Support passing of string and object arguments to plugins' bound functions.
This commit is contained in:
@@ -387,7 +387,7 @@ typedef enum
|
||||
* Description of ECMA-object or lexical environment
|
||||
* (depending on is_lexical_environment).
|
||||
*/
|
||||
typedef struct
|
||||
typedef struct ecma_object_t
|
||||
{
|
||||
/* Common part for objects and lexical environments */
|
||||
|
||||
@@ -763,7 +763,7 @@ typedef uint8_t ecma_string_hash_t;
|
||||
/**
|
||||
* ECMA string-value descriptor
|
||||
*/
|
||||
typedef struct
|
||||
typedef struct ecma_string_t
|
||||
{
|
||||
/** Reference counter for the string */
|
||||
unsigned int refs : CONFIG_ECMA_REFERENCE_COUNTER_WIDTH;
|
||||
|
||||
@@ -866,9 +866,7 @@ ecma_string_to_number (const ecma_string_t *str_p) /**< ecma-string */
|
||||
} /* ecma_string_to_number */
|
||||
|
||||
/**
|
||||
* Copy ecma-string's contents to a buffer.
|
||||
*
|
||||
* Buffer will contain length of string, in characters, followed by string's characters.
|
||||
* Convert ecma-string's contents to a zero-terminated string and put it to the buffer.
|
||||
*
|
||||
* @return number of bytes, actually copied to the buffer - if string's content was copied successfully;
|
||||
* otherwise (in case size of buffer is insuficcient) - negative number, which is calculated
|
||||
|
||||
@@ -193,19 +193,35 @@ ecma_builtin_jerry_dispatch_routine (uint16_t builtin_routine_id, /**< built-in
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (arg_p->type == JERRY_EXTENSION_FIELD_TYPE_STRING)
|
||||
{
|
||||
if (!ecma_is_value_string (arg_value))
|
||||
{
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
arg_p->v_string = ecma_get_string_from_value (arg_value);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
JERRY_ASSERT (arg_p->type == JERRY_EXTENSION_FIELD_TYPE_STRING);
|
||||
JERRY_ASSERT (arg_p->type == JERRY_EXTENSION_FIELD_TYPE_OBJECT);
|
||||
|
||||
#if CONFIG_ECMA_CHAR_ENCODING != CONFIG_ECMA_CHAR_ASCII
|
||||
JERRY_UNIMPLEMENTED ("Only ASCII encoding support is implemented.");
|
||||
#else /* CONFIG_ECMA_CHAR_ENCODING == CONFIG_ECMA_CHAR_ASCII */
|
||||
JERRY_UNIMPLEMENTED ("String arguments are not implemented");
|
||||
#endif /* CONFIG_ECMA_CHAR_ENCODING == CONFIG_ECMA_CHAR_ASCII */
|
||||
if (!ecma_is_value_object (arg_value))
|
||||
{
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
arg_p->v_object = ecma_get_object_from_value (arg_value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (arg_index != function_p->args_number)
|
||||
uint32_t initialized_args_count = arg_index;
|
||||
|
||||
if (initialized_args_count != function_p->args_number)
|
||||
{
|
||||
throw_type_error = true;
|
||||
}
|
||||
@@ -213,6 +229,29 @@ ecma_builtin_jerry_dispatch_routine (uint16_t builtin_routine_id, /**< built-in
|
||||
{
|
||||
function_p->function_wrapper_p (function_p);
|
||||
}
|
||||
|
||||
for (arg_index = 0;
|
||||
arg_index < initialized_args_count;
|
||||
arg_index++)
|
||||
{
|
||||
jerry_extension_function_arg_t *arg_p = &function_p->args_p [arg_index];
|
||||
|
||||
if (arg_p->type == JERRY_EXTENSION_FIELD_TYPE_STRING)
|
||||
{
|
||||
arg_p->v_string = NULL;
|
||||
}
|
||||
else if (arg_p->type == JERRY_EXTENSION_FIELD_TYPE_OBJECT)
|
||||
{
|
||||
arg_p->v_object = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
JERRY_ASSERT (arg_p->type == JERRY_EXTENSION_FIELD_TYPE_BOOLEAN
|
||||
|| arg_p->type == JERRY_EXTENSION_FIELD_TYPE_FLOAT32
|
||||
|| arg_p->type == JERRY_EXTENSION_FIELD_TYPE_FLOAT64
|
||||
|| arg_p->type == JERRY_EXTENSION_FIELD_TYPE_UINT32);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (throw_type_error)
|
||||
@@ -444,6 +483,10 @@ ecma_op_extension_object_get_own_property (ecma_object_t *obj_p, /**< the extens
|
||||
|
||||
break;
|
||||
}
|
||||
case JERRY_EXTENSION_FIELD_TYPE_OBJECT:
|
||||
{
|
||||
JERRY_UNREACHABLE ();
|
||||
}
|
||||
}
|
||||
|
||||
ecma_named_data_property_assign_value (obj_p, prop_p, value);
|
||||
|
||||
Reference in New Issue
Block a user