blob: b490a5998e5c2d39c3fa02ac53ddb71670d9af0c [file] [log] [blame]
The Android Open Source Project9066cfe2009-03-03 19:31:44 -08001#ifndef DEVICE_TOOLS_AIDL_AIDL_LANGUAGE_H
2#define DEVICE_TOOLS_AIDL_AIDL_LANGUAGE_H
3
4
5typedef enum {
6 NO_EXTRA_TEXT = 0,
7 SHORT_COMMENT,
8 LONG_COMMENT,
9 COPY_TEXT,
10 WHITESPACE
11} which_extra_text;
12
13typedef struct extra_text_type {
14 unsigned lineno;
15 which_extra_text which;
16 char* data;
17 unsigned len;
18 struct extra_text_type* next;
19} extra_text_type;
20
21typedef struct buffer_type {
22 unsigned lineno;
23 unsigned token;
24 char *data;
25 extra_text_type* extra;
26} buffer_type;
27
28typedef struct type_type {
29 buffer_type type;
30 buffer_type array_token;
31 int dimension;
32} type_type;
33
34typedef struct arg_type {
35 buffer_type comma_token; // empty in the first one in the list
36 buffer_type direction;
37 type_type type;
38 buffer_type name;
39 struct arg_type *next;
40} arg_type;
41
42enum {
43 METHOD_TYPE
44};
45
46typedef struct interface_item_type {
47 unsigned item_type;
48 struct interface_item_type* next;
49} interface_item_type;
50
51typedef struct method_type {
52 interface_item_type interface_item;
53 type_type type;
54 bool oneway;
55 buffer_type oneway_token;
56 buffer_type name;
57 buffer_type open_paren_token;
58 arg_type* args;
59 buffer_type close_paren_token;
60 // XXX missing comments/copy text here
61 buffer_type semicolon_token;
62 buffer_type* comments_token; // points into this structure, DO NOT DELETE
63} method_type;
64
65enum {
66 PARCELABLE_TYPE = 12,
Joe Onorato0ca2a36d2011-09-15 21:31:15 -070067 FLATTENABLE_TYPE,
Joe Onorato7add83b2011-08-30 17:24:17 -070068 INTERFACE_TYPE_BINDER,
69 INTERFACE_TYPE_RPC
The Android Open Source Project9066cfe2009-03-03 19:31:44 -080070};
71
72typedef struct document_item_type {
73 unsigned item_type;
74 struct document_item_type* next;
75} document_item_type;
76
77typedef struct parcelable_type {
78 document_item_type document_item;
79 buffer_type parcelable_token;
80 char* package;
81 buffer_type name;
82 buffer_type semicolon_token;
83} parcelable_type;
84
85typedef struct interface_type {
86 document_item_type document_item;
87 buffer_type interface_token;
88 bool oneway;
89 buffer_type oneway_token;
90 char* package;
91 buffer_type name;
92 buffer_type open_brace_token;
93 interface_item_type* interface_items;
94 buffer_type close_brace_token;
95 buffer_type* comments_token; // points into this structure, DO NOT DELETE
96} interface_type;
97
98typedef union lexer_type {
99 buffer_type buffer;
100 type_type type;
101 arg_type *arg;
102 method_type* method;
103 interface_item_type* interface_item;
104 interface_type* interface_obj;
105 parcelable_type* parcelable;
106 document_item_type* document_item;
107} lexer_type;
108
109
110#define YYSTYPE lexer_type
111
112#if __cplusplus
113extern "C" {
114#endif
115
116int parse_aidl(char const *);
117
118// strips off the leading whitespace, the "import" text
119// also returns whether it's a local or system import
120// we rely on the input matching the import regex from below
121char* parse_import_statement(const char* text);
122
123// in, out or inout
124enum {
125 IN_PARAMETER = 1,
126 OUT_PARAMETER = 2,
127 INOUT_PARAMETER = 3
128};
129int convert_direction(const char* direction);
130
131// callbacks from within the parser
132// these functions all take ownership of the strings
133typedef struct ParserCallbacks {
134 void (*document)(document_item_type* items);
135 void (*import)(buffer_type* statement);
136} ParserCallbacks;
137
138extern ParserCallbacks* g_callbacks;
139
140// true if there was an error parsing, false otherwise
141extern int g_error;
142
143// the name of the file we're currently parsing
144extern char const* g_currentFilename;
145
146// the package name for our current file
147extern char const* g_currentPackage;
148
149typedef enum {
150 STATEMENT_INSIDE_INTERFACE
151} error_type;
152
153void init_buffer_type(buffer_type* buf, int lineno);
154
155
156#if __cplusplus
157}
158#endif
159
160
161#endif // DEVICE_TOOLS_AIDL_AIDL_LANGUAGE_H