Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

Rebol library datatypes mappings ...

 [1/1] from: petr::krenzelok::trz::cz at: 14-Apr-2002 21:04


Hi, last few days I was dealing with some gfx library wrapping. I was supposed to define some larger structures, and I found out Rebol/library component structure wrappings incorrect or just I don't understand the issue correctly. If I am wrong, then take my apology, as my knowledge of C equals to zero, so, maybe you will help me to understand what is going on. So what have I observed?: 1) It doesn't depend how you define your structure types. The REAL data is contained in "third struct-name" expression output binary form. - It never changes, so Rebol level structure definition serves only as some kind of interface, which should help you to map binary data to Rebol datatypes. 2) I really don't understand, how C short (INT16, UINT16) datatypes can be mapped to Rebol integer! values? Rebol integer! datatype takes 4 bytes in binary form, while INT16 is represented only in two bytes, when returned back from the library. So - if you have such datatype, you have to define two char!s in your structure, or following integer! values will be shifted and incorrectly mapped back into your structure words ... 3) There is no way of how to simply create array mapping. E.g. you have array of Name[64], which will be represented by 64 bytes. You have to define 64 char!s or you can forget further wrapping the structure. (forget string!, as strings are passed by reference - 4 bytes pointer is passed to library). It would be really good to have ability to specify at least binary! when dealing with structure conversions (IIRC it was said it will come in next library interface update ...) 4) I even found following anomaly :-) typedef GFL_UINT16 GFL_ORIGIN; #define GFL_BOTTOM 0x10 typedef GFL_UINT16 GFL_BITMAP_TYPE; #define GFL_RGBA 0x0020 /* * BITMAP struct */ typedef struct { GFL_BITMAP_TYPE Type; GFL_ORIGIN Origin; GFL_INT32 Width; GFL_INT32 Height; GFL_UINT32 BytesPerLine; GFL_INT16 LinePadding; GFL_INT16 Reserved; GFL_UINT8 BytesPerPixel; GFL_UINT8 BitsPerComponent; /* Always 8 */ GFL_UINT16 Xdpi; GFL_UINT16 Ydpi; GFL_INT16 TransparentIndex; /* -1 if not used */ GFL_INT32 ColorUsed; GFL_COLORMAP *ColorMap; GFL_UINT8 *Data; } GFL_BITMAP; ... where both are defined as UINT16 types, but first one is returned back as only one byte (char) and second one is returned as two bytes ... I have to say that something like that is beyond my understanding of how things work between the outer world and Rebol .... Anyway - I just wonder how many ppl uses advanced capabilities of Rebol, as I can find current library interface as a little bit underpowered ;-) I would really welcome raw binary spec, as well as distinguishing 16 bit values from 32 bit ones (UINT16 vs UINT32) .... -pekr-