+ out << "} // end of namespace Wrapper\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)
+ create_squirrel_instance(_class);
+ }
+
+ out << "void register_" << modulename << "_wrapper(HSQUIRRELVM v)\n"
+ << "{\n"
+ << ind << "using namespace Wrapper;\n"
+ << "\n";
+
+ create_register_constants_code(ns);
+ create_register_functions_code(ns);
+ create_register_classes_code(ns);
+
+ out << "}\n"
+ << "\n"
+ << "} // end of namespace Scripting\n"
+ << "\n"
+ << "/* EOF */\n";
+}
+
+void
+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
+ << "_wrapper, 0);\n";
+
+ if(function->custom) {
+ out << ind << "sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, " << function->parameter_spec << ");\n";
+ } else {
+ out << ind << "sq_setparamscheck(v, SQ_MATCHTYPEMASKSTRING, \"";
+
+ out << "x|t";
+
+ if(!function->parameters.empty())
+ {
+ std::vector<Parameter>::iterator p = function->parameters.begin();
+
+ // Skip the first parameter since its a HSQUIRRELVM that is
+ // handled internally
+ if (function->suspend) {
+ ++p;
+ } else if (p->type.atomic_type == HSQUIRRELVMType::instance()) {
+ ++p;
+ }
+
+ for(; p != function->parameters.end(); ++p) {
+ if(p->type.atomic_type == &BasicType::INT) {
+ out << "i";
+ } else if(p->type.atomic_type == &BasicType::FLOAT) {
+ out << "n";
+ } else if(p->type.atomic_type == &BasicType::BOOL) {
+ out << "b";
+ } else if(p->type.atomic_type == StringType::instance()) {
+ out << "s";
+ } else {
+ out << ".";
+ }
+ }
+ }
+ out << "\");\n";
+ }
+
+ create_register_slot_code("function", function->name);
+ out << "\n";
+}
+
+void
+WrapperCreator::create_register_functions_code(Namespace* ns)
+{