SMG-Decomp
A decompilation of Super Mario Galaxy 1
Loading...
Searching...
No Matches
Functor.hpp
1#pragma once
2
3#include "Inline.hpp"
4
5class JKRHeap;
6
7namespace MR {
8 class FunctorBase {
9 public:
10 virtual void operator()() const = 0;
11 virtual FunctorBase* clone(JKRHeap *) const = 0;
12 };
13
14 template<typename T, typename U>
15 class FunctorV0M : public FunctorBase {
16 public:
17
18 inline FunctorV0M(T call, U callee)
19 : mCaller(call), mCallee(callee) {
20 }
21
22 inline FunctorV0M() {
23
24 }
25
26 virtual void operator()() const {
27 (mCaller->*mCallee)();
28 }
29
30 virtual FunctorBase* clone(JKRHeap *pHeap) const {
31 return new (pHeap, 0x16) FunctorV0M(*this);
32 };
33
34 T mCaller;
35 U mCallee;
36 };
37
38 template<typename T, typename U, typename V>
39 class FunctorV1M : public FunctorBase {
40 public:
41 inline FunctorV1M(T call, U callee, V arg_0) {
42 mCaller = call;
43 mCallee = callee;
44 mArg0 = arg_0;
45 }
46
47 inline FunctorV1M() {
48
49 }
50
51 virtual void operator()() const {
52 (mCaller->*mCallee)(mArg0);
53 }
54
55 virtual FunctorBase* clone(JKRHeap *pHeap) const {
56 return new (pHeap, 0x16) FunctorV1M(*this);
57 };
58
59 T mCaller;
60 U mCallee;
61 V mArg0;
62 };
63
64 template<typename T, typename U, typename V, typename W>
65 class FunctorV2M : public FunctorBase {
66 public:
67 inline FunctorV2M(T call, U callee, V arg_0, W arg_1) {
68 mCaller = call;
69 mCallee = callee;
70 mArg0 = arg_0;
71 mArg1 = arg_1;
72 }
73
74 inline FunctorV2M() {
75
76 }
77
78 virtual void operator()() const {
79 (mCaller->*mCallee)(mArg0, mArg1);
80 }
81
82 virtual FunctorBase* clone(JKRHeap *pHeap) const {
83 return new (pHeap, 0x16) FunctorV2M(*this);
84 };
85
86 T mCaller;
87 U mCallee;
88 V mArg0;
89 W mArg1;
90 };
91
92 template<class T>
93 static FunctorV0M<T *, void (T::*)()> Functor(T* a1, void (T::*a2)()) NO_INLINE {
94 return FunctorV0M<T *, void (T::*)()>(a1, a2);
95 }
96
97 template<class T>
98 inline static FunctorV0M<T *, void (T::*)()> Functor_Inline(T* a1, void (T::*a2)()) {
99 return FunctorV0M<T *, void (T::*)()>(a1, a2);
100 }
101
102 template<class T, typename U>
103 static FunctorV1M<T *, void (T::*)(U), U> Functor(T* a1, void (T::*a2)(U), U arg_0) {
104 return FunctorV1M<T *, void (T::*)(U), U>(a1, a2, arg_0);
105 }
106
107 template<class T, typename U, typename V>
108 static FunctorV2M<T *, void (T::*)(U, V), U, V> Functor(T* a1, void (T::*a2)(U, V), U arg_0, V arg_1) {
109 return FunctorV2M<T *, void (T::*)(U, V), U, V>(a1, a2, arg_0, arg_1);
110 }
111
112 class FunctorV0F : public FunctorBase {
113 public:
114 inline FunctorV0F(void (*func)(void)) {
115 mFunc = func;
116 };
117
118 virtual void operator()() const;
119 virtual FunctorBase* clone(JKRHeap *) const;
120
121 void* mFunc; // _4
122 };
123};