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

dtool/src/cppparser/cppDeclaration.h

Go to the documentation of this file.
00001 // Filename: cppDeclaration.h
00002 // Created by:  drose (19Oct99)
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 CPPDECLARATION_H
00020 #define CPPDECLARATION_H
00021 
00022 #include <dtoolbase.h>
00023 
00024 #include "cppVisibility.h"
00025 #include "cppFile.h"
00026 #include "cppCommentBlock.h"
00027 
00028 #include <string>
00029 #include <vector>
00030 #include <map>
00031 #include <set>
00032 
00033 using namespace std;
00034 
00035 class CPPInstance;
00036 class CPPTemplateParameterList;
00037 class CPPTypedef;
00038 class CPPTypeDeclaration;
00039 class CPPExpression;
00040 class CPPType;
00041 class CPPNamespace;
00042 class CPPUsing;
00043 class CPPSimpleType;
00044 class CPPPointerType;
00045 class CPPReferenceType;
00046 class CPPArrayType;
00047 class CPPConstType;
00048 class CPPFunctionType;
00049 class CPPFunctionGroup;
00050 class CPPExtensionType;
00051 class CPPStructType;
00052 class CPPEnumType;
00053 class CPPTypeProxy;
00054 class CPPClassTemplateParameter;
00055 class CPPTBDType;
00056 class CPPScope;
00057 class CPPTemplateScope;
00058 class CPPPreprocessor;
00059 
00060 ///////////////////////////////////////////////////////////////////
00061 //       Class : CPPDeclaration
00062 // Description :
00063 ////////////////////////////////////////////////////////////////////
00064 class CPPDeclaration {
00065 public:
00066   enum SubType {
00067     // Subtypes of CPPDeclaration
00068     ST_instance,
00069     ST_typedef,
00070     ST_type_declaration,
00071     ST_expression,
00072     ST_type,
00073     ST_namespace,
00074     ST_using,
00075 
00076     // Subtypes of CPPType
00077     ST_simple,
00078     ST_pointer,
00079     ST_reference,
00080     ST_array,
00081     ST_const,
00082     ST_function,
00083     ST_function_group,
00084     ST_extension,
00085     ST_struct,
00086     ST_enum,
00087     ST_class_template_parameter,
00088     ST_tbd,
00089     ST_type_proxy,
00090   };
00091 
00092   CPPDeclaration(const CPPFile &file);
00093   CPPDeclaration(const CPPDeclaration &copy);
00094   virtual ~CPPDeclaration();
00095 
00096   bool operator == (const CPPDeclaration &other) const;
00097   bool operator != (const CPPDeclaration &other) const;
00098   bool operator < (const CPPDeclaration &other) const;
00099 
00100   bool is_template() const;
00101   CPPTemplateScope *get_template_scope() const;
00102   virtual bool is_fully_specified() const;
00103   virtual CPPDeclaration *
00104   instantiate(const CPPTemplateParameterList *actual_params,
00105               CPPScope *current_scope, CPPScope *global_scope,
00106               CPPPreprocessor *error_sink = NULL) const;
00107 
00108   typedef map<CPPDeclaration *, CPPDeclaration *> SubstDecl;
00109   virtual CPPDeclaration *substitute_decl(SubstDecl &subst,
00110                                           CPPScope *current_scope,
00111                                           CPPScope *global_scope);
00112 
00113   typedef set<CPPDeclaration *> Instantiations;
00114   Instantiations _instantiations;
00115 
00116   virtual void output(ostream &out, int indent_level, CPPScope *scope,
00117                       bool complete) const=0;
00118 
00119   virtual SubType get_subtype() const=0;
00120 
00121   virtual CPPInstance *as_instance();
00122   virtual CPPClassTemplateParameter *as_class_template_parameter();
00123   virtual CPPTypedef *as_typedef();
00124   virtual CPPTypeDeclaration *as_type_declaration();
00125   virtual CPPExpression *as_expression();
00126   virtual CPPType *as_type();
00127   virtual CPPNamespace *as_namespace();
00128   virtual CPPUsing *as_using();
00129   virtual CPPSimpleType *as_simple_type();
00130   virtual CPPPointerType *as_pointer_type();
00131   virtual CPPReferenceType *as_reference_type();
00132   virtual CPPArrayType *as_array_type();
00133   virtual CPPConstType *as_const_type();
00134   virtual CPPFunctionType *as_function_type();
00135   virtual CPPFunctionGroup *as_function_group();
00136   virtual CPPExtensionType *as_extension_type();
00137   virtual CPPStructType *as_struct_type();
00138   virtual CPPEnumType *as_enum_type();
00139   virtual CPPTBDType *as_tbd_type();
00140   virtual CPPTypeProxy *as_type_proxy();
00141 
00142   CPPVisibility _vis;
00143   CPPTemplateScope *_template_scope;
00144   CPPFile _file;
00145   CPPCommentBlock *_leading_comment;
00146 
00147 protected:
00148   virtual bool is_equal(const CPPDeclaration *other) const;
00149   virtual bool is_less(const CPPDeclaration *other) const;
00150 };
00151 
00152 inline ostream &
00153 operator << (ostream &out, const CPPDeclaration &decl) {
00154   decl.output(out, 0, (CPPScope *)NULL, false);
00155   return out;
00156 }
00157 
00158 
00159 #endif
00160 
00161 
00162 

Generated on Thu May 1 22:12:50 2003 for DTool by doxygen1.3