This is work in progress, the javascript plugin does not yet compile.
Compatibility with old v8 lib will be added later, for now I'm focused on
compiling the plugin with v8 version 6.8.
set(V8_INC_PATHS
/usr/include
+ /usr/include/v8
${CMAKE_INCLUDE_PATH}
)
find_path(V8_INCLUDE_DIR v8.h PATHS ${V8_INC_PATHS})
#define API_DEF_FUNC(__name) \
weechat_obj->Set( \
- v8::String::New(#__name), \
+ v8::String::NewFromUtf8(isolate, #__name), \
v8::FunctionTemplate::New(weechat_js_api_##__name));
#define API_DEF_CONST_INT(__name) \
- weechat_obj->Set(v8::String::New(#__name), \
- v8::Integer::New(__name));
+ weechat_obj->Set(v8::String::NewFromUtf8(#__name), \
+ v8::Integer::NewFromUtf8(__name));
#define API_DEF_CONST_STR(__name) \
- weechat_obj->Set(v8::String::New(#__name), \
- v8::String::New(__name));
+ weechat_obj->Set(v8::String::NewFromUtf8(#__name), \
+ v8::String::NewFromUtf8(__name));
#define API_FUNC(__name) \
static v8::Handle<v8::Value> \
weechat_js_api_##__name(const v8::Arguments &args)
#define API_RETURN_OK return v8::True();
#define API_RETURN_ERROR return v8::False();
#define API_RETURN_EMPTY \
- return v8::String::New("");
+ return v8::String::NewFromUtf8("");
#define API_RETURN_STRING(__string) \
if (__string) \
- return v8::String::New(__string); \
- return v8::String::New("")
+ return v8::String::NewFromUtf8(__string); \
+ return v8::String::NewFromUtf8("")
#define API_RETURN_STRING_FREE(__string) \
if (__string) \
{ \
- v8::Handle<v8::Value> return_value = v8::String::New(__string); \
+ v8::Handle<v8::Value> return_value = \
+ v8::String::NewFromUtf8(__string); \
free ((void *)__string); \
return return_value; \
} \
- return v8::String::New("")
+ return v8::String::NewFromUtf8("")
#define API_RETURN_INT(__int) \
return v8::Integer::New(__int)
#define API_RETURN_LONG(__int) \
WeechatJsV8::loadLibs()
{
v8::Local<v8::ObjectTemplate> weechat_obj = v8::ObjectTemplate::New();
+ v8::Isolate* isolate = v8::Isolate::GetCurrent();
/* constants */
API_DEF_CONST_INT(WEECHAT_RC_OK);
WeechatJsV8::WeechatJsV8()
{
- this->global = ObjectTemplate::New();
+ v8::Isolate* isolate = v8::Isolate::GetCurrent();
+
+ this->global = ObjectTemplate::New(isolate);
}
/*
bool
WeechatJsV8::load(const char *source)
{
- Handle<String> src = String::New(source);
+ v8::Isolate* isolate = v8::Isolate::GetCurrent();
+
+ Handle<String> src = String::NewFromUtf8(isolate, source);
return this->load(src);
}
bool
WeechatJsV8::execScript()
{
- v8::TryCatch trycatch;
+ v8::Isolate* isolate = v8::Isolate::GetCurrent();
+ v8::TryCatch trycatch(isolate);
this->context = Context::New(NULL, this->global);
Context::Scope context_scope(this->context);
Context::Scope context_scope(this->context);
Handle<Object> global = this->context->Global();
- Handle<Value> value = global->Get(String::New(function));
+ v8::Isolate* isolate = v8::Isolate::GetCurrent();
+ Handle<Value> value = global->Get(String::NewFromUtf8(isolate, function));
return value->IsFunction();
}
Handle<Value>
WeechatJsV8::execFunction(const char *function, int argc, Handle<Value> *argv)
{
- v8::TryCatch trycatch;
+ v8::Isolate* isolate = v8::Isolate::GetCurrent();
+ v8::TryCatch trycatch(isolate);
Context::Scope context_scope(this->context);
Handle<Object> global = this->context->Global();
- Handle<Value> value = global->Get(String::New(function));
+ Handle<Value> value = global->Get(String::NewFromUtf8(isolate, function));
Handle<Function> func = Handle<Function>::Cast(value);
Handle<Value> res = func->Call(global, argc, argv);
void
WeechatJsV8::addGlobal(const char *key, Handle<Template> val)
{
- this->addGlobal(String::New(key), val);
+ v8::Isolate* isolate = v8::Isolate::GetCurrent();
+
+ this->addGlobal(String::NewFromUtf8(isolate, key), val);
}
/* make C++ compiler happy */
(void) hashtable;
+ v8::Isolate* isolate = v8::Isolate::GetCurrent();
v8::Handle<v8::Object> *obj = (v8::Handle<v8::Object> *)data;
- (*obj)->Set(v8::String::New(key), v8::String::New(value));
+ (*obj)->Set(v8::String::NewFromUtf8(isolate, key),
+ v8::String::NewFromUtf8(isolate, value));
}
/*
v8::Handle<v8::Object>
weechat_js_hashtable_to_object (struct t_hashtable *hashtable)
{
- v8::Handle<v8::Object> obj = v8::Object::New();
+ v8::Isolate* isolate = v8::Isolate::GetCurrent();
+ v8::Handle<v8::Object> obj = v8::Object::New(isolate);
weechat_hashtable_map_string (hashtable,
&weechat_js_hashtable_map_cb,
ret_value = NULL;
+ v8::Isolate* isolate = v8::Isolate::GetCurrent();
+
old_js_current_script = js_current_script;
js_current_script = script;
js_v8 = (WeechatJsV8 *)(script->interpreter);
switch (format[i])
{
case 's': /* string */
- argv2[i] = v8::String::New((const char *)argv[i]);
+ argv2[i] = v8::String::NewFromUtf8(isolate,
+ (const char *)argv[i]);
break;
case 'i': /* integer */
- argv2[i] = v8::Integer::New(*((int *)argv[i]));
+ argv2[i] = v8::Integer::New(isolate, *((int *)argv[i]));
break;
case 'h': /* hash */
argv2[i] = weechat_js_hashtable_to_object (