Kirill Simonov avatar Kirill Simonov committed 35266ce

Tagged the 0.1.1 release (better later than never).

Comments (0)

Files changed (2)

 
 #include "yaml_private.h"
 
-#if 0
-
 /*
  * API functions.
  */
     yaml_event_t event;
     yaml_mark_t mark = { 0, 0, 0 };
 
-    assert(emitter);            /* Non-NULL emitter object is required. */
-    assert(!emitter->opened);   /* Emitter should not be opened yet. */
+    assert(emitter);                /* Non-NULL emitter object is required. */
+    assert(!emitter->is_opened);    /* Emitter should not be opened yet. */
 
     STREAM_START_EVENT_INIT(event, YAML_ANY_ENCODING, mark, mark);
 
         return 0;
     }
 
-    emitter->opened = 1;
+    emitter->is_opened = 1;
 
     return 1;
 }
     yaml_mark_t mark = { 0, 0, 0 };
 
     assert(emitter);            /* Non-NULL emitter object is required. */
-    assert(emitter->opened);    /* Emitter should be opened. */
+    assert(emitter->is_opened); /* Emitter should be opened. */
 
-    if (emitter->closed) return 1;
+    if (emitter->is_closed) return 1;
 
     STREAM_END_EVENT_INIT(event, mark, mark);
 
         return 0;
     }
 
-    emitter->closed = 1;
+    emitter->is_closed = 1;
 
     return 1;
 }
 
     emitter->document = document;
 
-    if (!emitter->opened) {
+    if (!emitter->is_opened) {
         if (!yaml_emitter_open(emitter)) goto error;
     }
 
-    if (STACK_EMPTY(emitter, document->nodes)) {
-        if (!yaml_emitter_close(emitter)) goto error;
-        yaml_emitter_delete_document_and_anchors(emitter);
-        return 1;
+    if (document->type == YAML_DOCUMENT)
+    {
+        assert(emitter->is_opened); /* Emitter should be opened. */
+
+        if (STACK_EMPTY(emitter, emitter->nodes)) {
+            SERIALIZER_ERROR_INIT(emitter, "root node is not specified");
+            goto error;
+        }
+
+        emitter->anchors = yaml_malloc(sizeof(*(emitter->anchors))
+                * (document->nodes.length));
+        if (!emitter->anchors) goto error;
+        memset(emitter->anchors, 0, sizeof(*(emitter->anchors))
+                * (document->nodes.length));
+
+        DOCUMENT_START_EVENT_INIT(event, document->version_directive,
+                document->tag_directives.list, document->tag_directives.length,
+                document->tag_directives.capacity,
+                document->start_implicit, mark, mark);
+        if (!yaml_emitter_emit(emitter, &event)) goto error;
+
+        yaml_emitter_anchor_node(emitter, 0);
+        if (!yaml_emitter_dump_node(emitter, 0)) goto error;
+
+        DOCUMENT_END_EVENT_INIT(event, document->end_implicit, mark, mark);
+        if (!yaml_emitter_emit(emitter, &event)) goto error;
     }
 
-    assert(emitter->opened);    /* Emitter should be opened. */
-
-    emitter->anchors = yaml_malloc(sizeof(*(emitter->anchors))
-            * (document->nodes.top - document->nodes.start));
-    if (!emitter->anchors) goto error;
-    memset(emitter->anchors, 0, sizeof(*(emitter->anchors))
-            * (document->nodes.top - document->nodes.start));
-
-    DOCUMENT_START_EVENT_INIT(event, document->version_directive,
-            document->tag_directives.start, document->tag_directives.end,
-            document->start_implicit, mark, mark);
-    if (!yaml_emitter_emit(emitter, &event)) goto error;
-
-    yaml_emitter_anchor_node(emitter, 1);
-    if (!yaml_emitter_dump_node(emitter, 1)) goto error;
-
-    DOCUMENT_END_EVENT_INIT(event, document->end_implicit, mark, mark);
-    if (!yaml_emitter_emit(emitter, &event)) goto error;
+    if (!document->type) {
+        if (!yaml_emitter_close(emitter)) goto error;
+    }
 
     yaml_emitter_delete_document_and_anchors(emitter);
 
  * Generate a textual representation for an anchor.
  */
 
-#define ANCHOR_TEMPLATE         "id%03d"
+#define ANCHOR_TEMPLATE         "_%03d"
 #define ANCHOR_TEMPLATE_LENGTH  16
 
 static yaml_char_t *
     return 1;
 }
 
-#endif
-

src/yaml_private.h

 } yaml_emitter_state_t;
 
 /*
+ * The information of a node being emitted.
+ */
+
+struct typedef yaml_node_data_s {
+    /* The node id. */
+    int id;
+    /* The collection iterator. */
+    int index;
+} yaml_node_data_t;
+
+/*
  * The structure that holds data used by the file and string readers.
  */
 
 } yaml_standard_writer_data_t;
 
 /*
- * The internals emitter structure.
+ * The internal emitter structure.
  */
 
 struct yaml_emitter_s {
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.