]> git.saurik.com Git - cycript.git/blob - ObjectiveC/Internal.hpp
f9f92cbfe20037eed21e1dbd149472c7e618392a
[cycript.git] / ObjectiveC / Internal.hpp
1 #ifndef CYCRIPT_OBJECTIVEC_INTERNAL_HPP
2 #define CYCRIPT_OBJECTIVEC_INTERNAL_HPP
3
4 #include "Internal.hpp"
5
6 struct Selector_privateData :
7 CYValue
8 {
9 _finline Selector_privateData(SEL value) :
10 CYValue(value)
11 {
12 }
13
14 _finline SEL GetValue() const {
15 return reinterpret_cast<SEL>(value_);
16 }
17
18 virtual Type_privateData *GetType() const;
19 };
20
21 struct Instance :
22 CYValue
23 {
24 enum Flags {
25 None = 0,
26 Transient = (1 << 0),
27 Uninitialized = (1 << 1),
28 };
29
30 Flags flags_;
31
32 _finline Instance(id value, Flags flags) :
33 CYValue(value),
34 flags_(flags)
35 {
36 }
37
38 virtual ~Instance();
39
40 static JSObjectRef Make(JSContextRef context, id object, Flags flags = None);
41
42 _finline id GetValue() const {
43 return reinterpret_cast<id>(value_);
44 }
45
46 _finline bool IsUninitialized() const {
47 return (flags_ & Uninitialized) != 0;
48 }
49
50 virtual Type_privateData *GetType() const;
51 };
52
53 namespace cy {
54 struct Super :
55 Instance
56 {
57 Class class_;
58
59 _finline Super(id value, Class _class) :
60 Instance(value, Instance::Transient),
61 class_(_class)
62 {
63 }
64
65 static JSObjectRef Make(JSContextRef context, id object, Class _class);
66 }; }
67
68 struct Messages :
69 CYValue
70 {
71 _finline Messages(Class value) :
72 CYValue(value)
73 {
74 }
75
76 static JSObjectRef Make(JSContextRef context, Class _class, bool array = false);
77
78 _finline Class GetValue() const {
79 return reinterpret_cast<Class>(value_);
80 }
81 };
82
83 struct Internal :
84 CYOwned
85 {
86 _finline Internal(id value, JSContextRef context, JSObjectRef owner) :
87 CYOwned(value, context, owner)
88 {
89 }
90
91 static JSObjectRef Make(JSContextRef context, id object, JSObjectRef owner);
92
93 _finline id GetValue() const {
94 return reinterpret_cast<id>(value_);
95 }
96 };
97
98 #endif/*CYCRIPT_OBJECTIVEC_INTERNAL_HPP*/