2 * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #ifndef WRT_PLUGINS_TIZEN_1_0_JS_TIMEDURATION_H_
20 #define WRT_PLUGINS_TIZEN_1_0_JS_TIMEDURATION_H_
22 #include <dpl/shared_ptr.h>
23 #include <JavaScriptCore/JavaScript.h>
24 #include <CommonsJavaScript/PrivateObject.h>
25 #include <API/TimeUtil/DurationProperties.h>
29 typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT<
30 TizenApis::Api::TimeUtil::DurationPropertiesPtr>::
31 Type TimeDurationPrivObject;
34 * @class JSTimeDuration
35 * @brief This class is javascript extension
42 * Gets object's class description.
44 static const JSClassDefinition* getClassInfo();
47 * Gets class definition reference.
48 * @remarks New instance of JSClassRef is created (only once) if none was
49 * @remarks set before.
50 * @return Class reference.
52 static const JSClassRef getClassRef();
53 static JSObjectRef createJSObject(JSContextRef context, const Api::TimeUtil::DurationProperties &durations);
62 * The callback invoked when an object is first created.
64 static void initialize(JSContextRef context,
68 * The callback invoked when an object is finalized.
70 static void finalize(JSObjectRef object);
73 * Getters for properties
75 static JSValueRef getProperty(JSContextRef context, JSObjectRef object,
76 JSStringRef propertyName, JSValueRef* exception);
78 static bool setProperty(JSContextRef context, JSObjectRef object,
79 JSStringRef propertyName, JSValueRef value, JSValueRef* exception);
81 static JSObjectRef constructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
84 * The callback invoked when an object is used as the target of an 'instanceof' expression.
86 static bool hasInstance(JSContextRef context,
87 JSObjectRef constructor,
88 JSValueRef possibleInstance,
89 JSValueRef* exception);
91 static JSValueRef diffTimeDuration(JSContextRef context, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception, CompareType type);
92 static JSValueRef difference(JSContextRef context, JSObjectRef function,
93 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
94 static JSValueRef equalsTo(JSContextRef context, JSObjectRef function,
95 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
96 static JSValueRef lessThan(JSContextRef context, JSObjectRef function,
97 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
98 static JSValueRef greaterThan(JSContextRef context, JSObjectRef function,
99 JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
102 * This structure contains properties and callbacks that define a type of object.
104 static JSClassDefinition m_classInfo;
106 static JSClassRef m_jsClassRef;
109 * This structure describes a statically declared function property.
111 static JSStaticFunction m_function[];
114 * This member variable contains the initialization values for the
115 * properties of this class. The values are given according to the
116 * data structure JSPropertySpec.
118 static JSStaticValue m_property[];
123 #endif //WRT_PLUGINS_TIZEN_1_0_JS_TIMEDURATION_H_