diff --git a/plugins/Dfusion/CMakeLists.txt b/plugins/Dfusion/CMakeLists.txt
index 8ac2e79e9..c7f71c71c 100644
--- a/plugins/Dfusion/CMakeLists.txt
+++ b/plugins/Dfusion/CMakeLists.txt
@@ -13,3 +13,4 @@ DFHACK_PLUGIN(dfusion ${DFUSION_CPPS_ALL} ${DFUSION_HS} LINK_LIBRARIES lua)
# installs into DF root
install(DIRECTORY luafiles/ DESTINATION dfusion)
+install(FILES ../../library/include/df/codegen.out.xml DESTINATION dfusion/patterns/)
\ No newline at end of file
diff --git a/plugins/Dfusion/luafiles/patterns/supplementary.xml b/plugins/Dfusion/luafiles/patterns/supplementary.xml
new file mode 100644
index 000000000..e341a1368
--- /dev/null
+++ b/plugins/Dfusion/luafiles/patterns/supplementary.xml
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/plugins/Dfusion/luafiles/xml_struct.lua b/plugins/Dfusion/luafiles/xml_struct.lua
index 0a6b54138..7baa5c48a 100644
--- a/plugins/Dfusion/luafiles/xml_struct.lua
+++ b/plugins/Dfusion/luafiles/xml_struct.lua
@@ -84,7 +84,7 @@ local df_meta={}
function df_meta:__index(key)
local addr=VersionInfo.getAddress(key)
local vartype=rawget(df,"types")[key];
- if addr==nil then
+ if addr==0 then
error("No such global address exist")
elseif vartype==nil then
error("No such global type exist")
@@ -95,7 +95,7 @@ end
function df_meta:__newindex(key,val)
local addr=VersionInfo.getAddress(key)
local vartype=rawget(df,"types")[key];
- if addr==nil then
+ if addr==0 then
error("No such global address exist")
elseif vartype==nil then
error("No such global type exist")
@@ -129,3 +129,26 @@ for k,v in pairs(labels) do
end
end
end--]=]
+function addressOf(var)
+ local addr=rawget(var,"ptr")
+ return addr
+end
+function printGlobals()
+ print("Globals:")
+ for k,v in pairs(rawget(df,"types")) do
+ print(k)
+ end
+end
+function printFields(object)
+ local tbl
+ if getmetatable(object)==xtypes["struct-type"].wrap then
+ tbl=rawget(object,"mtype")
+ elseif getmetatable(object)==xtypes["struct-type"] then
+ tbl=object
+ else
+ error("Not an class_type or a class_object")
+ end
+ for k,v in pairs(tbl.types) do
+ print(k)
+ end
+end
\ No newline at end of file
diff --git a/plugins/Dfusion/luafiles/xml_types.lua b/plugins/Dfusion/luafiles/xml_types.lua
index b96e77b47..e1c870f24 100644
--- a/plugins/Dfusion/luafiles/xml_types.lua
+++ b/plugins/Dfusion/luafiles/xml_types.lua
@@ -1,13 +1,13 @@
function type_read(valtype,address)
if valtype.issimple then
- print("Simple read:"..tostring(valtype.ctype))
+ --print("Simple read:"..tostring(valtype.ctype))
return engine.peek(address,valtype.ctype)
else
return valtype:makewrap(address)
end
end
function type_write(valtype,address,val)
- if altype.issimple then
+ if valtype.issimple then
engine.poke(address,valtype.ctype,val)
else
engine.poke(address,DWORD,rawget(val,"ptr"))
@@ -20,6 +20,15 @@ function first_of_type(node,labelname)
end
end
end
+function padAddress(curoff,sizetoadd) --return new offset to place things
+ --windows -> sizeof(x)==alignof(x)
+ if sizetoadd>8 then sizetoadd=8 end
+ if(math.mod(curoff,sizetoadd)==0) then
+ return curoff
+ else
+ return curoff+(sizetoadd-math.mod(curoff,sizetoadd))
+ end
+end
xtypes={} -- list of all types prototypes (e.g. enum-type -> announcement_type)
-- type must have new and makewrap (that makes a wrapper around ptr)
local sarr={}
@@ -27,13 +36,13 @@ sarr.__index=sarr
function sarr.new(node)
local o={}
setmetatable(o,sarr)
- print("Making array.")
+ --print("Making array.")
o.count=tonumber(node.xarg.count)
- print("got cound:"..o.count)
+ --print("got count:"..o.count)
o.ctype=makeType(first_of_type(node,"ld:item"))
o.size=o.count*o.ctype.size
- print("got subtypesize:"..o.ctype.size)
+ --print("got subtypesize:"..o.ctype.size)
return o
end
function sarr:makewrap(address)
@@ -45,6 +54,9 @@ function sarr:makewrap(address)
end
sarr.wrap={}
function sarr.wrap:__index(key)
+ if key=="size" then
+ return rawget(self,"mtype").count
+ end
local num=tonumber(key)
local mtype=rawget(self,"mtype")
if num~=nil and num