1 /* Copyright 2015-present Samsung Electronics Co., Ltd. and other contributors
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
7 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 #ifndef IOTJS_MODULE_H
17 #define IOTJS_MODULE_H
19 #include "iotjs_binding.h"
22 typedef iotjs_jval_t (*register_func)();
25 #define CONCATENATE(x, ...) x##__VA_ARGS__
27 #define IF(c) CONCATENATE(IF_, c)
28 #define IF_1(expr) expr
31 // Check if specific module is enabled
32 #define E(F, UPPER, Camel, lower) \
33 IF(ENABLE_MODULE_##UPPER)(F(UPPER, Camel, lower))
35 // List of builtin modules
36 #define MAP_MODULE_LIST(F) \
38 E(F, BLEHCISOCKET, Blehcisocket, blehcisocket) \
39 E(F, BUFFER, Buffer, buffer) \
40 E(F, CONSOLE, Console, console) \
41 E(F, CONSTANTS, Constants, constants) \
44 E(F, GPIO, Gpio, gpio) \
45 E(F, HTTPPARSER, Httpparser, httpparser) \
47 E(F, PROCESS, Process, process) \
50 E(F, STM32F4DIS, Stm32f4dis, stm32f4dis) \
51 E(F, TESTDRIVER, Testdriver, testdriver) \
53 E(F, TIMER, Timer, timer) \
54 E(F, UART, Uart, uart) \
57 #define ENUMDEF_MODULE_LIST(upper, Camel, lower) MODULE_##upper,
60 MAP_MODULE_LIST(ENUMDEF_MODULE_LIST) // enumerate modules
64 #undef ENUMDEF_MODULE_LIST
67 void iotjs_module_list_init();
69 void iotjs_module_list_cleanup();
71 const iotjs_jval_t* iotjs_module_initialize_if_necessary(ModuleKind kind);
72 const iotjs_jval_t* iotjs_module_get(ModuleKind kind);
75 #endif /* IOTJS_MODULE_H */