Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions 7 generate/input/descriptor.json
Original file line number Diff line number Diff line change
Expand Up @@ -1348,6 +1348,13 @@
"git_remote_rename": {
"ignore": true
},
"git_remote_set_callbacks": {
"args": {
"callbacks": {
"saveArg": true
}
}
},
"git_remote_set_fetch_refspecs": {
"ignore": true
},
Expand Down
12 changes: 12 additions & 0 deletions 12 generate/templates/partials/sync_function.cc
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,18 @@ NAN_METHOD({{ cppClassName }}::{{ cppFunctionName }}) {
{%if not arg.isCallbackFunction %}
{%if not arg.payloadFor %}
{%partial convertFromV8 arg %}
{%if arg.saveArg %}
Persistent<Object> {{ arg.name }};
Handle<Object> {{ arg.name }}Handle(args[{{ arg.jsArg }}]->ToObject());
NanAssignPersistent({{ arg.name }}, {{ arg.name }}Handle);
{{ cppClassName }} *thisObj = ObjectWrap::Unwrap<{{ cppClassName }}>(args.This());

if (thisObj->{{ cppFunctionName }}_{{ arg.name }} != NULL) {
NanDisposePersistent(*thisObj->{{ cppFunctionName }}_{{ arg.name }});
}

thisObj->{{ cppFunctionName }}_{{ arg.name }} = &{{ arg.name }};
{%endif%}
{%endif%}
{%endif%}
{%endif%}
Expand Down
25 changes: 25 additions & 0 deletions 25 generate/templates/templates/class_content.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,16 @@ using namespace node;
{{ cppClassName }}::{{ cppClassName }}({{ cType }} *raw, bool selfFreeing) {
this->raw = raw;
this->selfFreeing = selfFreeing;

{% each functions as function %}
{% if not function.ignore %}
{% each function.args as arg %}
{% if arg.saveArg %}
{{ function.cppFunctionName }}_{{ arg.name }} = NULL;
{% endif %}
{% endeach %}
{% endif %}
{% endeach %}
}

{{ cppClassName }}::~{{ cppClassName }}() {
Expand All @@ -37,6 +47,21 @@ using namespace node;
{{ freeFunctionName }}(this->raw);
}
{% endif %}

// this will cause an error if you have a non-self-freeing object that also needs
// to save values. Since the object that will eventually free the object has no
// way of knowing to free these values.
{% each function as function %}
{% if not function.ignore %}
{% each function.args as arg %}
{% if arg.saveArg %}
if ({{ function.cppFunctionName }}_{{ arg.name }} != NULL) {
NanDisposePersistent(&{{ function.cppFunctionName }}_{{ arg.name }});
}
{% endif %}
{% endeach %}
{% endif %}
{% endeach %}
}

void {{ cppClassName }}::InitializeComponent(Handle<v8::Object> target) {
Expand Down
14 changes: 14 additions & 0 deletions 14 generate/templates/templates/class_header.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,26 @@ class {{ cppClassName }} : public ObjectWrap {
{% endeach %}
{% endif %}
{% endeach %}


private:


{%if cType%}
{{ cppClassName }}({{ cType }} *raw, bool selfFreeing);
~{{ cppClassName }}();
{%endif%}

{% each functions as function %}
{% if not function.ignore %}
{% each function.args as arg %}
{% if arg.saveArg %}
Persistent<Object> *{{ function.cppFunctionName }}_{{ arg.name }};
{% endif %}
{% endeach %}
{% endif %}
{% endeach %}

static NAN_METHOD(JSNewFunction);

{%each fields as field%}
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.