2021-11-03 18:15:46 -04:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include "quickjs.h"
|
|
|
|
|
2021-12-27 17:00:37 -05:00
|
|
|
#include <stdbool.h>
|
|
|
|
|
2021-11-03 18:15:46 -04:00
|
|
|
void tf_util_register(JSContext* context);
|
|
|
|
JSValue tf_util_utf8_decode(JSContext* context, JSValue value);
|
2021-11-03 18:28:25 -04:00
|
|
|
uint8_t* tf_util_try_get_array_buffer(JSContext* context, size_t* psize, JSValueConst obj);
|
|
|
|
JSValue tf_util_try_get_typed_array_buffer(JSContext* context, JSValueConst obj, size_t* pbyte_offset, size_t* pbyte_length, size_t* pbytes_per_element);
|
2021-12-27 16:48:16 -05:00
|
|
|
bool tf_util_report_error(JSContext* context, JSValue value);
|
2022-07-09 11:13:35 -04:00
|
|
|
int tf_util_get_length(JSContext* context, JSValue value);
|
2022-07-11 21:51:15 -04:00
|
|
|
int tf_util_insert_index(const void* key, const void* base, size_t count, size_t size, int (*compare)(const void*, const void*));
|
2023-01-28 16:59:36 -05:00
|
|
|
JSValue tf_util_new_uint8_array(JSContext* context, const uint8_t* data, size_t size);
|
2023-02-13 22:15:24 -05:00
|
|
|
|
|
|
|
size_t tf_base64_encode(const uint8_t* source, size_t source_length, char* out, size_t out_length);
|
|
|
|
size_t tf_base64_decode(const char* source, size_t source_length, uint8_t* out, size_t out_length);
|
2023-02-18 16:00:39 -05:00
|
|
|
|
|
|
|
int tf_util_backtrace(void** buffer, int count);
|
|
|
|
const char* tf_util_backtrace_to_string(void* const* buffer, int count);
|
|
|
|
const char* tf_util_backtrace_string();
|
2023-04-19 19:05:59 -04:00
|
|
|
|
|
|
|
const char* tf_util_function_to_string(void* function);
|
2023-06-01 18:53:44 -04:00
|
|
|
|
2023-07-20 01:06:15 -04:00
|
|
|
#define tf_min(a, b) ({ __typeof__ (a) _a = (a); __typeof__ (b) _b = (b); _a > _b ? _a : _b; })
|