• <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 閱讀(244) 評論(0)  編輯 收藏 引用
            色综合久久88色综合天天| 亚洲&#228;v永久无码精品天堂久久| 久久久久青草线蕉综合超碰 | 久久这里只有精品首页| 草草久久久无码国产专区| 91精品国产综合久久婷婷| 成人资源影音先锋久久资源网| 日韩精品久久久久久久电影蜜臀| 国产香蕉久久精品综合网| 久久精品极品盛宴观看| 久久人妻AV中文字幕| 久久亚洲精品无码aⅴ大香| 久久国语露脸国产精品电影| 久久精品国产亚洲av麻豆图片| 欧美日韩精品久久久免费观看| 久久天天婷婷五月俺也去| 狠狠精品久久久无码中文字幕| 久久精品国产亚洲AV忘忧草18| 波多野结衣AV无码久久一区| 人妻少妇久久中文字幕| 久久精品国产久精国产| 久久久久九九精品影院| 久久热这里只有精品在线观看| 亚洲愉拍99热成人精品热久久| 国产高潮国产高潮久久久| 亚洲午夜久久久精品影院 | 97精品伊人久久久大香线蕉 | 国内精品久久久久久久亚洲 | 亚洲国产精品人久久| 久久综合狠狠综合久久97色| 久久精品中文字幕一区| 国产精品免费福利久久| 久久久久人妻一区精品果冻| 久久亚洲中文字幕精品一区| 久久久久国产精品| 色欲综合久久躁天天躁| 国产精品久久免费| 久久国产AVJUST麻豆| 夜夜亚洲天天久久| 综合人妻久久一区二区精品| 亚洲国产精品久久66|