Repository navigation
JWW.Point, JWW.Drawing.Counts, JWW.BlockDef and JWW.Drawing can now be built from outside the module (#53). All four were public structs with public properties and internal initializers, so code that imported SwiftJWW could read one and not make one, and could not make the Entity cases that take a Point (.line, .arc, .point, .text, .insert) either. A test that needed a small drawing in memory had to use @testable import SwiftJWW, which builds in a debug configuration only, or read a .jww file.
This is additive, so a minor release. No public signature changes and no public API is removed. The reader, DXFWriter and jww2dxf are not edited, and the DXF jww2dxf writes from a real drawing is byte for byte the same as in 2.1.0.
Added
| Type | Public initializers | Parameters with a default |
|---|---|---|
Point |
init(x:y:) |
none |
Drawing.Counts |
init(line:arc:point:text:solid:block:dim:) |
all seven, 0 |
BlockDef |
init(number:name:entities:solidCount:), init(number:name:elements:solidCount:) |
solidCount, 0 |
Drawing |
init(version:entities:blocks:counts:layerGroups:), init(version:elements:blocks:counts:layerGroups:) |
blocks, empty; layerGroups, empty |
- A
DrawingorBlockDeftakes itsentitiesor itselements, not both, and derives the other, so a value built by hand starts with the two holding the same geometry. Both staypublic var. The two internal initializers that tookentities:with an optionalelements:are replaced by these; nothing in the package or its tests passed both. countshas no default: it is the tally of the objects in a file, and a drawing built by hand states none until the caller says so. A parameter can be given a default in a later release without breaking a caller; taking one away breaks them.layerGroupsdefaults to empty, as its documentation already said of a drawing not read from a file.scale(ofLayerGroup:)is then nil andDXFWriterwrites each group as drawn.
Still not constructible from outside, and not changed
BlockReference (so an Element built by hand cannot carry references, which default to none) and the types the package returns: RecoveredDimension, DimensionRecovery, BlockExpansion, Dimension with its Segment and Label, and DXFWriter.Output.
What was run
- A separate package with a plain
import SwiftJWWthat builds a drawing of a line and a text and reads the same values back. Against 2.1.0 it does not compile (initializer is inaccessible due to 'internal' protection level). With this change it builds and runs underswift buildandswift build -c release, and its own test target passes in both configurations. A@testable import SwiftJWWin the same package builds in debug and fails in release. - 11 new tests in
PublicInitializerTests, with a plainimport SwiftJWW, which fail to compile against the 2.1.0 sources. They also write hand-built drawings throughDXFWriter, drawn and full size. The suite goes from 186 to 197 tests, all passing, nine of them skipping withoutSWIFTJWW_FIXTURESas before.
Not verified
Linux and any platform but macOS were not run.
Documentation
The README and docs/index.md have a "Building a drawing" section, and JWW.Drawing has an in-source example. The install snippets still say from: "2.0.0", which takes this release.
Full entry: docs/CHANGELOG.md.