-
Notifications
You must be signed in to change notification settings - Fork 684
Rework usages/naming of configuration macros #2793
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
jerry-core/api/jerry-snapshot.c
Outdated
@@ -42,12 +42,12 @@ snapshot_get_global_flags (bool has_regex, /**< regex literal is present */ | |||
|
|||
uint32_t flags = 0; | |||
|
|||
#ifndef CONFIG_DISABLE_REGEXP_BUILTIN | |||
#if defined (JERRY_BUILTIN_REGEXP) && (JERRY_BUILTIN_REGEXP == 1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I see there is a sanity check macro guard for the incorrect configuration:
#if !defined (JERRY_BUILTIN_REGEXP) \
|| ((JERRY_BUILTIN_REGEXP != 0) && (JERRY_BUILTIN_REGEXP != 1))
# error "Invalid value for JERRY_BUILTIN_REGEXP macro."
#endif
Therefore wouldn't be much easier to use only the
#if JERRY_BUILTIN_REGEXP == 1
//code
#endif
guard all over the codebase? I think these double checks could make the code much harder to read especially if two or more guards are combined e.g..
Please rebase to the current master |
I agree with @rerobika, we should aim to make the code as readable as we can. Since each guard is checked to have well defined values, I would even go as far as to say that we should skip the comparison checks as well (in case of boolean guards). For example, instead of
we could simply write
What do you think? |
I think |
The |
f867fb2
to
6d1712d
Compare
@@ -107,4 +189,128 @@ | |||
*/ | |||
#define CONFIG_ECMA_GC_NEW_OBJECTS_SHARE_TO_START_GC (16) | |||
|
|||
|
|||
/** | |||
* Sanity check for macros to see if the values are 0 or 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are these sanity checks are generated somehow, or they should be written by hand? If the second, it would be good to add a note for add these checks whenever a new feature guard is introduced.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, as the feature guards are grouped by categories (es5.1, es2015, other), I think these checks should be separated as well for the easier maintenance. (Probably a comment is enough)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll add comments for these.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
14e8519
to
de49acd
Compare
There are quite a few configuration macros in the project. As discussed in the jerryscript-project#2520 issue there are a few awkward constructs. Main changes: * Renamed all CONFIG_DISABLE_<name>_BUILTIN macro to JERRY_BUILTIN_<name> format. * The special JERRY_BUILTINS macro specifies the basic config for all es5.1 builtins. * Renamed all CONFIG_DISABLE_ES2015_<name> to JERRY_ES2015_<name> format. * The special JERRY_ES2015 macro specifies the basic config for all es2015 builtins. * Renamed UNICODE_CASE_CONVERSION to JERRY_UNICODE_CASE_CONVERSION. * Renamed ENABLE_REGEXP_STRICT_MODE to JERRY_REGEXP_STRICT_MODE. * All options (in this change) can have a value of 0 or 1. * Renamed ENABLE_REGEXP_STRICT_MODE to JERRY_REGEXP_STRICT_MODE. JERRY_REGEXP_STRICT_MODE is set to 0 by default. * Reworked CONFIG_ECMA_NUMBER_TYPE macro to JERRY_NUMBER_TYPE_FLOAT64 name and now it uses the value 1 for 64 bit floating point numbers and 0 for 32 bit floating point number. By default the 64-bit floating point number mode is enabled. * All new JERRY_ defines can be used wit the `#if ENABLED (JERRY_...)` construct to test if the feature is enabled or not. * Added/replaced a few config.h includes to correctly propagate the macro values. * Added sanity checks for each macro to avoid incorrectly set values. * Updated profile documentation. * The CMake feature names are not updated at this point. JerryScript-DCO-1.0-Signed-off-by: Peter Gal [email protected]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There are quite a few configuration macros in the project.
As discussed in the #2520 issue there are a few awkward constructs.
Main changes:
CONFIG_DISABLE_<name>_BUILTIN
macro toJERRY_BUILTIN_<name>
format.JERRY_BUILTINS
macro specifies the basic config for all es5.1 builtins.CONFIG_DISABLE_ES2015_<name>
toJERRY_ES2015_<name>
format.JERRY_ES2015
macro specifies the basic config for all es2015 builtins.UNICODE_CASE_CONVERSION
toJERRY_UNICODE_CASE_CONVERSION
.ENABLE_REGEXP_STRICT_MODE
toJERRY_REGEXP_STRICT_MODE
.ENABLE_REGEXP_STRICT_MODE
toJERRY_REGEXP_STRICT_MODE
.JERRY_REGEXP_STRICT_MODE
is set to 0 by default.CONFIG_ECMA_NUMBER_TYPE
macro toJERRY_NUMBER_TYPE_FLOAT64
name and nowit uses the value 1 for 64 bit floating point numbers and 0 for 32 bit floating point
number.
By default the 64-bit floating point number mode is enabled.
JERRY_
defines can be used wit the#if ENABLED (JERRY_...)
construct totest if the feature is enabled or not.