??xml version="1.0" encoding="utf-8" standalone="yes"?>精品熟女少妇a∨免费久久,国产—久久香蕉国产线看观看,久久狠狠爱亚洲综合影院 http://www.shnenglu.com/sunicdavy/archive/2021/12/27/217894.html战魂筑战魂筑Mon, 27 Dec 2021 11:04:00 GMThttp://www.shnenglu.com/sunicdavy/archive/2021/12/27/217894.htmlhttp://www.shnenglu.com/sunicdavy/comments/217894.htmlhttp://www.shnenglu.com/sunicdavy/archive/2021/12/27/217894.html#Feedback0http://www.shnenglu.com/sunicdavy/comments/commentRss/217894.htmlhttp://www.shnenglu.com/sunicdavy/services/trackbacks/217894.html http://zhidao.baixing.com/question/11522863.html

http://zhidao.baixing.com/question/11522867.html

http://zhidao.baixing.com/question/11522873.html

http://zhidao.baixing.com/question/11522877.html

http://zhidao.baixing.com/question/11522881.html

http://zhidao.baixing.com/question/11522889.html

http://zhidao.baixing.com/question/11522891.html

http://zhidao.baixing.com/question/11522896.html

http://zhidao.baixing.com/question/11522897.html

http://zhidao.baixing.com/question/11522899.html

http://zhidao.baixing.com/question/11522901.html

http://zhidao.baixing.com/question/11522904.html

http://zhidao.baixing.com/question/11522910.html

http://zhidao.baixing.com/question/11522911.html

http://zhidao.baixing.com/question/11522912.html

http://zhidao.baixing.com/question/11522913.html

http://zhidao.baixing.com/question/11522916.html

http://zhidao.baixing.com/question/11522917.html

http://zhidao.baixing.com/question/11522923.html

http://zhidao.baixing.com/question/11522925.html

http://zhidao.baixing.com/question/11522931.html

http://zhidao.baixing.com/question/11522935.html

http://zhidao.baixing.com/question/11522936.html

http://zhidao.baixing.com/question/11522942.html

http://zhidao.baixing.com/question/11522945.html

http://zhidao.baixing.com/question/11522949.html

http://zhidao.baixing.com/question/11522952.html

http://zhidao.baixing.com/question/11522957.html

http://zhidao.baixing.com/question/11522962.html

http://zhidao.baixing.com/question/11522966.html

http://zhidao.baixing.com/question/11522968.html

http://zhidao.baixing.com/question/11522969.html

http://zhidao.baixing.com/question/11522971.html

http://zhidao.baixing.com/question/11522972.html

http://zhidao.baixing.com/question/11522976.html

http://zhidao.baixing.com/question/11522977.html

http://zhidao.baixing.com/question/11522979.html

http://zhidao.baixing.com/question/11522981.html

http://zhidao.baixing.com/question/11522982.html

http://zhidao.baixing.com/question/11522986.html

http://zhidao.baixing.com/question/11522990.html

http://zhidao.baixing.com/question/11522991.html

http://zhidao.baixing.com/question/11522993.html

http://zhidao.baixing.com/question/11522994.html

http://zhidao.baixing.com/question/11522999.html

http://zhidao.baixing.com/question/11523001.html

http://zhidao.baixing.com/question/11523002.html

http://zhidao.baixing.com/question/11523008.html

http://zhidao.baixing.com/question/11523011.html

http://zhidao.baixing.com/question/11523014.html

http://zhidao.baixing.com/question/11523017.html

http://zhidao.baixing.com/question/11523020.html

http://zhidao.baixing.com/question/11523023.html

http://zhidao.baixing.com/question/11523025.html

http://zhidao.baixing.com/question/11523028.html

http://zhidao.baixing.com/question/11523029.html

http://zhidao.baixing.com/question/11523035.html

http://zhidao.baixing.com/question/11523038.html

http://zhidao.baixing.com/question/11523042.html

http://zhidao.baixing.com/question/11523044.html

http://zhidao.baixing.com/question/11523045.html

http://zhidao.baixing.com/question/11523047.html

http://zhidao.baixing.com/question/11523049.html

http://zhidao.baixing.com/question/11523061.html

http://zhidao.baixing.com/question/11523063.html

http://zhidao.baixing.com/question/11523065.html

http://zhidao.baixing.com/question/11523066.html

http://zhidao.baixing.com/question/11523068.html

http://zhidao.baixing.com/question/11523076.html

http://zhidao.baixing.com/question/11523077.html

http://zhidao.baixing.com/question/11523082.html

http://zhidao.baixing.com/question/11523085.html

http://zhidao.baixing.com/question/11523086.html

http://zhidao.baixing.com/question/11523088.html

http://zhidao.baixing.com/question/11523093.html

http://zhidao.baixing.com/question/11523097.html

http://zhidao.baixing.com/question/11523098.html

http://zhidao.baixing.com/question/11523100.html

http://zhidao.baixing.com/question/11523102.html

http://zhidao.baixing.com/question/11523106.html

http://zhidao.baixing.com/question/11523109.html

http://zhidao.baixing.com/question/11523111.html

http://zhidao.baixing.com/question/11523113.html

http://zhidao.baixing.com/question/11523115.html

http://zhidao.baixing.com/question/11523116.html

http://zhidao.baixing.com/question/11523119.html

http://zhidao.baixing.com/question/11523121.html

http://zhidao.baixing.com/question/11523123.html

http://zhidao.baixing.com/question/11523125.html

http://zhidao.baixing.com/question/11523127.html

http://zhidao.baixing.com/question/11523132.html

http://zhidao.baixing.com/question/11523134.html

http://zhidao.baixing.com/question/11523136.html

http://zhidao.baixing.com/question/11523137.html

http://zhidao.baixing.com/question/11523139.html

http://zhidao.baixing.com/question/11523144.html

http://zhidao.baixing.com/question/11523147.html

http://zhidao.baixing.com/question/11523150.html

http://zhidao.baixing.com/question/11523151.html

http://zhidao.baixing.com/question/11523153.html

http://zhidao.baixing.com/question/11523155.html

http://zhidao.baixing.com/question/11523156.html

http://zhidao.baixing.com/question/11523159.html

http://zhidao.baixing.com/question/11523161.html

http://zhidao.baixing.com/question/11523164.html

http://zhidao.baixing.com/question/11523165.html

http://zhidao.baixing.com/question/11523168.html

http://zhidao.baixing.com/question/11523170.html

http://zhidao.baixing.com/question/11523171.html

http://zhidao.baixing.com/question/11523172.html

http://zhidao.baixing.com/question/11523173.html

http://zhidao.baixing.com/question/11523182.html

http://zhidao.baixing.com/question/11523184.html

http://zhidao.baixing.com/question/11523186.html

http://zhidao.baixing.com/question/11523188.html

http://zhidao.baixing.com/question/11523190.html

http://zhidao.baixing.com/question/11523196.html

http://zhidao.baixing.com/question/11523201.html

http://zhidao.baixing.com/question/11523203.html

http://zhidao.baixing.com/question/11523204.html

http://zhidao.baixing.com/question/11523206.html

http://zhidao.baixing.com/question/11523207.html

http://zhidao.baixing.com/question/11523213.html

http://zhidao.baixing.com/question/11523217.html

http://zhidao.baixing.com/question/11523220.html

http://zhidao.baixing.com/question/11523223.html

http://zhidao.baixing.com/question/11523225.html

http://zhidao.baixing.com/question/11523228.html

http://zhidao.baixing.com/question/11523230.html

http://zhidao.baixing.com/question/11523232.html

http://zhidao.baixing.com/question/11523234.html

http://zhidao.baixing.com/question/11523235.html

http://zhidao.baixing.com/question/11523237.html

http://zhidao.baixing.com/question/11523240.html

http://zhidao.baixing.com/question/11523242.html

http://zhidao.baixing.com/question/11523245.html

http://zhidao.baixing.com/question/11523248.html

http://zhidao.baixing.com/question/11523251.html

http://zhidao.baixing.com/question/11523254.html

http://zhidao.baixing.com/question/11523258.html

http://zhidao.baixing.com/question/11523262.html

http://zhidao.baixing.com/question/11523267.html

http://zhidao.baixing.com/question/11523268.html

http://zhidao.baixing.com/question/11523272.html

http://zhidao.baixing.com/question/11523277.html

http://zhidao.baixing.com/question/11523280.html

http://zhidao.baixing.com/question/11523281.html

http://zhidao.baixing.com/question/11523282.html

http://zhidao.baixing.com/question/11523287.html

http://zhidao.baixing.com/question/11523292.html

http://zhidao.baixing.com/question/11523298.html

http://zhidao.baixing.com/question/11523299.html

http://zhidao.baixing.com/question/11523301.html

http://zhidao.baixing.com/question/11523304.html

http://zhidao.baixing.com/question/11523305.html

http://zhidao.baixing.com/question/11523310.html

http://zhidao.baixing.com/question/11523312.html

http://zhidao.baixing.com/question/11523316.html

http://zhidao.baixing.com/question/11523320.html

http://zhidao.baixing.com/question/11523323.html

http://zhidao.baixing.com/question/11523325.html

http://zhidao.baixing.com/question/11523328.html

http://zhidao.baixing.com/question/11523330.html

http://zhidao.baixing.com/question/11523333.html

http://zhidao.baixing.com/question/11523337.html

http://zhidao.baixing.com/question/11523341.html

http://zhidao.baixing.com/question/11523345.html

http://zhidao.baixing.com/question/11523351.html

http://zhidao.baixing.com/question/11523355.html

http://zhidao.baixing.com/question/11523358.html

http://zhidao.baixing.com/question/11523360.html

http://zhidao.baixing.com/question/11523363.html

http://zhidao.baixing.com/question/11523367.html

http://zhidao.baixing.com/question/11523371.html

http://zhidao.baixing.com/question/11523375.html

http://zhidao.baixing.com/question/11523378.html

http://zhidao.baixing.com/question/11523380.html

http://zhidao.baixing.com/question/11523383.html

http://zhidao.baixing.com/question/11523386.html

http://zhidao.baixing.com/question/11523389.html

http://zhidao.baixing.com/question/11523394.html

http://zhidao.baixing.com/question/11523396.html

http://zhidao.baixing.com/question/11523399.html

http://zhidao.baixing.com/question/11523400.html

http://zhidao.baixing.com/question/11523404.html

http://zhidao.baixing.com/question/11523406.html

http://zhidao.baixing.com/question/11523412.html

http://zhidao.baixing.com/question/11523418.html

http://zhidao.baixing.com/question/11523422.html

http://zhidao.baixing.com/question/11523425.html

http://zhidao.baixing.com/question/11523428.html

http://zhidao.baixing.com/question/11523430.html

http://zhidao.baixing.com/question/11523432.html

http://zhidao.baixing.com/question/11523437.html

http://zhidao.baixing.com/question/11523441.html

http://zhidao.baixing.com/question/11523445.html

http://zhidao.baixing.com/question/11523446.html

http://zhidao.baixing.com/question/11523449.html

http://zhidao.baixing.com/question/11523452.html

http://zhidao.baixing.com/question/11523454.html

http://zhidao.baixing.com/question/11523460.html

http://zhidao.baixing.com/question/11523461.html

http://zhidao.baixing.com/question/11523468.html

http://zhidao.baixing.com/question/11523472.html

http://zhidao.baixing.com/question/11523475.html

http://zhidao.baixing.com/question/11523478.html

http://zhidao.baixing.com/question/11523481.html

http://zhidao.baixing.com/question/11523482.html

http://zhidao.baixing.com/question/11523485.html

http://zhidao.baixing.com/question/11523487.html

http://zhidao.baixing.com/question/11523492.html

http://zhidao.baixing.com/question/11523494.html

http://zhidao.baixing.com/question/11523500.html

http://zhidao.baixing.com/question/11523501.html

http://zhidao.baixing.com/question/11523502.html

http://zhidao.baixing.com/question/11523506.html

http://zhidao.baixing.com/question/11523509.html

http://zhidao.baixing.com/question/11523516.html

http://zhidao.baixing.com/question/11523521.html

http://zhidao.baixing.com/question/11523525.html

http://zhidao.baixing.com/question/11523530.html

http://zhidao.baixing.com/question/11523533.html

http://zhidao.baixing.com/question/11523534.html

http://zhidao.baixing.com/question/11523537.html

http://zhidao.baixing.com/question/11523539.html

http://zhidao.baixing.com/question/11523541.html

http://zhidao.baixing.com/question/11523543.html

http://zhidao.baixing.com/question/11523547.html

http://zhidao.baixing.com/question/11523550.html

http://zhidao.baixing.com/question/11523551.html

http://zhidao.baixing.com/question/11523554.html

http://zhidao.baixing.com/question/11523555.html

http://zhidao.baixing.com/question/11523561.html

http://zhidao.baixing.com/question/11523565.html

http://zhidao.baixing.com/question/11523572.html

http://zhidao.baixing.com/question/11523574.html

http://zhidao.baixing.com/question/11523580.html

http://zhidao.baixing.com/question/11523581.html

http://zhidao.baixing.com/question/11523583.html

http://zhidao.baixing.com/question/11523584.html

http://zhidao.baixing.com/question/11523592.html

http://zhidao.baixing.com/question/11523596.html

http://zhidao.baixing.com/question/11523599.html

http://zhidao.baixing.com/question/11523601.html

http://zhidao.baixing.com/question/11523605.html

http://zhidao.baixing.com/question/11523607.html

http://zhidao.baixing.com/question/11523613.html

http://zhidao.baixing.com/question/11523614.html

http://zhidao.baixing.com/question/11523616.html

http://zhidao.baixing.com/question/11523617.html

http://zhidao.baixing.com/question/11523620.html

http://zhidao.baixing.com/question/11523622.html

http://zhidao.baixing.com/question/11523623.html

http://zhidao.baixing.com/question/11523624.html

http://zhidao.baixing.com/question/11523625.html

http://zhidao.baixing.com/question/11523630.html

http://zhidao.baixing.com/question/11523633.html

http://zhidao.baixing.com/question/11523637.html

http://zhidao.baixing.com/question/11523638.html

http://zhidao.baixing.com/question/11523640.html

http://zhidao.baixing.com/question/11523641.html

http://zhidao.baixing.com/question/11523642.html

http://zhidao.baixing.com/question/11523643.html

http://zhidao.baixing.com/question/11523646.html

http://zhidao.baixing.com/question/11523648.html

http://zhidao.baixing.com/question/11523651.html

http://zhidao.baixing.com/question/11523653.html

http://zhidao.baixing.com/question/11523655.html

http://zhidao.baixing.com/question/11523656.html

http://zhidao.baixing.com/question/11523657.html

http://zhidao.baixing.com/question/11523660.html

http://zhidao.baixing.com/question/11523661.html

http://zhidao.baixing.com/question/11523665.html

http://zhidao.baixing.com/question/11523666.html

http://zhidao.baixing.com/question/11523669.html

http://zhidao.baixing.com/question/11523670.html

http://zhidao.baixing.com/question/11523673.html

http://zhidao.baixing.com/question/11523676.html

http://zhidao.baixing.com/question/11523678.html

http://zhidao.baixing.com/question/11523680.html

http://zhidao.baixing.com/question/11523685.html

http://zhidao.baixing.com/question/11523689.html

http://zhidao.baixing.com/question/11523693.html

http://zhidao.baixing.com/question/11523697.html

http://zhidao.baixing.com/question/11523700.html

http://zhidao.baixing.com/question/11523707.html

http://zhidao.baixing.com/question/11523711.html

http://zhidao.baixing.com/question/11523716.html

http://zhidao.baixing.com/question/11523719.html

http://zhidao.baixing.com/question/11523722.html

http://zhidao.baixing.com/question/11523724.html

http://zhidao.baixing.com/question/11523726.html

http://zhidao.baixing.com/question/11523728.html

http://zhidao.baixing.com/question/11523729.html

http://zhidao.baixing.com/question/11523736.html

http://zhidao.baixing.com/question/11523740.html

http://zhidao.baixing.com/question/11523742.html

http://zhidao.baixing.com/question/11523744.html

http://zhidao.baixing.com/question/11523746.html

http://zhidao.baixing.com/question/11523748.html

http://zhidao.baixing.com/question/11523753.html

http://zhidao.baixing.com/question/11523756.html

http://zhidao.baixing.com/question/11523757.html

http://zhidao.baixing.com/question/11523758.html

http://zhidao.baixing.com/question/11523759.html

http://zhidao.baixing.com/question/11523761.html

http://zhidao.baixing.com/question/11523763.html

http://zhidao.baixing.com/question/11523765.html

http://zhidao.baixing.com/question/11523767.html

http://zhidao.baixing.com/question/11523770.html

http://zhidao.baixing.com/question/11523772.html

http://zhidao.baixing.com/question/11523778.html

http://zhidao.baixing.com/question/11523779.html

http://zhidao.baixing.com/question/11523780.html

http://zhidao.baixing.com/question/11523783.html

http://zhidao.baixing.com/question/11523787.html

http://zhidao.baixing.com/question/11523791.html

http://zhidao.baixing.com/question/11523792.html

http://zhidao.baixing.com/question/11523794.html

http://zhidao.baixing.com/question/11523795.html

http://zhidao.baixing.com/question/11523796.html

http://zhidao.baixing.com/question/11523798.html

http://zhidao.baixing.com/question/11523802.html

http://zhidao.baixing.com/question/11523804.html

http://zhidao.baixing.com/question/11523805.html

http://zhidao.baixing.com/question/11523807.html

http://zhidao.baixing.com/question/11523812.html

http://zhidao.baixing.com/question/11523816.html

http://zhidao.baixing.com/question/11523819.html

http://zhidao.baixing.com/question/11523820.html

http://zhidao.baixing.com/question/11523822.html

http://zhidao.baixing.com/question/11523825.html

http://zhidao.baixing.com/question/11523826.html

http://zhidao.baixing.com/question/11523828.html

http://zhidao.baixing.com/question/11523830.html

http://zhidao.baixing.com/question/11523832.html

http://zhidao.baixing.com/question/11523834.html

http://zhidao.baixing.com/question/11523835.html

http://zhidao.baixing.com/question/11523839.html

http://zhidao.baixing.com/question/11523841.html

http://zhidao.baixing.com/question/11523845.html

http://zhidao.baixing.com/question/11523848.html

http://zhidao.baixing.com/question/11523849.html

http://zhidao.baixing.com/question/11523850.html

http://zhidao.baixing.com/question/11523851.html

http://zhidao.baixing.com/question/11523859.html

http://zhidao.baixing.com/question/11523861.html

http://zhidao.baixing.com/question/11523863.html

http://zhidao.baixing.com/question/11523864.html

http://zhidao.baixing.com/question/11523865.html

http://zhidao.baixing.com/question/11523867.html

http://zhidao.baixing.com/question/11523869.html

http://zhidao.baixing.com/question/11523874.html

http://zhidao.baixing.com/question/11523879.html

http://zhidao.baixing.com/question/11523884.html

http://zhidao.baixing.com/question/11523885.html

http://zhidao.baixing.com/question/11523887.html

http://zhidao.baixing.com/question/11523889.html

http://zhidao.baixing.com/question/11523891.html

