RE: Wrapping C++ libraries (was RE: Future of Euphoria)
- Posted by Ray Smith <smithr at ix.net.au> Jun 03, 2002
- 431 views
Matthew Lewis wrote: [snip] > Right. It helps to understand what, exactly, something like C++ does > with > classes at the binary level (turns out to be the same thing COM does). > Each > class has a vtbl, or a virtual function table. Which is to say, its an > array of pointers in memory. The pointers are to the functions in the > class. An instance of the class will basically be a pointer to the > vtbl. > This pointer is AKA the 'this' pointer. The this pointer is > automatically > the first param passed to any function in the class. C++ does this > automatically--Eu must do this explicitly. Also, there's no built in > way to > call functions by pointer in Eu (unless there are no params to be > passed). > But I've figured that out, too :). [snip] gee, this is pretty interesting and in depth stuff!!! My plan was to cheat a little and write a DLL in standard C which access the C++ objects (like SWIG - but do it manually). ie. convert the OO to a non OO library with a wrapper ... or create a wrapper on a wrapper. Then Euphoria will just call the C routines which will call the C++ routines. It's most likely more work but possibly easier. I actaully started a project to automate most of the C and euphoria code when I did the same thing for Allegro (but never finished it). It couldn't parse header files but I just created data files and it created the C DLL and the Euphoria wrapper. So after all that ... I guess my question should have been how do I create C wrapper for a C++ library?? Thanks, Ray Smith http://rays-web.com