]>
Commit | Line | Data |
---|---|---|
1 | /* Cycript - Optimizing JavaScript Compiler/Runtime | |
2 | * Copyright (C) 2009-2013 Jay Freeman (saurik) | |
3 | */ | |
4 | ||
5 | /* GNU General Public License, Version 3 {{{ */ | |
6 | /* | |
7 | * Cycript is free software: you can redistribute it and/or modify | |
8 | * it under the terms of the GNU General Public License as published | |
9 | * by the Free Software Foundation, either version 3 of the License, | |
10 | * or (at your option) any later version. | |
11 | * | |
12 | * Cycript is distributed in the hope that it will be useful, but | |
13 | * WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 | * GNU General Public License for more details. | |
16 | * | |
17 | * You should have received a copy of the GNU General Public License | |
18 | * along with Cycript. If not, see <http://www.gnu.org/licenses/>. | |
19 | **/ | |
20 | /* }}} */ | |
21 | ||
22 | #ifndef SIG_TYPES_H | |
23 | #define SIG_TYPES_H | |
24 | ||
25 | #include <cstdlib> | |
26 | #include <stdint.h> | |
27 | ||
28 | #include "Standard.hpp" | |
29 | ||
30 | namespace sig { | |
31 | ||
32 | enum Primitive { | |
33 | typename_P = '#', | |
34 | union_P = '(', | |
35 | string_P = '*', | |
36 | selector_P = ':', | |
37 | block_P = '?', | |
38 | object_P = 'W', | |
39 | boolean_P = 'B', | |
40 | uchar_P = 'C', | |
41 | uint_P = 'I', | |
42 | ulong_P = 'L', | |
43 | ulonglong_P = 'Q', | |
44 | ushort_P = 'S', | |
45 | array_P = '[', | |
46 | pointer_P = '^', | |
47 | bit_P = 'b', | |
48 | char_P = 'c', | |
49 | double_P = 'd', | |
50 | float_P = 'f', | |
51 | int_P = 'i', | |
52 | long_P = 'l', | |
53 | longlong_P = 'q', | |
54 | short_P = 's', | |
55 | void_P = 'v', | |
56 | struct_P = '{' | |
57 | }; | |
58 | ||
59 | struct Element { | |
60 | const char *name; | |
61 | struct Type *type; | |
62 | size_t offset; | |
63 | }; | |
64 | ||
65 | struct Signature { | |
66 | struct Element *elements; | |
67 | size_t count; | |
68 | }; | |
69 | ||
70 | #define JOC_TYPE_INOUT (1 << 0) | |
71 | #define JOC_TYPE_IN (1 << 1) | |
72 | #define JOC_TYPE_BYCOPY (1 << 2) | |
73 | #define JOC_TYPE_OUT (1 << 3) | |
74 | #define JOC_TYPE_BYREF (1 << 4) | |
75 | #define JOC_TYPE_CONST (1 << 5) | |
76 | #define JOC_TYPE_ONEWAY (1 << 6) | |
77 | ||
78 | struct Type { | |
79 | enum Primitive primitive; | |
80 | const char *name; | |
81 | uint8_t flags; | |
82 | ||
83 | union { | |
84 | struct { | |
85 | struct Type *type; | |
86 | size_t size; | |
87 | } data; | |
88 | ||
89 | struct Signature signature; | |
90 | } data; | |
91 | }; | |
92 | ||
93 | struct Type *joc_parse_type(char **name, char eos, bool variable, bool signature); | |
94 | void joc_parse_signature(struct Signature *signature, char **name, char eos, bool variable); | |
95 | ||
96 | _finline bool IsAggregate(Primitive primitive) { | |
97 | return primitive == struct_P || primitive == union_P; | |
98 | } | |
99 | ||
100 | } | |
101 | ||
102 | #endif/*SIG_TYPES_H*/ |