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


C++ v8::FunctionCallbackInfo类代码示例

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


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

示例1: create

void VBOModule::create(const v8::FunctionCallbackInfo<v8::Value>& args) {
  v8::Isolate* isolate = args.GetIsolate();
  v8::HandleScope scope(isolate);
  
  VboRef vbo;
  
  if(args.Length() == 2){
    VboRef vbo = Vbo::create(
      args[1]->ToUint32()->Value() // GLenum target
    );
  } else if(args.Length() == 4){
    
    // TODO: Support other array data types as well
    if(args[2]->IsNumber()){
      vbo = Vbo::create(
        args[1]->ToUint32()->Value(),
        args[2]->ToUint32()->Value(),
        nullptr,
        args[3]->ToUint32()->Value()
      );
    } else {
      Local<Float32Array> data = args[2].As<Float32Array>();
      
      // GLenum target, GLsizeiptr allocationSize, const void *data, GLenum usage
      vbo = Vbo::create(
        args[1]->ToUint32()->Value(),
        data->ByteLength(),
        *data,
        args[3]->ToUint32()->Value()
      );
    }
  }
  
  StaticFactory::put<Vbo>( isolate, vbo, args[0]->ToObject() );
  
  // TODO: throw isolate error on wrong arguments
  return;
}
开发者ID:kommander,项目名称:cinderjs,代码行数:38,代码来源:vbo.cpp

示例2: VideoCapture

void
HumixFaceRec::StartCam(const v8::FunctionCallbackInfo<v8::Value>& info) {

    v8::Local<v8::Integer> devInt = info[0].As<v8::Integer>();

    if (mVideoCap != NULL) {
        //restart the capture by delete the old one
        delete mVideoCap;
    }
    // Get a handle to the Video device:
    mVideoCap = new VideoCapture(devInt->Value());
    mVideoCap->set(CV_CAP_PROP_FRAME_WIDTH, 640);
    mVideoCap->set(CV_CAP_PROP_FRAME_HEIGHT, 480);

    // sleep 1 sec, waiting for camera warmup
    printf("waiting for camera.. %d\n", devInt->Value());
    sleep(1);

    if (!mVideoCap->isOpened()) {
        return info.GetReturnValue().Set(false);
    }
    info.GetReturnValue().Set(true);
}
开发者ID:project-humix,项目名称:humix-facerec-module,代码行数:23,代码来源:HumixFaceRec.cpp

示例3: getNamedItems

void V8HTMLAllCollection::namedItemMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<>, name, info[0]);

    HTMLAllCollection* imp = V8HTMLAllCollection::toNative(info.Holder());
    v8::Handle<v8::Value> result = getNamedItems(imp, name, info);

    if (result.IsEmpty()) {
        v8SetReturnValueNull(info);
        return;
    }

    v8SetReturnValue(info, result);
}
开发者ID:wangshijun,项目名称:Blink,代码行数:14,代码来源:V8HTMLAllCollectionCustom.cpp

示例4: exceptionState

void V8MutationObserver::constructorCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    ExceptionState exceptionState(ExceptionState::ConstructionContext, "MutationObserver", info.Holder(), info.GetIsolate());
    if (info.Length() < 1) {
        exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(1, info.Length()));
        exceptionState.throwIfNeeded();
        return;
    }

    v8::Local<v8::Value> arg = info[0];
    if (!arg->IsFunction()) {
        exceptionState.throwTypeError("Callback argument must be a function");
        exceptionState.throwIfNeeded();
        return;
    }

    v8::Local<v8::Object> wrapper = info.Holder();

    RawPtr<MutationCallback> callback = V8MutationCallback::create(v8::Local<v8::Function>::Cast(arg), wrapper, ScriptState::current(info.GetIsolate()));
    RawPtr<MutationObserver> observer = MutationObserver::create(callback.release());

    v8SetReturnValue(info, V8DOMWrapper::associateObjectWithWrapper(info.GetIsolate(), observer.get(), &wrapperTypeInfo, wrapper));
}
开发者ID:aobzhirov,项目名称:ChromiumGStreamerBackend,代码行数:23,代码来源:V8MutationObserverCustom.cpp

