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


C++ Local::SetInternalFieldCount方法代码示例

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


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

示例1: handleScope

// Wraps 'this' in a Javascript object.
Handle<Object> JsContext::wrap() {
    // Handle scope for temporary handles.
    EscapableHandleScope handleScope(fGlobal->getIsolate());

    // Fetch the template for creating JavaScript JsContext wrappers.
    // It only has to be created once, which we do on demand.
    if (gContextTemplate.IsEmpty()) {
        Local<ObjectTemplate> localTemplate = ObjectTemplate::New();

        // Add a field to store the pointer to a JsContext instance.
        localTemplate->SetInternalFieldCount(1);

        this->addAttributesAndMethods(localTemplate);

        gContextTemplate.Reset(fGlobal->getIsolate(), localTemplate);
    }
    Handle<ObjectTemplate> templ =
            Local<ObjectTemplate>::New(fGlobal->getIsolate(), gContextTemplate);

    // Create an empty JsContext wrapper.
    Local<Object> result = templ->NewInstance();

    // Wrap the raw C++ pointer in an External so it can be referenced
    // from within JavaScript.
    Handle<External> contextPtr = External::New(fGlobal->getIsolate(), this);

    // Store the context pointer in the JavaScript wrapper.
    result->SetInternalField(0, contextPtr);

    // Return the result through the current handle scope.  Since each
    // of these handles will go away when the handle scope is deleted
    // we need to call Close to let one, the result, escape into the
    // outer handle scope.
    return handleScope.Escape(result);
}
开发者ID:venkatarajasekhar,项目名称:Qt,代码行数:36,代码来源:JsContext.cpp

示例2: handle_scope

Local<Object> wrap_master_player(Isolate* isolate, Master_Player *player) {
	EscapableHandleScope handle_scope(isolate);

	Local<ObjectTemplate> localTemplate = ObjectTemplate::New(isolate);
	localTemplate->SetInternalFieldCount(1);
	Local<External> player_ptr = External::New(isolate, player);
	//将指针存在V8对象内部
	Local<Object> player_obj = localTemplate->NewInstance(isolate->GetCurrentContext()).ToLocalChecked();
	player_obj->SetInternalField(0, player_ptr);

	// 为当前对象设置其对外函数接口
	player_obj->Set(isolate->GetCurrentContext(), String::NewFromUtf8(isolate, "get_save_data_buffer", NewStringType::kNormal).ToLocalChecked(),
		                    FunctionTemplate::New(isolate, get_master_player_save_data_buffer)->GetFunction()) ;

	player_obj->Set(isolate->GetCurrentContext(), String::NewFromUtf8(isolate, "respond_success_result", NewStringType::kNormal).ToLocalChecked(),
	                    FunctionTemplate::New(isolate, master_player_respond_success_result)->GetFunction()) ;

	player_obj->Set(isolate->GetCurrentContext(), String::NewFromUtf8(isolate, "respond_error_result", NewStringType::kNormal).ToLocalChecked(),
	                    FunctionTemplate::New(isolate, master_player_respond_error_result)->GetFunction()) ;

	player_obj->Set(isolate->GetCurrentContext(), String::NewFromUtf8(isolate, "sync_data_to_game", NewStringType::kNormal).ToLocalChecked(),
			                    FunctionTemplate::New(isolate, sync_data_to_game)->GetFunction()) ;

	return handle_scope.Escape(player_obj);
}
开发者ID:firehot,项目名称:server,代码行数:25,代码来源:Player_Wrap.cpp

示例3: handle_scope

