Merge remote-tracking branch 'redux/master' into sh4-pool
[tamarin-stm.git] / shell / SystemClass.h
blob5d9afba5fedb5ca0d6a9eb9a2b6b058942b1688f
1 /* -*- Mode: C++; c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 4 -*- */
2 /* vi: set ts=4 sw=4 expandtab: (add to ~/.vimrc: set modeline modelines=5) */
3 /* ***** BEGIN LICENSE BLOCK *****
4 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
6 * The contents of this file are subject to the Mozilla Public License Version
7 * 1.1 (the "License"); you may not use this file except in compliance with
8 * the License. You may obtain a copy of the License at
9 * http://www.mozilla.org/MPL/
11 * Software distributed under the License is distributed on an "AS IS" basis,
12 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
13 * for the specific language governing rights and limitations under the
14 * License.
16 * The Original Code is [Open Source Virtual Machine.].
18 * The Initial Developer of the Original Code is
19 * Adobe System Incorporated.
20 * Portions created by the Initial Developer are Copyright (C) 2004-2006
21 * the Initial Developer. All Rights Reserved.
23 * Contributor(s):
24 * Adobe AS3 Team
26 * Alternatively, the contents of this file may be used under the terms of
27 * either the GNU General Public License Version 2 or later (the "GPL"), or
28 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
29 * in which case the provisions of the GPL or the LGPL are applicable instead
30 * of those above. If you wish to allow use of your version of this file only
31 * under the terms of either the GPL or the LGPL, and not to allow others to
32 * use your version of this file under the terms of the MPL, indicate your
33 * decision by deleting the provisions above and replace them with the notice
34 * and other provisions required by the GPL or the LGPL. If you do not delete
35 * the provisions above, a recipient may use your version of this file under
36 * the terms of any one of the MPL, the GPL or the LGPL.
38 * ***** END LICENSE BLOCK ***** */
40 #ifndef __avmshell_SystemClass__
41 #define __avmshell_SystemClass__
44 namespace avmshell
46 class AbstractBaseClass : public avmplus::ClassClosure
48 public:
49 AbstractBaseClass(VTable* cvtable) : ClassClosure(cvtable) {}
51 DECLARE_SLOTS_AbstractBaseClass;
54 class AbstractBaseObject : public avmplus::ScriptObject
56 public:
57 AbstractBaseObject(VTable* vtable, ScriptObject* prototype) : ScriptObject(vtable, prototype) {}
59 DECLARE_SLOTS_AbstractBaseObject;
62 class NativeSubclassOfAbstractBaseClass : public avmplus::ClassClosure
64 public:
65 NativeSubclassOfAbstractBaseClass(VTable* cvtable) : ClassClosure(cvtable) {}
67 DECLARE_SLOTS_NativeSubclassOfAbstractBaseClass;
70 class NativeSubclassOfAbstractBaseObject : public AbstractBaseObject
72 public:
73 NativeSubclassOfAbstractBaseObject(VTable* vtable, ScriptObject* prototype) : AbstractBaseObject(vtable, prototype) {}
75 DECLARE_SLOTS_NativeSubclassOfAbstractBaseObject;
78 class RestrictedBaseClass : public avmplus::ClassClosure
80 public:
81 RestrictedBaseClass(VTable* cvtable) : ClassClosure(cvtable) {}
83 DECLARE_SLOTS_RestrictedBaseClass;
86 class RestrictedBaseObject : public avmplus::ScriptObject
88 public:
89 RestrictedBaseObject(VTable* vtable, ScriptObject* prototype) : ScriptObject(vtable, prototype) {}
91 DECLARE_SLOTS_RestrictedBaseObject;
94 class NativeSubclassOfRestrictedBaseClass : public avmplus::ClassClosure
96 public:
97 NativeSubclassOfRestrictedBaseClass(VTable* cvtable) : ClassClosure(cvtable) {}
99 DECLARE_SLOTS_NativeSubclassOfRestrictedBaseClass;
102 class NativeSubclassOfRestrictedBaseObject : public RestrictedBaseObject
104 public:
105 NativeSubclassOfRestrictedBaseObject(VTable* vtable, ScriptObject* prototype) : RestrictedBaseObject(vtable, prototype) {}
107 DECLARE_SLOTS_NativeSubclassOfRestrictedBaseObject;
110 class AbstractRestrictedBaseClass : public avmplus::ClassClosure
112 public:
113 AbstractRestrictedBaseClass(VTable* cvtable) : ClassClosure(cvtable) {}
115 DECLARE_SLOTS_AbstractRestrictedBaseClass;
118 class AbstractRestrictedBaseObject : public avmplus::ScriptObject
120 public:
121 AbstractRestrictedBaseObject(VTable* vtable, ScriptObject* prototype) : ScriptObject(vtable, prototype) {}
123 DECLARE_SLOTS_AbstractRestrictedBaseObject;
126 class NativeSubclassOfAbstractRestrictedBaseClass : public avmplus::ClassClosure
128 public:
129 NativeSubclassOfAbstractRestrictedBaseClass(VTable* cvtable) : ClassClosure(cvtable) {}
131 DECLARE_SLOTS_NativeSubclassOfAbstractRestrictedBaseClass;
134 class NativeSubclassOfAbstractRestrictedBaseObject : public AbstractRestrictedBaseObject
136 public:
137 NativeSubclassOfAbstractRestrictedBaseObject(VTable* vtable, ScriptObject* prototype) : AbstractRestrictedBaseObject(vtable, prototype) {}
139 DECLARE_SLOTS_NativeSubclassOfAbstractRestrictedBaseObject;
142 // this class exists solely to test native classes that use MI.
143 class MIClass : public avmplus::ClassClosure
145 public:
146 MIClass(VTable* cvtable) : ClassClosure(cvtable) {}
147 ~MIClass() {}
149 DECLARE_SLOTS_MIClass;
152 // this class exists solely to test native classes that use MI.
153 class MixinClassThatDoesNotDescendFromScriptObject
155 public:
156 const double factor;
157 MixinClassThatDoesNotDescendFromScriptObject(double f) : factor(f) {}
158 // evil, wrong version that we DO NOT WANT
159 double plus(double v) { return v * factor; }
162 // this class exists solely to test native classes that use MI.
163 class MIObjectImpl : public avmplus::ScriptObject
165 public:
166 const double amount;
167 MIObjectImpl(VTable* vtable, ScriptObject* prototype, double a) : ScriptObject(vtable, prototype), amount(a) {}
168 double plus(double v) { return v + amount; }
171 class CheckBaseClass : public avmplus::ClassClosure
173 public:
174 CheckBaseClass(VTable* cvtable) : ClassClosure(cvtable) {}
176 DECLARE_SLOTS_CheckBaseClass;
179 class CheckBaseObject : public avmplus::ScriptObject
181 public:
182 CheckBaseObject(VTable* vtable, ScriptObject* prototype) : ScriptObject(vtable, prototype) {}
184 DECLARE_SLOTS_CheckBaseObject;
187 // this class exists solely to test native classes that use MI.
188 class MIObject : public MIObjectImpl, public MixinClassThatDoesNotDescendFromScriptObject
190 public:
191 MIObject(VTable* vtable, ScriptObject* prototype) : MIObjectImpl(vtable, prototype, 1), MixinClassThatDoesNotDescendFromScriptObject(2) {}
192 ~MIObject() {}
194 DECLARE_SLOTS_MIObject;
198 * A simple class that has some native methods.
199 * Included as an example for writers of native methods,
200 * and also to provide some useful QA instrumentation.
202 class GC_AS3_EXACT(SystemClass, avmplus::ClassClosure)
204 uint64_t initialTime;
206 SystemClass(VTable* cvtable);
207 public:
208 REALLY_INLINE static SystemClass* create(MMgc::GC* gc, VTable* cvtable)
210 return new (gc, MMgc::kExact, cvtable->getExtraSize()) SystemClass(cvtable);
213 ~SystemClass();
215 // set by shell
216 static int user_argc;
217 static char **user_argv;
220 * Implementation of System.exit
221 * AS usage: System.exit(status);
222 * Exits the VM with OS exit code specified by status.
224 void exit(int status);
227 * Implementation of System.getAvmplusVersion
228 * AS usage: System.getAvmplusVersion();
229 * Returns the current version of AVM+ in the form
230 * "1.0 d100"
232 Stringp getAvmplusVersion();
235 * Implementation of System.getFeatures
236 * AS usage: System.getFeatures();
237 * Returns the compiled in features of AVM+
239 Stringp getFeatures();
242 * Implementation of System.getRunmode
243 * AS usage: System.getRunmode();
244 * Returns the current runmode
246 Stringp getRunmode();
249 * Implementation of System.exec
250 * AS usage: exitCode = System.exec("command");
251 * Executes the specified command line and returns
252 * the status code
254 int exec(Stringp command);
256 void trace(ArrayObject* a);
257 void write(Stringp s);
261 * @name Debugging Extensions
263 /*@{*/
264 void debugger();
265 bool isDebugger();
266 /*@}*/
269 * @name ActionScript Extensions
270 * ActionScript extensions to ECMAScript
272 /*@{*/
273 unsigned getTimer();
274 /*@}*/
276 ArrayObject * getArgv();
278 Stringp readLine();
280 double get_totalMemory();
281 double get_freeMemory();
282 double get_privateMemory();
284 int32_t get_swfVersion();
285 int32_t get_apiVersion();
287 // Initiate a garbage collection; future versions will not return before completed.
288 void forceFullCollection();
290 // Queue a garbage collection request.
291 void queueCollection();
293 // function exists solely to test native-methods with custom namespaces
294 void ns_example_nstest() { }
296 // function exists solely to test ScriptObject::isGlobalObject
297 bool isGlobal(Atom o);
299 void disposeXML(XMLObject *xmlObject);
301 GC_NO_DATA(SystemClass)
303 DECLARE_SLOTS_SystemClass;
307 #endif /* __avmshell_SystemClass__ */