Update change log and spec for wrt-plugins-tizen_0.4.36
[platform/framework/web/wrt-plugins-tizen.git] / src / TimeUtil / JSTimeDuration.h
1 //
2 // Tizen Web Device API
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18
19
20 #ifndef WRT_PLUGINS_TIZEN_JS_TIMEDURATION_H_
21 #define WRT_PLUGINS_TIZEN_JS_TIMEDURATION_H_
22
23 #include <dpl/shared_ptr.h>
24 #include <JavaScriptCore/JavaScript.h>
25 #include <CommonsJavaScript/PrivateObject.h>
26 #include "DurationProperties.h"
27
28 namespace DeviceAPI {
29 namespace Time {
30 typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT<
31              DurationPropertiesPtr>::
32     Type TimeDurationPrivObject;
33
34 /**
35  * @class JSTimeDuration
36  * @brief This class is javascript extension
37  *
38  */
39 class JSTimeDuration
40 {
41   public:
42     /**
43      * Gets object's class description.
44      */
45     static const JSClassDefinition* getClassInfo();
46
47     /**
48      * Gets class definition reference.
49      * @remarks New instance of JSClassRef is created (only once) if none was
50      * @remarks set before.
51      * @return Class reference.
52      */
53     static const JSClassRef getClassRef();
54     static JSObjectRef createJSObject(JSContextRef context, const DurationProperties &durations);
55     static JSObjectRef createJSObject(JSContextRef context, const DurationPropertiesPtr duration);
56
57     static JSObjectRef constructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
58   private:
59         enum CompareType {
60                 DIFFERENCE,
61                 EQUALSTO,
62                 LESSTHAN,
63                 GREATERTHAN
64                 };
65     /**
66      * The callback invoked when an object is first created.
67      */
68     static void initialize(JSContextRef context,
69             JSObjectRef object);
70
71     /**
72      * The callback invoked when an object is finalized.
73      */
74     static void finalize(JSObjectRef object);
75
76     /**
77      * Getters for properties
78      */
79     static JSValueRef getProperty(JSContextRef context, JSObjectRef object,
80             JSStringRef propertyName, JSValueRef* exception);
81
82     static bool setProperty(JSContextRef context, JSObjectRef object,
83             JSStringRef propertyName,  JSValueRef value,  JSValueRef* exception);
84
85     static JSValueRef diffTimeDuration(JSContextRef context, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception, CompareType type);
86     static JSValueRef difference(JSContextRef context, JSObjectRef function, 
87         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
88     static JSValueRef equalsTo(JSContextRef context, JSObjectRef function, 
89         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
90     static JSValueRef lessThan(JSContextRef context, JSObjectRef function, 
91         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
92     static JSValueRef greaterThan(JSContextRef context, JSObjectRef function, 
93         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
94
95     /**
96      * This structure contains properties and callbacks that define a type of object.
97      */
98     static JSClassDefinition m_classInfo;
99
100     static JSClassRef m_jsClassRef;
101
102     /**
103      * This structure describes a statically declared function property.
104      */
105     static JSStaticFunction m_function[];
106
107     /**
108      * This member variable contains the initialization values for the 
109      * properties of this class. The values are given according to the
110      * data structure JSPropertySpec.
111      */
112     static JSStaticValue m_property[];
113 };
114 }
115 }
116
117 #endif //WRT_PLUGINS_TIZEN_JS_TIMEDURATION_H_