Local<ObjectTemplate> JsHttpRequestProcessor::MakeRequestTemplate(
    Isolate* isolate) {
  EscapableHandleScope handle_scope(isolate);

  Local<ObjectTemplate> result = ObjectTemplate::New(isolate);
  result->SetInternalFieldCount(1);

  // Add accessors for each of the fields of the request.
  result->SetAccessor(
      String::NewFromUtf8(isolate, "path", NewStringType::kInternalized)
          .ToLocalChecked(),
      GetPath);
  result->SetAccessor(
      String::NewFromUtf8(isolate, "referrer", NewStringType::kInternalized)
          .ToLocalChecked(),
      GetReferrer);
  result->SetAccessor(
      String::NewFromUtf8(isolate, "host", NewStringType::kInternalized)
          .ToLocalChecked(),
      GetHost);
  result->SetAccessor(
      String::NewFromUtf8(isolate, "userAgent", NewStringType::kInternalized)
          .ToLocalChecked(),
      GetUserAgent);

  // Again, return the result through the current handle scope.
  return handle_scope.Escape(result);
}
开发者ID:ACEZLY,项目名称:server,代码行数:28,代码来源:V8_Process.cpp

示例4:

Local<Object> ItemObject::createInstance()
{
	HandleScope handleScope;
	
	// Create the function template
	
	Local<FunctionTemplate> functionTemplate = FunctionTemplate::New();
	functionTemplate->SetClassName(String::New("Item"));
	
	// Create the object template
	
	Local<ObjectTemplate> objectTemplate = functionTemplate->InstanceTemplate();
	objectTemplate->SetInternalFieldCount(1);
	
	// Create an object instance
	
	Local<Object> objectInstance = objectTemplate->NewInstance();
	objectInstance->SetInternalField(0, External::New(this));
	
	// Add functions to object instance
	
	/*
	Local<FunctionTemplate> printTemplate = FunctionTemplate::New(print);
	Local<Function> printFunction = printTemplate->GetFunction();
	objectInstance->Set(String::New("print"), printFunction);
	
	Local<FunctionTemplate> inputTemplate = FunctionTemplate::New(input);
	Local<Function> inputFunction = inputTemplate->GetFunction();
	objectInstance->Set(String::New("input"), inputFunction);
	*/
	
	return handleScope.Close(objectInstance);
}
开发者ID:bagobor,项目名称:BitRPG,代码行数:33,代码来源:ItemObject.cpp

示例5: initJsApi

void JsVlcVideo::initJsApi()
{
    JsVlcDeinterlace::initJsApi();

    using namespace v8;

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

    Local<FunctionTemplate> constructorTemplate = FunctionTemplate::New( isolate, jsCreate );
    constructorTemplate->SetClassName(
        String::NewFromUtf8( isolate, "VlcVideo", v8::String::kInternalizedString ) );

    Local<ObjectTemplate> protoTemplate = constructorTemplate->PrototypeTemplate();
    Local<ObjectTemplate> instanceTemplate = constructorTemplate->InstanceTemplate();
    instanceTemplate->SetInternalFieldCount( 1 );

    SET_RO_PROPERTY( instanceTemplate, "count", &JsVlcVideo::count );

    SET_RO_PROPERTY( instanceTemplate, "deinterlace", &JsVlcVideo::deinterlace );

    SET_RW_PROPERTY( instanceTemplate, "track", &JsVlcVideo::track, &JsVlcVideo::setTrack );

    Local<Function> constructor = constructorTemplate->GetFunction();
    _jsConstructor.Reset( isolate, constructor );
}
开发者ID:Ivshti,项目名称:WebChimera.js,代码行数:26,代码来源:JsVlcVideo.cpp

示例6: Init

void DecoderNotifier::Init(){
  HandleScope scope;
  
  Local<ObjectTemplate> templ = ObjectTemplate::New();
  templ->SetInternalFieldCount(1);
  
  DecoderNotifier::templ = Persistent<ObjectTemplate>::New(templ);
}
开发者ID:OptimalBits,项目名称:navcodec,代码行数:8,代码来源:navformat.cpp

示例7: handle_scope

