-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
KrollObject.h
63 lines (51 loc) 路 2.09 KB
/
KrollObject.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/**
* Appcelerator Titanium Mobile
* Copyright (c) 2009-2010 by Appcelerator, Inc. All Rights Reserved.
* Licensed under the terms of the Apache Public License
* Please see the LICENSE included with this distribution for details.
*/
#import <Foundation/Foundation.h>
#import "TiCore.h"
#import "TiBase.h"
@class KrollContext, KrollCallback;
extern TiClassRef KrollObjectClassRef;
void KrollFinalizer(TiObjectRef ref);
void KrollInitializer(TiContextRef ctx, TiObjectRef object);
TiValueRef KrollGetProperty(TiContextRef jsContext, TiObjectRef obj, TiStringRef prop, TiValueRef* exception);
bool KrollSetProperty(TiContextRef jsContext, TiObjectRef obj, TiStringRef prop, TiValueRef value, TiValueRef* exception);
bool KrollDeleteProperty(TiContextRef ctx, TiObjectRef object, TiStringRef propertyName, TiValueRef* exception);
// this is simply a marker interface that we can use
// to determine if a object is undefined
@interface KrollUndefined : NSObject
+(KrollUndefined*)undefined;
@end
//
// KrollObject is a generic native wrapper around a native object exposed as a JS object
// in JS land.
//
@interface KrollObject : NSObject {
@private
NSMutableDictionary *properties;
NSMutableDictionary *statics;
TiObjectRef jsobject;
BOOL targetable;
@protected
id target;
KrollContext *context;
}
-(id)initWithTarget:(id)target_ context:(KrollContext*)context_;
+(TiValueRef)create:(id)object context:(KrollContext*)context_;
+(id)toID:(KrollContext*)context value:(TiValueRef)ref;
+(TiValueRef)toValue:(KrollContext*)context value:(id)obj;
+(id)nonNull:(id)value;
-(id)valueForKey:(NSString *)key;
-(void)deleteKey:(NSString *)key;
-(void)setValue:(id)value forKey:(NSString *)key;
-(void)setStaticValue:(id)value forKey:(NSString*)key purgable:(BOOL)purgable;
-(KrollContext*)context;
-(id)target;
-(TiObjectRef)jsobject;
-(void)storeCallback:(KrollCallback *)eventCallback forEvent:(NSString *)eventName;
-(void)removeCallback:(KrollCallback *)eventCallback forEvent:(NSString *)eventName;
-(void)triggerEvent:(NSString *)eventName withObject:(NSDictionary *)eventData thisObject:(KrollObject *)thisObject;
@end