3 Jan 2007 16:06
Perl and Subroutine Refrences
Aaron Dalton <aaron <at> daltons.ca>
2007-01-03 15:06:01 GMT
2007-01-03 15:06:01 GMT
I'm not quite sure where to start. I'm trying to wrap Sourceforge's libfov project (http://sourceforge.net/projects/libfov). I'm running into difficulty in regards to callbacks. The library allows you to set the two callbacks as follows: void fov_settings_set_opacity_test_function(fov_settings_type *settings, bool (*f)(void *map, int x, int y)) { settings->opaque = f; } void fov_settings_set_apply_lighting_function(fov_settings_type *settings, void (*f)(void *map, int x, int y, int dx, int dy, void *src)) { settings->apply = f; } In the example simple.cc file this is handled as follows: void apply(void *map, int x, int y, int dx, int dy, void *src) { if (((MAP *)map)->onMap(x, y)) ((MAP *)map)->setSeen(x, y); } bool opaque(void *map, int x, int y) { return ((MAP *)map)->blockLOS(x, y); } How on Earth can I usefully wrap this with Perl? Ideally, the end-user would create their own Map object that implements the setSeen() and blockLOS() routines and they would simply be magically called. I cannot simply add the above 2 declarations to the main fov.h file because MAP is a specific C type. Do I need to also wrap some basic MAP object that the end-user would have to inherit to make the above work? I'm really kinda confused. Anyway, I thank you for your time and attention. P.S. Yes, this is a resend. It is the first and last. I just wanted to see if anybody could help me. -- -- Aaron Dalton | Super Duper Games aaron <at> daltons.ca | http://superdupergames.org ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
RSS Feed