Pythn module fixes for 64bit, it gets built now, but doesn't work AFAIK

develop
Petr Mrázek 2010-04-28 23:11:24 +02:00
parent 3853a49d85
commit 61c5e36537
21 changed files with 100 additions and 43 deletions

@ -33,6 +33,7 @@ include_directories (${CMAKE_SOURCE_DIR}/dfhack/depends/tinyxml/)
include_directories (${CMAKE_SOURCE_DIR}/dfhack/depends/argstream/)
add_subdirectory (dfhack)
add_subdirectory (dfhack/python)
#add_subdirectory (dfhack/shm)
#FIXME: add exports for MSVC
#add_subdirectory (dfhack/depends/md5)

@ -383,7 +383,7 @@ namespace DFHack
bool WriteLabors(const uint32_t index, uint8_t labors[NUM_CREATURE_LABORS]);
uint32_t GetDwarfRaceIndex ( void );
int32_t GetDwarfCivId ( void );
bool ReadJob(const t_creature * furball, vector<t_material> & mat);
bool ReadJob(const t_creature * furball, std::vector<t_material> & mat);
private:
struct Private;
Private *d;

@ -17,9 +17,9 @@ namespace DFHack
feature_Other,
feature_Adamantine_Tube,
feature_Underworld,
feature_Hell_Temple,
feature_Hell_Temple
};
static char * sa_feature[]=
static const char * sa_feature[]=
{
"Other",
"Adamantine Tube",

@ -0,0 +1,42 @@
PROJECT (pydfhack)
FIND_PACKAGE(PythonLibs)
SET(PYTHON_MODULE_PREFIX "")
SET(PROJECT_LIBS ${PYTHON_LIBRARIES} dfhack )
IF(UNIX)
add_definitions(-DLINUX_BUILD)
add_definitions(-DUSE_CONFIG_H)
SET(CMAKE_CXX_FLAGS_DEBUG "-g -Wall -pedantic")
SET(PYTHON_MODULE_SUFFIX ".so")
ENDIF(UNIX)
IF(WIN32)
#windows
SET(PYTHON_MODULE_SUFFIX ".pyd")
ENDIF(WIN32)
IF(PYTHONLIBS_FOUND)
INCLUDE_DIRECTORIES(${PYTHON_INCLUDE_PATH})
PYTHON_ADD_MODULE(pydfhack
DF_API.cpp
DF_Buildings.cpp
DF_Constructions.cpp
DF_CreatureManager.cpp
DF_GUI.cpp
DF_Maps.cpp
DF_Material.cpp
DF_Position.cpp
DF_Translate.cpp
DF_Vegetation.cpp
pydfhack.cpp
)
SET_TARGET_PROPERTIES(pydfhack PROPERTIES PREFIX "")
# fix suffix on windows
SET_TARGET_PROPERTIES(pydfhack PROPERTIES SUFFIX ${PYTHON_MODULE_SUFFIX})
TARGET_LINK_LIBRARIES(pydfhack ${PROJECT_LIBS})
ELSE(PYTHONLIBS_FOUND)
MESSAGE("UNABLE TO BUILD PYTHON BINDINGS!")
ENDIF(PYTHONLIBS_FOUND)

@ -144,7 +144,7 @@ static void DF_API_dealloc(DF_API* self)
if(self->api_Ptr != NULL)
{
PySys_WriteStdout("api_Ptr = %i\n", (int)self->api_Ptr);
PySys_WriteStdout("api_Ptr = 0x%x\n", self->api_Ptr);
delete self->api_Ptr;
@ -692,4 +692,4 @@ static PyTypeObject DF_API_type =
DF_API_new, /* tp_new */
};
#endif
#endif

@ -1,6 +1,6 @@
/*
www.sourceforge.net/projects/dfhack
Copyright (c) 2009 Petr Mrázek (peterix), Kenneth Ferland (Impaler[WrG]), dorf, doomchild
Copyright (c) 2009 Petr Mrázek (peterix), Kenneth Ferland (Impaler[WrG]), dorf, doomchild
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
@ -113,7 +113,7 @@ static void DF_Building_dealloc(DF_Building* self)
if(self->b_Ptr != NULL)
{
PySys_WriteStdout("b_Ptr = %i\n", (int)self->b_Ptr);
PySys_WriteStdout("b_Ptr = 0x%x\n", self->b_Ptr);
delete self->b_Ptr;
@ -268,4 +268,4 @@ static PyTypeObject DF_Building_type =
DF_Building_new, /* tp_new */
};
#endif
#endif

