From b0b2fe350c5c7d4f59ffa9bc760cd6127c5354b6 Mon Sep 17 00:00:00 2001 From: David Rose Date: Tue, 22 Jun 2004 05:28:59 +0000 Subject: [PATCH] begin ranges --- direct/src/dcparser/Sources.pp | 1 + direct/src/dcparser/dcNumericRange.I | 222 +++++++ direct/src/dcparser/dcNumericRange.h | 75 +++ direct/src/dcparser/dcParser.cxx.prebuilt | 688 +++++++++++++--------- direct/src/dcparser/dcParser.yxx | 93 +++ direct/src/dcparser/dcSimpleParameter.cxx | 237 +++++++- direct/src/dcparser/dcSimpleParameter.h | 8 + direct/src/dcparser/dcbase.h | 1 + 8 files changed, 1016 insertions(+), 309 deletions(-) create mode 100644 direct/src/dcparser/dcNumericRange.I create mode 100644 direct/src/dcparser/dcNumericRange.h diff --git a/direct/src/dcparser/Sources.pp b/direct/src/dcparser/Sources.pp index 3e1fedce34..bb27355ace 100644 --- a/direct/src/dcparser/Sources.pp +++ b/direct/src/dcparser/Sources.pp @@ -25,6 +25,7 @@ dcPackerCatalog.h dcPackerCatalog.I \ dcPackerInterface.h dcPackerInterface.I \ dcParameter.h dcClassParameter.h dcArrayParameter.h dcSimpleParameter.h \ + dcNumericRange.h dcNumericRange.I \ dcTypedef.h \ dcbase.h dcindent.h hashGenerator.h \ primeNumberGenerator.h diff --git a/direct/src/dcparser/dcNumericRange.I b/direct/src/dcparser/dcNumericRange.I new file mode 100644 index 0000000000..481724e5b4 --- /dev/null +++ b/direct/src/dcparser/dcNumericRange.I @@ -0,0 +1,222 @@ +// Filename: dcNumericRange.I +// Created by: drose (21Jun04) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + + +//////////////////////////////////////////////////////////////////// +// Function: DCNumericRange::Constructor +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +template +INLINE DCNumericRange:: +DCNumericRange() { +} + +//////////////////////////////////////////////////////////////////// +// Function: DCNumericRange::Copy Constructor +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +template +INLINE DCNumericRange:: +DCNumericRange(const DCNumericRange ©) : + _ranges(copy._ranges) +{ +} + +//////////////////////////////////////////////////////////////////// +// Function: DCNumericRange::Copy Assignment Operator +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +template +INLINE void DCNumericRange:: +operator = (const DCNumericRange ©) { + _ranges = copy._ranges; +} + +//////////////////////////////////////////////////////////////////// +// Function: DCNumericRange::is_in_range +// Access: Public +// Description: Returns true if the indicated number is within the +// specified range, false otherwise. +//////////////////////////////////////////////////////////////////// +template +bool DCNumericRange:: +is_in_range(Number num) const { + if (_ranges.empty()) { + return true; + } + + TYPENAME Ranges::const_iterator ri; + for (ri = _ranges.begin(); ri != _ranges.end(); ++ri) { + if (num >= (*ri)._min && num <= (*ri)._max) { + return true; + } + } + + return false; +} + +//////////////////////////////////////////////////////////////////// +// Function: DCNumericRange::validate +// Access: Public +// Description: Convenience function to validate the indicated +// number. If the number is within the specified range, +// does nothing; otherwise, if it is outside the range, +// sets validation_error to true. +//////////////////////////////////////////////////////////////////// +template +INLINE void DCNumericRange:: +validate(Number num, bool &validation_error) const { + if (!is_in_range(num)) { + validation_error = true; + } +} + +//////////////////////////////////////////////////////////////////// +// Function: DCNumericRange::output +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +template +void DCNumericRange:: +output(ostream &out, Number divisor) const { + if (!_ranges.empty()) { + TYPENAME Ranges::const_iterator ri; + ri = _ranges.begin(); + output_minmax(out, divisor, *ri); + ++ri; + while (ri != _ranges.end()) { + out << ", "; + output_minmax(out, divisor, *ri); + ++ri; + } + } +} + +//////////////////////////////////////////////////////////////////// +// Function: DCNumericRange::clear +// Access: Public +// Description: +//////////////////////////////////////////////////////////////////// +template +INLINE void DCNumericRange:: +clear() { + _ranges.clear(); +} + +//////////////////////////////////////////////////////////////////// +// Function: DCNumericRange::add_range +// Access: Public +// Description: Adds a new minmax to the list of ranges. This is +// normally called only during dc file parsing. Returns +// true if successful, or false if the new minmax +// overlaps an existing minmax. +//////////////////////////////////////////////////////////////////// +template +bool DCNumericRange:: +add_range(Number min, Number max) { + // Check for an overlap. This is probably indicative of a typo and + // should be reported. + if (max < min) { + return false; + } + + TYPENAME Ranges::const_iterator ri; + for (ri = _ranges.begin(); ri != _ranges.end(); ++ri) { + if ((min >= (*ri)._min && min <= (*ri)._max) || + (max >= (*ri)._min && max <= (*ri)._max) || + (min < (*ri)._min && max > (*ri)._max)) { + return false; + } + } + + MinMax minmax; + minmax._min = min; + minmax._max = max; + _ranges.push_back(minmax); + + return true; +} + +//////////////////////////////////////////////////////////////////// +// Function: DCNumericRange::is_empty +// Access: Private +// Description: Returns true if the range contains no elements (and +// thus allows all numbers), false if it contains at +// least one. +//////////////////////////////////////////////////////////////////// +template +INLINE bool DCNumericRange:: +is_empty() const { + return _ranges.empty(); +} + +//////////////////////////////////////////////////////////////////// +// Function: DCNumericRange::get_num_ranges +// Access: Private +// Description: Returns the number of minmax components in the range +// description. +//////////////////////////////////////////////////////////////////// +template +INLINE int DCNumericRange:: +get_num_ranges() const { + return _ranges.size(); +} + +//////////////////////////////////////////////////////////////////// +// Function: DCNumericRange::get_min +// Access: Private +// Description: Returns the minimum value defined by the nth component. +//////////////////////////////////////////////////////////////////// +template +INLINE TYPENAME DCNumericRange::Number DCNumericRange:: +get_min(int n) const { + nassertr(n >= 0 && n < (int)_ranges.size(), 0); + return _ranges[n]._min; +} + +//////////////////////////////////////////////////////////////////// +// Function: DCNumericRange::get_max +// Access: Private +// Description: Returns the maximum value defined by the nth component. +//////////////////////////////////////////////////////////////////// +template +INLINE TYPENAME DCNumericRange::Number DCNumericRange:: +get_max(int n) const { + nassertr(n >= 0 && n < (int)_ranges.size(), 0); + return _ranges[n]._max; +} + +//////////////////////////////////////////////////////////////////// +// Function: DCNumericRange::output_minmax +// Access: Private +// Description: Outputs a single element of the range description. +//////////////////////////////////////////////////////////////////// +template +INLINE void DCNumericRange:: +output_minmax(ostream &out, Number divisor, const MinMax &range) const { + if (range._min == range._max) { + out << (double)range._min / (double)divisor; + } else { + out << (double)range._min / (double)divisor + << "-" + << (double)range._max / (double)divisor; + } +} diff --git a/direct/src/dcparser/dcNumericRange.h b/direct/src/dcparser/dcNumericRange.h new file mode 100644 index 0000000000..0b4c446805 --- /dev/null +++ b/direct/src/dcparser/dcNumericRange.h @@ -0,0 +1,75 @@ +// Filename: dcNumericRange.h +// Created by: drose (21Jun04) +// +//////////////////////////////////////////////////////////////////// +// +// PANDA 3D SOFTWARE +// Copyright (c) 2001 - 2004, Disney Enterprises, Inc. All rights reserved +// +// All use of this software is subject to the terms of the Panda 3d +// Software license. You should have received a copy of this license +// along with this source code; you will also find a current copy of +// the license at http://etc.cmu.edu/panda3d/docs/license/ . +// +// To contact the maintainers of this program write to +// panda3d-general@lists.sourceforge.net . +// +//////////////////////////////////////////////////////////////////// + +#ifndef DCNUMERICRANGE_H +#define DCNUMERICRANGE_H + +#include "dcbase.h" + +//////////////////////////////////////////////////////////////////// +// Class : DCNumericRange +// Description : Represents a range of legal integer or floating-point +// values. This is used to constrain simple numeric +// types, as well as array sizes. +//////////////////////////////////////////////////////////////////// +template +class DCNumericRange { +public: + typedef NUM Number; + + INLINE DCNumericRange(); + INLINE DCNumericRange(const DCNumericRange ©); + INLINE void operator = (const DCNumericRange ©); + + bool is_in_range(Number num) const; + INLINE void validate(Number num, bool &validation_error) const; + + void output(ostream &out, Number divisor = 1) const; + +public: + INLINE void clear(); + bool add_range(Number min, Number max); + + INLINE bool is_empty() const; + INLINE int get_num_ranges() const; + INLINE Number get_min(int n) const; + INLINE Number get_max(int n) const; + +private: + class MinMax { + public: + INLINE bool operator < (const MinMax &other) const; + + Number _min; + Number _max; + }; + INLINE void output_minmax(ostream &out, Number divisor, const MinMax &range) const; + + typedef pvector Ranges; + Ranges _ranges; +}; + +#include "dcNumericRange.I" + +typedef DCNumericRange DCIntRange; +typedef DCNumericRange DCUnsignedIntRange; +typedef DCNumericRange DCInt64Range; +typedef DCNumericRange DCUnsignedInt64Range; +typedef DCNumericRange DCDoubleRange; + +#endif diff --git a/direct/src/dcparser/dcParser.cxx.prebuilt b/direct/src/dcparser/dcParser.cxx.prebuilt index a8e1e33ac3..b0f18e152d 100644 --- a/direct/src/dcparser/dcParser.cxx.prebuilt +++ b/direct/src/dcparser/dcParser.cxx.prebuilt @@ -64,6 +64,7 @@ #include "dcSimpleParameter.h" #include "dcTypedef.h" #include "dcPacker.h" +#include "dcNumericRange.h" // Because our token type contains objects of type string, which // require correct copy construction (and not simply memcpying), we @@ -81,6 +82,7 @@ static DCAtomicField::ElementType atomic_element(new DCSimpleParameter(ST_invali static DCParameter *current_parameter = (DCParameter *)NULL; static DCPacker default_packer; static DCPacker *current_packer; +static DCDoubleRange double_range; //////////////////////////////////////////////////////////////////// // Defining the interface to the parser. @@ -112,12 +114,12 @@ dc_cleanup_parser() { -#define YYFINAL 157 +#define YYFINAL 177 #define YYFLAG -32768 -#define YYNTBASE 56 +#define YYNTBASE 57 /* YYTRANSLATE(YYLEX) -- Bison token number corresponding to YYLEX. */ -#define YYTRANSLATE(x) ((unsigned)(x) <= 296 ? yytranslate[x] : 99) +#define YYTRANSLATE(x) ((unsigned)(x) <= 296 ? yytranslate[x] : 102) /* YYTRANSLATE[YYLEX] -- Bison token number corresponding to YYLEX. */ static const char yytranslate[] = @@ -126,12 +128,12 @@ 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, - 51, 52, 48, 2, 49, 2, 47, 46, 2, 2, + 51, 52, 48, 2, 49, 54, 47, 46, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 50, 43, 2, 53, 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, 54, 2, 55, 2, 2, 2, 2, 2, 2, + 2, 55, 2, 56, 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, 44, 2, 45, 2, 2, 2, 2, @@ -162,47 +164,53 @@ static const short yyprhs[] = 57, 59, 61, 63, 67, 70, 72, 75, 77, 81, 83, 86, 89, 92, 96, 99, 100, 107, 109, 111, 113, 115, 119, 121, 122, 127, 128, 132, 134, 136, - 138, 140, 144, 146, 148, 152, 157, 159, 163, 167, - 172, 174, 176, 178, 180, 181, 186, 187, 192, 193, - 198, 202, 206, 210, 212, 215, 217, 219, 221, 225, - 227, 229, 231, 233, 235, 237, 239, 241, 243, 245, - 247, 249, 251, 253, 255, 257, 259, 261, 263, 265, - 268, 271, 274, 277, 280, 283, 286, 289, 292, 293, - 298, 300, 304 + 138, 140, 145, 149, 156, 163, 165, 167, 169, 173, + 176, 180, 186, 191, 193, 197, 202, 204, 208, 212, + 217, 219, 221, 223, 225, 227, 229, 230, 235, 236, + 241, 242, 247, 251, 255, 259, 261, 264, 266, 268, + 270, 274, 276, 278, 280, 282, 284, 286, 288, 290, + 292, 294, 296, 298, 300, 302, 304, 306, 308, 310, + 312, 314, 317, 320, 323, 326, 329, 332, 335, 338, + 341, 342, 347, 349, 353 }; static const short yyrhs[] = { - 41, 57, 0, 42, 86, 0, 98, 0, 57, 43, - 0, 57, 58, 0, 57, 64, 0, 57, 68, 0, - 0, 60, 7, 59, 69, 44, 71, 45, 0, 9, - 0, 8, 0, 7, 0, 7, 0, 62, 46, 7, - 0, 62, 0, 63, 47, 62, 0, 11, 63, 0, - 0, 10, 63, 11, 65, 66, 0, 67, 0, 48, - 0, 62, 0, 67, 49, 62, 0, 12, 82, 0, - 98, 0, 50, 70, 0, 61, 0, 70, 49, 61, - 0, 98, 0, 71, 43, 0, 71, 72, 0, 71, - 95, 0, 71, 81, 43, 0, 71, 79, 0, 0, - 7, 51, 73, 75, 52, 94, 0, 7, 0, 98, - 0, 76, 0, 77, 0, 76, 49, 77, 0, 82, - 0, 0, 82, 53, 78, 86, 0, 0, 84, 80, - 85, 0, 84, 0, 79, 0, 81, 0, 93, 0, - 93, 46, 3, 0, 7, 0, 83, 0, 84, 54, - 55, 0, 84, 54, 3, 55, 0, 7, 0, 85, - 46, 3, 0, 85, 54, 55, 0, 85, 54, 3, - 55, 0, 3, 0, 4, 0, 5, 0, 6, 0, - 0, 44, 87, 90, 45, 0, 0, 54, 88, 90, - 55, 0, 0, 51, 89, 90, 52, 0, 3, 48, - 3, 0, 4, 48, 3, 0, 6, 48, 3, 0, - 91, 0, 92, 91, 0, 98, 0, 49, 0, 86, - 0, 92, 49, 86, 0, 13, 0, 14, 0, 15, - 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, 98, 0, 94, 32, 0, 94, 33, - 0, 94, 34, 0, 94, 35, 0, 94, 36, 0, - 94, 37, 0, 94, 38, 0, 94, 39, 0, 94, - 40, 0, 0, 7, 50, 96, 97, 0, 74, 0, - 97, 49, 74, 0, 0 + 41, 58, 0, 42, 89, 0, 101, 0, 58, 43, + 0, 58, 59, 0, 58, 65, 0, 58, 69, 0, + 0, 61, 7, 60, 70, 44, 72, 45, 0, 9, + 0, 8, 0, 7, 0, 7, 0, 63, 46, 7, + 0, 63, 0, 64, 47, 63, 0, 11, 64, 0, + 0, 10, 64, 11, 66, 67, 0, 68, 0, 48, + 0, 63, 0, 68, 49, 63, 0, 12, 83, 0, + 101, 0, 50, 71, 0, 62, 0, 71, 49, 62, + 0, 101, 0, 72, 43, 0, 72, 73, 0, 72, + 98, 0, 72, 82, 43, 0, 72, 80, 0, 0, + 7, 51, 74, 76, 52, 97, 0, 7, 0, 101, + 0, 77, 0, 78, 0, 77, 49, 78, 0, 83, + 0, 0, 83, 53, 79, 89, 0, 0, 86, 81, + 87, 0, 86, 0, 80, 0, 82, 0, 96, 0, + 96, 51, 85, 52, 0, 96, 46, 3, 0, 96, + 46, 3, 51, 85, 52, 0, 96, 51, 85, 52, + 46, 3, 0, 7, 0, 101, 0, 88, 0, 88, + 54, 88, 0, 88, 88, 0, 85, 49, 88, 0, + 85, 49, 88, 54, 88, 0, 85, 49, 88, 88, + 0, 84, 0, 86, 55, 56, 0, 86, 55, 3, + 56, 0, 7, 0, 87, 46, 3, 0, 87, 55, + 56, 0, 87, 55, 3, 56, 0, 3, 0, 4, + 0, 3, 0, 4, 0, 5, 0, 6, 0, 0, + 44, 90, 93, 45, 0, 0, 55, 91, 93, 56, + 0, 0, 51, 92, 93, 52, 0, 3, 48, 3, + 0, 4, 48, 3, 0, 6, 48, 3, 0, 94, + 0, 95, 94, 0, 101, 0, 49, 0, 89, 0, + 95, 49, 89, 0, 13, 0, 14, 0, 15, 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, 101, 0, 97, 32, 0, 97, 33, 0, + 97, 34, 0, 97, 35, 0, 97, 36, 0, 97, + 37, 0, 97, 38, 0, 97, 39, 0, 97, 40, + 0, 0, 7, 50, 99, 100, 0, 75, 0, 100, + 49, 75, 0, 0 }; #endif @@ -211,18 +219,19 @@ static const short yyrhs[] = /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const short yyrline[] = { - 0, 123, 125, 128, 130, 131, 132, 133, 136, 136, - 152, 157, 163, 176, 178, 184, 186, 192, 197, 197, - 204, 206, 212, 217, 223, 239, 241, 244, 251, 259, - 261, 262, 263, 264, 268, 276, 276, 287, 303, 305, - 308, 310, 313, 319, 319, 343, 343, 354, 358, 360, - 363, 368, 379, 400, 402, 406, 412, 418, 432, 436, - 442, 447, 451, 455, 459, 459, 467, 467, 475, 475, - 483, 489, 495, 503, 505, 508, 510, 513, 515, 518, - 523, 527, 531, 535, 539, 543, 547, 551, 555, 559, - 563, 567, 571, 575, 579, 583, 587, 591, 597, 599, - 603, 607, 611, 615, 619, 623, 627, 631, 637, 637, - 648, 655, 668 + 0, 126, 128, 131, 133, 134, 135, 136, 139, 139, + 155, 160, 166, 179, 181, 187, 189, 195, 200, 200, + 207, 209, 215, 220, 226, 242, 244, 247, 254, 262, + 264, 265, 266, 267, 271, 279, 279, 290, 306, 308, + 311, 313, 316, 322, 322, 346, 346, 357, 361, 363, + 366, 371, 377, 388, 400, 412, 433, 438, 445, 452, + 462, 468, 474, 485, 487, 491, 497, 503, 517, 521, + 527, 532, 535, 540, 544, 548, 552, 552, 560, 560, + 568, 568, 576, 582, 588, 596, 598, 601, 603, 606, + 608, 611, 616, 620, 624, 628, 632, 636, 640, 644, + 648, 652, 656, 660, 664, 668, 672, 676, 680, 684, + 690, 692, 696, 700, 704, 708, 712, 716, 720, 724, + 730, 730, 741, 748, 761 }; #endif @@ -241,35 +250,36 @@ static const char *const yytname[] = "KW_UINT32UINT8ARRAY", "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", - "dclass", "@1", "kw_struct_or_kw_dclass", "dclass_name", - "slash_identifier", "import_identifier", "import", "@2", + "'*'", "','", "':'", "'('", "')'", "'='", "'-'", "'['", "']'", + "grammar", "dc", "dclass", "@1", "kw_struct_or_kw_dclass", + "dclass_name", "slash_identifier", "import_identifier", "import", "@2", "import_symbol_list_or_star", "import_symbol_list", "typedef_decl", "dclass_derivation", "base_list", "dclass_fields", "atomic_field", "@3", "atomic_name", "parameter_list", "nonempty_parameter_list", "atomic_element", "@4", "named_parameter", "@5", "unnamed_parameter", - "parameter", "type_name", "type_definition", "parameter_definition", - "parameter_value", "@6", "@7", "@8", "array", "maybe_comma", - "array_def", "type_token", "atomic_flags", "molecular_field", "@9", - "molecular_atom_list", "empty", 0 + "parameter", "type_name", "double_range", "type_definition", + "parameter_definition", "number", "parameter_value", "@6", "@7", "@8", + "array", "maybe_comma", "array_def", "type_token", "atomic_flags", + "molecular_field", "@9", "molecular_atom_list", "empty", 0 }; #endif /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ static const short yyr1[] = { - 0, 56, 56, 57, 57, 57, 57, 57, 59, 58, - 60, 60, 61, 62, 62, 63, 63, 64, 65, 64, - 66, 66, 67, 67, 68, 69, 69, 70, 70, 71, - 71, 71, 71, 71, 71, 73, 72, 74, 75, 75, - 76, 76, 77, 78, 77, 80, 79, 81, 82, 82, - 83, 83, 83, 84, 84, 84, 85, 85, 85, 85, - 86, 86, 86, 86, 87, 86, 88, 86, 89, 86, - 86, 86, 86, 90, 90, 91, 91, 92, 92, 93, - 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, - 93, 93, 93, 93, 93, 93, 93, 93, 94, 94, - 94, 94, 94, 94, 94, 94, 94, 94, 96, 95, - 97, 97, 98 + 0, 57, 57, 58, 58, 58, 58, 58, 60, 59, + 61, 61, 62, 63, 63, 64, 64, 65, 66, 65, + 67, 67, 68, 68, 69, 70, 70, 71, 71, 72, + 72, 72, 72, 72, 72, 74, 73, 75, 76, 76, + 77, 77, 78, 79, 78, 81, 80, 82, 83, 83, + 84, 84, 84, 84, 84, 84, 85, 85, 85, 85, + 85, 85, 85, 86, 86, 86, 87, 87, 87, 87, + 88, 88, 89, 89, 89, 89, 90, 89, 91, 89, + 92, 89, 89, 89, 89, 93, 93, 94, 94, 95, + 95, 96, 96, 96, 96, 96, 96, 96, 96, 96, + 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, + 97, 97, 97, 97, 97, 97, 97, 97, 97, 97, + 99, 98, 100, 100, 101 }; /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ @@ -280,13 +290,14 @@ static const short yyr2[] = 1, 1, 1, 3, 2, 1, 2, 1, 3, 1, 2, 2, 2, 3, 2, 0, 6, 1, 1, 1, 1, 3, 1, 0, 4, 0, 3, 1, 1, 1, - 1, 3, 1, 1, 3, 4, 1, 3, 3, 4, - 1, 1, 1, 1, 0, 4, 0, 4, 0, 4, - 3, 3, 3, 1, 2, 1, 1, 1, 3, 1, + 1, 4, 3, 6, 6, 1, 1, 1, 3, 2, + 3, 5, 4, 1, 3, 4, 1, 3, 3, 4, + 1, 1, 1, 1, 1, 1, 0, 4, 0, 4, + 0, 4, 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, 1, 2, - 2, 2, 2, 2, 2, 2, 2, 2, 0, 4, - 1, 3, 0 + 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 0, 4, 1, 3, 0 }; /* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE @@ -294,106 +305,110 @@ static const short yyr2[] = error. */ static const short yydefact[] = { - 0, 112, 0, 1, 3, 60, 61, 62, 63, 64, - 68, 66, 2, 11, 10, 0, 0, 0, 4, 5, - 0, 6, 7, 0, 0, 0, 112, 112, 112, 13, - 15, 0, 17, 52, 79, 80, 81, 82, 83, 84, - 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, - 95, 96, 97, 48, 49, 24, 53, 47, 50, 8, - 70, 71, 72, 76, 77, 0, 73, 112, 75, 0, - 0, 0, 18, 0, 0, 0, 0, 112, 65, 76, - 74, 69, 67, 14, 0, 16, 0, 54, 56, 46, - 51, 0, 0, 25, 78, 21, 22, 19, 20, 55, - 0, 0, 12, 27, 26, 112, 0, 57, 0, 58, - 0, 0, 29, 23, 59, 28, 52, 30, 9, 31, - 34, 0, 32, 108, 35, 33, 0, 112, 37, 110, - 109, 0, 39, 40, 42, 38, 0, 112, 0, 43, - 111, 36, 98, 41, 0, 99, 100, 101, 102, 103, - 104, 105, 106, 107, 44, 0, 0, 0 + 0, 124, 0, 1, 3, 72, 73, 74, 75, 76, + 80, 78, 2, 11, 10, 0, 0, 0, 4, 5, + 0, 6, 7, 0, 0, 0, 124, 124, 124, 13, + 15, 0, 17, 55, 91, 92, 93, 94, 95, 96, + 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, + 107, 108, 109, 48, 49, 24, 63, 47, 50, 8, + 82, 83, 84, 88, 89, 0, 85, 124, 87, 0, + 0, 0, 18, 0, 0, 0, 0, 124, 124, 77, + 88, 86, 81, 79, 14, 0, 16, 0, 64, 66, + 46, 52, 70, 71, 0, 57, 56, 0, 0, 25, + 90, 21, 22, 19, 20, 65, 0, 0, 124, 0, + 51, 0, 59, 12, 27, 26, 124, 0, 67, 0, + 68, 0, 60, 0, 58, 0, 0, 29, 23, 69, + 53, 0, 62, 54, 28, 55, 30, 9, 31, 34, + 0, 32, 61, 120, 35, 33, 0, 124, 37, 122, + 121, 0, 39, 40, 42, 38, 0, 124, 0, 43, + 123, 36, 110, 41, 0, 111, 112, 113, 114, 115, + 116, 117, 118, 119, 44, 0, 0, 0 }; static const short yydefgoto[] = { - 155, 3, 19, 77, 20, 103, 30, 31, 21, 84, - 97, 98, 22, 92, 104, 111, 119, 127, 129, 131, - 132, 133, 144, 53, 75, 54, 134, 56, 57, 89, - 64, 26, 28, 27, 65, 66, 67, 58, 141, 122, - 126, 130, 68 + 175, 3, 19, 78, 20, 114, 30, 31, 21, 85, + 103, 104, 22, 98, 115, 126, 138, 147, 149, 151, + 152, 153, 164, 53, 75, 54, 154, 56, 94, 57, + 90, 95, 64, 26, 28, 27, 65, 66, 67, 58, + 161, 141, 146, 150, 68 }; static const short yypact[] = { - -19,-32768, 9, 8,-32768, -41, -20,-32768, -16,-32768, - -32768,-32768,-32768,-32768,-32768, 17, 17, 130,-32768,-32768, - 26,-32768,-32768, 31, 34, 35, 5, 5, 5,-32768, - -11, -5, -8,-32768,-32768,-32768,-32768,-32768,-32768,-32768, + -3,-32768, 9, 25,-32768, -8, -4,-32768, 0,-32768, + -32768,-32768,-32768,-32768,-32768, 49, 49, 107,-32768,-32768, + 58,-32768,-32768, 63, 66, 67, 3, 3, 3,-32768, + 26, 12, 24,-32768,-32768,-32768,-32768,-32768,-32768,-32768, -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, - -32768,-32768,-32768,-32768,-32768,-32768,-32768, -6, 4,-32768, - -32768,-32768,-32768,-32768,-32768, -4,-32768, -9,-32768, 10, - -12, 37,-32768, 17, 0, 39, 44, 11,-32768, 9, - -32768,-32768,-32768,-32768, -3, -11, 19,-32768,-32768, -25, - -32768, 45, 54,-32768,-32768,-32768, -11,-32768, 27,-32768, - 72, 2,-32768,-32768, 50,-32768, 17,-32768, 46,-32768, - 45, 66,-32768, -11,-32768,-32768, -24,-32768,-32768,-32768, - -32768, 57,-32768,-32768,-32768,-32768, 95, 130,-32768,-32768, - 55, 51, 56,-32768, 59,-32768, 95,-32768, 130,-32768, - -32768, 32,-32768,-32768, 9,-32768,-32768,-32768,-32768,-32768, - -32768,-32768,-32768,-32768,-32768, 107, 108,-32768 + -32768,-32768,-32768,-32768,-32768,-32768,-32768, -6, -20,-32768, + -32768,-32768,-32768,-32768,-32768, 28,-32768, 27,-32768, 22, + 21, 93,-32768, 49, -1, 105, 112, 39, 89,-32768, + 9,-32768,-32768,-32768,-32768, 15, 26, 60,-32768,-32768, + -26, 90,-32768,-32768, -25, 7,-32768, 110, 75,-32768, + -32768,-32768, 26,-32768, 91,-32768, 139, 1, 39, 39, + 97, 39,-32768,-32768,-32768, 95,-32768, 49,-32768, 92, + -32768, -24, 13, 142,-32768, 110, 68,-32768, 26,-32768, + -32768, 39,-32768,-32768,-32768, -5,-32768,-32768,-32768,-32768, + 103,-32768,-32768,-32768,-32768,-32768, 140, 107,-32768,-32768, + 101, 99, 104,-32768, 102,-32768, 140,-32768, 107,-32768, + -32768, 69,-32768,-32768, 9,-32768,-32768,-32768,-32768,-32768, + -32768,-32768,-32768,-32768,-32768, 152, 154,-32768 }; static const short yypgoto[] = { - -32768,-32768,-32768,-32768,-32768, 6, -48, 94,-32768,-32768, - -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, -23,-32768, - -32768, -21,-32768, 7,-32768, 12, 97,-32768,-32768,-32768, - -2,-32768,-32768,-32768, 3, 48,-32768,-32768,-32768,-32768, - -32768,-32768, 1 + -32768,-32768,-32768,-32768,-32768, 31, -55, 141,-32768,-32768, + -32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768, 4,-32768, + -32768, 5,-32768, 32,-32768, 35, 147,-32768, 57,-32768, + -32768, -90, -2,-32768,-32768,-32768, 23, 100,-32768,-32768, + -32768,-32768,-32768,-32768, 2 }; -#define YYLAST 161 +#define YYLAST 167 static const short yytable[] = { - 12, -45, 4, 86, 29, 108, 72, 23, 5, 6, - 7, 8, 5, 6, 7, 8, 13, 14, 15, 16, - 17, 100, 1, 2, 29, 85, 123, 124, 24, 101, - 69, 70, 25, 59, 60, 71, 96, 61, 62, 73, - 79, 78, 73, 82, 83, 95, 88, 90, 74, 9, - 76, 18, 102, 9, 63, 87, 10, 109, 113, 11, - 10, 91, 81, 11, 145, 146, 147, 148, 149, 150, - 151, 152, 153, 116, 99, 107, 106, 94, 93, 34, - 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, - 45, 46, 47, 48, 49, 50, 51, 52, 105, 110, - 125, 114, 128, 137, 136, 138, 112, 156, 157, 117, - 32, 118, 139, 140, 55, 80, 115, 143, 120, 0, - 0, 0, 0, 121, 0, 0, 0, 0, 135, 0, - 0, 0, 0, 0, 0, 0, 0, 33, 142, 0, - 0, 0, 154, 34, 35, 36, 37, 38, 39, 40, - 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, - 51, 52 + 12, -45, 87, 4, 119, 112, 5, 6, 7, 8, + 92, 93, 5, 6, 7, 8, 92, 93, 86, 122, + 106, 124, 29, 72, 109, 109, 76, 110, 130, 107, + 102, 77, 132, 13, 14, 15, 16, 17, 1, 2, + 23, 142, 92, 93, 24, 143, 144, 9, 25, 74, + 69, 70, 63, 9, 10, 88, 29, 120, 11, 73, + 10, 111, 128, 101, 11, 59, 60, 131, 18, 61, + 62, 73, 71, 79, 82, 135, 80, 83, 100, 96, + 99, 34, 35, 36, 37, 38, 39, 40, 41, 42, + 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, + 84, 165, 166, 167, 168, 169, 170, 171, 172, 173, + 96, 136, 89, 137, 33, 91, 105, 113, 127, 116, + 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, + 44, 45, 46, 47, 48, 49, 50, 51, 52, 97, + 117, 108, 118, 123, 125, 133, 145, 148, 129, 155, + 156, 157, 176, 158, 177, 159, 134, 32, 139, 162, + 160, 140, 174, 163, 55, 121, 0, 81 }; static const short yycheck[] = { - 2, 7, 1, 3, 7, 3, 11, 48, 3, 4, - 5, 6, 3, 4, 5, 6, 8, 9, 10, 11, - 12, 46, 41, 42, 7, 73, 50, 51, 48, 54, - 27, 28, 48, 7, 3, 46, 84, 3, 3, 47, - 49, 45, 47, 55, 7, 48, 7, 3, 54, 44, - 46, 43, 7, 44, 49, 55, 51, 55, 106, 54, - 51, 50, 52, 54, 32, 33, 34, 35, 36, 37, - 38, 39, 40, 7, 55, 3, 49, 79, 77, 13, - 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, - 24, 25, 26, 27, 28, 29, 30, 31, 44, 49, - 43, 55, 7, 52, 49, 49, 105, 0, 0, 43, - 16, 45, 53, 136, 17, 67, 110, 138, 111, -1, - -1, -1, -1, 111, -1, -1, -1, -1, 127, -1, - -1, -1, -1, -1, -1, -1, -1, 7, 137, -1, - -1, -1, 144, 13, 14, 15, 16, 17, 18, 19, - 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, - 30, 31 + 2, 7, 3, 1, 3, 95, 3, 4, 5, 6, + 3, 4, 3, 4, 5, 6, 3, 4, 73, 109, + 46, 111, 7, 11, 49, 49, 46, 52, 52, 55, + 85, 51, 122, 8, 9, 10, 11, 12, 41, 42, + 48, 131, 3, 4, 48, 50, 51, 44, 48, 55, + 27, 28, 49, 44, 51, 56, 7, 56, 55, 47, + 51, 54, 117, 48, 55, 7, 3, 54, 43, 3, + 3, 47, 46, 45, 52, 7, 49, 56, 80, 77, + 78, 13, 14, 15, 16, 17, 18, 19, 20, 21, + 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, + 7, 32, 33, 34, 35, 36, 37, 38, 39, 40, + 108, 43, 7, 45, 7, 3, 56, 7, 116, 44, + 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, + 23, 24, 25, 26, 27, 28, 29, 30, 31, 50, + 49, 51, 3, 46, 49, 3, 43, 7, 56, 147, + 49, 52, 0, 49, 0, 53, 125, 16, 126, 157, + 156, 126, 164, 158, 17, 108, -1, 67 }; /* -*-C-*- Note some compilers choke on comments on `#line' lines. */ #line 3 "/usr/share/bison/bison.simple" @@ -1103,7 +1118,7 @@ yyreduce: switch (yyn) { case 8: -#line 138 "dcParser.yxx" +#line 141 "dcParser.yxx" { current_class = new DCClass(yyvsp[0].str, yyvsp[-1].u.flag, false); if (!dc_file->add_class(current_class)) { @@ -1117,19 +1132,19 @@ case 8: } break; case 10: -#line 154 "dcParser.yxx" +#line 157 "dcParser.yxx" { yyval.u.flag = true; } break; case 11: -#line 158 "dcParser.yxx" +#line 161 "dcParser.yxx" { yyval.u.flag = false; } break; case 12: -#line 165 "dcParser.yxx" +#line 168 "dcParser.yxx" { DCClass *dclass = dc_file->get_class_by_name(yyvsp[0].str); if (dclass == (DCClass *)NULL) { @@ -1141,49 +1156,49 @@ case 12: } break; case 14: -#line 179 "dcParser.yxx" +#line 182 "dcParser.yxx" { yyval.str = yyvsp[-2].str + string("/") + yyvsp[0].str; } break; case 16: -#line 187 "dcParser.yxx" +#line 190 "dcParser.yxx" { yyval.str = yyvsp[-2].str + string(".") + yyvsp[0].str; } break; case 17: -#line 194 "dcParser.yxx" +#line 197 "dcParser.yxx" { dc_file->add_import_module(yyvsp[0].str); } break; case 18: -#line 198 "dcParser.yxx" +#line 201 "dcParser.yxx" { dc_file->add_import_module(yyvsp[-1].str); } break; case 21: -#line 207 "dcParser.yxx" +#line 210 "dcParser.yxx" { dc_file->add_import_symbol("*"); } break; case 22: -#line 214 "dcParser.yxx" +#line 217 "dcParser.yxx" { dc_file->add_import_symbol(yyvsp[0].str); } break; case 23: -#line 218 "dcParser.yxx" +#line 221 "dcParser.yxx" { dc_file->add_import_symbol(yyvsp[0].str); } break; case 24: -#line 225 "dcParser.yxx" +#line 228 "dcParser.yxx" { DCTypedef *dtypedef = new DCTypedef(yyvsp[0].u.parameter); @@ -1198,7 +1213,7 @@ case 24: } break; case 27: -#line 246 "dcParser.yxx" +#line 249 "dcParser.yxx" { if (yyvsp[0].u.dclass != (DCClass *)NULL) { current_class->add_parent(yyvsp[0].u.dclass); @@ -1206,7 +1221,7 @@ case 27: } break; case 28: -#line 252 "dcParser.yxx" +#line 255 "dcParser.yxx" { if (yyvsp[0].u.dclass != (DCClass *)NULL) { current_class->add_parent(yyvsp[0].u.dclass); @@ -1214,13 +1229,13 @@ case 28: } break; case 33: -#line 265 "dcParser.yxx" +#line 268 "dcParser.yxx" { current_class->add_parameter(yyvsp[-1].u.parameter); } break; case 34: -#line 269 "dcParser.yxx" +#line 272 "dcParser.yxx" { if (!current_class->add_parameter(yyvsp[0].u.parameter)) { yyerror("Duplicate parameter name: " + yyvsp[0].u.parameter->get_name()); @@ -1228,7 +1243,7 @@ case 34: } break; case 35: -#line 278 "dcParser.yxx" +#line 281 "dcParser.yxx" { current_atomic = new DCAtomicField(yyvsp[-1].str); if (!current_class->add_field(current_atomic)) { @@ -1237,7 +1252,7 @@ case 35: } break; case 37: -#line 289 "dcParser.yxx" +#line 292 "dcParser.yxx" { DCField *field = current_class->get_field_by_name(yyvsp[0].str); yyval.u.atomic = (DCAtomicField *)NULL; @@ -1252,21 +1267,21 @@ case 37: } break; case 42: -#line 315 "dcParser.yxx" +#line 318 "dcParser.yxx" { atomic_element = DCAtomicField::ElementType(yyvsp[0].u.parameter); current_atomic->add_element(atomic_element); } break; case 43: -#line 320 "dcParser.yxx" +#line 323 "dcParser.yxx" { current_packer = &default_packer; current_packer->begin_pack(yyvsp[-1].u.parameter); } break; case 44: -#line 325 "dcParser.yxx" +#line 328 "dcParser.yxx" { bool is_valid = yyvsp[-3].u.parameter->is_valid(); atomic_element = DCAtomicField::ElementType(yyvsp[-3].u.parameter); @@ -1285,25 +1300,33 @@ case 44: } break; case 45: -#line 345 "dcParser.yxx" +#line 348 "dcParser.yxx" { current_parameter = yyvsp[0].u.parameter; } break; case 46: -#line 349 "dcParser.yxx" +#line 352 "dcParser.yxx" { yyval.u.parameter = yyvsp[0].u.parameter; } break; case 50: -#line 365 "dcParser.yxx" +#line 368 "dcParser.yxx" { yyval.u.parameter = new DCSimpleParameter(yyvsp[0].u.subatomic); } break; case 51: -#line 369 "dcParser.yxx" +#line 372 "dcParser.yxx" +{ + DCSimpleParameter *simple_param = new DCSimpleParameter(yyvsp[-3].u.subatomic); + simple_param->set_range(double_range); + yyval.u.parameter = simple_param; +} + break; +case 52: +#line 378 "dcParser.yxx" { DCSimpleParameter *simple_param = new DCSimpleParameter(yyvsp[-2].u.subatomic); if (yyvsp[0].u.integer == 0) { @@ -1315,8 +1338,36 @@ case 51: yyval.u.parameter = simple_param; } break; -case 52: -#line 380 "dcParser.yxx" +case 53: +#line 389 "dcParser.yxx" +{ + DCSimpleParameter *simple_param = new DCSimpleParameter(yyvsp[-5].u.subatomic); + if (yyvsp[-3].u.integer == 0) { + yyerror("Invalid divisor."); + + } else if (!simple_param->set_divisor(yyvsp[-3].u.integer)) { + yyerror("A divisor is only valid on a numeric type."); + } + simple_param->set_range(double_range); + yyval.u.parameter = simple_param; +} + break; +case 54: +#line 401 "dcParser.yxx" +{ + DCSimpleParameter *simple_param = new DCSimpleParameter(yyvsp[-5].u.subatomic); + if (yyvsp[0].u.integer == 0) { + yyerror("Invalid divisor."); + + } else if (!simple_param->set_divisor(yyvsp[0].u.integer)) { + yyerror("A divisor is only valid on a numeric type."); + } + simple_param->set_range(double_range); + yyval.u.parameter = simple_param; +} + break; +case 55: +#line 413 "dcParser.yxx" { DCTypedef *dtypedef = dc_file->get_typedef_by_name(yyvsp[0].str); if (dtypedef == (DCTypedef *)NULL) { @@ -1336,27 +1387,90 @@ case 52: yyval.u.parameter = dtypedef->make_new_parameter(); } break; -case 54: -#line 403 "dcParser.yxx" +case 56: +#line 435 "dcParser.yxx" +{ + double_range.clear(); +} + break; +case 57: +#line 439 "dcParser.yxx" +{ + double_range.clear(); + if (!double_range.add_range(yyvsp[0].u.real, yyvsp[0].u.real)) { + yyerror("Overlapping range"); + } +} + break; +case 58: +#line 446 "dcParser.yxx" +{ + double_range.clear(); + if (!double_range.add_range(yyvsp[-2].u.real, yyvsp[0].u.real)) { + yyerror("Overlapping range"); + } +} + break; +case 59: +#line 453 "dcParser.yxx" +{ + double_range.clear(); + if (yyvsp[0].u.real >= 0) { + yyerror("Syntax error"); + } + if (!double_range.add_range(yyvsp[-1].u.real, -yyvsp[0].u.real)) { + yyerror("Overlapping range"); + } +} + break; +case 60: +#line 463 "dcParser.yxx" +{ + if (!double_range.add_range(yyvsp[0].u.real, yyvsp[0].u.real)) { + yyerror("Overlapping range"); + } +} + break; +case 61: +#line 469 "dcParser.yxx" +{ + if (!double_range.add_range(yyvsp[-2].u.real, yyvsp[0].u.real)) { + yyerror("Overlapping range"); + } +} + break; +case 62: +#line 475 "dcParser.yxx" +{ + if (yyvsp[0].u.real >= 0) { + yyerror("Syntax error"); + } + if (!double_range.add_range(yyvsp[-1].u.real, -yyvsp[0].u.real)) { + yyerror("Overlapping range"); + } +} + break; +case 64: +#line 488 "dcParser.yxx" { yyval.u.parameter = new DCArrayParameter(yyvsp[-2].u.parameter); } break; -case 55: -#line 407 "dcParser.yxx" +case 65: +#line 492 "dcParser.yxx" { yyval.u.parameter = new DCArrayParameter(yyvsp[-3].u.parameter, yyvsp[-1].u.integer); } break; -case 56: -#line 414 "dcParser.yxx" +case 66: +#line 499 "dcParser.yxx" { current_parameter->set_name(yyvsp[0].str); yyval.u.parameter = current_parameter; } break; -case 57: -#line 419 "dcParser.yxx" +case 67: +#line 504 "dcParser.yxx" { if (yyvsp[0].u.integer == 0) { yyerror("Invalid divisor."); @@ -1371,272 +1485,278 @@ case 57: } } break; -case 58: -#line 433 "dcParser.yxx" +case 68: +#line 518 "dcParser.yxx" { yyval.u.parameter = new DCArrayParameter(yyvsp[-2].u.parameter); } break; -case 59: -#line 437 "dcParser.yxx" +case 69: +#line 522 "dcParser.yxx" { yyval.u.parameter = new DCArrayParameter(yyvsp[-3].u.parameter, yyvsp[-1].u.integer); } break; -case 60: -#line 444 "dcParser.yxx" +case 70: +#line 529 "dcParser.yxx" +{ + yyval.u.real = (double)yyvsp[0].u.integer; +} + break; +case 72: +#line 537 "dcParser.yxx" { current_packer->pack_int64(yyvsp[0].u.integer); } break; -case 61: -#line 448 "dcParser.yxx" +case 73: +#line 541 "dcParser.yxx" { current_packer->pack_double(yyvsp[0].u.real); } break; -case 62: -#line 452 "dcParser.yxx" +case 74: +#line 545 "dcParser.yxx" { current_packer->pack_string(yyvsp[0].str); } break; -case 63: -#line 456 "dcParser.yxx" +case 75: +#line 549 "dcParser.yxx" { current_packer->pack_literal_value(yyvsp[0].str); } break; -case 64: -#line 460 "dcParser.yxx" +case 76: +#line 553 "dcParser.yxx" { current_packer->push(); } break; -case 65: -#line 464 "dcParser.yxx" +case 77: +#line 557 "dcParser.yxx" { current_packer->pop(); } break; -case 66: -#line 468 "dcParser.yxx" +case 78: +#line 561 "dcParser.yxx" { current_packer->push(); } break; -case 67: -#line 472 "dcParser.yxx" +case 79: +#line 565 "dcParser.yxx" { current_packer->pop(); } break; -case 68: -#line 476 "dcParser.yxx" +case 80: +#line 569 "dcParser.yxx" { current_packer->push(); } break; -case 69: -#line 480 "dcParser.yxx" +case 81: +#line 573 "dcParser.yxx" { current_packer->pop(); } break; -case 70: -#line 484 "dcParser.yxx" +case 82: +#line 577 "dcParser.yxx" { for (int i = 0; i < yyvsp[0].u.integer; i++) { current_packer->pack_int64(yyvsp[-2].u.integer); } } break; -case 71: -#line 490 "dcParser.yxx" +case 83: +#line 583 "dcParser.yxx" { for (int i = 0; i < yyvsp[0].u.integer; i++) { current_packer->pack_double(yyvsp[-2].u.real); } } break; -case 72: -#line 496 "dcParser.yxx" +case 84: +#line 589 "dcParser.yxx" { for (int i = 0; i < yyvsp[0].u.integer; i++) { current_packer->pack_literal_value(yyvsp[-2].str); } } break; -case 79: -#line 520 "dcParser.yxx" +case 91: +#line 613 "dcParser.yxx" { yyval.u.subatomic = ST_int8; } break; -case 80: -#line 524 "dcParser.yxx" +case 92: +#line 617 "dcParser.yxx" { yyval.u.subatomic = ST_int16; } break; -case 81: -#line 528 "dcParser.yxx" +case 93: +#line 621 "dcParser.yxx" { yyval.u.subatomic = ST_int32; } break; -case 82: -#line 532 "dcParser.yxx" +case 94: +#line 625 "dcParser.yxx" { yyval.u.subatomic = ST_int64; } break; -case 83: -#line 536 "dcParser.yxx" +case 95: +#line 629 "dcParser.yxx" { yyval.u.subatomic = ST_uint8; } break; -case 84: -#line 540 "dcParser.yxx" +case 96: +#line 633 "dcParser.yxx" { yyval.u.subatomic = ST_uint16; } break; -case 85: -#line 544 "dcParser.yxx" +case 97: +#line 637 "dcParser.yxx" { yyval.u.subatomic = ST_uint32; } break; -case 86: -#line 548 "dcParser.yxx" +case 98: +#line 641 "dcParser.yxx" { yyval.u.subatomic = ST_uint64; } break; -case 87: -#line 552 "dcParser.yxx" +case 99: +#line 645 "dcParser.yxx" { yyval.u.subatomic = ST_float64; } break; -case 88: -#line 556 "dcParser.yxx" +case 100: +#line 649 "dcParser.yxx" { yyval.u.subatomic = ST_string; } break; -case 89: -#line 560 "dcParser.yxx" +case 101: +#line 653 "dcParser.yxx" { yyval.u.subatomic = ST_blob; } break; -case 90: -#line 564 "dcParser.yxx" +case 102: +#line 657 "dcParser.yxx" { yyval.u.subatomic = ST_blob32; } break; -case 91: -#line 568 "dcParser.yxx" +case 103: +#line 661 "dcParser.yxx" { yyval.u.subatomic = ST_int8array; } break; -case 92: -#line 572 "dcParser.yxx" +case 104: +#line 665 "dcParser.yxx" { yyval.u.subatomic = ST_int16array; } break; -case 93: -#line 576 "dcParser.yxx" +case 105: +#line 669 "dcParser.yxx" { yyval.u.subatomic = ST_int32array; } break; -case 94: -#line 580 "dcParser.yxx" +case 106: +#line 673 "dcParser.yxx" { yyval.u.subatomic = ST_uint8array; } break; -case 95: -#line 584 "dcParser.yxx" +case 107: +#line 677 "dcParser.yxx" { yyval.u.subatomic = ST_uint16array; } break; -case 96: -#line 588 "dcParser.yxx" +case 108: +#line 681 "dcParser.yxx" { yyval.u.subatomic = ST_uint32array; } break; -case 97: -#line 592 "dcParser.yxx" +case 109: +#line 685 "dcParser.yxx" { yyval.u.subatomic = ST_uint32uint8array; } break; -case 99: -#line 600 "dcParser.yxx" +case 111: +#line 693 "dcParser.yxx" { current_atomic->add_flag(DCAtomicField::F_required); } break; -case 100: -#line 604 "dcParser.yxx" +case 112: +#line 697 "dcParser.yxx" { current_atomic->add_flag(DCAtomicField::F_broadcast); } break; -case 101: -#line 608 "dcParser.yxx" +case 113: +#line 701 "dcParser.yxx" { current_atomic->add_flag(DCAtomicField::F_p2p); } break; -case 102: -#line 612 "dcParser.yxx" +case 114: +#line 705 "dcParser.yxx" { current_atomic->add_flag(DCAtomicField::F_ram); } break; -case 103: -#line 616 "dcParser.yxx" +case 115: +#line 709 "dcParser.yxx" { current_atomic->add_flag(DCAtomicField::F_db); } break; -case 104: -#line 620 "dcParser.yxx" +case 116: +#line 713 "dcParser.yxx" { current_atomic->add_flag(DCAtomicField::F_clsend); } break; -case 105: -#line 624 "dcParser.yxx" +case 117: +#line 717 "dcParser.yxx" { current_atomic->add_flag(DCAtomicField::F_clrecv); } break; -case 106: -#line 628 "dcParser.yxx" +case 118: +#line 721 "dcParser.yxx" { current_atomic->add_flag(DCAtomicField::F_ownsend); } break; -case 107: -#line 632 "dcParser.yxx" +case 119: +#line 725 "dcParser.yxx" { current_atomic->add_flag(DCAtomicField::F_airecv); } break; -case 108: -#line 639 "dcParser.yxx" +case 120: +#line 732 "dcParser.yxx" { current_molecular = new DCMolecularField(yyvsp[-1].str); if (!current_class->add_field(current_molecular)) { @@ -1644,16 +1764,16 @@ case 108: } } break; -case 110: -#line 650 "dcParser.yxx" +case 122: +#line 743 "dcParser.yxx" { if (yyvsp[0].u.atomic != (DCAtomicField *)NULL) { current_molecular->add_atomic(yyvsp[0].u.atomic); } } break; -case 111: -#line 656 "dcParser.yxx" +case 123: +#line 749 "dcParser.yxx" { if (yyvsp[0].u.atomic != (DCAtomicField *)NULL) { current_molecular->add_atomic(yyvsp[0].u.atomic); @@ -1898,4 +2018,4 @@ yyreturn: #endif return yyresult; } -#line 671 "dcParser.yxx" +#line 764 "dcParser.yxx" diff --git a/direct/src/dcparser/dcParser.yxx b/direct/src/dcparser/dcParser.yxx index e2006c4605..4b9f0ec112 100644 --- a/direct/src/dcparser/dcParser.yxx +++ b/direct/src/dcparser/dcParser.yxx @@ -15,6 +15,7 @@ #include "dcSimpleParameter.h" #include "dcTypedef.h" #include "dcPacker.h" +#include "dcNumericRange.h" // Because our token type contains objects of type string, which // require correct copy construction (and not simply memcpying), we @@ -32,6 +33,7 @@ static DCAtomicField::ElementType atomic_element(new DCSimpleParameter(ST_invali static DCParameter *current_parameter = (DCParameter *)NULL; static DCPacker default_packer; static DCPacker *current_packer; +static DCDoubleRange double_range; //////////////////////////////////////////////////////////////////// // Defining the interface to the parser. @@ -117,6 +119,7 @@ dc_cleanup_parser() { %type parameter_definition %type import_identifier %type slash_identifier +%type number %% @@ -364,6 +367,12 @@ type_name: type_token { $$ = new DCSimpleParameter($1); +} + | type_token '(' double_range ')' +{ + DCSimpleParameter *simple_param = new DCSimpleParameter($1); + simple_param->set_range(double_range); + $$ = simple_param; } | type_token '/' INTEGER { @@ -375,6 +384,30 @@ type_name: yyerror("A divisor is only valid on a numeric type."); } $$ = simple_param; +} + | type_token '/' INTEGER '(' double_range ')' +{ + DCSimpleParameter *simple_param = new DCSimpleParameter($1); + if ($3 == 0) { + yyerror("Invalid divisor."); + + } else if (!simple_param->set_divisor($3)) { + yyerror("A divisor is only valid on a numeric type."); + } + simple_param->set_range(double_range); + $$ = simple_param; +} + | type_token '(' double_range ')' '/' INTEGER +{ + DCSimpleParameter *simple_param = new DCSimpleParameter($1); + if ($6 == 0) { + yyerror("Invalid divisor."); + + } else if (!simple_param->set_divisor($6)) { + yyerror("A divisor is only valid on a numeric type."); + } + simple_param->set_range(double_range); + $$ = simple_param; } | IDENTIFIER { @@ -397,6 +430,58 @@ type_name: } ; +double_range: + empty +{ + double_range.clear(); +} + | number +{ + double_range.clear(); + if (!double_range.add_range($1, $1)) { + yyerror("Overlapping range"); + } +} + | number '-' number +{ + double_range.clear(); + if (!double_range.add_range($1, $3)) { + yyerror("Overlapping range"); + } +} + | number number +{ + double_range.clear(); + if ($2 >= 0) { + yyerror("Syntax error"); + } + if (!double_range.add_range($1, -$2)) { + yyerror("Overlapping range"); + } +} + | double_range ',' number +{ + if (!double_range.add_range($3, $3)) { + yyerror("Overlapping range"); + } +} + | double_range ',' number '-' number +{ + if (!double_range.add_range($3, $5)) { + yyerror("Overlapping range"); + } +} + | double_range ',' number number +{ + if ($4 >= 0) { + yyerror("Syntax error"); + } + if (!double_range.add_range($3, -$4)) { + yyerror("Overlapping range"); + } +} + ; + type_definition: type_name | type_definition '[' ']' @@ -439,6 +524,14 @@ parameter_definition: } ; +number: + INTEGER +{ + $$ = (double)$1; +} + | REAL + ; + parameter_value: INTEGER { diff --git a/direct/src/dcparser/dcSimpleParameter.cxx b/direct/src/dcparser/dcSimpleParameter.cxx index 0cb64c0478..2697acedee 100644 --- a/direct/src/dcparser/dcSimpleParameter.cxx +++ b/direct/src/dcparser/dcSimpleParameter.cxx @@ -194,7 +194,12 @@ DCSimpleParameter(const DCSimpleParameter ©) : _type(copy._type), _divisor(copy._divisor), _nested_field(copy._nested_field), - _bytes_per_element(copy._bytes_per_element) + _bytes_per_element(copy._bytes_per_element), + _int_range(copy._int_range), + _uint_range(copy._uint_range), + _int64_range(copy._int64_range), + _uint64_range(copy._uint64_range), + _double_range(copy._double_range) { } @@ -279,6 +284,74 @@ set_divisor(int divisor) { return true; } +//////////////////////////////////////////////////////////////////// +// Function: DCSimpleParameter::set_range +// Access: Public +// Description: Sets the parameter with the indicated range. A +// DCDoubleRange is used for specification, since this +// is the most generic type; but it is converted to the +// appropriate type internally. +//////////////////////////////////////////////////////////////////// +void DCSimpleParameter:: +set_range(const DCDoubleRange &range) { + int num_ranges = range.get_num_ranges(); + int i; + + switch (_type) { + case ST_int8: + case ST_int16: + case ST_int32: + _int_range.clear(); + for (i = 0; i < num_ranges; i++) { + int min = (int)floor(range.get_min(i) * _divisor + 0.5); + int max = (int)floor(range.get_max(i) * _divisor + 0.5); + _int_range.add_range(min, max); + } + break; + + case ST_int64: + _int64_range.clear(); + for (i = 0; i < num_ranges; i++) { + PN_int64 min = (PN_int64)floor(range.get_min(i) * _divisor + 0.5); + PN_int64 max = (PN_int64)floor(range.get_max(i) * _divisor + 0.5); + _int64_range.add_range(min, max); + } + break; + + case ST_uint8: + case ST_uint16: + case ST_uint32: + _uint_range.clear(); + for (i = 0; i < num_ranges; i++) { + unsigned int min = (unsigned int)floor(range.get_min(i) * _divisor + 0.5); + unsigned int max = (unsigned int)floor(range.get_max(i) * _divisor + 0.5); + _uint_range.add_range(min, max); + } + break; + + case ST_uint64: + _uint64_range.clear(); + for (i = 0; i < num_ranges; i++) { + PN_uint64 min = (PN_uint64)floor(range.get_min(i) * _divisor + 0.5); + PN_uint64 max = (PN_uint64)floor(range.get_max(i) * _divisor + 0.5); + _uint64_range.add_range(min, max); + } + break; + + case ST_float64: + _double_range.clear(); + for (i = 0; i < num_ranges; i++) { + double min = range.get_min(i) * _divisor; + double max = range.get_max(i) * _divisor; + _double_range.add_range(min, max); + } + break; + + default: + break; + } +} + //////////////////////////////////////////////////////////////////// // Function: DCSimpleParameter::calc_num_nested_fields // Access: Public, Virtual @@ -323,46 +396,71 @@ pack_double(DCPackData &pack_data, double value) const { switch (_type) { case ST_int8: - do_pack_int8(pack_data.get_write_pointer(1), - (int)floor(real_value + 0.5), pack_error); + { + int int_value = (int)floor(real_value + 0.5); + _int_range.validate(int_value, pack_error); + do_pack_int8(pack_data.get_write_pointer(1), int_value, pack_error); + } break; case ST_int16: - do_pack_int16(pack_data.get_write_pointer(2), - (int)floor(real_value + 0.5), pack_error); + { + int int_value = (int)floor(real_value + 0.5); + _int_range.validate(int_value, pack_error); + do_pack_int16(pack_data.get_write_pointer(2), int_value, pack_error); + } break; case ST_int32: - do_pack_int32(pack_data.get_write_pointer(4), - (int)floor(real_value + 0.5), pack_error); + { + int int_value = (int)floor(real_value + 0.5); + _int_range.validate(int_value, pack_error); + do_pack_int32(pack_data.get_write_pointer(4), int_value, pack_error); + } break; case ST_int64: - do_pack_int64(pack_data.get_write_pointer(8), - (PN_int64)floor(real_value + 0.5), pack_error); + { + PN_int64 int64_value = (PN_int64)floor(real_value + 0.5); + _int64_range.validate(int64_value, pack_error); + do_pack_int64(pack_data.get_write_pointer(8), int64_value, pack_error); + } break; case ST_uint8: - do_pack_uint8(pack_data.get_write_pointer(1), - (unsigned int)floor(real_value + 0.5), pack_error); + { + unsigned int int_value = (unsigned int)floor(real_value + 0.5); + _uint_range.validate(int_value, pack_error); + do_pack_uint8(pack_data.get_write_pointer(1), int_value, pack_error); + } break; case ST_uint16: - do_pack_uint16(pack_data.get_write_pointer(2), - (unsigned int)floor(real_value + 0.5), pack_error); + { + unsigned int int_value = (unsigned int)floor(real_value + 0.5); + _uint_range.validate(int_value, pack_error); + do_pack_uint16(pack_data.get_write_pointer(2), int_value, pack_error); + } break; case ST_uint32: - do_pack_uint32(pack_data.get_write_pointer(4), - (unsigned int)floor(real_value + 0.5), pack_error); + { + unsigned int int_value = (unsigned int)floor(real_value + 0.5); + _uint_range.validate(int_value, pack_error); + do_pack_uint32(pack_data.get_write_pointer(4), int_value, pack_error); + } break; case ST_uint64: - do_pack_uint64(pack_data.get_write_pointer(8), - (PN_uint64)floor(real_value + 0.5), pack_error); + { + PN_uint64 int64_value = (PN_uint64)floor(real_value + 0.5); + _uint64_range.validate(int64_value, pack_error); + do_pack_uint64(pack_data.get_write_pointer(8), int64_value, pack_error); + } break; case ST_float64: + _double_range.validate(real_value, pack_error); do_pack_float64(pack_data.get_write_pointer(8), real_value, pack_error); break; @@ -386,38 +484,47 @@ pack_int(DCPackData &pack_data, int value) const { switch (_type) { case ST_int8: + _int_range.validate(int_value, pack_error); do_pack_int8(pack_data.get_write_pointer(1), int_value, pack_error); break; case ST_int16: + _int_range.validate(int_value, pack_error); do_pack_int16(pack_data.get_write_pointer(2), int_value, pack_error); break; case ST_int32: + _int_range.validate(int_value, pack_error); do_pack_int32(pack_data.get_write_pointer(4), int_value, pack_error); break; case ST_int64: + _int64_range.validate(int_value, pack_error); do_pack_int64(pack_data.get_write_pointer(8), int_value, pack_error); break; case ST_uint8: + _uint_range.validate((unsigned int)int_value, pack_error); do_pack_uint8(pack_data.get_write_pointer(1), (unsigned int)int_value, pack_error); break; case ST_uint16: + _uint_range.validate((unsigned int)int_value, pack_error); do_pack_uint16(pack_data.get_write_pointer(2), (unsigned int)int_value, pack_error); break; case ST_uint32: + _uint_range.validate((unsigned int)int_value, pack_error); do_pack_uint32(pack_data.get_write_pointer(4), (unsigned int)int_value, pack_error); break; case ST_uint64: + _uint64_range.validate((unsigned int)int_value, pack_error); do_pack_uint64(pack_data.get_write_pointer(8), (unsigned int)int_value, pack_error); break; case ST_float64: + _double_range.validate(int_value, pack_error); do_pack_float64(pack_data.get_write_pointer(8), int_value, pack_error); break; @@ -441,39 +548,48 @@ pack_uint(DCPackData &pack_data, unsigned int value) const { switch (_type) { case ST_int8: + _int_range.validate((int)int_value, pack_error); do_pack_int8(pack_data.get_write_pointer(1), (int)int_value, pack_error); break; case ST_int16: + _int_range.validate((int)int_value, pack_error); do_pack_int16(pack_data.get_write_pointer(2), (int)int_value, pack_error); break; case ST_int32: + _int_range.validate((int)int_value, pack_error); do_pack_int32(pack_data.get_write_pointer(4), (int)int_value, pack_error); break; case ST_int64: + _int64_range.validate((int)int_value, pack_error); do_pack_int64(pack_data.get_write_pointer(8), (int)int_value, pack_error); break; case ST_uint8: + _uint_range.validate(int_value, pack_error); do_pack_uint8(pack_data.get_write_pointer(1), int_value, pack_error); break; case ST_uint16: + _uint_range.validate(int_value, pack_error); do_pack_uint16(pack_data.get_write_pointer(2), int_value, pack_error); break; case ST_uint32: + _uint_range.validate(int_value, pack_error); do_pack_uint32(pack_data.get_write_pointer(4), int_value, pack_error); break; case ST_uint64: + _uint64_range.validate(int_value, pack_error); do_pack_uint64(pack_data.get_write_pointer(8), int_value, pack_error); break; case ST_float64: - do_pack_float64(pack_data.get_write_pointer(8), (double)int_value, pack_error); + _double_range.validate(int_value, pack_error); + do_pack_float64(pack_data.get_write_pointer(8), int_value, pack_error); break; default: @@ -496,38 +612,47 @@ pack_int64(DCPackData &pack_data, PN_int64 value) const { switch (_type) { case ST_int8: + _int_range.validate((int)int_value, pack_error); do_pack_int8(pack_data.get_write_pointer(1), (int)int_value, pack_error); break; case ST_int16: + _int_range.validate((int)int_value, pack_error); do_pack_int16(pack_data.get_write_pointer(2), (int)int_value, pack_error); break; case ST_int32: + _int_range.validate((int)int_value, pack_error); do_pack_int32(pack_data.get_write_pointer(4), (int)int_value, pack_error); break; case ST_int64: + _int64_range.validate(int_value, pack_error); do_pack_int64(pack_data.get_write_pointer(8), int_value, pack_error); break; case ST_uint8: + _uint_range.validate((unsigned int)(PN_uint64)int_value, pack_error); do_pack_uint8(pack_data.get_write_pointer(1), (unsigned int)(PN_uint64)int_value, pack_error); break; case ST_uint16: + _uint_range.validate((unsigned int)(PN_uint64)int_value, pack_error); do_pack_uint16(pack_data.get_write_pointer(2), (unsigned int)(PN_uint64)int_value, pack_error); break; case ST_uint32: + _uint_range.validate((unsigned int)(PN_uint64)int_value, pack_error); do_pack_uint32(pack_data.get_write_pointer(4), (unsigned int)(PN_uint64)int_value, pack_error); break; case ST_uint64: + _uint64_range.validate((PN_uint64)int_value, pack_error); do_pack_uint64(pack_data.get_write_pointer(8), (PN_uint64)int_value, pack_error); break; case ST_float64: + _double_range.validate((double)int_value, pack_error); do_pack_float64(pack_data.get_write_pointer(8), (double)int_value, pack_error); break; @@ -551,38 +676,47 @@ pack_uint64(DCPackData &pack_data, PN_uint64 value) const { switch (_type) { case ST_int8: + _int_range.validate((int)(PN_int64)int_value, pack_error); do_pack_int8(pack_data.get_write_pointer(1), (int)(PN_int64)int_value, pack_error); break; case ST_int16: + _int_range.validate((int)(PN_int64)int_value, pack_error); do_pack_int16(pack_data.get_write_pointer(2), (int)(PN_int64)int_value, pack_error); break; case ST_int32: + _int_range.validate((int)(PN_int64)int_value, pack_error); do_pack_int32(pack_data.get_write_pointer(4), (int)(PN_int64)int_value, pack_error); break; case ST_int64: + _int64_range.validate((PN_int64)int_value, pack_error); do_pack_int64(pack_data.get_write_pointer(8), (PN_int64)int_value, pack_error); break; case ST_uint8: + _uint_range.validate((unsigned int)int_value, pack_error); do_pack_uint8(pack_data.get_write_pointer(1), (unsigned int)int_value, pack_error); break; case ST_uint16: + _uint_range.validate((unsigned int)int_value, pack_error); do_pack_uint16(pack_data.get_write_pointer(2), (unsigned int)int_value, pack_error); break; case ST_uint32: + _uint_range.validate((unsigned int)int_value, pack_error); do_pack_uint32(pack_data.get_write_pointer(4), (unsigned int)int_value, pack_error); break; case ST_uint64: + _uint64_range.validate(int_value, pack_error); do_pack_uint64(pack_data.get_write_pointer(8), int_value, pack_error); break; case ST_float64: + _double_range.validate((double)int_value, pack_error); do_pack_float64(pack_data.get_write_pointer(8), (double)int_value, pack_error); break; @@ -602,19 +736,21 @@ pack_uint64(DCPackData &pack_data, PN_uint64 value) const { bool DCSimpleParameter:: pack_string(DCPackData &pack_data, const string &value) const { bool pack_error = false; + size_t string_length = value.length(); + _uint_range.validate(string_length, pack_error); switch (_type) { case ST_string: case ST_blob: - do_pack_uint16(pack_data.get_write_pointer(2), value.length(), + do_pack_uint16(pack_data.get_write_pointer(2), string_length, pack_error); - pack_data.append_data(value.data(), value.length()); + pack_data.append_data(value.data(), string_length); break; case ST_blob32: - do_pack_uint32(pack_data.get_write_pointer(4), value.length(), + do_pack_uint32(pack_data.get_write_pointer(4), string_length, pack_error); - pack_data.append_data(value.data(), value.length()); + pack_data.append_data(value.data(), string_length); break; default: @@ -1197,11 +1333,62 @@ output_instance(ostream &out, const string &prename, const string &name, const string &postname) const { if (get_typedef() != (DCTypedef *)NULL) { out << get_typedef()->get_name(); + } else { out << _type; - } - if (_divisor != 1) { - out << "/" << _divisor; + if (_divisor != 1) { + out << "/" << _divisor; + } + + + switch (_type) { + case ST_int8: + case ST_int16: + case ST_int32: + if (!_int_range.is_empty()) { + out << "("; + _int_range.output(out, _divisor); + out << ")"; + } + break; + + case ST_int64: + if (!_int64_range.is_empty()) { + out << "("; + _int64_range.output(out, _divisor); + out << ")"; + } + break; + + case ST_uint8: + case ST_uint16: + case ST_uint32: + if (!_uint_range.is_empty()) { + out << "("; + _uint_range.output(out, _divisor); + out << ")"; + } + break; + + case ST_uint64: + if (!_uint64_range.is_empty()) { + out << "("; + _uint64_range.output(out, _divisor); + out << ")"; + } + break; + + case ST_float64: + if (!_double_range.is_empty()) { + out << "("; + _double_range.output(out, _divisor); + out << ")"; + } + break; + + default: + break; + } } if (!prename.empty() || !name.empty() || !postname.empty()) { diff --git a/direct/src/dcparser/dcSimpleParameter.h b/direct/src/dcparser/dcSimpleParameter.h index eab6191848..a84bedac89 100644 --- a/direct/src/dcparser/dcSimpleParameter.h +++ b/direct/src/dcparser/dcSimpleParameter.h @@ -22,6 +22,7 @@ #include "dcbase.h" #include "dcParameter.h" #include "dcSubatomicType.h" +#include "dcNumericRange.h" //////////////////////////////////////////////////////////////////// // Class : DCSimpleParameter @@ -47,6 +48,7 @@ PUBLISHED: public: bool set_divisor(int divisor); + void set_range(const DCDoubleRange &range); virtual int calc_num_nested_fields(size_t length_bytes) const; virtual DCPackerInterface *get_nested_field(int n) const; @@ -98,6 +100,12 @@ private: DCSimpleParameter *_uint8_type; }; + DCIntRange _int_range; + DCUnsignedIntRange _uint_range; + DCInt64Range _int64_range; + DCUnsignedInt64Range _uint64_range; + DCDoubleRange _double_range; + static Uint32Uint8Type *_uint32uint8_type; }; diff --git a/direct/src/dcparser/dcbase.h b/direct/src/dcparser/dcbase.h index b672b3b044..355ed8ee1a 100644 --- a/direct/src/dcparser/dcbase.h +++ b/direct/src/dcparser/dcbase.h @@ -67,6 +67,7 @@ using namespace std; #define INLINE inline +#define TYPENAME typename // These symbols are used within the Panda environment for exporting // classes and functions to the scripting language. They're largely