当前位置: 首页>>代码示例>>C++>>正文


C++ Isolate::GetCurrentContext方法代码示例

本文整理汇总了C++中Isolate::GetCurrentContext方法的典型用法代码示例。如果您正苦于以下问题:C++ Isolate::GetCurrentContext方法的具体用法?C++ Isolate::GetCurrentContext怎么用?C++ Isolate::GetCurrentContext使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Isolate的用法示例。


在下文中一共展示了Isolate::GetCurrentContext方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: jsCreateMyClass

void jsCreateMyClass(const FunctionCallbackInfo<Value>& args)
{
	if (args.Length() != 1)
	{
		args.GetIsolate()->ThrowException(
			String::NewFromUtf8(args.GetIsolate(), "Bad parameters",
			NewStringType::kNormal).ToLocalChecked());
		return;
	}

	Isolate* isolate = args.GetIsolate();

	Local<ObjectTemplate> myClassTemplate =
		Local<ObjectTemplate>::New(isolate, gMyClassTemplate);

	Local<Object> myClassObj = myClassTemplate->NewInstance(
		isolate->GetCurrentContext()).ToLocalChecked();

	int numValue =
		args[0]->Int32Value(isolate->GetCurrentContext()).FromMaybe(0);

	gMyClass = new ObjectWrap(numValue);
	gMyClass->Wrap(myClassObj);

	args.GetReturnValue().Set(myClassObj);
}
开发者ID:ACEZLY,项目名称:server,代码行数:26,代码来源:MyClass_Wrap.cpp

示例2: disconnectSync

//	DISCONNECT SYNC
void disconnectSync(const FunctionCallbackInfo<Value>& args) {
	Isolate* isolate = Isolate::GetCurrent();
	HandleScope scope(isolate);
	
	SQLRETURN retcode;

	// define callback
	Local<Function> cb = Local<Function>::Cast(args[0]);
	
    // Free handles
    // Statement
    if (hstmt != SQL_NULL_HSTMT)
        SQLFreeHandle(SQL_HANDLE_STMT, hstmt);

    // Connection
	retcode = SQLDisconnect(hdbc);
	if(!SQL_SUCCEEDED(retcode)){
		printf("ERROR AT SQLDISCONNECT\n");
		extract_error(hdbc, SQL_HANDLE_DBC);
	}
    SQLFreeHandle(SQL_HANDLE_DBC, hdbc);
/*
    // Environment
    if (henv != SQL_NULL_HENV)
        SQLFreeHandle(SQL_HANDLE_ENV, henv);
*/	

	Local<Value> argv[1] = { Number::New(isolate, retcode)};
	cb->Call(isolate->GetCurrentContext()->Global(), 1, argv);
}
开发者ID:puneethmanyam,项目名称:nedgedb,代码行数:31,代码来源:nodbc.cpp

示例3: ParseSync

void ParseSync(const Nan::FunctionCallbackInfo<Value> &args) {
  Isolate *isolate = args.GetIsolate();
  int args_length = args.Length();

  if (args_length < 1) {
    isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, "Wrong number of arguments")));
    return;
  }

  Local<Value> input = args[0];
  if (!ValidateInput(input, isolate)) {
    return;
  }

  anitomyJs::AnitomyJs anitomy;
  if (args_length >= 2) {
    Local<Value> options = args[1];
    if (!ValidateOptions(options, isolate) ||
        !anitomy.SetOptions(options->ToObject(isolate->GetCurrentContext()).ToLocalChecked(), isolate)) {
      return;
    }
  }

  anitomy.SetInput(input, isolate);
  anitomy.Parse();

  args.GetReturnValue().Set(anitomy.ParsedResult(isolate));
}
开发者ID:nevermnd,项目名称:anitomy-js,代码行数:28,代码来源:addon.cpp

示例4: SetLogHandler

void EModuleHelper::SetLogHandler( const FunctionCallbackInfo< Value >& args )
{
	Isolate* isolate = args.GetIsolate( );
	HandleScope scope( isolate );

	Local< Context > context = isolate->GetCurrentContext( );

	if( args[ 0 ]->IsNull( ) )
	{
		s_bLogEnabled = false;
	}
	else if( args[ 0 ]->IsFunction( ) )
	{
		s_bLogEnabled = true;
		s_fnLogHandler.Reset( isolate, args[ 0 ].As< Function >( ) );
	}
	else
	{
		std::wostringstream stream; 
		{ 
			stream << __FUNCTIONW__ << L" Invalid input type"; 
		} 
		ThrowV8Exception( isolate, stream );	
	}
}
开发者ID:ItsClemi,项目名称:node-odbc,代码行数:25,代码来源:EModuleHelper.cpp

