[Javascript] For v8 >= 4.3.0, use V8_MAJOR_VERSION.

Fixes https://github.com/swig/swig/issues/561.
This commit is contained in:
Olly Betts 2016-01-12 09:33:13 +13:00
commit b3bedc210c
7 changed files with 107 additions and 81 deletions

View file

@ -5,6 +5,10 @@ See the RELEASENOTES file for a summary of changes in each release.
Version 3.0.9 (in progress)
===========================
2016-01-12: olly
[Javascript] For v8 >= 4.3.0, use V8_MAJOR_VERSION.
Fixes https://github.com/swig/swig/issues/561.
2016-01-10: ahnolds
Improved size_t and ptrdiff_t typemaps to support large values
on platforms where sizeof(size_t) > sizeof(unsigned long) and

View file

@ -90,11 +90,22 @@ $ swig -javascript -jsc example.i</pre>
$ swig -c++ -javascript -jsc example.i</pre>
</div>
<p>The V8 code that SWIG generates should work with most versions from 3.11.10 up to 3.29.14 and later.</p>
<p>Specify the V8 version when running SWIG (e.g. 3.25.30)</p>
<p>The API headers for V8 &gt;= 4.3.0 define constants which SWIG can use to
determine the V8 version it is compiling for. For versions &lt; 4.3.0, you
need to specify the V8 version when running SWIG. This is specified as a hex
constant, but the constant is read as pairs of decimal digits, so for V8
3.25.30 use constant 0x032530. This scheme can't represent components &gt; 99,
but this constant is only useful for V8 &lt; 4.3.0, and no V8 versions from
that era had a component &gt; 99. For example:</p>
<div class="shell">
<pre>
$ swig -c++ -javascript -v8 -DV8_VERSION=0x032530 example.i</pre>
</div>
<p>If you're targetting V8 &gt;= 4.3.0, you would just run swig like so:<p>
<div class="shell">
<pre>
$ swig -c++ -javascript -v8 example.i</pre>
</div>
<p>This creates a C/C++ source file <code>example_wrap.c</code> or <code>example_wrap.cxx</code>. The generated C source file contains the low-level wrappers that need to be compiled and linked with the rest of your C/C++ application to create an extension module.</p>
<p>The name of the wrapper file is derived from the name of the input file. For example, if the input file is <code>example.i</code>, the name of the wrapper file is <code>example_wrap.c</code>. To change this, you can use the -o option. The wrapped module will export one function which must be called to register the module with the Javascript interpreter. For example, if your module is named <code>example</code> the corresponding initializer for JavascriptCore would be</p>
<div class="code">

View file

