blob: 63bcf4039f48416e2aadb245ce24b5e827b89d2e (
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
81
82
83
84
85
|
/* -------------------------------------------
Copyright ZKA Technologies.
File: rt.internal.inl
Purpose: Base code of XPCOM.
------------------------------------------- */
/// @internal
#ifndef __NDK__
#define object class
#define protocol class
#define clsid(X)
#warning ! You may be using the clang version of the ZKAKit, please be cautious that some features mayn't be present. !
#endif // !__NDK__
protocol IUnknown; // Refrenced from an IDB entry.
protocol UnknownUCLSID; // From the IDB, the constructor of the object, e.g: TextUCLSID.
object UUID;
/// @brief Unknown XPCOM interface
protocol clsid("d7c144b6-0792-44b8-b06b-02b227b547df") IUnknown
{
public:
explicit IUnknown() = default;
virtual ~IUnknown() = default;
IUnknown& operator=(const IUnknown&) = default;
IUnknown(const IUnknown&) = default;
virtual SInt32 Release() = 0;
virtual void RemoveRef() = 0;
virtual IUnknown* AddRef() = 0;
virtual VoidPtr QueryInterface(UUID * p_uuid) = 0;
};
/// @brief Allocate new XPCOM object.
/// @tparam TCLS the class type.
/// @tparam UCLSID UCLS factory class type.
/// @param uclsidOfCls UCLS factory class
/// @return TCLS interface
template <typename TCLS, typename UCLSID, typename... Args>
inline TCLS* XPCOMQueryInterface(UCLSID* uclsidOfCls, Args&&... args)
{
uclsidOfCls->AddRef();
return uclsidOfCls->QueryInterfaceWithArgs(args...);
}
/// @brief Release XPCOM object.
/// @tparam TCLS the class type.
/// @param cls the class to release.
/// @return status code.
template <typename TCLS>
inline SInt32 XPCOMReleaseClass(TCLS** cls)
{
if (!cls)
return -1;
cls->RemoveRef();
cls->Release();
cls = nullptr;
return 0;
}
template <typename FnSign, typename ClsID>
protocol IEventListener : public ClsID
{
public:
explicit IEventListener() = default;
virtual ~IEventListener() = default;
IEventListener& operator=(const IEventListener&) = default;
IEventListener(const IEventListener&) = default;
virtual IEventListener& operator+=(FnSign arg)
{
this->AddEventListener(arg);
return *this;
}
};
|