Re: TileEngine Wrapper Issue
- Posted by ghaberek (admin) Mar 23, 2021
- 787 views
I was currently writing a wrapper of TileEngine for Euphoria. Everything was going smoothly until I noticed I'd need to make a shim for it due to the way its functions are handled. Some work without shims, but its the structs.
Mmm nope. Not in this case at least. According to the Tilengine.h include file, TLN_Tilemap is an opaque reference:
typedef struct Tilemap* TLN_Tilemap; /*!< Opaque tilemap reference */
An "opaque" pointer or reference is just that: you can't see "through" it to the object on the other side (like an opaque wall versus a transparent window). The function expects to return a pointer to you and that's it. So in this case what you've already done is quite sufficient. No muss no fuss.
One tip I can offer when wrapping a libray is to start with the user-facing include files for a library (what you might call its "interface") before digging into back-end source code. If something isn't meant to be exposed to the programmer using the library then it's unlikely to be found in the include files and probably doesn't need to be wrapped.
Maybe I should just switch to Phix since has simple struct support. -slight sarcarsm
Har har. I've been working on the struct branch as best I can. I've had to re-familiarize myself with the Euphoria internals and then start work on finishing up the bits to make it complete. I'm making progress.
-Greg