Extension description syntax; extension instantiation, field values and calls with arguments (except strings); example of a simple extension.
String arguments support is supposed to be added in a subsequent commit.
This commit is contained in:
@@ -124,6 +124,13 @@ OBJECT_VALUE (ECMA_MAGIC_STRING_NUMBER_UL,
|
||||
ECMA_PROPERTY_CONFIGURABLE)
|
||||
#endif /* !CONFIG_ECMA_COMPACT_PROFILE_DISABLE_NUMBER_BUILTIN */
|
||||
|
||||
// Implementation-defined property for accessing the engine's extensions */
|
||||
OBJECT_VALUE (ECMA_MAGIC_STRING_JERRY_UL,
|
||||
ecma_builtin_get (ECMA_BUILTIN_ID_JERRY),
|
||||
ECMA_PROPERTY_NOT_WRITABLE,
|
||||
ECMA_PROPERTY_NOT_ENUMERABLE,
|
||||
ECMA_PROPERTY_NOT_CONFIGURABLE)
|
||||
|
||||
// ECMA-262 v5, 15.1.4.7
|
||||
CP_UNIMPLEMENTED_VALUE (ECMA_MAGIC_STRING_DATE_UL,
|
||||
ecma_builtin_get (ECMA_BUILTIN_ID_DATE),
|
||||
|
||||
@@ -167,6 +167,8 @@ TRY_TO_INSTANTIATE_PROPERTY_ROUTINE_NAME (BUILTIN_UNDERSCORED_ID) (ecma_object_t
|
||||
|
||||
switch (id)
|
||||
{
|
||||
JERRY_ASSERT ((uint16_t) id == id);
|
||||
|
||||
#define ROUTINE(name, c_function_name, args_number, length_prop_value) case name: \
|
||||
{ \
|
||||
ecma_object_t *func_obj_p = ecma_builtin_make_function_object_for_routine (builtin_object_id, \
|
||||
@@ -273,9 +275,8 @@ TRY_TO_INSTANTIATE_PROPERTY_ROUTINE_NAME (BUILTIN_UNDERSCORED_ID) (ecma_object_t
|
||||
* Returned value must be freed with ecma_free_completion_value.
|
||||
*/
|
||||
ecma_completion_value_t
|
||||
DISPATCH_ROUTINE_ROUTINE_NAME (BUILTIN_UNDERSCORED_ID) (ecma_magic_string_id_t builtin_routine_id, /**< built-in's
|
||||
routine's
|
||||
name */
|
||||
DISPATCH_ROUTINE_ROUTINE_NAME (BUILTIN_UNDERSCORED_ID) (uint16_t builtin_routine_id, /**< built-in wide routine
|
||||
identifier */
|
||||
const ecma_value_t& this_arg_value, /**< 'this' argument
|
||||
value */
|
||||
const ecma_value_t arguments_list [], /**< list of arguments
|
||||
|
||||
@@ -0,0 +1,499 @@
|
||||
/* Copyright 2015 Samsung Electronics Co., Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include <string.h>
|
||||
|
||||
#include "ecma-alloc.h"
|
||||
#include "ecma-builtins.h"
|
||||
#include "ecma-exceptions.h"
|
||||
#include "ecma-extension.h"
|
||||
#include "ecma-gc.h"
|
||||
#include "ecma-helpers.h"
|
||||
#include "ecma-objects-general.h"
|
||||
|
||||
#define ECMA_BUILTINS_INTERNAL
|
||||
#include "ecma-builtins-internal.h"
|
||||
|
||||
/**
|
||||
* List of registered extensions
|
||||
*/
|
||||
static jerry_extension_descriptor_t *jerry_extensions_list_p = NULL;
|
||||
|
||||
/**
|
||||
* Index to assign to next registered extension
|
||||
*/
|
||||
static uint32_t jerry_extensions_next_index = 0;
|
||||
|
||||
/**
|
||||
* If the property's name is one of built-in properties of the built-in object
|
||||
* that is not instantiated yet, instantiate the property and
|
||||
* return pointer to the instantiated property.
|
||||
*
|
||||
* @return pointer property, if one was instantiated,
|
||||
* NULL - otherwise.
|
||||
*/
|
||||
ecma_property_t*
|
||||
ecma_builtin_jerry_try_to_instantiate_property (ecma_object_t *obj_p, /**< object */
|
||||
ecma_string_t *extension_name_p) /**< property's name */
|
||||
{
|
||||
JERRY_ASSERT (ecma_builtin_is (obj_p, ECMA_BUILTIN_ID_JERRY));
|
||||
JERRY_ASSERT (ecma_find_named_property (obj_p, extension_name_p) == NULL);
|
||||
|
||||
ssize_t req_buffer_size = ecma_string_to_zt_string (extension_name_p, NULL, 0);
|
||||
JERRY_ASSERT (req_buffer_size < 0);
|
||||
|
||||
ecma_property_t *prop_p = NULL;
|
||||
|
||||
MEM_DEFINE_LOCAL_ARRAY (extension_name_zt_buf_p, -req_buffer_size, uint8_t);
|
||||
|
||||
req_buffer_size = ecma_string_to_zt_string (extension_name_p, extension_name_zt_buf_p, -req_buffer_size);
|
||||
JERRY_ASSERT (req_buffer_size > 0);
|
||||
|
||||
#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 */
|
||||
const char *name_p = (const char*) extension_name_zt_buf_p;
|
||||
|
||||
jerry_extension_descriptor_t *desc_p;
|
||||
for (desc_p = jerry_extensions_list_p;
|
||||
desc_p != NULL;
|
||||
desc_p = desc_p->next_p)
|
||||
{
|
||||
if (!strcmp (name_p, desc_p->name_p))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (desc_p == NULL)
|
||||
{
|
||||
/* no extension with specified name was found */
|
||||
prop_p = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
prop_p = ecma_create_named_data_property (obj_p,
|
||||
extension_name_p,
|
||||
ECMA_PROPERTY_NOT_WRITABLE,
|
||||
ECMA_PROPERTY_NOT_ENUMERABLE,
|
||||
ECMA_PROPERTY_NOT_CONFIGURABLE);
|
||||
|
||||
ecma_object_t *extension_object_p = ecma_create_object (NULL,
|
||||
false,
|
||||
ECMA_OBJECT_TYPE_EXTENSION);
|
||||
ecma_set_object_is_builtin (extension_object_p, true);
|
||||
ecma_property_t *extension_id_prop_p = ecma_create_internal_property (extension_object_p,
|
||||
ECMA_INTERNAL_PROPERTY_EXTENSION_ID);
|
||||
extension_id_prop_p->u.internal_property.value = desc_p->index;
|
||||
|
||||
ecma_named_data_property_assign_value (obj_p, prop_p, ecma_make_object_value (extension_object_p));
|
||||
|
||||
ecma_deref_object (extension_object_p);
|
||||
}
|
||||
#endif /* CONFIG_ECMA_CHAR_ENCODING == CONFIG_ECMA_CHAR_ASCII */
|
||||
|
||||
MEM_FINALIZE_LOCAL_ARRAY (extension_name_zt_buf_p);
|
||||
|
||||
return prop_p;
|
||||
} /* ecma_builtin_jerry_try_to_instantiate_property */
|
||||
|
||||
/**
|
||||
* Stub for dispatcher of the built-in's routines
|
||||
*
|
||||
* Warning:
|
||||
* does not return (the stub should be unreachable)
|
||||
*/
|
||||
ecma_completion_value_t
|
||||
ecma_builtin_jerry_dispatch_routine (uint16_t builtin_routine_id, /**< built-in wide identifier of routine */
|
||||
const ecma_value_t& this_arg_value __attr_unused___, /**< 'this' argument value */
|
||||
const ecma_value_t arguments_list [], /**< list of arguments
|
||||
passed to routine */
|
||||
ecma_length_t arguments_number) /**< length of arguments' list */
|
||||
{
|
||||
uint32_t extension_object_index = builtin_routine_id / ECMA_EXTENSION_MAX_FUNCTIONS_IN_EXTENSION;
|
||||
uint32_t function_index = builtin_routine_id % ECMA_EXTENSION_MAX_FUNCTIONS_IN_EXTENSION;
|
||||
|
||||
jerry_extension_descriptor_t *desc_p;
|
||||
for (desc_p = jerry_extensions_list_p;
|
||||
desc_p != NULL;
|
||||
desc_p = desc_p->next_p)
|
||||
{
|
||||
if (desc_p->index == extension_object_index)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
JERRY_ASSERT (desc_p != NULL);
|
||||
|
||||
JERRY_ASSERT (function_index < desc_p->functions_count);
|
||||
const jerry_extension_function_t *function_p = &desc_p->functions_p [function_index];
|
||||
|
||||
bool throw_type_error = false;
|
||||
if (function_p->args_number != arguments_number)
|
||||
{
|
||||
throw_type_error = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
uint32_t arg_index;
|
||||
for (arg_index = 0; arg_index < function_p->args_number; arg_index++)
|
||||
{
|
||||
jerry_extension_function_arg_t *arg_p = &function_p->args_p [arg_index];
|
||||
const ecma_value_t arg_value = arguments_list [arg_index];
|
||||
|
||||
if (arg_p->type == JERRY_EXTENSION_FIELD_TYPE_BOOLEAN)
|
||||
{
|
||||
if (!ecma_is_value_boolean (arg_value))
|
||||
{
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
arg_p->v_bool = ecma_is_value_true (arg_value);
|
||||
}
|
||||
}
|
||||
else if (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 (!ecma_is_value_number (arg_value))
|
||||
{
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_number_t num_value = *ecma_get_number_from_value (arg_value);
|
||||
if (arg_p->type == JERRY_EXTENSION_FIELD_TYPE_FLOAT32)
|
||||
{
|
||||
arg_p->v_float32 = (float) num_value;
|
||||
}
|
||||
else if (arg_p->type == JERRY_EXTENSION_FIELD_TYPE_FLOAT64)
|
||||
{
|
||||
#if CONFIG_ECMA_NUMBER_TYPE == CONFIG_ECMA_NUMBER_FLOAT32
|
||||
JERRY_UNREACHABLE ();
|
||||
#elif CONFIG_ECMA_NUMBER_TYPE == CONFIG_ECMA_NUMBER_FLOAT64
|
||||
arg_p->v_float64 = num_value;
|
||||
#endif /* CONFIG_ECMA_NUMBER_TYPE == CONFIG_ECMA_NUMBER_FLOAT64 */
|
||||
}
|
||||
else if (arg_p->type == JERRY_EXTENSION_FIELD_TYPE_UINT32)
|
||||
{
|
||||
arg_p->v_uint32 = ecma_number_to_uint32 (num_value);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
JERRY_ASSERT (arg_p->type == JERRY_EXTENSION_FIELD_TYPE_STRING);
|
||||
|
||||
#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 (arg_index != function_p->args_number)
|
||||
{
|
||||
throw_type_error = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
function_p->function_wrapper_p (function_p);
|
||||
}
|
||||
}
|
||||
|
||||
if (throw_type_error)
|
||||
{
|
||||
return ecma_make_throw_obj_completion_value (ecma_new_standard_error (ECMA_ERROR_TYPE));
|
||||
}
|
||||
else
|
||||
{
|
||||
return ecma_make_empty_completion_value ();
|
||||
}
|
||||
} /* ecma_builtin_jerry_dispatch_routine */
|
||||
|
||||
bool
|
||||
ecma_extension_register (jerry_extension_descriptor_t *extension_desc_p) /**< extension description */
|
||||
{
|
||||
if (jerry_extensions_next_index >= ECMA_EXTENSION_MAX_NUMBER_OF_EXTENSIONS)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (extension_desc_p->functions_count > ECMA_EXTENSION_MAX_FUNCTIONS_IN_EXTENSION)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Check names intersection */
|
||||
for (uint32_t i = 0; i < extension_desc_p->fields_count; i++)
|
||||
{
|
||||
for (uint32_t j = 0; j < extension_desc_p->fields_count; j++)
|
||||
{
|
||||
if (i != j
|
||||
&& !strcmp (extension_desc_p->fields_p [i].field_name_p,
|
||||
extension_desc_p->fields_p [j].field_name_p))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < extension_desc_p->functions_count; i++)
|
||||
{
|
||||
if (extension_desc_p->functions_p [i].args_number >= ECMA_EXTENSION_MAX_ARGUMENTS_IN_FUNCTION)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
#if CONFIG_ECMA_NUMBER_TYPE == CONFIG_ECMA_NUMBER_FLOAT32
|
||||
/* Check if we can represent the arguments' values */
|
||||
for (uint32_t j = 0; j < extension_desc_p->functions_p [i].args_number; j++)
|
||||
{
|
||||
if (extension_desc_p->functions_p[i].args_p[j].type == JERRY_EXTENSION_FIELD_TYPE_FLOAT64)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
#endif /* CONFIG_ECMA_NUMBER_TYPE == CONFIG_ECMA_NUMBER_FLOAT32 */
|
||||
|
||||
for (uint32_t j = 0; j < extension_desc_p->functions_count; j++)
|
||||
{
|
||||
if (i != j
|
||||
&& !strcmp (extension_desc_p->functions_p [i].function_name_p,
|
||||
extension_desc_p->functions_p [j].function_name_p))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (uint32_t i = 0; i < extension_desc_p->fields_count; i++)
|
||||
{
|
||||
#if CONFIG_ECMA_NUMBER_TYPE == CONFIG_ECMA_NUMBER_FLOAT32
|
||||
/* Check if we can represent the field's value */
|
||||
|
||||
if (extension_desc_p->fields_p[i].type == JERRY_EXTENSION_FIELD_TYPE_FLOAT64)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (extension_desc_p->fields_p[i].type == JERRY_EXTENSION_FIELD_TYPE_UINT32
|
||||
&& ecma_number_to_uint32 (ecma_uint32_to_number (extension_desc_p->fields_p[i].v_uint32))
|
||||
!= extension_desc_p->fields_p[i].v_uint32)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
#endif /* CONFIG_ECMA_NUMBER_TYPE == CONFIG_ECMA_NUMBER_FLOAT32 */
|
||||
|
||||
for (uint32_t j = 0; j < extension_desc_p->functions_count; j++)
|
||||
{
|
||||
if (!strcmp (extension_desc_p->fields_p [i].field_name_p,
|
||||
extension_desc_p->functions_p [j].function_name_p))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (jerry_extension_descriptor_t *desc_iter_p = jerry_extensions_list_p;
|
||||
desc_iter_p != NULL;
|
||||
desc_iter_p = desc_iter_p->next_p)
|
||||
{
|
||||
if (desc_iter_p == extension_desc_p
|
||||
|| !strcmp (desc_iter_p->name_p, extension_desc_p->name_p))
|
||||
{
|
||||
/* The extension already registered or an extension with the same name already registered */
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
extension_desc_p->next_p = jerry_extensions_list_p;
|
||||
jerry_extensions_list_p = extension_desc_p;
|
||||
extension_desc_p->index = jerry_extensions_next_index++;
|
||||
|
||||
return true;
|
||||
} /* ecma_extension_register */
|
||||
|
||||
/**
|
||||
* [[GetOwnProperty]] Implementation extension object's operation
|
||||
*
|
||||
* @return property descriptor
|
||||
*/
|
||||
ecma_property_t*
|
||||
ecma_op_extension_object_get_own_property (ecma_object_t *obj_p, /**< the extension object */
|
||||
ecma_string_t *property_name_p) /**< property name */
|
||||
{
|
||||
JERRY_ASSERT (ecma_get_object_type (obj_p) == ECMA_OBJECT_TYPE_EXTENSION);
|
||||
|
||||
// 1.
|
||||
ecma_property_t *prop_p = ecma_op_general_object_get_own_property (obj_p, property_name_p);
|
||||
|
||||
// 2.
|
||||
if (prop_p != NULL)
|
||||
{
|
||||
return prop_p;
|
||||
}
|
||||
|
||||
#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 */
|
||||
ssize_t req_buffer_size = ecma_string_to_zt_string (property_name_p, NULL, 0);
|
||||
JERRY_ASSERT (req_buffer_size < 0);
|
||||
|
||||
MEM_DEFINE_LOCAL_ARRAY (property_name_zt_buf_p, -req_buffer_size, uint8_t);
|
||||
|
||||
req_buffer_size = ecma_string_to_zt_string (property_name_p, property_name_zt_buf_p, -req_buffer_size);
|
||||
JERRY_ASSERT (req_buffer_size > 0);
|
||||
|
||||
const char *name_p = (const char*) property_name_zt_buf_p;
|
||||
|
||||
ecma_property_t *extension_id_prop_p = ecma_get_internal_property (obj_p,
|
||||
ECMA_INTERNAL_PROPERTY_EXTENSION_ID);
|
||||
uint32_t extension_object_index = extension_id_prop_p->u.internal_property.value;
|
||||
|
||||
jerry_extension_descriptor_t *desc_p;
|
||||
for (desc_p = jerry_extensions_list_p;
|
||||
desc_p != NULL;
|
||||
desc_p = desc_p->next_p)
|
||||
{
|
||||
if (desc_p->index == extension_object_index)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
JERRY_ASSERT (desc_p != NULL);
|
||||
|
||||
uint32_t field_index;
|
||||
for (field_index = 0;
|
||||
field_index < desc_p->fields_count;
|
||||
field_index++)
|
||||
{
|
||||
if (!strcmp (name_p, desc_p->fields_p [field_index].field_name_p))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (field_index < desc_p->fields_count)
|
||||
{
|
||||
const jerry_extension_field_t *field_p = &desc_p->fields_p [field_index];
|
||||
|
||||
ecma_value_t value;
|
||||
prop_p = ecma_create_named_data_property (obj_p,
|
||||
property_name_p,
|
||||
ECMA_PROPERTY_NOT_WRITABLE,
|
||||
ECMA_PROPERTY_NOT_ENUMERABLE,
|
||||
ECMA_PROPERTY_NOT_CONFIGURABLE);
|
||||
|
||||
switch (field_p->type)
|
||||
{
|
||||
case JERRY_EXTENSION_FIELD_TYPE_BOOLEAN:
|
||||
{
|
||||
value = ecma_make_simple_value (field_p->v_bool ? ECMA_SIMPLE_VALUE_TRUE : ECMA_SIMPLE_VALUE_FALSE);
|
||||
|
||||
break;
|
||||
}
|
||||
case JERRY_EXTENSION_FIELD_TYPE_FLOAT32:
|
||||
{
|
||||
ecma_number_t *num_p = ecma_alloc_number ();
|
||||
*num_p = field_p->v_float32;
|
||||
value = ecma_make_number_value (num_p);
|
||||
|
||||
break;
|
||||
}
|
||||
case JERRY_EXTENSION_FIELD_TYPE_FLOAT64:
|
||||
{
|
||||
#if CONFIG_ECMA_NUMBER_TYPE == CONFIG_ECMA_NUMBER_FLOAT32
|
||||
JERRY_UNREACHABLE ();
|
||||
#elif CONFIG_ECMA_NUMBER_TYPE == CONFIG_ECMA_NUMBER_FLOAT64
|
||||
ecma_number_t *num_p = ecma_alloc_number ();
|
||||
*num_p = field_p->v_float64;
|
||||
value = ecma_make_number_value (num_p);
|
||||
#endif /* CONFIG_ECMA_NUMBER_TYPE == CONFIG_ECMA_NUMBER_FLOAT64 */
|
||||
|
||||
break;
|
||||
}
|
||||
case JERRY_EXTENSION_FIELD_TYPE_UINT32:
|
||||
{
|
||||
ecma_number_t *num_p = ecma_alloc_number ();
|
||||
*num_p = ecma_uint32_to_number (field_p->v_uint32);
|
||||
JERRY_ASSERT (ecma_number_to_uint32 (*num_p) == field_p->v_uint32);
|
||||
value = ecma_make_number_value (num_p);
|
||||
|
||||
break;
|
||||
}
|
||||
case JERRY_EXTENSION_FIELD_TYPE_STRING:
|
||||
{
|
||||
const ecma_char_t *string_p = (const ecma_char_t*) field_p->v_string;
|
||||
ecma_string_t *str_p = ecma_new_ecma_string (string_p);
|
||||
value = ecma_make_string_value (str_p);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ecma_named_data_property_assign_value (obj_p, prop_p, value);
|
||||
ecma_free_value (value, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
uint32_t function_index;
|
||||
for (function_index = 0;
|
||||
function_index < desc_p->functions_count;
|
||||
function_index++)
|
||||
{
|
||||
if (!strcmp (name_p, desc_p->functions_p [function_index].function_name_p))
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (function_index < desc_p->functions_count)
|
||||
{
|
||||
const jerry_extension_function_t *function_p = &desc_p->functions_p [function_index];
|
||||
|
||||
/* Currently, combined identifier of extension object and extension function should fit in uint16_t. */
|
||||
JERRY_STATIC_ASSERT (ECMA_EXTENSION_MAX_NUMBER_OF_EXTENSIONS * ECMA_EXTENSION_MAX_FUNCTIONS_IN_EXTENSION
|
||||
< (1ull << (sizeof (uint16_t) * JERRY_BITSINBYTE)));
|
||||
|
||||
uint32_t routine_id = desc_p->index * ECMA_EXTENSION_MAX_FUNCTIONS_IN_EXTENSION + function_index;
|
||||
JERRY_ASSERT ((uint16_t) routine_id == routine_id);
|
||||
JERRY_STATIC_ASSERT ((ecma_number_t) ECMA_EXTENSION_MAX_ARGUMENTS_IN_FUNCTION
|
||||
== ECMA_EXTENSION_MAX_ARGUMENTS_IN_FUNCTION);
|
||||
ecma_number_t args_number = ecma_uint32_to_number (function_p->args_number);
|
||||
JERRY_ASSERT (function_p->args_number == ecma_number_to_uint32 (args_number));
|
||||
ecma_object_t *func_obj_p = ecma_builtin_make_function_object_for_routine (ECMA_BUILTIN_ID_JERRY,
|
||||
(uint16_t) routine_id,
|
||||
args_number);
|
||||
|
||||
prop_p = ecma_create_named_data_property (obj_p,
|
||||
property_name_p,
|
||||
ECMA_PROPERTY_NOT_WRITABLE,
|
||||
ECMA_PROPERTY_NOT_ENUMERABLE,
|
||||
ECMA_PROPERTY_NOT_CONFIGURABLE);
|
||||
|
||||
ecma_named_data_property_assign_value (obj_p, prop_p, ecma_make_object_value (func_obj_p));
|
||||
|
||||
ecma_deref_object (func_obj_p);
|
||||
}
|
||||
}
|
||||
|
||||
MEM_FINALIZE_LOCAL_ARRAY (property_name_zt_buf_p);
|
||||
|
||||
return prop_p;
|
||||
#endif /* CONFIG_ECMA_CHAR_ENCODING == CONFIG_ECMA_CHAR_ASCII */
|
||||
} /* ecma_op_extension_object_get_own_property */
|
||||
@@ -48,7 +48,7 @@
|
||||
/* ecma-builtins.c */
|
||||
extern ecma_object_t*
|
||||
ecma_builtin_make_function_object_for_routine (ecma_builtin_id_t builtin_id,
|
||||
ecma_magic_string_id_t routine_id,
|
||||
uint16_t routine_id,
|
||||
ecma_number_t length_prop_num_value);
|
||||
extern int32_t
|
||||
ecma_builtin_bin_search_for_magic_string_id_in_array (const ecma_magic_string_id_t ids[],
|
||||
@@ -60,6 +60,7 @@ ecma_builtin_bin_search_for_magic_string_id_in_array (const ecma_magic_string_id
|
||||
object_class, \
|
||||
object_prototype_builtin_id, \
|
||||
is_extensible, \
|
||||
is_static, \
|
||||
lowercase_name) \
|
||||
extern ecma_completion_value_t \
|
||||
ecma_builtin_ ## lowercase_name ## _dispatch_call (const ecma_value_t *arguments_list_p, \
|
||||
@@ -68,7 +69,7 @@ extern ecma_completion_value_t \
|
||||
ecma_builtin_ ## lowercase_name ## _dispatch_construct (const ecma_value_t *arguments_list_p, \
|
||||
ecma_length_t arguments_list_len); \
|
||||
extern ecma_completion_value_t \
|
||||
ecma_builtin_ ## lowercase_name ## _dispatch_routine (ecma_magic_string_id_t builtin_routine_id, \
|
||||
ecma_builtin_ ## lowercase_name ## _dispatch_routine (uint16_t builtin_routine_id, \
|
||||
const ecma_value_t& this_arg_value, \
|
||||
const ecma_value_t arguments_list [], \
|
||||
ecma_length_t arguments_number); \
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
|
||||
static ecma_completion_value_t
|
||||
ecma_builtin_dispatch_routine (ecma_builtin_id_t builtin_object_id,
|
||||
ecma_magic_string_id_t builtin_routine_id,
|
||||
uint16_t builtin_routine_id,
|
||||
const ecma_value_t& this_arg_value,
|
||||
const ecma_value_t arguments_list [],
|
||||
ecma_length_t arguments_number);
|
||||
@@ -186,11 +186,15 @@ ecma_instantiate_builtin (ecma_builtin_id_t id) /**< built-in id */
|
||||
object_class, \
|
||||
object_prototype_builtin_id, \
|
||||
is_extensible, \
|
||||
is_static, \
|
||||
lowercase_name) \
|
||||
case builtin_id: \
|
||||
{ \
|
||||
JERRY_ASSERT (ecma_builtin_objects [builtin_id] == NULL); \
|
||||
ecma_builtin_ ## lowercase_name ## _sort_property_names (); \
|
||||
if (is_static) \
|
||||
{ \
|
||||
ecma_builtin_ ## lowercase_name ## _sort_property_names (); \
|
||||
} \
|
||||
\
|
||||
ecma_object_t *prototype_obj_p; \
|
||||
if (object_prototype_builtin_id == ECMA_BUILTIN_ID__COUNT) \
|
||||
@@ -273,6 +277,7 @@ ecma_builtin_try_to_instantiate_property (ecma_object_t *object_p, /**< object *
|
||||
object_class, \
|
||||
object_prototype_builtin_id, \
|
||||
is_extensible, \
|
||||
is_static, \
|
||||
lowercase_name) \
|
||||
case builtin_id: \
|
||||
{ \
|
||||
@@ -310,8 +315,8 @@ ecma_object_t*
|
||||
ecma_builtin_make_function_object_for_routine (ecma_builtin_id_t builtin_id, /**< identifier of built-in object
|
||||
that initially contains property
|
||||
with the routine */
|
||||
ecma_magic_string_id_t routine_id, /**< name of the built-in
|
||||
object's routine property */
|
||||
uint16_t routine_id, /**< builtin-wide identifier of the built-in
|
||||
object's routine property */
|
||||
ecma_number_t length_prop_num_value) /**< ecma-number - value
|
||||
of 'length' property
|
||||
of function object to create */
|
||||
@@ -381,10 +386,10 @@ ecma_builtin_dispatch_call (ecma_object_t *obj_p, /**< built-in object */
|
||||
uint64_t routine_id_field = jrt_extract_bit_field (packed_built_in_and_routine_id,
|
||||
ECMA_BUILTIN_ROUTINE_ID_BUILT_IN_ROUTINE_ID_POS,
|
||||
ECMA_BUILTIN_ROUTINE_ID_BUILT_IN_ROUTINE_ID_WIDTH);
|
||||
JERRY_ASSERT (routine_id_field < ECMA_MAGIC_STRING__COUNT);
|
||||
JERRY_ASSERT ((uint16_t) routine_id_field == routine_id_field);
|
||||
|
||||
ecma_builtin_id_t built_in_id = (ecma_builtin_id_t) built_in_id_field;
|
||||
ecma_magic_string_id_t routine_id = (ecma_magic_string_id_t) routine_id_field;
|
||||
uint16_t routine_id = (uint16_t) routine_id_field;
|
||||
|
||||
return ecma_builtin_dispatch_routine (built_in_id,
|
||||
routine_id,
|
||||
@@ -409,6 +414,7 @@ ecma_builtin_dispatch_call (ecma_object_t *obj_p, /**< built-in object */
|
||||
object_class, \
|
||||
object_prototype_builtin_id, \
|
||||
is_extensible, \
|
||||
is_static, \
|
||||
lowercase_name) \
|
||||
case builtin_id: \
|
||||
{ \
|
||||
@@ -471,6 +477,7 @@ ecma_builtin_dispatch_construct (ecma_object_t *obj_p, /**< built-in object */
|
||||
object_class, \
|
||||
object_prototype_builtin_id, \
|
||||
is_extensible, \
|
||||
is_static, \
|
||||
lowercase_name) \
|
||||
case builtin_id: \
|
||||
{ \
|
||||
@@ -512,8 +519,9 @@ ecma_builtin_dispatch_construct (ecma_object_t *obj_p, /**< built-in object */
|
||||
*/
|
||||
static ecma_completion_value_t
|
||||
ecma_builtin_dispatch_routine (ecma_builtin_id_t builtin_object_id, /**< built-in object' identifier */
|
||||
ecma_magic_string_id_t builtin_routine_id, /**< name of the built-in object's
|
||||
routine property */
|
||||
uint16_t builtin_routine_id, /**< builtin-wide identifier
|
||||
* of the built-in object's
|
||||
* routine property */
|
||||
const ecma_value_t& this_arg_value, /**< 'this' argument value */
|
||||
const ecma_value_t arguments_list [], /**< list of arguments passed to routine */
|
||||
ecma_length_t arguments_number) /**< length of arguments' list */
|
||||
@@ -525,6 +533,7 @@ ecma_builtin_dispatch_routine (ecma_builtin_id_t builtin_object_id, /**< built-i
|
||||
object_class, \
|
||||
object_prototype_builtin_id, \
|
||||
is_extensible, \
|
||||
is_static, \
|
||||
lowercase_name) \
|
||||
case builtin_id: \
|
||||
{ \
|
||||
|
||||
@@ -28,6 +28,7 @@ typedef enum
|
||||
object_class, \
|
||||
object_prototype_builtin_id, \
|
||||
is_extensible, \
|
||||
is_static, \
|
||||
lowercase_name) \
|
||||
builtin_id,
|
||||
#include "ecma-builtins.inc.h"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* Copyright 2014 Samsung Electronics Co., Ltd.
|
||||
/* Copyright 2014-2015 Samsung Electronics Co., Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -22,6 +22,7 @@ BUILTIN (ECMA_BUILTIN_ID_OBJECT_PROTOTYPE,
|
||||
ECMA_MAGIC_STRING_OBJECT_UL,
|
||||
ECMA_BUILTIN_ID__COUNT /* no prototype */,
|
||||
true,
|
||||
true,
|
||||
object_prototype)
|
||||
|
||||
/* The Object object (15.2.1) */
|
||||
@@ -30,6 +31,7 @@ BUILTIN (ECMA_BUILTIN_ID_OBJECT,
|
||||
ECMA_MAGIC_STRING_OBJECT_UL,
|
||||
ECMA_BUILTIN_ID_OBJECT_PROTOTYPE,
|
||||
true,
|
||||
true,
|
||||
object)
|
||||
|
||||
#ifndef CONFIG_ECMA_COMPACT_PROFILE_DISABLE_ARRAY_BUILTIN
|
||||
@@ -39,6 +41,7 @@ BUILTIN (ECMA_BUILTIN_ID_ARRAY_PROTOTYPE,
|
||||
ECMA_MAGIC_STRING_ARRAY_UL,
|
||||
ECMA_BUILTIN_ID_OBJECT_PROTOTYPE,
|
||||
true,
|
||||
true,
|
||||
array_prototype)
|
||||
|
||||
/* The Array object (15.4.1) */
|
||||
@@ -47,6 +50,7 @@ BUILTIN (ECMA_BUILTIN_ID_ARRAY,
|
||||
ECMA_MAGIC_STRING_ARRAY_UL,
|
||||
ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE,
|
||||
true,
|
||||
true,
|
||||
array)
|
||||
#endif /* !CONFIG_ECMA_COMPACT_PROFILE_DISABLE_ARRAY_BUILTIN*/
|
||||
|
||||
@@ -57,6 +61,7 @@ BUILTIN (ECMA_BUILTIN_ID_STRING_PROTOTYPE,
|
||||
ECMA_MAGIC_STRING_STRING_UL,
|
||||
ECMA_BUILTIN_ID_OBJECT_PROTOTYPE,
|
||||
true,
|
||||
true,
|
||||
string_prototype)
|
||||
|
||||
/* The String object (15.5.1) */
|
||||
@@ -65,6 +70,7 @@ BUILTIN (ECMA_BUILTIN_ID_STRING,
|
||||
ECMA_MAGIC_STRING_STRING_UL,
|
||||
ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE,
|
||||
true,
|
||||
true,
|
||||
string)
|
||||
#endif /* !CONFIG_ECMA_COMPACT_PROFILE_DISABLE_STRING_BUILTIN */
|
||||
|
||||
@@ -75,6 +81,7 @@ BUILTIN (ECMA_BUILTIN_ID_BOOLEAN_PROTOTYPE,
|
||||
ECMA_MAGIC_STRING_BOOLEAN_UL,
|
||||
ECMA_BUILTIN_ID_OBJECT_PROTOTYPE,
|
||||
true,
|
||||
true,
|
||||
boolean_prototype)
|
||||
|
||||
/* The Boolean object (15.6.1) */
|
||||
@@ -83,6 +90,7 @@ BUILTIN (ECMA_BUILTIN_ID_BOOLEAN,
|
||||
ECMA_MAGIC_STRING_BOOLEAN_UL,
|
||||
ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE,
|
||||
true,
|
||||
true,
|
||||
boolean)
|
||||
#endif /* !CONFIG_ECMA_COMPACT_PROFILE_DISABLE_BOOLEAN_BUILTIN */
|
||||
|
||||
@@ -93,6 +101,7 @@ BUILTIN (ECMA_BUILTIN_ID_NUMBER_PROTOTYPE,
|
||||
ECMA_MAGIC_STRING_NUMBER_UL,
|
||||
ECMA_BUILTIN_ID_OBJECT_PROTOTYPE,
|
||||
true,
|
||||
true,
|
||||
number_prototype)
|
||||
|
||||
/* The Number object (15.7.1) */
|
||||
@@ -101,6 +110,7 @@ BUILTIN (ECMA_BUILTIN_ID_NUMBER,
|
||||
ECMA_MAGIC_STRING_NUMBER_UL,
|
||||
ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE,
|
||||
true,
|
||||
true,
|
||||
number)
|
||||
#endif /* !CONFIG_ECMA_COMPACT_PROFILE_DISABLE_NUMBER_BUILTIN */
|
||||
|
||||
@@ -110,6 +120,7 @@ BUILTIN (ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE,
|
||||
ECMA_MAGIC_STRING_FUNCTION_UL,
|
||||
ECMA_BUILTIN_ID_OBJECT_PROTOTYPE,
|
||||
true,
|
||||
true,
|
||||
function_prototype)
|
||||
|
||||
/* The Function object (15.3.1) */
|
||||
@@ -118,6 +129,7 @@ BUILTIN (ECMA_BUILTIN_ID_FUNCTION,
|
||||
ECMA_MAGIC_STRING_FUNCTION_UL,
|
||||
ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE,
|
||||
true,
|
||||
true,
|
||||
function)
|
||||
|
||||
#ifndef CONFIG_ECMA_COMPACT_PROFILE_DISABLE_MATH_BUILTIN
|
||||
@@ -127,6 +139,7 @@ BUILTIN (ECMA_BUILTIN_ID_MATH,
|
||||
ECMA_MAGIC_STRING_MATH_UL,
|
||||
ECMA_BUILTIN_ID_OBJECT_PROTOTYPE,
|
||||
true,
|
||||
true,
|
||||
math)
|
||||
#endif /* !CONFIG_ECMA_COMPACT_PROFILE_DISABLE_MATH_BUILTIN */
|
||||
|
||||
@@ -137,6 +150,7 @@ BUILTIN (ECMA_BUILTIN_ID_ERROR_PROTOTYPE,
|
||||
ECMA_MAGIC_STRING_ERROR_UL,
|
||||
ECMA_BUILTIN_ID_OBJECT_PROTOTYPE,
|
||||
true,
|
||||
true,
|
||||
error_prototype)
|
||||
|
||||
/* The Error object (15.11.1) */
|
||||
@@ -145,6 +159,7 @@ BUILTIN (ECMA_BUILTIN_ID_ERROR,
|
||||
ECMA_MAGIC_STRING_ERROR_UL,
|
||||
ECMA_BUILTIN_ID_ERROR_PROTOTYPE,
|
||||
true,
|
||||
true,
|
||||
error)
|
||||
|
||||
/* The EvalError.prototype object (15.11.6.1) */
|
||||
@@ -153,6 +168,7 @@ BUILTIN (ECMA_BUILTIN_ID_EVAL_ERROR_PROTOTYPE,
|
||||
ECMA_MAGIC_STRING_ERROR_UL,
|
||||
ECMA_BUILTIN_ID_ERROR_PROTOTYPE,
|
||||
true,
|
||||
true,
|
||||
eval_error_prototype)
|
||||
|
||||
/* The EvalError object (15.11.6.1) */
|
||||
@@ -161,6 +177,7 @@ BUILTIN (ECMA_BUILTIN_ID_EVAL_ERROR,
|
||||
ECMA_MAGIC_STRING_ERROR_UL,
|
||||
ECMA_BUILTIN_ID_EVAL_ERROR_PROTOTYPE,
|
||||
true,
|
||||
true,
|
||||
eval_error)
|
||||
|
||||
/* The RangeError.prototype object (15.11.6.2) */
|
||||
@@ -169,6 +186,7 @@ BUILTIN (ECMA_BUILTIN_ID_RANGE_ERROR_PROTOTYPE,
|
||||
ECMA_MAGIC_STRING_ERROR_UL,
|
||||
ECMA_BUILTIN_ID_ERROR_PROTOTYPE,
|
||||
true,
|
||||
true,
|
||||
range_error_prototype)
|
||||
|
||||
/* The RangeError object (15.11.6.2) */
|
||||
@@ -177,6 +195,7 @@ BUILTIN (ECMA_BUILTIN_ID_RANGE_ERROR,
|
||||
ECMA_MAGIC_STRING_ERROR_UL,
|
||||
ECMA_BUILTIN_ID_RANGE_ERROR_PROTOTYPE,
|
||||
true,
|
||||
true,
|
||||
range_error)
|
||||
|
||||
/* The ReferenceError.prototype object (15.11.6.3) */
|
||||
@@ -185,6 +204,7 @@ BUILTIN (ECMA_BUILTIN_ID_REFERENCE_ERROR_PROTOTYPE,
|
||||
ECMA_MAGIC_STRING_ERROR_UL,
|
||||
ECMA_BUILTIN_ID_ERROR_PROTOTYPE,
|
||||
true,
|
||||
true,
|
||||
reference_error_prototype)
|
||||
|
||||
/* The ReferenceError object (15.11.6.3) */
|
||||
@@ -193,6 +213,7 @@ BUILTIN (ECMA_BUILTIN_ID_REFERENCE_ERROR,
|
||||
ECMA_MAGIC_STRING_ERROR_UL,
|
||||
ECMA_BUILTIN_ID_REFERENCE_ERROR_PROTOTYPE,
|
||||
true,
|
||||
true,
|
||||
reference_error)
|
||||
|
||||
/* The SyntaxError.prototype object (15.11.6.4) */
|
||||
@@ -201,6 +222,7 @@ BUILTIN (ECMA_BUILTIN_ID_SYNTAX_ERROR_PROTOTYPE,
|
||||
ECMA_MAGIC_STRING_ERROR_UL,
|
||||
ECMA_BUILTIN_ID_ERROR_PROTOTYPE,
|
||||
true,
|
||||
true,
|
||||
syntax_error_prototype)
|
||||
|
||||
/* The SyntaxError object (15.11.6.4) */
|
||||
@@ -209,6 +231,7 @@ BUILTIN (ECMA_BUILTIN_ID_SYNTAX_ERROR,
|
||||
ECMA_MAGIC_STRING_ERROR_UL,
|
||||
ECMA_BUILTIN_ID_SYNTAX_ERROR_PROTOTYPE,
|
||||
true,
|
||||
true,
|
||||
syntax_error)
|
||||
|
||||
/* The TypeError.prototype object (15.11.6.5) */
|
||||
@@ -217,6 +240,7 @@ BUILTIN (ECMA_BUILTIN_ID_TYPE_ERROR_PROTOTYPE,
|
||||
ECMA_MAGIC_STRING_ERROR_UL,
|
||||
ECMA_BUILTIN_ID_ERROR_PROTOTYPE,
|
||||
true,
|
||||
true,
|
||||
type_error_prototype)
|
||||
|
||||
/* The TypeError object (15.11.6.5) */
|
||||
@@ -225,6 +249,7 @@ BUILTIN (ECMA_BUILTIN_ID_TYPE_ERROR,
|
||||
ECMA_MAGIC_STRING_ERROR_UL,
|
||||
ECMA_BUILTIN_ID_TYPE_ERROR_PROTOTYPE,
|
||||
true,
|
||||
true,
|
||||
type_error)
|
||||
|
||||
/* The URIError.prototype object (15.11.6.6) */
|
||||
@@ -233,6 +258,7 @@ BUILTIN (ECMA_BUILTIN_ID_URI_ERROR_PROTOTYPE,
|
||||
ECMA_MAGIC_STRING_ERROR_UL,
|
||||
ECMA_BUILTIN_ID_ERROR_PROTOTYPE,
|
||||
true,
|
||||
true,
|
||||
uri_error_prototype)
|
||||
|
||||
/* The URIError object (15.11.6.6) */
|
||||
@@ -241,6 +267,7 @@ BUILTIN (ECMA_BUILTIN_ID_URI_ERROR,
|
||||
ECMA_MAGIC_STRING_ERROR_UL,
|
||||
ECMA_BUILTIN_ID_URI_ERROR_PROTOTYPE,
|
||||
true,
|
||||
true,
|
||||
uri_error)
|
||||
#endif /* !CONFIG_ECMA_COMPACT_PROFILE_DISABLE_ERROR_BUILTINS */
|
||||
|
||||
@@ -250,6 +277,7 @@ BUILTIN (ECMA_BUILTIN_ID_TYPE_ERROR_THROWER,
|
||||
ECMA_MAGIC_STRING_FUNCTION_UL,
|
||||
ECMA_BUILTIN_ID_FUNCTION_PROTOTYPE,
|
||||
false,
|
||||
true,
|
||||
type_error_thrower)
|
||||
|
||||
#ifdef CONFIG_ECMA_COMPACT_PROFILE
|
||||
@@ -259,6 +287,7 @@ BUILTIN (ECMA_BUILTIN_ID_COMPACT_PROFILE_ERROR,
|
||||
ECMA_MAGIC_STRING_COMPACT_PROFILE_ERROR_UL,
|
||||
ECMA_BUILTIN_ID_OBJECT_PROTOTYPE,
|
||||
false,
|
||||
true,
|
||||
compact_profile_error)
|
||||
#endif /* CONFIG_ECMA_COMPACT_PROFILE */
|
||||
|
||||
@@ -268,6 +297,16 @@ BUILTIN (ECMA_BUILTIN_ID_GLOBAL,
|
||||
ECMA_MAGIC_STRING_OBJECT_UL,
|
||||
ECMA_BUILTIN_ID__COUNT /* no prototype */,
|
||||
true,
|
||||
true,
|
||||
global)
|
||||
|
||||
/* Jerry's dynamic extension proxy object */
|
||||
BUILTIN (ECMA_BUILTIN_ID_JERRY,
|
||||
ECMA_OBJECT_TYPE_GENERAL,
|
||||
ECMA_MAGIC_STRING_OBJECT_UL,
|
||||
ECMA_BUILTIN_ID__COUNT, /* no prototype */
|
||||
false,
|
||||
false,
|
||||
jerry)
|
||||
|
||||
#undef BUILTIN
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
/* Copyright 2015 Samsung Electronics Co., Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ECMA_EXTENSION_H
|
||||
#define ECMA_EXTENSION_H
|
||||
|
||||
#include "ecma-globals.h"
|
||||
#include "jerry-extension.h"
|
||||
|
||||
/**
|
||||
* Maximum number of registered extensions
|
||||
*/
|
||||
#define ECMA_EXTENSION_MAX_NUMBER_OF_EXTENSIONS (CONFIG_EXTENSION_MAX_NUMBER_OF_EXTENSIONS)
|
||||
|
||||
/**
|
||||
* Maximum number of functions in an extension
|
||||
*/
|
||||
#define ECMA_EXTENSION_MAX_FUNCTIONS_IN_EXTENSION (CONFIG_EXTENSION_MAX_FUNCTIONS_IN_EXTENSION)
|
||||
|
||||
/**
|
||||
* Maximum number of arguments in a function
|
||||
*/
|
||||
#define ECMA_EXTENSION_MAX_ARGUMENTS_IN_FUNCTION (CONFIG_EXTENSION_MAX_ARGUMENTS_IN_FUNCTION)
|
||||
|
||||
extern bool ecma_extension_register (jerry_extension_descriptor_t *extension_desc_p);
|
||||
extern ecma_property_t* ecma_op_extension_object_get_own_property (ecma_object_t*, ecma_string_t*);
|
||||
|
||||
#endif /* ECMA_EXTENSION_H */
|
||||
Reference in New Issue
Block a user