本文整理汇总了C++中KObjectRef::GetPropertyNames方法的典型用法代码示例。如果您正苦于以下问题:C++ KObjectRef::GetPropertyNames方法的具体用法?C++ KObjectRef::GetPropertyNames怎么用?C++ KObjectRef::GetPropertyNames使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KObjectRef
的用法示例。
在下文中一共展示了KObjectRef::GetPropertyNames方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
}
}
示例2: 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;
}