本文整理汇总了C++中JObject::SetProperty方法的典型用法代码示例。如果您正苦于以下问题:C++ JObject::SetProperty方法的具体用法?C++ JObject::SetProperty怎么用?C++ JObject::SetProperty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JObject
的用法示例。
在下文中一共展示了JObject::SetProperty方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Start
int Start(char* src) {
if (!InitJerry()) {
DLOG("InitJerry failed");
return 1;
}
JObject* process = InitModules();
// FIXME: this should be moved to seperate function
{
JObject argv;
argv.SetProperty("1", JObject(src));
process->SetProperty("argv", argv);
}
if (!StartIoTjs(process)) {
DLOG("StartIoTJs failed");
return 1;
}
CleanupModules();
ReleaseJerry();
return 0;
}
示例2: InitTcp
JObject* InitTcp() {
Module* module = GetBuiltinModule(MODULE_TCP);
JObject* tcp = module->module;
if (tcp == NULL) {
tcp = new JObject(TCP);
JObject prototype;
tcp->SetProperty("prototype", prototype);
prototype.SetMethod("open", Open);
prototype.SetMethod("close", Close);
prototype.SetMethod("connect", Connect);
prototype.SetMethod("bind", Bind);
prototype.SetMethod("listen", Listen);
prototype.SetMethod("write", Write);
prototype.SetMethod("readStart", ReadStart);
prototype.SetMethod("shutdown", Shutdown);
prototype.SetMethod("setKeepAlive", SetKeepAlive);
module->module = tcp;
}
return tcp;
}
示例3: FnSet
int JLuaServer::FnSet( lua_State* pLua )
{
if (lua_gettop( pLua ) < 3 || lua_gettop( pLua ) > 4)
{
rlog.err( "LUA: Incorrect command usage: <set>. "
"Function takes 3 or 4 arguments (<objectRef>|<objectName>, <propName>, <val>, [tag]), but %d is provided",
lua_gettop( pLua ) );
lua_settop( pLua, 0 );
lua_pushnil( pLua );
return 1;
}
JObject* pObj = NULL;
const char* pPath = lua_tostring( pLua, 1 );
if (pPath)
{
JLuaThread* pThread = reinterpret_cast<JLuaThread*>( pLua->userdata );
assert( pThread->m_pLua == pLua );
JObject* pRootObj = pThread->m_pRootObj;
pObj = g_pObjectServer->FindObject( pPath, NULL, pRootObj );
}
else
{
pObj = reinterpret_cast<JObject*>( lua_touserdata( pLua, 1 ) );
}
const char* pPropName = lua_tostring( pLua, 2 );
const char* pPropVal = lua_tostring( pLua, 3 );
if (!pPropVal && lua_isboolean( pLua, 3 ))
{
bool bVal = lua_toboolean( pLua, 3 ) == 0 ? false : true;
pPropVal = bVal ? "true" : "false";
}
int tag = -1;
if (lua_isnumber( pLua, 4 ))
{
tag = (int)lua_tonumber( pLua, 4 );
}
if (!pObj)
{
rlog.warn( "LUA: Trying to call <set> for the nil object." );
return 0;
}
bool bRes = pObj->SetProperty( pPropName, pPropVal, tag );
if (!bRes)
{
rlog.err( "LUA: Could not set property '%s' for object '%s' of type '%s'.",
pPropName, pObj->GetName(), pObj->ClassName() );
}
return 0;
} // JLuaServer::FnSet
示例4: ExtractStrings
void JStringServer::ExtractStrings()
{
FILE* fp = fopen( "strings.txt", "wt" );
if (!fp)
{
return;
}
m_Dictionary.clear();
// extract text strings
JObjectIterator it( JCore::s_pInstance );
JString val, hash;
while (it)
{
JObject* pObj = *it;
if (pObj->HasName( "system" ))
{
it.breadth_next();
continue;
}
++it;
bool bRes = pObj->GetProperty( "text", val );
if (!bRes || val.size() == 0 || val[0] == '#')
{
continue;
}
if (!HasCyrillics( val.c_str() ))
{
continue;
}
HashString( val.c_str(), hash );
JStringDictionary::iterator location = m_Dictionary.find( hash );
JString taggedHash = "#";
taggedHash += hash;
pObj->SetProperty( "text", taggedHash.c_str() );
if (location != m_Dictionary.end())
{
if (val == (*location).second)
{
continue;
}
assert( false );
}
fprintf( fp, "%s %s\n", hash.c_str(), val.c_str() );
m_Dictionary[hash] = val;
}
fclose( fp );
// save scripts
g_pPersistServer->SaveScripts();
}
示例5: InitBuffer
JObject* InitBuffer() {
Module* module = GetBuiltinModule(MODULE_BUFFER);
JObject* buffer = module->module;
if (buffer == NULL) {
buffer = new JObject(Buffer);
JObject prototype;
buffer->SetProperty("prototype", prototype);
prototype.SetMethod("compare", Compare);
prototype.SetMethod("copy", Copy);
prototype.SetMethod("write", Write);
prototype.SetMethod("slice", Slice);
prototype.SetMethod("toString", ToString);
module->module = buffer;
}
return buffer;
}