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