I'm doing this to dispatch callbacks on the C side. Are there any issues with doing it this way?
Is there a better way? Thanks, Joel --- enum { ALERT }; static CAMLprim value callbacks[] = { Val_unit // Alert }; template<class T> inline void dispatch(CAMLprim value (*make)(T*), value v, T* p, void* ctx) { if (v != Val_unit) { caml_c_thread_register(); CAMLlocal1(o); o = make(p); callback2(v, (value)ctx, o); } } class MyAdmCallbacks: public AdmCallbacks { public : MyAdmCallbacks() {}; ~MyAdmCallbacks() {}; virtual int Alert(AlertInfo* pInfo, void* pContext, int* aiCode) { dispatch(Alert_new_from, callbacks[ALERT], pInfo, pContext); *aiCode = API_OK; return (OK); } }; -------------------------------------------------------------------------- Working on AlgoKit, a new algorithmic trading platform using Rithmic R|API ---------------------+------------+--------------------------------------- http://wagerlabs.com | @wagerlabs | http://www.linkedin.com/in/joelreymont ---------------------+------------+--------------------------------------- -- Caml-list mailing list. Subscription management and archives: https://sympa-roc.inria.fr/wws/info/caml-list Beginner's list: http://groups.yahoo.com/group/ocaml_beginners Bug reports: http://caml.inria.fr/bin/caml-bugs