本文整理汇总了C++中SharedValue::SetObject方法的典型用法代码示例。如果您正苦于以下问题:C++ SharedValue::SetObject方法的具体用法?C++ SharedValue::SetObject怎么用?C++ SharedValue::SetObject使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SharedValue
的用法示例。
在下文中一共展示了SharedValue::SetObject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _CreateWindow
void UserWindow::_CreateWindow(const ValueList& args, SharedValue result)
{
//TODO: wrap in sharedptr
WindowConfig *config = NULL;
if (args.size() > 0 && args.at(0)->IsObject())
{
SharedKObject props = SharedKObject(new StaticBoundObject());
config = new WindowConfig();
props = args.at(0)->ToObject();
config->UseProperties(props);
}
else if (args.size() > 0 && args.at(0)->IsString())
{
// String might match a url spec
std::string url = args.at(0)->ToString();
WindowConfig* matchedConfig = AppConfig::Instance()->GetWindowByURL(url);
url = AppConfig::Instance()->InsertAppIDIntoURL(url);
config = new WindowConfig(matchedConfig, url);
}
else
{
config = new WindowConfig();
}
SharedUserWindow new_window = this->binding->CreateWindow(config, shared_this);
result->SetObject(new_window);
}
示例2: GetProxy
void NetworkBinding::GetProxy(const ValueList& args, SharedValue result)
{
if(proxy)
{
result->SetObject(this->proxy);
}
}
示例3: Open
void DatabaseModule::Open(const ValueList& args, SharedValue result)
{
DatabaseBinding *db = new DatabaseBinding(host);
db->Open(args,result);
SharedKObject kdb = db;
result->SetObject(kdb);
}
示例4: _AddCheckItem
void Menu::_AddCheckItem(const ValueList& args, SharedValue result)
{
UIBinding* binding = UIBinding::GetInstance();
AutoMenuItem newItem = binding->__CreateCheckMenuItem(args);
this->AppendItem(newItem);
result->SetObject(newItem);
}
示例5: Read
void HttpServerRequest::Read(const ValueList& args, SharedValue result)
{
std::istream &in = request.stream();
if (in.eof() || in.fail())
{
result->SetNull();
return;
}
int max_size = 8096;
if (args.size()==1)
{
max_size = args.at(0)->ToInt();
}
char *buf = new char[max_size];
in.read(buf,max_size);
std::streamsize count = in.gcount();
if (count == 0)
{
result->SetNull();
}
else
{
result->SetObject(new Blob(buf,count));
}
delete [] buf;
}
示例6: CreateProperties
void AppBinding::CreateProperties(const ValueList& args, SharedValue result)
{
AutoPtr<PropertiesBinding> properties = new PropertiesBinding();
result->SetObject(properties);
if (args.size() > 0 && args.at(0)->IsObject())
{
SharedKObject p = args.at(0)->ToObject();
SharedStringList names = p->GetPropertyNames();
for (size_t i = 0; i < names->size(); i++)
{
SharedValue 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);
}
}
}
示例7: _CreateSound
void MediaBinding::_CreateSound(const ValueList& args, SharedValue result)
{
if (args.size()!=1)
throw ValueException::FromString("createSound takes 1 parameter");
std::string path(args.at(0)->ToString());
result->SetObject(this->CreateSound(path));
}
示例8: LoadProperties
void AppBinding::LoadProperties(const ValueList& args, SharedValue result)
{
if (args.size() >= 1 && args.at(0)->IsString()) {
std::string file_path = args.at(1)->ToString();
SharedBoundObject properties = new PropertiesBinding(file_path);
result->SetObject(properties);
}
}
示例9: CreateHTTPServer
void NetworkBinding::CreateHTTPServer(const ValueList& args, SharedValue result)
{
HTTPServerBinding* http = new HTTPServerBinding(host);
SharedKObject obj = http->GetSelf()->ToObject();
// we hold the reference to this until we're done with it
// which happense when the binding impl calls remove
this->bindings.push_back(obj);
result->SetObject(obj);
}
示例10: CreateIPAddress
void NetworkBinding::CreateIPAddress(const ValueList& args, SharedValue result)
{
SharedPtr<IPAddressBinding> binding = new IPAddressBinding(args.at(0)->ToString());
if (binding->IsInvalid())
{
throw ValueException::FromString("Invalid address");
}
result->SetObject(binding);
}
示例11: _GetByHost
void NetworkBinding::_GetByHost(std::string hostname, SharedValue result)
{
SharedPtr<HostBinding> binding = new HostBinding(hostname);
if (binding->IsInvalid())
{
throw ValueException::FromString("Could not resolve address");
}
result->SetObject(binding);
}
示例12: _AddSeparatorItem
void MenuItem::_AddSeparatorItem(const ValueList& args, SharedValue result)
{
UIBinding* binding = UIBinding::GetInstance();
AutoMenuItem newItem = binding->__CreateSeparatorMenuItem(args);
this->EnsureHasSubmenu();
this->submenu->AppendItem(newItem);
result->SetObject(newItem);
}
示例13: CreateWorker
void WorkerBinding::CreateWorker(const ValueList& args, SharedValue result)
{
if (args.size()!=2)
{
throw ValueException::FromString("invalid argument specified");
}
bool is_function = args.at(1)->ToBool();
std::string code;
Logger *logger = Logger::Get("Worker");
if (is_function)
{
// convert the function to a string block
code = "(";
code += args.at(0)->ToString();
code += ")()";
}
else
{
// this is a path -- probably should verify that this is relative and not an absolute URL to remote
SharedKMethod appURLToPath = global->GetNS("App.appURLToPath")->ToMethod();
ValueList a;
a.push_back(args.at(0));
SharedValue result = appURLToPath->Call(a);
const char *path = result->ToString();
logger->Debug("worker file path = %s",path);
std::ios::openmode flags = std::ios::in;
Poco::FileInputStream *fis = new Poco::FileInputStream(path,flags);
std::stringstream ostr;
char buf[8096];
int count = 0;
while(!fis->eof())
{
fis->read((char*)&buf,8095);
std::streamsize len = fis->gcount();
if (len>0)
{
buf[len]='\0';
count+=len;
ostr << buf;
}
else break;
}
fis->close();
code = std::string(ostr.str());
}
logger->Debug("Worker script code = %s", code.c_str());
SharedKObject worker = new Worker(host,global,code);
result->SetObject(worker);
}
示例14: _AddTray
void UIBinding::_AddTray(const ValueList& args, SharedValue result)
{
args.VerifyException("createTrayIcon", "s,?m");
std::string iconURL = args.GetString(0);
SharedKMethod cb = args.GetMethod(1, NULL);
AutoTrayItem item = this->AddTray(iconURL, cb);
this->trayItems.push_back(item);
result->SetObject(item);
}
示例15: _AddItem
void Menu::_AddItem(const ValueList& args, SharedValue result)
{
args.VerifyException("addItem", "?s m|0 s|0");
UIBinding* binding = UIBinding::GetInstance();
// Create a menu item object and add it to this item's submenu
AutoMenuItem newItem = binding->__CreateMenuItem(args);
this->AppendItem(newItem);
result->SetObject(newItem);
}