parameterRemapBasicStringToString.cxx 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // Filename: parameterRemapBasicStringToString.C
  2. // Created by: drose (09Aug00)
  3. //
  4. ////////////////////////////////////////////////////////////////////
  5. #include "parameterRemapBasicStringToString.h"
  6. #include "wrapperBuilder.h"
  7. ////////////////////////////////////////////////////////////////////
  8. // Function: ParameterRemapBasicStringToString::Constructor
  9. // Access: Public
  10. // Description:
  11. ////////////////////////////////////////////////////////////////////
  12. ParameterRemapBasicStringToString::
  13. ParameterRemapBasicStringToString(CPPType *orig_type) :
  14. ParameterRemapToString(orig_type)
  15. {
  16. }
  17. ////////////////////////////////////////////////////////////////////
  18. // Function: ParameterRemapBasicStringToString::pass_parameter
  19. // Access: Public, Virtual
  20. // Description: Outputs an expression that converts the indicated
  21. // variable from the original type to the new type, for
  22. // passing into the actual C++ function.
  23. ////////////////////////////////////////////////////////////////////
  24. void ParameterRemapBasicStringToString::
  25. pass_parameter(ostream &out, const string &variable_name) {
  26. out << variable_name;
  27. }
  28. ////////////////////////////////////////////////////////////////////
  29. // Function: ParameterRemapBasicStringToString::prepare_return_expr
  30. // Access: Public, Virtual
  31. // Description: This will be called immediately before
  32. // get_return_expr(). It outputs whatever lines the
  33. // remapper needs to the function to set up its return
  34. // value, e.g. to declare a temporary variable or
  35. // something. It should return the modified expression.
  36. ////////////////////////////////////////////////////////////////////
  37. string ParameterRemapBasicStringToString::
  38. prepare_return_expr(ostream &out, int indent_level, const string &expression) {
  39. WrapperBuilder::indent(out, indent_level)
  40. << "static basic_string<char> string_holder = " << expression << ";\n";
  41. return "string_holder";
  42. }
  43. ////////////////////////////////////////////////////////////////////
  44. // Function: ParameterRemapBasicStringToString::get_return_expr
  45. // Access: Public, Virtual
  46. // Description: Returns an expression that evalutes to the
  47. // appropriate value type for returning from the
  48. // function, given an expression of the original type.
  49. ////////////////////////////////////////////////////////////////////
  50. string ParameterRemapBasicStringToString::
  51. get_return_expr(const string &expression) {
  52. return "string_holder.c_str()";
  53. }