• <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 放屁阿狗 閱讀(628) 評論(0)  編輯 收藏 引用 所屬分類: C++/Boost/STL/Templateperl/python/php/lua/tcl
            中文成人无码精品久久久不卡| 久久久午夜精品| 亚洲精品乱码久久久久久中文字幕| 精品国产综合区久久久久久 | 狠狠色丁香婷综合久久| 久久久久久精品久久久久| 久久久久99精品成人片| 国产精品99久久久久久董美香| 久久无码av三级| AA级片免费看视频久久| 午夜不卡888久久| 国产成人AV综合久久| 精品久久久久久国产牛牛app| 免费国产99久久久香蕉| 91精品国产色综久久| 国产精品嫩草影院久久| 久久99精品免费一区二区| 久久久久九九精品影院| 伊人久久精品影院| 久久久久人妻一区二区三区| 久久精品国产久精国产果冻传媒| 久久国产色av免费看| 色88久久久久高潮综合影院| 2022年国产精品久久久久| 日本久久久精品中文字幕| 久久精品二区| 久久人做人爽一区二区三区| 久久永久免费人妻精品下载| 国产精品久久成人影院| 国内精品久久久久久久久| 日本久久中文字幕| 日韩久久久久久中文人妻| 国产欧美久久久精品| 久久婷婷色综合一区二区| 亚洲国产精品久久电影欧美| 久久九九亚洲精品| 亚洲精品国精品久久99热| 久久久无码人妻精品无码| 伊人久久免费视频| 久久精品亚洲AV久久久无码| 2020最新久久久视精品爱 |