本文整理汇总了C++中KObjectRef::isNull方法的典型用法代码示例。如果您正苦于以下问题:C++ KObjectRef::isNull方法的具体用法?C++ KObjectRef::isNull怎么用?C++ KObjectRef::isNull使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KObjectRef
的用法示例。
在下文中一共展示了KObjectRef::isNull方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Log
void UIBinding::Log(Logger::Level level, std::string& message)
{
if (level > Logger::LWARN)
return;
std::string methodName("warn");
if (level < Logger::LWARN)
methodName = "error";
std::string origMethodName(methodName);
origMethodName.append("_orig");
std::vector<AutoUserWindow>& openWindows = UIBinding::GetInstance()->GetOpenWindows();
for (size_t i = 0; i < openWindows.size(); i++)
{
KObjectRef domWindow = openWindows[i]->GetDOMWindow();
if (domWindow.isNull())
continue;
KObjectRef console = domWindow->GetObject("console", 0);
if (console.isNull())
continue;
KMethodRef method = console->GetMethod(origMethodName.c_str(), 0);
if (method.isNull())
method = console->GetMethod(methodName.c_str(), 0);
RunOnMainThread(method, ValueList(Value::NewString(message)), false);
}
}
示例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);
}
}
示例3: _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);
}
示例4: 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;
}
示例5: _SetMenu
void UIBinding::_SetMenu(const ValueList& args, KValueRef result)
{
args.VerifyException("setMenu", "o|0");
KObjectRef argObj = args.GetObject(0, NULL);
AutoMenu menu = NULL;
if (!argObj.isNull())
{
menu = argObj.cast<Menu>();
}
this->SetMenu(menu); // platform-specific impl
// Notify all windows that the app menu has changed.
std::vector<AutoUserWindow>::iterator i = openWindows.begin();
while (i != openWindows.end()) {
(*i++)->AppMenuChanged();
}
}
示例6: ContextToGlobal
void RubyEvaluator::ContextToGlobal(VALUE ctx, KObjectRef o)
{
if (global_object.isNull())
return;
// Next copy all methods over -- they override variables
VALUE methods = rb_funcall(ctx, rb_intern("singleton_methods"), 0);
for (long i = 0; i < RARRAY_LEN(methods); i++)
{
VALUE meth_symbol = rb_ary_entry(methods, i);
const char* meth_name = STR2CSTR(meth_symbol);
// Skip our special method_missing method
if (strcmp(meth_name, "method_missing") == 0)
continue;
volatile VALUE rmeth = rb_funcall(ctx, rb_intern("method"), 1, meth_symbol);
KMethodRef method = new KRubyMethod(rmeth, meth_name);
o->SetMethod(meth_name, method);
}
}
示例7: 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;
}