本文整理汇总了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"));
}
}
示例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);
}
}
示例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);
}
}
}
示例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;
}
示例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;
}
示例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);
}
示例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;
}
}
示例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;
}
示例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;
}
示例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))
//.........这里部分代码省略.........