updated vector to video version, will probably break a lot

This commit is contained in:
herbglitch 2024-08-27 03:23:29 -06:00
parent c1e60a6d2f
commit 93dc0fa053
12 changed files with 461 additions and 97 deletions

View file

@ -17,19 +17,27 @@ extern "C" {
extern int32_t arc_errno;
#ifdef ARC_DEBUG
#include <stdio.h>
//this is handy to override for if they user is doing terminal output and wants to change where logs are sent
extern FILE *arc_errno_log_file;
#ifndef ARC_DEBUG_LOG_STREAM_OVERRIDE
//this functin will be called on start, handy to set the log file to stdout if it is not overrided
void __attribute__ ((constructor)) ARC_Errno_SetDefaultStream(void);
#endif // !ARC_DEBUG_LOG_STREAM_OVERRIDE
#endif // !ARC_DEBUG
#ifdef __cplusplus
}
#endif
#ifdef ARC_DEBUG
# include <stdio.h>
# define ARC_DEBUG_LOG(ERR, STR, ...) printf("[ERROR %d] " STR "\n", ERR, __VA_ARGS__)
# define ARC_DEBUG_ERR(STR) printf("[ERROR %d] " STR "\n", arc_errno)
#define ARC_DEBUG_LOG_ERROR(STR) fprintf(arc_errno_log_file, "[ERROR %d] " STR "\n", arc_errno)
#define ARC_DEBUG_LOG_ERROR_WITH_VARIABLES(STR, ...) fprintf(arc_errno_log_file, "[ERROR %d] " STR "\n", arc_errno, __VA_ARGS__)
#else
# define ARC_DEBUG_LOG(ERR, STR, ...)
# define ARC_DEBUG_ERR(STR)
#endif
#define ARC_DEBUG_LOG_ERROR(STR)
#define ARC_DEBUG_LOG_ERROR_WITH_VARIABLES(STR, ...)
#endif // !ARC_DEBUG
#define ARC_ERR_CHECK(FUNC) FUNC; if(arc_errno){ ARC_DEBUG_LOG(arc_errno, "%s", #FUNC); return; }
#endif //ARC_STD_ERRNO_H_
#endif // !ARC_STD_ERRNO_H_

31
include/arc/std/lexer.h Normal file
View file

@ -0,0 +1,31 @@
#ifndef ARC_STD_LEXER_H_
#define ARC_STD_LEXER_H_
#ifdef __cplusplus
extern "C" {
#endif
/**
* @brief a lexer type
*/
typedef struct ARC_Lexer ARC_Lexer;
/**
* @brief
*
* @param[out] lexer
*/
void ARC_Lexer_Create(ARC_Lexer **lexer);
/**
* @brief
*
* @param[in] lexer ARC_Lexer to free
*/
void ARC_Lexer_Destroy(ARC_Lexer *lexer);
#ifdef __cplusplus
}
#endif
#endif // !ARC_STD_LEXER_H_

0
include/arc/std/parser.h Normal file
View file

View file

@ -5,81 +5,100 @@
extern "C" {
#endif
#include "arc/std/bool.h"
#include <stdint.h>
/**
* @brief a dynamic array type
*/
*/
typedef struct ARC_Vector ARC_Vector;
/**
* @brief data comparison function ptr
* @brief a callback that allows the user to define a way to check the data stored in a vector for a match
*
* @param a first data struct
* @param b second data struct
* @param[in] dataA the first data to check
* @param[in] dataB the second data to check
*
* @return 0 when a == b, TODO: return and ARC_Bool
* @return ARC_True when dataA == dataB, and ARC_False otherwise
*/
typedef int32_t (* ARC_Vector_CompareDataFn)(void *a, void *b);
typedef ARC_Bool (* ARC_Vector_CompareDataFn)(void *dataA, void *dataB);
/**
* @brief creates ARC_Vector type
* @brief creates an ARC_Vector which is an "expandable" array
*
* @param vector ARC_Vector to initialize
*/
void ARC_Vector_Create(ARC_Vector **vector);
* @note for this basic implementation, the array will double in size every time the capacity is hit
* @note the array will also half in size when the array is only half filled
*
* @param[out] vector ARC_Vector to initialize
* @param[in] compareDataFn a callback that checks if data stored in the array matches,
* if set to NULL and ARC_Vector_Remove is called, the pointer addresses will be compared
*/
void ARC_Vector_Create(ARC_Vector **vector, ARC_Vector_CompareDataFn *compareDataFn);
/**
* @brief destroyes ARC_Vector type
*/
* @brief destroys an ARC_Vector
*
* @note this will not free the items stored in the vector
* @note please make sure to clear and free the children before destroying an ARC_Vector
*
* @param[in] vector ARC_Vector to free
*/
void ARC_Vector_Destroy(ARC_Vector *vector);
/**
* @brief adds value to vector
* @brief adds an item to an ARC_Vector
*
* @param vector ARC_Vector to add to
* @param data data that is being added
*/
* @note this will error if you add more than 4,294,967,295 items (the max value of an unsigned int 32)
*
* @param[in] vector ARC_Vector to add to
* @param[in] data data that is being added
*/
void ARC_Vector_Add(ARC_Vector *vector, void *data);
/**
* @brief remove from ARC_Vector
* @brief removes an item from a matching item in an ARC_Vector
*
* @param vector ARC_Vector to remove from
* @param data data that is being removed
* @param compare comparison callback to get check if data should be removed
*/
void ARC_Vector_Remove(ARC_Vector *vector, void *data, ARC_Vector_CompareDataFn compare);
* @note this function uses the ARC_Vector_CompareDataFn that the ARC_Vector was created with
* @note this function will not throw an error if there is no match
*
* @param[in] vector ARC_Vector to remove from
* @param[in] data matching data to remove
*/
void ARC_Vector_Remove(ARC_Vector *vector, void *data);
/**
* @brief remove from ARC_Vector
* @brief removes an item from an ARC_Vector at an index
*
* @param vector ARC_Vector to remove from
* @param index index of data that is being removed
*/
* @note this function will error if trying to remove an index that is outside the bounds of the ARC_Vector
*
* @param[in] vector ARC_Vector to remove from
* @param[in] index position of data to remove
*/
void ARC_Vector_RemoveIndex(ARC_Vector *vector, uint32_t index);
/**
* @brief gets size of vector
* @brief gets the current size of an ARC_Vector as an unsigned 32 bit integer
*
* @param vector ARC_Vector to get size from
* @param[in] vector ARC_Vector to get current size from
*
* @return the pointer of the vectors size, TODO: don't pass as a pointer
*/
uint32_t ARC_Vector_Size(ARC_Vector *vector);
* @return the current size as a unsigned 32 bit integer
*/
uint32_t ARC_Vector_GetSize(ARC_Vector *vector);
/**
* @brief gets data from ARC_Vector at position index
* @brief gets an item from an ARC_Vector at a position index
*
* @param vector ARC_Vector to get data from
* @param index position of data in ARC_Vector
* @note this function will error if trying to get an index that is outside the bounds of the ARC_Vector
*
* @return pointer to data on success, NULL on fail
*/
* @param[in] vector ARC_Vector to get data from
* @param[in] index position of data to get
*
* @return a void * item, or NULL on error
*/
void *ARC_Vector_Get(ARC_Vector *vector, uint32_t index);
#ifdef __cplusplus
}
#endif
#endif //ARC_STD_VECTOR_H_
#endif // !ARC_STD_VECTOR_H_