MIRROR: javascript for ๐Ÿœ's, a tiny runtime with big ambitions
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

add support for function pointers in readline module

+10 -4
+8 -4
src/modules/readline.c
··· 258 258 static void move_cursor_to_line_start(rl_interface_t *iface, int cols) { 259 259 int prompt_len = (int)strlen(iface->prompt); 260 260 int cursor_cols = prompt_len + iface->line_pos; 261 - int cursor_row = cursor_cols > 0 ? (cursor_cols - 1) / cols : 0; 261 + int cursor_row = cursor_cols / cols; 262 + if (cursor_cols > 0 && cursor_cols % cols == 0) cursor_row--; 262 263 263 264 if (cursor_row > 0) { 264 265 char move_buf[32]; ··· 621 622 622 623 char *event = js_getstr(js, args[0], NULL); 623 624 if (!event) return js_mkerr(js, "event must be a string"); 624 - if (vtype(args[1]) != T_FUNC) return js_mkerr(js, "listener must be a function"); 625 + int t = vtype(args[1]); 626 + if (t != T_FUNC && t != T_CFUNC) return js_mkerr(js, "listener must be a function"); 625 627 626 628 RLEventType *evt = find_or_create_event_type(iface, event); 627 629 if (evt->listener_count >= MAX_LISTENERS_PER_EVENT) { ··· 644 646 645 647 char *event = js_getstr(js, args[0], NULL); 646 648 if (!event) return js_mkerr(js, "event must be a string"); 647 - if (vtype(args[1]) != T_FUNC) return js_mkerr(js, "listener must be a function"); 649 + int t = vtype(args[1]); 650 + if (t != T_FUNC && t != T_CFUNC) return js_mkerr(js, "listener must be a function"); 648 651 649 652 RLEventType *evt = find_or_create_event_type(iface, event); 650 653 if (evt->listener_count >= MAX_LISTENERS_PER_EVENT) { ··· 937 940 char *query = js_getstr(js, args[0], &query_len); 938 941 if (!query) return js_mkerr(js, "query must be a string"); 939 942 940 - if (vtype(args[1]) != T_FUNC) { 943 + int t = vtype(args[1]); 944 + if (t != T_FUNC && t != T_CFUNC) { 941 945 return js_mkerr(js, "callback must be a function"); 942 946 } 943 947
+2
src/stack.c
··· 1 1 #include "stack.h" 2 2 #include "arena.h" 3 3 4 + #include <limits.h> 4 5 #include <stdint.h> 5 6 #include <stdlib.h> 6 7 #include <string.h> ··· 15 16 bool push_call_frame(const char *filename, const char *function_name, const char *code, uint32_t pos) { 16 17 if (global_call_stack.depth >= global_call_stack.capacity) { 17 18 size_t new_capacity = global_call_stack.capacity == 0 ? 32U : (size_t)global_call_stack.capacity * 2U; 19 + if (new_capacity > (size_t)INT_MAX) abort(); 18 20 if (new_capacity > SIZE_MAX / sizeof(call_frame_t)) abort(); 19 21 20 22 size_t alloc_size = new_capacity * sizeof(call_frame_t);