00001 // Filename: interrogateFunctionWrapper.cxx 00002 // Created by: drose (06Aug00) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) 2001, Disney Enterprises, Inc. All rights reserved 00008 // 00009 // All use of this software is subject to the terms of the Panda 3d 00010 // Software license. You should have received a copy of this license 00011 // along with this source code; you will also find a current copy of 00012 // the license at http://www.panda3d.org/license.txt . 00013 // 00014 // To contact the maintainers of this program write to 00015 // panda3d@yahoogroups.com . 00016 // 00017 //////////////////////////////////////////////////////////////////// 00018 00019 #include "interrogateFunctionWrapper.h" 00020 #include "indexRemapper.h" 00021 #include "interrogate_datafile.h" 00022 00023 #include <algorithm> 00024 00025 //////////////////////////////////////////////////////////////////// 00026 // Function: InterrogateFunctionWrapper::Parameter::output 00027 // Access: Public 00028 // Description: 00029 //////////////////////////////////////////////////////////////////// 00030 void InterrogateFunctionWrapper::Parameter:: 00031 output(ostream &out) const { 00032 idf_output_string(out, _name); 00033 out << _parameter_flags << " " << _type << " "; 00034 } 00035 00036 //////////////////////////////////////////////////////////////////// 00037 // Function: InterrogateFunctionWrapper::Parameter::input 00038 // Access: Public 00039 // Description: 00040 //////////////////////////////////////////////////////////////////// 00041 void InterrogateFunctionWrapper::Parameter:: 00042 input(istream &in) { 00043 idf_input_string(in, _name); 00044 in >> _parameter_flags >> _type; 00045 } 00046 00047 //////////////////////////////////////////////////////////////////// 00048 // Function: InterrogateFunctionWrapper::output 00049 // Access: Public 00050 // Description: Formats the InterrogateFunctionWrapper data for 00051 // output to a data file. 00052 //////////////////////////////////////////////////////////////////// 00053 void InterrogateFunctionWrapper:: 00054 output(ostream &out) const { 00055 InterrogateComponent::output(out); 00056 out << _flags << " " 00057 << _function << " " 00058 << _return_type << " " 00059 << _return_value_destructor << " "; 00060 idf_output_string(out, _unique_name); 00061 idf_output_vector(out, _parameters); 00062 } 00063 00064 //////////////////////////////////////////////////////////////////// 00065 // Function: InterrogateFunctionWrapper::input 00066 // Access: Public 00067 // Description: Reads the data file as previously formatted by 00068 // output(). 00069 //////////////////////////////////////////////////////////////////// 00070 void InterrogateFunctionWrapper:: 00071 input(istream &in) { 00072 InterrogateComponent::input(in); 00073 in >> _flags 00074 >> _function 00075 >> _return_type 00076 >> _return_value_destructor; 00077 idf_input_string(in, _unique_name); 00078 idf_input_vector(in, _parameters); 00079 } 00080 00081 //////////////////////////////////////////////////////////////////// 00082 // Function: InterrogateFunctionWrapper::remap_indices 00083 // Access: Public 00084 // Description: Remaps all internal index numbers according to the 00085 // indicated map. This called from 00086 // InterrogateDatabase::remap_indices(). 00087 //////////////////////////////////////////////////////////////////// 00088 void InterrogateFunctionWrapper:: 00089 remap_indices(const IndexRemapper &remap) { 00090 _return_value_destructor = remap.map_from(_return_value_destructor); 00091 _return_type = remap.map_from(_return_type); 00092 00093 Parameters::iterator pi; 00094 for (pi = _parameters.begin(); pi != _parameters.end(); ++pi) { 00095 (*pi)._type = remap.map_from((*pi)._type); 00096 } 00097 }