From e92cc501867ef1060dcec24feb4d5ce102755226 Mon Sep 17 00:00:00 2001 From: Redo0 Date: Tue, 25 May 2021 17:28:54 -0500 Subject: [PATCH] stop setting metatables on objects --- sim/gate.lua | 4 +--- sim/gatedef.lua | 8 +++----- sim/group.lua | 4 +--- sim/main.lua | 4 ++-- sim/port.lua | 4 +--- sim/simulation.lua | 4 ++-- sim/wire.lua | 4 +--- 7 files changed, 11 insertions(+), 21 deletions(-) diff --git a/sim/gate.lua b/sim/gate.lua index c646cb8..3aa96f1 100644 --- a/sim/gate.lua +++ b/sim/gate.lua @@ -10,7 +10,7 @@ FFI.cdef[[ }; ]] -function Gate.new(self, objref, definition) +function Gate.new(objref, definition) local o = { objref = objref, definition = definition, @@ -18,8 +18,6 @@ function Gate.new(self, objref, definition) in_queue = false, logic = definition.logic, } - setmetatable(o, self) - self.__index = self return o end diff --git a/sim/gatedef.lua b/sim/gatedef.lua index c9c537c..dca697a 100644 --- a/sim/gatedef.lua +++ b/sim/gatedef.lua @@ -5,7 +5,7 @@ GateDefinition = { input = function(gate, argv) end } -function GateDefinition.new(self, objref, name, description, init, logic, input, global, ports) +function GateDefinition.new(objref, name, description, init, logic, input, global, ports) name = collapseescape(name) init = collapseescape(init) @@ -53,13 +53,11 @@ function GateDefinition.new(self, objref, name, description, init, logic, input, print(global) end - setmetatable(o, self) - self.__index = self return o end function GateDefinition.constructgate(def, objref, position, rotation) - local gate = Gate.new(Gate, objref, def) + local gate = Gate.new(objref, def) for i = 1, #def.ports do local portd = def.ports[i] @@ -84,7 +82,7 @@ function GateDefinition.constructgate(def, objref, position, rotation) pos[2] = x end - Gate.addport(gate, Port.new(Port, type, dir, {position[1]+pos[1], position[2]+pos[2], position[3]+pos[3]}, portd.causeupdate)) + Gate.addport(gate, Port.new(type, dir, {position[1]+pos[1], position[2]+pos[2], position[3]+pos[3]}, portd.causeupdate)) end return gate diff --git a/sim/group.lua b/sim/group.lua index d8794b5..aff91c9 100644 --- a/sim/group.lua +++ b/sim/group.lua @@ -15,7 +15,7 @@ FFI.cdef[[ }; ]] -function Group.new(self) +function Group.new() local o = { state = false, fxstate = false, @@ -32,8 +32,6 @@ function Group.new(self) nout_ports = 0, nin_ports = 0, } - setmetatable(o, self) - self.__index = self return o end diff --git a/sim/main.lua b/sim/main.lua index cac837f..ca57b84 100644 --- a/sim/main.lua +++ b/sim/main.lua @@ -149,7 +149,7 @@ while 1 do local max = vectotable(data[i+4]) local bounds = {min[1], min[2], min[3], max[1], max[2], max[3]} - local wire = Wire.new(Wire, tonumber(data[i+1]), tonumber(data[i+2]), bounds) + local wire = Wire.new(tonumber(data[i+1]), tonumber(data[i+2]), bounds) Simulation.addwire(sim, wire) i = i + 4 @@ -202,7 +202,7 @@ while 1 do if not portd.direction then print(line) end end - local definition = GateDefinition.new(GateDefinition, objref, name, desc, init, logic, input, global, ports) + local definition = GateDefinition.new(objref, name, desc, init, logic, input, global, ports) Simulation.addgatedefinition(sim, definition) i = i + 8 + numports*5 diff --git a/sim/port.lua b/sim/port.lua index 9af0026..e4a5381 100644 --- a/sim/port.lua +++ b/sim/port.lua @@ -29,7 +29,7 @@ FFI.cdef[[ }; ]] -function Port.new(self, type, direction, position, causeupdate) +function Port.new(type, direction, position, causeupdate) local o = { type = type, direction = direction, @@ -39,8 +39,6 @@ function Port.new(self, type, direction, position, causeupdate) gate = nil, group = nil, } - setmetatable(o, self) - self.__index = self return o end diff --git a/sim/simulation.lua b/sim/simulation.lua index df0bfba..4433d86 100644 --- a/sim/simulation.lua +++ b/sim/simulation.lua @@ -219,7 +219,7 @@ function Simulation.connectwire(sim, wire) end if Wire.getgroup(wire)==nil then - Group.addwire(Group.new(Group), wire) + Group.addwire(Group.new(), wire) end end @@ -233,7 +233,7 @@ function Simulation.connectport(sim, port) end if Port.getgroup(port) == nil then - Group.addport(Group.new(Group), port) + Group.addport(Group.new(), port) end end diff --git a/sim/wire.lua b/sim/wire.lua index 27a60d5..818d381 100644 --- a/sim/wire.lua +++ b/sim/wire.lua @@ -10,15 +10,13 @@ FFI.cdef[[ }; ]] -function Wire.new(self, objref, layer, bounds) +function Wire.new(objref, layer, bounds) local o = { objref = objref, layer = layer, group = nil, bounds = bounds, } - setmetatable(o, self) - self.__index = self return o end