bool* arguments can be used by wrappers
[lqt.git] / cpptoxml / parser / binder.h
blob7c2a27386eecc28a5935a4d5935b33ac1bdf4262
1 /****************************************************************************
2 **
3 ** Copyright (C) 1992-2008 Trolltech ASA. All rights reserved.
4 ** Copyright (C) 2002-2005 Roberto Raggi <roberto@kdevelop.org>
5 **
6 ** This file is part of the Qt Script Generator project on Trolltech Labs.
7 **
8 ** This file may be used under the terms of the GNU General Public
9 ** License version 2.0 as published by the Free Software Foundation
10 ** and appearing in the file LICENSE.GPL included in the packaging of
11 ** this file. Please review the following information to ensure GNU
12 ** General Public Licensing requirements will be met:
13 ** http://www.trolltech.com/products/qt/opensource.html
15 ** If you are unsure which license is appropriate for your use, please
16 ** review the following information:
17 ** http://www.trolltech.com/products/qt/licensing.html or contact the
18 ** sales department at sales@trolltech.com.
20 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
21 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
23 ****************************************************************************/
26 #ifndef BINDER_H
27 #define BINDER_H
29 #include "default_visitor.h"
30 #include "codemodel.h"
31 #include "type_compiler.h"
32 #include "name_compiler.h"
33 #include "declarator_compiler.h"
35 class TokenStream;
36 class LocationManager;
37 class Control;
38 struct NameSymbol;
40 class Binder: protected DefaultVisitor
42 public:
43 Binder(CodeModel *__model, LocationManager &__location, Control *__control = 0);
44 virtual ~Binder();
46 inline TokenStream *tokenStream() const { return _M_token_stream; }
47 inline CodeModel *model() const { return _M_model; }
48 ScopeModelItem currentScope();
50 FileModelItem run(AST *node);
52 // utils
53 TypeInfo qualifyType(const TypeInfo &type, const QStringList &context) const;
55 protected:
56 virtual void visitAccessSpecifier(AccessSpecifierAST *);
57 virtual void visitClassSpecifier(ClassSpecifierAST *);
58 virtual void visitEnumSpecifier(EnumSpecifierAST *);
59 virtual void visitEnumerator(EnumeratorAST *);
60 virtual void visitFunctionDefinition(FunctionDefinitionAST *);
61 virtual void visitLinkageSpecification(LinkageSpecificationAST *);
62 virtual void visitNamespace(NamespaceAST *);
63 virtual void visitSimpleDeclaration(SimpleDeclarationAST *);
64 virtual void visitTemplateDeclaration(TemplateDeclarationAST *);
65 virtual void visitTypedef(TypedefAST *);
66 virtual void visitUsing(UsingAST *);
67 virtual void visitUsingDirective(UsingDirectiveAST *);
68 virtual void visitQProperty(QPropertyAST *);
69 virtual void visitForwardDeclarationSpecifier(ForwardDeclarationSpecifierAST *);
70 virtual void visitQEnums(QEnumsAST *);
72 private:
74 int decode_token(std::size_t index) const;
75 const NameSymbol *decode_symbol(std::size_t index) const;
76 CodeModel::AccessPolicy decode_access_policy(std::size_t index) const;
77 CodeModel::ClassType decode_class_type(std::size_t index) const;
79 CodeModel::FunctionType changeCurrentFunctionType(CodeModel::FunctionType functionType);
80 CodeModel::AccessPolicy changeCurrentAccess(CodeModel::AccessPolicy accessPolicy);
81 NamespaceModelItem changeCurrentNamespace(NamespaceModelItem item);
82 ClassModelItem changeCurrentClass(ClassModelItem item);
83 FunctionDefinitionModelItem changeCurrentFunction(FunctionDefinitionModelItem item);
84 TemplateParameterList changeTemplateParameters(TemplateParameterList templateParameters);
86 void declare_symbol(SimpleDeclarationAST *node, InitDeclaratorAST *init_declarator);
88 void applyStorageSpecifiers(const ListNode<std::size_t> *storage_specifiers, MemberModelItem item);
89 void applyFunctionSpecifiers(const ListNode<std::size_t> *it, FunctionModelItem item);
91 void updateItemPosition(CodeModelItem item, AST *node);
93 private:
94 CodeModel *_M_model;
95 LocationManager &_M_location;
96 TokenStream *_M_token_stream;
97 Control *_M_control;
99 CodeModel::FunctionType _M_current_function_type;
100 CodeModel::AccessPolicy _M_current_access;
101 FileModelItem _M_current_file;
102 NamespaceModelItem _M_current_namespace;
103 ClassModelItem _M_current_class;
104 FunctionDefinitionModelItem _M_current_function;
105 EnumModelItem _M_current_enum;
106 QStringList _M_context;
107 TemplateParameterList _M_current_template_parameters; // ### check me
108 QHash<QString, QString> _M_qualified_types;
109 QHash<QString, int> _M_anonymous_enums;
111 protected:
112 TypeCompiler type_cc;
113 NameCompiler name_cc;
114 DeclaratorCompiler decl_cc;
117 #endif // BINDER_H
119 // kate: space-indent on; indent-width 2; replace-tabs on;