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


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

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


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

示例1: jsObjectToJavaFunction

jobject TypeConverter::jsObjectToJavaFunction(JNIEnv *env, v8::Handle<v8::Object> jsObject)
{
	Persistent<Function> jsFunction = Persistent<Function>::New(Handle<Function>::Cast(jsObject));
	jsFunction.MarkIndependent();

	jlong ptr = (jlong) *jsFunction;
	return env->NewObject(JNIUtil::v8FunctionClass, JNIUtil::v8FunctionInitMethod, ptr);
}
开发者ID:GertjanSmits,项目名称:titanium_mobile,代码行数:8,代码来源:TypeConverter.cpp

示例2: New

void Shape::New(const v8::FunctionCallbackInfo<Value>& args)
{
  HandleScope scope;
  Handle<Object> self = args.Holder();
  Shape *shape;

  if (args[0]->IsExternal())
  {
    Local<External> ext = Local<External>::Cast(args[0]);
    void *ptr = ext->Value();
    shape = static_cast<Shape*>(ptr);
    shape->Wrap(args.Holder());
  }
  else
  {
    shapeObj *s = (shapeObj *)msSmallMalloc(sizeof(shapeObj));

    msInitShape(s);
    if(args.Length() >= 1) {
      s->type = args[0]->Int32Value();
    }
    else {
      s->type = MS_SHAPE_NULL;
    }

    shape = new Shape(s);
    shape->Wrap(self);
  }

  /* create the attribute template. should use ObjectWrap in future */
  Handle<ObjectTemplate> attributes_templ = ObjectTemplate::New();
  attributes_templ->SetInternalFieldCount(2);
  attributes_templ->SetNamedPropertyHandler(attributeGetValue,
                                            attributeSetValue);
  Handle<Object> attributes = attributes_templ->NewInstance();
  map<string, int> *attributes_map = new map<string, int>();
  attributes->SetInternalField(0, External::New(attributes_map));
  attributes->SetInternalField(1, External::New(shape->get()->values));  
  attributes->SetHiddenValue(String::New("__parent__"), self);

  if (shape->layer) {
    for (int i=0; i<shape->layer->numitems; ++i) {
      (*attributes_map)[string(shape->layer->items[i])] = i;
    }
  }

  Persistent<Object> pattributes;
  pattributes.Reset(Isolate::GetCurrent(), attributes);
  pattributes.MakeWeak(attributes_map, attributeWeakCallback);
  pattributes.MarkIndependent();

  self->Set(String::New("attributes"), attributes);
}
开发者ID:BentleySystems,项目名称:mapserver,代码行数:53,代码来源:shape.cpp

示例3: readJsFile

Handle<Value> TiRootObject::_require(void* userContext, TiObject* caller, const Arguments& args)
{
	HandleScope scope;
	Local<Object> globalObject = TitaniumRuntime::getContenxt()->Global();

	Handle<Value> nativeModule = TiModuleRegistry::GetModule(QString(*String::Utf8Value(args[0]->ToString())));
	if(!nativeModule->IsUndefined())
	{
		return scope.Close(nativeModule);
	}
	QString fileName = Ti::TiHelper::QStringFromValue(args[0]).append(".js");
	QString filePath = Ti::TiHelper::getAssetPath(fileName).prepend("app/native/");
	Local<Value> existingModule = globalObject->GetHiddenValue(Ti::TiHelper::ValueFromQString(fileName)->ToString());
	if(!existingModule.IsEmpty() && !existingModule->IsUndefined())
	{
		return scope.Close(existingModule);
	}

	QString js = readJsFile(filePath);
	if(js.isEmpty()) {
		ThrowException(String::New(
								QString("Module not found ").append(fileName).toLocal8Bit().constData()
						));
		return scope.Close(Undefined());
	}
	js.prepend("(function(){"
			"var __vars = {};"
			"__vars.exports = {};"
			"__vars.module = {exports:__vars.exports};"
			"var module = __vars.module;"
			"var exports = __vars.exports;");
	js.append("\nreturn __vars.module.exports;"
			"})();");


	Handle<Script> script = Script::Compile(Ti::TiHelper::ValueFromQString(js)->ToString() , Ti::TiHelper::ValueFromQString(fileName));
	TryCatch tryCatch;
	if (script.IsEmpty())
	{
    	Ti::TiErrorScreen::ShowWithTryCatch(tryCatch);
		return scope.Close(Undefined());
	}
	Persistent<Value> result = Persistent<Value>::New(script->Run());
	result.MarkIndependent();
	if (result.IsEmpty())
	{
    	Ti::TiErrorScreen::ShowWithTryCatch(tryCatch);
		return scope.Close(Undefined());
	}
	globalObject->SetHiddenValue(Ti::TiHelper::ValueFromQString(fileName)->ToString(), result);
	return scope.Close(result);
}
开发者ID:pec1985,项目名称:titanium_mobile_blackberry,代码行数:52,代码来源:TiRootObject.cpp


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