示例5: New

void UnZip_Wrap::New(const v8::FunctionCallbackInfo<v8::Value>& args) {
  Isolate* isolate = Isolate::GetCurrent();
  HandleScope scope(isolate);

  if (args.IsConstructCall()) {
    // Invoked as constructor: `new UnZip_Wrap(...)`
    UnZip_Wrap* obj = nullptr;

    if(args.Length()>1) {
      if(args[0]->IsString() && args[1]->IsString()) {
        Local<String> fileName = args[0]->ToString(),folder = args[1]->ToString();
        obj = new UnZip_Wrap(fileName,folder);
      }
    } else {
        //error goes here
    }

    if ( obj != nullptr ) {
      obj->Wrap(args.This());
      args.GetReturnValue().Set(args.This());
    }
  }
}
开发者ID:ayoubserti,项目名称:node-unzip,代码行数:23,代码来源:unzip_node.cpp

示例6: jsCreate

void JsVlcVideo::jsCreate( const v8::FunctionCallbackInfo<v8::Value>& args )
{
    using namespace v8;

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

    Local<Object> thisObject = args.Holder();
    if( args.IsConstructCall() && thisObject->InternalFieldCount() > 0 ) {
        JsVlcPlayer* jsPlayer =
            ObjectWrap::Unwrap<JsVlcPlayer>( Handle<Object>::Cast( args[0] ) );
        if( jsPlayer ) {
            JsVlcVideo* jsPlaylist = new JsVlcVideo( thisObject, jsPlayer );
            args.GetReturnValue().Set( thisObject );
        }
    } else {
        Local<Function> constructor =
            Local<Function>::New( isolate, _jsConstructor );
        Local<Value> argv[] = { args[0] };
        args.GetReturnValue().Set(
            constructor->NewInstance( sizeof( argv ) / sizeof( argv[0] ), argv ) );
    }
}
开发者ID:Ivshti,项目名称:WebChimera.js,代码行数:23,代码来源:JsVlcVideo.cpp

示例7: jsCreate

void JsVlcPlayer::jsCreate( const v8::FunctionCallbackInfo<v8::Value>& args )
{
    using namespace v8;

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

    Local<Object> thisObject = args.Holder();
    if( args.IsConstructCall() ) {
        Local<Array> options;
        if( args.Length() == 1 && args[0]->IsArray() ) {
            options = Local<Array>::Cast( args[0] );
        }

        JsVlcPlayer* jsPlayer = new JsVlcPlayer( thisObject, options );
        args.GetReturnValue().Set( jsPlayer->handle() );
    } else {
        Local<Value> argv[] = { args[0] };
        Local<Function> constructor =
            Local<Function>::New( isolate, _jsConstructor );
        args.GetReturnValue().Set( constructor->NewInstance( sizeof( argv ) / sizeof( argv[0] ), argv ) );
    }
}
开发者ID:EdZava,项目名称:WebChimera.js,代码行数:23,代码来源:JsVlcPlayer.cpp

示例8: voidMethodDocumentMethod

static void voidMethodDocumentMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    ExceptionState exceptionState(ExceptionState::ExecutionContext, "voidMethodDocument", "TestInterface3", info.Holder(), info.GetIsolate());
    if (UNLIKELY(info.Length() < 2)) {
        setMinimumArityTypeError(exceptionState, 2, info.Length());
        exceptionState.throwIfNeeded();
        return;
    }
    Document* document;
    double d;
    {
        document = V8Document::toImplWithTypeCheck(info.GetIsolate(), info[0]);
        if (!document) {
            exceptionState.throwTypeError("parameter 1 is not of type 'Document'.");
            exceptionState.throwIfNeeded();
            return;
        }
        d = toRestrictedDouble(info.GetIsolate(), info[1], exceptionState);
        if (exceptionState.throwIfNeeded())
            return;
    }
    TestPartialInterface4::voidMethodDocument(document, d);
}
开发者ID:joone,项目名称:blink-crosswalk,代码行数:23,代码来源:V8TestInterface3.cpp

