diff --git a/direct/src/dcparser/dcArrayParameter.cxx b/direct/src/dcparser/dcArrayParameter.cxx index d9f5aa4f39..08b897a9bf 100644 --- a/direct/src/dcparser/dcArrayParameter.cxx +++ b/direct/src/dcparser/dcArrayParameter.cxx @@ -17,6 +17,8 @@ //////////////////////////////////////////////////////////////////// #include "dcArrayParameter.h" +#include "dcSimpleParameter.h" +#include "dcClassParameter.h" #include "hashGenerator.h" //////////////////////////////////////////////////////////////////// @@ -276,3 +278,52 @@ pack_default_value(DCPackData &pack_data, bool &pack_error) const { return true; } + +//////////////////////////////////////////////////////////////////// +// Function: DCArrayParameter::do_check_match +// Access: Protected, Virtual +// Description: Returns true if the other interface is bitwise the +// same as this one--that is, a uint32 only matches a +// uint32, etc. Names of components, and range limits, +// are not compared. +//////////////////////////////////////////////////////////////////// +bool DCArrayParameter:: +do_check_match(const DCPackerInterface *other) const { + return other->do_check_match_array_parameter(this); +} + +//////////////////////////////////////////////////////////////////// +// Function: DCArrayParameter::do_check_match_simple_parameter +// Access: Protected, Virtual +// Description: Returns true if this field matches the indicated +// simple parameter, false otherwise. +//////////////////////////////////////////////////////////////////// +bool DCArrayParameter:: +do_check_match_simple_parameter(const DCSimpleParameter *other) const { + return ((const DCPackerInterface *)other)->do_check_match_array_parameter(this); +} + +//////////////////////////////////////////////////////////////////// +// Function: DCArrayParameter::do_check_match_class_parameter +// Access: Protected, Virtual +// Description: Returns true if this field matches the indicated +// class parameter, false otherwise. +//////////////////////////////////////////////////////////////////// +bool DCArrayParameter:: +do_check_match_class_parameter(const DCClassParameter *other) const { + return ((const DCPackerInterface *)other)->do_check_match_array_parameter(this); +} + +//////////////////////////////////////////////////////////////////// +// Function: DCArrayParameter::do_check_match_array_parameter +// Access: Protected, Virtual +// Description: Returns true if this field matches the indicated +// array parameter, false otherwise. +//////////////////////////////////////////////////////////////////// +bool DCArrayParameter:: +do_check_match_array_parameter(const DCArrayParameter *other) const { + if (_array_size != other->_array_size) { + return false; + } + return _element_type->check_match(other->_element_type); +} diff --git a/direct/src/dcparser/dcArrayParameter.h b/direct/src/dcparser/dcArrayParameter.h index 3245b56d66..29bc2a5f9e 100644 --- a/direct/src/dcparser/dcArrayParameter.h +++ b/direct/src/dcparser/dcArrayParameter.h @@ -56,6 +56,12 @@ public: virtual void generate_hash(HashGenerator &hashgen) const; virtual bool pack_default_value(DCPackData &pack_data, bool &pack_error) const; +protected: + virtual bool do_check_match(const DCPackerInterface *other) const; + virtual bool do_check_match_simple_parameter(const DCSimpleParameter *other) const; + virtual bool do_check_match_class_parameter(const DCClassParameter *other) const; + virtual bool do_check_match_array_parameter(const DCArrayParameter *other) const; + private: DCParameter *_element_type; int _array_size; diff --git a/direct/src/dcparser/dcAtomicField.cxx b/direct/src/dcparser/dcAtomicField.cxx index a1a806d167..e1ad202f93 100644 --- a/direct/src/dcparser/dcAtomicField.cxx +++ b/direct/src/dcparser/dcAtomicField.cxx @@ -284,6 +284,39 @@ add_element(DCParameter *element) { _default_value_stale = true; } +//////////////////////////////////////////////////////////////////// +// Function: DCAtomicField::do_check_match +// Access: Protected, Virtual +// Description: Returns true if the other interface is bitwise the +// same as this one--that is, a uint32 only matches a +// uint32, etc. Names of components, and range limits, +// are not compared. +//////////////////////////////////////////////////////////////////// +bool DCAtomicField:: +do_check_match(const DCPackerInterface *other) const { + return other->do_check_match_atomic_field(this); +} + +//////////////////////////////////////////////////////////////////// +// Function: DCAtomicField::do_check_match_atomic_field +// Access: Protected, Virtual +// Description: Returns true if this field matches the indicated +// atomic field, false otherwise. +//////////////////////////////////////////////////////////////////// +bool DCAtomicField:: +do_check_match_atomic_field(const DCAtomicField *other) const { + if (_elements.size() != other->_elements.size()) { + return false; + } + for (size_t i = 0; i < _elements.size(); i++) { + if (!_elements[i]->check_match(other->_elements[i])) { + return false; + } + } + + return true; +} + //////////////////////////////////////////////////////////////////// // Function: DCAtomicField::output_element // Access: Private diff --git a/direct/src/dcparser/dcAtomicField.h b/direct/src/dcparser/dcAtomicField.h index 7316c1dff6..53f7c312d5 100644 --- a/direct/src/dcparser/dcAtomicField.h +++ b/direct/src/dcparser/dcAtomicField.h @@ -63,6 +63,10 @@ public: virtual DCPackerInterface *get_nested_field(int n) const; +protected: + virtual bool do_check_match(const DCPackerInterface *other) const; + virtual bool do_check_match_atomic_field(const DCAtomicField *other) const; + private: void output_element(ostream &out, bool brief, DCParameter *element) const; diff --git a/direct/src/dcparser/dcClass.cxx b/direct/src/dcparser/dcClass.cxx index a260f5c0b9..1e2cf7eea5 100644 --- a/direct/src/dcparser/dcClass.cxx +++ b/direct/src/dcparser/dcClass.cxx @@ -876,27 +876,29 @@ generate_hash(HashGenerator &hashgen) const { //////////////////////////////////////////////////////////////////// bool DCClass:: add_field(DCField *field) { - if (!_name.empty() && field->get_name() == _name) { - // This field is a constructor. - if (_constructor != (DCField *)NULL) { - // We already have a constructor. + if (!field->get_name().empty()) { + if (field->get_name() == _name) { + // This field is a constructor. + if (_constructor != (DCField *)NULL) { + // We already have a constructor. + return false; + } + if (field->as_atomic_field() == (DCAtomicField *)NULL) { + // The constructor must be an atomic field. + return false; + } + _constructor = field; + _fields_by_name.insert + (FieldsByName::value_type(field->get_name(), field)); + return true; + } + + bool inserted = _fields_by_name.insert + (FieldsByName::value_type(field->get_name(), field)).second; + + if (!inserted) { return false; } - if (field->as_atomic_field() == (DCAtomicField *)NULL) { - // The constructor must be an atomic field. - return false; - } - _constructor = field; - _fields_by_name.insert - (FieldsByName::value_type(field->get_name(), field)); - return true; - } - - bool inserted = _fields_by_name.insert - (FieldsByName::value_type(field->get_name(), field)).second; - - if (!inserted) { - return false; } if (!is_struct()) { diff --git a/direct/src/dcparser/dcClassParameter.cxx b/direct/src/dcparser/dcClassParameter.cxx index a92da93555..f98c27e247 100644 --- a/direct/src/dcparser/dcClassParameter.cxx +++ b/direct/src/dcparser/dcClassParameter.cxx @@ -18,6 +18,7 @@ #include "dcClassParameter.h" #include "dcClass.h" +#include "dcArrayParameter.h" #include "hashGenerator.h" //////////////////////////////////////////////////////////////////// @@ -176,3 +177,60 @@ generate_hash(HashGenerator &hashgen) const { DCParameter::generate_hash(hashgen); _dclass->generate_hash(hashgen); } + +//////////////////////////////////////////////////////////////////// +// Function: DCClassParameter::do_check_match +// Access: Protected, Virtual +// Description: Returns true if the other interface is bitwise the +// same as this one--that is, a uint32 only matches a +// uint32, etc. Names of components, and range limits, +// are not compared. +//////////////////////////////////////////////////////////////////// +bool DCClassParameter:: +do_check_match(const DCPackerInterface *other) const { + return other->do_check_match_class_parameter(this); +} + +//////////////////////////////////////////////////////////////////// +// Function: DCClassParameter::do_check_match_class_parameter +// Access: Protected, Virtual +// Description: Returns true if this field matches the indicated +// class parameter, false otherwise. +//////////////////////////////////////////////////////////////////// +bool DCClassParameter:: +do_check_match_class_parameter(const DCClassParameter *other) const { + if (_nested_fields.size() != other->_nested_fields.size()) { + return false; + } + for (size_t i = 0; i < _nested_fields.size(); i++) { + if (!_nested_fields[i]->check_match(other->_nested_fields[i])) { + return false; + } + } + + return true; +} + +//////////////////////////////////////////////////////////////////// +// Function: DCClassParameter::do_check_match_array_parameter +// Access: Protected, Virtual +// Description: Returns true if this field matches the indicated +// array parameter, false otherwise. +//////////////////////////////////////////////////////////////////// +bool DCClassParameter:: +do_check_match_array_parameter(const DCArrayParameter *other) const { + if ((int)_nested_fields.size() != other->get_array_size()) { + // We can only match a fixed-size array whose size happens to + // exactly match our number of fields. + return false; + } + + const DCPackerInterface *element_type = other->get_element_type(); + for (size_t i = 0; i < _nested_fields.size(); i++) { + if (!_nested_fields[i]->check_match(element_type)) { + return false; + } + } + + return true; +} diff --git a/direct/src/dcparser/dcClassParameter.h b/direct/src/dcparser/dcClassParameter.h index c2af04e227..7691891dee 100644 --- a/direct/src/dcparser/dcClassParameter.h +++ b/direct/src/dcparser/dcClassParameter.h @@ -50,6 +50,11 @@ public: const string &name, const string &postname) const; virtual void generate_hash(HashGenerator &hashgen) const; +protected: + virtual bool do_check_match(const DCPackerInterface *other) const; + virtual bool do_check_match_class_parameter(const DCClassParameter *other) const; + virtual bool do_check_match_array_parameter(const DCArrayParameter *other) const; + private: typedef pvector Fields; Fields _nested_fields; diff --git a/direct/src/dcparser/dcLexer.cxx.prebuilt b/direct/src/dcparser/dcLexer.cxx.prebuilt index f886f78477..434f64e961 100644 --- a/direct/src/dcparser/dcLexer.cxx.prebuilt +++ b/direct/src/dcparser/dcLexer.cxx.prebuilt @@ -569,6 +569,13 @@ dc_start_parameter_value() { initial_token = START_PARAMETER_VALUE; } +void +dc_start_parameter_description() { + /* Set the initial state to begin parsing a parameter description, instead + of at the beginning of the dc file. */ + initial_token = START_PARAMETER_DESCRIPTION; +} + int dc_error_count() { return error_count; @@ -627,6 +634,10 @@ input_chars(char *buffer, int &result, int max_size) { if (*inp) { inp->read(buffer, max_size); result = inp->gcount(); + if (result >= 0 && result < max_size) { + // Truncate at the end of the read. + buffer[result] = '\0'; + } if (line_number == 0) { // This is a special case. If we are reading the very first bit @@ -888,7 +899,7 @@ inline void accept() { col_number += yyleng; } -#line 893 "lex.yy.c" +#line 904 "lex.yy.c" /* Macros after this point can all be overridden by user definitions in * section 1. @@ -1039,7 +1050,7 @@ YY_DECL register char *yy_cp = NULL, *yy_bp = NULL; register int yy_act; -#line 395 "dcLexer.lxx" +#line 406 "dcLexer.lxx" @@ -1050,7 +1061,7 @@ YY_DECL } -#line 1055 "lex.yy.c" +#line 1066 "lex.yy.c" if ( yy_init ) { @@ -1135,7 +1146,7 @@ do_action: /* This label is used only to access EOF actions. */ case 1: YY_RULE_SETUP -#line 405 "dcLexer.lxx" +#line 416 "dcLexer.lxx" { // New line. Save a copy of the line so we can print it out for the // benefit of the user in case we get an error. @@ -1152,7 +1163,7 @@ YY_RULE_SETUP YY_BREAK case 2: YY_RULE_SETUP -#line 419 "dcLexer.lxx" +#line 430 "dcLexer.lxx" { // Eat whitespace. accept(); @@ -1160,7 +1171,7 @@ YY_RULE_SETUP YY_BREAK case 3: YY_RULE_SETUP -#line 424 "dcLexer.lxx" +#line 435 "dcLexer.lxx" { // Eat C++-style comments. accept(); @@ -1168,7 +1179,7 @@ YY_RULE_SETUP YY_BREAK case 4: YY_RULE_SETUP -#line 429 "dcLexer.lxx" +#line 440 "dcLexer.lxx" { // Eat C-style comments. accept(); @@ -1177,7 +1188,7 @@ YY_RULE_SETUP YY_BREAK case 5: YY_RULE_SETUP -#line 436 "dcLexer.lxx" +#line 447 "dcLexer.lxx" { accept(); return KW_DCLASS; @@ -1185,7 +1196,7 @@ YY_RULE_SETUP YY_BREAK case 6: YY_RULE_SETUP -#line 441 "dcLexer.lxx" +#line 452 "dcLexer.lxx" { accept(); return KW_STRUCT; @@ -1193,7 +1204,7 @@ YY_RULE_SETUP YY_BREAK case 7: YY_RULE_SETUP -#line 446 "dcLexer.lxx" +#line 457 "dcLexer.lxx" { accept(); return KW_FROM; @@ -1201,7 +1212,7 @@ YY_RULE_SETUP YY_BREAK case 8: YY_RULE_SETUP -#line 451 "dcLexer.lxx" +#line 462 "dcLexer.lxx" { accept(); return KW_IMPORT; @@ -1209,7 +1220,7 @@ YY_RULE_SETUP YY_BREAK case 9: YY_RULE_SETUP -#line 456 "dcLexer.lxx" +#line 467 "dcLexer.lxx" { accept(); return KW_TYPEDEF; @@ -1217,7 +1228,7 @@ YY_RULE_SETUP YY_BREAK case 10: YY_RULE_SETUP -#line 461 "dcLexer.lxx" +#line 472 "dcLexer.lxx" { accept(); return KW_SWITCH; @@ -1225,7 +1236,7 @@ YY_RULE_SETUP YY_BREAK case 11: YY_RULE_SETUP -#line 466 "dcLexer.lxx" +#line 477 "dcLexer.lxx" { accept(); return KW_CASE; @@ -1233,7 +1244,7 @@ YY_RULE_SETUP YY_BREAK case 12: YY_RULE_SETUP -#line 471 "dcLexer.lxx" +#line 482 "dcLexer.lxx" { accept(); return KW_INT8; @@ -1241,7 +1252,7 @@ YY_RULE_SETUP YY_BREAK case 13: YY_RULE_SETUP -#line 476 "dcLexer.lxx" +#line 487 "dcLexer.lxx" { accept(); return KW_INT16; @@ -1249,7 +1260,7 @@ YY_RULE_SETUP YY_BREAK case 14: YY_RULE_SETUP -#line 481 "dcLexer.lxx" +#line 492 "dcLexer.lxx" { accept(); return KW_INT32; @@ -1257,7 +1268,7 @@ YY_RULE_SETUP YY_BREAK case 15: YY_RULE_SETUP -#line 486 "dcLexer.lxx" +#line 497 "dcLexer.lxx" { accept(); return KW_INT64; @@ -1265,7 +1276,7 @@ YY_RULE_SETUP YY_BREAK case 16: YY_RULE_SETUP -#line 491 "dcLexer.lxx" +#line 502 "dcLexer.lxx" { accept(); return KW_UINT8; @@ -1273,7 +1284,7 @@ YY_RULE_SETUP YY_BREAK case 17: YY_RULE_SETUP -#line 496 "dcLexer.lxx" +#line 507 "dcLexer.lxx" { accept(); return KW_UINT16; @@ -1281,7 +1292,7 @@ YY_RULE_SETUP YY_BREAK case 18: YY_RULE_SETUP -#line 501 "dcLexer.lxx" +#line 512 "dcLexer.lxx" { accept(); return KW_UINT32; @@ -1289,7 +1300,7 @@ YY_RULE_SETUP YY_BREAK case 19: YY_RULE_SETUP -#line 506 "dcLexer.lxx" +#line 517 "dcLexer.lxx" { accept(); return KW_UINT64; @@ -1297,7 +1308,7 @@ YY_RULE_SETUP YY_BREAK case 20: YY_RULE_SETUP -#line 511 "dcLexer.lxx" +#line 522 "dcLexer.lxx" { accept(); return KW_FLOAT64; @@ -1305,7 +1316,7 @@ YY_RULE_SETUP YY_BREAK case 21: YY_RULE_SETUP -#line 516 "dcLexer.lxx" +#line 527 "dcLexer.lxx" { accept(); return KW_STRING; @@ -1313,7 +1324,7 @@ YY_RULE_SETUP YY_BREAK case 22: YY_RULE_SETUP -#line 521 "dcLexer.lxx" +#line 532 "dcLexer.lxx" { accept(); return KW_BLOB; @@ -1321,7 +1332,7 @@ YY_RULE_SETUP YY_BREAK case 23: YY_RULE_SETUP -#line 526 "dcLexer.lxx" +#line 537 "dcLexer.lxx" { accept(); return KW_BLOB32; @@ -1329,7 +1340,7 @@ YY_RULE_SETUP YY_BREAK case 24: YY_RULE_SETUP -#line 531 "dcLexer.lxx" +#line 542 "dcLexer.lxx" { accept(); return KW_INT8ARRAY; @@ -1337,7 +1348,7 @@ YY_RULE_SETUP YY_BREAK case 25: YY_RULE_SETUP -#line 536 "dcLexer.lxx" +#line 547 "dcLexer.lxx" { accept(); return KW_INT16ARRAY; @@ -1345,7 +1356,7 @@ YY_RULE_SETUP YY_BREAK case 26: YY_RULE_SETUP -#line 541 "dcLexer.lxx" +#line 552 "dcLexer.lxx" { accept(); return KW_INT32ARRAY; @@ -1353,7 +1364,7 @@ YY_RULE_SETUP YY_BREAK case 27: YY_RULE_SETUP -#line 546 "dcLexer.lxx" +#line 557 "dcLexer.lxx" { accept(); return KW_UINT8ARRAY; @@ -1361,7 +1372,7 @@ YY_RULE_SETUP YY_BREAK case 28: YY_RULE_SETUP -#line 551 "dcLexer.lxx" +#line 562 "dcLexer.lxx" { accept(); return KW_UINT16ARRAY; @@ -1369,7 +1380,7 @@ YY_RULE_SETUP YY_BREAK case 29: YY_RULE_SETUP -#line 556 "dcLexer.lxx" +#line 567 "dcLexer.lxx" { accept(); return KW_UINT32ARRAY; @@ -1377,7 +1388,7 @@ YY_RULE_SETUP YY_BREAK case 30: YY_RULE_SETUP -#line 561 "dcLexer.lxx" +#line 572 "dcLexer.lxx" { accept(); return KW_UINT32UINT8ARRAY; @@ -1385,7 +1396,7 @@ YY_RULE_SETUP YY_BREAK case 31: YY_RULE_SETUP -#line 566 "dcLexer.lxx" +#line 577 "dcLexer.lxx" { accept(); return KW_CHAR; @@ -1393,7 +1404,7 @@ YY_RULE_SETUP YY_BREAK case 32: YY_RULE_SETUP -#line 571 "dcLexer.lxx" +#line 582 "dcLexer.lxx" { accept(); return KW_REQUIRED; @@ -1401,7 +1412,7 @@ YY_RULE_SETUP YY_BREAK case 33: YY_RULE_SETUP -#line 576 "dcLexer.lxx" +#line 587 "dcLexer.lxx" { accept(); return KW_BROADCAST; @@ -1409,7 +1420,7 @@ YY_RULE_SETUP YY_BREAK case 34: YY_RULE_SETUP -#line 581 "dcLexer.lxx" +#line 592 "dcLexer.lxx" { accept(); return KW_P2P; @@ -1417,7 +1428,7 @@ YY_RULE_SETUP YY_BREAK case 35: YY_RULE_SETUP -#line 586 "dcLexer.lxx" +#line 597 "dcLexer.lxx" { accept(); return KW_RAM; @@ -1425,7 +1436,7 @@ YY_RULE_SETUP YY_BREAK case 36: YY_RULE_SETUP -#line 591 "dcLexer.lxx" +#line 602 "dcLexer.lxx" { accept(); return KW_DB; @@ -1433,7 +1444,7 @@ YY_RULE_SETUP YY_BREAK case 37: YY_RULE_SETUP -#line 596 "dcLexer.lxx" +#line 607 "dcLexer.lxx" { accept(); return KW_CLSEND; @@ -1441,7 +1452,7 @@ YY_RULE_SETUP YY_BREAK case 38: YY_RULE_SETUP -#line 601 "dcLexer.lxx" +#line 612 "dcLexer.lxx" { accept(); return KW_CLRECV; @@ -1449,7 +1460,7 @@ YY_RULE_SETUP YY_BREAK case 39: YY_RULE_SETUP -#line 606 "dcLexer.lxx" +#line 617 "dcLexer.lxx" { accept(); return KW_OWNSEND; @@ -1457,7 +1468,7 @@ YY_RULE_SETUP YY_BREAK case 40: YY_RULE_SETUP -#line 611 "dcLexer.lxx" +#line 622 "dcLexer.lxx" { accept(); return KW_AIRECV; @@ -1465,7 +1476,7 @@ YY_RULE_SETUP YY_BREAK case 41: YY_RULE_SETUP -#line 616 "dcLexer.lxx" +#line 627 "dcLexer.lxx" { // An unsigned integer number. accept(); @@ -1491,7 +1502,7 @@ YY_RULE_SETUP YY_BREAK case 42: YY_RULE_SETUP -#line 639 "dcLexer.lxx" +#line 650 "dcLexer.lxx" { // A signed integer number. accept(); @@ -1540,7 +1551,7 @@ YY_RULE_SETUP YY_BREAK case 43: YY_RULE_SETUP -#line 685 "dcLexer.lxx" +#line 696 "dcLexer.lxx" { // A hexadecimal integer number. accept(); @@ -1570,7 +1581,7 @@ YY_RULE_SETUP YY_BREAK case 44: YY_RULE_SETUP -#line 712 "dcLexer.lxx" +#line 723 "dcLexer.lxx" { // A floating-point number. accept(); @@ -1581,7 +1592,7 @@ YY_RULE_SETUP YY_BREAK case 45: YY_RULE_SETUP -#line 720 "dcLexer.lxx" +#line 731 "dcLexer.lxx" { // Quoted string. accept(); @@ -1591,7 +1602,7 @@ YY_RULE_SETUP YY_BREAK case 46: YY_RULE_SETUP -#line 727 "dcLexer.lxx" +#line 738 "dcLexer.lxx" { // Single-quoted string. accept(); @@ -1601,7 +1612,7 @@ YY_RULE_SETUP YY_BREAK case 47: YY_RULE_SETUP -#line 734 "dcLexer.lxx" +#line 745 "dcLexer.lxx" { // Long hex string. accept(); @@ -1611,7 +1622,7 @@ YY_RULE_SETUP YY_BREAK case 48: YY_RULE_SETUP -#line 741 "dcLexer.lxx" +#line 752 "dcLexer.lxx" { // Identifier. accept(); @@ -1621,7 +1632,7 @@ YY_RULE_SETUP YY_BREAK case 49: YY_RULE_SETUP -#line 749 "dcLexer.lxx" +#line 760 "dcLexer.lxx" { // Send any other printable character as itself. accept(); @@ -1630,10 +1641,10 @@ YY_RULE_SETUP YY_BREAK case 50: YY_RULE_SETUP -#line 755 "dcLexer.lxx" +#line 766 "dcLexer.lxx" ECHO; YY_BREAK -#line 1638 "lex.yy.c" +#line 1649 "lex.yy.c" case YY_STATE_EOF(INITIAL): yyterminate(); @@ -2514,4 +2525,4 @@ int main() return 0; } #endif -#line 755 "dcLexer.lxx" +#line 766 "dcLexer.lxx" diff --git a/direct/src/dcparser/dcLexer.lxx b/direct/src/dcparser/dcLexer.lxx index 186e8d9c8e..907f23fd68 100644 --- a/direct/src/dcparser/dcLexer.lxx +++ b/direct/src/dcparser/dcLexer.lxx @@ -66,6 +66,13 @@ dc_start_parameter_value() { initial_token = START_PARAMETER_VALUE; } +void +dc_start_parameter_description() { + /* Set the initial state to begin parsing a parameter description, instead + of at the beginning of the dc file. */ + initial_token = START_PARAMETER_DESCRIPTION; +} + int dc_error_count() { return error_count; @@ -124,6 +131,10 @@ input_chars(char *buffer, int &result, int max_size) { if (*inp) { inp->read(buffer, max_size); result = inp->gcount(); + if (result >= 0 && result < max_size) { + // Truncate at the end of the read. + buffer[result] = '\0'; + } if (line_number == 0) { // This is a special case. If we are reading the very first bit diff --git a/direct/src/dcparser/dcLexerDefs.h b/direct/src/dcparser/dcLexerDefs.h index 0ee8c98735..5155907f91 100644 --- a/direct/src/dcparser/dcLexerDefs.h +++ b/direct/src/dcparser/dcLexerDefs.h @@ -23,6 +23,7 @@ void dc_init_lexer(istream &in, const string &filename); void dc_start_parameter_value(); +void dc_start_parameter_description(); int dc_error_count(); int dc_warning_count(); diff --git a/direct/src/dcparser/dcMolecularField.cxx b/direct/src/dcparser/dcMolecularField.cxx index cecb47bcec..48962e106b 100644 --- a/direct/src/dcparser/dcMolecularField.cxx +++ b/direct/src/dcparser/dcMolecularField.cxx @@ -192,3 +192,36 @@ get_nested_field(int n) const { nassertr(n >= 0 && n < (int)_nested_fields.size(), NULL); return _nested_fields[n]; } + +//////////////////////////////////////////////////////////////////// +// Function: DCMolecularField::do_check_match +// Access: Protected, Virtual +// Description: Returns true if the other interface is bitwise the +// same as this one--that is, a uint32 only matches a +// uint32, etc. Names of components, and range limits, +// are not compared. +//////////////////////////////////////////////////////////////////// +bool DCMolecularField:: +do_check_match(const DCPackerInterface *other) const { + return other->do_check_match_molecular_field(this); +} + +//////////////////////////////////////////////////////////////////// +// Function: DCMolecularField::do_check_match_molecular_field +// Access: Protected, Virtual +// Description: Returns true if this field matches the indicated +// molecular field, false otherwise. +//////////////////////////////////////////////////////////////////// +bool DCMolecularField:: +do_check_match_molecular_field(const DCMolecularField *other) const { + if (_nested_fields.size() != other->_nested_fields.size()) { + return false; + } + for (size_t i = 0; i < _nested_fields.size(); i++) { + if (!_nested_fields[i]->check_match(other->_nested_fields[i])) { + return false; + } + } + + return true; +} diff --git a/direct/src/dcparser/dcMolecularField.h b/direct/src/dcparser/dcMolecularField.h index 7612cc0141..b7d882f3f9 100644 --- a/direct/src/dcparser/dcMolecularField.h +++ b/direct/src/dcparser/dcMolecularField.h @@ -52,6 +52,10 @@ public: virtual DCPackerInterface *get_nested_field(int n) const; +protected: + virtual bool do_check_match(const DCPackerInterface *other) const; + virtual bool do_check_match_molecular_field(const DCMolecularField *other) const; + private: // These members define the primary interface to the molecular field // definition as read from the file. diff --git a/direct/src/dcparser/dcPackerCatalog.cxx b/direct/src/dcparser/dcPackerCatalog.cxx index 9f11aec7ce..7f6f867b62 100644 --- a/direct/src/dcparser/dcPackerCatalog.cxx +++ b/direct/src/dcparser/dcPackerCatalog.cxx @@ -190,8 +190,23 @@ add_entry(const string &name, const DCPackerInterface *field, int entry_index = (int)_entries.size(); _entries.push_back(entry); - _entries_by_name.insert(EntriesByName::value_type(name, entry_index)); _entries_by_field.insert(EntriesByField::value_type(field, entry_index)); + + // Add an entry for the fully-qualified field name + // (e.g. dna.topTex). If there was another entry for this name + // previously, completely replace it--the fully-qualified name is + // supposed to be unique and trumps the local field names (which are + // not necessarily unique). + _entries_by_name[name] = entry_index; + + // We'll also add an entry for the local field name, for the user's + // convenience. This won't override a fully-qualified name that + // might already have been recorded, and a fully-qualified name + // discovered later that conflicts with this name will replace it. + string local_name = field->get_name(); + if (local_name != name) { + _entries_by_name.insert(EntriesByName::value_type(local_name, entry_index)); + } } //////////////////////////////////////////////////////////////////// diff --git a/direct/src/dcparser/dcPackerInterface.I b/direct/src/dcparser/dcPackerInterface.I index 5624fa7a84..25ec49c64b 100644 --- a/direct/src/dcparser/dcPackerInterface.I +++ b/direct/src/dcparser/dcPackerInterface.I @@ -28,6 +28,19 @@ get_name() const { return _name; } +//////////////////////////////////////////////////////////////////// +// Function: DCPackerInterface::check_match +// Access: Published +// Description: Returns true if the other interface is bitwise the +// same as this one--that is, a uint32 only matches a +// uint32, etc. Names of components, and range limits, +// are not compared. +//////////////////////////////////////////////////////////////////// +INLINE bool DCPackerInterface:: +check_match(const DCPackerInterface *other) const { + return do_check_match(other); +} + //////////////////////////////////////////////////////////////////// // Function: DCPackerInterface::set_name // Access: Public diff --git a/direct/src/dcparser/dcPackerInterface.cxx b/direct/src/dcparser/dcPackerInterface.cxx index 7ed33a0d77..bb3ab2996b 100755 --- a/direct/src/dcparser/dcPackerInterface.cxx +++ b/direct/src/dcparser/dcPackerInterface.cxx @@ -18,6 +18,8 @@ #include "dcPackerInterface.h" #include "dcPackerCatalog.h" +#include "dcParserDefs.h" +#include "dcLexerDefs.h" //////////////////////////////////////////////////////////////////// // Function: DCPackerInterface::Constructor @@ -151,6 +153,42 @@ as_class_parameter() const { return (DCClassParameter *)NULL; } +//////////////////////////////////////////////////////////////////// +// Function: DCPackerInterface::check_match +// Access: Published +// Description: Returns true if this interface is bitwise the same as +// the interface described with the indicated formatted +// string, e.g. "(uint8, uint8, int16)", or false +// otherwise. +// +// If DCFile is not NULL, it specifies the DCFile that +// was previously loaded, from which some predefined +// structs and typedefs may be referenced in the +// description string. +//////////////////////////////////////////////////////////////////// +bool DCPackerInterface:: +check_match(const string &description, DCFile *dcfile) const { + bool match = false; + + istringstream strm(description); + dc_init_parser_parameter_description(strm, "check_match", dcfile); + dcyyparse(); + dc_cleanup_parser(); + + DCField *field = dc_get_parameter_description(); + if (field != NULL) { + match = check_match(field); + delete field; + } + + if (dc_error_count() == 0) { + return match; + } + + // Parse error: no match is allowed. + return false; +} + //////////////////////////////////////////////////////////////////// // Function: DCPackerInterface::calc_num_nested_fields // Access: Public, Virtual @@ -417,6 +455,72 @@ get_catalog() const { return _catalog; } +//////////////////////////////////////////////////////////////////// +// Function: DCPackerInterface::do_check_match_simple_parameter +// Access: Protected, Virtual +// Description: Returns true if this field matches the indicated +// simple parameter, false otherwise. +//////////////////////////////////////////////////////////////////// +bool DCPackerInterface:: +do_check_match_simple_parameter(const DCSimpleParameter *) const { + return false; +} + +//////////////////////////////////////////////////////////////////// +// Function: DCPackerInterface::do_check_match_class_parameter +// Access: Protected, Virtual +// Description: Returns true if this field matches the indicated +// class parameter, false otherwise. +//////////////////////////////////////////////////////////////////// +bool DCPackerInterface:: +do_check_match_class_parameter(const DCClassParameter *) const { + return false; +} + +//////////////////////////////////////////////////////////////////// +// Function: DCPackerInterface::do_check_match_switch_parameter +// Access: Protected, Virtual +// Description: Returns true if this field matches the indicated +// switch parameter, false otherwise. +//////////////////////////////////////////////////////////////////// +bool DCPackerInterface:: +do_check_match_switch_parameter(const DCSwitchParameter *) const { + return false; +} + +//////////////////////////////////////////////////////////////////// +// Function: DCPackerInterface::do_check_match_array_parameter +// Access: Protected, Virtual +// Description: Returns true if this field matches the indicated +// array parameter, false otherwise. +//////////////////////////////////////////////////////////////////// +bool DCPackerInterface:: +do_check_match_array_parameter(const DCArrayParameter *) const { + return false; +} + +//////////////////////////////////////////////////////////////////// +// Function: DCPackerInterface::do_check_match_atomic_field +// Access: Protected, Virtual +// Description: Returns true if this field matches the indicated +// atomic field, false otherwise. +//////////////////////////////////////////////////////////////////// +bool DCPackerInterface:: +do_check_match_atomic_field(const DCAtomicField *) const { + return false; +} + +//////////////////////////////////////////////////////////////////// +// Function: DCPackerInterface::do_check_match_molecular_field +// Access: Protected, Virtual +// Description: Returns true if this field matches the indicated +// molecular field, false otherwise. +//////////////////////////////////////////////////////////////////// +bool DCPackerInterface:: +do_check_match_molecular_field(const DCMolecularField *) const { + return false; +} + //////////////////////////////////////////////////////////////////// // Function: DCPackerInterface::make_catalog // Access: Private diff --git a/direct/src/dcparser/dcPackerInterface.h b/direct/src/dcparser/dcPackerInterface.h index c424991678..939bdfeda0 100755 --- a/direct/src/dcparser/dcPackerInterface.h +++ b/direct/src/dcparser/dcPackerInterface.h @@ -22,9 +22,14 @@ #include "dcbase.h" #include "dcSubatomicType.h" +class DCFile; class DCField; +class DCSimpleParameter; class DCSwitchParameter; class DCClassParameter; +class DCArrayParameter; +class DCAtomicField; +class DCMolecularField; class DCPackData; class DCPackerCatalog; @@ -84,6 +89,9 @@ PUBLISHED: virtual DCClassParameter *as_class_parameter(); virtual const DCClassParameter *as_class_parameter() const; + INLINE bool check_match(const DCPackerInterface *other) const; + bool check_match(const string &description, DCFile *dcfile = NULL) const; + public: INLINE void set_name(const string &name); INLINE bool has_fixed_byte_size() const; @@ -166,6 +174,20 @@ public: const DCPackerCatalog *get_catalog() const; +protected: + virtual bool do_check_match(const DCPackerInterface *other) const=0; + +public: + // These are declared public just so the derived classes can call + // them easily. They're not intended to be called directly. + + virtual bool do_check_match_simple_parameter(const DCSimpleParameter *other) const; + virtual bool do_check_match_class_parameter(const DCClassParameter *other) const; + virtual bool do_check_match_switch_parameter(const DCSwitchParameter *other) const; + virtual bool do_check_match_array_parameter(const DCArrayParameter *other) const; + virtual bool do_check_match_atomic_field(const DCAtomicField *other) const; + virtual bool do_check_match_molecular_field(const DCMolecularField *other) const; + private: void make_catalog(); diff --git a/direct/src/dcparser/dcParser.cxx.prebuilt b/direct/src/dcparser/dcParser.cxx.prebuilt index e89fb0f75a..c6f15b79ed 100644 --- a/direct/src/dcparser/dcParser.cxx.prebuilt +++ b/direct/src/dcparser/dcParser.cxx.prebuilt @@ -54,6 +54,7 @@ # define KW_AIRECV 298 # define START_DC 299 # define START_PARAMETER_VALUE 300 +# define START_PARAMETER_DESCRIPTION 301 #line 6 "dcParser.yxx" @@ -90,6 +91,7 @@ static DCPacker default_packer; static DCPacker *current_packer; static DCDoubleRange double_range; static DCUnsignedIntRange uint_range; +static DCField *parameter_description = (DCField *)NULL; //////////////////////////////////////////////////////////////////// // Defining the interface to the parser. @@ -110,6 +112,20 @@ dc_init_parser_parameter_value(istream &in, const string &filename, dc_start_parameter_value(); } +void +dc_init_parser_parameter_description(istream &in, const string &filename, + DCFile *file) { + dc_file = file; + dc_init_lexer(in, filename); + parameter_description = NULL; + dc_start_parameter_description(); +} + +DCField * +dc_get_parameter_description() { + return parameter_description; +} + void dc_cleanup_parser() { dc_file = (DCFile *)NULL; @@ -121,12 +137,12 @@ dc_cleanup_parser() { -#define YYFINAL 258 +#define YYFINAL 268 #define YYFLAG -32768 -#define YYNTBASE 61 +#define YYNTBASE 62 /* YYTRANSLATE(YYLEX) -- Bison token number corresponding to YYLEX. */ -#define YYTRANSLATE(x) ((unsigned)(x) <= 300 ? yytranslate[x] : 132) +#define YYTRANSLATE(x) ((unsigned)(x) <= 301 ? yytranslate[x] : 134) /* YYTRANSLATE[YYLEX] -- Bison token number corresponding to YYLEX. */ static const char yytranslate[] = @@ -135,15 +151,15 @@ static const char yytranslate[] = 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 55, 56, 50, 2, 51, 58, 49, 48, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 54, 47, - 2, 57, 2, 2, 2, 2, 2, 2, 2, 2, + 56, 57, 51, 2, 52, 59, 50, 49, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 55, 48, + 2, 58, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 59, 2, 60, 2, 2, 2, 2, 2, 2, + 2, 60, 2, 61, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, - 2, 2, 2, 52, 2, 53, 2, 2, 2, 2, + 2, 2, 2, 53, 2, 54, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -161,83 +177,84 @@ static const char yytranslate[] = 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, - 46 + 46, 47 }; #if YYDEBUG static const short yyprhs[] = { - 0, 0, 3, 6, 8, 11, 14, 17, 20, 23, - 25, 29, 31, 35, 38, 39, 45, 47, 49, 51, - 55, 58, 60, 62, 63, 71, 73, 75, 78, 80, - 84, 86, 89, 92, 95, 98, 102, 105, 106, 114, - 116, 118, 121, 123, 127, 129, 132, 135, 138, 141, - 145, 148, 149, 155, 157, 159, 161, 165, 167, 168, - 172, 174, 176, 177, 182, 184, 185, 190, 192, 194, - 196, 198, 200, 205, 209, 216, 223, 225, 227, 229, - 231, 233, 237, 240, 244, 250, 255, 257, 259, 263, - 267, 273, 275, 280, 282, 286, 291, 293, 295, 297, - 299, 301, 303, 305, 307, 309, 311, 313, 315, 317, - 319, 321, 322, 327, 328, 333, 334, 339, 343, 347, - 351, 355, 357, 360, 362, 364, 366, 370, 372, 374, - 376, 378, 380, 382, 384, 386, 388, 390, 392, 394, - 396, 398, 400, 402, 404, 406, 408, 410, 412, 415, - 418, 421, 424, 427, 430, 433, 436, 439, 441, 442, - 447, 449, 451, 455, 457, 459, 460, 470, 472, 475, - 478, 481, 482, 487, 490, 492 + 0, 0, 3, 6, 9, 11, 14, 17, 20, 23, + 26, 28, 32, 34, 38, 41, 42, 48, 50, 52, + 54, 58, 61, 63, 65, 66, 74, 76, 78, 81, + 83, 87, 89, 92, 95, 98, 101, 105, 108, 109, + 117, 119, 121, 124, 126, 130, 132, 135, 138, 141, + 144, 148, 151, 152, 158, 160, 162, 164, 168, 170, + 171, 175, 177, 179, 180, 185, 187, 188, 193, 195, + 197, 199, 201, 204, 207, 210, 212, 217, 221, 228, + 235, 237, 239, 241, 243, 245, 249, 252, 256, 262, + 267, 269, 271, 275, 279, 285, 287, 292, 294, 298, + 303, 305, 307, 309, 311, 313, 315, 317, 319, 321, + 323, 325, 327, 329, 331, 333, 334, 339, 340, 345, + 346, 351, 355, 359, 363, 367, 369, 372, 374, 376, + 378, 382, 384, 386, 388, 390, 392, 394, 396, 398, + 400, 402, 404, 406, 408, 410, 412, 414, 416, 418, + 420, 422, 424, 427, 430, 433, 436, 439, 442, 445, + 448, 451, 453, 454, 459, 461, 463, 467, 469, 471, + 472, 482, 484, 487, 490, 493, 494, 499, 502, 504 }; static const short yyrhs[] = { - 45, 62, 0, 46, 110, 0, 131, 0, 62, 47, - 0, 62, 70, 0, 62, 125, 0, 62, 65, 0, - 62, 69, 0, 8, 0, 63, 48, 8, 0, 63, - 0, 64, 49, 63, 0, 12, 64, 0, 0, 11, - 64, 12, 66, 67, 0, 68, 0, 50, 0, 63, - 0, 68, 51, 63, 0, 13, 98, 0, 71, 0, - 78, 0, 0, 9, 124, 72, 74, 52, 76, 53, - 0, 8, 0, 131, 0, 54, 75, 0, 73, 0, - 75, 51, 73, 0, 131, 0, 76, 47, 0, 76, - 77, 0, 85, 118, 0, 120, 119, 0, 95, 118, - 47, 0, 93, 118, 0, 0, 10, 124, 79, 81, - 52, 83, 53, 0, 8, 0, 131, 0, 54, 82, - 0, 80, 0, 82, 51, 80, 0, 131, 0, 83, - 47, 0, 83, 84, 0, 85, 119, 0, 120, 119, - 0, 95, 119, 47, 0, 93, 119, 0, 0, 8, - 55, 86, 87, 56, 0, 131, 0, 88, 0, 89, - 0, 88, 51, 89, 0, 98, 0, 0, 102, 91, - 103, 0, 102, 0, 90, 0, 0, 90, 57, 94, - 110, 0, 92, 0, 0, 92, 57, 96, 110, 0, - 90, 0, 92, 0, 93, 0, 95, 0, 117, 0, - 117, 55, 100, 56, 0, 117, 48, 105, 0, 117, - 48, 105, 55, 100, 56, 0, 117, 55, 100, 56, - 48, 105, 0, 8, 0, 78, 0, 125, 0, 131, - 0, 109, 0, 109, 58, 109, 0, 109, 108, 0, - 100, 51, 109, 0, 100, 51, 109, 58, 109, 0, - 100, 51, 109, 108, 0, 131, 0, 104, 0, 104, - 58, 104, 0, 101, 51, 104, 0, 101, 51, 104, - 58, 104, 0, 99, 0, 102, 59, 101, 60, 0, - 8, 0, 103, 48, 105, 0, 103, 59, 101, 60, - 0, 6, 0, 105, 0, 3, 0, 4, 0, 3, - 0, 107, 0, 106, 0, 5, 0, 6, 0, 108, - 0, 106, 0, 107, 0, 5, 0, 6, 0, 7, - 0, 0, 52, 111, 114, 53, 0, 0, 59, 112, - 114, 60, 0, 0, 55, 113, 114, 56, 0, 106, - 50, 105, 0, 107, 50, 105, 0, 5, 50, 105, - 0, 7, 50, 105, 0, 115, 0, 116, 115, 0, - 131, 0, 51, 0, 110, 0, 116, 51, 110, 0, - 16, 0, 17, 0, 18, 0, 19, 0, 20, 0, - 21, 0, 22, 0, 23, 0, 24, 0, 25, 0, - 26, 0, 27, 0, 28, 0, 29, 0, 30, 0, - 31, 0, 32, 0, 33, 0, 34, 0, 35, 0, - 131, 0, 118, 36, 0, 118, 37, 0, 118, 38, - 0, 118, 39, 0, 118, 40, 0, 118, 41, 0, - 118, 42, 0, 118, 43, 0, 118, 44, 0, 118, - 0, 0, 8, 54, 121, 123, 0, 8, 0, 122, - 0, 123, 51, 122, 0, 131, 0, 8, 0, 0, - 14, 124, 55, 97, 56, 52, 126, 127, 53, 0, - 131, 0, 127, 47, 0, 127, 128, 0, 127, 130, - 0, 0, 15, 129, 110, 54, 0, 95, 47, 0, - 93, 0, 0 + 45, 63, 0, 46, 112, 0, 47, 100, 0, 133, + 0, 63, 48, 0, 63, 71, 0, 63, 127, 0, + 63, 66, 0, 63, 70, 0, 8, 0, 64, 49, + 8, 0, 64, 0, 65, 50, 64, 0, 12, 65, + 0, 0, 11, 65, 12, 67, 68, 0, 69, 0, + 51, 0, 64, 0, 69, 52, 64, 0, 13, 99, + 0, 72, 0, 79, 0, 0, 9, 126, 73, 75, + 53, 77, 54, 0, 8, 0, 133, 0, 55, 76, + 0, 74, 0, 76, 52, 74, 0, 133, 0, 77, + 48, 0, 77, 78, 0, 86, 120, 0, 122, 121, + 0, 96, 120, 48, 0, 94, 120, 0, 0, 10, + 126, 80, 82, 53, 84, 54, 0, 8, 0, 133, + 0, 55, 83, 0, 81, 0, 83, 52, 81, 0, + 133, 0, 84, 48, 0, 84, 85, 0, 86, 121, + 0, 122, 121, 0, 96, 121, 48, 0, 94, 121, + 0, 0, 126, 56, 87, 88, 57, 0, 133, 0, + 89, 0, 90, 0, 89, 52, 90, 0, 99, 0, + 0, 104, 92, 105, 0, 104, 0, 91, 0, 0, + 91, 58, 95, 112, 0, 93, 0, 0, 93, 58, + 97, 112, 0, 91, 0, 93, 0, 94, 0, 96, + 0, 86, 121, 0, 96, 121, 0, 94, 121, 0, + 119, 0, 119, 56, 102, 57, 0, 119, 49, 107, + 0, 119, 49, 107, 56, 102, 57, 0, 119, 56, + 102, 57, 49, 107, 0, 8, 0, 79, 0, 127, + 0, 133, 0, 111, 0, 111, 59, 111, 0, 111, + 110, 0, 102, 52, 111, 0, 102, 52, 111, 59, + 111, 0, 102, 52, 111, 110, 0, 133, 0, 106, + 0, 106, 59, 106, 0, 103, 52, 106, 0, 103, + 52, 106, 59, 106, 0, 101, 0, 104, 60, 103, + 61, 0, 8, 0, 105, 49, 107, 0, 105, 60, + 103, 61, 0, 6, 0, 107, 0, 3, 0, 4, + 0, 3, 0, 109, 0, 108, 0, 5, 0, 6, + 0, 110, 0, 108, 0, 109, 0, 5, 0, 6, + 0, 7, 0, 0, 53, 113, 116, 54, 0, 0, + 60, 114, 116, 61, 0, 0, 56, 115, 116, 57, + 0, 108, 51, 107, 0, 109, 51, 107, 0, 5, + 51, 107, 0, 7, 51, 107, 0, 117, 0, 118, + 117, 0, 133, 0, 52, 0, 112, 0, 118, 52, + 112, 0, 16, 0, 17, 0, 18, 0, 19, 0, + 20, 0, 21, 0, 22, 0, 23, 0, 24, 0, + 25, 0, 26, 0, 27, 0, 28, 0, 29, 0, + 30, 0, 31, 0, 32, 0, 33, 0, 34, 0, + 35, 0, 133, 0, 120, 36, 0, 120, 37, 0, + 120, 38, 0, 120, 39, 0, 120, 40, 0, 120, + 41, 0, 120, 42, 0, 120, 43, 0, 120, 44, + 0, 120, 0, 0, 8, 55, 123, 125, 0, 8, + 0, 124, 0, 125, 52, 124, 0, 133, 0, 8, + 0, 0, 14, 126, 56, 98, 57, 53, 128, 129, + 54, 0, 133, 0, 129, 48, 0, 129, 130, 0, + 129, 132, 0, 0, 15, 131, 112, 55, 0, 96, + 48, 0, 94, 0, 0 }; #endif @@ -246,24 +263,24 @@ static const short yyrhs[] = /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const short yyrline[] = { - 0, 153, 155, 158, 160, 161, 172, 178, 179, 182, - 184, 190, 192, 198, 203, 203, 210, 212, 218, 223, - 229, 245, 247, 250, 250, 263, 280, 282, 285, 292, - 300, 302, 303, 313, 319, 320, 326, 333, 333, 346, - 363, 365, 368, 375, 383, 385, 386, 394, 396, 397, - 401, 407, 407, 420, 422, 425, 427, 430, 437, 437, - 448, 452, 454, 454, 477, 479, 479, 502, 504, 507, - 509, 512, 517, 525, 536, 550, 564, 593, 599, 607, - 612, 619, 626, 635, 641, 647, 657, 662, 669, 676, - 682, 690, 692, 698, 704, 718, 724, 734, 737, 748, - 752, 756, 761, 765, 768, 778, 782, 787, 791, 795, - 799, 803, 803, 811, 811, 819, 819, 827, 833, 839, - 845, 853, 855, 858, 860, 863, 865, 868, 873, 877, - 881, 885, 889, 893, 897, 901, 905, 909, 913, 917, - 921, 925, 929, 933, 937, 941, 945, 951, 956, 960, - 964, 968, 972, 976, 980, 984, 988, 994, 1004, 1004, - 1015, 1031, 1038, 1051, 1056, 1059, 1059, 1073, 1075, 1076, - 1077, 1087, 1087, 1104, 1109, 1115 + 0, 170, 172, 173, 179, 181, 182, 193, 199, 200, + 203, 205, 211, 213, 219, 224, 224, 231, 233, 239, + 244, 250, 268, 270, 273, 273, 286, 309, 311, 314, + 321, 329, 331, 332, 344, 355, 356, 364, 373, 373, + 386, 409, 411, 414, 421, 429, 431, 432, 442, 450, + 451, 455, 461, 461, 474, 476, 479, 481, 484, 493, + 493, 504, 508, 510, 510, 538, 540, 540, 568, 570, + 573, 575, 578, 583, 587, 593, 598, 606, 617, 631, + 645, 680, 692, 706, 711, 718, 725, 734, 740, 746, + 756, 761, 768, 775, 781, 789, 791, 801, 807, 821, + 827, 837, 840, 851, 855, 859, 864, 868, 871, 881, + 885, 890, 894, 898, 902, 906, 906, 914, 914, 922, + 922, 930, 936, 942, 948, 956, 958, 961, 963, 966, + 968, 971, 976, 980, 984, 988, 992, 996, 1000, 1004, + 1008, 1012, 1016, 1020, 1024, 1028, 1032, 1036, 1040, 1044, + 1048, 1054, 1059, 1063, 1067, 1071, 1075, 1079, 1083, 1087, + 1091, 1097, 1107, 1107, 1118, 1134, 1141, 1154, 1159, 1162, + 1162, 1176, 1178, 1179, 1180, 1192, 1192, 1209, 1214, 1220 }; #endif @@ -282,18 +299,19 @@ static const char *const yytname[] = "KW_UINT8ARRAY", "KW_UINT16ARRAY", "KW_UINT32ARRAY", "KW_UINT32UINT8ARRAY", "KW_CHAR", "KW_REQUIRED", "KW_BROADCAST", "KW_P2P", "KW_RAM", "KW_DB", "KW_CLSEND", "KW_CLRECV", "KW_OWNSEND", - "KW_AIRECV", "START_DC", "START_PARAMETER_VALUE", "';'", "'/'", "'.'", - "'*'", "','", "'{'", "'}'", "':'", "'('", "')'", "'='", "'-'", "'['", - "']'", "grammar", "dc", "slash_identifier", "import_identifier", - "import", "@1", "import_symbol_list_or_star", "import_symbol_list", - "typedef_decl", "dclass_or_struct", "dclass", "@2", "dclass_name", - "dclass_derivation", "dclass_base_list", "dclass_fields", - "dclass_field", "struct", "@3", "struct_name", "struct_derivation", - "struct_base_list", "struct_fields", "struct_field", "atomic_field", - "@4", "parameter_list", "nonempty_parameter_list", "atomic_element", - "named_parameter", "@5", "unnamed_parameter", - "named_parameter_with_default", "@6", "unnamed_parameter_with_default", - "@7", "parameter", "parameter_with_default", "type_name", + "KW_AIRECV", "START_DC", "START_PARAMETER_VALUE", + "START_PARAMETER_DESCRIPTION", "';'", "'/'", "'.'", "'*'", "','", "'{'", + "'}'", "':'", "'('", "')'", "'='", "'-'", "'['", "']'", "grammar", "dc", + "slash_identifier", "import_identifier", "import", "@1", + "import_symbol_list_or_star", "import_symbol_list", "typedef_decl", + "dclass_or_struct", "dclass", "@2", "dclass_name", "dclass_derivation", + "dclass_base_list", "dclass_fields", "dclass_field", "struct", "@3", + "struct_name", "struct_derivation", "struct_base_list", "struct_fields", + "struct_field", "atomic_field", "@4", "parameter_list", + "nonempty_parameter_list", "atomic_element", "named_parameter", "@5", + "unnamed_parameter", "named_parameter_with_default", "@6", + "unnamed_parameter_with_default", "@7", "parameter", + "parameter_with_default", "parameter_description", "type_name", "double_range", "uint_range", "type_definition", "parameter_definition", "char_or_uint", "small_unsigned_integer", "signed_integer", "unsigned_integer", "number", "char_or_number", "parameter_value", "@8", @@ -307,47 +325,47 @@ static const char *const yytname[] = /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ static const short yyr1[] = { - 0, 61, 61, 62, 62, 62, 62, 62, 62, 63, - 63, 64, 64, 65, 66, 65, 67, 67, 68, 68, - 69, 70, 70, 72, 71, 73, 74, 74, 75, 75, - 76, 76, 76, 77, 77, 77, 77, 79, 78, 80, - 81, 81, 82, 82, 83, 83, 83, 84, 84, 84, - 84, 86, 85, 87, 87, 88, 88, 89, 91, 90, - 92, 93, 94, 93, 95, 96, 95, 97, 97, 98, - 98, 99, 99, 99, 99, 99, 99, 99, 99, 100, - 100, 100, 100, 100, 100, 100, 101, 101, 101, 101, - 101, 102, 102, 103, 103, 103, 104, 104, 105, 106, - 107, 108, 108, 108, 109, 109, 110, 110, 110, 110, - 110, 111, 110, 112, 110, 113, 110, 110, 110, 110, - 110, 114, 114, 115, 115, 116, 116, 117, 117, 117, - 117, 117, 117, 117, 117, 117, 117, 117, 117, 117, - 117, 117, 117, 117, 117, 117, 117, 118, 118, 118, - 118, 118, 118, 118, 118, 118, 118, 119, 121, 120, - 122, 123, 123, 124, 124, 126, 125, 127, 127, 127, - 127, 129, 128, 130, 130, 131 + 0, 62, 62, 62, 63, 63, 63, 63, 63, 63, + 64, 64, 65, 65, 66, 67, 66, 68, 68, 69, + 69, 70, 71, 71, 73, 72, 74, 75, 75, 76, + 76, 77, 77, 77, 78, 78, 78, 78, 80, 79, + 81, 82, 82, 83, 83, 84, 84, 84, 85, 85, + 85, 85, 87, 86, 88, 88, 89, 89, 90, 92, + 91, 93, 94, 95, 94, 96, 97, 96, 98, 98, + 99, 99, 100, 100, 100, 101, 101, 101, 101, 101, + 101, 101, 101, 102, 102, 102, 102, 102, 102, 102, + 103, 103, 103, 103, 103, 104, 104, 105, 105, 105, + 106, 106, 107, 108, 109, 110, 110, 110, 111, 111, + 112, 112, 112, 112, 112, 113, 112, 114, 112, 115, + 112, 112, 112, 112, 112, 116, 116, 117, 117, 118, + 118, 119, 119, 119, 119, 119, 119, 119, 119, 119, + 119, 119, 119, 119, 119, 119, 119, 119, 119, 119, + 119, 120, 120, 120, 120, 120, 120, 120, 120, 120, + 120, 121, 123, 122, 124, 125, 125, 126, 126, 128, + 127, 129, 129, 129, 129, 131, 130, 132, 132, 133 }; /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ static const short yyr2[] = { - 0, 2, 2, 1, 2, 2, 2, 2, 2, 1, - 3, 1, 3, 2, 0, 5, 1, 1, 1, 3, - 2, 1, 1, 0, 7, 1, 1, 2, 1, 3, - 1, 2, 2, 2, 2, 3, 2, 0, 7, 1, - 1, 2, 1, 3, 1, 2, 2, 2, 2, 3, - 2, 0, 5, 1, 1, 1, 3, 1, 0, 3, - 1, 1, 0, 4, 1, 0, 4, 1, 1, 1, - 1, 1, 4, 3, 6, 6, 1, 1, 1, 1, - 1, 3, 2, 3, 5, 4, 1, 1, 3, 3, - 5, 1, 4, 1, 3, 4, 1, 1, 1, 1, + 0, 2, 2, 2, 1, 2, 2, 2, 2, 2, + 1, 3, 1, 3, 2, 0, 5, 1, 1, 1, + 3, 2, 1, 1, 0, 7, 1, 1, 2, 1, + 3, 1, 2, 2, 2, 2, 3, 2, 0, 7, + 1, 1, 2, 1, 3, 1, 2, 2, 2, 2, + 3, 2, 0, 5, 1, 1, 1, 3, 1, 0, + 3, 1, 1, 0, 4, 1, 0, 4, 1, 1, + 1, 1, 2, 2, 2, 1, 4, 3, 6, 6, + 1, 1, 1, 1, 1, 3, 2, 3, 5, 4, + 1, 1, 3, 3, 5, 1, 4, 1, 3, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 0, 4, 0, 4, 0, 4, 3, 3, 3, - 3, 1, 2, 1, 1, 1, 3, 1, 1, 1, + 1, 1, 1, 1, 1, 0, 4, 0, 4, 0, + 4, 3, 3, 3, 3, 1, 2, 1, 1, 1, + 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, - 2, 2, 2, 2, 2, 2, 2, 1, 0, 4, - 1, 1, 3, 1, 1, 0, 9, 1, 2, 2, - 2, 0, 4, 2, 1, 0 + 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 1, 0, 4, 1, 1, 3, 1, 1, 0, + 9, 1, 2, 2, 2, 0, 4, 2, 1, 0 }; /* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE @@ -355,162 +373,186 @@ static const short yyr2[] = error. */ static const short yydefact[] = { - 0, 175, 0, 1, 3, 100, 99, 108, 109, 110, - 111, 115, 113, 106, 107, 2, 175, 175, 0, 0, - 0, 175, 4, 7, 8, 5, 21, 22, 6, 0, - 0, 175, 175, 175, 0, 0, 164, 23, 163, 37, - 9, 11, 0, 13, 76, 127, 128, 129, 130, 131, - 132, 133, 134, 135, 136, 137, 138, 139, 140, 141, - 142, 143, 144, 145, 146, 77, 61, 64, 69, 70, - 20, 91, 60, 71, 78, 0, 98, 119, 120, 124, - 125, 0, 121, 175, 123, 0, 0, 117, 118, 175, - 175, 0, 14, 0, 62, 65, 175, 0, 0, 175, - 0, 112, 124, 122, 116, 114, 0, 0, 26, 0, - 0, 40, 10, 0, 12, 0, 0, 96, 0, 87, - 97, 86, 93, 59, 73, 103, 104, 0, 102, 101, - 105, 80, 79, 67, 68, 0, 126, 25, 28, 27, - 175, 39, 42, 41, 175, 17, 18, 15, 16, 63, - 66, 0, 92, 0, 0, 175, 175, 0, 72, 0, - 82, 0, 0, 0, 30, 0, 0, 44, 0, 89, - 88, 94, 0, 0, 83, 0, 81, 165, 29, 76, - 31, 24, 32, 175, 175, 175, 175, 43, 45, 38, - 46, 175, 175, 175, 175, 19, 0, 95, 74, 0, - 85, 75, 175, 158, 51, 33, 147, 36, 0, 157, - 34, 47, 50, 0, 48, 90, 84, 0, 167, 0, - 175, 148, 149, 150, 151, 152, 153, 154, 155, 156, - 35, 49, 171, 168, 166, 174, 0, 169, 170, 160, - 161, 159, 0, 54, 55, 57, 53, 0, 173, 0, - 52, 0, 0, 162, 56, 172, 0, 0, 0 + 0, 179, 0, 179, 1, 4, 104, 103, 112, 113, + 114, 115, 119, 117, 110, 111, 2, 80, 179, 179, + 131, 132, 133, 134, 135, 136, 137, 138, 139, 140, + 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, + 81, 179, 62, 65, 179, 179, 3, 95, 61, 75, + 0, 82, 167, 179, 0, 0, 0, 5, 8, 9, + 6, 22, 23, 7, 0, 0, 179, 179, 179, 0, + 0, 168, 38, 0, 161, 72, 151, 63, 66, 74, + 73, 179, 0, 0, 179, 52, 24, 10, 12, 0, + 14, 80, 70, 71, 21, 102, 123, 124, 128, 129, + 0, 125, 179, 127, 0, 0, 121, 122, 179, 0, + 152, 153, 154, 155, 156, 157, 158, 159, 160, 0, + 0, 100, 0, 91, 101, 90, 97, 60, 77, 107, + 108, 0, 106, 105, 109, 84, 83, 179, 179, 0, + 15, 0, 116, 128, 126, 120, 118, 0, 0, 41, + 68, 69, 0, 64, 67, 0, 96, 0, 0, 179, + 179, 0, 76, 0, 86, 0, 55, 56, 58, 54, + 0, 0, 27, 11, 0, 13, 130, 40, 43, 42, + 179, 0, 93, 92, 98, 0, 0, 87, 0, 85, + 53, 0, 26, 29, 28, 179, 18, 19, 16, 17, + 0, 179, 45, 169, 0, 99, 78, 0, 89, 79, + 57, 0, 179, 31, 0, 44, 80, 46, 39, 47, + 179, 179, 179, 179, 179, 94, 88, 30, 32, 25, + 33, 179, 179, 179, 179, 20, 162, 48, 51, 0, + 49, 0, 171, 34, 37, 0, 35, 0, 50, 175, + 172, 170, 178, 0, 173, 174, 36, 164, 165, 163, + 0, 177, 0, 0, 166, 176, 0, 0, 0 }; static const short yydefgoto[] = { - 256, 3, 41, 42, 23, 113, 147, 148, 24, 25, - 26, 89, 138, 107, 139, 163, 182, 65, 90, 142, - 110, 143, 166, 190, 183, 220, 242, 243, 244, 66, - 97, 67, 68, 115, 69, 116, 135, 245, 71, 127, - 118, 72, 123, 119, 120, 13, 14, 130, 131, 80, - 31, 33, 32, 81, 82, 83, 73, 209, 210, 186, - 219, 240, 241, 37, 74, 202, 217, 237, 247, 238, - 206 + 266, 4, 88, 89, 58, 174, 198, 199, 59, 60, + 61, 138, 193, 171, 194, 212, 230, 40, 108, 178, + 148, 179, 201, 219, 41, 137, 165, 166, 167, 42, + 82, 43, 92, 119, 93, 120, 152, 168, 46, 47, + 131, 122, 48, 127, 123, 124, 14, 15, 134, 135, + 99, 66, 68, 67, 100, 101, 102, 49, 74, 75, + 223, 247, 258, 259, 50, 51, 224, 241, 254, 260, + 255, 76 }; static const short yypact[] = { - -22,-32768, 39, 46,-32768,-32768,-32768, 20,-32768, 22, - -32768,-32768,-32768, 37, 55,-32768, 89, 89, 95, 95, - 281, 89,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 139, - 139, 23, 23, 23, 139, 139,-32768,-32768,-32768,-32768, - -32768, 97, 28, 94,-32768,-32768,-32768,-32768,-32768,-32768, + 61,-32768, 29, 362, 137,-32768,-32768,-32768, 13,-32768, + 19,-32768,-32768,-32768, 20, 30,-32768, 11, 82, 82, -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, - -32768,-32768,-32768,-32768,-32768,-32768, 90, 93,-32768,-32768, - -32768,-32768, 27, 53,-32768, 91,-32768,-32768,-32768,-32768, - -32768, 96,-32768, 101,-32768, 98, 127,-32768,-32768, 134, - 135, 183,-32768, 95,-32768,-32768, 48, 184, 139, 176, - 281,-32768, 39,-32768,-32768,-32768, 185, 142,-32768, 187, - 145,-32768,-32768, 31, 97, 39, 39,-32768, -13, 140, - -32768,-32768,-32768, 47, 144,-32768,-32768, -3,-32768,-32768, - -32768, 7,-32768,-32768,-32768, 147,-32768,-32768,-32768, 149, - -32768,-32768,-32768, 150,-32768,-32768, 97,-32768, 153,-32768, - -32768, 48,-32768, 48, 139, 48, 176, 176, 157, 176, - -32768, 154, 185, 205,-32768, 187, 243,-32768, 95, 151, - -32768,-32768, 25, 51, 10, 139,-32768,-32768,-32768, 70, -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, - -32768,-32768,-32768,-32768,-32768, 97, 48,-32768,-32768, 176, - -32768,-32768,-32768,-32768,-32768, 92,-32768, 92, 79, 92, - -32768,-32768,-32768, 160,-32768,-32768,-32768, 143,-32768, 200, - 281,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, - -32768,-32768,-32768,-32768,-32768,-32768, 163,-32768,-32768,-32768, - -32768, 161, 155, 165,-32768,-32768,-32768, 39,-32768, 200, - -32768, 281, 164,-32768,-32768,-32768, 214, 217,-32768 + -32768,-32768, 43, 58,-32768,-32768,-32768,-32768, 1, -25, + 44,-32768,-32768, 82, 90, 90, 390,-32768,-32768,-32768, + -32768,-32768,-32768,-32768, 119, 119, 16, 16, 16, 119, + 119,-32768,-32768, 67, 132,-32768,-32768,-32768,-32768,-32768, + -32768, 53, 117, 119, 108,-32768,-32768,-32768, 77, 3, + 78,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, + 73,-32768, 79,-32768, 72, 71,-32768,-32768, 81, 390, + -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 29, + 29,-32768, 2, 74,-32768,-32768,-32768, -31, 83,-32768, + -32768, 35,-32768,-32768,-32768, 37,-32768, 390, 85, 126, + -32768, 90,-32768, 29,-32768,-32768,-32768, 129, 89,-32768, + -32768,-32768, 86,-32768,-32768, 53,-32768, 53, 119, 53, + 108, 108, 112, 108,-32768, 105, 111,-32768,-32768,-32768, + 130, 124,-32768,-32768, 6, 77,-32768,-32768,-32768, 113, + -32768, 125, 120,-32768,-32768, 42, 45, 40, 119,-32768, + -32768, 390,-32768,-32768, 134,-32768,-32768, 77,-32768, 136, + 129, 284,-32768,-32768, 53,-32768,-32768, 108,-32768,-32768, + -32768, 130, 323,-32768, 90,-32768, -18,-32768,-32768,-32768, + -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, + -32768,-32768,-32768,-32768,-32768, 77,-32768,-32768,-32768, 141, + -32768, 245,-32768, 132, 132, 116,-32768, 176,-32768,-32768, + -32768,-32768,-32768, 142,-32768,-32768,-32768,-32768,-32768, 139, + 29,-32768, 176, 138,-32768,-32768, 192, 195,-32768 }; static const short yypgoto[] = { - -32768,-32768, -88, 222,-32768,-32768,-32768,-32768,-32768,-32768, - -32768,-32768, 80,-32768,-32768,-32768,-32768, 240,-32768, 81, - -32768,-32768,-32768,-32768, 78,-32768,-32768,-32768, -4, 148, - -32768, 156, -144,-32768, -129,-32768,-32768, 229,-32768, 99, - 124,-32768,-32768, -133, -27, -95, -90, -125, -107, -2, - -32768,-32768,-32768, 106, 167,-32768,-32768, -73, -8, 88, - -32768, 32,-32768, 120, 277,-32768,-32768,-32768,-32768,-32768, - 0 + -32768,-32768, -135, 143,-32768,-32768,-32768,-32768,-32768,-32768, + -32768,-32768, -15,-32768,-32768,-32768,-32768, 193,-32768, 4, + -32768,-32768,-32768,-32768, -146,-32768,-32768,-32768, 8, 94, + -32768, 96, -1,-32768, 0,-32768,-32768, 150,-32768,-32768, + 47, 50,-32768,-32768, -109, -53, -83, -77, -122, -114, + -2,-32768,-32768,-32768, -17, 114,-32768,-32768, -112, -40, + 5,-32768, -52,-32768, 9, 209,-32768,-32768,-32768,-32768, + -32768, 7 }; -#define YYLAST 316 +#define YYLAST 425 static const short yytable[] = { - 15, 4, 77, 78, 128, 114, 160, 87, 88, 129, - 5, 6, 125, 5, 6, 125, 38, 38, 169, 184, - 170, 38, 192, 1, 2, 146, 5, 6, 7, 8, - 9, 84, 84, 84, 185, -58, 128, 193, 151, 40, - 92, 129, 5, 6, 7, 8, 9, 152, 157, 200, - 174, 76, 176, 158, 117, 16, 17, 18, 19, 20, - 21, 128, 128, 215, 128, 159, 129, 129, 199, 129, - 29, 124, 30, 235, 79, 10, 151, 93, 11, 128, - 195, 145, 12, 84, 129, 197, 96, 34, 236, 108, - 111, 10, 216, 22, 11, 154, 121, 36, 12, 132, - 136, 98, 157, 40, 128, 35, 155, 198, 99, 129, - 205, 207, 208, 149, 150, 221, 222, 223, 224, 225, - 226, 227, 228, 229, 203, 204, 230, 171, 221, 222, - 223, 224, 225, 226, 227, 228, 229, 39, 85, 86, - 164, 75, 76, 93, 167, 91, 100, 94, 201, 101, - 95, 44, 102, 17, 104, 121, 132, 21, 232, 45, - 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, - 56, 57, 58, 59, 60, 61, 62, 63, 64, 5, - 6, 125, 126, 211, 212, 213, 214, 105, 106, 109, - 233, 112, 122, 137, 140, 141, 234, 144, 153, 156, - 162, 165, 218, 161, 168, 175, 177, 231, 239, 196, - 248, 250, 249, 179, 257, 17, 251, 258, 255, 21, - 246, 45, 46, 47, 48, 49, 50, 51, 52, 53, - 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, - 64, 43, 178, 27, 191, 252, 187, 254, 133, 70, - 103, 179, 180, 17, 194, 173, 134, 21, 181, 45, - 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, - 56, 57, 58, 59, 60, 61, 62, 63, 64, 172, - 28, 253, 0, 0, 0, 0, 0, 0, 0, 44, - 188, 17, 0, 0, 0, 21, 189, 45, 46, 47, - 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, - 58, 59, 60, 61, 62, 63, 64 + 16, 132, 44, 45, 79, 80, 175, 133, 5, -59, + 52, 96, 97, 164, 87, 140, 106, 107, 158, 6, + 7, 8, 9, 10, 83, 52, 52, 72, 73, 159, + 128, 84, 6, 7, 8, 9, 10, 236, -168, 197, + 6, 7, 129, 6, 7, 129, 182, 187, 183, 189, + 104, 105, 132, 141, 155, 220, 95, 196, 133, 121, + 52, 81, 86, 156, 64, 208, 231, -168, 98, 11, + 65, 69, 12, 103, 103, 103, 13, 132, 132, 235, + 132, 70, 11, 133, 133, 12, 133, 161, 125, 13, + 71, 136, 162, 226, 155, 225, 163, 161, 87, 207, + 85, 77, 206, 205, 132, 184, 1, 2, 3, 103, + 133, 6, 7, 129, 130, 149, 78, 153, 154, 243, + 244, 245, 95, 109, 132, 126, 139, 142, 141, 145, + 133, 143, 146, 157, 173, 209, 147, 177, 192, 160, + 170, 176, 180, 181, 169, 172, 53, 18, 54, 55, + 56, 19, 110, 111, 112, 113, 114, 115, 116, 117, + 118, 188, 190, 191, 256, 200, 125, 136, 110, 111, + 112, 113, 114, 115, 116, 117, 118, 195, 203, 204, + 237, 238, 239, 240, 257, 57, 211, 202, 214, 248, + 261, 262, 267, 265, 246, 268, 227, 62, 90, 210, + 221, 222, 213, 150, 215, 151, 94, 186, 52, 185, + 264, 232, 233, 63, 0, 0, 144, 234, 0, 52, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 242, 0, 0, 0, 0, 0, 0, 0, 0, + 252, 253, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 91, 0, 18, 0, 0, 263, 19, + 249, 20, 21, 22, 23, 24, 25, 26, 27, 28, + 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, + 39, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 216, 250, 18, 0, 0, 0, 19, 251, + 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, + 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 216, 217, 18, 0, 0, 0, 19, 218, 20, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 31, 32, 33, 34, 35, 36, 37, 38, 39, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 17, 228, 18, 0, 0, 0, 19, 229, 20, 21, + 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, + 32, 33, 34, 35, 36, 37, 38, 39, 91, 0, + 18, 0, 0, 0, 19, 0, 20, 21, 22, 23, + 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, + 34, 35, 36, 37, 38, 39 }; static const short yycheck[] = { - 2, 1, 29, 30, 99, 93, 131, 34, 35, 99, - 3, 4, 5, 3, 4, 5, 16, 17, 151, 163, - 153, 21, 166, 45, 46, 113, 3, 4, 5, 6, - 7, 31, 32, 33, 163, 8, 131, 166, 51, 8, - 12, 131, 3, 4, 5, 6, 7, 60, 51, 174, - 157, 3, 159, 56, 6, 9, 10, 11, 12, 13, - 14, 156, 157, 196, 159, 58, 156, 157, 58, 159, - 50, 98, 50, 217, 51, 52, 51, 49, 55, 174, - 168, 50, 59, 83, 174, 60, 59, 50, 217, 89, - 90, 52, 199, 47, 55, 48, 96, 8, 59, 99, - 102, 48, 51, 8, 199, 50, 59, 56, 55, 199, - 183, 184, 185, 115, 116, 36, 37, 38, 39, 40, - 41, 42, 43, 44, 54, 55, 47, 154, 36, 37, - 38, 39, 40, 41, 42, 43, 44, 17, 32, 33, - 140, 21, 3, 49, 144, 48, 55, 57, 175, 53, - 57, 8, 51, 10, 56, 155, 156, 14, 15, 16, - 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, - 27, 28, 29, 30, 31, 32, 33, 34, 35, 3, - 4, 5, 6, 191, 192, 193, 194, 60, 54, 54, - 47, 8, 8, 8, 52, 8, 53, 52, 58, 55, - 51, 51, 202, 56, 51, 48, 52, 47, 8, 58, - 47, 56, 51, 8, 0, 10, 51, 0, 54, 14, - 220, 16, 17, 18, 19, 20, 21, 22, 23, 24, + 2, 84, 3, 3, 44, 45, 141, 84, 1, 8, + 3, 64, 65, 135, 8, 12, 69, 70, 49, 3, + 4, 5, 6, 7, 49, 18, 19, 18, 19, 60, + 83, 56, 3, 4, 5, 6, 7, 55, 56, 174, + 3, 4, 5, 3, 4, 5, 155, 161, 157, 163, + 67, 68, 135, 50, 52, 201, 3, 51, 135, 6, + 53, 60, 53, 61, 51, 187, 212, 56, 52, 53, + 51, 51, 56, 66, 67, 68, 60, 160, 161, 214, + 163, 51, 53, 160, 161, 56, 163, 52, 81, 60, + 8, 84, 57, 207, 52, 204, 59, 52, 8, 59, + 56, 58, 57, 61, 187, 158, 45, 46, 47, 102, + 187, 3, 4, 5, 6, 108, 58, 119, 120, 231, + 232, 233, 3, 56, 207, 8, 49, 54, 50, 57, + 207, 52, 61, 59, 8, 188, 55, 8, 8, 56, + 55, 143, 53, 57, 137, 138, 9, 10, 11, 12, + 13, 14, 36, 37, 38, 39, 40, 41, 42, 43, + 44, 49, 57, 52, 48, 52, 159, 160, 36, 37, + 38, 39, 40, 41, 42, 43, 44, 53, 53, 59, + 220, 221, 222, 223, 8, 48, 52, 180, 52, 48, + 48, 52, 0, 55, 234, 0, 211, 4, 55, 191, + 201, 201, 195, 109, 200, 109, 56, 160, 201, 159, + 262, 212, 212, 4, -1, -1, 102, 212, -1, 212, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 224, -1, -1, -1, -1, -1, -1, -1, -1, + 241, 241, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, 8, -1, 10, -1, -1, 260, 14, + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, - 35, 19, 162, 3, 166, 247, 165, 251, 100, 20, - 83, 8, 47, 10, 166, 156, 100, 14, 53, 16, + 35, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, -1, 8, 48, 10, -1, -1, -1, 14, 54, + 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, + 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 8, 48, 10, -1, -1, -1, 14, 54, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, - 27, 28, 29, 30, 31, 32, 33, 34, 35, 155, - 3, 249, -1, -1, -1, -1, -1, -1, -1, 8, - 47, 10, -1, -1, -1, 14, 53, 16, 17, 18, - 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, - 29, 30, 31, 32, 33, 34, 35 + 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + 8, 48, 10, -1, -1, -1, 14, 54, 16, 17, + 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, + 28, 29, 30, 31, 32, 33, 34, 35, 8, -1, + 10, -1, -1, -1, 14, -1, 16, 17, 18, 19, + 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, + 30, 31, 32, 33, 34, 35 }; /* -*-C-*- Note some compilers choke on comments on `#line' lines. */ #line 3 "/usr/share/bison/bison.simple" @@ -1219,8 +1261,14 @@ yyreduce: switch (yyn) { -case 5: -#line 162 "dcParser.yxx" +case 3: +#line 174 "dcParser.yxx" +{ + parameter_description = yyvsp[0].u.field; +} + break; +case 6: +#line 183 "dcParser.yxx" { if (!dc_file->add_class(yyvsp[0].u.dclass)) { DCClass *old_class = dc_file->get_class_by_name(yyvsp[0].u.dclass->get_name()); @@ -1232,259 +1280,302 @@ case 5: } } break; -case 6: -#line 173 "dcParser.yxx" +case 7: +#line 194 "dcParser.yxx" { if (!dc_file->add_switch(yyvsp[0].u.dswitch)) { yyerror("Duplicate class name: " + yyvsp[0].u.dswitch->get_name()); } } break; -case 10: -#line 185 "dcParser.yxx" +case 11: +#line 206 "dcParser.yxx" { yyval.str = yyvsp[-2].str + string("/") + yyvsp[0].str; } break; -case 12: -#line 193 "dcParser.yxx" +case 13: +#line 214 "dcParser.yxx" { yyval.str = yyvsp[-2].str + string(".") + yyvsp[0].str; } break; -case 13: -#line 200 "dcParser.yxx" +case 14: +#line 221 "dcParser.yxx" { dc_file->add_import_module(yyvsp[0].str); } break; -case 14: -#line 204 "dcParser.yxx" +case 15: +#line 225 "dcParser.yxx" { dc_file->add_import_module(yyvsp[-1].str); } break; -case 17: -#line 213 "dcParser.yxx" +case 18: +#line 234 "dcParser.yxx" { dc_file->add_import_symbol("*"); } break; -case 18: -#line 220 "dcParser.yxx" -{ - dc_file->add_import_symbol(yyvsp[0].str); -} - break; case 19: -#line 224 "dcParser.yxx" +#line 241 "dcParser.yxx" { dc_file->add_import_symbol(yyvsp[0].str); } break; case 20: -#line 231 "dcParser.yxx" +#line 245 "dcParser.yxx" { - DCTypedef *dtypedef = new DCTypedef(yyvsp[0].u.parameter); - - if (!dc_file->add_typedef(dtypedef)) { - DCTypedef *old_typedef = dc_file->get_typedef_by_name(dtypedef->get_name()); - if (old_typedef->is_bogus_typedef()) { - yyerror("typedef defined after its first reference: " + dtypedef->get_name()); - } else { - yyerror("Duplicate typedef name: " + dtypedef->get_name()); + dc_file->add_import_symbol(yyvsp[0].str); +} + break; +case 21: +#line 252 "dcParser.yxx" +{ + if (yyvsp[0].u.parameter != (DCParameter *)NULL) { + DCTypedef *dtypedef = new DCTypedef(yyvsp[0].u.parameter); + + if (!dc_file->add_typedef(dtypedef)) { + DCTypedef *old_typedef = dc_file->get_typedef_by_name(dtypedef->get_name()); + if (old_typedef->is_bogus_typedef()) { + yyerror("typedef defined after its first reference: " + dtypedef->get_name()); + } else { + yyerror("Duplicate typedef name: " + dtypedef->get_name()); + } } } } break; -case 23: -#line 252 "dcParser.yxx" +case 24: +#line 275 "dcParser.yxx" { yyval.u.dclass = current_class; current_class = new DCClass(yyvsp[0].str, false, false); } break; -case 24: -#line 257 "dcParser.yxx" +case 25: +#line 280 "dcParser.yxx" { yyval.u.dclass = current_class; current_class = yyvsp[-4].u.dclass; } break; -case 25: -#line 265 "dcParser.yxx" +case 26: +#line 288 "dcParser.yxx" { - DCClass *dclass = dc_file->get_class_by_name(yyvsp[0].str); - if (dclass == (DCClass *)NULL) { - // Create a bogus class as a forward reference. - dclass = new DCClass(yyvsp[0].str, false, true); - dc_file->add_class(dclass); - } - if (dclass->is_struct()) { - yyerror("struct name not allowed"); - } + if (dc_file == (DCFile *)NULL) { + yyerror("No DCFile available, so no class names are predefined."); + yyval.u.dclass = NULL; + + } else { + DCClass *dclass = dc_file->get_class_by_name(yyvsp[0].str); + if (dclass == (DCClass *)NULL) { + // Create a bogus class as a forward reference. + dclass = new DCClass(yyvsp[0].str, false, true); + dc_file->add_class(dclass); + } + if (dclass->is_struct()) { + yyerror("struct name not allowed"); + } - yyval.u.dclass = dclass; -} - break; -case 28: -#line 287 "dcParser.yxx" -{ - if (yyvsp[0].u.dclass != (DCClass *)NULL) { - current_class->add_parent(yyvsp[0].u.dclass); + yyval.u.dclass = dclass; } } break; case 29: -#line 293 "dcParser.yxx" +#line 316 "dcParser.yxx" { if (yyvsp[0].u.dclass != (DCClass *)NULL) { current_class->add_parent(yyvsp[0].u.dclass); } } break; -case 32: -#line 304 "dcParser.yxx" +case 30: +#line 322 "dcParser.yxx" { - if (!current_class->add_field(yyvsp[0].u.field)) { + if (yyvsp[0].u.dclass != (DCClass *)NULL) { + current_class->add_parent(yyvsp[0].u.dclass); + } +} + break; +case 33: +#line 333 "dcParser.yxx" +{ + if (yyvsp[0].u.field == (DCField *)NULL) { + // Pass this error up. + } else if (!current_class->add_field(yyvsp[0].u.field)) { yyerror("Duplicate field name: " + yyvsp[0].u.field->get_name()); } else if (yyvsp[0].u.field->get_number() < 0) { yyerror("A non-network field cannot be stored on a dclass"); } } break; -case 33: -#line 315 "dcParser.yxx" +case 34: +#line 346 "dcParser.yxx" { + if (yyvsp[-1].u.field != (DCField *)NULL) { + if (yyvsp[-1].u.field->get_name().empty()) { + yyerror("Field name required."); + } + yyvsp[-1].u.field->set_flags(yyvsp[0].u.s_int); + } yyval.u.field = yyvsp[-1].u.field; - yyval.u.field->set_flags(yyvsp[0].u.s_int); -} - break; -case 35: -#line 321 "dcParser.yxx" -{ - yyerror("Unnamed parameters are not allowed on a dclass"); - yyval.u.field = yyvsp[-2].u.parameter; - yyval.u.field->set_flags(yyvsp[-1].u.s_int); } break; case 36: -#line 327 "dcParser.yxx" +#line 357 "dcParser.yxx" { - yyval.u.field = yyvsp[-1].u.parameter; - yyval.u.field->set_flags(yyvsp[0].u.s_int); + yyerror("Unnamed parameters are not allowed on a dclass"); + if (yyvsp[-2].u.parameter != (DCField *)NULL) { + yyvsp[-2].u.parameter->set_flags(yyvsp[-1].u.s_int); + } + yyval.u.field = yyvsp[-2].u.parameter; } break; case 37: -#line 335 "dcParser.yxx" +#line 365 "dcParser.yxx" +{ + if (yyvsp[-1].u.parameter != (DCField *)NULL) { + yyvsp[-1].u.parameter->set_flags(yyvsp[0].u.s_int); + } + yyval.u.field = yyvsp[-1].u.parameter; +} + break; +case 38: +#line 375 "dcParser.yxx" { yyval.u.dclass = current_class; current_class = new DCClass(yyvsp[0].str, true, false); } break; -case 38: -#line 340 "dcParser.yxx" +case 39: +#line 380 "dcParser.yxx" { yyval.u.dclass = current_class; current_class = yyvsp[-4].u.dclass; } break; -case 39: -#line 348 "dcParser.yxx" +case 40: +#line 388 "dcParser.yxx" { - DCClass *dstruct = dc_file->get_class_by_name(yyvsp[0].str); - if (dstruct == (DCClass *)NULL) { - // Create a bogus class as a forward reference. - dstruct = new DCClass(yyvsp[0].str, false, true); - dc_file->add_class(dstruct); - } - if (!dstruct->is_struct()) { - yyerror("struct name required"); - } + if (dc_file == (DCFile *)NULL) { + yyerror("No DCFile available, so no struct names are predefined."); + yyval.u.dclass = NULL; + + } else { + DCClass *dstruct = dc_file->get_class_by_name(yyvsp[0].str); + if (dstruct == (DCClass *)NULL) { + // Create a bogus class as a forward reference. + dstruct = new DCClass(yyvsp[0].str, false, true); + dc_file->add_class(dstruct); + } + if (!dstruct->is_struct()) { + yyerror("struct name required"); + } - yyval.u.dclass = dstruct; -} - break; -case 42: -#line 370 "dcParser.yxx" -{ - if (yyvsp[0].u.dclass != (DCClass *)NULL) { - current_class->add_parent(yyvsp[0].u.dclass); + yyval.u.dclass = dstruct; } } break; case 43: -#line 376 "dcParser.yxx" +#line 416 "dcParser.yxx" { if (yyvsp[0].u.dclass != (DCClass *)NULL) { current_class->add_parent(yyvsp[0].u.dclass); } } break; -case 46: -#line 387 "dcParser.yxx" +case 44: +#line 422 "dcParser.yxx" { - if (!current_class->add_field(yyvsp[0].u.field)) { + if (yyvsp[0].u.dclass != (DCClass *)NULL) { + current_class->add_parent(yyvsp[0].u.dclass); + } +} + break; +case 47: +#line 433 "dcParser.yxx" +{ + if (yyvsp[0].u.field == (DCField *)NULL) { + // Pass this error up. + } else if (!current_class->add_field(yyvsp[0].u.field)) { yyerror("Duplicate field name: " + yyvsp[0].u.field->get_name()); } } break; -case 49: -#line 398 "dcParser.yxx" +case 48: +#line 444 "dcParser.yxx" +{ + if (yyvsp[-1].u.field->get_name().empty()) { + yyerror("Field name required."); + } + yyval.u.field = yyvsp[-1].u.field; +} + break; +case 50: +#line 452 "dcParser.yxx" { yyval.u.field = yyvsp[-2].u.parameter; } break; -case 50: -#line 402 "dcParser.yxx" +case 51: +#line 456 "dcParser.yxx" { yyval.u.field = yyvsp[-1].u.parameter; } break; -case 51: -#line 409 "dcParser.yxx" +case 52: +#line 463 "dcParser.yxx" { yyval.u.field = current_atomic; current_atomic = new DCAtomicField(yyvsp[-1].str); } break; -case 52: -#line 414 "dcParser.yxx" +case 53: +#line 468 "dcParser.yxx" { yyval.u.field = current_atomic; current_atomic = yyvsp[-2].u.atomic; } break; -case 57: -#line 432 "dcParser.yxx" +case 58: +#line 486 "dcParser.yxx" { - current_atomic->add_element(yyvsp[0].u.parameter); + if (yyvsp[0].u.parameter != (DCParameter *)NULL) { + current_atomic->add_element(yyvsp[0].u.parameter); + } } break; -case 58: -#line 439 "dcParser.yxx" +case 59: +#line 495 "dcParser.yxx" { current_parameter = yyvsp[0].u.parameter; } break; -case 59: -#line 443 "dcParser.yxx" +case 60: +#line 499 "dcParser.yxx" { yyval.u.parameter = yyvsp[0].u.parameter; } break; -case 62: -#line 455 "dcParser.yxx" +case 63: +#line 511 "dcParser.yxx" { current_packer = &default_packer; current_packer->clear_data(); - current_packer->begin_pack(yyvsp[-1].u.parameter); + if (yyvsp[-1].u.parameter != (DCField *)NULL) { + current_packer->begin_pack(yyvsp[-1].u.parameter); + } } break; -case 63: -#line 461 "dcParser.yxx" +case 64: +#line 519 "dcParser.yxx" { - bool is_valid = yyvsp[-3].u.parameter->is_valid(); + bool is_valid = false; + if (yyvsp[-3].u.parameter != (DCField *)NULL) { + is_valid = yyvsp[-3].u.parameter->is_valid(); + } if (current_packer->end_pack()) { yyvsp[-3].u.parameter->set_default_value(current_packer->get_string()); @@ -1498,18 +1589,23 @@ case 63: } } break; -case 65: -#line 480 "dcParser.yxx" -{ - current_packer = &default_packer; - current_packer->clear_data(); - current_packer->begin_pack(yyvsp[-1].u.parameter); -} - break; case 66: -#line 486 "dcParser.yxx" +#line 541 "dcParser.yxx" { - bool is_valid = yyvsp[-3].u.parameter->is_valid(); + current_packer = &default_packer; + current_packer->clear_data(); + if (yyvsp[-1].u.parameter != (DCField *)NULL) { + current_packer->begin_pack(yyvsp[-1].u.parameter); + } +} + break; +case 67: +#line 549 "dcParser.yxx" +{ + bool is_valid = false; + if (yyvsp[-3].u.parameter != (DCField *)NULL) { + is_valid = yyvsp[-3].u.parameter->is_valid(); + } if (current_packer->end_pack()) { yyvsp[-3].u.parameter->set_default_value(current_packer->get_string()); @@ -1523,14 +1619,32 @@ case 66: } } break; -case 71: -#line 514 "dcParser.yxx" +case 72: +#line 580 "dcParser.yxx" +{ + yyval.u.field = yyvsp[-1].u.field; +} + break; +case 73: +#line 584 "dcParser.yxx" +{ + yyval.u.field = yyvsp[-1].u.parameter; +} + break; +case 74: +#line 588 "dcParser.yxx" +{ + yyval.u.field = yyvsp[-1].u.parameter; +} + break; +case 75: +#line 595 "dcParser.yxx" { yyval.u.parameter = new DCSimpleParameter(yyvsp[0].u.subatomic); } break; -case 72: -#line 518 "dcParser.yxx" +case 76: +#line 599 "dcParser.yxx" { DCSimpleParameter *simple_param = new DCSimpleParameter(yyvsp[-3].u.subatomic); if (!simple_param->set_range(double_range)) { @@ -1539,8 +1653,8 @@ case 72: yyval.u.parameter = simple_param; } break; -case 73: -#line 526 "dcParser.yxx" +case 77: +#line 607 "dcParser.yxx" { DCSimpleParameter *simple_param = new DCSimpleParameter(yyvsp[-2].u.subatomic); if (yyvsp[0].u.s_uint == 0) { @@ -1552,8 +1666,8 @@ case 73: yyval.u.parameter = simple_param; } break; -case 74: -#line 537 "dcParser.yxx" +case 78: +#line 618 "dcParser.yxx" { DCSimpleParameter *simple_param = new DCSimpleParameter(yyvsp[-5].u.subatomic); if (yyvsp[-3].u.s_uint == 0) { @@ -1568,8 +1682,8 @@ case 74: yyval.u.parameter = simple_param; } break; -case 75: -#line 551 "dcParser.yxx" +case 79: +#line 632 "dcParser.yxx" { DCSimpleParameter *simple_param = new DCSimpleParameter(yyvsp[-5].u.subatomic); if (yyvsp[0].u.s_uint == 0) { @@ -1584,106 +1698,124 @@ case 75: yyval.u.parameter = simple_param; } break; -case 76: -#line 565 "dcParser.yxx" -{ - DCTypedef *dtypedef = dc_file->get_typedef_by_name(yyvsp[0].str); - if (dtypedef == (DCTypedef *)NULL) { - // Maybe it's a class name. - DCClass *dclass = dc_file->get_class_by_name(yyvsp[0].str); - if (dclass != (DCClass *)NULL) { - if (!dclass->is_struct()) { - yyerror("cannot embed a dclass object within a message; use a struct"); - } - // Create an implicit typedef for this. - dtypedef = new DCTypedef(new DCClassParameter(dclass), true); - } else { - // Maybe it's a switch name. - DCSwitch *dswitch = dc_file->get_switch_by_name(yyvsp[0].str); - if (dswitch != (DCSwitch *)NULL) { - // This also gets an implicit typedef. - dtypedef = new DCTypedef(new DCSwitchParameter(dswitch), true); - } else { - // It's an undefined typedef. Create a bogus forward reference. - dtypedef = new DCTypedef(yyvsp[0].str); - } - } - - dc_file->add_typedef(dtypedef); - } - - yyval.u.parameter = dtypedef->make_new_parameter(); -} - break; -case 77: -#line 594 "dcParser.yxx" -{ - // This is an inline struct definition. - dc_file->add_thing_to_delete(yyvsp[0].u.dclass); - yyval.u.parameter = new DCClassParameter(yyvsp[0].u.dclass); -} - break; -case 78: -#line 600 "dcParser.yxx" -{ - // This is an inline switch definition. - dc_file->add_thing_to_delete(yyvsp[0].u.dswitch); - yyval.u.parameter = new DCSwitchParameter(yyvsp[0].u.dswitch); -} - break; -case 79: -#line 609 "dcParser.yxx" -{ - double_range.clear(); -} - break; case 80: -#line 613 "dcParser.yxx" +#line 646 "dcParser.yxx" { - double_range.clear(); - if (!double_range.add_range(yyvsp[0].u.real, yyvsp[0].u.real)) { - yyerror("Overlapping range"); + if (dc_file == (DCFile *)NULL) { + yyerror("Invalid type."); + yyval.u.parameter = NULL; + + } else { + DCTypedef *dtypedef = dc_file->get_typedef_by_name(yyvsp[0].str); + if (dtypedef == (DCTypedef *)NULL) { + // Maybe it's a class name. + DCClass *dclass = dc_file->get_class_by_name(yyvsp[0].str); + if (dclass != (DCClass *)NULL) { + if (!dclass->is_struct()) { + yyerror("cannot embed a dclass object within a message; use a struct"); + } + // Create an implicit typedef for this. + dtypedef = new DCTypedef(new DCClassParameter(dclass), true); + } else { + // Maybe it's a switch name. + DCSwitch *dswitch = dc_file->get_switch_by_name(yyvsp[0].str); + if (dswitch != (DCSwitch *)NULL) { + // This also gets an implicit typedef. + dtypedef = new DCTypedef(new DCSwitchParameter(dswitch), true); + } else { + // It's an undefined typedef. Create a bogus forward reference. + dtypedef = new DCTypedef(yyvsp[0].str); + } + } + + dc_file->add_typedef(dtypedef); + } + + yyval.u.parameter = dtypedef->make_new_parameter(); } } break; case 81: -#line 620 "dcParser.yxx" +#line 681 "dcParser.yxx" { - double_range.clear(); - if (!double_range.add_range(yyvsp[-2].u.real, yyvsp[0].u.real)) { - yyerror("Overlapping range"); + // This is an inline struct definition. + if (yyvsp[0].u.dclass == (DCClass *)NULL) { + yyval.u.parameter = NULL; + } else { + if (dc_file != (DCFile *)NULL) { + dc_file->add_thing_to_delete(yyvsp[0].u.dclass); + } + yyval.u.parameter = new DCClassParameter(yyvsp[0].u.dclass); } } break; case 82: -#line 627 "dcParser.yxx" +#line 693 "dcParser.yxx" { - double_range.clear(); - if (yyvsp[0].u.real >= 0) { - yyerror("Syntax error"); - } else if (!double_range.add_range(yyvsp[-1].u.real, -yyvsp[0].u.real)) { - yyerror("Overlapping range"); + // This is an inline switch definition. + if (yyvsp[0].u.dswitch == (DCSwitch *)NULL) { + yyval.u.parameter = NULL; + } else { + if (dc_file != (DCFile *)NULL) { + dc_file->add_thing_to_delete(yyvsp[0].u.dswitch); + } + yyval.u.parameter = new DCSwitchParameter(yyvsp[0].u.dswitch); } } break; case 83: -#line 636 "dcParser.yxx" +#line 708 "dcParser.yxx" { - if (!double_range.add_range(yyvsp[0].u.real, yyvsp[0].u.real)) { - yyerror("Overlapping range"); - } + double_range.clear(); } break; case 84: -#line 642 "dcParser.yxx" +#line 712 "dcParser.yxx" { - if (!double_range.add_range(yyvsp[-2].u.real, yyvsp[0].u.real)) { + double_range.clear(); + if (!double_range.add_range(yyvsp[0].u.real, yyvsp[0].u.real)) { yyerror("Overlapping range"); } } break; case 85: -#line 648 "dcParser.yxx" +#line 719 "dcParser.yxx" +{ + double_range.clear(); + if (!double_range.add_range(yyvsp[-2].u.real, yyvsp[0].u.real)) { + yyerror("Overlapping range"); + } +} + break; +case 86: +#line 726 "dcParser.yxx" +{ + double_range.clear(); + if (yyvsp[0].u.real >= 0) { + yyerror("Syntax error"); + } else if (!double_range.add_range(yyvsp[-1].u.real, -yyvsp[0].u.real)) { + yyerror("Overlapping range"); + } +} + break; +case 87: +#line 735 "dcParser.yxx" +{ + if (!double_range.add_range(yyvsp[0].u.real, yyvsp[0].u.real)) { + yyerror("Overlapping range"); + } +} + break; +case 88: +#line 741 "dcParser.yxx" +{ + if (!double_range.add_range(yyvsp[-2].u.real, yyvsp[0].u.real)) { + yyerror("Overlapping range"); + } +} + break; +case 89: +#line 747 "dcParser.yxx" { if (yyvsp[0].u.real >= 0) { yyerror("Syntax error"); @@ -1692,61 +1824,65 @@ case 85: } } break; -case 86: -#line 659 "dcParser.yxx" -{ - uint_range.clear(); -} - break; -case 87: -#line 663 "dcParser.yxx" -{ - uint_range.clear(); - if (!uint_range.add_range(yyvsp[0].u.s_uint, yyvsp[0].u.s_uint)) { - yyerror("Overlapping range"); - } -} - break; -case 88: -#line 670 "dcParser.yxx" -{ - uint_range.clear(); - if (!uint_range.add_range(yyvsp[-2].u.s_uint, yyvsp[0].u.s_uint)) { - yyerror("Overlapping range"); - } -} - break; -case 89: -#line 677 "dcParser.yxx" -{ - if (!uint_range.add_range(yyvsp[0].u.s_uint, yyvsp[0].u.s_uint)) { - yyerror("Overlapping range"); - } -} - break; case 90: -#line 683 "dcParser.yxx" +#line 758 "dcParser.yxx" { - if (!uint_range.add_range(yyvsp[-2].u.s_uint, yyvsp[0].u.s_uint)) { + uint_range.clear(); +} + break; +case 91: +#line 762 "dcParser.yxx" +{ + uint_range.clear(); + if (!uint_range.add_range(yyvsp[0].u.s_uint, yyvsp[0].u.s_uint)) { yyerror("Overlapping range"); } } break; case 92: -#line 693 "dcParser.yxx" +#line 769 "dcParser.yxx" { - yyval.u.parameter = new DCArrayParameter(yyvsp[-3].u.parameter, uint_range); + uint_range.clear(); + if (!uint_range.add_range(yyvsp[-2].u.s_uint, yyvsp[0].u.s_uint)) { + yyerror("Overlapping range"); + } } break; case 93: -#line 700 "dcParser.yxx" +#line 776 "dcParser.yxx" +{ + if (!uint_range.add_range(yyvsp[0].u.s_uint, yyvsp[0].u.s_uint)) { + yyerror("Overlapping range"); + } +} + break; +case 94: +#line 782 "dcParser.yxx" +{ + if (!uint_range.add_range(yyvsp[-2].u.s_uint, yyvsp[0].u.s_uint)) { + yyerror("Overlapping range"); + } +} + break; +case 96: +#line 792 "dcParser.yxx" +{ + if (yyvsp[-3].u.parameter == (DCParameter *)NULL) { + yyval.u.parameter = NULL; + } else { + yyval.u.parameter = new DCArrayParameter(yyvsp[-3].u.parameter, uint_range); + } +} + break; +case 97: +#line 803 "dcParser.yxx" { current_parameter->set_name(yyvsp[0].str); yyval.u.parameter = current_parameter; } break; -case 94: -#line 705 "dcParser.yxx" +case 98: +#line 808 "dcParser.yxx" { if (yyvsp[0].u.s_uint == 0) { yyerror("Invalid divisor."); @@ -1761,14 +1897,14 @@ case 94: } } break; -case 95: -#line 719 "dcParser.yxx" +case 99: +#line 822 "dcParser.yxx" { yyval.u.parameter = new DCArrayParameter(yyvsp[-3].u.parameter, uint_range); } break; -case 96: -#line 726 "dcParser.yxx" +case 100: +#line 829 "dcParser.yxx" { if (yyvsp[0].str.length() != 1) { yyerror("Single character required."); @@ -1778,8 +1914,8 @@ case 96: } } break; -case 98: -#line 739 "dcParser.yxx" +case 102: +#line 842 "dcParser.yxx" { yyval.u.s_uint = (unsigned int)yyvsp[0].u.uint64; if (yyval.u.s_uint != yyvsp[0].u.uint64) { @@ -1788,20 +1924,20 @@ case 98: } } break; -case 101: -#line 758 "dcParser.yxx" +case 105: +#line 861 "dcParser.yxx" { yyval.u.real = (double)yyvsp[0].u.uint64; } break; -case 102: -#line 762 "dcParser.yxx" +case 106: +#line 865 "dcParser.yxx" { yyval.u.real = (double)yyvsp[0].u.int64; } break; -case 104: -#line 770 "dcParser.yxx" +case 108: +#line 873 "dcParser.yxx" { if (yyvsp[0].str.length() != 1) { yyerror("Single character required."); @@ -1811,286 +1947,286 @@ case 104: } } break; -case 106: -#line 784 "dcParser.yxx" +case 110: +#line 887 "dcParser.yxx" { current_packer->pack_int64(yyvsp[0].u.int64); } break; -case 107: -#line 788 "dcParser.yxx" +case 111: +#line 891 "dcParser.yxx" { current_packer->pack_uint64(yyvsp[0].u.uint64); } break; -case 108: -#line 792 "dcParser.yxx" +case 112: +#line 895 "dcParser.yxx" { current_packer->pack_double(yyvsp[0].u.real); } break; -case 109: -#line 796 "dcParser.yxx" +case 113: +#line 899 "dcParser.yxx" { current_packer->pack_string(yyvsp[0].str); } break; -case 110: -#line 800 "dcParser.yxx" +case 114: +#line 903 "dcParser.yxx" { current_packer->pack_literal_value(yyvsp[0].str); } break; -case 111: -#line 804 "dcParser.yxx" -{ - current_packer->push(); -} - break; -case 112: -#line 808 "dcParser.yxx" -{ - current_packer->pop(); -} - break; -case 113: -#line 812 "dcParser.yxx" -{ - current_packer->push(); -} - break; -case 114: -#line 816 "dcParser.yxx" -{ - current_packer->pop(); -} - break; case 115: -#line 820 "dcParser.yxx" +#line 907 "dcParser.yxx" { current_packer->push(); } break; case 116: -#line 824 "dcParser.yxx" +#line 911 "dcParser.yxx" { current_packer->pop(); } break; case 117: -#line 828 "dcParser.yxx" +#line 915 "dcParser.yxx" +{ + current_packer->push(); +} + break; +case 118: +#line 919 "dcParser.yxx" +{ + current_packer->pop(); +} + break; +case 119: +#line 923 "dcParser.yxx" +{ + current_packer->push(); +} + break; +case 120: +#line 927 "dcParser.yxx" +{ + current_packer->pop(); +} + break; +case 121: +#line 931 "dcParser.yxx" { for (unsigned int i = 0; i < yyvsp[0].u.s_uint; i++) { current_packer->pack_int64(yyvsp[-2].u.int64); } } break; -case 118: -#line 834 "dcParser.yxx" +case 122: +#line 937 "dcParser.yxx" { for (unsigned int i = 0; i < yyvsp[0].u.s_uint; i++) { current_packer->pack_uint64(yyvsp[-2].u.uint64); } } break; -case 119: -#line 840 "dcParser.yxx" +case 123: +#line 943 "dcParser.yxx" { for (unsigned int i = 0; i < yyvsp[0].u.s_uint; i++) { current_packer->pack_double(yyvsp[-2].u.real); } } break; -case 120: -#line 846 "dcParser.yxx" +case 124: +#line 949 "dcParser.yxx" { for (unsigned int i = 0; i < yyvsp[0].u.s_uint; i++) { current_packer->pack_literal_value(yyvsp[-2].str); } } break; -case 127: -#line 870 "dcParser.yxx" +case 131: +#line 973 "dcParser.yxx" { yyval.u.subatomic = ST_int8; } break; -case 128: -#line 874 "dcParser.yxx" +case 132: +#line 977 "dcParser.yxx" { yyval.u.subatomic = ST_int16; } break; -case 129: -#line 878 "dcParser.yxx" +case 133: +#line 981 "dcParser.yxx" { yyval.u.subatomic = ST_int32; } break; -case 130: -#line 882 "dcParser.yxx" +case 134: +#line 985 "dcParser.yxx" { yyval.u.subatomic = ST_int64; } break; -case 131: -#line 886 "dcParser.yxx" +case 135: +#line 989 "dcParser.yxx" { yyval.u.subatomic = ST_uint8; } break; -case 132: -#line 890 "dcParser.yxx" +case 136: +#line 993 "dcParser.yxx" { yyval.u.subatomic = ST_uint16; } break; -case 133: -#line 894 "dcParser.yxx" +case 137: +#line 997 "dcParser.yxx" { yyval.u.subatomic = ST_uint32; } break; -case 134: -#line 898 "dcParser.yxx" +case 138: +#line 1001 "dcParser.yxx" { yyval.u.subatomic = ST_uint64; } break; -case 135: -#line 902 "dcParser.yxx" +case 139: +#line 1005 "dcParser.yxx" { yyval.u.subatomic = ST_float64; } break; -case 136: -#line 906 "dcParser.yxx" +case 140: +#line 1009 "dcParser.yxx" { yyval.u.subatomic = ST_string; } break; -case 137: -#line 910 "dcParser.yxx" +case 141: +#line 1013 "dcParser.yxx" { yyval.u.subatomic = ST_blob; } break; -case 138: -#line 914 "dcParser.yxx" +case 142: +#line 1017 "dcParser.yxx" { yyval.u.subatomic = ST_blob32; } break; -case 139: -#line 918 "dcParser.yxx" +case 143: +#line 1021 "dcParser.yxx" { yyval.u.subatomic = ST_int8array; } break; -case 140: -#line 922 "dcParser.yxx" +case 144: +#line 1025 "dcParser.yxx" { yyval.u.subatomic = ST_int16array; } break; -case 141: -#line 926 "dcParser.yxx" +case 145: +#line 1029 "dcParser.yxx" { yyval.u.subatomic = ST_int32array; } break; -case 142: -#line 930 "dcParser.yxx" +case 146: +#line 1033 "dcParser.yxx" { yyval.u.subatomic = ST_uint8array; } break; -case 143: -#line 934 "dcParser.yxx" +case 147: +#line 1037 "dcParser.yxx" { yyval.u.subatomic = ST_uint16array; } break; -case 144: -#line 938 "dcParser.yxx" +case 148: +#line 1041 "dcParser.yxx" { yyval.u.subatomic = ST_uint32array; } break; -case 145: -#line 942 "dcParser.yxx" +case 149: +#line 1045 "dcParser.yxx" { yyval.u.subatomic = ST_uint32uint8array; } break; -case 146: -#line 946 "dcParser.yxx" +case 150: +#line 1049 "dcParser.yxx" { yyval.u.subatomic = ST_char; } break; -case 147: -#line 953 "dcParser.yxx" +case 151: +#line 1056 "dcParser.yxx" { yyval.u.s_int = 0; } break; -case 148: -#line 957 "dcParser.yxx" +case 152: +#line 1060 "dcParser.yxx" { yyval.u.s_int = yyvsp[-1].u.s_int | DCAtomicField::F_required; } break; -case 149: -#line 961 "dcParser.yxx" +case 153: +#line 1064 "dcParser.yxx" { yyval.u.s_int = yyvsp[-1].u.s_int | DCAtomicField::F_broadcast; } break; -case 150: -#line 965 "dcParser.yxx" +case 154: +#line 1068 "dcParser.yxx" { yyval.u.s_int = yyvsp[-1].u.s_int | DCAtomicField::F_p2p; } break; -case 151: -#line 969 "dcParser.yxx" +case 155: +#line 1072 "dcParser.yxx" { yyval.u.s_int = yyvsp[-1].u.s_int | DCAtomicField::F_ram; } break; -case 152: -#line 973 "dcParser.yxx" +case 156: +#line 1076 "dcParser.yxx" { yyval.u.s_int = yyvsp[-1].u.s_int | DCAtomicField::F_db; } break; -case 153: -#line 977 "dcParser.yxx" +case 157: +#line 1080 "dcParser.yxx" { yyval.u.s_int = yyvsp[-1].u.s_int | DCAtomicField::F_clsend; } break; -case 154: -#line 981 "dcParser.yxx" +case 158: +#line 1084 "dcParser.yxx" { yyval.u.s_int = yyvsp[-1].u.s_int | DCAtomicField::F_clrecv; } break; -case 155: -#line 985 "dcParser.yxx" +case 159: +#line 1088 "dcParser.yxx" { yyval.u.s_int = yyvsp[-1].u.s_int | DCAtomicField::F_ownsend; } break; -case 156: -#line 989 "dcParser.yxx" +case 160: +#line 1092 "dcParser.yxx" { yyval.u.s_int = yyvsp[-1].u.s_int | DCAtomicField::F_airecv; } break; -case 157: -#line 996 "dcParser.yxx" +case 161: +#line 1099 "dcParser.yxx" { if (yyvsp[0].u.s_int != 0) { yyerror("Server flags are not allowed here."); @@ -2098,20 +2234,20 @@ case 157: yyval.u.s_int = yyvsp[0].u.s_int; } break; -case 158: -#line 1006 "dcParser.yxx" +case 162: +#line 1109 "dcParser.yxx" { current_molecular = new DCMolecularField(yyvsp[-1].str); } break; -case 159: -#line 1010 "dcParser.yxx" +case 163: +#line 1113 "dcParser.yxx" { yyval.u.field = current_molecular; } break; -case 160: -#line 1017 "dcParser.yxx" +case 164: +#line 1120 "dcParser.yxx" { DCField *field = current_class->get_field_by_name(yyvsp[0].str); yyval.u.atomic = (DCAtomicField *)NULL; @@ -2125,16 +2261,16 @@ case 160: } } break; -case 161: -#line 1033 "dcParser.yxx" +case 165: +#line 1136 "dcParser.yxx" { if (yyvsp[0].u.atomic != (DCAtomicField *)NULL) { current_molecular->add_atomic(yyvsp[0].u.atomic); } } break; -case 162: -#line 1039 "dcParser.yxx" +case 166: +#line 1142 "dcParser.yxx" { if (yyvsp[0].u.atomic != (DCAtomicField *)NULL) { current_molecular->add_atomic(yyvsp[0].u.atomic); @@ -2146,46 +2282,48 @@ case 162: } } break; -case 163: -#line 1053 "dcParser.yxx" +case 167: +#line 1156 "dcParser.yxx" { yyval.str = ""; } break; -case 165: -#line 1061 "dcParser.yxx" +case 169: +#line 1164 "dcParser.yxx" { yyval.u.dswitch = current_switch; current_switch = new DCSwitch(yyvsp[-4].str, yyvsp[-2].u.parameter); } break; -case 166: -#line 1066 "dcParser.yxx" +case 170: +#line 1169 "dcParser.yxx" { yyval.u.dswitch = current_switch; current_switch = (DCSwitch *)yyvsp[-2].u.parameter; } break; -case 170: -#line 1078 "dcParser.yxx" +case 174: +#line 1181 "dcParser.yxx" { if (current_switch->get_num_cases() == 0) { yyerror("case declaration required before first element"); - } else if (!current_switch->add_field(yyvsp[0].u.field)) { - yyerror("Duplicate field name: " + yyvsp[0].u.field->get_name()); + } else if (yyvsp[0].u.field != (DCField *)NULL) { + if (!current_switch->add_field(yyvsp[0].u.field)) { + yyerror("Duplicate field name: " + yyvsp[0].u.field->get_name()); + } } } break; -case 171: -#line 1089 "dcParser.yxx" +case 175: +#line 1194 "dcParser.yxx" { current_packer = &default_packer; current_packer->clear_data(); current_packer->begin_pack(current_switch->get_key_parameter()); } break; -case 172: -#line 1095 "dcParser.yxx" +case 176: +#line 1200 "dcParser.yxx" { if (!current_packer->end_pack()) { yyerror("Invalid value for switch parameter"); @@ -2194,14 +2332,14 @@ case 172: } } break; -case 173: -#line 1106 "dcParser.yxx" +case 177: +#line 1211 "dcParser.yxx" { yyval.u.field = yyvsp[-1].u.parameter; } break; -case 174: -#line 1110 "dcParser.yxx" +case 178: +#line 1215 "dcParser.yxx" { yyval.u.field = yyvsp[0].u.parameter; } @@ -2439,4 +2577,4 @@ yyreturn: #endif return yyresult; } -#line 1118 "dcParser.yxx" +#line 1223 "dcParser.yxx" diff --git a/direct/src/dcparser/dcParser.h.prebuilt b/direct/src/dcparser/dcParser.h.prebuilt index 929bca6b35..ba4f214af3 100644 --- a/direct/src/dcparser/dcParser.h.prebuilt +++ b/direct/src/dcparser/dcParser.h.prebuilt @@ -45,6 +45,7 @@ # define KW_AIRECV 298 # define START_DC 299 # define START_PARAMETER_VALUE 300 +# define START_PARAMETER_DESCRIPTION 301 extern YYSTYPE dcyylval; diff --git a/direct/src/dcparser/dcParser.yxx b/direct/src/dcparser/dcParser.yxx index 1833f5094f..29e8190bf8 100644 --- a/direct/src/dcparser/dcParser.yxx +++ b/direct/src/dcparser/dcParser.yxx @@ -37,6 +37,7 @@ static DCPacker default_packer; static DCPacker *current_packer; static DCDoubleRange double_range; static DCUnsignedIntRange uint_range; +static DCField *parameter_description = (DCField *)NULL; //////////////////////////////////////////////////////////////////// // Defining the interface to the parser. @@ -57,6 +58,20 @@ dc_init_parser_parameter_value(istream &in, const string &filename, dc_start_parameter_value(); } +void +dc_init_parser_parameter_description(istream &in, const string &filename, + DCFile *file) { + dc_file = file; + dc_init_lexer(in, filename); + parameter_description = NULL; + dc_start_parameter_description(); +} + +DCField * +dc_get_parameter_description() { + return parameter_description; +} + void dc_cleanup_parser() { dc_file = (DCFile *)NULL; @@ -113,6 +128,7 @@ dc_cleanup_parser() { of the input stream. */ %token START_DC %token START_PARAMETER_VALUE +%token START_PARAMETER_DESCRIPTION %type atomic_name %type server_flags @@ -124,6 +140,7 @@ dc_cleanup_parser() { %type struct_name %type struct %type struct_field +%type parameter_description %type switch %type switch_field %type atomic_field @@ -153,6 +170,10 @@ dc_cleanup_parser() { grammar: START_DC dc | START_PARAMETER_VALUE parameter_value + | START_PARAMETER_DESCRIPTION parameter_description +{ + parameter_description = $2; +} ; dc: @@ -229,14 +250,16 @@ import_symbol_list: typedef_decl: KW_TYPEDEF parameter_with_default { - DCTypedef *dtypedef = new DCTypedef($2); - - if (!dc_file->add_typedef(dtypedef)) { - DCTypedef *old_typedef = dc_file->get_typedef_by_name(dtypedef->get_name()); - if (old_typedef->is_bogus_typedef()) { - yyerror("typedef defined after its first reference: " + dtypedef->get_name()); - } else { - yyerror("Duplicate typedef name: " + dtypedef->get_name()); + if ($2 != (DCParameter *)NULL) { + DCTypedef *dtypedef = new DCTypedef($2); + + if (!dc_file->add_typedef(dtypedef)) { + DCTypedef *old_typedef = dc_file->get_typedef_by_name(dtypedef->get_name()); + if (old_typedef->is_bogus_typedef()) { + yyerror("typedef defined after its first reference: " + dtypedef->get_name()); + } else { + yyerror("Duplicate typedef name: " + dtypedef->get_name()); + } } } } @@ -263,17 +286,23 @@ dclass: dclass_name: IDENTIFIER { - DCClass *dclass = dc_file->get_class_by_name($1); - if (dclass == (DCClass *)NULL) { - // Create a bogus class as a forward reference. - dclass = new DCClass($1, false, true); - dc_file->add_class(dclass); - } - if (dclass->is_struct()) { - yyerror("struct name not allowed"); - } + if (dc_file == (DCFile *)NULL) { + yyerror("No DCFile available, so no class names are predefined."); + $$ = NULL; + + } else { + DCClass *dclass = dc_file->get_class_by_name($1); + if (dclass == (DCClass *)NULL) { + // Create a bogus class as a forward reference. + dclass = new DCClass($1, false, true); + dc_file->add_class(dclass); + } + if (dclass->is_struct()) { + yyerror("struct name not allowed"); + } - $$ = dclass; + $$ = dclass; + } } ; @@ -302,7 +331,9 @@ dclass_fields: | dclass_fields ';' | dclass_fields dclass_field { - if (!current_class->add_field($2)) { + if ($2 == (DCField *)NULL) { + // Pass this error up. + } else if (!current_class->add_field($2)) { yyerror("Duplicate field name: " + $2->get_name()); } else if ($2->get_number() < 0) { yyerror("A non-network field cannot be stored on a dclass"); @@ -313,20 +344,29 @@ dclass_fields: dclass_field: atomic_field server_flags { + if ($1 != (DCField *)NULL) { + if ($1->get_name().empty()) { + yyerror("Field name required."); + } + $1->set_flags($2); + } $$ = $1; - $$->set_flags($2); } | molecular_field no_server_flags | unnamed_parameter_with_default server_flags ';' { yyerror("Unnamed parameters are not allowed on a dclass"); + if ($1 != (DCField *)NULL) { + $1->set_flags($2); + } $$ = $1; - $$->set_flags($2); } | named_parameter_with_default server_flags { + if ($1 != (DCField *)NULL) { + $1->set_flags($2); + } $$ = $1; - $$->set_flags($2); } ; @@ -346,17 +386,23 @@ struct: struct_name: IDENTIFIER { - DCClass *dstruct = dc_file->get_class_by_name($1); - if (dstruct == (DCClass *)NULL) { - // Create a bogus class as a forward reference. - dstruct = new DCClass($1, false, true); - dc_file->add_class(dstruct); - } - if (!dstruct->is_struct()) { - yyerror("struct name required"); - } + if (dc_file == (DCFile *)NULL) { + yyerror("No DCFile available, so no struct names are predefined."); + $$ = NULL; + + } else { + DCClass *dstruct = dc_file->get_class_by_name($1); + if (dstruct == (DCClass *)NULL) { + // Create a bogus class as a forward reference. + dstruct = new DCClass($1, false, true); + dc_file->add_class(dstruct); + } + if (!dstruct->is_struct()) { + yyerror("struct name required"); + } - $$ = dstruct; + $$ = dstruct; + } } ; @@ -385,7 +431,9 @@ struct_fields: | struct_fields ';' | struct_fields struct_field { - if (!current_class->add_field($2)) { + if ($2 == (DCField *)NULL) { + // Pass this error up. + } else if (!current_class->add_field($2)) { yyerror("Duplicate field name: " + $2->get_name()); } } @@ -393,6 +441,12 @@ struct_fields: struct_field: atomic_field no_server_flags +{ + if ($1->get_name().empty()) { + yyerror("Field name required."); + } + $$ = $1; +} | molecular_field no_server_flags | unnamed_parameter_with_default no_server_flags ';' { @@ -405,7 +459,7 @@ struct_field: ; atomic_field: - IDENTIFIER '(' + optional_name '(' { $$ = current_atomic; current_atomic = new DCAtomicField($1); @@ -430,7 +484,9 @@ nonempty_parameter_list: atomic_element: parameter_with_default { - current_atomic->add_element($1); + if ($1 != (DCParameter *)NULL) { + current_atomic->add_element($1); + } } ; @@ -455,11 +511,16 @@ named_parameter_with_default: { current_packer = &default_packer; current_packer->clear_data(); - current_packer->begin_pack($1); + if ($1 != (DCField *)NULL) { + current_packer->begin_pack($1); + } } parameter_value { - bool is_valid = $1->is_valid(); + bool is_valid = false; + if ($1 != (DCField *)NULL) { + is_valid = $1->is_valid(); + } if (current_packer->end_pack()) { $1->set_default_value(current_packer->get_string()); @@ -480,11 +541,16 @@ unnamed_parameter_with_default: { current_packer = &default_packer; current_packer->clear_data(); - current_packer->begin_pack($1); + if ($1 != (DCField *)NULL) { + current_packer->begin_pack($1); + } } parameter_value { - bool is_valid = $1->is_valid(); + bool is_valid = false; + if ($1 != (DCField *)NULL) { + is_valid = $1->is_valid(); + } if (current_packer->end_pack()) { $1->set_default_value(current_packer->get_string()); @@ -509,6 +575,21 @@ parameter_with_default: | unnamed_parameter_with_default ; +parameter_description: + atomic_field no_server_flags +{ + $$ = $1; +} + | unnamed_parameter_with_default no_server_flags +{ + $$ = $1; +} + | named_parameter_with_default no_server_flags +{ + $$ = $1; +} + ; + type_name: type_token { @@ -563,44 +644,62 @@ type_name: } | IDENTIFIER { - DCTypedef *dtypedef = dc_file->get_typedef_by_name($1); - if (dtypedef == (DCTypedef *)NULL) { - // Maybe it's a class name. - DCClass *dclass = dc_file->get_class_by_name($1); - if (dclass != (DCClass *)NULL) { - if (!dclass->is_struct()) { - yyerror("cannot embed a dclass object within a message; use a struct"); - } - // Create an implicit typedef for this. - dtypedef = new DCTypedef(new DCClassParameter(dclass), true); - } else { - // Maybe it's a switch name. - DCSwitch *dswitch = dc_file->get_switch_by_name($1); - if (dswitch != (DCSwitch *)NULL) { - // This also gets an implicit typedef. - dtypedef = new DCTypedef(new DCSwitchParameter(dswitch), true); + if (dc_file == (DCFile *)NULL) { + yyerror("Invalid type."); + $$ = NULL; + + } else { + DCTypedef *dtypedef = dc_file->get_typedef_by_name($1); + if (dtypedef == (DCTypedef *)NULL) { + // Maybe it's a class name. + DCClass *dclass = dc_file->get_class_by_name($1); + if (dclass != (DCClass *)NULL) { + if (!dclass->is_struct()) { + yyerror("cannot embed a dclass object within a message; use a struct"); + } + // Create an implicit typedef for this. + dtypedef = new DCTypedef(new DCClassParameter(dclass), true); } else { - // It's an undefined typedef. Create a bogus forward reference. - dtypedef = new DCTypedef($1); + // Maybe it's a switch name. + DCSwitch *dswitch = dc_file->get_switch_by_name($1); + if (dswitch != (DCSwitch *)NULL) { + // This also gets an implicit typedef. + dtypedef = new DCTypedef(new DCSwitchParameter(dswitch), true); + } else { + // It's an undefined typedef. Create a bogus forward reference. + dtypedef = new DCTypedef($1); + } } + + dc_file->add_typedef(dtypedef); } - - dc_file->add_typedef(dtypedef); + + $$ = dtypedef->make_new_parameter(); } - - $$ = dtypedef->make_new_parameter(); } | struct { // This is an inline struct definition. - dc_file->add_thing_to_delete($1); - $$ = new DCClassParameter($1); + if ($1 == (DCClass *)NULL) { + $$ = NULL; + } else { + if (dc_file != (DCFile *)NULL) { + dc_file->add_thing_to_delete($1); + } + $$ = new DCClassParameter($1); + } } | switch { // This is an inline switch definition. - dc_file->add_thing_to_delete($1); - $$ = new DCSwitchParameter($1); + if ($1 == (DCSwitch *)NULL) { + $$ = NULL; + } else { + if (dc_file != (DCFile *)NULL) { + dc_file->add_thing_to_delete($1); + } + $$ = new DCSwitchParameter($1); + } } ; @@ -691,7 +790,11 @@ type_definition: type_name | type_definition '[' uint_range ']' { - $$ = new DCArrayParameter($1, uint_range); + if ($1 == (DCParameter *)NULL) { + $$ = NULL; + } else { + $$ = new DCArrayParameter($1, uint_range); + } } ; @@ -1078,8 +1181,10 @@ switch_fields: { if (current_switch->get_num_cases() == 0) { yyerror("case declaration required before first element"); - } else if (!current_switch->add_field($2)) { - yyerror("Duplicate field name: " + $2->get_name()); + } else if ($2 != (DCField *)NULL) { + if (!current_switch->add_field($2)) { + yyerror("Duplicate field name: " + $2->get_name()); + } } } ; diff --git a/direct/src/dcparser/dcParserDefs.h b/direct/src/dcparser/dcParserDefs.h index 0ebf5b4e88..bc29789d56 100644 --- a/direct/src/dcparser/dcParserDefs.h +++ b/direct/src/dcparser/dcParserDefs.h @@ -33,6 +33,9 @@ class DCPacker; void dc_init_parser(istream &in, const string &filename, DCFile &file); void dc_init_parser_parameter_value(istream &in, const string &filename, DCPacker &packer); +void dc_init_parser_parameter_description(istream &in, const string &filename, + DCFile *file); +DCField *dc_get_parameter_description(); void dc_cleanup_parser(); int dcyyparse(); diff --git a/direct/src/dcparser/dcSimpleParameter.cxx b/direct/src/dcparser/dcSimpleParameter.cxx index 0185d7722d..527e05a089 100644 --- a/direct/src/dcparser/dcSimpleParameter.cxx +++ b/direct/src/dcparser/dcSimpleParameter.cxx @@ -19,11 +19,14 @@ #include "dcSimpleParameter.h" #include "dcPackData.h" #include "dcTypedef.h" +#include "dcArrayParameter.h" +#include "dcClassParameter.h" +#include "dcClass.h" #include "hashGenerator.h" #include DCSimpleParameter::NestedFieldMap DCSimpleParameter::_nested_field_map; -DCSimpleParameter::Uint32Uint8Type *DCSimpleParameter::_uint32uint8_type = NULL; +DCClassParameter *DCSimpleParameter::_uint32uint8_type = NULL; //////////////////////////////////////////////////////////////////// // Function: DCSimpleParameter::Constructor @@ -2150,6 +2153,87 @@ generate_hash(HashGenerator &hashgen) const { _double_range.generate_hash(hashgen); } +//////////////////////////////////////////////////////////////////// +// Function: DCSimpleParameter::do_check_match +// Access: Protected, Virtual +// Description: Returns true if the other interface is bitwise the +// same as this one--that is, a uint32 only matches a +// uint32, etc. Names of components, and range limits, +// are not compared. +//////////////////////////////////////////////////////////////////// +bool DCSimpleParameter:: +do_check_match(const DCPackerInterface *other) const { + return other->do_check_match_simple_parameter(this); +} + +//////////////////////////////////////////////////////////////////// +// Function: DCSimpleParameter::do_check_match_simple_parameter +// Access: Protected, Virtual +// Description: Returns true if this field matches the indicated +// simple parameter, false otherwise. +//////////////////////////////////////////////////////////////////// +bool DCSimpleParameter:: +do_check_match_simple_parameter(const DCSimpleParameter *other) const { + if (_divisor != other->_divisor) { + return false; + } + + if (_type == other->_type) { + return true; + } + + // Check for certain types that are considered equivalent to each + // other. + switch (_type) { + case ST_uint8: + case ST_char: + switch (other->_type) { + case ST_uint8: + case ST_char: + return true; + + default: + return false; + } + + case ST_string: + case ST_blob: + case ST_uint8array: + switch (other->_type) { + case ST_string: + case ST_blob: + case ST_uint8array: + return true; + + default: + return false; + } + + default: + return false; + } +} + +//////////////////////////////////////////////////////////////////// +// Function: DCSimpleParameter::do_check_match_array_parameter +// Access: Protected, Virtual +// Description: Returns true if this field matches the indicated +// array parameter, false otherwise. +//////////////////////////////////////////////////////////////////// +bool DCSimpleParameter:: +do_check_match_array_parameter(const DCArrayParameter *other) const { + if (other->get_array_size() != -1) { + // We cannot match a fixed-size array. + return false; + } + if (_nested_field == NULL) { + // Only an array-style simple parameter can match a DCArrayParameter. + return false; + } + + return _nested_field->check_match(other->get_element_type()); +} + //////////////////////////////////////////////////////////////////// // Function: DCSimpleParameter::create_nested_field // Access: Private, Static @@ -2180,43 +2264,10 @@ create_nested_field(DCSubatomicType type, unsigned int divisor) { DCPackerInterface *DCSimpleParameter:: create_uint32uint8_type() { if (_uint32uint8_type == NULL) { - _uint32uint8_type = new Uint32Uint8Type; + DCClass *dclass = new DCClass("", true, false); + dclass->add_field(new DCSimpleParameter(ST_uint32)); + dclass->add_field(new DCSimpleParameter(ST_uint8)); + _uint32uint8_type = new DCClassParameter(dclass); } return _uint32uint8_type; } - -//////////////////////////////////////////////////////////////////// -// Function: DCSimpleParameter::Uint32Uint8Type::Constructor -// Access: Public -// Description: This special packer interface is provided just to -// implement uint32uint8array, which is a special kind -// of array that consists of nested pairs of (uint32, -// uint8) values. -//////////////////////////////////////////////////////////////////// -DCSimpleParameter::Uint32Uint8Type:: -Uint32Uint8Type() { - _uint32_type = new DCSimpleParameter(ST_uint32); - _uint8_type = new DCSimpleParameter(ST_uint8); - _has_nested_fields = true; - _num_nested_fields = 2; - _pack_type = PT_class; -} - -//////////////////////////////////////////////////////////////////// -// Function: DCSimpleParameter::Uint32Uint8Type::get_nested_field -// Access: Public, Virtual -// Description: -//////////////////////////////////////////////////////////////////// -DCPackerInterface *DCSimpleParameter::Uint32Uint8Type:: -get_nested_field(int n) const { - switch (n) { - case 0: - return _uint32_type; - - case 1: - return _uint8_type; - - default: - return NULL; - } -} diff --git a/direct/src/dcparser/dcSimpleParameter.h b/direct/src/dcparser/dcSimpleParameter.h index e16c01758b..f46d1fbc4a 100644 --- a/direct/src/dcparser/dcSimpleParameter.h +++ b/direct/src/dcparser/dcSimpleParameter.h @@ -89,6 +89,11 @@ public: const string &name, const string &postname) const; virtual void generate_hash(HashGenerator &hashgen) const; +protected: + virtual bool do_check_match(const DCPackerInterface *other) const; + virtual bool do_check_match_simple_parameter(const DCSimpleParameter *other) const; + virtual bool do_check_match_array_parameter(const DCArrayParameter *other) const; + private: static DCSimpleParameter *create_nested_field(DCSubatomicType type, unsigned int divisor); @@ -109,22 +114,13 @@ private: typedef pmap NestedFieldMap; static NestedFieldMap _nested_field_map; - class Uint32Uint8Type : public DCPackerInterface { - public: - Uint32Uint8Type(); - virtual DCPackerInterface *get_nested_field(int n) const; - - DCSimpleParameter *_uint32_type; - DCSimpleParameter *_uint8_type; - }; - DCIntRange _int_range; DCUnsignedIntRange _uint_range; DCInt64Range _int64_range; DCUnsignedInt64Range _uint64_range; DCDoubleRange _double_range; - static Uint32Uint8Type *_uint32uint8_type; + static DCClassParameter *_uint32uint8_type; }; #endif diff --git a/direct/src/dcparser/dcSwitch.cxx b/direct/src/dcparser/dcSwitch.cxx index 77170d07c7..af7de7a46f 100644 --- a/direct/src/dcparser/dcSwitch.cxx +++ b/direct/src/dcparser/dcSwitch.cxx @@ -410,6 +410,45 @@ pack_default_value(DCPackData &pack_data, bool &pack_error) const { return true; } +//////////////////////////////////////////////////////////////////// +// Function: DCSwitch::do_check_match_switch +// Access: Public +// Description: Returns true if this switch matches the indicated +// switch, false otherwise. This is only intended to be +// called internally from +// DCSwitchParameter::do_check_match_switch_parameter(). +//////////////////////////////////////////////////////////////////// +bool DCSwitch:: +do_check_match_switch(const DCSwitch *other) const { + if (!_key_parameter->check_match(other->_key_parameter)) { + return false; + } + + if (_cases.size() != other->_cases.size()) { + return false; + } + + Cases::const_iterator ci; + for (ci = _cases.begin(); ci != _cases.end(); ++ci) { + const SwitchCase *c1 = (*ci); + CasesByValue::const_iterator vi; + vi = other->_cases_by_value.find(c1->_value); + if (vi == other->_cases_by_value.end()) { + // No matching value. + return false; + } + int c2_index = (*vi).second; + nassertr(c2_index >= 0 && c2_index < (int)other->_cases.size(), false); + const SwitchCase *c2 = other->_cases[c2_index]; + + if (!c1->do_check_match_switch_case(c2)) { + return false; + } + } + + return true; +} + //////////////////////////////////////////////////////////////////// // Function: DCSwitch::SwitchCase::Constructor // Access: Public @@ -477,11 +516,13 @@ get_nested_field(int n) const { //////////////////////////////////////////////////////////////////// bool DCSwitch::SwitchCase:: add_field(DCField *field) { - bool inserted = _fields_by_name.insert - (FieldsByName::value_type(field->get_name(), field)).second; - - if (!inserted) { - return false; + if (!field->get_name().empty()) { + bool inserted = _fields_by_name.insert + (FieldsByName::value_type(field->get_name(), field)).second; + + if (!inserted) { + return false; + } } _fields.push_back(field); @@ -504,3 +545,40 @@ add_field(DCField *field) { } return true; } + +//////////////////////////////////////////////////////////////////// +// Function: DCSwitch::SwitchCase::do_check_match_switch_case +// Access: Public +// Description: Returns true if this case matches the indicated +// case, false otherwise. This is only intended to be +// called internally from +// DCSwitch::do_check_match_switch(). +//////////////////////////////////////////////////////////////////// +bool DCSwitch::SwitchCase:: +do_check_match_switch_case(const DCSwitch::SwitchCase *other) const { + if (_fields.size() != other->_fields.size()) { + return false; + } + for (size_t i = 0; i < _fields.size(); i++) { + if (!_fields[i]->check_match(other->_fields[i])) { + return false; + } + } + + return true; +} + +//////////////////////////////////////////////////////////////////// +// Function: DCSwitch::SwitchCase::do_check_match +// Access: Protected, Virtual +// Description: Returns true if the other interface is bitwise the +// same as this one--that is, a uint32 only matches a +// uint32, etc. Names of components, and range limits, +// are not compared. +//////////////////////////////////////////////////////////////////// +bool DCSwitch::SwitchCase:: +do_check_match(const DCPackerInterface *) const { + // This should never be called on a SwitchCase. + nassertr(false, false); + return false; +} diff --git a/direct/src/dcparser/dcSwitch.h b/direct/src/dcparser/dcSwitch.h index 9f18f942a6..b20f1cd063 100644 --- a/direct/src/dcparser/dcSwitch.h +++ b/direct/src/dcparser/dcSwitch.h @@ -70,6 +70,8 @@ public: virtual void generate_hash(HashGenerator &hashgen) const; virtual bool pack_default_value(DCPackData &pack_data, bool &pack_error) const; + bool do_check_match_switch(const DCSwitch *other) const; + public: typedef pvector Fields; typedef pmap FieldsByName; @@ -81,7 +83,12 @@ public: virtual DCPackerInterface *get_nested_field(int n) const; bool add_field(DCField *field); + bool do_check_match_switch_case(const SwitchCase *other) const; + protected: + virtual bool do_check_match(const DCPackerInterface *other) const; + + public: string _value; Fields _fields; FieldsByName _fields_by_name; diff --git a/direct/src/dcparser/dcSwitchParameter.cxx b/direct/src/dcparser/dcSwitchParameter.cxx index afd861be22..9350d431d7 100755 --- a/direct/src/dcparser/dcSwitchParameter.cxx +++ b/direct/src/dcparser/dcSwitchParameter.cxx @@ -224,3 +224,27 @@ pack_default_value(DCPackData &pack_data, bool &pack_error) const { return _dswitch->pack_default_value(pack_data, pack_error); } + +//////////////////////////////////////////////////////////////////// +// Function: DCSwitchParameter::do_check_match +// Access: Protected, Virtual +// Description: Returns true if the other interface is bitwise the +// same as this one--that is, a uint32 only matches a +// uint32, etc. Names of components, and range limits, +// are not compared. +//////////////////////////////////////////////////////////////////// +bool DCSwitchParameter:: +do_check_match(const DCPackerInterface *other) const { + return other->do_check_match_switch_parameter(this); +} + +//////////////////////////////////////////////////////////////////// +// Function: DCSwitchParameter::do_check_match_switch_parameter +// Access: Protected, Virtual +// Description: Returns true if this field matches the indicated +// switch parameter, false otherwise. +//////////////////////////////////////////////////////////////////// +bool DCSwitchParameter:: +do_check_match_switch_parameter(const DCSwitchParameter *other) const { + return _dswitch->do_check_match_switch(other->_dswitch); +} diff --git a/direct/src/dcparser/dcSwitchParameter.h b/direct/src/dcparser/dcSwitchParameter.h index 9ffd722185..8cb884ad6c 100755 --- a/direct/src/dcparser/dcSwitchParameter.h +++ b/direct/src/dcparser/dcSwitchParameter.h @@ -56,6 +56,10 @@ public: virtual void generate_hash(HashGenerator &hashgen) const; virtual bool pack_default_value(DCPackData &pack_data, bool &pack_error) const; +protected: + virtual bool do_check_match(const DCPackerInterface *other) const; + virtual bool do_check_match_switch_parameter(const DCSwitchParameter *other) const; + private: const DCSwitch *_dswitch; };