http://zhidao.baixing.com/question/11523894.html

http://zhidao.baixing.com/question/11523895.html

http://zhidao.baixing.com/question/11523897.html

http://zhidao.baixing.com/question/11523899.html

http://zhidao.baixing.com/question/11523900.html

http://zhidao.baixing.com/question/11523905.html

http://zhidao.baixing.com/question/11523907.html

http://zhidao.baixing.com/question/11523911.html

http://zhidao.baixing.com/question/11523917.html

http://zhidao.baixing.com/question/11523919.html

http://zhidao.baixing.com/question/11523922.html

http://zhidao.baixing.com/question/11523923.html

http://zhidao.baixing.com/question/11523925.html

http://zhidao.baixing.com/question/11523928.html

http://zhidao.baixing.com/question/11523931.html

http://zhidao.baixing.com/question/11523932.html

http://zhidao.baixing.com/question/11523935.html

http://zhidao.baixing.com/question/11523939.html

http://zhidao.baixing.com/question/11523942.html

http://zhidao.baixing.com/question/11523945.html

http://zhidao.baixing.com/question/11523947.html

http://zhidao.baixing.com/question/11523948.html

http://zhidao.baixing.com/question/11523950.html

http://zhidao.baixing.com/question/11523958.html

http://zhidao.baixing.com/question/11523965.html

http://zhidao.baixing.com/question/11523970.html

http://zhidao.baixing.com/question/11523975.html

http://zhidao.baixing.com/question/11523977.html

http://zhidao.baixing.com/question/11523979.html

http://zhidao.baixing.com/question/11523980.html

http://zhidao.baixing.com/question/11523982.html

http://zhidao.baixing.com/question/11523988.html

http://zhidao.baixing.com/question/11523993.html

http://zhidao.baixing.com/question/11523997.html

http://zhidao.baixing.com/question/11523998.html

http://zhidao.baixing.com/question/11524005.html

http://zhidao.baixing.com/question/11524008.html

http://zhidao.baixing.com/question/11524009.html

http://zhidao.baixing.com/question/11524017.html

http://zhidao.baixing.com/question/11524023.html

http://zhidao.baixing.com/question/11524025.html

http://zhidao.baixing.com/question/11524029.html

http://zhidao.baixing.com/question/11524031.html

http://zhidao.baixing.com/question/11524032.html

http://zhidao.baixing.com/question/11524033.html

http://zhidao.baixing.com/question/11524035.html

http://zhidao.baixing.com/question/11524040.html

http://zhidao.baixing.com/question/11524045.html

http://zhidao.baixing.com/question/11524048.html

http://zhidao.baixing.com/question/11524053.html

http://zhidao.baixing.com/question/11524055.html

http://zhidao.baixing.com/question/11524059.html

http://zhidao.baixing.com/question/11524063.html

http://zhidao.baixing.com/question/11524065.html

http://zhidao.baixing.com/question/11524067.html

http://zhidao.baixing.com/question/11524069.html

http://zhidao.baixing.com/question/11524071.html

http://zhidao.baixing.com/question/11524077.html

http://zhidao.baixing.com/question/11524082.html

http://zhidao.baixing.com/question/11524084.html

http://zhidao.baixing.com/question/11524087.html

http://zhidao.baixing.com/question/11524088.html

http://zhidao.baixing.com/question/11524089.html

http://zhidao.baixing.com/question/11524092.html

http://zhidao.baixing.com/question/11524094.html

http://zhidao.baixing.com/question/11524097.html

http://zhidao.baixing.com/question/11524098.html

http://zhidao.baixing.com/question/11524099.html

http://zhidao.baixing.com/question/11524100.html

http://zhidao.baixing.com/question/11524104.html

http://zhidao.baixing.com/question/11524106.html

http://zhidao.baixing.com/question/11524113.html

http://zhidao.baixing.com/question/11524114.html

http://zhidao.baixing.com/question/11524115.html

http://zhidao.baixing.com/question/11524118.html

http://zhidao.baixing.com/question/11524121.html

http://zhidao.baixing.com/question/11524131.html

http://zhidao.baixing.com/question/11524133.html

http://zhidao.baixing.com/question/11524136.html

http://zhidao.baixing.com/question/11524137.html

http://zhidao.baixing.com/question/11524139.html

http://zhidao.baixing.com/question/11524141.html

http://zhidao.baixing.com/question/11524142.html

http://zhidao.baixing.com/question/11524144.html

http://zhidao.baixing.com/question/11524149.html

http://zhidao.baixing.com/question/11524151.html

http://zhidao.baixing.com/question/11524156.html

http://zhidao.baixing.com/question/11524159.html

http://zhidao.baixing.com/question/11524160.html

http://zhidao.baixing.com/question/11524162.html

http://zhidao.baixing.com/question/11524163.html

http://zhidao.baixing.com/question/11524165.html

http://zhidao.baixing.com/question/11524169.html

http://zhidao.baixing.com/question/11524172.html

http://zhidao.baixing.com/question/11524177.html

http://zhidao.baixing.com/question/11524179.html

http://zhidao.baixing.com/question/11524183.html

http://zhidao.baixing.com/question/11524186.html

http://zhidao.baixing.com/question/11524188.html

http://zhidao.baixing.com/question/11524189.html

http://zhidao.baixing.com/question/11524193.html

http://zhidao.baixing.com/question/11524195.html

http://zhidao.baixing.com/question/11524196.html

http://zhidao.baixing.com/question/11524197.html

http://zhidao.baixing.com/question/11524199.html

http://zhidao.baixing.com/question/11524200.html

http://zhidao.baixing.com/question/11524204.html

http://zhidao.baixing.com/question/11524206.html

http://zhidao.baixing.com/question/11524208.html

http://zhidao.baixing.com/question/11524210.html

http://zhidao.baixing.com/question/11524211.html

http://zhidao.baixing.com/question/11524213.html

http://zhidao.baixing.com/question/11524216.html

http://zhidao.baixing.com/question/11524217.html

http://zhidao.baixing.com/question/11524218.html

http://zhidao.baixing.com/question/11524220.html

http://zhidao.baixing.com/question/11524221.html

http://zhidao.baixing.com/question/11524222.html

http://zhidao.baixing.com/question/11524224.html

http://zhidao.baixing.com/question/11524227.html

http://zhidao.baixing.com/question/11524228.html

http://zhidao.baixing.com/question/11524229.html

http://zhidao.baixing.com/question/11524230.html

http://zhidao.baixing.com/question/11524231.html

http://zhidao.baixing.com/question/11524233.html

http://zhidao.baixing.com/question/11524235.html

http://zhidao.baixing.com/question/11524238.html

http://zhidao.baixing.com/question/11524239.html

http://zhidao.baixing.com/question/11524242.html

http://zhidao.baixing.com/question/11524243.html

http://zhidao.baixing.com/question/11524245.html

http://zhidao.baixing.com/question/11524246.html

http://zhidao.baixing.com/question/11524247.html

http://zhidao.baixing.com/question/11524248.html

http://zhidao.baixing.com/question/11524251.html

http://zhidao.baixing.com/question/11524255.html

http://zhidao.baixing.com/question/11524259.html

http://zhidao.baixing.com/question/11524260.html

http://zhidao.baixing.com/question/11524262.html

http://zhidao.baixing.com/question/11524264.html

http://zhidao.baixing.com/question/11524266.html

http://zhidao.baixing.com/question/11524267.html

http://zhidao.baixing.com/question/11524268.html

http://zhidao.baixing.com/question/11524269.html

http://zhidao.baixing.com/question/11524271.html

http://zhidao.baixing.com/question/11524272.html

http://zhidao.baixing.com/question/11524273.html

http://zhidao.baixing.com/question/11524274.html

http://zhidao.baixing.com/question/11524277.html

http://zhidao.baixing.com/question/11524278.html

http://zhidao.baixing.com/question/11524279.html

http://zhidao.baixing.com/question/11524280.html

http://zhidao.baixing.com/question/11524281.html

http://zhidao.baixing.com/question/11524282.html

http://zhidao.baixing.com/question/11524283.html

http://zhidao.baixing.com/question/11524285.html

http://zhidao.baixing.com/question/11524288.html

http://zhidao.baixing.com/question/11524289.html

http://zhidao.baixing.com/question/11524290.html

http://zhidao.baixing.com/question/11524291.html

http://zhidao.baixing.com/question/11524294.html

http://zhidao.baixing.com/question/11524295.html

http://zhidao.baixing.com/question/11524297.html

http://zhidao.baixing.com/question/11524298.html

http://zhidao.baixing.com/question/11524299.html

http://zhidao.baixing.com/question/11524301.html

http://zhidao.baixing.com/question/11524302.html

http://zhidao.baixing.com/question/11524304.html

http://zhidao.baixing.com/question/11524305.html

http://zhidao.baixing.com/question/11524308.html

http://zhidao.baixing.com/question/11524309.html

http://zhidao.baixing.com/question/11524312.html

http://zhidao.baixing.com/question/11524313.html

http://zhidao.baixing.com/question/11524314.html

http://zhidao.baixing.com/question/11524315.html

http://zhidao.baixing.com/question/11524316.html

http://zhidao.baixing.com/question/11524317.html

http://zhidao.baixing.com/question/11524319.html

http://zhidao.baixing.com/question/11524320.html

http://zhidao.baixing.com/question/11524321.html

http://zhidao.baixing.com/question/11524322.html

http://zhidao.baixing.com/question/11524323.html

http://zhidao.baixing.com/question/11524324.html

http://zhidao.baixing.com/question/11524325.html

http://zhidao.baixing.com/question/11524328.html

http://zhidao.baixing.com/question/11524329.html

http://zhidao.baixing.com/question/11524330.html

http://zhidao.baixing.com/question/11524332.html

http://zhidao.baixing.com/question/11524334.html

http://zhidao.baixing.com/question/11524336.html

http://zhidao.baixing.com/question/11524338.html

http://zhidao.baixing.com/question/11524339.html

http://zhidao.baixing.com/question/11524341.html

http://zhidao.baixing.com/question/11524342.html

http://zhidao.baixing.com/question/11524343.html

http://zhidao.baixing.com/question/11524345.html

http://zhidao.baixing.com/question/11524347.html

http://zhidao.baixing.com/question/11524349.html

http://zhidao.baixing.com/question/11524350.html

http://zhidao.baixing.com/question/11524351.html

http://zhidao.baixing.com/question/11524352.html

http://zhidao.baixing.com/question/11524353.html

http://zhidao.baixing.com/question/11524354.html

http://zhidao.baixing.com/question/11524356.html

http://zhidao.baixing.com/question/11524357.html

http://zhidao.baixing.com/question/11524358.html

http://zhidao.baixing.com/question/11524359.html

http://zhidao.baixing.com/question/11524361.html

http://zhidao.baixing.com/question/11524362.html

http://zhidao.baixing.com/question/11524364.html

http://zhidao.baixing.com/question/11524366.html

http://zhidao.baixing.com/question/11524370.html

http://zhidao.baixing.com/question/11524373.html

http://zhidao.baixing.com/question/11524374.html

http://zhidao.baixing.com/question/11524375.html

http://zhidao.baixing.com/question/11524376.html

http://zhidao.baixing.com/question/11524377.html

http://zhidao.baixing.com/question/11524378.html

http://zhidao.baixing.com/question/11524380.html

http://zhidao.baixing.com/question/11524381.html

http://zhidao.baixing.com/question/11524382.html

http://zhidao.baixing.com/question/11524385.html

http://zhidao.baixing.com/question/11524387.html

http://zhidao.baixing.com/question/11524388.html

http://zhidao.baixing.com/question/11524389.html

http://zhidao.baixing.com/question/11524390.html

http://zhidao.baixing.com/question/11524391.html

http://zhidao.baixing.com/question/11524392.html

http://zhidao.baixing.com/question/11524393.html

http://zhidao.baixing.com/question/11524394.html

http://zhidao.baixing.com/question/11524395.html

http://zhidao.baixing.com/question/11524397.html

http://zhidao.baixing.com/question/11524398.html

http://zhidao.baixing.com/question/11524400.html

http://zhidao.baixing.com/question/11524401.html

http://zhidao.baixing.com/question/11524403.html

http://zhidao.baixing.com/question/11524404.html

http://zhidao.baixing.com/question/11524406.html

http://zhidao.baixing.com/question/11524407.html

http://zhidao.baixing.com/question/11524408.html

http://zhidao.baixing.com/question/11524409.html

http://zhidao.baixing.com/question/11524410.html

http://zhidao.baixing.com/question/11524411.html



