upload tizen1.0 source
[profile/ivi/wrt-plugins-tizen.git] / src / standards / Tizen / Tizen / JSAttributeRangeFilter.cpp
index 4f68995..b92cd67 100755 (executable)
@@ -166,7 +166,10 @@ JSObjectRef JSAttributeRangeFilter::constructor(JSContextRef context,
 {
        LogDebug("entered");
 
-//     AceSecurityStatus status = CONTACT_CHECK_ACCESS(controller->getContext(), CONTACT_FUNCTION_API_ADD);
+       bool js2ndParamIsValue = false;
+       bool js3rdParamIsValue = false;
+
+//     AceSecurityStatus status = CONTACT_CHECK_ACCESS(CONTACT_FUNCTION_API_ADD);
 //     TIZEN_SYNC_ACCESS_HANDLER(status, context, exception);
 
        JSAttributeRangeFilterPriv *priv = static_cast<JSAttributeRangeFilterPriv*>(JSObjectGetPrivate(constructor));
@@ -179,25 +182,28 @@ JSObjectRef JSAttributeRangeFilter::constructor(JSContextRef context,
 
        BasicValidator validator = BasicValidatorFactory::getValidator(gContext, exception);
        Try {
-               if (argumentCount < 2 || argumentCount > 3)
+               if (argumentCount < 1)
                        ThrowMsg(InvalidArgumentException, "Wrong arguments count.");
 
                if (!JSValueIsString(gContext, arguments[0]))
                        ThrowMsg(InvalidArgumentException, "1st argument is not string.");
 
                // 2nd and 3rd argument can be any type.
-               if (argumentCount == 2)
+               if (argumentCount >= 2)
                {
-                       if(JSValueIsNull(gContext, arguments[1]))
-                               ThrowMsg(InvalidArgumentException, "At least one of initialValue and endValue needed.");
+                       if(!JSValueIsUndefined(gContext, arguments[1]) && !JSValueIsNull(gContext, arguments[1]))
+                               js2ndParamIsValue = true;
                }
 
-               if (argumentCount == 3)
+               if (argumentCount >= 3)
                {
-                       if(JSValueIsNull(gContext, arguments[1]) && JSValueIsNull(gContext, arguments[2]))
-                               ThrowMsg(InvalidArgumentException, "At least one of initialValue and endValue needed.");
+                       if(!JSValueIsUndefined(gContext, arguments[2]) && !JSValueIsNull(gContext, arguments[2]))
+                               js3rdParamIsValue = true;
                }
 
+               if (!js2ndParamIsValue && !js3rdParamIsValue)
+                       ThrowMsg(InvalidArgumentException, "At least one of initialValue and endValue are needed.");
+
        } Catch(Exception ) {
                LogError("Argument type mismatch : " << _rethrown_exception.GetMessage());
                *exception = JSTizenExceptionFactory::makeErrorObject(context, JSTizenException::TYPE_MISMATCH_ERROR, "Wrong arguments");
@@ -207,8 +213,8 @@ JSObjectRef JSAttributeRangeFilter::constructor(JSContextRef context,
        FilterConverterFactory::ConverterType converter = FilterConverterFactory::getConverter(gContext);
 
        std::string attributeName;
-       AnyPtr initialValue;
-       AnyPtr endValue;
+       AnyPtr initialValue(NULL);
+       AnyPtr endValue(NULL);
 
        Try {
                attributeName = converter->toString(arguments[0]);
@@ -219,7 +225,7 @@ JSObjectRef JSAttributeRangeFilter::constructor(JSContextRef context,
        }
 
        Try {
-               if(argumentCount >= 2)
+               if(js2ndParamIsValue)
                        initialValue = converter->toAny(arguments[1]);
                else
                        initialValue = AnyPtr(new Any());
@@ -231,7 +237,7 @@ JSObjectRef JSAttributeRangeFilter::constructor(JSContextRef context,
        }
 
        Try {
-               if(argumentCount >= 3)
+               if(js3rdParamIsValue)
                        endValue = converter->toAny(arguments[2]);
                else
                        endValue = AnyPtr(new Any());