+
+ for(std::vector<Class*>::iterator i = _class->sub_classes.begin();
+ i != _class->sub_classes.end(); ++i) {
+ Class* _class = *i;
+ create_register_class_code(_class);
+ }
+}
+
+void
+WrapperCreator::create_register_constants_code(Namespace* ns)
+{
+ for(std::vector<Field*>::iterator i = ns->fields.begin();
+ i != ns->fields.end(); ++i) {
+ Field* field = *i;
+ create_register_constant_code(field);
+ }
+}
+
+void
+WrapperCreator::create_register_constant_code(Field* field)
+{
+ if(!field->has_const_value)
+ return;
+ out << ind << "sq_pushstring(v, \"" << field->name << "\", -1);\n";
+ if(field->type->atomic_type == &BasicType::INT) {
+ out << ind << "sq_pushinteger(v, " << field->const_int_value << ");\n";
+ } else if(field->type->atomic_type == &BasicType::FLOAT) {
+ out << ind << "sq_pushfloat(v, " << field->const_float_value << ");\n";
+ } else if(field->type->atomic_type == StringType::instance()) {
+ out << ind << "sq_pushstring(v, \""
+ << field->const_string_value << "\", -1);\n";
+ } else {
+ throw std::runtime_error("Constant is not int, float or string");
+ }
+ create_register_slot_code("constant", field->name);
+ out << "\n";
+}
+
+void
+WrapperCreator::create_register_slot_code(const std::string& what,
+ const std::string& name)
+{
+ out << ind << "if(sq_createslot(v, -3) < 0) {\n";
+ out << ind << ind << "std::ostringstream msg;\n";
+ out << ind << ind << "msg << \"Couldn't register " << what << "'"
+ << name << "'\";\n";
+ out << ind << ind << "throw SquirrelError(v, msg.str());\n";
+ out << ind << "}\n";