mirror of
https://github.com/jerryscript-project/jerryscript.git
synced 2025-12-15 16:29:21 +00:00
Currently, `lit-magic-strings.inc.h` is manually maintained. This has several drawbacks: - keeping the list of magic strings sorted first by length then alphabetically is error prone, - it is easy to leave unused magic strings in the list by accident (e.g., `LIT_MAGIC_STRING_JERRY_UL` is defined as a magic string but not used anywhere in the code) and, - it is very hard to add `CONFIG_DISABLE_*_BUILTIN` guards to the list, even though there are several magic strings, which are used in some of the configurations only (e.g, "setPrototypeOf" is used in ES2015 only). To ease the maintenance of magic strings, this commit moves the definition of magic strings to a config file (`lit-magic-strings.ini`), and adds `tools/gen-magic-strings.py` to generate the `.inc.h` file from this config file and from the use cases of the strings in the code. - The magic strings in the config file can appear in any order, the generator will ensure that they are correctly sorted. - The generator skips those definitions that are not used anywhere (and emits a warning to signal that such definitions can be removed). - The generator applies the same guards to the definitions in the `.inc.h` file as found in the code around the use of the strings to optimize for size. The commit also changes some builtin-related `.inc.h` files by adding guards that don't affect functionality but improve the results of the generator. To ensure that the invocation of the generator does not get forgotten, the commit also adds `tools/check-magic-strings.sh` and binds it into the testing infrastructure. JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
47 lines
1.5 KiB
C
47 lines
1.5 KiB
C
/* Copyright JS Foundation and other contributors, http://js.foundation
|
|
*
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
* you may not use this file except in compliance with the License.
|
|
* You may obtain a copy of the License at
|
|
*
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
*
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
* distributed under the License is distributed on an "AS IS" BASIS
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
* See the License for the specific language governing permissions and
|
|
* limitations under the License.
|
|
*/
|
|
|
|
/*
|
|
* ArrayBuffer built-in description
|
|
*/
|
|
|
|
#include "ecma-builtin-helpers-macro-defines.inc.h"
|
|
|
|
#ifndef CONFIG_DISABLE_ES2015_TYPEDARRAY_BUILTIN
|
|
|
|
/* Number properties:
|
|
* (property name, number value, writable, enumerable, configurable) */
|
|
|
|
NUMBER_VALUE (LIT_MAGIC_STRING_LENGTH,
|
|
1,
|
|
ECMA_PROPERTY_FIXED)
|
|
|
|
/* Object properties:
|
|
* (property name, object pointer getter) */
|
|
|
|
OBJECT_VALUE (LIT_MAGIC_STRING_PROTOTYPE,
|
|
ECMA_BUILTIN_ID_ARRAYBUFFER_PROTOTYPE,
|
|
ECMA_PROPERTY_FIXED)
|
|
|
|
/* Routine properties:
|
|
* (property name, C routine name, arguments number or NON_FIXED, value of the routine's length property) */
|
|
|
|
/* ES2015 24.1.3.1 */
|
|
ROUTINE (LIT_MAGIC_STRING_IS_VIEW_UL, ecma_builtin_arraybuffer_object_is_view, 1, 1)
|
|
|
|
#endif /* !CONFIG_DISABLE_ES2015_TYPEDARRAY_BUILTIN */
|
|
|
|
#include "ecma-builtin-helpers-macro-undefs.inc.h"
|