interrogateFunction.cxx 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. // Filename: interrogateFunction.cxx
  2. // Created by: drose (01Aug00)
  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 "interrogateFunction.h"
  15. #include "indexRemapper.h"
  16. #include "interrogate_datafile.h"
  17. #include "interrogateDatabase.h"
  18. ////////////////////////////////////////////////////////////////////
  19. // Function: InterrogateFunction::Copy Assignment Operator
  20. // Access: Public
  21. // Description:
  22. ////////////////////////////////////////////////////////////////////
  23. void InterrogateFunction::
  24. operator = (const InterrogateFunction &copy) {
  25. InterrogateComponent::operator = (copy);
  26. _flags = copy._flags;
  27. _scoped_name = copy._scoped_name;
  28. _comment = copy._comment;
  29. _prototype = copy._prototype;
  30. _class = copy._class;
  31. _c_wrappers = copy._c_wrappers;
  32. _python_wrappers = copy._python_wrappers;
  33. _instances = copy._instances;
  34. _expression = copy._expression;
  35. }
  36. ////////////////////////////////////////////////////////////////////
  37. // Function: InterrogateFunction::output
  38. // Access: Public
  39. // Description: Formats the InterrogateFunction data for output to a data
  40. // file.
  41. ////////////////////////////////////////////////////////////////////
  42. void InterrogateFunction::
  43. output(ostream &out) const {
  44. InterrogateComponent::output(out);
  45. out << _flags << " "
  46. << _class << " ";
  47. idf_output_string(out, _scoped_name);
  48. idf_output_vector(out, _c_wrappers);
  49. idf_output_vector(out, _python_wrappers);
  50. idf_output_string(out, _comment, '\n');
  51. idf_output_string(out, _prototype, '\n');
  52. }
  53. ////////////////////////////////////////////////////////////////////
  54. // Function: InterrogateFunction::input
  55. // Access: Public
  56. // Description: Reads the data file as previously formatted by
  57. // output().
  58. ////////////////////////////////////////////////////////////////////
  59. void InterrogateFunction::
  60. input(istream &in) {
  61. InterrogateComponent::input(in);
  62. in >> _flags >> _class;
  63. idf_input_string(in, _scoped_name);
  64. idf_input_vector(in, _c_wrappers);
  65. idf_input_vector(in, _python_wrappers);
  66. idf_input_string(in, _comment);
  67. if (InterrogateDatabase::get_file_minor_version() >= 2) {
  68. idf_input_string(in, _prototype);
  69. }
  70. }
  71. ////////////////////////////////////////////////////////////////////
  72. // Function: InterrogateFunction::remap_indices
  73. // Access: Public
  74. // Description: Remaps all internal index numbers according to the
  75. // indicated map. This called from
  76. // InterrogateDatabase::remap_indices().
  77. ////////////////////////////////////////////////////////////////////
  78. void InterrogateFunction::
  79. remap_indices(const IndexRemapper &remap) {
  80. _class = remap.map_from(_class);
  81. Wrappers::iterator wi;
  82. for (wi = _c_wrappers.begin(); wi != _c_wrappers.end(); ++wi) {
  83. (*wi) = remap.map_from(*wi);
  84. }
  85. for (wi = _python_wrappers.begin(); wi != _python_wrappers.end(); ++wi) {
  86. (*wi) = remap.map_from(*wi);
  87. }
  88. }