00001 // Filename: parameterRemap.cxx 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 #include "parameterRemap.h" 00020 00021 00022 //////////////////////////////////////////////////////////////////// 00023 // Function: ParameterRemap::Destructor 00024 // Access: Public, Virtual 00025 // Description: 00026 //////////////////////////////////////////////////////////////////// 00027 ParameterRemap:: 00028 ~ParameterRemap() { 00029 } 00030 00031 //////////////////////////////////////////////////////////////////// 00032 // Function: ParameterRemap::pass_parameter 00033 // Access: Public, Virtual 00034 // Description: Outputs an expression that converts the indicated 00035 // variable from the original type to the new type, for 00036 // passing into the actual C++ function. 00037 //////////////////////////////////////////////////////////////////// 00038 void ParameterRemap:: 00039 pass_parameter(ostream &out, const string &variable_name) { 00040 out << variable_name; 00041 } 00042 00043 //////////////////////////////////////////////////////////////////// 00044 // Function: ParameterRemap::prepare_return_expr 00045 // Access: Public, Virtual 00046 // Description: This will be called immediately before 00047 // get_return_expr(). It outputs whatever lines the 00048 // remapper needs to the function to set up its return 00049 // value, e.g. to declare a temporary variable or 00050 // something. It should return the modified expression. 00051 //////////////////////////////////////////////////////////////////// 00052 string ParameterRemap:: 00053 prepare_return_expr(ostream &, int, const string &expression) { 00054 return expression; 00055 } 00056 00057 //////////////////////////////////////////////////////////////////// 00058 // Function: ParameterRemap::get_return_expr 00059 // Access: Public, Virtual 00060 // Description: Returns an expression that evalutes to the 00061 // appropriate value type for returning from the 00062 // function, given an expression of the original type. 00063 //////////////////////////////////////////////////////////////////// 00064 string ParameterRemap:: 00065 get_return_expr(const string &expression) { 00066 return expression; 00067 } 00068 00069 //////////////////////////////////////////////////////////////////// 00070 // Function: ParameterRemap::temporary_to_return 00071 // Access: Public, Virtual 00072 // Description: Returns the string that converts the expression 00073 // stored in the indicated temporary variable to the 00074 // appropriate return value type. This is normally a 00075 // pass-through, but in cases when the temporary 00076 // variable type must be different than the return type 00077 // (i.e. get_temporary_type() != get_new_type()), this 00078 // might perform some operation. 00079 //////////////////////////////////////////////////////////////////// 00080 string ParameterRemap:: 00081 temporary_to_return(const string &temporary) { 00082 return temporary; 00083 } 00084 00085 //////////////////////////////////////////////////////////////////// 00086 // Function: ParameterRemap::return_value_needs_management 00087 // Access: Public, Virtual 00088 // Description: Returns true if the return value represents a value 00089 // that was newly allocated, and hence must be 00090 // explicitly deallocated later by the caller. 00091 //////////////////////////////////////////////////////////////////// 00092 bool ParameterRemap:: 00093 return_value_needs_management() { 00094 return false; 00095 } 00096 00097 //////////////////////////////////////////////////////////////////// 00098 // Function: ParameterRemap::get_return_value_destructor 00099 // Access: Public, Virtual 00100 // Description: If return_value_needs_management() returns true, this 00101 // should return the index of the function that should 00102 // be called when it is time to destruct the return 00103 // value. It will generally be the same as the 00104 // destructor for the class we just returned a pointer 00105 // to. 00106 //////////////////////////////////////////////////////////////////// 00107 FunctionIndex ParameterRemap:: 00108 get_return_value_destructor() { 00109 return 0; 00110 } 00111 00112 //////////////////////////////////////////////////////////////////// 00113 // Function: ParameterRemap::return_value_should_be_simple 00114 // Access: Public, Virtual 00115 // Description: This is a hack around a problem VC++ has with 00116 // overly-complex expressions, particularly in 00117 // conjunction with the 'new' operator. If this 00118 // parameter type is one that will probably give VC++ a 00119 // headache, this should be set true to indicate that 00120 // the code generator should save the return value 00121 // expression into a temporary variable first, and pass 00122 // the temporary variable name in instead. 00123 //////////////////////////////////////////////////////////////////// 00124 bool ParameterRemap:: 00125 return_value_should_be_simple() { 00126 return false; 00127 } 00128 00129 00130 //////////////////////////////////////////////////////////////////// 00131 // Function: ParameterRemap::new_type_is_atomic_string 00132 // Access: Public, Virtual 00133 // Description: Returns true if the type represented by the 00134 // conversion is now the atomic string type. We have to 00135 // have this crazy method for representing atomic 00136 // string, because there's no such type in C (and hence 00137 // no corresponding CPPType *). 00138 //////////////////////////////////////////////////////////////////// 00139 bool ParameterRemap:: 00140 new_type_is_atomic_string() { 00141 return false; 00142 } 00143 00144 //////////////////////////////////////////////////////////////////// 00145 // Function: ParameterRemap::is_this 00146 // Access: Public, Virtual 00147 // Description: Returns true if this is the "this" parameter. 00148 //////////////////////////////////////////////////////////////////// 00149 bool ParameterRemap:: 00150 is_this() { 00151 return false; 00152 } 00153