|
Serene Runtime 1.0.0-dev
C runtime for the Serene programming language
|
Source manager is what that read the source files and own the buffer that contains the data. More...
#include <stddef.h>#include "serene/rt/fiber/mutex.h"#include "serene/rt/fiber/thread.h"#include "serene/rt/impl/array_list.h"#include "serene/rt/impl/hashmap.h"#include "serene/utils.h"Go to the source code of this file.
Data Structures | |
| struct | srn_sm_maybe_id_t |
| struct | srn_sm_buffer_t |
| struct | srn_sm_maybe_buffer_t |
| struct | srn_sm_t |
Macros | |
| #define | SRN_SM_NO_ID UINTPTR_MAX |
| #define | SM_TRACEPOINT(...) |
Typedefs | |
| typedef size_t | srn_sm_buffer_id_t |
| typedef struct srn_sm_maybe_id_t | srn_sm_maybe_id_t |
| typedef struct srn_sm_buffer_t | srn_sm_buffer_t |
| typedef struct srn_sm_maybe_buffer_t | srn_sm_maybe_buffer_t |
| typedef struct srn_sm_t | srn_sm_t |
Functions | |
| srn_sm_t * | srn_sm_init (srn_context_t *ctx) |
| Initialize the source manager, as an immortal data structure. | |
| void | srn_sm_shutdown (srn_sm_t *sm) |
| Shutdown the source manager freeing all the buffers. | |
| srn_sm_buffer_t * | srn_sm_get_buffer (srn_sm_t *sm, srn_sm_buffer_id_t id) |
| Return the buffer pointer of the given id, nullptr if the id does not exists. | |
| srn_sm_maybe_id_t | srn_sm_read_buffer_file (srn_sm_t *sm, const char *filepath, bool reread) |
| Read and buffer the given filepath into the source manager and return the buffer id. | |
| srn_sm_maybe_buffer_t | srn_sm_buffer_file (srn_sm_t *sm, const char *filepath, bool reread) |
| Read and buffer the given filepath into the source manager and return a srn_sm_maybe_buffer_t which either fails or has a pointer to the buffer containing the content of the file. | |
| static const unsigned char * | srn_sm_buffer_data (srn_sm_buffer_t *buf) |
| static size_t | srn_sm_buffer_len (srn_sm_buffer_t *buf) |
Source manager is what that read the source files and own the buffer that contains the data.
Notes:
Definition in file source_manager.h.
| #define SM_TRACEPOINT | ( | ... | ) |
Definition at line 63 of file source_manager.h.
| #define SRN_SM_NO_ID UINTPTR_MAX |
Definition at line 61 of file source_manager.h.
| typedef size_t srn_sm_buffer_id_t |
Definition at line 66 of file source_manager.h.
| typedef struct srn_sm_buffer_t srn_sm_buffer_t |
| typedef struct srn_sm_maybe_buffer_t srn_sm_maybe_buffer_t |
| typedef struct srn_sm_maybe_id_t srn_sm_maybe_id_t |
| typedef struct srn_sm_t srn_sm_t |
|
inlinestatic |
Definition at line 131 of file source_manager.h.
| srn_sm_maybe_buffer_t srn_sm_buffer_file | ( | srn_sm_t * | sm, |
| const char * | filepath, | ||
| bool | reread ) |
Read and buffer the given filepath into the source manager and return a srn_sm_maybe_buffer_t which either fails or has a pointer to the buffer containing the content of the file.
A nullptr for the buffer means an empty file.
Definition at line 282 of file source_manager.c.
|
inlinestatic |
| srn_sm_buffer_t * srn_sm_get_buffer | ( | srn_sm_t * | sm, |
| srn_sm_buffer_id_t | id ) |
Return the buffer pointer of the given id, nullptr if the id does not exists.
Definition at line 77 of file source_manager.c.
| srn_sm_t * srn_sm_init | ( | srn_context_t * | ctx | ) |
Initialize the source manager, as an immortal data structure.
The buffers themselves will NOT be managed by the the memory manager.
Definition at line 37 of file source_manager.c.
| srn_sm_maybe_id_t srn_sm_read_buffer_file | ( | srn_sm_t * | sm, |
| const char * | filepath, | ||
| bool | reread ) |
Read and buffer the given filepath into the source manager and return the buffer id.
If the file already exists, it will just return the buffer id, unless the reread is true, which will reread the file and populate the buffer. It will NOT overwrite the old buffer.
Definition at line 174 of file source_manager.c.
| void srn_sm_shutdown | ( | srn_sm_t * | sm | ) |
Shutdown the source manager freeing all the buffers.
After this call all the pointers into the buffers will be invalid.
Definition at line 68 of file source_manager.c.