Remove deprecated native handle support. (#2496)

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
This commit is contained in:
Zoltan Herczeg
2018-08-29 12:51:37 +02:00
committed by GitHub
parent b4dc6b0cbe
commit 7d41d38e3c
9 changed files with 32 additions and 295 deletions
+8 -23
View File
@@ -404,37 +404,23 @@ ecma_gc_mark (ecma_object_t *object_p) /**< object to mark from */
* Free the native handle/pointer by calling its free callback.
*/
static void
ecma_gc_free_native_pointer (ecma_property_t *property_p, /**< property */
lit_magic_string_id_t id) /**< identifier of internal property */
ecma_gc_free_native_pointer (ecma_property_t *property_p) /**< property */
{
JERRY_ASSERT (property_p != NULL);
JERRY_ASSERT (id == LIT_INTERNAL_MAGIC_STRING_NATIVE_HANDLE
|| id == LIT_INTERNAL_MAGIC_STRING_NATIVE_POINTER);
ecma_property_value_t *value_p = ECMA_PROPERTY_VALUE_PTR (property_p);
ecma_native_pointer_t *native_pointer_p;
native_pointer_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_native_pointer_t,
value_p->value);
if (id == LIT_INTERNAL_MAGIC_STRING_NATIVE_HANDLE)
if (native_pointer_p->info_p != NULL)
{
if (native_pointer_p->u.callback_p != NULL)
{
native_pointer_p->u.callback_p ((uintptr_t) native_pointer_p->data_p);
}
}
else
{
if (native_pointer_p->u.info_p != NULL)
{
ecma_object_native_free_callback_t free_cb = native_pointer_p->u.info_p->free_cb;
ecma_object_native_free_callback_t free_cb = native_pointer_p->info_p->free_cb;
if (free_cb != NULL)
{
free_cb (native_pointer_p->data_p);
}
if (free_cb != NULL)
{
free_cb (native_pointer_p->data_p);
}
}
} /* ecma_gc_free_native_pointer */
@@ -479,10 +465,9 @@ ecma_gc_free_object (ecma_object_t *object_p) /**< object to free */
/* Call the native's free callback. */
if (ECMA_PROPERTY_GET_NAME_TYPE (*property_p) == ECMA_DIRECT_STRING_MAGIC
&& (name_cp == LIT_INTERNAL_MAGIC_STRING_NATIVE_HANDLE
|| name_cp == LIT_INTERNAL_MAGIC_STRING_NATIVE_POINTER))
&& (name_cp == LIT_INTERNAL_MAGIC_STRING_NATIVE_POINTER))
{
ecma_gc_free_native_pointer (property_p, (lit_magic_string_id_t) name_cp);
ecma_gc_free_native_pointer (property_p);
}
if (prop_iter_p->types[i] != ECMA_PROPERTY_TYPE_DELETED)
+1 -10
View File
@@ -261,11 +261,6 @@ typedef ecma_value_t (*ecma_external_handler_t) (const ecma_value_t function_obj
const ecma_value_t args_p[],
const ecma_length_t args_count);
/**
* Native free callback of an object (deprecated).
*/
typedef void (*ecma_object_free_callback_t) (const uintptr_t native_p);
/**
* Native free callback of an object.
*/
@@ -285,11 +280,7 @@ typedef struct
typedef struct
{
void *data_p; /**< points to the data of the object */
union
{
ecma_object_free_callback_t callback_p; /**< callback */
ecma_object_native_info_t *info_p; /**< native info */
} u;
ecma_object_native_info_t *info_p; /**< native info */
} ecma_native_pointer_t;
/**
@@ -25,27 +25,17 @@
*/
/**
* Create internal property with specified identifier and store native handle/pointer of the object.
*
* Note:
* property identifier should be one of the following:
* - LIT_INTERNAL_MAGIC_STRING_NATIVE_HANDLE
* - LIT_INTERNAL_MAGIC_STRING_NATIVE_POINTER
* Create a native pointer property to store the native pointer and its type info.
*
* @return true - if property was just created with specified value,
* false - otherwise, if property existed before the call, it's value was updated
*/
static bool
ecma_create_native_property (ecma_object_t *obj_p, /**< object to create property in */
lit_magic_string_id_t id, /**< identifier of internal
* property to create */
void *data_p, /**< native pointer data */
void *info_p) /**< native pointer's info */
bool
ecma_create_native_pointer_property (ecma_object_t *obj_p, /**< object to create property in */
void *native_p, /**< native pointer */
void *info_p) /**< native pointer's type info */
{
JERRY_ASSERT (id == LIT_INTERNAL_MAGIC_STRING_NATIVE_HANDLE
|| id == LIT_INTERNAL_MAGIC_STRING_NATIVE_POINTER);
ecma_string_t *name_p = ecma_get_magic_string (id);
ecma_string_t *name_p = ecma_get_magic_string (LIT_INTERNAL_MAGIC_STRING_NATIVE_POINTER);
ecma_property_t *property_p = ecma_find_named_property (obj_p, name_p);
bool is_new = (property_p == NULL);
@@ -68,44 +58,10 @@ ecma_create_native_property (ecma_object_t *obj_p, /**< object to create propert
native_pointer_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_native_pointer_t, value_p->value);
}
native_pointer_p->data_p = data_p;
native_pointer_p->u.info_p = info_p;
native_pointer_p->data_p = native_p;
native_pointer_p->info_p = info_p;
return is_new;
} /* ecma_create_native_property */
/**
* Create a native handle property to store the native handle and its 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_native_handle_property (ecma_object_t *obj_p, /**< object to create property in */
void *handle_p, /**< native handle */
void *free_cb) /**< native handle's free callback*/
{
return ecma_create_native_property (obj_p,
LIT_INTERNAL_MAGIC_STRING_NATIVE_HANDLE,
handle_p,
free_cb);
} /* ecma_create_native_handle_property */
/**
* Create a native pointer property to store the native pointer and its type info.
*
* @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_native_pointer_property (ecma_object_t *obj_p, /**< object to create property in */
void *native_p, /**< native pointer */
void *info_p) /**< native pointer's type info */
{
return ecma_create_native_property (obj_p,
LIT_INTERNAL_MAGIC_STRING_NATIVE_POINTER,
native_p,
info_p);
} /* ecma_create_native_pointer_property */
/**
@@ -120,14 +76,10 @@ ecma_create_native_pointer_property (ecma_object_t *obj_p, /**< object to create
* NULL otherwise
*/
ecma_native_pointer_t *
ecma_get_native_pointer_value (ecma_object_t *obj_p, /**< object to get property value from */
lit_magic_string_id_t id) /**< identifier of internal property
* to get value from */
ecma_get_native_pointer_value (ecma_object_t *obj_p) /**< object to get property value from */
{
JERRY_ASSERT (id == LIT_INTERNAL_MAGIC_STRING_NATIVE_HANDLE
|| id == LIT_INTERNAL_MAGIC_STRING_NATIVE_POINTER);
ecma_property_t *property_p = ecma_find_named_property (obj_p, ecma_get_magic_string (id));
ecma_string_t *name_p = ecma_get_magic_string (LIT_INTERNAL_MAGIC_STRING_NATIVE_POINTER);
ecma_property_t *property_p = ecma_find_named_property (obj_p, name_p);
if (property_p == NULL)
{
+1 -2
View File
@@ -744,8 +744,7 @@ 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_DIRECT_STRING_MAGIC
&& (name_cp == LIT_INTERNAL_MAGIC_STRING_NATIVE_HANDLE
|| name_cp == LIT_INTERNAL_MAGIC_STRING_NATIVE_POINTER))
&& (name_cp == LIT_INTERNAL_MAGIC_STRING_NATIVE_POINTER))
{
ecma_free_native_pointer (property_p);
break;
+1 -2
View File
@@ -355,9 +355,8 @@ 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_native_handle_property (ecma_object_t *obj_p, void *handle_p, void *free_cb);
bool ecma_create_native_pointer_property (ecma_object_t *obj_p, void *native_p, void *info_p);
ecma_native_pointer_t *ecma_get_native_pointer_value (ecma_object_t *obj_p, lit_magic_string_id_t id);
ecma_native_pointer_t *ecma_get_native_pointer_value (ecma_object_t *obj_p);
void ecma_free_native_pointer (ecma_property_t *prop_p);
/* ecma-helpers-conversion.c */