Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions examples/memory_example.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ static JUNO_STATUS_T Push(JUNO_MEMORY_ALLOC_T *ptAlloc, SINGLE_LINKED_LIST_T *pt
// Create a new node and return the status
// Allocate the memory for the first node
JUNO_MEMORY_T tMem = {};
const JUNO_MEMORY_ALLOC_API_T *ptApi = ptAlloc->tBase.ptApi;
const JUNO_MEMORY_ALLOC_API_T *ptApi = ptAlloc->tRoot.ptApi;
JUNO_STATUS_T tStatus = ptApi->Get(ptAlloc, &tMem, sizeof(SINGLE_LINKED_LIST_NODE_T));
if(tStatus) return tStatus;
// Using the memory directly since the SLL will own this memory
Expand All @@ -73,7 +73,7 @@ static JUNO_STATUS_T Push(JUNO_MEMORY_ALLOC_T *ptAlloc, SINGLE_LINKED_LIST_T *pt
}
// Allocate the memory for the first node
JUNO_MEMORY_T tMem = {};
const JUNO_MEMORY_ALLOC_API_T *ptApi = ptAlloc->tBase.ptApi;
const JUNO_MEMORY_ALLOC_API_T *ptApi = ptAlloc->tRoot.ptApi;
tStatus = ptApi->Get(ptAlloc, &tMem, sizeof(SINGLE_LINKED_LIST_NODE_T));
if(tStatus) return tStatus;
// Using the memory directly since the SLL will own this memory
Expand Down Expand Up @@ -109,7 +109,7 @@ static JUNO_STATUS_T Pop(JUNO_MEMORY_ALLOC_T *ptAlloc, SINGLE_LINKED_LIST_T *ptS
}
ptSll->ptStart = ptThisNode->ptNext;
*piRetData = ptThisNode->iExampleData;
const JUNO_MEMORY_ALLOC_API_T *ptApi = ptAlloc->tBase.ptApi;
const JUNO_MEMORY_ALLOC_API_T *ptApi = ptAlloc->tRoot.ptApi;
tStatus = ptApi->Put(ptAlloc, &ptThisNode->tMemory);
return tStatus;
}
Expand Down
2 changes: 1 addition & 1 deletion examples/minimal_memory_example.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ int main(void) {

// Step 2: Allocate memory
JUNO_MEMORY_T tMemory = {0};
const JUNO_MEMORY_ALLOC_API_T *ptApi = tMemAlloc.tBase.ptApi;
const JUNO_MEMORY_ALLOC_API_T *ptApi = tMemAlloc.tRoot.ptApi;
tStatus = ptApi->Get(&tMemAlloc, &tMemory, sizeof(USER_DATA_T));

if (tStatus != JUNO_STATUS_SUCCESS) {
Expand Down
4 changes: 2 additions & 2 deletions include/juno/app/app_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ extern "C"
typedef struct JUNO_APP_API_TAG JUNO_APP_API_T;

JUNO_MODULE_DECLARE(JUNO_APP_T);
JUNO_MODULE_BASE_DECLARE(JUNO_APP_BASE_T);
JUNO_MODULE_ROOT_DECLARE(JUNO_APP_ROOT_T);

JUNO_MODULE_BASE(JUNO_APP_BASE_T, JUNO_APP_API_T, JUNO_MODULE_EMPTY);
JUNO_MODULE_ROOT(JUNO_APP_ROOT_T, JUNO_APP_API_T, JUNO_MODULE_EMPTY);

struct JUNO_APP_API_TAG
{
Expand Down
4 changes: 2 additions & 2 deletions include/juno/hash/hash_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ extern "C"
typedef struct JUNO_HASH_API_TAG JUNO_HASH_API_T;

JUNO_MODULE_DECLARE(JUNO_HASH_T);
JUNO_MODULE_BASE_DECLARE(JUNO_HASH_BASE_T);
JUNO_MODULE_ROOT_DECLARE(JUNO_HASH_ROOT_T);

JUNO_MODULE_BASE(JUNO_HASH_BASE_T, JUNO_HASH_API_T, JUNO_MODULE_EMPTY);
JUNO_MODULE_ROOT(JUNO_HASH_ROOT_T, JUNO_HASH_API_T, JUNO_MODULE_EMPTY);

struct JUNO_HASH_API_TAG
{
Expand Down
4 changes: 2 additions & 2 deletions include/juno/hash/hash_djb2.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ extern "C"

JUNO_MODULE_DERIVE_DECLARE(JUNO_HASH_DJB2_T);

JUNO_MODULE_DERIVE(JUNO_HASH_DJB2_T, JUNO_HASH_BASE_T, JUNO_MODULE_EMPTY);
JUNO_MODULE_DERIVE(JUNO_HASH_DJB2_T, JUNO_HASH_ROOT_T, JUNO_MODULE_EMPTY);

#ifdef JUNO_HASH_DEFAULT
/**
Expand All @@ -49,7 +49,7 @@ JUNO_MODULE_DERIVE(JUNO_HASH_DJB2_T, JUNO_HASH_BASE_T, JUNO_MODULE_EMPTY);
Note: If you are djb2ementing a derived module you will need
to djb2ement `JUNO_HASH_DJB2`.
*/
JUNO_MODULE(JUNO_HASH_T, JUNO_HASH_API_T, JUNO_HASH_BASE_T,
JUNO_MODULE(JUNO_HASH_T, JUNO_HASH_API_T, JUNO_HASH_ROOT_T,
JUNO_HASH_DJB2_T tJunoHashDjb2;
);
#endif
Expand Down
4 changes: 2 additions & 2 deletions include/juno/io/async_io_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ extern "C"
typedef struct JUNO_ASYNC_IO_API_TAG JUNO_ASYNC_IO_API_T;

JUNO_MODULE_DECLARE(JUNO_ASYNC_IO_T);
JUNO_MODULE_BASE_DECLARE(JUNO_ASYNC_IO_BASE_T);
JUNO_MODULE_ROOT_DECLARE(JUNO_ASYNC_IO_ROOT_T);

JUNO_MODULE_BASE(JUNO_ASYNC_IO_BASE_T, JUNO_ASYNC_IO_API_T, JUNO_MODULE_EMPTY);
JUNO_MODULE_ROOT(JUNO_ASYNC_IO_ROOT_T, JUNO_ASYNC_IO_API_T, JUNO_MODULE_EMPTY);

struct JUNO_ASYNC_IO_API_TAG
{
Expand Down
4 changes: 2 additions & 2 deletions include/juno/io/i2c_io_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ typedef struct JUNO_I2C_IO_MSG_W_TAG JUNO_I2C_IO_MSG_W_T;
typedef struct JUNO_I2C_IO_MSG_HDR_TAG JUNO_I2C_IO_MSG_HDR_T;
typedef union JUNO_I2C_IO_MSG_TAG JUNO_I2C_IO_MSG_T;
JUNO_MODULE_DECLARE(JUNO_I2C_IO_T);
JUNO_MODULE_BASE_DECLARE(JUNO_I2C_IO_BASE_T);
JUNO_MODULE_ROOT_DECLARE(JUNO_I2C_IO_ROOT_T);

typedef enum JUNO_I2C_IO_MSG_TYPE_TAG
{
Expand Down Expand Up @@ -100,7 +100,7 @@ union JUNO_I2C_IO_MSG_TAG
} \
}

JUNO_MODULE_BASE(JUNO_I2C_IO_BASE_T, JUNO_I2C_IO_API_T, JUNO_MODULE_EMPTY);
JUNO_MODULE_ROOT(JUNO_I2C_IO_ROOT_T, JUNO_I2C_IO_API_T, JUNO_MODULE_EMPTY);

#define JUNO_I2C_IO_TRANSFER(...) (JUNO_I2C_IO_MSG_T[]){__VA_ARGS__}

Expand Down
4 changes: 2 additions & 2 deletions include/juno/io/spi_io_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ extern "C"

typedef struct JUNO_SPI_IO_API_TAG JUNO_SPI_IO_API_T;
JUNO_MODULE_DECLARE(JUNO_SPI_IO_T);
JUNO_MODULE_BASE_DECLARE(JUNO_SPI_IO_BASE_T);
JUNO_MODULE_ROOT_DECLARE(JUNO_SPI_IO_ROOT_T);

JUNO_MODULE_BASE(JUNO_SPI_IO_BASE_T, JUNO_SPI_IO_API_T, JUNO_MODULE_EMPTY);
JUNO_MODULE_ROOT(JUNO_SPI_IO_ROOT_T, JUNO_SPI_IO_API_T, JUNO_MODULE_EMPTY);


struct JUNO_SPI_IO_API_TAG
Expand Down
4 changes: 2 additions & 2 deletions include/juno/log/log_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ extern "C"
typedef struct JUNO_LOG_API_TAG JUNO_LOG_API_T;

JUNO_MODULE_DECLARE(JUNO_LOG_T);
JUNO_MODULE_BASE_DECLARE(JUNO_LOG_BASE_T);
JUNO_MODULE_ROOT_DECLARE(JUNO_LOG_ROOT_T);

JUNO_MODULE_BASE(JUNO_LOG_BASE_T, JUNO_LOG_API_T, JUNO_MODULE_EMPTY);
JUNO_MODULE_ROOT(JUNO_LOG_ROOT_T, JUNO_LOG_API_T, JUNO_MODULE_EMPTY);

struct JUNO_LOG_API_TAG
{
Expand Down
4 changes: 2 additions & 2 deletions include/juno/map/map_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ typedef struct JUNO_MAP_API_TAG JUNO_MAP_API_T;
typedef bool (*JUNO_MAP_KEY_EQUAL_FCN_T)(JUNO_MEMORY_T ptKey1, JUNO_MEMORY_T ptKey2);

JUNO_MODULE_DECLARE(JUNO_MAP_T);
JUNO_MODULE_BASE_DECLARE(JUNO_MAP_BASE_T);
JUNO_MODULE_ROOT_DECLARE(JUNO_MAP_ROOT_T);

JUNO_MODULE_BASE(JUNO_MAP_BASE_T, JUNO_MAP_API_T,
JUNO_MODULE_ROOT(JUNO_MAP_ROOT_T, JUNO_MAP_API_T,
JUNO_HASH_T *ptHash;
JUNO_MEMORY_T *ptMapKeys;
JUNO_MEMORY_T *ptMapValues;
Expand Down
4 changes: 2 additions & 2 deletions include/juno/map/map_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ extern "C"

JUNO_MODULE_DERIVE_DECLARE(JUNO_MAP_IMPL_T);

JUNO_MODULE_DERIVE(JUNO_MAP_IMPL_T, JUNO_MAP_BASE_T,
JUNO_MODULE_DERIVE(JUNO_MAP_IMPL_T, JUNO_MAP_ROOT_T,
/*

TODO: Include implementation specific members here
Expand All @@ -55,7 +55,7 @@ JUNO_MODULE_DERIVE(JUNO_MAP_IMPL_T, JUNO_MAP_BASE_T,
Note: If you are implementing a derived module you will need
to implement `JUNO_MAP_IMPL`.
*/
JUNO_MODULE(JUNO_MAP_T, JUNO_MAP_API_T, JUNO_MAP_BASE_T,
JUNO_MODULE(JUNO_MAP_T, JUNO_MAP_API_T, JUNO_MAP_ROOT_T,
JUNO_MAP_IMPL_T tJunoMapImpl;
);
#endif
Expand Down
4 changes: 2 additions & 2 deletions include/juno/memory/memory_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ struct JUNO_MEMORY_TAG
typedef struct JUNO_MEMORY_ALLOC_API_TAG JUNO_MEMORY_ALLOC_API_T;

JUNO_MODULE_DECLARE(JUNO_MEMORY_ALLOC_T);
JUNO_MODULE_BASE_DECLARE(JUNO_MEMORY_ALLOC_BASE_T);
JUNO_MODULE_ROOT_DECLARE(JUNO_MEMORY_ALLOC_ROOT_T);

JUNO_MODULE_BASE(JUNO_MEMORY_ALLOC_BASE_T, JUNO_MEMORY_ALLOC_API_T, JUNO_MODULE_EMPTY);
JUNO_MODULE_ROOT(JUNO_MEMORY_ALLOC_ROOT_T, JUNO_MEMORY_ALLOC_API_T, JUNO_MODULE_EMPTY);

struct JUNO_MEMORY_ALLOC_API_TAG
{
Expand Down
4 changes: 2 additions & 2 deletions include/juno/memory/memory_block.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ extern "C"

JUNO_MODULE_DERIVE_DECLARE(JUNO_MEMORY_ALLOC_BLOCK_T);

JUNO_MODULE_DERIVE(JUNO_MEMORY_ALLOC_BLOCK_T, JUNO_MEMORY_ALLOC_BASE_T,
JUNO_MODULE_DERIVE(JUNO_MEMORY_ALLOC_BLOCK_T, JUNO_MEMORY_ALLOC_ROOT_T,
uint8_t *pvMemory; ///< Pointer to the allocated memory area.
JUNO_MEMORY_BLOCK_METADATA_T *ptMetadata; ///< Array of metadata for each block.
size_t zTypeSize; ///< Size of each block element.
Expand All @@ -56,7 +56,7 @@ JUNO_MODULE_DERIVE(JUNO_MEMORY_ALLOC_BLOCK_T, JUNO_MEMORY_ALLOC_BASE_T,
Note: If you are blockementing a derived module you will need
to blockement `JUNO_MEMORY_BLOCK`.
*/
JUNO_MODULE(JUNO_MEMORY_ALLOC_T, JUNO_MEMORY_ALLOC_API_T, JUNO_MEMORY_ALLOC_BASE_T,
JUNO_MODULE(JUNO_MEMORY_ALLOC_T, JUNO_MEMORY_ALLOC_API_T, JUNO_MEMORY_ALLOC_ROOT_T,
JUNO_MEMORY_ALLOC_BLOCK_T tJunoMemoryBlock;
);
#endif
Expand Down
36 changes: 18 additions & 18 deletions include/juno/module.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@
*/
#define JUNO_MODULE_DECLARE(name) typedef union name##_TAG name
/**
Declare a base implementation for the module implemented as a struct
@param name The name of the base implementation type
Declare a root implementation for the module implemented as a struct
@param name The name of the root implementation type
*/
#define JUNO_MODULE_BASE_DECLARE(name) typedef struct name##_TAG name
#define JUNO_MODULE_ROOT_DECLARE(name) typedef struct name##_TAG name
/**
Declare a derivation of a juno module implemented as a struct
@param name The name of the derived module type
*/
#define JUNO_MODULE_DERIVE_DECLARE(name) JUNO_MODULE_BASE_DECLARE(name)
#define JUNO_MODULE_DERIVE_DECLARE(name) JUNO_MODULE_ROOT_DECLARE(name)

/**
Alias for the failure handler for a module
Expand All @@ -49,36 +49,36 @@
*/
#define JUNO_MODULE_EMPTY
/**
Alias for the module base implementation
Alias for the module root implementation
*/
#define JUNO_MODULE_SUPER tBase
#define JUNO_MODULE_SUPER tRoot

/**
Define a juno module. This needs to be done in
the composition root. This is where users define
all possible module implementations for a module.
@param name The name of the module as declared
@param API The name of the API type for the module
@param base The name of the base implementation type
@param root The name of the root implementation type
for the module as declared
@param derived The derived modules seperated by `;`

*/
#define JUNO_MODULE(name, API, base, derived) \
#define JUNO_MODULE(name, API, root, derived) \
union name##_TAG \
{ \
const API *ptApi; \
base JUNO_MODULE_SUPER; \
root JUNO_MODULE_SUPER; \
derived \
}

/**
Implement a base for a module
@param name The name of the module base implementation as declared
Implement a root for a module
@param name The name of the module root implementation as declared
@param API The API type for the module
@param members The member components of the module base implementation
@param members The member components of the module root implementation
*/
#define JUNO_MODULE_BASE(name, API, members) \
#define JUNO_MODULE_ROOT(name, API, members) \
struct name##_TAG \
{ \
const API *ptApi; \
Expand All @@ -90,21 +90,21 @@ struct name##_TAG \
/**
Implement a derivation of a module
@param name The name of the module derivation as declared
@param base The name of the base implementation for the module as declared
@param root The name of the root implementation for the module as declared
@param members The member components of the module derivation
*/
#define JUNO_MODULE_DERIVE(name, base, members) \
#define JUNO_MODULE_DERIVE(name, root, members) \
struct name##_TAG \
{ \
base JUNO_MODULE_SUPER; \
root JUNO_MODULE_SUPER; \
members \
}

/**
Get the API pointer from the module
@param ptModule The module pointer
@param MODULE_BASE_NAME The base type of the module
@param MODULE_ROOT_NAME The root type of the module
*/
#define JUNO_MODULE_GET_API(ptModule, MODULE_BASE_NAME) ((const MODULE_BASE_NAME *)ptModule)->ptApi
#define JUNO_MODULE_GET_API(ptModule, MODULE_ROOT_NAME) ((const MODULE_ROOT_NAME *)ptModule)->ptApi

#endif // JUNO_MODULE_H
4 changes: 2 additions & 2 deletions include/juno/sb/msg_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,15 +38,15 @@ typedef struct JUNO_MSG_API_TAG JUNO_MSG_API_T;
typedef struct JUNO_MSG_BUFFER_TAG JUNO_MSG_BUFFER_T;

JUNO_MODULE_DECLARE(JUNO_MSG_T);
JUNO_MODULE_BASE_DECLARE(JUNO_MSG_BASE_T);
JUNO_MODULE_ROOT_DECLARE(JUNO_MSG_ROOT_T);

struct JUNO_MSG_BUFFER_TAG
{
void *pvBuffer;
size_t zBufferSize;
};

JUNO_MODULE_BASE(JUNO_MSG_BASE_T, JUNO_MSG_API_T,
JUNO_MODULE_ROOT(JUNO_MSG_ROOT_T, JUNO_MSG_API_T,
const JUNO_MSG_BUFFER_T *ptBuffer;
);

Expand Down
4 changes: 2 additions & 2 deletions include/juno/sb/publisher_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ typedef struct JUNO_PUBLISHER_API_TAG JUNO_PUBLISHER_API_T;
typedef struct JUNO_PUBLISHER_ID_TAG JUNO_PUBLISHER_ID_T;

JUNO_MODULE_DECLARE(JUNO_PUBLISHER_T);
JUNO_MODULE_BASE_DECLARE(JUNO_PUBLISHER_BASE_T);
JUNO_MODULE_ROOT_DECLARE(JUNO_PUBLISHER_ROOT_T);

JUNO_MODULE_BASE(JUNO_PUBLISHER_BASE_T, JUNO_PUBLISHER_API_T,
JUNO_MODULE_ROOT(JUNO_PUBLISHER_ROOT_T, JUNO_PUBLISHER_API_T,
JUNO_PUBLISHER_ID_T *ptPublisherId;
);

Expand Down
4 changes: 2 additions & 2 deletions include/juno/sb/subscriber_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ extern "C"
typedef struct JUNO_SUBSCRIBER_API_TAG JUNO_SUBSCRIBER_API_T;

JUNO_MODULE_DECLARE(JUNO_SUBSCRIBER_T);
JUNO_MODULE_BASE_DECLARE(JUNO_SUBSCRIBER_BASE_T);
JUNO_MODULE_ROOT_DECLARE(JUNO_SUBSCRIBER_ROOT_T);

JUNO_MODULE_BASE(JUNO_SUBSCRIBER_BASE_T, JUNO_SUBSCRIBER_API_T,
JUNO_MODULE_ROOT(JUNO_SUBSCRIBER_ROOT_T, JUNO_SUBSCRIBER_API_T,
JUNO_MEMORY_ALLOC_T *ptAlloc;
);

Expand Down
4 changes: 2 additions & 2 deletions include/juno/string/string_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ typedef struct JUNO_STRING_API_TAG JUNO_STRING_API_T;
typedef struct JUNO_STRING_BUFFER_TAG JUNO_STRING_BUFFER_T;

JUNO_MODULE_DECLARE(JUNO_STRING_T);
JUNO_MODULE_BASE_DECLARE(JUNO_STRING_BASE_T);
JUNO_MODULE_ROOT_DECLARE(JUNO_STRING_ROOT_T);


JUNO_MODULE_BASE(JUNO_STRING_BASE_T, JUNO_STRING_API_T,
JUNO_MODULE_ROOT(JUNO_STRING_ROOT_T, JUNO_STRING_API_T,
JUNO_MEMORY_ALLOC_T *ptAlloc;
JUNO_MEMORY_T tMemory;
size_t zSize;
Expand Down
4 changes: 2 additions & 2 deletions include/juno/string/string_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ extern "C"

JUNO_MODULE_DERIVE_DECLARE(JUNO_STRING_IMPL_T);

JUNO_MODULE_DERIVE(JUNO_STRING_IMPL_T, JUNO_STRING_BASE_T,
JUNO_MODULE_DERIVE(JUNO_STRING_IMPL_T, JUNO_STRING_ROOT_T,
/*

TODO: Include implementation specific members here
Expand All @@ -55,7 +55,7 @@ JUNO_MODULE_DERIVE(JUNO_STRING_IMPL_T, JUNO_STRING_BASE_T,
Note: If you are implementing a derived module you will need
to implement `JUNO_STRING_IMPL`.
*/
JUNO_MODULE(JUNO_STRING_T, JUNO_STRING_API_T, JUNO_STRING_BASE_T,
JUNO_MODULE(JUNO_STRING_T, JUNO_STRING_API_T, JUNO_STRING_ROOT_T,
JUNO_STRING_IMPL_T tJunoStringImpl;
);
#endif
Expand Down
4 changes: 2 additions & 2 deletions include/juno/time/time_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ extern "C"

typedef struct JUNO_TIME_API_TAG JUNO_TIME_API_T;
JUNO_MODULE_DECLARE(JUNO_TIME_T);
JUNO_MODULE_BASE_DECLARE(JUNO_TIME_BASE_T);
JUNO_MODULE_ROOT_DECLARE(JUNO_TIME_ROOT_T);
typedef struct JUNO_TIMESTAMP_TAG JUNO_TIMESTAMP_T;

typedef uint64_t JUNO_TIME_SECONDS_T;
typedef uint64_t JUNO_TIME_MILLIS_T;
typedef uint64_t JUNO_TIME_MICROS_T;
typedef uint64_t JUNO_TIME_NANOS_T;

JUNO_MODULE_BASE(JUNO_TIME_BASE_T, JUNO_TIME_API_T, JUNO_MODULE_EMPTY);
JUNO_MODULE_ROOT(JUNO_TIME_ROOT_T, JUNO_TIME_API_T, JUNO_MODULE_EMPTY);

struct JUNO_TIMESTAMP_TAG
{
Expand Down
Loading