I think I've found a bug with my TV3D wrapper, and it's been a few months since I wrote this section, and I'm struggling to remember who, what and why I did it as I did it.
I have a C struct and I'm writing functions to populate the struct from a BMax type and vice versa, because BMax struggles to deal with structs.
Here's the C wrapper section which populates for one particular Struct, which contains two strings ( char* )
I think the second one is ok, and I don't think it's ever needed anyway. I think the first one is wrong though. Looking at the way I've had to put a * in front of Ha in those two lines which deal with the strings, I think that's where I've messed up trying to get it to compile. It doesn't crash but I'm getting empty strings.
Have I messed that up? How should it be? Is it just a case of removing the * from in front of both sides in those two instances? I think that's right, but I'm feeling very rusty with C++ and pointers always did do my head in pretty easy.
I have a C struct and I'm writing functions to populate the struct from a BMax type and vice versa, because BMax struggles to deal with structs.
Here's the C wrapper section which populates for one particular Struct, which contains two strings ( char* )
extern "C" __cdecl void cTVTEXTURE_PopulateType(cTV_TEXTURE* Ha,int* Active,char* Name,char* Filename,int* Width,int* Height,int* Size,int* bitdepth,int* colorkeyed,int* RealWidth,int* RealHeight,cCONST_TV_TEXTURETYPE* TextureType) { *Active=Ha->Active; *Name=*Ha->Name; *Filename=*Ha->Filename; *Width=Ha->Width; *Height=Ha->Height; *Size=Ha->Size; *bitdepth=Ha->bitdepth; *colorkeyed=Ha->colorkeyed; *RealWidth=Ha->RealWidth; *RealHeight=Ha->RealHeight; *TextureType=Ha->TextureType; }
extern "C" __cdecl void cTVTEXTURE_PopulateStruct(cTV_TEXTURE* Ha,int Active,char* Name,char* Filename,int Width,int Height,int Size,int bitdepth,int colorkeyed,int RealWidth,int RealHeight,cCONST_TV_TEXTURETYPE TextureType) { Ha->Active=Active; Ha->Name=Name; Ha->Filename=Filename; Ha->Width=Width; Ha->Height=Height; Ha->Size=Size; Ha->bitdepth=bitdepth; Ha->colorkeyed=colorkeyed; Ha->RealWidth=RealWidth; Ha->RealHeight=RealHeight; Ha->TextureType=TextureType; }
I think the second one is ok, and I don't think it's ever needed anyway. I think the first one is wrong though. Looking at the way I've had to put a * in front of Ha in those two lines which deal with the strings, I think that's where I've messed up trying to get it to compile. It doesn't crash but I'm getting empty strings.
Have I messed that up? How should it be? Is it just a case of removing the * from in front of both sides in those two instances? I think that's right, but I'm feeling very rusty with C++ and pointers always did do my head in pretty easy.