ivansafrin/Polycode — Issue #77: Lua code can't work with container/array ObjectEntries
Author: mcclure
Created: 2011-12-27 09:20:25+00:00
State: open

Following is with Polycode c3c534c with minor patches and I can provide sample code if helpful.

I have, in lua, a reference a to an array ObjectEntry. I ask for a[1]. I get nil.

Confused, I experimentally see if it would like a Container ObjectEntry better. I create a container objectentry with keys "one" and "two". I get a reference to it in Lua. I ask for a["one"]. I get nil.

I then look at the ObjectEntry.lua in the api.pak and see

```C++
function ObjectEntry:__index__(name)
if name == "type" then
return Polycore.ObjectEntry_get_type(self.__ptr)
elseif name == "name" then
return Polycore.ObjectEntry_get_name(self.__ptr)
elseif name == "NumberVal" then
return Polycore.ObjectEntry_get_NumberVal(self.__ptr)
elseif name == "intVal" then
return Polycore.ObjectEntry_get_intVal(self.__ptr)
elseif name == "stringVal" then
return Polycore.ObjectEntry_get_stringVal(self.__ptr)
elseif name == "boolVal" then
return Polycore.ObjectEntry_get_boolVal(self.__ptr)
elseif name == "length" then
return Polycore.ObjectEntry_get_length(self.__ptr)
end
end
```

In other words, "index" on an ObjectEntry asks for these fields, rather than giving access to either of the operator[] methods. If I say a["length"] or a["type"] these give me back meaningful values. But there is no way, looking at objectEntry.lua, given an ObjectEntry, to access any child of that ObjectEntry.

I'm interested in this because of http://polycode.org/forum/viewtopic.php?f=4&t=284