e8f457a26d9e87380490e3a6b2c18bf30854188a
[supertux.git] / src / scripting / wrapper_util.h
1 #ifndef __WRAPPERUTIL_HPP__
2 #define __WRAPPERUTIL_HPP__
3
4 #include <squirrel.h>
5 #include <exception>
6 #include <string>
7
8 struct WrappedFunction {
9     const char* name;
10     SQFUNCTION f;
11 };
12 struct WrappedClass {
13     const char* name;
14     WrappedFunction* functions;
15 };
16
17 class SquirrelError : public std::exception
18 {
19 public:
20   SquirrelError(HSQUIRRELVM v, const std::string& message) throw();
21   virtual ~SquirrelError() throw();
22
23   const char* what() const throw();
24 private:
25   std::string message;
26 };
27
28 void register_functions(HSQUIRRELVM v, WrappedFunction* functions);
29 void register_classes(HSQUIRRELVM v, WrappedClass* classes);
30
31 void expose_object(HSQUIRRELVM v, void* object, const char* type,
32         const char* name);
33 void print_squirrel_stack(HSQUIRRELVM v);
34
35 #endif