[utils] modified _toPlatformObject() to handle array input type
authorSunggyu Choi <sunggyu.choi@samsung.com>
Thu, 29 Jan 2015 08:03:09 +0000 (17:03 +0900)
committerSunggyu Choi <sunggyu.choi@samsung.com>
Thu, 29 Jan 2015 10:21:35 +0000 (19:21 +0900)
- replyResult() has a optional parameter as array type.
  previous _toPlatformObject() can't handle this case.

- removed lint error

[verification] self test

Change-Id: I970a47447bc7571ba8cee7741d69e7d247682ccb
Signed-off-by: Sunggyu Choi <sunggyu.choi@samsung.com>
src/utils/utils_api.js

index 64ebb783ffb83e4b6613e91cb67e445b4f40c35e..87c2f71b855f56d68668cbda1841c3281bbcfccc 100644 (file)
@@ -236,7 +236,14 @@ Converter.prototype.toString = function(val, nullable) {
 };
 
 function _toPlatformObject(val, types) {
+  var v;
   var t;
+  if (_type.isArray(val)) {
+    v = val;
+  } else {
+    v = [val];
+  }
+
   if (_type.isArray(types)) {
     t = types;
   } else {
@@ -244,7 +251,9 @@ function _toPlatformObject(val, types) {
   }
   var match = false;
   for (var i = 0; i < t.length; ++i) {
-    match = match || (val instanceof t[i]);
+    for (var j = 0; j < v.length; ++j) {
+      match = match || (v[j] instanceof t[i]);
+    }
   }
   if (match) {
     return val;