Beta merge 2
[profile/ivi/wrt-plugins-tizen.git] / src / standards / Tizen / Contact / JSStringArray.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  * @file        JSStringArray.h
19  * @author      Kisub Song (kisubs.song@samsung.com)
20  * @version     0.1
21  * @brief
22  */
23
24 #ifndef _TIZEN_CONTACT_JS_STRING_ARRAY_H_
25 #define _TIZEN_CONTACT_JS_STRING_ARRAY_H_
26
27 #include <vector>
28 #include <JavaScriptCore/JavaScript.h>
29 #include <CommonsJavaScript/PrivateObject.h>
30
31 namespace TizenApis {
32 namespace Tizen1_0 {
33 namespace Contact {
34
35 typedef std::vector<std::string> StringArray;
36 typedef DPL::SharedPtr<StringArray> StringArrayPtr;
37 typedef WrtDeviceApis::CommonsJavaScript::PrivateObjectT<StringArrayPtr>::Type JSStringArrayPriv;
38
39 class JSStringArray
40 {
41 public:
42
43         static const JSClassDefinition* getClassInfo();
44
45         static JSClassRef getClassRef();
46
47         static JSObjectRef createArray(JSContextRef context,
48                         const StringArrayPtr &Strings);
49
50         static bool isObjectOfClass(JSContextRef context, JSValueRef value);
51
52         static StringArrayPtr getStringArray(JSContextRef context, JSValueRef value);
53
54 private:
55
56         /**
57          * The callback invoked when an object is first created.
58          */
59         static void initialize(JSContextRef context,
60                         JSObjectRef object);
61
62         /**
63          * The callback invoked when an object is finalized.
64          */
65         static void finalize(JSObjectRef object);
66
67         static JSValueRef getLength(JSContextRef context,
68                         JSObjectRef object,
69                         JSStringRef propertyName,
70                         JSValueRef* exception);
71
72         static bool hasProperty(JSContextRef context,
73                         JSObjectRef object,
74                         JSStringRef propertyName);
75
76         static JSValueRef getProperty(JSContextRef context,
77                         JSObjectRef object,
78                         JSStringRef propertyName,
79                         JSValueRef* exception);
80
81         static bool setProperty(JSContextRef context,
82                         JSObjectRef object,
83                         JSStringRef propertyName,
84                         JSValueRef value,
85                         JSValueRef* exception);
86
87         static JSValueRef concat(JSContextRef context,
88                         JSObjectRef function,
89                         JSObjectRef thisObject,
90                         size_t argumentCount,
91                         const JSValueRef arguments[],
92                         JSValueRef* exception);
93         static JSValueRef join(JSContextRef context,
94                         JSObjectRef function,
95                         JSObjectRef thisObject,
96                         size_t argumentCount,
97                         const JSValueRef arguments[],
98                         JSValueRef* exception);
99         static JSValueRef pop(JSContextRef context,
100                         JSObjectRef function,
101                         JSObjectRef thisObject,
102                         size_t argumentCount,
103                         const JSValueRef arguments[],
104                         JSValueRef* exception);
105         static JSValueRef push(JSContextRef context,
106                         JSObjectRef function,
107                         JSObjectRef thisObject,
108                         size_t argumentCount,
109                         const JSValueRef arguments[],
110                         JSValueRef* exception);
111         static JSValueRef reverse(JSContextRef context,
112                         JSObjectRef function,
113                         JSObjectRef thisObject,
114                         size_t argumentCount,
115                         const JSValueRef arguments[],
116                         JSValueRef* exception);
117         static JSValueRef shift(JSContextRef context,
118                         JSObjectRef function,
119                         JSObjectRef thisObject,
120                         size_t argumentCount,
121                         const JSValueRef arguments[],
122                         JSValueRef* exception);
123         static JSValueRef slice(JSContextRef context,
124                         JSObjectRef function,
125                         JSObjectRef thisObject,
126                         size_t argumentCount,
127                         const JSValueRef arguments[],
128                         JSValueRef* exception);
129         static JSValueRef sort(JSContextRef context,
130                         JSObjectRef function,
131                         JSObjectRef thisObject,
132                         size_t argumentCount,
133                         const JSValueRef arguments[],
134                         JSValueRef* exception);
135         static JSValueRef splice(JSContextRef context,
136                         JSObjectRef function,
137                         JSObjectRef thisObject,
138                         size_t argumentCount,
139                         const JSValueRef arguments[],
140                         JSValueRef* exception);
141         static JSValueRef toString(JSContextRef context,
142                         JSObjectRef function,
143                         JSObjectRef thisObject,
144                         size_t argumentCount,
145                         const JSValueRef arguments[],
146                         JSValueRef* exception);
147         static JSValueRef unshift(JSContextRef context,
148                         JSObjectRef function,
149                         JSObjectRef thisObject,
150                         size_t argumentCount,
151                         const JSValueRef arguments[],
152                         JSValueRef* exception);
153         static JSValueRef valueOf(JSContextRef context,
154                         JSObjectRef function,
155                         JSObjectRef thisObject,
156                         size_t argumentCount,
157                         const JSValueRef arguments[],
158                         JSValueRef* exception);
159
160         static bool checkValue(const std::string &value);
161
162         static JSClassRef m_jsClassRef;
163         /**
164          * This structure describes a statically declared function property.
165          */
166         static JSStaticFunction m_function[];
167
168         /**
169          * This structure contains properties and callbacks that define a type of object.
170          */
171         static JSClassDefinition m_classInfo;
172
173         /**
174          * This member variable contains the initialization values for the static properties of this class.
175          * The values are given according to the data structure JSPropertySpec
176          */
177         static JSStaticValue m_property[];
178 };
179
180 } // Contact
181 } // Tizen1_0
182 } // TizenApis
183
184 #endif // _TIZEN_CONTACT_JS_STRING_ARRAY_H_