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

            的筆記

            隨時隨地編輯

            lua開發(fā)記錄

            編譯lua5.3

            cl /MD /O2 /c /DLUA_BUILD_AS_DLL *.c
            ren lua.obj lua.o
            ren luac.obj luac.o
            link /DLL /IMPLIB:lua5.3.0.lib /OUT:lua5.3.0.dll *.obj
            link /OUT:lua.exe lua.o lua5.3.0.lib
            lib /OUT:lua5.3.0-static.lib *.obj
            link /OUT:luac.exe luac.o lua5.3.0-static.lib
            

            require模塊

            http://cloudwu.github.io/lua53doc/manual.html#pdf-require
            當(dāng)請求 a.b.c 時, 它將查找 a 這個 C 庫。 如果找得到,它會在里面找子模塊的加載函數(shù)。 在我們的例子中,就是找 luaopen_a_b_c。 利用這個機(jī)制,可以把若干 C 子模塊打包進(jìn)單個庫。 每個子模塊都可以有原本的加載函數(shù)名。

            require不會重復(fù)加載

            顯示當(dāng)前加載的所有模塊

            for k,v in pairs(package.loaded) do
            print(k,v)
            end
            

            Lua Stack

            +-----------------------+
            | element with index 6 | <-- top ("relative" index -1)
            +-----------------------+
            | element with index 5 | <-- -2
            +-----------------------+
            | element with index 4 | <-- -3
            +-----------------------+
            | element with index 3 | <-- -4
            +-----------------------+
            | element with index 2 | <-- -5
            +-----------------------+
            | element with index 1 | <-- bottom ("relative" index -6 )
            +-----------------------+
            

            PIL

            Programming in Lua

            lua_call

            a = f("how", t.x, 14)

            lua_getglobal(L, "f"); /* function to be called */
            lua_pushliteral(L, "how"); /* 1st argument */
            lua_getglobal(L, "t"); /* table to be indexed */
            lua_getfield(L, -1, "x"); /* push result of t.x (2nd arg) */
            lua_remove(L, -2); /* remove 't' from the stack */
            lua_pushinteger(L, 14); /* 3rd argument */
            lua_call(L, 3, 1); /* call 'f' with 3 arguments and 1 result */
            lua_setglobal(L, "a"); /* set global 'a' */
            

            lua_setfield

            void lua_setfield (lua_State *L, int index, const char *k);

            做一個等價于 t[k] = v 的操作, 這里 t 是給出的索引處的值, 而 v 是棧頂?shù)哪莻€值。

          1. 扯淡1,lua_setfield(A,B), A一定是棧的一個位置,這個位置一定是個table,B必須是table的一個索引值,而棧頂?shù)闹蒂x值給這個索引值。
          2. 扯淡2,set(i,k)。set的參數(shù)i和k只是確定了table的索引位置,那個值在棧頂,也就是站上-1的位置

          3. dynamic libraries not enabled

            Error:

            lua 5.3 error: dynamic libraries not enabled; check your Lua installation

            Fix:

            luaconf.h
            #define LUA_DL_DLL
            

            8 basic types

            nil,boolean,number,string,function,userdata,thread, andtable

            Light Userdata

            ref:https://www.lua.org/pil/28.5.html
          4. A light userdatum is a value that represents a C pointer (that is, avoid *value)
          5. Light userdata are not buffers, but single pointers.They have no metatables. Like numbers, light userdata do not need to be managed by the garbage collector (and are not).
          6. it is equal to any userdata that represents the same pointer

          7. Userdata

            The userdata type allows arbitrary C data to be stored in Lua variables.
          8. 用戶數(shù)據(jù)類型的值是一個內(nèi)存塊, 有兩種用戶數(shù)據(jù):完全用戶數(shù)據(jù),指一塊由 Lua 管理的內(nèi)存對應(yīng)的對象;輕量用戶數(shù)據(jù),則指一個簡單的 C 指針
          9. 用戶數(shù)據(jù)在 Lua 中除了賦值與相等性判斷之外沒有其他預(yù)定義的操作。
          10. 你只能通過 C API 而無法在 Lua 代碼中創(chuàng)建或者修改用戶數(shù)據(jù)的值

          11. userdata 操作

          12. lua_islightuserdata
          13. 判斷給定索引的值是一個輕量用戶數(shù)據(jù)
          14. lua_isuserdata
          15. 判斷給定索引的值是一個用戶數(shù)據(jù)(無論是完全的還是輕量的)
          16. lua_newuserdata
          17. 這個函數(shù)分配一塊指定大小的內(nèi)存塊, 把內(nèi)存塊地址作為一個完全用戶數(shù)據(jù)壓棧, 并返回這個地址。 宿主程序可以隨意使用這塊內(nèi)存。
          18. lua_pushlightuserdata
          19. 把一個輕量用戶數(shù)據(jù)壓棧。輕量用戶數(shù)據(jù)表示一個指針void*。 它是一個像數(shù)字一樣的值: 你不需要專門創(chuàng)建它,它也沒有獨立的元表,而且也不會被收集(因為從來不需要創(chuàng)建)。 只要表示的 C 地址相同,兩個輕量用戶數(shù)據(jù)就相等。
          20. lua_touserdata
          21. 如果給定索引處的值是一個完全用戶數(shù)據(jù), 函數(shù)返回其內(nèi)存塊的地址。如果值是一個輕量用戶數(shù)據(jù), 那么就返回它表示的指針。

            冒號語法糖

            冒號語法可以用來定義方法,就是說,函數(shù)可以有一個隱式的形參 self。因此,如下語句

                function c:f(params) body end

            是這樣一種寫法的語法糖

                c.f = function(self, params) body end

          22. 也就是說,如果用冒號定義函數(shù),則等價于給函數(shù)增加了一個隱含的形參self
          23. 當(dāng)用冒號去訪問方法,相當(dāng)于隱含的傳遞了一個形參self
          24. 如果希望方法引用其所屬表上的其他變量,你可以加個冒號,這相當(dāng)于將方法所屬的表當(dāng)作class來使用

            冒號語法糖方法訪問原則

          25. 函數(shù)定義時帶冒號,則函數(shù)訪問時也帶冒號;同理,點號定義,則點號訪問
          26. 不按規(guī)矩來,則要注意了:

          27. 冒號定義方法,但卻不帶冒號訪問,則造成調(diào)用的時候,將第一個形參數(shù)賦值給self了。
          28. 可以這樣理解,當(dāng)用非冒號調(diào)用,則如果定義的函數(shù)用了冒號糖,則將糖展開為function foo(self, ...) end。------吃糖要先剝紙就是這個道理


            <占位標(biāo)題>

            <占位描述占位描述占位描述占位描述占位描述占位描述占位描述占位描述占位描述占位描述占位描述占位描述占位描述占位描述占位描述占位描述>
          29. <占位項1>
          30. <占位項2>

          31. <占位標(biāo)題>

            <占位描述占位描述占位描述占位描述占位描述占位描述占位描述占位描述占位描述占位描述占位描述占位描述占位描述占位描述占位描述占位描述>
          32. <占位項1>
          33. <占位項2>

          34. <占位標(biāo)題>

            <占位描述占位描述占位描述占位描述占位描述占位描述占位描述占位描述占位描述占位描述占位描述占位描述占位描述占位描述占位描述占位描述>
          35. <占位項1>
          36. <占位項2>

          37. <占位標(biāo)題>

            <占位描述占位描述占位描述占位描述占位描述占位描述占位描述占位描述占位描述占位描述占位描述占位描述占位描述占位描述占位描述占位描述>
          38. <占位項1>
          39. <占位項2>

          40. <占位標(biāo)題>

            <占位描述占位描述占位描述占位描述占位描述占位描述占位描述占位描述占位描述占位描述占位描述占位描述占位描述占位描述占位描述占位描述>
          41. <占位項1>
          42. <占位項2>

          43. posted on 2015-12-24 16:18 的筆記 閱讀(1226) 評論(0)  編輯 收藏 引用


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


            成人a毛片久久免费播放| 久久综合给合久久狠狠狠97色 | 91精品国产91久久久久久蜜臀| 97精品依人久久久大香线蕉97| 日本人妻丰满熟妇久久久久久| 久久精品夜夜夜夜夜久久| 久久国产亚洲精品麻豆| 久久久久久国产精品无码下载| 精品久久久无码人妻中文字幕| 久久精品国产乱子伦| 久久九九青青国产精品| 国产精品激情综合久久| 伊人色综合久久天天人手人婷| 久久精品无码午夜福利理论片| 久久99精品国产麻豆婷婷| 人妻无码αv中文字幕久久| 久久精品亚洲男人的天堂| 久久久久成人精品无码中文字幕| 国产精品激情综合久久 | 无码人妻精品一区二区三区久久久| 久久96国产精品久久久| 噜噜噜色噜噜噜久久| 狠狠色综合网站久久久久久久| 亚洲精品无码久久久久sm| 久久亚洲2019中文字幕| 国产精品久久永久免费| 久久中文字幕人妻丝袜| 久久精品一区二区三区中文字幕 | 国产成人久久精品区一区二区| 亚洲欧美另类日本久久国产真实乱对白 | 国产三级久久久精品麻豆三级| 欧美精品福利视频一区二区三区久久久精品 | 亚洲Av无码国产情品久久| 很黄很污的网站久久mimi色| 欧美一区二区三区久久综| 午夜精品久久久久久| 久久精品无码一区二区三区免费| 91久久香蕉国产熟女线看| 久久综合久久综合久久| 精品久久一区二区三区| 色综合色天天久久婷婷基地|