diff --git a/src/db/db/dbCommonReader.cc b/src/db/db/dbCommonReader.cc index b1becdcfb..e52b94c69 100644 --- a/src/db/db/dbCommonReader.cc +++ b/src/db/db/dbCommonReader.cc @@ -240,7 +240,7 @@ CommonReaderBase::cell_for_instance (db::Layout &layout, const std::string &cn) } void -CommonReaderBase::merge_cell (db::Layout &layout, db::cell_index_type target_cell_index, db::cell_index_type src_cell_index, bool with_meta, bool no_duplicate_instances) const +CommonReaderBase::merge_cell (db::Layout &layout, db::cell_index_type target_cell_index, db::cell_index_type src_cell_index, bool with_meta, bool no_duplicate_instances) { const db::Cell &src_cell = layout.cell (src_cell_index); db::Cell &target_cell = layout.cell (target_cell_index); @@ -284,7 +284,7 @@ CommonReaderBase::merge_cell (db::Layout &layout, db::cell_index_type target_cel } void -CommonReaderBase::merge_cell_without_instances (db::Layout &layout, db::cell_index_type target_cell_index, db::cell_index_type src_cell_index, bool with_meta) const +CommonReaderBase::merge_cell_without_instances (db::Layout &layout, db::cell_index_type target_cell_index, db::cell_index_type src_cell_index, bool with_meta) { const db::Cell &src_cell = layout.cell (src_cell_index); db::Cell &target_cell = layout.cell (target_cell_index); @@ -297,20 +297,21 @@ CommonReaderBase::merge_cell_without_instances (db::Layout &layout, db::cell_ind } // replace all instances of the new cell with the original one - layout.replace_instances_of (src_cell.cell_index (), target_cell.cell_index ()); + layout.replace_instances_of (src_cell_index, target_cell_index); // merge meta info if (with_meta) { - auto ib = layout.begin_meta (src_cell.cell_index ()); - auto ie = layout.end_meta (src_cell.cell_index ()); + auto ib = layout.begin_meta (src_cell_index); + auto ie = layout.end_meta (src_cell_index); for (auto i = ib; i != ie; ++i) { - layout.add_meta_info (target_cell.cell_index (), i->first, i->second); + layout.add_meta_info (target_cell_index, i->first, i->second); } } - layout.clear_meta (src_cell.cell_index ()); + layout.clear_meta (src_cell_index); // finally delete the new cell - layout.delete_cell (src_cell.cell_index ()); + m_temp_cells.erase (src_cell_index); + layout.delete_cell (src_cell_index); } void diff --git a/src/db/db/dbCommonReader.h b/src/db/db/dbCommonReader.h index 1a7dafcdf..065c5eb6c 100644 --- a/src/db/db/dbCommonReader.h +++ b/src/db/db/dbCommonReader.h @@ -242,12 +242,12 @@ protected: /** * @brief Merge (and delete) the src_cell into target_cell */ - void merge_cell (db::Layout &layout, db::cell_index_type target_cell_index, db::cell_index_type src_cell_index, bool with_meta, bool no_duplicate_instances) const; + void merge_cell (db::Layout &layout, db::cell_index_type target_cell_index, db::cell_index_type src_cell_index, bool with_meta, bool no_duplicate_instances); /** * @brief Merge (and delete) the src_cell into target_cell without instances */ - void merge_cell_without_instances (db::Layout &layout, db::cell_index_type target_cell_index, db::cell_index_type src_cell_index, bool with_meta) const; + void merge_cell_without_instances (db::Layout &layout, db::cell_index_type target_cell_index, db::cell_index_type src_cell_index, bool with_meta); /** * @brief Gets the layer name map diff --git a/src/db/db/dbTextWriter.cc b/src/db/db/dbTextWriter.cc index 87148793a..8ac82ad39 100644 --- a/src/db/db/dbTextWriter.cc +++ b/src/db/db/dbTextWriter.cc @@ -149,7 +149,7 @@ TextWriter::write_props (const db::Layout & /*layout*/, size_t prop_id) const tl::Variant &name = p->first; const tl::Variant &value = p->second; - if (name.is_long () || name.is_ulong ()) { + if (name.can_convert_to_long ()) { *this << " {" << int (name.to_long ()) << " {" << value.to_string () << "}}" << endl_str (); } else if (name.is_a_string ()) { *this << " {{" << name.to_string () << "} {" << value.to_string () << "}}" << endl_str (); diff --git a/src/plugins/streamers/oasis/db_plugin/dbOASISReader.cc b/src/plugins/streamers/oasis/db_plugin/dbOASISReader.cc index 74fc56034..91c5d000e 100644 --- a/src/plugins/streamers/oasis/db_plugin/dbOASISReader.cc +++ b/src/plugins/streamers/oasis/db_plugin/dbOASISReader.cc @@ -110,22 +110,22 @@ OASISReader::init (const db::LoadLayoutOptions &options) m_expect_strict_mode = oasis_options.expect_strict_mode; } -inline long long -OASISReader::get_long_long () +inline int64_t +OASISReader::get_int64 () { - unsigned long long u = get_ulong_long (); + uint64_t u = get_uint64 (); if ((u & 1) != 0) { - return -(long long) (u >> 1); + return -(int64_t) (u >> 1); } else { - return (long long) (u >> 1); + return (int64_t) (u >> 1); } } -inline unsigned long long -OASISReader::get_ulong_long () +inline uint64_t +OASISReader::get_uint64 () { - unsigned long long v = 0; - unsigned long long vm = 1; + uint64_t v = 0; + uint64_t vm = 1; char c; do { @@ -135,79 +135,43 @@ OASISReader::get_ulong_long () return 0; } c = *b; - if (vm > std::numeric_limits ::max () / 128 && - (unsigned long long) (c & 0x7f) > (std::numeric_limits ::max () / vm)) { - error (tl::to_string (tr ("Unsigned long value overflow"))); + if (vm > std::numeric_limits ::max () / 128 && + (uint64_t) (c & 0x7f) > (std::numeric_limits ::max () / vm)) { + error (tl::to_string (tr ("uint64 value overflow"))); } - v += (unsigned long long) (c & 0x7f) * vm; + v += (uint64_t) (c & 0x7f) * vm; vm <<= 7; } while ((c & 0x80) != 0); return v; } -inline long -OASISReader::get_long () +inline uint64_t +OASISReader::get_uint64_for_divider () { - unsigned long u = get_ulong (); - if ((u & 1) != 0) { - return -long (u >> 1); - } else { - return long (u >> 1); - } -} - -inline unsigned long -OASISReader::get_ulong_for_divider () -{ - unsigned long l = get_ulong (); + uint64_t l = get_uint64 (); if (l == 0) { error (tl::to_string (tr ("Divider must not be zero"))); } return l; } -inline unsigned long -OASISReader::get_ulong () +inline int32_t +OASISReader::get_int32 () { - unsigned long v = 0; - unsigned long vm = 1; - char c; - - do { - unsigned char *b = (unsigned char *) m_stream.get (1); - if (! b) { - error (tl::to_string (tr ("Unexpected end-of-file"))); - return 0; - } - c = *b; - if (vm > std::numeric_limits ::max () / 128 && - (unsigned long) (c & 0x7f) > (std::numeric_limits ::max () / vm)) { - error (tl::to_string (tr ("Unsigned long value overflow"))); - } - v += (unsigned long) (c & 0x7f) * vm; - vm <<= 7; - } while ((c & 0x80) != 0); - - return v; -} - -inline int -OASISReader::get_int () -{ - unsigned int u = get_uint (); + uint32_t u = get_uint32 (); if ((u & 1) != 0) { - return -int (u >> 1); + return -int32_t (u >> 1); } else { - return int (u >> 1); + return int32_t (u >> 1); } } -inline unsigned int -OASISReader::get_uint () +inline uint32_t +OASISReader::get_uint32 () { - unsigned int v = 0; - unsigned int vm = 1; + uint32_t v = 0; + uint32_t vm = 1; char c; do { @@ -217,11 +181,11 @@ OASISReader::get_uint () return 0; } c = *b; - if (vm > std::numeric_limits ::max () / 128 && - (unsigned int) (c & 0x7f) > (std::numeric_limits ::max () / vm)) { - error (tl::to_string (tr ("Unsigned integer value overflow"))); + if (vm > std::numeric_limits ::max () / 128 && + (uint32_t) (c & 0x7f) > (std::numeric_limits ::max () / vm)) { + error (tl::to_string (tr ("uin32 value overflow"))); } - v += (unsigned int) (c & 0x7f) * vm; + v += (uint32_t) (c & 0x7f) * vm; vm <<= 7; } while ((c & 0x80) != 0); @@ -240,7 +204,7 @@ void OASISReader::get_str (std::string &s) { size_t l = 0; - get (l); + get_size (l); char *b = (char *) m_stream.get (l); if (b) { @@ -253,33 +217,33 @@ OASISReader::get_str (std::string &s) double OASISReader::get_real () { - unsigned int t = get_uint (); + unsigned int t = get_uint32 (); if (t == 0) { - return double (get_ulong ()); + return double (get_uint64 ()); } else if (t == 1) { - return -double (get_ulong ()); + return -double (get_uint64 ()); } else if (t == 2) { - return 1.0 / double (get_ulong_for_divider ()); + return 1.0 / double (get_uint64_for_divider ()); } else if (t == 3) { - return -1.0 / double (get_ulong_for_divider ()); + return -1.0 / double (get_uint64_for_divider ()); } else if (t == 4) { - double d = double (get_ulong ()); - return d / double (get_ulong_for_divider ()); + double d = double (get_uint64 ()); + return d / double (get_uint64_for_divider ()); } else if (t == 5) { - double d = double (get_ulong ()); - return -d / double (get_ulong_for_divider ()); + double d = double (get_uint64 ()); + return -d / double (get_uint64_for_divider ()); } else if (t == 6) { @@ -326,51 +290,51 @@ OASISReader::get_real () } db::Coord -OASISReader::get_ucoord (unsigned long grid) +OASISReader::get_ucoord (uint64_t grid) { - unsigned long long lx = 0; + uint64_t lx = 0; get (lx); lx *= grid; - if (lx > (unsigned long long) (std::numeric_limits ::max ())) { + if (lx > (uint64_t) (std::numeric_limits ::max ())) { error (tl::to_string (tr ("Coordinate value overflow"))); } return db::Coord (lx); } OASISReader::distance_type -OASISReader::get_ucoord_as_distance (unsigned long grid) +OASISReader::get_ucoord_as_distance (uint64_t grid) { - unsigned long long lx = 0; + uint64_t lx = 0; get (lx); lx *= grid; - if (lx > (unsigned long long) (std::numeric_limits ::max ())) { + if (lx > (uint64_t) (std::numeric_limits ::max ())) { error (tl::to_string (tr ("Coordinate value overflow"))); } return distance_type (lx); } db::Coord -OASISReader::get_coord (long grid) +OASISReader::get_coord (int64_t grid) { - long long lx = 0; + int64_t lx = 0; get (lx); lx *= grid; - if (lx < (long long) (std::numeric_limits ::min ()) || - lx > (long long) (std::numeric_limits ::max ())) { + if (lx < (int64_t) (std::numeric_limits ::min ()) || + lx > (int64_t) (std::numeric_limits ::max ())) { error (tl::to_string (tr ("Coordinate value overflow"))); } return db::Coord (lx); } db::Vector -OASISReader::get_2delta (long grid) +OASISReader::get_2delta (int64_t grid) { - unsigned long long l1 = 0; + uint64_t l1 = 0; get (l1); - long long lx = l1 >> 2; + int64_t lx = l1 >> 2; lx *= grid; - if (lx > (long long) (std::numeric_limits ::max ())) { + if (lx > (int64_t) (std::numeric_limits ::max ())) { error (tl::to_string (tr ("Coordinate value overflow"))); } db::Coord x = lx; @@ -389,14 +353,14 @@ OASISReader::get_2delta (long grid) } db::Vector -OASISReader::get_3delta (long grid) +OASISReader::get_3delta (int64_t grid) { - unsigned long long l1 = 0; + uint64_t l1 = 0; get (l1); - long long lx = l1 >> 3; + int64_t lx = l1 >> 3; lx *= grid; - if (lx > (long long) (std::numeric_limits ::max ())) { + if (lx > (int64_t) (std::numeric_limits ::max ())) { error (tl::to_string (tr ("Coordinate value overflow"))); } db::Coord x = lx; @@ -423,25 +387,25 @@ OASISReader::get_3delta (long grid) } db::Vector -OASISReader::get_gdelta (long grid) +OASISReader::get_gdelta (int64_t grid) { - unsigned long long l1 = 0; + uint64_t l1 = 0; get (l1); if ((l1 & 1) != 0) { - long long lx = ((l1 & 2) == 0 ? (long long) (l1 >> 2) : -(long long) (l1 >> 2)); + int64_t lx = ((l1 & 2) == 0 ? (int64_t) (l1 >> 2) : -(int64_t) (l1 >> 2)); lx *= grid; - if (lx < (long long) (std::numeric_limits ::min ()) || - lx > (long long) (std::numeric_limits ::max ())) { + if (lx < (int64_t) (std::numeric_limits ::min ()) || + lx > (int64_t) (std::numeric_limits ::max ())) { error (tl::to_string (tr ("Coordinate value overflow"))); } - long long ly; + int64_t ly; get (ly); ly *= grid; - if (ly < (long long) (std::numeric_limits ::min ()) || - ly > (long long) (std::numeric_limits ::max ())) { + if (ly < (int64_t) (std::numeric_limits ::min ()) || + ly > (int64_t) (std::numeric_limits ::max ())) { error (tl::to_string (tr ("Coordinate value overflow"))); } @@ -449,9 +413,9 @@ OASISReader::get_gdelta (long grid) } else { - long long lx = l1 >> 4; + int64_t lx = l1 >> 4; lx *= grid; - if (lx > (long long) (std::numeric_limits ::max ())) { + if (lx > (int64_t) (std::numeric_limits ::max ())) { error (tl::to_string (tr ("Coordinate value overflow"))); } db::Coord x = lx; @@ -568,42 +532,42 @@ OASISReader::mark_start_table () void OASISReader::read_offset_table () { - unsigned int of = 0; + uint64_t of = 0; - of = get_uint (); - get (m_table_cellname); + of = get_uint64 (); + get_size (m_table_cellname); if (m_table_cellname != 0 && m_expect_strict_mode >= 0 && ((of == 0) != (m_expect_strict_mode == 0))) { warn (tl::to_string (tr ("CELLNAME offset table has unexpected strict mode"))); } - of = get_uint (); - get (m_table_textstring); + of = get_uint64 (); + get_size (m_table_textstring); if (m_table_textstring != 0 && m_expect_strict_mode >= 0 && ((of == 0) != (m_expect_strict_mode == 0))) { warn (tl::to_string (tr ("TEXTSTRING offset table has unexpected strict mode"))); } - of = get_uint (); - get (m_table_propname); + of = get_uint64 (); + get_size (m_table_propname); if (m_table_propname != 0 && m_expect_strict_mode >= 0 && ((of == 0) != (m_expect_strict_mode == 0))) { warn (tl::to_string (tr ("PROPNAME offset table has unexpected strict mode"))); } - of = get_uint (); - get (m_table_propstring); + of = get_uint64 (); + get_size (m_table_propstring); if (m_table_propstring != 0 && m_expect_strict_mode >= 0 && ((of == 0) != (m_expect_strict_mode == 0))) { warn (tl::to_string (tr ("PROPSTRING offset table has unexpected strict mode"))); } - of = get_uint (); - get (m_table_layername); + of = get_uint64 (); + get_size (m_table_layername); if (m_table_layername != 0 && m_expect_strict_mode >= 0 && ((of == 0) != (m_expect_strict_mode == 0))) { warn (tl::to_string (tr ("LAYERNAME offset table has unexpected strict mode"))); } // XNAME table ignored currently - get_uint (); + get_uint64 (); size_t dummy = 0; - get (dummy); + get_size (dummy); } static const char magic_bytes[] = { "%SEMI-OASIS\015\012" }; @@ -662,7 +626,7 @@ OASISReader::do_read (db::Layout &layout) layout.dbu (1.0 / res); // read over table offsets if required - bool table_offsets_at_end = get_uint (); + bool table_offsets_at_end = get_uint64 () != 0; if (! table_offsets_at_end) { read_offset_table (); } @@ -681,10 +645,10 @@ OASISReader::do_read (db::Layout &layout) m_table_layername = 0; // define the name id counters - unsigned long cellname_id = 0; - unsigned long textstring_id = 0; - unsigned long propstring_id = 0; - unsigned long propname_id = 0; + uint64_t cellname_id = 0; + uint64_t textstring_id = 0; + uint64_t propstring_id = 0; + uint64_t propname_id = 0; // id mode (explicit or implicit) enum id_mode { any, expl, impl }; @@ -744,7 +708,7 @@ OASISReader::do_read (db::Layout &layout) std::string name = get_str (); // and the associated id - unsigned long id = cellname_id; + uint64_t id = cellname_id; if (r == 3) { if (cellname_id_mode == expl) { error (tl::to_string (tr ("Explicit and implicit CELLNAME modes cannot be mixed"))); @@ -782,7 +746,7 @@ OASISReader::do_read (db::Layout &layout) std::string name = get_str (); // and the associated id - unsigned long id = textstring_id; + uint64_t id = textstring_id; if (r == 5) { if (textstring_id_mode == expl) { error (tl::to_string (tr ("Explicit and implicit TEXTSTRING modes cannot be mixed"))); @@ -819,7 +783,7 @@ OASISReader::do_read (db::Layout &layout) std::string name = get_str (); // and the associated id - unsigned long id = propname_id; + uint64_t id = propname_id; if (r == 7) { if (propname_id_mode == expl) { error (tl::to_string (tr ("Explicit and implicit PROPNAME modes cannot be mixed"))); @@ -861,7 +825,7 @@ OASISReader::do_read (db::Layout &layout) std::string name = get_str (); // and the associated id - unsigned long id = propstring_id; + uint64_t id = propstring_id; if (r == 9) { if (propstring_id_mode == expl) { error (tl::to_string (tr ("Explicit and implicit PROPSTRING modes cannot be mixed"))); @@ -880,7 +844,7 @@ OASISReader::do_read (db::Layout &layout) error (tl::sprintf (tl::to_string (tr ("A PROPSTRING with id %ld is present already")), id)); } - std::map::iterator fw = m_propvalue_forward_references.find (id); + std::map::iterator fw = m_propvalue_forward_references.find (id); if (fw != m_propvalue_forward_references.end ()) { fw->second = name; } @@ -904,38 +868,38 @@ OASISReader::do_read (db::Layout &layout) db::ld_type dt1 = 0, dt2 = std::numeric_limits::max () - 1; db::ld_type l1 = 0, l2 = std::numeric_limits::max () - 1; - unsigned int it; + uint32_t it; - it = get_uint (); + it = get_uint32 (); if (it == 0) { // keep limits } else if (it == 1) { - l2 = get_uint (); + l2 = get_uint32 (); } else if (it == 2) { - l1 = get_uint (); + l1 = get_uint32 (); } else if (it == 3) { - l1 = get_uint (); + l1 = get_uint32 (); l2 = l1; } else if (it == 4) { - l1 = get_uint (); - l2 = get_uint (); + l1 = get_uint32 (); + l2 = get_uint32 (); } else { error (tl::to_string (tr ("Invalid LAYERNAME interval mode (layer)"))); } - it = get_uint (); + it = get_uint32 (); if (it == 0) { // keep limits } else if (it == 1) { - dt2 = get_uint (); + dt2 = get_uint32 (); } else if (it == 2) { - dt1 = get_uint (); + dt1 = get_uint32 (); } else if (it == 3) { - dt1 = get_uint (); + dt1 = get_uint32 (); dt2 = dt1; } else if (it == 4) { - dt1 = get_uint (); - dt2 = get_uint (); + dt1 = get_uint32 (); + dt2 = get_uint32 (); } else { error (tl::to_string (tr ("Invalid LAYERNAME interval mode (datatype)"))); } @@ -973,10 +937,10 @@ OASISReader::do_read (db::Layout &layout) } else if (r == 30 || r == 31 /*XNAME*/) { // read a XNAME: it is simply ignored - get_ulong (); + get_uint64 (); get_str (); if (r == 31) { - get_ulong (); + get_uint64 (); } reset_modal_variables (); @@ -993,7 +957,7 @@ OASISReader::do_read (db::Layout &layout) // read a cell if (r == 13) { - unsigned long id = 0; + uint64_t id = 0; get (id); std::pair cc = cell_by_id (id); @@ -1034,12 +998,12 @@ OASISReader::do_read (db::Layout &layout) } else if (r == 34 /*CBLOCK*/) { - unsigned int type = get_uint (); + uint32_t type = get_uint32 (); if (type != 0) { error (tl::sprintf (tl::to_string (tr ("Invalid CBLOCK compression type %d")), type)); } - size_t dummy = 0; + uint64_t dummy = 0; get (dummy); // uncomp-byte-count - not needed get (dummy); // comp-byte-count - not needed @@ -1070,7 +1034,7 @@ OASISReader::do_read (db::Layout &layout) error (tl::to_string (tr ("Format error (too many bytes after END record)"))); } - for (std::map ::const_iterator fw = m_text_forward_references.begin (); fw != m_text_forward_references.end (); ++fw) { + for (std::map ::const_iterator fw = m_text_forward_references.begin (); fw != m_text_forward_references.end (); ++fw) { auto ts = m_textstrings.find (fw->first); if (ts == m_textstrings.end ()) { error (tl::sprintf (tl::to_string (tr ("No text string defined for text string id %ld")), fw->first)); @@ -1080,7 +1044,7 @@ OASISReader::do_read (db::Layout &layout) } // all forward references to property names must be resolved - for (std::map ::const_iterator fw = m_propname_forward_references.begin (); fw != m_propname_forward_references.end (); ++fw) { + for (std::map ::const_iterator fw = m_propname_forward_references.begin (); fw != m_propname_forward_references.end (); ++fw) { if (fw->second == 0) { error (tl::sprintf (tl::to_string (tr ("No property name defined for property name id %ld")), fw->first)); } @@ -1181,7 +1145,7 @@ OASISReader::do_read (db::Layout &layout) } // attach the properties found in CELLNAME to the cells (which may have other properties) - for (std::map::const_iterator p = m_cellname_properties.begin (); p != m_cellname_properties.end (); ++p) { + for (std::map::const_iterator p = m_cellname_properties.begin (); p != m_cellname_properties.end (); ++p) { // The cellname properties ID may be a forward properties ID, resolve it first @@ -1356,7 +1320,7 @@ OASISReader::resolve_forward_references (db::PropertiesSet &properties) const tl::Variant &name = db::property_name (p->first); if (name.is_id ()) { - std::map ::iterator pf = m_propname_forward_references.find (name.to_id ()); + std::map ::iterator pf = m_propname_forward_references.find (name.to_id ()); if (pf != m_propname_forward_references.end ()) { if (pf->second == m_s_gds_property_name_id) { @@ -1388,8 +1352,8 @@ OASISReader::replace_forward_references_in_variant (tl::Variant &v) { if (v.is_id ()) { - unsigned long id = (unsigned long) v.to_id (); - std::map ::const_iterator fw = m_propvalue_forward_references.find (id); + uint64_t id = (uint64_t) v.to_id (); + std::map ::const_iterator fw = m_propvalue_forward_references.find (id); if (fw != m_propvalue_forward_references.end ()) { v = tl::Variant (fw->second); } else { @@ -1412,8 +1376,8 @@ OASISReader::replace_forward_references_in_variant (tl::Variant &v) std::vector new_list (l); for (std::vector::iterator ll = new_list.begin (); ll != new_list.end (); ++ll) { if (ll->is_id ()) { - unsigned long id = (unsigned long) ll->to_id (); - std::map ::const_iterator fw = m_propvalue_forward_references.find (id); + uint64_t id = (uint64_t) ll->to_id (); + std::map ::const_iterator fw = m_propvalue_forward_references.find (id); if (fw != m_propvalue_forward_references.end ()) { *ll = tl::Variant (fw->second); } else { @@ -1483,12 +1447,12 @@ OASISReader::read_element_properties (bool ignore_special) } else if (m == 34 /*CBLOCK*/) { - unsigned int type = get_uint (); + uint32_t type = get_uint32 (); if (type != 0) { error (tl::sprintf (tl::to_string (tr ("Invalid CBLOCK compression type %d")), type)); } - size_t dummy = 0; + uint64_t dummy = 0; get (dummy); // uncomp-byte-count - not needed get (dummy); // comp-byte-count - not needed @@ -1539,10 +1503,10 @@ OASISReader::read_properties () if (m & 0x04) { if (m & 0x02) { - unsigned long id; + uint64_t id; get (id); - std::map ::const_iterator cid = m_propnames.find (id); + std::map ::const_iterator cid = m_propnames.find (id); if (cid == m_propnames.end ()) { mm_last_property_name = db::property_names_id (tl::Variant (id, true /*dummy for id type*/)); m_propname_forward_references.insert (std::make_pair (id, db::property_names_id_type (0))); @@ -1563,7 +1527,7 @@ OASISReader::read_properties () if (! (m & 0x08)) { - unsigned long n = ((unsigned long) (m >> 4)) & 0x0f; + uint64_t n = ((uint64_t) (m >> 4)) & 0x0f; if (n == 15) { get (n); } @@ -1584,15 +1548,15 @@ OASISReader::read_properties () } else if (t == 8) { - unsigned long l; + uint64_t l; get (l); if (m_read_properties) { - mm_last_value_list.get_non_const ().push_back (tl::Variant (long (l))); + mm_last_value_list.get_non_const ().push_back (tl::Variant (int64_t (l))); } } else if (t == 9) { - long l; + int64_t l; get (l); if (m_read_properties) { mm_last_value_list.get_non_const ().push_back (tl::Variant (l)); @@ -1612,10 +1576,10 @@ OASISReader::read_properties () } else if (t == 13 || t == 14 || t == 15) { - unsigned long id; + uint64_t id; get (id); if (m_read_properties) { - std::map ::const_iterator sid = m_propstrings.find (id); + std::map ::const_iterator sid = m_propstrings.find (id); if (sid == m_propstrings.end ()) { m_propvalue_forward_references.insert (std::make_pair (id, std::string ())); mm_last_value_list.get_non_const ().push_back (tl::Variant (id, true /*dummy for id type*/)); @@ -1642,9 +1606,9 @@ OASISReader::read_properties () void OASISReader::read_pointlist (modal_variable > &pointlist, bool for_polygon) { - unsigned int type = get_uint (); + uint32_t type = get_uint32 (); - unsigned long n = 0; + uint64_t n = 0; get (n); if (n == 0) { error (tl::to_string (tr ("Invalid point list: length is zero")).c_str ()); @@ -1665,7 +1629,7 @@ OASISReader::read_pointlist (modal_variable > &pointlis bool h = (type == 0); db::Point pos; - for (unsigned long i = 0; i < n; ++i) { + for (uint64_t i = 0; i < n; ++i) { db::Coord d = get_coord (); if (h) { pos += db::Vector (d, 0); @@ -1691,7 +1655,7 @@ OASISReader::read_pointlist (modal_variable > &pointlis } else if (type == 2) { db::Point pos; - for (unsigned long i = 0; i < n; ++i) { + for (uint64_t i = 0; i < n; ++i) { pos += get_2delta (); pointlist.get_non_const ().push_back (pos); } @@ -1699,7 +1663,7 @@ OASISReader::read_pointlist (modal_variable > &pointlis } else if (type == 3) { db::Point pos; - for (unsigned long i = 0; i < n; ++i) { + for (uint64_t i = 0; i < n; ++i) { pos += get_3delta (); pointlist.get_non_const ().push_back (pos); } @@ -1707,7 +1671,7 @@ OASISReader::read_pointlist (modal_variable > &pointlis } else if (type == 4) { db::Point pos; - for (unsigned long i = 0; i < n; ++i) { + for (uint64_t i = 0; i < n; ++i) { pos += get_gdelta (); pointlist.get_non_const ().push_back (pos); } @@ -1716,7 +1680,7 @@ OASISReader::read_pointlist (modal_variable > &pointlis db::Point pos; db::Vector delta; - for (unsigned long i = 0; i < n; ++i) { + for (uint64_t i = 0; i < n; ++i) { delta += get_gdelta (); pos += delta; pointlist.get_non_const ().push_back (pos); @@ -1732,14 +1696,14 @@ OASISReader::read_pointlist (modal_variable > &pointlis bool OASISReader::read_repetition () { - unsigned int type = get_uint (); + uint32_t type = get_uint32 (); if (type == 0) { // reuse modal variable } else if (type == 1) { - unsigned long nx = 0, ny = 0; + uint64_t nx = 0, ny = 0; get (nx); get (ny); @@ -1750,7 +1714,7 @@ OASISReader::read_repetition () } else if (type == 2) { - unsigned long nx = 0; + uint64_t nx = 0; get (nx); db::Coord dx = get_ucoord (); @@ -1759,7 +1723,7 @@ OASISReader::read_repetition () } else if (type == 3) { - unsigned long ny = 0; + uint64_t ny = 0; get (ny); db::Coord dy = get_ucoord (); @@ -1771,10 +1735,10 @@ OASISReader::read_repetition () IrregularRepetition *rep = new IrregularRepetition (); mm_repetition = rep; - unsigned long n = 0; + uint64_t n = 0; get (n); - unsigned long lgrid = 1; + uint64_t lgrid = 1; if (type == 5) { get (lgrid); } @@ -1782,7 +1746,7 @@ OASISReader::read_repetition () rep->reserve (n + 1); db::Coord x = 0; - for (unsigned long i = 0; i <= n; ++i) { + for (uint64_t i = 0; i <= n; ++i) { m_progress.set (m_stream.pos ()); db::Coord d = get_ucoord (lgrid); if (d != 0) { @@ -1796,10 +1760,10 @@ OASISReader::read_repetition () IrregularRepetition *rep = new IrregularRepetition (); mm_repetition = rep; - unsigned long n = 0; + uint64_t n = 0; get (n); - unsigned long lgrid = 1; + uint64_t lgrid = 1; if (type == 7) { get (lgrid); } @@ -1807,7 +1771,7 @@ OASISReader::read_repetition () rep->reserve (n + 1); db::Coord y = 0; - for (unsigned long i = 0; i <= n; ++i) { + for (uint64_t i = 0; i <= n; ++i) { m_progress.set (m_stream.pos ()); db::Coord d = get_ucoord (lgrid); if (d != 0) { @@ -1818,7 +1782,7 @@ OASISReader::read_repetition () } else if (type == 8) { - unsigned long n = 0, m = 0; + uint64_t n = 0, m = 0; get (n); get (m); @@ -1829,7 +1793,7 @@ OASISReader::read_repetition () } else if (type == 9) { - unsigned long n = 0; + uint64_t n = 0; get (n); db::Vector dn = get_gdelta (); @@ -1840,10 +1804,10 @@ OASISReader::read_repetition () IrregularRepetition *rep = new IrregularRepetition (); mm_repetition = rep; - unsigned long n = 0; + uint64_t n = 0; get (n); - unsigned long grid = 1; + uint64_t grid = 1; if (type == 11) { get (grid); } @@ -1851,7 +1815,7 @@ OASISReader::read_repetition () rep->reserve (n + 1); db::Vector p; - for (unsigned long i = 0; i <= n; ++i) { + for (uint64_t i = 0; i <= n; ++i) { m_progress.set (m_stream.pos ()); db::Vector d = get_gdelta (grid); if (d != db::Vector ()) { @@ -1882,7 +1846,7 @@ OASISReader::do_read_placement (unsigned char r, if (m & 0x40) { // cell by id - unsigned long id; + uint64_t id; get (id); mm_placement_cell = cell_for_instance (layout, id); @@ -1974,10 +1938,10 @@ OASISReader::do_read_placement (unsigned char r, if (mag_set || angle < 0) { inst = db::CellInstArray (db::CellInst (mm_placement_cell.get ()), - db::ICplxTrans (mag, angle_deg, mirror, pos), layout.array_repository (), a, b, (unsigned long) na, (unsigned long) nb); + db::ICplxTrans (mag, angle_deg, mirror, pos), layout.array_repository (), a, b, (uint64_t) na, (uint64_t) nb); } else { inst = db::CellInstArray (db::CellInst (mm_placement_cell.get ()), - db::Trans (angle, mirror, pos), layout.array_repository (), a, b, (unsigned long) na, (unsigned long) nb); + db::Trans (angle, mirror, pos), layout.array_repository (), a, b, (uint64_t) na, (uint64_t) nb); } if (pp.first) { @@ -2078,7 +2042,7 @@ OASISReader::do_read_text (bool xy_absolute, if (m & 0x40) { if (m & 0x20) { - unsigned long id; + uint64_t id; get (id); if (m_text_forward_references.find (id) != m_text_forward_references.end ()) { @@ -2088,7 +2052,7 @@ OASISReader::do_read_text (bool xy_absolute, } else { - std::map ::const_iterator tid = m_textstrings.find (id); + std::map ::const_iterator tid = m_textstrings.find (id); if (tid == m_textstrings.end ()) { mm_text_string.reset (); @@ -2117,11 +2081,11 @@ OASISReader::do_read_text (bool xy_absolute, } if (m & 0x1) { - mm_textlayer = get_uint (); + mm_textlayer = get_uint32 (); } if (m & 0x2) { - mm_texttype = get_uint (); + mm_texttype = get_uint32 (); } if (m & 0x10) { @@ -2178,12 +2142,12 @@ OASISReader::do_read_text (bool xy_absolute, db::TextPtr text_ptr (text, layout.shape_repository ()); if (pp.first) { - auto shape = cell.shapes (ll.second).insert (db::object_with_properties (db::Shape::text_ptr_array_type (text_ptr, db::Disp (pos), layout.array_repository (), a, b, (unsigned long) na, (unsigned long) nb), pp.second)); + auto shape = cell.shapes (ll.second).insert (db::object_with_properties (db::Shape::text_ptr_array_type (text_ptr, db::Disp (pos), layout.array_repository (), a, b, (uint64_t) na, (uint64_t) nb), pp.second)); if (is_forward_properties_id (pp.second)) { register_forward_property_for_shape (shape); } } else { - cell.shapes (ll.second).insert (db::Shape::text_ptr_array_type (text_ptr, db::Disp (pos), layout.array_repository (), a, b, (unsigned long) na, (unsigned long) nb)); + cell.shapes (ll.second).insert (db::Shape::text_ptr_array_type (text_ptr, db::Disp (pos), layout.array_repository (), a, b, (uint64_t) na, (uint64_t) nb)); } } else if (! layout.is_editable () && (points = mm_repetition.get ().is_iterated ()) != 0) { @@ -2261,11 +2225,11 @@ OASISReader::do_read_rectangle (bool xy_absolute, unsigned char m = get_byte (); if (m & 0x1) { - mm_layer = get_uint (); + mm_layer = get_uint32 (); } if (m & 0x2) { - mm_datatype = get_uint (); + mm_datatype = get_uint32 (); } if (m & 0x40) { @@ -2322,12 +2286,12 @@ OASISReader::do_read_rectangle (bool xy_absolute, // Create a box array if (pp.first) { - auto shape = cell.shapes (ll.second).insert (db::object_with_properties (db::Shape::box_array_type (box, db::UnitTrans (), layout.array_repository (), a, b, (unsigned long) na, (unsigned long) nb), pp.second)); + auto shape = cell.shapes (ll.second).insert (db::object_with_properties (db::Shape::box_array_type (box, db::UnitTrans (), layout.array_repository (), a, b, (uint64_t) na, (uint64_t) nb), pp.second)); if (is_forward_properties_id (pp.second)) { register_forward_property_for_shape (shape); } } else { - cell.shapes (ll.second).insert (db::Shape::box_array_type (box, db::UnitTrans (), layout.array_repository (), a, b, (unsigned long) na, (unsigned long) nb)); + cell.shapes (ll.second).insert (db::Shape::box_array_type (box, db::UnitTrans (), layout.array_repository (), a, b, (uint64_t) na, (uint64_t) nb)); } } else if (! layout.is_editable () && (points = mm_repetition.get ().is_iterated ()) != 0) { @@ -2395,11 +2359,11 @@ OASISReader::do_read_polygon (bool xy_absolute, db::cell_index_type cell_index, unsigned char m = get_byte (); if (m & 0x1) { - mm_layer = get_uint (); + mm_layer = get_uint32 (); } if (m & 0x2) { - mm_datatype = get_uint (); + mm_datatype = get_uint32 (); } if (m & 0x20) { @@ -2460,12 +2424,12 @@ OASISReader::do_read_polygon (bool xy_absolute, db::cell_index_type cell_index, db::SimplePolygonPtr poly_ptr (poly, layout.shape_repository ()); if (pp.first) { - auto shape = cell.shapes (ll.second).insert (db::object_with_properties > (db::array (poly_ptr, db::Disp (d + pos), layout.array_repository (), a, b, (unsigned long) na, (unsigned long) nb), pp.second)); + auto shape = cell.shapes (ll.second).insert (db::object_with_properties > (db::array (poly_ptr, db::Disp (d + pos), layout.array_repository (), a, b, (uint64_t) na, (uint64_t) nb), pp.second)); if (is_forward_properties_id (pp.second)) { register_forward_property_for_shape (shape); } } else { - cell.shapes (ll.second).insert (db::array (poly_ptr, db::Disp (d + pos), layout.array_repository (), a, b, (unsigned long) na, (unsigned long) nb)); + cell.shapes (ll.second).insert (db::array (poly_ptr, db::Disp (d + pos), layout.array_repository (), a, b, (uint64_t) na, (uint64_t) nb)); } } else if (! layout.is_editable () && (points = mm_repetition.get ().is_iterated ()) != 0) { @@ -2550,11 +2514,11 @@ OASISReader::do_read_path (bool xy_absolute, db::cell_index_type cell_index, db: unsigned char m = get_byte (); if (m & 0x1) { - mm_layer = get_uint (); + mm_layer = get_uint32 (); } if (m & 0x2) { - mm_datatype = get_uint (); + mm_datatype = get_uint32 (); } if (m & 0x40) { @@ -2563,7 +2527,7 @@ OASISReader::do_read_path (bool xy_absolute, db::cell_index_type cell_index, db: if (m & 0x80) { - unsigned int e = get_uint (); + uint32_t e = get_uint32 (); if ((e & 0x0c) == 0x0c) { mm_path_start_extension = get_coord (); } else if ((e & 0x0c) == 0x04) { @@ -2641,12 +2605,12 @@ OASISReader::do_read_path (bool xy_absolute, db::cell_index_type cell_index, db: db::PathPtr path_ptr (path, layout.shape_repository ()); if (pp.first) { - auto shape = cell.shapes (ll.second).insert (db::object_with_properties > (db::array (path_ptr, db::Disp (d + pos), layout.array_repository (), a, b, (unsigned long) na, (unsigned long) nb), pp.second)); + auto shape = cell.shapes (ll.second).insert (db::object_with_properties > (db::array (path_ptr, db::Disp (d + pos), layout.array_repository (), a, b, (uint64_t) na, (uint64_t) nb), pp.second)); if (is_forward_properties_id (pp.second)) { register_forward_property_for_shape (shape); } } else { - cell.shapes (ll.second).insert (db::array (path_ptr, db::Disp (d + pos), layout.array_repository (), a, b, (unsigned long) na, (unsigned long) nb)); + cell.shapes (ll.second).insert (db::array (path_ptr, db::Disp (d + pos), layout.array_repository (), a, b, (uint64_t) na, (uint64_t) nb)); } } else if (! layout.is_editable () && (points = mm_repetition.get ().is_iterated ()) != 0) { @@ -2733,11 +2697,11 @@ OASISReader::do_read_trapezoid (unsigned char r, bool xy_absolute,db::cell_index unsigned char m = get_byte (); if (m & 0x1) { - mm_layer = get_uint (); + mm_layer = get_uint32 (); } if (m & 0x2) { - mm_datatype = get_uint (); + mm_datatype = get_uint32 (); } if (m & 0x40) { @@ -2822,12 +2786,12 @@ OASISReader::do_read_trapezoid (unsigned char r, bool xy_absolute,db::cell_index db::SimplePolygonPtr poly_ptr (poly, layout.shape_repository ()); if (pp.first) { - auto shape = cell.shapes (ll.second).insert (db::object_with_properties > (db::array (poly_ptr, db::Disp (d + pos), layout.array_repository (), a, b, (unsigned long) na, (unsigned long) nb), pp.second)); + auto shape = cell.shapes (ll.second).insert (db::object_with_properties > (db::array (poly_ptr, db::Disp (d + pos), layout.array_repository (), a, b, (uint64_t) na, (uint64_t) nb), pp.second)); if (is_forward_properties_id (pp.second)) { register_forward_property_for_shape (shape); } } else { - cell.shapes (ll.second).insert (db::array (poly_ptr, db::Disp (d + pos), layout.array_repository (), a, b, (unsigned long) na, (unsigned long) nb)); + cell.shapes (ll.second).insert (db::array (poly_ptr, db::Disp (d + pos), layout.array_repository (), a, b, (uint64_t) na, (uint64_t) nb)); } } else if (! layout.is_editable () && (points = mm_repetition.get ().is_iterated ()) != 0) { @@ -2904,15 +2868,15 @@ OASISReader::do_read_ctrapezoid (bool xy_absolute,db::cell_index_type cell_index unsigned char m = get_byte (); if (m & 0x1) { - mm_layer = get_uint (); + mm_layer = get_uint32 (); } if (m & 0x2) { - mm_datatype = get_uint (); + mm_datatype = get_uint32 (); } if (m & 0x80) { - mm_ctrapezoid_type = get_uint (); + mm_ctrapezoid_type = get_uint32 (); } if (m & 0x40) { @@ -3193,12 +3157,12 @@ OASISReader::do_read_ctrapezoid (bool xy_absolute,db::cell_index_type cell_index db::SimplePolygonPtr poly_ptr (poly, layout.shape_repository ()); if (pp.first) { - auto shape = cell.shapes (ll.second).insert (db::object_with_properties > (db::array (poly_ptr, db::Disp (d + pos), layout.array_repository (), a, b, (unsigned long) na, (unsigned long) nb), pp.second)); + auto shape = cell.shapes (ll.second).insert (db::object_with_properties > (db::array (poly_ptr, db::Disp (d + pos), layout.array_repository (), a, b, (uint64_t) na, (uint64_t) nb), pp.second)); if (is_forward_properties_id (pp.second)) { register_forward_property_for_shape (shape); } } else { - cell.shapes (ll.second).insert (db::array (poly_ptr, db::Disp (d + pos), layout.array_repository (), a, b, (unsigned long) na, (unsigned long) nb)); + cell.shapes (ll.second).insert (db::array (poly_ptr, db::Disp (d + pos), layout.array_repository (), a, b, (uint64_t) na, (uint64_t) nb)); } } else if (! layout.is_editable () && (points = mm_repetition.get ().is_iterated ()) != 0) { @@ -3275,11 +3239,11 @@ OASISReader::do_read_circle (bool xy_absolute, db::cell_index_type cell_index, d unsigned char m = get_byte (); if (m & 0x1) { - mm_layer = get_uint (); + mm_layer = get_uint32 (); } if (m & 0x2) { - mm_datatype = get_uint (); + mm_datatype = get_uint32 (); } if (m & 0x20) { @@ -3343,12 +3307,12 @@ OASISReader::do_read_circle (bool xy_absolute, db::cell_index_type cell_index, d db::PathPtr path_ptr (path, layout.shape_repository ()); if (pp.first) { - auto shape = cell.shapes (ll.second).insert (db::object_with_properties > (db::array (path_ptr, db::Disp (pos), layout.array_repository (), a, b, (unsigned long) na, (unsigned long) nb), pp.second)); + auto shape = cell.shapes (ll.second).insert (db::object_with_properties > (db::array (path_ptr, db::Disp (pos), layout.array_repository (), a, b, (uint64_t) na, (uint64_t) nb), pp.second)); if (is_forward_properties_id (pp.second)) { register_forward_property_for_shape (shape); } } else { - cell.shapes (ll.second).insert (db::array (path_ptr, db::Disp (pos), layout.array_repository (), a, b, (unsigned long) na, (unsigned long) nb)); + cell.shapes (ll.second).insert (db::array (path_ptr, db::Disp (pos), layout.array_repository (), a, b, (uint64_t) na, (uint64_t) nb)); } } else if (! layout.is_editable () && (points = mm_repetition.get ().is_iterated ()) != 0) { @@ -3537,7 +3501,7 @@ OASISReader::do_read_cell (db::cell_index_type cell_index, db::Layout &layout) } else if (r == 32 /*XELEMENT*/) { // read over - get_ulong (); + get_uint64 (); get_str (); read_element_properties (true); @@ -3547,14 +3511,14 @@ OASISReader::do_read_cell (db::cell_index_type cell_index, db::Layout &layout) // read over. unsigned char m = get_byte (); - get_ulong (); + get_uint64 (); if (m & 0x1) { - mm_layer = get_uint (); + mm_layer = get_uint32 (); } if (m & 0x2) { - mm_datatype = get_uint (); + mm_datatype = get_uint32 (); } // data payload: @@ -3588,12 +3552,12 @@ OASISReader::do_read_cell (db::cell_index_type cell_index, db::Layout &layout) } else if (r == 34 /*CBLOCK*/) { - unsigned int type = get_uint (); + uint32_t type = get_uint32 (); if (type != 0) { error (tl::sprintf (tl::to_string (tr ("Invalid CBLOCK compression type %d")), type)); } - size_t dummy = 0; + uint64_t dummy = 0; get (dummy); // uncomp-byte-count - not needed get (dummy); // comp-byte-count - not needed diff --git a/src/plugins/streamers/oasis/db_plugin/dbOASISReader.h b/src/plugins/streamers/oasis/db_plugin/dbOASISReader.h index 7d64666bd..28df204fc 100644 --- a/src/plugins/streamers/oasis/db_plugin/dbOASISReader.h +++ b/src/plugins/streamers/oasis/db_plugin/dbOASISReader.h @@ -140,14 +140,14 @@ private: modal_variable mm_placement_cell; modal_variable mm_placement_x; modal_variable mm_placement_y; - modal_variable mm_layer; - modal_variable mm_datatype; - modal_variable mm_textlayer; - modal_variable mm_texttype; + modal_variable mm_layer; + modal_variable mm_datatype; + modal_variable mm_textlayer; + modal_variable mm_texttype; modal_variable mm_text_x; modal_variable mm_text_y; modal_variable mm_text_string; - modal_variable mm_text_string_id; + modal_variable mm_text_string_id; modal_variable mm_geometry_x; modal_variable mm_geometry_y; modal_variable mm_geometry_w; @@ -157,17 +157,17 @@ private: modal_variable mm_path_start_extension; modal_variable mm_path_end_extension; modal_variable< std::vector > mm_path_point_list; - modal_variable mm_ctrapezoid_type; + modal_variable mm_ctrapezoid_type; modal_variable mm_circle_radius; modal_variable mm_last_property_name; modal_variable mm_last_property_is_sprop; modal_variable mm_last_value_list; - std::map m_cellname_properties; - std::map m_textstrings; - std::map m_text_forward_references; - std::map m_propstrings; - std::map m_propnames; + std::map m_cellname_properties; + std::map m_textstrings; + std::map m_text_forward_references; + std::map m_propstrings; + std::map m_propnames; std::map > m_context_strings_per_cell; @@ -178,8 +178,8 @@ private: bool m_read_properties; bool m_read_all_properties; - std::map m_propname_forward_references; - std::map m_propvalue_forward_references; + std::map m_propname_forward_references; + std::map m_propvalue_forward_references; std::map > m_forward_properties_for_shapes; std::map > m_forward_properties_for_instances; std::map m_future_cell_properties; @@ -234,42 +234,35 @@ private: } } - long long get_long_long (); - unsigned long long get_ulong_long (); - long get_long (); - unsigned long get_ulong (); - unsigned long get_ulong_for_divider (); - int get_int (); - unsigned int get_uint (); + int64_t get_int64 (); + uint64_t get_uint64 (); + uint64_t get_uint64_for_divider (); + int32_t get_int32 (); + uint32_t get_uint32 (); - void get (long long &l) + void get (int64_t &l) { - l = get_long_long (); + l = get_int64 (); } - void get (unsigned long long &l) + void get_size (size_t &l) { - l = get_ulong_long (); + l = get_uint64 (); } - void get (long &l) + void get (uint64_t &l) { - l = get_long (); + l = get_uint64 (); } - void get (unsigned long &l) + void get (int32_t &l) { - l = get_ulong (); + l = get_int32 (); } - void get (int &l) + void get (uint32_t &l) { - l = get_int (); - } - - void get (unsigned int &l) - { - l = get_uint (); + l = get_uint32 (); } void get (double &d) @@ -280,12 +273,12 @@ private: std::string get_str (); void get_str (std::string &s); double get_real (); - db::Vector get_gdelta (long grid = 1); - db::Vector get_3delta (long grid = 1); - db::Vector get_2delta (long grid = 1); - db::Coord get_coord (long grid = 1); - db::Coord get_ucoord (unsigned long grid = 1); - distance_type get_ucoord_as_distance (unsigned long grid = 1); + db::Vector get_gdelta (int64_t grid = 1); + db::Vector get_3delta (int64_t grid = 1); + db::Vector get_2delta (int64_t grid = 1); + db::Coord get_coord (int64_t grid = 1); + db::Coord get_ucoord (uint64_t grid = 1); + distance_type get_ucoord_as_distance (uint64_t grid = 1); }; } diff --git a/src/plugins/streamers/oasis/db_plugin/dbOASISWriter.cc b/src/plugins/streamers/oasis/db_plugin/dbOASISWriter.cc index 548a4e447..82df035d8 100644 --- a/src/plugins/streamers/oasis/db_plugin/dbOASISWriter.cc +++ b/src/plugins/streamers/oasis/db_plugin/dbOASISWriter.cc @@ -411,7 +411,7 @@ Compressor::flush (db::OASISWriter *writer) if (dd != displacements.end ()) { dxy = xrep ? db::Vector (safe_diff (dd->x (), d->x ()), 0) : db::Vector (0, safe_diff (dd->y (), d->y ())); - while (dd != displacements.end () && *dd == dd[-1] + dxy) { + while (dd != displacements.end () && *dd == dd[-1] + dxy && nxy < std::numeric_limits::max ()) { ++dd; ++nxy; } @@ -453,7 +453,7 @@ Compressor::flush (db::OASISWriter *writer) db::Vector dxy = xrep ? db::Vector (safe_diff (dd->x (), d->x ()), 0) : db::Vector (0, safe_diff (dd->y (), d->y ())); int nxy = 2; - while (dd != dwindow) { + while (dd != dwindow && nxy < std::numeric_limits::max ()) { disp_vector::iterator df = std::lower_bound (dd + 1, dwindow, *dd + dxy); if (df == dwindow || *df != *dd + dxy) { break; @@ -717,45 +717,17 @@ OASISWriter::write_bytes (const char *b, size_t n) } void -OASISWriter::write (long long n) +OASISWriter::write (int64_t n) { if (n < 0) { - write (((unsigned long long) (-n) << 1) | 1); + write (((uint64_t) (-n) << 1) | 1); } else { - write ((unsigned long long) n << 1); + write ((uint64_t) n << 1); } } void -OASISWriter::write (unsigned long long n) -{ - char buffer [50]; - char *bptr = buffer; - - do { - unsigned char b = n & 0x7f; - n >>= 7; - if (n > 0) { - b |= 0x80; - } - *bptr++ = (char) b; - } while (n > 0); - - write_bytes (buffer, bptr - buffer); -} - -void -OASISWriter::write (long n) -{ - if (n < 0) { - write (((unsigned long) (-n) << 1) | 1); - } else { - write ((unsigned long) n << 1); - } -} - -void -OASISWriter::write (unsigned long n) +OASISWriter::write (uint64_t n) { char buffer [50]; char *bptr = buffer; @@ -775,15 +747,15 @@ OASISWriter::write (unsigned long n) void OASISWriter::write (float d) { - if (fabs (d) >= 0.5 && fabs (floor (d + 0.5) - d) < 1e-6 && fabs (d) < double (std::numeric_limits::max ())) { + if (fabs (d) >= 0.5 && fabs (floor (d + 0.5) - d) < 1e-6 && fabs (d) < double (std::numeric_limits::max ())) { // whole number (negative or positive) if (d < 0.0) { write_byte (1); - write ((unsigned long) floor (-d + 0.5)); + write ((uint64_t) floor (-d + 0.5)); } else { write_byte (0); - write ((unsigned long) floor (d + 0.5)); + write ((uint64_t) floor (d + 0.5)); } } else { @@ -799,7 +771,7 @@ OASISWriter::write (float d) f2i.d = d; uint32_t i = f2i.i; char b[sizeof (f2i.i)]; - for (unsigned int n = 0; n < sizeof (f2i.i); n++) { + for (size_t n = 0; n < sizeof (f2i.i); n++) { b[n] = char (i & 0xff); i >>= 8; } @@ -811,15 +783,15 @@ OASISWriter::write (float d) void OASISWriter::write (double d) { - if (fabs (d) >= 0.5 && fabs (floor (d + 0.5) - d) < 1e-10 && fabs (d) < double (std::numeric_limits::max ())) { + if (fabs (d) >= 0.5 && fabs (floor (d + 0.5) - d) < 1e-10 && fabs (d) < double (std::numeric_limits::max ())) { // whole number (negative or positive) if (d < 0.0) { write_byte (1); - write ((unsigned long) floor (-d + 0.5)); + write ((uint64_t) floor (-d + 0.5)); } else { write_byte (0); - write ((unsigned long) floor (d + 0.5)); + write ((uint64_t) floor (d + 0.5)); } } else { @@ -848,7 +820,7 @@ void OASISWriter::write_bstring (const char *s) { size_t l = strlen (s); - write (l); + write ((uint64_t) l); write_bytes (s, l); } @@ -867,7 +839,7 @@ void OASISWriter::write_astring (const char *s) { std::string nstr = make_astring (s); - write (nstr.size ()); + write ((uint64_t) nstr.size ()); write_bytes (nstr.c_str (), nstr.size ()); } @@ -886,7 +858,7 @@ void OASISWriter::write_nstring (const char *s) { std::string nstr = make_nstring (s); - write (nstr.size ()); + write ((uint64_t) nstr.size ()); write_bytes (nstr.c_str (), nstr.size ()); } @@ -903,8 +875,8 @@ OASISWriter::write_gdelta (const db::Vector &p, double sf) if (x == -y || x == y || x == 0 || y == 0) { - unsigned long long dir = 0; - unsigned long long l = 0; + uint64_t dir = 0; + uint64_t l = 0; if (x > 0) { l = x; @@ -938,11 +910,11 @@ OASISWriter::write_gdelta (const db::Vector &p, double sf) } else { - unsigned long long d; + uint64_t d; if (x < 0) { - d = ((unsigned long long) -x << 2) | 3; + d = ((uint64_t) -x << 2) | 3; } else { - d = ((unsigned long long) x << 2) | 1; + d = ((uint64_t) x << 2) | 1; } write (d); write (y); @@ -1090,8 +1062,8 @@ OASISWriter::end_cblock () // RFC1951 compression: write_byte (0); - write (m_cblock_buffer.size ()); - write (m_cblock_compressed.size ()); + write ((uint64_t) m_cblock_buffer.size ()); + write ((uint64_t) m_cblock_compressed.size ()); write_bytes (m_cblock_compressed.data (), m_cblock_compressed.size ()); @@ -1158,7 +1130,7 @@ OASISWriter::write_propname_table (size_t &propnames_table_pos, const std::vecto { // write the property names collected so far in the order of the ID's. - std::vector > rev_pn; + std::vector > rev_pn; rev_pn.reserve (m_propnames.size ()); for (auto p = m_propnames.begin (); p != m_propnames.end (); ++p) { rev_pn.push_back (std::make_pair (p->second, p->first)); @@ -1166,7 +1138,7 @@ OASISWriter::write_propname_table (size_t &propnames_table_pos, const std::vecto std::sort (rev_pn.begin (), rev_pn.end ()); for (auto p = rev_pn.begin (); p != rev_pn.end (); ++p) { - tl_assert (p->first == (unsigned long)(p - rev_pn.begin ())); + tl_assert (p->first == (uint64_t)(p - rev_pn.begin ())); begin_table (propnames_table_pos); write_record_id (7); write_nstring (p->second.c_str ()); @@ -1236,7 +1208,7 @@ OASISWriter::write_propstring_table (size_t &propstrings_table_pos, const std::v { // write the property strings collected so far in the order of the ID's. - std::vector > rev_ps; + std::vector > rev_ps; rev_ps.reserve (m_propstrings.size ()); for (auto p = m_propstrings.begin (); p != m_propstrings.end (); ++p) { rev_ps.push_back (std::make_pair (p->second, &p->first)); @@ -1246,7 +1218,7 @@ OASISWriter::write_propstring_table (size_t &propstrings_table_pos, const std::v tl_assert (rev_ps.size () == size_t (m_propstring_id)); for (auto p = rev_ps.begin (); p != rev_ps.end (); ++p) { - tl_assert (p->first == (unsigned long)(p - rev_ps.begin ())); + tl_assert (p->first == (uint64_t)(p - rev_ps.begin ())); begin_table (propstrings_table_pos); write_record_id (9); write_bstring (p->second->c_str ()); @@ -1336,7 +1308,7 @@ OASISWriter::write_cellname_table (size_t &cellnames_table_pos, const std::vecto write_record_id (sequential ? 3 : 4); write_nstring (layout.cell_name (*cell)); if (! sequential) { - write ((unsigned long) *cell); + write ((uint64_t) *cell); } if (m_options.write_std_properties >= 1) { @@ -1391,7 +1363,7 @@ OASISWriter::write_textstring_table (size_t &textstrings_table_pos, const std::v // write present text strings // collect present strings by ID - std::vector > rev_ts; + std::vector > rev_ts; rev_ts.reserve (m_textstrings.size ()); for (auto p = m_textstrings.begin (); p != m_textstrings.end (); ++p) { rev_ts.push_back (std::make_pair (p->second, &p->first)); @@ -1401,7 +1373,7 @@ OASISWriter::write_textstring_table (size_t &textstrings_table_pos, const std::v tl_assert (rev_ts.size () == size_t (m_textstring_id)); for (auto t = rev_ts.begin (); t != rev_ts.end (); ++t) { - tl_assert (t->first == (unsigned long)(t - rev_ts.begin ())); + tl_assert (t->first == (uint64_t)(t - rev_ts.begin ())); begin_table (textstrings_table_pos); write_record_id (5); write_nstring (t->second->c_str ()); @@ -1444,16 +1416,16 @@ OASISWriter::write_layername_table (size_t &layernames_table_pos, const std::vec write_record_id (11); write_nstring (l->second.name.c_str ()); write_byte (3); - write ((unsigned long) l->second.layer); + write ((uint64_t) l->second.layer); write_byte (3); - write ((unsigned long) l->second.datatype); + write ((uint64_t) l->second.datatype); write_record_id (12); write_nstring (l->second.name.c_str ()); write_byte (3); - write ((unsigned long) l->second.layer); + write ((uint64_t) l->second.layer); write_byte (3); - write ((unsigned long) l->second.datatype); + write ((uint64_t) l->second.datatype); m_progress.set (mp_stream->pos ()); @@ -1679,7 +1651,7 @@ OASISWriter::write (db::Layout &layout, tl::OutputStream &stream, const db::Save cell_positions.insert (std::make_pair (*cell, mp_stream->pos ())); write_record_id (13); // CELL - write ((unsigned long) *cell); + write ((uint64_t) *cell); reset_modal_variables (); @@ -1696,8 +1668,8 @@ OASISWriter::write (db::Layout &layout, tl::OutputStream &stream, const db::Save write_record_id (28); write_byte (char (0xf6)); - unsigned long pnid = 0; - std::map ::const_iterator pni = m_propnames.find (klayout_context_name); + uint64_t pnid = 0; + std::map ::const_iterator pni = m_propnames.find (klayout_context_name); if (pni == m_propnames.end ()) { pnid = m_propname_id++; m_propnames.insert (std::make_pair (klayout_context_name, pnid)); @@ -1706,12 +1678,12 @@ OASISWriter::write (db::Layout &layout, tl::OutputStream &stream, const db::Save } write (pnid); - write ((unsigned long) context_prop_strings.size ()); + write ((uint64_t) context_prop_strings.size ()); for (std::vector ::const_iterator c = context_prop_strings.begin (); c != context_prop_strings.end (); ++c) { write_byte (14); // b-string by reference number - unsigned long psid = 0; - std::map ::const_iterator psi = m_propstrings.find (*c); + uint64_t psid = 0; + std::map ::const_iterator psi = m_propstrings.find (*c); if (psi == m_propstrings.end ()) { psid = m_propstring_id++; m_propstrings.insert (std::make_pair (*c, psid)).second; @@ -1795,23 +1767,23 @@ OASISWriter::write (db::Layout &layout, tl::OutputStream &stream, const db::Save // cellnames write_byte (1); - write (cellnames_table_pos); + write ((uint64_t) cellnames_table_pos); // textstrings write_byte (1); - write (textstrings_table_pos); + write ((uint64_t) textstrings_table_pos); // propnames write_byte (1); - write (propnames_table_pos); + write ((uint64_t) propnames_table_pos); // propstrings write_byte (1); - write (propstrings_table_pos); + write ((uint64_t) propstrings_table_pos); // layernames write_byte (1); - write (layernames_table_pos); + write ((uint64_t) layernames_table_pos); // xnames (not used) write_byte (1); @@ -1875,11 +1847,11 @@ OASISWriter::write (const Repetition &rep) if (g <= 1) { write_byte (10); - write (iterated->size () - 1); + write ((uint64_t) iterated->size () - 1); g = 1; } else { write_byte (11); - write (iterated->size () - 1); + write ((uint64_t) iterated->size () - 1); write_ucoord (g, 1.0); } @@ -1909,39 +1881,39 @@ OASISWriter::write (const Repetition &rep) if (b.x () == 0 && b.y () >= 0) { write_byte (3); - write (bmax - 2); + write ((uint64_t) bmax - 2); write_ucoord (b.y ()); } else if (b.y () == 0 && b.x () >= 0) { write_byte (2); - write (bmax - 2); + write ((uint64_t) bmax - 2); write_ucoord (b.x ()); } else { write_byte (9); - write (bmax - 2); + write ((uint64_t) bmax - 2); write_gdelta (b); } } else if (b.x () == 0 && b.y () >= 0 && a.y () == 0 && a.x () >= 0) { write_byte (1); - write (amax - 2); - write (bmax - 2); + write ((uint64_t) amax - 2); + write ((uint64_t) bmax - 2); write_ucoord (a.x ()); write_ucoord (b.y ()); } else if (b.y () == 0 && b.x () >= 0 && a.x () == 0 && a.y () >= 0) { write_byte (1); - write (bmax - 2); - write (amax - 2); + write ((uint64_t) bmax - 2); + write ((uint64_t) amax - 2); write_ucoord (b.x ()); write_ucoord (a.y ()); } else { write_byte (8); - write (amax - 2); - write (bmax - 2); + write ((uint64_t) amax - 2); + write ((uint64_t) bmax - 2); write_gdelta (a); write_gdelta (b); @@ -1985,7 +1957,7 @@ OASISWriter::write_inst_with_rep (const db::CellInstArray &inst, db::properties_ if (info & 0x80) { mm_placement_cell = inst.object ().cell_index (); - write ((unsigned long) mm_placement_cell.get ()); + write ((uint64_t) mm_placement_cell.get ()); } if (inst.is_complex ()) { @@ -2191,7 +2163,7 @@ OASISWriter::write_property_def (const char *name_str, const std::vector::const_iterator pni = m_propnames.find (name_str); + std::map ::const_iterator pni = m_propnames.find (name_str); // In strict mode always write property ID's: before we have issued the table we can // create new ID's. @@ -2219,11 +2191,11 @@ OASISWriter::write_property_def (const char *name_str, const std::vector= 15) { - write ((unsigned long) pvl.size ()); + write ((uint64_t) pvl.size ()); } // write property values - for (unsigned long i = 0; i < pvl.size (); ++i) { + for (uint64_t i = 0; i < pvl.size (); ++i) { const tl::Variant &v = pvl[i]; @@ -2234,27 +2206,27 @@ OASISWriter::write_property_def (const char *name_str, const std::vector::const_iterator pvi = m_propstrings.find (pvs); + std::map ::const_iterator pvi = m_propstrings.find (pvs); // In strict mode always write property string ID's: before we have issued the table we can // create new ID's. @@ -2335,7 +2307,7 @@ OASISWriter::write_pointlist (const std::vector &pointlist, bool for // manhattan pointlist write_byte (type); size_t implicit = for_polygons ? 1 : 0; - write ((unsigned long) (pointlist.size () - implicit)); + write ((uint64_t) (pointlist.size () - implicit)); db::Vector plast (0, 0); for (std::vector::const_iterator p = pointlist.begin (); p != pointlist.end () - implicit; ++p) { @@ -2353,7 +2325,7 @@ OASISWriter::write_pointlist (const std::vector &pointlist, bool for // generic pointlist write_byte (4); - write ((unsigned long) pointlist.size ()); + write ((uint64_t) pointlist.size ()); db::Vector plast (0, 0); if (m_sf == 1.0) { for (std::vector::const_iterator p = pointlist.begin (); p != pointlist.end (); ++p) { @@ -2378,8 +2350,8 @@ OASISWriter::write (const db::Text &text, db::properties_id_type prop_id, const db::Trans trans = text.trans (); - unsigned long text_id = 0; - std::map ::const_iterator ts = m_textstrings.find (text.string ()); + uint64_t text_id = 0; + std::map ::const_iterator ts = m_textstrings.find (text.string ()); if (ts == m_textstrings.end ()) { text_id = m_textstring_id++; m_textstrings.insert (std::make_pair (text.string (), text_id)); @@ -2412,15 +2384,15 @@ OASISWriter::write (const db::Text &text, db::properties_id_type prop_id, const write_byte (info); if (info & 0x40) { mm_text_string = text.string (); - write ((unsigned long) text_id); + write ((uint64_t) text_id); } if (info & 0x01) { mm_textlayer = m_layer; - write ((unsigned long) m_layer); + write ((uint64_t) m_layer); } if (info & 0x02) { mm_texttype = m_datatype; - write ((unsigned long) m_datatype); + write ((uint64_t) m_datatype); } if (info & 0x10) { mm_text_x = trans.disp ().x (); @@ -2496,11 +2468,11 @@ OASISWriter::write (const db::SimplePolygon &polygon, db::properties_id_type pro if (info & 0x01) { mm_layer = m_layer; - write ((unsigned long) m_layer); + write ((uint64_t) m_layer); } if (info & 0x02) { mm_datatype = m_datatype; - write ((unsigned long) m_datatype); + write ((uint64_t) m_datatype); } if (info & 0x20) { mm_polygon_point_list.swap (m_pointlist); @@ -2597,11 +2569,11 @@ OASISWriter::write (const db::Polygon &polygon, db::properties_id_type prop_id, if (info & 0x01) { mm_layer = m_layer; - write ((unsigned long) m_layer); + write ((uint64_t) m_layer); } if (info & 0x02) { mm_datatype = m_datatype; - write ((unsigned long) m_datatype); + write ((uint64_t) m_datatype); } if (info & 0x20) { mm_polygon_point_list.swap (m_pointlist); @@ -2667,11 +2639,11 @@ OASISWriter::write (const db::Box &box, db::properties_id_type prop_id, const db if (info & 0x01) { mm_layer = m_layer; - write ((unsigned long) m_layer); + write ((uint64_t) m_layer); } if (info & 0x02) { mm_datatype = m_datatype; - write ((unsigned long) m_datatype); + write ((uint64_t) m_datatype); } mm_geometry_w = box.width (); @@ -2772,11 +2744,11 @@ OASISWriter::write (const db::Path &path, db::properties_id_type prop_id, const if (info & 0x01) { mm_layer = m_layer; - write ((unsigned long) m_layer); + write ((uint64_t) m_layer); } if (info & 0x02) { mm_datatype = m_datatype; - write ((unsigned long) m_datatype); + write ((uint64_t) m_datatype); } if (info & 0x20) { mm_circle_radius = hw; @@ -2853,11 +2825,11 @@ OASISWriter::write (const db::Path &path, db::properties_id_type prop_id, const if (info & 0x01) { mm_layer = m_layer; - write ((unsigned long) m_layer); + write ((uint64_t) m_layer); } if (info & 0x02) { mm_datatype = m_datatype; - write ((unsigned long) m_datatype); + write ((uint64_t) m_datatype); } if (info & 0x40) { mm_path_halfwidth = hw; @@ -3046,11 +3018,11 @@ OASISWriter::write (const db::Edge &edge, db::properties_id_type prop_id, const if (info & 0x01) { mm_layer = m_layer; - write ((unsigned long) m_layer); + write ((uint64_t) m_layer); } if (info & 0x02) { mm_datatype = m_datatype; - write ((unsigned long) m_datatype); + write ((uint64_t) m_datatype); } if (info & 0x40) { mm_path_halfwidth = 0; diff --git a/src/plugins/streamers/oasis/db_plugin/dbOASISWriter.h b/src/plugins/streamers/oasis/db_plugin/dbOASISWriter.h index 9c7fbf491..3987cf7f7 100644 --- a/src/plugins/streamers/oasis/db_plugin/dbOASISWriter.h +++ b/src/plugins/streamers/oasis/db_plugin/dbOASISWriter.h @@ -208,14 +208,14 @@ private: tl::OutputMemoryStream m_cblock_buffer; tl::OutputMemoryStream m_cblock_compressed; bool m_in_cblock; - unsigned long m_propname_id; - unsigned long m_propstring_id; - unsigned long m_textstring_id; + uint64_t m_propname_id; + uint64_t m_propstring_id; + uint64_t m_textstring_id; bool m_proptables_written; - std::map m_textstrings; - std::map m_propnames; - std::map m_propstrings; + std::map m_textstrings; + std::map m_propnames; + std::map m_propstrings; typedef std::vector property_value_list; @@ -223,23 +223,23 @@ private: modal_variable mm_placement_cell; modal_variable mm_placement_x; modal_variable mm_placement_y; - modal_variable mm_layer; - modal_variable mm_datatype; - modal_variable mm_textlayer; - modal_variable mm_texttype; + modal_variable mm_layer; + modal_variable mm_datatype; + modal_variable mm_textlayer; + modal_variable mm_texttype; modal_variable mm_text_x; modal_variable mm_text_y; modal_variable mm_text_string; modal_variable mm_geometry_x; modal_variable mm_geometry_y; - modal_variable mm_geometry_w; - modal_variable mm_geometry_h; + modal_variable::distance_type> mm_geometry_w; + modal_variable::distance_type> mm_geometry_h; modal_variable< std::vector > mm_polygon_point_list; modal_variable mm_path_halfwidth; modal_variable mm_path_start_extension; modal_variable mm_path_end_extension; modal_variable< std::vector > mm_path_point_list; - modal_variable mm_ctrapezoid_type; + modal_variable mm_ctrapezoid_type; modal_variable mm_circle_radius; modal_variable mm_last_property_name; modal_variable mm_last_property_is_sprop; @@ -273,19 +273,17 @@ private: void write (double d); void write (float d); - void write (long n); - void write (unsigned long n); - void write (long long n); - void write (unsigned long long n); + void write (int64_t n); + void write (uint64_t n); - void write (int n) + void write (int32_t n) { - write (long (n)); + write (int64_t (n)); } - void write (unsigned int n) + void write (uint32_t n) { - write ((unsigned long) (n)); + write ((uint64_t) (n)); } void write (const Repetition &rep); diff --git a/src/plugins/streamers/oasis/unit_tests/dbOASISReaderTests.cc b/src/plugins/streamers/oasis/unit_tests/dbOASISReaderTests.cc index 02d1f8a3c..7f906dcd8 100644 --- a/src/plugins/streamers/oasis/unit_tests/dbOASISReaderTests.cc +++ b/src/plugins/streamers/oasis/unit_tests/dbOASISReaderTests.cc @@ -679,3 +679,24 @@ TEST(DuplicateCellname) EXPECT_EQ (ex.msg ().find ("Same cell name TOP, but different IDs: 3 and 0 (position=1070, cell=)"), size_t (0)); } } + +TEST(BlendCrash) +{ + db::Manager m (false); + db::Layout layout (&m); + + { + tl::InputStream file (tl::testdata () + "/oasis/blend_crash1.oas"); + db::OASISReader reader (file); + reader.read (layout); + } + + { + tl::InputStream file (tl::testdata () + "/oasis/blend_crash2.oas"); + db::OASISReader reader (file); + reader.read (layout); + } + + std::string fn_au (tl::testdata () + "/oasis/blend_crash_au.gds.gz"); + db::compare_layouts (_this, layout, fn_au, db::WriteGDS2, 1); +} diff --git a/testdata/oasis/blend_crash1.oas b/testdata/oasis/blend_crash1.oas new file mode 100644 index 000000000..1d86e551f Binary files /dev/null and b/testdata/oasis/blend_crash1.oas differ diff --git a/testdata/oasis/blend_crash2.oas b/testdata/oasis/blend_crash2.oas new file mode 100644 index 000000000..ccd436483 Binary files /dev/null and b/testdata/oasis/blend_crash2.oas differ diff --git a/testdata/oasis/blend_crash_au.gds.gz b/testdata/oasis/blend_crash_au.gds.gz new file mode 100644 index 000000000..5118f4399 Binary files /dev/null and b/testdata/oasis/blend_crash_au.gds.gz differ