All library functions no longer require self
This commit is contained in:
@@ -351,7 +351,7 @@ impl<'r> MetatypeBuilder<'r> {
|
||||
name: impl Display,
|
||||
f: impl FnOnce(&mut MetatypeFunctionBuilder),
|
||||
) -> &mut Self {
|
||||
write!(self.lua, "__idx.{name} = ").unwrap();
|
||||
write!(self.lua, "Self.{name} = ").unwrap();
|
||||
f(&mut MetatypeFunctionBuilder::new(self));
|
||||
writeln!(self.lua, ";").unwrap();
|
||||
self.has_index = true;
|
||||
@@ -359,7 +359,7 @@ impl<'r> MetatypeBuilder<'r> {
|
||||
}
|
||||
|
||||
pub fn index_raw(&mut self, name: impl Display, value: impl Display) -> &mut Self {
|
||||
writeln!(self.lua, "__idx.{name} = {value};").unwrap();
|
||||
writeln!(self.lua, "Self.{name} = {value};").unwrap();
|
||||
self.has_index = true;
|
||||
self
|
||||
}
|
||||
@@ -395,13 +395,13 @@ impl<'r> Drop for MetatypeBuilder<'r> {
|
||||
write!(reg.lua, r#"do local __mt = {{}}; "#).unwrap();
|
||||
|
||||
if *has_index {
|
||||
write!(reg.lua, r#"local __idx = {{}}; __mt.__index = __idx; "#).unwrap();
|
||||
write!(reg.lua, r#"local Self = {{}}; __mt.__index = Self; "#).unwrap();
|
||||
}
|
||||
|
||||
reg.cdef.push_str(cdef);
|
||||
reg.lua.push_str(lua.trim_end());
|
||||
|
||||
writeln!(reg.lua, r#"__metatype(__ct.{ct}, __mt); end;"#).unwrap();
|
||||
writeln!(reg.lua, r#" __metatype(__ct.{ct}, __mt); end;"#).unwrap();
|
||||
|
||||
for lua in lua_includes {
|
||||
writeln!(reg.lua, "do {}\nend;", lua.trim_end()).unwrap();
|
||||
|
||||
Reference in New Issue
Block a user