@ -1,6 +1,6 @@
/*
www.sourceforge.net/projects/dfhack
Copyright (c) 2009 Petr Mrázek (peterix), Kenneth Ferland (Impaler[WrG]), dorf, doomchild
Copyright (c) 2009 Petr Mrázek (peterix), Kenneth Ferland (Impaler[WrG]), dorf, doomchild
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
@ -104,7 +104,7 @@ static void DF_Construction_dealloc(DF_Construction* self)
if(self->c_Ptr != NULL)
{
PySys_WriteStdout("c_Ptr = %i\n", (int)self->c_Ptr);
PySys_WriteStdout("c_Ptr = 0x%x\n", self->c_Ptr);
delete self->c_Ptr;
@ -217,4 +217,4 @@ static PyTypeObject DF_Construction_type =
DF_Construction_new, /* tp_new */
};
#endif
#endif

@ -1,6 +1,6 @@
/*
www.sourceforge.net/projects/dfhack
Copyright (c) 2009 Petr Mrázek (peterix), Kenneth Ferland (Impaler[WrG]), dorf, doomchild
Copyright (c) 2009 Petr Mrázek (peterix), Kenneth Ferland (Impaler[WrG]), dorf, doomchild
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
@ -27,6 +27,7 @@ distribution.
#include "Python.h"
#include "stdio.h"
#include <vector>
#include "DFTypes.h"
#include "modules/Creatures.h"
#include "DF_CreatureType.cpp"
@ -68,7 +69,7 @@ static void DF_CreatureManager_dealloc(DF_CreatureManager* self)
if(self->creature_Ptr != NULL)
{
PySys_WriteStdout("creature_Ptr = %i\n", (int)self->creature_Ptr);
PySys_WriteStdout("creature_Ptr = 0x%x\n", self->creature_Ptr);
delete self->creature_Ptr;
@ -272,4 +273,4 @@ static PyTypeObject DF_CreatureManager_type =
DF_CreatureManager_new, /* tp_new */
};
#endif
#endif

@ -1,6 +1,6 @@
/*
www.sourceforge.net/projects/dfhack
Copyright (c) 2009 Petr Mrázek (peterix), Kenneth Ferland (Impaler[WrG]), dorf, doomchild
Copyright (c) 2009 Petr Mrázek (peterix), Kenneth Ferland (Impaler[WrG]), dorf, doomchild
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
@ -253,4 +253,4 @@ static PyObject* BuildCreature(DFHack::t_creature& creature)
Py_RETURN_NONE;
}
#endif
#endif

@ -1,6 +1,6 @@
/*
www.sourceforge.net/projects/dfhack
Copyright (c) 2009 Petr Mrázek (peterix), Kenneth Ferland (Impaler[WrG]), dorf, doomchild
Copyright (c) 2009 Petr Mrázek (peterix), Kenneth Ferland (Impaler[WrG]), dorf, doomchild
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
@ -64,7 +64,7 @@ static void DF_GUI_dealloc(DF_GUI* self)
if(self->g_Ptr != NULL)
{
PySys_WriteStdout("g_Ptr = %i\n", (int)self->g_Ptr);
PySys_WriteStdout("g_Ptr = 0x%x\n", self->g_Ptr);
delete self->g_Ptr;
@ -203,4 +203,4 @@ static PyTypeObject DF_GUI_type =
DF_GUI_new, /* tp_new */
};
#endif
#endif

