interrogateFunctionWrapper.cxx 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. // Filename: interrogateFunctionWrapper.cxx
  2. // Created by: drose (06Aug00)
  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 "interrogateFunctionWrapper.h"
  15. #include "indexRemapper.h"
  16. #include "interrogate_datafile.h"
  17. #include <algorithm>
  18. ////////////////////////////////////////////////////////////////////
  19. // Function: InterrogateFunctionWrapper::Parameter::output
  20. // Access: Public
  21. // Description:
  22. ////////////////////////////////////////////////////////////////////
  23. void InterrogateFunctionWrapper::Parameter::
  24. output(ostream &out) const {
  25. idf_output_string(out, _name);
  26. out << _parameter_flags << " " << _type << " ";
  27. }
  28. ////////////////////////////////////////////////////////////////////
  29. // Function: InterrogateFunctionWrapper::Parameter::input
  30. // Access: Public
  31. // Description:
  32. ////////////////////////////////////////////////////////////////////
  33. void InterrogateFunctionWrapper::Parameter::
  34. input(istream &in) {
  35. idf_input_string(in, _name);
  36. in >> _parameter_flags >> _type;
  37. }
  38. ////////////////////////////////////////////////////////////////////
  39. // Function: InterrogateFunctionWrapper::output
  40. // Access: Public
  41. // Description: Formats the InterrogateFunctionWrapper data for
  42. // output to a data file.
  43. ////////////////////////////////////////////////////////////////////
  44. void InterrogateFunctionWrapper::
  45. output(ostream &out) const {
  46. InterrogateComponent::output(out);
  47. out << _flags << " "
  48. << _function << " "
  49. << _return_type << " "
  50. << _return_value_destructor << " ";
  51. idf_output_string(out, _unique_name);
  52. idf_output_vector(out, _parameters);
  53. }
  54. ////////////////////////////////////////////////////////////////////
  55. // Function: InterrogateFunctionWrapper::input
  56. // Access: Public
  57. // Description: Reads the data file as previously formatted by
  58. // output().
  59. ////////////////////////////////////////////////////////////////////
  60. void InterrogateFunctionWrapper::
  61. input(istream &in) {
  62. InterrogateComponent::input(in);
  63. in >> _flags
  64. >> _function
  65. >> _return_type
  66. >> _return_value_destructor;
  67. idf_input_string(in, _unique_name);
  68. idf_input_vector(in, _parameters);
  69. }
  70. ////////////////////////////////////////////////////////////////////
  71. // Function: InterrogateFunctionWrapper::remap_indices
  72. // Access: Public
  73. // Description: Remaps all internal index numbers according to the
  74. // indicated map. This called from
  75. // InterrogateDatabase::remap_indices().
  76. ////////////////////////////////////////////////////////////////////
  77. void InterrogateFunctionWrapper::
  78. remap_indices(const IndexRemapper &remap) {
  79. _return_value_destructor = remap.map_from(_return_value_destructor);
  80. _return_type = remap.map_from(_return_type);
  81. Parameters::iterator pi;
  82. for (pi = _parameters.begin(); pi != _parameters.end(); ++pi) {
  83. (*pi)._type = remap.map_from((*pi)._type);
  84. }
  85. }