namespace SquirrelWrapper
{
-using namespace Scripting;
-
static int DisplayEffect_release_hook(SQUserPointer ptr, int )
{
- DisplayEffect* _this = reinterpret_cast<DisplayEffect*> (ptr);
+ Scripting::DisplayEffect* _this = reinterpret_cast<Scripting::DisplayEffect*> (ptr);
delete _this;
return 0;
}
-void create_squirrel_instance(HSQUIRRELVM v, DisplayEffect* object, bool setup_releasehook)
+void create_squirrel_instance(HSQUIRRELVM v, Scripting::DisplayEffect* object, bool setup_releasehook)
{
sq_pushstring(v, "DisplayEffect", -1);
if(sq_get(v, -2) < 0) {
static int Camera_release_hook(SQUserPointer ptr, int )
{
- Camera* _this = reinterpret_cast<Camera*> (ptr);
+ Scripting::Camera* _this = reinterpret_cast<Scripting::Camera*> (ptr);
delete _this;
return 0;
}
-void create_squirrel_instance(HSQUIRRELVM v, Camera* object, bool setup_releasehook)
+void create_squirrel_instance(HSQUIRRELVM v, Scripting::Camera* object, bool setup_releasehook)
{
sq_pushstring(v, "Camera", -1);
if(sq_get(v, -2) < 0) {
static int Level_release_hook(SQUserPointer ptr, int )
{
- Level* _this = reinterpret_cast<Level*> (ptr);
+ Scripting::Level* _this = reinterpret_cast<Scripting::Level*> (ptr);
delete _this;
return 0;
}
-void create_squirrel_instance(HSQUIRRELVM v, Level* object, bool setup_releasehook)
+void create_squirrel_instance(HSQUIRRELVM v, Scripting::Level* object, bool setup_releasehook)
{
sq_pushstring(v, "Level", -1);
if(sq_get(v, -2) < 0) {
static int ScriptedObject_release_hook(SQUserPointer ptr, int )
{
- ScriptedObject* _this = reinterpret_cast<ScriptedObject*> (ptr);
+ Scripting::ScriptedObject* _this = reinterpret_cast<Scripting::ScriptedObject*> (ptr);
delete _this;
return 0;
}
-void create_squirrel_instance(HSQUIRRELVM v, ScriptedObject* object, bool setup_releasehook)
+void create_squirrel_instance(HSQUIRRELVM v, Scripting::ScriptedObject* object, bool setup_releasehook)
{
sq_pushstring(v, "ScriptedObject", -1);
if(sq_get(v, -2) < 0) {
static int Sound_release_hook(SQUserPointer ptr, int )
{
- Sound* _this = reinterpret_cast<Sound*> (ptr);
+ Scripting::Sound* _this = reinterpret_cast<Scripting::Sound*> (ptr);
delete _this;
return 0;
}
-void create_squirrel_instance(HSQUIRRELVM v, Sound* object, bool setup_releasehook)
+void create_squirrel_instance(HSQUIRRELVM v, Scripting::Sound* object, bool setup_releasehook)
{
sq_pushstring(v, "Sound", -1);
if(sq_get(v, -2) < 0) {
static int Text_release_hook(SQUserPointer ptr, int )
{
- Text* _this = reinterpret_cast<Text*> (ptr);
+ Scripting::Text* _this = reinterpret_cast<Scripting::Text*> (ptr);
delete _this;
return 0;
}
-void create_squirrel_instance(HSQUIRRELVM v, Text* object, bool setup_releasehook)
+void create_squirrel_instance(HSQUIRRELVM v, Scripting::Text* object, bool setup_releasehook)
{
sq_pushstring(v, "Text", -1);
if(sq_get(v, -2) < 0) {
static int Player_release_hook(SQUserPointer ptr, int )
{
- Player* _this = reinterpret_cast<Player*> (ptr);
+ Scripting::Player* _this = reinterpret_cast<Scripting::Player*> (ptr);
delete _this;
return 0;
}
-void create_squirrel_instance(HSQUIRRELVM v, Player* object, bool setup_releasehook)
+void create_squirrel_instance(HSQUIRRELVM v, Scripting::Player* object, bool setup_releasehook)
{
sq_pushstring(v, "Player", -1);
if(sq_get(v, -2) < 0) {
#define __supertux_WRAPPER_H__
#include <squirrel.h>
-
-namespace Scripting
-{
-class DisplayEffect;
-class Camera;
-class Level;
-class ScriptedObject;
-class Sound;
-class Text;
-class Player;
-}
+#include "wrapper.interface.hpp"
namespace SquirrelWrapper
{
-using namespace Scripting;
-
void register_supertux_wrapper(HSQUIRRELVM v);
-void create_squirrel_instance(HSQUIRRELVM v, DisplayEffect* object, bool setup_releasehook = false);
-void create_squirrel_instance(HSQUIRRELVM v, Camera* object, bool setup_releasehook = false);
-void create_squirrel_instance(HSQUIRRELVM v, Level* object, bool setup_releasehook = false);
-void create_squirrel_instance(HSQUIRRELVM v, ScriptedObject* object, bool setup_releasehook = false);
-void create_squirrel_instance(HSQUIRRELVM v, Sound* object, bool setup_releasehook = false);
-void create_squirrel_instance(HSQUIRRELVM v, Text* object, bool setup_releasehook = false);
-void create_squirrel_instance(HSQUIRRELVM v, Player* object, bool setup_releasehook = false);
+void create_squirrel_instance(HSQUIRRELVM v, Scripting::DisplayEffect* object, bool setup_releasehook = false);
+void create_squirrel_instance(HSQUIRRELVM v, Scripting::Camera* object, bool setup_releasehook = false);
+void create_squirrel_instance(HSQUIRRELVM v, Scripting::Level* object, bool setup_releasehook = false);
+void create_squirrel_instance(HSQUIRRELVM v, Scripting::ScriptedObject* object, bool setup_releasehook = false);
+void create_squirrel_instance(HSQUIRRELVM v, Scripting::Sound* object, bool setup_releasehook = false);
+void create_squirrel_instance(HSQUIRRELVM v, Scripting::Text* object, bool setup_releasehook = false);
+void create_squirrel_instance(HSQUIRRELVM v, Scripting::Player* object, bool setup_releasehook = false);
}
{
std::string fromfile = original_file != "" ? original_file : inputfile;
+ if(selected_namespace != "") {
+ ns_prefix = selected_namespace;
+ ns_prefix += "::";
+ }
+
// hpp file
hppout
<< "/**\n"
<< "#define __" << modulename << "_WRAPPER_H__\n"
<< "\n"
<< "#include <squirrel.h>\n"
+ << "#include \"wrapper.interface.hpp\"\n"
+ << "\n"
+ << "namespace SquirrelWrapper\n"
+ << "{\n"
<< "\n";
- if(selected_namespace != "") {
- hppout << "namespace " << selected_namespace << "\n"
- << "{\n";
- }
- for(std::vector<AtomicType*>::iterator i = ns->types.begin();
- i != ns->types.end(); ++i) {
- AtomicType* type = *i;
- Class* _class = dynamic_cast<Class*> (type);
- if(_class == 0)
- continue;
- hppout << "class " << _class->name << ";\n";
- }
-
- if(selected_namespace != "") {
- hppout << "}\n";
- }
-
- hppout << "\n"
- << "namespace SquirrelWrapper\n"
- << "{\n"
- << "\n";
-
- if(selected_namespace != "") {
- hppout << "using namespace " << selected_namespace << ";\n"
- << "\n";
- }
-
hppout << "void register_" << modulename << "_wrapper(HSQUIRRELVM v);\n"
<< "\n";
continue;
hppout << "void create_squirrel_instance(HSQUIRRELVM v, "
- << _class->name
+ << ns_prefix << _class->name
<< "* object, bool setup_releasehook = false);\n";
}
hppout <<"\n"
<< "{\n"
<< "\n";
- if(selected_namespace != "") {
- out << "using namespace " << selected_namespace << ";\n";
- out << "\n";
- }
-
for(std::vector<AtomicType*>::iterator i = ns->types.begin();
i != ns->types.end(); ++i) {
AtomicType* type = *i;
WrapperCreator::create_squirrel_instance(Class* _class)
{
out << "void create_squirrel_instance(HSQUIRRELVM v, "
- << _class->name
+ << ns_prefix << _class->name
<< "* object, bool setup_releasehook)\n"
<< "{\n"
<< ind << "sq_pushstring(v, \"" << _class->name << "\", -1);\n"
{
out << "static int " << _class->name << "_release_hook(SQUserPointer ptr, int )\n"
<< "{\n"
- << ind << _class->name
- << "* _this = reinterpret_cast<" << _class->name << "*> (ptr);\n"
+ << ind << ns_prefix << _class->name
+ << "* _this = reinterpret_cast<" << ns_prefix << _class->name
+ << "*> (ptr);\n"
<< ind << "delete _this;\n"
<< ind << "return 0;\n"
<< "}\n"
void create_wrapper(Namespace* ns);
private:
+ std::string ns_prefix;
+
void create_register_functions_code(Namespace* ns);
void create_register_function_code(Function* function, Class* _class);
void create_register_classes_code(Namespace* ns);