Skip to content

Commit

Permalink
Fix BLOCKSTRETCHACTION object codes
Browse files Browse the repository at this point in the history
Part of GH#1054
  • Loading branch information
michal-josef-spacek committed Dec 6, 2024
1 parent 2a4122d commit b71c292
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 23 deletions.
6 changes: 3 additions & 3 deletions doc/dynapi.texi
Original file line number Diff line number Diff line change
Expand Up @@ -13796,10 +13796,10 @@ BD*
struct _dwg_object_BLOCKSTRETCHACTION*
@item bl95
BL, DXF 95
@item bs76
@item num_indexes
BS, DXF 76
@item bl94
BL, DXF 94
@item indexes
BL*

@end vtable
@end indentedblock
Expand Down
6 changes: 3 additions & 3 deletions include/dwg.h
Original file line number Diff line number Diff line change
Expand Up @@ -7806,9 +7806,9 @@ typedef struct _dwg_BLOCKSTRETCHACTION_handles {

typedef struct _dwg_BLOCKSTRETCHACTION_codes {
struct _dwg_object_BLOCKSTRETCHACTION *parent;
BITCODE_BL bl95; // 95
BITCODE_BS bs76; // 76
BITCODE_BL bl94; // 94
BITCODE_BL bl95; // 95
BITCODE_BS num_indexes; // 76
BITCODE_BL *indexes; // 94
} Dwg_BLOCKSTRETCHACTION_codes;

typedef struct _dwg_object_BLOCKSTRETCHACTION
Expand Down
5 changes: 3 additions & 2 deletions src/dwg.spec
Original file line number Diff line number Diff line change
Expand Up @@ -12437,8 +12437,9 @@ DWG_OBJECT (BLOCKSTRETCHACTION)
REPEAT (num_codes, codes, Dwg_BLOCKSTRETCHACTION_codes)
REPEAT_BLOCK
SUB_FIELD_BL (codes[rcount1], bl95, 95);
SUB_FIELD_BS (codes[rcount1], bs76, 76);
SUB_FIELD_BL (codes[rcount1], bl94, 94);
SUB_FIELD_BS (codes[rcount1], num_indexes, 76);
SUB_FIELD_VALUE (codes[rcount1], indexes) = (BITCODE_BL *)calloc (_obj->codes[rcount1].num_indexes, sizeof (BITCODE_BL));
SUB_FIELD_VECTOR_INL (codes[rcount1], indexes, BL, _obj->codes[rcount1].num_indexes, 94);
SET_PARENT_OBJ (codes[rcount1]);
END_REPEAT_BLOCK
END_REPEAT (codes)
Expand Down
6 changes: 3 additions & 3 deletions src/dynapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -11242,10 +11242,10 @@ static const Dwg_DYNAPI_field _dwg_BLOCKSTRETCHACTION_codes_fields[] = {
1,1,0, 0 },
{ "bl95", "BL", sizeof (BITCODE_BL), OFF (struct _dwg_BLOCKSTRETCHACTION_codes, bl95),
0,0,0, 95 },
{ "bs76", "BS", sizeof (BITCODE_BS), OFF (struct _dwg_BLOCKSTRETCHACTION_codes, bs76),
{ "num_indexes", "BS", sizeof (BITCODE_BS), OFF (struct _dwg_BLOCKSTRETCHACTION_codes, num_indexes),
0,0,0, 76 },
{ "bl94", "BL", sizeof (BITCODE_BL), OFF (struct _dwg_BLOCKSTRETCHACTION_codes, bl94),
0,0,0, 94 },
{ "indexes", "BL*", sizeof (BITCODE_BL*), OFF (struct _dwg_BLOCKSTRETCHACTION_codes, indexes),
1,1,0, 0 },
{NULL, NULL, 0, 0, 0,0,0, 0},
};
/* from typedef struct _dwg_BLOCKSTRETCHACTION_handles: (sorted by offset) */
Expand Down
26 changes: 16 additions & 10 deletions src/in_dxf.c
Original file line number Diff line number Diff line change
Expand Up @@ -7906,18 +7906,24 @@ add_AcDbBlockStretchAction (Dwg_Object *restrict obj, Bit_Chain *restrict dat)
dxf_free_pair (pair);

pair = dxf_read_pair (dat);
EXPECT_DXF (obj->name, o->codes[i].bs76, 76);
o->codes[i].bs76 = pair->value.i;
LOG_TRACE ("%s.codes[%d].bs76 = %d [BS 76]\n", obj->name, i,
o->codes[i].bs76);
EXPECT_DXF (obj->name, o->codes[i].num_indexes, 76);
o->codes[i].num_indexes = pair->value.i;
LOG_TRACE ("%s.codes[%d].num_indexes = %d [BS 76]\n", obj->name, i,
o->codes[i].num_indexes);
dxf_free_pair (pair);

pair = dxf_read_pair (dat);
EXPECT_DXF (obj->name, o->codes[i].bl94, 94);
o->codes[i].bl94 = pair->value.i;
LOG_TRACE ("%s.codes[%d].bl94 = %d [BL 94]\n", obj->name, i,
o->codes[i].bl94);
dxf_free_pair (pair);
if (o->codes[i].num_indexes)
{
for (unsigned j = 0; j < o->hdls[i].num_indexes; j++)
{
pair = dxf_read_pair (dat);
EXPECT_DXF (obj->name, o->codes[i].indexes[j], 94);
o->codes[i].indexes[j] = pair->value.i;
LOG_TRACE ("%s.codes[%d].indexes[%d] = %d [BL 94]\n", obj->name, i, j,
o->codes[i].indexes[j]);
dxf_free_pair (pair);
}
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions test/unit-testing/blockstretchaction.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ api_process (dwg_object *obj)
for (i = 0; i < num_codes; i++)
{
CHK_SUBCLASS_TYPE (_obj->codes[i], BLOCKSTRETCHACTION_codes, bl95, BL);
CHK_SUBCLASS_TYPE (_obj->codes[i], BLOCKSTRETCHACTION_codes, bs76, BS);
CHK_SUBCLASS_TYPE (_obj->codes[i], BLOCKSTRETCHACTION_codes, bl94, BL);
CHK_SUBCLASS_TYPE (_obj->codes[i], BLOCKSTRETCHACTION_codes, num_indexes, BS);
CHK_SUBCLASS_VECTOR_TYPE (_obj->codes[i], BLOCKSTRETCHACTION, indexes, _obj->codes[i]->num_indexes, BL);
}

CHK_ENTITY_TYPE (_obj, BLOCKSTRETCHACTION, action_offset_x, BD);
Expand Down

0 comments on commit b71c292

Please sign in to comment.