SweetDream
高歌一壶新酿酒,醉抱青山不必归。
1.new tbClass{}, Binding "FunName" to C function "thunk" and set it's closure with upvalue;
2.rigister metatable "Class", and set metatable __index to table"tbClass"
3.new pObj, new userdata to point it, and set this userdata's metatable then push it into stack.
4.call Obj:FunName()
5.because Obj associate tbClass by metatable, so will call tbClass[FunName], then call thunk, remember thunk have upvalue.
6.when we have userdata whitch have pObj,and have upvalue,then CallFun



1.new tbClass{},Encapsulation all Class Memeber as KLuaData. tbClass[FunName] = KLuaData.KLuaData push as userdata.
2.rigister metatable "Class", and set metatable __index to C Function "_LuaIndex"
3.push userdata who's restore pObj, and set metatable
4.Call a.FunName()
5.Call C Function _LuaIndex,in this can get pObj and KLuaData,switch kind of KLuaData,execute diff Op.
6.if KLuaData is FunData, then push pObj,and FunData, and CFun "_LuaDispatcher",then () will Call this Fun
7.CallFun

posted on 2008-10-15 15:01  SweetDream  阅读(627)  评论(0编辑  收藏  举报