Better v8 version handling.
You should start to specify a version on command line, e.g.,
swig -javascript -v8 -DSWIG_V8_VERSION=0x032007
This commit is contained in:
parent
5228c0eeab
commit
a48438c562
3 changed files with 168 additions and 100 deletions
|
|
@ -6,8 +6,25 @@
|
||||||
* - $jsargcount: number of arguments
|
* - $jsargcount: number of arguments
|
||||||
* - $jsmangledtype: mangled type of class
|
* - $jsmangledtype: mangled type of class
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
|
%insert(runtime) %{
|
||||||
|
#if (SWIG_V8_VERSION < 0x031900)
|
||||||
|
typedef v8::Handle<v8::Value> SwigV8ReturnValue;
|
||||||
|
typedef v8::Arguments SwigV8Arguments;
|
||||||
|
typedef v8::AccessorInfo SwigV8PropertyCallbackInfo;
|
||||||
|
#define SWIGV8_RETURN(val) return scope.Close(val)
|
||||||
|
#define SWIGV8_RETURN_INFO(val, info) return scope.Close(val)
|
||||||
|
#else
|
||||||
|
typedef void SwigV8ReturnValue;
|
||||||
|
typedef v8::FunctionCallbackInfo<v8::Value> SwigV8Arguments;
|
||||||
|
typedef v8::PropertyCallbackInfo<v8::Value> SwigV8PropertyCallbackInfo;
|
||||||
|
#define SWIGV8_RETURN(val) return args.GetReturnValue().Set(val)
|
||||||
|
#define SWIGV8_RETURN_INFO(val, info) return args.GetReturnValue().Set(val)
|
||||||
|
#endif
|
||||||
|
%}
|
||||||
|
|
||||||
%fragment("js_ctor", "templates") %{
|
%fragment("js_ctor", "templates") %{
|
||||||
void $jswrapper(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
SwigV8ReturnValue $jswrapper(const SwigV8Arguments& args) {
|
||||||
v8::HandleScope scope;
|
v8::HandleScope scope;
|
||||||
v8::Handle<v8::Object> self = args.Holder();
|
v8::Handle<v8::Object> self = args.Holder();
|
||||||
$jslocals
|
$jslocals
|
||||||
|
|
@ -15,10 +32,11 @@ void $jswrapper(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||||
$jscode
|
$jscode
|
||||||
|
|
||||||
SWIGV8_SetPrivateData(self, result, SWIGTYPE_$jsmangledtype, SWIG_POINTER_OWN);
|
SWIGV8_SetPrivateData(self, result, SWIGTYPE_$jsmangledtype, SWIG_POINTER_OWN);
|
||||||
args.GetReturnValue().Set(self);
|
SWIGV8_RETURN(self);
|
||||||
|
|
||||||
|
goto fail;
|
||||||
fail:
|
fail:
|
||||||
return;
|
SWIGV8_RETURN(v8::Undefined());
|
||||||
}
|
}
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
|
@ -29,9 +47,10 @@ fail:
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
%fragment ("js_veto_ctor", "templates")
|
%fragment ("js_veto_ctor", "templates")
|
||||||
%{
|
%{
|
||||||
void $jswrapper(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
SwigV8ReturnValue $jswrapper(const SwigV8Arguments& 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");
|
||||||
|
SWIGV8_RETURN(v8::Undefined());
|
||||||
}
|
}
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
|
@ -43,7 +62,7 @@ void $jswrapper(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
%fragment ("js_ctor_dispatcher", "templates")
|
%fragment ("js_ctor_dispatcher", "templates")
|
||||||
%{
|
%{
|
||||||
void $jswrapper(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
SwigV8ReturnValue $jswrapper(const SwigV8Arguments& args) {
|
||||||
v8::HandleScope scope;
|
v8::HandleScope scope;
|
||||||
OverloadErrorHandler errorHandler;
|
OverloadErrorHandler errorHandler;
|
||||||
v8::Handle<v8::Value> self;
|
v8::Handle<v8::Value> self;
|
||||||
|
|
@ -55,6 +74,7 @@ void $jswrapper(const v8::FunctionCallbackInfo<v8::Value>& 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:
|
||||||
|
SWIGV8_RETURN(v8::Undefined());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
%}
|
%}
|
||||||
|
|
@ -68,7 +88,7 @@ fail:
|
||||||
* - $jsmangledtype: mangled type of class
|
* - $jsmangledtype: mangled type of class
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
%fragment("js_overloaded_ctor", "templates") %{
|
%fragment("js_overloaded_ctor", "templates") %{
|
||||||
void $jswrapper(const v8::FunctionCallbackInfo<v8::Value>& args, V8ErrorHandler& SWIGV8_ErrorHandler) {
|
SwigV8ReturnValue $jswrapper(const SwigV8Arguments& 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
|
||||||
|
|
@ -76,11 +96,11 @@ void $jswrapper(const v8::FunctionCallbackInfo<v8::Value>& args, V8ErrorHandler&
|
||||||
$jscode
|
$jscode
|
||||||
|
|
||||||
SWIGV8_SetPrivateData(self, result, SWIGTYPE_$jsmangledtype, SWIG_POINTER_OWN);
|
SWIGV8_SetPrivateData(self, result, SWIGTYPE_$jsmangledtype, SWIG_POINTER_OWN);
|
||||||
args.GetReturnValue().Set(self);
|
SWIGV8_RETURN(self);
|
||||||
|
|
||||||
goto fail;
|
goto fail;
|
||||||
fail:
|
fail:
|
||||||
return;
|
SWIGV8_RETURN(v8::Undefined());
|
||||||
}
|
}
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
|
@ -95,9 +115,17 @@ fail:
|
||||||
%{
|
%{
|
||||||
if(args.Length() == $jsargcount) {
|
if(args.Length() == $jsargcount) {
|
||||||
errorHandler.err.Clear();
|
errorHandler.err.Clear();
|
||||||
|
#if SWIG_V8_VERSION < 0x031900
|
||||||
|
self = $jswrapper(args, errorHandler);
|
||||||
|
if(errorHandler.err.IsEmpty()) {
|
||||||
|
return scope.Close(self);
|
||||||
|
}
|
||||||
|
#else
|
||||||
$jswrapper(args, errorHandler);
|
$jswrapper(args, errorHandler);
|
||||||
if(errorHandler.err.IsEmpty())
|
if(errorHandler.err.IsEmpty()) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
|
@ -109,15 +137,13 @@ fail:
|
||||||
%fragment ("js_dtor", "templates")
|
%fragment ("js_dtor", "templates")
|
||||||
%{
|
%{
|
||||||
|
|
||||||
#if defined(BUILDING_NODE_EXTENSION) || defined(V8_3_14)
|
#if (SWIG_V8_VERSION < 0x031900)
|
||||||
void $jswrapper(v8::Persistent< v8::Value > object, void *parameter)
|
void $jswrapper(v8::Persistent< v8::Value > object, void *parameter)
|
||||||
|
{
|
||||||
|
SWIGV8_Proxy *proxy = static_cast<SWIGV8_Proxy *>(parameter);
|
||||||
#else
|
#else
|
||||||
void $jswrapper(v8::Isolate *isolate, v8::Persistent< v8::Object > * object, SWIGV8_Proxy *proxy)
|
void $jswrapper(v8::Isolate *isolate, v8::Persistent< v8::Object > * object, SWIGV8_Proxy *proxy)
|
||||||
#endif
|
|
||||||
{
|
{
|
||||||
|
|
||||||
#if defined(BUILDING_NODE_EXTENSION) || defined(V8_3_14)
|
|
||||||
SWIGV8_Proxy *proxy = static_cast<SWIGV8_Proxy *>(parameter);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(proxy->swigCMemOwn && proxy->swigCObject) {
|
if(proxy->swigCMemOwn && proxy->swigCObject) {
|
||||||
|
|
@ -129,11 +155,10 @@ void $jswrapper(v8::Isolate *isolate, v8::Persistent< v8::Object > * object, SWI
|
||||||
delete proxy;
|
delete proxy;
|
||||||
|
|
||||||
|
|
||||||
#if defined(BUILDING_NODE_EXTENSION) || defined(V8_3_14)
|
|
||||||
object.Clear();
|
object.Clear();
|
||||||
|
#if (SWIG_V8_VERSION < 0x031900)
|
||||||
object.Dispose();
|
object.Dispose();
|
||||||
#else
|
#else
|
||||||
object->Clear();
|
|
||||||
object->Dispose(isolate);
|
object->Dispose(isolate);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
@ -168,16 +193,16 @@ void $jswrapper(v8::Persistent< v8::Value > object, void *parameter) {
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
%fragment("js_getter", "templates")
|
%fragment("js_getter", "templates")
|
||||||
%{
|
%{
|
||||||
void $jswrapper(v8::Local<v8::String> property, const v8::PropertyCallbackInfo<v8::Value>& info) {
|
SwigV8ReturnValue $jswrapper(v8::Local<v8::String> property, const SwigV8PropertyCallbackInfo& info) {
|
||||||
v8::HandleScope scope;
|
v8::HandleScope scope;
|
||||||
v8::Handle<v8::Value> jsresult;
|
v8::Handle<v8::Value> jsresult;
|
||||||
$jslocals
|
$jslocals
|
||||||
$jscode
|
$jscode
|
||||||
info.GetReturnValue().Set(jsresult);
|
SWIGV8_RETURN_INFO(jsresult, info);
|
||||||
return;
|
|
||||||
goto fail;
|
goto fail;
|
||||||
fail:
|
fail:
|
||||||
return;
|
SWIGV8_RETURN_INFO(v8::Undefined(), info);
|
||||||
}
|
}
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
|
@ -189,7 +214,8 @@ fail:
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
%fragment("js_setter", "templates")
|
%fragment("js_setter", "templates")
|
||||||
%{
|
%{
|
||||||
void $jswrapper(v8::Local<v8::String> property, v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<void>& info) {
|
void $jswrapper(v8::Local<v8::String> property, v8::Local<v8::Value> value,
|
||||||
|
const SwigV8PropertyCallbackInfo& info) {
|
||||||
v8::HandleScope scope;
|
v8::HandleScope scope;
|
||||||
$jslocals
|
$jslocals
|
||||||
$jscode
|
$jscode
|
||||||
|
|
@ -207,18 +233,18 @@ fail:
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
%fragment("js_function", "templates")
|
%fragment("js_function", "templates")
|
||||||
%{
|
%{
|
||||||
void $jswrapper(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
SwigV8ReturnValue $jswrapper(const SwigV8Arguments& 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
|
||||||
args.GetReturnValue().Set(jsresult);
|
SWIGV8_RETURN(jsresult);
|
||||||
return;
|
|
||||||
goto fail;
|
goto fail;
|
||||||
fail:
|
fail:
|
||||||
return;
|
SWIGV8_RETURN(v8::Undefined());
|
||||||
}
|
}
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
|
@ -231,7 +257,7 @@ fail:
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
%fragment("js_function_dispatcher", "templates")
|
%fragment("js_function_dispatcher", "templates")
|
||||||
%{
|
%{
|
||||||
void $jswrapper(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
SwigV8ReturnValue $jswrapper(const SwigV8Arguments& args) {
|
||||||
v8::HandleScope scope;
|
v8::HandleScope scope;
|
||||||
v8::Handle<v8::Value> jsresult;
|
v8::Handle<v8::Value> jsresult;
|
||||||
OverloadErrorHandler errorHandler;
|
OverloadErrorHandler errorHandler;
|
||||||
|
|
@ -241,7 +267,7 @@ void $jswrapper(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||||
|
|
||||||
goto fail;
|
goto fail;
|
||||||
fail:
|
fail:
|
||||||
return;
|
SWIGV8_RETURN(v8::Undefined());
|
||||||
}
|
}
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
|
@ -253,17 +279,17 @@ fail:
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
%fragment ("js_overloaded_function", "templates")
|
%fragment ("js_overloaded_function", "templates")
|
||||||
%{
|
%{
|
||||||
void $jswrapper(const v8::FunctionCallbackInfo<v8::Value>& args, V8ErrorHandler& SWIGV8_ErrorHandler)
|
SwigV8ReturnValue $jswrapper(const SwigV8Arguments& args, V8ErrorHandler& SWIGV8_ErrorHandler)
|
||||||
{
|
{
|
||||||
v8::HandleScope scope;
|
v8::HandleScope scope;
|
||||||
v8::Handle<v8::Value> jsresult;
|
v8::Handle<v8::Value> jsresult;
|
||||||
$jslocals
|
$jslocals
|
||||||
$jscode
|
$jscode
|
||||||
args.GetReturnValue().Set(jsresult);
|
SWIGV8_RETURN(jsresult);
|
||||||
return;
|
|
||||||
goto fail;
|
goto fail;
|
||||||
fail:
|
fail:
|
||||||
return;
|
SWIGV8_RETURN(v8::Undefined());
|
||||||
}
|
}
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
|
@ -275,11 +301,20 @@ fail:
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
%fragment ("js_function_dispatch_case", "templates")
|
%fragment ("js_function_dispatch_case", "templates")
|
||||||
%{
|
%{
|
||||||
|
|
||||||
if(args.Length() == $jsargcount) {
|
if(args.Length() == $jsargcount) {
|
||||||
errorHandler.err.Clear();
|
errorHandler.err.Clear();
|
||||||
$jswrapper(args, errorHandler);
|
#if (SWIG_V8_VERSION < 0x031900)
|
||||||
if(errorHandler.err.IsEmpty())
|
jsresult = $jswrapper(args, errorHandler);
|
||||||
|
if(errorHandler.err.IsEmpty()) {
|
||||||
|
return scope.Close(jsresult);
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
$jswrapper(args, errorHandler);
|
||||||
|
if(errorHandler.err.IsEmpty()) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
%}
|
%}
|
||||||
|
|
||||||
|
|
@ -301,7 +336,7 @@ fail:
|
||||||
%fragment("jsv8_define_class_template", "templates")
|
%fragment("jsv8_define_class_template", "templates")
|
||||||
%{
|
%{
|
||||||
v8::Handle<v8::FunctionTemplate> $jsmangledname_class = SWIGV8_CreateClassTemplate("$jsmangledname");
|
v8::Handle<v8::FunctionTemplate> $jsmangledname_class = SWIGV8_CreateClassTemplate("$jsmangledname");
|
||||||
#if defined(BUILDING_NODE_EXTENSION) || defined(V8_3_14)
|
#if (SWIG_V8_VERSION < 0x031900)
|
||||||
$jsmangledname_clientData.class_templ = v8::Persistent<v8::FunctionTemplate>::New($jsmangledname_class);
|
$jsmangledname_clientData.class_templ = v8::Persistent<v8::FunctionTemplate>::New($jsmangledname_class);
|
||||||
#else
|
#else
|
||||||
$jsmangledname_clientData.class_templ.Reset(v8::Isolate::GetCurrent(), $jsmangledname_class);
|
$jsmangledname_clientData.class_templ.Reset(v8::Isolate::GetCurrent(), $jsmangledname_class);
|
||||||
|
|
@ -320,7 +355,7 @@ fail:
|
||||||
%{
|
%{
|
||||||
if (SWIGTYPE_p$jsbaseclass->clientdata && !(static_cast<SWIGV8_ClientData *>(SWIGTYPE_p$jsbaseclass->clientdata)->class_templ.IsEmpty()))
|
if (SWIGTYPE_p$jsbaseclass->clientdata && !(static_cast<SWIGV8_ClientData *>(SWIGTYPE_p$jsbaseclass->clientdata)->class_templ.IsEmpty()))
|
||||||
{
|
{
|
||||||
#if defined(BUILDING_NODE_EXTENSION) || defined(V8_3_14)
|
#if (SWIG_V8_VERSION < 0x031900)
|
||||||
$jsmangledname_class->Inherit(static_cast<SWIGV8_ClientData *>(SWIGTYPE_p$jsbaseclass->clientdata)->class_templ);
|
$jsmangledname_class->Inherit(static_cast<SWIGV8_ClientData *>(SWIGTYPE_p$jsbaseclass->clientdata)->class_templ);
|
||||||
#else
|
#else
|
||||||
$jsmangledname_class->Inherit(
|
$jsmangledname_class->Inherit(
|
||||||
|
|
@ -449,8 +484,6 @@ fail:
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
%fragment("js_initializer", "templates")
|
%fragment("js_initializer", "templates")
|
||||||
%{
|
%{
|
||||||
// The extern "C" makes little sense here because the paramater is using C++ objects and templates.
|
|
||||||
// extern "C" {
|
|
||||||
|
|
||||||
#if defined(BUILDING_NODE_EXTENSION)
|
#if defined(BUILDING_NODE_EXTENSION)
|
||||||
void $jsname_initialize(v8::Handle<v8::Object> global_obj, v8::Handle<v8::Object> /*module*/)
|
void $jsname_initialize(v8::Handle<v8::Object> global_obj, v8::Handle<v8::Object> /*module*/)
|
||||||
|
|
@ -464,7 +497,7 @@ void $jsname_initialize(v8::Handle<v8::Object> global_obj)
|
||||||
|
|
||||||
// a class template for creating proxies of undefined types
|
// a class template for creating proxies of undefined types
|
||||||
|
|
||||||
#if defined(BUILDING_NODE_EXTENSION) || defined(V8_3_14)
|
#if (SWIG_V8_VERSION < 0x031900)
|
||||||
SWIGV8_SWIGTYPE_Proxy_class_templ = v8::Persistent<v8::FunctionTemplate>::New(SWIGV8_CreateClassTemplate("SwigProxy"));
|
SWIGV8_SWIGTYPE_Proxy_class_templ = v8::Persistent<v8::FunctionTemplate>::New(SWIGV8_CreateClassTemplate("SwigProxy"));
|
||||||
#else
|
#else
|
||||||
SWIGV8_SWIGTYPE_Proxy_class_templ.Reset(v8::Isolate::GetCurrent(), SWIGV8_CreateClassTemplate("SwigProxy"));
|
SWIGV8_SWIGTYPE_Proxy_class_templ.Reset(v8::Isolate::GetCurrent(), SWIGV8_CreateClassTemplate("SwigProxy"));
|
||||||
|
|
@ -500,7 +533,4 @@ void $jsname_initialize(v8::Handle<v8::Object> global_obj)
|
||||||
NODE_MODULE($jsname, $jsname_initialize);
|
NODE_MODULE($jsname, $jsname_initialize);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// } // extern "C"
|
|
||||||
%}
|
%}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,18 @@
|
||||||
%insert(runtime) %{
|
%insert(runtime) %{
|
||||||
|
|
||||||
|
// Note: since 3.19 there are new CallBack types, since 03.21.9 the old ones have been removed
|
||||||
|
#if SWIG_V8_VERSION < 0x031900
|
||||||
|
typedef v8::InvocationCallback SwigV8FunctionCallback;
|
||||||
|
typedef v8::AccessorGetter SwigV8AccessorGetterCallback;
|
||||||
|
typedef v8::AccessorSetter SwigV8AccessorSetterCallback;
|
||||||
|
typedef v8::AccessorInfo SwigV8PropertyCallbackInfoVoid;
|
||||||
|
#else
|
||||||
|
typedef v8::FunctionCallback SwigV8FunctionCallback;
|
||||||
|
typedef v8::AccessorGetterCallback SwigV8AccessorGetterCallback;
|
||||||
|
typedef v8::AccessorSetterCallback SwigV8AccessorSetterCallback;
|
||||||
|
typedef v8::PropertyCallbackInfo<void> SwigV8PropertyCallbackInfoVoid;
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates a class template for a class with specified initialization function.
|
* Creates a class template for a class with specified initialization function.
|
||||||
*/
|
*/
|
||||||
|
|
@ -17,7 +30,8 @@ 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::FunctionCallback _func) {
|
void SWIGV8_AddMemberFunction(v8::Handle<v8::FunctionTemplate> class_templ, const char* symbol,
|
||||||
|
SwigV8FunctionCallback _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 +39,8 @@ 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::AccessorGetterCallback getter, v8::AccessorSetterCallback setter) {
|
void SWIGV8_AddMemberVariable(v8::Handle<v8::FunctionTemplate> class_templ, const char* symbol,
|
||||||
|
SwigV8AccessorGetterCallback getter, SwigV8AccessorSetterCallback 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 +48,21 @@ 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, const v8::FunctionCallback& _func) {
|
void SWIGV8_AddStaticFunction(v8::Handle<v8::Object> obj, const char* symbol,
|
||||||
|
const SwigV8FunctionCallback& _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::AccessorGetterCallback getter, v8::AccessorSetterCallback setter) {
|
void SWIGV8_AddStaticVariable(v8::Handle<v8::Object> obj, const char* symbol,
|
||||||
|
SwigV8AccessorGetterCallback getter, SwigV8AccessorSetterCallback 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::PropertyCallbackInfo<void>& info)
|
void JS_veto_set_variable(v8::Local<v8::String> property, v8::Local<v8::Value> value,
|
||||||
|
const SwigV8PropertyCallbackInfoVoid& info)
|
||||||
{
|
{
|
||||||
char buffer[256];
|
char buffer[256];
|
||||||
char msg[512];
|
char msg[512];
|
||||||
|
|
|
||||||
|
|
@ -4,8 +4,28 @@
|
||||||
* Javascript support code
|
* Javascript support code
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
%insert(runtime) %{
|
%define %swig_v8_define_version(version)
|
||||||
|
%begin %{
|
||||||
|
#ifndef SWIG_V8_VERSION
|
||||||
|
#define SWIG_V8_VERSION version
|
||||||
|
#endif
|
||||||
|
%}
|
||||||
|
%enddef
|
||||||
|
|
||||||
|
#ifdef SWIG_V8_VERSION
|
||||||
|
%swig_v8_define_version(SWIG_V8_VERSION)
|
||||||
|
#else
|
||||||
|
// HACK: defining a default version
|
||||||
|
%swig_v8_define_version(SWIG_V8_VERSION)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#ifdef BUILDING_NODE_EXTENSION
|
||||||
|
%insert("runtime") %{
|
||||||
|
#include <node.h>
|
||||||
|
%}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
%insert(runtime) %{
|
||||||
#include <v8.h>
|
#include <v8.h>
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue