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

dtool/src/cppparser/cppInstanceIdentifier.h

Go to the documentation of this file.
00001 // Filename: cppInstanceIdentifier.h
00002 // Created by:  drose (21Oct99)
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 CPPINSTANCEIDENTIFIER_H
00020 #define CPPINSTANCEIDENTIFIER_H
00021 
00022 #include <dtoolbase.h>
00023 
00024 #include <vector>
00025 #include <string>
00026 
00027 using namespace std;
00028 
00029 class CPPIdentifier;
00030 class CPPParameterList;
00031 class CPPType;
00032 class CPPExpression;
00033 class CPPScope;
00034 class CPPPreprocessor;
00035 
00036 enum CPPInstanceIdentifierType {
00037   IIT_pointer,
00038   IIT_reference,
00039   IIT_scoped_pointer,
00040   IIT_array,
00041   IIT_const,
00042   IIT_paren,
00043   IIT_func,
00044 };
00045 
00046 ///////////////////////////////////////////////////////////////////
00047 //       Class : CPPInstanceIdentifier
00048 // Description : This class is used in parser.y to build up a variable
00049 //               instance definition.  An instance is something like
00050 //               'int *&a'; the InstanceIdentifier stores everything
00051 //               to the right of the typename.  Later this can be
00052 //               passed to make_instance() to construct a CPPInstance.
00053 ////////////////////////////////////////////////////////////////////
00054 class CPPInstanceIdentifier {
00055 public:
00056   CPPInstanceIdentifier(CPPIdentifier *ident);
00057 
00058   CPPType *unroll_type(CPPType *start_type);
00059 
00060   void add_modifier(CPPInstanceIdentifierType type);
00061   void add_func_modifier(CPPParameterList *params, int flags);
00062   void add_scoped_pointer_modifier(CPPIdentifier *scoping);
00063   void add_array_modifier(CPPExpression *expr);
00064 
00065   CPPScope *get_scope(CPPScope *current_scope, CPPScope *global_scope,
00066                       CPPPreprocessor *error_sink = NULL) const;
00067 
00068   CPPIdentifier *_ident;
00069 
00070   class Modifier {
00071   public:
00072     Modifier(CPPInstanceIdentifierType type);
00073     static Modifier func_type(CPPParameterList *params, int flags);
00074     static Modifier array_type(CPPExpression *expr);
00075     static Modifier scoped_pointer_type(CPPIdentifier *scoping);
00076 
00077     CPPInstanceIdentifierType _type;
00078     CPPParameterList *_func_params;
00079     int _func_flags;
00080     CPPIdentifier *_scoping;
00081     CPPExpression *_expr;
00082   };
00083   typedef vector<Modifier> Modifiers;
00084   Modifiers _modifiers;
00085 
00086 private:
00087   CPPType *
00088   r_unroll_type(CPPType *start_type, Modifiers::const_iterator mi);
00089 };
00090 
00091 #endif

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