From 2ed090e98929a1ab98fb80e0dc573e4b9ff01e22 Mon Sep 17 00:00:00 2001 From: Speiger Date: Tue, 6 Dec 2022 04:09:40 +0100 Subject: [PATCH] Fixed a few bugs and Started the Set compilation. --- ModulSettings.json | 107 ++++++++++++++++-- .../builder/PrimitiveCollectionsBuilder.java | 2 +- .../src/builder/modules/MapModule.java | 5 +- .../src/builder/modules/SetModule.java | 70 +++++++++++- .../templates/utils/maps/Maps.template | 5 +- 5 files changed, 169 insertions(+), 20 deletions(-) diff --git a/ModulSettings.json b/ModulSettings.json index ec1c9e1..ef31735 100644 --- a/ModulSettings.json +++ b/ModulSettings.json @@ -108,9 +108,6 @@ "ArrayList": true, "LinkedList": true }, - "Set": { - "Enabled": true - }, "Async": { "Enabled": true } @@ -369,7 +366,18 @@ "LinkedList": true }, "Set": { - "Enabled": true + "Enabled": true, + "LinkedHashSet": true, + "LinkedCustomHashSet": true, + "OrderedSet": true, + "ArraySet": true, + "AVLTreeSet": true, + "ImmutableSet": true, + "CustomHashSet": true, + "Sets": true, + "SortedSet": true, + "HashSet": true, + "RBTreeSet": true }, "Async": { "Enabled": true @@ -629,7 +637,18 @@ "LinkedList": true }, "Set": { - "Enabled": true + "Enabled": true, + "LinkedHashSet": true, + "LinkedCustomHashSet": true, + "OrderedSet": true, + "ArraySet": true, + "AVLTreeSet": true, + "ImmutableSet": true, + "CustomHashSet": true, + "Sets": true, + "SortedSet": true, + "HashSet": true, + "RBTreeSet": true }, "Async": { "Enabled": true @@ -889,7 +908,18 @@ "LinkedList": true }, "Set": { - "Enabled": true + "Enabled": true, + "LinkedHashSet": true, + "LinkedCustomHashSet": true, + "OrderedSet": true, + "ArraySet": true, + "AVLTreeSet": true, + "ImmutableSet": true, + "CustomHashSet": true, + "Sets": true, + "SortedSet": true, + "HashSet": true, + "RBTreeSet": true }, "Async": { "Enabled": true @@ -1149,7 +1179,18 @@ "LinkedList": true }, "Set": { - "Enabled": true + "Enabled": true, + "LinkedHashSet": true, + "LinkedCustomHashSet": true, + "OrderedSet": true, + "ArraySet": true, + "AVLTreeSet": true, + "ImmutableSet": true, + "CustomHashSet": true, + "Sets": true, + "SortedSet": true, + "HashSet": true, + "RBTreeSet": true }, "Async": { "Enabled": true @@ -1409,7 +1450,18 @@ "LinkedList": true }, "Set": { - "Enabled": true + "Enabled": true, + "LinkedHashSet": true, + "LinkedCustomHashSet": true, + "OrderedSet": true, + "ArraySet": true, + "AVLTreeSet": true, + "ImmutableSet": true, + "CustomHashSet": true, + "Sets": true, + "SortedSet": true, + "HashSet": true, + "RBTreeSet": true }, "Async": { "Enabled": true @@ -1669,7 +1721,18 @@ "LinkedList": true }, "Set": { - "Enabled": true + "Enabled": true, + "LinkedHashSet": true, + "LinkedCustomHashSet": true, + "OrderedSet": true, + "ArraySet": true, + "AVLTreeSet": true, + "ImmutableSet": true, + "CustomHashSet": true, + "Sets": true, + "SortedSet": true, + "HashSet": true, + "RBTreeSet": true }, "Async": { "Enabled": true @@ -1929,7 +1992,18 @@ "LinkedList": true }, "Set": { - "Enabled": true + "Enabled": true, + "LinkedHashSet": true, + "LinkedCustomHashSet": true, + "OrderedSet": true, + "ArraySet": true, + "AVLTreeSet": true, + "ImmutableSet": true, + "CustomHashSet": true, + "Sets": true, + "SortedSet": true, + "HashSet": true, + "RBTreeSet": true }, "Async": { "Enabled": true @@ -2189,7 +2263,18 @@ "LinkedList": true }, "Set": { - "Enabled": true + "Enabled": true, + "LinkedHashSet": true, + "LinkedCustomHashSet": true, + "OrderedSet": true, + "ArraySet": true, + "AVLTreeSet": true, + "ImmutableSet": true, + "CustomHashSet": true, + "Sets": true, + "SortedSet": true, + "HashSet": true, + "RBTreeSet": true }, "Async": { "Enabled": true diff --git a/src/builder/java/speiger/src/builder/PrimitiveCollectionsBuilder.java b/src/builder/java/speiger/src/builder/PrimitiveCollectionsBuilder.java index e495c6f..bf6e8ec 100644 --- a/src/builder/java/speiger/src/builder/PrimitiveCollectionsBuilder.java +++ b/src/builder/java/speiger/src/builder/PrimitiveCollectionsBuilder.java @@ -240,7 +240,7 @@ public class PrimitiveCollectionsBuilder extends TemplateProcessor boolean tests = flags.contains("tests"); boolean forceTests = flags.contains("force-tests"); boolean load = flags.contains("load"); - boolean save = flags.contains("save"); + boolean save = !flags.contains("save"); int flag = (load ? LOAD : 0) | (save ? SAVE : 0); new PrimitiveCollectionsBuilder(silent).setFlags(flag).process(force); if(tests) { diff --git a/src/builder/java/speiger/src/builder/modules/MapModule.java b/src/builder/java/speiger/src/builder/modules/MapModule.java index 1356449..25d396e 100644 --- a/src/builder/java/speiger/src/builder/modules/MapModule.java +++ b/src/builder/java/speiger/src/builder/modules/MapModule.java @@ -33,7 +33,8 @@ public class MapModule extends BaseModule } @Override - protected void loadFlags() { + protected void loadFlags() + { if(isModuleEnabled()) addFlag("MAP_MODULE"); if(isModuleEnabled("Maps")) addFlag("Maps"); boolean hashMap = isModuleEnabled("HashMap"); @@ -81,7 +82,7 @@ public class MapModule extends BaseModule if(enumMap) addBlockedFiles("EnumMap"); if(enumMap || ordered || !isModuleEnabled("LinkedEnumMap")) addBlockedFiles("LinkedEnumMap"); - if(ordered || isModuleEnabled("ArrayMap")) addBlockedFiles("ArrayMap"); + if(ordered || !isModuleEnabled("ArrayMap")) addBlockedFiles("ArrayMap"); boolean sorted = !isModuleEnabled("SortedMap"); if(sorted) addBlockedFiles("SortedMap", "NavigableMap"); diff --git a/src/builder/java/speiger/src/builder/modules/SetModule.java b/src/builder/java/speiger/src/builder/modules/SetModule.java index b5723d6..9d880ae 100644 --- a/src/builder/java/speiger/src/builder/modules/SetModule.java +++ b/src/builder/java/speiger/src/builder/modules/SetModule.java @@ -1,5 +1,9 @@ package speiger.src.builder.modules; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; + import speiger.src.builder.ClassType; @SuppressWarnings("javadoc") @@ -9,12 +13,74 @@ public class SetModule extends BaseModule public String getModuleName() { return "Set"; } @Override protected void loadVariables() {} + @Override - protected void loadFlags() {} + public boolean isModuleValid(ClassType keyType, ClassType valueType) + { + return keyType != ClassType.BOOLEAN; + } + + @Override + public Set getModuleKeys(ClassType keyType, ClassType valueType) + { + Set sets = new HashSet<>(); + sets.add("Sets"); + sets.addAll(Arrays.asList("OrderedSet", "SortedSet")); + sets.addAll(Arrays.asList("ArraySet", "ImmutableSet")); + sets.addAll(Arrays.asList("HashSet", "LinkedHashSet")); + sets.addAll(Arrays.asList("CustomHashSet", "LinkedCustomHashSet")); + sets.addAll(Arrays.asList("AVLTreeSet", "RBTreeSet")); + return sets; + } + + @Override + protected void loadFlags() + { + if(isModuleEnabled()) addFlag("SET_MODULE"); + if(isModuleEnabled("Sets")) addFlag("Sets"); + boolean hashSet = isModuleEnabled("HashSet"); + boolean customHashSet = isModuleEnabled("CustomHashSet"); + + if(isModuleEnabled("OrderedSet")) { + addFlag("ORDERED_SET_FEATURE"); + if(isModuleEnabled("ArraySet")) addFlag("ARRAY_SET_FEATURE"); + if(hashSet && isModuleEnabled("LinkedHashSet")) addFlag("LINKED_SET_FEATURE"); + if(customHashSet && isModuleEnabled("LinkedCustomHashSet")) addFlag("LINKED_CUSTOM_SET_FEATURE"); + } + if(isModuleEnabled("SortedSet")) { + addFlag("SORTED_SET_FEATURE"); + if(isModuleEnabled("AVLTreeSet")) addFlag("AVL_TREE_SET_FEATURE"); + if(isModuleEnabled("RBTreeSet")) addFlag("RB_TREE_SET_FEATURE"); + } + if(isModuleEnabled("ImmutableSet")) addFlag("IMMUTABLE_SET_FEATURE"); + if(hashSet) addFlag("HASH_SET_FEATURE"); + if(customHashSet) addFlag("CUSTOM_HASH_SET_FEATURE"); + } @Override protected void loadBlockades() { + if(!isModuleEnabled()) addBlockedFiles("Set", "AbstractSet"); + if(!isModuleEnabled("Sets")) addBlockedFiles("Sets"); + if(!isModuleEnabled("ImmutableSet")) addBlockedFiles("ImmutableOpenHashSet"); + + boolean ordered = !isModuleEnabled("OrderedSet"); + if(ordered) addBlockedFiles("OrderedSet"); + boolean hashSet = !isModuleEnabled("HashSet"); + if(hashSet) addBlockedFiles("OpenHashSet"); + if(hashSet || ordered || !isModuleEnabled("LinkedHashSet")) addBlockedFiles("LinkedOpenHashSet"); + + boolean customHashSet = !isModuleEnabled("CustomHashSet"); + if(customHashSet) addBlockedFiles("OpenCustomHashSet"); + if(customHashSet || ordered || !isModuleEnabled("LinkedCustomHashSet")) addBlockedFiles("LinkedOpenCustomHashSet"); + + if(ordered || !isModuleEnabled("ArraySet")) addBlockedFiles("ArraySet"); + + boolean sorted = !isModuleEnabled("SortedSet"); + if(sorted) addBlockedFiles("SortedSet", "NavigableSet"); + if(sorted || !isModuleEnabled("AVLTreeSet")) addBlockedFiles("AVLTreeSet"); + if(sorted || !isModuleEnabled("RBTreeSet")) addBlockedFiles("RBTreeSet"); + if(keyType == ClassType.BOOLEAN) { //Main Classes @@ -24,7 +90,7 @@ public class SetModule extends BaseModule //Test Classes addBlockedFiles("SetTests", "SetTestSuiteBuilder"); - addBlockedFiles("OrderedSetTestSuiteBuilder", "TestOrderedSetGenerator", "OrderedSetMoveTester", "OrderedSetNavigationTester", "OrderedMapNavigationTester", "OrderedMapTestSuiteBuilder", "OrderedSetIterationTester"); + addBlockedFiles("OrderedSetTestSuiteBuilder", "TestOrderedSetGenerator", "OrderedSetMoveTester", "OrderedSetNavigationTester", "OrderedSetIterationTester"); addBlockedFiles("SortedSetTestSuiteBuilder", "TestSortedSetGenerator", "SortedSetNaviationTester", "SortedSetSubsetTestSetGenerator", "SortedSetIterationTester", "SortedSetNaviationTester"); addBlockedFiles("NavigableSetTestSuiteBuilder", "TestNavigableSetGenerator", "NavigableSetNavigationTester"); } diff --git a/src/builder/resources/speiger/assets/collections/templates/utils/maps/Maps.template b/src/builder/resources/speiger/assets/collections/templates/utils/maps/Maps.template index ea7954e..d60338c 100644 --- a/src/builder/resources/speiger/assets/collections/templates/utils/maps/Maps.template +++ b/src/builder/resources/speiger/assets/collections/templates/utils/maps/Maps.template @@ -126,8 +126,6 @@ public class MAPS else entries.forEach(action); } -#if !TYPE_BOOLEAN - /** * Helper function that creates a Helper wrapper to synchronize access into the map. * @param map the map that should be synchronized @@ -198,7 +196,7 @@ public class MAPS public static GENERIC_KEY_VALUE_BRACES ORDERED_MAP KEY_VALUE_GENERIC_TYPE synchronize(ORDERED_MAP KEY_VALUE_GENERIC_TYPE map, Object mutex) { return map instanceof SynchronizedOrderedMap ? map : new SynchronizedOrderedMapKV_BRACES(map, mutex); } #endif -#if NAVIGABLE_MAP_FEATURE +#if SORTED_MAP_FEATURE /** * Helper function that creates a Helper wrapper to synchronize access into the NavigableMap. * @param map the NavigableMap that should be synchronized @@ -1174,5 +1172,4 @@ public class MAPS public void forEach(BiConsumer action) { synchronized(mutex) { map.forEach(action); } } #endif } -#endif } \ No newline at end of file