Continued work on profiler

This commit is contained in:
Victor Olin 2023-03-06 11:59:28 +01:00
parent 137687e446
commit 0d376171c8
6 changed files with 56 additions and 2 deletions

44
src/GC/tests/events.cpp Normal file
View file

@ -0,0 +1,44 @@
#include <iostream>
#include <stdio.h>
using namespace std;
// broken :(
// [event_source(native)]
class ESource {
public:
__event void TestEvent(int eValue);
};
// [event_receiver(native)]
class EReceiver {
public:
void Handler1(int eValue) {
cout << "Handler1 with: " << eValue << endl;
}
void Handler2(int eValue) {
cout << "Handler2 with: " << eValue << endl;
}
void hookEvent(ESource *eSource) {
__hook(&ESource::TestEvent, eSource, &EReceiver::Handler1);
__hook(&ESource::TestEvent, eSource, &EReceiver::Handler2);
}
void unhookEvent(ESource *eSource) {
__unhook(&ESource::TestEvent, eSource, &EReceiver::Handler1);
__unhook(&ESource::TestEvent, eSource, &EReceiver::Handler2);
}
};
int main() {
ESource src;
EReceiver rcv;
rcv.hookEvent(&src);
__raise src.TestEvent(12);
rcv.unhookEvent(&src);
return 0;
}