Commit Graph

180 Commits

Author SHA1 Message Date
Zahary Karadjov 2dd113f754 More progress towards Lent[T] in Nim 1.6
* Worked-around a bug where Nim comlains that the return value is
  not a path expression in functions lacking explicit return
  statements

* Worked-around a limitation that Nim doesn't allow:
  let foo: lent T = makeT()
2021-10-19 19:35:48 +03:00
Zahary Karadjov d8f35df7a7
Introduce a shim for the lent type and use it in the results module 2021-09-25 01:40:56 +03:00
Zahary Karadjov 478cc6efde Add object.isZeroMemory 2021-09-13 19:02:32 +03:00
Jacek Sieka 3c91b8694e
add void tests (#84) 2021-07-07 10:12:20 +02:00
jangko e10da4a90e
fixes bug in base64 decoder when decoding byte sequence
the decoder accepts string or byte sequence but assume
the inner type is a char, now fixed
2021-06-17 08:16:56 +07:00
Ștefan Talpalaru 70680e2af2
CI: refactor Nim compiler caching (#82) 2021-06-01 08:27:27 +02:00
Jacek Sieka 7fb220d1e8
assign2: string support (#81) 2021-04-16 15:23:36 +02:00
Jacek Sieka 7d2790fdf4
fix `countZeros` (#80)
should return zeros based on bits, not bytes!
2021-04-12 22:55:09 +02:00
Eugene Kabanov ede0651741
Fix issue with `uint` type. (#79)
* Fix issue with `uint` type.
Add tests for `uint` type.

* Add decode tests for `uint` type.
2021-04-09 19:01:50 +03:00
Zahary Karadjov ee78822e05
Alternative definition of string.hexToByteArray(N)
This definition is more robust. The previously existing version was
producing compilation errors in certain generic contexts. static
"regular" params are recommended in general as they are more flexible
than the explicit generic parameters.
2021-03-19 03:56:01 +02:00
Eugene Kabanov 6bcb21184a
Optimized and exception-less encoding/decoding procedures for decimal integers (#78)
* Optimized and exception-less encoding/decoding procedures for decimal integers.

* Add tests.

* Fix import path.

* Fix review comments.

* Code simplification.

* Make toBytes() allocation free.

* Do not perform conversion to signed type to avoid compiler's overflow checks.
2021-03-05 20:50:36 +02:00
Zahary Karadjov 42475fd2f1
Fix a FieldError crash in the == comparison for Result[void, T] 2021-02-22 21:04:27 +02:00
Gabben 04f8150a08
Fix #62 (#75)
* Fix #62

- Supports more than one pragma parameter (return tuple)
- Returns nil if there are zero parameters in the pragma (like std)
2021-02-10 15:10:08 +02:00
Jacek Sieka a0e8ec451e
results: include error when expecting (#76) 2021-02-10 11:05:29 +01:00
Mamy Ratsimbazafy 6d3e6a21ca
results.`==` with void, Reboot #73 addressing comments (#74) 2021-01-26 15:06:17 +01:00
Mamy Ratsimbazafy b4b3841a85
Revert "Allow comparing Result[void, E] (#71)" (#73)
This reverts commit 068412ff4e.
2021-01-26 14:20:09 +01:00
Mamy Ratsimbazafy 068412ff4e
Allow comparing Result[void, E] (#71) 2021-01-26 14:12:08 +01:00
Jacek Sieka 74d21ec8f4
mark io2 EH-free (#72) 2021-01-26 14:10:47 +01:00
andri lim 932fa6cef1
Merge pull request #69 from status-im/fix_gh_action
github CI: fixes backend selection
2021-01-08 12:06:21 +07:00
jangko 87096ee9ac
github CI: fixes backend selection 2021-01-07 10:33:01 +07:00
andri lim 1401c34374
Merge pull request #68 from status-im/fix_gh_action_script
remove redundant code from github action script
2020-12-24 09:12:02 +07:00
jangko ee6e30e7ff
remove redundant code from github action script 2020-12-23 21:40:17 +07:00
andri lim 42c09b36ee
add github action (#67)
* add github action

* test with MSVC in GH action

* fixes MSVC setup in GH action

* fixes MSVC setup in GH action: remove sdk selection
2020-12-23 12:04:18 +07:00
Jacek Sieka 5cf4feabea
leb128 + bitops fixes (#66)
Leb128 is a variable-length encoding for unsigned integers that is used
in a number of contexts - in particular, wasm, dwarf and protobuf.

This is an optimized low-level implementation that unrolls the loop
reading/writing the buffer - it is suitable to use as base for a more
specific API - no memory allocations, no exceptions.

This PR also fixes bitops2 to not raise on certaing uint->int
conversions, adapting bitops to nim 1.0 conversion rules by using a cast
instead of raising on uint->int conversion
2020-12-15 17:07:20 +02:00
Jacek Sieka 46068b49ae
forward assign declarations (#65) 2020-12-10 17:08:24 +01:00
Jacek Sieka d8d914332d
random helpers (#64)
* random helpers

* arrayops as a home for small array/openArray utilities
* assign2 - a replacement for genericAssign and assignment operators in
general which in nim are very slow
* use assign2 in a few places to speed things up

* fixes

* fixes
2020-12-10 12:05:22 +01:00
Jacek Sieka e15c1ae012
results: prevent dangling cstring pointers in result (#63) 2020-12-09 17:21:12 +01:00
Eugene Kabanov ff524ed832
Fix getCurrentDir() gcc compilation warning. (#61)
* Fix GCC warning on getcwd usage.
* Check returned value of getCurrentDir() in tests.
2020-11-04 15:22:38 +02:00
Eugene Kabanov bc3b4cf2de
Fix inherited objects problem. (#59) 2020-10-20 17:43:38 +03:00
Eugene Kabanov 7018fb0b5e
Procedures to set user-only Windows ACL settings for files and folders. (#58)
* Initial commit of UserOnly Windows ACL settings for files and folders.

* Move ACL procedures to windows/acl.
Move ACL tests to test_winacl.nim.

* Add test_winacl.nim

* Fix *nix compilation problem.

* More proper fix for *nix targets.
2020-10-15 14:27:58 +02:00
andri lim 529517d848
Merge pull request #56 from status-im/fix_bitops2
fixes bitops2: 'countOnesBuiltin' and 'parityBuiltin' when feed 'un…
2020-10-01 14:01:22 +07:00
jangko 999d3ca7ce
fixes bitops2: 'countOnesBuiltin' and 'parityBuiltin' when feeded 'unsigned' on 32 bit platform 2020-09-30 18:28:36 +07:00
Zahary Karadjov 2b9e5f34d1
Some fixes for Result[T, void] 2020-09-29 21:31:20 +03:00
cheatfate 3e4dc8213b
Fix some Windows API declarations. 2020-09-29 13:34:40 +03:00
Eugene Kabanov 7a2b6dbdda
IO2 (#53)
* Initial commit of io2 module

* Rename to io2.
Add createPath with permissions.
Add writeFile with permissions.
Add tests.

* Add test_io2 to all tests.

* Add posix permissions.

* Add toString procedure for set[Permission] and tests.

* Remove safeio.nim

* Add setPermissions procedures.
Fix writeFile() to change permissions.
Add more writeFile() tests.

* Change C ReadOnly/WriteOnly/ReadWrite to pair of Read/Write.
Add tests for openFile.

* File handles is no inherited by default, with option to turn on inheritance.

* Review comments fixes.
More tests.

* Fix x86 compilation problems.

* Rename toSet -> toPermissions.

* Avoid race condition on writeFile permissions.
2020-09-22 08:53:00 +03:00
Jacek Sieka 47ff49aae7
fix use of compiler intrinsics in endians/bitops (#54)
* fix use of compiler intrinsics in endians/bitops

* windows fix
2020-09-21 08:43:27 +02:00
Zahary Karadjov 1db43c7234
Add string.add(openarray[char]) (to be optimized later) 2020-09-02 19:59:50 +03:00
Eugene Kabanov 4c695e5933
Allow any integer type to use CT.isEqual(). (#51)
* Allow any integer type to use CT.isEqual().
* Add tests for different integer types.
2020-07-30 20:09:49 +03:00
cheatfate a5560c1ea6
Add constant isEqual operation for openarrays. 2020-07-29 01:43:09 +03:00
Jacek Sieka ec2f52b0ce
results: make `?` work with void (#50) 2020-07-13 18:09:45 +02:00
Zahary Karadjov 61e0f82858
More descriptive naming 2020-07-08 00:32:28 +03:00
Zahary Karadjov 32b86bfd1f
Faux closures: a facility for creating closure-like non-closure procs
This code is extracted from the error-handling proposal where it's
used to implement `Try` blocks (Faux closures are created there in
order to assign raises lists to them). The desktop team faced a
similar problem where the `spawn` API doesn't support closures,
but the restriction can be easily worked-around with faux closures.
2020-07-07 20:29:04 +03:00
Zahary Karadjov 61d5cfc376
Add array[N, byte].fromHex(string) 2020-07-02 18:00:39 +03:00
Zahary Karadjov c980d7592d
Missed some generic procs in the previous commit due to late instantiation 2020-07-02 13:00:38 +03:00
Zahary Karadjov a272986cb3
raises annotations for stew/byteutils 2020-07-02 12:48:05 +03:00
Ștefan Talpalaru 5b28c5f694
Merge pull request #46 from status-im/rlimits
POSIX stack size limiting
2020-06-25 19:17:21 +02:00
Ștefan Talpalaru d5e3c44917
POSIX stack size limiting 2020-06-25 19:01:01 +02:00
Zahary Karadjov 152eb1b58c Add 'checkedEnumAssign' for validating tainted enum inputs 2020-06-24 14:15:45 +03:00
Mamy Ratsimbazafy 11aeb996ab
Error message typo 2020-06-23 19:46:18 +02:00
andri lim 188230a368
Merge pull request #43 from status-im/fix_vcc_bitops2
fix bitops2 checkedScan and bitScan for vcc
2020-06-19 20:22:34 +07:00