]> git.saurik.com Git - cydia.git/blame - CyteKit/webScriptObjectInContext.mm
Move most of CydiaObject to CyteKit as CyteObject.
[cydia.git] / CyteKit / webScriptObjectInContext.mm
CommitLineData
f172aa8f 1/* Cydia - iPhone UIKit Front-End for Debian APT
4c66fad9 2 * Copyright (C) 2008-2015 Jay Freeman (saurik)
f172aa8f
JF
3*/
4
6d9696a5 5/* GNU General Public License, Version 3 {{{ */
f172aa8f 6/*
6d9696a5
JF
7 * Cydia is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published
9 * by the Free Software Foundation, either version 3 of the License,
10 * or (at your option) any later version.
f172aa8f 11 *
6d9696a5
JF
12 * Cydia is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
f172aa8f 16 *
6d9696a5
JF
17 * You should have received a copy of the GNU General Public License
18 * along with Cydia. If not, see <http://www.gnu.org/licenses/>.
19**/
f172aa8f
JF
20/* }}} */
21
63755c48
JF
22#include "CyteKit/UCPlatform.h"
23
a3d01a76 24#include "CyteKit/webScriptObjectInContext.h"
f172aa8f 25
63755c48
JF
26#include "iPhonePrivate.h"
27
a3d01a76 28@implementation NSObject (CydiaScript)
f172aa8f 29
a3d01a76
JF
30- (id) Cydia$webScriptObjectInContext:(WebScriptObject *)context {
31 return self;
f172aa8f
JF
32}
33
a3d01a76
JF
34@end
35
36@implementation NSArray (CydiaScript)
37
38- (id) Cydia$webScriptObjectInContext:(WebScriptObject *)context {
39 WebScriptObject *object([context evaluateWebScript:@"[]"]);
40 for (size_t i(0), e([self count]); i != e; ++i)
41 [object setWebScriptValueAtIndex:i value:[[self objectAtIndex:i] Cydia$webScriptObjectInContext:context]];
42 return object;
f172aa8f
JF
43}
44
a3d01a76
JF
45@end
46
47@implementation NSDictionary (CydiaScript)
48
49- (id) Cydia$webScriptObjectInContext:(WebScriptObject *)context {
50 WebScriptObject *object([context evaluateWebScript:@"({})"]);
51 for (id i in self)
52 [object setValue:[[self objectForKey:i] Cydia$webScriptObjectInContext:context] forKey:i];
53 return object;
5276ff21
JF
54}
55
f172aa8f 56@end