main
Last change
on this file since 6bd7144 was c2a9854, checked in by Adrien Destugues <pulkomandy@…>, 12 years ago |
WIP explorer
- Fill in the block list
- HexEditor in progress.
Commiting because I'm trying to improve iupplusplus and want to make sure I can revert it if I fail.
git-svn-id: svn://localhost/thomson@16 85ae3b6b-dc8f-4344-a89d-598714f2e4e5
|
-
Property mode
set to
100644
|
File size:
1.1 KB
|
Rev | Line | |
---|
[f9263dd] | 1 | /* CrO2 datassette emulator
|
---|
| 2 | * Copyright 2012, Adrien Destugues <pulkomandy@pulkomandy.ath.cx>
|
---|
| 3 | *
|
---|
| 4 | * Distributed under the terms of the MIT licence.
|
---|
| 5 | */
|
---|
| 6 |
|
---|
| 7 | #include <iup.h>
|
---|
| 8 |
|
---|
[c2a9854] | 9 | template<class Handler, typename ret = int, typename... Args> class Callback
|
---|
[f9263dd] | 10 | {
|
---|
[c2a9854] | 11 | typedef ret(Handler::*T)(Args... args);
|
---|
[f9263dd] | 12 |
|
---|
| 13 | public:
|
---|
| 14 | static int destroy(Ihandle* that)
|
---|
| 15 | {
|
---|
| 16 | Callback* call = (Callback*)IupGetAttribute(that, "LCALLBACK");
|
---|
| 17 | delete call;
|
---|
| 18 | return IUP_DEFAULT;
|
---|
| 19 | }
|
---|
| 20 |
|
---|
| 21 | static void create(Ihandle* handle, const char* name, Handler* self, T what)
|
---|
| 22 | {
|
---|
| 23 | Callback* cb = new Callback(self, what);
|
---|
| 24 | IupSetAttribute(handle, "LCALLBACK", (char*)cb);
|
---|
| 25 | IupSetCallback(handle, name, (Icallback)Callback::call);
|
---|
| 26 | IupSetCallback(handle, "LDESTROY_CB", Callback::destroy);
|
---|
| 27 | }
|
---|
| 28 |
|
---|
[c2a9854] | 29 | static ret call(Ihandle* that, Args... args)
|
---|
[f9263dd] | 30 | {
|
---|
| 31 | Callback* call = (Callback*)IupGetAttribute(that, "LCALLBACK");
|
---|
| 32 | return ((call->self)->*(call->what))(args...);
|
---|
| 33 | }
|
---|
| 34 |
|
---|
| 35 | private:
|
---|
| 36 | Callback(Handler* self, T what)
|
---|
| 37 | {
|
---|
| 38 | this->self = self;
|
---|
| 39 | this->what = what;
|
---|
| 40 | }
|
---|
| 41 |
|
---|
| 42 | Callback(); // do not use
|
---|
| 43 |
|
---|
| 44 | Handler* self;
|
---|
| 45 | T what;
|
---|
| 46 | };
|
---|
| 47 |
|
---|
Note:
See
TracBrowser
for help on using the repository browser.