parameterRemapReferenceToPointer.cxx 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. // Filename: parameterRemapReferenceToPointer.C
  2. // Created by: drose (01Aug00)
  3. //
  4. ////////////////////////////////////////////////////////////////////
  5. #include "parameterRemapReferenceToPointer.h"
  6. #include "typeManager.h"
  7. #include <cppType.h>
  8. #include <cppDeclaration.h>
  9. #include <cppConstType.h>
  10. #include <cppPointerType.h>
  11. #include <cppReferenceType.h>
  12. ////////////////////////////////////////////////////////////////////
  13. // Function: ParameterRemapReferenceToPointer::Constructor
  14. // Access: Public
  15. // Description:
  16. ////////////////////////////////////////////////////////////////////
  17. ParameterRemapReferenceToPointer::
  18. ParameterRemapReferenceToPointer(CPPType *orig_type) :
  19. ParameterRemap(orig_type)
  20. {
  21. _new_type = TypeManager::wrap_pointer(TypeManager::unwrap_reference(orig_type));
  22. }
  23. ////////////////////////////////////////////////////////////////////
  24. // Function: ParameterRemapReferenceToPointer::pass_parameter
  25. // Access: Public, Virtual
  26. // Description: Outputs an expression that converts the indicated
  27. // variable from the new type to the original type, for
  28. // passing into the actual C++ function.
  29. ////////////////////////////////////////////////////////////////////
  30. void ParameterRemapReferenceToPointer::
  31. pass_parameter(ostream &out, const string &variable_name) {
  32. out << "*" << variable_name;
  33. }
  34. ////////////////////////////////////////////////////////////////////
  35. // Function: ParameterRemapReferenceToPointer::get_return_expr
  36. // Access: Public, Virtual
  37. // Description: Returns an expression that evalutes to the
  38. // appropriate value type for returning from the
  39. // function, given an expression of the original type.
  40. ////////////////////////////////////////////////////////////////////
  41. string ParameterRemapReferenceToPointer::
  42. get_return_expr(const string &expression) {
  43. return "&(" + expression + ")";
  44. }