summaryrefslogtreecommitdiff
path: root/include/JSystem/JGadget/define.h
blob: bf219aa731b070eaccfde5dd2cf922e111d5901e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#ifndef DEFINE_H
#define DEFINE_H

#include "dolphin/types.h"

#ifdef __cplusplus
extern "C" {

class JGadget_outMessage {
public:
    typedef void (*MessageFunc)(const char*, int, const char*);

    static void warning(const char*, int, const char*) {
        /* Nonmatching - debug only */
    }

    JGadget_outMessage(MessageFunc fn, const char* file, int line) {
        /* Nonmatching - debug only */
    }
    ~JGadget_outMessage() {
        /* Nonmatching - debug only */
    }

    JGadget_outMessage& operator<<(int param_1) { return *this << (s32)param_1; }
    JGadget_outMessage& operator<<(u16);
    JGadget_outMessage& operator<<(unsigned int);
    JGadget_outMessage& operator<<(u8);
    JGadget_outMessage& operator<<(const char* str) {
        /* Nonmatching - debug only */
        return *this;
    }
    JGadget_outMessage& operator<<(s8);
    JGadget_outMessage& operator<<(s32);
    JGadget_outMessage& operator<<(u32);
    JGadget_outMessage& operator<<(const void*);

private:
    MessageFunc mMsgFunc;
    char mBuffer[256];
    char* mWrite_p;
    char* mFile;
    int mLine;
};

#ifdef DEBUG
// these macros are probably wrong, needs work
#define JGADGET_ASSERTWARN(line, COND) \
    if (!(COND)) {                                                            \
        JGadget_outMessage out(JGadget_outMessage::warning, __FILE__, line);  \
        out << #COND;                                                         \
    }

#define JGADGET_WARNMSG(line, msg)                                            \
        JGadget_outMessage out(JGadget_outMessage::warning, __FILE__, line);  \
        out << msg;

#define JGADGET_WARNMSG1(line, msg, arg)                                      \
        JGadget_outMessage out(JGadget_outMessage::warning, __FILE__, line);  \
        out << msg << (arg);

#define JGADGET_WARNMSG4(line, msg, arg1, arg2, arg3, arg4)                   \
        JGadget_outMessage out(JGadget_outMessage::warning, __FILE__, line);  \
        out << msg << (arg1) << (arg2) << (arg3) << (arg4);

#define JGADGET_EXITWARN(cond)                                                                     \
    if (!(cond)) {                                                                                 \
        false;                                                                                     \
        return false;                                                                              \
    }
#else
#define JGADGET_ASSERTWARN(line, COND) (void)0
#define JGADGET_WARNMSG(line, msg) (void)0
#define JGADGET_WARNMSG1(line, msg, arg) (void)0
#define JGADGET_WARNMSG4(line, msg, arg1, arg2, arg3, arg4) (void)0
#endif

} // extern "C"
#endif

#endif