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

Commitff25a23

Browse files
committed
日了狗了,vscode自带的git怎么只提交了新增文件的变动,没有提交更改文件的变动
1 parent5501833 commitff25a23

File tree

4 files changed

+15
-18
lines changed

4 files changed

+15
-18
lines changed

‎Assets/Plugins/Slua_Managed/LuaObject.cs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,7 @@ public static void createTypeMetatable(IntPtr l, LuaCSFunction constractor, Type
557557
completeInstanceMeta(l,self);
558558
completeTypeMeta(l,constractor,self);
559559

560-
LuaDLL.lua_pop(l,1);// pop type Table(static table)
560+
LuaDLL.lua_pop(l,1);// pop type Table(self table)
561561
}
562562

563563
/// <summary>
@@ -597,7 +597,7 @@ static void completeTypeMeta(IntPtr l, LuaCSFunction con, Type self)
597597
LuaDLL.lua_pushcfunction(l,typeToString);
598598
LuaDLL.lua_setfield(l,-2,"__tostring");
599599

600-
//set self's metatableas the static table,
600+
//set self's metatableto the static table,
601601
//the static table has __index/__newindex/__call/__tostring metamethod
602602
LuaDLL.lua_pushvalue(l,-1);
603603
LuaDLL.lua_setmetatable(l,-3);

‎Assets/Plugins/Slua_Managed/LuaState.cs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,8 +254,9 @@ public object call()
254254
}
255255

256256
/// <summary>
257-
/// TODO: 这里传入的c#类型的参数是怎么回收的??
258257
/// if the argument is a LuaTable ?? how to release the talbe ?
258+
/// NOTE: 这里传入的c#类型的参数是怎么回收的??
259+
/// 如果push上去的是一个C#object,那么会push一个userData,这个userData会有metatable,metatable有__gc 方法,在lua回收栈上面的数据的时候,gc会触发
259260
/// </summary>
260261
/// <param name="args"></param>
261262
/// <returns></returns>

‎Assets/Plugins/Slua_Managed/LuaVarObject.cs‎

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,9 @@ class LuaVarObject : LuaObject
4040
/// </summary>
4141
staticDictionary<Type,Dictionary<string,List<MemberInfo>>>cachedMemberInfos=newDictionary<Type,Dictionary<string,List<MemberInfo>>>();
4242

43+
/// <summary>
44+
/// Wrap a list a methodinfo, when invoked, try to find the best matched one, if not find, use the first one instead
45+
/// </summary>
4346
classMethodWrapper
4447
{
4548
objectself;
@@ -158,7 +161,8 @@ public int invoke(IntPtr l)
158161
for(intk=0;k<mis.Count;k++)
159162
{
160163
MethodInfom=(MethodInfo)mis[k];
161-
//TODO , why start from 2 ??
164+
//NOTE: , why start from 2 ??
165+
//because the first argument in function call is self
162166
if(matchType(l,2,m.GetParameters(),m.IsStatic))
163167
{
164168
returnforceInvoke(l,m);
@@ -193,6 +197,7 @@ private int forceInvoke(IntPtr l, MethodInfo m)
193197
++ct;
194198
}
195199
}
200+
//return status code + result
196201
returnct;
197202
}
198203
return1;
@@ -220,7 +225,7 @@ public void checkArgs(IntPtr l, int from, MethodInfo m, out object[] args)
220225
/// 這個類用於在沒有導出lua接口的時候使用,效率不好,因爲使用了反射
221226
/// 當使用一個String來訪問時,可以訪問是一個Dictionary<string,T>, 或者是對象的方法,屬性,字段
222227
/// Note:這個函數假定table在stack的1位置,key在2位置
223-
/// Note:不能访问没有导出的父类的成员、属性、字段等
228+
/// Note:不能访问没有导出的父类的成员、属性、字段等
224229
/// 如果父类没有导入,那么父类就默认是__luabaseobject, ref createTypeMetatable()
225230
/// NOTE: 导出List<int> 后,就不能用下表来访问了,必须要用GetItem函数,
226231
/// 因为只有在导出Array类型的类时才有下表访问, ref LuaArray
@@ -273,14 +278,6 @@ static Type getType(object o)
273278
returno.GetType();
274279
}
275280

276-
/// <summary>
277-
/// 根据self的类型来获取key所对应的值
278-
/// 支持方法、属性、字段, 不支持Event
279-
/// /// </summary>
280-
/// <param name="l"></param>
281-
/// <param name="self"></param>
282-
/// <param name="key"></param>
283-
/// <returns>TODO,返回值表示向棧上壓入元素的個數,在哪裏使用這個信息呢?</returns>
284281
staticintindexString(IntPtrl,objectself,stringkey)
285282
{
286283
Typet=getType(self);
@@ -308,9 +305,9 @@ static int indexString(IntPtr l, object self, string key)
308305
returnerror(l,"Can't find "+key);
309306
}
310307

311-
//TODO, 为啥多push一个true?
312308
pushValue(l,true);
313309
MemberInfomi=mis[0];
310+
//NOTE: get instance or static Property/filed/method
314311
switch(mi.MemberType)
315312
{
316313
caseMemberTypes.Property:
@@ -587,7 +584,7 @@ static public int methodWrapper(IntPtr l)
587584
}
588585

589586
/// <summary>
590-
/// TODO: why wrap the Type class ?
587+
/// TODO: why wrap the Type class ? ref GetType()
591588
/// </summary>
592589
classLuaClassObject
593590
{

‎build/slua.c‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -460,7 +460,7 @@ LUA_API int luaS_pushobject(lua_State *l, int index, const char* t, int gco, int
460460
if (gco)cacheud(l,index,cref);
461461

462462

463-
//get the metatable associated with obj's QAName, which is set when create the represent table of the C# class in instance table
463+
//NOTE:get the metatable associated with obj's QAName, which is set when create the represent table of the C# class in instance table
464464
//the metatable is the instance table
465465
luaL_getmetatable(l,t);
466466
if (lua_isnil(l,-1))
@@ -474,8 +474,7 @@ LUA_API int luaS_pushobject(lua_State *l, int index, const char* t, int gco, int
474474

475475
//step 2
476476
//set the metatable of userdata
477-
//TODO: why do this?
478-
//set instance table as the metatable, so it can call methods, TODO: how?
477+
//set instance table as the metatable, so it can call methods. the metatable has __index/ __newindex metamethods
479478
lua_setmetatable(l,-2);
480479
returnis_reflect;
481480
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp