[Release] wrt-plugins-common_0.3.101
[platform/framework/web/wrt-plugins-common.git] / src / standards / W3C / Widget / JSWidget.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  *
18  * @file       JSWidget.h
19  * @author     Grzegorz Krawczyk (g.krawczyk@samsung.com)
20  * @version    0.1
21  * @brief
22  */
23
24 #ifndef _WRT_PLUGIN_JS_WIDGET_H_
25 #define _WRT_PLUGIN_JS_WIDGET_H_
26
27 #include <JavaScriptCore/JavaScript.h>
28 #include <CommonsJavaScript/PrivateObject.h>
29 #include <wrt_plugin_export.h>
30
31 namespace WrtPlugins {
32 namespace W3C {
33 class JSWidget
34 {
35   public:
36     /**
37      * This method initializes this in the JS Engine.
38      */
39     static JSClassRef getClassRef();
40
41     /**
42      * Gets object's class description.
43      */
44     static const JSClassDefinition* getClassInfo();
45
46     static JSObjectRef callAsConstructor(JSContextRef context,
47                                          JSObjectRef constructor,
48                                          size_t argumentCount,
49                                          const JSValueRef arguments[],
50                                          JSValueRef* exception);
51
52   private:
53     /**
54      * The callback invoked when an object is first created.
55      */
56     static void initialize(JSContextRef context,
57                            JSObjectRef object);
58
59     /**
60      * The callback invoked when an object is finalized.
61      */
62     static void finalize(JSObjectRef object);
63
64     /**
65      * This structure describes a statically declared value property.
66      */
67     static JSStaticValue m_property[];
68
69     /**
70      * This structure contains properties and callbacks that define a type of
71      * object.
72      */
73     static JSClassDefinition m_classInfo;
74
75     static JSClassRef m_jsClassRef;
76
77     // getters for properties
78     static JSValueRef getAuthor(JSContextRef context,
79                                 JSObjectRef object,
80                                 JSStringRef propertyName,
81                                 JSValueRef* exception);
82     static JSValueRef getAuthorEmail(JSContextRef context,
83                                      JSObjectRef object,
84                                      JSStringRef propertyName,
85                                      JSValueRef* exception);
86     static JSValueRef getAuthorHref(JSContextRef context,
87                                     JSObjectRef object,
88                                     JSStringRef propertyName,
89                                     JSValueRef* exception);
90     static JSValueRef getDescription(JSContextRef context,
91                                      JSObjectRef object,
92                                      JSStringRef propertyName,
93                                      JSValueRef* exception);
94     static JSValueRef getId(JSContextRef context,
95                             JSObjectRef object,
96                             JSStringRef propertyName,
97                             JSValueRef* exception);
98     static JSValueRef getName(JSContextRef context,
99                               JSObjectRef object,
100                               JSStringRef propertyName,
101                               JSValueRef* exception);
102     static JSValueRef getShortName(JSContextRef context,
103                                    JSObjectRef object,
104                                    JSStringRef propertyName,
105                                    JSValueRef* exception);
106     static JSValueRef getVersion(JSContextRef context,
107                                  JSObjectRef object,
108                                  JSStringRef propertyName,
109                                  JSValueRef* exception);
110     static JSValueRef getHeight(JSContextRef context,
111                                 JSObjectRef object,
112                                 JSStringRef propertyName,
113                                 JSValueRef* exception);
114     static JSValueRef getWidth(JSContextRef context,
115                                JSObjectRef object,
116                                JSStringRef propertyName,
117                                JSValueRef* exception);
118
119     static bool hasProperty(JSContextRef context,
120                             JSObjectRef object,
121                             JSStringRef propertyName);
122
123     static JSValueRef getProperty(JSContextRef context,
124                                   JSObjectRef object,
125                                   JSStringRef propertyName,
126                                   JSValueRef* exception);
127
128     static bool setProperty(JSContextRef context,
129                             JSObjectRef object,
130                             JSStringRef propertyName,
131                             JSValueRef value,
132                             JSValueRef* exception);
133 };
134 }
135 }
136
137 #endif /* _WRT_PLUGIN_JS_WIDGET_INTERFACE_H_ */