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


C++ FunctionCallbackInfo::Data方法代码示例

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


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

示例1: callCallback

void ScriptFunction::callCallback(
    const v8::FunctionCallbackInfo<v8::Value>& args) {
  ASSERT(args.Data()->IsExternal());
  ScriptFunction* scriptFunction = static_cast<ScriptFunction*>(
      v8::Local<v8::External>::Cast(args.Data())->Value());
  ScriptValue result = scriptFunction->call(
      ScriptValue(scriptFunction->getScriptState(), args[0]));
  v8SetReturnValue(args, result.v8Value());
}
开发者ID:mirror,项目名称:chromium,代码行数:9,代码来源:ScriptFunction.cpp

示例2: promiseRejectCallback

void promiseRejectCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    ASSERT(!info.Data().IsEmpty());
    v8::Local<v8::Object> promise = info.Data().As<v8::Object>();
    v8::Local<v8::Value> result = v8::Undefined(info.GetIsolate());
    if (info.Length() > 0)
        result = info[0];

    V8PromiseCustom::reject(promise, result, info.GetIsolate());
}
开发者ID:jeremyroman,项目名称:blink,代码行数:10,代码来源:V8PromiseCustom.cpp

示例3: callCallback

void ScriptFunction::callCallback(const v8::FunctionCallbackInfo<v8::Value>& args)
{
    v8::Isolate* isolate = args.GetIsolate();
    ASSERT(!args.Data().IsEmpty());
    ScriptFunction* function = ScriptFunction::Cast(args.Data());
    v8::Local<v8::Value> value = args.Length() > 0 ? args[0] : v8::Local<v8::Value>(v8::Undefined(isolate));

    ScriptValue result = function->call(ScriptValue(ScriptState::current(isolate), value));

    v8SetReturnValue(args, result.v8Value());
}
开发者ID:darktears,项目名称:blink-crosswalk,代码行数:11,代码来源:ScriptFunction.cpp

示例4: callback

/**
 *  Callback function to be used when invoking functions
 *  defined from the PHP side
 *
 *  @param  info    callback information
 */
static void callback(const v8::FunctionCallbackInfo<v8::Value> &info)
{
    // create a local handle, so properties "fall out of scope"
    v8::HandleScope     scope(Isolate::get());

    // retrieve handle to the original object
    Handle              handle(info.Data());

    // an array to hold all the arguments
    Php::Array arguments;

    // add all the arguments
    for (int i = 0; i < info.Length(); ++i) arguments.set(i, value(info[i]));

    // catch any exceptions the PHP code might throw
    try
    {
        // now execute the function
        Php::Value result(Php::call("call_user_func_array", handle, arguments));

        // cast the value and set it as return parameter
        info.GetReturnValue().Set(value(result));
    }
    catch (const Php::Exception& exception)
    {
        // pass the exception on to javascript userspace
        Isolate::get()->ThrowException(v8::Exception::Error(v8::String::NewFromUtf8(Isolate::get(), exception.what())));
    }
}
开发者ID:Doanlmit,项目名称:PHP-JS,代码行数:35,代码来源:value.cpp

示例5: constructCustomElement

static void constructCustomElement(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    v8::Isolate* isolate = info.GetIsolate();

    if (!info.IsConstructCall()) {
        V8ThrowException::throwTypeError(isolate, "DOM object constructor cannot be called as a function.");
        return;
    }

    if (info.Length() > 0) {
        V8ThrowException::throwTypeError(isolate, "This constructor should be called without arguments.");
        return;
    }

    ScriptState* scriptState = ScriptState::current(isolate);
    v8::Local<v8::Object> data = v8::Local<v8::Object>::Cast(info.Data());
    Document* document = V8Document::toImpl(V8HiddenValue::getHiddenValue(scriptState, data, V8HiddenValue::customElementDocument(isolate)).As<v8::Object>());
    TOSTRING_VOID(V8StringResource<>, namespaceURI, V8HiddenValue::getHiddenValue(scriptState, data, V8HiddenValue::customElementNamespaceURI(isolate)));
    TOSTRING_VOID(V8StringResource<>, tagName, V8HiddenValue::getHiddenValue(scriptState, data, V8HiddenValue::customElementTagName(isolate)));
    v8::Local<v8::Value> maybeType = V8HiddenValue::getHiddenValue(scriptState, data, V8HiddenValue::customElementType(isolate));
    TOSTRING_VOID(V8StringResource<>, type, maybeType);

    ExceptionState exceptionState(ExceptionState::ConstructionContext, "CustomElement", info.Holder(), info.GetIsolate());
    V0CustomElementProcessingStack::CallbackDeliveryScope deliveryScope;
    Element* element = document->createElementNS(namespaceURI, tagName, maybeType->IsNull() ? nullAtom : type, exceptionState);
    if (exceptionState.throwIfNeeded())
        return;
    v8SetReturnValueFast(info, element, document);
}
开发者ID:endlessm,项目名称:chromium-browser,代码行数:29,代码来源:V0CustomElementConstructorBuilder.cpp

