--- a/src/squirrel.hpp Tue Feb 26 18:39:33 2008 +0000
+++ b/src/squirrel.hpp Tue Feb 26 21:35:22 2008 +0000
@@ -7,7 +7,11 @@
class Squirrel {
private:
- HSQUIRRELVM vm; ///< The VirtualMachine instnace for squirrel
+ typedef void (SQPrintFunc)(bool error_msg, const char *message);
+
+ HSQUIRRELVM vm; ///< The VirtualMachine instnace for squirrel
+ void *global_pointer; ///< Can be set by who ever initializes Squirrel
+ SQPrintFunc *print_func; ///< Points to either NULL, or a custom print handler
/**
* The internal RunError handler. It looks up the real error and calls RunError with it.
@@ -129,15 +133,20 @@
static int ObjectToInteger(HSQOBJECT *ptr) { return sq_objtointeger(ptr); }
/**
- * Sets a pointer in the VM that is reasable from where ever you are, what
- * ever your state is. Useful to keep track of the main instance.
+ * Sets a pointer in the VM that is reachable from where ever you are in SQ.
+ * Useful to keep track of the main instance.
*/
- void SetGlobalPointer(void *ptr) { sq_setforeignptr(this->vm, ptr); }
+ void SetGlobalPointer(void *ptr) { this->global_pointer = ptr; }
/**
* Get the pointer as set by SetGlobalPointer.
*/
- static void *GetGlobalPointer(HSQUIRRELVM vm) { return sq_getforeignptr(vm); }
+ static void *GetGlobalPointer(HSQUIRRELVM vm) { return ((Squirrel *)sq_getforeignptr(vm))->global_pointer; }
+
+ /**
+ * Set a custom print function, so you can handle outputs from SQ yourself.
+ */
+ void SetPrintFunction(SQPrintFunc *func) { this->print_func = func; }
/**
* Throw a Squirrel error that will be nicely displayed to the user.