• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ HandleScope函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中HandleScope函数的典型用法代码示例。如果您正苦于以下问题:C++ HandleScope函数的具体用法?C++ HandleScope怎么用?C++ HandleScope使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: HandleScope

void CJSKadID::FxToString(const v8::FunctionCallbackInfo<v8::Value> &args)
{
	v8::HandleScope HandleScope(v8::Isolate::GetCurrent());
	CJSKadID* jKadID = GetJSObject<CJSKadID>(args.Holder());

	args.GetReturnValue().Set(v8::String::NewFromTwoByte(v8::Isolate::GetCurrent(), V8STR(jKadID->m_pKadID->m_Value.ToHex().c_str())));
}
开发者ID:0vermind,项目名称:NeoLoader,代码行数:7,代码来源:JSKadID.cpp


示例2: HandleScope

/** toString:
* convert the buffer into a hex encoded string
* 
* @return string
*	Hex Encoded buffer content
*/
void CJSBuffer::FxToString(const v8::FunctionCallbackInfo<v8::Value> &args)
{
	v8::HandleScope HandleScope(v8::Isolate::GetCurrent());
	CBufferObj* pBuffer = GetCObject<CBufferObj>(args.Holder());

	args.GetReturnValue().Set(v8::String::NewFromTwoByte(v8::Isolate::GetCurrent(), V8STR(ToHex(pBuffer->GetBuffer(), pBuffer->GetSize()).c_str())));
}
开发者ID:0vermind,项目名称:NeoLoader,代码行数:13,代码来源:JSBuffer.cpp


示例3: HandleScope

PJsonVal TNodeJsStreamAggr::SaveJson(const int& Limit) const {
	if (!SaveJsonFun.IsEmpty()) {
		v8::Isolate* Isolate = v8::Isolate::GetCurrent();
		v8::HandleScope HandleScope(Isolate);

		v8::Local<v8::Function> Callback = v8::Local<v8::Function>::New(Isolate, SaveJsonFun);
		v8::Local<v8::Object> GlobalContext = Isolate->GetCurrentContext()->Global();
		const unsigned Argc = 1;
		v8::Local<v8::Value> ArgV[Argc] = { v8::Number::New(Isolate, Limit) };
		v8::TryCatch TryCatch;
		v8::Local<v8::Value> ReturnVal = Callback->Call(GlobalContext, Argc, ArgV);
		if (TryCatch.HasCaught()) {
			TryCatch.ReThrow();	
			return TJsonVal::NewObj();
		}
		QmAssertR(ReturnVal->IsObject(), "Stream aggr JS callback: saveJson didn't return an object.");
		PJsonVal Res = TNodeJsUtil::GetObjJson(ReturnVal->ToObject());

		QmAssertR(Res->IsDef(), "Stream aggr JS callback: saveJson didn't return a valid JSON.");
		return Res;
	}
	else {
		return TJsonVal::NewObj();
	}
}
开发者ID:Zala,项目名称:qminer,代码行数:25,代码来源:qm_nodejs_streamaggr.cpp


示例4: HandleScope

void TNodeJsFIn::Init(v8::Handle<v8::Object> exports) {
	v8::Isolate* Isolate = v8::Isolate::GetCurrent();
	v8::HandleScope HandleScope(Isolate);
	// template for creating function from javascript using "new", uses _NewJs callback
	v8::Local<v8::FunctionTemplate> tpl = v8::FunctionTemplate::New(Isolate, TNodeJsUtil::_NewJs<TNodeJsFIn>);
	// child will have the same properties and methods, but a different callback: _NewCpp
	v8::Local<v8::FunctionTemplate> child = v8::FunctionTemplate::New(Isolate, TNodeJsUtil::_NewCpp<TNodeJsFIn>);
	child->Inherit(tpl);

	child->SetClassName(v8::String::NewFromUtf8(Isolate, GetClassId().CStr()));
	// ObjectWrap uses the first internal field to store the wrapped pointer
	child->InstanceTemplate()->SetInternalFieldCount(1);
	
	tpl->SetClassName(v8::String::NewFromUtf8(Isolate, GetClassId().CStr()));
	// ObjectWrap uses the first internal field to store the wrapped pointer
	tpl->InstanceTemplate()->SetInternalFieldCount(1);

	// Add all prototype methods, getters and setters here
	NODE_SET_PROTOTYPE_METHOD(tpl, "peekCh", _peekCh);
	NODE_SET_PROTOTYPE_METHOD(tpl, "getCh", _getCh);
    NODE_SET_PROTOTYPE_METHOD(tpl, "readLine", _readLine);
    NODE_SET_PROTOTYPE_METHOD(tpl, "readJson", _readJson);
	NODE_SET_PROTOTYPE_METHOD(tpl, "readAll", _readAll);
	// Add properties
	tpl->InstanceTemplate()->SetAccessor(v8::String::NewFromUtf8(Isolate, "eof"), _eof);
	tpl->InstanceTemplate()->SetAccessor(v8::String::NewFromUtf8(Isolate, "length"), _length);

	// This has to be last, otherwise the properties won't show up on the object in JavaScript	
	// Constructor is used when creating the object from C++
	Constructor.Reset(Isolate, child->GetFunction());
	// we need to export the class for calling using "new FIn(...)"
	exports->Set(v8::String::NewFromUtf8(Isolate, GetClassId().CStr()),
		tpl->GetFunction());
}
开发者ID:quintelligence,项目名称:qminer,代码行数:34,代码来源:fs_nodejs.cpp


