parameterRemapBasicStringToString.cxx 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. // Filename: parameterRemapBasicStringToString.cxx
  2. // Created by: drose (09Aug00)
  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 "parameterRemapBasicStringToString.h"
  19. #include "interfaceMaker.h"
  20. ////////////////////////////////////////////////////////////////////
  21. // Function: ParameterRemapBasicStringToString::Constructor
  22. // Access: Public
  23. // Description:
  24. ////////////////////////////////////////////////////////////////////
  25. ParameterRemapBasicStringToString::
  26. ParameterRemapBasicStringToString(CPPType *orig_type) :
  27. ParameterRemapToString(orig_type)
  28. {
  29. }
  30. ////////////////////////////////////////////////////////////////////
  31. // Function: ParameterRemapBasicStringToString::pass_parameter
  32. // Access: Public, Virtual
  33. // Description: Outputs an expression that converts the indicated
  34. // variable from the original type to the new type, for
  35. // passing into the actual C++ function.
  36. ////////////////////////////////////////////////////////////////////
  37. void ParameterRemapBasicStringToString::
  38. pass_parameter(ostream &out, const string &variable_name) {
  39. out << variable_name;
  40. }
  41. ////////////////////////////////////////////////////////////////////
  42. // Function: ParameterRemapBasicStringToString::prepare_return_expr
  43. // Access: Public, Virtual
  44. // Description: This will be called immediately before
  45. // get_return_expr(). It outputs whatever lines the
  46. // remapper needs to the function to set up its return
  47. // value, e.g. to declare a temporary variable or
  48. // something. It should return the modified expression.
  49. ////////////////////////////////////////////////////////////////////
  50. string ParameterRemapBasicStringToString::
  51. prepare_return_expr(ostream &out, int indent_level, const string &expression) {
  52. InterfaceMaker::indent(out, indent_level)
  53. << "static string string_holder = " << expression << ";\n";
  54. return "string_holder";
  55. }
  56. ////////////////////////////////////////////////////////////////////
  57. // Function: ParameterRemapBasicStringToString::get_return_expr
  58. // Access: Public, Virtual
  59. // Description: Returns an expression that evalutes to the
  60. // appropriate value type for returning from the
  61. // function, given an expression of the original type.
  62. ////////////////////////////////////////////////////////////////////
  63. string ParameterRemapBasicStringToString::
  64. get_return_expr(const string &expression) {
  65. return "string_holder.c_str()";
  66. }
  67. ////////////////////////////////////////////////////////////////////
  68. // Function: ParameterRemapBasicWStringToWString::Constructor
  69. // Access: Public
  70. // Description:
  71. ////////////////////////////////////////////////////////////////////
  72. ParameterRemapBasicWStringToWString::
  73. ParameterRemapBasicWStringToWString(CPPType *orig_type) :
  74. ParameterRemapToString(orig_type)
  75. {
  76. }
  77. ////////////////////////////////////////////////////////////////////
  78. // Function: ParameterRemapBasicWStringToWString::pass_parameter
  79. // Access: Public, Virtual
  80. // Description: Outputs an expression that converts the indicated
  81. // variable from the original type to the new type, for
  82. // passing into the actual C++ function.
  83. ////////////////////////////////////////////////////////////////////
  84. void ParameterRemapBasicWStringToWString::
  85. pass_parameter(ostream &out, const string &variable_name) {
  86. out << variable_name;
  87. }
  88. ////////////////////////////////////////////////////////////////////
  89. // Function: ParameterRemapBasicWStringToWString::prepare_return_expr
  90. // Access: Public, Virtual
  91. // Description: This will be called immediately before
  92. // get_return_expr(). It outputs whatever lines the
  93. // remapper needs to the function to set up its return
  94. // value, e.g. to declare a temporary variable or
  95. // something. It should return the modified expression.
  96. ////////////////////////////////////////////////////////////////////
  97. string ParameterRemapBasicWStringToWString::
  98. prepare_return_expr(ostream &out, int indent_level, const string &expression) {
  99. InterfaceMaker::indent(out, indent_level)
  100. << "static wstring string_holder = " << expression << ";\n";
  101. return "string_holder";
  102. }
  103. ////////////////////////////////////////////////////////////////////
  104. // Function: ParameterRemapBasicWStringToWString::get_return_expr
  105. // Access: Public, Virtual
  106. // Description: Returns an expression that evalutes to the
  107. // appropriate value type for returning from the
  108. // function, given an expression of the original type.
  109. ////////////////////////////////////////////////////////////////////
  110. string ParameterRemapBasicWStringToWString::
  111. get_return_expr(const string &expression) {
  112. return "string_holder.c_str()";
  113. }