-#include "tree.h"
+#include "tree.hpp"
#include <iostream>
#include <sstream>
#include <stdexcept>
-#include "create_wrapper.h"
-#include "globals.h"
+#include "create_wrapper.hpp"
+#include "globals.hpp"
void
WrapperCreator::create_wrapper(Namespace* ns)
{
+ std::string fromfile = original_file != "" ? original_file : inputfile;
+
// hpp file
hppout
<< "/**\n"
- << " * WARNING: This file is automatically generated from '"
- << inputfile << "' - do not change\n"
+ << " * WARNING: This file is automatically generated from:\n"
+ << " * '" << fromfile << "'\n"
+ << " * DO NOT CHANGE\n"
<< " */\n"
<< "#ifndef __" << modulename << "_WRAPPER_H__\n"
<< "#define __" << modulename << "_WRAPPER_H__\n"
<< "\n"
- << "#include \"wrapper_util.h\"\n"
+ << "#include \"wrapper_util.hpp\"\n"
<< "\n"
<< "extern WrappedFunction " << modulename << "_global_functions[];\n"
<< "extern WrappedClass " << modulename << "_classes[];\n"
// cpp header
out << "/**\n"
- << " * WARNING: This file is automatically generated from '"
- << inputfile << "' - do not change\n"
+ << " * WARNING: This file is automatically generated from:\n"
+ << " * '" << fromfile << "'\n"
+ << " * DO NOT CHANGE\n"
<< " */\n"
- << "\n"
<< "#include <config.h>\n"
+ << "\n"
<< "#include <new>\n"
<< "#include <assert.h>\n"
<< "#include <string>\n"
<< "#include <squirrel.h>\n"
- << "#include \"wrapper_util.h\"\n"
- << "#include \"wrapper.interface.h\"\n"
+ << "#include \"wrapper_util.hpp\"\n"
+ << "#include \"wrapper.interface.hpp\"\n"
<< "\n";
if(selected_namespace != "") {
out << "using namespace " << selected_namespace << ";\n";
}
// declare and retrieve arguments
- size_t i = 0;
+ int i = 0;
+ int arg_offset = 2;
for(std::vector<Parameter>::iterator p = function->parameters.begin();
p != function->parameters.end(); ++p) {
- char argname[64];
- snprintf(argname, sizeof(argname), "arg%u", i);
- prepare_argument(p->type, i + 2, argname);
-
+ if(i == 0 && p->type.atomic_type == HSQUIRRELVMType::instance()) {
+ out << ind << "HSQUIRRELVM arg0 = v;\n";
+ arg_offset--;
+ } else {
+ char argname[64];
+ snprintf(argname, sizeof(argname), "arg%d", i);
+ prepare_argument(p->type, i + arg_offset, argname);
+ }
++i;
}