Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
60d79c7
Initial work on combyne templates
tbranyen Jul 19, 2014
391b3ed
Started working on replacing the header template
tbranyen Jul 22, 2014
f522bd6
Upgraded all dependencies
tbranyen Sep 24, 2014
5953faa
Converting more templates to Combyne
Sep 25, 2014
6a92dd2
Missed an els tag
Sep 26, 2014
6cffb84
Starting to fix template compile time errors
Sep 26, 2014
ed07f2a
Fixed more compile time errors
Sep 26, 2014
82167de
Stopped using a reserved word in the template.
Sep 26, 2014
16f9358
Bump Combyne version to fix partials issue
tbranyen Sep 26, 2014
38d7fc7
Remove functionInfo references
tbranyen Sep 26, 2014
b7b5c11
Updated gitignore to include log files
Sep 26, 2014
8d440d9
Added more combyne template files
Sep 26, 2014
9e929cf
Starting to work on sync_functions.cc
Sep 27, 2014
e52b9c0
Fixed an issue with the returns in the async function template
Sep 27, 2014
3c992e5
Fixing more bugs with the template build
Sep 29, 2014
cac4c8c
Templates build now
Sep 29, 2014
a288308
Fixed bug in header.h template
Sep 29, 2014
89cec60
More work on getting partials to have the right data
Sep 29, 2014
9c37236
Starting to make combyne templates 1:1 with ejs
Sep 29, 2014
10c2132
Getting close to template 1:1
Sep 29, 2014
e57b390
Combyne templates are almost finished
Sep 30, 2014
415e22a
Fixed sync_function.cc calling convertFromV8 for returns and self vars
Sep 30, 2014
ff17f1c
Removed ejs template files
Sep 30, 2014
6b30987
More fixes to generated files
Oct 2, 2014
70aefe5
Starting to put the filters for templates back in
Oct 3, 2014
f34ccc2
Added hasReturnType and isDoublePointer filter back in
Oct 3, 2014
79fe10b
Added more filters for combine templates back in
Oct 3, 2014
cac31a5
Some cleanup in templates
Oct 3, 2014
89a94ca
Fixed some more issues with the template conversion
Oct 3, 2014
8f16afa
Combyne templates are good
Oct 4, 2014
6865040
Moved comments into partial, fixed alignment
tbranyen Oct 4, 2014
db670ba
Generated templates are looking better
Oct 6, 2014
9a29299
Updated all NPM dependencies
tbranyen Oct 7, 2014
bc0e87e
Updated the README examples to use promises
tbranyen Oct 7, 2014
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Combyne templates are almost finished
  • Loading branch information
John Haley
John Haley committed Oct 4, 2014
commit e57b390579e0890f8e15e4882039baba620b58bb
3 changes: 0 additions & 3 deletions generate/filters/is_pointer.js

This file was deleted.

