|
|
@@ -80,14 +80,13 @@ func yaml_parser_set_encoding(parser *yaml_parser_t, encoding yaml_encoding_t) {
|
|
|
}
|
|
|
|
|
|
// Create a new emitter object.
|
|
|
-func yaml_emitter_initialize(emitter *yaml_emitter_t) bool {
|
|
|
+func yaml_emitter_initialize(emitter *yaml_emitter_t) {
|
|
|
*emitter = yaml_emitter_t{
|
|
|
buffer: make([]byte, output_buffer_size),
|
|
|
raw_buffer: make([]byte, 0, output_raw_buffer_size),
|
|
|
states: make([]yaml_emitter_state_t, 0, initial_stack_size),
|
|
|
events: make([]yaml_event_t, 0, initial_queue_size),
|
|
|
}
|
|
|
- return true
|
|
|
}
|
|
|
|
|
|
// Destroy an emitter object.
|
|
|
@@ -101,9 +100,10 @@ func yaml_string_write_handler(emitter *yaml_emitter_t, buffer []byte) error {
|
|
|
return nil
|
|
|
}
|
|
|
|
|
|
-// File write handler.
|
|
|
-func yaml_file_write_handler(emitter *yaml_emitter_t, buffer []byte) error {
|
|
|
- _, err := emitter.output_file.Write(buffer)
|
|
|
+// yaml_writer_write_handler uses emitter.output_writer to write the
|
|
|
+// emitted text.
|
|
|
+func yaml_writer_write_handler(emitter *yaml_emitter_t, buffer []byte) error {
|
|
|
+ _, err := emitter.output_writer.Write(buffer)
|
|
|
return err
|
|
|
}
|
|
|
|
|
|
@@ -117,12 +117,12 @@ func yaml_emitter_set_output_string(emitter *yaml_emitter_t, output_buffer *[]by
|
|
|
}
|
|
|
|
|
|
// Set a file output.
|
|
|
-func yaml_emitter_set_output_file(emitter *yaml_emitter_t, file io.Writer) {
|
|
|
+func yaml_emitter_set_output_writer(emitter *yaml_emitter_t, w io.Writer) {
|
|
|
if emitter.write_handler != nil {
|
|
|
panic("must set the output target only once")
|
|
|
}
|
|
|
- emitter.write_handler = yaml_file_write_handler
|
|
|
- emitter.output_file = file
|
|
|
+ emitter.write_handler = yaml_writer_write_handler
|
|
|
+ emitter.output_writer = w
|
|
|
}
|
|
|
|
|
|
// Set the output encoding.
|
|
|
@@ -251,41 +251,41 @@ func yaml_emitter_set_break(emitter *yaml_emitter_t, line_break yaml_break_t) {
|
|
|
//
|
|
|
|
|
|
// Create STREAM-START.
|
|
|
-func yaml_stream_start_event_initialize(event *yaml_event_t, encoding yaml_encoding_t) bool {
|
|
|
+func yaml_stream_start_event_initialize(event *yaml_event_t, encoding yaml_encoding_t) {
|
|
|
*event = yaml_event_t{
|
|
|
typ: yaml_STREAM_START_EVENT,
|
|
|
encoding: encoding,
|
|
|
}
|
|
|
- return true
|
|
|
}
|
|
|
|
|
|
// Create STREAM-END.
|
|
|
-func yaml_stream_end_event_initialize(event *yaml_event_t) bool {
|
|
|
+func yaml_stream_end_event_initialize(event *yaml_event_t) {
|
|
|
*event = yaml_event_t{
|
|
|
typ: yaml_STREAM_END_EVENT,
|
|
|
}
|
|
|
- return true
|
|
|
}
|
|
|
|
|
|
// Create DOCUMENT-START.
|
|
|
-func yaml_document_start_event_initialize(event *yaml_event_t, version_directive *yaml_version_directive_t,
|
|
|
- tag_directives []yaml_tag_directive_t, implicit bool) bool {
|
|
|
+func yaml_document_start_event_initialize(
|
|
|
+ event *yaml_event_t,
|
|
|
+ version_directive *yaml_version_directive_t,
|
|
|
+ tag_directives []yaml_tag_directive_t,
|
|
|
+ implicit bool,
|
|
|
+) {
|
|
|
*event = yaml_event_t{
|
|
|
typ: yaml_DOCUMENT_START_EVENT,
|
|
|
version_directive: version_directive,
|
|
|
tag_directives: tag_directives,
|
|
|
implicit: implicit,
|
|
|
}
|
|
|
- return true
|
|
|
}
|
|
|
|
|
|
// Create DOCUMENT-END.
|
|
|
-func yaml_document_end_event_initialize(event *yaml_event_t, implicit bool) bool {
|
|
|
+func yaml_document_end_event_initialize(event *yaml_event_t, implicit bool) {
|
|
|
*event = yaml_event_t{
|
|
|
typ: yaml_DOCUMENT_END_EVENT,
|
|
|
implicit: implicit,
|
|
|
}
|
|
|
- return true
|
|
|
}
|
|
|
|
|
|
///*
|
|
|
@@ -347,7 +347,7 @@ func yaml_sequence_end_event_initialize(event *yaml_event_t) bool {
|
|
|
}
|
|
|
|
|
|
// Create MAPPING-START.
|
|
|
-func yaml_mapping_start_event_initialize(event *yaml_event_t, anchor, tag []byte, implicit bool, style yaml_mapping_style_t) bool {
|
|
|
+func yaml_mapping_start_event_initialize(event *yaml_event_t, anchor, tag []byte, implicit bool, style yaml_mapping_style_t) {
|
|
|
*event = yaml_event_t{
|
|
|
typ: yaml_MAPPING_START_EVENT,
|
|
|
anchor: anchor,
|
|
|
@@ -355,15 +355,13 @@ func yaml_mapping_start_event_initialize(event *yaml_event_t, anchor, tag []byte
|
|
|
implicit: implicit,
|
|
|
style: yaml_style_t(style),
|
|
|
}
|
|
|
- return true
|
|
|
}
|
|
|
|
|
|
// Create MAPPING-END.
|
|
|
-func yaml_mapping_end_event_initialize(event *yaml_event_t) bool {
|
|
|
+func yaml_mapping_end_event_initialize(event *yaml_event_t) {
|
|
|
*event = yaml_event_t{
|
|
|
typ: yaml_MAPPING_END_EVENT,
|
|
|
}
|
|
|
- return true
|
|
|
}
|
|
|
|
|
|
// Destroy an event object.
|