_yaml.pxd 9.3 KB

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