Skip to content

Commit

Permalink
Avoid anonymous structs and unions
Browse files Browse the repository at this point in the history
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
  • Loading branch information
glondu committed Dec 20, 2021
1 parent f8f760f commit 9a7de23
Showing 1 changed file with 16 additions and 21 deletions.
37 changes: 16 additions & 21 deletions include/yaml.h
Original file line number Diff line number Diff line change
Expand Up @@ -272,36 +272,36 @@ typedef struct yaml_token_s {
yaml_token_type_t type;

/** The token data. */
union {
union yaml_data_u {

/** The stream start (for @c YAML_STREAM_START_TOKEN). */
struct {
struct yaml_stream_start_s {
/** The stream encoding. */
yaml_encoding_t encoding;
} stream_start;

/** The alias (for @c YAML_ALIAS_TOKEN). */
struct {
struct yaml_alias_s {
/** The alias value. */
yaml_char_t *value;
} alias;

/** The anchor (for @c YAML_ANCHOR_TOKEN). */
struct {
struct yaml_anchor_s {
/** The anchor value. */
yaml_char_t *value;
} anchor;

/** The tag (for @c YAML_TAG_TOKEN). */
struct {
struct yaml_tag_s {
/** The tag handle. */
yaml_char_t *handle;
/** The tag suffix. */
yaml_char_t *suffix;
} tag;

/** The scalar value (for @c YAML_SCALAR_TOKEN). */
struct {
struct yaml_scalar_s {
/** The scalar value. */
yaml_char_t *value;
/** The length of the scalar value. */
Expand All @@ -311,12 +311,7 @@ typedef struct yaml_token_s {
} scalar;

/** The version directive (for @c YAML_VERSION_DIRECTIVE_TOKEN). */
struct {
/** The major version number. */
int major;
/** The minor version number. */
int minor;
} version_directive;
struct yaml_version_directive_s version_directive;

/** The tag directive (for @c YAML_TAG_DIRECTIVE_TOKEN). */
struct {
Expand Down Expand Up @@ -389,21 +384,21 @@ typedef struct yaml_event_s {
yaml_event_type_t type;

/** The event data. */
union {
union yaml_event_data_u {

/** The stream parameters (for @c YAML_STREAM_START_EVENT). */
struct {
struct yaml_event_stream_start_s {
/** The document encoding. */
yaml_encoding_t encoding;
} stream_start;

/** The document parameters (for @c YAML_DOCUMENT_START_EVENT). */
struct {
struct yaml_event_document_start_s {
/** The version directive. */
yaml_version_directive_t *version_directive;

/** The list of tag directives. */
struct {
struct yaml_event_tag_directives_s {
/** The beginning of the tag directives list. */
yaml_tag_directive_t *start;
/** The end of the tag directives list. */
Expand All @@ -415,19 +410,19 @@ typedef struct yaml_event_s {
} document_start;

/** The document end parameters (for @c YAML_DOCUMENT_END_EVENT). */
struct {
struct yaml_event_document_end_s {
/** Is the document end indicator implicit? */
int implicit;
} document_end;

/** The alias parameters (for @c YAML_ALIAS_EVENT). */
struct {
struct yaml_event_alias_s {
/** The anchor. */
yaml_char_t *anchor;
} alias;

/** The scalar parameters (for @c YAML_SCALAR_EVENT). */
struct {
struct yaml_event_scalar_s {
/** The anchor. */
yaml_char_t *anchor;
/** The tag. */
Expand All @@ -445,7 +440,7 @@ typedef struct yaml_event_s {
} scalar;

/** The sequence parameters (for @c YAML_SEQUENCE_START_EVENT). */
struct {
struct yaml_event_sequence_start_s {
/** The anchor. */
yaml_char_t *anchor;
/** The tag. */
Expand All @@ -457,7 +452,7 @@ typedef struct yaml_event_s {
} sequence_start;

/** The mapping parameters (for @c YAML_MAPPING_START_EVENT). */
struct {
struct yaml_event_mapping_start_s {
/** The anchor. */
yaml_char_t *anchor;
/** The tag. */
Expand Down

0 comments on commit 9a7de23

Please sign in to comment.