add transform_object_properties in jerryx/arg (#1879)
Add a function in jerryx/arg. jerryx_arg_transform_object_properties, it will validate the properties of a JS object, and convert those properties into native type. JerryScript-DCO-1.0-Signed-off-by: Zidong Jiang zidong.jiang@intel.com
This commit is contained in:
@@ -16,7 +16,6 @@
|
||||
#ifndef JERRYX_ARG_H
|
||||
#define JERRYX_ARG_H
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
@@ -43,6 +42,17 @@ typedef struct jerryx_arg_js_iterator_t jerryx_arg_js_iterator_t;
|
||||
typedef jerry_value_t (*jerryx_arg_transform_func_t) (jerryx_arg_js_iterator_t *js_arg_iter_p, /**< available JS args */
|
||||
const jerryx_arg_t *c_arg_p); /**< native arg */
|
||||
|
||||
/**
|
||||
* The structure used in jerryx_arg_object_properties
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
const jerry_char_t **name_p; /**< property name list of the JS object */
|
||||
jerry_length_t name_cnt; /**< count of the name list */
|
||||
const jerryx_arg_t *c_arg_p; /**< points to the array of transformation steps */
|
||||
jerry_length_t c_arg_cnt; /**< the count of the `c_arg_p` array */
|
||||
} jerryx_arg_object_props_t;
|
||||
|
||||
/**
|
||||
* The structure defining a single validation & transformation step.
|
||||
*/
|
||||
@@ -64,6 +74,12 @@ jerry_value_t jerryx_arg_transform_args (const jerry_value_t *js_arg_p,
|
||||
const jerryx_arg_t *c_arg_p,
|
||||
jerry_length_t c_arg_cnt);
|
||||
|
||||
jerry_value_t jerryx_arg_transform_object_properties (const jerry_value_t obj_val,
|
||||
const jerry_char_t **name_p,
|
||||
const jerry_length_t name_cnt,
|
||||
const jerryx_arg_t *c_arg_p,
|
||||
jerry_length_t c_arg_cnt);
|
||||
|
||||
/**
|
||||
* Indicates whether an argument is allowed to be coerced into the expected JS type.
|
||||
*/
|
||||
@@ -105,6 +121,8 @@ static inline jerryx_arg_t
|
||||
jerryx_arg_ignore (void);
|
||||
static inline jerryx_arg_t
|
||||
jerryx_arg_custom (void *dest, uintptr_t extra_info, jerryx_arg_transform_func_t func);
|
||||
static inline jerryx_arg_t
|
||||
jerryx_arg_object_properties (const jerryx_arg_object_props_t *object_props_p, jerryx_arg_optional_t opt_flag);
|
||||
|
||||
jerry_value_t
|
||||
jerryx_arg_transform_optional (jerryx_arg_js_iterator_t *js_arg_iter_p,
|
||||
|
||||
Reference in New Issue
Block a user