Modules |
Files |
Inheritance Tree |
Inheritance Graph |
Name Index |
Config
File: Synopsis/Parser/C++/syn/synopsis.hh
1| // Synopsis C++ Parser: synopsis.hh
2| // Definition of the Synopsis class for mapping the C++ objects to Python
3| // objects
4|
5| // $Id: synopsis.hh,v 1.32 2003/01/27 06:53:37 chalky Exp $
6| //
7| // This file is a part of Synopsis.
8| // Copyright (C) 2002 Stephen Davies
9| //
10| // Synopsis is free software; you can redistribute it and/or modify it
11| // under the terms of the GNU General Public License as published by
12| // the Free Software Foundation; either version 2 of the License, or
13| // (at your option) any later version.
14| //
15| // This program is distributed in the hope that it will be useful,
16| // but WITHOUT ANY WARRANTY; without even the implied warranty of
17| // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
18| // General Public License for more details.
19| //
20| // You should have received a copy of the GNU General Public License
21| // along with this program; if not, write to the Free Software
22| // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
23| // 02111-1307, USA.
24|
25| #ifndef H_SYNOPSIS_CPP_SYNOPSIS
26| #define H_SYNOPSIS_CPP_SYNOPSIS
27|
28| #include <iostream>
29| #include <string>
30| #include <vector>
31| #include <list>
32| #include <stack>
33| #ifdef PYTHON_INCLUDE
34| # include PYTHON_INCLUDE
35| #else
36| # include <Python.h>
37| #endif
38| #include "ast.hh"
39| #include "type.hh"
40|
41| #if DEBUG
42| #define DO_TRACE
43| class Trace
44| {
45| public:
46| Trace(const std::string &s) : scope(s)
47| {
48| std::cout << indent() << "entering " << scope << std::endl;
49| ++level;
50| }
51| ~Trace()
52| {
53| --level;
54| std::cout << indent() << "leaving " << scope << std::endl;
55| }
56| private:
57| std::string indent()
58| {
59| return std::string(level, ' ');
60| }
61| static int level;
62| std::string scope;
63| };
64| #else
65| class Trace
66| {
67| public:
68| Trace(const std::string &)
69| {}
70| ~Trace()
71| {}
72| }
73| ;
74| #endif
75|
76| class FileFilter;
77|
78|
79| class Synopsis : public AST::Visitor, public Types::Visitor
80| {
81| public:
82|
83| Synopsis(FileFilter*, PyObject *decls, PyObject *types);
84| ~Synopsis();
85|
86| void translate(AST::Scope* global, PyObject* ast);
87| void set_builtin_decls(const AST::Declaration::vector& builtin_decls);
88|
89|
90|
91|
92| PyObject* Base(Types::Base*);
93| PyObject* Unknown(Types::Named*);
94| PyObject* Declared(Types::Declared*);
95| PyObject* Dependent(Types::Dependent*);
96| PyObject* Template(Types::Template*);
97| PyObject* Modifier(Types::Modifier*);
98| PyObject* Array(Types::Array*);
99| PyObject* Parameterized(Types::Parameterized*);
100| PyObject* FuncPtr(Types::FuncPtr*);
101|
102|
103|
104|
105| PyObject* SourceFile(AST::SourceFile*);
106| PyObject* Include(AST::Include*);
107| PyObject* Declaration(AST::Declaration*);
108| PyObject* Macro(AST::Macro*);
109| PyObject* Forward(AST::Forward*);
110| PyObject* Scope(AST::Scope*);
111| PyObject* Namespace(AST::Namespace*);
112| PyObject* Inheritance(AST::Inheritance*);
113| PyObject* Class(AST::Class*);
114| PyObject* Typedef(AST::Typedef*);
115| PyObject* Enumerator(AST::Enumerator*);
116| PyObject* Enum(AST::Enum*);
117| PyObject* Variable(AST::Variable*);
118| PyObject* Const(AST::Const*);
119| PyObject* Parameter(AST::Parameter*);
120| PyObject* Function(AST::Function*);
121| PyObject* Operation(AST::Operation*);
122| PyObject* Comment(AST::Comment*);
123|
124|
125|
126|
127| void visit_declaration(AST::Declaration*);
128| void visit_macro(AST::Macro*);
129| void visit_scope(AST::Scope*);
130| void visit_namespace(AST::Namespace*);
131| void visit_class(AST::Class*);
132| void visit_inheritance(AST::Inheritance*);
133| void visit_forward(AST::Forward*);
134| void visit_typedef(AST::Typedef*);
135| void visit_variable(AST::Variable*);
136| void visit_const(AST::Const*);
137| void visit_enum(AST::Enum*);
138| void visit_enumerator(AST::Enumerator*);
139| void visit_function(AST::Function*);
140| void visit_operation(AST::Operation*);
141| void visit_parameter(AST::Parameter*);
142| void visit_comment(AST::Comment*);
143|
144|
145|
146|
147|
148| void visit_unknown(Types::Unknown*);
149| void visit_modifier(Types::Modifier*);
150| void visit_array(Types::Array*);
151|
152| void visit_base(Types::Base*);
153| void visit_dependent(Types::Dependent*);
154| void visit_declared(Types::Declared*);
155| void visit_template_type(Types::Template*);
156| void visit_parameterized(Types::Parameterized*);
157| void visit_func_ptr(Types::FuncPtr*);
158|
159| private:
160|
161| struct Private;
162| friend struct Private;
163| Private* m;
164|
165|
166|
167|
168| void addComments(PyObject* pydecl, AST::Declaration* cdecl);
169|
170| ///////// EVERYTHING BELOW HERE SUBJECT TO REVIEW AND DELETION
171|
172|
173| /*
174| PyObject *lookupType(const std::string &, PyObject *);
175| PyObject *lookupType(const std::string &);
176| PyObject *lookupType(const std::vector<std::string>& qualified);
177|
178| static void addInheritance(PyObject *, const std::vector<PyObject *> &);
179| static PyObject *N2L(const std::string &);
180| static PyObject *V2L(const std::vector<std::string> &);
181| static PyObject *V2L(const std::vector<PyObject *> &);
182| static PyObject *V2L(const std::vector<size_t> &);
183| void pushClassBases(PyObject* clas);
184| PyObject* resolveDeclared(PyObject*);
185| void addDeclaration(PyObject *);
186| */
187| private:
188| PyObject* m_ast;
189| PyObject* m_type;
190| PyObject* m_declarations;
191| PyObject* m_dictionary;
192|
193| FileFilter* m_filter;
194| };
195|
196| #endif
197|