Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit48476b1

Browse files
committed
update
1 parent2205630 commit48476b1

File tree

3 files changed

+8
-126
lines changed

3 files changed

+8
-126
lines changed

‎Assets/Plugins/Slua_Managed/LuaObject.cs‎

Lines changed: 4 additions & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -116,11 +116,12 @@ public partial class LuaObject
116116
publicstaticvoidinit(IntPtrl)
117117
{
118118
/// <summary>
119-
/// ud is a table, may be a static table or an instance table
119+
/// NOTE: all public field is added to instance table with getter/setter
120+
/// userdata and self table all do not exit any key, so everytime key assignment, the __newindex function is called
120121
/// h[1],h[2] is get and set function, see function AddMember
121122
/// 獲取當前ud 的元表,從元表中獲取k所對應的值,如果沒有,則去__parent中去找(set in function createTypeMetatable())
122123
///如果有,h[2]應該是一個Set函數
123-
/// ///</summary>
124+
///</summary>
124125
/// <returns></returns>
125126
stringnewindexfun=@"
126127
@@ -149,8 +150,7 @@ local function newindex(ud,k,v)
149150
";
150151

151152
/// <summary>
152-
/// ud is a table, may be a static table or an instance table
153-
/// analogy with newindex, if value is a function, return it, if value is a table, this table contains get/set function
153+
/// userdata and self table all do not exit any key, so everytime access key, the __index function is called
154154
/// </summary>
155155
/// <returns></returns>
156156
stringindexfun=@"
@@ -267,115 +267,6 @@ static public int GetType(IntPtr l)
267267
}
268268
#endregion
269269

270-
staticvoidsetupPushVar()
271-
{
272-
typePushMap[typeof(float)]=(IntPtrL,objecto)=>
273-
{
274-
LuaDLL.lua_pushnumber(L,(float)o);
275-
};
276-
typePushMap[typeof(double)]=(IntPtrL,objecto)=>
277-
{
278-
LuaDLL.lua_pushnumber(L,(double)o);
279-
};
280-
281-
typePushMap[typeof(int)]=
282-
(IntPtrL,objecto)=>
283-
{
284-
LuaDLL.lua_pushinteger(L,(int)o);
285-
};
286-
287-
typePushMap[typeof(uint)]=
288-
(IntPtrL,objecto)=>
289-
{
290-
LuaDLL.lua_pushnumber(L,Convert.ToUInt32(o));
291-
};
292-
293-
typePushMap[typeof(short)]=
294-
(IntPtrL,objecto)=>
295-
{
296-
LuaDLL.lua_pushinteger(L,(short)o);
297-
};
298-
299-
typePushMap[typeof(ushort)]=
300-
(IntPtrL,objecto)=>
301-
{
302-
LuaDLL.lua_pushinteger(L,(ushort)o);
303-
};
304-
305-
typePushMap[typeof(sbyte)]=
306-
(IntPtrL,objecto)=>
307-
{
308-
LuaDLL.lua_pushinteger(L,(sbyte)o);
309-
};
310-
311-
typePushMap[typeof(byte)]=
312-
(IntPtrL,objecto)=>
313-
{
314-
LuaDLL.lua_pushinteger(L,(byte)o);
315-
};
316-
317-
318-
typePushMap[typeof(Int64)]=
319-
typePushMap[typeof(UInt64)]=
320-
(IntPtrL,objecto)=>
321-
{
322-
#ifLUA_5_3
323-
LuaDLL.lua_pushinteger(L,(long)o);
324-
#else
325-
LuaDLL.lua_pushnumber(L,System.Convert.ToDouble(o));
326-
#endif
327-
};
328-
329-
typePushMap[typeof(string)]=(IntPtrL,objecto)=>
330-
{
331-
LuaDLL.lua_pushstring(L,(string)o);
332-
};
333-
334-
typePushMap[typeof(bool)]=(IntPtrL,objecto)=>
335-
{
336-
LuaDLL.lua_pushboolean(L,(bool)o);
337-
};
338-
339-
typePushMap[typeof(LuaTable)]=
340-
typePushMap[typeof(LuaFunction)]=
341-
typePushMap[typeof(LuaThread)]=
342-
(IntPtrL,objecto)=>
343-
{
344-
((LuaVar)o).push(L);
345-
};
346-
#if!SLUA_STANDALONE
347-
typePushMap[typeof(Vector3)]=(IntPtrL,objecto)=>
348-
{
349-
pushValue(L,(Vector3)o);
350-
};
351-
352-
typePushMap[typeof(Vector2)]=(IntPtrL,objecto)=>
353-
{
354-
pushValue(L,(Vector2)o);
355-
};
356-
357-
typePushMap[typeof(Vector4)]=(IntPtrL,objecto)=>
358-
{
359-
pushValue(L,(Vector4)o);
360-
};
361-
362-
typePushMap[typeof(Quaternion)]=(IntPtrL,objecto)=>
363-
{
364-
pushValue(L,(Quaternion)o);
365-
};
366-
367-
typePushMap[typeof(Color)]=(IntPtrL,objecto)=>
368-
{
369-
pushValue(L,(Color)o);
370-
};
371-
#endif
372-
373-
typePushMap[typeof(LuaCSFunction)]=(IntPtrL,objecto)=>
374-
{
375-
pushValue(L,(LuaCSFunction)o);
376-
};
377-
}
378-
379270
staticintgetOpFunction(IntPtrl,stringf,stringtip)
380271
{
381272
interr=pushTry(l);
@@ -687,7 +578,6 @@ static void completeTypeMeta(IntPtr l, LuaCSFunction con, Type self)
687578
LuaDLL.lua_setfield(l,-3,"__fullname");
688579

689580
//下面两个metamethod 控制了字段的赋值和获取值的方式, see init function
690-
//TODO: 重点,这两个函数怎么工作的?
691581
index_func.push(l);
692582
LuaDLL.lua_setfield(l,-2,"__index");
693583

‎Assets/Plugins/Slua_Managed/LuaState.cs‎

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ abstract public class LuaVar : IDisposable
3737
{
3838
protectedLuaStatestate=null;
3939
/// <summary>
40-
/// 對於thread, function 等, 這個是在註冊表中的引用
40+
/// 對於thread, function, table 等, 這個是在註冊表中的引用
4141
/// TODO: 爲啥要這樣做?
4242
/// </summary>
4343
protectedintvalueref=0;
@@ -562,7 +562,6 @@ public IntPtr handle
562562
/// 默认是从Resources目录加载的,如果是通过动态下载AssetBundle,需要自己实现
563563
/// /// </summary>
564564
staticpublicLoaderDelegateloaderDelegate;
565-
staticpublicLoaderDelegateloaderDelegate;
566565
staticpublicOutputDelegatelogDelegate;
567566
staticpublicOutputDelegateerrorDelegate;
568567

@@ -583,7 +582,6 @@ struct UnrefPair
583582
Dictionary<Type,PushVarDelegate>typePushMap=newDictionary<Type,PushVarDelegate>();
584583

585584

586-
publicstaticLuaStatemain;
587585
//Global map, store all LuaState, map IntPtr 2 LuaState(c# class)
588586
publicstaticLuaStatemain;
589587
staticDictionary<IntPtr,LuaState>statemap=newDictionary<IntPtr,LuaState>();
@@ -990,6 +988,7 @@ internal static int printerror(IntPtr L)
990988
intn=LuaDLL.lua_gettop(L);
991989
s.Length=0;
992990

991+
//get lua function tostring
993992
LuaDLL.lua_getglobal(L,"tostring");
994993

995994
for(inti=1;i<=n;i++)
@@ -1185,8 +1184,6 @@ public bool doBuffer(byte[] bytes, string fn, out object ret)
11851184
LuaDLL.lua_pop(L,2);
11861185
returnfalse;
11871186
}
1188-
//TODO: pcall 調用的是一個luaCSFunction, 這個函數的返回值表示壓入棧上的結果數目 ??第一個值 true/false 是怎麼檢測的?
1189-
// 爲啥會少一個值 ??
11901187
LuaDLL.lua_remove(L,errfunc);// pop error function
11911188
ret=topObjects(errfunc-1);
11921189
returntrue;
@@ -1197,12 +1194,6 @@ public bool doBuffer(byte[] bytes, string fn, out object ret)
11971194
thrownewException(err);
11981195
}
11991196

1200-
/// <summary>
1201-
/// TODO:, loader 在 lua 中的使用 ???
1202-
/// require 机制
1203-
/// </summary>
1204-
/// <param name="fn"></param>
1205-
/// <returns></returns>
12061197
internalstaticbyte[]loadFile(stringfn)
12071198
{
12081199
try{
@@ -1297,6 +1288,7 @@ internal object getObject(int reference, int index)
12971288
}else{
12981289
LuaDLL.lua_getref(L,reference);
12991290
LuaDLL.lua_pushinteger(L,index);
1291+
//TODO: 为啥这里不用rawgeti ?
13001292
LuaDLL.lua_gettable(L,-2);
13011293
objectreturnValue=getObject(L,-1);
13021294
LuaDLL.lua_pop(L,2);
@@ -1340,6 +1332,7 @@ internal void setObject(int reference, string field, object o)
13401332

13411333
/// <summary>
13421334
/// TODO: 這裏設置table字段的時候,lua_rawseti 和 lua_settable 是如何抉擇的?
1335+
/// NOTE: when o is gc collectable, only get the ud(cache index)
13431336
/// </summary>
13441337
/// <param name="reference"></param>
13451338
/// <param name="index"></param>

‎Assets/Plugins/Slua_Managed/LuaVarObject.cs‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,6 @@ static public int methodWrapper(IntPtr l)
569569
/// 创建一个LucCSFunction对象,放入注册表中
570570
/// 这两个对象都有自己的元方法
571571
/// NOTE: __gc only works in the metatable of userdatum
572-
/// TODO: where is this used ??
573572
/// </summary>
574573
/// <param name="l"></param>
575574
staticnewpublicvoidinit(IntPtrl)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp