File indexing completed on 2024-11-10 12:25:04

0001 #ifndef UTIL_H
0002 #define UTIL_H
0003 
0004 namespace KJSEmbed
0005 {
0006 bool isBasic(KJS::JSValue *value)
0007 {
0008     switch (value->type()) {
0009     case KJS::NumberType:
0010     case KJS::BooleanType:
0011     case KJS::StringType:
0012         return true;
0013         break;
0014     default:
0015         return false;
0016 
0017     }
0018 }
0019 
0020 bool isVariant(KJS::JSObject *object)
0021 {
0022     return object->inherits(&VariantBinding::info);
0023 }
0024 
0025 /*bool isValue(KJS::JSObject *object)
0026 {
0027     return object->inherits(&ValueBinding::info);
0028 }*/
0029 
0030 bool isObject(KJS::JSObject *object)
0031 {
0032     return object->inherits(&ObjectBinding::info);
0033 }
0034 
0035 /*
0036 So this might be how the val checking would go:
0037     JSValue *arg = args[0];
0038     if (isBasic(arg))
0039     {
0040         switch (arg->type())
0041         {
0042             case KJS::Number:
0043                 extractInt...;
0044                 break;
0045             case KJS::String:
0046                 extractString...;
0047                 break;
0048             case KJS::Boolean:
0049                 extractBool...;
0050                 break;
0051             default: hmmm
0052         }
0053     }
0054     else
0055     {
0056         JSObject *object = arg->toObject(exec);
0057         if (isValue(object))
0058         {
0059             extractValue...
0060         }
0061         else if (isObject(object))
0062         {
0063             extractObject...
0064         }
0065         else
0066         {
0067             hmmm
0068         }
0069     }
0070 
0071 */
0072 
0073 }
0074 
0075 #endif
0076