Commit Graph

286 Commits

Author SHA1 Message Date
tersec 326ef09a46
remove dead code under Nim 1.6+ (#206) 2023-07-31 21:07:48 +00:00
Jacek Sieka 02f0929fc4
avoid zeroMem (#207)
on cached data, it doubles read time (!)
2023-07-21 08:01:07 +02:00
tersec 7afe7e3c07
deprecate pre-1.6 shims (#205)
* deprecate pre-1.6 shims

* revert stddefects shim deprecation until CI stops testing 1.2
2023-07-15 17:17:27 +00:00
tersec 422b6e1435
remove Nim 1.2 and 1.4 support (#204) 2023-07-05 13:13:50 +00:00
Jacek Sieka 2cf408b960
Graduate stew/results -> results (#185)
Since the results package has seen "stable" use for quite a while now,
it's as good time a time as any to release 1.0 and migrate it out of
stew, thus signalling API stability of some sort.

Part of that "stabilization" is underway in the nim-results [issue
tracker](https://github.com/arnetheduck/nim-results/issues/30).
2023-07-05 12:50:21 +02:00
andri lim 5c519d8582
fix results compiletime regression (#203)
* fix results compiletime regression

* disable results.value compiletime test for pre 1.6 nim
2023-07-05 10:07:17 +02:00
Jacek Sieka 8bb07fac39
results: fix `catch` template for statements (#201)
* results: fix `catch` template for statements

* disable void catch tests on pre-1.6
2023-06-28 10:57:00 +02:00
Jacek Sieka d085e48e89
results: add `mapConvertErr`, `mapCastErr` (#178)
We already have `mapConvert` and `mapCast` - this completes the API with
corresponding `Err` versions similar to `mapErr`.

The `Convert` / `Cast` operators are of somewhat dubious value - ie
they exist as "efficiency" shortcuts for `map` for the case that the
mapping should be done as a simple cast / conversion - an alternative
would be to deprecate these features and aim for some other, more
generic version that involves a type conversion library such as
https://github.com/status-im/nim-stew/pull/34, though this inherently,
and perhaps rightly, would be limited to "error-free" conversions.

Regardless, these helpers provide balance to the existing API.
2023-06-28 10:27:45 +02:00
tersec 9958aac68a
remove workaround for unsupported Nim 0.19 and earlier (#200)
* remove workaround for unsupported Nim 0.19 and earlier

* replace some proc with func
2023-06-15 13:13:41 +00:00
tersec 65ce2203f0
unconditionally pass through std/os and deprecate shim/os (#199) 2023-06-15 14:55:16 +02:00
tersec 607059fe31
rm copy of parseHex() from 1.2+ stdlib; some proc -> func (#197) 2023-06-15 14:21:51 +02:00
Jacek Sieka 273ce152a6
bitops2: fix resizing casts (#194) 2023-06-15 13:52:54 +02:00
Etan Kissling 500a614310
fix `ProveField` warnings in `results` (#198)
Nim emits `ProveField` warnings with `if` on case object discriminator.
Replace with `case` instead to avoid those warnings.
Note we currently have `ProveField` disabled but it keeps showing up
sometimes when compiling with `nim c` instead of `make`.
2023-06-15 12:02:54 +02:00
Jacek Sieka ebbb391b9e
ptrops: add makeUncheckedArray (#193)
turns a pointer into an array pointer of the same type
2023-06-12 14:13:18 +02:00
Jacek Sieka 36e0eb8d89
varints: remove (#195) 2023-06-12 11:42:27 +02:00
tersec d9400ddea0
unconditionally pass through std/atomics and deprecate shim/atomics (#196) 2023-06-10 23:14:12 +02:00
Jacek Sieka 6c97f11c7c
results: work around nim codegen bug (#192)
https://github.com/nim-lang/Nim/issues/22049
2023-06-08 17:24:19 +02:00
Jacek Sieka 13e55ed27a
results: collections integration (#179)
This set of helpers allows treating Result and Opt as collections of 0
or 1 item, allowing iterating over them and checking "membership" - such
integration is useful in generic code which can then be generalised to
handle more complex cases - the integration is most useful with Opt.

One design tradeoff here is the "explicitness" of `items` vs `values`
for `Result` - technically error and value are "equal" and therefore we
shouldn't give preference to the value, but there exists a convenience
argument to treat the value as the "default" and therefore define
`items` / `contains` for `Result` as well - this PR chooses the more
conservative and explicit approach - a more liberal version can easily
be added later should motivating examples emerge.
2023-06-07 16:45:53 +02:00
Jacek Sieka 000eeb14a3
result: void-ness tightenings (#191)
* better error messages and less pollution
2023-06-07 13:34:50 +02:00
Jacek Sieka fc349393f6
results: prefer `value` as canonical name for getting value (#188)
A `Result` has a `value` and an `error`, while `get` exists for `Option`
comptibility mainly - thus, use `value` more consistently.
2023-06-07 10:40:03 +02:00
Etan Kissling 7b4c9407f2
add `enumStyle` helper macro (#189)
For serialization and parsing, distinguishing enums with numeric values
from enums with associated strings for each value is useful. This adds
foundational helpers to allow such distinction.
2023-05-26 15:41:13 +03:00
diegomrsantos 003fe9f0c8
remove cast warnings (#186) 2023-05-23 11:05:55 +02:00
Jacek Sieka 266e9002f3
results: Add Opt/Result converters (#177)
Add `optError`, `optValue`, to convert back and forth between Opt and Result
These conversions end up being more common than others since "trivial"  success/fail-style API often use Opt while combining such API into combined operations tends to prefer richer error reporting.
2023-05-11 16:34:41 +03:00
Jacek Sieka 111d939940
assign2: guard against self-assignment / overlapping openArray (#182) 2023-04-25 21:32:22 +02:00
diegomrsantos 8caa977199
remove HoleEnumConv warning (#184) 2023-04-25 18:16:50 +02:00
Jacek Sieka 9b985e8ea8
results: Add `isOkOr`, `isErrOr` (#176)
These two helpers complete `valueOr` and `errorOr` to cover `void` cases
where no value should be returned or `Result[void, E]` /
`Result[T, void]` is being used - they can be used for a convient
early-return style in side-effectful proc:s:

```nim
v.update().isOkOr:
  echo "update failed: ", error
```
2023-04-20 13:08:54 +02:00
jangko 67fdc87e25
remove travis and appveyor badge from readme.md 2023-04-14 21:51:50 +07:00
tersec 09c6bc676f
test both refc and ORC in post-1.6 Nim versions (#180) 2023-04-14 01:32:27 +00:00
tersec 763d54c1ba
use Nim 2.0 in CI (#175) 2023-04-07 15:12:07 +00:00
c-blake e18f5a62af
Add API call from a (slight) future 1.6 branch with when guards to (#173)
* Add API call from a (slight) future 1.6 branch with when guards to
deactivate as per claim here

    https://github.com/status-im/nim-codex/pull/346#issuecomment-1432073926

that this (or something very near it) is where it belongs.

* I also cannot find any `shims/parse` import.  See discussion here:
  https://github.com/status-im/nim-stew/pull/173

So, rename module to match upstream Nim stdlib.

If anyone complains, re-create `parse.nim` that simply does import
& re-export parseutils & self-deprecates.
2023-02-21 16:29:07 -05:00
jangko c52569abd5
add {.used.} to stddefects for nim 1.4 and above 2023-02-15 16:18:10 +07:00
jangko 6cc42beac7
reenable Defect raises for Nim 1.2 2023-02-14 21:56:10 +07:00
jangko faabd40c30
reduce compiler warnings 2023-02-14 21:35:54 +07:00
Eugene Kabanov 407a598836
Fix Windows MAX_PATH limitation for absolute paths in io2 module. (#169)
* Fix Windows MAX_PATH limitation for absolute paths.

* Update algorithm to be more compatible with both directory and file paths.

* Add test.
2023-02-02 09:30:40 +01:00
Miran 11c8893cc6
switch CI to the supported version of ubuntu (#139)
* switch CI to the supported version of ubuntu

See https://github.com/actions/runner-images/issues/6002

* don't continue on error for Nim 1.6

* install openssl on macos for Nim devel

due to changes in https://github.com/nim-lang/Nim/pull/19814

---------

Co-authored-by: Jacek Sieka <jacek@status.im>
2023-02-01 13:19:07 +07:00
jangko 25aab846f1
upgrade github action to v3 2023-02-01 12:03:32 +07:00
Jacek Sieka 447b23d3bf
results: work around field access bugs (#167)
* results: work around field access bugs

See:

* https://github.com/nim-lang/Nim/issues/3770
* https://github.com/nim-lang/Nim/issues/20900

* comment fixes

* add test

* document test better
2023-01-20 15:32:51 +01:00
Jacek Sieka 19a6aea53b
results: document experimental error shortcut, and its gotchas (#168) 2023-01-20 15:32:34 +01:00
Jordan Hrycaj 609edbb5db
Updated unit tests using setup facility (#166)
why:
  Allows executing sub-tests independently.
2023-01-19 20:23:21 +00:00
Jacek Sieka 4e256104e1
Remove lock file (#165)
The lock file breaks devel testing - CI updates are needed as well as a
strategy for handling "nim important packages" builds (which build with
a version of Nim different from that in the lock file)
2023-01-19 15:23:48 +01:00
Jacek Sieka 32d6f43fff
byteutils: allow empty output buffers (#157)
* byteutils: allow empty output buffers

* er, closed
2023-01-19 08:19:26 +01:00
Jacek Sieka ac602b5086
results: print `none` for empty Opt instances (#164)
* results: print `none` for empty Opt instances

* fix test too
2023-01-16 09:01:31 +01:00
Bung f2f9685ec9
fix int set (#163) 2022-12-19 12:28:22 +01:00
Zahary Karadjov f5846de7b2
Add objects.isDefaultValue 2022-12-15 17:11:53 +02:00
Jacek Sieka 7184d2424d
ci: bump checkout (#160) 2022-11-22 17:17:06 +01:00
Jacek Sieka 8e8d99f912
cancel PR builds (#159)
* cancel PR builds

* test

* test again
2022-11-22 13:47:01 +01:00
Jacek Sieka aba51f1d29
normalise nimble file (#158)
* normalise nimble file

* loop args
2022-11-21 11:02:24 +01:00
Jacek Sieka 66c16920a6
update nimble build script (#155) 2022-11-19 07:50:31 +01:00
Jacek Sieka d087c039c2
fix `baseAddr`, move to `ptrops` (#156)
* return `nil` for empty openArrays / avoid returning `16`
* move to `ptrops`, deprecate `ptr_arith` fully
2022-11-18 15:22:29 +02:00
Jacek Sieka f295d00db9
remove `stew/ranges` (#152)
* deprecated for years
* relies on unavailable (shallowCopy) or broken (missing range checks)
features in nim
2022-11-18 12:52:55 +01:00