Oh right forgot to clean up error stuff from zOLD.
This commit is contained in:
parent
e3a4d34196
commit
9e05efa091
|
@ -1,21 +0,0 @@
|
|||
// 13 may 2016
|
||||
#include "../ui.h"
|
||||
#include "uipriv.h"
|
||||
|
||||
void uiprivDoImplBug(const char *file, const char *line, const char *func, const char *format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, format);
|
||||
uiprivRealBug(file, line, func, "POSSIBLE IMPLEMENTATION BUG; CONTACT ANDLABS:\n", format, ap);
|
||||
va_end(ap);
|
||||
}
|
||||
|
||||
void uiprivDoUserBug(const char *file, const char *line, const char *func, const char *format, ...)
|
||||
{
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, format);
|
||||
uiprivRealBug(file, line, func, "You have a bug: ", format, ap);
|
||||
va_end(ap);
|
||||
}
|
|
@ -12,28 +12,6 @@ extern "C" {
|
|||
// OS-specific init.* or main.* files
|
||||
extern uiInitOptions uiprivOptions;
|
||||
|
||||
// OS-specific alloc.* files
|
||||
extern void *uiprivAlloc(size_t, const char *);
|
||||
#define uiprivNew(T) ((T *) uiprivAlloc(sizeof (T), #T))
|
||||
extern void *uiprivRealloc(void *, size_t, const char *);
|
||||
extern void uiprivFree(void *);
|
||||
|
||||
// debug.c and OS-specific debug.* files
|
||||
// TODO get rid of this mess...
|
||||
// ugh, __func__ was only introduced in MSVC 2015...
|
||||
#ifdef _MSC_VER
|
||||
#define uiprivMacro__func__ __FUNCTION__
|
||||
#else
|
||||
#define uiprivMacro__func__ __func__
|
||||
#endif
|
||||
extern void uiprivRealBug(const char *file, const char *line, const char *func, const char *prefix, const char *format, va_list ap);
|
||||
#define uiprivMacro_ns2(s) #s
|
||||
#define uiprivMacro_ns(s) uiprivMacro_ns2(s)
|
||||
extern void uiprivDoImplBug(const char *file, const char *line, const char *func, const char *format, ...);
|
||||
#define uiprivImplBug(...) uiprivDoImplBug(__FILE__, uiprivMacro_ns(__LINE__), uiprivMacro__func__, __VA_ARGS__)
|
||||
extern void uiprivDoUserBug(const char *file, const char *line, const char *func, const char *format, ...);
|
||||
#define uiprivUserBug(...) uiprivDoUserBug(__FILE__, uiprivMacro_ns(__LINE__), uiprivMacro__func__, __VA_ARGS__)
|
||||
|
||||
// shouldquit.c
|
||||
extern int uiprivShouldQuit(void);
|
||||
|
||||
|
|
|
@ -1,19 +0,0 @@
|
|||
// 13 may 2016
|
||||
#import "uipriv_darwin.h"
|
||||
|
||||
// LONGTERM don't halt on release builds
|
||||
|
||||
void uiprivRealBug(const char *file, const char *line, const char *func, const char *prefix, const char *format, va_list ap)
|
||||
{
|
||||
NSMutableString *str;
|
||||
NSString *formatted;
|
||||
|
||||
str = [NSMutableString new];
|
||||
[str appendString:[NSString stringWithFormat:@"[libui] %s:%s:%s() %s", file, line, func, prefix]];
|
||||
formatted = [[NSString alloc] initWithFormat:[NSString stringWithUTF8String:format] arguments:ap];
|
||||
[str appendString:formatted];
|
||||
[formatted release];
|
||||
NSLog(@"%@", str);
|
||||
[str release];
|
||||
__builtin_trap();
|
||||
}
|
|
@ -1,14 +0,0 @@
|
|||
// 13 may 2016
|
||||
#include "uipriv_unix.h"
|
||||
|
||||
// LONGTERM don't halt on release builds
|
||||
|
||||
void uiprivRealBug(const char *file, const char *line, const char *func, const char *prefix, const char *format, va_list ap)
|
||||
{
|
||||
char *a, *b;
|
||||
|
||||
a = g_strdup_printf("[libui] %s:%s:%s() %s", file, line, func, prefix);
|
||||
b = g_strdup_vprintf(format, ap);
|
||||
g_critical("%s%s", a, b);
|
||||
G_BREAKPOINT();
|
||||
}
|
|
@ -1,84 +0,0 @@
|
|||
// 25 february 2015
|
||||
#include "uipriv_windows.hpp"
|
||||
|
||||
// LONGTERM disable logging and stopping on no-debug builds
|
||||
|
||||
static void printDebug(const WCHAR *msg)
|
||||
{
|
||||
OutputDebugStringW(msg);
|
||||
}
|
||||
|
||||
HRESULT _logLastError(debugargs, const WCHAR *s)
|
||||
{
|
||||
DWORD le;
|
||||
WCHAR *msg;
|
||||
WCHAR *formatted;
|
||||
BOOL useFormatted;
|
||||
|
||||
le = GetLastError();
|
||||
|
||||
useFormatted = FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, le, 0, (LPWSTR) (&formatted), 0, NULL) != 0;
|
||||
if (!useFormatted)
|
||||
formatted = (WCHAR *) L"\n"; // TODO
|
||||
msg = strf(L"[libui] %s:%s:%s() %s: GetLastError() == %I32u %s",
|
||||
file, line, func,
|
||||
s, le, formatted);
|
||||
if (useFormatted)
|
||||
LocalFree(formatted); // ignore error
|
||||
printDebug(msg);
|
||||
uiprivFree(msg);
|
||||
DebugBreak();
|
||||
|
||||
SetLastError(le);
|
||||
// a function does not have to set a last error
|
||||
// if the last error we get is actually 0, then HRESULT_FROM_WIN32(0) will return S_OK (0 cast to an HRESULT, since 0 <= 0), which we don't want
|
||||
// prevent this by returning E_FAIL
|
||||
if (le == 0)
|
||||
return E_FAIL;
|
||||
return HRESULT_FROM_WIN32(le);
|
||||
}
|
||||
|
||||
HRESULT _logHRESULT(debugargs, const WCHAR *s, HRESULT hr)
|
||||
{
|
||||
WCHAR *msg;
|
||||
WCHAR *formatted;
|
||||
BOOL useFormatted;
|
||||
|
||||
useFormatted = FormatMessageW(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS, NULL, hr, 0, (LPWSTR) (&formatted), 0, NULL) != 0;
|
||||
if (!useFormatted)
|
||||
formatted = (WCHAR *) L"\n"; // TODO
|
||||
msg = strf(L"[libui] %s:%s:%s() %s: HRESULT == 0x%08I32X %s",
|
||||
file, line, func,
|
||||
s, hr, formatted);
|
||||
if (useFormatted)
|
||||
LocalFree(formatted); // ignore error
|
||||
printDebug(msg);
|
||||
uiprivFree(msg);
|
||||
DebugBreak();
|
||||
|
||||
return hr;
|
||||
}
|
||||
|
||||
void uiprivRealBug(const char *file, const char *line, const char *func, const char *prefix, const char *format, va_list ap)
|
||||
{
|
||||
va_list ap2;
|
||||
char *msg;
|
||||
size_t n;
|
||||
WCHAR *final;
|
||||
|
||||
va_copy(ap2, ap);
|
||||
n = _vscprintf(format, ap2);
|
||||
va_end(ap2);
|
||||
n++; // terminating '\0'
|
||||
|
||||
msg = (char *) uiprivAlloc(n * sizeof (char), "char[]");
|
||||
// includes terminating '\0' according to example in https://msdn.microsoft.com/en-us/library/xa1a1a6z.aspx
|
||||
vsprintf_s(msg, n, format, ap);
|
||||
|
||||
final = strf(L"[libui] %hs:%hs:%hs() %hs%hs\n", file, line, func, prefix, msg);
|
||||
uiprivFree(msg);
|
||||
printDebug(final);
|
||||
uiprivFree(final);
|
||||
|
||||
DebugBreak();
|
||||
}
|
|
@ -41,28 +41,6 @@ extern void CRLFtoLF(char *s);
|
|||
extern WCHAR *ftoutf16(double d);
|
||||
extern WCHAR *itoutf16(int i);
|
||||
|
||||
// debug.cpp
|
||||
// see http://stackoverflow.com/questions/14421656/is-there-widely-available-wide-character-variant-of-file
|
||||
// we turn __LINE__ into a string because PRIiMAX can't be converted to a wide string in MSVC (it seems to be defined as "ll" "i" according to the compiler errors)
|
||||
// also note the use of __FUNCTION__ here; __func__ doesn't seem to work for some reason
|
||||
#define _ws2(m) L ## m
|
||||
#define _ws(m) _ws2(m)
|
||||
#define _ws2n(m) L ## #m
|
||||
#define _wsn(m) _ws2n(m)
|
||||
#define debugargs const WCHAR *file, const WCHAR *line, const WCHAR *func
|
||||
extern HRESULT _logLastError(debugargs, const WCHAR *s);
|
||||
#ifdef _MSC_VER
|
||||
#define logLastError(s) _logLastError(_ws(__FILE__), _wsn(__LINE__), _ws(__FUNCTION__), s)
|
||||
#else
|
||||
#define logLastError(s) _logLastError(_ws(__FILE__), _wsn(__LINE__), L"TODO none of the function name macros are macros in MinGW", s)
|
||||
#endif
|
||||
extern HRESULT _logHRESULT(debugargs, const WCHAR *s, HRESULT hr);
|
||||
#ifdef _MSC_VER
|
||||
#define logHRESULT(s, hr) _logHRESULT(_ws(__FILE__), _wsn(__LINE__), _ws(__FUNCTION__), s, hr)
|
||||
#else
|
||||
#define logHRESULT(s, hr) _logHRESULT(_ws(__FILE__), _wsn(__LINE__), L"TODO none of the function name macros are macros in MinGW", s, hr)
|
||||
#endif
|
||||
|
||||
// winutil.cpp
|
||||
extern int windowClassOf(HWND hwnd, ...);
|
||||
extern void mapWindowRect(HWND from, HWND to, RECT *r);
|
||||
|
|
Loading…
Reference in New Issue