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


C++ KObjectRef类代码示例

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


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

示例1: if

AutoPtr<StaticBoundObject> ScopeMethodDelegate::CreateDelegate(KObjectRef global, KObjectRef bo)
{
	AutoPtr<StaticBoundObject> scope = new StaticBoundObject();
	SharedStringList keys = bo->GetPropertyNames();
	StringList::iterator iter = keys->begin();

	while(iter!=keys->end())
	{
		SharedString key_ptr = (*iter++);
		std::string key = *key_ptr;
		KValueRef value = bo->Get(key.c_str());

		if (key == "set")
		{
			KMethodRef d = new ScopeMethodDelegate(SET, global, scope, value->ToMethod());
			KValueRef v = Value::NewMethod(d);
			scope->Set(key.c_str(), v);
		}
		else if (key == "get")
		{
			KMethodRef d = new ScopeMethodDelegate(GET, global, scope, value->ToMethod());
			KValueRef v = Value::NewMethod(d);
			scope->Set(key.c_str(), v);
		}
		else
		{
			scope->Set(key.c_str(), value);
		}

	}
	return scope;
}
开发者ID:OnlyChristopher,项目名称:TideSDK,代码行数:32,代码来源:scope_method_delegate.cpp

示例2: Evaluate

	KValueRef Script::Evaluate(const char *mimeType, const char *name, const char *code, KObjectRef scope)
	{
		KObjectRef evaluator = this->FindEvaluatorWithMethod("canEvaluate", mimeType);
		if (!evaluator.isNull())
		{
			KMethodRef evaluate = evaluator->GetMethod("evaluate");
			if (!evaluate.isNull())
			{
				ValueList args;
				args.push_back(Value::NewString(mimeType));
				args.push_back(Value::NewString(name));
				args.push_back(Value::NewString(code));
				args.push_back(Value::NewObject(scope));
				return evaluate->Call(args);
			}
			else
			{
				throw ValueException::FromFormat(
					"Error evaluating: No \"evaluate\" method found on evaluator for mimeType: \"%s\"", mimeType);
			}
		}
		else
		{
			throw ValueException::FromFormat("Error evaluating: No evaluator found for mimeType: \"%s\"", mimeType);
		}
	}
开发者ID:mital,项目名称:kroll,代码行数:26,代码来源:script.cpp

示例3: MergePyGlobalsWithContext

    static void MergePyGlobalsWithContext(PyObject* globals, KObjectRef context)
    {
		// Avoid compiler warnings
		PyObject *items = PyObject_CallMethod(globals, (char*) "items", NULL);
		if (items == NULL)
			return;

		PyObject *iterator = PyObject_GetIter(items);
		if (iterator == NULL)
			return;

		PyObject *item;
		while ((item = PyIter_Next(iterator)))
		{
			PyObject* k = PyTuple_GetItem(item, 0);
			PyObject* v = PyTuple_GetItem(item, 1);
			std::string sk = PythonUtils::ToString(k);
			if (sk.find("__") != 0)
			{
				KValueRef newValue = PythonUtils::ToKrollValue(v);
				KValueRef existingValue = context->Get(sk.c_str());
				if (!newValue->Equals(existingValue))
				{
					context->Set(sk.c_str(), newValue);
				}
			}
			Py_DECREF(item);
		}
    }
开发者ID:OnlyChristopher,项目名称:TideSDK,代码行数:29,代码来源:python_interpreter.cpp

示例4: PreprocessURLCallback

	char* PreprocessURLCallback(const char* url, KeyValuePair* headers, char** mimeType)
	{
		Logger* logger = Logger::Get("UI.URL");

		KObjectRef scope = new StaticBoundObject();
		KObjectRef kheaders = new StaticBoundObject();
		while (headers->key)
		{
			kheaders->SetString(headers->key, headers->value);
			headers++;
		}

		try
		{
			AutoPtr<PreprocessData> result = 
				Script::GetInstance()->Preprocess(url, scope);
			*mimeType = strdup(result->mimeType.c_str());
			return strdup(result->data->Pointer());
		}
		catch (ValueException& e)
		{
			logger->Error("Error in preprocessing: %s", e.ToString().c_str());
		}
		catch (...)
		{
			logger->Error("Unknown Error in preprocessing");
		}

		return NULL;
	}
开发者ID:Val9,项目名称:titanium_desktop,代码行数:30,代码来源:url.cpp

示例5: PropertiesBinding

	void AppBinding::CreateProperties(const ValueList& args, KValueRef result)
	{
		AutoPtr<PropertiesBinding> properties = new PropertiesBinding();
		result->SetObject(properties);
		
		if (args.size() > 0 && args.at(0)->IsObject())
		{
			KObjectRef p = args.at(0)->ToObject();
			SharedStringList names = p->GetPropertyNames();
			for (size_t i = 0; i < names->size(); i++)
			{
				KValueRef value = p->Get(names->at(i));
				ValueList setterArgs;
				setterArgs.push_back(Value::NewString(names->at(i)));
				setterArgs.push_back(value);
				PropertiesBinding::Type type;
				
				if (value->IsList()) type = PropertiesBinding::List;
				else if (value->IsInt()) type = PropertiesBinding::Int;
				else if (value->IsDouble()) type = PropertiesBinding::Double;
				else if (value->IsBool()) type = PropertiesBinding::Bool;
				else type = PropertiesBinding::String;
				
				properties->Setter(setterArgs, type);
			}
		}
	}
开发者ID:mital,项目名称:titanium_desktop,代码行数:27,代码来源:app_binding.cpp

示例6: Configure