战魂筑 2021-12-27 19:04 发表评论
]]>
Go语言与构造函?/title><link>http://www.shnenglu.com/sunicdavy/archive/2016/12/01/214457.html</link><dc:creator>战魂筑</dc:creator><author>战魂筑</author><pubDate>Thu, 01 Dec 2016 02:45:00 GMT</pubDate><guid>http://www.shnenglu.com/sunicdavy/archive/2016/12/01/214457.html</guid><wfw:comment>http://www.shnenglu.com/sunicdavy/comments/214457.html</wfw:comment><comments>http://www.shnenglu.com/sunicdavy/archive/2016/12/01/214457.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/sunicdavy/comments/commentRss/214457.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/sunicdavy/services/trackbacks/214457.html</trackback:ping><description><![CDATA[<p style="margin-right: 0px; margin-bottom: 10px; margin-left: 0px; font-size: 15px; font-family: Helvetica, "Hiragino Sans GB", 微Y雅黑, "Microsoft YaHei UI", SimSun, SimHei, arial, sans-serif; line-height: 24px; widows: 1; margin-top: 0px !important;">Golang中没有设计构造函? 取而代之的, 设计Golang的大师希望你用普通函数去实现构造的d. <br />一直只是觉得这只是体现Golangq门新语a的精设计之道, 直到自己实现~译器后才发现构造函数的设计本n是值得商榷?/p><p style="margin: 10px 0px; font-size: 15px; font-family: Helvetica, "Hiragino Sans GB", 微Y雅黑, "Microsoft YaHei UI", SimSun, SimHei, arial, sans-serif; line-height: 24px; widows: 1;">我们先看下构造函数的规则</p><h1>构造函数调用规?/h1><p style="margin: 10px 0px; font-size: 15px; font-family: Helvetica, "Hiragino Sans GB", 微Y雅黑, "Microsoft YaHei UI", SimSun, SimHei, arial, sans-serif; line-height: 24px; widows: 1;">构造参数量: 0表示没有构造函? 1表示有构造函?个参?/p><table style="margin: 10px 0px; border-collapse: collapse; border-style: solid; border-color: #bbbbbb; padding: 0px; color: #000000; font-family: Helvetica, "Hiragino Sans GB", 微Y雅黑, "Microsoft YaHei UI", SimSun, SimHei, arial, sans-serif; font-size: 15px; line-height: 24px; widows: 1;"><thead><tr style="border-top-width: 1px; border-top-style: solid; border-top-color: #cccccc; margin: 0px; padding: 0px; background-color: white;"><th style="padding: 6px 13px; border-collapse: collapse; border: 1px solid #cccccc; height: 28px; word-break: break-all; box-sizing: border-box; outline: none; margin: 0px; font-size: 14px;">本类构?/th><th style="padding: 6px 13px; border-collapse: collapse; border: 1px solid #cccccc; height: 28px; word-break: break-all; box-sizing: border-box; outline: none; margin: 0px; font-size: 14px;">父类构?/th><th style="padding: 6px 13px; border-collapse: collapse; border: 1px solid #cccccc; height: 28px; word-break: break-all; box-sizing: border-box; outline: none; margin: 0px; font-size: 14px;">处理Ҏ</th></tr></thead><tbody><tr style="border-top-width: 1px; border-top-style: solid; border-top-color: #cccccc; margin: 0px; padding: 0px; background-color: white;"><td style="padding: 6px 13px; border-collapse: collapse; border-style: solid; border-color: #cccccc; height: 28px; word-break: break-all; box-sizing: border-box; outline: none; margin: 0px; font-size: 14px;">0</td><td style="padding: 6px 13px; border-collapse: collapse; border-style: solid; border-color: #cccccc; height: 28px; word-break: break-all; box-sizing: border-box; outline: none; margin: 0px; font-size: 14px;">0</td><td style="padding: 6px 13px; border-collapse: collapse; border-style: solid; border-color: #cccccc; height: 28px; word-break: break-all; box-sizing: border-box; outline: none; margin: 0px; font-size: 14px;">不处?/td></tr><tr style="border-top-width: 1px; border-top-style: solid; border-top-color: #cccccc; margin: 0px; padding: 0px; background-color: #f8f8f8;"><td style="padding: 6px 13px; border-collapse: collapse; border-style: solid; border-color: #cccccc; height: 28px; word-break: break-all; box-sizing: border-box; outline: none; margin: 0px; font-size: 14px;">1</td><td style="padding: 6px 13px; border-collapse: collapse; border-style: solid; border-color: #cccccc; height: 28px; word-break: break-all; box-sizing: border-box; outline: none; margin: 0px; font-size: 14px;">0</td><td style="padding: 6px 13px; border-collapse: collapse; border-style: solid; border-color: #cccccc; height: 28px; word-break: break-all; box-sizing: border-box; outline: none; margin: 0px; font-size: 14px;">调本cctor</td></tr><tr style="border-top-width: 1px; border-top-style: solid; border-top-color: #cccccc; margin: 0px; padding: 0px; background-color: white;"><td style="padding: 6px 13px; border-collapse: collapse; border-style: solid; border-color: #cccccc; height: 28px; word-break: break-all; box-sizing: border-box; outline: none; margin: 0px; font-size: 14px;">0</td><td style="padding: 6px 13px; border-collapse: collapse; border-style: solid; border-color: #cccccc; height: 28px; word-break: break-all; box-sizing: border-box; outline: none; margin: 0px; font-size: 14px;">1</td><td style="padding: 6px 13px; border-collapse: collapse; border-style: solid; border-color: #cccccc; height: 28px; word-break: break-all; box-sizing: border-box; outline: none; margin: 0px; font-size: 14px;">调父cctor</td></tr><tr style="border-top-width: 1px; border-top-style: solid; border-top-color: #cccccc; margin: 0px; padding: 0px; background-color: #f8f8f8;"><td style="padding: 6px 13px; border-collapse: collapse; border-style: solid; border-color: #cccccc; height: 28px; word-break: break-all; box-sizing: border-box; outline: none; margin: 0px; font-size: 14px;">1</td><td style="padding: 6px 13px; border-collapse: collapse; border-style: solid; border-color: #cccccc; height: 28px; word-break: break-all; box-sizing: border-box; outline: none; margin: 0px; font-size: 14px;">1</td><td style="padding: 6px 13px; border-collapse: collapse; border-style: solid; border-color: #cccccc; height: 28px; word-break: break-all; box-sizing: border-box; outline: none; margin: 0px; font-size: 14px;">调本cctor, 本类ctor调父cctor</td></tr><tr style="border-top-width: 1px; border-top-style: solid; border-top-color: #cccccc; margin: 0px; padding: 0px; background-color: white;"><td style="padding: 6px 13px; border-collapse: collapse; border-style: solid; border-color: #cccccc; height: 28px; word-break: break-all; box-sizing: border-box; outline: none; margin: 0px; font-size: 14px;">2</td><td style="padding: 6px 13px; border-collapse: collapse; border-style: solid; border-color: #cccccc; height: 28px; word-break: break-all; box-sizing: border-box; outline: none; margin: 0px; font-size: 14px;">1</td><td style="padding: 6px 13px; border-collapse: collapse; border-style: solid; border-color: #cccccc; height: 28px; word-break: break-all; box-sizing: border-box; outline: none; margin: 0px; font-size: 14px;">调本cctor, 本类ctor调父cctor</td></tr><tr style="border-top-width: 1px; border-top-style: solid; border-top-color: #cccccc; margin: 0px; padding: 0px; background-color: #f8f8f8;"><td style="padding: 6px 13px; border-collapse: collapse; border-style: solid; border-color: #cccccc; height: 28px; word-break: break-all; box-sizing: border-box; outline: none; margin: 0px; font-size: 14px;">1</td><td style="padding: 6px 13px; border-collapse: collapse; border-style: solid; border-color: #cccccc; height: 28px; word-break: break-all; box-sizing: border-box; outline: none; margin: 0px; font-size: 14px;">2</td><td style="padding: 6px 13px; border-collapse: collapse; border-style: solid; border-color: #cccccc; height: 28px; word-break: break-all; box-sizing: border-box; outline: none; margin: 0px; font-size: 14px;">报错, 手动调父cctor</td></tr><tr style="border-top-width: 1px; border-top-style: solid; border-top-color: #cccccc; margin: 0px; padding: 0px; background-color: white;"><td style="padding: 6px 13px; border-collapse: collapse; border-style: solid; border-color: #cccccc; height: 28px; word-break: break-all; box-sizing: border-box; outline: none; margin: 0px; font-size: 14px;">2</td><td style="padding: 6px 13px; border-collapse: collapse; border-style: solid; border-color: #cccccc; height: 28px; word-break: break-all; box-sizing: border-box; outline: none; margin: 0px; font-size: 14px;">2</td><td style="padding: 6px 13px; border-collapse: collapse; border-style: solid; border-color: #cccccc; height: 28px; word-break: break-all; box-sizing: border-box; outline: none; margin: 0px; font-size: 14px;">报错, 手动调父cctor</td></tr></tbody></table><h1>普通函数重载规?/h1><p style="margin: 10px 0px; font-size: 15px; font-family: Helvetica, "Hiragino Sans GB", 微Y雅黑, "Microsoft YaHei UI", SimSun, SimHei, arial, sans-serif; line-height: 24px; widows: 1;">实际只用考虑最典型的一U行? 实例化子c? 转ؓ父类调用Ҏ, q个时?/p><p style="margin: 10px 0px; font-size: 15px; font-family: Helvetica, "Hiragino Sans GB", 微Y雅黑, "Microsoft YaHei UI", SimSun, SimHei, arial, sans-serif; line-height: 24px; widows: 1;">如果Ҏ是override, 调用的是子类</p><p style="margin: 10px 0px; font-size: 15px; font-family: Helvetica, "Hiragino Sans GB", 微Y雅黑, "Microsoft YaHei UI", SimSun, SimHei, arial, sans-serif; line-height: 24px; widows: 1;">如果Ҏ是virutal或者不指明, 调用的是父类</p><p style="margin: 10px 0px; font-size: 15px; font-family: Helvetica, "Hiragino Sans GB", 微Y雅黑, "Microsoft YaHei UI", SimSun, SimHei, arial, sans-serif; line-height: 24px; widows: 1;">整个重蝲q程, 子类l对不会隐式调用父类的行?/p><h1>需要构造函C?</h1><p style="margin: 10px 0px; font-size: 15px; font-family: Helvetica, "Hiragino Sans GB", 微Y雅黑, "Microsoft YaHei UI", SimSun, SimHei, arial, sans-serif; line-height: 24px; widows: 1;">构造函数的优点</p><ul style="margin: 10px 0px; padding-left: 32px; font-family: Helvetica, "Hiragino Sans GB", 微Y雅黑, "Microsoft YaHei UI", SimSun, SimHei, arial, sans-serif; font-size: 15px; line-height: 24px; widows: 1;"><li style="margin: 0px 0px 5px;">本n属于一U特D的成员函数</li><li style="margin: 5px 0px;">~译器帮你自动传D用父U?/li></ul><p style="margin: 10px 0px; font-size: 15px; font-family: Helvetica, "Hiragino Sans GB", 微Y雅黑, "Microsoft YaHei UI", SimSun, SimHei, arial, sans-serif; line-height: 24px; widows: 1;">构造函数的~点</p><ul style="margin: 10px 0px; padding-left: 32px; font-family: Helvetica, "Hiragino Sans GB", 微Y雅黑, "Microsoft YaHei UI", SimSun, SimHei, arial, sans-serif; font-size: 15px; line-height: 24px; widows: 1;"><li style="margin: 0px 0px 5px;">隐式的调用规?/li><li style="margin: 5px 0px;">虽然属于成员函数, 但是与其他成员函数调用规则完全不? 需要特D记?/li><li style="margin: 5px 0px;">带参数的构造函? 在父cd数多于子cL, 需要引用复杂语法来实现父构造调?/li></ul><p style="margin: 10px 0px; font-size: 15px; font-family: Helvetica, "Hiragino Sans GB", 微Y雅黑, "Microsoft YaHei UI", SimSun, SimHei, arial, sans-serif; line-height: 24px; widows: 1;">其实我们对初始化函数的需求只?? 自定?/p><p style="margin-top: 10px; margin-right: 0px; margin-left: 0px; font-size: 15px; font-family: Helvetica, "Hiragino Sans GB", 微Y雅黑, "Microsoft YaHei UI", SimSun, SimHei, arial, sans-serif; line-height: 24px; widows: 1; margin-bottom: 0px !important;">所? 可以理解Golang不加入构造函数的设计是正的 <br />? ? 清晰, 有规?/p><img src ="http://www.shnenglu.com/sunicdavy/aggbug/214457.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/sunicdavy/" target="_blank">战魂筑</a> 2016-12-01 10:45 <a href="http://www.shnenglu.com/sunicdavy/archive/2016/12/01/214457.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>ulual合protoc-gen-lua的几个坑http://www.shnenglu.com/sunicdavy/archive/2016/05/31/213612.html战魂筑战魂筑Tue, 31 May 2016 03:26:00 GMThttp://www.shnenglu.com/sunicdavy/archive/2016/05/31/213612.htmlhttp://www.shnenglu.com/sunicdavy/comments/213612.htmlhttp://www.shnenglu.com/sunicdavy/archive/2016/05/31/213612.html#Feedback0http://www.shnenglu.com/sunicdavy/comments/commentRss/213612.htmlhttp://www.shnenglu.com/sunicdavy/services/trackbacks/213612.html最q整合ulua到项目里q行热更? protoc-gen-luaq古老的东西重新让我l箋发博? 因ؓ?/p>

生成好的协议报错找不到protobuf

在每个protoc-gen-lua生成的lua文g? 都有一?/p>

local protobuf = require "protobuf"

本n按照官方出的没问? 但是在ulua的目录里, L报protobuf找不到的错误. 前后Ҏ了下我生成的lua和ulua官方生成的代码里

发现居然他修改了地址改ؓ?/p>

local protobuf = require "protobuf/protobuf"

好吧, 只有修改生成器代码protoc-gen-lua\plugin\protoc-gen-lua中第412行改?/p>

lua('local protobuf = require "protobuf/protobuf"\n')
 

生成消息无法扑ֈDescriptor反射查信?/h2>
在LuaFramework\ToLua\Lua\protobuf\protobuf.lua?39行添?/pre>
message_meta._member.Descriptor = descriptor
在消息里可以通过msg.Descriptor获得此消息的反射信息

׃proto文g定义的内容过多导致的lua local过限制的警?/h2>

image

q个错误真是让我哭笑不得, protoc-gen-lua的可用性再一ơ被怀?/p>

我们的协议好歹分成了接近100? 每个里面消息和数据是混合? 更别说有些童鞋喜Ƣ把一个项目的协议全写在一个文仉, 那生成的local数量直是酸爽

 

 

 

后记

搜烦protoc-gen-lua? 无意间又搜到3q前自己的博?a title="http://www.shnenglu.com/sunicdavy/archive/2013/04/24/199693.html" href="http://www.shnenglu.com/sunicdavy/archive/2013/04/24/199693.html">http://www.shnenglu.com/sunicdavy/archive/2013/04/24/199693.html

记得那个时候准备在服务器用lua, q好没这么干, 转了go, 否则后果不堪设想

lua上用pb其实q不Ҏ, 云风的pbc写的不错, 但怕有? sproto直接不兼容现有项? 风险大于易用性所以果断弃?/p>

因此, 看来有必要自己写一个支持良好的lua pb?/p>

战魂筑 2016-05-31 11:26 发表评论
]]>Golang, Lua, C#闭包变量捕获差异http://www.shnenglu.com/sunicdavy/archive/2015/09/23/211895.html战魂筑战魂筑Wed, 23 Sep 2015 10:31:00 GMThttp://www.shnenglu.com/sunicdavy/archive/2015/09/23/211895.htmlhttp://www.shnenglu.com/sunicdavy/comments/211895.htmlhttp://www.shnenglu.com/sunicdavy/archive/2015/09/23/211895.html#Feedback2http://www.shnenglu.com/sunicdavy/comments/commentRss/211895.htmlhttp://www.shnenglu.com/sunicdavy/services/trackbacks/211895.html看C#例子

            Action[] a = new Action[3];
 
            for (int i = 0; i < 3; i++)
            {
                a[i] = ( ) => { Console.WriteLine(i); };
            }
 
            for (int i = 0; i < 3; i++){
                a[i]();
            }

C#打印l果? 3 3

 

Golang的例?/p>

    a := make([]func(), 3 )
    
    for i := 0; i < 3; i++ {
        
        a[i]= func( ){
            
            fmt.Println(i)
            
        }    
    
    }
    
    for _, s := range a {
        s()
    }

Golang打印l果? 3 3

 

最后是Lua的例?/p>

a = {}
 
for i = 1, 3 do
 
    table.insert( a, function()
        print(i)
    end
    )
 
end
 
 
for _, v in ipairs(a) do
    v()
end

Lua打印l果? 2 3

 

差异在于, C#和Golang变量捕获到闭包内时, 均用引用方? 卛_最后开始调用用变量时, ׃变量已经l束循环, 所以是最l?/p>

但是Lua捕获方式是值捕? 因此比较Ҏ理解, 是多就是多?/p>

战魂筑 2015-09-23 18:31 发表评论
]]>
深入挖掘protobuf: 通过protoc获取proto文g信息http://www.shnenglu.com/sunicdavy/archive/2015/03/01/209894.html战魂筑战魂筑Sun, 01 Mar 2015 05:49:00 GMThttp://www.shnenglu.com/sunicdavy/archive/2015/03/01/209894.htmlhttp://www.shnenglu.com/sunicdavy/comments/209894.htmlhttp://www.shnenglu.com/sunicdavy/archive/2015/03/01/209894.html#Feedback0http://www.shnenglu.com/sunicdavy/comments/commentRss/209894.htmlhttp://www.shnenglu.com/sunicdavy/services/trackbacks/209894.html准备:

?a title="http://code.google.com/p/protobuf/" >http://code.google.com/p/protobuf/下蝲protobuf-2.5版本

预备知识: 已经使用qprotobuf, 熟练应用protobuf序列化在各语a间交互信?/p>

目标: 获取proto内容而无需手动解析proto文g

为proto文gd更多的meta信息, q在q行期获?

 

protoc~译器准?/strong>

通过protobuf-2.5的源码或者从官网下蝲, 可以获得protoc的protobuf~译? q个~译器由C++~写, 官方支持完整的protobufҎ? ~译器默认支持C++, python和java 三种语言的代码生? 如需生成更多的语a, 可以通过官网的第三方面获取.

 

protoc插g原理

但我们在日常使用? 可能需要提取proto信息, 例如: 所有的枚D,消息{信? 字段名称和导出号. 自己~写词法解析器来做是费力不讨好的. 官方推荐的方法是使用protoc外挂插g来实?

protoc的插件设计比较独? 不用动态链接库或者java的jar包导入方? 而是直接使用了命令行来交换数?查看protobuf源码我们可以发现q样一个文?

protobuf-2.5.0\src\google\protobuf\descriptor.proto

q个文g描述了一个proto文g的格? 消息l成及枚丄完整信息. q是一U自我描q的Ҏ.

在找到这样一个文?/p>

protobuf-2.5.0\src\google\protobuf\compiler\plugin.proto

q样一个文件描q? 插g如何与protocq行交互的协?/p>

protoc~译器在l定指定proto文g及搜索\径后, 各U信息填充ؓdescriptor.proto描述的结构后通过CodeGeneratorRequest消息pd化ؓ二进制流后输出到命o? 插g只用捕获protoc命o行输出的二进制流, 序列化化回CodeGeneratorRequest卛_获得解析后的proto文g内容

q里需要注意的? 插g可执行文件很有讲I? 必须为protoc-gen-$NAME,  而且输出文g名参数必Mؓ--${NAME}_out

看一个栗?

protoc.exe foo.proto --plugin=protoc-gen-go=..\tools\protoc-gen-go.exe --go_out foo.go --proto_path "."

q个栗子? $NAME=go

protocfoo.proto文g(搜烦路径为当前\?的内定w过命o行输出给位于..\tools\的插件protoc-gen-go.exe,  输出文g名字?foo.go

descriptor.proto信息挖掘

我们注意到在descriptor.proto文g中包含有q样的一个message: SourceCodeInfo, q个消息体里有如下字D?/p>

optional string leading_comments = 3;
    optional string trailing_comments = 4;

q两个字D对于我们获取proto文g的meta信息ؓ重要, 所谓的meta信息, 理解理解为C#语言中的attribute

q个attribute功能可以Z个字D? 一个消息扩充一些描q? 比如: 当一个字D通过反射昄在gui上时, gui需要获取这个字D늚中文描述

那么只需要如下编?

optional int32 somevalue = 1 //@ desc=”中文描q?

位于字段N的描q? 会被填充到SourceCodeInfo?trailing_comments? 而位于字D上方的字段, 会被填充到leading_comments?

 

SourceCodeInfo q没有直接挂载在message或者字D늚附近, 而是通过其下的path字段来描qC字段的关p? q是个极为麻烦的设计.

其原理如?

假设我有如下一个message

message foo

{

     optional int32 v = 1;  // comments

}

要获取v后的注释, 对应的path?4, 0, 2, 0

4 表示descriptor中message_type所在的序号,׃message_type对应的类型DescriptorProto是一个数l? 所?表示foo是在FileDescriptorProto的message_type数组cd的烦引ؓ0;

如此cL: 2, 0 表示 v在DescriptorProtol构体的field成员序号?的数l元素的索引?

 

如果需要更多的参? 可以获取https://github.com/golang/protobuf

github.com\golang\protobuf\protoc-gen-go工程内有详细代码解析

战魂筑 2015-03-01 13:49 发表评论
]]>
lua调试的工具选择http://www.shnenglu.com/sunicdavy/archive/2014/09/28/208441.html战魂筑战魂筑Sun, 28 Sep 2014 07:19:00 GMThttp://www.shnenglu.com/sunicdavy/archive/2014/09/28/208441.htmlhttp://www.shnenglu.com/sunicdavy/comments/208441.htmlhttp://www.shnenglu.com/sunicdavy/archive/2014/09/28/208441.html#Feedback7http://www.shnenglu.com/sunicdavy/comments/commentRss/208441.htmlhttp://www.shnenglu.com/sunicdavy/services/trackbacks/208441.html最q看C个关于vs的lua调试插g, 装了vs2012试了? 忍不住发此文ȝ下lua各种调试工具

Decoda

    q是C地球上调试lua5.1最方便的工? 没有之一. 强大的注入式调试, 性能极高.支持 挂接q程, 变量展开, 断点{各U日常所需.

早期的Decoda是收费工? 因此质量非常?

    Decoda现在已经停止开发ƈ开源了, 调试lua5.2会crash. 源代码可以作ZU技术参? 很多dll注入修改技? 灰常牛X

image

LuaStudio

   比较优秀的调试工?因ؓ收费), 可以调试lua5.1/5.2, 界面属于vs2008cd, 土豪可以考虑买几套试?/p>

 

ZeroBrane Studio

对lua5.1支持较好, 5.2也能调但偶尔q是会crash, Zq程调试方式, 所以性能略低.

RemDebug

没有IDE, U命令行方式调试? 但因为简? 所以可以参考后写一个自qE序内徏调试?/p>

Babe Lua

把这货放在最后是有原因的, q记得那句老话: 老外一开? 我们有自主研发? 对的, q货一定是参考了Decoda的代码后搞出个vs的插件来, 虽然不收? 但是不提下参考对象的行ؓq是值得Ҏ? q货在中文博客上? 不支持挂接到q程(Decoda支持), 不支?4位调?LuaStudio支持), 调试30~50ơ偶挂1?? ? 毕竟只是代码搬运? 不生产代?

q货装上, 能用, ?.2是不行的, 5.1比Decoda方便? 毕竟vs支持悬Q昄变量.

 

说了那么? 其实对于lua5.2版本的调? q是没有免费的比较合适的Ҏ, 如果实在惌? q是可以参考下RemDebug的原理及lua官方调试文档, 自己通过c api调用写一套适合自己的远E调试工? 其实没有多复? 但L不调试的?img class="wlEmoticon wlEmoticon-smile" style="border-top-style: none; border-bottom-style: none; border-right-style: none; border-left-style: none" alt="微笑" src="http://www.shnenglu.com/images/cppblog_com/sunicdavy/Windows-Live-Writer/lua_D2A5/wlEmoticon-smile_2.png">



战魂筑 2014-09-28 15:19 发表评论
]]>
lua module/package 机制的自定义dhttp://www.shnenglu.com/sunicdavy/archive/2014/04/16/206610.html战魂筑战魂筑Wed, 16 Apr 2014 12:29:00 GMThttp://www.shnenglu.com/sunicdavy/archive/2014/04/16/206610.htmlhttp://www.shnenglu.com/sunicdavy/comments/206610.htmlhttp://www.shnenglu.com/sunicdavy/archive/2014/04/16/206610.html#Feedback0http://www.shnenglu.com/sunicdavy/comments/commentRss/206610.htmlhttp://www.shnenglu.com/sunicdavy/services/trackbacks/206610.htmllua5.2? 官方大家攑ּmodule/package机制, q套机制对于使用者来说是方便? 对于module的编写者简直要抓狂, 所有module后的函数对_G均不可见, q要一个个手动在module前{成local调用. 相当反hc? 官方大家手动实现package机制. 本博客之前有实现q? 参?a title="http://www.shnenglu.com/sunicdavy/archive/2013/12/10/204696.html" href="http://www.shnenglu.com/sunicdavy/archive/2013/12/10/204696.html">http://www.shnenglu.com/sunicdavy/archive/2013/12/10/204696.html

