-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathnlua.patch
More file actions
323 lines (319 loc) · 11.4 KB
/
nlua.patch
File metadata and controls
323 lines (319 loc) · 11.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
diff --git a/src/Lua.cs b/src/Lua.cs
index fd8a85f..dd799ce 100644
--- a/src/Lua.cs
+++ b/src/Lua.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Linq;
using System.Reflection;
using System.Collections.Generic;
@@ -340,9 +340,7 @@ namespace NLua
_luaState = null;
}
-#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__
[MonoPInvokeCallback(typeof(LuaNativeFunction))]
-#endif
static int PanicCallback(IntPtr state)
{
var luaState = LuaState.FromIntPtr(state);
diff --git a/src/Metatables.cs b/src/Metatables.cs
index c42e5d9..8ee9208 100644
--- a/src/Metatables.cs
+++ b/src/Metatables.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.Linq;
using System.Collections;
using System.Reflection;
@@ -104,9 +104,7 @@ namespace NLua
/*
* __call metafunction of CLR delegates, retrieves and calls the delegate.
*/
-#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__
[MonoPInvokeCallback(typeof(LuaNativeFunction))]
-#endif
private static int RunFunctionDelegate(IntPtr luaState)
{
var state = LuaState.FromIntPtr(luaState);
@@ -127,9 +125,7 @@ namespace NLua
/*
* __gc metafunction of CLR objects.
*/
-#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__
[MonoPInvokeCallback(typeof(LuaNativeFunction))]
-#endif
private static int CollectObject(IntPtr state)
{
var luaState = LuaState.FromIntPtr(state);
@@ -150,9 +146,7 @@ namespace NLua
/*
* __tostring metafunction of CLR objects.
*/
-#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__
[MonoPInvokeCallback(typeof(LuaNativeFunction))]
-#endif
private static int ToStringLua(IntPtr state)
{
var luaState = LuaState.FromIntPtr(state);
@@ -176,9 +170,7 @@ namespace NLua
/*
* __add metafunction of CLR objects.
*/
-#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__
[MonoPInvokeCallback(typeof(LuaNativeFunction))]
-#endif
static int AddLua(IntPtr luaState)
{
var state = LuaState.FromIntPtr(luaState);
@@ -194,9 +186,7 @@ namespace NLua
/*
* __sub metafunction of CLR objects.
*/
-#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__
[MonoPInvokeCallback(typeof(LuaNativeFunction))]
-#endif
static int SubtractLua(IntPtr luaState)
{
var state = LuaState.FromIntPtr(luaState);
@@ -212,9 +202,7 @@ namespace NLua
/*
* __mul metafunction of CLR objects.
*/
-#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__
[MonoPInvokeCallback(typeof(LuaNativeFunction))]
-#endif
static int MultiplyLua(IntPtr luaState)
{
var state = LuaState.FromIntPtr(luaState);
@@ -230,9 +218,7 @@ namespace NLua
/*
* __div metafunction of CLR objects.
*/
-#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__
[MonoPInvokeCallback(typeof(LuaNativeFunction))]
-#endif
static int DivideLua(IntPtr luaState)
{
var state = LuaState.FromIntPtr(luaState);
@@ -248,9 +234,7 @@ namespace NLua
/*
* __mod metafunction of CLR objects.
*/
-#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__
[MonoPInvokeCallback(typeof(LuaNativeFunction))]
-#endif
static int ModLua(IntPtr luaState)
{
var state = LuaState.FromIntPtr(luaState);
@@ -266,9 +250,7 @@ namespace NLua
/*
* __unm metafunction of CLR objects.
*/
-#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__
[MonoPInvokeCallback(typeof(LuaNativeFunction))]
-#endif
static int UnaryNegationLua(IntPtr luaState)
{
var state = LuaState.FromIntPtr(luaState);
@@ -308,9 +290,7 @@ namespace NLua
/*
* __eq metafunction of CLR objects.
*/
-#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__
[MonoPInvokeCallback(typeof(LuaNativeFunction))]
-#endif
static int EqualLua(IntPtr luaState)
{
var state = LuaState.FromIntPtr(luaState);
@@ -326,9 +306,7 @@ namespace NLua
/*
* __lt metafunction of CLR objects.
*/
-#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__
[MonoPInvokeCallback(typeof(LuaNativeFunction))]
-#endif
static int LessThanLua(IntPtr luaState)
{
var state = LuaState.FromIntPtr(luaState);
@@ -344,9 +322,7 @@ namespace NLua
/*
* __le metafunction of CLR objects.
*/
-#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__
[MonoPInvokeCallback(typeof(LuaNativeFunction))]
-#endif
static int LessThanOrEqualLua(IntPtr luaState)
{
var state = LuaState.FromIntPtr(luaState);
@@ -394,9 +370,7 @@ namespace NLua
* either the value of the member or a delegate to call it.
* If the member does not exist returns nil.
*/
-#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__
[MonoPInvokeCallback(typeof(LuaNativeFunction))]
-#endif
private static int GetMethod(IntPtr state)
{
var luaState = LuaState.FromIntPtr(state);
@@ -698,9 +672,7 @@ namespace NLua
* __index metafunction of base classes (the base field of Lua tables).
* Adds a prefix to the method name to call the base version of the method.
*/
-#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__
[MonoPInvokeCallback(typeof(LuaNativeFunction))]
-#endif
private static int GetBaseMethod(IntPtr state)
{
var luaState = LuaState.FromIntPtr(state);
@@ -1001,9 +973,7 @@ namespace NLua
* the member name and the value to be stored as arguments. Throws
* and error if the assignment is invalid.
*/
-#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__
[MonoPInvokeCallback(typeof(LuaNativeFunction))]
-#endif
private static int SetFieldOrProperty(IntPtr state)
{
var luaState = LuaState.FromIntPtr(state);
@@ -1206,9 +1176,7 @@ namespace NLua
/*
* __index metafunction of type references, works on static members.
*/
-#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__
[MonoPInvokeCallback(typeof(LuaNativeFunction))]
-#endif
private static int GetClassMethod(IntPtr state)
{
var luaState = LuaState.FromIntPtr(state);
@@ -1252,9 +1220,7 @@ namespace NLua
/*
* __newindex function of type references, works on static members.
*/
-#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__
[MonoPInvokeCallback(typeof(LuaNativeFunction))]
-#endif
private static int SetClassFieldOrProperty(IntPtr state)
{
var luaState = LuaState.FromIntPtr(state);
@@ -1284,9 +1250,7 @@ namespace NLua
/*
* __call metafunction of Delegates.
*/
-#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__
[MonoPInvokeCallback(typeof(LuaNativeFunction))]
-#endif
static int CallDelegate(IntPtr state)
{
var luaState = LuaState.FromIntPtr(state);
@@ -1353,9 +1317,7 @@ namespace NLua
* found or if the arguments are invalid. Throws an error if the constructor
* generates an exception.
*/
-#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__
[MonoPInvokeCallback(typeof(LuaNativeFunction))]
-#endif
private static int CallConstructor(IntPtr state)
{
var luaState = LuaState.FromIntPtr(state);
diff --git a/src/ObjectTranslator.cs b/src/ObjectTranslator.cs
index a6233fa..fbe0850 100644
--- a/src/ObjectTranslator.cs
+++ b/src/ObjectTranslator.cs
@@ -1,4 +1,4 @@
-using System;
+using System;
using System.IO;
using System.Reflection;
using System.Collections.Generic;
@@ -18,6 +18,12 @@ using LuaState = KeraLua.Lua;
using LuaNativeFunction = KeraLua.LuaFunction;
using System.Runtime.CompilerServices;
+
+[AttributeUsage (AttributeTargets.Method)]
+sealed class MonoPInvokeCallbackAttribute : Attribute {
+ public MonoPInvokeCallbackAttribute (Type t) {}
+}
+
namespace NLua
{
public class ObjectTranslator
@@ -258,9 +264,7 @@ namespace NLua
* Implementation of load_assembly. Throws an error
* if the assembly is not found.
*/
-#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__
[MonoPInvokeCallback(typeof(LuaNativeFunction))]
-#endif
private static int LoadAssembly(IntPtr luaState)
{
var state = LuaState.FromIntPtr(luaState);
@@ -362,9 +366,7 @@ namespace NLua
* Implementation of import_type. Returns nil if the
* type is not found.
*/
-#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__
[MonoPInvokeCallback(typeof(LuaNativeFunction))]
-#endif
private static int ImportType(IntPtr luaState)
{
var state = LuaState.FromIntPtr(luaState);
@@ -390,9 +392,7 @@ namespace NLua
* argument in the stack) as an object subclassing the
* type passed as second argument in the stack.
*/
-#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__
[MonoPInvokeCallback(typeof(LuaNativeFunction))]
-#endif
private static int RegisterTable(IntPtr luaState)
{
var state = LuaState.FromIntPtr(luaState);
@@ -457,9 +457,7 @@ namespace NLua
* Implementation of free_object. Clears the metatable and the
* base field, freeing the created object for garbage-collection
*/
-#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__
[MonoPInvokeCallback(typeof(LuaNativeFunction))]
-#endif
private static int UnregisterTable(IntPtr luaState)
{
var state = LuaState.FromIntPtr(luaState);
@@ -514,9 +512,7 @@ namespace NLua
* Implementation of get_method_bysig. Returns nil
* if no matching method is not found.
*/
-#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__
[MonoPInvokeCallback(typeof(LuaNativeFunction))]
-#endif
private static int GetMethodSignature(IntPtr luaState)
{
var state = LuaState.FromIntPtr(luaState);
@@ -579,9 +575,7 @@ namespace NLua
* Implementation of get_constructor_bysig. Returns nil
* if no matching constructor is found.
*/
-#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__
[MonoPInvokeCallback(typeof(LuaNativeFunction))]
-#endif
private static int GetConstructorSignature(IntPtr luaState)
{
var state = LuaState.FromIntPtr(luaState);
@@ -1174,9 +1168,7 @@ namespace NLua
return 2;
}
-#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__
[MonoPInvokeCallback(typeof(LuaNativeFunction))]
-#endif
private static int CType(IntPtr luaState)
{
var state = LuaState.FromIntPtr(luaState);
@@ -1194,9 +1186,7 @@ namespace NLua
return 1;
}
-#if __IOS__ || __TVOS__ || __WATCHOS__ || __MACCATALYST__
[MonoPInvokeCallback(typeof(LuaNativeFunction))]
-#endif
private static int EnumFromInt(IntPtr luaState)
{
var state = LuaState.FromIntPtr(luaState);