Go to the documentation of this file.00001 #ifndef __TYPESOLVER_H__
00002 #define __TYPESOLVER_H__
00003
00004 #include <CPPParser.hpp>
00005
00006 #include <typelib/typemodel.hh>
00007 #include <typelib/typebuilder.hh>
00008 #include <utilmm/stringtools.hh>
00009 #include <list>
00010 #include <sstream>
00011
00012 namespace Typelib { class Registry; }
00013
00014 class TypeSolver : public CPPParser
00015 {
00016 Typelib::Type* m_class_object;
00017 TypeSpecifier m_class_type;
00018
00019 utilmm::stringlist m_namespace;
00020
00021 std::list<CurrentTypeDefinition> m_current;
00022
00023 std::map<std::string, int> m_constants;
00024
00025 Typelib::Type& buildClassObject();
00026 Typelib::Registry& m_registry;
00027
00028 bool m_cxx_mode;
00029 bool m_opaques_forced_alignment;
00030 bool m_opaques_ignore;
00031 typedef std::map<std::string, size_t> AlignmentMap;
00032 AlignmentMap m_opaques_alignment;
00033
00034 Typelib::Type const& buildCurrentType();
00035 void setTypename(std::string const& name);
00036 void beginTypeDefinition(TypeSpecifier class_type, const std::string& name);
00037
00038 public:
00039 struct UnsupportedClassType : public std::runtime_error
00040 {
00041 const int type;
00042 UnsupportedClassType(int type_)
00043 : std::runtime_error("internal error: found a type which is classified neither as struct nor union")
00044 , type(type_) {}
00045 };
00046
00047 struct NestedTypeDefinition : public std::runtime_error
00048 {
00049 NestedTypeDefinition(std::string const& inside, std::string const& outside)
00050 : std::runtime_error("found nested type definition: " + inside + " is defined in " + outside) {}
00051 };
00052
00053 TypeSolver(antlr::TokenStream& lexer, Typelib::Registry& registry, bool cxx_mode);
00054 TypeSolver(const antlr::ParserSharedInputState& state, Typelib::Registry& registry, bool cxx_mode);
00055
00056 void setupOpaqueHandling(bool forced_alignment, bool ignore);
00057 void defineOpaqueAlignment(std::string const& type_name, size_t value);
00058
00059 virtual void beginClassDefinition(TypeSpecifier class_type, const std::string& name);
00060 virtual void endClassDefinition();
00061 virtual void beginEnumDefinition(const std::string& name);
00062 virtual void enumElement(const std::string& name, bool has_value, int value);
00063 virtual void endEnumDefinition();
00064 virtual int getIntConstant(std::string const& name);
00065 virtual int getTypeSize(CurrentTypeDefinition const& def);
00066 virtual void beginTypedef();
00067
00068 virtual void enterNamespace(std::string const& name);
00069 virtual void exitNamespace();
00070
00071 virtual void beginFieldDeclaration();
00072 virtual void endFieldDeclaration();
00073 virtual void foundSimpleType(const std::list<std::string>& full_type);
00074 virtual void classForwardDeclaration(TypeSpecifier ts, DeclSpecifier,const std::string& name);
00075 virtual void end_of_stmt();
00076 virtual void declaratorID(const std::string& name, QualifiedItem);
00077 virtual void declaratorArray(int size);
00078
00079 virtual void resetPointerLevel();
00080 virtual void incrementPointerLevel();
00081
00082 virtual CurrentTypeDefinition popType();
00083 virtual CurrentTypeDefinition& pushNewType();
00084 virtual int getStackSize() const;
00085 void setTemplateArguments(int count);
00086 };
00087
00088 #endif
00089