diff --git a/modules/juce_browser_plugin_client/wrapper/juce_ActiveX_GlueCode.cpp b/modules/juce_browser_plugin_client/wrapper/juce_ActiveX_GlueCode.cpp index 1b51154bd5..28235a1fdf 100644 --- a/modules/juce_browser_plugin_client/wrapper/juce_ActiveX_GlueCode.cpp +++ b/modules/juce_browser_plugin_client/wrapper/juce_ActiveX_GlueCode.cpp @@ -69,17 +69,26 @@ public: String getStringFromDISPID (const DISPID hash) const { - for (int i = identifierPool.size(); --i >= 0;) - if (getHashFromString (identifierPool[i]) == hash) - return identifierPool[i]; + return identifierNames [identifierIDs.indexOf (hash)]; + } - return String::empty; + DISPID getDISPIDForName (const String& name) + { + const int i = identifierNames.indexOf (String (name)); + + if (i >= 0) + return identifierIDs[i]; + + const DISPID newID = (DISPID) name.hashCode64(); + identifierNames.add (name); + identifierIDs.add (newID); + return newID; } HRESULT doGetIDsOfNames (LPOLESTR* rgszNames, UINT cNames, DISPID* rgDispId) { for (unsigned int i = 0; i < cNames; ++i) - rgDispId[i] = getHashFromString (identifierPool.getPooledString (String (rgszNames[i]))); + rgDispId[i] = getDISPIDForName (rgszNames[i]); return S_OK; } @@ -97,36 +106,33 @@ public: if ((wFlags & DISPATCH_METHOD) != 0) { - if (! object->hasMethod (memberId)) - return DISP_E_MEMBERNOTFOUND; - - const int numArgs = pDispParams == nullptr ? 0 : pDispParams->cArgs; - var result; - - if (numArgs == 0) + if (object->hasMethod (memberId)) { - result = v.call (memberId); + const int numArgs = pDispParams == nullptr ? 0 : pDispParams->cArgs; + var result; + + if (numArgs == 0) + { + result = v.call (memberId); + } + else + { + Array args; + for (int j = numArgs; --j >= 0;) + args.add (variantTojuceVar (pDispParams->rgvarg[j])); + + result = v.invoke (memberId, numArgs == 0 ? nullptr : args.getRawDataPointer(), numArgs); + } + + if (pVarResult != nullptr) + juceVarToVariant (result, *pVarResult); + + return S_OK; } - else - { - Array args; - for (int j = numArgs; --j >= 0;) - args.add (variantTojuceVar (pDispParams->rgvarg[j])); - - result = v.invoke (memberId, numArgs == 0 ? 0 : args.getRawDataPointer(), numArgs); - } - - if (pVarResult != nullptr) - juceVarToVariant (result, *pVarResult); - - return S_OK; } else if ((wFlags & DISPATCH_PROPERTYGET) != 0) { - if (! object->hasProperty (memberId)) - return DISP_E_MEMBERNOTFOUND; - - if (pVarResult != nullptr) + if (object->hasProperty (memberId) && pVarResult != nullptr) { juceVarToVariant (object->getProperty (memberId), *pVarResult); return S_OK; @@ -145,12 +151,8 @@ public: } private: - StringPool identifierPool; - - static DISPID getHashFromString (const String::CharPointerType s) noexcept - { - return (DISPID) (pointer_sized_int) s.getAddress(); - } + Array identifierIDs; + StringArray identifierNames; JUCE_DECLARE_NON_COPYABLE (IDispatchHelper) };