Local<ObjectTemplate> NaObject::MakeObjectTemplate(Isolate * isolate)
{
	EscapableHandleScope handle_scope(isolate);

	Local<ObjectTemplate> result = ObjectTemplate::New(isolate);
	result->SetInternalFieldCount(1);

	// Again, return the result through the current handle scope.
	return handle_scope.Escape(result);
}
开发者ID:neoarc,项目名称:NaMacroJS,代码行数:10,代码来源:NaObject.cpp

示例8: initJsApi

void JsVlcPlaylist::initJsApi()
{
    JsVlcPlaylistItems::initJsApi();

    using namespace v8;

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

    Local<FunctionTemplate> constructorTemplate = FunctionTemplate::New( isolate, jsCreate );
    constructorTemplate->SetClassName( String::NewFromUtf8( isolate, "VlcPlaylist", v8::String::kInternalizedString ) );

    Local<ObjectTemplate> protoTemplate = constructorTemplate->PrototypeTemplate();
    Local<ObjectTemplate> instanceTemplate = constructorTemplate->InstanceTemplate();
    instanceTemplate->SetInternalFieldCount( 1 );

    protoTemplate->Set( String::NewFromUtf8( isolate, "Normal", v8::String::kInternalizedString ),
                        Integer::New( isolate, static_cast<int>( PlaybackMode::Normal ) ),
                        static_cast<v8::PropertyAttribute>( ReadOnly | DontDelete ) );
    protoTemplate->Set( String::NewFromUtf8( isolate, "Loop", v8::String::kInternalizedString ),
                        Integer::New( isolate, static_cast<int>( PlaybackMode::Loop ) ),
                        static_cast<v8::PropertyAttribute>( ReadOnly | DontDelete ) );
    protoTemplate->Set( String::NewFromUtf8( isolate, "Single", v8::String::kInternalizedString ),
                        Integer::New( isolate, static_cast<int>( PlaybackMode::Single ) ),
                        static_cast<v8::PropertyAttribute>( ReadOnly | DontDelete ) );

    SET_RO_PROPERTY( instanceTemplate, "itemCount", &JsVlcPlaylist::itemCount );
    SET_RO_PROPERTY( instanceTemplate, "isPlaying", &JsVlcPlaylist::isPlaying );
    SET_RO_PROPERTY( instanceTemplate, "items", &JsVlcPlaylist::items );

    SET_RW_PROPERTY( instanceTemplate, "currentItem", &JsVlcPlaylist::currentItem, &JsVlcPlaylist::setCurrentItem );
    SET_RW_PROPERTY( instanceTemplate, "mode", &JsVlcPlaylist::mode, &JsVlcPlaylist::setMode );

    SET_METHOD( constructorTemplate, "add", &JsVlcPlaylist::add );
    SET_METHOD( constructorTemplate, "addWithOptions", &JsVlcPlaylist::addWithOptions );
    SET_METHOD( constructorTemplate, "play", &JsVlcPlaylist::play );
    SET_METHOD( constructorTemplate, "playItem", &JsVlcPlaylist::playItem );
    SET_METHOD( constructorTemplate, "pause", &JsVlcPlaylist::pause );
    SET_METHOD( constructorTemplate, "togglePause", &JsVlcPlaylist::togglePause );
    SET_METHOD( constructorTemplate, "stop",  &JsVlcPlaylist::stop );
    SET_METHOD( constructorTemplate, "next",  &JsVlcPlaylist::next );
    SET_METHOD( constructorTemplate, "prev",  &JsVlcPlaylist::prev );
    SET_METHOD( constructorTemplate, "clear",  &JsVlcPlaylist::clear );
    SET_METHOD( constructorTemplate, "removeItem",  &JsVlcPlaylist::removeItem );
    SET_METHOD( constructorTemplate, "advanceItem",  &JsVlcPlaylist::advanceItem );

    Local<Function> constructor = constructorTemplate->GetFunction();
    _jsConstructor.Reset( isolate, constructor );
}
开发者ID:DavidYangfei,项目名称:WebChimera.js,代码行数:49,代码来源:JsVlcPlaylist.cpp

