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

dtool/src/interrogate/functionRemap.h

Go to the documentation of this file.
00001 // Filename: functionRemap.h
00002 // Created by:  drose (19Sep01)
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 FUNCTIONREMAP_H
00020 #define FUNCTIONREMAP_H
00021 
00022 #include "dtoolbase.h"
00023 
00024 #include "interrogate_interface.h"
00025 #include "vector_string.h"
00026 
00027 #include <vector>
00028 
00029 class InterrogateBuilder;
00030 class InterrogateType;
00031 class InterrogateFunction;
00032 class ParameterRemap;
00033 class CPPType;
00034 class CPPInstance;
00035 class CPPStructType;
00036 class CPPScope;
00037 class CPPFunctionType;
00038 class InterfaceMaker;
00039 
00040 ////////////////////////////////////////////////////////////////////
00041 //       Class : FunctionRemap
00042 // Description : This class describes how to remap a C++ function (and
00043 //               its list of parameters and return type) to a wrapped
00044 //               function, for a particular scripting language.
00045 //
00046 //               The InterfaceMaker class will create one of these for
00047 //               each function, including one for each instance of an
00048 //               overloaded function.
00049 ////////////////////////////////////////////////////////////////////
00050 class FunctionRemap {
00051 public:
00052   FunctionRemap(const InterrogateType &itype,
00053                 const InterrogateFunction &ifunc,
00054                 CPPInstance *cppfunc, int num_default_parameters,
00055                 InterfaceMaker *interface);
00056   ~FunctionRemap();
00057 
00058   string get_parameter_name(int n) const;
00059   string call_function(ostream &out, int indent_level, 
00060                        bool convert_result, const string &container,
00061                        const vector_string &pexprs = vector_string()) const;
00062 
00063   void write_orig_prototype(ostream &out, int indent_level) const;
00064 
00065   FunctionWrapperIndex make_wrapper_entry(FunctionIndex function_index);
00066 
00067   class Parameter {
00068   public:
00069     bool _has_name;
00070     string _name;
00071     ParameterRemap *_remap;
00072   };
00073 
00074   enum Type {
00075     T_normal,
00076     T_constructor,
00077     T_destructor,
00078     T_typecast_method,
00079     T_assignment_method,
00080     T_typecast,
00081     T_getter,
00082     T_setter
00083   };
00084 
00085   typedef vector<Parameter> Parameters;
00086 
00087   Parameters _parameters;
00088   ParameterRemap *_return_type;
00089   bool _void_return;
00090   bool _has_this;
00091   int _first_true_parameter;
00092   int _num_default_parameters;
00093   Type _type;
00094   string _expression;
00095   string _function_signature;
00096   string _hash;
00097   string _unique_name;
00098   string _wrapper_name;
00099   FunctionWrapperIndex _wrapper_index;
00100   
00101   bool _return_value_needs_management;
00102   FunctionIndex _return_value_destructor;
00103   bool _manage_reference_count;
00104 
00105   CPPType *_cpptype;
00106   CPPScope *_cppscope;
00107   CPPInstance *_cppfunc;
00108   CPPFunctionType *_ftype;
00109 
00110   bool _is_valid;
00111 
00112 private:
00113   string
00114   get_call_str(const string &container, const vector_string &pexprs) const;
00115 
00116   string
00117   get_parameter_expr(int n, const vector_string &pexprs) const;
00118 
00119   bool
00120   setup_properties(const InterrogateFunction &ifunc, InterfaceMaker *interface);
00121 };
00122 
00123 #endif

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