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 "integers.h"
#include "DFCommonInternal.h"
using namespace DFHack;
#include "DFTypes.h"
#include "modules/Items.h"
#include "DFHackAPI_C.h"
using namespace DFHack;
#ifdef __cplusplus
extern "C" {
#endif
DFHACK_EXPORT char* Items_getItemDescription(DFHackObject* items, uint32_t itemptr, DFHackObject* mats, char* (*char_buffer_create)(int));
DFHACK_EXPORT char* Items_getItemClass(DFHackObject* items, int32_t index, 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);
DFHACK_EXPORT int Items_getItemData(DFHackObject* items, uint32_t itemptr, t_item* item);
#ifdef __cplusplus

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