moderate system cleanup & refactor (#20355)

* system refactor, move out 600 lines

* compilation, slice, backwardsindex, misc_num moved out of system
* some procs/types moved into arithmetics, basic_types
* system no longer depends on syncio
* some procs moved around to fit with their surroundings

* make exceptions an import, old ops to misc_num

* move instantiationInfo back

* move back nim version, fix windows echo

* include compilation

* better docs for imported modules, fix unsigned ops

also remove ze, ze64, toU8, toU16, toU32 with nimPreviewSlimSystem

* fix terminal

* workaround IC test & weird csize bug, changelog

* move NimMajor etc back to compilation, rebase for CI

* try ic fix

* form single `indices`, slim out TaintedString, try fix IC

* fix CI, update changelog, addQuitProc

* fix CI

* try fix CI

* actually fix CI finally hopefully

* Update lib/system/compilation.nim

Co-authored-by: ringabout <43030857+ringabout@users.noreply.github.com>

* update kochdocs

* hopefully fix csize uses for slimsystem

* fix tquit

Co-authored-by: ringabout <43030857+ringabout@users.noreply.github.com>
This commit is contained in:
metagn 2022-09-28 22:28:45 +03:00 • committed by GitHub
commit 919a889ba8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
37 changed files with 1167 additions and 1102 deletions

90
lib/system/ctypes.nim Normal file
View file

@ -0,0 +1,90 @@
## Some type definitions for compatibility between different
## backends and platforms.
type
BiggestInt* = int64
## is an alias for the biggest signed integer type the Nim compiler
## supports. Currently this is `int64`, but it is platform-dependent
## in general.
BiggestFloat* = float64
## is an alias for the biggest floating point type the Nim
## compiler supports. Currently this is `float64`, but it is
## platform-dependent in general.
when defined(js):
type BiggestUInt* = uint32
## is an alias for the biggest unsigned integer type the Nim compiler
## supports. Currently this is `uint32` for JS and `uint64` for other
## targets.
else:
type BiggestUInt* = uint64
## is an alias for the biggest unsigned integer type the Nim compiler
## supports. Currently this is `uint32` for JS and `uint64` for other
## targets.
when defined(windows):
type
clong* {.importc: "long", nodecl.} = int32
## This is the same as the type `long` in *C*.
culong* {.importc: "unsigned long", nodecl.} = uint32
## This is the same as the type `unsigned long` in *C*.
else:
type
clong* {.importc: "long", nodecl.} = int
## This is the same as the type `long` in *C*.
culong* {.importc: "unsigned long", nodecl.} = uint
## This is the same as the type `unsigned long` in *C*.
type # these work for most platforms:
cchar* {.importc: "char", nodecl.} = char
## This is the same as the type `char` in *C*.
cschar* {.importc: "signed char", nodecl.} = int8
## This is the same as the type `signed char` in *C*.
cshort* {.importc: "short", nodecl.} = int16
## This is the same as the type `short` in *C*.
cint* {.importc: "int", nodecl.} = int32
## This is the same as the type `int` in *C*.
csize_t* {.importc: "size_t", nodecl.} = uint
## This is the same as the type `size_t` in *C*.
clonglong* {.importc: "long long", nodecl.} = int64
## This is the same as the type `long long` in *C*.
cfloat* {.importc: "float", nodecl.} = float32
## This is the same as the type `float` in *C*.
cdouble* {.importc: "double", nodecl.} = float64
## This is the same as the type `double` in *C*.
clongdouble* {.importc: "long double", nodecl.} = BiggestFloat
## This is the same as the type `long double` in *C*.
## This C type is not supported by Nim's code generator.
cuchar* {.importc: "unsigned char", nodecl, deprecated: "use `char` or `uint8` instead".} = char
## Deprecated: Use `uint8` instead.
cushort* {.importc: "unsigned short", nodecl.} = uint16
## This is the same as the type `unsigned short` in *C*.
cuint* {.importc: "unsigned int", nodecl.} = uint32
## This is the same as the type `unsigned int` in *C*.
culonglong* {.importc: "unsigned long long", nodecl.} = uint64
## This is the same as the type `unsigned long long` in *C*.
type
ByteAddress* = int
## is the signed integer type that should be used for converting
## pointers to integer addresses for readability.
cstringArray* {.importc: "char**", nodecl.} = ptr UncheckedArray[cstring]
## This is binary compatible to the type `char**` in *C*. The array's
## high value is large enough to disable bounds checking in practice.
## Use `cstringArrayToSeq proc <#cstringArrayToSeq,cstringArray,Natural>`_
## to convert it into a `seq[string]`.
when not defined(nimPreviewSlimSystem):
# pollutes namespace
type
PFloat32* {.deprecated: "use `ptr float32`".} = ptr float32
## An alias for `ptr float32`.
PFloat64* {.deprecated: "use `ptr float64`".} = ptr float64
## An alias for `ptr float64`.
PInt64* {.deprecated: "use `ptr int64`".} = ptr int64
## An alias for `ptr int64`.
PInt32* {.deprecated: "use `ptr int32`".} = ptr int32
## An alias for `ptr int32`.