示例5: Method

void Method(const FunctionCallbackInfo<Value>& args) {
	Isolate* isolate = Isolate::GetCurrent();
	HandleScope scope(isolate);
	const char * cstr;
	String::Utf8Value str(args[0]->ToString());
	cstr = *str;

	CTime curTime;
	CRTime deliLimit;
	vector<CDriver> drivers;
	vector<CTask> tasks;
	vector<CPath> paths;
	vector<CScheduleItem> schedule;
	schedule.clear();
	if (parseInput(cstr, curTime, deliLimit, drivers, tasks, paths)) {
		int ret = ALG::findScheduleGreedy(curTime, deliLimit, drivers, tasks, paths, schedule);
		if (ret != E_NORMAL) {
			printf("search algorithm returned %d.\n", ret);
		}
	}
	Local<String> schd_string = String::NewFromUtf8(isolate, prepareOutput(schedule).c_str());
	//args.GetReturnValue().Set(schd_string);
	Local<Function> cb = Local<Function>::Cast(args[1]);
	const unsigned int argc = 1;
	Local<Value> argv[argc] = {schd_string};
	cb->Call(isolate->GetCurrentContext()->Global(), argc, argv);
}
开发者ID:ace68723,项目名称:smart,代码行数:27,代码来源:wrapper.cpp

示例6: ParseAsync

void ParseAsync(const Nan::FunctionCallbackInfo<Value> &args) {
  Isolate *isolate = args.GetIsolate();
  int args_length = args.Length();

  if (args_length < 2) {
    isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, "Wrong number of arguments")));
    return;
  }

  Local<Value> input = args[0];
  if (!ValidateInput(input, isolate)) {
    return;
  }
  if (!args[1]->IsFunction()) {
    isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, "Second parameter must be a callback")));
    return;
  }

  Nan::Callback *callback = new Nan::Callback(args[1].As<Function>());
  anitomyJs::Worker *worker = new anitomyJs::Worker(callback);

  if (args_length >= 3) {
    Local<Value> options = args[2];
    if (!ValidateOptions(options, isolate) ||
        !worker->GetAnitomy()->SetOptions(options->ToObject(isolate->GetCurrentContext()).ToLocalChecked(), isolate)) {
      return;
    }
  }

  worker->GetAnitomy()->SetInput(input, isolate);
  Nan::AsyncQueueWorker(worker);
  args.GetReturnValue().Set(Nan::Undefined());
}
开发者ID:nevermnd,项目名称:anitomy-js,代码行数:33,代码来源:addon.cpp

示例7: onFrameSetup

void* JsVlcPlayer::onFrameSetup( const I420VideoFrame& videoFrame )
{
    using namespace v8;

    if( 0 == videoFrame.width() || 0 == videoFrame.height() ||
        0 == videoFrame.uPlaneOffset() || 0 == videoFrame.vPlaneOffset() ||
        0 == videoFrame.size() )
    {
        assert( false );
        return nullptr;
    }

    Isolate* isolate = Isolate::GetCurrent();
    HandleScope scope( isolate );

    Local<Object> global = isolate->GetCurrentContext()->Global();

    Local<Value> abv =
        global->Get(
            String::NewFromUtf8( isolate,
                                 "Uint8Array",
                                 v8::String::kInternalizedString ) );
    Local<Value> argv[] =
        { Integer::NewFromUnsigned( isolate, videoFrame.size() ) };
    Local<Uint8Array> jsArray =
        Handle<Uint8Array>::Cast( Handle<Function>::Cast( abv )->NewInstance( 1, argv ) );

    Local<Integer> jsWidth = Integer::New( isolate, videoFrame.width() );
    Local<Integer> jsHeight = Integer::New( isolate, videoFrame.height() );
    Local<Integer> jsPixelFormat = Integer::New( isolate, static_cast<int>( PixelFormat::I420 ) );

    jsArray->ForceSet( String::NewFromUtf8( isolate, "width", v8::String::kInternalizedString ),
                       jsWidth,
                       static_cast<v8::PropertyAttribute>( ReadOnly | DontDelete ) );
    jsArray->ForceSet( String::NewFromUtf8( isolate, "height", v8::String::kInternalizedString ),
                       jsHeight,
                       static_cast<v8::PropertyAttribute>( ReadOnly | DontDelete ) );
    jsArray->ForceSet( String::NewFromUtf8( isolate, "pixelFormat", v8::String::kInternalizedString ),
                       jsPixelFormat,
                       static_cast<v8::PropertyAttribute>( ReadOnly | DontDelete ) );
    jsArray->ForceSet( String::NewFromUtf8( isolate, "uOffset", v8::String::kInternalizedString ),
                       Integer::New( isolate, videoFrame.uPlaneOffset() ),
                       static_cast<v8::PropertyAttribute>( ReadOnly | DontDelete ) );
    jsArray->ForceSet( String::NewFromUtf8( isolate, "vOffset", v8::String::kInternalizedString ),
                       Integer::New( isolate, videoFrame.vPlaneOffset() ),
                       static_cast<v8::PropertyAttribute>( ReadOnly | DontDelete ) );

    _jsFrameBuffer.Reset( isolate, jsArray );

    callCallback( CB_FrameSetup, { jsWidth, jsHeight, jsPixelFormat, jsArray } );

#ifdef USE_ARRAY_BUFFER
    return jsArray->Buffer()->GetContents().Data();
#else
    return jsArray->GetIndexedPropertiesExternalArrayData();
#endif
}
开发者ID:atifzaidi,项目名称:WebChimera.js,代码行数:57,代码来源:JsVlcPlayer.cpp

