mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 10:22:45 -04:00
regularize output() and write() and make more consistent with other Panda conventions
This commit is contained in:
parent
634ed836a1
commit
98aabb1568
@ -189,8 +189,9 @@ DCField *DCClass::
|
|||||||
get_field(int n) const {
|
get_field(int n) const {
|
||||||
#ifndef NDEBUG //[
|
#ifndef NDEBUG //[
|
||||||
if (n < 0 || n >= (int)_fields.size()) {
|
if (n < 0 || n >= (int)_fields.size()) {
|
||||||
write(cerr, 0);
|
cerr << *this << " "
|
||||||
cerr<<"n:"<<n<<" _fields.size():"<<(int)_fields.size()<<endl;
|
<< "n:" << n << " _fields.size():"
|
||||||
|
<< (int)_fields.size() << endl;
|
||||||
// __asm { int 3 }
|
// __asm { int 3 }
|
||||||
}
|
}
|
||||||
#endif //]
|
#endif //]
|
||||||
@ -268,41 +269,21 @@ get_inherited_field(int n) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function : output
|
// Function : DCClass::output
|
||||||
// Access : Published
|
// Access : Published, Virtual
|
||||||
// Description : Write a string representation of this instance to
|
// Description : Write a string representation of this instance to
|
||||||
// <out>.
|
// <out>.
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
void DCClass::
|
void DCClass::
|
||||||
output(ostream &out) const {
|
output(ostream &out) const {
|
||||||
#ifndef NDEBUG //[
|
if (_is_struct) {
|
||||||
out<<""<<"DCClass";
|
out << "struct";
|
||||||
#endif //] NDEBUG
|
} else {
|
||||||
}
|
out << "dclass";
|
||||||
|
}
|
||||||
////////////////////////////////////////////////////////////////////
|
if (!_name.empty()) {
|
||||||
// Function : write
|
out << " " << _name;
|
||||||
// Access : Published
|
}
|
||||||
// Description : Write a string representation of this instance to
|
|
||||||
// <out>.
|
|
||||||
////////////////////////////////////////////////////////////////////
|
|
||||||
void DCClass::
|
|
||||||
write(ostream &out, unsigned int indent) const {
|
|
||||||
#ifndef NDEBUG //[
|
|
||||||
out.width(indent); out<<""<<"DCClass:\n";
|
|
||||||
|
|
||||||
out.width(indent+2); out<<""<<"_name "<<_name<<"\n";
|
|
||||||
out.width(indent+2); out<<""<<"_is_struct "<<_is_struct<<"\n";
|
|
||||||
out.width(indent+2); out<<""<<"_bogus_class "<<_bogus_class<<"\n";
|
|
||||||
out.width(indent+2); out<<""<<"_number "<<_number<<"\n";
|
|
||||||
|
|
||||||
//typedef pvector<DCClass *> Parents;
|
|
||||||
//Parents _parents;
|
|
||||||
//typedef pvector<DCField *> Fields;
|
|
||||||
//Fields _fields;
|
|
||||||
//typedef pmap<string, DCField *> FieldsByName;
|
|
||||||
//FieldsByName _fields_by_name;
|
|
||||||
#endif //] NDEBUG
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef HAVE_PYTHON
|
#ifdef HAVE_PYTHON
|
||||||
@ -820,6 +801,17 @@ ai_format_generate(PyObject *distobj, int do_id,
|
|||||||
}
|
}
|
||||||
#endif // HAVE_PYTHON
|
#endif // HAVE_PYTHON
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function : DCClass::output
|
||||||
|
// Access : Public, Virtual
|
||||||
|
// Description : Write a string representation of this instance to
|
||||||
|
// <out>.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void DCClass::
|
||||||
|
output(ostream &out, bool brief) const {
|
||||||
|
output_instance(out, brief, "", "", "");
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: DCClass::write
|
// Function: DCClass::write
|
||||||
// Access: Public, Virtual
|
// Access: Public, Virtual
|
||||||
|
@ -68,7 +68,6 @@ PUBLISHED:
|
|||||||
INLINE void stop_generate();
|
INLINE void stop_generate();
|
||||||
|
|
||||||
virtual void output(ostream &out) const;
|
virtual void output(ostream &out) const;
|
||||||
virtual void write(ostream &out, unsigned int indent=0) const;
|
|
||||||
|
|
||||||
#ifdef HAVE_PYTHON
|
#ifdef HAVE_PYTHON
|
||||||
bool has_class_def() const;
|
bool has_class_def() const;
|
||||||
@ -101,6 +100,7 @@ PUBLISHED:
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
virtual void output(ostream &out, bool brief) const;
|
||||||
virtual void write(ostream &out, bool brief, int indent_level) const;
|
virtual void write(ostream &out, bool brief, int indent_level) const;
|
||||||
void output_instance(ostream &out, bool brief, const string &prename,
|
void output_instance(ostream &out, bool brief, const string &prename,
|
||||||
const string &name, const string &postname) const;
|
const string &name, const string &postname) const;
|
||||||
|
@ -67,3 +67,25 @@ const DCSwitch *DCDeclaration::
|
|||||||
as_switch() const {
|
as_switch() const {
|
||||||
return (DCSwitch *)NULL;
|
return (DCSwitch *)NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function : DCDeclaration::output
|
||||||
|
// Access : Published, Virtual
|
||||||
|
// Description : Write a string representation of this instance to
|
||||||
|
// <out>.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void DCDeclaration::
|
||||||
|
output(ostream &out) const {
|
||||||
|
output(out, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function : DCDeclaration::
|
||||||
|
// Access : Published
|
||||||
|
// Description : Write a string representation of this instance to
|
||||||
|
// <out>.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void DCDeclaration::
|
||||||
|
write(ostream &out, int indent_level) const {
|
||||||
|
write(out, false, indent_level);
|
||||||
|
}
|
||||||
|
@ -44,9 +44,18 @@ PUBLISHED:
|
|||||||
virtual DCSwitch *as_switch();
|
virtual DCSwitch *as_switch();
|
||||||
virtual const DCSwitch *as_switch() const;
|
virtual const DCSwitch *as_switch() const;
|
||||||
|
|
||||||
|
virtual void output(ostream &out) const;
|
||||||
|
void write(ostream &out, int indent_level) const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
virtual void output(ostream &out, bool brief) const=0;
|
||||||
virtual void write(ostream &out, bool brief, int indent_level) const=0;
|
virtual void write(ostream &out, bool brief, int indent_level) const=0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
INLINE ostream &operator << (ostream &out, const DCDeclaration &decl) {
|
||||||
|
decl.output(out);
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -391,6 +391,28 @@ compare_flags(const DCField &other) const {
|
|||||||
return _flags == other._flags;
|
return _flags == other._flags;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function : DCField::output
|
||||||
|
// Access : Published
|
||||||
|
// Description : Write a string representation of this instance to
|
||||||
|
// <out>.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void DCField::
|
||||||
|
output(ostream &out) const {
|
||||||
|
output(out, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function : DCField::
|
||||||
|
// Access : Published
|
||||||
|
// Description : Write a string representation of this instance to
|
||||||
|
// <out>.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void DCField::
|
||||||
|
write(ostream &out, int indent_level) const {
|
||||||
|
write(out, false, indent_level);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef HAVE_PYTHON
|
#ifdef HAVE_PYTHON
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: DCField::pack_args
|
// Function: DCField::pack_args
|
||||||
|
@ -78,6 +78,9 @@ PUBLISHED:
|
|||||||
|
|
||||||
bool compare_flags(const DCField &other) const;
|
bool compare_flags(const DCField &other) const;
|
||||||
|
|
||||||
|
void output(ostream &out) const;
|
||||||
|
void write(ostream &out, int indent_level) const;
|
||||||
|
|
||||||
#ifdef HAVE_PYTHON
|
#ifdef HAVE_PYTHON
|
||||||
bool pack_args(DCPacker &packer, PyObject *sequence) const;
|
bool pack_args(DCPacker &packer, PyObject *sequence) const;
|
||||||
PyObject *unpack_args(DCPacker &packer) const;
|
PyObject *unpack_args(DCPacker &packer) const;
|
||||||
@ -139,4 +142,9 @@ private:
|
|||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
INLINE ostream &operator << (ostream &out, const DCField &field) {
|
||||||
|
field.output(out);
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -253,6 +253,17 @@ apply_switch(const char *value_data, size_t length) const {
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function : DCSwitch::output
|
||||||
|
// Access : Public, Virtual
|
||||||
|
// Description : Write a string representation of this instance to
|
||||||
|
// <out>.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void DCSwitch::
|
||||||
|
output(ostream &out, bool brief) const {
|
||||||
|
output_instance(out, brief, "", "", "");
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: DCSwitch::write
|
// Function: DCSwitch::write
|
||||||
// Access: Public, Virtual
|
// Access: Public, Virtual
|
||||||
@ -265,7 +276,7 @@ write(ostream &out, bool brief, int indent_level) const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: DCClass::output_instance
|
// Function: DCSwitch::output_instance
|
||||||
// Access: Public
|
// Access: Public
|
||||||
// Description: Generates a parseable description of the object to
|
// Description: Generates a parseable description of the object to
|
||||||
// the indicated output stream.
|
// the indicated output stream.
|
||||||
|
@ -61,6 +61,7 @@ public:
|
|||||||
|
|
||||||
const DCPackerInterface *apply_switch(const char *value_data, size_t length) const;
|
const DCPackerInterface *apply_switch(const char *value_data, size_t length) const;
|
||||||
|
|
||||||
|
virtual void output(ostream &out, bool brief) const;
|
||||||
virtual void write(ostream &out, bool brief, int indent_level) const;
|
virtual void write(ostream &out, bool brief, int indent_level) const;
|
||||||
void output_instance(ostream &out, bool brief, const string &prename,
|
void output_instance(ostream &out, bool brief, const string &prename,
|
||||||
const string &name, const string &postname) const;
|
const string &name, const string &postname) const;
|
||||||
|
@ -149,6 +149,18 @@ set_number(int number) {
|
|||||||
_number = number;
|
_number = number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
// Function : DCTypedef::output
|
||||||
|
// Access : Public, Virtual
|
||||||
|
// Description : Write a string representation of this instance to
|
||||||
|
// <out>.
|
||||||
|
////////////////////////////////////////////////////////////////////
|
||||||
|
void DCTypedef::
|
||||||
|
output(ostream &out, bool brief) const {
|
||||||
|
out << "typedef ";
|
||||||
|
_parameter->output(out, false);
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////
|
||||||
// Function: DCTypedef::write
|
// Function: DCTypedef::write
|
||||||
// Access: Public, Virtual
|
// Access: Public, Virtual
|
||||||
|
@ -48,6 +48,7 @@ public:
|
|||||||
DCParameter *make_new_parameter() const;
|
DCParameter *make_new_parameter() const;
|
||||||
|
|
||||||
void set_number(int number);
|
void set_number(int number);
|
||||||
|
virtual void output(ostream &out, bool brief) const;
|
||||||
virtual void write(ostream &out, bool brief, int indent_level) const;
|
virtual void write(ostream &out, bool brief, int indent_level) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user