wrt-plugins-tizen_0.4.23
[framework/web/wrt-plugins-tizen.git] / src / Contact / JSContactAddressTypeArray.cpp
1 //
2 // Tizen Web Device API
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
8 //
9 // http://www.apache.org/licenses/LICENSE-2.0
10 //
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
16 //
17
18 /**
19  * @file        JSContactAddressTypeArray.cpp
20  * @author      Kisub Song (kisubs.song@samsung.com)
21  * @version     0.1
22  * @brief
23  */
24
25 #include <algorithm>
26 #include <CommonsJavaScript/Converter.h>
27 #include <CommonsJavaScript/ScopedJSStringRef.h>
28 #include <JSTizenExceptionFactory.h>
29 #include <JSTizenException.h>
30 #include "ContactConverter.h"
31 #include "JSContactAddressTypeArray.h"
32 #include <Logger.h>
33
34 #define FUNCTION_CONCAT "concat"
35 #define FUNCTION_JOIN "join"
36 #define FUNCTION_POP "pop"
37 #define FUNCTION_PUSH "push"
38 #define FUNCTION_REVERSE "reverse"
39 #define FUNCTION_SHIFT "shift"
40 #define FUNCTION_SLICE "slice"
41 #define FUNCTION_SORT "sort"
42 #define FUNCTION_SPLICE "splice"
43 #define FUNCTION_TOSTRING "toString"
44 #define FUNCTION_UNSHIFT "unshift"
45 #define FUNCTION_VALUEOF "valueOf"
46 #define ARRAY "Array"
47 #define ATTRIBUTE_LENGTH "length"
48
49 namespace DeviceAPI {
50 namespace Contact {
51
52 using namespace DeviceAPI::Common;
53 using namespace WrtDeviceApis::CommonsJavaScript;
54
55 JSClassDefinition JSContactAddressTypeArray::m_classInfo = {
56         0,
57         kJSClassAttributeNone,
58         ARRAY,
59         0,
60         m_property,
61         m_function,
62         initialize,
63         finalize,
64         hasProperty,
65         getProperty,
66         setProperty,
67         deleteProperty,
68         getPropertyNames,
69         NULL, //callAsFunction,
70         NULL, //callAsConstructor,
71         NULL, //hasInstance,
72         NULL, //convertToType,
73 };
74
75 JSStaticValue JSContactAddressTypeArray::m_property[] = {
76         { ATTRIBUTE_LENGTH, getLength, NULL, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete },
77         { 0, 0, 0, 0 }
78 };
79
80 JSStaticFunction JSContactAddressTypeArray::m_function[] = {
81         { FUNCTION_CONCAT, concat, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete },
82         { FUNCTION_JOIN, join, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete },
83         { FUNCTION_POP, pop, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete },
84         { FUNCTION_PUSH, push, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete },
85         { FUNCTION_REVERSE, reverse, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete },
86         { FUNCTION_SHIFT, shift, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete },
87         { FUNCTION_SLICE, slice, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete },
88         { FUNCTION_SORT, sort, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete },
89         { FUNCTION_SPLICE, splice, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete },
90         { FUNCTION_TOSTRING, toString, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete },
91         { FUNCTION_UNSHIFT, unshift, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete },
92         { FUNCTION_VALUEOF, valueOf, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontEnum | kJSPropertyAttributeDontDelete },
93         { 0, 0, 0 }
94 };
95
96 JSClassRef JSContactAddressTypeArray::m_jsClassRef = JSClassCreate(
97                 JSContactAddressTypeArray::getClassInfo());
98
99 JSValueRef JSContactAddressTypeArray::getLength(JSContextRef context,
100                 JSObjectRef object,
101                 JSStringRef propertyName,
102                 JSValueRef* exception)
103 {
104         Try
105         {
106                 JSContactAddressTypeArrayPriv* priv =
107                         static_cast<JSContactAddressTypeArrayPriv*>(JSObjectGetPrivate(object));
108                 if (!priv) {
109                         Throw(WrtDeviceApis::Commons::NullPointerException);
110                 }
111                 ContactAddressTypeArrayPtr typeArray = priv->getObject();
112                 if (typeArray) {
113                         WrtDeviceApis::CommonsJavaScript::BasicConverter converter =
114                                         WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context);
115                         return converter->toJSValueRef(typeArray->size());
116                 }
117         }
118         Catch(WrtDeviceApis::Commons::Exception)
119         {
120                 LoggerE("invalid conversion");
121         }
122         return JSValueMakeUndefined(context);
123 }
124
125 JSObjectRef JSContactAddressTypeArray::createArray(JSContextRef context,
126                 const ContactAddressTypeArrayPtr &typeArray)
127 {
128         JSContactAddressTypeArrayPriv *priv = new JSContactAddressTypeArrayPriv(context, typeArray);
129         return JSObjectMake(context, getClassRef(), priv);
130 }
131
132 const JSClassDefinition* JSContactAddressTypeArray::getClassInfo()
133 {
134         return &(m_classInfo);
135 }
136
137 JSClassRef JSContactAddressTypeArray::getClassRef()
138 {
139         if (!m_jsClassRef) {
140                 m_jsClassRef = JSClassCreate(&m_classInfo);
141         }
142         return m_jsClassRef;
143 }
144
145 bool JSContactAddressTypeArray::isObjectOfClass(JSContextRef context, JSValueRef value)
146 {
147         return JSValueIsObjectOfClass(context, value, getClassRef());
148 }
149
150 ContactAddressTypeArrayPtr JSContactAddressTypeArray::getContactAddressTypeArray(JSContextRef context, JSValueRef value)
151 {
152         if (!isObjectOfClass(context, value)) {
153                 Throw(WrtDeviceApis::Commons::InvalidArgumentException);
154         }
155         JSObjectRef object = JSValueToObject(context, value, NULL);
156         if (!object) {
157                 Throw(WrtDeviceApis::Commons::InvalidArgumentException);
158         }
159         JSContactAddressTypeArrayPriv *priv = static_cast<JSContactAddressTypeArrayPriv*>(JSObjectGetPrivate(object));
160         if (!priv) {
161                 Throw(WrtDeviceApis::Commons::NullPointerException);
162         }
163         return priv->getObject();
164 }
165
166 void JSContactAddressTypeArray::initialize(JSContextRef context,
167                 JSObjectRef object)
168 {
169 }
170
171 void JSContactAddressTypeArray::finalize(JSObjectRef object)
172 {
173         JSContactAddressTypeArrayPriv* priv =
174                 static_cast<JSContactAddressTypeArrayPriv*>(JSObjectGetPrivate(object));
175         delete priv;
176         JSObjectSetPrivate(object, NULL);
177 }
178
179 bool JSContactAddressTypeArray::hasProperty(JSContextRef context,
180                 JSObjectRef object,
181                 JSStringRef propertyName)
182 {
183         WrtDeviceApis::CommonsJavaScript::BasicConverter converter =
184                         WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context);
185         Try
186         {
187                 size_t index = converter->toSizeT(propertyName);
188                 JSContactAddressTypeArrayPriv* priv =
189                         static_cast<JSContactAddressTypeArrayPriv*>(JSObjectGetPrivate(object));
190                 if (!priv) {
191                         Throw(WrtDeviceApis::Commons::NullPointerException);
192                 }
193                 ContactAddressTypeArrayPtr typeArray = priv->getObject();
194                 if (index < typeArray->size()) {
195                         return true;
196                 }
197         }
198         Catch(WrtDeviceApis::Commons::Exception)
199         {
200                 //not reporting error is intended
201         }
202         return false;
203 }
204
205 JSValueRef JSContactAddressTypeArray::getProperty(JSContextRef context,
206                 JSObjectRef object,
207                 JSStringRef propertyName,
208                 JSValueRef* exception)
209 {
210         ContactConverterFactory::ConverterType converter =
211                                         ContactConverterFactory::getConverter(context);
212         Try
213         {
214                 size_t index = converter->toSizeT(propertyName);
215                 JSContactAddressTypeArrayPriv* priv =
216                         static_cast<JSContactAddressTypeArrayPriv*>(JSObjectGetPrivate(object));
217                 if (!priv) {
218                         Throw(WrtDeviceApis::Commons::NullPointerException);
219                 }
220                 ContactAddressTypeArrayPtr typeArray = priv->getObject();
221                 if (index < typeArray->size()) {
222                         std::string result = converter->toContactAddressTypeStr(typeArray->at(index));
223                         if (!result.empty()) {
224                                 return converter->toJSValueRef(result);
225                         }
226                 }
227         }
228         Catch(WrtDeviceApis::Commons::Exception)
229         {
230                 LoggerE("invalid property");
231         }
232         return JSValueMakeUndefined(context);
233 }
234
235 bool JSContactAddressTypeArray::setProperty(JSContextRef context,
236                 JSObjectRef object,
237                 JSStringRef propertyName,
238                 JSValueRef value,
239                 JSValueRef* exception)
240 {
241         ContactConverterFactory::ConverterType converter =
242                                         ContactConverterFactory::getConverter(context);
243    Try
244         {
245                 size_t index = converter->toSizeT(propertyName);
246                 std::string str;
247                 if (!JSValueIsUndefined(context, value)) {
248                         str = converter->toString(value);
249                 }
250                 JSContactAddressTypeArrayPriv* priv =
251                         static_cast<JSContactAddressTypeArrayPriv*>(JSObjectGetPrivate(object));
252                 if (!priv) {
253                         Throw(WrtDeviceApis::Commons::NullPointerException);
254                 }
255                 ContactAddressTypeArrayPtr typeArray = priv->getObject();
256                 if (!typeArray) {
257                         Throw(WrtDeviceApis::Commons::NullPointerException);
258                 }
259                 if (typeArray->size() <= index) {
260                         typeArray->resize(index + 1);
261                 }
262                 (*typeArray)[index] = converter->toContactAddressType(str);
263                 return true;
264         }
265         Catch(WrtDeviceApis::Commons::Exception)
266         {
267                 LoggerE("error occured");
268                 JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
269         }
270         return false;
271 }
272
273 bool JSContactAddressTypeArray::deleteProperty(JSContextRef context,
274                 JSObjectRef object,
275                 JSStringRef propertyName,
276                 JSValueRef* exception)
277 {
278         ContactConverterFactory::ConverterType converter = ContactConverterFactory::getConverter(context);
279         Try
280         {
281                 size_t index = converter->toSizeT(propertyName);
282                 JSContactAddressTypeArrayPriv* priv =
283                         static_cast<JSContactAddressTypeArrayPriv*>(JSObjectGetPrivate(object));
284                 if (!priv) {
285                         Throw(WrtDeviceApis::Commons::NullPointerException);
286                 }
287                 ContactAddressTypeArrayPtr typeArray = priv->getObject();
288                 if (!typeArray) {
289                         Throw(WrtDeviceApis::Commons::NullPointerException);
290                 }
291                 if (typeArray->size() > index) {
292                         (*typeArray)[index] = converter->toContactAddressType("");
293                 }
294                 return true;
295         }
296         Catch(WrtDeviceApis::Commons::Exception)
297         {
298                 LoggerE("error occured");
299                 JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
300         }
301         return false;
302 }
303
304 void JSContactAddressTypeArray::getPropertyNames(JSContextRef context,
305                 JSObjectRef object,
306                 JSPropertyNameAccumulatorRef propertyNames)
307 {
308         ContactConverterFactory::ConverterType converter =
309                         ContactConverterFactory::getConverter(context);
310         Try
311         {
312                 JSContactAddressTypeArrayPriv* priv =
313                         static_cast<JSContactAddressTypeArrayPriv*>(JSObjectGetPrivate(object));
314                 if (!priv) {
315                         Throw(WrtDeviceApis::Commons::NullPointerException);
316                 }
317                 ContactAddressTypeArrayPtr addressTypes = priv->getObject();
318
319                 int count = addressTypes->size();
320
321                 for(int i=0; i < count; i++)
322                 {
323                         ScopedJSStringRef name(converter->toJSStringRef(converter->toString(i)));
324                         JSPropertyNameAccumulatorAddName(propertyNames, name.get());
325                 }
326         }
327         Catch(WrtDeviceApis::Commons::Exception)
328         {
329                 LoggerE("invalid property");
330         }
331 }
332
333 JSValueRef JSContactAddressTypeArray::concat(JSContextRef context,
334                 JSObjectRef function,
335                 JSObjectRef thisObject,
336                 size_t argumentCount,
337                 const JSValueRef arguments[],
338                 JSValueRef* exception)
339 {
340         Try
341         {
342                 ContactAddressTypeArrayPtr typeArray = ContactAddressTypeArrayPtr(new ContactAddressTypeArray());
343                 JSContactAddressTypeArrayPriv *newPrivateObject = new JSContactAddressTypeArrayPriv(
344                                 context,
345                                 typeArray);
346                 JSValueRef result = JSObjectMake(context,
347                                                                                  getClassRef(), newPrivateObject);
348
349                 //copy current typeArray
350                 JSContactAddressTypeArrayPriv* priv =
351                         static_cast<JSContactAddressTypeArrayPriv*>(JSObjectGetPrivate(thisObject));
352                 ContactAddressTypeArrayPtr currentTypes = priv->getObject();
353                 for (size_t i = 0; i < currentTypes->size(); ++i) {
354                         typeArray->push_back(currentTypes->at(i));
355                 }
356
357                 //copy submitted arrays
358                 ContactConverterFactory::ConverterType converter =
359                                                 ContactConverterFactory::getConverter(context);
360                 for (size_t i = 0; i < argumentCount; ++i) {
361                         if (!JSIsArrayValue(context, arguments[i])) {
362                                 Throw(WrtDeviceApis::Commons::ConversionException);
363                         }
364                         // process array of types
365                         JSObjectRef arrayObj = converter->toJSObjectRef(arguments[i]);
366                         unsigned int len = JSGetArrayLength(context, arrayObj);
367                         for (unsigned int e = 0; e < len; ++e) {
368                                 JSValueRef att = JSGetArrayElement(context, arrayObj, e);
369                                 typeArray->push_back(converter->toContactAddressType(att));
370                         }
371                 }
372                 return result;
373         }
374         Catch(WrtDeviceApis::Commons::Exception)
375         {
376                 LoggerE("error occured");
377         }
378         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
379 }
380
381 JSValueRef JSContactAddressTypeArray::join(JSContextRef context,
382                 JSObjectRef function,
383                 JSObjectRef thisObject,
384                 size_t argumentCount,
385                 const JSValueRef arguments[],
386                 JSValueRef* exception)
387 {
388         Try
389         {
390                 std::string result;
391                 std::string separator(",");
392                 WrtDeviceApis::CommonsJavaScript::BasicConverter converter =
393                                 WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context);
394                 JSContactAddressTypeArrayPriv* priv =
395                         static_cast<JSContactAddressTypeArrayPriv*>(JSObjectGetPrivate(thisObject));
396                 ContactAddressTypeArrayPtr currentTypes = priv->getObject();
397                 if (argumentCount > 0 && JSValueIsString(context, arguments[0])) {
398                         separator = converter->toString(arguments[0]);
399                 }
400                 for (size_t i = 0; i < currentTypes->size(); ++i) {
401                         if (i != 0) {
402                                 result += separator;
403                         }
404                         result += currentTypes->at(i);
405                 }
406                 return converter->toJSValueRef(result);
407         }
408         Catch(WrtDeviceApis::Commons::Exception)
409         {
410                 LoggerE("error occured");
411         }
412         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
413 }
414
415 JSValueRef JSContactAddressTypeArray::pop(JSContextRef context,
416                 JSObjectRef function,
417                 JSObjectRef thisObject,
418                 size_t argumentCount,
419                 const JSValueRef arguments[],
420                 JSValueRef* exception)
421 {
422         Try
423         {
424                 ContactConverterFactory::ConverterType converter =
425                                                 ContactConverterFactory::getConverter(context);
426                 JSContactAddressTypeArrayPriv* priv =
427                         static_cast<JSContactAddressTypeArrayPriv*>(JSObjectGetPrivate(thisObject));
428                 ContactAddressTypeArrayPtr currentTypes = priv->getObject();
429                 if (currentTypes->size() > 0) {
430                         std::string result = converter->toContactAddressTypeStr(currentTypes->at(currentTypes->size()-1));
431                         currentTypes->pop_back();
432                         return converter->toJSValueRef(result);
433                 }
434         }
435         Catch(WrtDeviceApis::Commons::Exception)
436         {
437                 LoggerE("error occured");
438         }
439         return JSValueMakeUndefined(context);
440 }
441
442 JSValueRef JSContactAddressTypeArray::push(JSContextRef context,
443                 JSObjectRef function,
444                 JSObjectRef thisObject,
445                 size_t argumentCount,
446                 const JSValueRef arguments[],
447                 JSValueRef* exception)
448 {
449         Try
450         {
451                 ContactConverterFactory::ConverterType converter =
452                                                 ContactConverterFactory::getConverter(context);
453                 JSContactAddressTypeArrayPriv* priv =
454                         static_cast<JSContactAddressTypeArrayPriv*>(JSObjectGetPrivate(thisObject));
455                 ContactAddressTypeArrayPtr currentTypes = priv->getObject();
456                 for (size_t i = 0; i < argumentCount; ++i) {
457                         currentTypes->push_back(converter->toContactAddressType(arguments[i]));
458                 }
459                 return converter->toJSValueRef(currentTypes->size());
460         }
461         Catch(WrtDeviceApis::Commons::Exception)
462         {
463                 LoggerE("error occured");
464         }
465         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
466 }
467
468 JSValueRef JSContactAddressTypeArray::reverse(JSContextRef context,
469                 JSObjectRef function,
470                 JSObjectRef thisObject,
471                 size_t argumentCount,
472                 const JSValueRef arguments[],
473                 JSValueRef* exception)
474 {
475         Try
476         {
477                 WrtDeviceApis::CommonsJavaScript::BasicConverter converter =
478                                 WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context);
479                 JSContactAddressTypeArrayPriv* priv =
480                         static_cast<JSContactAddressTypeArrayPriv*>(JSObjectGetPrivate(thisObject));
481                 ContactAddressTypeArrayPtr currentTypes = priv->getObject();
482                 std::reverse(currentTypes->begin(), currentTypes->end());
483                 return thisObject;
484         }
485         Catch(WrtDeviceApis::Commons::Exception)
486         {
487                 LoggerE("error occured");
488         }
489         return JSValueMakeUndefined(context);
490 }
491
492 JSValueRef JSContactAddressTypeArray::shift(JSContextRef context,
493                 JSObjectRef function,
494                 JSObjectRef thisObject,
495                 size_t argumentCount,
496                 const JSValueRef arguments[],
497                 JSValueRef* exception)
498 {
499         Try
500         {
501                 ContactConverterFactory::ConverterType converter =
502                                                 ContactConverterFactory::getConverter(context);
503                 JSContactAddressTypeArrayPriv* priv =
504                         static_cast<JSContactAddressTypeArrayPriv*>(JSObjectGetPrivate(thisObject));
505                 ContactAddressTypeArrayPtr currentTypes = priv->getObject();
506                 if (currentTypes->size() > 0) {
507                         std::string result = converter->toContactAddressTypeStr(currentTypes->at(0));
508                         currentTypes->erase(currentTypes->begin());
509                         return converter->toJSValueRef(result);
510                 }
511         }
512         Catch(WrtDeviceApis::Commons::Exception)
513         {
514                 LoggerE("error occured");
515         }
516         return JSValueMakeUndefined(context);
517 }
518
519 JSValueRef JSContactAddressTypeArray::slice(JSContextRef context,
520                 JSObjectRef function,
521                 JSObjectRef thisObject,
522                 size_t argumentCount,
523                 const JSValueRef arguments[],
524                 JSValueRef* exception)
525 {
526         Try
527         {
528                 if (argumentCount < 1) {
529                         return JSValueMakeUndefined(context);
530                 }
531                 WrtDeviceApis::CommonsJavaScript::BasicConverter converter =
532                                 WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context);
533                 ContactAddressTypeArrayPtr typeArray = ContactAddressTypeArrayPtr(new ContactAddressTypeArray());
534                 JSContactAddressTypeArrayPriv *newPrivateObject = new JSContactAddressTypeArrayPriv(
535                                 context,
536                                 typeArray);
537                 JSValueRef result = JSObjectMake(context,
538                                                                                  getClassRef(), newPrivateObject);
539
540                 //copy current typeArray
541                 JSContactAddressTypeArrayPriv* priv =
542                         static_cast<JSContactAddressTypeArrayPriv*>(JSObjectGetPrivate(thisObject));
543                 ContactAddressTypeArrayPtr currentTypes = priv->getObject();
544                 std::size_t first = converter->toSizeT(arguments[0]);
545                 std::size_t last = currentTypes->size() - 1;
546                 if (argumentCount > 1) {
547                         last = converter->toSizeT(arguments[1]);
548                         if (last >= currentTypes->size()) {
549                                 last = currentTypes->size() - 1;
550                         }
551                 }
552                 for (size_t i = first; i <= last; ++i) {
553                         typeArray->push_back(currentTypes->at(i));
554                 }
555
556                 return result;
557         }
558         Catch(WrtDeviceApis::Commons::Exception)
559         {
560                 LoggerE("error occured");
561         }
562         return JSTizenExceptionFactory::postException(context, exception, JSTizenException::TYPE_MISMATCH_ERROR, "Type mismatch");
563 }
564
565 JSValueRef JSContactAddressTypeArray::sort(JSContextRef context,
566                 JSObjectRef function,
567                 JSObjectRef thisObject,
568                 size_t argumentCount,
569                 const JSValueRef arguments[],
570                 JSValueRef* exception)
571 {
572         Try
573         {
574                 WrtDeviceApis::CommonsJavaScript::BasicConverter converter =
575                                 WrtDeviceApis::CommonsJavaScript::BasicConverterFactory::getConverter(context);
576                 JSContactAddressTypeArrayPriv* priv =
577                         static_cast<JSContactAddressTypeArrayPriv*>(JSObjectGetPrivate(thisObject));
578                 ContactAddressTypeArrayPtr currentTypes = priv->getObject();
579                 std::sort(currentTypes->begin(), currentTypes->end());
580                 return thisObject;
581         }
582         Catch(WrtDeviceApis::Commons::Exception)
583         {
584                 LoggerE("error occured");
585         }
586         return JSValueMakeUndefined(context);
587 }
588
589 JSValueRef JSContactAddressTypeArray::splice(JSContextRef context,
590                 JSObjectRef function,
591                 JSObjectRef thisObject,
592                 size_t argumentCount,
593                 const JSValueRef arguments[],
594                 JSValueRef* exception)
595 {
596         return JSValueMakeUndefined(context);
597 }
598
599 JSValueRef JSContactAddressTypeArray::toString(JSContextRef context,
600                 JSObjectRef function,
601                 JSObjectRef thisObject,
602                 size_t argumentCount,
603                 const JSValueRef arguments[],
604                 JSValueRef* exception)
605 {
606         return join(context, function, thisObject, 0, arguments, exception);
607 }
608
609 JSValueRef JSContactAddressTypeArray::unshift(JSContextRef context,
610                 JSObjectRef function,
611                 JSObjectRef thisObject,
612                 size_t argumentCount,
613                 const JSValueRef arguments[],
614                 JSValueRef* exception)
615 {
616         return JSValueMakeUndefined(context);
617 }
618
619 JSValueRef JSContactAddressTypeArray::valueOf(JSContextRef context,
620                 JSObjectRef function,
621                 JSObjectRef thisObject,
622                 size_t argumentCount,
623                 const JSValueRef arguments[],
624                 JSValueRef* exception)
625 {
626         return JSValueMakeUndefined(context);
627 }
628
629 } // Contact
630 } // DeviceAPI