示例9: initJsApi

void JsVlcAudio::initJsApi()
{
    using namespace v8;

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

    Local<FunctionTemplate> constructorTemplate = FunctionTemplate::New( isolate, jsCreate );
    constructorTemplate->SetClassName(
        String::NewFromUtf8( isolate, "VlcVideo", v8::String::kInternalizedString ) );

    Local<ObjectTemplate> protoTemplate = constructorTemplate->PrototypeTemplate();
    Local<ObjectTemplate> instanceTemplate = constructorTemplate->InstanceTemplate();
    instanceTemplate->SetInternalFieldCount( 1 );

    protoTemplate->Set( String::NewFromUtf8( isolate, "Error", v8::String::kInternalizedString ),
                        Integer::New( isolate, libvlc_AudioChannel_Error ),
                        static_cast<v8::PropertyAttribute>( ReadOnly | DontDelete ) );
    protoTemplate->Set( String::NewFromUtf8( isolate, "Stereo", v8::String::kInternalizedString ),
                        Integer::New( isolate, libvlc_AudioChannel_Stereo ),
                        static_cast<v8::PropertyAttribute>( ReadOnly | DontDelete ) );
    protoTemplate->Set( String::NewFromUtf8( isolate, "ReverseStereo", v8::String::kInternalizedString ),
                        Integer::New( isolate, libvlc_AudioChannel_RStereo ),
                        static_cast<v8::PropertyAttribute>( ReadOnly | DontDelete ) );
    protoTemplate->Set( String::NewFromUtf8( isolate, "Left", v8::String::kInternalizedString ),
                        Integer::New( isolate, libvlc_AudioChannel_Left ),
                        static_cast<v8::PropertyAttribute>( ReadOnly | DontDelete ) );
    protoTemplate->Set( String::NewFromUtf8( isolate, "Right", v8::String::kInternalizedString ),
                        Integer::New( isolate, libvlc_AudioChannel_Right ),
                        static_cast<v8::PropertyAttribute>( ReadOnly | DontDelete ) );
    protoTemplate->Set( String::NewFromUtf8( isolate, "Dolby", v8::String::kInternalizedString ),
                        Integer::New( isolate, libvlc_AudioChannel_Dolbys ),
                        static_cast<v8::PropertyAttribute>( ReadOnly | DontDelete ) );

    SET_RO_INDEXED_PROPERTY( instanceTemplate, &JsVlcAudio::description );

    SET_RO_PROPERTY( instanceTemplate, "count", &JsVlcAudio::count );

    SET_RW_PROPERTY( instanceTemplate, "track", &JsVlcAudio::track, &JsVlcAudio::setTrack );
    SET_RW_PROPERTY( instanceTemplate, "mute", &JsVlcAudio::muted, &JsVlcAudio::setMuted );
    SET_RW_PROPERTY( instanceTemplate, "volume", &JsVlcAudio::volume, &JsVlcAudio::setVolume );
    SET_RW_PROPERTY( instanceTemplate, "channel", &JsVlcAudio::channel, &JsVlcAudio::setChannel );
    SET_RW_PROPERTY( instanceTemplate, "delay", &JsVlcAudio::delay, &JsVlcAudio::setDelay );

    SET_METHOD( constructorTemplate, "toggleMute", &JsVlcAudio::toggleMute );

    Local<Function> constructor = constructorTemplate->GetFunction();
    _jsConstructor.Reset( isolate, constructor );
}
开发者ID:DavidYangfei,项目名称:WebChimera.js,代码行数:49,代码来源:JsVlcAudio.cpp

示例10: scope

