File tree Expand file tree Collapse file tree 2 files changed +85
-19
lines changed
Expand file tree Collapse file tree 2 files changed +85
-19
lines changed Original file line number Diff line number Diff line change 33
44namespace XLuaTest
55{
6- public class IntObject : RawObject
7- {
8- int mTarget ;
9-
10- public IntObject ( int i )
11- {
12- mTarget = i ;
13- }
14-
15- public object Target
16- {
17- get
18- {
19- return mTarget ;
20- }
21- }
22- }
23-
246 public class RawObjectTest : MonoBehaviour
257 {
268 public static void PrintType ( object o )
@@ -35,7 +17,7 @@ void Start()
3517 //直接传1234到一个object参数,xLua将选择能保留最大精度的long来传递
3618 luaenv . DoString ( "CS.XLuaTest.RawObjectTest.PrintType(1234)" ) ;
3719 //通过一个继承RawObject的类,能实现指明以一个int来传递
38- luaenv . DoString ( "CS.XLuaTest.RawObjectTest.PrintType(CS.XLuaTest.IntObject (1234))" ) ;
20+ luaenv . DoString ( "CS.XLuaTest.RawObjectTest.PrintType(CS.XLua.Cast.Int32 (1234))" ) ;
3921 luaenv . Dispose ( ) ;
4022 }
4123
Original file line number Diff line number Diff line change @@ -5,3 +5,87 @@ public interface RawObject
55 object Target { get ; }
66 }
77}
8+
9+ namespace XLua . Cast
10+ {
11+ public class Any < T > : RawObject
12+ {
13+ T mTarget ;
14+
15+ public Any ( T i )
16+ {
17+ mTarget = i ;
18+ }
19+
20+ public object Target
21+ {
22+ get
23+ {
24+ return mTarget ;
25+ }
26+ }
27+ }
28+
29+ public class Byte : Any < byte >
30+ {
31+ public Byte ( byte i ) : base ( i )
32+ {
33+ }
34+ }
35+
36+ public class SByte : Any < sbyte >
37+ {
38+ public SByte ( sbyte i ) : base ( i )
39+ {
40+ }
41+ }
42+
43+ public class Char : Any < char >
44+ {
45+ public Char ( char i ) : base ( i )
46+ {
47+ }
48+ }
49+
50+ public class Int16 : Any < short >
51+ {
52+ public Int16 ( short i ) : base ( i )
53+ {
54+ }
55+ }
56+
57+ public class UInt16 : Any < ushort >
58+ {
59+ public UInt16 ( ushort i ) : base ( i )
60+ {
61+ }
62+ }
63+
64+ public class Int32 : Any < int >
65+ {
66+ public Int32 ( int i ) : base ( i )
67+ {
68+ }
69+ }
70+
71+ public class UInt32 : Any < uint >
72+ {
73+ public UInt32 ( uint i ) : base ( i )
74+ {
75+ }
76+ }
77+
78+ public class UInt64 : Any < ulong >
79+ {
80+ public UInt64 ( ulong i ) : base ( i )
81+ {
82+ }
83+ }
84+
85+ public class Float : Any < float >
86+ {
87+ public Float ( float i ) : base ( i )
88+ {
89+ }
90+ }
91+ }
You can’t perform that action at this time.
0 commit comments