zoukankan      html  css  js  c++  java
  • Lua

    lua_State* lua_state; //定义对象
    lua_state = luaL_newstate();
    
    
        luaL_openlibs(lua_state);
        if(lua_state == NULL)
        {
            LOGERROR("错误:初始化lua环境失败!");
            m_error = "错误:初始化lua环境失败!";
            return false;
        }
        luabridge::getGlobalNamespace(lua_state)
                .beginNamespace ("kbd")
                .addFunction ("getDataByIndex",&CCalcLua::getDataByIndex)
                .endNamespace ();
      
      
    lua_settop(lua_state,0);
        try
        {
            if( LUA_OK != luaL_dostring(lua_state,m_content.toStdString().c_str()) )
            {
                LOGERROR("错误:验证公式正确性失败!");
                m_error ="错误:验证公式正确性失败!";
                return false;
            }
        }catch(std::exception &ex)
        {
            m_error = QString::fromStdString(ex.what());
            LOGERROR("错误:验证公式正确性异常[%s]!",ex.what());
            return false;
        }

      //执行
      luabridge::LuaRef objFunc = luabridge::getGlobal(lua_state, m_name.toStdString().c_str());
    
    
            luabridge::LuaRef ret = objFunc();

      ret//需要解析

      
    lua_close(lua_state);//释放
    不为其他,只为快乐!
  • 相关阅读:
    笔试题 1.3 百度 2012 10.09 简答题 + 程设 --A
    windows中搜索dll的顺序
    笔试题 1.2 关于大文件处理:
    笔试题 1.1 最少比赛数目
    小优化
    LightOJ
    LightOJ
    LightOJ
    LightOJ
    LightOJ
  • 原文地址:https://www.cnblogs.com/1521299249study/p/12083306.html
Copyright © 2011-2022 走看看