fix cr/lfs and remove trailing whitespaces...
[supertux.git] / tools / miniswig / create_wrapper.cpp
index fafe124..64318fd 100644 (file)
@@ -40,7 +40,7 @@ WrapperCreator::create_wrapper(Namespace* ns)
     for(std::vector<AtomicType*>::iterator i = ns->types.begin();
             i != ns->types.end(); ++i) {
         AtomicType* type = *i;
-        Class* _class = dynamic_cast<Class*> (type);                 
+        Class* _class = dynamic_cast<Class*> (type);
         if(_class == 0)
             continue;
 
@@ -53,7 +53,7 @@ WrapperCreator::create_wrapper(Namespace* ns)
            << "\n"
            << "#endif\n"
            << "\n";
-    
+
     // cpp header
     out << "/**\n"
         << " * WARNING: This file is automatically generated from:\n"
@@ -92,13 +92,13 @@ WrapperCreator::create_wrapper(Namespace* ns)
     out << "\n";
 
     for(std::vector<AtomicType*>::iterator i = ns->types.begin();
-            i != ns->types.end(); ++i) {                             
+            i != ns->types.end(); ++i) {
         AtomicType* type = *i;
         Class* _class = dynamic_cast<Class*> (type);
         if(_class != 0)
             create_squirrel_instance(_class);
     }
-    
+
     out << "void register_" << modulename << "_wrapper(HSQUIRRELVM v)\n"
         << "{\n"
         << ind << "using namespace Wrapper;\n"
@@ -119,13 +119,13 @@ WrapperCreator::create_register_function_code(Function* function, Class* _class)
 {
     if(function->type == Function::DESTRUCTOR)
         return;
-    
+
     out << ind << "sq_pushstring(v, \"" << function->name << "\", -1);\n";
-    out << ind << "sq_newclosure(v, &" 
-        << (_class != 0 ? _class->name + "_" : "") << function->name 
+    out << ind << "sq_newclosure(v, &"
+        << (_class != 0 ? _class->name + "_" : "") << function->name
         << "_wrapper, 0);\n";
     create_register_slot_code("function", function->name);
-    out << "\n";                                                              
+    out << "\n";
 }
 
 void
@@ -144,7 +144,7 @@ WrapperCreator::create_register_classes_code(Namespace* ns)
     for(std::vector<AtomicType*>::iterator i = ns->types.begin();
             i != ns->types.end(); ++i) {
         AtomicType* type = *i;
-        Class* _class = dynamic_cast<Class*> (type);                 
+        Class* _class = dynamic_cast<Class*> (type);
         if(_class == 0)
             continue;
         if(_class->super_classes.size() > 0)
@@ -158,9 +158,9 @@ void
 WrapperCreator::create_register_class_code(Class* _class)
 {
     out << ind << "// Register class " << _class->name << "\n";
-    out << ind << "sq_pushstring(v, \"" 
-        << _class->name << "\", -1);\n";    
-    
+    out << ind << "sq_pushstring(v, \""
+        << _class->name << "\", -1);\n";
+
     if(_class->super_classes.size() > 0) {
         if(_class->super_classes.size() > 1) {
             std::ostringstream msg;
@@ -168,7 +168,7 @@ WrapperCreator::create_register_class_code(Class* _class)
                 << _class->name << "')";
             throw std::runtime_error(msg.str());
         }
-        
+
         out << ind << "sq_pushstring(v, \""
             << _class->super_classes[0]->name << "\", -1);\n";
         out << ind << "sq_get(v, -3);\n";
@@ -177,7 +177,7 @@ WrapperCreator::create_register_class_code(Class* _class)
         << (_class->super_classes.size() > 0 ? "SQTrue" : "SQFalse")
         << ") < 0) {\n";
     out << ind << ind << "std::ostringstream msg;\n";
-    out << ind << ind << "msg << \"Couldn't create new class '" 
+    out << ind << ind << "msg << \"Couldn't create new class '"
         << _class->name << "'\";\n";
     out << ind << ind << "throw SquirrelError(v, msg.str());\n";
     out << ind << "}\n";
@@ -199,7 +199,7 @@ WrapperCreator::create_register_class_code(Class* _class)
 
     create_register_slot_code("class", _class->name);
     out << "\n";
-    
+
     for(std::vector<Class*>::iterator i = _class->sub_classes.begin();
             i != _class->sub_classes.end(); ++i) {
         Class* _class = *i;
@@ -266,12 +266,12 @@ WrapperCreator::create_function_wrapper(Class* _class, Function* function)
     out << function->name << "_wrapper(HSQUIRRELVM vm)\n"
         << "{\n";
     // avoid warning...
-    if(_class == 0 && function->parameters.empty() 
+    if(_class == 0 && function->parameters.empty()
             && function->return_type.is_void()
             && function->type != Function::CONSTRUCTOR) {
         out << ind << "(void) vm;\n";
     }
-    
+
     // retrieve pointer to class instance
     if(_class != 0 && function->type != Function::CONSTRUCTOR) {
         out << ind << "SQUserPointer data;\n";
@@ -303,7 +303,7 @@ WrapperCreator::create_function_wrapper(Class* _class, Function* function)
         out << "\n";
         return;
     }
-    
+
     // declare and retrieve arguments
     int i = 0;
     int arg_offset = 2;
@@ -319,7 +319,7 @@ WrapperCreator::create_function_wrapper(Class* _class, Function* function)
         }
         ++i;
     }
-    
+
     // call function
     out << ind << "\n";
     out << ind << "try {\n";
@@ -365,7 +365,7 @@ WrapperCreator::create_function_wrapper(Class* _class, Function* function)
         out << ind << ind << "sq_throwerror(vm, _SC(\"Couldn't setup instance of '" << _class->name << "' class\"));\n";
         out << ind << ind << "return SQ_ERROR;\n";
         out << ind << "}\n";
-        out << ind << "sq_setreleasehook(vm, 1, " 
+        out << ind << "sq_setreleasehook(vm, 1, "
             << _class->name << "_release_hook);\n";
     }
     out << ind << "\n";
@@ -394,7 +394,7 @@ WrapperCreator::create_function_wrapper(Class* _class, Function* function)
     out << ind << ind << "return SQ_ERROR;\n";
     out << ind << "}\n";
     out << ind << "\n";
-    
+
     out << "}\n";
     out << "\n";
 }
@@ -453,7 +453,7 @@ WrapperCreator::push_to_stack(const Type& type, const std::string& var)
     } else if(type.atomic_type == &BasicType::BOOL) {
         out << "sq_pushbool(vm, " << var << ");\n";
     } else if(type.atomic_type == StringType::instance()) {
-        out << "sq_pushstring(vm, " << var << ".c_str(), " 
+        out << "sq_pushstring(vm, " << var << ".c_str(), "
             << var << ".size());\n";
     } else {
         std::ostringstream msg;
@@ -485,7 +485,7 @@ void
 WrapperCreator::create_squirrel_instance(Class* _class)
 {
     out << "void create_squirrel_instance(HSQUIRRELVM v, "
-        << ns_prefix << _class->name 
+        << ns_prefix << _class->name
         << "* object, bool setup_releasehook)\n"
         << "{\n"
         << ind << "using namespace Wrapper;\n"
@@ -523,12 +523,11 @@ WrapperCreator::create_class_release_hook(Class* _class)
 {
     out << "static SQInteger " << _class->name << "_release_hook(SQUserPointer ptr, SQInteger )\n"
         << "{\n"
-        << ind << ns_prefix << _class->name 
-        << "* _this = reinterpret_cast<" << ns_prefix << _class->name 
+        << ind << ns_prefix << _class->name
+        << "* _this = reinterpret_cast<" << ns_prefix << _class->name
         << "*> (ptr);\n"
         << ind << "delete _this;\n"
         << ind << "return 0;\n"
         << "}\n"
         << "\n";
 }
-