I'm tired of writing C++ code to surface JS classes and functions
implemented in C++.
We need a way to code a struct with a manifest of JS classes, functions,
etc.
Today we write, for every single class:
void MyClass::Init(Handle<Object> target) {
HandleScope scope;
Local<FunctionTemplate> t = FunctionTemplate::New(New);
constructor_template = Persistent<FunctionTemplate>::New(t);
constructor_template->InstanceTemplate()->SetInternalFieldCount(1);
constructor_template->SetClassName(String::NewSymbol("MyClass"));
Handle<Object> aO = constructor_template->GetFunction();
NODE_SET_PROTOTYPE_METHOD(constructor_template, "myMethod", MyMethod);
aO->Set(String::NewSymbol("member"), Integer::New(1), ReadOnly);
target->Set(String::NewSymbol("MyClass"), aO);
}
I'd like to write a JS manifest for the entire module, in one place:
void manifest() {
HandleScope scope;
JSClass::Method aMt[] = { { "myMethod", MyClass::MyMethod } }; // arrays
of structs
JSClass::Member aMm[] = { { "member", Integer::New(1), true } };
JSClass aC = { "MyClass", MyClass::New, aMt, aMm };
// etc
JSClass* all[] = { &aC, &bC, &dC };
RegisterManifest(all);
}
NODE_MODULE(mymodule, manifest)
--
--
Job Board: http://jobs.nodejs.org/
Posting guidelines:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en
---
You received this message because you are subscribed to the Google Groups
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.