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.

move everything to init_module pattern

+17 -13
+1 -3
include/modules/crypto.h
··· 1 1 #ifndef CRYPTO_H 2 2 #define CRYPTO_H 3 3 4 - #include "ant.h" 5 - 6 - void init_crypto_module(struct js *js, jsval_t ant_obj); 4 + void init_crypto_module(); 7 5 8 6 #endif
+1 -2
include/modules/timer.h
··· 1 1 #ifndef TIMER_H 2 2 #define TIMER_H 3 3 4 - #include <stdint.h> 5 4 #include "ant.h" 6 5 7 - void init_timer_module(struct js *js); 6 + void init_timer_module(void); 8 7 void process_timers(struct js *js); 9 8 void process_microtasks(struct js *js); 10 9 void queue_microtask(struct js *js, jsval_t callback);
+1 -1
meson.build
··· 41 41 build_date = run_command('date', '+%Y-%m-%d', check: true).stdout().strip() 42 42 43 43 version_conf = configuration_data() 44 - version_conf.set('ANT_VERSION', '0.0.5.55') 44 + version_conf.set('ANT_VERSION', '0.0.5.56') 45 45 version_conf.set('ANT_GIT_HASH', git_hash) 46 46 version_conf.set('ANT_BUILD_DATE', build_date) 47 47
+4 -5
src/main.c
··· 202 202 struct ant_runtime *rt = ant_runtime_init(js); 203 203 204 204 init_builtin_module(); 205 + init_crypto_module(); 206 + init_fetch_module(); 205 207 init_console_module(); 206 208 init_json_module(); 207 - init_fetch_module(); 208 209 init_server_module(); 210 + init_timer_module(); 209 211 210 - init_timer_module(js); 211 - init_crypto_module(js, rt->ant_obj); 212 + jsval_t exports_obj = js_mkobj(js); 212 213 213 214 js_set(js, rt->ant_obj, "require", js_mkfun(js_require)); 214 - 215 - jsval_t exports_obj = js_mkobj(js); 216 215 js_set(js, rt->ant_obj, "exports", exports_obj); 217 216 218 217 int result = execute_module(js, module_file);
+6 -1
src/modules/crypto.c
··· 4 4 #include <uuidv7.h> 5 5 #include <uuid/uuid.h> 6 6 7 + #include "ant.h" 8 + #include "runtime.h" 7 9 #include "modules/crypto.h" 8 10 9 11 static int ensure_crypto_init(struct js *js) { ··· 127 129 return js_mkstr(js, uuid_str, strlen(uuid_str)); 128 130 } 129 131 130 - void init_crypto_module(struct js *js, jsval_t ant_obj) { 132 + void init_crypto_module() { 133 + struct js *js = rt->js; 134 + jsval_t ant_obj = rt->ant_obj; 135 + 131 136 jsval_t crypto_obj = js_mkobj(js); 132 137 js_set(js, ant_obj, "Crypto", crypto_obj); 133 138
+4 -1
src/modules/timer.c
··· 5 5 #include <time.h> 6 6 #include <unistd.h> 7 7 8 + #include "runtime.h" 8 9 #include "modules/timer.h" 9 10 10 11 typedef struct timer_entry { ··· 217 218 return min_timeout; 218 219 } 219 220 220 - void init_timer_module(struct js *js) { 221 + void init_timer_module() { 222 + struct js *js = rt->js; 223 + 221 224 timer_state.js = js; 222 225 jsval_t global = js_glob(js); 223 226