@ -102,7 +102,7 @@ fail:
%{
if(args.Length() == $jsargcount) {
errorHandler.err.Clear();
#if (SWIG_V8_VERSION < 0x031903)
#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031903)
self = $jswrapper(args, errorHandler);
if(errorHandler.err.IsEmpty()) {
SWIGV8_ESCAPE(self);
@ -124,13 +124,13 @@ fail:
%fragment ("js_dtor", "templates")
%{
#if (SWIG_V8_VERSION < 0x031710)
#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031710)
static void $jswrapper(v8::Persistent< v8::Value > object, void *parameter) {
SWIGV8_Proxy *proxy = static_cast<SWIGV8_Proxy *>(parameter);
#elif (SWIG_V8_VERSION < 0x031900)
#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031900)
static void $jswrapper(v8::Isolate *isolate, v8::Persistent<v8::Value> object, void *parameter) {
SWIGV8_Proxy *proxy = static_cast<SWIGV8_Proxy *>(parameter);
#elif (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION)
#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION)
static void $jswrapper(v8::Isolate *isolate, v8::Persistent<v8::Object> *object, SWIGV8_Proxy *proxy) {
#else
static void $jswrapper(const v8::WeakCallbackData<v8::Object, SWIGV8_Proxy> &data) {
@ -148,11 +148,11 @@ static void $jswrapper(const v8::WeakCallbackData<v8::Object, SWIGV8_Proxy> &dat
object.Clear();
#if (SWIG_V8_VERSION < 0x031710)
#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031710)
object.Dispose();
#elif (SWIG_V8_VERSION < 0x031900)
#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031900)
object.Dispose(isolate);
#elif (SWIG_V8_VERSION < 0x032100)
#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x032100)
object->Dispose(isolate);
#else
object->Dispose();
@ -168,13 +168,13 @@ static void $jswrapper(const v8::WeakCallbackData<v8::Object, SWIGV8_Proxy> &dat
* ----------------------------------------------------------------------------- */
%fragment ("js_dtoroverride", "templates")
%{
#if (SWIG_V8_VERSION < 0x031710)
#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031710)
static void $jswrapper(v8::Persistent<v8::Value> object, void *parameter) {
SWIGV8_Proxy *proxy = static_cast<SWIGV8_Proxy *>(parameter);
#elif (SWIG_V8_VERSION < 0x031900)
#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031900)
static void $jswrapper(v8::Isolate *isolate, v8::Persistent<v8::Value> object, void *parameter) {
SWIGV8_Proxy *proxy = static_cast<SWIGV8_Proxy *>(parameter);
#elif (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION)
#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION)
static void $jswrapper(v8::Isolate *isolate, v8::Persistent< v8::Object> *object, SWIGV8_Proxy *proxy) {
#else
static void $jswrapper(const v8::WeakCallbackData<v8::Object, SWIGV8_Proxy> &data) {
@ -188,13 +188,13 @@ static void $jswrapper(const v8::WeakCallbackData<v8::Object, SWIGV8_Proxy> &dat
}
delete proxy;
#if (SWIG_V8_VERSION < 0x031710)
#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031710)
object.Dispose();
#elif (SWIG_V8_VERSION < 0x031900)
#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031900)
object.Dispose(isolate);
#elif (SWIG_V8_VERSION < 0x032100)
#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x032100)
object->Dispose(isolate);
#elif (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION)
#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION)
object->Dispose();
#else
object.Clear();
@ -326,7 +326,7 @@ fail:
if(args.Length() == $jsargcount) {
errorHandler.err.Clear();
#if (SWIG_V8_VERSION < 0x031903)
#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031903)
jsresult = $jswrapper(args, errorHandler);
if(errorHandler.err.IsEmpty()) {
SWIGV8_ESCAPE(jsresult);
@ -376,7 +376,7 @@ fail:
%{
if (SWIGTYPE_p$jsbaseclass->clientdata && !(static_cast<SWIGV8_ClientData *>(SWIGTYPE_p$jsbaseclass->clientdata)->class_templ.IsEmpty()))
{
#if (SWIG_V8_VERSION < 0x031903)
#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031903)
$jsmangledname_class->Inherit(static_cast<SWIGV8_ClientData *>(SWIGTYPE_p$jsbaseclass->clientdata)->class_templ);
#else
$jsmangledname_class->Inherit(

View file

@ -1,7 +1,7 @@
%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 < 0x031903)
#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031903)
typedef v8::InvocationCallback SwigV8FunctionCallback;
typedef v8::AccessorGetter SwigV8AccessorGetterCallback;
typedef v8::AccessorSetter SwigV8AccessorSetterCallback;

View file

@ -7,13 +7,13 @@
#define SWIGV8_SETWEAK_VERSION 0x032224
#if (SWIG_V8_VERSION < 0x031803)
#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031803)
#define SWIGV8_STRING_NEW2(cstr, len) v8::String::New(cstr, len)
#else
#define SWIGV8_STRING_NEW2(cstr, len) v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), cstr, v8::String::kNormalString, len)
#endif
#if (SWIG_V8_VERSION < 0x031903)
#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031903)
typedef v8::Handle<v8::Value> SwigV8ReturnValue;
typedef v8::Arguments SwigV8Arguments;
typedef v8::AccessorInfo SwigV8PropertyCallbackInfo;
@ -27,11 +27,11 @@ typedef v8::PropertyCallbackInfo<v8::Value> SwigV8PropertyCallbackInfo;
#define SWIGV8_RETURN_INFO(val, info) info.GetReturnValue().Set(val); return
#endif
#if (SWIG_V8_VERSION < 0x032117)
#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x032117)
#define SWIGV8_HANDLESCOPE() v8::HandleScope scope
#define SWIGV8_HANDLESCOPE_ESC() v8::HandleScope scope
#define SWIGV8_ESCAPE(val) return scope.Close(val)
#elif (SWIG_V8_VERSION < 0x032224)
#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x032224)
#define SWIGV8_HANDLESCOPE() v8::HandleScope scope(v8::Isolate::GetCurrent());
#define SWIGV8_HANDLESCOPE_ESC() v8::HandleScope scope(v8::Isolate::GetCurrent());
#define SWIGV8_ESCAPE(val) return scope.Close(val)
@ -41,7 +41,7 @@ typedef v8::PropertyCallbackInfo<v8::Value> SwigV8PropertyCallbackInfo;
#define SWIGV8_ESCAPE(val) return scope.Escape(val)
#endif
#if (SWIG_V8_VERSION < 0x032224)
#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x032224)
#define SWIGV8_ADJUST_MEMORY(size) v8::V8::AdjustAmountOfExternalAllocatedMemory(size)
#define SWIGV8_CURRENT_CONTEXT() v8::Context::GetCurrent()
#define SWIGV8_THROW_EXCEPTION(err) v8::ThrowException(err)
@ -55,7 +55,7 @@ typedef v8::PropertyCallbackInfo<v8::Value> SwigV8PropertyCallbackInfo;
#define SWIGV8_SYMBOL_NEW(sym) v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), sym)
#endif
#if (SWIG_V8_VERSION < 0x032318)
#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x032318)
#define SWIGV8_ARRAY_NEW() v8::Array::New()
#define SWIGV8_BOOLEAN_NEW(bool) v8::Boolean::New(bool)
#define SWIGV8_EXTERNAL_NEW(val) v8::External::New(val)
@ -83,9 +83,9 @@ typedef v8::PropertyCallbackInfo<v8::Value> SwigV8PropertyCallbackInfo;
#define SWIGV8_NULL() v8::Null(v8::Isolate::GetCurrent())
#endif
#if (SWIG_V8_VERSION < 0x031710)
#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031710)
#define SWIGV8_SET_CLASS_TEMPL(class_templ, class) class_templ = v8::Persistent<v8::FunctionTemplate>::New(class);
#elif (SWIG_V8_VERSION < 0x031900)
#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031900)
#define SWIGV8_SET_CLASS_TEMPL(class_templ, class) class_templ = v8::Persistent<v8::FunctionTemplate>::New(v8::Isolate::GetCurrent(), class);
#else
#define SWIGV8_SET_CLASS_TEMPL(class_templ, class) class_templ.Reset(v8::Isolate::GetCurrent(), class);
@ -156,13 +156,13 @@ public:
};
~SWIGV8_Proxy() {
#if (SWIG_V8_VERSION < 0x031710)
#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031710)
handle.ClearWeak();
handle.Dispose();
#elif (SWIG_V8_VERSION < 0x032100)
#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x032100)
handle.ClearWeak(v8::Isolate::GetCurrent());
handle.Dispose(v8::Isolate::GetCurrent());
#elif (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION)
#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION)
handle.ClearWeak();
handle.Dispose();
#else
@ -170,7 +170,7 @@ public:
handle.Reset();
#endif
#if (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION)
#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION)
handle.Clear();
#endif
@ -187,11 +187,11 @@ class SWIGV8_ClientData {
public:
v8::Persistent<v8::FunctionTemplate> class_templ;
#if (SWIG_V8_VERSION < 0x031710)
#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031710)
void (*dtor) (v8::Persistent< v8::Value> object, void *parameter);
#elif (SWIG_V8_VERSION < 0x031900)
#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031900)
void (*dtor) (v8::Isolate *isolate, v8::Persistent< v8::Value> object, void *parameter);
#elif (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION)
#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION)
void (*dtor) (v8::Isolate *isolate, v8::Persistent< v8::Object > *object, SWIGV8_Proxy *proxy);
#else
void (*dtor) (const v8::WeakCallbackData<v8::Object, SWIGV8_Proxy> &data);
@ -205,7 +205,7 @@ SWIGRUNTIME int SWIG_V8_ConvertInstancePtr(v8::Handle<v8::Object> objRef, void *
if(objRef->InternalFieldCount() < 1) return SWIG_ERROR;
#if (SWIG_V8_VERSION < 0x031511)
#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031511)
v8::Handle<v8::Value> cdataRef = objRef->GetInternalField(0);
SWIGV8_Proxy *cdata = static_cast<SWIGV8_Proxy *>(v8::External::Unwrap(cdataRef));
#else
@ -233,13 +233,13 @@ SWIGRUNTIME int SWIG_V8_ConvertInstancePtr(v8::Handle<v8::Object> objRef, void *
}
#if (SWIG_V8_VERSION < 0x031710)
#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031710)
SWIGRUNTIME void SWIGV8_Proxy_DefaultDtor(v8::Persistent< v8::Value > object, void *parameter) {
SWIGV8_Proxy *proxy = static_cast<SWIGV8_Proxy *>(parameter);
#elif (SWIG_V8_VERSION < 0x031900)
#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031900)
SWIGRUNTIME void SWIGV8_Proxy_DefaultDtor(v8::Isolate *, v8::Persistent< v8::Value > object, void *parameter) {
SWIGV8_Proxy *proxy = static_cast<SWIGV8_Proxy *>(parameter);
#elif (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION)
#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION)
SWIGRUNTIME void SWIGV8_Proxy_DefaultDtor(v8::Isolate *, v8::Persistent< v8::Object > *object, SWIGV8_Proxy *proxy) {
#else
SWIGRUNTIME void SWIGV8_Proxy_DefaultDtor(const v8::WeakCallbackData<v8::Object, SWIGV8_Proxy> &data) {
@ -257,7 +257,7 @@ SWIGRUNTIME int SWIG_V8_GetInstancePtr(v8::Handle<v8::Value> valRef, void **ptr)
if(objRef->InternalFieldCount() < 1) return SWIG_ERROR;
#if (SWIG_V8_VERSION < 0x031511)
#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031511)
v8::Handle<v8::Value> cdataRef = objRef->GetInternalField(0);
SWIGV8_Proxy *cdata = static_cast<SWIGV8_Proxy *>(v8::External::Unwrap(cdataRef));
#else
@ -279,34 +279,34 @@ SWIGRUNTIME void SWIGV8_SetPrivateData(v8::Handle<v8::Object> obj, void *ptr, sw
cdata->swigCMemOwn = (flags & SWIG_POINTER_OWN) ? 1 : 0;
cdata->info = info;
#if (SWIG_V8_VERSION < 0x031511)
#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031511)
obj->SetPointerInInternalField(0, cdata);
#else
obj->SetAlignedPointerInInternalField(0, cdata);
#endif
#if (SWIG_V8_VERSION < 0x031710)
#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031710)
cdata->handle = v8::Persistent<v8::Object>::New(obj);
#elif (SWIG_V8_VERSION < 0x031900)
#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031900)
cdata->handle = v8::Persistent<v8::Object>::New(v8::Isolate::GetCurrent(), obj);
#else
cdata->handle.Reset(v8::Isolate::GetCurrent(), obj);
#endif
#if (SWIG_V8_VERSION < 0x031710)
#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031710)
// clientdata must be set for owned data as we need to register the dtor
if(cdata->swigCMemOwn && (SWIGV8_ClientData*)info->clientdata) {
cdata->handle.MakeWeak(cdata, ((SWIGV8_ClientData*)info->clientdata)->dtor);
} else {
cdata->handle.MakeWeak(cdata, SWIGV8_Proxy_DefaultDtor);
}
#elif (SWIG_V8_VERSION < 0x031918)
#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031918)
if(cdata->swigCMemOwn && (SWIGV8_ClientData*)info->clientdata) {
cdata->handle.MakeWeak(v8::Isolate::GetCurrent(), cdata, ((SWIGV8_ClientData*)info->clientdata)->dtor);
} else {
cdata->handle.MakeWeak(v8::Isolate::GetCurrent(), cdata, SWIGV8_Proxy_DefaultDtor);
}
#elif (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION)
#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION)
if(cdata->swigCMemOwn && (SWIGV8_ClientData*)info->clientdata) {
cdata->handle.MakeWeak(cdata, ((SWIGV8_ClientData*)info->clientdata)->dtor);
} else {
@ -320,9 +320,9 @@ SWIGRUNTIME void SWIGV8_SetPrivateData(v8::Handle<v8::Object> obj, void *ptr, sw
}
#endif
#if (SWIG_V8_VERSION < 0x031710)
#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031710)
cdata->handle.MarkIndependent();
#elif (SWIG_V8_VERSION < 0x032100)
#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x032100)
cdata->handle.MarkIndependent(v8::Isolate::GetCurrent());
#else
cdata->handle.MarkIndependent();
@ -351,15 +351,15 @@ SWIGRUNTIME v8::Handle<v8::Value> SWIG_V8_NewPointerObj(void *ptr, swig_type_inf
v8::Handle<v8::FunctionTemplate> class_templ;
if (ptr == NULL) {
#if (SWIG_V8_VERSION < 0x031903)
#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031903)
SWIGV8_ESCAPE(SWIGV8_NULL());
#else
v8::Local<v8::Primitive> result = SWIGV8_NULL();
SWIGV8_ESCAPE(result);
#endif
#endif
}
#if (SWIG_V8_VERSION < 0x031903)
#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031903)
if(info->clientdata != 0) {
class_templ = ((SWIGV8_ClientData*) info->clientdata)->class_templ;
} else {
@ -483,7 +483,7 @@ swig_type_info *SwigV8Packed_UnpackData(v8::Handle<v8::Value> valRef, void *ptr,
v8::Handle<v8::Object> objRef = valRef->ToObject();
#if (SWIG_V8_VERSION < 0x031511)
#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031511)
v8::Handle<v8::Value> cdataRef = objRef->GetInternalField(0);
sobj = static_cast<SwigV8PackedData*>(v8::External::Unwrap(cdataRef));
#else
@ -511,13 +511,13 @@ int SWIGV8_ConvertPacked(v8::Handle<v8::Value> valRef, void *ptr, size_t sz, swi
return SWIG_OK;
}
#if (SWIG_V8_VERSION < 0x031710)
#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031710)
SWIGRUNTIME void _wrap_SwigV8PackedData_delete(v8::Persistent< v8::Value > object, void *parameter) {
SwigV8PackedData *cdata = static_cast<SwigV8PackedData *>(parameter);
#elif (SWIG_V8_VERSION < 0x031900)
#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031900)
SWIGRUNTIME void _wrap_SwigV8PackedData_delete(v8::Isolate *isolate, v8::Persistent<v8::Value> object, void *parameter) {
SwigV8PackedData *cdata = static_cast<SwigV8PackedData *>(parameter);
#elif (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION)
#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION)
SWIGRUNTIME void _wrap_SwigV8PackedData_delete(v8::Isolate *isolate, v8::Persistent<v8::Object> *object, SwigV8PackedData *cdata) {
#else
SWIGRUNTIME void _wrap_SwigV8PackedData_delete(const v8::WeakCallbackData<v8::Object, SwigV8PackedData> &data) {
@ -527,15 +527,15 @@ SWIGRUNTIME void _wrap_SwigV8PackedData_delete(const v8::WeakCallbackData<v8::Ob
delete cdata;
#if (SWIG_V8_VERSION < 0x031710)
#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031710)
object.Clear();
object.Dispose();
#elif (SWIG_V8_VERSION < 0x031900)
#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031900)
object.Clear();
object.Dispose(isolate);
#elif (SWIG_V8_VERSION < 0x032100)
#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x032100)
object->Dispose(isolate);
#elif (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION)
#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION)
object->Dispose();
#else
object.Clear();
@ -552,35 +552,35 @@ v8::Handle<v8::Value> SWIGV8_NewPackedObj(void *data, size_t size, swig_type_inf
obj->SetHiddenValue(SWIGV8_STRING_NEW("__swig__packed_data__"), SWIGV8_BOOLEAN_NEW(true));
#if (SWIG_V8_VERSION < 0x031511)
#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031511)
obj->SetPointerInInternalField(0, cdata);
#else
obj->SetAlignedPointerInInternalField(0, cdata);
#endif
#if (SWIG_V8_VERSION < 0x031710)
#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031710)
cdata->handle = v8::Persistent<v8::Object>::New(obj);
#elif (SWIG_V8_VERSION < 0x031900)
#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031900)
cdata->handle = v8::Persistent<v8::Object>::New(v8::Isolate::GetCurrent(), obj);
#else
cdata->handle.Reset(v8::Isolate::GetCurrent(), obj);
#endif
#if (SWIG_V8_VERSION < 0x031710)
#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031710)
cdata->handle.MakeWeak(cdata, _wrap_SwigV8PackedData_delete);
#elif (SWIG_V8_VERSION < 0x031918)
#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031918)
cdata->handle.MakeWeak(v8::Isolate::GetCurrent(), cdata, _wrap_SwigV8PackedData_delete);
#elif (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION)
#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < SWIGV8_SETWEAK_VERSION)
cdata->handle.MakeWeak(cdata, _wrap_SwigV8PackedData_delete);
#else
cdata->handle.SetWeak(cdata, _wrap_SwigV8PackedData_delete);
// v8::V8::SetWeak(&cdata->handle, cdata, _wrap_SwigV8PackedData_delete);
#endif
#if (SWIG_V8_VERSION < 0x031710)
#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031710)
cdata->handle.MarkIndependent();
#elif (SWIG_V8_VERSION < 0x032100)
#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x032100)
cdata->handle.MarkIndependent(v8::Isolate::GetCurrent());
#else
cdata->handle.MarkIndependent();
@ -600,7 +600,7 @@ v8::Handle<v8::Value> SWIGV8_NewPackedObj(void *data, size_t size, swig_type_inf
SWIGRUNTIME
#if (SWIG_V8_VERSION < 0x031903)
#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031903)
v8::Handle<v8::Value> SWIGV8_AppendOutput(v8::Handle<v8::Value> result, v8::Handle<v8::Value> obj) {
#else
v8::Handle<v8::Value> SWIGV8_AppendOutput(v8::Local<v8::Value> result, v8::Handle<v8::Value> obj) {
@ -610,11 +610,11 @@ v8::Handle<v8::Value> SWIGV8_AppendOutput(v8::Local<v8::Value> result, v8::Handl
if (result->IsUndefined()) {
result = SWIGV8_ARRAY_NEW();
}
#if (SWIG_V8_VERSION < 0x031903)
#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031903)
v8::Handle<v8::Array> arr = v8::Handle<v8::Array>::Cast(result);
#else
v8::Local<v8::Array> arr = v8::Local<v8::Array>::Cast(result);
#endif
#endif
arr->Set(arr->Length(), obj);
SWIGV8_ESCAPE(arr);

View file

@ -5,11 +5,22 @@
// V8 Version Macro
// ----------------
// v8 does not (until now) provide a version macro - which is still discussed and may come soon.
// Until then, we set a default version which can be overridden via command line using V8_VERSION:
// swig -javascript -v8 -DV8_VERSION=0x031110
//
// v8 added version macros V8_MAJOR_VERSION, V8_MINOR_VERSION, V8_BUILD_NUMBER
// and V8_PATCH_LEVEL in version 4.3.0. SWIG generated code uses these if
// they are defined - to support earlier versions you can specify the V8 version
// in use via the command line when you run SWIG:
//
// swig -c++ -javascript -v8 -DV8_VERSION=0x032530 example.i
//
// Or code in the interface file using SWIG_V8_VERSION:
//
// %begin %{#define SWIG_V8_VERSION 0x031110%}
//
// This is specified as a hex constant, but the constant is read as pairs of
// decimal digits, so for V8 3.25.30 use constant 0x032530. This scheme can't
// represent components > 99, but this constant is only useful for V8 < 4.3.0,
// and no V8 versions from that era had a component > 99.
%define %swig_v8_define_version(version)
%insert("runtime") %{

View file

@ -13,7 +13,7 @@ typedef int (*V8ExtensionInitializer) (v8::Handle<v8::Object> module);
// Note: these typedefs and defines are used to deal with v8 API changes since version 3.19.00
#if (SWIG_V8_VERSION < 0x031903)
#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031903)
typedef v8::Handle<v8::Value> SwigV8ReturnValue;
typedef v8::Arguments SwigV8Arguments;
typedef v8::AccessorInfo SwigV8PropertyCallbackInfo;
@ -28,11 +28,11 @@ typedef v8::PropertyCallbackInfo<v8::Value> SwigV8PropertyCallbackInfo;
#endif
#if (SWIG_V8_VERSION < 0x032117)
#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x032117)
#define SWIGV8_HANDLESCOPE() v8::HandleScope scope
#define SWIGV8_HANDLESCOPE_ESC() v8::HandleScope scope
#define SWIGV8_ESCAPE(val) return scope.Close(val)
#elif (SWIG_V8_VERSION < 0x032318)
#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x032318)
#define SWIGV8_HANDLESCOPE() v8::HandleScope scope(v8::Isolate::GetCurrent());
#define SWIGV8_HANDLESCOPE_ESC() v8::HandleScope scope(v8::Isolate::GetCurrent());
#define SWIGV8_ESCAPE(val) return scope.Close(val)
@ -42,7 +42,7 @@ typedef v8::PropertyCallbackInfo<v8::Value> SwigV8PropertyCallbackInfo;
#define SWIGV8_ESCAPE(val) return scope.Escape(val)
#endif
#if (SWIG_V8_VERSION < 0x032318)
#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x032318)
#define SWIGV8_CURRENT_CONTEXT() v8::Context::GetCurrent()
#define SWIGV8_STRING_NEW(str) v8::String::New(str)
#define SWIGV8_FUNCTEMPLATE_NEW(func) v8::FunctionTemplate::New(func)
@ -59,7 +59,7 @@ typedef v8::PropertyCallbackInfo<v8::Value> SwigV8PropertyCallbackInfo;
#endif
#if (SWIG_V8_VERSION < 0x031900)
#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031900)
typedef v8::Persistent<v8::Context> SwigV8Context;
#else
typedef v8::Local<v8::Context> SwigV8Context;
@ -149,9 +149,9 @@ bool V8Shell::RunScript(const std::string &scriptPath) {
context->Exit();
#if (SWIG_V8_VERSION < 0x031710)
#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031710)
context.Dispose();
#elif (SWIG_V8_VERSION < 0x031900)
#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031900)
context.Dispose(v8::Isolate::GetCurrent());
#else
// context.Dispose();
@ -193,9 +193,9 @@ bool V8Shell::RunShell() {
context->Exit();
#if (SWIG_V8_VERSION < 0x031710)
#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031710)
context.Dispose();
#elif (SWIG_V8_VERSION < 0x031900)
#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031900)
context.Dispose(v8::Isolate::GetCurrent());
#else
// context.Dispose();
@ -249,7 +249,7 @@ SwigV8Context V8Shell::CreateShellContext() {
global->Set(SWIGV8_STRING_NEW("require"), SWIGV8_FUNCTEMPLATE_NEW(V8Shell::Require));
global->Set(SWIGV8_STRING_NEW("version"), SWIGV8_FUNCTEMPLATE_NEW(V8Shell::Version));
#if (SWIG_V8_VERSION < 0x031900)
#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031900)
SwigV8Context context = v8::Context::New(NULL, global);
return context;
#else