Skip to content

Commit 2aff3c0

Browse files
author
John Haley
committed
Fix callbacks with just return value
1 parent 663f693 commit 2aff3c0

File tree

5 files changed

+26
-8
lines changed

5 files changed

+26
-8
lines changed

generate/input/callbacks.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,7 @@
455455
],
456456
"return": {
457457
"type": "int",
458-
"noResults": 1,
458+
"noResults": 0,
459459
"success": 0,
460460
"error": -1
461461
}

generate/templates/filters/returns_info.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ module.exports = function(fn, argReturnsOnly, isAsync) {
1414
return_info.parsedClassName = (return_info.cppClassName || '').toLowerCase() + "_t";
1515
return_info.returnNameOrName = return_info.returnName || return_info.name;
1616
return_info.jsOrCppClassName = return_info.jsClassName || return_info.cppClassName;
17+
return_info.isOutParam = true;
1718

1819
result.push(return_info);
1920
});
2021

2122
if (!result.length
22-
&& !fn.isCallbackFunction
2323
&& !argReturnsOnly
2424
&& fn.return
2525
&& !fn.return.isErrorCode

generate/templates/partials/callback_helpers.cc

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,16 +86,25 @@ void {{ cppClassName }}::{{ cppFunctionName }}_{{ cbFunction.name }}_asyncAfter(
8686

8787
{{ cbFunction.return.type }} resultStatus;
8888

89-
{% each cbFunction|returnsInfo true false as _return %}
89+
{% each cbFunction|returnsInfo false true as _return %}
9090
if (result.IsEmpty() || result->IsNativeError()) {
9191
baton->result = {{ cbFunction.return.error }};
9292
}
9393
else if (!result->IsNull() && !result->IsUndefined()) {
94+
{% if _return.isOutParam %}
9495
{{ _return.cppClassName }}* wrapper = ObjectWrap::Unwrap<{{ _return.cppClassName }}>(result->ToObject());
9596
wrapper->selfFreeing = false;
9697

9798
baton->{{ _return.name }} = wrapper->GetRefValue();
9899
baton->result = {{ cbFunction.return.success }};
100+
{% else %}
101+
if (result->IsNumber()) {
102+
baton->result = (int) result->ToNumber()->Value();
103+
}
104+
else {
105+
baton->result = {{ cbFunction.return.noResults }};
106+
}
107+
{% endif %}
99108
}
100109
else {
101110
baton->result = {{ cbFunction.return.noResults }};
@@ -126,16 +135,25 @@ void {{ cppClassName }}::{{ cppFunctionName }}_{{ cbFunction.name }}_asyncPromis
126135
Handle<v8::Value> result = resultFn->Call(0, argv);
127136
{{ cbFunction.return.type }} resultStatus;
128137

129-
{% each cbFunction|returnsInfo true false as _return %}
138+
{% each cbFunction|returnsInfo false true as _return %}
130139
if (result.IsEmpty() || result->IsNativeError()) {
131140
baton->result = {{ cbFunction.return.error }};
132141
}
133142
else if (!result->IsNull() && !result->IsUndefined()) {
143+
{% if _return.isOutParam %}
134144
{{ _return.cppClassName }}* wrapper = ObjectWrap::Unwrap<{{ _return.cppClassName }}>(result->ToObject());
135145
wrapper->selfFreeing = false;
136146

137147
baton->{{ _return.name }} = wrapper->GetRefValue();
138148
baton->result = {{ cbFunction.return.success }};
149+
{% else %}
150+
if (result->IsNumber()) {
151+
baton->result = (int) result->ToNumber()->Value();
152+
}
153+
else {
154+
baton->result = {{ cbFunction.return.noResults }};
155+
}
156+
{% endif %}
139157
}
140158
else {
141159
baton->result = {{ cbFunction.return.noResults }};

lib/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,17 @@ Index.prototype.entries = function() {
1919

2020
var addAll = Index.prototype.addAll;
2121
Index.prototype.addAll = function(pathspec, flags, matchedCallback) {
22-
return addAll.call(this, pathspec, flags, matchedCallback, null);
22+
return addAll.call(this, pathspec || "*", flags, matchedCallback, null);
2323
};
2424

2525
var removeAll = Index.prototype.removeAll;
2626
Index.prototype.removeAll = function(pathspec, matchedCallback) {
27-
return removeAll.call(this, pathspec, matchedCallback, null);
27+
return removeAll.call(this, pathspec || "*", matchedCallback, null);
2828
};
2929

3030
var updateAll = Index.prototype.updateAll;
3131
Index.prototype.updateAll = function(pathspec, matchedCallback) {
32-
return updateAll.call(this, pathspec, matchedCallback, null);
32+
return updateAll.call(this, pathspec || "*", matchedCallback, null);
3333
};
3434

3535
module.exports = Index;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
"which-native-nodish": "^1.0.3"
6363
},
6464
"devDependencies": {
65-
"combyne": "^0.6.4",
65+
"combyne": "^0.6.5",
6666
"istanbul": "^0.3.5",
6767
"js-beautify": "^1.5.4",
6868
"jshint": "^2.6.0",

0 commit comments

Comments
 (0)