
Brian Hulley wrote:
minh thu wrote
* for c++, is it better to first write a c api for the c++ code before writing the binding [snip] class TimerFactory { static void Construct(); static void Destruct(); };
then the C api functions are given names like:
xxx_TimerConstruct() Ooops! xxx_TimerFactory_Construct()
I think I also missed the point of your question. In the program I'm writing sometimes I find I need to write the binding first and other times the C first and other times the C++ first since it is not always clear how to achieve a goal. One other thing to bear in mind is that foreign calls are extremely slow, so for example it is much faster to use the Foreign.Marshal.Array and Foreign.C.String functions to allocate and populate a temporary array with the contents of a list, and send the pointer to this array to C with one foreign call, than to send each element of the list with multiple foreign calls (eg to paste only 19K of text from the Windows clipboard to my app took over 1 minute!!! with individual foreign calls but a fraction of a second when I switched to passing a pointer and using peekCAString (ditto pokeArray0 for copy)) Regards, Brian.