|
21 | 21 | m_context *c = map_get(ctx, (char *)name); \ |
22 | 22 | MOD_ASSERT(c, "Context not found.", MOD_NO_CTX); |
23 | 23 |
|
| 24 | +#define GET_CTX_PRIV(self) m_context *c = self->ctx |
24 | 25 | /* |
25 | 26 | * Convenience macro to retrieve self->ctx + doing some checks. |
26 | 27 | * Skip reference check for pure functions. |
27 | 28 | */ |
28 | 29 | #define _GET_CTX(self, pure) \ |
29 | 30 | MOD_ASSERT(self, "NULL self handler.", MOD_NO_SELF); \ |
30 | 31 | MOD_ASSERT(!self->is_ref || pure, "Self is a reference object. It does not own module.", MOD_REF_ERR); \ |
31 | | - m_context *c = self->ctx; \ |
| 32 | + GET_CTX_PRIV(self); \ |
32 | 33 | MOD_ASSERT(c, "Context not found.", MOD_NO_CTX); |
33 | 34 |
|
| 35 | +/* Convenience macros for exposed API */ |
34 | 36 | #define GET_CTX(self) _GET_CTX(self, false) |
35 | 37 | #define GET_CTX_PURE(self) _GET_CTX(self, true) |
36 | 38 |
|
|
39 | 41 | module *mod = map_get(ctx->modules, (char *)name); \ |
40 | 42 | MOD_ASSERT(mod, "Module not found.", MOD_NO_MOD); |
41 | 43 |
|
| 44 | +#define GET_MOD_PRIV(self) module *mod = self->mod |
42 | 45 | /* |
43 | 46 | * Convenience macro to retrieve self->mod + doing some checks. |
44 | 47 | * Skip reference check for pure functions. |
45 | 48 | */ |
46 | 49 | #define _GET_MOD(self, pure) \ |
47 | 50 | MOD_ASSERT(self, "NULL self handler.", MOD_NO_SELF); \ |
48 | 51 | MOD_ASSERT(!self->is_ref || pure, "Self is a reference object. It does not own module.", MOD_REF_ERR); \ |
49 | | - module *mod = self->mod; \ |
| 52 | + GET_MOD_PRIV(self); \ |
50 | 53 | MOD_ASSERT(mod, "Module not found.", MOD_NO_MOD); |
51 | 54 |
|
| 55 | +/* Convenience macros for exposed API */ |
52 | 56 | #define GET_MOD(self) _GET_MOD(self, false) |
53 | 57 | #define GET_MOD_PURE(self) _GET_MOD(self, true) |
54 | 58 |
|
|
0 commit comments