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
|
#ifndef DEVICE_TOOLS_AIDL_AIDL_LANGUAGE_H
#define DEVICE_TOOLS_AIDL_AIDL_LANGUAGE_H
typedef enum {
NO_EXTRA_TEXT = 0,
SHORT_COMMENT,
LONG_COMMENT,
COPY_TEXT,
WHITESPACE
} which_extra_text;
typedef struct extra_text_type {
unsigned lineno;
which_extra_text which;
char* data;
unsigned len;
struct extra_text_type* next;
} extra_text_type;
typedef struct buffer_type {
unsigned lineno;
unsigned token;
char *data;
extra_text_type* extra;
} buffer_type;
typedef struct type_type {
buffer_type type;
buffer_type array_token;
int dimension;
} type_type;
typedef struct arg_type {
buffer_type comma_token; // empty in the first one in the list
buffer_type direction;
type_type type;
buffer_type name;
struct arg_type *next;
} arg_type;
enum {
METHOD_TYPE
};
typedef struct interface_item_type {
unsigned item_type;
struct interface_item_type* next;
} interface_item_type;
typedef struct method_type {
interface_item_type interface_item;
type_type type;
bool oneway;
buffer_type oneway_token;
buffer_type name;
buffer_type open_paren_token;
arg_type* args;
buffer_type close_paren_token;
bool hasId;
buffer_type equals_token;
buffer_type id;
// XXX missing comments/copy text here
buffer_type semicolon_token;
buffer_type* comments_token; // points into this structure, DO NOT DELETE
int assigned_id;
} method_type;
enum {
USER_DATA_TYPE = 12,
INTERFACE_TYPE_BINDER,
INTERFACE_TYPE_RPC
};
typedef struct document_item_type {
unsigned item_type;
struct document_item_type* next;
} document_item_type;
// for user_data_type.flattening_methods
enum {
PARCELABLE_DATA = 0x1,
RPC_DATA = 0x2
};
typedef struct user_data_type {
document_item_type document_item;
buffer_type keyword_token; // only the first one
char* package;
buffer_type name;
buffer_type semicolon_token;
int flattening_methods;
} user_data_type;
typedef struct interface_type {
document_item_type document_item;
buffer_type interface_token;
bool oneway;
buffer_type oneway_token;
char* package;
buffer_type name;
buffer_type open_brace_token;
interface_item_type* interface_items;
buffer_type close_brace_token;
buffer_type* comments_token; // points into this structure, DO NOT DELETE
} interface_type;
typedef union lexer_type {
buffer_type buffer;
type_type type;
arg_type *arg;
method_type* method;
interface_item_type* interface_item;
interface_type* interface_obj;
user_data_type* user_data;
document_item_type* document_item;
} lexer_type;
#define YYSTYPE lexer_type
#if __cplusplus
extern "C" {
#endif
int parse_aidl(char const *);
// strips off the leading whitespace, the "import" text
// also returns whether it's a local or system import
// we rely on the input matching the import regex from below
char* parse_import_statement(const char* text);
// in, out or inout
enum {
IN_PARAMETER = 1,
OUT_PARAMETER = 2,
INOUT_PARAMETER = 3
};
int convert_direction(const char* direction);
// callbacks from within the parser
// these functions all take ownership of the strings
typedef struct ParserCallbacks {
void (*document)(document_item_type* items);
void (*import)(buffer_type* statement);
} ParserCallbacks;
extern ParserCallbacks* g_callbacks;
// true if there was an error parsing, false otherwise
extern int g_error;
// the name of the file we're currently parsing
extern char const* g_currentFilename;
// the package name for our current file
extern char const* g_currentPackage;
typedef enum {
STATEMENT_INSIDE_INTERFACE
} error_type;
void init_buffer_type(buffer_type* buf, int lineno);
#if __cplusplus
}
#endif
#endif // DEVICE_TOOLS_AIDL_AIDL_LANGUAGE_H
|