Skip to content

Commit 6d1712d

Browse files
committed
Rework usages/naming of configuration macros [part 1]
There are quite a few configuration macros in the project. As discussed in the #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]
1 parent 4123f35 commit 6d1712d

File tree

210 files changed

+1867
-1628
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

210 files changed

+1867
-1628
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ matrix:
1515
install: pip install --user pylint==1.6.5
1616
script:
1717
- tools/run-tests.py --check-signed-off=travis --check-doxygen --check-vera --check-license --check-magic-strings --check-pylint
18-
- travis_wait 30 tools/run-tests.py --check-cppcheck
18+
- travis_wait 40 tools/run-tests.py --check-cppcheck
1919
addons:
2020
apt:
2121
packages: [doxygen, cppcheck, vera++]

jerry-core/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ endif()
229229

230230
# RegExp strict mode
231231
if(FEATURE_REGEXP_STRICT_MODE)
232-
set(DEFINES_JERRY ${DEFINES_JERRY} ENABLE_REGEXP_STRICT_MODE)
232+
set(DEFINES_JERRY ${DEFINES_JERRY} JERRY_REGEXP_STRICT_MODE=1)
233233
endif()
234234

235235
# RegExp recursion depth limit

jerry-core/api/jerry-snapshot.c

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,12 @@ snapshot_get_global_flags (bool has_regex, /**< regex literal is present */
4242

4343
uint32_t flags = 0;
4444

45-
#ifndef CONFIG_DISABLE_REGEXP_BUILTIN
45+
#if ENABLED (JERRY_BUILTIN_REGEXP)
4646
flags |= (has_regex ? JERRY_SNAPSHOT_HAS_REGEX_LITERAL : 0);
47-
#endif /* !CONFIG_DISABLE_REGEXP_BUILTIN */
48-
#ifndef CONFIG_DISABLE_ES2015_CLASS
47+
#endif /* ENABLED (JERRY_BUILTIN_REGEXP) */
48+
#if ENABLED (JERRY_ES2015_CLASS)
4949
flags |= (has_class ? JERRY_SNAPSHOT_HAS_CLASS_LITERAL : 0);
50-
#endif /* !CONFIG_DISABLE_ES2015_CLASS */
50+
#endif /* ENABLED (JERRY_ES2015_CLASS) */
5151

5252
return flags;
5353
} /* snapshot_get_global_flags */
@@ -60,12 +60,12 @@ snapshot_get_global_flags (bool has_regex, /**< regex literal is present */
6060
static inline bool JERRY_ATTR_ALWAYS_INLINE
6161
snapshot_check_global_flags (uint32_t global_flags) /**< global flags */
6262
{
63-
#ifndef CONFIG_DISABLE_REGEXP_BUILTIN
63+
#if ENABLED (JERRY_BUILTIN_REGEXP)
6464
global_flags &= (uint32_t) ~JERRY_SNAPSHOT_HAS_REGEX_LITERAL;
65-
#endif /* !CONFIG_DISABLE_REGEXP_BUILTIN */
66-
#ifndef CONFIG_DISABLE_ES2015_CLASS
65+
#endif /* ENABLED (JERRY_BUILTIN_REGEXP) */
66+
#if ENABLED (JERRY_ES2015_CLASS)
6767
global_flags &= (uint32_t) ~JERRY_SNAPSHOT_HAS_CLASS_LITERAL;
68-
#endif /* !CONFIG_DISABLE_ES2015_CLASS */
68+
#endif /* ENABLED (JERRY_ES2015_CLASS) */
6969

7070
return global_flags == snapshot_get_global_flags (false, false);
7171
} /* snapshot_check_global_flags */
@@ -120,11 +120,11 @@ snapshot_write_to_buffer_by_offset (uint8_t *buffer_p, /**< buffer */
120120
/**
121121
* Maximum snapshot write buffer offset.
122122
*/
123-
#if CONFIG_ECMA_NUMBER_TYPE == CONFIG_ECMA_NUMBER_FLOAT32
123+
#if !ENABLED (JERRY_NUMBER_TYPE_FLOAT64)
124124
#define JERRY_SNAPSHOT_MAXIMUM_WRITE_OFFSET (0x7fffff >> 1)
125-
#else
125+
#else /* ENABLED (JERRY_NUMBER_TYPE_FLOAT64) */
126126
#define JERRY_SNAPSHOT_MAXIMUM_WRITE_OFFSET (UINT32_MAX >> 1)
127-
#endif
127+
#endif /* !ENABLED (JERRY_NUMBER_TYPE_FLOAT64) */
128128

129129
/**
130130
* Save snapshot helper.
@@ -160,14 +160,14 @@ snapshot_add_compiled_code (ecma_compiled_code_t *compiled_code_p, /**< compiled
160160
uint8_t *copied_code_start_p = snapshot_buffer_p + globals_p->snapshot_buffer_write_offset;
161161
ecma_compiled_code_t *copied_code_p = (ecma_compiled_code_t *) copied_code_start_p;
162162

163-
#ifndef CONFIG_DISABLE_ES2015_CLASS
163+
#if ENABLED (JERRY_ES2015_CLASS)
164164
if (compiled_code_p->status_flags & CBC_CODE_FLAGS_CONSTRUCTOR)
165165
{
166166
globals_p->class_found = true;
167167
}
168-
#endif /* !CONFIG_DISABLE_ES2015_CLASS */
168+
#endif /* ENABLED (JERRY_ES2015_CLASS) */
169169

170-
#ifndef CONFIG_DISABLE_REGEXP_BUILTIN
170+
#if ENABLED (JERRY_BUILTIN_REGEXP)
171171
if (!(compiled_code_p->status_flags & CBC_CODE_FLAGS_FUNCTION))
172172
{
173173
/* Regular expression. */
@@ -219,7 +219,7 @@ snapshot_add_compiled_code (ecma_compiled_code_t *compiled_code_p, /**< compiled
219219

220220
return start_offset;
221221
}
222-
#endif /* !CONFIG_DISABLE_REGEXP_BUILTIN */
222+
#endif /* ENABLED (JERRY_BUILTIN_REGEXP) */
223223

224224
JERRY_ASSERT (compiled_code_p->status_flags & CBC_CODE_FLAGS_FUNCTION);
225225

@@ -548,7 +548,7 @@ snapshot_load_compiled_code (const uint8_t *base_addr_p, /**< base address of th
548548
ecma_compiled_code_t *bytecode_p = (ecma_compiled_code_t *) base_addr_p;
549549
uint32_t code_size = ((uint32_t) bytecode_p->size) << JMEM_ALIGNMENT_LOG;
550550

551-
#ifndef CONFIG_DISABLE_REGEXP_BUILTIN
551+
#if ENABLED (JERRY_BUILTIN_REGEXP)
552552
if (!(bytecode_p->status_flags & CBC_CODE_FLAGS_FUNCTION))
553553
{
554554
const re_compiled_code_t *re_bytecode_p = NULL;
@@ -567,7 +567,7 @@ snapshot_load_compiled_code (const uint8_t *base_addr_p, /**< base address of th
567567

568568
return (ecma_compiled_code_t *) re_bytecode_p;
569569
}
570-
#endif /* !CONFIG_DISABLE_REGEXP_BUILTIN */
570+
#endif /* ENABLED (JERRY_BUILTIN_REGEXP) */
571571

572572
JERRY_ASSERT (bytecode_p->status_flags & CBC_CODE_FLAGS_FUNCTION);
573573

0 commit comments

Comments
 (0)