Skip to content

Commit 22804cb

Browse files
author
John Haley
committed
Payloads no longer need to be named payload
1 parent 2fa3150 commit 22804cb

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

generate/scripts/generateNativeCode.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ module.exports = function generateNativeCode() {
6060
isDoublePointer: require("../templates/filters/is_double_pointer"),
6161
isFixedLengthString: require("../templates/filters/is_fixed_length_string"),
6262
isOid: require("../templates/filters/is_oid"),
63+
isPayload: require("../templates/filters/is_payload"),
6364
isPointer: require("../templates/filters/is_pointer"),
6465
isV8Value: require("../templates/filters/is_v8_value"),
6566
jsArgsCount: require("../templates/filters/js_args_count"),
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = function(field) {
2+
return field.name == 'payload' || field.payload;
3+
};

generate/templates/partials/callback_helpers.cc

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,15 @@ void {{ cppClassName }}::{{ cppFunctionName }}_{{ cbFunction.name }}_asyncAfter(
4040

4141
{{ cppFunctionName }}_{{ cbFunction.name|titleCase }}Baton* baton = static_cast<{{ cppFunctionName }}_{{ cbFunction.name|titleCase }}Baton*>(req->data);
4242

43-
NanCallback* callback = (NanCallback *)baton->payload;
43+
{% each cbFunction.args|argsInfo as arg %}
44+
{% if arg | isPayload %}
45+
NanCallback* callback = (NanCallback *)baton->{{ arg.name }};
46+
{% endif %}
47+
{% endeach %}
4448

4549
Local<Value> argv[{{ cbFunction.args|jsArgsCount }}] = {
4650
{% each cbFunction.args|argsInfo as arg %}
47-
{% if arg.name == "payload" %}
51+
{% if arg | isPayload %}
4852
{%-- payload is always the last arg --%}
4953
// payload is null because we can use closure scope in javascript
5054
NanUndefined()

0 commit comments

Comments
 (0)