• <ins id="pjuwb"></ins>
    <blockquote id="pjuwb"><pre id="pjuwb"></pre></blockquote>
    <noscript id="pjuwb"></noscript>
          <sup id="pjuwb"><pre id="pjuwb"></pre></sup>
            <dd id="pjuwb"></dd>
            <abbr id="pjuwb"></abbr>

            Error

            C++博客 首頁 新隨筆 聯系 聚合 管理
              217 Posts :: 61 Stories :: 32 Comments :: 0 Trackbacks
            #include <iostream>
            extern "C"
            {
            #include "lua.h"
            #include "lauxlib.h"
            #include "lualib.h"
            }
            #include <luabind/luabind.hpp>
            using namespace luabind;
            class TestClass
            {
            public:
            TestClass(int a,int b);
            static TestClass* Singleton();
            int add();
            virtual void ShowTest(std::string& strMsg);
            private:
            static TestClass* mSingleton;
            int __a,__b;
            };
            void TestClass::ShowTest(std::string& strMsg)
            {
            std::cout << __FUNCTION__ << std::endl;
            std::cout << strMsg.c_str() << std::endl;
            strMsg += "000";
            }
            TestClass* TestClass::mSingleton = NULL;
            TestClass::TestClass(int a,int b)
            {
            __a = a;
            __b = b;
            mSingleton = this;
            }
            TestClass* TestClass::Singleton()
            {
            if(TestClass::mSingleton == NULL)
            {
            return new TestClass(0,0);
            }
            else
            {
            return mSingleton;
            }
            }
            int TestClass::add()
            {
            std::cout << __FUNCTION__ << std::endl;
            return __a+__b;
            }
            int bindClass(lua_State* L)
            {
            open(L);
            module(L)
            [
            class_<TestClass>("TestClass")
            //.def(constructor<int,int>())
            .def("add", &TestClass::add)
            .def("ShowTest", &TestClass::ShowTest),
            def("Singleton", &TestClass::Singleton)
            ];
            return 0;
            }
            int LuaErrorCallBack(lua_State *L)
            {
            std::cout << __FUNCTION__ << std::endl;
            return 0;
            }
            int main(int argc, char* argv[])
            {
            luabind::set_pcall_callback(&LuaErrorCallBack);
            TestClass testClass(10,5);
            lua_State* L = lua_open();  
            luaL_openlibs(L);
            std::cout << "init lua system" << std::endl;
            bindClass(L);
            std::cout << "do lua file" << std::endl;
            try
            {
            std::string strFileName = "add.lua.ini";
            int iRet = luaL_dofile(L, "add.lua.ini");
            if (iRet != 0)
            {
            std::cout<<"loadfile error[file: " << strFileName.c_str() << "]: "<<lua_tostring(L, -1)<<std::endl;
            }
            //if (luaL_loadfile(L, strFileName.c_str()) != 0) {
            // std::cout<<"loadfile error[file: " << strFileName.c_str() << "]"<<lua_tostring(L, -1)<<std::endl;
            //}
            //if (lua_pcall(L, 0, LUA_MULTRET, 0) != 0) {
            // std::cout<<"pcall error[file: " << strFileName.c_str() << "]" <<lua_tostring(L, -1)<<std::endl;
            //}
            std::cout << "end" << std::endl;
            //getchar();
            }
            catch(std::exception& ex)
            {
            std::cout << ex.what() << std::endl;
            }
            catch(luabind::error er)
            {
            std::cout << er.what() << std::endl;
            }
            lua_close(L);
            return 0;
            }


            print("This is valid")
            print(1234)
            bad_function()
            a = "meow"
            b = 7
            c = a + b
            testClass = Singleton()
            a = testClass:add()
            print(a)
            local valMsg = '中文'
            testClass:ShowTest(valMsg)
            print(valMsg)
            posted on 2014-01-06 16:49 Enic 閱讀(246) 評論(0)  編輯 收藏 引用
            精品久久久久久久| 久久久WWW免费人成精品| 精品综合久久久久久97| 色婷婷综合久久久中文字幕| 久久精品aⅴ无码中文字字幕不卡 久久精品aⅴ无码中文字字幕重口 | 四虎国产精品成人免费久久| 2021最新久久久视精品爱| 欧美牲交A欧牲交aⅴ久久| 热re99久久精品国产99热| 婷婷久久综合| 色综合久久88色综合天天| 精品久久久久久中文字幕大豆网| 久久精品这里热有精品| 无码八A片人妻少妇久久| 天天综合久久久网| 亚洲αv久久久噜噜噜噜噜| 国产午夜精品久久久久九九电影| A级毛片无码久久精品免费| 91久久精品国产成人久久| 日产精品99久久久久久| 久久久久亚洲精品天堂久久久久久| 久久亚洲私人国产精品vA | 亚洲AV无码久久精品色欲| 久久国产成人精品国产成人亚洲| 奇米影视7777久久精品| 99久久做夜夜爱天天做精品| 久久综合伊人77777| 久久综合成人网| 亚洲精品美女久久久久99小说 | 色综合久久88色综合天天| 亚洲国产欧美国产综合久久| 四虎国产精品成人免费久久| 91精品婷婷国产综合久久| 久久久久女人精品毛片| 午夜精品久久久久久中宇| 中文字幕热久久久久久久| 久久99这里只有精品国产| 伊人伊成久久人综合网777| 亚洲国产精品综合久久一线| 久久久免费观成人影院 | 91精品国产91久久久久福利|