Panda3D
|
00001 // Filename: interrogateFunction.cxx 00002 // Created by: drose (01Aug00) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 #include "interrogateFunction.h" 00016 #include "indexRemapper.h" 00017 #include "interrogate_datafile.h" 00018 #include "interrogateDatabase.h" 00019 00020 //////////////////////////////////////////////////////////////////// 00021 // Function: InterrogateFunction::Constructor 00022 // Access: Public 00023 // Description: 00024 //////////////////////////////////////////////////////////////////// 00025 InterrogateFunction:: 00026 InterrogateFunction(InterrogateModuleDef *def) : 00027 InterrogateComponent(def) 00028 { 00029 _flags = 0; 00030 _class = 0; 00031 _instances = (Instances *)NULL; 00032 } 00033 00034 //////////////////////////////////////////////////////////////////// 00035 // Function: InterrogateFunction::Copy Constructor 00036 // Access: Public 00037 // Description: 00038 //////////////////////////////////////////////////////////////////// 00039 InterrogateFunction:: 00040 InterrogateFunction(const InterrogateFunction ©) { 00041 (*this) = copy; 00042 } 00043 00044 //////////////////////////////////////////////////////////////////// 00045 // Function: InterrogateFunction::Copy Assignment Operator 00046 // Access: Public 00047 // Description: 00048 //////////////////////////////////////////////////////////////////// 00049 void InterrogateFunction:: 00050 operator = (const InterrogateFunction ©) { 00051 InterrogateComponent::operator = (copy); 00052 _flags = copy._flags; 00053 _scoped_name = copy._scoped_name; 00054 _comment = copy._comment; 00055 _prototype = copy._prototype; 00056 _class = copy._class; 00057 _c_wrappers = copy._c_wrappers; 00058 _python_wrappers = copy._python_wrappers; 00059 00060 _instances = copy._instances; 00061 _expression = copy._expression; 00062 } 00063 00064 //////////////////////////////////////////////////////////////////// 00065 // Function: InterrogateFunction::output 00066 // Access: Public 00067 // Description: Formats the InterrogateFunction data for output to a data 00068 // file. 00069 //////////////////////////////////////////////////////////////////// 00070 void InterrogateFunction:: 00071 output(ostream &out) const { 00072 InterrogateComponent::output(out); 00073 out << _flags << " " 00074 << _class << " "; 00075 idf_output_string(out, _scoped_name); 00076 idf_output_vector(out, _c_wrappers); 00077 idf_output_vector(out, _python_wrappers); 00078 idf_output_string(out, _comment, '\n'); 00079 idf_output_string(out, _prototype, '\n'); 00080 } 00081 00082 //////////////////////////////////////////////////////////////////// 00083 // Function: InterrogateFunction::input 00084 // Access: Public 00085 // Description: Reads the data file as previously formatted by 00086 // output(). 00087 //////////////////////////////////////////////////////////////////// 00088 void InterrogateFunction:: 00089 input(istream &in) { 00090 InterrogateComponent::input(in); 00091 in >> _flags >> _class; 00092 idf_input_string(in, _scoped_name); 00093 idf_input_vector(in, _c_wrappers); 00094 idf_input_vector(in, _python_wrappers); 00095 idf_input_string(in, _comment); 00096 00097 if (InterrogateDatabase::get_file_minor_version() >= 2) { 00098 idf_input_string(in, _prototype); 00099 } 00100 } 00101 00102 //////////////////////////////////////////////////////////////////// 00103 // Function: InterrogateFunction::remap_indices 00104 // Access: Public 00105 // Description: Remaps all internal index numbers according to the 00106 // indicated map. This called from 00107 // InterrogateDatabase::remap_indices(). 00108 //////////////////////////////////////////////////////////////////// 00109 void InterrogateFunction:: 00110 remap_indices(const IndexRemapper &remap) { 00111 _class = remap.map_from(_class); 00112 Wrappers::iterator wi; 00113 for (wi = _c_wrappers.begin(); wi != _c_wrappers.end(); ++wi) { 00114 (*wi) = remap.map_from(*wi); 00115 } 00116 for (wi = _python_wrappers.begin(); wi != _python_wrappers.end(); ++wi) { 00117 (*wi) = remap.map_from(*wi); 00118 } 00119 }