׃要用protoc-gen-lua, q东西生成出来的lua依然使用官方的module/package机制. 对于游戏目来说, 惌行一些自定义d, 加密{? 变得不可能. q好官方在扩展上支持的还是不错的.

参考lua5.2的官Ҏ?a title="http://www.lua.org/manual/5.2/manual.html#pdf-require" >http://www.lua.org/manual/5.2/manual.html#pdf-require

require? lua会自动根据一定的搜烦规律扑ֈ加蝲代码的方? q个Ҏ定义?a name="pdf-package.searchers">package.searchersq个数组? 一共有4个加载搜索顺?/p>

1. preload, 对已加蝲的moduleq行直接q回, 对应package.preload[modname]

2. lualoader, 对lua文gq行加蝲, 搜烦路径?a >package.path

3. cloader, 对lua标准dllq行加蝲, 搜烦路径?a >package.cpath

4. croot, 官方文档说的是all-in-one加蝲? 感觉很神? 感兴可以自行参考源?/p>

那么, 如果只需要自q加蝲? 只需要这样做:

  package.searchers[2] = function( name )
        print("try to load", name )
    end
    package.searchers[3] = nil
    package.searchers[4] = nil
    
    require "libtest"
    只保留preload功能, 然后第二个加蝲器换成自q加蝲函数, W三,W四直接屏蔽



战魂筑 2014-04-16 20:29 发表评论
]]>
探访lua5.2新特性及package机制模拟http://www.shnenglu.com/sunicdavy/archive/2013/12/10/204696.html战魂筑战魂筑Tue, 10 Dec 2013 08:29:00 GMThttp://www.shnenglu.com/sunicdavy/archive/2013/12/10/204696.htmlhttp://www.shnenglu.com/sunicdavy/comments/204696.htmlhttp://www.shnenglu.com/sunicdavy/archive/2013/12/10/204696.html#Feedback0http://www.shnenglu.com/sunicdavy/comments/commentRss/204696.htmlhttp://www.shnenglu.com/sunicdavy/services/trackbacks/204696.html目客户端脚本全面升Ulua5.2 q是?6q后最大的一ơ主q更? 带来的机? 函数变化也是非常不错?/p>

1. L了全局性质的setfenv/getfenvpd函数, 语言层面提供_ENV语法p? q东西跟:操作W一? 只存在于~译?

官方自己实现module/require/package机制, 毕竟原生q套机制实现太弱Z..

2. 提供了无W号讉K函数

3. 更多的lua api变化. 如果惛_容lua5.1的写? 可以参?a >luabridge内LuaHelpers.h的实?/p>

以下是本Z用lua5.2实现的一套package机制, 供大家参?/p>

package = {}
 
-- d标记
package.loaded = {}
 
-- 搜烦路径数组
package.path = {}
 
package.access =
{
    ["string"] = string,
    ["print"] = print,
    ["table"] = table,
    ["assert"] = assert,
    ["error"] = error,
    ["pairs"] = pairs,
    ["ipairs"] = ipairs,
    ["tonumber"] = tonumber,
    ["tostring"] = tostring,
    ["type"] = type,
    ["math"] = math,
}
 
local function getreadablepath( name, pathlist )
    for _, path in ipairs(pathlist) do
        
        local fullpath = path .. "/" .. name .. ".lua"
        local f = io.open( fullpath )
        if f then
            f:close()
            return fullpath
        end
    end
    
    return nil
    
end
 
 
function package.import( name )
 
    -- 已经d的直接返?/pre>
    local existedenv = package.loaded[name]
    if existedenv then
        return existedenv
    end
    
    local access = package.access
    
    -- 讄讉K控制权限
    local meta = 
    {
        __index = function( tab, key )
            
            -- 优先取包的空?/pre>
            local v = rawget( tab, key )
            
            if v then
                return v
            end
            
            -- 找不到时,从可讉K的权限表中查?/pre>
            return access[key]             
            
        end,
    }
    
    -- 初始化一个包的全局环境, q设|访问方?/pre>
    local env = setmetatable( {} , meta )
    
    --
    local readablepath = getreadablepath( name, package.path )
    
    if not readablepath then
        error(string.format("package '%s' not found \n%s", name, table.concat( package.path, "\n" ) ) )
    end
 
    local func = loadfile( readablepath, "bt",  env )
    
    if type(func) ~= "function" then
        return nil
    end
    
    -- 讄标记
    package.loaded[name] = env
    
    -- 执行全局I间
    func( )
    
    return env
end
 
package.path = {"E:/Download/t"}
local m = package.import "m"
 
m.foo()
以下是m模块(m.lua)的内?/pre>
 
 
 
function foo( )
    print("转蝲注明: 战魂筑 http://www.shnenglu.com/sunicdavy", io )    
end

 

试l果? io打印出nil, 昄权限已经被控制住

本package设计比原生package更灵z? 更强?/p>

战魂筑 2013-12-10 16:29 发表评论
]]>
越luabind的luaBridgehttp://www.shnenglu.com/sunicdavy/archive/2013/12/07/204648.html战魂筑战魂筑Sat, 07 Dec 2013 06:05:00 GMThttp://www.shnenglu.com/sunicdavy/archive/2013/12/07/204648.htmlhttp://www.shnenglu.com/sunicdavy/comments/204648.htmlhttp://www.shnenglu.com/sunicdavy/archive/2013/12/07/204648.html#Feedback24http://www.shnenglu.com/sunicdavy/comments/commentRss/204648.htmlhttp://www.shnenglu.com/sunicdavy/services/trackbacks/204648.html 

最q准备在手机目客户端中使用lua, 以前一直在服务器用luabind. 另外, tolua++也体验过, LuaPlus也在早年用过. 以下是本人对q些l定库的个h感觉:

luabind

利用boost机制把绑定做到极? 比较适合主c++, 弱lua的脚本框?

作者已l停止更? 在windows/linux~译没问? 但是在ios的LLVM? 无法~译

tolua++

像cocos2dx使用tolua++也是可以理解? 那么多函数需要绑? tolua++的头文gparse及自动代码生成节U了很多手动l定的时?

但是看到代码中有一部分bugfix心存不?U个人感? 本h使用不多, Ƣ迎砖头伺?,另外, tolua++只能p本层驱动C++, 而没有将已经实例化的句柄注册到lua的功能也是煞W啊

 

LuaPlus

接口较ؓ? 适于初学者上? 无Q何的模板, 性能不高

 

luaBridge

目地址: https://github.com/vinniefalco/LuaBridge

手册: http://vinniefalco.com/LuaBridge/Manual.html

U头文g实现, 无需~译, 包含q入工程卛_, 接口z高?/p>

相比luabind, 唯一不能实现的常用功能就是枚? 但是可以支持cL员静态变量注? q个无所谓了, 手写一个枚举支持也很简?/p>

看下演示代码:

class A
{
public:
    A( )
    {

    }
    virtual void foo( int a )
    {
        printf("foo base\n");
    }

    std::string Member;
};

class B : public A
{
public:
    virtual void foo( int a )
    {
        printf("foo inherited\n");
    }
};
void foo( int b )
{

}

luabridge::getGlobalNamespace(L)
        .beginClass<A>("Sobj")
            .addConstructor<void (*) (void)> ()
            .addFunction("foo", &A::foo)
            .addData("Member",&A::Member)
        .endClass()
        .deriveClass<B, A>("SSec")
            .addFunction("foo",&B::foo )
        .endClass();

    luabridge::getGlobalNamespace(L).addFunction("foo", foo );


    B ins;
    ins.Member = "data";
    luabridge::setGlobal(L, ins, "ins");

lua侧的代码

local a = Sobj()
a:foo(2)
a.Member = "hello"


ins:foo(3)


战魂筑 2013-12-07 14:05 发表评论
]]>
Google Protocolbuf 文本格式的解?/title><link>http://www.shnenglu.com/sunicdavy/archive/2013/07/09/201643.html</link><dc:creator>战魂筑</dc:creator><author>战魂筑</author><pubDate>Tue, 09 Jul 2013 10:29:00 GMT</pubDate><guid>http://www.shnenglu.com/sunicdavy/archive/2013/07/09/201643.html</guid><wfw:comment>http://www.shnenglu.com/sunicdavy/comments/201643.html</wfw:comment><comments>http://www.shnenglu.com/sunicdavy/archive/2013/07/09/201643.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.shnenglu.com/sunicdavy/comments/commentRss/201643.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/sunicdavy/services/trackbacks/201643.html</trackback:ping><description><![CDATA[<p>protobuf是为懒造的工具, 啥协? 啥配|文? l统定义proto, 解析ok, 非常方便</p> <p> </p> <p>文本格式的解析错误不能用捕获错误来获取, 因此,我们需要用自定义的错误收集器q行攉, 看代?</p> <div id="umyakci" class="csharpcode"><pre class="alt">#include <google/protobuf/text_format.h></pre><pre>#include <google/protobuf/io/zero_copy_stream_impl_lite.h></pre><pre class="alt">#include <google/protobuf/io/tokenizer.h></pre><pre> </pre><pre class="alt"><span id="gamysoo" class="kwrd">class</span> PBTextErrorCollector : <span id="woqkeka" class="kwrd">public</span> google::protobuf::io::ErrorCollector</pre><pre>{</pre><pre class="alt"><span id="ascwyoe" class="kwrd">public</span>:</pre><pre> PBTextErrorCollector( <span id="meykwms" class="kwrd">const</span> std::<span id="ueicess" class="kwrd">string</span>& FileName )</pre><pre class="alt"> : mFileName( FileName )</pre><pre> {</pre><pre class="alt"> </pre><pre> }</pre><pre class="alt"> </pre><pre> <span id="uwakuma" class="kwrd">virtual</span> <span id="wqkoymk" class="kwrd">void</span> AddError(<span id="cceyaiy" class="kwrd">int</span> line, <span id="ykmwiqo" class="kwrd">int</span> column, <span id="koqicaq" class="kwrd">const</span> <span id="cmiscaa" class="kwrd">string</span>& message)</pre><pre class="alt"> {</pre><pre> CCLog(<span id="cuoqaqo" class="str">"%s(%d:%d) %s "</span>, mFileName.c_str(), line, column, message.c_str() );</pre><pre class="alt"> }</pre><pre> </pre><pre class="alt"> <span id="owikwca" class="kwrd">virtual</span> <span id="amgqaqo" class="kwrd">void</span> AddWarning(<span id="wgcuyuu" class="kwrd">int</span> line, <span id="oosuemk" class="kwrd">int</span> column, <span id="mwgsmcy" class="kwrd">const</span> <span id="aewakkq" class="kwrd">string</span>& message) </pre><pre> {</pre><pre class="alt"> CCLog(<span id="oquwgou" class="str">"%s(%d:%d) %s "</span>, mFileName.c_str(), line, column, message.c_str() );</pre><pre> }</pre><pre class="alt"> </pre><pre><span id="akmoaqe" class="kwrd">private</span>:</pre><pre class="alt"> std::<span id="oqsmyws" class="kwrd">string</span> mFileName;</pre><pre>};</pre><pre class="alt"> </pre></div> <style type="text/css">.csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; } </style> <p>解析代码</p> <div id="uyscmki" class="csharpcode"><pre class="alt">google::protobuf::TextFormat::Parser P; </pre><pre> P.RecordErrorsTo( &PEC );</pre><pre class="alt"> P.Parse( &AIS, &AF );</pre></div> <style type="text/css">.csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; } </style> <p> </p> <p>另外: 文本格式的注释用unix shell风格: ?开?/p> <p>下面是我的文本格式的配置文g</p> <p> </p><pre class="csharpcode">AnchorPointX: 0.5 AnchorPointY: 0 SpriteScale: 2 ComponentName: <span id="gaeyige" class="str">"ActorActionManager"</span> ComponentName: <span id="kmwisgg" class="str">"ActorFrameEventDispatcher"</span> <span id="yqcmoeu" class="rem">#ComponentName: "SoundFXController"</span> ComponentName: <span id="oakegei" class="str">"RoleDeltaMoveController"</span> ComponentName: <span id="oquwgew" class="str">"RoleBehaviorDirector"</span> InitAction: AA_Idle Animations { AnimationName: <span id="eqkuwms" class="str">"mai_idle"</span> AnimationInterval: 0.067 } </pre> <style type="text/css">.csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; } </style><img src ="http://www.shnenglu.com/sunicdavy/aggbug/201643.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/sunicdavy/" target="_blank">战魂筑</a> 2013-07-09 18:29 <a href="http://www.shnenglu.com/sunicdavy/archive/2013/07/09/201643.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Lua使用protocolbufhttp://www.shnenglu.com/sunicdavy/archive/2013/04/24/199693.html战魂筑战魂筑Wed, 24 Apr 2013 07:44:00 GMThttp://www.shnenglu.com/sunicdavy/archive/2013/04/24/199693.htmlhttp://www.shnenglu.com/sunicdavy/comments/199693.htmlhttp://www.shnenglu.com/sunicdavy/archive/2013/04/24/199693.html#Feedback4http://www.shnenglu.com/sunicdavy/comments/commentRss/199693.htmlhttp://www.shnenglu.com/sunicdavy/services/trackbacks/199693.html?a >https://code.google.com/p/protoc-gen-lua/ 下蝲|易兄弟写的lua的protobuf插g(|易都把pbl弄完了,as3的也是他们写?.)

 

~译python版的protobuf模块

?a >https://code.google.com/p/protobuf/downloads/list 下蝲官方的原生版本protobuf, q里发文时用的?.4.1版本

~译出protoc执行文g, 放一份在protobuf-2.4.1\src\?/p>

下蝲python2.7版本, 在protobuf-2.4.1\python下运行python setup.py install(如果找不到pythonLpythonl对路径)

q一? python会下一个蛋( 真的是一个python的egg文g ), 然后~译出python版本的protobuf模块攄在python?/p>

 

制作protoc-gen-lua的批处理

放一份protoc在protoc-gen-lua的plugin目录

~写批处?protoc-gen-lua.bat

@python "%~dp0protoc-gen-lua"

 

协议目录生成脚本

在你需要放|协议的目录~写如下批处?/p>

buildproto.bat

rd /S /Q .\%1%
"..\..\src\protoc-gen-lua\plugin\protoc.exe" --plugin=protoc-gen-lua="..\..\src\protoc-gen-lua\plugin\protoc-gen-lua.bat" --lua_out=. %1%.proto

注意protoc.exe及protoc-gen-lua.bat的\径符合你的\?/p>

再编写要~译的proto协议的批处理generate.bat

call buildproto.bat loginsvc

执行generate.bat? 会~译同目录下的loginsvc.proto,输出loginsvc_pb.lua

 

~译链接lua的pb?/strong>

protoc-gen-lua\protobuf\目录拯C前的协议目录

其下的pb.c铑օ你的工程, 注意VS2010的VC下需要修Ҏ?/p>

1.?#include <endian.h>修改?/p>

#ifndef _WIN32
     #include <endian.h>
     #endif

避免在windows下缺失文件报?

2. 调整struct_unpack函数前几行ؓ

static int struct_unpack(lua_State *L)
{
    uint8_t format = luaL_checkinteger(L, 1);
    size_t len;
    const uint8_t* buffer = (uint8_t*)luaL_checklstring(L, 2, &len);
    size_t pos = luaL_checkinteger(L, 3);
    uint8_t out[8];   

    buffer += pos;

避免VS2010的VC~译器过于标? 严格要求C风格函数变量前置声明

在lua_State声明后添加如下代?/p>

extern "C" { int luaopen_pb (lua_State *L);}   // 注意防在命名I间外的全局声明

    luaopen_pb( L );   // 直接注入全局pb, 避免动态加载pb.dll造成的一pd跨^台问?/p>

 

lua中用pb

local loginsvc_pb = require “loginsvc_pb”
 
local REQ = loginsvc_pb.CheckVersionREQ()
local Data = REQ:SerializeToString( )
 
local ACK = loginsvc_pb.CheckVersionACK()
ACK:ParseFromString( Data )

 

.csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; }

我的工程目录

script\
        protobuf\
            buildproto.bat
            generate.bat
            loginsvc_pb.lua
            loginsvc.proto
        Main.lua
    src\
        protoc-gen-lua\
            example\
            plugin\
            protobuf\



战魂筑 2013-04-24 15:44 发表评论
]]>
Lua实现事gz֏?/title><link>http://www.shnenglu.com/sunicdavy/archive/2013/04/24/199692.html</link><dc:creator>战魂筑</dc:creator><author>战魂筑</author><pubDate>Wed, 24 Apr 2013 07:19:00 GMT</pubDate><guid>http://www.shnenglu.com/sunicdavy/archive/2013/04/24/199692.html</guid><wfw:comment>http://www.shnenglu.com/sunicdavy/comments/199692.html</wfw:comment><comments>http://www.shnenglu.com/sunicdavy/archive/2013/04/24/199692.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/sunicdavy/comments/commentRss/199692.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/sunicdavy/services/trackbacks/199692.html</trackback:ping><description><![CDATA[<p>Z降低模块间的耦合, 很多pȝ使用事gz֏机制, 接收Ҏ需知道z֏者是?在Qt?q个pȝ被称作Slot&Signal, 需要配合moc代码生成机制, 但是pȝ本n是线E安全的.</p> <p>q里我们讨论的是lua的事件派发机? 我将此写成lua模块, 方便配合cocos2dxq行逻辑处理</p> <p> </p> <div id="iiuoqge" class="csharpcode"><pre class="alt"><span id="queyiqm" class="kwrd">local</span> Global = _G</pre><pre><span id="sewiige" class="kwrd">local</span> package = _G.package</pre><pre class="alt"><span id="mgiuwui" class="kwrd">local</span> setmetatable = _G.setmetatable</pre><pre><span id="gicmgec" class="kwrd">local</span> assert = _G.assert</pre><pre class="alt"><span id="moisecq" class="kwrd">local</span> table = _G.table</pre><pre><span id="wgcuqmc" class="kwrd">local</span> pairs = _G.pairs</pre><pre class="alt"><span id="ggicouk" class="kwrd">local</span> ipairs = _G.ipairs</pre><pre> </pre><pre class="alt"> </pre><pre>module <span id="ugsuoca" class="str">"Core.EventDispatcher"</span></pre><pre class="alt"> </pre><pre>--[[</pre><pre class="alt">数据层次</pre><pre> </pre><pre class="alt">[<span id="eeikmsq" class="str">"EventName1"</span>] =</pre><pre>{</pre><pre class="alt"> [<span id="qumgige" class="str">"_StaticFunc"</span>] = { Func1, Func2 },</pre><pre> </pre><pre class="alt"> [Object1] = { Func1, Func2 },</pre><pre> [Object2] = { Func1, Func2 },</pre><pre class="alt">},</pre><pre> </pre><pre class="alt">[<span id="cwyqsqq" class="str">"EventName2"</span>] =</pre><pre>{</pre><pre class="alt"> ...</pre><pre>}</pre><pre class="alt"> </pre><pre>]]</pre><pre class="alt"> </pre><pre>-- 默认调用函数</pre><pre class="alt"><span id="segsmai" class="kwrd">local</span> <span id="ewauecs" class="kwrd">function</span> PreInvoke( EventName, Func, Object, UserData, ... )</pre><pre> </pre><pre class="alt"> <span id="wqcmqoc" class="kwrd">if</span> Object then</pre><pre> Func( Object, EventName, ... )</pre><pre class="alt"> <span id="qieegwm" class="kwrd">else</span></pre><pre> Func( EventName, ... )</pre><pre class="alt"> <span id="kwykmig" class="kwrd">end</span></pre><pre> </pre><pre class="alt"><span id="akmqsge" class="kwrd">end</span></pre><pre> </pre><pre class="alt"><span id="oqauwuq" class="kwrd">function</span> New( ) </pre><pre> </pre><pre class="alt"> <span id="wyccymu" class="kwrd">local</span> NewObj = setmetatable( {}, { __index = package.loaded[<span id="sugasqo" class="str">"Core.EventDispatcher"</span>] } )</pre><pre> </pre><pre class="alt"> -- 对象成员初始?/pre><pre> NewObj.mPreInvokeFunc = PreInvoke</pre><pre class="alt"> NewObj.mEventTable = {}</pre><pre> </pre><pre class="alt"> <span id="wgiuwcq" class="kwrd">return</span> NewObj</pre><pre><span id="icuwsqo" class="kwrd">end</span></pre><pre class="alt"> </pre><pre>-- d</pre><pre class="alt"><span id="segsuui" class="kwrd">function</span> Add( Self, EventName, Func, Object, UserData )</pre><pre> </pre><pre class="alt"> assert( Func )</pre><pre> </pre><pre class="alt"> Self.mEventTable[ EventName ] = Self.mEventTable[ EventName ] or {}</pre><pre> </pre><pre class="alt"> <span id="oauuyuu" class="kwrd">local</span> Event = Self.mEventTable[ EventName ]</pre><pre> </pre><pre class="alt"> <span id="kmwycao" class="kwrd">if</span> not Object then</pre><pre> Object = <span id="kmqkcsa" class="str">"_StaticFunc"</span></pre><pre class="alt"> <span id="ysueyoo" class="kwrd">end</span></pre><pre> </pre><pre class="alt"> Event[Object] = Event[Object] or {}</pre><pre> <span id="ueoakai" class="kwrd">local</span> ObjectEvent = Event[Object]</pre><pre class="alt"> </pre><pre> ObjectEvent[Func] = UserData or true</pre><pre class="alt"> </pre><pre><span id="acwoqye" class="kwrd">end</span></pre><pre class="alt"> </pre><pre>-- 讄调用前回?/pre><pre class="alt"><span id="akeeioa" class="kwrd">function</span> SetDispatchHook( Self, HookFunc )</pre><pre> </pre><pre class="alt"> Self.mPreInvokeFunc = HookFunc</pre><pre><span id="oiswoem" class="kwrd">end</span></pre><pre class="alt"> </pre><pre> </pre><pre class="alt">-- z֏</pre><pre><span id="owgickg" class="kwrd">function</span> Dispatch( Self, EventName, ... )</pre><pre class="alt"> </pre><pre> assert( EventName )</pre><pre class="alt"> </pre><pre> <span id="ugqcuui" class="kwrd">local</span> Event = Self.mEventTable[ EventName ]</pre><pre class="alt"> </pre><pre> <span id="moikmay" class="kwrd">for</span> Object,ObjectFunc <span id="gicwggw" class="kwrd">in</span> pairs( Event ) do</pre><pre class="alt"> </pre><pre> <span id="cuyaayw" class="kwrd">if</span> Object == <span id="ykmegwu" class="str">"_StaticFunc"</span> then</pre><pre class="alt"> </pre><pre> <span id="icmosoe" class="kwrd">for</span> Func, UserData <span id="moqsukq" class="kwrd">in</span> pairs( ObjectFunc ) do</pre><pre class="alt"> Self.mPreInvokeFunc( EventName, Func, nil, UserData, ... ) </pre><pre> <span id="qsmogwe" class="kwrd">end</span></pre><pre class="alt"> </pre><pre> <span id="ikegigw" class="kwrd">else</span></pre><pre class="alt"> </pre><pre> <span id="eoqcesi" class="kwrd">for</span> Func, UserData <span id="myauoms" class="kwrd">in</span> pairs( ObjectFunc ) do</pre><pre class="alt"> Self.mPreInvokeFunc( EventName, Func, Object, UserData, ... )</pre><pre> <span id="scwgkqo" class="kwrd">end</span></pre><pre class="alt"> </pre><pre> <span id="cuoiska" class="kwrd">end</span></pre><pre class="alt"> </pre><pre> <span id="mwqcwki" class="kwrd">end</span></pre><pre class="alt"> </pre><pre><span id="mwgsmsy" class="kwrd">end</span></pre><pre class="alt"> </pre><pre>-- 回调是否存在</pre><pre class="alt"><span id="yykcoek" class="kwrd">function</span> Exist( Self, EventName )</pre><pre> </pre><pre class="alt"> assert( EventName )</pre><pre> </pre><pre class="alt"> <span id="gyskous" class="kwrd">local</span> Event = Self.mEventTable[ EventName ]</pre><pre> </pre><pre class="alt"> <span id="ggkycss" class="kwrd">if</span> not Event then</pre><pre> <span id="amgcuki" class="kwrd">return</span> false</pre><pre class="alt"> <span id="qakeoom" class="kwrd">end</span></pre><pre> </pre><pre class="alt"> -- 需要遍历下map, 可能有事件名存在, 但是没有M回调?/pre><pre> <span id="yseegem" class="kwrd">for</span> Object,ObjectFunc <span id="wiaegms" class="kwrd">in</span> pairs( Event ) do</pre><pre class="alt"> </pre><pre> <span id="qcwyiom" class="kwrd">for</span> Func, _ <span id="kwwasiq" class="kwrd">in</span> pairs( ObjectFunc ) do</pre><pre class="alt"> -- 居然有一?/pre><pre> <span id="cmosuai" class="kwrd">return</span> true</pre><pre class="alt"> <span id="egscgwe" class="kwrd">end</span></pre><pre> </pre><pre class="alt"> <span id="cwoiccq" class="kwrd">end</span></pre><pre> </pre><pre class="alt"> </pre><pre> <span id="ikgiaag" class="kwrd">return</span> false</pre><pre class="alt"> </pre><pre><span id="aueoagw" class="kwrd">end</span></pre><pre class="alt"> </pre><pre>-- 清除</pre><pre class="alt"><span id="mykuwou" class="kwrd">function</span> Remove( Self, EventName, Func, Object )</pre><pre> </pre><pre class="alt"> assert( Func )</pre><pre> </pre><pre class="alt"> <span id="mgaswsq" class="kwrd">local</span> Event = Self.mEventTable[ EventName ]</pre><pre> </pre><pre class="alt"> <span id="wyikous" class="kwrd">if</span> not Event then</pre><pre> <span id="skoqsga" class="kwrd">return</span></pre><pre class="alt"> <span id="augquso" class="kwrd">end</span></pre><pre> </pre><pre class="alt"> <span id="amegaqo" class="kwrd">if</span> not Object then</pre><pre> Object = <span id="oqawgmc" class="str">"_StaticFunc"</span></pre><pre class="alt"> <span id="moacomu" class="kwrd">end</span></pre><pre> </pre><pre class="alt"> </pre><pre> <span id="wyiegwk" class="kwrd">local</span> ObjectEvent = Event[Object]</pre><pre class="alt"> </pre><pre> <span id="eqkmwus" class="kwrd">if</span> not ObjectEvent then</pre><pre class="alt"> <span id="oimgyom" class="kwrd">return</span></pre><pre> <span id="kmgscag" class="kwrd">end</span></pre><pre class="alt"> </pre><pre> ObjectEvent[Func] = nil</pre><pre class="alt"> </pre><pre> </pre><pre class="alt"><span id="myiugek" class="kwrd">end</span></pre><pre> </pre><pre class="alt">-- 清除对象的所有回?/pre><pre><span id="yswgsyg" class="kwrd">function</span> RemoveObjectAllFunc( Self, EventName, Object )</pre><pre class="alt"> </pre><pre> assert( Object )</pre><pre class="alt"> </pre><pre> <span id="maaeguc" class="kwrd">local</span> Event = Self.mEventTable[ EventName ]</pre><pre class="alt"> </pre><pre> <span id="gcmqkyy" class="kwrd">if</span> not Event then</pre><pre class="alt"> <span id="mgikmsk" class="kwrd">return</span></pre><pre> <span id="seoakag" class="kwrd">end</span></pre><pre class="alt"> </pre><pre> Event[Object] = nil</pre><pre class="alt"> </pre><pre><span id="wssmoek" class="kwrd">end</span></pre><pre class="alt"> </pre></div> <style type="text/css">.csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; } </style> <p>q里注意? 我是EventDispatcher.lua攄在Core目录? 因此需要用require “Core.EventDispatcher”进行调?/p> <p>使用用例</p> <p> </p> <div id="oieeyye" class="csharpcode"><pre class="alt"> <span id="eeaswci" class="kwrd">local</span> EventDispatcher = require <span id="iueikqy" class="str">'Core.EventDispatcher'</span></pre><pre> </pre><pre class="alt"> <span id="cmoimiy" class="kwrd">local</span> E = EventDispatcher.New()</pre><pre> </pre><pre class="alt"> </pre><pre> E:Add( <span id="yimoqom" class="str">"a"</span>, <span id="qccoyym" class="kwrd">function</span>( a, b ) print( a, b ) <span id="eyquwka" class="kwrd">end</span> )</pre><pre class="alt"> </pre><pre> <span id="gakugmm" class="kwrd">local</span> Func = <span id="qskegoe" class="kwrd">function</span>( a ) print( a ) <span id="ewicwci" class="kwrd">end</span> </pre><pre class="alt"> E:Add( <span id="ceqacka" class="str">"a"</span>, Func )</pre><pre> </pre><pre class="alt"> </pre><pre> E:Dispatch(<span id="iseyiqo" class="str">"a"</span>, 1, 2 )</pre><pre class="alt"> print( E:Exist(<span id="wyikuui" class="str">"a"</span>), E:Exist(<span id="qsceoec" class="str">"b"</span>))</pre><pre> </pre><pre class="alt"> E:Remove(<span id="gacyygu" class="str">"a"</span>, Func )</pre><pre> </pre><pre class="alt"> E:Dispatch(<span id="meauwsa" class="str">"a"</span>, 1, 2 )</pre><pre> print( E:Exist(<span id="aeeqcaq" class="str">"a"</span>), E:Exist(<span id="yauwgge" class="str">"b"</span>))</pre></div> <style type="text/css">.csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; } </style><img src ="http://www.shnenglu.com/sunicdavy/aggbug/199692.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/sunicdavy/" target="_blank">战魂筑</a> 2013-04-24 15:19 <a href="http://www.shnenglu.com/sunicdavy/archive/2013/04/24/199692.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>Excel中VBA转换文g~码到UTF-8http://www.shnenglu.com/sunicdavy/archive/2012/09/13/190553.html战魂筑战魂筑Thu, 13 Sep 2012 11:43:00 GMThttp://www.shnenglu.com/sunicdavy/archive/2012/09/13/190553.htmlhttp://www.shnenglu.com/sunicdavy/comments/190553.htmlhttp://www.shnenglu.com/sunicdavy/archive/2012/09/13/190553.html#Feedback2http://www.shnenglu.com/sunicdavy/comments/commentRss/190553.htmlhttp://www.shnenglu.com/sunicdavy/services/trackbacks/190553.html|上找了很多, 真正好用的代码不? 自己研究了下,写下例子备䆾

 

Private Sub ConvFile(InputFile As String, OutputFile As String)
 
    Dim ReadStream As Object
    Set ReadStream = CreateObject("ADODB.Stream")
    
    Dim FileContent As String
    
    With ReadStream
        .Type = 2               'adTypeText
        .Charset = "UNICODE"
        .Open
        .LoadFromFile InputFile
        FileContent = .ReadText
        .Close
        
    End With
    
    Set ReadStream = Nothing
    
    
    
    Dim WriteStream As Object
    Set WriteStream = CreateObject("ADODB.Stream")
       
    
    With WriteStream
        .Type = 2               'adTypeText
        .Charset = "UTF-8"
        .Open
        .WriteText FileContent
        .SaveToFile OutputFile, 2  'adSaveCreateOverWrite
        
        .Flush
        .Close
        
    End With
    
    Set WriteStream = Nothing
 
    
End Sub

 

上半截是d文g, 下半截是写入文g, 需要{换不同格? 误行更?/p>

战魂筑 2012-09-13 19:43 发表评论
]]>
Linux服务自动安装卸蝲部v脚本http://www.shnenglu.com/sunicdavy/archive/2012/04/12/171026.html战魂筑战魂筑Thu, 12 Apr 2012 01:33:00 GMThttp://www.shnenglu.com/sunicdavy/archive/2012/04/12/171026.htmlhttp://www.shnenglu.com/sunicdavy/comments/171026.htmlhttp://www.shnenglu.com/sunicdavy/archive/2012/04/12/171026.html#Feedback0http://www.shnenglu.com/sunicdavy/comments/commentRss/171026.htmlhttp://www.shnenglu.com/sunicdavy/services/trackbacks/171026.html#!/bin/bash # chkconfig: 3 3 1 # description: svclauncher

ServicePath=/usr/local/bin

ServiceList=(
"wkcenterd --toc /home/davy/dev/kaze/Config/CenterService.toc --logfile /tmp/centerd.log"
"wkagentd --toc /home/davy/dev/kaze/Config/AgentService.toc --logfile /tmp/agentd.log"
)

StartAll()
{
    for((i = 0;i<${#ServiceList[*]};i=i+1))
    do

     echo "start:" $ServicePath/${ServiceList[i]}
     $ServicePath/${ServiceList[i]} > /dev/null &

    done
}

StopAll()
{
    for((i = 0;i<${#ServiceList[*]};i=i+1))
    do

     echo "stop:" $ServicePath/${ServiceList[i]}
     svcname=`echo ${ServiceList[i]} | awk '{print $1}'`
     killall $svcname > /dev/null

    done
}

RestartAll()
{
    StopAll
    StartAll
}


InstallService()
{
    svcname=`basename $0`
    chmod +x $svcname
    cp $svcname /etc/init.d
    ln /etc/init.d/$svcname /etc/rc3.d/S03$svcname
    ln /etc/init.d/$svcname /etc/rc0.d/K03$svcname
    chkconfig --add $svcname
    chkconfig $svcname on
    chkconfig --list | grep $svcname
}

UninstallService()
{
    svcname=`basename $0`
    chkconfig --del $svcname
    rm -f /etc/init.d/$svcname
    rm -f /etc/rc3.d/S03$svcname
    rm -f /etc/rc3.d/K03$svcname
}



case "$1" in
    start)
    StartAll
    ;;
    stop)
    StopAll
    ;;
    restart)
    RestartAll
    ;;
    install)
    InstallService
    ;;
    uninstall)
    UninstallService
    ;;
    *)
           echo "Usage: service $EXEC {install|start|stop|restart|uninst}"
       exit 1
esac
 
exit $? 



战魂筑 2012-04-12 09:33 发表评论
]]>luabind实现lua中的取对象大功?/title><link>http://www.shnenglu.com/sunicdavy/archive/2012/03/27/169178.html</link><dc:creator>战魂筑</dc:creator><author>战魂筑</author><pubDate>Tue, 27 Mar 2012 09:36:00 GMT</pubDate><guid>http://www.shnenglu.com/sunicdavy/archive/2012/03/27/169178.html</guid><wfw:comment>http://www.shnenglu.com/sunicdavy/comments/169178.html</wfw:comment><comments>http://www.shnenglu.com/sunicdavy/archive/2012/03/27/169178.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.shnenglu.com/sunicdavy/comments/commentRss/169178.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/sunicdavy/services/trackbacks/169178.html</trackback:ping><description><![CDATA[<p>在lua? #操作W用于获取对象大? 对于table来说, 获取的是table元素个数, 对于字符串来说获取的是字W串长度</p> <p>另外一U获取方法是table.getn(obj), 但是q个Ҏ已经标记为废除了, 量使用通用且简z的#操作W?/p> <p> </p> <p>使用lua api实现此功能就需要用到lua_objlen( ),但是q个功能未在luabind中提?所以我们顺手添加一?/p> <p>首先扑ֈluabind源码的object.hpp中取对象cd的type函数,在其下添加以下代?/p> <p> </p><pre style="border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; padding-bottom: 5px; background-color: #fbfbfb; min-height: 40px; padding-left: 5px; width: 650px; padding-right: 5px; overflow: auto; border-top: #cecece 1px solid; border-right: #cecece 1px solid; padding-top: 5px"><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 1: <span style="color: #0000ff">template</span><<span style="color: #0000ff">class</span> ValueWrapper></pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 2: <span style="color: #0000ff">inline</span> <span style="color: #0000ff">int</span> obj_size(ValueWrapper <span style="color: #0000ff">const</span>& value)</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 3: {</pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 4: lua_State* interpreter = value_wrapper_traits<ValueWrapper>::interpreter(</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 5: value</pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 6: );</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 7: </pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 8: value_wrapper_traits<ValueWrapper>::unwrap(interpreter, value);</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 9: detail::stack_pop pop(interpreter, 1);</pre><pre style="background-color: #ffffff; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 10: <span style="color: #0000ff">return</span> lua_objlen(interpreter, -1);</pre><pre style="background-color: #fbfbfb; margin: 0em; width: 100%; font-family: consolas,'Courier New',courier,monospace; font-size: 12px"> 11: }</pre><p> </p></pre> 重新~译你的代码, 可以这样用luabind::obj_size( obj ) 获取对象大小?img src ="http://www.shnenglu.com/sunicdavy/aggbug/169178.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/sunicdavy/" target="_blank">战魂筑</a> 2012-03-27 17:36 <a href="http://www.shnenglu.com/sunicdavy/archive/2012/03/27/169178.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>luabind使用coroutine时的一处善意提C导致的BUGhttp://www.shnenglu.com/sunicdavy/archive/2012/03/27/169110.html战魂筑战魂筑Tue, 27 Mar 2012 02:38:00 GMThttp://www.shnenglu.com/sunicdavy/archive/2012/03/27/169110.htmlhttp://www.shnenglu.com/sunicdavy/comments/169110.htmlhttp://www.shnenglu.com/sunicdavy/archive/2012/03/27/169110.html#Feedback2http://www.shnenglu.com/sunicdavy/comments/commentRss/169110.htmlhttp://www.shnenglu.com/sunicdavy/services/trackbacks/169110.html以下代码使用luabindq行lua的coroutine试

   1: void ScriptManagedChannel::OnServiceInitialize()
   2: {    
   3:     try
   4:     {        
   5:         mThread = lua_newthread( GScriptScriptContext->GetVM() );
   6:  
   7:         luabind::resume_function<void>( mThread, "ScriptMain", this );
   8:  
   9:         Resume();
  10:     }
  11:     catch (std::exception& e)
  12:     {
  13:         const char* ErrorMsg = lua_tostring( GScriptScriptContext->GetVM(), -1 );            
  14:         printf("%s\n", e.what() );
  15:     }
  16:  
  17:     
  18: }
  19:  
  20: void ScriptManagedChannel::Resume( )
  21: {
  22:     luabind::resume<void>( mThread );
  23: }
  24:  
  25: void ScriptManagedChannel::StopTest( )
  26: {
  27:     lua_yield( mThread, 0 );
  28: }
  29:  
  30:  

