fix handling of multiple arguments
authorJens Thiele <jens.thiele@intra2net.com>
Tue, 21 Nov 2006 10:20:35 +0000 (10:20 +0000)
committerJens Thiele <jens.thiele@intra2net.com>
Tue, 21 Nov 2006 10:20:35 +0000 (10:20 +0000)
codegen/codegen-stubhead.hxx
codegen/main.cpp

index a05540e..d21130f 100644 (file)
@@ -7,6 +7,7 @@
 #include <boost/archive/xml_iarchive.hpp>
 #include <boost/serialization/serialization.hpp>
 #include <boost/serialization/string.hpp>
+#include <boost/serialization/utility.hpp>
 
 #include <string>
 #include <t2n_exception.hxx>
index 6cf197e..1236b5c 100644 (file)
@@ -3,6 +3,7 @@
 #include <iostream>
 #include <set>
 #include <fstream>
+#include <list>
 
 void print_indentation(unsigned int indentation)
 {
@@ -71,7 +72,7 @@ struct type_info
      std::string name;
      std::string noref_name;
      bool operator==(const type_info& o) {return (name==o.name) && (noref_name == o.noref_name);}
-     std::string noref() const {return noref_name;}
+     std::string noref() const {return noref_name.empty() ? name : noref_name;}
 };
 
 std::ostream &operator<<(std::ostream &o, const type_info &t) {
@@ -93,8 +94,7 @@ type_info get_type(const xmlpp::Element* root, const std::string &id)
      // if we recurse - when do we stop?
      // if it is a typedef? yes? (hmm if the typedef is in the file parsed this will not work)
 
-     // TODO: const and reference types (perhaps it is good enough to remove the const and &?)
-     //       non-const reference types/pointers (output error message? not yet supported)
+     // TODO: const and reference types handling is a ugly hack
 
      std::string tag(element->get_name());
      if (tag=="ReferenceType") {
@@ -115,15 +115,16 @@ type_info get_type(const xmlpp::Element* root, const std::string &id)
      }
 
      assert(element->get_attribute("name"));
-     assert(element->get_attribute("context"));
      type_info ret;
-     ret.name=get_namespace(root, element->get_attribute("context")->get_value())+"::"+element->get_attribute("name")->get_value();
+     if (element->get_attribute("context"))
+         ret.name=get_namespace(root, element->get_attribute("context")->get_value())+"::";
+     ret.name+=element->get_attribute("name")->get_value();
      return ret;
 }
 
 struct t2n_procedure
 {
-     typedef std::map<std::string, type_info> Args;
+     typedef std::list<std::pair<std::string, type_info> > Args;
 
      std::string group;
      type_info ret_type;
@@ -205,10 +206,10 @@ protected:
                    assert(arg->get_name() == "Argument");
                    assert(arg->get_attribute("name"));
                    assert(arg->get_attribute("type"));
-                   assert(f.args.find(arg->get_attribute("name")->get_value())==f.args.end());
-                   f.args[arg->get_attribute("name")->get_value()]=get_type(root, arg->get_attribute("type")->get_value());
+                   f.args.push_back(std::pair<std::string, type_info>(arg->get_attribute("name")->get_value(), get_type(root, arg->get_attribute("type")->get_value())));
               }
          }
+         std::cerr << "Found function: " << f << std::endl;
          m_procedures.push_back(f);
      }