mirror of
https://github.com/jerryscript-project/jerryscript.git
synced 2025-12-15 16:29:21 +00:00
Completely remove internal property support. (#1603)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
This commit is contained in:
parent
cc0f69613a
commit
54544163a9
@ -202,20 +202,8 @@ ecma_gc_mark_property (ecma_property_t *property_p) /**< property */
|
||||
}
|
||||
case ECMA_PROPERTY_TYPE_SPECIAL:
|
||||
{
|
||||
switch (ECMA_PROPERTY_GET_INTERNAL_PROPERTY_TYPE (property_p))
|
||||
{
|
||||
case ECMA_INTERNAL_PROPERTY_NATIVE_HANDLE: /* an external pointer */
|
||||
case ECMA_INTERNAL_PROPERTY_FREE_CALLBACK: /* an object's native free callback */
|
||||
{
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
JERRY_ASSERT (ECMA_PROPERTY_GET_INTERNAL_PROPERTY_TYPE (property_p) == ECMA_SPECIAL_PROPERTY_DELETED
|
||||
|| ECMA_PROPERTY_GET_INTERNAL_PROPERTY_TYPE (property_p) == ECMA_SPECIAL_PROPERTY_HASHMAP);
|
||||
break;
|
||||
}
|
||||
}
|
||||
JERRY_ASSERT (ECMA_PROPERTY_GET_SPECIAL_PROPERTY_TYPE (property_p) == ECMA_SPECIAL_PROPERTY_DELETED
|
||||
|| ECMA_PROPERTY_GET_SPECIAL_PROPERTY_TYPE (property_p) == ECMA_SPECIAL_PROPERTY_HASHMAP);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@ -369,13 +357,13 @@ ecma_gc_sweep (ecma_object_t *object_p) /**< object to free */
|
||||
ecma_external_pointer_t native_p;
|
||||
|
||||
bool is_retrieved = ecma_get_external_pointer_value (object_p,
|
||||
ECMA_INTERNAL_PROPERTY_FREE_CALLBACK,
|
||||
LIT_INTERNAL_MAGIC_STRING_FREE_CALLBACK,
|
||||
&freecb_p);
|
||||
|
||||
if (is_retrieved && ((jerry_object_free_callback_t) freecb_p) != NULL)
|
||||
{
|
||||
is_retrieved = ecma_get_external_pointer_value (object_p,
|
||||
ECMA_INTERNAL_PROPERTY_NATIVE_HANDLE,
|
||||
LIT_INTERNAL_MAGIC_STRING_NATIVE_HANDLE,
|
||||
&native_p);
|
||||
JERRY_ASSERT (is_retrieved);
|
||||
|
||||
|
||||
@ -206,9 +206,6 @@ typedef enum
|
||||
* ECMA_PROPERTY_IS_PROPERTY_PAIR must be updated as well. */
|
||||
ECMA_SPECIAL_PROPERTY_HASHMAP, /**< hashmap property */
|
||||
|
||||
ECMA_INTERNAL_PROPERTY_NATIVE_HANDLE, /**< native handle associated with an object */
|
||||
ECMA_INTERNAL_PROPERTY_FREE_CALLBACK, /**< object's native free callback */
|
||||
|
||||
ECMA_SPECIAL_PROPERTY__COUNT /**< Number of special property types */
|
||||
} ecma_internal_property_id_t;
|
||||
|
||||
@ -455,7 +452,7 @@ typedef struct
|
||||
/**
|
||||
* Returns the internal property type
|
||||
*/
|
||||
#define ECMA_PROPERTY_GET_INTERNAL_PROPERTY_TYPE(property_p) \
|
||||
#define ECMA_PROPERTY_GET_SPECIAL_PROPERTY_TYPE(property_p) \
|
||||
((ecma_internal_property_id_t) (*(property_p) >> ECMA_PROPERTY_FLAG_SHIFT))
|
||||
|
||||
/**
|
||||
|
||||
@ -29,35 +29,45 @@
|
||||
*
|
||||
* Note:
|
||||
* property identifier should be one of the following:
|
||||
* - ECMA_INTERNAL_PROPERTY_NATIVE_HANDLE;
|
||||
* - ECMA_INTERNAL_PROPERTY_FREE_CALLBACK.
|
||||
* - LIT_INTERNAL_MAGIC_STRING_NATIVE_HANDLE
|
||||
* - LIT_INTERNAL_MAGIC_STRING_FREE_CALLBACK
|
||||
*
|
||||
* @return true - if property was just created with specified value,
|
||||
* false - otherwise, if property existed before the call, it's value was updated.
|
||||
*/
|
||||
bool
|
||||
ecma_create_external_pointer_property (ecma_object_t *obj_p, /**< object to create property in */
|
||||
ecma_internal_property_id_t id, /**< identifier of internal
|
||||
* property to create */
|
||||
lit_magic_string_id_t id, /**< identifier of internal
|
||||
* property to create */
|
||||
ecma_external_pointer_t ptr_value) /**< value to store in the property */
|
||||
{
|
||||
JERRY_ASSERT (id == ECMA_INTERNAL_PROPERTY_NATIVE_HANDLE
|
||||
|| id == ECMA_INTERNAL_PROPERTY_FREE_CALLBACK);
|
||||
JERRY_ASSERT (id == LIT_INTERNAL_MAGIC_STRING_NATIVE_HANDLE
|
||||
|| id == LIT_INTERNAL_MAGIC_STRING_FREE_CALLBACK);
|
||||
|
||||
ecma_value_t *prop_p = ecma_find_internal_property (obj_p, id);
|
||||
bool is_new = (prop_p == NULL);
|
||||
ecma_string_t name;
|
||||
ecma_init_ecma_magic_string (&name, id);
|
||||
|
||||
ecma_property_t *property_p = ecma_find_named_property (obj_p, &name);
|
||||
bool is_new = (property_p == NULL);
|
||||
ecma_property_value_t *value_p;
|
||||
|
||||
if (is_new)
|
||||
{
|
||||
prop_p = ecma_create_internal_property (obj_p, id);
|
||||
value_p = ecma_create_named_data_property (obj_p, &name, ECMA_PROPERTY_FLAG_WRITABLE, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
value_p = ECMA_PROPERTY_VALUE_PTR (property_p);
|
||||
}
|
||||
|
||||
JERRY_STATIC_ASSERT (sizeof (uint32_t) <= sizeof (ECMA_PROPERTY_VALUE_PTR (prop_p)->value),
|
||||
JERRY_ASSERT (ECMA_STRING_IS_REF_EQUALS_TO_ONE (&name));
|
||||
|
||||
JERRY_STATIC_ASSERT (sizeof (uint32_t) <= sizeof (value_p->value),
|
||||
size_of_internal_property_value_must_be_greater_than_or_equal_to_4_bytes);
|
||||
|
||||
#ifdef ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY
|
||||
|
||||
*prop_p = (ecma_value_t) ptr_value;
|
||||
value_p->value = (ecma_value_t) ptr_value;
|
||||
|
||||
#else /* !ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY */
|
||||
|
||||
@ -67,11 +77,11 @@ ecma_create_external_pointer_property (ecma_object_t *obj_p, /**< object to crea
|
||||
{
|
||||
handler_p = ecma_alloc_external_pointer ();
|
||||
|
||||
ECMA_SET_NON_NULL_POINTER (*prop_p, handler_p);
|
||||
ECMA_SET_NON_NULL_POINTER (value_p->value, handler_p);
|
||||
}
|
||||
else
|
||||
{
|
||||
handler_p = ECMA_GET_NON_NULL_POINTER (ecma_external_pointer_t, *prop_p);
|
||||
handler_p = ECMA_GET_NON_NULL_POINTER (ecma_external_pointer_t, value_p->value);
|
||||
}
|
||||
|
||||
*handler_p = ptr_value;
|
||||
@ -86,37 +96,44 @@ ecma_create_external_pointer_property (ecma_object_t *obj_p, /**< object to crea
|
||||
*
|
||||
* Note:
|
||||
* property identifier should be one of the following:
|
||||
* - ECMA_INTERNAL_PROPERTY_NATIVE_HANDLE;
|
||||
* - ECMA_INTERNAL_PROPERTY_FREE_CALLBACK.
|
||||
* - LIT_INTERNAL_MAGIC_STRING_NATIVE_HANDLE
|
||||
* - LIT_INTERNAL_MAGIC_STRING_FREE_CALLBACK
|
||||
*
|
||||
* @return true - if property exists and it's value is returned through out_pointer_p,
|
||||
* false - otherwise (value returned through out_pointer_p is NULL).
|
||||
*/
|
||||
bool
|
||||
ecma_get_external_pointer_value (ecma_object_t *obj_p, /**< object to get property value from */
|
||||
ecma_internal_property_id_t id, /**< identifier of internal property
|
||||
* to get value from */
|
||||
lit_magic_string_id_t id, /**< identifier of internal property
|
||||
* to get value from */
|
||||
ecma_external_pointer_t *out_pointer_p) /**< [out] value of the external pointer */
|
||||
{
|
||||
JERRY_ASSERT (id == ECMA_INTERNAL_PROPERTY_NATIVE_HANDLE
|
||||
|| id == ECMA_INTERNAL_PROPERTY_FREE_CALLBACK);
|
||||
JERRY_ASSERT (id == LIT_INTERNAL_MAGIC_STRING_NATIVE_HANDLE
|
||||
|| id == LIT_INTERNAL_MAGIC_STRING_FREE_CALLBACK);
|
||||
|
||||
ecma_value_t *prop_p = ecma_find_internal_property (obj_p, id);
|
||||
ecma_string_t name;
|
||||
ecma_init_ecma_magic_string (&name, id);
|
||||
|
||||
if (prop_p == NULL)
|
||||
ecma_property_t *property_p = ecma_find_named_property (obj_p, &name);
|
||||
|
||||
JERRY_ASSERT (ECMA_STRING_IS_REF_EQUALS_TO_ONE (&name));
|
||||
|
||||
if (property_p == NULL)
|
||||
{
|
||||
*out_pointer_p = (ecma_external_pointer_t) NULL;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
ecma_property_value_t *value_p = ECMA_PROPERTY_VALUE_PTR (property_p);
|
||||
|
||||
#ifdef ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY
|
||||
|
||||
*out_pointer_p = *prop_p;
|
||||
*out_pointer_p = value_p->value;
|
||||
|
||||
#else /* !ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY */
|
||||
|
||||
*out_pointer_p = *ECMA_GET_NON_NULL_POINTER (ecma_external_pointer_t, *prop_p);
|
||||
*out_pointer_p = *ECMA_GET_NON_NULL_POINTER (ecma_external_pointer_t, value_p->value);
|
||||
|
||||
#endif /* ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY */
|
||||
|
||||
@ -128,18 +145,16 @@ ecma_get_external_pointer_value (ecma_object_t *obj_p, /**< object to get proper
|
||||
*
|
||||
* Note:
|
||||
* property identifier should be one of the following:
|
||||
* - ECMA_INTERNAL_PROPERTY_NATIVE_HANDLE;
|
||||
* - ECMA_INTERNAL_PROPERTY_FREE_CALLBACK.
|
||||
* - LIT_INTERNAL_MAGIC_STRING_NATIVE_HANDLE
|
||||
* - LIT_INTERNAL_MAGIC_STRING_FREE_CALLBACK
|
||||
*/
|
||||
void
|
||||
ecma_free_external_pointer_in_property (ecma_property_t *prop_p) /**< internal property */
|
||||
{
|
||||
JERRY_ASSERT (ECMA_PROPERTY_GET_INTERNAL_PROPERTY_TYPE (prop_p) == ECMA_INTERNAL_PROPERTY_NATIVE_HANDLE
|
||||
|| ECMA_PROPERTY_GET_INTERNAL_PROPERTY_TYPE (prop_p) == ECMA_INTERNAL_PROPERTY_FREE_CALLBACK);
|
||||
|
||||
#ifdef ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY
|
||||
|
||||
/* no additional memory was allocated for the pointer storage */
|
||||
JERRY_UNUSED (prop_p);
|
||||
|
||||
#else /* !ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY */
|
||||
|
||||
@ -149,7 +164,6 @@ ecma_free_external_pointer_in_property (ecma_property_t *prop_p) /**< internal p
|
||||
ecma_dealloc_external_pointer (handler_p);
|
||||
|
||||
#endif /* ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY */
|
||||
|
||||
} /* ecma_free_external_pointer_in_property */
|
||||
|
||||
/**
|
||||
|
||||
@ -357,16 +357,26 @@ ecma_init_ecma_string_from_uint32 (ecma_string_t *string_desc_p, /**< ecma-strin
|
||||
string_desc_p->u.uint32_number = uint32_number;
|
||||
} /* ecma_init_ecma_string_from_uint32 */
|
||||
|
||||
/**
|
||||
* Initialize a magic ecma-string
|
||||
*/
|
||||
void
|
||||
ecma_init_ecma_magic_string (ecma_string_t *string_desc_p, /**< ecma-string */
|
||||
lit_magic_string_id_t id) /**< literal id */
|
||||
{
|
||||
string_desc_p->refs_and_container = ECMA_STRING_CONTAINER_MAGIC_STRING | ECMA_STRING_REF_ONE;
|
||||
string_desc_p->hash = (lit_string_hash_t) id;
|
||||
|
||||
string_desc_p->u.magic_string_id = (uint32_t) id;
|
||||
} /* ecma_init_ecma_magic_string */
|
||||
|
||||
/**
|
||||
* Initialize a length ecma-string
|
||||
*/
|
||||
inline void __attr_always_inline___
|
||||
ecma_init_ecma_length_string (ecma_string_t *string_desc_p) /**< ecma-string */
|
||||
{
|
||||
string_desc_p->refs_and_container = ECMA_STRING_CONTAINER_MAGIC_STRING | ECMA_STRING_REF_ONE;
|
||||
string_desc_p->hash = LIT_MAGIC_STRING_LENGTH;
|
||||
|
||||
string_desc_p->u.magic_string_id = LIT_MAGIC_STRING_LENGTH;
|
||||
ecma_init_ecma_magic_string (string_desc_p, LIT_MAGIC_STRING_LENGTH);
|
||||
} /* ecma_init_ecma_length_string */
|
||||
|
||||
/**
|
||||
|
||||
@ -518,86 +518,6 @@ ecma_create_property (ecma_object_t *object_p, /**< the object */
|
||||
return first_property_pair_p->values + 1;
|
||||
} /* ecma_create_property */
|
||||
|
||||
/**
|
||||
* Create internal property in an object and link it into
|
||||
* the object's properties' linked-list (at start of the list).
|
||||
*
|
||||
* @return pointer to the newly created property value
|
||||
*/
|
||||
ecma_value_t *
|
||||
ecma_create_internal_property (ecma_object_t *object_p, /**< the object */
|
||||
ecma_internal_property_id_t property_id) /**< internal property identifier */
|
||||
{
|
||||
JERRY_ASSERT (ecma_find_internal_property (object_p, property_id) == NULL);
|
||||
|
||||
uint8_t type_and_flags = ECMA_SPECIAL_PROPERTY_VALUE (property_id);
|
||||
|
||||
ecma_property_value_t value;
|
||||
value.value = ECMA_NULL_POINTER;
|
||||
|
||||
ecma_property_value_t *prop_value_p = ecma_create_property (object_p, NULL, type_and_flags, value, NULL);
|
||||
return &prop_value_p->value;
|
||||
} /* ecma_create_internal_property */
|
||||
|
||||
/**
|
||||
* Find internal property in the object's property set.
|
||||
*
|
||||
* @return pointer to the property, if it is found,
|
||||
* NULL - otherwise.
|
||||
*/
|
||||
ecma_value_t *
|
||||
ecma_find_internal_property (ecma_object_t *object_p, /**< object descriptor */
|
||||
ecma_internal_property_id_t property_id) /**< internal property identifier */
|
||||
{
|
||||
JERRY_ASSERT (object_p != NULL);
|
||||
|
||||
ecma_property_header_t *prop_iter_p = ecma_get_property_list (object_p);
|
||||
|
||||
uint8_t value = ECMA_SPECIAL_PROPERTY_VALUE (property_id);
|
||||
|
||||
while (prop_iter_p != NULL)
|
||||
{
|
||||
JERRY_ASSERT (prop_iter_p->types[0] == ECMA_PROPERTY_TYPE_HASHMAP
|
||||
|| ECMA_PROPERTY_IS_PROPERTY_PAIR (prop_iter_p));
|
||||
|
||||
if (prop_iter_p->types[0] == value)
|
||||
{
|
||||
ecma_property_pair_t *prop_pair_p = (ecma_property_pair_t *) prop_iter_p;
|
||||
return &prop_pair_p->values[0].value;
|
||||
}
|
||||
|
||||
if (prop_iter_p->types[1] == value)
|
||||
{
|
||||
ecma_property_pair_t *prop_pair_p = (ecma_property_pair_t *) prop_iter_p;
|
||||
return &prop_pair_p->values[1].value;
|
||||
}
|
||||
|
||||
prop_iter_p = ECMA_GET_POINTER (ecma_property_header_t,
|
||||
prop_iter_p->next_property_cp);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
} /* ecma_find_internal_property */
|
||||
|
||||
/**
|
||||
* Get an internal property.
|
||||
*
|
||||
* Warning:
|
||||
* the property must exist
|
||||
*
|
||||
* @return pointer to the property
|
||||
*/
|
||||
inline ecma_value_t * __attr_always_inline___
|
||||
ecma_get_internal_property (ecma_object_t *object_p, /**< object descriptor */
|
||||
ecma_internal_property_id_t property_id) /**< internal property identifier */
|
||||
{
|
||||
ecma_value_t *property_p = ecma_find_internal_property (object_p, property_id);
|
||||
|
||||
JERRY_ASSERT (property_p != NULL);
|
||||
|
||||
return property_p;
|
||||
} /* ecma_get_internal_property */
|
||||
|
||||
/**
|
||||
* Create named data property with given name, attributes and undefined value
|
||||
* in the specified object.
|
||||
@ -779,31 +699,6 @@ ecma_get_named_data_property (ecma_object_t *obj_p, /**< object to find property
|
||||
return ECMA_PROPERTY_VALUE_PTR (property_p);
|
||||
} /* ecma_get_named_data_property */
|
||||
|
||||
/**
|
||||
* Free the internal property and values it references.
|
||||
*/
|
||||
static void
|
||||
ecma_free_internal_property (ecma_property_t *property_p) /**< the property */
|
||||
{
|
||||
JERRY_ASSERT (property_p != NULL && ECMA_PROPERTY_GET_TYPE (*property_p) == ECMA_PROPERTY_TYPE_SPECIAL);
|
||||
|
||||
switch (ECMA_PROPERTY_GET_INTERNAL_PROPERTY_TYPE (property_p))
|
||||
{
|
||||
case ECMA_INTERNAL_PROPERTY_NATIVE_HANDLE: /* an external pointer */
|
||||
case ECMA_INTERNAL_PROPERTY_FREE_CALLBACK: /* an external pointer */
|
||||
{
|
||||
ecma_free_external_pointer_in_property (property_p);
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
JERRY_UNREACHABLE ();
|
||||
break;
|
||||
}
|
||||
}
|
||||
} /* ecma_free_internal_property */
|
||||
|
||||
/**
|
||||
* Free property values and change their type to deleted.
|
||||
*/
|
||||
@ -818,6 +713,16 @@ ecma_free_property (ecma_object_t *object_p, /**< object the property belongs to
|
||||
{
|
||||
case ECMA_PROPERTY_TYPE_NAMEDDATA:
|
||||
{
|
||||
if (ECMA_PROPERTY_GET_NAME_TYPE (*property_p) == ECMA_STRING_CONTAINER_MAGIC_STRING)
|
||||
{
|
||||
if (name_cp == LIT_INTERNAL_MAGIC_STRING_NATIVE_HANDLE
|
||||
|| name_cp == LIT_INTERNAL_MAGIC_STRING_FREE_CALLBACK)
|
||||
{
|
||||
ecma_free_external_pointer_in_property (property_p);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ecma_free_value_if_not_object (ECMA_PROPERTY_VALUE_PTR (property_p)->value);
|
||||
break;
|
||||
}
|
||||
@ -833,11 +738,7 @@ ecma_free_property (ecma_object_t *object_p, /**< object the property belongs to
|
||||
}
|
||||
default:
|
||||
{
|
||||
JERRY_ASSERT (ECMA_PROPERTY_GET_TYPE (*property_p) == ECMA_PROPERTY_TYPE_SPECIAL);
|
||||
JERRY_ASSERT (name_cp == ECMA_NULL_POINTER);
|
||||
|
||||
ecma_free_internal_property (property_p);
|
||||
*property_p = ECMA_PROPERTY_TYPE_DELETED;
|
||||
JERRY_UNREACHABLE ();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@ -202,6 +202,7 @@ void ecma_string_to_utf8_bytes (const ecma_string_t *string_desc_p, lit_utf8_byt
|
||||
const lit_utf8_byte_t *ecma_string_raw_chars (const ecma_string_t *string_p, lit_utf8_size_t *size_p, bool *is_ascii_p);
|
||||
void ecma_init_ecma_string_from_uint32 (ecma_string_t *string_desc_p, uint32_t uint32_number);
|
||||
void ecma_init_ecma_length_string (ecma_string_t *string_desc_p);
|
||||
void ecma_init_ecma_magic_string (ecma_string_t *string_desc_p, lit_magic_string_id_t id);
|
||||
bool ecma_string_is_empty (const ecma_string_t *str_p);
|
||||
bool ecma_string_is_length (const ecma_string_t *string_p);
|
||||
|
||||
@ -298,10 +299,6 @@ ecma_property_header_t *ecma_get_property_list (const ecma_object_t *object_p) _
|
||||
ecma_object_t *ecma_get_lex_env_binding_object (const ecma_object_t *object_p) __attr_pure___;
|
||||
bool ecma_get_lex_env_provide_this (const ecma_object_t *object_p) __attr_pure___;
|
||||
|
||||
ecma_value_t *ecma_create_internal_property (ecma_object_t *object_p, ecma_internal_property_id_t property_id);
|
||||
ecma_value_t *ecma_find_internal_property (ecma_object_t *object_p, ecma_internal_property_id_t property_id);
|
||||
ecma_value_t *ecma_get_internal_property (ecma_object_t *object_p, ecma_internal_property_id_t property_id);
|
||||
|
||||
ecma_property_value_t *
|
||||
ecma_create_named_data_property (ecma_object_t *object_p, ecma_string_t *name_p, uint8_t prop_attributes,
|
||||
ecma_property_t **out_prop_p);
|
||||
@ -346,14 +343,11 @@ void ecma_bytecode_ref (ecma_compiled_code_t *bytecode_p);
|
||||
void ecma_bytecode_deref (ecma_compiled_code_t *bytecode_p);
|
||||
|
||||
/* ecma-helpers-external-pointers.c */
|
||||
bool
|
||||
ecma_create_external_pointer_property (ecma_object_t *obj_p, ecma_internal_property_id_t id,
|
||||
ecma_external_pointer_t ptr_value);
|
||||
bool
|
||||
ecma_get_external_pointer_value (ecma_object_t *obj_p, ecma_internal_property_id_t id,
|
||||
ecma_external_pointer_t *out_pointer_p);
|
||||
void
|
||||
ecma_free_external_pointer_in_property (ecma_property_t *prop_p);
|
||||
bool ecma_create_external_pointer_property (ecma_object_t *obj_p, lit_magic_string_id_t id,
|
||||
ecma_external_pointer_t ptr_value);
|
||||
bool ecma_get_external_pointer_value (ecma_object_t *obj_p, lit_magic_string_id_t id,
|
||||
ecma_external_pointer_t *out_pointer_p);
|
||||
void ecma_free_external_pointer_in_property (ecma_property_t *prop_p);
|
||||
|
||||
/* ecma-helpers-conversion.c */
|
||||
ecma_number_t ecma_utf8_string_to_number (const lit_utf8_byte_t *str_p, lit_utf8_size_t str_size);
|
||||
|
||||
@ -1433,6 +1433,14 @@ ecma_op_object_get_property_names (ecma_object_t *obj_p, /**< object */
|
||||
|| ECMA_PROPERTY_GET_TYPE (*property_p) == ECMA_PROPERTY_TYPE_NAMEDACCESSOR)
|
||||
{
|
||||
ecma_property_pair_t *prop_pair_p = (ecma_property_pair_t *) prop_iter_p;
|
||||
|
||||
if (ECMA_PROPERTY_GET_NAME_TYPE (*property_p) == ECMA_STRING_CONTAINER_MAGIC_STRING
|
||||
&& prop_pair_p->names_cp[i] >= LIT_NON_INTERNAL_MAGIC_STRING__COUNT)
|
||||
{
|
||||
/* Internal properties are never enumerated. */
|
||||
continue;
|
||||
}
|
||||
|
||||
ecma_string_t *name_p = ecma_string_from_property_name (*property_p,
|
||||
prop_pair_p->names_cp[i]);
|
||||
|
||||
|
||||
@ -1914,7 +1914,7 @@ jerry_get_object_native_handle (const jerry_value_t obj_val, /**< object to get
|
||||
uintptr_t handle_value;
|
||||
|
||||
bool does_exist = ecma_get_external_pointer_value (ecma_get_object_from_value (obj_val),
|
||||
ECMA_INTERNAL_PROPERTY_NATIVE_HANDLE,
|
||||
LIT_INTERNAL_MAGIC_STRING_NATIVE_HANDLE,
|
||||
&handle_value);
|
||||
|
||||
if (does_exist)
|
||||
@ -1947,11 +1947,11 @@ jerry_set_object_native_handle (const jerry_value_t obj_val, /**< object to set
|
||||
ecma_object_t *object_p = ecma_get_object_from_value (obj_val);
|
||||
|
||||
ecma_create_external_pointer_property (object_p,
|
||||
ECMA_INTERNAL_PROPERTY_NATIVE_HANDLE,
|
||||
LIT_INTERNAL_MAGIC_STRING_NATIVE_HANDLE,
|
||||
handle_p);
|
||||
|
||||
ecma_create_external_pointer_property (object_p,
|
||||
ECMA_INTERNAL_PROPERTY_FREE_CALLBACK,
|
||||
LIT_INTERNAL_MAGIC_STRING_FREE_CALLBACK,
|
||||
(uintptr_t) freecb_p);
|
||||
} /* jerry_set_object_native_handle */
|
||||
|
||||
|
||||
@ -47,7 +47,7 @@ lit_get_magic_string_utf8 (lit_magic_string_id_t id) /**< magic string id */
|
||||
#undef LIT_MAGIC_STRING_FIRST_STRING_WITH_SIZE
|
||||
};
|
||||
|
||||
JERRY_ASSERT (id < LIT_MAGIC_STRING__COUNT);
|
||||
JERRY_ASSERT (id < LIT_NON_INTERNAL_MAGIC_STRING__COUNT);
|
||||
|
||||
return lit_magic_strings[id];
|
||||
} /* lit_get_magic_string_utf8 */
|
||||
@ -70,7 +70,7 @@ lit_get_magic_string_size (lit_magic_string_id_t id) /**< magic string id */
|
||||
#undef LIT_MAGIC_STRING_FIRST_STRING_WITH_SIZE
|
||||
};
|
||||
|
||||
JERRY_ASSERT (id < LIT_MAGIC_STRING__COUNT);
|
||||
JERRY_ASSERT (id < LIT_NON_INTERNAL_MAGIC_STRING__COUNT);
|
||||
|
||||
return lit_magic_string_sizes[id];
|
||||
} /* lit_get_magic_string_size */
|
||||
@ -90,7 +90,7 @@ lit_get_magic_string_size_block_start (lit_utf8_size_t size) /**< magic string s
|
||||
#define LIT_MAGIC_STRING_FIRST_STRING_WITH_SIZE(size, id) \
|
||||
id,
|
||||
#include "lit-magic-strings.inc.h"
|
||||
LIT_MAGIC_STRING__COUNT
|
||||
LIT_NON_INTERNAL_MAGIC_STRING__COUNT
|
||||
#undef LIT_MAGIC_STRING_DEF
|
||||
#undef LIT_MAGIC_STRING_FIRST_STRING_WITH_SIZE
|
||||
};
|
||||
@ -189,7 +189,7 @@ lit_magic_string_id_t
|
||||
lit_is_utf8_string_magic (const lit_utf8_byte_t *string_p, /**< utf-8 string */
|
||||
lit_utf8_size_t string_size) /**< string size in bytes */
|
||||
{
|
||||
if (string_size > lit_get_magic_string_size (LIT_MAGIC_STRING__COUNT - 1))
|
||||
if (string_size > lit_get_magic_string_size (LIT_NON_INTERNAL_MAGIC_STRING__COUNT - 1))
|
||||
{
|
||||
return LIT_MAGIC_STRING__COUNT;
|
||||
}
|
||||
@ -234,7 +234,7 @@ lit_is_utf8_string_pair_magic (const lit_utf8_byte_t *string1_p, /**< first utf-
|
||||
{
|
||||
lit_utf8_size_t total_string_size = string1_size + string2_size;
|
||||
|
||||
if (total_string_size > lit_get_magic_string_size (LIT_MAGIC_STRING__COUNT - 1))
|
||||
if (total_string_size > lit_get_magic_string_size (LIT_NON_INTERNAL_MAGIC_STRING__COUNT - 1))
|
||||
{
|
||||
return LIT_MAGIC_STRING__COUNT;
|
||||
}
|
||||
|
||||
@ -34,6 +34,12 @@ typedef enum
|
||||
#include "lit-magic-strings.inc.h"
|
||||
#undef LIT_MAGIC_STRING_DEF
|
||||
#undef LIT_MAGIC_STRING_FIRST_STRING_WITH_SIZE
|
||||
LIT_NON_INTERNAL_MAGIC_STRING__COUNT, /**< number of non-internal magic strings */
|
||||
|
||||
LIT_INTERNAL_MAGIC_STRING_NATIVE_HANDLE = LIT_NON_INTERNAL_MAGIC_STRING__COUNT, /**< native handle associated
|
||||
* with an object */
|
||||
LIT_INTERNAL_MAGIC_STRING_FREE_CALLBACK, /**< object's native free callback */
|
||||
|
||||
LIT_MAGIC_STRING__COUNT /**< number of magic strings */
|
||||
} lit_magic_string_id_t;
|
||||
|
||||
|
||||
@ -85,7 +85,7 @@ main ()
|
||||
}
|
||||
else if (type == 1)
|
||||
{
|
||||
lit_magic_string_id_t msi = (lit_magic_string_id_t) (rand () % LIT_MAGIC_STRING__COUNT);
|
||||
lit_magic_string_id_t msi = (lit_magic_string_id_t) (rand () % LIT_NON_INTERNAL_MAGIC_STRING__COUNT);
|
||||
ptrs[j] = lit_get_magic_string_utf8 (msi);
|
||||
TEST_ASSERT (ptrs[j]);
|
||||
lengths[j] = (lit_utf8_size_t) lit_zt_utf8_string_size (ptrs[j]);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user