Commit Graph

60 Commits (528d7b1be146f04d6f2c414e6b932967e3a73e76)

Author SHA1 Message Date
Alexander Gavrilov 85c91c92d8 Implement __pairs and __ipairs for DF objects.
Structs enumerate fields in memory order in pairs().
Containers & biftields enumerate int indexes in ipairs, and
string keys in pairs (i.e. using index-enum for arrays).
2012-03-29 14:39:13 +04:00
Quietust 95ec363a7f Merge branch 'master' of https://github.com/peterix/dfhack
Conflicts:
	library/LuaTypes.cpp
	library/LuaWrapper.cpp
2012-03-28 11:51:49 -05:00
Alexander Gavrilov 929657bed4 Disable pointer auto-vivification unless new is specified.
Since it is essentially allocating non-gc managed objects,
it can lead to memory leaks and shouldn't happen invisibly.
Also support using the 'assign' key to request assign()
from another object before processing the current map.
2012-03-28 17:00:07 +08:00
Alexander Gavrilov b76bdad50f Implement recursive transfer of values from lua to c++ structures.
E.g. df.global.cursor = { x = 1, y = 2, z = 3 }. The lua data
must be represented by raw lua tables.

For structs, the entries in the table are assigned to matching fields.

For containers, if a 'resize' field is missing or nil, the table is
treated like 1-based lua array, and the container is resized to match
its # length. Otherwise, the field must be either an explicit number,
true or false. If it is true, the size is selected by the highest index
in the table. After that, entries are copied using 0-based indices.

For pointers, the table must match the target object. If the pointer
is null, the object is auto-allocated; this can be controlled using
the 'new' field, the value of which will be passed to df.new().
2012-03-28 16:58:51 +08:00
Alexander Gavrilov bc74c5984e Implement recursive transfer of values from lua to c++ structures.
E.g. df.global.cursor = { x = 1, y = 2, z = 3 }. The lua data
must be represented by raw lua tables.

For structs, the entries in the table are assigned to matching fields.

For containers, if a 'resize' field is missing or nil, the table is
treated like 1-based lua array, and the container is resized to match
its # length. Otherwise, the field must be either an explicit number,
true or false. If it is true, the size is selected by the highest index
in the table. After that, entries are copied using 0-based indices.

For pointers, the table must match the target object. If the pointer
is null, the object is auto-allocated; this can be controlled using
the 'new' field, the value of which will be passed to df.new().
2012-03-27 21:47:52 +04:00
Alexander Gavrilov 1d81cb56ba Make enum attributes accessible through the lua wrapper.
TODO: make them completely read-only.
2012-03-25 19:12:59 +04:00
Alexander Gavrilov 7209e4d3f2 Attach static methods to the type objects in the lua wrapper. 2012-03-25 15:20:58 +04:00
Alexander Gavrilov 8d345be6e7 Expose virtual methods in the lua wrapper. 2012-03-25 14:06:05 +04:00
Alexander Gavrilov 0c7fc233bd Support resize/erase/insert for containers, and allow any index in BitArray. 2012-03-24 16:28:53 +04:00
Alexander Gavrilov d865d54a90 Split LuaWrapper.cpp into two files. 2012-03-24 13:25:10 +04:00