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.
17 #ifndef TIZENAPIS_TIZEN_JS_APPLICATION_SERVICE_DATA_H_
18 #define TIZENAPIS_TIZEN_JS_APPLICATION_SERVICE_DATA_H_
20 #include <JavaScriptCore/JavaScript.h>
21 #include <dpl/shared_ptr.h>
22 #include <CommonsJavaScript/PrivateObject.h>
23 #include <Commons/IEvent.h>
24 #include <API/Application/ApplicationServiceData.h>
28 namespace Application {
30 typedef WrtDeviceApis::CommonsJavaScript::PrivateObject<Api::Application::ApplicationServiceDataPtr, WrtDeviceApis::CommonsJavaScript::NoOwnership> JSApplicationServiceDataPriv;
32 class JSApplicationServiceData {
35 * This initializes this JS class in the JS Engine.
37 static JSClassRef getClassRef();
39 static JSValueRef createJSObject(JSContextRef context,
40 const std::string &key,
41 const std::vector<std::string> &value);
43 static JSObjectRef constructor(JSContextRef ctx,
44 JSObjectRef constructor,
46 const JSValueRef arguments[],
47 JSValueRef* exception);
49 static bool isObjectOfClass(JSContextRef context, JSValueRef value);
51 static Api::Application::ApplicationServiceDataPtr
52 getApplicationServiceData(JSContextRef context, JSValueRef value);
56 * The callback invoked when an object is first created.
58 static void initialize(JSContextRef context, JSObjectRef object);
61 * The callback invoked when an object is finalized.
63 static void finalize(JSObjectRef object);
66 * This structure contains properties and callbacks that define a type of object.
68 static JSClassDefinition m_classInfo;
71 * This structure describes a statically declared function property.
73 static JSStaticFunction m_functions[];
76 * This member variable contains the initialization values for the static properties of this class.
77 * The values are given according to the data structure JSPropertySpec
79 static JSStaticValue m_property[];
81 static JSClassRef m_classRef;
83 static Api::Application::ApplicationServiceDataPtr getPrivData(JSObjectRef object);
85 static JSValueRef getDataKey(JSContextRef context,
87 JSStringRef propertyName,
88 JSValueRef* exception);
90 static bool setDataKey(JSContextRef context,
92 JSStringRef propertyName,
94 JSValueRef* exception);
96 static JSValueRef getDataValue(JSContextRef context,
98 JSStringRef propertyName,
99 JSValueRef* exception);
101 static bool setDataValue(JSContextRef context,
103 JSStringRef propertyName,
105 JSValueRef* exception);