Update Iot.js
[platform/upstream/iotjs.git] / src / iotjs_module.h
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 #ifndef IOTJS_MODULE_H
17 #define IOTJS_MODULE_H
18
19 #include "iotjs_binding.h"
20
21
22 typedef iotjs_jval_t (*register_func)();
23
24
25 #define CONCATENATE(x, ...) x##__VA_ARGS__
26
27 #define IF(c) CONCATENATE(IF_, c)
28 #define IF_1(expr) expr
29 #define IF_0(expr)
30
31 // Check if specific module is enabled
32 #define E(F, UPPER, Camel, lower) \
33   IF(ENABLE_MODULE_##UPPER)(F(UPPER, Camel, lower))
34
35 // List of builtin modules
36 #define MAP_MODULE_LIST(F)                       \
37   E(F, ADC, Adc, adc)                            \
38   E(F, BLEHCISOCKET, Blehcisocket, blehcisocket) \
39   E(F, BUFFER, Buffer, buffer)                   \
40   E(F, CONSOLE, Console, console)                \
41   E(F, CONSTANTS, Constants, constants)          \
42   E(F, DNS, Dns, dns)                            \
43   E(F, FS, Fs, fs)                               \
44   E(F, GPIO, Gpio, gpio)                         \
45   E(F, HTTPPARSER, Httpparser, httpparser)       \
46   E(F, I2C, I2c, i2c)                            \
47   E(F, PROCESS, Process, process)                \
48   E(F, PWM, Pwm, pwm)                            \
49   E(F, SPI, Spi, spi)                            \
50   E(F, STM32F4DIS, Stm32f4dis, stm32f4dis)       \
51   E(F, TESTDRIVER, Testdriver, testdriver)       \
52   E(F, TCP, Tcp, tcp)                            \
53   E(F, TIMER, Timer, timer)                      \
54   E(F, UART, Uart, uart)                         \
55   E(F, UDP, Udp, udp)
56
57 #define ENUMDEF_MODULE_LIST(upper, Camel, lower) MODULE_##upper,
58
59 typedef enum {
60   MAP_MODULE_LIST(ENUMDEF_MODULE_LIST) // enumerate modules
61   MODULE_COUNT,
62 } ModuleKind;
63
64 #undef ENUMDEF_MODULE_LIST
65
66
67 void iotjs_module_list_init();
68
69 void iotjs_module_list_cleanup();
70
71 const iotjs_jval_t* iotjs_module_initialize_if_necessary(ModuleKind kind);
72 const iotjs_jval_t* iotjs_module_get(ModuleKind kind);
73
74
75 #endif /* IOTJS_MODULE_H */