]> git.ipfire.org Git - thirdparty/freeswitch.git/commitdiff
Revert "FS-11048: [build] support v8 6.6 fixes from Andrey Volk"
authorMike Jerris <mike@jerris.com>
Thu, 3 May 2018 21:19:22 +0000 (17:19 -0400)
committerMuteesa Fred <muteesafred@hotmail.com>
Tue, 24 Jul 2018 07:21:52 +0000 (07:21 +0000)
This reverts commit 27389f29377f84a4bee2625053cba64255980409.

src/mod/languages/mod_v8/include/javascript.hpp
src/mod/languages/mod_v8/mod_v8.cpp
src/mod/languages/mod_v8/src/jsbase.cpp
src/mod/languages/mod_v8/src/jsmain.cpp

index a080a508deeeb6ef42d47079ae1898582dec8906..5650ad18e1a1c024f1f755bc03b2ec7c692c5be0 100644 (file)
 
 /* Macro for basic script state check (to know if the script is being terminated), should be called before calling any callback actual code */
 #define JS_CHECK_SCRIPT_STATE() \
-       if (info.GetIsolate()->IsExecutionTerminating()) return;\
+       if (v8::V8::IsExecutionTerminating(info.GetIsolate())) return;\
        if (JSMain::GetScriptInstanceFromIsolate(info.GetIsolate()) && JSMain::GetScriptInstanceFromIsolate(info.GetIsolate())->GetForcedTermination()) return
 
 /* Macro for easy unlocking an isolate on a long running c call */
index 9d1d8a9b91f73f6967dae7d5426631a0caefe31b..636b93e5aca0b77b41225a0970a938356237862b 100644 (file)
@@ -645,7 +645,7 @@ static int v8_parse_and_execute(switch_core_session_t *session, const char *inpu
                        isolate->SetData(0, js);
 
                        // New global template
-                       Handle<ObjectTemplate> global = ObjectTemplate::New(isolate);
+                       Handle<ObjectTemplate> global = ObjectTemplate::New();
 
                        if (global.IsEmpty()) {
                                switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Failed to create JS global object template\n");
@@ -793,7 +793,7 @@ static int v8_parse_and_execute(switch_core_session_t *session, const char *inpu
                                                        free(path);
                                                }
 
-                                               TryCatch try_catch(isolate);
+                                               TryCatch try_catch;
 
                                                // Compile the source code.
 #if defined(V8_MAJOR_VERSION) && V8_MAJOR_VERSION >=5
index 9e8b2032a5c501a3d91b9f1eae4c4b2f0fc118bf..4fd320f4397af15263003347d35045c2e36e411c 100644 (file)
@@ -153,9 +153,17 @@ void JSBase::CreateInstance(const v8::FunctionCallbackInfo<Value>& args)
                autoDestroy = args[1]->BooleanValue();
        } else {
                // Create a new C++ instance
-#if defined(V8_MAJOR_VERSION) && V8_MAJOR_VERSION >=6 
-               Handle<External> ex = Handle<External>::Cast(args.Data());
-#else 
+#if defined(V8_MAJOR_VERSION) && V8_MAJOR_VERSION >=5
+               Isolate *isolate = args.GetIsolate();
+               v8::Local<v8::Context> context = isolate->GetCurrentContext();
+               v8::Local<v8::String> key = String::NewFromUtf8(isolate, "constructor_method");
+               v8::Local<v8::Private> privateKey = v8::Private::ForApi(isolate, key);
+               Handle<External> ex;
+               v8::MaybeLocal<v8::Value> hiddenValue = args.Callee()->GetPrivate(context, privateKey);
+               if (!hiddenValue.IsEmpty()) {
+                       ex = Handle<External>::Cast(hiddenValue.ToLocalChecked());
+               }
+#else
                Handle<External> ex = Handle<External>::Cast(args.Callee()->GetHiddenValue(String::NewFromUtf8(args.GetIsolate(), "constructor_method")));
 #endif
 
@@ -224,14 +232,13 @@ void JSBase::Register(Isolate *isolate, const js_class_definition_t *desc)
 void JSBase::RegisterInstance(Isolate *isolate, string name, bool autoDestroy)
 {
        // Get the context's global scope (that's where we'll put the constructor)
-       Local<Context> context = isolate->GetCurrentContext();
-       Handle<Object> global = context->Global();
+       Handle<Object> global = isolate->GetCurrentContext()->Global();
 
        Local<Function> func = Local<Function>::Cast(global->Get(v8::String::NewFromUtf8(isolate, this->GetJSClassName().c_str())));
 
        // Add the C++ instance as an argument, so it won't try to create another one.
        Handle<Value> args[] = { External::New(isolate, this), Boolean::New(isolate, autoDestroy) };
-       Handle<Object> newObj = func->NewInstance(context, 2, args).ToLocalChecked();
+       Handle<Object> newObj = func->NewInstance(2, args);
 
        // Add the instance to JavaScript.
        if (name.size() > 0) {
index 86fed7b27f3cce377cf14ca4104714bc494a9a75..e162460df2c630db72b38d0b9e65f1dc29f2c5a2 100644 (file)
@@ -209,7 +209,7 @@ const string JSMain::GetExceptionInfo(Isolate* isolate, TryCatch* try_catch)
                        ss << " ";
                }
 
-               int32_t end = message->GetEndColumn(isolate->GetCurrentContext()).FromMaybe(0);
+               int end = message->GetEndColumn();
 
                for (int i = start; i < end; i++) {
                        ss << "^";
@@ -292,7 +292,7 @@ const string JSMain::ExecuteString(const string& scriptData, const string& fileN
 
                        isolate->SetData(0, this);
 
-                       Handle<ObjectTemplate> global = ObjectTemplate::New(isolate);
+                       Handle<ObjectTemplate> global = ObjectTemplate::New();
                        global->Set(String::NewFromUtf8(isolate, "include"), FunctionTemplate::New(isolate, Include));
                        global->Set(String::NewFromUtf8(isolate, "require"), FunctionTemplate::New(isolate, Include));
                        global->Set(String::NewFromUtf8(isolate, "log"), FunctionTemplate::New(isolate, Log));
@@ -323,7 +323,7 @@ const string JSMain::ExecuteString(const string& scriptData, const string& fileN
                                inst->obj->RegisterInstance(isolate, inst->name, inst->auto_destroy);
                        }
 
-                       TryCatch try_catch(isolate);
+                       TryCatch try_catch;
 
                        // Compile the source code.
 #if defined(V8_MAJOR_VERSION) && V8_MAJOR_VERSION >=5
@@ -583,7 +583,7 @@ void JSMain::ExitScript(Isolate *isolate, const char *msg)
                js->forcedTerminationScriptFile = GetStackInfo(isolate, &js->forcedTerminationLineNumber);
        }
 
-       isolate->TerminateExecution();
+       V8::TerminateExecution(isolate);
 }
 
 char *JSMain::GetStackInfo(Isolate *isolate, int *lineNumber)