|
From: Petr M. <pe...@gm...> - 2010-03-30 20:19:52
|
Hello,
I've got a problem with SWIG generating something I wouldn't really expect.
There is a rather simple struct:
struct t_matgloss
{
char id[128]; //the id in the raws
uint8_t fore; // Annoyingly the offset for this differs between types
uint8_t back;
uint8_t bright;
char name[128]; //this is the name displayed ingame
};
And SWIG generates this for getting the simple strings:
size_t size = 128;
while (size && (result[size - 1] == '\0')) --size;
resultobj = SWIG_FromCharPtrAndSize(result, size);
This is obviously wrong and my simple python script doesn't work right:
ID BLUE JADE, name blue jade
ID LAPIS LAZULI, name lapis lazuli
ID PRASE, name praselazuli
ID PRASE OPAL, name prase opali
ID BLOODSTONE, name bloodstonei
ID MOSS AGATE, name moss agatei
ID MOSS OPAL, name moss opali
(I'm just iterating through a vector of t_matgloss)
So, how do I make it treat the character arrays as null-terminated strings?
|