Update wrt-plugins-common_0.3.53
[framework/web/wrt-plugins-common.git] / src / Commons / plugin_initializer_def.h
1 /*
2  * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
3  *
4  *    Licensed under the Apache License, Version 2.0 (the "License");
5  *    you may not use this file except in compliance with the License.
6  *    You may obtain a copy of the License at
7  *
8  *        http://www.apache.org/licenses/LICENSE-2.0
9  *
10  *    Unless required by applicable law or agreed to in writing, software
11  *    distributed under the License is distributed on an "AS IS" BASIS,
12  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  *    See the License for the specific language governing permissions and
14  *    limitations under the License.
15  */
16 /*
17  * @author      Karol Majewski (k.majewski@samsung.com)
18  * @version     0.1
19  * @brief       This is a file that you provides interface for wrt-engine while loading and using plugin
20  *              If you are a plugin developer you need to plugin_initializer.cpp in your module and provide implementation for macros below
21  */
22
23 #ifndef WRTDEVICEAPIS_COMMONS_PLUGIN_INITIALIZER_DEF_H_
24 #define WRTDEVICEAPIS_COMMONS_PLUGIN_INITIALIZER_DEF_H_
25
26 #include <wrt_plugin_export.h>
27
28 typedef java_script_context_t JavaScriptContext;
29
30 #define EXPORT_SYMBOL __attribute__((__visibility__("default")))
31
32 //DEFINES FOR GLOBAL OBJECTS AVAILABLE IN JAVASCRIPT
33 /**
34  * each object which declare this object as parent
35  * will ba available as global object in javascript
36  */
37 #define WRT_JS_EXTENSION_OBJECT_GLOBAL  "GLOBAL_OBJECT"
38
39 /**
40  * global object bondi
41  * */
42 #define WRT_JS_EXTENSION_OBJECT_BONDI "bondi"
43
44 /**
45  * global object Widget
46  * */
47 #define WRT_JS_EXTENSION_OBJECT_WIDGET "Widget"
48
49 /**
50  * global object deviceapis
51  * */
52 #define WRT_JS_EXTENSION_OBJECT_DEVICEAPIS "deviceapis"
53
54 /**
55  * global object tizen
56  * */
57 #define WRT_JS_EXTENSION_OBJECT_TIZEN "tizen"
58
59
60
61
62 //HAVE TO BE IMPLEMENTED IN EVERY PLUGIN
63 /*
64  *  You have to(!) call this macro in your plugin_initializer.cpp(!) file providing callback that will be called while loading each widget (for every loaded widget this function will be called)
65  *  Example:
66  *       plugin_initializer.cpp
67  *        void on_widget_start_callback(int widgetId, JSContextRef context, const engine_interface_t *interface)
68  *        {
69  *          //...
70  *        }
71  *        PLUGIN_ON_WIDGET_START(on_widget_start_callback)
72  */
73 #define PLUGIN_ON_WIDGET_START(CALLBACK_NAME) extern "C" const on_widget_start_proc PLUGIN_WIDGET_START_PROC EXPORT_SYMBOL = CALLBACK_NAME;
74
75 /*
76  *  You have to(!) call this macro in your plugin_initializer.cpp(!) file
77  *  providing callback that will be called while loading each widget
78  * (for every loaded widget this function will be called)
79  *  Example:
80  *       plugin_initializer.cpp
81  *        void on_widget_init_callback(feature_mapping_interface_t *mapping)
82  *        {
83  *          //...
84  *        }
85  *        PLUGIN_ON_WIDGET_INIT(on_widget_init_callback)
86  */
87 #define PLUGIN_ON_WIDGET_INIT(CALLBACK_NAME) extern "C" \
88 const on_widget_init_proc PLUGIN_WIDGET_INIT_PROC EXPORT_SYMBOL = CALLBACK_NAME;
89
90 /*
91  *  You have to(!) call this macro in your plugin_initializer.cpp(!) file providing callback that will be called while unloading each widget (for every unloaded widget this function will be called)
92  *  Example:
93  *        void on_widget_stop_callback(int widgetId)
94  *        {
95  *          //...
96  *        }
97  *        PLUGIN_ON_WIDGET_STOP(on_widget_stop_callback)
98  */
99 #define PLUGIN_ON_WIDGET_STOP(CALLBACK_NAME) extern "C" const on_widget_stop_proc PLUGIN_WIDGET_STOP_PROC EXPORT_SYMBOL = CALLBACK_NAME;
100
101 /*
102  *  You have to(!) call this macro in your plugin_initializer.cpp(!) file providing callback that will be called while unloading each page (for every loaded page, including nested page, this function will be called)
103  *  Example:
104  *        void on_frame_load_callback(java_script_context_t context)
105  *        {
106  *          //...
107  *        }
108  *        PLUGIN_ON_FRAME_LOAD(on_frame_load_callback)
109  */
110 #define PLUGIN_ON_FRAME_LOAD(CALLBACK_NAME) extern "C" const on_frame_load_proc PLUGIN_FRAME_LOAD_PROC EXPORT_SYMBOL = CALLBACK_NAME;
111
112 /*
113  *  You have to(!) call this macro in your plugin_initializer.cpp(!) file providing callback that will be called while ununloading each page (for every unloaded page, including nested page, this function will be called)
114  *  Example:
115  *        void on_frame_unload_callback(java_script_context_t context)
116  *        {
117  *          //...
118  *        }
119  *        PLUGIN_ON_FRAME_UNLOAD(on_frame_unload_callback)
120  */
121 #define PLUGIN_ON_FRAME_UNLOAD(CALLBACK_NAME) extern "C" const on_frame_unload_proc PLUGIN_FRAME_UNLOAD_PROC EXPORT_SYMBOL = CALLBACK_NAME;
122
123 /*
124  * You have to(!) define an array of structures in your plugin_initializer.cpp(!) file describing a JS class (class_definition) and it's parent class name (parent_name).
125  * JS class will be bind to a parent class name (parent_name.jsclass_name).
126  * Example:
127  *    plugin_initializer.cpp
128  *      PLUGIN_CLASS_MAP_BEGIN
129  *          PLUGIN_CLASS_MAP_ADD_CLASS("bondi",WrtPluginBondi::JSICameraManager::getClassInfo())
130  *          PLUGIN_CLASS_MAP_ADD_CLASS("bondi",WrtPluginBondi::JSICameraAnotherClass::getClassInfo())
131  *      PLUGIN_CLASS_MAP_END
132  *
133  */
134 #define PLUGIN_CLASS_MAP_BEGIN extern "C" const js_entity_definition_t\
135             PLUGIN_CLASS_MAP[] EXPORT_SYMBOL = {
136
137 #define PLUGIN_CLASS_MAP_ADD_INTERFACE(PARENTNAME,INTERFACENAME,\
138             JSPRODUCTCLASSTEMPLATE,PRODUCTCONSTRUCTORCB,PRIVDATA) \
139                 {PARENTNAME,INTERFACENAME,"",JSPRODUCTCLASSTEMPLATE,\
140                  PRODUCTCONSTRUCTORCB,PRIVDATA},
141
142 #define PLUGIN_CLASS_MAP_ADD_INTERFACE_PRODUCT(PARENTNAME,OBJECTNAME,\
143             INTERFACENAME,PRIVDATA)\
144                 {PARENTNAME,OBJECTNAME,INTERFACENAME,NULL,NULL,PRIVDATA},
145
146 #define PLUGIN_CLASS_MAP_ADD_CLASS(PARENTNAME,CLASSNAME,JSCLASSTEMPLATE,\
147             PRIVDATA)\
148                 {PARENTNAME,CLASSNAME,"",JSCLASSTEMPLATE,NULL,PRIVDATA},
149
150 #define PLUGIN_CLASS_MAP_END {NULL,NULL,NULL,NULL,NULL,NULL} };
151
152 #define PLUGIN_CLASS_MAP_BEGIN_STATIC static const js_entity_definition_t\
153                 PLUGIN_CLASS_MAP[] = {
154
155 #define PLUGIN_GET_CLASS_MAP(CALLBACK_NAME) extern "C" const\
156                 get_widget_entity_map_proc\
157                 PLUGIN_GET_CLASS_PROC_MAP EXPORT_SYMBOL = CALLBACK_NAME;
158
159 #endif // WRTDEVICEAPIS_COMMONS_PLUGIN_INITIALIZER_DEF_H_