updated to use preregistered callbacks

develop
doomchild 2010-05-25 15:39:45 -05:00
parent 9908ae3a87
commit 7a7183276f
2 changed files with 17 additions and 13 deletions

@ -27,18 +27,20 @@ distribution.
#include "Export.h" #include "Export.h"
#include "integers.h" #include "integers.h"
#include "DFCommonInternal.h"
using namespace DFHack;
#include "DFTypes.h" #include "DFTypes.h"
#include "modules/Items.h" #include "modules/Items.h"
#include "DFHackAPI_C.h" #include "DFHackAPI_C.h"
using namespace DFHack;
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
DFHACK_EXPORT char* Items_getItemDescription(DFHackObject* items, uint32_t itemptr, DFHackObject* mats, char* (*char_buffer_create)(int)); DFHACK_EXPORT char* Items_getItemDescription(DFHackObject* items, uint32_t itemptr, DFHackObject* mats);
DFHACK_EXPORT char* Items_getItemClass(DFHackObject* items, int32_t index, char* (*char_buffer_create)(int)); DFHACK_EXPORT char* Items_getItemClass(DFHackObject* items, int32_t index);
DFHACK_EXPORT int Items_getItemData(DFHackObject* items, uint32_t itemptr, t_item* item); DFHACK_EXPORT int Items_getItemData(DFHackObject* items, uint32_t itemptr, t_item* item);
#ifdef __cplusplus #ifdef __cplusplus

@ -22,25 +22,27 @@ must not be misrepresented as being the original software.
distribution. distribution.
*/ */
#include "Export.h"
#include "integers.h" #include "integers.h"
#include <string> #include <map>
#include <vector>
#include "DFTypes.h"
using namespace std; using namespace std;
using namespace DFHack;
#include "DFCommonInternal.h" #include "DFProcess.h"
#include "DFTypes.h"
#include "DFHackAPI.h"
#include "modules/Materials.h" #include "modules/Materials.h"
#include "modules/Items.h" #include "modules/Items.h"
#include "DFTypes_C.h"
#include "modules/Items_C.h" #include "modules/Items_C.h"
using namespace DFHack;
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {
#endif #endif
char* Items_getItemDescription(DFHackObject* items, uint32_t itemptr, DFHackObject* mats, char* (*char_buffer_create)(int)) char* Items_getItemDescription(DFHackObject* items, uint32_t itemptr, DFHackObject* mats)
{ {
if(items != NULL && mats != NULL) if(items != NULL && mats != NULL)
{ {
@ -48,7 +50,7 @@ char* Items_getItemDescription(DFHackObject* items, uint32_t itemptr, DFHackObje
if(desc.size() > 0) if(desc.size() > 0)
{ {
char* buf = (*char_buffer_create)(desc.size()); char* buf = (*alloc_char_buffer_callback)(desc.size());
if(buf != NULL) if(buf != NULL)
{ {
@ -67,7 +69,7 @@ char* Items_getItemDescription(DFHackObject* items, uint32_t itemptr, DFHackObje
return NULL; return NULL;
} }
char* Items_getItemClass(DFHackObject* items, int32_t index, char* (*char_buffer_create)(int)) char* Items_getItemClass(DFHackObject* items, int32_t index)
{ {
if(items != NULL) if(items != NULL)
{ {
@ -75,7 +77,7 @@ char* Items_getItemClass(DFHackObject* items, int32_t index, char* (*char_buffer
if(iclass.size() > 0) if(iclass.size() > 0)
{ {
char* buf = (*char_buffer_create)(iclass.size()); char* buf = (*alloc_char_buffer_callback)(iclass.size());
if(buf != NULL) if(buf != NULL)
{ {