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


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

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


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

示例1: setPersistentFunc

	void setPersistentFunc(Persistent<Function>& pf,Handle<Value>& v){
		if(v->IsFunction()){
			if(!pf.IsEmpty()) pf.Dispose();
			pf = Persistent<Function>::New(Handle<Function>::Cast(v));
		}else if(v->IsNull()||v->IsUndefined()){
			if(pf.IsEmpty()) return;
			pf.Dispose();
			pf.Clear();
		}
	}
开发者ID:pgmsoul,项目名称:GitLib,代码行数:10,代码来源:v8base.cpp

示例2: Nil

static Handle<Value> Nil(const Arguments& args)
{
    HandleScope handle_scope;

    if (object_template_.IsEmpty()) {
        Handle<ObjectTemplate> raw_template = PrepareTemplate();
        object_template_ = Persistent<ObjectTemplate>::New(raw_template);
    }

    if (nil_instance_.IsEmpty()) {
        nil_instance_ = Persistent<Value>::New(object_template_->NewInstance());
    }
    
    return handle_scope.Close(nil_instance_);
}
开发者ID:temas,项目名称:node-nil,代码行数:15,代码来源:nil.cpp

示例3: context_scope

extern "C" Handle<Value> execute_string(Persistent<Context> context,
					const char* s,
					bool* is_exception) {
    // Create a stack-allocated handle scope.
    HandleScope handle_scope;

    // Enter the created context for compiling and
    // running the hello world script.
    Context::Scope context_scope(context);

    // Create a string containing the JavaScript source code.
    Handle<String> source = String::New(s);

    // Compile it
    Handle<Script> script = Script::Compile(source);

    // try-catch handler
    TryCatch trycatch;
    // Run it
    Persistent<Value> result = Persistent<Value>::New(script->Run());

    // Script->Run() returns an empty handle if the code threw an exception
    if (result.IsEmpty()) {
	*is_exception = true;
	Handle<Value> exception = trycatch.Exception();
	// String::AsciiValue exception_str(exception);
	return Persistent<Value>::New(exception);	
    }
    
    return result;
}
开发者ID:edumunoz,项目名称:MiXture,代码行数:31,代码来源:v8_helper.cpp

示例4: TitaniumCountlyAndroidMessaging_dispose

static void TitaniumCountlyAndroidMessaging_dispose()
{
	HandleScope scope;
	if (bindingCache.IsEmpty()) {
		return;
	}

	Local<Array> propertyNames = bindingCache->GetPropertyNames();
	uint32_t length = propertyNames->Length();

	for (uint32_t i = 0; i < length; ++i) {
		String::Utf8Value binding(propertyNames->Get(i));
		int bindingLength = binding.length();

		titanium::bindings::BindEntry *extBinding =
			::TitaniumCountlyAndroidMessagingBindings::lookupGeneratedInit(*binding, bindingLength);

		if (extBinding && extBinding->dispose) {
			extBinding->dispose();
		}
	}

	bindingCache.Dispose();
	bindingCache = Persistent<Object>();
}
开发者ID:Arthien,项目名称:countly-sdk-appcelerator-titanium-android,代码行数:25,代码来源:TitaniumCountlyAndroidMessagingBootstrap.cpp

示例5: jniScope

/*
 * Class:     org_appcelerator_kroll_runtime_v8_V8Runtime
 * Method:    nativeRunModule
 * Signature: (Ljava/lang/String;Ljava/lang/String;)V
 */
