2 Copyright (C) 2000-2003 SKYRIX Software AG
4 This file is part of OGo
6 OGo is free software; you can redistribute it and/or modify it under
7 the terms of the GNU Lesser General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
11 OGo is distributed in the hope that it will be useful, but WITHOUT ANY
12 WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
14 License for more details.
16 You should have received a copy of the GNU Lesser General Public
17 License along with OGo; see the file COPYING. If not, write to the
18 Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
23 #ifndef __NGJavaScriptObject_H__
24 #define __NGJavaScriptObject_H__
26 #import <Foundation/NSObject.h>
27 #include "NSObject+JS.h"
32 Related: NGJavaScriptObjectHandler, see docu
34 Hm, what is the difference between the handler and the object ?
35 => find out and document
37 Note: this object keeps a retained reference to the context.
40 @class NSEnumerator, NSArray, NSString, NSDictionary;
41 @class NGObjectMappingContext;
42 @class NGJavaScriptObjectMappingContext;
44 @interface NGJavaScriptObject : NSObject < NSCoding >
46 NGJavaScriptObjectMappingContext *ctx;
47 void *jscx; /* cached JSContext handle */
48 void *handle; /* the handle of the object itself */
49 BOOL addedRoot; /* was a root-ref added */
52 - (id)initWithHandle:(void *)_handle
53 inMappingContext:(NGObjectMappingContext *)_ctx;
59 - (void *)_jsHandleInMapContext:(NGObjectMappingContext *)_ctx;
63 - (void)applyStandardClasses;
65 - (void)setParentObject:(id)_parent;
67 - (NSEnumerator *)parentObjectChain;
69 - (void)setPrototypeObject:(id)_proto;
70 - (id)prototypeObject;
71 - (NSEnumerator *)prototypeObjectChain;
73 - (BOOL)hasPropertyNamed:(NSString *)_key;
74 - (BOOL)hasFunctionNamed:(NSString *)_key;
76 /* a function object */
78 - (BOOL)isJavaScriptFunction;
79 - (id)callOn:(id)_this;
80 - (id)callOn:(id)_this withObject:(id)_arg0;
82 /* mimic an NSDictionary */
84 - (void)setObject:(id)_value forKey:(id)_key;
85 - (id)objectForKey:(id)_key;
86 - (void)removeObjectForKey:(id)_key;
87 - (NSEnumerator *)keyEnumerator;
88 - (NSEnumerator *)objectEnumerator;
90 - (NSArray *)allValues;
92 /* convert to dictionary */
94 - (NSDictionary *)convertToNSDictionary;
98 - (void)takeValue:(id)_value forKey:(NSString *)_key;
99 - (id)valueForKey:(NSString *)_key;
103 #import <Foundation/NSArray.h>
105 /* this class gets the NSMutableArray behaviour added !!! */
107 @interface NGJavaScriptArray : NGJavaScriptObject < NSCopying >
109 /* convert to array */
111 - (NSArray *)convertToNSArray;
115 @interface NGJavaScriptArray(NSArrayCompatibility)
118 - (id)objectAtIndex:(unsigned)_idx;
119 - (NSEnumerator *)objectEnumerator;
122 - (NSArray *)arrayByAddingObject:(id)anObject;
123 - (NSArray *)arrayByAddingObjectsFromArray:(NSArray *)anotherArray;
125 - (NSArray *)sortedArrayUsingFunction:
126 (int(*)(id element1, id element2, void *userData))comparator
127 context:(void*)context;
131 @interface NGJavaScriptArray(NSMutableArrayCompatibility)
133 - (void)setObject:(id)_obj atIndex:(unsigned)_idx;
135 - (void)removeObjectsInRange:(NSRange)aRange;
136 - (void)removeAllObjects;
137 - (void)removeLastObject;
138 - (void)removeObjectAtIndex:(unsigned)_idx;
140 - (void)insertObject:(id)_object atIndex:(unsigned)_idx;
141 - (void)addObject:(id)_object;
145 #endif /* __NGJavaScriptObject_H__ */