@@ -232,21 +232,9 @@ static int Exists(IntPtr L)
232232 try
233233 {
234234 ToLua . CheckArgsCount ( L , 2 ) ;
235- Type argType = null ;
236- Delegate arg0 = null ;
237- object obj = ToLua . CheckGenericObject ( L , 1 , typeof ( List < > ) , out argType ) ;
238- LuaTypes funcType2 = LuaDLL . lua_type ( L , 2 ) ;
239-
240- if ( funcType2 != LuaTypes . LUA_TFUNCTION )
241- {
242- arg0 = ( Delegate ) ToLua . CheckObject ( L , 2 , typeof ( System . Predicate < > ) . MakeGenericType ( argType ) ) ;
243- }
244- else
245- {
246- LuaFunction func = ToLua . ToLuaFunction ( L , 2 ) ;
247- arg0 = DelegateFactory . CreateDelegate ( typeof ( System . Predicate < > ) . MakeGenericType ( argType ) , func ) ;
248- }
249-
235+ Type argType = null ;
236+ object obj = ToLua . CheckGenericObject ( L , 1 , typeof ( List < > ) , out argType ) ;
237+ Delegate arg0 = ToLua . CheckDelegate ( typeof ( System . Predicate < > ) . MakeGenericType ( argType ) , L , 2 ) ;
250238 bool o = ( bool ) LuaMethodCache . CallMethod ( "Exists" , obj , arg0 ) ;
251239 LuaDLL . lua_pushboolean ( L , o ) ;
252240 return 1 ;
@@ -263,21 +251,9 @@ static int Find(IntPtr L)
263251 try
264252 {
265253 ToLua . CheckArgsCount ( L , 2 ) ;
266- Type argType = null ;
267- Delegate arg0 = null ;
268- object obj = ToLua . CheckGenericObject ( L , 1 , typeof ( List < > ) , out argType ) ;
269- LuaTypes funcType2 = LuaDLL . lua_type ( L , 2 ) ;
270-
271- if ( funcType2 != LuaTypes . LUA_TFUNCTION )
272- {
273- arg0 = ( Delegate ) ToLua . CheckObject ( L , 2 , typeof ( System . Predicate < > ) . MakeGenericType ( argType ) ) ;
274- }
275- else
276- {
277- LuaFunction func = ToLua . ToLuaFunction ( L , 2 ) ;
278- arg0 = DelegateFactory . CreateDelegate ( typeof ( System . Predicate < > ) . MakeGenericType ( argType ) , func ) ;
279- }
280-
254+ Type argType = null ;
255+ object obj = ToLua . CheckGenericObject ( L , 1 , typeof ( List < > ) , out argType ) ;
256+ Delegate arg0 = ToLua . CheckDelegate ( typeof ( System . Predicate < > ) . MakeGenericType ( argType ) , L , 2 ) ;
281257 object o = LuaMethodCache . CallMethod ( "Find" , obj , arg0 ) ;
282258 ToLua . Push ( L , o ) ;
283259 return 1 ;
@@ -294,21 +270,9 @@ static int FindAll(IntPtr L)
294270 try
295271 {
296272 ToLua . CheckArgsCount ( L , 2 ) ;
297- Type argType = null ;
298- Delegate arg0 = null ;
273+ Type argType = null ;
299274 object obj = ToLua . CheckGenericObject ( L , 1 , typeof ( List < > ) , out argType ) ;
300- LuaTypes funcType2 = LuaDLL . lua_type ( L , 2 ) ;
301-
302- if ( funcType2 != LuaTypes . LUA_TFUNCTION )
303- {
304- arg0 = ( Delegate ) ToLua . CheckObject ( L , 2 , typeof ( System . Predicate < > ) . MakeGenericType ( argType ) ) ;
305- }
306- else
307- {
308- LuaFunction func = ToLua . ToLuaFunction ( L , 2 ) ;
309- arg0 = DelegateFactory . CreateDelegate ( typeof ( System . Predicate < > ) . MakeGenericType ( argType ) , func ) ;
310- }
311-
275+ Delegate arg0 = ToLua . CheckDelegate ( typeof ( System . Predicate < > ) . MakeGenericType ( argType ) , L , 2 ) ;
312276 object o = LuaMethodCache . CallMethod ( "FindAll" , obj , arg0 ) ;
313277 ToLua . Push ( L , o ) ;
314278 return 1 ;
@@ -329,25 +293,25 @@ static int FindIndex(IntPtr L)
329293 object obj = ToLua . CheckGenericObject ( L , 1 , typeof ( List < > ) , out argType ) ;
330294
331295 if ( count == 2 )
332- {
333- Delegate arg0 = ( Delegate ) ToLua . CheckObject ( L , 2 , typeof ( System . Predicate < > ) . MakeGenericType ( argType ) ) ;
296+ {
297+ Delegate arg0 = ToLua . CheckDelegate ( typeof ( System . Predicate < > ) . MakeGenericType ( argType ) , L , 2 ) ;
334298 int o = ( int ) LuaMethodCache . CallMethod ( "FindIndex" , obj , arg0 ) ;
335299 LuaDLL . lua_pushinteger ( L , o ) ;
336300 return 1 ;
337301 }
338302 else if ( count == 3 )
339303 {
340304 int arg0 = ( int ) LuaDLL . luaL_checknumber ( L , 2 ) ;
341- Delegate arg1 = ( Delegate ) ToLua . CheckObject ( L , 3 , typeof ( System . Predicate < > ) . MakeGenericType ( argType ) ) ;
305+ Delegate arg1 = ToLua . CheckDelegate ( typeof ( System . Predicate < > ) . MakeGenericType ( argType ) , L , 3 ) ;
342306 int o = ( int ) LuaMethodCache . CallMethod ( "FindIndex" , obj , arg0 , arg1 ) ;
343307 LuaDLL . lua_pushinteger ( L , o ) ;
344308 return 1 ;
345309 }
346310 else if ( count == 4 )
347311 {
348312 int arg0 = ( int ) LuaDLL . luaL_checknumber ( L , 2 ) ;
349- int arg1 = ( int ) LuaDLL . luaL_checknumber ( L , 3 ) ;
350- Delegate arg2 = ( Delegate ) ToLua . CheckObject ( L , 4 , typeof ( System . Predicate < > ) . MakeGenericType ( argType ) ) ;
313+ int arg1 = ( int ) LuaDLL . luaL_checknumber ( L , 3 ) ;
314+ Delegate arg2 = ToLua . CheckDelegate ( typeof ( System . Predicate < > ) . MakeGenericType ( argType ) , L , 4 ) ;
351315 int o = ( int ) LuaMethodCache . CallMethod ( "FindIndex" , obj , arg0 , arg1 , arg2 ) ;
352316 LuaDLL . lua_pushinteger ( L , o ) ;
353317 return 1 ;
@@ -369,21 +333,9 @@ static int FindLast(IntPtr L)
369333 try
370334 {
371335 ToLua . CheckArgsCount ( L , 2 ) ;
372- Type argType = null ;
373- Delegate arg0 = null ;
374- object obj = ToLua . CheckGenericObject ( L , 1 , typeof ( List < > ) , out argType ) ;
375- LuaTypes funcType2 = LuaDLL . lua_type ( L , 2 ) ;
376-
377- if ( funcType2 != LuaTypes . LUA_TFUNCTION )
378- {
379- arg0 = ( Delegate ) ToLua . CheckObject ( L , 2 , typeof ( System . Predicate < > ) . MakeGenericType ( argType ) ) ;
380- }
381- else
382- {
383- LuaFunction func = ToLua . ToLuaFunction ( L , 2 ) ;
384- arg0 = DelegateFactory . CreateDelegate ( typeof ( System . Predicate < > ) . MakeGenericType ( argType ) , func ) ;
385- }
386-
336+ Type argType = null ;
337+ object obj = ToLua . CheckGenericObject ( L , 1 , typeof ( List < > ) , out argType ) ;
338+ Delegate arg0 = ToLua . CheckDelegate ( typeof ( System . Predicate < > ) . MakeGenericType ( argType ) , L , 2 ) ;
387339 object o = LuaMethodCache . CallSingleMethod ( "FindLast" , obj , arg0 ) ;
388340 ToLua . Push ( L , o ) ;
389341 return 1 ;
@@ -446,19 +398,7 @@ static int ForEach(IntPtr L)
446398 ToLua . CheckArgsCount ( L , 2 ) ;
447399 Type argType = null ;
448400 object obj = ToLua . CheckGenericObject ( L , 1 , typeof ( List < > ) , out argType ) ;
449- Delegate arg0 = null ;
450- LuaTypes funcType2 = LuaDLL . lua_type ( L , 2 ) ;
451-
452- if ( funcType2 != LuaTypes . LUA_TFUNCTION )
453- {
454- arg0 = ( Delegate ) ToLua . CheckObject ( L , 2 , typeof ( System . Action < > ) . MakeGenericType ( argType ) ) ;
455- }
456- else
457- {
458- LuaFunction func = ToLua . ToLuaFunction ( L , 2 ) ;
459- arg0 = DelegateFactory . CreateDelegate ( typeof ( System . Action < > ) . MakeGenericType ( argType ) , func ) ;
460- }
461-
401+ Delegate arg0 = ToLua . CheckDelegate ( typeof ( System . Action < > ) . MakeGenericType ( argType ) , L , 2 ) ;
462402 LuaMethodCache . CallSingleMethod ( "ForEach" , obj , arg0 ) ;
463403 return 0 ;
464404 }
@@ -657,19 +597,7 @@ static int RemoveAll(IntPtr L)
657597 ToLua . CheckArgsCount ( L , 2 ) ;
658598 Type argType = null ;
659599 object obj = ToLua . CheckGenericObject ( L , 1 , typeof ( List < > ) , out argType ) ;
660- Delegate arg0 = null ;
661- LuaTypes funcType2 = LuaDLL . lua_type ( L , 2 ) ;
662-
663- if ( funcType2 != LuaTypes . LUA_TFUNCTION )
664- {
665- arg0 = ( Delegate ) ToLua . CheckObject ( L , 2 , typeof ( System . Predicate < > ) . MakeGenericType ( argType ) ) ;
666- }
667- else
668- {
669- LuaFunction func = ToLua . ToLuaFunction ( L , 2 ) ;
670- arg0 = DelegateFactory . CreateDelegate ( typeof ( System . Predicate < > ) . MakeGenericType ( argType ) , func ) ;
671- }
672-
600+ Delegate arg0 = ToLua . CheckDelegate ( typeof ( System . Predicate < > ) . MakeGenericType ( argType ) , L , 2 ) ;
673601 int o = ( int ) LuaMethodCache . CallSingleMethod ( "RemoveAll" , obj , arg0 ) ;
674602 LuaDLL . lua_pushinteger ( L , o ) ;
675603 return 1 ;
@@ -833,19 +761,7 @@ static int TrueForAll(IntPtr L)
833761 ToLua . CheckArgsCount ( L , 2 ) ;
834762 Type argType = null ;
835763 object obj = ToLua . CheckGenericObject ( L , 1 , typeof ( List < > ) , out argType ) ;
836- Delegate arg0 = null ;
837- LuaTypes funcType2 = LuaDLL . lua_type ( L , 2 ) ;
838-
839- if ( funcType2 != LuaTypes . LUA_TFUNCTION )
840- {
841- arg0 = ( Delegate ) ToLua . CheckObject ( L , 2 , typeof ( System . Predicate < > ) . MakeGenericType ( argType ) ) ;
842- }
843- else
844- {
845- LuaFunction func = ToLua . ToLuaFunction ( L , 2 ) ;
846- arg0 = DelegateFactory . CreateDelegate ( typeof ( System . Predicate < > ) . MakeGenericType ( argType ) , func ) ;
847- }
848-
764+ Delegate arg0 = ToLua . CheckDelegate ( typeof ( System . Predicate < > ) . MakeGenericType ( argType ) , L , 2 ) ;
849765 bool o = ( bool ) LuaMethodCache . CallSingleMethod ( "TrueForAll" , obj , arg0 ) ;
850766 LuaDLL . lua_pushboolean ( L , o ) ;
851767 return 1 ;
@@ -907,7 +823,7 @@ static int get_Capacity(IntPtr L)
907823 }
908824 catch ( Exception e )
909825 {
910- return LuaDLL . toluaL_exception ( L , e , o == null ? "attempt to index Capacity on a nil value" : e . Message ) ;
826+ return LuaDLL . toluaL_exception ( L , e , o , "attempt to index Capacity on a nil value" ) ;
911827 }
912828 }
913829
@@ -925,7 +841,7 @@ static int get_Count(IntPtr L)
925841 }
926842 catch ( Exception e )
927843 {
928- return LuaDLL . toluaL_exception ( L , e , o == null ? "attempt to index Count on a nil value" : e . Message ) ;
844+ return LuaDLL . toluaL_exception ( L , e , o , "attempt to index Count on a nil value" ) ;
929845 }
930846 }
931847
@@ -943,7 +859,7 @@ static int set_Capacity(IntPtr L)
943859 }
944860 catch ( Exception e )
945861 {
946- return LuaDLL . toluaL_exception ( L , e , o == null ? "attempt to index Capacity on a nil value" : e . Message ) ;
862+ return LuaDLL . toluaL_exception ( L , e , o , "attempt to index Capacity on a nil value" ) ;
947863 }
948864 }
949865}
0 commit comments