parameterRemapReferenceToPointer.cxx 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. // Filename: parameterRemapReferenceToPointer.cxx
  2. // Created by: drose (01Aug00)
  3. //
  4. ////////////////////////////////////////////////////////////////////
  5. //
  6. // PANDA 3D SOFTWARE
  7. // Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved
  8. //
  9. // All use of this software is subject to the terms of the Panda 3d
  10. // Software license. You should have received a copy of this license
  11. // along with this source code; you will also find a current copy of
  12. // the license at http://etc.cmu.edu/panda3d/docs/license/ .
  13. //
  14. // To contact the maintainers of this program write to
  15. // [email protected] .
  16. //
  17. ////////////////////////////////////////////////////////////////////
  18. #include "parameterRemapReferenceToPointer.h"
  19. #include "typeManager.h"
  20. #include "cppType.h"
  21. #include "cppDeclaration.h"
  22. #include "cppConstType.h"
  23. #include "cppPointerType.h"
  24. #include "cppReferenceType.h"
  25. ////////////////////////////////////////////////////////////////////
  26. // Function: ParameterRemapReferenceToPointer::Constructor
  27. // Access: Public
  28. // Description:
  29. ////////////////////////////////////////////////////////////////////
  30. ParameterRemapReferenceToPointer::
  31. ParameterRemapReferenceToPointer(CPPType *orig_type) :
  32. ParameterRemap(orig_type)
  33. {
  34. _new_type = TypeManager::wrap_pointer(TypeManager::unwrap_reference(orig_type));
  35. }
  36. ////////////////////////////////////////////////////////////////////
  37. // Function: ParameterRemapReferenceToPointer::pass_parameter
  38. // Access: Public, Virtual
  39. // Description: Outputs an expression that converts the indicated
  40. // variable from the new type to the original type, for
  41. // passing into the actual C++ function.
  42. ////////////////////////////////////////////////////////////////////
  43. void ParameterRemapReferenceToPointer::
  44. pass_parameter(ostream &out, const string &variable_name) {
  45. out << "*" << variable_name;
  46. }
  47. ////////////////////////////////////////////////////////////////////
  48. // Function: ParameterRemapReferenceToPointer::get_return_expr
  49. // Access: Public, Virtual
  50. // Description: Returns an expression that evalutes to the
  51. // appropriate value type for returning from the
  52. // function, given an expression of the original type.
  53. ////////////////////////////////////////////////////////////////////
  54. string ParameterRemapReferenceToPointer::
  55. get_return_expr(const string &expression) {
  56. return "&(" + expression + ")";
  57. }