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

dtool/src/interrogate/parameterRemapConcreteToPointer.cxx

Go to the documentation of this file.
00001 // Filename: parameterRemapConcreteToPointer.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 "parameterRemapConcreteToPointer.h"
00020 #include "interrogate.h"
00021 #include "interrogateBuilder.h"
00022 #include "typeManager.h"
00023 
00024 #include <cppType.h>
00025 #include <cppDeclaration.h>
00026 #include <cppConstType.h>
00027 #include <cppPointerType.h>
00028 
00029 ////////////////////////////////////////////////////////////////////
00030 //     Function: ParameterRemapConcreteToPointer::Constructor
00031 //       Access: Public
00032 //  Description:
00033 ////////////////////////////////////////////////////////////////////
00034 ParameterRemapConcreteToPointer::
00035 ParameterRemapConcreteToPointer(CPPType *orig_type) :
00036   ParameterRemap(orig_type)
00037 {
00038   _new_type = TypeManager::wrap_pointer(orig_type);
00039 }
00040 
00041 ////////////////////////////////////////////////////////////////////
00042 //     Function: ParameterRemapConcreteToPointer::pass_parameter
00043 //       Access: Public, Virtual
00044 //  Description: Outputs an expression that converts the indicated
00045 //               variable from the new type to the original type, for
00046 //               passing into the actual C++ function.
00047 ////////////////////////////////////////////////////////////////////
00048 void ParameterRemapConcreteToPointer::
00049 pass_parameter(ostream &out, const string &variable_name) {
00050   out << "*" << variable_name;
00051 }
00052 
00053 ////////////////////////////////////////////////////////////////////
00054 //     Function: ParameterRemapConcreteToPointer::get_return_expr
00055 //       Access: Public, Virtual
00056 //  Description: Returns an expression that evalutes to the
00057 //               appropriate value type for returning from the
00058 //               function, given an expression of the original type.
00059 ////////////////////////////////////////////////////////////////////
00060 string ParameterRemapConcreteToPointer::
00061 get_return_expr(const string &expression) {
00062   return
00063     "new " + _orig_type->get_local_name(&parser) +
00064     "(" + expression + ")";
00065 }
00066 
00067 ////////////////////////////////////////////////////////////////////
00068 //     Function: ParameterRemapConcreteToPointer::return_value_needs_management
00069 //       Access: Public, Virtual
00070 //  Description: Returns true if the return value represents a value
00071 //               that was newly allocated, and hence must be
00072 //               explicitly deallocated later by the caller.
00073 ////////////////////////////////////////////////////////////////////
00074 bool ParameterRemapConcreteToPointer::
00075 return_value_needs_management() {
00076   return true;
00077 }
00078 
00079 ////////////////////////////////////////////////////////////////////
00080 //     Function: ParameterRemapConcreteToPointer::get_return_value_destructor
00081 //       Access: Public, Virtual
00082 //  Description: If return_value_needs_management() returns true, this
00083 //               should return the index of the function that should
00084 //               be called when it is time to destruct the return
00085 //               value.  It will generally be the same as the
00086 //               destructor for the class we just returned a pointer
00087 //               to.
00088 ////////////////////////////////////////////////////////////////////
00089 FunctionIndex ParameterRemapConcreteToPointer::
00090 get_return_value_destructor() {
00091   return builder.get_destructor_for(_orig_type);
00092 }
00093 
00094 ////////////////////////////////////////////////////////////////////
00095 //     Function: ParameterRemapConcreteToPointer::return_value_should_be_simple
00096 //       Access: Public, Virtual
00097 //  Description: This is a hack around a problem VC++ has with
00098 //               overly-complex expressions, particularly in
00099 //               conjunction with the 'new' operator.  If this
00100 //               parameter type is one that will probably give VC++ a
00101 //               headache, this should be set true to indicate that
00102 //               the code generator should save the return value
00103 //               expression into a temporary variable first, and pass
00104 //               the temporary variable name in instead.
00105 ////////////////////////////////////////////////////////////////////
00106 bool ParameterRemapConcreteToPointer::
00107 return_value_should_be_simple() {
00108   return true;
00109 }

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