|
Tilde Friends
|
Macros | |
| #define | tf_min(a, b) |
| #define | tf_max(a, b) |
| #define | tf_countof(a) ((int)(sizeof((a)) / sizeof(*(a)))) |
Typedefs | |
| typedef enum _tf_setting_kind_t | tf_setting_kind_t |
Enumerations | |
| enum | _tf_setting_kind_t { k_kind_unknown , k_kind_bool , k_kind_int , k_kind_string } |
Functions | |
| void | tf_util_register (JSContext *context) |
| JSValue | tf_util_utf8_decode (JSContext *context, JSValue value) |
| 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) |
| bool | tf_util_report_error (JSContext *context, JSValue value) |
| int | tf_util_get_length (JSContext *context, JSValue value) |
| const char * | tf_util_get_property_as_string (JSContext *context, JSValue object, const char *key) |
| int | tf_util_insert_index (const void *key, const void *base, size_t count, size_t size, int(*compare)(const void *, const void *)) |
| JSValue | tf_util_new_uint8_array (JSContext *context, const uint8_t *data, size_t size) |
| 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) |
| 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 () |
| void | tf_util_print_backtrace () |
| const char * | tf_util_function_to_string (void *function) |
| bool | tf_util_get_default_global_setting_bool (const char *name) |
| int | tf_util_get_default_global_setting_int (const char *name) |
| const char * | tf_util_get_default_global_setting_string (const char *name) |
| tf_setting_kind_t | tf_util_get_global_setting_kind (const char *name) |
| bool | tf_util_get_global_setting_by_index (int index, const char **out_name, const char **out_type, tf_setting_kind_t *out_kind, const char **out_description) |
| void | tf_util_document_settings (const char *line_prefix) |
| bool | tf_util_is_mobile () |
| size_t | tf_string_set (char *buffer, size_t size, const char *string) |
| const char * | tf_util_uv_error_buf (char *buffer, size_t size, const char *prefix, int error) |
This is becoming just a dumping ground of small helpers.
| #define tf_countof | ( | a | ) | ((int)(sizeof((a)) / sizeof(*(a)))) |
Get the number of elements in an array.
| a | The array. |
| #define tf_max | ( | a, | |
| b | |||
| ) |
Get the maximum of two values.
| a | The first value. |
| b | The second value. |
| #define tf_min | ( | a, | |
| b | |||
| ) |
Get the minimum of two values.
| a | The first value. |
| b | The second value. |
| typedef enum _tf_setting_kind_t tf_setting_kind_t |
Type of a setting.
| enum _tf_setting_kind_t |
Type of a setting.
| size_t tf_base64_decode | ( | const char * | source, |
| size_t | source_length, | ||
| uint8_t * | out, | ||
| size_t | out_length | ||
| ) |
Base64-decode data.
| source | The source data. | |
| source_length | The length of the source data. | |
| [out] | out | A buffer to receipve the decoded data. |
| out_length | The size of the buffer to receive decoded data. |
| size_t tf_base64_encode | ( | const uint8_t * | source, |
| size_t | source_length, | ||
| char * | out, | ||
| size_t | out_length | ||
| ) |
Base64-encode data.
| source | The source data. | |
| source_length | The length of the source data. | |
| [out] | out | A buffer to receive the encoded data. |
| out_length | The size of the buffer to receive encoded data. |
| size_t tf_string_set | ( | char * | buffer, |
| size_t | size, | ||
| const char * | string | ||
| ) |
Populate a string buffer, truncating if necessary.
| buffer | The buffer. |
| size | The size of the buffer. |
| string | The value to set. |
| int tf_util_backtrace | ( | void ** | buffer, |
| int | count | ||
| ) |
Capture a stack backtrace of the calling thread.
| [out] | buffer | A buffer with at least count element to receive the backtrace. |
| count | The size of buffer. |
| const char * tf_util_backtrace_string | ( | ) |
Capture a stack backtrace of the calling thread and convert it immediately to string.
| const char * tf_util_backtrace_to_string | ( | void *const * | buffer, |
| int | count | ||
| ) |
Convert a stack backtrace to string.
| buffer | A stack backtrace. |
| count | The number of elements in the backtrace. |
| void tf_util_document_settings | ( | const char * | line_prefix | ) |
Log documentation for the available settings.
| line_prefix | Text to prefix each line with." |
| const char * tf_util_function_to_string | ( | void * | function | ) |
Convert a function pointer to its name, if possible.
| bool tf_util_get_default_global_setting_bool | ( | const char * | name | ) |
Get the default value of a global setting as a boolean.
| name | The setting name. |
| int tf_util_get_default_global_setting_int | ( | const char * | name | ) |
Get the default value of a global setting as an integer.
| name | The setting name. |
| const char * tf_util_get_default_global_setting_string | ( | const char * | name | ) |
Get the default value of a global setting as a string.
| name | The setting name. |
| bool tf_util_get_global_setting_by_index | ( | int | index, |
| const char ** | out_name, | ||
| const char ** | out_type, | ||
| tf_setting_kind_t * | out_kind, | ||
| const char ** | out_description | ||
| ) |
Get the index-th global setting.
| index | The index. |
| out_name | Populated with the setting name. |
| out_type | Populated with the setting type. |
| out_kind | Populated with the setting kind. |
| out_description | Populated with the setting description. |
| tf_setting_kind_t tf_util_get_global_setting_kind | ( | const char * | name | ) |
Get the expected kind of a global setting.
| name | The setting name. |
| int tf_util_get_length | ( | JSContext * | context, |
| JSValue | value | ||
| ) |
Get the length of an array.
| context | The JS context. |
| value | An array with a "length" field. |
| const char * tf_util_get_property_as_string | ( | JSContext * | context, |
| JSValue | object, | ||
| const char * | key | ||
| ) |
Get an object property by string key as a C-style string.
| context | The JS context. |
| object | The object. |
| key | The property key. |
| int tf_util_insert_index | ( | const void * | key, |
| const void * | base, | ||
| size_t | count, | ||
| size_t | size, | ||
| int(*)(const void *, const void *) | compare | ||
| ) |
Get the index at which to insert into an array in order to preserve sorted order.
| key | The key being inserted. |
| base | The beginning of the array. |
| count | The number of elements in the array. |
| size | The size of a single element of the array. |
| compare | A comparison function comparing key and an element of the array. |
| bool tf_util_is_mobile | ( | ) |
Check if the app is running on a mobile device.
| JSValue tf_util_new_uint8_array | ( | JSContext * | context, |
| const uint8_t * | data, | ||
| size_t | size | ||
| ) |
Create a Uint8Array from bytes.
| context | The JS context. |
| data | The bytes. |
| size | The number of bytes in data. |
| void tf_util_print_backtrace | ( | ) |
Print a stack backtrace of the calling thread.
| void tf_util_register | ( | JSContext * | context | ) |
Register utility script functions.
| context | The JS context. |
| bool tf_util_report_error | ( | JSContext * | context, |
| JSValue | value | ||
| ) |
Print an error and message the owning task if possible.
| context | The JS context. |
| value | The value which might be an exception. |
| uint8_t * tf_util_try_get_array_buffer | ( | JSContext * | context, |
| size_t * | psize, | ||
| JSValueConst | obj | ||
| ) |
Get the data from what might be an ArrayBuffer.
| context | The JS context. | |
| [out] | psize | The size of the data in bytes. |
| obj | The object which might be an ArrayBuffer. |
| 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 | ||
| ) |
Get the ArrayBuffer from what might be a typed ArrayBuffer.
| context | The JS context. | |
| obj | The object which might be a typed ArrayBuffer. | |
| [out] | pbyte_offset | The offset into the buffer at which the typed ArrayBuffer starts. |
| [out] | pbyte_length | The length of the buffer. |
| [out] | pbytes_per_element | Element size in bytes. |
| JSValue tf_util_utf8_decode | ( | JSContext * | context, |
| JSValue | value | ||
| ) |
Convert UTF-8 bytes in a buffer or Uint8Array or similar to a String.
| context | The JS context. |
| value | The UTF-8 bytes. |
| const char * tf_util_uv_error_buf | ( | char * | buffer, |
| size_t | size, | ||
| const char * | prefix, | ||
| int | error | ||
| ) |
Format a string representation of a libuv error into a string buffer.
| buffer | The string buffer to be populated. |
| size | The size of the buffer. |
| prefix | Prefix to the error message. |
| error | The libuv error number. |