next up previous contents
Next: 2.3.3 Connection Points Up: 2.3.2 Using Methods and Previous: Generic LuaCOM objects   Contents 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"

-- must print nil (if there is no member named 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

-- Now must return 4
i = obj:TestIndex(2)

Vinicius da Silva Almendra 2003-06-27