本文整理汇总了C++中ecma_get_object_from_value函数的典型用法代码示例。如果您正苦于以下问题:C++ ecma_get_object_from_value函数的具体用法?C++ ecma_get_object_from_value怎么用?C++ ecma_get_object_from_value使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ecma_get_object_from_value函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ecma_builtin_date_prototype_to_date_string
/**
* The Date.prototype object's 'toDateString' routine
*
* See also:
* ECMA-262 v5, 15.9.5.3
*
* @return ecma value
* Returned value must be freed with ecma_free_value.
*/
static ecma_value_t
ecma_builtin_date_prototype_to_date_string (ecma_value_t this_arg) /**< this argument */
{
ecma_value_t ret_value = ecma_make_simple_value (ECMA_SIMPLE_VALUE_EMPTY);
if (!ecma_is_value_object (this_arg)
|| ecma_object_get_class_name (ecma_get_object_from_value (this_arg)) != LIT_MAGIC_STRING_DATE_UL)
{
ret_value = ecma_raise_type_error (ECMA_ERR_MSG ("Incompatible type"));
}
else
{
ECMA_TRY_CATCH (obj_this,
ecma_op_to_object (this_arg),
ret_value);
ecma_object_t *obj_p = ecma_get_object_from_value (obj_this);
ecma_property_t *prim_prop_p = ecma_get_internal_property (obj_p,
ECMA_INTERNAL_PROPERTY_PRIMITIVE_NUMBER_VALUE);
ecma_number_t *prim_value_num_p = ECMA_GET_NON_NULL_POINTER (ecma_number_t,
ecma_get_internal_property_value (prim_prop_p));
if (ecma_number_is_nan (*prim_value_num_p))
{
ecma_string_t *magic_str_p = ecma_get_magic_string (LIT_MAGIC_STRING_INVALID_DATE_UL);
ret_value = ecma_make_string_value (magic_str_p);
}
else
{
ret_value = ecma_date_value_to_date_string (*prim_value_num_p);
}
ECMA_FINALIZE (obj_this);
}
return ret_value;
} /* ecma_builtin_date_prototype_to_date_string */
示例2: ecma_process_promise_resolve_thenable_job
/**
* Process the PromiseResolveThenableJob.
*
* See also: ES2015 25.4.2.2
*
* @return ecma value
* Returned value must be freed with ecma_free_value
*/
static ecma_value_t
ecma_process_promise_resolve_thenable_job (void *obj_p) /**< the job to be operated */
{
ecma_job_promise_resolve_thenable_t *job_p = (ecma_job_promise_resolve_thenable_t *) obj_p;
ecma_object_t *promise_p = ecma_get_object_from_value (job_p->promise);
ecma_string_t str_resolve, str_reject;
ecma_init_ecma_magic_string (&str_resolve, LIT_INTERNAL_MAGIC_STRING_RESOLVE_FUNCTION);
ecma_init_ecma_magic_string (&str_reject, LIT_INTERNAL_MAGIC_STRING_REJECT_FUNCTION);
ecma_value_t resolve = ecma_op_object_get (promise_p, &str_resolve);
ecma_value_t reject = ecma_op_object_get (promise_p, &str_reject);
ecma_value_t argv[] = { resolve, reject };
ecma_value_t ret;
ecma_value_t then_call_result = ecma_op_function_call (ecma_get_object_from_value (job_p->then),
job_p->thenable,
argv,
2);
ret = then_call_result;
if (ECMA_IS_VALUE_ERROR (then_call_result))
{
ret = ecma_op_function_call (ecma_get_object_from_value (reject),
ecma_make_simple_value (ECMA_SIMPLE_VALUE_UNDEFINED),
&then_call_result,
1);
ecma_free_value (then_call_result);
}
ecma_free_value (resolve);
ecma_free_value (reject);
ecma_free_promise_resolve_thenable_job (job_p);
return ret;
} /* ecma_process_promise_resolve_thenable_job */
示例3: ecma_builtin_object_prototype_object_to_locale_string
/**
* The Object.prototype object's 'toLocaleString' routine
*
* See also:
* ECMA-262 v5, 15.2.4.3
*
* @return completion value
* Returned value must be freed with ecma_free_completion_value.
*/
static ecma_completion_value_t
ecma_builtin_object_prototype_object_to_locale_string (ecma_value_t this_arg) /**< this argument */
{
ecma_completion_value_t return_value = ecma_make_empty_completion_value ();
/* 1. */
ECMA_TRY_CATCH (obj_val,
ecma_op_to_object (this_arg),
return_value);
ecma_object_t *obj_p = ecma_get_object_from_value (obj_val);
ecma_string_t *to_string_magic_string_p = ecma_get_magic_string (LIT_MAGIC_STRING_TO_STRING_UL);
/* 2. */
ECMA_TRY_CATCH (to_string_val,
ecma_op_object_get (obj_p, to_string_magic_string_p),
return_value);
/* 3. */
if (!ecma_op_is_callable (to_string_val))
{
return_value = ecma_make_throw_obj_completion_value (ecma_new_standard_error (ECMA_ERROR_TYPE));
}
else
{
/* 4. */
ecma_object_t *to_string_func_obj_p = ecma_get_object_from_value (to_string_val);
return_value = ecma_op_function_call (to_string_func_obj_p, this_arg, NULL);
}
ECMA_FINALIZE (to_string_val);
ecma_deref_ecma_string (to_string_magic_string_p);
ECMA_FINALIZE (obj_val);
return return_value;
} /* ecma_builtin_object_prototype_object_to_locale_string */
示例4: ecma_builtin_object_prototype_object_to_locale_string
/**
* The Object.prototype object's 'toLocaleString' routine
*
* See also:
* ECMA-262 v5, 15.2.4.3
*
* @return ecma value
* Returned value must be freed with ecma_free_value.
*/
static ecma_value_t
ecma_builtin_object_prototype_object_to_locale_string (ecma_value_t this_arg) /**< this argument */
{
ecma_value_t return_value = ecma_make_simple_value (ECMA_SIMPLE_VALUE_EMPTY);
/* 1. */
ECMA_TRY_CATCH (obj_val,
ecma_op_to_object (this_arg),
return_value);
ecma_object_t *obj_p = ecma_get_object_from_value (obj_val);
ecma_string_t *to_string_magic_string_p = ecma_get_magic_string (LIT_MAGIC_STRING_TO_STRING_UL);
/* 2. */
ECMA_TRY_CATCH (to_string_val,
ecma_op_object_get (obj_p, to_string_magic_string_p),
return_value);
/* 3. */
if (!ecma_op_is_callable (to_string_val))
{
return_value = ecma_raise_type_error (ECMA_ERR_MSG (""));
}
else
{
/* 4. */
ecma_object_t *to_string_func_obj_p = ecma_get_object_from_value (to_string_val);
return_value = ecma_op_function_call (to_string_func_obj_p, this_arg, NULL, 0);
}
ECMA_FINALIZE (to_string_val);
ecma_deref_ecma_string (to_string_magic_string_p);
ECMA_FINALIZE (obj_val);
return return_value;
} /* ecma_builtin_object_prototype_object_to_locale_string */
示例5: ecma_has_object_value_in_collection
/**
* Check the object value existance in the collection.
*
* Used by:
* - ecma_builtin_json_object step 1
* - ecma_builtin_json_array step 1
*
* @return true, if the object is already in the collection.
*/
bool
ecma_has_object_value_in_collection (ecma_collection_header_t *collection_p, /**< collection */
ecma_value_t object_value) /**< object value */
{
JERRY_ASSERT (ecma_is_value_object (object_value));
ecma_object_t *obj_p = ecma_get_object_from_value (object_value);
ecma_collection_iterator_t iterator;
ecma_collection_iterator_init (&iterator, collection_p);
while (ecma_collection_iterator_next (&iterator))
{
ecma_value_t value = *iterator.current_value_p;
ecma_object_t *current_p = ecma_get_object_from_value (value);
if (current_p == obj_p)
{
return true;
}
}
return false;
} /* ecma_has_object_value_in_collection */
示例6: ecma_builtin_object_prototype_object_is_prototype_of
/**
* The Object.prototype object's 'isPrototypeOf' routine
*
* See also:
* ECMA-262 v5, 15.2.4.6
*
* @return completion value
* Returned value must be freed with ecma_free_completion_value.
*/
static ecma_completion_value_t
ecma_builtin_object_prototype_object_is_prototype_of (ecma_value_t this_arg, /**< this argument */
ecma_value_t arg) /**< routine's first argument */
{
/* 1. Is the argument an object? */
if (!ecma_is_value_object (arg))
{
return ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_FALSE);
}
ecma_completion_value_t return_value = ecma_make_empty_completion_value ();
/* 2. ToObject(this) */
ECMA_TRY_CATCH (obj_value,
ecma_op_to_object (this_arg),
return_value);
ecma_object_t *obj_p = ecma_get_object_from_value (obj_value);
/* 3. Compare prototype to object */
ECMA_TRY_CATCH (v_obj_value,
ecma_op_to_object (arg),
return_value);
ecma_object_t *v_obj_p = ecma_get_object_from_value (v_obj_value);
bool is_prototype_of = ecma_op_object_is_prototype_of (obj_p, v_obj_p);
return_value = ecma_make_simple_completion_value (is_prototype_of
? ECMA_SIMPLE_VALUE_TRUE
: ECMA_SIMPLE_VALUE_FALSE);
ECMA_FINALIZE (v_obj_value);
ECMA_FINALIZE (obj_value);
return return_value;
} /* ecma_builtin_object_prototype_object_is_prototype_of */
示例7: ecma_builtin_object_object_create
/**
* The Object object's 'create' routine
*
* See also:
* ECMA-262 v5, 15.2.3.5
*
* @return completion value
* Returned value must be freed with ecma_free_completion_value.
*/
static ecma_completion_value_t
ecma_builtin_object_object_create (ecma_value_t this_arg, /**< 'this' argument */
ecma_value_t arg1, /**< routine's first argument */
ecma_value_t arg2) /**< routine's second argument */
{
ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
// 1.
if (!ecma_is_value_object (arg1) && !ecma_is_value_null (arg1))
{
ret_value = ecma_make_throw_obj_completion_value (ecma_new_standard_error (ECMA_ERROR_TYPE));
}
else
{
ecma_object_t *obj_p = NULL;
if (!ecma_is_value_null (arg1))
{
obj_p = ecma_get_object_from_value (arg1);
}
// 2-3.
ecma_object_t *result_obj_p = ecma_op_create_object_object_noarg_and_set_prototype (obj_p);
// 4.
if (!ecma_is_value_undefined (arg2))
{
ECMA_TRY_CATCH (obj,
ecma_builtin_object_object_define_properties (this_arg,
ecma_make_object_value (result_obj_p),
arg2),
ret_value);
ECMA_FINALIZE (obj);
}
// 5.
if (ecma_is_completion_value_empty (ret_value))
{
ret_value = ecma_make_normal_completion_value (ecma_copy_value (ecma_make_object_value (result_obj_p),
true));
}
ecma_deref_object (result_obj_p);
}
return ret_value;
} /* ecma_builtin_object_object_create */
示例8: ecma_builtin_object_object_get_own_property_descriptor
/**
* The Object object's 'getOwnPropertyDescriptor' routine
*
* See also:
* ECMA-262 v5, 15.2.3.3
*
* @return completion value
* Returned value must be freed with ecma_free_completion_value.
*/
static ecma_completion_value_t
ecma_builtin_object_object_get_own_property_descriptor (ecma_value_t this_arg __attr_unused___, /**< 'this' argument */
ecma_value_t arg1, /**< routine's first argument */
ecma_value_t arg2) /**< routine's second argument */
{
ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
// 1.
if (!ecma_is_value_object (arg1))
{
ret_value = ecma_make_throw_obj_completion_value (ecma_new_standard_error (ECMA_ERROR_TYPE));
return ret_value;
}
ecma_object_t *obj_p = ecma_get_object_from_value (arg1);
// 2.
ECMA_TRY_CATCH (name_str_value,
ecma_op_to_string (arg2),
ret_value);
ecma_string_t *name_str_p = ecma_get_string_from_value (name_str_value);
// 3.
ecma_property_t *prop_p = ecma_op_object_get_own_property (obj_p, name_str_p);
if (prop_p != NULL)
{
ecma_property_descriptor_t prop_desc = ecma_get_property_descriptor_from_property (prop_p);
// 4.
ecma_object_t* desc_obj_p = ecma_op_from_property_descriptor (&prop_desc);
ecma_free_property_descriptor (&prop_desc);
ret_value = ecma_make_normal_completion_value (ecma_make_object_value (desc_obj_p));
}
else
{
ret_value = ecma_make_simple_completion_value (ECMA_SIMPLE_VALUE_UNDEFINED);
}
ECMA_FINALIZE (name_str_value);
return ret_value;
} /* ecma_builtin_object_object_get_own_property_descriptor */
示例9: ecma_op_is_callable
/**
* IsCallable operation.
*
* See also: ECMA-262 v5, 9.11
*
* @return true, if value is callable object;
* false - otherwise.
*/
bool
ecma_op_is_callable (ecma_value_t value) /**< ecma value */
{
if (!ecma_is_value_object (value))
{
return false;
}
ecma_object_t *obj_p = ecma_get_object_from_value (value);
JERRY_ASSERT (obj_p != NULL);
JERRY_ASSERT (!ecma_is_lexical_environment (obj_p));
return (ecma_get_object_type (obj_p) == ECMA_OBJECT_TYPE_FUNCTION
|| ecma_get_object_type (obj_p) == ECMA_OBJECT_TYPE_EXTERNAL_FUNCTION
|| ecma_get_object_type (obj_p) == ECMA_OBJECT_TYPE_BOUND_FUNCTION);
} /* ecma_op_is_callable */
示例10: ecma_op_to_primitive
/**
* ToPrimitive operation.
*
* See also:
* ECMA-262 v5, 9.1
*
* @return ecma value
* Returned value must be freed with ecma_free_value
*/
ecma_value_t
ecma_op_to_primitive (ecma_value_t value, /**< ecma value */
ecma_preferred_type_hint_t preferred_type) /**< preferred type hint */
{
ecma_check_value_type_is_spec_defined (value);
if (ecma_is_value_object (value))
{
ecma_object_t *obj_p = ecma_get_object_from_value (value);
return ecma_op_object_default_value (obj_p, preferred_type);
}
else
{
return ecma_copy_value (value);
}
} /* ecma_op_to_primitive */
示例11: ecma_builtin_object_object_define_property
/**
* The Object object's 'defineProperty' routine
*
* See also:
* ECMA-262 v5, 15.2.3.6
*
* @return completion value
* Returned value must be freed with ecma_free_completion_value.
*/
static ecma_completion_value_t
ecma_builtin_object_object_define_property (ecma_value_t this_arg __attr_unused___, /**< 'this' argument */
ecma_value_t arg1, /**< routine's first argument */
ecma_value_t arg2, /**< routine's second argument */
ecma_value_t arg3) /**< routine's third argument */
{
ecma_completion_value_t ret_value = ecma_make_empty_completion_value ();
if (!ecma_is_value_object (arg1))
{
ret_value = ecma_make_throw_obj_completion_value (ecma_new_standard_error (ECMA_ERROR_TYPE));
}
else
{
ecma_object_t *obj_p = ecma_get_object_from_value (arg1);
ECMA_TRY_CATCH (name_str_value,
ecma_op_to_string (arg2),
ret_value);
ecma_string_t *name_str_p = ecma_get_string_from_value (name_str_value);
ecma_property_descriptor_t prop_desc;
ECMA_TRY_CATCH (conv_result,
ecma_op_to_property_descriptor (arg3, &prop_desc),
ret_value);
ECMA_TRY_CATCH (define_own_prop_ret,
ecma_op_object_define_own_property (obj_p,
name_str_p,
&prop_desc,
true),
ret_value);
ret_value = ecma_make_normal_completion_value (ecma_copy_value (arg1, true));
ECMA_FINALIZE (define_own_prop_ret);
ecma_free_property_descriptor (&prop_desc);
ECMA_FINALIZE (conv_result);
ECMA_FINALIZE (name_str_value);
}
return ret_value;
} /* ecma_builtin_object_object_define_property */
示例12: vm_op_delete_prop
/**
* Deletes an object property.
*
* @return ecma value
* Returned value must be freed with ecma_free_value
*/
ecma_value_t
vm_op_delete_prop (ecma_value_t object, /**< base object */
ecma_value_t property, /**< property name */
bool is_strict) /**< strict mode */
{
ecma_value_t completion_value = ecma_make_simple_value (ECMA_SIMPLE_VALUE_EMPTY);
if (ecma_is_value_undefined (object))
{
completion_value = ecma_make_simple_value (ECMA_SIMPLE_VALUE_TRUE);
}
else
{
completion_value = ecma_make_simple_value (ECMA_SIMPLE_VALUE_EMPTY);
ECMA_TRY_CATCH (check_coercible_ret,
ecma_op_check_object_coercible (object),
completion_value);
ECMA_TRY_CATCH (str_name_value,
ecma_op_to_string (property),
completion_value);
JERRY_ASSERT (ecma_is_value_string (str_name_value));
ecma_string_t *name_string_p = ecma_get_string_from_value (str_name_value);
ECMA_TRY_CATCH (obj_value, ecma_op_to_object (object), completion_value);
JERRY_ASSERT (ecma_is_value_object (obj_value));
ecma_object_t *obj_p = ecma_get_object_from_value (obj_value);
JERRY_ASSERT (!ecma_is_lexical_environment (obj_p));
ECMA_TRY_CATCH (delete_op_ret_val,
ecma_op_object_delete (obj_p, name_string_p, is_strict),
completion_value);
completion_value = delete_op_ret_val;
ECMA_FINALIZE (delete_op_ret_val);
ECMA_FINALIZE (obj_value);
ECMA_FINALIZE (str_name_value);
ECMA_FINALIZE (check_coercible_ret);
}
return completion_value;
} /* vm_op_delete_prop */
示例13: ecma_create_promise_resolve_thenable_job
/**
* Create a PromiseResolveThenableJob
*
* @return pointer to the PromiseResolveThenableJob
*/
static ecma_job_promise_resolve_thenable_t *
ecma_create_promise_resolve_thenable_job (ecma_value_t promise, /**< promise to be resolved */
ecma_value_t thenable, /**< thenable object */
ecma_value_t then) /**< 'then' function */
{
JERRY_ASSERT (ecma_is_promise (ecma_get_object_from_value (promise)));
JERRY_ASSERT (ecma_is_value_object (thenable));
JERRY_ASSERT (ecma_op_is_callable (then));
ecma_job_promise_resolve_thenable_t *job_p;
job_p = (ecma_job_promise_resolve_thenable_t *) jmem_heap_alloc_block (sizeof (ecma_job_promise_resolve_thenable_t));
job_p->promise = ecma_copy_value (promise);
job_p->thenable = ecma_copy_value (thenable);
job_p->then = ecma_copy_value (then);
return job_p;
} /* ecma_create_promise_resolve_thenable_job */
示例14: ecma_builtin_date_prototype_get_time
/**
* The Date.prototype object's 'getTime' routine
*
* See also:
* ECMA-262 v5, 15.9.5.9
*
* @return ecma value
* Returned value must be freed with ecma_free_value.
*/
static ecma_value_t
ecma_builtin_date_prototype_get_time (ecma_value_t this_arg) /**< this argument */
{
if (ecma_is_value_object (this_arg))
{
ecma_object_t *obj_p = ecma_get_object_from_value (this_arg);
if (ecma_object_get_class_name (obj_p) == LIT_MAGIC_STRING_DATE_UL)
{
ecma_value_t *date_prop_p = ecma_get_internal_property (obj_p,
ECMA_INTERNAL_PROPERTY_DATE_FLOAT);
ecma_number_t *date_num_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_number_t, *date_prop_p);
return ecma_make_number_value (*date_num_p);
}
}
return ecma_raise_type_error (ECMA_ERR_MSG (""));
} /* ecma_builtin_date_prototype_get_time */
示例15: ecma_builtin_object_prototype_object_property_is_enumerable
/**
* The Object.prototype object's 'propertyIsEnumerable' routine
*
* See also:
* ECMA-262 v5, 15.2.4.7
*
* @return ecma value
* Returned value must be freed with ecma_free_value.
*/
static ecma_value_t
ecma_builtin_object_prototype_object_property_is_enumerable (ecma_value_t this_arg, /**< this argument */
ecma_value_t arg) /**< routine's first argument */
{
ecma_value_t return_value = ecma_make_simple_value (ECMA_SIMPLE_VALUE_EMPTY);
/* 1. */
ECMA_TRY_CATCH (to_string_val,
ecma_op_to_string (arg),
return_value);
/* 2. */
ECMA_TRY_CATCH (obj_val,
ecma_op_to_object (this_arg),
return_value);
ecma_string_t *property_name_string_p = ecma_get_string_from_value (to_string_val);
ecma_object_t *obj_p = ecma_get_object_from_value (obj_val);
/* 3. */
ecma_property_t property = ecma_op_object_get_own_property (obj_p,
property_name_string_p,
NULL,
ECMA_PROPERTY_GET_NO_OPTIONS);
/* 4. */
if (property != ECMA_PROPERTY_TYPE_NOT_FOUND)
{
bool is_enumerable = ecma_is_property_enumerable (property);
return_value = ecma_make_boolean_value (is_enumerable);
}
else
{
return_value = ecma_make_simple_value (ECMA_SIMPLE_VALUE_FALSE);
}
ECMA_FINALIZE (obj_val);
ECMA_FINALIZE (to_string_val);
return return_value;
} /* ecma_builtin_object_prototype_object_property_is_enumerable */