FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Starting to put the filters for templates back in · javascript-forks/nodegit.nodegit@70aefe5 · GitHub

Repository navigation

Commit 70aefe5

Browse files
John Haley
committed
Starting to put the filters for templates back in
1 parent 6b30987 commit 70aefe5

4 files changed

Lines changed: 9 additions & 23 deletions

File tree

‎generate/filters/is_pointer.js‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = function(cType) {
2+
return /\s*\*\s*/.test(cType);
3+
};

‎generate/index.js‎

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ var filters = {
3333
or: require("./filters/or"),
3434
and: require("./filters/and"),
3535
isV8Value: require("./filters/is_v8_value"),
36+
isPointer: require("./filters/is_pointer"),
3637
unPointer: require("./filters/un_pointer"),
3738
defaultValue: require("./filters/default_value")
3839
};
@@ -57,7 +58,6 @@ Object.keys(partials).forEach(function(partial) {
5758
var enabled = idefs.filter(function(idef) {
5859
// Additionally provide a friendly name to the actual filename.
5960
idef.name = path.basename(idef.filename, ".h");
60-
idef.cTypeIsUndefined = typeof idef.cType == 'undefined';
6161

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

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

116115
// generate returns data
117-
fn.argsInfo.forEach(function(arg) {
116+
fn.args.forEach(function(arg) {
118117
if (!arg.isReturn) return;
119118

120119
var _return = {};
@@ -135,21 +134,6 @@ var enabled = idefs.filter(function(idef) {
135134
if (!fn.returns.length
136135
&& !fn.return.isErrorCode
137136
&& 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-
153137
fn.returns.push(fn.return);
154138
}
155139

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

176159
fn.fieldInfos.push(fieldInfo);
177160
});

‎generate/partials/convert_to_v8.cc‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ to = NanNew<String>({{= parsedName =}});
1010
{%if freeFunctionName %}
1111
{{ freeFunctionName }}({{= parsedName =}});
1212
{%endif%}
13-
{%elsif isV8Value %}
13+
{%elsif cppClassName|isV8Value %}
1414
{%if isCppClassIntType %}
1515
to = NanNew<{{ cppClassName }}>(({{ parsedClassName }}){{= parsedName =}});
1616
{%else%}
@@ -30,7 +30,7 @@ to = tmpArray;
3030
{%else%}
3131
{%if copy %}
3232
if ({{= parsedName =}} != NULL) {
33-
{{= parsedName =}} = ({{ cType|replace '**' '*' }} {%if not isPointer %}*{%endif%}){{ copy }}({{= parsedName =}});
33+
{{= parsedName =}} = ({{ cType|replace '**' '*' }} {%if not cType|isPointer %}*{%endif%}){{ copy }}({{= parsedName =}});
3434
}
3535
{%endif%}
3636
if ({{= parsedName =}} != NULL) {

‎generate/partials/fields.cc‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ NAN_METHOD({{ cppClassName }}::{{ field.cppFunctionName }}) {
55
NanScope();
66
Handle<Value> to;
77

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

1111
{%partial convertToV8 field %}
1212
NanReturnValue(to);

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL