adayaml_0.3.0_ab19e387/dropin/src/yaml-c.ads

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
--  part of AdaYaml, (c) 2017 Felix Krause
--  released under the terms of the MIT license, see the file "copying.txt"

with System;
with Interfaces.C.Strings;
private with Yaml.Parser;
private with Yaml.Presenter;

package Yaml.C is
   --  this is an implementation of libyaml's C interface declared in yaml.h

   function Get_Version_String return Interfaces.C.Strings.chars_ptr
     with Export, Convention => C, External_Name => "yaml_get_version_string";

   procedure Get_Version (Major, Minor, Patch : out Interfaces.C.int)
     with Export, Convention => C, External_Name => "yaml_get_version";

   type Encoding_Type is
     (Any, UTF8, UTF16LE, UTF16BE) with Convention => C;

   type Bool is new Boolean with Convention => C;
   for Bool'Size use Interfaces.C.int'Size;

   type Error_Type is
     (No_Error, Memory_Error, Reader_Error, Scanner_Error, Parser_Error,
      Composer_Error, Writer_Error, Emitter_Error) with Convention => C;

   procedure Token_Delete (Token : System.Address) with Export,
     Convention => C, External_Name => "yaml_token_delete";

   type Event_Type is
     (No_Event, Stream_Start, Stream_End, Document_Start, Document_End,
      Alias, Scalar, Sequence_Start, Sequence_End, Mapping_Start,
      Mapping_End, Annotation_Start, Annotation_End) with Convention => C;

   type Event_Data (T : Event_Type := No_Event) is record
      case T is
         when Stream_Start =>
            Encoding : Encoding_Type;
         when Document_Start =>
            --  TODO: make available from parser
            Version_Directive, Start_Dir, End_Dir : System.Address;
            DS_Implicit : Bool;
         when Document_End =>
            DE_Implicit : Bool;
         when Alias =>
            Ali_Anchor : Text.Exported;
         when Scalar =>
            Scalar_Anchor, Scalar_Tag, Value : Text.Exported;
            Length : Interfaces.C.size_t;
            Plain_Implicit, Quoted_Implicit : Bool;
            Scalar_Style : Scalar_Style_Type;
         when Sequence_Start =>
            Seq_Anchor, Seq_Tag : Text.Exported;
            Seq_Implicit : Bool;
            Seq_Style : Collection_Style_Type;
         when Mapping_Start =>
            Map_Anchor, Map_Tag : Text.Exported;
            Map_Implicit : Bool;
            Map_Style : Collection_Style_Type;
         when Annotation_Start =>
            Ann_Anchor, Ann_Tag : Text.Exported;
            Ann_Name : Text.Exported;
         when others => null;
      end case;
   end record with Unchecked_Union, Convention => C;

   type C_Mark is record
      Index, Line, Column : Interfaces.C.size_t;
   end record;

   type Event is record
      Kind : Event_Type;
      Data : Event_Data;
      Start_Mark, End_Mark : C_Mark;
   end record with Convention => C;

   type Event_Access is access Event with Convention => C;

   type Read_Handler is access function (Data, Buffer : System.Address;
                                         Size : Interfaces.C.size_t;
                                         Size_Read : out Interfaces.C.size_t)
                                         return Bool with Convention => C;

   type Write_Handler is access function (Data, Buffer : System.Address;
                                          Size : Interfaces.C.size_t)
                                          return Bool with Convention => C;

   function Stream_Start_Event_Initialize (E : out Event;
                                           Encoding : Encoding_Type) return Bool
      with Export, Convention => C,
     External_Name => "yaml_stream_start_event_initialize";

   function Stream_End_Event_Initialize (E : out Event) return Bool with Export,
     Convention => C, External_Name => "yaml_stream_end_event_initialize";

   function Document_Start_Event_Initialize
     (E : out Event; Version_Directive, Tag_Directive_Start, Tag_Directive_End :
      System.Address; Implicit : Bool) return Bool with Export, Convention => C,
     External_Name => "yaml_document_start_event_initialize";

   function Document_End_Event_Initialize
     (E : out Event; Implicit : Bool) return Bool with Export, Convention => C,
     External_Name => "yaml_document_end_event_initialize";

   function Alias_Event_Initialize
     (E : out Event; Anchor : Interfaces.C.Strings.chars_ptr) return Bool with
     Export, Convention => C, External_Name => "yaml_alias_event_initialize";

   function Scalar_Event_Initialize
     (E : out Event; Anchor, Tag, Value : Interfaces.C.Strings.chars_ptr;
      Plain_Implicit, Quoted_Implicit : Bool; Style : Scalar_Style_Type)
      return Bool with Export, Convention => C,
     External_Name => "yaml_scalar_event_initialize";

   function Sequence_Start_Event_Initialize
     (E : out Event; Anchor, Tag : Interfaces.C.Strings.chars_ptr;
      Implicit : Bool; Style : Collection_Style_Type) return Bool with
     Export, Convention => C,
     External_Name => "yaml_sequence_start_event_initialize";

   function Sequence_End_Event_Initialize
     (E : out Event) return Bool with Export, Convention => C,
     External_Name => "yaml_sequence_end_event_initialize";

   function Mapping_Start_Event_Initialize
     (E : out Event; Anchor, Tag : Interfaces.C.Strings.chars_ptr;
      Implicit : Bool; Style : Collection_Style_Type) return Bool with
     Export, Convention => C,
     External_Name => "yaml_mapping_start_event_initialize";

   function Mapping_End_Event_Initialize
     (E : out Event) return Bool with Export, Convention => C,
     External_Name => "yaml_mapping_end_event_initialize";

   procedure Event_Delete (E : in out Event) with Export, Convention => C,
     External_Name => "yaml_event_delete";

   function Document_Initialize (Document, Version_Directive,
                                 Tag_Directives_Start, Tag_Directives_End :
                                 System.Address; Start_Implicit, End_Implicit :
                                 Bool) return Bool with Export, Convention => C,
     External_Name => "yaml_document_initialize";

   procedure Document_Delete (Document : System.Address) with Export,
     Convention => C, External_Name => "yaml_document_delete";

   function Document_Get_Node (Document : System.Address;
                               Index : Interfaces.C.int) return System.Address
     with Export, Convention => C, External_Name => "yaml_document_get_node";

   function Document_Get_Root_Node (Document : System.Address)
                                    return System.Address with Export,
     Convention => C, External_Name => "yaml_document_get_root_node";

   function Document_Add_Scalar (Document : System.Address;
                                 Tag, Value : Interfaces.C.Strings.chars_ptr;
                                 Length : Interfaces.C.int;
                                 Style : Scalar_Style_Type) return Bool
     with Export, Convention => C, External_Name => "yaml_document_add_scalar";

   function Document_Add_Sequence (Document : System.Address;
                                   Tag : Interfaces.C.Strings.chars_ptr;
                                   Style : Collection_Style_Type) return Bool
     with Export, Convention => C,
     External_Name => "yaml_document_add_sequence";

   function Document_Add_Mapping (Document : System.Address;
                                  Tag : Interfaces.C.Strings.chars_ptr;
                                  Style : Collection_Style_Type) return Bool
     with Export, Convention => C, External_Name => "yaml_document_add_mapping";

   function Document_Append_Sequence_Item (Document : System.Address;
                                           Sequence, Item : Interfaces.C.int)
                                           return Bool with Export,
     Convention => C, External_Name => "yaml_document_append_sequence_item";

   function Document_Append_Mapping_Pair
     (Document : System.Address; Mapping, Key, Value : Interfaces.C.int)
      return Bool with Export, Convention => C,
     External_Name => "yaml_document_append_mapping_pair";

   type Parser_Type is limited private;

   function Parser_Initialize (P : in out Parser_Type) return Bool with Export,
     Convention => C, External_Name => "yaml_parser_initialize";

   procedure Parser_Delete (P : in out Parser_Type) with Export,
     Convention => C, External_Name => "yaml_parser_delete";

   procedure Parser_Set_Input_String (P : in out Parser_Type;
                                      Input : Interfaces.C.Strings.chars_ptr;
                                      Size : Interfaces.C.size_t) with Export,
     Convention => C, External_Name => "yaml_parser_set_input_string";

   procedure Parser_Set_Input_File (P : in out Parser_Type;
                                    File : System.Address) with Export,
     Convention => C, External_Name => "yaml_parser_set_input_file";

   procedure Parser_Set_Input (P : in out Parser_Type;
                               Handler : Read_Handler; Data : System.Address)
     with Export, Convention => C, External_Name => "yaml_parser_set_input";

   procedure Parser_Set_Encoding (P : in out Parser_Type;
                                  Encoding : Encoding_Type) with Export,
     Convention => C, External_Name => "yaml_parser_set_encoding";

   function Parser_Scan (P : in out Parser_Type; Token : System.Address)
                         return Bool with Export, Convention => C,
     External_Name => "yaml_parser_scan";

   function Parser_Parse (P : in out Parser_Type; E : out Event) return Bool
     with Export, Convention => C, External_Name => "yaml_parser_parse";

   function Parser_Load (P : in out Parser_Type; Document : System.Address)
                         return Bool with Export, Convention => C,
     External_Name => "yaml_parser_load";

   type Emitter_Type is limited private;

   function Emitter_Initialize (Emitter : in out Emitter_Type)
                                return Bool with Export, Convention => C,
     External_Name => "yaml_emitter_initialize";

   procedure Emitter_Delete (Emitter : in out Emitter_Type) with Export,
     Convention => C, External_Name => "yaml_emitter_delete";

   procedure Emitter_Set_Output_String
     (Emitter : in out Emitter_Type; Output : System.Address;
      Size : Interfaces.C.size_t; Size_Written : access Interfaces.C.size_t)
     with Export, Convention => C,
     External_Name => "yaml_emitter_set_output_string";

   procedure Emitter_Set_Output_File
     (Emitter : in out Emitter_Type; File : System.Address) with Export,
     Convention => C, External_Name => "yaml_emitter_set_output_file";

   procedure Emitter_Set_Output
     (Emitter : in out Emitter_Type; Handler : Write_Handler;
      Data : System.Address) with Export, Convention => C,
     External_Name => "yaml_emitter_set_output";

   function Emitter_Emit (Emitter : in out Emitter_Type; E : in out Event)
                          return Bool with Export, Convention => C,
     External_Name => "yaml_emitter_emit";
private
   type Parser_Pointer is access Parser.Instance;

   type Parser_Type is limited record
      Error : Error_Type;
      Problem : Interfaces.C.Strings.chars_ptr;
      Ptr : Parser_Pointer;
   end record with Convention => C;

   type Presenter_Pointer is access Presenter.Instance;

   type Emitter_Type is limited record
      Error : Error_Type;
      Problem : Interfaces.C.Strings.chars_ptr;
      Ptr : Presenter_Pointer;
   end record with Convention => C;
end Yaml.C;