2 // Tizen Web Device API
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
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
9 // http://www.apache.org/licenses/LICENSE-2.0
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.
18 #ifndef __TIZEN_JS_TIMEDURATION_H_
19 #define __TIZEN_JS_TIMEDURATION_H_
21 #include "TimeDuration.h"
22 #include <PlatformException.h>
26 #ifdef IMPL_BACKWARD_COMPATIBLE
27 #include <CommonsJavaScript/PrivateObject.h>
28 #include "DurationProperties.h"
29 #endif // IMPL_BACKWARD_COMPATIBLE
34 #ifdef IMPL_BACKWARD_COMPATIBLE
35 typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT<
36 DurationPropertiesPtr>::
37 Type TimeDurationPrivObject;
38 #endif // IMPL_BACKWARD_COMPATIBLE
41 * @class JSTimeDuration
42 * @brief This class is javascript extension
45 class JSTimeDuration {
48 * Gets object's class description.
50 static const JSClassDefinition* getClassInfo();
53 * Gets class definition reference.
54 * @remarks New instance of JSClassRef is created (only once) if none was
55 * @remarks set before.
56 * @return Class reference.
58 static const JSClassRef getClassRef();
60 static JSObjectRef constructor(JSContextRef context,
61 JSObjectRef constructor,
63 const JSValueRef arguments[],
64 JSValueRef* exception);
66 static TimeDurationPtr getPrivateObject(JSContextRef context, JSValueRef value);
68 static void setPrivateObject(JSObjectRef object, TimeDurationPtr native);
70 static JSObjectRef makeJSObject(JSContextRef context, TimeDurationPtr native);
72 #ifdef IMPL_BACKWARD_COMPATIBLE
73 static JSObjectRef createJSObject(JSContextRef context, const DurationProperties &durations);
74 static JSObjectRef createJSObject(JSContextRef context, const DurationPropertiesPtr duration);
75 #endif // IMPL_BACKWARD_COMPATIBLE
79 * This structure contains properties and callbacks that define a type of object.
81 static JSClassDefinition m_classInfo;
84 * This member variable contains the initialization values for the static properties
86 * The values are given according to the data structure JSPropertySpec
88 static JSStaticValue m_property[];
91 * This structure describes a statically declared function property.
93 static JSStaticFunction m_function[];
95 static JSClassRef m_jsClassRef;
98 * The callback invoked when an object is first created.
100 static void initialize(JSContextRef context, JSObjectRef object);
103 * The callback invoked when an object is finalized.
105 static void finalize(JSObjectRef object);
108 * Getters for properties
110 static JSValueRef getLength(JSContextRef context,
112 JSStringRef propertyName,
113 JSValueRef* exception);
115 static JSValueRef getUnit(JSContextRef context,
117 JSStringRef propertyName,
118 JSValueRef* exception);
120 static bool setLength(JSContextRef context,
122 JSStringRef propertyName,
124 JSValueRef* exception);
126 static bool setUnit(JSContextRef context,
128 JSStringRef propertyName,
130 JSValueRef* exception);
133 * Functions declaration for the JSTimeDuration interface.
135 static JSValueRef difference(JSContextRef context,
136 JSObjectRef function,
137 JSObjectRef thisObject,
138 size_t argumentCount,
139 const JSValueRef arguments[],
140 JSValueRef * exception);
142 static JSValueRef equalsTo(JSContextRef context,
143 JSObjectRef function,
144 JSObjectRef thisObject,
145 size_t argumentCount,
146 const JSValueRef arguments[],
147 JSValueRef * exception);
149 static JSValueRef lessThan(JSContextRef context,
150 JSObjectRef function,
151 JSObjectRef thisObject,
152 size_t argumentCount,
153 const JSValueRef arguments[],
154 JSValueRef * exception);
156 static JSValueRef greaterThan(JSContextRef context,
157 JSObjectRef function,
158 JSObjectRef thisObject,
159 size_t argumentCount,
160 const JSValueRef arguments[],
161 JSValueRef * exception);
167 #endif // __TIZEN_JS_TIMEDURATION_H_