本文整理汇总了C++中Handle::SetName方法的典型用法代码示例。如果您正苦于以下问题:C++ Handle::SetName方法的具体用法?C++ Handle::SetName怎么用?C++ Handle::SetName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Handle
的用法示例。
在下文中一共展示了Handle::SetName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: context_scope
extern "C" Handle<Value> create_function(Persistent<Context> context,
char* source_s,
char* name) {
// Create a stack-allocated handle scope.
HandleScope handle_scope;
Context::Scope context_scope(context);
// Create a string containing the JavaScript source code.
Handle<String> source = String::New(source_s);
// Compile the source code.
Handle<Script> script = Script::Compile(source);
// Run the script to get the result.
Handle<Value> result = script->Run();
// magic
Handle<Object> global = context->Global();
Handle<Value> value = global->Get(String::New(name));
Handle<Function> func = v8::Handle<Function>::Cast(value);
func->SetName(String::New(name));
Persistent<Function> persistent_func = Persistent<Function>::New(func);
return persistent_func;
}
示例2:
int LuaV6Chat3App::ChangeServerInfo(lua_State *luaState)
{
V6Chat3App *App = GetV6Chat3App(luaState);
if (App)
{
int id = lua_tointeger(luaState, 2);
ServerList *list = ServerList::Instance();
Handle<ServerInfo> server;
if(list->GetServer(id, server))
{
size_t name_len=lua_objlen(luaState, 3);
const char *name = lua_tolstring(luaState, 3, &name_len);
size_t admain_len=lua_objlen(luaState, 4);
const char *admain = lua_tolstring(luaState, 4, &admain_len);
size_t account_len=lua_objlen(luaState, 5);
const char *account = lua_tolstring(luaState, 5, &account_len);
size_t password_len=lua_objlen(luaState, 6);
const char *password = lua_tolstring(luaState, 6, &password_len);
size_t introduction_len=lua_objlen(luaState, 7);
const char *introduction = lua_tolstring(luaState, 7, &introduction_len);
if(name)
server->SetName(V6Util::Utf8ToUnicode(name));
if(admain)
server->SetIp(admain);
if(account)
server->SetUid(account);
if(password)
server->SetUpassword(password);
if(introduction)
server->SetDescription(V6Util::Utf8ToUnicode(introduction));
if(server->HasChange())
{
server->DisConnect();
server->Connect();
}
}
}
return 0;
}