Update change log and spec for wrt-plugins-tizen_0.4.21
[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
56     static JSObjectRef constructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
57   private:
58         enum CompareType {
59                 DIFFERENCE,
60                 EQUALSTO,
61                 LESSTHAN,
62                 GREATERTHAN
63                 };
64     /**
65      * The callback invoked when an object is first created.
66      */
67     static void initialize(JSContextRef context,
68             JSObjectRef object);
69
70     /**
71      * The callback invoked when an object is finalized.
72      */
73     static void finalize(JSObjectRef object);
74
75     /**
76      * Getters for properties
77      */
78     static JSValueRef getProperty(JSContextRef context, JSObjectRef object,
79             JSStringRef propertyName, JSValueRef* exception);
80
81     static bool setProperty(JSContextRef context, JSObjectRef object,
82             JSStringRef propertyName,  JSValueRef value,  JSValueRef* exception);
83
84     static JSValueRef diffTimeDuration(JSContextRef context, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception, CompareType type);
85     static JSValueRef difference(JSContextRef context, JSObjectRef function, 
86         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
87     static JSValueRef equalsTo(JSContextRef context, JSObjectRef function, 
88         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
89     static JSValueRef lessThan(JSContextRef context, JSObjectRef function, 
90         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
91     static JSValueRef greaterThan(JSContextRef context, JSObjectRef function, 
92         JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
93
94     /**
95      * This structure contains properties and callbacks that define a type of object.
96      */
97     static JSClassDefinition m_classInfo;
98
99     static JSClassRef m_jsClassRef;
100
101     /**
102      * This structure describes a statically declared function property.
103      */
104     static JSStaticFunction m_function[];
105
106     /**
107      * This member variable contains the initialization values for the 
108      * properties of this class. The values are given according to the
109      * data structure JSPropertySpec.
110      */
111     static JSStaticValue m_property[];
112 };
113 }
114 }
115
116 #endif //WRT_PLUGINS_TIZEN_JS_TIMEDURATION_H_