LibJuno 0.35.0
LibJuno is a lightweight C99 library designed specifically for embedded systems.
Loading...
Searching...
No Matches
module.h
Go to the documentation of this file.
1/*
2 MIT License
3
4 Copyright (c) 2025 Robin A. Onsay
5
6 Permission is hereby granted, free of charge, to any person obtaining
7 a copy of this software and associated documentation files
8 (the "Software"), to deal in the Software without restriction,
9 including without limitation the rights to use, copy, modify, merge,
10 publish, distribute, sublicense, and/or sell copies of the Software,
11 and to permit persons to whom the Software is furnished to do so,
12 subject to the following conditions:
13
14 The above copyright notice and this permission notice shall be
15 included in all copies or substantial portions of the Software.
16*/
17#ifndef JUNO_MODULE_H
18#define JUNO_MODULE_H
19
20#include "juno/status.h"
21#include <stdint.h>
22
102#define JUNO_MODULE_DECLARE(NAME_T) typedef union NAME_T NAME_T
107#define JUNO_MODULE_ROOT_DECLARE(NAME_T) typedef struct NAME_T NAME_T
112#define JUNO_MODULE_DERIVE_DECLARE(NAME_T) JUNO_MODULE_ROOT_DECLARE(NAME_T)
113
117#define JUNO_FAILURE_HANDLER _pfcnFailureHandler
121#define JUNO_FAILURE_USER_DATA _pvFailurUserData
126#define JUNO_MODULE_EMPTY
132#define JUNO_MODULE_SUPER tRoot
133
154#define JUNO_MODULE(API_T, ROOT_T, derived) \
155{ \
156 const API_T *ptApi; \
157 ROOT_T JUNO_MODULE_SUPER; \
158 derived \
159}
160
175#define JUNO_MODULE_ROOT(API_T, members) \
176{ \
177 const API_T *ptApi; \
178 members \
179 JUNO_FAILURE_HANDLER_T JUNO_FAILURE_HANDLER; \
180 JUNO_USER_DATA_T *JUNO_FAILURE_USER_DATA; \
181}
182
196#define JUNO_MODULE_DERIVE(ROOT_T, members) \
197{ \
198 ROOT_T JUNO_MODULE_SUPER; \
199 members \
200}
201
207#define JUNO_MODULE_GET_API(ptModule, ROOT_T) ((const ROOT_T *)ptModule)->ptApi
208
209
210
211#endif // JUNO_MODULE_H