1425bb815Sopenharmony_ci/* Copyright JS Foundation and other contributors, http://js.foundation
2425bb815Sopenharmony_ci *
3425bb815Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4425bb815Sopenharmony_ci * you may not use this file except in compliance with the License.
5425bb815Sopenharmony_ci * You may obtain a copy of the License at
6425bb815Sopenharmony_ci *
7425bb815Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8425bb815Sopenharmony_ci *
9425bb815Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10425bb815Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS
11425bb815Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12425bb815Sopenharmony_ci * See the License for the specific language governing permissions and
13425bb815Sopenharmony_ci * limitations under the License.
14425bb815Sopenharmony_ci */
15425bb815Sopenharmony_ci
16425bb815Sopenharmony_ci#ifndef LIT_MAGIC_STRINGS_H
17425bb815Sopenharmony_ci#define LIT_MAGIC_STRINGS_H
18425bb815Sopenharmony_ci
19425bb815Sopenharmony_ci#include "lit-globals.h"
20425bb815Sopenharmony_ci
21425bb815Sopenharmony_ci/**
22425bb815Sopenharmony_ci * Identifiers of ECMA and implementation-defined magic string constants
23425bb815Sopenharmony_ci */
24425bb815Sopenharmony_citypedef enum
25425bb815Sopenharmony_ci{
26425bb815Sopenharmony_ci/** @cond doxygen_suppress */
27425bb815Sopenharmony_ci#define LIT_MAGIC_STRING_FIRST_STRING_WITH_SIZE(size, id)
28425bb815Sopenharmony_ci#define LIT_MAGIC_STRING_DEF(id, ascii_zt_string) \
29425bb815Sopenharmony_ci     id,
30425bb815Sopenharmony_ci#include "lit-magic-strings.inc.h"
31425bb815Sopenharmony_ci#undef LIT_MAGIC_STRING_DEF
32425bb815Sopenharmony_ci#undef LIT_MAGIC_STRING_FIRST_STRING_WITH_SIZE
33425bb815Sopenharmony_ci/** @endcond */
34425bb815Sopenharmony_ci  LIT_NON_INTERNAL_MAGIC_STRING__COUNT, /**< number of non-internal magic strings */
35425bb815Sopenharmony_ci  LIT_INTERNAL_MAGIC_STRING_PROMISE = LIT_NON_INTERNAL_MAGIC_STRING__COUNT, /**<  [[Promise]] of promise
36425bb815Sopenharmony_ci                                                                             *    reject or resolve functions */
37425bb815Sopenharmony_ci  LIT_INTERNAL_MAGIC_STRING_ALREADY_RESOLVED, /**< [[AlreadyResolved]] of promise reject or resolve functions */
38425bb815Sopenharmony_ci  LIT_INTERNAL_MAGIC_STRING_RESOLVE_FUNCTION, /**< the resolve funtion of the promise object */
39425bb815Sopenharmony_ci  LIT_INTERNAL_MAGIC_STRING_REJECT_FUNCTION, /**< the reject function of the promise object */
40425bb815Sopenharmony_ci  LIT_INTERNAL_MAGIC_STRING_PROMISE_PROPERTY_PROMISE, /**< [[Promise]] property */
41425bb815Sopenharmony_ci  LIT_INTERNAL_MAGIC_STRING_PROMISE_PROPERTY_RESOLVE, /**< [[Resolve]] property */
42425bb815Sopenharmony_ci  LIT_INTERNAL_MAGIC_STRING_PROMISE_PROPERTY_REJECT, /**< [[Reject]] property */
43425bb815Sopenharmony_ci  LIT_INTERNAL_MAGIC_STRING_PROMISE_PROPERTY_CAPABILITY, /**< [[Capability]] property */
44425bb815Sopenharmony_ci  LIT_INTERNAL_MAGIC_STRING_PROMISE_PROPERTY_ALREADY_CALLED, /**< [[AlreadyCalled]] property */
45425bb815Sopenharmony_ci  LIT_INTERNAL_MAGIC_STRING_PROMISE_PROPERTY_INDEX, /**< [[Index]] property */
46425bb815Sopenharmony_ci  LIT_INTERNAL_MAGIC_STRING_PROMISE_PROPERTY_VALUE, /**< [[Values]] property */
47425bb815Sopenharmony_ci  LIT_INTERNAL_MAGIC_STRING_PROMISE_PROPERTY_REMAINING_ELEMENT, /**< [[RemainingElement]] property */
48425bb815Sopenharmony_ci  LIT_INTERNAL_MAGIC_STRING_ITERATOR_NEXT_INDEX, /**< [[%Iterator%NextIndex]] property */
49425bb815Sopenharmony_ci  LIT_INTERNAL_MAGIC_STRING_MAP_KEY, /**< Property key used when an object is a key in a map object */
50425bb815Sopenharmony_ci  LIT_INTERNAL_MAGIC_API_INTERNAL, /**< Property key used to add non-visible JS properties from the public API  */
51425bb815Sopenharmony_ci  LIT_INTERNAL_MAGIC_STRING_ARRAY_PROTOTYPE_VALUES, /**< %ArrayProto_values% intrinsic routine */
52425bb815Sopenharmony_ci  LIT_INTERNAL_MAGIC_THIS_BINDING_VALUE, /**< FunctionEnvironmentRecord [[ThisBindingValue]] internal slot */
53425bb815Sopenharmony_ci  /* List of well known symbols */
54425bb815Sopenharmony_ci  LIT_GLOBAL_SYMBOL_HAS_INSTANCE, /**< @@hasInstance well known symbol */
55425bb815Sopenharmony_ci  LIT_GLOBAL_SYMBOL_IS_CONCAT_SPREADABLE, /**< @@isConcatSpreadable well known symbol */
56425bb815Sopenharmony_ci  LIT_GLOBAL_SYMBOL_ITERATOR, /**< @@iterator well known symbol */
57425bb815Sopenharmony_ci  LIT_GLOBAL_SYMBOL_MATCH, /**< @@match well known symbol */
58425bb815Sopenharmony_ci  LIT_GLOBAL_SYMBOL_REPLACE, /**< @@replace well known symbol */
59425bb815Sopenharmony_ci  LIT_GLOBAL_SYMBOL_SEARCH, /**< @@search well known symbol */
60425bb815Sopenharmony_ci  LIT_GLOBAL_SYMBOL_SPECIES, /**< @@species well known symbol */
61425bb815Sopenharmony_ci  LIT_GLOBAL_SYMBOL_SPLIT, /**< @@split well known symbol */
62425bb815Sopenharmony_ci  LIT_GLOBAL_SYMBOL_TO_PRIMITIVE, /**< @@toPrimitive well known symbol */
63425bb815Sopenharmony_ci  LIT_GLOBAL_SYMBOL_TO_STRING_TAG, /**< @@toStringTag well known symbol */
64425bb815Sopenharmony_ci  LIT_GLOBAL_SYMBOL_UNSCOPABLES, /**< @@unscopables well known symbol */
65425bb815Sopenharmony_ci  LIT_GC_MARK_REQUIRED_MAGIC_STRING__COUNT,  /**< number of internal magic strings which will be used as
66425bb815Sopenharmony_ci                                              *   property names, and their values need to be marked during gc. */
67425bb815Sopenharmony_ci  LIT_INTERNAL_MAGIC_STRING_DELETED = LIT_GC_MARK_REQUIRED_MAGIC_STRING__COUNT, /**< special value for
68425bb815Sopenharmony_ci                                                                                 *   deleted properties */
69425bb815Sopenharmony_ci
70425bb815Sopenharmony_ci  LIT_INTERNAL_MAGIC_STRING_NATIVE_POINTER, /**< native pointer info associated with an object */
71425bb815Sopenharmony_ci  LIT_FIRST_INTERNAL_MAGIC_STRING = LIT_INTERNAL_MAGIC_STRING_NATIVE_POINTER,  /**< first index of internal
72425bb815Sopenharmony_ci                                                                                *   magic strings */
73425bb815Sopenharmony_ci  LIT_INTERNAL_MAGIC_STRING_WEAK_REFS, /**< Weak references to the current object */
74425bb815Sopenharmony_ci  LIT_INTERNAL_MAGIC_STRING_INTERNAL_OBJECT, /**< Internal object ID for internal properties */
75425bb815Sopenharmony_ci  LIT_MAGIC_STRING__COUNT /**< number of magic strings */
76425bb815Sopenharmony_ci} lit_magic_string_id_t;
77425bb815Sopenharmony_ci
78425bb815Sopenharmony_ci/**
79425bb815Sopenharmony_ci * Identifiers of implementation-defined external magic string constants
80425bb815Sopenharmony_ci */
81425bb815Sopenharmony_citypedef uint32_t lit_magic_string_ex_id_t;
82425bb815Sopenharmony_ci
83425bb815Sopenharmony_ciuint32_t lit_get_magic_string_ex_count (void);
84425bb815Sopenharmony_ci
85425bb815Sopenharmony_ciconst lit_utf8_byte_t *lit_get_magic_string_utf8 (uint32_t id);
86425bb815Sopenharmony_cilit_utf8_size_t lit_get_magic_string_size (uint32_t id);
87425bb815Sopenharmony_ci
88425bb815Sopenharmony_ciconst lit_utf8_byte_t *lit_get_magic_string_ex_utf8 (uint32_t id);
89425bb815Sopenharmony_cilit_utf8_size_t lit_get_magic_string_ex_size (uint32_t id);
90425bb815Sopenharmony_ci
91425bb815Sopenharmony_civoid lit_magic_strings_ex_set (const lit_utf8_byte_t * const *ex_str_items,
92425bb815Sopenharmony_ci                               uint32_t count,
93425bb815Sopenharmony_ci                               const lit_utf8_size_t *ex_str_sizes);
94425bb815Sopenharmony_ci
95425bb815Sopenharmony_cilit_magic_string_id_t lit_is_utf8_string_magic (const lit_utf8_byte_t *string_p, lit_utf8_size_t string_size);
96425bb815Sopenharmony_cilit_magic_string_id_t lit_is_utf8_string_pair_magic (const lit_utf8_byte_t *string1_p, lit_utf8_size_t string1_size,
97425bb815Sopenharmony_ci                                                     const lit_utf8_byte_t *string2_p, lit_utf8_size_t string2_size);
98425bb815Sopenharmony_ci
99425bb815Sopenharmony_cilit_magic_string_ex_id_t lit_is_ex_utf8_string_magic (const lit_utf8_byte_t *string_p, lit_utf8_size_t string_size);
100425bb815Sopenharmony_cilit_magic_string_ex_id_t lit_is_ex_utf8_string_pair_magic (const lit_utf8_byte_t *string1_p,
101425bb815Sopenharmony_ci                                                           lit_utf8_size_t string1_size,
102425bb815Sopenharmony_ci                                                           const lit_utf8_byte_t *string2_p,
103425bb815Sopenharmony_ci                                                           lit_utf8_size_t string2_size);
104425bb815Sopenharmony_ci
105425bb815Sopenharmony_cilit_utf8_byte_t *lit_copy_magic_string_to_buffer (lit_magic_string_id_t id, lit_utf8_byte_t *buffer_p,
106425bb815Sopenharmony_ci                                                  lit_utf8_size_t buffer_size);
107425bb815Sopenharmony_ci
108425bb815Sopenharmony_ci#endif /* !LIT_MAGIC_STRINGS_H */
109