|
Serene Runtime 1.0.0-dev
C runtime for the Serene programming language
|
#include "serene/rt/source_manager.h"#include <errno.h>#include <fcntl.h>#include <limits.h>#include <string.h>#include <sys/stat.h>#include <unistd.h>#include "serene/rt/context.h"#include "serene/rt/engine.h"#include "serene/rt/errors.h"#include "serene/rt/fiber/io.h"#include "serene/rt/impl/array_list.h"#include "serene/rt/impl/hashmap.h"#include "serene/rt/mm/interface.h"#include "serene/utils.h"Go to the source code of this file.
Data Structures | |
| struct | maybe_buffer_t |
Typedefs | |
| typedef struct maybe_buffer_t | maybe_buffer_t |
Functions | |
| srn_sm_t * | srn_sm_init (srn_context_t *ctx) |
| Initialize the source manager, as an immortal data structure. | |
| static srn_error_t * | free_each_buffer_chain (array_list_t *al, size_t n, void *data) |
| 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. | |
| static maybe_buffer_t | read_file (srn_sm_t *sm, const char *filepath) |
| 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. | |
| typedef struct maybe_buffer_t maybe_buffer_t |
|
static |
Definition at line 50 of file source_manager.c.
|
inlinestatic |
Definition at line 96 of file source_manager.c.
| 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.
| 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.