Minor improvements in v8 emitter implementation

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/oliverb-javascript-v8@13746 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Oliver Buchtala 2012-09-08 00:48:11 +00:00
commit 6c90d1eb6d
3 changed files with 64 additions and 33 deletions

View file

@ -27,10 +27,14 @@ v8::Persistent<v8::FunctionTemplate> SWIGV8_CreateClassTemplate(const char* symb
return v8::Persistent<v8::FunctionTemplate>::New(class_templ);
}
v8::Handle<v8::ObjectTemplate> SWIGV8_CreateNamespace(const char* name, v8::Handle<v8::Context> parentContext) {
Handle<ObjectTemplate> namespace = ObjectTemplate::New();
}
/**
* Sets the pimpl data of a V8 class.
*/
v8::Handle<v8::Value> V8GeneratorUtils::SetInstance(const v8::Arguments& args, void* data) {
v8::Handle<v8::Value> SWIGV8_SetInstance(const v8::Arguments& args, void* data) {
v8::HandleScope scope;
v8::Handle<v8::Object> self = args.Holder();
@ -42,15 +46,22 @@ v8::Handle<v8::Value> V8GeneratorUtils::SetInstance(const v8::Arguments& args, v
/**
* Registers a class method with given name for a given class template.
*/
void V8GeneratorUtils::AddClassMethod(v8::Handle<v8::FunctionTemplate> class_templ, const char* symbol, v8::InvocationCallback _func) {
void SWIGV8_AddClassMethod(v8::Handle<v8::FunctionTemplate> class_templ, const char* symbol, v8::InvocationCallback _func) {
v8::Handle<v8::ObjectTemplate> proto_templ = class_templ->PrototypeTemplate();
proto_templ->Set(v8::String::NewSymbol(symbol), v8::FunctionTemplate::New(_func));
}
/**
* Registers a class method with given name for a given class template.
*/
void SWIGV8_AddGlobalMethod(v8::Handle<v8::ObjectTemplate> obj_templ, const char* symbol, v8::InvocationCallback _func) {
obj_templ->Set(String::New(symbol), FunctionTemplate::New(_func));
}
/**
* Registers a class property with given name for a given class template.
*/
void V8GeneratorUtils::AddProperty(v8::Handle<v8::FunctionTemplate> class_templ, const char* varname, v8::AccessorGetter getter, v8::AccessorSetter setter) {
void SWIGV8_AddProperty(v8::Handle<v8::FunctionTemplate> class_templ, const char* varname, v8::AccessorGetter getter, v8::AccessorSetter setter) {
v8::Handle<v8::ObjectTemplate> proto_templ = class_templ->InstanceTemplate();
proto_templ->SetAccessor(v8::String::New(varname), getter, setter);
}