From cb48a9f57341af813b437c52fce0568e8e890bc3 Mon Sep 17 00:00:00 2001 From: herbglitch Date: Fri, 28 Mar 2025 01:34:29 -0600 Subject: [PATCH] finished config.h documentation, need to write config.md --- doc/pages/standard.md | 2 +- doc/pages/standard/{chemical.md => config.md} | 4 +- include/arc/math/config.h | 2 - include/arc/std/config.h | 253 +++++++++++++++--- 4 files changed, 217 insertions(+), 44 deletions(-) rename doc/pages/standard/{chemical.md => config.md} (66%) diff --git a/doc/pages/standard.md b/doc/pages/standard.md index 2b4bbc9..a03c1fd 100644 --- a/doc/pages/standard.md +++ b/doc/pages/standard.md @@ -4,7 +4,7 @@ Archeus' standard library is a collection of basic datatypes that does not depen - @subpage standard-array "ARC_Array" - @subpage standard-bool "ARC_Bool" -- @subpage standard-chemical "ARC_Chemical" +- @subpage standard-config "ARC_Config" - @subpage standard-errno "ARC_Errno" - @subpage standard-hashtable "ARC_Hashtable" - @subpage standard-io "ARC_IO" diff --git a/doc/pages/standard/chemical.md b/doc/pages/standard/config.md similarity index 66% rename from doc/pages/standard/chemical.md rename to doc/pages/standard/config.md index e698e8b..3f387c4 100644 --- a/doc/pages/standard/chemical.md +++ b/doc/pages/standard/config.md @@ -1,5 +1,5 @@ -\page standard-chemical ARC_Chemical +\page standard-config ARC_Config This type is being actively worked on. It will be a config type to read in .chemical files. The name was chosen from the four ethers that Archeus can be broken down into (Chemical, Life, Light, and Reflective) -*This page will be written after completing the ::ARC_Chemical type* +*This page will be written after completing the ::ARC_Config type* diff --git a/include/arc/math/config.h b/include/arc/math/config.h index 9e33b41..483a863 100644 --- a/include/arc/math/config.h +++ b/include/arc/math/config.h @@ -9,8 +9,6 @@ extern "C" { #include "arc/std/config.h" -typedef struct ARC_Config ARC_Config; - /** * @brief */ diff --git a/include/arc/std/config.h b/include/arc/std/config.h index 61a3542..251007a 100644 --- a/include/arc/std/config.h +++ b/include/arc/std/config.h @@ -15,11 +15,19 @@ typedef struct ARC_Config ARC_Config; /** * @brief a function callback to create a type stored within a config + * + * @param[out] type the place to store the type copy, should be set to NULL on error + * @param[in] parsedData the parsed data used to copy from. will be as defined in the language + * @param[in] config the config that is reading in the data, can be used within the copy function to add a new type (check ARC_ConfigType_SpriteCopyFn for an example) + * @param[in] userdata userdata that was stored in the type during type register */ typedef void (* ARC_ConfigType_CopyFn)(void **type, ARC_ParserTagToken *parsedData, ARC_Config *config, void *userdata); /** * @brief a function callback to destroy a type + * + * @param[in] config the config that is destroying the data, can be used within the destroy function to remove a previously added tag (check ARC_ConfigType_SpriteDestroyFn for an example) + * @param[in] type the type to be destroyed */ typedef void (* ARC_ConfigType_DestroyFn)(ARC_Config *config, void *type); @@ -196,20 +204,50 @@ void ARC_Config_LoadFromFile(ARC_Config *config, ARC_String *path); void ARC_Config_LoadFromFileWithCStr(ARC_Config *config, const char *path); /** - * @brief TODO: write this + * @brief takes a given file path and unloads it into the config + * + * @note this path will be based on wherever the executable is run from + * + * @breif config the config to unload the file from + * @breif path the location of the .chemical file to unload */ void ARC_Config_UnloadFromString(ARC_Config *config, ARC_String **string); /** - * @brief TODO: write this + * @brief takes a given file path and unloads it into the config + * + * @note this path will be based on wherever the executable is run from + * + * @breif config the config to unload the file from + * @breif path the location of the .chemical file to unload */ void ARC_Config_UnloadFromFile(ARC_Config *config, ARC_String *data); +/** + * @{ + * @brief defaults used by arc config can be defined before building to change them +*/ +#ifndef ARC_CONFIG_DEFAULT_GROUP #define ARC_CONFIG_DEFAULT_GROUP " " -#define ARC_CONFIG_GROUP_TAG_NAME "group" -#define ARC_CONFIG_GROUP_SEPARATOR "::" +#endif -//the grouping is based on the ascii table, but the ids are sequential to make finding tokens quicker (look at the lexer continious for more explanation) +#ifndef ARC_CONFIG_GROUP_TAG_NAME +#define ARC_CONFIG_GROUP_TAG_NAME "group" +#endif + +#ifndef ARC_CONFIG_GROUP_SEPARATOR +#define ARC_CONFIG_GROUP_SEPARATOR "::" +#endif +/** + * @} +*/ + +/** + * @{ + * @brief tokens used in the config langauge, defined here for use in ARC_ConfigType_CopyFn and ARC_ConfigType_DestroyFn + * + * @note the grouping is based on the ascii table, but the ids are sequential to make finding tokens quicker (look at the lexer continious for more explanation) +*/ #define ARC_CONFIG_TAB 0x01 #define ARC_CONFIG_NEWLINE 0x02 @@ -282,6 +320,9 @@ void ARC_Config_UnloadFromFile(ARC_Config *config, ARC_String *data); #define ARC_CONFIG_LINE_CHARS 0x41 #define ARC_CONFIG_MULTI_LINE_CHARS 0x42 #define ARC_CONFIG_COMMENT_CHAR 0x43 +/** + * @} +*/ /** * @brief TODO: write this @@ -289,132 +330,266 @@ void ARC_Config_UnloadFromFile(ARC_Config *config, ARC_String *data); void ARC_Config_InitStd(ARC_Config *config); /** - * @brief + * @brief a function callback to create an ARC_Bool stored within a config + * + * @note this function is an ARC_ConfigType_CopyFn callback + * + * @param[out] type the place to store the type copy, should be set to NULL on error + * @param[in] parsedData the parsed data used to copy from. will be as defined in the language + * @param[in] config the config that is reading in the data, can be used within the copy function to add a new type (check ARC_ConfigType_SpriteCopyFn for an example) + * @param[in] userdata userdata that was stored in the type during type register */ void ARC_ConfigType_BoolCopyFn(void **type, ARC_ParserTagToken *parsedData, ARC_Config *config, void *userdata); /** - * @brief + * @brief a function callback to destroy an ARC_Bool type + * + * @note this function is an ARC_ConfigType_DestroyFn callback + * + * @param[in] config the config that is destroying the data, can be used within the destroy function to remove a previously added tag (check ARC_ConfigType_SpriteDestroyFn for an example) + * @param[in] type the type to be destroyed */ void ARC_ConfigType_BoolDestroyFn(ARC_Config *config, void *type); /** - * @brief -*/ -void ARC_ConfigType_CharCopyFn(void **type, ARC_ParserTagToken *parsedData, ARC_Config *config, void *userdata); - -/** - * @brief -*/ -void ARC_ConfigType_CharDestroyFn(ARC_Config *config, void *type); - -/** - * @brief + * @brief a function callback to create an int8_t stored within a config + * + * @note this function is an ARC_ConfigType_CopyFn callback + * + * @param[out] type the place to store the type copy, should be set to NULL on error + * @param[in] parsedData the parsed data used to copy from. will be as defined in the language + * @param[in] config the config that is reading in the data, can be used within the copy function to add a new type (check ARC_ConfigType_SpriteCopyFn for an example) + * @param[in] userdata userdata that was stored in the type during type register */ void ARC_ConfigType_Int8CopyFn(void **type, ARC_ParserTagToken *parsedData, ARC_Config *config, void *userdata); /** - * @brief + * @brief a function callback to destroy an int8_t type + * + * @note this function is an ARC_ConfigType_DestroyFn callback + * + * @param[in] config the config that is destroying the data, can be used within the destroy function to remove a previously added tag (check ARC_ConfigType_SpriteDestroyFn for an example) + * @param[in] type the type to be destroyed */ void ARC_ConfigType_Int8DestroyFn(ARC_Config *config, void *type); /** - * @brief + * @brief a function callback to create an uint8_t stored within a config + * + * @note this function is an ARC_ConfigType_CopyFn callback + * + * @param[out] type the place to store the type copy, should be set to NULL on error + * @param[in] parsedData the parsed data used to copy from. will be as defined in the language + * @param[in] config the config that is reading in the data, can be used within the copy function to add a new type (check ARC_ConfigType_SpriteCopyFn for an example) + * @param[in] userdata userdata that was stored in the type during type register */ void ARC_ConfigType_Uint8CopyFn(void **type, ARC_ParserTagToken *parsedData, ARC_Config *config, void *userdata); /** - * @brief + * @brief a function callback to destroy an uint8_t type + * + * @note this function is an ARC_ConfigType_DestroyFn callback + * + * @param[in] config the config that is destroying the data, can be used within the destroy function to remove a previously added tag (check ARC_ConfigType_SpriteDestroyFn for an example) + * @param[in] type the type to be destroyed */ void ARC_ConfigType_Uint8DestroyFn(ARC_Config *config, void *type); /** - * @brief + * @brief a function callback to create an int16_t stored within a config + * + * @note this function is an ARC_ConfigType_CopyFn callback + * + * @param[out] type the place to store the type copy, should be set to NULL on error + * @param[in] parsedData the parsed data used to copy from. will be as defined in the language + * @param[in] config the config that is reading in the data, can be used within the copy function to add a new type (check ARC_ConfigType_SpriteCopyFn for an example) + * @param[in] userdata userdata that was stored in the type during type register */ void ARC_ConfigType_Int16CopyFn(void **type, ARC_ParserTagToken *parsedData, ARC_Config *config, void *userdata); /** - * @brief + * @brief a function callback to destroy an int16_t type + * + * @note this function is an ARC_ConfigType_DestroyFn callback + * + * @param[in] config the config that is destroying the data, can be used within the destroy function to remove a previously added tag (check ARC_ConfigType_SpriteDestroyFn for an example) + * @param[in] type the type to be destroyed */ void ARC_ConfigType_Int16DestroyFn(ARC_Config *config, void *type); /** - * @brief + * @brief a function callback to create an uint16_t stored within a config + * + * @note this function is an ARC_ConfigType_CopyFn callback + * + * @param[out] type the place to store the type copy, should be set to NULL on error + * @param[in] parsedData the parsed data used to copy from. will be as defined in the language + * @param[in] config the config that is reading in the data, can be used within the copy function to add a new type (check ARC_ConfigType_SpriteCopyFn for an example) + * @param[in] userdata userdata that was stored in the type during type register */ void ARC_ConfigType_Uint16CopyFn(void **type, ARC_ParserTagToken *parsedData, ARC_Config *config, void *userdata); /** - * @brief + * @brief a function callback to destroy an uint16_t type + * + * @note this function is an ARC_ConfigType_DestroyFn callback + * + * @param[in] config the config that is destroying the data, can be used within the destroy function to remove a previously added tag (check ARC_ConfigType_SpriteDestroyFn for an example) + * @param[in] type the type to be destroyed */ void ARC_ConfigType_Uint16DestroyFn(ARC_Config *config, void *type); /** - * @brief + * @brief a function callback to create an int32_t stored within a config + * + * @note this function is an ARC_ConfigType_CopyFn callback + * + * @param[out] type the place to store the type copy, should be set to NULL on error + * @param[in] parsedData the parsed data used to copy from. will be as defined in the language + * @param[in] config the config that is reading in the data, can be used within the copy function to add a new type (check ARC_ConfigType_SpriteCopyFn for an example) + * @param[in] userdata userdata that was stored in the type during type register */ void ARC_ConfigType_Int32CopyFn(void **type, ARC_ParserTagToken *parsedData, ARC_Config *config, void *userdata); /** - * @brief + * @brief a function callback to destroy an int32_t type + * + * @note this function is an ARC_ConfigType_DestroyFn callback + * + * @param[in] config the config that is destroying the data, can be used within the destroy function to remove a previously added tag (check ARC_ConfigType_SpriteDestroyFn for an example) + * @param[in] type the type to be destroyed */ void ARC_ConfigType_Int32DestroyFn(ARC_Config *config, void *type); /** - * @brief + * @brief a function callback to create an uint32_t stored within a config + * + * @note this function is an ARC_ConfigType_CopyFn callback + * + * @param[out] type the place to store the type copy, should be set to NULL on error + * @param[in] parsedData the parsed data used to copy from. will be as defined in the language + * @param[in] config the config that is reading in the data, can be used within the copy function to add a new type (check ARC_ConfigType_SpriteCopyFn for an example) + * @param[in] userdata userdata that was stored in the type during type register */ void ARC_ConfigType_Uint32CopyFn(void **type, ARC_ParserTagToken *parsedData, ARC_Config *config, void *userdata); /** - * @brief + * @brief a function callback to destroy an uint32_t type + * + * @note this function is an ARC_ConfigType_DestroyFn callback + * + * @param[in] config the config that is destroying the data, can be used within the destroy function to remove a previously added tag (check ARC_ConfigType_SpriteDestroyFn for an example) + * @param[in] type the type to be destroyed */ void ARC_ConfigType_Uint32DestroyFn(ARC_Config *config, void *type); /** - * @brief + * @brief a function callback to create an int64_t stored within a config + * + * @note this function is an ARC_ConfigType_CopyFn callback + * + * @param[out] type the place to store the type copy, should be set to NULL on error + * @param[in] parsedData the parsed data used to copy from. will be as defined in the language + * @param[in] config the config that is reading in the data, can be used within the copy function to add a new type (check ARC_ConfigType_SpriteCopyFn for an example) + * @param[in] userdata userdata that was stored in the type during type register */ void ARC_ConfigType_Int64CopyFn(void **type, ARC_ParserTagToken *parsedData, ARC_Config *config, void *userdata); /** - * @brief + * @brief a function callback to destroy an int64_t type + * + * @note this function is an ARC_ConfigType_DestroyFn callback + * + * @param[in] config the config that is destroying the data, can be used within the destroy function to remove a previously added tag (check ARC_ConfigType_SpriteDestroyFn for an example) + * @param[in] type the type to be destroyed */ void ARC_ConfigType_Int64DestroyFn(ARC_Config *config, void *type); /** - * @brief + * @brief a function callback to create an uint64_t stored within a config + * + * @note this function is an ARC_ConfigType_CopyFn callback + * + * @param[out] type the place to store the type copy, should be set to NULL on error + * @param[in] parsedData the parsed data used to copy from. will be as defined in the language + * @param[in] config the config that is reading in the data, can be used within the copy function to add a new type (check ARC_ConfigType_SpriteCopyFn for an example) + * @param[in] userdata userdata that was stored in the type during type register */ void ARC_ConfigType_Uint64CopyFn(void **type, ARC_ParserTagToken *parsedData, ARC_Config *config, void *userdata); /** - * @brief + * @brief a function callback to destroy an uint64_t type + * + * @note this function is an ARC_ConfigType_DestroyFn callback + * + * @param[in] config the config that is destroying the data, can be used within the destroy function to remove a previously added tag (check ARC_ConfigType_SpriteDestroyFn for an example) + * @param[in] type the type to be destroyed */ void ARC_ConfigType_Uint64DestroyFn(ARC_Config *config, void *type); /** - * @brief + * @brief a function callback to create a float stored within a config + * + * @note this function is an ARC_ConfigType_CopyFn callback + * + * @param[out] type the place to store the type copy, should be set to NULL on error + * @param[in] parsedData the parsed data used to copy from. will be as defined in the language + * @param[in] config the config that is reading in the data, can be used within the copy function to add a new type (check ARC_ConfigType_SpriteCopyFn for an example) + * @param[in] userdata userdata that was stored in the type during type register */ void ARC_ConfigType_FloatCopyFn(void **type, ARC_ParserTagToken *parsedData, ARC_Config *config, void *userdata); /** - * @brief + * @brief a function callback to destroy a float type + * + * @note this function is an ARC_ConfigType_DestroyFn callback + * + * @param[in] config the config that is destroying the data, can be used within the destroy function to remove a previously added tag (check ARC_ConfigType_SpriteDestroyFn for an example) + * @param[in] type the type to be destroyed */ void ARC_ConfigType_FloatDestroyFn(ARC_Config *config, void *type); /** - * @brief + * @brief a function callback to create a double stored within a config + * + * @note this function is an ARC_ConfigType_CopyFn callback + * + * @param[out] type the place to store the type copy, should be set to NULL on error + * @param[in] parsedData the parsed data used to copy from. will be as defined in the language + * @param[in] config the config that is reading in the data, can be used within the copy function to add a new type (check ARC_ConfigType_SpriteCopyFn for an example) + * @param[in] userdata userdata that was stored in the type during type register */ void ARC_ConfigType_DoubleCopyFn(void **type, ARC_ParserTagToken *parsedData, ARC_Config *config, void *userdata); /** - * @brief + * @brief a function callback to destroy a double type + * + * @note this function is an ARC_ConfigType_DestroyFn callback + * + * @param[in] config the config that is destroying the data, can be used within the destroy function to remove a previously added tag (check ARC_ConfigType_SpriteDestroyFn for an example) + * @param[in] type the type to be destroyed */ void ARC_ConfigType_DoubleDestroyFn(ARC_Config *config, void *type); /** - * @brief + * @brief a function callback to create an ARC_String stored within a config + * + * @note this function is an ARC_ConfigType_CopyFn callback + * + * @param[out] type the place to store the type copy, should be set to NULL on error + * @param[in] parsedData the parsed data used to copy from. will be as defined in the language + * @param[in] config the config that is reading in the data, can be used within the copy function to add a new type (check ARC_ConfigType_SpriteCopyFn for an example) + * @param[in] userdata userdata that was stored in the type during type register */ void ARC_ConfigType_StringCopyFn(void **type, ARC_ParserTagToken *parsedData, ARC_Config *config, void *userdata); /** - * @brief + * @brief a function callback to destroy an ARC_String type + * + * @note this function is an ARC_ConfigType_DestroyFn callback + * + * @param[in] config the config that is destroying the data, can be used within the destroy function to remove a previously added tag (check ARC_ConfigType_SpriteDestroyFn for an example) + * @param[in] type the type to be destroyed */ void ARC_ConfigType_StringDestroyFn(ARC_Config *config, void *type);