]>
Commit | Line | Data |
---|---|---|
7341eedb JF |
1 | /* Cycript - The Truly Universal Scripting Language |
2 | * Copyright (C) 2009-2016 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 | ||
aabea98c | 25 | #include <objc/objc.h> |
3c1c3635 | 26 | |
20052ff7 JF |
27 | #include "../Internal.hpp" |
28 | ||
3c1c3635 | 29 | struct Selector_privateData : |
d4222ffb | 30 | CYRoot |
3c1c3635 | 31 | { |
88c31c1e JF |
32 | SEL value_; |
33 | ||
3c1c3635 | 34 | _finline Selector_privateData(SEL value) : |
88c31c1e | 35 | value_(value) |
3c1c3635 JF |
36 | { |
37 | } | |
3c1c3635 JF |
38 | }; |
39 | ||
40 | struct Instance : | |
d4222ffb | 41 | CYPrivateOld<Instance> |
3c1c3635 | 42 | { |
78b24692 JF |
43 | typedef unsigned Flags; |
44 | static const Flags None = 0; | |
45 | static const Flags Permanent = 1 << 0; | |
46 | static const Flags Uninitialized = 1 << 1; | |
3c1c3635 | 47 | |
88c31c1e | 48 | id value_; |
3c1c3635 JF |
49 | Flags flags_; |
50 | ||
d6848e73 | 51 | Instance(id value, Flags flags); |
3c1c3635 JF |
52 | virtual ~Instance(); |
53 | ||
d6848e73 | 54 | JSValueRef GetPrototype(JSContextRef context) const; |
3c1c3635 | 55 | |
d6848e73 | 56 | static JSClassRef GetClass(id value, Flags flags); |
3c1c3635 | 57 | |
78b24692 JF |
58 | _finline bool IsPermanent() const { |
59 | return (flags_ & Permanent) != 0; | |
60 | } | |
61 | ||
3c1c3635 JF |
62 | _finline bool IsUninitialized() const { |
63 | return (flags_ & Uninitialized) != 0; | |
64 | } | |
3c1c3635 JF |
65 | }; |
66 | ||
67 | namespace cy { | |
68 | struct Super : | |
d4222ffb | 69 | CYRoot |
3c1c3635 | 70 | { |
88c31c1e | 71 | id value_; |
3c1c3635 JF |
72 | Class class_; |
73 | ||
74 | _finline Super(id value, Class _class) : | |
88c31c1e | 75 | value_(value), |
3c1c3635 JF |
76 | class_(_class) |
77 | { | |
78 | } | |
3c1c3635 JF |
79 | }; } |
80 | ||
81 | struct Messages : | |
d4222ffb | 82 | CYRoot |
3c1c3635 | 83 | { |
3d2d95a0 JF |
84 | virtual Class GetClass() const = 0; |
85 | }; | |
86 | ||
87 | struct Prototype : | |
88 | Messages | |
89 | { | |
90 | static constexpr const char *const Cache_ = "p"; | |
91 | ||
88c31c1e JF |
92 | Class value_; |
93 | ||
3d2d95a0 | 94 | _finline Prototype(Class value) : |
88c31c1e | 95 | value_(value) |
3c1c3635 JF |
96 | { |
97 | } | |
98 | ||
3d2d95a0 JF |
99 | Class GetClass() const override { |
100 | return value_; | |
101 | } | |
102 | ||
103 | JSValueRef GetPrototype(JSContextRef context) const; | |
104 | }; | |
105 | ||
106 | struct Constructor : | |
107 | Messages | |
108 | { | |
109 | static constexpr const char *const Cache_ = "m"; | |
110 | ||
111 | Class value_; | |
112 | ||
113 | _finline Constructor(Class value) : | |
114 | value_(value) | |
115 | { | |
116 | } | |
117 | ||
118 | Class GetClass() const override { | |
119 | return value_; | |
120 | } | |
121 | ||
d6848e73 | 122 | JSValueRef GetPrototype(JSContextRef context) const; |
3c1c3635 JF |
123 | }; |
124 | ||
8effd381 | 125 | struct Interior : |
d4222ffb | 126 | CYRoot |
3c1c3635 | 127 | { |
88c31c1e | 128 | id value_; |
d6848e73 JF |
129 | CYProtect owner_; |
130 | ||
8effd381 | 131 | _finline Interior(id value, JSContextRef context, JSObjectRef owner) : |
88c31c1e | 132 | value_(value), |
d6848e73 | 133 | owner_(context, owner) |
3c1c3635 JF |
134 | { |
135 | } | |
3c1c3635 JF |
136 | }; |
137 | ||
138 | #endif/*CYCRIPT_OBJECTIVEC_INTERNAL_HPP*/ |