local ffi = require("ffi") local class, object = require("class"), require("class.object") require("ecs") local Component = class(object) local function make_component(name, struct) if type(struct) == "string" then -- Assuming FFI cdef -- TODO : find a way to merge class and userdata local ct = ffi.cdef("typdef struct {"..struct.."} "..name..";") return ffi.metatype(ct, class(Component)) elseif struct.instanceof and struct:instanceof(Component) then -- Assuming parent class return class(struct) else return class(Component) end end