Beta merge 2
[profile/ivi/wrt-plugins-tizen.git] / src / standards / Tizen / NFC / JSNdefMessage.h
1 /*
2  * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16
17
18
19 #ifndef _JS_TIZEN_NDEFMESSAGE_H_
20 #define _JS_TIZEN_NDEFMESSAGE_H_
21
22 #include <JavaScriptCore/JavaScript.h>
23 #include <API/NFC/INdefMessage.h>
24 #include <CommonsJavaScript/PrivateObject.h>
25
26 namespace TizenApis {
27 namespace Tizen1_0 {
28
29 typedef WrtDeviceApis::CommonsJavaScript::PrivateObject<Api::NFC::INdefMessagePtr, WrtDeviceApis::CommonsJavaScript::NoOwnership> NdefMessagePrivObject;
30
31 class JSNdefMessage
32 {
33 public:
34
35     static const JSClassDefinition* getClassInfo();
36
37     static const JSClassRef getClassRef();
38
39     static JSObjectRef createJSObject(JSContextRef context);
40     static JSObjectRef createJSObject(JSContextRef context, void *messageHandle);
41     static JSObjectRef createJSObject(JSContextRef context, Api::NFC::INdefMessagePtr message);
42     static JSObjectRef createJSObject(JSContextRef context, std::vector<void *> ndefRcords);
43     static JSObjectRef createJSObject(JSContextRef context, std::vector<unsigned char> rawdata);
44
45 private:
46     /**
47      * This member variable contains the values which has to be passed when
48      * the this class is embedded into JS Engine.
49      */
50     static JSClassDefinition m_classInfo;
51
52     /**
53      * This structure describes a statically declared function property.
54      */
55     static JSStaticFunction m_function[];
56
57     /**
58      * This member variable contains the initialization values for the
59      * properties of this class. The values are given according to the
60      * data structure JSPropertySpec.
61      */
62     static JSStaticValue m_property[];
63
64     static JSClassRef m_jsClassRef;
65
66     /**
67      * The callback invoked when an object is first created.
68      */
69     static void initialize(JSContextRef context, JSObjectRef object);
70
71     /**
72      * The callback invoked when an object is finalized.
73      */
74     static void finalize(JSObjectRef object);
75
76     static JSObjectRef constructor(JSContextRef ctx, JSObjectRef constructor, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception);
77
78     /**
79      * Getters and setters for properties
80      */
81     static JSValueRef getProperty(JSContextRef context, JSObjectRef object,
82             JSStringRef propertyName, JSValueRef* exception);
83     static bool setProperty(JSContextRef context, JSObjectRef object,
84             JSStringRef propertyName,  JSValueRef value,  JSValueRef* exception);
85     /**
86      * The callback invoked when an object is used as the target of an 'instanceof' expression.
87      */
88     static bool hasInstance(JSContextRef context,
89             JSObjectRef constructor,
90             JSValueRef possibleInstance,
91                 JSValueRef* exception);
92
93     static JSValueRef toByte(JSContextRef context,
94                 JSObjectRef object,
95                 JSObjectRef thisObject,
96                 size_t argumentCount,
97                 const JSValueRef arguments[],
98                 JSValueRef* exception);
99 };
100
101 }
102 }
103
104 #endif /* _JS_TIZEN_NDEFMESSAGE_H_ */