JNIEXPORT void JNICALL Java_org_appcelerator_kroll_runtime_v8_V8Runtime_nativeRunModule
	(JNIEnv *env, jobject self, jstring source, jstring filename, jobject activityProxy)
{
	ENTER_V8(V8Runtime::globalContext);
	titanium::JNIScope jniScope(env);

	if (moduleObject.IsEmpty()) {
		moduleObject = Persistent<Object>::New(
			V8Runtime::krollGlobalObject->Get(String::New("Module"))->ToObject());

		runModuleFunction = Persistent<Function>::New(
			Handle<Function>::Cast(moduleObject->Get(String::New("runModule"))));
	}

	Handle<Value> jsSource = TypeConverter::javaStringToJsString(source);
	Handle<Value> jsFilename = TypeConverter::javaStringToJsString(filename);
	Handle<Value> jsActivity = TypeConverter::javaObjectToJsValue(activityProxy);

	Handle<Value> args[] = { jsSource, jsFilename, jsActivity };
	TryCatch tryCatch;

	runModuleFunction->Call(moduleObject, 3, args);

	if (tryCatch.HasCaught()) {
		V8Util::openJSErrorDialog(tryCatch);
		V8Util::reportException(tryCatch, true);
	}
}
开发者ID:EnochManohar,项目名称:titanium_mobile,代码行数:33,代码来源:V8Runtime.cpp

示例6:

JNIEXPORT void JNICALL Java_ag_boersego_bgjs_ClientAndroid_load(JNIEnv * env,
		jobject obj, jlong ctxPtr, jstring path) {
	BGJSContext* ct = (BGJSContext*) ctxPtr;
	const char* pathStr = env->GetStringUTFChars(path, 0);
	Persistent<Script> res = ct->load(pathStr);
	if (!res.IsEmpty()) {
		ct->_script = res;
	}
	env->ReleaseStringUTFChars(path, pathStr);
}
开发者ID:vasun77,项目名称:ejecta-v8,代码行数:10,代码来源:ClientAndroid.cpp

示例7: 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

示例8: scope

Handle<Object> Log::Wrap()
{
	Isolate *isolate = jsCompiler_.GetIsolate();
	HandleScope scope(isolate);

	if (logTemplate.IsEmpty()) {
		Handle<ObjectTemplate> objTemplate = MakeLogTemplate(isolate);
		logTemplate.Reset(isolate, objTemplate);
	}
	Handle<ObjectTemplate> local = Local<ObjectTemplate>::New(isolate, logTemplate);
	Handle<Object> obj = local->NewInstance();
	Handle<External> log_ptr = External::New(this);
	obj->SetInternalField(0, log_ptr);
	return scope.Close(obj);
}
开发者ID:Nightaway,项目名称:dragon,代码行数:15,代码来源:Log.cpp

示例9:

bool V8Util::isNaN(Handle<Value> value)
{
	HandleScope scope;
	Local<Object> global = Context::GetCurrent()->Global();

	if (isNaNFunction.IsEmpty()) {
		Local<Value> isNaNValue = global->Get(String::NewSymbol("isNaN"));
		isNaNFunction = Persistent<Function>::New(isNaNValue.As<Function> ());
	}

	Handle<Value> args[] = { value };

	return isNaNFunction->Call(global, 1, args)->BooleanValue();

}
开发者ID:1rp,项目名称:titanium_mobile,代码行数:15,代码来源:V8Util.cpp

示例10: 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

示例11: filename

void V8Util::reportException(TryCatch &tryCatch, bool showLine)
{
	HandleScope scope;
	Handle<Message> message = tryCatch.Message();

	if (nameSymbol.IsEmpty()) {
		nameSymbol = SYMBOL_LITERAL("name");
		messageSymbol = SYMBOL_LITERAL("message");
	}

	if (showLine) {
		Handle<Message> message = tryCatch.Message();
		if (!message.IsEmpty()) {
			String::Utf8Value filename(message->GetScriptResourceName());
			String::Utf8Value msg(message->Get());
			int linenum = message->GetLineNumber();
			LOGE(EXC_TAG, "Exception occurred at %s:%i: %s", *filename, linenum, *msg);
		}
	}

	Local<Value> stackTrace = tryCatch.StackTrace();
	String::Utf8Value trace(tryCatch.StackTrace());

	if (trace.length() > 0 && !stackTrace->IsUndefined()) {
		LOGD(EXC_TAG, *trace);
	} else {
		Local<Value> exception = tryCatch.Exception();
		if (exception->IsObject()) {
			Handle<Object> exceptionObj = exception->ToObject();
			Handle<Value> message = exceptionObj->Get(messageSymbol);
			Handle<Value> name = exceptionObj->Get(nameSymbol);

			if (!message->IsUndefined() && !name->IsUndefined()) {
				String::Utf8Value nameValue(name);
				String::Utf8Value messageValue(message);
				LOGE(EXC_TAG, "%s: %s", *nameValue, *messageValue);
			}
		} else {
			String::Utf8Value error(exception);
			LOGE(EXC_TAG, *error);
		}
	}
}
开发者ID:1rp,项目名称:titanium_mobile,代码行数:43,代码来源:V8Util.cpp

