next up previous contents
Next: 2.3.3 Connection Points Up: 2.3.2 Using Methods and Previous: 2.3.2.1 Generic LuaCOM objects   Contents

2.3.2.2 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)


Vinicius da Silva Almendra 2003-06-27