LibJuno 0.22.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>
26#define JUNO_MODULE_DECLARE(name) typedef union name##_TAG name
31#define JUNO_MODULE_BASE_DECLARE(name) typedef struct name##_TAG name
36#define JUNO_MODULE_DERIVE_DECLARE(name) JUNO_MODULE_BASE_DECLARE(name)
37
41#define JUNO_FAILURE_HANDLER _pfcnFailureHandler
45#define JUNO_FAILURE_USER_DATA _pvFailurUserData
50#define JUNO_MODULE_EMPTY
54#define JUNO_MODULE_SUPER tBase
55
67#define JUNO_MODULE(name, API, base, derived) \
68union name##_TAG \
69{ \
70 const API *ptApi; \
71 base JUNO_MODULE_SUPER; \
72 derived \
73}
74
81#define JUNO_MODULE_BASE(name, API, members) \
82struct name##_TAG \
83{ \
84 const API *ptApi; \
85 members \
86 JUNO_FAILURE_HANDLER_T JUNO_FAILURE_HANDLER; \
87 JUNO_USER_DATA_T *JUNO_FAILURE_USER_DATA; \
88}
89
96#define JUNO_MODULE_DERIVE(name, base, members) \
97struct name##_TAG \
98{ \
99 base JUNO_MODULE_SUPER; \
100 members \
101}
102
108#define JUNO_MODULE_GET_API(ptModule, MODULE_BASE_NAME) ((const MODULE_BASE_NAME *)ptModule)->ptApi
109
110#endif // JUNO_MODULE_H