示例9: exceptionState

void V8HTMLOptionsCollection::addMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    ExceptionState exceptionState(ExceptionState::ExecutionContext, "add", "HTMLOptionsCollection", info.Holder(), info.GetIsolate());
    if (!V8HTMLOptionElement::hasInstance(info[0], info.GetIsolate(), worldType(info.GetIsolate()))) {
        exceptionState.throwTypeError("The element provided was not an HTMLOptionElement.");
    } else {
        HTMLOptionsCollection* imp = V8HTMLOptionsCollection::toNative(info.Holder());
        HTMLOptionElement* option = V8HTMLOptionElement::toNative(v8::Handle<v8::Object>(v8::Handle<v8::Object>::Cast(info[0])));

        if (info.Length() < 2) {
            imp->add(option, exceptionState);
        } else {
            bool ok;
            V8TRYCATCH_VOID(int, index, toInt32(info[1], ok));
            if (!ok)
                exceptionState.throwTypeError("The index provided could not be interpreted as an integer.");
            else
                imp->add(option, index, exceptionState);
        }
    }

    exceptionState.throwIfNeeded();
}
开发者ID:Igalia,项目名称:blink,代码行数:23,代码来源:V8HTMLOptionsCollectionCustom.cpp

示例10: join

result_t path_base::join(const v8::FunctionCallbackInfo<v8::Value> &args, exlib::string &retVal)
{
    exlib::string strBuffer;
    int32_t argc = args.Length();
    int32_t i;

    for (i = 0; i < argc; i++)
    {
        v8::String::Utf8Value s(args[i]);
        pathAdd(strBuffer, *s);
    }

    return normalize(strBuffer, retVal);
}
开发者ID:anlebcoder,项目名称:fibjs,代码行数:14,代码来源:path.cpp

示例11: Execvp

//v8::Handle<v8::Value> Execvp(const v8::Arguments& args) {
void Execvp(const v8::FunctionCallbackInfo<v8::Value>& args) {
   //v8::HandleScope scope;
   v8::Isolate* isolate = args.GetIsolate();
   
   // check input
   std::vector<std::string> str_vec = detail::parse_arguments(isolate, args);
   if(str_vec.size() == 0) {
      //return scope.Close(v8::Integer::New(-1));
      args.GetReturnValue().Set(v8::Integer::New(isolate, -1));
      return;
   }
   std::vector<char*> argv = detail::to_argv(str_vec);

   // get ready for the exec
   int status;
   detail::unset_cloexec(0);
   detail::unset_cloexec(1);
   detail::unset_cloexec(2);
   detail::handle_error(status = execvp(argv[0], &argv[0]), "execvp");
   
   //return scope.Close(v8::Integer::New(status));
   args.GetReturnValue().Set(v8::Integer::New(isolate, status));
}
开发者ID:IanHG,项目名称:node-easyexec,代码行数:24,代码来源:easyexec.cpp

示例12: partial2VoidMethodMethod

static void partial2VoidMethodMethod(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    ExceptionState exceptionState(ExceptionState::ExecutionContext, "partial2VoidMethod", "TestInterface", info.Holder(), info.GetIsolate());
    switch (std::min(1, info.Length())) {
    case 0:
        break;
    case 1:
        if (V8Node::hasInstance(info[0], info.GetIsolate())) {
            partial2VoidMethod3Method(info);
            return;
        }
        if (true) {
            partial2VoidMethod2Method(info);
            return;
        }
        break;
    default:
        break;
    }
    exceptionState.throwTypeError("No function was found that matched the signature provided.");
    exceptionState.throwIfNeeded();
    return;
}
开发者ID:joone,项目名称:chromium-crosswalk,代码行数:23,代码来源:V8TestInterfacePartial.cpp

