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

dtool/src/interrogatedb/interrogateFunctionWrapper.h

Go to the documentation of this file.
00001 // Filename: interrogateFunctionWrapper.h
00002 // Created by:  drose (06Aug00)
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 INTERROGATEFUNCTIONWRAPPER_H
00020 #define INTERROGATEFUNCTIONWRAPPER_H
00021 
00022 #include <dtoolbase.h>
00023 
00024 #include "interrogateComponent.h"
00025 
00026 #include <vector>
00027 
00028 class IndexRemapper;
00029 
00030 ////////////////////////////////////////////////////////////////////
00031 //       Class : InterrogateFunctionWrapper
00032 // Description : An internal representation of a callable function.
00033 ////////////////////////////////////////////////////////////////////
00034 class EXPCL_DTOOLCONFIG InterrogateFunctionWrapper : public InterrogateComponent {
00035 public:
00036   INLINE InterrogateFunctionWrapper(InterrogateModuleDef *def = NULL);
00037   INLINE InterrogateFunctionWrapper(const InterrogateFunctionWrapper &copy);
00038   INLINE void operator = (const InterrogateFunctionWrapper &copy);
00039 
00040   INLINE FunctionIndex get_function() const;
00041 
00042   INLINE bool is_callable_by_name() const;
00043 
00044   INLINE bool has_return_value() const;
00045   INLINE TypeIndex get_return_type() const;
00046   INLINE bool caller_manages_return_value() const;
00047   INLINE FunctionIndex get_return_value_destructor() const;
00048 
00049   INLINE int number_of_parameters() const;
00050   INLINE TypeIndex parameter_get_type(int n) const;
00051   INLINE bool parameter_has_name(int n) const;
00052   INLINE const string &parameter_get_name(int n) const;
00053   INLINE bool parameter_is_this(int n) const;
00054 
00055   INLINE const string &get_unique_name() const;
00056 
00057   void output(ostream &out) const;
00058   void input(istream &in);
00059 
00060   void remap_indices(const IndexRemapper &remap);
00061 
00062 private:
00063   enum Flags {
00064     F_caller_manages   = 0x0001,
00065     F_has_return       = 0x0002,
00066     F_callable_by_name = 0x0004
00067   };
00068 
00069   enum ParameterFlags {
00070     PF_has_name       = 0x0001,
00071     PF_is_this        = 0x0002,
00072   };
00073 
00074   int _flags;
00075   FunctionIndex _function;
00076   TypeIndex _return_type;
00077   FunctionIndex _return_value_destructor;
00078   string _unique_name;
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

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