当前位置: 首页>>代码示例>>C++>>正文


C++ JObject::ClassName方法代码示例

本文整理汇总了C++中JObject::ClassName方法的典型用法代码示例。如果您正苦于以下问题:C++ JObject::ClassName方法的具体用法?C++ JObject::ClassName怎么用?C++ JObject::ClassName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在JObject的用法示例。


在下文中一共展示了JObject::ClassName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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
开发者ID:skopp,项目名称:rush,代码行数:54,代码来源:luafunc.cpp

示例2: FnCall

int JLuaServer::FnCall( lua_State* pLua )
{
    if (lua_gettop( pLua ) < 2 || lua_gettop( pLua ) > 3)
    {
        rlog.err( "LUA: Incorrect command usage: <call>. "
            "Function takes 2 to 3 arguments (object|objectName, funcName, [tag]), but %d is provided", lua_gettop( pLua ) );
        lua_settop( pLua, 0 );
        return 0;
    }

    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 );
        if (!pObj)
        {
            rlog.warn( "LUA: Method <call> refers to non-existing object: %s", pPath );
            return NULL;
        }
    }
    else
    {
        pObj = reinterpret_cast<JObject*>( lua_touserdata( pLua, 1 ) );
        if (!pObj)
        {
            rlog.warn( "LUA: Trying to call <call> for the nil object" );
            return NULL;
        }
    }
    
    const char* pMethodName = lua_tostring( pLua, 2 );

    int tag = -1;
    if (lua_isnumber( pLua, 3 ))
    {
        tag = (int)lua_tonumber( pLua, 3 );
    }

    bool bRes = pObj->CallMethod( pMethodName, tag );
    if (!bRes)
    {
        rlog.err( "LUA: Could not call method '%s' for object '%s' of type '%s'.", 
            pMethodName, pObj->GetName(), pObj->ClassName() );
    }
    return 0;
} // JLuaServer::FnCall
开发者ID:skopp,项目名称:rush,代码行数:50,代码来源:luafunc.cpp

示例3: FnGet

int JLuaServer::FnGet( lua_State* pLua )
{
    if (lua_gettop( pLua ) < 2 || lua_gettop( pLua ) > 3)
    {
        rlog.err( "LUA: Incorrect command usage: <get>. "
            "Function takes 2 or 3 arguments (<objectRef>|<objectName>, <propName>, [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 );
    int tag = -1;
    if (lua_isnumber( pLua, 3 ))
    {
        tag = (int)lua_tonumber( pLua, 3 );
    }

    if (!pObj)
    {
        rlog.warn( "LUA: Trying to call <get> for the nil object. Nil is returned." );
        lua_pushnil( pLua );
        return 1;
    }

    static JString val;
    bool bRes = pObj->GetProperty( pPropName, val, tag );
    if (!bRes)
    {
        rlog.err( "LUA: Could not get property '%s' for object '%s' of type '%s'.", 
            pPropName, pObj->GetName(), pObj->ClassName() );
    }

    lua_pushstring( pLua, val.c_str() );
    return 1;
} // JLuaServer::FnGet
开发者ID:skopp,项目名称:rush,代码行数:49,代码来源:luafunc.cpp


注:本文中的JObject::ClassName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。