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


C++ KObjectRef::Get方法代码示例

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


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

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

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

示例3: CreateProperties

	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

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

示例5: m_missing

    static VALUE m_missing(int argc, VALUE* argv, VALUE self)
    {
        bool assignment = false;

        if (global_object.isNull())
            return Qnil;

        // store the method name and arguments in separate variables
        VALUE method_name, args;
        rb_scan_args(argc, argv, "1*", &method_name, &args);
        char* name = strdup(rb_id2name(SYM2ID(method_name)));

        // Check if this is an assignment
        if (name[strlen(name) - 1] == '=')
        {
            name[strlen(name) - 1] = '\0';
            assignment = true;
        }
        // If we can't find this property perhaps we should return
        // the same property name except capitalized.
        KValueRef v = global_object->Get(name);
        if (v->IsUndefined())
        {
            name[0] = toupper(name[0]);
            v = global_object->Get(name);
        }
        // Okay, maybe not
        if (v->IsUndefined())
            name[0] = tolower(name[0]);

        VALUE rval;
        if (assignment) // Assignment
        {
            rval = rb_ary_entry(args, 0);
            KValueRef val = RubyUtils::ToKrollValue(rval);
            global_object->Set(name, val);
        }
        else if (v->IsMethod()) // Method call
        {
            rval = RubyUtils::GenericKMethodCall(v->ToMethod(), args);
        }
        else // Plain old access
        {
            rval = RubyUtils::ToRubyValue(v);
        }
        return rval;
    }
开发者ID:Adimpression,项目名称:TideSDK,代码行数:47,代码来源:ruby_evaluator.cpp

示例6: GetContextId

 std::string RubyEvaluator::GetContextId(KObjectRef global)
 {
     static int nextId = 0;
     int cid = 0;
     KValueRef idv = global->Get("__ruby_module_id__");
     if (idv->IsUndefined())
     {
         cid = nextId++;
         global->Set("__ruby_module_id__", Value::NewInt(cid));
     }
     else
     {
         cid = idv->ToInt();
     }
     return std::string("$windowProc") + KList::IntToChars(cid);
 }
开发者ID:Adimpression,项目名称:TideSDK,代码行数:16,代码来源:ruby_evaluator.cpp

示例7: Call

KValueRef ScopeMethodDelegate::Call(const ValueList& args)
{
	std::string key = args.at(0)->ToString();
	KObjectRef obj = IsGlobalKey(key) ? global : scope;
	if (type == GET)
	{
		// not found, look inside scope
		return obj->Get(key.c_str());
	}
	else
	{
		KValueRef result = args.at(1);
		obj->SetNS(key.c_str(),result);
		return Value::Undefined;
	}
}
开发者ID:OnlyChristopher,项目名称:TideSDK,代码行数:16,代码来源:scope_method_delegate.cpp

示例8: CoerceBool

static bool CoerceBool(KObjectRef props, const char* name, bool defaultValue)
{
	KValueRef v(props->Get(name));
	if (v->IsString())
	{
		std::string value(v->ToString());
		if (value=="yes" || value=="1" || value=="true" || value=="True")
			return true;
		else
			return false;
	}
	else if (v->IsInt())
		return v->ToInt();

	else if (v->IsBool())
		return v->ToBool();

	return defaultValue;
}
开发者ID:fossamikom,项目名称:TideSDK,代码行数:19,代码来源:window_config.cpp

示例9: if

	AutoPtr<PreprocessData> Script::Preprocess(const char *url, KObjectRef scope)
	{
		KObjectRef evaluator = this->FindEvaluatorWithMethod("canPreprocess", url);
		if (!evaluator.isNull())
		{
			KMethodRef preprocess = evaluator->GetMethod("preprocess");
			if (!preprocess.isNull())
			{
				ValueList args;
				args.push_back(Value::NewString(url));
				args.push_back(Value::NewObject(scope));
				
				KValueRef result = preprocess->Call(args);
				
				if (result->IsObject())
				{
					KObjectRef object = result->ToObject();
					AutoPtr<PreprocessData> data = new PreprocessData();
					if (object->HasProperty("data"))
					{
						KValueRef objectData = object->Get("data");
						if (objectData->IsObject())
						{
							BlobRef blobData = objectData->ToObject().cast<Blob>();
							if (!blobData.isNull())
							{
								data->data = blobData;
							}
						}
						else if (objectData->IsString())
						{
							data->data = new Blob(objectData->ToString(), strlen(objectData->ToString()));
						}
					}
					else
					{
						throw ValueException::FromString("Preprocessor didn't return any data");
					}
					if (object->HasProperty("mimeType"))
					{
						data->mimeType = object->Get("mimeType")->ToString();
					}
					else
					{
						throw ValueException::FromString("Preprocessor didn't return a mimeType");
					}
					
					return data;
				}
			}
			else
			{
				throw ValueException::FromFormat(
					"Error preprocessing: No \"preprocess\" method found on evaluator for url: \"%s\"", url);
			}
		}
		else
		{
			throw ValueException::FromFormat("Error preprocessing: No evaluator found for url: \"%s\"", url);
		}
		return 0;
	}