示例8: onConnection

void onConnection(const FunctionCallbackInfo<Value> &args) {
    uWS::Server *server = (uWS::Server *) args.Holder()->GetAlignedPointerFromInternalField(0);
    Isolate *isolate = args.GetIsolate();
    Persistent<Function> *connectionCallback = (Persistent<Function> *) args.Holder()->GetAlignedPointerFromInternalField(CONNECTION_CALLBACK);
    connectionCallback->Reset(isolate, Local<Function>::Cast(args[0]));
    server->onConnection([isolate, connectionCallback](uWS::Socket socket) {
        HandleScope hs(isolate);
        Local<Value> argv[] = {wrapSocket(socket, isolate)};
        node::MakeCallback(isolate, isolate->GetCurrentContext()->Global(), Local<Function>::New(isolate, *connectionCallback), 1, argv);
    });
}
开发者ID:cuongquay,项目名称:uWebSockets,代码行数:11,代码来源:addon.cpp

示例9: CreateDelegate

	Local<Object> CreateDelegate(UObject* Object, UProperty* Property)
	{
		//@HACK
		CollectGarbageDelegates();

		auto payload = new FJavascriptDelegate(Object, Property);
		auto created = payload->Initialize(isolate_->GetCurrentContext());

		Delegates.Add(payload);

		return created;
	}
开发者ID:Galvarezss,项目名称:Unreal.js,代码行数:12,代码来源:Delegates.cpp

示例10: csv

 void parse2json(const FunctionCallbackInfo<Value>& args) {
     Isolate* isolate = args.GetIsolate();
     if (args.Length() < 1) {
         isolate->ThrowException(Exception::TypeError(String::NewFromUtf8(isolate, "Wrong number of arguments.", NewStringType::kNormal).ToLocalChecked()));
     }
     // Use maybe version
     std::string csv(*String::Utf8Value(isolate, args[0]->ToString(isolate->GetCurrentContext()).ToLocalChecked()));
     // std::string csv(*String::Utf8Value(isolate, args[0]->ToString()));
     std::string json = csv2json_str(csv);
     
     args.GetReturnValue().Set(String::NewFromUtf8(isolate, json.c_str(), NewStringType::kNormal).ToLocalChecked());
 }
开发者ID:luck4f,项目名称:ms_p,代码行数:12,代码来源:csv.cpp

示例11: type

void
_gum_v8_module_realize (GumV8Module * self)
{
  static gsize gonce_value = 0;

  if (g_once_init_enter (&gonce_value))
  {
    Isolate * isolate = self->core->isolate;
    Local<Context> context = isolate->GetCurrentContext ();

    Local<String> type (String::NewFromUtf8 (isolate, "type"));
    Local<String> name (String::NewFromUtf8 (isolate, "name"));
    Local<String> module (String::NewFromUtf8 (isolate, "module"));
    Local<String> address (String::NewFromUtf8 (isolate, "address"));

    Local<String> function (String::NewFromUtf8 (isolate, "function"));
    Local<String> variable (String::NewFromUtf8 (isolate, "variable"));

    Local<String> empty_string = String::NewFromUtf8 (isolate, "");

    Local<Object> imp (Object::New (isolate));
    Maybe<bool> result = imp->ForceSet (context, type, function);
    g_assert (result.IsJust ());
    result = imp->ForceSet (context, name, empty_string, DontDelete);
    g_assert (result.IsJust ());
    result = imp->ForceSet (context, module, empty_string);
    g_assert (result.IsJust ());
    result = imp->ForceSet (context, address, _gum_v8_native_pointer_new (
        GSIZE_TO_POINTER (NULL), self->core));
    g_assert (result.IsJust ());

    Local<Object> exp (Object::New (isolate));
    result = exp->ForceSet (context, type, function, DontDelete);
    g_assert (result.IsJust ());
    result = exp->ForceSet (context, name, empty_string, DontDelete);
    g_assert (result.IsJust ());
    result = exp->ForceSet (context, address, _gum_v8_native_pointer_new (
        GSIZE_TO_POINTER (NULL), self->core), DontDelete);
    g_assert (result.IsJust ());

    eternal_imp.Set (isolate, imp);
    eternal_exp.Set (isolate, exp);

    eternal_type.Set (isolate, type);
    eternal_name.Set (isolate, name);
    eternal_module.Set (isolate, module);
    eternal_address.Set (isolate, address);
    eternal_variable.Set (isolate, variable);

    g_once_init_leave (&gonce_value, 1);
  }
}
开发者ID:terry2012,项目名称:frida-gum,代码行数:52,代码来源:gumv8module.cpp

