reverse order of nested array brackets to match C convention

This commit is contained in:
David Rose 2005-01-26 12:08:44 +00:00
parent a39a8f57c3
commit 33517c9c8d
5 changed files with 37 additions and 4 deletions

View File

@ -154,6 +154,22 @@ get_array_size() const {
return _array_size;
}
////////////////////////////////////////////////////////////////////
// Function: DCArrayParameter::append_array_specification
// Access: Public, Virtual
// Description: Returns the type represented by this_type[size].
//
// In the case of a DCArrayParameter, this means it
// modifies the current type to append the array
// specification on the innermost type, and returns this
// same pointer again.
////////////////////////////////////////////////////////////////////
DCParameter *DCArrayParameter::
append_array_specification(const DCUnsignedIntRange &size) {
_element_type = _element_type->append_array_specification(size);
return this;
}
////////////////////////////////////////////////////////////////////
// Function: DCArrayParameter::calc_num_nested_fields
// Access: Public, Virtual
@ -223,7 +239,7 @@ output_instance(ostream &out, bool brief, const string &prename,
strm << "]";
_element_type->output_instance(out, brief, prename, name,
strm.str() + postname);
postname + strm.str());
}
}

View File

@ -47,6 +47,8 @@ PUBLISHED:
int get_array_size() const;
public:
virtual DCParameter *append_array_specification(const DCUnsignedIntRange &size);
virtual int calc_num_nested_fields(size_t length_bytes) const;
virtual DCPackerInterface *get_nested_field(int n) const;
virtual bool validate_num_nested_fields(int num_nested_fields) const;

View File

@ -17,11 +17,11 @@
////////////////////////////////////////////////////////////////////
#include "dcParameter.h"
#include "dcArrayParameter.h"
#include "hashGenerator.h"
#include "dcindent.h"
#include "dcTypedef.h"
////////////////////////////////////////////////////////////////////
// Function: DCParameter::Constructor
// Access: Protected
@ -180,6 +180,19 @@ set_typedef(const DCTypedef *dtypedef) {
_typedef = dtypedef;
}
////////////////////////////////////////////////////////////////////
// Function: DCParameter::append_array_specification
// Access: Public, Virtual
// Description: Returns the type represented by this_type[size].
//
// In the case of a generic DCParameter, this means it
// returns a DCArrayParameter wrapped around this type.
////////////////////////////////////////////////////////////////////
DCParameter *DCParameter::
append_array_specification(const DCUnsignedIntRange &size) {
return new DCArrayParameter(this, size);
}
////////////////////////////////////////////////////////////////////
// Function: DCParameter::output
// Access: Public, Virtual

View File

@ -21,6 +21,7 @@
#include "dcbase.h"
#include "dcField.h"
#include "dcNumericRange.h"
class DCSimpleParameter;
class DCClassParameter;
@ -65,6 +66,7 @@ PUBLISHED:
public:
void set_typedef(const DCTypedef *dtypedef);
virtual DCParameter *append_array_specification(const DCUnsignedIntRange &size);
virtual void output(ostream &out, bool brief) const;
virtual void write(ostream &out, bool brief, int indent_level) const;

View File

@ -810,7 +810,7 @@ type_definition:
if ($1 == (DCParameter *)NULL) {
$$ = NULL;
} else {
$$ = new DCArrayParameter($1, uint_range);
$$ = $1->append_array_specification(uint_range);
}
}
;
@ -853,7 +853,7 @@ parameter_definition:
}
| parameter_definition '[' uint_range ']'
{
$$ = new DCArrayParameter($1, uint_range);
$$ = $1->append_array_specification(uint_range);
}
;