Update Iot.js
[platform/upstream/iotjs.git] / tools / src / iotjs_string_ext.c
1 /* Copyright 2015-present Samsung Electronics Co., Ltd. and other contributors
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15
16
17 #include "iotjs_def.h"
18
19 //
20 // strings in iotjs built-in scripts
21 //
22 #include "iotjs_string_ext.inl.h"
23
24 //
25 // declare string items
26 //
27 #define MAGICSTR_EX_DEF(NAME, STRING) \
28   static const char jerry_magic_string_ex_##NAME[] = STRING;
29
30 JERRY_MAGIC_STRING_ITEMS
31
32 #undef MAGICSTR_EX_DEF
33
34
35 //
36 // declare strings length array
37 //
38 static const jerry_length_t magic_string_lengths[] = {
39 #define MAGICSTR_EX_DEF(NAME, STRING) \
40   (jerry_length_t)(sizeof(jerry_magic_string_ex_##NAME) - 1u),
41
42   JERRY_MAGIC_STRING_ITEMS
43
44 #undef MAGICSTR_EX_DEF
45 };
46
47
48 //
49 // declare strings table
50 //
51 static const jerry_char_ptr_t magic_string_items[] = {
52 #define MAGICSTR_EX_DEF(NAME, STRING) \
53   (const jerry_char_ptr_t) jerry_magic_string_ex_##NAME,
54
55   JERRY_MAGIC_STRING_ITEMS
56
57 #undef MAGICSTR_EX_DEF
58 };
59
60
61 void iotjs_register_jerry_magic_string(void) {
62   uint32_t num_magic_string_items =
63       (uint32_t)(sizeof(magic_string_items) / sizeof(jerry_char_ptr_t));
64   jerry_register_magic_strings(magic_string_items, num_magic_string_items,
65                                magic_string_lengths);
66 }