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.
20 #ifndef WRT_PLUGINS_TIZEN_JS_TIMEDURATION_H_
21 #define WRT_PLUGINS_TIZEN_JS_TIMEDURATION_H_
23 #include <dpl/shared_ptr.h>
24 #include <JavaScriptCore/JavaScript.h>
25 #include <CommonsJavaScript/PrivateObject.h>
26 #include "DurationProperties.h"
30 typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT<
31 DurationPropertiesPtr>::
32 Type TimeDurationPrivObject;
35 * @class JSTimeDuration
36 * @brief This class is javascript extension
43 * Gets object's class description.
45 static const JSClassDefinition* getClassInfo();
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.
53 static const JSClassRef getClassRef();
54 static JSObjectRef createJSObject(JSContextRef context, const DurationProperties &durations);
56 static JSObjectRef constructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
65 * The callback invoked when an object is first created.
67 static void initialize(JSContextRef context,
71 * The callback invoked when an object is finalized.
73 static void finalize(JSObjectRef object);
76 * Getters for properties
78 static JSValueRef getProperty(JSContextRef context, JSObjectRef object,
79 JSStringRef propertyName, JSValueRef* exception);
81 static bool setProperty(JSContextRef context, JSObjectRef object,
82 JSStringRef propertyName, JSValueRef value, JSValueRef* exception);
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);
95 * This structure contains properties and callbacks that define a type of object.
97 static JSClassDefinition m_classInfo;
99 static JSClassRef m_jsClassRef;
102 * This structure describes a statically declared function property.
104 static JSStaticFunction m_function[];
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.
111 static JSStaticValue m_property[];
116 #endif //WRT_PLUGINS_TIZEN_JS_TIMEDURATION_H_