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

dtool/src/cppparser/cppInstance.h

Go to the documentation of this file.
00001 // Filename: cppInstance.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 CPPINSTANCE_H
00020 #define CPPINSTANCE_H
00021 
00022 #include <dtoolbase.h>
00023 
00024 #include "cppDeclaration.h"
00025 #include "cppType.h"
00026 #include "cppIdentifier.h"
00027 #include "cppTemplateParameterList.h"
00028 
00029 class CPPInstanceIdentifier;
00030 class CPPIdentifier;
00031 class CPPParameterList;
00032 class CPPScope;
00033 class CPPExpression;
00034 
00035 ///////////////////////////////////////////////////////////////////
00036 //       Class : CPPInstance
00037 // Description :
00038 ////////////////////////////////////////////////////////////////////
00039 class CPPInstance : public CPPDeclaration {
00040 public:
00041   // Some of these flags clearly only make sense in certain contexts,
00042   // e.g. for a function or method.
00043   enum StorageClass {
00044     SC_static       = 0x001,
00045     SC_extern       = 0x002,
00046     SC_c_binding    = 0x004,
00047     SC_virtual      = 0x008,
00048     SC_inline       = 0x010,
00049     SC_explicit     = 0x020,
00050     SC_register     = 0x040,
00051     SC_pure_virtual = 0x080,
00052     SC_volatile     = 0x100,
00053     SC_mutable      = 0x200,
00054 
00055     // This bit is only set by CPPStructType::check_virtual().
00056     SC_inherited_virtual = 0x400,
00057   };
00058 
00059   CPPInstance(CPPType *type, const string &name, int storage_class = 0);
00060   CPPInstance(CPPType *type, CPPIdentifier *ident, int storage_class = 0);
00061   CPPInstance(CPPType *type, CPPInstanceIdentifier *ii,
00062               int storage_class, const CPPFile &file);
00063   CPPInstance(const CPPInstance &copy);
00064   ~CPPInstance();
00065 
00066   static CPPInstance *
00067   make_typecast_function(CPPInstance *inst, CPPIdentifier *ident,
00068                          CPPParameterList *parameters, int function_flags);
00069 
00070   bool operator == (const CPPInstance &other) const;
00071   bool operator != (const CPPInstance &other) const;
00072   bool operator < (const CPPInstance &other) const;
00073 
00074   void set_initializer(CPPExpression *initializer);
00075 
00076   bool is_scoped() const;
00077   CPPScope *get_scope(CPPScope *current_scope, CPPScope *global_scope,
00078                       CPPPreprocessor *error_sink = NULL) const;
00079 
00080   string get_simple_name() const;
00081   string get_local_name(CPPScope *scope = NULL) const;
00082   string get_fully_scoped_name() const;
00083 
00084   void check_for_constructor(CPPScope *current_scope, CPPScope *global_scope);
00085 
00086   virtual CPPDeclaration *
00087   instantiate(const CPPTemplateParameterList *actual_params,
00088               CPPScope *current_scope, CPPScope *global_scope,
00089               CPPPreprocessor *error_sink = NULL) const;
00090 
00091   virtual bool is_fully_specified() const;
00092   virtual CPPDeclaration *substitute_decl(SubstDecl &subst,
00093                                           CPPScope *current_scope,
00094                                           CPPScope *global_scope);
00095 
00096   virtual void output(ostream &out, int indent_level, CPPScope *scope,
00097                       bool complete) const;
00098   void output(ostream &out, int indent_level, CPPScope *scope,
00099               bool complete, int num_default_parameters) const;
00100   virtual SubType get_subtype() const;
00101 
00102   virtual CPPInstance *as_instance();
00103 
00104   CPPType *_type;
00105   CPPIdentifier *_ident;
00106   CPPExpression *_initializer;
00107 
00108   int _storage_class;
00109 
00110 private:
00111   typedef map<const CPPTemplateParameterList *, CPPInstance *, CPPTPLCompare> Instantiations;
00112   Instantiations _instantiations;
00113 };
00114 
00115 #endif
00116 

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