LibJuno 1.0.1
LibJuno is a lightweight C11 library designed specifically for embedded systems.
Loading...
Searching...
No Matches
module.h File Reference

Module system and dependency injection primitives for LibJuno. More...

#include "juno/status.h"
#include <stdint.h>
#include <stdbool.h>
Include dependency graph for module.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define JUNO_MODULE_DECLARE(NAME_T)   typedef union NAME_T NAME_T
 Forward-declare a Juno module union type.
 
#define JUNO_MODULE_ROOT_DECLARE(NAME_T)   typedef struct NAME_T NAME_T
 Forward-declare a module root struct type.
 
#define JUNO_MODULE_DERIVE_DECLARE(NAME_T)   JUNO_MODULE_ROOT_DECLARE(NAME_T)
 Forward-declare a derived module struct type.
 
#define JUNO_FAILURE_HANDLER   _pfcnFailureHandler
 Member name alias for a module's failure handler.
 
#define JUNO_FAILURE_USER_DATA   _pvFailureUserData
 Member name alias for failure handler user data.
 
#define JUNO_MODULE_EMPTY
 Helper for module definitions with no additional members.
 
#define JUNO_MODULE_ARG(...)   __VA_ARGS__
 Pass-through argument pack helper for module macros.
 
#define JUNO_MODULE_SUPER   tRoot
 Standard member name for the embedded module root.
 
#define JUNO_MODULE(API_T, ROOT_T, ...)
 Define a module union consisting of the root and all derivations.
 
#define JUNO_MODULE_ROOT(API_T, ...)
 Implement a module root struct containing ptApi and failure fields.
 
#define JUNO_TRAIT_ROOT(API_T, ...)
 Define a trait root carrying only the API pointer and members.
 
#define JUNO_MODULE_DERIVE(ROOT_T, ...)
 Implement a derived module embedding the root as the first member.
 
#define JUNO_TRAIT_DERIVE(ROOT_T, ...)   JUNO_MODULE_DERIVE(ROOT_T, __VA_ARGS__)
 Alias to define a trait derivation with the standard layout.
 
#define JUNO_MODULE_GET_API(ptModule, ROOT_T)   ((const ROOT_T *)ptModule)->ptApi
 Retrieve the API pointer from a module (via its root view).
 
#define JUNO_MODULE_RESULT(NAME_T, OK_T)
 Define a result type combining a status and a success payload.
 
#define JUNO_OK(result)   result.tOk
 Access the success payload from a result produced by JUNO_MODULE_RESULT.
 
#define JUNO_ASSERT_OK(result, ...)   JUNO_ASSERT_SUCCESS(result.tStatus, __VA_ARGS__)
 Execute the provided statements if result.tStatus is not success.
 
#define JUNO_OK_RESULT(value)   {JUNO_STATUS_SUCCESS, value}
 Construct a result indicating success with the provided payload.
 
#define JUNO_ERR_RESULT(err, value)   {err, value}
 Construct a result indicating error with a payload (may be default-initialized).
 
#define JUNO_MODULE_OPTION(NAME_T, SOME_T)
 Define an option type combining a presence flag and a payload.
 
#define JUNO_SOME(result)   result.tSome
 Access the payload from an option produced by JUNO_MODULE_OPTION.
 
#define JUNO_ASSERT_SOME(result, ...)
 Execute the provided statements if result.bIsSome is false.
 
#define JUNO_SOME_OPTION(value)   {true, value}
 Construct an option in the present state with the provided payload.
 
#define JUNO_NONE_OPTION(default_value)   {false, default_value}
 Construct an option in the empty state, carrying a default payload.
 

Detailed Description

Module system and dependency injection primitives for LibJuno.