-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvmdefines.h
41 lines (34 loc) · 1.39 KB
/
vmdefines.h
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
//Contains general definitions and macros for virtual mouse. This is most
//likely included in every virtual mouse file.
//Author: Edwin Heerschap
#ifndef VM_DEFINES_H
#define VM_DEFINES_H
#include "vmdebug.h"
#define VM_ERROR 1 // Non-fatal error
#define VM_FATAL -1 //Fatal error
#define VM_SUCCESS 0 // =D
//Object call definitions. Call object methods on themselves
//in different manners. //////////////////////////
#define VM_POC_R_(self, call) self->call(self); // POC = Pointer object call
#define VM_POC_C_(self, call) self->call(self*); // R = reference, C = copy
#define VM_OC_R_(self, call) self.call(&self); // OC = Object call
#define VM_OC_C_(self, call) self.call(self); // APOC = Argument POC
// AOC = Argument OC
#define VM_APOC_R_(self, call, args...) self->call(self, args);
#define VM_APOC_C_(self, call, args...) self->call(self*, args);
#define VM_AOC_R_(self, call, args...) self.call(&self, args);
#define VM_AOC_C_(self, call, args...) self.call(self, args);
//Checks if fields are null before attempting to call "call".
#define NULL_CHECK_CALL_SELF(ptr, call) \
if (ptr != NULL) { \
if (ptr->call != NULL) { \
VM_POC_R_(ptr, call) \
} \
else { \
VM_DEBUG("NULL_CHECK_CALL passed ptr -> call is NULL\n"); \
} \
} \
else { \
VM_DEBUG("NULL_CHECK_CALL passed ptr is NULL!\n"); \
}
#endif