2 // Tizen Web Device API
3 // Copyright (c) 2013 Samsung Electronics Co., Ltd.
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
9 // http://www.apache.org/licenses/LICENSE-2.0
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.
18 #ifndef _WRTPLUGINS_TIZEN_ARGUMENTVALIDATIONCHECKER_
19 #define _WRTPLUGINS_TIZEN_ARGUMENTVALIDATIONCHECKER_
22 #include <JavaScriptCore/JavaScript.h>
27 class ArgumentValidationException{
29 std::string mTizenException;
31 int mInvalidArgumentIndex;
32 ArgumentValidationException(const std::string tizenException ,const std::string message):mTizenException(tizenException),mMessage(message),mInvalidArgumentIndex(-1){}
33 ArgumentValidationException(const std::string tizenException ,const std::string message, int index):mTizenException(tizenException),mMessage(message),mInvalidArgumentIndex(index){}
38 class ArgumentValidationChecker{
40 typedef bool (* SelfChecker)(JSValueRef value);
43 * @brief Argument Validation options
44 * MANDATORY - Must existed
45 * OPTIONAL - Can be omitted
46 * NULLABLE - Can be use NULL value
47 * END - Variable argument terminator symbol
49 enum Option { MANDATORY = 0x01 , OPTIONAL = 0x02, NULLABLE = 0x04, END = 0x00 };
51 enum Type { Float, Long, String, Function, Boolean, Object, Array, UserDefine, SelfCheck };
54 * @brief check argment validation
57 * Option phase instruction
59 * OPTIONS => OPTION, OPTIONS | OPTION,"END"
60 * OPTION => FIRST, SECOND
61 * FIRST => "MANDATORY" | "OPTIONAL" NULLABLE
62 * NULLABLE => "|NULLABLE" | ""
63 * SECOND => "Float" | "Long" | "String" | "Function" | "Boolean" | "Object" | "Array" | "UserDefine", CLASSREF | "SelfCheck", CHECKFUN
64 * CLASSREF => ,JSClassRef
65 * CHECKFUN => ,SelfChecker
67 * @param[in] ctx Context
68 * @param[in] oirginArgumentCount Number of passed arguments count
69 * @param[in] originArguments Passed arguments
70 * @param[in] convertedArgumentCount Number of argument count in spec
71 * @param[out] convertedArguments Converted arguments in proper types
72 * @param[in] option Argument options
75 static void check(JSContextRef ctx, int oirginArgumentCount , const JSValueRef originArguments[], int convertedArgumentCount , JSValueRef convertedArguments[], Option option, ...);
81 #endif //_WRTPLUGINS_TIZEN_ARGUMENTVALIDATIONCHECKER_