11# CHANGELOG
22
3+ ## 4.0.0-alpha
4+
5+ > [ !IMPORTANT]
6+ > Version 4.0.0 has a _ large_ set of breaking changes, including removing the
7+ > vast majority of extension methods and boxed classes, in favor of using the
8+ > newer _ extension types_ feature in Dart. I would be opening to adding back
9+ > some deprecated methods, or a ` lib/compat.dart ` file if there is demand;
10+ > please [ file an issue] [ ] if you need this.
11+
12+ [ file an issue ] : https://github.com/matanlurey/binary.dart/issues
13+
14+ ** New features** :
15+
16+ Lots and lots. It will be easier to just read the API documentation.
17+
18+ ** Breaking changes:**
19+
20+ _ Basically everything_ . The entire API has been restructured to use extension
21+ types, and some APIs removed entirely that were either not well-thought out
22+ (_ oops_ ) or were unnecessary:
23+
24+ - ` Integral ` , which was a base type for defining integers, has been removed in
25+ favor of a helper class, ` IntDescriptor ` , which is used to define new integer
26+ types, and acts sort of a meta type or poor man's macro for defining features:
27+
28+ ``` diff
29+ - class Int4 extends Integral<Int4> {
30+ - Int4(int value) : super.checked(value, signed: true, size: 4);
31+ -
32+ - @override
33+ - Int4 wrapSafeValue(int value) => Int4(value);
34+ - }
35+
36+ + extension type const Int4._(int _) implements FixedInt {
37+ + static const _descriptor = _IntDescriptor<Int8>.signed(
38+ + Int4.fromUnchecked,
39+ + width: 4,
40+ + max: 7,
41+ + );
42+ +
43+ + factory Int4(int v) => _descriptor.fit(v);
44+ +
45+ + // ...
46+ + }
47+ ```
48+
49+ In practice, it is much more difficult to implement a custom type, as many
50+ methods have to be hand-written, but it is also a much better future-proof
51+ approach. In the near-term, it's possible we could expose the code generator
52+ used by this package internally as a tool for others to use, and longer-term
53+ [ Dart macros] ( https://dart.dev/language/macros ) can be used to simplify this
54+ process for users.
55+
56+ - Fixed-size integers still exist, but with an updated API. Replacements are a
57+ follows:
58+
59+ - ` .bitChunk(l, r) ` -> ` .chunk(l, [s?]) `
60+ - ` .bitRange(l, r) ` -> ` .slice(l, [r?]) `
61+ - ` .bitsSet ` -> ` .countOnes() `
62+ - ` .clearBit(n) ` -> ` .setNthBit(n, false) `
63+ - ` .getBit(n) ` -> ` .nthBit(n) ` or ` operator [n] `
64+ - ` .replaceBitRange(l, r, b) ` -> ` .replace(l, r?, b) `
65+ - ` .rotateLeftShift(n) ` -> ` .rotateLeft(n) `
66+ - ` .rotateRightShift(n) ` -> ` .rotateRight(n) `
67+ - ` .setBit(n) ` -> ` .setNthBit(n) `
68+ - ` .signExtend(n) ` -> _ removed_ .
69+ - ` .size ` has been removed in favor of a static ` .width ` ; as extension types
70+ are non-virtual.
71+ - ` .toggleBit(n) ` -> ` .toggleNthBit(n) `
72+ - ` .value ` -> ` .toInt() `
73+
74+ - The extension methods ` BinaryInt ` were removed. Instead, use the extension
75+ types directly. A small subset of helper methods are available on
76+ ` IntExtension ` but have little in common with the previous API (mostly
77+ convenience methods).
78+
79+ - Every other extension method set was removed.
80+
381## 3.0.1
482
583- Downgrade [ meta] ( https://pub.dev/packages/meta ) version to [ v1.7.0] ( https://pub.dev/packages/meta/versions/1.7.0 ) for Flutter compatibility.
@@ -16,7 +94,7 @@ _Special thanks to <https://github.com/leynier> for driving this update!_
1694
1795## 2.0.0
1896
19- ### Highlights
97+ ** Highlights** :
2098
2199Added limited support for operations on integer values that exceed 32-bits.
22100Before ` 2.0.0 ` most of the methods provided by this package had undefined
@@ -40,7 +118,7 @@ assumed to have _undefined behavior_ when compiled to JavaScript.
40118
41119> Tip: Don't want to consider all of that? You can always just use ` Uint32 ` !
42120
43- ### Operating on Larger Ints
121+ ** Operating on Larger Ints** :
44122
45123Added ` <int>.hiLo() ` , which returns a fixed 2-length ` Uint32List ` where
46124element 0 is the "hi" (upper bits) and element 1 is the "lo" (lower bits).
@@ -61,7 +139,7 @@ future release, but you may also try using these other implemntations:
61139- [ BigInt] ( https://api.dart.dev/stable/2.8.4/dart-core/BigInt-class.html )
62140- [ Int64] ( https://pub.dev/documentation/fixnum/latest/fixnum/Int64-class.html )
63141
64- ### Additional changes
142+ ** Additional Changes: **
65143
66144- Added ` <int>.pow(n) ` , which is like ` <dart:math>.pow ` with a return of ` int ` .
67145- Added ` <Integral>.signExtend(startSize) ` .
0 commit comments