Parcourir la source

Promotions overhaul

Billy Barrow il y a 4 jours
Parent
commit
b9118aa6a9

+ 0 - 4
src/lib/ByteComposition.vala

@@ -210,10 +210,6 @@ namespace Invercargill {
             return amount != 0;
         }
 
-        public bool equals(Enumerable<uint8> other) {
-            return this == other || matches(other, (a, b) => a == b);
-        }
-
         public uint hash_code() {
             return aggregate<uint>(5381, (h, b) => h * 33 + b);
         }

+ 1 - 5
src/lib/DataStructures/ByteBuffer.vala

@@ -1,16 +1,12 @@
 
 namespace Invercargill.DataStructures {
 
-    public class ByteBuffer : Buffer<uint8>, Equatable<Enumerable<uint8>>, Hashable, Sticky<BinaryData, uint8>, BinaryData, ReadOnlyAddressableBytes, AddressableBytes {
+    public class ByteBuffer : Buffer<uint8>, Hashable, Sticky<BinaryData, uint8>, BinaryData, ReadOnlyAddressableBytes, AddressableBytes {
 
         public ByteBuffer(uint size) {
             base(size);
         }
 
-        public bool equals(Enumerable<uint8> other) {
-            return this == other || matches(other, (a, b) => a == b);
-        }
-
         public uint hash_code() {
             return aggregate<uint>(5381, (h, b) => h * 33 + b);
         }

+ 1 - 1
src/lib/DataStructures/HashSet.vala

@@ -157,7 +157,7 @@ namespace Invercargill.DataStructures {
             return try_find(item, out _);
         }
 
-        public bool equals(Enumerable<T> other) {
+        public override bool equals(Enumerable<T> other) {
             if(other == this) {
                 return true;
             }

+ 1 - 1
src/lib/Debug.vala

@@ -146,7 +146,7 @@ namespace Invercargill {
             if(type.is_a(typeof(Properties))) {
                 names.add("Properties");
             }
-            if(type.is_a(typeof(Promotion))) {
+            if(type.is_a(typeof(PromotionWrapper))) {
                 names.add("Promotion");
             }
 

+ 5 - 1
src/lib/Element.vala

@@ -1,7 +1,11 @@
 using Invercargill.DataStructures;
 namespace Invercargill {
     
-    private class ElementSeries : Series<Element>, Elements {}
+    private class ElementSeries : Series<Element>, Sticky<Elements, Element>, Elements {
+        protected Elements adhere(Enumerable<Element> enumerable) {
+            return enumerable.assert_promotion<Elements>();
+        }
+    }
 
 
     public interface Element : Object {

+ 15 - 6
src/lib/Enumerable.vala

@@ -4,7 +4,7 @@ using Invercargill.Mapping;
 
 namespace Invercargill {
 
-    public abstract class Enumerable<T> : Object {
+    public abstract class Enumerable<T> : Object, Equatable<Enumerable<T>> {
 
         public abstract Tracker<T> get_tracker();
         public abstract uint? peek_count();
@@ -350,8 +350,17 @@ namespace Invercargill {
             return new MergeQuery<TOut>(fork((owned)fork1, (owned)fork2));
         }
 
-        public virtual bool matches(Enumerable<T> other, EqualityDelegate<T> equals) {
-            return zip<T, bool>(other, p => p.value1_is_set == p.value2_is_set && equals(p.value1, p.value2)).all(r => r);
+        public virtual bool matches(Enumerable<T> other, EqualityDelegate<T>? compare_func = null) {
+            return matches_by<T>(other, i => i, compare_func);
+        }
+
+        public virtual bool matches_by<TProp>(Enumerable<T> other, TransformDelegate<T, TProp> property_selector, EqualityDelegate<TProp>? compare_func = null) {
+            var func = compare_func ?? Operators.equality<T>();
+            return zip<T, bool>(other, p => p.value1_is_set == p.value2_is_set && func(property_selector(p.value1), property_selector(p.value2))).all(r => r);
+        }
+
+        public virtual bool equals(Enumerable<T> other) {
+            return this == other || matches(other);
         }
 
         public virtual Enumerable<T> act(ItemDelegate<T> handler) {
@@ -554,7 +563,7 @@ namespace Invercargill {
             if(!type.is_instantiatable()) {
                 throw new PromotionError.INVALID_PROMOTION_TYPE(@"Promotion type $(type.name()) is not instansiatable.");
             }
-            if(!type.is_a(typeof(Promotion))) {
+            if(!type.is_a(typeof(PromotionWrapper))) {
                 throw new PromotionError.INVALID_PROMOTION_TYPE(@"Promotion type $(type.name()) does not implement Invercargill.Promotion.");
             }
             if(!type.is_a(typeof(Enumerable)) && typeof(TPromotion) == type) {
@@ -562,11 +571,11 @@ namespace Invercargill {
             }
 
             var promotion = Object.new(type);
-            if(!((Promotion)promotion).can_wrap(element_type)) {
+            if(!((PromotionWrapper)promotion).call_can_wrap(element_type)) {
                 throw new PromotionError.INCOMPATIBLE_ELEMENT_TYPE(@"Enumerable has an element type of $(element_type.name()) which cannot be wrapped by $(type.name())");
             }
 
-            return ((Promotion)promotion).wrap(this);
+            return ((PromotionWrapper<T, TPromotion>)promotion).call_wrap(this);
         }
 
         public virtual TPromotion assert_promotion<TPromotion>() {

+ 1 - 43
src/lib/Interfaces/BinaryData.vala

@@ -1,48 +1,6 @@
-using Invercargill.DataStructures;
 
-namespace Invercargill {
-
-    public interface BinaryData : Enumerable<uint8>, Sticky<BinaryData, uint8>, Equatable<Enumerable<uint8>>, Hashable {
-
-        public virtual string to_raw_string(bool null_terminate = true) {
-            Enumerable<uint8> data = this;
-            if(null_terminate) {
-                data.concat(Iterate.single<uint8>(0));
-            }
-            return (string)data.to_array();
-        }
-
-        public virtual string to_base64() {
-            return Base64.encode(to_array());
-        }
-
-        public virtual string to_hex() {
-            return to_string(i => i.to_string("%x"));
-        }
 
-        public virtual Bytes to_bytes() {
-            return new Bytes(to_array());
-        }
-
-        public virtual ByteBuffer to_byte_buffer() {
-            return new ByteBuffer.from_enumerable(this);
-        }
-
-        public virtual BinaryData slice(uint start, uint end) {
-            return skip(start).take(end-start).assert_promotion<BinaryData>();
-        }
-
-        public virtual ByteBuffer read(uint start, uint length) {
-            return new ByteBuffer.from_enumerable(skip(start).take(length));
-        }
+namespace Invercargill {
 
-        public virtual size_t write_to(void* array, size_t max_size) {
-            var data = to_array();
-            var size = max_size > data.length ? data.length : max_size;
-            Memory.copy(array, data, size);
-            return size;
-        }
-        
-    }
 
 }

+ 13 - 3
src/lib/Promotion.vala

@@ -17,14 +17,24 @@ namespace Invercargill {
         Type promotion;
         if(promotion_registry.try_get(typeof(T), out promotion)) {
             type = promotion;
+            print(@"Mapped $(typeof(T).name()) -> $(promotion.name())\n");
         }
     }
 
-    public interface Promotion<T> {
 
-        public abstract Enumerable<T> wrap(Enumerable<T> enumerable) throws PromotionError;
+    public interface PromotionWrapper<TSelf, T> : Enumerable<T>, Sticky<TSelf, T> {
+
+        protected abstract bool can_wrap(Type element_type);
+        protected abstract TSelf wrap(Enumerable<T> enumerable);
+
+        internal TSelf call_wrap(Enumerable<T> enumerable) {
+            return wrap(enumerable);
+        }
+
+        internal bool call_can_wrap(Type element_type) {
+            return can_wrap(element_type);
+        }
 
-        public abstract bool can_wrap(Type element_type);
     }
 
 }

+ 11 - 3
src/lib/Promotions/Attempts.vala

@@ -3,15 +3,23 @@ using Invercargill.Mapping;
 
 namespace Invercargill {
 
-    public class Attempts<T> : Proxy<Attempt<T>>, Promotion<Attempt<T>> {
+    public class Attempts<T> : StickyProxyPromotion<Attempts<T>, Attempt<T>> {
 
-        public Enumerable<Attempt<T>> wrap (Enumerable<Attempt<T>> enumerable) {
+        public override Attempts<T> wrap (Enumerable<Attempt<T>> enumerable) {
             inner = enumerable;
             results = inner.where(a => a.success).select<T>(a => a.result);
             errors = inner.where(a => !a.success).select<Error>(a => a.error);
             return this;
         }
-        public bool can_wrap (GLib.Type element_type) {
+
+        protected override Attempts<T> adhere(Enumerable<Attempt<T>> enumerable) {
+            return new Attempts<T>().wrap(enumerable);
+        }
+        protected override Attempts<T> passthrough() {
+            return this;
+        }
+
+        public override bool can_wrap (GLib.Type element_type) {
             return element_type.is_a (typeof(Attempt));
         }
 

+ 48 - 10
src/lib/Promotions/BinaryData.vala

@@ -1,30 +1,68 @@
+using Invercargill.DataStructures;
 using Invercargill.Mapping;
 
 namespace Invercargill {
 
-    private class BinaryDataPromotionImplementation : StickyPromotion<uint8, BinaryData>, Promotion<uint8>, Equatable<Enumerable<uint8>>, Hashable, BinaryData {
+    public interface BinaryData : Enumerable<uint8>, Sticky<BinaryData, uint8>, Equatable<Enumerable<uint8>>, Hashable {
 
-        public override Enumerable<uint8> wrap (Enumerable<uint8> enumerable) {
-            inner = enumerable;
-            return this;
+        public virtual string to_raw_string(bool null_terminate = true) {
+            Enumerable<uint8> data = this;
+            if(null_terminate) {
+                data.concat(Iterate.single<uint8>(0));
+            }
+            return (string)data.to_array();
         }
 
-        public override bool can_wrap (GLib.Type element_type) {
-            return element_type.is_a (typeof(uint8));
+        public virtual string to_base64() {
+            return Base64.encode(to_array());
         }
 
-        public bool equals(Enumerable<uint8> other) {
-            return this == other || matches(other, (a, b) => a == b);
+        public virtual string to_hex() {
+            return to_string(i => i.to_string("%x"));
         }
 
-        public uint hash_code() {
-            return aggregate<uint>(5381, (h, b) => h * 33 + b);
+        public virtual Bytes to_bytes() {
+            return new Bytes(to_array());
+        }
+
+        public virtual ByteBuffer to_byte_buffer() {
+            return new ByteBuffer.from_enumerable(this);
         }
 
+        public virtual BinaryData slice(uint start, uint end) {
+            return skip(start).take(end-start).assert_promotion<BinaryData>();
+        }
+
+        public virtual ByteBuffer read(uint start, uint length) {
+            return new ByteBuffer.from_enumerable(skip(start).take(length));
+        }
+
+        public virtual size_t write_to(void* array, size_t max_size) {
+            var data = to_array();
+            var size = max_size > data.length ? data.length : max_size;
+            Memory.copy(array, data, size);
+            return size;
+        }
+        
+    }
+
+    private class BinaryDataPromotionImplementation : StickyProxyPromotion<BinaryData, uint8>, PromotionWrapper<BinaryData, uint8>, Equatable<Enumerable<uint8>>, Hashable, BinaryData {
+
         protected override BinaryData adhere (Enumerable<uint8> enumerable) {
             return (BinaryData)new BinaryDataPromotionImplementation().wrap(enumerable);
         }
 
+        protected override BinaryData passthrough () {
+            return this;
+        }
+
+        public override bool can_wrap (GLib.Type element_type) {
+            return element_type.is_a (typeof(uint8));
+        }
+
+        public uint hash_code() {
+            return aggregate<uint>(5381, (h, b) => h * 33 + b);
+        }
     }
 
 }

+ 1 - 1
src/lib/Interfaces/Elements.vala → src/lib/Promotions/Elements.vala

@@ -1,5 +1,5 @@
 namespace Invercargill {
-    public interface Elements : Enumerable<Element> {
+    public interface Elements : Enumerable<Element>, Sticky<Elements, Element> {
 
         public virtual Enumerable<T> elements_as<T>() {
             return select_where<T>((e, out r) => e.try_get_as<T>(out r));

+ 0 - 26
src/lib/Promotions/Equatables.vala

@@ -1,26 +0,0 @@
-namespace Invercargill {
-
-    public class Equatables<T> : StickyPromotion<T, Equatables<T>>, Promotion<T>, Equatable<Enumerable<T>> {
-
-        public override bool can_wrap(GLib.Type element_type) {
-            return element_type.is_a(typeof(Equatable));
-        }
-
-        public override Enumerable<T> wrap (Enumerable<T> enumerable) {
-            inner = enumerable;
-            return this;
-        }
-
-        protected override Equatables<T> adhere(Enumerable<T> enumerable) {
-            return (Equatables<T>)new Equatables<T>().wrap(enumerable);
-        }
-
-        public bool equals(Enumerable<T> other) {
-            return this == other || this.matches(other, (a, b) => ((Equatable<T>)a).equals (b));
-        }
-
-
-
-    }
-
-}

+ 60 - 12
src/lib/Promotions/Numbers/Implementations.vala

@@ -1,6 +1,10 @@
 namespace Invercargill {
 
-    public class SignedNativeIntegers : Numbers<int, SignedNativeIntegers> {
+    public class SignedNativeIntegers : Numbers<SignedNativeIntegers, int>, PromotionWrapper<SignedNativeIntegers, int> {
+
+        protected override SignedNativeIntegers passthrough() {
+            return this;
+        }
         protected override SignedNativeIntegers adhere(Enumerable<int> enumerable) {
             return (SignedNativeIntegers)new SignedNativeIntegers().wrap(enumerable);
         }
@@ -36,7 +40,11 @@ namespace Invercargill {
         }        
     }
 
-    public class UnsignedNativeIntegers : Numbers<uint, UnsignedNativeIntegers> {
+    public class UnsignedNativeIntegers : Numbers<UnsignedNativeIntegers, uint> {
+
+        protected override UnsignedNativeIntegers passthrough() {
+            return this;
+        }
         protected override UnsignedNativeIntegers adhere(Enumerable<uint> enumerable) {
             return (UnsignedNativeIntegers)new UnsignedNativeIntegers().wrap(enumerable);
         }
@@ -72,7 +80,11 @@ namespace Invercargill {
         }      
     }
 
-    public class Signed8BitIntegers : Numbers<int8, Signed8BitIntegers> {
+    public class Signed8BitIntegers : Numbers<Signed8BitIntegers, int8> {
+
+        protected override Signed8BitIntegers passthrough() {
+            return this;
+        }
         protected override Signed8BitIntegers adhere(Enumerable<int8> enumerable) {
             return (Signed8BitIntegers)new Signed8BitIntegers().wrap(enumerable);
         }
@@ -108,7 +120,11 @@ namespace Invercargill {
         }      
     }
 
-    public class Unsigned8BitIntegers : Numbers<uint8, Unsigned8BitIntegers> {
+    public class Unsigned8BitIntegers : Numbers<Unsigned8BitIntegers, uint8> {
+
+        protected override Unsigned8BitIntegers passthrough() {
+            return this;
+        }
         protected override Unsigned8BitIntegers adhere(Enumerable<uint8> enumerable) {
             return (Unsigned8BitIntegers)new Unsigned8BitIntegers().wrap(enumerable);
         }
@@ -144,7 +160,11 @@ namespace Invercargill {
         }      
     }
 
-    public class Signed16BitIntegers : Numbers<int16, Signed16BitIntegers> {
+    public class Signed16BitIntegers : Numbers<Signed16BitIntegers, int16> {
+
+        protected override Signed16BitIntegers passthrough() {
+            return this;
+        }
         protected override Signed16BitIntegers adhere(Enumerable<int16> enumerable) {
             return (Signed16BitIntegers)new Signed16BitIntegers().wrap(enumerable);
         }
@@ -180,7 +200,11 @@ namespace Invercargill {
         }      
     }
 
-    public class Unsigned16BitIntegers : Numbers<uint16, Unsigned16BitIntegers> {
+    public class Unsigned16BitIntegers : Numbers<Unsigned16BitIntegers, uint16> {
+
+        protected override Unsigned16BitIntegers passthrough() {
+            return this;
+        }
         protected override Unsigned16BitIntegers adhere(Enumerable<uint16> enumerable) {
             return (Unsigned16BitIntegers)new Unsigned16BitIntegers().wrap(enumerable);
         }
@@ -216,7 +240,11 @@ namespace Invercargill {
         }      
     }
 
-    public class Signed32BitIntegers : Numbers<int32, Signed32BitIntegers> {
+    public class Signed32BitIntegers : Numbers<Signed32BitIntegers, int32> {
+
+        protected override Signed32BitIntegers passthrough() {
+            return this;
+        }
         protected override Signed32BitIntegers adhere(Enumerable<int32> enumerable) {
             return (Signed32BitIntegers)new Signed32BitIntegers().wrap(enumerable);
         }
@@ -252,7 +280,11 @@ namespace Invercargill {
         }      
     }
 
-    public class Unsigned32BitIntegers : Numbers<uint32, Unsigned32BitIntegers> {
+    public class Unsigned32BitIntegers : Numbers<Unsigned32BitIntegers, uint32> {
+
+        protected override Unsigned32BitIntegers passthrough() {
+            return this;
+        }
         protected override Unsigned32BitIntegers adhere(Enumerable<uint32> enumerable) {
             return (Unsigned32BitIntegers)new Unsigned32BitIntegers().wrap(enumerable);
         }
@@ -288,7 +320,11 @@ namespace Invercargill {
         }      
     }
 
-    public class Signed64BitIntegers : Numbers<int64?, Signed64BitIntegers> {
+    public class Signed64BitIntegers : Numbers<Signed64BitIntegers, int64?> {
+
+        protected override Signed64BitIntegers passthrough() {
+            return this;
+        }
         protected override Signed64BitIntegers adhere(Enumerable<int64?> enumerable) {
             return (Signed64BitIntegers)new Signed64BitIntegers().wrap(enumerable);
         }
@@ -324,7 +360,11 @@ namespace Invercargill {
         }      
     }
 
-    public class Unsigned64BitIntegers : Numbers<uint64?, Unsigned64BitIntegers> {
+    public class Unsigned64BitIntegers : Numbers<Unsigned64BitIntegers, uint64?> {
+
+        protected override Unsigned64BitIntegers passthrough() {
+            return this;
+        }
         protected override Unsigned64BitIntegers adhere(Enumerable<uint64?> enumerable) {
             return (Unsigned64BitIntegers)new Unsigned64BitIntegers().wrap(enumerable);
         }
@@ -360,7 +400,11 @@ namespace Invercargill {
         }      
     }
 
-    public class Doubles : Numbers<double?, Doubles> {
+    public class Doubles : Numbers<Doubles, double?> {
+
+        protected override Doubles passthrough() {
+            return this;
+        }
         protected override Doubles adhere(Enumerable<double?> enumerable) {
             return (Doubles)new Doubles().wrap(enumerable);
         }
@@ -396,7 +440,11 @@ namespace Invercargill {
         }      
     }
 
-    public class Floats : Numbers<float?, Floats> {
+    public class Floats : Numbers<Floats, float?> {
+
+        protected override Floats passthrough() {
+            return this;
+        }
         protected override Floats adhere(Enumerable<float?> enumerable) {
             return (Floats)new Floats().wrap(enumerable);
         }

+ 2 - 7
src/lib/Promotions/Numbers/Numbers.vala

@@ -1,6 +1,6 @@
 namespace Invercargill {
 
-    public abstract class Numbers<T, TSelf> : StickyPromotion<T, TSelf>, Promotion<T>, Equatable<Enumerable<T>> {
+    public abstract class Numbers<TSelf, T> : StickyProxyPromotion<TSelf, T>, PromotionWrapper<TSelf, T>, Equatable<Enumerable<T>> {
 
         protected abstract bool greater_than(T a, T b);
         protected abstract bool less_than(T a, T b);
@@ -65,12 +65,7 @@ namespace Invercargill {
             return value;
         }
 
-        public override Enumerable<T> wrap (Enumerable<T> enumerable) {
-            inner = enumerable;
-            return this;
-        }
-
-        public bool equals(Enumerable<T> other) {
+        public override bool equals(Enumerable<T> other) {
             return this == other || this.matches(other, (a, b) => equal_to(a, b));
         }
 

+ 5 - 6
src/lib/Promotions/PropertyGroups.vala

@@ -2,12 +2,7 @@ using Invercargill.Mapping;
 
 namespace Invercargill {
 
-    public class PropertyGroups : StickyPromotion<Properties, PropertyGroups>, Promotion<Properties> {
-
-        public override Enumerable<Properties> wrap (Enumerable<Properties> enumerable) {
-            inner = enumerable;
-            return this;
-        }
+    public class PropertyGroups : StickyProxyPromotion<PropertyGroups, Properties> {
 
         protected override PropertyGroups adhere(Enumerable<Properties> enumerable) {
             return (PropertyGroups)new PropertyGroups().wrap(enumerable);
@@ -21,6 +16,10 @@ namespace Invercargill {
             return inner.attempt_map_with<TOut>(mapper);
         }
 
+        protected override PropertyGroups passthrough() {
+            return this;
+        }
+
     }
 
 }

+ 1 - 4
src/lib/Proxy.vala

@@ -9,6 +9,7 @@ namespace Invercargill {
 
         // NOTE: Do not implement debug functions here (debug_type, debug_dump, or debug_trace)
         // as that will make the proxy invisable to the debug output, and can also cause nasty loops.
+        // We also DO NOT want to implement as_enumerable()
 
         public override EnumerableInfo get_info() {
             return new EnumerableInfo.infer_single(this, EnumerableCategory.PROXY, inner);
@@ -370,10 +371,6 @@ namespace Invercargill {
             return inner.attempt_map_with<TOut>(mapper);
         }
         
-        public override Enumerable<T> as_enumerable() {
-            return inner.as_enumerable();
-        }
-        
         public override Enumerable<Enumerable<T>> chunk(uint chunk_size) {
             return inner.chunk(chunk_size);
         }

+ 0 - 13
src/lib/StickyPromotion.vala

@@ -1,13 +0,0 @@
-namespace Invercargill {
-
-    public abstract class StickyPromotion<T, TPromotion> : StickyProxy<TPromotion, T>, Promotion<T> {
-
-        public abstract Enumerable<T> wrap(Enumerable<T> enumerable);
-        public abstract bool can_wrap(GLib.Type element_type);
-
-        public override TPromotion passthrough() {
-            return (TPromotion)wrap(inner);
-        }
-    }
-
-}

+ 13 - 0
src/lib/StickyProxyPromotion.vala

@@ -0,0 +1,13 @@
+
+namespace Invercargill {
+
+    public abstract class StickyProxyPromotion<TPromotion, T> : StickyProxy<TPromotion, T>, Sticky<TPromotion, T>, PromotionWrapper<TPromotion, T> {
+        protected abstract bool can_wrap (GLib.Type element_type);
+        protected virtual TPromotion wrap (Enumerable<T> enumerable) {
+            inner = enumerable;
+            return passthrough();
+        }
+
+    }
+
+}

+ 6 - 8
src/lib/meson.build

@@ -18,7 +18,6 @@ sources += files('Tracker.vala')
 sources += files('Errors.vala')
 sources += files('SelectionContext.vala')
 sources += files('Safety.vala')
-sources += files('Promotion.vala')
 sources += files('Grouping.vala')
 sources += files('Interfaces.vala')
 sources += files('KeyValuePair.vala')
@@ -26,9 +25,11 @@ sources += files('KeyCountPair.vala')
 sources += files('Attempt.vala')
 sources += files('Cache.vala')
 sources += files('Proxy.vala')
+sources += files('Sticky.vala')
+sources += files('Promotion.vala')
 sources += files('StickyProxy.vala')
+sources += files('StickyProxyPromotion.vala')
 sources += files('EnumerableInfo.vala')
-sources += files('StickyPromotion.vala')
 sources += files('Element.vala')
 sources += files('Debug.vala')
 sources += files('OrderConfiguration.vala')
@@ -37,7 +38,6 @@ sources += files('Wrap.vala')
 sources += files('Partition.vala')
 sources += files('Composition.vala')
 sources += files('ByteComposition.vala')
-sources += files('Sticky.vala')
 
 sources += files('Modifiers/Transform.vala')
 sources += files('Modifiers/Filter.vala')
@@ -84,10 +84,10 @@ sources += files('Generators/Deferred.vala')
 
 sources += files('Promotions/Numbers/Numbers.vala')
 sources += files('Promotions/Numbers/Implementations.vala')
-sources += files('Promotions/Equatables.vala')
 sources += files('Promotions/Attempts.vala')
 sources += files('Promotions/PropertyGroups.vala')
 sources += files('Promotions/BinaryData.vala')
+sources += files('Promotions/Elements.vala')
 sources += files('Promotions/Registration.c')
 
 sources += files('Interfaces/Lot.vala')
@@ -101,11 +101,9 @@ sources += files('Interfaces/Collection.vala')
 sources += files('Interfaces/Associative.vala')
 sources += files('Interfaces/Addressable.vala')
 sources += files('Interfaces/Set.vala')
-sources += files('Interfaces/Properties.vala')
-sources += files('Interfaces/Elements.vala')
 sources += files('Interfaces/AddressableCollection.vala')
 sources += files('Interfaces/AddressableBytes.vala')
-sources += files('Interfaces/BinaryData.vala')
+sources += files('Interfaces/Properties.vala')
 sources += files('Interfaces/Queue.vala')
 
 sources += files('DataStructures/Series.vala')
@@ -143,7 +141,7 @@ invercargill_dep = declare_dependency(link_with: invercargill, include_directori
 pkg = import('pkgconfig')
 pkg.generate(invercargill,
     version : invercargill_version,
-    name : 'invercargill',)
+    name : 'invercargill-@0@'.format(invercargill_major))
     
 g_ir_compiler = find_program('g-ir-compiler')
 custom_target('invercargill typelib', command: [g_ir_compiler, '--shared-library=libinvercargill-@0@.so'.format(invercargill_major), '--output', '@OUTPUT@', meson.current_build_dir() / 'invercargill-@0@.gir'.format(invercargill_major)],

+ 15 - 1
src/tests/Integration/Promotion.vala

@@ -24,7 +24,7 @@ void promotion_tests() {
         assert_true(data == new_data);
     });
 
-    Test.add_func("/invercargill/promotions/sticky", () => { 
+    Test.add_func("/invercargill/promotions/sticky/numbers", () => { 
         try {
             var sum = Iterate.range(0, 10000, 1)
                 .promote_to<Signed32BitIntegers>()
@@ -37,4 +37,18 @@ void promotion_tests() {
             assert_no_error(e);
         }
     });
+
+        Test.add_func("/invercargill/promotions/sticky/binary_data", () => { 
+        try {
+            var data = new ByteBuffer.from_base64("AQkH")
+                .where(i => i != 9)
+                .to_base64();
+            
+
+            assert_cmpstr(data, CompareOperator.EQ, "AQc=");
+        }
+        catch (Error e) {
+            assert_no_error(e);
+        }
+    });
 }