Skip to content

Commit

Permalink
Use const object parameters in getter API functions
Browse files Browse the repository at this point in the history
Related issue: jerryscript-project#668

JerryScript-DCO-1.0-Signed-off-by: László Langó [email protected]
  • Loading branch information
LaszloLango committed Jun 2, 2016
1 parent 5c852ab commit 56dd68c
Show file tree
Hide file tree
Showing 17 changed files with 49 additions and 50 deletions.
2 changes: 1 addition & 1 deletion jerry-core/ecma/base/ecma-helpers-external-pointers.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ ecma_create_external_pointer_property (ecma_object_t *obj_p, /**< object to crea
* 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_get_external_pointer_value (const 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 */
ecma_external_pointer_t *out_pointer_p) /**< [out] value of the external pointer */
Expand Down
6 changes: 3 additions & 3 deletions jerry-core/ecma/base/ecma-helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ ecma_create_internal_property (ecma_object_t *object_p, /**< the object */
* NULL - otherwise.
*/
ecma_property_t *
ecma_find_internal_property (ecma_object_t *object_p, /**< object descriptor */
ecma_find_internal_property (const ecma_object_t *object_p, /**< object descriptor */
ecma_internal_property_id_t property_id) /**< internal property identifier */
{
JERRY_ASSERT (object_p != NULL);
Expand Down Expand Up @@ -557,7 +557,7 @@ ecma_find_internal_property (ecma_object_t *object_p, /**< object descriptor */
* @return pointer to the property
*/
ecma_property_t *
ecma_get_internal_property (ecma_object_t *object_p, /**< object descriptor */
ecma_get_internal_property (const ecma_object_t *object_p, /**< object descriptor */
ecma_internal_property_id_t property_id) /**< internal property identifier */
{
ecma_property_t *property_p = ecma_find_internal_property (object_p, property_id);
Expand Down Expand Up @@ -1096,7 +1096,7 @@ ecma_set_internal_property_value (ecma_property_t *prop_p, /**< property */
* value previously stored in the property is freed
*/
void
ecma_named_data_property_assign_value (ecma_object_t *obj_p, /**< object */
ecma_named_data_property_assign_value (const ecma_object_t *obj_p, /**< object */
ecma_property_t *prop_p, /**< property */
ecma_value_t value) /**< value to assign */
{
Expand Down
8 changes: 4 additions & 4 deletions jerry-core/ecma/base/ecma-helpers.h
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,8 @@ extern ecma_object_t *ecma_get_lex_env_binding_object (const ecma_object_t *) __
extern bool ecma_get_lex_env_provide_this (const ecma_object_t *) __attr_pure___;

extern ecma_property_t *ecma_create_internal_property (ecma_object_t *, ecma_internal_property_id_t);
extern ecma_property_t *ecma_find_internal_property (ecma_object_t *, ecma_internal_property_id_t);
extern ecma_property_t *ecma_get_internal_property (ecma_object_t *, ecma_internal_property_id_t);
extern ecma_property_t *ecma_find_internal_property (const ecma_object_t *, ecma_internal_property_id_t);
extern ecma_property_t *ecma_get_internal_property (const ecma_object_t *, ecma_internal_property_id_t);

extern ecma_property_t *
ecma_create_named_data_property (ecma_object_t *, ecma_string_t *, uint8_t);
Expand All @@ -282,7 +282,7 @@ extern void ecma_delete_property (ecma_object_t *, ecma_property_t *);

extern ecma_value_t ecma_get_named_data_property_value (const ecma_property_t *);
extern void ecma_set_named_data_property_value (ecma_property_t *, ecma_value_t);
extern void ecma_named_data_property_assign_value (ecma_object_t *, ecma_property_t *, ecma_value_t);
extern void ecma_named_data_property_assign_value (const ecma_object_t *, ecma_property_t *, ecma_value_t);

extern ecma_value_t ecma_get_internal_property_value (const ecma_property_t *);
extern void ecma_set_internal_property_value (ecma_property_t *, ecma_value_t);
Expand Down Expand Up @@ -314,7 +314,7 @@ extern void ecma_bytecode_deref (ecma_compiled_code_t *);
extern bool
ecma_create_external_pointer_property (ecma_object_t *, ecma_internal_property_id_t, ecma_external_pointer_t);
extern bool
ecma_get_external_pointer_value (ecma_object_t *, ecma_internal_property_id_t, ecma_external_pointer_t *);
ecma_get_external_pointer_value (const ecma_object_t *, ecma_internal_property_id_t, ecma_external_pointer_t *);
extern void
ecma_free_external_pointer_in_property (ecma_property_t *);

Expand Down
2 changes: 1 addition & 1 deletion jerry-core/ecma/base/ecma-lcache.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ ecma_lcache_insert (ecma_object_t *object_p, /**< object */
* NULL otherwise
*/
inline ecma_property_t * __attr_always_inline___
ecma_lcache_lookup (ecma_object_t *object_p, /**< object */
ecma_lcache_lookup (const ecma_object_t *object_p, /**< object */
const ecma_string_t *prop_name_p) /**< property's name */
{
JERRY_ASSERT (object_p != NULL);
Expand Down
2 changes: 1 addition & 1 deletion jerry-core/ecma/base/ecma-lcache.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@

extern void ecma_lcache_init (void);
extern void ecma_lcache_insert (ecma_object_t *, ecma_string_t *, ecma_property_t *);
extern ecma_property_t *ecma_lcache_lookup (ecma_object_t *, const ecma_string_t *);
extern ecma_property_t *ecma_lcache_lookup (const ecma_object_t *, const ecma_string_t *);
extern void ecma_lcache_invalidate (ecma_object_t *, ecma_string_t *, ecma_property_t *);

/**
Expand Down
4 changes: 2 additions & 2 deletions jerry-core/ecma/operations/ecma-function-object.c
Original file line number Diff line number Diff line change
Expand Up @@ -373,7 +373,7 @@ ecma_op_function_try_lazy_instantiate_property (ecma_object_t *obj_p, /**< the f
* NULL (i.e. ecma-undefined) - otherwise.
*/
ecma_property_t *
ecma_op_function_object_get_own_property (ecma_object_t *obj_p, /**< the function object */
ecma_op_function_object_get_own_property (const ecma_object_t *obj_p, /**< the function object */
ecma_string_t *property_name_p) /**< property name */
{
JERRY_ASSERT (ecma_get_object_type (obj_p) == ECMA_OBJECT_TYPE_FUNCTION);
Expand All @@ -386,7 +386,7 @@ ecma_op_function_object_get_own_property (ecma_object_t *obj_p, /**< the functio
}
else if (!ecma_get_object_is_builtin (obj_p))
{
prop_p = ecma_op_function_try_lazy_instantiate_property (obj_p, property_name_p);
prop_p = ecma_op_function_try_lazy_instantiate_property ((ecma_object_t *) obj_p, property_name_p);

/*
* Only non-configurable properties could be instantiated lazily in the function,
Expand Down
2 changes: 1 addition & 1 deletion jerry-core/ecma/operations/ecma-function-object.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ ecma_op_function_call (ecma_object_t *, ecma_value_t,
const ecma_value_t *, ecma_length_t);

extern ecma_property_t *
ecma_op_function_object_get_own_property (ecma_object_t *, ecma_string_t *);
ecma_op_function_object_get_own_property (const ecma_object_t *, ecma_string_t *);

extern ecma_value_t
ecma_op_function_construct (ecma_object_t *, const ecma_value_t *, ecma_length_t);
Expand Down
4 changes: 2 additions & 2 deletions jerry-core/ecma/operations/ecma-objects-arguments.c
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ ecma_arguments_get_mapped_arg_value (ecma_object_t *map_p, /**< [[ParametersMap]
* Returned value must be freed with ecma_free_value
*/
ecma_value_t
ecma_op_arguments_object_get (ecma_object_t *obj_p, /**< the object */
ecma_op_arguments_object_get (const ecma_object_t *obj_p, /**< the object */
ecma_string_t *property_name_p) /**< property name */
{
// 1.
Expand Down Expand Up @@ -344,7 +344,7 @@ ecma_op_arguments_object_get (ecma_object_t *obj_p, /**< the object */
* Returned value must be freed with ecma_free_value
*/
ecma_property_t *
ecma_op_arguments_object_get_own_property (ecma_object_t *obj_p, /**< the object */
ecma_op_arguments_object_get_own_property (const ecma_object_t *obj_p, /**< the object */
ecma_string_t *property_name_p) /**< property name */
{
// 1.
Expand Down
4 changes: 2 additions & 2 deletions jerry-core/ecma/operations/ecma-objects-arguments.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ ecma_op_create_arguments_object (ecma_object_t *, ecma_object_t *, const ecma_va
ecma_length_t, const ecma_compiled_code_t *);

extern ecma_value_t
ecma_op_arguments_object_get (ecma_object_t *, ecma_string_t *);
ecma_op_arguments_object_get (const ecma_object_t *, ecma_string_t *);
extern ecma_property_t *
ecma_op_arguments_object_get_own_property (ecma_object_t *, ecma_string_t *);
ecma_op_arguments_object_get_own_property (const ecma_object_t *, ecma_string_t *);
extern ecma_value_t
ecma_op_arguments_object_delete (ecma_object_t *, ecma_string_t *, bool);
extern ecma_value_t
Expand Down
8 changes: 4 additions & 4 deletions jerry-core/ecma/operations/ecma-objects-general.c
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ ecma_op_create_object_object_noarg_and_set_prototype (ecma_object_t *object_prot
* Returned value must be freed with ecma_free_value
*/
ecma_value_t
ecma_op_general_object_get (ecma_object_t *obj_p, /**< the object */
ecma_op_general_object_get (const ecma_object_t *obj_p, /**< the object */
ecma_string_t *property_name_p) /**< property name */
{
JERRY_ASSERT (obj_p != NULL
Expand Down Expand Up @@ -194,14 +194,14 @@ ecma_op_general_object_get (ecma_object_t *obj_p, /**< the object */
* NULL (i.e. ecma-undefined) - otherwise.
*/
ecma_property_t *
ecma_op_general_object_get_own_property (ecma_object_t *obj_p, /**< the object */
ecma_op_general_object_get_own_property (const ecma_object_t *obj_p, /**< the object */
ecma_string_t *property_name_p) /**< property name */
{
JERRY_ASSERT (obj_p != NULL
&& !ecma_is_lexical_environment (obj_p));
JERRY_ASSERT (property_name_p != NULL);

return ecma_find_named_property (obj_p, property_name_p);
return ecma_find_named_property ((ecma_object_t *) obj_p, property_name_p);
} /* ecma_op_general_object_get_own_property */

/**
Expand All @@ -215,7 +215,7 @@ ecma_op_general_object_get_own_property (ecma_object_t *obj_p, /**< the object *
* NULL (i.e. ecma-undefined) - otherwise.
*/
ecma_property_t *
ecma_op_general_object_get_property (ecma_object_t *obj_p, /**< the object */
ecma_op_general_object_get_property (const ecma_object_t *obj_p, /**< the object */
ecma_string_t *property_name_p) /**< property name */
{
JERRY_ASSERT (obj_p != NULL
Expand Down
6 changes: 3 additions & 3 deletions jerry-core/ecma/operations/ecma-objects-general.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ extern ecma_object_t *ecma_op_create_object_object_noarg (void);
extern ecma_value_t ecma_op_create_object_object_arg (ecma_value_t);
extern ecma_object_t *ecma_op_create_object_object_noarg_and_set_prototype (ecma_object_t *);

extern ecma_value_t ecma_op_general_object_get (ecma_object_t *, ecma_string_t *);
extern ecma_property_t *ecma_op_general_object_get_own_property (ecma_object_t *, ecma_string_t *);
extern ecma_property_t *ecma_op_general_object_get_property (ecma_object_t *, ecma_string_t *);
extern ecma_value_t ecma_op_general_object_get (const ecma_object_t *, ecma_string_t *);
extern ecma_property_t *ecma_op_general_object_get_own_property (const ecma_object_t *, ecma_string_t *);
extern ecma_property_t *ecma_op_general_object_get_property (const ecma_object_t *, ecma_string_t *);
extern ecma_value_t ecma_op_general_object_put (ecma_object_t *, ecma_string_t *, ecma_value_t, bool);
extern ecma_value_t ecma_op_general_object_delete (ecma_object_t *, ecma_string_t *, bool);
extern ecma_value_t ecma_op_general_object_default_value (ecma_object_t *, ecma_preferred_type_hint_t);
Expand Down
13 changes: 6 additions & 7 deletions jerry-core/ecma/operations/ecma-objects.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
* Returned value must be freed with ecma_free_value
*/
ecma_value_t
ecma_op_object_get (ecma_object_t *obj_p, /**< the object */
ecma_op_object_get (const ecma_object_t *obj_p, /**< the object */
ecma_string_t *property_name_p) /**< property name */
{
JERRY_ASSERT (obj_p != NULL
Expand Down Expand Up @@ -101,11 +101,10 @@ ecma_op_object_get (ecma_object_t *obj_p, /**< the object */
* NULL (i.e. ecma-undefined) - otherwise.
*/
static ecma_property_t * __attr_noinline___
ecma_op_object_get_own_property_longpath (ecma_object_t *obj_p, /**< the object */
ecma_op_object_get_own_property_longpath (const ecma_object_t *obj_p, /**< the object */
ecma_string_t *property_name_p) /**< property name */
{
const ecma_object_type_t type = ecma_get_object_type (obj_p);
const bool is_builtin = ecma_get_object_is_builtin (obj_p);

ecma_property_t *prop_p = NULL;

Expand Down Expand Up @@ -151,9 +150,9 @@ ecma_op_object_get_own_property_longpath (ecma_object_t *obj_p, /**< the object

if (unlikely (prop_p == NULL))
{
if (is_builtin)
if (ecma_get_object_is_builtin (obj_p))
{
prop_p = ecma_builtin_try_to_instantiate_property (obj_p, property_name_p);
prop_p = ecma_builtin_try_to_instantiate_property ((ecma_object_t *) obj_p, property_name_p);
}
}

Expand All @@ -170,7 +169,7 @@ ecma_op_object_get_own_property_longpath (ecma_object_t *obj_p, /**< the object
* NULL (i.e. ecma-undefined) - otherwise.
*/
ecma_property_t *
ecma_op_object_get_own_property (ecma_object_t *obj_p, /**< the object */
ecma_op_object_get_own_property (const ecma_object_t *obj_p, /**< the object */
ecma_string_t *property_name_p) /**< property name */
{
JERRY_ASSERT (obj_p != NULL
Expand Down Expand Up @@ -199,7 +198,7 @@ ecma_op_object_get_own_property (ecma_object_t *obj_p, /**< the object */
* NULL (i.e. ecma-undefined) - otherwise.
*/
ecma_property_t *
ecma_op_object_get_property (ecma_object_t *obj_p, /**< the object */
ecma_op_object_get_property (const ecma_object_t *obj_p, /**< the object */
ecma_string_t *property_name_p) /**< property name */
{
JERRY_ASSERT (obj_p != NULL
Expand Down
6 changes: 3 additions & 3 deletions jerry-core/ecma/operations/ecma-objects.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
* @{
*/

extern ecma_value_t ecma_op_object_get (ecma_object_t *, ecma_string_t *);
extern ecma_property_t *ecma_op_object_get_own_property (ecma_object_t *, ecma_string_t *);
extern ecma_property_t *ecma_op_object_get_property (ecma_object_t *, ecma_string_t *);
extern ecma_value_t ecma_op_object_get (const ecma_object_t *, ecma_string_t *);
extern ecma_property_t *ecma_op_object_get_own_property (const ecma_object_t *, ecma_string_t *);
extern ecma_property_t *ecma_op_object_get_property (const ecma_object_t *, ecma_string_t *);
extern ecma_value_t ecma_op_object_put (ecma_object_t *, ecma_string_t *, ecma_value_t, bool);
extern ecma_value_t ecma_op_object_delete (ecma_object_t *, ecma_string_t *, bool);
extern ecma_value_t ecma_op_object_default_value (ecma_object_t *, ecma_preferred_type_hint_t);
Expand Down
4 changes: 2 additions & 2 deletions jerry-core/ecma/operations/ecma-string-object.c
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ ecma_op_create_string_object (const ecma_value_t *arguments_list_p, /**< list of
* Returned value must be freed with ecma_free_value
*/
ecma_property_t *
ecma_op_string_object_get_own_property (ecma_object_t *obj_p, /**< a String object */
ecma_op_string_object_get_own_property (const ecma_object_t *obj_p, /**< a String object */
ecma_string_t *property_name_p) /**< property name */
{
JERRY_ASSERT (ecma_get_object_type (obj_p) == ECMA_OBJECT_TYPE_STRING);
Expand Down Expand Up @@ -189,7 +189,7 @@ ecma_op_string_object_get_own_property (ecma_object_t *obj_p, /**< a String obje
// 9.
ecma_string_t *new_prop_str_value_p = ecma_new_ecma_string_from_code_unit (c);

new_prop_p = ecma_create_named_data_property (obj_p,
new_prop_p = ecma_create_named_data_property ((ecma_object_t *) obj_p,
new_prop_name_p,
ECMA_PROPERTY_FLAG_ENUMERABLE);

Expand Down
2 changes: 1 addition & 1 deletion jerry-core/ecma/operations/ecma-string-object.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ extern ecma_value_t
ecma_op_create_string_object (const ecma_value_t *, ecma_length_t);

extern ecma_property_t *
ecma_op_string_object_get_own_property (ecma_object_t *, ecma_string_t *);
ecma_op_string_object_get_own_property (const ecma_object_t *, ecma_string_t *);

extern void
ecma_op_string_list_lazy_property_names (ecma_object_t *,
Expand Down
8 changes: 4 additions & 4 deletions jerry-core/jerry-api.h
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ jerry_api_string_t *jerry_api_create_string (const jerry_api_char_t *);
jerry_api_string_t *jerry_api_create_string_sz (const jerry_api_char_t *, jerry_api_size_t);

bool jerry_api_set_array_index_value (jerry_api_object_t *, jerry_api_length_t, jerry_api_value_t *);
bool jerry_api_get_array_index_value (jerry_api_object_t *, jerry_api_length_t, jerry_api_value_t *);
bool jerry_api_get_array_index_value (const jerry_api_object_t *, jerry_api_length_t, jerry_api_value_t *);

jerry_api_object_t *jerry_api_create_error (jerry_api_error_t, const jerry_api_char_t *);
jerry_api_object_t *jerry_api_create_error_sz (jerry_api_error_t, const jerry_api_char_t *, jerry_api_size_t);
Expand All @@ -297,16 +297,16 @@ bool jerry_api_add_object_field (jerry_api_object_t *, const jerry_api_char_t *,
const jerry_api_value_t *, bool);
bool jerry_api_delete_object_field (jerry_api_object_t *, const jerry_api_char_t *, jerry_api_size_t);

bool jerry_api_get_object_field_value (jerry_api_object_t *, const jerry_api_char_t *, jerry_api_value_t *);
bool jerry_api_get_object_field_value_sz (jerry_api_object_t *, const jerry_api_char_t *, jerry_api_size_t,
bool jerry_api_get_object_field_value (const jerry_api_object_t *, const jerry_api_char_t *, jerry_api_value_t *);
bool jerry_api_get_object_field_value_sz (const jerry_api_object_t *, const jerry_api_char_t *, jerry_api_size_t,
jerry_api_value_t *);

bool jerry_api_set_object_field_value (jerry_api_object_t *, const jerry_api_char_t *, const jerry_api_value_t *);
bool jerry_api_set_object_field_value_sz (jerry_api_object_t *, const jerry_api_char_t *, jerry_api_size_t,
const jerry_api_value_t *);

bool jerry_api_foreach_object_field (jerry_api_object_t *, jerry_object_field_foreach_t, void *);
bool jerry_api_get_object_native_handle (jerry_api_object_t *, uintptr_t *);
bool jerry_api_get_object_native_handle (const jerry_api_object_t *, uintptr_t *);
void jerry_api_set_object_native_handle (jerry_api_object_t *, uintptr_t, jerry_object_free_callback_t);
bool jerry_api_call_function (jerry_api_object_t *, jerry_api_object_t *, jerry_api_value_t *,
const jerry_api_value_t[], uint16_t);
Expand Down
Loading

0 comments on commit 56dd68c

Please sign in to comment.