@@ -35,95 +35,6 @@ impl From<ReflectReference> for LuaReflectReference {
35
35
}
36
36
}
37
37
38
- // Looks up a function in the registry on the given type id
39
- // fn lookup_function(lua: &Lua, key: &str, type_id: TypeId) -> Option<Result<Function, mlua::Error>> {
40
- // let function = lookup_dynamic_function(lua, key, type_id);
41
-
42
- // function.map(|mut function| {
43
- // lua.create_function_mut(move |_lua, args: Variadic<LuaScriptValue>| {
44
- // let world = ThreadWorldContainer.get_world();
45
- // let out = function.call_script_function(
46
- // args.into_iter().map(Into::into),
47
- // world,
48
- // LUA_CALLER_CONTEXT,
49
- // )?;
50
-
51
- // Ok(LuaScriptValue::from(out))
52
- // })
53
- // })
54
- // }
55
-
56
- // fn lookup_function_typed<T: 'static + ?Sized>(
57
- // lua: &Lua,
58
- // key: &str,
59
- // ) -> Option<Result<Function, mlua::Error>> {
60
- // let type_id = TypeId::of::<T>();
61
- // lookup_function(lua, key, type_id)
62
- // }
63
-
64
- // fn lookup_dynamic_function(
65
- // _lua: &Lua,
66
- // key: &str,
67
- // type_id: TypeId,
68
- // ) -> Option<DynamicScriptFunction> {
69
- // let function_registry = ThreadWorldContainer
70
- // .get_world()
71
- // .with_resource(|registry: &AppScriptFunctionRegistry| registry.clone());
72
- // let registry = function_registry.read();
73
-
74
- // registry
75
- // .get_function(Namespace::OnType(type_id), key.to_string())
76
- // .cloned()
77
- // }
78
-
79
- // fn lookup_dynamic_function_typed<T: 'static + ?Sized>(
80
- // lua: &Lua,
81
- // key: &str,
82
- // ) -> Option<DynamicScriptFunction> {
83
- // let type_id = TypeId::of::<T>();
84
- // lookup_dynamic_function(lua, key, type_id)
85
- // }
86
-
87
- // fn iter_dynamic_function_overloads(
88
- // _lua: &Lua,
89
- // key: &str,
90
- // type_id: TypeId,
91
- // ) -> impl Iterator<Item = DynamicScriptFunction> {
92
- // let registry = ThreadWorldContainer
93
- // .get_world()
94
- // .with_resource(|registry: &AppScriptFunctionRegistry| registry.clone());
95
- // let registry = registry.read();
96
-
97
- // registry
98
- // .iter_overloads(Namespace::OnType(type_id), key.to_string())
99
- // .cloned()
100
- // .collect::<Vec<_>>()
101
- // .into_iter()
102
- // }
103
-
104
- // fn try_call_overloads(
105
- // lua: &Lua,
106
- // key: &str,
107
- // type_id: TypeId,
108
- // args: Vec<ScriptValue>,
109
- // world: WorldGuard,
110
- // ) -> Result<LuaScriptValue, InteropError> {
111
- // let overloads = iter_dynamic_function_overloads(lua, key, type_id);
112
- // let mut last_error = None;
113
- // for mut overload in overloads {
114
- // match overload.call_script_function(
115
- // args.clone(),
116
- // world.clone(),
117
- // lua_caller_context(Some(type_id)),
118
- // ) {
119
- // Ok(out) => return Ok(out.into()),
120
- // Err(e) => last_error = Some(e),
121
- // }
122
- // }
123
-
124
- // Err(last_error.unwrap_or_else(|| InteropError::missing_function(type_id, key.to_string())))
125
- // }
126
-
127
38
/// Look up a function on the given type ids
128
39
fn lookup_function (
129
40
guard : WorldGuard ,
@@ -205,13 +116,6 @@ impl UserData for LuaReflectReference {
205
116
LUA_CALLER_CONTEXT ,
206
117
) ?;
207
118
Ok ( LuaScriptValue ( out) )
208
- // // call the function with the key
209
- // let out = index_func.call_script_function(
210
- // vec![ScriptValue::Reference(self_), key],
211
- // world.clone(),
212
- // lua_caller_context(Some(std::any::TypeId::of::<ReflectReference>())),
213
- // )?;
214
- // LuaScriptValue::from(out).into_lua(lua)
215
119
} ,
216
120
) ;
217
121
@@ -222,15 +126,6 @@ impl UserData for LuaReflectReference {
222
126
let key: ScriptValue = key. into ( ) ;
223
127
let value: ScriptValue = value. into ( ) ;
224
128
225
- // lookup_dynamic_function_typed::<ReflectReference>(lua, "set")
226
- // .expect("No 'set' function registered for a ReflectReference")
227
- // .call_script_function(
228
- // vec![ScriptValue::Reference(self_), key, value],
229
- // ThreadWorldContainer.get_world(),
230
- // lua_caller_context(Some(std::any::TypeId::of::<ReflectReference>())),
231
- // )?;
232
- // Ok(())
233
-
234
129
let func = lookup_function (
235
130
ThreadWorldContainer . get_world ( ) ,
236
131
[ TypeId :: of :: < ReflectReference > ( ) ] ,
@@ -256,7 +151,6 @@ impl UserData for LuaReflectReference {
256
151
let other: ScriptValue = other. into ( ) ;
257
152
let target_type_id = self_. tail_type_id ( world. clone ( ) ) ?. or_fake_id ( ) ;
258
153
let args = vec ! [ ScriptValue :: Reference ( self_) , other] ;
259
- // Ok(try_call_overloads(lua, "sub", target_type_id, args, world)?)
260
154
Ok ( try_call_overloads ( world, target_type_id, "sub" , args) ?)
261
155
} ,
262
156
) ;
@@ -269,7 +163,6 @@ impl UserData for LuaReflectReference {
269
163
let other: ScriptValue = other. into ( ) ;
270
164
let target_type_id = self_. tail_type_id ( world. clone ( ) ) ?. or_fake_id ( ) ;
271
165
let args = vec ! [ ScriptValue :: Reference ( self_) , other] ;
272
- // Ok(try_call_overloads(lua, "add", target_type_id, args, world)?)
273
166
Ok ( try_call_overloads ( world, target_type_id, "add" , args) ?)
274
167
} ,
275
168
) ;
@@ -282,7 +175,6 @@ impl UserData for LuaReflectReference {
282
175
let other: ScriptValue = other. into ( ) ;
283
176
let target_type_id = self_. tail_type_id ( world. clone ( ) ) ?. or_fake_id ( ) ;
284
177
let args = vec ! [ ScriptValue :: Reference ( self_) , other] ;
285
- // Ok(try_call_overloads(lua, "mul", target_type_id, args, world)?)
286
178
Ok ( try_call_overloads ( world, target_type_id, "mul" , args) ?)
287
179
} ,
288
180
) ;
@@ -295,7 +187,6 @@ impl UserData for LuaReflectReference {
295
187
let other: ScriptValue = other. into ( ) ;
296
188
let target_type_id = self_. tail_type_id ( world. clone ( ) ) ?. or_fake_id ( ) ;
297
189
let args = vec ! [ ScriptValue :: Reference ( self_) , other] ;
298
- // Ok(try_call_overloads(lua, "div", target_type_id, args, world)?)
299
190
Ok ( try_call_overloads ( world, target_type_id, "div" , args) ?)
300
191
} ,
301
192
) ;
@@ -308,7 +199,6 @@ impl UserData for LuaReflectReference {
308
199
let other: ScriptValue = other. into ( ) ;
309
200
let target_type_id = self_. tail_type_id ( world. clone ( ) ) ?. or_fake_id ( ) ;
310
201
let args = vec ! [ ScriptValue :: Reference ( self_) , other] ;
311
- // Ok(try_call_overloads(lua, "rem", target_type_id, args, world)?)
312
202
Ok ( try_call_overloads ( world, target_type_id, "rem" , args) ?)
313
203
} ,
314
204
) ;
@@ -318,7 +208,6 @@ impl UserData for LuaReflectReference {
318
208
let self_: ReflectReference = self_. into ( ) ;
319
209
let target_type_id = self_. tail_type_id ( world. clone ( ) ) ?. or_fake_id ( ) ;
320
210
let args = vec ! [ ScriptValue :: Reference ( self_) ] ;
321
- // Ok(try_call_overloads(lua, "neg", target_type_id, args, world)?)
322
211
Ok ( try_call_overloads ( world, target_type_id, "neg" , args) ?)
323
212
} ) ;
324
213
@@ -330,7 +219,6 @@ impl UserData for LuaReflectReference {
330
219
let other: ScriptValue = other. into ( ) ;
331
220
let target_type_id = self_. tail_type_id ( world. clone ( ) ) ?. or_fake_id ( ) ;
332
221
let args = vec ! [ ScriptValue :: Reference ( self_) , other] ;
333
- // Ok(try_call_overloads(lua, "pow", target_type_id, args, world)?)
334
222
Ok ( try_call_overloads ( world, target_type_id, "pow" , args) ?)
335
223
} ,
336
224
) ;
@@ -343,7 +231,6 @@ impl UserData for LuaReflectReference {
343
231
let other: ScriptValue = other. into ( ) ;
344
232
let target_type_id = self_. tail_type_id ( world. clone ( ) ) ?. or_fake_id ( ) ;
345
233
let args = vec ! [ ScriptValue :: Reference ( self_) , other] ;
346
- // Ok(try_call_overloads(lua, "eq", target_type_id, args, world)?)
347
234
Ok ( try_call_overloads ( world, target_type_id, "eq" , args) ?)
348
235
} ,
349
236
) ;
@@ -356,7 +243,6 @@ impl UserData for LuaReflectReference {
356
243
let other: ScriptValue = other. into ( ) ;
357
244
let target_type_id = self_. tail_type_id ( world. clone ( ) ) ?. or_fake_id ( ) ;
358
245
let args = vec ! [ ScriptValue :: Reference ( self_) , other] ;
359
- // Ok(try_call_overloads(lua, "lt", target_type_id, args, world)?)
360
246
Ok ( try_call_overloads ( world, target_type_id, "lt" , args) ?)
361
247
} ,
362
248
) ;
@@ -411,17 +297,6 @@ impl UserData for LuaReflectReference {
411
297
LUA_CALLER_CONTEXT ,
412
298
) ?;
413
299
Ok ( LuaScriptValue ( out) )
414
- // let mut display_func =
415
- // lookup_dynamic_function_typed::<ReflectReference>(lua, "display_ref")
416
- // .expect("No 'display' function registered for a ReflectReference");
417
-
418
- // let out = display_func.call_script_function(
419
- // vec![ScriptValue::Reference(self_)],
420
- // world,
421
- // lua_caller_context(Some(std::any::TypeId::of::<ReflectReference>())),
422
- // )?;
423
-
424
- // Ok(LuaScriptValue::from(out))
425
300
} ) ;
426
301
}
427
302
}
0 commit comments