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; 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 // Function: DCArrayParameter::calc_num_nested_fields
// Access: Public, Virtual // Access: Public, Virtual
@ -223,7 +239,7 @@ output_instance(ostream &out, bool brief, const string &prename,
strm << "]"; strm << "]";
_element_type->output_instance(out, brief, prename, name, _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; int get_array_size() const;
public: public:
virtual DCParameter *append_array_specification(const DCUnsignedIntRange &size);
virtual int calc_num_nested_fields(size_t length_bytes) const; virtual int calc_num_nested_fields(size_t length_bytes) const;
virtual DCPackerInterface *get_nested_field(int n) const; virtual DCPackerInterface *get_nested_field(int n) const;
virtual bool validate_num_nested_fields(int num_nested_fields) const; virtual bool validate_num_nested_fields(int num_nested_fields) const;

View File

@ -17,11 +17,11 @@
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
#include "dcParameter.h" #include "dcParameter.h"
#include "dcArrayParameter.h"
#include "hashGenerator.h" #include "hashGenerator.h"
#include "dcindent.h" #include "dcindent.h"
#include "dcTypedef.h" #include "dcTypedef.h"
//////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////
// Function: DCParameter::Constructor // Function: DCParameter::Constructor
// Access: Protected // Access: Protected
@ -180,6 +180,19 @@ set_typedef(const DCTypedef *dtypedef) {
_typedef = 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 // Function: DCParameter::output
// Access: Public, Virtual // Access: Public, Virtual

View File

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

View File

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