Panda3D
|
00001 // Filename: interrogateFunction.h 00002 // Created by: drose (01Aug00) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #ifndef INTERROGATEFUNCTION_H 00016 #define INTERROGATEFUNCTION_H 00017 00018 #include "dtoolbase.h" 00019 00020 #include "interrogateComponent.h" 00021 00022 #include <vector> 00023 #include <map> 00024 00025 class IndexRemapper; 00026 class CPPInstance; 00027 00028 //////////////////////////////////////////////////////////////////// 00029 // Class : InterrogateFunction 00030 // Description : An internal representation of a function. 00031 //////////////////////////////////////////////////////////////////// 00032 class EXPCL_DTOOLCONFIG InterrogateFunction : public InterrogateComponent { 00033 public: 00034 InterrogateFunction(InterrogateModuleDef *def = NULL); 00035 InterrogateFunction(const InterrogateFunction ©); 00036 void operator = (const InterrogateFunction ©); 00037 00038 INLINE bool is_global() const; 00039 INLINE bool is_virtual() const; 00040 INLINE bool is_method() const; 00041 INLINE bool is_unary_op() const; 00042 INLINE bool is_operator_typecast() const; 00043 INLINE TypeIndex get_class() const; 00044 00045 INLINE bool has_scoped_name() const; 00046 INLINE const string &get_scoped_name() const; 00047 00048 INLINE bool has_comment() const; 00049 INLINE const string &get_comment() const; 00050 00051 INLINE bool has_prototype() const; 00052 INLINE const string &get_prototype() const; 00053 00054 INLINE int number_of_c_wrappers() const; 00055 INLINE FunctionWrapperIndex get_c_wrapper(int n) const; 00056 00057 INLINE int number_of_python_wrappers() const; 00058 INLINE FunctionWrapperIndex get_python_wrapper(int n) const; 00059 00060 void output(ostream &out) const; 00061 void input(istream &in); 00062 00063 void remap_indices(const IndexRemapper &remap); 00064 00065 private: 00066 enum Flags { 00067 F_global = 0x0001, 00068 F_virtual = 0x0002, 00069 F_method = 0x0004, 00070 F_typecast = 0x0008, 00071 F_getter = 0x0010, 00072 F_setter = 0x0020, 00073 F_unary_op = 0x0040, 00074 F_operator_typecast = 0x0080, 00075 }; 00076 00077 int _flags; 00078 string _scoped_name; 00079 string _comment; 00080 string _prototype; 00081 TypeIndex _class; 00082 00083 typedef vector<FunctionWrapperIndex> Wrappers; 00084 Wrappers _c_wrappers; 00085 Wrappers _python_wrappers; 00086 00087 public: 00088 // The rest of the members in this class aren't part of the public 00089 // interface to interrogate, but are used internally as the 00090 // interrogate database is built. They are valid only during the 00091 // session of interrogate that generates the database, and will not 00092 // be filled in when the database is reloaded from disk. 00093 00094 // This must be a pointer, rather than a concrete map, so we don't 00095 // risk trying to create a map in one DLL and access it in another. 00096 // Silly Windows. 00097 typedef map<string, CPPInstance *> Instances; 00098 Instances *_instances; 00099 string _expression; 00100 00101 friend class InterrogateBuilder; 00102 friend class InterfaceMakerC; 00103 friend class InterfaceMakerPythonSimple; 00104 friend class InterfaceMakerPythonNative; 00105 friend class FunctionRemap; 00106 }; 00107 00108 INLINE ostream &operator << (ostream &out, const InterrogateFunction &function); 00109 INLINE istream &operator >> (istream &in, InterrogateFunction &function); 00110 00111 #include "interrogateFunction.I" 00112 00113 #endif