Several fixes in v8 emitter and code templates.

Achieves first compile of example "class" after re-integration.

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/oliverb-javascript-v8@13793 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Oliver Buchtala 2012-09-08 01:06:58 +00:00
commit cda09239ad
4 changed files with 112 additions and 75 deletions

View file

@ -24,10 +24,12 @@ void SWIGV8_AddMemberFunction(v8::Handle<v8::FunctionTemplate> class_templ, cons
/**
* Registers a class method with given name for a given class template.
*/
void SWIGV8_AddGlobalFunction(v8::Handle<v8::ObjectTemplate> obj_templ, const char* symbol, v8::InvocationCallback _func) {
obj_templ->Set(v8::String::NewSymbol(symbol), v8::FunctionTemplate::New(_func)->GetFunction());
void SWIGV8_AddGlobalFunction(v8::Handle<v8::FunctionTemplate> class_templ, const char* symbol, v8::InvocationCallback _func) {
v8::Handle<v8::ObjectTemplate> obj_templ = class_templ->InstanceTemplate();
obj_templ->Set(v8::String::NewSymbol(symbol), v8::FunctionTemplate::New(_func)->GetFunction());
}
/**
* Registers a class property with given name for a given class template.
*/
@ -39,7 +41,8 @@ void SWIGV8_AddMemberVariable(v8::Handle<v8::FunctionTemplate> class_templ, cons
/**
* Registers a class method with given name for a given class template.
*/
void SWIGV8_AddGlobalVariable(v8::Handle<v8::ObjectTemplate> obj_templ, const char* symbol, v8::AccessorGetter getter, v8::AccessorSetter setter) {
obj_templ->SetAccessor(v8::String::NewSymbol(symbol), getter, setter);
void SWIGV8_AddGlobalVariable(v8::Handle<v8::FunctionTemplate> class_templ, const char* symbol, v8::AccessorGetter getter, v8::AccessorSetter setter) {
v8::Handle<v8::ObjectTemplate> obj_templ = class_templ->InstanceTemplate();
obj_templ->SetAccessor(v8::String::NewSymbol(symbol), getter, setter);
}
%} // v8_helper_functions