From 562c30c7031f96b9234fe8e13454f6753669a15a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Fri, 26 Feb 2010 22:23:43 +0100 Subject: [PATCH] Python stuffs --- library/dfhack.i | 27 +++++++++++++++++++++++++++ output/stones.py | 9 +++++++++ 2 files changed, 36 insertions(+) create mode 100644 library/dfhack.i create mode 100644 output/stones.py diff --git a/library/dfhack.i b/library/dfhack.i new file mode 100644 index 000000000..bf10d4339 --- /dev/null +++ b/library/dfhack.i @@ -0,0 +1,27 @@ +%module dfhack +%include "std_string.i" +%include "std_vector.i" +%include "stdint.i" +%{ +/* Includes the header in the wrapper code */ +#define LINUX_BUILD +#define SWIG_WRAPPER +#include "DFTypes.h" +#include "DFHackAPI.h" +using namespace std; +using namespace DFHack; +%} + +/* templates have to be instantiated for swig */ +using namespace std; +namespace std +{ + %template(MatglossVector) vector; + %template(PlantMatglossVector) vector; + %template(VeinVector) std::vector ; + %template(IceVeinVector) std::vector ; +} + +/* Parse the header file to generate wrappers */ +%include "DFTypes.h" +%include "DFHackAPI.h" \ No newline at end of file diff --git a/output/stones.py b/output/stones.py new file mode 100644 index 000000000..8014a4aec --- /dev/null +++ b/output/stones.py @@ -0,0 +1,9 @@ +import dfhack +x = dfhack.API("Memory.xml") +y = dfhack.MatglossVector() + +if x.Attach(): + if x.ReadStoneMatgloss(y): + print "Dumping all stone" + for matgloss in y: + print "ID %s, name %s" % (matgloss.id, matgloss.name)