Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members  

dtool/src/interrogatedb/interrogateType.h

Go to the documentation of this file.
00001 // Filename: interrogateType.h
00002 // Created by:  drose (31Jul00)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 
00019 #ifndef INTERROGATETYPE_H
00020 #define INTERROGATETYPE_H
00021 
00022 #include <dtoolbase.h>
00023 
00024 #include "interrogateComponent.h"
00025 
00026 #include <vector>
00027 
00028 class IndexRemapper;
00029 class CPPType;
00030 class CPPScope;
00031 
00032 ////////////////////////////////////////////////////////////////////
00033 //       Class : InterrogateType
00034 // Description : An internal representation of a type.
00035 ////////////////////////////////////////////////////////////////////
00036 class EXPCL_DTOOLCONFIG InterrogateType : public InterrogateComponent {
00037 public:
00038   INLINE InterrogateType(InterrogateModuleDef *def = NULL);
00039   INLINE InterrogateType(const InterrogateType &copy);
00040   void operator = (const InterrogateType &copy);
00041 
00042   INLINE bool is_global() const;
00043 
00044   INLINE bool has_scoped_name() const;
00045   INLINE const string &get_scoped_name() const;
00046 
00047   INLINE bool has_true_name() const;
00048   INLINE const string &get_true_name() const;
00049 
00050   INLINE bool has_comment() const;
00051   INLINE const string &get_comment() const;
00052 
00053   INLINE bool is_nested() const;
00054   INLINE TypeIndex get_outer_class() const;
00055 
00056   INLINE bool is_atomic() const;
00057   INLINE AtomicToken get_atomic_token() const;
00058   INLINE bool is_unsigned() const;
00059   INLINE bool is_signed() const;
00060   INLINE bool is_long() const;
00061   INLINE bool is_longlong() const;
00062   INLINE bool is_short() const;
00063 
00064   INLINE bool is_wrapped() const;
00065   INLINE bool is_pointer() const;
00066   INLINE bool is_const() const;
00067   INLINE TypeIndex get_wrapped_type() const;
00068 
00069   INLINE bool is_enum() const;
00070   INLINE int number_of_enum_values() const;
00071   INLINE const string &get_enum_value_name(int n) const;
00072   INLINE const string &get_enum_value_scoped_name(int n) const;
00073   INLINE int get_enum_value(int n) const;
00074 
00075   INLINE bool is_struct() const;
00076   INLINE bool is_class() const;
00077   INLINE bool is_union() const;
00078 
00079   INLINE bool is_fully_defined() const;
00080   INLINE bool is_unpublished() const;
00081   INLINE int number_of_constructors() const;
00082   INLINE FunctionIndex get_constructor(int n) const;
00083   INLINE bool has_destructor() const;
00084   INLINE bool destructor_is_inherited() const;
00085   INLINE FunctionIndex get_destructor() const;
00086   INLINE int number_of_elements() const;
00087   INLINE ElementIndex get_element(int n) const;
00088   INLINE int number_of_methods() const;
00089   INLINE FunctionIndex get_method(int n) const;
00090 
00091   INLINE int number_of_casts() const;
00092   INLINE FunctionIndex get_cast(int n) const;
00093 
00094   INLINE int number_of_derivations() const;
00095   INLINE TypeIndex get_derivation(int n) const;
00096 
00097   INLINE bool derivation_has_upcast(int n) const;
00098   INLINE FunctionIndex derivation_get_upcast(int n) const;
00099 
00100   INLINE bool derivation_downcast_is_impossible(int n) const;
00101   INLINE bool derivation_has_downcast(int n) const;
00102   INLINE FunctionIndex derivation_get_downcast(int n) const;
00103 
00104   INLINE int number_of_nested_types() const;
00105   INLINE TypeIndex get_nested_type(int n) const;
00106 
00107   void merge_with(const InterrogateType &other);
00108   void output(ostream &out) const;
00109   void input(istream &in);
00110 
00111   void remap_indices(const IndexRemapper &remap);
00112 
00113 private:
00114   enum Flags {
00115     F_global               = 0x000001,
00116     F_atomic               = 0x000002,
00117     F_unsigned             = 0x000004,
00118     F_signed               = 0x000008,
00119     F_long                 = 0x000010,
00120     F_longlong             = 0x000020,
00121     F_short                = 0x000040,
00122     F_wrapped              = 0x000080,
00123     F_pointer              = 0x000100,
00124     F_const                = 0x000200,
00125     F_struct               = 0x000400,
00126     F_class                = 0x000800,
00127     F_union                = 0x001000,
00128     F_fully_defined        = 0x002000,
00129     F_true_destructor      = 0x004000,
00130     F_private_destructor   = 0x008000,
00131     F_inherited_destructor = 0x010000,
00132     F_implicit_destructor  = 0x020000,
00133     F_nested               = 0x040000,
00134     F_enum                 = 0x080000,
00135     F_unpublished          = 0x100000,
00136   };
00137 
00138   int _flags;
00139   string _scoped_name;
00140   string _true_name;
00141   string _comment;
00142   TypeIndex _outer_class;
00143   AtomicToken _atomic_token;
00144   TypeIndex _wrapped_type;
00145 
00146   typedef vector<FunctionIndex> Functions;
00147   Functions _constructors;
00148   FunctionIndex _destructor;
00149 
00150   typedef vector<ElementIndex> Elements;
00151   Elements _elements;
00152   Functions _methods;
00153   Functions _casts;
00154 
00155   enum DerivationFlags {
00156     DF_upcast               = 0x01,
00157     DF_downcast             = 0x02,
00158     DF_downcast_impossible  = 0x04
00159   };
00160 
00161 public:
00162   // This nested class must be declared public just so we can declare
00163   // the external ostream and istream I/O operator functions, on the
00164   // SGI compiler.  Arguably a compiler bug, but what can you do.
00165   class Derivation {
00166   public:
00167     void output(ostream &out) const;
00168     void input(istream &in);
00169 
00170     int _flags;
00171     TypeIndex _base;
00172     FunctionIndex _upcast;
00173     FunctionIndex _downcast;
00174   };
00175 
00176 private:
00177   typedef vector<Derivation> Derivations;
00178   Derivations _derivations;
00179 
00180 public:
00181   // This nested class must also be public, for the same reason.
00182   class EnumValue {
00183   public:
00184     void output(ostream &out) const;
00185     void input(istream &in);
00186 
00187     string _name;
00188     string _scoped_name;
00189     int _value;
00190   };
00191 
00192 private:
00193   typedef vector<EnumValue> EnumValues;
00194   EnumValues _enum_values;
00195 
00196   typedef vector<TypeIndex> Types;
00197   Types _nested_types;
00198 
00199   static string _empty_string;
00200 
00201 public:
00202   // The rest of the members in this class aren't part of the public
00203   // interface to interrogate, but are used internally as the
00204   // interrogate database is built.  They are valid only during the
00205   // session of interrogate that generates the database, and will not
00206   // be filled in when the database is reloaded from disk.
00207   CPPType *_cpptype;
00208   CPPScope *_cppscope;
00209 
00210   friend class InterrogateBuilder;
00211 };
00212 
00213 INLINE ostream &operator << (ostream &out, const InterrogateType &type);
00214 INLINE istream &operator >> (istream &in, InterrogateType &type);
00215 
00216 INLINE ostream &operator << (ostream &out, const InterrogateType::Derivation &d);
00217 INLINE istream &operator >> (istream &in, InterrogateType::Derivation &d);
00218 
00219 INLINE ostream &operator << (ostream &out, const InterrogateType::EnumValue &d);
00220 INLINE istream &operator >> (istream &in, InterrogateType::EnumValue &d);
00221 
00222 #include "interrogateType.I"
00223 
00224 #endif

Generated on Thu May 1 22:13:07 2003 for DTool by doxygen1.3