JS Example Campatibility Update
This commit is contained in:
parent
f16350e774
commit
19d284a896
1 changed files with 18 additions and 6 deletions
|
|
@ -7,16 +7,28 @@
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
|
||||||
#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031903)
|
#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x031903)
|
||||||
# define V8_RETURN(val) return scope.Close(val)
|
typedef v8::Handle<v8::Value> V8ReturnValue;
|
||||||
|
typedef v8::Arguments V8Arguments;
|
||||||
|
# define V8_RETURN(val) return scope.Close(val)
|
||||||
#else
|
#else
|
||||||
# define V8_RETURN(val) args.GetReturnValue().Set(val); return
|
typedef void V8ReturnValue;
|
||||||
|
typedef v8::FunctionCallbackInfo<v8::Value> V8Arguments;
|
||||||
|
# define V8_RETURN(val) args.GetReturnValue().Set(val); return
|
||||||
#endif
|
#endif
|
||||||
#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x032318)
|
#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x032318)
|
||||||
# define V8_UNDEFINED() v8::Undefined()
|
# define V8_UNDEFINED() v8::Undefined()
|
||||||
#else
|
#else
|
||||||
# define V8_UNDEFINED() v8::Undefined(v8::Isolate::GetCurrent())
|
# define V8_UNDEFINED() v8::Undefined(v8::Isolate::GetCurrent())
|
||||||
#endif
|
#endif
|
||||||
|
#if (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x032117)
|
||||||
|
# define V8_HANDLESCOPE() v8::HandleScope scope
|
||||||
|
#elif (V8_MAJOR_VERSION-0) < 4 && (SWIG_V8_VERSION < 0x032224)
|
||||||
|
# define V8_HANDLESCOPE() v8::HandleScope scope(v8::Isolate::GetCurrent());
|
||||||
|
#else
|
||||||
|
# define V8_HANDLESCOPE() v8::HandleScope scope(v8::Isolate::GetCurrent());
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
// 'unused' attribute only necessary for GNUC < v3.4
|
// 'unused' attribute only necessary for GNUC < v3.4
|
||||||
|
|
@ -44,8 +56,8 @@ static void work_async(uv_work_t* request) {
|
||||||
|
|
||||||
// send async result back to node's thread
|
// send async result back to node's thread
|
||||||
static void work_complete(uv_work_t* request, int status) {
|
static void work_complete(uv_work_t* request, int status) {
|
||||||
|
V8_HANDLESCOPE();
|
||||||
v8::Isolate* iso = v8::Isolate::GetCurrent();
|
v8::Isolate* iso = v8::Isolate::GetCurrent();
|
||||||
v8::HandleScope scope(iso);
|
|
||||||
worker_packet* packet = static_cast<worker_packet*>(request->data);
|
worker_packet* packet = static_cast<worker_packet*>(request->data);
|
||||||
const int argc = 1;
|
const int argc = 1;
|
||||||
v8::Handle<v8::Value> argv[] = {
|
v8::Handle<v8::Value> argv[] = {
|
||||||
|
|
@ -58,7 +70,7 @@ static void work_complete(uv_work_t* request, int status) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void entry(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
static void entry(const V8Arguments& args) {
|
||||||
v8::Isolate* iso = v8::Isolate::GetCurrent();
|
v8::Isolate* iso = v8::Isolate::GetCurrent();
|
||||||
v8::Local<v8::Value> value = args[0];
|
v8::Local<v8::Value> value = args[0];
|
||||||
if (!value->IsFunction()) {
|
if (!value->IsFunction()) {
|
||||||
|
|
@ -76,8 +88,8 @@ static void entry(const v8::FunctionCallbackInfo<v8::Value>& args) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void JavaScript_exampleV8_callback_function(const v8::Arguments& args) {
|
V8ReturnValue JavaScript_exampleV8_callback_function(const V8Arguments& args) {
|
||||||
v8::HandleScope scope
|
V8_HANDLESCOPE();
|
||||||
if (args.Length() != 1) {
|
if (args.Length() != 1) {
|
||||||
V8_ErrorHandler.error((-1), "Illegal number of arguments.");
|
V8_ErrorHandler.error((-1), "Illegal number of arguments.");
|
||||||
V8_RETURN(V8_UNDEFINED());
|
V8_RETURN(V8_UNDEFINED());
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue