Panda3D
|
00001 // Filename: interrogateFunctionWrapper.h 00002 // Created by: drose (06Aug00) 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 INTERROGATEFUNCTIONWRAPPER_H 00016 #define INTERROGATEFUNCTIONWRAPPER_H 00017 00018 #include "dtoolbase.h" 00019 00020 #include "interrogateComponent.h" 00021 00022 #include <vector> 00023 00024 class IndexRemapper; 00025 00026 //////////////////////////////////////////////////////////////////// 00027 // Class : InterrogateFunctionWrapper 00028 // Description : An internal representation of a callable function. 00029 //////////////////////////////////////////////////////////////////// 00030 class EXPCL_DTOOLCONFIG InterrogateFunctionWrapper : public InterrogateComponent { 00031 public: 00032 INLINE InterrogateFunctionWrapper(InterrogateModuleDef *def = NULL); 00033 INLINE InterrogateFunctionWrapper(const InterrogateFunctionWrapper ©); 00034 INLINE void operator = (const InterrogateFunctionWrapper ©); 00035 00036 INLINE FunctionIndex get_function() const; 00037 00038 INLINE bool is_callable_by_name() const; 00039 00040 INLINE bool has_return_value() const; 00041 INLINE TypeIndex get_return_type() const; 00042 INLINE bool caller_manages_return_value() const; 00043 INLINE FunctionIndex get_return_value_destructor() const; 00044 00045 INLINE int number_of_parameters() const; 00046 INLINE TypeIndex parameter_get_type(int n) const; 00047 INLINE bool parameter_has_name(int n) const; 00048 INLINE const string ¶meter_get_name(int n) const; 00049 INLINE bool parameter_is_this(int n) const; 00050 00051 INLINE const string &get_unique_name() const; 00052 00053 INLINE bool has_comment() const; 00054 INLINE const string &get_comment() const; 00055 00056 void output(ostream &out) const; 00057 void input(istream &in); 00058 00059 void remap_indices(const IndexRemapper &remap); 00060 00061 private: 00062 enum Flags { 00063 F_caller_manages = 0x0001, 00064 F_has_return = 0x0002, 00065 F_callable_by_name = 0x0004 00066 }; 00067 00068 enum ParameterFlags { 00069 PF_has_name = 0x0001, 00070 PF_is_this = 0x0002, 00071 }; 00072 00073 int _flags; 00074 FunctionIndex _function; 00075 TypeIndex _return_type; 00076 FunctionIndex _return_value_destructor; 00077 string _unique_name; 00078 string _comment; 00079 00080 public: 00081 // This nested class must be declared public just so we can declare 00082 // the external ostream and istream I/O operator functions, on the 00083 // SGI compiler. Arguably a compiler bug, but what can you do. 00084 class Parameter { 00085 public: 00086 void output(ostream &out) const; 00087 void input(istream &in); 00088 00089 int _parameter_flags; 00090 TypeIndex _type; 00091 string _name; 00092 }; 00093 00094 private: 00095 typedef vector<Parameter> Parameters; 00096 Parameters _parameters; 00097 00098 friend class InterrogateBuilder; 00099 friend class FunctionRemap; 00100 }; 00101 00102 INLINE ostream &operator << (ostream &out, const InterrogateFunctionWrapper &wrapper); 00103 INLINE istream &operator >> (istream &in, InterrogateFunctionWrapper &wrapper); 00104 00105 INLINE ostream &operator << (ostream &out, const InterrogateFunctionWrapper::Parameter &p); 00106 INLINE istream &operator >> (istream &in, InterrogateFunctionWrapper::Parameter &p); 00107 00108 #include "interrogateFunctionWrapper.I" 00109 00110 #endif