• <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++博客 首頁 新隨筆 聯(lián)系 聚合 管理
              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 閱讀(248) 評(píng)論(0)  編輯 收藏 引用

            只有注冊(cè)用戶登錄后才能發(fā)表評(píng)論。
            網(wǎng)站導(dǎo)航: 博客園   IT新聞   BlogJava   博問   Chat2DB   管理


            欧美麻豆久久久久久中文| 久久综合狠狠综合久久激情 | 久久99精品国产99久久6男男| 亚洲综合精品香蕉久久网| 久久婷婷人人澡人人爽人人爱| 香港aa三级久久三级老师2021国产三级精品三级在 | 亚洲v国产v天堂a无码久久| 大香网伊人久久综合网2020| 久久国产精品免费| 午夜精品久久久久久久| 午夜视频久久久久一区 | 国产aⅴ激情无码久久| 99久久无码一区人妻a黑| 久久久久亚洲精品天堂久久久久久 | 欧美日韩成人精品久久久免费看| 久久精品国产69国产精品亚洲| 久久ww精品w免费人成| 亚洲欧美日韩久久精品| 一本久久综合亚洲鲁鲁五月天亚洲欧美一区二区 | 丁香色欲久久久久久综合网| 精品久久久久久| 午夜欧美精品久久久久久久| 亚洲欧美一级久久精品| 少妇被又大又粗又爽毛片久久黑人 | 欧美日韩精品久久久久| 亚洲精品乱码久久久久久蜜桃图片 | 久久精品国产只有精品66| 午夜不卡888久久| 99久久免费国产精品| 老司机国内精品久久久久| 久久无码国产| 久久精品a亚洲国产v高清不卡| 热re99久久6国产精品免费| 女人香蕉久久**毛片精品| 久久久精品波多野结衣| 精品久久久久久无码不卡| 久久精品国产99国产精品亚洲| 久久精品欧美日韩精品| 91麻豆国产精品91久久久| 国内精品久久国产大陆| 国产99久久久国产精品小说|