1
+ syntax = "proto3" ;
2
+
3
+ package org.scalanative.bindgen ;
4
+
5
+ option optimize_for = LITE_RUNTIME ;
6
+
7
+ message IR {
8
+ repeated EnumType enums = 1 ;
9
+ repeated StructType structs = 2 ;
10
+ repeated UnionType unions = 3 ;
11
+ repeated TypedefType typedefs = 4 ;
12
+ repeated Decl.FunctionDecl functions = 5 ;
13
+ repeated Decl.VariableDecl variables = 6 ;
14
+ //std::vector<std::shared_ptr<LiteralDefine>> literalDefines;
15
+ //std::vector<std::shared_ptr<PossibleVarDefine>> possibleVarDefines;
16
+ //std::vector<std::shared_ptr<VarDefine>> varDefines;
17
+ }
18
+
19
+ message Range {
20
+ int32 start_line = 1 ;
21
+ int32 start_character = 2 ;
22
+ int32 end_line = 3 ;
23
+ int32 end_character = 4 ;
24
+ }
25
+
26
+ message Location {
27
+ string uri = 1 ;
28
+ Range range = 2 ;
29
+ }
30
+
31
+ message Type {
32
+ /*
33
+ enum Kind {
34
+ UNKNOWN = 0;
35
+ PRIMITIVE = 1;
36
+ ENUM = 2;
37
+ POINTER = 3;
38
+ ARRAY = 4;
39
+ FUNCTION_POINTER = 5;
40
+ UNION = 6;
41
+ STRUCT = 7;
42
+ TYPEDEF = 8;
43
+ }
44
+ */
45
+
46
+ //Kind kind = 1; // FIXME: remove?
47
+ Location location = 2 ;
48
+
49
+ oneof kind {
50
+ PrimitiveType primitiveType = 3 ;
51
+ EnumType enumType = 4 ;
52
+ PointerType pointerType = 5 ;
53
+ ArrayType arrayType = 6 ;
54
+ FunctionPointerType functionPointerType = 7 ;
55
+ UnionType unionType = 8 ;
56
+ StructType structType = 9 ;
57
+ TypedefType typedefType = 10 ;
58
+ }
59
+ }
60
+
61
+ message PrimitiveType {
62
+ enum Modifier {
63
+ NONE = 0 ;
64
+ CONST = 0x1 ;
65
+ }
66
+
67
+ string type = 1 ;
68
+ uint64 modifiers = 2 ;
69
+ }
70
+
71
+ message EnumType {
72
+ message Enumerator {
73
+ string name = 1 ;
74
+ // Have both int64 and uint64?
75
+ int64 value = 2 ;
76
+ }
77
+
78
+ string name = 1 ;
79
+ repeated Enumerator enumerators = 2 ;
80
+ }
81
+
82
+ message PointerType {
83
+ Type type = 1 ;
84
+ }
85
+
86
+ message ArrayType {
87
+ Type type = 1 ;
88
+ uint64 size = 2 ;
89
+ }
90
+
91
+ message FunctionPointerType {
92
+ // FIXME: Include parameter name in doc string?
93
+ Type returnType = 1 ;
94
+ repeated Type parameterTypes = 2 ;
95
+ bool isVariadic = 3 ;
96
+ }
97
+
98
+ message Field {
99
+ string name = 1 ;
100
+ Type type = 2 ;
101
+ }
102
+
103
+ message UnionType {
104
+ string name = 1 ;
105
+ repeated Field fields = 2 ;
106
+ uint64 size = 3 ;
107
+ }
108
+
109
+ message StructType {
110
+ // FIXME: packed attr
111
+ string name = 1 ;
112
+ repeated Field fields = 2 ;
113
+ uint64 size = 3 ;
114
+ }
115
+
116
+ message TypedefType {
117
+ string name = 1 ;
118
+ Type type = 2 ;
119
+ }
120
+
121
+ message Decl {
122
+ /*
123
+ enum Kind {
124
+ UNKNOWN = 0;
125
+ FUNCTION = 1;
126
+ VARIABLE = 2;
127
+ VARIABLE_DEFINE = 3;
128
+ LITERAL_DEFINE = 4;
129
+ }
130
+ */
131
+
132
+ //Kind kind = 1;
133
+ Location location = 2 ;
134
+
135
+ oneof kind {
136
+ FunctionDecl functionDecl = 11 ;
137
+ VariableDecl variableDecl = 12 ;
138
+ }
139
+
140
+ message FunctionDecl {
141
+ message Parameter {
142
+ string name = 1 ;
143
+ Type type = 2 ;
144
+ }
145
+
146
+ string name = 1 ;
147
+ Type returnType = 2 ;
148
+ repeated Parameter parameters = 3 ;
149
+ bool isVariadic = 4 ;
150
+ }
151
+
152
+ message VariableDecl {
153
+ enum Modifier {
154
+ NONE = 0 ;
155
+ VOLATILE = 1 ;
156
+ }
157
+
158
+ string name = 1 ;
159
+ Type type = 2 ;
160
+ repeated Modifier modifiers = 3 ;
161
+ }
162
+ }
0 commit comments