代码? mThreadcd为lua_State*cd

GScriptScriptContext->GetVM()是加载了代码的lua_State*

StopTest为注册ؓScriptManagedChannelcL员函数到lua中的定义

接下来看lua端的试代码:

   1: function ScriptMain( Channel )
   2:  
   3:     
   4:     for i = 1, 5 do
   5:     
   6:     print("done", i)
   7:     
   8:     Channel:StopTest( )
   9:     
  10:     
  11:     
  12:     end
  13: end

刚开?在测试代码时, lua中有个手误而造成的错? DC++代码q行到第7行时弹出assert

位于:luabind-0.9.1\luabind\detail\call_function.hpp W?64?对应以下代码W?3?/p>

   1: ~proxy_function_void_caller()
   2: {
   3:     if (m_called) return;
   4:  
   5:     m_called = true;
   6:     lua_State* L = m_state;
   7:  
   8:     int top = lua_gettop(L);
   9:  
  10:     push_args_from_tuple<1>::apply(L, m_args);
  11:     if (m_fun(L, boost::tuples::length<Tuple>::value, 0))
  12:     {
  13:         assert(lua_gettop(L) == top - m_params + 1);
  14:  
  15: NO_EXCEPTIONS
  16:         throw luabind::error(L);
  17: #else
  18:         error_callback_fun e = get_error_callback();
  19:         if (e) e(L);
  20:     
  21:         assert(0 && "the lua function threw an error and exceptions are disabled."
  22:                 " If you want to handle the error you can use luabind::set_error_callback()");
  23:         std::terminate();
  24: #endif
  25:     }
  26:     // pops the return values from the function call
  27:     stack_pop pop(L, lua_gettop(L) - top + m_params);
  28: }

11行代码中调用的是lua_resume, q回的是q行错误, 但是?3行的assert挡住? 无法通过W?6行抛出异常被外面捕获.

因此,试注释W?3?/strong>, 再测? 可以在lua抛出错误? 在栈捕获到coroutine函数resume时报出的错误信息.问题解决

 

对于lua的coroutine, |上资料不多, q里有一比较详l的代码

我比较疑惑的? 有没有必要将代码在dofile或者dobuffer? 必须传入newthread出的state? 如果q是传入原始的state会有什么媄?

Ƣ迎各位有此l验的讨?/p>

战魂筑 2012-03-27 10:38 发表评论
]]>
为lua构徏沙盒(SandBox)环境http://www.shnenglu.com/sunicdavy/archive/2012/03/02/166948.html战魂筑战魂筑Fri, 02 Mar 2012 01:40:00 GMThttp://www.shnenglu.com/sunicdavy/archive/2012/03/02/166948.htmlhttp://www.shnenglu.com/sunicdavy/comments/166948.htmlhttp://www.shnenglu.com/sunicdavy/archive/2012/03/02/166948.html#Feedback0http://www.shnenglu.com/sunicdavy/comments/commentRss/166948.htmlhttp://www.shnenglu.com/sunicdavy/services/trackbacks/166948.html我们有时需要限制lua代码的运行环?或者是让用者不能访问到lua的一些全局函数.lua语言本n没有cM于C++, C#, Java那样的成员访问控? 但lua提供了setfenv函数可以很灵zȝ处理各类权限问题

废话不多? 看代?/p>

   1:  -- 创徏沙盒
   2:  function SpawnSandBox( )
   3:   
   4:      local SandBoxGlobals = {}
   5:      
   6:      -- 基础函数d
   7:      SandBoxGlobals.print             = print
   8:      SandBoxGlobals.table             = table
   9:      SandBoxGlobals.string             = string     
  10:      SandBoxGlobals.math               = math 
  11:      SandBoxGlobals.assert             = assert 
  12:      SandBoxGlobals.getmetatable    = getmetatable 
  13:      SandBoxGlobals.ipairs             = ipairs 
  14:      SandBoxGlobals.pairs             = pairs 
  15:      SandBoxGlobals.pcall             = pcall 
  16:      SandBoxGlobals.setmetatable    = setmetatable 
  17:      SandBoxGlobals.tostring        = tostring 
  18:      SandBoxGlobals.tonumber        = tonumber 
  19:      SandBoxGlobals.type            = type 
  20:      SandBoxGlobals.unpack             = unpack 
  21:      SandBoxGlobals.collectgarbage     = collectgarbage
  22:      SandBoxGlobals._G                = SandBoxGlobals
  23:      
  24:      return SandBoxGlobals
  25:  end
  26:   
  27:  -- 在沙盒内执行脚本, 出错时返回错? nil表示正确
  28:  function ExecuteInSandBox( SandBox, Script )
  29:      
  30:      local ScriptFunc, CompileError = loadstring( Script )
  31:      
  32:      if CompileError then
  33:          return CompileError
  34:      end
  35:      
  36:      setfenv( ScriptFunc, SandBox )
  37:      
  38:      local Result, RuntimeError = pcall( ScriptFunc )
  39:      if RuntimeError then
  40:          return RuntimeError
  41:      end
  42:      
  43:      return nil
  44:  end
  45:   
  46:  function ProtectedFunction( )
  47:      print("protected func")
  48:  end
  49:   
  50:   
  51:  local SandBox = SpawnSandBox( )
  52:   
  53:   
  54:  print ( "Response=", ExecuteInSandBox( SandBox, "table.foreach( _G, print )" ) )
  55:   
  56:  print ( "Response=", ExecuteInSandBox( SandBox, "ProtectedFunction()" ) )
  57:   
  58:  SandBox.ProtectedFunction = ProtectedFunction
  59:   
  60:  print ( "Response=", ExecuteInSandBox( SandBox, "ProtectedFunction()" ) )

 

54行执行结果是

 

   1:  _G    table: 00421258
   2:  string    table: 00421050
   3:  pairs    function: 00567F58
   4:  collectgarbage    function: 005675F0
   5:  unpack    function: 004217E8
   6:  assert    function: 005675B0
   7:  print    function: 00567830
   8:  ipairs    function: 00567F28
   9:  type    function: 004217A8
  10:  tonumber    function: 00421768
  11:  tostring    function: 00421788
  12:  table    table: 00420DA8
  13:  math    table: 004210C8
  14:  setmetatable    function: 00421748
  15:  getmetatable    function: 00567710
  16:  pcall    function: 005677F0
  17:  Response=    nil
 
54行由于没有注册这个全局函数, 因此无法讉K
Response=    [string "ProtectedFunction()"]:1: attempt to call global 'ProtectedFunction' (a nil value)
 
58行在全局环境中加上了q个函数,因此?0行访问正?/div>
protected func
Response=    nil
 


战魂筑 2012-03-02 09:40 发表评论
]]>Linux下将ldd打印的依赖列表拷贝到指定目录http://www.shnenglu.com/sunicdavy/archive/2012/02/29/166791.html战魂筑战魂筑Wed, 29 Feb 2012 08:05:00 GMThttp://www.shnenglu.com/sunicdavy/archive/2012/02/29/166791.htmlhttp://www.shnenglu.com/sunicdavy/comments/166791.htmlhttp://www.shnenglu.com/sunicdavy/archive/2012/02/29/166791.html#Feedback0http://www.shnenglu.com/sunicdavy/comments/commentRss/166791.htmlhttp://www.shnenglu.com/sunicdavy/services/trackbacks/166791.htmlLinux下的ldd命o可以查看一个可执行文g/׃n?静态库的依? 但是惛_到这些依赖文? 必须手动L,非常ȝ

q里是一个Shell可以依赖列表中的文件拷贝到指定目录

deplist=$( ldd $1 | awk '{if (match($3,"/")){ print $3}}' )
cp $deplist $2
代码解释: ldd导出列表, q个列表打印出来很丑

linux-gate.so.1 =>  (0x00ed2000)
    liblog4cpp.so.4 => /usr/local/lib/liblog4cpp.so.4 (0x00657000)
    libprotobuf.so.7 => /usr/local/lib/libprotobuf.so.7 (0x00360000)
    libboost_filesystem.so.1.48.0 => /usr/local/lib/libboost_filesystem.so.1.48.0 (0x00a9a000)
    libboost_program_options.so.1.48.0 => /usr/local/lib/libboost_program_options.so.1.48.0 (0x00110000)
    libboost_system.so.1.48.0 => /usr/local/lib/libboost_system.so.1.48.0 (0x00a85000)
    libboost_thread.so.1.48.0 => /usr/local/lib/libboost_thread.so.1.48.0 (0x00179000)
    libunwind-x86.so.7 => /usr/lib/libunwind-x86.so.7 (0x00821000)
    libluabindd.so.0.9.0 => /usr/local/lib/libluabindd.so.0.9.0 (0x00bb3000)
    libmysqlpp.so.3 => /usr/local/lib/libmysqlpp.so.3 (0x00de5000)
    libstdc++.so.6 => /usr/lib/i386-linux-gnu/libstdc++.so.6 (0x001a9000)
    libm.so.6 => /lib/i386-linux-gnu/libm.so.6 (0x00782000)
    libgcc_s.so.1 => /lib/i386-linux-gnu/libgcc_s.so.1 (0x00aea000)
    libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0x00447000)
    libpthread.so.0 => /lib/i386-linux-gnu/libpthread.so.0 (0x00abd000)
    librt.so.1 => /lib/i386-linux-gnu/librt.so.1 (0x00193000)
    libnsl.so.1 => /lib/i386-linux-gnu/libnsl.so.1 (0x00294000)
    libunwind.so.7 => /usr/lib/libunwind.so.7 (0x002ab000)
    libdl.so.2 => /lib/i386-linux-gnu/libdl.so.2 (0x00e8a000)
    libmysqlclient_r.so.16 => /usr/lib/libmysqlclient_r.so.16 (0x0083b000)
    /lib/ld-linux.so.2 (0x00608000)
    libz.so.1 => /lib/i386-linux-gnu/libz.so.1 (0x002c0000)

 

我们发现W一行的so没有对应的库地址, 因此我们使用awk的脚本功?判断W三个参?也就?>之后的\径必d?

之后第一行的输出重定向到变量? 再用cp指o从列表拷贝到指定目录



战魂筑 2012-02-29 16:05 发表评论
]]>
使用批处理ؓprotocbuffer的输出c++文gd预编译头http://www.shnenglu.com/sunicdavy/archive/2011/11/02/159518.html战魂筑战魂筑Wed, 02 Nov 2011 09:32:00 GMThttp://www.shnenglu.com/sunicdavy/archive/2011/11/02/159518.htmlhttp://www.shnenglu.com/sunicdavy/comments/159518.htmlhttp://www.shnenglu.com/sunicdavy/archive/2011/11/02/159518.html#Feedback1http://www.shnenglu.com/sunicdavy/comments/commentRss/159518.htmlhttp://www.shnenglu.com/sunicdavy/services/trackbacks/159518.html使用ProtocolBuffer的编译程序protoc可以?proto生成*.pb.cc的C++代码文g. 但是在带有预~译头的工程? q帔R要手动添加类似stdafx.h的包? q里使用批处理来完成q一q程:

BuildProtoCC.bat

@echo off

set protofile=%1%.proto
set output_cc=%1%.pb.cc

"protoc.exe" %protofile% --cpp_out .
@echo 使用%protofile%生成%output_cc%

if exist "pchheader.txt" goto 合ƈ预编译头 else echo pchheader.txt NOT EXIST

:合ƈ预编译头
@echo 试删除以前的中间文?br>del *.pched
@echo 合ƈ~译头文件pchheader.txt到生?output_cc%
copy pchheader.txt+"%output_cc%" "%output_cc%.pched" /y
@echo {待protoc.exel束
@ping -n 2 127.1>nul
echo 清理文g
del "%output_cc%"
ren "%output_cc%.pched" "%output_cc%"

 

q段批处理这样?

假设你有一个叫login.proto文g和批处理攑֜一?

在同一目录再放|一个pchheader.txt文g,q在里面写入#include "stdafx.h?

调用一下批处理

call BuildProtoCC.bat login

注意login不能带后~

用protoc.exe生成login.pb.cc和login.pb.h 然后使用批处理合q文件功能自动合q~译?

战魂筑 2011-11-02 17:32 发表评论
]]>
protocolbufferdActionScript3支持http://www.shnenglu.com/sunicdavy/archive/2011/08/10/152995.html战魂筑战魂筑Wed, 10 Aug 2011 14:00:00 GMThttp://www.shnenglu.com/sunicdavy/archive/2011/08/10/152995.htmlhttp://www.shnenglu.com/sunicdavy/comments/152995.htmlhttp://www.shnenglu.com/sunicdavy/archive/2011/08/10/152995.html#Feedback0http://www.shnenglu.com/sunicdavy/comments/commentRss/152995.htmlhttp://www.shnenglu.com/sunicdavy/services/trackbacks/152995.htmlprotocolbuffer默认支持java, python 和c++,其他的语a需要自q写代码生成器他语a的代?

不过官网也提到过ActionScript3的支?点击?a >q里

protobuf-actionscript3包括ActionScript3的序列号及反序列化的as源码.以及protoc的as3代码生成器的C++代码

另外, protobuf-actionscript3q需要一个加密库as3crypto支持,需要一q下?/p>

当然, protobuf 库也是最重要?

下面说明如何~译出支持as3的protoc代码生成?

 

1. protobuf-actionscript3库中compiler\as3目录拯到protobuf库的src\google\protobuf\compiler?目录l构如下:

as3\
    cpp\
    java\
    python\
    code_generator.cc
    command_line_interface.cc

...

 

2.打开protobuf工程中的sln, 在libprotocd刚才d的as3目录下的所有文?/p>

3. 在protoc工程的main.cc中添?/p>

  google::protobuf::compiler::as3::As3Generator as3_generator;
  cli.RegisterGenerator("--as3_out", &as3_generator,
      "Generate ActionScript source file."); 

4. 打开as3_file.h

注释掉以下代?/p>

namespace protobuf {
  class FileDescriptor;        // descriptor.h
  namespace io {
    class Printer;             // printer.h
  }
  namespace compiler {
    class OutputDirectory;     // code_generator.h
  }
}

包含内添?/p>

#include <google/protobuf/stubs/common.h>
#include <google/protobuf/compiler/code_generator.h>
#include <google/protobuf/io/printer.h>
5. ~译出protoc.exe
6. 准备proto文g, 使用protoc.exe使用cMCPP生成的方式进行生?/pre>
7. protobuf-actionscript里的as3-lib及下载好的加密的swc整合到自qflash工程卛_开始?/pre>

