Example #1
0
v8::Handle<v8::ObjectTemplate>
JSVec3d::GetObjectTemplate()
{
    v8::HandleScope handle_scope;

    static v8::Persistent<v8::ObjectTemplate> template_instance;

    if (template_instance.IsEmpty())
    {
        template_instance = v8::Persistent<v8::ObjectTemplate>::New(v8::ObjectTemplate::New());
        template_instance->Set(v8::String::New(V8_OBJECT_TYPE_PROPERTY), v8::String::New(GetObjectType().c_str()));
        template_instance->SetInternalFieldCount(1);
        template_instance->SetNamedPropertyHandler(PropertyCallback);
        template_instance->SetIndexedPropertyHandler(IndexedPropertyCallback);
    }

    return template_instance;
}