• <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>

            socketref,再見!高德

            https://github.com/adoggie

              C++博客 :: 首頁 :: 聯系 :: 聚合  :: 管理
              246 Posts :: 4 Stories :: 312 Comments :: 0 Trackbacks

            常用鏈接

            留言簿(54)

            我參與的團隊

            搜索

            •  

            最新評論

            閱讀排行榜

            評論排行榜


            table 是個怪物,有很多facets,類似array,map,struct,整個是個混合物,用起來也比較怪異。
            t={1,2,3,a="gen",b=100}
            t={[0]=1;["name"]="ultra"}
            t.a, t.b , t[0] , t["name"]

            表操作函數:
            ipairs,pairs迭代函數
            table.getn(t)   len of table

            ================================================================
            function() 可以接受任意多的參數,如果實參數過多將丟棄,過少將默認設置為nil
            同樣可以返回多個參數
            a,b=foo()

            表作為參數傳遞到function
            function rename( arg ) os.rename(arg.old,arg.new) end
            rename{old="";new=""}

            匿名函數(lambda in python )
            foo = function(x) return x*2 end
            局部函數 local f=function(x) ... end
            ================================================================
            for n=start,end,step do ... end
            while b do   ... end
            repeat do .... until

            if then .. elseif then ...  end;

            有意思的語法表達式:
                print a or b or c   如果a=false,嘗試b...

            注釋: --     --{ --} 


            字符串操作:    .. 連接

            ==================================================
            io 函數:
            loadfile('test.lua')()    execute external lua script
            loadstring('print 100')()


            代碼測試:
            =======================
            c程序調用lua函數
            c 程序:
            void call_lua_func(){
                lua_State *s = lua_open();
                luaL_openlibs(s);
                int c = lua_gettop(s);
                luaL_dofile(s,"/nandflashpartition/test1.lua");
                lua_getglobal(s,"add");
                lua_pushnumber(s,0.25);
                lua_pushnumber(s,8);
                if( lua_pcall(s,2,1,0)){
                    std::cout<< lua_tostring(s,-1)<<std::endl;
                }
                double r;
                r = lua_tonumber(s,-1);
                lua_close(s);
            }
            lua程序:
            function add(x,y)
                return x*y
            end
            --------------------------------
            lua訪問c程序空間變量

            1.定義變量student.h
            extern char * gender;
            extern int class_count;

            2.創建pkg文件 student.pkg
            $#include "student.h"
            extern char * gender;
            extern int class_count;

            3.產生tolua++存根框架
            tolua++ -o student.pkg

            4.創建lua測試代碼 call_c.lua
            print(gender)
            print(class_count)  訪問c 空間的變量

            5.c測試代碼
            char * gender;
            int class_count;
            void lua_call_c(){
                int  tolua_student_open (lua_State* tolua_S);
                lua_State * s = lua_open();
                luaopen_base(s);

                gender ="my gender is male!";
                class_count = 100;
                tolua_student_open(s);
                luaL_dofile(s,"/nandflashpartition/call_c.lua");
                lua_close(s);
            }

            6.build && test it!



            posted on 2008-05-13 03:13 放屁阿狗 閱讀(635) 評論(0)  編輯 收藏 引用 所屬分類: C++/Boost/STL/Templateperl/python/php/lua/tcl
            久久这里的只有是精品23| 久久99精品久久久久久野外| 日韩人妻无码一区二区三区久久99| 久久久久女教师免费一区| 久久精品国产亚洲一区二区三区 | av无码久久久久不卡免费网站| 亚洲AV无码久久| 久久噜噜电影你懂的| 亚洲va久久久久| 国内精品九九久久久精品| 精品久久久久久无码中文字幕 | 国产精品岛国久久久久| 久久国产视屏| 久久96国产精品久久久| 亚洲欧美日韩精品久久亚洲区 | 久久国产综合精品五月天| 久久人人爽人人爽人人片AV高清 | 国内精品免费久久影院| av色综合久久天堂av色综合在| 99久久精品国产综合一区| 久久国产色AV免费观看| 亚洲精品tv久久久久| 久久成人永久免费播放| 久久精品www| 精品久久久久久无码中文字幕一区| 中文国产成人精品久久亚洲精品AⅤ无码精品 | 99久久免费国产精品| 韩国免费A级毛片久久| 久久人人爽人人爽人人爽| 亚洲欧美国产日韩综合久久 | 亚洲国产成人久久一区久久| 久久久久人妻一区精品| 久久AAAA片一区二区| 欧美精品一本久久男人的天堂| 午夜久久久久久禁播电影| 久久久噜噜噜久久中文字幕色伊伊 | 欧美日韩精品久久久免费观看| 久久久精品视频免费观看| 久久99精品久久久久久噜噜| 精品国产91久久久久久久a| 久久国产成人亚洲精品影院|