00001 // Filename: parameterRemapReferenceToPointer.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 "parameterRemapReferenceToPointer.h" 00020 #include "typeManager.h" 00021 00022 #include <cppType.h> 00023 #include <cppDeclaration.h> 00024 #include <cppConstType.h> 00025 #include <cppPointerType.h> 00026 #include <cppReferenceType.h> 00027 00028 //////////////////////////////////////////////////////////////////// 00029 // Function: ParameterRemapReferenceToPointer::Constructor 00030 // Access: Public 00031 // Description: 00032 //////////////////////////////////////////////////////////////////// 00033 ParameterRemapReferenceToPointer:: 00034 ParameterRemapReferenceToPointer(CPPType *orig_type) : 00035 ParameterRemap(orig_type) 00036 { 00037 _new_type = TypeManager::wrap_pointer(TypeManager::unwrap_reference(orig_type)); 00038 } 00039 00040 //////////////////////////////////////////////////////////////////// 00041 // Function: ParameterRemapReferenceToPointer::pass_parameter 00042 // Access: Public, Virtual 00043 // Description: Outputs an expression that converts the indicated 00044 // variable from the new type to the original type, for 00045 // passing into the actual C++ function. 00046 //////////////////////////////////////////////////////////////////// 00047 void ParameterRemapReferenceToPointer:: 00048 pass_parameter(ostream &out, const string &variable_name) { 00049 out << "*" << variable_name; 00050 } 00051 00052 //////////////////////////////////////////////////////////////////// 00053 // Function: ParameterRemapReferenceToPointer::get_return_expr 00054 // Access: Public, Virtual 00055 // Description: Returns an expression that evalutes to the 00056 // appropriate value type for returning from the 00057 // function, given an expression of the original type. 00058 //////////////////////////////////////////////////////////////////// 00059 string ParameterRemapReferenceToPointer:: 00060 get_return_expr(const string &expression) { 00061 return "&(" + expression + ")"; 00062 }