示例12: context_scope

  static Persistent<Object> getPlugin(shared_ptr<PluginContext> script)
  {
    Context::Scope context_scope(script->getContext());
    HandleScope handleScope;
    Handle<Object> global = script->getContext()->Global();

    if (global->Has(String::New("plugin")) == false)
    {
      throw IllegalArgumentException("Expected the script to have exports.");
    }

    Handle<Value> pluginValue = global->Get(String::New("plugin"));
    Persistent<Object> plugin = Persistent<Object>::New(Handle<Object>::Cast(pluginValue));
    if (plugin.IsEmpty() || plugin->IsObject() == false)
    {
      throw IllegalArgumentException("Expected plugin to be a valid object.");
    }

    return plugin;
  }
开发者ID:mitulvpatel,项目名称:hootenanny,代码行数:20,代码来源:ScriptMatchCreator.cpp

示例13: WrapResults

    static Handle<Value> WrapResults(cached_object cache)
    {
        HandleScope handle_scope;


        if (object_template_.IsEmpty()) {
            Handle<ObjectTemplate> raw_template = PrepareTemplate();
            object_template_ = Persistent<ObjectTemplate>::New(raw_template);
        }

        Handle<Object> new_object = object_template_->NewInstance();
        //new_object->SetInternalField(1, External::New(results));

        //printf("Here: %x\n", buffer);

        object* obj = new object(cache);
        obj->Wrap(new_object);
        // TODO: Lookup the args id and wrap it

        //printf("Wrapped and returning\n");

        return handle_scope.Close(new_object);
    }
开发者ID:temas,项目名称:js0n-cache,代码行数:23,代码来源:js0n-cache.cpp

示例14: ThrowException

static Handle<Value> TitaniumCountlyAndroidMessaging_getBinding(const Arguments& args)
{
	HandleScope scope;

	if (args.Length() == 0) {
		return ThrowException(Exception::Error(String::New("TitaniumCountlyAndroidMessaging.getBinding requires 1 argument: binding")));
	}

	if (bindingCache.IsEmpty()) {
		bindingCache = Persistent<Object>::New(Object::New());
	}

	Handle<String> binding = args[0]->ToString();

	if (bindingCache->Has(binding)) {
		return bindingCache->Get(binding);
	}

	String::Utf8Value bindingValue(binding);

	LOGD(TAG, "Looking up binding: %s", *bindingValue);

	titanium::bindings::BindEntry *extBinding = ::TitaniumCountlyAndroidMessagingBindings::lookupGeneratedInit(
		*bindingValue, bindingValue.length());

	if (!extBinding) {
		LOGE(TAG, "Couldn't find binding: %s, returning undefined", *bindingValue);
		return Undefined();
	}

	Handle<Object> exports = Object::New();
	extBinding->bind(exports);
	bindingCache->Set(binding, exports);

	return exports;
}
开发者ID:Arthien,项目名称:countly-sdk-appcelerator-titanium-android,代码行数:36,代码来源:TitaniumCountlyAndroidMessagingBootstrap.cpp

示例15: gcx

 Persistent<Context> gcx() {
   if (gRootContext.IsEmpty()) {
     gRootContext = Context::New();
   }
   return gRootContext;
 }
开发者ID:mmmulani,项目名称:v8monkey,代码行数:6,代码来源:v8.cpp


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