From 840f28ef182b703d08dcb028dd3809b20846ffae Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 19 Dec 2018 12:43:39 +0100 Subject: [PATCH 01/33] glgsg: fix framebuffer_copy_to_ram format for float framebuffers --- .../src/glstuff/glGraphicsStateGuardian_src.cxx | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx index 7974a9345c..df2095284c 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx @@ -7049,6 +7049,16 @@ framebuffer_copy_to_ram(Texture *tex, int view, int z, } else { format = Texture::F_srgb; } + } else if (_current_properties->get_float_color()) { + if (_current_properties->get_alpha_bits()) { + format = Texture::F_rgba32; + } else if (_current_properties->get_blue_bits()) { + format = Texture::F_rgb32; + } else if (_current_properties->get_green_bits()) { + format = Texture::F_rg32; + } else { + format = Texture::F_r32; + } } else { if (_current_properties->get_alpha_bits()) { format = Texture::F_rgba; @@ -7058,7 +7068,11 @@ framebuffer_copy_to_ram(Texture *tex, int view, int z, } if (_current_properties->get_float_color()) { component_type = Texture::T_float; - } else if (_current_properties->get_color_bits() <= 24) { + } else if (_current_properties->get_color_bits() <= 24 + && _current_properties->get_red_bits() <= 8 + && _current_properties->get_green_bits() <= 8 + && _current_properties->get_blue_bits() <= 8 + && _current_properties->get_alpha_bits() <= 8) { component_type = Texture::T_unsigned_byte; } else { component_type = Texture::T_unsigned_short; From e4f493b872c16f6b242db29a654db2c898f06fb3 Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 19 Dec 2018 12:45:32 +0100 Subject: [PATCH 02/33] dcparser: use vector_uchar for blobs, step towards Python 3 compat Closes #298 --- direct/src/dcparser/dcArrayParameter.cxx | 72 + direct/src/dcparser/dcArrayParameter.h | 4 + direct/src/dcparser/dcAtomicField.cxx | 10 +- direct/src/dcparser/dcAtomicField.h | 2 +- direct/src/dcparser/dcClass.cxx | 11 +- direct/src/dcparser/dcClass.h | 2 +- direct/src/dcparser/dcField.I | 6 +- direct/src/dcparser/dcField.cxx | 19 +- direct/src/dcparser/dcField.h | 12 +- direct/src/dcparser/dcLexer.cxx.prebuilt | 378 +-- direct/src/dcparser/dcLexer.lxx | 62 +- direct/src/dcparser/dcPacker.I | 120 +- direct/src/dcparser/dcPacker.cxx | 18 +- direct/src/dcparser/dcPacker.h | 19 +- direct/src/dcparser/dcPackerInterface.cxx | 16 + direct/src/dcparser/dcPackerInterface.h | 9 +- direct/src/dcparser/dcParser.cxx.prebuilt | 2864 ++++++++--------- direct/src/dcparser/dcParser.h.prebuilt | 129 +- direct/src/dcparser/dcParser.yxx | 55 +- direct/src/dcparser/dcParserDefs.h | 2 + direct/src/dcparser/dcSimpleParameter.cxx | 119 + direct/src/dcparser/dcSimpleParameter.h | 4 + direct/src/dcparser/dcSwitch.cxx | 15 +- direct/src/dcparser/dcSwitch.h | 12 +- direct/src/dcparser/hashGenerator.cxx | 12 + direct/src/dcparser/hashGenerator.h | 2 + .../src/distributed/cConnectionRepository.cxx | 2 +- 27 files changed, 2016 insertions(+), 1960 deletions(-) diff --git a/direct/src/dcparser/dcArrayParameter.cxx b/direct/src/dcparser/dcArrayParameter.cxx index 2f2ea69932..c2c73635a2 100644 --- a/direct/src/dcparser/dcArrayParameter.cxx +++ b/direct/src/dcparser/dcArrayParameter.cxx @@ -262,6 +262,38 @@ pack_string(DCPackData &pack_data, const string &value, } } +/** + * Packs the indicated numeric or string value into the stream. + */ +void DCArrayParameter:: +pack_blob(DCPackData &pack_data, const vector_uchar &value, + bool &pack_error, bool &range_error) const { + // We can only pack a string if the array element type is char or int8. + DCSimpleParameter *simple_type = _element_type->as_simple_parameter(); + if (simple_type == nullptr) { + pack_error = true; + return; + } + + size_t blob_size = value.size(); + + switch (simple_type->get_type()) { + case ST_char: + case ST_uint8: + case ST_int8: + _array_size_range.validate(blob_size, range_error); + if (_num_length_bytes != 0) { + nassertv(_num_length_bytes == 2); + do_pack_uint16(pack_data.get_write_pointer(2), blob_size); + } + pack_data.append_data((const char *)value.data(), blob_size); + break; + + default: + pack_error = true; + } +} + /** * Packs the arrayParameter's specified default value (or a sensible default * if no value is specified) into the stream. Returns true if the default @@ -339,6 +371,46 @@ unpack_string(const char *data, size_t length, size_t &p, string &value, } } +/** + * Unpacks the current numeric or string value from the stream. + */ +void DCArrayParameter:: +unpack_blob(const char *data, size_t length, size_t &p, vector_uchar &value, + bool &pack_error, bool &range_error) const { + // We can only unpack a string if the array element type is char or int8. + DCSimpleParameter *simple_type = _element_type->as_simple_parameter(); + if (simple_type == nullptr) { + pack_error = true; + return; + } + + size_t blob_size; + + switch (simple_type->get_type()) { + case ST_char: + case ST_uint8: + case ST_int8: + if (_num_length_bytes != 0) { + blob_size = do_unpack_uint16(data + p); + p += 2; + } else { + nassertv(_array_size >= 0); + blob_size = _array_size; + } + if (p + blob_size > length) { + pack_error = true; + return; + } + value = vector_uchar((const unsigned char *)data + p, + (const unsigned char *)data + p + blob_size); + p += blob_size; + break; + + default: + pack_error = true; + } +} + /** * 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 diff --git a/direct/src/dcparser/dcArrayParameter.h b/direct/src/dcparser/dcArrayParameter.h index 97fb32bdf0..d81707a9e6 100644 --- a/direct/src/dcparser/dcArrayParameter.h +++ b/direct/src/dcparser/dcArrayParameter.h @@ -51,9 +51,13 @@ public: virtual void generate_hash(HashGenerator &hashgen) const; virtual void pack_string(DCPackData &pack_data, const std::string &value, bool &pack_error, bool &range_error) const; + virtual void pack_blob(DCPackData &pack_data, const vector_uchar &value, + bool &pack_error, bool &range_error) const; virtual bool pack_default_value(DCPackData &pack_data, bool &pack_error) const; virtual void unpack_string(const char *data, size_t length, size_t &p, std::string &value, bool &pack_error, bool &range_error) const; + virtual void unpack_blob(const char *data, size_t length, size_t &p, + vector_uchar &value, bool &pack_error, bool &range_error) const; protected: virtual bool do_check_match(const DCPackerInterface *other) const; diff --git a/direct/src/dcparser/dcAtomicField.cxx b/direct/src/dcparser/dcAtomicField.cxx index 3efebfa2d6..eb5607e55c 100644 --- a/direct/src/dcparser/dcAtomicField.cxx +++ b/direct/src/dcparser/dcAtomicField.cxx @@ -88,11 +88,11 @@ get_element(int n) const { * If the element is an array-type element, the returned value will include * the two-byte length preceding the array data. * - * This is deprecated; use get_element() instead. + * @deprecated use get_element() instead. */ -string DCAtomicField:: +vector_uchar DCAtomicField:: get_element_default(int n) const { - nassertr(n >= 0 && n < (int)_elements.size(), string()); + nassertr(n >= 0 && n < (int)_elements.size(), vector_uchar()); return _elements[n]->get_default_value(); } @@ -100,7 +100,7 @@ get_element_default(int n) const { * Returns true if the nth element of the field has a default value specified, * false otherwise. * - * This is deprecated; use get_element() instead. + * @deprecated use get_element() instead. */ bool DCAtomicField:: has_element_default(int n) const { @@ -113,7 +113,7 @@ has_element_default(int n) const { * for documentary purposes; it does not generally affect operation. If a * name is not specified, this will be the empty string. * - * This method is deprecated; use get_element()->get_name() instead. + * @deprecated use get_element()->get_name() instead. */ string DCAtomicField:: get_element_name(int n) const { diff --git a/direct/src/dcparser/dcAtomicField.h b/direct/src/dcparser/dcAtomicField.h index 9eb92e2527..418b1b768f 100644 --- a/direct/src/dcparser/dcAtomicField.h +++ b/direct/src/dcparser/dcAtomicField.h @@ -40,7 +40,7 @@ PUBLISHED: DCParameter *get_element(int n) const; // These five methods are deprecated and will be removed soon. - std::string get_element_default(int n) const; + vector_uchar get_element_default(int n) const; bool has_element_default(int n) const; std::string get_element_name(int n) const; DCSubatomicType get_element_type(int n) const; diff --git a/direct/src/dcparser/dcClass.cxx b/direct/src/dcparser/dcClass.cxx index 374ed47d3c..9487c5e323 100644 --- a/direct/src/dcparser/dcClass.cxx +++ b/direct/src/dcparser/dcClass.cxx @@ -587,7 +587,7 @@ receive_update_other(PyObject *distobj, DatagramIterator &di) const { */ void DCClass:: direct_update(PyObject *distobj, const string &field_name, - const string &value_blob) { + const vector_uchar &value_blob) { DCField *field = get_field_by_name(field_name); nassertv_always(field != nullptr); @@ -606,7 +606,14 @@ direct_update(PyObject *distobj, const string &field_name, void DCClass:: direct_update(PyObject *distobj, const string &field_name, const Datagram &datagram) { - direct_update(distobj, field_name, datagram.get_message()); + DCField *field = get_field_by_name(field_name); + nassertv_always(field != nullptr); + + DCPacker packer; + packer.set_unpack_data((const char *)datagram.get_data(), datagram.get_length(), false); + packer.begin_unpack(field); + field->receive_update(packer, distobj); + packer.end_unpack(); } #endif // HAVE_PYTHON diff --git a/direct/src/dcparser/dcClass.h b/direct/src/dcparser/dcClass.h index cd69716470..94feae1c19 100644 --- a/direct/src/dcparser/dcClass.h +++ b/direct/src/dcparser/dcClass.h @@ -95,7 +95,7 @@ PUBLISHED: void receive_update_other(PyObject *distobj, DatagramIterator &di) const; void direct_update(PyObject *distobj, const std::string &field_name, - const std::string &value_blob); + const vector_uchar &value_blob); void direct_update(PyObject *distobj, const std::string &field_name, const Datagram &datagram); bool pack_required_field(Datagram &datagram, PyObject *distobj, diff --git a/direct/src/dcparser/dcField.I b/direct/src/dcparser/dcField.I index aabf5cf114..e6aa4a4672 100644 --- a/direct/src/dcparser/dcField.I +++ b/direct/src/dcparser/dcField.I @@ -42,7 +42,7 @@ has_default_value() const { * explicitly set (e.g. has_default_value() returns true), returns that * value; otherwise, returns an implicit default for the field. */ -INLINE const std::string &DCField:: +INLINE const vector_uchar &DCField:: get_default_value() const { if (_default_value_stale) { ((DCField *)this)->refresh_default_value(); @@ -172,8 +172,8 @@ set_class(DCClass *dclass) { * Establishes a default value for this field. */ INLINE void DCField:: -set_default_value(const std::string &default_value) { - _default_value = default_value; +set_default_value(vector_uchar default_value) { + _default_value = std::move(default_value); _has_default_value = true; _default_value_stale = false; } diff --git a/direct/src/dcparser/dcField.cxx b/direct/src/dcparser/dcField.cxx index 4f255dea7d..5880fd5097 100644 --- a/direct/src/dcparser/dcField.cxx +++ b/direct/src/dcparser/dcField.cxx @@ -162,7 +162,7 @@ as_parameter() const { * is an error. */ string DCField:: -format_data(const string &packed_data, bool show_field_names) { +format_data(const vector_uchar &packed_data, bool show_field_names) { DCPacker packer; packer.set_unpack_data(packed_data); packer.begin_unpack(this); @@ -178,20 +178,20 @@ format_data(const string &packed_data, bool show_field_names) { * above) that represents the value of this field, parse the string and return * the corresponding packed data. Returns empty string if there is an error. */ -string DCField:: +vector_uchar DCField:: parse_string(const string &formatted_string) { DCPacker packer; packer.begin_pack(this); if (!packer.parse_and_pack(formatted_string)) { // Parse error. - return string(); + return vector_uchar(); } if (!packer.end_pack()) { // Data type mismatch. - return string(); + return vector_uchar(); } - return packer.get_string(); + return packer.get_bytes(); } /** @@ -200,7 +200,7 @@ parse_string(const string &formatted_string) { * record. Returns true if all fields are valid, false otherwise. */ bool DCField:: -validate_ranges(const string &packed_data) const { +validate_ranges(const vector_uchar &packed_data) const { DCPacker packer; packer.set_unpack_data(packed_data); packer.begin_unpack(this); @@ -209,7 +209,7 @@ validate_ranges(const string &packed_data) const { return false; } - return (packer.get_num_unpacked_bytes() == packed_data.length()); + return (packer.get_num_unpacked_bytes() == packed_data.size()); } #ifdef HAVE_PYTHON @@ -488,7 +488,7 @@ pack_default_value(DCPackData &pack_data, bool &) const { // The default behavior is to pack the default value if we got it; // otherwise, to return false and let the packer visit our nested elements. if (!_default_value_stale) { - pack_data.append_data(_default_value.data(), _default_value.length()); + pack_data.append_data((const char *)_default_value.data(), _default_value.size()); return true; } @@ -566,7 +566,8 @@ refresh_default_value() { if (!packer.end_pack()) { std::cerr << "Error while packing default value for " << get_name() << "\n"; } else { - _default_value.assign(packer.get_data(), packer.get_length()); + const unsigned char *data = (const unsigned char *)packer.get_data(); + _default_value = vector_uchar(data, data + packer.get_length()); } _default_value_stale = false; } diff --git a/direct/src/dcparser/dcField.h b/direct/src/dcparser/dcField.h index dc06ff76f2..96b7da4487 100644 --- a/direct/src/dcparser/dcField.h +++ b/direct/src/dcparser/dcField.h @@ -53,13 +53,13 @@ PUBLISHED: virtual DCParameter *as_parameter(); virtual const DCParameter *as_parameter() const; - std::string format_data(const std::string &packed_data, bool show_field_names = true); - std::string parse_string(const std::string &formatted_string); + std::string format_data(const vector_uchar &packed_data, bool show_field_names = true); + vector_uchar parse_string(const std::string &formatted_string); - bool validate_ranges(const std::string &packed_data) const; + bool validate_ranges(const vector_uchar &packed_data) const; INLINE bool has_default_value() const; - INLINE const std::string &get_default_value() const; + INLINE const vector_uchar &get_default_value() const; INLINE bool is_bogus_field() const; @@ -98,7 +98,7 @@ public: INLINE void set_number(int number); INLINE void set_class(DCClass *dclass); - INLINE void set_default_value(const std::string &default_value); + INLINE void set_default_value(vector_uchar default_value); #ifdef HAVE_PYTHON static std::string get_pystr(PyObject *value); @@ -115,7 +115,7 @@ protected: bool _bogus_field; private: - std::string _default_value; + vector_uchar _default_value; #ifdef WITHIN_PANDA PStatCollector _field_update_pcollector; diff --git a/direct/src/dcparser/dcLexer.cxx.prebuilt b/direct/src/dcparser/dcLexer.cxx.prebuilt index 660f96b5cb..fece97f2ae 100644 --- a/direct/src/dcparser/dcLexer.cxx.prebuilt +++ b/direct/src/dcparser/dcLexer.cxx.prebuilt @@ -1,6 +1,6 @@ -#line 2 "lex.yy.c" +#line 2 "built/tmp/dcLexer.lxx.cxx" -#line 4 "lex.yy.c" +#line 4 "built/tmp/dcLexer.lxx.cxx" #define YY_INT_ALIGNED short int @@ -28,13 +28,23 @@ #define FLEX_SCANNER #define YY_FLEX_MAJOR_VERSION 2 #define YY_FLEX_MINOR_VERSION 5 -#define YY_FLEX_SUBMINOR_VERSION 35 +#define YY_FLEX_SUBMINOR_VERSION 37 #if YY_FLEX_SUBMINOR_VERSION > 0 #define FLEX_BETA #endif /* First, we deal with platform-specific or compiler-specific issues. */ +#if defined(__FreeBSD__) +#ifndef __STDC_LIMIT_MACROS +#define __STDC_LIMIT_MACROS +#endif +#include +#include +#else +#define __dead2 +#endif + /* begin standard C headers. */ #include #include @@ -50,10 +60,11 @@ /* C99 systems have . Non-C99 systems may or may not. */ -#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L +#if defined(__FreeBSD__) || \ + (defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h, - * if you want the limit (max/min) macros for int types. + * if you want the limit (max/min) macros for int types. */ #ifndef __STDC_LIMIT_MACROS #define __STDC_LIMIT_MACROS 1 @@ -70,10 +81,9 @@ typedef uint32_t flex_uint32_t; typedef signed char flex_int8_t; typedef short int flex_int16_t; typedef int flex_int32_t; -typedef unsigned char flex_uint8_t; +typedef unsigned char flex_uint8_t; typedef unsigned short int flex_uint16_t; typedef unsigned int flex_uint32_t; -#endif /* ! C99 */ /* Limits of integral types. */ #ifndef INT8_MIN @@ -104,6 +114,8 @@ typedef unsigned int flex_uint32_t; #define UINT32_MAX (4294967295U) #endif +#endif /* ! C99 */ + #endif /* ! FLEXINT_H */ #ifdef __cplusplus @@ -172,7 +184,12 @@ typedef unsigned int flex_uint32_t; typedef struct yy_buffer_state *YY_BUFFER_STATE; #endif -extern int dcyyleng; +#ifndef YY_TYPEDEF_YY_SIZE_T +#define YY_TYPEDEF_YY_SIZE_T +typedef size_t yy_size_t; +#endif + +extern yy_size_t dcyyleng; extern FILE *dcyyin, *dcyyout; @@ -181,7 +198,7 @@ extern FILE *dcyyin, *dcyyout; #define EOB_ACT_LAST_MATCH 2 #define YY_LESS_LINENO(n) - + /* Return all but the first "n" matched characters back to the input stream. */ #define yyless(n) \ do \ @@ -198,11 +215,6 @@ extern FILE *dcyyin, *dcyyout; #define unput(c) yyunput( c, (yytext_ptr) ) -#ifndef YY_TYPEDEF_YY_SIZE_T -#define YY_TYPEDEF_YY_SIZE_T -typedef size_t yy_size_t; -#endif - #ifndef YY_STRUCT_YY_BUFFER_STATE #define YY_STRUCT_YY_BUFFER_STATE struct yy_buffer_state @@ -220,7 +232,7 @@ struct yy_buffer_state /* Number of characters read into yy_ch_buf, not including EOB * characters. */ - int yy_n_chars; + yy_size_t yy_n_chars; /* Whether we "own" the buffer - i.e., we know we created it, * and can realloc() it to grow it, and should free() it to @@ -243,7 +255,7 @@ struct yy_buffer_state int yy_bs_lineno; /**< The line count. */ int yy_bs_column; /**< The column count. */ - + /* Whether to try to fill the input buffer when we reach the * end of it. */ @@ -282,6 +294,7 @@ static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */ #define YY_CURRENT_BUFFER ( (yy_buffer_stack) \ ? (yy_buffer_stack)[(yy_buffer_stack_top)] \ : NULL) +#define yy_current_buffer YY_CURRENT_BUFFER /* Same as previous macro, but useful when we know that the buffer stack is not * NULL or when we need an lvalue. For internal use only. @@ -290,8 +303,8 @@ static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */ /* yy_hold_char holds the character lost when dcyytext is formed. */ static char yy_hold_char; -static int yy_n_chars; /* number of characters read into yy_ch_buf */ -int dcyyleng; +static yy_size_t yy_n_chars; /* number of characters read into yy_ch_buf */ +yy_size_t dcyyleng; /* Points to current character in buffer. */ static char *yy_c_buf_p = (char *) 0; @@ -319,7 +332,7 @@ static void dcyy_init_buffer (YY_BUFFER_STATE b,FILE *file ); YY_BUFFER_STATE dcyy_scan_buffer (char *base,yy_size_t size ); YY_BUFFER_STATE dcyy_scan_string (yyconst char *yy_str ); -YY_BUFFER_STATE dcyy_scan_bytes (yyconst char *bytes,int len ); +YY_BUFFER_STATE dcyy_scan_bytes (yyconst char *bytes,yy_size_t len ); void *dcyyalloc (yy_size_t ); void *dcyyrealloc (void *,yy_size_t ); @@ -365,7 +378,7 @@ extern char *dcyytext; static yy_state_type yy_get_previous_state (void ); static yy_state_type yy_try_NUL_trans (yy_state_type current_state ); static int yy_get_next_buffer (void ); -static void yy_fatal_error (yyconst char msg[] ); +static void yy_fatal_error (yyconst char msg[] ) __dead2; /* Done after the current pattern has been matched and before the * corresponding action - sets up dcyytext. @@ -573,14 +586,14 @@ int dcyy_flex_debug = 0; #define YY_MORE_ADJ 0 #define YY_RESTORE_YY_MORE_OFFSET char *dcyytext; -#line 1 "dcLexer.lxx" +#line 1 "direct/src/dcparser/dcLexer.lxx" /* // Filename: dcLexer.lxx // Created by: drose (05Oct00) -// +// //////////////////////////////////////////////////////////////////// */ -#line 9 "dcLexer.lxx" +#line 9 "direct/src/dcparser/dcLexer.lxx" #include "dcLexerDefs.h" #include "dcParserDefs.h" #include "dcParser.h" @@ -678,12 +691,12 @@ dcyyerror(const std::string &msg) { if (!dc_filename.empty()) { cerr << " in " << dc_filename; } - cerr + cerr << " at line " << line_number << ", column " << col_number << ":\n" << current_line << "\n"; - indent(cerr, col_number-1) + indent(cerr, col_number-1) << "^\n" << msg << "\n\n"; - + error_count++; } @@ -695,10 +708,10 @@ dcyywarning(const std::string &msg) { if (!dc_filename.empty()) { cerr << " in " << dc_filename; } - cerr + cerr << " at line " << line_number << ", column " << col_number << ":\n" << current_line << "\n"; - indent(cerr, col_number-1) + indent(cerr, col_number-1) << "^\n" << msg << "\n\n"; warning_count++; @@ -708,7 +721,7 @@ dcyywarning(const std::string &msg) { // stdio FILE pointer. This is flex-specific. static void input_chars(char *buffer, int &result, int max_size) { - nassertv(input_p != NULL); + nassertv(input_p != nullptr); if (*input_p) { input_p->read(buffer, max_size); result = input_p->gcount(); @@ -729,7 +742,7 @@ input_chars(char *buffer, int &result, int max_size) { // Truncate it at the newline. char *end = strchr(current_line, '\n'); - if (end != NULL) { + if (end != nullptr) { *end = '\0'; } } @@ -888,9 +901,9 @@ scan_quoted_string(char quote_mark) { // scan_hex_string reads a string of hexadecimal digits delimited by // angle brackets and returns the representative string. -static std::string +static vector_uchar scan_hex_string() { - std::string result; + vector_uchar result; // We don't touch the current line number and column number during // scanning, so that if we detect an error while scanning the string @@ -920,24 +933,24 @@ scan_hex_string() { line_number = line; col_number = col; dcyyerror("Invalid hex digit."); - return std::string(); + return vector_uchar(); } odd = !odd; if (odd) { last = value; } else { - result += (char)((last << 4) | value); + result.push_back((unsigned char)((last << 4) | value)); } c = read_char(line, col); } if (c == EOF) { dcyyerror("This hex string is unterminated."); - return std::string(); + return vector_uchar(); } else if (odd) { dcyyerror("Odd number of hex digits."); - return std::string(); + return vector_uchar(); } line_number = line; @@ -957,7 +970,7 @@ eat_c_comment() { int col = col_number; int c, last_c; - + last_c = '\0'; c = read_char(line, col); while (c != EOF && !(last_c == '*' && c == '/')) { @@ -984,7 +997,7 @@ inline void accept() { col_number += dcyyleng; } -#line 984 "lex.yy.c" +#line 1001 "built/tmp/dcLexer.lxx.cxx" #define INITIAL 0 @@ -993,6 +1006,7 @@ inline void accept() { * down here because we want the user's section 1 to have been scanned first. * The user has a chance to override it with an option. */ +#include #endif #ifndef YY_EXTRA_TYPE @@ -1022,7 +1036,7 @@ FILE *dcyyget_out (void ); void dcyyset_out (FILE * out_str ); -int dcyyget_leng (void ); +yy_size_t dcyyget_leng (void ); char *dcyyget_text (void ); @@ -1042,8 +1056,10 @@ extern int dcyywrap (void ); #endif #endif +#ifndef YY_NO_UNPUT static void yyunput (int c,char *buf_ptr ); - +#endif + #ifndef yytext_ptr static void yy_flex_strncpy (char *,yyconst char *,int ); #endif @@ -1072,7 +1088,7 @@ static int input (void ); /* This used to be an fputs(), but since the string might contain NUL's, * we now use fwrite(). */ -#define ECHO fwrite( dcyytext, dcyyleng, 1, dcyyout ) +#define ECHO do { if (fwrite( dcyytext, dcyyleng, 1, dcyyout )) {} } while (0) #endif /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL, @@ -1083,7 +1099,7 @@ static int input (void ); if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \ { \ int c = '*'; \ - int n; \ + size_t n; \ for ( n = 0; n < max_size && \ (c = getc( dcyyin )) != EOF && c != '\n'; ++n ) \ buf[n] = (char) c; \ @@ -1161,11 +1177,11 @@ extern int dcyylex (void); */ YY_DECL { - register yy_state_type yy_current_state; - register char *yy_cp, *yy_bp; - register int yy_act; - -#line 415 "dcLexer.lxx" + yy_state_type yy_current_state; + char *yy_cp, *yy_bp; + int yy_act; + +#line 419 "direct/src/dcparser/dcLexer.lxx" @@ -1176,7 +1192,7 @@ YY_DECL } -#line 1177 "lex.yy.c" +#line 1196 "built/tmp/dcLexer.lxx.cxx" if ( !(yy_init) ) { @@ -1220,7 +1236,7 @@ YY_DECL yy_match: do { - register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)]; + YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ; if ( yy_accept[yy_current_state] ) { (yy_last_accepting_state) = yy_current_state; @@ -1262,7 +1278,7 @@ do_action: /* This label is used only to access EOF actions. */ case 1: /* rule 1 can match eol */ YY_RULE_SETUP -#line 425 "dcLexer.lxx" +#line 429 "direct/src/dcparser/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. @@ -1279,32 +1295,32 @@ YY_RULE_SETUP YY_BREAK case 2: YY_RULE_SETUP -#line 439 "dcLexer.lxx" -{ +#line 443 "direct/src/dcparser/dcLexer.lxx" +{ // Eat whitespace. accept(); } YY_BREAK case 3: YY_RULE_SETUP -#line 444 "dcLexer.lxx" -{ +#line 448 "direct/src/dcparser/dcLexer.lxx" +{ // Eat C++-style comments. accept(); } YY_BREAK case 4: YY_RULE_SETUP -#line 449 "dcLexer.lxx" +#line 453 "direct/src/dcparser/dcLexer.lxx" { // Eat C-style comments. accept(); - eat_c_comment(); + eat_c_comment(); } YY_BREAK case 5: YY_RULE_SETUP -#line 456 "dcLexer.lxx" +#line 460 "direct/src/dcparser/dcLexer.lxx" { accept(); return KW_DCLASS; @@ -1312,7 +1328,7 @@ YY_RULE_SETUP YY_BREAK case 6: YY_RULE_SETUP -#line 461 "dcLexer.lxx" +#line 465 "direct/src/dcparser/dcLexer.lxx" { accept(); return KW_STRUCT; @@ -1320,7 +1336,7 @@ YY_RULE_SETUP YY_BREAK case 7: YY_RULE_SETUP -#line 466 "dcLexer.lxx" +#line 470 "direct/src/dcparser/dcLexer.lxx" { accept(); return KW_FROM; @@ -1328,7 +1344,7 @@ YY_RULE_SETUP YY_BREAK case 8: YY_RULE_SETUP -#line 471 "dcLexer.lxx" +#line 475 "direct/src/dcparser/dcLexer.lxx" { accept(); return KW_IMPORT; @@ -1336,7 +1352,7 @@ YY_RULE_SETUP YY_BREAK case 9: YY_RULE_SETUP -#line 476 "dcLexer.lxx" +#line 480 "direct/src/dcparser/dcLexer.lxx" { accept(); return KW_KEYWORD; @@ -1344,7 +1360,7 @@ YY_RULE_SETUP YY_BREAK case 10: YY_RULE_SETUP -#line 481 "dcLexer.lxx" +#line 485 "direct/src/dcparser/dcLexer.lxx" { accept(); return KW_TYPEDEF; @@ -1352,7 +1368,7 @@ YY_RULE_SETUP YY_BREAK case 11: YY_RULE_SETUP -#line 486 "dcLexer.lxx" +#line 490 "direct/src/dcparser/dcLexer.lxx" { accept(); return KW_SWITCH; @@ -1360,7 +1376,7 @@ YY_RULE_SETUP YY_BREAK case 12: YY_RULE_SETUP -#line 491 "dcLexer.lxx" +#line 495 "direct/src/dcparser/dcLexer.lxx" { accept(); return KW_CASE; @@ -1368,7 +1384,7 @@ YY_RULE_SETUP YY_BREAK case 13: YY_RULE_SETUP -#line 496 "dcLexer.lxx" +#line 500 "direct/src/dcparser/dcLexer.lxx" { accept(); return KW_DEFAULT; @@ -1376,7 +1392,7 @@ YY_RULE_SETUP YY_BREAK case 14: YY_RULE_SETUP -#line 501 "dcLexer.lxx" +#line 505 "direct/src/dcparser/dcLexer.lxx" { accept(); return KW_BREAK; @@ -1384,7 +1400,7 @@ YY_RULE_SETUP YY_BREAK case 15: YY_RULE_SETUP -#line 506 "dcLexer.lxx" +#line 510 "direct/src/dcparser/dcLexer.lxx" { accept(); return KW_INT8; @@ -1392,7 +1408,7 @@ YY_RULE_SETUP YY_BREAK case 16: YY_RULE_SETUP -#line 511 "dcLexer.lxx" +#line 515 "direct/src/dcparser/dcLexer.lxx" { accept(); return KW_INT16; @@ -1400,7 +1416,7 @@ YY_RULE_SETUP YY_BREAK case 17: YY_RULE_SETUP -#line 516 "dcLexer.lxx" +#line 520 "direct/src/dcparser/dcLexer.lxx" { accept(); return KW_INT32; @@ -1408,7 +1424,7 @@ YY_RULE_SETUP YY_BREAK case 18: YY_RULE_SETUP -#line 521 "dcLexer.lxx" +#line 525 "direct/src/dcparser/dcLexer.lxx" { accept(); return KW_INT64; @@ -1416,7 +1432,7 @@ YY_RULE_SETUP YY_BREAK case 19: YY_RULE_SETUP -#line 526 "dcLexer.lxx" +#line 530 "direct/src/dcparser/dcLexer.lxx" { accept(); return KW_UINT8; @@ -1424,7 +1440,7 @@ YY_RULE_SETUP YY_BREAK case 20: YY_RULE_SETUP -#line 531 "dcLexer.lxx" +#line 535 "direct/src/dcparser/dcLexer.lxx" { accept(); return KW_UINT16; @@ -1432,7 +1448,7 @@ YY_RULE_SETUP YY_BREAK case 21: YY_RULE_SETUP -#line 536 "dcLexer.lxx" +#line 540 "direct/src/dcparser/dcLexer.lxx" { accept(); return KW_UINT32; @@ -1440,7 +1456,7 @@ YY_RULE_SETUP YY_BREAK case 22: YY_RULE_SETUP -#line 541 "dcLexer.lxx" +#line 545 "direct/src/dcparser/dcLexer.lxx" { accept(); return KW_UINT64; @@ -1448,7 +1464,7 @@ YY_RULE_SETUP YY_BREAK case 23: YY_RULE_SETUP -#line 546 "dcLexer.lxx" +#line 550 "direct/src/dcparser/dcLexer.lxx" { accept(); return KW_FLOAT64; @@ -1456,7 +1472,7 @@ YY_RULE_SETUP YY_BREAK case 24: YY_RULE_SETUP -#line 551 "dcLexer.lxx" +#line 555 "direct/src/dcparser/dcLexer.lxx" { accept(); return KW_STRING; @@ -1464,7 +1480,7 @@ YY_RULE_SETUP YY_BREAK case 25: YY_RULE_SETUP -#line 556 "dcLexer.lxx" +#line 560 "direct/src/dcparser/dcLexer.lxx" { accept(); return KW_BLOB; @@ -1472,7 +1488,7 @@ YY_RULE_SETUP YY_BREAK case 26: YY_RULE_SETUP -#line 561 "dcLexer.lxx" +#line 565 "direct/src/dcparser/dcLexer.lxx" { accept(); return KW_BLOB32; @@ -1480,7 +1496,7 @@ YY_RULE_SETUP YY_BREAK case 27: YY_RULE_SETUP -#line 566 "dcLexer.lxx" +#line 570 "direct/src/dcparser/dcLexer.lxx" { accept(); return KW_INT8ARRAY; @@ -1488,7 +1504,7 @@ YY_RULE_SETUP YY_BREAK case 28: YY_RULE_SETUP -#line 571 "dcLexer.lxx" +#line 575 "direct/src/dcparser/dcLexer.lxx" { accept(); return KW_INT16ARRAY; @@ -1496,7 +1512,7 @@ YY_RULE_SETUP YY_BREAK case 29: YY_RULE_SETUP -#line 576 "dcLexer.lxx" +#line 580 "direct/src/dcparser/dcLexer.lxx" { accept(); return KW_INT32ARRAY; @@ -1504,7 +1520,7 @@ YY_RULE_SETUP YY_BREAK case 30: YY_RULE_SETUP -#line 581 "dcLexer.lxx" +#line 585 "direct/src/dcparser/dcLexer.lxx" { accept(); return KW_UINT8ARRAY; @@ -1512,7 +1528,7 @@ YY_RULE_SETUP YY_BREAK case 31: YY_RULE_SETUP -#line 586 "dcLexer.lxx" +#line 590 "direct/src/dcparser/dcLexer.lxx" { accept(); return KW_UINT16ARRAY; @@ -1520,7 +1536,7 @@ YY_RULE_SETUP YY_BREAK case 32: YY_RULE_SETUP -#line 591 "dcLexer.lxx" +#line 595 "direct/src/dcparser/dcLexer.lxx" { accept(); return KW_UINT32ARRAY; @@ -1528,7 +1544,7 @@ YY_RULE_SETUP YY_BREAK case 33: YY_RULE_SETUP -#line 596 "dcLexer.lxx" +#line 600 "direct/src/dcparser/dcLexer.lxx" { accept(); return KW_UINT32UINT8ARRAY; @@ -1536,7 +1552,7 @@ YY_RULE_SETUP YY_BREAK case 34: YY_RULE_SETUP -#line 601 "dcLexer.lxx" +#line 605 "direct/src/dcparser/dcLexer.lxx" { accept(); return KW_CHAR; @@ -1544,8 +1560,8 @@ YY_RULE_SETUP YY_BREAK case 35: YY_RULE_SETUP -#line 606 "dcLexer.lxx" -{ +#line 610 "direct/src/dcparser/dcLexer.lxx" +{ // An unsigned integer number. accept(); @@ -1564,14 +1580,14 @@ YY_RULE_SETUP dcyylval.u.uint64 = next_value + (*p - '0'); ++p; } - + return UNSIGNED_INTEGER; } YY_BREAK case 36: YY_RULE_SETUP -#line 629 "dcLexer.lxx" -{ +#line 633 "direct/src/dcparser/dcLexer.lxx" +{ // A signed integer number. accept(); @@ -1612,17 +1628,17 @@ YY_RULE_SETUP dcyyerror("Number out of range."); dcyylval.u.int64 = 1; } - } - + } + return SIGNED_INTEGER; } YY_BREAK case 37: YY_RULE_SETUP -#line 675 "dcLexer.lxx" +#line 679 "direct/src/dcparser/dcLexer.lxx" { // A hexadecimal integer number. - accept(); + accept(); // As above, we'll decode the hex string by hand. dcyylval.str = dcyytext; @@ -1644,23 +1660,23 @@ YY_RULE_SETUP ++p; } - return UNSIGNED_INTEGER; + return UNSIGNED_INTEGER; } YY_BREAK case 38: YY_RULE_SETUP -#line 702 "dcLexer.lxx" -{ +#line 706 "direct/src/dcparser/dcLexer.lxx" +{ // A floating-point number. - accept(); - dcyylval.u.real = patof(dcyytext); + accept(); + dcyylval.u.real = patof(dcyytext); dcyylval.str = dcyytext; - return REAL; + return REAL; } YY_BREAK case 39: YY_RULE_SETUP -#line 710 "dcLexer.lxx" +#line 714 "direct/src/dcparser/dcLexer.lxx" { // Quoted string. accept(); @@ -1670,7 +1686,7 @@ YY_RULE_SETUP YY_BREAK case 40: YY_RULE_SETUP -#line 717 "dcLexer.lxx" +#line 721 "direct/src/dcparser/dcLexer.lxx" { // Single-quoted string. accept(); @@ -1680,25 +1696,25 @@ YY_RULE_SETUP YY_BREAK case 41: YY_RULE_SETUP -#line 724 "dcLexer.lxx" +#line 728 "direct/src/dcparser/dcLexer.lxx" { // Long hex string. accept(); - dcyylval.str = scan_hex_string(); + dcyylval.bytes = scan_hex_string(); return HEX_STRING; } YY_BREAK case 42: YY_RULE_SETUP -#line 731 "dcLexer.lxx" -{ +#line 735 "direct/src/dcparser/dcLexer.lxx" +{ // Identifier or keyword. accept(); dcyylval.str = dcyytext; - if (dc_file != (DCFile *)NULL) { + if (dc_file != nullptr) { const DCKeyword *keyword = dc_file->get_keyword_by_name(dcyylval.str); - if (keyword != (DCKeyword *)NULL) { + if (keyword != nullptr) { dcyylval.u.keyword = keyword; return KEYWORD; } @@ -1708,19 +1724,19 @@ YY_RULE_SETUP YY_BREAK case 43: YY_RULE_SETUP -#line 747 "dcLexer.lxx" +#line 751 "direct/src/dcparser/dcLexer.lxx" { // Send any other printable character as itself. - accept(); + accept(); return dcyytext[0]; } YY_BREAK case 44: YY_RULE_SETUP -#line 753 "dcLexer.lxx" +#line 757 "direct/src/dcparser/dcLexer.lxx" ECHO; YY_BREAK -#line 1721 "lex.yy.c" +#line 1740 "built/tmp/dcLexer.lxx.cxx" case YY_STATE_EOF(INITIAL): yyterminate(); @@ -1862,9 +1878,9 @@ case YY_STATE_EOF(INITIAL): */ static int yy_get_next_buffer (void) { - register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; - register char *source = (yytext_ptr); - register int number_to_move, i; + char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf; + char *source = (yytext_ptr); + int number_to_move, i; int ret_val; if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] ) @@ -1906,21 +1922,21 @@ static int yy_get_next_buffer (void) else { - int num_to_read = + yy_size_t num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1; while ( num_to_read <= 0 ) { /* Not enough room in the buffer - grow it. */ /* just a shorter name for the current buffer */ - YY_BUFFER_STATE b = YY_CURRENT_BUFFER; + YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE; int yy_c_buf_p_offset = (int) ((yy_c_buf_p) - b->yy_ch_buf); if ( b->yy_is_our_buffer ) { - int new_size = b->yy_buf_size * 2; + yy_size_t new_size = b->yy_buf_size * 2; if ( new_size <= 0 ) b->yy_buf_size += b->yy_buf_size / 8; @@ -1951,7 +1967,7 @@ static int yy_get_next_buffer (void) /* Read in more data. */ YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]), - (yy_n_chars), (size_t) num_to_read ); + (yy_n_chars), num_to_read ); YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars); } @@ -1996,14 +2012,14 @@ static int yy_get_next_buffer (void) static yy_state_type yy_get_previous_state (void) { - register yy_state_type yy_current_state; - register char *yy_cp; - + yy_state_type yy_current_state; + char *yy_cp; + yy_current_state = (yy_start); for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp ) { - register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); + YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1); if ( yy_accept[yy_current_state] ) { (yy_last_accepting_state) = yy_current_state; @@ -2028,10 +2044,10 @@ static int yy_get_next_buffer (void) */ static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state ) { - register int yy_is_jam; - register char *yy_cp = (yy_c_buf_p); + int yy_is_jam; + char *yy_cp = (yy_c_buf_p); - register YY_CHAR yy_c = 1; + YY_CHAR yy_c = 1; if ( yy_accept[yy_current_state] ) { (yy_last_accepting_state) = yy_current_state; @@ -2046,13 +2062,14 @@ static int yy_get_next_buffer (void) yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c]; yy_is_jam = (yy_current_state == 164); - return yy_is_jam ? 0 : yy_current_state; + return yy_is_jam ? 0 : yy_current_state; } - static void yyunput (int c, register char * yy_bp ) +#ifndef YY_NO_UNPUT + static void yyunput (int c, char * yy_bp ) { - register char *yy_cp; - + char *yy_cp; + yy_cp = (yy_c_buf_p); /* undo effects of setting up dcyytext */ @@ -2061,10 +2078,10 @@ static int yy_get_next_buffer (void) if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 ) { /* need to shift things up to make room */ /* +2 for EOB chars. */ - register int number_to_move = (yy_n_chars) + 2; - register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ + yy_size_t number_to_move = (yy_n_chars) + 2; + char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[ YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2]; - register char *source = + char *source = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]; while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf ) @@ -2085,6 +2102,7 @@ static int yy_get_next_buffer (void) (yy_hold_char) = *yy_cp; (yy_c_buf_p) = yy_cp; } +#endif /* ifndef YY_NO_UNPUT */ #ifndef YY_NO_INPUT #ifdef __cplusplus @@ -2095,7 +2113,7 @@ static int yy_get_next_buffer (void) { int c; - + *(yy_c_buf_p) = (yy_hold_char); if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR ) @@ -2110,7 +2128,7 @@ static int yy_get_next_buffer (void) else { /* need more input */ - int offset = (yy_c_buf_p) - (yytext_ptr); + yy_size_t offset = (yy_c_buf_p) - (yytext_ptr); ++(yy_c_buf_p); switch ( yy_get_next_buffer( ) ) @@ -2162,12 +2180,12 @@ static int yy_get_next_buffer (void) /** Immediately switch to a different input stream. * @param input_file A readable stream. - * + * * @note This function does not reset the start condition to @c INITIAL . */ void dcyyrestart (FILE * input_file ) { - + if ( ! YY_CURRENT_BUFFER ){ dcyyensure_buffer_stack (); YY_CURRENT_BUFFER_LVALUE = @@ -2180,11 +2198,11 @@ static int yy_get_next_buffer (void) /** Switch to a different input buffer. * @param new_buffer The new input buffer. - * + * */ void dcyy_switch_to_buffer (YY_BUFFER_STATE new_buffer ) { - + /* TODO. We should be able to replace this entire function body * with * dcyypop_buffer_state(); @@ -2224,13 +2242,13 @@ static void dcyy_load_buffer_state (void) /** Allocate and initialize an input buffer state. * @param file A readable stream. * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE. - * + * * @return the allocated buffer state. */ YY_BUFFER_STATE dcyy_create_buffer (FILE * file, int size ) { YY_BUFFER_STATE b; - + b = (YY_BUFFER_STATE) dcyyalloc(sizeof( struct yy_buffer_state ) ); if ( ! b ) YY_FATAL_ERROR( "out of dynamic memory in dcyy_create_buffer()" ); @@ -2253,11 +2271,11 @@ static void dcyy_load_buffer_state (void) /** Destroy the buffer. * @param b a buffer created with dcyy_create_buffer() - * + * */ void dcyy_delete_buffer (YY_BUFFER_STATE b ) { - + if ( ! b ) return; @@ -2270,10 +2288,6 @@ static void dcyy_load_buffer_state (void) dcyyfree((void *) b ); } -#ifndef __cplusplus -extern int isatty (int ); -#endif /* __cplusplus */ - /* Initializes or reinitializes a buffer. * This function is sometimes called more than once on the same buffer, * such as during a dcyyrestart() or at EOF. @@ -2282,7 +2296,7 @@ extern int isatty (int ); { int oerrno = errno; - + dcyy_flush_buffer(b ); b->yy_input_file = file; @@ -2298,13 +2312,13 @@ extern int isatty (int ); } b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0; - + errno = oerrno; } /** Discard all buffered characters. On the next scan, YY_INPUT will be called. * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER. - * + * */ void dcyy_flush_buffer (YY_BUFFER_STATE b ) { @@ -2333,7 +2347,7 @@ extern int isatty (int ); * the current state. This function will allocate the stack * if necessary. * @param new_buffer The new state. - * + * */ void dcyypush_buffer_state (YY_BUFFER_STATE new_buffer ) { @@ -2363,7 +2377,7 @@ void dcyypush_buffer_state (YY_BUFFER_STATE new_buffer ) /** Removes and deletes the top of the stack, if present. * The next element becomes the new top. - * + * */ void dcyypop_buffer_state (void) { @@ -2386,8 +2400,8 @@ void dcyypop_buffer_state (void) */ static void dcyyensure_buffer_stack (void) { - int num_to_alloc; - + yy_size_t num_to_alloc; + if (!(yy_buffer_stack)) { /* First allocation is just for 2 elements, since we don't know if this @@ -2400,9 +2414,9 @@ static void dcyyensure_buffer_stack (void) ); if ( ! (yy_buffer_stack) ) YY_FATAL_ERROR( "out of dynamic memory in dcyyensure_buffer_stack()" ); - + memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); - + (yy_buffer_stack_max) = num_to_alloc; (yy_buffer_stack_top) = 0; return; @@ -2430,13 +2444,13 @@ static void dcyyensure_buffer_stack (void) /** Setup the input buffer state to scan directly from a user-specified character buffer. * @param base the character buffer * @param size the size in bytes of the character buffer - * - * @return the newly allocated buffer state object. + * + * @return the newly allocated buffer state object. */ YY_BUFFER_STATE dcyy_scan_buffer (char * base, yy_size_t size ) { YY_BUFFER_STATE b; - + if ( size < 2 || base[size-2] != YY_END_OF_BUFFER_CHAR || base[size-1] != YY_END_OF_BUFFER_CHAR ) @@ -2465,31 +2479,31 @@ YY_BUFFER_STATE dcyy_scan_buffer (char * base, yy_size_t size ) /** Setup the input buffer state to scan a string. The next call to dcyylex() will * scan from a @e copy of @a str. * @param yystr a NUL-terminated string to scan - * + * * @return the newly allocated buffer state object. * @note If you want to scan bytes that may contain NUL values, then use * dcyy_scan_bytes() instead. */ YY_BUFFER_STATE dcyy_scan_string (yyconst char * yystr ) { - + return dcyy_scan_bytes(yystr,strlen(yystr) ); } /** Setup the input buffer state to scan the given bytes. The next call to dcyylex() will * scan from a @e copy of @a bytes. - * @param bytes the byte buffer to scan - * @param len the number of bytes in the buffer pointed to by @a bytes. - * + * @param yybytes the byte buffer to scan + * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes. + * * @return the newly allocated buffer state object. */ -YY_BUFFER_STATE dcyy_scan_bytes (yyconst char * yybytes, int _yybytes_len ) +YY_BUFFER_STATE dcyy_scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len ) { YY_BUFFER_STATE b; char *buf; yy_size_t n; - int i; - + yy_size_t i; + /* Get memory for full buffer, including space for trailing EOB's. */ n = _yybytes_len + 2; buf = (char *) dcyyalloc(n ); @@ -2543,16 +2557,16 @@ static void yy_fatal_error (yyconst char* msg ) /* Accessor methods (get/set functions) to struct members. */ /** Get the current line number. - * + * */ int dcyyget_lineno (void) { - + return dcyylineno; } /** Get the input stream. - * + * */ FILE *dcyyget_in (void) { @@ -2560,7 +2574,7 @@ FILE *dcyyget_in (void) } /** Get the output stream. - * + * */ FILE *dcyyget_out (void) { @@ -2568,15 +2582,15 @@ FILE *dcyyget_out (void) } /** Get the length of the current token. - * + * */ -int dcyyget_leng (void) +yy_size_t dcyyget_leng (void) { return dcyyleng; } /** Get the current token. - * + * */ char *dcyyget_text (void) @@ -2586,18 +2600,18 @@ char *dcyyget_text (void) /** Set the current line number. * @param line_number - * + * */ void dcyyset_lineno (int line_number ) { - + dcyylineno = line_number; } /** Set the input stream. This does not discard the current * input buffer. * @param in_str A readable stream. - * + * * @see dcyy_switch_to_buffer */ void dcyyset_in (FILE * in_str ) @@ -2651,7 +2665,7 @@ static int yy_init_globals (void) /* dcyylex_destroy is for both reentrant and non-reentrant scanners. */ int dcyylex_destroy (void) { - + /* Pop the buffer stack, destroying each element. */ while(YY_CURRENT_BUFFER){ dcyy_delete_buffer(YY_CURRENT_BUFFER ); @@ -2677,7 +2691,7 @@ int dcyylex_destroy (void) #ifndef yytext_ptr static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) { - register int i; + int i; for ( i = 0; i < n; ++i ) s1[i] = s2[i]; } @@ -2686,7 +2700,7 @@ static void yy_flex_strncpy (char* s1, yyconst char * s2, int n ) #ifdef YY_NEED_STRLEN static int yy_flex_strlen (yyconst char * s ) { - register int n; + int n; for ( n = 0; s[n]; ++n ) ; @@ -2718,4 +2732,4 @@ void dcyyfree (void * ptr ) #define YYTABLES_NAME "yytables" -#line 753 "dcLexer.lxx" +#line 757 "direct/src/dcparser/dcLexer.lxx" diff --git a/direct/src/dcparser/dcLexer.lxx b/direct/src/dcparser/dcLexer.lxx index 3c20a69b5f..3a8156a4f3 100644 --- a/direct/src/dcparser/dcLexer.lxx +++ b/direct/src/dcparser/dcLexer.lxx @@ -1,7 +1,7 @@ /* // Filename: dcLexer.lxx // Created by: drose (05Oct00) -// +// //////////////////////////////////////////////////////////////////// */ @@ -103,12 +103,12 @@ dcyyerror(const std::string &msg) { if (!dc_filename.empty()) { cerr << " in " << dc_filename; } - cerr + cerr << " at line " << line_number << ", column " << col_number << ":\n" << current_line << "\n"; - indent(cerr, col_number-1) + indent(cerr, col_number-1) << "^\n" << msg << "\n\n"; - + error_count++; } @@ -120,10 +120,10 @@ dcyywarning(const std::string &msg) { if (!dc_filename.empty()) { cerr << " in " << dc_filename; } - cerr + cerr << " at line " << line_number << ", column " << col_number << ":\n" << current_line << "\n"; - indent(cerr, col_number-1) + indent(cerr, col_number-1) << "^\n" << msg << "\n\n"; warning_count++; @@ -313,9 +313,9 @@ scan_quoted_string(char quote_mark) { // scan_hex_string reads a string of hexadecimal digits delimited by // angle brackets and returns the representative string. -static std::string +static vector_uchar scan_hex_string() { - std::string result; + vector_uchar result; // We don't touch the current line number and column number during // scanning, so that if we detect an error while scanning the string @@ -345,24 +345,24 @@ scan_hex_string() { line_number = line; col_number = col; dcyyerror("Invalid hex digit."); - return std::string(); + return vector_uchar(); } odd = !odd; if (odd) { last = value; } else { - result += (char)((last << 4) | value); + result.push_back((unsigned char)((last << 4) | value)); } c = read_char(line, col); } if (c == EOF) { dcyyerror("This hex string is unterminated."); - return std::string(); + return vector_uchar(); } else if (odd) { dcyyerror("Odd number of hex digits."); - return std::string(); + return vector_uchar(); } line_number = line; @@ -382,7 +382,7 @@ eat_c_comment() { int col = col_number; int c, last_c; - + last_c = '\0'; c = read_char(line, col); while (c != EOF && !(last_c == '*' && c == '/')) { @@ -440,12 +440,12 @@ REALNUM ([+-]?(([0-9]+[.])|([0-9]*[.][0-9]+))([eE][+-]?[0-9]+)?) yyless(1); } -[ \t\r] { +[ \t\r] { // Eat whitespace. accept(); } -"//".* { +"//".* { // Eat C++-style comments. accept(); } @@ -453,7 +453,7 @@ REALNUM ([+-]?(([0-9]+[.])|([0-9]*[.][0-9]+))([eE][+-]?[0-9]+)?) "/*" { // Eat C-style comments. accept(); - eat_c_comment(); + eat_c_comment(); } @@ -607,7 +607,7 @@ REALNUM ([+-]?(([0-9]+[.])|([0-9]*[.][0-9]+))([eE][+-]?[0-9]+)?) return KW_CHAR; } -{UNSIGNED_INTEGERNUM} { +{UNSIGNED_INTEGERNUM} { // An unsigned integer number. accept(); @@ -626,11 +626,11 @@ REALNUM ([+-]?(([0-9]+[.])|([0-9]*[.][0-9]+))([eE][+-]?[0-9]+)?) dcyylval.u.uint64 = next_value + (*p - '0'); ++p; } - + return UNSIGNED_INTEGER; } -{SIGNED_INTEGERNUM} { +{SIGNED_INTEGERNUM} { // A signed integer number. accept(); @@ -671,14 +671,14 @@ REALNUM ([+-]?(([0-9]+[.])|([0-9]*[.][0-9]+))([eE][+-]?[0-9]+)?) dcyyerror("Number out of range."); dcyylval.u.int64 = 1; } - } - + } + return SIGNED_INTEGER; } {UNSIGNED_HEXNUM} { // A hexadecimal integer number. - accept(); + accept(); // As above, we'll decode the hex string by hand. dcyylval.str = dcyytext; @@ -700,15 +700,15 @@ REALNUM ([+-]?(([0-9]+[.])|([0-9]*[.][0-9]+))([eE][+-]?[0-9]+)?) ++p; } - return UNSIGNED_INTEGER; + return UNSIGNED_INTEGER; } -{REALNUM} { +{REALNUM} { // A floating-point number. - accept(); - dcyylval.u.real = patof(dcyytext); + accept(); + dcyylval.u.real = patof(dcyytext); dcyylval.str = dcyytext; - return REAL; + return REAL; } ["] { @@ -728,11 +728,11 @@ REALNUM ([+-]?(([0-9]+[.])|([0-9]*[.][0-9]+))([eE][+-]?[0-9]+)?) [<] { // Long hex string. accept(); - dcyylval.str = scan_hex_string(); + dcyylval.bytes = scan_hex_string(); return HEX_STRING; } -[A-Za-z_][A-Za-z_0-9]* { +[A-Za-z_][A-Za-z_0-9]* { // Identifier or keyword. accept(); dcyylval.str = dcyytext; @@ -750,7 +750,7 @@ REALNUM ([+-]?(([0-9]+[.])|([0-9]*[.][0-9]+))([eE][+-]?[0-9]+)?) . { // Send any other printable character as itself. - accept(); + accept(); return dcyytext[0]; } - + diff --git a/direct/src/dcparser/dcPacker.I b/direct/src/dcparser/dcPacker.I index 8c640d77b1..6b6ef79ee5 100644 --- a/direct/src/dcparser/dcPacker.I +++ b/direct/src/dcparser/dcPacker.I @@ -217,16 +217,30 @@ pack_string(const std::string &value) { } /** - * Adds the indicated string value into the stream, representing a single pre- - * packed field element, or a whole group of field elements at once. + * Packs the indicated numeric or string value into the stream. */ INLINE void DCPacker:: -pack_literal_value(const std::string &value) { +pack_blob(const vector_uchar &value) { nassertv(_mode == M_pack || _mode == M_repack); if (_current_field == nullptr) { _pack_error = true; } else { - _pack_data.append_data(value.data(), value.length()); + _current_field->pack_blob(_pack_data, value, _pack_error, _range_error); + advance(); + } +} + +/** + * Adds the indicated string value into the stream, representing a single pre- + * packed field element, or a whole group of field elements at once. + */ +INLINE void DCPacker:: +pack_literal_value(const vector_uchar &value) { + nassertv(_mode == M_pack || _mode == M_repack); + if (_current_field == nullptr) { + _pack_error = true; + } else { + _pack_data.append_data((const char *)value.data(), value.size()); advance(); } } @@ -345,16 +359,36 @@ unpack_string() { return value; } +/** + * Unpacks the current binary data value from the stream. + */ +INLINE vector_uchar DCPacker:: +unpack_blob() { + vector_uchar value; + nassertr(_mode == M_unpack, value); + if (_current_field == nullptr) { + _pack_error = true; + + } else { + _current_field->unpack_blob(_unpack_data, _unpack_length, _unpack_p, + value, _pack_error, _range_error); + advance(); + } + + return value; +} + /** * Returns the literal string that represents the packed value of the current * field, and advances the field pointer. */ -INLINE std::string DCPacker:: +INLINE vector_uchar DCPacker:: unpack_literal_value() { size_t start = _unpack_p; unpack_skip(); - nassertr(_unpack_p >= start, std::string()); - return std::string(_unpack_data + start, _unpack_p - start); + nassertr(_unpack_p >= start, vector_uchar()); + return vector_uchar((const unsigned char *)_unpack_data + start, + (const unsigned char *)_unpack_data + _unpack_p); } /** @@ -453,16 +487,33 @@ unpack_string(std::string &value) { } } +/** + * Unpacks the current numeric or string value from the stream. + */ +INLINE void DCPacker:: +unpack_blob(vector_uchar &value) { + nassertv(_mode == M_unpack); + if (_current_field == nullptr) { + _pack_error = true; + + } else { + _current_field->unpack_blob(_unpack_data, _unpack_length, _unpack_p, + value, _pack_error, _range_error); + advance(); + } +} + /** * Returns the literal string that represents the packed value of the current * field, and advances the field pointer. */ INLINE void DCPacker:: -unpack_literal_value(std::string &value) { +unpack_literal_value(vector_uchar &value) { size_t start = _unpack_p; unpack_skip(); nassertv(_unpack_p >= start); - value.assign(_unpack_data + start, _unpack_p - start); + value = vector_uchar((const unsigned char *)_unpack_data + start, + (const unsigned char *)_unpack_data + _unpack_p); } /** @@ -541,6 +592,15 @@ get_string() const { return _pack_data.get_string(); } +/** + * Returns the packed data buffer as a bytes object. Also see get_data(). + */ +INLINE vector_uchar DCPacker:: +get_bytes() const { + const unsigned char *p = (const unsigned char *)_pack_data.get_data(); + return vector_uchar(p, p + _pack_data.get_length()); +} + /** * Returns the total number of bytes in the unpack data buffer. This is the * buffer used when unpacking; it is separate from the pack data returned by @@ -601,9 +661,9 @@ take_data() { * between packing sessions. */ INLINE void DCPacker:: -append_data(const char *buffer, size_t size) { +append_data(const unsigned char *buffer, size_t size) { nassertv(_mode == M_idle); - _pack_data.append_data(buffer, size); + _pack_data.append_data((const char *)buffer, size); } /** @@ -728,6 +788,16 @@ raw_pack_string(const std::string &value) { _pack_data.append_data(value.data(), value.length()); } +/** + * Packs the data into the buffer between packing sessions. + */ +INLINE void DCPacker:: +raw_pack_blob(const vector_uchar &value) { + nassertv(_mode == M_idle); + DCPackerInterface::do_pack_uint16(_pack_data.get_write_pointer(2), value.size()); + _pack_data.append_data((const char *)value.data(), value.size()); +} + /** * Unpacks the data from the buffer between unpacking sessions. */ @@ -870,6 +940,16 @@ raw_unpack_string() { return value; } +/** + * Unpacks the data from the buffer between unpacking sessions. + */ +INLINE vector_uchar DCPacker:: +raw_unpack_blob() { + vector_uchar value; + raw_unpack_blob(value); + return value; +} + /** * Unpacks the data from the buffer between unpacking sessions. */ @@ -971,6 +1051,24 @@ raw_unpack_string(std::string &value) { _unpack_p += string_length; } +/** + * Unpacks the data from the buffer between unpacking sessions. + */ +INLINE void DCPacker:: +raw_unpack_blob(vector_uchar &value) { + nassertv(_mode == M_idle && _unpack_data != nullptr); + unsigned int blob_size = raw_unpack_uint16(); + + if (_unpack_p + blob_size > _unpack_length) { + _pack_error = true; + return; + } + + const unsigned char *p = (const unsigned char *)_unpack_data + _unpack_p; + value = vector_uchar(p, p + blob_size); + _unpack_p += blob_size; +} + /** * Advances to the next field after a call to pack_value() or pop(). */ diff --git a/direct/src/dcparser/dcPacker.cxx b/direct/src/dcparser/dcPacker.cxx index ebab348f6f..b6dbd60855 100644 --- a/direct/src/dcparser/dcPacker.cxx +++ b/direct/src/dcparser/dcPacker.cxx @@ -114,12 +114,12 @@ end_pack() { * version of begin_unpack() that takes only one parameter. */ void DCPacker:: -set_unpack_data(const string &data) { +set_unpack_data(const vector_uchar &data) { nassertv(_mode == M_idle); - char *buffer = new char[data.length()]; - memcpy(buffer, data.data(), data.length()); - set_unpack_data(buffer, data.length(), true); + char *buffer = new char[data.size()]; + memcpy(buffer, data.data(), data.size()); + set_unpack_data(buffer, data.size(), true); } /** @@ -721,11 +721,11 @@ pack_object(PyObject *object) { pack_string(string(buffer, length)); } } else if (PyBytes_Check(object)) { - char *buffer; + const unsigned char *buffer; Py_ssize_t length; - PyBytes_AsStringAndSize(object, &buffer, &length); + PyBytes_AsStringAndSize(object, (char **)&buffer, &length); if (buffer) { - pack_string(string(buffer, length)); + pack_blob(vector_uchar(buffer, buffer + length)); } #else } else if (PyString_Check(object) || PyUnicode_Check(object)) { @@ -1118,9 +1118,9 @@ enquote_string(ostream &out, char quote_mark, const string &str) { * Outputs the indicated string as a hex constant. */ void DCPacker:: -output_hex_string(ostream &out, const string &str) { +output_hex_string(ostream &out, const vector_uchar &str) { out << '<'; - for (string::const_iterator pi = str.begin(); + for (vector_uchar::const_iterator pi = str.begin(); pi != str.end(); ++pi) { char buffer[10]; diff --git a/direct/src/dcparser/dcPacker.h b/direct/src/dcparser/dcPacker.h index 68a01a5999..dce28dbc30 100644 --- a/direct/src/dcparser/dcPacker.h +++ b/direct/src/dcparser/dcPacker.h @@ -41,7 +41,7 @@ PUBLISHED: void begin_pack(const DCPackerInterface *root); bool end_pack(); - void set_unpack_data(const std::string &data); + void set_unpack_data(const vector_uchar &data); public: void set_unpack_data(const char *unpack_data, size_t unpack_length, bool owns_unpack_data); @@ -75,7 +75,8 @@ PUBLISHED: INLINE void pack_int64(int64_t value); INLINE void pack_uint64(uint64_t value); INLINE void pack_string(const std::string &value); - INLINE void pack_literal_value(const std::string &value); + INLINE void pack_blob(const vector_uchar &value); + INLINE void pack_literal_value(const vector_uchar &value); void pack_default_value(); INLINE double unpack_double(); @@ -84,7 +85,8 @@ PUBLISHED: INLINE int64_t unpack_int64(); INLINE uint64_t unpack_uint64(); INLINE std::string unpack_string(); - INLINE std::string unpack_literal_value(); + INLINE vector_uchar unpack_blob(); + INLINE vector_uchar unpack_literal_value(); void unpack_validate(); void unpack_skip(); @@ -97,7 +99,8 @@ public: INLINE void unpack_int64(int64_t &value); INLINE void unpack_uint64(uint64_t &value); INLINE void unpack_string(std::string &value); - INLINE void unpack_literal_value(std::string &value); + INLINE void unpack_blob(vector_uchar &value); + INLINE void unpack_literal_value(vector_uchar &value); PUBLISHED: @@ -119,6 +122,7 @@ PUBLISHED: INLINE size_t get_length() const; INLINE std::string get_string() const; + INLINE vector_uchar get_bytes() const; INLINE size_t get_unpack_length() const; INLINE std::string get_unpack_string() const; public: @@ -126,7 +130,7 @@ public: INLINE const char *get_data() const; INLINE char *take_data(); - INLINE void append_data(const char *buffer, size_t size); + INLINE void append_data(const unsigned char *buffer, size_t size); INLINE char *get_write_pointer(size_t size); INLINE const char *get_unpack_data() const; @@ -148,6 +152,7 @@ PUBLISHED: INLINE void raw_pack_uint64(uint64_t value); INLINE void raw_pack_float64(double value); INLINE void raw_pack_string(const std::string &value); + INLINE void raw_pack_blob(const vector_uchar &value); // this is a hack to allw me to get in and out of 32bit Mode Faster need to // agree with channel_type in dcbase.h @@ -165,6 +170,7 @@ PUBLISHED: INLINE uint64_t raw_unpack_uint64(); INLINE double raw_unpack_float64(); INLINE std::string raw_unpack_string(); + INLINE vector_uchar raw_unpack_blob(); public: INLINE void raw_unpack_int8(int &value); @@ -177,10 +183,11 @@ public: INLINE void raw_unpack_uint64(uint64_t &value); INLINE void raw_unpack_float64(double &value); INLINE void raw_unpack_string(std::string &value); + INLINE void raw_unpack_blob(vector_uchar &value); public: static void enquote_string(std::ostream &out, char quote_mark, const std::string &str); - static void output_hex_string(std::ostream &out, const std::string &str); + static void output_hex_string(std::ostream &out, const vector_uchar &str); private: INLINE void advance(); diff --git a/direct/src/dcparser/dcPackerInterface.cxx b/direct/src/dcparser/dcPackerInterface.cxx index d17ff1f7b7..db51d2712c 100644 --- a/direct/src/dcparser/dcPackerInterface.cxx +++ b/direct/src/dcparser/dcPackerInterface.cxx @@ -248,6 +248,14 @@ pack_string(DCPackData &, const string &, bool &pack_error, bool &) const { pack_error = true; } +/** + * Packs the indicated numeric or string value into the stream. + */ +void DCPackerInterface:: +pack_blob(DCPackData &, const vector_uchar &, bool &pack_error, bool &) const { + pack_error = true; +} + /** * Packs the field's specified default value (or a sensible default if no * value is specified) into the stream. Returns true if the default value is @@ -306,6 +314,14 @@ unpack_string(const char *, size_t, size_t &, string &, bool &pack_error, bool & pack_error = true; } +/** + * Unpacks the current numeric or string value from the stream. + */ +void DCPackerInterface:: +unpack_blob(const char *, size_t, size_t &, vector_uchar &, bool &pack_error, bool &) const { + pack_error = true; +} + /** * Internally unpacks the current numeric or string value and validates it * against the type range limits, but does not return the value. Returns true diff --git a/direct/src/dcparser/dcPackerInterface.h b/direct/src/dcparser/dcPackerInterface.h index ef28b85647..0b2f81d2fe 100644 --- a/direct/src/dcparser/dcPackerInterface.h +++ b/direct/src/dcparser/dcPackerInterface.h @@ -16,6 +16,7 @@ #include "dcbase.h" #include "dcSubatomicType.h" +#include "vector_uchar.h" class DCFile; class DCField; @@ -37,8 +38,8 @@ enum DCPackType { // These PackTypes are all fundamental types, and should be packed (or // unpacked) with the corresponding call to pack_double(), pack_int(), etc. - // PT_blob is the same as PT_string, but implies that the string contains - // binary data. + // PT_blob is similar to PT_string, except that it contains arbitrary binary + // data instead of just UTF-8 text. PT_double, PT_int, PT_uint, @@ -113,6 +114,8 @@ public: bool &pack_error, bool &range_error) const; virtual void pack_string(DCPackData &pack_data, const std::string &value, bool &pack_error, bool &range_error) const; + virtual void pack_blob(DCPackData &pack_data, const vector_uchar &value, + bool &pack_error, bool &range_error) const; virtual bool pack_default_value(DCPackData &pack_data, bool &pack_error) const; virtual void unpack_double(const char *data, size_t length, size_t &p, @@ -127,6 +130,8 @@ public: uint64_t &value, bool &pack_error, bool &range_error) const; virtual void unpack_string(const char *data, size_t length, size_t &p, std::string &value, bool &pack_error, bool &range_error) const; + virtual void unpack_blob(const char *data, size_t length, size_t &p, + vector_uchar &value, bool &pack_error, bool &range_error) const; virtual bool unpack_validate(const char *data, size_t length, size_t &p, bool &pack_error, bool &range_error) const; virtual bool unpack_skip(const char *data, size_t length, size_t &p, diff --git a/direct/src/dcparser/dcParser.cxx.prebuilt b/direct/src/dcparser/dcParser.cxx.prebuilt index 80df4b2b09..9adc570263 100644 --- a/direct/src/dcparser/dcParser.cxx.prebuilt +++ b/direct/src/dcparser/dcParser.cxx.prebuilt @@ -1,20 +1,19 @@ -/* A Bison parser, made by GNU Bison 2.4.2. */ +/* A Bison parser, made by GNU Bison 3.0.4. */ + +/* Bison implementation for Yacc-like parsers in C + + Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc. -/* Skeleton implementation for Bison's Yacc-like parsers in C - - Copyright (C) 1984, 1989-1990, 2000-2006, 2009-2010 Free Software - Foundation, Inc. - This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program. If not, see . */ @@ -27,7 +26,7 @@ special exception, which will cause the skeleton and the resulting Bison output files to be licensed under the GNU General Public License without this special exception. - + This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ @@ -45,7 +44,7 @@ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "2.4.2" +#define YYBISON_VERSION "3.0.4" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -59,23 +58,19 @@ /* Pull parsers. */ #define YYPULL 1 -/* Using locations. */ -#define YYLSP_NEEDED 0 /* Substitute the variable and function names. */ #define yyparse dcyyparse #define yylex dcyylex #define yyerror dcyyerror -#define yylval dcyylval -#define yychar dcyychar #define yydebug dcyydebug #define yynerrs dcyynerrs +#define yylval dcyylval +#define yychar dcyychar /* Copy the first part of user declarations. */ - -/* Line 189 of yacc.c */ -#line 6 "dcParser.yxx" +#line 7 "direct/src/dcparser/dcParser.yxx" /* yacc.c:339 */ #include "dcLexerDefs.h" #include "dcParserDefs.h" @@ -105,18 +100,18 @@ using std::istream; using std::ostringstream; using std::string; -DCFile *dc_file = (DCFile *)NULL; -static DCClass *current_class = (DCClass *)NULL; -static DCSwitch *current_switch = (DCSwitch *)NULL; -static DCAtomicField *current_atomic = (DCAtomicField *)NULL; -static DCMolecularField *current_molecular = (DCMolecularField *)NULL; -static DCParameter *current_parameter = (DCParameter *)NULL; +DCFile *dc_file = nullptr; +static DCClass *current_class = nullptr; +static DCSwitch *current_switch = nullptr; +static DCAtomicField *current_atomic = nullptr; +static DCMolecularField *current_molecular = nullptr; +static DCParameter *current_parameter = nullptr; static DCKeywordList current_keyword_list; static DCPacker default_packer; static DCPacker *current_packer; static DCDoubleRange double_range; static DCUnsignedIntRange uint_range; -static DCField *parameter_description = (DCField *)NULL; +static DCField *parameter_description = nullptr; //////////////////////////////////////////////////////////////////// // Defining the interface to the parser. @@ -129,9 +124,9 @@ dc_init_parser(istream &in, const string &filename, DCFile &file) { } void -dc_init_parser_parameter_value(istream &in, const string &filename, +dc_init_parser_parameter_value(istream &in, const string &filename, DCPacker &packer) { - dc_file = NULL; + dc_file = nullptr; current_packer = &packer; dc_init_lexer(in, filename); dc_start_parameter_value(); @@ -142,7 +137,7 @@ dc_init_parser_parameter_description(istream &in, const string &filename, DCFile *file) { dc_file = file; dc_init_lexer(in, filename); - parameter_description = NULL; + parameter_description = nullptr; dc_start_parameter_description(); } @@ -153,18 +148,19 @@ dc_get_parameter_description() { void dc_cleanup_parser() { - dc_file = (DCFile *)NULL; + dc_file = nullptr; } +#line 156 "built/tmp/dcParser.yxx.c" /* yacc.c:339 */ -/* Line 189 of yacc.c */ -#line 159 "y.tab.c" - -/* Enabling traces. */ -#ifndef YYDEBUG -# define YYDEBUG 0 -#endif +# ifndef YY_NULLPTR +# if defined __cplusplus && 201103L <= __cplusplus +# define YY_NULLPTR nullptr +# else +# define YY_NULLPTR 0 +# endif +# endif /* Enabling verbose error messages. */ #ifdef YYERROR_VERBOSE @@ -174,67 +170,72 @@ dc_cleanup_parser() { # define YYERROR_VERBOSE 0 #endif -/* Enabling the token table. */ -#ifndef YYTOKEN_TABLE -# define YYTOKEN_TABLE 0 +/* In a future release of Bison, this section will be replaced + by #include "dcParser.yxx.h". */ +#ifndef YY_DCYY_BUILT_TMP_DCPARSER_YXX_H_INCLUDED +# define YY_DCYY_BUILT_TMP_DCPARSER_YXX_H_INCLUDED +/* Debug traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif +#if YYDEBUG +extern int dcyydebug; #endif - -/* Tokens. */ +/* Token type. */ #ifndef YYTOKENTYPE # define YYTOKENTYPE - /* Put the tokens into the symbol table, so that GDB and other debuggers - know about them. */ - enum yytokentype { - UNSIGNED_INTEGER = 258, - SIGNED_INTEGER = 259, - REAL = 260, - STRING = 261, - HEX_STRING = 262, - IDENTIFIER = 263, - KEYWORD = 264, - KW_DCLASS = 265, - KW_STRUCT = 266, - KW_FROM = 267, - KW_IMPORT = 268, - KW_TYPEDEF = 269, - KW_KEYWORD = 270, - KW_SWITCH = 271, - KW_CASE = 272, - KW_DEFAULT = 273, - KW_BREAK = 274, - KW_INT8 = 275, - KW_INT16 = 276, - KW_INT32 = 277, - KW_INT64 = 278, - KW_UINT8 = 279, - KW_UINT16 = 280, - KW_UINT32 = 281, - KW_UINT64 = 282, - KW_FLOAT64 = 283, - KW_STRING = 284, - KW_BLOB = 285, - KW_BLOB32 = 286, - KW_INT8ARRAY = 287, - KW_INT16ARRAY = 288, - KW_INT32ARRAY = 289, - KW_UINT8ARRAY = 290, - KW_UINT16ARRAY = 291, - KW_UINT32ARRAY = 292, - KW_UINT32UINT8ARRAY = 293, - KW_CHAR = 294, - START_DC = 295, - START_PARAMETER_VALUE = 296, - START_PARAMETER_DESCRIPTION = 297 - }; + enum yytokentype + { + UNSIGNED_INTEGER = 258, + SIGNED_INTEGER = 259, + REAL = 260, + STRING = 261, + IDENTIFIER = 262, + HEX_STRING = 263, + KEYWORD = 264, + KW_DCLASS = 265, + KW_STRUCT = 266, + KW_FROM = 267, + KW_IMPORT = 268, + KW_TYPEDEF = 269, + KW_KEYWORD = 270, + KW_SWITCH = 271, + KW_CASE = 272, + KW_DEFAULT = 273, + KW_BREAK = 274, + KW_INT8 = 275, + KW_INT16 = 276, + KW_INT32 = 277, + KW_INT64 = 278, + KW_UINT8 = 279, + KW_UINT16 = 280, + KW_UINT32 = 281, + KW_UINT64 = 282, + KW_FLOAT64 = 283, + KW_STRING = 284, + KW_BLOB = 285, + KW_BLOB32 = 286, + KW_INT8ARRAY = 287, + KW_INT16ARRAY = 288, + KW_INT32ARRAY = 289, + KW_UINT8ARRAY = 290, + KW_UINT16ARRAY = 291, + KW_UINT32ARRAY = 292, + KW_UINT32UINT8ARRAY = 293, + KW_CHAR = 294, + START_DC = 295, + START_PARAMETER_VALUE = 296, + START_PARAMETER_DESCRIPTION = 297 + }; #endif /* Tokens. */ #define UNSIGNED_INTEGER 258 #define SIGNED_INTEGER 259 #define REAL 260 #define STRING 261 -#define HEX_STRING 262 -#define IDENTIFIER 263 +#define IDENTIFIER 262 +#define HEX_STRING 263 #define KEYWORD 264 #define KW_DCLASS 265 #define KW_STRUCT 266 @@ -270,21 +271,18 @@ dc_cleanup_parser() { #define START_PARAMETER_VALUE 296 #define START_PARAMETER_DESCRIPTION 297 +/* Value type. */ +extern YYSTYPE dcyylval; -#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED - -# define yystype YYSTYPE /* obsolescent; will be withdrawn */ -# define YYSTYPE_IS_DECLARED 1 -#endif +int dcyyparse (void); +#endif /* !YY_DCYY_BUILT_TMP_DCPARSER_YXX_H_INCLUDED */ /* Copy the second part of user declarations. */ - -/* Line 264 of yacc.c */ -#line 284 "y.tab.c" +#line 286 "built/tmp/dcParser.yxx.c" /* yacc.c:358 */ #ifdef short # undef short @@ -298,11 +296,8 @@ typedef unsigned char yytype_uint8; #ifdef YYTYPE_INT8 typedef YYTYPE_INT8 yytype_int8; -#elif (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -typedef signed char yytype_int8; #else -typedef short int yytype_int8; +typedef signed char yytype_int8; #endif #ifdef YYTYPE_UINT16 @@ -322,8 +317,7 @@ typedef short int yytype_int16; # define YYSIZE_T __SIZE_TYPE__ # elif defined size_t # define YYSIZE_T size_t -# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) +# elif ! defined YYSIZE_T # include /* INFRINGES ON USER NAME SPACE */ # define YYSIZE_T size_t # else @@ -337,38 +331,67 @@ typedef short int yytype_int16; # if defined YYENABLE_NLS && YYENABLE_NLS # if ENABLE_NLS # include /* INFRINGES ON USER NAME SPACE */ -# define YY_(msgid) dgettext ("bison-runtime", msgid) +# define YY_(Msgid) dgettext ("bison-runtime", Msgid) # endif # endif # ifndef YY_ -# define YY_(msgid) msgid +# define YY_(Msgid) Msgid +# endif +#endif + +#ifndef YY_ATTRIBUTE +# if (defined __GNUC__ \ + && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__))) \ + || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C +# define YY_ATTRIBUTE(Spec) __attribute__(Spec) +# else +# define YY_ATTRIBUTE(Spec) /* empty */ +# endif +#endif + +#ifndef YY_ATTRIBUTE_PURE +# define YY_ATTRIBUTE_PURE YY_ATTRIBUTE ((__pure__)) +#endif + +#ifndef YY_ATTRIBUTE_UNUSED +# define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__)) +#endif + +#if !defined _Noreturn \ + && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112) +# if defined _MSC_VER && 1200 <= _MSC_VER +# define _Noreturn __declspec (noreturn) +# else +# define _Noreturn YY_ATTRIBUTE ((__noreturn__)) # endif #endif /* Suppress unused-variable warnings by "using" E. */ #if ! defined lint || defined __GNUC__ -# define YYUSE(e) ((void) (e)) +# define YYUSE(E) ((void) (E)) #else -# define YYUSE(e) /* empty */ +# define YYUSE(E) /* empty */ #endif -/* Identity function, used to suppress warnings about constant conditions. */ -#ifndef lint -# define YYID(n) (n) +#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__ +/* Suppress an incorrect diagnostic about yylval being uninitialized. */ +# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ + _Pragma ("GCC diagnostic push") \ + _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\ + _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"") +# define YY_IGNORE_MAYBE_UNINITIALIZED_END \ + _Pragma ("GCC diagnostic pop") #else -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -static int -YYID (int yyi) -#else -static int -YYID (yyi) - int yyi; +# define YY_INITIAL_VALUE(Value) Value #endif -{ - return yyi; -} +#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN +# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN +# define YY_IGNORE_MAYBE_UNINITIALIZED_END #endif +#ifndef YY_INITIAL_VALUE +# define YY_INITIAL_VALUE(Value) /* Nothing. */ +#endif + #if ! defined yyoverflow || YYERROR_VERBOSE @@ -387,11 +410,11 @@ YYID (yyi) # define alloca _alloca # else # define YYSTACK_ALLOC alloca -# if ! defined _ALLOCA_H && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) +# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS # include /* INFRINGES ON USER NAME SPACE */ -# ifndef _STDLIB_H -# define _STDLIB_H 1 + /* Use EXIT_SUCCESS as a witness for stdlib.h. */ +# ifndef EXIT_SUCCESS +# define EXIT_SUCCESS 0 # endif # endif # endif @@ -399,8 +422,8 @@ YYID (yyi) # endif # ifdef YYSTACK_ALLOC - /* Pacify GCC's `empty if-body' warning. */ -# define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0)) + /* Pacify GCC's 'empty if-body' warning. */ +# define YYSTACK_FREE(Ptr) do { /* empty */; } while (0) # ifndef YYSTACK_ALLOC_MAXIMUM /* The OS might guarantee only one guard page at the bottom of the stack, and a page size can be as small as 4096 bytes. So we cannot safely @@ -414,25 +437,23 @@ YYID (yyi) # ifndef YYSTACK_ALLOC_MAXIMUM # define YYSTACK_ALLOC_MAXIMUM YYSIZE_MAXIMUM # endif -# if (defined __cplusplus && ! defined _STDLIB_H \ +# if (defined __cplusplus && ! defined EXIT_SUCCESS \ && ! ((defined YYMALLOC || defined malloc) \ - && (defined YYFREE || defined free))) + && (defined YYFREE || defined free))) # include /* INFRINGES ON USER NAME SPACE */ -# ifndef _STDLIB_H -# define _STDLIB_H 1 +# ifndef EXIT_SUCCESS +# define EXIT_SUCCESS 0 # endif # endif # ifndef YYMALLOC # define YYMALLOC malloc -# if ! defined malloc && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) +# if ! defined malloc && ! defined EXIT_SUCCESS void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */ # endif # endif # ifndef YYFREE # define YYFREE free -# if ! defined free && ! defined _STDLIB_H && (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) +# if ! defined free && ! defined EXIT_SUCCESS void free (void *); /* INFRINGES ON USER NAME SPACE */ # endif # endif @@ -442,7 +463,7 @@ void free (void *); /* INFRINGES ON USER NAME SPACE */ #if (! defined yyoverflow \ && (! defined __cplusplus \ - || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) + || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL))) /* A type that is properly aligned for any stack member. */ union yyalloc @@ -460,46 +481,50 @@ union yyalloc ((N) * (sizeof (yytype_int16) + sizeof (YYSTYPE)) \ + YYSTACK_GAP_MAXIMUM) -/* Copy COUNT objects from FROM to TO. The source and destination do - not overlap. */ -# ifndef YYCOPY -# if defined __GNUC__ && 1 < __GNUC__ -# define YYCOPY(To, From, Count) \ - __builtin_memcpy (To, From, (Count) * sizeof (*(From))) -# else -# define YYCOPY(To, From, Count) \ - do \ - { \ - YYSIZE_T yyi; \ - for (yyi = 0; yyi < (Count); yyi++) \ - (To)[yyi] = (From)[yyi]; \ - } \ - while (YYID (0)) -# endif -# endif +# define YYCOPY_NEEDED 1 /* Relocate STACK from its old location to the new one. The local variables YYSIZE and YYSTACKSIZE give the old and new number of elements in the stack, and YYPTR gives the new location of the stack. Advance YYPTR to a properly aligned location for the next stack. */ -# define YYSTACK_RELOCATE(Stack_alloc, Stack) \ - do \ - { \ - YYSIZE_T yynewbytes; \ - YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ - Stack = &yyptr->Stack_alloc; \ - yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ - yyptr += yynewbytes / sizeof (*yyptr); \ - } \ - while (YYID (0)) +# define YYSTACK_RELOCATE(Stack_alloc, Stack) \ + do \ + { \ + YYSIZE_T yynewbytes; \ + YYCOPY (&yyptr->Stack_alloc, Stack, yysize); \ + Stack = &yyptr->Stack_alloc; \ + yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \ + yyptr += yynewbytes / sizeof (*yyptr); \ + } \ + while (0) #endif +#if defined YYCOPY_NEEDED && YYCOPY_NEEDED +/* Copy COUNT objects from SRC to DST. The source and destination do + not overlap. */ +# ifndef YYCOPY +# if defined __GNUC__ && 1 < __GNUC__ +# define YYCOPY(Dst, Src, Count) \ + __builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src))) +# else +# define YYCOPY(Dst, Src, Count) \ + do \ + { \ + YYSIZE_T yyi; \ + for (yyi = 0; yyi < (Count); yyi++) \ + (Dst)[yyi] = (Src)[yyi]; \ + } \ + while (0) +# endif +# endif +#endif /* !YYCOPY_NEEDED */ + /* YYFINAL -- State number of the termination state. */ #define YYFINAL 57 /* YYLAST -- Last index in YYTABLE. */ -#define YYLAST 430 +#define YYLAST 431 /* YYNTOKENS -- Number of terminals. */ #define YYNTOKENS 58 @@ -507,17 +532,19 @@ union yyalloc #define YYNNTS 82 /* YYNRULES -- Number of rules. */ #define YYNRULES 190 -/* YYNRULES -- Number of states. */ +/* YYNSTATES -- Number of states. */ #define YYNSTATES 282 -/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */ +/* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned + by yylex, with out-of-bounds checking. */ #define YYUNDEFTOK 2 #define YYMAXUTOK 297 -#define YYTRANSLATE(YYX) \ +#define YYTRANSLATE(YYX) \ ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) -/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX. */ +/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM + as returned by yylex, without out-of-bounds checking. */ static const yytype_uint8 yytranslate[] = { 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, @@ -553,123 +580,39 @@ static const yytype_uint8 yytranslate[] = }; #if YYDEBUG -/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in - YYRHS. */ -static const yytype_uint16 yyprhs[] = -{ - 0, 0, 3, 6, 9, 12, 14, 17, 20, 23, - 26, 29, 32, 34, 38, 40, 44, 47, 48, 54, - 56, 58, 60, 64, 67, 70, 72, 75, 78, 80, - 82, 83, 91, 93, 95, 98, 100, 104, 106, 109, - 113, 116, 119, 122, 125, 126, 134, 136, 138, 141, - 143, 147, 149, 152, 156, 159, 162, 165, 168, 169, - 175, 177, 179, 181, 185, 187, 188, 192, 194, 196, - 197, 202, 204, 205, 210, 212, 214, 216, 218, 220, - 222, 225, 228, 231, 233, 238, 242, 246, 248, 250, - 252, 254, 256, 258, 262, 265, 269, 275, 280, 282, - 284, 288, 291, 295, 301, 306, 308, 313, 315, 319, - 323, 328, 330, 332, 334, 336, 338, 340, 342, 344, - 346, 348, 350, 352, 353, 358, 360, 362, 364, 366, - 368, 369, 374, 375, 380, 381, 386, 390, 394, 398, - 402, 404, 407, 409, 411, 413, 417, 419, 421, 423, - 425, 427, 429, 431, 433, 435, 437, 439, 441, 443, - 445, 447, 449, 451, 453, 455, 457, 459, 462, 464, - 465, 470, 472, 474, 478, 480, 482, 483, 493, 495, - 498, 501, 504, 508, 512, 513, 518, 521, 523, 525, - 527 -}; - -/* YYRHS -- A `-1'-separated list of the rules' RHS. */ -static const yytype_int16 yyrhs[] = -{ - 59, 0, -1, 40, 60, -1, 41, 114, -1, 42, - 100, -1, 139, -1, 60, 43, -1, 60, 70, -1, - 60, 131, -1, 60, 63, -1, 60, 67, -1, 60, - 68, -1, 8, -1, 61, 44, 8, -1, 61, -1, - 62, 45, 61, -1, 13, 62, -1, -1, 12, 62, - 13, 64, 65, -1, 66, -1, 46, -1, 61, -1, - 66, 47, 61, -1, 14, 98, -1, 15, 69, -1, - 139, -1, 69, 8, -1, 69, 9, -1, 71, -1, - 78, -1, -1, 10, 130, 72, 74, 48, 76, 49, - -1, 8, -1, 139, -1, 50, 75, -1, 73, -1, - 75, 47, 73, -1, 139, -1, 76, 43, -1, 76, - 77, 43, -1, 85, 124, -1, 126, 125, -1, 95, - 124, -1, 93, 124, -1, -1, 11, 130, 79, 81, - 48, 83, 49, -1, 8, -1, 139, -1, 50, 82, - -1, 80, -1, 82, 47, 80, -1, 139, -1, 83, - 43, -1, 83, 84, 43, -1, 85, 125, -1, 126, - 125, -1, 95, 125, -1, 93, 125, -1, -1, 130, - 51, 86, 87, 52, -1, 139, -1, 88, -1, 89, - -1, 88, 47, 89, -1, 98, -1, -1, 105, 91, - 106, -1, 105, -1, 90, -1, -1, 90, 53, 94, - 114, -1, 92, -1, -1, 92, 53, 96, 114, -1, - 90, -1, 92, -1, 93, -1, 95, -1, 97, -1, - 85, -1, 85, 125, -1, 95, 125, -1, 93, 125, - -1, 123, -1, 101, 51, 103, 52, -1, 101, 44, - 108, -1, 101, 54, 112, -1, 101, -1, 8, -1, - 78, -1, 131, -1, 139, -1, 113, -1, 113, 55, - 113, -1, 113, 112, -1, 103, 47, 113, -1, 103, - 47, 113, 55, 113, -1, 103, 47, 113, 112, -1, - 139, -1, 107, -1, 107, 55, 107, -1, 107, 109, - -1, 104, 47, 107, -1, 104, 47, 107, 55, 107, - -1, 104, 47, 107, 109, -1, 102, -1, 105, 56, - 104, 57, -1, 8, -1, 106, 44, 108, -1, 106, - 54, 112, -1, 106, 56, 104, 57, -1, 6, -1, - 108, -1, 3, -1, 4, -1, 4, -1, 3, -1, - 111, -1, 110, -1, 5, -1, 6, -1, 112, -1, - 116, -1, -1, 8, 53, 115, 116, -1, 110, -1, - 111, -1, 5, -1, 6, -1, 7, -1, -1, 48, - 117, 120, 49, -1, -1, 56, 118, 120, 57, -1, - -1, 51, 119, 120, 52, -1, 110, 46, 108, -1, - 111, 46, 108, -1, 5, 46, 108, -1, 7, 46, - 108, -1, 121, -1, 122, 121, -1, 139, -1, 47, - -1, 114, -1, 122, 47, 114, -1, 20, -1, 21, - -1, 22, -1, 23, -1, 24, -1, 25, -1, 26, - -1, 27, -1, 28, -1, 29, -1, 30, -1, 31, - -1, 32, -1, 33, -1, 34, -1, 35, -1, 36, - -1, 37, -1, 38, -1, 39, -1, 139, -1, 124, - 9, -1, 124, -1, -1, 8, 50, 127, 129, -1, - 8, -1, 128, -1, 129, 47, 128, -1, 139, -1, - 8, -1, -1, 16, 130, 51, 99, 52, 48, 132, - 133, 49, -1, 139, -1, 133, 43, -1, 133, 134, - -1, 133, 136, -1, 133, 137, 43, -1, 133, 138, - 43, -1, -1, 17, 135, 114, 50, -1, 18, 50, - -1, 19, -1, 95, -1, 93, -1, -1 -}; - -/* YYRLINE[YYN] -- source line where rule number YYN was defined. */ + /* YYRLINE[YYN] -- Source line where rule number YYN was defined. */ static const yytype_uint16 yyrline[] = { - 0, 168, 168, 169, 170, 177, 178, 179, 190, 196, - 197, 198, 202, 203, 210, 211, 218, 223, 222, 230, - 231, 238, 242, 249, 267, 271, 272, 276, 287, 288, - 293, 292, 304, 327, 328, 332, 338, 352, 353, 354, - 367, 377, 378, 386, 397, 396, 408, 431, 432, 436, - 442, 451, 452, 453, 464, 471, 472, 476, 484, 483, - 501, 502, 506, 507, 511, 521, 520, 531, 535, 537, - 536, 565, 567, 566, 595, 596, 600, 601, 605, 609, - 616, 620, 624, 631, 635, 644, 660, 675, 676, 708, - 724, 743, 747, 754, 761, 770, 776, 782, 793, 797, - 804, 811, 818, 824, 830, 839, 840, 851, 856, 871, - 886, 893, 902, 906, 917, 931, 935, 939, 943, 947, - 951, 960, 965, 969, 968, 983, 987, 991, 995, 999, - 1004, 1003, 1012, 1011, 1020, 1019, 1027, 1033, 1039, 1045, - 1054, 1055, 1059, 1060, 1064, 1065, 1069, 1073, 1077, 1081, - 1085, 1089, 1093, 1097, 1101, 1105, 1109, 1113, 1117, 1121, - 1125, 1129, 1133, 1137, 1141, 1145, 1152, 1156, 1163, 1173, - 1172, 1183, 1210, 1216, 1230, 1234, 1239, 1238, 1251, 1252, - 1253, 1254, 1255, 1256, 1270, 1269, 1290, 1299, 1306, 1310, - 1316 + 0, 174, 174, 175, 176, 183, 184, 185, 196, 202, + 203, 204, 208, 209, 216, 217, 224, 229, 228, 236, + 237, 244, 248, 255, 273, 277, 278, 282, 293, 294, + 299, 298, 310, 333, 334, 338, 344, 358, 359, 360, + 373, 383, 384, 392, 403, 402, 414, 437, 438, 442, + 448, 457, 458, 459, 470, 477, 478, 482, 490, 489, + 507, 508, 512, 513, 517, 527, 526, 537, 541, 543, + 542, 571, 573, 572, 601, 602, 606, 607, 611, 615, + 622, 626, 630, 637, 641, 650, 666, 681, 682, 714, + 730, 749, 753, 760, 767, 776, 782, 788, 799, 803, + 810, 817, 824, 830, 836, 845, 846, 857, 862, 877, + 892, 899, 908, 912, 923, 937, 941, 945, 949, 953, + 957, 966, 971, 975, 974, 989, 993, 997, 1001, 1005, + 1010, 1009, 1018, 1017, 1026, 1025, 1033, 1039, 1045, 1051, + 1060, 1061, 1065, 1066, 1070, 1071, 1075, 1079, 1083, 1087, + 1091, 1095, 1099, 1103, 1107, 1111, 1115, 1119, 1123, 1127, + 1131, 1135, 1139, 1143, 1147, 1151, 1158, 1162, 1169, 1179, + 1178, 1189, 1216, 1222, 1236, 1240, 1245, 1244, 1257, 1258, + 1259, 1260, 1261, 1262, 1276, 1275, 1296, 1305, 1312, 1316, + 1322 }; #endif -#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE +#if YYDEBUG || YYERROR_VERBOSE || 0 /* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM. First, the terminals, then, starting at YYNTOKENS, nonterminals. */ static const char *const yytname[] = { "$end", "error", "$undefined", "UNSIGNED_INTEGER", "SIGNED_INTEGER", - "REAL", "STRING", "HEX_STRING", "IDENTIFIER", "KEYWORD", "KW_DCLASS", + "REAL", "STRING", "IDENTIFIER", "HEX_STRING", "KEYWORD", "KW_DCLASS", "KW_STRUCT", "KW_FROM", "KW_IMPORT", "KW_TYPEDEF", "KW_KEYWORD", "KW_SWITCH", "KW_CASE", "KW_DEFAULT", "KW_BREAK", "KW_INT8", "KW_INT16", "KW_INT32", "KW_INT64", "KW_UINT8", "KW_UINT16", "KW_UINT32", @@ -697,13 +640,13 @@ static const char *const yytname[] = "array_def", "type_token", "keyword_list", "no_keyword_list", "molecular_field", "$@12", "atomic_name", "molecular_atom_list", "optional_name", "switch", "@13", "switch_fields", "switch_case", "$@14", - "switch_default", "switch_break", "switch_field", "empty", 0 + "switch_default", "switch_break", "switch_field", "empty", YY_NULLPTR }; #endif # ifdef YYPRINT -/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to - token YYLEX-NUM. */ +/* YYTOKNUM[NUM] -- (External) token number corresponding to the + (internal) symbol number NUM (which must be that of a token). */ static const yytype_uint16 yytoknum[] = { 0, 256, 257, 258, 259, 260, 261, 262, 263, 264, @@ -715,7 +658,250 @@ static const yytype_uint16 yytoknum[] = }; # endif -/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ +#define YYPACT_NINF -127 + +#define yypact_value_is_default(Yystate) \ + (!!((Yystate) == (-127))) + +#define YYTABLE_NINF -176 + +#define yytable_value_is_error(Yytable_value) \ + 0 + + /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing + STATE-NUM. */ +static const yytype_int16 yypact[] = +{ + 61, -127, 104, 359, 19, 128, -127, -127, -127, -23, + -127, -27, 17, -127, -127, -127, 44, 69, -127, -127, + 15, 42, 42, -127, -127, -127, -127, -127, -127, -127, + -127, -127, -127, -127, -127, -127, -127, -127, -127, -127, + -127, -127, -127, -127, -127, 46, 76, -127, -127, -127, + 4, -127, 27, -127, 22, -127, -127, -127, 42, 63, + 63, 392, -127, -127, -127, -127, -127, -127, -127, -127, + -127, 117, -127, 117, 24, 24, 24, 117, 117, -127, + -127, 96, 142, -127, -127, -127, -127, -127, -127, 117, + 153, 158, 53, 146, -127, -127, -127, 110, 1, 119, + -127, -127, -127, -127, 141, -127, -127, -127, 122, -127, + -127, -127, 116, -127, 120, -127, 114, 111, -127, -127, + 124, 359, -127, 104, 104, -127, -127, -127, 67, -127, + -127, -127, 33, -127, -127, -127, -12, 7, -127, -127, + -127, 20, 392, 125, 162, -127, 63, -127, -127, -127, + -127, 104, -127, -127, -127, 165, 129, -127, -127, -127, + -127, -127, 130, -127, -127, 153, -127, 153, -127, 53, + -127, -127, 53, -127, 117, 158, 53, 131, 133, -127, + -127, -127, 169, 136, -127, -127, 11, 110, -127, -127, + -127, 134, -127, 137, 36, -127, 12, -127, -127, -127, + -4, -127, 392, -127, -127, 139, -127, -127, 110, -127, + 140, 165, 291, -127, -127, 153, -127, 53, -127, -127, + -127, 169, 325, -127, 63, -127, 31, -127, -127, 145, + -127, -127, -127, -127, -127, -127, -127, -127, -127, -127, + 151, -127, -127, -127, -127, 110, -127, -127, -127, -127, + -127, -127, 257, -127, -127, 142, 142, 142, -127, 182, + -127, 147, -127, -127, -127, -127, -127, -127, -127, 155, + 156, -127, -127, 149, 104, -127, -127, -127, 182, 150, + -127, -127 +}; + + /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM. + Performed when YYTABLE does not specify something else to do. Zero + means the default is an error. */ +static const yytype_uint8 yydefact[] = +{ + 0, 190, 0, 190, 0, 2, 5, 116, 115, 127, + 128, 0, 129, 130, 134, 132, 125, 126, 3, 122, + 88, 190, 190, 146, 147, 148, 149, 150, 151, 152, + 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, + 163, 164, 165, 89, 190, 68, 71, 190, 190, 4, + 87, 105, 67, 83, 0, 90, 174, 1, 190, 0, + 0, 0, 190, 6, 9, 10, 11, 7, 28, 29, + 8, 0, 123, 0, 190, 190, 190, 0, 0, 175, + 44, 0, 168, 80, 166, 69, 72, 82, 81, 0, + 190, 0, 190, 0, 58, 30, 12, 14, 0, 16, + 88, 76, 77, 23, 24, 25, 113, 138, 0, 139, + 143, 144, 0, 140, 190, 142, 0, 0, 136, 137, + 190, 190, 167, 0, 0, 85, 119, 120, 0, 118, + 117, 121, 92, 91, 86, 111, 0, 99, 112, 98, + 107, 66, 190, 190, 0, 17, 0, 26, 27, 124, + 131, 143, 141, 135, 133, 0, 0, 47, 79, 74, + 75, 78, 0, 70, 73, 0, 84, 0, 94, 0, + 106, 114, 0, 101, 0, 0, 190, 0, 61, 62, + 64, 60, 0, 0, 33, 13, 0, 15, 145, 46, + 49, 48, 190, 0, 95, 93, 102, 100, 108, 109, + 0, 59, 0, 32, 35, 34, 190, 20, 21, 18, + 19, 0, 190, 51, 176, 0, 97, 0, 104, 110, + 63, 0, 190, 37, 0, 50, 88, 52, 45, 0, + 190, 190, 190, 190, 190, 96, 103, 36, 38, 31, + 0, 190, 190, 190, 190, 22, 169, 53, 54, 57, + 56, 55, 0, 178, 39, 40, 43, 42, 41, 0, + 184, 0, 187, 179, 177, 189, 188, 180, 181, 0, + 0, 171, 172, 170, 0, 186, 182, 183, 0, 0, + 173, 185 +}; + + /* YYPGOTO[NTERM-NUM]. */ +static const yytype_int16 yypgoto[] = +{ + -127, -127, -127, -126, 143, -127, -127, -127, -127, -127, + -127, -127, -127, -127, -127, -20, -127, -127, -127, -127, + 197, -127, -6, -127, -127, -127, -127, -116, -127, -127, + -127, 5, 85, -127, 87, -1, -127, 0, -127, -127, + 152, -127, -127, -127, -127, -127, 34, -127, -127, -125, + -56, 18, -81, -78, -90, -115, -2, -127, 108, -127, + -127, -127, 60, 103, -127, -127, -110, -40, -3, -127, + -60, -127, 47, 215, -127, -127, -127, -127, -127, -127, + -127, 3 +}; + + /* YYDEFGOTO[NTERM-NUM]. */ +static const yytype_int16 yydefgoto[] = +{ + -1, 4, 5, 97, 98, 64, 186, 209, 210, 65, + 66, 104, 67, 68, 143, 204, 183, 205, 222, 240, + 43, 120, 190, 156, 191, 212, 229, 44, 142, 177, + 178, 179, 45, 93, 46, 101, 123, 102, 124, 161, + 180, 162, 49, 50, 51, 128, 136, 52, 141, 137, + 138, 173, 16, 17, 131, 132, 111, 108, 19, 74, + 76, 75, 112, 113, 114, 53, 82, 83, 233, 259, + 272, 273, 54, 55, 234, 252, 267, 274, 268, 269, + 270, 84 +}; + + /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM. If + positive, shift that token. If negative, reduce the rule whose + number is the opposite. If YYTABLE_NINF, syntax error. */ +static const yytype_int16 yytable[] = +{ + 18, 134, 47, 48, 6, 158, 56, 87, 88, 129, + 129, 171, 130, 130, 145, 107, 171, 109, 96, 57, + 187, 118, 119, 71, 56, 56, 72, 7, 8, 9, + 10, 11, 12, 125, -65, 169, 7, 8, 126, 7, + 8, 126, 168, 169, 196, 170, 146, 197, 89, 79, + 194, 129, 195, 219, 130, 90, 106, 207, 91, 135, + 208, 56, 172, 73, 174, 105, -175, 217, 80, 81, + 96, 110, 13, 94, 175, 14, 176, 115, 115, 115, + 15, 246, -175, 92, 129, 199, 129, 130, 167, 130, + 77, 215, 236, 133, 129, 139, 230, 130, 245, 85, + 235, 1, 2, 3, 216, 95, 241, 7, 8, 9, + 10, 11, 12, 129, 165, 78, 130, 115, 198, 166, + 106, 163, 164, 157, 56, 7, 8, 9, 10, 86, + 12, 255, 256, 257, 129, 116, 117, 130, 58, 21, + 59, 60, 61, 62, 22, 181, 184, 121, 147, 188, + 148, 122, 13, 140, 144, 14, 7, 8, 126, 127, + 15, 7, 8, 126, 146, 150, 153, 151, 154, 185, + 13, 63, 189, 14, 155, 182, 203, 192, 15, 139, + 202, 211, 193, 201, 206, 214, 221, 224, 247, 271, + 248, 249, 250, 251, 254, 213, 278, 275, 276, 277, + 281, 237, 69, 99, 258, 225, 159, 220, 160, 223, + 200, 231, 232, 103, 218, 56, 149, 152, 280, 244, + 70, 242, 243, 0, 0, 56, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 253, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 265, 266, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 100, 0, 0, 0, 21, 0, + 0, 0, 279, 22, 260, 261, 262, 23, 24, 25, + 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, + 36, 37, 38, 39, 40, 41, 42, 0, 226, 0, + 263, 0, 21, 0, 0, 0, 264, 22, 0, 0, + 0, 23, 24, 25, 26, 27, 28, 29, 30, 31, + 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, + 42, 0, 226, 0, 227, 0, 21, 0, 0, 0, + 228, 22, 0, 0, 0, 23, 24, 25, 26, 27, + 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, + 38, 39, 40, 41, 42, 0, 20, 0, 238, 0, + 21, 0, 0, 0, 239, 22, 0, 0, 0, 23, + 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, + 34, 35, 36, 37, 38, 39, 40, 41, 42, 100, + 0, 0, 0, 21, 0, 0, 0, 0, 22, 0, + 0, 0, 23, 24, 25, 26, 27, 28, 29, 30, + 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, + 41, 42 +}; + +static const yytype_int16 yycheck[] = +{ + 2, 91, 3, 3, 1, 121, 3, 47, 48, 90, + 91, 4, 90, 91, 13, 71, 4, 73, 7, 0, + 146, 77, 78, 46, 21, 22, 53, 3, 4, 5, + 6, 7, 8, 89, 7, 47, 3, 4, 5, 3, + 4, 5, 132, 47, 169, 57, 45, 172, 44, 7, + 165, 132, 167, 57, 132, 51, 3, 46, 54, 6, + 186, 58, 55, 46, 44, 62, 51, 55, 21, 22, + 7, 47, 48, 51, 54, 51, 56, 74, 75, 76, + 56, 50, 51, 56, 165, 175, 167, 165, 55, 167, + 46, 55, 217, 90, 175, 92, 212, 175, 224, 53, + 215, 40, 41, 42, 194, 58, 222, 3, 4, 5, + 6, 7, 8, 194, 47, 46, 194, 114, 174, 52, + 3, 123, 124, 120, 121, 3, 4, 5, 6, 53, + 8, 241, 242, 243, 215, 75, 76, 215, 10, 11, + 12, 13, 14, 15, 16, 142, 143, 51, 7, 151, + 9, 9, 48, 7, 44, 51, 3, 4, 5, 6, + 56, 3, 4, 5, 45, 49, 52, 47, 57, 7, + 48, 43, 7, 51, 50, 50, 7, 48, 56, 176, + 47, 47, 52, 52, 48, 48, 47, 47, 43, 7, + 230, 231, 232, 233, 43, 192, 47, 50, 43, 43, + 50, 221, 5, 60, 244, 211, 121, 202, 121, 206, + 176, 212, 212, 61, 196, 212, 108, 114, 278, 222, + 5, 222, 222, -1, -1, 222, -1, -1, -1, -1, + -1, -1, -1, -1, -1, -1, -1, 234, -1, -1, + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, + -1, 252, 252, -1, -1, -1, -1, -1, -1, -1, + -1, -1, -1, -1, 7, -1, -1, -1, 11, -1, + -1, -1, 274, 16, 17, 18, 19, 20, 21, 22, + 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, + 33, 34, 35, 36, 37, 38, 39, -1, 7, -1, + 43, -1, 11, -1, -1, -1, 49, 16, -1, -1, + -1, 20, 21, 22, 23, 24, 25, 26, 27, 28, + 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, + 39, -1, 7, -1, 43, -1, 11, -1, -1, -1, + 49, 16, -1, -1, -1, 20, 21, 22, 23, 24, + 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, + 35, 36, 37, 38, 39, -1, 7, -1, 43, -1, + 11, -1, -1, -1, 49, 16, -1, -1, -1, 20, + 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, + 31, 32, 33, 34, 35, 36, 37, 38, 39, 7, + -1, -1, -1, 11, -1, -1, -1, -1, 16, -1, + -1, -1, 20, 21, 22, 23, 24, 25, 26, 27, + 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, + 38, 39 +}; + + /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing + symbol of state STATE-NUM. */ +static const yytype_uint8 yystos[] = +{ + 0, 40, 41, 42, 59, 60, 139, 3, 4, 5, + 6, 7, 8, 48, 51, 56, 110, 111, 114, 116, + 7, 11, 16, 20, 21, 22, 23, 24, 25, 26, + 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, + 37, 38, 39, 78, 85, 90, 92, 93, 95, 100, + 101, 102, 105, 123, 130, 131, 139, 0, 10, 12, + 13, 14, 15, 43, 63, 67, 68, 70, 71, 78, + 131, 46, 53, 46, 117, 119, 118, 46, 46, 7, + 130, 130, 124, 125, 139, 53, 53, 125, 125, 44, + 51, 54, 56, 91, 51, 130, 7, 61, 62, 62, + 7, 93, 95, 98, 69, 139, 3, 108, 115, 108, + 47, 114, 120, 121, 122, 139, 120, 120, 108, 108, + 79, 51, 9, 94, 96, 108, 5, 6, 103, 110, + 111, 112, 113, 139, 112, 6, 104, 107, 108, 139, + 7, 106, 86, 72, 44, 13, 45, 7, 9, 116, + 49, 47, 121, 52, 57, 50, 81, 139, 85, 90, + 92, 97, 99, 114, 114, 47, 52, 55, 112, 47, + 57, 4, 55, 109, 44, 54, 56, 87, 88, 89, + 98, 139, 50, 74, 139, 7, 64, 61, 114, 7, + 80, 82, 48, 52, 113, 113, 107, 107, 108, 112, + 104, 52, 47, 7, 73, 75, 48, 46, 61, 65, + 66, 47, 83, 139, 48, 55, 112, 55, 109, 57, + 89, 47, 76, 139, 47, 80, 7, 43, 49, 84, + 85, 93, 95, 126, 132, 113, 107, 73, 43, 49, + 77, 85, 93, 95, 126, 61, 50, 43, 125, 125, + 125, 125, 133, 139, 43, 124, 124, 124, 125, 127, + 17, 18, 19, 43, 49, 93, 95, 134, 136, 137, + 138, 7, 128, 129, 135, 50, 43, 43, 47, 114, + 128, 50 +}; + + /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */ static const yytype_uint8 yyr1[] = { 0, 58, 59, 59, 59, 60, 60, 60, 60, 60, @@ -740,7 +926,7 @@ static const yytype_uint8 yyr1[] = 139 }; -/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */ + /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN. */ static const yytype_uint8 yyr2[] = { 0, 2, 2, 2, 2, 1, 2, 2, 2, 2, @@ -765,340 +951,41 @@ static const yytype_uint8 yyr2[] = 0 }; -/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state - STATE-NUM when YYTABLE doesn't specify something else to do. Zero - means the default is an error. */ -static const yytype_uint8 yydefact[] = -{ - 0, 190, 0, 190, 0, 2, 5, 116, 115, 127, - 128, 129, 0, 130, 134, 132, 125, 126, 3, 122, - 88, 190, 190, 146, 147, 148, 149, 150, 151, 152, - 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, - 163, 164, 165, 89, 190, 68, 71, 190, 190, 4, - 87, 105, 67, 83, 0, 90, 174, 1, 190, 0, - 0, 0, 190, 6, 9, 10, 11, 7, 28, 29, - 8, 0, 0, 123, 190, 190, 190, 0, 0, 175, - 44, 0, 168, 80, 166, 69, 72, 82, 81, 0, - 190, 0, 190, 0, 58, 30, 12, 14, 0, 16, - 88, 76, 77, 23, 24, 25, 113, 138, 139, 0, - 143, 144, 0, 140, 190, 142, 0, 0, 136, 137, - 190, 190, 167, 0, 0, 85, 119, 120, 0, 118, - 117, 121, 92, 91, 86, 111, 0, 99, 112, 98, - 107, 66, 190, 190, 0, 17, 0, 26, 27, 124, - 131, 143, 141, 135, 133, 0, 0, 47, 79, 74, - 75, 78, 0, 70, 73, 0, 84, 0, 94, 0, - 106, 114, 0, 101, 0, 0, 190, 0, 61, 62, - 64, 60, 0, 0, 33, 13, 0, 15, 145, 46, - 49, 48, 190, 0, 95, 93, 102, 100, 108, 109, - 0, 59, 0, 32, 35, 34, 190, 20, 21, 18, - 19, 0, 190, 51, 176, 0, 97, 0, 104, 110, - 63, 0, 190, 37, 0, 50, 88, 52, 45, 0, - 190, 190, 190, 190, 190, 96, 103, 36, 38, 31, - 0, 190, 190, 190, 190, 22, 169, 53, 54, 57, - 56, 55, 0, 178, 39, 40, 43, 42, 41, 0, - 184, 0, 187, 179, 177, 189, 188, 180, 181, 0, - 0, 171, 172, 170, 0, 186, 182, 183, 0, 0, - 173, 185 -}; -/* YYDEFGOTO[NTERM-NUM]. */ -static const yytype_int16 yydefgoto[] = -{ - -1, 4, 5, 97, 98, 64, 186, 209, 210, 65, - 66, 104, 67, 68, 143, 204, 183, 205, 222, 240, - 43, 120, 190, 156, 191, 212, 229, 44, 142, 177, - 178, 179, 45, 93, 46, 101, 123, 102, 124, 161, - 180, 162, 49, 50, 51, 128, 136, 52, 141, 137, - 138, 173, 16, 17, 131, 132, 111, 109, 19, 74, - 76, 75, 112, 113, 114, 53, 82, 83, 233, 259, - 272, 273, 54, 55, 234, 252, 267, 274, 268, 269, - 270, 84 -}; +#define yyerrok (yyerrstatus = 0) +#define yyclearin (yychar = YYEMPTY) +#define YYEMPTY (-2) +#define YYEOF 0 -/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing - STATE-NUM. */ -#define YYPACT_NINF -127 -static const yytype_int16 yypact[] = -{ - 8, -127, 104, 359, 35, 128, -127, -127, -127, 20, - -127, 22, 28, -127, -127, -127, 37, 53, -127, -127, - 54, 139, 139, -127, -127, -127, -127, -127, -127, -127, - -127, -127, -127, -127, -127, -127, -127, -127, -127, -127, - -127, -127, -127, -127, -127, 95, 97, -127, -127, -127, - 2, -127, 26, -127, 100, -127, -127, -127, 139, 145, - 145, 391, -127, -127, -127, -127, -127, -127, -127, -127, - -127, 151, 151, -127, 24, 24, 24, 151, 151, -127, - -127, 108, 152, -127, -127, -127, -127, -127, -127, 151, - 127, 98, 64, 154, -127, -127, -127, 119, 13, 120, - -127, -127, -127, -127, 106, -127, -127, -127, -127, 122, - -127, -127, 115, -127, 121, -127, 114, 110, -127, -127, - 124, 359, -127, 104, 104, -127, -127, -127, 12, -127, - -127, -127, 14, -127, -127, -127, 16, 7, -127, -127, - -127, 1, 391, 125, 161, -127, 145, -127, -127, -127, - -127, 104, -127, -127, -127, 164, 129, -127, -127, -127, - -127, -127, 130, -127, -127, 127, -127, 127, -127, 64, - -127, -127, 64, -127, 151, 98, 64, 131, 133, -127, - -127, -127, 168, 136, -127, -127, 6, 119, -127, -127, - -127, 134, -127, 137, 33, -127, 19, -127, -127, -127, - 43, -127, 391, -127, -127, 140, -127, -127, 119, -127, - 141, 164, 291, -127, -127, 127, -127, 64, -127, -127, - -127, 168, 325, -127, 145, -127, 69, -127, -127, 143, - -127, -127, -127, -127, -127, -127, -127, -127, -127, -127, - 146, -127, -127, -127, -127, 119, -127, -127, -127, -127, - -127, -127, 257, -127, -127, 152, 152, 152, -127, 186, - -127, 147, -127, -127, -127, -127, -127, -127, -127, 153, - 155, -127, -127, 156, 104, -127, -127, -127, 186, 149, - -127, -127 -}; +#define YYACCEPT goto yyacceptlab +#define YYABORT goto yyabortlab +#define YYERROR goto yyerrorlab -/* YYPGOTO[NTERM-NUM]. */ -static const yytype_int16 yypgoto[] = -{ - -127, -127, -127, -126, 142, -127, -127, -127, -127, -127, - -127, -127, -127, -127, -127, -21, -127, -127, -127, -127, - 196, -127, -6, -127, -127, -127, -127, -116, -127, -127, - -127, 4, 86, -127, 87, -1, -127, 0, -127, -127, - 157, -127, -127, -127, -127, -127, 34, -127, -127, -125, - -56, 17, -81, -78, -90, -124, -2, -127, 105, -127, - -127, -127, 60, 102, -127, -127, -85, -40, -5, -127, - -59, -127, 18, 215, -127, -127, -127, -127, -127, -127, - -127, 3 -}; - -/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If - positive, shift that token. If negative, reduce the rule which - number is the opposite. If zero, do what YYDEFACT says. - If YYTABLE_NINF, syntax error. */ -#define YYTABLE_NINF -176 -static const yytype_int16 yytable[] = -{ - 18, 134, 47, 48, 6, 158, 56, 87, 88, 129, - 129, 171, 130, 130, 96, 107, 108, 7, 8, 126, - 187, 118, 119, 171, 56, 56, 145, 7, 8, 9, - 10, 11, 12, 125, -65, 57, 7, 8, 126, 80, - 81, 194, 168, 195, 196, 174, 89, 197, 1, 2, - 3, 129, 207, 90, 130, 175, 91, 176, 146, 165, - 208, 56, 172, 169, 166, 105, 71, 106, 72, 167, - 135, 110, 13, 170, 217, 14, 95, 115, 115, 115, - 15, 73, 92, 77, 129, 199, 129, 130, 215, 130, - 169, 235, 236, 133, 129, 139, 230, 130, 245, 78, - 219, 7, 8, 126, 216, -175, 241, 7, 8, 9, - 10, 11, 12, 129, 147, 148, 130, 115, 198, 246, - -175, 163, 164, 157, 56, 7, 8, 9, 10, 11, - 7, 8, 126, 127, 129, 116, 117, 130, 58, 21, - 59, 60, 61, 62, 22, 181, 184, 79, 85, 188, - 86, 94, 13, 96, 106, 14, 255, 256, 257, 121, - 15, 122, 140, 144, 150, 146, 153, 154, 151, 185, - 13, 63, 189, 14, 155, 182, 203, 192, 15, 139, - 202, 211, 193, 201, 206, 214, 247, 221, 224, 254, - 248, 249, 250, 251, 271, 213, 276, 275, 277, 281, - 237, 69, 99, 278, 258, 225, 220, 159, 160, 223, - 200, 231, 232, 218, 149, 56, 152, 244, 103, 280, - 70, 242, 243, 0, 0, 56, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 253, 0, 0, - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 0, 265, 266, 0, 0, 0, 0, 0, 0, 0, - 0, 0, 0, 0, 0, 100, 0, 0, 21, 0, - 0, 0, 279, 22, 260, 261, 262, 23, 24, 25, - 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, - 36, 37, 38, 39, 40, 41, 42, 0, 0, 226, - 263, 0, 21, 0, 0, 0, 264, 22, 0, 0, - 0, 23, 24, 25, 26, 27, 28, 29, 30, 31, - 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, - 42, 0, 0, 226, 227, 0, 21, 0, 0, 0, - 228, 22, 0, 0, 0, 23, 24, 25, 26, 27, - 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, - 38, 39, 40, 41, 42, 0, 0, 20, 238, 0, - 21, 0, 0, 0, 239, 22, 0, 0, 0, 23, - 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, - 34, 35, 36, 37, 38, 39, 40, 41, 42, 100, - 0, 0, 21, 0, 0, 0, 0, 22, 0, 0, - 0, 23, 24, 25, 26, 27, 28, 29, 30, 31, - 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, - 42 -}; - -static const yytype_int16 yycheck[] = -{ - 2, 91, 3, 3, 1, 121, 3, 47, 48, 90, - 91, 4, 90, 91, 8, 71, 72, 3, 4, 5, - 146, 77, 78, 4, 21, 22, 13, 3, 4, 5, - 6, 7, 8, 89, 8, 0, 3, 4, 5, 21, - 22, 165, 132, 167, 169, 44, 44, 172, 40, 41, - 42, 132, 46, 51, 132, 54, 54, 56, 45, 47, - 186, 58, 55, 47, 52, 62, 46, 3, 46, 55, - 6, 47, 48, 57, 55, 51, 58, 74, 75, 76, - 56, 53, 56, 46, 165, 175, 167, 165, 55, 167, - 47, 215, 217, 90, 175, 92, 212, 175, 224, 46, - 57, 3, 4, 5, 194, 51, 222, 3, 4, 5, - 6, 7, 8, 194, 8, 9, 194, 114, 174, 50, - 51, 123, 124, 120, 121, 3, 4, 5, 6, 7, - 3, 4, 5, 6, 215, 75, 76, 215, 10, 11, - 12, 13, 14, 15, 16, 142, 143, 8, 53, 151, - 53, 51, 48, 8, 3, 51, 241, 242, 243, 51, - 56, 9, 8, 44, 49, 45, 52, 57, 47, 8, - 48, 43, 8, 51, 50, 50, 8, 48, 56, 176, - 47, 47, 52, 52, 48, 48, 43, 47, 47, 43, - 230, 231, 232, 233, 8, 192, 43, 50, 43, 50, - 221, 5, 60, 47, 244, 211, 202, 121, 121, 206, - 176, 212, 212, 196, 109, 212, 114, 222, 61, 278, - 5, 222, 222, -1, -1, 222, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, 234, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, 252, 252, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, 8, -1, -1, 11, -1, - -1, -1, 274, 16, 17, 18, 19, 20, 21, 22, - 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, - 33, 34, 35, 36, 37, 38, 39, -1, -1, 8, - 43, -1, 11, -1, -1, -1, 49, 16, -1, -1, - -1, 20, 21, 22, 23, 24, 25, 26, 27, 28, - 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, - 39, -1, -1, 8, 43, -1, 11, -1, -1, -1, - 49, 16, -1, -1, -1, 20, 21, 22, 23, 24, - 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, - 35, 36, 37, 38, 39, -1, -1, 8, 43, -1, - 11, -1, -1, -1, 49, 16, -1, -1, -1, 20, - 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, - 31, 32, 33, 34, 35, 36, 37, 38, 39, 8, - -1, -1, 11, -1, -1, -1, -1, 16, -1, -1, - -1, 20, 21, 22, 23, 24, 25, 26, 27, 28, - 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, - 39 -}; - -/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing - symbol of state STATE-NUM. */ -static const yytype_uint8 yystos[] = -{ - 0, 40, 41, 42, 59, 60, 139, 3, 4, 5, - 6, 7, 8, 48, 51, 56, 110, 111, 114, 116, - 8, 11, 16, 20, 21, 22, 23, 24, 25, 26, - 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, - 37, 38, 39, 78, 85, 90, 92, 93, 95, 100, - 101, 102, 105, 123, 130, 131, 139, 0, 10, 12, - 13, 14, 15, 43, 63, 67, 68, 70, 71, 78, - 131, 46, 46, 53, 117, 119, 118, 46, 46, 8, - 130, 130, 124, 125, 139, 53, 53, 125, 125, 44, - 51, 54, 56, 91, 51, 130, 8, 61, 62, 62, - 8, 93, 95, 98, 69, 139, 3, 108, 108, 115, - 47, 114, 120, 121, 122, 139, 120, 120, 108, 108, - 79, 51, 9, 94, 96, 108, 5, 6, 103, 110, - 111, 112, 113, 139, 112, 6, 104, 107, 108, 139, - 8, 106, 86, 72, 44, 13, 45, 8, 9, 116, - 49, 47, 121, 52, 57, 50, 81, 139, 85, 90, - 92, 97, 99, 114, 114, 47, 52, 55, 112, 47, - 57, 4, 55, 109, 44, 54, 56, 87, 88, 89, - 98, 139, 50, 74, 139, 8, 64, 61, 114, 8, - 80, 82, 48, 52, 113, 113, 107, 107, 108, 112, - 104, 52, 47, 8, 73, 75, 48, 46, 61, 65, - 66, 47, 83, 139, 48, 55, 112, 55, 109, 57, - 89, 47, 76, 139, 47, 80, 8, 43, 49, 84, - 85, 93, 95, 126, 132, 113, 107, 73, 43, 49, - 77, 85, 93, 95, 126, 61, 50, 43, 125, 125, - 125, 125, 133, 139, 43, 124, 124, 124, 125, 127, - 17, 18, 19, 43, 49, 93, 95, 134, 136, 137, - 138, 8, 128, 129, 135, 50, 43, 43, 47, 114, - 128, 50 -}; - -#define yyerrok (yyerrstatus = 0) -#define yyclearin (yychar = YYEMPTY) -#define YYEMPTY (-2) -#define YYEOF 0 - -#define YYACCEPT goto yyacceptlab -#define YYABORT goto yyabortlab -#define YYERROR goto yyerrorlab - - -/* Like YYERROR except do call yyerror. This remains here temporarily - to ease the transition to the new meaning of YYERROR, for GCC. - Once GCC version 2 has supplanted version 1, this can go. However, - YYFAIL appears to be in use. Nevertheless, it is formally deprecated - in Bison 2.4.2's NEWS entry, where a plan to phase it out is - discussed. */ - -#define YYFAIL goto yyerrlab -#if defined YYFAIL - /* This is here to suppress warnings from the GCC cpp's - -Wunused-macros. Normally we don't worry about that warning, but - some users do, and we want to make it easy for users to remove - YYFAIL uses, which will produce warnings from Bison 2.5. */ -#endif #define YYRECOVERING() (!!yyerrstatus) -#define YYBACKUP(Token, Value) \ -do \ - if (yychar == YYEMPTY && yylen == 1) \ - { \ - yychar = (Token); \ - yylval = (Value); \ - yytoken = YYTRANSLATE (yychar); \ - YYPOPSTACK (1); \ - goto yybackup; \ - } \ - else \ - { \ +#define YYBACKUP(Token, Value) \ +do \ + if (yychar == YYEMPTY) \ + { \ + yychar = (Token); \ + yylval = (Value); \ + YYPOPSTACK (yylen); \ + yystate = *yyssp; \ + goto yybackup; \ + } \ + else \ + { \ yyerror (YY_("syntax error: cannot back up")); \ - YYERROR; \ - } \ -while (YYID (0)) + YYERROR; \ + } \ +while (0) + +/* Error token number */ +#define YYTERROR 1 +#define YYERRCODE 256 -#define YYTERROR 1 -#define YYERRCODE 256 - - -/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. - If N is 0, then set CURRENT to the empty location which ends - the previous symbol: RHS[0] (always defined). */ - -#define YYRHSLOC(Rhs, K) ((Rhs)[K]) -#ifndef YYLLOC_DEFAULT -# define YYLLOC_DEFAULT(Current, Rhs, N) \ - do \ - if (YYID (N)) \ - { \ - (Current).first_line = YYRHSLOC (Rhs, 1).first_line; \ - (Current).first_column = YYRHSLOC (Rhs, 1).first_column; \ - (Current).last_line = YYRHSLOC (Rhs, N).last_line; \ - (Current).last_column = YYRHSLOC (Rhs, N).last_column; \ - } \ - else \ - { \ - (Current).first_line = (Current).last_line = \ - YYRHSLOC (Rhs, 0).last_line; \ - (Current).first_column = (Current).last_column = \ - YYRHSLOC (Rhs, 0).last_column; \ - } \ - while (YYID (0)) -#endif - - -/* YY_LOCATION_PRINT -- Print the location on the stream. - This macro was not mandated originally: define only if we know - we won't break user code: when these are the locations we know. */ - -#ifndef YY_LOCATION_PRINT -# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL -# define YY_LOCATION_PRINT(File, Loc) \ - fprintf (File, "%d.%d-%d.%d", \ - (Loc).first_line, (Loc).first_column, \ - (Loc).last_line, (Loc).last_column) -# else -# define YY_LOCATION_PRINT(File, Loc) ((void) 0) -# endif -#endif - - -/* YYLEX -- calling `yylex' with the right arguments. */ - -#ifdef YYLEX_PARAM -# define YYLEX yylex (YYLEX_PARAM) -#else -# define YYLEX yylex () -#endif /* Enable debugging if requested. */ #if YYDEBUG @@ -1108,54 +995,46 @@ while (YYID (0)) # define YYFPRINTF fprintf # endif -# define YYDPRINTF(Args) \ -do { \ - if (yydebug) \ - YYFPRINTF Args; \ -} while (YYID (0)) +# define YYDPRINTF(Args) \ +do { \ + if (yydebug) \ + YYFPRINTF Args; \ +} while (0) -# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ -do { \ - if (yydebug) \ - { \ - YYFPRINTF (stderr, "%s ", Title); \ - yy_symbol_print (stderr, \ - Type, Value); \ - YYFPRINTF (stderr, "\n"); \ - } \ -} while (YYID (0)) +/* This macro is provided for backward compatibility. */ +#ifndef YY_LOCATION_PRINT +# define YY_LOCATION_PRINT(File, Loc) ((void) 0) +#endif -/*--------------------------------. -| Print this symbol on YYOUTPUT. | -`--------------------------------*/ +# define YY_SYMBOL_PRINT(Title, Type, Value, Location) \ +do { \ + if (yydebug) \ + { \ + YYFPRINTF (stderr, "%s ", Title); \ + yy_symbol_print (stderr, \ + Type, Value); \ + YYFPRINTF (stderr, "\n"); \ + } \ +} while (0) + + +/*----------------------------------------. +| Print this symbol's value on YYOUTPUT. | +`----------------------------------------*/ -/*ARGSUSED*/ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) static void yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) -#else -static void -yy_symbol_value_print (yyoutput, yytype, yyvaluep) - FILE *yyoutput; - int yytype; - YYSTYPE const * const yyvaluep; -#endif { + FILE *yyo = yyoutput; + YYUSE (yyo); if (!yyvaluep) return; # ifdef YYPRINT if (yytype < YYNTOKENS) YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep); -# else - YYUSE (yyoutput); # endif - switch (yytype) - { - default: - break; - } + YYUSE (yytype); } @@ -1163,22 +1042,11 @@ yy_symbol_value_print (yyoutput, yytype, yyvaluep) | Print this symbol on YYOUTPUT. | `--------------------------------*/ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) static void yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep) -#else -static void -yy_symbol_print (yyoutput, yytype, yyvaluep) - FILE *yyoutput; - int yytype; - YYSTYPE const * const yyvaluep; -#endif { - if (yytype < YYNTOKENS) - YYFPRINTF (yyoutput, "token %s (", yytname[yytype]); - else - YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]); + YYFPRINTF (yyoutput, "%s %s (", + yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]); yy_symbol_value_print (yyoutput, yytype, yyvaluep); YYFPRINTF (yyoutput, ")"); @@ -1189,16 +1057,8 @@ yy_symbol_print (yyoutput, yytype, yyvaluep) | TOP (included). | `------------------------------------------------------------------*/ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) static void yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop) -#else -static void -yy_stack_print (yybottom, yytop) - yytype_int16 *yybottom; - yytype_int16 *yytop; -#endif { YYFPRINTF (stderr, "Stack now"); for (; yybottom <= yytop; yybottom++) @@ -1209,49 +1069,42 @@ yy_stack_print (yybottom, yytop) YYFPRINTF (stderr, "\n"); } -# define YY_STACK_PRINT(Bottom, Top) \ -do { \ - if (yydebug) \ - yy_stack_print ((Bottom), (Top)); \ -} while (YYID (0)) +# define YY_STACK_PRINT(Bottom, Top) \ +do { \ + if (yydebug) \ + yy_stack_print ((Bottom), (Top)); \ +} while (0) /*------------------------------------------------. | Report that the YYRULE is going to be reduced. | `------------------------------------------------*/ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) static void -yy_reduce_print (YYSTYPE *yyvsp, int yyrule) -#else -static void -yy_reduce_print (yyvsp, yyrule) - YYSTYPE *yyvsp; - int yyrule; -#endif +yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule) { + unsigned long int yylno = yyrline[yyrule]; int yynrhs = yyr2[yyrule]; int yyi; - unsigned long int yylno = yyrline[yyrule]; YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", - yyrule - 1, yylno); + yyrule - 1, yylno); /* The symbols being reduced. */ for (yyi = 0; yyi < yynrhs; yyi++) { YYFPRINTF (stderr, " $%d = ", yyi + 1); - yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi], - &(yyvsp[(yyi + 1) - (yynrhs)]) - ); + yy_symbol_print (stderr, + yystos[yyssp[yyi + 1 - yynrhs]], + &(yyvsp[(yyi + 1) - (yynrhs)]) + ); YYFPRINTF (stderr, "\n"); } } -# define YY_REDUCE_PRINT(Rule) \ -do { \ - if (yydebug) \ - yy_reduce_print (yyvsp, Rule); \ -} while (YYID (0)) +# define YY_REDUCE_PRINT(Rule) \ +do { \ + if (yydebug) \ + yy_reduce_print (yyssp, yyvsp, Rule); \ +} while (0) /* Nonzero means print parse trace. It is left uninitialized so that multiple parsers can coexist. */ @@ -1265,7 +1118,7 @@ int yydebug; /* YYINITDEPTH -- initial size of the parser's stacks. */ -#ifndef YYINITDEPTH +#ifndef YYINITDEPTH # define YYINITDEPTH 200 #endif @@ -1280,7 +1133,6 @@ int yydebug; # define YYMAXDEPTH 10000 #endif - #if YYERROR_VERBOSE @@ -1289,15 +1141,8 @@ int yydebug; # define yystrlen strlen # else /* Return the length of YYSTR. */ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) static YYSIZE_T yystrlen (const char *yystr) -#else -static YYSIZE_T -yystrlen (yystr) - const char *yystr; -#endif { YYSIZE_T yylen; for (yylen = 0; yystr[yylen]; yylen++) @@ -1313,16 +1158,8 @@ yystrlen (yystr) # else /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in YYDEST. */ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) static char * yystpcpy (char *yydest, const char *yysrc) -#else -static char * -yystpcpy (yydest, yysrc) - char *yydest; - const char *yysrc; -#endif { char *yyd = yydest; const char *yys = yysrc; @@ -1352,27 +1189,27 @@ yytnamerr (char *yyres, const char *yystr) char const *yyp = yystr; for (;;) - switch (*++yyp) - { - case '\'': - case ',': - goto do_not_strip_quotes; + switch (*++yyp) + { + case '\'': + case ',': + goto do_not_strip_quotes; - case '\\': - if (*++yyp != '\\') - goto do_not_strip_quotes; - /* Fall through. */ - default: - if (yyres) - yyres[yyn] = *yyp; - yyn++; - break; + case '\\': + if (*++yyp != '\\') + goto do_not_strip_quotes; + /* Fall through. */ + default: + if (yyres) + yyres[yyn] = *yyp; + yyn++; + break; - case '"': - if (yyres) - yyres[yyn] = '\0'; - return yyn; - } + case '"': + if (yyres) + yyres[yyn] = '\0'; + return yyn; + } do_not_strip_quotes: ; } @@ -1383,161 +1220,160 @@ yytnamerr (char *yyres, const char *yystr) } # endif -/* Copy into YYRESULT an error message about the unexpected token - YYCHAR while in state YYSTATE. Return the number of bytes copied, - including the terminating null byte. If YYRESULT is null, do not - copy anything; just return the number of bytes that would be - copied. As a special case, return 0 if an ordinary "syntax error" - message will do. Return YYSIZE_MAXIMUM if overflow occurs during - size calculation. */ -static YYSIZE_T -yysyntax_error (char *yyresult, int yystate, int yychar) +/* Copy into *YYMSG, which is of size *YYMSG_ALLOC, an error message + about the unexpected token YYTOKEN for the state stack whose top is + YYSSP. + + Return 0 if *YYMSG was successfully written. Return 1 if *YYMSG is + not large enough to hold the message. In that case, also set + *YYMSG_ALLOC to the required number of bytes. Return 2 if the + required number of bytes is too large to store. */ +static int +yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, + yytype_int16 *yyssp, int yytoken) { - int yyn = yypact[yystate]; + YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]); + YYSIZE_T yysize = yysize0; + enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; + /* Internationalized format string. */ + const char *yyformat = YY_NULLPTR; + /* Arguments of yyformat. */ + char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; + /* Number of reported tokens (one for the "unexpected", one per + "expected"). */ + int yycount = 0; - if (! (YYPACT_NINF < yyn && yyn <= YYLAST)) - return 0; - else + /* There are many possibilities here to consider: + - If this state is a consistent state with a default action, then + the only way this function was invoked is if the default action + is an error action. In that case, don't check for expected + tokens because there are none. + - The only way there can be no lookahead present (in yychar) is if + this state is a consistent state with a default action. Thus, + detecting the absence of a lookahead is sufficient to determine + that there is no unexpected or expected token to report. In that + case, just report a simple "syntax error". + - Don't assume there isn't a lookahead just because this state is a + consistent state with a default action. There might have been a + previous inconsistent state, consistent state with a non-default + action, or user semantic action that manipulated yychar. + - Of course, the expected token list depends on states to have + correct lookahead information, and it depends on the parser not + to perform extra reductions after fetching a lookahead from the + scanner and before detecting a syntax error. Thus, state merging + (from LALR or IELR) and default reductions corrupt the expected + token list. However, the list is correct for canonical LR with + one exception: it will still contain any token that will not be + accepted due to an error action in a later state. + */ + if (yytoken != YYEMPTY) { - int yytype = YYTRANSLATE (yychar); - YYSIZE_T yysize0 = yytnamerr (0, yytname[yytype]); - YYSIZE_T yysize = yysize0; - YYSIZE_T yysize1; - int yysize_overflow = 0; - enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 }; - char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM]; - int yyx; + int yyn = yypact[*yyssp]; + yyarg[yycount++] = yytname[yytoken]; + if (!yypact_value_is_default (yyn)) + { + /* Start YYX at -YYN if negative to avoid negative indexes in + YYCHECK. In other words, skip the first -YYN actions for + this state because they are default actions. */ + int yyxbegin = yyn < 0 ? -yyn : 0; + /* Stay within bounds of both yycheck and yytname. */ + int yychecklim = YYLAST - yyn + 1; + int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; + int yyx; -# if 0 - /* This is so xgettext sees the translatable formats that are - constructed on the fly. */ - YY_("syntax error, unexpected %s"); - YY_("syntax error, unexpected %s, expecting %s"); - YY_("syntax error, unexpected %s, expecting %s or %s"); - YY_("syntax error, unexpected %s, expecting %s or %s or %s"); - YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s"); -# endif - char *yyfmt; - char const *yyf; - static char const yyunexpected[] = "syntax error, unexpected %s"; - static char const yyexpecting[] = ", expecting %s"; - static char const yyor[] = " or %s"; - char yyformat[sizeof yyunexpected - + sizeof yyexpecting - 1 - + ((YYERROR_VERBOSE_ARGS_MAXIMUM - 2) - * (sizeof yyor - 1))]; - char const *yyprefix = yyexpecting; - - /* Start YYX at -YYN if negative to avoid negative indexes in - YYCHECK. */ - int yyxbegin = yyn < 0 ? -yyn : 0; - - /* Stay within bounds of both yycheck and yytname. */ - int yychecklim = YYLAST - yyn + 1; - int yyxend = yychecklim < YYNTOKENS ? yychecklim : YYNTOKENS; - int yycount = 1; - - yyarg[0] = yytname[yytype]; - yyfmt = yystpcpy (yyformat, yyunexpected); - - for (yyx = yyxbegin; yyx < yyxend; ++yyx) - if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR) - { - if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) - { - yycount = 1; - yysize = yysize0; - yyformat[sizeof yyunexpected - 1] = '\0'; - break; - } - yyarg[yycount++] = yytname[yyx]; - yysize1 = yysize + yytnamerr (0, yytname[yyx]); - yysize_overflow |= (yysize1 < yysize); - yysize = yysize1; - yyfmt = yystpcpy (yyfmt, yyprefix); - yyprefix = yyor; - } - - yyf = YY_(yyformat); - yysize1 = yysize + yystrlen (yyf); - yysize_overflow |= (yysize1 < yysize); - yysize = yysize1; - - if (yysize_overflow) - return YYSIZE_MAXIMUM; - - if (yyresult) - { - /* Avoid sprintf, as that infringes on the user's name space. - Don't have undefined behavior even if the translation - produced a string with the wrong number of "%s"s. */ - char *yyp = yyresult; - int yyi = 0; - while ((*yyp = *yyf) != '\0') - { - if (*yyp == '%' && yyf[1] == 's' && yyi < yycount) - { - yyp += yytnamerr (yyp, yyarg[yyi++]); - yyf += 2; - } - else - { - yyp++; - yyf++; - } - } - } - return yysize; + for (yyx = yyxbegin; yyx < yyxend; ++yyx) + if (yycheck[yyx + yyn] == yyx && yyx != YYTERROR + && !yytable_value_is_error (yytable[yyx + yyn])) + { + if (yycount == YYERROR_VERBOSE_ARGS_MAXIMUM) + { + yycount = 1; + yysize = yysize0; + break; + } + yyarg[yycount++] = yytname[yyx]; + { + YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]); + if (! (yysize <= yysize1 + && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) + return 2; + yysize = yysize1; + } + } + } } + + switch (yycount) + { +# define YYCASE_(N, S) \ + case N: \ + yyformat = S; \ + break + YYCASE_(0, YY_("syntax error")); + YYCASE_(1, YY_("syntax error, unexpected %s")); + YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); + YYCASE_(3, YY_("syntax error, unexpected %s, expecting %s or %s")); + YYCASE_(4, YY_("syntax error, unexpected %s, expecting %s or %s or %s")); + YYCASE_(5, YY_("syntax error, unexpected %s, expecting %s or %s or %s or %s")); +# undef YYCASE_ + } + + { + YYSIZE_T yysize1 = yysize + yystrlen (yyformat); + if (! (yysize <= yysize1 && yysize1 <= YYSTACK_ALLOC_MAXIMUM)) + return 2; + yysize = yysize1; + } + + if (*yymsg_alloc < yysize) + { + *yymsg_alloc = 2 * yysize; + if (! (yysize <= *yymsg_alloc + && *yymsg_alloc <= YYSTACK_ALLOC_MAXIMUM)) + *yymsg_alloc = YYSTACK_ALLOC_MAXIMUM; + return 1; + } + + /* Avoid sprintf, as that infringes on the user's name space. + Don't have undefined behavior even if the translation + produced a string with the wrong number of "%s"s. */ + { + char *yyp = *yymsg; + int yyi = 0; + while ((*yyp = *yyformat) != '\0') + if (*yyp == '%' && yyformat[1] == 's' && yyi < yycount) + { + yyp += yytnamerr (yyp, yyarg[yyi++]); + yyformat += 2; + } + else + { + yyp++; + yyformat++; + } + } + return 0; } #endif /* YYERROR_VERBOSE */ - /*-----------------------------------------------. | Release the memory associated to this symbol. | `-----------------------------------------------*/ -/*ARGSUSED*/ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) static void yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep) -#else -static void -yydestruct (yymsg, yytype, yyvaluep) - const char *yymsg; - int yytype; - YYSTYPE *yyvaluep; -#endif { YYUSE (yyvaluep); - if (!yymsg) yymsg = "Deleting"; YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp); - switch (yytype) - { - - default: - break; - } + YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN + YYUSE (yytype); + YY_IGNORE_MAYBE_UNINITIALIZED_END } -/* Prevent warnings from -Wmissing-prototypes. */ -#ifdef YYPARSE_PARAM -#if defined __STDC__ || defined __cplusplus -int yyparse (void *YYPARSE_PARAM); -#else -int yyparse (); -#endif -#else /* ! YYPARSE_PARAM */ -#if defined __STDC__ || defined __cplusplus -int yyparse (void); -#else -int yyparse (); -#endif -#endif /* ! YYPARSE_PARAM */ + /* The lookahead symbol. */ @@ -1545,49 +1381,26 @@ int yychar; /* The semantic value of the lookahead symbol. */ YYSTYPE yylval; - /* Number of syntax errors so far. */ int yynerrs; +/*----------. +| yyparse. | +`----------*/ -/*-------------------------. -| yyparse or yypush_parse. | -`-------------------------*/ - -#ifdef YYPARSE_PARAM -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) -int -yyparse (void *YYPARSE_PARAM) -#else -int -yyparse (YYPARSE_PARAM) - void *YYPARSE_PARAM; -#endif -#else /* ! YYPARSE_PARAM */ -#if (defined __STDC__ || defined __C99__FUNC__ \ - || defined __cplusplus || defined _MSC_VER) int yyparse (void) -#else -int -yyparse () - -#endif -#endif { - - int yystate; /* Number of tokens to shift before error messages enabled. */ int yyerrstatus; /* The stacks and their tools: - `yyss': related to states. - `yyvs': related to semantic values. + 'yyss': related to states. + 'yyvs': related to semantic values. - Refer to the stacks thru separate pointers, to allow yyoverflow + Refer to the stacks through separate pointers, to allow yyoverflow to reallocate them elsewhere. */ /* The state stack. */ @@ -1605,7 +1418,7 @@ yyparse () int yyn; int yyresult; /* Lookahead token as an internal (translated) token number. */ - int yytoken; + int yytoken = 0; /* The variables used to return semantic value and location from the action routines. */ YYSTYPE yyval; @@ -1623,9 +1436,8 @@ yyparse () Keep to zero when no symbol should be popped. */ int yylen = 0; - yytoken = 0; - yyss = yyssa; - yyvs = yyvsa; + yyssp = yyss = yyssa; + yyvsp = yyvs = yyvsa; yystacksize = YYINITDEPTH; YYDPRINTF ((stderr, "Starting parse\n")); @@ -1634,14 +1446,6 @@ yyparse () yyerrstatus = 0; yynerrs = 0; yychar = YYEMPTY; /* Cause a token to be read. */ - - /* Initialize stack pointers. - Waste one element of value and location stack - so that they stay on the same level as the state stack. - The wasted elements are never initialized. */ - yyssp = yyss; - yyvsp = yyvs; - goto yysetstate; /*------------------------------------------------------------. @@ -1662,23 +1466,23 @@ yyparse () #ifdef yyoverflow { - /* Give user a chance to reallocate the stack. Use copies of - these so that the &'s don't force the real ones into - memory. */ - YYSTYPE *yyvs1 = yyvs; - yytype_int16 *yyss1 = yyss; + /* Give user a chance to reallocate the stack. Use copies of + these so that the &'s don't force the real ones into + memory. */ + YYSTYPE *yyvs1 = yyvs; + yytype_int16 *yyss1 = yyss; - /* Each stack pointer address is followed by the size of the - data in use in that stack, in bytes. This used to be a - conditional around just the two extra args, but that might - be undefined if yyoverflow is a macro. */ - yyoverflow (YY_("memory exhausted"), - &yyss1, yysize * sizeof (*yyssp), - &yyvs1, yysize * sizeof (*yyvsp), - &yystacksize); + /* Each stack pointer address is followed by the size of the + data in use in that stack, in bytes. This used to be a + conditional around just the two extra args, but that might + be undefined if yyoverflow is a macro. */ + yyoverflow (YY_("memory exhausted"), + &yyss1, yysize * sizeof (*yyssp), + &yyvs1, yysize * sizeof (*yyvsp), + &yystacksize); - yyss = yyss1; - yyvs = yyvs1; + yyss = yyss1; + yyvs = yyvs1; } #else /* no yyoverflow */ # ifndef YYSTACK_RELOCATE @@ -1686,22 +1490,22 @@ yyparse () # else /* Extend the stack our own way. */ if (YYMAXDEPTH <= yystacksize) - goto yyexhaustedlab; + goto yyexhaustedlab; yystacksize *= 2; if (YYMAXDEPTH < yystacksize) - yystacksize = YYMAXDEPTH; + yystacksize = YYMAXDEPTH; { - yytype_int16 *yyss1 = yyss; - union yyalloc *yyptr = - (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); - if (! yyptr) - goto yyexhaustedlab; - YYSTACK_RELOCATE (yyss_alloc, yyss); - YYSTACK_RELOCATE (yyvs_alloc, yyvs); + yytype_int16 *yyss1 = yyss; + union yyalloc *yyptr = + (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize)); + if (! yyptr) + goto yyexhaustedlab; + YYSTACK_RELOCATE (yyss_alloc, yyss); + YYSTACK_RELOCATE (yyvs_alloc, yyvs); # undef YYSTACK_RELOCATE - if (yyss1 != yyssa) - YYSTACK_FREE (yyss1); + if (yyss1 != yyssa) + YYSTACK_FREE (yyss1); } # endif #endif /* no yyoverflow */ @@ -1710,10 +1514,10 @@ yyparse () yyvsp = yyvs + yysize - 1; YYDPRINTF ((stderr, "Stack size increased to %lu\n", - (unsigned long int) yystacksize)); + (unsigned long int) yystacksize)); if (yyss + yystacksize - 1 <= yyssp) - YYABORT; + YYABORT; } YYDPRINTF ((stderr, "Entering state %d\n", yystate)); @@ -1733,7 +1537,7 @@ yybackup: /* First try to decide what to do without reference to lookahead token. */ yyn = yypact[yystate]; - if (yyn == YYPACT_NINF) + if (yypact_value_is_default (yyn)) goto yydefault; /* Not known => get a lookahead token if don't already have one. */ @@ -1742,7 +1546,7 @@ yybackup: if (yychar == YYEMPTY) { YYDPRINTF ((stderr, "Reading a token: ")); - yychar = YYLEX; + yychar = yylex (); } if (yychar <= YYEOF) @@ -1764,8 +1568,8 @@ yybackup: yyn = yytable[yyn]; if (yyn <= 0) { - if (yyn == 0 || yyn == YYTABLE_NINF) - goto yyerrlab; + if (yytable_value_is_error (yyn)) + goto yyerrlab; yyn = -yyn; goto yyreduce; } @@ -1782,7 +1586,9 @@ yybackup: yychar = YYEMPTY; yystate = yyn; + YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN *++yyvsp = yylval; + YY_IGNORE_MAYBE_UNINITIALIZED_END goto yynewstate; @@ -1805,7 +1611,7 @@ yyreduce: yylen = yyr2[yyn]; /* If YYLEN is nonzero, implement the default value of the action: - `$$ = $1'. + '$$ = $1'. Otherwise, the following line sets YYVAL to garbage. This behavior is undocumented and Bison @@ -1819,112 +1625,100 @@ yyreduce: switch (yyn) { case 4: - -/* Line 1464 of yacc.c */ -#line 171 "dcParser.yxx" +#line 177 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { - parameter_description = (yyvsp[(2) - (2)].u.field); + parameter_description = (yyvsp[0].u.field); } +#line 1633 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 7: - -/* Line 1464 of yacc.c */ -#line 180 "dcParser.yxx" +#line 186 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { - if (!dc_file->add_class((yyvsp[(2) - (2)].u.dclass))) { - DCClass *old_class = dc_file->get_class_by_name((yyvsp[(2) - (2)].u.dclass)->get_name()); - if (old_class != (DCClass *)NULL && old_class->is_bogus_class()) { - yyerror("Base class defined after its first reference: " + (yyvsp[(2) - (2)].u.dclass)->get_name()); + if (!dc_file->add_class((yyvsp[0].u.dclass))) { + DCClass *old_class = dc_file->get_class_by_name((yyvsp[0].u.dclass)->get_name()); + if (old_class != nullptr && old_class->is_bogus_class()) { + yyerror("Base class defined after its first reference: " + (yyvsp[0].u.dclass)->get_name()); } else { - yyerror("Duplicate class name: " + (yyvsp[(2) - (2)].u.dclass)->get_name()); + yyerror("Duplicate class name: " + (yyvsp[0].u.dclass)->get_name()); } } } +#line 1648 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 8: - -/* Line 1464 of yacc.c */ -#line 191 "dcParser.yxx" +#line 197 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { - if (!dc_file->add_switch((yyvsp[(2) - (2)].u.dswitch))) { - yyerror("Duplicate class name: " + (yyvsp[(2) - (2)].u.dswitch)->get_name()); + if (!dc_file->add_switch((yyvsp[0].u.dswitch))) { + yyerror("Duplicate class name: " + (yyvsp[0].u.dswitch)->get_name()); } } +#line 1658 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 13: - -/* Line 1464 of yacc.c */ -#line 204 "dcParser.yxx" +#line 210 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { - (yyval.str) = (yyvsp[(1) - (3)].str) + string("/") + (yyvsp[(3) - (3)].str); + (yyval.str) = (yyvsp[-2].str) + string("/") + (yyvsp[0].str); } +#line 1666 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 15: - -/* Line 1464 of yacc.c */ -#line 212 "dcParser.yxx" +#line 218 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { - (yyval.str) = (yyvsp[(1) - (3)].str) + string(".") + (yyvsp[(3) - (3)].str); + (yyval.str) = (yyvsp[-2].str) + string(".") + (yyvsp[0].str); } +#line 1674 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 16: - -/* Line 1464 of yacc.c */ -#line 219 "dcParser.yxx" +#line 225 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { - dc_file->add_import_module((yyvsp[(2) - (2)].str)); + dc_file->add_import_module((yyvsp[0].str)); } +#line 1682 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 17: - -/* Line 1464 of yacc.c */ -#line 223 "dcParser.yxx" +#line 229 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { - dc_file->add_import_module((yyvsp[(2) - (3)].str)); + dc_file->add_import_module((yyvsp[-1].str)); } +#line 1690 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 20: - -/* Line 1464 of yacc.c */ -#line 232 "dcParser.yxx" +#line 238 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { dc_file->add_import_symbol("*"); } +#line 1698 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 21: - -/* Line 1464 of yacc.c */ -#line 239 "dcParser.yxx" +#line 245 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { - dc_file->add_import_symbol((yyvsp[(1) - (1)].str)); + dc_file->add_import_symbol((yyvsp[0].str)); } +#line 1706 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 22: - -/* Line 1464 of yacc.c */ -#line 243 "dcParser.yxx" +#line 249 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { - dc_file->add_import_symbol((yyvsp[(3) - (3)].str)); + dc_file->add_import_symbol((yyvsp[0].str)); } +#line 1714 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 23: - -/* Line 1464 of yacc.c */ -#line 250 "dcParser.yxx" +#line 256 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { - if ((yyvsp[(2) - (2)].u.parameter) != (DCParameter *)NULL) { - DCTypedef *dtypedef = new DCTypedef((yyvsp[(2) - (2)].u.parameter)); - + if ((yyvsp[0].u.parameter) != nullptr) { + 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()) { @@ -1935,343 +1729,316 @@ yyreduce: } } } +#line 1733 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 26: - -/* Line 1464 of yacc.c */ -#line 273 "dcParser.yxx" +#line 279 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { - dc_file->add_keyword((yyvsp[(2) - (2)].str)); + dc_file->add_keyword((yyvsp[0].str)); } +#line 1741 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 27: - -/* Line 1464 of yacc.c */ -#line 277 "dcParser.yxx" +#line 283 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { // This keyword has already been defined. But since we are now // explicitly defining it, clear its bitmask, so that we will have a // new hash code--doing this will allow us to phase out the // historical hash code support later. - ((DCKeyword *)(yyvsp[(2) - (2)].u.keyword))->clear_historical_flag(); + ((DCKeyword *)(yyvsp[0].u.keyword))->clear_historical_flag(); } +#line 1753 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 30: - -/* Line 1464 of yacc.c */ -#line 293 "dcParser.yxx" +#line 299 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { - current_class = new DCClass(dc_file, (yyvsp[(2) - (2)].str), false, false); + current_class = new DCClass(dc_file, (yyvsp[0].str), false, false); } +#line 1761 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 31: - -/* Line 1464 of yacc.c */ -#line 297 "dcParser.yxx" +#line 303 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { (yyval.u.dclass) = current_class; - current_class = (yyvsp[(3) - (7)].u.dclass); + current_class = (yyvsp[-4].u.dclass); } +#line 1770 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 32: - -/* Line 1464 of yacc.c */ -#line 305 "dcParser.yxx" +#line 311 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { - if (dc_file == (DCFile *)NULL) { + if (dc_file == nullptr) { yyerror("No DCFile available, so no class names are predefined."); - (yyval.u.dclass) = NULL; + (yyval.u.dclass) = nullptr; } else { - DCClass *dclass = dc_file->get_class_by_name((yyvsp[(1) - (1)].str)); - if (dclass == (DCClass *)NULL) { + DCClass *dclass = dc_file->get_class_by_name((yyvsp[0].str)); + if (dclass == nullptr) { // Create a bogus class as a forward reference. - dclass = new DCClass(dc_file, (yyvsp[(1) - (1)].str), false, true); + dclass = new DCClass(dc_file, (yyvsp[0].str), false, true); dc_file->add_class(dclass); } if (dclass->is_struct()) { yyerror("struct name not allowed"); } - + (yyval.u.dclass) = dclass; } } +#line 1794 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 35: - -/* Line 1464 of yacc.c */ -#line 333 "dcParser.yxx" +#line 339 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { - if ((yyvsp[(1) - (1)].u.dclass) != (DCClass *)NULL) { - current_class->add_parent((yyvsp[(1) - (1)].u.dclass)); + if ((yyvsp[0].u.dclass) != nullptr) { + current_class->add_parent((yyvsp[0].u.dclass)); } } +#line 1804 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 36: - -/* Line 1464 of yacc.c */ -#line 339 "dcParser.yxx" +#line 345 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { if (!dc_multiple_inheritance) { yyerror("Multiple inheritance is not supported without \"dc-multiple-inheritance 1\" in your Config.prc file."); } else { - if ((yyvsp[(3) - (3)].u.dclass) != (DCClass *)NULL) { - current_class->add_parent((yyvsp[(3) - (3)].u.dclass)); + if ((yyvsp[0].u.dclass) != nullptr) { + current_class->add_parent((yyvsp[0].u.dclass)); } } } +#line 1819 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 39: - -/* Line 1464 of yacc.c */ -#line 355 "dcParser.yxx" +#line 361 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { - if ((yyvsp[(2) - (3)].u.field) == (DCField *)NULL) { + if ((yyvsp[-1].u.field) == nullptr) { // Pass this error up. - } else if (!current_class->add_field((yyvsp[(2) - (3)].u.field))) { - yyerror("Duplicate field name: " + (yyvsp[(2) - (3)].u.field)->get_name()); - } else if ((yyvsp[(2) - (3)].u.field)->get_number() < 0) { + } else if (!current_class->add_field((yyvsp[-1].u.field))) { + yyerror("Duplicate field name: " + (yyvsp[-1].u.field)->get_name()); + } else if ((yyvsp[-1].u.field)->get_number() < 0) { yyerror("A non-network field cannot be stored on a dclass"); } } +#line 1833 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 40: - -/* Line 1464 of yacc.c */ -#line 368 "dcParser.yxx" +#line 374 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { - if ((yyvsp[(1) - (2)].u.field) != (DCField *)NULL) { - if ((yyvsp[(1) - (2)].u.field)->get_name().empty()) { + if ((yyvsp[-1].u.field) != nullptr) { + if ((yyvsp[-1].u.field)->get_name().empty()) { yyerror("Field name required."); } - (yyvsp[(1) - (2)].u.field)->copy_keywords(current_keyword_list); + (yyvsp[-1].u.field)->copy_keywords(current_keyword_list); } - (yyval.u.field) = (yyvsp[(1) - (2)].u.field); + (yyval.u.field) = (yyvsp[-1].u.field); } +#line 1847 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 42: - -/* Line 1464 of yacc.c */ -#line 379 "dcParser.yxx" +#line 385 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { yyerror("Unnamed parameters are not allowed on a dclass"); - if ((yyvsp[(1) - (2)].u.parameter) != (DCField *)NULL) { - (yyvsp[(1) - (2)].u.parameter)->copy_keywords(current_keyword_list); + if ((yyvsp[-1].u.parameter) != nullptr) { + (yyvsp[-1].u.parameter)->copy_keywords(current_keyword_list); } - (yyval.u.field) = (yyvsp[(1) - (2)].u.parameter); + (yyval.u.field) = (yyvsp[-1].u.parameter); } +#line 1859 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 43: - -/* Line 1464 of yacc.c */ -#line 387 "dcParser.yxx" +#line 393 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { - if ((yyvsp[(1) - (2)].u.parameter) != (DCField *)NULL) { - (yyvsp[(1) - (2)].u.parameter)->copy_keywords(current_keyword_list); + if ((yyvsp[-1].u.parameter) != nullptr) { + (yyvsp[-1].u.parameter)->copy_keywords(current_keyword_list); } - (yyval.u.field) = (yyvsp[(1) - (2)].u.parameter); + (yyval.u.field) = (yyvsp[-1].u.parameter); } +#line 1870 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 44: - -/* Line 1464 of yacc.c */ -#line 397 "dcParser.yxx" +#line 403 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { - current_class = new DCClass(dc_file, (yyvsp[(2) - (2)].str), true, false); + current_class = new DCClass(dc_file, (yyvsp[0].str), true, false); } +#line 1878 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 45: - -/* Line 1464 of yacc.c */ -#line 401 "dcParser.yxx" +#line 407 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { (yyval.u.dclass) = current_class; - current_class = (yyvsp[(3) - (7)].u.dclass); + current_class = (yyvsp[-4].u.dclass); } +#line 1887 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 46: - -/* Line 1464 of yacc.c */ -#line 409 "dcParser.yxx" +#line 415 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { - if (dc_file == (DCFile *)NULL) { + if (dc_file == nullptr) { yyerror("No DCFile available, so no struct names are predefined."); - (yyval.u.dclass) = NULL; + (yyval.u.dclass) = nullptr; } else { - DCClass *dstruct = dc_file->get_class_by_name((yyvsp[(1) - (1)].str)); - if (dstruct == (DCClass *)NULL) { + DCClass *dstruct = dc_file->get_class_by_name((yyvsp[0].str)); + if (dstruct == nullptr) { // Create a bogus class as a forward reference. - dstruct = new DCClass(dc_file, (yyvsp[(1) - (1)].str), false, true); + dstruct = new DCClass(dc_file, (yyvsp[0].str), false, true); dc_file->add_class(dstruct); } if (!dstruct->is_struct()) { yyerror("struct name required"); } - + (yyval.u.dclass) = dstruct; } } +#line 1911 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 49: - -/* Line 1464 of yacc.c */ -#line 437 "dcParser.yxx" +#line 443 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { - if ((yyvsp[(1) - (1)].u.dclass) != (DCClass *)NULL) { - current_class->add_parent((yyvsp[(1) - (1)].u.dclass)); + if ((yyvsp[0].u.dclass) != nullptr) { + current_class->add_parent((yyvsp[0].u.dclass)); } } +#line 1921 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 50: - -/* Line 1464 of yacc.c */ -#line 443 "dcParser.yxx" +#line 449 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { - if ((yyvsp[(3) - (3)].u.dclass) != (DCClass *)NULL) { - current_class->add_parent((yyvsp[(3) - (3)].u.dclass)); + if ((yyvsp[0].u.dclass) != nullptr) { + current_class->add_parent((yyvsp[0].u.dclass)); } } +#line 1931 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 53: - -/* Line 1464 of yacc.c */ -#line 454 "dcParser.yxx" +#line 460 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { - if ((yyvsp[(2) - (3)].u.field) == (DCField *)NULL) { + if ((yyvsp[-1].u.field) == nullptr) { // Pass this error up. - } else if (!current_class->add_field((yyvsp[(2) - (3)].u.field))) { - yyerror("Duplicate field name: " + (yyvsp[(2) - (3)].u.field)->get_name()); + } else if (!current_class->add_field((yyvsp[-1].u.field))) { + yyerror("Duplicate field name: " + (yyvsp[-1].u.field)->get_name()); } } +#line 1943 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 54: - -/* Line 1464 of yacc.c */ -#line 465 "dcParser.yxx" +#line 471 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { - if ((yyvsp[(1) - (2)].u.field)->get_name().empty()) { + if ((yyvsp[-1].u.field)->get_name().empty()) { yyerror("Field name required."); } - (yyval.u.field) = (yyvsp[(1) - (2)].u.field); + (yyval.u.field) = (yyvsp[-1].u.field); } +#line 1954 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 56: - -/* Line 1464 of yacc.c */ -#line 473 "dcParser.yxx" +#line 479 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { - (yyval.u.field) = (yyvsp[(1) - (2)].u.parameter); + (yyval.u.field) = (yyvsp[-1].u.parameter); } +#line 1962 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 57: - -/* Line 1464 of yacc.c */ -#line 477 "dcParser.yxx" +#line 483 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { - (yyval.u.field) = (yyvsp[(1) - (2)].u.parameter); + (yyval.u.field) = (yyvsp[-1].u.parameter); } +#line 1970 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 58: - -/* Line 1464 of yacc.c */ -#line 484 "dcParser.yxx" +#line 490 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { - if (current_class == (DCClass *)NULL) { + if (current_class == nullptr) { yyerror("Cannot define a method outside of a struct or class."); DCClass *temp_class = new DCClass(dc_file, "temp", false, false); // memory leak. - current_atomic = new DCAtomicField((yyvsp[(1) - (2)].str), temp_class, false); + current_atomic = new DCAtomicField((yyvsp[-1].str), temp_class, false); } else { - current_atomic = new DCAtomicField((yyvsp[(1) - (2)].str), current_class, false); + current_atomic = new DCAtomicField((yyvsp[-1].str), current_class, false); } } +#line 1984 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 59: - -/* Line 1464 of yacc.c */ -#line 494 "dcParser.yxx" +#line 500 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { (yyval.u.field) = current_atomic; - current_atomic = (yyvsp[(3) - (5)].u.atomic); + current_atomic = (yyvsp[-2].u.atomic); } +#line 1993 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 64: - -/* Line 1464 of yacc.c */ -#line 512 "dcParser.yxx" +#line 518 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { - if ((yyvsp[(1) - (1)].u.parameter) != (DCParameter *)NULL) { - current_atomic->add_element((yyvsp[(1) - (1)].u.parameter)); + if ((yyvsp[0].u.parameter) != nullptr) { + current_atomic->add_element((yyvsp[0].u.parameter)); } } +#line 2003 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 65: - -/* Line 1464 of yacc.c */ -#line 521 "dcParser.yxx" +#line 527 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { - current_parameter = (yyvsp[(1) - (1)].u.parameter); + current_parameter = (yyvsp[0].u.parameter); } +#line 2011 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 66: - -/* Line 1464 of yacc.c */ -#line 525 "dcParser.yxx" +#line 531 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { - (yyval.u.parameter) = (yyvsp[(3) - (3)].u.parameter); + (yyval.u.parameter) = (yyvsp[0].u.parameter); } +#line 2019 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 69: - -/* Line 1464 of yacc.c */ -#line 537 "dcParser.yxx" +#line 543 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { current_packer = &default_packer; current_packer->clear_data(); - if ((yyvsp[(1) - (2)].u.parameter) != (DCField *)NULL) { - current_packer->begin_pack((yyvsp[(1) - (2)].u.parameter)); + if ((yyvsp[-1].u.parameter) != nullptr) { + current_packer->begin_pack((yyvsp[-1].u.parameter)); } } +#line 2031 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 70: - -/* Line 1464 of yacc.c */ -#line 545 "dcParser.yxx" +#line 551 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { bool is_valid = false; - if ((yyvsp[(1) - (4)].u.parameter) != (DCField *)NULL) { - is_valid = (yyvsp[(1) - (4)].u.parameter)->is_valid(); + if ((yyvsp[-3].u.parameter) != nullptr) { + is_valid = (yyvsp[-3].u.parameter)->is_valid(); } if (current_packer->end_pack()) { - (yyvsp[(1) - (4)].u.parameter)->set_default_value(current_packer->get_string()); + (yyvsp[-3].u.parameter)->set_default_value(current_packer->get_bytes()); } else { if (is_valid) { @@ -2282,32 +2049,30 @@ yyreduce: // just ignore the default value in this case. } } +#line 2053 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 72: - -/* Line 1464 of yacc.c */ -#line 567 "dcParser.yxx" +#line 573 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { current_packer = &default_packer; current_packer->clear_data(); - if ((yyvsp[(1) - (2)].u.parameter) != (DCField *)NULL) { - current_packer->begin_pack((yyvsp[(1) - (2)].u.parameter)); + if ((yyvsp[-1].u.parameter) != nullptr) { + current_packer->begin_pack((yyvsp[-1].u.parameter)); } } +#line 2065 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 73: - -/* Line 1464 of yacc.c */ -#line 575 "dcParser.yxx" +#line 581 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { bool is_valid = false; - if ((yyvsp[(1) - (4)].u.parameter) != (DCField *)NULL) { - is_valid = (yyvsp[(1) - (4)].u.parameter)->is_valid(); + if ((yyvsp[-3].u.parameter) != nullptr) { + is_valid = (yyvsp[-3].u.parameter)->is_valid(); } if (current_packer->end_pack()) { - (yyvsp[(1) - (4)].u.parameter)->set_default_value(current_packer->get_string()); + (yyvsp[-3].u.parameter)->set_default_value(current_packer->get_bytes()); } else { if (is_valid) { @@ -2318,87 +2083,79 @@ yyreduce: // just ignore the default value in this case. } } +#line 2087 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 78: - -/* Line 1464 of yacc.c */ -#line 606 "dcParser.yxx" +#line 612 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { - (yyval.u.field) = (yyvsp[(1) - (1)].u.parameter); + (yyval.u.field) = (yyvsp[0].u.parameter); } +#line 2095 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 79: - -/* Line 1464 of yacc.c */ -#line 610 "dcParser.yxx" +#line 616 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { - (yyval.u.field) = (yyvsp[(1) - (1)].u.field); + (yyval.u.field) = (yyvsp[0].u.field); } +#line 2103 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 80: - -/* Line 1464 of yacc.c */ -#line 617 "dcParser.yxx" +#line 623 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { - (yyval.u.field) = (yyvsp[(1) - (2)].u.field); + (yyval.u.field) = (yyvsp[-1].u.field); } +#line 2111 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 81: - -/* Line 1464 of yacc.c */ -#line 621 "dcParser.yxx" +#line 627 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { - (yyval.u.field) = (yyvsp[(1) - (2)].u.parameter); + (yyval.u.field) = (yyvsp[-1].u.parameter); } +#line 2119 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 82: - -/* Line 1464 of yacc.c */ -#line 625 "dcParser.yxx" +#line 631 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { - (yyval.u.field) = (yyvsp[(1) - (2)].u.parameter); + (yyval.u.field) = (yyvsp[-1].u.parameter); } +#line 2127 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 83: - -/* Line 1464 of yacc.c */ -#line 632 "dcParser.yxx" +#line 638 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { - (yyval.u.parameter) = new DCSimpleParameter((yyvsp[(1) - (1)].u.subatomic)); + (yyval.u.parameter) = new DCSimpleParameter((yyvsp[0].u.subatomic)); } +#line 2135 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 84: - -/* Line 1464 of yacc.c */ -#line 636 "dcParser.yxx" +#line 642 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { - DCSimpleParameter *simple_param = (yyvsp[(1) - (4)].u.parameter)->as_simple_parameter(); - nassertr(simple_param != (DCSimpleParameter *)NULL, 0); + DCSimpleParameter *simple_param = (yyvsp[-3].u.parameter)->as_simple_parameter(); + nassertr(simple_param != nullptr, 0); if (!simple_param->set_range(double_range)) { yyerror("Inappropriate range for type"); } (yyval.u.parameter) = simple_param; } +#line 2148 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 85: - -/* Line 1464 of yacc.c */ -#line 645 "dcParser.yxx" +#line 651 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { - DCSimpleParameter *simple_param = (yyvsp[(1) - (3)].u.parameter)->as_simple_parameter(); - nassertr(simple_param != (DCSimpleParameter *)NULL, 0); + DCSimpleParameter *simple_param = (yyvsp[-2].u.parameter)->as_simple_parameter(); + nassertr(simple_param != nullptr, 0); if (!simple_param->is_numeric_type()) { yyerror("A divisor is only valid on a numeric type."); - } else if (!simple_param->set_divisor((yyvsp[(3) - (3)].u.s_uint))) { + } else if (!simple_param->set_divisor((yyvsp[0].u.s_uint))) { yyerror("Invalid divisor."); } else if (simple_param->has_modulus() && !simple_param->set_modulus(simple_param->get_modulus())) { @@ -2407,982 +2164,907 @@ yyreduce: } (yyval.u.parameter) = simple_param; } +#line 2168 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 86: - -/* Line 1464 of yacc.c */ -#line 661 "dcParser.yxx" - { - DCSimpleParameter *simple_param = (yyvsp[(1) - (3)].u.parameter)->as_simple_parameter(); - nassertr(simple_param != (DCSimpleParameter *)NULL, 0); +#line 667 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ + { + DCSimpleParameter *simple_param = (yyvsp[-2].u.parameter)->as_simple_parameter(); + nassertr(simple_param != nullptr, 0); if (!simple_param->is_numeric_type()) { yyerror("A divisor is only valid on a numeric type."); - } else if (!simple_param->set_modulus((yyvsp[(3) - (3)].u.real))) { + } else if (!simple_param->set_modulus((yyvsp[0].u.real))) { yyerror("Invalid modulus."); } (yyval.u.parameter) = simple_param; } +#line 2184 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 88: - -/* Line 1464 of yacc.c */ -#line 677 "dcParser.yxx" +#line 683 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { - if (dc_file == (DCFile *)NULL) { + if (dc_file == nullptr) { yyerror("Invalid type."); - (yyval.u.parameter) = NULL; + (yyval.u.parameter) = nullptr; } else { - DCTypedef *dtypedef = dc_file->get_typedef_by_name((yyvsp[(1) - (1)].str)); - if (dtypedef == (DCTypedef *)NULL) { + DCTypedef *dtypedef = dc_file->get_typedef_by_name((yyvsp[0].str)); + if (dtypedef == nullptr) { // Maybe it's a class name. - DCClass *dclass = dc_file->get_class_by_name((yyvsp[(1) - (1)].str)); - if (dclass != (DCClass *)NULL) { + DCClass *dclass = dc_file->get_class_by_name((yyvsp[0].str)); + if (dclass != nullptr) { // 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[(1) - (1)].str)); - if (dswitch != (DCSwitch *)NULL) { + DCSwitch *dswitch = dc_file->get_switch_by_name((yyvsp[0].str)); + if (dswitch != nullptr) { // 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[(1) - (1)].str)); + dtypedef = new DCTypedef((yyvsp[0].str)); } } - + dc_file->add_typedef(dtypedef); } - + (yyval.u.parameter) = dtypedef->make_new_parameter(); } } +#line 2220 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 89: - -/* Line 1464 of yacc.c */ -#line 709 "dcParser.yxx" +#line 715 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { // This is an inline struct definition. - if ((yyvsp[(1) - (1)].u.dclass) == (DCClass *)NULL) { - (yyval.u.parameter) = NULL; + if ((yyvsp[0].u.dclass) == nullptr) { + (yyval.u.parameter) = nullptr; } else { - if (dc_file != (DCFile *)NULL) { - dc_file->add_thing_to_delete((yyvsp[(1) - (1)].u.dclass)); + if (dc_file != nullptr) { + dc_file->add_thing_to_delete((yyvsp[0].u.dclass)); } else { // This is a memory leak--this happens when we put an anonymous // struct reference within the string passed to // DCPackerInterface::check_match(). Maybe it doesn't really matter. } - (yyval.u.parameter) = new DCClassParameter((yyvsp[(1) - (1)].u.dclass)); + (yyval.u.parameter) = new DCClassParameter((yyvsp[0].u.dclass)); } } +#line 2240 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 90: - -/* Line 1464 of yacc.c */ -#line 725 "dcParser.yxx" +#line 731 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { // This is an inline switch definition. - if ((yyvsp[(1) - (1)].u.dswitch) == (DCSwitch *)NULL) { - (yyval.u.parameter) = NULL; + if ((yyvsp[0].u.dswitch) == nullptr) { + (yyval.u.parameter) = nullptr; } else { - if (dc_file != (DCFile *)NULL) { - dc_file->add_thing_to_delete((yyvsp[(1) - (1)].u.dswitch)); + if (dc_file != nullptr) { + dc_file->add_thing_to_delete((yyvsp[0].u.dswitch)); } else { // This is a memory leak--this happens when we put an anonymous // switch reference within the string passed to // DCPackerInterface::check_match(). Maybe it doesn't really matter. } - (yyval.u.parameter) = new DCSwitchParameter((yyvsp[(1) - (1)].u.dswitch)); + (yyval.u.parameter) = new DCSwitchParameter((yyvsp[0].u.dswitch)); } } +#line 2260 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 91: - -/* Line 1464 of yacc.c */ -#line 744 "dcParser.yxx" +#line 750 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { double_range.clear(); } +#line 2268 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 92: - -/* Line 1464 of yacc.c */ -#line 748 "dcParser.yxx" +#line 754 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { double_range.clear(); - if (!double_range.add_range((yyvsp[(1) - (1)].u.real), (yyvsp[(1) - (1)].u.real))) { + if (!double_range.add_range((yyvsp[0].u.real), (yyvsp[0].u.real))) { yyerror("Overlapping range"); } } +#line 2279 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 93: - -/* Line 1464 of yacc.c */ -#line 755 "dcParser.yxx" +#line 761 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { double_range.clear(); - if (!double_range.add_range((yyvsp[(1) - (3)].u.real), (yyvsp[(3) - (3)].u.real))) { + if (!double_range.add_range((yyvsp[-2].u.real), (yyvsp[0].u.real))) { yyerror("Overlapping range"); } } +#line 2290 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 94: - -/* Line 1464 of yacc.c */ -#line 762 "dcParser.yxx" +#line 768 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { double_range.clear(); - if ((yyvsp[(2) - (2)].u.real) >= 0) { + if ((yyvsp[0].u.real) >= 0) { yyerror("Syntax error"); - } else if (!double_range.add_range((yyvsp[(1) - (2)].u.real), -(yyvsp[(2) - (2)].u.real))) { + } else if (!double_range.add_range((yyvsp[-1].u.real), -(yyvsp[0].u.real))) { yyerror("Overlapping range"); } } +#line 2303 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 95: - -/* Line 1464 of yacc.c */ -#line 771 "dcParser.yxx" +#line 777 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { - if (!double_range.add_range((yyvsp[(3) - (3)].u.real), (yyvsp[(3) - (3)].u.real))) { + if (!double_range.add_range((yyvsp[0].u.real), (yyvsp[0].u.real))) { yyerror("Overlapping range"); } } +#line 2313 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 96: - -/* Line 1464 of yacc.c */ -#line 777 "dcParser.yxx" +#line 783 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { - if (!double_range.add_range((yyvsp[(3) - (5)].u.real), (yyvsp[(5) - (5)].u.real))) { + if (!double_range.add_range((yyvsp[-2].u.real), (yyvsp[0].u.real))) { yyerror("Overlapping range"); } } +#line 2323 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 97: - -/* Line 1464 of yacc.c */ -#line 783 "dcParser.yxx" +#line 789 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { - if ((yyvsp[(4) - (4)].u.real) >= 0) { + if ((yyvsp[0].u.real) >= 0) { yyerror("Syntax error"); - } else if (!double_range.add_range((yyvsp[(3) - (4)].u.real), -(yyvsp[(4) - (4)].u.real))) { + } else if (!double_range.add_range((yyvsp[-1].u.real), -(yyvsp[0].u.real))) { yyerror("Overlapping range"); } } +#line 2335 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 98: - -/* Line 1464 of yacc.c */ -#line 794 "dcParser.yxx" +#line 800 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { uint_range.clear(); } +#line 2343 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 99: - -/* Line 1464 of yacc.c */ -#line 798 "dcParser.yxx" +#line 804 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { uint_range.clear(); - if (!uint_range.add_range((yyvsp[(1) - (1)].u.s_uint), (yyvsp[(1) - (1)].u.s_uint))) { + if (!uint_range.add_range((yyvsp[0].u.s_uint), (yyvsp[0].u.s_uint))) { yyerror("Overlapping range"); } } +#line 2354 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 100: - -/* Line 1464 of yacc.c */ -#line 805 "dcParser.yxx" +#line 811 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { uint_range.clear(); - if (!uint_range.add_range((yyvsp[(1) - (3)].u.s_uint), (yyvsp[(3) - (3)].u.s_uint))) { + if (!uint_range.add_range((yyvsp[-2].u.s_uint), (yyvsp[0].u.s_uint))) { yyerror("Overlapping range"); } } +#line 2365 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 101: - -/* Line 1464 of yacc.c */ -#line 812 "dcParser.yxx" +#line 818 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { uint_range.clear(); - if (!uint_range.add_range((yyvsp[(1) - (2)].u.s_uint), (yyvsp[(2) - (2)].u.s_uint))) { + if (!uint_range.add_range((yyvsp[-1].u.s_uint), (yyvsp[0].u.s_uint))) { yyerror("Overlapping range"); } } +#line 2376 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 102: - -/* Line 1464 of yacc.c */ -#line 819 "dcParser.yxx" +#line 825 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { - if (!uint_range.add_range((yyvsp[(3) - (3)].u.s_uint), (yyvsp[(3) - (3)].u.s_uint))) { + if (!uint_range.add_range((yyvsp[0].u.s_uint), (yyvsp[0].u.s_uint))) { yyerror("Overlapping range"); } } +#line 2386 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 103: - -/* Line 1464 of yacc.c */ -#line 825 "dcParser.yxx" +#line 831 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { - if (!uint_range.add_range((yyvsp[(3) - (5)].u.s_uint), (yyvsp[(5) - (5)].u.s_uint))) { + if (!uint_range.add_range((yyvsp[-2].u.s_uint), (yyvsp[0].u.s_uint))) { yyerror("Overlapping range"); } } +#line 2396 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 104: - -/* Line 1464 of yacc.c */ -#line 831 "dcParser.yxx" +#line 837 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { - if (!uint_range.add_range((yyvsp[(3) - (4)].u.s_uint), (yyvsp[(4) - (4)].u.s_uint))) { + if (!uint_range.add_range((yyvsp[-1].u.s_uint), (yyvsp[0].u.s_uint))) { yyerror("Overlapping range"); } } +#line 2406 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 106: - -/* Line 1464 of yacc.c */ -#line 841 "dcParser.yxx" +#line 847 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { - if ((yyvsp[(1) - (4)].u.parameter) == (DCParameter *)NULL) { - (yyval.u.parameter) = NULL; + if ((yyvsp[-3].u.parameter) == nullptr) { + (yyval.u.parameter) = nullptr; } else { - (yyval.u.parameter) = (yyvsp[(1) - (4)].u.parameter)->append_array_specification(uint_range); + (yyval.u.parameter) = (yyvsp[-3].u.parameter)->append_array_specification(uint_range); } } +#line 2418 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 107: - -/* Line 1464 of yacc.c */ -#line 852 "dcParser.yxx" +#line 858 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { - current_parameter->set_name((yyvsp[(1) - (1)].str)); + current_parameter->set_name((yyvsp[0].str)); (yyval.u.parameter) = current_parameter; } +#line 2427 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 108: - -/* Line 1464 of yacc.c */ -#line 857 "dcParser.yxx" +#line 863 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { - DCSimpleParameter *simple_param = (yyvsp[(1) - (3)].u.parameter)->as_simple_parameter(); - if (simple_param == NULL || simple_param->get_typedef() != (DCTypedef *)NULL) { + DCSimpleParameter *simple_param = (yyvsp[-2].u.parameter)->as_simple_parameter(); + if (simple_param == nullptr || simple_param->get_typedef() != nullptr) { yyerror("A divisor is only allowed on a primitive type."); } else if (!simple_param->is_numeric_type()) { yyerror("A divisor is only valid on a numeric type."); } else { - if (!simple_param->set_divisor((yyvsp[(3) - (3)].u.s_uint))) { + if (!simple_param->set_divisor((yyvsp[0].u.s_uint))) { yyerror("Invalid divisor."); } } } +#line 2446 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 109: - -/* Line 1464 of yacc.c */ -#line 872 "dcParser.yxx" +#line 878 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { - DCSimpleParameter *simple_param = (yyvsp[(1) - (3)].u.parameter)->as_simple_parameter(); - if (simple_param == NULL || simple_param->get_typedef() != (DCTypedef *)NULL) { + DCSimpleParameter *simple_param = (yyvsp[-2].u.parameter)->as_simple_parameter(); + if (simple_param == nullptr || simple_param->get_typedef() != nullptr) { yyerror("A modulus is only allowed on a primitive type."); } else if (!simple_param->is_numeric_type()) { yyerror("A modulus is only valid on a numeric type."); } else { - if (!simple_param->set_modulus((yyvsp[(3) - (3)].u.real))) { + if (!simple_param->set_modulus((yyvsp[0].u.real))) { yyerror("Invalid modulus."); } } } +#line 2465 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 110: - -/* Line 1464 of yacc.c */ -#line 887 "dcParser.yxx" +#line 893 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { - (yyval.u.parameter) = (yyvsp[(1) - (4)].u.parameter)->append_array_specification(uint_range); + (yyval.u.parameter) = (yyvsp[-3].u.parameter)->append_array_specification(uint_range); } +#line 2473 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 111: - -/* Line 1464 of yacc.c */ -#line 894 "dcParser.yxx" +#line 900 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { - if ((yyvsp[(1) - (1)].str).length() != 1) { + if ((yyvsp[0].str).length() != 1) { yyerror("Single character required."); (yyval.u.s_uint) = 0; } else { - (yyval.u.s_uint) = (unsigned char)(yyvsp[(1) - (1)].str)[0]; + (yyval.u.s_uint) = (unsigned char)(yyvsp[0].str)[0]; } } +#line 2486 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 113: - -/* Line 1464 of yacc.c */ -#line 907 "dcParser.yxx" +#line 913 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { - (yyval.u.s_uint) = (unsigned int)(yyvsp[(1) - (1)].u.uint64); - if ((yyval.u.s_uint) != (yyvsp[(1) - (1)].u.uint64)) { + (yyval.u.s_uint) = (unsigned int)(yyvsp[0].u.uint64); + if ((yyval.u.s_uint) != (yyvsp[0].u.uint64)) { yyerror("Number out of range."); (yyval.u.s_uint) = 1; } } +#line 2498 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 114: - -/* Line 1464 of yacc.c */ -#line 918 "dcParser.yxx" +#line 924 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { - (yyval.u.s_uint) = (unsigned int)-(yyvsp[(1) - (1)].u.int64); - if ((yyvsp[(1) - (1)].u.int64) >= 0) { + (yyval.u.s_uint) = (unsigned int)-(yyvsp[0].u.int64); + if ((yyvsp[0].u.int64) >= 0) { yyerror("Syntax error."); - } else if ((yyval.u.s_uint) != -(yyvsp[(1) - (1)].u.int64)) { + } else if ((yyval.u.s_uint) != -(yyvsp[0].u.int64)) { yyerror("Number out of range."); (yyval.u.s_uint) = 1; } } +#line 2513 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 117: - -/* Line 1464 of yacc.c */ -#line 940 "dcParser.yxx" +#line 946 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { - (yyval.u.real) = (double)(yyvsp[(1) - (1)].u.uint64); + (yyval.u.real) = (double)(yyvsp[0].u.uint64); } +#line 2521 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 118: - -/* Line 1464 of yacc.c */ -#line 944 "dcParser.yxx" +#line 950 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { - (yyval.u.real) = (double)(yyvsp[(1) - (1)].u.int64); + (yyval.u.real) = (double)(yyvsp[0].u.int64); } +#line 2529 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 120: - -/* Line 1464 of yacc.c */ -#line 952 "dcParser.yxx" +#line 958 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { - if ((yyvsp[(1) - (1)].str).length() != 1) { + if ((yyvsp[0].str).length() != 1) { yyerror("Single character required."); (yyval.u.real) = 0; } else { - (yyval.u.real) = (double)(unsigned char)(yyvsp[(1) - (1)].str)[0]; + (yyval.u.real) = (double)(unsigned char)(yyvsp[0].str)[0]; } } +#line 2542 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 122: - -/* Line 1464 of yacc.c */ -#line 966 "dcParser.yxx" +#line 972 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { } +#line 2549 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 123: - -/* Line 1464 of yacc.c */ -#line 969 "dcParser.yxx" +#line 975 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { - if ((yyvsp[(1) - (2)].str) != current_packer->get_current_field_name()) { + if ((yyvsp[-1].str) != current_packer->get_current_field_name()) { ostringstream strm; - strm << "Got '" << (yyvsp[(1) - (2)].str) << "', expected '" + strm << "Got '" << (yyvsp[-1].str) << "', expected '" << current_packer->get_current_field_name() << "'"; yyerror(strm.str()); } } +#line 2562 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 124: - -/* Line 1464 of yacc.c */ -#line 978 "dcParser.yxx" +#line 984 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { } +#line 2569 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 125: - -/* Line 1464 of yacc.c */ -#line 984 "dcParser.yxx" +#line 990 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { - current_packer->pack_int64((yyvsp[(1) - (1)].u.int64)); + current_packer->pack_int64((yyvsp[0].u.int64)); } +#line 2577 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 126: - -/* Line 1464 of yacc.c */ -#line 988 "dcParser.yxx" +#line 994 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { - current_packer->pack_uint64((yyvsp[(1) - (1)].u.uint64)); + current_packer->pack_uint64((yyvsp[0].u.uint64)); } +#line 2585 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 127: - -/* Line 1464 of yacc.c */ -#line 992 "dcParser.yxx" +#line 998 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { - current_packer->pack_double((yyvsp[(1) - (1)].u.real)); + current_packer->pack_double((yyvsp[0].u.real)); } +#line 2593 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 128: - -/* Line 1464 of yacc.c */ -#line 996 "dcParser.yxx" +#line 1002 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { - current_packer->pack_string((yyvsp[(1) - (1)].str)); + current_packer->pack_string((yyvsp[0].str)); } +#line 2601 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 129: - -/* Line 1464 of yacc.c */ -#line 1000 "dcParser.yxx" +#line 1006 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { - current_packer->pack_literal_value((yyvsp[(1) - (1)].str)); + current_packer->pack_literal_value((yyvsp[0].bytes)); } +#line 2609 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 130: - -/* Line 1464 of yacc.c */ -#line 1004 "dcParser.yxx" +#line 1010 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { current_packer->push(); } +#line 2617 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 131: - -/* Line 1464 of yacc.c */ -#line 1008 "dcParser.yxx" +#line 1014 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { current_packer->pop(); } +#line 2625 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 132: - -/* Line 1464 of yacc.c */ -#line 1012 "dcParser.yxx" +#line 1018 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { current_packer->push(); } +#line 2633 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 133: - -/* Line 1464 of yacc.c */ -#line 1016 "dcParser.yxx" +#line 1022 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { current_packer->pop(); } +#line 2641 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 134: - -/* Line 1464 of yacc.c */ -#line 1020 "dcParser.yxx" +#line 1026 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { current_packer->push(); } +#line 2649 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 135: - -/* Line 1464 of yacc.c */ -#line 1024 "dcParser.yxx" +#line 1030 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { current_packer->pop(); } +#line 2657 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 136: - -/* Line 1464 of yacc.c */ -#line 1028 "dcParser.yxx" +#line 1034 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { - for (unsigned int i = 0; i < (yyvsp[(3) - (3)].u.s_uint); i++) { - current_packer->pack_int64((yyvsp[(1) - (3)].u.int64)); + for (unsigned int i = 0; i < (yyvsp[0].u.s_uint); i++) { + current_packer->pack_int64((yyvsp[-2].u.int64)); } } +#line 2667 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 137: - -/* Line 1464 of yacc.c */ -#line 1034 "dcParser.yxx" +#line 1040 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { - for (unsigned int i = 0; i < (yyvsp[(3) - (3)].u.s_uint); i++) { - current_packer->pack_uint64((yyvsp[(1) - (3)].u.uint64)); + for (unsigned int i = 0; i < (yyvsp[0].u.s_uint); i++) { + current_packer->pack_uint64((yyvsp[-2].u.uint64)); } } +#line 2677 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 138: - -/* Line 1464 of yacc.c */ -#line 1040 "dcParser.yxx" +#line 1046 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { - for (unsigned int i = 0; i < (yyvsp[(3) - (3)].u.s_uint); i++) { - current_packer->pack_double((yyvsp[(1) - (3)].u.real)); + for (unsigned int i = 0; i < (yyvsp[0].u.s_uint); i++) { + current_packer->pack_double((yyvsp[-2].u.real)); } } +#line 2687 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 139: - -/* Line 1464 of yacc.c */ -#line 1046 "dcParser.yxx" +#line 1052 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { - for (unsigned int i = 0; i < (yyvsp[(3) - (3)].u.s_uint); i++) { - current_packer->pack_literal_value((yyvsp[(1) - (3)].str)); + for (unsigned int i = 0; i < (yyvsp[0].u.s_uint); i++) { + current_packer->pack_literal_value((yyvsp[-2].bytes)); } } +#line 2697 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 146: - -/* Line 1464 of yacc.c */ -#line 1070 "dcParser.yxx" +#line 1076 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { (yyval.u.subatomic) = ST_int8; } +#line 2705 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 147: - -/* Line 1464 of yacc.c */ -#line 1074 "dcParser.yxx" +#line 1080 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { (yyval.u.subatomic) = ST_int16; } +#line 2713 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 148: - -/* Line 1464 of yacc.c */ -#line 1078 "dcParser.yxx" +#line 1084 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { (yyval.u.subatomic) = ST_int32; } +#line 2721 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 149: - -/* Line 1464 of yacc.c */ -#line 1082 "dcParser.yxx" +#line 1088 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { (yyval.u.subatomic) = ST_int64; } +#line 2729 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 150: - -/* Line 1464 of yacc.c */ -#line 1086 "dcParser.yxx" +#line 1092 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { (yyval.u.subatomic) = ST_uint8; } +#line 2737 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 151: - -/* Line 1464 of yacc.c */ -#line 1090 "dcParser.yxx" +#line 1096 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { (yyval.u.subatomic) = ST_uint16; } +#line 2745 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 152: - -/* Line 1464 of yacc.c */ -#line 1094 "dcParser.yxx" +#line 1100 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { (yyval.u.subatomic) = ST_uint32; } +#line 2753 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 153: - -/* Line 1464 of yacc.c */ -#line 1098 "dcParser.yxx" +#line 1104 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { (yyval.u.subatomic) = ST_uint64; } +#line 2761 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 154: - -/* Line 1464 of yacc.c */ -#line 1102 "dcParser.yxx" +#line 1108 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { (yyval.u.subatomic) = ST_float64; } +#line 2769 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 155: - -/* Line 1464 of yacc.c */ -#line 1106 "dcParser.yxx" +#line 1112 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { (yyval.u.subatomic) = ST_string; } +#line 2777 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 156: - -/* Line 1464 of yacc.c */ -#line 1110 "dcParser.yxx" +#line 1116 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { (yyval.u.subatomic) = ST_blob; } +#line 2785 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 157: - -/* Line 1464 of yacc.c */ -#line 1114 "dcParser.yxx" +#line 1120 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { (yyval.u.subatomic) = ST_blob32; } +#line 2793 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 158: - -/* Line 1464 of yacc.c */ -#line 1118 "dcParser.yxx" +#line 1124 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { (yyval.u.subatomic) = ST_int8array; } +#line 2801 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 159: - -/* Line 1464 of yacc.c */ -#line 1122 "dcParser.yxx" +#line 1128 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { (yyval.u.subatomic) = ST_int16array; } +#line 2809 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 160: - -/* Line 1464 of yacc.c */ -#line 1126 "dcParser.yxx" +#line 1132 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { (yyval.u.subatomic) = ST_int32array; } +#line 2817 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 161: - -/* Line 1464 of yacc.c */ -#line 1130 "dcParser.yxx" +#line 1136 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { (yyval.u.subatomic) = ST_uint8array; } +#line 2825 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 162: - -/* Line 1464 of yacc.c */ -#line 1134 "dcParser.yxx" +#line 1140 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { (yyval.u.subatomic) = ST_uint16array; } +#line 2833 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 163: - -/* Line 1464 of yacc.c */ -#line 1138 "dcParser.yxx" +#line 1144 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { (yyval.u.subatomic) = ST_uint32array; } +#line 2841 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 164: - -/* Line 1464 of yacc.c */ -#line 1142 "dcParser.yxx" +#line 1148 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { (yyval.u.subatomic) = ST_uint32uint8array; } +#line 2849 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 165: - -/* Line 1464 of yacc.c */ -#line 1146 "dcParser.yxx" +#line 1152 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { (yyval.u.subatomic) = ST_char; } +#line 2857 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 166: - -/* Line 1464 of yacc.c */ -#line 1153 "dcParser.yxx" +#line 1159 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { current_keyword_list.clear_keywords(); } +#line 2865 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 167: - -/* Line 1464 of yacc.c */ -#line 1157 "dcParser.yxx" +#line 1163 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { - current_keyword_list.add_keyword((yyvsp[(2) - (2)].u.keyword)); + current_keyword_list.add_keyword((yyvsp[0].u.keyword)); } +#line 2873 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 168: - -/* Line 1464 of yacc.c */ -#line 1164 "dcParser.yxx" +#line 1170 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { if (current_keyword_list.get_num_keywords() != 0) { yyerror("Communication keywords are not allowed here."); } } +#line 2883 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 169: - -/* Line 1464 of yacc.c */ -#line 1173 "dcParser.yxx" +#line 1179 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { - current_molecular = new DCMolecularField((yyvsp[(1) - (2)].str), current_class); + current_molecular = new DCMolecularField((yyvsp[-1].str), current_class); } +#line 2891 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 170: - -/* Line 1464 of yacc.c */ -#line 1177 "dcParser.yxx" +#line 1183 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { (yyval.u.field) = current_molecular; } +#line 2899 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 171: - -/* Line 1464 of yacc.c */ -#line 1184 "dcParser.yxx" +#line 1190 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { - DCField *field = current_class->get_field_by_name((yyvsp[(1) - (1)].str)); - (yyval.u.atomic) = (DCAtomicField *)NULL; - if (field == (DCField *)NULL) { + DCField *field = current_class->get_field_by_name((yyvsp[0].str)); + (yyval.u.atomic) = nullptr; + if (field == nullptr) { // Maybe the field is unknown because the class is partially // bogus. In that case, allow it for now; create a bogus field as // a placeholder. if (current_class->inherits_from_bogus_class()) { - (yyval.u.atomic) = new DCAtomicField((yyvsp[(1) - (1)].str), current_class, true); + (yyval.u.atomic) = new DCAtomicField((yyvsp[0].str), current_class, true); current_class->add_field((yyval.u.atomic)); } else { // Nope, it's a fully-defined class, so this is a real error. - yyerror("Unknown field: " + (yyvsp[(1) - (1)].str)); + yyerror("Unknown field: " + (yyvsp[0].str)); } } else { (yyval.u.atomic) = field->as_atomic_field(); - if ((yyval.u.atomic) == (DCAtomicField *)NULL) { - yyerror("Not an atomic field: " + (yyvsp[(1) - (1)].str)); + if ((yyval.u.atomic) == nullptr) { + yyerror("Not an atomic field: " + (yyvsp[0].str)); } } } +#line 2927 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 172: - -/* Line 1464 of yacc.c */ -#line 1211 "dcParser.yxx" +#line 1217 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { - if ((yyvsp[(1) - (1)].u.atomic) != (DCAtomicField *)NULL) { - current_molecular->add_atomic((yyvsp[(1) - (1)].u.atomic)); + if ((yyvsp[0].u.atomic) != nullptr) { + current_molecular->add_atomic((yyvsp[0].u.atomic)); } } +#line 2937 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 173: - -/* Line 1464 of yacc.c */ -#line 1217 "dcParser.yxx" +#line 1223 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { - if ((yyvsp[(3) - (3)].u.atomic) != (DCAtomicField *)NULL) { - current_molecular->add_atomic((yyvsp[(3) - (3)].u.atomic)); - if (!(yyvsp[(3) - (3)].u.atomic)->is_bogus_field() && !current_molecular->compare_keywords(*(yyvsp[(3) - (3)].u.atomic))) { - yyerror("Mismatched keywords in molecule between " + + if ((yyvsp[0].u.atomic) != nullptr) { + current_molecular->add_atomic((yyvsp[0].u.atomic)); + if (!(yyvsp[0].u.atomic)->is_bogus_field() && !current_molecular->compare_keywords(*(yyvsp[0].u.atomic))) { + yyerror("Mismatched keywords in molecule between " + current_molecular->get_atomic(0)->get_name() + " and " + - (yyvsp[(3) - (3)].u.atomic)->get_name()); + (yyvsp[0].u.atomic)->get_name()); } } } +#line 2952 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 174: - -/* Line 1464 of yacc.c */ -#line 1231 "dcParser.yxx" +#line 1237 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { (yyval.str) = ""; } +#line 2960 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 176: - -/* Line 1464 of yacc.c */ -#line 1239 "dcParser.yxx" +#line 1245 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { - current_switch = new DCSwitch((yyvsp[(2) - (6)].str), (yyvsp[(4) - (6)].u.field)); + current_switch = new DCSwitch((yyvsp[-4].str), (yyvsp[-2].u.field)); } +#line 2968 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 177: - -/* Line 1464 of yacc.c */ -#line 1243 "dcParser.yxx" +#line 1249 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { (yyval.u.dswitch) = current_switch; - current_switch = (DCSwitch *)(yyvsp[(7) - (9)].u.parameter); + current_switch = (DCSwitch *)(yyvsp[-2].u.parameter); } +#line 2977 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 183: - -/* Line 1464 of yacc.c */ -#line 1257 "dcParser.yxx" +#line 1263 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { if (!current_switch->is_field_valid()) { yyerror("case declaration required before first element"); - } else if ((yyvsp[(2) - (3)].u.field) != (DCField *)NULL) { - if (!current_switch->add_field((yyvsp[(2) - (3)].u.field))) { - yyerror("Duplicate field name: " + (yyvsp[(2) - (3)].u.field)->get_name()); + } else if ((yyvsp[-1].u.field) != nullptr) { + if (!current_switch->add_field((yyvsp[-1].u.field))) { + yyerror("Duplicate field name: " + (yyvsp[-1].u.field)->get_name()); } } } +#line 2991 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 184: - -/* Line 1464 of yacc.c */ -#line 1270 "dcParser.yxx" +#line 1276 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { current_packer = &default_packer; current_packer->clear_data(); current_packer->begin_pack(current_switch->get_key_parameter()); } +#line 3001 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 185: - -/* Line 1464 of yacc.c */ -#line 1276 "dcParser.yxx" +#line 1282 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { if (!current_packer->end_pack()) { yyerror("Invalid value for switch parameter"); current_switch->add_invalid_case(); } else { - int case_index = current_switch->add_case(current_packer->get_string()); + int case_index = current_switch->add_case(current_packer->get_bytes()); if (case_index == -1) { yyerror("Duplicate case value"); } } } +#line 3017 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 186: - -/* Line 1464 of yacc.c */ -#line 1291 "dcParser.yxx" +#line 1297 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { if (!current_switch->add_default()) { yyerror("Default case already defined"); } } +#line 3027 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 187: - -/* Line 1464 of yacc.c */ -#line 1300 "dcParser.yxx" +#line 1306 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { current_switch->add_break(); } +#line 3035 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 188: - -/* Line 1464 of yacc.c */ -#line 1307 "dcParser.yxx" +#line 1313 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { - (yyval.u.field) = (yyvsp[(1) - (1)].u.parameter); + (yyval.u.field) = (yyvsp[0].u.parameter); } +#line 3043 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; case 189: - -/* Line 1464 of yacc.c */ -#line 1311 "dcParser.yxx" +#line 1317 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ { - (yyval.u.field) = (yyvsp[(1) - (1)].u.parameter); + (yyval.u.field) = (yyvsp[0].u.parameter); } +#line 3051 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ break; - -/* Line 1464 of yacc.c */ -#line 3380 "y.tab.c" +#line 3055 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ default: break; } + /* User semantic actions sometimes alter yychar, and that requires + that yytoken be updated with the new translation. We take the + approach of translating immediately before every use of yytoken. + One alternative is translating here after every semantic action, + but that translation would be missed if the semantic action invokes + YYABORT, YYACCEPT, or YYERROR immediately after altering yychar or + if it invokes YYBACKUP. In the case of YYABORT or YYACCEPT, an + incorrect destructor might then be invoked immediately. In the + case of YYERROR or YYBACKUP, subsequent parser actions might lead + to an incorrect destructor call or verbose syntax error message + before the lookahead is translated. */ YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc); YYPOPSTACK (yylen); @@ -3391,7 +3073,7 @@ yyreduce: *++yyvsp = yyval; - /* Now `shift' the result of the reduction. Determine what state + /* Now 'shift' the result of the reduction. Determine what state that goes to, based on the state we popped back to and the rule number reduced by. */ @@ -3406,10 +3088,14 @@ yyreduce: goto yynewstate; -/*------------------------------------. -| yyerrlab -- here on detecting error | -`------------------------------------*/ +/*--------------------------------------. +| yyerrlab -- here on detecting error. | +`--------------------------------------*/ yyerrlab: + /* Make sure we have latest lookahead translation. See comments at + user semantic actions for why this is necessary. */ + yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar); + /* If not already recovering from an error, report this error. */ if (!yyerrstatus) { @@ -3417,37 +3103,36 @@ yyerrlab: #if ! YYERROR_VERBOSE yyerror (YY_("syntax error")); #else +# define YYSYNTAX_ERROR yysyntax_error (&yymsg_alloc, &yymsg, \ + yyssp, yytoken) { - YYSIZE_T yysize = yysyntax_error (0, yystate, yychar); - if (yymsg_alloc < yysize && yymsg_alloc < YYSTACK_ALLOC_MAXIMUM) - { - YYSIZE_T yyalloc = 2 * yysize; - if (! (yysize <= yyalloc && yyalloc <= YYSTACK_ALLOC_MAXIMUM)) - yyalloc = YYSTACK_ALLOC_MAXIMUM; - if (yymsg != yymsgbuf) - YYSTACK_FREE (yymsg); - yymsg = (char *) YYSTACK_ALLOC (yyalloc); - if (yymsg) - yymsg_alloc = yyalloc; - else - { - yymsg = yymsgbuf; - yymsg_alloc = sizeof yymsgbuf; - } - } - - if (0 < yysize && yysize <= yymsg_alloc) - { - (void) yysyntax_error (yymsg, yystate, yychar); - yyerror (yymsg); - } - else - { - yyerror (YY_("syntax error")); - if (yysize != 0) - goto yyexhaustedlab; - } + char const *yymsgp = YY_("syntax error"); + int yysyntax_error_status; + yysyntax_error_status = YYSYNTAX_ERROR; + if (yysyntax_error_status == 0) + yymsgp = yymsg; + else if (yysyntax_error_status == 1) + { + if (yymsg != yymsgbuf) + YYSTACK_FREE (yymsg); + yymsg = (char *) YYSTACK_ALLOC (yymsg_alloc); + if (!yymsg) + { + yymsg = yymsgbuf; + yymsg_alloc = sizeof yymsgbuf; + yysyntax_error_status = 2; + } + else + { + yysyntax_error_status = YYSYNTAX_ERROR; + yymsgp = yymsg; + } + } + yyerror (yymsgp); + if (yysyntax_error_status == 2) + goto yyexhaustedlab; } +# undef YYSYNTAX_ERROR #endif } @@ -3456,20 +3141,20 @@ yyerrlab: if (yyerrstatus == 3) { /* If just tried and failed to reuse lookahead token after an - error, discard it. */ + error, discard it. */ if (yychar <= YYEOF) - { - /* Return failure if at end of input. */ - if (yychar == YYEOF) - YYABORT; - } + { + /* Return failure if at end of input. */ + if (yychar == YYEOF) + YYABORT; + } else - { - yydestruct ("Error: discarding", - yytoken, &yylval); - yychar = YYEMPTY; - } + { + yydestruct ("Error: discarding", + yytoken, &yylval); + yychar = YYEMPTY; + } } /* Else will try to reuse lookahead token after shifting the error @@ -3488,7 +3173,7 @@ yyerrorlab: if (/*CONSTCOND*/ 0) goto yyerrorlab; - /* Do not reclaim the symbols of the rule which action triggered + /* Do not reclaim the symbols of the rule whose action triggered this YYERROR. */ YYPOPSTACK (yylen); yylen = 0; @@ -3501,35 +3186,37 @@ yyerrorlab: | yyerrlab1 -- common code for both syntax error and YYERROR. | `-------------------------------------------------------------*/ yyerrlab1: - yyerrstatus = 3; /* Each real token shifted decrements this. */ + yyerrstatus = 3; /* Each real token shifted decrements this. */ for (;;) { yyn = yypact[yystate]; - if (yyn != YYPACT_NINF) - { - yyn += YYTERROR; - if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) - { - yyn = yytable[yyn]; - if (0 < yyn) - break; - } - } + if (!yypact_value_is_default (yyn)) + { + yyn += YYTERROR; + if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR) + { + yyn = yytable[yyn]; + if (0 < yyn) + break; + } + } /* Pop the current state because it cannot handle the error token. */ if (yyssp == yyss) - YYABORT; + YYABORT; yydestruct ("Error: popping", - yystos[yystate], yyvsp); + yystos[yystate], yyvsp); YYPOPSTACK (1); yystate = *yyssp; YY_STACK_PRINT (yyss, yyssp); } + YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN *++yyvsp = yylval; + YY_IGNORE_MAYBE_UNINITIALIZED_END /* Shift the error token. */ @@ -3553,7 +3240,7 @@ yyabortlab: yyresult = 1; goto yyreturn; -#if !defined(yyoverflow) || YYERROR_VERBOSE +#if !defined yyoverflow || YYERROR_VERBOSE /*-------------------------------------------------. | yyexhaustedlab -- memory exhaustion comes here. | `-------------------------------------------------*/ @@ -3565,16 +3252,21 @@ yyexhaustedlab: yyreturn: if (yychar != YYEMPTY) - yydestruct ("Cleanup: discarding lookahead", - yytoken, &yylval); - /* Do not reclaim the symbols of the rule which action triggered + { + /* Make sure we have latest lookahead translation. See comments at + user semantic actions for why this is necessary. */ + yytoken = YYTRANSLATE (yychar); + yydestruct ("Cleanup: discarding lookahead", + yytoken, &yylval); + } + /* Do not reclaim the symbols of the rule whose action triggered this YYABORT or YYACCEPT. */ YYPOPSTACK (yylen); YY_STACK_PRINT (yyss, yyssp); while (yyssp != yyss) { yydestruct ("Cleanup: popping", - yystos[*yyssp], yyvsp); + yystos[*yyssp], yyvsp); YYPOPSTACK (1); } #ifndef yyoverflow @@ -3585,9 +3277,5 @@ yyreturn: if (yymsg != yymsgbuf) YYSTACK_FREE (yymsg); #endif - /* Make sure YYID is used. */ - return YYID (yyresult); + return yyresult; } - - - diff --git a/direct/src/dcparser/dcParser.h.prebuilt b/direct/src/dcparser/dcParser.h.prebuilt index 680eeff59c..7b46c4c7b1 100644 --- a/direct/src/dcparser/dcParser.h.prebuilt +++ b/direct/src/dcparser/dcParser.h.prebuilt @@ -1,20 +1,19 @@ -/* A Bison parser, made by GNU Bison 2.4.2. */ +/* A Bison parser, made by GNU Bison 3.0.4. */ + +/* Bison interface for Yacc-like parsers in C + + Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc. -/* Skeleton interface for Bison's Yacc-like parsers in C - - Copyright (C) 1984, 1989-1990, 2000-2006, 2009-2010 Free Software - Foundation, Inc. - This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. - + This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - + You should have received a copy of the GNU General Public License along with this program. If not, see . */ @@ -27,66 +26,74 @@ special exception, which will cause the skeleton and the resulting Bison output files to be licensed under the GNU General Public License without this special exception. - + This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ +#ifndef YY_DCYY_BUILT_TMP_DCPARSER_YXX_H_INCLUDED +# define YY_DCYY_BUILT_TMP_DCPARSER_YXX_H_INCLUDED +/* Debug traces. */ +#ifndef YYDEBUG +# define YYDEBUG 0 +#endif +#if YYDEBUG +extern int dcyydebug; +#endif -/* Tokens. */ +/* Token type. */ #ifndef YYTOKENTYPE # define YYTOKENTYPE - /* Put the tokens into the symbol table, so that GDB and other debuggers - know about them. */ - enum yytokentype { - UNSIGNED_INTEGER = 258, - SIGNED_INTEGER = 259, - REAL = 260, - STRING = 261, - HEX_STRING = 262, - IDENTIFIER = 263, - KEYWORD = 264, - KW_DCLASS = 265, - KW_STRUCT = 266, - KW_FROM = 267, - KW_IMPORT = 268, - KW_TYPEDEF = 269, - KW_KEYWORD = 270, - KW_SWITCH = 271, - KW_CASE = 272, - KW_DEFAULT = 273, - KW_BREAK = 274, - KW_INT8 = 275, - KW_INT16 = 276, - KW_INT32 = 277, - KW_INT64 = 278, - KW_UINT8 = 279, - KW_UINT16 = 280, - KW_UINT32 = 281, - KW_UINT64 = 282, - KW_FLOAT64 = 283, - KW_STRING = 284, - KW_BLOB = 285, - KW_BLOB32 = 286, - KW_INT8ARRAY = 287, - KW_INT16ARRAY = 288, - KW_INT32ARRAY = 289, - KW_UINT8ARRAY = 290, - KW_UINT16ARRAY = 291, - KW_UINT32ARRAY = 292, - KW_UINT32UINT8ARRAY = 293, - KW_CHAR = 294, - START_DC = 295, - START_PARAMETER_VALUE = 296, - START_PARAMETER_DESCRIPTION = 297 - }; + enum yytokentype + { + UNSIGNED_INTEGER = 258, + SIGNED_INTEGER = 259, + REAL = 260, + STRING = 261, + IDENTIFIER = 262, + HEX_STRING = 263, + KEYWORD = 264, + KW_DCLASS = 265, + KW_STRUCT = 266, + KW_FROM = 267, + KW_IMPORT = 268, + KW_TYPEDEF = 269, + KW_KEYWORD = 270, + KW_SWITCH = 271, + KW_CASE = 272, + KW_DEFAULT = 273, + KW_BREAK = 274, + KW_INT8 = 275, + KW_INT16 = 276, + KW_INT32 = 277, + KW_INT64 = 278, + KW_UINT8 = 279, + KW_UINT16 = 280, + KW_UINT32 = 281, + KW_UINT64 = 282, + KW_FLOAT64 = 283, + KW_STRING = 284, + KW_BLOB = 285, + KW_BLOB32 = 286, + KW_INT8ARRAY = 287, + KW_INT16ARRAY = 288, + KW_INT32ARRAY = 289, + KW_UINT8ARRAY = 290, + KW_UINT16ARRAY = 291, + KW_UINT32ARRAY = 292, + KW_UINT32UINT8ARRAY = 293, + KW_CHAR = 294, + START_DC = 295, + START_PARAMETER_VALUE = 296, + START_PARAMETER_DESCRIPTION = 297 + }; #endif /* Tokens. */ #define UNSIGNED_INTEGER 258 #define SIGNED_INTEGER 259 #define REAL 260 #define STRING 261 -#define HEX_STRING 262 -#define IDENTIFIER 263 +#define IDENTIFIER 262 +#define HEX_STRING 263 #define KEYWORD 264 #define KW_DCLASS 265 #define KW_STRUCT 266 @@ -122,15 +129,11 @@ #define START_PARAMETER_VALUE 296 #define START_PARAMETER_DESCRIPTION 297 +/* Value type. */ - -#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED - -# define yystype YYSTYPE /* obsolescent; will be withdrawn */ -# define YYSTYPE_IS_DECLARED 1 -#endif - extern YYSTYPE dcyylval; +int dcyyparse (void); +#endif /* !YY_DCYY_BUILT_TMP_DCPARSER_YXX_H_INCLUDED */ diff --git a/direct/src/dcparser/dcParser.yxx b/direct/src/dcparser/dcParser.yxx index 0a5c3d6aa0..b283c3314b 100644 --- a/direct/src/dcparser/dcParser.yxx +++ b/direct/src/dcparser/dcParser.yxx @@ -57,7 +57,7 @@ dc_init_parser(istream &in, const string &filename, DCFile &file) { } void -dc_init_parser_parameter_value(istream &in, const string &filename, +dc_init_parser_parameter_value(istream &in, const string &filename, DCPacker &packer) { dc_file = nullptr; current_packer = &packer; @@ -89,15 +89,16 @@ dc_cleanup_parser() { %token UNSIGNED_INTEGER %token SIGNED_INTEGER %token REAL -%token STRING HEX_STRING IDENTIFIER +%token STRING IDENTIFIER +%token HEX_STRING %token KEYWORD -%token KW_DCLASS -%token KW_STRUCT -%token KW_FROM -%token KW_IMPORT -%token KW_TYPEDEF -%token KW_KEYWORD +%token KW_DCLASS +%token KW_STRUCT +%token KW_FROM +%token KW_IMPORT +%token KW_TYPEDEF +%token KW_KEYWORD %token KW_SWITCH %token KW_CASE %token KW_DEFAULT @@ -224,7 +225,7 @@ import: { dc_file->add_import_module($2); } - | KW_FROM import_identifier KW_IMPORT + | KW_FROM import_identifier KW_IMPORT { dc_file->add_import_module($2); } @@ -255,7 +256,7 @@ typedef_decl: { if ($2 != nullptr) { 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()) { @@ -294,7 +295,7 @@ dclass_or_struct: ; dclass: - KW_DCLASS optional_name + KW_DCLASS optional_name { current_class = new DCClass(dc_file, $2, false, false); } @@ -322,7 +323,7 @@ dclass_name: if (dclass->is_struct()) { yyerror("struct name not allowed"); } - + $$ = dclass; } } @@ -398,7 +399,7 @@ dclass_field: ; struct: - KW_STRUCT optional_name + KW_STRUCT optional_name { current_class = new DCClass(dc_file, $2, true, false); } @@ -426,7 +427,7 @@ struct_name: if (!dstruct->is_struct()) { yyerror("struct name required"); } - + $$ = dstruct; } } @@ -538,7 +539,7 @@ unnamed_parameter: named_parameter_with_default: named_parameter - | named_parameter '=' + | named_parameter '=' { current_packer = &default_packer; current_packer->clear_data(); @@ -553,7 +554,7 @@ named_parameter_with_default: is_valid = $1->is_valid(); } if (current_packer->end_pack()) { - $1->set_default_value(current_packer->get_string()); + $1->set_default_value(current_packer->get_bytes()); } else { if (is_valid) { @@ -568,7 +569,7 @@ named_parameter_with_default: unnamed_parameter_with_default: unnamed_parameter - | unnamed_parameter '=' + | unnamed_parameter '=' { current_packer = &default_packer; current_packer->clear_data(); @@ -583,7 +584,7 @@ unnamed_parameter_with_default: is_valid = $1->is_valid(); } if (current_packer->end_pack()) { - $1->set_default_value(current_packer->get_string()); + $1->set_default_value(current_packer->get_bytes()); } else { if (is_valid) { @@ -663,7 +664,7 @@ simple_type_name: $$ = simple_param; } | simple_type_name '%' number -{ +{ DCSimpleParameter *simple_param = $1->as_simple_parameter(); nassertr(simple_param != nullptr, 0); if (!simple_param->is_numeric_type()) { @@ -703,10 +704,10 @@ type_name: dtypedef = new DCTypedef($1); } } - + dc_file->add_typedef(dtypedef); } - + $$ = dtypedef->make_new_parameter(); } } @@ -974,7 +975,7 @@ parameter_value: { if ($1 != current_packer->get_current_field_name()) { ostringstream strm; - strm << "Got '" << $1 << "', expected '" + strm << "Got '" << $1 << "', expected '" << current_packer->get_current_field_name() << "'"; yyerror(strm.str()); } @@ -1005,7 +1006,7 @@ parameter_actual_value: { current_packer->pack_literal_value($1); } - | '{' + | '{' { current_packer->push(); } @@ -1013,7 +1014,7 @@ parameter_actual_value: { current_packer->pop(); } - | '[' + | '[' { current_packer->push(); } @@ -1021,7 +1022,7 @@ parameter_actual_value: { current_packer->pop(); } - | '(' + | '(' { current_packer->push(); } @@ -1223,7 +1224,7 @@ molecular_atom_list: if ($3 != nullptr) { current_molecular->add_atomic($3); if (!$3->is_bogus_field() && !current_molecular->compare_keywords(*$3)) { - yyerror("Mismatched keywords in molecule between " + + yyerror("Mismatched keywords in molecule between " + current_molecular->get_atomic(0)->get_name() + " and " + $3->get_name()); } @@ -1283,7 +1284,7 @@ switch_case: yyerror("Invalid value for switch parameter"); current_switch->add_invalid_case(); } else { - int case_index = current_switch->add_case(current_packer->get_string()); + int case_index = current_switch->add_case(current_packer->get_bytes()); if (case_index == -1) { yyerror("Duplicate case value"); } diff --git a/direct/src/dcparser/dcParserDefs.h b/direct/src/dcparser/dcParserDefs.h index 28659a37e3..f6f7aacd71 100644 --- a/direct/src/dcparser/dcParserDefs.h +++ b/direct/src/dcparser/dcParserDefs.h @@ -16,6 +16,7 @@ #include "dcbase.h" #include "dcSubatomicType.h" +#include "vector_uchar.h" class DCFile; class DCClass; @@ -61,6 +62,7 @@ public: const DCKeyword *keyword; } u; std::string str; + vector_uchar bytes; }; // The yacc-generated code expects to use the symbol 'YYSTYPE' to refer to the diff --git a/direct/src/dcparser/dcSimpleParameter.cxx b/direct/src/dcparser/dcSimpleParameter.cxx index bd2cb05534..5043307a4f 100644 --- a/direct/src/dcparser/dcSimpleParameter.cxx +++ b/direct/src/dcparser/dcSimpleParameter.cxx @@ -1069,6 +1069,52 @@ pack_string(DCPackData &pack_data, const string &value, } } +/** + * Packs the indicated numeric or string value into the stream. + */ +void DCSimpleParameter:: +pack_blob(DCPackData &pack_data, const vector_uchar &value, + bool &pack_error, bool &range_error) const { + size_t blob_size = value.size(); + + switch (_type) { + case ST_char: + case ST_uint8: + case ST_int8: + if (blob_size == 0) { + pack_error = true; + } else { + if (blob_size != 1) { + range_error = true; + } + _uint_range.validate((unsigned int)value[0], range_error); + do_pack_uint8(pack_data.get_write_pointer(1), (unsigned int)value[0]); + } + break; + + case ST_string: + case ST_blob: + _uint_range.validate(blob_size, range_error); + validate_uint_limits(blob_size, 16, range_error); + if (_num_length_bytes != 0) { + do_pack_uint16(pack_data.get_write_pointer(2), blob_size); + } + pack_data.append_data((const char *)value.data(), blob_size); + break; + + case ST_blob32: + _uint_range.validate(blob_size, range_error); + if (_num_length_bytes != 0) { + do_pack_uint32(pack_data.get_write_pointer(4), blob_size); + } + pack_data.append_data((const char *)value.data(), blob_size); + break; + + default: + pack_error = true; + } +} + /** * Packs the simpleParameter's specified default value (or a sensible default * if no value is specified) into the stream. Returns true if the default @@ -1937,6 +1983,79 @@ unpack_string(const char *data, size_t length, size_t &p, string &value, return; } +/** + * Unpacks the current numeric or string value from the stream. + */ +void DCSimpleParameter:: +unpack_blob(const char *data, size_t length, size_t &p, vector_uchar &value, + bool &pack_error, bool &range_error) const { + // If the type is a single byte, unpack it into a string of length 1. + switch (_type) { + case ST_char: + case ST_int8: + case ST_uint8: + { + if (p + 1 > length) { + pack_error = true; + return; + } + unsigned int int_value = do_unpack_uint8(data + p); + _uint_range.validate(int_value, range_error); + value.resize(1); + value[0] = int_value; + p++; + } + return; + + default: + break; + } + + size_t blob_size; + + if (_num_length_bytes == 0) { + blob_size = _fixed_byte_size; + + } else { + switch (_type) { + case ST_string: + case ST_blob: + if (p + 2 > length) { + pack_error = true; + return; + } + blob_size = do_unpack_uint16(data + p); + p += 2; + break; + + case ST_blob32: + if (p + 4 > length) { + pack_error = true; + return; + } + blob_size = do_unpack_uint32(data + p); + p += 4; + break; + + default: + pack_error = true; + return; + } + } + + _uint_range.validate(blob_size, range_error); + + if (p + blob_size > length) { + pack_error = true; + return; + } + value = vector_uchar((const unsigned char *)data + p, + (const unsigned char *)data + p + blob_size); + p += blob_size; + + return; +} + /** * Internally unpacks the current numeric or string value and validates it * against the type range limits, but does not return the value. Returns true diff --git a/direct/src/dcparser/dcSimpleParameter.h b/direct/src/dcparser/dcSimpleParameter.h index 7b47773a3d..cafd246d62 100644 --- a/direct/src/dcparser/dcSimpleParameter.h +++ b/direct/src/dcparser/dcSimpleParameter.h @@ -62,6 +62,8 @@ public: bool &pack_error, bool &range_error) const; virtual void pack_string(DCPackData &pack_data, const std::string &value, bool &pack_error, bool &range_error) const; + virtual void pack_blob(DCPackData &pack_data, const vector_uchar &value, + bool &pack_error, bool &range_error) const; virtual bool pack_default_value(DCPackData &pack_data, bool &pack_error) const; virtual void unpack_double(const char *data, size_t length, size_t &p, @@ -76,6 +78,8 @@ public: uint64_t &value, bool &pack_error, bool &range_error) const; virtual void unpack_string(const char *data, size_t length, size_t &p, std::string &value, bool &pack_error, bool &range_error) const; + virtual void unpack_blob(const char *data, size_t length, size_t &p, + vector_uchar &value, bool &pack_error, bool &range_error) const; virtual bool unpack_validate(const char *data, size_t length, size_t &p, bool &pack_error, bool &range_error) const; virtual bool unpack_skip(const char *data, size_t length, size_t &p, diff --git a/direct/src/dcparser/dcSwitch.cxx b/direct/src/dcparser/dcSwitch.cxx index 5b23505209..041533efbe 100644 --- a/direct/src/dcparser/dcSwitch.cxx +++ b/direct/src/dcparser/dcSwitch.cxx @@ -109,7 +109,7 @@ get_num_cases() const { * if no case has this value. */ int DCSwitch:: -get_case_by_value(const string &case_value) const { +get_case_by_value(const vector_uchar &case_value) const { CasesByValue::const_iterator vi; vi = _cases_by_value.find(case_value); if (vi != _cases_by_value.end()) { @@ -140,9 +140,9 @@ get_default_case() const { /** * Returns the packed value associated with the indicated case. */ -string DCSwitch:: +vector_uchar DCSwitch:: get_value(int case_index) const { - nassertr(case_index >= 0 && case_index < (int)_cases.size(), string()); + nassertr(case_index >= 0 && case_index < (int)_cases.size(), vector_uchar()); return _cases[case_index]->_value; } @@ -198,7 +198,7 @@ is_field_valid() const { * -1. This is normally called only by the parser. */ int DCSwitch:: -add_case(const string &value) { +add_case(const vector_uchar &value) { int case_index = (int)_cases.size(); if (!_cases_by_value.insert(CasesByValue::value_type(value, case_index)).second) { add_invalid_case(); @@ -283,7 +283,8 @@ add_break() { const DCPackerInterface *DCSwitch:: apply_switch(const char *value_data, size_t length) const { CasesByValue::const_iterator vi; - vi = _cases_by_value.find(string(value_data, length)); + vi = _cases_by_value.find(vector_uchar((const unsigned char *)value_data, + (const unsigned char *)value_data + length)); if (vi != _cases_by_value.end()) { return _cases[(*vi).second]->_fields; } @@ -421,7 +422,7 @@ generate_hash(HashGenerator &hashgen) const { Cases::const_iterator ci; for (ci = _cases.begin(); ci != _cases.end(); ++ci) { const SwitchCase *dcase = (*ci); - hashgen.add_string(dcase->_value); + hashgen.add_blob(dcase->_value); const SwitchFields *fields = dcase->_fields; hashgen.add_int(fields->_fields.size()); @@ -702,7 +703,7 @@ do_check_match(const DCPackerInterface *) const { * */ DCSwitch::SwitchCase:: -SwitchCase(const string &value, DCSwitch::SwitchFields *fields) : +SwitchCase(const vector_uchar &value, DCSwitch::SwitchFields *fields) : _value(value), _fields(fields) { diff --git a/direct/src/dcparser/dcSwitch.h b/direct/src/dcparser/dcSwitch.h index ac58f5439d..31e69b452b 100644 --- a/direct/src/dcparser/dcSwitch.h +++ b/direct/src/dcparser/dcSwitch.h @@ -40,18 +40,18 @@ PUBLISHED: DCField *get_key_parameter() const; int get_num_cases() const; - int get_case_by_value(const std::string &case_value) const; + int get_case_by_value(const vector_uchar &case_value) const; DCPackerInterface *get_case(int n) const; DCPackerInterface *get_default_case() const; - std::string get_value(int case_index) const; + vector_uchar get_value(int case_index) const; int get_num_fields(int case_index) const; DCField *get_field(int case_index, int n) const; DCField *get_field_by_name(int case_index, const std::string &name) const; public: bool is_field_valid() const; - int add_case(const std::string &value); + int add_case(const vector_uchar &value); void add_invalid_case(); bool add_default(); bool add_field(DCField *field); @@ -98,13 +98,13 @@ public: class SwitchCase { public: - SwitchCase(const std::string &value, SwitchFields *fields); + SwitchCase(const vector_uchar &value, SwitchFields *fields); ~SwitchCase(); bool do_check_match_switch_case(const SwitchCase *other) const; public: - std::string _value; + vector_uchar _value; SwitchFields *_fields; }; @@ -137,7 +137,7 @@ private: bool _fields_added; // This map indexes into the _cases vector, above. - typedef pmap CasesByValue; + typedef pmap CasesByValue; CasesByValue _cases_by_value; }; diff --git a/direct/src/dcparser/hashGenerator.cxx b/direct/src/dcparser/hashGenerator.cxx index 900fd4bf42..bd3a6553b4 100644 --- a/direct/src/dcparser/hashGenerator.cxx +++ b/direct/src/dcparser/hashGenerator.cxx @@ -56,6 +56,18 @@ add_string(const std::string &str) { } } +/** + * Adds a blob to the hash, by breaking it down into a sequence of integers. + */ +void HashGenerator:: +add_blob(const vector_uchar &bytes) { + add_int(bytes.size()); + vector_uchar::const_iterator bi; + for (bi = bytes.begin(); bi != bytes.end(); ++bi) { + add_int(*bi); + } +} + /** * Returns the hash number generated. */ diff --git a/direct/src/dcparser/hashGenerator.h b/direct/src/dcparser/hashGenerator.h index 29ae1a6609..472e858cb0 100644 --- a/direct/src/dcparser/hashGenerator.h +++ b/direct/src/dcparser/hashGenerator.h @@ -16,6 +16,7 @@ #include "dcbase.h" #include "primeNumberGenerator.h" +#include "vector_uchar.h" /** * This class generates an arbitrary hash number from a sequence of ints. @@ -26,6 +27,7 @@ public: void add_int(int num); void add_string(const std::string &str); + void add_blob(const vector_uchar &bytes); unsigned long get_hash() const; diff --git a/direct/src/distributed/cConnectionRepository.cxx b/direct/src/distributed/cConnectionRepository.cxx index 6e429bfbec..16aea6e8dd 100644 --- a/direct/src/distributed/cConnectionRepository.cxx +++ b/direct/src/distributed/cConnectionRepository.cxx @@ -891,7 +891,7 @@ describe_message(std::ostream &out, const string &prefix, const Datagram &dg) const { DCPacker packer; - packer.set_unpack_data(dg.get_message()); + packer.set_unpack_data((const char *)dg.get_data(), dg.get_length(), false); CHANNEL_TYPE do_id; int msg_type; bool is_update = false; From 92539a310790b95c95fc239e8edba1a64185902e Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 19 Dec 2018 13:14:07 +0100 Subject: [PATCH 03/33] dcparser: rebuild dcParser.{cxx,h}.prebuilt --- direct/src/dcparser/dcParser.cxx.prebuilt | 555 +++++++++++----------- direct/src/dcparser/dcParser.h.prebuilt | 4 +- 2 files changed, 280 insertions(+), 279 deletions(-) diff --git a/direct/src/dcparser/dcParser.cxx.prebuilt b/direct/src/dcparser/dcParser.cxx.prebuilt index 9adc570263..399e4af2f9 100644 --- a/direct/src/dcparser/dcParser.cxx.prebuilt +++ b/direct/src/dcparser/dcParser.cxx.prebuilt @@ -1,8 +1,8 @@ -/* A Bison parser, made by GNU Bison 3.0.4. */ +/* A Bison parser, made by GNU Bison 3.1. */ /* Bison implementation for Yacc-like parsers in C - Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc. + Copyright (C) 1984, 1989-1990, 2000-2015, 2018 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -44,7 +44,7 @@ #define YYBISON 1 /* Bison version. */ -#define YYBISON_VERSION "3.0.4" +#define YYBISON_VERSION "3.1" /* Skeleton name. */ #define YYSKELETON_NAME "yacc.c" @@ -303,13 +303,13 @@ typedef signed char yytype_int8; #ifdef YYTYPE_UINT16 typedef YYTYPE_UINT16 yytype_uint16; #else -typedef unsigned short int yytype_uint16; +typedef unsigned short yytype_uint16; #endif #ifdef YYTYPE_INT16 typedef YYTYPE_INT16 yytype_int16; #else -typedef short int yytype_int16; +typedef short yytype_int16; #endif #ifndef YYSIZE_T @@ -321,7 +321,7 @@ typedef short int yytype_int16; # include /* INFRINGES ON USER NAME SPACE */ # define YYSIZE_T size_t # else -# define YYSIZE_T unsigned int +# define YYSIZE_T unsigned # endif #endif @@ -373,7 +373,7 @@ typedef short int yytype_int16; # define YYUSE(E) /* empty */ #endif -#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__ +#if defined __GNUC__ && ! defined __ICC && 407 <= __GNUC__ * 100 + __GNUC_MINOR__ /* Suppress an incorrect diagnostic about yylval being uninitialized. */ # define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \ _Pragma ("GCC diagnostic push") \ @@ -541,7 +541,7 @@ union yyalloc #define YYMAXUTOK 297 #define YYTRANSLATE(YYX) \ - ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) + ((unsigned) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK) /* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM as returned by yylex, without out-of-bounds checking. */ @@ -1083,7 +1083,7 @@ do { \ static void yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule) { - unsigned long int yylno = yyrline[yyrule]; + unsigned long yylno = yyrline[yyrule]; int yynrhs = yyr2[yyrule]; int yyi; YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n", @@ -1309,6 +1309,7 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg, case N: \ yyformat = S; \ break + default: /* Avoid compiler warnings. */ YYCASE_(0, YY_("syntax error")); YYCASE_(1, YY_("syntax error, unexpected %s")); YYCASE_(2, YY_("syntax error, unexpected %s, expecting %s")); @@ -1514,7 +1515,7 @@ yyparse (void) yyvsp = yyvs + yysize - 1; YYDPRINTF ((stderr, "Stack size increased to %lu\n", - (unsigned long int) yystacksize)); + (unsigned long) yystacksize)); if (yyss + yystacksize - 1 <= yyssp) YYABORT; @@ -1625,15 +1626,15 @@ yyreduce: switch (yyn) { case 4: -#line 177 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 177 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { parameter_description = (yyvsp[0].u.field); } -#line 1633 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 1634 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 7: -#line 186 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 186 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { if (!dc_file->add_class((yyvsp[0].u.dclass))) { DCClass *old_class = dc_file->get_class_by_name((yyvsp[0].u.dclass)->get_name()); @@ -1644,77 +1645,77 @@ yyreduce: } } } -#line 1648 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 1649 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 8: -#line 197 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 197 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { if (!dc_file->add_switch((yyvsp[0].u.dswitch))) { yyerror("Duplicate class name: " + (yyvsp[0].u.dswitch)->get_name()); } } -#line 1658 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 1659 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 13: -#line 210 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 210 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { (yyval.str) = (yyvsp[-2].str) + string("/") + (yyvsp[0].str); } -#line 1666 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 1667 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 15: -#line 218 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 218 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { (yyval.str) = (yyvsp[-2].str) + string(".") + (yyvsp[0].str); } -#line 1674 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 1675 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 16: -#line 225 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 225 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { dc_file->add_import_module((yyvsp[0].str)); } -#line 1682 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 1683 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 17: -#line 229 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 229 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { dc_file->add_import_module((yyvsp[-1].str)); } -#line 1690 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 1691 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 20: -#line 238 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 238 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { dc_file->add_import_symbol("*"); } -#line 1698 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 1699 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 21: -#line 245 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 245 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { dc_file->add_import_symbol((yyvsp[0].str)); } -#line 1706 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 1707 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 22: -#line 249 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 249 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { dc_file->add_import_symbol((yyvsp[0].str)); } -#line 1714 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 1715 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 23: -#line 256 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 256 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { if ((yyvsp[0].u.parameter) != nullptr) { DCTypedef *dtypedef = new DCTypedef((yyvsp[0].u.parameter)); @@ -1729,19 +1730,19 @@ yyreduce: } } } -#line 1733 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 1734 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 26: -#line 279 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 279 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { dc_file->add_keyword((yyvsp[0].str)); } -#line 1741 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 1742 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 27: -#line 283 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 283 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { // This keyword has already been defined. But since we are now // explicitly defining it, clear its bitmask, so that we will have a @@ -1749,28 +1750,28 @@ yyreduce: // historical hash code support later. ((DCKeyword *)(yyvsp[0].u.keyword))->clear_historical_flag(); } -#line 1753 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 1754 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 30: -#line 299 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 299 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { current_class = new DCClass(dc_file, (yyvsp[0].str), false, false); } -#line 1761 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 1762 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 31: -#line 303 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 303 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { (yyval.u.dclass) = current_class; current_class = (yyvsp[-4].u.dclass); } -#line 1770 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 1771 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 32: -#line 311 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 311 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { if (dc_file == nullptr) { yyerror("No DCFile available, so no class names are predefined."); @@ -1790,21 +1791,21 @@ yyreduce: (yyval.u.dclass) = dclass; } } -#line 1794 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 1795 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 35: -#line 339 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 339 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { if ((yyvsp[0].u.dclass) != nullptr) { current_class->add_parent((yyvsp[0].u.dclass)); } } -#line 1804 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 1805 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 36: -#line 345 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 345 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { if (!dc_multiple_inheritance) { yyerror("Multiple inheritance is not supported without \"dc-multiple-inheritance 1\" in your Config.prc file."); @@ -1815,11 +1816,11 @@ yyreduce: } } } -#line 1819 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 1820 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 39: -#line 361 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 361 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { if ((yyvsp[-1].u.field) == nullptr) { // Pass this error up. @@ -1829,11 +1830,11 @@ yyreduce: yyerror("A non-network field cannot be stored on a dclass"); } } -#line 1833 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 1834 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 40: -#line 374 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 374 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { if ((yyvsp[-1].u.field) != nullptr) { if ((yyvsp[-1].u.field)->get_name().empty()) { @@ -1843,11 +1844,11 @@ yyreduce: } (yyval.u.field) = (yyvsp[-1].u.field); } -#line 1847 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 1848 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 42: -#line 385 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 385 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { yyerror("Unnamed parameters are not allowed on a dclass"); if ((yyvsp[-1].u.parameter) != nullptr) { @@ -1855,39 +1856,39 @@ yyreduce: } (yyval.u.field) = (yyvsp[-1].u.parameter); } -#line 1859 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 1860 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 43: -#line 393 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 393 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { if ((yyvsp[-1].u.parameter) != nullptr) { (yyvsp[-1].u.parameter)->copy_keywords(current_keyword_list); } (yyval.u.field) = (yyvsp[-1].u.parameter); } -#line 1870 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 1871 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 44: -#line 403 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 403 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { current_class = new DCClass(dc_file, (yyvsp[0].str), true, false); } -#line 1878 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 1879 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 45: -#line 407 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 407 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { (yyval.u.dclass) = current_class; current_class = (yyvsp[-4].u.dclass); } -#line 1887 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 1888 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 46: -#line 415 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 415 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { if (dc_file == nullptr) { yyerror("No DCFile available, so no struct names are predefined."); @@ -1907,31 +1908,31 @@ yyreduce: (yyval.u.dclass) = dstruct; } } -#line 1911 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 1912 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 49: -#line 443 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 443 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { if ((yyvsp[0].u.dclass) != nullptr) { current_class->add_parent((yyvsp[0].u.dclass)); } } -#line 1921 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 1922 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 50: -#line 449 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 449 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { if ((yyvsp[0].u.dclass) != nullptr) { current_class->add_parent((yyvsp[0].u.dclass)); } } -#line 1931 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 1932 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 53: -#line 460 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 460 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { if ((yyvsp[-1].u.field) == nullptr) { // Pass this error up. @@ -1939,38 +1940,38 @@ yyreduce: yyerror("Duplicate field name: " + (yyvsp[-1].u.field)->get_name()); } } -#line 1943 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 1944 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 54: -#line 471 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 471 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { if ((yyvsp[-1].u.field)->get_name().empty()) { yyerror("Field name required."); } (yyval.u.field) = (yyvsp[-1].u.field); } -#line 1954 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 1955 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 56: -#line 479 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 479 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { (yyval.u.field) = (yyvsp[-1].u.parameter); } -#line 1962 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 1963 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 57: -#line 483 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 483 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { (yyval.u.field) = (yyvsp[-1].u.parameter); } -#line 1970 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 1971 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 58: -#line 490 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 490 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { if (current_class == nullptr) { yyerror("Cannot define a method outside of a struct or class."); @@ -1980,46 +1981,46 @@ yyreduce: current_atomic = new DCAtomicField((yyvsp[-1].str), current_class, false); } } -#line 1984 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 1985 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 59: -#line 500 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 500 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { (yyval.u.field) = current_atomic; current_atomic = (yyvsp[-2].u.atomic); } -#line 1993 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 1994 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 64: -#line 518 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 518 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { if ((yyvsp[0].u.parameter) != nullptr) { current_atomic->add_element((yyvsp[0].u.parameter)); } } -#line 2003 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 2004 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 65: -#line 527 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 527 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { current_parameter = (yyvsp[0].u.parameter); } -#line 2011 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 2012 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 66: -#line 531 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 531 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { (yyval.u.parameter) = (yyvsp[0].u.parameter); } -#line 2019 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 2020 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 69: -#line 543 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 543 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { current_packer = &default_packer; current_packer->clear_data(); @@ -2027,11 +2028,11 @@ yyreduce: current_packer->begin_pack((yyvsp[-1].u.parameter)); } } -#line 2031 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 2032 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 70: -#line 551 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 551 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { bool is_valid = false; if ((yyvsp[-3].u.parameter) != nullptr) { @@ -2049,11 +2050,11 @@ yyreduce: // just ignore the default value in this case. } } -#line 2053 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 2054 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 72: -#line 573 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 573 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { current_packer = &default_packer; current_packer->clear_data(); @@ -2061,11 +2062,11 @@ yyreduce: current_packer->begin_pack((yyvsp[-1].u.parameter)); } } -#line 2065 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 2066 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 73: -#line 581 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 581 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { bool is_valid = false; if ((yyvsp[-3].u.parameter) != nullptr) { @@ -2083,59 +2084,59 @@ yyreduce: // just ignore the default value in this case. } } -#line 2087 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 2088 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 78: -#line 612 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 612 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { (yyval.u.field) = (yyvsp[0].u.parameter); } -#line 2095 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 2096 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 79: -#line 616 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 616 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { (yyval.u.field) = (yyvsp[0].u.field); } -#line 2103 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 2104 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 80: -#line 623 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 623 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { (yyval.u.field) = (yyvsp[-1].u.field); } -#line 2111 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 2112 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 81: -#line 627 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 627 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { (yyval.u.field) = (yyvsp[-1].u.parameter); } -#line 2119 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 2120 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 82: -#line 631 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 631 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { (yyval.u.field) = (yyvsp[-1].u.parameter); } -#line 2127 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 2128 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 83: -#line 638 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 638 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { (yyval.u.parameter) = new DCSimpleParameter((yyvsp[0].u.subatomic)); } -#line 2135 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 2136 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 84: -#line 642 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 642 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { DCSimpleParameter *simple_param = (yyvsp[-3].u.parameter)->as_simple_parameter(); nassertr(simple_param != nullptr, 0); @@ -2144,11 +2145,11 @@ yyreduce: } (yyval.u.parameter) = simple_param; } -#line 2148 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 2149 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 85: -#line 651 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 651 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { DCSimpleParameter *simple_param = (yyvsp[-2].u.parameter)->as_simple_parameter(); nassertr(simple_param != nullptr, 0); @@ -2164,11 +2165,11 @@ yyreduce: } (yyval.u.parameter) = simple_param; } -#line 2168 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 2169 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 86: -#line 667 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 667 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { DCSimpleParameter *simple_param = (yyvsp[-2].u.parameter)->as_simple_parameter(); nassertr(simple_param != nullptr, 0); @@ -2180,11 +2181,11 @@ yyreduce: } (yyval.u.parameter) = simple_param; } -#line 2184 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 2185 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 88: -#line 683 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 683 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { if (dc_file == nullptr) { yyerror("Invalid type."); @@ -2216,11 +2217,11 @@ yyreduce: (yyval.u.parameter) = dtypedef->make_new_parameter(); } } -#line 2220 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 2221 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 89: -#line 715 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 715 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { // This is an inline struct definition. if ((yyvsp[0].u.dclass) == nullptr) { @@ -2236,11 +2237,11 @@ yyreduce: (yyval.u.parameter) = new DCClassParameter((yyvsp[0].u.dclass)); } } -#line 2240 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 2241 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 90: -#line 731 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 731 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { // This is an inline switch definition. if ((yyvsp[0].u.dswitch) == nullptr) { @@ -2256,41 +2257,41 @@ yyreduce: (yyval.u.parameter) = new DCSwitchParameter((yyvsp[0].u.dswitch)); } } -#line 2260 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 2261 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 91: -#line 750 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 750 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { double_range.clear(); } -#line 2268 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 2269 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 92: -#line 754 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 754 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { double_range.clear(); if (!double_range.add_range((yyvsp[0].u.real), (yyvsp[0].u.real))) { yyerror("Overlapping range"); } } -#line 2279 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 2280 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 93: -#line 761 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 761 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { double_range.clear(); if (!double_range.add_range((yyvsp[-2].u.real), (yyvsp[0].u.real))) { yyerror("Overlapping range"); } } -#line 2290 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 2291 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 94: -#line 768 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 768 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { double_range.clear(); if ((yyvsp[0].u.real) >= 0) { @@ -2299,31 +2300,31 @@ yyreduce: yyerror("Overlapping range"); } } -#line 2303 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 2304 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 95: -#line 777 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 777 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { if (!double_range.add_range((yyvsp[0].u.real), (yyvsp[0].u.real))) { yyerror("Overlapping range"); } } -#line 2313 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 2314 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 96: -#line 783 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 783 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { if (!double_range.add_range((yyvsp[-2].u.real), (yyvsp[0].u.real))) { yyerror("Overlapping range"); } } -#line 2323 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 2324 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 97: -#line 789 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 789 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { if ((yyvsp[0].u.real) >= 0) { yyerror("Syntax error"); @@ -2331,82 +2332,82 @@ yyreduce: yyerror("Overlapping range"); } } -#line 2335 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 2336 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 98: -#line 800 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 800 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { uint_range.clear(); } -#line 2343 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 2344 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 99: -#line 804 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 804 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { uint_range.clear(); if (!uint_range.add_range((yyvsp[0].u.s_uint), (yyvsp[0].u.s_uint))) { yyerror("Overlapping range"); } } -#line 2354 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 2355 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 100: -#line 811 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 811 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { uint_range.clear(); if (!uint_range.add_range((yyvsp[-2].u.s_uint), (yyvsp[0].u.s_uint))) { yyerror("Overlapping range"); } } -#line 2365 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 2366 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 101: -#line 818 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 818 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { uint_range.clear(); if (!uint_range.add_range((yyvsp[-1].u.s_uint), (yyvsp[0].u.s_uint))) { yyerror("Overlapping range"); } } -#line 2376 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 2377 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 102: -#line 825 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 825 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { if (!uint_range.add_range((yyvsp[0].u.s_uint), (yyvsp[0].u.s_uint))) { yyerror("Overlapping range"); } } -#line 2386 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 2387 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 103: -#line 831 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 831 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { if (!uint_range.add_range((yyvsp[-2].u.s_uint), (yyvsp[0].u.s_uint))) { yyerror("Overlapping range"); } } -#line 2396 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 2397 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 104: -#line 837 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 837 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { if (!uint_range.add_range((yyvsp[-1].u.s_uint), (yyvsp[0].u.s_uint))) { yyerror("Overlapping range"); } } -#line 2406 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 2407 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 106: -#line 847 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 847 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { if ((yyvsp[-3].u.parameter) == nullptr) { (yyval.u.parameter) = nullptr; @@ -2414,20 +2415,20 @@ yyreduce: (yyval.u.parameter) = (yyvsp[-3].u.parameter)->append_array_specification(uint_range); } } -#line 2418 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 2419 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 107: -#line 858 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 858 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { current_parameter->set_name((yyvsp[0].str)); (yyval.u.parameter) = current_parameter; } -#line 2427 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 2428 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 108: -#line 863 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 863 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { DCSimpleParameter *simple_param = (yyvsp[-2].u.parameter)->as_simple_parameter(); if (simple_param == nullptr || simple_param->get_typedef() != nullptr) { @@ -2442,11 +2443,11 @@ yyreduce: } } } -#line 2446 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 2447 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 109: -#line 878 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 878 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { DCSimpleParameter *simple_param = (yyvsp[-2].u.parameter)->as_simple_parameter(); if (simple_param == nullptr || simple_param->get_typedef() != nullptr) { @@ -2461,19 +2462,19 @@ yyreduce: } } } -#line 2465 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 2466 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 110: -#line 893 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 893 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { (yyval.u.parameter) = (yyvsp[-3].u.parameter)->append_array_specification(uint_range); } -#line 2473 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 2474 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 111: -#line 900 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 900 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { if ((yyvsp[0].str).length() != 1) { yyerror("Single character required."); @@ -2482,11 +2483,11 @@ yyreduce: (yyval.u.s_uint) = (unsigned char)(yyvsp[0].str)[0]; } } -#line 2486 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 2487 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 113: -#line 913 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 913 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { (yyval.u.s_uint) = (unsigned int)(yyvsp[0].u.uint64); if ((yyval.u.s_uint) != (yyvsp[0].u.uint64)) { @@ -2494,11 +2495,11 @@ yyreduce: (yyval.u.s_uint) = 1; } } -#line 2498 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 2499 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 114: -#line 924 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 924 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { (yyval.u.s_uint) = (unsigned int)-(yyvsp[0].u.int64); if ((yyvsp[0].u.int64) >= 0) { @@ -2509,27 +2510,27 @@ yyreduce: (yyval.u.s_uint) = 1; } } -#line 2513 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 2514 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 117: -#line 946 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 946 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { (yyval.u.real) = (double)(yyvsp[0].u.uint64); } -#line 2521 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 2522 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 118: -#line 950 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 950 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { (yyval.u.real) = (double)(yyvsp[0].u.int64); } -#line 2529 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 2530 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 120: -#line 958 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 958 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { if ((yyvsp[0].str).length() != 1) { yyerror("Single character required."); @@ -2538,18 +2539,18 @@ yyreduce: (yyval.u.real) = (double)(unsigned char)(yyvsp[0].str)[0]; } } -#line 2542 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 2543 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 122: -#line 972 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 972 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { } -#line 2549 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 2550 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 123: -#line 975 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 975 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { if ((yyvsp[-1].str) != current_packer->get_current_field_name()) { ostringstream strm; @@ -2558,348 +2559,348 @@ yyreduce: yyerror(strm.str()); } } -#line 2562 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 2563 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 124: -#line 984 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 984 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { } -#line 2569 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 2570 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 125: -#line 990 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 990 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { current_packer->pack_int64((yyvsp[0].u.int64)); } -#line 2577 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 2578 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 126: -#line 994 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 994 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { current_packer->pack_uint64((yyvsp[0].u.uint64)); } -#line 2585 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 2586 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 127: -#line 998 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 998 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { current_packer->pack_double((yyvsp[0].u.real)); } -#line 2593 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 2594 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 128: -#line 1002 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 1002 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { current_packer->pack_string((yyvsp[0].str)); } -#line 2601 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 2602 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 129: -#line 1006 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 1006 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { current_packer->pack_literal_value((yyvsp[0].bytes)); } -#line 2609 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 2610 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 130: -#line 1010 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 1010 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { current_packer->push(); } -#line 2617 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 2618 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 131: -#line 1014 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 1014 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { current_packer->pop(); } -#line 2625 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 2626 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 132: -#line 1018 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 1018 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { current_packer->push(); } -#line 2633 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 2634 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 133: -#line 1022 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 1022 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { current_packer->pop(); } -#line 2641 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 2642 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 134: -#line 1026 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 1026 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { current_packer->push(); } -#line 2649 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 2650 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 135: -#line 1030 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 1030 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { current_packer->pop(); } -#line 2657 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 2658 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 136: -#line 1034 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 1034 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { for (unsigned int i = 0; i < (yyvsp[0].u.s_uint); i++) { current_packer->pack_int64((yyvsp[-2].u.int64)); } } -#line 2667 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 2668 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 137: -#line 1040 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 1040 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { for (unsigned int i = 0; i < (yyvsp[0].u.s_uint); i++) { current_packer->pack_uint64((yyvsp[-2].u.uint64)); } } -#line 2677 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 2678 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 138: -#line 1046 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 1046 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { for (unsigned int i = 0; i < (yyvsp[0].u.s_uint); i++) { current_packer->pack_double((yyvsp[-2].u.real)); } } -#line 2687 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 2688 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 139: -#line 1052 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 1052 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { for (unsigned int i = 0; i < (yyvsp[0].u.s_uint); i++) { current_packer->pack_literal_value((yyvsp[-2].bytes)); } } -#line 2697 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 2698 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 146: -#line 1076 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 1076 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { (yyval.u.subatomic) = ST_int8; } -#line 2705 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 2706 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 147: -#line 1080 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 1080 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { (yyval.u.subatomic) = ST_int16; } -#line 2713 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 2714 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 148: -#line 1084 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 1084 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { (yyval.u.subatomic) = ST_int32; } -#line 2721 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 2722 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 149: -#line 1088 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 1088 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { (yyval.u.subatomic) = ST_int64; } -#line 2729 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 2730 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 150: -#line 1092 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 1092 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { (yyval.u.subatomic) = ST_uint8; } -#line 2737 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 2738 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 151: -#line 1096 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 1096 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { (yyval.u.subatomic) = ST_uint16; } -#line 2745 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 2746 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 152: -#line 1100 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 1100 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { (yyval.u.subatomic) = ST_uint32; } -#line 2753 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 2754 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 153: -#line 1104 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 1104 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { (yyval.u.subatomic) = ST_uint64; } -#line 2761 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 2762 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 154: -#line 1108 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 1108 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { (yyval.u.subatomic) = ST_float64; } -#line 2769 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 2770 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 155: -#line 1112 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 1112 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { (yyval.u.subatomic) = ST_string; } -#line 2777 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 2778 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 156: -#line 1116 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 1116 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { (yyval.u.subatomic) = ST_blob; } -#line 2785 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 2786 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 157: -#line 1120 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 1120 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { (yyval.u.subatomic) = ST_blob32; } -#line 2793 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 2794 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 158: -#line 1124 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 1124 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { (yyval.u.subatomic) = ST_int8array; } -#line 2801 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 2802 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 159: -#line 1128 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 1128 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { (yyval.u.subatomic) = ST_int16array; } -#line 2809 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 2810 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 160: -#line 1132 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 1132 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { (yyval.u.subatomic) = ST_int32array; } -#line 2817 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 2818 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 161: -#line 1136 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 1136 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { (yyval.u.subatomic) = ST_uint8array; } -#line 2825 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 2826 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 162: -#line 1140 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 1140 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { (yyval.u.subatomic) = ST_uint16array; } -#line 2833 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 2834 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 163: -#line 1144 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 1144 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { (yyval.u.subatomic) = ST_uint32array; } -#line 2841 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 2842 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 164: -#line 1148 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 1148 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { (yyval.u.subatomic) = ST_uint32uint8array; } -#line 2849 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 2850 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 165: -#line 1152 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 1152 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { (yyval.u.subatomic) = ST_char; } -#line 2857 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 2858 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 166: -#line 1159 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 1159 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { current_keyword_list.clear_keywords(); } -#line 2865 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 2866 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 167: -#line 1163 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 1163 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { current_keyword_list.add_keyword((yyvsp[0].u.keyword)); } -#line 2873 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 2874 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 168: -#line 1170 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 1170 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { if (current_keyword_list.get_num_keywords() != 0) { yyerror("Communication keywords are not allowed here."); } } -#line 2883 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 2884 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 169: -#line 1179 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 1179 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { current_molecular = new DCMolecularField((yyvsp[-1].str), current_class); } -#line 2891 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 2892 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 170: -#line 1183 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 1183 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { (yyval.u.field) = current_molecular; } -#line 2899 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 2900 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 171: -#line 1190 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 1190 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { DCField *field = current_class->get_field_by_name((yyvsp[0].str)); (yyval.u.atomic) = nullptr; @@ -2923,21 +2924,21 @@ yyreduce: } } } -#line 2927 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 2928 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 172: -#line 1217 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 1217 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { if ((yyvsp[0].u.atomic) != nullptr) { current_molecular->add_atomic((yyvsp[0].u.atomic)); } } -#line 2937 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 2938 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 173: -#line 1223 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 1223 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { if ((yyvsp[0].u.atomic) != nullptr) { current_molecular->add_atomic((yyvsp[0].u.atomic)); @@ -2948,36 +2949,36 @@ yyreduce: } } } -#line 2952 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 2953 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 174: -#line 1237 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 1237 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { (yyval.str) = ""; } -#line 2960 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 2961 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 176: -#line 1245 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 1245 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { current_switch = new DCSwitch((yyvsp[-4].str), (yyvsp[-2].u.field)); } -#line 2968 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 2969 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 177: -#line 1249 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 1249 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { (yyval.u.dswitch) = current_switch; current_switch = (DCSwitch *)(yyvsp[-2].u.parameter); } -#line 2977 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 2978 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 183: -#line 1263 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 1263 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { if (!current_switch->is_field_valid()) { yyerror("case declaration required before first element"); @@ -2987,21 +2988,21 @@ yyreduce: } } } -#line 2991 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 2992 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 184: -#line 1276 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 1276 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { current_packer = &default_packer; current_packer->clear_data(); current_packer->begin_pack(current_switch->get_key_parameter()); } -#line 3001 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 3002 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 185: -#line 1282 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 1282 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { if (!current_packer->end_pack()) { yyerror("Invalid value for switch parameter"); @@ -3013,45 +3014,45 @@ yyreduce: } } } -#line 3017 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 3018 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 186: -#line 1297 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 1297 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { if (!current_switch->add_default()) { yyerror("Default case already defined"); } } -#line 3027 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 3028 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 187: -#line 1306 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 1306 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { current_switch->add_break(); } -#line 3035 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 3036 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 188: -#line 1313 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 1313 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { (yyval.u.field) = (yyvsp[0].u.parameter); } -#line 3043 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 3044 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; case 189: -#line 1317 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1646 */ +#line 1317 "direct/src/dcparser/dcParser.yxx" /* yacc.c:1651 */ { (yyval.u.field) = (yyvsp[0].u.parameter); } -#line 3051 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 3052 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ break; -#line 3055 "built/tmp/dcParser.yxx.c" /* yacc.c:1646 */ +#line 3056 "built/tmp/dcParser.yxx.c" /* yacc.c:1651 */ default: break; } /* User semantic actions sometimes alter yychar, and that requires diff --git a/direct/src/dcparser/dcParser.h.prebuilt b/direct/src/dcparser/dcParser.h.prebuilt index 7b46c4c7b1..8880652bb0 100644 --- a/direct/src/dcparser/dcParser.h.prebuilt +++ b/direct/src/dcparser/dcParser.h.prebuilt @@ -1,8 +1,8 @@ -/* A Bison parser, made by GNU Bison 3.0.4. */ +/* A Bison parser, made by GNU Bison 3.1. */ /* Bison interface for Yacc-like parsers in C - Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc. + Copyright (C) 1984, 1989-1990, 2000-2015, 2018 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by From 5cafe8552b2cec6753fbef0cc576fde4972cac5d Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 19 Dec 2018 20:26:51 +0100 Subject: [PATCH 04/33] gobj: add F_rg, F_rg16, F_rg32, F_rgb32 to TexturePeeker --- panda/src/gobj/texturePeeker.cxx | 19 +++++++++++++++++++ panda/src/gobj/texturePeeker.h | 1 + 2 files changed, 20 insertions(+) diff --git a/panda/src/gobj/texturePeeker.cxx b/panda/src/gobj/texturePeeker.cxx index 7bb17ab87a..ece87f36a5 100644 --- a/panda/src/gobj/texturePeeker.cxx +++ b/panda/src/gobj/texturePeeker.cxx @@ -140,6 +140,12 @@ TexturePeeker(Texture *tex, Texture::CData *cdata) { _get_texel = get_texel_la; break; + case Texture::F_rg16: + case Texture::F_rg32: + case Texture::F_rg: + _get_texel = get_texel_rg; + break; + case Texture::F_rgb: case Texture::F_rgb5: case Texture::F_rgb8: @@ -148,6 +154,7 @@ TexturePeeker(Texture *tex, Texture::CData *cdata) { case Texture::F_rgb332: case Texture::F_r11_g11_b10: case Texture::F_rgb9_e5: + case Texture::F_rgb32: _get_texel = get_texel_rgb; break; @@ -582,6 +589,18 @@ get_texel_la(LColor &color, const unsigned char *&p, GetComponentFunc *get_compo color[3] = (*get_component)(p); } +/** + * Gets the color of the texel at byte p, given that the texture is in format + * F_rg or similar. + */ +void TexturePeeker:: +get_texel_rg(LColor &color, const unsigned char *&p, GetComponentFunc *get_component) { + color[0] = (*get_component)(p); + color[1] = (*get_component)(p); + color[2] = 0.0f; + color[3] = 1.0f; +} + /** * Gets the color of the texel at byte p, given that the texture is in format * F_rgb or similar. diff --git a/panda/src/gobj/texturePeeker.h b/panda/src/gobj/texturePeeker.h index ffe3aba2b1..e88603bcea 100644 --- a/panda/src/gobj/texturePeeker.h +++ b/panda/src/gobj/texturePeeker.h @@ -77,6 +77,7 @@ private: static void get_texel_a(LColor &color, const unsigned char *&p, GetComponentFunc *get_component); static void get_texel_l(LColor &color, const unsigned char *&p, GetComponentFunc *get_component); static void get_texel_la(LColor &color, const unsigned char *&p, GetComponentFunc *get_component); + static void get_texel_rg(LColor &color, const unsigned char *&p, GetComponentFunc *get_component); static void get_texel_rgb(LColor &color, const unsigned char *&p, GetComponentFunc *get_component); static void get_texel_rgba(LColor &color, const unsigned char *&p, GetComponentFunc *get_component); static void get_texel_srgb(LColor &color, const unsigned char *&p, GetComponentFunc *get_component); From ebef9f3de8d2eb1c3628a25fe3bd08aa59c8804d Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 19 Dec 2018 20:45:57 +0100 Subject: [PATCH 05/33] pgraph: add assertions to prevent invalid TransformState If this commit is causing crashes in your code, it is probably exposing a bug in some other system that is assigning bad TransformState objects. --- panda/src/pgraph/pandaNode.cxx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/panda/src/pgraph/pandaNode.cxx b/panda/src/pgraph/pandaNode.cxx index 7d53cbcaf7..1e3d427e28 100644 --- a/panda/src/pgraph/pandaNode.cxx +++ b/panda/src/pgraph/pandaNode.cxx @@ -1084,6 +1084,8 @@ set_effects(const RenderEffects *effects, Thread *current_thread) { */ void PandaNode:: set_transform(const TransformState *transform, Thread *current_thread) { + nassertv(!transform->is_invalid()); + // Need to have this held before we grab any other locks. LightMutexHolder holder(_dirty_prev_transforms._lock); @@ -1120,6 +1122,8 @@ set_transform(const TransformState *transform, Thread *current_thread) { */ void PandaNode:: set_prev_transform(const TransformState *transform, Thread *current_thread) { + nassertv(!transform->is_invalid()); + // Need to have this held before we grab any other locks. LightMutexHolder holder(_dirty_prev_transforms._lock); @@ -3849,6 +3853,9 @@ complete_pointers(TypedWritable **p_list, BamReader *manager) { // Mark the bounds stale. ++_next_update; + nassertr(!_transform->is_invalid(), pi); + nassertr(!_prev_transform->is_invalid(), pi); + return pi; } From daa3100bf194592fb8ac865dd1ab8015f4399651 Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 19 Dec 2018 20:47:57 +0100 Subject: [PATCH 06/33] pgraph: mark TransformState as invalid in destructor This, in combination with ebef9f3de8d2eb1c3628a25fe3bd08aa59c8804d, makes it easier to catch issues in code that is accidentally letting get temporary TransformState objects get destroyed. It does not affect release builds. --- panda/src/pgraph/transformState.cxx | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/panda/src/pgraph/transformState.cxx b/panda/src/pgraph/transformState.cxx index 4d02425683..fc8b3de606 100644 --- a/panda/src/pgraph/transformState.cxx +++ b/panda/src/pgraph/transformState.cxx @@ -96,6 +96,10 @@ TransformState:: // true now, probably we've been double-deleted. nassertv(get_ref_count() == 0); _cache_stats.add_num_states(-1); + +#ifndef NDEBUG + _flags = F_is_invalid | F_is_destructing; +#endif } /** From cbda6166a8b6b4222ec37cb61f531e444b7f31e8 Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 19 Dec 2018 20:53:11 +0100 Subject: [PATCH 07/33] tform: fix MouseWatcherRegion area calculation Fixes #233 --- panda/src/tform/mouseWatcherRegion.I | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/panda/src/tform/mouseWatcherRegion.I b/panda/src/tform/mouseWatcherRegion.I index 50dfada487..91ccbc7063 100644 --- a/panda/src/tform/mouseWatcherRegion.I +++ b/panda/src/tform/mouseWatcherRegion.I @@ -17,11 +17,11 @@ INLINE MouseWatcherRegion:: MouseWatcherRegion(const std::string &name, PN_stdfloat left, PN_stdfloat right, PN_stdfloat bottom, PN_stdfloat top) : - Namable(name), - _frame(left, right, bottom, top) + Namable(name) { _sort = 0; _flags = F_active; + set_frame(left, right, bottom, top); } /** From 837d3d6b6dbbb1a168d9813561be60a729401e02 Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 19 Dec 2018 20:54:48 +0100 Subject: [PATCH 08/33] tform: add properties to MouseWatcherRegion --- panda/src/tform/mouseWatcherRegion.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/panda/src/tform/mouseWatcherRegion.h b/panda/src/tform/mouseWatcherRegion.h index a49cfcbc6e..c3e668bf34 100644 --- a/panda/src/tform/mouseWatcherRegion.h +++ b/panda/src/tform/mouseWatcherRegion.h @@ -61,6 +61,15 @@ PUBLISHED: void output(std::ostream &out) const; void write(std::ostream &out, int indent_level = 0) const; +PUBLISHED: + MAKE_PROPERTY(frame, get_frame, set_frame); + MAKE_PROPERTY(area, get_area); + + MAKE_PROPERTY(sort, get_sort, set_sort); + MAKE_PROPERTY(active, get_active, set_active); + MAKE_PROPERTY(keyboard, get_keyboard, set_keyboard); + MAKE_PROPERTY(suppress_flags, get_suppress_flags, set_suppress_flags); + public: INLINE bool operator < (const MouseWatcherRegion &other) const; From 9035b4a6105fe383ab7091104f7a238c4594b70b Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 19 Dec 2018 20:56:42 +0100 Subject: [PATCH 09/33] pgraph: don't bother calling xform() on empty BoundingVolume --- panda/src/pgraph/pandaNode.cxx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/panda/src/pgraph/pandaNode.cxx b/panda/src/pgraph/pandaNode.cxx index 1e3d427e28..25a65e19ae 100644 --- a/panda/src/pgraph/pandaNode.cxx +++ b/panda/src/pgraph/pandaNode.cxx @@ -3514,12 +3514,12 @@ update_cached(bool update_bounds, int pipeline_stage, PandaNode::CDLockedStageRe const BoundingVolume **child_begin = &child_volumes[0]; const BoundingVolume **child_end = child_begin + child_volumes_i; ((BoundingVolume *)gbv)->around(child_begin, child_end); - } - // If we have a transform, apply it to the bounding volume we just - // computed. - if (!transform->is_identity()) { - gbv->xform(transform->get_mat()); + // If we have a transform, apply it to the bounding volume we just + // computed. + if (!transform->is_identity()) { + gbv->xform(transform->get_mat()); + } } cdataw->_external_bounds = gbv; From 0668509791116a11df78b540674c8e6695586a13 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 23 Dec 2018 15:07:02 +0100 Subject: [PATCH 10/33] stdpy: remove commented-out method that is confusing Doxygen --- direct/src/stdpy/thread.py | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/direct/src/stdpy/thread.py b/direct/src/stdpy/thread.py index c10675dd4c..29844b32e2 100644 --- a/direct/src/stdpy/thread.py +++ b/direct/src/stdpy/thread.py @@ -277,13 +277,6 @@ class _local(object): d = _get_thread_locals(core.Thread.getCurrentThread(), id(self)) d[key] = value -## def __getattr__(self, key): -## d = _get_thread_locals(core.Thread.getCurrentThread(), id(self)) -## try: -## return d[key] -## except KeyError: -## raise AttributeError - def __getattribute__(self, key): d = _get_thread_locals(core.Thread.getCurrentThread(), id(self)) if key == '__dict__': @@ -292,6 +285,3 @@ class _local(object): return d[key] except KeyError: return object.__getattribute__(self, key) - - - From a0a2bf59bb61f1de2d1ba6eb1dc95a34341df0d0 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 23 Dec 2018 15:42:43 +0100 Subject: [PATCH 11/33] actor: remove commented-out code that is confusing doxygen --- direct/src/actor/Actor.py | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/direct/src/actor/Actor.py b/direct/src/actor/Actor.py index b9ba299aaa..b7d48f2d87 100644 --- a/direct/src/actor/Actor.py +++ b/direct/src/actor/Actor.py @@ -653,15 +653,11 @@ class Actor(DirectObject, NodePath): """ # make sure we don't call this twice in a row # and pollute the the switches dictionary -## sortedKeys = list(self.switches.keys()) -## sortedKeys.sort() child = self.__LODNode.find(str(lodName)) index = self.__LODNode.node().findChild(child.node()) self.__LODNode.node().forceSwitch(index) def printLOD(self): -## sortedKeys = list(self.switches.keys()) -## sortedKeys.sort() sortedKeys = self.__sortedLODNames for eachLod in sortedKeys: print("python switches for %s: in: %d, out %d" % (eachLod, @@ -679,12 +675,6 @@ class Actor(DirectObject, NodePath): """ Restore all switch distance info (usually after a useLOD call)""" self.__LODNode.node().clearForceSwitch() -## sortedKeys = list(self.switches.keys()) -## sortedKeys.sort() -## for eachLod in sortedKeys: -## index = sortedKeys.index(eachLod) -## self.__LODNode.node().setSwitch(index, self.switches[eachLod][0], -## self.switches[eachLod][1]) def addLOD(self, lodName, inDist=0, outDist=0, center=None): """addLOD(self, string) @@ -706,8 +696,6 @@ class Actor(DirectObject, NodePath): # save the switch distance info self.switches[lodName] = [inDist, outDist] # add the switch distance info -## sortedKeys = list(self.switches.keys()) -## sortedKeys.sort() self.__LODNode.node().setSwitch(self.getLODIndex(lodName), inDist, outDist) def getLODIndex(self, lodName): From 6df8aede1fc70317171da2f08027a96a51ae37c6 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 23 Dec 2018 15:44:01 +0100 Subject: [PATCH 12/33] interrogatedb: add interrogate_element_is_sequence/mapping --- dtool/src/interrogatedb/interrogate_interface.cxx | 12 ++++++++++++ dtool/src/interrogatedb/interrogate_interface.h | 3 +++ 2 files changed, 15 insertions(+) diff --git a/dtool/src/interrogatedb/interrogate_interface.cxx b/dtool/src/interrogatedb/interrogate_interface.cxx index 2cd08d4adf..3fc2053855 100644 --- a/dtool/src/interrogatedb/interrogate_interface.cxx +++ b/dtool/src/interrogatedb/interrogate_interface.cxx @@ -176,6 +176,18 @@ interrogate_element_setter(ElementIndex element) { return InterrogateDatabase::get_ptr()->get_element(element).get_setter(); } +bool +interrogate_element_is_sequence(ElementIndex element) { + // cerr << "interrogate_element_is_sequence(" << element << ")\n"; + return InterrogateDatabase::get_ptr()->get_element(element).is_sequence(); +} + +bool +interrogate_element_is_mapping(ElementIndex element) { + // cerr << "interrogate_element_is_mapping(" << element << ")\n"; + return InterrogateDatabase::get_ptr()->get_element(element).is_mapping(); +} + int interrogate_number_of_globals() { // cerr << "interrogate_number_of_globals()\n"; diff --git a/dtool/src/interrogatedb/interrogate_interface.h b/dtool/src/interrogatedb/interrogate_interface.h index 6c434d7833..cc88af041d 100644 --- a/dtool/src/interrogatedb/interrogate_interface.h +++ b/dtool/src/interrogatedb/interrogate_interface.h @@ -153,6 +153,9 @@ EXPCL_INTERROGATEDB FunctionIndex interrogate_element_getter(ElementIndex elemen EXPCL_INTERROGATEDB bool interrogate_element_has_setter(ElementIndex element); EXPCL_INTERROGATEDB FunctionIndex interrogate_element_setter(ElementIndex element); +EXPCL_INTERROGATEDB bool interrogate_element_is_sequence(ElementIndex element); +EXPCL_INTERROGATEDB bool interrogate_element_is_mapping(ElementIndex element); + // Global Data // This is the list of global data elements. From 256c8c5a23a20331d8c88a4e5074c13716792153 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 23 Dec 2018 15:44:59 +0100 Subject: [PATCH 13/33] interrogate: don't add space at end of command-line comment --- dtool/src/interrogate/interrogate.cxx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/dtool/src/interrogate/interrogate.cxx b/dtool/src/interrogate/interrogate.cxx index ef06833324..e3cab85a6b 100644 --- a/dtool/src/interrogate/interrogate.cxx +++ b/dtool/src/interrogate/interrogate.cxx @@ -312,7 +312,10 @@ main(int argc, char **argv) { string command_line; int i; for (i = 0; i < argc; i++) { - command_line += string(argv[i]) + " "; + if (i > 0) { + command_line += ' '; + } + command_line += string(argv[i]); } Filename fn; From 47188b47f6b71530ed351c57653cfe47d8cf0e3d Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 23 Dec 2018 15:45:30 +0100 Subject: [PATCH 14/33] interrogate: fix recording type of property in interrogatedb --- dtool/src/interrogate/interrogateBuilder.cxx | 1 + 1 file changed, 1 insertion(+) diff --git a/dtool/src/interrogate/interrogateBuilder.cxx b/dtool/src/interrogate/interrogateBuilder.cxx index b740d59e1a..da0e2a5318 100644 --- a/dtool/src/interrogate/interrogateBuilder.cxx +++ b/dtool/src/interrogate/interrogateBuilder.cxx @@ -2024,6 +2024,7 @@ get_make_property(CPPMakeProperty *make_property, CPPStructType *struct_type, CP if (iproperty._type != 0 && iproperty._type != return_index) { cerr << "Property " << property_name << " has inconsistent element type!\n"; } + iproperty._type = return_index; } else { iproperty._type = 0; } From a24c8171447003996361fd74c2119890cc84b021 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 23 Dec 2018 15:46:09 +0100 Subject: [PATCH 15/33] interrogatedb: regenerate Python bindings --- dtool/metalibs/dtoolconfig/pydtool.cxx | 584 +++++++++++++------------ 1 file changed, 308 insertions(+), 276 deletions(-) diff --git a/dtool/metalibs/dtoolconfig/pydtool.cxx b/dtool/metalibs/dtoolconfig/pydtool.cxx index 7f2e0185f6..39719b385d 100644 --- a/dtool/metalibs/dtoolconfig/pydtool.cxx +++ b/dtool/metalibs/dtoolconfig/pydtool.cxx @@ -17,7 +17,7 @@ #if PYTHON_FRAMEWORK #include #else - #include + #include "Python.h" #endif static PyObject *_inP07yttbRf(PyObject *self, PyObject *args); @@ -45,6 +45,8 @@ static PyObject *_inP07ytDId0(PyObject *self, PyObject *args); static PyObject *_inP07ytHuAm(PyObject *self, PyObject *args); static PyObject *_inP07yt_xr0(PyObject *self, PyObject *args); static PyObject *_inP07ytH5qp(PyObject *self, PyObject *args); +static PyObject *_inP07ytq45U(PyObject *self, PyObject *args); +static PyObject *_inP07yt6IPa(PyObject *self, PyObject *args); static PyObject *_inP07ytU2_B(PyObject *self, PyObject *args); static PyObject *_inP07ytHFO2(PyObject *self, PyObject *args); static PyObject *_inP07ytcfjm(PyObject *self, PyObject *args); @@ -166,10 +168,10 @@ static PyObject * _inP07yttbRf(PyObject *, PyObject *args) { char *param0; if (PyArg_ParseTuple(args, "s", ¶m0)) { - interrogate_add_search_directory((char const *)param0); + ::interrogate_add_search_directory((char const *)param0); return Py_BuildValue(""); } - return (PyObject *)NULL; + return nullptr; } /* @@ -180,10 +182,10 @@ static PyObject * _inP07ytda_g(PyObject *, PyObject *args) { char *param0; if (PyArg_ParseTuple(args, "s", ¶m0)) { - interrogate_add_search_path((char const *)param0); + ::interrogate_add_search_path((char const *)param0); return Py_BuildValue(""); } - return (PyObject *)NULL; + return nullptr; } /* @@ -193,10 +195,10 @@ _inP07ytda_g(PyObject *, PyObject *args) { static PyObject * _inP07yt4RgX(PyObject *, PyObject *args) { if (PyArg_ParseTuple(args, "")) { - bool return_value = interrogate_error_flag(); + bool return_value = ::interrogate_error_flag(); return PyBool_FromLong(return_value); } - return (PyObject *)NULL; + return nullptr; } /* @@ -206,14 +208,14 @@ _inP07yt4RgX(PyObject *, PyObject *args) { static PyObject * _inP07yt3Gip(PyObject *, PyObject *args) { if (PyArg_ParseTuple(args, "")) { - int return_value = interrogate_number_of_manifests(); + int return_value = ::interrogate_number_of_manifests(); #if PY_MAJOR_VERSION >= 3 return PyLong_FromLong(return_value); #else return PyInt_FromLong(return_value); #endif } - return (PyObject *)NULL; + return nullptr; } /* @@ -224,14 +226,14 @@ static PyObject * _inP07ytRKDz(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - ManifestIndex return_value = interrogate_get_manifest((int)param0); + ManifestIndex return_value = ::interrogate_get_manifest((int)param0); #if PY_MAJOR_VERSION >= 3 return PyLong_FromLong(return_value); #else return PyInt_FromLong(return_value); #endif } - return (PyObject *)NULL; + return nullptr; } /* @@ -242,14 +244,14 @@ static PyObject * _inP07ytgZ9N(PyObject *, PyObject *args) { char *param0; if (PyArg_ParseTuple(args, "s", ¶m0)) { - ManifestIndex return_value = interrogate_get_manifest_by_name((char const *)param0); + ManifestIndex return_value = ::interrogate_get_manifest_by_name((char const *)param0); #if PY_MAJOR_VERSION >= 3 return PyLong_FromLong(return_value); #else return PyInt_FromLong(return_value); #endif } - return (PyObject *)NULL; + return nullptr; } /* @@ -260,14 +262,14 @@ static PyObject * _inP07ytFnRZ(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - char const *return_value = interrogate_manifest_name((ManifestIndex)param0); + char const *return_value = ::interrogate_manifest_name((ManifestIndex)param0); #if PY_MAJOR_VERSION >= 3 return PyUnicode_FromString(return_value); #else return PyString_FromString(return_value); #endif } - return (PyObject *)NULL; + return nullptr; } /* @@ -278,14 +280,14 @@ static PyObject * _inP07ytg0Qv(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - char const *return_value = interrogate_manifest_definition((ManifestIndex)param0); + char const *return_value = ::interrogate_manifest_definition((ManifestIndex)param0); #if PY_MAJOR_VERSION >= 3 return PyUnicode_FromString(return_value); #else return PyString_FromString(return_value); #endif } - return (PyObject *)NULL; + return nullptr; } /* @@ -296,10 +298,10 @@ static PyObject * _inP07yttrqw(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - bool return_value = interrogate_manifest_has_type((ManifestIndex)param0); + bool return_value = ::interrogate_manifest_has_type((ManifestIndex)param0); return PyBool_FromLong(return_value); } - return (PyObject *)NULL; + return nullptr; } /* @@ -310,14 +312,14 @@ static PyObject * _inP07ytdmpW(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - TypeIndex return_value = interrogate_manifest_get_type((ManifestIndex)param0); + TypeIndex return_value = ::interrogate_manifest_get_type((ManifestIndex)param0); #if PY_MAJOR_VERSION >= 3 return PyLong_FromLong(return_value); #else return PyInt_FromLong(return_value); #endif } - return (PyObject *)NULL; + return nullptr; } /* @@ -328,10 +330,10 @@ static PyObject * _inP07ytUYgQ(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - bool return_value = interrogate_manifest_has_getter((ManifestIndex)param0); + bool return_value = ::interrogate_manifest_has_getter((ManifestIndex)param0); return PyBool_FromLong(return_value); } - return (PyObject *)NULL; + return nullptr; } /* @@ -342,14 +344,14 @@ static PyObject * _inP07yt0k7F(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - FunctionIndex return_value = interrogate_manifest_getter((ManifestIndex)param0); + FunctionIndex return_value = ::interrogate_manifest_getter((ManifestIndex)param0); #if PY_MAJOR_VERSION >= 3 return PyLong_FromLong(return_value); #else return PyInt_FromLong(return_value); #endif } - return (PyObject *)NULL; + return nullptr; } /* @@ -360,10 +362,10 @@ static PyObject * _inP07ytfIsr(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - bool return_value = interrogate_manifest_has_int_value((ManifestIndex)param0); + bool return_value = ::interrogate_manifest_has_int_value((ManifestIndex)param0); return PyBool_FromLong(return_value); } - return (PyObject *)NULL; + return nullptr; } /* @@ -374,14 +376,14 @@ static PyObject * _inP07ytvysR(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - int return_value = interrogate_manifest_get_int_value((ManifestIndex)param0); + int return_value = ::interrogate_manifest_get_int_value((ManifestIndex)param0); #if PY_MAJOR_VERSION >= 3 return PyLong_FromLong(return_value); #else return PyInt_FromLong(return_value); #endif } - return (PyObject *)NULL; + return nullptr; } /* @@ -392,14 +394,14 @@ static PyObject * _inP07ytYQ_2(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - char const *return_value = interrogate_element_name((ElementIndex)param0); + char const *return_value = ::interrogate_element_name((ElementIndex)param0); #if PY_MAJOR_VERSION >= 3 return PyUnicode_FromString(return_value); #else return PyString_FromString(return_value); #endif } - return (PyObject *)NULL; + return nullptr; } /* @@ -410,14 +412,14 @@ static PyObject * _inP07yt3kdv(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - char const *return_value = interrogate_element_scoped_name((ElementIndex)param0); + char const *return_value = ::interrogate_element_scoped_name((ElementIndex)param0); #if PY_MAJOR_VERSION >= 3 return PyUnicode_FromString(return_value); #else return PyString_FromString(return_value); #endif } - return (PyObject *)NULL; + return nullptr; } /* @@ -428,10 +430,10 @@ static PyObject * _inP07ytew01(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - bool return_value = interrogate_element_has_comment((ElementIndex)param0); + bool return_value = ::interrogate_element_has_comment((ElementIndex)param0); return PyBool_FromLong(return_value); } - return (PyObject *)NULL; + return nullptr; } /* @@ -442,14 +444,14 @@ static PyObject * _inP07ytQna7(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - char const *return_value = interrogate_element_comment((ElementIndex)param0); + char const *return_value = ::interrogate_element_comment((ElementIndex)param0); #if PY_MAJOR_VERSION >= 3 return PyUnicode_FromString(return_value); #else return PyString_FromString(return_value); #endif } - return (PyObject *)NULL; + return nullptr; } /* @@ -460,14 +462,14 @@ static PyObject * _inP07ytkg95(PyObject *, PyObject *args) { char *param0; if (PyArg_ParseTuple(args, "s", ¶m0)) { - ElementIndex return_value = interrogate_get_element_by_name((char const *)param0); + ElementIndex return_value = ::interrogate_get_element_by_name((char const *)param0); #if PY_MAJOR_VERSION >= 3 return PyLong_FromLong(return_value); #else return PyInt_FromLong(return_value); #endif } - return (PyObject *)NULL; + return nullptr; } /* @@ -478,14 +480,14 @@ static PyObject * _inP07ytluRc(PyObject *, PyObject *args) { char *param0; if (PyArg_ParseTuple(args, "s", ¶m0)) { - ElementIndex return_value = interrogate_get_element_by_scoped_name((char const *)param0); + ElementIndex return_value = ::interrogate_get_element_by_scoped_name((char const *)param0); #if PY_MAJOR_VERSION >= 3 return PyLong_FromLong(return_value); #else return PyInt_FromLong(return_value); #endif } - return (PyObject *)NULL; + return nullptr; } /* @@ -496,14 +498,14 @@ static PyObject * _inP07yttHdM(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - TypeIndex return_value = interrogate_element_type((ElementIndex)param0); + TypeIndex return_value = ::interrogate_element_type((ElementIndex)param0); #if PY_MAJOR_VERSION >= 3 return PyLong_FromLong(return_value); #else return PyInt_FromLong(return_value); #endif } - return (PyObject *)NULL; + return nullptr; } /* @@ -514,10 +516,10 @@ static PyObject * _inP07ytDId0(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - bool return_value = interrogate_element_has_getter((ElementIndex)param0); + bool return_value = ::interrogate_element_has_getter((ElementIndex)param0); return PyBool_FromLong(return_value); } - return (PyObject *)NULL; + return nullptr; } /* @@ -528,14 +530,14 @@ static PyObject * _inP07ytHuAm(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - FunctionIndex return_value = interrogate_element_getter((ElementIndex)param0); + FunctionIndex return_value = ::interrogate_element_getter((ElementIndex)param0); #if PY_MAJOR_VERSION >= 3 return PyLong_FromLong(return_value); #else return PyInt_FromLong(return_value); #endif } - return (PyObject *)NULL; + return nullptr; } /* @@ -546,10 +548,10 @@ static PyObject * _inP07yt_xr0(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - bool return_value = interrogate_element_has_setter((ElementIndex)param0); + bool return_value = ::interrogate_element_has_setter((ElementIndex)param0); return PyBool_FromLong(return_value); } - return (PyObject *)NULL; + return nullptr; } /* @@ -560,14 +562,42 @@ static PyObject * _inP07ytH5qp(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - FunctionIndex return_value = interrogate_element_setter((ElementIndex)param0); + FunctionIndex return_value = ::interrogate_element_setter((ElementIndex)param0); #if PY_MAJOR_VERSION >= 3 return PyLong_FromLong(return_value); #else return PyInt_FromLong(return_value); #endif } - return (PyObject *)NULL; + return nullptr; +} + +/* + * Python simple wrapper for + * bool interrogate_element_is_sequence(ElementIndex element) + */ +static PyObject * +_inP07ytq45U(PyObject *, PyObject *args) { + int param0; + if (PyArg_ParseTuple(args, "i", ¶m0)) { + bool return_value = ::interrogate_element_is_sequence((ElementIndex)param0); + return PyBool_FromLong(return_value); + } + return nullptr; +} + +/* + * Python simple wrapper for + * bool interrogate_element_is_mapping(ElementIndex element) + */ +static PyObject * +_inP07yt6IPa(PyObject *, PyObject *args) { + int param0; + if (PyArg_ParseTuple(args, "i", ¶m0)) { + bool return_value = ::interrogate_element_is_mapping((ElementIndex)param0); + return PyBool_FromLong(return_value); + } + return nullptr; } /* @@ -577,14 +607,14 @@ _inP07ytH5qp(PyObject *, PyObject *args) { static PyObject * _inP07ytU2_B(PyObject *, PyObject *args) { if (PyArg_ParseTuple(args, "")) { - int return_value = interrogate_number_of_globals(); + int return_value = ::interrogate_number_of_globals(); #if PY_MAJOR_VERSION >= 3 return PyLong_FromLong(return_value); #else return PyInt_FromLong(return_value); #endif } - return (PyObject *)NULL; + return nullptr; } /* @@ -595,14 +625,14 @@ static PyObject * _inP07ytHFO2(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - ElementIndex return_value = interrogate_get_global((int)param0); + ElementIndex return_value = ::interrogate_get_global((int)param0); #if PY_MAJOR_VERSION >= 3 return PyLong_FromLong(return_value); #else return PyInt_FromLong(return_value); #endif } - return (PyObject *)NULL; + return nullptr; } /* @@ -612,14 +642,14 @@ _inP07ytHFO2(PyObject *, PyObject *args) { static PyObject * _inP07ytcfjm(PyObject *, PyObject *args) { if (PyArg_ParseTuple(args, "")) { - int return_value = interrogate_number_of_global_functions(); + int return_value = ::interrogate_number_of_global_functions(); #if PY_MAJOR_VERSION >= 3 return PyLong_FromLong(return_value); #else return PyInt_FromLong(return_value); #endif } - return (PyObject *)NULL; + return nullptr; } /* @@ -630,14 +660,14 @@ static PyObject * _inP07yt3Sjw(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - FunctionIndex return_value = interrogate_get_global_function((int)param0); + FunctionIndex return_value = ::interrogate_get_global_function((int)param0); #if PY_MAJOR_VERSION >= 3 return PyLong_FromLong(return_value); #else return PyInt_FromLong(return_value); #endif } - return (PyObject *)NULL; + return nullptr; } /* @@ -647,14 +677,14 @@ _inP07yt3Sjw(PyObject *, PyObject *args) { static PyObject * _inP07ytgJcX(PyObject *, PyObject *args) { if (PyArg_ParseTuple(args, "")) { - int return_value = interrogate_number_of_functions(); + int return_value = ::interrogate_number_of_functions(); #if PY_MAJOR_VERSION >= 3 return PyLong_FromLong(return_value); #else return PyInt_FromLong(return_value); #endif } - return (PyObject *)NULL; + return nullptr; } /* @@ -665,14 +695,14 @@ static PyObject * _inP07ytYlw6(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - FunctionIndex return_value = interrogate_get_function((int)param0); + FunctionIndex return_value = ::interrogate_get_function((int)param0); #if PY_MAJOR_VERSION >= 3 return PyLong_FromLong(return_value); #else return PyInt_FromLong(return_value); #endif } - return (PyObject *)NULL; + return nullptr; } /* @@ -683,14 +713,14 @@ static PyObject * _inP07ytsmnz(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - char const *return_value = interrogate_function_name((FunctionIndex)param0); + char const *return_value = ::interrogate_function_name((FunctionIndex)param0); #if PY_MAJOR_VERSION >= 3 return PyUnicode_FromString(return_value); #else return PyString_FromString(return_value); #endif } - return (PyObject *)NULL; + return nullptr; } /* @@ -701,14 +731,14 @@ static PyObject * _inP07ytxQ10(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - char const *return_value = interrogate_function_scoped_name((FunctionIndex)param0); + char const *return_value = ::interrogate_function_scoped_name((FunctionIndex)param0); #if PY_MAJOR_VERSION >= 3 return PyUnicode_FromString(return_value); #else return PyString_FromString(return_value); #endif } - return (PyObject *)NULL; + return nullptr; } /* @@ -719,10 +749,10 @@ static PyObject * _inP07yt6gPB(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - bool return_value = interrogate_function_has_comment((FunctionIndex)param0); + bool return_value = ::interrogate_function_has_comment((FunctionIndex)param0); return PyBool_FromLong(return_value); } - return (PyObject *)NULL; + return nullptr; } /* @@ -733,14 +763,14 @@ static PyObject * _inP07ytISgV(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - char const *return_value = interrogate_function_comment((FunctionIndex)param0); + char const *return_value = ::interrogate_function_comment((FunctionIndex)param0); #if PY_MAJOR_VERSION >= 3 return PyUnicode_FromString(return_value); #else return PyString_FromString(return_value); #endif } - return (PyObject *)NULL; + return nullptr; } /* @@ -751,14 +781,14 @@ static PyObject * _inP07ytH3bx(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - char const *return_value = interrogate_function_prototype((FunctionIndex)param0); + char const *return_value = ::interrogate_function_prototype((FunctionIndex)param0); #if PY_MAJOR_VERSION >= 3 return PyUnicode_FromString(return_value); #else return PyString_FromString(return_value); #endif } - return (PyObject *)NULL; + return nullptr; } /* @@ -769,10 +799,10 @@ static PyObject * _inP07ytzeUk(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - bool return_value = interrogate_function_is_method((FunctionIndex)param0); + bool return_value = ::interrogate_function_is_method((FunctionIndex)param0); return PyBool_FromLong(return_value); } - return (PyObject *)NULL; + return nullptr; } /* @@ -783,14 +813,14 @@ static PyObject * _inP07ytUeI5(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - TypeIndex return_value = interrogate_function_class((FunctionIndex)param0); + TypeIndex return_value = ::interrogate_function_class((FunctionIndex)param0); #if PY_MAJOR_VERSION >= 3 return PyLong_FromLong(return_value); #else return PyInt_FromLong(return_value); #endif } - return (PyObject *)NULL; + return nullptr; } /* @@ -801,10 +831,10 @@ static PyObject * _inP07ytuSvx(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - bool return_value = interrogate_function_has_module_name((FunctionIndex)param0); + bool return_value = ::interrogate_function_has_module_name((FunctionIndex)param0); return PyBool_FromLong(return_value); } - return (PyObject *)NULL; + return nullptr; } /* @@ -815,14 +845,14 @@ static PyObject * _inP07ytwpYd(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - char const *return_value = interrogate_function_module_name((FunctionIndex)param0); + char const *return_value = ::interrogate_function_module_name((FunctionIndex)param0); #if PY_MAJOR_VERSION >= 3 return PyUnicode_FromString(return_value); #else return PyString_FromString(return_value); #endif } - return (PyObject *)NULL; + return nullptr; } /* @@ -833,10 +863,10 @@ static PyObject * _inP07ytOfNh(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - bool return_value = interrogate_function_has_library_name((FunctionIndex)param0); + bool return_value = ::interrogate_function_has_library_name((FunctionIndex)param0); return PyBool_FromLong(return_value); } - return (PyObject *)NULL; + return nullptr; } /* @@ -847,14 +877,14 @@ static PyObject * _inP07ytf5_U(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - char const *return_value = interrogate_function_library_name((FunctionIndex)param0); + char const *return_value = ::interrogate_function_library_name((FunctionIndex)param0); #if PY_MAJOR_VERSION >= 3 return PyUnicode_FromString(return_value); #else return PyString_FromString(return_value); #endif } - return (PyObject *)NULL; + return nullptr; } /* @@ -865,10 +895,10 @@ static PyObject * _inP07ytL3ZB(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - bool return_value = interrogate_function_is_virtual((FunctionIndex)param0); + bool return_value = ::interrogate_function_is_virtual((FunctionIndex)param0); return PyBool_FromLong(return_value); } - return (PyObject *)NULL; + return nullptr; } /* @@ -879,14 +909,14 @@ static PyObject * _inP07ytXw0I(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - int return_value = interrogate_function_number_of_c_wrappers((FunctionIndex)param0); + int return_value = ::interrogate_function_number_of_c_wrappers((FunctionIndex)param0); #if PY_MAJOR_VERSION >= 3 return PyLong_FromLong(return_value); #else return PyInt_FromLong(return_value); #endif } - return (PyObject *)NULL; + return nullptr; } /* @@ -898,14 +928,14 @@ _inP07yt3zru(PyObject *, PyObject *args) { int param0; int param1; if (PyArg_ParseTuple(args, "ii", ¶m0, ¶m1)) { - FunctionWrapperIndex return_value = interrogate_function_c_wrapper((FunctionIndex)param0, (int)param1); + FunctionWrapperIndex return_value = ::interrogate_function_c_wrapper((FunctionIndex)param0, (int)param1); #if PY_MAJOR_VERSION >= 3 return PyLong_FromLong(return_value); #else return PyInt_FromLong(return_value); #endif } - return (PyObject *)NULL; + return nullptr; } /* @@ -916,14 +946,14 @@ static PyObject * _inP07ytRrg2(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - int return_value = interrogate_function_number_of_python_wrappers((FunctionIndex)param0); + int return_value = ::interrogate_function_number_of_python_wrappers((FunctionIndex)param0); #if PY_MAJOR_VERSION >= 3 return PyLong_FromLong(return_value); #else return PyInt_FromLong(return_value); #endif } - return (PyObject *)NULL; + return nullptr; } /* @@ -935,14 +965,14 @@ _inP07ytEJCx(PyObject *, PyObject *args) { int param0; int param1; if (PyArg_ParseTuple(args, "ii", ¶m0, ¶m1)) { - FunctionWrapperIndex return_value = interrogate_function_python_wrapper((FunctionIndex)param0, (int)param1); + FunctionWrapperIndex return_value = ::interrogate_function_python_wrapper((FunctionIndex)param0, (int)param1); #if PY_MAJOR_VERSION >= 3 return PyLong_FromLong(return_value); #else return PyInt_FromLong(return_value); #endif } - return (PyObject *)NULL; + return nullptr; } /* @@ -953,14 +983,14 @@ static PyObject * _inP07ytWAZr(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - char const *return_value = interrogate_wrapper_name((FunctionWrapperIndex)param0); + char const *return_value = ::interrogate_wrapper_name((FunctionWrapperIndex)param0); #if PY_MAJOR_VERSION >= 3 return PyUnicode_FromString(return_value); #else return PyString_FromString(return_value); #endif } - return (PyObject *)NULL; + return nullptr; } /* @@ -971,10 +1001,10 @@ static PyObject * _inP07ytrD_M(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - bool return_value = interrogate_wrapper_is_callable_by_name((FunctionWrapperIndex)param0); + bool return_value = ::interrogate_wrapper_is_callable_by_name((FunctionWrapperIndex)param0); return PyBool_FromLong(return_value); } - return (PyObject *)NULL; + return nullptr; } /* @@ -985,10 +1015,10 @@ static PyObject * _inP07ytjolz(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - bool return_value = interrogate_wrapper_has_comment((FunctionWrapperIndex)param0); + bool return_value = ::interrogate_wrapper_has_comment((FunctionWrapperIndex)param0); return PyBool_FromLong(return_value); } - return (PyObject *)NULL; + return nullptr; } /* @@ -999,14 +1029,14 @@ static PyObject * _inP07ytt_JD(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - char const *return_value = interrogate_wrapper_comment((FunctionWrapperIndex)param0); + char const *return_value = ::interrogate_wrapper_comment((FunctionWrapperIndex)param0); #if PY_MAJOR_VERSION >= 3 return PyUnicode_FromString(return_value); #else return PyString_FromString(return_value); #endif } - return (PyObject *)NULL; + return nullptr; } /* @@ -1017,10 +1047,10 @@ static PyObject * _inP07ytwEts(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - bool return_value = interrogate_wrapper_has_return_value((FunctionWrapperIndex)param0); + bool return_value = ::interrogate_wrapper_has_return_value((FunctionWrapperIndex)param0); return PyBool_FromLong(return_value); } - return (PyObject *)NULL; + return nullptr; } /* @@ -1031,14 +1061,14 @@ static PyObject * _inP07ytrJWs(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - TypeIndex return_value = interrogate_wrapper_return_type((FunctionWrapperIndex)param0); + TypeIndex return_value = ::interrogate_wrapper_return_type((FunctionWrapperIndex)param0); #if PY_MAJOR_VERSION >= 3 return PyLong_FromLong(return_value); #else return PyInt_FromLong(return_value); #endif } - return (PyObject *)NULL; + return nullptr; } /* @@ -1049,10 +1079,10 @@ static PyObject * _inP07ytpmFD(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - bool return_value = interrogate_wrapper_caller_manages_return_value((FunctionWrapperIndex)param0); + bool return_value = ::interrogate_wrapper_caller_manages_return_value((FunctionWrapperIndex)param0); return PyBool_FromLong(return_value); } - return (PyObject *)NULL; + return nullptr; } /* @@ -1063,14 +1093,14 @@ static PyObject * _inP07ytyYUX(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - FunctionIndex return_value = interrogate_wrapper_return_value_destructor((FunctionWrapperIndex)param0); + FunctionIndex return_value = ::interrogate_wrapper_return_value_destructor((FunctionWrapperIndex)param0); #if PY_MAJOR_VERSION >= 3 return PyLong_FromLong(return_value); #else return PyInt_FromLong(return_value); #endif } - return (PyObject *)NULL; + return nullptr; } /* @@ -1081,14 +1111,14 @@ static PyObject * _inP07yt54dn(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - int return_value = interrogate_wrapper_number_of_parameters((FunctionWrapperIndex)param0); + int return_value = ::interrogate_wrapper_number_of_parameters((FunctionWrapperIndex)param0); #if PY_MAJOR_VERSION >= 3 return PyLong_FromLong(return_value); #else return PyInt_FromLong(return_value); #endif } - return (PyObject *)NULL; + return nullptr; } /* @@ -1100,14 +1130,14 @@ _inP07ytGMpW(PyObject *, PyObject *args) { int param0; int param1; if (PyArg_ParseTuple(args, "ii", ¶m0, ¶m1)) { - TypeIndex return_value = interrogate_wrapper_parameter_type((FunctionWrapperIndex)param0, (int)param1); + TypeIndex return_value = ::interrogate_wrapper_parameter_type((FunctionWrapperIndex)param0, (int)param1); #if PY_MAJOR_VERSION >= 3 return PyLong_FromLong(return_value); #else return PyInt_FromLong(return_value); #endif } - return (PyObject *)NULL; + return nullptr; } /* @@ -1119,10 +1149,10 @@ _inP07ytNuBV(PyObject *, PyObject *args) { int param0; int param1; if (PyArg_ParseTuple(args, "ii", ¶m0, ¶m1)) { - bool return_value = interrogate_wrapper_parameter_has_name((FunctionWrapperIndex)param0, (int)param1); + bool return_value = ::interrogate_wrapper_parameter_has_name((FunctionWrapperIndex)param0, (int)param1); return PyBool_FromLong(return_value); } - return (PyObject *)NULL; + return nullptr; } /* @@ -1134,14 +1164,14 @@ _inP07yt9UwA(PyObject *, PyObject *args) { int param0; int param1; if (PyArg_ParseTuple(args, "ii", ¶m0, ¶m1)) { - char const *return_value = interrogate_wrapper_parameter_name((FunctionWrapperIndex)param0, (int)param1); + char const *return_value = ::interrogate_wrapper_parameter_name((FunctionWrapperIndex)param0, (int)param1); #if PY_MAJOR_VERSION >= 3 return PyUnicode_FromString(return_value); #else return PyString_FromString(return_value); #endif } - return (PyObject *)NULL; + return nullptr; } /* @@ -1153,10 +1183,10 @@ _inP07yt3FDt(PyObject *, PyObject *args) { int param0; int param1; if (PyArg_ParseTuple(args, "ii", ¶m0, ¶m1)) { - bool return_value = interrogate_wrapper_parameter_is_this((FunctionWrapperIndex)param0, (int)param1); + bool return_value = ::interrogate_wrapper_parameter_is_this((FunctionWrapperIndex)param0, (int)param1); return PyBool_FromLong(return_value); } - return (PyObject *)NULL; + return nullptr; } /* @@ -1167,10 +1197,10 @@ static PyObject * _inP07ytf513(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - bool return_value = interrogate_wrapper_has_pointer((FunctionWrapperIndex)param0); + bool return_value = ::interrogate_wrapper_has_pointer((FunctionWrapperIndex)param0); return PyBool_FromLong(return_value); } - return (PyObject *)NULL; + return nullptr; } /* @@ -1181,10 +1211,10 @@ static PyObject * _inP07ytsqGH(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - interrogate_wrapper_pointer((FunctionWrapperIndex)param0); + ::interrogate_wrapper_pointer((FunctionWrapperIndex)param0); return Py_BuildValue(""); } - return (PyObject *)NULL; + return nullptr; } /* @@ -1195,14 +1225,14 @@ static PyObject * _inP07yt7shV(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - char const *return_value = interrogate_wrapper_unique_name((FunctionWrapperIndex)param0); + char const *return_value = ::interrogate_wrapper_unique_name((FunctionWrapperIndex)param0); #if PY_MAJOR_VERSION >= 3 return PyUnicode_FromString(return_value); #else return PyString_FromString(return_value); #endif } - return (PyObject *)NULL; + return nullptr; } /* @@ -1213,14 +1243,14 @@ static PyObject * _inP07ytA1eF(PyObject *, PyObject *args) { char *param0; if (PyArg_ParseTuple(args, "s", ¶m0)) { - FunctionWrapperIndex return_value = interrogate_get_wrapper_by_unique_name((char const *)param0); + FunctionWrapperIndex return_value = ::interrogate_get_wrapper_by_unique_name((char const *)param0); #if PY_MAJOR_VERSION >= 3 return PyLong_FromLong(return_value); #else return PyInt_FromLong(return_value); #endif } - return (PyObject *)NULL; + return nullptr; } /* @@ -1231,14 +1261,14 @@ static PyObject * _inP07yt776V(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - char const *return_value = interrogate_make_seq_seq_name((MakeSeqIndex)param0); + char const *return_value = ::interrogate_make_seq_seq_name((MakeSeqIndex)param0); #if PY_MAJOR_VERSION >= 3 return PyUnicode_FromString(return_value); #else return PyString_FromString(return_value); #endif } - return (PyObject *)NULL; + return nullptr; } /* @@ -1249,14 +1279,14 @@ static PyObject * _inP07ytryup(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - char const *return_value = interrogate_make_seq_scoped_name((MakeSeqIndex)param0); + char const *return_value = ::interrogate_make_seq_scoped_name((MakeSeqIndex)param0); #if PY_MAJOR_VERSION >= 3 return PyUnicode_FromString(return_value); #else return PyString_FromString(return_value); #endif } - return (PyObject *)NULL; + return nullptr; } /* @@ -1267,10 +1297,10 @@ static PyObject * _inP07ytiytI(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - bool return_value = interrogate_make_seq_has_comment((ElementIndex)param0); + bool return_value = ::interrogate_make_seq_has_comment((ElementIndex)param0); return PyBool_FromLong(return_value); } - return (PyObject *)NULL; + return nullptr; } /* @@ -1281,14 +1311,14 @@ static PyObject * _inP07ytZc07(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - char const *return_value = interrogate_make_seq_comment((ElementIndex)param0); + char const *return_value = ::interrogate_make_seq_comment((ElementIndex)param0); #if PY_MAJOR_VERSION >= 3 return PyUnicode_FromString(return_value); #else return PyString_FromString(return_value); #endif } - return (PyObject *)NULL; + return nullptr; } /* @@ -1299,14 +1329,14 @@ static PyObject * _inP07ytfaH0(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - char const *return_value = interrogate_make_seq_num_name((MakeSeqIndex)param0); + char const *return_value = ::interrogate_make_seq_num_name((MakeSeqIndex)param0); #if PY_MAJOR_VERSION >= 3 return PyUnicode_FromString(return_value); #else return PyString_FromString(return_value); #endif } - return (PyObject *)NULL; + return nullptr; } /* @@ -1317,14 +1347,14 @@ static PyObject * _inP07ytGB9D(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - char const *return_value = interrogate_make_seq_element_name((MakeSeqIndex)param0); + char const *return_value = ::interrogate_make_seq_element_name((MakeSeqIndex)param0); #if PY_MAJOR_VERSION >= 3 return PyUnicode_FromString(return_value); #else return PyString_FromString(return_value); #endif } - return (PyObject *)NULL; + return nullptr; } /* @@ -1334,14 +1364,14 @@ _inP07ytGB9D(PyObject *, PyObject *args) { static PyObject * _inP07ytsxxs(PyObject *, PyObject *args) { if (PyArg_ParseTuple(args, "")) { - int return_value = interrogate_number_of_global_types(); + int return_value = ::interrogate_number_of_global_types(); #if PY_MAJOR_VERSION >= 3 return PyLong_FromLong(return_value); #else return PyInt_FromLong(return_value); #endif } - return (PyObject *)NULL; + return nullptr; } /* @@ -1352,14 +1382,14 @@ static PyObject * _inP07ytMT0z(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - TypeIndex return_value = interrogate_get_global_type((int)param0); + TypeIndex return_value = ::interrogate_get_global_type((int)param0); #if PY_MAJOR_VERSION >= 3 return PyLong_FromLong(return_value); #else return PyInt_FromLong(return_value); #endif } - return (PyObject *)NULL; + return nullptr; } /* @@ -1369,14 +1399,14 @@ _inP07ytMT0z(PyObject *, PyObject *args) { static PyObject * _inP07ytiW3v(PyObject *, PyObject *args) { if (PyArg_ParseTuple(args, "")) { - int return_value = interrogate_number_of_types(); + int return_value = ::interrogate_number_of_types(); #if PY_MAJOR_VERSION >= 3 return PyLong_FromLong(return_value); #else return PyInt_FromLong(return_value); #endif } - return (PyObject *)NULL; + return nullptr; } /* @@ -1387,14 +1417,14 @@ static PyObject * _inP07yt4Px8(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - TypeIndex return_value = interrogate_get_type((int)param0); + TypeIndex return_value = ::interrogate_get_type((int)param0); #if PY_MAJOR_VERSION >= 3 return PyLong_FromLong(return_value); #else return PyInt_FromLong(return_value); #endif } - return (PyObject *)NULL; + return nullptr; } /* @@ -1405,14 +1435,14 @@ static PyObject * _inP07ytNHcs(PyObject *, PyObject *args) { char *param0; if (PyArg_ParseTuple(args, "s", ¶m0)) { - TypeIndex return_value = interrogate_get_type_by_name((char const *)param0); + TypeIndex return_value = ::interrogate_get_type_by_name((char const *)param0); #if PY_MAJOR_VERSION >= 3 return PyLong_FromLong(return_value); #else return PyInt_FromLong(return_value); #endif } - return (PyObject *)NULL; + return nullptr; } /* @@ -1423,14 +1453,14 @@ static PyObject * _inP07ytqHrb(PyObject *, PyObject *args) { char *param0; if (PyArg_ParseTuple(args, "s", ¶m0)) { - TypeIndex return_value = interrogate_get_type_by_scoped_name((char const *)param0); + TypeIndex return_value = ::interrogate_get_type_by_scoped_name((char const *)param0); #if PY_MAJOR_VERSION >= 3 return PyLong_FromLong(return_value); #else return PyInt_FromLong(return_value); #endif } - return (PyObject *)NULL; + return nullptr; } /* @@ -1441,14 +1471,14 @@ static PyObject * _inP07ytaOqq(PyObject *, PyObject *args) { char *param0; if (PyArg_ParseTuple(args, "s", ¶m0)) { - TypeIndex return_value = interrogate_get_type_by_true_name((char const *)param0); + TypeIndex return_value = ::interrogate_get_type_by_true_name((char const *)param0); #if PY_MAJOR_VERSION >= 3 return PyLong_FromLong(return_value); #else return PyInt_FromLong(return_value); #endif } - return (PyObject *)NULL; + return nullptr; } /* @@ -1459,10 +1489,10 @@ static PyObject * _inP07ytpTBb(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - bool return_value = interrogate_type_is_global((TypeIndex)param0); + bool return_value = ::interrogate_type_is_global((TypeIndex)param0); return PyBool_FromLong(return_value); } - return (PyObject *)NULL; + return nullptr; } /* @@ -1473,14 +1503,14 @@ static PyObject * _inP07ytqWOw(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - char const *return_value = interrogate_type_name((TypeIndex)param0); + char const *return_value = ::interrogate_type_name((TypeIndex)param0); #if PY_MAJOR_VERSION >= 3 return PyUnicode_FromString(return_value); #else return PyString_FromString(return_value); #endif } - return (PyObject *)NULL; + return nullptr; } /* @@ -1491,14 +1521,14 @@ static PyObject * _inP07ytHu7x(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - char const *return_value = interrogate_type_scoped_name((TypeIndex)param0); + char const *return_value = ::interrogate_type_scoped_name((TypeIndex)param0); #if PY_MAJOR_VERSION >= 3 return PyUnicode_FromString(return_value); #else return PyString_FromString(return_value); #endif } - return (PyObject *)NULL; + return nullptr; } /* @@ -1509,14 +1539,14 @@ static PyObject * _inP07ytwGnA(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - char const *return_value = interrogate_type_true_name((TypeIndex)param0); + char const *return_value = ::interrogate_type_true_name((TypeIndex)param0); #if PY_MAJOR_VERSION >= 3 return PyUnicode_FromString(return_value); #else return PyString_FromString(return_value); #endif } - return (PyObject *)NULL; + return nullptr; } /* @@ -1527,10 +1557,10 @@ static PyObject * _inP07ytXGxx(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - bool return_value = interrogate_type_is_nested((TypeIndex)param0); + bool return_value = ::interrogate_type_is_nested((TypeIndex)param0); return PyBool_FromLong(return_value); } - return (PyObject *)NULL; + return nullptr; } /* @@ -1541,14 +1571,14 @@ static PyObject * _inP07ytj04Z(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - TypeIndex return_value = interrogate_type_outer_class((TypeIndex)param0); + TypeIndex return_value = ::interrogate_type_outer_class((TypeIndex)param0); #if PY_MAJOR_VERSION >= 3 return PyLong_FromLong(return_value); #else return PyInt_FromLong(return_value); #endif } - return (PyObject *)NULL; + return nullptr; } /* @@ -1559,10 +1589,10 @@ static PyObject * _inP07ytEOv4(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - bool return_value = interrogate_type_has_comment((TypeIndex)param0); + bool return_value = ::interrogate_type_has_comment((TypeIndex)param0); return PyBool_FromLong(return_value); } - return (PyObject *)NULL; + return nullptr; } /* @@ -1573,14 +1603,14 @@ static PyObject * _inP07ytpCqJ(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - char const *return_value = interrogate_type_comment((TypeIndex)param0); + char const *return_value = ::interrogate_type_comment((TypeIndex)param0); #if PY_MAJOR_VERSION >= 3 return PyUnicode_FromString(return_value); #else return PyString_FromString(return_value); #endif } - return (PyObject *)NULL; + return nullptr; } /* @@ -1591,10 +1621,10 @@ static PyObject * _inP07yt_Pz3(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - bool return_value = interrogate_type_has_module_name((TypeIndex)param0); + bool return_value = ::interrogate_type_has_module_name((TypeIndex)param0); return PyBool_FromLong(return_value); } - return (PyObject *)NULL; + return nullptr; } /* @@ -1605,14 +1635,14 @@ static PyObject * _inP07ytt_06(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - char const *return_value = interrogate_type_module_name((TypeIndex)param0); + char const *return_value = ::interrogate_type_module_name((TypeIndex)param0); #if PY_MAJOR_VERSION >= 3 return PyUnicode_FromString(return_value); #else return PyString_FromString(return_value); #endif } - return (PyObject *)NULL; + return nullptr; } /* @@ -1623,10 +1653,10 @@ static PyObject * _inP07ytmuPs(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - bool return_value = interrogate_type_has_library_name((TypeIndex)param0); + bool return_value = ::interrogate_type_has_library_name((TypeIndex)param0); return PyBool_FromLong(return_value); } - return (PyObject *)NULL; + return nullptr; } /* @@ -1637,14 +1667,14 @@ static PyObject * _inP07ytvM8B(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - char const *return_value = interrogate_type_library_name((TypeIndex)param0); + char const *return_value = ::interrogate_type_library_name((TypeIndex)param0); #if PY_MAJOR_VERSION >= 3 return PyUnicode_FromString(return_value); #else return PyString_FromString(return_value); #endif } - return (PyObject *)NULL; + return nullptr; } /* @@ -1655,10 +1685,10 @@ static PyObject * _inP07ytap97(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - bool return_value = interrogate_type_is_atomic((TypeIndex)param0); + bool return_value = ::interrogate_type_is_atomic((TypeIndex)param0); return PyBool_FromLong(return_value); } - return (PyObject *)NULL; + return nullptr; } /* @@ -1669,14 +1699,14 @@ static PyObject * _inP07yt0o8D(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - AtomicToken return_value = interrogate_type_atomic_token((TypeIndex)param0); + AtomicToken return_value = ::interrogate_type_atomic_token((TypeIndex)param0); #if PY_MAJOR_VERSION >= 3 return PyLong_FromLong(return_value); #else return PyInt_FromLong(return_value); #endif } - return (PyObject *)NULL; + return nullptr; } /* @@ -1687,10 +1717,10 @@ static PyObject * _inP07ytOoQ2(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - bool return_value = interrogate_type_is_unsigned((TypeIndex)param0); + bool return_value = ::interrogate_type_is_unsigned((TypeIndex)param0); return PyBool_FromLong(return_value); } - return (PyObject *)NULL; + return nullptr; } /* @@ -1701,10 +1731,10 @@ static PyObject * _inP07ytKuFh(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - bool return_value = interrogate_type_is_signed((TypeIndex)param0); + bool return_value = ::interrogate_type_is_signed((TypeIndex)param0); return PyBool_FromLong(return_value); } - return (PyObject *)NULL; + return nullptr; } /* @@ -1715,10 +1745,10 @@ static PyObject * _inP07yto5L6(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - bool return_value = interrogate_type_is_long((TypeIndex)param0); + bool return_value = ::interrogate_type_is_long((TypeIndex)param0); return PyBool_FromLong(return_value); } - return (PyObject *)NULL; + return nullptr; } /* @@ -1729,10 +1759,10 @@ static PyObject * _inP07ytzgKK(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - bool return_value = interrogate_type_is_longlong((TypeIndex)param0); + bool return_value = ::interrogate_type_is_longlong((TypeIndex)param0); return PyBool_FromLong(return_value); } - return (PyObject *)NULL; + return nullptr; } /* @@ -1743,10 +1773,10 @@ static PyObject * _inP07yt0FIF(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - bool return_value = interrogate_type_is_short((TypeIndex)param0); + bool return_value = ::interrogate_type_is_short((TypeIndex)param0); return PyBool_FromLong(return_value); } - return (PyObject *)NULL; + return nullptr; } /* @@ -1757,10 +1787,10 @@ static PyObject * _inP07ytZqvD(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - bool return_value = interrogate_type_is_wrapped((TypeIndex)param0); + bool return_value = ::interrogate_type_is_wrapped((TypeIndex)param0); return PyBool_FromLong(return_value); } - return (PyObject *)NULL; + return nullptr; } /* @@ -1771,10 +1801,10 @@ static PyObject * _inP07ytDyRd(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - bool return_value = interrogate_type_is_pointer((TypeIndex)param0); + bool return_value = ::interrogate_type_is_pointer((TypeIndex)param0); return PyBool_FromLong(return_value); } - return (PyObject *)NULL; + return nullptr; } /* @@ -1785,10 +1815,10 @@ static PyObject * _inP07ytMnKa(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - bool return_value = interrogate_type_is_const((TypeIndex)param0); + bool return_value = ::interrogate_type_is_const((TypeIndex)param0); return PyBool_FromLong(return_value); } - return (PyObject *)NULL; + return nullptr; } /* @@ -1799,10 +1829,10 @@ static PyObject * _inP07ytRtji(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - bool return_value = interrogate_type_is_typedef((TypeIndex)param0); + bool return_value = ::interrogate_type_is_typedef((TypeIndex)param0); return PyBool_FromLong(return_value); } - return (PyObject *)NULL; + return nullptr; } /* @@ -1813,14 +1843,14 @@ static PyObject * _inP07ytCnbQ(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - TypeIndex return_value = interrogate_type_wrapped_type((TypeIndex)param0); + TypeIndex return_value = ::interrogate_type_wrapped_type((TypeIndex)param0); #if PY_MAJOR_VERSION >= 3 return PyLong_FromLong(return_value); #else return PyInt_FromLong(return_value); #endif } - return (PyObject *)NULL; + return nullptr; } /* @@ -1831,10 +1861,10 @@ static PyObject * _inP07ytdUVN(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - bool return_value = interrogate_type_is_enum((TypeIndex)param0); + bool return_value = ::interrogate_type_is_enum((TypeIndex)param0); return PyBool_FromLong(return_value); } - return (PyObject *)NULL; + return nullptr; } /* @@ -1845,14 +1875,14 @@ static PyObject * _inP07ytihbt(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - int return_value = interrogate_type_number_of_enum_values((TypeIndex)param0); + int return_value = ::interrogate_type_number_of_enum_values((TypeIndex)param0); #if PY_MAJOR_VERSION >= 3 return PyLong_FromLong(return_value); #else return PyInt_FromLong(return_value); #endif } - return (PyObject *)NULL; + return nullptr; } /* @@ -1864,14 +1894,14 @@ _inP07ytbyPY(PyObject *, PyObject *args) { int param0; int param1; if (PyArg_ParseTuple(args, "ii", ¶m0, ¶m1)) { - char const *return_value = interrogate_type_enum_value_name((TypeIndex)param0, (int)param1); + char const *return_value = ::interrogate_type_enum_value_name((TypeIndex)param0, (int)param1); #if PY_MAJOR_VERSION >= 3 return PyUnicode_FromString(return_value); #else return PyString_FromString(return_value); #endif } - return (PyObject *)NULL; + return nullptr; } /* @@ -1883,14 +1913,14 @@ _inP07ytAaT6(PyObject *, PyObject *args) { int param0; int param1; if (PyArg_ParseTuple(args, "ii", ¶m0, ¶m1)) { - char const *return_value = interrogate_type_enum_value_scoped_name((TypeIndex)param0, (int)param1); + char const *return_value = ::interrogate_type_enum_value_scoped_name((TypeIndex)param0, (int)param1); #if PY_MAJOR_VERSION >= 3 return PyUnicode_FromString(return_value); #else return PyString_FromString(return_value); #endif } - return (PyObject *)NULL; + return nullptr; } /* @@ -1902,14 +1932,14 @@ _inP07ytgL9q(PyObject *, PyObject *args) { int param0; int param1; if (PyArg_ParseTuple(args, "ii", ¶m0, ¶m1)) { - char const *return_value = interrogate_type_enum_value_comment((TypeIndex)param0, (int)param1); + char const *return_value = ::interrogate_type_enum_value_comment((TypeIndex)param0, (int)param1); #if PY_MAJOR_VERSION >= 3 return PyUnicode_FromString(return_value); #else return PyString_FromString(return_value); #endif } - return (PyObject *)NULL; + return nullptr; } /* @@ -1921,14 +1951,14 @@ _inP07ytWB97(PyObject *, PyObject *args) { int param0; int param1; if (PyArg_ParseTuple(args, "ii", ¶m0, ¶m1)) { - int return_value = interrogate_type_enum_value((TypeIndex)param0, (int)param1); + int return_value = ::interrogate_type_enum_value((TypeIndex)param0, (int)param1); #if PY_MAJOR_VERSION >= 3 return PyLong_FromLong(return_value); #else return PyInt_FromLong(return_value); #endif } - return (PyObject *)NULL; + return nullptr; } /* @@ -1939,10 +1969,10 @@ static PyObject * _inP07ytDUAl(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - bool return_value = interrogate_type_is_struct((TypeIndex)param0); + bool return_value = ::interrogate_type_is_struct((TypeIndex)param0); return PyBool_FromLong(return_value); } - return (PyObject *)NULL; + return nullptr; } /* @@ -1953,10 +1983,10 @@ static PyObject * _inP07yt1_Kf(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - bool return_value = interrogate_type_is_class((TypeIndex)param0); + bool return_value = ::interrogate_type_is_class((TypeIndex)param0); return PyBool_FromLong(return_value); } - return (PyObject *)NULL; + return nullptr; } /* @@ -1967,10 +1997,10 @@ static PyObject * _inP07yt98lD(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - bool return_value = interrogate_type_is_union((TypeIndex)param0); + bool return_value = ::interrogate_type_is_union((TypeIndex)param0); return PyBool_FromLong(return_value); } - return (PyObject *)NULL; + return nullptr; } /* @@ -1981,10 +2011,10 @@ static PyObject * _inP07yt9SHr(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - bool return_value = interrogate_type_is_fully_defined((TypeIndex)param0); + bool return_value = ::interrogate_type_is_fully_defined((TypeIndex)param0); return PyBool_FromLong(return_value); } - return (PyObject *)NULL; + return nullptr; } /* @@ -1995,10 +2025,10 @@ static PyObject * _inP07ytdiZP(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - bool return_value = interrogate_type_is_unpublished((TypeIndex)param0); + bool return_value = ::interrogate_type_is_unpublished((TypeIndex)param0); return PyBool_FromLong(return_value); } - return (PyObject *)NULL; + return nullptr; } /* @@ -2009,14 +2039,14 @@ static PyObject * _inP07ytTdER(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - int return_value = interrogate_type_number_of_constructors((TypeIndex)param0); + int return_value = ::interrogate_type_number_of_constructors((TypeIndex)param0); #if PY_MAJOR_VERSION >= 3 return PyLong_FromLong(return_value); #else return PyInt_FromLong(return_value); #endif } - return (PyObject *)NULL; + return nullptr; } /* @@ -2028,14 +2058,14 @@ _inP07ytYO56(PyObject *, PyObject *args) { int param0; int param1; if (PyArg_ParseTuple(args, "ii", ¶m0, ¶m1)) { - FunctionIndex return_value = interrogate_type_get_constructor((TypeIndex)param0, (int)param1); + FunctionIndex return_value = ::interrogate_type_get_constructor((TypeIndex)param0, (int)param1); #if PY_MAJOR_VERSION >= 3 return PyLong_FromLong(return_value); #else return PyInt_FromLong(return_value); #endif } - return (PyObject *)NULL; + return nullptr; } /* @@ -2046,10 +2076,10 @@ static PyObject * _inP07ytxtCG(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - bool return_value = interrogate_type_has_destructor((TypeIndex)param0); + bool return_value = ::interrogate_type_has_destructor((TypeIndex)param0); return PyBool_FromLong(return_value); } - return (PyObject *)NULL; + return nullptr; } /* @@ -2060,10 +2090,10 @@ static PyObject * _inP07yt_EB2(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - bool return_value = interrogate_type_destructor_is_inherited((TypeIndex)param0); + bool return_value = ::interrogate_type_destructor_is_inherited((TypeIndex)param0); return PyBool_FromLong(return_value); } - return (PyObject *)NULL; + return nullptr; } /* @@ -2074,14 +2104,14 @@ static PyObject * _inP07ytEG1l(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - FunctionIndex return_value = interrogate_type_get_destructor((TypeIndex)param0); + FunctionIndex return_value = ::interrogate_type_get_destructor((TypeIndex)param0); #if PY_MAJOR_VERSION >= 3 return PyLong_FromLong(return_value); #else return PyInt_FromLong(return_value); #endif } - return (PyObject *)NULL; + return nullptr; } /* @@ -2092,14 +2122,14 @@ static PyObject * _inP07yt7tUq(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - int return_value = interrogate_type_number_of_elements((TypeIndex)param0); + int return_value = ::interrogate_type_number_of_elements((TypeIndex)param0); #if PY_MAJOR_VERSION >= 3 return PyLong_FromLong(return_value); #else return PyInt_FromLong(return_value); #endif } - return (PyObject *)NULL; + return nullptr; } /* @@ -2111,14 +2141,14 @@ _inP07ytyStU(PyObject *, PyObject *args) { int param0; int param1; if (PyArg_ParseTuple(args, "ii", ¶m0, ¶m1)) { - ElementIndex return_value = interrogate_type_get_element((TypeIndex)param0, (int)param1); + ElementIndex return_value = ::interrogate_type_get_element((TypeIndex)param0, (int)param1); #if PY_MAJOR_VERSION >= 3 return PyLong_FromLong(return_value); #else return PyInt_FromLong(return_value); #endif } - return (PyObject *)NULL; + return nullptr; } /* @@ -2129,14 +2159,14 @@ static PyObject * _inP07ytdM85(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - int return_value = interrogate_type_number_of_methods((TypeIndex)param0); + int return_value = ::interrogate_type_number_of_methods((TypeIndex)param0); #if PY_MAJOR_VERSION >= 3 return PyLong_FromLong(return_value); #else return PyInt_FromLong(return_value); #endif } - return (PyObject *)NULL; + return nullptr; } /* @@ -2148,14 +2178,14 @@ _inP07ytk_GN(PyObject *, PyObject *args) { int param0; int param1; if (PyArg_ParseTuple(args, "ii", ¶m0, ¶m1)) { - FunctionIndex return_value = interrogate_type_get_method((TypeIndex)param0, (int)param1); + FunctionIndex return_value = ::interrogate_type_get_method((TypeIndex)param0, (int)param1); #if PY_MAJOR_VERSION >= 3 return PyLong_FromLong(return_value); #else return PyInt_FromLong(return_value); #endif } - return (PyObject *)NULL; + return nullptr; } /* @@ -2166,14 +2196,14 @@ static PyObject * _inP07yt8QjG(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - int return_value = interrogate_type_number_of_make_seqs((TypeIndex)param0); + int return_value = ::interrogate_type_number_of_make_seqs((TypeIndex)param0); #if PY_MAJOR_VERSION >= 3 return PyLong_FromLong(return_value); #else return PyInt_FromLong(return_value); #endif } - return (PyObject *)NULL; + return nullptr; } /* @@ -2185,14 +2215,14 @@ _inP07ytyMtj(PyObject *, PyObject *args) { int param0; int param1; if (PyArg_ParseTuple(args, "ii", ¶m0, ¶m1)) { - MakeSeqIndex return_value = interrogate_type_get_make_seq((TypeIndex)param0, (int)param1); + MakeSeqIndex return_value = ::interrogate_type_get_make_seq((TypeIndex)param0, (int)param1); #if PY_MAJOR_VERSION >= 3 return PyLong_FromLong(return_value); #else return PyInt_FromLong(return_value); #endif } - return (PyObject *)NULL; + return nullptr; } /* @@ -2203,14 +2233,14 @@ static PyObject * _inP07ytHDtN(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - int return_value = interrogate_type_number_of_casts((TypeIndex)param0); + int return_value = ::interrogate_type_number_of_casts((TypeIndex)param0); #if PY_MAJOR_VERSION >= 3 return PyLong_FromLong(return_value); #else return PyInt_FromLong(return_value); #endif } - return (PyObject *)NULL; + return nullptr; } /* @@ -2222,14 +2252,14 @@ _inP07ytHFjA(PyObject *, PyObject *args) { int param0; int param1; if (PyArg_ParseTuple(args, "ii", ¶m0, ¶m1)) { - FunctionIndex return_value = interrogate_type_get_cast((TypeIndex)param0, (int)param1); + FunctionIndex return_value = ::interrogate_type_get_cast((TypeIndex)param0, (int)param1); #if PY_MAJOR_VERSION >= 3 return PyLong_FromLong(return_value); #else return PyInt_FromLong(return_value); #endif } - return (PyObject *)NULL; + return nullptr; } /* @@ -2240,14 +2270,14 @@ static PyObject * _inP07yt_NPR(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - int return_value = interrogate_type_number_of_derivations((TypeIndex)param0); + int return_value = ::interrogate_type_number_of_derivations((TypeIndex)param0); #if PY_MAJOR_VERSION >= 3 return PyLong_FromLong(return_value); #else return PyInt_FromLong(return_value); #endif } - return (PyObject *)NULL; + return nullptr; } /* @@ -2259,14 +2289,14 @@ _inP07ytcTOH(PyObject *, PyObject *args) { int param0; int param1; if (PyArg_ParseTuple(args, "ii", ¶m0, ¶m1)) { - TypeIndex return_value = interrogate_type_get_derivation((TypeIndex)param0, (int)param1); + TypeIndex return_value = ::interrogate_type_get_derivation((TypeIndex)param0, (int)param1); #if PY_MAJOR_VERSION >= 3 return PyLong_FromLong(return_value); #else return PyInt_FromLong(return_value); #endif } - return (PyObject *)NULL; + return nullptr; } /* @@ -2278,10 +2308,10 @@ _inP07ythdU7(PyObject *, PyObject *args) { int param0; int param1; if (PyArg_ParseTuple(args, "ii", ¶m0, ¶m1)) { - bool return_value = interrogate_type_derivation_has_upcast((TypeIndex)param0, (int)param1); + bool return_value = ::interrogate_type_derivation_has_upcast((TypeIndex)param0, (int)param1); return PyBool_FromLong(return_value); } - return (PyObject *)NULL; + return nullptr; } /* @@ -2293,14 +2323,14 @@ _inP07ytQPxU(PyObject *, PyObject *args) { int param0; int param1; if (PyArg_ParseTuple(args, "ii", ¶m0, ¶m1)) { - FunctionIndex return_value = interrogate_type_get_upcast((TypeIndex)param0, (int)param1); + FunctionIndex return_value = ::interrogate_type_get_upcast((TypeIndex)param0, (int)param1); #if PY_MAJOR_VERSION >= 3 return PyLong_FromLong(return_value); #else return PyInt_FromLong(return_value); #endif } - return (PyObject *)NULL; + return nullptr; } /* @@ -2312,10 +2342,10 @@ _inP07ytO7Pz(PyObject *, PyObject *args) { int param0; int param1; if (PyArg_ParseTuple(args, "ii", ¶m0, ¶m1)) { - bool return_value = interrogate_type_derivation_downcast_is_impossible((TypeIndex)param0, (int)param1); + bool return_value = ::interrogate_type_derivation_downcast_is_impossible((TypeIndex)param0, (int)param1); return PyBool_FromLong(return_value); } - return (PyObject *)NULL; + return nullptr; } /* @@ -2327,10 +2357,10 @@ _inP07ytvu_E(PyObject *, PyObject *args) { int param0; int param1; if (PyArg_ParseTuple(args, "ii", ¶m0, ¶m1)) { - bool return_value = interrogate_type_derivation_has_downcast((TypeIndex)param0, (int)param1); + bool return_value = ::interrogate_type_derivation_has_downcast((TypeIndex)param0, (int)param1); return PyBool_FromLong(return_value); } - return (PyObject *)NULL; + return nullptr; } /* @@ -2342,14 +2372,14 @@ _inP07ytxGUt(PyObject *, PyObject *args) { int param0; int param1; if (PyArg_ParseTuple(args, "ii", ¶m0, ¶m1)) { - FunctionIndex return_value = interrogate_type_get_downcast((TypeIndex)param0, (int)param1); + FunctionIndex return_value = ::interrogate_type_get_downcast((TypeIndex)param0, (int)param1); #if PY_MAJOR_VERSION >= 3 return PyLong_FromLong(return_value); #else return PyInt_FromLong(return_value); #endif } - return (PyObject *)NULL; + return nullptr; } /* @@ -2360,14 +2390,14 @@ static PyObject * _inP07ytzM1P(PyObject *, PyObject *args) { int param0; if (PyArg_ParseTuple(args, "i", ¶m0)) { - int return_value = interrogate_type_number_of_nested_types((TypeIndex)param0); + int return_value = ::interrogate_type_number_of_nested_types((TypeIndex)param0); #if PY_MAJOR_VERSION >= 3 return PyLong_FromLong(return_value); #else return PyInt_FromLong(return_value); #endif } - return (PyObject *)NULL; + return nullptr; } /* @@ -2379,14 +2409,14 @@ _inP07ytoY5L(PyObject *, PyObject *args) { int param0; int param1; if (PyArg_ParseTuple(args, "ii", ¶m0, ¶m1)) { - TypeIndex return_value = interrogate_type_get_nested_type((TypeIndex)param0, (int)param1); + TypeIndex return_value = ::interrogate_type_get_nested_type((TypeIndex)param0, (int)param1); #if PY_MAJOR_VERSION >= 3 return PyLong_FromLong(return_value); #else return PyInt_FromLong(return_value); #endif } - return (PyObject *)NULL; + return nullptr; } /* @@ -2397,10 +2427,10 @@ static PyObject * _inP07yte_7S(PyObject *, PyObject *args) { char *param0; if (PyArg_ParseTuple(args, "s", ¶m0)) { - interrogate_request_database((char const *)param0); + ::interrogate_request_database((char const *)param0); return Py_BuildValue(""); } - return (PyObject *)NULL; + return nullptr; } /* @@ -2411,10 +2441,10 @@ static PyObject * _inP07ytw_15(PyObject *, PyObject *args) { Py_ssize_t param0; if (PyArg_ParseTuple(args, "n", ¶m0)) { - interrogate_request_module((InterrogateModuleDef *)param0); + ::interrogate_request_module((InterrogateModuleDef *)param0); return Py_BuildValue(""); } - return (PyObject *)NULL; + return nullptr; } @@ -2444,6 +2474,8 @@ static PyMethodDef python_simple_funcs[] = { { "interrogate_element_getter", &_inP07ytHuAm, METH_VARARGS }, { "interrogate_element_has_setter", &_inP07yt_xr0, METH_VARARGS }, { "interrogate_element_setter", &_inP07ytH5qp, METH_VARARGS }, + { "interrogate_element_is_sequence", &_inP07ytq45U, METH_VARARGS }, + { "interrogate_element_is_mapping", &_inP07yt6IPa, METH_VARARGS }, { "interrogate_number_of_globals", &_inP07ytU2_B, METH_VARARGS }, { "interrogate_get_global", &_inP07ytHFO2, METH_VARARGS }, { "interrogate_number_of_global_functions", &_inP07ytcfjm, METH_VARARGS }, @@ -2555,17 +2587,17 @@ static PyMethodDef python_simple_funcs[] = { { "interrogate_type_get_nested_type", &_inP07ytoY5L, METH_VARARGS }, { "interrogate_request_database", &_inP07yte_7S, METH_VARARGS }, { "interrogate_request_module", &_inP07ytw_15, METH_VARARGS }, - { NULL, NULL } + { nullptr, nullptr } }; #if PY_MAJOR_VERSION >= 3 static struct PyModuleDef python_simple_module = { PyModuleDef_HEAD_INIT, "interrogatedb", - NULL, + nullptr, -1, python_simple_funcs, - NULL, NULL, NULL, NULL + nullptr, nullptr, nullptr, nullptr }; #define INIT_FUNC PyObject *PyInit_interrogatedb From c0c202a423d15cec50535311cc22b635a7677f6a Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 23 Dec 2018 15:47:44 +0100 Subject: [PATCH 16/33] directscripts: bring Python documentation generation up-to-date Fixes #484 --- direct/src/directscripts/Doxyfile.python | 4 +- direct/src/directscripts/extract_docs.py | 130 ++++++++++++++--------- 2 files changed, 82 insertions(+), 52 deletions(-) diff --git a/direct/src/directscripts/Doxyfile.python b/direct/src/directscripts/Doxyfile.python index 4bcfb58727..5b2e73ff77 100644 --- a/direct/src/directscripts/Doxyfile.python +++ b/direct/src/directscripts/Doxyfile.python @@ -665,7 +665,9 @@ EXCLUDE_SYMLINKS = NO # for example use the pattern */test/* EXCLUDE_PATTERNS = */Opt*-*/* \ - */CVS/* + */CVS/* \ + */.git/* \ + */__pycache__/* # The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names # (namespaces, classes, functions, etc.) that should be excluded from the diff --git a/direct/src/directscripts/extract_docs.py b/direct/src/directscripts/extract_docs.py index b6ad69e946..caead7e4dc 100644 --- a/direct/src/directscripts/extract_docs.py +++ b/direct/src/directscripts/extract_docs.py @@ -9,9 +9,20 @@ from __future__ import print_function __all__ = [] -import os +import os, sys +from distutils import sysconfig import panda3d, pandac -from panda3d.dtoolconfig import * +from panda3d.interrogatedb import * + + +if 'interrogate_element_is_sequence' not in globals(): + def interrogate_element_is_sequence(element): + return False + +if 'interrogate_element_is_mapping' not in globals(): + def interrogate_element_is_mapping(element): + return False + LICENSE = """PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University. All rights reserved. @@ -19,6 +30,16 @@ All use of this software is subject to the terms of the revised BSD license. You should have received a copy of this license along with this source code in a file named \"LICENSE.\"""".split("\n") +MAINPAGE = """@mainpage Panda3D Python API Reference +Welcome to the Panda3D API reference. + +Use the links at the top of this page to browse through the list of modules or +the list of classes. + +This reference is automatically generated from comments in the source code. +""" + + def comment(code): if not code: return "" @@ -45,49 +66,16 @@ def comment(code): return '' def block_comment(code): - if not code: + code = code.strip() + + if not code.startswith('///<') and '@verbatim' not in code: + code = code.replace('<', '\\<').replace('>', '\\>') + + if not code or code[0] != '/': + # Not really a comment; get rid of it. return "" - lines = code.split("\n") - newlines = [] - indent = 0 - reading_desc = False - - for line in lines: - if line.startswith("////"): - continue - - line = line.rstrip() - strline = line.lstrip('/ \t') - - if ':' in strline: - pre, post = strline.split(':', 1) - pre = pre.rstrip() - if pre == "Description": - strline = post.lstrip() - elif pre in ("Class", "Access", "Function", "Created by", "Enum"): - continue - - if strline or len(newlines) > 0: - newlines.append('/// ' + strline) - - #if reading_desc: - # newlines.append('/// ' + line[min(indent, len(line) - len(strline)):]) - #else: - # # A "Description:" text starts the description. - # if strline.startswith("Description"): - # strline = strline[11:].lstrip(': \t') - # indent = len(line) - len(strline) - # reading_desc = True - # newlines.append('/// ' + strline) - # else: - # print line - - newcode = '\n'.join(newlines) - if len(newcode) > 0: - return newcode - else: - return "" + return code def translateFunctionName(name): if name.startswith("__"): @@ -139,11 +127,17 @@ def translated_type_name(type, scoped=True): return "object" elif typename == "PN_stdfloat": return "float" + elif typename == "size_t": + return "int" if interrogate_type_is_atomic(type): token = interrogate_type_atomic_token(type) if token == 7: return 'str' + elif token == 8: + return 'long' + elif token == 9: + return 'NoneType' else: return typename @@ -156,12 +150,25 @@ def translated_type_name(type, scoped=True): else: return typename + def processElement(handle, element): if interrogate_element_has_comment(element): print(comment(interrogate_element_comment(element)), file=handle) + elif interrogate_element_has_getter(element): + # If the property has no comment, use the comment of the getter. + getter = interrogate_element_getter(element) + if interrogate_function_has_comment(getter): + print(block_comment(interrogate_function_comment(getter)), file=handle) + + if interrogate_element_is_mapping(element) or \ + interrogate_element_is_sequence(element): + suffix = "[]" + else: + suffix = "" print(translated_type_name(interrogate_element_type(element)), end=' ', file=handle) - print(interrogate_element_name(element) + ';', file=handle) + print(interrogate_element_name(element) + suffix + ';', file=handle) + def processFunction(handle, function, isConstructor = False): for i_wrapper in range(interrogate_function_number_of_python_wrappers(function)): @@ -195,6 +202,7 @@ def processFunction(handle, function, isConstructor = False): print(");", file=handle) + def processType(handle, type): typename = translated_type_name(type, scoped=False) derivations = [ translated_type_name(interrogate_type_get_derivation(type, n)) for n in range(interrogate_type_number_of_derivations(type)) ] @@ -211,8 +219,10 @@ def processType(handle, type): print(interrogate_type_enum_value_name(type, i_value), "=", interrogate_type_enum_value(type, i_value), ",", file=handle) elif interrogate_type_is_typedef(type): - wrapped_type = translated_type_name(interrogate_type_wrapped_type(type)) - print("typedef %s %s;" % (wrapped_type, typename), file=handle) + wrapped_type = interrogate_type_wrapped_type(type) + if interrogate_type_is_global(wrapped_type): + wrapped_type_name = translated_type_name(wrapped_type) + print("typedef %s %s;" % (wrapped_type_name, typename), file=handle) return else: if interrogate_type_is_struct(type): @@ -249,6 +259,7 @@ def processType(handle, type): print("};", file=handle) def processModule(handle, package): + print("Processing module %s" % (package)) print("namespace %s {" % package, file=handle) if package != "core": @@ -280,22 +291,39 @@ def processModule(handle, package): if __name__ == "__main__": handle = open("pandadoc.hpp", "w") + mainpage = MAINPAGE.strip() + if mainpage: + print("/**\n * " + mainpage.replace('\n', '\n * ') + '\n */', file=handle) + print(comment("Panda3D modules that are implemented in C++."), file=handle) print("namespace panda3d {", file=handle) # Determine the path to the interrogatedb files - interrogate_add_search_directory(os.path.join(os.path.dirname(pandac.__file__), "..", "..", "etc")) - interrogate_add_search_directory(os.path.join(os.path.dirname(pandac.__file__), "input")) + pandac = os.path.dirname(pandac.__file__) + interrogate_add_search_directory(os.path.join(pandac, "..", "..", "etc")) + interrogate_add_search_directory(os.path.join(pandac, "input")) import panda3d.core processModule(handle, "core") + # Determine the suffix for the extension modules. + if sys.version_info >= (3, 0): + import _imp + ext_suffix = _imp.extension_suffixes()[0] + elif sys.platform == "win32": + ext_suffix = ".pyd" + else: + ext_suffix = ".so" + for lib in os.listdir(os.path.dirname(panda3d.__file__)): - if lib.endswith(('.pyd', '.so')) and not lib.startswith('core.'): - module_name = os.path.splitext(lib)[0] + if lib.endswith(ext_suffix) and not lib.startswith('core.'): + module_name = lib[:-len(ext_suffix)] __import__("panda3d." + module_name) processModule(handle, module_name) - print("}", file=handle) handle.close() + + print("Wrote output to pandadoc.hpp. You can now run:") + print() + print(" doxygen built/direct/directscripts/Doxyfile.python") From d28e99db82660e2eef8ab8c531ca129b5fa37e6c Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 23 Dec 2018 16:14:28 +0100 Subject: [PATCH 17/33] directscripts: some fixes for C++ API reference --- direct/src/directscripts/Doxyfile.cxx | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/direct/src/directscripts/Doxyfile.cxx b/direct/src/directscripts/Doxyfile.cxx index 8b4fda2230..7aec9a9d3d 100644 --- a/direct/src/directscripts/Doxyfile.cxx +++ b/direct/src/directscripts/Doxyfile.cxx @@ -797,7 +797,15 @@ EXCLUDE = dtool/src/parser-inc \ panda/src/linmath/fltnames.h \ panda/src/linmath/dblnames.h \ panda/src/linmath/dbl2fltnames.h \ - panda/src/linmath/flt2dblnames.h + panda/src/linmath/flt2dblnames.h \ + panda/src/android \ + panda/src/iphone \ + panda/src/tinydisplay \ + panda/src/movies/dr_flac.h \ + dtool/src/dtoolbase/pdtoa.cxx \ + dtool/src/dtoolutil/panda_getopt_long.h \ + dtool/src/dtoolutil/panda_getopt_impl.h \ + dtool/src/dtoolutil/panda_getopt_impl.cxx # The EXCLUDE_SYMLINKS tag can be used to select whether or not files or # directories that are symbolic links (a Unix file system feature) are excluded @@ -1972,7 +1980,13 @@ PREDEFINED = TVOLATILE= \ EXTEND= \ ALLOC_DELETED_CHAIN(x)= \ BLOCKING= \ - TYPENAME=typename + TYPENAME=typename \ + MAKE_PROPERTY(x)= \ + MAKE_PROPERTY2(x)= \ + MAKE_SEQ(x)= \ + MAKE_SEQ_PROPERTY(x)= \ + MAKE_MAP_PROPERTY(x)= \ + MAKE_MAP_KEYS_SEQ(x)= # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then this # tag can be used to specify a list of macro names that should be expanded. The From 729a2364bcff2ebdee3b271657f0f5fca5aaac72 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 23 Dec 2018 16:25:29 +0100 Subject: [PATCH 18/33] windisplay: remove unused WHQL stuff --- panda/src/windisplay/winDetectDx.h | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/panda/src/windisplay/winDetectDx.h b/panda/src/windisplay/winDetectDx.h index df7d89f0ff..4b979de6f0 100644 --- a/panda/src/windisplay/winDetectDx.h +++ b/panda/src/windisplay/winDetectDx.h @@ -21,18 +21,6 @@ typedef struct { } DISPLAY_FORMAT; -typedef union -{ - struct - { - unsigned int day : 8; - unsigned int month : 8; - unsigned int year : 16; - }; - DWORD whql; -} -WHQL; - static DISPLAY_FORMAT display_format_array [ ] = { D3DFMT_X8R8G8B8, 32, FALSE, D3DFMT_R5G6B5, 16, FALSE, @@ -321,14 +309,6 @@ static int get_display_information (DisplaySearchParameters &display_search_para if (debug) { printf ("DRIVER VERSION: %d.%d.%d.%d \n", product, version, sub_version, build); } - - WHQL whql; - - whql.whql= d3d_adapter_identifier.WHQLLevel; - - if (debug) { - printf ("WHQL: %d %d %d \n", whql.day, whql.day, whql.year); - } } if (direct_3d -> GetDeviceCaps (adapter, device_type, &d3d_caps) == D3D_OK) { From b40ecd6c51bdc569f1bfd1ea6af55f9a04da8554 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 23 Dec 2018 16:27:08 +0100 Subject: [PATCH 19/33] general: fix some old-style docstring comment blocks --- panda/src/dxml/config_dxml.cxx | 47 +++++++++++++++------------------- panda/src/pgraph/camera.cxx | 11 +++----- 2 files changed, 24 insertions(+), 34 deletions(-) diff --git a/panda/src/dxml/config_dxml.cxx b/panda/src/dxml/config_dxml.cxx index bbc119cb14..8cb75706f9 100644 --- a/panda/src/dxml/config_dxml.cxx +++ b/panda/src/dxml/config_dxml.cxx @@ -30,14 +30,12 @@ ConfigureFn(config_dxml) { init_libdxml(); } -//////////////////////////////////////////////////////////////////// -// Function: init_libdxml -// Description: Initializes the library. This must be called at -// least once before any of the functions or classes in -// this library can be used. Normally it will be -// called by the static initializers and need not be -// called explicitly, but special cases exist. -//////////////////////////////////////////////////////////////////// +/** + * Initializes the library. This must be called at least once before any of + * the functions or classes in this library can be used. Normally it will be + * called by the static initializers and need not be called explicitly, but + * special cases exist. + */ void init_libdxml() { static bool initialized = false; @@ -48,11 +46,10 @@ init_libdxml() { } BEGIN_PUBLISH -//////////////////////////////////////////////////////////////////// -// Function: read_xml_stream -// Description: Reads an XML document from the indicated stream. -// Returns the document, or NULL on error. -//////////////////////////////////////////////////////////////////// +/** + * Reads an XML document from the indicated stream. + * @returns the document, or NULL on error. + */ TiXmlDocument * read_xml_stream(std::istream &in) { TiXmlDocument *doc = new TiXmlDocument; @@ -67,10 +64,9 @@ read_xml_stream(std::istream &in) { END_PUBLISH BEGIN_PUBLISH -//////////////////////////////////////////////////////////////////// -// Function: write_xml_stream -// Description: Writes an XML document to the indicated stream. -//////////////////////////////////////////////////////////////////// +/** + * Writes an XML document to the indicated stream. + */ void write_xml_stream(std::ostream &out, TiXmlDocument *doc) { out << *doc; @@ -78,10 +74,9 @@ write_xml_stream(std::ostream &out, TiXmlDocument *doc) { END_PUBLISH BEGIN_PUBLISH -//////////////////////////////////////////////////////////////////// -// Function: print_xml -// Description: Writes an XML object to stdout, with formatting. -//////////////////////////////////////////////////////////////////// +/** + * Writes an XML object to stdout, with formatting. + */ void print_xml(TiXmlNode *xnode) { xnode->Print(stdout, 0); @@ -89,12 +84,10 @@ print_xml(TiXmlNode *xnode) { END_PUBLISH BEGIN_PUBLISH -//////////////////////////////////////////////////////////////////// -// Function: print_xml_to_file -// Description: Writes an XML object to the indicated file, with -// formatting. Unfortunately the VFS cannot be -// supported; the file must be a real filename on disk. -//////////////////////////////////////////////////////////////////// +/** + * Writes an XML object to the indicated file, with formatting. Unfortunately + * the VFS cannot be supported; the file must be a real filename on disk. + */ void print_xml_to_file(const Filename &filename, TiXmlNode *xnode) { std::string os_name = filename.to_os_specific(); diff --git a/panda/src/pgraph/camera.cxx b/panda/src/pgraph/camera.cxx index 5a10d6145e..ddf8006862 100644 --- a/panda/src/pgraph/camera.cxx +++ b/panda/src/pgraph/camera.cxx @@ -280,13 +280,10 @@ write_datagram(BamWriter *manager, Datagram &dg) { } } -//////////////////////////////////////////////////////////////////// -// Function: Camera::complete_pointers -// Access: Public, Virtual -// Description: Receives an array of pointers, one for each time -// manager->read_pointer() was called in fillin(). -// Returns the number of pointers processed. -//////////////////////////////////////////////////////////////////// +/** + * Receives an array of pointers, one for each time manager->read_pointer() + * was called in fillin(). Returns the number of pointers processed. + */ int Camera:: complete_pointers(TypedWritable **p_list, BamReader *manager) { int pi = LensNode::complete_pointers(p_list, manager); From bd6ef2b0ea2832ff1095f9e41b3137452f0619f4 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 23 Dec 2018 19:44:53 +0100 Subject: [PATCH 20/33] Rename CollisionTube to CollisionCapsule (bam 6.44) Adds ability to register "obsolete" names for certain types under older .bam versions, so that we are still able to write out old .bam files. Fixes #347 --- makepanda/makepanda.vcproj | 6 +- panda/src/bullet/bulletBodyNode.cxx | 12 +- panda/src/bullet/bulletCapsuleShape.cxx | 10 +- panda/src/bullet/bulletCapsuleShape.h | 4 +- panda/src/collide/collisionBox.cxx | 20 +-- panda/src/collide/collisionBox.h | 2 +- .../{collisionTube.I => collisionCapsule.I} | 38 ++--- ...collisionTube.cxx => collisionCapsule.cxx} | 148 +++++++++--------- .../{collisionTube.h => collisionCapsule.h} | 42 +++-- .../collide/collisionHandlerFluidPusher.cxx | 2 +- panda/src/collide/collisionPlane.cxx | 22 +-- panda/src/collide/collisionPlane.h | 2 +- panda/src/collide/collisionSolid.cxx | 8 +- panda/src/collide/collisionSolid.h | 4 +- panda/src/collide/collisionSphere.cxx | 20 +-- panda/src/collide/collisionSphere.h | 2 +- panda/src/collide/collisionTraverser.cxx | 4 +- panda/src/collide/config_collide.cxx | 10 +- panda/src/collide/p3collide_composite1.cxx | 3 +- panda/src/collide/p3collide_composite2.cxx | 3 +- panda/src/display/graphicsEngine.cxx | 8 +- panda/src/display/graphicsEngine.h | 4 +- panda/src/doc/collisionFlags.txt | 2 +- panda/src/egg/eggGroup.cxx | 3 +- panda/src/egg2pg/eggLoader.cxx | 20 +-- panda/src/egg2pg/eggLoader.h | 4 +- panda/src/egg2pg/eggSaver.cxx | 30 ++-- panda/src/putil/bam.h | 3 +- panda/src/putil/bamWriter.cxx | 67 +++++++- panda/src/putil/bamWriter.h | 4 + pandatool/src/eggprogs/eggMakeTube.cxx | 2 +- pandatool/src/eggprogs/eggMakeTube.h | 2 +- tests/collide/test_collision_tube.py | 63 ++++++++ 33 files changed, 360 insertions(+), 214 deletions(-) rename panda/src/collide/{collisionTube.I => collisionCapsule.I} (70%) rename panda/src/collide/{collisionTube.cxx => collisionCapsule.cxx} (89%) rename panda/src/collide/{collisionTube.h => collisionCapsule.h} (81%) create mode 100644 tests/collide/test_collision_tube.py diff --git a/makepanda/makepanda.vcproj b/makepanda/makepanda.vcproj index ad7f219650..03324fb60e 100644 --- a/makepanda/makepanda.vcproj +++ b/makepanda/makepanda.vcproj @@ -1043,7 +1043,7 @@ - + @@ -1054,7 +1054,7 @@ - + @@ -1089,7 +1089,7 @@ - + diff --git a/panda/src/bullet/bulletBodyNode.cxx b/panda/src/bullet/bulletBodyNode.cxx index 81a056adc2..cb9d7ed9c0 100644 --- a/panda/src/bullet/bulletBodyNode.cxx +++ b/panda/src/bullet/bulletBodyNode.cxx @@ -28,7 +28,7 @@ #include "collisionPlane.h" #include "collisionSphere.h" #include "collisionPolygon.h" -#include "collisionTube.h" +#include "collisionCapsule.h" TypeHandle BulletBodyNode::_type_handle; @@ -813,12 +813,12 @@ add_shapes_from_collision_solids(CollisionNode *cnode) { do_add_shape(BulletBoxShape::make_from_solid(box), ts); } - // CollisionTube - else if (CollisionTube::get_class_type() == type) { - CPT(CollisionTube) tube = DCAST(CollisionTube, solid); - CPT(TransformState) ts = TransformState::make_pos((tube->get_point_b() + tube->get_point_a()) / 2.0); + // CollisionCapsule + else if (CollisionCapsule::get_class_type() == type) { + CPT(CollisionCapsule) capsule = DCAST(CollisionCapsule, solid); + CPT(TransformState) ts = TransformState::make_pos((capsule->get_point_b() + capsule->get_point_a()) / 2.0); - do_add_shape(BulletCapsuleShape::make_from_solid(tube), ts); + do_add_shape(BulletCapsuleShape::make_from_solid(capsule), ts); } // CollisionPlane diff --git a/panda/src/bullet/bulletCapsuleShape.cxx b/panda/src/bullet/bulletCapsuleShape.cxx index 0bdb1284dc..cde5e64050 100644 --- a/panda/src/bullet/bulletCapsuleShape.cxx +++ b/panda/src/bullet/bulletCapsuleShape.cxx @@ -87,16 +87,16 @@ ptr() const { /** * Constructs a new BulletCapsuleShape using the information from a - * CollisionTube from the builtin collision system. + * CollisionCapsule from the builtin collision system. */ BulletCapsuleShape *BulletCapsuleShape:: -make_from_solid(const CollisionTube *solid) { - +make_from_solid(const CollisionCapsule *solid) { + PN_stdfloat radius = solid->get_radius(); - // Get tube's cylinder height: length from point A to point B + // Get capsule's cylinder height: length from point A to point B PN_stdfloat height = (solid->get_point_b() - solid->get_point_a()).length(); - // CollisionTubes are always Z-Up. + // CollisionCapsules are always Z-Up. return new BulletCapsuleShape(radius, height, Z_up); } diff --git a/panda/src/bullet/bulletCapsuleShape.h b/panda/src/bullet/bulletCapsuleShape.h index f8eecfe3d7..e78b06bc08 100644 --- a/panda/src/bullet/bulletCapsuleShape.h +++ b/panda/src/bullet/bulletCapsuleShape.h @@ -20,7 +20,7 @@ #include "bullet_utils.h" #include "bulletShape.h" -#include "collisionTube.h" +#include "collisionCapsule.h" /** * @@ -35,7 +35,7 @@ PUBLISHED: BulletCapsuleShape(const BulletCapsuleShape ©); INLINE ~BulletCapsuleShape(); - static BulletCapsuleShape *make_from_solid(const CollisionTube *solid); + static BulletCapsuleShape *make_from_solid(const CollisionCapsule *solid); INLINE PN_stdfloat get_radius() const; INLINE PN_stdfloat get_half_height() const; diff --git a/panda/src/collide/collisionBox.cxx b/panda/src/collide/collisionBox.cxx index a8af257456..8528e7bc27 100644 --- a/panda/src/collide/collisionBox.cxx +++ b/panda/src/collide/collisionBox.cxx @@ -16,7 +16,7 @@ #include "collisionRay.h" #include "collisionSphere.h" #include "collisionSegment.h" -#include "collisionTube.h" +#include "collisionCapsule.h" #include "collisionHandler.h" #include "collisionEntry.h" #include "config_collide.h" @@ -547,19 +547,19 @@ test_intersection_from_segment(const CollisionEntry &entry) const { } /** - * Double dispatch point for tube as a FROM object + * Double dispatch point for capsule as a FROM object */ PT(CollisionEntry) CollisionBox:: -test_intersection_from_tube(const CollisionEntry &entry) const { - const CollisionTube *tube; - DCAST_INTO_R(tube, entry.get_from(), nullptr); +test_intersection_from_capsule(const CollisionEntry &entry) const { + const CollisionCapsule *capsule; + DCAST_INTO_R(capsule, entry.get_from(), nullptr); const LMatrix4 &wrt_mat = entry.get_wrt_mat(); - LPoint3 from_a = tube->get_point_a() * wrt_mat; - LPoint3 from_b = tube->get_point_b() * wrt_mat; + LPoint3 from_a = capsule->get_point_a() * wrt_mat; + LPoint3 from_b = capsule->get_point_b() * wrt_mat; LVector3 from_direction = from_b - from_a; - PN_stdfloat radius_sq = wrt_mat.xform_vec(LVector3(0, 0, tube->get_radius())).length_squared(); + PN_stdfloat radius_sq = wrt_mat.xform_vec(LVector3(0, 0, capsule->get_radius())).length_squared(); PN_stdfloat radius = csqrt(radius_sq); LPoint3 box_min = get_min(); @@ -620,7 +620,7 @@ test_intersection_from_tube(const CollisionEntry &entry) const { LVector3 delta(0); delta[edges[i].axis] = dimensions[edges[i].axis]; double u1, u2; - CollisionTube::calc_closest_segment_points(u1, u2, from_a, from_direction, vertex, delta); + CollisionCapsule::calc_closest_segment_points(u1, u2, from_a, from_direction, vertex, delta); PN_stdfloat dist_sq = ((from_a + from_direction * u1) - (vertex + delta * u2)).length_squared(); if (dist_sq < best_dist_sq) { best_dist_sq = dist_sq; @@ -682,7 +682,7 @@ test_intersection_from_tube(const CollisionEntry &entry) const { new_entry->set_interior_point(point - interior_vec * radius); new_entry->set_surface_point(surface_point); - if (has_effective_normal() && tube->get_respect_effective_normal()) { + if (has_effective_normal() && capsule->get_respect_effective_normal()) { new_entry->set_surface_normal(get_effective_normal()); } else { new_entry->set_surface_normal(normal); diff --git a/panda/src/collide/collisionBox.h b/panda/src/collide/collisionBox.h index cf9e8bc15b..db9d2c2aa9 100644 --- a/panda/src/collide/collisionBox.h +++ b/panda/src/collide/collisionBox.h @@ -82,7 +82,7 @@ protected: virtual PT(CollisionEntry) test_intersection_from_segment(const CollisionEntry &entry) const; virtual PT(CollisionEntry) - test_intersection_from_tube(const CollisionEntry &entry) const; + test_intersection_from_capsule(const CollisionEntry &entry) const; virtual PT(CollisionEntry) test_intersection_from_box(const CollisionEntry &entry) const; diff --git a/panda/src/collide/collisionTube.I b/panda/src/collide/collisionCapsule.I similarity index 70% rename from panda/src/collide/collisionTube.I rename to panda/src/collide/collisionCapsule.I index 53e0f4cff6..78b8c3559b 100644 --- a/panda/src/collide/collisionTube.I +++ b/panda/src/collide/collisionCapsule.I @@ -6,7 +6,7 @@ * license. You should have received a copy of this license along * with this source code in a file named "LICENSE." * - * @file collisionTube.I + * @file collisionCapsule.I * @author drose * @date 2003-09-25 */ @@ -14,8 +14,8 @@ /** * */ -INLINE CollisionTube:: -CollisionTube(const LPoint3 &a, const LPoint3 &b, PN_stdfloat radius) : +INLINE CollisionCapsule:: +CollisionCapsule(const LPoint3 &a, const LPoint3 &b, PN_stdfloat radius) : _a(a), _b(b), _radius(radius) { recalc_internals(); @@ -25,8 +25,8 @@ CollisionTube(const LPoint3 &a, const LPoint3 &b, PN_stdfloat radius) : /** * */ -INLINE CollisionTube:: -CollisionTube(PN_stdfloat ax, PN_stdfloat ay, PN_stdfloat az, +INLINE CollisionCapsule:: +CollisionCapsule(PN_stdfloat ax, PN_stdfloat ay, PN_stdfloat az, PN_stdfloat bx, PN_stdfloat by, PN_stdfloat bz, PN_stdfloat radius) : _a(ax, ay, az), _b(bx, by, bz), _radius(radius) @@ -36,17 +36,17 @@ CollisionTube(PN_stdfloat ax, PN_stdfloat ay, PN_stdfloat az, } /** - * Creates an invalid tube. Only used when reading from a bam file. + * Creates an invalid capsule. Only used when reading from a bam file. */ -INLINE CollisionTube:: -CollisionTube() { +INLINE CollisionCapsule:: +CollisionCapsule() { } /** * */ -INLINE CollisionTube:: -CollisionTube(const CollisionTube ©) : +INLINE CollisionCapsule:: +CollisionCapsule(const CollisionCapsule ©) : CollisionSolid(copy), _a(copy._a), _b(copy._b), @@ -58,7 +58,7 @@ CollisionTube(const CollisionTube ©) : /** * Flushes the PStatCollectors used during traversal. */ -INLINE void CollisionTube:: +INLINE void CollisionCapsule:: flush_level() { _volume_pcollector.flush_level(); _test_pcollector.flush_level(); @@ -67,7 +67,7 @@ flush_level() { /** * */ -INLINE void CollisionTube:: +INLINE void CollisionCapsule:: set_point_a(const LPoint3 &a) { _a = a; recalc_internals(); @@ -76,7 +76,7 @@ set_point_a(const LPoint3 &a) { /** * */ -INLINE void CollisionTube:: +INLINE void CollisionCapsule:: set_point_a(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) { set_point_a(LPoint3(x, y, z)); } @@ -84,7 +84,7 @@ set_point_a(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) { /** * */ -INLINE const LPoint3 &CollisionTube:: +INLINE const LPoint3 &CollisionCapsule:: get_point_a() const { return _a; } @@ -92,7 +92,7 @@ get_point_a() const { /** * */ -INLINE void CollisionTube:: +INLINE void CollisionCapsule:: set_point_b(const LPoint3 &b) { _b = b; recalc_internals(); @@ -101,7 +101,7 @@ set_point_b(const LPoint3 &b) { /** * */ -INLINE void CollisionTube:: +INLINE void CollisionCapsule:: set_point_b(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) { set_point_b(LPoint3(x, y, z)); } @@ -109,7 +109,7 @@ set_point_b(PN_stdfloat x, PN_stdfloat y, PN_stdfloat z) { /** * */ -INLINE const LPoint3 &CollisionTube:: +INLINE const LPoint3 &CollisionCapsule:: get_point_b() const { return _b; } @@ -117,7 +117,7 @@ get_point_b() const { /** * */ -INLINE void CollisionTube:: +INLINE void CollisionCapsule:: set_radius(PN_stdfloat radius) { nassertv(radius >= 0.0f); _radius = radius; @@ -131,7 +131,7 @@ set_radius(PN_stdfloat radius) { /** * */ -INLINE PN_stdfloat CollisionTube:: +INLINE PN_stdfloat CollisionCapsule:: get_radius() const { return _radius; } diff --git a/panda/src/collide/collisionTube.cxx b/panda/src/collide/collisionCapsule.cxx similarity index 89% rename from panda/src/collide/collisionTube.cxx rename to panda/src/collide/collisionCapsule.cxx index 90f82a3630..91ab319735 100644 --- a/panda/src/collide/collisionTube.cxx +++ b/panda/src/collide/collisionCapsule.cxx @@ -6,12 +6,12 @@ * license. You should have received a copy of this license along * with this source code in a file named "LICENSE." * - * @file collisionTube.cxx + * @file collisionCapsule.cxx * @author drose * @date 2003-09-25 */ -#include "collisionTube.h" +#include "collisionCapsule.h" #include "collisionSphere.h" #include "collisionLine.h" #include "collisionRay.h" @@ -35,30 +35,30 @@ #include "geomVertexWriter.h" #include "boundingSphere.h" -PStatCollector CollisionTube::_volume_pcollector("Collision Volumes:CollisionTube"); -PStatCollector CollisionTube::_test_pcollector("Collision Tests:CollisionTube"); -TypeHandle CollisionTube::_type_handle; +PStatCollector CollisionCapsule::_volume_pcollector("Collision Volumes:CollisionCapsule"); +PStatCollector CollisionCapsule::_test_pcollector("Collision Tests:CollisionCapsule"); +TypeHandle CollisionCapsule::_type_handle; /** * */ -CollisionSolid *CollisionTube:: +CollisionSolid *CollisionCapsule:: make_copy() { - return new CollisionTube(*this); + return new CollisionCapsule(*this); } /** * */ -PT(CollisionEntry) CollisionTube:: +PT(CollisionEntry) CollisionCapsule:: test_intersection(const CollisionEntry &entry) const { - return entry.get_into()->test_intersection_from_tube(entry); + return entry.get_into()->test_intersection_from_capsule(entry); } /** * Transforms the solid by the indicated matrix. */ -void CollisionTube:: +void CollisionCapsule:: xform(const LMatrix4 &mat) { _a = _a * mat; _b = _b * mat; @@ -77,7 +77,7 @@ xform(const LMatrix4 &mat) { * collision purposes. The closest intersection point to this origin point is * considered to be the most significant. */ -LPoint3 CollisionTube:: +LPoint3 CollisionCapsule:: get_collision_origin() const { return get_point_a(); } @@ -86,7 +86,7 @@ get_collision_origin() const { * Returns a PStatCollector that is used to count the number of bounding * volume tests made against a solid of this type in a given frame. */ -PStatCollector &CollisionTube:: +PStatCollector &CollisionCapsule:: get_volume_pcollector() { return _volume_pcollector; } @@ -95,7 +95,7 @@ get_volume_pcollector() { * Returns a PStatCollector that is used to count the number of intersection * tests made against a solid of this type in a given frame. */ -PStatCollector &CollisionTube:: +PStatCollector &CollisionCapsule:: get_test_pcollector() { return _test_pcollector; } @@ -103,15 +103,15 @@ get_test_pcollector() { /** * */ -void CollisionTube:: +void CollisionCapsule:: output(std::ostream &out) const { - out << "tube, a (" << _a << "), b (" << _b << "), r " << _radius; + out << "capsule, a (" << _a << "), b (" << _b << "), r " << _radius; } /** * */ -PT(BoundingVolume) CollisionTube:: +PT(BoundingVolume) CollisionCapsule:: compute_internal_bounds() const { PT(BoundingVolume) bound = CollisionSolid::compute_internal_bounds(); @@ -143,7 +143,7 @@ compute_internal_bounds() const { /** * */ -PT(CollisionEntry) CollisionTube:: +PT(CollisionEntry) CollisionCapsule:: test_intersection_from_sphere(const CollisionEntry &entry) const { const CollisionSphere *sphere; DCAST_INTO_R(sphere, entry.get_from(), nullptr); @@ -160,7 +160,7 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { PN_stdfloat actual_t = 0.0f; if (wrt_prev_space != wrt_space) { - // If the sphere is moving relative to the tube, it becomes a tube itself. + // If the sphere is moving relative to the capsule, it becomes a capsule itself. from_a = sphere->get_center() * wrt_prev_space->get_mat(); } @@ -195,11 +195,11 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { LPoint3 into_intersection_point; if (t2 > 1.0) { - // Point b is within the tube. The first intersection point is point b + // Point b is within the capsule. The first intersection point is point b // itself. into_intersection_point = from_b; } else { - // Point b is outside the tube, and point a is either inside the tube or + // Point b is outside the capsule, and point a is either inside the capsule or // beyond it. The first intersection point is at t2. into_intersection_point = from_a + t2 * from_direction; } @@ -221,7 +221,7 @@ test_intersection_from_sphere(const CollisionEntry &entry) const { /** * */ -PT(CollisionEntry) CollisionTube:: +PT(CollisionEntry) CollisionCapsule:: test_intersection_from_line(const CollisionEntry &entry) const { const CollisionLine *line; DCAST_INTO_R(line, entry.get_from(), nullptr); @@ -269,7 +269,7 @@ test_intersection_from_line(const CollisionEntry &entry) const { /** * */ -PT(CollisionEntry) CollisionTube:: +PT(CollisionEntry) CollisionCapsule:: test_intersection_from_ray(const CollisionEntry &entry) const { const CollisionRay *ray; DCAST_INTO_R(ray, entry.get_from(), nullptr); @@ -299,11 +299,11 @@ test_intersection_from_ray(const CollisionEntry &entry) const { LPoint3 into_intersection_point; if (t1 < 0.0) { - // Point a is within the tube. The first intersection point is point a + // Point a is within the capsule. The first intersection point is point a // itself. into_intersection_point = from_origin; } else { - // Point a is outside the tube. The first intersection point is at t1. + // Point a is outside the capsule. The first intersection point is at t1. into_intersection_point = from_origin + t1 * from_direction; } set_intersection_point(new_entry, into_intersection_point, 0.0); @@ -330,7 +330,7 @@ test_intersection_from_ray(const CollisionEntry &entry) const { /** * */ -PT(CollisionEntry) CollisionTube:: +PT(CollisionEntry) CollisionCapsule:: test_intersection_from_segment(const CollisionEntry &entry) const { const CollisionSegment *segment; DCAST_INTO_R(segment, entry.get_from(), nullptr); @@ -362,11 +362,11 @@ test_intersection_from_segment(const CollisionEntry &entry) const { LPoint3 into_intersection_point; if (t1 < 0.0) { - // Point a is within the tube. The first intersection point is point a + // Point a is within the capsule. The first intersection point is point a // itself. into_intersection_point = from_a; } else { - // Point a is outside the tube, and point b is either inside the tube or + // Point a is outside the capsule, and point b is either inside the capsule or // beyond it. The first intersection point is at t1. into_intersection_point = from_a + t1 * from_direction; } @@ -394,22 +394,22 @@ test_intersection_from_segment(const CollisionEntry &entry) const { /** * */ -PT(CollisionEntry) CollisionTube:: -test_intersection_from_tube(const CollisionEntry &entry) const { - const CollisionTube *tube; - DCAST_INTO_R(tube, entry.get_from(), nullptr); +PT(CollisionEntry) CollisionCapsule:: +test_intersection_from_capsule(const CollisionEntry &entry) const { + const CollisionCapsule *capsule; + DCAST_INTO_R(capsule, entry.get_from(), nullptr); LPoint3 into_a = _a; LVector3 into_direction = _b - into_a; const LMatrix4 &wrt_mat = entry.get_wrt_mat(); - LPoint3 from_a = tube->get_point_a() * wrt_mat; - LPoint3 from_b = tube->get_point_b() * wrt_mat; + LPoint3 from_a = capsule->get_point_a() * wrt_mat; + LPoint3 from_b = capsule->get_point_b() * wrt_mat; LVector3 from_direction = from_b - from_a; LVector3 from_radius_v = - LVector3(tube->get_radius(), 0.0f, 0.0f) * wrt_mat; + LVector3(capsule->get_radius(), 0.0f, 0.0f) * wrt_mat; PN_stdfloat from_radius = length(from_radius_v); // Determine the points on each segment with the smallest distance between. @@ -420,7 +420,7 @@ test_intersection_from_tube(const CollisionEntry &entry) const { LPoint3 into_closest = into_a + into_direction * into_t; LPoint3 from_closest = from_a + from_direction * from_t; - // If the distance is greater than the sum of tube radii, the test fails. + // If the distance is greater than the sum of capsule radii, the test fails. LVector3 closest_vec = from_closest - into_closest; PN_stdfloat distance = closest_vec.length(); if (distance > _radius + from_radius) { @@ -442,7 +442,7 @@ test_intersection_from_tube(const CollisionEntry &entry) const { new_entry->set_surface_point(into_closest + surface_normal * _radius); new_entry->set_interior_point(from_closest - surface_normal * from_radius); - if (has_effective_normal() && tube->get_respect_effective_normal()) { + if (has_effective_normal() && capsule->get_respect_effective_normal()) { new_entry->set_surface_normal(get_effective_normal()); } else if (distance != 0) { new_entry->set_surface_normal(surface_normal); @@ -458,7 +458,7 @@ test_intersection_from_tube(const CollisionEntry &entry) const { /** * */ -PT(CollisionEntry) CollisionTube:: +PT(CollisionEntry) CollisionCapsule:: test_intersection_from_parabola(const CollisionEntry &entry) const { const CollisionParabola *parabola; DCAST_INTO_R(parabola, entry.get_from(), nullptr); @@ -510,14 +510,14 @@ test_intersection_from_parabola(const CollisionEntry &entry) const { * Fills the _viz_geom GeomNode up with Geoms suitable for rendering this * solid. */ -void CollisionTube:: +void CollisionCapsule:: fill_viz_geom() { if (collide_cat.is_debug()) { collide_cat.debug() << "Recomputing viz for " << *this << "\n"; } - // Generate the vertices such that we draw a tube with one endpoint at (0, + // Generate the vertices such that we draw a capsule with one endpoint at (0, // 0, 0), and another at (0, length, 0). Then we'll rotate and translate it // into place with the appropriate look_at matrix. LVector3 direction = (_b - _a); @@ -576,9 +576,9 @@ fill_viz_geom() { /** * Should be called internally to recompute the matrix and length when the - * properties of the tube have changed. + * properties of the capsule have changed. */ -void CollisionTube:: +void CollisionCapsule:: recalc_internals() { LVector3 direction = (_b - _a); _length = direction.length(); @@ -595,7 +595,7 @@ recalc_internals() { * Calculates a particular vertex on the surface of the first endcap * hemisphere, for use in generating the viz geometry. */ -LVertex CollisionTube:: +LVertex CollisionCapsule:: calc_sphere1_vertex(int ri, int si, int num_rings, int num_slices) { PN_stdfloat r = (PN_stdfloat)ri / (PN_stdfloat)num_rings; PN_stdfloat s = (PN_stdfloat)si / (PN_stdfloat)num_slices; @@ -620,7 +620,7 @@ calc_sphere1_vertex(int ri, int si, int num_rings, int num_slices) { * Calculates a particular vertex on the surface of the second endcap * hemisphere, for use in generating the viz geometry. */ -LVertex CollisionTube:: +LVertex CollisionCapsule:: calc_sphere2_vertex(int ri, int si, int num_rings, int num_slices, PN_stdfloat length) { PN_stdfloat r = (PN_stdfloat)ri / (PN_stdfloat)num_rings; @@ -646,7 +646,7 @@ calc_sphere2_vertex(int ri, int si, int num_rings, int num_slices, * Given line segments s1 and s2 defined by two points each, computes the * point on each segment with the closest distance between them. */ -void CollisionTube:: +void CollisionCapsule:: calc_closest_segment_points(double &t1, double &t2, const LPoint3 &from1, const LVector3 &delta1, const LPoint3 &from2, const LVector3 &delta2) { @@ -717,18 +717,18 @@ calc_closest_segment_points(double &t1, double &t2, } /** - * Determine the point(s) of intersection of a parametric line with the tube. + * Determine the point(s) of intersection of a parametric line with the capsule. * The line is infinite in both directions, and passes through "from" and - * from+delta. If the line does not intersect the tube, the function returns - * false, and t1 and t2 are undefined. If it does intersect the tube, it + * from+delta. If the line does not intersect the capsule, the function returns + * false, and t1 and t2 are undefined. If it does intersect the capsule, it * returns true, and t1 and t2 are set to the points along the equation * from+t*delta that correspond to the two points of intersection. */ -bool CollisionTube:: +bool CollisionCapsule:: intersects_line(double &t1, double &t2, const LPoint3 &from0, const LVector3 &delta0, PN_stdfloat inflate_radius) const { - // Convert the line into our canonical coordinate space: the tube is aligned + // Convert the line into our canonical coordinate space: the capsule is aligned // with the y axis. LPoint3 from = from0 * _inv_mat; LVector3 delta = delta0 * _inv_mat; @@ -776,7 +776,7 @@ intersects_line(double &t1, double &t2, } } - // The point is within the tube! + // The point is within the capsule! t1 = t2 = 0.0; return true; } @@ -819,15 +819,15 @@ intersects_line(double &t1, double &t2, PN_stdfloat t2_y = from[1] + t2 * delta[1]; if (t1_y < -radius && t2_y < -radius) { - // Both points are way off the bottom of the tube; no intersection. + // Both points are way off the bottom of the capsule; no intersection. return false; } else if (t1_y > _length + radius && t2_y > _length + radius) { - // Both points are way off the top of the tube; no intersection. + // Both points are way off the top of the capsule; no intersection. return false; } if (t1_y < 0.0f) { - // The starting point is off the bottom of the tube. Test the line + // The starting point is off the bottom of the capsule. Test the line // against the first endcap. double t1a, t2a; if (!sphere_intersects_line(t1a, t2a, 0.0f, from, delta, radius)) { @@ -838,7 +838,7 @@ intersects_line(double &t1, double &t2, t1 = t1a; } else if (t1_y > _length) { - // The starting point is off the top of the tube. Test the line against + // The starting point is off the top of the capsule. Test the line against // the second endcap. double t1b, t2b; if (!sphere_intersects_line(t1b, t2b, _length, from, delta, radius)) { @@ -850,7 +850,7 @@ intersects_line(double &t1, double &t2, } if (t2_y < 0.0f) { - // The ending point is off the bottom of the tube. Test the line against + // The ending point is off the bottom of the capsule. Test the line against // the first endcap. double t1a, t2a; if (!sphere_intersects_line(t1a, t2a, 0.0f, from, delta, radius)) { @@ -861,7 +861,7 @@ intersects_line(double &t1, double &t2, t2 = t2a; } else if (t2_y > _length) { - // The ending point is off the top of the tube. Test the line against the + // The ending point is off the top of the capsule. Test the line against the // second endcap. double t1b, t2b; if (!sphere_intersects_line(t1b, t2b, _length, from, delta, radius)) { @@ -880,7 +880,7 @@ intersects_line(double &t1, double &t2, * whether it intersects one or the other endcaps. The y parameter specifies * the center of the sphere (and hence the particular endcap). */ -bool CollisionTube:: +bool CollisionCapsule:: sphere_intersects_line(double &t1, double &t2, PN_stdfloat center_y, const LPoint3 &from, const LVector3 &delta, PN_stdfloat radius) { @@ -917,14 +917,14 @@ sphere_intersects_line(double &t1, double &t2, PN_stdfloat center_y, } /** - * Determine a point of intersection of a parametric parabola with the tube. + * Determine a point of intersection of a parametric parabola with the capsule. * * We only consider the segment of the parabola between t1 and t2, which has * already been computed as corresponding to points p1 and p2. If there is an * intersection, t is set to the parametric point of intersection, and true is * returned; otherwise, false is returned. */ -bool CollisionTube:: +bool CollisionCapsule:: intersects_parabola(double &t, const LParabola ¶bola, double t1, double t2, const LPoint3 &p1, const LPoint3 &p2) const { @@ -965,11 +965,11 @@ intersects_parabola(double &t, const LParabola ¶bola, } /** - * Calculates a point that is exactly on the surface of the tube and its + * Calculates a point that is exactly on the surface of the capsule and its * corresponding normal, given a point that is supposedly on the surface of - * the tube. + * the capsule. */ -void CollisionTube:: +void CollisionCapsule:: calculate_surface_point_and_normal(const LPoint3 &surface_point, double extra_radius, LPoint3 &result_point, @@ -1015,7 +1015,7 @@ calculate_surface_point_and_normal(const LPoint3 &surface_point, * point in the CollisionEntry, and also compute the relevant normal based on * that point. */ -void CollisionTube:: +void CollisionCapsule:: set_intersection_point(CollisionEntry *new_entry, const LPoint3 &into_intersection_point, double extra_radius) const { @@ -1033,16 +1033,16 @@ set_intersection_point(CollisionEntry *new_entry, new_entry->set_surface_normal(normal); new_entry->set_surface_point(point); - // Also adjust the original point into the tube by the amount of - // extra_radius, which should put it on the surface of the tube if our + // Also adjust the original point into the capsule by the amount of + // extra_radius, which should put it on the surface of the capsule if our // collision was tangential. new_entry->set_interior_point(into_intersection_point - normal * extra_radius); } /** - * Tells the BamReader how to create objects of type CollisionTube. + * Tells the BamReader how to create objects of type CollisionCapsule. */ -void CollisionTube:: +void CollisionCapsule:: register_with_read_factory() { BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); } @@ -1051,7 +1051,7 @@ register_with_read_factory() { * Writes the contents of this object to the datagram for shipping out to a * Bam file. */ -void CollisionTube:: +void CollisionCapsule:: write_datagram(BamWriter *manager, Datagram &dg) { CollisionSolid::write_datagram(manager, dg); _a.write_datagram(dg); @@ -1061,12 +1061,12 @@ write_datagram(BamWriter *manager, Datagram &dg) { /** * This function is called by the BamReader's factory when a new object of - * type CollisionTube is encountered in the Bam file. It should create the - * CollisionTube and extract its information from the file. + * type CollisionCapsule is encountered in the Bam file. It should create the + * CollisionCapsule and extract its information from the file. */ -TypedWritable *CollisionTube:: +TypedWritable *CollisionCapsule:: make_from_bam(const FactoryParams ¶ms) { - CollisionTube *node = new CollisionTube(); + CollisionCapsule *node = new CollisionCapsule(); DatagramIterator scan; BamReader *manager; @@ -1078,9 +1078,9 @@ make_from_bam(const FactoryParams ¶ms) { /** * This internal function is called by make_from_bam to read in all of the - * relevant data from the BamFile for the new CollisionTube. + * relevant data from the BamFile for the new CollisionCapsule. */ -void CollisionTube:: +void CollisionCapsule:: fillin(DatagramIterator &scan, BamReader *manager) { CollisionSolid::fillin(scan, manager); _a.read_datagram(scan); diff --git a/panda/src/collide/collisionTube.h b/panda/src/collide/collisionCapsule.h similarity index 81% rename from panda/src/collide/collisionTube.h rename to panda/src/collide/collisionCapsule.h index 3d91ce2506..af5cbcc92d 100644 --- a/panda/src/collide/collisionTube.h +++ b/panda/src/collide/collisionCapsule.h @@ -6,38 +6,39 @@ * license. You should have received a copy of this license along * with this source code in a file named "LICENSE." * - * @file collisionTube.h + * @file collisionCapsule.h * @author drose * @date 2003-09-25 */ -#ifndef COLLISIONTUBE_H -#define COLLISIONTUBE_H +#ifndef COLLISIONCAPSULE_H +#define COLLISIONCAPSULE_H #include "pandabase.h" #include "collisionSolid.h" #include "parabola.h" /** - * This implements a solid roughly in cylindrical shape. It's not called a - * CollisionCylinder because it's not a true cylinder; specifically, it has - * rounded ends instead of flat ends. It looks more like a Contac pill. + * This implements a solid consisting of a cylinder with hemispherical endcaps, + * also known as a capsule or a spherocylinder. + * + * This shape was previously erroneously called CollisionTube. */ -class EXPCL_PANDA_COLLIDE CollisionTube : public CollisionSolid { +class EXPCL_PANDA_COLLIDE CollisionCapsule : public CollisionSolid { PUBLISHED: - INLINE explicit CollisionTube(const LPoint3 &a, const LPoint3 &db, - PN_stdfloat radius); - INLINE explicit CollisionTube(PN_stdfloat ax, PN_stdfloat ay, PN_stdfloat az, - PN_stdfloat bx, PN_stdfloat by, PN_stdfloat bz, - PN_stdfloat radius); + INLINE explicit CollisionCapsule(const LPoint3 &a, const LPoint3 &db, + PN_stdfloat radius); + INLINE explicit CollisionCapsule(PN_stdfloat ax, PN_stdfloat ay, PN_stdfloat az, + PN_stdfloat bx, PN_stdfloat by, PN_stdfloat bz, + PN_stdfloat radius); virtual LPoint3 get_collision_origin() const; private: - INLINE CollisionTube(); + INLINE CollisionCapsule(); public: - INLINE CollisionTube(const CollisionTube ©); + INLINE CollisionCapsule(const CollisionCapsule ©); virtual CollisionSolid *make_copy(); virtual PT(CollisionEntry) @@ -82,7 +83,7 @@ protected: virtual PT(CollisionEntry) test_intersection_from_segment(const CollisionEntry &entry) const; virtual PT(CollisionEntry) - test_intersection_from_tube(const CollisionEntry &entry) const; + test_intersection_from_capsule(const CollisionEntry &entry) const; virtual PT(CollisionEntry) test_intersection_from_parabola(const CollisionEntry &entry) const; @@ -141,7 +142,7 @@ public: } static void init_type() { CollisionSolid::init_type(); - register_type(_type_handle, "CollisionTube", + register_type(_type_handle, "CollisionCapsule", CollisionSolid::get_class_type()); } virtual TypeHandle get_type() const { @@ -155,6 +156,13 @@ private: friend class CollisionBox; }; -#include "collisionTube.I" +BEGIN_PUBLISH +/** + * Alias for backward compatibility. + */ +typedef CollisionCapsule CollisionTube; +END_PUBLISH + +#include "collisionCapsule.I" #endif diff --git a/panda/src/collide/collisionHandlerFluidPusher.cxx b/panda/src/collide/collisionHandlerFluidPusher.cxx index df15e8bacc..622f5da00d 100644 --- a/panda/src/collide/collisionHandlerFluidPusher.cxx +++ b/panda/src/collide/collisionHandlerFluidPusher.cxx @@ -72,7 +72,7 @@ handle_entries() { PosB = collider's current position M = movement vector (PosB - PosA) BV = bounding sphere that includes collider at PosA and PosB - CS = 'collision set', all 'collidables' within BV (collision polys, tubes, etc) + CS = 'collision set', all 'collidables' within BV (collision polys, capsules, etc) VARIABLES N = movement vector since most recent collision (or start of frame) diff --git a/panda/src/collide/collisionPlane.cxx b/panda/src/collide/collisionPlane.cxx index 8a325ea082..2e174d4aa8 100644 --- a/panda/src/collide/collisionPlane.cxx +++ b/panda/src/collide/collisionPlane.cxx @@ -18,7 +18,7 @@ #include "collisionLine.h" #include "collisionRay.h" #include "collisionSegment.h" -#include "collisionTube.h" +#include "collisionCapsule.h" #include "collisionParabola.h" #include "config_collide.h" #include "pointerToArray.h" @@ -298,16 +298,16 @@ test_intersection_from_segment(const CollisionEntry &entry) const { * */ PT(CollisionEntry) CollisionPlane:: -test_intersection_from_tube(const CollisionEntry &entry) const { - const CollisionTube *tube; - DCAST_INTO_R(tube, entry.get_from(), nullptr); +test_intersection_from_capsule(const CollisionEntry &entry) const { + const CollisionCapsule *capsule; + DCAST_INTO_R(capsule, entry.get_from(), nullptr); const LMatrix4 &wrt_mat = entry.get_wrt_mat(); - LPoint3 from_a = tube->get_point_a() * wrt_mat; - LPoint3 from_b = tube->get_point_b() * wrt_mat; + LPoint3 from_a = capsule->get_point_a() * wrt_mat; + LPoint3 from_b = capsule->get_point_b() * wrt_mat; LVector3 from_radius_v = - LVector3(tube->get_radius(), 0.0f, 0.0f) * wrt_mat; + LVector3(capsule->get_radius(), 0.0f, 0.0f) * wrt_mat; PN_stdfloat from_radius = length(from_radius_v); PN_stdfloat dist_a = _plane.dist_to_plane(from_a); @@ -325,7 +325,7 @@ test_intersection_from_tube(const CollisionEntry &entry) const { } PT(CollisionEntry) new_entry = new CollisionEntry(entry); - LVector3 normal = (has_effective_normal() && tube->get_respect_effective_normal()) ? get_effective_normal() : get_normal(); + LVector3 normal = (has_effective_normal() && capsule->get_respect_effective_normal()) ? get_effective_normal() : get_normal(); new_entry->set_surface_normal(normal); PN_stdfloat t; @@ -339,17 +339,17 @@ test_intersection_from_tube(const CollisionEntry &entry) const { new_entry->set_surface_point(from_a - get_normal() * dist_a); } else { - // Within the tube! Yay, that means we have a surface point. + // Within the capsule! Yay, that means we have a surface point. new_entry->set_surface_point(from_a + t * from_direction); } } else { // If it's completely parallel, pretend it's colliding in the center of - // the tube. + // the capsule. new_entry->set_surface_point(from_a + 0.5f * from_direction - get_normal() * dist_a); } if (IS_NEARLY_EQUAL(dist_a, dist_b)) { - // Let's be fair and choose the center of the tube. + // Let's be fair and choose the center of the capsule. new_entry->set_interior_point(from_a + 0.5f * from_direction - get_normal() * from_radius); } else if (dist_a < dist_b) { diff --git a/panda/src/collide/collisionPlane.h b/panda/src/collide/collisionPlane.h index bc7602ba8b..719e33f489 100644 --- a/panda/src/collide/collisionPlane.h +++ b/panda/src/collide/collisionPlane.h @@ -72,7 +72,7 @@ protected: virtual PT(CollisionEntry) test_intersection_from_segment(const CollisionEntry &entry) const; virtual PT(CollisionEntry) - test_intersection_from_tube(const CollisionEntry &entry) const; + test_intersection_from_capsule(const CollisionEntry &entry) const; virtual PT(CollisionEntry) test_intersection_from_parabola(const CollisionEntry &entry) const; virtual PT(CollisionEntry) diff --git a/panda/src/collide/collisionSolid.cxx b/panda/src/collide/collisionSolid.cxx index b862ec7c73..b68673be15 100644 --- a/panda/src/collide/collisionSolid.cxx +++ b/panda/src/collide/collisionSolid.cxx @@ -17,7 +17,7 @@ #include "collisionLine.h" #include "collisionRay.h" #include "collisionSegment.h" -#include "collisionTube.h" +#include "collisionCapsule.h" #include "collisionParabola.h" #include "collisionBox.h" #include "collisionEntry.h" @@ -240,11 +240,11 @@ test_intersection_from_segment(const CollisionEntry &) const { /** * This is part of the double-dispatch implementation of test_intersection(). - * It is called when the "from" object is a tube. + * It is called when the "from" object is a capsule. */ PT(CollisionEntry) CollisionSolid:: -test_intersection_from_tube(const CollisionEntry &) const { - report_undefined_intersection_test(CollisionTube::get_class_type(), +test_intersection_from_capsule(const CollisionEntry &) const { + report_undefined_intersection_test(CollisionCapsule::get_class_type(), get_type()); return nullptr; } diff --git a/panda/src/collide/collisionSolid.h b/panda/src/collide/collisionSolid.h index 6b2914e954..4721d70381 100644 --- a/panda/src/collide/collisionSolid.h +++ b/panda/src/collide/collisionSolid.h @@ -108,7 +108,7 @@ protected: virtual PT(CollisionEntry) test_intersection_from_segment(const CollisionEntry &entry) const; virtual PT(CollisionEntry) - test_intersection_from_tube(const CollisionEntry &entry) const; + test_intersection_from_capsule(const CollisionEntry &entry) const; virtual PT(CollisionEntry) test_intersection_from_parabola(const CollisionEntry &entry) const; virtual PT(CollisionEntry) @@ -177,7 +177,7 @@ private: friend class CollisionLine; friend class CollisionRay; friend class CollisionSegment; - friend class CollisionTube; + friend class CollisionCapsule; friend class CollisionParabola; friend class CollisionHandlerFluidPusher; friend class CollisionBox; diff --git a/panda/src/collide/collisionSphere.cxx b/panda/src/collide/collisionSphere.cxx index a07b1fbcbc..aacc43fcb2 100644 --- a/panda/src/collide/collisionSphere.cxx +++ b/panda/src/collide/collisionSphere.cxx @@ -17,7 +17,7 @@ #include "collisionHandler.h" #include "collisionEntry.h" #include "collisionSegment.h" -#include "collisionTube.h" +#include "collisionCapsule.h" #include "collisionParabola.h" #include "collisionBox.h" #include "config_collide.h" @@ -444,18 +444,18 @@ test_intersection_from_segment(const CollisionEntry &entry) const { * */ PT(CollisionEntry) CollisionSphere:: -test_intersection_from_tube(const CollisionEntry &entry) const { - const CollisionTube *tube; - DCAST_INTO_R(tube, entry.get_from(), nullptr); +test_intersection_from_capsule(const CollisionEntry &entry) const { + const CollisionCapsule *capsule; + DCAST_INTO_R(capsule, entry.get_from(), nullptr); const LMatrix4 &wrt_mat = entry.get_wrt_mat(); - LPoint3 from_a = tube->get_point_a() * wrt_mat; - LPoint3 from_b = tube->get_point_b() * wrt_mat; + LPoint3 from_a = capsule->get_point_a() * wrt_mat; + LPoint3 from_b = capsule->get_point_b() * wrt_mat; LVector3 from_direction = from_b - from_a; LVector3 from_radius_v = - LVector3(tube->get_radius(), 0.0f, 0.0f) * wrt_mat; + LVector3(capsule->get_radius(), 0.0f, 0.0f) * wrt_mat; PN_stdfloat from_radius = length(from_radius_v); double t1, t2; @@ -465,8 +465,8 @@ test_intersection_from_tube(const CollisionEntry &entry) const { } if (t2 < 0.0 || t1 > 1.0) { - // Both intersection points are before the start of the tube or after - // the end of the tube. + // Both intersection points are before the start of the capsule or after + // the end of the capsule. return nullptr; } @@ -487,7 +487,7 @@ test_intersection_from_tube(const CollisionEntry &entry) const { new_entry->set_surface_point(get_center() + normal * get_radius()); new_entry->set_interior_point(inner_point - normal * from_radius); - if (has_effective_normal() && tube->get_respect_effective_normal()) { + if (has_effective_normal() && capsule->get_respect_effective_normal()) { new_entry->set_surface_normal(get_effective_normal()); } else { new_entry->set_surface_normal(normal); diff --git a/panda/src/collide/collisionSphere.h b/panda/src/collide/collisionSphere.h index 8337644b42..39b21d59f1 100644 --- a/panda/src/collide/collisionSphere.h +++ b/panda/src/collide/collisionSphere.h @@ -72,7 +72,7 @@ protected: virtual PT(CollisionEntry) test_intersection_from_segment(const CollisionEntry &entry) const; virtual PT(CollisionEntry) - test_intersection_from_tube(const CollisionEntry &entry) const; + test_intersection_from_capsule(const CollisionEntry &entry) const; virtual PT(CollisionEntry) test_intersection_from_parabola(const CollisionEntry &entry) const; virtual PT(CollisionEntry) diff --git a/panda/src/collide/collisionTraverser.cxx b/panda/src/collide/collisionTraverser.cxx index 35f7966a3f..794e7552da 100644 --- a/panda/src/collide/collisionTraverser.cxx +++ b/panda/src/collide/collisionTraverser.cxx @@ -20,7 +20,7 @@ #include "collisionVisualizer.h" #include "collisionSphere.h" #include "collisionBox.h" -#include "collisionTube.h" +#include "collisionCapsule.h" #include "collisionPolygon.h" #include "collisionPlane.h" #include "config_collide.h" @@ -345,7 +345,7 @@ traverse(const NodePath &root) { _geom_volume_pcollector.flush_level(); CollisionSphere::flush_level(); - CollisionTube::flush_level(); + CollisionCapsule::flush_level(); CollisionPolygon::flush_level(); CollisionPlane::flush_level(); CollisionBox::flush_level(); diff --git a/panda/src/collide/config_collide.cxx b/panda/src/collide/config_collide.cxx index 38c821ed05..b9ca4e368a 100644 --- a/panda/src/collide/config_collide.cxx +++ b/panda/src/collide/config_collide.cxx @@ -13,6 +13,7 @@ #include "config_collide.h" #include "collisionBox.h" +#include "collisionCapsule.h" #include "collisionEntry.h" #include "collisionHandler.h" #include "collisionHandlerEvent.h" @@ -38,7 +39,6 @@ #include "collisionSolid.h" #include "collisionSphere.h" #include "collisionTraverser.h" -#include "collisionTube.h" #include "collisionVisualizer.h" #include "dconfig.h" @@ -126,6 +126,7 @@ init_libcollide() { initialized = true; CollisionBox::init_type(); + CollisionCapsule::init_type(); CollisionEntry::init_type(); CollisionHandler::init_type(); CollisionHandlerEvent::init_type(); @@ -150,14 +151,18 @@ init_libcollide() { CollisionSolid::init_type(); CollisionSphere::init_type(); CollisionTraverser::init_type(); - CollisionTube::init_type(); #ifdef DO_COLLISION_RECORDING CollisionRecorder::init_type(); CollisionVisualizer::init_type(); #endif + // Record the old name for CollisionCapsule for backwards compatibility. + BamWriter::record_obsolete_type_name(CollisionCapsule::get_class_type(), + "CollisionTube", 6, 44); + CollisionBox::register_with_read_factory(); + CollisionCapsule::register_with_read_factory(); CollisionInvSphere::register_with_read_factory(); CollisionLine::register_with_read_factory(); CollisionNode::register_with_read_factory(); @@ -168,5 +173,4 @@ init_libcollide() { CollisionRay::register_with_read_factory(); CollisionSegment::register_with_read_factory(); CollisionSphere::register_with_read_factory(); - CollisionTube::register_with_read_factory(); } diff --git a/panda/src/collide/p3collide_composite1.cxx b/panda/src/collide/p3collide_composite1.cxx index d66b71b18c..af8ecc07d8 100644 --- a/panda/src/collide/p3collide_composite1.cxx +++ b/panda/src/collide/p3collide_composite1.cxx @@ -1,5 +1,6 @@ #include "config_collide.cxx" #include "collisionBox.cxx" +#include "collisionCapsule.cxx" #include "collisionEntry.cxx" #include "collisionGeom.cxx" #include "collisionHandler.cxx" @@ -12,5 +13,3 @@ #include "collisionHandlerFluidPusher.cxx" #include "collisionHandlerQueue.cxx" #include "collisionInvSphere.cxx" -#include "collisionLevelStateBase.cxx" -#include "collisionLevelState.cxx" diff --git a/panda/src/collide/p3collide_composite2.cxx b/panda/src/collide/p3collide_composite2.cxx index 50a6acdddc..4b74e9dd9e 100644 --- a/panda/src/collide/p3collide_composite2.cxx +++ b/panda/src/collide/p3collide_composite2.cxx @@ -1,3 +1,5 @@ +#include "collisionLevelStateBase.cxx" +#include "collisionLevelState.cxx" #include "collisionLine.cxx" #include "collisionNode.cxx" #include "collisionParabola.cxx" @@ -10,5 +12,4 @@ #include "collisionSolid.cxx" #include "collisionSphere.cxx" #include "collisionTraverser.cxx" -#include "collisionTube.cxx" #include "collisionVisualizer.cxx" diff --git a/panda/src/display/graphicsEngine.cxx b/panda/src/display/graphicsEngine.cxx index c06c2b207f..ae1052ba1d 100644 --- a/panda/src/display/graphicsEngine.cxx +++ b/panda/src/display/graphicsEngine.cxx @@ -110,8 +110,8 @@ PStatCollector GraphicsEngine::_volume_sphere_pcollector("Collision Volumes:Coll PStatCollector GraphicsEngine::_test_sphere_pcollector("Collision Tests:CollisionSphere"); PStatCollector GraphicsEngine::_volume_box_pcollector("Collision Volumes:CollisionBox"); PStatCollector GraphicsEngine::_test_box_pcollector("Collision Tests:CollisionBox"); -PStatCollector GraphicsEngine::_volume_tube_pcollector("Collision Volumes:CollisionTube"); -PStatCollector GraphicsEngine::_test_tube_pcollector("Collision Tests:CollisionTube"); +PStatCollector GraphicsEngine::_volume_capsule_pcollector("Collision Volumes:CollisionCapsule"); +PStatCollector GraphicsEngine::_test_capsule_pcollector("Collision Tests:CollisionCapsule"); PStatCollector GraphicsEngine::_volume_inv_sphere_pcollector("Collision Volumes:CollisionInvSphere"); PStatCollector GraphicsEngine::_test_inv_sphere_pcollector("Collision Tests:CollisionInvSphere"); PStatCollector GraphicsEngine::_volume_geom_pcollector("Collision Volumes:CollisionGeom"); @@ -875,8 +875,8 @@ render_frame() { _test_sphere_pcollector.clear_level(); _volume_box_pcollector.clear_level(); _test_box_pcollector.clear_level(); - _volume_tube_pcollector.clear_level(); - _test_tube_pcollector.clear_level(); + _volume_capsule_pcollector.clear_level(); + _test_capsule_pcollector.clear_level(); _volume_inv_sphere_pcollector.clear_level(); _test_inv_sphere_pcollector.clear_level(); _volume_geom_pcollector.clear_level(); diff --git a/panda/src/display/graphicsEngine.h b/panda/src/display/graphicsEngine.h index 3371f20b39..e3e7df66c8 100644 --- a/panda/src/display/graphicsEngine.h +++ b/panda/src/display/graphicsEngine.h @@ -401,8 +401,8 @@ private: static PStatCollector _test_sphere_pcollector; static PStatCollector _volume_box_pcollector; static PStatCollector _test_box_pcollector; - static PStatCollector _volume_tube_pcollector; - static PStatCollector _test_tube_pcollector; + static PStatCollector _volume_capsule_pcollector; + static PStatCollector _test_capsule_pcollector; static PStatCollector _volume_inv_sphere_pcollector; static PStatCollector _test_inv_sphere_pcollector; static PStatCollector _volume_geom_pcollector; diff --git a/panda/src/doc/collisionFlags.txt b/panda/src/doc/collisionFlags.txt index 4989ef8e33..04a890f42b 100644 --- a/panda/src/doc/collisionFlags.txt +++ b/panda/src/doc/collisionFlags.txt @@ -6,7 +6,7 @@ camera-collide: for things that the camera should avoid trigger: for things (usually not barriers or floors) that should trigger an event when avatars intersect with them sphere: for things that should have a collision sphere around them -tube: for things that should have a collision tube (cylinder) around them +tube: for things that should have a collision capsule around them NOTES diff --git a/panda/src/egg/eggGroup.cxx b/panda/src/egg/eggGroup.cxx index 6bc6f152f0..fe36f2b123 100644 --- a/panda/src/egg/eggGroup.cxx +++ b/panda/src/egg/eggGroup.cxx @@ -897,7 +897,8 @@ string_cs_type(const string &strval) { } else if (cmp_nocase_uh(strval, "inv-sphere") == 0 || cmp_nocase_uh(strval, "invsphere") == 0) { return CST_inv_sphere; - } else if (cmp_nocase_uh(strval, "tube") == 0) { + } else if (cmp_nocase_uh(strval, "tube") == 0 || + cmp_nocase_uh(strval, "capsule") == 0) { return CST_tube; } else if (cmp_nocase_uh(strval, "floor-mesh") == 0 || cmp_nocase_uh(strval, "floormesh") == 0) { diff --git a/panda/src/egg2pg/eggLoader.cxx b/panda/src/egg2pg/eggLoader.cxx index 9d885e0234..6aeb84f54f 100644 --- a/panda/src/egg2pg/eggLoader.cxx +++ b/panda/src/egg2pg/eggLoader.cxx @@ -74,7 +74,7 @@ #include "collisionNode.h" #include "collisionSphere.h" #include "collisionInvSphere.h" -#include "collisionTube.h" +#include "collisionCapsule.h" #include "collisionPlane.h" #include "collisionPolygon.h" #include "collisionFloorMesh.h" @@ -2865,7 +2865,7 @@ make_collision_solids(EggGroup *start_group, EggGroup *egg_group, break; case EggGroup::CST_tube: - make_collision_tube(egg_group, cnode, start_group->get_collide_flags()); + make_collision_capsule(egg_group, cnode, start_group->get_collide_flags()); break; case EggGroup::CST_floor_mesh: @@ -3045,12 +3045,12 @@ make_collision_inv_sphere(EggGroup *egg_group, CollisionNode *cnode, } /** - * Creates a single CollisionTube corresponding to the polygons associated + * Creates a single CollisionCapsule corresponding to the polygons associated * with this group. */ void EggLoader:: -make_collision_tube(EggGroup *egg_group, CollisionNode *cnode, - EggGroup::CollideFlags flags) { +make_collision_capsule(EggGroup *egg_group, CollisionNode *cnode, + EggGroup::CollideFlags flags) { EggGroup *geom_group = find_collision_geometry(egg_group, flags); if (geom_group != nullptr) { // Collect all of the vertices. @@ -3175,7 +3175,7 @@ make_collision_tube(EggGroup *egg_group, CollisionNode *cnode, // Transform all of the points so that the major axis is along the Y // axis, and the origin is the center. This is very similar to the - // CollisionTube's idea of its canonical orientation (although not + // CollisionCapsule's idea of its canonical orientation (although not // exactly the same, since it is centered on the origin instead of // having point_a on the origin). It makes it easier to determine the // length and radius of the cylinder. @@ -3230,11 +3230,11 @@ make_collision_tube(EggGroup *egg_group, CollisionNode *cnode, LPoint3d point_a = center - half; LPoint3d point_b = center + half; - CollisionTube *cstube = - new CollisionTube(LCAST(PN_stdfloat, point_a), LCAST(PN_stdfloat, point_b), + CollisionCapsule *cscapsule = + new CollisionCapsule(LCAST(PN_stdfloat, point_a), LCAST(PN_stdfloat, point_b), radius); - apply_collision_flags(cstube, flags); - cnode->add_solid(cstube); + apply_collision_flags(cscapsule, flags); + cnode->add_solid(cscapsule); } } } diff --git a/panda/src/egg2pg/eggLoader.h b/panda/src/egg2pg/eggLoader.h index eb81317bd8..0f974f41c2 100644 --- a/panda/src/egg2pg/eggLoader.h +++ b/panda/src/egg2pg/eggLoader.h @@ -180,8 +180,8 @@ private: EggGroup::CollideFlags flags); void make_collision_inv_sphere(EggGroup *egg_group, CollisionNode *cnode, EggGroup::CollideFlags flags); - void make_collision_tube(EggGroup *egg_group, CollisionNode *cnode, - EggGroup::CollideFlags flags); + void make_collision_capsule(EggGroup *egg_group, CollisionNode *cnode, + EggGroup::CollideFlags flags); void make_collision_floor_mesh(EggGroup *egg_group, CollisionNode *cnode, EggGroup::CollideFlags flags); void apply_collision_flags(CollisionSolid *solid, diff --git a/panda/src/egg2pg/eggSaver.cxx b/panda/src/egg2pg/eggSaver.cxx index fb6bb3a59b..9aba56cc01 100644 --- a/panda/src/egg2pg/eggSaver.cxx +++ b/panda/src/egg2pg/eggSaver.cxx @@ -39,7 +39,7 @@ #include "collisionSphere.h" #include "collisionBox.h" #include "collisionInvSphere.h" -#include "collisionTube.h" +#include "collisionCapsule.h" #include "textureStage.h" #include "geomNode.h" #include "geom.h" @@ -620,13 +620,13 @@ convert_collision_node(CollisionNode *node, const WorkingNodePath &node_path, egg_poly->add_vertex(cvpool->create_unique_vertex(ev0)); egg_poly->add_vertex(cvpool->create_unique_vertex(ev1)); - } else if (child->is_of_type(CollisionTube::get_class_type())) { - CPT(CollisionTube) tube = DCAST(CollisionTube, child); - LPoint3 point_a = tube->get_point_a(); - LPoint3 point_b = tube->get_point_b(); + } else if (child->is_of_type(CollisionCapsule::get_class_type())) { + CPT(CollisionCapsule) capsule = DCAST(CollisionCapsule, child); + LPoint3 point_a = capsule->get_point_a(); + LPoint3 point_b = capsule->get_point_b(); LPoint3 centroid = (point_a + point_b) * 0.5f; - // Also get an arbitrary vector perpendicular to the tube. + // Also get an arbitrary vector perpendicular to the capsule. LVector3 axis = point_b - point_a; LVector3 sideways; if (std::fabs(axis[2]) > std::fabs(axis[1])) { @@ -635,18 +635,18 @@ convert_collision_node(CollisionNode *node, const WorkingNodePath &node_path, sideways = axis.cross(LVector3(0, 0, 1)); } sideways.normalize(); - sideways *= tube->get_radius(); - LVector3 extend = axis.normalized() * tube->get_radius(); + sideways *= capsule->get_radius(); + LVector3 extend = axis.normalized() * capsule->get_radius(); - EggGroup *egg_tube; + EggGroup *egg_capsule; if (num_solids == 1) { - egg_tube = egg_group; + egg_capsule = egg_group; } else { - egg_tube = new EggGroup; - egg_group->add_child(egg_tube); + egg_capsule = new EggGroup; + egg_group->add_child(egg_capsule); } - egg_tube->set_cs_type(EggGroup::CST_tube); - egg_tube->set_collide_flags(flags); + egg_capsule->set_cs_type(EggGroup::CST_tube); + egg_capsule->set_collide_flags(flags); // Add two points for the endcaps, and then two points around the // centroid to indicate the radius. @@ -657,7 +657,7 @@ convert_collision_node(CollisionNode *node, const WorkingNodePath &node_path, ev3.set_pos(LCAST(double, (centroid - sideways) * net_mat)); EggPolygon *egg_poly = new EggPolygon; - egg_tube->add_child(egg_poly); + egg_capsule->add_child(egg_poly); egg_poly->add_vertex(cvpool->create_unique_vertex(ev0)); egg_poly->add_vertex(cvpool->create_unique_vertex(ev1)); diff --git a/panda/src/putil/bam.h b/panda/src/putil/bam.h index 96f41cbf98..e21dadbc14 100644 --- a/panda/src/putil/bam.h +++ b/panda/src/putil/bam.h @@ -32,7 +32,7 @@ static const unsigned short _bam_major_ver = 6; // Bumped to major version 6 on 2006-02-11 to factor out PandaNode::CData. static const unsigned short _bam_first_minor_ver = 14; -static const unsigned short _bam_minor_ver = 43; +static const unsigned short _bam_minor_ver = 44; // Bumped to minor version 14 on 2007-12-19 to change default ColorAttrib. // Bumped to minor version 15 on 2008-04-09 to add TextureAttrib::_implicit_sort. // Bumped to minor version 16 on 2008-05-13 to add Texture::_quality_level. @@ -63,5 +63,6 @@ static const unsigned short _bam_minor_ver = 43; // Bumped to minor version 41 on 2016-03-02 to change LensNode, Lens, and Camera. // Bumped to minor version 42 on 2016-04-08 to expand ColorBlendAttrib. // Bumped to minor version 43 on 2018-12-06 to expand BillboardEffect and CompassEffect. +// Bumped to minor version 44 on 2018-12-23 to rename CollisionTube to CollisionCapsule. #endif diff --git a/panda/src/putil/bamWriter.cxx b/panda/src/putil/bamWriter.cxx index d8aa3e0b30..3de731d27d 100644 --- a/panda/src/putil/bamWriter.cxx +++ b/panda/src/putil/bamWriter.cxx @@ -20,9 +20,28 @@ #include "bamWriter.h" #include "bamReader.h" #include "lightMutexHolder.h" +#include "simpleHashMap.h" #include +// Keeps track of older type names in case we want to write out older .bam +// files. +struct ObsoleteName { + std::string _name; + int _before_major; + int _before_minor; + + bool operator < (const ObsoleteName &other) const { + if (_before_major != other._before_major) { + return _before_major < other._before_major; + } + return _before_minor < other._before_minor; + } +}; + +// This is a SimpleHashMap to avoid static init ordering issues. +static SimpleHashMap > obsolete_type_names; + /** * */ @@ -504,7 +523,14 @@ write_handle(Datagram &packet, TypeHandle type) { if (inserted) { // This is the first time this TypeHandle has been written, so also // write out its definition. - packet.add_string(type.get_name()); + + if (_file_major == _bam_major_ver && _file_minor == _bam_minor_ver) { + packet.add_string(type.get_name()); + } else { + // We are writing an older .bam format, so we need to look up whether + // we may need to write an older type name. + packet.add_string(get_obsolete_type_name(type, _file_major, _file_minor)); + } // We also need to write the derivation of the TypeHandle, in case the // program reading this file later has never heard of this type before. @@ -518,6 +544,45 @@ write_handle(Datagram &packet, TypeHandle type) { } } +/** + * Returns the name that the given type had in an older .bam version. + */ +std::string BamWriter:: +get_obsolete_type_name(TypeHandle type, int major, int minor) { + int index = obsolete_type_names.find(type); + if (index >= 0) { + // Iterate over the names. It is sorted such that the lower versions are + // listed first. + for (const ObsoleteName &name : obsolete_type_names.get_data((size_t)index)) { + if (major < name._before_major || + (major == name._before_major && minor < name._before_minor)) { + // We have a hit. + return name._name; + } + } + } + + return TypeRegistry::ptr()->get_name(type, nullptr); +} + +/** + * Registers the given type as having an older name in .bam files *before* the + * indicated version. You can call this multiple times for the same type in + * order to establish a history of renames for this type. + */ +void BamWriter:: +record_obsolete_type_name(TypeHandle type, std::string name, + int before_major, int before_minor) { + // Make sure it is registered as alternate name for reading. + TypeRegistry *reg = TypeRegistry::ptr(); + reg->record_alternate_name(type, name); + + ObsoleteName obsolete_name; + obsolete_name._name = std::move(name); + obsolete_name._before_major = before_major; + obsolete_name._before_minor = before_minor; + obsolete_type_names[type].insert(std::move(obsolete_name)); +} /** * This is called by the TypedWritable destructor. It should remove the diff --git a/panda/src/putil/bamWriter.h b/panda/src/putil/bamWriter.h index b8c53aac38..780104b61c 100644 --- a/panda/src/putil/bamWriter.h +++ b/panda/src/putil/bamWriter.h @@ -111,6 +111,10 @@ public: bool register_pta(Datagram &packet, const void *ptr); void write_handle(Datagram &packet, TypeHandle type); + static std::string get_obsolete_type_name(TypeHandle type, int major, int minor); + static void record_obsolete_type_name(TypeHandle type, std::string name, + int before_major, int before_minor); + private: void object_destructs(TypedWritable *object); diff --git a/pandatool/src/eggprogs/eggMakeTube.cxx b/pandatool/src/eggprogs/eggMakeTube.cxx index 7017e97dcd..85ec85081d 100644 --- a/pandatool/src/eggprogs/eggMakeTube.cxx +++ b/pandatool/src/eggprogs/eggMakeTube.cxx @@ -29,7 +29,7 @@ EggMakeTube() { set_program_description ("egg-make-tube generates an egg file representing a \"tube\" model, " "a cylinder capped on both ends by hemispheres. This is similar " - "in shape to the CollisionTube object within Panda.\n\n" + "in shape to the CollisionCapsule object within Panda.\n\n" "This program can also generate spheres if you omit -b; in this " "case, you are generating a degenerate tube of length 0."); diff --git a/pandatool/src/eggprogs/eggMakeTube.h b/pandatool/src/eggprogs/eggMakeTube.h index 520d178aee..3031b1c74e 100644 --- a/pandatool/src/eggprogs/eggMakeTube.h +++ b/pandatool/src/eggprogs/eggMakeTube.h @@ -24,7 +24,7 @@ class EggVertex; /** * A program to generate an egg file representing a tube model, similar in - * shape to a CollisionTube. + * shape to a CollisionCapsule. */ class EggMakeTube : public EggMakeSomething { public: diff --git a/tests/collide/test_collision_tube.py b/tests/collide/test_collision_tube.py new file mode 100644 index 0000000000..3d97754d87 --- /dev/null +++ b/tests/collide/test_collision_tube.py @@ -0,0 +1,63 @@ +from panda3d import core + + +def test_collision_tube_alias(): + assert hasattr(core, 'CollisionCapsule') + assert hasattr(core, 'CollisionTube') + assert core.CollisionTube is core.CollisionCapsule + + +def test_collision_tube_write_old(): + buffer = core.DatagramBuffer() + writer = core.BamWriter(buffer) + assert writer.get_file_major_ver() == 6 + writer.set_file_minor_ver(43) + + capsule = core.CollisionCapsule((0, 0, -1), (0, 0, 1), 0.5) + writer.init() + writer.write_object(capsule) + writer.flush() + + data = buffer.data + assert b'CollisionTube' in data + assert b'CollisionCapsule' not in data + + +def test_collision_tube_write_new(): + buffer = core.DatagramBuffer() + writer = core.BamWriter(buffer) + assert writer.get_file_major_ver() == 6 + writer.set_file_minor_ver(44) + + capsule = core.CollisionCapsule((0, 0, -1), (0, 0, 1), 0.5) + writer.init() + writer.write_object(capsule) + writer.flush() + + data = buffer.data + assert b'CollisionTube' not in data + assert b'CollisionCapsule' in data + + +def test_collision_tube_read_old(): + # Make sure we can read an older file that contains CollisionTube. + buffer = core.DatagramBuffer(b'\x06\x00\x00\x00\x06\x00+\x00\x01\x00\xd6\x00\x00\x00\x00j\x01\r\x00CollisionTube\x01h\x01\x0e\x00CollisionSolid\x01B\x00\x11\x00CopyOnWriteObject\x01A\x00!\x00CachedTypedWritableReferenceCount\x01=\x00\x1b\x00TypedWritableReferenceCount\x02<\x00\r\x00TypedWritable\x01\x03\x00\x0b\x00TypedObject\x00\x07\x00\x0e\x00ReferenceCount\x00\x01\x00\x15\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80\xbf\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80?\x00\x00\x00?\x01\x00\x00\x00\x01') + reader = core.BamReader(buffer) + reader.init() + assert reader.file_version == (6, 43) + + capsule = reader.read_object() + reader.resolve() + assert isinstance(capsule, core.CollisionCapsule) + + +def test_collision_tube_read_new(): + # Make sure we can read a newer file that contains CollisionCapsule. + buffer = core.DatagramBuffer(b'\x06\x00\x00\x00\x06\x00,\x00\x01\x00\xd9\x00\x00\x00\x00j\x01\x10\x00CollisionCapsule\x01h\x01\x0e\x00CollisionSolid\x01B\x00\x11\x00CopyOnWriteObject\x01A\x00!\x00CachedTypedWritableReferenceCount\x01=\x00\x1b\x00TypedWritableReferenceCount\x02<\x00\r\x00TypedWritable\x01\x03\x00\x0b\x00TypedObject\x00\x07\x00\x0e\x00ReferenceCount\x00\x01\x00\x15\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80\xbf\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x80?\x00\x00\x00?\x01\x00\x00\x00\x01') + reader = core.BamReader(buffer) + reader.init() + assert reader.file_version == (6, 44) + + capsule = reader.read_object() + reader.resolve() + assert isinstance(capsule, core.CollisionCapsule) From e2574af82dde2ecb0c8d63a2db64e87d0e47e240 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 23 Dec 2018 19:49:00 +0100 Subject: [PATCH 21/33] collide: create compatibility header collisionTube.h This is a separate commit from the previous one in order not to confuse Git's rename tracking. --- panda/src/collide/collisionCapsule.h | 7 ------- panda/src/collide/collisionTube.h | 27 +++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 7 deletions(-) create mode 100644 panda/src/collide/collisionTube.h diff --git a/panda/src/collide/collisionCapsule.h b/panda/src/collide/collisionCapsule.h index af5cbcc92d..b6d375ff44 100644 --- a/panda/src/collide/collisionCapsule.h +++ b/panda/src/collide/collisionCapsule.h @@ -156,13 +156,6 @@ private: friend class CollisionBox; }; -BEGIN_PUBLISH -/** - * Alias for backward compatibility. - */ -typedef CollisionCapsule CollisionTube; -END_PUBLISH - #include "collisionCapsule.I" #endif diff --git a/panda/src/collide/collisionTube.h b/panda/src/collide/collisionTube.h new file mode 100644 index 0000000000..c67708628e --- /dev/null +++ b/panda/src/collide/collisionTube.h @@ -0,0 +1,27 @@ +/** + * PANDA 3D SOFTWARE + * Copyright (c) Carnegie Mellon University. All rights reserved. + * + * All use of this software is subject to the terms of the revised BSD + * license. You should have received a copy of this license along + * with this source code in a file named "LICENSE." + * + * @file collisionTube.h + * @author rdb + * @date 2018-12-23 + */ + +#ifndef COLLISIONTUBE_H +#define COLLISIONTUBE_H + +#include "collisionCapsule.h" + +BEGIN_PUBLISH +/** + * Alias for backward compatibility. + * @deprecated use CollisionCapsule instead. + */ +typedef CollisionCapsule CollisionTube; +END_PUBLISH + +#endif From 8cb7f7d9c0ba38cc6f1d3839aab19cd74c71c8c3 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 23 Dec 2018 20:07:05 +0100 Subject: [PATCH 22/33] ffmpeg: don't hold AV lock while fetching first packet/frame This allows loading multiple videos side-by-side more effectively. Closes #397 --- panda/src/ffmpeg/ffmpegVideoCursor.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/panda/src/ffmpeg/ffmpegVideoCursor.cxx b/panda/src/ffmpeg/ffmpegVideoCursor.cxx index ef23a9414e..fa5789b6c4 100644 --- a/panda/src/ffmpeg/ffmpegVideoCursor.cxx +++ b/panda/src/ffmpeg/ffmpegVideoCursor.cxx @@ -79,8 +79,6 @@ init_from(FfmpegVideo *source) { return; } - ReMutexHolder av_holder(_av_lock); - #if LIBAVCODEC_VERSION_INT >= AV_VERSION_INT(55, 45, 101) _frame = av_frame_alloc(); _frame_out = av_frame_alloc(); @@ -109,6 +107,8 @@ init_from(FfmpegVideo *source) { _eof_known = false; _eof_frame = 0; + ReMutexHolder av_holder(_av_lock); + // Check if we got an alpha format. Please note that some video codecs // (eg. libvpx) change the pix_fmt after decoding the first frame, which is // why we didn't do this earlier. From 395b9733fb05940756390aba6f50577f4e1591a6 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 23 Dec 2018 19:52:49 +0100 Subject: [PATCH 23/33] makepanda: when making Linux package, ship Python 2 and 3 bindings See #441 for discussion. --- makepanda/installpanda.py | 44 ++++++++--------- makepanda/makepackage.py | 96 +++++++++++++++++++++++++++----------- makepanda/makepanda.py | 12 ++++- makepanda/makepandacore.py | 65 ++++++++++++++++++++++++++ 4 files changed, 166 insertions(+), 51 deletions(-) diff --git a/makepanda/installpanda.py b/makepanda/installpanda.py index 410847efc7..b53153c5d8 100644 --- a/makepanda/installpanda.py +++ b/makepanda/installpanda.py @@ -13,10 +13,6 @@ from distutils.sysconfig import get_python_lib from optparse import OptionParser from makepandacore import * -def python_sitepackages_path(): - from distutils.sysconfig import get_python_lib - return get_python_lib(1) -PYTHON_SITEPACKAGES=python_sitepackages_path() MIME_INFO = ( ("egg", "model/x-egg", "EGG model file", "pview"), @@ -153,18 +149,11 @@ def GetLibDir(): return "lib" -def InstallPanda(destdir="", prefix="/usr", outputdir="built", libdir=GetLibDir()): +def InstallPanda(destdir="", prefix="/usr", outputdir="built", libdir=GetLibDir(), python_versions=[]): if (not prefix.startswith("/")): prefix = "/" + prefix libdir = prefix + "/" + libdir - # Determine the location of the Python executable and site-packages dir. - PPATH = get_python_lib(1) - if os.path.islink(sys.executable): - PEXEC = os.path.join(os.path.dirname(sys.executable), os.readlink(sys.executable)) - else: - PEXEC = sys.executable - # Create the directory structure that we will be putting our files in. oscmd("mkdir -m 0755 -p "+destdir+prefix+"/bin") oscmd("mkdir -m 0755 -p "+destdir+prefix+"/include") @@ -174,8 +163,10 @@ def InstallPanda(destdir="", prefix="/usr", outputdir="built", libdir=GetLibDir( oscmd("mkdir -m 0755 -p "+destdir+prefix+"/share/application-registry") oscmd("mkdir -m 0755 -p "+destdir+prefix+"/share/applications") oscmd("mkdir -m 0755 -p "+destdir+libdir+"/panda3d") - oscmd("mkdir -m 0755 -p "+destdir+PPATH) - oscmd("mkdir -m 0755 -p "+destdir+PPATH+"/panda3d") + + for python_version in python_versions: + oscmd("mkdir -m 0755 -p "+destdir+python_version["purelib"]) + oscmd("mkdir -m 0755 -p "+destdir+python_version["platlib"]+"/panda3d") if (sys.platform.startswith("freebsd")): oscmd("mkdir -m 0755 -p "+destdir+prefix+"/etc") @@ -201,10 +192,12 @@ def InstallPanda(destdir="", prefix="/usr", outputdir="built", libdir=GetLibDir( if os.path.isdir(outputdir+"/Pmw"): oscmd("cp -R "+outputdir+"/Pmw "+destdir+prefix+"/share/panda3d/") if os.path.isdir(outputdir+"/plugins"): oscmd("cp -R "+outputdir+"/plugins "+destdir+prefix+"/share/panda3d/") - suffix = GetExtensionSuffix() - for base in os.listdir(outputdir + "/panda3d"): - if base.endswith(".py") or (base.endswith(suffix) and '.' not in base[:-len(suffix)]): - oscmd("cp "+outputdir+"/panda3d/"+base+" "+destdir+PPATH+"/panda3d/"+base) + for python_version in python_versions: + for base in os.listdir(outputdir + "/panda3d"): + suffix = python_version["ext_suffix"] + platlib = python_version["platlib"] + if base.endswith(".py") or (base.endswith(suffix) and '.' not in base[:-len(suffix)]): + oscmd("cp "+outputdir+"/panda3d/"+base+" "+destdir+platlib+"/panda3d/"+base) WriteMimeFile(destdir+prefix+"/share/mime-info/panda3d.mime", MIME_INFO) WriteKeysFile(destdir+prefix+"/share/mime-info/panda3d.keys", MIME_INFO) @@ -214,8 +207,11 @@ def InstallPanda(destdir="", prefix="/usr", outputdir="built", libdir=GetLibDir( oscmd("cp makepanda/pview.desktop "+destdir+prefix+"/share/applications/pview.desktop") oscmd("cp doc/ReleaseNotes "+destdir+prefix+"/share/panda3d/ReleaseNotes") - oscmd("echo '"+prefix+"/share/panda3d' > "+destdir+PPATH+"/panda3d.pth") - oscmd("echo '"+libdir+"/panda3d'>> "+destdir+PPATH+"/panda3d.pth") + + for python_version in python_versions: + pth_file = python_version["purelib"] + "/panda3d.pth" + oscmd("echo '"+prefix+"/share/panda3d' > "+destdir+pth_file) + if (sys.platform.startswith("freebsd")): oscmd("echo '"+libdir+"/panda3d'> "+destdir+"/usr/local/libdata/ldconfig/panda3d") else: @@ -300,6 +296,8 @@ if (__name__ == "__main__"): if (destdir != "" and not os.path.isdir(destdir)): exit("Directory '%s' does not exist!" % destdir) + SetOutputDir(options.outputdir) + if options.verbose: SetVerbose(True) @@ -308,6 +306,8 @@ if (__name__ == "__main__"): InstallRuntime(destdir = destdir, prefix = options.prefix, outputdir = options.outputdir) else: print("Installing Panda3D SDK into " + destdir + options.prefix) - InstallPanda(destdir = destdir, prefix = options.prefix, outputdir = options.outputdir) + InstallPanda(destdir=destdir, + prefix=options.prefix, + outputdir=options.outputdir, + python_versions=ReadPythonVersionInfoFile()) print("Installation finished!") - diff --git a/makepanda/makepackage.py b/makepanda/makepackage.py index dc3da45e19..f1148e1de8 100755 --- a/makepanda/makepackage.py +++ b/makepanda/makepackage.py @@ -16,9 +16,9 @@ Architecture: ARCH Essential: no Depends: DEPENDS Recommends: RECOMMENDS -Provides: panda3d, pythonPV-panda3d -Conflicts: panda3d, pythonPV-panda3d -Replaces: panda3d, pythonPV-panda3d +Provides: PROVIDES +Conflicts: PROVIDES +Replaces: PROVIDES Maintainer: rdb Installed-Size: INSTSIZE Description: Panda3D free 3D engine SDK @@ -73,7 +73,6 @@ This package contains the SDK for development with Panda3D, install panda3d-runt /usr/share/panda3d /etc/ld.so.conf.d/panda3d.conf /usr/%_lib/panda3d -""" + PYTHON_SITEPACKAGES + """ /usr/include/panda3d """ INSTALLER_SPEC_FILE_PVIEW = \ @@ -254,17 +253,28 @@ def MakeDebugSymbolArchive(zipname, dirname): zip.close() -def MakeInstallerLinux(version, debversion=None, runtime=False, **kwargs): +def MakeInstallerLinux(version, debversion=None, rpmrelease=1, runtime=False, + python_versions=[], **kwargs): outputdir = GetOutputDir() - if not runtime and not PkgSkip("PYTHON"): - if "PYTHONVERSION" in SDK: - PYTHONV = SDK["PYTHONVERSION"].rstrip('dmu') - else: - PYTHONV = "python%d.%d" % (sys.version_info[:2]) - else: - PYTHONV = "python" - PV = PYTHONV.replace("python", "") + # We pack Python 2 and Python 3, if we built with support for it. + python2_ver = None + python3_ver = None + install_python_versions = [] + + if not runtime: + # What's the system version of Python 3? + oscmd('python3 -V > "%s/tmp/python3_version.txt"' % (outputdir)) + sys_python3_ver = '.'.join(ReadFile(outputdir + "/tmp/python3_version.txt").strip().split(' ')[1].split('.')[:2]) + + # Check that we built with support for these. + for version_info in python_versions: + if version_info["version"] == "2.7": + python2_ver = "2.7" + install_python_versions.append(version_info) + elif version_info["version"] == sys_python3_ver: + python3_ver = sys_python3_ver + install_python_versions.append(version_info) major_version = '.'.join(version.split('.')[:2]) if not debversion: @@ -272,7 +282,7 @@ def MakeInstallerLinux(version, debversion=None, runtime=False, **kwargs): # Clean and set up a directory to install Panda3D into oscmd("rm -rf targetroot data.tar.gz control.tar.gz panda3d.spec") - oscmd("mkdir --mode=0755 targetroot") + oscmd("mkdir -m 0755 targetroot") dpkg_present = False if os.path.exists("/usr/bin/dpkg-architecture") and os.path.exists("/usr/bin/dpkg-deb"): @@ -288,9 +298,12 @@ def MakeInstallerLinux(version, debversion=None, runtime=False, **kwargs): # Invoke installpanda.py to install it into a temporary dir lib_dir = GetDebLibDir() if runtime: - InstallRuntime(destdir="targetroot", prefix="/usr", outputdir=outputdir, libdir=lib_dir) + InstallRuntime(destdir="targetroot", prefix="/usr", + outputdir=outputdir, libdir=lib_dir) else: - InstallPanda(destdir="targetroot", prefix="/usr", outputdir=outputdir, libdir=lib_dir) + InstallPanda(destdir="targetroot", prefix="/usr", + outputdir=outputdir, libdir=lib_dir, + python_versions=install_python_versions) oscmd("chmod -R 755 targetroot/usr/share/panda3d") oscmd("mkdir -m 0755 -p targetroot/usr/share/man/man1") oscmd("install -m 0644 doc/man/*.1 targetroot/usr/share/man/man1/") @@ -301,9 +314,10 @@ def MakeInstallerLinux(version, debversion=None, runtime=False, **kwargs): txt = RUNTIME_INSTALLER_DEB_FILE[1:] else: txt = INSTALLER_DEB_FILE[1:] - txt = txt.replace("VERSION", debversion).replace("ARCH", pkg_arch).replace("PV", PV).replace("MAJOR", major_version) - txt = txt.replace("INSTSIZE", str(GetDirectorySize("targetroot") / 1024)) - oscmd("mkdir --mode=0755 -p targetroot/DEBIAN") + txt = txt.replace("VERSION", debversion).replace("ARCH", pkg_arch).replace("MAJOR", major_version) + txt = txt.replace("INSTSIZE", str(GetDirectorySize("targetroot") // 1024)) + + oscmd("mkdir -m 0755 -p targetroot/DEBIAN") oscmd("cd targetroot && (find usr -type f -exec md5sum {} ;) > DEBIAN/md5sums") if not runtime: oscmd("cd targetroot && (find etc -type f -exec md5sum {} ;) >> DEBIAN/md5sums") @@ -337,6 +351,7 @@ def MakeInstallerLinux(version, debversion=None, runtime=False, **kwargs): oscmd("cd targetroot && %(dpkg_shlibdeps)s -x%(pkg_name)s %(lib_pattern)s %(bin_pattern)s*" % locals()) depends = ReadFile("targetroot/debian/substvars").replace("shlibs:Depends=", "").strip() recommends = "" + provides = "panda3d-runtime" else: pkg_name = "panda3d" + major_version pkg_dir = "debian/panda3d" + major_version @@ -352,15 +367,29 @@ def MakeInstallerLinux(version, debversion=None, runtime=False, **kwargs): # Parse the substvars files generated by dpkg-shlibdeps. depends = ReadFile("targetroot/debian/substvars_dep").replace("shlibs:Depends=", "").strip() recommends = ReadFile("targetroot/debian/substvars_rec").replace("shlibs:Depends=", "").strip() - if PkgSkip("PYTHON")==0: - depends += ", " + PYTHONV - recommends += ", python-wxversion, python-profiler (>= " + PV + "), python-pmw, python-tk (>= " + PV + ")" - if PkgSkip("NVIDIACG")==0: + provides = "panda3d" + + if python2_ver or python3_ver: + recommends += ", python-pmw" + + if python2_ver: + depends += ", python%s" % (python2_ver) + recommends += ", python-wxversion" + recommends += ", python-tk (>= %s)" % (python2_ver) + provides += ", python2-panda3d" + + if python3_ver: + depends += ", python%s" % (python3_ver) + recommends += ", python3-tk (>= %s)" % (python3_ver) + provides += ", python3-panda3d" + + if not PkgSkip("NVIDIACG"): depends += ", nvidia-cg-toolkit" # Write back the dependencies, and delete the dummy set-up. txt = txt.replace("DEPENDS", depends.strip(', ')) txt = txt.replace("RECOMMENDS", recommends.strip(', ')) + txt = txt.replace("PROVIDES", provides.strip(', ')) WriteFile("targetroot/DEBIAN/control", txt) oscmd("rm -rf targetroot/debian") @@ -376,7 +405,9 @@ def MakeInstallerLinux(version, debversion=None, runtime=False, **kwargs): if runtime: InstallRuntime(destdir="targetroot", prefix="/usr", outputdir=outputdir, libdir=GetRPMLibDir()) else: - InstallPanda(destdir="targetroot", prefix="/usr", outputdir=outputdir, libdir=GetRPMLibDir()) + InstallPanda(destdir="targetroot", prefix="/usr", + outputdir=outputdir, libdir=GetRPMLibDir(), + python_versions=install_python_versions) oscmd("chmod -R 755 targetroot/usr/share/panda3d") oscmd("rpm -E '%_target_cpu' > "+outputdir+"/tmp/architecture.txt") @@ -392,15 +423,23 @@ def MakeInstallerLinux(version, debversion=None, runtime=False, **kwargs): if not PkgSkip("PVIEW"): txt += INSTALLER_SPEC_FILE_PVIEW + # Add the platform-specific Python directories. + dirs = set() + for version_info in install_python_versions: + dirs.add(version_info["platlib"]) + dirs.add(version_info["purelib"]) + + for dir in dirs: + txt += dir + "\n" + # Add the binaries in /usr/bin explicitly to the spec file for base in os.listdir(outputdir + "/bin"): txt += "/usr/bin/%s\n" % (base) # Write out the spec file. txt = txt.replace("VERSION", version) - txt = txt.replace("RPMRELEASE", rpmrelease) + txt = txt.replace("RPMRELEASE", str(rpmrelease)) txt = txt.replace("PANDASOURCE", pandasource) - txt = txt.replace("PV", PV) WriteFile("panda3d.spec", txt) oscmd("fakeroot rpmbuild --define '_rpmdir "+pandasource+"' --buildroot '"+os.path.abspath("targetroot")+"' -bb panda3d.spec") @@ -693,7 +732,7 @@ def MakeInstallerFreeBSD(version, runtime=False, **kwargs): manifest_txt = manifest_txt.replace("ARCH", pkg_arch) manifest_txt = manifest_txt.replace("ORIGIN", 'devel/panda3d' if not runtime else 'graphics/panda3d-runtime') manifest_txt = manifest_txt.replace("DEPENDS", dependencies) - manifest_txt = manifest_txt.replace("INSTSIZE", str(GetDirectorySize("targetroot") / 1024 / 1024)) + manifest_txt = manifest_txt.replace("INSTSIZE", str(GetDirectorySize("targetroot") // 1024 // 1024)) WriteFile("pkg-plist", plist_txt) WriteFile("+DESC", INSTALLER_PKG_DESCR_FILE[1:] if not runtime else RUNTIME_INSTALLER_PKG_DESCR_FILE[1:]) @@ -961,4 +1000,5 @@ if __name__ == "__main__": compressor=options.compressor, debversion=options.debversion, rpmrelease=options.rpmrelease, - runtime=options.runtime) + runtime=options.runtime, + python_versions=ReadPythonVersionInfoFile()) diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index cb9ab10e0c..f0f3c8de90 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -6742,6 +6742,10 @@ if RUNTESTS: cmdstr += " --verbose" oscmd(cmdstr) +# Write out information about the Python versions in the built dir. +python_version_info = GetCurrentPythonVersionInfo() +UpdatePythonVersionInfoFile(python_version_info) + ########################################################################################## # # The Installers @@ -6755,10 +6759,16 @@ if RUNTESTS: if INSTALLER: ProgressOutput(100.0, "Building installer") from makepackage import MakeInstaller + + # When using the --installer flag, only install for the current version. + python_versions = [] + if python_version_info: + python_versions.append(python_version_info) + MakeInstaller(version=VERSION, outputdir=GetOutputDir(), optimize=GetOptimize(), compressor=COMPRESSOR, debversion=DEBVERSION, rpmrelease=RPMRELEASE, - runtime=RUNTIME) + runtime=RUNTIME, python_versions=python_versions) if WHEEL: ProgressOutput(100.0, "Building wheel") diff --git a/makepanda/makepandacore.py b/makepanda/makepandacore.py index 435b45a023..d4811c1120 100644 --- a/makepanda/makepandacore.py +++ b/makepanda/makepandacore.py @@ -3383,6 +3383,71 @@ def FindLocation(fn, ipath, pyabi=None): ORIG_EXT[loc] = ext return loc + +######################################################################## +## +## These files maintain a python_versions.json file in the built/tmp +## directory that can be used by the other scripts in this directory. +## +######################################################################## + + +def GetCurrentPythonVersionInfo(): + if PkgSkip("PYTHON"): + return + + from distutils.sysconfig import get_python_lib + return { + "version": SDK["PYTHONVERSION"][6:9], + "soabi": GetPythonABI(), + "ext_suffix": GetExtensionSuffix(), + "executable": sys.executable, + "purelib": get_python_lib(False), + "platlib": get_python_lib(True), + } + + +def UpdatePythonVersionInfoFile(new_info): + import json + + json_file = os.path.join(GetOutputDir(), "tmp", "python_versions.json") + json_data = [] + if os.path.isfile(json_file) and not PkgSkip("PYTHON"): + try: + json_data = json.load(open(json_file, 'r')) + except: + json_data = [] + + # Prune the list by removing the entries that conflict with our build, + # plus the entries that no longer exist + for version_info in json_data[:]: + core_pyd = os.path.join(GetOutputDir(), "panda3d", "core" + version_info["ext_suffix"]) + if version_info["ext_suffix"] == new_info["ext_suffix"] or \ + version_info["soabi"] == new_info["soabi"] or \ + not os.path.isfile(core_pyd): + json_data.remove(version_info) + + if not PkgSkip("PYTHON"): + json_data.append(new_info) + + if VERBOSE: + print("Writing %s" % (json_file)) + json.dump(json_data, open(json_file, 'w'), indent=4) + + +def ReadPythonVersionInfoFile(): + import json + + json_file = os.path.join(GetOutputDir(), "tmp", "python_versions.json") + if os.path.isfile(json_file): + try: + return json.load(open(json_file, 'r')) + except: + pass + + return [] + + ######################################################################## ## ## TargetAdd From 69decc17ff78c77ca7ec6a205ce8b045854830f9 Mon Sep 17 00:00:00 2001 From: rdb Date: Sun, 23 Dec 2018 22:28:52 +0100 Subject: [PATCH 24/33] tests: raise GLSL version from 1.30 to 1.50 for compute shader --- tests/display/test_glsl_shader.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/display/test_glsl_shader.py b/tests/display/test_glsl_shader.py index 0a0a5f5737..8deadf40d9 100644 --- a/tests/display/test_glsl_shader.py +++ b/tests/display/test_glsl_shader.py @@ -38,7 +38,7 @@ void main() {{ """ -def run_glsl_test(gsg, body, preamble="", inputs={}, version=130, exts=set()): +def run_glsl_test(gsg, body, preamble="", inputs={}, version=150, exts=set()): """ Runs a GLSL test on the given GSG. The given body is executed in the main function and should call assert(). The preamble should contain all of the shader inputs. """ From 8a38337e6bf390ed2ddab7afa8b964be547232af Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 24 Dec 2018 00:17:02 +0100 Subject: [PATCH 25/33] makepanda: fix model cache written in current dir on macOS This was a regression in 2b537d2263d312672fe4a380fb6f49bda641cd48 that caused the model-cache to be written to ./Library/Caches rather than $HOME/Library/Caches --- makepanda/makepanda.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index f0f3c8de90..5172672380 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -2934,7 +2934,7 @@ else: configprc = configprc.replace("aux-display pandadx9", "") if (GetTarget() == 'darwin'): - configprc = configprc.replace("$XDG_CACHE_HOME/panda3d", "Library/Caches/Panda3D-%s" % MAJOR_VERSION) + configprc = configprc.replace("$XDG_CACHE_HOME/panda3d", "$HOME/Library/Caches/Panda3D-%s" % MAJOR_VERSION) # OpenAL is not yet working well on OSX for us, so let's do this for now. configprc = configprc.replace("p3openal_audio", "p3fmod_audio") From 0fa0ad673f74ded96d6bb11378277b8e34529b29 Mon Sep 17 00:00:00 2001 From: Donny Lawrence Date: Mon, 24 Dec 2018 13:36:13 +0100 Subject: [PATCH 26/33] cocoa: use CVDisplayLink on macOS to sync video to display(s) Closes #487 Fixes #486 --- .../cocoadisplay/cocoaGraphicsStateGuardian.h | 8 +++ .../cocoaGraphicsStateGuardian.mm | 70 +++++++++++++++++-- panda/src/cocoadisplay/cocoaGraphicsWindow.h | 3 + panda/src/cocoadisplay/cocoaGraphicsWindow.mm | 13 ++++ 4 files changed, 90 insertions(+), 4 deletions(-) diff --git a/panda/src/cocoadisplay/cocoaGraphicsStateGuardian.h b/panda/src/cocoadisplay/cocoaGraphicsStateGuardian.h index 2e83e60c34..8365834a16 100644 --- a/panda/src/cocoadisplay/cocoaGraphicsStateGuardian.h +++ b/panda/src/cocoadisplay/cocoaGraphicsStateGuardian.h @@ -20,6 +20,7 @@ #import #import +#import /** * A tiny specialization on GLGraphicsStateGuardian to add some Cocoa-specific @@ -38,14 +39,21 @@ public: CocoaGraphicsStateGuardian *share_with); virtual ~CocoaGraphicsStateGuardian(); + bool setup_vsync(); INLINE void lock_context(); INLINE void unlock_context(); NSOpenGLContext *_share_context; NSOpenGLContext *_context; + NSOpenGLPixelFormat *_format = nullptr; FrameBufferProperties _fbprops; + CVDisplayLinkRef _display_link = nullptr; + Mutex _swap_lock; + ConditionVar _swap_condition; + AtomicAdjust::Integer _last_wait_frame = 0; + protected: virtual void query_gl_version(); virtual void *do_get_extension_func(const char *name); diff --git a/panda/src/cocoadisplay/cocoaGraphicsStateGuardian.mm b/panda/src/cocoadisplay/cocoaGraphicsStateGuardian.mm index d0dbd37c16..92f6226492 100644 --- a/panda/src/cocoadisplay/cocoaGraphicsStateGuardian.mm +++ b/panda/src/cocoadisplay/cocoaGraphicsStateGuardian.mm @@ -28,6 +28,20 @@ #define NSAppKitVersionNumber10_7 1138 #endif +/** + * Called whenever a display wants a frame. The context argument contains the + * applicable CocoaGraphicsStateGuardian. + */ +static CVReturn +display_link_cb(CVDisplayLinkRef link, const CVTimeStamp *now, + const CVTimeStamp* output_time, CVOptionFlags flags_in, + CVOptionFlags *flags_out, void *context) { + CocoaGraphicsStateGuardian *gsg = (CocoaGraphicsStateGuardian *)context; + MutexHolder swap_holder(gsg->_swap_lock); + gsg->_swap_condition.notify(); + return kCVReturnSuccess; +} + TypeHandle CocoaGraphicsStateGuardian::_type_handle; /** @@ -36,7 +50,8 @@ TypeHandle CocoaGraphicsStateGuardian::_type_handle; CocoaGraphicsStateGuardian:: CocoaGraphicsStateGuardian(GraphicsEngine *engine, GraphicsPipe *pipe, CocoaGraphicsStateGuardian *share_with) : - GLGraphicsStateGuardian(engine, pipe) + GLGraphicsStateGuardian(engine, pipe), + _swap_condition(_swap_lock) { _share_context = nil; _context = nil; @@ -52,12 +67,59 @@ CocoaGraphicsStateGuardian(GraphicsEngine *engine, GraphicsPipe *pipe, */ CocoaGraphicsStateGuardian:: ~CocoaGraphicsStateGuardian() { + if (_format != nil) { + [_format release]; + } + if (_display_link != nil) { + CVDisplayLinkRelease(_display_link); + _display_link = nil; + MutexHolder swap_holder(_swap_lock); + _swap_condition.notify(); + } if (_context != nil) { [_context clearDrawable]; [_context release]; } } +/** + * Creates a CVDisplayLink, which tells us when the display the window is on + * will want a frame. + */ +bool CocoaGraphicsStateGuardian:: +setup_vsync() { + if (_display_link != nil) { + // Already set up. + return true; + } + + CVReturn result = CVDisplayLinkCreateWithActiveCGDisplays(&_display_link); + if (result != kCVReturnSuccess) { + cocoadisplay_cat.error() << "Failed to create CVDisplayLink.\n"; + return false; + } + + result = CVDisplayLinkSetCurrentCGDisplayFromOpenGLContext(_display_link, (CGLContextObj)[_context CGLContextObj], (CGLPixelFormatObj)[_format CGLPixelFormatObj]); + if (result != kCVReturnSuccess) { + cocoadisplay_cat.error() << "Failed to set CVDisplayLink's current display.\n"; + return false; + } + + result = CVDisplayLinkSetOutputCallback(_display_link, &display_link_cb, this); + if (result != kCVReturnSuccess) { + cocoadisplay_cat.error() << "Failed to set CVDisplayLink output callback.\n"; + return false; + } + + result = CVDisplayLinkStart(_display_link); + if (result != kCVReturnSuccess) { + cocoadisplay_cat.error() << "Failed to start the CVDisplayLink.\n"; + return false; + } + + return true; +} + /** * Gets the FrameBufferProperties to match the indicated config. */ @@ -262,15 +324,15 @@ choose_pixel_format(const FrameBufferProperties &properties, // TODO: print out renderer _context = [[NSOpenGLContext alloc] initWithFormat:format shareContext:_share_context]; - [format release]; + _format = format; if (_context == nil) { cocoadisplay_cat.error() << "Failed to create OpenGL context!\n"; return; } - // Set vsync setting on the context - GLint swap = sync_video ? 1 : 0; + // Disable vsync via the built-in mechanism, which doesn't work on Mojave + GLint swap = 0; [_context setValues:&swap forParameter:NSOpenGLCPSwapInterval]; cocoadisplay_cat.debug() diff --git a/panda/src/cocoadisplay/cocoaGraphicsWindow.h b/panda/src/cocoadisplay/cocoaGraphicsWindow.h index a49f748020..a053cb11b9 100644 --- a/panda/src/cocoadisplay/cocoaGraphicsWindow.h +++ b/panda/src/cocoadisplay/cocoaGraphicsWindow.h @@ -23,6 +23,8 @@ #import #import +#import + /** * An interface to the Cocoa system for managing OpenGL windows under Mac OS * X. @@ -92,6 +94,7 @@ private: PT(GraphicsWindowInputDevice) _input; bool _mouse_hidden; bool _context_needs_update; + bool _vsync_enabled = false; #if __MAC_OS_X_VERSION_MAX_ALLOWED >= 1060 CGDisplayModeRef _fullscreen_mode; diff --git a/panda/src/cocoadisplay/cocoaGraphicsWindow.mm b/panda/src/cocoadisplay/cocoaGraphicsWindow.mm index df3ecf3b12..85e01917eb 100644 --- a/panda/src/cocoadisplay/cocoaGraphicsWindow.mm +++ b/panda/src/cocoadisplay/cocoaGraphicsWindow.mm @@ -274,6 +274,14 @@ end_flip() { CocoaGraphicsStateGuardian *cocoagsg; DCAST_INTO_V(cocoagsg, _gsg); + if (_vsync_enabled) { + AtomicAdjust::Integer cur_frame = ClockObject::get_global_clock()->get_frame_count(); + if (AtomicAdjust::set(cocoagsg->_last_wait_frame, cur_frame) != cur_frame) { + MutexHolder swap_holder(cocoagsg->_swap_lock); + cocoagsg->_swap_condition.wait(); + } + } + cocoagsg->lock_context(); // Swap the front and back buffer. @@ -669,6 +677,8 @@ open_window() { mouse_mode_relative(); } + _vsync_enabled = sync_video && cocoagsg->setup_vsync(); + return true; } @@ -710,6 +720,8 @@ close_window() { _view = nil; } + _vsync_enabled = false; + GraphicsWindow::close_window(); } @@ -1491,6 +1503,7 @@ handle_close_event() { cocoagsg->unlock_context(); } _gsg.clear(); + _vsync_enabled = false; } // Dump the view, too From d180be2acc9316269e715a106e457a62fce535a6 Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 24 Dec 2018 13:49:41 +0100 Subject: [PATCH 27/33] makepackage: build macOS installer for multiple Python versions See #441 --- makepanda/makepackage.py | 112 ++++++++++++++++++++++++++++----------- 1 file changed, 81 insertions(+), 31 deletions(-) diff --git a/makepanda/makepackage.py b/makepanda/makepackage.py index f1148e1de8..ce7282626e 100755 --- a/makepanda/makepackage.py +++ b/makepanda/makepackage.py @@ -453,7 +453,7 @@ def MakeInstallerLinux(version, debversion=None, rpmrelease=1, runtime=False, exit("To build an installer, either rpmbuild or dpkg-deb must be present on your system!") -def MakeInstallerOSX(version, runtime=False, **kwargs): +def MakeInstallerOSX(version, runtime=False, python_versions=[], **kwargs): outputdir = GetOutputDir() if runtime: @@ -467,17 +467,11 @@ def MakeInstallerOSX(version, runtime=False, **kwargs): oscmd(cmdstr) return - if "PYTHONVERSION" in SDK: - pyver = SDK["PYTHONVERSION"][6:9] - else: - pyver = "%d.%d" % (sys.version_info[:2]) - dmg_name = "Panda3D-" + version - if not pyver.startswith("2."): + if len(python_versions) == 1 and not python_versions[0]["version"].startswith("2."): dmg_name += "-py" + pyver dmg_name += ".dmg" - import compileall if (os.path.isfile(dmg_name)): oscmd("rm -f %s" % dmg_name) if (os.path.exists("dstroot")): oscmd("rm -rf dstroot") if (os.path.exists("Panda3D-rw.dmg")): oscmd('rm -f Panda3D-rw.dmg') @@ -518,33 +512,43 @@ def MakeInstallerOSX(version, runtime=False, **kwargs): # OSX needs the -R argument to copy symbolic links correctly, it doesn't have -d. How weird. oscmd("cp -R " + outputdir + "/bin/" + base + " " + binname) - if not PkgSkip("PYTHON"): - pyexec = SDK.get("PYTHONEXEC", sys.executable) - oscmd("mkdir -p dstroot/pythoncode/usr/local/bin") + if python_versions: + # Let's only write a ppython link if there is only one Python version. + if len(python_versions) == 1: + oscmd("mkdir -p dstroot/pythoncode/usr/local/bin") + oscmd("ln -s %s dstroot/pythoncode/usr/local/bin/ppython" % (python_versions[0]["executable"])) + oscmd("mkdir -p dstroot/pythoncode/Developer/Panda3D/panda3d") - oscmd("mkdir -p dstroot/pythoncode/Library/Python/%s/site-packages" % pyver) - WriteFile("dstroot/pythoncode/Library/Python/%s/site-packages/Panda3D.pth" % pyver, "/Developer/Panda3D") oscmd("cp -R %s/pandac dstroot/pythoncode/Developer/Panda3D/pandac" % outputdir) oscmd("cp -R %s/direct dstroot/pythoncode/Developer/Panda3D/direct" % outputdir) - oscmd("ln -s %s dstroot/pythoncode/usr/local/bin/ppython" % pyexec) oscmd("cp -R %s/*.so dstroot/pythoncode/Developer/Panda3D/" % outputdir, True) oscmd("cp -R %s/*.py dstroot/pythoncode/Developer/Panda3D/" % outputdir, True) if os.path.isdir(outputdir+"/Pmw"): oscmd("cp -R %s/Pmw dstroot/pythoncode/Developer/Panda3D/Pmw" % outputdir) - compileall.compile_dir("dstroot/pythoncode/Developer/Panda3D/Pmw") - WriteFile("dstroot/pythoncode/Developer/Panda3D/direct/__init__.py", "") - for base in os.listdir("dstroot/pythoncode/Developer/Panda3D/direct"): - if ((base != "extensions") and (base != "extensions_native")): - compileall.compile_dir("dstroot/pythoncode/Developer/Panda3D/direct/"+base) - suffix = GetExtensionSuffix() for base in os.listdir(outputdir+"/panda3d"): - if base.endswith('.py') or (base.endswith(suffix) and '.' not in base[:-len(suffix)]): + if base.endswith('.py'): libname = "dstroot/pythoncode/Developer/Panda3D/panda3d/" + base + oscmd("cp -R " + outputdir + "/panda3d/" + base + " " + libname) + + for version_info in python_versions: + pyver = version_info["version"] + oscmd("mkdir -p dstroot/pybindings%s/Library/Python/%s/site-packages" % (pyver, pyver)) + oscmd("mkdir -p dstroot/pybindings%s/Developer/Panda3D/panda3d" % (pyver)) + + # Copy over extension modules. + suffix = version_info["ext_suffix"] + for base in os.listdir(outputdir+"/panda3d"): + if base.endswith(suffix) and '.' not in base[:-len(suffix)]: + libname = "dstroot/pybindings%s/Developer/Panda3D/panda3d/%s" % (pyver, base) # We really need to specify -R in order not to follow symlinks # On OSX, just specifying -P is not enough to do that. oscmd("cp -R -P " + outputdir + "/panda3d/" + base + " " + libname) + # Write a .pth file. + oscmd("mkdir -p dstroot/pybindings%s/Library/Python/%s/site-packages" % (pyver, pyver)) + WriteFile("dstroot/pybindings%s/Library/Python/%s/site-packages/Panda3D.pth" % (pyver, pyver), "/Developer/Panda3D") + if not PkgSkip("FFMPEG"): oscmd("mkdir -p dstroot/ffmpeg/Developer/Panda3D/lib") oscmd("cp -R %s/lib/libp3ffmpeg.* dstroot/ffmpeg/Developer/Panda3D/lib/" % outputdir) @@ -567,9 +571,19 @@ def MakeInstallerOSX(version, runtime=False, **kwargs): oscmd("mkdir -p dstroot/samples/Developer/Examples/Panda3D") oscmd("cp -R samples/* dstroot/samples/Developer/Examples/Panda3D/") - oscmd("chmod -R 0775 dstroot/*") DeleteVCS("dstroot") DeleteBuildFiles("dstroot") + + # Compile Python files. Do this *after* the DeleteVCS step, above, which + # deletes __pycache__ directories. + for version_info in python_versions: + if os.path.isdir("dstroot/pythoncode/Developer/Panda3D/Pmw"): + oscmd("%s -m compileall -q -f -d /Developer/Panda3D/Pmw dstroot/pythoncode/Developer/Panda3D/Pmw" % (version_info["executable"]), True) + oscmd("%s -m compileall -q -f -d /Developer/Panda3D/direct dstroot/pythoncode/Developer/Panda3D/direct" % (version_info["executable"])) + oscmd("%s -m compileall -q -f -d /Developer/Panda3D/pandac dstroot/pythoncode/Developer/Panda3D/pandac" % (version_info["executable"])) + oscmd("%s -m compileall -q -f -d /Developer/Panda3D/panda3d dstroot/pythoncode/Developer/Panda3D/panda3d" % (version_info["executable"])) + + oscmd("chmod -R 0775 dstroot/*") # We need to be root to perform a chown. Bleh. # Fortunately PackageMaker does it for us, on 10.5 and above. #oscmd("chown -R root:admin dstroot/*", True) @@ -578,7 +592,10 @@ def MakeInstallerOSX(version, runtime=False, **kwargs): oscmd("mkdir -p dstroot/Panda3D/Panda3D.mpkg/Contents/Resources/en.lproj/") pkgs = ["base", "tools", "headers"] - if not PkgSkip("PYTHON"): pkgs.append("pythoncode") + if python_versions: + pkgs.append("pythoncode") + for version_info in python_versions: + pkgs.append("pybindings" + version_info["version"]) if not PkgSkip("FFMPEG"): pkgs.append("ffmpeg") #if not PkgSkip("OPENAL"): pkgs.append("openal") if not PkgSkip("FMODEX"): pkgs.append("fmodex") @@ -620,22 +637,55 @@ def MakeInstallerOSX(version, runtime=False, **kwargs): dist.write(' Panda3D SDK %s\n' % (version)) dist.write(' \n') dist.write(' %s\n' % ReadFile("doc/LICENSE")) + dist.write(' \n') dist.write(' \n') - for pkg in pkgs: - dist.write(' \n' % (pkg)) + dist.write(' \n') + if python_versions: + dist.write(' \n') + for version_info in python_versions: + dist.write(' \n' % (version_info["version"])) + dist.write(' \n') + dist.write(' \n') + if os.path.isdir("samples"): + dist.write(' \n') + if not PkgSkip("FFMPEG"): + dist.write(' \n') + if not PkgSkip("FMODEX"): + dist.write(' \n') + dist.write(' \n') dist.write(' \n') - dist.write(' \n') + dist.write(' \n') dist.write(' \n') dist.write(' \n') - dist.write(' \n') + dist.write(' \n') dist.write(' \n') dist.write(' \n') - if not PkgSkip("PYTHON"): - dist.write(' \n') + if python_versions: + dist.write(' \n') dist.write(' \n') dist.write(' \n') + for version_info in python_versions: + pyver = version_info["version"] + if pyver == "2.7": + # Always install Python 2.7 by default; it's included on macOS. + cond = "true" + else: + cond = "isPythonVersionInstalled('%s')" % (pyver) + dist.write(' \n' % (pyver, cond, pyver, pyver)) + dist.write(' \n' % (pyver)) + dist.write(' \n') + if not PkgSkip("FFMPEG"): dist.write(' \n') if os.path.isdir("samples"): - dist.write(' \n') + dist.write(' \n') dist.write(' \n') dist.write(' \n') - dist.write(' \n') + dist.write(' \n') dist.write(' \n') dist.write(' \n') for pkg in pkgs: From 94d1722c8c29e304798119e875fb328a7829a3d2 Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 24 Dec 2018 20:51:20 +0100 Subject: [PATCH 28/33] makepanda: add --no-copy-python flag for Windows build This will avoid copying over the python installation to the built/python directory. --- makepanda/makepanda.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/makepanda/makepanda.py b/makepanda/makepanda.py index 5172672380..b03ca4d4d9 100755 --- a/makepanda/makepanda.py +++ b/makepanda/makepanda.py @@ -70,6 +70,7 @@ WINDOWS_SDK = None MSVC_VERSION = None BOOUSEINTELCOMPILER = False OPENCV_VER_23 = False +COPY_PYTHON = True if "MACOSX_DEPLOYMENT_TARGET" in os.environ: OSXTARGET=os.environ["MACOSX_DEPLOYMENT_TARGET"] @@ -170,6 +171,7 @@ def parseopts(args): global COMPRESSOR,THREADCOUNT,OSXTARGET,OSX_ARCHS,HOST_URL global DEBVERSION,WHLVERSION,RPMRELEASE,GIT_COMMIT,P3DSUFFIX,RTDIST_VERSION global STRDXSDKVERSION, WINDOWS_SDK, MSVC_VERSION, BOOUSEINTELCOMPILER + global COPY_PYTHON # Options for which to display a deprecation warning. removedopts = [ @@ -183,7 +185,7 @@ def parseopts(args): "version=","lzma","no-python","threads=","outputdir=","override=", "static","host=","debversion=","rpmrelease=","p3dsuffix=","rtdist-version=", "directx-sdk=", "windows-sdk=", "msvc-version=", "clean", "use-icl", - "universal", "target=", "arch=", "git-commit=", + "universal", "target=", "arch=", "git-commit=", "no-copy-python", ] + removedopts anything = 0 @@ -249,6 +251,7 @@ def parseopts(args): MSVC_VERSION = value.strip().lower() elif (option=="--use-icl"): BOOUSEINTELCOMPILER = True elif (option=="--clean"): clean_build = True + elif (option=="--no-copy-python"): COPY_PYTHON = False elif (option[2:] in removedopts): Warn("Ignoring removed option %s" % (option)) else: @@ -3058,7 +3061,8 @@ if tp_dir is not None: CopyFile(GetOutputDir() + "/bin/", fn) # Copy the whole Python directory. - CopyTree(GetOutputDir() + "/python", SDK["PYTHON"]) + if COPY_PYTHON: + CopyTree(GetOutputDir() + "/python", SDK["PYTHON"]) # NB: Python does not always ship with the correct manifest/dll. # Figure out the correct one to ship, and grab it from WinSxS dir. @@ -3067,7 +3071,7 @@ if tp_dir is not None: os.unlink(manifest) oscmd('mt -inputresource:"%s\\python.exe";#1 -out:"%s" -nologo' % (SDK["PYTHON"], manifest), True) - if os.path.isfile(manifest): + if COPY_PYTHON and os.path.isfile(manifest): import xml.etree.ElementTree as ET tree = ET.parse(manifest) idents = tree.findall('./{urn:schemas-microsoft-com:asm.v1}dependency/{urn:schemas-microsoft-com:asm.v1}dependentAssembly/{urn:schemas-microsoft-com:asm.v1}assemblyIdentity') @@ -3097,11 +3101,12 @@ if tp_dir is not None: CopyFile(GetOutputDir() + "/python/", file) # Copy python.exe to ppython.exe. - if not os.path.isfile(SDK["PYTHON"] + "/ppython.exe") and os.path.isfile(SDK["PYTHON"] + "/python.exe"): - CopyFile(GetOutputDir() + "/python/ppython.exe", SDK["PYTHON"] + "/python.exe") - if not os.path.isfile(SDK["PYTHON"] + "/ppythonw.exe") and os.path.isfile(SDK["PYTHON"] + "/pythonw.exe"): - CopyFile(GetOutputDir() + "/python/ppythonw.exe", SDK["PYTHON"] + "/pythonw.exe") - ConditionalWriteFile(GetOutputDir() + "/python/panda.pth", "..\n../bin\n") + if COPY_PYTHON: + if not os.path.isfile(SDK["PYTHON"] + "/ppython.exe") and os.path.isfile(SDK["PYTHON"] + "/python.exe"): + CopyFile(GetOutputDir() + "/python/ppython.exe", SDK["PYTHON"] + "/python.exe") + if not os.path.isfile(SDK["PYTHON"] + "/ppythonw.exe") and os.path.isfile(SDK["PYTHON"] + "/pythonw.exe"): + CopyFile(GetOutputDir() + "/python/ppythonw.exe", SDK["PYTHON"] + "/pythonw.exe") + ConditionalWriteFile(GetOutputDir() + "/python/panda.pth", "..\n../bin\n") # Copy over the MSVC runtime. if GetTarget() == 'windows' and "VISUALSTUDIO" in SDK: From 862906b86d4a363c9d52afc00a5c6527bb07d5b8 Mon Sep 17 00:00:00 2001 From: rdb Date: Mon, 24 Dec 2018 21:38:46 +0100 Subject: [PATCH 29/33] makepackage: install for multiple Python versions on Windows See #441 --- makepanda/installer.nsi | 696 ++++++++++++++++++++++----------------- makepanda/makepackage.py | 34 +- 2 files changed, 416 insertions(+), 314 deletions(-) diff --git a/makepanda/installer.nsi b/makepanda/installer.nsi index 8bc608cf6f..9abb029cac 100644 --- a/makepanda/installer.nsi +++ b/makepanda/installer.nsi @@ -14,7 +14,7 @@ ; ; BUILT - location of panda install tree. ; SOURCE - location of the panda source-tree if available, OR location of panda install tree. -; PYVER - version of Python that Panda was built with (ie, "2.7") +; INCLUDE_PYVER - version of Python that Panda was built with (eg. "2.7", "3.5-32") ; REGVIEW - either 32 or 64, depending on the build architecture. ; @@ -46,7 +46,9 @@ SetCompressor ${COMPRESSOR} !insertmacro MUI_PAGE_LICENSE "${SOURCE}/doc/LICENSE" !insertmacro MUI_PAGE_DIRECTORY +!ifdef INCLUDE_PYVER !define MUI_PAGE_CUSTOMFUNCTION_LEAVE ConfirmPythonSelection +!endif !insertmacro MUI_PAGE_COMPONENTS !insertmacro MUI_PAGE_INSTFILES @@ -64,8 +66,9 @@ ShowUninstDetails hide LicenseData "${SOURCE}/doc/LICENSE" -InstType "Full (Recommended)" -InstType "Minimal" +InstType "Auto (Recommended)" +InstType "Full" +InstType "Light" LangString DESC_SecCore ${LANG_ENGLISH} "The Panda3D core libraries, configuration files and models/textures that are needed to use Panda3D." LangString DESC_SecOpenGL ${LANG_ENGLISH} "The OpenGL graphics back-end is the most well-supported renderer." @@ -78,8 +81,9 @@ LangString DESC_SecODE ${LANG_ENGLISH} "Support for the Open Dynamics Engine to LangString DESC_SecPhysX ${LANG_ENGLISH} "Support for NVIDIA PhysX to implement physics." LangString DESC_SecRocket ${LANG_ENGLISH} "Support for the libRocket GUI library. This is an optional library that offers an HTML/CSS-like approach to creating user interfaces." LangString DESC_SecTools ${LANG_ENGLISH} "Useful tools and model converters to help with Panda3D development. Recommended." -LangString DESC_SecPyBindings ${LANG_ENGLISH} "Contains the Python modules that allow use of Panda3D using Python. These will only work with a ${REGVIEW}-bit version of Python ${PYVER}." -LangString DESC_SecPython ${LANG_ENGLISH} "Contains a ${REGVIEW}-bit copy of Python ${PYVER} preconfigured to make use of Panda3D." +LangString DESC_SecGroupPython ${LANG_ENGLISH} "Contains modules that provide Python support for Panda3D." +LangString DESC_SecPyShared ${LANG_ENGLISH} "Contains the common Python code used by the Panda3D Python bindings." +LangString DESC_SecPython ${LANG_ENGLISH} "Contains a ${REGVIEW}-bit copy of Python ${INCLUDE_PYVER} preconfigured to make use of Panda3D." LangString DESC_SecHeadersLibs ${LANG_ENGLISH} "Headers and libraries needed for C++ development with Panda3D." LangString DESC_SecSamples ${LANG_ENGLISH} "The sample programs demonstrate how to make Python applications with Panda3D." LangString DESC_SecMaxPlugins ${LANG_ENGLISH} "Plug-ins for Autodesk 3ds Max (${REGVIEW}-bit) that can be used to export models to Panda3D." @@ -112,224 +116,38 @@ var MANPAGE !insertmacro !defineifexist HAVE_ODE "${BUILT}\bin\libpandaode.dll" !insertmacro !defineifexist HAVE_PHYSX "${BUILT}\bin\libpandaphysx.dll" !insertmacro !defineifexist HAVE_ROCKET "${BUILT}\bin\libp3rocket.dll" -!insertmacro !defineifexist HAVE_PYTHON "${BUILT}\python" !insertmacro !defineifexist HAVE_SAMPLES "${SOURCE}\samples" !insertmacro !defineifexist HAVE_MAX_PLUGINS "${BUILT}\plugins\*.dlo" !insertmacro !defineifexist HAVE_MAYA_PLUGINS "${BUILT}\plugins\*.mll" -Function runFunction - ExecShell "open" "$SMPROGRAMS\${TITLE}\Panda3D Manual.lnk" -FunctionEnd +!macro RemovePythonPath PYVER + ReadRegStr $0 HKCU "Software\Python\PythonCore\${PYVER}\PythonPath\Panda3D" "" + StrCmp $0 "$INSTDIR" 0 +2 + DeleteRegKey HKCU "Software\Python\PythonCore\${PYVER}\PythonPath\Panda3D" +!macroend -Function .onInit - ${If} ${REGVIEW} = 64 - ${AndIfNot} ${RunningX64} - MessageBox MB_OK|MB_ICONEXCLAMATION "You are attempting to install the 64-bit version of Panda3D on a 32-bit version of Windows. Please download and install the 32-bit version of Panda3D instead." - Abort - ${EndIf} -FunctionEnd +!macro PyBindingSection PYVER EXT_SUFFIX + LangString DESC_SecPyBindings${PYVER} ${LANG_ENGLISH} "Contains the Python modules that allow use of Panda3D using a ${REGVIEW}-bit version of Python ${PYVER}." -SectionGroup "Panda3D Libraries" - Section "Core Libraries" SecCore - SectionIn 1 2 RO - - SetShellVarContext current - SetOverwrite try + !insertmacro !defineifexist _present "${BUILT}\panda3d\core${EXT_SUFFIX}" + !ifdef _present + Section "${PYVER} bindings" SecPyBindings${PYVER} + !if "${PYVER}" == "${INCLUDE_PYVER}" + SectionIn 1 2 3 + !else + !if "${PYVER}" == "2.7" + SectionIn 1 2 + !else + ; See .onInit function where this is dynamically enabled. + SectionIn 2 + !endif + !endif SetDetailsPrint both - DetailPrint "Installing Panda3D libraries..." + DetailPrint "Installing Panda3D bindings for Python ${PYVER}..." SetDetailsPrint listonly - SetOutPath "$INSTDIR" - File /nonfatal "${BUILT}\LICENSE" - File /nonfatal "${BUILT}\ReleaseNotes" - File /nonfatal "${BUILT}\pandaIcon.ico" - - SetOutPath $INSTDIR\etc - File /r "${BUILT}\etc\*" - - SetOutPath $INSTDIR\bin - File /r /x api-ms-win-*.dll /x ucrtbase.dll /x libpandagl.dll /x libpandadx9.dll /x cgD3D*.dll /x python*.dll /x libpandaode.dll /x libp3fmod_audio.dll /x fmodex*.dll /x libp3ffmpeg.dll /x av*.dll /x postproc*.dll /x swscale*.dll /x swresample*.dll /x NxCharacter*.dll /x cudart*.dll /x PhysX*.dll /x libpandaphysx.dll /x libp3rocket.dll /x boost_python*.dll /x Rocket*.dll /x _rocket*.pyd /x libpandabullet.dll /x OpenAL32.dll /x *_oal.dll /x libp3openal_audio.dll "${BUILT}\bin\*.dll" - File /nonfatal /r "${BUILT}\bin\Microsoft.*.manifest" - - ; Before Windows 10, we need these stubs for the UCRT as well. - ReadRegDWORD $0 HKLM "Software\Microsoft\Windows NT\CurrentVersion" "CurrentMajorVersionNumber" - ${If} $0 < 10 - ClearErrors - File /nonfatal /r "${BUILT}\bin\api-ms-win-*.dll" - File /nonfatal "${BUILT}\bin\ucrtbase.dll" - ${Endif} - - SetDetailsPrint both - DetailPrint "Installing models..." - SetDetailsPrint listonly - - SetOutPath $INSTDIR\models - File /r /x CVS "${BUILT}\models\*" - - SetDetailsPrint both - DetailPrint "Installing optional components..." - SetDetailsPrint listonly - - RMDir /r "$SMPROGRAMS\${TITLE}" - CreateDirectory "$SMPROGRAMS\${TITLE}" - SectionEnd - - !ifdef HAVE_GL - Section "OpenGL" SecOpenGL - SectionIn 1 2 RO - - SetOutPath "$INSTDIR\bin" - File "${BUILT}\bin\libpandagl.dll" - SectionEnd - !endif - - !ifdef HAVE_DX9 - Section "Direct3D 9" SecDirect3D9 - SectionIn 1 - - SetOutPath "$INSTDIR\bin" - File "${BUILT}\bin\libpandadx9.dll" - File /nonfatal /r "${BUILT}\bin\cgD3D9.dll" - SectionEnd - !endif - - !ifdef HAVE_OPENAL - Section "OpenAL Audio" SecOpenAL - SectionIn 1 2 - - SetOutPath "$INSTDIR\bin" - File "${BUILT}\bin\libp3openal_audio.dll" - File /nonfatal /r "${BUILT}\bin\OpenAL32.dll" - File /nonfatal /r "${BUILT}\bin\*_oal.dll" - SectionEnd - !endif - - !ifdef HAVE_FMOD - Section "FMOD Audio" SecFMOD - SectionIn 1 - - SetOutPath "$INSTDIR\bin" - File "${BUILT}\bin\libp3fmod_audio.dll" - File /r "${BUILT}\bin\fmodex*.dll" - SectionEnd - !endif - - !ifdef HAVE_FFMPEG - Section "FFMpeg" SecFFMpeg - SectionIn 1 - - SetOutPath "$INSTDIR\bin" - File "${BUILT}\bin\libp3ffmpeg.dll" - File /nonfatal /r "${BUILT}\bin\av*.dll" - File /nonfatal /r "${BUILT}\bin\swscale*.dll" - File /nonfatal /r "${BUILT}\bin\swresample*.dll" - File /nonfatal /r "${BUILT}\bin\postproc*.dll" - SectionEnd - !endif - - !ifdef HAVE_BULLET - Section "Bullet Physics" SecBullet - SectionIn 1 - - SetOutPath "$INSTDIR\bin" - File "${BUILT}\bin\libpandabullet.dll" - SectionEnd - !endif - - !ifdef HAVE_ODE - Section "ODE Physics" SecODE - SectionIn 1 - - SetOutPath "$INSTDIR\bin" - File "${BUILT}\bin\libpandaode.dll" - SectionEnd - !endif - - !ifdef HAVE_PHYSX - Section "NVIDIA PhysX" SecPhysX - SectionIn 1 - - SetOutPath "$INSTDIR\bin" - File "${BUILT}\bin\libpandaphysx.dll" - File /nonfatal /r "${BUILT}\bin\PhysX*.dll" - File /nonfatal /r "${BUILT}\bin\NxCharacter*.dll" - File /nonfatal /r "${BUILT}\bin\cudart*.dll" - SectionEnd - !endif - - !ifdef HAVE_ROCKET - Section "libRocket GUI" SecRocket - SectionIn 1 - - SetOutPath "$INSTDIR\bin" - File "${BUILT}\bin\libp3rocket.dll" - File /nonfatal /r "${BUILT}\bin\Rocket*.dll" - File /nonfatal /r "${BUILT}\bin\_rocket*.pyd" - File /nonfatal /r "${BUILT}\bin\boost_python*.dll" - SectionEnd - !endif -SectionGroupEnd - -Section "Tools and utilities" SecTools - SectionIn 1 2 - - SetDetailsPrint both - DetailPrint "Installing utilities..." - SetDetailsPrint listonly - - SetOutPath "$INSTDIR\bin" - File /r "${BUILT}\bin\*.exe" - File /nonfatal /r "${BUILT}\bin\*.p3d" - SetOutPath "$INSTDIR\NSIS" - File /r /x CVS "${NSISDIR}\*" - - WriteRegStr HKCU "Software\Classes\Panda3D.Model" "" "Panda3D model/animation" - WriteRegStr HKCU "Software\Classes\Panda3D.Model\DefaultIcon" "" "$INSTDIR\bin\pview.exe" - WriteRegStr HKCU "Software\Classes\Panda3D.Model\shell" "" "open" - WriteRegStr HKCU "Software\Classes\Panda3D.Model\shell\open\command" "" '"$INSTDIR\bin\pview.exe" -l "%1"' - WriteRegStr HKCU "Software\Classes\Panda3D.Model\shell\compress" "" "Compress to .pz" - WriteRegStr HKCU "Software\Classes\Panda3D.Model\shell\compress\command" "" '"$INSTDIR\bin\pzip.exe" "%1"' - - WriteRegStr HKCU "Software\Classes\Panda3D.Compressed" "" "Compressed file" - WriteRegStr HKCU "Software\Classes\Panda3D.Compressed\DefaultIcon" "" "$INSTDIR\bin\pzip.exe" - WriteRegStr HKCU "Software\Classes\Panda3D.Compressed\shell" "" "open" - WriteRegStr HKCU "Software\Classes\Panda3D.Compressed\shell\open\command" "" '"$INSTDIR\bin\pview.exe" -l "%1"' - WriteRegStr HKCU "Software\Classes\Panda3D.Compressed\shell\decompress" "" "Decompress" - WriteRegStr HKCU "Software\Classes\Panda3D.Compressed\shell\decompress\command" "" '"$INSTDIR\bin\punzip.exe" "%1"' - - WriteRegStr HKCU "Software\Classes\Panda3D.Multifile" "" "Panda3D Multifile" - WriteRegStr HKCU "Software\Classes\Panda3D.Multifile\DefaultIcon" "" "$INSTDIR\bin\multify.exe" - WriteRegStr HKCU "Software\Classes\Panda3D.Multifile\shell" "" "open" - WriteRegStr HKCU "Software\Classes\Panda3D.Multifile\shell\extract" "" "Extract here" - WriteRegStr HKCU "Software\Classes\Panda3D.Multifile\shell\extract\command" "" '"$INSTDIR\bin\multify.exe" -xf "%1"' -SectionEnd - -SectionGroup "Python support" - Section "Python bindings" SecPyBindings - SectionIn 1 2 - - SetDetailsPrint both - DetailPrint "Installing Panda3D Python modules..." - SetDetailsPrint listonly - - SetOutPath "$INSTDIR\bin" - File /nonfatal /r "${BUILT}\bin\*.pyd" - - SetOutPath $INSTDIR\direct\directscripts - File /r /x CVS /x Opt?-Win32 "${BUILT}\direct\directscripts\*" - SetOutPath $INSTDIR\direct\filter - File /r /x CVS /x Opt?-Win32 "${BUILT}\direct\filter\*.sha" - SetOutPath $INSTDIR\direct - File /r /x CVS /x Opt?-Win32 "${BUILT}\direct\*.py" - - Delete "$INSTDIR\panda3d.py" - Delete "$INSTDIR\panda3d.pyc" - Delete "$INSTDIR\panda3d.pyo" - SetOutPath $INSTDIR\pandac - File /r "${BUILT}\pandac\*.py" SetOutPath $INSTDIR\panda3d - File /r "${BUILT}\panda3d\*.py" File /nonfatal /r "${BUILT}\panda3d\core${EXT_SUFFIX}" File /nonfatal /r "${BUILT}\panda3d\ai${EXT_SUFFIX}" @@ -384,87 +202,344 @@ SectionGroup "Python support" SetRegView ${REGVIEW} !endif - ; Check for a non-Panda3D system-wide Python installation. - ReadRegStr $0 HKLM "Software\Python\PythonCore\${PYVER}\InstallPath" "" - StrCmp $0 "$INSTDIR\python" UserExternalPthCheck 0 - StrCmp $0 "" UserExternalPthCheck 0 - IfFileExists "$0\ppython.exe" UserExternalPthCheck 0 - IfFileExists "$0\python.exe" AskExternalPth UserExternalPthCheck - - ; Check for a non-Panda3D user installation of Python. - UserExternalPthCheck: - ReadRegStr $0 HKCU "Software\Python\PythonCore\${PYVER}\InstallPath" "" - StrCmp $0 "$INSTDIR\python" SkipExternalPth 0 - StrCmp $0 "" SkipExternalPth 0 - IfFileExists "$0\ppython.exe" SkipExternalPth 0 - IfFileExists "$0\python.exe" AskExternalPth SkipExternalPth - - ; We're pretty sure this Python build is of the right architecture. - AskExternalPth: - MessageBox MB_YESNO|MB_ICONQUESTION \ - "Your system already has a copy of Python ${PYVER} installed in:$\r$\n$0$\r$\nWould you like to configure it to be able to use the Panda3D libraries?$\r$\nIf you choose no, you will only be able to use Panda3D's own copy of Python." \ - IDYES WriteExternalPth IDNO SkipExternalPth - - WriteExternalPth: - ;FileOpen $1 "$0\Lib\site-packages\panda.pth" w - ;FileWrite $1 "$INSTDIR$\r$\n" - ;FileWrite $1 "$INSTDIR\bin$\r$\n" - ;FileClose $1 - - ; Actually, it looks like we can just do this instead: + ; Install a Panda3D path into the global PythonPath for this version + ; of Python. WriteRegStr HKCU "Software\Python\PythonCore\${PYVER}\PythonPath\Panda3D" "" "$INSTDIR" + SectionEnd + !undef _present + !endif +!macroend - SkipExternalPth: +Function runFunction + ExecShell "open" "$SMPROGRAMS\${TITLE}\Panda3D Manual.lnk" +FunctionEnd + +SectionGroup "Panda3D Libraries" + Section "Core Libraries" SecCore + SectionIn 1 2 3 RO + + SetShellVarContext current + SetOverwrite try + + SetDetailsPrint both + DetailPrint "Installing Panda3D libraries..." + SetDetailsPrint listonly + + SetOutPath "$INSTDIR" + File /nonfatal "${BUILT}\LICENSE" + File /nonfatal "${BUILT}\ReleaseNotes" + File /nonfatal "${BUILT}\pandaIcon.ico" + + SetOutPath $INSTDIR\etc + File /r "${BUILT}\etc\*" + + SetOutPath $INSTDIR\bin + File /r /x api-ms-win-*.dll /x ucrtbase.dll /x libpandagl.dll /x libpandadx9.dll /x cgD3D*.dll /x python*.dll /x libpandaode.dll /x libp3fmod_audio.dll /x fmodex*.dll /x libp3ffmpeg.dll /x av*.dll /x postproc*.dll /x swscale*.dll /x swresample*.dll /x NxCharacter*.dll /x cudart*.dll /x PhysX*.dll /x libpandaphysx.dll /x libp3rocket.dll /x boost_python*.dll /x Rocket*.dll /x _rocket*.pyd /x libpandabullet.dll /x OpenAL32.dll /x *_oal.dll /x libp3openal_audio.dll "${BUILT}\bin\*.dll" + File /nonfatal /r "${BUILT}\bin\Microsoft.*.manifest" + + ; Before Windows 10, we need these stubs for the UCRT as well. + ReadRegDWORD $0 HKLM "Software\Microsoft\Windows NT\CurrentVersion" "CurrentMajorVersionNumber" + ${If} $0 < 10 + ClearErrors + File /nonfatal /r "${BUILT}\bin\api-ms-win-*.dll" + File /nonfatal "${BUILT}\bin\ucrtbase.dll" + ${Endif} + + SetDetailsPrint both + DetailPrint "Installing models..." + SetDetailsPrint listonly + + SetOutPath $INSTDIR\models + File /r /x CVS "${BUILT}\models\*" + + SetDetailsPrint both + DetailPrint "Installing optional components..." + SetDetailsPrint listonly + + RMDir /r "$SMPROGRAMS\${TITLE}" + CreateDirectory "$SMPROGRAMS\${TITLE}" SectionEnd - !ifdef HAVE_PYTHON - Section "Python ${PYVER}" SecPython - SectionIn 1 2 - - !ifdef REGVIEW - SetRegView ${REGVIEW} - !endif - - SetDetailsPrint both - DetailPrint "Installing Python ${PYVER} (${REGVIEW}-bit)..." - SetDetailsPrint listonly + !ifdef HAVE_GL + Section "OpenGL" SecOpenGL + SectionIn 1 2 3 RO SetOutPath "$INSTDIR\bin" - File /nonfatal "${BUILT}\bin\python*.dll" + File "${BUILT}\bin\libpandagl.dll" + SectionEnd + !endif - SetOutPath "$INSTDIR\python" - File /r /x *.pdb "${BUILT}\python\*" + !ifdef HAVE_DX9 + Section "Direct3D 9" SecDirect3D9 + SectionIn 1 2 - SetDetailsPrint both - DetailPrint "Adding registry keys for Python..." - SetDetailsPrint listonly + SetOutPath "$INSTDIR\bin" + File "${BUILT}\bin\libpandadx9.dll" + File /nonfatal /r "${BUILT}\bin\cgD3D9.dll" + SectionEnd + !endif - ; Check if a copy of Python is installed for this user. - ReadRegStr $0 HKCU "Software\Python\PythonCore\${PYVER}\InstallPath" "" - StrCmp "$0" "$INSTDIR\python" RegPath 0 - StrCmp "$0" "" SkipFileCheck 0 - IfFileExists "$0\python.exe" AskRegPath 0 - SkipFileCheck: + !ifdef HAVE_OPENAL + Section "OpenAL Audio" SecOpenAL + SectionIn 1 2 3 - ; Check if a system-wide copy of Python is installed. - ReadRegStr $0 HKLM "Software\Python\PythonCore\${PYVER}\InstallPath" "" - StrCmp "$0" "$INSTDIR\python" RegPath 0 - StrCmp "$0" "" RegPath 0 - IfFileExists "$0\python.exe" AskRegPath RegPath + SetOutPath "$INSTDIR\bin" + File "${BUILT}\bin\libp3openal_audio.dll" + File /nonfatal /r "${BUILT}\bin\OpenAL32.dll" + File /nonfatal /r "${BUILT}\bin\*_oal.dll" + SectionEnd + !endif - AskRegPath: - MessageBox MB_YESNO|MB_ICONQUESTION \ - "You already have a copy of Python ${PYVER} installed in:$\r$\n$0$\r$\n$\r$\nPanda3D installs its own copy of Python ${PYVER}, which will install alongside your existing copy. Would you like to make Panda's copy the default Python for your user account?" \ - IDNO SkipRegPath + !ifdef HAVE_FMOD + Section "FMOD Audio" SecFMOD + SectionIn 1 2 - RegPath: - WriteRegStr HKCU "Software\Python\PythonCore\${PYVER}\InstallPath" "" "$INSTDIR\python" - SkipRegPath: + SetOutPath "$INSTDIR\bin" + File "${BUILT}\bin\libp3fmod_audio.dll" + File /r "${BUILT}\bin\fmodex*.dll" + SectionEnd + !endif + !ifdef HAVE_FFMPEG + Section "FFMpeg" SecFFMpeg + SectionIn 1 2 + + SetOutPath "$INSTDIR\bin" + File "${BUILT}\bin\libp3ffmpeg.dll" + File /nonfatal /r "${BUILT}\bin\av*.dll" + File /nonfatal /r "${BUILT}\bin\swscale*.dll" + File /nonfatal /r "${BUILT}\bin\swresample*.dll" + File /nonfatal /r "${BUILT}\bin\postproc*.dll" + SectionEnd + !endif + + !ifdef HAVE_BULLET + Section "Bullet Physics" SecBullet + SectionIn 1 2 + + SetOutPath "$INSTDIR\bin" + File "${BUILT}\bin\libpandabullet.dll" + SectionEnd + !endif + + !ifdef HAVE_ODE + Section "ODE Physics" SecODE + SectionIn 1 2 + + SetOutPath "$INSTDIR\bin" + File "${BUILT}\bin\libpandaode.dll" + SectionEnd + !endif + + !ifdef HAVE_PHYSX + Section "NVIDIA PhysX" SecPhysX + ; Only enable in "Full" + SectionIn 2 + + SetOutPath "$INSTDIR\bin" + File "${BUILT}\bin\libpandaphysx.dll" + File /nonfatal /r "${BUILT}\bin\PhysX*.dll" + File /nonfatal /r "${BUILT}\bin\NxCharacter*.dll" + File /nonfatal /r "${BUILT}\bin\cudart*.dll" + SectionEnd + !endif + + !ifdef HAVE_ROCKET + Section "libRocket GUI" SecRocket + SectionIn 1 2 + + SetOutPath "$INSTDIR\bin" + File "${BUILT}\bin\libp3rocket.dll" + File /nonfatal /r "${BUILT}\bin\Rocket*.dll" + File /nonfatal /r "${BUILT}\bin\_rocket*.pyd" + File /nonfatal /r "${BUILT}\bin\boost_python*.dll" SectionEnd !endif SectionGroupEnd +Section "Tools and utilities" SecTools + SectionIn 1 2 3 + + SetDetailsPrint both + DetailPrint "Installing utilities..." + SetDetailsPrint listonly + + SetOutPath "$INSTDIR\bin" + File /r "${BUILT}\bin\*.exe" + File /nonfatal /r "${BUILT}\bin\*.p3d" + SetOutPath "$INSTDIR\NSIS" + File /r /x CVS "${NSISDIR}\*" + + WriteRegStr HKCU "Software\Classes\Panda3D.Model" "" "Panda3D model/animation" + WriteRegStr HKCU "Software\Classes\Panda3D.Model\DefaultIcon" "" "$INSTDIR\bin\pview.exe" + WriteRegStr HKCU "Software\Classes\Panda3D.Model\shell" "" "open" + WriteRegStr HKCU "Software\Classes\Panda3D.Model\shell\open\command" "" '"$INSTDIR\bin\pview.exe" -l "%1"' + WriteRegStr HKCU "Software\Classes\Panda3D.Model\shell\compress" "" "Compress to .pz" + WriteRegStr HKCU "Software\Classes\Panda3D.Model\shell\compress\command" "" '"$INSTDIR\bin\pzip.exe" "%1"' + + WriteRegStr HKCU "Software\Classes\Panda3D.Compressed" "" "Compressed file" + WriteRegStr HKCU "Software\Classes\Panda3D.Compressed\DefaultIcon" "" "$INSTDIR\bin\pzip.exe" + WriteRegStr HKCU "Software\Classes\Panda3D.Compressed\shell" "" "open" + WriteRegStr HKCU "Software\Classes\Panda3D.Compressed\shell\open\command" "" '"$INSTDIR\bin\pview.exe" -l "%1"' + WriteRegStr HKCU "Software\Classes\Panda3D.Compressed\shell\decompress" "" "Decompress" + WriteRegStr HKCU "Software\Classes\Panda3D.Compressed\shell\decompress\command" "" '"$INSTDIR\bin\punzip.exe" "%1"' + + WriteRegStr HKCU "Software\Classes\Panda3D.Multifile" "" "Panda3D Multifile" + WriteRegStr HKCU "Software\Classes\Panda3D.Multifile\DefaultIcon" "" "$INSTDIR\bin\multify.exe" + WriteRegStr HKCU "Software\Classes\Panda3D.Multifile\shell" "" "open" + WriteRegStr HKCU "Software\Classes\Panda3D.Multifile\shell\extract" "" "Extract here" + WriteRegStr HKCU "Software\Classes\Panda3D.Multifile\shell\extract\command" "" '"$INSTDIR\bin\multify.exe" -xf "%1"' +SectionEnd + +SectionGroup "Python modules" SecGroupPython + Section "Shared code" SecPyShared + SectionIn 1 2 3 + + SetDetailsPrint both + DetailPrint "Installing Panda3D shared Python modules..." + SetDetailsPrint listonly + + SetOutPath $INSTDIR\direct\directscripts + File /r /x CVS /x Opt?-Win32 "${BUILT}\direct\directscripts\*" + SetOutPath $INSTDIR\direct\filter + File /r /x CVS /x Opt?-Win32 "${BUILT}\direct\filter\*.sha" + SetOutPath $INSTDIR\direct + File /r /x CVS /x Opt?-Win32 "${BUILT}\direct\*.py" + + Delete "$INSTDIR\panda3d.py" + Delete "$INSTDIR\panda3d.pyc" + Delete "$INSTDIR\panda3d.pyo" + SetOutPath $INSTDIR\pandac + File /r "${BUILT}\pandac\*.py" + SetOutPath $INSTDIR\panda3d + File /r "${BUILT}\panda3d\*.py" + SectionEnd + + !insertmacro PyBindingSection 2.7 .pyd + !if "${REGVIEW}" == "32" + !insertmacro PyBindingSection 3.5-32 .cp35-win32.pyd + !insertmacro PyBindingSection 3.6-32 .cp36-win32.pyd + !insertmacro PyBindingSection 3.7-32 .cp37-win32.pyd + !insertmacro PyBindingSection 3.8-32 .cp38-win32.pyd + !insertmacro PyBindingSection 3.9-32 .cp39-win32.pyd + !else + !insertmacro PyBindingSection 3.5 .cp35-win_amd64.pyd + !insertmacro PyBindingSection 3.6 .cp36-win_amd64.pyd + !insertmacro PyBindingSection 3.7 .cp37-win_amd64.pyd + !insertmacro PyBindingSection 3.8 .cp38-win_amd64.pyd + !insertmacro PyBindingSection 3.9 .cp39-win_amd64.pyd + !endif +SectionGroupEnd + +!ifdef INCLUDE_PYVER +Section "Python ${INCLUDE_PYVER}" SecPython + SectionIn 1 2 3 + + !ifdef REGVIEW + SetRegView ${REGVIEW} + !endif + + SetDetailsPrint both + DetailPrint "Installing Python ${INCLUDE_PYVER} interpreter (${REGVIEW}-bit)..." + SetDetailsPrint listonly + + SetOutPath "$INSTDIR\bin" + File /nonfatal "${BUILT}\bin\python*.dll" + + SetOutPath "$INSTDIR\python" + File /r /x *.pdb "${BUILT}\python\*" + + SetDetailsPrint both + DetailPrint "Adding registry keys for Python..." + SetDetailsPrint listonly + + ; Check if a copy of Python is installed for this user. + ReadRegStr $0 HKCU "Software\Python\PythonCore\${INCLUDE_PYVER}\InstallPath" "" + StrCmp "$0" "$INSTDIR\python" RegPath 0 + StrCmp "$0" "" SkipFileCheck 0 + IfFileExists "$0\python.exe" AskRegPath 0 + SkipFileCheck: + + ; Check if a system-wide copy of Python is installed. + ReadRegStr $0 HKLM "Software\Python\PythonCore\${INCLUDE_PYVER}\InstallPath" "" + StrCmp "$0" "$INSTDIR\python" RegPath 0 + StrCmp "$0" "" RegPath 0 + IfFileExists "$0\python.exe" AskRegPath RegPath + + AskRegPath: + MessageBox MB_YESNO|MB_ICONQUESTION \ + "You already have a copy of Python ${INCLUDE_PYVER} installed in:$\r$\n$0$\r$\n$\r$\nPanda3D installs its own copy of Python ${INCLUDE_PYVER}, which will install alongside your existing copy. Would you like to make Panda's copy the default Python for your user account?" \ + IDNO SkipRegPath + + RegPath: + WriteRegStr HKCU "Software\Python\PythonCore\${INCLUDE_PYVER}\InstallPath" "" "$INSTDIR\python" + WriteRegStr HKCU "Software\Python\PythonCore\${INCLUDE_PYVER}\InstallPath" "ExecutablePath" "$INSTDIR\python\python.exe" + SkipRegPath: + +SectionEnd +!endif + +!macro MaybeEnablePyBindingSection PYVER + !if "${INCLUDE_PYVER}" != "${PYVER}" + !ifdef SecPyBindings${PYVER} + ; Check if a copy of Python is installed for this user. + Push $0 + ReadRegStr $0 HKCU "Software\Python\PythonCore\${PYVER}\InstallPath" "" + StrCmp "$0" "" +2 0 + IfFileExists "$0\python.exe" Py${PYVER}Exists 0 + + ; Check if a system-wide copy of Python is installed. + ReadRegStr $0 HKLM "Software\Python\PythonCore\${PYVER}\InstallPath" "" + StrCmp "$0" "" Py${PYVER}ExistsNot 0 + IfFileExists "$0\python.exe" Py${PYVER}Exists Py${PYVER}ExistsNot + + Py${PYVER}Exists: + SectionSetFlags ${SecPyBindings${PYVER}} ${SF_SELECTED} + SectionSetInstTypes ${SecPyBindings${PYVER}} 3 + + Py${PYVER}ExistsNot: + Pop $0 + !endif + !endif +!macroend + +Function .onInit + ${If} ${REGVIEW} = 64 + ${AndIfNot} ${RunningX64} + MessageBox MB_OK|MB_ICONEXCLAMATION "You are attempting to install the 64-bit version of Panda3D on a 32-bit version of Windows. Please download and install the 32-bit version of Panda3D instead." + Abort + ${EndIf} + + !ifdef REGVIEW + SetRegView ${REGVIEW} + !endif + + ; We never check for 2.7; it is always enabled in Auto mode + !if "${REGVIEW}" == "32" + !insertmacro MaybeEnablePyBindingSection 3.5-32 + !insertmacro MaybeEnablePyBindingSection 3.6-32 + !insertmacro MaybeEnablePyBindingSection 3.7-32 + !insertmacro MaybeEnablePyBindingSection 3.8-32 + !insertmacro MaybeEnablePyBindingSection 3.9-32 + !else + !insertmacro MaybeEnablePyBindingSection 3.5 + !insertmacro MaybeEnablePyBindingSection 3.6 + !insertmacro MaybeEnablePyBindingSection 3.7 + !insertmacro MaybeEnablePyBindingSection 3.8 + !insertmacro MaybeEnablePyBindingSection 3.9 + !endif +FunctionEnd + +Function .onSelChange + ; If someone selects any Python version, the "shared modules" must be on. + ${If} ${SectionIsPartiallySelected} ${SecGroupPython} + SectionGetFlags ${SecPyShared} $R0 + IntOp $R0 $R0 | ${SF_SELECTED} + SectionSetFlags ${SecPyShared} $R0 + ${EndIf} +FunctionEnd + +!ifdef INCLUDE_PYVER Function ConfirmPythonSelection ; Check the current state of the "Python" section selection. SectionGetFlags ${SecPython} $R0 @@ -474,16 +549,14 @@ Function ConfirmPythonSelection StrCmp $R1 ${SF_SELECTED} SkipCheck 0 ; Maybe the user just doesn't want Python support at all? - SectionGetFlags ${SecPyBindings} $R1 - IntOp $R1 $R1 & ${SF_SELECTED} - StrCmp $R1 ${SF_SELECTED} 0 SkipCheck + !insertmacro SectionFlagIsSet ${SecGroupPython} ${SF_PSELECTED} 0 SkipCheck !ifdef REGVIEW SetRegView ${REGVIEW} !endif ; Check for a user installation of Python. - ReadRegStr $0 HKCU "Software\Python\PythonCore\${PYVER}\InstallPath" "" + ReadRegStr $0 HKCU "Software\Python\PythonCore\${INCLUDE_PYVER}\InstallPath" "" StrCmp $0 "$INSTDIR\python" CheckSystemWidePython 0 StrCmp $0 "" CheckSystemWidePython 0 IfFileExists "$0\ppython.exe" CheckSystemWidePython 0 @@ -491,7 +564,7 @@ Function ConfirmPythonSelection ; Check for a system-wide Python installation. CheckSystemWidePython: - ReadRegStr $0 HKLM "Software\Python\PythonCore\${PYVER}\InstallPath" "" + ReadRegStr $0 HKLM "Software\Python\PythonCore\${INCLUDE_PYVER}\InstallPath" "" StrCmp $0 "$INSTDIR\python" AskConfirmation 0 StrCmp $0 "" AskConfirmation 0 IfFileExists "$0\ppython.exe" AskConfirmation 0 @@ -501,7 +574,7 @@ Function ConfirmPythonSelection ; of a different Panda3D build.) Ask the user if he's sure about this. AskConfirmation: MessageBox MB_YESNO|MB_ICONQUESTION \ - "You do not appear to have a ${REGVIEW}-bit version of Python ${PYVER} installed. Are you sure you don't want Panda to install a compatible copy of Python?$\r$\n$\r$\nIf you choose Yes, you will not be able to do Python development with Panda3D until you install a ${REGVIEW}-bit version of Python ${PYVER} and manually configure it to be able to use Panda3D." \ + "You do not appear to have a ${REGVIEW}-bit version of Python ${INCLUDE_PYVER} installed. Are you sure you don't want Panda to install a compatible copy of Python?$\r$\n$\r$\nIf you choose Yes, you will not be able to do Python development with Panda3D until you install a ${REGVIEW}-bit version of Python and install the bindings for this version." \ IDYES SkipCheck ; User clicked no, so re-enable the select box and abort. @@ -511,9 +584,10 @@ Function ConfirmPythonSelection SkipCheck: FunctionEnd +!endif Section "C++ support" SecHeadersLibs - SectionIn 1 + SectionIn 1 2 SetDetailsPrint both DetailPrint "Installing header files..." @@ -532,7 +606,7 @@ SectionEnd !ifdef HAVE_SAMPLES Section "Sample programs" SecSamples - SectionIn 1 + SectionIn 1 2 ; Necessary for proper start menu shortcut installation SetShellVarContext current @@ -599,7 +673,7 @@ SectionEnd !ifdef HAVE_MAX_PLUGINS Section "3ds Max plug-ins" SecMaxPlugins - SectionIn 1 3 + SectionIn 1 2 SetDetailsPrint both DetailPrint "Installing Autodesk 3ds Max plug-ins..." @@ -614,7 +688,7 @@ SectionEnd !ifdef HAVE_MAYA_PLUGINS Section "Maya plug-ins" SecMayaPlugins - SectionIn 1 3 + SectionIn 1 2 SetDetailsPrint both DetailPrint "Installing Autodesk Maya plug-ins..." @@ -737,17 +811,30 @@ Section Uninstall DeleteRegKey HKCU "Software\Classes\Panda3D.Multifile\DefaultIcon" DeleteRegKey HKCU "Software\Classes\Panda3D.Multifile\shell" - ReadRegStr $0 HKLM "Software\Python\PythonCore\${PYVER}\InstallPath" "" - StrCmp $0 "$INSTDIR\python" 0 +2 - DeleteRegKey HKLM "Software\Python\PythonCore\${PYVER}" + !ifdef INCLUDE_PYVER + ReadRegStr $0 HKLM "Software\Python\PythonCore\${INCLUDE_PYVER}\InstallPath" "" + StrCmp $0 "$INSTDIR\python" 0 +2 + DeleteRegKey HKLM "Software\Python\PythonCore\${INCLUDE_PYVER}" - ReadRegStr $0 HKCU "Software\Python\PythonCore\${PYVER}\InstallPath" "" - StrCmp $0 "$INSTDIR\python" 0 +2 - DeleteRegKey HKCU "Software\Python\PythonCore\${PYVER}" + ReadRegStr $0 HKCU "Software\Python\PythonCore\${INCLUDE_PYVER}\InstallPath" "" + StrCmp $0 "$INSTDIR\python" 0 +2 + DeleteRegKey HKCU "Software\Python\PythonCore\${INCLUDE_PYVER}" + !endif - ReadRegStr $0 HKCU "Software\Python\PythonCore\${PYVER}\PythonPath\Panda3D" "" - StrCmp $0 "$INSTDIR" 0 +2 - DeleteRegKey HKCU "Software\Python\PythonCore\${PYVER}\PythonPath\Panda3D" + !insertmacro RemovePythonPath 2.7 + !if "${REGVIEW}" == "32" + !insertmacro RemovePythonPath 3.5-32 + !insertmacro RemovePythonPath 3.6-32 + !insertmacro RemovePythonPath 3.7-32 + !insertmacro RemovePythonPath 3.8-32 + !insertmacro RemovePythonPath 3.9-32 + !else + !insertmacro RemovePythonPath 3.5 + !insertmacro RemovePythonPath 3.6 + !insertmacro RemovePythonPath 3.7 + !insertmacro RemovePythonPath 3.8 + !insertmacro RemovePythonPath 3.9 + !endif SetDetailsPrint both DetailPrint "Deleting files..." @@ -812,8 +899,23 @@ SectionEnd !insertmacro MUI_DESCRIPTION_TEXT ${SecRocket} $(DESC_SecRocket) !endif !insertmacro MUI_DESCRIPTION_TEXT ${SecTools} $(DESC_SecTools) - !insertmacro MUI_DESCRIPTION_TEXT ${SecPyBindings} $(DESC_SecPyBindings) - !ifdef HAVE_PYTHON + !insertmacro MUI_DESCRIPTION_TEXT ${SecGroupPython} $(DESC_SecGroupPython) + !insertmacro MUI_DESCRIPTION_TEXT ${SecPyShared} $(DESC_SecPyShared) + !insertmacro MUI_DESCRIPTION_TEXT ${SecPyBindings2.7} $(DESC_SecPyBindings2.7) + !if "${REGVIEW}" == "32" + !insertmacro MUI_DESCRIPTION_TEXT ${SecPyBindings3.5-32} $(DESC_SecPyBindings3.5-32) + !insertmacro MUI_DESCRIPTION_TEXT ${SecPyBindings3.6-32} $(DESC_SecPyBindings3.6-32) + !insertmacro MUI_DESCRIPTION_TEXT ${SecPyBindings3.7-32} $(DESC_SecPyBindings3.7-32) + !insertmacro MUI_DESCRIPTION_TEXT ${SecPyBindings3.8-32} $(DESC_SecPyBindings3.8-32) + !insertmacro MUI_DESCRIPTION_TEXT ${SecPyBindings3.9-32} $(DESC_SecPyBindings3.9-32) + !else + !insertmacro MUI_DESCRIPTION_TEXT ${SecPyBindings3.5} $(DESC_SecPyBindings3.5) + !insertmacro MUI_DESCRIPTION_TEXT ${SecPyBindings3.6} $(DESC_SecPyBindings3.6) + !insertmacro MUI_DESCRIPTION_TEXT ${SecPyBindings3.7} $(DESC_SecPyBindings3.7) + !insertmacro MUI_DESCRIPTION_TEXT ${SecPyBindings3.8} $(DESC_SecPyBindings3.8) + !insertmacro MUI_DESCRIPTION_TEXT ${SecPyBindings3.9} $(DESC_SecPyBindings3.9) + !endif + !ifdef INCLUDE_PYVER !insertmacro MUI_DESCRIPTION_TEXT ${SecPython} $(DESC_SecPython) !endif !insertmacro MUI_DESCRIPTION_TEXT ${SecHeadersLibs} $(DESC_SecHeadersLibs) diff --git a/makepanda/makepackage.py b/makepanda/makepackage.py index ce7282626e..e23bedffd7 100755 --- a/makepanda/makepackage.py +++ b/makepanda/makepackage.py @@ -168,17 +168,10 @@ def MakeInstallerNSIS(version, file, title, installdir, runtime=False, compresso elif os.path.isdir(file): shutil.rmtree(file) - if "PYTHONVERSION" in SDK: - pyver = SDK["PYTHONVERSION"][6:9] - else: - pyver = "%d.%d" % (sys.version_info[:2]) - if GetTargetArch() == 'x64': regview = '64' else: regview = '32' - if int(pyver[0]) == 3 and int(pyver[2]) >= 5: - pyver += '-32' if runtime: # Invoke the make_installer script. @@ -211,11 +204,22 @@ def MakeInstallerNSIS(version, file, title, installdir, runtime=False, compresso 'OUTFILE' : '..\\' + file, 'BUILT' : '..\\' + outputdir, 'SOURCE' : '..', - 'PYVER' : pyver, 'REGVIEW' : regview, - 'EXT_SUFFIX': GetExtensionSuffix(), } + # Are we shipping a version of Python? + if os.path.isfile(os.path.join(outputdir, "python", "python.exe")): + py_dlls = glob.glob(os.path.join(outputdir, "python", "python[0-9][0-9].dll")) \ + + glob.glob(os.path.join(outputdir, "python", "python[0-9][0-9]_d.dll")) + assert py_dlls + py_dll = os.path.basename(py_dlls[0]) + pyver = py_dll[6] + "." + py_dll[7] + + if GetTargetArch() != 'x64': + pyver += '-32' + + nsis_defs['INCLUDE_PYVER'] = pyver + if GetHost() == 'windows': cmd = os.path.join(GetThirdpartyBase(), 'win-nsis', 'makensis') + ' /V2' for item in nsis_defs.items(): @@ -651,7 +655,7 @@ def MakeInstallerOSX(version, runtime=False, python_versions=[], **kwargs): dist.write(' \n') if python_versions: dist.write(' \n') - for version_info in python_versions: + for version_info in sorted(python_versions, key=lambda info:info["version"], reverse=True): dist.write(' \n' % (version_info["version"])) dist.write(' \n') dist.write(' \n') @@ -978,13 +982,9 @@ def MakeInstaller(version, **kwargs): fn += version - if "PYTHONVERSION" in SDK: - pyver = SDK["PYTHONVERSION"][6:9] - else: - pyver = "%d.%d" % (sys.version_info[:2]) - - if not runtime and pyver != "2.7": - fn += '-py' + pyver + python_versions = kwargs.get('python_versions', []) + if not runtime and len(python_versions) == 1 and python_versions[0]["version"] != "2.7": + fn += '-py' + python_versions[0]["version"] if GetOptimize() <= 2: fn += "-dbg" From f29643dd14bd2cbf52037216b0cbd75e4b94c7b4 Mon Sep 17 00:00:00 2001 From: Donny Lawrence Date: Wed, 26 Dec 2018 22:46:29 +0100 Subject: [PATCH 30/33] cocoa: Prevent a deadlock when using SIMPLE_THREADS on macOS Closes #491 Fixes #490 --- panda/src/cocoadisplay/cocoaGraphicsStateGuardian.h | 4 ++-- .../src/cocoadisplay/cocoaGraphicsStateGuardian.mm | 6 ++++-- panda/src/cocoadisplay/cocoaGraphicsWindow.mm | 3 ++- panda/src/pipeline/conditionVarImpl.h | 13 +++++++++++++ 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/panda/src/cocoadisplay/cocoaGraphicsStateGuardian.h b/panda/src/cocoadisplay/cocoaGraphicsStateGuardian.h index 8365834a16..c8820a73d3 100644 --- a/panda/src/cocoadisplay/cocoaGraphicsStateGuardian.h +++ b/panda/src/cocoadisplay/cocoaGraphicsStateGuardian.h @@ -50,8 +50,8 @@ public: FrameBufferProperties _fbprops; CVDisplayLinkRef _display_link = nullptr; - Mutex _swap_lock; - ConditionVar _swap_condition; + TrueMutexImpl _swap_lock; + TrueConditionVarImpl _swap_condition; AtomicAdjust::Integer _last_wait_frame = 0; protected: diff --git a/panda/src/cocoadisplay/cocoaGraphicsStateGuardian.mm b/panda/src/cocoadisplay/cocoaGraphicsStateGuardian.mm index 92f6226492..aac8beb033 100644 --- a/panda/src/cocoadisplay/cocoaGraphicsStateGuardian.mm +++ b/panda/src/cocoadisplay/cocoaGraphicsStateGuardian.mm @@ -37,8 +37,9 @@ display_link_cb(CVDisplayLinkRef link, const CVTimeStamp *now, const CVTimeStamp* output_time, CVOptionFlags flags_in, CVOptionFlags *flags_out, void *context) { CocoaGraphicsStateGuardian *gsg = (CocoaGraphicsStateGuardian *)context; - MutexHolder swap_holder(gsg->_swap_lock); + gsg->_swap_lock.lock(); gsg->_swap_condition.notify(); + gsg->_swap_lock.unlock(); return kCVReturnSuccess; } @@ -73,8 +74,9 @@ CocoaGraphicsStateGuardian:: if (_display_link != nil) { CVDisplayLinkRelease(_display_link); _display_link = nil; - MutexHolder swap_holder(_swap_lock); + _swap_lock.lock(); _swap_condition.notify(); + _swap_lock.unlock(); } if (_context != nil) { [_context clearDrawable]; diff --git a/panda/src/cocoadisplay/cocoaGraphicsWindow.mm b/panda/src/cocoadisplay/cocoaGraphicsWindow.mm index 85e01917eb..c3f23d4013 100644 --- a/panda/src/cocoadisplay/cocoaGraphicsWindow.mm +++ b/panda/src/cocoadisplay/cocoaGraphicsWindow.mm @@ -277,8 +277,9 @@ end_flip() { if (_vsync_enabled) { AtomicAdjust::Integer cur_frame = ClockObject::get_global_clock()->get_frame_count(); if (AtomicAdjust::set(cocoagsg->_last_wait_frame, cur_frame) != cur_frame) { - MutexHolder swap_holder(cocoagsg->_swap_lock); + cocoagsg->_swap_lock.lock(); cocoagsg->_swap_condition.wait(); + cocoagsg->_swap_lock.unlock(); } } diff --git a/panda/src/pipeline/conditionVarImpl.h b/panda/src/pipeline/conditionVarImpl.h index 499a5b0c62..7837622ba6 100644 --- a/panda/src/pipeline/conditionVarImpl.h +++ b/panda/src/pipeline/conditionVarImpl.h @@ -50,4 +50,17 @@ typedef ConditionVarPosixImpl ConditionVarFullImpl; #endif +#if defined(WIN32_VC) +#include "conditionVarWin32Impl.h" +typedef ConditionVarWin32Impl TrueConditionVarImpl; + +#elif defined(HAVE_POSIX_THREADS) +#include "conditionVarPosixImpl.h" +typedef ConditionVarPosixImpl TrueConditionVarImpl; + +#else +// No true threads, sorry. Better not try to use 'em. + +#endif + #endif From a9d6d3be46be68576008577f1ca1c453b23cddd7 Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 26 Dec 2018 20:03:14 +0100 Subject: [PATCH 31/33] interrogate: refactor default argument handling --- dtool/src/cppparser/cppExpression.cxx | 60 +++- dtool/src/cppparser/cppExpression.h | 1 + .../interfaceMakerPythonNative.cxx | 322 +++++++++--------- 3 files changed, 220 insertions(+), 163 deletions(-) diff --git a/dtool/src/cppparser/cppExpression.cxx b/dtool/src/cppparser/cppExpression.cxx index 2b2cc0bd50..78da68b5a7 100644 --- a/dtool/src/cppparser/cppExpression.cxx +++ b/dtool/src/cppparser/cppExpression.cxx @@ -25,6 +25,7 @@ #include "cppFunctionGroup.h" #include "cppFunctionType.h" #include "cppClosureType.h" +#include "cppReferenceType.h" #include "cppStructType.h" #include "cppBison.h" #include "pdtoa.h" @@ -260,12 +261,12 @@ CPPExpression(CPPIdentifier *ident, CPPScope *current_scope, _u._variable = inst; return; } - CPPFunctionGroup *fgroup = decl->as_function_group(); + /*CPPFunctionGroup *fgroup = decl->as_function_group(); if (fgroup != nullptr) { _type = T_function; _u._fgroup = fgroup; return; - } + }*/ } _type = T_unknown_ident; @@ -1232,6 +1233,61 @@ determine_type() const { return nullptr; // Compiler kludge; can't get here. } +/** + * Returns true if this is an lvalue expression. + */ +bool CPPExpression:: +is_lvalue() const { + switch (_type) { + case T_variable: + case T_function: + case T_unknown_ident: + return true; + + case T_typecast: + case T_static_cast: + case T_dynamic_cast: + case T_const_cast: + case T_reinterpret_cast: + { + CPPReferenceType *ref_type = _u._typecast._to->as_reference_type(); + return ref_type != nullptr && ref_type->_value_category == CPPReferenceType::VC_lvalue; + } + + case T_unary_operation: + if (_u._op._operator == 'f') { + // A function returning an lvalue reference. + CPPType *return_type = determine_type(); + if (return_type != nullptr) { + CPPReferenceType *ref_type = return_type->as_reference_type(); + return ref_type != nullptr && ref_type->_value_category == CPPReferenceType::VC_lvalue; + } + } + return _u._op._operator == PLUSPLUS + || _u._op._operator == MINUSMINUS + || _u._op._operator == '*'; + + case T_binary_operation: + if (_u._op._operator == ',') { + CPPReferenceType *ref_type = _u._op._op2->as_reference_type(); + return ref_type != nullptr && ref_type->_value_category == CPPReferenceType::VC_lvalue; + } + return (_u._op._operator == POINTSAT || _u._op._operator == ','); + + case T_trinary_operation: + return _u._op._op2->is_lvalue() && _u._op._op3->is_lvalue(); + + case T_literal: + case T_raw_literal: + return true; + + default: + break; + } + + return false; +} + /** * Returns true if this declaration is an actual, factual declaration, or * false if some part of the declaration depends on a template parameter which diff --git a/dtool/src/cppparser/cppExpression.h b/dtool/src/cppparser/cppExpression.h index 4482727f53..3cea871679 100644 --- a/dtool/src/cppparser/cppExpression.h +++ b/dtool/src/cppparser/cppExpression.h @@ -133,6 +133,7 @@ public: Result evaluate() const; CPPType *determine_type() const; + bool is_lvalue() const; bool is_tbd() const; virtual bool is_fully_specified() const; diff --git a/dtool/src/interrogate/interfaceMakerPythonNative.cxx b/dtool/src/interrogate/interfaceMakerPythonNative.cxx index 59575668d4..3964cad919 100644 --- a/dtool/src/interrogate/interfaceMakerPythonNative.cxx +++ b/dtool/src/interrogate/interfaceMakerPythonNative.cxx @@ -4078,13 +4078,9 @@ write_coerce_constructor(ostream &out, Object *obj, bool is_const) { /** * Special case optimization: if the last map is a subset of the map before - * it, and the last parameter is only a simple parameter type (that we have - * special default argument handling for), we can merge the cases. When this - * happens, we can make use of a special feature of PyArg_ParseTuple for - * handling of these last few default arguments. This doesn't work well for - * all types of default expressions, though, hence the need for this elaborate - * checking mechanism down here, which goes in parallel with the actual - * optional arg handling logic in write_function_instance. + * it, we can merge the cases. When this happens, we can make use of a + * special feature of PyArg_ParseTuple for handling of these last few default + * arguments. * * This isn't just to help reduce the amount of generated code; it also * enables arbitrary selection of keyword arguments for many functions, ie. @@ -4095,14 +4091,6 @@ write_coerce_constructor(ostream &out, Object *obj, bool is_const) { * Thanks to this mechanism, we can call it like so: * * func(c=True, d=".") - * - * The return value is the minimum of the number of maximum arguments. - * - * Sorry, let me try that again: it returns the largest number of arguments - * for which the overloads will be separated out rather than handled via the - * special default handling mechanism. Or something. - * - * Please don't hate me. */ int InterfaceMakerPythonNative:: collapse_default_remaps(std::map > &map_sets, @@ -4118,70 +4106,8 @@ collapse_default_remaps(std::map > &map_sets, if (std::includes(rmi_next->second.begin(), rmi_next->second.end(), rmi->second.begin(), rmi->second.end())) { - // Check if the nth argument is something we can easily create a default - // for. - std::set::iterator sii; - for (sii = rmi->second.begin(); sii != rmi->second.end(); ++sii) { - FunctionRemap *remap = (*sii); - size_t pn = (size_t)rmi->first; - if (!remap->_has_this || remap->_type == FunctionRemap::T_constructor) { - --pn; - } - nassertd(pn < remap->_parameters.size()) goto abort_iteration; - - ParameterRemap *param = remap->_parameters[pn]._remap; - CPPType *type = param->get_new_type(); - - if (param->new_type_is_atomic_string()) { - CPPType *orig_type = param->get_orig_type(); - if (TypeManager::is_char_pointer(orig_type)) { - } else if (TypeManager::is_wchar_pointer(orig_type)) { - goto abort_iteration; - } else if (TypeManager::is_wstring(orig_type)) { - goto abort_iteration; - } else if (TypeManager::is_const_ptr_to_basic_string_wchar(orig_type)) { - goto abort_iteration; - } else { - // Regular strings are OK if the default argument is a string - // literal or the default string constructor, since those are - // trivial to handle. This actually covers almost all of the - // cases of default string args. - CPPExpression::Type expr_type = param->get_default_value()->_type; - if (expr_type != CPPExpression::T_default_construct && - expr_type != CPPExpression::T_string) { - goto abort_iteration; - } - } - } else if (TypeManager::is_integer(type)) { - } else if (TypeManager::is_float(type)) { - } else if (TypeManager::is_const_char_pointer(type)) { - } else if (TypeManager::is_pointer_to_PyTypeObject(type)) { - } else if (TypeManager::is_pointer_to_PyStringObject(type)) { - } else if (TypeManager::is_pointer_to_PyUnicodeObject(type)) { - } else if (TypeManager::is_pointer_to_PyObject(type)) { - } else if (TypeManager::is_pointer_to_Py_buffer(type)) { - goto abort_iteration; - } else if (TypeManager::is_pointer_to_simple(type)) { - goto abort_iteration; - } else if (TypeManager::is_pointer(type)) { - // I'm allowing other pointer types, but only if the expression - // happens to evaluate to a numeric constant (which will likely only - // be NULL). There are too many issues to resolve right now with - // allowing more complex default expressions, including issues in - // the C++ parser (but the reader is welcome to give it a try!) - CPPExpression::Result res = param->get_default_value()->evaluate(); - if (res._type != CPPExpression::RT_integer && - res._type != CPPExpression::RT_pointer) { - goto abort_iteration; - } - } else { - goto abort_iteration; - } - } - // rmi_next has a superset of the remaps in rmi, and we are going to - // erase rmi_next, so put all the remaps in rmi. rmi->second = - // rmi_next->second; + // erase rmi_next, so put all the remaps in rmi. max_required_args = rmi_next->first; rmi = rmi_next; @@ -4191,7 +4117,6 @@ collapse_default_remaps(std::map > &map_sets, } } -abort_iteration: // Now erase the other remap sets. Reverse iterators are weird, we first // need to get forward iterators and decrement them by one. std::map >::iterator erase_begin, erase_end; @@ -4738,6 +4663,7 @@ write_function_instance(ostream &out, FunctionRemap *remap, "(" + orig_type->get_local_name(&parser) + ")" + param_name; string default_expr; + const char *null_assign = ""; if (is_optional) { // If this is an optional argument, PyArg_ParseTuple will leave the @@ -4747,6 +4673,7 @@ write_function_instance(ostream &out, FunctionRemap *remap, default_expr_str << " = "; default_value->output(default_expr_str, 0, &parser, false); default_expr = default_expr_str.str(); + null_assign = " = nullptr"; // We should only ever have to consider optional arguments for functions // taking a variable number of arguments. @@ -4776,23 +4703,40 @@ write_function_instance(ostream &out, FunctionRemap *remap, expected_params += "str"; } else if (TypeManager::is_wchar_pointer(orig_type)) { - indent(out, indent_level) << "#if PY_VERSION_HEX >= 0x03020000\n"; - indent(out, indent_level) << "PyObject *" << param_name << ";\n"; - indent(out, indent_level) << "#else\n"; - indent(out, indent_level) << "PyUnicodeObject *" << param_name << ";\n"; - indent(out, indent_level) << "#endif\n"; + out << "#if PY_VERSION_HEX >= 0x03020000\n"; + indent(out, indent_level) << "PyObject *" << param_name << null_assign << ";\n"; + out << "#else\n"; + indent(out, indent_level) << "PyUnicodeObject *" << param_name << null_assign << ";\n"; + out << "#endif\n"; format_specifiers += "U"; parameter_list += ", &" + param_name; - extra_convert - << "#if PY_VERSION_HEX >= 0x03030000\n" - << "wchar_t *" << param_name << "_str = PyUnicode_AsWideCharString(" << param_name << ", nullptr);\n" - << "#else" - << "Py_ssize_t " << param_name << "_len = PyUnicode_GET_SIZE(" << param_name << ");\n" - << "wchar_t *" << param_name << "_str = (wchar_t *)alloca(sizeof(wchar_t) * (" + param_name + "_len + 1));\n" - << "PyUnicode_AsWideChar(" << param_name << ", " << param_name << "_str, " << param_name << "_len);\n" - << param_name << "_str[" << param_name << "_len] = 0;\n" - << "#endif\n"; + if (is_optional) { + extra_convert + << "wchar_t *" << param_name << "_str;\n" + << "if (" << param_name << " != nullptr) {\n" + << "#if PY_VERSION_HEX >= 0x03030000\n" + << " " << param_name << "_str = PyUnicode_AsWideCharString(" << param_name << ", nullptr);\n" + << "#else" + << "Py_ssize_t " << param_name << "_len = PyUnicode_GET_SIZE(" << param_name << ");\n" + << " " << param_name << "_str = (wchar_t *)alloca(sizeof(wchar_t) * (" + param_name + "_len + 1));\n" + << "PyUnicode_AsWideChar(" << param_name << ", " << param_name << "_str, " << param_name << "_len);\n" + << param_name << "_str[" << param_name << "_len] = 0;\n" + << "#endif\n" + << "} else {\n" + << " " << param_name << "_str" << default_expr << ";\n" + << "}\n"; + } else { + extra_convert + << "#if PY_VERSION_HEX >= 0x03030000\n" + << "wchar_t *" << param_name << "_str = PyUnicode_AsWideCharString(" << param_name << ", nullptr);\n" + << "#else" + << "Py_ssize_t " << param_name << "_len = PyUnicode_GET_SIZE(" << param_name << ");\n" + << "wchar_t *" << param_name << "_str = (wchar_t *)alloca(sizeof(wchar_t) * (" + param_name + "_len + 1));\n" + << "PyUnicode_AsWideChar(" << param_name << ", " << param_name << "_str, " << param_name << "_len);\n" + << param_name << "_str[" << param_name << "_len] = 0;\n" + << "#endif\n"; + } pexpr_string = param_name + "_str"; @@ -4803,56 +4747,48 @@ write_function_instance(ostream &out, FunctionRemap *remap, expected_params += "unicode"; - } else if (TypeManager::is_wstring(orig_type)) { - indent(out, indent_level) << "#if PY_VERSION_HEX >= 0x03020000\n"; - indent(out, indent_level) << "PyObject *" << param_name << ";\n"; - indent(out, indent_level) << "#else\n"; - indent(out, indent_level) << "PyUnicodeObject *" << param_name << ";\n"; - indent(out, indent_level) << "#endif\n"; + } else if (TypeManager::is_wstring(orig_type) || + TypeManager::is_const_ptr_to_basic_string_wchar(orig_type)) { + out << "#if PY_VERSION_HEX >= 0x03020000\n"; + indent(out, indent_level) << "PyObject *" << param_name << null_assign << ";\n"; + out << "#else\n"; + indent(out, indent_level) << "PyUnicodeObject *" << param_name << null_assign << ";\n"; + out << "#endif\n"; format_specifiers += "U"; parameter_list += ", &" + param_name; - extra_convert - << "#if PY_VERSION_HEX >= 0x03030000\n" - << "Py_ssize_t " << param_name << "_len;\n" - << "wchar_t *" << param_name << "_str = PyUnicode_AsWideCharString(" - << param_name << ", &" << param_name << "_len);\n" - << "#else\n" - << "Py_ssize_t " << param_name << "_len = PyUnicode_GET_SIZE(" << param_name << ");\n" - << "wchar_t *" << param_name << "_str = (wchar_t *)alloca(sizeof(wchar_t) * (" + param_name + "_len + 1));\n" - << "PyUnicode_AsWideChar(" << param_name << ", " << param_name << "_str, " << param_name << "_len);\n" - << "#endif\n"; - - pexpr_string = param_name + "_str, " + param_name + "_len"; - - extra_cleanup - << "#if PY_VERSION_HEX >= 0x03030000\n" - << "PyMem_Free(" << param_name << "_str);\n" - << "#endif\n"; - - expected_params += "unicode"; - - } else if (TypeManager::is_const_ptr_to_basic_string_wchar(orig_type)) { - indent(out, indent_level) << "#if PY_VERSION_HEX >= 0x03020000\n"; - indent(out, indent_level) << "PyObject *" << param_name << ";\n"; - indent(out, indent_level) << "#else\n"; - indent(out, indent_level) << "PyUnicodeObject *" << param_name << ";\n"; - indent(out, indent_level) << "#endif\n"; - format_specifiers += "U"; - parameter_list += ", &" + param_name; - - extra_convert - << "#if PY_VERSION_HEX >= 0x03030000\n" - << "Py_ssize_t " << param_name << "_len;\n" - << "wchar_t *" << param_name << "_str = PyUnicode_AsWideCharString(" - << param_name << ", &" << param_name << "_len);\n" - << "#else\n" - << "Py_ssize_t " << param_name << "_len = PyUnicode_GET_SIZE(" << param_name << ");\n" - << "wchar_t *" << param_name << "_str = (wchar_t *)alloca(sizeof(wchar_t) * (" + param_name + "_len + 1));\n" - << "PyUnicode_AsWideChar(" << param_name << ", " << param_name << "_str, " << param_name << "_len);\n" - << "#endif\n"; - - pexpr_string = param_name + "_str, " + param_name + "_len"; + if (is_optional) { + extra_convert + << "Py_ssize_t " << param_name << "_len;\n" + << "wchar_t *" << param_name << "_str;\n" + << "std::wstring " << param_name << "_wstr;\n" + << "if (" << param_name << " != nullptr) {\n" + << "#if PY_VERSION_HEX >= 0x03030000\n" + << " " << param_name << "_str = PyUnicode_AsWideCharString(" + << param_name << ", &" << param_name << "_len);\n" + << "#else\n" + << " " << param_name << "_len = PyUnicode_GET_SIZE(" << param_name << ");\n" + << " " << param_name << "_str = (wchar_t *)alloca(sizeof(wchar_t) * (" + param_name + "_len + 1));\n" + << "PyUnicode_AsWideChar(" << param_name << ", " << param_name << "_str, " << param_name << "_len);\n" + << "#endif\n" + << " " << param_name << "_wstr.assign(" << param_name << "_str, " << param_name << "_len);\n" + << "} else {\n" + << " " << param_name << "_wstr" << default_expr << ";\n" + << "}\n"; + pexpr_string = "std::move(" + param_name + "_wstr)"; + } else { + extra_convert + << "#if PY_VERSION_HEX >= 0x03030000\n" + << "Py_ssize_t " << param_name << "_len;\n" + << "wchar_t *" << param_name << "_str = PyUnicode_AsWideCharString(" + << param_name << ", &" << param_name << "_len);\n" + << "#else\n" + << "Py_ssize_t " << param_name << "_len = PyUnicode_GET_SIZE(" << param_name << ");\n" + << "wchar_t *" << param_name << "_str = (wchar_t *)alloca(sizeof(wchar_t) * (" + param_name + "_len + 1));\n" + << "PyUnicode_AsWideChar(" << param_name << ", " << param_name << "_str, " << param_name << "_len);\n" + << "#endif\n"; + pexpr_string = param_name + "_str, " + param_name + "_len"; + } extra_cleanup << "#if PY_VERSION_HEX >= 0x03030000\n" @@ -5019,11 +4955,11 @@ write_function_instance(ostream &out, FunctionRemap *remap, only_pyobjects = false; } else if (TypeManager::is_wchar(type)) { - indent(out, indent_level) << "#if PY_VERSION_HEX >= 0x03020000\n"; + out << "#if PY_VERSION_HEX >= 0x03020000\n"; indent(out, indent_level) << "PyObject *" << param_name << ";\n"; - indent(out, indent_level) << "#else\n"; + out << "#else\n"; indent(out, indent_level) << "PyUnicodeObject *" << param_name << ";\n"; - indent(out, indent_level) << "#endif\n"; + out << "#endif\n"; format_specifiers += "U"; parameter_list += ", &" + param_name; @@ -5348,17 +5284,36 @@ write_function_instance(ostream &out, FunctionRemap *remap, if (args_type == AT_single_arg) { param_name = "arg"; } else { - indent(out, indent_level) << "PyObject *" << param_name << ";\n"; + indent(out, indent_level) << "PyObject *" << param_name << null_assign << ";\n"; format_specifiers += "O"; parameter_list += ", &" + param_name; } indent(out, indent_level) << "Py_buffer " << param_name << "_view;\n"; - extra_param_check << " && PyObject_GetBuffer(" - << param_name << ", &" - << param_name << "_view, PyBUF_FULL) == 0"; - pexpr_string = "&" + param_name + "_view"; - extra_cleanup << "PyBuffer_Release(&" << param_name << "_view);\n"; + if (is_optional) { + indent(out, indent_level) << "Py_buffer *" << param_name << "_viewp;\n"; + + extra_convert + << "bool " << param_name << "_success;\n" + << "if (" << param_name << " != nullptr) {\n" + << " " << param_name << "_success = (PyObject_GetBuffer(" + << param_name << ", &" << param_name << "_view, PyBUF_FULL) == 0);\n" + << " " << param_name << "_viewp = &" << param_name << "_view;\n" + << "} else {\n" + << " " << param_name << "_viewp" << default_expr << ";\n" + << " " << param_name << "_success = true;\n" + << "}\n"; + + extra_param_check << " && " << param_name << "_success"; + pexpr_string = param_name + "_viewp"; + extra_cleanup << "if (" << param_name << " != nullptr) PyBuffer_Release(&" << param_name << "_view);\n"; + } else { + extra_param_check << " && PyObject_GetBuffer(" + << param_name << ", &" + << param_name << "_view, PyBUF_FULL) == 0"; + pexpr_string = "&" + param_name + "_view"; + extra_cleanup << "PyBuffer_Release(&" << param_name << "_view);\n"; + } expected_params += "buffer"; may_raise_typeerror = true; clear_error = true; @@ -5367,7 +5322,7 @@ write_function_instance(ostream &out, FunctionRemap *remap, if (args_type == AT_single_arg) { param_name = "arg"; } else { - indent(out, indent_level) << "PyObject *" << param_name << ";\n"; + indent(out, indent_level) << "PyObject *" << param_name << null_assign << ";\n"; format_specifiers += "O"; parameter_list += ", &" + param_name; } @@ -5496,18 +5451,15 @@ write_function_instance(ostream &out, FunctionRemap *remap, if (args_type == AT_single_arg) { param_name = "arg"; } else { - indent(out, indent_level) << "PyObject *" << param_name; - if (is_optional) { - out << " = nullptr"; - } - out << ";\n"; + indent(out, indent_level) << "PyObject *" << param_name << null_assign << ";\n"; format_specifiers += "O"; parameter_list += ", &" + param_name; } // If the default value is NULL, we also accept a None value. bool maybe_none = false; - if (default_value != nullptr && (return_flags & RF_coerced) == 0) { + if (default_value != nullptr && (return_flags & RF_coerced) == 0 && + TypeManager::is_pointer(orig_type)) { CPPExpression::Result res = param->get_default_value()->evaluate(); if (res._type == CPPExpression::RT_integer || res._type == CPPExpression::RT_pointer) { @@ -5576,8 +5528,11 @@ write_function_instance(ostream &out, FunctionRemap *remap, << "if (" << param_name << " != nullptr && " << param_name << " != Py_None) {\n" << " " << param_name << "_this"; } else if (is_optional) { + if (TypeManager::is_pointer(orig_type)) { + extra_convert << default_expr; + } extra_convert - << default_expr << ";\n" + << ";\n" << "if (" << param_name << " != nullptr) {\n" << " " << param_name << "_this"; } else if (maybe_none) { @@ -5590,7 +5545,13 @@ write_function_instance(ostream &out, FunctionRemap *remap, extra_convert << " = Dtool_Coerce_" + make_safe_name(class_name) + "(" + param_name + ", " + param_name + "_local);\n"; - if (is_optional || maybe_none) { + if (is_optional && !TypeManager::is_pointer(orig_type)) { + extra_convert + << "} else {\n" + << " " << param_name << "_local" << default_expr << ";\n" + << " " << param_name << "_this = &" << param_name << "_local;\n" + << "}\n"; + } else if (is_optional || maybe_none) { extra_convert << "}\n"; } @@ -5645,21 +5606,60 @@ write_function_instance(ostream &out, FunctionRemap *remap, } else { // The regular, non-coercion case. type->output_instance(extra_convert, param_name + "_this", &parser); if (is_optional && maybe_none) { + // This parameter has a default value of nullptr, so we need to also + // allow passing in None. extra_convert << default_expr << ";\n" << "if (" << param_name << " != nullptr && " << param_name << " != Py_None) {\n" << " " << param_name << "_this"; - } else if (is_optional) { + } + else if (is_optional && !TypeManager::is_pointer(orig_type) && !default_value->is_lvalue()) { + // Most annoying case, where we have to use an rvalue reference to + // extend the lifetime of the default argument. In this case, the + // default expression is invoked even if not used. + extra_convert << ";\n"; + if (TypeManager::is_const_pointer_to_anything(type)) { + extra_convert << "const "; + obj_type->output_instance(extra_convert, "&" + param_name + "_ref", &parser); + } else { + obj_type->output_instance(extra_convert, "&&" + param_name + "_ref", &parser); + } extra_convert << default_expr << ";\n" - << "if (" << param_name << " != nullptr) {\n" + << "if (" << param_name << " == nullptr) {\n" + << " " << param_name << "_this = &" << param_name << "_ref;\n" + << "} else {\n" << " " << param_name << "_this"; - } else if (maybe_none) { + } + else if (is_optional) { + // General case where the default argument is either an lvalue or a + // pointer. + extra_convert + << ";\n" + << "if (" << param_name << " == nullptr) {\n" + << " " << param_name << "_this = "; + if (TypeManager::is_pointer(orig_type)) { + default_value->output(extra_convert, 0, &parser, false); + extra_convert << ";\n"; + } else { + // The rvalue case was handled above, so this is an lvalue, which + // means we can safely take a reference to it. + extra_convert << "&("; + default_value->output(extra_convert, 0, &parser, false); + extra_convert << ");\n"; + } + extra_convert + << "} else {\n" + << " " << param_name << "_this"; + } + else if (maybe_none) { + // No default argument, but we still need to check for None. extra_convert << " = nullptr;\n" << "if (" << param_name << " != Py_None) {\n" << " " << param_name << "_this"; } + if (const_ok && !report_errors) { // This function does the same thing in this case and is slightly // simpler. But maybe we should just reorganize these functions From 669a65536623ac8ba0e3f5c3186c23cf3c0ce5de Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 26 Dec 2018 22:44:26 +0100 Subject: [PATCH 32/33] Fix ShaderBuffer cleanup assertion with state cache disabled --- panda/src/glstuff/glBufferContext_src.I | 5 ++- panda/src/glstuff/glBufferContext_src.h | 3 +- panda/src/glstuff/glGraphicsBuffer_src.cxx | 2 +- .../glstuff/glGraphicsStateGuardian_src.cxx | 2 +- panda/src/gobj/bufferContext.I | 8 ++++ panda/src/gobj/bufferContext.cxx | 3 +- panda/src/gobj/bufferContext.h | 12 +++++- panda/src/gobj/indexBufferContext.I | 15 +++---- panda/src/gobj/indexBufferContext.h | 3 -- panda/src/gobj/preparedGraphicsObjects.cxx | 43 +++++++++++-------- panda/src/gobj/shaderBuffer.cxx | 25 +++++++++++ panda/src/gobj/shaderBuffer.h | 5 +++ panda/src/gobj/textureContext.I | 19 ++++---- panda/src/gobj/textureContext.h | 3 -- panda/src/gobj/vertexBufferContext.I | 15 +++---- panda/src/gobj/vertexBufferContext.h | 4 -- 16 files changed, 106 insertions(+), 61 deletions(-) diff --git a/panda/src/glstuff/glBufferContext_src.I b/panda/src/glstuff/glBufferContext_src.I index bec8283a18..56ecf2102a 100644 --- a/panda/src/glstuff/glBufferContext_src.I +++ b/panda/src/glstuff/glBufferContext_src.I @@ -16,8 +16,9 @@ */ INLINE CLP(BufferContext):: CLP(BufferContext)(CLP(GraphicsStateGuardian) *glgsg, - PreparedGraphicsObjects *pgo) : - BufferContext(&pgo->_sbuffer_residency), + PreparedGraphicsObjects *pgo, + TypedWritableReferenceCount *object) : + BufferContext(&pgo->_sbuffer_residency, object), AdaptiveLruPage(0), _glgsg(glgsg) { diff --git a/panda/src/glstuff/glBufferContext_src.h b/panda/src/glstuff/glBufferContext_src.h index b6c46aab76..b67a9d214e 100644 --- a/panda/src/glstuff/glBufferContext_src.h +++ b/panda/src/glstuff/glBufferContext_src.h @@ -21,7 +21,8 @@ class EXPCL_GL CLP(BufferContext) : public BufferContext, public AdaptiveLruPage { public: INLINE CLP(BufferContext)(CLP(GraphicsStateGuardian) *glgsg, - PreparedGraphicsObjects *pgo); + PreparedGraphicsObjects *pgo, + TypedWritableReferenceCount *object); ALLOC_DELETED_CHAIN(CLP(BufferContext)); virtual void evict_lru(); diff --git a/panda/src/glstuff/glGraphicsBuffer_src.cxx b/panda/src/glstuff/glGraphicsBuffer_src.cxx index 8fbba8f79d..ebb038de7a 100644 --- a/panda/src/glstuff/glGraphicsBuffer_src.cxx +++ b/panda/src/glstuff/glGraphicsBuffer_src.cxx @@ -1413,7 +1413,7 @@ open_buffer() { } if (_rb_context == nullptr) { - _rb_context = new BufferContext(&(glgsg->_renderbuffer_residency)); + _rb_context = new BufferContext(&(glgsg->_renderbuffer_residency), nullptr); } /* diff --git a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx index df2095284c..1e6d1781cc 100644 --- a/panda/src/glstuff/glGraphicsStateGuardian_src.cxx +++ b/panda/src/glstuff/glGraphicsStateGuardian_src.cxx @@ -6519,7 +6519,7 @@ prepare_shader_buffer(ShaderBuffer *data) { if (_supports_shader_buffers) { PStatGPUTimer timer(this, _prepare_shader_buffer_pcollector); - CLP(BufferContext) *gbc = new CLP(BufferContext)(this, _prepared_objects); + CLP(BufferContext) *gbc = new CLP(BufferContext)(this, _prepared_objects, data); _glGenBuffers(1, &gbc->_index); if (GLCAT.is_debug() && gl_debug_buffers) { diff --git a/panda/src/gobj/bufferContext.I b/panda/src/gobj/bufferContext.I index 3c34d93a8a..6d564cef02 100644 --- a/panda/src/gobj/bufferContext.I +++ b/panda/src/gobj/bufferContext.I @@ -11,6 +11,14 @@ * @date 2006-03-16 */ +/** + * Returns the associated object. + */ +INLINE TypedWritableReferenceCount *BufferContext:: +get_object() const { + return _object; +} + /** * Returns the number of bytes previously reported for the data object. This * is used to track changes in the data object's allocated size; if it changes diff --git a/panda/src/gobj/bufferContext.cxx b/panda/src/gobj/bufferContext.cxx index 52cac06ce4..b268400d35 100644 --- a/panda/src/gobj/bufferContext.cxx +++ b/panda/src/gobj/bufferContext.cxx @@ -19,7 +19,8 @@ TypeHandle BufferContext::_type_handle; * */ BufferContext:: -BufferContext(BufferResidencyTracker *residency) : +BufferContext(BufferResidencyTracker *residency, TypedWritableReferenceCount *object) : + _object(object), _residency(residency), _residency_state(0), _data_size_bytes(0), diff --git a/panda/src/gobj/bufferContext.h b/panda/src/gobj/bufferContext.h index dedf5411e9..60c9ab3333 100644 --- a/panda/src/gobj/bufferContext.h +++ b/panda/src/gobj/bufferContext.h @@ -23,6 +23,7 @@ #include "bufferResidencyTracker.h" class PreparedGraphicsObjects; +class TypedWritableReferenceCount; /** * This is a base class for those kinds of SavedContexts that occupy an @@ -36,15 +37,19 @@ class PreparedGraphicsObjects; */ class EXPCL_PANDA_GOBJ BufferContext : public SavedContext, private LinkedListNode { public: - BufferContext(BufferResidencyTracker *residency); + BufferContext(BufferResidencyTracker *residency, TypedWritableReferenceCount *object); virtual ~BufferContext(); + INLINE TypedWritableReferenceCount *get_object() const; + PUBLISHED: INLINE size_t get_data_size_bytes() const; INLINE UpdateSeq get_modified() const; INLINE bool get_active() const; INLINE bool get_resident() const; + MAKE_PROPERTY(object, get_object); + MAKE_PROPERTY(data_size_bytes, get_data_size_bytes); MAKE_PROPERTY(modified, get_modified); MAKE_PROPERTY(active, get_active); @@ -62,6 +67,11 @@ public: private: void set_owning_chain(BufferContextChain *chain); +protected: + // This cannot be a PT(), because the object and the GSG both own their + // BufferContexts! That would create a circular reference count. + TypedWritableReferenceCount *_object; + private: BufferResidencyTracker *_residency; int _residency_state; diff --git a/panda/src/gobj/indexBufferContext.I b/panda/src/gobj/indexBufferContext.I index caf5e7f34a..e55304bfcb 100644 --- a/panda/src/gobj/indexBufferContext.I +++ b/panda/src/gobj/indexBufferContext.I @@ -16,9 +16,8 @@ */ INLINE IndexBufferContext:: IndexBufferContext(PreparedGraphicsObjects *pgo, GeomPrimitive *data) : - BufferContext(&pgo->_ibuffer_residency), - AdaptiveLruPage(0), - _data(data) + BufferContext(&pgo->_ibuffer_residency, data), + AdaptiveLruPage(0) { } @@ -27,7 +26,7 @@ IndexBufferContext(PreparedGraphicsObjects *pgo, GeomPrimitive *data) : */ INLINE GeomPrimitive *IndexBufferContext:: get_data() const { - return _data; + return (GeomPrimitive *)_object; } /** @@ -36,7 +35,7 @@ get_data() const { */ INLINE bool IndexBufferContext:: changed_size(const GeomPrimitivePipelineReader *reader) const { - nassertr(reader->get_object() == _data, false); + nassertr(reader->get_object() == get_data(), false); return get_data_size_bytes() != (size_t)reader->get_data_size_bytes(); } @@ -46,7 +45,7 @@ changed_size(const GeomPrimitivePipelineReader *reader) const { */ INLINE bool IndexBufferContext:: changed_usage_hint(const GeomPrimitivePipelineReader *reader) const { - nassertr(reader->get_object() == _data, false); + nassertr(reader->get_object() == get_data(), false); return _usage_hint != reader->get_usage_hint(); } @@ -56,7 +55,7 @@ changed_usage_hint(const GeomPrimitivePipelineReader *reader) const { */ INLINE bool IndexBufferContext:: was_modified(const GeomPrimitivePipelineReader *reader) const { - nassertr(reader->get_object() == _data, false); + nassertr(reader->get_object() == get_data(), false); return get_modified() != reader->get_modified(); } @@ -76,7 +75,7 @@ update_data_size_bytes(size_t new_data_size_bytes) { */ INLINE void IndexBufferContext:: mark_loaded(const GeomPrimitivePipelineReader *reader) { - nassertv(reader->get_object() == _data); + nassertv(reader->get_object() == get_data()); update_data_size_bytes(reader->get_data_size_bytes()); update_modified(reader->get_modified()); _usage_hint = reader->get_usage_hint(); diff --git a/panda/src/gobj/indexBufferContext.h b/panda/src/gobj/indexBufferContext.h index 6b2004fac2..139ab69362 100644 --- a/panda/src/gobj/indexBufferContext.h +++ b/panda/src/gobj/indexBufferContext.h @@ -50,9 +50,6 @@ public: virtual void write(std::ostream &out, int indent_level) const; private: - // This cannot be a PT(GeomPrimitive), because the data and the GSG both own - // their IndexBufferContexts! That would create a circular reference count. - GeomPrimitive *_data; GeomEnums::UsageHint _usage_hint; public: diff --git a/panda/src/gobj/preparedGraphicsObjects.cxx b/panda/src/gobj/preparedGraphicsObjects.cxx index 96fcd80269..e3ab0e8d83 100644 --- a/panda/src/gobj/preparedGraphicsObjects.cxx +++ b/panda/src/gobj/preparedGraphicsObjects.cxx @@ -270,11 +270,11 @@ void PreparedGraphicsObjects:: release_texture(TextureContext *tc) { ReMutexHolder holder(_lock); - tc->_texture->clear_prepared(tc->get_view(), this); + tc->get_texture()->clear_prepared(tc->get_view(), this); // We have to set the Texture pointer to NULL at this point, since the // Texture itself might destruct at any time after it has been released. - tc->_texture = nullptr; + tc->_object = nullptr; bool removed = (_prepared_textures.erase(tc) != 0); nassertv(removed); @@ -307,8 +307,8 @@ release_all_textures() { tci != _prepared_textures.end(); ++tci) { TextureContext *tc = (*tci); - tc->_texture->clear_prepared(tc->get_view(), this); - tc->_texture = nullptr; + tc->get_texture()->clear_prepared(tc->get_view(), this); + tc->_object = nullptr; _released_textures.insert(tc); } @@ -946,14 +946,14 @@ void PreparedGraphicsObjects:: release_vertex_buffer(VertexBufferContext *vbc) { ReMutexHolder holder(_lock); - vbc->_data->clear_prepared(this); + vbc->get_data()->clear_prepared(this); - size_t data_size_bytes = vbc->_data->get_data_size_bytes(); - GeomEnums::UsageHint usage_hint = vbc->_data->get_usage_hint(); + size_t data_size_bytes = vbc->get_data()->get_data_size_bytes(); + GeomEnums::UsageHint usage_hint = vbc->get_data()->get_usage_hint(); // We have to set the Data pointer to NULL at this point, since the Data // itself might destruct at any time after it has been released. - vbc->_data = nullptr; + vbc->_object = nullptr; bool removed = (_prepared_vertex_buffers.erase(vbc) != 0); nassertv(removed); @@ -985,8 +985,8 @@ release_all_vertex_buffers() { vbci != _prepared_vertex_buffers.end(); ++vbci) { VertexBufferContext *vbc = (VertexBufferContext *)(*vbci); - vbc->_data->clear_prepared(this); - vbc->_data = nullptr; + vbc->get_data()->clear_prepared(this); + vbc->_object = nullptr; _released_vertex_buffers.insert(vbc); } @@ -1061,7 +1061,7 @@ prepare_vertex_buffer_now(GeomVertexArrayData *data, GraphicsStateGuardianBase * _vertex_buffer_cache, _vertex_buffer_cache_lru, _vertex_buffer_cache_size); if (vbc != nullptr) { - vbc->_data = data; + vbc->_object = data; } else { // Ask the GSG to create a brand new VertexBufferContext. There might be @@ -1144,14 +1144,14 @@ void PreparedGraphicsObjects:: release_index_buffer(IndexBufferContext *ibc) { ReMutexHolder holder(_lock); - ibc->_data->clear_prepared(this); + ibc->get_data()->clear_prepared(this); - size_t data_size_bytes = ibc->_data->get_data_size_bytes(); - GeomEnums::UsageHint usage_hint = ibc->_data->get_usage_hint(); + size_t data_size_bytes = ibc->get_data()->get_data_size_bytes(); + GeomEnums::UsageHint usage_hint = ibc->get_data()->get_usage_hint(); // We have to set the Data pointer to NULL at this point, since the Data // itself might destruct at any time after it has been released. - ibc->_data = nullptr; + ibc->_object = nullptr; bool removed = (_prepared_index_buffers.erase(ibc) != 0); nassertv(removed); @@ -1183,8 +1183,8 @@ release_all_index_buffers() { ibci != _prepared_index_buffers.end(); ++ibci) { IndexBufferContext *ibc = (IndexBufferContext *)(*ibci); - ibc->_data->clear_prepared(this); - ibc->_data = nullptr; + ibc->get_data()->clear_prepared(this); + ibc->_object = nullptr; _released_index_buffers.insert(ibc); } @@ -1258,7 +1258,7 @@ prepare_index_buffer_now(GeomPrimitive *data, GraphicsStateGuardianBase *gsg) { _index_buffer_cache, _index_buffer_cache_lru, _index_buffer_cache_size); if (ibc != nullptr) { - ibc->_data = data; + ibc->_object = data; } else { // Ask the GSG to create a brand new IndexBufferContext. There might be @@ -1341,6 +1341,13 @@ void PreparedGraphicsObjects:: release_shader_buffer(BufferContext *bc) { ReMutexHolder holder(_lock); + ShaderBuffer *buffer = (ShaderBuffer *)bc->_object; + buffer->clear_prepared(this); + + // We have to set the ShaderBuffer pointer to NULL at this point, since the + // buffer itself might destruct at any time after it has been released. + bc->_object = nullptr; + bool removed = (_prepared_shader_buffers.erase(bc) != 0); nassertv(removed); diff --git a/panda/src/gobj/shaderBuffer.cxx b/panda/src/gobj/shaderBuffer.cxx index 4e21319b49..fa16293d4d 100644 --- a/panda/src/gobj/shaderBuffer.cxx +++ b/panda/src/gobj/shaderBuffer.cxx @@ -143,6 +143,31 @@ release_all() { return num_freed; } +/** + * Removes the indicated PreparedGraphicsObjects table from the buffer's + * table, without actually releasing the texture. This is intended to be + * called only from PreparedGraphicsObjects::release_shader_buffer(); it + * should never be called by user code. + */ +void ShaderBuffer:: +clear_prepared(PreparedGraphicsObjects *prepared_objects) { + nassertv(_contexts != nullptr); + + Contexts::iterator ci; + ci = _contexts->find(prepared_objects); + if (ci != _contexts->end()) { + _contexts->erase(ci); + if (_contexts->empty()) { + delete _contexts; + _contexts = nullptr; + } + } else { + // If this assertion fails, clear_prepared() was given a prepared_objects + // which the data array didn't know about. + nassert_raise("unknown PreparedGraphicsObjects"); + } +} + /** * Tells the BamReader how to create objects of type ParamValue. */ diff --git a/panda/src/gobj/shaderBuffer.h b/panda/src/gobj/shaderBuffer.h index bdf0538857..0cc0660433 100644 --- a/panda/src/gobj/shaderBuffer.h +++ b/panda/src/gobj/shaderBuffer.h @@ -57,6 +57,9 @@ PUBLISHED: bool release(PreparedGraphicsObjects *prepared_objects); int release_all(); +private: + void clear_prepared(PreparedGraphicsObjects *prepared_objects); + private: uint64_t _data_size_bytes; UsageHint _usage_hint; @@ -91,6 +94,8 @@ public: private: static TypeHandle _type_handle; + + friend class PreparedGraphicsObjects; }; INLINE std::ostream &operator << (std::ostream &out, const ShaderBuffer &m) { diff --git a/panda/src/gobj/textureContext.I b/panda/src/gobj/textureContext.I index fa947755d0..2c58bc7b07 100644 --- a/panda/src/gobj/textureContext.I +++ b/panda/src/gobj/textureContext.I @@ -16,9 +16,8 @@ */ INLINE TextureContext:: TextureContext(PreparedGraphicsObjects *pgo, Texture *tex, int view) : - BufferContext(&pgo->_texture_residency), + BufferContext(&pgo->_texture_residency, tex), AdaptiveLruPage(0), - _texture(tex), _view(view) { } @@ -28,7 +27,7 @@ TextureContext(PreparedGraphicsObjects *pgo, Texture *tex, int view) : */ INLINE Texture *TextureContext:: get_texture() const { - return _texture; + return (Texture *)_object; } /** @@ -56,7 +55,7 @@ was_modified() const { */ INLINE bool TextureContext:: was_properties_modified() const { - return _properties_modified != _texture->get_properties_modified(); + return _properties_modified != get_texture()->get_properties_modified(); } /** @@ -65,7 +64,7 @@ was_properties_modified() const { */ INLINE bool TextureContext:: was_image_modified() const { - return _image_modified != _texture->get_image_modified(); + return _image_modified != get_texture()->get_image_modified(); } /** @@ -74,7 +73,7 @@ was_image_modified() const { */ INLINE bool TextureContext:: was_simple_image_modified() const { - return _simple_image_modified != _texture->get_simple_image_modified(); + return _simple_image_modified != get_texture()->get_simple_image_modified(); } /** @@ -121,8 +120,8 @@ update_data_size_bytes(size_t new_data_size_bytes) { INLINE void TextureContext:: mark_loaded() { // _data_size_bytes = _data->get_texture_size_bytes(); - _properties_modified = _texture->get_properties_modified(); - _image_modified = _texture->get_image_modified(); + _properties_modified = get_texture()->get_properties_modified(); + _image_modified = get_texture()->get_image_modified(); update_modified(std::max(_properties_modified, _image_modified)); // Assume the texture is now resident. @@ -135,8 +134,8 @@ mark_loaded() { */ INLINE void TextureContext:: mark_simple_loaded() { - _properties_modified = _texture->get_properties_modified(); - _simple_image_modified = _texture->get_simple_image_modified(); + _properties_modified = get_texture()->get_properties_modified(); + _simple_image_modified = get_texture()->get_simple_image_modified(); update_modified(std::max(_properties_modified, _simple_image_modified)); // The texture's not exactly resident now, but some part of it is. diff --git a/panda/src/gobj/textureContext.h b/panda/src/gobj/textureContext.h index c7ae367ccc..2962fd38c0 100644 --- a/panda/src/gobj/textureContext.h +++ b/panda/src/gobj/textureContext.h @@ -60,9 +60,6 @@ public: virtual void write(std::ostream &out, int indent_level) const; private: - // This cannot be a PT(Texture), because the texture and the GSG both own - // their TextureContexts! That would create a circular reference count. - Texture *_texture; int _view; UpdateSeq _properties_modified; UpdateSeq _image_modified; diff --git a/panda/src/gobj/vertexBufferContext.I b/panda/src/gobj/vertexBufferContext.I index b57739cf09..bbfff0bb27 100644 --- a/panda/src/gobj/vertexBufferContext.I +++ b/panda/src/gobj/vertexBufferContext.I @@ -16,9 +16,8 @@ */ INLINE VertexBufferContext:: VertexBufferContext(PreparedGraphicsObjects *pgo, GeomVertexArrayData *data) : - BufferContext(&pgo->_vbuffer_residency), - AdaptiveLruPage(0), - _data(data) + BufferContext(&pgo->_vbuffer_residency, data), + AdaptiveLruPage(0) { } @@ -27,7 +26,7 @@ VertexBufferContext(PreparedGraphicsObjects *pgo, GeomVertexArrayData *data) : */ INLINE GeomVertexArrayData *VertexBufferContext:: get_data() const { - return _data; + return (GeomVertexArrayData *)_object; } /** @@ -36,7 +35,7 @@ get_data() const { */ INLINE bool VertexBufferContext:: changed_size(const GeomVertexArrayDataHandle *reader) const { - nassertr(reader->get_object() == _data, false); + nassertr(reader->get_object() == get_data(), false); return get_data_size_bytes() != (size_t)reader->get_data_size_bytes(); } @@ -46,7 +45,7 @@ changed_size(const GeomVertexArrayDataHandle *reader) const { */ INLINE bool VertexBufferContext:: changed_usage_hint(const GeomVertexArrayDataHandle *reader) const { - nassertr(reader->get_object() == _data, false); + nassertr(reader->get_object() == get_data(), false); return _usage_hint != reader->get_usage_hint(); } @@ -56,7 +55,7 @@ changed_usage_hint(const GeomVertexArrayDataHandle *reader) const { */ INLINE bool VertexBufferContext:: was_modified(const GeomVertexArrayDataHandle *reader) const { - nassertr(reader->get_object() == _data, false); + nassertr(reader->get_object() == get_data(), false); return get_modified() != reader->get_modified(); } @@ -77,7 +76,7 @@ update_data_size_bytes(size_t new_data_size_bytes) { */ INLINE void VertexBufferContext:: mark_loaded(const GeomVertexArrayDataHandle *reader) { - nassertv(reader->get_object() == _data); + nassertv(reader->get_object() == get_data()); update_data_size_bytes(reader->get_data_size_bytes()); update_modified(reader->get_modified()); _usage_hint = reader->get_usage_hint(); diff --git a/panda/src/gobj/vertexBufferContext.h b/panda/src/gobj/vertexBufferContext.h index 69f02e0ed7..c1696ba6cb 100644 --- a/panda/src/gobj/vertexBufferContext.h +++ b/panda/src/gobj/vertexBufferContext.h @@ -51,10 +51,6 @@ public: virtual void write(std::ostream &out, int indent_level) const; private: - // This cannot be a PT(GeomVertexArrayData), because the data and the GSG - // both own their VertexBufferContexts! That would create a circular - // reference count. - GeomVertexArrayData *_data; GeomEnums::UsageHint _usage_hint; public: From 981c44f636113d798993f7e8b86f32a291bc62c8 Mon Sep 17 00:00:00 2001 From: rdb Date: Wed, 26 Dec 2018 23:31:48 +0100 Subject: [PATCH 33/33] glgsg: fix misleading errors from p3d_LightSource[].shadowMap --- panda/src/glstuff/glShaderContext_src.cxx | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/panda/src/glstuff/glShaderContext_src.cxx b/panda/src/glstuff/glShaderContext_src.cxx index bf6c6097fa..ae7a845efc 100644 --- a/panda/src/glstuff/glShaderContext_src.cxx +++ b/panda/src/glstuff/glShaderContext_src.cxx @@ -2797,14 +2797,24 @@ update_shader_texture_bindings(ShaderContext *prev) { } if (tex->get_texture_type() != spec._desired_type) { - if (id != nullptr) { + switch (spec._part) { + case Shader::STO_named_input: GLCAT.error() << "Sampler type of GLSL shader input '" << *id << "' does not " "match type of texture " << *tex << ".\n"; - } else { + break; + + case Shader::STO_stage_i: GLCAT.error() << "Sampler type of GLSL shader input p3d_Texture" << spec._stage << " does not match type of texture " << *tex << ".\n"; + break; + + case Shader::STO_light_i_shadow_map: + GLCAT.error() + << "Sampler type of GLSL shader input p3d_LightSource[" << spec._stage + << "].shadowMap does not match type of texture " << *tex << ".\n"; + break; } // TODO: also check whether shadow sampler textures have shadow filter // enabled.