upload tizen1.0 source
[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
30 namespace WrtPlugins {
31 namespace W3C {
32
33
34 class JSWidget
35 {
36   public:
37     /**
38      * This method initializes this in the JS Engine.
39      */
40     static const JSClassRef getClassRef();
41
42     /**
43      * Gets object's class description.
44      */
45     static const JSClassDefinition* getClassInfo();
46
47   private:
48     /**
49      * The callback invoked when an object is first created.
50      */
51     static void initialize(JSContextRef context,
52             JSObjectRef object);
53
54     /**
55      * The callback invoked when an object is finalized.
56      */
57     static void finalize(JSObjectRef object);
58
59     /**
60      * This structure describes a statically declared value property.
61      */
62     static JSStaticValue m_property[];
63
64     /**
65      * This structure contains properties and callbacks that define a type of object.
66      */
67     static JSClassDefinition m_classInfo;
68
69     static JSClassRef m_jsClassRef;
70
71     // getters for properties
72     static JSValueRef getAuthor(JSContextRef context,
73                                 JSObjectRef object,
74                                 JSStringRef propertyName,
75                                 JSValueRef* exception);
76     static JSValueRef getAuthorEmail(JSContextRef context,
77                                      JSObjectRef object,
78                                      JSStringRef propertyName,
79                                      JSValueRef* exception);
80     static JSValueRef getAuthorHref(JSContextRef context,
81                                     JSObjectRef object,
82                                     JSStringRef propertyName,
83                                     JSValueRef* exception);
84     static JSValueRef getDescription(JSContextRef context,
85                                      JSObjectRef object,
86                                      JSStringRef propertyName,
87                                      JSValueRef* exception);
88     static JSValueRef getId(JSContextRef context,
89                             JSObjectRef object,
90                             JSStringRef propertyName,
91                             JSValueRef* exception);
92     static JSValueRef getName(JSContextRef context,
93                               JSObjectRef object,
94                               JSStringRef propertyName,
95                               JSValueRef* exception);
96     static JSValueRef getShortName(JSContextRef context,
97                                    JSObjectRef object,
98                                    JSStringRef propertyName,
99                                    JSValueRef* exception);
100     static JSValueRef getVersion(JSContextRef context,
101                                  JSObjectRef object,
102                                  JSStringRef propertyName,
103                                  JSValueRef* exception);
104     static JSValueRef getHeight(JSContextRef context,
105                                 JSObjectRef object,
106                                 JSStringRef propertyName,
107                                 JSValueRef* exception);
108     static JSValueRef getWidth(JSContextRef context,
109                                JSObjectRef object,
110                                JSStringRef propertyName,
111                                JSValueRef* exception);
112
113     static bool hasProperty(JSContextRef context,
114                             JSObjectRef object,
115                             JSStringRef propertyName);
116
117     static JSValueRef getProperty(JSContextRef context,
118                                   JSObjectRef object,
119                                   JSStringRef propertyName,
120                                   JSValueRef* exception);
121
122     static bool setProperty(JSContextRef context,
123                             JSObjectRef object,
124                             JSStringRef propertyName,
125                             JSValueRef value,
126                             JSValueRef* exception);
127 };
128 }
129 }
130
131 #endif /* _WRT_PLUGIN_JS_WIDGET_INTERFACE_H_ */