diff options
Diffstat (limited to 'include')
-rw-r--r-- | include/ucode/source.h | 11 | ||||
-rw-r--r-- | include/ucode/types.h | 6 |
2 files changed, 13 insertions, 4 deletions
diff --git a/include/ucode/source.h b/include/ucode/source.h index b05e84b..e0339a4 100644 --- a/include/ucode/source.h +++ b/include/ucode/source.h @@ -37,8 +37,15 @@ uc_source_t *uc_source_new_buffer(const char *name, char *buf, size_t len); size_t uc_source_get_line(uc_source_t *source, size_t *offset); -uc_source_t *uc_source_get(uc_source_t *source); -void uc_source_put(uc_source_t *source); +static inline uc_source_t * +uc_source_get(uc_source_t *source) { + return (uc_source_t *)ucv_get(source ? &source->header : NULL); +} + +static inline void +uc_source_put(uc_source_t *source) { + ucv_put(source ? &source->header : NULL); +} uc_source_type_t uc_source_type_test(uc_source_t *source); diff --git a/include/ucode/types.h b/include/ucode/types.h index ff87ca7..8e2030a 100644 --- a/include/ucode/types.h +++ b/include/ucode/types.h @@ -40,7 +40,8 @@ typedef enum uc_type { UC_CLOSURE, UC_UPVALUE, UC_RESOURCE, - UC_PROGRAM + UC_PROGRAM, + UC_SOURCE } uc_type_t; typedef struct uc_value { @@ -66,9 +67,10 @@ typedef struct { uc_declare_vector(uc_lineinfo_t, uint8_t); typedef struct { + uc_value_t header; char *filename, *runpath, *buffer; FILE *fp; - size_t usecount, off; + size_t off; uc_lineinfo_t lineinfo; } uc_source_t; |