Repository: jerryscript-project/jerryscript
File: jerry-core/ecma/base/ecma-globals.h (C/C++)

Code before:

/**
 * Default flag of length property.
 */
#if ENABLED (JERRY_ESNEXT)
#define ECMA_PROPERTY_FLAG_DEFAULT_LENGTH ECMA_PROPERTY_FLAG_CONFIGURABLE
#else /* !ENABLED (JERRY_ESNEXT) */
#define ECMA_PROPERTY_FLAG_DEFAULT_LENGTH ECMA_PROPERTY_FIXED
#endif /* ENABLED (JERRY_ESNEXT) */

/**
 * Shift for property name part.
 */
#define ECMA_PROPERTY_NAME_TYPE_SHIFT (ECMA_PROPERTY_FLAG_SHIFT + 4)

/**
 * Convert data property to accessor property.
 */
#define ECMA_CONVERT_DATA_PROPERTY_TO_ACCESSOR_PROPERTY(property_p) \
   *(property_p) = (uint8_t) (*(property_p) + (ECMA_PROPERTY_TYPE_NAMEDACCESSOR - ECMA_PROPERTY_TYPE_NAMEDDATA))

/**
 * Convert accessor property to data property.
 */
#define ECMA_CONVERT_ACCESSOR_PROPERTY_TO_DATA_PROPERTY(property_p) \
   *(property_p) = (uint8_t) (*(property_p) - (ECMA_PROPERTY_TYPE_NAMEDACCESSOR - ECMA_PROPERTY_TYPE_NAMEDDATA))

/**
 * Convert data property to internal property.
 */
#define ECMA_CONVERT_DATA_PROPERTY_TO_INTERNAL_PROPERTY(property_p) \
   *(property_p) = (uint8_t) (*(property_p) + (ECMA_PROPERTY_TYPE_INTERNAL - ECMA_PROPERTY_TYPE_NAMEDDATA))

/**
 * Convert internal property to data property.
 */
#define ECMA_CONVERT_INTERNAL_PROPERTY_TO_DATA_PROPERTY(property_p) \
   *(property_p) = (uint8_t) (*(property_p) - (ECMA_PROPERTY_TYPE_INTERNAL - ECMA_PROPERTY_TYPE_NAMEDDATA))

/**
 * Special property identifiers.
 */
typedef enum
{
  /* Note: when new special types are added
   * ECMA_PROPERTY_IS_PROPERTY_PAIR must be updated as well. */
  ECMA_SPECIAL_PROPERTY_HASHMAP, /**< hashmap property */
  ECMA_SPECIAL_PROPERTY_DELETED, /**< deleted property */

  ECMA_SPECIAL_PROPERTY__COUNT /**< Number of special property types */
} ecma_special_property_id_t;

Review comment (suggestion):
I think you can do both direction with a xor operator:
`*(property_p) ^= ECMA_PROPERTY_TYPE_NAMEDACCESSOR ^ ECMA_PROPERTY_TYPE_NAMEDDATA;`


Code after:

/**
 * Default flag of length property.
 */
#if ENABLED (JERRY_ESNEXT)
#define ECMA_PROPERTY_FLAG_DEFAULT_LENGTH ECMA_PROPERTY_FLAG_CONFIGURABLE
#else /* !ENABLED (JERRY_ESNEXT) */
#define ECMA_PROPERTY_FLAG_DEFAULT_LENGTH ECMA_PROPERTY_FIXED
#endif /* ENABLED (JERRY_ESNEXT) */

/**
 * Shift for property name part.
 */
#define ECMA_PROPERTY_NAME_TYPE_SHIFT (ECMA_PROPERTY_FLAG_SHIFT + 4)

/**
 * Convert data property to accessor property or accessor property to data property
 */
#define ECMA_CHANGE_PROPERTY_TYPE(property_p) \
  *(property_p) ^= ECMA_PROPERTY_TYPE_NAMEDACCESSOR ^ ECMA_PROPERTY_TYPE_NAMEDDATA;

/**
 * Convert data property to internal property.
 */
#define ECMA_CONVERT_DATA_PROPERTY_TO_INTERNAL_PROPERTY(property_p) \
   *(property_p) = (uint8_t) (*(property_p) + (ECMA_PROPERTY_TYPE_INTERNAL - ECMA_PROPERTY_TYPE_NAMEDDATA))

/**
 * Convert internal property to data property.
 */
#define ECMA_CONVERT_INTERNAL_PROPERTY_TO_DATA_PROPERTY(property_p) \
   *(property_p) = (uint8_t) (*(property_p) - (ECMA_PROPERTY_TYPE_INTERNAL - ECMA_PROPERTY_TYPE_NAMEDDATA))

/**
 * Special property identifiers.
 */
typedef enum
{
  /* Note: when new special types are added
   * ECMA_PROPERTY_IS_PROPERTY_PAIR must be updated as well. */
  ECMA_SPECIAL_PROPERTY_HASHMAP, /**< hashmap property */
  ECMA_SPECIAL_PROPERTY_DELETED, /**< deleted property */

  ECMA_SPECIAL_PROPERTY__COUNT /**< Number of special property types */
} ecma_special_property_id_t;

/**
 * Define special property type.
 */
#define ECMA_SPECIAL_PROPERTY_VALUE(type) \
  ((uint8_t) (ECMA_PROPERTY_TYPE_SPECIAL | ((type) << ECMA_PROPERTY_NAME_TYPE_SHIFT)))