]> git.saurik.com Git - cycript.git/blame - ObjectiveC/Internal.hpp
Fix Objective-C dictionary/array literal lowering.
[cycript.git] / ObjectiveC / Internal.hpp
CommitLineData
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
aabea98c 25#include <objc/objc.h>
3c1c3635 26
20052ff7
JF
27#include "../Internal.hpp"
28
3c1c3635
JF
29struct Selector_privateData :
30 CYValue
31{
32 _finline Selector_privateData(SEL value) :
33 CYValue(value)
34 {
35 }
36
37 _finline SEL GetValue() const {
38 return reinterpret_cast<SEL>(value_);
39 }
40
41 virtual Type_privateData *GetType() const;
42};
43
44struct Instance :
45 CYValue
46{
47 enum Flags {
48 None = 0,
8b8a64c5 49 Permanent = (1 << 0),
3c1c3635
JF
50 Uninitialized = (1 << 1),
51 };
52
53 Flags flags_;
54
55 _finline Instance(id value, Flags flags) :
56 CYValue(value),
57 flags_(flags)
58 {
59 }
60
61 virtual ~Instance();
62
63 static JSObjectRef Make(JSContextRef context, id object, Flags flags = None);
64
65 _finline id GetValue() const {
66 return reinterpret_cast<id>(value_);
67 }
68
69 _finline bool IsUninitialized() const {
70 return (flags_ & Uninitialized) != 0;
71 }
72
73 virtual Type_privateData *GetType() const;
74};
75
76namespace cy {
77struct Super :
78 Instance
79{
80 Class class_;
81
82 _finline Super(id value, Class _class) :
8b8a64c5 83 Instance(value, Instance::Permanent),
3c1c3635
JF
84 class_(_class)
85 {
86 }
87
88 static JSObjectRef Make(JSContextRef context, id object, Class _class);
89}; }
90
91struct Messages :
92 CYValue
93{
94 _finline Messages(Class value) :
95 CYValue(value)
96 {
97 }
98
8150077d 99 static JSObjectRef Make(JSContextRef context, Class _class);
3c1c3635
JF
100
101 _finline Class GetValue() const {
102 return reinterpret_cast<Class>(value_);
103 }
104};
105
106struct Internal :
107 CYOwned
108{
109 _finline Internal(id value, JSContextRef context, JSObjectRef owner) :
110 CYOwned(value, context, owner)
111 {
112 }
113
114 static JSObjectRef Make(JSContextRef context, id object, JSObjectRef owner);
115
116 _finline id GetValue() const {
117 return reinterpret_cast<id>(value_);
118 }
119};
120
121#endif/*CYCRIPT_OBJECTIVEC_INTERNAL_HPP*/