@ -1,6 +1,6 @@
/*
www.sourceforge.net/projects/dfhack
Copyright (c) 2009 Petr Mrázek (peterix), Kenneth Ferland (Impaler[WrG]), dorf, doomchild
Copyright (c) 2009 Petr Mrázek (peterix), Kenneth Ferland (Impaler[WrG]), dorf, doomchild
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
@ -365,4 +365,4 @@ static PyObject* BuildSoul(DFHack::t_soul& soul)
return soulObj;
}
#endif
#endif

@ -1,6 +1,6 @@
/*
www.sourceforge.net/projects/dfhack
Copyright (c) 2009 Petr Mrázek (peterix), Kenneth Ferland (Impaler[WrG]), dorf, doomchild
Copyright (c) 2009 Petr Mrázek (peterix), Kenneth Ferland (Impaler[WrG]), dorf, doomchild
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
@ -97,4 +97,4 @@ static void DoImports()
}
}
#endif
#endif

@ -1,6 +1,6 @@
/*
www.sourceforge.net/projects/dfhack
Copyright (c) 2009 Petr Mrázek (peterix), Kenneth Ferland (Impaler[WrG]), dorf, doomchild
Copyright (c) 2009 Petr Mrázek (peterix), Kenneth Ferland (Impaler[WrG]), dorf, doomchild
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
@ -32,6 +32,7 @@ distribution.
using namespace std;
#include "DFTypes.h"
#include <map>
#include "modules/Maps.h"
#include "DF_Imports.cpp"
#include "DF_Helpers.cpp"
@ -391,7 +392,7 @@ static void DF_Map_dealloc(DF_Map* self)
if(self->m_Ptr != NULL)
{
PySys_WriteStdout("m_Ptr = %i\n", (int)self->m_Ptr);
PySys_WriteStdout("m_Ptr = 0x%x\n", self->m_Ptr);
delete self->m_Ptr;
@ -857,4 +858,4 @@ static PyTypeObject DF_Map_type =
DF_Map_new, /* tp_new */
};
#endif
#endif

@ -1,6 +1,6 @@
/*
www.sourceforge.net/projects/dfhack
Copyright (c) 2009 Petr Mrázek (peterix), Kenneth Ferland (Impaler[WrG]), dorf, doomchild
Copyright (c) 2009 Petr Mrázek (peterix), Kenneth Ferland (Impaler[WrG]), dorf, doomchild
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
@ -244,7 +244,7 @@ static void DF_Material_dealloc(DF_Material* self)
if(self->mat_Ptr != NULL)
{
PySys_WriteStdout("mat_Ptr = %i\n", (int)self->mat_Ptr);
PySys_WriteStdout("mat_Ptr = 0x%x\n", self->mat_Ptr);
delete self->mat_Ptr;
@ -421,4 +421,4 @@ static PyTypeObject DF_Material_type =
DF_Material_new, /* tp_new */
};
#endif
#endif

@ -1,6 +1,6 @@
/*
www.sourceforge.net/projects/dfhack
Copyright (c) 2009 Petr Mrázek (peterix), Kenneth Ferland (Impaler[WrG]), dorf, doomchild
Copyright (c) 2009 Petr Mrázek (peterix), Kenneth Ferland (Impaler[WrG]), dorf, doomchild
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
@ -71,7 +71,7 @@ static void DF_MemInfo_dealloc(DF_MemInfo* self)
if(self->mem_Ptr != NULL)
{
PySys_WriteStdout("mem_Ptr = %i\n", (int)self->mem_Ptr);
PySys_WriteStdout("mem_Ptr = 0x%x\n", self->mem_Ptr);
delete self->mem_Ptr;
@ -681,4 +681,4 @@ static PyTypeObject DF_MemInfo_type =
DF_MemInfo_new, /* tp_new */
};
#endif
#endif

@ -1,6 +1,6 @@
/*
www.sourceforge.net/projects/dfhack
Copyright (c) 2009 Petr Mrázek (peterix), Kenneth Ferland (Impaler[WrG]), dorf, doomchild
Copyright (c) 2009 Petr Mrázek (peterix), Kenneth Ferland (Impaler[WrG]), dorf, doomchild
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
@ -198,4 +198,4 @@ static PyTypeObject DF_Position_type =
DF_Position_new, /* tp_new */
};
#endif
#endif

