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);
55 static JSObjectRef createJSObject(JSContextRef context, const DurationPropertiesPtr duration);
57 static JSObjectRef constructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
66 * The callback invoked when an object is first created.
68 static void initialize(JSContextRef context,
72 * The callback invoked when an object is finalized.
74 static void finalize(JSObjectRef object);
77 * Getters for properties
79 static JSValueRef getProperty(JSContextRef context, JSObjectRef object,
80 JSStringRef propertyName, JSValueRef* exception);
82 static bool setProperty(JSContextRef context, JSObjectRef object,
83 JSStringRef propertyName, JSValueRef value, JSValueRef* exception);
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);
96 * This structure contains properties and callbacks that define a type of object.
98 static JSClassDefinition m_classInfo;
100 static JSClassRef m_jsClassRef;
103 * This structure describes a statically declared function property.
105 static JSStaticFunction m_function[];
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.
112 static JSStaticValue m_property[];
117 #endif //WRT_PLUGINS_TIZEN_JS_TIMEDURATION_H_