Ludovic 'Archivist' Lagouardette 6 months ago
parent
commit
3803deda06
2 changed files with 29 additions and 8 deletions
  1. +27
    -0
      include/ink.h
  2. +2
    -8
      lib.c

+ 27
- 0
include/ink.h View File

@ -321,6 +321,33 @@ struct elem ink_make_transparent(struct context* ctx, int type_id, void* ptr);
*/
void ink_gc(struct context* ctx);
/**
* Obtains the type id from the declared name of the type
* @param ctx The context where we want to detect the type
* @param name The name of the type
* @return the type id if it exists, -1 otherwise
*/
int get_type_by_name(struct context* ctx, const char* name);
/**
* The internal representation of arrays in ink
*/
struct ink_array {
int top;
int capacity;
struct elem* elements;
};
/**
* Pushes a value in an array. in case of failure, panics the routine
*
* @param ctx the working context
* @param currentRoutine the routine that will panic
* @param ary the array to be incremented
* @param value the value to push
*/
void array_push(struct context* ctx, struct ink_routine* currentRoutine, struct ink_array* ary, struct elem value);
#ifdef __cplusplus
};
#endif

+ 2
- 8
lib.c View File

@ -1509,7 +1509,7 @@ static void print_as_utf8(struct context* ctx) {
ink_pop(ctx);
}
static int get_type_by_name(struct context* ctx, const char* name) {
int get_type_by_name(struct context* ctx, const char* name) {
int i;
for(i = 0; i < ctx->types_top; ++i) {
if(strcmp(ctx->types[i].name, name) == 0) {
@ -1570,12 +1570,6 @@ static struct ink_collection_list gc_noop() {
#ifndef NOARRAYLIB
struct ink_array {
int top;
int capacity;
struct elem* elements;
};
static void collect_array(struct context* ctx, void* array) {
struct ink_array* ary;
ary = array;
@ -1613,7 +1607,7 @@ static void push_array_stack_delim(struct context* ctx) {
ink_push(ctx, e);
}
static void array_push(struct context* ctx, struct ink_routine* currentRoutine, struct ink_array* ary, struct elem value) {
void array_push(struct context* ctx, struct ink_routine* currentRoutine, struct ink_array* ary, struct elem value) {
if(ary->elements == NULL) {
ary->elements = ctx->malloc(sizeof(struct elem) * 8);
ary->top = 0;

Loading…
Cancel
Save