示例13: tryCatch

void V8InjectedScriptHost::evalCallback(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    v8::Isolate* isolate = info.GetIsolate();
    if (info.Length() < 1) {
        isolate->ThrowException(v8::Exception::Error(v8::String::NewFromUtf8(isolate, "One argument expected.")));
        return;
    }

    v8::Local<v8::String> expression = info[0]->ToString(isolate);
    if (expression.IsEmpty()) {
        isolate->ThrowException(v8::Exception::Error(v8::String::NewFromUtf8(isolate, "The argument must be a string.")));
        return;
    }

    ASSERT(isolate->InContext());
    v8::TryCatch tryCatch(isolate);
    v8::Local<v8::Value> result;
    if (!v8Call(V8ScriptRunner::compileAndRunInternalScript(expression, info.GetIsolate()), result, tryCatch)) {
        v8SetReturnValue(info, tryCatch.ReThrow());
        return;
    }
    v8SetReturnValue(info, result);
}
开发者ID:golden628,项目名称:ChromiumGStreamerBackend,代码行数:23,代码来源:V8InjectedScriptHost.cpp

示例14: constructor4

static void constructor4(const v8::FunctionCallbackInfo<v8::Value>& info)
{
    ExceptionState exceptionState(ExceptionState::ConstructionContext, "TestInterfaceConstructor", info.Holder(), info.GetIsolate());
    V8StringResource<> arg;
    V8StringResource<> arg2;
    V8StringResource<> arg3;
    {
        TOSTRING_VOID_INTERNAL(arg, info[0]);
        TOSTRING_VOID_INTERNAL(arg2, info[1]);
        TOSTRING_VOID_INTERNAL(arg3, info[2]);
    }
    ScriptState* scriptState = ScriptState::current(info.GetIsolate());
    ExecutionContext* executionContext = currentExecutionContext(info.GetIsolate());
    Document& document = *toDocument(currentExecutionContext(info.GetIsolate()));
    RefPtr<TestInterfaceConstructor> impl = TestInterfaceConstructor::create(scriptState, executionContext, document, arg, arg2, arg3, exceptionState);
    if (exceptionState.hadException()) {
        exceptionState.throwIfNeeded();
        return;
    }
    v8::Local<v8::Object> wrapper = info.Holder();
    impl->associateWithWrapper(info.GetIsolate(), &V8TestInterfaceConstructor::wrapperTypeInfo, wrapper);
    v8SetReturnValue(info, wrapper);
}
开发者ID:eth-srl,项目名称:BlinkER,代码行数:23,代码来源:V8TestInterfaceConstructor.cpp

示例15: HandleScope

int TNodeJsUtil::GetArgInt32(const v8::FunctionCallbackInfo<v8::Value>& Args, const int& ArgN, const TStr& Property) {
	v8::Isolate* Isolate = v8::Isolate::GetCurrent();
	v8::HandleScope HandleScope(Isolate);

	EAssertR(Args.Length() > ArgN, "insufficient number of arguments!");

	EAssertR(Args[ArgN]->IsObject() && Args[ArgN]->ToObject()->Has(v8::String::NewFromUtf8(Isolate, Property.CStr())), TStr::Fmt("Argument %d, missing property %s", ArgN, Property.CStr()).CStr());

	v8::Handle<v8::Value> Val = Args[ArgN]->ToObject()->Get(v8::String::NewFromUtf8(Isolate, Property.CStr()));
	bool IsInt = Val->IsInt32();
	EAssertR(IsInt,
		TStr::Fmt("Argument %d, property %s expected to be int32", ArgN, Property.CStr()).CStr());
	return Val->ToNumber()->Int32Value();	
}
开发者ID:amrsobhy,项目名称:qminer,代码行数:14,代码来源:nodeutil.cpp


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