示例6: log_callback

	void PreludeScript::log_callback(const v8::FunctionCallbackInfo<v8::Value>& args) 
	{
		if (args.Length() != 1)
		{
			args.GetReturnValue().Set(
				v8::Isolate::GetCurrent()->ThrowException(
				v8::Exception::Error(v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), "The 'log' handler expects 1 argument"))));
			return;
		}
		if (args[0].IsEmpty()) 
		{
			args.GetReturnValue().Set(v8::Isolate::GetCurrent()->ThrowException(
				v8::Exception::Error(v8::String::NewFromUtf8(v8::Isolate::GetCurrent(), "The 'log' handler argument cannot be empty"))));
			return;
		}

		// TODO: do we need to check argument data type?

		v8::Handle<v8::External> data = args.Data().As<v8::External>();
		PreludeScript *prelude = reinterpret_cast<PreludeScript *>(data->Value());

		//TODO: make sure correct value type passed
		v8::String::Value message(args[0].As<v8::String>());

		prelude->log_handler(*message);
		args.GetReturnValue().Set(v8::Undefined(v8::Isolate::GetCurrent()));
		return;
	};
开发者ID:18098924759,项目名称:EventStore,代码行数:28,代码来源:PreludeScript.cpp

示例7:

typename std::enable_if<is_function_pointer<F>::value,
	typename function_traits<F>::return_type>::type
invoke(v8::FunctionCallbackInfo<v8::Value> const& args)
{
	F f = get_external_data<F>(args.Data());
	return call_from_v8(std::forward<F>(f), args);
}
开发者ID:aspectron,项目名称:iris-crypt,代码行数:7,代码来源:function.hpp

示例8: ClassConstructorCallback

void MetadataNode::ClassConstructorCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
	try
	{
		SET_PROFILER_FRAME();

		auto thiz = info.This();
		auto node = reinterpret_cast<MetadataNode*>(info.Data().As<External>()->Value());

		Local<Object> outerThis;
		string extendName;
		auto className = node->m_name;

		SetInstanceMetadata(info.GetIsolate(), thiz, node);

		ArgsWrapper argWrapper(info, ArgType::Class, outerThis);

		string fullClassName = CreateFullClassName(className, extendName);
		bool success = NativeScriptRuntime::RegisterInstance(thiz, fullClassName, argWrapper, outerThis, false);
	}
	catch (NativeScriptException& e)
	{
		e.ReThrowToV8();
	}
	catch (std::exception e) {
		stringstream ss;
		ss << "Error: c++ exception: " << e.what() << endl;
		NativeScriptException nsEx(ss.str());
		nsEx.ReThrowToV8();
	}
	catch (...) {
		NativeScriptException nsEx(std::string("Error: c++ exception!"));
		nsEx.ReThrowToV8();
	}
}
开发者ID:atifzaidi,项目名称:android-runtime,代码行数:35,代码来源:MetadataNode.cpp

示例9: scope

static void FXJSE_V8ProxyCallback_defineProperty(
    const v8::FunctionCallbackInfo<v8::Value>& info) {
  const FXJSE_CLASS* lpClass =
      static_cast<FXJSE_CLASS*>(info.Data().As<v8::External>()->Value());
  if (!lpClass) {
    return;
  }
  v8::Isolate* pIsolate = info.GetIsolate();
  v8::HandleScope scope(pIsolate);
  v8::Local<v8::String> hPropName = info[0]->ToString();
  v8::Local<v8::Object> hPropDescriptor = info[1]->ToObject();
  v8::String::Utf8Value szPropName(hPropName);
  if (!hPropDescriptor->Has(v8::String::NewFromUtf8(pIsolate, "value"))) {
    return;
  }
  v8::Local<v8::Value> hPropValue =
      hPropDescriptor->Get(v8::String::NewFromUtf8(pIsolate, "value"));
  CFX_ByteStringC szFxPropName(*szPropName, szPropName.length());
  CFXJSE_Value* lpThisValue = CFXJSE_Value::Create(info.GetIsolate());
  CFXJSE_Value* lpPropValue = CFXJSE_Value::Create(info.GetIsolate());
  lpThisValue->ForceSetValue(info.This());
  lpPropValue->ForceSetValue(hPropValue);
  FXJSE_DynPropSetterAdapter(
      lpClass, reinterpret_cast<FXJSE_HOBJECT>(lpThisValue), szFxPropName,
      reinterpret_cast<FXJSE_HVALUE>(lpPropValue));
  delete lpThisValue;
  lpThisValue = nullptr;
  delete lpPropValue;
  lpPropValue = nullptr;
}
开发者ID:andoma,项目名称:pdfium,代码行数:30,代码来源:dynprop.cpp