战魂筑 2011-08-10 22:00 发表评论
]]>试SquirrelN脚本的远E调试功?/title><link>http://www.shnenglu.com/sunicdavy/archive/2011/05/14/146376.html</link><dc:creator>战魂筑</dc:creator><author>战魂筑</author><pubDate>Sat, 14 May 2011 09:42:00 GMT</pubDate><guid>http://www.shnenglu.com/sunicdavy/archive/2011/05/14/146376.html</guid><wfw:comment>http://www.shnenglu.com/sunicdavy/comments/146376.html</wfw:comment><comments>http://www.shnenglu.com/sunicdavy/archive/2011/05/14/146376.html#Feedback</comments><slash:comments>5</slash:comments><wfw:commentRss>http://www.shnenglu.com/sunicdavy/comments/commentRss/146376.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/sunicdavy/services/trackbacks/146376.html</trackback:ping><description><![CDATA[<p>{了大半q?<a >N脚本</a>l于释出?a >3.0E_版本</a></p> <p>N脚本可以说是Lua的超U增强版,作者在Crysis目使用Lua多年,qLua的优~点.之后自己~写了松鼠脚本来解决诸如class,attribute,delegation,更强大的thread,exception{等功能. </p> <p>N脚本本n对Windows开发h员极为照?W三方库可谓丰富,q程调试,代码加色及语法检查都可以直接在VS2008的IDE中进?</p> <p>单的q程调试功能需要以下步?</p> <p>1. 下蝲<a >N脚本3.0版本</a></p> <p>2. ?a >N脚本Wiki</a>中下?a >SQDBGq程调试?/a></p> <p>3. sqdbg工程攑ֈSQUIRREL3之下,打开SQUIRREL3\squirrel.sln,sqdbgd到工E?~译所?/p> <p>4. 在这个Solution?创徏一个SquirrelN工程</p> <p><a href="http://www.shnenglu.com/images/cppblog_com/sunicdavy/WindowsLiveWriter/Squirrel_F936/image_2.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.shnenglu.com/images/cppblog_com/sunicdavy/WindowsLiveWriter/Squirrel_F936/image_thumb.png" width="459" height="96"></a></p> <p>5. 在新创徏的松鼠工E属性中如下图设|?/p> <p><a href="http://www.shnenglu.com/images/cppblog_com/sunicdavy/WindowsLiveWriter/Squirrel_F936/image_4.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.shnenglu.com/images/cppblog_com/sunicdavy/WindowsLiveWriter/Squirrel_F936/image_thumb_1.png" width="535" height="215"></a>  </p> <p>Interpreter其实是启动调试?不是sq.exe)</p> <p>WorkingDirectory 是main.nut所在的目录(官网的\径设|有点误?</p> <p>Command Line Options 是传入sqdbg.exe的命令行参数</p> <p>修改下main.nut文g,例如:</p> <p>for(local i = 1;i<10;i++)<br>{<br>    print( i );<br>}</p> <p>在print语句前打上断?调试N工程,卛_看到调试l果</p> <p><a href="http://www.shnenglu.com/images/cppblog_com/sunicdavy/WindowsLiveWriter/Squirrel_F936/image_8.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.shnenglu.com/images/cppblog_com/sunicdavy/WindowsLiveWriter/Squirrel_F936/image_thumb_3.png" width="361" height="180"></a> </p> <p> </p> <p>有关于SQDBG多文件调?</p> <p>SQDBG默认只能调试1个文?昄是个玩具,不能应对游戏和其他领域的多文件调? 分析了下SQDBG的代?/p> <div id="am4isso" class="csharpcode"><pre class="alt"><span id="k444mc4" class="lnum"> 1: </span><span id="44eaciw" class="kwrd">int</span> main(<span id="44ieyuu" class="kwrd">int</span> argc, <span id="4o4s4ou" class="kwrd">char</span> *argv[])</pre><pre><span id="o4ya4yo" class="lnum"> 2: </span>{</pre><pre class="alt"><span id="ewmmgec" class="lnum"> 3: </span> <span id="qc22ow4" class="kwrd">if</span>(argc < 2){</pre><pre><span id="42my6u4" class="lnum"> 4: </span> scprintf(_SC(<span id="gao4msq" class="str">"SQDBG error : no file specified"</span>));</pre><pre class="alt"><span id="quuwqyo" class="lnum"> 5: </span> <span id="c4wqag2" class="kwrd">return</span> -1;</pre><pre><span id="eic2gem" class="lnum"> 6: </span> }</pre><pre class="alt"><span id="4e2uo46" class="lnum"> 7: </span> </pre><pre><span id="o244om4" class="lnum"> 8: </span> HSQUIRRELVM v = sq_open(1024);</pre><pre class="alt"><span id="44sewem" class="lnum"> 9: </span> sqstd_seterrorhandlers(v);</pre><pre><span id="sc44ymk" class="lnum"> 10: </span> </pre><pre class="alt"><span id="qa4w444" class="lnum"> 11: </span> <span id="iuoimk4" class="rem">//!! INITIALIZES THE DEBUGGER ON THE TCP PORT 1234</span></pre><pre><span id="imoqii4" class="lnum"> 12: </span> <span id="424c4aq" class="rem">//!! ENABLES AUTOUPDATE</span></pre><pre class="alt"><span id="26uoaio" class="lnum"> 13: </span> HSQREMOTEDBG rdbg = sq_rdbg_init(v,1234,SQTrue);</pre><pre><span id="46cw4ka" class="lnum"> 14: </span> <span id="am2i44m" class="kwrd">if</span>(rdbg) {</pre><pre class="alt"><span id="wikcy4u" class="lnum"> 15: </span> </pre><pre><span id="wi244wo" class="lnum"> 16: </span> <span id="q4a46s4" class="rem">//!! ENABLES DEBUG INFO GENERATION(for the compiler)</span></pre><pre class="alt"><span id="qk4e4ms" class="lnum"> 17: </span> sq_enabledebuginfo(v,SQTrue);</pre><pre><span id="4ieak4k" class="lnum"> 18: </span> </pre><pre class="alt"><span id="4s6iwka" class="lnum"> 19: </span> sq_setprintfunc(v,printfunc,errorfunc);</pre><pre><span id="yuwq2ow" class="lnum"> 20: </span> </pre><pre class="alt"><span id="2qgycao" class="lnum"> 21: </span> <span id="coiu4us" class="rem">//!! SUSPENDS THE APP UNTIL THE DEBUGGER CLIENT CONNECTS</span></pre><pre><span id="m244mkq" class="lnum"> 22: </span> <span id="4ci4c4e" class="kwrd">if</span>(SQ_SUCCEEDED(sq_rdbg_waitforconnections(rdbg))) {</pre><pre class="alt"><span id="uwiaw44" class="lnum"> 23: </span> scprintf(_SC(<span id="u4eicyw" class="str">"connected\n"</span>));</pre><pre><span id="4c4oqgc" class="lnum"> 24: </span> </pre><pre class="alt"><span id="ieei4yo" class="lnum"> 25: </span> <span id="eose2w4" class="kwrd">const</span> SQChar *fname=NULL;</pre><pre><span id="k44444e" class="lnum"> 26: </span>#ifdef _UNICODE</pre><pre class="alt"><span id="iuo244s" class="lnum"> 27: </span> SQChar sTemp[256];</pre><pre><span id="42cw6c4" class="lnum"> 28: </span> mbstowcs(sTemp,argv[1],(<span id="cga2ecs" class="kwrd">int</span>)strlen(argv[1])+1);</pre><pre class="alt"><span id="ey2e4ac" class="lnum"> 29: </span> fname=sTemp;</pre><pre><span id="2u2a4om" class="lnum"> 30: </span><span id="yameaw4" class="preproc">#else</span></pre><pre class="alt"><span id="4oe4yeu" class="lnum"> 31: </span> fname=argv[1];</pre><pre><span id="coiaw4k" class="lnum"> 32: </span><span id="s4m44qq" class="preproc">#endif</span> </pre><pre class="alt"><span id="y44iyw4" class="lnum"> 33: </span> <span id="ime4us2" class="rem">//!!REGISTERS STANDARDS LIBS</span></pre><pre><span id="mgs4oc4" class="lnum"> 34: </span> sq_pushroottable(v);</pre><pre class="alt"><span id="ic4y4ee" class="lnum"> 35: </span> sqstd_register_bloblib(v);</pre><pre><span id="e2gsk2o" class="lnum"> 36: </span> sqstd_register_iolib(v);</pre><pre class="alt"><span id="yacg44g" class="lnum"> 37: </span> <span id="c2wq4ws" class="rem">//!!EXECUTE A SCTIPT</span></pre><pre><span id="e2g444w" class="lnum"> 38: </span> <span id="4w4w44q" class="kwrd">if</span>(SQ_FAILED(sqstd_dofile(v,fname,SQFalse,SQTrue))) {</pre><pre class="alt"><span id="4k4sge4" class="lnum"> 39: </span> PrintError(v);</pre><pre><span id="e2yceku" class="lnum"> 40: </span> _getch();</pre><pre class="alt"><span id="4q2ymi6" class="lnum"> 41: </span> }</pre><pre><span id="22ea4e4" class="lnum"> 42: </span> }</pre><pre class="alt"><span id="e24yaga" class="lnum"> 43: </span> <span id="2ycws2u" class="rem">//!! CLEANUP</span></pre><pre><span id="424uo4y" class="lnum"> 44: </span> sq_rdbg_shutdown(rdbg);</pre><pre class="alt"><span id="o444mka" class="lnum"> 45: </span> }</pre><pre><span id="4qw4s4k" class="lnum"> 46: </span> <span id="emo4cyo" class="kwrd">else</span> {</pre><pre class="alt"><span id="4a44ocs" class="lnum"> 47: </span> PrintError(v);</pre><pre><span id="go24qoe" class="lnum"> 48: </span> }</pre><pre class="alt"><span id="22k66s4" class="lnum"> 49: </span> sq_close(v);</pre></div> <p>发现写这个库的老外q是很认真的,使用了sq_rdbg作ؓdebugger的api前缀,意味着q个库代码是可以复用?</p> <div id="as4oqgw" class="csharpcode">注意W?8?</div> <style type="text/css">.csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas, "Courier New", courier, monospace; background-color: #ffffff; /*white-space: pre;*/ } .csharpcode pre { margin: 0em; } .csharpcode .rem { color: #008000; } .csharpcode .kwrd { color: #0000ff; } .csharpcode .str { color: #006080; } .csharpcode .op { color: #0000c0; } .csharpcode .preproc { color: #cc6633; } .csharpcode .asp { background-color: #ffff00; } .csharpcode .html { color: #800000; } .csharpcode .attr { color: #ff0000; } .csharpcode .alt { background-color: #f4f4f4; width: 100%; margin: 0em; } .csharpcode .lnum { color: #606060; } </style> <p></p> <p></p> <p> sqstd_dofile(v,fname,SQFalse,SQTrue)</p> <p>q就是SQDBG只能debug 1个文件的原因.</p> <p>如果需要在目中做q程调试,只需要将q句代码换ؓ工程中加载所有脚本的代码和注册系lAPI代码卛_</p> <p> </p> <p>当然,最单的Ҏ,直接在代码顶端添加dofile引用另外的代码即?/p><img src ="http://www.shnenglu.com/sunicdavy/aggbug/146376.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/sunicdavy/" target="_blank">战魂筑</a> 2011-05-14 17:42 <a href="http://www.shnenglu.com/sunicdavy/archive/2011/05/14/146376.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>q的游戏脚本选择 Lua, Google V8, Mono?JavaScriptCorehttp://www.shnenglu.com/sunicdavy/archive/2011/05/14/146369.html战魂筑战魂筑Sat, 14 May 2011 07:13:00 GMThttp://www.shnenglu.com/sunicdavy/archive/2011/05/14/146369.htmlhttp://www.shnenglu.com/sunicdavy/comments/146369.htmlhttp://www.shnenglu.com/sunicdavy/archive/2011/05/14/146369.html#Feedback24http://www.shnenglu.com/sunicdavy/comments/commentRss/146369.htmlhttp://www.shnenglu.com/sunicdavy/services/trackbacks/146369.html最q正为游戏引擎选择一ƾ较好的逻辑脚本而头g?/p>

1. Lua

Lua用了5,6q的样子,从LuaPlus到lua-tinker再到lua_bind. 虽然lua本n很小巧方?但是其不支持面向对象Ҏ?让很多h在用时模拟了很多面向对象的Ҏ?但是q种做法在调试时直是噩梦.

我觉得游戏脚本最好是能预~译成byte code,让编译器在编译期很多的bug暴露出来,而不是像lua那样.很多I问错误必要{到runtime才能暴露.让调试效率大大降?q点,mono C#是极好的选择.

2. Mono

׃Unity的流?Mono被带入游戏开发者的视线?其内|的很多pȝ脚本都是用C#写成,而且逻辑脚本用C#~写也是非常清晰严}?

据说Mono在Windows下编译异帔R?而且嵌入方式也没有太多例?现在q块严重~Z资料.

3. V8

Google V8正是׃Chrome而风靡v?直接JIT方式是Chrome速度飞快的原?

最qdown了一个下来试了下,果然名不虚传,API也非常的易用.不过׃不是很熟悉JavaScript的原? 自己用scons~译Z个v8的shell,跑了一个带cȝ承的例子,居然不识别class关键?q才感叹q不如用y的lua?在我看来,JavaScript与Lua比较,也就是个能new,但是没class的语a.也被别hUCؓ半吊子面向对?都是使用prototype方式来实现类功能.

4. JavaScriptCore

在Google V8的类试壁?马上研究了下Unity下的JavaScript到底用了什么库,没错是Apple Safari里的JavaScriptCore. q东西资料比Monoq少,都是高龄库了.惛_整合不是一般的ȝ.但是q是不确定这个脚本引擎是否原生支持类

5. Python

Python? 没想q这U格式诡异的语言,正如Unity里支持Boo(一U很cMPython的语a)很少有h用一? 上次用过Python是在一个buildpȝ? 游戏里是不会考虑q种脚本pȝ?效率也是很大的原?

6. AngleScript, GameMonkey

q两U语a都是很老的游戏脚本语言,不过都是cc++方式?不过׃目使用不多,或许是有一定的bug,资料也相对较?所以可能最后考虑



战魂筑 2011-05-14 15:13 发表评论
]]>
Lua 5.2 work5 更新Q解x制{换问?/title><link>http://www.shnenglu.com/sunicdavy/archive/2010/11/14/133613.html</link><dc:creator>战魂筑</dc:creator><author>战魂筑</author><pubDate>Sun, 14 Nov 2010 14:07:00 GMT</pubDate><guid>http://www.shnenglu.com/sunicdavy/archive/2010/11/14/133613.html</guid><wfw:comment>http://www.shnenglu.com/sunicdavy/comments/133613.html</wfw:comment><comments>http://www.shnenglu.com/sunicdavy/archive/2010/11/14/133613.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.shnenglu.com/sunicdavy/comments/commentRss/133613.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/sunicdavy/services/trackbacks/133613.html</trackback:ping><description><![CDATA[<p>主要修改Q?/p> <p>更新了文档(q是必须的)</p> <p><strong>新的无符h数C API</strong></p> <p>位处理函数重命名</p> <p><strong>更好及更快的支持双精度QҎ转换为整?/strong></p> <p> </p> <p>原文<strong><a >在此</a></strong></p> <p> </p> <p>可以看到Q我在年初发文指出的lua数字处理斚w的bug已经得到很好的解冻I不过q种解决Ҏ只是d了api而已Q看来还是没有松鼠脚本处理的dQ原?a href="http://www.shnenglu.com/sunicdavy/archive/2010/02/04/107161.html"><strong>在此</strong></a></p><img src ="http://www.shnenglu.com/sunicdavy/aggbug/133613.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/sunicdavy/" target="_blank">战魂筑</a> 2010-11-14 22:07 <a href="http://www.shnenglu.com/sunicdavy/archive/2010/11/14/133613.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>设计D3D9 HLSL渲染脚本http://www.shnenglu.com/sunicdavy/archive/2010/02/15/107911.html战魂筑战魂筑Mon, 15 Feb 2010 15:18:00 GMThttp://www.shnenglu.com/sunicdavy/archive/2010/02/15/107911.htmlhttp://www.shnenglu.com/sunicdavy/comments/107911.htmlhttp://www.shnenglu.com/sunicdavy/archive/2010/02/15/107911.html#Feedback0http://www.shnenglu.com/sunicdavy/comments/commentRss/107911.htmlhttp://www.shnenglu.com/sunicdavy/services/trackbacks/107911.html最q翻出很早之前自己写的一套用Direct3D 9  Effectpȝ的纯shader 3d引擎Q打用最新技术重写。重写的主要修改在于Q?/p>

1. LEffectpȝQ改用HLSL + 渲染脚本

2. 优化渲染接口Q用材质统一shader和渲染状?/p>

随即参考了DirectX SDK的Graphics部分文档QDirectX9 时代的EffectpȝUa只是一个HLSL的简单渲染脚本实玎ͼ除了DXUTQFXComposer{极程序用这套东西外Q大型的引擎很少使用q种半成品系l。到了DirectX10甚至11Q因为架构更改,L固定线Q因此Effect成ؓ较ؓ高效和便L渲染脚本Q如果不是要求较高的3d引擎Q一般的游戏使用DirectX10的Effect渲染脚本q是很不错的?/p>

DX10的fx脚本与DX9的差异在?/p>

渲染状态,采样器状态等都变为对象,q与API高度l一

在脚本与API中均可以讄

DepthStencilState EnableDepth
{
    DepthEnable = TRUE;
    DepthWriteMask = ALL;
    DepthFunc = LESS_EQUAL;
};

BlendState NoBlending
{
    AlphaToCoverageEnable = FALSE;
    BlendEnable[0] = FALSE;
};

technique10 Render
{
    pass P0
    {

        SetDepthStencilState( EnableDepth, 0 );
        SetBlendState( NoBlending, float4( 0.0f, 0.0f, 0.0f, 0.0f ), 0xFFFFFFFF );
    }
}

本h觉得Q这L设计让图形API更ؓ敏捷与归cdQ另外,也便于StateManager或者自己做渲染状态{Ud差异比较时更为高?

 

Vista操作pȝ推出很久后,DX10的显卡也占有了大量的市场份额。但是由于DX10仍然是一个过渡APIQ类gDX8)Q因此,很多3D游戏要么仍然支持DX9Q要不然x持DX9也支持DX10Q甚至DX11.

   看博客上有达人组团编写类似DX10接口和系l的软渲染,DX10的设计是优秀的。因此,在DX9 HLSL基础上,l合自己~写的渲染脚本会是非常好的选择?

    渲染脚本我的设计思\是这LQ?

1. 只是一U预处理脚本Qƈ非实时运行脚本?

~译器将文本解析后,转化Z些运行指令,比如Q本pass使用一块小U理Q下一pass的target是这个纹理,q且开启哪些渲染状态?

2. 自定义格式的解析脚本?

使用luaQpython{脚本其实也是可以的。但是在出现错误Ӟ报出的错可能会让不熟悉这个脚本语a的h莫名其妙?

使用Nsq脚本语言Q可惜其在lua基础上,对table的slot初次赋值时必须使用<-而不是统一使用=Q因此会让你的脚本稀奇古?

XML脚本Q?XML可以避免复杂的语法检查,写完是归整的,但也是罗嗦的Q本来Texture[2]可以表达完毕的,非要<Texture index = 2/>来罗嗦下?

OGRE的compositor脚本和材质脚本就是自p析的Q不q出乎预料的使用了BNF范式q类较ؓ正规的方法。这是_需要先解析BNF表达式,然后再输入脚本解析,~写q程和系l复杂度会变得异常复杂?

最l选择q是使用自己解析的脚本,使用一些具体代码结构来替代BNFq类高深的东?

军_以后Q下一步需要制定渲染脚本具体各部分及制作过E?

1. 基本lexer

   从文本得到各Utoken

1. 渲染状态对?

   照着DX10抄就?

2. Shader导入?

     shader文g来自于何处,入口怎样定义

3. 渲染脚本VM及指?

  军_一个纹理怎样讄QRenderTarget怎样使用{的指o

战魂筑 2010-02-15 23:18 发表评论
]]>
LemonComposer 2D游戏动画开发工?/title><link>http://www.shnenglu.com/sunicdavy/archive/2010/02/05/107257.html</link><dc:creator>战魂筑</dc:creator><author>战魂筑</author><pubDate>Fri, 05 Feb 2010 06:58:00 GMT</pubDate><guid>http://www.shnenglu.com/sunicdavy/archive/2010/02/05/107257.html</guid><wfw:comment>http://www.shnenglu.com/sunicdavy/comments/107257.html</wfw:comment><comments>http://www.shnenglu.com/sunicdavy/archive/2010/02/05/107257.html#Feedback</comments><slash:comments>4</slash:comments><wfw:commentRss>http://www.shnenglu.com/sunicdavy/comments/commentRss/107257.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/sunicdavy/services/trackbacks/107257.html</trackback:ping><description><![CDATA[<p>Lemon是本人开发的一套适用?D游戏动画和高U游戏框架及配套~辑器(LemonComposerQ?/p> <blockquote> <p>LemonpȝҎ:</p> <p>1. 支持 Canvas,Sprite,ImageSetQ图片存储于一张图片,{大)</p> <p>2. ImageSetExQ自由摆攄囄帧于一张图片)*</p> <p>3. 支持对象无关键时用静态属性进行设|,cM于HGE里的_</p> <p>4. 每个对象均可成ؓContainerQƈ拥有Child Node</p> <p>5. 动画关键帧类型支持:~放Q旋转,位移Q颜Ԍ动画帧,锚点Q音?</p> <p>6. 支持拑֏</p> <p>7. ZXML存储的文件格?/p> <p>8. Z<a >Squirrel</a>N脚本的高速面向对象脚?</p> <p>9. 囑ŞpȝGraphics抽象Q适用于Q何渲染设?/p> <p>10. 控gpȝ*</p> <p>11. 视频回放*</p> <p>所有对象均由RTTI创徏Q枚丑֝有NamePool+HashQƈ׃PropertySet的反系l?/p> <p> </p></blockquote> <blockquote> <p>LemonComposer~辑器特?/p> <p>界面Z我去q开发的<a href="http://www.shnenglu.com/sunicdavy/archive/2009/07/24/91059.html">MotionUI</a>Qlua</p> <p>8+1控制点点对象调节属?/p> <p>cAdobe Flash的~辑?/p> <p>c?DS Max的分轨道关键帧编辑,有助于优化art assert</p> <p>自由调节对象层及父子关p?/p> <p>全功能无限制自由Redo,Undo</p> <p> </p></blockquote> <p>*在未来版本支持</p> <p><a href="http://www.shnenglu.com/images/cppblog_com/sunicdavy/WindowsLiveWriter/LemonComposer2D_D2B9/image_2.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.shnenglu.com/images/cppblog_com/sunicdavy/WindowsLiveWriter/LemonComposer2D_D2B9/image_thumb.png" width="483" height="300"></a> </p> <p> </p> <p> </p> <blockquote> <p>2D游戏是独立游戏的LQ也是创意,投入比最的一个维度。但是基?D的大多是一些类gHGEQIndieLib{开源免?D引擎。但是面Ҏ戏中大量的动画而言Q开发者大多是使用囄帧来制作Q虽然效果很好,但是讑֤资源好用和制作难度也是很难控制的?/p></blockquote> <blockquote> <p>行于去q的植物对僵和2004q发行的<a >RO Offline</a>l过资源分析Q就是用类gLemonpȝQ或者说Flash的系l制作而成Q因此效果和扩展性非常好?/p> <p>q就是Lemon存在的理由?/p> <p>Flash面向的是GDI+WebQ那么Lemon是针对游戏专有的,Zg加速的游戏框架</p> <p>Flash Action Script 对应的就是Lemon?a >Squirrel</a>脚本</p> <p>FlashIDE 对应的就是Lemon Composer</p> <p>Lemon的目标就是让2D游戏开发更单,让游戏中充满更多的动? 让游戏开发难度降?/p> <p><a href="http://www.shnenglu.com/images/cppblog_com/sunicdavy/WindowsLiveWriter/LemonComposer2D_D2B9/farming-gold-in-pvz%5B1%5D_2.jpg"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="farming-gold-in-pvz[1]" border="0" alt="farming-gold-in-pvz[1]" src="http://www.shnenglu.com/images/cppblog_com/sunicdavy/WindowsLiveWriter/LemonComposer2D_D2B9/farming-gold-in-pvz%5B1%5D_thumb.jpg" width="244" height="196"></a></p></blockquote><img src ="http://www.shnenglu.com/sunicdavy/aggbug/107257.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/sunicdavy/" target="_blank">战魂筑</a> 2010-02-05 14:58 <a href="http://www.shnenglu.com/sunicdavy/archive/2010/02/05/107257.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>批处理批量编译lua脚本http://www.shnenglu.com/sunicdavy/archive/2010/02/04/107187.html战魂筑战魂筑Thu, 04 Feb 2010 09:27:00 GMThttp://www.shnenglu.com/sunicdavy/archive/2010/02/04/107187.htmlhttp://www.shnenglu.com/sunicdavy/comments/107187.htmlhttp://www.shnenglu.com/sunicdavy/archive/2010/02/04/107187.html#Feedback0http://www.shnenglu.com/sunicdavy/comments/commentRss/107187.htmlhttp://www.shnenglu.com/sunicdavy/services/trackbacks/107187.htmlfor /r 路径 %%i in (匚w文g? do 指o

 

例子Q?/p>

for /r publish\ui\ %%i in (*.lua) do luac -o %%i %%i



战魂筑 2010-02-04 17:27 发表评论
]]>
Lua脚本点转整形bug分析http://www.shnenglu.com/sunicdavy/archive/2010/02/04/107161.html战魂筑战魂筑Thu, 04 Feb 2010 04:49:00 GMThttp://www.shnenglu.com/sunicdavy/archive/2010/02/04/107161.htmlhttp://www.shnenglu.com/sunicdavy/comments/107161.htmlhttp://www.shnenglu.com/sunicdavy/archive/2010/02/04/107161.html#Feedback9http://www.shnenglu.com/sunicdavy/comments/commentRss/107161.htmlhttp://www.shnenglu.com/sunicdavy/services/trackbacks/107161.html前面一?a href="http://www.shnenglu.com/sunicdavy/archive/2010/02/04/107155.html">文章中lua出现的bugQ其实是lua本nl构问题D的:

