File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 13721372 "git_remote_rename" : {
13731373 "ignore" : true
13741374 },
1375+ "git_remote_set_callbacks" : {
1376+ "args" : {
1377+ "callbacks" : {
1378+ "saveArg" : true
1379+ }
1380+ }
1381+ },
13751382 "git_remote_set_fetch_refspecs" : {
13761383 "ignore" : true
13771384 },
Original file line number Diff line number Diff line change @@ -18,6 +18,18 @@ NAN_METHOD({{ cppClassName }}::{{ cppFunctionName }}) {
1818 {%if not arg.isCallbackFunction %}
1919 {%if not arg.payloadFor %}
2020 {%partial convertFromV8 arg %}
21+ {%if arg.saveArg %}
22+ Persistent<Object> {{ arg.name }};
23+ Handle<Object> {{ arg.name }}Handle (args[{{ arg.jsArg }}]->ToObject ());
24+ NanAssignPersistent ({{ arg.name }}, {{ arg.name }}Handle);
25+ {{ cppClassName }} *thisObj = ObjectWrap::Unwrap<{{ cppClassName }}>(args.This ());
26+
27+ if (thisObj->{{ cppFunctionName }}_{{ arg.name }} != NULL ) {
28+ NanDisposePersistent (*thisObj->{{ cppFunctionName }}_{{ arg.name }});
29+ }
30+
31+ thisObj->{{ cppFunctionName }}_{{ arg.name }} = &{{ arg.name }};
32+ {%endif%}
2133 {%endif%}
2234 {%endif%}
2335 {%endif%}
Original file line number Diff line number Diff line change @@ -29,6 +29,16 @@ using namespace node;
2929 {{ cppClassName }}::{{ cppClassName }}({{ cType }} *raw, bool selfFreeing) {
3030 this ->raw = raw;
3131 this ->selfFreeing = selfFreeing;
32+
33+ {% each functions as function %}
34+ {% if not function.ignore %}
35+ {% each function.args as arg %}
36+ {% if arg.saveArg %}
37+ {{ function.cppFunctionName }}_{{ arg.name }} = NULL ;
38+ {% endif %}
39+ {% endeach %}
40+ {% endif %}
41+ {% endeach %}
3242 }
3343
3444 {{ cppClassName }}::~{{ cppClassName }}() {
@@ -37,6 +47,21 @@ using namespace node;
3747 {{ freeFunctionName }}(this ->raw );
3848 }
3949 {% endif %}
50+
51+ // this will cause an error if you have a non-self-freeing object that also needs
52+ // to save values. Since the object that will eventually free the object has no
53+ // way of knowing to free these values.
54+ {% each function as function %}
55+ {% if not function.ignore %}
56+ {% each function.args as arg %}
57+ {% if arg.saveArg %}
58+ if ({{ function.cppFunctionName }}_{{ arg.name }} != NULL ) {
59+ NanDisposePersistent (&{{ function.cppFunctionName }}_{{ arg.name }});
60+ }
61+ {% endif %}
62+ {% endeach %}
63+ {% endif %}
64+ {% endeach %}
4065 }
4166
4267 void {{ cppClassName }}::InitializeComponent(Handle<v8::Object> target) {
Original file line number Diff line number Diff line change @@ -73,12 +73,26 @@ class {{ cppClassName }} : public ObjectWrap {
7373 {% endeach %}
7474 {% endif %}
7575 {% endeach %}
76+
77+
7678 private:
79+
80+
7781 {%if cType%}
7882 {{ cppClassName }}({{ cType }} *raw, bool selfFreeing);
7983 ~{{ cppClassName }}();
8084 {%endif%}
8185
86+ {% each functions as function %}
87+ {% if not function.ignore %}
88+ {% each function.args as arg %}
89+ {% if arg.saveArg %}
90+ Persistent<Object> *{{ function.cppFunctionName }}_{{ arg.name }};
91+ {% endif %}
92+ {% endeach %}
93+ {% endif %}
94+ {% endeach %}
95+
8296 static NAN_METHOD (JSNewFunction);
8397
8498 {%each fields as field%}
You can’t perform that action at this time.
0 commit comments