void CanvasRenderingContext2D::Create(const v8::FunctionCallbackInfo<v8::Value>& args)
{
	auto isolate = args.GetIsolate();
	HandleScope scope(isolate);

	Local<ObjectTemplate> contextTemplate = ObjectTemplate::New(isolate);
	contextTemplate->SetInternalFieldCount(1);

	contextTemplate->Set(ConvertToV8String("__draw"), FunctionTemplate::New(isolate, &Draw));
	contextTemplate->Set(ConvertToV8String("__sizeChanged"), FunctionTemplate::New(isolate, &SizeChanged));

	contextTemplate->SetAccessor(ConvertToV8String("fillStyle"), &GetFillStyle, &SetFillStyle);
	contextTemplate->SetAccessor(ConvertToV8String("strokeStyle"), &GetStrokeStyle, &SetStrokeStyle);

	contextTemplate->Set(ConvertToV8String("arc"), FunctionTemplate::New(isolate, &Arc));
	contextTemplate->Set(ConvertToV8String("beginPath"), FunctionTemplate::New(isolate, &BeginPath));
	contextTemplate->Set(ConvertToV8String("bezierCurveTo"), FunctionTemplate::New(isolate, &BezierCurveTo));
	contextTemplate->Set(ConvertToV8String("clearRect"), FunctionTemplate::New(isolate, &ClearRect));
	contextTemplate->Set(ConvertToV8String("closePath"), FunctionTemplate::New(isolate, &ClosePath));
	contextTemplate->Set(ConvertToV8String("drawImage"), FunctionTemplate::New(isolate, &DrawImage));
	contextTemplate->Set(ConvertToV8String("fill"), FunctionTemplate::New(isolate, &Fill));
	contextTemplate->Set(ConvertToV8String("fillRect"), FunctionTemplate::New(isolate, &FillRect));
	contextTemplate->Set(ConvertToV8String("fillText"), FunctionTemplate::New(isolate, &FillText));
	contextTemplate->Set(ConvertToV8String("getImageData"), FunctionTemplate::New(isolate, &GetImageData));
	contextTemplate->Set(ConvertToV8String("lineTo"), FunctionTemplate::New(isolate, &LineTo));
	contextTemplate->Set(ConvertToV8String("measureText"), FunctionTemplate::New(isolate, &MeasureText));
	contextTemplate->Set(ConvertToV8String("moveTo"), FunctionTemplate::New(isolate, &MoveTo));
	contextTemplate->Set(ConvertToV8String("quadraticCurveTo"), FunctionTemplate::New(isolate, &QuadraticCurveTo));
	contextTemplate->Set(ConvertToV8String("restore"), FunctionTemplate::New(isolate, &Restore));
	contextTemplate->Set(ConvertToV8String("rotate"), FunctionTemplate::New(isolate, &Rotate));
	contextTemplate->Set(ConvertToV8String("save"), FunctionTemplate::New(isolate, &Save));
	contextTemplate->Set(ConvertToV8String("stroke"), FunctionTemplate::New(isolate, &Stroke));
	contextTemplate->Set(ConvertToV8String("translate"), FunctionTemplate::New(isolate, &Translate));

	Local<Object> newContext = contextTemplate->NewInstance();
	newContext->ForceSet(ConvertToV8String("canvas"), args[0]);
	newContext->ForceSet(ConvertToV8String("__kind"), ConvertToV8String("2d"));

	auto nativeContext = new CanvasRenderingContext2D();
	newContext->SetInternalField(0, External::New(isolate, nativeContext));

	Persistent<Object> persistentHandle(isolate, newContext);
	persistentHandle.SetWeak(nativeContext, &Deallocate);

	args.GetReturnValue().Set(newContext);
}
开发者ID:NativeScript,项目名称:nativescript-canvas,代码行数:46,代码来源:CanvasRenderingContext2D.cpp

示例11: Bind

