symbolic4
foundation.h
Go to the documentation of this file.
1 
2 /*
3 
4  Copyright (c) 2019 Hannes Eberhard
5 
6  Permission is hereby granted, free of charge, to any person obtaining a copy
7  of this software and associated documentation files (the "Software"), to deal
8  in the Software without restriction, including without limitation the rights
9  to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10  copies of the Software, and to permit persons to whom the Software is
11  furnished to do so, subject to the following conditions:
12 
13  The above copyright notice and this permission notice shall be included in all
14  copies or substantial portions of the Software.
15 
16  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22  SOFTWARE.
23 
24  */
25 
26 #ifndef foundation_h
27 #define foundation_h
28 
29 #include "symbolic4.h"
30 
31 #define ERROR_CHECK(F) if ((F) == RETS_ERROR) return RETS_ERROR ///< Check if the return status of a function is @c RETS_ERROR. If so, return @c RETS_ERROR.
32 
33 typedef enum {
47 } error_domain;
48 
49 typedef enum {
63 
64 typedef enum {
71 
72 typedef struct {
75  char body[20];
76 } error;
77 
78 extern error current_error;
79 extern void** allocated_pointers;
80 extern bool smart_alloc_is_recording;
81 
82 void* smart_alloc(uint8_t length, size_t size);
83 void* smart_realloc(void* source, uint8_t length, size_t size);
84 void smart_free(void* pointer);
85 void smart_free_all(void);
86 uint8_t set_error(error_domain domain, error_identifier identifier, const char* body);
87 void set_handle_unrecoverable_error(error_domain domain, error_identifier identifier, const char* body);
88 double uintmax_max_value(void);
89 char* string_to_lower(const char* string);
90 void itoa(char* buffer, uintmax_t source);
91 void dtoa(char* buffer, uint8_t length, double source);
92 
93 #endif /* foundation_h */
ERRI_ARGUMENTS
Definition: foundation.h:58
symbolic4.h
ERRI_UNDEFINED_VALUE
Definition: foundation.h:60
string_to_lower
char * string_to_lower(const char *string)
Converts a string to lowercase.
Definition: foundation.c:206
ERRI_VECTOR_DIMENSIONS
Definition: foundation.h:59
ERRD_SOLVE
Definition: foundation.h:41
ERRI_NULL
Definition: foundation.h:50
ERRD_POLY
Definition: foundation.h:44
ERRI_UNEXPECTED_CHARACTER
Definition: foundation.h:52
ERRD_NULL
Definition: foundation.h:34
ERRD_VECTOR
Definition: foundation.h:46
error::identifier
error_identifier identifier
Definition: foundation.h:74
ERRI_FUNCTION_CALL_SYNTAX
Definition: foundation.h:54
ERRD_PARSER
Definition: foundation.h:39
ERRD_SYNTAX
Definition: foundation.h:36
ERRI_SYNTAX
Definition: foundation.h:55
ERRD_DERIVATIVE
Definition: foundation.h:42
error
Definition: foundation.h:72
ERRD_INTEGRAL
Definition: foundation.h:43
smart_free_all
void smart_free_all(void)
Frees all pointers.
Definition: foundation.c:133
ERRI_MEMORY_ALLOCATION
Definition: foundation.h:51
RETS_NULL
Definition: foundation.h:65
ERRD_MATRIX
Definition: foundation.h:45
RETS_UNCHANGED
Definition: foundation.h:69
current_error
error current_error
Definition: foundation.c:28
RETS_SUCCESS
Definition: foundation.h:67
allocated_pointers
void ** allocated_pointers
Definition: foundation.c:29
RETS_CHANGED
Definition: foundation.h:68
RETS_ERROR
Definition: foundation.h:66
smart_free
void smart_free(void *pointer)
Frees a pointer.
Definition: foundation.c:112
error::domain
error_domain domain
Definition: foundation.h:73
smart_alloc_is_recording
bool smart_alloc_is_recording
Definition: foundation.c:30
set_handle_unrecoverable_error
void set_handle_unrecoverable_error(error_domain domain, error_identifier identifier, const char *body)
Handles severe and unrecoverable errors.
Definition: foundation.c:181
smart_alloc
void * smart_alloc(uint8_t length, size_t size)
Allocates and keeps track of memory.
Definition: foundation.c:59
ERRD_SYSTEM
Definition: foundation.h:35
error_identifier
error_identifier
Definition: foundation.h:49
itoa
void itoa(char *buffer, uintmax_t source)
Definition: foundation.c:216
smart_realloc
void * smart_realloc(void *source, uint8_t length, size_t size)
Resizes a pointer.
Definition: foundation.c:86
ERRI_NON_DIFFERENTIABLE
Definition: foundation.h:61
ERRD_MATH
Definition: foundation.h:37
uintmax_max_value
double uintmax_max_value(void)
Definition: foundation.c:188
set_error
uint8_t set_error(error_domain domain, error_identifier identifier, const char *body)
Sets current_error to the arguments provided.
Definition: foundation.c:152
ERRI_UNEXPECTED_EXPRESSION
Definition: foundation.h:53
return_status
return_status
Definition: foundation.h:64
ERRD_EXPRESSION
Definition: foundation.h:38
error_domain
error_domain
Definition: foundation.h:33
ERRI_MAX_INT_VALUE_EXCEEDED
Definition: foundation.h:57
ERRI_PARENTHESIS_MISMATCH
Definition: foundation.h:56
ERRD_SIMPLFY
Definition: foundation.h:40
dtoa
void dtoa(char *buffer, uint8_t length, double source)
Definition: foundation.c:233