lua中,数g用double来存储,包含整Ş和double。而解析出来的整Ş也是被强转ؓdoubleq行存储Q这样就会出问题?/p>

举一个简单的例子Q?/p>

double f = (double)0xffffffff;
int a = int(f);

a肯定不是-1

q里的文章说明这个类型{换问题的~由?/p>

 

?a >Squirrel脚本中就不会有这个问?/p>

local a = 0xffffffff

print( a )

l果?1

查看其源代码Q?/p>

typedef union tagSQObjectValue
{
    struct SQTable *pTable;
    struct SQArray *pArray;
    struct SQClosure *pClosure;
    struct SQGenerator *pGenerator;
    struct SQNativeClosure *pNativeClosure;
    struct SQString *pString;
    struct SQUserData *pUserData;
    SQInteger nInteger;
    SQFloat fFloat;
    SQUserPointer pUserPointer;
    struct SQFunctionProto *pFunctionProto;
    struct SQRefCounted *pRefCounted;
    struct SQDelegable *pDelegable;
    struct SQVM *pThread;
    struct SQClass *pClass;
    struct SQInstance *pInstance;
    struct SQWeakRef *pWeakRef;
    SQRawObjectVal raw;
}SQObjectValue;

 

可以看到

SQInteger nInteger;
SQFloat fFloat;

是分开存储的,因此׃会有q个问题

 

lua解决ҎQ?/p>

1. 十六进制换?0q制存储

2. {待大侠或者官方修改代码,做出patch



战魂筑 2010-02-04 12:49 发表评论
]]>
Lua在Release版本下的一个bughttp://www.shnenglu.com/sunicdavy/archive/2010/02/04/107155.html战魂筑战魂筑Thu, 04 Feb 2010 02:59:00 GMThttp://www.shnenglu.com/sunicdavy/archive/2010/02/04/107155.htmlhttp://www.shnenglu.com/sunicdavy/comments/107155.htmlhttp://www.shnenglu.com/sunicdavy/archive/2010/02/04/107155.html#Feedback2http://www.shnenglu.com/sunicdavy/comments/commentRss/107155.htmlhttp://www.shnenglu.com/sunicdavy/services/trackbacks/107155.html最q将自己的UI工程在Release版下~译Q发现有部分控g的颜色居然偏黄,惛_液晶也不至于老化的那么厉宻I随机开始将工程加入调试信息q行跟踪Q排除UI工程Q及自己写的lua装问题Q将问题~小为:

lua代码Q?/p>

t = {}

t.FillColor = 0xFFFFFFFF

foo( t )

在C++中注册一个foo函数Q然后获取table t中的FillColor成员

发现取得的值居然ؓ0x80000000

 

使用lua c api试代码

lua_newtable( L );
lua_setglobal( L, "t");

lua_getglobal( L, "t");
lua_pushstring(L,"FillColor");
lua_pushinteger( L, 0xffffffff );
lua_pushinteger( L, -1 );
lua_settable( L, -3 );

lua_getglobal( L, "t");
lua_pushstring( L, "FillColor");
lua_gettable( L, -2 );
int t = lua_tointeger( L, -1 );

l果t也是0x80000000

 

然后十六进制的0xFFFFFFFF换成十进制的4294967295Q测试结果正显C?1

再用几个样本测?

0xFF5F5F5F = 4284440415 会被Ҏ0xFF5F5F00

 

q个bug倒是很好解决Q将代码中的十六q制数全换ؓ10q制卛_。但是ؓ什么只在Release版本发生呢?

本h使用的是lua 5.1.4 原生



战魂筑 2010-02-04 10:59 发表评论
]]>
为游戏系l选择一个接口方?/title><link>http://www.shnenglu.com/sunicdavy/archive/2009/12/31/104543.html</link><dc:creator>战魂筑</dc:creator><author>战魂筑</author><pubDate>Thu, 31 Dec 2009 03:42:00 GMT</pubDate><guid>http://www.shnenglu.com/sunicdavy/archive/2009/12/31/104543.html</guid><wfw:comment>http://www.shnenglu.com/sunicdavy/comments/104543.html</wfw:comment><comments>http://www.shnenglu.com/sunicdavy/archive/2009/12/31/104543.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.shnenglu.com/sunicdavy/comments/commentRss/104543.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/sunicdavy/services/trackbacks/104543.html</trackback:ping><description><![CDATA[<p>     准备q2D游戏动画pȝ选择一套给外部使用的接口方式,有如下几U选择Q?/p> <p> </p> <p>1. UC API方式导出Q类gWindows API方式</p> <p>优点Q简z,可以供C/C#乃至其他可以导入C DLL的语a使用</p> <p>~点QC++的系l{化ؓC会遇到很多性能以及架构的折损,对于对象控制cd能导出比较多的系l,q种方式直是噩梦</p> <p> </p> <p>2. C++方式导出Q宏方式实现RTTI以及C++反射pȝ</p> <p>优点Q强大,易用?/p> <p>~点Q对象生命周期不Ҏ控制Q反系l设计比较费Ӟ可能暴露很多cȝl节Q只能给C++使用</p> <p> </p> <p>3. COM方式Q类DirectX的接口方?/p> <p>优点Q商业项目已l证明这U接口方式的强大地方。无论是多个对象的类功能导出Q还是COM接口重蝲都非常方ѝ而且Q可以极为容易的?NET讉K。XBOX SDK里的XUI是采用q种方式Q而且q设计了一套C API搭配的强大C++反射pȝQ支持动态类创徏QRTTIQ动态类型{换等{?/p> <p>~点Q需要系l注册,不能跨^台。COM标准学习h需要时?/p> <p> </p> <p>4. 脚本l定</p> <p>优点Q保持你的系l对外C/C++接口的干净Q简z。通过脚本cȝ定,可以很快的将C++功能注册到脚本中?/p> <p>~点Q脚本如果没有调试器Q将会让开发中到的棘手问题,甚至于在后期l护pȝ以及pȝ架构大变动变得异常复杂。脚本的性能军_了不能让其做实时处理Q例如:渲染</p> <p> </p> <p> 最l选择下来Q由于有自己的界面系lMotion使用lua的函数绑定的前例Q因此还是决定选择一ƾ脚本语a来做pȝ的对外接口,q里有几个选择Q?/p> <p>1. Lua</p> <p>  可以说最好的游戏pȝ脚本语言。稳定,高效Qbug几乎没有Q即便有Q普通开发者也是很隑֯觉的Q。配上LuaPlus的强大C++l定pȝQ你的系l开发效率可以提高很多。这里推荐notepad++来做lua开发,E微配置下,弹出提示l你感觉在用Visual StudioQ:Q?/p> <p>   同时需要指出的是,lua的类功能实比较弱。虽然可以用metatable方式来模拟。但D跟native class支持q差很远Q实际开发中Q你能体会出class中的权限控制QprivateQprotectedQ有多么重要?/p> <p>2. Python</p> <p>   诚然Q这是个最OO的脚本。但是对于游戏,它太慢了。虽然本人只是用python写过一些buildpȝQ但从很多朋友反应的情况来看QPython嵌入游戏pȝQ确实太慢。用Stackless PythonQ?用第三方开源品,q是认准品牌Q呵呵,q里如果有用q的同学Q欢q提供感受?/p> <p>3. C#</p> <p>   语言和系l都很美Q但是想嵌入游戏Q还是很痛的?netq_可惜在于,到现在ؓ止,可能q不是所有机器默认安装有.netq_。如果你的游戏是C++写成Q但却要安装.net以便你的脚本能运行,q很奇怪吧Q所以,如果要用C#Q还不如不用脚本Q全?net好了。Managed DXQ?那东西几q前pMS打入冷宫了。XNAQ?那东西只是一个玩P别摸?/p> <p>4.<a >Squirrel</a>N脚本</p> <p>   q是个好东西。类lua的语法,C/C++/Java的语al构Q纯正的native class外加OO支持。拥有开源的C++cȝ定系l。最爽的是,<a >SQDEV</a>支持日食QEclipseQ下的远E调试,开发环境还支持动态语法检查。oh,my god。还说不定哪天这脚本被MS招安Q跟IronPython一样弄?netl定?/p> <p> </p> <p><img src="http://wiki.squirrel-lang.org/myimages/debugger.png" width="568" height="451"></p><img src ="http://www.shnenglu.com/sunicdavy/aggbug/104543.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/sunicdavy/" target="_blank">战魂筑</a> 2009-12-31 11:42 <a href="http://www.shnenglu.com/sunicdavy/archive/2009/12/31/104543.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>虚引擎中的Kismet虚拟游戏逻辑~辑器资?/title><link>http://www.shnenglu.com/sunicdavy/archive/2009/12/18/103480.html</link><dc:creator>战魂筑</dc:creator><author>战魂筑</author><pubDate>Fri, 18 Dec 2009 09:42:00 GMT</pubDate><guid>http://www.shnenglu.com/sunicdavy/archive/2009/12/18/103480.html</guid><wfw:comment>http://www.shnenglu.com/sunicdavy/comments/103480.html</wfw:comment><comments>http://www.shnenglu.com/sunicdavy/archive/2009/12/18/103480.html#Feedback</comments><slash:comments>2</slash:comments><wfw:commentRss>http://www.shnenglu.com/sunicdavy/comments/commentRss/103480.html</wfw:commentRss><trackback:ping>http://www.shnenglu.com/sunicdavy/services/trackbacks/103480.html</trackback:ping><description><![CDATA[<p>虚中有一套专门用于策划用的逻辑开发工PKismetQ号U无需~程可以完成大部分的逻辑。最q正好在研究q方面的技术,所以找C一些资?/p> <p> </p> <p>q是一个简单的教学Q告诉你Kismet是怎么q行?/p> <p><a >http://udn.epicgames.com/Three/KismetUserGuide.html</a></p> <p> </p> <p>q是Kismet的资?/p> <p><a >http://udn.epicgames.com/Three/KismetReference.html</a></p> <p> </p> <p>让我们来熟悉?/p> <p><img alt="event.jpg" src="http://udn.epicgames.com/Three/rsrc/Three/KismetUserGuide/event.jpg">q是一个Event节点Q一般用于创入流Q事件可以从Actor或者其他地方进?/p> <p> </p> <p><img alt="action.jpg" src="http://udn.epicgames.com/Three/rsrc/Three/KismetUserGuide/action.jpg">q是一个Action节点Q动态的搭接输入条gQ可以快速的输出你需要的l果</p> <p> </p> <p><img alt="condition.jpg" src="http://udn.epicgames.com/Three/rsrc/Three/KismetUserGuide/condition.jpg">q是一个Condition节点Q用于根据输入,输出l果</p> <p> </p> <p><img alt="variable.jpg" src="http://udn.epicgames.com/Three/rsrc/Three/KismetUserGuide/variable.jpg">q是一个普通的变量Q存储Q何可以存储的对象</p> <p> </p> <p>W一个例子:</p> <p><img alt="simple_sequence.jpg" src="http://udn.epicgames.com/Three/rsrc/Three/KismetUserGuide/simple_sequence.jpg"></p> <p>q个例子要实现的是,玩家点击后,打开一盏灯</p> <p>玩家通过Event节点Q生一个输入流Q这个流被连接到ToggerQActionQ的Turn On节点Q注意,黑色的连接线表示“操作流”,而Togger的执行目标被接到了灯上,q样一个简单的逻辑执行出来了</p> <p> </p> <p>动态绑定事?/p> <p><img alt="attach_event.jpg" src="http://udn.epicgames.com/Three/rsrc/Three/KismetUserGuide/attach_event.jpg"></p> <p> </p> <p></p> <p></p> <p></p> <p></p> <p></p> <p>有时你需要绑定的对象是不在编辑器里的Q这个例子就是在游戏中动态创Z个ActorQ要解决q个问题Q就必须物体连接到一个变量?/p> <p>当Actor Factory执行后,其生成一个新的ActorQƈ其攄在一个对象数l中Q图中的问号Q,然后Q他会调用AttachToEvent actionQ将M事gq接到这个变量?那么当这个ActorMӞ事g׃被触发?/p> <p> </p> <p>先讲q些Q呵呵,吃饭吃饭</p><img src ="http://www.shnenglu.com/sunicdavy/aggbug/103480.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.shnenglu.com/sunicdavy/" target="_blank">战魂筑</a> 2009-12-18 17:42 <a href="http://www.shnenglu.com/sunicdavy/archive/2009/12/18/103480.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss> <footer> <div class="friendship-link"> <p>лǵվܻԴȤ</p> <a href="http://www.shnenglu.com/" title="精品视频久久久久">精品视频久久久久</a> <div class="friend-links"> </div> </div> </footer> <a href="http://www.hbqw.net.cn" target="_blank">þþۺϾɫۺ98</a>| <a href="http://www.u33g.cn" target="_blank">þþþAVۿ</a>| <a href="http://www.bethesdagroup.cn" target="_blank">þùֱ</a>| <a href="http://www.51peini.cn" target="_blank">þþƷһapp</a>| <a href="http://www.maichayo.cn" target="_blank">91鶹Ʒ91þþþþ</a>| <a href="http://www.fjhby.cn" target="_blank">þþƷһ</a>| <a href="http://www.huanshengdou.org.cn" target="_blank">һþaþþƷ</a>| <a href="http://www.hanxuefs.com.cn" target="_blank">һaƬþëƬ </a>| <a href="http://www.jkmdz.cn" target="_blank">97þþƷҹһ</a>| <a href="http://www.jzbbbs.cn" target="_blank">þ99žŹѿС˵</a>| <a href="http://www.tvue.cn" target="_blank">ŷþ޾Ʒ</a>| <a href="http://www.tdpqb.cn" target="_blank">þۺϹɫ88þþƷۺ</a>| <a href="http://www.jingxi.jx.cn" target="_blank">þeֻйľƷ99</a>| <a href="http://www.eiszar86.cn" target="_blank">ȾþùƷ</a>| <a href="http://www.o33k.cn" target="_blank">þ˳ƷCAOPOREN</a>| <a href="http://www.liuyunying.cn" target="_blank">ҹƷþþþ9999</a>| <a href="http://www.uushipin.cn" target="_blank">˺ݺۺϾþ</a>| <a href="http://www.mabcrea.cn" target="_blank">þ99Ʒ鶹լլ</a>| <a href="http://www.mx3g.cn" target="_blank">þþþAVƬ</a>| <a href="http://www.91zuoai.cn" target="_blank">ԭۺϾþô˾Ʒ</a>| <a href="http://www.guoweipi.cn" target="_blank">ƷŮþAV</a>| <a href="http://www.0838auto.cn" target="_blank">þ99Ʒþþþþ9</a>| <a href="http://www.t2tt.cn" target="_blank">޾Ʒþþwww</a>| <a href="http://www.hf169.cn" target="_blank">97Ʒ˾þþô߽97</a>| <a href="http://www.www008tt.cn" target="_blank">þþƷAVũ帾Ů </a>| <a href="http://www.pudlv.cn" target="_blank">޹Ʒþþž</a>| <a href="http://www.qzxqd.cn" target="_blank">þþAVҰ</a>| <a href="http://www.710p.cn" target="_blank">97þþƷһ</a>| <a href="http://www.west-data.cn" target="_blank"> ŷ þ</a>| <a href="http://www.3secshop.cn" target="_blank">ɫþùƷ12p </a>| <a href="http://www.kingvit.com.cn" target="_blank">ݾƷŮ˾þþþþ</a>| <a href="http://www.bekin.com.cn" target="_blank">Ƭѹۿþ</a>| <a href="http://www.88981.com.cn" target="_blank">þþƷ99þ㽶ɫ</a>| <a href="http://www.spbbs.cn" target="_blank">99þþùƷţ</a>| <a href="http://www.apramomall.cn" target="_blank">ŷþþþƷӰԺ</a>| <a href="http://www.pyspiderking.cn" target="_blank">Ʒþþþþר</a>| <a href="http://www.034867.cn" target="_blank">ŷԴսþþþþ</a>| <a href="http://www.2jg.com.cn" target="_blank">þþƷ99þ޶</a>| <a href="http://www.travain.cn" target="_blank">þþƷA㽶</a>| <a href="http://www.s6893.cn" target="_blank">鶹AV뾫Ʒþ</a>| <a href="http://www.mg7701.cn" target="_blank">Ʒþþþһ</a>| <script> (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })(); </script> </body>