stop setting metatables on objects
This commit is contained in:
parent
4cf2231a01
commit
e92cc50186
@ -10,7 +10,7 @@ FFI.cdef[[
|
|||||||
};
|
};
|
||||||
]]
|
]]
|
||||||
|
|
||||||
function Gate.new(self, objref, definition)
|
function Gate.new(objref, definition)
|
||||||
local o = {
|
local o = {
|
||||||
objref = objref,
|
objref = objref,
|
||||||
definition = definition,
|
definition = definition,
|
||||||
@ -18,8 +18,6 @@ function Gate.new(self, objref, definition)
|
|||||||
in_queue = false,
|
in_queue = false,
|
||||||
logic = definition.logic,
|
logic = definition.logic,
|
||||||
}
|
}
|
||||||
setmetatable(o, self)
|
|
||||||
self.__index = self
|
|
||||||
return o
|
return o
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ GateDefinition = {
|
|||||||
input = function(gate, argv) end
|
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)
|
name = collapseescape(name)
|
||||||
init = collapseescape(init)
|
init = collapseescape(init)
|
||||||
@ -53,13 +53,11 @@ function GateDefinition.new(self, objref, name, description, init, logic, input,
|
|||||||
print(global)
|
print(global)
|
||||||
end
|
end
|
||||||
|
|
||||||
setmetatable(o, self)
|
|
||||||
self.__index = self
|
|
||||||
return o
|
return o
|
||||||
end
|
end
|
||||||
|
|
||||||
function GateDefinition.constructgate(def, objref, position, rotation)
|
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
|
for i = 1, #def.ports do
|
||||||
local portd = def.ports[i]
|
local portd = def.ports[i]
|
||||||
@ -84,7 +82,7 @@ function GateDefinition.constructgate(def, objref, position, rotation)
|
|||||||
pos[2] = x
|
pos[2] = x
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
return gate
|
return gate
|
||||||
|
@ -15,7 +15,7 @@ FFI.cdef[[
|
|||||||
};
|
};
|
||||||
]]
|
]]
|
||||||
|
|
||||||
function Group.new(self)
|
function Group.new()
|
||||||
local o = {
|
local o = {
|
||||||
state = false,
|
state = false,
|
||||||
fxstate = false,
|
fxstate = false,
|
||||||
@ -32,8 +32,6 @@ function Group.new(self)
|
|||||||
nout_ports = 0,
|
nout_ports = 0,
|
||||||
nin_ports = 0,
|
nin_ports = 0,
|
||||||
}
|
}
|
||||||
setmetatable(o, self)
|
|
||||||
self.__index = self
|
|
||||||
return o
|
return o
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -149,7 +149,7 @@ while 1 do
|
|||||||
local max = vectotable(data[i+4])
|
local max = vectotable(data[i+4])
|
||||||
local bounds = {min[1], min[2], min[3], max[1], max[2], max[3]}
|
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)
|
Simulation.addwire(sim, wire)
|
||||||
|
|
||||||
i = i + 4
|
i = i + 4
|
||||||
@ -202,7 +202,7 @@ while 1 do
|
|||||||
if not portd.direction then print(line) end
|
if not portd.direction then print(line) end
|
||||||
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)
|
Simulation.addgatedefinition(sim, definition)
|
||||||
|
|
||||||
i = i + 8 + numports*5
|
i = i + 8 + numports*5
|
||||||
|
@ -29,7 +29,7 @@ FFI.cdef[[
|
|||||||
};
|
};
|
||||||
]]
|
]]
|
||||||
|
|
||||||
function Port.new(self, type, direction, position, causeupdate)
|
function Port.new(type, direction, position, causeupdate)
|
||||||
local o = {
|
local o = {
|
||||||
type = type,
|
type = type,
|
||||||
direction = direction,
|
direction = direction,
|
||||||
@ -39,8 +39,6 @@ function Port.new(self, type, direction, position, causeupdate)
|
|||||||
gate = nil,
|
gate = nil,
|
||||||
group = nil,
|
group = nil,
|
||||||
}
|
}
|
||||||
setmetatable(o, self)
|
|
||||||
self.__index = self
|
|
||||||
return o
|
return o
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -219,7 +219,7 @@ function Simulation.connectwire(sim, wire)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if Wire.getgroup(wire)==nil then
|
if Wire.getgroup(wire)==nil then
|
||||||
Group.addwire(Group.new(Group), wire)
|
Group.addwire(Group.new(), wire)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -233,7 +233,7 @@ function Simulation.connectport(sim, port)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if Port.getgroup(port) == nil then
|
if Port.getgroup(port) == nil then
|
||||||
Group.addport(Group.new(Group), port)
|
Group.addport(Group.new(), port)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -10,15 +10,13 @@ FFI.cdef[[
|
|||||||
};
|
};
|
||||||
]]
|
]]
|
||||||
|
|
||||||
function Wire.new(self, objref, layer, bounds)
|
function Wire.new(objref, layer, bounds)
|
||||||
local o = {
|
local o = {
|
||||||
objref = objref,
|
objref = objref,
|
||||||
layer = layer,
|
layer = layer,
|
||||||
group = nil,
|
group = nil,
|
||||||
bounds = bounds,
|
bounds = bounds,
|
||||||
}
|
}
|
||||||
setmetatable(o, self)
|
|
||||||
self.__index = self
|
|
||||||
return o
|
return o
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user