openglada_0.9.0_4deb7eff/src/generator/specs.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
--  part of OpenGLAda, (c) 2017 Felix Krause
--  released under the terms of the MIT license, see the file "COPYING"

private with Ada.Containers.Vectors;
private with Ada.Containers.Indefinite_Vectors;
private with Ada.Strings.Unbounded;

package Specs is
   -- This package implements parsing and applying .spec files.
   -- These are used to easily generate parts of the low-level OpenGL
   -- binding code. This package is not part of the OpenGLAda API nor
   -- implementation - it is only used for generating part of its
   -- source code.

   type Processor is limited private;
   type Spec is private;

   No_Spec : constant Spec;
   Parsing_Error : exception;

   procedure Parse_File (Proc : in out Processor; Path : String);

   function First (Proc : Processor) return Spec;

   function Next (Proc : Processor; Cur : Spec) return Spec;

   procedure Write_API (Proc : Processor; Cur : Spec;
                        Dir_Path : String);

   procedure Write_Init (Proc : Processor; Dir_Path : String);

   procedure Write_Wrapper_Table (Proc : Processor;
                                  Dir_Path, Interface_Folder : String);
private
   use Ada.Strings.Unbounded;

   type Param_Mode is
     (Mode_In, Mode_Out, Mode_In_Out, Mode_Access, Mode_Access_Constant);

   package String_Lists is new Ada.Containers.Indefinite_Vectors
     (Positive, String);

   type Parameter is record
      Mode : Param_Mode;
      Names : String_Lists.Vector;
      Type_Name : Unbounded_String;
   end record;

   package Param_Lists is new Ada.Containers.Vectors
      (Positive, Parameter);

   type Signature is record
      Params : Param_Lists.Vector;
      Return_Type : Unbounded_String;
   end record;

   package Sig_Lists is new Ada.Containers.Vectors (Positive, Signature);

   type Body_Item_Kind is (Copy, Static, Dynamic);

   type Body_Item (Kind : Body_Item_Kind) is record
      case Kind is
      when Copy => To_Copy : Unbounded_String;
      when Static =>
         S_Name, S_GL_Name : Unbounded_String;
         Sigs : Sig_Lists.Vector;
      when Dynamic =>
         D_Name, D_GL_Name : Unbounded_String;
         Sig_Id : Positive;
      end case;
   end record;

   package Item_Lists is
     new Ada.Containers.Indefinite_Vectors (Positive, Body_Item);

   package Wrapper_Lists is new Ada.Containers.Indefinite_Vectors
     (Positive, String_Lists.Vector, String_Lists."=");

   type Spec_Data is record
      Name, File_Base_Name : Unbounded_String;
      Withs : String_Lists.Vector;
      Uses  : String_Lists.Vector;
      Items : Item_Lists.Vector;
      Wrappers : Wrapper_Lists.Vector;
   end record;

   type Spec is new Natural;
   subtype Valid_Spec is Spec range 1 .. Spec'Last;

   No_Spec : constant Spec := 0;

   package Spec_Lists is new Ada.Containers.Vectors (Valid_Spec, Spec_Data);

   type Processor is record
      Dynamic_Subprogram_Types : Sig_Lists.Vector;
      List : Spec_Lists.Vector;
   end record;
end Specs;