Synopsis - Cross-Reference

File: /src/Synopsis/ASG/TypeId.hh
  1//
  2// Copyright (C) 2004 Stefan Seefeld
  3// All rights reserved.
  4// Licensed to the public under the terms of the GNU LGPL (>= 2),
  5// see the file COPYING for details.
  6//
  7
  8#ifndef _Synopsis_ASG_TypeId_hh
  9#define _Synopsis_ASG_TypeId_hh
 10
 11#include <Synopsis/Python/Object.hh>
 12#include <Synopsis/Python/TypedList.hh>
 13#include <Synopsis/ASG/Visitor.hh>
 14
 15namespace Synopsis
 16{
 17typedef Python::TypedList<std::string> ScopedName;
 18namespace ASG
 19{
 20
 21typedef Python::TypedList<std::string> Modifiers;
 22
 23class TypeId : public Python::Object
 24{
 25public:
 26  TypeId() {}
 27  TypeId(const Python::Object &o, bool check = true)
 28    : Python::Object(o) { if (check && o) assert_type("TypeId");}
 29
 30  std::string language() const { return narrow<std::string>(attr("language")());}
 31
 32  virtual void accept(TypeIdVisitor *v) { v->visit_type_id(this);}
 33
 34  void assert_type(const char *type_id) { Python::Object::assert_type("Synopsis.ASG", type_id);}
 35};
 36
 37typedef Python::TypedList<TypeId> TypeIdList;
 38
 39class NamedTypeId : public TypeId
 40{
 41public:
 42  NamedTypeId() {}
 43  NamedTypeId(const Python::Object &o, bool check = true)
 44    : TypeId(o, false) { if (check && o) assert_type("NamedTypeId");}
 45
 46  ScopedName name() const { return attr("name")();}  
 47
 48  virtual void accept(TypeIdVisitor *v) { v->visit_named_type_id(this);}
 49};
 50
 51class BuiltinTypeId : public NamedTypeId
 52{
 53public:
 54  BuiltinTypeId() {}
 55  BuiltinTypeId(const Python::Object &o, bool check = true)
 56    : NamedTypeId(o, false) { if (check && o) assert_type("BuiltinTypeId");}
 57
 58  virtual void accept(TypeIdVisitor *v) { v->visit_builtin_type_id(this);}
 59};
 60
 61class DependentTypeId : public NamedTypeId
 62{
 63public:
 64  DependentTypeId() {}
 65  DependentTypeId(const Python::Object &o, bool check = true)
 66    : NamedTypeId(o, false) { if (check && o) assert_type("DependentTypeId");}
 67
 68  virtual void accept(TypeIdVisitor *v) { v->visit_dependent_type_id(this);}
 69};
 70
 71class UnknownTypeId : public NamedTypeId
 72{
 73public:
 74  UnknownTypeId() {}
 75  UnknownTypeId(const Python::Object &o, bool check = true)
 76    : NamedTypeId(o, false) { if (check && o) assert_type("UnknownTypeId");}
 77
 78  virtual void accept(TypeIdVisitor *v) { v->visit_unknown_type_id(this);}
 79};
 80
 81class ModifierTypeId : public TypeId
 82{
 83public:
 84  ModifierTypeId() {}
 85  ModifierTypeId(const Python::Object &o, bool check = true)
 86    : TypeId(o, false) { if (check && o) assert_type("ModifierTypeId");}
 87
 88  TypeId alias() const { return narrow<TypeId>(attr("alias")());}
 89  Modifiers pre() const { return narrow<Modifiers>(attr("premod")());}  
 90  Modifiers post() const { return narrow<Modifiers>(attr("postmod")());}  
 91
 92  virtual void accept(TypeIdVisitor *v) { v->visit_modifier_type_id(this);}
 93};
 94
 95class ArrayTypeId : public TypeId
 96{
 97public:
 98  typedef Python::TypedList<size_t> Sizes;
 99
100  ArrayTypeId() {}
101  ArrayTypeId(const Python::Object &o, bool check = true)
102    : TypeId(o, false) { if (check && o) assert_type("ArrayTypeId");}
103
104  Sizes sizes() const { return narrow<Sizes>(attr("sizes")());}  
105
106  virtual void accept(TypeIdVisitor *v) { v->visit_array_type_id(this);}
107};
108
109class FunctionTypeId : public TypeId
110{
111public:
112  FunctionTypeId() {}
113  FunctionTypeId(const Python::Object &o, bool check = true)
114    : TypeId(o, false) { if (check && o) assert_type("FunctionTypeId");}
115
116  TypeId return_type() const { return narrow<TypeId>(attr("return_type")());}  
117  Modifiers pre() const { return narrow<Modifiers>(attr("premod")());}  
118  TypeIdList parameters() const { return narrow<TypeIdList>(attr("parameters")());}
119
120  virtual void accept(TypeIdVisitor *v) { v->visit_function_type_id(this);}
121};
122
123}
124}
125
126#endif