summaryrefslogtreecommitdiff
path: root/wearable_src/TimeUtil/JSTimeDuration.h
diff options
context:
space:
mode:
Diffstat (limited to 'wearable_src/TimeUtil/JSTimeDuration.h')
-rwxr-xr-xwearable_src/TimeUtil/JSTimeDuration.h117
1 files changed, 117 insertions, 0 deletions
diff --git a/wearable_src/TimeUtil/JSTimeDuration.h b/wearable_src/TimeUtil/JSTimeDuration.h
new file mode 100755
index 0000000..6d2565c
--- /dev/null
+++ b/wearable_src/TimeUtil/JSTimeDuration.h
@@ -0,0 +1,117 @@
+//
+// Tizen Web Device API
+// Copyright (c) 2012 Samsung Electronics Co., Ltd.
+//
+// Licensed under the Apache License, Version 2.0 (the License);
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+
+
+
+#ifndef WRT_PLUGINS_TIZEN_JS_TIMEDURATION_H_
+#define WRT_PLUGINS_TIZEN_JS_TIMEDURATION_H_
+
+#include <dpl/shared_ptr.h>
+#include <JavaScriptCore/JavaScript.h>
+#include <CommonsJavaScript/PrivateObject.h>
+#include "DurationProperties.h"
+
+namespace DeviceAPI {
+namespace Time {
+typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT<
+ DurationPropertiesPtr>::
+ Type TimeDurationPrivObject;
+
+/**
+ * @class JSTimeDuration
+ * @brief This class is javascript extension
+ *
+ */
+class JSTimeDuration
+{
+ public:
+ /**
+ * Gets object's class description.
+ */
+ static const JSClassDefinition* getClassInfo();
+
+ /**
+ * Gets class definition reference.
+ * @remarks New instance of JSClassRef is created (only once) if none was
+ * @remarks set before.
+ * @return Class reference.
+ */
+ static const JSClassRef getClassRef();
+ static JSObjectRef createJSObject(JSContextRef context, const DurationProperties &durations);
+ static JSObjectRef createJSObject(JSContextRef context, const DurationPropertiesPtr duration);
+
+ static JSObjectRef constructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
+ private:
+ enum CompareType {
+ DIFFERENCE,
+ EQUALSTO,
+ LESSTHAN,
+ GREATERTHAN
+ };
+ /**
+ * The callback invoked when an object is first created.
+ */
+ static void initialize(JSContextRef context,
+ JSObjectRef object);
+
+ /**
+ * The callback invoked when an object is finalized.
+ */
+ static void finalize(JSObjectRef object);
+
+ /**
+ * Getters for properties
+ */
+ static JSValueRef getProperty(JSContextRef context, JSObjectRef object,
+ JSStringRef propertyName, JSValueRef* exception);
+
+ static bool setProperty(JSContextRef context, JSObjectRef object,
+ JSStringRef propertyName, JSValueRef value, JSValueRef* exception);
+
+ static JSValueRef diffTimeDuration(JSContextRef context, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception, CompareType type);
+ static JSValueRef difference(JSContextRef context, JSObjectRef function,
+ JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
+ static JSValueRef equalsTo(JSContextRef context, JSObjectRef function,
+ JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
+ static JSValueRef lessThan(JSContextRef context, JSObjectRef function,
+ JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
+ static JSValueRef greaterThan(JSContextRef context, JSObjectRef function,
+ JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef * exception);
+
+ /**
+ * This structure contains properties and callbacks that define a type of object.
+ */
+ static JSClassDefinition m_classInfo;
+
+ static JSClassRef m_jsClassRef;
+
+ /**
+ * This structure describes a statically declared function property.
+ */
+ static JSStaticFunction m_function[];
+
+ /**
+ * This member variable contains the initialization values for the
+ * properties of this class. The values are given according to the
+ * data structure JSPropertySpec.
+ */
+ static JSStaticValue m_property[];
+};
+}
+}
+
+#endif //WRT_PLUGINS_TIZEN_JS_TIMEDURATION_H_ \ No newline at end of file