]> git.saurik.com Git - cycript.git/blame - sig/types.hpp
Mostly implemented Struct support.
[cycript.git] / sig / types.hpp
CommitLineData
ea2d184c
JF
1#ifndef SIG_TYPES_H
2#define SIG_TYPES_H
3
4#include "minimal/stdlib.h"
5
6namespace sig {
7
8enum Primitive {
9 typename_P = '#',
10 union_P = '(',
11 string_P = '*',
12 selector_P = ':',
13 object_P = '@',
14 boolean_P = 'B',
15 uchar_P = 'C',
16 uint_P = 'I',
17 ulong_P = 'L',
18 ulonglong_P = 'Q',
19 ushort_P = 'S',
20 array_P = '[',
21 pointer_P = '^',
22 bit_P = 'b',
23 char_P = 'c',
24 double_P = 'd',
25 float_P = 'f',
26 int_P = 'i',
27 long_P = 'l',
28 longlong_P = 'q',
29 short_P = 's',
30 void_P = 'v',
31 struct_P = '{'
32};
33
34struct Element {
35 char *name;
36 struct Type *type;
37 size_t offset;
38};
39
40struct Signature {
41 struct Element *elements;
42 size_t count;
43};
44
45#define JOC_TYPE_INOUT (1 << 0)
46#define JOC_TYPE_IN (1 << 1)
47#define JOC_TYPE_BYCOPY (1 << 2)
48#define JOC_TYPE_OUT (1 << 3)
49#define JOC_TYPE_BYREF (1 << 4)
50#define JOC_TYPE_CONST (1 << 5)
51#define JOC_TYPE_ONEWAY (1 << 6)
52
53struct Type {
54 enum Primitive primitive;
55 char *name;
56 uint8_t flags;
57
58 union {
59 struct {
60 struct Type *type;
61 size_t size;
62 } data;
63
64 struct Signature signature;
ea2d184c
JF
65 } data;
66};
67
68struct Type *joc_parse_type(char **name, char eos, bool variable, bool signature);
69void joc_parse_signature(struct Signature *signature, char **name, char eos, bool variable);
70
bd17e6f3
JF
71_finline bool IsAggregate(Primitive primitive) {
72 return primitive == struct_P || primitive == union_P;
73}
74
ea2d184c
JF
75}
76
77#endif/*SIG_TYPES_H*/