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


C++ Persistent::SetInternalField方法代码示例

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


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

示例1: Null

Handle<Value> JsEngine::AnyToV8(jsvalue v, int32_t contextId)
{
	if (v.type == JSVALUE_TYPE_EMPTY) {
		return Handle<Value>();
	}
	if (v.type == JSVALUE_TYPE_NULL) {
        return Null();
    }
    if (v.type == JSVALUE_TYPE_BOOLEAN) {
        return Boolean::New(v.value.i32);
    }
    if (v.type == JSVALUE_TYPE_INTEGER) {
        return Int32::New(v.value.i32);
    }
    if (v.type == JSVALUE_TYPE_NUMBER) {
        return Number::New(v.value.num);
    }
    if (v.type == JSVALUE_TYPE_STRING) {
        return String::New(v.value.str);
    }
    if (v.type == JSVALUE_TYPE_DATE) {
        return Date::New(v.value.num);
    }
	
    // Arrays are converted to JS native arrays.
    
    if (v.type == JSVALUE_TYPE_ARRAY) {
        Local<Array> a = Array::New(v.length);
        for(int i = 0; i < v.length; i++) {
            a->Set(i, AnyToV8(v.value.arr[i], contextId));
        }
        return a;        
    }
        
    // This is an ID to a managed object that lives inside the JsContext keep-alive
    // cache. We just wrap it and the pointer to the engine inside an External. A
    // managed error is still a CLR object so it is wrapped exactly as a normal
    // managed object.
    if (v.type == JSVALUE_TYPE_MANAGED || v.type == JSVALUE_TYPE_MANAGED_ERROR) {
		ManagedRef* ref = new ManagedRef(this, contextId, v.length);
		Local<Object> object = (*(managed_template_))->InstanceTemplate()->NewInstance();
		if (object.IsEmpty()) {
			return Null();
		}
		
		Persistent<Object> persistent = Persistent<Object>::New(object);
		persistent->SetInternalField(0, External::New(ref));
		persistent.MakeWeak(NULL, managed_destroy);
        return persistent;
    }

    return Null();
}
开发者ID:Daniel15,项目名称:vroomjs,代码行数:53,代码来源:jsengine.cpp

示例2: RemoveFromComponentMap

   bool ScriptSystem::RemoveFromComponentMap(dtEntity::ComponentType ct, dtEntity::EntityId eid)
   {
      ComponentMap::iterator it = mComponentMap.find(std::make_pair(ct, eid));
      if(it == mComponentMap.end())
      {
         return false;
      }
      HandleScope scope;
      Persistent<Object> obj = it->second;
      assert(!obj.IsEmpty() && obj->IsObject());
      // invalidate component wrapper
      obj->SetInternalField(0, External::New(0));
      obj.Dispose();
      mComponentMap.erase(it);
      V8::AdjustAmountOfExternalAllocatedMemory(-(int)sizeof(dtEntity::Component));
      return true;

   }
开发者ID:mathieu,项目名称:dtEntity,代码行数:18,代码来源:scriptcomponent.cpp

示例3: Image

	Image *Image::CreateFromFile(const char *file)
	{
		ce::Image *baseImage = ce::Image::CreateFromFile(file);

		if(!baseImage)
			return 0;

		Image *image = new Image();
		image->m_image = baseImage;

		Handle<ObjectTemplate> objectTemplate = ObjectTemplate::New();
		objectTemplate->SetInternalFieldCount(1);

		HandleScope handleScope;

		Persistent<Object> instance = Persistent<Object>::New(objectTemplate->NewInstance());
		instance->SetInternalField(0, External::New(image));
		image->m_instance = instance;

		return image;
	}
开发者ID:zadanwr,项目名称:sandbox,代码行数:21,代码来源:Image.cpp


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