Rework the public API (#4829)

Related to #4186.

Some notable changes:
  - The term 'Error' now strictly refers to native Error objects defined in
    the ECMA standard, which are ordinary objects. All other uses of
    'error' or 'error reference' where the term refers to a thrown value is
    now called 'exception'.

  - Simplified the naming scheme of many String API functions. These functions
    will now also take an 'encoding' argument to specify the desired
    encoding in which to operate.

  - Removed the substring-copy-to-buffer functions. These functions
    behaved awkwardly, as they use character index to specify the
    start/end positions, and were mostly used incorrectly with byte
    offsets instead. The functionality can still be replicated with
    other functions if necessary.

  - String-to-buffer functions will no longer fail if the buffer is not
    sufficiently large, the string will instead be cropped.

  - Fixed the usage of the '_sz' prefix in many API functions. The term
    'sz' means zero-terminated string in hungarian notation, this was
    used incorrectly in many cases.

  - Renamed most of the public API functions to have shorter, more on-point
    names, rather than the often too long descriptive names. Functions are now
    also grouped by the type of value they operate on, where this makes
    sense.

JerryScript-DCO-1.0-Signed-off-by: Dániel Bátyai dbatyai@inf.u-szeged.hu
This commit is contained in:
Dániel Bátyai
2021-12-06 10:20:09 +01:00
committed by GitHub
parent 81d2319144
commit 9860d66a56
180 changed files with 10738 additions and 11025 deletions
+15 -15
View File
@@ -150,22 +150,22 @@ struct jerry_context_t
#if JERRY_MODULE_SYSTEM
ecma_module_t *module_current_p; /**< current module context */
jerry_module_state_changed_callback_t module_state_changed_callback_p; /**< callback which is called after the
* state of a module is changed */
jerry_module_state_changed_cb_t module_state_changed_callback_p; /**< callback which is called after the
* state of a module is changed */
void *module_state_changed_callback_user_p; /**< user pointer for module_state_changed_callback_p */
jerry_module_import_meta_callback_t module_import_meta_callback_p; /**< callback which is called when an
* import.meta expression of a module
* is evaluated the first time */
jerry_module_import_meta_cb_t module_import_meta_callback_p; /**< callback which is called when an
* import.meta expression of a module
* is evaluated the first time */
void *module_import_meta_callback_user_p; /**< user pointer for module_import_meta_callback_p */
jerry_module_import_callback_t module_import_callback_p; /**< callback for dynamic module import */
jerry_module_import_cb_t module_import_callback_p; /**< callback for dynamic module import */
void *module_import_callback_user_p; /**< user pointer for module_import_callback_p */
#endif /* JERRY_MODULE_SYSTEM */
vm_frame_ctx_t *vm_top_context_p; /**< top (current) interpreter context */
jerry_context_data_header_t *context_data_p; /**< linked list of user-provided context-specific pointers */
jerry_external_string_free_callback_t external_string_free_callback_p; /**< free callback for external strings */
jerry_external_string_free_cb_t external_string_free_callback_p; /**< free callback for external strings */
void *error_object_created_callback_user_p; /**< user pointer for error_object_update_callback_p */
jerry_error_object_created_callback_t error_object_created_callback_p; /**< decorator callback for Error objects */
jerry_error_object_created_cb_t error_object_created_callback_p; /**< decorator callback for Error objects */
size_t ecma_gc_objects_number; /**< number of currently allocated objects */
size_t ecma_gc_new_objects; /**< number of newly allocated objects since last GC session */
size_t jmem_heap_allocated_size; /**< size of allocated regions */
@@ -194,30 +194,30 @@ struct jerry_context_t
#if JERRY_PROMISE_CALLBACK
uint32_t promise_callback_filters; /**< reported event types for promise callback */
void *promise_callback_user_p; /**< user pointer for promise callback */
jerry_promise_callback_t promise_callback; /**< user function for tracking Promise object operations */
jerry_promise_event_cb_t promise_callback; /**< user function for tracking Promise object operations */
#endif /* JERRY_PROMISE_CALLBACK */
#endif /* JERRY_ESNEXT */
#if JERRY_BUILTIN_TYPEDARRAY
uint32_t arraybuffer_compact_allocation_limit; /**< maximum size of compact allocation */
jerry_arraybuffer_allocate_t arraybuffer_allocate_callback; /**< callback for allocating
* arraybuffer memory */
jerry_arraybuffer_free_t arraybuffer_free_callback; /**< callback for freeing arraybuffer memory */
jerry_arraybuffer_allocate_cb_t arraybuffer_allocate_callback; /**< callback for allocating
* arraybuffer memory */
jerry_arraybuffer_free_cb_t arraybuffer_free_callback; /**< callback for freeing arraybuffer memory */
void *arraybuffer_allocate_callback_user_p; /**< user pointer passed to arraybuffer_allocate_callback
* and arraybuffer_free_callback functions */
#endif /* JERRY_BUILTIN_TYPEDARRAY */
#if JERRY_VM_EXEC_STOP
#if JERRY_VM_HALT
uint32_t vm_exec_stop_frequency; /**< reset value for vm_exec_stop_counter */
uint32_t vm_exec_stop_counter; /**< down counter for reducing the calls of vm_exec_stop_cb */
void *vm_exec_stop_user_p; /**< user pointer for vm_exec_stop_cb */
ecma_vm_exec_stop_callback_t vm_exec_stop_cb; /**< user function which returns whether the
* ECMAScript execution should be stopped */
#endif /* JERRY_VM_EXEC_STOP */
#endif /* JERRY_VM_HALT */
#if JERRY_VM_THROW
void *vm_throw_callback_user_p; /**< user pointer for vm_throw_callback_p */
jerry_vm_throw_callback_t vm_throw_callback_p; /**< callback for capturing throws */
jerry_throw_cb_t vm_throw_callback_p; /**< callback for capturing throws */
#endif /* JERRY_VM_THROW */
#if (JERRY_STACK_LIMIT != 0)