]>
Commit | Line | Data |
---|---|---|
b3378a02 | 1 | /* Cycript - Optimizing JavaScript Compiler/Runtime |
c1d3e52e | 2 | * Copyright (C) 2009-2015 Jay Freeman (saurik) |
d15b59f5 JF |
3 | */ |
4 | ||
f95d2598 | 5 | /* GNU Affero General Public License, Version 3 {{{ */ |
d15b59f5 | 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 | **/ |
d15b59f5 JF |
20 | /* }}} */ |
21 | ||
3c1c3635 JF |
22 | #ifndef CYCRIPT_OBJECTIVEC_INTERNAL_HPP |
23 | #define CYCRIPT_OBJECTIVEC_INTERNAL_HPP | |
24 | ||
37954781 | 25 | #include <Internal.hpp> |
aabea98c | 26 | #include <objc/objc.h> |
3c1c3635 JF |
27 | |
28 | struct Selector_privateData : | |
29 | CYValue | |
30 | { | |
31 | _finline Selector_privateData(SEL value) : | |
32 | CYValue(value) | |
33 | { | |
34 | } | |
35 | ||
36 | _finline SEL GetValue() const { | |
37 | return reinterpret_cast<SEL>(value_); | |
38 | } | |
39 | ||
40 | virtual Type_privateData *GetType() const; | |
41 | }; | |
42 | ||
43 | struct Instance : | |
44 | CYValue | |
45 | { | |
46 | enum Flags { | |
47 | None = 0, | |
8b8a64c5 | 48 | Permanent = (1 << 0), |
3c1c3635 JF |
49 | Uninitialized = (1 << 1), |
50 | }; | |
51 | ||
52 | Flags flags_; | |
53 | ||
54 | _finline Instance(id value, Flags flags) : | |
55 | CYValue(value), | |
56 | flags_(flags) | |
57 | { | |
58 | } | |
59 | ||
60 | virtual ~Instance(); | |
61 | ||
62 | static JSObjectRef Make(JSContextRef context, id object, Flags flags = None); | |
63 | ||
64 | _finline id GetValue() const { | |
65 | return reinterpret_cast<id>(value_); | |
66 | } | |
67 | ||
68 | _finline bool IsUninitialized() const { | |
69 | return (flags_ & Uninitialized) != 0; | |
70 | } | |
71 | ||
72 | virtual Type_privateData *GetType() const; | |
73 | }; | |
74 | ||
75 | namespace cy { | |
76 | struct Super : | |
77 | Instance | |
78 | { | |
79 | Class class_; | |
80 | ||
81 | _finline Super(id value, Class _class) : | |
8b8a64c5 | 82 | Instance(value, Instance::Permanent), |
3c1c3635 JF |
83 | class_(_class) |
84 | { | |
85 | } | |
86 | ||
87 | static JSObjectRef Make(JSContextRef context, id object, Class _class); | |
88 | }; } | |
89 | ||
90 | struct Messages : | |
91 | CYValue | |
92 | { | |
93 | _finline Messages(Class value) : | |
94 | CYValue(value) | |
95 | { | |
96 | } | |
97 | ||
8150077d | 98 | static JSObjectRef Make(JSContextRef context, Class _class); |
3c1c3635 JF |
99 | |
100 | _finline Class GetValue() const { | |
101 | return reinterpret_cast<Class>(value_); | |
102 | } | |
103 | }; | |
104 | ||
105 | struct Internal : | |
106 | CYOwned | |
107 | { | |
108 | _finline Internal(id value, JSContextRef context, JSObjectRef owner) : | |
109 | CYOwned(value, context, owner) | |
110 | { | |
111 | } | |
112 | ||
113 | static JSObjectRef Make(JSContextRef context, id object, JSObjectRef owner); | |
114 | ||
115 | _finline id GetValue() const { | |
116 | return reinterpret_cast<id>(value_); | |
117 | } | |
118 | }; | |
119 | ||
120 | #endif/*CYCRIPT_OBJECTIVEC_INTERNAL_HPP*/ |