示例12: queryAfter

void queryAfter(uv_work_t* req, int status) {
	Isolate* isolate = Isolate::GetCurrent();
	HandleScope scope(isolate);

	query_data* data = (query_data *)(req->data);

	Local<Value> argv[1] = { Number::New(isolate, data->result)};
	Local<Function> cb = Local<Function>::New(isolate, data->cb);
	cb->Call(isolate->GetCurrentContext()->Global(), 1, argv);
	
	free(data);
	free(req);
}
开发者ID:puneethmanyam,项目名称:nedgedb,代码行数:13,代码来源:nodbc.cpp

示例13: onMessage

void onMessage(const FunctionCallbackInfo<Value> &args) {
    uWS::Server *server = (uWS::Server *) args.Holder()->GetAlignedPointerFromInternalField(0);
    Isolate *isolate = args.GetIsolate();
    Persistent<Function> *messageCallback = (Persistent<Function> *) args.Holder()->GetAlignedPointerFromInternalField(MESSAGE_CALLBACK);
    messageCallback->Reset(isolate, Local<Function>::Cast(args[0]));
    server->onMessage([isolate, messageCallback](uWS::Socket socket, const char *message, size_t length, uWS::OpCode opCode) {
        HandleScope hs(isolate);
        Local<Value> argv[] = {wrapSocket(socket, isolate),
                               node::Buffer::New(isolate, (char *) message, length, [](char *data, void *hint) {}, nullptr).ToLocalChecked(),
                               Boolean::New(isolate, opCode == BINARY),
                               getDataV8(socket, isolate)};
        node::MakeCallback(isolate, isolate->GetCurrentContext()->Global(), Local<Function>::New(isolate, *messageCallback), 4, argv);
    });
}
开发者ID:cuongquay,项目名称:uWebSockets,代码行数:14,代码来源:addon.cpp

示例14: selectAfter

void selectAfter(uv_work_t* req, int status) {
	Isolate* isolate = Isolate::GetCurrent();
	HandleScope scope(isolate);

	select_data* data = (select_data *)(req->data);

	Local<Value> argv[2] = { Number::New(isolate, data->result), String::NewFromUtf8(isolate, data->records) }; 
	Local<Function> cb = Local<Function>::New(isolate, data->cb);
	cb->Call(isolate->GetCurrentContext()->Global(), 2, argv);
	
	free(data->records);
	free(data);
	free(req);
}
开发者ID:puneethmanyam,项目名称:nedgedb,代码行数:14,代码来源:nodbc.cpp

示例15: onDisconnection

void onDisconnection(const FunctionCallbackInfo<Value> &args) {
    uWS::Server *server = (uWS::Server *) args.Holder()->GetAlignedPointerFromInternalField(0);
    Isolate *isolate = args.GetIsolate();
    Persistent<Function> *disconnectionCallback = (Persistent<Function> *) args.Holder()->GetAlignedPointerFromInternalField(DISCONNECTION_CALLBACK);
    disconnectionCallback->Reset(isolate, Local<Function>::Cast(args[0]));
    server->onDisconnection([isolate, disconnectionCallback](uWS::Socket socket, int code, char *message, size_t length) {
        HandleScope hs(isolate);
        Local<Value> argv[] = {wrapSocket(socket, isolate),
                               Integer::New(isolate, code),
                               node::Buffer::New(isolate, (char *) message, length, [](char *data, void *hint) {}, nullptr).ToLocalChecked(),
                               getDataV8(socket, isolate)};
        node::MakeCallback(isolate, isolate->GetCurrentContext()->Global(), Local<Function>::New(isolate, *disconnectionCallback), 4, argv);
    });
}
开发者ID:cuongquay,项目名称:uWebSockets,代码行数:14,代码来源:addon.cpp


注:本文中的Isolate::GetCurrentContext方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。