本文整理汇总了C++中KObjectRef::Set方法的典型用法代码示例。如果您正苦于以下问题:C++ KObjectRef::Set方法的具体用法?C++ KObjectRef::Set怎么用?C++ KObjectRef::Set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KObjectRef
的用法示例。
在下文中一共展示了KObjectRef::Set方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
}
示例2: 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);
}
示例3: InitializeBinding
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);
}
示例4: CloneEnvironment
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;
}
示例5: 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);
}
示例6: 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);
}
示例7: 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);
}
示例8: 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;
}
示例9: Clipboard
UIBinding::UIBinding(Host *host) :
KAccessorObject("UI"),
host(host)
{
instance = this;
// @tiproperty[Number, UI.CENTERED, since=0.6] The CENTERED event constant
this->Set("CENTERED", Value::NewInt(UIBinding::CENTERED));
/**
* @tiapi(method=True,name=UI.createMenu,since=0.6)
* @tiapi Create a new menu
* @tiresult[UI.Menu] A new menu
*/
this->SetMethod("createMenu", &UIBinding::_CreateMenu);
/**
* @tiapi(method=True,name=UI.createMenuItem,since=0.6)
* @tiapi Create a new menu item.
* @tiarg[String, label] The label for this menu item
* @tiarg[Function, eventListener, optional=True] An event listener for this menu item
* @tiarg[String, iconURL, optional=True] A URL to an icon to use for this menu item
* @tiresult[UI.MenuItem] A new menu item
*/
this->SetMethod("createMenuItem", &UIBinding::_CreateMenuItem);
/**
* @tiapi(method=True,name=UI.createCheckMenuItem,since=0.6)
* @tiapi Create a new CheckMenuItem object.
* @tiarg[String, label] The label for this menu item
* @tiarg[Function, eventListener, optional=True] An event listener for this menu item
* @tiresult[UI.CheckMenuItem] The new CheckMenuItem object
*/
this->SetMethod("createCheckMenuItem", &UIBinding::_CreateCheckMenuItem);
/**
* @tiapi(method=True,name=UI.createSeperatorMenuItem,since=0.6)
* @tiapi Create a new separator menu item.
* @tiresult[UI.SeparatorMenuItem] A new separator menu item
*/
this->SetMethod("createSeparatorMenuItem", &UIBinding::_CreateSeparatorMenuItem);
/**
* @tiapi(method=True,name=UI.setMenu,since=0.2) Set a menu for the application
* @tiarg[UI.Menu|null, menu] A Menu object to use as the menu or null to unset the menu
*/
this->SetMethod("setMenu", &UIBinding::_SetMenu);
/**
* @tiapi(method=True,name=UI.getMenu,since=0.2) Returns the application's main MenuItem
* @tiresult[UI.Menu|null] The application's main menu
*/
this->SetMethod("getMenu", &UIBinding::_GetMenu);
/**
* @tiapi(method=True,name=UI.setContextMenu,since=0.2) Set the application's context menu
* @tiarg(for=UI.setContextMenu,type=UI.Menu|null,name=menu) a MenuItem object or null to unset
*/
this->SetMethod("setContextMenu", &UIBinding::_SetContextMenu);
/**
* @tiapi(method=True,name=UI.getContextMenu,since=0.2) Returns the application context menu
* @tiresult(for=UI.getContextMenu,type=UI.Menu|null) the application's context MenuItem object
*/
this->SetMethod("getContextMenu", &UIBinding::_GetContextMenu);
/**
* @tiapi(method=True,name=UI.setIcon,since=0.2) Set the application's icon
* @tiarg(for=UI.setIcon,type=String,name=menu) path to the icon
*/
this->SetMethod("setIcon", &UIBinding::_SetIcon);
/**
* @tiapi(method=True,name=UI.addTray,since=0.2)
* @tiapi Create and add a tray icon
* @tiarg[String, iconURL] URL to the icon to use for this tray item
* @tiarg[Function, eventListener, optional=True] Event listener to add for this item
* @tiresult(for=UI.addTray,type=UI.Tray|null) the application's Tray icon object
*/
this->SetMethod("addTray", &UIBinding::_AddTray);
/**
* @tiapi(method=True,name=UI.clearTray,since=0.2)
* @tiapi Empty the tray of all this application's tray items
*/
this->SetMethod("clearTray", &UIBinding::_ClearTray);
/**
* @tiapi(method=True,name=UI.setDockIcon,since=0.2) Set the dock icon
* @tiarg(for=UI.setDockIcon,type=String,name=icon) path to the icon
*/
this->SetMethod("setDockIcon", &UIBinding::_SetDockIcon);
/**
* @tiapi(method=True,name=UI.setDockMenu,since=0.2) Set the dock menu
* @tiarg(for=UI.setDockMenu,type=UI.Menu,name=menu) The new menu for the dock
*/
this->SetMethod("setDockMenu", &UIBinding::_SetDockMenu);
/**
//.........这里部分代码省略.........
示例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))
//.........这里部分代码省略.........