Added symbolic constants (or the closest you can get in JavaScript) for debug flags to console object.
git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@3143 127b21dd-08f5-0310-b4b7-95ae10353056
This commit is contained in:
parent
d3dca497f2
commit
a84f5cc45f
@ -19,23 +19,24 @@ The console object has the following properties and methods:
|
||||
debugFlags : Number (integer, read/write)
|
||||
An integer bit mask specifying various debug options. The flags vary
|
||||
between builds, but at the time of writing they are:
|
||||
DEBUG_LINKED_LISTS: 0x1
|
||||
DEBUG_ENTITIES: 0x2
|
||||
DEBUG_COLLISIONS: 0x4
|
||||
DEBUG_DOCKING: 0x8
|
||||
DEBUG_OCTREE: 0x10
|
||||
DEBUG_OCTREE_TEXT: 0x20
|
||||
DEBUG_BOUNDING_BOXES: 0x40
|
||||
DEBUG_OCTREE_DRAW: 0x80
|
||||
DEBUG_DRAW_NORMALS: 0x100
|
||||
DEBUG_NO_DUST: 0x200
|
||||
console.DEBUG_LINKED_LISTS
|
||||
console.DEBUG_ENTITIES
|
||||
console.DEBUG_COLLISIONS
|
||||
console.DEBUG_DOCKING
|
||||
console.DEBUG_OCTREE
|
||||
console.DEBUG_OCTREE_TEXT
|
||||
console.DEBUG_BOUNDING_BOXES
|
||||
console.DEBUG_OCTREE_DRAW
|
||||
console.DEBUG_DRAW_NORMALS
|
||||
console.DEBUG_NO_DUST
|
||||
console.DEBUG_NO_SHADER_FALLBACK
|
||||
The current flags can be seen in Entity.h in the Oolite source code,
|
||||
for instance at:
|
||||
http://svn.berlios.de/svnroot/repos/oolite-linux/trunk/src/Core/Entities/Entity.h
|
||||
For example, to enable rendering of bounding boxes and surface normals,
|
||||
you might use:
|
||||
console.debugFlags ^= 0x40
|
||||
console.debugFlags ^= 0x100
|
||||
console.debugFlags ^= console.DEBUG_BOUNDING_BOXES
|
||||
console.debugFlags ^= console.DEBUG_DRAW_NORMALS
|
||||
Explaining bitwise operations is beyond the scope of this comment, but
|
||||
the ^= operator (XOR assign) can be thought of as a “toggle option”
|
||||
command.
|
||||
|
@ -104,6 +104,21 @@ enum
|
||||
kConsole_glVendorString, // OpenGL GL_VENDOR string, string, read-only
|
||||
kConsole_glRendererString, // OpenGL GL_RENDERER string, string, read-only
|
||||
kConsole_platformDescription, // Information about system we're running on in unspecified format, string, read-only
|
||||
|
||||
// Symbolic constants for debug flags:
|
||||
kConsole_DEBUG_LINKED_LISTS,
|
||||
kConsole_DEBUG_ENTITIES,
|
||||
kConsole_DEBUG_COLLISIONS,
|
||||
kConsole_DEBUG_DOCKING,
|
||||
kConsole_DEBUG_OCTREE,
|
||||
kConsole_DEBUG_OCTREE_TEXT,
|
||||
kConsole_DEBUG_BOUNDING_BOXES,
|
||||
kConsole_DEBUG_OCTREE_DRAW,
|
||||
kConsole_DEBUG_DRAW_NORMALS,
|
||||
kConsole_DEBUG_NO_DUST,
|
||||
kConsole_DEBUG_NO_SHADER_FALLBACK,
|
||||
|
||||
kConsole_DEBUG_MISC
|
||||
};
|
||||
|
||||
|
||||
@ -116,6 +131,23 @@ static JSPropertySpec sConsoleProperties[] =
|
||||
{ "glVendorString", kConsole_glVendorString, JSPROP_PERMANENT | JSPROP_ENUMERATE | JSPROP_READONLY },
|
||||
{ "glRendererString", kConsole_glRendererString, JSPROP_PERMANENT | JSPROP_ENUMERATE | JSPROP_READONLY },
|
||||
{ "platformDescription", kConsole_platformDescription, JSPROP_PERMANENT | JSPROP_ENUMERATE | JSPROP_READONLY },
|
||||
|
||||
#define DEBUG_FLAG_DECL(x) { #x, kConsole_##x, JSPROP_PERMANENT | JSPROP_ENUMERATE | JSPROP_READONLY }
|
||||
DEBUG_FLAG_DECL(DEBUG_LINKED_LISTS),
|
||||
DEBUG_FLAG_DECL(DEBUG_ENTITIES),
|
||||
DEBUG_FLAG_DECL(DEBUG_COLLISIONS),
|
||||
DEBUG_FLAG_DECL(DEBUG_DOCKING),
|
||||
DEBUG_FLAG_DECL(DEBUG_OCTREE),
|
||||
DEBUG_FLAG_DECL(DEBUG_OCTREE_TEXT),
|
||||
DEBUG_FLAG_DECL(DEBUG_BOUNDING_BOXES),
|
||||
DEBUG_FLAG_DECL(DEBUG_OCTREE_DRAW),
|
||||
DEBUG_FLAG_DECL(DEBUG_DRAW_NORMALS),
|
||||
DEBUG_FLAG_DECL(DEBUG_NO_DUST),
|
||||
DEBUG_FLAG_DECL(DEBUG_NO_SHADER_FALLBACK),
|
||||
|
||||
DEBUG_FLAG_DECL(DEBUG_MISC),
|
||||
#undef DEBUG_FLAG_DECL
|
||||
|
||||
{ 0 }
|
||||
};
|
||||
|
||||
@ -241,6 +273,22 @@ static JSBool ConsoleGetProperty(JSContext *context, JSObject *this, jsval name,
|
||||
*outValue = [OOPlatformDescription() javaScriptValueInContext:context];
|
||||
break;
|
||||
|
||||
#define DEBUG_FLAG_CASE(x) case kConsole_##x: *outValue = INT_TO_JSVAL(x); break;
|
||||
DEBUG_FLAG_CASE(DEBUG_LINKED_LISTS);
|
||||
DEBUG_FLAG_CASE(DEBUG_ENTITIES);
|
||||
DEBUG_FLAG_CASE(DEBUG_COLLISIONS);
|
||||
DEBUG_FLAG_CASE(DEBUG_DOCKING);
|
||||
DEBUG_FLAG_CASE(DEBUG_OCTREE);
|
||||
DEBUG_FLAG_CASE(DEBUG_OCTREE_TEXT);
|
||||
DEBUG_FLAG_CASE(DEBUG_BOUNDING_BOXES);
|
||||
DEBUG_FLAG_CASE(DEBUG_OCTREE_DRAW);
|
||||
DEBUG_FLAG_CASE(DEBUG_DRAW_NORMALS);
|
||||
DEBUG_FLAG_CASE(DEBUG_NO_DUST);
|
||||
DEBUG_FLAG_CASE(DEBUG_NO_SHADER_FALLBACK);
|
||||
|
||||
DEBUG_FLAG_CASE(DEBUG_MISC);
|
||||
#undef DEBUG_FLAG_CASE
|
||||
|
||||
default:
|
||||
OOReportJSBadPropertySelector(context, @"Console", JSVAL_TO_INT(name));
|
||||
return NO;
|
||||
@ -293,6 +341,39 @@ static JSBool ConsoleSetProperty(JSContext *context, JSObject *this, jsval name,
|
||||
}
|
||||
|
||||
|
||||
static BOOL DoWeDefineAllDebugFlags(enum OODebugFlags flags) GCC_ATTR((unused));
|
||||
static BOOL DoWeDefineAllDebugFlags(enum OODebugFlags flags)
|
||||
{
|
||||
/* This function doesn't do anything, but will generate a warning
|
||||
(Enumeration value 'DEBUG_FOO' not handled in switch) if a debug flag
|
||||
is added without updating it. The point is that if you get such a
|
||||
warning, you should first add a JS symbolic constant for the flag,
|
||||
then add it to the switch to supress the warning.
|
||||
NOTE: don't add a default: to this switch, or I will have to hurt you.
|
||||
-- Ahruman 2010-04-11
|
||||
*/
|
||||
switch (flags)
|
||||
{
|
||||
case DEBUG_LINKED_LISTS:
|
||||
case DEBUG_ENTITIES:
|
||||
case DEBUG_COLLISIONS:
|
||||
case DEBUG_DOCKING:
|
||||
case DEBUG_OCTREE:
|
||||
case DEBUG_OCTREE_TEXT:
|
||||
case DEBUG_BOUNDING_BOXES:
|
||||
case DEBUG_OCTREE_DRAW:
|
||||
case DEBUG_DRAW_NORMALS:
|
||||
case DEBUG_NO_DUST:
|
||||
case DEBUG_NO_SHADER_FALLBACK:
|
||||
|
||||
case DEBUG_MISC:
|
||||
return YES;
|
||||
}
|
||||
|
||||
return NO;
|
||||
}
|
||||
|
||||
|
||||
static void ConsoleFinalize(JSContext *context, JSObject *this)
|
||||
{
|
||||
[(id)JS_GetPrivate(context, this) release];
|
||||
|
@ -36,18 +36,24 @@ MA 02110-1301, USA.
|
||||
|
||||
#ifndef NDEBUG
|
||||
|
||||
enum OODebugFlags
|
||||
{
|
||||
DEBUG_LINKED_LISTS = 0x00000001,
|
||||
DEBUG_ENTITIES = 0x00000002,
|
||||
DEBUG_COLLISIONS = 0x00000004,
|
||||
DEBUG_DOCKING = 0x00000008,
|
||||
DEBUG_OCTREE = 0x00000010,
|
||||
DEBUG_OCTREE_TEXT = 0x00000020,
|
||||
DEBUG_BOUNDING_BOXES = 0x00000040,
|
||||
DEBUG_OCTREE_DRAW = 0x00000080,
|
||||
DEBUG_DRAW_NORMALS = 0x00000100,
|
||||
DEBUG_NO_DUST = 0x00000200,
|
||||
DEBUG_NO_SHADER_FALLBACK = 0x00000400,
|
||||
|
||||
// Flag for temporary use, always last in list.
|
||||
DEBUG_MISC = 0x10000000
|
||||
};
|
||||
#define DEBUG_ALL 0xffffffff
|
||||
#define DEBUG_LINKED_LISTS 0x00000001
|
||||
#define DEBUG_ENTITIES 0x00000002
|
||||
#define DEBUG_COLLISIONS 0x00000004
|
||||
#define DEBUG_DOCKING 0x00000008
|
||||
#define DEBUG_OCTREE 0x00000010
|
||||
#define DEBUG_OCTREE_TEXT 0x00000020
|
||||
#define DEBUG_BOUNDING_BOXES 0x00000040
|
||||
#define DEBUG_OCTREE_DRAW 0x00000080
|
||||
#define DEBUG_DRAW_NORMALS 0x00000100
|
||||
#define DEBUG_NO_DUST 0x00000200
|
||||
#define DEBUG_MISC 0x10000000
|
||||
|
||||
|
||||
extern uint32_t gDebugFlags;
|
||||
|
Loading…
x
Reference in New Issue
Block a user