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_CONTEXT_H_
18 #define TIZENAPIS_TIZEN_JS_APPLICATION_CONTEXT_H_
20 #include <JavaScriptCore/JavaScript.h>
21 #include <CommonsJavaScript/PrivateObject.h>
22 #include <dpl/shared_ptr.h>
23 #include <API/Application/ApplicationContext.h>
27 namespace Application {
29 typedef WrtDeviceApis::CommonsJavaScript::PrivateObject<Api::Application::ApplicationContextPtr, WrtDeviceApis::CommonsJavaScript::NoOwnership> JSApplicationContextPriv;
31 class JSApplicationContext {
34 * This initializes this JS class in the JS Engine.
36 static JSClassRef getClassRef();
38 static JSValueRef createJSObject(JSContextRef context,
39 const std::string &appId,
40 const std::string &contextId);
42 static bool isObjectOfClass(JSContextRef context, JSValueRef value);
44 static Api::Application::ApplicationContextPtr
45 getApplicationContext(JSContextRef context, JSValueRef value);
49 * The callback invoked when an object is first created.
51 static void initialize(JSContextRef context, JSObjectRef object);
54 * The callback invoked when an object is finalized.
56 static void finalize(JSObjectRef object);
59 * This structure contains properties and callbacks that define a type of object.
61 static JSClassDefinition m_classInfo;
64 * This structure describes a statically declared function property.
66 static JSStaticFunction m_functions[];
69 * This member variable contains the initialization values for the static properties of this class.
70 * The values are given according to the data structure JSPropertySpec
72 static JSStaticValue m_property[];
74 static JSClassRef m_classRef;
76 static Api::Application::ApplicationContextPtr getPrivData(JSObjectRef object);
78 static JSValueRef getAppId(JSContextRef context,
80 JSStringRef propertyName,
81 JSValueRef* exception);
83 static bool setAppId(JSContextRef context,
85 JSStringRef propertyName,
87 JSValueRef* exception);
89 static JSValueRef getContextId(JSContextRef context,
91 JSStringRef propertyName,
92 JSValueRef* exception);
94 static bool setContextId(JSContextRef context,
96 JSStringRef propertyName,
98 JSValueRef* exception);