Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import java.nio.file.attribute.BasicFileAttributes;
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.Set;

/**
Expand All @@ -44,12 +44,12 @@ public class WindowsApiRun {
private String basePackage = "";
private EventListener eventListener = new NullEventListener();

private Set<String> structs = new HashSet<>();
private Set<String> functions = new HashSet<>();
private Set<String> enumerations = new HashSet<>();
private Set<String> callbackFunctions = new HashSet<>();
private Set<String> comInterfaces = new HashSet<>();
private Set<String> constants = new HashSet<>();
private Set<String> structs = new LinkedHashSet<>();
private Set<String> functions = new LinkedHashSet<>();
private Set<String> enumerations = new LinkedHashSet<>();
private Set<String> callbackFunctions = new LinkedHashSet<>();
private Set<String> comInterfaces = new LinkedHashSet<>();
private Set<String> constants = new LinkedHashSet<>();

/**
* Creates a new instance.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
Expand All @@ -25,13 +25,13 @@
*/
@SuppressWarnings({"java:S4274", "java:S1192"})
public class Metadata {
private final Map<String, Namespace> namespaces = new HashMap<>();
private final Map<String, Namespace> namespaces = new LinkedHashMap<>();
private final Namespace unnamedNamespace = new Namespace(null);
private final Map<Integer, Type> typesByDefinitionIndex = new HashMap<>();
private final Map<Integer, Method> methodsByMethodDefIndex = new HashMap<>();
private final Map<Integer, Type> typesByDefinitionIndex = new LinkedHashMap<>();
private final Map<Integer, Method> methodsByMethodDefIndex = new LinkedHashMap<>();
private final Map<PrimitiveKind, Primitive> primitivesByKind = buildPrimitiveTypes(unnamedNamespace);
private final Map<Type, Pointer> pointersByType = new HashMap<>();
private final Map<Integer, TypeAlias> aliasesByTypeDefIndex = new HashMap<>();
private final Map<Type, Pointer> pointersByType = new LinkedHashMap<>();
private final Map<Integer, TypeAlias> aliasesByTypeDefIndex = new LinkedHashMap<>();

/**
* Creates a new instance.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//
package net.codecrete.windowsapi.metadata;

import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;

/**
Expand All @@ -18,9 +18,9 @@
@SuppressWarnings("java:S4274")
public class Namespace {
private final String name;
private final Map<String, Type> types = new HashMap<>();
private final Map<String, Method> methods = new HashMap<>();
private final Map<String, ConstantValue> constants = new HashMap<>();
private final Map<String, Type> types = new LinkedHashMap<>();
private final Map<String, Method> methods = new LinkedHashMap<>();
private final Map<String, ConstantValue> constants = new LinkedHashMap<>();

/**
* Creates a new instance.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
package net.codecrete.windowsapi.metadata;

import java.util.Collection;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;
Expand Down Expand Up @@ -143,7 +143,7 @@ public Struct enclosingType() {
*/
public void addNestedType(Type nestedType) {
if (nestedTypes == null)
nestedTypes = new HashMap<>();
nestedTypes = new LinkedHashMap<>();
assert !nestedTypes.containsKey(nestedType.name());
nestedTypes.put(nestedType.name(), nestedType);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
Expand Down Expand Up @@ -65,7 +65,7 @@ public class MetadataBuilder implements TypeLookup {
private final VariantTransformation variantTransformation;
private final Primitive[] primitiveTypes = new Primitive[15];
private final CustomAttributeDecoder customAttributeDecoder;
private final Map<Integer, Namespace> apiTypes = new HashMap<>();
private final Map<Integer, Namespace> apiTypes = new LinkedHashMap<>();
private final SignatureDecoder signatureDecoder;
private final Primitive intPtrType;
private final Primitive uintPtrType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
import net.codecrete.windowsapi.metadata.Type;
import net.codecrete.windowsapi.metadata.TypeAlias;

import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
Expand All @@ -45,8 +45,8 @@ class VariantTransformation {
private static final int ARM64_OFFSET = 1000000;

private final Metadata metadata;
private final HashMap<String, HashMap<Integer, Type>> typeVariants = new HashMap<>();
private final Set<Integer> unsupportedVariants = new HashSet<>();
private final Map<String, Map<Integer, Type>> typeVariants = new LinkedHashMap<>();
private final Set<Integer> unsupportedVariants = new LinkedHashSet<>();

VariantTransformation(Metadata metadata) {
this.metadata = metadata;
Expand Down Expand Up @@ -77,7 +77,7 @@ boolean preprocessType(Type type, int architecture) {
return false;

assert type instanceof Struct || type instanceof Delegate;
var variants = typeVariants.computeIfAbsent(type.name(), k -> new HashMap<>());
var variants = typeVariants.computeIfAbsent(type.name(), k -> new LinkedHashMap<>());
variants.put(architecture, type);
if (type instanceof Struct struct)
struct.setArchitectureSpecific(true);
Expand Down Expand Up @@ -126,7 +126,7 @@ boolean preprocessMethod(Method method, int architecture) {
* </p>
*/
void splitCombinedVariants() {
var architectureSpecificCache = new HashMap<Type, Boolean>();
var architectureSpecificCache = new LinkedHashMap<Type, Boolean>();

// identify types that are indirectly architecture-specific
var indirectlySpecificTypes = metadata.types()
Expand All @@ -136,8 +136,8 @@ void splitCombinedVariants() {
.map(Struct.class::cast)
.collect(Collectors.toSet());

var x64Replacements = new HashMap<Type, Type>();
var arm64Replacements = new HashMap<Type, Type>();
var x64Replacements = new LinkedHashMap<Type, Type>();
var arm64Replacements = new LinkedHashMap<Type, Type>();

// create two separate variants for each indirectly architecture-specific type
for (var type : indirectlySpecificTypes) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

import java.util.ArrayList;
import java.util.Collection;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;

Expand Down Expand Up @@ -129,7 +129,7 @@ boolean isForStruct() {
* @return the required address layouts
*/
static List<AddressLayout> requiredLayouts(Struct struct) {
var addressLayouts = new HashSet<AddressLayout>();
var addressLayouts = new LinkedHashSet<AddressLayout>();
addLayoutsRecursively(struct, struct.packageSize(), addressLayouts);
return filteredAndSorted(addressLayouts);
}
Expand All @@ -141,7 +141,7 @@ static List<AddressLayout> requiredLayouts(Struct struct) {
* @return the required address layouts
*/
static List<AddressLayout> requiredLayouts(Collection<Method> functions) {
var addressLayouts = new HashSet<AddressLayout>();
var addressLayouts = new LinkedHashSet<AddressLayout>();
functions.stream().flatMap(Method::referencedTypes).forEach(it -> addLayout(it, addressLayouts));
return filteredAndSorted(addressLayouts);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.Set;

/**
Expand Down Expand Up @@ -135,7 +135,7 @@ public void setDryRun(boolean isDryRun) {
*/
public void write(Scope scope) {
if (!isDryRun)
generatedFiles = new HashSet<>();
generatedFiles = new LinkedHashSet<>();
scope.getTransitiveTypeScope().forEach(this::writeType);
scope.getFunctions().forEach(functionCodeWriter::writeFunctions);
scope.getConstants().forEach(constantCodeWriter::writeConstants);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import net.codecrete.windowsapi.metadata.TypeAlias;

import java.util.Collection;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
Expand All @@ -39,10 +39,10 @@ public class Scope {
private static final String ENUMERATION_MEMBER_SINGLE = "%s Enumeration \"%s\" contains a member with that name. " +
"Specify the enumeration instead of the constant.";

private final Set<Type> typeSet = new HashSet<>();
private final Set<Method> methodSet = new HashSet<>();
private final Set<ConstantValue> constantSet = new HashSet<>();
private final Set<Type> transitiveScope = new HashSet<>();
private final Set<Type> typeSet = new LinkedHashSet<>();
private final Set<Method> methodSet = new LinkedHashSet<>();
private final Set<ConstantValue> constantSet = new LinkedHashSet<>();
private final Set<Type> transitiveScope = new LinkedHashSet<>();
private final Metadata metadata;
private final EventListener eventListener;
private boolean hasInvalidArguments = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import net.codecrete.windowsapi.winmd.LayoutRequirement;

import java.util.Comparator;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
import java.util.regex.Pattern;
Expand Down Expand Up @@ -520,7 +520,7 @@ private void writeStructComment() {
}

private static Set<Struct> getUnalignedMemberStructs(Struct struct, int packageSize) {
var unalignedStructs = new HashSet<Struct>();
var unalignedStructs = new LinkedHashSet<Struct>();
collectUnalignedMemberStructs(struct, packageSize, unalignedStructs);
return unalignedStructs;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

import java.io.File;
import java.nio.file.Path;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;

/**
Expand Down Expand Up @@ -151,17 +151,17 @@ private WindowsApiRun createRun(Path sourceFolder) {
run.setEventListener(new EventLogger(getLog()));

if (functions != null)
run.setFunctions(new HashSet<>(functions));
run.setFunctions(new LinkedHashSet<>(functions));
if (structs != null)
run.setStructs(new HashSet<>(structs));
run.setStructs(new LinkedHashSet<>(structs));
if (enumerations != null)
run.setEnumerations(new HashSet<>(enumerations));
run.setEnumerations(new LinkedHashSet<>(enumerations));
if (callbackFunctions != null)
run.setCallbackFunctions(new HashSet<>(callbackFunctions));
run.setCallbackFunctions(new LinkedHashSet<>(callbackFunctions));
if (comInterfaces != null)
run.setComInterfaces(new HashSet<>(comInterfaces));
run.setComInterfaces(new LinkedHashSet<>(comInterfaces));
if (constants != null)
run.setConstants(new HashSet<>(constants));
run.setConstants(new LinkedHashSet<>(constants));

run.setOutputDirectory(sourceFolder);
run.setBasePackage(basePackage != null ? basePackage : "");
Expand Down