Skip to content

Commit 9a7de23

Browse files
committed
Avoid anonymous structs and unions
Rationale: ocaml-yaml bindings need to probe their size at compile time. For this reason, it vendors libyaml with a modified include file, which is not reasonable. See: https://github.com/avsm/ocaml-yaml/blob/master/vendor/README.md
1 parent f8f760f commit 9a7de23

File tree

1 file changed

+16
-21
lines changed

1 file changed

+16
-21
lines changed

include/yaml.h

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -272,36 +272,36 @@ typedef struct yaml_token_s {
272272
yaml_token_type_t type;
273273

274274
/** The token data. */
275-
union {
275+
union yaml_data_u {
276276

277277
/** The stream start (for @c YAML_STREAM_START_TOKEN). */
278-
struct {
278+
struct yaml_stream_start_s {
279279
/** The stream encoding. */
280280
yaml_encoding_t encoding;
281281
} stream_start;
282282

283283
/** The alias (for @c YAML_ALIAS_TOKEN). */
284-
struct {
284+
struct yaml_alias_s {
285285
/** The alias value. */
286286
yaml_char_t *value;
287287
} alias;
288288

289289
/** The anchor (for @c YAML_ANCHOR_TOKEN). */
290-
struct {
290+
struct yaml_anchor_s {
291291
/** The anchor value. */
292292
yaml_char_t *value;
293293
} anchor;
294294

295295
/** The tag (for @c YAML_TAG_TOKEN). */
296-
struct {
296+
struct yaml_tag_s {
297297
/** The tag handle. */
298298
yaml_char_t *handle;
299299
/** The tag suffix. */
300300
yaml_char_t *suffix;
301301
} tag;
302302

303303
/** The scalar value (for @c YAML_SCALAR_TOKEN). */
304-
struct {
304+
struct yaml_scalar_s {
305305
/** The scalar value. */
306306
yaml_char_t *value;
307307
/** The length of the scalar value. */
@@ -311,12 +311,7 @@ typedef struct yaml_token_s {
311311
} scalar;
312312

313313
/** The version directive (for @c YAML_VERSION_DIRECTIVE_TOKEN). */
314-
struct {
315-
/** The major version number. */
316-
int major;
317-
/** The minor version number. */
318-
int minor;
319-
} version_directive;
314+
struct yaml_version_directive_s version_directive;
320315

321316
/** The tag directive (for @c YAML_TAG_DIRECTIVE_TOKEN). */
322317
struct {
@@ -389,21 +384,21 @@ typedef struct yaml_event_s {
389384
yaml_event_type_t type;
390385

391386
/** The event data. */
392-
union {
387+
union yaml_event_data_u {
393388

394389
/** The stream parameters (for @c YAML_STREAM_START_EVENT). */
395-
struct {
390+
struct yaml_event_stream_start_s {
396391
/** The document encoding. */
397392
yaml_encoding_t encoding;
398393
} stream_start;
399394

400395
/** The document parameters (for @c YAML_DOCUMENT_START_EVENT). */
401-
struct {
396+
struct yaml_event_document_start_s {
402397
/** The version directive. */
403398
yaml_version_directive_t *version_directive;
404399

405400
/** The list of tag directives. */
406-
struct {
401+
struct yaml_event_tag_directives_s {
407402
/** The beginning of the tag directives list. */
408403
yaml_tag_directive_t *start;
409404
/** The end of the tag directives list. */
@@ -415,19 +410,19 @@ typedef struct yaml_event_s {
415410
} document_start;
416411

417412
/** The document end parameters (for @c YAML_DOCUMENT_END_EVENT). */
418-
struct {
413+
struct yaml_event_document_end_s {
419414
/** Is the document end indicator implicit? */
420415
int implicit;
421416
} document_end;
422417

423418
/** The alias parameters (for @c YAML_ALIAS_EVENT). */
424-
struct {
419+
struct yaml_event_alias_s {
425420
/** The anchor. */
426421
yaml_char_t *anchor;
427422
} alias;
428423

429424
/** The scalar parameters (for @c YAML_SCALAR_EVENT). */
430-
struct {
425+
struct yaml_event_scalar_s {
431426
/** The anchor. */
432427
yaml_char_t *anchor;
433428
/** The tag. */
@@ -445,7 +440,7 @@ typedef struct yaml_event_s {
445440
} scalar;
446441

447442
/** The sequence parameters (for @c YAML_SEQUENCE_START_EVENT). */
448-
struct {
443+
struct yaml_event_sequence_start_s {
449444
/** The anchor. */
450445
yaml_char_t *anchor;
451446
/** The tag. */
@@ -457,7 +452,7 @@ typedef struct yaml_event_s {
457452
} sequence_start;
458453

459454
/** The mapping parameters (for @c YAML_MAPPING_START_EVENT). */
460-
struct {
455+
struct yaml_event_mapping_start_s {
461456
/** The anchor. */
462457
yaml_char_t *anchor;
463458
/** The tag. */

0 commit comments

Comments
 (0)