10#include "prism/compiler/exported.h"
11#include "prism/compiler/filesystem.h"
12#include "prism/compiler/nodiscard.h"
13#include "prism/compiler/nonnull.h"
PRISM_EXPORTED_FUNCTION const uint8_t * pm_source_source(const pm_source_t *source) PRISM_NONNULL(1)
Returns a pointer to the source data.
PRISM_EXPORTED_FUNCTION PRISM_NODISCARD pm_source_t * pm_source_file_new(const char *filepath, pm_source_init_result_t *result) PRISM_NONNULL(1
Create a new source by reading a file into a heap-allocated buffer.
int() pm_source_stream_feof_t(void *stream)
This function is used to check whether a stream is at EOF.
Definition source.h:34
PRISM_EXPORTED_FUNCTION PRISM_NODISCARD pm_source_t PRISM_EXPORTED_FUNCTION PRISM_NODISCARD pm_source_t PRISM_EXPORTED_FUNCTION PRISM_NODISCARD pm_source_t * pm_source_stream_new(void *stream, pm_source_stream_fgets_t *fgets, pm_source_stream_feof_t *feof)
Create a new source by reading from a stream using the provided callbacks.
PRISM_EXPORTED_FUNCTION PRISM_NODISCARD pm_source_t * pm_source_constant_new(const uint8_t *data, size_t length)
Create a new source that wraps existing constant memory.
PRISM_EXPORTED_FUNCTION PRISM_NODISCARD pm_source_t * pm_source_owned_new(uint8_t *data, size_t length)
Create a new source that owns its memory.
char *() pm_source_stream_fgets_t(char *string, int size, void *stream)
This function is used to retrieve a line of input from a stream.
Definition source.h:28
struct pm_source_t pm_source_t
An opaque type representing source code being parsed.
Definition source.h:21
PRISM_EXPORTED_FUNCTION PRISM_NODISCARD pm_source_t PRISM_EXPORTED_FUNCTION PRISM_NODISCARD pm_source_t * pm_source_mapped_new(const char *filepath, int open_flags, pm_source_init_result_t *result) PRISM_NONNULL(1
Create a new source by memory-mapping a file.
PRISM_EXPORTED_FUNCTION size_t pm_source_length(const pm_source_t *source) PRISM_NONNULL(1)
Returns the length of the source data in bytes.
PRISM_EXPORTED_FUNCTION PRISM_NODISCARD pm_source_t * pm_source_shared_new(const uint8_t *data, size_t length)
Create a new source that wraps existing shared memory.
PRISM_EXPORTED_FUNCTION void pm_source_free(pm_source_t *source) PRISM_NONNULL(1)
Free the given source and any memory it owns.
pm_source_init_result_t
Represents the result of initializing a source from a file.
Definition source.h:39
@ PM_SOURCE_INIT_ERROR_GENERIC
Indicates a generic error from a source init function, where the type of error should be read from er...
Definition source.h:47
@ PM_SOURCE_INIT_SUCCESS
Indicates that the source was successfully initialized.
Definition source.h:41
@ PM_SOURCE_INIT_ERROR_NON_REGULAR
Indicates that the file is not a regular file (e.g.
Definition source.h:58
@ PM_SOURCE_INIT_ERROR_DIRECTORY
Indicates that the file that was attempted to be opened was a directory.
Definition source.h:52