From 96f88784a257320df3c53793502aeacb78820134 Mon Sep 17 00:00:00 2001 From: Peter Reijnders Date: Wed, 18 Jan 2017 09:08:41 +0100 Subject: [PATCH 01/23] Changed formatting style from Mozilla to file --- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) mode change 100644 => 100755 Makefile diff --git a/Makefile b/Makefile old mode 100644 new mode 100755 index cb509da..c497d75 --- a/Makefile +++ b/Makefile @@ -1,6 +1,7 @@ NODE=nodejs NPM=npm -CLANGFORMAT=clang-format-3.5 -style=Mozilla +CLANGFORMAT=clang-format-3.5 -style=file + PROJECT=./examples/Hello.idl OUTPUT_DIR=./output/Hello From 354c4cd50587af9af77f8bb92f3a25442183d39b Mon Sep 17 00:00:00 2001 From: Peter Reijnders Date: Wed, 18 Jan 2017 10:13:15 +0100 Subject: [PATCH 02/23] Moved files around --- Makefile | 29 --------- config.mk | 23 +++++++ examples/Hello/.gitignore | 1 + examples/{ => Hello}/Hello.idl | 3 +- examples/Hello/Makefile | 11 ++++ _clang-format => examples/_clang-format | 28 ++++---- examples/common.mk | 21 ++++++ parse.js | 87 +++++++++++++++++++++---- types_mapping.json | 62 ------------------ 9 files changed, 146 insertions(+), 119 deletions(-) delete mode 100755 Makefile create mode 100644 config.mk create mode 100644 examples/Hello/.gitignore rename examples/{ => Hello}/Hello.idl (79%) mode change 100644 => 100755 create mode 100755 examples/Hello/Makefile rename _clang-format => examples/_clang-format (79%) create mode 100644 examples/common.mk delete mode 100644 types_mapping.json diff --git a/Makefile b/Makefile deleted file mode 100755 index c497d75..0000000 --- a/Makefile +++ /dev/null @@ -1,29 +0,0 @@ -NODE=nodejs -NPM=npm -CLANGFORMAT=clang-format-3.5 -style=file - - -PROJECT=./examples/Hello.idl -OUTPUT_DIR=./output/Hello -TEMPLATE_DIR=./templates - -TEMPLATES=$(shell find $(TEMPLATE_DIR) -type f) -TARGET=$(OUTPUT_DIR)/base_Hello.h - -all: $(TARGET) - -setup: package.json - @$(NPM) install - -$(TARGET): parse.js $(PROJECT) $(TEMPLATES) - @echo "creating" - @$(NODE) parse.js $(PROJECT) $(TEMPLATE_DIR) $(OUTPUT_DIR) - @echo "formatting" - @$(CLANGFORMAT) -i $(OUTPUT_DIR)/* - - -.PHONY: clean - -clean: - @echo "cleaning" - @rm -rf $(shell find $(OUTPUT_DIR)/ -type f) diff --git a/config.mk b/config.mk new file mode 100644 index 0000000..525c448 --- /dev/null +++ b/config.mk @@ -0,0 +1,23 @@ + +BIN_CLANGFORMAT := $(shell command -v clang-format-3.5 2> /dev/null) +BIN_NPM := $(shell command -v npm 2> /dev/null) +BIN_NODEJS := $(shell command -v nodejs 2> /dev/null) + +ifndef BIN_CLANGFORMAT + $(error "clang-format-3.5 is not available. Please install") +endif + +ifndef BIN_NPM + $(error "npm is not available. Please install") +endif + +ifndef BIN_NODEJS + $(error "nodejs is not available. Please install") +endif + +.PHONY: setup + +setup: package.json + @$(BIN_NPM) install + @echo "All node dependencies are installed; Have a look at the examples" + diff --git a/examples/Hello/.gitignore b/examples/Hello/.gitignore new file mode 100644 index 0000000..53752db --- /dev/null +++ b/examples/Hello/.gitignore @@ -0,0 +1 @@ +output diff --git a/examples/Hello.idl b/examples/Hello/Hello.idl old mode 100644 new mode 100755 similarity index 79% rename from examples/Hello.idl rename to examples/Hello/Hello.idl index d57d947..d5bbdd7 --- a/examples/Hello.idl +++ b/examples/Hello/Hello.idl @@ -5,7 +5,7 @@ };*/ [ - Constructor(cstring ip, unsigned short port), + Constructor(cstring ip, (unsigned short or cstring) port), className=Hello ] interface Hello { @@ -14,4 +14,3 @@ }; - diff --git a/examples/Hello/Makefile b/examples/Hello/Makefile new file mode 100755 index 0000000..d1a43f0 --- /dev/null +++ b/examples/Hello/Makefile @@ -0,0 +1,11 @@ +PROJECT=./Hello.idl +OUTPUT_DIR=./output + +TARGET=$(OUTPUT_DIR)/base_Hello.h + +all: $(TARGET) + + +include ../common.mk + + diff --git a/_clang-format b/examples/_clang-format similarity index 79% rename from _clang-format rename to examples/_clang-format index 8c69764..d2a24e6 100644 --- a/_clang-format +++ b/examples/_clang-format @@ -1,23 +1,23 @@ # BasedOnStyle: WebKit AccessModifierOffset: -4 -AlignAfterOpenBracket: true -AlignConsecutiveAssignments: true +#AlignAfterOpenBracket: true +#AlignConsecutiveAssignments: true AlignEscapedNewlinesLeft: true -AlignOperands: true +#AlignOperands: true AlignTrailingComments: true AllowAllParametersOfDeclarationOnNextLine: true AllowShortBlocksOnASingleLine: false -AllowShortCaseLabelsOnASingleLine: false +#AllowShortCaseLabelsOnASingleLine: false AllowShortFunctionsOnASingleLine: None AllowShortIfStatementsOnASingleLine: true AllowShortLoopsOnASingleLine: false -AlwaysBreakAfterDefinitionReturnType: None +#AlwaysBreakAfterDefinitionReturnType: None AlwaysBreakBeforeMultilineStrings: true AlwaysBreakTemplateDeclarations: true -BinPackArguments: true -BinPackParameters: false -BreakBeforeBinaryOperators: All -BreakBeforeBraces: Mozilla +#BinPackArguments: true +#BinPackParameters: false +BreakBeforeBinaryOperators: false +BreakBeforeBraces: GNU BreakBeforeTernaryOperators: true BreakConstructorInitializersBeforeComma: false ColumnLimit: 80 @@ -34,11 +34,11 @@ IndentCaseLabels: true IndentWidth: 4 IndentWrappedFunctionNames: false KeepEmptyLinesAtTheStartOfBlocks: true -MacroBlockBegin: '' -MacroBlockEnd: '' +#MacroBlockBegin: '' +#MacroBlockEnd: '' MaxEmptyLinesToKeep: 2 NamespaceIndentation: None -ObjCBlockIndentWidth: 4 +#ObjCBlockIndentWidth: 4 ObjCSpaceAfterProperty: true ObjCSpaceBeforeProtocolList: true PenaltyBreakBeforeFirstCallParameter: 19 @@ -48,7 +48,7 @@ PenaltyBreakString: 1000 PenaltyExcessCharacter: 1000000 PenaltyReturnTypeOnItsOwnLine: 60 PointerAlignment: Right -SpaceAfterCStyleCast: false +#SpaceAfterCStyleCast: false SpaceBeforeAssignmentOperators: true SpaceBeforeParens: ControlStatements SpaceInEmptyParentheses: false @@ -57,7 +57,7 @@ SpacesInAngles: false SpacesInContainerLiterals: true SpacesInCStyleCastParentheses: false SpacesInParentheses: false -SpacesInSquareBrackets: false +#SpacesInSquareBrackets: false Standard: Cpp11 TabWidth: 8 UseTab: Never diff --git a/examples/common.mk b/examples/common.mk new file mode 100644 index 0000000..787c0ac --- /dev/null +++ b/examples/common.mk @@ -0,0 +1,21 @@ +include ../../config.mk + +PARSE=../../parse.js + +TEMPLATE_DIR=../../templates +TEMPLATES=$(shell find $(TEMPLATE_DIR) -type f) + +$(OUTPUT_DIR): + mkdir -p $(OUTPUT_DIR) + +$(TARGET): $(PARSE) $(PROJECT) $(TEMPLATES) $(OUTPUT_DIR) ../_clang-format + @echo "creating $@" + @$(BIN_NODEJS) $(PARSE) $(PROJECT) $(TEMPLATE_DIR) $(OUTPUT_DIR) + @echo "formatting $@" + @$(BIN_CLANGFORMAT) -style=file -i $(OUTPUT_DIR)/* + +.PHONY: clean + +clean: + @echo "cleaning" + @rm -rf $(shell find $(OUTPUT_DIR)/ -type f) diff --git a/parse.js b/parse.js index fe2dfbb..93df084 100644 --- a/parse.js +++ b/parse.js @@ -4,10 +4,72 @@ var nunjucks = require('nunjucks'); var fs = require('fs'); var util = require("util"); +var mapping = { + "boolean": { + "c": "bool", + "convert": "ToBoolean", + "jsval": "boolean" + }, + + "cstring": { + "c": "char *", + "jsval": "string" + }, + + "byte": { + "c": "int8_t", + "convert": "ToInt16" + }, + + "octet": { + "c": "uint8_t", + "convert": "ToUint16" + }, + + "short": { + "c": "int16_t", + "convert": "ToInt16" + }, + + "unsigned short": { + "c": "uint16_t", + "convert": "ToUint16" + }, + + "long": { + "c": "int32_t", + "convert": "ToInt32" + }, + + "unsigned long": { + "c": "uint32_t", + "convert": "ToUint32" + }, + + "long long": { + "c": "int64_t", + "convert": "ToInt64" + }, + + "unsigned long long": { + "c": "uint64_t", + "convert": "ToUint64" + }, + + "float": { + "c": "double", + "convert": "ToNumber" + }, + + "double": { + "c": "double", + "convert": "ToNumber" + } +} -var NidiumIDL = function(file) { +var NidiumIDL = function(file, templatePath) { - this.env = nunjucks.configure({ + this.env = nunjucks.configure(templatePath, { trimBlocks: true, lstripBlocks: true }); @@ -33,7 +95,8 @@ var NidiumIDL = function(file) { } NidiumIDL.prototype.loadConf = function() { - this.typeMapping = JSON.parse(fs.readFileSync("./types_mapping.json", {encoding: "utf8"})); + this.typeMapping = mapping; + //this.typeMapping = JSON.parse(fs.readFileSync("./types_mapping.json", {encoding: "utf8"})); } NidiumIDL.prototype.parse = function() { @@ -44,23 +107,23 @@ NidiumIDL.prototype.printTree = function() { console.log(util.inspect(this.tree, {colors: true, depth: 16})); } -NidiumIDL.prototype.generate = function(templatePath, outputPath) { +NidiumIDL.prototype.generate = function(outputPath) { for (var i = 0; i < this.tree.length; i++) { var obj = this.tree[i]; switch(obj.type) { case 'interface': - this.createInterface(templatePath, outputPath, obj); + this.createInterface(outputPath, obj); break; case 'dictionary': - this.createDict(templatePath, outputPath, obj); + this.createDict(outputPath, obj); break; } } } -NidiumIDL.prototype.createInterface = function(templatePath, outputPath, obj) +NidiumIDL.prototype.createInterface = function(outputPath, obj) { /* Scan for constructor @@ -104,7 +167,7 @@ NidiumIDL.prototype.createInterface = function(templatePath, outputPath, obj) obj.operations = operations; //console.log(obj.operations); - var interfaceHeader = this.env.render(templatePath + '/base_class.tpl.h', obj); + var interfaceHeader = this.env.render('base_class.tpl.h', obj); var fileName = outputPath + "/base_" + obj.className + ".h"; fs.writeFile(fileName, interfaceHeader, function(err) { if (err) { @@ -114,8 +177,8 @@ NidiumIDL.prototype.createInterface = function(templatePath, outputPath, obj) }); } -NidiumIDL.prototype.createDict = function(templatePath, outputPath, obj) { - var dictHeader = this.env.render(templatePath + '/dict_class.h', obj); +NidiumIDL.prototype.createDict = function(outputPath, obj) { + var dictHeader = this.env.render('dict_class.h', obj); var fileName = outputPath + "/dict_" + obj.className + ".h"; fs.writeFile(fileName, dictHeader, function(err) { if (err) { @@ -128,8 +191,8 @@ NidiumIDL.prototype.createDict = function(templatePath, outputPath, obj) { if (process.argv.length < 5) { console.log("Usage : " + process.argv[0] + " " + process.argv[1] + " idlfile templatepath outputpath\n"); } else { - var idl = new NidiumIDL(process.argv[2]); + var idl = new NidiumIDL(process.argv[2], process.argv[3]); idl.parse(); //idl.printTree(); - idl.generate(process.argv[3], process.argv[4]); + idl.generate(process.argv[4]); } diff --git a/types_mapping.json b/types_mapping.json deleted file mode 100644 index 07cbfe7..0000000 --- a/types_mapping.json +++ /dev/null @@ -1,62 +0,0 @@ -{ - "boolean": { - "c": "bool", - "convert": "ToBoolean", - "jsval": "boolean" - }, - - "cstring": { - "c": "char *", - "jsval": "string" - }, - - "byte": { - "c": "int8_t", - "convert": "ToInt16" - }, - - "octet": { - "c": "uint8_t", - "convert": "ToUint16" - }, - - "short": { - "c": "int16_t", - "convert": "ToInt16" - }, - - "unsigned short": { - "c": "uint16_t", - "convert": "ToUint16" - }, - - "long": { - "c": "int32_t", - "convert": "ToInt32" - }, - - "unsigned long": { - "c": "uint32_t", - "convert": "ToUint32" - }, - - "long long": { - "c": "int64_t", - "convert": "ToInt64" - }, - - "unsigned long long": { - "c": "uint64_t", - "convert": "ToUint64" - }, - - "float": { - "c": "double", - "convert": "ToNumber" - }, - - "double": { - "c": "double", - "convert": "ToNumber" - } -} \ No newline at end of file From 84ddce8efb5984bbd11a29d9c6a01a409b005ee0 Mon Sep 17 00:00:00 2001 From: Peter Reijnders Date: Wed, 18 Jan 2017 10:28:44 +0100 Subject: [PATCH 03/23] Renamed output directory to cpp --- examples/Hello/.gitignore | 2 +- examples/Hello/Makefile | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/Hello/.gitignore b/examples/Hello/.gitignore index 53752db..80a53cd 100644 --- a/examples/Hello/.gitignore +++ b/examples/Hello/.gitignore @@ -1 +1 @@ -output +cpp diff --git a/examples/Hello/Makefile b/examples/Hello/Makefile index d1a43f0..b83bcf1 100755 --- a/examples/Hello/Makefile +++ b/examples/Hello/Makefile @@ -1,5 +1,5 @@ PROJECT=./Hello.idl -OUTPUT_DIR=./output +OUTPUT_DIR=./cpp TARGET=$(OUTPUT_DIR)/base_Hello.h From abe42f5da3d613671b4448b12eca48a2dffb806e Mon Sep 17 00:00:00 2001 From: Peter Reijnders Date: Wed, 18 Jan 2017 10:32:51 +0100 Subject: [PATCH 04/23] Moved idl file into idl directory --- examples/Hello/Makefile | 3 ++- examples/Hello/{ => idl}/Hello.idl | 0 2 files changed, 2 insertions(+), 1 deletion(-) rename examples/Hello/{ => idl}/Hello.idl (100%) diff --git a/examples/Hello/Makefile b/examples/Hello/Makefile index b83bcf1..ddf86d9 100755 --- a/examples/Hello/Makefile +++ b/examples/Hello/Makefile @@ -1,5 +1,6 @@ -PROJECT=./Hello.idl +INPUT_DIR=./idl OUTPUT_DIR=./cpp +PROJECT=$(INPUT_DIR)/Hello.idl TARGET=$(OUTPUT_DIR)/base_Hello.h diff --git a/examples/Hello/Hello.idl b/examples/Hello/idl/Hello.idl similarity index 100% rename from examples/Hello/Hello.idl rename to examples/Hello/idl/Hello.idl From 70c3a38a65676d7a003f14d72edf4c138a1bb8b7 Mon Sep 17 00:00:00 2001 From: Peter Reijnders Date: Wed, 18 Jan 2017 10:55:36 +0100 Subject: [PATCH 05/23] Preparations for multiple file creation and easier setup. --- examples/Hello/Makefile | 2 +- examples/common.mk | 10 +++++----- parse.js | 15 ++++++++++----- 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/examples/Hello/Makefile b/examples/Hello/Makefile index ddf86d9..59feb20 100755 --- a/examples/Hello/Makefile +++ b/examples/Hello/Makefile @@ -1,6 +1,6 @@ INPUT_DIR=./idl OUTPUT_DIR=./cpp -PROJECT=$(INPUT_DIR)/Hello.idl +#PROJECT=$(INPUT_DIR)/Hello.idl TARGET=$(OUTPUT_DIR)/base_Hello.h diff --git a/examples/common.mk b/examples/common.mk index 787c0ac..77f7d51 100644 --- a/examples/common.mk +++ b/examples/common.mk @@ -8,11 +8,11 @@ TEMPLATES=$(shell find $(TEMPLATE_DIR) -type f) $(OUTPUT_DIR): mkdir -p $(OUTPUT_DIR) -$(TARGET): $(PARSE) $(PROJECT) $(TEMPLATES) $(OUTPUT_DIR) ../_clang-format - @echo "creating $@" - @$(BIN_NODEJS) $(PARSE) $(PROJECT) $(TEMPLATE_DIR) $(OUTPUT_DIR) - @echo "formatting $@" - @$(BIN_CLANGFORMAT) -style=file -i $(OUTPUT_DIR)/* +$(OUTPUT_DIR)/base_%.h: $(INPUT_DIR)/%.idl $(PARSE) $(TEMPLATES) $(OUTPUT_DIR) ../_clang-format + $(eval CMD = $(BIN_NODEJS) $(PARSE) $< $(TEMPLATE_DIR) $(OUTPUT_DIR)) + @echo "$(CMD)" + $(eval CREATED = $(shell $(CMD))) + $(BIN_CLANGFORMAT) -style=file -i $(CREATED) .PHONY: clean diff --git a/parse.js b/parse.js index 93df084..d38ebe0 100644 --- a/parse.js +++ b/parse.js @@ -108,18 +108,20 @@ NidiumIDL.prototype.printTree = function() { } NidiumIDL.prototype.generate = function(outputPath) { + var created_files = []; for (var i = 0; i < this.tree.length; i++) { var obj = this.tree[i]; switch(obj.type) { case 'interface': - this.createInterface(outputPath, obj); + created_files.push(this.createInterface(outputPath, obj)); break; case 'dictionary': - this.createDict(outputPath, obj); + create_files.push(this.createDict(outputPath, obj)); break; } } + return created_files; } @@ -173,8 +175,9 @@ NidiumIDL.prototype.createInterface = function(outputPath, obj) if (err) { return console.log(err); } - console.log("Wrote " + fileName); + //console.log("Wrote " + fileName); }); + return fileName; } NidiumIDL.prototype.createDict = function(outputPath, obj) { @@ -184,8 +187,9 @@ NidiumIDL.prototype.createDict = function(outputPath, obj) { if (err) { return console.log(err); } - console.log("Wrote " + fileName); + //console.log("Wrote " + fileName); }); + return fileName; } if (process.argv.length < 5) { @@ -194,5 +198,6 @@ if (process.argv.length < 5) { var idl = new NidiumIDL(process.argv[2], process.argv[3]); idl.parse(); //idl.printTree(); - idl.generate(process.argv[4]); + var created = idl.generate(process.argv[4]); + console.log(created.join(" ")); } From 7d7b4d025bd24e8b1f4520c27a1304f56412ca25 Mon Sep 17 00:00:00 2001 From: Peter Reijnders Date: Wed, 18 Jan 2017 11:12:13 +0100 Subject: [PATCH 06/23] Automatically process all idl input files. --- examples/Hello/Makefile | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/examples/Hello/Makefile b/examples/Hello/Makefile index 59feb20..210411b 100755 --- a/examples/Hello/Makefile +++ b/examples/Hello/Makefile @@ -1,12 +1,17 @@ INPUT_DIR=./idl OUTPUT_DIR=./cpp -#PROJECT=$(INPUT_DIR)/Hello.idl -TARGET=$(OUTPUT_DIR)/base_Hello.h +INPUT_FILES = $(shell find $(INPUT_DIR) -type f -name '*.idl') -all: $(TARGET) +TARGETS = $(addprefix \ + $(join $(OUTPUT_DIR)/, base_), \ + $(addsuffix .h, $(basename \ + $(notdir $(INPUT_FILES) ) \ + ) \ + ) \ + ) +all: $(TARGETS) include ../common.mk - From c1abeec34121894d2dede96d812980eb214bdcb7 Mon Sep 17 00:00:00 2001 From: Peter Reijnders Date: Wed, 18 Jan 2017 11:24:17 +0100 Subject: [PATCH 07/23] Renamed example/Hello to example/Demo --- examples/{Hello => Demo}/.gitignore | 0 examples/{Hello => Demo}/Makefile | 0 examples/{Hello => Demo}/idl/Hello.idl | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename examples/{Hello => Demo}/.gitignore (100%) rename examples/{Hello => Demo}/Makefile (100%) rename examples/{Hello => Demo}/idl/Hello.idl (100%) diff --git a/examples/Hello/.gitignore b/examples/Demo/.gitignore similarity index 100% rename from examples/Hello/.gitignore rename to examples/Demo/.gitignore diff --git a/examples/Hello/Makefile b/examples/Demo/Makefile similarity index 100% rename from examples/Hello/Makefile rename to examples/Demo/Makefile diff --git a/examples/Hello/idl/Hello.idl b/examples/Demo/idl/Hello.idl similarity index 100% rename from examples/Hello/idl/Hello.idl rename to examples/Demo/idl/Hello.idl From e14c8f1d76b4a3aa17474bd702f08f46400af221 Mon Sep 17 00:00:00 2001 From: Peter Reijnders Date: Wed, 18 Jan 2017 11:24:55 +0100 Subject: [PATCH 08/23] Take the correct classname to generate the file and handle constructor arguments. --- parse.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/parse.js b/parse.js index d38ebe0..611b658 100644 --- a/parse.js +++ b/parse.js @@ -131,7 +131,6 @@ NidiumIDL.prototype.createInterface = function(outputPath, obj) Scan for constructor */ obj.ctor = false; - var constructors = { maxArgs: 0, lst: [] @@ -142,7 +141,8 @@ NidiumIDL.prototype.createInterface = function(outputPath, obj) if (attr.name == 'Constructor') { obj.ctor = true; constructors.lst.push(attr); - constructors.maxArgs = Math.max(constructors.maxArgs, attr.arguments.length); + var curArg = (attr.arguments) ? attr.arguments.length : 0; + constructors.maxArgs = Math.max(constructors.maxArgs, curArg); continue; } @@ -150,6 +150,9 @@ NidiumIDL.prototype.createInterface = function(outputPath, obj) obj.className = attr.rhs.value; } } + if (! obj.className) { + obj.className = obj.name; + } var operations = {}; From 9cc4dcddd154136de5274332257a1993813aa2e7 Mon Sep 17 00:00:00 2001 From: Peter Reijnders Date: Wed, 18 Jan 2017 11:25:20 +0100 Subject: [PATCH 09/23] Add another demo (Fragment) --- examples/Demo/idl/Fragment.idl | 27 +++++++++++++++++++++++++++ examples/Demo/idl/Hello.idl | 0 2 files changed, 27 insertions(+) create mode 100644 examples/Demo/idl/Fragment.idl mode change 100755 => 100644 examples/Demo/idl/Hello.idl diff --git a/examples/Demo/idl/Fragment.idl b/examples/Demo/idl/Fragment.idl new file mode 100644 index 0000000..5a8de16 --- /dev/null +++ b/examples/Demo/idl/Fragment.idl @@ -0,0 +1,27 @@ +exception GraphicsException { + DOMString reason; +}; + +interface Paint { }; + +interface SolidColor : Paint { + attribute float red; + attribute float green; + attribute float blue; +}; + +interface Pattern : Paint { + attribute DOMString imageURL; +}; + +[Constructor] +interface GraphicalWindow { + readonly attribute unsigned long width; + readonly attribute unsigned long height; + + attribute Paint currentPaint; + + void drawRectangle(float x, float y, float width, float height); + + void drawText(float x, float y, DOMString text); +}; diff --git a/examples/Demo/idl/Hello.idl b/examples/Demo/idl/Hello.idl old mode 100755 new mode 100644 From 91339d017c5eb08148348fb38caa3f1912b60b14 Mon Sep 17 00:00:00 2001 From: Peter Reijnders Date: Wed, 18 Jan 2017 11:48:15 +0100 Subject: [PATCH 10/23] Renamed 'base_*' templates to 'impl_*' --- examples/Demo/Makefile | 4 +++- examples/common.mk | 2 +- parse.js | 6 +++--- templates/{dict_class.h => dict_class.tpl.h} | 0 templates/{base_class.cpp => impl_class.tpl.cpp} | 0 templates/{base_class.tpl.h => impl_class.tpl.h} | 0 6 files changed, 7 insertions(+), 5 deletions(-) rename templates/{dict_class.h => dict_class.tpl.h} (100%) rename templates/{base_class.cpp => impl_class.tpl.cpp} (100%) rename templates/{base_class.tpl.h => impl_class.tpl.h} (100%) diff --git a/examples/Demo/Makefile b/examples/Demo/Makefile index 210411b..b2c0d17 100755 --- a/examples/Demo/Makefile +++ b/examples/Demo/Makefile @@ -1,10 +1,11 @@ INPUT_DIR=./idl OUTPUT_DIR=./cpp +IMPL_PREFIX=sm_JS_ INPUT_FILES = $(shell find $(INPUT_DIR) -type f -name '*.idl') TARGETS = $(addprefix \ - $(join $(OUTPUT_DIR)/, base_), \ + $(join $(OUTPUT_DIR)/, $(IMPL_PREFIX)), \ $(addsuffix .h, $(basename \ $(notdir $(INPUT_FILES) ) \ ) \ @@ -12,6 +13,7 @@ TARGETS = $(addprefix \ ) all: $(TARGETS) + @echo $(TARGETS) include ../common.mk diff --git a/examples/common.mk b/examples/common.mk index 77f7d51..62e0caf 100644 --- a/examples/common.mk +++ b/examples/common.mk @@ -8,7 +8,7 @@ TEMPLATES=$(shell find $(TEMPLATE_DIR) -type f) $(OUTPUT_DIR): mkdir -p $(OUTPUT_DIR) -$(OUTPUT_DIR)/base_%.h: $(INPUT_DIR)/%.idl $(PARSE) $(TEMPLATES) $(OUTPUT_DIR) ../_clang-format +$(OUTPUT_DIR)/$(IMPL_PREFIX)%.h: $(INPUT_DIR)/%.idl $(PARSE) $(TEMPLATES) $(OUTPUT_DIR) ../_clang-format $(eval CMD = $(BIN_NODEJS) $(PARSE) $< $(TEMPLATE_DIR) $(OUTPUT_DIR)) @echo "$(CMD)" $(eval CREATED = $(shell $(CMD))) diff --git a/parse.js b/parse.js index 611b658..f45d6b9 100644 --- a/parse.js +++ b/parse.js @@ -172,8 +172,8 @@ NidiumIDL.prototype.createInterface = function(outputPath, obj) obj.operations = operations; //console.log(obj.operations); - var interfaceHeader = this.env.render('base_class.tpl.h', obj); - var fileName = outputPath + "/base_" + obj.className + ".h"; + var interfaceHeader = this.env.render('impl_class.tpl.h', obj); + var fileName = outputPath + "/impl_" + obj.className + ".h"; fs.writeFile(fileName, interfaceHeader, function(err) { if (err) { return console.log(err); @@ -184,7 +184,7 @@ NidiumIDL.prototype.createInterface = function(outputPath, obj) } NidiumIDL.prototype.createDict = function(outputPath, obj) { - var dictHeader = this.env.render('dict_class.h', obj); + var dictHeader = this.env.render('dict_class.tpl.h', obj); var fileName = outputPath + "/dict_" + obj.className + ".h"; fs.writeFile(fileName, dictHeader, function(err) { if (err) { diff --git a/templates/dict_class.h b/templates/dict_class.tpl.h similarity index 100% rename from templates/dict_class.h rename to templates/dict_class.tpl.h diff --git a/templates/base_class.cpp b/templates/impl_class.tpl.cpp similarity index 100% rename from templates/base_class.cpp rename to templates/impl_class.tpl.cpp diff --git a/templates/base_class.tpl.h b/templates/impl_class.tpl.h similarity index 100% rename from templates/base_class.tpl.h rename to templates/impl_class.tpl.h From 076d06189efb1efbb2e4f38966883846d64279e8 Mon Sep 17 00:00:00 2001 From: Peter Reijnders Date: Wed, 18 Jan 2017 11:52:55 +0100 Subject: [PATCH 11/23] Generate the cpp code based on the template. --- parse.js | 29 +++++++++++++++++++++-------- templates/impl_class.tpl.cpp | 4 ++-- 2 files changed, 23 insertions(+), 10 deletions(-) diff --git a/parse.js b/parse.js index f45d6b9..d672ccb 100644 --- a/parse.js +++ b/parse.js @@ -114,13 +114,14 @@ NidiumIDL.prototype.generate = function(outputPath) { switch(obj.type) { case 'interface': - created_files.push(this.createInterface(outputPath, obj)); + created_files = created_files.concat(this.createInterface(outputPath, obj)); break; case 'dictionary': - create_files.push(this.createDict(outputPath, obj)); + create_files = created_files.concat(this.createDict(outputPath, obj)); break; } } + return created_files; } @@ -135,6 +136,7 @@ NidiumIDL.prototype.createInterface = function(outputPath, obj) maxArgs: 0, lst: [] }; + var fileNames = []; for (var i = 0; i < obj.extAttrs.length; i++) { var attr = obj.extAttrs[i]; @@ -173,26 +175,37 @@ NidiumIDL.prototype.createInterface = function(outputPath, obj) //console.log(obj.operations); var interfaceHeader = this.env.render('impl_class.tpl.h', obj); - var fileName = outputPath + "/impl_" + obj.className + ".h"; - fs.writeFile(fileName, interfaceHeader, function(err) { + var fileNameHeader = outputPath + "/impl_" + obj.className + ".h"; + fileNames.push(fileNameHeader); + fs.writeFile(fileNameHeader, interfaceHeader, function(err) { if (err) { return console.log(err); } - //console.log("Wrote " + fileName); }); - return fileName; + var interfaceCode = this.env.render('impl_class.tpl.cpp', obj); + var fileNameCode = outputPath + "/impl_" + obj.className + ".cpp"; + fileNames.push(fileNameCode); + fs.writeFile(fileNameCode, interfaceCode, function(err) { + if (err) { + return console.log(err); + } + }); + + return fileNames; } NidiumIDL.prototype.createDict = function(outputPath, obj) { + var fileNames = []; var dictHeader = this.env.render('dict_class.tpl.h', obj); var fileName = outputPath + "/dict_" + obj.className + ".h"; + fileNames.push(fileName); fs.writeFile(fileName, dictHeader, function(err) { if (err) { return console.log(err); } - //console.log("Wrote " + fileName); }); - return fileName; + + return fileNames; } if (process.argv.length < 5) { diff --git a/templates/impl_class.tpl.cpp b/templates/impl_class.tpl.cpp index 81a0407..47a92d1 100644 --- a/templates/impl_class.tpl.cpp +++ b/templates/impl_class.tpl.cpp @@ -6,9 +6,9 @@ namespace Nidium { namespace Binding { -// {{{ Class {{ classname }} +{% raw %}// Class {{{ {% endraw %} {{name}} -// }}} +{% raw %}// }}} {% endraw %} } // namespace Binding } // namespace Nidium From 5bb01c05114a516cb3a2b056d35512c8552d22ab Mon Sep 17 00:00:00 2001 From: Peter Reijnders Date: Wed, 18 Jan 2017 12:06:17 +0100 Subject: [PATCH 12/23] style --- templates/dict_class.tpl.h | 54 ++++++++++++++++++------------------ templates/impl_class.tpl.cpp | 1 + 2 files changed, 28 insertions(+), 27 deletions(-) diff --git a/templates/dict_class.tpl.h b/templates/dict_class.tpl.h index 28fab6f..14ecc87 100644 --- a/templates/dict_class.tpl.h +++ b/templates/dict_class.tpl.h @@ -11,12 +11,12 @@ class Dict_{{name}} : public Dict public: Dict_{{name}}() { {% for attr in members %} - {% set type = attr.idlType.idlType %} - {% if type == 'cstring' %} - m_{{attr.name}} = {% if not attr.default %}NULL{%else%}strdup("{{ attr.default.value }}"){%endif%}; - {% else %} - m_{{attr.name}} = {% if not attr.default %}NULL{%else%}{{ attr.default.value }}{%endif%}; - {% endif %} + {% set type = attr.idlType.idlType %} + {% if type == 'cstring' %} + m_{{attr.name}} = {% if not attr.default %}NULL{%else%}strdup("{{ attr.default.value }}"){%endif%}; + {% else %} + m_{{attr.name}} = {% if not attr.default %}NULL{%else%}{{ attr.default.value }}{%endif%}; + {% endif %} {% endfor %} } @@ -32,38 +32,38 @@ class Dict_{{name}} : public Dict JS::RootedObject curobj(cx, &v.toObject()); JS::RootedValue curopt(cx); {% for attr in members %} - {% set type = attr.idlType.idlType %} + {% set type = attr.idlType.idlType %} - if (!JS_GetProperty(cx, curobj, "{{ attr.name }}", &curopt)) { - return false; - } else { - {% if type == 'cstring' %} - JS::RootedString curstr(cx, JS::ToString(cx, curopt)); - JSAutoByteString c_curstr(cx, curstr); - - m_{{attr.name}} = strdup(c_curstr.ptr()); - {% elif type == 'unsigned short' %} - if (!JS::ToUint16(cx, curopt, &m_{{attr.name}})) { + if (!JS_GetProperty(cx, curobj, "{{ attr.name }}", &curopt)) { return false; + } else { + {% if type == 'cstring' %} + JS::RootedString curstr(cx, JS::ToString(cx, curopt)); + JSAutoByteString c_curstr(cx, curstr); + + m_{{attr.name}} = strdup(c_curstr.ptr()); + {% elif type == 'unsigned short' %} + if (!JS::ToUint16(cx, curopt, &m_{{attr.name}})) { + return false; + } + {% endif %} } - {% endif %} - } - {% endfor %} + {% endfor %} return true; } {% for attr in members %} - {% set type = attr.idlType.idlType %} - const {{type|ctype}} {{attr.name}}() const { - return m_{{attr.name}}; - } - + {% set type = attr.idlType.idlType %} + const {{type|ctype}} {{attr.name}}() const { + return m_{{attr.name}}; + } {% endfor %} + private: {% for attr in members %} - {% set type = attr.idlType.idlType %} - {{ type|ctype }} m_{{attr.name}}; + {% set type = attr.idlType.idlType %} + {{ type|ctype }} m_{{attr.name}}; {% endfor %} }; {% raw %}// }}} {% endraw %} diff --git a/templates/impl_class.tpl.cpp b/templates/impl_class.tpl.cpp index 47a92d1..ccc6a59 100644 --- a/templates/impl_class.tpl.cpp +++ b/templates/impl_class.tpl.cpp @@ -10,5 +10,6 @@ namespace Binding { {% raw %}// }}} {% endraw %} + } // namespace Binding } // namespace Nidium From e87c61e28594a19e6e8cfd732bb4f55ba3174c54 Mon Sep 17 00:00:00 2001 From: Peter Reijnders Date: Wed, 18 Jan 2017 16:35:30 +0100 Subject: [PATCH 13/23] Transferred research from NidiumTools:idl_classmapper branch. --- parse.js | 34 +++- templates/defs.tpl | 40 +++++ templates/dict_class.tpl.h | 33 ++-- templates/impl_class.tpl.cpp | 239 ++++++++++++++++++++++++++- templates/impl_class.tpl.h | 312 +++++++++++++---------------------- 5 files changed, 426 insertions(+), 232 deletions(-) create mode 100644 templates/defs.tpl diff --git a/parse.js b/parse.js index d672ccb..feb1b93 100644 --- a/parse.js +++ b/parse.js @@ -111,7 +111,23 @@ NidiumIDL.prototype.generate = function(outputPath) { var created_files = []; for (var i = 0; i < this.tree.length; i++) { var obj = this.tree[i]; - + obj.getMethods = function(operations, thatAreStatic) { + statics = [] + for (var j = 0; j @@ -5,17 +7,17 @@ namespace Nidium { namespace Binding { -{% raw %}// {{{ {% endraw %} Dict_{{name}} -class Dict_{{name}} : public Dict +// {{ '{{{' }} Dict_{{ name }} +class Dict_{{ name }} : public Dict { public: - Dict_{{name}}() { + Dict_{{ name }}() { {% for attr in members %} {% set type = attr.idlType.idlType %} {% if type == 'cstring' %} - m_{{attr.name}} = {% if not attr.default %}NULL{%else%}strdup("{{ attr.default.value }}"){%endif%}; + m_{{ attr.name }} = {{ 'NULL' if not attr.default else "strdup(" + attr.default.value + ");" }} {% else %} - m_{{attr.name}} = {% if not attr.default %}NULL{%else%}{{ attr.default.value }}{%endif%}; + m_{{ attr.name }} = {{ 'NULL' if not attr.default else attr.default.value }}; {% endif %} {% endfor %} } @@ -23,7 +25,6 @@ class Dict_{{name}} : public Dict /* TODO dtor */ - bool initWithJSVal(JSContext *cx, JS::HandleValue v) { if (!v.isObject()) { @@ -33,7 +34,6 @@ class Dict_{{name}} : public Dict JS::RootedValue curopt(cx); {% for attr in members %} {% set type = attr.idlType.idlType %} - if (!JS_GetProperty(cx, curobj, "{{ attr.name }}", &curopt)) { return false; } else { @@ -41,32 +41,31 @@ class Dict_{{name}} : public Dict JS::RootedString curstr(cx, JS::ToString(cx, curopt)); JSAutoByteString c_curstr(cx, curstr); - m_{{attr.name}} = strdup(c_curstr.ptr()); - {% elif type == 'unsigned short' %} - if (!JS::ToUint16(cx, curopt, &m_{{attr.name}})) { + m_{{ attr.name }} = strdup(c_curstr.ptr()); + {% elif type == 'unsigned_short' %} + if (!JS::ToUint16(cx, curopt, &m_{{ attr.name }})) { return false; } {% endif %} } - {% endfor %} + {% endfor %} return true; } - {% for attr in members %} {% set type = attr.idlType.idlType %} - const {{type|ctype}} {{attr.name}}() const { - return m_{{attr.name}}; + const {{ attr.name }} {{ attr.name }}() const { + return m_{{ attr.name }}; } {% endfor %} - private: {% for attr in members %} {% set type = attr.idlType.idlType %} - {{ type|ctype }} m_{{attr.name}}; + {{ type|ctype }} m_{{ attr.name }}; {% endfor %} }; -{% raw %}// }}} {% endraw %} +// {{ '}}}' }} } // namespace Binding } // namespace Nidium + diff --git a/templates/impl_class.tpl.cpp b/templates/impl_class.tpl.cpp index ccc6a59..70e9130 100644 --- a/templates/impl_class.tpl.cpp +++ b/templates/impl_class.tpl.cpp @@ -1,15 +1,244 @@ -#include -#include +/* + Copyright 2016 Nidium Inc. All rights reserved. + Use of this source code is governed by a MIT license + that can be found in the LICENSE file. +*/ -//#include "{{ classname }}.h" +{% import 'defs.tpl' as defs %} + +#include +#include "{{ className }}.h" namespace Nidium { namespace Binding { -{% raw %}// Class {{{ {% endraw %} {{name}} +// {{ '{{{' }} JSBinding + +{% if ctor %} + // {{ '{{{' }} Start Constructor + {{ className }} *{{ className }}::Constructor(JSContext *cx, JS::CallArgs &args, + JS::HandleObject obj) + { + unsigned argc = args.length(); + unsigned argcMin = (({{ constructors['maxArgs'] }} > argc) ? (argc) : ({{ constructors['maxArgs'] }})); + + switch (argcMin) { + {% for op in constructors.lst %} + case {{ op.arguments|length }}: + { + /* Start arguments conversion */ + {% for arg in op.arguments %} + /* Handle argument #{{ loop.index0 }} of type "{{ arg.idlType.idlType }}" */ + {% if not arg.idlType.nullable %} + if (args[{{ loop.index0 }}].isNull()) { + JS_ReportError(cx, "TypeError"); + return nullptr; + } + {% endif %} + {{ defs.jsval2c('args[' ~ loop.index0 ~ ']', arg.idlType.idlType, 'inArg_' ~ loop.index0 , 'nullptr') }} + {% endfor %} + /* End of arguments conversion */ + + {{ className }} *n_{{ className }} = new {{ className }}( + {% for i in range(0, op.arguments|length) %} + inArg_{{ i }}{{ ' ' if loop.last else ', ' }} + {% endfor %} + ); + n_{{ className }}->root(); + + return n_{{ className }}; + break; + } + {% endfor %} + default: + JS_ReportError(cx, "TypeError: wrong number of arguments"); + return nullptr; + break; + } + + return nullptr; + } + // {{ '}}}' }} End Constructor +{% endif %} + +{% set static_methods = getMethods(operations, true) %} +{% set normal_methods = getMethods(operations, false ) %} + +{% if normal_methods|length > 0 %} + // {{ '{{{' }} Start Operations + JSFunctionSpec * {{ className }}::ListMethods() + { + static JSFunctionSpec funcs[] = { + {% for attrName, attr in normal_methods %} + {% if hasAttr(attr.extAttrs, 'Alias') %} + CLASSMAPPER_FN_ALIAS({{ className }}, {{ attrName }}, {{ attr['maxArgs'] }}, {{ hasAttr( attr.extAttrs, 'Alias') }}), + {% endif %} + CLASSMAPPER_FN({{ className }}, {{ attrName }}, {{ attr['maxArgs'] }} ), + {% endfor %} + + JS_FS_END + }; + + return funcs; + } + {% endif %} + +{% if static_methods|length > 0 %} + // {{ '{{{' }} Start Operations + JSFunctionSpec * {{ className }}::ListStaticMethods() + { + static JSFunctionSpec funcs[] = { + {% for attrName, attr in static_methods %} + {% if hasAttr(attr.extAttrs, 'Alias') %} + CLASSMAPPER_FN_ALIAS({{ className }}, {{ attrName }}, {{ attr['maxArgs'] }}, {{ hasAttr(attr.extAttrs, 'Alias') }}), + {% endif %} + CLASSMAPPER_FN({{ className }}, {{ attrName }}, {{ attr['maxArgs'] }} ), + {% endfor %} + + JS_FS_END + }; + + return funcs; + } + + + {% for attrName, attr in operations %} + bool {{ className }}::JS_{{ attrName }}(JSContext *cx, JS::CallArgs &args) + { + unsigned argc = args.length(); + unsigned argcMin = (({{ attr['maxArgs'] }} > argc) ? (argc) : ({{ attr['maxArgs'] }})); + {#TODO: optimize when argcMin == 0 #} + switch (argcMin) { + {% for op in attr.lst %} + case {{ op.arguments|length }}: + { + /* Start arguments conversion */ + {% for arg in op.arguments %} + /* Handle argument #{{ loop.index0 }} of type "{{ arg.idlType.idlType }}" */ + {% if not arg.idlType.nullable %} + if (args[{{ loop.index0 }}].isNull()) { + JS_ReportError(cx, "TypeError"); + return false; + } + {% endif %} + {# TODO union-types #} + {% if arg.idlType.idlType != 'UNKNOWN' %} + {{ defs.jsval2c('args[' ~ loop.index0 ~ ']', arg.idlType.idlType, 'inArg_' ~ loop.index0) }} + {% else %} + {{ defs.jsval2c('args[' ~ loop.index0 ~ ']', arg.type, 'inArg_' ~ loop.index0) }} + {% endif %} + {% endfor %} + + /* End of arguments conversion */ + {% if op.return.idlType.idlType|ctype != 'void' %} + {{ op.return.idlType.idlType|ctype }} _opret = + {%endif %} + this->{{ attrName }}( + {% for i in range(0, op.arguments|length) %} + inArg_{{ i }}{{ ' ' if loop.last else ', ' }} + {% endfor %} + ); + {% if op.return.idlType.idlType != 'void' %} + args.rval().set{{ op.return.idlType.idlType|jsvaltype|capitalize }}(_opret); + {% endif %} + break; + } + {% endfor %} + default: + JS_ReportError(cx, "TypeError: wrong number of arguments"); + return false; + break; + } -{% raw %}// }}} {% endraw %} + return true; + } + {% endfor %} + + // {{ '}}}' }} End Operations + {% endif %} + +{% if members.length > 0 %} + // {{ '{{{' }} Start Members + JSPropertySpec *{{ className }}::ListProperties() + { + static JSPropertySpec props[] = { + {% for attr in members %} + {# TODO: ONLY-SETTER #} + {% if not attr.readonly %} + CLASSMAPPER_PROP_GS({{ className }}, {{ attr.name }}), + {% else %} + CLASSMAPPER_PROP_G({{ className }}, {{ attr.name }}), + {% endif %} + {% endfor %} + JS_PS_END + }; + + return props; + } + + + {% for attr in members %} + {% if not attr.readonly %} + bool {{ className }}::JSSetter_{{ attr.name }}(JSContext *cx, JS::MutableHandleValue vp) + { + {# TODO: uniontype#} + {{ attr.idlType }} + {{ defs.jsval2c('vp', attr.idlType.idlType, 'inArg_0') }} + + return this->set_{{ attr.name }}(inArg_0); + } + {% endif %} + + bool {{ className }}::JSGetter_{{ attr.name }}(JSContext *cx, JS::MutableHandleValue vp) + { + {% set need = attr.idlType.idlType %} + + {% if need == 'cstring' %} + JS::RootedString jstr(cx, JS_NewStringCopyZ(cx, this->get_{{ attr.name }}())); + vp.setString(jstr); + {% elif attr.idlType.idlType == 'UNKNOWN' %} + {# TODO InterfaceType {{ need.name }} {{attr.type.__class__}} #} + {% else %} + {{ need|ctype }} cval = this->get_{{ attr.name }}(); + JS::RootedValue jval(cx); + if (!JS::{{ need | convert }}(cx, jval, &cval)) { + JS_ReportError(cx, "TypeError"); + return false; + } + vp.set(jval); + {% endif %} + + return true; + } + {% endfor %} + +// {{ '}}}' }} End Members +{% endif %} + +{% if hasAttr(extAttrs, 'exposed') %} + void {{ className }}::RegisterObject(JSContext *cx) + { + {% if exposed == 'class' %} + {{ className }}::ExposeClass<{{ constructors['maxArgs'] }}>(cx, "{{ name }}"); + {# TODO: HAS_RESERVED_SLOTS #} + {% elif exposed == 'module' %} + JSModules::RegisterEmbedded("{{ className }}", {{ className }}::RegisterModule); + {% endif %} + } + + {% if exposed == 'module' %} + JSObject *{{ className }}::RegisterModule(JSContext *cx) + { + JS::RootedObject exports(cx, {{ className }}::ExposeObject(cx, "{{ name }}")); + + return exports; + } + {% endif %} + +{% endif %} +// {{ '}}}' }} } // namespace Binding } // namespace Nidium + diff --git a/templates/impl_class.tpl.h b/templates/impl_class.tpl.h index 166f2e2..71878df 100644 --- a/templates/impl_class.tpl.h +++ b/templates/impl_class.tpl.h @@ -1,225 +1,135 @@ -{% macro arglst(args) %} - {% for arg in args %}{{arg.idlType.idlType|ctype}} {{arg.name}}{{ ', ' if not loop.last }}{% endfor %} -{% endmacro %} - -{% macro jsval2c(jval, need, dest) %} - {% if need == 'cstring' %} - JS::RootedString __curstr(cx, JS::ToString(cx, {{jval}})); - if (!__curstr) { - JS_ReportError(cx, "TypeError"); - return false; - } - JSAutoByteString __curstr_c; - __curstr_c.encodeUtf8(cx, __curstr); - - char *{{dest}} = __curstr_c.ptr(); - {% else %} - {{need|ctype}} {{dest}}; - if (!JS::{{ need|convert }}(cx, {{jval}}, &{{dest}})) { - JS_ReportError(cx, "TypeError"); - return false; - } - {% endif %} -{% endmacro %} +/* + Copyright 2016 Nidium Inc. All rights reserved. + Use of this source code is governed by a MIT license + that can be found in the LICENSE file. +*/ +#include +#include +{% import "defs.tpl" as defs %} + +#ifndef binding_{{ className }}_h__ +#define binding_{{ className }}_h__ + +{% set header = hasAttr(extAttrs, 'headerfile') %} +{% if header %} +#include "{{ header.rhs.value }}.h" +{% endif %} -#pragma once -#include +#include "Binding/ClassMapper.h" namespace Nidium { namespace Binding { -{% raw %}// {{{ {% endraw %} {{ name }} +// {{ '{{{' }} fake {{ className }} -class Interface_{{name}} +/* +//This is a model of our imaginary base class '{{ className }}' + +class {{ className }}_Base { public: - - template - static bool registerObject(JSContext *cx, JS::HandleObject exports = JS::NullPtr()); - {% if ctor %} - /* These static(s) must be implemented */ + // Constructor {% for constructor in constructors.lst %} - //static Interface_{{name}} *Constructor({{arglst(constructor.arguments)}}); + {{ className }}_Base({{ defs.arglst(constructor.arguments) }}); + {% endfor %} + {% else %} + {{ className }}_Base(){}; + {% endif %} + ~{{ className }}_Base(); +protected: + {% if operations|length > 0 %} + // Methods + {% for attrName, attr in operations %} + {% for op in attr.lst %} + {{ op.return_type.idl_type|ctype }} {{ op.name }}({{ defs.arglst(op.arguments) }}); + {% endfor %} + {% endfor %} + {% endif %} + {% if members.length > 0 %} + // Properties + {# TODO Setter only #} + {% for attr in members %} + {% if not attr.readonly %} + {% if attr.type.idl_type != 'UNKNOWN' %} + bool set_{{ attr.name }}({{ attr.type.idl_type|ctype }} {{attr.name }}); + {% else %} + bool set_{{ attr.name }}({{ attr.name }} ); + {% endif %} + {% endif %} + {% if attr.type.idl_type != 'UNKNOWN' %} + {{ attr.type.idl_type|ctype }} get_{{ attr.name }}(); + {% else %} + {{ attr.name }} get_{{ attr.name }}(); + {% endif %} {% endfor %} - - template - static bool js_{{name}}_Constructor(JSContext *cx, unsigned argc, JS::Value *vp); {% endif %} - - {% for attr in members %} - {% if attr.type == 'operation'%} - virtual {{ attr.idlType.idlType|ctype }} {{attr.name}}({{arglst(attr.arguments)}})=0; - {%endif%} - {% endfor %} - - /* JS Natives */ - - {% for attrName, attrData in operations %} - static bool js_{{attrName}}(JSContext *cx, unsigned argc, JS::Value *vp); - {% endfor %} - - static void JSFinalize(JSFreeOp *fop, JSObject *obj) - { - - } private: -}; -{% raw %}// }}} {% endraw %} - -{% raw %}// {{{ {% endraw %} Preamble -static JSClass {{ className }}_class = { - "{{ className }}", JSCLASS_HAS_PRIVATE, - JS_PropertyStub, JS_DeletePropertyStub, JS_PropertyStub, JS_StrictPropertyStub, - JS_EnumerateStub, JS_ResolveStub, JS_ConvertStub, Interface_{{name}}::JSFinalize, - nullptr, nullptr, nullptr, nullptr, JSCLASS_NO_INTERNAL_MEMBERS -}; - -static JSFunctionSpec {{ className }}_funcs[] = { - {% for attrName, attrData in operations %} - JS_FN("{{attrName}}", Interface_{{name}}::js_{{attrName}}, {{attrData.maxArgs}}, 0), + // Properties + {% for attr in members %} + {% if attr.type.idl_type != 'UNKNOWN' %} + {{ attr.type.idl_type|ctype }} {{ attr.name }}; + {% else %} + {{ attr.name }} {{ attr.name }}; + {% endif %} {% endfor %} - JS_FS_END }; -{% raw %}// }}} {% endraw %} +// {{ '}}}' }} +*/ -{% raw %}// {{{ {% endraw %} Implementation -{% raw %}// {{{ {% endraw %} Construction -{% if ctor %} -template -bool Interface_{{name}}::js_{{name}}_Constructor(JSContext *cx, unsigned argc, JS::Value *vp) +class {{ className }} : public ClassMapper{% if hasAttr(extAttrs, 'Events') %} + WithEvents + {% endif %}<{{ className }}>, public {{ className }}_Base { - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - if (!args.isConstructing()) { - JS_ReportError(cx, "Bad constructor"); - return false; - } - - unsigned argcMin = (({{constructors.maxArgs}} > argc) ? (argc) : ({{constructors.maxArgs}})); - - switch (argcMin) { - {% for op in constructors.lst %} - case {{op.arguments.length}}: - { - /* Start arguments convertion */ - - {% for arg in op.arguments %} - /* Handle argument #{{ loop.index0 }} of type "{{ arg.idlType.idlType }}" */ - {% if not arg.idlType.nullable %} - if (args[{{ loop.index0 }}].isNull()) { - JS_ReportError(cx, "TypeError"); - return false; - } - {% endif %} - {{jsval2c('args['~ loop.index0 ~']', arg.idlType.idlType, 'inArg_' ~ loop.index0)}} - {% endfor %} - /* End of arguments convertion */ - - T *ret = T::Constructor({% for i in range(0, op.arguments.length) %}inArg_{{i}}{{ ', ' if not loop.last }}{%endfor%}); - - if (!ret) { - JS_ReportError(cx, "TypeError"); - return false; - } - - JS::RootedObject rthis(cx, JS_NewObjectForConstructor(cx, &{{ className }}_class, args)); - - JS_SetPrivate(rthis, ret); - - args.rval().setObjectOrNull(rthis); - - break; - } - {% endfor %} - default: - JS_ReportError(cx, "TypeError: wrong number of arguments"); - return false; - break; - } - - return true; -} - +public: +{% if ctor %} + {% for constructor in constructors.lst %} + {{ className }}( {{ defs.arglst(constructor.arguments) }}) + : {{ className }}_Base( {{ defs.argcall(constructor.arguments) }} ) { } + {% else %} + {{ className }}()::{{className}}_Base(){} + {% endfor %} {% endif %} -{% raw %}// }}} {% endraw %} - -{% raw %}// {{{ {% endraw %} Operations -{% for attrName, attrData in operations %} -bool Interface_{{name}}::js_{{attrName}}(JSContext *cx, unsigned argc, JS::Value *vp) -{ - JS::CallArgs args = JS::CallArgsFromVp(argc, vp); - JS::RootedObject caller(cx, JS_THIS_OBJECT(cx, vp)); - - if (!caller) { - JS_ReportError(cx, "Illegal invocation"); - return false; - } - - Interface_{{name}} *obj = (Interface_{{name}} *)JS_GetInstancePrivate(cx, caller, &{{ className }}_class, NULL); - if (!obj) { - JS_ReportError(cx, "Illegal invocation"); - return false; - } - - unsigned argcMin = (({{attrData.maxArgs}} > argc) ? (argc) : ({{attrData.maxArgs}})); - - switch (argcMin) { - {% for op in attrData.lst %} - case {{op.arguments.length}}: - { - /* Start arguments convertion */ - - {% for arg in op.arguments %} - /* Handle argument #{{ loop.index0 }} of type "{{ arg.idlType.idlType }}" */ - {% if not arg.idlType.nullable %} - if (args[{{ loop.index0 }}].isNull()) { - JS_ReportError(cx, "TypeError"); - return false; - } - {% endif %} - {{jsval2c('args['~ loop.index0 ~']', arg.idlType.idlType, 'inArg_' ~ loop.index0)}} - {% endfor %} - /* End of arguments convertion */ - - {%if op.idlType.idlType != 'void'%} - {{ op.idlType.idlType|ctype }} _opret = - {%endif%} - obj->{{attrName}}({% for i in range(0, op.arguments.length) %}inArg_{{i}}{{ ', ' if not loop.last }}{%endfor%}); - - args.rval().set{{ op.idlType.idlType|jsvaltype|capitalize }}(_opret); - break; - } - {% endfor %} - default: - JS_ReportError(cx, "TypeError: wrong number of arguments"); - return false; - break; - } - - return true; -} -{% raw %}// }}} {% endraw %} -{% endfor %} -{% raw %}// }}} {% endraw %} - -{% raw %}// {{{ {% endraw %} Registration -template -bool Interface_{{name}}::registerObject(JSContext *cx, - JS::HandleObject exports) -{ + ~{{ className }}(); {% if ctor %} - JS::RootedObject to(cx); - - to = exports ? exports : JS::CurrentGlobalOrNull(cx); - - JS_InitClass(cx, to, JS::NullPtr(), &{{ className }}_class, - Interface_{{name}}::js_{{name}}_Constructor, - 0, NULL, {{ className }}_funcs, NULL, NULL); + static {{ className }} * Constructor(JSContext *cx, JS::CallArgs &args, + JS::HandleObject obj); + static void RegisterObject(JSContext *cx); + {% endif %} + {% set static_methods = getMethods(operations, true) %} + {% set normal_methods = getMethods(operations, false) %} + {% if normal_methods.lenght > 0 %} + static JSFunctionSpec * ListMethods(); + {% endif %} + {% if static_methods.lenght > 0 %} + static JSFunctionSpec * ListStaticMethods(); + {% endif %} + {% if members.length > 0 %} + static JSPropertySpec *ListProperties(); + {% endif %} + {% if hasAttr(extAttrs, 'exposed') %} + static void RegisterObject(JSContext *cx); + {% endif %} +protected: + {% for attrName, attr in operations %} + NIDIUM_DECL_JSCALL{%if attr.static%}STATIC{% endif%}({{ attrName }}); + {% endfor %} + {# TODO ONLY-SETTER #} + {% for attr in members %} + {% if not attr.readonly %} + NIDIUM_DECL_JSGETTERSETTER({{ attr.name }}); + {% else %} + NIDIUM_DECL_JSGETTER({{ attr.name }}); + {% endif %} + {% endfor %} + {% if hasAttr(extAttrs, 'exposed') == 'module' %} + static JSObject *RegisterModule(JSContext *cx); {% endif %} - return true; -} -{% raw %}// }}} {% endraw %} +private: +}; } // namespace Binding } // namespace Nidium + +#endif From b92440cd8bee81cf373f360512f565859ea011fc Mon Sep 17 00:00:00 2001 From: Peter Reijnders Date: Wed, 18 Jan 2017 17:10:10 +0100 Subject: [PATCH 14/23] Added the NidiumModule example (WIP) --- examples/NidiumModules/.gitignore | 1 + examples/NidiumModules/Makefile | 19 +++++++++++++++++++ examples/NidiumModules/idl/.gitignore | 0 examples/NidiumModules/idl/Hello.idl | 8 ++++++++ 4 files changed, 28 insertions(+) create mode 100644 examples/NidiumModules/.gitignore create mode 100755 examples/NidiumModules/Makefile create mode 100644 examples/NidiumModules/idl/.gitignore create mode 100644 examples/NidiumModules/idl/Hello.idl diff --git a/examples/NidiumModules/.gitignore b/examples/NidiumModules/.gitignore new file mode 100644 index 0000000..80a53cd --- /dev/null +++ b/examples/NidiumModules/.gitignore @@ -0,0 +1 @@ +cpp diff --git a/examples/NidiumModules/Makefile b/examples/NidiumModules/Makefile new file mode 100755 index 0000000..b2c0d17 --- /dev/null +++ b/examples/NidiumModules/Makefile @@ -0,0 +1,19 @@ +INPUT_DIR=./idl +OUTPUT_DIR=./cpp +IMPL_PREFIX=sm_JS_ + +INPUT_FILES = $(shell find $(INPUT_DIR) -type f -name '*.idl') + +TARGETS = $(addprefix \ + $(join $(OUTPUT_DIR)/, $(IMPL_PREFIX)), \ + $(addsuffix .h, $(basename \ + $(notdir $(INPUT_FILES) ) \ + ) \ + ) \ + ) + +all: $(TARGETS) + @echo $(TARGETS) + +include ../common.mk + diff --git a/examples/NidiumModules/idl/.gitignore b/examples/NidiumModules/idl/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/examples/NidiumModules/idl/Hello.idl b/examples/NidiumModules/idl/Hello.idl new file mode 100644 index 0000000..0ef2180 --- /dev/null +++ b/examples/NidiumModules/idl/Hello.idl @@ -0,0 +1,8 @@ +[ + Constructor(DOMString bar, optional unsigned short foo), + classname = Hello +] interface Hello { + attribute DOMString bar; + attribute unsigned short foo; + boolean foobar(unsigned short foo); +}; From 859a6bd7aef39ea99bf2960668d7e3e84b0ae01b Mon Sep 17 00:00:00 2001 From: Peter Reijnders Date: Wed, 18 Jan 2017 17:10:40 +0100 Subject: [PATCH 15/23] Added the Nidium example (WIP) --- examples/Nidium/.gitignore | 2 ++ examples/Nidium/Makefile | 27 +++++++++++++++++++++++++++ examples/Nidium/README.md | 5 +++++ examples/Nidium/idl/.gitignore | 0 4 files changed, 34 insertions(+) create mode 100644 examples/Nidium/.gitignore create mode 100644 examples/Nidium/Makefile create mode 100644 examples/Nidium/README.md create mode 100644 examples/Nidium/idl/.gitignore diff --git a/examples/Nidium/.gitignore b/examples/Nidium/.gitignore new file mode 100644 index 0000000..ae7126a --- /dev/null +++ b/examples/Nidium/.gitignore @@ -0,0 +1,2 @@ +cpp + diff --git a/examples/Nidium/Makefile b/examples/Nidium/Makefile new file mode 100644 index 0000000..0a8322c --- /dev/null +++ b/examples/Nidium/Makefile @@ -0,0 +1,27 @@ +INPUT_DIR=./idl +OUTPUT_DIR=./cpp +IMPL_PREFIX=sm_JS_ + +DOC_DIR = ../../..Nidium/docs +DOC2IDL=./../../NativeTools/IDL/doc2idl_transformer.py + +INPUT_FILES = $(shell find $(INPUT_DIR) -type f -name '*.idl') + +TARGETS = $(addprefix \ + $(join $(OUTPUT_DIR)/, $(IMPL_PREFIX)), \ + $(addsuffix .h, $(basename \ + $(notdir $(INPUT_FILES) ) \ + ) \ + ) \ + ) + +all: $(TARGETS) + @echo $(TARGETS) + +$(OUTPUT_DIR)/$(IMPL_PREFIX)%.h: $(DOC_DIR)/%.cpp.py $(DOC2IDL) + $(DOC2IDL) $< $@ + +include ../common.mk + + + diff --git a/examples/Nidium/README.md b/examples/Nidium/README.md new file mode 100644 index 0000000..a590430 --- /dev/null +++ b/examples/Nidium/README.md @@ -0,0 +1,5 @@ +# Please note + +The files in the idl directory are automatically generated based on nidiums documentation. +It is *very likely* that these will be overwritten any time. +These are only commited here, to gather some experience with IDL. diff --git a/examples/Nidium/idl/.gitignore b/examples/Nidium/idl/.gitignore new file mode 100644 index 0000000..e69de29 From 646bb9a01f3ff6251cac4d021200e4343355b259 Mon Sep 17 00:00:00 2001 From: Peter Reijnders Date: Wed, 18 Jan 2017 17:11:21 +0100 Subject: [PATCH 16/23] Added the automatically generated idf files for Nidium. Please note: this is just temporary. These files should/will be removed soon. --- examples/Nidium/idl/JSAV.idl | 408 ++++++++ examples/Nidium/idl/JSCanvas.idl | 308 ++++++ examples/Nidium/idl/JSCanvas2DContext.idl | 304 ++++++ examples/Nidium/idl/JSConsole.idl | 54 + examples/Nidium/idl/JSDB.idl | 50 + examples/Nidium/idl/JSDebug.idl | 72 ++ examples/Nidium/idl/JSDebugger.idl | 47 + examples/Nidium/idl/JSDocument.idl | 59 ++ examples/Nidium/idl/JSFS.idl | 43 + examples/Nidium/idl/JSFile.idl | 92 ++ examples/Nidium/idl/JSGlobal.idl | 68 ++ examples/Nidium/idl/JSHTTP.idl | 89 ++ examples/Nidium/idl/JSHTTPServer.idl | 143 +++ examples/Nidium/idl/JSImage.idl | 70 ++ examples/Nidium/idl/JSModules.idl | 75 ++ examples/Nidium/idl/JSOS.idl | 42 + examples/Nidium/idl/JSProcess.idl | 90 ++ examples/Nidium/idl/JSSocket.idl | 178 ++++ examples/Nidium/idl/JSStream.idl | 75 ++ examples/Nidium/idl/JSThread.idl | 119 +++ examples/Nidium/idl/JSWebGL.idl | 1121 +++++++++++++++++++++ examples/Nidium/idl/JSWebSocket.idl | 93 ++ examples/Nidium/idl/JSWebSocketClient.idl | 103 ++ examples/Nidium/idl/JSWindow.idl | 430 ++++++++ 24 files changed, 4133 insertions(+) create mode 100644 examples/Nidium/idl/JSAV.idl create mode 100644 examples/Nidium/idl/JSCanvas.idl create mode 100644 examples/Nidium/idl/JSCanvas2DContext.idl create mode 100644 examples/Nidium/idl/JSConsole.idl create mode 100644 examples/Nidium/idl/JSDB.idl create mode 100644 examples/Nidium/idl/JSDebug.idl create mode 100644 examples/Nidium/idl/JSDebugger.idl create mode 100644 examples/Nidium/idl/JSDocument.idl create mode 100644 examples/Nidium/idl/JSFS.idl create mode 100644 examples/Nidium/idl/JSFile.idl create mode 100644 examples/Nidium/idl/JSGlobal.idl create mode 100644 examples/Nidium/idl/JSHTTP.idl create mode 100644 examples/Nidium/idl/JSHTTPServer.idl create mode 100644 examples/Nidium/idl/JSImage.idl create mode 100644 examples/Nidium/idl/JSModules.idl create mode 100644 examples/Nidium/idl/JSOS.idl create mode 100644 examples/Nidium/idl/JSProcess.idl create mode 100644 examples/Nidium/idl/JSSocket.idl create mode 100644 examples/Nidium/idl/JSStream.idl create mode 100644 examples/Nidium/idl/JSThread.idl create mode 100644 examples/Nidium/idl/JSWebGL.idl create mode 100644 examples/Nidium/idl/JSWebSocket.idl create mode 100644 examples/Nidium/idl/JSWebSocketClient.idl create mode 100644 examples/Nidium/idl/JSWindow.idl diff --git a/examples/Nidium/idl/JSAV.idl b/examples/Nidium/idl/JSAV.idl new file mode 100644 index 0000000..3808bcd --- /dev/null +++ b/examples/Nidium/idl/JSAV.idl @@ -0,0 +1,408 @@ +/* DO NOT EDIT MANUALLY, THIS FILE IS GENERATED + at... : 2017-01-05T12:35:42.507856 + by... : ../../doc2idl_transformer.py + for.. : ../../../../Nidium/docs/JSAV.cpp.py +*/ + + + + + + +/* class */ + + +[ + + /* extended properties*/ + + + + + ImplementedAs=JS_GLOBALAudioThread, + HeaderFile=JS_GLOBALAudioThread, + classname = _GLOBALAudioThread + + +] interface _GLOBALAudioThread { + + + /* methods */ + + static void console( ); + + + +}; + + + +/* anon_callbacks */ + + callback AudioNode_assignSetter_Callback = void( DOMString key, any value, _GLOBALAudioThread scope ); + + callback AudioNode_assignSeek_Callback = void( float postition, _GLOBALAudioThread scope ); + + callback AudioNode_assignProcessor_Callback = void( object frame, _GLOBALAudioThread scope ); + + callback AudioNode_assignInit_Callback = void( _GLOBALAudioThread scope ); + + + +/* callbacks */ + + callback interface AudioNodePlayEventHandler { + + void play( any dummy ); + +}; + + callback interface AudioNodePauseEventHandler { + + void pause( any dummy ); + +}; + + callback interface AudioNodeEndEventHandler { + + void end( any dummy ); + +}; + + callback interface AudioNodeErrorEventHandler { + + void error( object event ); + +}; + + callback interface AudioNodeReadyEventHandler { + + void ready( any dummy ); + +}; + + callback interface AudioNodeMessageEventHandler { + + void message( object event ); + +}; + + callback interface AudioNodeBufferingEventHandler { + + void buffering( object event ); + +}; + + + +/* class */ + + +[ + + /* extended properties*/ + + + + HasEvents=True, + + + ImplementedAs=JSAudioNode, + HeaderFile=JSAudioNode, + classname = AudioNode + + +] interface AudioNode { + + /* properties */ + + readonly attribute integer bitrate; + + readonly attribute AudioNodeLink[] input; + + readonly attribute integer duration; + + attribute integer position; + + readonly attribute Object metadata; + + readonly attribute DOMString type; + + readonly attribute AudioNodeLink[] output; + + + + /* methods */ + + any get( DOMString key ); + + void assignSeek( AudioNode_assignSeek_Callback cb ); + + void set( DOMString key, any value ); + + void pause( ); + + void play( ); + + void close( ); + + void assignProcessor( AudioNode_assignProcessor_Callback processor ); + + void stop( ); + + void assignSetter( AudioNode_assignSetter_Callback cb ); + + void assignInit( AudioNode_assignInit_Callback cb ); + + void send( ); + + void open( DOMString src ); + + + + /* events */ + + void play( any dummy); + + void pause( any dummy); + + void end( any dummy); + + void error( AudioNodeErrorEventHandler event); + + void ready( any dummy); + + void message( AudioNodeMessageEventHandler event); + + void buffering( AudioNodeBufferingEventHandler event); + + +}; + + + + +/* callbacks */ + + callback interface VideoPlayEventHandler { + + void play( any dummy ); + +}; + + callback interface VideoPauseEventHandler { + + void pause( any dummy ); + +}; + + callback interface VideoEndEventHandler { + + void end( any dummy ); + +}; + + callback interface VideoFrameEventHandler { + + void frame( Video video ); + +}; + + callback interface VideoErrorEventHandler { + + void error( object event ); + +}; + + callback interface VideoReadyEventHandler { + + void ready( any dummy ); + +}; + + callback interface VideoBufferingEventHandler { + + void buffering( object event ); + +}; + + + +/* class */ + + +[ + + /* extended properties*/ + + Constructor( Canvas canvas ), + + + Exposed=class, + + + HasEvents=True, + + + ImplementedAs=JSVideo, + HeaderFile=JSVideo, + classname = Video + + +] interface Video { + + /* properties */ + + readonly attribute Object metadata; + + attribute integer position; + + readonly attribute integer height; + + readonly attribute integer width; + + readonly attribute integer bitrate; + + readonly attribute integer duration; + + + + /* methods */ + + AudioNode? getAudioNode( ); + + + + /* events */ + + void play( any dummy); + + void pause( any dummy); + + void end( any dummy); + + void frame( Video video); + + void error( VideoErrorEventHandler event); + + void ready( any dummy); + + void buffering( VideoBufferingEventHandler event); + + +}; + + + + + +/* class */ + + +[ + + /* extended properties*/ + + + Exposed=class, + + + + ImplementedAs=JSAudioNodeLink, + HeaderFile=JSAudioNodeLink, + classname = AudioNodeLink + + +] interface AudioNodeLink { + + + +}; + + + + + +/* class */ + + +[ + + /* extended properties*/ + + + + + ImplementedAs=JSAudio, + HeaderFile=JSAudio, + classname = Audio + + +] interface Audio { + + + /* methods */ + + static AudioContext getContext( optional integer buffersize, optional integer channels, optional integer sampleRate ); + + + +}; + + + +/* anon_callbacks */ + + callback AudioContext_run_Callback = void( ); + + + + +/* class */ + + +[ + + /* extended properties*/ + + + Exposed=class, + + + + ImplementedAs=JSAudioContext, + HeaderFile=JSAudioContext, + classname = AudioContext + + +] interface AudioContext { + + /* properties */ + + attribute integer volume; + + readonly attribute integer sampleRate; + + readonly attribute integer bufferSize; + + readonly attribute integer channels; + + + + /* methods */ + + void run( AudioContext_run_Callback cb ); + + void connect( AudioNodeLink output, AudioNodeLink input ); + + AudioNode createNode( DOMString type, integer inputChannels, integer outputChannels ); + + void disconnect( AudioNodeLink output, AudioNodeLink input ); + + static void pFFT( float[] xArray, float[] yArray, integer length, integer dir ); + + + +}; + +/* END OF GENERATED FILE 2017-01-05T12:35:42.507856 */ \ No newline at end of file diff --git a/examples/Nidium/idl/JSCanvas.idl b/examples/Nidium/idl/JSCanvas.idl new file mode 100644 index 0000000..bc7e2df --- /dev/null +++ b/examples/Nidium/idl/JSCanvas.idl @@ -0,0 +1,308 @@ +/* DO NOT EDIT MANUALLY, THIS FILE IS GENERATED + at... : 2017-01-05T12:35:47.444631 + by... : ../../doc2idl_transformer.py + for.. : ../../../../Nidium/docs/JSCanvas.cpp.py +*/ + + + + + + +/* class */ + + +[ + + /* extended properties*/ + + + + + ImplementedAs=JSCanvasInherrit, + HeaderFile=JSCanvasInherrit, + classname = CanvasInherrit + + +] interface CanvasInherrit { + + + +}; + + + + +/* callbacks */ + + callback interface CanvasLoadEventHandler { + + void load( object event ); + +}; + + callback interface CanvasMousewheelEventHandler { + + void mousewheel( object event ); + +}; + + callback interface CanvasDropEventHandler { + + void drop( object event ); + +}; + + callback interface CanvasMouseupEventHandler { + + void mouseup( object event ); + +}; + + callback interface CanvasMousemoveEventHandler { + + void mousemove( object event ); + +}; + + callback interface CanvasDragendEventHandler { + + void dragend( object event ); + +}; + + callback interface CanvasMousedownEventHandler { + + void mousedown( object event ); + +}; + + callback interface CanvasResizeEventHandler { + + void resize( object event ); + +}; + + callback interface CanvasDragstartEventHandler { + + void dragstart( CanvasDragendEventHandler event ); + +}; + + callback interface CanvasDragoverEventHandler { + + void dragover( CanvasDropEventHandler event ); + +}; + + callback interface CanvasDblclickEventHandler { + + void dblclick( object event ); + +}; + + callback interface CanvasChangeEventHandler { + + void change( object obj ); + +}; + + + +/* class */ + + +[ + + /* extended properties*/ + + Constructor( integer width, integer height,optional object options ), + + + Exposed=class, + + + HasEvents=True, + + + ImplementedAs=JSCanvas, + HeaderFile=JSCanvas, + classname = Canvas + + +] interface Canvas { + + /* properties */ + + attribute DOMString id; + + readonly attribute Canvas ctx; + + attribute boolean visible; + + attribute float marginLeft; + + readonly attribute boolean __fixed; + + attribute integer scrollTop; + + attribute integer maxWidth; + + readonly attribute integer clientTop; + + attribute integer minWidth; + + readonly attribute boolean __visible; + + readonly attribute integer innerHeight; + + attribute boolean fluidWidth; + + attribute DOMString position; + + attribute boolean staticLeft; + + readonly attribute integer innerWidth; + + attribute integer minHeight; + + attribute float top; + + attribute float marginRight; + + readonly attribute boolean __outofbound; + + attribute float coating; + + attribute boolean staticRight; + + readonly attribute float __top; + + attribute float left; + + readonly attribute CanvasInherrit inherrit; + + attribute integer height; + + attribute float opacity; + + readonly attribute integer clientHeight; + + readonly attribute integer clientWidth; + + attribute integer scrollLeft; + + attribute boolean staticTop; + + readonly attribute integer clientLeft; + + attribute boolean marginBottom; + + attribute float right; + + attribute boolean marginTop; + + readonly attribute integer contentHeight; + + attribute integer maxHeight; + + attribute boolean overflow; + + attribute boolean allowNegativeScroll; + + attribute boolean staticBottom; + + readonly attribute float __left; + + readonly attribute integer contentWidth; + + attribute float bottom; + + attribute boolean fluidHeight; + + attribute integer width; + + + + /* methods */ + + ( CanvasRenderingContext2D? or WebGLRenderingContext? ) getContext( DOMString mode ); + + Canvas? getPrevSibling( ); + + void removeFromParent( ); + + void bringToFront( ); + + void setContext( CanvasRenderingContext2D obj ); + + void cursor( DOMString type ); + + void clear( ); + + void setCoordinates( integer left, integer right ); + + void add( Canvas child ); + + void setZoom( float factor ); + + void show( ); + + void insertBefore( Canvas insert, Canvas reference ); + + void setSize( integer width, integer height ); + + Canvas[] getChildren( ); + + Canvas? getLastChild( ); + + Canvas? getFirstChild( ); + + void insertAfter( Canvas insert, Canvas reference ); + + void setScale( integer x_pos, integer y_pos ); + + Canvas? getParent( ); + + void hide( ); + + object getVisibleRect( ); + + void sendToBack( ); + + Canvas? getNextSibling( ); + + void translate( integer left, integer right ); + + + + /* events */ + + void load( CanvasLoadEventHandler event); + + void mousewheel( CanvasMousewheelEventHandler event); + + void drop( CanvasDropEventHandler event); + + void mouseup( CanvasMouseupEventHandler event); + + void mousemove( CanvasMousemoveEventHandler event); + + void dragend( CanvasDragendEventHandler event); + + void mousedown( CanvasMousedownEventHandler event); + + void resize( CanvasResizeEventHandler event); + + void dragstart( CanvasDragendEventHandler event); + + void dragover( CanvasDropEventHandler event); + + void dblclick( CanvasDblclickEventHandler event); + + void change( CanvasChangeEventHandler obj); + + +}; + +/* END OF GENERATED FILE 2017-01-05T12:35:47.444631 */ \ No newline at end of file diff --git a/examples/Nidium/idl/JSCanvas2DContext.idl b/examples/Nidium/idl/JSCanvas2DContext.idl new file mode 100644 index 0000000..5429207 --- /dev/null +++ b/examples/Nidium/idl/JSCanvas2DContext.idl @@ -0,0 +1,304 @@ +/* DO NOT EDIT MANUALLY, THIS FILE IS GENERATED + at... : 2017-01-05T12:35:46.813776 + by... : ../../doc2idl_transformer.py + for.. : ../../../../Nidium/docs/JSCanvas2DContext.cpp.py +*/ + + + + + + +/* class */ + + +[ + + /* extended properties*/ + + + Exposed=class, + + + + ImplementedAs=JSCanvasGradient, + HeaderFile=JSCanvasGradient, + classname = CanvasGradient + + +] interface CanvasGradient { + + + /* methods */ + + static void addColorStop( float position, DOMString color ); + + + +}; + + + + + +/* class */ + + +[ + + /* extended properties*/ + + + Exposed=class, + + + + ImplementedAs=JSCanvasRenderingContext2D, + HeaderFile=JSCanvasRenderingContext2D, + classname = CanvasRenderingContext2D + + +] interface CanvasRenderingContext2D { + + /* properties */ + + /*[static=True] static */ attribute float shadowOffsetX; + + /*[static=True] static */ attribute float shadowOffsetY; + + /*[static=True] static */ attribute DOMString fontFamily; + + /*[static=True] static */ attribute float miterLimit; + + /*[static=True] static */ attribute DOMString fontStyle; + + /*[static=True] static */ attribute DOMString textAlign; + + /*[static=True] static */ attribute boolean imageSmoothingEnabled; + + /*[static=True] static */ attribute integer width; + + /*[static=True] static */ attribute float globalAlpha; + + /*[static=True] static */ attribute float shadowBlur; + + /*[static=True] static */ attribute float lineWidth; + + /*[static=True] static */ attribute DOMString fontFile; + + /*[static=True] static */ attribute DOMString globalCompositionOperation; + + /*[static=True] static */ attribute integer height; + + /*[static=True] static */ attribute DOMString textBaseline; + + /*[static=True] static */ attribute DOMString lineCap; + + /*[static=True] static */ attribute DOMString shadowColor; + + /*[static=True] static */ attribute float fontSize; + + /*[static=True] static */ attribute float fontSkew; + + /*[static=True] static */ attribute DOMString lineJoin; + + /*[static=True] static */ attribute ( DOMString or CanvasGradient ) fillStyle; + + + + /* methods */ + + void strokeText( DOMString text, integer x, integer y, integer maxWidth ); + + CanvasGLProgram attachFragmentShader( DOMString glsl ); + + CanvasGradient createRadialGradient( float x1, float y1, float r1, float x2, float y2, float r2 ); + + CanvasPattern createPattern( Image image, DOMString mode ); + + void bezierCurveTo( float cx1, float cy1, float cx2, float cy2, float x, float y ); + + void fill( ); + + void quadraticCurveTo( float cx, float cy, float x, float y ); + + object measureText( DOMString text ); + + void scale( float x, float y ); + + void rect( float x, float y, float width, float height ); + + void fillText( DOMString text, integer x, integer y, integer maxWidth ); + + ImageData getImageData( integer left, integer top, integer width, integer heigth ); + + boolean isPointPath( float x, float y ); + + void transform( float scaleX, float skewX, float skewY, float scaleY, float translateX, float translateY, optional float rotate ); + + void arc( float x, float y, float radius, float start, float end, optional boolean ccw ); + + void drawImage( Image image, integer x, integer y, optional integer width, optional integer heigth ); + + ImageData createImageData( integer x, integer y ); + + void setTransform( float scaleX, float skewX, float skewY, float scaleY, float translateX, float translateY ); + + void iTransform( float scaleX, float skewX, float skewY, float scaleY, float translateX, float translateY ); + + void clip( ); + + void translate( float x, float y ); + + void setVertexOffset( integer vertex, float x, float y ); + + object breakText( DOMString text, float maxWidth ); + + void stroke( ); + + void detachFragmentShader( ); + + void rotate( float angle ); + + void strokRect( float x, float y, float width, float height, float rx, float ry ); + + void fillRect( float x1, float y1, float width, float height, optional float rx, optional float ry ); + + void save( ); + + void lineTo( float x, float y ); + + void arcTo( integer x1, integer y1, integer x2, integer y2, float radius ); + + void moveTo( float x, float y ); + + void clearRect( float x, float y, float width, float height ); + + void beginPath( ); + + void restore( ); + + void putImageData( ImageData image, integer width, integer heigth ); + + object getPathBounds( ); + + void closePath( ); + + CanvasGradient createLinearGradient( float x1, float y1, float x2, float y2 ); + + + +}; + + + + + +/* class */ + + +[ + + /* extended properties*/ + + + Exposed=class, + + + + ImplementedAs=JSCanvasGLProgram, + HeaderFile=JSCanvasGLProgram, + classname = CanvasGLProgram + + +] interface CanvasGLProgram { + + + /* methods */ + + static void uniform3i( integer location, integer value1, integer value2, integer value3 ); + + static void uniform2i( integer location, integer value1, integer value2, integer value3 ); + + static void uniform2f( integer location, float value1, float value2, float value3 ); + + static void uniform1i( integer location, integer value1, integer value2, integer value3 ); + + static void uniform1f( integer location, float value1, float value2, float value3 ); + + static integer getUniformLocation( DOMString location ); + + static void uniform3f( integer location, float value1, float value2, float value3 ); + + static void light( float x, float y, float z ); + + static object getUniforms( ); + + + +}; + + + + + +/* class */ + + +[ + + /* extended properties*/ + + + Exposed=class, + + + + ImplementedAs=JSImageData, + HeaderFile=JSImageData, + classname = ImageData + + +] interface ImageData { + + /* properties */ + + readonly attribute integer height; + + readonly attribute ArrayBuffer data; + + readonly attribute integer width; + + + + +}; + + + + + +/* class */ + + +[ + + /* extended properties*/ + + + Exposed=class, + + + + ImplementedAs=JSCanvasPattern, + HeaderFile=JSCanvasPattern, + classname = CanvasPattern + + +] interface CanvasPattern { + + + +}; + +/* END OF GENERATED FILE 2017-01-05T12:35:46.813776 */ \ No newline at end of file diff --git a/examples/Nidium/idl/JSConsole.idl b/examples/Nidium/idl/JSConsole.idl new file mode 100644 index 0000000..0ef3274 --- /dev/null +++ b/examples/Nidium/idl/JSConsole.idl @@ -0,0 +1,54 @@ +/* DO NOT EDIT MANUALLY, THIS FILE IS GENERATED + at... : 2017-01-05T12:35:33.492318 + by... : ../../doc2idl_transformer.py + for.. : ../../../../Nidium/docs/JSConsole.cpp.py +*/ + + + + + + +/* class */ + + +[ + + /* extended properties*/ + + + Exposed=class, + + + + ImplementedAs=JSConsole, + HeaderFile=JSConsole, + classname = Console + + +] interface Console { + + + /* methods */ + + static void log( optional DOMString text ); + + static void clear( ); + + static void error( optional DOMString text ); + + static void write( optional DOMString text ); + + static void hide( ); + + static void warn( optional DOMString text ); + + static void show( ); + + static void info( optional DOMString text ); + + + +}; + +/* END OF GENERATED FILE 2017-01-05T12:35:33.492318 */ \ No newline at end of file diff --git a/examples/Nidium/idl/JSDB.idl b/examples/Nidium/idl/JSDB.idl new file mode 100644 index 0000000..3373740 --- /dev/null +++ b/examples/Nidium/idl/JSDB.idl @@ -0,0 +1,50 @@ +/* DO NOT EDIT MANUALLY, THIS FILE IS GENERATED + at... : 2017-01-05T12:35:34.786330 + by... : ../../doc2idl_transformer.py + for.. : ../../../../Nidium/docs/JSDB.cpp.py +*/ + + + + + + +/* class */ + + +[ + + /* extended properties*/ + + Constructor( ), + + + Exposed=module, + + + + ImplementedAs=JSDB, + HeaderFile=JSDB, + classname = DB + + +] interface DB { + + + /* methods */ + + void close( ); + + void drop( ); + + void set( DOMString key, any value ); + + void delete( ); + + any get( DOMString key ); + + + +}; + +/* END OF GENERATED FILE 2017-01-05T12:35:34.786330 */ \ No newline at end of file diff --git a/examples/Nidium/idl/JSDebug.idl b/examples/Nidium/idl/JSDebug.idl new file mode 100644 index 0000000..8375462 --- /dev/null +++ b/examples/Nidium/idl/JSDebug.idl @@ -0,0 +1,72 @@ +/* DO NOT EDIT MANUALLY, THIS FILE IS GENERATED + at... : 2017-01-05T12:35:33.882429 + by... : ../../doc2idl_transformer.py + for.. : ../../../../Nidium/docs/JSDebug.cpp.py +*/ + + + + + + +/* class */ + + +[ + + /* extended properties*/ + + + + + ImplementedAs=JSglobal, + HeaderFile=JSglobal, + classname = global + + +] interface global { + + /* properties */ + + readonly attribute object Debug; + + + + +}; + + + + + +/* class */ + + +[ + + /* extended properties*/ + + + Exposed=class, + + + + ImplementedAs=JSNidiumDebug, + HeaderFile=JSNidiumDebug, + classname = NidiumDebug + + +] interface NidiumDebug { + + + /* methods */ + + static any[] serialize( object obj ); + + static any unserialize( ArrayBuffer arraybuf, optional unsigned long offset ); + + + +}; + +/* END OF GENERATED FILE 2017-01-05T12:35:33.882429 */ \ No newline at end of file diff --git a/examples/Nidium/idl/JSDebugger.idl b/examples/Nidium/idl/JSDebugger.idl new file mode 100644 index 0000000..8731a4d --- /dev/null +++ b/examples/Nidium/idl/JSDebugger.idl @@ -0,0 +1,47 @@ +/* DO NOT EDIT MANUALLY, THIS FILE IS GENERATED + at... : 2017-01-05T12:35:40.748712 + by... : ../../doc2idl_transformer.py + for.. : ../../../../Nidium/docs/JSDebugger.cpp.py +*/ + + + + +/* anon_callbacks */ + + callback DebuggerCompartment_run_Callback = void( DebuggerCompartment debugger, optional any[] params ); + + + + +/* class */ + + +[ + + /* extended properties*/ + + Constructor( ), + + + Exposed=class, + + + + ImplementedAs=JSDebuggerCompartment, + HeaderFile=JSDebuggerCompartment, + classname = DebuggerCompartment + + +] interface DebuggerCompartment { + + + /* methods */ + + static any run( DebuggerCompartment context, DebuggerCompartment_run_Callback cb, optional any argn ); + + + +}; + +/* END OF GENERATED FILE 2017-01-05T12:35:40.748712 */ \ No newline at end of file diff --git a/examples/Nidium/idl/JSDocument.idl b/examples/Nidium/idl/JSDocument.idl new file mode 100644 index 0000000..23b9d8f --- /dev/null +++ b/examples/Nidium/idl/JSDocument.idl @@ -0,0 +1,59 @@ +/* DO NOT EDIT MANUALLY, THIS FILE IS GENERATED + at... : 2017-01-05T12:35:37.211997 + by... : ../../doc2idl_transformer.py + for.. : ../../../../Nidium/docs/JSDocument.cpp.py +*/ + + + + + + +/* class */ + + +[ + + /* extended properties*/ + + + Exposed=class, + + + + ImplementedAs=JSNidiumDocument, + HeaderFile=JSNidiumDocument, + classname = NidiumDocument + + +] interface NidiumDocument { + + /* properties */ + + /*[static=True] static */ attribute object stylesheet; + + + + /* methods */ + + static NidiumDocument parse( DOMString ast ); + + static void getPasteBuffer( DOMString content ); + + static DOMString setPasteBuffer( ); + + static Canvas? getCanvasById( DOMString id ); + + static object getScreenData( Canvas element ); + + static boolean loadFont( DOMString name ); + + static void run( DOMString location ); + + static void showFPS( boolean show ); + + + +}; + +/* END OF GENERATED FILE 2017-01-05T12:35:37.211997 */ \ No newline at end of file diff --git a/examples/Nidium/idl/JSFS.idl b/examples/Nidium/idl/JSFS.idl new file mode 100644 index 0000000..b519fb1 --- /dev/null +++ b/examples/Nidium/idl/JSFS.idl @@ -0,0 +1,43 @@ +/* DO NOT EDIT MANUALLY, THIS FILE IS GENERATED + at... : 2017-01-05T12:35:36.854363 + by... : ../../doc2idl_transformer.py + for.. : ../../../../Nidium/docs/JSFS.cpp.py +*/ + + + + +/* anon_callbacks */ + + callback fs_readDir_Callback = void( optional integer err, object entry ); + + + + +/* class */ + + +[ + + /* extended properties*/ + + + + + ImplementedAs=JSfs, + HeaderFile=JSfs, + classname = fs + + +] interface fs { + + + /* methods */ + + static void readDir( DOMString dir, fs_readDir_Callback fn ); + + + +}; + +/* END OF GENERATED FILE 2017-01-05T12:35:36.854363 */ \ No newline at end of file diff --git a/examples/Nidium/idl/JSFile.idl b/examples/Nidium/idl/JSFile.idl new file mode 100644 index 0000000..19ce4f5 --- /dev/null +++ b/examples/Nidium/idl/JSFile.idl @@ -0,0 +1,92 @@ +/* DO NOT EDIT MANUALLY, THIS FILE IS GENERATED + at... : 2017-01-05T12:35:52.066408 + by... : ../../doc2idl_transformer.py + for.. : ../../../../Nidium/docs/JSFile.cpp.py +*/ + + + + +/* anon_callbacks */ + + callback File_open_Callback = void( DOMString Error ); + + callback File_Callback = void( DOMString err, ( DOMString or ArrayBuffer ) buffer ); + + callback File_seek_Callback = void( DOMString err ); + + callback File_read_Callback = void( DOMString err, DOMString buffer ); + + callback File_write_Callback = void( DOMString err ); + + + + +/* class */ + + +[ + + /* extended properties*/ + + Constructor( DOMString path,optional object options, File_Callback cb ), + + + Exposed=class, + + + + ImplementedAs=JSFile, + HeaderFile=JSFile, + classname = File + + +] interface File { + + /* properties */ + + readonly attribute DOMString filesize; + + readonly attribute DOMString filename; + + + + /* methods */ + + void closeSync( ); + + void rm( ); + + boolean isDir( ); + + ( DOMString or ArrayBuffer ) readSync( optional integer readSize ); + + void seek( integer offset, File_seek_Callback cb ); + + void listFiles( ); + + void read( integer bytes, File_read_Callback cb ); + + void writeSync( ( DOMString or ArrayBuffer ) buffer ); + + void write( ( DOMString or ArrayBuffer ) buffer, File_write_Callback cb ); + + void openSync( ); + + void close( ); + + void open( DOMString mode, File_open_Callback cb ); + + void seekSync( integer offset ); + + void rmrf( ); + + static DOMString readSync( DOMString path, optional object options ); + + static DOMString read( DOMString path, optional object options, File_read_Callback cb ); + + + +}; + +/* END OF GENERATED FILE 2017-01-05T12:35:52.066408 */ \ No newline at end of file diff --git a/examples/Nidium/idl/JSGlobal.idl b/examples/Nidium/idl/JSGlobal.idl new file mode 100644 index 0000000..4a358fe --- /dev/null +++ b/examples/Nidium/idl/JSGlobal.idl @@ -0,0 +1,68 @@ +/* DO NOT EDIT MANUALLY, THIS FILE IS GENERATED + at... : 2017-01-05T12:35:37.485084 + by... : ../../doc2idl_transformer.py + for.. : ../../../../Nidium/docs/JSGlobal.cpp.py +*/ + + + + +/* anon_callbacks */ + + callback global_setTimeout_Callback = void( ); + + callback global_setInterval_Callback = void( ); + + callback global_setImmediate_Callback = void( ); + + + + +/* class */ + + +[ + + /* extended properties*/ + + + + + ImplementedAs=JSglobal, + HeaderFile=JSglobal, + classname = global + + +] interface global { + + /* properties */ + + /*[static=True] static */ readonly attribute DOMString __dirname; + + /*[static=True] static */ attribute Window window; + + /*[static=True] static */ readonly attribute DOMString __filename; + + + + /* methods */ + + static void setImmediate( global_setImmediate_Callback fn, any[] args ); + + static void clearInterval( integer identifier ); + + static integer setTimeout( global_setTimeout_Callback fn, integer timeout, any args ); + + static integer setInterval( global_setInterval_Callback fn, integer timeout, any[] args ); + + static void load( DOMString path ); + + static void clearTimeout( integer identifier ); + + static DOMString btoa( DOMString binary ); + + + +}; + +/* END OF GENERATED FILE 2017-01-05T12:35:37.485084 */ \ No newline at end of file diff --git a/examples/Nidium/idl/JSHTTP.idl b/examples/Nidium/idl/JSHTTP.idl new file mode 100644 index 0000000..955f65e --- /dev/null +++ b/examples/Nidium/idl/JSHTTP.idl @@ -0,0 +1,89 @@ +/* DO NOT EDIT MANUALLY, THIS FILE IS GENERATED + at... : 2017-01-05T12:35:41.487233 + by... : ../../doc2idl_transformer.py + for.. : ../../../../Nidium/docs/JSHTTP.cpp.py +*/ + + + + +/* anon_callbacks */ + + callback HTTP_Callback = void( object event ); + + + +/* callbacks */ + + callback interface HTTPHeadersEventHandler { + + void headers( object event ); + +}; + + callback interface HTTPProgressEventHandler { + + void progress( object event ); + +}; + + callback interface HTTPResponseEventHandler { + + void response( object event ); + +}; + + callback interface HTTPErrorEventHandler { + + void error( object event ); + +}; + + + +/* class */ + + +[ + + /* extended properties*/ + + Constructor( DOMString url,optional object params,optional HTTP_Callback cb ), + + + Exposed=class, + + + HasEvents=True, + + + ImplementedAs=JSHTTP, + HeaderFile=JSHTTP, + classname = HTTP + + +] interface HTTP { + + + /* methods */ + + HTTP request( optional object params ); + + HTTP stop( ); + + + + /* events */ + + void headers( HTTPHeadersEventHandler event); + + void progress( HTTPProgressEventHandler event); + + void response( HTTPResponseEventHandler event); + + void error( HTTPErrorEventHandler event); + + +}; + +/* END OF GENERATED FILE 2017-01-05T12:35:41.487233 */ \ No newline at end of file diff --git a/examples/Nidium/idl/JSHTTPServer.idl b/examples/Nidium/idl/JSHTTPServer.idl new file mode 100644 index 0000000..0abc2cc --- /dev/null +++ b/examples/Nidium/idl/JSHTTPServer.idl @@ -0,0 +1,143 @@ +/* DO NOT EDIT MANUALLY, THIS FILE IS GENERATED + at... : 2017-01-05T12:35:50.812112 + by... : ../../doc2idl_transformer.py + for.. : ../../../../Nidium/docs/JSHTTPServer.cpp.py +*/ + + + + + + +/* class */ + + +[ + + /* extended properties*/ + + + + + ImplementedAs=JSHTTPRequest, + HeaderFile=JSHTTPRequest, + classname = HTTPRequest + + +] interface HTTPRequest { + + /* properties */ + + readonly attribute object headers; + + readonly attribute object client; + + readonly attribute DOMString method; + + readonly attribute DOMString url; + + readonly attribute DOMString data; + + + + +}; + + + + + +/* class */ + + +[ + + /* extended properties*/ + + + Exposed=class, + + + + ImplementedAs=JSHTTPServerResponse, + HeaderFile=JSHTTPServerResponse, + classname = HTTPServerResponse + + +] interface HTTPServerResponse { + + + /* methods */ + + void end( ( DOMString or ArrayBuffer ) data ); + + void writeHead( integer statuscode, object kvpairs ); + + void write( ( DOMString or ArrayBuffer ) data ); + + + +}; + + + + +/* callbacks */ + + callback interface HTTPServerOndisconnectEventHandler { + + void onDisconnect( ); + +}; + + callback interface HTTPServerOnrequestEventHandler { + + void onrequest( HTTPRequest request, HTTPServerResponse response ); + +}; + + callback interface HTTPServerOndataEventHandler { + + void ondata( ); + +}; + + + +/* class */ + + +[ + + /* extended properties*/ + + Constructor( DOMString ip, integer port,optional object options ), + + + Exposed=class, + + + HasEvents=True, + + + ImplementedAs=JSHTTPServer, + HeaderFile=JSHTTPServer, + classname = HTTPServer + + +] interface HTTPServer { + + + + /* events */ + + void onDisconnect( ); + + void onrequest( HTTPRequest request, HTTPServerResponse response); + + void ondata( ); + + +}; + +/* END OF GENERATED FILE 2017-01-05T12:35:50.812112 */ \ No newline at end of file diff --git a/examples/Nidium/idl/JSImage.idl b/examples/Nidium/idl/JSImage.idl new file mode 100644 index 0000000..db23276 --- /dev/null +++ b/examples/Nidium/idl/JSImage.idl @@ -0,0 +1,70 @@ +/* DO NOT EDIT MANUALLY, THIS FILE IS GENERATED + at... : 2017-01-05T12:36:48.771628 + by... : ../../doc2idl_transformer.py + for.. : ../../../../Nidium/docs/JSImage.cpp.py +*/ + + + + + +/* callbacks */ + + callback interface ImageLoadEventHandler { + + void load( object event ); + +}; + + callback interface ImageErrorEventHandler { + + void error( object event ); + +}; + + + +/* class */ + + +[ + + /* extended properties*/ + + Constructor( ), + + + Exposed=class, + + + HasEvents=True, + + + ImplementedAs=JSImage, + HeaderFile=JSImage, + classname = Image + + +] interface Image { + + /* properties */ + + readonly attribute integer width; + + attribute ( DOMString or Image ) src; + + readonly attribute integer height; + + + + + /* events */ + + void load( ImageLoadEventHandler event); + + void error( ImageErrorEventHandler event); + + +}; + +/* END OF GENERATED FILE 2017-01-05T12:36:48.771628 */ \ No newline at end of file diff --git a/examples/Nidium/idl/JSModules.idl b/examples/Nidium/idl/JSModules.idl new file mode 100644 index 0000000..7c8ef2a --- /dev/null +++ b/examples/Nidium/idl/JSModules.idl @@ -0,0 +1,75 @@ +/* DO NOT EDIT MANUALLY, THIS FILE IS GENERATED + at... : 2017-01-05T12:35:38.030511 + by... : ../../doc2idl_transformer.py + for.. : ../../../../Nidium/docs/JSModules.cpp.py +*/ + + + + + + +/* class */ + + +[ + + /* extended properties*/ + + + + + ImplementedAs=JSglobal, + HeaderFile=JSglobal, + classname = global + + +] interface global { + + /* properties */ + + /*[static=True] static */ readonly attribute Module[] modules; + + + + /* methods */ + + static DOMString require( DOMString path ); + + + +}; + + + + + +/* class */ + + +[ + + /* extended properties*/ + + + + + ImplementedAs=JSModule, + HeaderFile=JSModule, + classname = Module + + +] interface Module { + + /* properties */ + + /*[static=True] static */ readonly attribute integer id; + + /*[static=True] static */ readonly attribute any exports; + + + + +}; + +/* END OF GENERATED FILE 2017-01-05T12:35:38.030511 */ \ No newline at end of file diff --git a/examples/Nidium/idl/JSOS.idl b/examples/Nidium/idl/JSOS.idl new file mode 100644 index 0000000..7ee2314 --- /dev/null +++ b/examples/Nidium/idl/JSOS.idl @@ -0,0 +1,42 @@ +/* DO NOT EDIT MANUALLY, THIS FILE IS GENERATED + at... : 2017-01-05T12:35:34.358226 + by... : ../../doc2idl_transformer.py + for.. : ../../../../Nidium/docs/JSOS.cpp.py +*/ + + + + + + +/* class */ + + +[ + + /* extended properties*/ + + + Exposed=module, + + + + ImplementedAs=JSOS, + HeaderFile=JSOS, + classname = OS + + +] interface OS { + + /* properties */ + + /*[static=True] static */ readonly attribute DOMString language; + + /*[static=True] static */ readonly attribute DOMString platform; + + + + +}; + +/* END OF GENERATED FILE 2017-01-05T12:35:34.358226 */ \ No newline at end of file diff --git a/examples/Nidium/idl/JSProcess.idl b/examples/Nidium/idl/JSProcess.idl new file mode 100644 index 0000000..1287bd5 --- /dev/null +++ b/examples/Nidium/idl/JSProcess.idl @@ -0,0 +1,90 @@ +/* DO NOT EDIT MANUALLY, THIS FILE IS GENERATED + at... : 2017-01-05T12:35:35.989401 + by... : ../../doc2idl_transformer.py + for.. : ../../../../Nidium/docs/JSProcess.cpp.py +*/ + + + + +/* anon_callbacks */ + + callback NidiumProcess_setSignalHandler_Callback = void( ); + + + + +/* class */ + + +[ + + /* extended properties*/ + + + Exposed=class, + + + + ImplementedAs=JSNidiumProcess, + HeaderFile=JSNidiumProcess, + classname = NidiumProcess + + +] interface NidiumProcess { + + /* properties */ + + readonly attribute integer workerId; + + readonly attribute object argv; + + + + /* methods */ + + void setOwner( ( DOMString or integer ) user, optional ( DOMString or integer ) group ); + + void exit( ); + + object getOwner( ); + + void setSignalHandler( NidiumProcess_setSignalHandler_Callback cb ); + + static DOMString cwd( ); + + + +}; + + + + + +/* class */ + + +[ + + /* extended properties*/ + + + + + ImplementedAs=JSglobal, + HeaderFile=JSglobal, + classname = global + + +] interface global { + + /* properties */ + + readonly attribute object process; + + + + +}; + +/* END OF GENERATED FILE 2017-01-05T12:35:35.989401 */ \ No newline at end of file diff --git a/examples/Nidium/idl/JSSocket.idl b/examples/Nidium/idl/JSSocket.idl new file mode 100644 index 0000000..77b5177 --- /dev/null +++ b/examples/Nidium/idl/JSSocket.idl @@ -0,0 +1,178 @@ +/* DO NOT EDIT MANUALLY, THIS FILE IS GENERATED + at... : 2017-01-05T12:35:49.435763 + by... : ../../doc2idl_transformer.py + for.. : ../../../../Nidium/docs/JSSocket.cpp.py +*/ + + + + + +/* callbacks */ + + callback interface SocketClientOndisconnectEventHandler { + + void ondisconnect( SocketClient clientSocket ); + +}; + + callback interface SocketClientOnreadEventHandler { + + void onread( SocketClient socketClient, DOMString data ); + +}; + + + +/* class */ + + +[ + + /* extended properties*/ + + + + HasEvents=True, + + + ImplementedAs=JSSocketClient, + HeaderFile=JSSocketClient, + classname = SocketClient + + +] interface SocketClient { + + /* properties */ + + readonly attribute DOMString ip; + + + + /* methods */ + + integer write( ( DOMString or ArrayBuffer ) data ); + + void disconnect( ); + + + + /* events */ + + void ondisconnect( SocketClient clientSocket); + + void onread( SocketClient socketClient, DOMString data); + + +}; + + + + +/* callbacks */ + + callback interface SocketOnconnectEventHandler { + + void onconnect( ); + +}; + + callback interface SocketOnacceptEventHandler { + + void onaccept( SocketClient clientSocket ); + +}; + + callback interface SocketOndisconnectEventHandler { + + void ondisconnect( SocketClient client ); + +}; + + callback interface SocketOndrainEventHandler { + + void ondrain( ); + +}; + + callback interface SocketOnreadEventHandler { + + void onread( DOMString data ); + +}; + + callback interface SocketOnmessageEventHandler { + + void onmessage( DOMString data, object details ); + +}; + + + +/* class */ + + +[ + + /* extended properties*/ + + Constructor( DOMString host, integer port ), + + + Exposed=class, + + + HasEvents=True, + + + ImplementedAs=JSSocket, + HeaderFile=JSSocket, + classname = Socket + + +] interface Socket { + + /* properties */ + + attribute boolean binary; + + attribute boolean readline; + + attribute integer timeout; + + attribute DOMString encoding; + + + + /* methods */ + + integer write( ( DOMString or ArrayBuffer ) data ); + + void close( ); + + void sendTo( DOMString ip, integer port, ( DOMString or ArrayBuffer ) data ); + + Socket connect( optional DOMString mode ); + + Socket listen( optional DOMString mode ); + + + + /* events */ + + void onconnect( ); + + void onaccept( SocketClient clientSocket); + + void ondisconnect( SocketClient client); + + void ondrain( ); + + void onread( DOMString data); + + void onmessage( DOMString data, SocketOnmessageEventHandler details); + + +}; + +/* END OF GENERATED FILE 2017-01-05T12:35:49.435763 */ \ No newline at end of file diff --git a/examples/Nidium/idl/JSStream.idl b/examples/Nidium/idl/JSStream.idl new file mode 100644 index 0000000..63d7c33 --- /dev/null +++ b/examples/Nidium/idl/JSStream.idl @@ -0,0 +1,75 @@ +/* DO NOT EDIT MANUALLY, THIS FILE IS GENERATED + at... : 2017-01-05T12:35:40.264164 + by... : ../../doc2idl_transformer.py + for.. : ../../../../Nidium/docs/JSStream.cpp.py +*/ + + + + + +/* callbacks */ + + callback interface StreamOnavailabledataEventHandler { + + void onavailabledata( ); + +}; + + callback interface StreamOnprogressEventHandler { + + void onProgress( integer buffered, integer total ); + +}; + + + +/* class */ + + +[ + + /* extended properties*/ + + Constructor( DOMString url ), + + + Exposed=class, + + + HasEvents=True, + + + ImplementedAs=JSStream, + HeaderFile=JSStream, + classname = Stream + + +] interface Stream { + + /* properties */ + + attribute integer fileSize; + + + + /* methods */ + + Stream? getNextPacket( ); + + void start( integer packetlen ); + + void seek( integer pos ); + + + + /* events */ + + void onavailabledata( ); + + void onProgress( integer buffered, integer total); + + +}; + +/* END OF GENERATED FILE 2017-01-05T12:35:40.264164 */ \ No newline at end of file diff --git a/examples/Nidium/idl/JSThread.idl b/examples/Nidium/idl/JSThread.idl new file mode 100644 index 0000000..8bf256b --- /dev/null +++ b/examples/Nidium/idl/JSThread.idl @@ -0,0 +1,119 @@ +/* DO NOT EDIT MANUALLY, THIS FILE IS GENERATED + at... : 2017-01-05T12:35:35.234833 + by... : ../../doc2idl_transformer.py + for.. : ../../../../Nidium/docs/JSThread.cpp.py +*/ + + + + + + +/* class */ + + +[ + + /* extended properties*/ + + + + + ImplementedAs=JS_GLOBALThread, + HeaderFile=JS_GLOBALThread, + classname = _GLOBALThread + + +] interface _GLOBALThread { + + + /* methods */ + + static void send( ); + + + +}; + + + + + +/* class */ + + +[ + + /* extended properties*/ + + + + + ImplementedAs=JSThreadMessageEvent, + HeaderFile=JSThreadMessageEvent, + classname = ThreadMessageEvent + + +] interface ThreadMessageEvent { + + + +}; + + + + +/* callbacks */ + + callback interface ThreadOncompleteEventHandler { + + void oncomplete( object event ); + +}; + + callback interface ThreadOnmessageEventHandler { + + void onmessage( object event ); + +}; + + + +/* class */ + + +[ + + /* extended properties*/ + + + Exposed=class, + + + HasEvents=True, + + + ImplementedAs=JSThread, + HeaderFile=JSThread, + classname = Thread + + +] interface Thread { + + + /* methods */ + + void start( any args ); + + + + /* events */ + + void oncomplete( ThreadOncompleteEventHandler event); + + void onmessage( ThreadOnmessageEventHandler event); + + +}; + +/* END OF GENERATED FILE 2017-01-05T12:35:35.234833 */ \ No newline at end of file diff --git a/examples/Nidium/idl/JSWebGL.idl b/examples/Nidium/idl/JSWebGL.idl new file mode 100644 index 0000000..7ef67a1 --- /dev/null +++ b/examples/Nidium/idl/JSWebGL.idl @@ -0,0 +1,1121 @@ +/* DO NOT EDIT MANUALLY, THIS FILE IS GENERATED + at... : 2017-01-05T12:35:38.795563 + by... : ../../doc2idl_transformer.py + for.. : ../../../../Nidium/docs/JSWebGL.cpp.py +*/ + + + + + + +/* class */ + + +[ + + /* extended properties*/ + + + + + ImplementedAs=JSWebGLTexture, + HeaderFile=JSWebGLTexture, + classname = WebGLTexture + + +] interface WebGLTexture { + + + +}; + + + + + +/* class */ + + +[ + + /* extended properties*/ + + + + + ImplementedAs=JSWebGL, + HeaderFile=JSWebGL, + classname = WebGL + + +] interface WebGL { + + + +}; + + + + + +/* class */ + + +[ + + /* extended properties*/ + + + Exposed=class, + + + + ImplementedAs=JSWebGLShader, + HeaderFile=JSWebGLShader, + classname = WebGLShader + + +] interface WebGLShader { + + + +}; + + + + + +/* class */ + + +[ + + /* extended properties*/ + + + Exposed=class, + + + + ImplementedAs=JSWebGLActiveInfo, + HeaderFile=JSWebGLActiveInfo, + classname = WebGLActiveInfo + + +] interface WebGLActiveInfo { + + /* properties */ + + /*[static=True] static */ attribute DOMString name; + + /*[static=True] static */ attribute DOMString type; + + /*[static=True] static */ attribute integer size; + + + + +}; + + + + + +/* class */ + + +[ + + /* extended properties*/ + + + Exposed=class, + + + + ImplementedAs=JSWebGLShaderPrecisionFormat, + HeaderFile=JSWebGLShaderPrecisionFormat, + classname = WebGLShaderPrecisionFormat + + +] interface WebGLShaderPrecisionFormat { + + /* properties */ + + /*[static=True] static */ attribute integer rangeMax; + + /*[static=True] static */ attribute integer precision; + + /*[static=True] static */ attribute integer rangeMin; + + + + +}; + + + + + +/* class */ + + +[ + + /* extended properties*/ + + + Exposed=class, + + + + ImplementedAs=JSWebGLUniformLocation, + HeaderFile=JSWebGLUniformLocation, + classname = WebGLUniformLocation + + +] interface WebGLUniformLocation { + + + +}; + + + + + +/* class */ + + +[ + + /* extended properties*/ + + + + + ImplementedAs=JSWebGLRenderbuffer, + HeaderFile=JSWebGLRenderbuffer, + classname = WebGLRenderbuffer + + +] interface WebGLRenderbuffer { + + + +}; + + + + + +/* class */ + + +[ + + /* extended properties*/ + + Constructor( ), + + + + + ImplementedAs=JSWebGLRenderingContext, + HeaderFile=JSWebGLRenderingContext, + classname = WebGLRenderingContext + + +] interface WebGLRenderingContext { + + /* properties */ + + /*[static=True] static */ readonly attribute integer DITHER; + + /*[static=True] static */ readonly attribute integer SUBPIXEL_BITS; + + /*[static=True] static */ readonly attribute integer FUNC_REVERSE_SUBTRACT; + + /*[static=True] static */ readonly attribute integer FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT; + + /*[static=True] static */ readonly attribute integer ELEMENT_ARRAY_BUFFER; + + /*[static=True] static */ readonly attribute integer TRIANGLE_STRIP; + + /*[static=True] static */ readonly attribute integer MAX_COMBINED_TEXTURE_IMAGE_UNITS; + + /*[static=True] static */ readonly attribute integer RGBA; + + /*[static=True] static */ readonly attribute integer DEPTH_BUFFER_BIT; + + /*[static=True] static */ readonly attribute integer ELEMENT_ARRAY_BUFFER_BINDING; + + /*[static=True] static */ readonly attribute integer RENDERBUFFER; + + /*[static=True] static */ readonly attribute integer DEPTH_STENCIL_ATTACHMENT; + + /*[static=True] static */ readonly attribute integer STENCIL_BUFFER_BIT; + + /*[static=True] static */ readonly attribute integer NO_ERROR; + + /*[static=True] static */ readonly attribute integer NICEST; + + /*[static=True] static */ readonly attribute integer RENDERBUFFER_BLUE_SIZE; + + /*[static=True] static */ readonly attribute integer BLEND_SRC_RGB; + + /*[static=True] static */ readonly attribute integer SAMPLE_COVERAGE_VALUE; + + /*[static=True] static */ readonly attribute integer LINK_STATUS; + + /*[static=True] static */ readonly attribute integer SRC_ALPHA_SATURATE; + + /*[static=True] static */ readonly attribute integer RENDERBUFFER_INTERNAL_FORMAT; + + /*[static=True] static */ readonly attribute integer RGB; + + /*[static=True] static */ readonly attribute integer FLOAT_MAT4; + + /*[static=True] static */ readonly attribute integer TEXTURE_WRAP_S; + + /*[static=True] static */ readonly attribute integer TEXTURE14; + + /*[static=True] static */ readonly attribute integer STENCIL_ATTACHMENT; + + /*[static=True] static */ readonly attribute integer DST_ALPHA; + + /*[static=True] static */ readonly attribute integer TRIANGLES; + + /*[static=True] static */ readonly attribute integer IMPLEMENTATION_COLOR_READ_FORMAT; + + /*[static=True] static */ readonly attribute integer STENCIL_BACK_REF; + + /*[static=True] static */ readonly attribute integer FRAMEBUFFER_COMPLETE; + + /*[static=True] static */ readonly attribute integer UNPACK_COLORSPACE_CONVERSION_WEBGL; + + /*[static=True] static */ readonly attribute integer ONE_MINUS_CONSTANT_COLOR; + + /*[static=True] static */ readonly attribute integer CLAMP_TO_EDGE; + + /*[static=True] static */ readonly attribute integer UNSIGNED_SHORT_4_4_4_4; + + /*[static=True] static */ readonly attribute integer DEPTH_STENCIL; + + /*[static=True] static */ readonly attribute integer TEXTURE11; + + /*[static=True] static */ readonly attribute integer LINEAR; + + /*[static=True] static */ readonly attribute integer MAX_RENDERBUFFER_SIZE; + + /*[static=True] static */ readonly attribute integer VERSION; + + /*[static=True] static */ readonly attribute integer FLOAT_MAT3; + + /*[static=True] static */ readonly attribute integer MAX_VERTEX_ATTRIBS; + + /*[static=True] static */ readonly attribute integer ONE_MINUS_SRC_ALPHA; + + /*[static=True] static */ readonly attribute integer UNPACK_FLIP_Y_WEBGL; + + /*[static=True] static */ readonly attribute integer FRAMEBUFFER_INCOMPLETE_ATTACHMENT; + + /*[static=True] static */ readonly attribute integer ACTIVE_TEXTURE; + + /*[static=True] static */ readonly attribute integer TEXTURE12; + + /*[static=True] static */ readonly attribute integer STENCIL_CLEAR_VALUE; + + /*[static=True] static */ readonly attribute integer RENDERBUFFER_RED_SIZE; + + /*[static=True] static */ readonly attribute integer STENCIL_TEST; + + /*[static=True] static */ readonly attribute integer ES_VERSION_2_0; + + /*[static=True] static */ readonly attribute integer LINEAR_MIPMAP_LINEAR; + + /*[static=True] static */ readonly attribute integer STENCIL_BACK_PASS_DEPTH_PASS; + + /*[static=True] static */ readonly attribute integer CCW; + + /*[static=True] static */ readonly attribute integer MAX_VERTEX_TEXTURE_IMAGE_UNITS; + + /*[static=True] static */ readonly attribute integer TEXTURE_MAG_FILTER; + + /*[static=True] static */ readonly attribute integer INCR; + + /*[static=True] static */ readonly attribute integer BLEND_SRC_ALPHA; + + /*[static=True] static */ readonly attribute integer ONE_MINUS_CONSTANT_ALPHA; + + /*[static=True] static */ readonly attribute integer INVERT; + + /*[static=True] static */ readonly attribute integer TEXTURE19; + + /*[static=True] static */ readonly attribute integer ACTIVE_ATTRIBUTE_MAX_LENGTH; + + /*[static=True] static */ readonly attribute integer BLUE_BITS; + + /*[static=True] static */ readonly attribute integer BLEND_DST_ALPHA; + + /*[static=True] static */ readonly attribute integer FRAMEBUFFER_ATTACHMENT_OBJECT_NAME; + + /*[static=True] static */ readonly attribute integer LUMINANCE; + + /*[static=True] static */ readonly attribute integer RGB5_A1; + + /*[static=True] static */ readonly attribute integer MAX_VERTEX_UNIFORM_VECTORS; + + /*[static=True] static */ readonly attribute integer POINTS; + + /*[static=True] static */ readonly attribute integer STENCIL_REF; + + /*[static=True] static */ readonly attribute integer GREEN_BITS; + + /*[static=True] static */ readonly attribute integer VERTEX_ATTRIB_ARRAY_POINTER; + + /*[static=True] static */ readonly attribute integer VERTEX_ATTRIB_ARRAY_BUFFER_BINDING; + + /*[static=True] static */ readonly attribute integer FRONT_FACE; + + /*[static=True] static */ readonly attribute integer FLOAT_VEC3; + + /*[static=True] static */ readonly attribute integer FLOAT_VEC2; + + /*[static=True] static */ readonly attribute integer DEPTH_BITS; + + /*[static=True] static */ readonly attribute integer PACK_ALIGNMENT; + + /*[static=True] static */ readonly attribute integer BLEND_COLOR; + + /*[static=True] static */ readonly attribute integer DEPTH_TEST; + + /*[static=True] static */ readonly attribute integer MIRRORED_REPEAT; + + /*[static=True] static */ readonly attribute integer OUT_OF_MEMORY; + + /*[static=True] static */ readonly attribute integer STENCIL_PASS_DEPTH_PASS; + + /*[static=True] static */ readonly attribute integer LINEAR_MIPMAP_NEAREST; + + /*[static=True] static */ readonly attribute integer BLEND_EQUATION; + + /*[static=True] static */ readonly attribute integer LINE_WIDTH; + + /*[static=True] static */ readonly attribute integer STENCIL_WRITEMASK; + + /*[static=True] static */ readonly attribute integer TEXTURE_CUBE_MAP; + + /*[static=True] static */ readonly attribute integer BLEND_EQUATION_RGB; + + /*[static=True] static */ readonly attribute integer ALIASED_POINT_SIZE_RANGE; + + /*[static=True] static */ readonly attribute integer TEXTURE_BINDING_2D; + + /*[static=True] static */ readonly attribute integer SHADER_TYPE; + + /*[static=True] static */ readonly attribute integer SRC_COLOR; + + /*[static=True] static */ readonly attribute integer STATIC_DRAW; + + /*[static=True] static */ readonly attribute integer STENCIL_FAIL; + + /*[static=True] static */ readonly attribute integer SHADER_SOURCE_LENGTH; + + /*[static=True] static */ readonly attribute integer VERTEX_ATTRIB_ARRAY_STRIDE; + + /*[static=True] static */ readonly attribute integer TEXTURE_BINDING_CUBE_MAP; + + /*[static=True] static */ readonly attribute integer ALIASED_LINE_WIDTH_RANGE; + + /*[static=True] static */ readonly attribute integer HIGH_INT; + + /*[static=True] static */ readonly attribute integer CULL_FACE; + + /*[static=True] static */ readonly attribute integer SRC_ALPHA; + + /*[static=True] static */ readonly attribute integer KEEP; + + /*[static=True] static */ readonly attribute integer ACTIVE_ATTRIBUTES; + + /*[static=True] static */ readonly attribute integer FRAMEBUFFER_UNSUPPORTED; + + /*[static=True] static */ readonly attribute integer DONT_CARE; + + /*[static=True] static */ readonly attribute integer DEPTH_ATTACHMENT; + + /*[static=True] static */ readonly attribute integer TEXTURE_CUBE_MAP_NEGATIVE_Z; + + /*[static=True] static */ readonly attribute integer LESS; + + /*[static=True] static */ readonly attribute integer TEXTURE_CUBE_MAP_NEGATIVE_X; + + /*[static=True] static */ readonly attribute integer TEXTURE_CUBE_MAP_NEGATIVE_Y; + + /*[static=True] static */ readonly attribute integer INVALID_FRAMEBUFFER_OPERATION; + + /*[static=True] static */ readonly attribute integer FRONT; + + /*[static=True] static */ readonly attribute integer GENERATE_MIPMAP_HINT; + + /*[static=True] static */ readonly attribute integer MAX_TEXTURE_IMAGE_UNITS; + + /*[static=True] static */ readonly attribute integer FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL; + + /*[static=True] static */ readonly attribute integer NOTEQUAL; + + /*[static=True] static */ readonly attribute integer VIEWPORT; + + /*[static=True] static */ readonly attribute integer FLOAT_MAT2; + + /*[static=True] static */ readonly attribute integer TEXTURE_WRAP_T; + + /*[static=True] static */ readonly attribute integer UNSIGNED_BYTE; + + /*[static=True] static */ readonly attribute integer FRONT_AND_BACK; + + /*[static=True] static */ readonly attribute integer RENDERBUFFER_BINDING; + + /*[static=True] static */ readonly attribute integer RENDERER; + + /*[static=True] static */ readonly attribute integer ARRAY_BUFFER_BINDING; + + /*[static=True] static */ readonly attribute integer TEXTURE_MIN_FILTER; + + /*[static=True] static */ readonly attribute integer STENCIL_PASS_DEPTH_FAIL; + + /*[static=True] static */ readonly attribute integer UNPACK_ALIGNMENT; + + /*[static=True] static */ readonly attribute integer NUM_COMPRESSED_TEXTURE_FORMATS; + + /*[static=True] static */ readonly attribute integer ONE_MINUS_DST_ALPHA; + + /*[static=True] static */ readonly attribute integer STREAM_DRAW; + + /*[static=True] static */ readonly attribute integer EQUAL; + + /*[static=True] static */ readonly attribute integer STENCIL_BACK_FUNC; + + /*[static=True] static */ readonly attribute integer POLYGON_OFFSET_UNITS; + + /*[static=True] static */ readonly attribute integer UNSIGNED_SHORT_5_6_5; + + /*[static=True] static */ readonly attribute integer IMPLEMENTATION_COLOR_READ_TYPE; + + /*[static=True] static */ readonly attribute integer ONE_MINUS_DST_COLOR; + + /*[static=True] static */ readonly attribute integer VERTEX_ATTRIB_ARRAY_ENABLED; + + /*[static=True] static */ readonly attribute integer EXTENSIONS; + + /*[static=True] static */ readonly attribute integer ALWAYS; + + /*[static=True] static */ readonly attribute integer BLEND_EQUATION_ALPHA; + + /*[static=True] static */ readonly attribute integer LINES; + + /*[static=True] static */ readonly attribute integer RENDERBUFFER_HEIGHT; + + /*[static=True] static */ readonly attribute integer TEXTURE; + + /*[static=True] static */ readonly attribute integer TEXTURE_CUBE_MAP_POSITIVE_Z; + + /*[static=True] static */ readonly attribute integer COMPRESSED_TEXTURE_FORMATS; + + /*[static=True] static */ readonly attribute integer TEXTURE_CUBE_MAP_POSITIVE_X; + + /*[static=True] static */ readonly attribute integer TEXTURE_CUBE_MAP_POSITIVE_Y; + + /*[static=True] static */ readonly attribute integer INT_VEC2; + + /*[static=True] static */ readonly attribute integer INT_VEC3; + + /*[static=True] static */ readonly attribute integer VENDOR; + + /*[static=True] static */ readonly attribute integer RENDERBUFFER_WIDTH; + + /*[static=True] static */ readonly attribute integer FRAMEBUFFER; + + /*[static=True] static */ readonly attribute integer FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE; + + /*[static=True] static */ readonly attribute integer LUMINANCE_ALPHA; + + /*[static=True] static */ readonly attribute integer COLOR_WRITEMASK; + + /*[static=True] static */ readonly attribute integer SHORT; + + /*[static=True] static */ readonly attribute integer TEXTURE_2D; + + /*[static=True] static */ readonly attribute integer MAX_VARYING_VECTORS; + + /*[static=True] static */ readonly attribute integer RGB565; + + /*[static=True] static */ readonly attribute integer COLOR_CLEAR_VALUE; + + /*[static=True] static */ readonly attribute integer MEDIUM_INT; + + /*[static=True] static */ readonly attribute integer LOW_FLOAT; + + /*[static=True] static */ readonly attribute integer HIGH_FLOAT; + + /*[static=True] static */ readonly attribute integer INFO_LOG_LENGTH; + + /*[static=True] static */ readonly attribute integer STENCIL_BACK_PASS_DEPTH_FAIL; + + /*[static=True] static */ readonly attribute integer DEPTH_COMPONENT; + + /*[static=True] static */ readonly attribute integer BACK; + + /*[static=True] static */ readonly attribute integer BYTE; + + /*[static=True] static */ readonly attribute integer BLEND_DST_RGB; + + /*[static=True] static */ readonly attribute integer BLEND; + + /*[static=True] static */ readonly attribute integer SHADING_LANGUAGE_VERSION; + + /*[static=True] static */ readonly attribute integer GREATER; + + /*[static=True] static */ readonly attribute integer SAMPLE_ALPHA_TO_COVERAGE; + + /*[static=True] static */ readonly attribute integer NEAREST_MIPMAP_NEAREST; + + /*[static=True] static */ readonly attribute integer STENCIL_FUNC; + + /*[static=True] static */ readonly attribute integer VERTEX_ATTRIB_ARRAY_NORMALIZED; + + /*[static=True] static */ readonly attribute integer DEPTH_COMPONENT16; + + /*[static=True] static */ readonly attribute integer FUNC_ADD; + + /*[static=True] static */ readonly attribute integer DYNAMIC_DRAW; + + /*[static=True] static */ readonly attribute integer FUNC_SUBTRACT; + + /*[static=True] static */ readonly attribute integer DEPTH_WRITEMASK; + + /*[static=True] static */ readonly attribute integer DEPTH_CLEAR_VALUE; + + /*[static=True] static */ readonly attribute integer RENDERBUFFER_DEPTH_SIZE; + + /*[static=True] static */ readonly attribute integer RENDERBUFFER_GREEN_SIZE; + + /*[static=True] static */ readonly attribute integer CURRENT_VERTEX_ATTRIB; + + /*[static=True] static */ readonly attribute integer FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE; + + /*[static=True] static */ readonly attribute integer TEXTURE31; + + /*[static=True] static */ readonly attribute integer TEXTURE30; + + /*[static=True] static */ readonly attribute integer BOOL_VEC4; + + /*[static=True] static */ readonly attribute integer SAMPLE_BUFFERS; + + /*[static=True] static */ readonly attribute integer TEXTURE1; + + /*[static=True] static */ readonly attribute integer LINE_STRIP; + + /*[static=True] static */ readonly attribute integer TEXTURE3; + + /*[static=True] static */ readonly attribute integer TEXTURE2; + + /*[static=True] static */ readonly attribute integer TEXTURE5; + + /*[static=True] static */ readonly attribute integer ATTACHED_SHADERS; + + /*[static=True] static */ readonly attribute integer TEXTURE7; + + /*[static=True] static */ readonly attribute integer TEXTURE6; + + /*[static=True] static */ readonly attribute integer ZERO; + + /*[static=True] static */ readonly attribute integer TEXTURE8; + + /*[static=True] static */ readonly attribute integer DST_COLOR; + + /*[static=True] static */ readonly attribute integer UNPACK_PREMULTIPLY_ALPHA_WEBGL; + + /*[static=True] static */ readonly attribute integer TEXTURE0; + + /*[static=True] static */ readonly attribute integer RGBA4; + + /*[static=True] static */ readonly attribute integer LOW_INT; + + /*[static=True] static */ readonly attribute integer FRAMEBUFFER_INCOMPLETE_DIMENSIONS; + + /*[static=True] static */ readonly attribute integer MAX_VIEWPORT_DIMS; + + /*[static=True] static */ readonly attribute integer UNSIGNED_SHORT_5_5_5_1; + + /*[static=True] static */ readonly attribute integer ARRAY_BUFFER; + + /*[static=True] static */ readonly attribute integer MEDIUM_FLOAT; + + /*[static=True] static */ readonly attribute integer TEXTURE10; + + /*[static=True] static */ readonly attribute integer RENDERBUFFER_ALPHA_SIZE; + + /*[static=True] static */ readonly attribute integer UNSIGNED_SHORT; + + /*[static=True] static */ readonly attribute integer POLYGON_OFFSET_FACTOR; + + /*[static=True] static */ readonly attribute integer STENCIL_BACK_FAIL; + + /*[static=True] static */ readonly attribute integer NEVER; + + /*[static=True] static */ readonly attribute integer CONTEXT_LOST_WEBGL; + + /*[static=True] static */ readonly attribute integer VALIDATE_STATUS; + + /*[static=True] static */ readonly attribute integer TEXTURE28; + + /*[static=True] static */ readonly attribute integer TEXTURE29; + + /*[static=True] static */ readonly attribute integer BUFFER_USAGE; + + /*[static=True] static */ readonly attribute integer DELETE_STATUS; + + /*[static=True] static */ readonly attribute integer MAX_TEXTURE_SIZE; + + /*[static=True] static */ readonly attribute integer TEXTURE21; + + /*[static=True] static */ readonly attribute integer TEXTURE22; + + /*[static=True] static */ readonly attribute integer FASTEST; + + /*[static=True] static */ readonly attribute integer TEXTURE24; + + /*[static=True] static */ readonly attribute integer TEXTURE25; + + /*[static=True] static */ readonly attribute integer TEXTURE26; + + /*[static=True] static */ readonly attribute integer TEXTURE27; + + /*[static=True] static */ readonly attribute integer FLOAT_VEC4; + + /*[static=True] static */ readonly attribute integer REPEAT; + + /*[static=True] static */ readonly attribute integer CULL_FACE_MODE; + + /*[static=True] static */ readonly attribute integer STENCIL_BITS; + + /*[static=True] static */ readonly attribute integer MAX_CUBE_MAP_TEXTURE_SIZE; + + /*[static=True] static */ readonly attribute integer CW; + + /*[static=True] static */ readonly attribute integer BOOL_VEC2; + + /*[static=True] static */ readonly attribute integer BOOL_VEC3; + + /*[static=True] static */ readonly attribute integer SAMPLER_2D; + + /*[static=True] static */ readonly attribute integer SHADER_COMPILER; + + /*[static=True] static */ readonly attribute integer ALPHA_BITS; + + /*[static=True] static */ readonly attribute integer NEAREST_MIPMAP_LINEAR; + + /*[static=True] static */ readonly attribute integer BOOL; + + /*[static=True] static */ readonly attribute integer SCISSOR_TEST; + + /*[static=True] static */ readonly attribute integer FRAMEBUFFER_BINDING; + + /*[static=True] static */ readonly attribute integer SAMPLE_COVERAGE_INVERT; + + /*[static=True] static */ readonly attribute integer TEXTURE4; + + /*[static=True] static */ readonly attribute integer TEXTURE20; + + /*[static=True] static */ readonly attribute integer COLOR_BUFFER_BIT; + + /*[static=True] static */ readonly attribute integer INVALID_ENUM; + + /*[static=True] static */ readonly attribute integer DECR; + + /*[static=True] static */ readonly attribute integer FRAGMENT_SHADER; + + /*[static=True] static */ readonly attribute integer STENCIL_BACK_WRITEMASK; + + /*[static=True] static */ readonly attribute integer MAX_FRAGMENT_UNIFORM_VECTORS; + + /*[static=True] static */ readonly attribute integer LINE_LOOP; + + /*[static=True] static */ readonly attribute integer POLYGON_OFFSET_FILL; + + /*[static=True] static */ readonly attribute integer RENDERBUFFER_STENCIL_SIZE; + + /*[static=True] static */ readonly attribute integer GEQUAL; + + /*[static=True] static */ readonly attribute integer TEXTURE15; + + /*[static=True] static */ readonly attribute integer TEXTURE9; + + /*[static=True] static */ readonly attribute integer TEXTURE17; + + /*[static=True] static */ readonly attribute integer TEXTURE16; + + /*[static=True] static */ readonly attribute integer DEPTH_RANGE; + + /*[static=True] static */ readonly attribute integer CONSTANT_ALPHA; + + /*[static=True] static */ readonly attribute integer TEXTURE13; + + /*[static=True] static */ readonly attribute integer NEAREST; + + /*[static=True] static */ readonly attribute integer VERTEX_ATTRIB_ARRAY_SIZE; + + /*[static=True] static */ readonly attribute integer LEQUAL; + + /*[static=True] static */ readonly attribute integer TEXTURE18; + + /*[static=True] static */ readonly attribute integer BROWSER_DEFAULT_WEBGL; + + /*[static=True] static */ readonly attribute integer VERTEX_ATTRIB_ARRAY_TYPE; + + /*[static=True] static */ readonly attribute integer ONE; + + /*[static=True] static */ readonly attribute integer CONSTANT_COLOR; + + /*[static=True] static */ readonly attribute integer FIXED; + + /*[static=True] static */ readonly attribute integer INT; + + /*[static=True] static */ readonly attribute integer ONE_MINUS_SRC_COLOR; + + /*[static=True] static */ readonly attribute integer STENCIL_INDEX; + + /*[static=True] static */ readonly attribute integer DEPTH_FUNC; + + /*[static=True] static */ readonly attribute integer SAMPLER_CUBE; + + /*[static=True] static */ readonly attribute integer COLOR_ATTACHMENT0; + + /*[static=True] static */ readonly attribute integer SAMPLES; + + /*[static=True] static */ readonly attribute integer COMPILE_STATUS; + + /*[static=True] static */ readonly attribute integer RED_BITS; + + /*[static=True] static */ readonly attribute integer BUFFER_SIZE; + + /*[static=True] static */ readonly attribute integer DECR_WRAP; + + /*[static=True] static */ readonly attribute integer CURRENT_PROGRAM; + + /*[static=True] static */ readonly attribute integer INVALID_OPERATION; + + /*[static=True] static */ readonly attribute integer UNSIGNED_INT; + + /*[static=True] static */ readonly attribute integer INVALID_VALUE; + + /*[static=True] static */ readonly attribute integer ALPHA; + + /*[static=True] static */ readonly attribute integer VERTEX_SHADER; + + /*[static=True] static */ readonly attribute integer STENCIL_INDEX8; + + /*[static=True] static */ readonly attribute integer INCR_WRAP; + + /*[static=True] static */ readonly attribute integer ACTIVE_UNIFORM_MAX_LENGTH; + + /*[static=True] static */ readonly attribute integer STENCIL_VALUE_MASK; + + /*[static=True] static */ readonly attribute integer SAMPLE_COVERAGE; + + /*[static=True] static */ readonly attribute integer ACTIVE_UNIFORMS; + + /*[static=True] static */ readonly attribute integer INT_VEC4; + + /*[static=True] static */ readonly attribute integer FLOAT; + + /*[static=True] static */ readonly attribute integer NONE; + + /*[static=True] static */ readonly attribute integer REPLACE; + + /*[static=True] static */ readonly attribute integer STENCIL_BACK_VALUE_MASK; + + /*[static=True] static */ readonly attribute integer TEXTURE23; + + /*[static=True] static */ readonly attribute integer TRIANGLE_FAN; + + /*[static=True] static */ readonly attribute integer SCISSOR_BOX; + + + + /* methods */ + + void vertexAttrib3fv( integer index, float[] array ); + + void cullFace( integer mode ); + + void renderBufferStorage( integer target, integer internalFormat, integer width, integer height ); + + void vertexAttrib1fv( integer index, float[] array ); + + void depthMask( boolean flag ); + + void bindRenderbuffer( integer target, WebGLRenderbuffer buffer ); + + void uniform2fv( WebGLUniformLocation location, float[] array ); + + void deleteProgram( WebGLProgram Object ); + + void uniform4f( integer x_pos, integer y_pos, integer z_index, integer w_pos ); + + WebGLProgram createProgram( ); + + void vertexAttrib4f( integer index, integer v0, integer v1, integer v2, integer v3 ); + + void disable( integer cap ); + + void blendFunc( integer sfactor, integer dfactor ); + + void getActiveUniform( integer target ); + + void blendEquation( integer mode ); + + void uniform2iv( WebGLUniformLocation location, boolean transpose, float[] array ); + + DOMString getShaderInfoLog( WebGLShader shader ); + + WebGLRenderbuffer createRenderBuffer( ); + + void clearStencil( integer stencil ); + + WebGLShader createShader( integer type ); + + void getExtension( ); + + void uniform4i( WebGLUniformLocation location, integer x_pos, integer y_pos, integer z_index, integer width ); + + void bindAttribLocation( WebGLProgram program, integer vertex, DOMString name ); + + void framebufferRenderbuffer( integer target, integer attach, integer renderbuffer_target, WebGLRenderbuffer renderbuffer ); + + void drawArrays( integer mode, integer first, integer count ); + + WebGLBuffer createBuffer( ); + + void depthFunc( integer func ); + + void depthRange( float near, float far ); + + boolean isContextLost( ); + + void vertexAttrib3f( integer index, integer v0, integer v1, integer v2, integer v3 ); + + void drawElements( integer mode, integer first, integer count, integer offset ); + + void uniform4fv( WebGLUniformLocation location, float[] array ); + + void pixelStorei( integer param, integer value ); + + DOMString getProgramInfoLog( WebGLProgram program ); + + void framebufferTexture2D( integer target, integer attach, integer texture_target, WebGLTexture texture, integer level ); + + void disableVertexAttribArray( integer cap ); + + void bufferData( integer target, WebGLBuffer array, integer usage ); + + void bindBuffer( integer target, WebGLBuffer buffer ); + + integer getError( ); + + void vertexAttrib2f( integer index, integer v0, integer v1, integer v2, integer v3 ); + + void texParameteri( integer target, integer name, integer value ); + + void texImage2D( integer target, integer level, integer internalFormat, integer width, integer height, integer border, integer format, integer type ); + + void compileShader( optional WebGLShader shader ); + + void uniform1iv( WebGLUniformLocation location, boolean transpose, float[] array ); + + void generateMipmap( integer target ); + + void clearColor( float red, float green, float blue, float alpha ); + + void vertexAttrib2fv( integer index, float[] array ); + + void lineWidth( integer width ); + + void enableVertexAttribArray( integer attr ); + + void uniform1i( WebGLUniformLocation location, integer x_pos, integer y_pos, integer z_index, integer width ); + + void uniform1fv( WebGLUniformLocation location, float[] array ); + + void enable( integer bits ); + + void uniform1f( integer x_pos, integer y_pos, integer z_index, integer w_pos ); + + void vertexAttrib1f( integer index, integer v0, integer v1, integer v2, integer v3 ); + + void linkProgram( WebGLProgram program ); + + void deleteTexture( WebGLTexture Object ); + + void bufferSubData( integer target, integer offset, WebGLBuffer array ); + + WebGLFramebuffer createFrameBuffer( ); + + void uniform3fv( WebGLUniformLocation location, float[] array ); + + void blendEquationSeparate( integer rgb, integer alpha ); + + void frontFace( integer mode ); + + void vertexAttribPointer( integer attr, integer size, integer type, boolean normalized, integer stride, integer offset ); + + void detachShader( WebGLProgram program, WebGLShader shader ); + + integer getShaderParameter( WebGLShader shader, integer param ); + + WebGLActiveInfo getActiveAttrib( WebGLProgram program, integer index ); + + void shaderSource( WebGLShader shader, DOMString source ); + + void vertexAttrib4fv( integer index, float[] array ); + + void deleteRenderbuffer( WebGLRenderbuffer Object ); + + void bindTexture( integer target, WebGLTexture texture ); + + void activeTexture( integer texture ); + + void deleteBuffer( WebGLBuffer Object ); + + void copyTexImage2D( integer target, integer level, integer internal, integer x_pos, integer y_pos, integer width, integer height, integer border ); + + void uniform3f( integer x_pos, integer y_pos, integer z_index, integer w_pos ); + + void flush( ); + + WebGLShaderPrecisionFormat getShaderPrecisionFormat( integer shader, integer precision ); + + void uniform3i( WebGLUniformLocation location, integer x_pos, integer y_pos, integer z_index, integer width ); + + void deleteFramebuffer( WebGLFramebuffer Object ); + + void viewPort( integer x_pos, integer y_pos, integer width, integer height ); + + WebGLTexture createTexture( ); + + void useProgram( WebGLProgram program ); + + void copyTexSubImage2D( integer target, integer level, integer internal, integer x_pos, integer y_pos, integer width, integer height, integer border ); + + any getParameter( WebGLProgram program, integer attr ); + + WebGLUniformLocation getUniformLocation( WebGLProgram program, DOMString name ); + + void uniform4iv( WebGLUniformLocation location, boolean transpose, float[] array ); + + void colorMask( optional float red, optional float green, optional float blue, optional float alpha ); + + void uniform2f( integer x_pos, integer y_pos, integer z_index, integer w_pos ); + + void uniform3iv( WebGLUniformLocation location, boolean transpose, float[] array ); + + void bindFramebuffer( integer target, WebGLFramebuffer buffer ); + + void uniform2i( WebGLUniformLocation location, integer x_pos, integer y_pos, integer z_index, integer width ); + + void attachShader( WebGLProgram program, WebGLShader shader ); + + void clearDepth( float depth ); + + void deleteShader( WebGLShader Object ); + + void finish( ); + + WebGLUniformLocation getAttribLocation( WebGLProgram program, DOMString attr ); + + void clear( ); + + void blendFuncSeparate( integer srcRgb, integer dstRgb, integer srcAlpha, integer dstAlpha ); + + + +}; + + + + + +/* class */ + + +[ + + /* extended properties*/ + + + + + ImplementedAs=JSWebGLFramebuffer, + HeaderFile=JSWebGLFramebuffer, + classname = WebGLFramebuffer + + +] interface WebGLFramebuffer { + + + +}; + + + + + +/* class */ + + +[ + + /* extended properties*/ + + + + + ImplementedAs=JSWebGLBuffer, + HeaderFile=JSWebGLBuffer, + classname = WebGLBuffer + + +] interface WebGLBuffer { + + + +}; + + + + + +/* class */ + + +[ + + /* extended properties*/ + + + + + ImplementedAs=JSWebGLProgram, + HeaderFile=JSWebGLProgram, + classname = WebGLProgram + + +] interface WebGLProgram { + + + +}; + +/* END OF GENERATED FILE 2017-01-05T12:35:38.795563 */ \ No newline at end of file diff --git a/examples/Nidium/idl/JSWebSocket.idl b/examples/Nidium/idl/JSWebSocket.idl new file mode 100644 index 0000000..c2b619a --- /dev/null +++ b/examples/Nidium/idl/JSWebSocket.idl @@ -0,0 +1,93 @@ +/* DO NOT EDIT MANUALLY, THIS FILE IS GENERATED + at... : 2017-01-05T12:35:50.241100 + by... : ../../doc2idl_transformer.py + for.. : ../../../../Nidium/docs/JSWebSocket.cpp.py +*/ + + + + + +/* callbacks */ + + callback interface WebSocketServerOnmessageEventHandler { + + void onmessage( WebSocketServerClient client, object event ); + +}; + + callback interface WebSocketServerOnopenEventHandler { + + void onopen( WebSocketServerClient client ); + +}; + + + +/* class */ + + +[ + + /* extended properties*/ + + Constructor( DOMString host,optional DOMString protocol ), + + + Exposed=class, + + + HasEvents=True, + + + ImplementedAs=JSWebSocketServer, + HeaderFile=JSWebSocketServer, + classname = WebSocketServer + + +] interface WebSocketServer { + + + + /* events */ + + void onmessage( WebSocketServerClient client, WebSocketServerOnmessageEventHandler event); + + void onopen( WebSocketServerClient client); + + +}; + + + + + +/* class */ + + +[ + + /* extended properties*/ + + + + + ImplementedAs=JSWebSocketServerClient, + HeaderFile=JSWebSocketServerClient, + classname = WebSocketServerClient + + +] interface WebSocketServerClient { + + + /* methods */ + + integer? send( ( DOMString or ArrayBuffer ) message ); + + void close( ); + + + +}; + +/* END OF GENERATED FILE 2017-01-05T12:35:50.241100 */ \ No newline at end of file diff --git a/examples/Nidium/idl/JSWebSocketClient.idl b/examples/Nidium/idl/JSWebSocketClient.idl new file mode 100644 index 0000000..998ebf3 --- /dev/null +++ b/examples/Nidium/idl/JSWebSocketClient.idl @@ -0,0 +1,103 @@ +/* DO NOT EDIT MANUALLY, THIS FILE IS GENERATED + at... : 2017-01-05T12:35:46.190535 + by... : ../../doc2idl_transformer.py + for.. : ../../../../Nidium/docs/JSWebSocketClient.cpp.py +*/ + + + + + +/* callbacks */ + + callback interface WebSocketServerOnmessageEventHandler { + + void onmessage( WebSocketServerClient client, object event ); + +}; + + + +/* class */ + + +[ + + /* extended properties*/ + + + Exposed=class, + + + HasEvents=True, + + + ImplementedAs=JSWebSocketServer, + HeaderFile=JSWebSocketServer, + classname = WebSocketServer + + +] interface WebSocketServer { + + + + /* events */ + + void onmessage( WebSocketServerClient client, WebSocketServerOnmessageEventHandler event); + + +}; + + + + +/* callbacks */ + + callback interface WebSocketOnopenEventHandler { + + void onopen( WebSocketServerClient client ); + +}; + + + +/* class */ + + +[ + + /* extended properties*/ + + + Exposed=class, + + + HasEvents=True, + + + ImplementedAs=JSWebSocket, + HeaderFile=JSWebSocket, + classname = WebSocket + + +] interface WebSocket { + + + /* methods */ + + integer? send( ( DOMString or ArrayBuffer ) message ); + + WebSocket? ping( DOMString url, optional DOMString protocol ); + + void close( ); + + + + /* events */ + + void onopen( WebSocketServerClient client); + + +}; + +/* END OF GENERATED FILE 2017-01-05T12:35:46.190535 */ \ No newline at end of file diff --git a/examples/Nidium/idl/JSWindow.idl b/examples/Nidium/idl/JSWindow.idl new file mode 100644 index 0000000..52405cb --- /dev/null +++ b/examples/Nidium/idl/JSWindow.idl @@ -0,0 +1,430 @@ +/* DO NOT EDIT MANUALLY, THIS FILE IS GENERATED + at... : 2017-01-05T12:35:44.203057 + by... : ../../doc2idl_transformer.py + for.. : ../../../../Nidium/docs/JSWindow.cpp.py +*/ + + + + + + +/* class */ + + +[ + + /* extended properties*/ + + + + + ImplementedAs=JSNMLEvent, + HeaderFile=JSNMLEvent, + classname = NMLEvent + + +] interface NMLEvent { + + + +}; + + + + + +/* class */ + + +[ + + /* extended properties*/ + + + + + ImplementedAs=JSkeyEvent, + HeaderFile=JSkeyEvent, + classname = keyEvent + + +] interface keyEvent { + + + +}; + + + + + +/* class */ + + +[ + + /* extended properties*/ + + + + + ImplementedAs=JSMouseEvent, + HeaderFile=JSMouseEvent, + classname = MouseEvent + + +] interface MouseEvent { + + + +}; + + + + + +/* class */ + + +[ + + /* extended properties*/ + + + + + ImplementedAs=JSTextInputEvent, + HeaderFile=JSTextInputEvent, + classname = TextInputEvent + + +] interface TextInputEvent { + + + +}; + + + +/* anon_callbacks */ + + callback Window_requestAnimationFrame_Callback = void( string[] list ); + + callback Window_openDirDialog_Callback = void( string[] list ); + + callback Window_openFileDialog_Callback = void( string[] list ); + + + +/* callbacks */ + + callback interface Window_onfiledragdropEventHandler { + + void _onFileDragDrop( object event ); + +}; + + callback interface Window_ontextinputEventHandler { + + void _ontextinput( object event ); + +}; + + callback interface Window_onfiledragEventHandler { + + void _onFileDrag( object event ); + +}; + + callback interface Window_onfocusEventHandler { + + void _onfocus( ); + +}; + + callback interface Window_onmousedownEventHandler { + + void _onmousedown( object event ); + +}; + + callback interface Window_onmousewheelEventHandler { + + void _onmousewheel( object event ); + +}; + + callback interface Window_oncloseEventHandler { + + void _onclose( WindowEvent event ); + +}; + + callback interface Window_onmousemoveEventHandler { + + void _onmousemove( object event ); + +}; + + callback interface Window_onfiledragleaveEventHandler { + + void _onFileDragLeave( object event ); + +}; + + callback interface Window_onmouseupEventHandler { + + void _onmouseup( object event ); + +}; + + callback interface Window_onsystemtrayclickEventHandler { + + void _onsystemtrayclick( object event ); + +}; + + callback interface Window_onassetreadyEventHandler { + + void _onassetready( object event ); + +}; + + callback interface Window_onfiledragenterEventHandler { + + void _onFileDragEnter( object event ); + +}; + + callback interface Window_onkeydownEventHandler { + + void _onkeydown( object event ); + +}; + + callback interface Window_onblurEventHandler { + + void _onblur( ); + +}; + + callback interface Window_onreadyEventHandler { + + void _onready( WindowEvent event ); + +}; + + callback interface Window_onkeyupEventHandler { + + void _onkeyup( object event ); + +}; + + + +/* class */ + + +[ + + /* extended properties*/ + + + + HasEvents=True, + + + ImplementedAs=JSWindow, + HeaderFile=JSWindow, + classname = Window + + +] interface Window { + + /* properties */ + + /*[static=True] static */ attribute integer top; + + /*[static=True] static */ attribute Canvas canvas; + + /*[static=True] static */ attribute DOMString cursor; + + /*[static=True] static */ attribute integer outerHeight; + + /*[static=True] static */ attribute integer left; + + /*[static=True] static */ readonly attribute object __nidium__; + + /*[static=True] static */ attribute integer innerHeight; + + /*[static=True] static */ attribute integer titleBarColor; + + /*[static=True] static */ readonly attribute Navigator navigator; + + /*[static=True] static */ attribute integer innerWidth; + + /*[static=True] static */ attribute DOMString title; + + /*[static=True] static */ attribute integer titleBarControlOffsetY; + + /*[static=True] static */ attribute integer titleBarControlOffsetX; + + + + /* methods */ + + static void requestAnimationFrame( Window_requestAnimationFrame_Callback fn ); + + static void setFrame( ( integer or DOMString ) x_pos, ( integer or DOMString ) y_pos, integer hh, integer nn ); + + static void openDirDialog( Window_openDirDialog_Callback fn ); + + static void openURL( DOMString url ); + + static void center( integer x_pos, integer y_pos ); + + static void openFileDialog( string[] types, Window_openFileDialog_Callback fn ); + + static void quit( ); + + static void exec( DOMString cmd ); + + static void setSize( integer width, integer heigth ); + + static void notify( object config ); + + static void close( ); + + + + /* events */ + + void _onFileDragDrop( Window_onfiledragdropEventHandler event); + + void _ontextinput( Window_ontextinputEventHandler event); + + void _onFileDrag( Window_onfiledragEventHandler event); + + void _onfocus( ); + + void _onmousedown( Window_onmousedownEventHandler event); + + void _onmousewheel( Window_onmousewheelEventHandler event); + + void _onclose( WindowEvent event); + + void _onmousemove( Window_onmousemoveEventHandler event); + + void _onFileDragLeave( Window_onfiledragleaveEventHandler event); + + void _onmouseup( Window_onmouseupEventHandler event); + + void _onsystemtrayclick( Window_onsystemtrayclickEventHandler event); + + void _onassetready( Window_onassetreadyEventHandler event); + + void _onFileDragEnter( Window_onfiledragenterEventHandler event); + + void _onkeydown( Window_onkeydownEventHandler event); + + void _onblur( ); + + void _onready( WindowEvent event); + + void _onkeyup( Window_onkeyupEventHandler event); + + +}; + + + + + +/* class */ + + +[ + + /* extended properties*/ + + + + + ImplementedAs=JSWindowEvent, + HeaderFile=JSWindowEvent, + classname = WindowEvent + + +] interface WindowEvent { + + + +}; + + + + + +/* class */ + + +[ + + /* extended properties*/ + + + + + ImplementedAs=JSMouseDrag, + HeaderFile=JSMouseDrag, + classname = MouseDrag + + +] interface MouseDrag { + + + +}; + + + + + +/* class */ + + +[ + + /* extended properties*/ + + + + + ImplementedAs=JSNavigator, + HeaderFile=JSNavigator, + classname = Navigator + + +] interface Navigator { + + /* properties */ + + /*[static=True] static */ readonly attribute DOMString appVersion; + + /*[static=True] static */ readonly attribute boolean vibrate; + + /*[static=True] static */ readonly attribute DOMString userAgent; + + /*[static=True] static */ readonly attribute DOMString platform; + + /*[static=True] static */ readonly attribute DOMString language; + + /*[static=True] static */ readonly attribute DOMString appName; + + + + +}; + +/* END OF GENERATED FILE 2017-01-05T12:35:44.203057 */ \ No newline at end of file From 28c292c6c8c8392212d43ce1206ee16b919f9ad9 Mon Sep 17 00:00:00 2001 From: Peter Reijnders Date: Wed, 18 Jan 2017 17:11:37 +0100 Subject: [PATCH 17/23] Added more details to the README --- README.md | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/README.md b/README.md index e29ad27..7189d8d 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,44 @@ # Generate CPP for JS based on IDL See [WebIDL spec](http://heycam.github.io/webidl/) for details + +# Usage: + +Currently there are 3 example projects. +In any of these directories you can start with: + +``` +make +``` +If not all dependencies are met, make should complain. + +The idl input files are supposed to be in the 'idl' subdirectory +The generated cpp code will be written in the cpp subdirectory. + +# Status + +This is a work in progress, allthough the first resulst look promissing. + +The following fields require more work: + +* UnionType +* OtherType +* callbacks +* dictionaries +* events +* .. + +# Spec + +There is no final specification yet, only an rough outline that is under discussion. +Details will follow asap. + +# Dependencies + +executables: 'npm', 'nodejs' +NodeJs modules: 'nunjucks', 'webidl2' + +# License + +Copyright 2016 Nidium Inc. All rights reserved. Use of this source code is governed by a MIT license that can be found in the LICENSE file. + From 47a32fd0b3c0631e970c5ca0ac8867e70e38af41 Mon Sep 17 00:00:00 2001 From: Peter Reijnders Date: Wed, 18 Jan 2017 17:42:11 +0100 Subject: [PATCH 18/23] Added LICENSE texts --- LICENSE | 79 +++++++++++++++++++++++++++++++++ config.mk | 3 ++ examples/Demo/Makefile | 4 ++ examples/Nidium/Makefile | 4 ++ examples/NidiumModules/Makefile | 4 ++ examples/_clang-format | 4 ++ examples/common.mk | 4 ++ package.json | 6 +++ parse.js | 8 +++- templates/dict_class.tpl.h | 6 +++ 10 files changed, 121 insertions(+), 1 deletion(-) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..54a12b2 --- /dev/null +++ b/LICENSE @@ -0,0 +1,79 @@ +This Software is MIT licensed but builds upon third-party libraries. + +MIT License + +Copyright (c) 2016 Nidium Inc. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +############################################################################### +Nunjucks - A powerful templating engine with inheritance, asynchronous control, and more (jinja2 inspired) +############################################################################### +Copyright (c) 2012-2015, James Long +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in + the documentation and/or other materials provided with the + distribution. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +############################################################################### +WebIDL2s - IDL Parse for node +############################################################################### +The MIT License (MIT) + +Copyright (c) 2014 Robin Berjon + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + diff --git a/config.mk b/config.mk index 525c448..7d78949 100644 --- a/config.mk +++ b/config.mk @@ -1,3 +1,6 @@ +# Copyright 2016 Nidium Inc. All rights reserved. +# Use of this source code is governed by a MIT license +# that can be found in the LICENSE file. BIN_CLANGFORMAT := $(shell command -v clang-format-3.5 2> /dev/null) BIN_NPM := $(shell command -v npm 2> /dev/null) diff --git a/examples/Demo/Makefile b/examples/Demo/Makefile index b2c0d17..b3883af 100755 --- a/examples/Demo/Makefile +++ b/examples/Demo/Makefile @@ -1,3 +1,7 @@ +# Copyright 2016 Nidium Inc. All rights reserved. +# Use of this source code is governed by a MIT license +# that can be found in the LICENSE file. + INPUT_DIR=./idl OUTPUT_DIR=./cpp IMPL_PREFIX=sm_JS_ diff --git a/examples/Nidium/Makefile b/examples/Nidium/Makefile index 0a8322c..72eb432 100644 --- a/examples/Nidium/Makefile +++ b/examples/Nidium/Makefile @@ -1,3 +1,7 @@ +# Copyright 2016 Nidium Inc. All rights reserved. +# Use of this source code is governed by a MIT license +# that can be found in the LICENSE file. + INPUT_DIR=./idl OUTPUT_DIR=./cpp IMPL_PREFIX=sm_JS_ diff --git a/examples/NidiumModules/Makefile b/examples/NidiumModules/Makefile index b2c0d17..b3883af 100755 --- a/examples/NidiumModules/Makefile +++ b/examples/NidiumModules/Makefile @@ -1,3 +1,7 @@ +# Copyright 2016 Nidium Inc. All rights reserved. +# Use of this source code is governed by a MIT license +# that can be found in the LICENSE file. + INPUT_DIR=./idl OUTPUT_DIR=./cpp IMPL_PREFIX=sm_JS_ diff --git a/examples/_clang-format b/examples/_clang-format index d2a24e6..defda6c 100644 --- a/examples/_clang-format +++ b/examples/_clang-format @@ -1,3 +1,7 @@ +# Copyright 2016 Nidium Inc. All rights reserved. +# Use of this source code is governed by a MIT license +# that can be found in the LICENSE file. + # BasedOnStyle: WebKit AccessModifierOffset: -4 #AlignAfterOpenBracket: true diff --git a/examples/common.mk b/examples/common.mk index 62e0caf..9c0fea1 100644 --- a/examples/common.mk +++ b/examples/common.mk @@ -1,3 +1,7 @@ +# Copyright 2016 Nidium Inc. All rights reserved. +# Use of this source code is governed by a MIT license +# that can be found in the LICENSE file. + include ../../config.mk PARSE=../../parse.js diff --git a/package.json b/package.json index f60c2aa..252f94f 100644 --- a/package.json +++ b/package.json @@ -1,3 +1,9 @@ +/* + Copyright 2016 Nidium Inc. All rights reserved. + Use of this source code is governed by a MIT license + that can be found in the LICENSE file. +*/ + { "name": "IDLMonkey", "version": "0.0.0", diff --git a/parse.js b/parse.js index feb1b93..33f1168 100644 --- a/parse.js +++ b/parse.js @@ -1,3 +1,9 @@ +/* + Copyright 2016 Nidium Inc. All rights reserved. + Use of this source code is governed by a MIT license + that can be found in the LICENSE file. +*/ + var WebIDL2 = require("webidl2"); var nunjucks = require('nunjucks'); @@ -188,7 +194,7 @@ NidiumIDL.prototype.createInterface = function(outputPath, obj) obj.constructors = constructors; obj.operations = operations; - //console.log(obj.operations.foobar.lst[0]); + //console.log(obj); var interfaceHeader = this.env.render('impl_class.tpl.h', obj); var fileNameHeader = outputPath + "/impl_" + obj.className + ".h"; fileNames.push(fileNameHeader); diff --git a/templates/dict_class.tpl.h b/templates/dict_class.tpl.h index 9a89f6b..3d77405 100644 --- a/templates/dict_class.tpl.h +++ b/templates/dict_class.tpl.h @@ -1,3 +1,9 @@ +/* + Copyright 2016 Nidium Inc. All rights reserved. + Use of this source code is governed by a MIT license + that can be found in the LICENSE file. +*/ + {% import "defs.tpl" as defs %} #pragma once From a8391a6611b8352488e64c87b4d081c86afbd970 Mon Sep 17 00:00:00 2001 From: Peter Reijnders Date: Wed, 18 Jan 2017 17:44:51 +0100 Subject: [PATCH 19/23] Added Prefix to classname. --- examples/common.mk | 4 ++-- parse.js | 23 ++++++++++--------- templates/dict_class.tpl.h | 4 ++-- templates/impl_class.tpl.cpp | 44 ++++++++++++++++++------------------ templates/impl_class.tpl.h | 14 ++++++------ 5 files changed, 45 insertions(+), 44 deletions(-) diff --git a/examples/common.mk b/examples/common.mk index 9c0fea1..6b56560 100644 --- a/examples/common.mk +++ b/examples/common.mk @@ -13,9 +13,9 @@ $(OUTPUT_DIR): mkdir -p $(OUTPUT_DIR) $(OUTPUT_DIR)/$(IMPL_PREFIX)%.h: $(INPUT_DIR)/%.idl $(PARSE) $(TEMPLATES) $(OUTPUT_DIR) ../_clang-format - $(eval CMD = $(BIN_NODEJS) $(PARSE) $< $(TEMPLATE_DIR) $(OUTPUT_DIR)) + @$(eval CMD = $(BIN_NODEJS) $(PARSE) $< $(TEMPLATE_DIR) $(OUTPUT_DIR) $(IMPL_PREFIX)) + @$(eval CREATED = $(shell $(CMD))) @echo "$(CMD)" - $(eval CREATED = $(shell $(CMD))) $(BIN_CLANGFORMAT) -style=file -i $(CREATED) .PHONY: clean diff --git a/parse.js b/parse.js index 33f1168..9f6becf 100644 --- a/parse.js +++ b/parse.js @@ -113,7 +113,7 @@ NidiumIDL.prototype.printTree = function() { console.log(util.inspect(this.tree, {colors: true, depth: 16})); } -NidiumIDL.prototype.generate = function(outputPath) { +NidiumIDL.prototype.generate = function(outputPath, prefix) { var created_files = []; for (var i = 0; i < this.tree.length; i++) { var obj = this.tree[i]; @@ -136,10 +136,10 @@ NidiumIDL.prototype.generate = function(outputPath) { }; switch(obj.type) { case 'interface': - created_files = created_files.concat(this.createInterface(outputPath, obj)); + created_files = created_files.concat(this.createInterface(outputPath, obj, prefix)); break; case 'dictionary': - create_files = created_files.concat(this.createDict(outputPath, obj)); + create_files = created_files.concat(this.createDict(outputPath, obj, prefix)); break; } } @@ -148,7 +148,7 @@ NidiumIDL.prototype.generate = function(outputPath) { } -NidiumIDL.prototype.createInterface = function(outputPath, obj) +NidiumIDL.prototype.createInterface = function(outputPath, obj, prefix) { /* Scan for constructor @@ -193,10 +193,11 @@ NidiumIDL.prototype.createInterface = function(outputPath, obj) obj.constructors = constructors; obj.operations = operations; + obj.prefix = prefix; //console.log(obj); var interfaceHeader = this.env.render('impl_class.tpl.h', obj); - var fileNameHeader = outputPath + "/impl_" + obj.className + ".h"; + var fileNameHeader = outputPath + "/" + prefix + obj.className + ".h"; fileNames.push(fileNameHeader); fs.writeFile(fileNameHeader, interfaceHeader, function(err) { if (err) { @@ -204,7 +205,7 @@ NidiumIDL.prototype.createInterface = function(outputPath, obj) } }); var interfaceCode = this.env.render('impl_class.tpl.cpp', obj); - var fileNameCode = outputPath + "/impl_" + obj.className + ".cpp"; + var fileNameCode = outputPath + "/" + prefix + obj.className + ".cpp"; fileNames.push(fileNameCode); fs.writeFile(fileNameCode, interfaceCode, function(err) { if (err) { @@ -215,11 +216,11 @@ NidiumIDL.prototype.createInterface = function(outputPath, obj) return fileNames; } -NidiumIDL.prototype.createDict = function(outputPath, obj) { +NidiumIDL.prototype.createDict = function(outputPath, obj, prefix) { var fileNames = []; //console.log(obj); var dictHeader = this.env.render('dict_class.tpl.h', obj); - var fileName = outputPath + "/dict_" + obj.className + ".h"; + var fileName = outputPath + "/" + prefix + obj.className + ".h"; fileNames.push(fileName); fs.writeFile(fileName, dictHeader, function(err) { if (err) { @@ -230,12 +231,12 @@ NidiumIDL.prototype.createDict = function(outputPath, obj) { return fileNames; } -if (process.argv.length < 5) { - console.log("Usage : " + process.argv[0] + " " + process.argv[1] + " idlfile templatepath outputpath\n"); +if (process.argv.length < 6) { + console.log("Usage : " + process.argv[0] + " " + process.argv[1] + " idlfile templatepath outputpath prefix\n"); } else { var idl = new NidiumIDL(process.argv[2], process.argv[3]); idl.parse(); //idl.printTree(); - var created = idl.generate(process.argv[4]); + var created = idl.generate(process.argv[4], process.argv[5]); console.log(created.join(" ")); } diff --git a/templates/dict_class.tpl.h b/templates/dict_class.tpl.h index 3d77405..a722925 100644 --- a/templates/dict_class.tpl.h +++ b/templates/dict_class.tpl.h @@ -13,8 +13,8 @@ namespace Nidium { namespace Binding { -// {{ '{{{' }} Dict_{{ name }} -class Dict_{{ name }} : public Dict +// {{ '{{{' }} Dict_{{prefix}}{{ name }} +class Dict_{{prefix}}{{ name }} : public Dict { public: Dict_{{ name }}() { diff --git a/templates/impl_class.tpl.cpp b/templates/impl_class.tpl.cpp index 70e9130..7845ae0 100644 --- a/templates/impl_class.tpl.cpp +++ b/templates/impl_class.tpl.cpp @@ -7,7 +7,7 @@ {% import 'defs.tpl' as defs %} #include -#include "{{ className }}.h" +#include "{{ prefix }}{{ className }}.h" namespace Nidium { namespace Binding { @@ -16,7 +16,7 @@ namespace Binding { {% if ctor %} // {{ '{{{' }} Start Constructor - {{ className }} *{{ className }}::Constructor(JSContext *cx, JS::CallArgs &args, + {{ prefix }}{{ className }} *{{ prefix }}{{ className }}::Constructor(JSContext *cx, JS::CallArgs &args, JS::HandleObject obj) { unsigned argc = args.length(); @@ -39,14 +39,14 @@ namespace Binding { {% endfor %} /* End of arguments conversion */ - {{ className }} *n_{{ className }} = new {{ className }}( + {{ prefix }}{{ className }} *n_{{ prefix }}{{ className }} = new {{ prefix }}{{ className }}( {% for i in range(0, op.arguments|length) %} inArg_{{ i }}{{ ' ' if loop.last else ', ' }} {% endfor %} ); - n_{{ className }}->root(); + n_{{ prefix }}{{ className }}->root(); - return n_{{ className }}; + return n_{{ prefix }}{{ className }}; break; } {% endfor %} @@ -66,14 +66,14 @@ namespace Binding { {% if normal_methods|length > 0 %} // {{ '{{{' }} Start Operations - JSFunctionSpec * {{ className }}::ListMethods() + JSFunctionSpec * {{ prefix }}{{ className }}::ListMethods() { static JSFunctionSpec funcs[] = { {% for attrName, attr in normal_methods %} {% if hasAttr(attr.extAttrs, 'Alias') %} - CLASSMAPPER_FN_ALIAS({{ className }}, {{ attrName }}, {{ attr['maxArgs'] }}, {{ hasAttr( attr.extAttrs, 'Alias') }}), + CLASSMAPPER_FN_ALIAS({{ prefix }}{{ className }}, {{ attrName }}, {{ attr['maxArgs'] }}, {{ hasAttr( attr.extAttrs, 'Alias') }}), {% endif %} - CLASSMAPPER_FN({{ className }}, {{ attrName }}, {{ attr['maxArgs'] }} ), + CLASSMAPPER_FN({{ prefix }}{{ className }}, {{ attrName }}, {{ attr['maxArgs'] }} ), {% endfor %} JS_FS_END @@ -85,14 +85,14 @@ namespace Binding { {% if static_methods|length > 0 %} // {{ '{{{' }} Start Operations - JSFunctionSpec * {{ className }}::ListStaticMethods() + JSFunctionSpec * {{ prefix }}{{ className }}::ListStaticMethods() { static JSFunctionSpec funcs[] = { {% for attrName, attr in static_methods %} {% if hasAttr(attr.extAttrs, 'Alias') %} - CLASSMAPPER_FN_ALIAS({{ className }}, {{ attrName }}, {{ attr['maxArgs'] }}, {{ hasAttr(attr.extAttrs, 'Alias') }}), + CLASSMAPPER_FN_ALIAS({{ prefix }}{{ className }}, {{ attrName }}, {{ attr['maxArgs'] }}, {{ hasAttr(attr.extAttrs, 'Alias') }}), {% endif %} - CLASSMAPPER_FN({{ className }}, {{ attrName }}, {{ attr['maxArgs'] }} ), + CLASSMAPPER_FN({{ prefix }}{{ className }}, {{ attrName }}, {{ attr['maxArgs'] }} ), {% endfor %} JS_FS_END @@ -103,7 +103,7 @@ namespace Binding { {% for attrName, attr in operations %} - bool {{ className }}::JS_{{ attrName }}(JSContext *cx, JS::CallArgs &args) + bool {{ prefix }}{{ className }}::JS_{{ attrName }}(JSContext *cx, JS::CallArgs &args) { unsigned argc = args.length(); unsigned argcMin = (({{ attr['maxArgs'] }} > argc) ? (argc) : ({{ attr['maxArgs'] }})); @@ -160,15 +160,15 @@ namespace Binding { {% if members.length > 0 %} // {{ '{{{' }} Start Members - JSPropertySpec *{{ className }}::ListProperties() + JSPropertySpec *{{ prefix }}{{ className }}::ListProperties() { static JSPropertySpec props[] = { {% for attr in members %} {# TODO: ONLY-SETTER #} {% if not attr.readonly %} - CLASSMAPPER_PROP_GS({{ className }}, {{ attr.name }}), + CLASSMAPPER_PROP_GS({{ prefix }}{{ className }}, {{ attr.name }}), {% else %} - CLASSMAPPER_PROP_G({{ className }}, {{ attr.name }}), + CLASSMAPPER_PROP_G({{ prefix }}{{ className }}, {{ attr.name }}), {% endif %} {% endfor %} JS_PS_END @@ -180,7 +180,7 @@ namespace Binding { {% for attr in members %} {% if not attr.readonly %} - bool {{ className }}::JSSetter_{{ attr.name }}(JSContext *cx, JS::MutableHandleValue vp) + bool {{ prefix }}{{ className }}::JSSetter_{{ attr.name }}(JSContext *cx, JS::MutableHandleValue vp) { {# TODO: uniontype#} {{ attr.idlType }} @@ -190,7 +190,7 @@ namespace Binding { } {% endif %} - bool {{ className }}::JSGetter_{{ attr.name }}(JSContext *cx, JS::MutableHandleValue vp) + bool {{ prefix }}{{ className }}::JSGetter_{{ attr.name }}(JSContext *cx, JS::MutableHandleValue vp) { {% set need = attr.idlType.idlType %} @@ -217,20 +217,20 @@ namespace Binding { {% endif %} {% if hasAttr(extAttrs, 'exposed') %} - void {{ className }}::RegisterObject(JSContext *cx) + void {{ prefix }}{{ className }}::RegisterObject(JSContext *cx) { {% if exposed == 'class' %} - {{ className }}::ExposeClass<{{ constructors['maxArgs'] }}>(cx, "{{ name }}"); + {{ prefix }}{{ className }}::ExposeClass<{{ constructors['maxArgs'] }}>(cx, "{{ name }}"); {# TODO: HAS_RESERVED_SLOTS #} {% elif exposed == 'module' %} - JSModules::RegisterEmbedded("{{ className }}", {{ className }}::RegisterModule); + JSModules::RegisterEmbedded("{{ className }}", {{ prefix }}{{ className }}::RegisterModule); {% endif %} } {% if exposed == 'module' %} - JSObject *{{ className }}::RegisterModule(JSContext *cx) + JSObject *{{ prefix }}{{ className }}::RegisterModule(JSContext *cx) { - JS::RootedObject exports(cx, {{ className }}::ExposeObject(cx, "{{ name }}")); + JS::RootedObject exports(cx, {{ prefix }}{{ className }}::ExposeObject(cx, "{{ name }}")); return exports; } diff --git a/templates/impl_class.tpl.h b/templates/impl_class.tpl.h index 71878df..3abef3e 100644 --- a/templates/impl_class.tpl.h +++ b/templates/impl_class.tpl.h @@ -7,8 +7,8 @@ #include {% import "defs.tpl" as defs %} -#ifndef binding_{{ className }}_h__ -#define binding_{{ className }}_h__ +#ifndef binding_{{ prefix }}{{ className }}_h__ +#define binding_{{ prefix }}{{ className }}_h__ {% set header = hasAttr(extAttrs, 'headerfile') %} {% if header %} @@ -77,23 +77,23 @@ class {{ className }}_Base // {{ '}}}' }} */ -class {{ className }} : public ClassMapper{% if hasAttr(extAttrs, 'Events') %} +class {{ prefix }}{{ className }} : public ClassMapper{% if hasAttr(extAttrs, 'Events') %} WithEvents - {% endif %}<{{ className }}>, public {{ className }}_Base + {% endif %}<{{ prefix }}{{ className }}>, public {{ className }}_Base { public: {% if ctor %} {% for constructor in constructors.lst %} - {{ className }}( {{ defs.arglst(constructor.arguments) }}) + {{ prefix }}{{ className }}( {{ defs.arglst(constructor.arguments) }}) : {{ className }}_Base( {{ defs.argcall(constructor.arguments) }} ) { } {% else %} {{ className }}()::{{className}}_Base(){} {% endfor %} {% endif %} - ~{{ className }}(); + ~{{ prefix }}{{ className }}(); {% if ctor %} - static {{ className }} * Constructor(JSContext *cx, JS::CallArgs &args, + static {{ prefix }}{{ className }} * Constructor(JSContext *cx, JS::CallArgs &args, JS::HandleObject obj); static void RegisterObject(JSContext *cx); {% endif %} From 347b1acd335f60ff5445784b1efd33c42dc67c09 Mon Sep 17 00:00:00 2001 From: Peter Reijnders Date: Wed, 18 Jan 2017 18:40:58 +0100 Subject: [PATCH 20/23] NidiumModule 'Hello' looks good. --- examples/NidiumModules/idl/Hello.idl | 6 ++++-- templates/defs.tpl | 4 +++- templates/impl_class.tpl.cpp | 8 +++++--- templates/impl_class.tpl.h | 16 ++++++---------- 4 files changed, 18 insertions(+), 16 deletions(-) diff --git a/examples/NidiumModules/idl/Hello.idl b/examples/NidiumModules/idl/Hello.idl index 0ef2180..aad2463 100644 --- a/examples/NidiumModules/idl/Hello.idl +++ b/examples/NidiumModules/idl/Hello.idl @@ -1,8 +1,10 @@ [ - Constructor(DOMString bar, optional unsigned short foo), + Constructor(cstring bar, optional unsigned short foo), + headerfile=HelloBase, classname = Hello ] interface Hello { - attribute DOMString bar; + attribute cstring bar; attribute unsigned short foo; boolean foobar(unsigned short foo); }; + diff --git a/templates/defs.tpl b/templates/defs.tpl index 0eda04c..22684fd 100644 --- a/templates/defs.tpl +++ b/templates/defs.tpl @@ -26,7 +26,9 @@ __curstr_c.encodeUtf8(cx, __curstr); char *{{ dest }} = __curstr_c.ptr(); - {% elif not need != 'UNKNOWN' %} + {% elif need == 'boolean' %} + {{ need|ctype }} {{ dest }} = JS::ToBoolean( {{ jval }}); + {% elif need == 'unknown' %} //TODO: Interface {{ need.name }} : {{ jval }} {{ need }} {{dest}} {{returning}} {% else %} {{ need|ctype }} {{ dest }}; diff --git a/templates/impl_class.tpl.cpp b/templates/impl_class.tpl.cpp index 7845ae0..6e9beed 100644 --- a/templates/impl_class.tpl.cpp +++ b/templates/impl_class.tpl.cpp @@ -182,8 +182,7 @@ namespace Binding { {% if not attr.readonly %} bool {{ prefix }}{{ className }}::JSSetter_{{ attr.name }}(JSContext *cx, JS::MutableHandleValue vp) { - {# TODO: uniontype#} - {{ attr.idlType }} + {# TODO: uniontype attr.idlType #} {{ defs.jsval2c('vp', attr.idlType.idlType, 'inArg_0') }} return this->set_{{ attr.name }}(inArg_0); @@ -197,7 +196,10 @@ namespace Binding { {% if need == 'cstring' %} JS::RootedString jstr(cx, JS_NewStringCopyZ(cx, this->get_{{ attr.name }}())); vp.setString(jstr); - {% elif attr.idlType.idlType == 'UNKNOWN' %} + {% elif need == 'boolean' %} + {{ need|ctype }} cval = this->get_{{ attr.name }}(); + vp.setBoolean(cval); + {% elif attr.idlType.idlType == 'unknown' %} {# TODO InterfaceType {{ need.name }} {{attr.type.__class__}} #} {% else %} {{ need|ctype }} cval = this->get_{{ attr.name }}(); diff --git a/templates/impl_class.tpl.h b/templates/impl_class.tpl.h index 3abef3e..e9cae10 100644 --- a/templates/impl_class.tpl.h +++ b/templates/impl_class.tpl.h @@ -42,7 +42,7 @@ class {{ className }}_Base // Methods {% for attrName, attr in operations %} {% for op in attr.lst %} - {{ op.return_type.idl_type|ctype }} {{ op.name }}({{ defs.arglst(op.arguments) }}); + {{ op.return_type.idlType|ctype }} {{ op.name }}({{ defs.arglst(op.arguments) }}); {% endfor %} {% endfor %} {% endif %} @@ -51,14 +51,10 @@ class {{ className }}_Base {# TODO Setter only #} {% for attr in members %} {% if not attr.readonly %} - {% if attr.type.idl_type != 'UNKNOWN' %} - bool set_{{ attr.name }}({{ attr.type.idl_type|ctype }} {{attr.name }}); - {% else %} - bool set_{{ attr.name }}({{ attr.name }} ); - {% endif %} + bool set_{{ attr.name }}({{ attr.idlType.idlType|ctype }} {{attr.name }}); {% endif %} - {% if attr.type.idl_type != 'UNKNOWN' %} - {{ attr.type.idl_type|ctype }} get_{{ attr.name }}(); + {% if attr.idlType.idlType|ctype %} + {{ attr.idlType.idlType|ctype }} get_{{ attr.name }}(); {% else %} {{ attr.name }} get_{{ attr.name }}(); {% endif %} @@ -67,8 +63,8 @@ class {{ className }}_Base private: // Properties {% for attr in members %} - {% if attr.type.idl_type != 'UNKNOWN' %} - {{ attr.type.idl_type|ctype }} {{ attr.name }}; + {% if attr.idlType.idlType != 'UNKNOWN' %} + {{ attr.idlType.idlType|ctype }} {{ attr.name }}; {% else %} {{ attr.name }} {{ attr.name }}; {% endif %} From 4bdb401901d7d60168a6070c8f53abe6349a4f80 Mon Sep 17 00:00:00 2001 From: Peter Reijnders Date: Wed, 25 Jan 2017 12:12:51 +0100 Subject: [PATCH 21/23] Corrected several inconsistancies for static methods. --- parse.js | 31 +++-- templates/impl_class.tpl.cpp | 216 ++++++++++++++++++++--------------- templates/impl_class.tpl.h | 69 +++++++---- 3 files changed, 194 insertions(+), 122 deletions(-) diff --git a/parse.js b/parse.js index 9f6becf..980660e 100644 --- a/parse.js +++ b/parse.js @@ -113,18 +113,34 @@ NidiumIDL.prototype.printTree = function() { console.log(util.inspect(this.tree, {colors: true, depth: 16})); } + NidiumIDL.prototype.generate = function(outputPath, prefix) { var created_files = []; for (var i = 0; i < this.tree.length; i++) { var obj = this.tree[i]; - obj.getMethods = function(operations, thatAreStatic) { - statics = [] - for (var j = 0; j #include "{{ prefix }}{{ className }}.h" @@ -20,13 +24,13 @@ namespace Binding { JS::HandleObject obj) { unsigned argc = args.length(); - unsigned argcMin = (({{ constructors['maxArgs'] }} > argc) ? (argc) : ({{ constructors['maxArgs'] }})); + unsigned argcMin = (({{ constructors.maxArgs }} > argc) ? (argc) : ({{ constructors.maxArgs }})); switch (argcMin) { {% for op in constructors.lst %} case {{ op.arguments|length }}: { - /* Start arguments conversion */ + /* Start argument conversion */ {% for arg in op.arguments %} /* Handle argument #{{ loop.index0 }} of type "{{ arg.idlType.idlType }}" */ {% if not arg.idlType.nullable %} @@ -37,7 +41,7 @@ namespace Binding { {% endif %} {{ defs.jsval2c('args[' ~ loop.index0 ~ ']', arg.idlType.idlType, 'inArg_' ~ loop.index0 , 'nullptr') }} {% endfor %} - /* End of arguments conversion */ + /* End of argument conversion */ {{ prefix }}{{ className }} *n_{{ prefix }}{{ className }} = new {{ prefix }}{{ className }}( {% for i in range(0, op.arguments|length) %} @@ -61,109 +65,139 @@ namespace Binding { // {{ '}}}' }} End Constructor {% endif %} -{% set static_methods = getMethods(operations, true) %} -{% set normal_methods = getMethods(operations, false ) %} - -{% if normal_methods|length > 0 %} - // {{ '{{{' }} Start Operations - JSFunctionSpec * {{ prefix }}{{ className }}::ListMethods() - { - static JSFunctionSpec funcs[] = { - {% for attrName, attr in normal_methods %} - {% if hasAttr(attr.extAttrs, 'Alias') %} - CLASSMAPPER_FN_ALIAS({{ prefix }}{{ className }}, {{ attrName }}, {{ attr['maxArgs'] }}, {{ hasAttr( attr.extAttrs, 'Alias') }}), - {% endif %} - CLASSMAPPER_FN({{ prefix }}{{ className }}, {{ attrName }}, {{ attr['maxArgs'] }} ), - {% endfor %} +{% if (normal_methods|length + static_methods|length) > 0 %} + // {{ '{{{' }} Methods + {% if normal_methods|length > 0 %} + // List normal methods + JSFunctionSpec * {{ prefix }}{{ className }}::ListMethods() + { + static JSFunctionSpec funcs[] = { + {% for attr in normal_methods %} + {% set maxArgs = operations[attr.name].maxArgs %} + {% if hasAttr(attr.extAttrs, 'Alias') %} + CLASSMAPPER_FN_ALIAS({{ prefix }}{{ className }}, {{ attr.name }}, {{ maxArgs }}, {{ hasAttr( attr.extAttrs, 'Alias') }}), + {% endif %} + CLASSMAPPER_FN({{ prefix }}{{ className }}, {{ attr.name }}, {{ maxArgs }} ), + {% endfor %} - JS_FS_END - }; + JS_FS_END + }; - return funcs; - } + return funcs; + } {% endif %} -{% if static_methods|length > 0 %} - // {{ '{{{' }} Start Operations - JSFunctionSpec * {{ prefix }}{{ className }}::ListStaticMethods() - { - static JSFunctionSpec funcs[] = { - {% for attrName, attr in static_methods %} - {% if hasAttr(attr.extAttrs, 'Alias') %} - CLASSMAPPER_FN_ALIAS({{ prefix }}{{ className }}, {{ attrName }}, {{ attr['maxArgs'] }}, {{ hasAttr(attr.extAttrs, 'Alias') }}), - {% endif %} - CLASSMAPPER_FN({{ prefix }}{{ className }}, {{ attrName }}, {{ attr['maxArgs'] }} ), - {% endfor %} - - JS_FS_END - }; + {% if static_methods|length > 0 %} + // List static methods + JSFunctionSpec * {{ prefix }}{{ className }}::ListStaticMethods() + { + static JSFunctionSpec funcs[] = { + {% for attr in static_methods %} + {% set maxArgs = operations[attr.name].maxArgs %} + {% if hasAttr(attr.extAttrs, 'Alias') %} + CLASSMAPPER_FN_ALIAS({{ prefix }}{{ className }}, {{ attr.name }}, {{ maxArgs }}, {{ hasAttr(attr.extAttrs, 'Alias') }}), + {% endif %} + {% if attr.static %} + CLASSMAPPER_FN_STATIC({{ prefix }}{{ className }}, {{ attr.name }}, {{ maxArgs }} ), + {% else %} + CLASSMAPPER_FN({{ prefix }}{{ className }}, {{ attr.name }}, {{ maxArgs }} ), + {% endif %} + {% endfor %} - return funcs; - } + JS_FS_END + }; + return funcs; + } + {% endif %} - {% for attrName, attr in operations %} - bool {{ prefix }}{{ className }}::JS_{{ attrName }}(JSContext *cx, JS::CallArgs &args) - { - unsigned argc = args.length(); - unsigned argcMin = (({{ attr['maxArgs'] }} > argc) ? (argc) : ({{ attr['maxArgs'] }})); - {#TODO: optimize when argcMin == 0 #} - switch (argcMin) { - {% for op in attr.lst %} - case {{ op.arguments|length }}: - { - /* Start arguments conversion */ - {% for arg in op.arguments %} - /* Handle argument #{{ loop.index0 }} of type "{{ arg.idlType.idlType }}" */ - {% if not arg.idlType.nullable %} - if (args[{{ loop.index0 }}].isNull()) { + // Methods implementation + {% for method_list in [normal_methods, static_methods ] %} + {% for attr in method_list %} + {% set maxArgs = operations[attr.name].maxArgs %} + // {{ '{{{' }} Start method {{ attr.name }} + {% if attr.static %} + bool {{ prefix }}{{ className }}::JSStatic_{{ attr.name }}(JSContext *cx, JS::CallArgs &args) + {% else %} + bool {{ prefix }}{{ className }}::JS_{{ attr.name }}(JSContext *cx, JS::CallArgs &args) + {%endif %} + { + unsigned argc = args.length(); + unsigned argcMin = (({{maxArgs }} > argc) ? (argc) : ({{ maxArgs }})); + {#TODO: optimize when argcMin == 0 #} + switch (argcMin) { + {% for op in operations[attr.name].lst %} + case {{ op.arguments|length }}: + { + /* Start argument conversion */ + {% for arg in op.arguments %} + /* Handle argument #{{ loop.index0 }} of type "{{ arg.idlType.idlType }}" */ + {% if not arg.idlType.nullable %} + if (args[{{ loop.index0 }}].isNull()) { + JS_ReportError(cx, "TypeError"); + return false; + } + {% endif %} + {# TODO union-types #} + {% if arg.idlType.idlType != 'UNKNOWN' %} + {{ defs.jsval2c('args[' ~ loop.index0 ~ ']', arg.idlType.idlType, 'inArg_' ~ loop.index0) }} + {% else %} + {{ defs.jsval2c('args[' ~ loop.index0 ~ ']', arg.type, 'inArg_' ~ loop.index0) }} + {% endif %} + {% endfor %} + + /* End of argument conversion */ + {# if op.idlType.idlType|ctype != 'void' #} + {{ op.idlType.idlType|ctype }} _opret = + {#endif #} + {% if attr.static %}{{ prefix }}{{ className }}::{% else %}this->{% endif %} + {{ attr.name }}( + {% for i in range(0, op.arguments|length) %} + inArg_{{ i }}{{ ' ' if loop.last else ', ' }} + {% endfor %} + ); + {% set need = attr.idlType.idlType %} + {% if need == 'cstring' %} + JS::RootedString jstr0(cx, JS_NewStringCopyZ(cx, _opret)); + args.rval().setString(jstr); + {% elif need == 'boolean' %} + args.rval().setBoolean(_opret); + {% elif attr.idlType.idlType == 'unknown' %} + {# TODO InterfaceType {{ need }} {{ need.idlType}} #} + {% else %} + JS::RootedValue jval(cx); + if (!JS::{{ need | convert }}(cx, jval, &_opret)) { JS_ReportError(cx, "TypeError"); return false; } + args.rval().set(jval); {% endif %} - {# TODO union-types #} - {% if arg.idlType.idlType != 'UNKNOWN' %} - {{ defs.jsval2c('args[' ~ loop.index0 ~ ']', arg.idlType.idlType, 'inArg_' ~ loop.index0) }} - {% else %} - {{ defs.jsval2c('args[' ~ loop.index0 ~ ']', arg.type, 'inArg_' ~ loop.index0) }} - {% endif %} - {% endfor %} - - /* End of arguments conversion */ - {% if op.return.idlType.idlType|ctype != 'void' %} - {{ op.return.idlType.idlType|ctype }} _opret = - {%endif %} - this->{{ attrName }}( - {% for i in range(0, op.arguments|length) %} - inArg_{{ i }}{{ ' ' if loop.last else ', ' }} - {% endfor %} - ); - {% if op.return.idlType.idlType != 'void' %} - args.rval().set{{ op.return.idlType.idlType|jsvaltype|capitalize }}(_opret); - {% endif %} + break; + } + {% endfor %} + default: + JS_ReportError(cx, "TypeError: wrong number of arguments"); + return false; break; - } - {% endfor %} - default: - JS_ReportError(cx, "TypeError: wrong number of arguments"); - return false; - break; - } + } - return true; - } + return true; + } + // {{ '}}}' }} End method {{ attr.name }} + {% endfor %} {% endfor %} - // {{ '}}}' }} End Operations + // {{ '}}}' }} End Methods {% endif %} -{% if members.length > 0 %} - // {{ '{{{' }} Start Members +{% if properties|length > 0 %} + // {{ '{{{' }} Properties + // List properties JSPropertySpec *{{ prefix }}{{ className }}::ListProperties() { static JSPropertySpec props[] = { - {% for attr in members %} + {% for attr in properties %} {# TODO: ONLY-SETTER #} {% if not attr.readonly %} CLASSMAPPER_PROP_GS({{ prefix }}{{ className }}, {{ attr.name }}), @@ -177,9 +211,10 @@ namespace Binding { return props; } - - {% for attr in members %} + {% for attr in properties %} + // {{ '{{{' }} Start property {{ attr.name }} {% if not attr.readonly %} + // Setter {{ attr.name }} bool {{ prefix }}{{ className }}::JSSetter_{{ attr.name }}(JSContext *cx, JS::MutableHandleValue vp) { {# TODO: uniontype attr.idlType #} @@ -188,7 +223,7 @@ namespace Binding { return this->set_{{ attr.name }}(inArg_0); } {% endif %} - + // Getter {{ attr.name }} bool {{ prefix }}{{ className }}::JSGetter_{{ attr.name }}(JSContext *cx, JS::MutableHandleValue vp) { {% set need = attr.idlType.idlType %} @@ -213,16 +248,17 @@ namespace Binding { return true; } + // {{ '}}}' }} End property {{ attr.name }} {% endfor %} -// {{ '}}}' }} End Members +// {{ '}}}' }} End Properties {% endif %} {% if hasAttr(extAttrs, 'exposed') %} void {{ prefix }}{{ className }}::RegisterObject(JSContext *cx) { {% if exposed == 'class' %} - {{ prefix }}{{ className }}::ExposeClass<{{ constructors['maxArgs'] }}>(cx, "{{ name }}"); + {{ prefix }}{{ className }}::ExposeClass<{{ constructors.maxArgs }}>(cx, "{{ name }}"); {# TODO: HAS_RESERVED_SLOTS #} {% elif exposed == 'module' %} JSModules::RegisterEmbedded("{{ className }}", {{ prefix }}{{ className }}::RegisterModule); diff --git a/templates/impl_class.tpl.h b/templates/impl_class.tpl.h index e9cae10..0b7fdb1 100644 --- a/templates/impl_class.tpl.h +++ b/templates/impl_class.tpl.h @@ -7,6 +7,10 @@ #include {% import "defs.tpl" as defs %} +{% set static_methods = getMethods(members, true) %} +{% set normal_methods = getMethods(members, false) %} +{% set properties = getProperties(members) %} + #ifndef binding_{{ prefix }}{{ className }}_h__ #define binding_{{ prefix }}{{ className }}_h__ @@ -20,16 +24,16 @@ namespace Nidium { namespace Binding { -// {{ '{{{' }} fake {{ className }} -/* -//This is a model of our imaginary base class '{{ className }}' +// {{ '{{{' }} fake {{ className }}_Base +#if 0 +//This is a model of our imaginary base class '{{ className }}_Base' class {{ className }}_Base { public: + // Constructor {% if ctor %} - // Constructor {% for constructor in constructors.lst %} {{ className }}_Base({{ defs.arglst(constructor.arguments) }}); {% endfor %} @@ -38,18 +42,25 @@ class {{ className }}_Base {% endif %} ~{{ className }}_Base(); protected: - {% if operations|length > 0 %} - // Methods - {% for attrName, attr in operations %} - {% for op in attr.lst %} - {{ op.return_type.idlType|ctype }} {{ op.name }}({{ defs.arglst(op.arguments) }}); + // Methods + {% for method_list in [normal_methods, static_methods ] %} + {% for op in method_list %} + {% if operations[op.name].lst|length > 1 %} + // Overloading {{ op.name}}-s methods + {% endif %} + {% for attr in operations[op.name].lst %} + {% if attr.static %}static {% endif %} + {# if op.idlType.idlType|ctype != 'void' #} + {{ op.idlType.idlType|ctype }} + {#endif #} + {{ attr.return_type.idlType|ctype }} {{ attr.name }}({{ defs.arglst(attr.arguments) }}); {% endfor %} {% endfor %} - {% endif %} - {% if members.length > 0 %} - // Properties + {% endfor %} + // Properties + {% if properties|length > 0 %} {# TODO Setter only #} - {% for attr in members %} + {% for attr in properties %} {% if not attr.readonly %} bool set_{{ attr.name }}({{ attr.idlType.idlType|ctype }} {{attr.name }}); {% endif %} @@ -62,7 +73,7 @@ class {{ className }}_Base {% endif %} private: // Properties - {% for attr in members %} + {% for attr in properties %} {% if attr.idlType.idlType != 'UNKNOWN' %} {{ attr.idlType.idlType|ctype }} {{ attr.name }}; {% else %} @@ -70,8 +81,8 @@ class {{ className }}_Base {% endif %} {% endfor %} }; +#endif // {{ '}}}' }} -*/ class {{ prefix }}{{ className }} : public ClassMapper{% if hasAttr(extAttrs, 'Events') %} WithEvents @@ -89,36 +100,44 @@ class {{ prefix }}{{ className }} : public ClassMapper{% if hasAttr(extAttrs, 'E ~{{ prefix }}{{ className }}(); {% if ctor %} + //Constructor static {{ prefix }}{{ className }} * Constructor(JSContext *cx, JS::CallArgs &args, JS::HandleObject obj); - static void RegisterObject(JSContext *cx); {% endif %} - {% set static_methods = getMethods(operations, true) %} - {% set normal_methods = getMethods(operations, false) %} - {% if normal_methods.lenght > 0 %} + //Listings + {% if normal_methods|length > 0 %} static JSFunctionSpec * ListMethods(); {% endif %} - {% if static_methods.lenght > 0 %} + {% if static_methods|length > 0 %} static JSFunctionSpec * ListStaticMethods(); {% endif %} - {% if members.length > 0 %} - static JSPropertySpec *ListProperties(); + {% if properties|length > 0 %} + static JSPropertySpec * ListProperties(); {% endif %} + //Registration {% if hasAttr(extAttrs, 'exposed') %} static void RegisterObject(JSContext *cx); {% endif %} protected: - {% for attrName, attr in operations %} - NIDIUM_DECL_JSCALL{%if attr.static%}STATIC{% endif%}({{ attrName }}); + //Methods + {% for attr in static_methods %} + {# this is one js entry point, no method overloading #} + NIDIUM_DECL_JSCALL_STATIC({{ attr.name }}); + {% endfor %} + {% for attr in normal_methods %} + {# this is one js entry point, no method overloading #} + NIDIUM_DECL_JSCALL({{ attr.name }}); {% endfor %} {# TODO ONLY-SETTER #} - {% for attr in members %} + //Properties + {% for attr in properties %} {% if not attr.readonly %} NIDIUM_DECL_JSGETTERSETTER({{ attr.name }}); {% else %} NIDIUM_DECL_JSGETTER({{ attr.name }}); {% endif %} {% endfor %} + //Registration {% if hasAttr(extAttrs, 'exposed') == 'module' %} static JSObject *RegisterModule(JSContext *cx); {% endif %} From 12babd2530d9a5f8a08a04929038fe2c99ce7d54 Mon Sep 17 00:00:00 2001 From: Peter Reijnders Date: Wed, 25 Jan 2017 13:44:57 +0100 Subject: [PATCH 22/23] Registration process works with the Axtended Attribute 'exposed': 5 flavors * not set: not exposed * 'class': build in (Socket) * 'embed': build, but not loaded in the namespace by default (DB) * 'module': module that is dynamically loaded * /a-z/+: build in module, that is loaded only once, and it's instance is put in the global object. todo: Alias & Implemented as --- examples/NidiumModules/idl/Hello.idl | 13 +++++--- parse.js | 2 +- templates/impl_class.tpl.cpp | 49 +++++++++++++++++++++------- templates/impl_class.tpl.h | 25 +++++++++++++- 4 files changed, 71 insertions(+), 18 deletions(-) diff --git a/examples/NidiumModules/idl/Hello.idl b/examples/NidiumModules/idl/Hello.idl index aad2463..09f2913 100644 --- a/examples/NidiumModules/idl/Hello.idl +++ b/examples/NidiumModules/idl/Hello.idl @@ -1,10 +1,13 @@ [ Constructor(cstring bar, optional unsigned short foo), - headerfile=HelloBase, - classname = Hello + classname = Hello /* obligated, but could default to the file's basename*/ + ,headerfile=HelloBase /*optional; '.h' is added + , exposed=class /*'class'|'embed'|'module'|/a-z+/ thus 'once' or not defined at all to not expose */ + /*missing attributes: Alias ImplementedAs*/ ] interface Hello { - attribute cstring bar; - attribute unsigned short foo; - boolean foobar(unsigned short foo); + readonly attribute unsigned short foo; + attribute cstring bar; + boolean foobar(unsigned short foo); + static unsigned short barfoo(unsigned short bar); }; diff --git a/parse.js b/parse.js index 980660e..1c97b82 100644 --- a/parse.js +++ b/parse.js @@ -211,7 +211,7 @@ NidiumIDL.prototype.createInterface = function(outputPath, obj, prefix) obj.operations = operations; obj.prefix = prefix; - console.log(obj); + console.log(obj.hasAttr(obj.extAttrs, 'exposed')); //console.log(obj.operations['foobar'].lst[0].idlType); var interfaceHeader = this.env.render('impl_class.tpl.h', obj); var fileNameHeader = outputPath + "/" + prefix + obj.className + ".h"; diff --git a/templates/impl_class.tpl.cpp b/templates/impl_class.tpl.cpp index 3a2f137..ad35ebf 100644 --- a/templates/impl_class.tpl.cpp +++ b/templates/impl_class.tpl.cpp @@ -9,10 +9,15 @@ {% set static_methods = getMethods(members, true) %} {% set normal_methods = getMethods(members, false ) %} {% set properties = getProperties(members) %} +{% set exposed = hasAttr(extAttrs, 'exposed') %} #include #include "{{ prefix }}{{ className }}.h" +{% if exposed.rhs.value == 'module' %} +#include "Binding/JSModules.h" +{% endif %} + namespace Nidium { namespace Binding { @@ -254,26 +259,48 @@ namespace Binding { // {{ '}}}' }} End Properties {% endif %} -{% if hasAttr(extAttrs, 'exposed') %} - void {{ prefix }}{{ className }}::RegisterObject(JSContext *cx) - { - {% if exposed == 'class' %} - {{ prefix }}{{ className }}::ExposeClass<{{ constructors.maxArgs }}>(cx, "{{ name }}"); - {# TODO: HAS_RESERVED_SLOTS #} - {% elif exposed == 'module' %} - JSModules::RegisterEmbedded("{{ className }}", {{ prefix }}{{ className }}::RegisterModule); - {% endif %} - } +{% if exposed %} +// {{ '{{{' }} Registration + {% if exposed.rhs.value == 'class' %} + {# nothing special #} + {% elif exposed.rhs.value == 'embed' %} + static JSObject *registerCallback(JSContext *cx) + { + JS::RootedObject obj(cx, JS_NewPlainObject(cx)); + {{ prefix }}{{ classname }}::ExposeClass<1>(cx, "{{ classname }}", 0, {{ prefix }}{{ classname }}::kEmpty_ExposeFlag, obj); + JS::RootedValue val(cx); + if (!JS_GetProperty(cx, obj, {{ classname }}, &val)) { + return nullptr; + } + JS::RootedObject ret(cx, val.toObjectOrNull()); - {% if exposed == 'module' %} + return ret; + } + {% elif exposed.rhs.value == 'module' %} JSObject *{{ prefix }}{{ className }}::RegisterModule(JSContext *cx) { JS::RootedObject exports(cx, {{ prefix }}{{ className }}::ExposeObject(cx, "{{ name }}")); return exports; } + {% else %} + {# thus this exposed=='embed', the rhs.value is the name to expose to #} {% endif %} + void {{ prefix }}{{ className }}::RegisterObject(JSContext *cx) + { + {# TODO: HAS_RESERVED_SLOTS #} + {% if exposed.rhs.value == 'class' %} + {% elif exposed.rhs.value == 'embed' %} + JSModules::RegisterEmbedded("{{ className }}", registerCallback); + {% elif exposed.rhs.value == 'module' %} + JSModules::RegisterEmbedded("{{ className }}", {{ prefix }}{{ className }}::RegisterModule); + {% else %} + {# thus this exposed == 'embed', the rhs.value is the name to expose to #} + {{ prefix }}{{ className }}::ExposeClass(cx, "{{ className }}"); + {{ prefix }}{{ className }}::CreateUniqueInstance(cx, new {{ prefix}}{{ className }}(), "{{ exposed.rhs.value }}"); + {% endif %} + } {% endif %} // {{ '}}}' }} diff --git a/templates/impl_class.tpl.h b/templates/impl_class.tpl.h index 0b7fdb1..124544b 100644 --- a/templates/impl_class.tpl.h +++ b/templates/impl_class.tpl.h @@ -10,6 +10,7 @@ {% set static_methods = getMethods(members, true) %} {% set normal_methods = getMethods(members, false) %} {% set properties = getProperties(members) %} +{% set exposed = hasAttr(extAttrs, 'exposed') %} #ifndef binding_{{ prefix }}{{ className }}_h__ #define binding_{{ prefix }}{{ className }}_h__ @@ -40,6 +41,16 @@ class {{ className }}_Base {% else %} {{ className }}_Base(){}; {% endif %} + {% if exposed.rhs.value == 'class' %} + {# nothing special #} + {% elif exposed.rhs.value == 'embedded' %} + {# nothing special #} + {% elif exposed.rhs.value == 'module' %} + {% else %} + {# thus this exposed=='embed', the rhs.value is the name to expose to #} + {# todo only generate the default constructor if that was not already generated by .lst #} + {{ className }}_Base (); + {% endif %} ~{{ className }}_Base(); protected: // Methods @@ -97,6 +108,18 @@ class {{ prefix }}{{ className }} : public ClassMapper{% if hasAttr(extAttrs, 'E {{ className }}()::{{className}}_Base(){} {% endfor %} {% endif %} + {% if exposed.rhs.value == 'class' %} + {# nothing special #} + {% elif exposed.rhs.value == 'embedded' %} + {# nothing special #} + {% elif exposed.rhs.value == 'module' %} + {% else %} + {# thus this exposed=='embed', the rhs.value is the name to expose to #} + {# todo only generate the default constructor if that was not already generated by .lst #} + {{ prefix }}{{ className }}() { + {{ className }}_Base (); + } + {% endif %} ~{{ prefix }}{{ className }}(); {% if ctor %} @@ -138,7 +161,7 @@ class {{ prefix }}{{ className }} : public ClassMapper{% if hasAttr(extAttrs, 'E {% endif %} {% endfor %} //Registration - {% if hasAttr(extAttrs, 'exposed') == 'module' %} + {% if exposed.rhs.value == 'module' %} static JSObject *RegisterModule(JSContext *cx); {% endif %} From 661aeb86667a8f63159212315e2e3d7318be7698 Mon Sep 17 00:00:00 2001 From: Peter Reijnders Date: Fri, 27 Jan 2017 09:30:47 +0100 Subject: [PATCH 23/23] Processed feedback - rename class Base - indentation - removed ctor/dtor - fixed a bug in the registration - removed '->root()' - added a 'void registrationHook()' --- examples/NidiumModules/idl/Hello.idl | 5 ++-- templates/dict_class.tpl.h | 2 +- templates/impl_class.tpl.cpp | 12 ++++---- templates/impl_class.tpl.h | 41 ++++++++++++++-------------- 4 files changed, 30 insertions(+), 30 deletions(-) diff --git a/examples/NidiumModules/idl/Hello.idl b/examples/NidiumModules/idl/Hello.idl index 09f2913..805818a 100644 --- a/examples/NidiumModules/idl/Hello.idl +++ b/examples/NidiumModules/idl/Hello.idl @@ -1,9 +1,10 @@ [ Constructor(cstring bar, optional unsigned short foo), classname = Hello /* obligated, but could default to the file's basename*/ - ,headerfile=HelloBase /*optional; '.h' is added - , exposed=class /*'class'|'embed'|'module'|/a-z+/ thus 'once' or not defined at all to not expose */ + ,headerfile=HelloBase /*optional; '.h' is added */ + /*,exposed=class *//*'class'|'embed'|'module'|/a-z+/ thus 'once' or not defined at all to not expose */ /*missing attributes: Alias ImplementedAs*/ + ] interface Hello { readonly attribute unsigned short foo; attribute cstring bar; diff --git a/templates/dict_class.tpl.h b/templates/dict_class.tpl.h index a722925..e486070 100644 --- a/templates/dict_class.tpl.h +++ b/templates/dict_class.tpl.h @@ -13,7 +13,7 @@ namespace Nidium { namespace Binding { -// {{ '{{{' }} Dict_{{prefix}}{{ name }} +// {{ '{{{' }} Dict_{{ prefix }}{{ name }} class Dict_{{prefix}}{{ name }} : public Dict { public: diff --git a/templates/impl_class.tpl.cpp b/templates/impl_class.tpl.cpp index ad35ebf..1d297f9 100644 --- a/templates/impl_class.tpl.cpp +++ b/templates/impl_class.tpl.cpp @@ -14,7 +14,7 @@ #include #include "{{ prefix }}{{ className }}.h" -{% if exposed.rhs.value == 'module' %} +{% if exposed.rhs.value == 'module' or exposed.rhs.value == 'embed' %} #include "Binding/JSModules.h" {% endif %} @@ -53,7 +53,6 @@ namespace Binding { inArg_{{ i }}{{ ' ' if loop.last else ', ' }} {% endfor %} ); - n_{{ prefix }}{{ className }}->root(); return n_{{ prefix }}{{ className }}; break; @@ -267,9 +266,9 @@ namespace Binding { static JSObject *registerCallback(JSContext *cx) { JS::RootedObject obj(cx, JS_NewPlainObject(cx)); - {{ prefix }}{{ classname }}::ExposeClass<1>(cx, "{{ classname }}", 0, {{ prefix }}{{ classname }}::kEmpty_ExposeFlag, obj); + {{ prefix }}{{ className }}::ExposeClass<1>(cx, "{{ className }}", 0, {{ prefix }}{{ className }}::kEmpty_ExposeFlag, obj); JS::RootedValue val(cx); - if (!JS_GetProperty(cx, obj, {{ classname }}, &val)) { + if (!JS_GetProperty(cx, obj, "{{ className }}", &val)) { return nullptr; } JS::RootedObject ret(cx, val.toObjectOrNull()); @@ -284,7 +283,7 @@ namespace Binding { return exports; } {% else %} - {# thus this exposed=='embed', the rhs.value is the name to expose to #} + {# thus this exposed == 'once', the rhs.value is the name to expose to #} {% endif %} void {{ prefix }}{{ className }}::RegisterObject(JSContext *cx) @@ -296,10 +295,11 @@ namespace Binding { {% elif exposed.rhs.value == 'module' %} JSModules::RegisterEmbedded("{{ className }}", {{ prefix }}{{ className }}::RegisterModule); {% else %} - {# thus this exposed == 'embed', the rhs.value is the name to expose to #} + {# thus this exposed == 'once', the rhs.value is the name to expose to #} {{ prefix }}{{ className }}::ExposeClass(cx, "{{ className }}"); {{ prefix }}{{ className }}::CreateUniqueInstance(cx, new {{ prefix}}{{ className }}(), "{{ exposed.rhs.value }}"); {% endif %} + {# //todo: call the created instances->registrationHook();#} } {% endif %} // {{ '}}}' }} diff --git a/templates/impl_class.tpl.h b/templates/impl_class.tpl.h index 124544b..5382e1e 100644 --- a/templates/impl_class.tpl.h +++ b/templates/impl_class.tpl.h @@ -3,6 +3,7 @@ Use of this source code is governed by a MIT license that can be found in the LICENSE file. */ + #include #include {% import "defs.tpl" as defs %} @@ -25,34 +26,31 @@ namespace Nidium { namespace Binding { - -// {{ '{{{' }} fake {{ className }}_Base +// {{ '{{{' }} fake {{ className }}Base #if 0 -//This is a model of our imaginary base class '{{ className }}_Base' +//This is a model of our imaginary base class '{{ className }}Base' -class {{ className }}_Base +class {{ className }}Base { public: // Constructor {% if ctor %} {% for constructor in constructors.lst %} - {{ className }}_Base({{ defs.arglst(constructor.arguments) }}); + {{ className }}Base({{ defs.arglst(constructor.arguments) }}); {% endfor %} - {% else %} - {{ className }}_Base(){}; {% endif %} {% if exposed.rhs.value == 'class' %} {# nothing special #} - {% elif exposed.rhs.value == 'embedded' %} + {% elif exposed.rhs.value == 'embed' %} {# nothing special #} {% elif exposed.rhs.value == 'module' %} {% else %} - {# thus this exposed=='embed', the rhs.value is the name to expose to #} + {# thus this exposed == 'once', the rhs.value is the name to expose to #} {# todo only generate the default constructor if that was not already generated by .lst #} - {{ className }}_Base (); + {{ className }}Base (); {% endif %} - ~{{ className }}_Base(); protected: + void registrationHook() = 0; // Methods {% for method_list in [normal_methods, static_methods ] %} {% for op in method_list %} @@ -97,28 +95,28 @@ class {{ className }}_Base class {{ prefix }}{{ className }} : public ClassMapper{% if hasAttr(extAttrs, 'Events') %} WithEvents - {% endif %}<{{ prefix }}{{ className }}>, public {{ className }}_Base + {% endif %}<{{ prefix }}{{ className }}>, public {{ className }}Base { public: {% if ctor %} {% for constructor in constructors.lst %} {{ prefix }}{{ className }}( {{ defs.arglst(constructor.arguments) }}) - : {{ className }}_Base( {{ defs.argcall(constructor.arguments) }} ) { } - {% else %} - {{ className }}()::{{className}}_Base(){} + : {{ className }}Base( {{ defs.argcall(constructor.arguments) }} ) { } {% endfor %} +{% else %} + {{ className }}()::{{className}}Base(){} {% endif %} {% if exposed.rhs.value == 'class' %} {# nothing special #} - {% elif exposed.rhs.value == 'embedded' %} + {% elif exposed.rhs.value == 'embed' %} {# nothing special #} {% elif exposed.rhs.value == 'module' %} {% else %} - {# thus this exposed=='embed', the rhs.value is the name to expose to #} - {# todo only generate the default constructor if that was not already generated by .lst #} - {{ prefix }}{{ className }}() { - {{ className }}_Base (); - } + {# thus this exposed == 'once', the rhs.value is the name to expose to #} + {# todo only generate the default constructor if that was not already generated by .lst #} + {{ prefix }}{{ className }}() { + {{ className }}Base (); + } {% endif %} ~{{ prefix }}{{ className }}(); @@ -171,3 +169,4 @@ class {{ prefix }}{{ className }} : public ClassMapper{% if hasAttr(extAttrs, 'E } // namespace Nidium #endif +