23 changes: 20 additions & 3 deletions generate/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ var filters = {
or: require("./filters/or"),
and: require("./filters/and"),
isV8Value: require("./filters/is_v8_value"),
isPointer: require("./filters/is_pointer"),
unPointer: require("./filters/un_pointer"),
defaultValue: require("./filters/default_value")
};
Expand All @@ -58,7 +57,8 @@ Object.keys(partials).forEach(function(partial) {
var enabled = idefs.filter(function(idef) {
// Additionally provide a friendly name to the actual filename.
idef.name = path.basename(idef.filename, ".h");

idef.cTypeIsUndefined = typeof idef.cType == 'undefined';

// We need some custom data on each of the functions
idef.functions.forEach(function(fn) {
fn.cppClassName = idef.cppClassName;
Expand Down Expand Up @@ -102,6 +102,7 @@ var enabled = idefs.filter(function(idef) {
arg.cArg = cArg;
arg.v8ValueClassName = cppToV8(arg.cppClassName);
arg.isCppClassStringOrArray = ~["String", "Array"].indexOf(arg.cppClassName);
arg.isPointer = /\s*\*\s*/.test(arg.cType);
arg.isDoublePointer = /\s*\*\*\s*/.test(arg.cType);
arg.isV8Value = ~v8Values.indexOf(arg.cppClassName);

Expand All @@ -113,7 +114,7 @@ var enabled = idefs.filter(function(idef) {
fn.returns = [];

// generate returns data
fn.args.forEach(function(arg) {
fn.argsInfo.forEach(function(arg) {
if (!arg.isReturn) return;

var _return = {};
Expand All @@ -134,6 +135,21 @@ var enabled = idefs.filter(function(idef) {
if (!fn.returns.length
&& !fn.return.isErrorCode
&& fn.return.cType != "void") {
var _return = {};

_return = fn.return;

_return.v8ValueClassName = cppToV8(_return.cppClassName);
_return.isCppClassStringOrArray = ~["String", "Array"].indexOf(_return.cppClassName);
_return.isPointer = /\s*\*\s*/.test(_return.cType);
_return.isDoublePointer = /\s*\*\*\s*/.test(_return.cType);
_return.isV8Value = ~v8Values.indexOf(_return.cppClassName);
_return.parsedName = 'result';
_return.jsOrCppClassName = _return.jsClassName || _return.cppClassName;
_return.isCppClassIntType = ~["Uint32", "Int32"].indexOf(_return.cppClassName);
_return.parsedClassName = (_return.cppClassName || '').toLowerCase() + "_t";
_return.jsNameOrName = _return.jsName | _return.name;

fn.returns.push(fn.return);
}

Expand All @@ -155,6 +171,7 @@ var enabled = idefs.filter(function(idef) {
fieldInfo.parsedName = field.name || "result";
fieldInfo.isCppClassIntType = ~["Uin32", "Int32"].indexOf(field.cppClassName);
fieldInfo.parsedClassName = (field.cppClassName || '').toLowerCase() + "_t";
fieldInfo.isV8Value = ~v8Values.indexOf(field.cppClassName);

fn.fieldInfos.push(fieldInfo);
});
Expand Down
2 changes: 1 addition & 1 deletion generate/partials/convert_from_v8.cc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{%if not isPayload %}
{{ cType }} from_{{ name }};
{%if isOptional %}
if (args{{[ jsArg }}]->Is{{ v8ValueClassName }}()) {
if (args[{{ jsArg }}]->Is{{ v8ValueClassName }}()) {
{%endif%}
{%if cppClassName == 'String' %}
String::Utf8Value {{ name }}(args[{{ jsArg }}]->ToString());
Expand Down
8 changes: 5 additions & 3 deletions generate/partials/convert_to_v8.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ to = NanNew<String>({{{ parsedName }}});
{%if freeFunctionName %}
{{ freeFunctionName }}({{{ parsedName }}});
{%endif%}
{%elsif cppClassName|isV8Value %}
{%elsif isV8Value %}
{%if isCppClassIntType %}
to = NanNew<{{ cppClassName }}>(({{ parsedClassName }}){{{ parsedName }}});
{%else%}
Expand All @@ -19,7 +19,9 @@ to = NanNew<{{ cppClassName }}>({{{ parsedName }}});
{%elsif cppClassName == 'External' %}
to = NanNew<External>((void *){{{ parsedName }}});
{%elsif cppClassName == 'Array' %}
{%-- // FIXME this is not general purpose enough. --%}
{%--
// FIXME this is not general purpose enough.
--%}
Local<Array> tmpArray = NanNew<Array>({{{ parsedName }}}->{{ size }});
for (unsigned int i = 0; i < {{{ parsedName }}}->{{ size }}; i++) {
tmpArray->Set(NanNew<Number>(i), NanNew<String>({{{ parsedName }}}->{{ key }}[i]));
Expand All @@ -28,7 +30,7 @@ to = tmpArray;
{%else%}
{%if copy %}
if ({{{ parsedName }}} != NULL) {
{{{ parsedName }}} = ({{ cType|replace '**' '*' }} {%if cType|isPointer %}*{%endif%}){{ copy }}({{{ parsedName }}});
{{{ parsedName }}} = ({{ cType|replace '**' '*' }} {%if isPointer %}*{%endif%}){{ copy }}({{{ parsedName }}});
}
{%endif%}
if ({{{ parsedName }}} != NULL) {
Expand Down
4 changes: 2 additions & 2 deletions generate/partials/fields.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ NAN_METHOD({{ cppClassName }}::{{ field.cppFunctionName }}) {
NanScope();
Handle<Value> to;

{{ field.cType }} {%if field.cppClassName|isV8Value %}*{%endif%}{{ field.name }} =
{%if not field.cppClassName|isV8Value %}&{%endif%}ObjectWrap::Unwrap<{{ cppClassName }}>(args.This())->GetValue()->{{ field.name }};
{{ field.cType }} {%if field.isV8Value %}*{%endif%}{{ field.name }} =
{%if not field.isV8Value %}&{%endif%}ObjectWrap::Unwrap<{{ cppClassName }}>(args.This())->GetValue()->{{ field.name }};

{%partial convertToV8 field %}
NanReturnValue(to);
Expand Down
1 change: 1 addition & 0 deletions generate/partials/sync_function.cc
Original file line number Diff line number Diff line change
Expand Up @@ -81,5 +81,6 @@ from_{{ arg.name }}
NanReturnValue(to);
{%else%}
NanReturnValue(toReturn);
{%endif%}
{%endif%}
}
2 changes: 1 addition & 1 deletion generate/templates/class.cc
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,6 @@ void {{ cppClassName }}::Initialize(Handle<v8::Object> target) {

{%partial fields .%}

{%if cType%}
{%if not cTypeIsUndefined %}
Persistent<Function> {{ cppClassName }}::constructor_template;
{%endif%}