mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-10-26 21:24:16 +00:00
FS-10435 [mod_v8] Update mod_v8 to support future v8 engine version change
This commit is contained in:
1 parent
3fef65b7c2
commit
ba32e0e23d
5 files changed
+105
-1
No files matched your search
@@ -120,6 +120,9 @@ typedef struct {
|
||||
switch_event_node_t *event_node;
|
||||
set<FSEventHandler *> *event_handlers;
|
||||
char *xml_handler;
|
||||
#if defined(V8_MAJOR_VERSION) && V8_MAJOR_VERSION >=5
|
||||
v8::Platform *v8platform;
|
||||
#endif
|
||||
} mod_v8_global_t;
|
||||
|
||||
static mod_v8_global_t globals = { 0 };
|
||||
@@ -651,12 +654,23 @@ static int v8_parse_and_execute(switch_core_session_t *session, const char *inpu
|
||||
free(path);
|
||||
}
|
||||
// Create a string containing the JavaScript source code.
|
||||
#if defined(V8_MAJOR_VERSION) && V8_MAJOR_VERSION >=5
|
||||
ScriptCompiler::Source *source = new ScriptCompiler::Source(String::NewFromUtf8(isolate, script_data));
|
||||
#else
|
||||
Handle<String> source = String::NewFromUtf8(isolate, script_data);
|
||||
#endif
|
||||
|
||||
TryCatch try_catch;
|
||||
|
||||
// Compile the source code.
|
||||
#if defined(V8_MAJOR_VERSION) && V8_MAJOR_VERSION >=5
|
||||
v8::ScriptCompiler::CompileOptions options = v8::ScriptCompiler::kNoCompileOptions;
|
||||
Handle<v8::Script> v8_script = v8::ScriptCompiler::Compile(context, source, options).ToLocalChecked();
|
||||
//Handle<v8::Script> v8_script = v8::ScriptCompiler::Compile(context, source,/* String::NewFromUtf8(isolate, script_file),*/ v8::ScriptCompiler::kProduceCodeCache).ToLocalChecked();
|
||||
//source->GetCachedData();
|
||||
#else
|
||||
Handle<Script> v8_script = Script::Compile(source, Local<Value>::New(isolate, String::NewFromUtf8(isolate, script_file)));
|
||||
#endif
|
||||
|
||||
if (try_catch.HasCaught()) {
|
||||
v8_error(isolate, &try_catch);
|
||||
@@ -1007,7 +1021,12 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_v8_load)
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
#if defined(V8_MAJOR_VERSION) && V8_MAJOR_VERSION >=5
|
||||
globals.v8platform = NULL;
|
||||
JSMain::Initialize(&globals.v8platform);
|
||||
#else
|
||||
JSMain::Initialize();
|
||||
#endif
|
||||
|
||||
/* Make all "built in" modules available to load on demand */
|
||||
v8_mod_init_built_in(FSCoreDB::GetModuleInterface());
|
||||
@@ -1045,6 +1064,10 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_v8_shutdown)
|
||||
delete globals.event_handlers;
|
||||
switch_mutex_destroy(globals.event_mutex);
|
||||
|
||||
#if defined(V8_MAJOR_VERSION) && V8_MAJOR_VERSION >=5
|
||||
delete globals.v8platform;
|
||||
#endif
|
||||
|
||||
switch_core_hash_destroy(&module_manager.load_hash);
|
||||
switch_core_destroy_memory_pool(&module_manager.pool);
|
||||
|
||||
|
||||
Reference in new issue
Block a user