os_object_base.h
2.11 KB
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
#ifndef _OS_BASE_H
#define _OS_BASE_H
#define OS_CONSUME __attribute__((os_consumed))
#define OS_RETURNS_RETAINED __attribute__((os_returns_retained))
#define OS_RETURNS_RETAINED_ON_ZERO __attribute__((os_returns_retained_on_zero))
#define OS_RETURNS_RETAINED_ON_NONZERO __attribute__((os_returns_retained_on_non_zero))
#define OS_RETURNS_NOT_RETAINED __attribute__((os_returns_not_retained))
#define OS_CONSUMES_THIS __attribute__((os_consumes_this))
#define OSTypeID(type) (type::metaClass)
#define OSDynamicCast(type, inst) \
((type *) OSMetaClassBase::safeMetaCast((inst), OSTypeID(type)))
#define OSRequiredCast(type, inst) \
((type *) OSMetaClassBase::requiredMetaCast((inst), OSTypeID(type)))
#define OSTypeAlloc(type) ((type *) ((type::metaClass)->alloc()))
using size_t = decltype(sizeof(int));
typedef int kern_return_t;
struct IORPC {};
struct OSMetaClass;
struct OSMetaClassBase {
static OSMetaClassBase *safeMetaCast(const OSMetaClassBase *inst,
const OSMetaClass *meta);
static OSMetaClassBase *requiredMetaCast(const OSMetaClassBase *inst,
const OSMetaClass *meta);
OSMetaClassBase *metaCast(const char *toMeta);
virtual void retain() const;
virtual void release() const;
virtual void taggedRetain(const void * tag = nullptr) const;
virtual void taggedRelease(const void * tag = nullptr) const;
virtual void free();
virtual ~OSMetaClassBase(){};
kern_return_t Invoke(IORPC invoke);
};
typedef kern_return_t (*OSDispatchMethod)(OSMetaClassBase *self,
const IORPC rpc);
struct OSObject : public OSMetaClassBase {
virtual ~OSObject(){}
unsigned int foo() { return 42; }
virtual OS_RETURNS_NOT_RETAINED OSObject *identity();
static OSObject *generateObject(int);
static OSObject *getObject();
static OSObject *GetObject();
static void * operator new(size_t size);
static const OSMetaClass * const metaClass;
};
struct OSMetaClass : public OSMetaClassBase {
virtual OSObject * alloc() const;
virtual ~OSMetaClass(){}
};
#endif /* _OS_BASE_H */