local nkeys = self.nkeys
if nkeys > 1 then
-- ultra slow path, q66 failed optimizing this
+ -- if you ever get to touch this, increment this
+ -- counter to let others know you failed too.
+ --
+ -- failures: 1
+ --
+ -- fortunately this one is not very commonly used.
local atbl
if type(key) == "table" then
atbl = { unpack(key) }
-- provides alt syntax for getters with keys
__call = function(self, ...)
return self.mt[self.key .. "_get"](self.obj, ...)
- end
+ end,
+
+ -- locks out the proxy
+ __metatable = false
}
+-- each __properties field looks like this:
+--
+-- { NUMBER_OF_KEYS, NUMBER_OF_VALUES, GETTABLE, SETTABLE }
+--
+-- the last two are booleans (determining if the property can be get and set).
ffi.metatype("Eo", {
+ -- handles property getting with no keys and also property setting with keys
__index = function(self, key)
local mt = get_obj_mt(self)
if mt == nil then return nil end
end
local nkeys, nvals = pp[1], pp[2]
if nkeys ~= 0 then
- -- proxy - slow path... TODO: find a better way
+ -- proxy - slow path, but no way around it
+ -- basically the proxy is needed because we want nice syntax and
+ -- lua can't do it by default. so we help ourselves a bit with this
return setmetatable({ nkeys = nkeys, nvals = nvals,
obj = self, key = key, mt = mt }, prop_proxy_meta)
end
end
end,
+ -- handles property setting with no keys
__newindex = function(self, key, val)
local mt = get_obj_mt(self)
if mt == nil then return nil end