Oolite
Loading...
Searching...
No Matches
OOJSConsole.m
Go to the documentation of this file.
1/*
2
3OOJSConsole.m (QuickJS-ng)
4
5
6Oolite
7Copyright (C) 2004-2013 Giles C Williams and contributors
8
9Permission is hereby granted, free of charge, to any person obtaining a copy
10of this software and associated documentation files (the "Software"), to deal
11in the Software without restriction, including without limitation the rights
12to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13copies of the Software, and to permit persons to whom the Software is
14furnished to do so, subject to the following conditions:
15
16The above copyright notice and this permission notice shall be included in all
17copies or substantial portions of the Software.
18
19THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
25SOFTWARE.
26
27*/
28
29#ifdef OO_DEBUG_MONITOR_ENABLED
30
31#import "OOJSConsole.h"
32#import "OODebugMonitor.h"
33#include <stdint.h>
34
35#import "OOConstToString.h"
36#import "OODebugFlags.h"
37#import "OOJSCall.h"
38#import "OOJSEngineTimeManagement.h"
39#import "OOJSEntity.h"
40#import "OOJSScript.h"
41#import "OOJSVector.h"
42#import "OOLoggingExtended.h"
44#import "ResourceManager.h"
45
46@interface Entity (OODebugInspector)
47
48// Method added by inspector in Debug OXP under OS X only.
49- (void)inspect;
50
51@end
52
53NSString* OOPlatformDescription(void);
54
55/* Differences from the SpiderMonkey version:
56 - pedanticMode is remembered but has no effect: SpiderMonkey's
57 JSOPTION_STRICT extra warnings have no QuickJS equivalent.
58 - dumpNamedRoots() does not exist (QuickJS has no named roots), and
59 dumpHeap() writes QuickJS's memory usage summary.
60 - profile(), getProfile() and trace() only profile natives, as in
61 SpiderMonkey builds without MOZ_TRACE_JSCALLS.
62 - ConsoleSettings properties are provided by the class's exotic methods
63 rather than get/set/delete hooks. As before, they are not enumerable.
64*/
65
66static JSClassID sConsoleClassID;
67static JSClassID sConsoleSettingsClassID;
68static BOOL sPedanticMode = YES;
69
70static JSValue ConsoleGetProperty(OOJS_GETTER_ARGS);
71static JSValue ConsoleSetProperty(OOJS_SETTER_ARGS);
72
73// Methods
74static JSValue ConsoleConsoleMessage(OOJS_NATIVE_ARGS);
75static JSValue ConsoleClearConsole(OOJS_NATIVE_ARGS);
76static JSValue ConsoleScriptStack(OOJS_NATIVE_ARGS);
77static JSValue ConsoleInspectEntity(OOJS_NATIVE_ARGS);
78#if OO_DEBUG
79static JSValue ConsoleCallObjCMethod(OOJS_NATIVE_ARGS);
80static JSValue ConsoleSetUpCallObjC(OOJS_NATIVE_ARGS);
81#endif
82static JSValue ConsoleIsExecutableJavaScript(OOJS_NATIVE_ARGS);
83static JSValue ConsoleDisplayMessagesInClass(OOJS_NATIVE_ARGS);
84static JSValue ConsoleSetDisplayMessagesInClass(OOJS_NATIVE_ARGS);
85static JSValue ConsoleWriteLogMarker(OOJS_NATIVE_ARGS);
86static JSValue ConsoleWriteMemoryStats(OOJS_NATIVE_ARGS);
87static JSValue ConsoleWriteJSMemoryStats(OOJS_NATIVE_ARGS);
88static JSValue ConsoleGarbageCollect(OOJS_NATIVE_ARGS);
89#if DEBUG
90static JSValue ConsoleDumpHeap(OOJS_NATIVE_ARGS);
91#endif
92#if OOJS_PROFILE
93static JSValue ConsoleProfile(OOJS_NATIVE_ARGS);
94static JSValue ConsoleGetProfile(OOJS_NATIVE_ARGS);
95static JSValue ConsoleTrace(OOJS_NATIVE_ARGS);
96
97static BOOL PerformProfiling(JSContext* context, NSString* nominalFunction, int argc, JSValueConst* argv, JSValue* outRval, BOOL trace, OOTimeProfile** outProfile);
98#endif
99
100static int ConsoleSettingsGetOwnProperty(JSContext* context, JSPropertyDescriptor* desc, JSValueConst object, JSAtom propID);
101static int ConsoleSettingsDeleteProperty(JSContext* context, JSValueConst object, JSAtom propID);
102static int ConsoleSettingsDefineOwnProperty(JSContext* context, JSValueConst object, JSAtom propID, JSValueConst value, JSValueConst getter, JSValueConst setter, int flags);
103static JSValue ConsoleSettingsGetProperty(JSContext* context, JSValueConst object, JSAtom propID, JSValueConst receiver);
104static int ConsoleSettingsSetProperty(JSContext* context, JSValueConst object, JSAtom propID, JSValueConst value, JSValueConst receiver, int flags);
105
106static JSClassDef sConsoleClass = {
107 .class_name = "Console",
108 .finalizer = OOJSObjectWrapperFinalize,
109};
110
111enum {
112 // Property IDs
113 kConsole_debugFlags, // debug flags, integer, read/write
114 kConsole_detailLevel, // graphics detail level, symbolic string, read/write
115 kConsole_maximumDetailLevel, // maximum graphics detail level, symbolic string, read-only
116 kConsole_displayFPS, // display FPS (and related info), boolean, read/write
117 kConsole_platformDescription, // Information about system we're running on in unspecified format, string, read-only
118 kConsole_ignoreDroppedPackets, // boolean (default false), read/write
119 kConsole_pedanticMode, // JS pedantic mode (JS_STRICT flag, not the same as "use strict"), boolean (default true), read/write
120 kConsole_showErrorLocations, // Show error/warning source locations, boolean (default true), read/write
121 kConsole_dumpStackForErrors, // Write stack dump when reporting error/exception, boolean (default false), read/write
122 kConsole_dumpStackForWarnings, // Write stack dump when reporting warning, boolean (default false), read/write
123
124 kConsole_glVendorString, // OpenGL GL_VENDOR string, string, read-only
125 kConsole_glRendererString, // OpenGL GL_RENDERER string, string, read-only
126 kConsole_glFixedFunctionTextureUnitCount, // GL_MAX_TEXTURE_UNITS_ARB, integer, read-only
127 kConsole_glFragmentShaderTextureUnitCount, // GL_MAX_TEXTURE_IMAGE_UNITS_ARB, integer, read-only
128
129 // Symbolic constants for debug flags:
130 kConsole_DEBUG_LINKED_LISTS,
131 kConsole_DEBUG_COLLISIONS,
132 kConsole_DEBUG_DOCKING,
133 kConsole_DEBUG_OCTREE_LOGGING,
134 kConsole_DEBUG_BOUNDING_BOXES,
135 kConsole_DEBUG_OCTREE_DRAW,
136 kConsole_DEBUG_DRAW_NORMALS,
137 kConsole_DEBUG_NO_DUST,
138 kConsole_DEBUG_NO_SHADER_FALLBACK,
139 kConsole_DEBUG_SHADER_VALIDATION,
140
141 kConsole_DEBUG_MISC
142};
143
144#define OOJS_PROPERTY_HIDDEN_RW(name, getter, setter, magic) JS_CGETSET_MAGIC_DEF2(name, getter, setter, magic, OOJS_PROP_HIDDEN_READWRITE_CB)
145
146static const JSCFunctionListEntry sConsoleProperties[] = {
147 // JS name Getter Setter ID
148 OOJS_PROPERTY_RW("debugFlags", ConsoleGetProperty, ConsoleSetProperty, kConsole_debugFlags),
149 OOJS_PROPERTY_RW("detailLevel", ConsoleGetProperty, ConsoleSetProperty, kConsole_detailLevel),
150 OOJS_PROPERTY_RO("maximumDetailLevel", ConsoleGetProperty, kConsole_maximumDetailLevel),
151 OOJS_PROPERTY_RW("displayFPS", ConsoleGetProperty, ConsoleSetProperty, kConsole_displayFPS),
152 OOJS_PROPERTY_RO("platformDescription", ConsoleGetProperty, kConsole_platformDescription),
153 OOJS_PROPERTY_RW("pedanticMode", ConsoleGetProperty, ConsoleSetProperty, kConsole_pedanticMode),
154 OOJS_PROPERTY_RW("ignoreDroppedPackets", ConsoleGetProperty, ConsoleSetProperty, kConsole_ignoreDroppedPackets),
155 OOJS_PROPERTY_HIDDEN_RW("__showErrorLocations", ConsoleGetProperty, ConsoleSetProperty, kConsole_showErrorLocations),
156 OOJS_PROPERTY_HIDDEN_RW("__dumpStackForErrors", ConsoleGetProperty, ConsoleSetProperty, kConsole_dumpStackForErrors),
157 OOJS_PROPERTY_HIDDEN_RW("__dumpStackForWarnings", ConsoleGetProperty, ConsoleSetProperty, kConsole_dumpStackForWarnings),
158 OOJS_PROPERTY_RO("glVendorString", ConsoleGetProperty, kConsole_glVendorString),
159 OOJS_PROPERTY_RO("glRendererString", ConsoleGetProperty, kConsole_glRendererString),
160 OOJS_PROPERTY_RO("glFixedFunctionTextureUnitCount", ConsoleGetProperty, kConsole_glFixedFunctionTextureUnitCount),
161 OOJS_PROPERTY_RO("glFragmentShaderTextureUnitCount", ConsoleGetProperty, kConsole_glFragmentShaderTextureUnitCount),
162
163#define DEBUG_FLAG_DECL(x) OOJS_PROPERTY_RO(#x, ConsoleGetProperty, kConsole_##x)
164 DEBUG_FLAG_DECL(DEBUG_LINKED_LISTS),
165 DEBUG_FLAG_DECL(DEBUG_COLLISIONS),
166 DEBUG_FLAG_DECL(DEBUG_DOCKING),
167 DEBUG_FLAG_DECL(DEBUG_OCTREE_LOGGING),
168 DEBUG_FLAG_DECL(DEBUG_BOUNDING_BOXES),
169 DEBUG_FLAG_DECL(DEBUG_OCTREE_DRAW),
170 DEBUG_FLAG_DECL(DEBUG_DRAW_NORMALS),
171 DEBUG_FLAG_DECL(DEBUG_NO_DUST),
172 DEBUG_FLAG_DECL(DEBUG_NO_SHADER_FALLBACK),
173 DEBUG_FLAG_DECL(DEBUG_SHADER_VALIDATION),
174
175 DEBUG_FLAG_DECL(DEBUG_MISC),
176#undef DEBUG_FLAG_DECL
177};
178
179static const JSCFunctionListEntry sConsoleMethods[] = {
180 // JS name Function min args
181 JS_CFUNC_DEF("consoleMessage", 2, ConsoleConsoleMessage),
182 JS_CFUNC_DEF("clearConsole", 0, ConsoleClearConsole),
183 JS_CFUNC_DEF("scriptStack", 0, ConsoleScriptStack),
184 JS_CFUNC_DEF("inspectEntity", 1, ConsoleInspectEntity),
185#if OO_DEBUG
186 JS_CFUNC_DEF("__setUpCallObjC", 1, ConsoleSetUpCallObjC),
187#endif
188 JS_CFUNC_DEF("isExecutableJavaScript", 2, ConsoleIsExecutableJavaScript),
189 JS_CFUNC_DEF("displayMessagesInClass", 1, ConsoleDisplayMessagesInClass),
190 JS_CFUNC_DEF("setDisplayMessagesInClass", 2, ConsoleSetDisplayMessagesInClass),
191 JS_CFUNC_DEF("writeLogMarker", 0, ConsoleWriteLogMarker),
192 JS_CFUNC_DEF("writeMemoryStats", 0, ConsoleWriteMemoryStats),
193 JS_CFUNC_DEF("writeJSMemoryStats", 0, ConsoleWriteJSMemoryStats),
194 JS_CFUNC_DEF("garbageCollect", 0, ConsoleGarbageCollect),
195#if DEBUG
196 JS_CFUNC_DEF("dumpHeap", 0, ConsoleDumpHeap),
197#endif
198#if OOJS_PROFILE
199 JS_CFUNC_DEF("profile", 1, ConsoleProfile),
200 JS_CFUNC_DEF("getProfile", 1, ConsoleGetProfile),
201 JS_CFUNC_DEF("trace", 1, ConsoleTrace),
202#endif
203};
204
205static JSClassExoticMethods sConsoleSettingsExoticMethods = {
206 .get_own_property = ConsoleSettingsGetOwnProperty,
207 .delete_property = ConsoleSettingsDeleteProperty,
208 .define_own_property = ConsoleSettingsDefineOwnProperty,
209 .get_property = ConsoleSettingsGetProperty,
210 .set_property = ConsoleSettingsSetProperty,
211};
212
213static JSClassDef sConsoleSettingsClass = {
214 .class_name = "ConsoleSettings",
215 .finalizer = OOJSObjectWrapperFinalize, // (same as Console)
216 .exotic = &sConsoleSettingsExoticMethods,
217};
218
219static void InitOOJSConsole(JSContext* context, JSValueConst global)
220{
221 OOJSRegisterClass(&sConsoleClassID, &sConsoleClass);
222 OOJSInitClass(context, global, sConsoleClassID, JS_UNDEFINED, OOJSUnconstructableConstruct, 0,
223 sConsoleProperties, OOJS_COUNT(sConsoleProperties), sConsoleMethods, OOJS_COUNT(sConsoleMethods), NULL, 0);
225
226 OOJSRegisterClass(&sConsoleSettingsClassID, &sConsoleSettingsClass);
227 OOJSInitClass(context, global, sConsoleSettingsClassID, JS_UNDEFINED, OOJSUnconstructableConstruct, 0,
228 NULL, 0, NULL, 0, NULL, 0);
230}
231
232JSValue DebugMonitorToJSConsole(JSContext* context, OODebugMonitor* monitor)
233{
235
236 // The classes belong to the context, so are set up again after every reset.
237 JSValue consolePrototype = (sConsoleClassID != 0) ? JS_GetClassProto(context, sConsoleClassID) : JS_NULL;
238 if (!JS_IsObject(consolePrototype)) {
239 JS_FreeValue(context, consolePrototype);
240 InitOOJSConsole(context, [[OOJavaScriptEngine sharedEngine] globalObject]);
241 consolePrototype = JS_GetClassProto(context, sConsoleClassID);
242 }
243
244 // Create Console object
245 JSValue object = JS_NewObjectProtoClass(context, consolePrototype, sConsoleClassID);
246 JS_FreeValue(context, consolePrototype);
247 if (JS_IsException(object)) {
249 return JS_NULL;
250 }
251 JS_SetOpaque(object, [monitor weakRetain]);
252
253 // Create ConsoleSettings object
254 JSValue settingsPrototype = JS_GetClassProto(context, sConsoleSettingsClassID);
255 JSValue settingsObject = JS_NewObjectProtoClass(context, settingsPrototype, sConsoleSettingsClassID);
256 JS_FreeValue(context, settingsPrototype);
257 if (JS_IsException(settingsObject)) {
259 JS_FreeValue(context, object);
260 return JS_NULL;
261 }
262 JS_SetOpaque(settingsObject, [monitor weakRetain]);
263
264 if (JS_SetPropertyStr(context, object, "settings", settingsObject) < 0) {
266 JS_FreeValue(context, object);
267 return JS_NULL;
268 }
269
270 return object;
271
273}
274
275static OODebugMonitor* MonitorForConsoleObject(JSContext* context, JSValueConst object, const char* function)
276{
277 id monitor = OOJSNativeObjectFromJSObject(context, object);
278 if (![monitor isKindOfClass:[OODebugMonitor class]]) {
279 OOJSReportError(context, @"Expected OODebugMonitor, got %@ in %s. %@", [monitor class], function, @"This is an internal error, please report it.");
280 return nil;
281 }
282 return monitor;
283}
284
285static JSValue ConsoleGetProperty(OOJS_GETTER_ARGS)
286{
287 OOJS_NATIVE_ENTER(context)
288
289 switch (magic) {
290#ifdef OO_DEBUG_MONITOR_ENABLED
291 case kConsole_debugFlags:
292 return JS_NewUint32(context, (uint32_t)gDebugFlags);
293#endif
294
295 case kConsole_detailLevel:
296 return [OOStringFromGraphicsDetail([UNIVERSE detailLevel]) oo_jsValueInContext:context];
297
298 case kConsole_maximumDetailLevel:
299 return [OOStringFromGraphicsDetail([[OOOpenGLExtensionManager sharedManager] maximumDetailLevel]) oo_jsValueInContext:context];
300
301 case kConsole_displayFPS:
302 return OOJSValueFromBOOL([UNIVERSE displayFPS]);
303
304 case kConsole_platformDescription:
306
307 case kConsole_pedanticMode:
308 return OOJSValueFromBOOL(sPedanticMode);
309
310 case kConsole_ignoreDroppedPackets:
311 return OOJSValueFromBOOL([[OODebugMonitor sharedDebugMonitor] TCPIgnoresDroppedPackets]);
312
313 case kConsole_showErrorLocations:
314 return OOJSValueFromBOOL([[OOJavaScriptEngine sharedEngine] showErrorLocations]);
315
316 case kConsole_dumpStackForErrors:
317 return OOJSValueFromBOOL([[OOJavaScriptEngine sharedEngine] dumpStackForErrors]);
318
319 case kConsole_dumpStackForWarnings:
320 return OOJSValueFromBOOL([[OOJavaScriptEngine sharedEngine] dumpStackForWarnings]);
321
322 case kConsole_glVendorString:
323 return OOJSValueFromNativeObject(context, [[OOOpenGLExtensionManager sharedManager] vendorString]);
324
325 case kConsole_glRendererString:
326 return OOJSValueFromNativeObject(context, [[OOOpenGLExtensionManager sharedManager] rendererString]);
327
328 case kConsole_glFixedFunctionTextureUnitCount:
329 return JS_NewInt32(context, [[OOOpenGLExtensionManager sharedManager] textureUnitCount]);
330
331 case kConsole_glFragmentShaderTextureUnitCount:
332 return JS_NewInt32(context, [[OOOpenGLExtensionManager sharedManager] textureImageUnitCount]);
333
334#define DEBUG_FLAG_CASE(x) \
335 case kConsole_##x: \
336 return JS_NewInt32(context, x);
337 DEBUG_FLAG_CASE(DEBUG_LINKED_LISTS);
338 DEBUG_FLAG_CASE(DEBUG_COLLISIONS);
339 DEBUG_FLAG_CASE(DEBUG_DOCKING);
340 DEBUG_FLAG_CASE(DEBUG_OCTREE_LOGGING);
341 DEBUG_FLAG_CASE(DEBUG_BOUNDING_BOXES);
342 DEBUG_FLAG_CASE(DEBUG_OCTREE_DRAW);
343 DEBUG_FLAG_CASE(DEBUG_DRAW_NORMALS);
344 DEBUG_FLAG_CASE(DEBUG_NO_DUST);
345 DEBUG_FLAG_CASE(DEBUG_NO_SHADER_FALLBACK);
346 DEBUG_FLAG_CASE(DEBUG_SHADER_VALIDATION);
347
348 DEBUG_FLAG_CASE(DEBUG_MISC);
349#undef DEBUG_FLAG_CASE
350
351 default:
352 OOJSReportBadPropertySelector(context, this, magic, sConsoleProperties, OOJS_COUNT(sConsoleProperties));
353 return OOJSNativeFailure(context);
354 }
355
357}
358
359static JSValue ConsoleSetProperty(OOJS_SETTER_ARGS)
360{
361 OOJS_NATIVE_ENTER(context)
362
363 int32_t iValue;
364 NSString* sValue;
365
366 switch (magic) {
367#ifdef OO_DEBUG_MONITOR_ENABLED
368 case kConsole_debugFlags:
369 if (OOJSValueToInt32(context, value, &iValue)) {
370 gDebugFlags = iValue;
371 }
372 break;
373#endif
374 case kConsole_detailLevel:
375 sValue = OOStringFromJSValue(context, value);
377 [UNIVERSE setDetailLevel:OOGraphicsDetailFromString(sValue)];
379 break;
380
381 case kConsole_displayFPS:
382 [UNIVERSE setDisplayFPS:OOJSValueToBOOL(context, value)];
383 break;
384
385 case kConsole_pedanticMode:
386 sPedanticMode = OOJSValueToBOOL(context, value);
387 break;
388
389 case kConsole_ignoreDroppedPackets:
390 [[OODebugMonitor sharedDebugMonitor] setTCPIgnoresDroppedPackets:OOJSValueToBOOL(context, value)];
391 break;
392
393 case kConsole_showErrorLocations:
394 [[OOJavaScriptEngine sharedEngine] setShowErrorLocations:OOJSValueToBOOL(context, value)];
395 break;
396
397 case kConsole_dumpStackForErrors:
398 [[OOJavaScriptEngine sharedEngine] setDumpStackForErrors:OOJSValueToBOOL(context, value)];
399 break;
400
401 case kConsole_dumpStackForWarnings:
402 [[OOJavaScriptEngine sharedEngine] setDumpStackForWarnings:OOJSValueToBOOL(context, value)];
403 break;
404
405 default:
406 OOJSReportBadPropertySelector(context, this, magic, sConsoleProperties, OOJS_COUNT(sConsoleProperties));
407 return OOJSNativeFailure(context);
408 }
409
410 return JS_UNDEFINED;
411
413}
414
415static BOOL DoWeDefineAllDebugFlags(enum OODebugFlags flags) GCC_ATTR((unused));
416static BOOL DoWeDefineAllDebugFlags(enum OODebugFlags flags)
417{
418 /* This function doesn't do anything, but will generate a warning
419 (Enumeration value 'DEBUG_FOO' not handled in switch) if a debug flag
420 is added without updating it. The point is that if you get such a
421 warning, you should first add a JS symbolic constant for the flag,
422 then add it to the switch to suppress the warning.
423 NOTE: don't add a default: to this switch, or I will have to hurt you.
424 -- Ahruman 2010-04-11
425 */
426 switch (flags) {
428 case DEBUG_COLLISIONS:
429 case DEBUG_DOCKING:
434 case DEBUG_NO_DUST:
437 case DEBUG_MISC:
438 return YES;
439 }
440
441 return NO;
442}
443
444// *** Settings ***
445
446/* The ConsoleSettings prototype is itself an instance of the class (see
447 OOJSInitClass()), but has no monitor. It has no settings: properties
448 defined on it while the class is set up, such as constructor, are
449 ignored, and reads fall through to Object.prototype.
450*/
451static BOOL IsSettingsPrototype(JSValueConst object)
452{
453 return JS_GetOpaque(object, sConsoleSettingsClassID) == NULL;
454}
455
456// Setting key for a string property ID, or nil for other IDs (symbols).
457static NSString* SettingKeyForPropertyID(JSContext* context, JSAtom propID)
458{
459 NSString* result = nil;
460 JSValue idValue = JS_AtomToValue(context, propID);
461 if (JS_IsString(idValue)) {
462 result = OOStringFromJSValue(context, idValue);
463 }
464 JS_FreeValue(context, idValue);
465 return result;
466}
467
468/* SpiderMonkey's get hook was called for every read; settings that don't
469 exist read as undefined, and settings are not reported as own properties
470 (the enumerate hook was a stub), so for-in and Object.keys() see nothing.
471*/
472static int ConsoleSettingsGetOwnProperty(JSContext* context, JSPropertyDescriptor* desc, JSValueConst object, JSAtom propID)
473{
474 return NO;
475}
476
477static JSValue ConsoleSettingsGetProperty(JSContext* context, JSValueConst object, JSAtom propID, JSValueConst receiver)
478{
479 OOJS_NATIVE_ENTER(context)
480
481 NSString* key = SettingKeyForPropertyID(context, propID);
482 if (key == nil || IsSettingsPrototype(object)) {
483 // Symbols, such as Symbol.toPrimitive: look them up on the prototype.
484 JSValue prototype = JS_GetPrototype(context, object);
485 JSValue result = JS_GetProperty(context, prototype, propID);
486 JS_FreeValue(context, prototype);
487 return result;
488 }
489
490 OODebugMonitor* monitor = MonitorForConsoleObject(context, object, __PRETTY_FUNCTION__);
491 if (monitor == nil)
492 return OOJSNativeFailure(context);
493
494 id settingValue = [monitor configurationValueForKey:key];
495 if (settingValue != nil)
496 return [settingValue oo_jsValueInContext:context];
497 return JS_UNDEFINED;
498
500}
501
502static int SetSetting(JSContext* context, JSValueConst object, JSAtom propID, JSValueConst value)
503{
504 NSString* key = SettingKeyForPropertyID(context, propID);
505 if (key == nil || IsSettingsPrototype(object))
506 return YES;
507
508 OODebugMonitor* monitor = MonitorForConsoleObject(context, object, __PRETTY_FUNCTION__);
509 if (monitor == nil)
510 return -1;
511
512 // Not OOJS_BEGIN_FULL_NATIVE() - we use JSAPI while paused.
514 if (JS_IsNull(value) || JS_IsUndefined(value)) {
515 [monitor setConfigurationValue:nil forKey:key];
516 } else {
517 id settingValue = OOJSNativeObjectFromJSValue(context, value);
518 if (settingValue != nil) {
519 [monitor setConfigurationValue:settingValue forKey:key];
520 } else {
521 OOJSReportWarning(context, @"debugConsole.settings: could not convert %@ to native object.", OOStringFromJSValue(context, value));
522 }
523 }
525
526 return YES;
527}
528
529static int ConsoleSettingsSetProperty(JSContext* context, JSValueConst object, JSAtom propID, JSValueConst value, JSValueConst receiver, int flags)
530{
531 @try {
532 return SetSetting(context, object, propID, value);
533 }
534 @catch (id exception) {
535 OOJSReportWrappedException(context, exception);
536 return -1;
537 }
538}
539
540// Object.defineProperty() and similar: treated as assignment of the value.
541static int ConsoleSettingsDefineOwnProperty(JSContext* context, JSValueConst object, JSAtom propID, JSValueConst value, JSValueConst getter, JSValueConst setter, int flags)
542{
543 @try {
544 if (!(flags & JS_PROP_HAS_VALUE))
545 return YES;
546 return SetSetting(context, object, propID, value);
547 }
548 @catch (id exception) {
549 OOJSReportWrappedException(context, exception);
550 return -1;
551 }
552}
553
554static int ConsoleSettingsDeleteProperty(JSContext* context, JSValueConst object, JSAtom propID)
555{
556 @try {
557 NSString* key = SettingKeyForPropertyID(context, propID);
558 if (key == nil || IsSettingsPrototype(object))
559 return NO;
560
561 OODebugMonitor* monitor = MonitorForConsoleObject(context, object, __PRETTY_FUNCTION__);
562 if (monitor == nil)
563 return -1;
564
565 [monitor setConfigurationValue:nil forKey:key];
566 return YES;
567 }
568 @catch (id exception) {
569 OOJSReportWrappedException(context, exception);
570 return -1;
571 }
572}
573
574// *** Methods ***
575
576// function consoleMessage(colorCode : String, message : String [, emphasisStart : Number, emphasisLength : Number]) : void
577static JSValue ConsoleConsoleMessage(OOJS_NATIVE_ARGS)
578{
579 NSRange emphasisRange = { 0, 0 };
580
581 OOJS_NATIVE_ENTER(context)
582
583 id monitor = nil;
584 NSString *colorKey = nil,
585 *message = nil;
586 double location, length;
587
588 // Not OOJS_BEGIN_FULL_NATIVE() - we use JSAPI while paused.
590 monitor = OOJSNativeObjectOfClassFromJSObject(context, OOJS_THIS, [OODebugMonitor class]);
591 if (monitor == nil) {
592 OOJSReportError(context, @"Expected OODebugMonitor, got %@ in %s. %@", [monitor class], __PRETTY_FUNCTION__, @"This is an internal error, please report it.");
594 return OOJSNativeFailure(context);
595 }
596
597 if (argc > 0)
598 colorKey = OOStringFromJSValue(context, OOJS_ARGV[0]);
599 if (argc > 1)
600 message = OOStringFromJSValue(context, OOJS_ARGV[1]);
601
602 if (argc > 3) {
603 // Attempt to get two numbers, specifying an emphasis range.
604 if (JS_ToFloat64(context, &location, OOJS_ARGV[2]) == 0 && JS_ToFloat64(context, &length, OOJS_ARGV[3]) == 0) {
605 emphasisRange = (NSRange) { location, length };
606 }
607 }
608
609 if (message == nil) {
610 if (colorKey == nil) {
611 OOJSReportWarning(context, @"Console.consoleMessage() called with no parameters.");
612 } else {
613 message = colorKey;
614 colorKey = @"command-result";
615 }
616 }
617
618 if (message != nil) {
619 [monitor appendJSConsoleLine:message
620 colorKey:colorKey
621 emphasisRange:emphasisRange];
622 }
624
626
628}
629
630// function clearConsole() : void
631static JSValue ConsoleClearConsole(OOJS_NATIVE_ARGS)
632{
633 OOJS_NATIVE_ENTER(context)
634
635 OODebugMonitor* monitor = MonitorForConsoleObject(context, OOJS_THIS, __PRETTY_FUNCTION__);
636 if (monitor == nil)
637 return OOJSNativeFailure(context);
638
639 [monitor clearJSConsole];
641
643}
644
645// function scriptStack() : Array
646static JSValue ConsoleScriptStack(OOJS_NATIVE_ARGS)
647{
648 OOJS_NATIVE_ENTER(context)
649
650 OOJS_RETURN_OBJECT([OOJSScript scriptStack]);
651
653}
654
655// function inspectEntity(entity : Entity) : void
656static JSValue ConsoleInspectEntity(OOJS_NATIVE_ARGS)
657{
658 OOJS_NATIVE_ENTER(context)
659
660 Entity* entity = nil;
661
662 if (argc > 0 && JSValueToEntity(context, OOJS_ARGV[0], &entity)) {
664 if ([entity respondsToSelector:@selector(inspect)]) {
665 [entity inspect];
666 }
668 }
669
671
673}
674
675#if OO_DEBUG
676// function callObjC(selector : String [, ...]) : Object
677static JSValue ConsoleCallObjCMethod(OOJS_NATIVE_ARGS)
678{
679 OOJS_NATIVE_ENTER(context)
680
681 id object = nil;
682 JSValue result;
683 BOOL OK;
684
685 object = OOJSNativeObjectFromJSObject(context, OOJS_THIS);
686 if (object == nil) {
687 OOJSReportError(context, @"Attempt to call __callObjCMethod() for non-Objective-C object %@.", OOStringFromJSValueEvenIfNull(context, OOJS_THIS));
688 return OOJSNativeFailure(context);
689 }
690
692 result = JS_UNDEFINED;
693 OK = OOJSCallObjCObjectMethod(context, object, [object oo_jsClassName], argc, OOJS_ARGV, &result);
695
696 if (!OK) {
697 JS_FreeValue(context, result);
698 return OOJSNativeFailure(context);
699 }
700 return result;
701
703}
704
705// function __setUpCallObjC(object) -- object is expected to be Object.prototye.
706static JSValue ConsoleSetUpCallObjC(OOJS_NATIVE_ARGS)
707{
708 OOJS_NATIVE_ENTER(context)
709
710 if (EXPECT_NOT(argc < 1 || !JS_IsObject(OOJS_ARGV[0]))) {
711 OOJSReportBadArguments(context, @"Console", @"__setUpCallObjC", argc, OOJS_ARGV, nil, @"Object.prototype");
712 return OOJSNativeFailure(context);
713 }
714
715 // Read-only, permanent and not enumerable, as OOJS_METHOD_READONLY was.
716 JSValue function = JS_NewCFunction(context, ConsoleCallObjCMethod, "callObjC", 1);
717 JS_DefinePropertyValueStr(context, OOJS_ARGV[0], "callObjC", function, 0);
719
721}
722#endif
723
724/* Like SpiderMonkey's JS_BufferIsCompilableUnit(): true unless the code fails
725 to compile only because it ends too soon, as when the console user is
726 part way through typing a multi-line function. Code with other syntax
727 errors is "executable" so that the error is reported when it's run.
728 QuickJS reports running out of input as an "end of" error (input,
729 string, comment, regexp) or an unexpected empty token, at the end of
730 the code.
731*/
732static BOOL IsIncompleteSyntaxError(JSContext* context, JSValueConst exception, NSString* code)
733{
734 if (!JS_IsError(exception))
735 return NO;
736
737 JSValue nameVal = JS_GetPropertyStr(context, exception, "name");
738 NSString* name = OOStringFromJSValue(context, nameVal);
739 JS_FreeValue(context, nameVal);
740 if (![name isEqualToString:@"SyntaxError"])
741 return NO;
742
743 JSValue messageVal = JS_GetPropertyStr(context, exception, "message");
744 NSString* message = OOStringFromJSValue(context, messageVal);
745 JS_FreeValue(context, messageVal);
746
747 if ([message rangeOfString:@"end of " options:NSCaseInsensitiveSearch].location != NSNotFound)
748 return YES;
749 if ([message hasSuffix:@"''"])
750 return YES;
751
752 // Otherwise, incomplete if the error is at the very end of the code.
753 JSValue stackVal = JS_GetPropertyStr(context, exception, "stack");
754 NSString* stack = OOStringFromJSValue(context, stackVal);
755 JS_FreeValue(context, stackVal);
756
757 NSArray* lines = [code componentsSeparatedByString:@"\n"];
758 NSString* endLocation = [NSString stringWithFormat:@"<console input>:%lu:%lu", (unsigned long)[lines count], (unsigned long)[[lines lastObject] length] + 1];
759 NSString* firstFrame = [[stack componentsSeparatedByString:@"\n"] firstObject];
760 return [firstFrame rangeOfString:endLocation].location != NSNotFound;
761}
762
763// function isExecutableJavaScript(this : Object, string : String) : Boolean
764static JSValue ConsoleIsExecutableJavaScript(OOJS_NATIVE_ARGS)
765{
766 OOJS_NATIVE_ENTER(context)
767
768 BOOL result = YES;
769
770 if (argc < 2 || !JS_IsObject(OOJS_ARGV[0]) || !JS_IsString(OOJS_ARGV[1])) {
771 OOJS_RETURN_BOOL(NO); // Fail silently
772 }
773
774 // Not OOJS_BEGIN_FULL_NATIVE() - we use JSAPI while paused.
776
777 NSString* string = OOStringFromJSValue(context, OOJS_ARGV[1]);
778 NSData* stringData = [string dataUsingEncoding:NSUTF8StringEncoding];
779 NSMutableData* source = [NSMutableData dataWithData:stringData];
780 [source appendBytes:"" length:1]; // JS_Eval() requires a terminating NUL.
781
782 JSValue compiled = JS_Eval(context, [source bytes], [stringData length], "<console input>", JS_EVAL_TYPE_GLOBAL | JS_EVAL_FLAG_COMPILE_ONLY);
783 if (JS_IsException(compiled)) {
784 JSValue exception = JS_GetException(context);
785 result = !IsIncompleteSyntaxError(context, exception, string);
786 JS_FreeValue(context, exception);
787 } else {
788 JS_FreeValue(context, compiled);
789 }
790
792
793 OOJS_RETURN_BOOL(result);
794
796}
797
798// function displayMessagesInClass(class : String) : Boolean
799static JSValue ConsoleDisplayMessagesInClass(OOJS_NATIVE_ARGS)
800{
801 OOJS_NATIVE_ENTER(context)
802
803 NSString* messageClass = nil;
804
805 if (argc > 0)
806 messageClass = OOStringFromJSValue(context, OOJS_ARGV[0]);
807 OOJS_RETURN_BOOL(messageClass != nil && OOLogWillDisplayMessagesInClass(messageClass));
808
810}
811
812// function setDisplayMessagesInClass(class : String, flag : Boolean) : void
813static JSValue ConsoleSetDisplayMessagesInClass(OOJS_NATIVE_ARGS)
814{
815 OOJS_NATIVE_ENTER(context)
816
817 NSString* messageClass = nil;
818
819 if (argc > 0)
820 messageClass = OOStringFromJSValue(context, OOJS_ARGV[0]);
821 if (messageClass != nil && argc > 1) {
822 OOLogSetDisplayMessagesInClass(messageClass, OOJSValueToBOOL(context, OOJS_ARGV[1]));
823 }
825
827}
828
829// function writeLogMarker() : void
830static JSValue ConsoleWriteLogMarker(OOJS_NATIVE_ARGS)
831{
832 OOJS_NATIVE_ENTER(context)
833
836
838}
839
840// function writeMemoryStats() : void
841static JSValue ConsoleWriteMemoryStats(OOJS_NATIVE_ARGS)
842{
843 OOJS_NATIVE_ENTER(context)
844
848
850
852}
853
854// function writeJSMemoryStats() : void
855static JSValue ConsoleWriteJSMemoryStats(OOJS_NATIVE_ARGS)
856{
857 OOJS_NATIVE_ENTER(context)
858
862
864
866}
867
868static size_t JSHeapSize(JSRuntime* runtime)
869{
870 JSMemoryUsage usage;
871 JS_ComputeMemoryUsage(runtime, &usage);
872 return (size_t)usage.malloc_size;
873}
874
875// function garbageCollect() : string
876static JSValue ConsoleGarbageCollect(OOJS_NATIVE_ARGS)
877{
878 OOJS_NATIVE_ENTER(context)
879
880 JSRuntime* runtime = JS_GetRuntime(context);
881 size_t bytesBefore = JSHeapSize(runtime);
882 JS_RunGC(runtime);
883 size_t bytesAfter = JSHeapSize(runtime);
884
885 OOJS_RETURN_OBJECT(([NSString stringWithFormat:@"Bytes before: %zu Bytes after: %zu", bytesBefore, bytesAfter]));
886
888}
889
890#if DEBUG
891static JSValue ConsoleDumpHeap(OOJS_NATIVE_ARGS)
892{
893 OOJS_NATIVE_ENTER(context)
894
895 BOOL OK = NO;
896 NSString* path = [[ResourceManager diagnosticFileLocation] stringByAppendingPathComponent:@"js-heaps.txt"];
897 FILE* file = fopen([path UTF8String], "w");
898 if (file != NULL) {
899 JSRuntime* runtime = JS_GetRuntime(context);
900 JSMemoryUsage usage;
901 JS_ComputeMemoryUsage(runtime, &usage);
902 JS_DumpMemoryUsage(file, &usage, runtime);
903 fclose(file);
904 OK = YES;
905 }
906
908
910}
911#endif
912
913#if OOJS_PROFILE
914
915// function profile(func : function [, Object this = debugConsole.script]) : String
916static JSValue ConsoleProfile(OOJS_NATIVE_ARGS)
917{
918 OOJS_NATIVE_ENTER(context)
919
920 if (EXPECT_NOT(OOJSIsProfiling())) {
921 OOJSReportError(context, @"Profiling functions may not be called while already profiling.");
922 return OOJSNativeFailure(context);
923 }
924
925 NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
926 OOTimeProfile* profile = nil;
927 JSValue result = JS_UNDEFINED;
928
929 if (PerformProfiling(context, @"profile", argc, OOJS_ARGV, NULL, NO, &profile)) {
930 result = OOJSValueFromNativeObject(context, [profile description]);
931 } else {
932 result = OOJSNativeFailure(context);
933 }
934
935 [pool release];
936 return result;
937
939}
940
941// function getProfile(func : function [, Object this = debugConsole.script]) : Object { totalTime : Number, jsTime : Number, extensionTime : Number }
942static JSValue ConsoleGetProfile(OOJS_NATIVE_ARGS)
943{
944 OOJS_NATIVE_ENTER(context)
945
946 if (EXPECT_NOT(OOJSIsProfiling())) {
947 OOJSReportError(context, @"Profiling functions may not be called while already profiling.");
948 return OOJSNativeFailure(context);
949 }
950
951 NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
952 OOTimeProfile* profile = nil;
953 JSValue result = JS_UNDEFINED;
954
955 if (PerformProfiling(context, @"getProfile", argc, OOJS_ARGV, NULL, NO, &profile)) {
956 result = OOJSValueFromNativeObject(context, profile);
957 } else {
958 result = OOJSNativeFailure(context);
959 }
960
961 [pool release];
962 return result;
963
965}
966
967// function trace(func : function [, Object this = debugConsole.script]) : [return type of func]
968static JSValue ConsoleTrace(OOJS_NATIVE_ARGS)
969{
970 OOJS_NATIVE_ENTER(context)
971
972 if (EXPECT_NOT(OOJSIsProfiling())) {
973 OOJSReportError(context, @"Profiling functions may not be called while already profiling.");
974 return OOJSNativeFailure(context);
975 }
976
977 NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
978 JSValue rval = JS_UNDEFINED;
979 JSValue result;
980
981 if (PerformProfiling(context, @"trace", argc, OOJS_ARGV, &rval, YES, NULL)) {
982 result = rval;
983 } else {
984 result = OOJSNativeFailure(context);
985 }
986
987 [pool release];
988 return result;
989
991}
992
993/* Calls argv[0] with argv[1] (or debugConsole.script) as this, profiling it.
994 *outRval, if not NULL, is owned by the caller. On failure, any exception
995 has been reported.
996*/
997static BOOL PerformProfiling(JSContext* context, NSString* nominalFunction, int argc, JSValueConst* argv, JSValue* outRval, BOOL trace, OOTimeProfile** outProfile)
998{
999 // Get function.
1000 if (argc < 1 || !OOJSValueIsFunction(context, argv[0])) {
1001 OOJSReportBadArguments(context, @"Console", nominalFunction, MIN(argc, 1), argv, nil, @"function");
1002 return NO;
1003 }
1004 JSValueConst function = argv[0];
1005
1006 // Get "this" object.
1007 JSValue this;
1008 if (argc > 1)
1009 this = JS_DupValue(context, argv[1]);
1010 else {
1011 JSValue debugConsole = OOJSValueFromNativeObject(context, [OODebugMonitor sharedDebugMonitor]);
1012 this = JS_GetPropertyStr(context, debugConsole, "script");
1013 JS_FreeValue(context, debugConsole);
1014 }
1015
1016 // Fiddle with time limiter.
1017 // We want to save the current limit, reset the limiter, and set the time limit to a long time.
1018#define LONG_TIME (1e7) // A long time - 115.7 days - but, crucially, finite.
1019
1020 OOTimeDelta originalLimit = OOJSGetTimeLimiterLimit();
1021 OOJSSetTimeLimiterLimit(LONG_TIME);
1023
1024 OOJSBeginProfiling(trace);
1025
1026 // Call the function.
1027 JSValue rval = JS_Call(context, function, this, 0, NULL);
1028
1029 // Get results.
1030 OOTimeProfile* profile = OOJSEndProfiling();
1031 if (outProfile != NULL)
1032 *outProfile = profile;
1033
1034 // Restore original timer state.
1035 OOJSSetTimeLimiterLimit(originalLimit);
1037
1038 JS_FreeValue(context, this);
1039
1040 if (JS_IsException(rval)) {
1042 return NO;
1043 }
1044
1045 if (outRval != NULL)
1046 *outRval = rval;
1047 else
1048 JS_FreeValue(context, rval);
1049 return YES;
1050}
1051
1052#endif // OOJS_PROFILE
1053
1054#endif /* OO_DEBUG_MONITOR_ENABLED */
#define gDebugFlags
OODebugFlags
Definition OODebugFlags.h:3
@ DEBUG_COLLISIONS
Definition OODebugFlags.h:6
@ DEBUG_NO_DUST
@ DEBUG_DOCKING
Definition OODebugFlags.h:7
@ DEBUG_SHADER_VALIDATION
@ DEBUG_MISC
@ DEBUG_OCTREE_LOGGING
Definition OODebugFlags.h:8
@ DEBUG_OCTREE_DRAW
@ DEBUG_NO_SHADER_FALLBACK
@ DEBUG_DRAW_NORMALS
@ DEBUG_LINKED_LISTS
Definition OODebugFlags.h:4
@ DEBUG_BOUNDING_BOXES
#define EXPECT_NOT(x)
#define GCC_ATTR(x)
JSObject * DebugMonitorToJSConsole(JSContext *context, OODebugMonitor *monitor)
#define OOJS_PROFILE_EXIT
#define OOJS_END_FULL_NATIVE
#define OOJS_BEGIN_FULL_NATIVE(context)
#define OOJS_NATIVE_ENTER(cx)
#define OOJS_NATIVE_EXIT
#define OOJS_PROFILE_ENTER
void OOJSResetTimeLimiter(void)
OOTimeDelta OOJSGetTimeLimiterLimit(void)
void OOJSSetTimeLimiterLimit(OOTimeDelta limit)
BOOL JSValueToEntity(JSContext *context, jsval value, Entity **outEntity)
Definition OOJSEntity.m:133
void OOJSPauseTimeLimiter(void)
id OOJSNativeObjectFromJSValue(JSContext *context, jsval value)
void OOJSReportWarning(JSContext *context, NSString *format,...)
#define OOJS_THIS
void OOJSRegisterObjectConverter(JSClass *theClass, OOJSClassConverterCallback converter)
OOINLINE jsval OOJSValueFromNativeObject(JSContext *context, id object)
id OOJSNativeObjectFromJSObject(JSContext *context, JSObject *object)
OOINLINE BOOL OOJSValueToBOOL(JSContext *context, jsval value)
void OOJSObjectWrapperFinalize(JSContext *context, JSObject *this)
#define OOJS_RETURN_OBJECT(o)
void OOJSReportBadPropertySelector(JSContext *context, JSObject *thisObj, jsid propID, JSPropertySpec *propertySpec)
#define OOJS_RETURN_BOOL(v)
OOINLINE BOOL OOJSValueToInt32(JSContext *context, jsval value, int32_t *outValue)
NSString * OOStringFromJSValue(JSContext *context, jsval value)
JSBool OOJSUnconstructableConstruct(JSContext *context, uintN argc, jsval *vp)
OOINLINE BOOL OOJSValueIsFunction(JSContext *context, jsval value)
OOINLINE void OOJSReportPendingException(JSContext *context)
void OOJSReportError(JSContext *context, NSString *format,...)
#define OOJS_ARGV
OOINLINE jsval OOJSValueFromBOOL(int b) INLINE_CONST_FUNC
NSString * OOStringFromJSValueEvenIfNull(JSContext *context, jsval value)
id OOJSBasicPrivateObjectConverter(JSContext *context, JSObject *object)
void OOJSReportBadArguments(JSContext *context, NSString *scriptClass, NSString *function, uintN argc, jsval *argv, NSString *message, NSString *expectedArgsDescription)
void OOJSResumeTimeLimiter(void)
#define OOJS_RETURN_VOID
id OOJSNativeObjectOfClassFromJSObject(JSContext *context, JSObject *object, Class requiredClass)
void OOJSReportWrappedException(JSContext *context, id exception)
NSString * OOPlatformDescription(void)
BOOL OOLogWillDisplayMessagesInClass(NSString *inMessageClass)
Definition OOLogging.m:136
void OOLogSetDisplayMessagesInClass(NSString *inClass, BOOL inFlag)
Definition OOLogging.m:172
void OOLogInsertMarker(void)
Definition OOLogging.m:581
#define MIN(A, B)
Definition OOMaths.h:91
return nil
double OOTimeDelta
Definition OOTypes.h:193
#define OOJS_PROPERTY_RW(name, getter, setter, magic)
JSValue OOJSNativeFailure(JSContext *context)
JSClassID OOJSRegisterClass(JSClassID *ioClassID, const JSClassDef *classDef)
Definition OOJSClasses.m:61
#define OOJS_SETTER_ARGS
#define OOJS_PROPERTY_RO(name, getter, magic)
JSValueConst OOJSInitClass(JSContext *context, JSValueConst global, JSClassID classID, JSValueConst parentPrototype, JSCFunction *constructor, int constructorArgCount, const JSCFunctionListEntry *properties, size_t propertyCount, const JSCFunctionListEntry *methods, size_t methodCount, const JSCFunctionListEntry *staticMethods, size_t staticMethodCount)
#define OOJS_GETTER_ARGS
#define OOJS_NATIVE_ARGS
#define OOJS_COUNT(array)
#define UNIVERSE
Definition Universe.h:827
void dumpMemoryStatistics()
void setTCPIgnoresDroppedPackets:(BOOL flag)
size_t dumpJSMemoryStatistics()
OODebugMonitor * sharedDebugMonitor()
void setShowErrorLocations:(BOOL value)
OOJavaScriptEngine * sharedEngine()
OOOpenGLExtensionManager * sharedManager()
NSString * diagnosticFileLocation()
id configurationValueForKey:(in NSString *key)
void setConfigurationValue:forKey:(in id value,[forKey] in NSString *key)