added basic documentation/boilerplate up till ARC_Lexer for the standard library documentation

This commit is contained in:
herbglitch 2024-12-30 05:22:12 -07:00
parent 442f74b195
commit 7b5194dc05
15 changed files with 153 additions and 0 deletions

View file

@ -0,0 +1,20 @@
\page standard-array ARC_Array
The ARC_Array is a simple type, all it does is have a `void *` to store the array data in and a `uint32_t` to store the size in. This type is mostly a helper type to cut down on the number of parameters needed within Archeus' functions
Example:
```c
#include <arc/std/array.h>
#include <stdlib.h>
//initing the array (as it is a basic type there is no ARC_Array_Create or ARC_Array_Destroy)
ARC_Array exampleArray;
exampleArray.size = 4;
exampleArray.data = malloc(sizeof(uint32_t) * exampleArray.size);
//example function using an ARC_Array
ARC_Example_RunArray(&exampleArray);
//cleanup
free(exampleArray.data);
```

View file

@ -0,0 +1,34 @@
\page standard-bool ARC_Bool
The ::ARC_Bool type simple sets ::ARC_Bool to the `stdbool.h` `bool` type, ::ARC_True to true, and ::ARC_False to false. This type exists so that it can be overriden if a different boolean type should be used (like with opengl)
Basic Example:
```c
#include <arc/std/bool.h>
ARC_Bool example = ARC_True;
//this example is very pedantic, saying `== ARC_True` isn't required, just recommended
if(example == ARC_True){
//this will be executed
}
```
Override Example:
```c
#include <stdint.h>
//this should be called at the start of the program
#define ARC_BOOL_OVERRIDE
#define ARC_Bool uint8_t
#define ARC_True 1
#define ARC_False 0
#include <arc/std/bool.h>
ARC_Bool example = ARC_False;
if(example != ARC_True){
//this will be executed
}
```

View file

@ -0,0 +1,3 @@
\page standard-chemical ARC_Chemical
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)

View file

@ -0,0 +1,63 @@
\page standard-errno ARC_Errno
*Note: this file is being actively worked on and might change during minor updates*
## About
arc/std/errno.h is used for handling errors as well as printing to debug. It defines a global `uint32_t` ::arc_errno, as well as a global `FILE` ::arc_errno_log_file. For now it just has printing errors, but in the future it is planned to have warnings and general logs added. For error logs to be printed, `ARC_DEBUG` needs to be defined when compiled.
## Basic Error Handling
When throwing errors, ::arc_errno should usually be set to an ARC_ERRNO_ define describing the error. After setting ::arc_errno it is strongly recommended to log that the error happened (this really helps when debugging).
Basic Example:
```c
#include <arc/std/errno.h>
void ARC_Example_ThrowNullError(){
uint32_t *exampleNumber = NULL;
if(exampleNumber == NULL){
//set arc_errno to the most applicable error
arc_errno = ARC_ERRNO_NULL;
//log where the error happened
ARC_DEBUG_LOG_ERROR("ARC_Example_ThrowNullError(), exampleNumber was NULL");
}
}
```
## Error Handling With More Information
Sometimes the error will have data that could be helpful when debugging, so there is also a log macro that can log the error with variables added. The formatting is the same as printf.
Example With Variables:
```c
#include <arc/std/errno.h>
#include <arc/std/string.h>
void ARC_Example_ThrowPathError(ARC_String *path){
ARC_String *data;
/* .. try loading data from path here .. */
if(data == NULL){
//set arc_errno to the most applicable error
arc_errno = ARC_ERRNO_DATA;
//log where the error happened
ARC_DEBUG_LOG_ERROR_WITH_VARIABLES("ARC_Example_ThrowPathError(path), path was %s", path->data);
}
}
```
## Overriding Output File
By default the logs will output to stdout, however this can has an override by defining ARC_DEBUG_LOG_STREAM_OVERRIDE
Example of Overriding Log Stream:
```c
//when compiling, ARC_DEBUG_LOG_STREAM_OVERRIDE needs to be set, then just add
//this sets the output to a example_out.txt file that has write permissions
arc_errno_log_file = fopen("example_out.txt", "w");
```

View file

@ -0,0 +1,3 @@
\page standard-hashtable ARC_Hashtable
*This page will be written after refactoring the ::ARC_Hashtable type*

3
doc/pages/standard/io.md Normal file
View file

@ -0,0 +1,3 @@
\page standard-io ARC_IO
*This page will be written after refactoring the arc/std/io.h header*

View file

@ -0,0 +1 @@
\page standard-lexer ARC_Lexer

View file

@ -0,0 +1 @@
\page standard-parser ARC_Parser

View file

@ -0,0 +1 @@
\page standard-queue ARC_Queue

View file

@ -0,0 +1 @@
\page standard-stack ARC_Stack

View file

@ -0,0 +1 @@
\page standard-string ARC_String

View file

@ -0,0 +1 @@
\page standard-time ARC_Time

View file

@ -0,0 +1 @@
\page standard-vector ARC_Vector