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

Allow for saving of props to an object by johnhaley81 · Pull Request #421 · nodegit/nodegit · GitHub

Repository navigation

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

Filter by extension

Filter by extension .cc  (2) .h  (1) .json  (1) All 3 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
7 changes: 7 additions & 0 deletions generate/input/descriptor.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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 generate/templates/partials/sync_function.cc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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 generate/templates/templates/class_content.cc
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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 generate/templates/templates/class_header.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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

Back | FazBrowse Home | New Git URL