]> git.saurik.com Git - cycript.git/blob - ObjectiveC/Internal.hpp
49461489d2a06b5825b1f560d1fc6741f066d53c
[cycript.git] / ObjectiveC / Internal.hpp
1 /* Cycript - Optimizing JavaScript Compiler/Runtime
2 * Copyright (C) 2009-2015 Jay Freeman (saurik)
3 */
4
5 /* GNU Affero General Public License, Version 3 {{{ */
6 /*
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
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
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/>.
19 **/
20 /* }}} */
21
22 #ifndef CYCRIPT_OBJECTIVEC_INTERNAL_HPP
23 #define CYCRIPT_OBJECTIVEC_INTERNAL_HPP
24
25 #include <objc/objc.h>
26
27 #include "../Internal.hpp"
28
29 struct Selector_privateData :
30 CYValue_<Selector_privateData, SEL>
31 {
32 _finline Selector_privateData(SEL value) :
33 CYValue_(value)
34 {
35 }
36 };
37
38 struct Instance :
39 CYValue_<Instance, id>
40 {
41 enum Flags {
42 None = 0,
43 Permanent = (1 << 0),
44 Uninitialized = (1 << 1),
45 };
46
47 Flags flags_;
48
49 Instance(id value, Flags flags);
50 virtual ~Instance();
51
52 JSValueRef GetPrototype(JSContextRef context) const;
53
54 static JSClassRef GetClass(id value, Flags flags);
55
56 _finline bool IsUninitialized() const {
57 return (flags_ & Uninitialized) != 0;
58 }
59 };
60
61 namespace cy {
62 struct Super :
63 CYValue_<Super, id>
64 {
65 Class class_;
66
67 _finline Super(id value, Class _class) :
68 CYValue_(value),
69 class_(_class)
70 {
71 }
72 }; }
73
74 struct Messages :
75 CYValue_<Messages, Class>
76 {
77 _finline Messages(Class value) :
78 CYValue_(value)
79 {
80 }
81
82 JSValueRef GetPrototype(JSContextRef context) const;
83 };
84
85 struct Internal :
86 CYValue_<Internal, id>
87 {
88 CYProtect owner_;
89
90 _finline Internal(id value, JSContextRef context, JSObjectRef owner) :
91 CYValue_(value),
92 owner_(context, owner)
93 {
94 }
95 };
96
97 #endif/*CYCRIPT_OBJECTIVEC_INTERNAL_HPP*/