summaryrefslogtreecommitdiff
path: root/src/bindings
diff options
context:
space:
mode:
authorDaniel Kolesa <d.kolesa@samsung.com>2015-04-01 14:19:49 +0100
committerDaniel Kolesa <d.kolesa@samsung.com>2015-04-01 14:20:08 +0100
commit34beed984da160ccc774ed22462607b05f7f99d9 (patch)
tree78fe1af31f33760a3678a38e435ad0b733c0a725 /src/bindings
parent155126828010e8a1914050958866130422437cee (diff)
elua: clarify comments in eo.lua (explain how the property system works)
Diffstat (limited to 'src/bindings')
-rw-r--r--src/bindings/luajit/eo.lua22
1 files changed, 20 insertions, 2 deletions
diff --git a/src/bindings/luajit/eo.lua b/src/bindings/luajit/eo.lua
index 17765ac5cb..6c7d5c78e8 100644
--- a/src/bindings/luajit/eo.lua
+++ b/src/bindings/luajit/eo.lua
@@ -363,6 +363,12 @@ local prop_proxy_meta = {
363 local nkeys = self.nkeys 363 local nkeys = self.nkeys
364 if nkeys > 1 then 364 if nkeys > 1 then
365 -- ultra slow path, q66 failed optimizing this 365 -- ultra slow path, q66 failed optimizing this
366 -- if you ever get to touch this, increment this
367 -- counter to let others know you failed too.
368 --
369 -- failures: 1
370 --
371 -- fortunately this one is not very commonly used.
366 local atbl 372 local atbl
367 if type(key) == "table" then 373 if type(key) == "table" then
368 atbl = { unpack(key) } 374 atbl = { unpack(key) }
@@ -389,10 +395,19 @@ local prop_proxy_meta = {
389 -- provides alt syntax for getters with keys 395 -- provides alt syntax for getters with keys
390 __call = function(self, ...) 396 __call = function(self, ...)
391 return self.mt[self.key .. "_get"](self.obj, ...) 397 return self.mt[self.key .. "_get"](self.obj, ...)
392 end 398 end,
399
400 -- locks out the proxy
401 __metatable = false
393} 402}
394 403
404-- each __properties field looks like this:
405--
406-- { NUMBER_OF_KEYS, NUMBER_OF_VALUES, GETTABLE, SETTABLE }
407--
408-- the last two are booleans (determining if the property can be get and set).
395ffi.metatype("Eo", { 409ffi.metatype("Eo", {
410 -- handles property getting with no keys and also property setting with keys
396 __index = function(self, key) 411 __index = function(self, key)
397 local mt = get_obj_mt(self) 412 local mt = get_obj_mt(self)
398 if mt == nil then return nil end 413 if mt == nil then return nil end
@@ -406,7 +421,9 @@ ffi.metatype("Eo", {
406 end 421 end
407 local nkeys, nvals = pp[1], pp[2] 422 local nkeys, nvals = pp[1], pp[2]
408 if nkeys ~= 0 then 423 if nkeys ~= 0 then
409 -- proxy - slow path... TODO: find a better way 424 -- proxy - slow path, but no way around it
425 -- basically the proxy is needed because we want nice syntax and
426 -- lua can't do it by default. so we help ourselves a bit with this
410 return setmetatable({ nkeys = nkeys, nvals = nvals, 427 return setmetatable({ nkeys = nkeys, nvals = nvals,
411 obj = self, key = key, mt = mt }, prop_proxy_meta) 428 obj = self, key = key, mt = mt }, prop_proxy_meta)
412 end 429 end
@@ -417,6 +434,7 @@ ffi.metatype("Eo", {
417 end 434 end
418 end, 435 end,
419 436
437 -- handles property setting with no keys
420 __newindex = function(self, key, val) 438 __newindex = function(self, key, val)
421 local mt = get_obj_mt(self) 439 local mt = get_obj_mt(self)
422 if mt == nil then return nil end 440 if mt == nil then return nil end