OLD | NEW |
1 // Copyright (c) 2011 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium OS Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef POWER_MANAGER_SIGNAL_CALLBACK_H_ | 5 #ifndef POWER_MANAGER_SIGNAL_CALLBACK_H_ |
6 #define POWER_MANAGER_SIGNAL_CALLBACK_H_ | 6 #define POWER_MANAGER_SIGNAL_CALLBACK_H_ |
7 | 7 |
8 // These macros provide a wrapper around class methods so they can be used as | 8 // These macros provide a wrapper around class methods so they can be used as |
9 // callbacks. | 9 // callbacks. |
10 | 10 |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 static RETURN METHOD ## Thunk(void* data) { \ | 101 static RETURN METHOD ## Thunk(void* data) { \ |
102 METHOD ## Args* args = reinterpret_cast<METHOD ## Args*>(data); \ | 102 METHOD ## Args* args = reinterpret_cast<METHOD ## Args*>(data); \ |
103 CLASS* obj = args->obj; \ | 103 CLASS* obj = args->obj; \ |
104 TYPE0 arg0 = args->arg0; \ | 104 TYPE0 arg0 = args->arg0; \ |
105 TYPE0 arg1 = args->arg1; \ | 105 TYPE0 arg1 = args->arg1; \ |
106 delete args; \ | 106 delete args; \ |
107 return obj->METHOD(arg0, arg1); \ | 107 return obj->METHOD(arg0, arg1); \ |
108 } \ | 108 } \ |
109 RETURN METHOD(TYPE0, TYPE1); | 109 RETURN METHOD(TYPE0, TYPE1); |
110 | 110 |
| 111 // This macro defines a function pointer for the thunk functions defined by |
| 112 // the above macros. |
| 113 // |
| 114 // Usage example: |
| 115 // SIGNAL_CALLBACK_PTR(bool, callback_func); |
| 116 // is equivalent to: |
| 117 // bool (*callback_func)((void*) |
| 118 |
| 119 #define SIGNAL_CALLBACK_PTR(RETURN, NAME) RETURN (*NAME)(void*) |
| 120 |
111 #endif // POWER_MANAGER_SIGNAL_CALLBACK_H_ | 121 #endif // POWER_MANAGER_SIGNAL_CALLBACK_H_ |
OLD | NEW |