void Point::Bind( Isolate* isolate, Handle< Context > context ) {
	// Get creation scope
	HandleScope scope( isolate );

	// Create constructor function and object template
	Local< FunctionTemplate > constructor = FunctionTemplate::New( Construct );
	Local< ObjectTemplate > templ = constructor->InstanceTemplate();
	templ->SetInternalFieldCount( 1 );

	// Set properties and methods
	templ->SetAccessor( String::New( "x" ), GetX, SetX );
	templ->SetAccessor( String::New( "y" ), GetY, SetY );
	templ->Set( String::New( "print" ), FunctionTemplate::New( Print ) );

	// Register constructor
	context->Global()->Set( String::New( "Point" ), constructor->GetFunction() );
}
开发者ID:TheCodeInside,项目名称:v8-example,代码行数:17,代码来源:point.cpp

示例12: Main

void Main(Local<Object> exports)
{
    Isolate *isolate = exports->GetIsolate();
    Local<FunctionTemplate> tpl = FunctionTemplate::New(isolate, constructor);
    tpl->InstanceTemplate()->SetInternalFieldCount(1);

    NODE_SET_PROTOTYPE_METHOD(tpl, "on", on);
    NODE_SET_PROTOTYPE_METHOD(tpl, "send", send);
    NODE_SET_PROTOTYPE_METHOD(tpl, "setUserData", setUserData);
    NODE_SET_PROTOTYPE_METHOD(tpl, "getUserData", getUserData);
    NODE_SET_PROTOTYPE_METHOD(tpl, "getFd", getFd);

    exports->Set(String::NewFromUtf8(isolate, "Server"), tpl->GetFunction());

    Local<ObjectTemplate> socketTemplate = ObjectTemplate::New(isolate);
    socketTemplate->SetInternalFieldCount(2);
    persistentSocket.Reset(isolate, socketTemplate->NewInstance());
}
开发者ID:iamapinan,项目名称:node-lws,代码行数:18,代码来源:addon.cpp

示例13: getValueObjectConstructor

/* arg0: Record constructed over the appropriate column list
   arg1: Array of field names
   arg2: Array of typeConverters 

   Returns: a constructor function that can be used to create native-backed 
   objects
*/
Handle<Value> getValueObjectConstructor(const Arguments &args) {
  DEBUG_MARKER(UDEB_DEBUG);
  HandleScope scope;
  Local<FunctionTemplate> ft = FunctionTemplate::New();
  Local<ObjectTemplate> inst = ft->InstanceTemplate();
  inst->SetInternalFieldCount(2);

  /* Initialize the mapData */
  Local<Object> mapData = Object::New();
  
  /* Store the record in the mapData at 0 */
  mapData->Set(0, args[0]);

  /* Build the ColumnHandlers and store them in the mapData at 1 */
  const Record * record = unwrapPointer<const Record *>(args[0]->ToObject());
  const uint32_t ncol = record->getNoOfColumns();
  ColumnHandlerSet *columnHandlers = new ColumnHandlerSet(ncol);
  for(unsigned int i = 0 ; i < ncol ; i++) {
    const NdbDictionary::Column * col = record->getColumn(i);
    size_t offset = record->getColumnOffset(i);
    ColumnHandler * handler = columnHandlers->getHandler(i);
    handler->init(col, offset, args[2]->ToObject()->Get(i));
  }
  Local<Object> jsHandlerSet = columnHandlerSetEnvelope.newWrapper();
  wrapPointerInObject<ColumnHandlerSet *>(columnHandlers, 
                                          columnHandlerSetEnvelope,
                                          jsHandlerSet);
  mapData->Set(1, jsHandlerSet);

  /* Create accessors for the mapped fields in the instance template.
     AccessorInfo.Data() for the accessor will hold the field number.
  */
  Local<Object> jsFields = args[1]->ToObject();
  for(unsigned int i = 0 ; i < ncol; i++) {
    Handle<String> fieldName = jsFields->Get(i)->ToString();
    inst->SetAccessor(fieldName, nroGetter, nroSetter, Number::New(i),
                      DEFAULT, DontDelete);
  }

  /* The generic constructor is the CallHandler */
  ft->SetCallHandler(nroConstructor, Persistent<Object>::New(mapData));

  return scope.Close(ft->GetFunction());
}
开发者ID:Bendalexis,项目名称:mysql-js,代码行数:51,代码来源:ValueObject.cpp

示例14: RegisterMyClass

void RegisterMyClass(Isolate* isolate, Local<ObjectTemplate> global)
{
	Local<ObjectTemplate> localTemplate = ObjectTemplate::New(isolate);
	localTemplate->SetInternalFieldCount(1);

	localTemplate->SetAccessor(
		String::NewFromUtf8(isolate, "num", NewStringType::kInternalized)
		.ToLocalChecked(),
		jsMyClassGetNumber,
		jsMyClassSetNumber);
	localTemplate->SetAccessor(
		String::NewFromUtf8(isolate, "name", NewStringType::kInternalized)
		.ToLocalChecked(),
		jsMyClassGetName,
		jsMyClassSetName);
	localTemplate->Set(
		String::NewFromUtf8(isolate, "Method1", NewStringType::kNormal)
		.ToLocalChecked(),
		FunctionTemplate::New(isolate, jsMyClassMethod1));
	localTemplate->Set(
		String::NewFromUtf8(isolate, "Method2", NewStringType::kNormal)
		.ToLocalChecked(),
		FunctionTemplate::New(isolate, jsMyClassMethod2));

	gMyClassTemplate.Reset(isolate, localTemplate);

	global->Set(
		String::NewFromUtf8(isolate, "MyClass", NewStringType::kNormal)
		.ToLocalChecked(),
		FunctionTemplate::New(isolate, jsCreateMyClass));
	global->Set(
		String::NewFromUtf8(isolate, "jsMyFunction", NewStringType::kNormal)
		.ToLocalChecked(),
		FunctionTemplate::New(isolate, jsMyFunction));
	global->Set(
		String::NewFromUtf8(isolate, "jsMyFunction1", NewStringType::kNormal)
		.ToLocalChecked(),
		FunctionTemplate::New(isolate, jsMyFunction1));
	global->Set(
		String::NewFromUtf8(isolate, "jsMyFunction2", NewStringType::kNormal)
		.ToLocalChecked(),
		FunctionTemplate::New(isolate, jsMyFunction2));
}
开发者ID:ACEZLY,项目名称:server,代码行数:43,代码来源:MyClass_Wrap.cpp

示例15: initJsObjectsTemplate

    void JSZCluster::initJsObjectsTemplate(v8::Isolate *isolate, v8::Handle<v8::Object> &global) {
        Local<String> jszClusterClassName = String::NewFromUtf8(isolate, JSZCLUSTER);
        // methods
        Local<String> getProperyByIdMethod = String::NewFromUtf8(isolate, GET_PROPERTY_BY_ID);
        Local<String> executeCmdByIdMethod = String::NewFromUtf8(isolate, EXECUTE_CMD_BY_ID);

        Local<FunctionTemplate> zClusterFunctionTemplate = FunctionTemplate::New(isolate, constructor,
                                                                                 External::New(isolate, this));
        zClusterFunctionTemplate->SetClassName(jszClusterClassName);
        Local<ObjectTemplate> zClusterInstanceTemplate = zClusterFunctionTemplate->InstanceTemplate();

        zClusterInstanceTemplate->SetInternalFieldCount(3);
        // attributes
        // functions
        zClusterInstanceTemplate->Set(getProperyByIdMethod, FunctionTemplate::New(isolate, jsGetPropertyById));
        zClusterInstanceTemplate->Set(executeCmdByIdMethod, FunctionTemplate::New(isolate, jsExecuteCmdById));
        global->Set(jszClusterClassName, zClusterFunctionTemplate->GetFunction());

        functionTemplate.Reset(isolate, zClusterFunctionTemplate);
    }
开发者ID:paoloach,项目名称:zdomus,代码行数:20,代码来源:JSZCluster.cpp


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