mirror of
git://xwords.git.sourceforge.net/gitroot/xwords/xwords
synced 2025-01-28 07:58:08 +01:00
debug functions to turn enums and defines into loggable strings
This commit is contained in:
parent
7c2e09cca5
commit
57f2f4ba2a
2 changed files with 100 additions and 0 deletions
71
xwords4/common/dbgutil.c
Normal file
71
xwords4/common/dbgutil.c
Normal file
|
@ -0,0 +1,71 @@
|
|||
/* -*-mode: C; fill-column: 78; c-basic-offset: 4; -*- */
|
||||
/*
|
||||
* Copyright 2006 by Eric House (xwords@eehouse.org). All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
#include "dbgutil.h"
|
||||
|
||||
#define CASESTR(s) case s: return #s
|
||||
|
||||
#define FUNC(f) #f
|
||||
|
||||
const char*
|
||||
XP_Key_2str( XP_Key key )
|
||||
{
|
||||
switch( key ) {
|
||||
CASESTR(XP_KEY_NONE);
|
||||
CASESTR(XP_CURSOR_KEY_DOWN);
|
||||
CASESTR(XP_CURSOR_KEY_RIGHT);
|
||||
CASESTR(XP_CURSOR_KEY_UP);
|
||||
CASESTR(XP_CURSOR_KEY_LEFT);
|
||||
CASESTR(XP_CURSOR_KEY_DEL);
|
||||
CASESTR(XP_FOCUSCHANGE_KEY);
|
||||
CASESTR(XP_RETURN_KEY);
|
||||
CASESTR(XP_KEY_LAST );
|
||||
default: return FUNC(__FUNCTION__) " unknown";
|
||||
}
|
||||
}
|
||||
|
||||
const char*
|
||||
DrawFocusState_2str( DrawFocusState dfs )
|
||||
{
|
||||
switch( dfs ) {
|
||||
CASESTR(DFS_NONE);
|
||||
CASESTR(DFS_TOP);
|
||||
CASESTR(DFS_DIVED);
|
||||
default: return FUNC(__FUNCTION__) " unknown";
|
||||
}
|
||||
}
|
||||
|
||||
const char*
|
||||
BoardObjectType_2str( BoardObjectType obj )
|
||||
{
|
||||
switch( obj ) {
|
||||
CASESTR(OBJ_NONE);
|
||||
CASESTR(OBJ_BOARD);
|
||||
CASESTR(OBJ_SCORE);
|
||||
CASESTR(OBJ_TRAY);
|
||||
default: return FUNC(__FUNCTION__) " unknown";
|
||||
}
|
||||
}
|
||||
|
||||
#undef CASESTR
|
||||
|
||||
#endif /* DEBUG */
|
||||
|
29
xwords4/common/dbgutil.h
Normal file
29
xwords4/common/dbgutil.h
Normal file
|
@ -0,0 +1,29 @@
|
|||
/* -*-mode: C; fill-column: 78; c-basic-offset: 4; -*- */
|
||||
/*
|
||||
* Copyright 2006 by Eric House (xwords@eehouse.org). All rights reserved.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU General Public License
|
||||
* as published by the Free Software Foundation; either version 2
|
||||
* of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||
*/
|
||||
|
||||
#ifndef _DBGUTIL_H_
|
||||
#define _DBGUTIL_H_
|
||||
|
||||
#include "board.h"
|
||||
|
||||
const char* XP_Key_2str( XP_Key key );
|
||||
const char* DrawFocusState_2str( DrawFocusState dfs );
|
||||
const char* BoardObjectType_2str( BoardObjectType dfs );
|
||||
|
||||
#endif
|
Loading…
Add table
Reference in a new issue