From 00877dd6d36ca52b1a8720cbbd4a013c958f7fad Mon Sep 17 00:00:00 2001 From: truebrain Date: Tue, 29 Nov 2011 22:24:30 +0000 Subject: (svn r23352) -Add: support dynamically adding an API prefix when returning a C++ class to Squirrel --- src/script/squirrel.hpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'src/script/squirrel.hpp') diff --git a/src/script/squirrel.hpp b/src/script/squirrel.hpp index 44ab21650..e4aaf6ae3 100644 --- a/src/script/squirrel.hpp +++ b/src/script/squirrel.hpp @@ -23,11 +23,12 @@ class Squirrel { private: typedef void (SQPrintFunc)(bool error_msg, const SQChar *message); - HSQUIRRELVM vm; ///< The VirtualMachine instnace for squirrel + HSQUIRRELVM vm; ///< The VirtualMachine instance 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 bool crashed; ///< True if the squirrel script made an error. int overdrawn_ops; ///< The amount of operations we have overdrawn. + const char *APIName; ///< Name of the API used for this squirrel. /** * The internal RunError handler. It looks up the real error and calls RunError with it. @@ -39,6 +40,11 @@ private: */ HSQUIRRELVM GetVM() { return this->vm; } + /** + * Get the API name. + */ + const char *GetAPIName() { return this->APIName; } + protected: /** * The CompileError handler. @@ -66,7 +72,7 @@ public: friend class AIController; friend void squirrel_register_std(Squirrel *engine); - Squirrel(); + Squirrel(const char *APIName); ~Squirrel(); /** @@ -165,9 +171,10 @@ public: * @param real_instance The instance to the real class, if it represents a real class. * @param instance Returning value with the pointer to the instance. * @param release_hook Optional param to give a release hook. + * @param prepend_API_name Optional parameter; if true, the class_name is prefixed with the current API name. * @return False if creating failed. */ - static bool CreateClassInstanceVM(HSQUIRRELVM vm, const char *class_name, void *real_instance, HSQOBJECT *instance, SQRELEASEHOOK release_hook); + static bool CreateClassInstanceVM(HSQUIRRELVM vm, const char *class_name, void *real_instance, HSQOBJECT *instance, SQRELEASEHOOK release_hook, bool prepend_API_name = false); /** * Exactly the same as CreateClassInstanceVM, only callable without instance of Squirrel. -- cgit v1.2.3-54-g00ecf