| 79 | } |
| 80 | |
| 81 | bool VariantUtilities::VariantIsArray(VARIANT value) { |
| 82 | if (value.vt != VT_DISPATCH) { |
| 83 | return false; |
| 84 | } |
| 85 | |
| 86 | std::wstring type_name = GetVariantObjectTypeName(value); |
| 87 | |
| 88 | // If the name is DispStaticNodeList, we can be pretty sure it's an array |
| 89 | // (or at least has array semantics). It is unclear to what extent checking |
| 90 | // for DispStaticNodeList is supported behaviour. |
| 91 | if (type_name == L"DispStaticNodeList") { |
| 92 | LOG(DEBUG) << "Result type is DispStaticNodeList"; |
| 93 | return true; |
| 94 | } |
| 95 | |
| 96 | // If the name is JScriptTypeInfo then this *may* be a Javascript array. |
| 97 | // Note that strictly speaking, to determine if the result is *actually* |
| 98 | // a JavaScript array object, we should also be testing to see if |
| 99 | // propertyIsEnumerable('length') == false, but that does not find the |
| 100 | // array-like objects returned by some of the calls we make to the Google |
| 101 | // Closure library. |
| 102 | // IMPORTANT: Using this script, user-defined objects with a length |
| 103 | // property defined will be seen as arrays instead of objects. |
| 104 | if (type_name == L"JScriptTypeInfo" || type_name == L"") { |
| 105 | LOG(DEBUG) << "Result type is JScriptTypeInfo"; |
| 106 | LPOLESTR length_property_name = L"length"; |
| 107 | DISPID dispid_length = 0; |
| 108 | HRESULT hr = value.pdispVal->GetIDsOfNames(IID_NULL, |
| 109 | &length_property_name, |
| 110 | 1, |
| 111 | LOCALE_USER_DEFAULT, |
| 112 | &dispid_length); |
| 113 | if (SUCCEEDED(hr)) { |
| 114 | return true; |
| 115 | } |
| 116 | } |
| 117 | |
| 118 | return false; |
| 119 | } |
| 120 | |
| 121 | bool VariantUtilities::VariantIsObject(VARIANT value) { |
| 122 | if (value.vt != VT_DISPATCH) { |