Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
add custom macro for dealing with returning while escaping a scope in…
… js methods
  • Loading branch information
maxkorp committed Oct 23, 2014
commit 86a41a09f0514509cb647282a982c54a29b6dd9e
12 changes: 12 additions & 0 deletions generate/manual/include/macros.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#ifndef NODEGIT_PSUEDONAN_H_
#if (NODE_MODULE_VERSION > 0x000B)
// Node 0.11+ (0.11.3 and below won't compile with these)
# define NodeGitPsueodoNanReturnEscapingValue(val) NanReturnValue(NanEscapeScope(val))

#else
// Node 0.8 and 0.10
# define NodeGitPsueodoNanReturnEscapingValue(val) NanReturnValue(val)

#endif

#endif //NODEGIT_PSUEDONAN_H_
5 changes: 3 additions & 2 deletions generate/partials/sync_function.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

{%partial doc .%}
NAN_METHOD({{ cppClassName }}::{{ cppFunctionName }}) {
NanEscapableScope();
{%partial guardArguments .%}

{%each .|returnsInfo 'true' as _return %}
Expand Down Expand Up @@ -65,9 +66,9 @@ from_{{ arg.name }}
{%endif%}
{%endeach%}
{%if .|returnsCount == 1 %}
NanReturnValue(to);
NodeGitPsueodoNanReturnEscapingValue(to);
{%else%}
NanReturnValue(toReturn);
NodeGitPsueodoNanReturnEscapingValue(toReturn);
{%endif%}
{%endif%}
}
1 change: 1 addition & 0 deletions generate/templates/class_content.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ extern "C" {
}

#include "../include/functions/copy.h"
#include "../include/macros.h"
#include "../include/{{ filename }}"

{%each dependencies as dependency%}
Expand Down