• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1
2cdef extern from "_yaml.h":
3
4    void malloc(int l)
5    void memcpy(void *d, void *s, int l)
6    int strlen(char *s)
7    int PyString_CheckExact(object o)
8    int PyUnicode_CheckExact(object o)
9    char *PyString_AS_STRING(object o)
10    object PyUnicode_FromString(char *u)
11    object PyUnicode_DecodeUTF8(char *u, int s, char *e)
12    object PyUnicode_AsUTF8String(object o)
13    int PY_MAJOR_VERSION
14
15    ctypedef unsigned char yaml_char_t
16
17    object PyUnicode_FromYamlString(void *u)
18    yaml_char_t *PyBytes_AS_Yaml_STRING(object o)
19    const char *PyBytes_AS_STRING(object o)
20    int PyBytes_CheckExact(object o)
21    int PyBytes_GET_SIZE(object o)
22    object PyBytes_FromStringAndSize(char *v, int l)
23
24    ctypedef enum:
25        SIZEOF_VOID_P
26    ctypedef enum yaml_encoding_t:
27        YAML_ANY_ENCODING
28        YAML_UTF8_ENCODING
29        YAML_UTF16LE_ENCODING
30        YAML_UTF16BE_ENCODING
31    ctypedef enum yaml_break_t:
32        YAML_ANY_BREAK
33        YAML_CR_BREAK
34        YAML_LN_BREAK
35        YAML_CRLN_BREAK
36    ctypedef enum yaml_error_type_t:
37        YAML_NO_ERROR
38        YAML_MEMORY_ERROR
39        YAML_READER_ERROR
40        YAML_SCANNER_ERROR
41        YAML_PARSER_ERROR
42        YAML_WRITER_ERROR
43        YAML_EMITTER_ERROR
44    ctypedef enum yaml_scalar_style_t:
45        YAML_ANY_SCALAR_STYLE
46        YAML_PLAIN_SCALAR_STYLE
47        YAML_SINGLE_QUOTED_SCALAR_STYLE
48        YAML_DOUBLE_QUOTED_SCALAR_STYLE
49        YAML_LITERAL_SCALAR_STYLE
50        YAML_FOLDED_SCALAR_STYLE
51    ctypedef enum yaml_sequence_style_t:
52        YAML_ANY_SEQUENCE_STYLE
53        YAML_BLOCK_SEQUENCE_STYLE
54        YAML_FLOW_SEQUENCE_STYLE
55    ctypedef enum yaml_mapping_style_t:
56        YAML_ANY_MAPPING_STYLE
57        YAML_BLOCK_MAPPING_STYLE
58        YAML_FLOW_MAPPING_STYLE
59    ctypedef enum yaml_token_type_t:
60        YAML_NO_TOKEN
61        YAML_STREAM_START_TOKEN
62        YAML_STREAM_END_TOKEN
63        YAML_VERSION_DIRECTIVE_TOKEN
64        YAML_TAG_DIRECTIVE_TOKEN
65        YAML_DOCUMENT_START_TOKEN
66        YAML_DOCUMENT_END_TOKEN
67        YAML_BLOCK_SEQUENCE_START_TOKEN
68        YAML_BLOCK_MAPPING_START_TOKEN
69        YAML_BLOCK_END_TOKEN
70        YAML_FLOW_SEQUENCE_START_TOKEN
71        YAML_FLOW_SEQUENCE_END_TOKEN
72        YAML_FLOW_MAPPING_START_TOKEN
73        YAML_FLOW_MAPPING_END_TOKEN
74        YAML_BLOCK_ENTRY_TOKEN
75        YAML_FLOW_ENTRY_TOKEN
76        YAML_KEY_TOKEN
77        YAML_VALUE_TOKEN
78        YAML_ALIAS_TOKEN
79        YAML_ANCHOR_TOKEN
80        YAML_TAG_TOKEN
81        YAML_SCALAR_TOKEN
82    ctypedef enum yaml_event_type_t:
83        YAML_NO_EVENT
84        YAML_STREAM_START_EVENT
85        YAML_STREAM_END_EVENT
86        YAML_DOCUMENT_START_EVENT
87        YAML_DOCUMENT_END_EVENT
88        YAML_ALIAS_EVENT
89        YAML_SCALAR_EVENT
90        YAML_SEQUENCE_START_EVENT
91        YAML_SEQUENCE_END_EVENT
92        YAML_MAPPING_START_EVENT
93        YAML_MAPPING_END_EVENT
94
95    ctypedef int yaml_read_handler_t(void *data, unsigned char *buffer,
96            size_t size, size_t *size_read) except 0
97
98    ctypedef int yaml_write_handler_t(void *data, unsigned char *buffer,
99            size_t size) except 0
100
101    ctypedef struct yaml_mark_t:
102        size_t index
103        size_t line
104        size_t column
105    ctypedef struct yaml_version_directive_t:
106        int major
107        int minor
108    ctypedef struct yaml_tag_directive_t:
109        yaml_char_t *handle
110        yaml_char_t *prefix
111
112    ctypedef struct _yaml_token_stream_start_data_t:
113        yaml_encoding_t encoding
114    ctypedef struct _yaml_token_alias_data_t:
115        char *value
116    ctypedef struct _yaml_token_anchor_data_t:
117        char *value
118    ctypedef struct _yaml_token_tag_data_t:
119        char *handle
120        char *suffix
121    ctypedef struct _yaml_token_scalar_data_t:
122        char *value
123        size_t length
124        yaml_scalar_style_t style
125    ctypedef struct _yaml_token_version_directive_data_t:
126        int major
127        int minor
128    ctypedef struct _yaml_token_tag_directive_data_t:
129        char *handle
130        char *prefix
131    ctypedef union _yaml_token_data_t:
132        _yaml_token_stream_start_data_t stream_start
133        _yaml_token_alias_data_t alias
134        _yaml_token_anchor_data_t anchor
135        _yaml_token_tag_data_t tag
136        _yaml_token_scalar_data_t scalar
137        _yaml_token_version_directive_data_t version_directive
138        _yaml_token_tag_directive_data_t tag_directive
139    ctypedef struct yaml_token_t:
140        yaml_token_type_t type
141        _yaml_token_data_t data
142        yaml_mark_t start_mark
143        yaml_mark_t end_mark
144
145    ctypedef struct _yaml_event_stream_start_data_t:
146        yaml_encoding_t encoding
147    ctypedef struct _yaml_event_document_start_data_tag_directives_t:
148        yaml_tag_directive_t *start
149        yaml_tag_directive_t *end
150    ctypedef struct _yaml_event_document_start_data_t:
151        yaml_version_directive_t *version_directive
152        _yaml_event_document_start_data_tag_directives_t tag_directives
153        int implicit
154    ctypedef struct _yaml_event_document_end_data_t:
155        int implicit
156    ctypedef struct _yaml_event_alias_data_t:
157        char *anchor
158    ctypedef struct _yaml_event_scalar_data_t:
159        char *anchor
160        char *tag
161        char *value
162        size_t length
163        int plain_implicit
164        int quoted_implicit
165        yaml_scalar_style_t style
166    ctypedef struct _yaml_event_sequence_start_data_t:
167        char *anchor
168        char *tag
169        int implicit
170        yaml_sequence_style_t style
171    ctypedef struct _yaml_event_mapping_start_data_t:
172        char *anchor
173        char *tag
174        int implicit
175        yaml_mapping_style_t style
176    ctypedef union _yaml_event_data_t:
177        _yaml_event_stream_start_data_t stream_start
178        _yaml_event_document_start_data_t document_start
179        _yaml_event_document_end_data_t document_end
180        _yaml_event_alias_data_t alias
181        _yaml_event_scalar_data_t scalar
182        _yaml_event_sequence_start_data_t sequence_start
183        _yaml_event_mapping_start_data_t mapping_start
184    ctypedef struct yaml_event_t:
185        yaml_event_type_t type
186        _yaml_event_data_t data
187        yaml_mark_t start_mark
188        yaml_mark_t end_mark
189
190    ctypedef struct yaml_parser_t:
191        yaml_error_type_t error
192        char *problem
193        size_t problem_offset
194        int problem_value
195        yaml_mark_t problem_mark
196        char *context
197        yaml_mark_t context_mark
198
199    ctypedef struct yaml_emitter_t:
200        yaml_error_type_t error
201        char *problem
202
203    char *yaml_get_version_string()
204    void yaml_get_version(int *major, int *minor, int *patch)
205
206    void yaml_token_delete(yaml_token_t *token)
207
208    int yaml_stream_start_event_initialize(yaml_event_t *event,
209            yaml_encoding_t encoding)
210    int yaml_stream_end_event_initialize(yaml_event_t *event)
211    int yaml_document_start_event_initialize(yaml_event_t *event,
212            yaml_version_directive_t *version_directive,
213            yaml_tag_directive_t *tag_directives_start,
214            yaml_tag_directive_t *tag_directives_end,
215            int implicit)
216    int yaml_document_end_event_initialize(yaml_event_t *event,
217            int implicit)
218    int yaml_alias_event_initialize(yaml_event_t *event, yaml_char_t *anchor)
219    int yaml_scalar_event_initialize(yaml_event_t *event,
220            yaml_char_t *anchor, yaml_char_t *tag, yaml_char_t *value, int length,
221            int plain_implicit, int quoted_implicit,
222            yaml_scalar_style_t style)
223    int yaml_sequence_start_event_initialize(yaml_event_t *event,
224            yaml_char_t *anchor, yaml_char_t *tag, int implicit, yaml_sequence_style_t style)
225    int yaml_sequence_end_event_initialize(yaml_event_t *event)
226    int yaml_mapping_start_event_initialize(yaml_event_t *event,
227            yaml_char_t *anchor, yaml_char_t *tag, int implicit, yaml_mapping_style_t style)
228    int yaml_mapping_end_event_initialize(yaml_event_t *event)
229    void yaml_event_delete(yaml_event_t *event)
230
231    int yaml_parser_initialize(yaml_parser_t *parser)
232    void yaml_parser_delete(yaml_parser_t *parser)
233    void yaml_parser_set_input_string(yaml_parser_t *parser,
234            const unsigned char *input, size_t size)
235    void yaml_parser_set_input(yaml_parser_t *parser,
236            yaml_read_handler_t *handler, void *data)
237    void yaml_parser_set_encoding(yaml_parser_t *parser,
238            yaml_encoding_t encoding)
239    int yaml_parser_scan(yaml_parser_t *parser, yaml_token_t *token) except *
240    int yaml_parser_parse(yaml_parser_t *parser, yaml_event_t *event) except *
241
242    int yaml_emitter_initialize(yaml_emitter_t *emitter)
243    void yaml_emitter_delete(yaml_emitter_t *emitter)
244    void yaml_emitter_set_output_string(yaml_emitter_t *emitter,
245            char *output, size_t size, size_t *size_written)
246    void yaml_emitter_set_output(yaml_emitter_t *emitter,
247            yaml_write_handler_t *handler, void *data)
248    void yaml_emitter_set_encoding(yaml_emitter_t *emitter,
249            yaml_encoding_t encoding)
250    void yaml_emitter_set_canonical(yaml_emitter_t *emitter, int canonical)
251    void yaml_emitter_set_indent(yaml_emitter_t *emitter, int indent)
252    void yaml_emitter_set_width(yaml_emitter_t *emitter, int width)
253    void yaml_emitter_set_unicode(yaml_emitter_t *emitter, int unicode)
254    void yaml_emitter_set_break(yaml_emitter_t *emitter,
255            yaml_break_t line_break)
256    int yaml_emitter_emit(yaml_emitter_t *emitter, yaml_event_t *event) except *
257    int yaml_emitter_flush(yaml_emitter_t *emitter)
258
259