title: V8 object wrapper is not adding properties correctly
body: <p>I have a C++ class called <code>TransformComponent</code> and it has three properties of type <code>glm::vec3*</code>. I am trying to expose and instance of this class to my JS code, but I'm having difficulty wrapping it.</p>
  
  <p>This is my wrapper code:</p>
  
  <pre><code>v8::Local&lt;v8::Object&gt; TransformComponent::WrapObject(TransformComponent* object)
  {
      v8::Isolate* isolate = v8::Isolate::GetCurrent();
      v8::Isolate::Scope isolate_scope(isolate);
      v8::HandleScope handle_scope(isolate);
  
      v8::Local&lt;v8::Context&gt; context = isolate-&gt;GetCurrentContext();
      v8::Context::Scope context_scope(context);
  
      v8::Local&lt;v8::ObjectTemplate&gt; class_template = v8::ObjectTemplate::New(isolate);
      class_template-&gt;SetInternalFieldCount(1);
      // class_template-&gt;SetAccessor(v8::String::NewFromUtf8(isolate, "position"), V8_GetPosition);
      // class_template-&gt;SetAccessor(v8::String::NewFromUtf8(isolate, "rotation"), V8_GetRotation);
      class_template-&gt;SetAccessor(v8::String::NewFromUtf8(isolate, "scale"), V8_GetScale);
  
      v8::Local&lt;v8::Object&gt; obj = class_template-&gt;NewInstance(context).ToLocalChecked();
      obj-&gt;SetInternalField(0, v8::External::New(isolate, object));
  
      return obj;
  }
  </code></pre>
  
  <p>This is my getter method:</p>
  
  <pre><code>void TransformComponent::V8_GetScale(v8::Local&lt;v8::Name&gt; property, const v8::PropertyCallbackInfo&lt;v8::Value&gt;&amp; info)
  {
      printf("S: Getter called!\n");
      TransformComponent* component = V8Helper::UnwrapObject&lt;TransformComponent&gt;(info);
      info.GetReturnValue().Set(Vec3Wrapper::WrapObject(component-&gt;scale));
  }
  </code></pre>
  
  <p>And finally this is how I inject the wrapped object in the global js object:</p>
  
  <pre><code>v8::Local&lt;v8::Object&gt; transform_obj = TransformComponent::WrapObject(actor-&gt;GetComponent&lt;TransformComponent&gt;());
  global-&gt;Set(V8_STR("transform"), transform_obj);
  </code></pre>
  
  <p>With this code, a global object called <code>transform</code> becomes available in the JS code, but for some reason, its properties are undefined (<code>console.log(transform.scale); prints 'undefined'</code>) even though I am calling <code>SetAccessor</code> and passing the correct functions. The getter function isn't even being called, because the printf doesn't print anything to the console.</p>
  
  <p>Am I missing something here? I have tried wrapping nested objects in a separate project (where I usually test V8 stuff before implementing them in the main project), and it works there. <a href="https://pastebin.com/R44qJgUi" rel="nofollow noreferrer">Here</a> you can look at the working test program where I wrap a <code>Line</code> object with a <code>Point*</code> property.</p>