示例10: ExtendedClassConstructorCallback

void MetadataNode::ExtendedClassConstructorCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
	SET_PROFILER_FRAME();

	assert(info.IsConstructCall());

	auto isolate = info.GetIsolate();
	auto thiz = info.This();
	auto extData = reinterpret_cast<ExtendedClassData*>(info.Data().As<External>()->Value());

	auto implementationObject = Local<Object>::New(isolate, *extData->implementationObject);

	const auto& extendName = extData->extendedName;
//	auto className = TNS_PREFIX + extData->node->m_name;

	SetInstanceMetadata(isolate, thiz, extData->node);
	thiz->SetInternalField(static_cast<int>(ObjectManager::MetadataNodeKeys::CallSuper), True(isolate));
	thiz->SetHiddenValue(ConvertToV8String("t::implObj"), implementationObject);

	ArgsWrapper argWrapper(info, ArgType::Class, Local<Object>());

//	string fullClassName = CreateFullClassName(className, extendName);
	string fullClassName = extData->fullClassName;

	bool success = NativeScriptRuntime::RegisterInstance(thiz, fullClassName, argWrapper, implementationObject, false);
}
开发者ID:bright-sparks,项目名称:android-runtime,代码行数:26,代码来源:MetadataNode.cpp

示例11: FXJSE_DynPropGetterAdapter_MethodCallback

static void FXJSE_DynPropGetterAdapter_MethodCallback(
    const v8::FunctionCallbackInfo<v8::Value>& info) {
  v8::Local<v8::Object> hCallBackInfo = info.Data().As<v8::Object>();
  FXJSE_CLASS* lpClass = static_cast<FXJSE_CLASS*>(
      hCallBackInfo->GetAlignedPointerFromInternalField(0));
  v8::Local<v8::String> hPropName =
      hCallBackInfo->GetInternalField(1).As<v8::String>();
  ASSERT(lpClass && !hPropName.IsEmpty());
  v8::String::Utf8Value szPropName(hPropName);
  CFX_ByteStringC szFxPropName = *szPropName;
  CFXJSE_Value* lpThisValue = CFXJSE_Value::Create(info.GetIsolate());
  lpThisValue->ForceSetValue(info.This());
  CFXJSE_Value* lpRetValue = CFXJSE_Value::Create(info.GetIsolate());
  CFXJSE_ArgumentsImpl impl = {&info, lpRetValue};
  lpClass->dynMethodCall(reinterpret_cast<FXJSE_HOBJECT>(lpThisValue),
                         szFxPropName,
                         reinterpret_cast<CFXJSE_Arguments&>(impl));
  if (!lpRetValue->DirectGetValue().IsEmpty()) {
    info.GetReturnValue().Set(lpRetValue->DirectGetValue());
  }
  delete lpRetValue;
  lpRetValue = nullptr;
  delete lpThisValue;
  lpThisValue = nullptr;
}
开发者ID:andoma,项目名称:pdfium,代码行数:25,代码来源:dynprop.cpp

示例12: InterfaceConstructorCallback

