ported to newer, more efficient v8 api
This commit is contained in:
parent
c291675cce
commit
cb5f4dc47e
2 changed files with 38 additions and 39 deletions
|
|
@ -7,19 +7,18 @@
|
||||||
* - $jsmangledtype: mangled type of class
|
* - $jsmangledtype: mangled type of class
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
%fragment("js_ctor", "templates") %{
|
%fragment("js_ctor", "templates") %{
|
||||||
v8::Handle<v8::Value> $jswrapper(const v8::Arguments& args) {
|
void $jswrapper(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||||
v8::HandleScope scope;
|
v8::HandleScope scope;
|
||||||
v8::Handle<v8::Object> self = args.Holder();
|
v8::Handle<v8::Object> self = args.Holder();
|
||||||
$jslocals
|
$jslocals
|
||||||
if(args.Length() != $jsargcount) SWIG_exception_fail(SWIG_ERROR, "Illegal number of arguments for $jswrapper.");
|
if(args.Length() != $jsargcount) SWIG_exception_fail(SWIG_ERROR, "Illegal number of arguments for $jswrapper.");
|
||||||
$jscode
|
$jscode
|
||||||
|
|
||||||
SWIGV8_SetPrivateData(self, result, SWIGTYPE_$jsmangledtype, SWIG_POINTER_OWN);
|
|
||||||
return scope.Close(self);
|
|
||||||
|
|
||||||
goto fail;
|
SWIGV8_SetPrivateData(self, result, SWIGTYPE_$jsmangledtype, SWIG_POINTER_OWN);
|
||||||
|
args.GetReturnValue().Set(self);
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
return scope.Close(v8::Undefined());
|
return;
|
||||||
}
|
}
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
|
@ -30,10 +29,9 @@ fail:
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
%fragment ("js_veto_ctor", "templates")
|
%fragment ("js_veto_ctor", "templates")
|
||||||
%{
|
%{
|
||||||
v8::Handle<v8::Value> $jswrapper(const v8::Arguments& args) {
|
void $jswrapper(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||||
v8::HandleScope scope;
|
v8::HandleScope scope;
|
||||||
SWIG_exception(SWIG_ERROR, "Class $jsname can not be instantiated");
|
SWIG_exception(SWIG_ERROR, "Class $jsname can not be instantiated");
|
||||||
return scope.Close(v8::Undefined());
|
|
||||||
}
|
}
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
|
@ -45,7 +43,7 @@ v8::Handle<v8::Value> $jswrapper(const v8::Arguments& args) {
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
%fragment ("js_ctor_dispatcher", "templates")
|
%fragment ("js_ctor_dispatcher", "templates")
|
||||||
%{
|
%{
|
||||||
v8::Handle<v8::Value> $jswrapper(const v8::Arguments& args) {
|
void $jswrapper(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||||
v8::HandleScope scope;
|
v8::HandleScope scope;
|
||||||
OverloadErrorHandler errorHandler;
|
OverloadErrorHandler errorHandler;
|
||||||
v8::Handle<v8::Value> self;
|
v8::Handle<v8::Value> self;
|
||||||
|
|
@ -57,7 +55,7 @@ v8::Handle<v8::Value> $jswrapper(const v8::Arguments& args) {
|
||||||
SWIG_exception_fail(SWIG_ERROR, "Illegal arguments for contruction of $jsmangledname");
|
SWIG_exception_fail(SWIG_ERROR, "Illegal arguments for contruction of $jsmangledname");
|
||||||
|
|
||||||
fail:
|
fail:
|
||||||
return scope.Close(v8::Undefined());
|
return;
|
||||||
}
|
}
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
|
@ -70,7 +68,7 @@ fail:
|
||||||
* - $jsmangledtype: mangled type of class
|
* - $jsmangledtype: mangled type of class
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
%fragment("js_overloaded_ctor", "templates") %{
|
%fragment("js_overloaded_ctor", "templates") %{
|
||||||
v8::Handle<v8::Value> $jswrapper(const v8::Arguments& args, V8ErrorHandler& SWIGV8_ErrorHandler) {
|
void $jswrapper(const v8::FunctionCallbackInfo<v8::Value>& args, V8ErrorHandler& SWIGV8_ErrorHandler) {
|
||||||
v8::HandleScope scope;
|
v8::HandleScope scope;
|
||||||
v8::Handle<v8::Object> self = args.Holder();
|
v8::Handle<v8::Object> self = args.Holder();
|
||||||
$jslocals
|
$jslocals
|
||||||
|
|
@ -78,11 +76,11 @@ v8::Handle<v8::Value> $jswrapper(const v8::Arguments& args, V8ErrorHandler& SWIG
|
||||||
$jscode
|
$jscode
|
||||||
|
|
||||||
SWIGV8_SetPrivateData(self, result, SWIGTYPE_$jsmangledtype, SWIG_POINTER_OWN);
|
SWIGV8_SetPrivateData(self, result, SWIGTYPE_$jsmangledtype, SWIG_POINTER_OWN);
|
||||||
return scope.Close(self);
|
args.GetReturnValue().Set(self);
|
||||||
|
|
||||||
goto fail;
|
goto fail;
|
||||||
fail:
|
fail:
|
||||||
return scope.Close(v8::Undefined());
|
return;
|
||||||
}
|
}
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
|
@ -97,10 +95,9 @@ fail:
|
||||||
%{
|
%{
|
||||||
if(args.Length() == $jsargcount) {
|
if(args.Length() == $jsargcount) {
|
||||||
errorHandler.err.Clear();
|
errorHandler.err.Clear();
|
||||||
self = $jswrapper(args, errorHandler);
|
$jswrapper(args, errorHandler);
|
||||||
if(errorHandler.err.IsEmpty()) {
|
if(errorHandler.err.IsEmpty())
|
||||||
return scope.Close(self);
|
return;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
|
@ -171,15 +168,16 @@ void $jswrapper(v8::Persistent< v8::Value > object, void *parameter) {
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
%fragment("js_getter", "templates")
|
%fragment("js_getter", "templates")
|
||||||
%{
|
%{
|
||||||
v8::Handle<v8::Value> $jswrapper(v8::Local<v8::String> property, const v8::AccessorInfo& info) {
|
void $jswrapper(v8::Local<v8::String> property, const v8::PropertyCallbackInfo<v8::Value>& info) {
|
||||||
v8::HandleScope scope;
|
v8::HandleScope scope;
|
||||||
v8::Handle<v8::Value> jsresult;
|
v8::Handle<v8::Value> jsresult;
|
||||||
$jslocals
|
$jslocals
|
||||||
$jscode
|
$jscode
|
||||||
return scope.Close(jsresult);
|
info.GetReturnValue().Set(jsresult);
|
||||||
|
return;
|
||||||
goto fail;
|
goto fail;
|
||||||
fail:
|
fail:
|
||||||
return scope.Close(v8::Undefined());
|
return;
|
||||||
}
|
}
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
|
@ -191,7 +189,7 @@ fail:
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
%fragment("js_setter", "templates")
|
%fragment("js_setter", "templates")
|
||||||
%{
|
%{
|
||||||
void $jswrapper(v8::Local<v8::String> property, v8::Local<v8::Value> value, const v8::AccessorInfo& info) {
|
void $jswrapper(v8::Local<v8::String> property, v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<void>& info) {
|
||||||
v8::HandleScope scope;
|
v8::HandleScope scope;
|
||||||
$jslocals
|
$jslocals
|
||||||
$jscode
|
$jscode
|
||||||
|
|
@ -209,17 +207,18 @@ fail:
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
%fragment("js_function", "templates")
|
%fragment("js_function", "templates")
|
||||||
%{
|
%{
|
||||||
v8::Handle<v8::Value> $jswrapper(const v8::Arguments &args) {
|
void $jswrapper(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||||
v8::HandleScope scope;
|
v8::HandleScope scope;
|
||||||
v8::Handle<v8::Value> jsresult;
|
v8::Handle<v8::Value> jsresult;
|
||||||
$jslocals
|
$jslocals
|
||||||
if(args.Length() != $jsargcount) SWIG_exception_fail(SWIG_ERROR, "Illegal number of arguments for $jswrapper.");
|
if(args.Length() != $jsargcount) SWIG_exception_fail(SWIG_ERROR, "Illegal number of arguments for $jswrapper.");
|
||||||
|
|
||||||
$jscode
|
$jscode
|
||||||
return scope.Close(jsresult);
|
args.GetReturnValue().Set(jsresult);
|
||||||
|
return;
|
||||||
goto fail;
|
goto fail;
|
||||||
fail:
|
fail:
|
||||||
return scope.Close(v8::Undefined());
|
return;
|
||||||
}
|
}
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
|
@ -232,7 +231,7 @@ fail:
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
%fragment("js_function_dispatcher", "templates")
|
%fragment("js_function_dispatcher", "templates")
|
||||||
%{
|
%{
|
||||||
v8::Handle<v8::Value> $jswrapper(const v8::Arguments &args) {
|
void $jswrapper(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||||
v8::HandleScope scope;
|
v8::HandleScope scope;
|
||||||
v8::Handle<v8::Value> jsresult;
|
v8::Handle<v8::Value> jsresult;
|
||||||
OverloadErrorHandler errorHandler;
|
OverloadErrorHandler errorHandler;
|
||||||
|
|
@ -242,7 +241,7 @@ v8::Handle<v8::Value> $jswrapper(const v8::Arguments &args) {
|
||||||
|
|
||||||
goto fail;
|
goto fail;
|
||||||
fail:
|
fail:
|
||||||
return scope.Close(v8::Undefined());
|
return;
|
||||||
}
|
}
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
|
@ -254,16 +253,17 @@ fail:
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
%fragment ("js_overloaded_function", "templates")
|
%fragment ("js_overloaded_function", "templates")
|
||||||
%{
|
%{
|
||||||
v8::Handle<v8::Value> $jswrapper(const v8::Arguments &args, V8ErrorHandler& SWIGV8_ErrorHandler)
|
void $jswrapper(const v8::FunctionCallbackInfo<v8::Value>& args, V8ErrorHandler& SWIGV8_ErrorHandler)
|
||||||
{
|
{
|
||||||
v8::HandleScope scope;
|
v8::HandleScope scope;
|
||||||
v8::Handle<v8::Value> jsresult;
|
v8::Handle<v8::Value> jsresult;
|
||||||
$jslocals
|
$jslocals
|
||||||
$jscode
|
$jscode
|
||||||
return scope.Close(jsresult);
|
args.GetReturnValue().Set(jsresult);
|
||||||
|
return;
|
||||||
goto fail;
|
goto fail;
|
||||||
fail:
|
fail:
|
||||||
return scope.Close(jsresult);
|
return;
|
||||||
}
|
}
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
|
@ -277,10 +277,9 @@ fail:
|
||||||
%{
|
%{
|
||||||
if(args.Length() == $jsargcount) {
|
if(args.Length() == $jsargcount) {
|
||||||
errorHandler.err.Clear();
|
errorHandler.err.Clear();
|
||||||
jsresult = $jswrapper(args, errorHandler);
|
$jswrapper(args, errorHandler);
|
||||||
if(errorHandler.err.IsEmpty()) {
|
if(errorHandler.err.IsEmpty())
|
||||||
return scope.Close(jsresult);
|
return;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ v8::Handle<v8::FunctionTemplate> SWIGV8_CreateClassTemplate(const char* symbol)
|
||||||
/**
|
/**
|
||||||
* Registers a class method with given name for a given class template.
|
* Registers a class method with given name for a given class template.
|
||||||
*/
|
*/
|
||||||
void SWIGV8_AddMemberFunction(v8::Handle<v8::FunctionTemplate> class_templ, const char* symbol, v8::InvocationCallback _func) {
|
void SWIGV8_AddMemberFunction(v8::Handle<v8::FunctionTemplate> class_templ, const char* symbol, v8::FunctionCallback _func) {
|
||||||
v8::Handle<v8::ObjectTemplate> proto_templ = class_templ->PrototypeTemplate();
|
v8::Handle<v8::ObjectTemplate> proto_templ = class_templ->PrototypeTemplate();
|
||||||
proto_templ->Set(v8::String::NewSymbol(symbol), v8::FunctionTemplate::New(_func));
|
proto_templ->Set(v8::String::NewSymbol(symbol), v8::FunctionTemplate::New(_func));
|
||||||
}
|
}
|
||||||
|
|
@ -25,7 +25,7 @@ void SWIGV8_AddMemberFunction(v8::Handle<v8::FunctionTemplate> class_templ, cons
|
||||||
/**
|
/**
|
||||||
* Registers a class property with given name for a given class template.
|
* Registers a class property with given name for a given class template.
|
||||||
*/
|
*/
|
||||||
void SWIGV8_AddMemberVariable(v8::Handle<v8::FunctionTemplate> class_templ, const char* symbol, v8::AccessorGetter getter, v8::AccessorSetter setter) {
|
void SWIGV8_AddMemberVariable(v8::Handle<v8::FunctionTemplate> class_templ, const char* symbol, v8::AccessorGetterCallback getter, v8::AccessorSetterCallback setter) {
|
||||||
v8::Handle<v8::ObjectTemplate> proto_templ = class_templ->InstanceTemplate();
|
v8::Handle<v8::ObjectTemplate> proto_templ = class_templ->InstanceTemplate();
|
||||||
proto_templ->SetAccessor(v8::String::NewSymbol(symbol), getter, setter);
|
proto_templ->SetAccessor(v8::String::NewSymbol(symbol), getter, setter);
|
||||||
}
|
}
|
||||||
|
|
@ -33,18 +33,18 @@ void SWIGV8_AddMemberVariable(v8::Handle<v8::FunctionTemplate> class_templ, cons
|
||||||
/**
|
/**
|
||||||
* Registers a class method with given name for a given object.
|
* Registers a class method with given name for a given object.
|
||||||
*/
|
*/
|
||||||
void SWIGV8_AddStaticFunction(v8::Handle<v8::Object> obj, const char* symbol, v8::InvocationCallback _func) {
|
void SWIGV8_AddStaticFunction(v8::Handle<v8::Object> obj, const char* symbol, const v8::FunctionCallback& _func) {
|
||||||
obj->Set(v8::String::NewSymbol(symbol), v8::FunctionTemplate::New(_func)->GetFunction());
|
obj->Set(v8::String::NewSymbol(symbol), v8::FunctionTemplate::New(_func)->GetFunction());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Registers a class method with given name for a given object.
|
* Registers a class method with given name for a given object.
|
||||||
*/
|
*/
|
||||||
void SWIGV8_AddStaticVariable(v8::Handle<v8::Object> obj, const char* symbol, v8::AccessorGetter getter, v8::AccessorSetter setter) {
|
void SWIGV8_AddStaticVariable(v8::Handle<v8::Object> obj, const char* symbol, v8::AccessorGetterCallback getter, v8::AccessorSetterCallback setter) {
|
||||||
obj->SetAccessor(v8::String::NewSymbol(symbol), getter, setter);
|
obj->SetAccessor(v8::String::NewSymbol(symbol), getter, setter);
|
||||||
}
|
}
|
||||||
|
|
||||||
void JS_veto_set_variable(v8::Local<v8::String> property, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
|
void JS_veto_set_variable(v8::Local<v8::String> property, v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<void>& info)
|
||||||
{
|
{
|
||||||
char buffer[256];
|
char buffer[256];
|
||||||
char msg[512];
|
char msg[512];
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue