Skip to content
Prev Previous commit
Next Next commit
Add ClearValue method to structs and classes
  • Loading branch information
John Haley committed Feb 26, 2015
commit 7eb2108c06f7d4bfefccbbacd7dfd82b168a36ea
3 changes: 1 addition & 2 deletions generate/templates/partials/sync_function.cc
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ from_{{ arg.name }}
{%endif%}

{% if cppFunctionName == "Free" %}
// FIXME Stuck here unable to NULL out this->repo
// ObjectWrap::Unwrap<{{ cppClassName }}>(args.This())->SetValue(NULL);
ObjectWrap::Unwrap<{{ cppClassName }}>(args.This())->ClearValue();
}
{% endif %}

Expand Down
6 changes: 5 additions & 1 deletion generate/templates/templates/class_content.cc
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,11 @@ using namespace node;
}

{{ cType }} **{{ cppClassName }}::GetRefValue() {
return &this->raw;
return this->raw == NULL ? NULL : &this->raw;
}

void {{ cppClassName }}::ClearValue() {
this->raw = NULL;
}

{% else %}
Expand Down
1 change: 1 addition & 0 deletions generate/templates/templates/class_header.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ class {{ cppClassName }} : public ObjectWrap {
{%if cType%}
{{ cType }} *GetValue();
{{ cType }} **GetRefValue();
void ClearValue();

static Handle<v8::Value> New(void *raw, bool selfFreeing);
{%endif%}
Expand Down
6 changes: 5 additions & 1 deletion generate/templates/templates/struct_content.cc
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,11 @@ Handle<v8::Value> {{ cppClassName }}::New(void* raw, bool selfFreeing) {
}

{{ cType }} **{{ cppClassName }}::GetRefValue() {
return &this->raw;
return this->raw == NULL ? NULL : &this->raw;
}

void {{ cppClassName }}::ClearValue() {
this->raw = NULL;
}

{% partial fieldAccessors . %}
Expand Down
1 change: 1 addition & 0 deletions generate/templates/templates/struct_header.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class {{ cppClassName }} : public ObjectWrap {

{{ cType }} *GetValue();
{{ cType }} **GetRefValue();
void ClearValue();

static Handle<v8::Value> New(void *raw, bool selfFreeing);

Expand Down