Changes for better SWIG support

develop
Petr Mrázek 2010-02-26 22:22:10 +01:00
parent 626d266e27
commit 347eb66d21
12 changed files with 230 additions and 205 deletions

@ -1,6 +1,3 @@
// Attach test
// attachtest - 100x attach/detach, 100x reads, 100x writes
#include <iostream>
#include <climits>
#include <integers.h>
@ -39,6 +36,12 @@ int main (void)
cout << "Metal: " << Metals[0].id << endl;
cout << "Stone: " << Stones[0].id << endl;
cout << "Creature: " << CreatureTypes[0].id << endl;
cout << endl;
cout << "Dumping all stones!" << endl;
for(int i = 0; i < Stones.size();i++)
{
cout << Stones[i].id << "$" << endl;;
}
DF.Detach();
#ifndef LINUX_BUILD

@ -25,7 +25,7 @@ distribution.
#ifndef DFCOMMONINTERNAL_H_INCLUDED
#define DFCOMMONINTERNAL_H_INCLUDED
#include <Tranquility.h>
#include "Tranquility.h"
#include <string>
#include <vector>

@ -25,14 +25,14 @@ distribution.
#ifndef SIMPLEAPI_H_INCLUDED
#define SIMPLEAPI_H_INCLUDED
#include <Tranquility.h>
#include "Tranquility.h"
#include "Export.h"
#include <string>
#include <vector>
#include <map>
#include "integers.h"
#include "DFTileTypes.h"
#include "DFTypes.h"
#include "DFWindow.h"
namespace DFHack
@ -44,7 +44,7 @@ namespace DFHack
class Private;
Private * const d;
public:
API(const string path_to_xml);
API(const std::string path_to_xml);
~API();
bool Attach();
bool Detach();
@ -76,12 +76,12 @@ namespace DFHack
* I'll keep it like this, even with the code duplication as it will hopefully get more features and separate data types later.
* Yay for nebulous plans for a rock survey tool that tracks how much of which metal could be smelted from available resorces
*/
bool ReadStoneMatgloss(vector<t_matgloss> & output);
bool ReadWoodMatgloss (vector<t_matgloss> & output);
bool ReadMetalMatgloss(vector<t_matgloss> & output);
bool ReadPlantMatgloss(vector<t_matgloss> & output);
bool ReadPlantMatgloss (vector<t_matglossPlant> & plants);
bool ReadCreatureMatgloss(vector<t_matgloss> & output);
bool ReadStoneMatgloss(std::vector<t_matgloss> & output);
bool ReadWoodMatgloss (std::vector<t_matgloss> & output);
bool ReadMetalMatgloss(std::vector<t_matgloss> & output);
bool ReadPlantMatgloss(std::vector<t_matgloss> & output);
bool ReadPlantMatgloss (std::vector<t_matglossPlant> & plants);
bool ReadCreatureMatgloss(std::vector<t_matgloss> & output);
// read region surroundings, get their vectors of geolayers so we can do translation (or just hand the translation table to the client)
// returns an array of 9 vectors of indices into stone matgloss
@ -114,7 +114,7 @@ namespace DFHack
}
}
*/
bool ReadGeology( vector < vector <uint16_t> >& assign );
bool ReadGeology( std::vector < std::vector <uint16_t> >& assign );
/*
* BLOCK DATA
@ -151,7 +151,7 @@ namespace DFHack
bool ReadRegionOffsets(uint32_t blockx, uint32_t blocky, uint32_t blockz, uint8_t *buffer); // 16 * sizeof(uint8_t)
/// read aggregated veins of a block
bool ReadVeins(uint32_t blockx, uint32_t blocky, uint32_t blockz, vector <t_vein> & veins, vector <t_frozenliquidvein>& ices);
bool ReadVeins(uint32_t blockx, uint32_t blocky, uint32_t blockz, std::vector <t_vein> & veins, std::vector <t_frozenliquidvein>& ices);
/**
* Buildings, constructions, plants, all pretty straighforward. InitReadBuildings returns all the building types as a mapping between a numeric values and strings
@ -200,13 +200,15 @@ namespace DFHack
bool setCursorCoords (const int32_t &x, const int32_t &y, const int32_t &z);
/// This returns false if there is nothing under the cursor, it puts the addresses in a vector if there is
bool getCurrentCursorCreatures(vector<uint32_t> &addresses);
bool getCurrentCursorCreatures(std::vector<uint32_t> &addresses);
bool InitViewSize();
bool getWindowSize(int32_t & width, int32_t & height);
/* unimplemented
bool setWindowSize(const int32_t & width, const int32_t & height);
*/
void getItemIndexesInBox(vector<uint32_t> &indexes,
void getItemIndexesInBox(std::vector<uint32_t> &indexes,
const uint16_t &x1, const uint16_t &y1, const uint16_t &z1,
const uint16_t &x2, const uint16_t &y2, const uint16_t &z2);
/*
@ -219,12 +221,12 @@ namespace DFHack
vector<t_trait> getTraits(const uint32_t &index);
vector<t_labor> getLabors(const uint32_t &index);
*/
bool InitReadNameTables (map< string, vector<string> > & nameTable);
bool InitReadNameTables (std::map< std::string, std::vector<std::string> > & nameTable);
void FinishReadNameTables();
string TranslateName(const t_lastname & last, const map< string, vector< string > > &nameTable,const string & language="GENERIC");
string TranslateName(const t_squadname & squad, const map< string, vector< string > > &nameTable,const string & language="GENERIC");
string TranslateName (const int names[], int size, const map<string, vector<string> > & nameTable, const string & language="GENERIC");
std::string TranslateName(const t_lastname & last, const std::map< std::string, std::vector< std::string > > &nameTable,const std::string & language="GENERIC");
std::string TranslateName(const t_squadname & squad, const std::map< std::string, std::vector< std::string > > &nameTable,const std::string & language="GENERIC");
std::string TranslateName (const int names[], int size, const std::map<std::string, std::vector<std::string> > &nameTable, const std::string & language="GENERIC");
void WriteLabors(const uint32_t &index, uint8_t labors[NUM_CREATURE_LABORS]);
@ -239,7 +241,7 @@ namespace DFHack
// FIXME: BAD!
bool ReadAllMatgloss(vector< vector< string > > & all);
*/
bool ReadItemTypes(vector< vector< t_itemType > > & itemTypes);
bool ReadItemTypes(std::vector< std::vector< t_itemType > > & itemTypes);
};
} // namespace DFHack
#endif // SIMPLEAPI_H_INCLUDED

