diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2017-04-11 21:52:36 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2017-04-12 09:36:20 +0200 |
commit | 61f43d0327c81bb2df88734c9572e489e4a9de31 (patch) | |
tree | e9deeaac41e1f8ef3d5af4a27a11ca6312ce0237 /jvmfwk | |
parent | 346b5cfd9078826f8705e226ad317b2e4c58162d (diff) |
Simplify jfw::VersionInfo
Change-Id: I2cc1071bbaf9c68fbd621d6c0c6953b7646b1a62
Diffstat (limited to 'jvmfwk')
-rw-r--r-- | jvmfwk/inc/elements.hxx | 18 | ||||
-rw-r--r-- | jvmfwk/inc/vendorplugin.hxx | 14 | ||||
-rw-r--r-- | jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx | 39 | ||||
-rw-r--r-- | jvmfwk/source/elements.cxx | 37 | ||||
-rw-r--r-- | jvmfwk/source/framework.cxx | 15 | ||||
-rw-r--r-- | jvmfwk/source/fwkbase.cxx | 2 |
6 files changed, 23 insertions, 102 deletions
diff --git a/jvmfwk/inc/elements.hxx b/jvmfwk/inc/elements.hxx index a2c17bfcaeb0..f99861a83051 100644 --- a/jvmfwk/inc/elements.hxx +++ b/jvmfwk/inc/elements.hxx @@ -318,27 +318,11 @@ public: }; -class VersionInfo +struct VersionInfo { ::std::vector< OUString> vecExcludeVersions; - rtl_uString ** arVersions; - -public: - VersionInfo(); - ~VersionInfo(); - - void addExcludeVersion(const OUString& sVersion); - OUString sMinVersion; OUString sMaxVersion; - - /** The caller DOES NOT get ownership of the strings. That is he - does not need to release the strings. - The array exists as long as this object exists. - */ - - rtl_uString** getExcludeVersions(); - sal_Int32 getExcludeVersionSize(); }; } //end namespace diff --git a/jvmfwk/inc/vendorplugin.hxx b/jvmfwk/inc/vendorplugin.hxx index d4febd726d18..d456fe74a59c 100644 --- a/jvmfwk/inc/vendorplugin.hxx +++ b/jvmfwk/inc/vendorplugin.hxx @@ -88,9 +88,7 @@ enum class javaPluginError [in] represents the maximum version of a JRE. The string can be empty. @param arExcludeList [in] contains a list of "bad" versions. JREs which have one of these - versions must not be returned by this function. It can be NULL. - @param nSizeExcludeList - [in] the number of version strings contained in <code>arExcludeList</code>. + versions must not be returned by this function. @param parJavaInfo [out] if the function runs successfully then <code>parJavaInfo</code> contains on return an array of pointers to <code>JavaInfo</code> objects. @@ -111,8 +109,7 @@ javaPluginError jfw_plugin_getAllJavaInfos( OUString const& sVendor, OUString const& sMinVersion, OUString const& sMaxVersion, - rtl_uString * * arExcludeList, - sal_Int32 nSizeExcludeList, + std::vector<OUString> const & arExcludeList, JavaInfo*** parJavaInfo, sal_Int32 *nSizeJavaInfo, std::vector<rtl::Reference<jfw_plugin::VendorBase>> & infos); @@ -136,9 +133,7 @@ javaPluginError jfw_plugin_getAllJavaInfos( [in] represents the maximum version of a JRE. @param arExcludeList [in] contains a list of "bad" versions. JREs which have one of these - versions must not be returned by this function. It can be NULL. - @param nSizeExcludeList - [in] the number of version strings contained in <code>arExcludeList</code>. + versions must not be returned by this function. @param ppInfo [out] if the function runs successfully then <code>ppInfo</code> contains on return a pointer to a <code>JavaInfo</code> object. @@ -162,8 +157,7 @@ javaPluginError jfw_plugin_getJavaInfoByPath( OUString const& sVendor, OUString const& sMinVersion, OUString const& sMaxVersion, - rtl_uString * *arExcludeList, - sal_Int32 nSizeExcludeList, + std::vector<OUString> const &arExcludeList, JavaInfo ** ppInfo); diff --git a/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx b/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx index 9f3822a3772c..7ade439ed694 100644 --- a/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx +++ b/jvmfwk/plugins/sunmajor/pluginlib/sunjavaplugin.cxx @@ -32,6 +32,8 @@ #include <cassert> #include <memory> +#include <vector> + #include "config_options.h" #include "osl/diagnose.h" #include "rtl/ustring.hxx" @@ -208,9 +210,7 @@ extern "C" void JNICALL abort_handler() [in] represents the maximum version of a JRE. The string can be empty. @param arExcludeList [in] contains a list of "bad" versions. JREs which have one of these - versions must not be returned by this function. It can be NULL. - @param nLenList - [in] the number of version strings contained in <code>arExcludeList</code>. + versions must not be returned by this function. @return javaPluginError::NONE the function ran successfully and the version requirements are met @@ -225,8 +225,7 @@ javaPluginError checkJavaVersionRequirements( rtl::Reference<VendorBase> const & aVendorInfo, OUString const& sMinVersion, OUString const& sMaxVersion, - rtl_uString * * arExcludeList, - sal_Int32 nLenList) + std::vector<OUString> const & arExcludeList) { if (!aVendorInfo->isValidArch()) { @@ -270,9 +269,7 @@ javaPluginError checkJavaVersionRequirements( } } - for (int i = 0; i < nLenList; i++) - { - OUString sExVer(arExcludeList[i]); + for (auto const & sExVer: arExcludeList) { try { if (aVendorInfo->compareVersions(sExVer) == 0) @@ -300,8 +297,7 @@ javaPluginError jfw_plugin_getAllJavaInfos( OUString const& sVendor, OUString const& sMinVersion, OUString const& sMaxVersion, - rtl_uString * *arExcludeList, - sal_Int32 nLenList, + std::vector<OUString> const &arExcludeList, JavaInfo*** parJavaInfo, sal_Int32 *nLenInfoList, std::vector<rtl::Reference<jfw_plugin::VendorBase>> & infos) @@ -309,10 +305,6 @@ javaPluginError jfw_plugin_getAllJavaInfos( assert(parJavaInfo); assert(nLenInfoList); - //nLenlist contains the number of elements in arExcludeList. - //If no exclude list is provided then nLenList must be 0 - assert( ! (arExcludeList == nullptr && nLenList > 0)); - OSL_ASSERT(!sVendor.isEmpty()); if (sVendor.isEmpty()) return javaPluginError::InvalidArg; @@ -333,7 +325,7 @@ javaPluginError jfw_plugin_getAllJavaInfos( continue; javaPluginError err = checkJavaVersionRequirements( - cur, sMinVersion, sMaxVersion, arExcludeList, nLenList); + cur, sMinVersion, sMaxVersion, arExcludeList); if (err == javaPluginError::FailedVersion || err == javaPluginError::WrongArch) continue; @@ -363,8 +355,7 @@ javaPluginError jfw_plugin_getJavaInfoByPath( OUString const& sVendor, OUString const& sMinVersion, OUString const& sMaxVersion, - rtl_uString * *arExcludeList, - sal_Int32 nLenList, + std::vector<OUString> const &arExcludeList, JavaInfo ** ppInfo) { assert(ppInfo != nullptr); @@ -372,10 +363,6 @@ javaPluginError jfw_plugin_getJavaInfoByPath( if (sPath.isEmpty()) return javaPluginError::InvalidArg; - //nLenlist contains the number of elements in arExcludeList. - //If no exclude list is provided then nLenList must be 0 - assert( ! (arExcludeList == nullptr && nLenList > 0)); - OSL_ASSERT(!sVendor.isEmpty()); if (sVendor.isEmpty()) return javaPluginError::InvalidArg; @@ -388,7 +375,7 @@ javaPluginError jfw_plugin_getJavaInfoByPath( if (!sVendor.equals(aVendorInfo->getVendor())) return javaPluginError::NoJre; javaPluginError errorcode = checkJavaVersionRequirements( - aVendorInfo, sMinVersion, sMaxVersion, arExcludeList, nLenList); + aVendorInfo, sMinVersion, sMaxVersion, arExcludeList); if (errorcode == javaPluginError::NONE) *ppInfo = createJavaInfo(aVendorInfo); @@ -422,8 +409,7 @@ javaPluginError jfw_plugin_getJavaInfoFromJavaHome( infoJavaHome[0], versionInfo.sMinVersion, versionInfo.sMaxVersion, - versionInfo.getExcludeVersions(), - versionInfo.getExcludeVersionSize()); + versionInfo.vecExcludeVersions); if (errorcode == javaPluginError::NONE) { @@ -457,7 +443,7 @@ javaPluginError jfw_plugin_getJavaInfosFromPath( for (ci_pl vendorInfo = vecVendorInfos.begin(); vendorInfo != vecVendorInfos.end(); ++vendorInfo) { const OUString& vendor = vendorInfo->first; - jfw::VersionInfo versionInfo = vendorInfo->second; + jfw::VersionInfo const & versionInfo = vendorInfo->second; if (vendor.equals(currentInfo->getVendor())) { @@ -465,8 +451,7 @@ javaPluginError jfw_plugin_getJavaInfosFromPath( currentInfo, versionInfo.sMinVersion, versionInfo.sMaxVersion, - versionInfo.getExcludeVersions(), - versionInfo.getExcludeVersionSize()); + versionInfo.vecExcludeVersions); if (errorcode == javaPluginError::NONE) { diff --git a/jvmfwk/source/elements.cxx b/jvmfwk/source/elements.cxx index 70c38e852eaf..b25c49f07104 100644 --- a/jvmfwk/source/elements.cxx +++ b/jvmfwk/source/elements.cxx @@ -171,43 +171,6 @@ void createSettingsStructure(xmlDoc * document, bool * bNeedsSave) xmlAddChild(root, nodeCrLf); } - -VersionInfo::VersionInfo(): arVersions(nullptr) -{ -} - -VersionInfo::~VersionInfo() -{ -} - -void VersionInfo::addExcludeVersion(const OUString& sVersion) -{ - vecExcludeVersions.push_back(sVersion); -} - -rtl_uString** VersionInfo::getExcludeVersions() -{ - osl::MutexGuard guard(FwkMutex::get()); - if (arVersions != nullptr) - return arVersions; - - arVersions = new rtl_uString*[vecExcludeVersions.size()]; - int j=0; - typedef std::vector<OUString>::const_iterator it; - for (it i = vecExcludeVersions.begin(); i != vecExcludeVersions.end(); - ++i, ++j) - { - arVersions[j] = vecExcludeVersions[j].pData; - } - return arVersions; -} - -sal_Int32 VersionInfo::getExcludeVersionSize() -{ - return vecExcludeVersions.size(); -} - - NodeJava::NodeJava(Layer layer): m_layer(layer) { diff --git a/jvmfwk/source/framework.cxx b/jvmfwk/source/framework.cxx index 5ae4c8773f71..99b3e5e329dd 100644 --- a/jvmfwk/source/framework.cxx +++ b/jvmfwk/source/framework.cxx @@ -93,8 +93,7 @@ javaFrameworkError jfw_findAllJREs(std::vector<std::unique_ptr<JavaInfo>> *pparI vendor, versionInfo.sMinVersion, versionInfo.sMaxVersion, - versionInfo.getExcludeVersions(), - versionInfo.getExcludeVersionSize(), + versionInfo.vecExcludeVersions, & arInfos, & cInfos, infos); @@ -121,8 +120,7 @@ javaFrameworkError jfw_findAllJREs(std::vector<std::unique_ptr<JavaInfo>> *pparI vendor, versionInfo.sMinVersion, versionInfo.sMaxVersion, - versionInfo.getExcludeVersions(), - versionInfo.getExcludeVersionSize(), + versionInfo.vecExcludeVersions, & aInfo.pInfo); if (plerr == javaPluginError::NoJre) continue; @@ -480,8 +478,7 @@ javaFrameworkError jfw_findAndSelectJRE(std::unique_ptr<JavaInfo> *pInfo) vendor, versionInfo.sMinVersion, versionInfo.sMaxVersion, - versionInfo.getExcludeVersions(), - versionInfo.getExcludeVersionSize(), + versionInfo.vecExcludeVersions, & arInfos, & cInfos, infos); @@ -551,8 +548,7 @@ javaFrameworkError jfw_findAndSelectJRE(std::unique_ptr<JavaInfo> *pInfo) vendor, versionInfo.sMinVersion, versionInfo.sMaxVersion, - versionInfo.getExcludeVersions(), - versionInfo.getExcludeVersionSize(), + versionInfo.vecExcludeVersions, & aInfo.pInfo); if (err == javaPluginError::NoJre) continue; @@ -717,8 +713,7 @@ javaFrameworkError jfw_getJavaInfoByPath(OUString const & pPath, std::unique_ptr vendor, versionInfo.sMinVersion, versionInfo.sMaxVersion, - versionInfo.getExcludeVersions(), - versionInfo.getExcludeVersionSize(), + versionInfo.vecExcludeVersions, & pInfo); if (plerr == javaPluginError::NONE) diff --git a/jvmfwk/source/fwkbase.cxx b/jvmfwk/source/fwkbase.cxx index df2e41e4994f..27950eb11630 100644 --- a/jvmfwk/source/fwkbase.cxx +++ b/jvmfwk/source/fwkbase.cxx @@ -191,7 +191,7 @@ VersionInfo VendorSettings::getVersionInformation(const OUString & sVendor) OString osVersion(sVersion); OUString usVersion = OStringToOUString( osVersion, RTL_TEXTENCODING_UTF8); - aVersionInfo.addExcludeVersion(usVersion); + aVersionInfo.vecExcludeVersions.push_back(usVersion); } } cur = cur->next; |