home *** CD-ROM | disk | FTP | other *** search
Text File | 1996-09-17 | 4.5 KB | 173 lines | [TEXT/MPS ] |
- //========================================================================================
- //
- // File: FWPriDeb.cpp
- // Release Version: $ ODF 2 $
- //
- // Copyright: (c) 1993-1996 by Apple Computer, Inc., all rights reserved.
- //
- //========================================================================================
-
- #include "FWFound.hpp"
-
- // Need to include first so that FW_DEBUG is properly defined
-
- #ifndef FWPRIDEB_H
- #include "FWPriDeb.h"
- #endif
-
- #ifndef FWPRISTR_H
- #include "FWPriStr.h"
- #endif
-
- #ifndef FWPRIMEM_H
- #include "FWPriMem.h"
- #endif
-
- #if defined(FW_BUILD_MAC) && !defined(__TYPES__)
- #include <Types.h>
- #endif
-
- #if defined(THINK_CPLUS) && !defined(__PASCAL__)
- #include <Pascal.h>
- #endif
-
- #if defined(FW_BUILD_WIN) && !defined(_INC_WINDOWS)
- #include <Windows.h>
- #endif
-
- #ifdef FW_BUILD_MAC
- #pragma segment FWDebug
- #endif
-
-
- //----------------------------------------------------------------------------------------
- // privDebugger
- //----------------------------------------------------------------------------------------
- extern "C" void privDebugger(FW_SDebugConsole* self);
-
- void privDebugger(FW_SDebugConsole* self)
- {
- FW_UNUSED(self);
- #if defined(FW_BUILD_WIN)
- #ifndef FW_BUILD_DOS
- ::DebugBreak();
- #endif
-
- #elif defined(FW_BUILD_MAC)
- ::Debugger();
- #endif
- }
-
- #if defined(FW_BUILD_MAC) && !defined(CGLUESUPPORTED)
- //----------------------------------------------------------------------------------------
- // fwctop
- //----------------------------------------------------------------------------------------
-
- static void fwctop(char* s)
- {
- int len = FW_PrimitiveStringLength(s);
- FW_PrimitiveCopyMemory(s, s+1, len);
- s[0] = len;
- }
-
- //----------------------------------------------------------------------------------------
- // fwptoc
- //----------------------------------------------------------------------------------------
-
- static void fwptoc(char* s)
- {
- int len = s[0];
- FW_PrimitiveCopyMemory(s+1, s, len);
- s[len] = 0;
- }
-
- //----------------------------------------------------------------------------------------
- // debugstr
- //----------------------------------------------------------------------------------------
- static void debugstr(const char *message)
- {
- fwctop((char*) message);
- DebugStr((const unsigned char*) message);
- fwptoc((char*) message);
- }
- #endif
-
- //----------------------------------------------------------------------------------------
- // privDebugMessage
- //----------------------------------------------------------------------------------------
- extern "C" void privDebugMessage(FW_SDebugConsole* self, const char* message);
-
-
- void privDebugMessage(FW_SDebugConsole* self, const char* message)
- {
- #if defined(FW_BUILD_WIN)
- #ifndef FW_BUILD_DOS
- char crlf[3] = {0x0D, 0x0A, 0x00};
- ::OutputDebugString(message);
- ::OutputDebugString(crlf);
- ::DebugBreak();
- if (self->fPrivate != 0)
- {
- ::OutputDebugString("Oh, by the way, self->fPrivate should be 0");
- ::OutputDebugString(crlf);
- ::DebugBreak();
- }
- #endif
-
- #elif defined(FW_BUILD_MAC)
- ::debugstr(message);
- if (self->fPrivate != 0)
- ::debugstr("Oh, by the way, self->fPrivate should be 0");
- #endif
- }
-
-
- //----------------------------------------------------------------------------------------
- // If FW_DEBUG is defined, there is a default debug console. The default console uses
- // whatever debugging packages are available. If FW_DEBUG is undefined, there is no
- // default debug console.
- //----------------------------------------------------------------------------------------
- #ifdef FW_DEBUG
- #define FW_DEBUG_CONSOLE &sDebugConsole
-
- static FW_SDebugConsole sDebugConsole =
- {
- privDebugMessage,
- privDebugMessage,
- privDebugMessage,
- privDebugMessage,
- privDebugger
- };
- #else
- #define FW_DEBUG_CONSOLE {0}
- #endif
-
-
-
- static FW_SDebugConsole *gDebugConsole = FW_DEBUG_CONSOLE;
-
-
- //----------------------------------------------------------------------------------------
- // FW_PrivDebugConsole_GetConsole
- //----------------------------------------------------------------------------------------
-
- FW_EXPORT FW_SDebugConsole* FW_PrivDebugConsole_GetConsole()
- {
- // No try block necessary - Do not throw
- return gDebugConsole;
- }
-
- //----------------------------------------------------------------------------------------
- // FW_PrivDebugConsole_SetConsole
- //----------------------------------------------------------------------------------------
-
- FW_EXPORT FW_SDebugConsole* FW_PrivDebugConsole_SetConsole(FW_SDebugConsole* console)
- {
- // No try block necessary - Do not throw
- FW_SDebugConsole* prior = gDebugConsole;
- gDebugConsole = console;
- return prior;
- }
-
-
-