Repository: jerryscript-project/jerryscript
File: jerry-core/api/jerry.c (C)

Code before:

    if (ecma_is_value_error_reference (setter))
    {
      prop_desc.value = ecma_raise_type_error (ECMA_ERR_MSG (wrong_args_msg_p));
      return prop_desc;
    }

    if (ecma_op_is_callable (setter))
    {
      prop_desc.setter = setter;
    }
    else if (!ecma_is_value_null (setter))
    {
      prop_desc.value = ecma_raise_type_error (ECMA_ERR_MSG (wrong_args_msg_p));
      return prop_desc;
    }
  }

  return prop_desc;
} /* ecma_property_descriptor_to_jerry */

/**
 * Convert a jerry_property_descriptor_t to a ecma_property_descriptor_t
 *
 * @return raised error - if the operation fail
 *         ecma_property_descriptor_t - if the operation is a success
 */
static ecma_property_descriptor_t
jerry_property_descriptor_to_ecma (const jerry_property_descriptor_t *prop_desc_p) /**< input property_descriptor */
{
  ecma_property_descriptor_t prop_desc = ecma_make_empty_property_descriptor ();

  uint32_t flags = ECMA_PROP_NO_OPTS;

  if (prop_desc_p->is_enumerable_defined)
  {
    flags |= (uint32_t) (ECMA_PROP_IS_ENUMERABLE_DEFINED | (prop_desc_p->is_enumerable ? ECMA_PROP_IS_ENUMERABLE
                                                                                       : ECMA_PROP_NO_OPTS));
  }

  if (prop_desc_p->is_configurable_defined)
  {
    flags |= (uint32_t) (ECMA_PROP_IS_CONFIGURABLE_DEFINED | (prop_desc_p->is_configurable ? ECMA_PROP_IS_CONFIGURABLE
                                                                                           : ECMA_PROP_NO_OPTS));
  }

  /* Copy data property info. */
  flags |= (prop_desc_p->is_value_defined ? ECMA_PROP_IS_VALUE_DEFINED : ECMA_PROP_NO_OPTS);

  if (prop_desc_p->is_value_defined)
  {

Review comment (suggestion):
Ditto, always return with ecma_property_descriptor_t,
just note if any conversion error occurs, the property descriptor's `value` field is filled with `ECMA_VALUE_ERROR`

Code after:

  if (prop_desc_p->is_enumerable_defined)
  {
    flags |= (uint32_t) (ECMA_PROP_IS_ENUMERABLE_DEFINED | (prop_desc_p->is_enumerable ? ECMA_PROP_IS_ENUMERABLE
                                                                                       : ECMA_PROP_NO_OPTS));
  }

  if (prop_desc_p->is_configurable_defined)
  {
    flags |= (uint32_t) (ECMA_PROP_IS_CONFIGURABLE_DEFINED | (prop_desc_p->is_configurable ? ECMA_PROP_IS_CONFIGURABLE
                                                                                           : ECMA_PROP_NO_OPTS));
  }

  /* Copy data property info. */
  flags |= (prop_desc_p->is_value_defined ? ECMA_PROP_IS_VALUE_DEFINED : ECMA_PROP_NO_OPTS);

  if (prop_desc_p->is_value_defined)
  {
    if (ecma_is_value_error_reference (prop_desc_p->value))
    {
      prop_desc.value = ecma_raise_type_error (ECMA_ERR_MSG (wrong_args_msg_p));
      return prop_desc;
    }

    prop_desc.value = prop_desc_p->value;
  }

  if (prop_desc_p->is_writable_defined)
  {
    flags |= (uint32_t) (ECMA_PROP_IS_WRITABLE_DEFINED | (prop_desc_p->is_writable ? ECMA_PROP_IS_WRITABLE
                                                                                   : ECMA_PROP_NO_OPTS));
  }

  /* Copy accessor property info. */
  if (prop_desc_p->is_get_defined)
  {
    ecma_value_t getter = prop_desc_p->getter;
    flags |= ECMA_PROP_IS_GET_DEFINED;

    if (ecma_is_value_error_reference (getter))
    {
      prop_desc.value = ecma_raise_type_error (ECMA_ERR_MSG (wrong_args_msg_p));
      return prop_desc;
    }

    if (ecma_op_is_callable (getter))
    {
      prop_desc.get_p = ecma_get_object_from_value (getter);
    }
    else if (!ecma_is_value_null (getter))
    {