@ -25,7 +25,7 @@ distribution.
#ifndef MEMINFO_H_INCLUDED
#define MEMINFO_H_INCLUDED
#include <Tranquility.h>
#include "Tranquility.h"
#include "Export.h"
#include <map>

@ -25,7 +25,7 @@ distribution.
#ifndef MEMINFO_MANAGER_H_INCLUDED
#define MEMINFO_MANAGER_H_INCLUDED
#include <Tranquility.h>
#include "Tranquility.h"
namespace DFHack
{

@ -25,7 +25,7 @@ distribution.
#ifndef PROCESS_H_INCLUDED
#define PROCESS_H_INCLUDED
#include <Tranquility.h>
#include "Tranquility.h"
#include "Export.h"
namespace DFHack

@ -25,7 +25,7 @@ distribution.
#ifndef PROCESSMANAGER_H_INCLUDED
#define PROCESSMANAGER_H_INCLUDED
#include <Tranquility.h>
#include "Tranquility.h"
#include "Export.h"
class TiXmlElement;

@ -25,7 +25,7 @@ distribution.
#ifndef TILETYPES_H_INCLUDED
#define TILETYPES_H_INCLUDED
#include <Tranquility.h>
#include "Tranquility.h"
namespace DFHack
{

@ -25,7 +25,7 @@ distribution.
#ifndef TYPES_H_INCLUDED
#define TYPES_H_INCLUDED
#include <Tranquility.h>
#include "Tranquility.h"
#include "Export.h"
namespace DFHack
@ -269,10 +269,8 @@ bits:
31 Is an important historical figure
*/
union t_creaturflags1
struct naked_creaturflags1
{
uint32_t whole;
struct {
unsigned int move_state : 1; // Can the dwarf move or are they waiting for their movement timer
unsigned int dead : 1; // might also be set for incoming/leaving critters that are alive
unsigned int has_mood : 1; // Currently in mood
@ -313,8 +311,12 @@ union t_creaturflags1
unsigned int fortress_guard : 1;
unsigned int suppress_wield : 1; // Suppress wield for beatings/etc
unsigned int important_historical_figure : 1; // Is an important historical figure
};
} bits;
union t_creaturflags1
{
uint32_t whole;
naked_creaturflags1 bits;
};
/*
@ -360,11 +362,8 @@ bits:
30 Roaming wilderness population source
31 Roaming wilderness population source -- not a map feature
*/
union t_creaturflags2
struct naked_creaturflags2
{
uint32_t whole;
struct {
unsigned int swimming : 1;
unsigned int sparring : 1;
unsigned int no_notify : 1; // Do not notify about level gains (for embark etc)
@ -405,8 +404,13 @@ union t_creaturflags2
unsigned int roaming_wilderness_population_source : 1;
unsigned int roaming_wilderness_population_source_not_a_map_feature : 1;
} bits;
};
union t_creaturflags2
{
uint32_t whole;
naked_creaturflags2 bits;
};
/*
struct t_labor
{
@ -559,12 +563,11 @@ struct t_item_df40d
uint32_t ID;
// not complete
};
//From http://dwarffortresswiki.net/index.php/User:Rick/Memory_research
//They all seem to be valid on 40d as well
union t_itemflags
struct naked_itemflags
{
uint32_t whole;
struct {
unsigned int on_ground : 1; // Item on ground
unsigned int in_job : 1; // item currently being used in a job
unsigned int in_inventory : 1; // Item in a creatures inventory
@ -605,8 +608,12 @@ union t_itemflags
unsigned int unk9 : 1; // unknown function
unsigned int unk10 : 1; // unknown function
unsigned int unk11 : 1; // unknown function
};
} bits;
union t_itemflags
{
uint32_t whole;
naked_itemflags bits;
};
//cooked
@ -659,10 +666,8 @@ enum e_designation
designation_7 // whatever
};
union t_designation
struct naked_designation
{
uint32_t whole;
struct {
unsigned int flow_size : 3; // how much liquid is here?
unsigned int pile : 1; // stockpile?
/*
@ -687,8 +692,8 @@ union t_designation
*/
unsigned int biome : 4;
/*
0 = water
1 = magma
* 0 = water
* 1 = magma
*/
unsigned int liquid_type : 1;
unsigned int water_table : 1; // srsly. wtf?
@ -699,14 +704,17 @@ union t_designation
unsigned int moss : 1;// I LOVE MOSS
unsigned int feature_present : 1; // another wtf... is this required for magma pipes to work?
unsigned int liquid_character : 2; // those ripples on streams?
} bits;
};
// occupancy flags (rat,dwarf,horse,built wall,not build wall,etc)
union t_occupancy
union t_designation
{
uint32_t whole;
struct {
naked_designation bits;
};
// occupancy flags (rat,dwarf,horse,built wall,not build wall,etc)
struct naked_occupancy
{
unsigned int building : 3;// building type... should be an enum?
// 7 = door
unsigned int unit : 1;
@ -736,8 +744,10 @@ union t_occupancy
unsigned int blood2 : 1;
unsigned int broken_arrows_variant : 1;
unsigned int snow : 1;
} bits;
struct {
};
struct naked_occupancy_grouped
{
unsigned int building : 3;// building type... should be an enum?
// 7 = door
unsigned int unit : 1;
@ -745,7 +755,13 @@ union t_occupancy
unsigned int item : 1;
// splatter. everyone loves splatter.
unsigned int splatter : 26;
} unibits;
};
union t_occupancy
{
uint32_t whole;
naked_occupancy bits;
naked_occupancy_grouped unibits;
};
struct t_viewscreen

@ -25,7 +25,7 @@ distribution.
#ifndef DFVECTOR_H_INCLUDED
#define DFVECTOR_H_INCLUDED
#include <Tranquility.h>
#include "Tranquility.h"
namespace DFHack
{

@ -25,7 +25,7 @@ distribution.
#ifndef KEYS_H_INCLUDED
#define KEYS_H_INCLUDED
#include <Tranquility.h>
#include "Tranquility.h"
#include "Export.h"
namespace DFHack

@ -24,7 +24,11 @@ distribution.
#ifdef LINUX_BUILD
#ifndef DFHACK_EXPORT
#ifndef SWIGIMPORTED
#define DFHACK_EXPORT __attribute__ ((visibility("default")))
#else
#define DFHACK_EXPORT
#endif
#endif
#else
#ifdef BUILD_DFHACK_LIB