void Notification::Configure(KObjectRef properties)
{
	this->title = properties->GetString("title");
	this->message = properties->GetString("message");
	this->iconURL = properties->GetString("icon");
	this->timeout = properties->GetInt("timeout", -1);
	this->clickedCallback = properties->GetMethod("callback");
}
开发者ID:Val9,项目名称:titanium_desktop,代码行数:8,代码来源:notification.cpp

示例7: Stop

	void RubyModule::Stop()
	{
		KObjectRef global = this->host->GetGlobalObject();
		global->Set("Ruby", Value::Undefined);
		Script::GetInstance()->RemoveScriptEvaluator(this->binding);
		this->binding = NULL;
		RubyModule::instance_ = NULL;

		ruby_cleanup(0);
	}
开发者ID:mital,项目名称:kroll,代码行数:10,代码来源:ruby_module.cpp

示例8: _SetContextMenu

	void UIBinding::_SetContextMenu(const ValueList& args, KValueRef result)
	{
		args.VerifyException("setContextMenu", "o|0");
		KObjectRef argObj = args.GetObject(0, NULL);
		AutoMenu menu = NULL;

		if (!argObj.isNull())
		{
			menu = argObj.cast<Menu>();
		}
		this->SetContextMenu(menu);
	}
开发者ID:ksmythe,项目名称:titanium_desktop,代码行数:12,代码来源:ui_binding.cpp

示例9: SG

void PHPModule::InitializeBinding()
{
    PHPModule::mimeType = SG(default_mimetype);

    KObjectRef global = this->host->GetGlobalObject();
    this->binding = new PHPEvaluator();
    global->Set("PHP", Value::NewObject(this->binding));
    Script::GetInstance()->AddScriptEvaluator(this->binding);

    zval *titaniumValue = PHPUtils::ToPHPValue(Value::NewObject(global));
    ZEND_SET_SYMBOL(&EG(symbol_table), PRODUCT_NAME, titaniumValue);
}
开发者ID:toisoftware,项目名称:TideSDK,代码行数:12,代码来源:php_module.cpp

示例10: InitializeBinding

	void RubyModule::InitializeBinding()
	{
		// Expose the Ruby evaluator into Kroll
		KObjectRef global = this->host->GetGlobalObject();
		this->binding = new RubyEvaluator();
		global->Set("Ruby", Value::NewObject(binding));
		Script::GetInstance()->AddScriptEvaluator(this->binding);
		
		// Bind the API global constant
		VALUE ruby_api_val = RubyUtils::KObjectToRubyValue(Value::NewObject(global));
		rb_define_global_const(PRODUCT_NAME, ruby_api_val);
	}
开发者ID:mital,项目名称:kroll,代码行数:12,代码来源:ruby_module.cpp

示例11: StaticBoundObject

	KObjectRef Process::CloneEnvironment()
	{
		SharedStringList properties = environment->GetPropertyNames();
		KObjectRef clonedEnvironment = new StaticBoundObject();
		for (size_t i = 0; i < properties->size(); i++)
		{
			std::string property = *properties->at(i);
			std::string value = environment->Get(property.c_str())->ToString();
			clonedEnvironment->Set(property.c_str(), Value::NewString(value.c_str()));
		}
		return clonedEnvironment;
	}
开发者ID:Val9,项目名称:titanium_desktop,代码行数:12,代码来源:process.cpp

示例12: GetContextId

	static string GetContextId(KObjectRef global)
	{
		string contextId(global->GetString("__php_module_id__"));
		if (contextId.empty())
		{
			static int nextId = 0;
			contextId.append("__kroll__namespace__");
			contextId.append(KList::IntToChars(++nextId));
			global->SetString("__php_module_id__", contextId);
		}

		return contextId;
	}
开发者ID:mital,项目名称:kroll,代码行数:13,代码来源:php_evaluator.cpp

示例13: Start

 void PlatformModule::Start()
 {
     // Duplicate the network module address, macaddress and interfaces here for
     // backward compatibility. The network module should be initialized when
     // Start() is called.
     if (!GlobalObject::GetInstance()->GetObject("Network").isNull())
     {
         KObjectRef network = GlobalObject::GetInstance()->GetObject("Network");
         this->binding->Set("getAddress", network->Get("getAddress"));
         this->binding->Set("getMACAddress", network->Get("getMACAddress"));
         this->binding->Set("getInterfaces", network->Get("getInterfaces"));
     }
 }
开发者ID:Adimpression,项目名称:TideSDK,代码行数:13,代码来源:platform_module.cpp

示例14: StaticBoundObject

 void HttpServerRequest::GetHeaders(const ValueList& args, KValueRef result)
 {
     Poco::Net::HTTPServerRequest::ConstIterator iter = request.begin();
     KObjectRef headers = new StaticBoundObject();
     
     for(; iter != request.end(); iter++)
     {
         std::string name = iter->first;
         std::string value = iter->second;
         headers->SetString(name.c_str(), value.c_str());
     }
     result->SetObject(headers);
 }
开发者ID:Adimpression,项目名称:TideSDK,代码行数:13,代码来源:http_server_request.cpp

示例15: Stop

void PHPModule::Stop()
{
    PHPModule::instance_ = NULL;

    KObjectRef global = this->host->GetGlobalObject();
    Script::GetInstance()->RemoveScriptEvaluator(this->binding);
    global->Set("PHP", Value::Undefined);
    this->binding->Set("evaluate", Value::Undefined);

    this->binding = 0;
    PHPModule::instance_ = 0;

    php_embed_shutdown(TSRMLS_C);
}
开发者ID:toisoftware,项目名称:TideSDK,代码行数:14,代码来源:php_module.cpp


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