3.3.2.4 Property Access in Lua

LuaCOM

next up previous contents Next: 3.3.3 Connection Points: handling Up: 3.3.2 Using Methods and Previous: 3.3.2.3 Generic LuaCOM objects   Contents

3.3.2.4 Property Access in Lua

When implementing a COM interface in Lua, LuaCOM also supports the concept of property and of indexed properties. LuaCOM translate property reads and writes to table field accesses:

interface = {}
interface.Test = 1
interface.TestIndex = {2,3}
obj = luacom.ImplInterface(interface, "TEST.Test", "ITest")
-- must print "1"
print(obj.Test)
-- must print nil (if there is no member named Test2)
print(obj.Test2)
-- this writes the filed Test
obj.Test = 1
-- Indexed property read. Must return 3 (remember that
-- indexed tables start at 1 in Lua)
i = obj:TestIndex(2)
-- Sets the indexed field
obj:setTestIndex(2,4)
-- Now must return 4
i = obj:TestIndex(2)



Fabio Mascarenhas de Queiroz 2005-01-07