@ -1,6 +1,6 @@
/*
www.sourceforge.net/projects/dfhack
Copyright (c) 2009 Petr Mrázek (peterix), Kenneth Ferland (Impaler[WrG]), dorf, doomchild
Copyright (c) 2009 Petr Mrázek (peterix), Kenneth Ferland (Impaler[WrG]), dorf, doomchild
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
@ -75,7 +75,7 @@ static void DF_Translate_dealloc(DF_Translate* self)
{
Py_XDECREF(self->dict);
PySys_WriteStdout("tran_Ptr = %i\n", (int)self->tran_Ptr);
PySys_WriteStdout("tran_Ptr = 0x%x\n", self->tran_Ptr);
delete self->tran_Ptr;
@ -284,4 +284,4 @@ static PyTypeObject DF_Translate_type =
DF_Translate_new, /* tp_new */
};
#endif
#endif

@ -1,6 +1,6 @@
/*
www.sourceforge.net/projects/dfhack
Copyright (c) 2009 Petr Mrázek (peterix), Kenneth Ferland (Impaler[WrG]), dorf, doomchild
Copyright (c) 2009 Petr Mrázek (peterix), Kenneth Ferland (Impaler[WrG]), dorf, doomchild
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
@ -78,7 +78,7 @@ static void DF_Vegetation_dealloc(DF_Vegetation* self)
if(self->veg_Ptr != NULL)
{
PySys_WriteStdout("veg_Ptr = %i\n", (int)self->veg_Ptr);
PySys_WriteStdout("veg_Ptr = 0x%x\n", self->veg_Ptr);
delete self->veg_Ptr;
@ -191,4 +191,4 @@ static PyTypeObject DF_Vegetation_type =
DF_Vegetation_new, /* tp_new */
};
#endif
#endif

@ -0,0 +1,12 @@
# -*- coding: utf-8 -*-
from distutils.core import setup, Extension
e = Extension("pydfhack",
sources=["DF_API.cpp", "DF_Buildings.cpp", "DF_Constructions.cpp", "DF_CreatureManager.cpp", "DF_GUI.cpp", "DF_Maps.cpp", "DF_Material.cpp", "DF_Position.cpp", "DF_Translate.cpp", "DF_Vegetation.cpp", "pydfhack.cpp"],
include_dirs=["../", "../include", "../depends/md5", "../depends/tinyxml"],
library_dirs=["../../output"],
extra_compile_args=["-DLINUX_BUILD"],
libraries=["dfhack-debug"],
export_symbols=["initpydfhack", "ReadRaw", "WriteRaw"])
setup(name="PyDFHack", version="1.0", ext_modules=[e])

@ -1,6 +1,6 @@
/*
www.sourceforge.net/projects/dfhack
Copyright (c) 2009 Petr Mrázek (peterix), Kenneth Ferland (Impaler[WrG]), dorf, doomchild
Copyright (c) 2009 Petr Mrázek (peterix), Kenneth Ferland (Impaler[WrG]), dorf, doomchild
This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any
@ -132,4 +132,4 @@ PyMODINIT_FUNC initpydfhack(void)
DoImports();
}
}

@ -3,7 +3,7 @@ from distutils.core import setup, Extension
e = Extension("pydfhack",
sources=["DF_API.cpp", "DF_Buildings.cpp", "DF_Constructions.cpp", "DF_CreatureManager.cpp", "DF_GUI.cpp", "DF_Maps.cpp", "DF_Material.cpp", "DF_Position.cpp", "DF_Translate.cpp", "DF_Vegetation.cpp", "pydfhack.cpp"],
include_dirs=["..\\", "..\\include", "..\\depends\\md5", "..\\depends\\tinyxml"],
include_dirs=["../", "../include", "../depends/md5", "../depends/tinyxml"],
library_dirs=["..\\..\\output"],
#extra_compile_args=["-w"],
libraries=["libdfhack"],