| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 10c2132 commit e57b390
7 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -33,7 +33,6 @@ var filters = { | |||
| 33 | 33 | or: require("./filters/or"), | |
| 34 | 34 | and: require("./filters/and"), | |
| 35 | 35 | isV8Value: require("./filters/is_v8_value"), | |
| 36 | - isPointer: require("./filters/is_pointer"), | ||
| 37 | 36 | unPointer: require("./filters/un_pointer"), | |
| 38 | 37 | defaultValue: require("./filters/default_value") | |
| 39 | 38 | }; | |
@@ -58,7 +57,8 @@ Object.keys(partials).forEach(function(partial) { | |||
| 58 | 57 | var enabled = idefs.filter(function(idef) { | |
| 59 | 58 | // Additionally provide a friendly name to the actual filename. | |
| 60 | 59 | idef.name = path.basename(idef.filename, ".h"); | |
| 61 | - | ||
| 60 | + idef.cTypeIsUndefined = typeof idef.cType == 'undefined'; | ||
| 61 | + | ||
| 62 | 62 | // We need some custom data on each of the functions | |
| 63 | 63 | idef.functions.forEach(function(fn) { | |
| 64 | 64 | fn.cppClassName = idef.cppClassName; | |
@@ -102,6 +102,7 @@ var enabled = idefs.filter(function(idef) { | |||
| 102 | 102 | arg.cArg = cArg; | |
| 103 | 103 | arg.v8ValueClassName = cppToV8(arg.cppClassName); | |
| 104 | 104 | arg.isCppClassStringOrArray = ~["String", "Array"].indexOf(arg.cppClassName); | |
| 105 | + arg.isPointer = /\s*\*\s*/.test(arg.cType); | ||
| 105 | 106 | arg.isDoublePointer = /\s*\*\*\s*/.test(arg.cType); | |
| 106 | 107 | arg.isV8Value = ~v8Values.indexOf(arg.cppClassName); | |
| 107 | 108 | ||
@@ -113,7 +114,7 @@ var enabled = idefs.filter(function(idef) { | |||
| 113 | 114 | fn.returns = []; | |
| 114 | 115 | ||
| 115 | 116 | // generate returns data | |
| 116 | - fn.args.forEach(function(arg) { | ||
| 117 | + fn.argsInfo.forEach(function(arg) { | ||
| 117 | 118 | if (!arg.isReturn) return; | |
| 118 | 119 | ||
| 119 | 120 | var _return = {}; | |
@@ -134,6 +135,21 @@ var enabled = idefs.filter(function(idef) { | |||
| 134 | 135 | if (!fn.returns.length | |
| 135 | 136 | && !fn.return.isErrorCode | |
| 136 | 137 | && fn.return.cType != "void") { | |
| 138 | + var _return = {}; | ||
| 139 | + | ||
| 140 | + _return = fn.return; | ||
| 141 | + | ||
| 142 | + _return.v8ValueClassName = cppToV8(_return.cppClassName); | ||
| 143 | + _return.isCppClassStringOrArray = ~["String", "Array"].indexOf(_return.cppClassName); | ||
| 144 | + _return.isPointer = /\s*\*\s*/.test(_return.cType); | ||
| 145 | + _return.isDoublePointer = /\s*\*\*\s*/.test(_return.cType); | ||
| 146 | + _return.isV8Value = ~v8Values.indexOf(_return.cppClassName); | ||
| 147 | + _return.parsedName = 'result'; | ||
| 148 | + _return.jsOrCppClassName = _return.jsClassName || _return.cppClassName; | ||
| 149 | + _return.isCppClassIntType = ~["Uint32", "Int32"].indexOf(_return.cppClassName); | ||
| 150 | + _return.parsedClassName = (_return.cppClassName || '').toLowerCase() + "_t"; | ||
| 151 | + _return.jsNameOrName = _return.jsName | _return.name; | ||
| 152 | + | ||
| 137 | 153 | fn.returns.push(fn.return); | |
| 138 | 154 | } | |
| 139 | 155 | ||
@@ -155,6 +171,7 @@ var enabled = idefs.filter(function(idef) { | |||
| 155 | 171 | fieldInfo.parsedName = field.name || "result"; | |
| 156 | 172 | fieldInfo.isCppClassIntType = ~["Uin32", "Int32"].indexOf(field.cppClassName); | |
| 157 | 173 | fieldInfo.parsedClassName = (field.cppClassName || '').toLowerCase() + "_t"; | |
| 174 | + fieldInfo.isV8Value = ~v8Values.indexOf(field.cppClassName); | ||
| 158 | 175 | ||
| 159 | 176 | fn.fieldInfos.push(fieldInfo); | |
| 160 | 177 | }); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,7 +1,7 @@ | |||
| 1 | 1 | {%if not isPayload %} | |
| 2 | 2 | {{ cType }} from_{{ name }}; | |
| 3 | 3 | {%if isOptional %} | |
| 4 | - if (args{{[ jsArg }}]->Is{{ v8ValueClassName }}()) { | ||
| 4 | + if (args[{{ jsArg }}]->Is{{ v8ValueClassName }}()) { | ||
| 5 | 5 | {%endif%} | |
| 6 | 6 | {%if cppClassName == 'String' %} | |
| 7 | 7 | String::Utf8Value {{ name }}(args[{{ jsArg }}]->ToString()); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -10,7 +10,7 @@ to = NanNew<String>({{{ parsedName }}}); | |||
| 10 | 10 | {%if freeFunctionName %} | |
| 11 | 11 | {{ freeFunctionName }}({{{ parsedName }}}); | |
| 12 | 12 | {%endif%} | |
| 13 | - {%elsif cppClassName|isV8Value %} | ||
| 13 | + {%elsif isV8Value %} | ||
| 14 | 14 | {%if isCppClassIntType %} | |
| 15 | 15 | to = NanNew<{{ cppClassName }}>(({{ parsedClassName }}){{{ parsedName }}}); | |
| 16 | 16 | {%else%} | |
@@ -19,7 +19,9 @@ to = NanNew<{{ cppClassName }}>({{{ parsedName }}}); | |||
| 19 | 19 | {%elsif cppClassName == 'External' %} | |
| 20 | 20 | to = NanNew<External>((void *){{{ parsedName }}}); | |
| 21 | 21 | {%elsif cppClassName == 'Array' %} | |
| 22 | - {%-- // FIXME this is not general purpose enough. --%} | ||
| 22 | + {%-- | ||
| 23 | + // FIXME this is not general purpose enough. | ||
| 24 | + --%} | ||
| 23 | 25 | Local<Array> tmpArray = NanNew<Array>({{{ parsedName }}}->{{ size }}); | |
| 24 | 26 | for (unsigned int i = 0; i < {{{ parsedName }}}->{{ size }}; i++) { | |
| 25 | 27 | tmpArray->Set(NanNew<Number>(i), NanNew<String>({{{ parsedName }}}->{{ key }}[i])); | |
@@ -28,7 +30,7 @@ to = tmpArray; | |||
| 28 | 30 | {%else%} | |
| 29 | 31 | {%if copy %} | |
| 30 | 32 | if ({{{ parsedName }}} != NULL) { | |
| 31 | - {{{ parsedName }}} = ({{ cType|replace '**' '*' }} {%if cType|isPointer %}*{%endif%}){{ copy }}({{{ parsedName }}}); | ||
| 33 | + {{{ parsedName }}} = ({{ cType|replace '**' '*' }} {%if isPointer %}*{%endif%}){{ copy }}({{{ parsedName }}}); | ||
| 32 | 34 | } | |
| 33 | 35 | {%endif%} | |
| 34 | 36 | if ({{{ parsedName }}} != NULL) { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -5,8 +5,8 @@ NAN_METHOD({{ cppClassName }}::{{ field.cppFunctionName }}) { | |||
| 5 | 5 | NanScope(); | |
| 6 | 6 | Handle<Value> to; | |
| 7 | 7 | ||
| 8 | - {{ field.cType }} {%if field.cppClassName|isV8Value %}*{%endif%}{{ field.name }} = | ||
| 9 | - {%if not field.cppClassName|isV8Value %}&{%endif%}ObjectWrap::Unwrap<{{ cppClassName }}>(args.This())->GetValue()->{{ field.name }}; | ||
| 8 | + {{ field.cType }} {%if field.isV8Value %}*{%endif%}{{ field.name }} = | ||
| 9 | + {%if not field.isV8Value %}&{%endif%}ObjectWrap::Unwrap<{{ cppClassName }}>(args.This())->GetValue()->{{ field.name }}; | ||
| 10 | 10 | ||
| 11 | 11 | {%partial convertToV8 field %} | |
| 12 | 12 | NanReturnValue(to); | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -81,5 +81,6 @@ from_{{ arg.name }} | |||
| 81 | 81 | NanReturnValue(to); | |
| 82 | 82 | {%else%} | |
| 83 | 83 | NanReturnValue(toReturn); | |
| 84 | + {%endif%} | ||
| 84 | 85 | {%endif%} | |
| 85 | 86 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -103,6 +103,6 @@ void {{ cppClassName }}::Initialize(Handle<v8::Object> target) { | |||
| 103 | 103 | ||
| 104 | 104 | {%partial fields .%} | |
| 105 | 105 | ||
| 106 | - {%if cType%} | ||
| 106 | + {%if not cTypeIsUndefined %} | ||
| 107 | 107 | Persistent<Function> {{ cppClassName }}::constructor_template; | |
| 108 | 108 | {%endif%} | |
| Back | FazBrowse Home | New Git URL |
0 commit comments