externed callback declarations to fix multiple declaration errors

develop
doomchild 2010-05-25 15:36:50 -05:00
parent af354e2dee
commit d9aa16245a
2 changed files with 42 additions and 129 deletions

@ -32,137 +32,45 @@ using namespace std;
#include "DFCommonInternal.h"
#include "DFTypes.h"
#include "modules/Materials.h"
#include "DFTypes_C.h"
#include "modules/Materials.h"
using namespace DFHack;
/*
#ifdef __cplusplus
extern "C" {
#endif
c_colormodifier* ColorModifier_New()
{
c_colormodifier* temp;
temp = (c_colormodifier*)malloc(sizeof(c_colormodifier));
if(temp == NULL)
return NULL;
temp->part[0] = '\0';
temp->colorlist = NULL;
temp->colorlistLength = 0;
return temp;
}
void ColorModifier_Free(c_colormodifier* src)
{
if(src != NULL)
{
if(src->colorlist != NULL)
free(src->colorlist);
free(src);
}
}
c_creaturecaste* CreatureCaste_New()
{
c_creaturecaste* temp;
temp = (c_creaturecaste*)malloc(sizeof(c_creaturecaste));
if(temp == NULL)
return NULL;
temp->rawname[0] = '\0';
temp->singular[0] = '\0';
temp->plural[0] = '\0';
temp->adjective[0] = '\0';
temp->ColorModifier = NULL;
temp->colorModifierLength = 0;
temp->bodypart = NULL;
temp->bodypartLength = 0;
int8_t* (*alloc_byte_buffer_callback)(uint32_t) = NULL;
int16_t* (*alloc_short_buffer_callback)(uint32_t) = NULL;
int32_t* (*alloc_int_buffer_callback)(uint32_t) = NULL;
return temp;
}
void CreatureCaste_Free(c_creaturecaste* src)
{
if(src != NULL)
{
if(src->bodypart != NULL)
free(src->bodypart);
if(src->ColorModifier != NULL)
{
for(int i = 0; i < src->colorModifierLength; i++)
ColorModifier_Free(&src->ColorModifier[i]);
free(src->ColorModifier);
}
free(src);
}
}
c_creaturetype* CreatureType_New()
{
c_creaturetype* temp;
temp = (c_creaturetype*)malloc(sizeof(c_creaturetype));
if(temp == NULL)
return NULL;
uint8_t* (*alloc_ubyte_buffer_callback)(uint32_t) = NULL;
uint16_t* (*alloc_ushort_buffer_callback)(uint32_t) = NULL;
uint32_t* (*alloc_uint_buffer_callback)(uint32_t) = NULL;
temp->rawname[0] = '\0';
char* (*alloc_char_buffer_callback)(uint32_t) = NULL;
temp->castes = NULL;
temp->castesCount = 0;
t_matgloss* (*alloc_matgloss_buffer_callback)(int) = NULL;
t_descriptor_color* (*alloc_descriptor_buffer_callback)(int) = NULL;
t_matglossOther* (*alloc_matgloss_other_buffer_callback)(int) = NULL;
temp->extract = NULL;
temp->extractCount = 0;
c_colormodifier* (*alloc_empty_colormodifier_callback)(void) = NULL;
c_colormodifier* (*alloc_colormodifier_callback)(const char*, uint32_t) = NULL;
c_colormodifier* (*alloc_colormodifier_buffer_callback)(uint32_t) = NULL;
temp->tile_character = 0;
c_creaturecaste* (*alloc_empty_creaturecaste_callback)(void) = NULL;
c_creaturecaste* (*alloc_creaturecaste_callback)(const char*, const char*, const char*, const char*, uint32_t, uint32_t) = NULL;
c_creaturecaste* (*alloc_creaturecaste_buffer_callback)(uint32_t) = NULL;
temp->tilecolor.fore = 0;
temp->tilecolor.back = 0;
temp->tilecolor.bright = 0;
return temp;
}
void CreatureType_Free(c_creaturetype* src)
{
if(src != NULL)
{
if(src->castes != NULL)
{
for(int i = 0; i < src->castesCount; i++)
CreatureCaste_Free(&src->castes[i]);
free(src->castes);
}
if(src->extract != NULL)
free(src->extract);
free(src);
}
}
c_creaturetype* (*alloc_empty_creaturetype_callback)(void) = NULL;
c_creaturetype* (*alloc_creaturetype_callback)(const char*, uint32_t, uint32_t, uint8_t, uint16_t, uint16_t, uint16_t) = NULL;
c_creaturetype* (*alloc_creaturetype_buffer_callback)(uint32_t) = NULL;
#ifdef __cplusplus
}
#endif
*/
int ColorListConvert(t_colormodifier* src, c_colormodifier* dest)
{
if(src == NULL)

@ -29,7 +29,6 @@ distribution.
#include "integers.h"
#include "DFTypes.h"
#include "modules/Materials.h"
#include "DFHackAPI_C.h"
using namespace DFHack;
@ -37,13 +36,19 @@ using namespace DFHack;
extern "C" {
#endif
int8_t* (*alloc_byte_buffer_callback)(uint32_t);
int16_t* (*alloc_short_buffer_callback)(uint32_t);
int32_t* (*alloc_int_buffer_callback)(uint32_t);
DFHACK_EXPORT extern int8_t* (*alloc_byte_buffer_callback)(uint32_t);
DFHACK_EXPORT extern int16_t* (*alloc_short_buffer_callback)(uint32_t);
DFHACK_EXPORT extern int32_t* (*alloc_int_buffer_callback)(uint32_t);
uint8_t* (*alloc_ubyte_buffer_callback)(uint32_t);
uint16_t* (*alloc_ushort_buffer_callback)(uint32_t);
uint32_t* (*alloc_uint_buffer_callback)(uint32_t);
DFHACK_EXPORT extern uint8_t* (*alloc_ubyte_buffer_callback)(uint32_t);
DFHACK_EXPORT extern uint16_t* (*alloc_ushort_buffer_callback)(uint32_t);
DFHACK_EXPORT extern uint32_t* (*alloc_uint_buffer_callback)(uint32_t);
DFHACK_EXPORT extern char* (*alloc_char_buffer_callback)(uint32_t);
DFHACK_EXPORT extern t_matgloss* (*alloc_matgloss_buffer_callback)(int);
DFHACK_EXPORT extern t_descriptor_color* (*alloc_descriptor_buffer_callback)(int);
DFHACK_EXPORT extern t_matglossOther* (*alloc_matgloss_other_buffer_callback)(int);
struct c_colormodifier
{
@ -52,9 +57,9 @@ struct c_colormodifier
uint32_t colorlistLength;
};
c_colormodifier* (*alloc_empty_colormodifier_callback)(void);
c_colormodifier* (*alloc_colormodifier_callback)(const char*, uint32_t);
c_colormodifier* (*alloc_colormodifier_buffer_callback)(uint32_t);
DFHACK_EXPORT extern c_colormodifier* (*alloc_empty_colormodifier_callback)(void);
DFHACK_EXPORT extern c_colormodifier* (*alloc_colormodifier_callback)(const char*, uint32_t);
DFHACK_EXPORT extern c_colormodifier* (*alloc_colormodifier_buffer_callback)(uint32_t);
struct c_creaturecaste
{
@ -70,9 +75,9 @@ struct c_creaturecaste
uint32_t bodypartLength;
};
c_creaturecaste* (*alloc_empty_creaturecaste_callback)(void);
c_creaturecaste* (*alloc_creaturecaste_callback)(const char*, const char*, const char*, const char*, uint32_t, uint32_t);
c_creaturecaste* (*alloc_creaturecaste_buffer_callback)(uint32_t);
DFHACK_EXPORT extern c_creaturecaste* (*alloc_empty_creaturecaste_callback)(void);
DFHACK_EXPORT extern c_creaturecaste* (*alloc_creaturecaste_callback)(const char*, const char*, const char*, const char*, uint32_t, uint32_t);
DFHACK_EXPORT extern c_creaturecaste* (*alloc_creaturecaste_buffer_callback)(uint32_t);
struct c_creaturetype
{
@ -94,9 +99,9 @@ struct c_creaturetype
} tilecolor;
};
c_creaturetype* (*alloc_empty_creaturetype_callback)(void);
c_creaturetype* (*alloc_creaturetype_callback)(const char*, uint32_t, uint32_t, uint8_t, uint16_t, uint16_t, uint16_t);
c_creaturetype* (*alloc_creaturetype_buffer_callback)(uint32_t);
DFHACK_EXPORT extern c_creaturetype* (*alloc_empty_creaturetype_callback)(void);
DFHACK_EXPORT extern c_creaturetype* (*alloc_creaturetype_callback)(const char*, uint32_t, uint32_t, uint8_t, uint16_t, uint16_t, uint16_t);
DFHACK_EXPORT extern c_creaturetype* (*alloc_creaturetype_buffer_callback)(uint32_t);
#ifdef __cplusplus
}