void MetadataNode::InterfaceConstructorCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
	SET_PROFILER_FRAME();

	auto thiz = info.This();
	auto node = reinterpret_cast<MetadataNode*>(info.Data().As<External>()->Value());

	Handle<Object> implementationObject;
	Handle<String> v8ExtendName;
	string extendLocation;
	bool extendLocationFound = GetExtendLocation(extendLocation);
	if (info.Length() == 1)
	{
		if (!extendLocationFound)
		{
			ASSERT_FAIL("Invalid extend() call. No name specified for extend. Location: %s", extendLocation.c_str());
		}

		ASSERT_MESSAGE(info[0]->IsObject(), "Invalid extend() call. No implementation object specified. Location: %s", extendLocation.c_str());
		implementationObject = info[0]->ToObject();
	}
	else if (info.Length() == 2)
	{
		ASSERT_MESSAGE(info[0]->IsString(), "Invalid extend() call. No name for extend specified. Location: %s", extendLocation.c_str());
		ASSERT_MESSAGE(info[1]->IsObject(), "Invalid extend() call. Named extend should be called with second object parameter containing overridden methods. Location: %s", extendLocation.c_str());

		DEBUG_WRITE("InterfaceConstructorCallback: getting extend name");
		v8ExtendName = info[0]->ToString();
		implementationObject = info[1]->ToObject();
	}
	else
	{
		ASSERT_FAIL("Invalid extend() call. Location: %s", extendLocation.c_str());
	}

	auto className = node->m_implType;
	auto extendName = ConvertToString(v8ExtendName);
	auto extendNameAndLocation = extendLocation + extendName;
	SetInstanceMetadata(info.GetIsolate(), implementationObject, node);

	//@@@ Refactor
	string fullClassName = CreateFullClassName(className, extendNameAndLocation);
	thiz->SetHiddenValue(ConvertToV8String("implClassName"), ConvertToV8String(fullClassName));
	//

	jclass generatedClass = s_resolveClass(fullClassName, implementationObject);
	implementationObject->SetHiddenValue(ConvertToV8String(fullClassName), External::New(Isolate::GetCurrent(), generatedClass));//

	implementationObject->SetPrototype(thiz->GetPrototype());
	thiz->SetPrototype(implementationObject);
	thiz->SetHiddenValue(ConvertToV8String("t::implObj"), implementationObject);

	ArgsWrapper argWrapper(info, ArgType::Interface, Handle<Object>());

	auto success = s_registerInstance(thiz, fullClassName, argWrapper, implementationObject, true);

	assert(success);
}
开发者ID:frodoking,项目名称:NativeScriptAndroidRuntime,代码行数:58,代码来源:MetadataNode.cpp

示例13: VoidPointerCallback

void CallbackInterfaces::VoidPointerCallback(const v8::FunctionCallbackInfo<v8::Value>& args)
{
	Types::CallbackInfoIMPL cb(args);

	v8::Handle<v8::External> ext = v8::Handle<v8::External>::Cast(args.Data());
	Types::VoidPFunction icb = (Types::VoidPFunction)ext->Value();

	args.GetReturnValue().Set((int)icb(cb));
}
开发者ID:AddictArts,项目名称:Flathead,代码行数:9,代码来源:CallbackInterfaces.cpp

示例14: MethodCallback

void MetadataNode::MethodCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
	SET_PROFILER_FRAME();

	auto e = info.Data().As<External>();

	auto callbackData = reinterpret_cast<MethodCallbackData*>(e->Value());

	auto& candidates = callbackData->candidates;

	auto className = callbackData->node->m_name;
	auto methodName = candidates.front().name;

	int argLength = info.Length();
	int count = 0;
	MetadataEntry *entry = nullptr;
	for (auto& c: candidates)
	{
		if (c.paramCount == argLength)
		{
			if (++count > 1)
				break;
			entry = &c;
		}
	}

	auto thiz = info.This();

	auto isSuper = false;
	const auto& first = candidates.front();
	if (!first.isStatic)
	{
		auto extededClassName = thiz->GetHiddenValue(ConvertToV8String("implClassName"));
		isSuper = !extededClassName.IsEmpty();
		if (!isSuper)
		{
			auto superValue = thiz->GetHiddenValue(ConvertToV8String("issupervalue"));
			isSuper = !superValue.IsEmpty();
		}
	}

	// TODO: refactor this
	if (isSuper && (className == "com/tns/NativeScriptActivity"))
	{
		className = "android/app/Activity";
	}

	if ((methodName == V8StringConstants::VALUE_OF) && (argLength == 0))
	{
		info.GetReturnValue().Set(thiz);
	}
	else
	{
		s_callJavaMethod(thiz, className, methodName, entry, first.isStatic, isSuper, info);
	}
}
开发者ID:frodoking,项目名称:NativeScriptAndroidRuntime,代码行数:56,代码来源:MetadataNode.cpp

示例15: runtime_error

AdblockPlus::JsEnginePtr AdblockPlus::JsEngine::FromArguments(const v8::FunctionCallbackInfo<v8::Value>& arguments)
{
  const v8::Local<const v8::External> external =
      v8::Local<const v8::External>::Cast(arguments.Data());
  std::weak_ptr<JsEngine>* data =
      static_cast<std::weak_ptr<JsEngine>*>(external->Value());
  JsEnginePtr result = data->lock();
  if (!result)
    throw std::runtime_error("Oops, our JsEngine is gone, how did that happen?");
  return result;
}
开发者ID:LTears,项目名称:libadblockplus-vs2013,代码行数:11,代码来源:JsEngine.cpp


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