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.

at mir/inline-method 67 lines 1.4 kB view raw
1#ifndef ANT_UTILS_H 2#define ANT_UTILS_H 3#define ARGTABLE_COUNT 10 4 5#include <stdlib.h> 6#include <stdint.h> 7#include <string.h> 8 9typedef struct { 10 char *ptr; 11 char *heap; 12} cstr_buf_t; 13 14extern const char *const module_resolve_extensions[]; 15uint64_t hash_key(const char *key, size_t len); 16 17double half_to_double(uint16_t bits16); 18uint16_t double_to_half(double value); 19 20char hex_char(int v); 21char *resolve_js_file(const char *filename); 22char *resolve_typescript_source_fallback(const char *filename); 23 24int hex_digit(char c); 25int is_typescript_file(const char *filename); 26 27int strip_typescript_inplace( 28 char **buffer, 29 size_t len, 30 const char *filename, 31 int is_module, 32 size_t *out_len, 33 const char **error_detail 34); 35 36void *try_oom(size_t size); 37void cstr_free(cstr_buf_t *buf); 38 39char *cstr_init( 40 cstr_buf_t *buf, 41 char *stack, 42 size_t stack_size, 43 const char *src, 44 size_t len 45); 46 47#define CSTR_BUF(name, size) \ 48 char name##_stack[size]; \ 49 cstr_buf_t name = {0} 50 51#define CSTR_INIT(buf, src, len) \ 52 cstr_init(&(buf), buf##_stack, sizeof(buf##_stack), (src), (len)) 53 54typedef struct { 55 const char *ptr; 56 size_t len; 57} repl_capture_t; 58 59bool repl_template( 60 const char *repl, size_t repl_len, 61 const char *matched, size_t matched_len, 62 const char *str, size_t str_len, size_t position, 63 const repl_capture_t *caps, int ncaptures, 64 char **buf, size_t *buf_len, size_t *buf_cap 65); 66 67#endif