示例5: HandleScope

void TNodeJsFIn::New(const v8::FunctionCallbackInfo<v8::Value>& Args) {
    v8::Isolate* Isolate = v8::Isolate::GetCurrent();
    v8::HandleScope HandleScope(Isolate);

    if (Args.IsConstructCall()) {
        EAssertR(Args.Length() == 1 && Args[0]->IsString(),
            "Expected a file path.");
        TStr FNm(*v8::String::Utf8Value(Args[0]->ToString()));
        EAssertR(TFile::Exists(FNm), "File does not exist.");

        TNodeJsFIn* JsFIn = new TNodeJsFIn(FNm);
        v8::Local<v8::Object> Instance = Args.This();
		
		v8::Handle<v8::String> key = v8::String::NewFromUtf8(Isolate, "class");
		v8::Handle<v8::String> value = v8::String::NewFromUtf8(Isolate, ClassId.CStr());
		Instance->SetHiddenValue(key, value);

        JsFIn->Wrap(Instance);
        Args.GetReturnValue().Set(Instance);
    } else {
        const int Argc = 1;
        v8::Local<v8::Value> Argv[Argc] = { Args[0] };
        v8::Local<v8::Function> cons = v8::Local<v8::Function>::New(Isolate, constructor);
        v8::Local<v8::Object> Instance = cons->NewInstance(Argc, Argv);
        Args.GetReturnValue().Set(Instance);
    }
}
开发者ID:josthkko,项目名称:qminer,代码行数:27,代码来源:fs_nodejs.cpp


示例6: HandleScope

TNodeJsRf24Radio* TNodeJsRf24Radio::NewFromArgs(const v8::FunctionCallbackInfo<v8::Value>& Args) {
	v8::Isolate* Isolate = v8::Isolate::GetCurrent();
	v8::HandleScope HandleScope(Isolate);

	PJsonVal ParamJson = TNodeJsUtil::GetArgJson(Args, 0);

	const int PinCE = ParamJson->GetObjInt("pinCE");
	const int PinCSN = ParamJson->GetObjInt("pinCSN");
	const uint16 MyId = (uint16) ParamJson->GetObjInt("id");
	const PJsonVal SensorJsonV = ParamJson->GetObjKey("sensors");

	const bool Verbose = ParamJson->GetObjBool("verbose", false);
	const PNotify Notify = Verbose ? TNotify::StdNotify : TNotify::NullNotify;

	Notify->OnNotify(TNotifyType::ntInfo, "Parsing configuration ...");

	TStrIntH SensorNmIdH;
	TStrIntH SensorIdNodeIdH;

	for (int SensorN = 0; SensorN < SensorJsonV->GetArrVals(); SensorN++) {
		const PJsonVal SensorJson = SensorJsonV->GetArrVal(SensorN);
		const TStr& SensorId = SensorJson->GetObjStr("id");
		SensorNmIdH.AddDat(SensorId, SensorJson->GetObjInt("internalId"));
		SensorIdNodeIdH.AddDat(SensorId, SensorJson->GetObjInt("nodeId"));
	}

	Notify->OnNotify(TNotifyType::ntInfo, "Calling cpp constructor ...");

	return new TNodeJsRf24Radio(MyId, PinCE, PinCSN, SensorNmIdH, SensorIdNodeIdH, Notify);
}
开发者ID:lstopar,项目名称:HomeDevelopment,代码行数:30,代码来源:rpinode.cpp


示例7: TNodeTask

TNodejsDHT11Sensor::TReadTask::TReadTask(const v8::FunctionCallbackInfo<v8::Value>& Args):
		TNodeTask(Args),
		JsSensor(nullptr) {
	v8::Isolate* Isolate = v8::Isolate::GetCurrent();
	v8::HandleScope HandleScope(Isolate);

	JsSensor = ObjectWrap::Unwrap<TNodejsDHT11Sensor>(Args.Holder());
}
开发者ID:lstopar,项目名称:HomeDevelopment,代码行数:8,代码来源:rpinode.cpp


示例8: HandleScope

void TNodeTask::AfterRunSync(const v8::FunctionCallbackInfo<v8::Value>& Args) {
	v8::Isolate* Isolate = v8::Isolate::GetCurrent();
	v8::HandleScope HandleScope(Isolate);

	if (!Except.Empty()) { throw Except; }

	Args.GetReturnValue().Set(WrapResult());
}
开发者ID:amrsobhy,项目名称:qminer,代码行数:8,代码来源:nodeutil.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ HandleStatus函数代码示例发布时间:2022-05-30
下一篇:
C++ HandleReturnMovement函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap