Fixes for v8 3.21.17 (0x032117)

This commit is contained in:
Richard 2014-08-12 23:05:14 -05:00
commit e98a659246
6 changed files with 190 additions and 25 deletions

View file

@ -9,7 +9,12 @@
%fragment("js_ctor", "templates") %{
SwigV8ReturnValue $jswrapper(const SwigV8Arguments& args) {
#if (SWIG_V8_VERSION < 0x032117)
v8::HandleScope scope;
#else
v8::HandleScope scope(v8::Isolate::GetCurrent());
#endif
v8::Handle<v8::Object> self = args.Holder();
$jslocals
if(args.Length() != $jsargcount) SWIG_exception_fail(SWIG_ERROR, "Illegal number of arguments for $jswrapper.");
@ -32,7 +37,12 @@ fail:
%fragment ("js_veto_ctor", "templates")
%{
SwigV8ReturnValue $jswrapper(const SwigV8Arguments& args) {
#if (SWIG_V8_VERSION < 0x032117)
v8::HandleScope scope;
#else
v8::HandleScope scope(v8::Isolate::GetCurrent());
#endif
SWIG_exception(SWIG_ERROR, "Class $jsname can not be instantiated");
SWIGV8_RETURN(v8::Undefined());
}
@ -47,7 +57,12 @@ SwigV8ReturnValue $jswrapper(const SwigV8Arguments& args) {
%fragment ("js_ctor_dispatcher", "templates")
%{
SwigV8ReturnValue $jswrapper(const SwigV8Arguments& args) {
#if (SWIG_V8_VERSION < 0x032117)
v8::HandleScope scope;
#else
v8::HandleScope scope(v8::Isolate::GetCurrent());
#endif
OverloadErrorHandler errorHandler;
v8::Handle<v8::Value> self;
@ -72,7 +87,12 @@ fail:
* ----------------------------------------------------------------------------- */
%fragment("js_overloaded_ctor", "templates") %{
SwigV8ReturnValue $jswrapper(const SwigV8Arguments& args, V8ErrorHandler& SWIGV8_ErrorHandler) {
#if (SWIG_V8_VERSION < 0x032117)
v8::HandleScope scope;
#else
v8::HandleScope scope(v8::Isolate::GetCurrent());
#endif
v8::Handle<v8::Object> self = args.Holder();
$jslocals
if(args.Length() != $jsargcount) SWIG_exception_fail(SWIG_ERROR, "Illegal number of arguments for $jswrapper.");
@ -201,7 +221,12 @@ void $jswrapper(v8::Isolate *isolate, v8::Persistent< v8::Object > * object, SWI
%fragment("js_getter", "templates")
%{
SwigV8ReturnValue $jswrapper(v8::Local<v8::String> property, const SwigV8PropertyCallbackInfo& info) {
#if (SWIG_V8_VERSION < 0x032117)
v8::HandleScope scope;
#else
v8::HandleScope scope(v8::Isolate::GetCurrent());
#endif
v8::Handle<v8::Value> jsresult;
$jslocals
$jscode
@ -223,7 +248,12 @@ fail:
%{
void $jswrapper(v8::Local<v8::String> property, v8::Local<v8::Value> value,
const SwigV8PropertyCallbackInfoVoid& info) {
#if (SWIG_V8_VERSION < 0x032117)
v8::HandleScope scope;
#else
v8::HandleScope scope(v8::Isolate::GetCurrent());
#endif
$jslocals
$jscode
goto fail;
@ -241,7 +271,12 @@ fail:
%fragment("js_function", "templates")
%{
SwigV8ReturnValue $jswrapper(const SwigV8Arguments& args) {
#if (SWIG_V8_VERSION < 0x032117)
v8::HandleScope scope;
#else
v8::HandleScope scope(v8::Isolate::GetCurrent());
#endif
v8::Handle<v8::Value> jsresult;
$jslocals
if(args.Length() != $jsargcount) SWIG_exception_fail(SWIG_ERROR, "Illegal number of arguments for $jswrapper.");
@ -265,7 +300,12 @@ fail:
%fragment("js_function_dispatcher", "templates")
%{
SwigV8ReturnValue $jswrapper(const SwigV8Arguments& args) {
#if (SWIG_V8_VERSION < 0x032117)
v8::HandleScope scope;
#else
v8::HandleScope scope(v8::Isolate::GetCurrent());
#endif
v8::Handle<v8::Value> jsresult;
OverloadErrorHandler errorHandler;
$jscode
@ -288,7 +328,12 @@ fail:
%{
SwigV8ReturnValue $jswrapper(const SwigV8Arguments& args, V8ErrorHandler& SWIGV8_ErrorHandler)
{
#if (SWIG_V8_VERSION < 0x032117)
v8::HandleScope scope;
#else
v8::HandleScope scope(v8::Isolate::GetCurrent());
#endif
v8::Handle<v8::Value> jsresult;
$jslocals
$jscode

View file

@ -15,7 +15,12 @@
SWIGINTERNINLINE v8::Handle<v8::Value>
SWIG_From_dec(Type)(%ifcplusplus(const Type&, Type) c)
{
#if (SWIG_V8_VERSION < 0x032117)
v8::HandleScope scope;
#else
v8::HandleScope scope(v8::Isolate::GetCurrent());
#endif
v8::Local<v8::Array> vals = v8::Array::New(2);
vals->Set(0, SWIG_From(double)(Real(c)));
@ -33,7 +38,11 @@ SWIG_From_dec(Type)(%ifcplusplus(const Type&, Type) c)
SWIGINTERN int
SWIG_AsVal_dec(Type) (v8::Handle<v8::Value> o, Type* val)
{
#if (SWIG_V8_VERSION < 0x032117)
v8::HandleScope scope;
#else
v8::HandleScope scope(v8::Isolate::GetCurrent());
#endif
if (o->IsArray()) {
v8::Handle<v8::Array> array = v8::Handle<v8::Array>::Cast(o);
@ -75,7 +84,11 @@ SWIG_AsVal_dec(Type) (v8::Handle<v8::Value> o, Type* val)
SWIGINTERN int
SWIG_AsVal_dec(Type) (v8::Handle<v8::Value> o, Type* val)
{
#if (SWIG_V8_VERSION < 0x032117)
v8::HandleScope scope;
#else
v8::HandleScope scope(v8::Isolate::GetCurrent());
#endif
if (o->IsArray()) {
v8::Handle<v8::Array> array = v8::Handle<v8::Array>::Cast(o);

View file

@ -17,7 +17,12 @@ typedef v8::PropertyCallbackInfo<void> SwigV8PropertyCallbackInfoVoid;
* Creates a class template for a class with specified initialization function.
*/
SWIGRUNTIME v8::Handle<v8::FunctionTemplate> SWIGV8_CreateClassTemplate(const char* symbol) {
#if (SWIG_V8_VERSION < 0x032117)
v8::HandleScope scope;
#else
v8::HandleScope scope(v8::Isolate::GetCurrent());
#endif
v8::Local<v8::FunctionTemplate> class_templ = v8::FunctionTemplate::New();
class_templ->SetClassName(v8::String::NewSymbol(symbol));

View file

@ -61,7 +61,12 @@ void SWIGV8_INIT (v8::Handle<v8::Object> exports, v8::Handle<v8::Object> /*modul
{
SWIG_InitializeModule(static_cast<void *>(&exports));
#if (SWIG_V8_VERSION < 0x032117)
v8::HandleScope scope;
#else
v8::HandleScope scope(v8::Isolate::GetCurrent());
#endif
v8::Handle<v8::Object> exports_obj = exports;
%}

View file

@ -117,7 +117,11 @@ public:
v8::Persistent<v8::FunctionTemplate> SWIGV8_SWIGTYPE_Proxy_class_templ;
int SWIG_V8_ConvertInstancePtr(v8::Handle<v8::Object> objRef, void** ptr, swig_type_info *info, int flags) {
#if (SWIG_V8_VERSION < 0x032117)
v8::HandleScope scope;
#else
v8::HandleScope scope(v8::Isolate::GetCurrent());
#endif
if(objRef->InternalFieldCount() < 1) return SWIG_ERROR;
@ -239,7 +243,12 @@ void SWIGV8_SetPrivateData(v8::Handle<v8::Object> obj, void* ptr, swig_type_info
}
int SWIG_V8_ConvertPtr(v8::Handle<v8::Value> valRef, void** ptr, swig_type_info *info, int flags) {
#if (SWIG_V8_VERSION < 0x032117)
v8::HandleScope scope;
#else
v8::HandleScope scope(v8::Isolate::GetCurrent());
#endif
/* special case: JavaScript null => C NULL pointer */
if(valRef->IsNull()) {
*ptr=0;
@ -253,7 +262,12 @@ int SWIG_V8_ConvertPtr(v8::Handle<v8::Value> valRef, void** ptr, swig_type_info
}
v8::Handle<v8::Value> SWIG_V8_NewPointerObj(void *ptr, swig_type_info *info, int flags) {
#if (SWIG_V8_VERSION < 0x032117)
v8::HandleScope scope;
#else
v8::HandleScope scope(v8::Isolate::GetCurrent());
#endif
v8::Handle<v8::FunctionTemplate> class_templ;
if (ptr == NULL) {
@ -293,12 +307,14 @@ v8::Handle<v8::Value> SWIG_V8_NewPointerObj(void *ptr, swig_type_info *info, int
#define SWIG_GetInstancePtr(obj, ptr) SWIG_V8_GetInstancePtr(obj, ptr)
#if (SWIG_V8_VERSION < 0x031903)
v8::Handle<v8::Value> _SWIGV8_wrap_equals(const v8::Arguments &args) {
#else
void _SWIGV8_wrap_equals(const v8::FunctionCallbackInfo<v8::Value>& args) {
#endif
SwigV8ReturnValue _SWIGV8_wrap_equals(const SwigV8Arguments &args) {
#if (SWIG_V8_VERSION < 0x032117)
v8::HandleScope scope;
#else
v8::HandleScope scope(v8::Isolate::GetCurrent());
#endif
v8::Handle<v8::Value> jsresult;
void *arg1 = (void *) 0 ;
void *arg2 = (void *) 0 ;
@ -326,12 +342,14 @@ fail:
SWIGV8_RETURN(v8::Undefined());
}
#if (SWIG_V8_VERSION < 0x031903)
v8::Handle<v8::Value> _wrap_getCPtr(const v8::Arguments &args) {
#else
void _wrap_getCPtr(const v8::FunctionCallbackInfo<v8::Value>& args) {
#endif
SwigV8ReturnValue _wrap_getCPtr(const SwigV8Arguments &args) {
#if (SWIG_V8_VERSION < 0x032117)
v8::HandleScope scope;
#else
v8::HandleScope scope(v8::Isolate::GetCurrent());
#endif
v8::Handle<v8::Value> jsresult;
void *arg1 = (void *) 0 ;
long result;
@ -372,7 +390,13 @@ public:
SWIGRUNTIMEINLINE
int SwigV8Packed_Check(v8::Handle<v8::Value> valRef) {
#if (SWIG_V8_VERSION < 0x032117)
v8::HandleScope scope;
#else
v8::HandleScope scope(v8::Isolate::GetCurrent());
#endif
v8::Handle<v8::Object> objRef = valRef->ToObject();
if(objRef->InternalFieldCount() < 1) return false;
v8::Handle<v8::Value> flag = objRef->GetHiddenValue(v8::String::New("__swig__packed_data__"));
@ -382,7 +406,13 @@ int SwigV8Packed_Check(v8::Handle<v8::Value> valRef) {
SWIGRUNTIME
swig_type_info* SwigV8Packed_UnpackData(v8::Handle<v8::Value> valRef, void *ptr, size_t size) {
if (SwigV8Packed_Check(valRef)) {
#if (SWIG_V8_VERSION < 0x032117)
v8::HandleScope scope;
#else
v8::HandleScope scope(v8::Isolate::GetCurrent());
#endif
SwigV8PackedData *sobj;
v8::Handle<v8::Object> objRef = valRef->ToObject();
@ -445,7 +475,11 @@ void _wrap_SwigV8PackedData_delete(v8::Isolate *isolate, v8::Persistent< v8::Obj
SWIGRUNTIME
v8::Handle<v8::Value> SWIGV8_NewPackedObj(void *data, size_t size, swig_type_info *type) {
#if (SWIG_V8_VERSION < 0x032117)
v8::HandleScope scope;
#else
v8::HandleScope scope(v8::Isolate::GetCurrent());
#endif
SwigV8PackedData* cdata = new SwigV8PackedData(data, size, type);
v8::Handle<v8::Object> obj = v8::Object::New();
@ -497,7 +531,12 @@ v8::Handle<v8::Value> SWIGV8_NewPackedObj(void *data, size_t size, swig_type_inf
SWIGRUNTIME
v8::Handle<v8::Value> SWIGV8_AppendOutput(v8::Handle<v8::Value> result, v8::Handle<v8::Value> obj) {
#if (SWIG_V8_VERSION < 0x032117)
v8::HandleScope scope;
#else
v8::HandleScope scope(v8::Isolate::GetCurrent());
#endif
if (result->IsUndefined()) {
result = v8::Array::New();
}

View file

@ -11,6 +11,22 @@
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 (V8_VERSION < 0x031903)
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) args.GetReturnValue().Set(val); return
#define SWIGV8_RETURN_INFO(val, info) info.GetReturnValue().Set(val); return
#endif
class V8Shell: public JSShell {
public:
@ -43,13 +59,13 @@ private:
void ReportException(v8::TryCatch* handler);
static v8::Handle<v8::Value> Print(const v8::Arguments& args);
static SwigV8ReturnValue Print(const SwigV8Arguments& args);
static v8::Handle<v8::Value> Require(const v8::Arguments& args);
static SwigV8ReturnValue Require(const SwigV8Arguments& args);
static v8::Handle<v8::Value> Quit(const v8::Arguments& args);
static SwigV8ReturnValue Quit(const SwigV8Arguments& args);
static v8::Handle<v8::Value> Version(const v8::Arguments& args);
static SwigV8ReturnValue Version(const SwigV8Arguments& args);
static const char* ToCString(const v8::String::Utf8Value& value);
@ -69,7 +85,11 @@ V8Shell::~V8Shell() {}
bool V8Shell::RunScript(const std::string& scriptPath) {
std::string source = ReadFile(scriptPath);
#if (V8_VERSION < 0x032117)
v8::HandleScope scope;
#else
v8::HandleScope scope(v8::Isolate::GetCurrent());
#endif
#if (V8_VERSION < 0x031900)
v8::Persistent<v8::Context> context = CreateShellContext();
@ -113,7 +133,12 @@ bool V8Shell::RunScript(const std::string& scriptPath) {
}
bool V8Shell::RunShell() {
#if (V8_VERSION < 0x032117)
v8::HandleScope scope;
#else
v8::HandleScope scope(v8::Isolate::GetCurrent());
#endif
#if (V8_VERSION < 0x031900)
v8::Persistent<v8::Context> context = CreateShellContext();
@ -166,7 +191,13 @@ bool V8Shell::InitializeEngine() {
}
bool V8Shell::ExecuteScript(const std::string& source, const std::string& name) {
v8::HandleScope handle_scope;
#if (V8_VERSION < 0x032117)
v8::HandleScope scope;
#else
v8::HandleScope scope(v8::Isolate::GetCurrent());
#endif
v8::TryCatch try_catch;
v8::Handle<v8::Script> script = v8::Script::Compile(v8::String::New(source.c_str()), v8::String::New(name.c_str()));
@ -197,7 +228,12 @@ v8::Persistent<v8::Context> V8Shell::CreateShellContext() {
#else
v8::Local<v8::Context> V8Shell::CreateShellContext() {
#endif
#if (V8_VERSION < 0x032117)
v8::HandleScope scope;
#else
v8::HandleScope scope(v8::Isolate::GetCurrent());
#endif
// Create a template for the global object.
v8::Handle<v8::ObjectTemplate> global = v8::ObjectTemplate::New();
@ -224,7 +260,12 @@ v8::Local<v8::Context> V8Shell::CreateShellContext() {
v8::Handle<v8::Value> V8Shell::Import(const std::string& module_path)
{
#if (V8_VERSION < 0x032117)
v8::HandleScope scope;
#else
v8::HandleScope scope(v8::Isolate::GetCurrent());
#endif
HANDLE library;
std::string module_name = LoadModule(module_path, &library);
@ -243,10 +284,16 @@ v8::Handle<v8::Value> V8Shell::Import(const std::string& module_path)
return scope.Close(module);
}
v8::Handle<v8::Value> V8Shell::Print(const v8::Arguments& args) {
SwigV8ReturnValue V8Shell::Print(const SwigV8Arguments& args) {
bool first = true;
for (int i = 0; i < args.Length(); i++) {
v8::HandleScope handle_scope;
#if (V8_VERSION < 0x032117)
v8::HandleScope scope;
#else
v8::HandleScope scope(v8::Isolate::GetCurrent());
#endif
if (first) {
first = false;
} else {
@ -258,11 +305,16 @@ v8::Handle<v8::Value> V8Shell::Print(const v8::Arguments& args) {
}
printf("\n");
fflush(stdout);
return v8::Undefined();
SWIGV8_RETURN(v8::Undefined());
}
v8::Handle<v8::Value> V8Shell::Require(const v8::Arguments& args) {
SwigV8ReturnValue V8Shell::Require(const SwigV8Arguments& args) {
#if (V8_VERSION < 0x032117)
v8::HandleScope scope;
#else
v8::HandleScope scope(v8::Isolate::GetCurrent());
#endif
if (args.Length() != 1) {
printf("Illegal arguments for `require`");
@ -279,23 +331,29 @@ v8::Handle<v8::Value> V8Shell::Require(const v8::Arguments& args) {
v8::Handle<v8::Value> module = _this->Import(moduleName);
return scope.Close(module);
SWIGV8_RETURN(module);
}
v8::Handle<v8::Value> V8Shell::Quit(const v8::Arguments& args) {
SwigV8ReturnValue V8Shell::Quit(const SwigV8Arguments& args) {
int exit_code = args[0]->Int32Value();
fflush(stdout);
fflush(stderr);
exit(exit_code);
return v8::Undefined();
SWIGV8_RETURN(v8::Undefined());
}
v8::Handle<v8::Value> V8Shell::Version(const v8::Arguments& args) {
return v8::String::New(v8::V8::GetVersion());
SwigV8ReturnValue V8Shell::Version(const SwigV8Arguments& args) {
SWIGV8_RETURN(v8::String::New(v8::V8::GetVersion()));
}
void V8Shell::ReportException(v8::TryCatch* try_catch) {
v8::HandleScope handle_scope;
#if (V8_VERSION < 0x032117)
v8::HandleScope scope;
#else
v8::HandleScope scope(v8::Isolate::GetCurrent());
#endif
v8::String::Utf8Value exception(try_catch->Exception());
const char* exception_string = V8Shell::ToCString(exception);
v8::Handle<v8::Message> message = try_catch->Message();