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

dtool/src/interrogate/interrogateBuilder.h

Go to the documentation of this file.
00001 // Filename: interrogateBuilder.h
00002 // Created by:  drose (01Aug00)
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 INTERROGATEBUILDER_H
00020 #define INTERROGATEBUILDER_H
00021 
00022 #include <dtoolbase.h>
00023 
00024 #include "interrogate_interface.h"
00025 #include "interrogate_request.h"
00026 
00027 #include <map>
00028 #include <set>
00029 #include <vector>
00030 
00031 class CPPFunctionGroup;
00032 class CPPInstance;
00033 class CPPType;
00034 class CPPSimpleType;
00035 class CPPPointerType;
00036 class CPPConstType;
00037 class CPPExtensionType;
00038 class CPPStructType;
00039 class CPPEnumType;
00040 class CPPFunctionType;
00041 class CPPScope;
00042 class CPPIdentifier;
00043 class CPPNameComponent;
00044 class CPPManifest;
00045 class InterrogateType;
00046 class InterrogateFunction;
00047 class FunctionRemap;
00048 class InterfaceMaker;
00049 
00050 ////////////////////////////////////////////////////////////////////
00051 //       Class : InterrogateBuilder
00052 // Description : This class builds up the InterrogateDatabase based on
00053 //               the data indicated by CPPParser after reading the
00054 //               source code.
00055 ////////////////////////////////////////////////////////////////////
00056 class InterrogateBuilder {
00057 public:
00058   void add_source_file(const string &filename);
00059   void read_command_file(istream &in);
00060   void do_command(const string &command, const string &params);
00061   void build();
00062   void write_code(ostream &out, InterrogateModuleDef *def);
00063   InterrogateModuleDef *make_module_def(int file_identifier);
00064 
00065   static string clean_identifier(const string &name);
00066   static string descope(const string &name);
00067   FunctionIndex get_destructor_for(CPPType *type);
00068 
00069   string get_preferred_name(CPPType *type);
00070   static string hash_string(const string &name, int shift_offset);
00071 
00072 private:
00073   typedef set<string> Commands;
00074   typedef map<string, string> CommandParams;
00075   void insert_param_list(InterrogateBuilder::Commands &commands,
00076                          const string &params);
00077 
00078   bool in_forcetype(const string &name) const;
00079   string in_renametype(const string &name) const;
00080   bool in_ignoretype(const string &name) const;
00081   bool in_ignoreinvolved(const string &name) const;
00082   bool in_ignoreinvolved(CPPType *type) const;
00083   bool in_ignorefile(const string &name) const;
00084   bool in_ignoremember(const string &name) const;
00085   bool in_noinclude(const string &name) const;
00086   bool should_include(const string &filename) const;
00087 
00088   void remap_indices(vector<FunctionRemap *> &remaps);
00089   void scan_function(CPPFunctionGroup *fgroup);
00090   void scan_function(CPPInstance *function);
00091   void scan_struct_type(CPPStructType *type);
00092   void scan_enum_type(CPPEnumType *type);
00093   void scan_manifest(CPPManifest *manifest);
00094   ElementIndex scan_element(CPPInstance *element, CPPStructType *struct_type,
00095                             CPPScope *scope);
00096 
00097   FunctionIndex get_getter(CPPType *expr_type, string expression,
00098                            CPPStructType *struct_type, CPPScope *scope,
00099                            CPPInstance *element);
00100   FunctionIndex get_setter(CPPType *expr_type, string expression,
00101                            CPPStructType *struct_type, CPPScope *scope,
00102                            CPPInstance *element);
00103   FunctionIndex get_cast_function(CPPType *to_type, CPPType *from_type,
00104                                   const string &prefix);
00105   FunctionIndex
00106   get_function(CPPInstance *function, string description,
00107                CPPStructType *struct_type, CPPScope *scope,
00108                int flags, const string &expression = string());
00109 
00110   TypeIndex get_atomic_string_type();
00111   TypeIndex get_type(CPPType *type, bool global);
00112 
00113   void define_atomic_type(InterrogateType &itype, CPPSimpleType *cpptype);
00114   void define_wrapped_type(InterrogateType &itype, CPPPointerType *cpptype);
00115   void define_wrapped_type(InterrogateType &itype, CPPConstType *cpptype);
00116   void define_struct_type(InterrogateType &itype, CPPStructType *cpptype,
00117                           TypeIndex type_index, bool forced);
00118   void update_method_comment(CPPInstance *function, CPPStructType *struct_type,
00119                              CPPScope *scope);
00120   void define_method(CPPFunctionGroup *fgroup, InterrogateType &itype,
00121                      CPPStructType *struct_type, CPPScope *scope);
00122   void define_method(CPPInstance *function, InterrogateType &itype,
00123                      CPPStructType *struct_type, CPPScope *scope);
00124   void define_enum_type(InterrogateType &itype, CPPEnumType *cpptype);
00125   void define_extension_type(InterrogateType &itype,
00126                              CPPExtensionType *cpptype);
00127 
00128   static string trim_blanks(const string &str);
00129 
00130   typedef map<string, TypeIndex> TypesByName;
00131   typedef map<string, FunctionIndex> FunctionsByName;
00132 
00133   TypesByName _types_by_name;
00134   FunctionsByName _functions_by_name;
00135 
00136   typedef map<string, char> IncludeFiles;
00137   IncludeFiles _include_files;
00138 
00139   Commands _forcetype;
00140   CommandParams _renametype;
00141   Commands _ignoretype;
00142   Commands _ignoreinvolved;
00143   Commands _ignorefile;
00144   Commands _ignoremember;
00145   Commands _noinclude;
00146 
00147   string _library_hash_name;
00148 
00149   friend class FunctionRemap;
00150 };
00151 
00152 extern InterrogateBuilder builder;
00153 
00154 #endif
00155 
00156 

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