! */
! /** The character type (UTF-8 octet). */
+! libYAML returns it's data as null-terminated UTF-8 string.
+! It copies it's input and we can use null-terminated string
+! if we give a negative length. So we can use factor's c-string
+! for input and output.
TYPEDEF: uchar yaml_char_t
! /** The version directive data. */
! /** The tag directive data. */
STRUCT: yaml_tag_directive_t
- { handle yaml_char_t* }
- { prefix yaml_char_t* }
+ { handle c-string }
+ { prefix c-string }
;
! /** The stream encoding. */
;
! /** The alias (for @c YAML_ALIAS_TOKEN). */
STRUCT: alias_token_data
- { value yaml_char_t* }
+ { value c-string }
;
! /** The anchor (for @c YAML_ANCHOR_TOKEN). */
STRUCT: anchor_token_data
- { value yaml_char_t* }
+ { value c-string }
;
! /** The tag (for @c YAML_TAG_TOKEN). */
STRUCT: tag_token_data
- { handle yaml_char_t* }
- { suffix yaml_char_t* }
+ { handle c-string }
+ { suffix c-string }
;
! /** The scalar value (for @c YAML_SCALAR_TOKEN). */
STRUCT: scalar_token_data
- { value yaml_char_t* }
+ { value c-string }
{ length size_t }
{ style yaml_scalar_style_t }
;
! /** The alias parameters (for @c YAML_ALIAS_EVENT). */
STRUCT: alias_event_data
- { anchor yaml_char_t* }
+ { anchor c-string }
;
! /** The scalar parameters (for @c YAML_SCALAR_EVENT). */
STRUCT: scalar_event_data
- { anchor yaml_char_t* }
- { tag yaml_char_t* }
- { value yaml_char_t* }
+ { anchor c-string }
+ { tag c-string }
+ { value c-string }
{ length size_t }
{ plain_implicit int }
{ quoted_implicit int }
! /** The sequence parameters (for @c YAML_SEQUENCE_START_EVENT). */
STRUCT: sequence_start_event_data
- { anchor yaml_char_t* }
- { tag yaml_char_t* }
+ { anchor c-string }
+ { tag c-string }
{ implicit int }
{ style yaml_sequence_style_t }
;
! /** The mapping parameters (for @c YAML_MAPPING_START_EVENT). */
STRUCT: mapping_start_event_data
- { anchor yaml_char_t* }
- { tag yaml_char_t* }
+ { anchor c-string }
+ { tag c-string }
{ implicit int }
{ style yaml_mapping_style_t }
;
! */
FUNCTION: int
-yaml_alias_event_initialize ( yaml_event_t *event, yaml_char_t *anchor ) ;
+yaml_alias_event_initialize ( yaml_event_t *event, c-string anchor ) ;
! /**
! * Create a SCALAR event.
FUNCTION: int
yaml_scalar_event_initialize ( yaml_event_t *event,
- yaml_char_t *anchor, yaml_char_t *tag,
- yaml_char_t *value, int length,
+ c-string anchor, c-string tag,
+ c-string value, int length,
int plain_implicit, int quoted_implicit,
yaml_scalar_style_t style ) ;
FUNCTION: int
yaml_sequence_start_event_initialize ( yaml_event_t *event,
- yaml_char_t *anchor, yaml_char_t *tag, int implicit,
+ c-string anchor, c-string tag, int implicit,
yaml_sequence_style_t style ) ;
! /**
FUNCTION: int
yaml_mapping_start_event_initialize ( yaml_event_t *event,
- yaml_char_t *anchor, yaml_char_t *tag, int implicit,
+ c-string anchor, c-string tag, int implicit,
yaml_mapping_style_t style ) ;
! /**
! /** The node structure. */
! /** The scalar parameters (for @c YAML_SCALAR_NODE). */
STRUCT: scalar_node_data
- { value yaml_char_t* }
+ { value c-string }
{ length size_t }
{ style yaml_scalar_style_t }
;
{ type yaml_node_type_t }
- { tag yaml_char_t* }
+ { tag c-string }
{ data node_data }
FUNCTION: int
yaml_document_add_scalar ( yaml_document_t *document,
- yaml_char_t *tag, yaml_char_t *value, int length,
+ c-string tag, c-string value, int length,
yaml_scalar_style_t style ) ;
! /**
FUNCTION: int
yaml_document_add_sequence ( yaml_document_t *document,
- yaml_char_t *tag, yaml_sequence_style_t style ) ;
+ c-string tag, yaml_sequence_style_t style ) ;
! /**
! * Create a MAPPING node and attach it to the document.
FUNCTION: int
yaml_document_add_mapping ( yaml_document_t *document,
- yaml_char_t *tag, yaml_mapping_style_t style ) ;
+ c-string tag, yaml_mapping_style_t style ) ;
! /**
! * Add an item to a SEQUENCE node.
! */
STRUCT: yaml_alias_data_t
- { anchor yaml_char_t* }
+ { anchor c-string }
{ index int }
{ mark yaml_mark_t }
;
! /** Anchor analysis. */
STRUCT: yaml_emitter_anchor_data
- { anchor yaml_char_t* }
+ { anchor c-string }
{ anchor_length size_t }
{ alias int }
;
! /** Tag analysis. */
STRUCT: yaml_emitter_tag_data
- { handle yaml_char_t* }
+ { handle c-string }
{ handle_length size_t }
- { suffix yaml_char_t* }
+ { suffix c-string }
{ suffix_length size_t }
;
! /** Scalar analysis. */
STRUCT: yaml_emitter_scalar_data
- { value yaml_char_t* }
+ { value c-string }
{ length size_t }
{ multiline int }
{ flow_plain_allowed int }
: yaml-assert-ok ( n -- ) 0 = [ "yaml error" throw ] when ;
: event>scalar ( event -- obj )
- data>> scalar>> [ value>> ] [ length>> ] bi
- memory>byte-array utf8 decode ;
+ data>> scalar>> value>> ;
: ?scalar-value ( event -- scalar/f f/type )
dup type>> YAML_SCALAR_EVENT =
GENERIC: emit-value ( emitter event obj -- )
M:: string emit-value ( emitter event string -- )
- [
- string utf8 encode
- [ malloc-byte-array &free ] [ length ] bi :> ( value length )
-
- YAML_STR_TAG utf8 malloc-string &free :> tag
-
- event f tag value length 0 0 0
- yaml_scalar_event_initialize yaml-assert-ok
-
- emitter event yaml_emitter_emit yaml-assert-ok
- ] with-destructors ;
+ event f YAML_STR_TAG string -1 0 0 0
+ yaml_scalar_event_initialize yaml-assert-ok
+ emitter event yaml_emitter_emit yaml-assert-ok ;
:: emit-sequence-start ( emitter event -- )
- [
- YAML_SEQ_TAG utf8 malloc-string &free :> tag
-
- event f tag 0 0
- yaml_sequence_start_event_initialize yaml-assert-ok
-
- emitter event yaml_emitter_emit yaml-assert-ok
- ] with-destructors ;
+ event f YAML_SEQ_TAG 0 0
+ yaml_sequence_start_event_initialize yaml-assert-ok
+ emitter event yaml_emitter_emit yaml-assert-ok ;
: emit-sequence-end ( emitter event -- )
dup yaml_sequence_end_event_initialize yaml-assert-ok
yaml_emitter_emit yaml-assert-ok ;
[ drop emit-sequence-end ] 3tri ;
:: emit-assoc-start ( emitter event -- )
- [
- YAML_MAP_TAG utf8 malloc-string &free :> tag
-
- event f tag 0 0
- yaml_mapping_start_event_initialize yaml-assert-ok
-
- emitter event yaml_emitter_emit yaml-assert-ok
- ] with-destructors ;
+ event f YAML_MAP_TAG 0 0
+ yaml_mapping_start_event_initialize yaml-assert-ok
+ emitter event yaml_emitter_emit yaml-assert-ok ;
: emit-assoc-end ( emitter event -- )
dup yaml_mapping_end_event_initialize yaml-assert-ok
yaml_emitter_emit yaml-assert-ok ;