]> err.no Git - sope/blob - Recycler/NGJavaScript/NGJavaScriptContext.h
necessary changes
[sope] / Recycler / NGJavaScript / NGJavaScriptContext.h
1 /*
2   Copyright (C) 2000-2003 SKYRIX Software AG
3
4   This file is part of OGo
5
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
9   later version.
10
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.
15
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
19   02111-1307, USA.
20 */
21 // $Id$
22
23 #ifndef __NGJavaScriptContext_H__
24 #define __NGJavaScriptContext_H__
25
26 #import <Foundation/NSObject.h>
27
28 @class NSString, NSException;
29 @class NGJavaScriptRuntime;
30
31 @interface NGJavaScriptContext : NSObject
32 {
33   NGJavaScriptRuntime *rt;
34   void                *handle;
35
36   NSException *lastError;
37 }
38
39 + (NGJavaScriptContext *)jsContextForHandle:(void *)_handle;
40
41 - (id)initWithRuntime:(NGJavaScriptRuntime *)_rt
42   maximumStackSize:(unsigned)_size;
43 - (id)initWithRuntime:(NGJavaScriptRuntime *)_rt;
44 - (id)init;
45
46 - (BOOL)loadStandardClasses;
47
48 /* private */
49
50 - (void *)handle;
51
52 /* accessors */
53
54 - (NGJavaScriptRuntime *)runtime;
55
56 - (BOOL)isRunning;
57 - (BOOL)isConstructing;
58
59 - (void)setJavaScriptVersion:(int)_version;
60 - (int)javaScriptVersion;
61
62 /* evaluation */
63
64 - (id)evaluateScript:(NSString *)_script;
65
66 /* invocation */
67
68 - (id)callFunctionNamed:(NSString *)_funcName, ...;
69
70 /* errors */
71
72 - (void)reportException:(NSException *)_exc;
73 - (void)reportError:(NSString *)_fmt, ...;
74 - (void)reportOutOfMemory;
75
76 - (void)reportError:(NSString *)_msg
77   inFile:(NSString *)_path inLine:(unsigned)_line
78   report:(void *)_report;
79 - (NSException *)lastError;
80 - (void)clearLastError;
81
82 /* garbage collector */
83
84 - (void)collectGarbage;
85 - (void)maybeCollectGarbage;
86
87 - (void *)malloc:(unsigned)_size;
88 - (void *)realloc:(void *)_pointer size:(unsigned)_size;
89 - (void)freePointer:(void *)_pointer;
90
91 - (BOOL)addRootPointer:(void *)_root;
92 - (BOOL)addRootPointer:(void *)_root name:(NSString *)_name;
93 - (BOOL)removeRootPointer:(void *)_root;
94
95 - (BOOL)lockGCThing:(void *)_ptr;
96 - (BOOL)unlockGCThing:(void *)_ptr;
97
98 - (BOOL)beginGarbageCollection;
99 - (BOOL)endGarbageCollection;
100
101 /* threads */
102
103 - (void)beginRequest;
104 - (void)endRequest;
105 - (void)suspendRequest;
106 - (void)resumeRequest;
107
108 @end
109
110 #endif /* __NGJavaScriptContext_H__ */