22 virtual void write_c(std::ostream& out)
31 AtomicType(const AtomicType&);
32 AtomicType& operator=(const AtomicType&);
35 class BasicType : public AtomicType {
37 static BasicType VOID;
38 static BasicType BOOL;
39 static BasicType CHAR;
40 static BasicType SHORT;
42 static BasicType LONG;
43 static BasicType FLOAT;
44 static BasicType DOUBLE;
47 BasicType(const std::string& name)
56 : atomic_type(0), _unsigned(false), _const(false), _static(false),
60 void write_c_type(std::ostream& out)
66 atomic_type->write_c(out);
67 for(int i = 0; i < pointer; ++i)
69 for(int i = 0; i < ref; ++i)
77 if(atomic_type == &BasicType::VOID && pointer == 0)
82 AtomicType* atomic_type;
86 // number of '*' in the type declaration...
88 // number of '&' in the type declaration...
92 class SQIntegerType : public AtomicType {
96 this->name = "SQInteger";
97 assert(_instance == 0);
100 virtual ~SQIntegerType()
102 assert(_instance == this);
106 static SQIntegerType* instance()
111 static SQIntegerType* _instance;
114 class HSQUIRRELVMType : public AtomicType {
118 this->name = "HSQUIRRELVM";
119 assert(_instance == 0);
122 virtual ~HSQUIRRELVMType()
124 assert(_instance == this);
128 static HSQUIRRELVMType* instance()
133 static HSQUIRRELVMType* _instance;
136 class StringType : public AtomicType {
140 this->name = "string";
141 assert(_instance == 0);
144 virtual ~StringType()
146 assert(_instance == this);
150 static StringType* instance()
155 virtual void write_c(std::ostream& out)
157 out << "std::string";
161 static StringType* _instance;
181 virtual ~ClassMember()
189 Visibility visibility;
192 class Function : public ClassMember {
215 /// function should suspend squirrel VM after execution
217 /// a custom wrapper (just pass along HSQUIRRELVM)
219 std::string parameter_spec;
220 std::string docu_comment;
223 std::vector<Parameter> parameters;
226 class Field : public ClassMember {
237 has_const_value = false;
241 std::string docu_comment;
243 bool has_const_value;
245 float const_float_value;
247 std::string const_string_value;
251 Field& operator=(const Field&);
254 class Class : public AtomicType {
263 for(std::vector<ClassMember*>::iterator i = members.begin(); i != members.end(); ++i)
267 std::vector<ClassMember*> members;
268 std::vector<Class*> super_classes;
269 std::vector<Class*> sub_classes;
270 std::string docu_comment;
285 virtual ~Namespace() {
286 for(std::vector<Function*>::iterator i = functions.begin();
287 i != functions.end(); ++i)
289 for(std::vector<AtomicType*>::iterator i = types.begin();
290 i != types.end(); ++i)
292 for(std::vector<Namespace*>::iterator i = namespaces.begin();
293 i != namespaces.end(); ++i)
296 void add_type(AtomicType* type)
298 types.push_back(type);
301 void add_namespace(Namespace* ns)
303 namespaces.push_back(ns);
306 AtomicType* _findType(const std::string& name, bool godown = false) {
307 for(std::vector<AtomicType*>::iterator i = types.begin();
308 i != types.end(); ++i) {
309 AtomicType* type = *i;
310 if(type->name == name)
314 return parent->_findType(name, true);
319 Namespace* _findNamespace(const std::string& name, bool godown = false) {
320 for(std::vector<Namespace*>::iterator i = namespaces.begin();
321 i != namespaces.end(); ++i) {
327 return parent->_findNamespace(name, true);
332 Namespace* findNamespace(const std::string& name, bool godown = false) {
333 Namespace* ret = _findNamespace(name, godown);
335 std::ostringstream msg;
336 msg << "Couldn't find namespace '" << name << "'.";
337 throw std::runtime_error(msg.str());
343 std::vector<Function*> functions;
344 std::vector<Field*> fields;
345 std::vector<AtomicType*> types;
346 std::vector<Namespace*> namespaces;
352 Namespace(const Namespace&);
353 Namespace& operator=(const Namespace&);
356 class CompilationUnit : public Namespace {