diff --git a/examples/memory_example.c b/examples/memory_example.c index 59c1dc3d..4faf401b 100644 --- a/examples/memory_example.c +++ b/examples/memory_example.c @@ -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 @@ -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 @@ -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; } diff --git a/examples/minimal_memory_example.c b/examples/minimal_memory_example.c index 93f4adf8..dd164b10 100644 --- a/examples/minimal_memory_example.c +++ b/examples/minimal_memory_example.c @@ -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) { diff --git a/include/juno/app/app_api.h b/include/juno/app/app_api.h index e08349ca..ed001d39 100644 --- a/include/juno/app/app_api.h +++ b/include/juno/app/app_api.h @@ -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 { diff --git a/include/juno/hash/hash_api.h b/include/juno/hash/hash_api.h index eafe13cf..3a442345 100644 --- a/include/juno/hash/hash_api.h +++ b/include/juno/hash/hash_api.h @@ -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 { diff --git a/include/juno/hash/hash_djb2.h b/include/juno/hash/hash_djb2.h index 289b33e6..e3ed0a80 100644 --- a/include/juno/hash/hash_djb2.h +++ b/include/juno/hash/hash_djb2.h @@ -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 /** @@ -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 diff --git a/include/juno/io/async_io_api.h b/include/juno/io/async_io_api.h index a2a953d8..b5ed56af 100644 --- a/include/juno/io/async_io_api.h +++ b/include/juno/io/async_io_api.h @@ -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 { diff --git a/include/juno/io/i2c_io_api.h b/include/juno/io/i2c_io_api.h index 9923b8fe..80d824ab 100644 --- a/include/juno/io/i2c_io_api.h +++ b/include/juno/io/i2c_io_api.h @@ -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 { @@ -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__} diff --git a/include/juno/io/spi_io_api.h b/include/juno/io/spi_io_api.h index 63db6a58..b212ae7c 100644 --- a/include/juno/io/spi_io_api.h +++ b/include/juno/io/spi_io_api.h @@ -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 diff --git a/include/juno/log/log_api.h b/include/juno/log/log_api.h index 2741af8b..de44ecac 100644 --- a/include/juno/log/log_api.h +++ b/include/juno/log/log_api.h @@ -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 { diff --git a/include/juno/map/map_api.h b/include/juno/map/map_api.h index 12298c12..6ddf61e9 100644 --- a/include/juno/map/map_api.h +++ b/include/juno/map/map_api.h @@ -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; diff --git a/include/juno/map/map_impl.h b/include/juno/map/map_impl.h index f66db36d..139d577b 100644 --- a/include/juno/map/map_impl.h +++ b/include/juno/map/map_impl.h @@ -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 @@ -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 diff --git a/include/juno/memory/memory_api.h b/include/juno/memory/memory_api.h index e3f7ab24..35839da6 100644 --- a/include/juno/memory/memory_api.h +++ b/include/juno/memory/memory_api.h @@ -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 { diff --git a/include/juno/memory/memory_block.h b/include/juno/memory/memory_block.h index cdb1452a..49372886 100644 --- a/include/juno/memory/memory_block.h +++ b/include/juno/memory/memory_block.h @@ -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. @@ -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 diff --git a/include/juno/module.h b/include/juno/module.h index 488764a2..6e8b3a22 100644 --- a/include/juno/module.h +++ b/include/juno/module.h @@ -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 @@ -49,9 +49,9 @@ */ #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 @@ -59,26 +59,26 @@ 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; \ @@ -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 diff --git a/include/juno/sb/msg_api.h b/include/juno/sb/msg_api.h index 6a4d89cc..e8719367 100644 --- a/include/juno/sb/msg_api.h +++ b/include/juno/sb/msg_api.h @@ -38,7 +38,7 @@ 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 { @@ -46,7 +46,7 @@ struct JUNO_MSG_BUFFER_TAG 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; ); diff --git a/include/juno/sb/publisher_api.h b/include/juno/sb/publisher_api.h index eff70fbd..d3f5d595 100644 --- a/include/juno/sb/publisher_api.h +++ b/include/juno/sb/publisher_api.h @@ -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; ); diff --git a/include/juno/sb/subscriber_api.h b/include/juno/sb/subscriber_api.h index d45bdbd3..9ce3d9be 100644 --- a/include/juno/sb/subscriber_api.h +++ b/include/juno/sb/subscriber_api.h @@ -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; ); diff --git a/include/juno/string/string_api.h b/include/juno/string/string_api.h index 66c21571..24088ecf 100644 --- a/include/juno/string/string_api.h +++ b/include/juno/string/string_api.h @@ -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; diff --git a/include/juno/string/string_impl.h b/include/juno/string/string_impl.h index 87825017..70655497 100644 --- a/include/juno/string/string_impl.h +++ b/include/juno/string/string_impl.h @@ -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 @@ -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 diff --git a/include/juno/time/time_api.h b/include/juno/time/time_api.h index 97d6351b..cd296d54 100644 --- a/include/juno/time/time_api.h +++ b/include/juno/time/time_api.h @@ -31,7 +31,7 @@ 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; @@ -39,7 +39,7 @@ 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 { diff --git a/src/juno_map.c b/src/juno_map.c index 20ed28e4..0721cd8a 100644 --- a/src/juno_map.c +++ b/src/juno_map.c @@ -53,11 +53,11 @@ static inline JUNO_STATUS_T Juno_MapGetIndex(JUNO_MAP_T *ptJunoMap, JUNO_MEMORY_ JUNO_MAP_IMPL_T *ptMap = (JUNO_MAP_IMPL_T *)(ptJunoMap); size_t zHash = 0; - JUNO_HASH_BASE_T *ptHash = (JUNO_HASH_BASE_T *)(ptMap->tBase.ptHash); - JUNO_STATUS_T tStatus = ptHash->ptApi->Hash(ptMap->tBase.ptHash, (const uint8_t *)(tKey.pvAddr), tKey.zSize, &zHash); + JUNO_HASH_ROOT_T *ptHash = (JUNO_HASH_ROOT_T *)(ptMap->tRoot.ptHash); + JUNO_STATUS_T tStatus = ptHash->ptApi->Hash(ptMap->tRoot.ptHash, (const uint8_t *)(tKey.pvAddr), tKey.zSize, &zHash); ASSERT_SUCCESS(tStatus, return tStatus); // Get the capacity - size_t zCapacity = ptMap->tBase.zCapacity; + size_t zCapacity = ptMap->tRoot.zCapacity; tStatus = JUNO_STATUS_TABLE_FULL_ERROR; // Calculate the index size_t zIndex = zHash % zCapacity; @@ -66,14 +66,14 @@ static inline JUNO_STATUS_T Juno_MapGetIndex(JUNO_MAP_T *ptJunoMap, JUNO_MEMORY_ for (size_t i = 0; i < zCapacity; i++) { // Get a pointer to the current key - JUNO_MEMORY_T tCurKey = ptMap->tBase.ptMapKeys[zIndex]; + JUNO_MEMORY_T tCurKey = ptMap->tRoot.ptMapKeys[zIndex]; // Check if the spot is empty or the key is equal - if((!tCurKey.pvAddr && !bShallEqual) || (tCurKey.pvAddr && tKey.pvAddr && ptMap->tBase.pfcnIsEqual(tCurKey, tKey))) + if((!tCurKey.pvAddr && !bShallEqual) || (tCurKey.pvAddr && tKey.pvAddr && ptMap->tRoot.pfcnIsEqual(tCurKey, tKey))) { // Return the index *pzRetSize = zIndex; tStatus = JUNO_STATUS_SUCCESS; - ptMap->tBase.zLenHashTable += 1; + ptMap->tRoot.zLenHashTable += 1; break; } zIndex = (zHash + i) % zCapacity; @@ -94,8 +94,8 @@ static JUNO_STATUS_T Juno_MapSet(JUNO_MAP_T *ptJunoMap, JUNO_MEMORY_T tKey, JUNO size_t zIndex = 0; tStatus = Juno_MapGetIndex(ptJunoMap, tKey, &zIndex, false); ASSERT_SUCCESS(tStatus, return tStatus); - ptMap->tBase.ptMapKeys[zIndex] = tKey; - ptMap->tBase.ptMapValues[zIndex] = tValue; + ptMap->tRoot.ptMapKeys[zIndex] = tKey; + ptMap->tRoot.ptMapValues[zIndex] = tValue; return tStatus; } @@ -107,8 +107,8 @@ static JUNO_STATUS_T Juno_MapRemove(JUNO_MAP_T *ptJunoMap, JUNO_MEMORY_T tKey) size_t zIndex = 0; tStatus = Juno_MapGetIndex(ptJunoMap, tKey, &zIndex, true); ASSERT_SUCCESS(tStatus, return tStatus); - ptMap->tBase.ptMapKeys[zIndex] = (JUNO_MEMORY_T){0}; - ptMap->tBase.ptMapValues[zIndex] = (JUNO_MEMORY_T){0}; + ptMap->tRoot.ptMapKeys[zIndex] = (JUNO_MEMORY_T){0}; + ptMap->tRoot.ptMapValues[zIndex] = (JUNO_MEMORY_T){0}; return tStatus; } @@ -121,13 +121,13 @@ static JUNO_STATUS_T Juno_MapGet(JUNO_MAP_T *ptJunoMap, JUNO_MEMORY_T tKey, JUNO size_t zIndex = 0; tStatus = Juno_MapGetIndex(ptJunoMap, tKey, &zIndex, true); ASSERT_SUCCESS(tStatus, return tStatus); - if(!ptMap->tBase.ptMapKeys[zIndex].pvAddr) + if(!ptMap->tRoot.ptMapKeys[zIndex].pvAddr) { tStatus = JUNO_STATUS_DNE_ERROR; FAIL_MODULE(tStatus, ptMap, "Key Does not exist"); return tStatus; } - *ptRetValue = ptMap->tBase.ptMapValues[zIndex]; + *ptRetValue = ptMap->tRoot.ptMapValues[zIndex]; return tStatus; } diff --git a/templates/template_app/include/template_app/template_app.h b/templates/template_app/include/template_app/template_app.h index 629d4814..aca3ffbb 100644 --- a/templates/template_app/include/template_app/template_app.h +++ b/templates/template_app/include/template_app/template_app.h @@ -38,7 +38,7 @@ extern "C" typedef struct TEMPLATE_APP_API_TAG TEMPLATE_APP_API_T; JUNO_MODULE_DERIVE_DECLARE(TEMPLATE_APP_T); -JUNO_MODULE_DERIVE(TEMPLATE_APP_T, JUNO_APP_BASE_T, +JUNO_MODULE_DERIVE(TEMPLATE_APP_T, JUNO_APP_ROOT_T, JUNO_LOG_T *ptLogger; ); diff --git a/templates/template_impl/include/template/template_impl.h b/templates/template_impl/include/template/template_impl.h index 46937788..05e8a05c 100644 --- a/templates/template_impl/include/template/template_impl.h +++ b/templates/template_impl/include/template/template_impl.h @@ -37,7 +37,7 @@ extern "C" JUNO_MODULE_DERIVE_DECLARE(TEMPLATE_IMPL_T); -JUNO_MODULE_DERIVE(TEMPLATE_IMPL_T, TEMPLATE_BASE_T, +JUNO_MODULE_DERIVE(TEMPLATE_IMPL_T, TEMPLATE_ROOT_T, /* TODO: Include implementation specific members here @@ -55,7 +55,7 @@ JUNO_MODULE_DERIVE(TEMPLATE_IMPL_T, TEMPLATE_BASE_T, Note: If you are implementing a derived module you will need to implement `TEMPLATE_IMPL`. */ -JUNO_MODULE(TEMPLATE_T, TEMPLATE_API_T, TEMPLATE_BASE_T, +JUNO_MODULE(TEMPLATE_T, TEMPLATE_API_T, TEMPLATE_ROOT_T, TEMPLATE_IMPL_T tTemplateImpl; ); #endif diff --git a/templates/template_lib/include/template/template_api.h b/templates/template_lib/include/template/template_api.h index b2d2aa58..2619a140 100644 --- a/templates/template_lib/include/template/template_api.h +++ b/templates/template_lib/include/template/template_api.h @@ -36,9 +36,9 @@ extern "C" typedef struct TEMPLATE_API_TAG TEMPLATE_API_T; JUNO_MODULE_DECLARE(TEMPLATE_T); -JUNO_MODULE_BASE_DECLARE(TEMPLATE_BASE_T); +JUNO_MODULE_ROOT_DECLARE(TEMPLATE_ROOT_T); -JUNO_MODULE_BASE(TEMPLATE_BASE_T, TEMPLATE_API_T, +JUNO_MODULE_ROOT(TEMPLATE_ROOT_T, TEMPLATE_API_T, /* TODO: Add implementation independent member variables here diff --git a/templates/template_lib/include/template/template_impl.h b/templates/template_lib/include/template/template_impl.h index 46937788..05e8a05c 100644 --- a/templates/template_lib/include/template/template_impl.h +++ b/templates/template_lib/include/template/template_impl.h @@ -37,7 +37,7 @@ extern "C" JUNO_MODULE_DERIVE_DECLARE(TEMPLATE_IMPL_T); -JUNO_MODULE_DERIVE(TEMPLATE_IMPL_T, TEMPLATE_BASE_T, +JUNO_MODULE_DERIVE(TEMPLATE_IMPL_T, TEMPLATE_ROOT_T, /* TODO: Include implementation specific members here @@ -55,7 +55,7 @@ JUNO_MODULE_DERIVE(TEMPLATE_IMPL_T, TEMPLATE_BASE_T, Note: If you are implementing a derived module you will need to implement `TEMPLATE_IMPL`. */ -JUNO_MODULE(TEMPLATE_T, TEMPLATE_API_T, TEMPLATE_BASE_T, +JUNO_MODULE(TEMPLATE_T, TEMPLATE_API_T, TEMPLATE_ROOT_T, TEMPLATE_IMPL_T tTemplateImpl; ); #endif diff --git a/templates/template_lib/src/template_impl.c b/templates/template_lib/src/template_impl.c index c9344f6c..d29a500a 100644 --- a/templates/template_lib/src/template_impl.c +++ b/templates/template_lib/src/template_impl.c @@ -51,12 +51,12 @@ static inline JUNO_STATUS_T Verify(TEMPLATE_T *ptTemplate) ASSERT_EXISTS(ptTemplate); TEMPLATE_IMPL_T *ptTemplateImpl = (TEMPLATE_IMPL_T *)(ptTemplate); ASSERT_EXISTS_MODULE( - ptTemplate && ptTemplateImpl->tBase.ptApi + ptTemplate && ptTemplateImpl->tRoot.ptApi /* TODO: Assert other dependencies and members here using &&*/, ptTemplateImpl, "Module does not have all dependencies" ); - if(ptTemplateImpl->tBase.ptApi != &tTemplateImplApi) + if(ptTemplateImpl->tRoot.ptApi != &tTemplateImplApi) { FAIL_MODULE(JUNO_STATUS_INVALID_TYPE_ERROR, ptTemplateImpl, "Module has invalid API"); return JUNO_STATUS_INVALID_TYPE_ERROR; @@ -69,9 +69,9 @@ JUNO_STATUS_T Template_ImplApi(TEMPLATE_T *ptTemplate, JUNO_FAILURE_HANDLER_T pf { ASSERT_EXISTS(ptTemplate); TEMPLATE_IMPL_T *ptTemplateImpl = (TEMPLATE_IMPL_T *)(ptTemplate); - ptTemplateImpl->tBase.ptApi = &tTemplateImplApi; - ptTemplateImpl->tBase.JUNO_FAILURE_HANDLER = pfcnFailureHandler; - ptTemplateImpl->tBase.JUNO_FAILURE_USER_DATA = pvFailureUserData; + ptTemplateImpl->tRoot.ptApi = &tTemplateImplApi; + ptTemplateImpl->tRoot.JUNO_FAILURE_HANDLER = pfcnFailureHandler; + ptTemplateImpl->tRoot.JUNO_FAILURE_USER_DATA = pvFailureUserData; JUNO_STATUS_T tStatus = Verify(ptTemplate); ASSERT_SUCCESS(tStatus, return tStatus); /* diff --git a/tests/test_memory.c b/tests/test_memory.c index 5ca3f11d..fbc8002e 100644 --- a/tests/test_memory.c +++ b/tests/test_memory.c @@ -44,7 +44,7 @@ static void test_nominal_single_alloc_and_free(void) ); TEST_ASSERT_EQUAL(JUNO_STATUS_SUCCESS, tStatus); JUNO_MEMORY_T tMemory = {0}; - const JUNO_MEMORY_ALLOC_API_T *ptApi = tMem.tJunoMemoryBlock.tBase.ptApi; + const JUNO_MEMORY_ALLOC_API_T *ptApi = tMem.tJunoMemoryBlock.tRoot.ptApi; tStatus = ptApi->Get(&tMem, &tMemory, sizeof(TEST_BLOCK_T)); TEST_ASSERT_EQUAL(JUNO_STATUS_SUCCESS, tStatus); TEST_ASSERT_NOT_NULL(tMemory.pvAddr); @@ -108,7 +108,7 @@ static void test_nominal_multiple_alloc_and_free(void) NULL ); TEST_ASSERT_EQUAL(JUNO_STATUS_SUCCESS, tStatus); - const JUNO_MEMORY_ALLOC_API_T *ptApi = tMem.tJunoMemoryBlock.tBase.ptApi; + const JUNO_MEMORY_ALLOC_API_T *ptApi = tMem.tJunoMemoryBlock.tRoot.ptApi; TEST_BLOCK_T *ptTestPtr[10] = {0}; JUNO_MEMORY_T ptMemory[10] = {0}; for (int j = 0; j < 5; j++) @@ -163,7 +163,7 @@ static void test_negative_memory_empty(void) NULL ); TEST_ASSERT_EQUAL(JUNO_STATUS_SUCCESS, tStatus); - const JUNO_MEMORY_ALLOC_API_T *ptApi = tMem.tJunoMemoryBlock.tBase.ptApi; + const JUNO_MEMORY_ALLOC_API_T *ptApi = tMem.tJunoMemoryBlock.tRoot.ptApi; JUNO_MEMORY_T tFailMemory = { .pvAddr = ptTestBlock, .zSize = 128 @@ -207,7 +207,7 @@ static void test_negative_memory_full(void) NULL ); TEST_ASSERT_EQUAL(JUNO_STATUS_SUCCESS, tStatus); - const JUNO_MEMORY_ALLOC_API_T *ptApi = tMem.tJunoMemoryBlock.tBase.ptApi; + const JUNO_MEMORY_ALLOC_API_T *ptApi = tMem.tJunoMemoryBlock.tRoot.ptApi; TEST_BLOCK_T *ptTestPtr[10] = {0}; JUNO_MEMORY_T ptMemory[10] = {0}; for (size_t i = 0; i < 10; i++) @@ -259,7 +259,7 @@ static void test_double_free(void) NULL ); TEST_ASSERT_EQUAL(JUNO_STATUS_SUCCESS, tStatus); - const JUNO_MEMORY_ALLOC_API_T *ptApi = tMem.tJunoMemoryBlock.tBase.ptApi; + const JUNO_MEMORY_ALLOC_API_T *ptApi = tMem.tJunoMemoryBlock.tRoot.ptApi; JUNO_MEMORY_T tMemory = {0}; tStatus = ptApi->Get(&tMem, &tMemory, sizeof(TEST_BLOCK_T)); TEST_ASSERT_EQUAL(JUNO_STATUS_SUCCESS, tStatus); @@ -286,7 +286,7 @@ static void test_free_unallocated(void) NULL ); TEST_ASSERT_EQUAL(JUNO_STATUS_SUCCESS, tStatus); - const JUNO_MEMORY_ALLOC_API_T *ptApi = tMem.tJunoMemoryBlock.tBase.ptApi; + const JUNO_MEMORY_ALLOC_API_T *ptApi = tMem.tJunoMemoryBlock.tRoot.ptApi; JUNO_MEMORY_T tMemory = {0}; // tMemory never allocated via Get should be flagged as unallocated. tStatus = ptApi->Put(&tMem, &tMemory); @@ -309,7 +309,7 @@ static void test_update_memory(void) NULL ); TEST_ASSERT_EQUAL(JUNO_STATUS_SUCCESS, tStatus); - const JUNO_MEMORY_ALLOC_API_T *ptApi = tMem.tJunoMemoryBlock.tBase.ptApi; + const JUNO_MEMORY_ALLOC_API_T *ptApi = tMem.tJunoMemoryBlock.tRoot.ptApi; JUNO_MEMORY_T tMemory = {0}; tStatus = ptApi->Get(&tMem, &tMemory, sizeof(TEST_BLOCK_T)); @@ -343,7 +343,7 @@ static void test_generic_memory_get_put(void) NULL ); TEST_ASSERT_EQUAL(JUNO_STATUS_SUCCESS, tStatus); - const JUNO_MEMORY_ALLOC_API_T *ptApi = tMem.tJunoMemoryBlock.tBase.ptApi; + const JUNO_MEMORY_ALLOC_API_T *ptApi = tMem.tJunoMemoryBlock.tRoot.ptApi; // Cast the address to the generic allocator type. JUNO_MEMORY_ALLOC_T *ptAlloc = (JUNO_MEMORY_ALLOC_T *)&tMem; @@ -376,7 +376,7 @@ static void test_zero_size_allocation(void) NULL ); TEST_ASSERT_EQUAL(JUNO_STATUS_SUCCESS, tStatus); - const JUNO_MEMORY_ALLOC_API_T *ptApi = tMem.tJunoMemoryBlock.tBase.ptApi; + const JUNO_MEMORY_ALLOC_API_T *ptApi = tMem.tJunoMemoryBlock.tRoot.ptApi; JUNO_MEMORY_T tMemory = {0}; // Attempt zero-size allocation @@ -398,15 +398,15 @@ static void test_bad_api(void) NULL ); TEST_ASSERT_EQUAL(JUNO_STATUS_SUCCESS, tStatus); - const JUNO_MEMORY_ALLOC_API_T *ptApi = tMem.tJunoMemoryBlock.tBase.ptApi; - tMem.tBase.ptApi = NULL; + const JUNO_MEMORY_ALLOC_API_T *ptApi = tMem.tJunoMemoryBlock.tRoot.ptApi; + tMem.tRoot.ptApi = NULL; JUNO_MEMORY_T tMemory = {0}; tStatus = ptApi->Get(&tMem, &tMemory, 0); tStatus = ptApi->Put(&tMem, &tMemory); tStatus = ptApi->Update(&tMem, &tMemory, 0); // The implementation should handle this gracefully TEST_ASSERT_NOT_EQUAL(JUNO_STATUS_SUCCESS, tStatus); - tMem.tBase.ptApi = &ptApi[1]; + tMem.tRoot.ptApi = &ptApi[1]; tStatus = ptApi->Get(&tMem, &tMemory, 0); tStatus = ptApi->Put(&tMem, &tMemory); tStatus = ptApi->Update(&tMem, &tMemory, 0); @@ -430,7 +430,7 @@ static void test_invalid_size_and_addr(void) ); TEST_ASSERT_EQUAL(JUNO_STATUS_SUCCESS, tStatus); JUNO_MEMORY_T tMemory = {0}; - const JUNO_MEMORY_ALLOC_API_T *ptApi = tMem.tJunoMemoryBlock.tBase.ptApi; + const JUNO_MEMORY_ALLOC_API_T *ptApi = tMem.tJunoMemoryBlock.tRoot.ptApi; tStatus = ptApi->Get(&tMem, &tMemory, sizeof(TEST_BLOCK_T)+1); TEST_ASSERT_NOT_EQUAL(JUNO_STATUS_SUCCESS, tStatus); tStatus = ptApi->Get(&tMem, &tMemory, sizeof(TEST_BLOCK_T));