parameterRemapBasicStringPtrToString.cxx 4.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. // Filename: parameterRemapBasicStringPtrToString.cxx
  2. // Created by: drose (11Aug09)
  3. //
  4. ////////////////////////////////////////////////////////////////////
  5. //
  6. // PANDA 3D SOFTWARE
  7. // Copyright (c) Carnegie Mellon University. All rights reserved.
  8. //
  9. // All use of this software is subject to the terms of the revised BSD
  10. // license. You should have received a copy of this license along
  11. // with this source code in a file named "LICENSE."
  12. //
  13. ////////////////////////////////////////////////////////////////////
  14. #include "parameterRemapBasicStringPtrToString.h"
  15. #include "interrogate.h"
  16. ////////////////////////////////////////////////////////////////////
  17. // Function: ParameterRemapBasicStringPtrToString::Constructor
  18. // Access: Public
  19. // Description:
  20. ////////////////////////////////////////////////////////////////////
  21. ParameterRemapBasicStringPtrToString::
  22. ParameterRemapBasicStringPtrToString(CPPType *orig_type) :
  23. ParameterRemapToString(orig_type)
  24. {
  25. static CPPType *const_char_star_type = (CPPType *)NULL;
  26. if (const_char_star_type == (CPPType *)NULL) {
  27. const_char_star_type = parser.parse_type("const char *");
  28. }
  29. _new_type = const_char_star_type;
  30. }
  31. ////////////////////////////////////////////////////////////////////
  32. // Function: ParameterRemapBasicStringPtrToString::pass_parameter
  33. // Access: Public, Virtual
  34. // Description: Outputs an expression that converts the indicated
  35. // variable from the original type to the new type, for
  36. // passing into the actual C++ function.
  37. ////////////////////////////////////////////////////////////////////
  38. void ParameterRemapBasicStringPtrToString::
  39. pass_parameter(ostream &out, const string &variable_name) {
  40. out << "&std::string(" << variable_name << ")";
  41. }
  42. ////////////////////////////////////////////////////////////////////
  43. // Function: ParameterRemapBasicStringPtrToString::get_return_expr
  44. // Access: Public, Virtual
  45. // Description: Returns an expression that evalutes to the
  46. // appropriate value type for returning from the
  47. // function, given an expression of the original type.
  48. ////////////////////////////////////////////////////////////////////
  49. string ParameterRemapBasicStringPtrToString::
  50. get_return_expr(const string &expression) {
  51. return "(" + expression + ")->c_str()";
  52. }
  53. ////////////////////////////////////////////////////////////////////
  54. // Function: ParameterRemapBasicWStringPtrToWString::Constructor
  55. // Access: Public
  56. // Description:
  57. ////////////////////////////////////////////////////////////////////
  58. ParameterRemapBasicWStringPtrToWString::
  59. ParameterRemapBasicWStringPtrToWString(CPPType *orig_type) :
  60. ParameterRemapToWString(orig_type)
  61. {
  62. static CPPType *const_wchar_star_type = (CPPType *)NULL;
  63. if (const_wchar_star_type == (CPPType *)NULL) {
  64. const_wchar_star_type = parser.parse_type("const wchar_t *");
  65. }
  66. _new_type = const_wchar_star_type;
  67. }
  68. ////////////////////////////////////////////////////////////////////
  69. // Function: ParameterRemapBasicWStringPtrToWString::pass_parameter
  70. // Access: Public, Virtual
  71. // Description: Outputs an expression that converts the indicated
  72. // variable from the original type to the new type, for
  73. // passing into the actual C++ function.
  74. ////////////////////////////////////////////////////////////////////
  75. void ParameterRemapBasicWStringPtrToWString::
  76. pass_parameter(ostream &out, const string &variable_name) {
  77. out << "&std::wstring(" << variable_name << ")";
  78. }
  79. ////////////////////////////////////////////////////////////////////
  80. // Function: ParameterRemapBasicWStringPtrToWString::get_return_expr
  81. // Access: Public, Virtual
  82. // Description: Returns an expression that evalutes to the
  83. // appropriate value type for returning from the
  84. // function, given an expression of the original type.
  85. ////////////////////////////////////////////////////////////////////
  86. string ParameterRemapBasicWStringPtrToWString::
  87. get_return_expr(const string &expression) {
  88. return "(" + expression + ")->c_str()";
  89. }