开发者ID:mital,项目名称:kroll,代码行数:62,代码来源:script.cpp

示例10: appid

void Win32UserWindow::InitWebKit()
{
	HRESULT hr = WebKitCreateInstance(CLSID_WebView, 0, IID_IWebView,
		(void**) &(this->webView));
	if (FAILED(hr))
		HandleHResultError("Error creating WebKitWebView", hr, true);

	// Set the custom user agent for Titanium
	const char *version = host->GetGlobalObject()->Get("version")->ToString();
	char userAgent[128];
	//TI-303 we need to add safari UA to our UA to resolve broken
	//sites that look at Safari and not WebKit for UA
	sprintf(userAgent, "Version/4.0 Safari/528.16 %s/%s", PRODUCT_NAME, version);
	_bstr_t ua(userAgent);
	webView->setApplicationNameForUserAgent(ua.copy());

	// place our user agent string in the global so we can later use it
	KObjectRef global = host->GetGlobalObject();
	if (global->Get("userAgent")->IsUndefined())
	{
		_bstr_t uaURL("http://titaniumapp.com");
		BSTR uaResp;
		webView->userAgentForURL(uaURL.copy(), &uaResp);
		std::string uaStr = _bstr_t(uaResp);
		global->Set("userAgent", Value::NewString(uaStr.c_str()));
	}

	frameLoadDelegate = new Win32WebKitFrameLoadDelegate(this);
	hr = webView->setFrameLoadDelegate(frameLoadDelegate);
	if (FAILED(hr))
		HandleHResultError("Error setting FrameLoadDelegate", hr, true);

	uiDelegate = new Win32WebKitUIDelegate(this);
	hr = webView->setUIDelegate(uiDelegate);
	if (FAILED(hr))
		HandleHResultError("Error setting UIDelegate", hr, true);

	policyDelegate = new Win32WebKitPolicyDelegate(this);
	hr = webView->setPolicyDelegate(policyDelegate);
	if (FAILED(hr))
		HandleHResultError("Error setting PolicyDelegate", hr, true);

	hr = webView->setHostWindow((OLE_HANDLE) windowHandle);
	if (FAILED(hr))
		HandleHResultError("Error setting host window", hr, true);

	RECT clientRect;
	GetClientRect(windowHandle, &clientRect);
	hr = webView->initWithFrame(clientRect, 0, 0);
	if (FAILED(hr))
		HandleHResultError("Could not intialize WebView with frame", hr, true);

	IWebPreferences *prefs = NULL;
	hr = WebKitCreateInstance(CLSID_WebPreferences, 0, IID_IWebPreferences,
		(void**) &prefs);
	if (FAILED(hr) || !prefs)
		HandleHResultError("Error getting IWebPreferences", hr, true);

	std::string appid(AppConfig::Instance()->GetAppID());
	_bstr_t pi(appid.c_str());
	prefs->initWithIdentifier(pi.copy(), &prefs);
	prefs->setCacheModel(WebCacheModelDocumentBrowser);
	prefs->setPlugInsEnabled(true);
	prefs->setJavaEnabled(true);
	prefs->setJavaScriptEnabled(true);
	prefs->setJavaScriptCanOpenWindowsAutomatically(true);
	prefs->setDOMPasteAllowed(true);

	IWebPreferencesPrivate* privatePrefs = NULL;
	hr = prefs->QueryInterface(IID_IWebPreferencesPrivate, (void**) &privatePrefs);
	if (FAILED(hr) || !privatePrefs)
		HandleHResultError("Error getting IWebPreferencesPrivate", hr, true);

	privatePrefs->setDeveloperExtrasEnabled(host->IsDebugMode());
	privatePrefs->setDatabasesEnabled(true);
	privatePrefs->setLocalStorageEnabled(true);
	privatePrefs->setOfflineWebApplicationCacheEnabled(true);
	privatePrefs->setAllowUniversalAccessFromFileURLs(true);
	_bstr_t dbPath(FileUtils::GetApplicationDataDirectory(appid).c_str());
	privatePrefs->setLocalStorageDatabasePath(dbPath.copy());
	privatePrefs->Release();

	webView->setPreferences(prefs);
	prefs->Release();

	// allow app:// and ti:// to run with local permissions (cross-domain ajax,etc)
	_bstr_t appProto("app");
	webView->registerURLSchemeAsLocal(appProto.copy());

	_bstr_t tiProto("ti");
	webView->registerURLSchemeAsLocal(tiProto.copy());

	IWebViewPrivate *webViewPrivate;
	hr = webView->QueryInterface(IID_IWebViewPrivate, (void**) &webViewPrivate);
	if (FAILED(hr))
		HandleHResultError("Error getting IWebViewPrivate", hr);

	// Get the WebView's HWND
	hr = webViewPrivate->viewWindow((OLE_HANDLE*) &viewWindowHandle);
	if (FAILED(hr))
//.........这里部分代码省略.........
开发者ID:mital,项目名称:titanium_desktop,代码行数:101,代码来源:win32_user_window.cpp


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