mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Bug 568079: Reducing transitions from JAVA to native code (part 1)
Advapi32Util.registryGetValues() is more efficient to fetch all the values since the regiter only needs to be opened once. XXX: Due to a cycle in the dependencies we need to split this in two parts, this commit handles the core.native API change and the next commit handles the use of the new API Change-Id: Ifd9f1ccc44c652ef3b517278bd342a486155c5fb Signed-off-by: Torbjörn Svensson <azoff@svenskalinuxforeningen.se>
This commit is contained in:
parent
7d7d21cc67
commit
d0c3b2aaff
6 changed files with 50 additions and 6 deletions
|
@ -2,7 +2,7 @@ Manifest-Version: 1.0
|
|||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: %pluginName
|
||||
Bundle-SymbolicName: org.eclipse.cdt.core.native;singleton:=true
|
||||
Bundle-Version: 6.0.100.qualifier
|
||||
Bundle-Version: 6.1.0.qualifier
|
||||
Bundle-Activator: org.eclipse.cdt.internal.core.natives.CNativePlugin
|
||||
Bundle-Vendor: %providerName
|
||||
Bundle-Localization: plugin
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<version>6.0.100-SNAPSHOT</version>
|
||||
<version>6.1.0-SNAPSHOT</version>
|
||||
<artifactId>org.eclipse.cdt.core.native</artifactId>
|
||||
<packaging>eclipse-plugin</packaging>
|
||||
|
||||
|
|
|
@ -13,6 +13,8 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.utils;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.cdt.internal.core.natives.CNativePlugin;
|
||||
import org.eclipse.core.runtime.CoreException;
|
||||
|
||||
|
@ -51,6 +53,15 @@ public abstract class WindowsRegistry {
|
|||
*/
|
||||
public abstract String getLocalMachineValue(String subkey, String name);
|
||||
|
||||
/**
|
||||
* Given a subkey of HKEY_LOCAL_MACHINE, return the map of valueName => value.
|
||||
* The return value is an empty map on error or when the subkey does not exist.
|
||||
* @param subkey subkey of HKEY_LOCAL_MACHINE
|
||||
* @return valueName => value map of the entries in subkey
|
||||
* @since 6.1
|
||||
*/
|
||||
public abstract Map<String, Object> getLocalMachineValues(String subkey);
|
||||
|
||||
/**
|
||||
* Given a subkey of HKEY_LOCAL_MACHINE, and an index (starting from 0)
|
||||
* to the key's array of values, return the name of the indexed value.
|
||||
|
@ -69,7 +80,7 @@ public abstract class WindowsRegistry {
|
|||
* The return value is null on any error or when the index is invalid.
|
||||
* The key name can be used in the above getLocalMachineValueName()
|
||||
* to retrieve value names.
|
||||
* @param subkey subkey of HKEY_CURRENT_USER
|
||||
* @param subkey subkey of HKEY_LOCAL_MACHINE
|
||||
* @param index index to the subkey's array of values, starting from 0.
|
||||
* @return name of registry value or null if not found
|
||||
*/
|
||||
|
@ -85,6 +96,15 @@ public abstract class WindowsRegistry {
|
|||
*/
|
||||
public abstract String getCurrentUserValue(String subkey, String name);
|
||||
|
||||
/**
|
||||
* Given a subkey of HKEY_CURRENT_USER, return the map of valueName => value.
|
||||
* The return value is an empty map on error or when the subkey does not exist.
|
||||
* @param subkey subkey of HKEY_CURRENT_USER
|
||||
* @return valueName => value map of the entries in subkey
|
||||
* @since 6.1
|
||||
*/
|
||||
public abstract Map<String, Object> getCurrentUserValues(String subkey);
|
||||
|
||||
/**
|
||||
* Given a subkey of HKEY_CURRENT_USER, and an index (starting from 0)
|
||||
* to the key's array of values, return the name of the indexed value.
|
||||
|
|
|
@ -2,9 +2,9 @@ Manifest-Version: 1.0
|
|||
Bundle-ManifestVersion: 2
|
||||
Bundle-Name: %fragmentName.win32
|
||||
Bundle-SymbolicName: org.eclipse.cdt.core.win32; singleton:=true
|
||||
Bundle-Version: 6.0.0.qualifier
|
||||
Bundle-Version: 6.0.100.qualifier
|
||||
Bundle-Vendor: %providerName
|
||||
Fragment-Host: org.eclipse.cdt.core.native;bundle-version="[6.0.0,7.0.0)"
|
||||
Fragment-Host: org.eclipse.cdt.core.native;bundle-version="[6.1.0,7.0.0)"
|
||||
Bundle-Localization: plugin
|
||||
Bundle-RequiredExecutionEnvironment: JavaSE-11
|
||||
Eclipse-PlatformFilter: (osgi.os=win32)
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
<relativePath>../../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<version>6.0.0-SNAPSHOT</version>
|
||||
<version>6.0.100-SNAPSHOT</version>
|
||||
<artifactId>org.eclipse.cdt.core.win32</artifactId>
|
||||
<packaging>eclipse-plugin</packaging>
|
||||
|
||||
|
|
|
@ -13,6 +13,9 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.internal.core.win32;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
|
||||
import org.eclipse.cdt.internal.core.natives.CNativePlugin;
|
||||
import org.eclipse.cdt.utils.WindowsRegistry;
|
||||
import org.eclipse.core.runtime.Platform;
|
||||
|
@ -41,6 +44,11 @@ public class WindowsRegistryImpl extends WindowsRegistry {
|
|||
return getValue(WinReg.HKEY_LOCAL_MACHINE, subkey, name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getLocalMachineValues(String subkey) {
|
||||
return getValues(WinReg.HKEY_LOCAL_MACHINE, subkey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLocalMachineValueName(String subkey, int index) {
|
||||
return getValueName(WinReg.HKEY_LOCAL_MACHINE, subkey, index);
|
||||
|
@ -56,6 +64,11 @@ public class WindowsRegistryImpl extends WindowsRegistry {
|
|||
return getValue(WinReg.HKEY_CURRENT_USER, subkey, name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getCurrentUserValues(String subkey) {
|
||||
return getValues(WinReg.HKEY_CURRENT_USER, subkey);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCurrentUserValueName(String subkey, int index) {
|
||||
return getValueName(WinReg.HKEY_CURRENT_USER, subkey, index);
|
||||
|
@ -118,4 +131,15 @@ public class WindowsRegistryImpl extends WindowsRegistry {
|
|||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private Map<String, Object> getValues(HKEY key, String subkey) {
|
||||
try {
|
||||
return Advapi32Util.registryGetValues(key, subkey);
|
||||
} catch (Win32Exception e) {
|
||||
if (DEBUG) {
|
||||
CNativePlugin.log(String.format("Unable to get values for %s", subkey), e); //$NON-NLS-1$
|
||||
}
|
||||
return Collections.emptyMap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue