Skip to content

fix(tables): read the entry header's 64-flag and Xdep bits by release, under the spec's names - #235

Merged
DrunkOnJava merged 2 commits into
mainfrom
fix/table-entry-flags
Oct 26, 2026
Merged

DrunkOnJava merged 2 commits into
mainfrom
fix/table-entry-flags

Conversation

@DrunkOnJava

Copy link
Copy Markdown
Owner

Summary

The table-entry header's two flag bits land in the field the spec names them by, on every release: TableEntryHeader now has flag_64 and is_xref_dependent (Xdep), and the R2007+ reader orders the two bits by release as AutoCAD's own DXF exports show they are ordered.

Spec reference

§20.4.54 LAYER and every other table section (§20.4.52, .56, .58, .60, .62, .64, .66, .68) give the header as TV name, B 64-flag (70), BS xrefindex+1, B Xdep (70, bit 16). On main:

  • TableEntryHeader called the first bit is_xref_dependent and the last is_xref_resolved, so on R2000 and R2004 is_xref_dependent held the 64-flag;
  • the R2007+ split-stream decoders read the two bits ahead of the BS (measured earlier on R2018 STYLE) and stored them the other way round, so the same bit landed in a different field by release.

Which bit is which on R2007+ is settled by the DXF value oracle (#99): AutoCAD's exports leave bit 16 of group 70 clear on every table entry of the corpus and never write bit 64. On R2007 and R2010 the first bit of the pair is the one clear on every entry; on R2013 and R2018 it is the second. read_entry_flags now orders them by release (documented on the function). The corpus has no xref-dependent entry, so it pins which position carries the always-clear bit, not a set Xdep; that caveat is in the docs.

StyleEntry's xref flag (0x08) is derived from Xdep; it was set on R2000 to R2010 styles and now follows the right bit.

Test plan

  • cargo fmt --all -- --check, cargo clippy --all-targets --all-features -- -D warnings, RUSTDOCFLAGS="-D warnings" cargo doc --no-deps --all-features
  • cargo test --release --all-features (with the 19-file ../../samples corpus present): all pass; the renames touch three existing assertions, no test added
  • Shown on real files with the DXF value oracle (examples/dxf_oracle, the pairing and scorer example that follows feat(dxf): an ASCII DXF reader keyed by handle, for the value oracle #223), over the 42 nextgis/dwg_samples drawings at ff05d5a8 and the ACadSharp samples/ at c30a97ce (the pinned set of ci(corpus): measure the reader on public drawings fetched by pinned hash #225), every table record paired with AutoCAD's export of the same drawing by handle:
cargo run --release --features dxf-reader --example dxf_oracle -- <corpus-dir>

Before (main): the header bit scored against bit 16 of group 70 (cells: = all agree, ≠k/n k of n disagree):

              field                                    group            R14   R2000   R2004   R2007   R2010   R2013   R2018   total
APPID         xdep (header.is_xref_resolved)           70&16                      =       =       =       =  ≠60/60  ≠41/41   240/0/101/0
BLOCK_HEADER  BLOCK.xdep (header.is_xref_resolved)     BLOCK.70&16                =       =       =       =  ≠40/47  ≠21/29   203/0/61/0
DIMSTYLE      xdep (header.is_xref_resolved)           70&16                      =       =       =       =  ≠20/20    ≠8/8   74/0/28/0
LAYER         xdep (header.is_xref_resolved)           70&16                      =       =       =       =  ≠24/26  ≠17/20   109/0/41/0
LTYPE         xdep (header.is_xref_resolved)           70&16                      =       =       =       =  ≠29/29  ≠11/11   116/0/40/0
STYLE         xdep (header.is_xref_resolved)           70&16                      =       =       =       =  ≠20/20    ≠8/8   80/0/28/0
VPORT         xdep (header.is_xref_resolved)           70&16                      =       =       =       =    ≠8/8    ≠1/2   33/0/9/0

After (this branch):

  field                                    group            R14   R2000   R2004   R2007   R2010   R2013   R2018   total
APPID        is_xref_dependent (Xdep)                 70&16                      =       =       =       =       =       =   341/0/0/0
BLOCK_HEADER BLOCK.is_xref_dependent (Xdep)           BLOCK.70&16                =       =       =       =       =       =   264/0/0/0
DIMSTYLE     is_xref_dependent (Xdep)                 70&16                      =       =       =       =       =       =   102/0/0/0
LAYER        is_xref_dependent (Xdep)                 70&16                      =       =       =       =       =       =   150/0/0/0
LTYPE        is_xref_dependent (Xdep)                 70&16                      =       =       =       =       =       =   156/0/0/0
STYLE        is_xref_dependent (Xdep)                 70&16                      =       =       =       =       =       =   108/0/0/0
VPORT        is_xref_dependent (Xdep)                 70&16                      =       =       =       =       =       =   42/0/0/0

308 disagreements become 0; the oracle's total disagreements across the corpus fall from 420 to 112 (the remainder are the VPORT and LAYOUT findings, which have their own PRs, and the open ones listed on #99). Decode counts are unchanged: the same bits are consumed.

Source-provenance declaration

By submitting this PR I certify that my contribution does not incorporate executable code from any source whose license is incompatible with Apache-2.0. Specifically:

  • No Autodesk DWG SDK source (RealDWG, ObjectARX, ObjectDBX) or NDA-protected Autodesk documentation was consulted or imported.
  • No Open Design Alliance Teigha / Drawings SDK source was consulted or imported. The ODA's public Open Design Specification for .dwg files PDF is explicitly allowed (see CLEANROOM.md).
  • No GPL-licensed DWG implementation source (LibreDWG, etc.) was consulted or imported.

My contribution is based on the ODA specification v5.4.1 (§20.4.54 and the other table sections), Autodesk's public DXF Reference (group 70 bits 16 and 64), and AutoCAD's own DXF exports in nextgis/dwg_samples and the ACadSharp samples/ directory, read as data only. No permissively-licensed project's code or comments were read.

Developer Certificate of Origin

By submitting this PR, I certify that the contribution complies with the Developer Certificate of Origin 1.1.

Refs #99

…, under the spec's names

§20.4.54 and every table section give the entry header as TV name,
B 64-flag, BS xrefindex+1, B Xdep. TableEntryHeader called the first
bit is_xref_dependent and the last is_xref_resolved, and the R2007+
split-stream decoders, which read the two bits ahead of the BS, stored
them in the opposite fields, so the same on-disk bit landed in a
different field depending on the release: is_xref_dependent held the
64-flag on R2000 to R2010, and on R2013 and R2018 is_xref_resolved did.

The DXF value oracle settles which bit is which. AutoCAD's exports
leave bit 16 of group 70 (Xdep) clear on every table entry of the
corpus and never write bit 64. On R2007 and R2010 the first bit of the
pair is the one that is clear on every entry, on R2013 and R2018 the
second, so read_entry_flags now orders them by release. The fields are
flag_64 and is_xref_dependent on every release; Xdep equals the
export's bit 16 on all 899 table entries and 264 BLOCK records of the
nextgis and ACadSharp exports, where 308 disagreed before. STYLE's xref
flag (0x08), derived from Xdep, was set on R2000 to R2010 styles and
now follows the right bit.

Refs #99
@DrunkOnJava
DrunkOnJava enabled auto-merge (squash) October 26, 2026 09:25
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-26T10:32:15.582680Z 34af30f New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@DrunkOnJava
DrunkOnJava enabled auto-merge (squash) October 26, 2026 10:30
@DrunkOnJava
DrunkOnJava merged commit 10f83c8 into main Oct 26, 2026
25 checks passed
@DrunkOnJava
DrunkOnJava deleted the fix/table-entry-flags branch October 26, 2026 10:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant