• <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 放屁阿狗 閱讀(629) 評論(0)  編輯 收藏 引用 所屬分類: C++/Boost/STL/Templateperl/python/php/lua/tcl
            久久天天躁夜夜躁狠狠| 久久这里都是精品| a级毛片无码兔费真人久久| 久久精品国产一区二区三区不卡| 亚洲精品国产第一综合99久久| 欧美粉嫩小泬久久久久久久 | 久久无码av三级| 久久人人爽人人澡人人高潮AV| 综合久久给合久久狠狠狠97色 | 99久久精品免费国产大片| 久久99久久99精品免视看动漫| 久久国产亚洲精品无码| 亚洲第一极品精品无码久久| 亚洲国产成人精品91久久久 | 国产成人99久久亚洲综合精品 | 久久久久亚洲精品天堂| 免费一级做a爰片久久毛片潮 | 亚洲欧洲精品成人久久奇米网| 国产亚洲色婷婷久久99精品| 7777精品久久久大香线蕉| 老男人久久青草av高清| 久久精品免费全国观看国产| 99精品国产在热久久无毒不卡| 国产精品久久久亚洲| 国产成人综合久久精品红| 久久综合九色欧美综合狠狠| 99久久www免费人成精品| 久久精品国产亚洲av高清漫画| 中文字幕人妻色偷偷久久| 久久久久亚洲AV成人网人人网站| 久久精品国产99国产精品澳门| 国产精品无码久久久久| 欧美伊香蕉久久综合类网站| 99国产欧美精品久久久蜜芽| 天天躁日日躁狠狠久久| 国产精品久久久久a影院| 亚洲国产精品一区二区三区久久 | 国产精品激情综合久久| 久久综合综合久久狠狠狠97色88 | 精品无码久久久久国产| 性色欲网站人妻丰满中文久久不卡|