diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index e573dfdf9..000000000 --- a/.gitattributes +++ /dev/null @@ -1,53 +0,0 @@ - - -[attr]lfTxt text eol=lf -# get rid of mess -[attr]normTxt lfTxt - -*.sh lfTxt - -/LICENSE normTxt -.gitignore normTxt - -*.nim normTxt -*.nimble normTxt -*.nims normTxt -*.py normTxt -*.c normTxt -*.yml normTxt -*.md normTxt -*.txt normTxt - -# Binary data types -*.aif binary -*.aifc binary -*.aiff binary -*.au binary -*.bmp binary -*.exe binary -*.icns binary -*.gif binary -*.ico binary -*.jpg binary -*.pck binary -*.png binary -*.psd binary -*.tar binary -*.wav binary -*.zip binary - -# Generated files -# https://github.com/github/linguist/blob/master/docs/overrides.md -# -# To always hide generated files in local diffs, mark them as binary: -# $ git config diff.generated.binary true -# -[attr]generated linguist-generated=true diff=generated - -/src/pylib/pystring/unicase/*.nim generated - - -# CRLF files -[attr]dos text eol=crlf - -*.bat dos diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml deleted file mode 100644 index 7db3bc4b4..000000000 --- a/.github/FUNDING.yml +++ /dev/null @@ -1,15 +0,0 @@ -# These are supported funding model platforms - -github: litlighilit # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] -#patreon: # Replace with a single Patreon username -open_collective: nimpylib # Replace with a single Open Collective username -#ko_fi: # Replace with a single Ko-fi username -#tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel -#community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry -#liberapay: # Replace with a single Liberapay username -#issuehunt: # Replace with a single IssueHunt username -#lfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry -#polar: # Replace with a single Polar username -#buy_me_a_coffee: # Replace with a single Buy Me a Coffee username -#thanks_dev: # Replace with a single thanks.dev username -#custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml deleted file mode 100644 index 83d1146dd..000000000 --- a/.github/workflows/docs.yml +++ /dev/null @@ -1,53 +0,0 @@ -name: docs - -# yamllint disable-line rule:truthy -on: - push: - branches: - - master - workflow_dispatch: - -env: - nim-version: 'stable' - git-url-arg: --git.url:https://github.com/${{ github.repository }} --git.commit:master - deploy-dir: .gh-pages - lib-deploy-dir: .gh-pages/Lib -jobs: - docs: - runs-on: ubuntu-latest - permissions: - contents: write - steps: - - uses: actions/checkout@v4 - - name: Cache nimble - id: cache-nimble - uses: actions/cache@v4 - with: - path: ~/.nimble - key: ${{ runner.os }}-nimble - - uses: jiro4989/setup-nim-action@v1 - with: - nim-version: ${{ env.nim-version }} - - name: genDoc - run: nimble testDoc --index:on --project ${{ env.git-url-arg }} --outdir:${{ env.deploy-dir }} -d:homepage="${{ github.event.repository.homepage }}" - - name: genLibDoc - run: nimble testLibDoc ${{ env.git-url-arg }} --outdir:${{ env.lib-deploy-dir }} - - name: "Copy to index.html" - run: cp ${{ env.deploy-dir }}/${{ github.event.repository.name }}.html ${{ env.deploy-dir }}/index.html - - name: "CNAME" - run: | - cname=$(echo ${{ github.event.repository.homepage }} | grep -oP 'https?://\K[^/]+') - prefix="docs." - # py: if cname.startswith(prefix) - # bash: if [[ "${cname}" != $prefix* ]] - if [ ${cname##$prefix} = $cname ]; then - cname="${prefix}${cname}" - fi - echo -n $cname > ${{ env.deploy-dir }}/CNAME - # We must re-build CNAME as we use 'peaceiris/actions-gh-pages@v4', - # where the old dir (including CNAME) will be purged. - - name: Deploy documents - uses: peaceiris/actions-gh-pages@v4 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: ${{ env.deploy-dir }} diff --git a/.github/workflows/testC.yml b/.github/workflows/testC.yml deleted file mode 100644 index 905fa9128..000000000 --- a/.github/workflows/testC.yml +++ /dev/null @@ -1,29 +0,0 @@ -name: testC -on: - push: - branches-ignore: - - 'feat-*' - paths: - - 'src/**' - - './*.nimble' - - 'tests/**' - pull_request: -env: - nim-version: 'stable' -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Cache nimble - id: cache-nimble - uses: actions/cache@v4 - with: - path: ~/.nimble - key: ${{ runner.os }}-nimble - - uses: jiro4989/setup-nim-action@v1 - with: - nim-version: ${{ env.nim-version }} - - name: Test C backend - run: nimble testC - diff --git a/.github/workflows/testJs.yml b/.github/workflows/testJs.yml deleted file mode 100644 index 3a7f63b4b..000000000 --- a/.github/workflows/testJs.yml +++ /dev/null @@ -1,28 +0,0 @@ -name: testJs -on: - push: - branches-ignore: - - 'feat-*' - paths: - - 'src/**' - - './*.nimble' - - 'tests/**' - pull_request: -env: - nim-version: 'stable' -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - name: Cache nimble - id: cache-nimble - uses: actions/cache@v4 - with: - path: ~/.nimble - key: ${{ runner.os }}-nimble - - uses: jiro4989/setup-nim-action@v1 - with: - nim-version: ${{ env.nim-version }} - - name: Test JS backend - run: nimble testJs diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 02a77a9b4..000000000 --- a/.gitignore +++ /dev/null @@ -1,7 +0,0 @@ -/.vscode/ -nimcache/ -/docs/ -tester* -tempfiletest -/testresults/ -/tools/bin/ \ No newline at end of file diff --git a/tests/testaments/megatest.nim b/.nojekyll similarity index 100% rename from tests/testaments/megatest.nim rename to .nojekyll diff --git a/CNAME b/CNAME new file mode 100644 index 000000000..ca57c08dd --- /dev/null +++ b/CNAME @@ -0,0 +1 @@ +docs.nimpylib.org \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md deleted file mode 100644 index 3770481c5..000000000 --- a/CONTRIBUTING.md +++ /dev/null @@ -1,17 +0,0 @@ -# Contributing to NimPylib - - -## Lib/ - -If in one library: `LIB`, one API returns str -or a variable is of str, consider firstly port a `n_LIB` -that is only in pure Nim (NimPylib-independent) if possible. - -For example, `n_time` for `time`, in which `string` shall be used. -Then let `LIB` import `n_LIB` and wrap around `string` to only return `PyStr`. - -So does for `seq` <-> `PyList`. - -In such a way, `n_LIB` is for Nim and `LIB` is for NimPylib. - - diff --git a/LICENSE b/LICENSE deleted file mode 100644 index d6cb8eb1b..000000000 --- a/LICENSE +++ /dev/null @@ -1,22 +0,0 @@ -MIT License - -Copyright (c) 2017-2023 Daniil Yarancev -Copyright (c) 2023-2025 litlighilit - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. diff --git a/Lib/_._/Python/config_read_env.html b/Lib/_._/Python/config_read_env.html new file mode 100644 index 000000000..e27f92864 --- /dev/null +++ b/Lib/_._/Python/config_read_env.html @@ -0,0 +1,173 @@ + + + + + + + +src/pylib/Python/config_read_env + + + + + + + + + + + + + + + + +
+
+

src/pylib/Python/config_read_env

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Procs

+
+
+
+
proc ib_b(name: string; flagInit: bool): bool {....raises: [],
+    tags: [ReadEnvEffect], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc ib_b(name: string; flagInit: int): int {....raises: [], tags: [ReadEnvEffect],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc ib_e[T](name: string; flagInit: T): T
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc ib_i[T](name: string; flagInit: T): T
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func toPyEnv(name: string): string {.inline, ...raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/Python/config_read_env.idx b/Lib/_._/Python/config_read_env.idx new file mode 100644 index 000000000..e95c4abef --- /dev/null +++ b/Lib/_._/Python/config_read_env.idx @@ -0,0 +1,7 @@ +nimTitle config_read_env _._/Python/config_read_env.html module src/pylib/Python/config_read_env 0 +nim toPyEnv _._/Python/config_read_env.html#toPyEnv proc toPyEnv(name: string): string 12 +nim ib_i _._/Python/config_read_env.html#ib_i,,T proc ib_i[T](name: string; flagInit: T): T 13 +nim ib_e _._/Python/config_read_env.html#ib_e,,T proc ib_e[T](name: string; flagInit: T): T 23 +nim ib_b _._/Python/config_read_env.html#ib_b,,int proc ib_b(name: string; flagInit: int): int 24 +nim ib_b _._/Python/config_read_env.html#ib_b,,bool proc ib_b(name: string; flagInit: bool): bool 25 +nimgrp ibb _._/Python/config_read_env.html#ib_b-procs-all proc 24 diff --git a/Lib/_._/Python/envutils.html b/Lib/_._/Python/envutils.html new file mode 100644 index 000000000..d843196b1 --- /dev/null +++ b/Lib/_._/Python/envutils.html @@ -0,0 +1,155 @@ + + + + + + + +src/pylib/Python/envutils + + + + + + + + + + + + + + + + +
+
+

src/pylib/Python/envutils

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
proc c_getenv(v: cstring): cstring {.importc: "getenv", header: "<stdlib.h>",
+                                     ...raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc Py_SetLocaleFromEnv(category: cint): cstring {.discardable, ...raises: [],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc setenvOverwrite(key, val: string): bool {....raises: [],
+    tags: [WriteEnvEffect], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/Python/envutils.idx b/Lib/_._/Python/envutils.idx new file mode 100644 index 000000000..2b223b3d7 --- /dev/null +++ b/Lib/_._/Python/envutils.idx @@ -0,0 +1,4 @@ +nimTitle envutils _._/Python/envutils.html module src/pylib/Python/envutils 0 +nim setenvOverwrite _._/Python/envutils.html#setenvOverwrite,string,string proc setenvOverwrite(key, val: string): bool 10 +nim c_getenv _._/Python/envutils.html#c_getenv,cstring proc c_getenv(v: cstring): cstring 17 +nim Py_SetLocaleFromEnv _._/Python/envutils.html#Py_SetLocaleFromEnv,cint proc Py_SetLocaleFromEnv(category: cint): cstring 22 diff --git a/Lib/_._/Python/fileutils.html b/Lib/_._/Python/fileutils.html new file mode 100644 index 000000000..39fa34641 --- /dev/null +++ b/Lib/_._/Python/fileutils.html @@ -0,0 +1,190 @@ + + + + + + + +src/pylib/Python/fileutils + + + + + + + + + + + + + + + + +
+
+

src/pylib/Python/fileutils

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Consts

+
+
+
Utf8 = "utf-8"
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
proc Py_DecodeLocaleEx(arg: cstring; wstr: var ptr wchar_t; wlen: ptr csize_t;
+                       reason: var cstring; current_locale: bool;
+                       errors: Py_error_handler): int {....raises: [], tags: [],
+    forbids: [].}
+
+ +

Decode a byte string from the locale encoding.

+

Use the strict error handler if 'surrogateescape' is zero. Use the surrogateescape error handler if 'surrogateescape' is non-zero: undecodable bytes are decoded as characters in range U+DC80..U+DCFF. If a byte sequence can be decoded as a surrogate character, escape the bytes using the surrogateescape error handler instead of decoding them.

+

On success, return 0 and write the newly allocated wide character string into wstr (use PyMem_RawFree() to free the memory). If wlen is not NULL, write the number of wide characters excluding the null character into wlen.

+

On memory allocation failure, return -1.

+

On decoding error, return -2. Write the start of invalid byte sequence in the input string into wlen. If reason is not NULL, write the decoding error message into reason.

+

Return -3 if the error handler 'errors' is not supported.

+

Use the Py_EncodeLocaleEx() function to encode the character string back to a byte string.

+ + Source   +Edit   + +
+
+ +
+
+
+
proc Py_GetLocaleEncoding(): string {....raises: [], tags: [], forbids: [].}
+
+ + Get the current locale encoding name:
  • Return "utf-8" if Py_FORCE_UTF8_LOCALE is defined (ex: on Android)
  • +
  • Return "utf-8" if the UTF-8 Mode is enabled
  • +
  • On Windows, return the ANSI code page (ex: "cp1250")
  • +
  • Return "utf-8" if nl_langinfo(CODESET) returns an empty string.
  • +
  • Otherwise, return nl_langinfo(CODESET).
  • +
+

See also config_get_locale_encoding()

+ + Source   +Edit   + +
+
+ +
+ +
+
+ + +
+
+ + +
+
+ + + diff --git a/Lib/_._/Python/fileutils.idx b/Lib/_._/Python/fileutils.idx new file mode 100644 index 000000000..5b8f1655b --- /dev/null +++ b/Lib/_._/Python/fileutils.idx @@ -0,0 +1,4 @@ +nimTitle fileutils _._/Python/fileutils.html module src/pylib/Python/fileutils 0 +nim Py_DecodeLocaleEx _._/Python/fileutils.html#Py_DecodeLocaleEx,cstring,ptr.wchar_t,ptr.csize_t,cstring,bool,Py_error_handler proc Py_DecodeLocaleEx(arg: cstring; wstr: var ptr wchar_t; wlen: ptr csize_t;\n reason: var cstring; current_locale: bool;\n errors: Py_error_handler): int 179 +nim Utf8 _._/Python/fileutils.html#Utf8 const Utf8 236 +nim Py_GetLocaleEncoding _._/Python/fileutils.html#Py_GetLocaleEncoding proc Py_GetLocaleEncoding(): string 239 diff --git a/Lib/_._/Python/force_ascii_utils.html b/Lib/_._/Python/force_ascii_utils.html new file mode 100644 index 000000000..d25d2526f --- /dev/null +++ b/Lib/_._/Python/force_ascii_utils.html @@ -0,0 +1,228 @@ + + + + + + + +src/pylib/Python/force_ascii_utils + + + + + + + + + + + + + + + + +
+
+

src/pylib/Python/force_ascii_utils

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Consts

+
+
+
Py_FORCE_UTF8_FS_ENCODING = false
+
+ + + Source   +Edit   + +
+
+
+
Py_FORCE_UTF8_LOCALE = false
+
+ + CPython/Include/pyport.h: Use UTF-8 as the filesystem encoding. See PyUnicode_DecodeFSDefaultAndSize(), PyUnicode_EncodeFSDefault(), Py_DecodeLocale() and Py_EncodeLocale(). + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
proc check_force_ascii(): bool {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc Py_GetForceASCII(): bool {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc Py_ResetForceASCII() {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template force_ascii(): untyped
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Exports

+
+ Py_mbstowcs +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/Python/force_ascii_utils.idx b/Lib/_._/Python/force_ascii_utils.idx new file mode 100644 index 000000000..fff45757d --- /dev/null +++ b/Lib/_._/Python/force_ascii_utils.idx @@ -0,0 +1,7 @@ +nimTitle force_ascii_utils _._/Python/force_ascii_utils.html module src/pylib/Python/force_ascii_utils 0 +nim Py_FORCE_UTF8_LOCALE _._/Python/force_ascii_utils.html#Py_FORCE_UTF8_LOCALE const Py_FORCE_UTF8_LOCALE 8 +nim Py_FORCE_UTF8_FS_ENCODING _._/Python/force_ascii_utils.html#Py_FORCE_UTF8_FS_ENCODING const Py_FORCE_UTF8_FS_ENCODING 13 +nim force_ascii _._/Python/force_ascii_utils.html#force_ascii.t template force_ascii(): untyped 47 +nim check_force_ascii _._/Python/force_ascii_utils.html#check_force_ascii proc check_force_ascii(): bool 49 +nim Py_GetForceASCII _._/Python/force_ascii_utils.html#Py_GetForceASCII proc Py_GetForceASCII(): bool 109 +nim Py_ResetForceASCII _._/Python/force_ascii_utils.html#Py_ResetForceASCII proc Py_ResetForceASCII() 114 diff --git a/Lib/_._/Python/internal/pycore_fileutils.html b/Lib/_._/Python/internal/pycore_fileutils.html new file mode 100644 index 000000000..a1cea052c --- /dev/null +++ b/Lib/_._/Python/internal/pycore_fileutils.html @@ -0,0 +1,145 @@ + + + + + + + +src/pylib/Python/internal/pycore_fileutils + + + + + + + + + + + + + + + + +
+
+

src/pylib/Python/internal/pycore_fileutils

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Types

+
+
+
Py_error_handler = enum
+  Py_ERROR_UNKNOWN = "unknown", Py_ERROR_STRICT = "strict",
+  Py_ERROR_SURROGATEESCAPE = "surrogateescape", Py_ERROR_REPLACE = "replace",
+  Py_ERROR_IGNORE = "ignore", Py_ERROR_BACKSLASHREPLACE = "backslashreplace",
+  Py_ERROR_SURROGATEPASS = "surrogatepass",
+  Py_ERROR_XMLCHARREFREPLACE = "xmlcharrefreplace", Py_ERROR_OTHER = "other"
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
proc Py_GetErrorHandler(errors: string): Py_error_handler {....raises: [],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/Python/internal/pycore_fileutils.idx b/Lib/_._/Python/internal/pycore_fileutils.idx new file mode 100644 index 000000000..febb9ddef --- /dev/null +++ b/Lib/_._/Python/internal/pycore_fileutils.idx @@ -0,0 +1,12 @@ +nimTitle pycore_fileutils _._/Python/internal/pycore_fileutils.html module src/pylib/Python/internal/pycore_fileutils 0 +nim Py_ERROR_UNKNOWN _._/Python/internal/pycore_fileutils.html#Py_ERROR_UNKNOWN Py_error_handler.Py_ERROR_UNKNOWN 5 +nim Py_ERROR_STRICT _._/Python/internal/pycore_fileutils.html#Py_ERROR_STRICT Py_error_handler.Py_ERROR_STRICT 5 +nim Py_ERROR_SURROGATEESCAPE _._/Python/internal/pycore_fileutils.html#Py_ERROR_SURROGATEESCAPE Py_error_handler.Py_ERROR_SURROGATEESCAPE 5 +nim Py_ERROR_REPLACE _._/Python/internal/pycore_fileutils.html#Py_ERROR_REPLACE Py_error_handler.Py_ERROR_REPLACE 5 +nim Py_ERROR_IGNORE _._/Python/internal/pycore_fileutils.html#Py_ERROR_IGNORE Py_error_handler.Py_ERROR_IGNORE 5 +nim Py_ERROR_BACKSLASHREPLACE _._/Python/internal/pycore_fileutils.html#Py_ERROR_BACKSLASHREPLACE Py_error_handler.Py_ERROR_BACKSLASHREPLACE 5 +nim Py_ERROR_SURROGATEPASS _._/Python/internal/pycore_fileutils.html#Py_ERROR_SURROGATEPASS Py_error_handler.Py_ERROR_SURROGATEPASS 5 +nim Py_ERROR_XMLCHARREFREPLACE _._/Python/internal/pycore_fileutils.html#Py_ERROR_XMLCHARREFREPLACE Py_error_handler.Py_ERROR_XMLCHARREFREPLACE 5 +nim Py_ERROR_OTHER _._/Python/internal/pycore_fileutils.html#Py_ERROR_OTHER Py_error_handler.Py_ERROR_OTHER 5 +nim Py_error_handler _._/Python/internal/pycore_fileutils.html#Py_error_handler enum Py_error_handler 5 +nim Py_GetErrorHandler _._/Python/internal/pycore_fileutils.html#Py_GetErrorHandler,string proc Py_GetErrorHandler(errors: string): Py_error_handler 16 diff --git a/Lib/_._/Python/localeutils.html b/Lib/_._/Python/localeutils.html new file mode 100644 index 000000000..67b18dc54 --- /dev/null +++ b/Lib/_._/Python/localeutils.html @@ -0,0 +1,177 @@ + + + + + + + +src/pylib/Python/localeutils + + + + + + + + + + + + + + + + +
+
+

src/pylib/Python/localeutils

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Lets

+
+
+
LC_ALL {.importc.}: cint
+
+ + + Source   +Edit   + +
+
+
+
LC_CTYPE {.importc.}: cint
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
proc c_setlocale(category: cint; v: cstring): cstring {.importc: "setlocale",
+    header: "<locale.h>", ...raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template setlocale(category; v: string): cstring
+
+ + we know setlocale won't modify 2nd param Thus v: string is allowed to convert to cstring implicitly + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/Python/localeutils.idx b/Lib/_._/Python/localeutils.idx new file mode 100644 index 000000000..cde4611b5 --- /dev/null +++ b/Lib/_._/Python/localeutils.idx @@ -0,0 +1,5 @@ +nimTitle localeutils _._/Python/localeutils.html module src/pylib/Python/localeutils 0 +nim LC_ALL _._/Python/localeutils.html#LC_ALL let LC_ALL 4 +nim LC_CTYPE _._/Python/localeutils.html#LC_CTYPE let LC_CTYPE 5 +nim c_setlocale _._/Python/localeutils.html#c_setlocale,cint,cstring proc c_setlocale(category: cint; v: cstring): cstring 6 +nim setlocale _._/Python/localeutils.html#setlocale.t,,string template setlocale(category; v: string): cstring 9 diff --git a/Lib/_._/Python/pylifecycle/signal.html b/Lib/_._/Python/pylifecycle/signal.html new file mode 100644 index 000000000..d7f3c953b --- /dev/null +++ b/Lib/_._/Python/pylifecycle/signal.html @@ -0,0 +1,145 @@ + + + + + + + +src/pylib/Python/pylifecycle/signal + + + + + + + + + + + + + + + + +
+
+

src/pylib/Python/pylifecycle/signal

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
proc PyOS_getsig(sig: cint): CSigHandler {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc PyOS_setsig(sig: cint; handler: CSigHandler): CSigHandler {....raises: [],
+    tags: [], forbids: [].}
+
+ + Python/pylifecycle.c PyOS_setsig + Source   +Edit   + +
+
+ +
+ +
+
+ + +
+
+ + +
+
+ + + diff --git a/Lib/_._/Python/pylifecycle/signal.idx b/Lib/_._/Python/pylifecycle/signal.idx new file mode 100644 index 000000000..282e198d4 --- /dev/null +++ b/Lib/_._/Python/pylifecycle/signal.idx @@ -0,0 +1,3 @@ +nimTitle signal _._/Python/pylifecycle/signal.html module src/pylib/Python/pylifecycle/signal 0 +nim PyOS_getsig _._/Python/pylifecycle/signal.html#PyOS_getsig,cint proc PyOS_getsig(sig: cint): CSigHandler 12 +nim PyOS_setsig _._/Python/pylifecycle/signal.html#PyOS_setsig,cint,CSigHandler proc PyOS_setsig(sig: cint; handler: CSigHandler): CSigHandler 26 diff --git a/Lib/_._/Python/pylifecycle/signal/c_syms.html b/Lib/_._/Python/pylifecycle/signal/c_syms.html new file mode 100644 index 000000000..00b010a16 --- /dev/null +++ b/Lib/_._/Python/pylifecycle/signal/c_syms.html @@ -0,0 +1,241 @@ + + + + + + + +src/pylib/Python/pylifecycle/signal/c_syms + + + + + + + + + + + + + + + + +
+
+

src/pylib/Python/pylifecycle/signal/c_syms

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

XXX: posix/winlean's a2 cannot be nil (a var Sigaction)

+ +
+

Lets

+
+
+
ITIMER_PROF {.importc, header: "<sys/time.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ITIMER_REAL {.importc, header: "<sys/time.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ITIMER_VIRTUAL {.importc, header: "<sys/time.h>".}: cint
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Consts

+
+
+
HAVE_BROKEN_PTHREAD_SIGMASK = false
+
+ + + Source   +Edit   + +
+
+
+
HAVE_SIGSET_T = true
+
+ + + Source   +Edit   + +
+
+
+
PYPTHREAD_SIGMASK = true
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
proc c_signal(a1: cint; a2: CSigHandler): CSigHandler {.importc: "signal",
+    header: "<signal.h>", ...raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc sigaction(a1: cint; a2: ptr Sigaction; a3: var Sigaction): cint {.
+    importc: "sigaction", header: "<sys/signal.h>", ...raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ + +
+
+ + +
+
+ + + diff --git a/Lib/_._/Python/pylifecycle/signal/c_syms.idx b/Lib/_._/Python/pylifecycle/signal/c_syms.idx new file mode 100644 index 000000000..543beb6e3 --- /dev/null +++ b/Lib/_._/Python/pylifecycle/signal/c_syms.idx @@ -0,0 +1,9 @@ +nimTitle c_syms _._/Python/pylifecycle/signal/c_syms.html module src/pylib/Python/pylifecycle/signal/c_syms 0 +nim HAVE_BROKEN_PTHREAD_SIGMASK _._/Python/pylifecycle/signal/c_syms.html#HAVE_BROKEN_PTHREAD_SIGMASK const HAVE_BROKEN_PTHREAD_SIGMASK 5 +nim PYPTHREAD_SIGMASK _._/Python/pylifecycle/signal/c_syms.html#PYPTHREAD_SIGMASK const PYPTHREAD_SIGMASK 6 +nim HAVE_SIGSET_T _._/Python/pylifecycle/signal/c_syms.html#HAVE_SIGSET_T const HAVE_SIGSET_T 7 +nim ITIMER_REAL _._/Python/pylifecycle/signal/c_syms.html#ITIMER_REAL let ITIMER_REAL 35 +nim ITIMER_VIRTUAL _._/Python/pylifecycle/signal/c_syms.html#ITIMER_VIRTUAL let ITIMER_VIRTUAL 36 +nim ITIMER_PROF _._/Python/pylifecycle/signal/c_syms.html#ITIMER_PROF let ITIMER_PROF 37 +nim sigaction _._/Python/pylifecycle/signal/c_syms.html#sigaction,cint,ptr.Sigaction,Sigaction proc sigaction(a1: cint; a2: ptr Sigaction; a3: var Sigaction): cint 43 +nim c_signal _._/Python/pylifecycle/signal/c_syms.html#c_signal,cint,CSigHandler proc c_signal(a1: cint; a2: CSigHandler): CSigHandler 46 diff --git a/Lib/_._/Python/pylifecycle/signal/chk_util.html b/Lib/_._/Python/pylifecycle/signal/chk_util.html new file mode 100644 index 000000000..e50232cdc --- /dev/null +++ b/Lib/_._/Python/pylifecycle/signal/chk_util.html @@ -0,0 +1,109 @@ + + + + + + + +src/pylib/Python/pylifecycle/signal/chk_util + + + + + + + + + + + + + + + + +
+
+

src/pylib/Python/pylifecycle/signal/chk_util

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Templates

+
+
+
+
template ifInvalidOnVcc(signalnum: cint; handleExc)
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/Python/pylifecycle/signal/chk_util.idx b/Lib/_._/Python/pylifecycle/signal/chk_util.idx new file mode 100644 index 000000000..52c1fc620 --- /dev/null +++ b/Lib/_._/Python/pylifecycle/signal/chk_util.idx @@ -0,0 +1,2 @@ +nimTitle chk_util _._/Python/pylifecycle/signal/chk_util.html module src/pylib/Python/pylifecycle/signal/chk_util 0 +nim ifInvalidOnVcc _._/Python/pylifecycle/signal/chk_util.html#ifInvalidOnVcc.t,cint, template ifInvalidOnVcc(signalnum: cint; handleExc) 2 diff --git a/Lib/_._/Python/pylifecycle/signal/handler_types.html b/Lib/_._/Python/pylifecycle/signal/handler_types.html new file mode 100644 index 000000000..6be09c2c6 --- /dev/null +++ b/Lib/_._/Python/pylifecycle/signal/handler_types.html @@ -0,0 +1,125 @@ + + + + + + + +src/pylib/Python/pylifecycle/signal/handler_types + + + + + + + + + + + + + + + + +
+
+

src/pylib/Python/pylifecycle/signal/handler_types

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Types

+
+
+
CSigHandler = proc (signalnum: cint) {.noconv.}
+
+ + PyOS_sighandler_t + Source   +Edit   + +
+
+
+
NimSigHandler = proc (signalnum: int) {.nimcall.}
+
+ + + Source   +Edit   + +
+
+
+
PySigHandler = proc (signalnum: int; frame: PFrame) {.closure.}
+
+ + + Source   +Edit   + +
+
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/Python/pylifecycle/signal/handler_types.idx b/Lib/_._/Python/pylifecycle/signal/handler_types.idx new file mode 100644 index 000000000..849a3a2ec --- /dev/null +++ b/Lib/_._/Python/pylifecycle/signal/handler_types.idx @@ -0,0 +1,4 @@ +nimTitle handler_types _._/Python/pylifecycle/signal/handler_types.html module src/pylib/Python/pylifecycle/signal/handler_types 0 +nim PySigHandler _._/Python/pylifecycle/signal/handler_types.html#PySigHandler type PySigHandler 3 +nim CSigHandler _._/Python/pylifecycle/signal/handler_types.html#CSigHandler type CSigHandler 4 +nim NimSigHandler _._/Python/pylifecycle/signal/handler_types.html#NimSigHandler type NimSigHandler 5 diff --git a/Lib/_._/Python/pytime/deadline.html b/Lib/_._/Python/pytime/deadline.html new file mode 100644 index 000000000..49534ffa8 --- /dev/null +++ b/Lib/_._/Python/pytime/deadline.html @@ -0,0 +1,146 @@ + + + + + + + +src/pylib/Python/pytime/deadline + + + + + + + + + + + + + + + + +
+
+

src/pylib/Python/pytime/deadline

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Imports

+
+ monotonic, types, ops +
+
+
+

Procs

+
+
+
+
proc PyDeadline_Get(deadline: PyTime): PyTime {....raises: [], tags: [TimeEffect],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc PyDeadline_Init(timeout: PyTime): PyTime {....raises: [], tags: [TimeEffect],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ + +
+
+ + +
+
+ + + diff --git a/Lib/_._/Python/pytime/deadline.idx b/Lib/_._/Python/pytime/deadline.idx new file mode 100644 index 000000000..86172bafb --- /dev/null +++ b/Lib/_._/Python/pytime/deadline.idx @@ -0,0 +1,3 @@ +nimTitle deadline _._/Python/pytime/deadline.html module src/pylib/Python/pytime/deadline 0 +nim PyDeadline_Init _._/Python/pytime/deadline.html#PyDeadline_Init,PyTime proc PyDeadline_Init(timeout: PyTime): PyTime 5 +nim PyDeadline_Get _._/Python/pytime/deadline.html#PyDeadline_Get,PyTime proc PyDeadline_Get(deadline: PyTime): PyTime 9 diff --git a/Lib/_._/Python/pytime/exc_util.html b/Lib/_._/Python/pytime/exc_util.html new file mode 100644 index 000000000..b50f53d03 --- /dev/null +++ b/Lib/_._/Python/pytime/exc_util.html @@ -0,0 +1,109 @@ + + + + + + + +src/pylib/Python/pytime/exc_util + + + + + + + + + + + + + + + + +
+
+

src/pylib/Python/pytime/exc_util

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Procs

+
+
+
+
proc time_t_overflow() {....raises: [], tags: [], forbids: [].}
+
+ + pytime_time_t_overflow + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/Python/pytime/exc_util.idx b/Lib/_._/Python/pytime/exc_util.idx new file mode 100644 index 000000000..c8b51b3be --- /dev/null +++ b/Lib/_._/Python/pytime/exc_util.idx @@ -0,0 +1,2 @@ +nimTitle exc_util _._/Python/pytime/exc_util.html module src/pylib/Python/pytime/exc_util 0 +nim time_t_overflow _._/Python/pytime/exc_util.html#time_t_overflow proc time_t_overflow() 2 diff --git a/Lib/_._/Python/pytime/monotonic.html b/Lib/_._/Python/pytime/monotonic.html new file mode 100644 index 000000000..de9108279 --- /dev/null +++ b/Lib/_._/Python/pytime/monotonic.html @@ -0,0 +1,119 @@ + + + + + + + +src/pylib/Python/pytime/monotonic + + + + + + + + + + + + + + + + +
+
+

src/pylib/Python/pytime/monotonic

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Imports

+
+ types +
+
+
+

Procs

+
+
+
+
proc monotonicRaw(res: var PyTime): bool {....raises: [], tags: [TimeEffect],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/Python/pytime/monotonic.idx b/Lib/_._/Python/pytime/monotonic.idx new file mode 100644 index 000000000..be28ae566 --- /dev/null +++ b/Lib/_._/Python/pytime/monotonic.idx @@ -0,0 +1,2 @@ +nimTitle monotonic _._/Python/pytime/monotonic.html module src/pylib/Python/pytime/monotonic 0 +nim monotonicRaw _._/Python/pytime/monotonic.html#monotonicRaw,PyTime proc monotonicRaw(res: var PyTime): bool 10 diff --git a/Lib/_._/Python/pytime/ops.html b/Lib/_._/Python/pytime/ops.html new file mode 100644 index 000000000..89f75a5a9 --- /dev/null +++ b/Lib/_._/Python/pytime/ops.html @@ -0,0 +1,188 @@ + + + + + + + +src/pylib/Python/pytime/ops + + + + + + + + + + + + + + + + +
+
+

src/pylib/Python/pytime/ops

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Imports

+
+ types +
+
+
+

Procs

+
+
+
+
proc add(t1, t2: PyTime): PyTime {....raises: [], tags: [], forbids: [].}
+
+ + _PyTime_Add + Source   +Edit   + +
+
+ +
+
+
+
proc divide(t, k: PyTime; round: PyTime_round_t): PyTime {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc divide_round_up(t, k: PyTime): PyTime {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc divmod(t, k: PyTime; pq, pr: var PyTime): bool {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc iadd(t1: var PyTime; t2: PyTime): bool {....raises: [], tags: [], forbids: [].}
+
+ + pytime_add + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/Python/pytime/ops.idx b/Lib/_._/Python/pytime/ops.idx new file mode 100644 index 000000000..eb895d26e --- /dev/null +++ b/Lib/_._/Python/pytime/ops.idx @@ -0,0 +1,6 @@ +nimTitle ops _._/Python/pytime/ops.html module src/pylib/Python/pytime/ops 0 +nim iadd _._/Python/pytime/ops.html#iadd,PyTime,PyTime proc iadd(t1: var PyTime; t2: PyTime): bool 5 +nim add _._/Python/pytime/ops.html#add,PyTime,PyTime proc add(t1, t2: PyTime): PyTime 17 +nim divide_round_up _._/Python/pytime/ops.html#divide_round_up,PyTime,PyTime proc divide_round_up(t, k: PyTime): PyTime 22 +nim divide _._/Python/pytime/ops.html#divide,PyTime,PyTime,PyTime_round_t proc divide(t, k: PyTime; round: PyTime_round_t): PyTime 34 +nim divmod _._/Python/pytime/ops.html#divmod,PyTime,PyTime,PyTime,PyTime proc divmod(t, k: PyTime; pq, pr: var PyTime): bool 56 diff --git a/Lib/_._/Python/pytime/pytimeAsTimeval.html b/Lib/_._/Python/pytime/pytimeAsTimeval.html new file mode 100644 index 000000000..b61f0a1bf --- /dev/null +++ b/Lib/_._/Python/pytime/pytimeAsTimeval.html @@ -0,0 +1,119 @@ + + + + + + + +src/pylib/Python/pytime/pytimeAsTimeval + + + + + + + + + + + + + + + + +
+
+

src/pylib/Python/pytime/pytimeAsTimeval

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
proc asTimeval(t: PyTime; round: PyTime_round_t): Timeval {....raises: [],
+    tags: [], forbids: [].}
+
+ + _PyTime_AsTimeval + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/Python/pytime/pytimeAsTimeval.idx b/Lib/_._/Python/pytime/pytimeAsTimeval.idx new file mode 100644 index 000000000..cdf553412 --- /dev/null +++ b/Lib/_._/Python/pytime/pytimeAsTimeval.idx @@ -0,0 +1,2 @@ +nimTitle pytimeAsTimeval _._/Python/pytime/pytimeAsTimeval.html module src/pylib/Python/pytime/pytimeAsTimeval 0 +nim asTimeval _._/Python/pytime/pytimeAsTimeval.html#asTimeval,, proc asTimeval(t: PyTime; round: PyTime_round_t): Timeval 58 diff --git a/Lib/_._/Python/pytime/pytimeFromSeconds.html b/Lib/_._/Python/pytime/pytimeFromSeconds.html new file mode 100644 index 000000000..e8ce87722 --- /dev/null +++ b/Lib/_._/Python/pytime/pytimeFromSeconds.html @@ -0,0 +1,118 @@ + + + + + + + +src/pylib/Python/pytime/pytimeFromSeconds + + + + + + + + + + + + + + + + +
+
+

src/pylib/Python/pytime/pytimeFromSeconds

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
proc fromSecondsObject(tp; obj: Timestamp; round: PyTime_round_t)
+
+ + _PyTime_FromSecondsObject + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/Python/pytime/pytimeFromSeconds.idx b/Lib/_._/Python/pytime/pytimeFromSeconds.idx new file mode 100644 index 000000000..079472772 --- /dev/null +++ b/Lib/_._/Python/pytime/pytimeFromSeconds.idx @@ -0,0 +1,2 @@ +nimTitle pytimeFromSeconds _._/Python/pytime/pytimeFromSeconds.html module src/pylib/Python/pytime/pytimeFromSeconds 0 +nim fromSecondsObject _._/Python/pytime/pytimeFromSeconds.html#fromSecondsObject,,Timestamp, proc fromSecondsObject(tp; obj: Timestamp; round: PyTime_round_t) 36 diff --git a/Lib/_._/Python/pytime/rounds.html b/Lib/_._/Python/pytime/rounds.html new file mode 100644 index 000000000..7b499fe0d --- /dev/null +++ b/Lib/_._/Python/pytime/rounds.html @@ -0,0 +1,136 @@ + + + + + + + +src/pylib/Python/pytime/rounds + + + + + + + + + + + + + + + + +
+
+

src/pylib/Python/pytime/rounds

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Imports

+
+ types +
+
+
+

Procs

+
+
+
+
func round(x: float; round: PyTime_round_t): float {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func round_half_even(x: float): float {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/Python/pytime/rounds.idx b/Lib/_._/Python/pytime/rounds.idx new file mode 100644 index 000000000..86bd51b2e --- /dev/null +++ b/Lib/_._/Python/pytime/rounds.idx @@ -0,0 +1,3 @@ +nimTitle rounds _._/Python/pytime/rounds.html module src/pylib/Python/pytime/rounds 0 +nim round_half_even _._/Python/pytime/rounds.html#round_half_even,float proc round_half_even(x: float): float 5 +nim round _._/Python/pytime/rounds.html#round,float,PyTime_round_t proc round(x: float; round: PyTime_round_t): float 11 diff --git a/Lib/_._/Python/pytime/time_t_decl.html b/Lib/_._/Python/pytime/time_t_decl.html new file mode 100644 index 000000000..02dd1edb0 --- /dev/null +++ b/Lib/_._/Python/pytime/time_t_decl.html @@ -0,0 +1,150 @@ + + + + + + + +src/pylib/Python/pytime/time_t_decl + + + + + + + + + + + + + + + + +
+
+

src/pylib/Python/pytime/time_t_decl

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Types

+
+
+
time_t {.importc.} = int64
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Consts

+
+
+
PY_TIME_T_MAX = 9223372036854775807'i64
+
+ + + Source   +Edit   + +
+
+
+
PY_TIME_T_MIN = -9223372036854775808'i64
+
+ + + Source   +Edit   + +
+
+
+
SIZEOF_TIME_T = 8
+
+ + + Source   +Edit   + +
+
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/Python/pytime/time_t_decl.idx b/Lib/_._/Python/pytime/time_t_decl.idx new file mode 100644 index 000000000..363e9085a --- /dev/null +++ b/Lib/_._/Python/pytime/time_t_decl.idx @@ -0,0 +1,5 @@ +nimTitle time_t_decl _._/Python/pytime/time_t_decl.html module src/pylib/Python/pytime/time_t_decl 0 +nim time_t _._/Python/pytime/time_t_decl.html#time_t type time_t 14 +nim SIZEOF_TIME_T _._/Python/pytime/time_t_decl.html#SIZEOF_TIME_T const SIZEOF_TIME_T 22 +nim PY_TIME_T_MAX _._/Python/pytime/time_t_decl.html#PY_TIME_T_MAX const PY_TIME_T_MAX 23 +nim PY_TIME_T_MIN _._/Python/pytime/time_t_decl.html#PY_TIME_T_MIN const PY_TIME_T_MIN 24 diff --git a/Lib/_._/Python/pytime/types.html b/Lib/_._/Python/pytime/types.html new file mode 100644 index 000000000..60331dc5e --- /dev/null +++ b/Lib/_._/Python/pytime/types.html @@ -0,0 +1,181 @@ + + + + + + + +src/pylib/Python/pytime/types + + + + + + + + + + + + + + + + +
+
+

src/pylib/Python/pytime/types

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Imports

+
+ time_t_decl +
+
+
+

Types

+
+
+
long = clong
+
+ + + Source   +Edit   + +
+
+
+
PyTime = int64
+
+ + PyTime_t, time in ns + Source   +Edit   + +
+
+
+
PyTime_round_t = enum
+  prFLoor, prCeiling, prHalfEven, prRoundUp
+
+ + _PyTime_round_t + Source   +Edit   + +
+
+
+
Timestamp = int | float
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Consts

+
+
+
prTimeout = prRoundUp
+
+ + + Source   +Edit   + +
+
+ +
+
+ + +
+
+ + +
+
+ + + diff --git a/Lib/_._/Python/pytime/types.idx b/Lib/_._/Python/pytime/types.idx new file mode 100644 index 000000000..1a7aa2c6c --- /dev/null +++ b/Lib/_._/Python/pytime/types.idx @@ -0,0 +1,10 @@ +nimTitle types _._/Python/pytime/types.html module src/pylib/Python/pytime/types 0 +nim long _._/Python/pytime/types.html#long type long 6 +nim Timestamp _._/Python/pytime/types.html#Timestamp type Timestamp 9 +nim PyTime _._/Python/pytime/types.html#PyTime type PyTime 10 +nim prFLoor _._/Python/pytime/types.html#prFLoor PyTime_round_t.prFLoor 15 +nim prCeiling _._/Python/pytime/types.html#prCeiling PyTime_round_t.prCeiling 15 +nim prHalfEven _._/Python/pytime/types.html#prHalfEven PyTime_round_t.prHalfEven 15 +nim prRoundUp _._/Python/pytime/types.html#prRoundUp PyTime_round_t.prRoundUp 15 +nim PyTime_round_t _._/Python/pytime/types.html#PyTime_round_t enum PyTime_round_t 15 +nim prTimeout _._/Python/pytime/types.html#prTimeout const prTimeout 21 diff --git a/Lib/_._/Python/pytime/units.html b/Lib/_._/Python/pytime/units.html new file mode 100644 index 000000000..818be8de1 --- /dev/null +++ b/Lib/_._/Python/pytime/units.html @@ -0,0 +1,191 @@ + + + + + + + +src/pylib/Python/pytime/units + + + + + + + + + + + + + + + + +
+
+

src/pylib/Python/pytime/units

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Consts

+
+
+
MS_TO_NS = 1000000
+
+ + + Source   +Edit   + +
+
+
+
MS_TO_US = 1000
+
+ + + Source   +Edit   + +
+
+
+
NS_TO_100NS = 100
+
+ + + Source   +Edit   + +
+
+
+
NS_TO_MS = 1000000
+
+ + + Source   +Edit   + +
+
+
+
NS_TO_US = 1000
+
+ + + Source   +Edit   + +
+
+
+
SEC_TO_MS = 1000
+
+ + + Source   +Edit   + +
+
+
+
SEC_TO_NS = 1000000000
+
+ + + Source   +Edit   + +
+
+
+
SEC_TO_US = 1000000
+
+ + + Source   +Edit   + +
+
+
+
US_TO_NS = 1000
+
+ + + Source   +Edit   + +
+
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/Python/pytime/units.idx b/Lib/_._/Python/pytime/units.idx new file mode 100644 index 000000000..802d8ff62 --- /dev/null +++ b/Lib/_._/Python/pytime/units.idx @@ -0,0 +1,10 @@ +nimTitle units _._/Python/pytime/units.html module src/pylib/Python/pytime/units 0 +nim SEC_TO_MS _._/Python/pytime/units.html#SEC_TO_MS const SEC_TO_MS 3 +nim MS_TO_US _._/Python/pytime/units.html#MS_TO_US const MS_TO_US 5 +nim SEC_TO_US _._/Python/pytime/units.html#SEC_TO_US const SEC_TO_US 6 +nim US_TO_NS _._/Python/pytime/units.html#US_TO_NS const US_TO_NS 8 +nim MS_TO_NS _._/Python/pytime/units.html#MS_TO_NS const MS_TO_NS 9 +nim SEC_TO_NS _._/Python/pytime/units.html#SEC_TO_NS const SEC_TO_NS 10 +nim NS_TO_MS _._/Python/pytime/units.html#NS_TO_MS const NS_TO_MS 12 +nim NS_TO_US _._/Python/pytime/units.html#NS_TO_US const NS_TO_US 13 +nim NS_TO_100NS _._/Python/pytime/units.html#NS_TO_100NS const NS_TO_100NS 14 diff --git a/Lib/_._/Python/unicodeobject/char_decl.html b/Lib/_._/Python/unicodeobject/char_decl.html new file mode 100644 index 000000000..be47f5334 --- /dev/null +++ b/Lib/_._/Python/unicodeobject/char_decl.html @@ -0,0 +1,125 @@ + + + + + + + +src/pylib/Python/unicodeobject/char_decl + + + + + + + + + + + + + + + + +
+
+

src/pylib/Python/unicodeobject/char_decl

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Types

+
+
+
Py_UCS1 = uint8
+
+ + + Source   +Edit   + +
+
+
+
Py_UCS2 = uint16
+
+ + + Source   +Edit   + +
+
+
+
Py_UCS4 = uint32
+
+ + + Source   +Edit   + +
+
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/Python/unicodeobject/char_decl.idx b/Lib/_._/Python/unicodeobject/char_decl.idx new file mode 100644 index 000000000..eddcce2ef --- /dev/null +++ b/Lib/_._/Python/unicodeobject/char_decl.idx @@ -0,0 +1,4 @@ +nimTitle char_decl _._/Python/unicodeobject/char_decl.html module src/pylib/Python/unicodeobject/char_decl 0 +nim Py_UCS1 _._/Python/unicodeobject/char_decl.html#Py_UCS1 type Py_UCS1 3 +nim Py_UCS2 _._/Python/unicodeobject/char_decl.html#Py_UCS2 type Py_UCS2 4 +nim Py_UCS4 _._/Python/unicodeobject/char_decl.html#Py_UCS4 type Py_UCS4 5 diff --git a/Lib/_._/Python/unicodeobject/codecs.html b/Lib/_._/Python/unicodeobject/codecs.html new file mode 100644 index 000000000..dedd12482 --- /dev/null +++ b/Lib/_._/Python/unicodeobject/codecs.html @@ -0,0 +1,226 @@ + + + + + + + +src/pylib/Python/unicodeobject/codecs + + + + + + + + + + + + + + + + +
+
+

src/pylib/Python/unicodeobject/codecs

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

Mask to quickly check whether a C 'size_t' contains a non-ASCII, UTF8-encoded char.10xxxxxx

+ +
+

Consts

+
+
+
ALIGNOF_SIZE_T = 8
+
+ + + Source   +Edit   + +
+
+
+
ASCII_CHAR_MASK = 0x80808080'u
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
func getMaxChar[C](): C
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc utf8_decode[STRINGLIB_CHAR](inptr: var (cstring | ptr char);
+                                 end: (cstring | ptr char);
+                                 dest: ptr STRINGLIB_CHAR;
+                                 outpos: var Py_ssize_t): Py_UCS4
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template IS_CONTINUATION_BYTE(ch: untyped): untyped
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template Py_IS_ALIGNED(p: cstring | ptr; a: typeof(ALIGNOF_SIZE_T)): bool
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/Python/unicodeobject/codecs.idx b/Lib/_._/Python/unicodeobject/codecs.idx new file mode 100644 index 000000000..36fc47224 --- /dev/null +++ b/Lib/_._/Python/unicodeobject/codecs.idx @@ -0,0 +1,7 @@ +nimTitle codecs _._/Python/unicodeobject/codecs.html module src/pylib/Python/unicodeobject/codecs 0 +nim ASCII_CHAR_MASK _._/Python/unicodeobject/codecs.html#ASCII_CHAR_MASK const ASCII_CHAR_MASK 15 +nim IS_CONTINUATION_BYTE _._/Python/unicodeobject/codecs.html#IS_CONTINUATION_BYTE.t,untyped template IS_CONTINUATION_BYTE(ch: untyped): untyped 23 +nim ALIGNOF_SIZE_T _._/Python/unicodeobject/codecs.html#ALIGNOF_SIZE_T const ALIGNOF_SIZE_T 29 +nim Py_IS_ALIGNED _._/Python/unicodeobject/codecs.html#Py_IS_ALIGNED.t,, template Py_IS_ALIGNED(p: cstring | ptr; a: typeof(ALIGNOF_SIZE_T)): bool 31 +nim getMaxChar _._/Python/unicodeobject/codecs.html#getMaxChar proc getMaxChar[C](): C 34 +nim utf8_decode _._/Python/unicodeobject/codecs.html#utf8_decode,,,ptr.STRINGLIB_CHAR,Py_ssize_t proc utf8_decode[STRINGLIB_CHAR](inptr: var (cstring | ptr char);\n end: (cstring | ptr char); dest: ptr STRINGLIB_CHAR;\n outpos: var Py_ssize_t): Py_UCS4 43 diff --git a/Lib/_._/Python/unicodeobject/cstring_ptr_op.html b/Lib/_._/Python/unicodeobject/cstring_ptr_op.html new file mode 100644 index 000000000..db8b222fc --- /dev/null +++ b/Lib/_._/Python/unicodeobject/cstring_ptr_op.html @@ -0,0 +1,186 @@ + + + + + + + +src/pylib/Python/unicodeobject/cstring_ptr_op + + + + + + + + + + + + + + + + +
+
+

src/pylib/Python/unicodeobject/cstring_ptr_op

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Imports

+
+ ptr_types +
+
+
+

Templates

+
+
+
+
template `+`[I: IndexType](s: cstring; i: I): cstring
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template `-`(a, b: cstring): ptrdiff_t
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template `<%`(a, b: cstring): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template `<=%`(a, b: cstring): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template inc(s: cstring; i = 1)
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/Python/unicodeobject/cstring_ptr_op.idx b/Lib/_._/Python/unicodeobject/cstring_ptr_op.idx new file mode 100644 index 000000000..7cb07cd45 --- /dev/null +++ b/Lib/_._/Python/unicodeobject/cstring_ptr_op.idx @@ -0,0 +1,6 @@ +nimTitle cstring_ptr_op _._/Python/unicodeobject/cstring_ptr_op.html module src/pylib/Python/unicodeobject/cstring_ptr_op 0 +nim `+` _._/Python/unicodeobject/cstring_ptr_op.html#+.t,cstring,I template `+`[I: IndexType](s: cstring; i: I): cstring 6 +nim inc _._/Python/unicodeobject/cstring_ptr_op.html#inc.t,cstring,int template inc(s: cstring; i = 1) 9 +nim `-` _._/Python/unicodeobject/cstring_ptr_op.html#-.t,cstring,cstring template `-`(a, b: cstring): ptrdiff_t 11 +nim `<%` _._/Python/unicodeobject/cstring_ptr_op.html#<%.t,cstring,cstring template `<%`(a, b: cstring): bool 14 +nim `<=%` _._/Python/unicodeobject/cstring_ptr_op.html#<=%.t,cstring,cstring template `<=%`(a, b: cstring): bool 17 diff --git a/Lib/_._/Python/unicodeobject/locale_codec.html b/Lib/_._/Python/unicodeobject/locale_codec.html new file mode 100644 index 000000000..38ce306bc --- /dev/null +++ b/Lib/_._/Python/unicodeobject/locale_codec.html @@ -0,0 +1,119 @@ + + + + + + + +src/pylib/Python/unicodeobject/locale_codec + + + + + + + + + + + + + + + + +
+
+

src/pylib/Python/unicodeobject/locale_codec

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
proc PyUnicode_DecodeLocale(str: PyStrData; errors: string): string {.
+    ...raises: [ValueError, UnicodeDecodeError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/Python/unicodeobject/locale_codec.idx b/Lib/_._/Python/unicodeobject/locale_codec.idx new file mode 100644 index 000000000..4da25bb2c --- /dev/null +++ b/Lib/_._/Python/unicodeobject/locale_codec.idx @@ -0,0 +1,2 @@ +nimTitle locale_codec _._/Python/unicodeobject/locale_codec.html module src/pylib/Python/unicodeobject/locale_codec 0 +nim PyUnicode_DecodeLocale _._/Python/unicodeobject/locale_codec.html#PyUnicode_DecodeLocale,PyStrData,string proc PyUnicode_DecodeLocale(str: PyStrData; errors: string): string 38 diff --git a/Lib/_._/Python/unicodeobject/ptr_op.html b/Lib/_._/Python/unicodeobject/ptr_op.html new file mode 100644 index 000000000..b9defe38b --- /dev/null +++ b/Lib/_._/Python/unicodeobject/ptr_op.html @@ -0,0 +1,203 @@ + + + + + + + +src/pylib/Python/unicodeobject/ptr_op + + + + + + + + + + + + + + + + +
+
+

src/pylib/Python/unicodeobject/ptr_op

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Imports

+
+ ptr_types +
+
+
+

Templates

+
+
+
+
template `+`[I: IndexType; T](s: ptr T; i: I): ptr T
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template `-`[T](a, b: ptr T): ptrdiff_t
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template `<%`[T](a, b: ptr T): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template `<=%`[T](a, b: ptr T): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template `[]`[I: IndexType; T](p: ptr T; i: I): T
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template inc[T](s: ptr T; i = 1)
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/Python/unicodeobject/ptr_op.idx b/Lib/_._/Python/unicodeobject/ptr_op.idx new file mode 100644 index 000000000..97aa1fb02 --- /dev/null +++ b/Lib/_._/Python/unicodeobject/ptr_op.idx @@ -0,0 +1,7 @@ +nimTitle ptr_op _._/Python/unicodeobject/ptr_op.html module src/pylib/Python/unicodeobject/ptr_op 0 +nim `+` _._/Python/unicodeobject/ptr_op.html#+.t,ptr.T,I template `+`[I: IndexType; T](s: ptr T; i: I): ptr T 5 +nim inc _._/Python/unicodeobject/ptr_op.html#inc.t,ptr.T,int template inc[T](s: ptr T; i = 1) 8 +nim `-` _._/Python/unicodeobject/ptr_op.html#-.t,ptr.T,ptr.T template `-`[T](a, b: ptr T): ptrdiff_t 10 +nim `<%` _._/Python/unicodeobject/ptr_op.html#<%.t,ptr.T,ptr.T template `<%`[T](a, b: ptr T): bool 13 +nim `<=%` _._/Python/unicodeobject/ptr_op.html#<=%.t,ptr.T,ptr.T template `<=%`[T](a, b: ptr T): bool 16 +nim `[]` _._/Python/unicodeobject/ptr_op.html#[].t,ptr.T,I template `[]`[I: IndexType; T](p: ptr T; i: I): T 19 diff --git a/Lib/_._/Python/unicodeobject/ptr_types.html b/Lib/_._/Python/unicodeobject/ptr_types.html new file mode 100644 index 000000000..0a32e8eff --- /dev/null +++ b/Lib/_._/Python/unicodeobject/ptr_types.html @@ -0,0 +1,103 @@ + + + + + + + +src/pylib/Python/unicodeobject/ptr_types + + + + + + + + + + + + + + + + +
+
+

src/pylib/Python/unicodeobject/ptr_types

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Types

+
+
+
ptrdiff_t = int
+
+ + + Source   +Edit   + +
+
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/Python/unicodeobject/ptr_types.idx b/Lib/_._/Python/unicodeobject/ptr_types.idx new file mode 100644 index 000000000..1738657fc --- /dev/null +++ b/Lib/_._/Python/unicodeobject/ptr_types.idx @@ -0,0 +1,2 @@ +nimTitle ptr_types _._/Python/unicodeobject/ptr_types.html module src/pylib/Python/unicodeobject/ptr_types 0 +nim ptrdiff_t _._/Python/unicodeobject/ptr_types.html#ptrdiff_t type ptrdiff_t 2 diff --git a/Lib/_._/Python/unicodeobject/utf8_codec.html b/Lib/_._/Python/unicodeobject/utf8_codec.html new file mode 100644 index 000000000..95a2ff5a7 --- /dev/null +++ b/Lib/_._/Python/unicodeobject/utf8_codec.html @@ -0,0 +1,152 @@ + + + + + + + +src/pylib/Python/unicodeobject/utf8_codec + + + + + + + + + + + + + + + + +
+
+

src/pylib/Python/unicodeobject/utf8_codec

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Consts

+
+
+
MaxWStrLen = 2305843009213693951
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
proc Py_DecodeUTF8Ex(orig_s: cstring; size: csize_t; wstr: var ptr wchar_t;
+                     wlen: ptr csize_t; reason: var cstring;
+                     errors: Py_error_handler): int {....raises: [], tags: [],
+    forbids: [].}
+
+ +

UTF-8 decoder: use surrogateescape error handler if 'surrogateescape' is non-zero, use strict error handler otherwise.

+

On success, write a pointer to a newly allocated wide character string into wstr (use PyMem_RawFree() to free the memory) and write the output length (in number of wchar_t units) into wlen (if wlen is set).

+

On memory allocation failure, return -1.

+

On decoding error (if surrogateescape is zero), return -2. If wlen is non-NULL, write the start of the illegal byte sequence into wlen. If reason is not NULL, write the decoding error message into reason.

+ + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/Python/unicodeobject/utf8_codec.idx b/Lib/_._/Python/unicodeobject/utf8_codec.idx new file mode 100644 index 000000000..a1ed96e59 --- /dev/null +++ b/Lib/_._/Python/unicodeobject/utf8_codec.idx @@ -0,0 +1,3 @@ +nimTitle utf8_codec _._/Python/unicodeobject/utf8_codec.html module src/pylib/Python/unicodeobject/utf8_codec 0 +nim MaxWStrLen _._/Python/unicodeobject/utf8_codec.html#MaxWStrLen const MaxWStrLen 10 +nim Py_DecodeUTF8Ex _._/Python/unicodeobject/utf8_codec.html#Py_DecodeUTF8Ex,cstring,csize_t,ptr.wchar_t,ptr.csize_t,cstring,Py_error_handler proc Py_DecodeUTF8Ex(orig_s: cstring; size: csize_t; wstr: var ptr wchar_t;\n wlen: ptr csize_t; reason: var cstring; errors: Py_error_handler): int 30 diff --git a/Lib/_._/Python/unicodeobject/wchar_utils.html b/Lib/_._/Python/unicodeobject/wchar_utils.html new file mode 100644 index 000000000..043c44451 --- /dev/null +++ b/Lib/_._/Python/unicodeobject/wchar_utils.html @@ -0,0 +1,205 @@ + + + + + + + +src/pylib/Python/unicodeobject/wchar_utils + + + + + + + + + + + + + + + + +
+
+

src/pylib/Python/unicodeobject/wchar_utils

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Imports

+
+ ../wchar_t +
+
+
+

Procs

+
+
+
+
proc `$`(s; le: int): string {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc `$`(s; size = s.size): string {....raises: [], tags: [], forbids: [].}
+
+ +
Warning: +as equal to s$Natural(size)
+ + Source   +Edit   + +
+
+ +
+
+
+
proc len(s): int {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc size(s): csize_t {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Iterators

+
+
+
+
iterator items(s): wchar_t {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ + +
+
+ + +
+
+ + + diff --git a/Lib/_._/Python/unicodeobject/wchar_utils.idx b/Lib/_._/Python/unicodeobject/wchar_utils.idx new file mode 100644 index 000000000..0bdd89bfb --- /dev/null +++ b/Lib/_._/Python/unicodeobject/wchar_utils.idx @@ -0,0 +1,7 @@ +nimTitle wchar_utils _._/Python/unicodeobject/wchar_utils.html module src/pylib/Python/unicodeobject/wchar_utils 0 +nim len _._/Python/unicodeobject/wchar_utils.html#len proc len(s): int 8 +nim size _._/Python/unicodeobject/wchar_utils.html#size proc size(s): csize_t 12 +nim items _._/Python/unicodeobject/wchar_utils.html#items.i iterator items(s): wchar_t 16 +nim `$` _._/Python/unicodeobject/wchar_utils.html#$ proc `$`(s; size = s.size): string 29 +nim `$` _._/Python/unicodeobject/wchar_utils.html#$,,int proc `$`(s; le: int): string 34 +nimgrp $ _._/Python/unicodeobject/wchar_utils.html#$-procs-all proc 29 diff --git a/Lib/_._/Python/wchar_t.html b/Lib/_._/Python/wchar_t.html new file mode 100644 index 000000000..9b693a4f2 --- /dev/null +++ b/Lib/_._/Python/wchar_t.html @@ -0,0 +1,383 @@ + + + + + + + +src/pylib/Python/wchar_t + + + + + + + + + + + + + + + + +
+
+

src/pylib/Python/wchar_t

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Types

+
+
+
mbstate_t {.importc, header: "wchar.h>".} = object
+
+ + + Source   +Edit   + +
+
+
+
wchar_t {.importc, header: "<wchar.h>".} = uint32
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Consts

+
+
+
DECODE_ERROR = -1
+
+ + + Source   +Edit   + +
+
+
+
HAVE_MBRTOWC = true
+
+ + + Source   +Edit   + +
+
+
+
INCOMPLETE_CHARACTER = -2
+
+ + + Source   +Edit   + +
+
+
+
MAX_UNICODE_val = 0x0010FFFF
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
proc `[]`(p: ptr wchar_t; i: csize_t): wchar_t {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc `[]`(p: ptr wchar_t; i: int): wchar_t {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc `[]=`[I: csize_t | int](p: ptr wchar_t; i: I; val: wchar_t)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc is_valid_wide_char(ch: wchar_t): bool {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func ord(wc: wchar_t): int {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc Py_mbrtowc(wc: PWc; src: cstring; n: csize_t; mbs: var mbstate_t): csize_t
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc Py_mbstowcs(dest: ptr wchar_t; src: cstring; n: csize_t): csize_t {.
+    ...raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template allocWcharArr[I](n: I): ptr wchar_t
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template deallocWcArr(p: ptr wchar_t)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template inc[I](p: var ptr wchar_t; i: I = 1)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template Py_UNICODE_IS_SURROGATE(ch: wchar_t): bool
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/Python/wchar_t.idx b/Lib/_._/Python/wchar_t.idx new file mode 100644 index 000000000..c0d6ef109 --- /dev/null +++ b/Lib/_._/Python/wchar_t.idx @@ -0,0 +1,19 @@ +nimTitle wchar_t _._/Python/wchar_t.html module src/pylib/Python/wchar_t 0 +nim wchar_t _._/Python/wchar_t.html#wchar_t type wchar_t 5 +nim ord _._/Python/wchar_t.html#ord,wchar_t proc ord(wc: wchar_t): int 7 +nim allocWcharArr _._/Python/wchar_t.html#allocWcharArr.t,I template allocWcharArr[I](n: I): ptr wchar_t 9 +nim deallocWcArr _._/Python/wchar_t.html#deallocWcArr.t,ptr.wchar_t template deallocWcArr(p: ptr wchar_t) 11 +nim mbstate_t _._/Python/wchar_t.html#mbstate_t object mbstate_t 14 +nim Py_UNICODE_IS_SURROGATE _._/Python/wchar_t.html#Py_UNICODE_IS_SURROGATE.t,wchar_t template Py_UNICODE_IS_SURROGATE(ch: wchar_t): bool 18 +nim MAX_UNICODE_val _._/Python/wchar_t.html#MAX_UNICODE_val const MAX_UNICODE_val 20 +nim is_valid_wide_char _._/Python/wchar_t.html#is_valid_wide_char,wchar_t proc is_valid_wide_char(ch: wchar_t): bool 26 +nim HAVE_MBRTOWC _._/Python/wchar_t.html#HAVE_MBRTOWC const HAVE_MBRTOWC 55 +nim DECODE_ERROR _._/Python/wchar_t.html#DECODE_ERROR const DECODE_ERROR 59 +nim INCOMPLETE_CHARACTER _._/Python/wchar_t.html#INCOMPLETE_CHARACTER const INCOMPLETE_CHARACTER 60 +nim `[]` _._/Python/wchar_t.html#[],ptr.wchar_t,csize_t proc `[]`(p: ptr wchar_t; i: csize_t): wchar_t 62 +nim `[]` _._/Python/wchar_t.html#[],ptr.wchar_t,int proc `[]`(p: ptr wchar_t; i: int): wchar_t 64 +nim `[]=` _._/Python/wchar_t.html#[]=,ptr.wchar_t,I,wchar_t proc `[]=`[I: csize_t | int](p: ptr wchar_t; i: I; val: wchar_t) 67 +nim inc _._/Python/wchar_t.html#inc.t,ptr.wchar_t,I template inc[I](p: var ptr wchar_t; i: I = 1) 69 +nim Py_mbstowcs _._/Python/wchar_t.html#Py_mbstowcs,ptr.wchar_t,cstring,csize_t proc Py_mbstowcs(dest: ptr wchar_t; src: cstring; n: csize_t): csize_t 75 +nim Py_mbrtowc _._/Python/wchar_t.html#Py_mbrtowc,PWc,cstring,csize_t,mbstate_t proc Py_mbrtowc(wc: PWc; src: cstring; n: csize_t; mbs: var mbstate_t): csize_t 87 +nimgrp [] _._/Python/wchar_t.html#[]-procs-all proc 62 diff --git a/Lib/_._/builtins/asciiImpl.html b/Lib/_._/builtins/asciiImpl.html new file mode 100644 index 000000000..df0976e6d --- /dev/null +++ b/Lib/_._/builtins/asciiImpl.html @@ -0,0 +1,111 @@ + + + + + + + +src/pylib/builtins/asciiImpl + + + + + + + + + + + + + + + + +
+
+

src/pylib/builtins/asciiImpl

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Procs

+
+
+
+
func pyasciiImpl(us: string): string {....raises: [], tags: [], forbids: [].}
+
+ +

Python's ascii impl

+

Note this assumes us is already processed by repr i.e., this only escape the non-ASCII characters in us using x, u, or U escapes and doesn't touch ASCII characters.

+ + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/builtins/asciiImpl.idx b/Lib/_._/builtins/asciiImpl.idx new file mode 100644 index 000000000..2ee3ba7e2 --- /dev/null +++ b/Lib/_._/builtins/asciiImpl.idx @@ -0,0 +1,2 @@ +nimTitle asciiImpl _._/builtins/asciiImpl.html module src/pylib/builtins/asciiImpl 0 +nim pyasciiImpl _._/builtins/asciiImpl.html#pyasciiImpl,string proc pyasciiImpl(us: string): string 10 diff --git a/Lib/_._/builtins/dict.html b/Lib/_._/builtins/dict.html new file mode 100644 index 000000000..daf426789 --- /dev/null +++ b/Lib/_._/builtins/dict.html @@ -0,0 +1,888 @@ + + + + + + + +src/pylib/builtins/dict + + + + + + + + + + + + + + + + +
+
+

src/pylib/builtins/dict

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Types

+
+
+
PyDictItemView[K; V] = object of PyDictView
+  mapping*: PyDict[K, V]
+
+ + + Source   +Edit   + +
+
+
+
PyDictKeyView[T] = object of PyDictView
+  mapping*: PyDict[T, auto]
+
+ + + Source   +Edit   + +
+
+
+
PyDictValueView[T] = object of PyDictView
+  mapping*: PyDict[auto, T]
+
+ + + Source   +Edit   + +
+
+
+
PyDictView = object of RootObj
+
+ +
Warning: +currently mapping attr is dict itself, i.e. modifiable
+ + Source   +Edit   + +
+
+ +
+
SomeSinglePyDictView[T] = PyDictValueView[T] | PyDictKeyView[T]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
proc `==`[A, B](self, other: PyDict[A, B]): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc `[]`[A, B](t: PyDict[A, B]; key: A): B
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc `[]=`[A, B](t: PyDict[A, B]; key: A; val: sink B)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc clear(self: PyDict)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc contains[A, B](t: PyDict[A, B]; key: A): bool
+
+ + + Source   +Edit   + +
+
+
+
func contains[K, V](t: PyDictItemView[K, V]; x: (K, V)): bool
+
+ + + Source   +Edit   + +
+
+
+
func contains[T](t: PyDictKeyView[T]; x: T): bool
+
+ + + Source   +Edit   + +
+
+
+
func contains[T](t: PyDictValueView[T]; x: T): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func copy[K, V](self: PyDict[K, V]): PyDict[K, V]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc delitem[K, V](self: PyDict[K, V]; k: K)
+
+ + pysugar expect such a proc to hook del d[k] + Source   +Edit   + +
+
+ +
+
+
+
func get[K, V](self: PyDict[K, V]; key: K): V
+
+ + + Source   +Edit   + +
+
+
+
func get[K, V](self: PyDict[K, V]; key: K; default: V): V
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func items[K, V](self: PyDict[K, V]): PyDictItemView[K, V]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func iter[K, V](self: PyDict[K, V]): PyIterator[K]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func keys[K, V](self: PyDict[K, V]): PyDictKeyView[K]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc len(self: PyDict): int
+
+ + dict.__len__ + Source   +Edit   + +
+
+
+
proc len(view: SomePyDictView): int
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func pop[K, V](self: PyDict[K, V]; key: K): V
+
+ + + Source   +Edit   + +
+
+
+
func pop[K, V](self: PyDict[K, V]; key: K; default: V): V
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func popitem[K, V](self: PyDict[K, V]): (K, V)
+
+ +
Warning: +this is currently LILO instead of LIFO
+ + Source   +Edit   + +
+
+ +
+
+
+
func setdefault[K, V](self: PyDict[K, V]; key: K; default = V.default)
+
+ +
Warning: +default defaults to V.default instead of None
+ + Source   +Edit   + +
+
+ +
+
+
+
func toPyDict[K, V](x: not openArray[(K, V)] and Iterable[(K, V)]): PyDict[K, V]
+
+ + + Source   +Edit   + +
+
+
+
func toPyDict[K, V](x: openArray[(K, V)]): PyDict[K, V]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func values[K, V](self: PyDict[K, V]): PyDictValueView[V]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func `|`(a, b: PyDict): PyDict
+
+ + Python-like merge dict operator, a new dict is created from a and b, keys in the second operand override keys in the first operand + Source   +Edit   + +
+
+ +
+
+
+
proc `|=`(a, b: PyDict)
+
+ + Python-like in-place dict update operator. b is added into a, keys in b override same keys from a + Source   +Edit   + +
+
+ +
+ +
+
+
+

Iterators

+
+
+
+
iterator items[K, V](self: PyDict[K, V]): (K, V)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
iterator iter[K, V](self: PyDict[K, V]): K
+
+ +
Warning: +Nim's for stmt calls items implicitly, instead of iter so beware to always write iter for dict in for loop
+ +

Example:

+
let d = dict(a=1)
+for i in iter(d):
+  assert i == "a"
+for i in d:
+  assert i[0] == "a" and i[1] == 1
+ Source   +Edit   + +
+
+ +
+
+
+
iterator keys[K, V](self: PyDict[K, V]): K
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
iterator values[K, V](self: PyDict[K, V]): V
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Macros

+
+
+
+
macro dict(kwargs: varargs[untyped]): PyDict
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
macro update(self: PyDict; kws: varargs[untyped])
+
+ + d.update(**kws) d.update(iterable, **kws) + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template `$`(self: PyDict): string
+
+ + + Source   +Edit   + +
+
+
+
template `$`(self: PyDictItemView): string
+
+ + + Source   +Edit   + +
+
+
+
template `$`(self: PyDictKeyView): string
+
+ + + Source   +Edit   + +
+
+
+
template `$`(self: PyDictValueView): string
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template items(view: SomePyDictView): untyped
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template iter(view: SomePyDictView): untyped
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template repr(self: PyDict): string {.dirty.}
+
+ + + Source   +Edit   + +
+
+
+
template repr(self: PyDictItemView): string {.dirty.}
+
+ + + Source   +Edit   + +
+
+
+
template repr(self: PyDictKeyView): string {.dirty.}
+
+ + + Source   +Edit   + +
+
+
+
template repr(self: PyDictValueView): string {.dirty.}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ + +
+
+ + +
+
+ + + diff --git a/Lib/_._/builtins/dict.idx b/Lib/_._/builtins/dict.idx new file mode 100644 index 000000000..7b9e8bab7 --- /dev/null +++ b/Lib/_._/builtins/dict.idx @@ -0,0 +1,56 @@ +nimTitle dict _._/builtins/dict.html module src/pylib/builtins/dict 0 +nim PyDictView _._/builtins/dict.html#PyDictView object PyDictView 14 +nim PyDictKeyView _._/builtins/dict.html#PyDictKeyView object PyDictKeyView 16 +nim PyDictValueView _._/builtins/dict.html#PyDictValueView object PyDictValueView 18 +nim PyDictItemView _._/builtins/dict.html#PyDictItemView object PyDictItemView 20 +nim SomeSinglePyDictView _._/builtins/dict.html#SomeSinglePyDictView type SomeSinglePyDictView 22 +nim SomePyDictView _._/builtins/dict.html#SomePyDictView type SomePyDictView 23 +nim contains _._/builtins/dict.html#contains,PyDict[A,B],A proc contains[A, B](t: PyDict[A, B]; key: A): bool 26 +nim `[]` _._/builtins/dict.html#[],PyDict[A,B],A proc `[]`[A, B](t: PyDict[A, B]; key: A): B 27 +nim `[]=` _._/builtins/dict.html#[]=,PyDict[A,B],A,sinkB proc `[]=`[A, B](t: PyDict[A, B]; key: A; val: sink B) 28 +nim repr _._/builtins/dict.html#repr.t,PyDict template repr(self: PyDict): string 42 +nim `$` _._/builtins/dict.html#$.t,PyDict template `$`(self: PyDict): string 36 +nim len _._/builtins/dict.html#len proc len(self: PyDict): int 38 +nim `==` _._/builtins/dict.html#==,PyDict[A,B],PyDict[A,B] proc `==`[A, B](self, other: PyDict[A, B]): bool 42 +nim clear _._/builtins/dict.html#clear proc clear(self: PyDict) 44 +nim len _._/builtins/dict.html#len,SomePyDictView proc len(view: SomePyDictView): int 46 +nim iter _._/builtins/dict.html#iter.t,SomePyDictView template iter(view: SomePyDictView): untyped 47 +nim items _._/builtins/dict.html#items.t,SomePyDictView template items(view: SomePyDictView): untyped 48 +nim contains _._/builtins/dict.html#contains,PyDictKeyView[T],T proc contains[T](t: PyDictKeyView[T]; x: T): bool 49 +nim contains _._/builtins/dict.html#contains,PyDictValueView[T],T proc contains[T](t: PyDictValueView[T]; x: T): bool 50 +nim contains _._/builtins/dict.html#contains,PyDictItemView[K,V], proc contains[K, V](t: PyDictItemView[K, V]; x: (K, V)): bool 53 +nim repr _._/builtins/dict.html#repr.t,PyDictKeyView template repr(self: PyDictKeyView): string 42 +nim `$` _._/builtins/dict.html#$.t,PyDictKeyView template `$`(self: PyDictKeyView): string 57 +nim repr _._/builtins/dict.html#repr.t,PyDictValueView template repr(self: PyDictValueView): string 42 +nim `$` _._/builtins/dict.html#$.t,PyDictValueView template `$`(self: PyDictValueView): string 58 +nim repr _._/builtins/dict.html#repr.t,PyDictItemView template repr(self: PyDictItemView): string 42 +nim `$` _._/builtins/dict.html#$.t,PyDictItemView template `$`(self: PyDictItemView): string 59 +nim keys _._/builtins/dict.html#keys.i,PyDict[K,V] iterator keys[K, V](self: PyDict[K, V]): K 62 +nim iter _._/builtins/dict.html#iter.i,PyDict[K,V] iterator iter[K, V](self: PyDict[K, V]): K 65 +nim iter _._/builtins/dict.html#iter,PyDict[K,V] proc iter[K, V](self: PyDict[K, V]): PyIterator[K] 77 +nim values _._/builtins/dict.html#values.i,PyDict[K,V] iterator values[K, V](self: PyDict[K, V]): V 81 +nim items _._/builtins/dict.html#items.i,PyDict[K,V] iterator items[K, V](self: PyDict[K, V]): (K, V) 84 +nim keys _._/builtins/dict.html#keys,PyDict[K,V] proc keys[K, V](self: PyDict[K, V]): PyDictKeyView[K] 87 +nim values _._/builtins/dict.html#values,PyDict[K,V] proc values[K, V](self: PyDict[K, V]): PyDictValueView[V] 88 +nim items _._/builtins/dict.html#items,PyDict[K,V] proc items[K, V](self: PyDict[K, V]): PyDictItemView[K, V] 89 +nim toPyDict _._/builtins/dict.html#toPyDict,openArray[] proc toPyDict[K, V](x: openArray[(K, V)]): PyDict[K, V] 91 +nim toPyDict _._/builtins/dict.html#toPyDict proc toPyDict[K, V](x: not openArray[(K, V)] and Iterable[(K, V)]): PyDict[K, V] 95 +nim copy _._/builtins/dict.html#copy,PyDict[K,V] proc copy[K, V](self: PyDict[K, V]): PyDict[K, V] 101 +nim setdefault _._/builtins/dict.html#setdefault,PyDict[K,V],K proc setdefault[K, V](self: PyDict[K, V]; key: K; default = V.default) 108 +nim get _._/builtins/dict.html#get,PyDict[K,V],K proc get[K, V](self: PyDict[K, V]; key: K): V 115 +nim get _._/builtins/dict.html#get,PyDict[K,V],K,V proc get[K, V](self: PyDict[K, V]; key: K; default: V): V 116 +nim pop _._/builtins/dict.html#pop,PyDict[K,V],K proc pop[K, V](self: PyDict[K, V]; key: K): V 117 +nim pop _._/builtins/dict.html#pop,PyDict[K,V],K,V proc pop[K, V](self: PyDict[K, V]; key: K; default: V): V 120 +nim popitem _._/builtins/dict.html#popitem,PyDict[K,V] proc popitem[K, V](self: PyDict[K, V]): (K, V) 124 +nim delitem _._/builtins/dict.html#delitem,PyDict[K,V],K proc delitem[K, V](self: PyDict[K, V]; k: K) 131 +nim dict _._/builtins/dict.html#dict.m,varargs[untyped] macro dict(kwargs: varargs[untyped]): PyDict 162 +nim update _._/builtins/dict.html#update.m,PyDict,varargs[untyped] macro update(self: PyDict; kws: varargs[untyped]) 184 +nim `|` _._/builtins/dict.html#|,PyDict,PyDict proc `|`(a, b: PyDict): PyDict 206 +nim `|=` _._/builtins/dict.html#|=,PyDict,PyDict proc `|=`(a, b: PyDict) 214 +nimgrp contains _._/builtins/dict.html#contains-procs-all proc 26 +nimgrp topydict _._/builtins/dict.html#toPyDict-procs-all proc 91 +nimgrp get _._/builtins/dict.html#get-procs-all proc 115 +nimgrp len _._/builtins/dict.html#len-procs-all proc 38 +nimgrp pop _._/builtins/dict.html#pop-procs-all proc 117 +nimgrp $ _._/builtins/dict.html#$-templates-all template 46 +nimgrp repr _._/builtins/dict.html#repr-templates-all template 42 diff --git a/Lib/_._/builtins/dict_decl.html b/Lib/_._/builtins/dict_decl.html new file mode 100644 index 000000000..bb6c0efc6 --- /dev/null +++ b/Lib/_._/builtins/dict_decl.html @@ -0,0 +1,260 @@ + + + + + + + +src/pylib/builtins/dict_decl + + + + + + + + + + + + + + + + +
+
+

src/pylib/builtins/dict_decl

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+
+ Deprecated: use newPyDict, to be removed since 0.10 +
+ +

+
+

Types

+
+
+
dict[K; V] = ref object
+
+ + + Source   +Edit   + +
+
+
+
PyDict[K; V] = dict[K, V]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
func emptyPyDict[K, V](): PyDict[K, V]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc getOrDefault[A, B](t: PyDict[A, B]; key: A): B
+
+ + inner. used to impl get(key, default) + Source   +Edit   + +
+
+ +
+
+
+
func newPyDict[K, V](x: int): PyDict[K, V] {.inline.}
+
+ + + Source   +Edit   + +
+
+
+
func newPyDict[K, V](x: openArray[(K, V)] = []): PyDict[K, V]
+
+ + zero or one arg shall support [], {k:v, ...}, @[(k, v),...] + Source   +Edit   + +
+
+ +
+
+
+
func toNimTable[K, V](self: PyDict[K, V]): var OrderedTable[K, V]
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template newPyDictImpl[K, V](x: int): untyped {.
+    ...deprecated: "use newPyDict, to be removed since 0.10".}
+
+
+ Deprecated: use newPyDict, to be removed since 0.10 +
+ + + Source   +Edit   + +
+
+
+
template newPyDictImpl[K, V](x: openArray[(K, V)] = []): untyped {.
+    ...deprecated: "use newPyDict, to be removed since 0.10".}
+
+
+ Deprecated: use newPyDict, to be removed since 0.10 +
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/builtins/dict_decl.idx b/Lib/_._/builtins/dict_decl.idx new file mode 100644 index 000000000..94bfafe31 --- /dev/null +++ b/Lib/_._/builtins/dict_decl.idx @@ -0,0 +1,12 @@ +nimTitle dict_decl _._/builtins/dict_decl.html module src/pylib/builtins/dict_decl 0 +nim dict _._/builtins/dict_decl.html#dict type dict 5 +nim PyDict _._/builtins/dict_decl.html#PyDict type PyDict 7 +nim toNimTable _._/builtins/dict_decl.html#toNimTable,PyDict[K,V] proc toNimTable[K, V](self: PyDict[K, V]): var OrderedTable[K, V] 9 +nim newPyDict _._/builtins/dict_decl.html#newPyDict,int proc newPyDict[K, V](x: int): PyDict[K, V] 11 +nim newPyDict _._/builtins/dict_decl.html#newPyDict,openArray[] proc newPyDict[K, V](x: openArray[(K, V)] = []): PyDict[K, V] 15 +nim newPyDictImpl _._/builtins/dict_decl.html#newPyDictImpl.t,int template newPyDictImpl[K, V](x: int): untyped 22 +nim newPyDictImpl _._/builtins/dict_decl.html#newPyDictImpl.t,openArray[] template newPyDictImpl[K, V](x: openArray[(K, V)] = []): untyped 26 +nim getOrDefault _._/builtins/dict_decl.html#getOrDefault,PyDict[A,B],A proc getOrDefault[A, B](t: PyDict[A, B]; key: A): B 31 +nim emptyPyDict _._/builtins/dict_decl.html#emptyPyDict proc emptyPyDict[K, V](): PyDict[K, V] 34 +nimgrp newpydict _._/builtins/dict_decl.html#newPyDict-procs-all proc 11 +nimgrp newpydictimpl _._/builtins/dict_decl.html#newPyDictImpl-templates-all template 22 diff --git a/Lib/_._/builtins/iter_next.html b/Lib/_._/builtins/iter_next.html new file mode 100644 index 000000000..512ed9552 --- /dev/null +++ b/Lib/_._/builtins/iter_next.html @@ -0,0 +1,247 @@ + + + + + + + +src/pylib/builtins/iter_next + + + + + + + + + + + + + + + + +
+
+

src/pylib/builtins/iter_next

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

builtins.iter

+ +
+

Types

+
+
+
PyIterator[T] = ref object
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
func iter[T](x: Iterable[T]): PyIterator[T]
+
+ + + Source   +Edit   + +
+
+
+
func iter[T](x: Iterator[T]): PyIterator[T]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func newPyIterator[T](it: iterator (): T): PyIterator[T]
+
+ + init with a Nim iterator + Source   +Edit   + +
+
+ +
+
+
+
proc next[T](self: PyIterator[T]): T
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc nextImpl[T](self: PyIterator[T]): Option[T] {.inline.}
+
+ + EXT. Get rid of exception for faster iteration. + Source   +Edit   + +
+
+
+
proc nextImpl[T](self: PyIterator[T]; res: var T): bool {.inline.}
+
+ + EXT. Get rid of exception for faster iteration. + Source   +Edit   + +
+
+ +
+ +
+
+
+

Iterators

+
+
+
+
iterator items[T](self: PyIterator[T]): T
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/builtins/iter_next.idx b/Lib/_._/builtins/iter_next.idx new file mode 100644 index 000000000..665216358 --- /dev/null +++ b/Lib/_._/builtins/iter_next.idx @@ -0,0 +1,11 @@ +nimTitle iter_next _._/builtins/iter_next.html module src/pylib/builtins/iter_next 0 +nim PyIterator _._/builtins/iter_next.html#PyIterator type PyIterator 10 +nim newPyIterator _._/builtins/iter_next.html#newPyIterator proc newPyIterator[T](it: iterator (): T): PyIterator[T] 13 +nim iter _._/builtins/iter_next.html#iter,Iterable[T] proc iter[T](x: Iterable[T]): PyIterator[T] 17 +nim iter _._/builtins/iter_next.html#iter,Iterator[T] proc iter[T](x: Iterator[T]): PyIterator[T] 26 +nim items _._/builtins/iter_next.html#items.i,PyIterator[T] iterator items[T](self: PyIterator[T]): T 35 +nim nextImpl _._/builtins/iter_next.html#nextImpl,PyIterator[T] proc nextImpl[T](self: PyIterator[T]): Option[T] 39 +nim nextImpl _._/builtins/iter_next.html#nextImpl,PyIterator[T],T proc nextImpl[T](self: PyIterator[T]; res: var T): bool 44 +nim next _._/builtins/iter_next.html#next,PyIterator[T] proc next[T](self: PyIterator[T]): T 49 +nimgrp iter _._/builtins/iter_next.html#iter-procs-all proc 17 +nimgrp nextimpl _._/builtins/iter_next.html#nextImpl-procs-all proc 39 diff --git a/Lib/_._/builtins/iters.html b/Lib/_._/builtins/iters.html new file mode 100644 index 000000000..0a0ba06c2 --- /dev/null +++ b/Lib/_._/builtins/iters.html @@ -0,0 +1,439 @@ + + + + + + + +src/pylib/builtins/iters + + + + + + + + + + + + + + + + +
+
+

src/pylib/builtins/iters

+
+ +
+ Source   +Edit   + +
+ +

Some iterable in builtins

+

XXX: For JS backend: Currently due to Nim's inner buys, using of some iterable functions in this modules may result in Error: ...:

+
  • list(...)
  • +
  • filter/map/... as func (using iterator is okey) (solved after Nim-2.1.1)
  • +
+

For details, trace:

+ +

+ +
+

Procs

+
+
+
+
func enumerate[T](x: Iterable[T]; start = 0): Enumerate[T]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func filter[T](comp: NoneType; iter: Iterable[T]): Filter[T]
+
+ + + Source   +Edit   + +
+
+
+
func filter[T](comp: proc (arg: T): bool; iter: Iterable[T]): Filter[T]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func map[T, R](function: proc (x: T): R; iterable: Iterable[T]): Map[T]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func reversed[T](x: Sequence[T]): Reversed[T]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func zip[A, B](it1: Iterable[A]; it2: Iterable[B]; strict = false): Zip[A]
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Iterators

+
+
+
+
iterator enumerate[T](x: Iterable[T]; start = 0): (int, T)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
iterator filter[T](comp: NoneType; iter: Iterable[T]): T
+
+ + + Source   +Edit   + +
+
+
+
iterator filter[T](comp: proc (arg: T): bool; iter: Iterable[T]): T
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
iterator items[T](x: Enumerate[T]): T
+
+ + + Source   +Edit   + +
+
+
+
iterator items[T](x: Filter[T]): T
+
+ + + Source   +Edit   + +
+
+
+
iterator items[T](x: Map[T]): T
+
+ + + Source   +Edit   + +
+
+
+
iterator items[T](x: Reversed[T]): T
+
+ + + Source   +Edit   + +
+
+
+
iterator items[T](x: Zip[T]): T
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
iterator map[T, R](function: proc (x: T): R; iterable: Iterable[T]): R
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
iterator reversed[T](x: Sequence[T]): T
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
iterator zip[A, B](it1: Iterable[A]; it2: Iterable[B]; strict = false): (A, B)
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Macros

+
+
+
+
macro map(function: proc; iterable: typed; iterables: varargs[typed]): Map
+
+ +
Note: +unlike Python, if arguments number does not fit function, instead of runtime error compile-time error occurs, in which a generated temporary name gen_iter_res will be seen
+ + Source   +Edit   + +
+
+ +
+
+
+
macro zip(iterables_or_strict: varargs[untyped]): Zip
+
+ + zip(*args, strict=False)
+

To support its similarity with Python's zip function signature, this macro signature has to be varargs[untyped].

+

So it's designed to be undefined when pylibDisableMoreArgsZip is defined.

+ + Source   +Edit   + +
+
+ +
+ +
+
+
+

Exports

+
+ None, iter, iter, iter, next, next +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/builtins/iters.idx b/Lib/_._/builtins/iters.idx new file mode 100644 index 000000000..0418a8239 --- /dev/null +++ b/Lib/_._/builtins/iters.idx @@ -0,0 +1,23 @@ +nimTitle iters _._/builtins/iters.html module src/pylib/builtins/iters 0 +nim items _._/builtins/iters.html#items.i,Filter[T] iterator items[T](x: Filter[T]): T 38 +nim filter _._/builtins/iters.html#filter,proc(T),Iterable[T] proc filter[T](comp: proc (arg: T): bool; iter: Iterable[T]): Filter[T] 27 +nim filter _._/builtins/iters.html#filter.i,proc(T),Iterable[T] iterator filter[T](comp: proc (arg: T): bool; iter: Iterable[T]): T 27 +nim filter _._/builtins/iters.html#filter,NoneType,Iterable[T] proc filter[T](comp: NoneType; iter: Iterable[T]): Filter[T] 32 +nim filter _._/builtins/iters.html#filter.i,NoneType,Iterable[T] iterator filter[T](comp: NoneType; iter: Iterable[T]): T 32 +nim items _._/builtins/iters.html#items.i,Enumerate[T] iterator items[T](x: Enumerate[T]): T 38 +nim enumerate _._/builtins/iters.html#enumerate,Iterable[T],int proc enumerate[T](x: Iterable[T]; start = 0): Enumerate[T] 37 +nim enumerate _._/builtins/iters.html#enumerate.i,Iterable[T],int iterator enumerate[T](x: Iterable[T]; start = 0): (int, T) 37 +nim items _._/builtins/iters.html#items.i,Reversed[T] iterator items[T](x: Reversed[T]): T 38 +nim reversed _._/builtins/iters.html#reversed,Sequence[T] proc reversed[T](x: Sequence[T]): Reversed[T] 43 +nim reversed _._/builtins/iters.html#reversed.i,Sequence[T] iterator reversed[T](x: Sequence[T]): T 43 +nim items _._/builtins/iters.html#items.i,Map[T] iterator items[T](x: Map[T]): T 51 +nim map _._/builtins/iters.html#map,proc(T),Iterable[T] proc map[T, R](function: proc (x: T): R; iterable: Iterable[T]): Map[T] 53 +nim map _._/builtins/iters.html#map.i,proc(T),Iterable[T] iterator map[T, R](function: proc (x: T): R; iterable: Iterable[T]): R 54 +nim map _._/builtins/iters.html#map.m,proc,typed,varargs[typed] macro map(function: proc; iterable: typed; iterables: varargs[typed]): Map 64 +nim items _._/builtins/iters.html#items.i,Zip[T] iterator items[T](x: Zip[T]): T 74 +nim zip _._/builtins/iters.html#zip,Iterable[A],Iterable[B] proc zip[A, B](it1: Iterable[A]; it2: Iterable[B]; strict = false): Zip[A] 116 +nim zip _._/builtins/iters.html#zip.i,Iterable[A],Iterable[B] iterator zip[A, B](it1: Iterable[A]; it2: Iterable[B]; strict = false): (A, B) 116 +nim zip _._/builtins/iters.html#zip.m,varargs[untyped] macro zip(iterables_or_strict: varargs[untyped]): Zip 153 +nimgrp filter _._/builtins/iters.html#filter-procs-all proc 27 +nimgrp items _._/builtins/iters.html#items-iterators-all iterator 14 +nimgrp filter _._/builtins/iters.html#filter-iterators-all iterator 27 diff --git a/Lib/_._/builtins/iters/macroutils.html b/Lib/_._/builtins/iters/macroutils.html new file mode 100644 index 000000000..f483aba39 --- /dev/null +++ b/Lib/_._/builtins/iters/macroutils.html @@ -0,0 +1,340 @@ + + + + + + + +src/pylib/builtins/iters/macroutils + + + + + + + + + + + + + + + + +
+
+

src/pylib/builtins/iters/macroutils

+
+ +
+ Source   +Edit   + +
+ +

+ +
+

Types

+
+
+
PreBreakCb = proc (i: NimNode): NimNode {.closure.}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Lets

+
+
+
emptyn {.compileTime.} = newEmptyNode()
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Consts

+
+
+
preferredGenIterResName {.strdefine.} = "gen_iter_res"
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
proc addEachIter(loopBody: NimNode; nIt: int; itors, res: NimNode;
+                 preBreakCb: PreBreakCb = noopPreBreakCb) {....raises: [Exception],
+    tags: [RootEffect], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc addLoopEach(loopBody: NimNode; parent: NimNode;
+                 iterables: NimNode | seq[NimNode];
+                 res = ident preferredGenIterResName;
+                 preBreakCb: PreBreakCb = noopPreBreakCb): NimNode {.discardable.}
+
+ + returns res type (a tuple) + Source   +Edit   + +
+
+ +
+
+
+
proc addResDecl(body: NimNode; iterables: NimNode | seq[NimNode];
+                res = ident preferredGenIterResName;
+                iters = genSym(nskLet, "iters")): NimNode {.discardable.}
+
+ + returns res type (a tuple) + Source   +Edit   + +
+
+ +
+
+
+
proc addYield(res, dest: NimNode) {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func newLoop(body: NimNode): NimNode {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc newNullaryLambdaIter(body: NimNode; resType = ident"auto"): NimNode {.
+    ...raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func newTuple(): NimNode {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func noInitVarDecl(name, Type: NimNode): NimNode {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Exports

+
+ iter, iter +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/builtins/iters/macroutils.idx b/Lib/_._/builtins/iters/macroutils.idx new file mode 100644 index 000000000..05da0278c --- /dev/null +++ b/Lib/_._/builtins/iters/macroutils.idx @@ -0,0 +1,12 @@ +nimTitle macroutils _._/builtins/iters/macroutils.html module src/pylib/builtins/iters/macroutils 0 +nim newTuple _._/builtins/iters/macroutils.html#newTuple proc newTuple(): NimNode 6 +nim emptyn _._/builtins/iters/macroutils.html#emptyn let emptyn 7 +nim noInitVarDecl _._/builtins/iters/macroutils.html#noInitVarDecl,NimNode,NimNode proc noInitVarDecl(name, Type: NimNode): NimNode 10 +nim preferredGenIterResName _._/builtins/iters/macroutils.html#preferredGenIterResName const preferredGenIterResName 14 +nim addResDecl _._/builtins/iters/macroutils.html#addResDecl,NimNode, proc addResDecl(body: NimNode; iterables: NimNode | seq[NimNode];\n res = ident preferredGenIterResName; iters = genSym(nskLet, "iters")): NimNode 16 +nim newLoop _._/builtins/iters/macroutils.html#newLoop,NimNode proc newLoop(body: NimNode): NimNode 33 +nim newNullaryLambdaIter _._/builtins/iters/macroutils.html#newNullaryLambdaIter,NimNode proc newNullaryLambdaIter(body: NimNode; resType = ident"auto"): NimNode 36 +nim PreBreakCb _._/builtins/iters/macroutils.html#PreBreakCb type PreBreakCb 39 +nim addEachIter _._/builtins/iters/macroutils.html#addEachIter,NimNode,int,NimNode,NimNode,PreBreakCb proc addEachIter(loopBody: NimNode; nIt: int; itors, res: NimNode;\n preBreakCb: PreBreakCb = noopPreBreakCb) 43 +nim addYield _._/builtins/iters/macroutils.html#addYield,NimNode,NimNode proc addYield(res, dest: NimNode) 55 +nim addLoopEach _._/builtins/iters/macroutils.html#addLoopEach,NimNode,NimNode,,PreBreakCb proc addLoopEach(loopBody: NimNode; parent: NimNode;\n iterables: NimNode | seq[NimNode];\n res = ident preferredGenIterResName;\n preBreakCb: PreBreakCb = noopPreBreakCb): NimNode 59 diff --git a/Lib/_._/builtins/iters/mapMacro.html b/Lib/_._/builtins/iters/mapMacro.html new file mode 100644 index 000000000..504809037 --- /dev/null +++ b/Lib/_._/builtins/iters/mapMacro.html @@ -0,0 +1,119 @@ + + + + + + + +src/pylib/builtins/iters/mapMacro + + + + + + + + + + + + + + + + +
+
+

src/pylib/builtins/iters/mapMacro

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Imports

+
+ macroutils +
+
+
+

Procs

+
+
+
+
proc mapIterBodyImpl(f: NimNode; iterables: NimNode; res = genSym(nskVar, "res")): NimNode {.
+    ...raises: [Exception], tags: [RootEffect], forbids: [].}
+
+ + res: generated symbol name temporarily storing iteration result and will be used as if f(*res) in Python at each loop; do not use genSym if wanting simpler err msg for arg num mismatch + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/builtins/iters/mapMacro.idx b/Lib/_._/builtins/iters/mapMacro.idx new file mode 100644 index 000000000..b137676fa --- /dev/null +++ b/Lib/_._/builtins/iters/mapMacro.idx @@ -0,0 +1,2 @@ +nimTitle mapMacro _._/builtins/iters/mapMacro.html module src/pylib/builtins/iters/mapMacro 0 +nim mapIterBodyImpl _._/builtins/iters/mapMacro.html#mapIterBodyImpl,NimNode,NimNode proc mapIterBodyImpl(f: NimNode; iterables: NimNode; res = genSym(nskVar, "res")): NimNode 6 diff --git a/Lib/_._/builtins/iters/zipMacro.html b/Lib/_._/builtins/iters/zipMacro.html new file mode 100644 index 000000000..2e814812f --- /dev/null +++ b/Lib/_._/builtins/iters/zipMacro.html @@ -0,0 +1,136 @@ + + + + + + + +src/pylib/builtins/iters/zipMacro + + + + + + + + + + + + + + + + +
+
+

src/pylib/builtins/iters/zipMacro

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Imports

+
+ macroutils +
+
+
+

Procs

+
+
+
+
func raiseZipBound(ordLonger: int) {.inline, ...raises: [ValueError], tags: [],
+                                     forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc zipIterBodyImpl(iterables: NimNode | seq[NimNode]; strict: NimNode): NimNode
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/builtins/iters/zipMacro.idx b/Lib/_._/builtins/iters/zipMacro.idx new file mode 100644 index 000000000..415bc532f --- /dev/null +++ b/Lib/_._/builtins/iters/zipMacro.idx @@ -0,0 +1,3 @@ +nimTitle zipMacro _._/builtins/iters/zipMacro.html module src/pylib/builtins/iters/zipMacro 0 +nim raiseZipBound _._/builtins/iters/zipMacro.html#raiseZipBound,int proc raiseZipBound(ordLonger: int) 5 +nim zipIterBodyImpl _._/builtins/iters/zipMacro.html#zipIterBodyImpl,,NimNode proc zipIterBodyImpl(iterables: NimNode | seq[NimNode]; strict: NimNode): NimNode 10 diff --git a/Lib/_._/builtins/list.html b/Lib/_._/builtins/list.html new file mode 100644 index 000000000..8472e0eff --- /dev/null +++ b/Lib/_._/builtins/list.html @@ -0,0 +1,758 @@ + + + + + + + +src/pylib/builtins/list + + + + + + + + + + + + + + + + +
+
+

src/pylib/builtins/list

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

Python's list with its methods and sorted buitin

+

LIMIT: slice literal is not supported. ls[1:3] has to be rewritten as ls[1..2]

+

+ +
+

Procs

+
+
+
+
func `*`[T](n: Natural; ls: PyList[T]): PyList[T]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func `*=`[T](self: var PyList[T]; n: int)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func `+`[T](self: PyList[T]; x: openArray[T]): PyList[T]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func `+=`[T](self: var PyList[T]; ls: openArray[T])
+
+ + + Source   +Edit   + +
+
+
+
func `+=`[T](self: var PyList[T]; ls: PyList[T])
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func `[]`[T](self: PyList[T]; idx: int): T
+
+ + + Source   +Edit   + +
+
+
+
func `[]`[T](self: PyList[T]; s: BackwardsIndex): T
+
+ + + Source   +Edit   + +
+
+
+
func `[]`[T](self: PyList[T]; s: HSlice): PyList[T]
+
+ + + Source   +Edit   + +
+
+
+
func `[]`[T](self: PyList[T]; s: PySlice): PyList[T]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func `[]=`[T](ms: var PyList[T]; indices: Slice[int]; o: Sequence[T])
+
+ + + Source   +Edit   + +
+
+
+
func `[]=`[T](self: var PyList[T]; idx: int; x: T)
+
+ + + Source   +Edit   + +
+
+
+
func `[]=`[T](self: var PyList[T]; s: BackwardsIndex; x: T)
+
+ + + Source   +Edit   + +
+
+
+
func `[]=`[T](self: var PyList[T]; s: HSlice; x: Iterable[T])
+
+ + + Source   +Edit   + +
+
+
+
func `[]=`[T](self: var PyList[T]; s: HSlice; x: openArray[T])
+
+ + + Source   +Edit   + +
+
+
+
func `[]=`[T](self: var PyList[T]; s: HSlice; x: PyList[T])
+
+ + + Source   +Edit   + +
+
+
+
func `[]=`[T](self: var PyList[T]; s: PySlice;
+              x: not Sequence[T] and Iterable[T])
+
+ + + Source   +Edit   + +
+
+
+
func `[]=`[T](self: var PyList[T]; s: PySlice; x: Sequence[T])
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func append[T](self: var PyList[T]; x: T)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func clear(self: var PyList)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func delitem(ms: var PyList; indices: PySlice)
+
+ + + Source   +Edit   + +
+
+
+
func delitem(ms: var PyList; indices: Slice[int])
+
+ + + Source   +Edit   + +
+
+
+
func delitem(self: var PyList; idx: int)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func extend[T](self: var PyList[T]; ls: openArray[T])
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func insert[T](self: var PyList[T]; idx: int; x: T)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func list[T](): PyList[T]
+
+ + +

Example:

+
assert len(list[int]()) == 0
+ Source   +Edit   + +
+
+
+
func list[T](a: sink openArray[T]): PyList[T]
+
+ + + Source   +Edit   + +
+
+
+
proc list[T](iter: Iterable[T]): PyList[T]
+
+ + + Source   +Edit   + +
+
+
+
func list[T](x: sink seq[T]): PyList[T]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func pop[T](self: var PyList[T]): T {.discardable.}
+
+ + + Source   +Edit   + +
+
+
+
func pop[T](self: var PyList[T]; index: int): T {.discardable.}
+
+ + index can be negative to index backwards. + Source   +Edit   + +
+
+ +
+
+
+
func reverse(self: var PyList)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc sort[T, K](self: var PyList[T]; key: proc (x: T): K; reverse = false)
+
+ + list.sort(key, reverse=False) + Source   +Edit   + +
+
+
+
func sort[T](self: var PyList[T]; reverse = false)
+
+ + list.sort(reverse=False) + Source   +Edit   + +
+
+ +
+
+
+
proc sorted[T, K](x: not Sequence[T] and Iterable[T]; key: proc (x: T): K;
+                  reverse = false): PyList[T]
+
+ + + Source   +Edit   + +
+
+
+
proc sorted[T, K](x: Sequence[T]; key: proc (x: T): K; reverse = false): PyList[
+    T]
+
+ + + Source   +Edit   + +
+
+
+
func sorted[T](self: PyList[T]; reverse = false): PyList[T]
+
+ + sorted(list, reverse=False) + Source   +Edit   + +
+
+ +
+ +
+
+
+

Converters

+
+
+
+
converter nimArrayAsList[T; I](arr: array[I, T]): PyList[T]
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template `$`(self: PyList): string
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template `*`[T](ls: PyList[T]; n: Natural): PyList[T]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template `+`[T](self: var PyList[T]; x: PyList[T]): PyList[T]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template extend[T](self: var PyList[T]; ls: Iterable[T])
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template len(self: PyList): int
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template repr(self: PyList): string {.dirty.}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ + +
+
+ + +
+
+ + + diff --git a/Lib/_._/builtins/list.idx b/Lib/_._/builtins/list.idx new file mode 100644 index 000000000..a3dab455e --- /dev/null +++ b/Lib/_._/builtins/list.idx @@ -0,0 +1,52 @@ +nimTitle list _._/builtins/list.html module src/pylib/builtins/list 0 +nim nimArrayAsList _._/builtins/list.html#nimArrayAsList.c,array[I,T] converter nimArrayAsList[T; I](arr: array[I, T]): PyList[T] 23 +nim len _._/builtins/list.html#len.t,PyList template len(self: PyList): int 26 +nim `[]=` _._/builtins/list.html#[]=,PyList[T],int,T proc `[]=`[T](self: var PyList[T]; idx: int; x: T) 31 +nim `[]` _._/builtins/list.html#[],PyList[T],int proc `[]`[T](self: PyList[T]; idx: int): T 33 +nim `[]=` _._/builtins/list.html#[]=,PyList[T],HSlice,openArray[T] proc `[]=`[T](self: var PyList[T]; s: HSlice; x: openArray[T]) 36 +nim `[]=` _._/builtins/list.html#[]=,PyList[T],HSlice,PyList[T] proc `[]=`[T](self: var PyList[T]; s: HSlice; x: PyList[T]) 38 +nim `[]=` _._/builtins/list.html#[]=,PyList[T],BackwardsIndex,T proc `[]=`[T](self: var PyList[T]; s: BackwardsIndex; x: T) 41 +nim list _._/builtins/list.html#list,Iterable[T] proc list[T](iter: Iterable[T]): PyList[T] 44 +nim `[]=` _._/builtins/list.html#[]=,PyList[T],HSlice,Iterable[T] proc `[]=`[T](self: var PyList[T]; s: HSlice; x: Iterable[T]) 45 +nim `[]=` _._/builtins/list.html#[]=,PyList[T],PySlice,Sequence[T] proc `[]=`[T](self: var PyList[T]; s: PySlice; x: Sequence[T]) 54 +nim `[]=` _._/builtins/list.html#[]=,PyList[T],PySlice, proc `[]=`[T](self: var PyList[T]; s: PySlice; x: not Sequence[T] and Iterable[T]) 68 +nim append _._/builtins/list.html#append,PyList[T],T proc append[T](self: var PyList[T]; x: T) 74 +nim `+=` _._/builtins/list.html#+=,PyList[T],openArray[T] proc `+=`[T](self: var PyList[T]; ls: openArray[T]) 75 +nim `+=` _._/builtins/list.html#+=,PyList[T],PyList[T] proc `+=`[T](self: var PyList[T]; ls: PyList[T]) 76 +nim `[]` _._/builtins/list.html#[],PyList[T],HSlice proc `[]`[T](self: PyList[T]; s: HSlice): PyList[T] 78 +nim `[]` _._/builtins/list.html#[],PyList[T],BackwardsIndex proc `[]`[T](self: PyList[T]; s: BackwardsIndex): T 80 +nim `[]` _._/builtins/list.html#[],PyList[T],PySlice proc `[]`[T](self: PyList[T]; s: PySlice): PyList[T] 83 +nim reverse _._/builtins/list.html#reverse,PyList proc reverse(self: var PyList) 93 +nim pop _._/builtins/list.html#pop,PyList[T] proc pop[T](self: var PyList[T]): T 95 +nim pop _._/builtins/list.html#pop,PyList[T],int proc pop[T](self: var PyList[T]; index: int): T 96 +nim extend _._/builtins/list.html#extend,PyList[T],openArray[T] proc extend[T](self: var PyList[T]; ls: openArray[T]) 102 +nim extend _._/builtins/list.html#extend.t,PyList[T],Iterable[T] template extend[T](self: var PyList[T]; ls: Iterable[T]) 105 +nim insert _._/builtins/list.html#insert,PyList[T],int,T proc insert[T](self: var PyList[T]; idx: int; x: T) 109 +nim delitem _._/builtins/list.html#delitem,PyList,int proc delitem(self: var PyList; idx: int) 115 +nim clear _._/builtins/list.html#clear,PyList proc clear(self: var PyList) 118 +nim sort _._/builtins/list.html#sort,PyList[T] proc sort[T](self: var PyList[T]; reverse = false) 125 +nim sorted _._/builtins/list.html#sorted,PyList[T] proc sorted[T](self: PyList[T]; reverse = false): PyList[T] 129 +nim `+` _._/builtins/list.html#+,PyList[T],openArray[T] proc `+`[T](self: PyList[T]; x: openArray[T]): PyList[T] 133 +nim list _._/builtins/list.html#list,sinkseq[T] proc list[T](x: sink seq[T]): PyList[T] 136 +nim list _._/builtins/list.html#list,sinkopenArray[T] proc list[T](a: sink openArray[T]): PyList[T] 137 +nim list _._/builtins/list.html#list_2 proc list[T](): PyList[T] 142 +nim `*` _._/builtins/list.html#*,Natural,PyList[T] proc `*`[T](n: Natural; ls: PyList[T]): PyList[T] 147 +nim `*` _._/builtins/list.html#*.t,PyList[T],Natural template `*`[T](ls: PyList[T]; n: Natural): PyList[T] 151 +nim `*=` _._/builtins/list.html#*=,PyList[T],int proc `*=`[T](self: var PyList[T]; n: int) 154 +nim `+` _._/builtins/list.html#+.t,PyList[T],PyList[T] template `+`[T](self: var PyList[T]; x: PyList[T]): PyList[T] 158 +nim repr _._/builtins/list.html#repr.t,PyList template repr(self: PyList): string 42 +nim `$` _._/builtins/list.html#$.t,PyList template `$`(self: PyList): string 172 +nim sort _._/builtins/list.html#sort,PyList[T],proc(T) proc sort[T, K](self: var PyList[T]; key: proc (x: T): K; reverse = false) 234 +nim sorted _._/builtins/list.html#sorted,Sequence[T],proc(T) proc sorted[T, K](x: Sequence[T]; key: proc (x: T): K; reverse = false): PyList[T] 239 +nim sorted _._/builtins/list.html#sorted,,proc(T) proc sorted[T, K](x: not Sequence[T] and Iterable[T]; key: proc (x: T): K;\n reverse = false): PyList[T] 244 +nim delitem _._/builtins/list.html#delitem,PyList,Slice[int] proc delitem(ms: var PyList; indices: Slice[int]) 13 +nim delitem _._/builtins/list.html#delitem,PyList,PySlice proc delitem(ms: var PyList; indices: PySlice) 249 +nim `[]=` _._/builtins/list.html#[]=,PyList[T],Slice[int],Sequence[T] proc `[]=`[T](ms: var PyList[T]; indices: Slice[int]; o: Sequence[T]) 250 +nimgrp sort _._/builtins/list.html#sort-procs-all proc 125 +nimgrp []= _._/builtins/list.html#[]=-procs-all proc 31 +nimgrp list _._/builtins/list.html#list-procs-all proc 44 +nimgrp sorted _._/builtins/list.html#sorted-procs-all proc 129 +nimgrp [] _._/builtins/list.html#[]-procs-all proc 33 +nimgrp += _._/builtins/list.html#+=-procs-all proc 75 +nimgrp pop _._/builtins/list.html#pop-procs-all proc 95 +nimgrp delitem _._/builtins/list.html#delitem-procs-all proc 115 diff --git a/Lib/_._/builtins/list_decl.html b/Lib/_._/builtins/list_decl.html new file mode 100644 index 000000000..3d54f83b9 --- /dev/null +++ b/Lib/_._/builtins/list_decl.html @@ -0,0 +1,601 @@ + + + + + + + +src/pylib/builtins/list_decl + + + + + + + + + + + + + + + + +
+
+

src/pylib/builtins/list_decl

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Types

+
+
+
list[T] = ref object
+
+ + + Source   +Edit   + +
+
+
+
PyList[T] = list[T]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
func `<`[A, B](self: PyList[A]; o: openArray[B]): bool {.inline.}
+
+ + + Source   +Edit   + +
+
+
+
func `<`[A, B](self: PyList[A]; o: PyList[B]): bool {.inline.}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func `<=`[A, B](self: PyList[A]; o: openArray[B]): bool {.inline.}
+
+ + + Source   +Edit   + +
+
+
+
func `<=`[A, B](self: PyList[A]; o: PyList[B]): bool {.inline.}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func `==`[A, B](self: PyList[A]; o: openArray[B]): bool {.inline.}
+
+ + + Source   +Edit   + +
+
+
+
func `==`[A, B](self: PyList[A]; o: PyList[B]): bool {.inline.}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func `@`[T](ls: PyList[T]): seq[T]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func getPtr[T](self: sink PyList[T]; i: Natural | BackwardsIndex): ptr T {.
+    inline.}
+
+ + EXT. unstable. used by Lib/array frombytes and tobytes. + Source   +Edit   + +
+
+ +
+
+
+
func newPyList(a: sink openArray[char]): PyList[char] {.inline, ...raises: [],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func newPyList(a: sink openArray[float]): PyList[float] {.inline, ...raises: [],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func newPyList(a: sink openArray[int]): PyList[int] {.inline, ...raises: [],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func newPyList[T](a: sink openArray[T]): PyList[T] {.inline.}
+
+ + + Source   +Edit   + +
+
+
+
func newPyList[T](len = 0): PyList[T] {.inline.}
+
+ + + Source   +Edit   + +
+
+
+
func newPyList[T](s: sink seq[T]): PyList[T] {.inline.}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func newPyListOfCap[T](cap = 0): PyList[T] {.inline.}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func newPyListOfStr(a: openArray[string]): PyList[PyStr] {.inline, ...raises: [],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func newPyListOfStr(a: PyList[string]): PyList[PyStr] {.inline, ...raises: [],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func repr[T: set | string | openArray](self: PyList[T]): string
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func setLen(self: PyList; len: Natural)
+
+ + EXT. unstable. only works for simple types + Source   +Edit   + +
+
+ +
+ +
+
+
+

Iterators

+
+
+
+
iterator items[T](self: PyList[T]): T
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
iterator mitems[T](self: PyList[T]): var T
+
+ + EXT. + Source   +Edit   + +
+
+ +
+
+
+
iterator pairs[T](self: PyList[T]): (int, T)
+
+ + EXT. Nim's auto-enumerate + Source   +Edit   + +
+
+ +
+ +
+
+
+

Converters

+
+
+
+
converter asSeq[T](self: PyList[T]): seq[T]
+
+ + + Source   +Edit   + +
+
+
+
converter asSeq[T](self: var PyList[T]): var seq[T]
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template `<`[A, B](o: openArray[A]; self: PyList[B]): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template `<=`[A, B](o: openArray[A]; self: PyList[B]): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template `==`[A, B](o: openArray[A]; self: PyList[B]): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template checkLenientOps(A, B)
+
+ + inner. unstable + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/builtins/list_decl.idx b/Lib/_._/builtins/list_decl.idx new file mode 100644 index 000000000..de725968e --- /dev/null +++ b/Lib/_._/builtins/list_decl.idx @@ -0,0 +1,37 @@ +nimTitle list_decl _._/builtins/list_decl.html module src/pylib/builtins/list_decl 0 +nim list _._/builtins/list_decl.html#list type list 5 +nim PyList _._/builtins/list_decl.html#PyList type PyList 9 +nim asSeq _._/builtins/list_decl.html#asSeq.c,PyList[T] converter asSeq[T](self: PyList[T]): seq[T] 12 +nim asSeq _._/builtins/list_decl.html#asSeq.c,PyList[T]_2 converter asSeq[T](self: var PyList[T]): var seq[T] 13 +nim `@` _._/builtins/list_decl.html#@,PyList[T] proc `@`[T](ls: PyList[T]): seq[T] 15 +nim setLen _._/builtins/list_decl.html#setLen,PyList,Natural proc setLen(self: PyList; len: Natural) 16 +nim repr _._/builtins/list_decl.html#repr,PyList[T: set or string or openArray] proc repr[T: set | string | openArray](self: PyList[T]): string 22 +nim newPyList _._/builtins/list_decl.html#newPyList,sinkseq[T] proc newPyList[T](s: sink seq[T]): PyList[T] 26 +nim newPyList _._/builtins/list_decl.html#newPyList,sinkopenArray[T] proc newPyList[T](a: sink openArray[T]): PyList[T] 27 +nim newPyListOfStr _._/builtins/list_decl.html#newPyListOfStr,PyList[string] proc newPyListOfStr(a: PyList[string]): PyList[PyStr] 30 +nim newPyListOfStr _._/builtins/list_decl.html#newPyListOfStr,openArray[string] proc newPyListOfStr(a: openArray[string]): PyList[PyStr] 31 +nim newPyList _._/builtins/list_decl.html#newPyList,sinkopenArray[int] proc newPyList(a: sink openArray[int]): PyList[int] 42 +nim newPyList _._/builtins/list_decl.html#newPyList,sinkopenArray[float] proc newPyList(a: sink openArray[float]): PyList[float] 43 +nim newPyList _._/builtins/list_decl.html#newPyList,sinkopenArray[char] proc newPyList(a: sink openArray[char]): PyList[char] 44 +nim newPyList _._/builtins/list_decl.html#newPyList,int proc newPyList[T](len = 0): PyList[T] 46 +nim newPyListOfCap _._/builtins/list_decl.html#newPyListOfCap,int proc newPyListOfCap[T](cap = 0): PyList[T] 47 +nim items _._/builtins/list_decl.html#items.i,PyList[T] iterator items[T](self: PyList[T]): T 50 +nim mitems _._/builtins/list_decl.html#mitems.i,PyList[T] iterator mitems[T](self: PyList[T]): var T 53 +nim pairs _._/builtins/list_decl.html#pairs.i,PyList[T] iterator pairs[T](self: PyList[T]): (int, T) 57 +nim getPtr _._/builtins/list_decl.html#getPtr,sinkPyList[T], proc getPtr[T](self: sink PyList[T]; i: Natural | BackwardsIndex): ptr T 67 +nim checkLenientOps _._/builtins/list_decl.html#checkLenientOps.t,, template checkLenientOps(A, B) 74 +nim `==` _._/builtins/list_decl.html#==,PyList[A],PyList[B] proc `==`[A, B](self: PyList[A]; o: PyList[B]): bool 103 +nim `==` _._/builtins/list_decl.html#==,PyList[A],openArray[B] proc `==`[A, B](self: PyList[A]; o: openArray[B]): bool 106 +nim `==` _._/builtins/list_decl.html#==.t,openArray[A],PyList[B] template `==`[A, B](o: openArray[A]; self: PyList[B]): bool 113 +nim `<=` _._/builtins/list_decl.html#<=,PyList[A],PyList[B] proc `<=`[A, B](self: PyList[A]; o: PyList[B]): bool 103 +nim `<=` _._/builtins/list_decl.html#<=,PyList[A],openArray[B] proc `<=`[A, B](self: PyList[A]; o: openArray[B]): bool 106 +nim `<=` _._/builtins/list_decl.html#<=.t,openArray[A],PyList[B] template `<=`[A, B](o: openArray[A]; self: PyList[B]): bool 114 +nim `<` _._/builtins/list_decl.html#<,PyList[A],PyList[B] proc `<`[A, B](self: PyList[A]; o: PyList[B]): bool 103 +nim `<` _._/builtins/list_decl.html#<,PyList[A],openArray[B] proc `<`[A, B](self: PyList[A]; o: openArray[B]): bool 106 +nim `<` _._/builtins/list_decl.html#<.t,openArray[A],PyList[B] template `<`[A, B](o: openArray[A]; self: PyList[B]): bool 115 +nimgrp == _._/builtins/list_decl.html#==-procs-all proc 113 +nimgrp newpylistofstr _._/builtins/list_decl.html#newPyListOfStr-procs-all proc 30 +nimgrp newpylist _._/builtins/list_decl.html#newPyList-procs-all proc 26 +nimgrp <= _._/builtins/list_decl.html#<=-procs-all proc 114 +nimgrp < _._/builtins/list_decl.html#<-procs-all proc 115 +nimgrp asseq _._/builtins/list_decl.html#asSeq-converters-all converter 12 diff --git a/Lib/_._/builtins/private/mathutils.html b/Lib/_._/builtins/private/mathutils.html new file mode 100644 index 000000000..e65aa5c81 --- /dev/null +++ b/Lib/_._/builtins/private/mathutils.html @@ -0,0 +1,126 @@ + + + + + + + +src/pylib/builtins/private/mathutils + + + + + + + + + + + + + + + + +
+
+

src/pylib/builtins/private/mathutils

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Procs

+
+
+
+
func iPosCeil[I: SomeInteger](x: float): I
+
+ + I(ceil(x)) if x > 0 else 0 + Source   +Edit   + +
+
+ +
+
+
+
func rangeLen[I](start, stop, step: I): I
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/builtins/private/mathutils.idx b/Lib/_._/builtins/private/mathutils.idx new file mode 100644 index 000000000..2a106e923 --- /dev/null +++ b/Lib/_._/builtins/private/mathutils.idx @@ -0,0 +1,3 @@ +nimTitle mathutils _._/builtins/private/mathutils.html module src/pylib/builtins/private/mathutils 0 +nim iPosCeil _._/builtins/private/mathutils.html#iPosCeil,float proc iPosCeil[I: SomeInteger](x: float): I 2 +nim rangeLen _._/builtins/private/mathutils.html#rangeLen,I,I,I proc rangeLen[I](start, stop, step: I): I 9 diff --git a/Lib/_._/builtins/private/strIter.html b/Lib/_._/builtins/private/strIter.html new file mode 100644 index 000000000..49e4c0f1f --- /dev/null +++ b/Lib/_._/builtins/private/strIter.html @@ -0,0 +1,158 @@ + + + + + + + +src/pylib/builtins/private/strIter + + + + + + + + + + + + + + + + +
+
+

src/pylib/builtins/private/strIter

+
+ +
+ Source   +Edit   + +
+ +

+
+

Templates

+
+
+
+
template genDollarRepr(Coll; start, stop: char | string; linear = false;
+                       useIter = true) {.dirty.}
+
+ + + Source   +Edit   + +
+
+
+
template genDollarRepr(Coll; start, stop: char | string; strProc: typed;
+                       linear = false; useIter = true) {.dirty.}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template strIterImpl(it: typed{atom}; strProc; start, stop: char | string;
+                     linear = false; useIter = true): string
+
+ + requires iter(it), it.len, it[int] + Source   +Edit   + +
+
+
+
template strIterImpl(itExpr: typed{~atom}; strProc; start, stop: char | string;
+                     linear = false; useIter = true): string
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/builtins/private/strIter.idx b/Lib/_._/builtins/private/strIter.idx new file mode 100644 index 000000000..9d1793e48 --- /dev/null +++ b/Lib/_._/builtins/private/strIter.idx @@ -0,0 +1,7 @@ +nimTitle strIter _._/builtins/private/strIter.html module src/pylib/builtins/private/strIter 0 +nim strIterImpl _._/builtins/private/strIter.html#strIterImpl.t,,,, template strIterImpl(it: typed{atom}; strProc; start, stop: char | string;\n linear = false; useIter = true): string 7 +nim strIterImpl _._/builtins/private/strIter.html#strIterImpl.t,,,,_2 template strIterImpl(itExpr: typed{~atom}; strProc; start, stop: char | string;\n linear = false; useIter = true): string 32 +nim genDollarRepr _._/builtins/private/strIter.html#genDollarRepr.t,,,,typed template genDollarRepr(Coll; start, stop: char | string; strProc: typed; linear = false;\n useIter = true) 50 +nim genDollarRepr _._/builtins/private/strIter.html#genDollarRepr.t,,, template genDollarRepr(Coll; start, stop: char | string; linear = false; useIter = true) 53 +nimgrp gendollarrepr _._/builtins/private/strIter.html#genDollarRepr-templates-all template 50 +nimgrp striterimpl _._/builtins/private/strIter.html#strIterImpl-templates-all template 7 diff --git a/Lib/_._/builtins/pyrange.html b/Lib/_._/builtins/pyrange.html new file mode 100644 index 000000000..1f6a8ee59 --- /dev/null +++ b/Lib/_._/builtins/pyrange.html @@ -0,0 +1,373 @@ + + + + + + + +src/pylib/builtins/pyrange + + + + + + + + + + + + + + + + +
+
+

src/pylib/builtins/pyrange

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Types

+
+
+
PyRange[T] = ref object
+  start*, stop*: T           ## `start`, `stop`, `step` are exported since Python 3.3
+  step*, len: int
+
+ + Python-like range object + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
func `$`[T](rng: PyRange[T]): string
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func `[]`[T](x: PyRange[T]; y: Natural): T {.inline.}
+
+ + Get value from range by its index + Source   +Edit   + +
+
+ +
+
+
+
func contains[T](x: PyRange[T]; y: T): bool
+
+ + Checks if given value is in range + Source   +Edit   + +
+
+ +
+
+
+
func count[T](r: PyRange[T]; x: T): int
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func index[T](r: PyRange[T]; x: T): int
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func max[T](x: PyRange[T]): T {.inline.}
+
+ + Get maximum value from range. Python's max(range(...)) + Source   +Edit   + +
+
+ +
+
+
+
func min[T](x: PyRange[T]): T {.inline.}
+
+ + Get minimum value from range. Python's max(range(...)) + Source   +Edit   + +
+
+ +
+
+
+
func range[T: SomeInteger](start, stop, step: T): PyRange[T]
+
+ + Creates new range object with given start, stop and step of any integer type + Source   +Edit   + +
+
+ +
+
+
+
func repr[T](rng: PyRange[T]): string
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Iterators

+
+
+
+
iterator items[T](rng: PyRange[T]): T
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template len[T](rng: PyRange[T]): int
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template range[T: SomeInteger](start, stop: T): PyRange[T]
+
+ + Shortcut for range(start, stop, 1) + Source   +Edit   + +
+
+
+
template range[T: SomeInteger](stop: T): PyRange[T]
+
+ + Shortcut for range(0, stop, 1) + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/builtins/pyrange.idx b/Lib/_._/builtins/pyrange.idx new file mode 100644 index 000000000..c9325c53c --- /dev/null +++ b/Lib/_._/builtins/pyrange.idx @@ -0,0 +1,16 @@ +nimTitle pyrange _._/builtins/pyrange.html module src/pylib/builtins/pyrange 0 +nim PyRange _._/builtins/pyrange.html#PyRange type PyRange 5 +nim `$` _._/builtins/pyrange.html#$,PyRange[T] proc `$`[T](rng: PyRange[T]): string 9 +nim repr _._/builtins/pyrange.html#repr,PyRange[T] proc repr[T](rng: PyRange[T]): string 14 +nim range _._/builtins/pyrange.html#range,T,T,T proc range[T: SomeInteger](start, stop, step: T): PyRange[T] 16 +nim range _._/builtins/pyrange.html#range.t,T,T template range[T: SomeInteger](start, stop: T): PyRange[T] 24 +nim range _._/builtins/pyrange.html#range.t,T template range[T: SomeInteger](stop: T): PyRange[T] 29 +nim len _._/builtins/pyrange.html#len.t,PyRange[T] template len[T](rng: PyRange[T]): int 34 +nim items _._/builtins/pyrange.html#items.i,PyRange[T] iterator items[T](rng: PyRange[T]): T 37 +nim contains _._/builtins/pyrange.html#contains,PyRange[T],T proc contains[T](x: PyRange[T]; y: T): bool 49 +nim `[]` _._/builtins/pyrange.html#[],PyRange[T],Natural proc `[]`[T](x: PyRange[T]; y: Natural): T 58 +nim min _._/builtins/pyrange.html#min,PyRange[T] proc min[T](x: PyRange[T]): T 63 +nim max _._/builtins/pyrange.html#max,PyRange[T] proc max[T](x: PyRange[T]): T 69 +nim count _._/builtins/pyrange.html#count,PyRange[T],T proc count[T](r: PyRange[T]; x: T): int 75 +nim index _._/builtins/pyrange.html#index,PyRange[T],T proc index[T](r: PyRange[T]; x: T): int 78 +nimgrp range _._/builtins/pyrange.html#range-templates-all template 24 diff --git a/Lib/_._/builtins/pyslice.html b/Lib/_._/builtins/pyslice.html new file mode 100644 index 000000000..4ee675d60 --- /dev/null +++ b/Lib/_._/builtins/pyslice.html @@ -0,0 +1,308 @@ + + + + + + + +src/pylib/builtins/pyslice + + + + + + + + + + + + + + + + +
+
+

src/pylib/builtins/pyslice

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Types

+
+
+
PySlice = ref object of PySlice1
+  step*: int
+
+ + + Source   +Edit   + +
+
+
+
PySlice1 = ref object of RootObj
+  start*, stop*: int
+
+ + slice of 1 step + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
func `<`(self`gensym3: PySlice; o`gensym3: PySlice): bool {....raises: [],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func `<=`(self`gensym6: PySlice; o`gensym6: PySlice): bool {....raises: [],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func `==`(self: PySlice; o: PySlice): bool {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func indices(self: PySlice; length: int): (int, int, int) {.
+    ...raises: [ValueError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func repr(self: PySlice): string {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func slice(start, stop: int): PySlice1 {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func slice(start, stop: int; step: int): PySlice {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func slice(stop: int): PySlice1 {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc toNimSlice(s: PySlice1): Slice[int] {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Converters

+
+
+
+
converter toPySlice(s: PySlice1): PySlice {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/builtins/pyslice.idx b/Lib/_._/builtins/pyslice.idx new file mode 100644 index 000000000..64398f216 --- /dev/null +++ b/Lib/_._/builtins/pyslice.idx @@ -0,0 +1,14 @@ +nimTitle pyslice _._/builtins/pyslice.html module src/pylib/builtins/pyslice 0 +nim PySlice1 _._/builtins/pyslice.html#PySlice1 type PySlice1 4 +nim PySlice _._/builtins/pyslice.html#PySlice type PySlice 7 +nim `==` _._/builtins/pyslice.html#==,PySlice,PySlice proc `==`(self: PySlice; o: PySlice): bool 10 +nim `<` _._/builtins/pyslice.html#<,PySlice,PySlice proc `<`(self`gensym3: PySlice; o`gensym3: PySlice): bool 19 +nim `<=` _._/builtins/pyslice.html#<=,PySlice,PySlice proc `<=`(self`gensym6: PySlice; o`gensym6: PySlice): bool 20 +nim slice _._/builtins/pyslice.html#slice,int,int proc slice(start, stop: int): PySlice1 23 +nim slice _._/builtins/pyslice.html#slice,int,int,int proc slice(start, stop: int; step: int): PySlice 26 +nim slice _._/builtins/pyslice.html#slice,int proc slice(stop: int): PySlice1 29 +nim toPySlice _._/builtins/pyslice.html#toPySlice.c,PySlice1 converter toPySlice(s: PySlice1): PySlice 31 +nim toNimSlice _._/builtins/pyslice.html#toNimSlice,PySlice1 proc toNimSlice(s: PySlice1): Slice[int] 34 +nim repr _._/builtins/pyslice.html#repr,PySlice proc repr(self: PySlice): string 39 +nim indices _._/builtins/pyslice.html#indices,PySlice,int proc indices(self: PySlice; length: int): (int, int, int) 74 +nimgrp slice _._/builtins/pyslice.html#slice-procs-all proc 23 diff --git a/Lib/_._/builtins/reprImpl.html b/Lib/_._/builtins/reprImpl.html new file mode 100644 index 000000000..685fd3198 --- /dev/null +++ b/Lib/_._/builtins/reprImpl.html @@ -0,0 +1,133 @@ + + + + + + + +src/pylib/builtins/reprImpl + + + + + + + + + + + + + + + + +
+
+

src/pylib/builtins/reprImpl

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Procs

+
+
+
+
func pyreprbImpl(s: string): string {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func pyreprImpl(s: string; escape127: static[bool] = false): string
+
+ +

Python's repr but returns Nim's string.

+

nim's Escape Char feature can be enabled via -d:useNimCharEsc, in which 'e' (i.e.'x1B' in Nim) will be replaced by "\e"

+ +

Example:

+
# NOTE: string literal's `repr` is `system.repr`, as following. 
+assert repr("\"") == "\"\\\"\""   # string literal of "\""
+# use pyrepr for any StringLike and returns a PyStr
+assert pyreprImpl("\"") == "'\"'"
+ Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/builtins/reprImpl.idx b/Lib/_._/builtins/reprImpl.idx new file mode 100644 index 000000000..82a0ca5b5 --- /dev/null +++ b/Lib/_._/builtins/reprImpl.idx @@ -0,0 +1,3 @@ +nimTitle reprImpl _._/builtins/reprImpl.html module src/pylib/builtins/reprImpl 0 +nim pyreprImpl _._/builtins/reprImpl.html#pyreprImpl,string,static[bool] proc pyreprImpl(s: string; escape127: static[bool] = false): string 71 +nim pyreprbImpl _._/builtins/reprImpl.html#pyreprbImpl,string proc pyreprbImpl(s: string): string 85 diff --git a/Lib/_._/builtins/set.html b/Lib/_._/builtins/set.html new file mode 100644 index 000000000..3712f1c7e --- /dev/null +++ b/Lib/_._/builtins/set.html @@ -0,0 +1,1037 @@ + + + + + + + +src/pylib/builtins/set + + + + + + + + + + + + + + + + +
+
+

src/pylib/builtins/set

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

set and its methods. +

set type

set[T] is still for system.set[T], with its restriction of only allowing small ordinal as elements. PySet[T] is used to minic Python's.

+ +

Literal

Something like {1,2} shall be rewritten as pyset([1,2]), please note either pyset((1,2)) or pyset({1,2}) doesn't mean the same.

+

+ +
+

Types

+
+
+
SomeSet[H] = SomePySet[H] or HashSet[H] or OrderedSet[H] or set[H]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
proc `&=`[H; S: SomeSet[H]](self: var SomePySet[H]; s: S)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc `-`[H](self, o: PySet[H]): PySet[H]
+
+ + + Source   +Edit   + +
+
+
+
proc `-`[H](self: PyFrozenSet[H]; o: SomePySet[H]): PyFrozenSet[H]
+
+ + + Source   +Edit   + +
+
+
+
proc `-`[H](self: PySet[H]; o: PyFrozenSet[H]): PyFrozenSet[H]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc `-=`[H; S: SomeSet[H]](self: var SomePySet[H]; s: S)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc `<`[H](s: set[H]; self: SomePySet[H]): bool {.error: "When used, Nim compiler(at least 2.0.0-2.1.2) will complain:\n\'Error: unhandled exception: ccgexprs.nim(1994, 9) `setType.kind == tySet`\', \nConsider using `pyset` instead of set literal.".}
+
+ + + Source   +Edit   + +
+
+
+
proc `<`[H](self: SomePySet[H]; s: set[H]): bool {.error: "When used, Nim compiler(at least 2.0.0-2.1.2) will complain:\n\'Error: unhandled exception: ccgexprs.nim(1994, 9) `setType.kind == tySet`\', \nConsider using `pyset` instead of set literal.".}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc `<=`[H](s: set[H]; self: SomePySet[H]): bool {.error: "When used, Nim compiler(at least 2.0.0-2.1.2) will complain:\n\'Error: unhandled exception: ccgexprs.nim(1994, 9) `setType.kind == tySet`\', \nConsider using `pyset` instead of set literal.".}
+
+ + + Source   +Edit   + +
+
+
+
proc `<=`[H](self: SomePySet[H]; s: set[H]): bool {.error: "When used, Nim compiler(at least 2.0.0-2.1.2) will complain:\n\'Error: unhandled exception: ccgexprs.nim(1994, 9) `setType.kind == tySet`\', \nConsider using `pyset` instead of set literal.".}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc `==`[H](s: set[H]; self: SomePySet[H]): bool {.error: "When used, Nim compiler(at least 2.0.0-2.1.2) will complain:\n\'Error: unhandled exception: ccgexprs.nim(1994, 9) `setType.kind == tySet`\', \nConsider using `pyset` instead of set literal.".}
+
+ + + Source   +Edit   + +
+
+
+
proc `==`[H](self: SomePySet[H]; s: set[H]): bool {.error: "When used, Nim compiler(at least 2.0.0-2.1.2) will complain:\n\'Error: unhandled exception: ccgexprs.nim(1994, 9) `setType.kind == tySet`\', \nConsider using `pyset` instead of set literal.".}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc add[H](self: var PySet[H]; x: H)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc difference[H; Self: SomePySet[H]; S: not PySet[H]](self: Self; s: S): Self
+
+ + + Source   +Edit   + +
+
+
+
proc difference[H; Self: SomePySet[H]; S](self: Self; s1: auto; s2: auto;
+    x: varargs[S]): Self
+
+ + + Source   +Edit   + +
+
+
+
proc difference[H](self, o: PySet[H]): PySet[H]
+
+ + + Source   +Edit   + +
+
+
+
proc difference[H](self: PyFrozenSet[H]; o: SomePySet[H]): PyFrozenSet[H]
+
+ + + Source   +Edit   + +
+
+
+
proc difference[H](self: PySet[H]; o: PyFrozenSet[H]): PyFrozenSet[H]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc difference_update[H; I: Iterable[H]](self: var SomePySet[H]; i: I)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc `discard`[H](self: var PySet[H]; ele: H)
+
+ + discard is keyword of Nim, consider use `discard` or pydiscard + Source   +Edit   + +
+
+ +
+
+
+
proc frozenset[H](): PyFrozenSet[H]
+
+ + + Source   +Edit   + +
+
+
+
proc frozenset[H](arr: openArray[H]): PyFrozenSet[H]
+
+ + + Source   +Edit   + +
+
+
+
proc frozenset[H](it: Iterable[H]): PyFrozenSet[H]
+
+ + + Source   +Edit   + +
+
+
+
proc frozenset[H](s: HashSet[H]): PyFrozenSet[H]
+
+ + + Source   +Edit   + +
+
+
+
proc frozenset[H](s: SomePySet[H]): PyFrozenSet[H]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc intersection[H; Self: SomePySet[H]; S: not PySet[H]](self: Self; s: S): Self
+
+ + + Source   +Edit   + +
+
+
+
proc intersection[H; Self: SomePySet[H]; S](self: Self; s1: auto; s2: auto;
+    x: varargs[S]): Self
+
+ + + Source   +Edit   + +
+
+
+
proc intersection[H](self, o: PySet[H]): PySet[H]
+
+ + + Source   +Edit   + +
+
+
+
proc intersection[H](self: PyFrozenSet[H]; o: SomePySet[H]): PyFrozenSet[H]
+
+ + + Source   +Edit   + +
+
+
+
proc intersection[H](self: PySet[H]; o: PyFrozenSet[H]): PyFrozenSet[H]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc intersection_update[H; I: Iterable[H]](self: var SomePySet[H]; i: I)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func isdisjoint[H, S](self: SomePySet[H]; s: S): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc issubset[H, S](self, o: SomePySet[H]; s: S): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc issuperset[H, S](self, o: SomePySet[H]; s: S): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc pydiscard[H](self: var PySet[H]; ele: H)
+
+ + set.discard(ele) + Source   +Edit   + +
+
+ +
+
+
+
proc pyset[H](): PySet[H]
+
+ + + Source   +Edit   + +
+
+
+
proc pyset[H](arr: openArray[H]): PySet[H]
+
+ + + Source   +Edit   + +
+
+
+
proc pyset[H](iterable: Iterable[H]): PySet[H]
+
+ + + Source   +Edit   + +
+
+
+
proc pyset[H](s: HashSet[H]): PySet[H]
+
+ + + Source   +Edit   + +
+
+
+
proc pyset[H](s: SomePySet[H]): PySet[H]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc remove[H](self: var PySet[H]; ele: H)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc set[H](): PySet[H]
+
+ + + Source   +Edit   + +
+
+
+
proc set[H](arr: openArray[H]): PySet[H]
+
+ + + Source   +Edit   + +
+
+
+
proc set[H](iterable: Iterable[H]): PySet[H]
+
+ + + Source   +Edit   + +
+
+
+
proc set[H](s: HashSet[H]): PySet[H]
+
+ + + Source   +Edit   + +
+
+
+
proc set[H](s: SomePySet[H]): PySet[H]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc symmetric_difference[H; Self: SomePySet[H]; S: not PySet[H]](self: Self;
+    s: S): Self
+
+ + + Source   +Edit   + +
+
+
+
proc symmetric_difference[H; Self: SomePySet[H]; S](self: Self; s1: auto;
+    s2: auto; x: varargs[S]): Self
+
+ + + Source   +Edit   + +
+
+
+
proc symmetric_difference[H](self, o: PySet[H]): PySet[H]
+
+ + + Source   +Edit   + +
+
+
+
proc symmetric_difference[H](self: PyFrozenSet[H]; o: SomePySet[H]): PyFrozenSet[
+    H]
+
+ + + Source   +Edit   + +
+
+
+
proc symmetric_difference[H](self: PySet[H]; o: PyFrozenSet[H]): PyFrozenSet[H]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc union[H; Self: SomePySet[H]; S: not PySet[H]](self: Self; s: S): Self
+
+ + + Source   +Edit   + +
+
+
+
proc union[H; Self: SomePySet[H]; S](self: Self; s1: auto; s2: auto;
+                                     x: varargs[S]): Self
+
+ + + Source   +Edit   + +
+
+
+
proc union[H](self, o: PySet[H]): PySet[H]
+
+ + + Source   +Edit   + +
+
+
+
proc union[H](self: PyFrozenSet[H]; o: SomePySet[H]): PyFrozenSet[H]
+
+ + + Source   +Edit   + +
+
+
+
proc union[H](self: PySet[H]; o: PyFrozenSet[H]): PyFrozenSet[H]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc update[H; I: Iterable[H]](self: var SomePySet[H]; i: I)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc `|=`[H; S: SomeSet[H]](self: var SomePySet[H]; s: S)
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Macros

+
+
+
+
macro pysetLit(lit): PySet
+
+ + To solve: pyset({1,2,3}) is invalid + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template `&`[H; M: SomePySet[H]; S: SomePySet[H]](self: M; s: S): M | S
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template `^`[H; M: SomePySet[H]; S: SomePySet[H]](self: M; s: S): M | S
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template copy[H; S: SomePySet[H]](self): S
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template `|`[H; M: SomePySet[H]; S: SomePySet[H]](self: M; s: S): M | S
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ + +
+
+ + +
+
+ + + diff --git a/Lib/_._/builtins/set.idx b/Lib/_._/builtins/set.idx new file mode 100644 index 000000000..0ebae7708 --- /dev/null +++ b/Lib/_._/builtins/set.idx @@ -0,0 +1,77 @@ +nimTitle set _._/builtins/set.html module src/pylib/builtins/set 0 +nim SomeSet _._/builtins/set.html#SomeSet type SomeSet 18 +nim set _._/builtins/set.html#set_2 proc set[H](): PySet[H] 29 +nim pyset _._/builtins/set.html#pyset_2 proc pyset[H](): PySet[H] 29 +nim set _._/builtins/set.html#set,HashSet[H] proc set[H](s: HashSet[H]): PySet[H] 31 +nim pyset _._/builtins/set.html#pyset,HashSet[H] proc pyset[H](s: HashSet[H]): PySet[H] 31 +nim set _._/builtins/set.html#set,SomePySet[H] proc set[H](s: SomePySet[H]): PySet[H] 33 +nim pyset _._/builtins/set.html#pyset,SomePySet[H] proc pyset[H](s: SomePySet[H]): PySet[H] 33 +nim set _._/builtins/set.html#set,openArray[H] proc set[H](arr: openArray[H]): PySet[H] 34 +nim pyset _._/builtins/set.html#pyset,openArray[H] proc pyset[H](arr: openArray[H]): PySet[H] 34 +nim set _._/builtins/set.html#set,Iterable[H] proc set[H](iterable: Iterable[H]): PySet[H] 35 +nim pyset _._/builtins/set.html#pyset,Iterable[H] proc pyset[H](iterable: Iterable[H]): PySet[H] 28 +nim frozenset _._/builtins/set.html#frozenset_2 proc frozenset[H](): PyFrozenSet[H] 40 +nim frozenset _._/builtins/set.html#frozenset,HashSet[H] proc frozenset[H](s: HashSet[H]): PyFrozenSet[H] 42 +nim frozenset _._/builtins/set.html#frozenset,SomePySet[H] proc frozenset[H](s: SomePySet[H]): PyFrozenSet[H] 44 +nim frozenset _._/builtins/set.html#frozenset,openArray[H] proc frozenset[H](arr: openArray[H]): PyFrozenSet[H] 45 +nim frozenset _._/builtins/set.html#frozenset,Iterable[H] proc frozenset[H](it: Iterable[H]): PyFrozenSet[H] 46 +nim pysetLit _._/builtins/set.html#pysetLit.m macro pysetLit(lit): PySet 56 +nim copy _._/builtins/set.html#copy.t template copy[H; S: SomePySet[H]](self): S 67 +nim `-` _._/builtins/set.html#-,PySet[H],PySet[H] proc `-`[H](self, o: PySet[H]): PySet[H] 71 +nim `-` _._/builtins/set.html#-,PyFrozenSet[H],SomePySet[H] proc `-`[H](self: PyFrozenSet[H]; o: SomePySet[H]): PyFrozenSet[H] 73 +nim `-` _._/builtins/set.html#-,PySet[H],PyFrozenSet[H] proc `-`[H](self: PySet[H]; o: PyFrozenSet[H]): PyFrozenSet[H] 83 +nim intersection _._/builtins/set.html#intersection,PySet[H],PySet[H] proc intersection[H](self, o: PySet[H]): PySet[H] 71 +nim intersection _._/builtins/set.html#intersection,PyFrozenSet[H],SomePySet[H] proc intersection[H](self: PyFrozenSet[H]; o: SomePySet[H]): PyFrozenSet[H] 73 +nim intersection _._/builtins/set.html#intersection,PySet[H],PyFrozenSet[H] proc intersection[H](self: PySet[H]; o: PyFrozenSet[H]): PyFrozenSet[H] 83 +nim union _._/builtins/set.html#union,PySet[H],PySet[H] proc union[H](self, o: PySet[H]): PySet[H] 71 +nim union _._/builtins/set.html#union,PyFrozenSet[H],SomePySet[H] proc union[H](self: PyFrozenSet[H]; o: SomePySet[H]): PyFrozenSet[H] 73 +nim union _._/builtins/set.html#union,PySet[H],PyFrozenSet[H] proc union[H](self: PySet[H]; o: PyFrozenSet[H]): PyFrozenSet[H] 83 +nim difference _._/builtins/set.html#difference,PySet[H],PySet[H] proc difference[H](self, o: PySet[H]): PySet[H] 71 +nim difference _._/builtins/set.html#difference,PyFrozenSet[H],SomePySet[H] proc difference[H](self: PyFrozenSet[H]; o: SomePySet[H]): PyFrozenSet[H] 73 +nim difference _._/builtins/set.html#difference,PySet[H],PyFrozenSet[H] proc difference[H](self: PySet[H]; o: PyFrozenSet[H]): PyFrozenSet[H] 83 +nim symmetric_difference _._/builtins/set.html#symmetric_difference,PySet[H],PySet[H] proc symmetric_difference[H](self, o: PySet[H]): PySet[H] 71 +nim symmetric_difference _._/builtins/set.html#symmetric_difference,PyFrozenSet[H],SomePySet[H] proc symmetric_difference[H](self: PyFrozenSet[H]; o: SomePySet[H]): PyFrozenSet[H] 73 +nim symmetric_difference _._/builtins/set.html#symmetric_difference,PySet[H],PyFrozenSet[H] proc symmetric_difference[H](self: PySet[H]; o: PyFrozenSet[H]): PyFrozenSet[H] 83 +nim `==` _._/builtins/set.html#==,SomePySet[H],set[H] proc `==`[H](self: SomePySet[H]; s: set[H]): bool 90 +nim `==` _._/builtins/set.html#==,set[H],SomePySet[H] proc `==`[H](s: set[H]; self: SomePySet[H]): bool 95 +nim `<=` _._/builtins/set.html#<=,SomePySet[H],set[H] proc `<=`[H](self: SomePySet[H]; s: set[H]): bool 90 +nim `<=` _._/builtins/set.html#<=,set[H],SomePySet[H] proc `<=`[H](s: set[H]; self: SomePySet[H]): bool 96 +nim `<` _._/builtins/set.html#<,SomePySet[H],set[H] proc `<`[H](self: SomePySet[H]; s: set[H]): bool 90 +nim `<` _._/builtins/set.html#<,set[H],SomePySet[H] proc `<`[H](s: set[H]; self: SomePySet[H]): bool 97 +nim `^` _._/builtins/set.html#^.t,M,S template `^`[H; M: SomePySet[H]; S: SomePySet[H]](self: M; s: S): M | S 105 +nim `&` _._/builtins/set.html#&.t,M,S template `&`[H; M: SomePySet[H]; S: SomePySet[H]](self: M; s: S): M | S 106 +nim `|` _._/builtins/set.html#|.t,M,S template `|`[H; M: SomePySet[H]; S: SomePySet[H]](self: M; s: S): M | S 107 +nim issuperset _._/builtins/set.html#issuperset,SomePySet[H],SomePySet[H],S proc issuperset[H, S](self, o: SomePySet[H]; s: S): bool 112 +nim issubset _._/builtins/set.html#issubset,SomePySet[H],SomePySet[H],S proc issubset[H, S](self, o: SomePySet[H]; s: S): bool 113 +nim intersection _._/builtins/set.html#intersection,Self,S proc intersection[H; Self: SomePySet[H]; S: not PySet[H]](self: Self; s: S): Self 117 +nim intersection _._/builtins/set.html#intersection,Self,auto,auto,varargs[S] proc intersection[H; Self: SomePySet[H]; S](self: Self; s1: auto; s2: auto;\n x: varargs[S]): Self 127 +nim union _._/builtins/set.html#union,Self,S proc union[H; Self: SomePySet[H]; S: not PySet[H]](self: Self; s: S): Self 117 +nim union _._/builtins/set.html#union,Self,auto,auto,varargs[S] proc union[H; Self: SomePySet[H]; S](self: Self; s1: auto; s2: auto; x: varargs[S]): Self 128 +nim difference _._/builtins/set.html#difference,Self,S proc difference[H; Self: SomePySet[H]; S: not PySet[H]](self: Self; s: S): Self 117 +nim difference _._/builtins/set.html#difference,Self,auto,auto,varargs[S] proc difference[H; Self: SomePySet[H]; S](self: Self; s1: auto; s2: auto;\n x: varargs[S]): Self 129 +nim symmetric_difference _._/builtins/set.html#symmetric_difference,Self,S proc symmetric_difference[H; Self: SomePySet[H]; S: not PySet[H]](self: Self; s: S): Self 117 +nim symmetric_difference _._/builtins/set.html#symmetric_difference,Self,auto,auto,varargs[S] proc symmetric_difference[H; Self: SomePySet[H]; S](self: Self; s1: auto; s2: auto;\n x: varargs[S]): Self 130 +nim isdisjoint _._/builtins/set.html#isdisjoint,SomePySet[H],S proc isdisjoint[H, S](self: SomePySet[H]; s: S): bool 132 +nim add _._/builtins/set.html#add,PySet[H],H proc add[H](self: var PySet[H]; x: H) 135 +nim `discard` _._/builtins/set.html#discard,PySet[H],H proc `discard`[H](self: var PySet[H]; ele: H) 136 +nim pydiscard _._/builtins/set.html#pydiscard,PySet[H],H proc pydiscard[H](self: var PySet[H]; ele: H) 139 +nim remove _._/builtins/set.html#remove,PySet[H],H proc remove[H](self: var PySet[H]; ele: H) 143 +nim `-=` _._/builtins/set.html#-=,SomePySet[H],S proc `-=`[H; S: SomeSet[H]](self: var SomePySet[H]; s: S) 149 +nim difference_update _._/builtins/set.html#difference_update,SomePySet[H],I proc difference_update[H; I: Iterable[H]](self: var SomePySet[H]; i: I) 152 +nim `|=` _._/builtins/set.html#|=,SomePySet[H],S proc `|=`[H; S: SomeSet[H]](self: var SomePySet[H]; s: S) 149 +nim update _._/builtins/set.html#update,SomePySet[H],I proc update[H; I: Iterable[H]](self: var SomePySet[H]; i: I) 153 +nim `&=` _._/builtins/set.html#&=,SomePySet[H],S proc `&=`[H; S: SomeSet[H]](self: var SomePySet[H]; s: S) 149 +nim intersection_update _._/builtins/set.html#intersection_update,SomePySet[H],I proc intersection_update[H; I: Iterable[H]](self: var SomePySet[H]; i: I) 156 +nimgrp == _._/builtins/set.html#==-procs-all proc 95 +nimgrp - _._/builtins/set.html#--procs-all proc 83 +nimgrp pyset _._/builtins/set.html#pyset-procs-all proc 21 +nimgrp symmetricdifference _._/builtins/set.html#symmetric_difference-procs-all proc 83 +nimgrp frozenset _._/builtins/set.html#frozenset-procs-all proc 40 +nimgrp <= _._/builtins/set.html#<=-procs-all proc 96 +nimgrp union _._/builtins/set.html#union-procs-all proc 83 +nimgrp < _._/builtins/set.html#<-procs-all proc 97 +nimgrp set _._/builtins/set.html#set-procs-all proc 29 +nimgrp intersection _._/builtins/set.html#intersection-procs-all proc 83 +nimgrp difference _._/builtins/set.html#difference-procs-all proc 83 +heading set type _._/builtins/set.html#set-type set type 0 +heading Literal _._/builtins/set.html#literal Literal 0 diff --git a/Lib/_._/builtins/set_decl.html b/Lib/_._/builtins/set_decl.html new file mode 100644 index 000000000..41e308495 --- /dev/null +++ b/Lib/_._/builtins/set_decl.html @@ -0,0 +1,536 @@ + + + + + + + +src/pylib/builtins/set_decl + + + + + + + + + + + + + + + + +
+
+

src/pylib/builtins/set_decl

+
+ +
+ Source   +Edit   + +
+ +

+ +
+

Types

+
+
+
frozenset[H] = ref object
+
+ + + Source   +Edit   + +
+
+
+
PyFrozenSet[H] = frozenset[H]
+
+ + + Source   +Edit   + +
+
+
+
PySet[H] = set[H]
+
+ + + Source   +Edit   + +
+
+
+
set[H] = ref object
+
+ + + Source   +Edit   + +
+
+
+
SomePySet[H] = set[H] | frozenset[H]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
func `<`(self, o: SomePySet): int
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func `<=`(self, o: SomePySet): int
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func `==`(self, o: SomePySet): int
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func asHashSet[H](self: SomePySet[H]): HashSet[H]
+
+ + + Source   +Edit   + +
+
+
+
func asHashSet[H](self: var SomePySet[H]): var HashSet[H]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc clear(self: var PySet): int
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func contains[H](self: SomePySet[H]; x: H): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc excl[H](self: var SomePySet[H]; x: H)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func hash[H](self: PyFrozenSet[H]): int
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc incl[H](self: var SomePySet[H]; x: H)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func len(self: SomePySet): int
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func newPyFrozenSet[H](h: HashSet[H]): PyFrozenSet[H]
+
+ + + Source   +Edit   + +
+
+
+
func newPyFrozenSet[H](initialSize = defaultInitialSize): PyFrozenSet[H]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func newPySet[H](h: HashSet[H]): PySet[H]
+
+ + + Source   +Edit   + +
+
+
+
func newPySet[H](initialSize = defaultInitialSize): PySet[H]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc pop[H](self: var PySet[H]): H {.discardable.}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Iterators

+
+
+
+
iterator items[H](self: SomePySet[H]): H
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template `$`(self: PyFrozenSet): string
+
+ + + Source   +Edit   + +
+
+
+
template `$`(self: PySet): string
+
+ + + Source   +Edit   + +
+
+
+
template `$`(self: SomePySet): string
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template repr(self: PyFrozenSet): string {.dirty.}
+
+ + + Source   +Edit   + +
+
+
+
template repr(self: PySet): string {.dirty.}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/builtins/set_decl.idx b/Lib/_._/builtins/set_decl.idx new file mode 100644 index 000000000..26702ea71 --- /dev/null +++ b/Lib/_._/builtins/set_decl.idx @@ -0,0 +1,33 @@ +nimTitle set_decl _._/builtins/set_decl.html module src/pylib/builtins/set_decl 0 +nim frozenset _._/builtins/set_decl.html#frozenset type frozenset 7 +nim PyFrozenSet _._/builtins/set_decl.html#PyFrozenSet type PyFrozenSet 9 +nim set _._/builtins/set_decl.html#set type set 10 +nim PySet _._/builtins/set_decl.html#PySet type PySet 12 +nim SomePySet _._/builtins/set_decl.html#SomePySet type SomePySet 13 +nim hash _._/builtins/set_decl.html#hash,PyFrozenSet[H] proc hash[H](self: PyFrozenSet[H]): int 15 +nim asHashSet _._/builtins/set_decl.html#asHashSet,SomePySet[H] proc asHashSet[H](self: SomePySet[H]): HashSet[H] 17 +nim asHashSet _._/builtins/set_decl.html#asHashSet,SomePySet[H]_2 proc asHashSet[H](self: var SomePySet[H]): var HashSet[H] 18 +nim newPySet _._/builtins/set_decl.html#newPySet,HashSet[H] proc newPySet[H](h: HashSet[H]): PySet[H] 19 +nim newPyFrozenSet _._/builtins/set_decl.html#newPyFrozenSet,HashSet[H] proc newPyFrozenSet[H](h: HashSet[H]): PyFrozenSet[H] 20 +nim newPySet _._/builtins/set_decl.html#newPySet proc newPySet[H](initialSize = defaultInitialSize): PySet[H] 21 +nim newPyFrozenSet _._/builtins/set_decl.html#newPyFrozenSet proc newPyFrozenSet[H](initialSize = defaultInitialSize): PyFrozenSet[H] 23 +nim incl _._/builtins/set_decl.html#incl,SomePySet[H],H proc incl[H](self: var SomePySet[H]; x: H) 26 +nim excl _._/builtins/set_decl.html#excl,SomePySet[H],H proc excl[H](self: var SomePySet[H]; x: H) 27 +nim len _._/builtins/set_decl.html#len,SomePySet proc len(self: SomePySet): int 29 +nim repr _._/builtins/set_decl.html#repr.t,PySet template repr(self: PySet): string 42 +nim `$` _._/builtins/set_decl.html#$.t,PySet template `$`(self: PySet): string 31 +nim repr _._/builtins/set_decl.html#repr.t,PyFrozenSet template repr(self: PyFrozenSet): string 42 +nim `$` _._/builtins/set_decl.html#$.t,PyFrozenSet template `$`(self: PyFrozenSet): string 32 +nim `$` _._/builtins/set_decl.html#$.t,SomePySet template `$`(self: SomePySet): string 34 +nim clear _._/builtins/set_decl.html#clear,PySet proc clear(self: var PySet): int 38 +nim `==` _._/builtins/set_decl.html#==,SomePySet,SomePySet proc `==`(self, o: SomePySet): int 39 +nim `<=` _._/builtins/set_decl.html#<=,SomePySet,SomePySet proc `<=`(self, o: SomePySet): int 40 +nim `<` _._/builtins/set_decl.html#<,SomePySet,SomePySet proc `<`(self, o: SomePySet): int 41 +nim contains _._/builtins/set_decl.html#contains,SomePySet[H],H proc contains[H](self: SomePySet[H]; x: H): bool 42 +nim pop _._/builtins/set_decl.html#pop,PySet[H] proc pop[H](self: var PySet[H]): H 43 +nim items _._/builtins/set_decl.html#items.i,SomePySet[H] iterator items[H](self: SomePySet[H]): H 44 +nimgrp ashashset _._/builtins/set_decl.html#asHashSet-procs-all proc 17 +nimgrp newpyfrozenset _._/builtins/set_decl.html#newPyFrozenSet-procs-all proc 20 +nimgrp newpyset _._/builtins/set_decl.html#newPySet-procs-all proc 19 +nimgrp $ _._/builtins/set_decl.html#$-templates-all template 46 +nimgrp repr _._/builtins/set_decl.html#repr-templates-all template 42 diff --git a/Lib/_._/collections_abc.html b/Lib/_._/collections_abc.html new file mode 100644 index 000000000..bc35ee315 --- /dev/null +++ b/Lib/_._/collections_abc.html @@ -0,0 +1,96 @@ + + + + + + + +src/pylib/collections_abc + + + + + + + + + + + + + + + + +
+
+

src/pylib/collections_abc

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+ +
+ + +
+
+ + + diff --git a/Lib/_._/collections_abc.idx b/Lib/_._/collections_abc.idx new file mode 100644 index 000000000..8581495ba --- /dev/null +++ b/Lib/_._/collections_abc.idx @@ -0,0 +1 @@ +nimTitle collections_abc _._/collections_abc.html module src/pylib/collections_abc 0 diff --git a/Lib/_._/collections_abc/asyncs.html b/Lib/_._/collections_abc/asyncs.html new file mode 100644 index 000000000..3b32b1c56 --- /dev/null +++ b/Lib/_._/collections_abc/asyncs.html @@ -0,0 +1,301 @@ + + + + + + + +src/pylib/collections_abc/asyncs + + + + + + + + + + + + + + + + +
+
+

src/pylib/collections_abc/asyncs

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+

Coroutine

ref pep of `Coroutines with async and await syntax`, Future-like object is just an alias of Awaitable

+

V = 1
+async def f():
+    return V
+
+c: Coroutine[None, None, int] = f()
+
+try: c.send(None)
+except StopIteraion as s: assert V == s.value
+
+try: c.send(None)
+except RuntimeError as e: assert str(e) == "cannot reuse already awaited coroutine"
+
+# Also: V == await f()

+

pep for Asynchronous Generators

+ +

AsyncGenerator

V = 1
+async def f(): yield V
+ag = f()
+
+ag_asend_obj = ag.asend(None)  #  or `anext(ag)`
+try: ag_asend_obj.send(None)
+except StopIteration as s: assert V == s.value
+
+
+ag_asend_obj = ag.asend(None)  #  or `anext(ag, defval)` if wanting
+# the next `send` raises `StopIteration` and its value to be `defval`
+
+try: ag_asend_obj.send(None)
+except StopAsyncIteration: pass   # iteration end
+
+

+

for ag_asend_obj, ref link of PyAsyncGenASend:

+

PyAsyncGenASend is a coroutine-like object...

+

PyAsyncGenAThrow is very similar to PyAsyncGenASend. The only difference is that PyAsyncGenAThrow.send(), when called first time, throws an exception into the parent agen object (instead of pushing a value into it.)

+

+ +
+

Types

+
+
+
AsyncGenerator[Yield; Send] = concept selfof AsyncIterator[Yield]
+    self.asend(Send) is Awaitable[Yield]
+    self.athrow(CatchableError) is Awaitable[void]
+
+ + type( (async _(): yield)() ) ABC for such a function which returns an asynchronous generator iterator. It looks like a coroutine function defined with async def except that it contains yield expressions for producing a series of values usable in an async for loop. + Source   +Edit   + +
+
+
+
AsyncIterable[T] = concept self
+    aiter(self) is AsyncIterator[T]
+
+ + + Source   +Edit   + +
+
+
+
AsyncIterator[T] = concept selfof AsyncIterable[T]
+    anext(self) is Awaitable[T]
+
+ + + Source   +Edit   + +
+
+
+
Awaitable[T] = concept self
+    T is await self
+
+ + + Source   +Edit   + +
+
+
+
Coroutine[Yield; Send; Return] = concept selfof Awaitable[Return]
+    self.send(Send) is Yield
+    self.throw(CatchableError)
+
+ + type( (async def _(): return Return() )() ) in details: Coroutine[None, None, Return] + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
proc aclose(self: AsyncGenerator): owned(Future[void]) {....stackTrace: false.}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc anext[T](self: AsyncGenerator[T]): Awaitable[T] {.inline.}
+
+ + this shall be an async def + Source   +Edit   + +
+
+
+
proc anext[T](self: AsyncGenerator[T]; default: T): Awaitable[T] {.inline.}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc await[T](self: anextawaitableobject[T]): T
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc close(self: Coroutine)
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/collections_abc/asyncs.idx b/Lib/_._/collections_abc/asyncs.idx new file mode 100644 index 000000000..748d237c8 --- /dev/null +++ b/Lib/_._/collections_abc/asyncs.idx @@ -0,0 +1,14 @@ +nimTitle asyncs _._/collections_abc/asyncs.html module src/pylib/collections_abc/asyncs 0 +nim Awaitable _._/collections_abc/asyncs.html#Awaitable type Awaitable 69 +nim Coroutine _._/collections_abc/asyncs.html#Coroutine type Coroutine 71 +nim close _._/collections_abc/asyncs.html#close,Coroutine proc close(self: Coroutine) 79 +nim AsyncIterable _._/collections_abc/asyncs.html#AsyncIterable type AsyncIterable 103 +nim AsyncIterator _._/collections_abc/asyncs.html#AsyncIterator type AsyncIterator 105 +nim AsyncGenerator _._/collections_abc/asyncs.html#AsyncGenerator type AsyncGenerator 108 +nim anext _._/collections_abc/asyncs.html#anext,AsyncGenerator[T] proc anext[T](self: AsyncGenerator[T]): Awaitable[T] 119 +nim await _._/collections_abc/asyncs.html#await,anextawaitableobject[T] proc await[T](self: anextawaitableobject[T]): T 127 +nim anext _._/collections_abc/asyncs.html#anext,AsyncGenerator[T],T proc anext[T](self: AsyncGenerator[T]; default: T): Awaitable[T] 134 +nim aclose _._/collections_abc/asyncs.html#aclose,AsyncGenerator proc aclose(self: AsyncGenerator): owned(Future[void]) 137 +nimgrp anext _._/collections_abc/asyncs.html#anext-procs-all proc 119 +heading Coroutine _._/collections_abc/asyncs.html#coroutine Coroutine 0 +heading AsyncGenerator _._/collections_abc/asyncs.html#asyncgenerator AsyncGenerator 0 diff --git a/Lib/_._/collections_abc/collections.html b/Lib/_._/collections_abc/collections.html new file mode 100644 index 000000000..0496b5073 --- /dev/null +++ b/Lib/_._/collections_abc/collections.html @@ -0,0 +1,510 @@ + + + + + + + +src/pylib/collections_abc/collections + + + + + + + + + + + + + + + + +
+
+

src/pylib/collections_abc/collections

+
+ +
+ Source   +Edit   + +
+ +

+
+

Imports

+
+ iters +
+
+
+

Types

+
+
+
Collection[T] = Sized and Container[T] and Iterable[T]
+
+ + + Source   +Edit   + +
+
+
+
Container[T] = concept self
+    T
+    contains(self, T) is bool
+
+ + + Source   +Edit   + +
+
+
+
Mapping[K; V] = concept selfof Collection[K]
+    K
+    V
+    self[K] is V
+
+ + + Source   +Edit   + +
+
+
+
MutableSequence[T] = concept selfof Sequence[T]
+    T
+    self[int] = T
+    self.delitem(int)
+    self.insert(int, T)      ## insert item before index
+
+ + __delitem__ + Source   +Edit   + +
+
+
+
Sequence[T] = concept selfof Collection[T]
+    T
+    self[int] is T
+
+ + + Source   +Edit   + +
+
+
+
Sized = concept self
+    len(self) is int
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
func `==`[K, V](a, b: Mapping[K, V]): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func `@`[T](s: Sequence[T]): seq[T] {.noInit, inline.}
+
+ + EXT. stable. + Source   +Edit   + +
+
+ +
+
+
+
func append[T](ms: MutableSequence[T]; x: T)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func clear(ms: MutableSequence)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func contains[K, V](m: Mapping[K, V]; k: K): bool
+
+ + + Source   +Edit   + +
+
+
+
func contains[T](s: Container[T]; x: T): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func count[T](s: Sequence[T]; x: T): int
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func extend[T](ms: MutableSequence[T]; it: Iterable[T])
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func get[K, V](m: Mapping[K, V]; key: K): V
+
+ + + Source   +Edit   + +
+
+
+
func get[K, V](m: Mapping[K, V]; key: K; default: V): V
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func index[T](s: Sequence[T]; x: T; start = 0; stop = -1): int
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func pop[T](ms: MutableSequence[T]; index = -1): T
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func remove[T](ms: MutableSequence[T]; x: T)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func reverse(ms: MutableSequence)
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Iterators

+
+
+
+
iterator items[K, V](m: Mapping[K, V]): (K, V)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
iterator values[K, V](m: Mapping[K, V]): V
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template keys[K, V](m: Mapping[K, V]): untyped
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/collections_abc/collections.idx b/Lib/_._/collections_abc/collections.idx new file mode 100644 index 000000000..d9f575b4f --- /dev/null +++ b/Lib/_._/collections_abc/collections.idx @@ -0,0 +1,26 @@ +nimTitle collections _._/collections_abc/collections.html module src/pylib/collections_abc/collections 0 +nim Sized _._/collections_abc/collections.html#Sized type Sized 5 +nim Container _._/collections_abc/collections.html#Container type Container 8 +nim Collection _._/collections_abc/collections.html#Collection type Collection 14 +nim Sequence _._/collections_abc/collections.html#Sequence type Sequence 16 +nim MutableSequence _._/collections_abc/collections.html#MutableSequence type MutableSequence 19 +nim Mapping _._/collections_abc/collections.html#Mapping type Mapping 25 +nim contains _._/collections_abc/collections.html#contains,Container[T],T proc contains[T](s: Container[T]; x: T): bool 33 +nim index _._/collections_abc/collections.html#index,Sequence[T],T,int,int proc index[T](s: Sequence[T]; x: T; start = 0; stop = -1): int 39 +nim count _._/collections_abc/collections.html#count,Sequence[T],T proc count[T](s: Sequence[T]; x: T): int 48 +nim `@` _._/collections_abc/collections.html#@,Sequence[T] proc `@`[T](s: Sequence[T]): seq[T] 60 +nim append _._/collections_abc/collections.html#append,MutableSequence[T],T proc append[T](ms: MutableSequence[T]; x: T) 68 +nim clear _._/collections_abc/collections.html#clear,MutableSequence proc clear(ms: MutableSequence) 71 +nim reverse _._/collections_abc/collections.html#reverse,MutableSequence proc reverse(ms: MutableSequence) 75 +nim extend _._/collections_abc/collections.html#extend,MutableSequence[T],Iterable[T] proc extend[T](ms: MutableSequence[T]; it: Iterable[T]) 80 +nim pop _._/collections_abc/collections.html#pop,MutableSequence[T],int proc pop[T](ms: MutableSequence[T]; index = -1): T 84 +nim remove _._/collections_abc/collections.html#remove,MutableSequence[T],T proc remove[T](ms: MutableSequence[T]; x: T) 89 +nim keys _._/collections_abc/collections.html#keys.t,Mapping[K,V] template keys[K, V](m: Mapping[K, V]): untyped 94 +nim values _._/collections_abc/collections.html#values.i,Mapping[K,V] iterator values[K, V](m: Mapping[K, V]): V 96 +nim items _._/collections_abc/collections.html#items.i,Mapping[K,V] iterator items[K, V](m: Mapping[K, V]): (K, V) 98 +nim contains _._/collections_abc/collections.html#contains,Mapping[K,V],K proc contains[K, V](m: Mapping[K, V]; k: K): bool 101 +nim get _._/collections_abc/collections.html#get,Mapping[K,V],K proc get[K, V](m: Mapping[K, V]; key: K): V 105 +nim get _._/collections_abc/collections.html#get,Mapping[K,V],K,V proc get[K, V](m: Mapping[K, V]; key: K; default: V): V 106 +nim `==` _._/collections_abc/collections.html#==,Mapping[K,V],Mapping[K,V] proc `==`[K, V](a, b: Mapping[K, V]): bool 110 +nimgrp contains _._/collections_abc/collections.html#contains-procs-all proc 33 +nimgrp get _._/collections_abc/collections.html#get-procs-all proc 105 diff --git a/Lib/_._/collections_abc/generators.html b/Lib/_._/collections_abc/generators.html new file mode 100644 index 000000000..96913918f --- /dev/null +++ b/Lib/_._/collections_abc/generators.html @@ -0,0 +1,201 @@ + + + + + + + +src/pylib/collections_abc/generators + + + + + + + + + + + + + + + + +
+
+

src/pylib/collections_abc/generators

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Types

+
+
+
Generator[YieldType; SendType; ReturnType] = concept selfof Iterator[YieldType]
+    try:
+      self.send(SendType) is YieldType
+    except StopIterationT[ReturnType]:
+      discard
+    self.throw(CatchableError)
+
+ + type( (def _(): yield)() ) + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
proc close(self: Generator)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc next[T; R](self: Generator[T, NoneType, R]): T {.inline.}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template iter[T; S; R](self: Generator[T, S, R]): Iterator[T]
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/collections_abc/generators.idx b/Lib/_._/collections_abc/generators.idx new file mode 100644 index 000000000..1dc51a5b5 --- /dev/null +++ b/Lib/_._/collections_abc/generators.idx @@ -0,0 +1,5 @@ +nimTitle generators _._/collections_abc/generators.html module src/pylib/collections_abc/generators 0 +nim Generator _._/collections_abc/generators.html#Generator type Generator 8 +nim close _._/collections_abc/generators.html#close,Generator proc close(self: Generator) 16 +nim iter _._/collections_abc/generators.html#iter.t,Generator[T,S,R] template iter[T; S; R](self: Generator[T, S, R]): Iterator[T] 20 +nim next _._/collections_abc/generators.html#next,Generator[T,NoneType,R] proc next[T; R](self: Generator[T, NoneType, R]): T 21 diff --git a/Lib/_._/collections_abc/iters.html b/Lib/_._/collections_abc/iters.html new file mode 100644 index 000000000..2e3febaaf --- /dev/null +++ b/Lib/_._/collections_abc/iters.html @@ -0,0 +1,136 @@ + + + + + + + +src/pylib/collections_abc/iters + + + + + + + + + + + + + + + + +
+
+

src/pylib/collections_abc/iters

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Types

+
+
+
Iterable[T] = concept self
+    T
+    when SupportIteratorHit:
+      iterator items(self): T
+    else:
+      when defined(js):
+        typeof(self.items(), ItemTypeMode) is T
+      else:
+        for value in self:
+          value is T
+
+ + Mimic Pythons Iterable. But not checks iter + Source   +Edit   + +
+
+
+
Iterator[T] = concept selfof Iterable[T]
+    T
+    self.next is T
+
+ + + Source   +Edit   + +
+
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/collections_abc/iters.idx b/Lib/_._/collections_abc/iters.idx new file mode 100644 index 000000000..2512de205 --- /dev/null +++ b/Lib/_._/collections_abc/iters.idx @@ -0,0 +1,3 @@ +nimTitle iters _._/collections_abc/iters.html module src/pylib/collections_abc/iters 0 +nim Iterable _._/collections_abc/iters.html#Iterable type Iterable 10 +nim Iterator _._/collections_abc/iters.html#Iterator type Iterator 22 diff --git a/Lib/_._/collections_abc/private/templ.html b/Lib/_._/collections_abc/private/templ.html new file mode 100644 index 000000000..ecdb996cb --- /dev/null +++ b/Lib/_._/collections_abc/private/templ.html @@ -0,0 +1,109 @@ + + + + + + + +src/pylib/collections_abc/private/templ + + + + + + + + + + + + + + + + +
+
+

src/pylib/collections_abc/private/templ

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Templates

+
+
+
+
template closeImpl(msg: string; throwBody)
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/collections_abc/private/templ.idx b/Lib/_._/collections_abc/private/templ.idx new file mode 100644 index 000000000..240ab340b --- /dev/null +++ b/Lib/_._/collections_abc/private/templ.idx @@ -0,0 +1,2 @@ +nimTitle templ _._/collections_abc/private/templ.html module src/pylib/collections_abc/private/templ 0 +nim closeImpl _._/collections_abc/private/templ.html#closeImpl.t,string, template closeImpl(msg: string; throwBody) 2 diff --git a/Lib/_._/io_abc.html b/Lib/_._/io_abc.html new file mode 100644 index 000000000..4b6795bf1 --- /dev/null +++ b/Lib/_._/io_abc.html @@ -0,0 +1,267 @@ + + + + + + + +src/pylib/io_abc + + + + + + + + + + + + + + + + +
+
+

src/pylib/io_abc

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Types

+
+
+
CanIOOpenT[T] = int | PathLike[T]
+
+ + + Source   +Edit   + +
+
+
+
PathLike[T] = concept self
+    T
+    self.fspath is T
+
+ + os.PathLike + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
proc `$`(p: CanIOOpenT): string
+
+ + Mainly for error message + Source   +Edit   + +
+
+
+
func `$`(p: PathLike): string
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func fspath(c: char): PyStr {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func fspath(s: string): PyStr {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func pathrepr(p: PathLike[PyBytes]): string
+
+ + + Source   +Edit   + +
+
+
+
func pathrepr(p: PathLike[PyStr]): string
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template mapPathLike[T](nexpr): T
+
+ + + Source   +Edit   + +
+
+
+
template mapPathLike[T](s: PathLike[T]; nimProc): T
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/io_abc.idx b/Lib/_._/io_abc.idx new file mode 100644 index 000000000..85d15952d --- /dev/null +++ b/Lib/_._/io_abc.idx @@ -0,0 +1,15 @@ +nimTitle io_abc _._/io_abc.html module src/pylib/io_abc 0 +nim fspath _._/io_abc.html#fspath,string proc fspath(s: string): PyStr 6 +nim fspath _._/io_abc.html#fspath,char proc fspath(c: char): PyStr 7 +nim PathLike _._/io_abc.html#PathLike type PathLike 11 +nim CanIOOpenT _._/io_abc.html#CanIOOpenT type CanIOOpenT 14 +nim mapPathLike _._/io_abc.html#mapPathLike.t,PathLike[T], template mapPathLike[T](s: PathLike[T]; nimProc): T 17 +nim mapPathLike _._/io_abc.html#mapPathLike.t template mapPathLike[T](nexpr): T 20 +nim `$` _._/io_abc.html#$,PathLike proc `$`(p: PathLike): string 25 +nim `$` _._/io_abc.html#$,CanIOOpenT proc `$`(p: CanIOOpenT): string 29 +nim pathrepr _._/io_abc.html#pathrepr,PathLike[PyBytes] proc pathrepr(p: PathLike[PyBytes]): string 34 +nim pathrepr _._/io_abc.html#pathrepr,PathLike[PyStr] proc pathrepr(p: PathLike[PyStr]): string 35 +nimgrp fspath _._/io_abc.html#fspath-procs-all proc 6 +nimgrp $ _._/io_abc.html#$-procs-all proc 25 +nimgrp pathrepr _._/io_abc.html#pathrepr-procs-all proc 34 +nimgrp mappathlike _._/io_abc.html#mapPathLike-templates-all template 17 diff --git a/Lib/_._/mutSeqSliceOp.html b/Lib/_._/mutSeqSliceOp.html new file mode 100644 index 000000000..05f1fac9a --- /dev/null +++ b/Lib/_._/mutSeqSliceOp.html @@ -0,0 +1,169 @@ + + + + + + + +src/pylib/mutSeqSliceOp + + + + + + + + + + + + + + + + +
+
+

src/pylib/mutSeqSliceOp

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

As Python's MutableSequence does not mixin these we place them here.

+ +
+

Templates

+
+
+
+
template bodySetItem(Arr) {.dirty.}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template genDelItem(Arr) {.dirty.}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template genGenericSetItem(Arr, Arr2) {.dirty.}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template genNonGenericSetItem(Arr, Arr2) {.dirty.}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/mutSeqSliceOp.idx b/Lib/_._/mutSeqSliceOp.idx new file mode 100644 index 000000000..10c2eab74 --- /dev/null +++ b/Lib/_._/mutSeqSliceOp.idx @@ -0,0 +1,5 @@ +nimTitle mutSeqSliceOp _._/mutSeqSliceOp.html module src/pylib/mutSeqSliceOp 0 +nim genDelItem _._/mutSeqSliceOp.html#genDelItem.t template genDelItem(Arr) 11 +nim bodySetItem _._/mutSeqSliceOp.html#bodySetItem.t template bodySetItem(Arr) 41 +nim genGenericSetItem _._/mutSeqSliceOp.html#genGenericSetItem.t,, template genGenericSetItem(Arr, Arr2) 63 +nim genNonGenericSetItem _._/mutSeqSliceOp.html#genNonGenericSetItem.t,, template genNonGenericSetItem(Arr, Arr2) 68 diff --git a/Lib/_._/nimpatch/abs.html b/Lib/_._/nimpatch/abs.html new file mode 100644 index 000000000..12cf266e7 --- /dev/null +++ b/Lib/_._/nimpatch/abs.html @@ -0,0 +1,134 @@ + + + + + + + +src/pylib/nimpatch/abs + + + + + + + + + + + + + + + + +
+
+

src/pylib/nimpatch/abs

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Imports

+
+ utils +
+
+
+

Consts

+
+
+
BeforeFixedVer = false
+
+ + + Source   +Edit   + +
+
+
+
FixedVer = (2, 1, 1)
+
+ + + Source   +Edit   + +
+
+
+
hasBug = false
+
+ + + Source   +Edit   + +
+
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/nimpatch/abs.idx b/Lib/_._/nimpatch/abs.idx new file mode 100644 index 000000000..8e20c5bd1 --- /dev/null +++ b/Lib/_._/nimpatch/abs.idx @@ -0,0 +1,4 @@ +nimTitle abs _._/nimpatch/abs.html module src/pylib/nimpatch/abs 0 +nim FixedVer _._/nimpatch/abs.html#FixedVer const FixedVer 12 +nim BeforeFixedVer _._/nimpatch/abs.html#BeforeFixedVer const BeforeFixedVer 13 +nim hasBug _._/nimpatch/abs.html#hasBug const hasBug 15 diff --git a/Lib/_._/nimpatch/nansign.html b/Lib/_._/nimpatch/nansign.html new file mode 100644 index 000000000..fcbcffdec --- /dev/null +++ b/Lib/_._/nimpatch/nansign.html @@ -0,0 +1,134 @@ + + + + + + + +src/pylib/nimpatch/nansign + + + + + + + + + + + + + + + + +
+
+

src/pylib/nimpatch/nansign

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Imports

+
+ utils +
+
+
+

Consts

+
+
+
BeforeFixedVer = true
+
+ + + Source   +Edit   + +
+
+
+
FixedVer = (2, 3, 1)
+
+ + + Source   +Edit   + +
+
+
+
hasBug = true
+
+ + + Source   +Edit   + +
+
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/nimpatch/nansign.idx b/Lib/_._/nimpatch/nansign.idx new file mode 100644 index 000000000..990599af1 --- /dev/null +++ b/Lib/_._/nimpatch/nansign.idx @@ -0,0 +1,4 @@ +nimTitle nansign _._/nimpatch/nansign.html module src/pylib/nimpatch/nansign 0 +nim FixedVer _._/nimpatch/nansign.html#FixedVer const FixedVer 12 +nim BeforeFixedVer _._/nimpatch/nansign.html#BeforeFixedVer const BeforeFixedVer 13 +nim hasBug _._/nimpatch/nansign.html#hasBug const hasBug 15 diff --git a/Lib/_._/nimpatch/newUninit.html b/Lib/_._/nimpatch/newUninit.html new file mode 100644 index 000000000..8e6583808 --- /dev/null +++ b/Lib/_._/nimpatch/newUninit.html @@ -0,0 +1,134 @@ + + + + + + + +src/pylib/nimpatch/newUninit + + + + + + + + + + + + + + + + +
+
+

src/pylib/nimpatch/newUninit

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Imports

+
+ utils +
+
+
+

Consts

+
+
+
BeforeFixedVer = false
+
+ + + Source   +Edit   + +
+
+
+
FixedVer = (2, 1, 1)
+
+ + + Source   +Edit   + +
+
+
+
hasBug = false
+
+ + + Source   +Edit   + +
+
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/nimpatch/newUninit.idx b/Lib/_._/nimpatch/newUninit.idx new file mode 100644 index 000000000..e5c9a524a --- /dev/null +++ b/Lib/_._/nimpatch/newUninit.idx @@ -0,0 +1,4 @@ +nimTitle newUninit _._/nimpatch/newUninit.html module src/pylib/nimpatch/newUninit 0 +nim FixedVer _._/nimpatch/newUninit.html#FixedVer const FixedVer 12 +nim BeforeFixedVer _._/nimpatch/newUninit.html#BeforeFixedVer const BeforeFixedVer 13 +nim hasBug _._/nimpatch/newUninit.html#hasBug const hasBug 15 diff --git a/Lib/_._/nimpatch/utils.html b/Lib/_._/nimpatch/utils.html new file mode 100644 index 000000000..bc27bef10 --- /dev/null +++ b/Lib/_._/nimpatch/utils.html @@ -0,0 +1,146 @@ + + + + + + + +src/pylib/nimpatch/utils + + + + + + + + + + + + + + + + +
+
+

src/pylib/nimpatch/utils

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Consts

+
+
+
JsBigInt64Option = true
+
+ + + Source   +Edit   + +
+
+
+
NimVersionTuple = (2, 2, 4)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Templates

+
+
+
+
template addPatch(ver: (int, int, int); flag: untyped; patchBody: untyped) {.
+    dirty.}
+
+ + flag is a bool expr, here uses untyped to delay evaluation to get its string represent + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/nimpatch/utils.idx b/Lib/_._/nimpatch/utils.idx new file mode 100644 index 000000000..1d9d2180f --- /dev/null +++ b/Lib/_._/nimpatch/utils.idx @@ -0,0 +1,4 @@ +nimTitle utils _._/nimpatch/utils.html module src/pylib/nimpatch/utils 0 +nim NimVersionTuple _._/nimpatch/utils.html#NimVersionTuple const NimVersionTuple 2 +nim JsBigInt64Option _._/nimpatch/utils.html#JsBigInt64Option const JsBigInt64Option 4 +nim addPatch _._/nimpatch/utils.html#addPatch.t,,untyped,untyped template addPatch(ver: (int, int, int); flag: untyped; patchBody: untyped) 6 diff --git a/Lib/_._/nimpatch/winOpenFileHandle.html b/Lib/_._/nimpatch/winOpenFileHandle.html new file mode 100644 index 000000000..3663bfc00 --- /dev/null +++ b/Lib/_._/nimpatch/winOpenFileHandle.html @@ -0,0 +1,134 @@ + + + + + + + +src/pylib/nimpatch/winOpenFileHandle + + + + + + + + + + + + + + + + +
+
+

src/pylib/nimpatch/winOpenFileHandle

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Imports

+
+ utils +
+
+
+

Consts

+
+
+
BeforeFixedVer = false
+
+ + + Source   +Edit   + +
+
+
+
FixedVer = (2, 1, 1)
+
+ + + Source   +Edit   + +
+
+
+
hasBug = false
+
+ + + Source   +Edit   + +
+
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/nimpatch/winOpenFileHandle.idx b/Lib/_._/nimpatch/winOpenFileHandle.idx new file mode 100644 index 000000000..9364d073f --- /dev/null +++ b/Lib/_._/nimpatch/winOpenFileHandle.idx @@ -0,0 +1,4 @@ +nimTitle winOpenFileHandle _._/nimpatch/winOpenFileHandle.html module src/pylib/nimpatch/winOpenFileHandle 0 +nim FixedVer _._/nimpatch/winOpenFileHandle.html#FixedVer const FixedVer 12 +nim BeforeFixedVer _._/nimpatch/winOpenFileHandle.html#BeforeFixedVer const BeforeFixedVer 13 +nim hasBug _._/nimpatch/winOpenFileHandle.html#hasBug const hasBug 15 diff --git a/Lib/_._/noneType.html b/Lib/_._/noneType.html new file mode 100644 index 000000000..2e32275fc --- /dev/null +++ b/Lib/_._/noneType.html @@ -0,0 +1,128 @@ + + + + + + + +src/pylib/noneType + + + + + + + + + + + + + + + + +
+
+

src/pylib/noneType

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Types

+
+
+
NoneType = distinct bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Consts

+
+
+
None = false
+
+ + Python-like None for special handling + Source   +Edit   + +
+
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/noneType.idx b/Lib/_._/noneType.idx new file mode 100644 index 000000000..c08cb77c0 --- /dev/null +++ b/Lib/_._/noneType.idx @@ -0,0 +1,3 @@ +nimTitle noneType _._/noneType.html module src/pylib/noneType 0 +nim NoneType _._/noneType.html#NoneType type NoneType 3 +nim None _._/noneType.html#None const None 8 diff --git a/Lib/_._/private/backendMark.html b/Lib/_._/private/backendMark.html new file mode 100644 index 000000000..3df22660e --- /dev/null +++ b/Lib/_._/private/backendMark.html @@ -0,0 +1,206 @@ + + + + + + + +src/pylib/private/backendMark + + + + + + + + + + + + + + + + +
+
+

src/pylib/private/backendMark

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Types

+
+
+
CompileBackend {.pure.} = enum
+  c = "C", cpp = "C++", objc = "Object-C", js = "JavaScript",
+  nimscript = "NimScript"
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Templates

+
+
+
+
template noBackend(backends: untyped; def)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template noBackends(backends: untyped; def)
+
+ + does the same as noBackend(...) + Source   +Edit   + +
+
+ +
+
+
+
template noJsBackend(def)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template noNimsBackend(def)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template noWeirdBackend(def)
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/private/backendMark.idx b/Lib/_._/private/backendMark.idx new file mode 100644 index 000000000..cc064a1de --- /dev/null +++ b/Lib/_._/private/backendMark.idx @@ -0,0 +1,7 @@ +nimTitle backendMark _._/private/backendMark.html module src/pylib/private/backendMark 0 +nim CompileBackend _._/private/backendMark.html#CompileBackend enum CompileBackend 5 +nim noJsBackend _._/private/backendMark.html#noJsBackend.t template noJsBackend(def) 71 +nim noNimsBackend _._/private/backendMark.html#noNimsBackend.t template noNimsBackend(def) 75 +nim noBackends _._/private/backendMark.html#noBackends.t,untyped, template noBackends(backends: untyped; def) 102 +nim noWeirdBackend _._/private/backendMark.html#noWeirdBackend.t template noWeirdBackend(def) 107 +nim noBackend _._/private/backendMark.html#noBackend.t,untyped, template noBackend(backends: untyped; def) 117 diff --git a/Lib/_._/private/encoding_norm.html b/Lib/_._/private/encoding_norm.html new file mode 100644 index 000000000..000057cf4 --- /dev/null +++ b/Lib/_._/private/encoding_norm.html @@ -0,0 +1,131 @@ + + + + + + + +src/pylib/private/encoding_norm + + + + + + + + + + + + + + + + +
+
+

src/pylib/private/encoding_norm

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Procs

+
+
+
+
proc encodings.normalize_encoding(encoding: string): string {....raises: [],
+    tags: [], forbids: [].}
+
+ +

Normalize an encoding name.

+

Normalization works as follows: all non-alphanumeric characters except the dot used for Python package names are collapsed and replaced with a single underscore, e.g. ' -;#' becomes '_'. Leading and trailing underscores are removed.

+

Note that encoding names should be ASCII only.

+ + Source   +Edit   + +
+
+ +
+
+
+
proc Py_normalize_encoding(encoding: string): string {....raises: [], tags: [],
+    forbids: [].}
+
+ + Normalize an encoding name: similar to encodings.normalize_encoding(), but also convert to lowercase. + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/private/encoding_norm.idx b/Lib/_._/private/encoding_norm.idx new file mode 100644 index 000000000..e1124243b --- /dev/null +++ b/Lib/_._/private/encoding_norm.idx @@ -0,0 +1,3 @@ +nimTitle encoding_norm _._/private/encoding_norm.html module src/pylib/private/encoding_norm 0 +nim Py_normalize_encoding _._/private/encoding_norm.html#Py_normalize_encoding,string proc Py_normalize_encoding(encoding: string): string 22 +nim encodings.normalize_encoding _._/private/encoding_norm.html#encodings.normalize_encoding,string proc encodings.normalize_encoding(encoding: string): string 28 diff --git a/Lib/_._/private/inspect_cleandoc.html b/Lib/_._/private/inspect_cleandoc.html new file mode 100644 index 000000000..b94ffd601 --- /dev/null +++ b/Lib/_._/private/inspect_cleandoc.html @@ -0,0 +1,124 @@ + + + + + + + +src/pylib/private/inspect_cleandoc + + + + + + + + + + + + + + + + +
+
+

src/pylib/private/inspect_cleandoc

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
func inspect.cleandoc(doc: openArray[char]): string {....raises: [], tags: [],
+    forbids: [].}
+
+ +

Clean up indentation from docstrings.

+

Any whitespace that can be uniformly removed from the second line onwards is removed.

+
Note: +this is also used as _PyCompile_CleanDoc here. Nim itself will trace the fileno of the file being
+

compiled. no need to keep the leading adn tailing blank lines like Python/compile.c: _PyCompile_CleanDoc does.

+ + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/private/inspect_cleandoc.idx b/Lib/_._/private/inspect_cleandoc.idx new file mode 100644 index 000000000..6181beffc --- /dev/null +++ b/Lib/_._/private/inspect_cleandoc.idx @@ -0,0 +1,2 @@ +nimTitle inspect_cleandoc _._/private/inspect_cleandoc.html module src/pylib/private/inspect_cleandoc 0 +nim inspect.cleandoc _._/private/inspect_cleandoc.html#inspect.cleandoc,openArray[char] proc inspect.cleandoc(doc: openArray[char]): string 21 diff --git a/Lib/_._/private/iph_utils.html b/Lib/_._/private/iph_utils.html new file mode 100644 index 000000000..f3cf75a9a --- /dev/null +++ b/Lib/_._/private/iph_utils.html @@ -0,0 +1,111 @@ + + + + + + + +src/pylib/private/iph_utils + + + + + + + + + + + + + + + + +
+
+

src/pylib/private/iph_utils

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

Macros to protect CRT calls against instant termination when passed an invalid parameter (bpo-23524). IPH stands for Invalid Parameter Handler.

+

CPython/Include/internal/pycore_fileutils.h

+

+
+

Templates

+
+
+
+
template with_Py_SUPPRESS_IPH(body)
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/private/iph_utils.idx b/Lib/_._/private/iph_utils.idx new file mode 100644 index 000000000..5e1ee09a8 --- /dev/null +++ b/Lib/_._/private/iph_utils.idx @@ -0,0 +1,2 @@ +nimTitle iph_utils _._/private/iph_utils.html module src/pylib/private/iph_utils 0 +nim with_Py_SUPPRESS_IPH _._/private/iph_utils.html#with_Py_SUPPRESS_IPH.t template with_Py_SUPPRESS_IPH(body) 33 diff --git a/Lib/_._/private/iterGen.html b/Lib/_._/private/iterGen.html new file mode 100644 index 000000000..a40300276 --- /dev/null +++ b/Lib/_._/private/iterGen.html @@ -0,0 +1,142 @@ + + + + + + + +src/pylib/private/iterGen + + + + + + + + + + + + + + + + +
+
+

src/pylib/private/iterGen

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Macros

+
+
+
+
macro genIter(def)
+
+ +

used as pragma

+

Generates code of non-reentrant iterable, according to an iterator.

+ + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template makeIterable(Typ) {.dirty.}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/private/iterGen.idx b/Lib/_._/private/iterGen.idx new file mode 100644 index 000000000..a584ff567 --- /dev/null +++ b/Lib/_._/private/iterGen.idx @@ -0,0 +1,3 @@ +nimTitle iterGen _._/private/iterGen.html module src/pylib/private/iterGen 0 +nim makeIterable _._/private/iterGen.html#makeIterable.t template makeIterable(Typ) 13 +nim genIter _._/private/iterGen.html#genIter.m macro genIter(def) 17 diff --git a/Lib/_._/private/platform_utils.html b/Lib/_._/private/platform_utils.html new file mode 100644 index 000000000..c8c6af90c --- /dev/null +++ b/Lib/_._/private/platform_utils.html @@ -0,0 +1,162 @@ + + + + + + + +src/pylib/private/platform_utils + + + + + + + + + + + + + + + + +
+
+

src/pylib/private/platform_utils

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Templates

+
+
+
+
template platformAvail(platform; def)
+
+ +

Pragma on procs to generate doc of sth like Availability: Windows.

+

Currently, platform must be something that can be put within defined.

+ + Source   +Edit   + +
+
+ +
+
+
+
template platformAvailWhen(platform; cond: bool; def)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template platformNoJs(def)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template platformUnavail(platform; def)
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/private/platform_utils.idx b/Lib/_._/private/platform_utils.idx new file mode 100644 index 000000000..d1052b23a --- /dev/null +++ b/Lib/_._/private/platform_utils.idx @@ -0,0 +1,5 @@ +nimTitle platform_utils _._/private/platform_utils.html module src/pylib/private/platform_utils 0 +nim platformAvail _._/private/platform_utils.html#platformAvail.t,, template platformAvail(platform; def) 23 +nim platformAvailWhen _._/private/platform_utils.html#platformAvailWhen.t,,bool, template platformAvailWhen(platform; cond: bool; def) 31 +nim platformUnavail _._/private/platform_utils.html#platformUnavail.t,, template platformUnavail(platform; def) 36 +nim platformNoJs _._/private/platform_utils.html#platformNoJs.t template platformNoJs(def) 40 diff --git a/Lib/_._/private/trans_imp.html b/Lib/_._/private/trans_imp.html new file mode 100644 index 000000000..add869d00 --- /dev/null +++ b/Lib/_._/private/trans_imp.html @@ -0,0 +1,109 @@ + + + + + + + +src/pylib/private/trans_imp + + + + + + + + + + + + + + + + +
+
+

src/pylib/private/trans_imp

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

import & export helper

+
+

Macros

+
+
+
+
macro impExp(pre; mods: varargs[untyped])
+
+ + gen: import ./pre/[...mods]; export ...mods + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/private/trans_imp.idx b/Lib/_._/private/trans_imp.idx new file mode 100644 index 000000000..c3dc3bc0f --- /dev/null +++ b/Lib/_._/private/trans_imp.idx @@ -0,0 +1,2 @@ +nimTitle trans_imp _._/private/trans_imp.html module src/pylib/private/trans_imp 0 +nim impExp _._/private/trans_imp.html#impExp.m,,varargs[untyped] macro impExp(pre; mods: varargs[untyped]) 4 diff --git a/Lib/_._/pybool.html b/Lib/_._/pybool.html new file mode 100644 index 000000000..e293e36ff --- /dev/null +++ b/Lib/_._/pybool.html @@ -0,0 +1,553 @@ + + + + + + + +src/pylib/pybool + + + + + + + + + + + + + + + + +
+
+

src/pylib/pybool

+
+ +
+ Source   +Edit   + +
+ +

+ +
+

Types

+
+
+
PyBool = distinct bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Consts

+
+
+
False = false
+
+ + False + Source   +Edit   + +
+
+
+
True = true
+
+ + True + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
func `$`(self: PyBool): string {....raises: [], tags: [], forbids: [].}
+
+ +

alias for repr

+

NOTE: CPython's bool's __str__ is itself not defined, which is inherted from object, which will call obj.__repr__ as fallback. This minics it.

+ + Source   +Edit   + +
+
+ +
+
+
+
func `==`(b: bool; self: PyBool): PyBool {.borrow, ...raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func `==`(self: PyBool; b: bool): PyBool {.borrow, ...raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func `==`(self: PyBool; opyb: PyBool): PyBool {.borrow, ...raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func all[T](iter: Iterable[T]): PyBool
+
+ + Checks if all values in iterable are truthy + Source   +Edit   + +
+
+ +
+
+
+
func `and`(b: bool; self: PyBool): PyBool {.borrow, ...raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func `and`(self: PyBool; b: bool): PyBool {.borrow, ...raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func `and`(self: PyBool; opyb: PyBool): PyBool {.borrow, ...raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func `and`[T](nself, npyb: T): T
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func any[T](iter: Iterable[T]): PyBool
+
+ + Checks if at least one value in iterable is truthy + Source   +Edit   + +
+
+ +
+
+
+
proc bool[T](arg: T): PyBool
+
+ + Alias for pybool + Source   +Edit   + +
+
+ +
+
+
+
func `is`(self: PyBool; opyb: PyBool): PyBool {.borrow, ...raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func `not`(self: PyBool): PyBool {.borrow, ...raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func `not`[T](nself: T): PyBool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func `or`(b: bool; self: PyBool): PyBool {.borrow, ...raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func `or`(self: PyBool; b: bool): PyBool {.borrow, ...raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func `or`(self: PyBool; opyb: PyBool): PyBool {.borrow, ...raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func `or`[T](nself, npyb: T): T
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func repr(self: PyBool): string {....raises: [], tags: [], forbids: [].}
+
+ + Returns "True" or "False" + Source   +Edit   + +
+
+ +
+
+
+
func `xor`(self: PyBool; opyb: PyBool): PyBool {.borrow, ...raises: [], tags: [],
+    forbids: [].}
+
+ + EXT + Source   +Edit   + +
+
+ +
+ +
+
+
+

Converters

+
+
+
+
converter pybool(x: bool): PyBool {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
converter pybool[T](x: T): PyBool
+
+ +

Converts any to PyBool

+

NOTE: In Nim, "implicit converter chain is not support". (See manual.html). Therefore any type can be implicitly converted to PyBool, not bool, which, however, is desired, as if any is convertible to bool, then there'll be ## compile-error for repr(<list>)

+ + Source   +Edit   + +
+
+ +
+
+
+
converter toNimBool(self: PyBool): bool {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template toBool[T](arg: T): bool
+
+ + Converts argument to boolean, checking python-like truthiness. + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/pybool.idx b/Lib/_._/pybool.idx new file mode 100644 index 000000000..b855bab0e --- /dev/null +++ b/Lib/_._/pybool.idx @@ -0,0 +1,33 @@ +nimTitle pybool _._/pybool.html module src/pylib/pybool 0 +nim PyBool _._/pybool.html#PyBool type PyBool 7 +nim True _._/pybool.html#True const True 10 +nim False _._/pybool.html#False const False 11 +nim `==` _._/pybool.html#==,, proc `==`(self: PyBool; opyb: PyBool): PyBool 15 +nim `==` _._/pybool.html#==,,bool proc `==`(self: PyBool; b: bool): PyBool 16 +nim `==` _._/pybool.html#==,bool, proc `==`(b: bool; self: PyBool): PyBool 18 +nim `is` _._/pybool.html#is,, proc `is`(self: PyBool; opyb: PyBool): PyBool 19 +nim `xor` _._/pybool.html#xor,, proc `xor`(self: PyBool; opyb: PyBool): PyBool 20 +nim `not` _._/pybool.html#not proc `not`(self: PyBool): PyBool 21 +nim `and` _._/pybool.html#and,, proc `and`(self: PyBool; opyb: PyBool): PyBool 15 +nim `and` _._/pybool.html#and,,bool proc `and`(self: PyBool; b: bool): PyBool 16 +nim `and` _._/pybool.html#and,bool, proc `and`(b: bool; self: PyBool): PyBool 22 +nim `or` _._/pybool.html#or,, proc `or`(self: PyBool; opyb: PyBool): PyBool 15 +nim `or` _._/pybool.html#or,,bool proc `or`(self: PyBool; b: bool): PyBool 16 +nim `or` _._/pybool.html#or,bool, proc `or`(b: bool; self: PyBool): PyBool 23 +nim repr _._/pybool.html#repr proc repr(self: PyBool): string 25 +nim `$` _._/pybool.html#$ proc `$`(self: PyBool): string 30 +nim toBool _._/pybool.html#toBool.t,T template toBool[T](arg: T): bool 62 +nim toNimBool _._/pybool.html#toNimBool.c converter toNimBool(self: PyBool): bool 92 +nim pybool _._/pybool.html#pybool.c,bool converter pybool(x: bool): PyBool 93 +nim pybool _._/pybool.html#pybool.c,T converter pybool[T](x: T): PyBool 94 +nim `not` _._/pybool.html#not,T proc `not`[T](nself: T): PyBool 104 +nim `and` _._/pybool.html#and,T,T proc `and`[T](nself, npyb: T): T 105 +nim `or` _._/pybool.html#or,T,T proc `or`[T](nself, npyb: T): T 107 +nim bool _._/pybool.html#bool,T proc bool[T](arg: T): PyBool 110 +nim all _._/pybool.html#all,Iterable[T] proc all[T](iter: Iterable[T]): PyBool 112 +nim any _._/pybool.html#any,Iterable[T] proc any[T](iter: Iterable[T]): PyBool 119 +nimgrp == _._/pybool.html#==-procs-all proc 18 +nimgrp and _._/pybool.html#and-procs-all proc 22 +nimgrp not _._/pybool.html#not-procs-all proc 21 +nimgrp or _._/pybool.html#or-procs-all proc 23 +nimgrp pybool _._/pybool.html#pybool-converters-all converter 93 diff --git a/Lib/_._/pybytes/bytesbltins.html b/Lib/_._/pybytes/bytesbltins.html new file mode 100644 index 000000000..e5bd57a46 --- /dev/null +++ b/Lib/_._/pybytes/bytesbltins.html @@ -0,0 +1,154 @@ + + + + + + + +src/pylib/pybytes/bytesbltins + + + + + + + + + + + + + + + + +
+
+

src/pylib/pybytes/bytesbltins

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
proc ord(a: PyBytes): int {....raises: [TypeError], tags: [], forbids: [].}
+
+ + Raises TypeError if len(a) is not 1. + Source   +Edit   + +
+
+ +
+
+
+
func repr(x: PyBytes): string {....raises: [], tags: [], forbids: [].}
+
+ +

Overwites system.repr for PyBytes

+

minics Python's

+ + Source   +Edit   + +
+
+ +
+
+
+
func reversed(s: PyBytes): PyBytes {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/pybytes/bytesbltins.idx b/Lib/_._/pybytes/bytesbltins.idx new file mode 100644 index 000000000..292de28aa --- /dev/null +++ b/Lib/_._/pybytes/bytesbltins.idx @@ -0,0 +1,4 @@ +nimTitle bytesbltins _._/pybytes/bytesbltins.html module src/pylib/pybytes/bytesbltins 0 +nim reversed _._/pybytes/bytesbltins.html#reversed,PyBytes proc reversed(s: PyBytes): PyBytes 7 +nim ord _._/pybytes/bytesbltins.html#ord,PyBytes proc ord(a: PyBytes): int 10 +nim repr _._/pybytes/bytesbltins.html#repr,PyBytes proc repr(x: PyBytes): string 20 diff --git a/Lib/_._/pybytes/bytesimpl.html b/Lib/_._/pybytes/bytesimpl.html new file mode 100644 index 000000000..2b5504663 --- /dev/null +++ b/Lib/_._/pybytes/bytesimpl.html @@ -0,0 +1,697 @@ + + + + + + + +src/pylib/pybytes/bytesimpl + + + + + + + + + + + + + + + + +
+
+

src/pylib/pybytes/bytesimpl

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Types

+
+
+
PyBytes = distinct string
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
func `$`(self: PyBytes): string {.borrow, ...raises: [], tags: [], forbids: [].}
+
+ + to Nim string + Source   +Edit   + +
+
+ +
+
+
+
func `+`(o: char; self: PyBytes): PyBytes {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func `+`(o: string; self: PyBytes): PyBytes {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func `+`(self: PyBytes; o: char): PyBytes {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func `+`(self: PyBytes; o: PyBytes): PyBytes {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func `+`(self: PyBytes; o: string): PyBytes {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func `+=`(mself; s: char) {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func `+=`(mself; s: PyBytes) {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func `+=`(mself; s: string) {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func `==`(self: PyBytes; o: PyBytes): bool {.borrow, ...raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func `@`(self: PyBytes): seq[char] {....raises: [], tags: [], forbids: [].}
+
+ +

EXT.

+

Python has no concept of seq (though has list)

+ + Source   +Edit   + +
+
+ +
+
+
+
func `[]`(self: PyBytes; i: HSlice[int, BackwardsIndex]): PyBytes {....raises: [],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func `[]`(self: PyBytes; i: int): int {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func `[]`(self: PyBytes; i: Slice[int]): PyBytes {....raises: [], tags: [],
+    forbids: [].}
+
+ + EXT. s[1..2] means s[1:3], and the latter is not valid Nim code + Source   +Edit   + +
+
+ +
+
+
+
func byteLen(self: PyBytes): int {....raises: [], tags: [], forbids: [].}
+
+ + EXT. the same as len(self) + Source   +Edit   + +
+
+ +
+
+
+
func bytes(): PyBytes {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func bytes(c: char): PyBytes {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func bytes(nLen: int): PyBytes {....raises: [], tags: [], forbids: [].}
+
+ + null bytes of length nLen (a.k.a. b'\0'*nLen) + Source   +Edit   + +
+
+
+
func bytes(s: openArray[char | uint8]): PyBytes
+
+ +

EXT.

+

Python has no concept of openArray

+ + Source   +Edit   + +
+
+
+
func bytes(s: sink string): PyBytes {.inline, ...raises: [], tags: [], forbids: [].}
+
+ + XXX: Currently no encode and errors params + Source   +Edit   + +
+
+
+
func bytes(self: PyBytes): PyBytes {....raises: [], tags: [], forbids: [].}
+
+ + copy + Source   +Edit   + +
+
+
+
func bytes(x: Iterable[char]): PyBytes
+
+ + EXT. as Python has no char type. + Source   +Edit   + +
+
+
+
func bytes(x: Iterable[SomeInteger]): PyBytes
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func fspath(self: PyBytes): PyBytes {....raises: [], tags: [], forbids: [].}
+
+ + make a PathLike + Source   +Edit   + +
+
+ +
+
+
+
func getChar(self: PyBytes; i: Natural): char {....raises: [], tags: [],
+    forbids: [].}
+
+ + EXT. + Source   +Edit   + +
+
+ +
+
+
+
func getCharPtr(self: PyBytes; i: Natural | BackwardsIndex): ptr char
+
+ + EXT. unstable. used by Lib/array frombytes and tobytes + Source   +Edit   + +
+
+ +
+
+
+
func hasChar(a: PyBytes; o: char): bool {....raises: [], tags: [], forbids: [].}
+
+ + EXT. 'c' in b"asc" is allowed + Source   +Edit   + +
+
+ +
+
+
+
func len(self: PyBytes): int {.borrow, ...raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc substr(self: PyBytes; start, last: int): PyBytes {.borrow, ...raises: [],
+    tags: [], forbids: [].}
+
+ + EXT. byte index + Source   +Edit   + +
+
+
+
proc substr(self: PyBytes; start: int): PyBytes {.borrow, ...raises: [], tags: [],
+    forbids: [].}
+
+ + EXT. byte index + Source   +Edit   + +
+
+ +
+ +
+
+
+

Iterators

+
+
+
+
iterator chars(self: PyBytes): char {....raises: [], tags: [], forbids: [].}
+
+ + EXT. + Source   +Edit   + +
+
+ +
+
+
+
iterator items(self: PyBytes): int {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Converters

+
+
+
+
converter toNimString(self: PyBytes): string {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template `not`(s: PyBytes): bool
+
+ + +

Mimics Python not str -> bool.

"not" for strings, return true if the string is not nil or empty.

+ + Source   +Edit   + +
+
+ +
+
+
+
template `or`(a, b: PyBytes): PyBytes
+
+ + Mimics Python str or str -> str. Returns a if a is not empty, otherwise b (even if it's empty) + Source   +Edit   + +
+
+ +
+
+
+
template pybytes[T](x: T): PyBytes
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/pybytes/bytesimpl.idx b/Lib/_._/pybytes/bytesimpl.idx new file mode 100644 index 000000000..cbdc80bf4 --- /dev/null +++ b/Lib/_._/pybytes/bytesimpl.idx @@ -0,0 +1,44 @@ +nimTitle bytesimpl _._/pybytes/bytesimpl.html module src/pylib/pybytes/bytesimpl 0 +nim PyBytes _._/pybytes/bytesimpl.html#PyBytes type PyBytes 6 +nim bytes _._/pybytes/bytesimpl.html#bytes proc bytes(): PyBytes 8 +nim bytes _._/pybytes/bytesimpl.html#bytes,sinkstring proc bytes(s: sink string): PyBytes 9 +nim bytes _._/pybytes/bytesimpl.html#bytes,openArray[] proc bytes(s: openArray[char | uint8]): PyBytes 12 +nim bytes _._/pybytes/bytesimpl.html#bytes,char proc bytes(c: char): PyBytes 21 +nim bytes _._/pybytes/bytesimpl.html#bytes,int proc bytes(nLen: int): PyBytes 23 +nim getCharPtr _._/pybytes/bytesimpl.html#getCharPtr,, proc getCharPtr(self: PyBytes; i: Natural | BackwardsIndex): ptr char 31 +nim bytes _._/pybytes/bytesimpl.html#bytes,Iterable[SomeInteger] proc bytes(x: Iterable[SomeInteger]): PyBytes 40 +nim bytes _._/pybytes/bytesimpl.html#bytes,Iterable[char] proc bytes(x: Iterable[char]): PyBytes 44 +nim bytes _._/pybytes/bytesimpl.html#bytes_2 proc bytes(self: PyBytes): PyBytes 49 +nim pybytes _._/pybytes/bytesimpl.html#pybytes.t,T template pybytes[T](x: T): PyBytes 51 +nim `$` _._/pybytes/bytesimpl.html#$ proc `$`(self: PyBytes): string 55 +nim fspath _._/pybytes/bytesimpl.html#fspath proc fspath(self: PyBytes): PyBytes 56 +nim toNimString _._/pybytes/bytesimpl.html#toNimString.c converter toNimString(self: PyBytes): string 57 +nim `==` _._/pybytes/bytesimpl.html#==,,PyBytes proc `==`(self: PyBytes; o: PyBytes): bool 61 +nim `+` _._/pybytes/bytesimpl.html#+,,PyBytes proc `+`(self: PyBytes; o: PyBytes): PyBytes 67 +nim `+` _._/pybytes/bytesimpl.html#+,,string proc `+`(self: PyBytes; o: string): PyBytes 68 +nim `+` _._/pybytes/bytesimpl.html#+,,char proc `+`(self: PyBytes; o: char): PyBytes 69 +nim `+` _._/pybytes/bytesimpl.html#+,string, proc `+`(o: string; self: PyBytes): PyBytes 71 +nim `+` _._/pybytes/bytesimpl.html#+,char, proc `+`(o: char; self: PyBytes): PyBytes 72 +nim `+=` _._/pybytes/bytesimpl.html#+=,,PyBytes proc `+=`(mself; s: PyBytes) 74 +nim `+=` _._/pybytes/bytesimpl.html#+=,,char proc `+=`(mself; s: char) 75 +nim `+=` _._/pybytes/bytesimpl.html#+=,,string proc `+=`(mself; s: string) 76 +nim len _._/pybytes/bytesimpl.html#len proc len(self: PyBytes): int 79 +nim byteLen _._/pybytes/bytesimpl.html#byteLen proc byteLen(self: PyBytes): int 80 +nim substr _._/pybytes/bytesimpl.html#substr,,int,int proc substr(self: PyBytes; start, last: int): PyBytes 82 +nim substr _._/pybytes/bytesimpl.html#substr,,int proc substr(self: PyBytes; start: int): PyBytes 83 +nim getChar _._/pybytes/bytesimpl.html#getChar,,Natural proc getChar(self: PyBytes; i: Natural): char 85 +nim hasChar _._/pybytes/bytesimpl.html#hasChar,PyBytes,char proc hasChar(a: PyBytes; o: char): bool 87 +nim `[]` _._/pybytes/bytesimpl.html#[],,int proc `[]`(self: PyBytes; i: int): int 90 +nim `[]` _._/pybytes/bytesimpl.html#[],,Slice[int] proc `[]`(self: PyBytes; i: Slice[int]): PyBytes 94 +nim `[]` _._/pybytes/bytesimpl.html#[],,HSlice[int,BackwardsIndex] proc `[]`(self: PyBytes; i: HSlice[int, BackwardsIndex]): PyBytes 100 +nim chars _._/pybytes/bytesimpl.html#chars.i iterator chars(self: PyBytes): char 103 +nim items _._/pybytes/bytesimpl.html#items.i iterator items(self: PyBytes): int 108 +nim `@` _._/pybytes/bytesimpl.html#@,PyBytes proc `@`(self: PyBytes): seq[char] 112 +nim `or` _._/pybytes/bytesimpl.html#or.t,PyBytes,PyBytes template `or`(a, b: PyBytes): PyBytes 126 +nim `not` _._/pybytes/bytesimpl.html#not.t,PyBytes template `not`(s: PyBytes): bool 131 +nimgrp + _._/pybytes/bytesimpl.html#+-procs-all proc 67 +nimgrp bytes _._/pybytes/bytesimpl.html#bytes-procs-all proc 8 +nimgrp [] _._/pybytes/bytesimpl.html#[]-procs-all proc 90 +nimgrp += _._/pybytes/bytesimpl.html#+=-procs-all proc 74 +nimgrp substr _._/pybytes/bytesimpl.html#substr-procs-all proc 82 +heading Mimics Python not str -> bool. _._/pybytes/bytesimpl.html#mimics-python-not-str-minusgt-booldot Mimics Python not str -> bool. 0 diff --git a/Lib/_._/pyconfig/bootstrap_hash.html b/Lib/_._/pyconfig/bootstrap_hash.html new file mode 100644 index 000000000..57095e8f6 --- /dev/null +++ b/Lib/_._/pyconfig/bootstrap_hash.html @@ -0,0 +1,192 @@ + + + + + + + +src/pylib/pyconfig/bootstrap_hash + + + + + + + + + + + + + + + + +
+
+

src/pylib/pyconfig/bootstrap_hash

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Imports

+
+ util +
+
+
+

Lets

+
+
+
SYS_getrandom {.importc, header: "<sys/syscall.h>".}: clong
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Consts

+
+
+
have_getrandom = true
+
+ + + Source   +Edit   + +
+
+
+
have_getrandom_syscall = true
+
+ + + Source   +Edit   + +
+
+
+
py_getrandom = true
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
proc syscall(n: clong): clong {.importc: "syscall", varargs, header: """#include <unistd.h>
+    #include <sys/syscall.h>""",
+                                ...raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/pyconfig/bootstrap_hash.idx b/Lib/_._/pyconfig/bootstrap_hash.idx new file mode 100644 index 000000000..f4b3af6c9 --- /dev/null +++ b/Lib/_._/pyconfig/bootstrap_hash.idx @@ -0,0 +1,6 @@ +nimTitle bootstrap_hash _._/pyconfig/bootstrap_hash.html module src/pylib/pyconfig/bootstrap_hash 0 +nim have_getrandom _._/pyconfig/bootstrap_hash.html#have_getrandom const have_getrandom 50 +nim have_getrandom_syscall _._/pyconfig/bootstrap_hash.html#have_getrandom_syscall const have_getrandom_syscall 50 +nim SYS_getrandom _._/pyconfig/bootstrap_hash.html#SYS_getrandom let SYS_getrandom 26 +nim syscall _._/pyconfig/bootstrap_hash.html#syscall,clong proc syscall(n: clong): clong 29 +nim py_getrandom _._/pyconfig/bootstrap_hash.html#py_getrandom const py_getrandom 36 diff --git a/Lib/_._/pyconfig/chmods.html b/Lib/_._/pyconfig/chmods.html new file mode 100644 index 000000000..7db5269ca --- /dev/null +++ b/Lib/_._/pyconfig/chmods.html @@ -0,0 +1,156 @@ + + + + + + + +src/pylib/pyconfig/chmods + + + + + + + + + + + + + + + + +
+
+

src/pylib/pyconfig/chmods

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Consts

+
+
+
HAVE_LCHMOD = false
+
+ + + Source   +Edit   + +
+
+
+
HAVEchmod = true
+
+ + + Source   +Edit   + +
+
+
+
HAVEfchmod = true
+
+ + + Source   +Edit   + +
+
+
+
HAVEfchmodat = true
+
+ + + Source   +Edit   + +
+
+
+
HAVEfchmodatRUNTIME = true
+
+ + + Source   +Edit   + +
+
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/pyconfig/chmods.idx b/Lib/_._/pyconfig/chmods.idx new file mode 100644 index 000000000..2b9b728cd --- /dev/null +++ b/Lib/_._/pyconfig/chmods.idx @@ -0,0 +1,6 @@ +nimTitle chmods _._/pyconfig/chmods.html module src/pylib/pyconfig/chmods 0 +nim HAVEchmod _._/pyconfig/chmods.html#HAVEchmod const HAVEchmod 50 +nim HAVEfchmod _._/pyconfig/chmods.html#HAVEfchmod const HAVEfchmod 50 +nim HAVEfchmodat _._/pyconfig/chmods.html#HAVEfchmodat const HAVEfchmodat 50 +nim HAVE_LCHMOD _._/pyconfig/chmods.html#HAVE_LCHMOD const HAVE_LCHMOD 15 +nim HAVEfchmodatRUNTIME _._/pyconfig/chmods.html#HAVEfchmodatRUNTIME const HAVEfchmodatRUNTIME 17 diff --git a/Lib/_._/pyconfig/floats.html b/Lib/_._/pyconfig/floats.html new file mode 100644 index 000000000..8b26570bd --- /dev/null +++ b/Lib/_._/pyconfig/floats.html @@ -0,0 +1,249 @@ + + + + + + + +src/pylib/pyconfig/floats + + + + + + + + + + + + + + + + +
+
+

src/pylib/pyconfig/floats

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

--- HAVE_PY_SET_53BIT_PRECISION macro ------------------------------------Inline assembly for getting and setting the 387 FPU control word on GCC/x86.ifdef _Py_MEMORY_SANITIZERendif

+
+

Imports

+
+ util +
+
+
+

Consts

+
+
+
DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754 = false
+
+ + + Source   +Edit   + +
+
+
+
DOUBLE_IS_BIG_ENDIAN_IEEE754 = false
+
+ + + Source   +Edit   + +
+
+
+
DOUBLE_IS_LITTLE_ENDIAN_IEEE754 = true
+
+ + + Source   +Edit   + +
+
+
+
HAVE_GCC_ASM_FOR_MC68881 = false
+
+ + + Source   +Edit   + +
+
+
+
HAVE_GCC_ASM_FOR_X87 = true
+
+ + + Source   +Edit   + +
+
+
+
X87_double_rounding = false
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Templates

+
+
+
+
template HAVE_PY_SET_53BIT_PRECISION(): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template Py_SET_53BIT_PRECISION_END()
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template Py_SET_53BIT_PRECISION_HEADER() {.dirty.}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template Py_SET_53BIT_PRECISION_START()
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/pyconfig/floats.idx b/Lib/_._/pyconfig/floats.idx new file mode 100644 index 000000000..e3320530c --- /dev/null +++ b/Lib/_._/pyconfig/floats.idx @@ -0,0 +1,11 @@ +nimTitle floats _._/pyconfig/floats.html module src/pylib/pyconfig/floats 0 +nim X87_double_rounding _._/pyconfig/floats.html#X87_double_rounding const X87_double_rounding 50 +nim HAVE_GCC_ASM_FOR_X87 _._/pyconfig/floats.html#HAVE_GCC_ASM_FOR_X87 const HAVE_GCC_ASM_FOR_X87 50 +nim HAVE_GCC_ASM_FOR_MC68881 _._/pyconfig/floats.html#HAVE_GCC_ASM_FOR_MC68881 const HAVE_GCC_ASM_FOR_MC68881 50 +nim HAVE_PY_SET_53BIT_PRECISION _._/pyconfig/floats.html#HAVE_PY_SET_53BIT_PRECISION.t template HAVE_PY_SET_53BIT_PRECISION(): bool 85 +nim Py_SET_53BIT_PRECISION_HEADER _._/pyconfig/floats.html#Py_SET_53BIT_PRECISION_HEADER.t template Py_SET_53BIT_PRECISION_HEADER() 104 +nim Py_SET_53BIT_PRECISION_START _._/pyconfig/floats.html#Py_SET_53BIT_PRECISION_START.t template Py_SET_53BIT_PRECISION_START() 107 +nim Py_SET_53BIT_PRECISION_END _._/pyconfig/floats.html#Py_SET_53BIT_PRECISION_END.t template Py_SET_53BIT_PRECISION_END() 112 +nim DOUBLE_IS_BIG_ENDIAN_IEEE754 _._/pyconfig/floats.html#DOUBLE_IS_BIG_ENDIAN_IEEE754 const DOUBLE_IS_BIG_ENDIAN_IEEE754 201 +nim DOUBLE_IS_LITTLE_ENDIAN_IEEE754 _._/pyconfig/floats.html#DOUBLE_IS_LITTLE_ENDIAN_IEEE754 const DOUBLE_IS_LITTLE_ENDIAN_IEEE754 201 +nim DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754 _._/pyconfig/floats.html#DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754 const DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754 201 diff --git a/Lib/_._/pyconfig/have_x_runtime.html b/Lib/_._/pyconfig/have_x_runtime.html new file mode 100644 index 000000000..8e3a50a0f --- /dev/null +++ b/Lib/_._/pyconfig/have_x_runtime.html @@ -0,0 +1,109 @@ + + + + + + + +src/pylib/pyconfig/have_x_runtime + + + + + + + + + + + + + + + + +
+
+

src/pylib/pyconfig/have_x_runtime

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Templates

+
+
+
+
template check_func_runtime(fn; versionsOfApple: varargs[untyped])
+
+ + export const HAVEfn_RUNTIME + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/pyconfig/have_x_runtime.idx b/Lib/_._/pyconfig/have_x_runtime.idx new file mode 100644 index 000000000..1527077d5 --- /dev/null +++ b/Lib/_._/pyconfig/have_x_runtime.idx @@ -0,0 +1,2 @@ +nimTitle have_x_runtime _._/pyconfig/have_x_runtime.html module src/pylib/pyconfig/have_x_runtime 0 +nim check_func_runtime _._/pyconfig/have_x_runtime.html#check_func_runtime.t,,varargs[untyped] template check_func_runtime(fn; versionsOfApple: varargs[untyped]) 15 diff --git a/Lib/_._/pyconfig/os.html b/Lib/_._/pyconfig/os.html new file mode 100644 index 000000000..ae63d557b --- /dev/null +++ b/Lib/_._/pyconfig/os.html @@ -0,0 +1,257 @@ + + + + + + + +src/pylib/pyconfig/os + + + + + + + + + + + + + + + + +
+
+

src/pylib/pyconfig/os

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Lets

+
+
+
AT_REMOVEDIR {.importc, header: "<fcntl.h>".}: cint
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Consts

+
+ +
+
DEFAULT_DIR_FD = -100
+
+ + + Source   +Edit   + +
+
+
+
HAVE_FTRUNCATE = true
+
+ + + Source   +Edit   + +
+
+
+
HAVE_OPENAT = true
+
+ + + Source   +Edit   + +
+
+
+
HAVEfdopendir = true
+
+ + + Source   +Edit   + +
+
+
+
HAVEfdopendirRUNTIME = true
+
+ + + Source   +Edit   + +
+
+
+
HAVEuname = true
+
+ + + Source   +Edit   + +
+
+
+
HAVEunlinkat = true
+
+ + + Source   +Edit   + +
+
+
+
HAVEunlinkatRUNTIME = true
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
proc unlinkat(dir_fd: cint; path: cstring; flag: cint): cint {.importc,
+    header: "<unistd.h>", ...raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/pyconfig/os.idx b/Lib/_._/pyconfig/os.idx new file mode 100644 index 000000000..c2f660dfc --- /dev/null +++ b/Lib/_._/pyconfig/os.idx @@ -0,0 +1,12 @@ +nimTitle os _._/pyconfig/os.html module src/pylib/pyconfig/os 0 +nim DEFAULT_DIR_FD _._/pyconfig/os.html#DEFAULT_DIR_FD const DEFAULT_DIR_FD 5 +nim AT_SYMLINK_NOFOLLOW _._/pyconfig/os.html#AT_SYMLINK_NOFOLLOW const AT_SYMLINK_NOFOLLOW 6 +nim HAVE_OPENAT _._/pyconfig/os.html#HAVE_OPENAT const HAVE_OPENAT 8 +nim HAVE_FTRUNCATE _._/pyconfig/os.html#HAVE_FTRUNCATE const HAVE_FTRUNCATE 9 +nim HAVEuname _._/pyconfig/os.html#HAVEuname const HAVEuname 50 +nim HAVEunlinkat _._/pyconfig/os.html#HAVEunlinkat const HAVEunlinkat 50 +nim HAVEfdopendir _._/pyconfig/os.html#HAVEfdopendir const HAVEfdopendir 50 +nim HAVEunlinkatRUNTIME _._/pyconfig/os.html#HAVEunlinkatRUNTIME const HAVEunlinkatRUNTIME 17 +nim HAVEfdopendirRUNTIME _._/pyconfig/os.html#HAVEfdopendirRUNTIME const HAVEfdopendirRUNTIME 17 +nim unlinkat _._/pyconfig/os.html#unlinkat,cint,cstring,cint proc unlinkat(dir_fd: cint; path: cstring; flag: cint): cint 21 +nim AT_REMOVEDIR _._/pyconfig/os.html#AT_REMOVEDIR let AT_REMOVEDIR 23 diff --git a/Lib/_._/pyconfig/os_consts.html b/Lib/_._/pyconfig/os_consts.html new file mode 100644 index 000000000..5cd1da1c3 --- /dev/null +++ b/Lib/_._/pyconfig/os_consts.html @@ -0,0 +1,178 @@ + + + + + + + +src/pylib/pyconfig/os_consts + + + + + + + + + + + + + + + + +
+
+

src/pylib/pyconfig/os_consts

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Imports

+
+ util +
+
+
+

Consts

+
+
+
O_ASYNC = 8192'i32
+
+ + + Source   +Edit   + +
+
+
+
O_DIRECT = 16384'i32
+
+ + + Source   +Edit   + +
+
+
+
O_DIRECTORY = 65536'i32
+
+ + + Source   +Edit   + +
+
+
+
O_NOATIME = 262144'i32
+
+ + + Source   +Edit   + +
+
+
+
O_NOFOLLOW = 131072'i32
+
+ + + Source   +Edit   + +
+
+
+
O_PATH = 2097152'i32
+
+ + + Source   +Edit   + +
+
+
+
O_TMPFILE = 4259840'i32
+
+ + + Source   +Edit   + +
+
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/pyconfig/os_consts.idx b/Lib/_._/pyconfig/os_consts.idx new file mode 100644 index 000000000..eff836db9 --- /dev/null +++ b/Lib/_._/pyconfig/os_consts.idx @@ -0,0 +1,8 @@ +nimTitle os_consts _._/pyconfig/os_consts.html module src/pylib/pyconfig/os_consts 0 +nim O_ASYNC _._/pyconfig/os_consts.html#O_ASYNC const O_ASYNC 7 +nim O_DIRECT _._/pyconfig/os_consts.html#O_DIRECT const O_DIRECT 7 +nim O_DIRECTORY _._/pyconfig/os_consts.html#O_DIRECTORY const O_DIRECTORY 7 +nim O_NOFOLLOW _._/pyconfig/os_consts.html#O_NOFOLLOW const O_NOFOLLOW 7 +nim O_NOATIME _._/pyconfig/os_consts.html#O_NOATIME const O_NOATIME 7 +nim O_PATH _._/pyconfig/os_consts.html#O_PATH const O_PATH 7 +nim O_TMPFILE _._/pyconfig/os_consts.html#O_TMPFILE const O_TMPFILE 7 diff --git a/Lib/_._/pyconfig/pycore/pymath.html b/Lib/_._/pyconfig/pycore/pymath.html new file mode 100644 index 000000000..3694d54d5 --- /dev/null +++ b/Lib/_._/pyconfig/pycore/pymath.html @@ -0,0 +1,96 @@ + + + + + + + +src/pylib/pyconfig/pycore/pymath + + + + + + + + + + + + + + + + +
+
+

src/pylib/pyconfig/pycore/pymath

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

Py_ADJUST_ERANGE1 and Py_ADJUST_ERANGE2 are defined in pylib/builtins/private/pycore_pymath.nim as they're only required but complex-about routinues

+ + + +
+
+ + +
+
+ + + diff --git a/Lib/_._/pyconfig/pycore/pymath.idx b/Lib/_._/pyconfig/pycore/pymath.idx new file mode 100644 index 000000000..c73665d07 --- /dev/null +++ b/Lib/_._/pyconfig/pycore/pymath.idx @@ -0,0 +1 @@ +nimTitle pymath _._/pyconfig/pycore/pymath.html module src/pylib/pyconfig/pycore/pymath 0 diff --git a/Lib/_._/pyconfig/pycore/pymath/short_float_repr.html b/Lib/_._/pyconfig/pycore/pymath/short_float_repr.html new file mode 100644 index 000000000..d629a48a9 --- /dev/null +++ b/Lib/_._/pyconfig/pycore/pymath/short_float_repr.html @@ -0,0 +1,132 @@ + + + + + + + +src/pylib/pyconfig/pycore/pymath/short_float_repr + + + + + + + + + + + + + + + + +
+
+

src/pylib/pyconfig/pycore/pymath/short_float_repr

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

ref https://nim-lang.org/docs/manual.html#types-preminusdefined-floatingminuspoint-types Nim's float XX shall always follows IEEE754 --- _PY_SHORT_FLOAT_REPR macro -------------------------------------------

+ +
+

Consts

+
+
+
WORDS_BIGENDIAN = false
+
+ + + Source   +Edit   + +
+
+
+
WORDS_LITTLEENDIAN = true
+
+ + + Source   +Edit   + +
+
+ +
+
+ + +
+
+ + +
+
+ + + diff --git a/Lib/_._/pyconfig/pycore/pymath/short_float_repr.idx b/Lib/_._/pyconfig/pycore/pymath/short_float_repr.idx new file mode 100644 index 000000000..e70c1c5f6 --- /dev/null +++ b/Lib/_._/pyconfig/pycore/pymath/short_float_repr.idx @@ -0,0 +1,3 @@ +nimTitle short_float_repr _._/pyconfig/pycore/pymath/short_float_repr.html module src/pylib/pyconfig/pycore/pymath/short_float_repr 0 +nim WORDS_BIGENDIAN _._/pyconfig/pycore/pymath/short_float_repr.html#WORDS_BIGENDIAN const WORDS_BIGENDIAN 9 +nim WORDS_LITTLEENDIAN _._/pyconfig/pycore/pymath/short_float_repr.html#WORDS_LITTLEENDIAN const WORDS_LITTLEENDIAN 10 diff --git a/Lib/_._/pyconfig/resource.html b/Lib/_._/pyconfig/resource.html new file mode 100644 index 000000000..b6297660d --- /dev/null +++ b/Lib/_._/pyconfig/resource.html @@ -0,0 +1,167 @@ + + + + + + + +src/pylib/pyconfig/resource + + + + + + + + + + + + + + + + +
+
+

src/pylib/pyconfig/resource

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Imports

+
+ util +
+
+
+

Consts

+
+
+
HAVE_GETPAGESIZE = true
+
+ + + Source   +Edit   + +
+
+
+
HAVE_PRLIMIT = true
+
+ + + Source   +Edit   + +
+
+
+
HAVE_SYSCONF_PAGE_SIZE = false
+
+ + + Source   +Edit   + +
+
+
+
RUSAGE_BOTH = -9223372036854775808
+
+ + + Source   +Edit   + +
+
+
+
RUSAGE_THREAD = 1
+
+ + + Source   +Edit   + +
+
+
+
SIZEOF_RLIMIT_T = 8
+
+ + + Source   +Edit   + +
+
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/pyconfig/resource.idx b/Lib/_._/pyconfig/resource.idx new file mode 100644 index 000000000..703dc3267 --- /dev/null +++ b/Lib/_._/pyconfig/resource.idx @@ -0,0 +1,7 @@ +nimTitle resource _._/pyconfig/resource.html module src/pylib/pyconfig/resource 0 +nim RUSAGE_BOTH _._/pyconfig/resource.html#RUSAGE_BOTH const RUSAGE_BOTH 5 +nim RUSAGE_THREAD _._/pyconfig/resource.html#RUSAGE_THREAD const RUSAGE_THREAD 6 +nim SIZEOF_RLIMIT_T _._/pyconfig/resource.html#SIZEOF_RLIMIT_T const SIZEOF_RLIMIT_T 8 +nim HAVE_PRLIMIT _._/pyconfig/resource.html#HAVE_PRLIMIT const HAVE_PRLIMIT 50 +nim HAVE_GETPAGESIZE _._/pyconfig/resource.html#HAVE_GETPAGESIZE const HAVE_GETPAGESIZE 50 +nim HAVE_SYSCONF_PAGE_SIZE _._/pyconfig/resource.html#HAVE_SYSCONF_PAGE_SIZE const HAVE_SYSCONF_PAGE_SIZE 50 diff --git a/Lib/_._/pyconfig/sched.html b/Lib/_._/pyconfig/sched.html new file mode 100644 index 000000000..e182f14bf --- /dev/null +++ b/Lib/_._/pyconfig/sched.html @@ -0,0 +1,123 @@ + + + + + + + +src/pylib/pyconfig/sched + + + + + + + + + + + + + + + + +
+
+

src/pylib/pyconfig/sched

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Imports

+
+ util +
+
+
+

Consts

+
+
+
HAVE_sched_h = false
+
+ + + Source   +Edit   + +
+
+
+
HAVE_sched_setaffinity = false
+
+ + + Source   +Edit   + +
+
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/pyconfig/sched.idx b/Lib/_._/pyconfig/sched.idx new file mode 100644 index 000000000..631c65af1 --- /dev/null +++ b/Lib/_._/pyconfig/sched.idx @@ -0,0 +1,3 @@ +nimTitle sched _._/pyconfig/sched.html module src/pylib/pyconfig/sched 0 +nim HAVE_sched_h _._/pyconfig/sched.html#HAVE_sched_h const HAVE_sched_h 50 +nim HAVE_sched_setaffinity _._/pyconfig/sched.html#HAVE_sched_setaffinity const HAVE_sched_setaffinity 4 diff --git a/Lib/_._/pyconfig/signal.html b/Lib/_._/pyconfig/signal.html new file mode 100644 index 000000000..a431e32cc --- /dev/null +++ b/Lib/_._/pyconfig/signal.html @@ -0,0 +1,376 @@ + + + + + + + +src/pylib/pyconfig/signal + + + + + + + + + + + + + + + + +
+
+

src/pylib/pyconfig/signal

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Imports

+
+ util +
+
+
+

Consts

+
+
+
DEF_SIG = -1
+
+ + CPython checks SIG* in [0, NSIG) + Source   +Edit   + +
+
+
+
HAVEalarm = true
+
+ + + Source   +Edit   + +
+
+
+
HAVEgetitimer = true
+
+ + + Source   +Edit   + +
+
+
+
HAVEpause = true
+
+ + + Source   +Edit   + +
+
+
+
HAVEpthread_kill = true
+
+ + + Source   +Edit   + +
+
+
+
HAVEpthread_sigmask = true
+
+ + + Source   +Edit   + +
+
+
+
HAVEsetitimer = true
+
+ + + Source   +Edit   + +
+
+
+
HAVEsigaction = true
+
+ + + Source   +Edit   + +
+
+
+
HAVEsigfillset = true
+
+ + + Source   +Edit   + +
+
+
+
HAVEsiginterrupt = true
+
+ + + Source   +Edit   + +
+
+
+
HAVEsigpending = true
+
+ + + Source   +Edit   + +
+
+
+
HAVEsigtimedwait = true
+
+ + + Source   +Edit   + +
+
+
+
HAVEsigwait = true
+
+ + + Source   +Edit   + +
+
+
+
HAVEsigwaitinfo = true
+
+ + + Source   +Edit   + +
+
+
+
HAVEstrsignal = true
+
+ + + Source   +Edit   + +
+
+
+
Py_NSIG = 65
+
+ + + Source   +Edit   + +
+
+
+
SIGCLD = 17
+
+ + + Source   +Edit   + +
+
+
+
SIGEMT = -1
+
+ + + Source   +Edit   + +
+
+
+
SIGIO = 29
+
+ + + Source   +Edit   + +
+
+
+
SIGIOT = 6
+
+ + + Source   +Edit   + +
+
+
+
SIGPWR = 30
+
+ + + Source   +Edit   + +
+
+
+
SIGRTMAX = 64
+
+ + + Source   +Edit   + +
+
+
+
SIGRTMIN = 34
+
+ + + Source   +Edit   + +
+
+
+
SIGSTKFLT = 16
+
+ + + Source   +Edit   + +
+
+
+
SIGWINCH = 28
+
+ + + Source   +Edit   + +
+
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/pyconfig/signal.idx b/Lib/_._/pyconfig/signal.idx new file mode 100644 index 000000000..ef3848c69 --- /dev/null +++ b/Lib/_._/pyconfig/signal.idx @@ -0,0 +1,26 @@ +nimTitle signal _._/pyconfig/signal.html module src/pylib/pyconfig/signal 0 +nim Py_NSIG _._/pyconfig/signal.html#Py_NSIG const Py_NSIG 3 +nim HAVEstrsignal _._/pyconfig/signal.html#HAVEstrsignal const HAVEstrsignal 50 +nim HAVEpthread_kill _._/pyconfig/signal.html#HAVEpthread_kill const HAVEpthread_kill 50 +nim HAVEalarm _._/pyconfig/signal.html#HAVEalarm const HAVEalarm 50 +nim HAVEpause _._/pyconfig/signal.html#HAVEpause const HAVEpause 50 +nim HAVEgetitimer _._/pyconfig/signal.html#HAVEgetitimer const HAVEgetitimer 50 +nim HAVEsetitimer _._/pyconfig/signal.html#HAVEsetitimer const HAVEsetitimer 50 +nim HAVEsigaction _._/pyconfig/signal.html#HAVEsigaction const HAVEsigaction 50 +nim HAVEsigfillset _._/pyconfig/signal.html#HAVEsigfillset const HAVEsigfillset 50 +nim HAVEsiginterrupt _._/pyconfig/signal.html#HAVEsiginterrupt const HAVEsiginterrupt 50 +nim HAVEsigpending _._/pyconfig/signal.html#HAVEsigpending const HAVEsigpending 50 +nim HAVEsigtimedwait _._/pyconfig/signal.html#HAVEsigtimedwait const HAVEsigtimedwait 50 +nim HAVEsigwait _._/pyconfig/signal.html#HAVEsigwait const HAVEsigwait 50 +nim HAVEsigwaitinfo _._/pyconfig/signal.html#HAVEsigwaitinfo const HAVEsigwaitinfo 50 +nim HAVEpthread_sigmask _._/pyconfig/signal.html#HAVEpthread_sigmask const HAVEpthread_sigmask 50 +nim DEF_SIG _._/pyconfig/signal.html#DEF_SIG const DEF_SIG 35 +nim SIGIOT _._/pyconfig/signal.html#SIGIOT const SIGIOT 38 +nim SIGEMT _._/pyconfig/signal.html#SIGEMT const SIGEMT 38 +nim SIGCLD _._/pyconfig/signal.html#SIGCLD const SIGCLD 38 +nim SIGPWR _._/pyconfig/signal.html#SIGPWR const SIGPWR 38 +nim SIGIO _._/pyconfig/signal.html#SIGIO const SIGIO 38 +nim SIGWINCH _._/pyconfig/signal.html#SIGWINCH const SIGWINCH 38 +nim SIGRTMIN _._/pyconfig/signal.html#SIGRTMIN const SIGRTMIN 38 +nim SIGRTMAX _._/pyconfig/signal.html#SIGRTMAX const SIGRTMAX 38 +nim SIGSTKFLT _._/pyconfig/signal.html#SIGSTKFLT const SIGSTKFLT 38 diff --git a/Lib/_._/pyconfig/stats.html b/Lib/_._/pyconfig/stats.html new file mode 100644 index 000000000..4b0bd2359 --- /dev/null +++ b/Lib/_._/pyconfig/stats.html @@ -0,0 +1,134 @@ + + + + + + + +src/pylib/pyconfig/stats + + + + + + + + + + + + + + + + +
+
+

src/pylib/pyconfig/stats

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Consts

+
+
+
HAVEfstatat = true
+
+ + + Source   +Edit   + +
+
+
+
HAVEfstatatRUNTIME = true
+
+ + + Source   +Edit   + +
+
+
+
HAVElstat = true
+
+ + + Source   +Edit   + +
+
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/pyconfig/stats.idx b/Lib/_._/pyconfig/stats.idx new file mode 100644 index 000000000..31f09796c --- /dev/null +++ b/Lib/_._/pyconfig/stats.idx @@ -0,0 +1,4 @@ +nimTitle stats _._/pyconfig/stats.html module src/pylib/pyconfig/stats 0 +nim HAVElstat _._/pyconfig/stats.html#HAVElstat const HAVElstat 50 +nim HAVEfstatat _._/pyconfig/stats.html#HAVEfstatat const HAVEfstatat 50 +nim HAVEfstatatRUNTIME _._/pyconfig/stats.html#HAVEfstatatRUNTIME const HAVEfstatatRUNTIME 17 diff --git a/Lib/_._/pyconfig/util.html b/Lib/_._/pyconfig/util.html new file mode 100644 index 000000000..623e63da2 --- /dev/null +++ b/Lib/_._/pyconfig/util.html @@ -0,0 +1,378 @@ + + + + + + + +src/pylib/pyconfig/util + + + + + + + + + + + + + + + + +
+
+

src/pylib/pyconfig/util

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Macros

+
+
+
+
macro AC_CHECK_FUNCS(xs: varargs[untyped]): untyped
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
macro AC_CHECK_HEADER(header)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
macro AC_CHECK_HEADER_THEN_FUNCS(header; functions)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
macro AC_CHECK_HEADERS(xs: varargs[untyped]): untyped
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
macro from_c_int_expr(cExpr: static[string]; defval: int): int
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
macro from_c_int_underlined(variable: static[string]; defval: int): int
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template AC_CHECK_FUNC(function)
+
+ + + Source   +Edit   + +
+
+
+
template AC_CHECK_FUNC(res, function)
+
+ + export const HAVEfunction + Source   +Edit   + +
+
+ +
+
+
+
template AC_CHECK_HEADER(res, header)
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
template AC_RUN_IFELSE(variable, defval, code)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template AX_C_FLOAT_WORDS_BIGENDIAN(id; doIfTrue, doIfFalse, doIfUnknown) {.
+    dirty.}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template AX_C_FLOAT_WORDS_BIGENDIAN_def(defIfTrue, defIfFalse, doIfUnknown)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template c_defined(variable; c_macro: string; headers: openArray = [])
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template from_c_int(variable; defval: int; precode): int
+
+ + + Source   +Edit   + +
+
+
+
template from_c_int(variable; defvar: int): int
+
+ + + Source   +Edit   + +
+
+
+
template from_c_int(variable; includeFile: static[string]; defval = low(int)): int
+
+ + we know int.low is smaller than low(cint) + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/pyconfig/util.idx b/Lib/_._/pyconfig/util.idx new file mode 100644 index 000000000..a03e5a29a --- /dev/null +++ b/Lib/_._/pyconfig/util.idx @@ -0,0 +1,20 @@ +nimTitle util _._/pyconfig/util.html module src/pylib/pyconfig/util 0 +nim from_c_int _._/pyconfig/util.html#from_c_int.t,,int, template from_c_int(variable; defval: int; precode): int 62 +nim from_c_int_underlined _._/pyconfig/util.html#from_c_int_underlined.m,static[string],int macro from_c_int_underlined(variable: static[string]; defval: int): int 75 +nim from_c_int_expr _._/pyconfig/util.html#from_c_int_expr.m,static[string],int macro from_c_int_expr(cExpr: static[string]; defval: int): int 79 +nim from_c_int _._/pyconfig/util.html#from_c_int.t,,static[string] template from_c_int(variable; includeFile: static[string]; defval = low(int)): int 98 +nim from_c_int _._/pyconfig/util.html#from_c_int.t,,int template from_c_int(variable; defvar: int): int 106 +nim AC_LINK_IFELSE _._/pyconfig/util.html#AC_LINK_IFELSE.t,,, template AC_LINK_IFELSE(variable, defval, code) 110 +nim AC_RUN_IFELSE _._/pyconfig/util.html#AC_RUN_IFELSE.t,,, template AC_RUN_IFELSE(variable, defval, code) 111 +nim AX_C_FLOAT_WORDS_BIGENDIAN _._/pyconfig/util.html#AX_C_FLOAT_WORDS_BIGENDIAN.t,,,, template AX_C_FLOAT_WORDS_BIGENDIAN(id; doIfTrue, doIfFalse, doIfUnknown) 114 +nim AX_C_FLOAT_WORDS_BIGENDIAN_def _._/pyconfig/util.html#AX_C_FLOAT_WORDS_BIGENDIAN_def.t,,, template AX_C_FLOAT_WORDS_BIGENDIAN_def(defIfTrue, defIfFalse, doIfUnknown) 143 +nim c_defined _._/pyconfig/util.html#c_defined.t,,string,openArray template c_defined(variable; c_macro: string; headers: openArray = []) 149 +nim AC_CHECK_FUNC _._/pyconfig/util.html#AC_CHECK_FUNC.t,, template AC_CHECK_FUNC(res, function) 187 +nim AC_CHECK_FUNC _._/pyconfig/util.html#AC_CHECK_FUNC.t template AC_CHECK_FUNC(function) 206 +nim AC_CHECK_FUNCS _._/pyconfig/util.html#AC_CHECK_FUNCS.m,varargs[untyped] macro AC_CHECK_FUNCS(xs: varargs[untyped]): untyped 206 +nim AC_CHECK_HEADER _._/pyconfig/util.html#AC_CHECK_HEADER.t,, template AC_CHECK_HEADER(res, header) 209 +nim AC_CHECK_HEADER _._/pyconfig/util.html#AC_CHECK_HEADER.m macro AC_CHECK_HEADER(header) 219 +nim AC_CHECK_HEADERS _._/pyconfig/util.html#AC_CHECK_HEADERS.m,varargs[untyped] macro AC_CHECK_HEADERS(xs: varargs[untyped]): untyped 219 +nim AC_CHECK_HEADER_THEN_FUNCS _._/pyconfig/util.html#AC_CHECK_HEADER_THEN_FUNCS.m,, macro AC_CHECK_HEADER_THEN_FUNCS(header; functions) 229 +nimgrp Accheckfunc _._/pyconfig/util.html#AC_CHECK_FUNC-templates-all template 187 +nimgrp fromcint _._/pyconfig/util.html#from_c_int-templates-all template 62 diff --git a/Lib/_._/pyconfig/ver.html b/Lib/_._/pyconfig/ver.html new file mode 100644 index 000000000..674f90307 --- /dev/null +++ b/Lib/_._/pyconfig/ver.html @@ -0,0 +1,103 @@ + + + + + + + +src/pylib/pyconfig/ver + + + + + + + + + + + + + + + + +
+
+

src/pylib/pyconfig/ver

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Consts

+
+
+
ANDROID_API = 0
+
+ + + Source   +Edit   + +
+
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/pyconfig/ver.idx b/Lib/_._/pyconfig/ver.idx new file mode 100644 index 000000000..ab63abfb2 --- /dev/null +++ b/Lib/_._/pyconfig/ver.idx @@ -0,0 +1,2 @@ +nimTitle ver _._/pyconfig/ver.html module src/pylib/pyconfig/ver 0 +nim ANDROID_API _._/pyconfig/ver.html#ANDROID_API const ANDROID_API 7 diff --git a/Lib/_._/pyerrors.html b/Lib/_._/pyerrors.html new file mode 100644 index 000000000..0e139147c --- /dev/null +++ b/Lib/_._/pyerrors.html @@ -0,0 +1,96 @@ + + + + + + + +src/pylib/pyerrors + + + + + + + + + + + + + + + + +
+
+

src/pylib/pyerrors

+ + + +
+
+ + + diff --git a/Lib/_._/pyerrors.idx b/Lib/_._/pyerrors.idx new file mode 100644 index 000000000..9eb9b970d --- /dev/null +++ b/Lib/_._/pyerrors.idx @@ -0,0 +1 @@ +nimTitle pyerrors _._/pyerrors.html module src/pylib/pyerrors 0 diff --git a/Lib/_._/pyerrors/aritherr.html b/Lib/_._/pyerrors/aritherr.html new file mode 100644 index 000000000..67acf69ae --- /dev/null +++ b/Lib/_._/pyerrors/aritherr.html @@ -0,0 +1,114 @@ + + + + + + + +src/pylib/pyerrors/aritherr + + + + + + + + + + + + + + + + +
+
+

src/pylib/pyerrors/aritherr

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Types

+
+
+
ArithmeticError = object of CatchableError
+
+ + + Source   +Edit   + +
+
+
+
ZeroDivisionError = object of ArithmeticError
+
+ + + Source   +Edit   + +
+
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/pyerrors/aritherr.idx b/Lib/_._/pyerrors/aritherr.idx new file mode 100644 index 000000000..e630d878b --- /dev/null +++ b/Lib/_._/pyerrors/aritherr.idx @@ -0,0 +1,3 @@ +nimTitle aritherr _._/pyerrors/aritherr.html module src/pylib/pyerrors/aritherr 0 +nim ArithmeticError _._/pyerrors/aritherr.html#ArithmeticError object ArithmeticError 3 +nim ZeroDivisionError _._/pyerrors/aritherr.html#ZeroDivisionError object ZeroDivisionError 4 diff --git a/Lib/_._/pyerrors/errno.html b/Lib/_._/pyerrors/errno.html new file mode 100644 index 000000000..3fcb6c92c --- /dev/null +++ b/Lib/_._/pyerrors/errno.html @@ -0,0 +1,75 @@ + + + + + + + +src/pylib/pyerrors/errno + + + + + + + + + + + + + + + + +
+
+

src/pylib/pyerrors/errno

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ +
+
+ Source   +Edit   + +
+ +

+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/pyerrors/errno.idx b/Lib/_._/pyerrors/errno.idx new file mode 100644 index 000000000..464614620 --- /dev/null +++ b/Lib/_._/pyerrors/errno.idx @@ -0,0 +1 @@ +nimTitle errno _._/pyerrors/errno.html module src/pylib/pyerrors/errno 0 diff --git a/Lib/_._/pyerrors/lkuperr.html b/Lib/_._/pyerrors/lkuperr.html new file mode 100644 index 000000000..62739ffcc --- /dev/null +++ b/Lib/_._/pyerrors/lkuperr.html @@ -0,0 +1,106 @@ + + + + + + + +src/pylib/pyerrors/lkuperr + + + + + + + + + + + + + + + + +
+
+

src/pylib/pyerrors/lkuperr

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Types

+
+
+
LookupError = object of CatchableError
+
+ +
Warning: +Python's KeyError inherits LookupError,
+

but Nim's doesn't, but inherits ValueError instead.

+ + Source   +Edit   + +
+
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/pyerrors/lkuperr.idx b/Lib/_._/pyerrors/lkuperr.idx new file mode 100644 index 000000000..44582b7f4 --- /dev/null +++ b/Lib/_._/pyerrors/lkuperr.idx @@ -0,0 +1,2 @@ +nimTitle lkuperr _._/pyerrors/lkuperr.html module src/pylib/pyerrors/lkuperr 0 +nim LookupError _._/pyerrors/lkuperr.html#LookupError object LookupError 3 diff --git a/Lib/_._/pyerrors/oserr.html b/Lib/_._/pyerrors/oserr.html new file mode 100644 index 000000000..a0694918a --- /dev/null +++ b/Lib/_._/pyerrors/oserr.html @@ -0,0 +1,363 @@ + + + + + + + +src/pylib/pyerrors/oserr + + + + + + + + + + + + + + + + +
+
+

src/pylib/pyerrors/oserr

+
+ +
+ Source   +Edit   + +
+ +

See CPython's Objects/exceptions.c

+

OSError_new(a.k.a. OSError.__new__) will returns a subclass of OSError, via lookup in state->errnomap, which is initialized by _PyExc_InitState,

+

where key-value pairs are inserted via ADD_ERRNO macro.

+

+ +
+

Procs

+
+
+
+
func errnoMsg(errno: cint): string {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc raiseErrno(errno = getErrno()) {....raises: [PyOSError], tags: [], forbids: [].}
+
+ + may raise subclass of OSError + Source   +Edit   + +
+
+ +
+
+
+
proc raiseErrnoT[T: PyOSError](errno = getErrno())
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc raiseErrnoWithPath[T](p: PathLike[T]; errno = getErrno())
+
+ + raises OSError or its SubError. refer to errno even under Windows. + Source   +Edit   + +
+
+ +
+
+
+
func raiseExcWithPath(fp: PathLike; exc: typedesc; err: OSErrorCode;
+                      additionalInfo: string)
+
+ + + Source   +Edit   + +
+
+
+
proc raiseExcWithPath(fp: PathLike; exc: typedesc; err: OSErrorCode;
+                      osErrorMsgCb: proc = osErrorMsg)
+
+ + + Source   +Edit   + +
+
+
+
proc raiseExcWithPath(p: PathLike) {.sideEffect.}
+
+ + + Source   +Edit   + +
+
+
+
proc raiseExcWithPath(p: PathLike; errCode: OSErrorCode) {.sideEffect.}
+
+ + raises OSError or its one of SubError type + Source   +Edit   + +
+
+ +
+
+
+
proc raiseExcWithPath2(src, dst: PathLike)
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template noWeirdTarget(def)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template osErrorMsgWithPath(fp: PathLike; err: OSErrorCode): string
+
+ + + Source   +Edit   + +
+
+
+
template osErrorMsgWithPath(fp: PathLike; err: OSErrorCode; osErrorMsgCb): string
+
+ + always suffixed with a \n + Source   +Edit   + +
+
+ +
+
+
+
template tryOsOp(p1, p2: PathLike; body)
+
+ + + Source   +Edit   + +
+
+
+
template tryOsOp(p: PathLike; body)
+
+ + + Source   +Edit   + +
+
+
+
template tryOsOp(p: PathLike; raiseCond: bool; body)
+
+ + + Source   +Edit   + +
+
+
+
template tryOsOp(raiseCond: bool; body)
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ + +
+
+ + +
+
+ + + diff --git a/Lib/_._/pyerrors/oserr.idx b/Lib/_._/pyerrors/oserr.idx new file mode 100644 index 000000000..4fb8b7bc6 --- /dev/null +++ b/Lib/_._/pyerrors/oserr.idx @@ -0,0 +1,20 @@ +nimTitle oserr _._/pyerrors/oserr.html module src/pylib/pyerrors/oserr 0 +nim osErrorMsgWithPath _._/pyerrors/oserr.html#osErrorMsgWithPath.t,PathLike,OSErrorCode, template osErrorMsgWithPath(fp: PathLike; err: OSErrorCode; osErrorMsgCb): string 36 +nim osErrorMsgWithPath _._/pyerrors/oserr.html#osErrorMsgWithPath.t,PathLike,OSErrorCode template osErrorMsgWithPath(fp: PathLike; err: OSErrorCode): string 52 +nim raiseExcWithPath _._/pyerrors/oserr.html#raiseExcWithPath,PathLike,typedesc,OSErrorCode,proc proc raiseExcWithPath(fp: PathLike; exc: typedesc; err: OSErrorCode;\n osErrorMsgCb: proc = osErrorMsg) 56 +nim raiseExcWithPath _._/pyerrors/oserr.html#raiseExcWithPath,PathLike,typedesc,OSErrorCode,string proc raiseExcWithPath(fp: PathLike; exc: typedesc; err: OSErrorCode;\n additionalInfo: string) 60 +nim noWeirdTarget _._/pyerrors/oserr.html#noWeirdTarget.t template noWeirdTarget(def) 66 +nim raiseExcWithPath _._/pyerrors/oserr.html#raiseExcWithPath,PathLike,OSErrorCode proc raiseExcWithPath(p: PathLike; errCode: OSErrorCode) 71 +nim raiseExcWithPath _._/pyerrors/oserr.html#raiseExcWithPath,PathLike proc raiseExcWithPath(p: PathLike) 78 +nim raiseExcWithPath2 _._/pyerrors/oserr.html#raiseExcWithPath2,PathLike,PathLike proc raiseExcWithPath2(src, dst: PathLike) 87 +nim tryOsOp _._/pyerrors/oserr.html#tryOsOp.t,PathLike, template tryOsOp(p: PathLike; body) 96 +nim tryOsOp _._/pyerrors/oserr.html#tryOsOp.t,PathLike,bool, template tryOsOp(p: PathLike; raiseCond: bool; body) 101 +nim tryOsOp _._/pyerrors/oserr.html#tryOsOp.t,bool, template tryOsOp(raiseCond: bool; body) 107 +nim tryOsOp _._/pyerrors/oserr.html#tryOsOp.t,PathLike,PathLike, template tryOsOp(p1, p2: PathLike; body) 113 +nim errnoMsg _._/pyerrors/oserr.html#errnoMsg,cint proc errnoMsg(errno: cint): string 122 +nim raiseErrno _._/pyerrors/oserr.html#raiseErrno proc raiseErrno(errno = getErrno()) 132 +nim raiseErrnoT _._/pyerrors/oserr.html#raiseErrnoT proc raiseErrnoT[T: PyOSError](errno = getErrno()) 136 +nim raiseErrnoWithPath _._/pyerrors/oserr.html#raiseErrnoWithPath,PathLike[T] proc raiseErrnoWithPath[T](p: PathLike[T]; errno = getErrno()) 139 +nimgrp raiseexcwithpath _._/pyerrors/oserr.html#raiseExcWithPath-procs-all proc 56 +nimgrp tryosop _._/pyerrors/oserr.html#tryOsOp-templates-all template 96 +nimgrp oserrormsgwithpath _._/pyerrors/oserr.html#osErrorMsgWithPath-templates-all template 36 diff --git a/Lib/_._/pyerrors/oserr/errmap.html b/Lib/_._/pyerrors/oserr/errmap.html new file mode 100644 index 000000000..2832a2ff9 --- /dev/null +++ b/Lib/_._/pyerrors/oserr/errmap.html @@ -0,0 +1,177 @@ + + + + + + + +src/pylib/pyerrors/oserr/errmap + + + + + + + + + + + + + + + + +
+
+

src/pylib/pyerrors/oserr/errmap

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Vars

+
+
+
errnomap {.compileTime.}: Table[cint,
+                                proc (): ref PyOSError {.nimcall, noSideEffect.}]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
proc default_oserror(): ref PyOSError {.nimcall, noSideEffect, ...raises: [],
+                                        tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template decl_c_int(name, includeFile; defval)
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/pyerrors/oserr/errmap.idx b/Lib/_._/pyerrors/oserr/errmap.idx new file mode 100644 index 000000000..09c6e3f59 --- /dev/null +++ b/Lib/_._/pyerrors/oserr/errmap.idx @@ -0,0 +1,4 @@ +nimTitle errmap _._/pyerrors/oserr/errmap.html module src/pylib/pyerrors/oserr/errmap 0 +nim decl_c_int _._/pyerrors/oserr/errmap.html#decl_c_int.t,,, template decl_c_int(name, includeFile; defval) 30 +nim errnomap _._/pyerrors/oserr/errmap.html#errnomap var errnomap 37 +nim default_oserror _._/pyerrors/oserr/errmap.html#default_oserror proc default_oserror(): ref PyOSError 38 diff --git a/Lib/_._/pyerrors/oserr/init.html b/Lib/_._/pyerrors/oserr/init.html new file mode 100644 index 000000000..67165653f --- /dev/null +++ b/Lib/_._/pyerrors/oserr/init.html @@ -0,0 +1,233 @@ + + + + + + + +src/pylib/pyerrors/oserr/init + + + + + + + + + + + + + + + + +
+
+

src/pylib/pyerrors/oserr/init

+
+ +
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
proc BlockingIOError(myerrno: cint; strerr: string; filename = 0;
+                     winerror: cint = 0; filename2 = ""): ref PyOSError {.
+    ...raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc BlockingIOError(strerr: string = ""): ref PyOSError {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc newBlockingIOError(myerrno: cint; strerr: string; filename = 0;
+                        winerror: cint = 0; filename2 = ""): ref PyOSError {.
+    ...raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc newBlockingIOError(strerr: string = ""): ref PyOSError {....raises: [],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc newPyOSError(myerrno: cint; strerr: string; filename = "";
+                  winerror: cint = 0; filename2 = ""): ref PyOSError {.
+    ...raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc newPyOSError(strerr: string = ""): ref PyOSError {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc PyOSError(myerrno: cint; strerr: string; filename = ""; winerror: cint = 0;
+               filename2 = ""): ref PyOSError {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc PyOSError(strerr: string = ""): ref PyOSError {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/pyerrors/oserr/init.idx b/Lib/_._/pyerrors/oserr/init.idx new file mode 100644 index 000000000..c09a45055 --- /dev/null +++ b/Lib/_._/pyerrors/oserr/init.idx @@ -0,0 +1,13 @@ +nimTitle init _._/pyerrors/oserr/init.html module src/pylib/pyerrors/oserr/init 0 +nim newPyOSError _._/pyerrors/oserr/init.html#newPyOSError,cint,string,string,cint,string proc newPyOSError(myerrno: cint; strerr: string; filename = ""; winerror: cint = 0;\n filename2 = ""): ref PyOSError 6 +nim newPyOSError _._/pyerrors/oserr/init.html#newPyOSError,string proc newPyOSError(strerr: string = ""): ref PyOSError 14 +nim PyOSError _._/pyerrors/oserr/init.html#PyOSError,cint,string,string,cint,string proc PyOSError(myerrno: cint; strerr: string; filename = ""; winerror: cint = 0;\n filename2 = ""): ref PyOSError 6 +nim PyOSError _._/pyerrors/oserr/init.html#PyOSError,string proc PyOSError(strerr: string = ""): ref PyOSError 17 +nim newBlockingIOError _._/pyerrors/oserr/init.html#newBlockingIOError,cint,string,int,cint,string proc newBlockingIOError(myerrno: cint; strerr: string; filename = 0;\n winerror: cint = 0; filename2 = ""): ref PyOSError 6 +nim newBlockingIOError _._/pyerrors/oserr/init.html#newBlockingIOError,string proc newBlockingIOError(strerr: string = ""): ref PyOSError 14 +nim BlockingIOError _._/pyerrors/oserr/init.html#BlockingIOError,cint,string,int,cint,string proc BlockingIOError(myerrno: cint; strerr: string; filename = 0; winerror: cint = 0;\n filename2 = ""): ref PyOSError 6 +nim BlockingIOError _._/pyerrors/oserr/init.html#BlockingIOError,string proc BlockingIOError(strerr: string = ""): ref PyOSError 18 +nimgrp Blockingioerror _._/pyerrors/oserr/init.html#BlockingIOError-procs-all proc 15 +nimgrp newpyoserror _._/pyerrors/oserr/init.html#newPyOSError-procs-all proc 14 +nimgrp Pyoserror _._/pyerrors/oserr/init.html#PyOSError-procs-all proc 15 +nimgrp newblockingioerror _._/pyerrors/oserr/init.html#newBlockingIOError-procs-all proc 14 diff --git a/Lib/_._/pyerrors/oserr/oserror_decl.html b/Lib/_._/pyerrors/oserr/oserror_decl.html new file mode 100644 index 000000000..07aed5cad --- /dev/null +++ b/Lib/_._/pyerrors/oserr/oserror_decl.html @@ -0,0 +1,113 @@ + + + + + + + +src/pylib/pyerrors/oserr/oserror_decl + + + + + + + + + + + + + + + + +
+
+

src/pylib/pyerrors/oserr/oserror_decl

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Types

+
+
+
PyOSError = object of system.OSError
+  errno* {.exportc: "myerrno".}: cint
+  strerror*, filename*, filename2*: string
+  when defined(windows):
+    winerror*: cint          ## Windows-specific error code
+  characters_written*: int
+
+ + Python-compatible OSError + Source   +Edit   + +
+
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/pyerrors/oserr/oserror_decl.idx b/Lib/_._/pyerrors/oserr/oserror_decl.idx new file mode 100644 index 000000000..a579367fc --- /dev/null +++ b/Lib/_._/pyerrors/oserr/oserror_decl.idx @@ -0,0 +1,2 @@ +nimTitle oserror_decl _._/pyerrors/oserr/oserror_decl.html module src/pylib/pyerrors/oserr/oserror_decl 0 +nim PyOSError _._/pyerrors/oserr/oserror_decl.html#PyOSError object PyOSError 2 diff --git a/Lib/_._/pyerrors/oserr/oserror_new.html b/Lib/_._/pyerrors/oserr/oserror_new.html new file mode 100644 index 000000000..b260b215e --- /dev/null +++ b/Lib/_._/pyerrors/oserr/oserror_new.html @@ -0,0 +1,206 @@ + + + + + + + +src/pylib/pyerrors/oserr/oserror_new + + + + + + + + + + + + + + + + +
+
+

src/pylib/pyerrors/oserr/oserror_new

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

Where a function has a single filename, such as open() or some of the os module functions, PyErr_SetFromErrnoWithFilename() is called, giving a third argument which is the filename. But, so that old code using in-place unpacking doesn't break, e.g.:

+

except OSError, (errno, strerror):

+

we hack args so that it only contains two items. This also means we need our own __str__() which prints out the filename when it was supplied.

+

(If a function has two filenames, such as rename(), symlink(), or copy(), PyErr_SetFromErrnoWithFilenameObjects() is called, which allows passing in a second filename.)

+

+ +
+

Types

+
+
+
OSErrorArgs[third] = tuple[errno: cint, strerror: string, filename: third,
+                           winerror: cint, filename2: string]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
proc init[E: PyOSError](self: ref E; args: OSErrorArgs)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc OSError_new[E: PyOSError](myerrno: cint; strerr: string;
+                               filename: string | int = ""; winerror: cint = 0;
+                               filename2 = ""; fillMsg: static[bool] = true): ref PyOSError
+
+ + may returns a subclass of OSError + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template oserror_use_init[E: PyOSError](self): bool
+
+ +

When __init__ is defined in an OSError subclass, we want any extraneous argument to __new__ to be ignored. The only reasonable solution, given __new__ takes a variable number of arguments, is to defer arg parsing and initialization to __init__.

+

But when __new__ is overridden as well, it should call our __new__ with the right arguments.

+

(see http://bugs.python.org/issue12555#msg148829 )

+ + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/pyerrors/oserr/oserror_new.idx b/Lib/_._/pyerrors/oserr/oserror_new.idx new file mode 100644 index 000000000..0301a88ea --- /dev/null +++ b/Lib/_._/pyerrors/oserr/oserror_new.idx @@ -0,0 +1,5 @@ +nimTitle oserror_new _._/pyerrors/oserr/oserror_new.html module src/pylib/pyerrors/oserr/oserror_new 0 +nim OSErrorArgs _._/pyerrors/oserr/oserror_new.html#OSErrorArgs tuple OSErrorArgs 22 +nim oserror_use_init _._/pyerrors/oserr/oserror_new.html#oserror_use_init.t template oserror_use_init[E: PyOSError](self): bool 40 +nim init _._/pyerrors/oserr/oserror_new.html#init,ref.E,OSErrorArgs proc init[E: PyOSError](self: ref E; args: OSErrorArgs) 55 +nim OSError_new _._/pyerrors/oserr/oserror_new.html#OSError_new,cint,string,string,cint,string,static[bool] proc OSError_new[E: PyOSError](myerrno: cint; strerr: string;\n filename: string | int = ""; winerror: cint = 0;\n filename2 = ""; fillMsg: static[bool] = true): ref PyOSError 67 diff --git a/Lib/_._/pyerrors/oserr/oserror_str.html b/Lib/_._/pyerrors/oserr/oserror_str.html new file mode 100644 index 000000000..8a6f8afe6 --- /dev/null +++ b/Lib/_._/pyerrors/oserr/oserror_str.html @@ -0,0 +1,118 @@ + + + + + + + +src/pylib/pyerrors/oserr/oserror_str + + + + + + + + + + + + + + + + +
+
+

src/pylib/pyerrors/oserr/oserror_str

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Imports

+
+ types +
+
+
+

Procs

+
+
+
+
proc `$`(self: ref PyOSError): string {....raises: [], tags: [], forbids: [].}
+
+ + String representation of OSError + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/pyerrors/oserr/oserror_str.idx b/Lib/_._/pyerrors/oserr/oserror_str.idx new file mode 100644 index 000000000..73118f4ee --- /dev/null +++ b/Lib/_._/pyerrors/oserr/oserror_str.idx @@ -0,0 +1,2 @@ +nimTitle oserror_str _._/pyerrors/oserr/oserror_str.html module src/pylib/pyerrors/oserr/oserror_str 0 +nim `$` _._/pyerrors/oserr/oserror_str.html#$,ref.PyOSError proc `$`(self: ref PyOSError): string 5 diff --git a/Lib/_._/pyerrors/oserr/types.html b/Lib/_._/pyerrors/oserr/types.html new file mode 100644 index 000000000..d2fffdc6e --- /dev/null +++ b/Lib/_._/pyerrors/oserr/types.html @@ -0,0 +1,275 @@ + + + + + + + +src/pylib/pyerrors/oserr/types + + + + + + + + + + + + + + + + +
+
+

src/pylib/pyerrors/oserr/types

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Types

+
+
+
BlockingIOError = object of oserror_decl.PyOSError
+
+ + + Source   +Edit   + +
+
+
+
BrokenPipeError = object of ConnectionError
+
+ + + Source   +Edit   + +
+
+
+
ChildProcessError = object of oserror_decl.PyOSError
+
+ + + Source   +Edit   + +
+
+
+
ConnectionAbortedError = object of ConnectionError
+
+ + + Source   +Edit   + +
+
+
+
ConnectionError = object of oserror_decl.PyOSError
+
+ + + Source   +Edit   + +
+
+
+
ConnectionRefusedError = object of ConnectionError
+
+ + + Source   +Edit   + +
+
+
+
ConnectionResetError = object of ConnectionError
+
+ + + Source   +Edit   + +
+
+
+
FileExistsError = object of oserror_decl.PyOSError
+
+ + + Source   +Edit   + +
+
+
+
FileNotFoundError = object of oserror_decl.PyOSError
+
+ + + Source   +Edit   + +
+
+
+
InterruptedError = object of oserror_decl.PyOSError
+
+ + + Source   +Edit   + +
+
+
+
IsADirectoryError = object of oserror_decl.PyOSError
+
+ + + Source   +Edit   + +
+
+
+
NotADirectoryError = object of oserror_decl.PyOSError
+
+ + + Source   +Edit   + +
+
+
+
PermissionError = object of oserror_decl.PyOSError
+
+ + + Source   +Edit   + +
+
+
+
ProcessLookupError = object of oserror_decl.PyOSError
+
+ + + Source   +Edit   + +
+
+
+
TimeoutError = object of oserror_decl.PyOSError
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Exports

+
+ PyOSError +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/pyerrors/oserr/types.idx b/Lib/_._/pyerrors/oserr/types.idx new file mode 100644 index 000000000..7c680e375 --- /dev/null +++ b/Lib/_._/pyerrors/oserr/types.idx @@ -0,0 +1,16 @@ +nimTitle types _._/pyerrors/oserr/types.html module src/pylib/pyerrors/oserr/types 0 +nim BlockingIOError _._/pyerrors/oserr/types.html#BlockingIOError object BlockingIOError 6 +nim ConnectionError _._/pyerrors/oserr/types.html#ConnectionError object ConnectionError 6 +nim ChildProcessError _._/pyerrors/oserr/types.html#ChildProcessError object ChildProcessError 6 +nim BrokenPipeError _._/pyerrors/oserr/types.html#BrokenPipeError object BrokenPipeError 6 +nim ConnectionAbortedError _._/pyerrors/oserr/types.html#ConnectionAbortedError object ConnectionAbortedError 6 +nim ConnectionRefusedError _._/pyerrors/oserr/types.html#ConnectionRefusedError object ConnectionRefusedError 6 +nim ConnectionResetError _._/pyerrors/oserr/types.html#ConnectionResetError object ConnectionResetError 6 +nim FileExistsError _._/pyerrors/oserr/types.html#FileExistsError object FileExistsError 6 +nim FileNotFoundError _._/pyerrors/oserr/types.html#FileNotFoundError object FileNotFoundError 6 +nim IsADirectoryError _._/pyerrors/oserr/types.html#IsADirectoryError object IsADirectoryError 6 +nim NotADirectoryError _._/pyerrors/oserr/types.html#NotADirectoryError object NotADirectoryError 6 +nim InterruptedError _._/pyerrors/oserr/types.html#InterruptedError object InterruptedError 6 +nim PermissionError _._/pyerrors/oserr/types.html#PermissionError object PermissionError 6 +nim ProcessLookupError _._/pyerrors/oserr/types.html#ProcessLookupError object ProcessLookupError 6 +nim TimeoutError _._/pyerrors/oserr/types.html#TimeoutError object TimeoutError 6 diff --git a/Lib/_._/pyerrors/rterr.html b/Lib/_._/pyerrors/rterr.html new file mode 100644 index 000000000..ac236989d --- /dev/null +++ b/Lib/_._/pyerrors/rterr.html @@ -0,0 +1,125 @@ + + + + + + + +src/pylib/pyerrors/rterr + + + + + + + + + + + + + + + + +
+
+

src/pylib/pyerrors/rterr

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Types

+
+
+
KeyboardInterrupt = object of CatchableError
+
+ + + Source   +Edit   + +
+
+
+
NotImplementedError = object of RuntimeError
+
+ + + Source   +Edit   + +
+
+
+
RuntimeError = object of CatchableError
+
+ + + Source   +Edit   + +
+
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/pyerrors/rterr.idx b/Lib/_._/pyerrors/rterr.idx new file mode 100644 index 000000000..cac12c28d --- /dev/null +++ b/Lib/_._/pyerrors/rterr.idx @@ -0,0 +1,4 @@ +nimTitle rterr _._/pyerrors/rterr.html module src/pylib/pyerrors/rterr 0 +nim RuntimeError _._/pyerrors/rterr.html#RuntimeError object RuntimeError 3 +nim NotImplementedError _._/pyerrors/rterr.html#NotImplementedError object NotImplementedError 4 +nim KeyboardInterrupt _._/pyerrors/rterr.html#KeyboardInterrupt object KeyboardInterrupt 6 diff --git a/Lib/_._/pyerrors/signals.html b/Lib/_._/pyerrors/signals.html new file mode 100644 index 000000000..121a7e30a --- /dev/null +++ b/Lib/_._/pyerrors/signals.html @@ -0,0 +1,247 @@ + + + + + + + +src/pylib/pyerrors/signals + + + + + + + + + + + + + + + + +
+
+

src/pylib/pyerrors/signals

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Imports

+
+ ../noneType +
+
+
+

Types

+
+
+
GeneratorExit = object of CatchableError
+
+ + + Source   +Edit   + +
+
+
+
StopAsyncIteration = object of CatchableError
+
+ + + Source   +Edit   + +
+
+
+
StopIteration = StopIterationT[NoneType]
+
+ +
Note: +CPython's StopIteration is not generics, at least as of 3.13
+ + Source   +Edit   + +
+
+
+
StopIterationT[T] = object of CatchableError
+  value*: T                  ## generator return value
+
+ + EXT. as StopIteraton's value was not statically typed in Python, this must be used for those whose value is not None + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
func `$`(self: StopIteration): string {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func `$`(self: StopIterationT): string
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func msg(self: StopIteration): string {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func msg(self: StopIterationT): string
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func newStopIteration(): ref StopIteration {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func newStopIteration[T](value: T): ref StopIterationT[T]
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/pyerrors/signals.idx b/Lib/_._/pyerrors/signals.idx new file mode 100644 index 000000000..344b24bc5 --- /dev/null +++ b/Lib/_._/pyerrors/signals.idx @@ -0,0 +1,14 @@ +nimTitle signals _._/pyerrors/signals.html module src/pylib/pyerrors/signals 0 +nim StopIterationT _._/pyerrors/signals.html#StopIterationT object StopIterationT 5 +nim StopIteration _._/pyerrors/signals.html#StopIteration type StopIteration 9 +nim StopAsyncIteration _._/pyerrors/signals.html#StopAsyncIteration object StopAsyncIteration 12 +nim GeneratorExit _._/pyerrors/signals.html#GeneratorExit object GeneratorExit 13 +nim newStopIteration _._/pyerrors/signals.html#newStopIteration proc newStopIteration(): ref StopIteration 15 +nim newStopIteration _._/pyerrors/signals.html#newStopIteration,T proc newStopIteration[T](value: T): ref StopIterationT[T] 16 +nim `$` _._/pyerrors/signals.html#$,StopIteration proc `$`(self: StopIteration): string 20 +nim `$` _._/pyerrors/signals.html#$,StopIterationT proc `$`(self: StopIterationT): string 21 +nim msg _._/pyerrors/signals.html#msg,StopIteration proc msg(self: StopIteration): string 23 +nim msg _._/pyerrors/signals.html#msg,StopIterationT proc msg(self: StopIterationT): string 24 +nimgrp msg _._/pyerrors/signals.html#msg-procs-all proc 23 +nimgrp $ _._/pyerrors/signals.html#$-procs-all proc 20 +nimgrp newstopiteration _._/pyerrors/signals.html#newStopIteration-procs-all proc 15 diff --git a/Lib/_._/pyerrors/simperr.html b/Lib/_._/pyerrors/simperr.html new file mode 100644 index 000000000..aacaeb66d --- /dev/null +++ b/Lib/_._/pyerrors/simperr.html @@ -0,0 +1,136 @@ + + + + + + + +src/pylib/pyerrors/simperr + + + + + + + + + + + + + + + + +
+
+

src/pylib/pyerrors/simperr

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Types

+
+
+
AttributeError = object of CatchableError
+
+ + + Source   +Edit   + +
+
+
+
NameError = object of CatchableError
+
+ + + Source   +Edit   + +
+
+
+
SystemExit = object of CatchableError
+
+ + + Source   +Edit   + +
+
+
+
TypeError = object of CatchableError
+
+ + + Source   +Edit   + +
+
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/pyerrors/simperr.idx b/Lib/_._/pyerrors/simperr.idx new file mode 100644 index 000000000..e6e5355d9 --- /dev/null +++ b/Lib/_._/pyerrors/simperr.idx @@ -0,0 +1,5 @@ +nimTitle simperr _._/pyerrors/simperr.html module src/pylib/pyerrors/simperr 0 +nim TypeError _._/pyerrors/simperr.html#TypeError object TypeError 3 +nim SystemExit _._/pyerrors/simperr.html#SystemExit object SystemExit 4 +nim AttributeError _._/pyerrors/simperr.html#AttributeError object AttributeError 5 +nim NameError _._/pyerrors/simperr.html#NameError object NameError 6 diff --git a/Lib/_._/pyerrors/unicode_err.html b/Lib/_._/pyerrors/unicode_err.html new file mode 100644 index 000000000..5c218f02c --- /dev/null +++ b/Lib/_._/pyerrors/unicode_err.html @@ -0,0 +1,162 @@ + + + + + + + +src/pylib/pyerrors/unicode_err + + + + + + + + + + + + + + + + +
+
+

src/pylib/pyerrors/unicode_err

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Types

+
+
+
UnicodeDecodeError = object of UnicodeError
+
+ + + Source   +Edit   + +
+
+
+
UnicodeError = object of ValueError
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
func newUnicodeDecodeError(codec: string; src: char; start, stop: int;
+                           reason: string): ref UnicodeDecodeError {.
+    ...raises: [ValueError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func newUnicodeDecodeError(codec: string; src: string; start, stop: int;
+                           reason: string): ref UnicodeDecodeError {.
+    ...raises: [ValueError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/pyerrors/unicode_err.idx b/Lib/_._/pyerrors/unicode_err.idx new file mode 100644 index 000000000..4e120f71c --- /dev/null +++ b/Lib/_._/pyerrors/unicode_err.idx @@ -0,0 +1,6 @@ +nimTitle unicode_err _._/pyerrors/unicode_err.html module src/pylib/pyerrors/unicode_err 0 +nim UnicodeError _._/pyerrors/unicode_err.html#UnicodeError object UnicodeError 5 +nim UnicodeDecodeError _._/pyerrors/unicode_err.html#UnicodeDecodeError object UnicodeDecodeError 6 +nim newUnicodeDecodeError _._/pyerrors/unicode_err.html#newUnicodeDecodeError,string,char,int,int,string proc newUnicodeDecodeError(codec: string; src: char; start, stop: int; reason: string): ref UnicodeDecodeError 8 +nim newUnicodeDecodeError _._/pyerrors/unicode_err.html#newUnicodeDecodeError,string,string,int,int,string proc newUnicodeDecodeError(codec: string; src: string; start, stop: int;\n reason: string): ref UnicodeDecodeError 27 +nimgrp newunicodedecodeerror _._/pyerrors/unicode_err.html#newUnicodeDecodeError-procs-all proc 8 diff --git a/Lib/_._/pystring.html b/Lib/_._/pystring.html new file mode 100644 index 000000000..1b07eea2a --- /dev/null +++ b/Lib/_._/pystring.html @@ -0,0 +1,96 @@ + + + + + + + +src/pylib/pystring + + + + + + + + + + + + + + + + +
+
+

src/pylib/pystring

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Exports

+
+ runeLenAt, not, str, str, toPyStr, contains, substr, byteLen, str, items, StringLike, ==, str, toNimString, +, ==, str, chars, contains, and, getChar, $, len, +=, str, +=, len, toPyStr, PyStr, runes, [], ==, runeAtPos, or, contains, +, toNimStr, fspath, +=, toPyStr, [], [], endsWith, toPyStr, substr, ==, str, endsWith, PyStr, and, isupper, $, +=, rfind, isascii, index, startsWith, split, rjust, ljust, endsWith, rpartition, str, runeLenAt, contains, rsplit, StringLike, count, split, isspace, ==, contains, chars, endsWith, istitle, len, rstrip, isalpha, *, toPyStr, rindex, center, startsWith, split, str, str, expandtabs, splitlines, removeprefix, title, toPyStr, splitlines, replace, not, islower, rsplit, runes, casefold, toNimString, +, count, join, upper, contains, lstrip, getChar, strip, +=, find, strip, ==, runeAtPos, +, lstrip, +=, zfill, partition, startsWith, str, capitalize, or, byteLen, items, startsWith, startsWith, endsWith, split, len, center, str, rstrip, replace, rjust, rsplit, [], isascii, count, removesuffix, ljust, lower, toNimStr, fspath, *, [], [], chr, bin, hex, pyrepr, ord1, oct, ord, ascii, ascii, repr, ascii, reversed, ascii, <>, u, u, rf, fr, f, Fr, Rf, format, format, TypedTranslateTableABC, maketrans, not, toPyStr, substr, contains, ==, str, toNimString, +, StrTypedTranslateTable, PyStr, contains, and, getChar, $, None, +=, +=, $, maketrans, ==, TranslateTableABC, runeAtPos, TranslateAction, +, TranslateTable, +=, translate, translate, runeLenAt, str, str, or, translate, byteLen, items, StringLike, ==, translate, str, chars, repr, len, len, str, maketrans, toPyStr, str, runes, [], NoneType, TranslateTableVal, contains, toNimStr, fspath, toPyStr, [], TranslateValType, [] +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/pystring.idx b/Lib/_._/pystring.idx new file mode 100644 index 000000000..6b5564670 --- /dev/null +++ b/Lib/_._/pystring.idx @@ -0,0 +1 @@ +nimTitle pystring _._/pystring.html module src/pylib/pystring 0 diff --git a/Lib/_._/pystring/consts.html b/Lib/_._/pystring/consts.html new file mode 100644 index 000000000..942e9443f --- /dev/null +++ b/Lib/_._/pystring/consts.html @@ -0,0 +1,111 @@ + + + + + + + +src/pylib/pystring/consts + + + + + + + + + + + + + + + + +
+
+

src/pylib/pystring/consts

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Consts

+
+
+
unicodeSpaces = [9'i32, 10'i32, 11'i32, 12'i32, 13'i32, 28'i32, 29'i32, 30'i32,
+                 31'i32, 32'i32, 133'i32, 160'i32, 5760'i32, 8192'i32, 8193'i32,
+                 8194'i32, 8195'i32, 8196'i32, 8197'i32, 8198'i32, 8199'i32,
+                 8200'i32, 8201'i32, 8202'i32, 8232'i32, 8233'i32, 8239'i32,
+                 8287'i32, 12288'i32]
+
+ + This differs Nim's unicodeSpaces(inner symbol) std/unicode. This has foour more characters than the latter: \x1C, \x1D, \x1E, \x1F + Source   +Edit   + +
+
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/pystring/consts.idx b/Lib/_._/pystring/consts.idx new file mode 100644 index 000000000..3ff2d8a74 --- /dev/null +++ b/Lib/_._/pystring/consts.idx @@ -0,0 +1,2 @@ +nimTitle consts _._/pystring/consts.html module src/pylib/pystring/consts 0 +nim unicodeSpaces _._/pystring/consts.html#unicodeSpaces const unicodeSpaces 5 diff --git a/Lib/_._/pystring/format.html b/Lib/_._/pystring/format.html new file mode 100644 index 000000000..1e0054890 --- /dev/null +++ b/Lib/_._/pystring/format.html @@ -0,0 +1,131 @@ + + + + + + + +src/pylib/pystring/format + + + + + + + + + + + + + + + + +
+
+

src/pylib/pystring/format

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Templates

+
+
+
+
template format(s: PyStr; argKw: varargs[untyped]): PyStr
+
+ +

str.format

+

NOTE: s must be static (e.g. a str literal), as this will be expanded at compile-time

+ + Source   +Edit   + +
+
+
+
template format[T](value: T; format_spec: PyStr = ""): PyStr
+
+ + builtins.format + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/pystring/format.idx b/Lib/_._/pystring/format.idx new file mode 100644 index 000000000..0d0499347 --- /dev/null +++ b/Lib/_._/pystring/format.idx @@ -0,0 +1,4 @@ +nimTitle format _._/pystring/format.html module src/pylib/pystring/format 0 +nim format _._/pystring/format.html#format.t,T,PyStr template format[T](value: T; format_spec: PyStr = ""): PyStr 6 +nim format _._/pystring/format.html#format.t,PyStr,varargs[untyped] template format(s: PyStr; argKw: varargs[untyped]): PyStr 10 +nimgrp format _._/pystring/format.html#format-templates-all template 6 diff --git a/Lib/_._/pystring/fstring.html b/Lib/_._/pystring/fstring.html new file mode 100644 index 000000000..8707b4e52 --- /dev/null +++ b/Lib/_._/pystring/fstring.html @@ -0,0 +1,241 @@ + + + + + + + +src/pylib/pystring/fstring + + + + + + + + + + + + + + + + +
+
+

src/pylib/pystring/fstring

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

f-string

+

a string literal with a prefix of fr, Fr, rf of Rf behaves as if with a prefix of strformat.fmt.

+

and f"xxx" is different, where the escaped literals in string will be interpreted.

+ +

Example:

+
import src/pylib/pystring/fstring
+assert fr"\n" == "\\n"
+assert f"\n" == "\n"
+
+let s = "asd"
+
+assert f"[{s}]" == "[asd]"
+assert not compiles(fr s)

+ +
+

Macros

+
+
+
+
macro Fr(pattern: string{lit}): PyStr
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
macro fr(pattern: string{lit}): PyStr
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
macro rf(pattern: string{lit}): PyStr
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
macro Rf(pattern: string{lit}): PyStr
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template f(s: string{lit}): PyStr
+
+ +

Python F-String.

+

Not the same as Nim's fmt"xxx" as that's equal to fmt r"xxx", a.k.a fr"xx" in Python

+

Any escape-translation error is reported at compile-time, with information of filename and line number

+ +

Unicode

\Uhhhhhhhh is supported as Python's, while Nim's \U{...} is unsupported but \u{...} is reserved

+ +

oct

\\[0-7]{1,3} in f-string will be interpreted as octal digit as Python,

+

instead of decimal as Nim.

+ +

multiline

the following shows the deature of Nim's multiline string which is different from Python's

+

assert "" == """
+"""
+
+## Unicode Names
+`\N{name}` is not supported yet.
+

+ +

Example:

+
assert f"\n" == "\n"
+assert f"123{'a'}\n456" == "123a\n456"
+
+assert f"\U0001f451" == "👑"
+
+assert f"\10" == "\x08"   # nim's "\10" means chr(10)
+
+assert f"""\t123
+""" == "\t123\n"  # even if the source code's newline is crlf.
+ Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/pystring/fstring.idx b/Lib/_._/pystring/fstring.idx new file mode 100644 index 000000000..3f00b9876 --- /dev/null +++ b/Lib/_._/pystring/fstring.idx @@ -0,0 +1,9 @@ +nimTitle fstring _._/pystring/fstring.html module src/pylib/pystring/fstring 0 +nim fr _._/pystring/fstring.html#fr.m macro fr(pattern: string{lit}): PyStr 29 +nim Fr _._/pystring/fstring.html#Fr.m_2 macro Fr(pattern: string{lit}): PyStr 30 +nim rf _._/pystring/fstring.html#rf.m macro rf(pattern: string{lit}): PyStr 31 +nim Rf _._/pystring/fstring.html#Rf.m_2 macro Rf(pattern: string{lit}): PyStr 32 +nim f _._/pystring/fstring.html#f.t template f(s: string{lit}): PyStr 34 +heading Unicode _._/pystring/fstring.html#unicode Unicode 0 +heading oct _._/pystring/fstring.html#oct oct 0 +heading multiline _._/pystring/fstring.html#multiline multiline 0 diff --git a/Lib/_._/pystring/split/common.html b/Lib/_._/pystring/split/common.html new file mode 100644 index 000000000..693a9e2fb --- /dev/null +++ b/Lib/_._/pystring/split/common.html @@ -0,0 +1,127 @@ + + + + + + + +src/pylib/pystring/split/common + + + + + + + + + + + + + + + + +
+
+

src/pylib/pystring/split/common

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
func ISSPACE(s: PyStr; pos: int): bool {....raises: [], tags: [], forbids: [].}
+
+ + Checks unicode space at unicode char's pos + Source   +Edit   + +
+
+ +
+ +
+
+ + +
+
+ + +
+
+ + + diff --git a/Lib/_._/pystring/split/common.idx b/Lib/_._/pystring/split/common.idx new file mode 100644 index 000000000..4cb178af2 --- /dev/null +++ b/Lib/_._/pystring/split/common.idx @@ -0,0 +1,2 @@ +nimTitle common _._/pystring/split/common.html module src/pylib/pystring/split/common 0 +nim ISSPACE _._/pystring/split/common.html#ISSPACE,PyStr,int proc ISSPACE(s: PyStr; pos: int): bool 8 diff --git a/Lib/_._/pystring/split/reimporter.html b/Lib/_._/pystring/split/reimporter.html new file mode 100644 index 000000000..dbd9475ed --- /dev/null +++ b/Lib/_._/pystring/split/reimporter.html @@ -0,0 +1,96 @@ + + + + + + + +src/pylib/pystring/split/reimporter + + + + + + + + + + + + + + + + +
+
+

src/pylib/pystring/split/reimporter

+ + + +
+
+ + + diff --git a/Lib/_._/pystring/split/reimporter.idx b/Lib/_._/pystring/split/reimporter.idx new file mode 100644 index 000000000..e637c7530 --- /dev/null +++ b/Lib/_._/pystring/split/reimporter.idx @@ -0,0 +1 @@ +nimTitle reimporter _._/pystring/split/reimporter.html module src/pylib/pystring/split/reimporter 0 diff --git a/Lib/_._/pystring/split/rsplit.html b/Lib/_._/pystring/split/rsplit.html new file mode 100644 index 000000000..fbc520524 --- /dev/null +++ b/Lib/_._/pystring/split/rsplit.html @@ -0,0 +1,164 @@ + + + + + + + +src/pylib/pystring/split/rsplit + + + + + + + + + + + + + + + + +
+
+

src/pylib/pystring/split/rsplit

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
proc rsplit(a: PyStr; sep = None; maxsplit = -1): PyList[PyStr] {....raises: [],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc rsplit(a: PyStr; sep: StringLike; maxsplit = -1): PyList[PyStr]
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Iterators

+
+
+
+
iterator rsplit(a: PyStr; sep = None; maxsplit = -1): PyStr {....raises: [],
+    tags: [], forbids: [].}
+
+ +

with unicode whitespaces as sep.

+

treat runs of whitespaces as one sep (i.e. discard empty strings from result), while Nim's unicode doesn't has rsplit yet

+ + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/pystring/split/rsplit.idx b/Lib/_._/pystring/split/rsplit.idx new file mode 100644 index 000000000..2b6a5b12a --- /dev/null +++ b/Lib/_._/pystring/split/rsplit.idx @@ -0,0 +1,5 @@ +nimTitle rsplit _._/pystring/split/rsplit.html module src/pylib/pystring/split/rsplit 0 +nim rsplit _._/pystring/split/rsplit.html#rsplit.i,PyStr,int iterator rsplit(a: PyStr; sep = None; maxsplit = -1): PyStr 9 +nim rsplit _._/pystring/split/rsplit.html#rsplit,PyStr,int proc rsplit(a: PyStr; sep = None; maxsplit = -1): PyList[PyStr] 26 +nim rsplit _._/pystring/split/rsplit.html#rsplit,PyStr,StringLike,int proc rsplit(a: PyStr; sep: StringLike; maxsplit = -1): PyList[PyStr] 37 +nimgrp rsplit _._/pystring/split/rsplit.html#rsplit-procs-all proc 26 diff --git a/Lib/_._/pystring/split/rsplit_whitespace.html b/Lib/_._/pystring/split/rsplit_whitespace.html new file mode 100644 index 000000000..ec57b10f5 --- /dev/null +++ b/Lib/_._/pystring/split/rsplit_whitespace.html @@ -0,0 +1,119 @@ + + + + + + + +src/pylib/pystring/split/rsplit_whitespace + + + + + + + + + + + + + + + + +
+
+

src/pylib/pystring/split/rsplit_whitespace

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
proc rsplit_whitespace(pystr: PyStr; maxsplit = -1): PyList[PyStr] {....raises: [],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/pystring/split/rsplit_whitespace.idx b/Lib/_._/pystring/split/rsplit_whitespace.idx new file mode 100644 index 000000000..537694848 --- /dev/null +++ b/Lib/_._/pystring/split/rsplit_whitespace.idx @@ -0,0 +1,2 @@ +nimTitle rsplit_whitespace _._/pystring/split/rsplit_whitespace.html module src/pylib/pystring/split/rsplit_whitespace 0 +nim rsplit_whitespace _._/pystring/split/rsplit_whitespace.html#rsplit_whitespace,PyStr,int proc rsplit_whitespace(pystr: PyStr; maxsplit = -1): PyList[PyStr] 5 diff --git a/Lib/_._/pystring/split/split.html b/Lib/_._/pystring/split/split.html new file mode 100644 index 000000000..af480b081 --- /dev/null +++ b/Lib/_._/pystring/split/split.html @@ -0,0 +1,202 @@ + + + + + + + +src/pylib/pystring/split/split + + + + + + + + + + + + + + + + +
+
+

src/pylib/pystring/split/split

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
proc split(a: PyStr; sep = None; maxsplit = -1): PyList[PyStr] {....raises: [],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc split(a: PyStr; sep: StringLike; maxsplit = -1): PyList[PyStr]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc splitlines(self: PyStr; keepends = false): PyList[PyStr] {....raises: [],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Iterators

+
+
+
+
iterator split(a: PyStr; sep = None; maxsplit = -1): PyStr {....raises: [],
+    tags: [], forbids: [].}
+
+ +

with unicode whitespaces as sep.

+

treat runs of whitespaces as one sep (i.e. discard empty strings from result), while Nim's unicode.split(s) doesn't

+ + Source   +Edit   + +
+
+
+
iterator split(a: PyStr; sep: StringLike; maxsplit = -1): PyStr {.inline.}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Exports

+
+ splitlines +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/pystring/split/split.idx b/Lib/_._/pystring/split/split.idx new file mode 100644 index 000000000..5ca5d498b --- /dev/null +++ b/Lib/_._/pystring/split/split.idx @@ -0,0 +1,8 @@ +nimTitle split _._/pystring/split/split.html module src/pylib/pystring/split/split 0 +nim split _._/pystring/split/split.html#split.i,PyStr,int iterator split(a: PyStr; sep = None; maxsplit = -1): PyStr 12 +nim split _._/pystring/split/split.html#split.i,PyStr,StringLike,int iterator split(a: PyStr; sep: StringLike; maxsplit = -1): PyStr 27 +nim split _._/pystring/split/split.html#split,PyStr,int proc split(a: PyStr; sep = None; maxsplit = -1): PyList[PyStr] 32 +nim split _._/pystring/split/split.html#split,PyStr,StringLike,int proc split(a: PyStr; sep: StringLike; maxsplit = -1): PyList[PyStr] 43 +nim splitlines _._/pystring/split/split.html#splitlines,PyStr proc splitlines(self: PyStr; keepends = false): PyList[PyStr] 52 +nimgrp split _._/pystring/split/split.html#split-procs-all proc 32 +nimgrp split _._/pystring/split/split.html#split-iterators-all iterator 12 diff --git a/Lib/_._/pystring/split/split_whitespace.html b/Lib/_._/pystring/split/split_whitespace.html new file mode 100644 index 000000000..b8a28a7f7 --- /dev/null +++ b/Lib/_._/pystring/split/split_whitespace.html @@ -0,0 +1,151 @@ + + + + + + + +src/pylib/pystring/split/split_whitespace + + + + + + + + + + + + + + + + +
+
+

src/pylib/pystring/split/split_whitespace

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
proc split_whitespace(pystr: PyStr; maxsplit = -1): PyList[PyStr] {....raises: [],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Iterators

+
+
+
+
iterator split_whitespace(pystr: PyStr; maxsplit = -1): PyStr {....raises: [],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/pystring/split/split_whitespace.idx b/Lib/_._/pystring/split/split_whitespace.idx new file mode 100644 index 000000000..b2ba3f9d0 --- /dev/null +++ b/Lib/_._/pystring/split/split_whitespace.idx @@ -0,0 +1,3 @@ +nimTitle split_whitespace _._/pystring/split/split_whitespace.html module src/pylib/pystring/split/split_whitespace 0 +nim split_whitespace _._/pystring/split/split_whitespace.html#split_whitespace.i,PyStr,int iterator split_whitespace(pystr: PyStr; maxsplit = -1): PyStr 5 +nim split_whitespace _._/pystring/split/split_whitespace.html#split_whitespace,PyStr,int proc split_whitespace(pystr: PyStr; maxsplit = -1): PyList[PyStr] 9 diff --git a/Lib/_._/pystring/split/splitlinesIter.html b/Lib/_._/pystring/split/splitlinesIter.html new file mode 100644 index 000000000..093507793 --- /dev/null +++ b/Lib/_._/pystring/split/splitlinesIter.html @@ -0,0 +1,119 @@ + + + + + + + +src/pylib/pystring/split/splitlinesIter + + + + + + + + + + + + + + + + +
+
+

src/pylib/pystring/split/splitlinesIter

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Iterators

+
+
+
+
iterator splitlines(self: PyStr; keepends = false): PyStr {....raises: [],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/pystring/split/splitlinesIter.idx b/Lib/_._/pystring/split/splitlinesIter.idx new file mode 100644 index 000000000..b597a7147 --- /dev/null +++ b/Lib/_._/pystring/split/splitlinesIter.idx @@ -0,0 +1,2 @@ +nimTitle splitlinesIter _._/pystring/split/splitlinesIter.html module src/pylib/pystring/split/splitlinesIter 0 +nim splitlines _._/pystring/split/splitlinesIter.html#splitlines.i,PyStr iterator splitlines(self: PyStr; keepends = false): PyStr 25 diff --git a/Lib/_._/pystring/strbltins.html b/Lib/_._/pystring/strbltins.html new file mode 100644 index 000000000..f5d52c99f --- /dev/null +++ b/Lib/_._/pystring/strbltins.html @@ -0,0 +1,357 @@ + + + + + + + +src/pylib/pystring/strbltins + + + + + + + + + + + + + + + + +
+
+

src/pylib/pystring/strbltins

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
func ascii(us: PyStr): PyStr {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func ascii(us: string): PyStr {....raises: [], tags: [], forbids: [].}
+
+ + +

Example:

+
assert ascii("𐀀") == r"'\U00010000'"
+assert ascii("đ") == r"'\u0111'"
+assert ascii("和") == r"'\u548c'"
+let s = ascii("v我\n\e")
+when not defined(useNimCharEsc):
+  let rs = r"'v\u6211\n\x1b'"
+else:
+  let rs = r"'v\u6211\n\e'"
+assert s == rs
+assert ascii("\"") == "'\"'"
+assert ascii("\"'") == "'\"\\''"
+let s2 = ascii("'")
+when not defined(singQuotedStr):
+  let rs2 = "\"'\""
+else:
+  let rs2 = r"'\''"
+assert s2 == rs2
+ Source   +Edit   + +
+
+ +
+
+
+
func bin(a`gensym13: SomeInteger): PyStr
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func chr(a: SomeInteger): PyStr
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func hex(a`gensym16: SomeInteger): PyStr
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func oct(a`gensym10: SomeInteger): PyStr
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc ord(a: PyStr): int {....raises: [TypeError], tags: [], forbids: [].}
+
+ + Raises TypeError if len(a) is not 1. +

Example:

+
doAssert ord("δ") == 0x03b4
+ Source   +Edit   + +
+
+ +
+
+
+
func ord1(a: PyStr): int {....raises: [], tags: [], forbids: [].}
+
+ + +

Example:

+
assert ord1("123") == ord("1")
+ Source   +Edit   + +
+
+ +
+
+
+
func pyrepr(s: StringLike): PyStr
+
+ + Shortcut for str(pyreprImpl($s))) +

Example:

+
# NOTE: string literal's `repr` is `system.repr`, as following. 
+assert repr("\"") == "\"\\\"\""   # string literal of "\""
+# use pyrepr for any StringLike and returns a PyStr
+assert pyrepr("\"") == "'\"'"
+ Source   +Edit   + +
+
+ +
+
+
+
func repr(x: PyStr): string {....raises: [], tags: [], forbids: [].}
+
+ +

Overwites system.repr for PyStr

+

The same as proc ascii except for unicode chars being remained AS-IS, and returns Nim's string.

+ + Source   +Edit   + +
+
+ +
+
+
+
func reversed(s: PyStr): PyStr {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template ascii(a: untyped): PyStr
+
+ + As repr(), return a string containing a printable representation of an object, but escape the non-ASCII characters in the string returned by repr() using x, u, or U escapes +

Example:

+
assert ascii(6) == "6"
+ Source   +Edit   + +
+
+
+
template ascii(c: char): PyStr
+
+ + we regard 'x' as a str (so as in python) +

Example:

+
assert ascii('c') == "'c'"
+ Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/pystring/strbltins.idx b/Lib/_._/pystring/strbltins.idx new file mode 100644 index 000000000..d53a0d9b9 --- /dev/null +++ b/Lib/_._/pystring/strbltins.idx @@ -0,0 +1,16 @@ +nimTitle strbltins _._/pystring/strbltins.html module src/pylib/pystring/strbltins 0 +nim reversed _._/pystring/strbltins.html#reversed,PyStr proc reversed(s: PyStr): PyStr 9 +nim chr _._/pystring/strbltins.html#chr,SomeInteger proc chr(a: SomeInteger): PyStr 12 +nim ord1 _._/pystring/strbltins.html#ord1,PyStr proc ord1(a: PyStr): int 18 +nim ord _._/pystring/strbltins.html#ord,PyStr proc ord(a: PyStr): int 23 +nim pyrepr _._/pystring/strbltins.html#pyrepr,StringLike proc pyrepr(s: StringLike): PyStr 35 +nim repr _._/pystring/strbltins.html#repr,PyStr proc repr(x: PyStr): string 44 +nim ascii _._/pystring/strbltins.html#ascii,string proc ascii(us: string): PyStr 51 +nim ascii _._/pystring/strbltins.html#ascii,PyStr proc ascii(us: PyStr): PyStr 72 +nim ascii _._/pystring/strbltins.html#ascii.t,char template ascii(c: char): PyStr 75 +nim ascii _._/pystring/strbltins.html#ascii.t,untyped template ascii(a: untyped): PyStr 82 +nim oct _._/pystring/strbltins.html#oct,SomeInteger proc oct(a`gensym10: SomeInteger): PyStr 110 +nim bin _._/pystring/strbltins.html#bin,SomeInteger proc bin(a`gensym13: SomeInteger): PyStr 111 +nim hex _._/pystring/strbltins.html#hex,SomeInteger proc hex(a`gensym16: SomeInteger): PyStr 112 +nimgrp ascii _._/pystring/strbltins.html#ascii-procs-all proc 51 +nimgrp ascii _._/pystring/strbltins.html#ascii-templates-all template 75 diff --git a/Lib/_._/pystring/strimpl.html b/Lib/_._/pystring/strimpl.html new file mode 100644 index 000000000..255c6a15f --- /dev/null +++ b/Lib/_._/pystring/strimpl.html @@ -0,0 +1,777 @@ + + + + + + + +src/pylib/pystring/strimpl + + + + + + + + + + + + + + + + +
+
+

src/pylib/pystring/strimpl

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Types

+
+
+
PyStr = distinct string
+
+ + Python str, use func str to get an instance + Source   +Edit   + +
+
+
+
StringLike = string | char | PyStr
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
func `$`(self: PyStr): string {.borrow, ...raises: [], tags: [], forbids: [].}
+
+ + to Nim string + Source   +Edit   + +
+
+ +
+
+
+
func `+`(self: PyStr; s: PyStr): PyStr {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func `+`(self: PyStr; s: StringLike): PyStr
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func `+=`(mself; s: char) {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func `+=`(mself; s: PyStr) {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func `+=`(mself; s: string) {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func `==`(o: string; self: PyStr): bool {.borrow, ...raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func `==`(self: PyStr; o: PyStr): bool {.borrow, ...raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func `==`(self: PyStr; o: string): bool {.borrow, ...raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func `[]`(self: PyStr; i: HSlice[int, BackwardsIndex]): PyStr {....raises: [],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func `[]`(self: PyStr; i: int): PyStr {....raises: [], tags: [], forbids: [].}
+
+ + +

Example:

+
assert str("你好")[1] == str("好")

str.__getitem__(int)

+

i may be negative to index from backward.

+ + Source   +Edit   + +
+
+
+
func `[]`(self: PyStr; i: Slice[int]): PyStr {....raises: [], tags: [], forbids: [].}
+
+ + EXT. s[1..2] means s[1:3], and the latter is not valid Nim code + Source   +Edit   + +
+
+ +
+
+
+
func byteLen(self: PyStr): int {....raises: [], tags: [], forbids: [].}
+
+ + EXT. len of bytes + Source   +Edit   + +
+
+ +
+
+
+
func contains(s: PyStr; c: char): bool {.borrow.}
+
+ + + Source   +Edit   + +
+
+
+
func contains(s: PyStr; c: PyStr): bool {.borrow, ...raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func contains(s: PyStr; c: string): bool {.borrow, ...raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func fspath(self: PyStr): PyStr {....raises: [], tags: [], forbids: [].}
+
+ + make a PathLike + Source   +Edit   + +
+
+ +
+
+
+
func getChar(self: PyStr; i: Natural): char {....raises: [], tags: [], forbids: [].}
+
+ + EXT. get char by byte index. + Source   +Edit   + +
+
+ +
+
+
+
func len(c: char): int {....raises: [], tags: [], forbids: [].}
+
+ + len('c'), always returns 1 + Source   +Edit   + +
+
+
+
func len(self: PyStr): int {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func runeAtPos(self: PyStr; pos: int): Rune {.borrow, ...raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc runeLenAt(self: PyStr; i: Natural): int {.borrow, ...raises: [], tags: [],
+    forbids: [].}
+
+ + EXT. i is byte index + Source   +Edit   + +
+
+ +
+
+
+
func str(a: Rune): PyStr {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func str(c: char): PyStr {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func str(object = ""): PyStr {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func str(self: PyStr): PyStr {....raises: [], tags: [], forbids: [].}
+
+ + copy + Source   +Edit   + +
+
+ +
+
+
+
proc substr(self: PyStr; start, last: int): PyStr {.borrow, ...raises: [],
+    tags: [], forbids: [].}
+
+ + EXT. byte index + Source   +Edit   + +
+
+ +
+
+
+
func toNimStr(self: PyStr): string {....deprecated: "use toNimString instead. will be removed since 0.10",
+                                     raises: [], tags: [], forbids: [].}
+
+
+ Deprecated: use toNimString instead. will be removed since 0.10 +
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Iterators

+
+
+
+
iterator chars(self: PyStr): char {....raises: [], tags: [], forbids: [].}
+
+ + EXT. + Source   +Edit   + +
+
+ +
+
+
+
iterator items(self: PyStr): PyStr {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
iterator runes(self: PyStr): Rune {....raises: [], tags: [], forbids: [].}
+
+ + EXT. + Source   +Edit   + +
+
+ +
+ +
+
+
+

Converters

+
+
+
+
converter toNimString(self: PyStr): string {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
converter toPyStr(s: char): PyStr {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
converter toPyStr(s: Rune): PyStr {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
converter toPyStr(s: string): PyStr {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template `and`(a, b: PyStr): PyStr
+
+ + Mimics Python str and str -> str. Returns a if a is not empty, otherwise b (even if it's empty) + Source   +Edit   + +
+
+ +
+
+
+
template `not`(s: PyStr): bool
+
+ + +

Mimics Python not str -> bool.

"not" for strings, return true if the string is not nil or empty.

+ + Source   +Edit   + +
+
+ +
+
+
+
template `or`(a, b: PyStr): PyStr
+
+ + Mimics Python str or str -> str. Returns a if a is not empty, otherwise b (even if it's empty) + Source   +Edit   + +
+
+ +
+
+
+
template str[O: object](o: O): PyStr
+
+ + + Source   +Edit   + +
+
+
+
template str[T](a: T): PyStr
+
+ +

convert any object based on repr

+

This is alreadly a fallback, used for types without str defined.

+

In Python, if a object's type has no __str__, then it falls to use __repr__

+ + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/pystring/strimpl.idx b/Lib/_._/pystring/strimpl.idx new file mode 100644 index 000000000..5cee8f46f --- /dev/null +++ b/Lib/_._/pystring/strimpl.idx @@ -0,0 +1,53 @@ +nimTitle strimpl _._/pystring/strimpl.html module src/pylib/pystring/strimpl 0 +nim PyStr _._/pystring/strimpl.html#PyStr type PyStr 6 +nim StringLike _._/pystring/strimpl.html#StringLike type StringLike 8 +nim str _._/pystring/strimpl.html#str,PyStr proc str(self: PyStr): PyStr 10 +nim str _._/pystring/strimpl.html#str,string proc str(object = ""): PyStr 11 +nim str _._/pystring/strimpl.html#str,Rune proc str(a: Rune): PyStr 12 +nim str _._/pystring/strimpl.html#str,char proc str(c: char): PyStr 13 +nim str _._/pystring/strimpl.html#str.t,O template str[O: object](o: O): PyStr 15 +nim str _._/pystring/strimpl.html#str.t,T template str[T](a: T): PyStr 17 +nim `$` _._/pystring/strimpl.html#$ proc `$`(self: PyStr): string 30 +nim fspath _._/pystring/strimpl.html#fspath proc fspath(self: PyStr): PyStr 31 +nim toNimStr _._/pystring/strimpl.html#toNimStr proc toNimStr(self: PyStr): string 32 +nim toNimString _._/pystring/strimpl.html#toNimString.c converter toNimString(self: PyStr): string 34 +nim toPyStr _._/pystring/strimpl.html#toPyStr.c,string converter toPyStr(s: string): PyStr 35 +nim toPyStr _._/pystring/strimpl.html#toPyStr.c,char converter toPyStr(s: char): PyStr 36 +nim toPyStr _._/pystring/strimpl.html#toPyStr.c,Rune converter toPyStr(s: Rune): PyStr 37 +nim contains _._/pystring/strimpl.html#contains,PyStr,char proc contains(s: PyStr; c: char): bool 39 +nim contains _._/pystring/strimpl.html#contains,PyStr,string proc contains(s: PyStr; c: string): bool 40 +nim contains _._/pystring/strimpl.html#contains,PyStr,PyStr proc contains(s: PyStr; c: PyStr): bool 41 +nim `==` _._/pystring/strimpl.html#==,,PyStr proc `==`(self: PyStr; o: PyStr): bool 43 +nim `==` _._/pystring/strimpl.html#==,,string proc `==`(self: PyStr; o: string): bool 44 +nim `==` _._/pystring/strimpl.html#==,string, proc `==`(o: string; self: PyStr): bool 45 +nim `+` _._/pystring/strimpl.html#+,,PyStr proc `+`(self: PyStr; s: PyStr): PyStr 50 +nim `+` _._/pystring/strimpl.html#+,,StringLike proc `+`(self: PyStr; s: StringLike): PyStr 51 +nim `+=` _._/pystring/strimpl.html#+=,,PyStr proc `+=`(mself; s: PyStr) 53 +nim `+=` _._/pystring/strimpl.html#+=,,char proc `+=`(mself; s: char) 54 +nim `+=` _._/pystring/strimpl.html#+=,,string proc `+=`(mself; s: string) 55 +nim len _._/pystring/strimpl.html#len proc len(self: PyStr): int 57 +nim len _._/pystring/strimpl.html#len,char proc len(c: char): int 58 +nim byteLen _._/pystring/strimpl.html#byteLen proc byteLen(self: PyStr): int 59 +nim runeLenAt _._/pystring/strimpl.html#runeLenAt,,Natural proc runeLenAt(self: PyStr; i: Natural): int 60 +nim substr _._/pystring/strimpl.html#substr,,int,int proc substr(self: PyStr; start, last: int): PyStr 61 +nim runeAtPos _._/pystring/strimpl.html#runeAtPos,,int proc runeAtPos(self: PyStr; pos: int): Rune 62 +nim getChar _._/pystring/strimpl.html#getChar,,Natural proc getChar(self: PyStr; i: Natural): char 72 +nim `[]` _._/pystring/strimpl.html#[],,int proc `[]`(self: PyStr; i: int): PyStr 73 +nim `[]` _._/pystring/strimpl.html#[],,Slice[int] proc `[]`(self: PyStr; i: Slice[int]): PyStr 87 +nim `[]` _._/pystring/strimpl.html#[],,HSlice[int,BackwardsIndex] proc `[]`(self: PyStr; i: HSlice[int, BackwardsIndex]): PyStr 93 +nim items _._/pystring/strimpl.html#items.i iterator items(self: PyStr): PyStr 96 +nim chars _._/pystring/strimpl.html#chars.i iterator chars(self: PyStr): char 100 +nim runes _._/pystring/strimpl.html#runes.i iterator runes(self: PyStr): Rune 104 +nim `and` _._/pystring/strimpl.html#and.t,PyStr,PyStr template `and`(a, b: PyStr): PyStr 109 +nim `or` _._/pystring/strimpl.html#or.t,PyStr,PyStr template `or`(a, b: PyStr): PyStr 114 +nim `not` _._/pystring/strimpl.html#not.t,PyStr template `not`(s: PyStr): bool 119 +nimgrp == _._/pystring/strimpl.html#==-procs-all proc 43 +nimgrp str _._/pystring/strimpl.html#str-procs-all proc 10 +nimgrp + _._/pystring/strimpl.html#+-procs-all proc 50 +nimgrp contains _._/pystring/strimpl.html#contains-procs-all proc 39 +nimgrp [] _._/pystring/strimpl.html#[]-procs-all proc 73 +nimgrp len _._/pystring/strimpl.html#len-procs-all proc 57 +nimgrp += _._/pystring/strimpl.html#+=-procs-all proc 53 +nimgrp topystr _._/pystring/strimpl.html#toPyStr-converters-all converter 35 +nimgrp str _._/pystring/strimpl.html#str-templates-all template 15 +heading Mimics Python not str -> bool. _._/pystring/strimpl.html#mimics-python-not-str-minusgt-booldot Mimics Python not str -> bool. 0 diff --git a/Lib/_._/pystring/strip.html b/Lib/_._/pystring/strip.html new file mode 100644 index 000000000..f22dac805 --- /dev/null +++ b/Lib/_._/pystring/strip.html @@ -0,0 +1,187 @@ + + + + + + + +src/pylib/pystring/strip + + + + + + + + + + + + + + + + +
+
+

src/pylib/pystring/strip

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Imports

+
+ consts, strimpl +
+
+
+

Procs

+
+
+
+
func lstrip(self: PyStr): PyStr {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func lstrip(self: PyStr; chars: PyStr): PyStr {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func rstrip(self: PyStr): PyStr {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func rstrip(self: PyStr; chars: PyStr): PyStr {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func strip(self: PyStr): PyStr {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func strip(self: PyStr; chars: PyStr): PyStr {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/pystring/strip.idx b/Lib/_._/pystring/strip.idx new file mode 100644 index 000000000..7b1cf0902 --- /dev/null +++ b/Lib/_._/pystring/strip.idx @@ -0,0 +1,10 @@ +nimTitle strip _._/pystring/strip.html module src/pylib/pystring/strip 0 +nim strip _._/pystring/strip.html#strip,PyStr proc strip(self: PyStr): PyStr 24 +nim lstrip _._/pystring/strip.html#lstrip,PyStr proc lstrip(self: PyStr): PyStr 25 +nim rstrip _._/pystring/strip.html#rstrip,PyStr proc rstrip(self: PyStr): PyStr 26 +nim strip _._/pystring/strip.html#strip,PyStr,PyStr proc strip(self: PyStr; chars: PyStr): PyStr 29 +nim lstrip _._/pystring/strip.html#lstrip,PyStr,PyStr proc lstrip(self: PyStr; chars: PyStr): PyStr 31 +nim rstrip _._/pystring/strip.html#rstrip,PyStr,PyStr proc rstrip(self: PyStr; chars: PyStr): PyStr 33 +nimgrp lstrip _._/pystring/strip.html#lstrip-procs-all proc 25 +nimgrp strip _._/pystring/strip.html#strip-procs-all proc 24 +nimgrp rstrip _._/pystring/strip.html#rstrip-procs-all proc 26 diff --git a/Lib/_._/pystring/strmeth.html b/Lib/_._/pystring/strmeth.html new file mode 100644 index 000000000..4a0d150b7 --- /dev/null +++ b/Lib/_._/pystring/strmeth.html @@ -0,0 +1,864 @@ + + + + + + + +src/pylib/pystring/strmeth + + + + + + + + + + + + + + + + +
+
+

src/pylib/pystring/strmeth

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
func capitalize(a: PyStr): PyStr {....raises: [], tags: [], forbids: [].}
+
+ +

make the first character have title/upper case and the rest lower case.

+

changed when Python 3.8: the first character will have title case.

+

while Nim's unicode.capitalize only make the first character upper-case.

+ + Source   +Edit   + +
+
+ +
+
+
+
func casefold(a: PyStr): PyStr {....raises: [], tags: [], forbids: [].}
+
+ +
Admonition: +since Python 3.3
+

str.casefold()

+

str.lower() is used for most characters, but, for example, Cherokee letters is casefolded to their uppercase counterparts, and some will be converted to their normal case, e.g. "ß" -> "ss"

+ + Source   +Edit   + +
+
+ +
+
+
+
func center(a: PyStr; width: int; fillchar = ' '): PyStr {....raises: [], tags: [],
+    forbids: [].}
+
+ + Mimics Python str.center(width: int, fillchar: str=" ") -> str + Source   +Edit   + +
+
+
+
func center(a: PyStr; width: int; fillchar: PyStr): PyStr {....raises: [TypeError],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func count(a: PyStr; sub: PyStr): int {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func count(a: PyStr; sub: PyStr; start = 0; end: int): int {....raises: [],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func count(a: PyStr; sub: PyStr; start: int): int {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func endsWith(a: char; suffix: PyStr): bool {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func endsWith(a: PyStr; suffix: char): bool {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func endsWith[Suf: PyStr | tuple](a: PyStr; suffix: Suf; start, end: int): bool
+
+ + + Source   +Edit   + +
+
+
+
func endsWith[Suf: PyStr | tuple](a: PyStr; suffix: Suf; start: int): bool
+
+ + + Source   +Edit   + +
+
+
+
func endsWith[Tup: tuple](a: PyStr; suffix: Tup): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func expandtabs(a: PyStr; tabsize = 8): PyStr {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func find(a: PyStr; b: PyStr; start = 0; end = len(a)): int {....raises: [],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func index(a, b: PyStr; start = 0; end = len(a)): int {.
+    ...raises: [ValueError, Exception], tags: [RootEffect], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func isalpha(a: PyStr): bool {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func isascii(a: PyStr): bool {....raises: [], tags: [], forbids: [].}
+
+ +
Admonition: +since Python 3.7
+ + Source   +Edit   + +
+
+
+
func isascii(a: Rune): bool {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func islower(a: PyStr): bool {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func isspace(a: PyStr): bool {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func istitle(a: PyStr): bool {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func isupper(a: PyStr): bool {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func join[T](sep: PyStr; a: openArray[T]): PyStr
+
+ + Mimics Python join() -> string + Source   +Edit   + +
+
+ +
+
+
+
func ljust(a: PyStr; width: int; fillchar = ' '): PyStr {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func ljust(a: PyStr; width: int; fillchar: PyStr): PyStr {....raises: [TypeError],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func lower(a: PyStr): PyStr {....raises: [], tags: [], forbids: [].}
+
+ +

str.lower

+

not the same as Nim's unicode.toLower, see examples

+ +

Example:

+
import std/unicode
+let dotI = Rune 0x0130  # İ  (LATIN CAPITAL LETTER I WITH DOT ABOVE)
+assert str(dotI).lower() == "i\u0307"  ## i̇ (\u0207 is a upper dot)
+assert dotI.toLower() == Rune('i')
+ Source   +Edit   + +
+
+ +
+
+
+
func partition(a: PyStr; sep: PyStr): tuple[before, sep, after: PyStr] {.
+    ...raises: [ValueError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func removeprefix(a: PyStr; suffix: PyStr): PyStr {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func removesuffix(a: PyStr; suffix: PyStr): PyStr {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func replace(a: PyStr; sub, by: PyStr | char): PyStr
+
+ + + Source   +Edit   + +
+
+
+
func replace(a: PyStr; sub, by: PyStr | char; count: int): PyStr
+
+ +

str.replace(sub, by, count = -1)

+

count may be negative or zero.

+ + Source   +Edit   + +
+
+ +
+
+
+
func rfind(a: PyStr; b: PyStr; start = 0; end = len(a)): int {....raises: [],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func rindex(a, b: PyStr; start = 0; end = len(a)): int {.
+    ...raises: [ValueError, Exception], tags: [RootEffect], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func rjust(a: PyStr; width: int; fillchar = ' '): PyStr {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func rjust(a: PyStr; width: int; fillchar: PyStr): PyStr {....raises: [TypeError],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func rpartition(a: PyStr; sep: PyStr): tuple[before, sep, after: PyStr] {.
+    ...raises: [ValueError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func startsWith(a: char; suffix: PyStr): bool {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func startsWith(a: PyStr; suffix: char): bool {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func startsWith[Suf: PyStr | tuple](a: PyStr; suffix: Suf; start, end: int): bool
+
+ + + Source   +Edit   + +
+
+
+
func startsWith[Suf: PyStr | tuple](a: PyStr; suffix: Suf; start: int): bool
+
+ + + Source   +Edit   + +
+
+
+
func startsWith[Tup: tuple](a: PyStr; suffix: Tup): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func title(a: PyStr): PyStr {....raises: [], tags: [], forbids: [].}
+
+ +

str.title()

+

not the same as title proc in std/unicode, see example.

+ +

Example:

+
let s = "lj"  # \u01c9
+let u = str(s)
+assert u.title() == "Lj"  # \u01c8
+import std/unicode
+assert unicode.title(s) == "LJ"  # \u01c7
+ Source   +Edit   + +
+
+ +
+
+
+
func upper(a: PyStr): PyStr {....raises: [], tags: [], forbids: [].}
+
+ +

str.upper

+

not the same as Nim's unicode.toUpper, see examples

+ +

Example:

+
import std/unicode
+let a = "ᾷ"
+# GREEK SMALL LETTER ALPHA WITH PERISPOMENI AND YPOGEGRAMMENI
+assert str(a).upper() == "Α͂Ι"  # 3 chars
+assert a.toUpper() == a   # Nim just maps it as-is.
+# There is more examples... (101 characters in total)
+ Source   +Edit   + +
+
+ +
+
+
+
func zfill(a: PyStr; width: int): PyStr {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template `*`(a: StringLike; i: int): PyStr
+
+ + + Source   +Edit   + +
+
+
+
template `*`(i: int; a: StringLike): PyStr
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ + +
+
+ + +
+
+ + + diff --git a/Lib/_._/pystring/strmeth.idx b/Lib/_._/pystring/strmeth.idx new file mode 100644 index 000000000..d81f218a9 --- /dev/null +++ b/Lib/_._/pystring/strmeth.idx @@ -0,0 +1,56 @@ +nimTitle strmeth _._/pystring/strmeth.html module src/pylib/pystring/strmeth 0 +nim `*` _._/pystring/strmeth.html#*.t,StringLike,int template `*`(a: StringLike; i: int): PyStr 49 +nim `*` _._/pystring/strmeth.html#*.t,int,StringLike template `*`(i: int; a: StringLike): PyStr 52 +nim count _._/pystring/strmeth.html#count,PyStr,PyStr proc count(a: PyStr; sub: PyStr): int 56 +nim count _._/pystring/strmeth.html#count,PyStr,PyStr,int proc count(a: PyStr; sub: PyStr; start: int): int 59 +nim count _._/pystring/strmeth.html#count,PyStr,PyStr,int,int proc count(a: PyStr; sub: PyStr; start = 0; end: int): int 62 +nim casefold _._/pystring/strmeth.html#casefold,PyStr proc casefold(a: PyStr): PyStr 70 +nim lower _._/pystring/strmeth.html#lower,PyStr proc lower(a: PyStr): PyStr 95 +nim upper _._/pystring/strmeth.html#upper,PyStr proc upper(a: PyStr): PyStr 105 +nim title _._/pystring/strmeth.html#title,PyStr proc title(a: PyStr): PyStr 141 +nim capitalize _._/pystring/strmeth.html#capitalize,PyStr proc capitalize(a: PyStr): PyStr 162 +nim startsWith _._/pystring/strmeth.html#startsWith,PyStr,char proc startsWith(a: PyStr; suffix: char): bool 185 +nim startsWith _._/pystring/strmeth.html#startsWith,char,PyStr proc startsWith(a: char; suffix: PyStr): bool 187 +nim startsWith _._/pystring/strmeth.html#startsWith,PyStr,Tup proc startsWith[Tup: tuple](a: PyStr; suffix: Tup): bool 189 +nim startsWith _._/pystring/strmeth.html#startsWith,PyStr,Suf,int proc startsWith[Suf: PyStr | tuple](a: PyStr; suffix: Suf; start: int): bool 191 +nim startsWith _._/pystring/strmeth.html#startsWith,PyStr,Suf,int,int proc startsWith[Suf: PyStr | tuple](a: PyStr; suffix: Suf; start, end: int): bool 197 +nim endsWith _._/pystring/strmeth.html#endsWith,PyStr,char proc endsWith(a: PyStr; suffix: char): bool 185 +nim endsWith _._/pystring/strmeth.html#endsWith,char,PyStr proc endsWith(a: char; suffix: PyStr): bool 187 +nim endsWith _._/pystring/strmeth.html#endsWith,PyStr,Tup proc endsWith[Tup: tuple](a: PyStr; suffix: Tup): bool 189 +nim endsWith _._/pystring/strmeth.html#endsWith,PyStr,Suf,int proc endsWith[Suf: PyStr | tuple](a: PyStr; suffix: Suf; start: int): bool 191 +nim endsWith _._/pystring/strmeth.html#endsWith,PyStr,Suf,int,int proc endsWith[Suf: PyStr | tuple](a: PyStr; suffix: Suf; start, end: int): bool 198 +nim find _._/pystring/strmeth.html#find,PyStr,PyStr,int proc find(a: PyStr; b: PyStr; start = 0; end = len(a)): int 200 +nim rfind _._/pystring/strmeth.html#rfind,PyStr,PyStr,int proc rfind(a: PyStr; b: PyStr; start = 0; end = len(a)): int 206 +nim index _._/pystring/strmeth.html#index,PyStr,PyStr,int proc index(a, b: PyStr; start = 0; end = len(a)): int 212 +nim rindex _._/pystring/strmeth.html#rindex,PyStr,PyStr,int proc rindex(a, b: PyStr; start = 0; end = len(a)): int 218 +nim isascii _._/pystring/strmeth.html#isascii,Rune proc isascii(a: Rune): bool 225 +nim isascii _._/pystring/strmeth.html#isascii,PyStr proc isascii(a: PyStr): bool 236 +nim isalpha _._/pystring/strmeth.html#isalpha,PyStr proc isalpha(a: PyStr): bool 239 +nim islower _._/pystring/strmeth.html#islower,PyStr proc islower(a: PyStr): bool 244 +nim isupper _._/pystring/strmeth.html#isupper,PyStr proc isupper(a: PyStr): bool 245 +nim istitle _._/pystring/strmeth.html#istitle,PyStr proc istitle(a: PyStr): bool 246 +nim isspace _._/pystring/strmeth.html#isspace,PyStr proc isspace(a: PyStr): bool 250 +nim center _._/pystring/strmeth.html#center,PyStr,int,char proc center(a: PyStr; width: int; fillchar = ' '): PyStr 252 +nim ljust _._/pystring/strmeth.html#ljust,PyStr,int,char proc ljust(a: PyStr; width: int; fillchar = ' '): PyStr 256 +nim rjust _._/pystring/strmeth.html#rjust,PyStr,int,char proc rjust(a: PyStr; width: int; fillchar = ' '): PyStr 258 +nim center _._/pystring/strmeth.html#center,PyStr,int,PyStr proc center(a: PyStr; width: int; fillchar: PyStr): PyStr 261 +nim ljust _._/pystring/strmeth.html#ljust,PyStr,int,PyStr proc ljust(a: PyStr; width: int; fillchar: PyStr): PyStr 264 +nim rjust _._/pystring/strmeth.html#rjust,PyStr,int,PyStr proc rjust(a: PyStr; width: int; fillchar: PyStr): PyStr 267 +nim zfill _._/pystring/strmeth.html#zfill,PyStr,int proc zfill(a: PyStr; width: int): PyStr 270 +nim removeprefix _._/pystring/strmeth.html#removeprefix,PyStr,PyStr proc removeprefix(a: PyStr; suffix: PyStr): PyStr 273 +nim removesuffix _._/pystring/strmeth.html#removesuffix,PyStr,PyStr proc removesuffix(a: PyStr; suffix: PyStr): PyStr 275 +nim replace _._/pystring/strmeth.html#replace,PyStr,, proc replace(a: PyStr; sub, by: PyStr | char): PyStr 278 +nim replace _._/pystring/strmeth.html#replace,PyStr,,,int proc replace(a: PyStr; sub, by: PyStr | char; count: int): PyStr 281 +nim expandtabs _._/pystring/strmeth.html#expandtabs,PyStr,int proc expandtabs(a: PyStr; tabsize = 8): PyStr 287 +nim join _._/pystring/strmeth.html#join,PyStr,openArray[T] proc join[T](sep: PyStr; a: openArray[T]): PyStr 290 +nim partition _._/pystring/strmeth.html#partition,PyStr,PyStr proc partition(a: PyStr; sep: PyStr): tuple[before, sep, after: PyStr] 294 +nim rpartition _._/pystring/strmeth.html#rpartition,PyStr,PyStr proc rpartition(a: PyStr; sep: PyStr): tuple[before, sep, after: PyStr] 297 +nimgrp replace _._/pystring/strmeth.html#replace-procs-all proc 278 +nimgrp startswith _._/pystring/strmeth.html#startsWith-procs-all proc 197 +nimgrp isascii _._/pystring/strmeth.html#isascii-procs-all proc 225 +nimgrp ljust _._/pystring/strmeth.html#ljust-procs-all proc 256 +nimgrp rjust _._/pystring/strmeth.html#rjust-procs-all proc 258 +nimgrp count _._/pystring/strmeth.html#count-procs-all proc 56 +nimgrp endswith _._/pystring/strmeth.html#endsWith-procs-all proc 198 +nimgrp center _._/pystring/strmeth.html#center-procs-all proc 252 +nimgrp * _._/pystring/strmeth.html#*-templates-all template 49 diff --git a/Lib/_._/pystring/strops.html b/Lib/_._/pystring/strops.html new file mode 100644 index 000000000..bc4018521 --- /dev/null +++ b/Lib/_._/pystring/strops.html @@ -0,0 +1,118 @@ + + + + + + + +src/pylib/pystring/strops + + + + + + + + + + + + + + + + +
+
+

src/pylib/pystring/strops

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Imports

+
+ strimpl +
+
+
+

Templates

+
+
+
+
template `<>`[A: StringLike; B: StringLike](a: A; b: B): bool
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/pystring/strops.idx b/Lib/_._/pystring/strops.idx new file mode 100644 index 000000000..3a8c02ca9 --- /dev/null +++ b/Lib/_._/pystring/strops.idx @@ -0,0 +1,2 @@ +nimTitle strops _._/pystring/strops.html module src/pylib/pystring/strops 0 +nim `<>` _._/pystring/strops.html#<>.t,A,B template `<>`[A: StringLike; B: StringLike](a: A; b: B): bool 7 diff --git a/Lib/_._/pystring/strprefix.html b/Lib/_._/pystring/strprefix.html new file mode 100644 index 000000000..731bf51a3 --- /dev/null +++ b/Lib/_._/pystring/strprefix.html @@ -0,0 +1,129 @@ + + + + + + + +src/pylib/pystring/strprefix + + + + + + + + + + + + + + + + +
+
+

src/pylib/pystring/strprefix

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
func u(a: char{lit}): PyStr {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func u(s: static[string]{lit}): PyStr
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/pystring/strprefix.idx b/Lib/_._/pystring/strprefix.idx new file mode 100644 index 000000000..3fbea92ec --- /dev/null +++ b/Lib/_._/pystring/strprefix.idx @@ -0,0 +1,4 @@ +nimTitle strprefix _._/pystring/strprefix.html module src/pylib/pystring/strprefix 0 +nim u _._/pystring/strprefix.html#u proc u(s: static[string]{lit}): PyStr 5 +nim u _._/pystring/strprefix.html#u_2 proc u(a: char{lit}): PyStr 9 +nimgrp u _._/pystring/strprefix.html#u-procs-all proc 5 diff --git a/Lib/_._/pystring/translate.html b/Lib/_._/pystring/translate.html new file mode 100644 index 000000000..919ee5161 --- /dev/null +++ b/Lib/_._/pystring/translate.html @@ -0,0 +1,396 @@ + + + + + + + +src/pylib/pystring/translate + + + + + + + + + + + + + + + + +
+
+

src/pylib/pystring/translate

+
+ +
+ Source   +Edit   + +
+ +

str.translate


+

NOTE: Nim's KeyError is a subclass of ValueError instead of LookupError. Therefore when writing a custom TranslateTableABC or TypedTranslateTableABC for translate, beware a Nim's KeyError is not considered as a sign to leave such a character untouched, but will be just raised outside.

+

However, TranslateTable or StrTypedTranslateTable is handled via overload. Using them as translate table is fine.

+

+ +
+

Types

+
+
+
StrTypedTranslateTable = TableRef[int, PyStr]
+
+ + result of str.maketrans(keys, values) + Source   +Edit   + +
+
+
+
TranslateAction {.pure.} = enum
+  skip, aOrd, aChr, aStr
+
+ + + Source   +Edit   + +
+
+
+
TranslateTable = TableRef[int, TranslateTableVal]
+
+ + result of maketrans + Source   +Edit   + +
+
+
+
TranslateTableABC = concept self
+    self[int] is TranslateTableVal
+
+ + + Source   +Edit   + +
+
+
+
TranslateTableVal = object
+  case
+  of skip:
+    nil
+  of aOrd:
+    i*: int
+  of aChr:
+    c*: char
+  of aStr:
+    s*: PyStr
+
+ + + Source   +Edit   + +
+
+
+
TranslateValType = int | PyStr | char | NoneType
+
+ + + Source   +Edit   + +
+
+
+
TypedTranslateTableABC[V] = concept self
+    V
+    self[int] is V
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
func repr(table: TranslateTable): string {....raises: [], tags: [], forbids: [].}
+
+ + dict stringification. + Source   +Edit   + +
+
+ +
+
+
+
proc translate(s: PyStr; table: StrTypedTranslateTable): PyStr {.
+    ...raises: [TypeError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc translate(s: PyStr; table: TranslateTable): PyStr {.
+    ...raises: [TypeError, ValueError, KeyError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc translate(s: PyStr; table: TranslateTableABC): PyStr
+
+ + + Source   +Edit   + +
+
+
+
proc translate[K: TranslateValType](s: PyStr; table: TypedTranslateTableABC[K]): PyStr
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Macros

+
+
+
+
macro maketrans(_: typedesc[PyStr]; mapOrLit: untyped): TranslateTable
+
+ + str.maketrans with dict literal or a mapping +

Example:

+
let tbl = PyStr.maketrans({"a": None, "b": "123"})
+assert "axb".translate(tbl) == "x123"
+ Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template `$`(table: TranslateTable): string
+
+ + repr table + Source   +Edit   + +
+
+ +
+
+
+
template maketrans(_: typedesc[PyStr]; frm, to): StrTypedTranslateTable
+
+ +

frm, to shall be string/PyStr.

+

see Nim#23662 for why this is not defined as a proc with typed param-types

+ + Source   +Edit   + +
+
+
+
template maketrans(_: typedesc[PyStr]; frm, to, skip): TranslateTable
+
+ +

frm, to, skip shall be string/PyStr.

+

see Nim#23662 for why this is not defined as a proc with typed param-types

+ + Source   +Edit   + +
+
+ +
+ +
+
+ + +
+
+ + +
+
+ + + diff --git a/Lib/_._/pystring/translate.idx b/Lib/_._/pystring/translate.idx new file mode 100644 index 000000000..de8c328c3 --- /dev/null +++ b/Lib/_._/pystring/translate.idx @@ -0,0 +1,19 @@ +nimTitle translate _._/pystring/translate.html module src/pylib/pystring/translate 0 +nim TranslateValType _._/pystring/translate.html#TranslateValType type TranslateValType 25 +nim TranslateAction _._/pystring/translate.html#TranslateAction enum TranslateAction 26 +nim TranslateTableVal _._/pystring/translate.html#TranslateTableVal object TranslateTableVal 28 +nim TranslateTableABC _._/pystring/translate.html#TranslateTableABC type TranslateTableABC 34 +nim TypedTranslateTableABC _._/pystring/translate.html#TypedTranslateTableABC type TypedTranslateTableABC 36 +nim TranslateTable _._/pystring/translate.html#TranslateTable type TranslateTable 40 +nim StrTypedTranslateTable _._/pystring/translate.html#StrTypedTranslateTable type StrTypedTranslateTable 41 +nim repr _._/pystring/translate.html#repr,TranslateTable proc repr(table: TranslateTable): string 53 +nim `$` _._/pystring/translate.html#$.t,TranslateTable template `$`(table: TranslateTable): string 71 +nim translate _._/pystring/translate.html#translate,PyStr,TranslateTable proc translate(s: PyStr; table: TranslateTable): PyStr 93 +nim translate _._/pystring/translate.html#translate,PyStr,StrTypedTranslateTable proc translate(s: PyStr; table: StrTypedTranslateTable): PyStr 101 +nim translate _._/pystring/translate.html#translate,PyStr,TypedTranslateTableABC[K: TranslateValType] proc translate[K: TranslateValType](s: PyStr; table: TypedTranslateTableABC[K]): PyStr 105 +nim translate _._/pystring/translate.html#translate,PyStr,TranslateTableABC proc translate(s: PyStr; table: TranslateTableABC): PyStr 113 +nim maketrans _._/pystring/translate.html#maketrans.m,typedesc[PyStr],untyped macro maketrans(_: typedesc[PyStr]; mapOrLit: untyped): TranslateTable 190 +nim maketrans _._/pystring/translate.html#maketrans.t,typedesc[PyStr],, template maketrans(_: typedesc[PyStr]; frm, to): StrTypedTranslateTable 201 +nim maketrans _._/pystring/translate.html#maketrans.t,typedesc[PyStr],,, template maketrans(_: typedesc[PyStr]; frm, to, skip): TranslateTable 214 +nimgrp translate _._/pystring/translate.html#translate-procs-all proc 93 +nimgrp maketrans _._/pystring/translate.html#maketrans-templates-all template 201 diff --git a/Lib/_._/pysugar/pywith.html b/Lib/_._/pysugar/pywith.html new file mode 100644 index 000000000..c6462d0a6 --- /dev/null +++ b/Lib/_._/pysugar/pywith.html @@ -0,0 +1,109 @@ + + + + + + + +src/pylib/pysugar/pywith + + + + + + + + + + + + + + + + +
+
+

src/pylib/pysugar/pywith

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Macros

+
+
+
+
macro with(args: varargs[untyped]): untyped
+
+ + Python-like with statement. Supports most of the possible variants Python with statement supports. Context managers are supported but need to use enter() and exit() or open() and close() instead of the underscored names. + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/pysugar/pywith.idx b/Lib/_._/pysugar/pywith.idx new file mode 100644 index 000000000..4b2b2951e --- /dev/null +++ b/Lib/_._/pysugar/pywith.idx @@ -0,0 +1,2 @@ +nimTitle pywith _._/pysugar/pywith.html module src/pylib/pysugar/pywith 0 +nim with _._/pysugar/pywith.html#with.m,varargs[untyped] macro with(args: varargs[untyped]): untyped 17 diff --git a/Lib/_._/stringlib/errHandle.html b/Lib/_._/stringlib/errHandle.html new file mode 100644 index 000000000..cfec355f1 --- /dev/null +++ b/Lib/_._/stringlib/errHandle.html @@ -0,0 +1,109 @@ + + + + + + + +src/pylib/stringlib/errHandle + + + + + + + + + + + + + + + + +
+
+

src/pylib/stringlib/errHandle

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Templates

+
+
+
+
template noEmptySep(sep)
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/stringlib/errHandle.idx b/Lib/_._/stringlib/errHandle.idx new file mode 100644 index 000000000..e6826ffbf --- /dev/null +++ b/Lib/_._/stringlib/errHandle.idx @@ -0,0 +1,2 @@ +nimTitle errHandle _._/stringlib/errHandle.html module src/pylib/stringlib/errHandle 0 +nim noEmptySep _._/stringlib/errHandle.html#noEmptySep.t template noEmptySep(sep) 2 diff --git a/Lib/_._/stringlib/format.html b/Lib/_._/stringlib/format.html new file mode 100644 index 000000000..e6ff6da69 --- /dev/null +++ b/Lib/_._/stringlib/format.html @@ -0,0 +1,163 @@ + + + + + + + +src/pylib/stringlib/format + + + + + + + + + + + + + + + + +
+
+

src/pylib/stringlib/format

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

str.format

+

NOTE: only str in Python has format method, not bytes nor bytearray.

+

+
+

Imports

+
+ formats +
+
+
+

Procs

+
+
+
+
proc pyformatImplAux(s: string; args: seq[NimNode]; kw: Kw): NimNode {.
+    ...raises: [ValueError, KeyError], tags: [], forbids: [].}
+
+ +

if -d:pylibUseFormatValue, use formatValue instead of format for formatting.

+

Convertion is not supported yet (like !r).

+ + Source   +Edit   + +
+
+ +
+ +
+
+
+

Macros

+
+
+
+
macro pyformat(s: static[string]; argKw: varargs[untyped]): string
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Exports

+
+ format, format +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/stringlib/format.idx b/Lib/_._/stringlib/format.idx new file mode 100644 index 000000000..6403dbd51 --- /dev/null +++ b/Lib/_._/stringlib/format.idx @@ -0,0 +1,3 @@ +nimTitle format _._/stringlib/format.html module src/pylib/stringlib/format 0 +nim pyformatImplAux _._/stringlib/format.html#pyformatImplAux,string,seq[NimNode],Kw proc pyformatImplAux(s: string; args: seq[NimNode]; kw: Kw): NimNode 43 +nim pyformat _._/stringlib/format.html#pyformat.m,static[string],varargs[untyped] macro pyformat(s: static[string]; argKw: varargs[untyped]): string 132 diff --git a/Lib/_._/stringlib/formats.html b/Lib/_._/stringlib/formats.html new file mode 100644 index 000000000..93ef82dd1 --- /dev/null +++ b/Lib/_._/stringlib/formats.html @@ -0,0 +1,141 @@ + + + + + + + +src/pylib/stringlib/formats + + + + + + + + + + + + + + + + +
+
+

src/pylib/stringlib/formats

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Procs

+
+
+
+
func format(value: char; format_spec: string = ""): string {.
+    ...raises: [ValueError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template format[T](value: T; format_spec: string = ""): string
+
+ + wrapper of std/strformat formatValue + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/stringlib/formats.idx b/Lib/_._/stringlib/formats.idx new file mode 100644 index 000000000..ebd6b96dc --- /dev/null +++ b/Lib/_._/stringlib/formats.idx @@ -0,0 +1,3 @@ +nimTitle formats _._/stringlib/formats.html module src/pylib/stringlib/formats 0 +nim format _._/stringlib/formats.html#format.t,T,string template format[T](value: T; format_spec: string = ""): string 4 +nim format _._/stringlib/formats.html#format,char,string proc format(value: char; format_spec: string = ""): string 11 diff --git a/Lib/_._/stringlib/meth.html b/Lib/_._/stringlib/meth.html new file mode 100644 index 000000000..622a9ea47 --- /dev/null +++ b/Lib/_._/stringlib/meth.html @@ -0,0 +1,963 @@ + + + + + + + +src/pylib/stringlib/meth + + + + + + + + + + + + + + + + +
+
+

src/pylib/stringlib/meth

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
func center[S](a: S; width: int; fillchar = ' '): S
+
+ + Mimics Python str.center(width: int, fillchar: str=" ") -> str + Source   +Edit   + +
+
+
+
func center[S](a: S; width: int; fillchar: S = " "): S
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func count[S](a: S; sub: S): int
+
+ + + Source   +Edit   + +
+
+
+
func count[S](a: S; sub: S; start = 0; end: int): int
+
+ + + Source   +Edit   + +
+
+
+
func count[S](a: S; sub: S; start: int): int
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func endsWith[S; Suf: S | tuple](a: S; suffix: Suf; start, end: int): bool
+
+ + + Source   +Edit   + +
+
+
+
func endsWith[S; Suf: S | tuple](a: S; suffix: Suf; start: int): bool
+
+ + + Source   +Edit   + +
+
+
+
func endsWith[S; Tup: tuple](a: S; suffix: Tup): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func find[S; T](a: S; b: T; start = 0): int
+
+ + + Source   +Edit   + +
+
+
+
func find[S; T](a: S; b: T; start = 0; end: int): int
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func find1[S; T](a: S; b: T; start = 0): int
+
+ + b shall be one length long. + Source   +Edit   + +
+
+
+
func find1[S; T](a: S; b: T; start = 0; end: int): int
+
+ + b shall be one length long. + Source   +Edit   + +
+
+ +
+
+
+
func index[S; T](a: S; b: T; start = 0): int
+
+ + + Source   +Edit   + +
+
+
+
func index[S; T](a: S; b: T; start = 0; end: int): int
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func index1[S; T](a: S; b: T; start = 0): int
+
+ + + Source   +Edit   + +
+
+
+
func index1[S; T](a: S; b: T; start = 0; end: int): int
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func isalnum(c: char): bool {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func isalnum(s: string): bool {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func isalpha(c: char): bool {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func isalpha(s: string): bool {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func isascii(c: char): bool {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func isascii(s: string): bool {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func isdigit(c: char): bool {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func isdigit(s: string): bool {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func isspace(c: char): bool {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func isspace(s: string): bool {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func join[T, S](sep: S; a: openArray[T]): S
+
+ + Mimics Python join() -> string + Source   +Edit   + +
+
+
+
func join[T](sep: char; a: openArray[T]): string
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func ljust(a: string; width: int; fillchar = ' '): string {....raises: [],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func ljust[S](a: S; width: int; fillchar: S = " "): S
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func partition[S](a: S; sep: S): tuple[before, sep, after: S]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func removeprefix[S](a: S; suffix: S): S
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func removesuffix[S](a: S; suffix: S): S
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func replace[S](a: S; sub, by: char): S
+
+ + + Source   +Edit   + +
+
+
+
func replace[S](a: S; sub, by: char; count: int): S
+
+ + + Source   +Edit   + +
+
+
+
func replace[S](a: S; sub, by: S): S
+
+ + + Source   +Edit   + +
+
+
+
func replace[S](a: S; sub, by: S; count: int): S
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func rfind[S; T](a: S; b: T; start = 0): int
+
+ + + Source   +Edit   + +
+
+
+
func rfind[S; T](a: S; b: T; start = 0; end: int): int
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func rfind1[S; T](a: S; b: T; start = 0): int
+
+ + + Source   +Edit   + +
+
+
+
func rfind1[S; T](a: S; b: T; start = 0; end: int): int
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func rindex[S; T](a: S; b: T; start = 0): int
+
+ + + Source   +Edit   + +
+
+
+
func rindex[S; T](a: S; b: T; start = 0; end: int): int
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func rindex1[S; T](a: S; b: T; start = 0): int
+
+ + + Source   +Edit   + +
+
+
+
func rindex1[S; T](a: S; b: T; start = 0; end: int): int
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func rjust(a: string; width: int; fillchar = ' '): string {....raises: [],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func rjust[S](a: S; width: int; fillchar: S = " "): S
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func rpartition[S](a: S; sep: S): tuple[before, sep, after: S]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func startsWith[S; Suf: S | tuple](a: S; suffix: Suf; start, end: int): bool
+
+ + + Source   +Edit   + +
+
+
+
func startsWith[S; Suf: S | tuple](a: S; suffix: Suf; start: int): bool
+
+ + + Source   +Edit   + +
+
+
+
func startsWith[S; Tup: tuple](a: S; suffix: Tup): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func zfill(a: string; width: int): string {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func zfill(c: char; width: int): string {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template allAlpha(a, isWhat, isNotWhat: typed; iter, firstItemGetter)
+
+ + used as func body. e.g. func isupper(self: PyBytes): bool = self.allAlpha(isUpperAscii, isLowerAscii, items, [0]) + Source   +Edit   + +
+
+ +
+
+
+
template endsWith[S](a: char; suffix: S): bool
+
+ + + Source   +Edit   + +
+
+
+
template endsWith[S](a: S; suffix: char): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template expandtabsImpl[S](a: S; tabsize: int; strByteLen: int; iter): string
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template istitleImpl(a, isupper, islower: typed; iter, firstItemGetter)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template startsWith[S](a: char; suffix: S): bool
+
+ + + Source   +Edit   + +
+
+
+
template startsWith[S](a: S; suffix: char): bool
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/stringlib/meth.idx b/Lib/_._/stringlib/meth.idx new file mode 100644 index 000000000..6c681ab27 --- /dev/null +++ b/Lib/_._/stringlib/meth.idx @@ -0,0 +1,85 @@ +nimTitle meth _._/stringlib/meth.html module src/pylib/stringlib/meth 0 +nim count _._/stringlib/meth.html#count,S,S proc count[S](a: S; sub: S): int 13 +nim count _._/stringlib/meth.html#count,S,S,int proc count[S](a: S; sub: S; start: int): int 17 +nim count _._/stringlib/meth.html#count,S,S,int,int proc count[S](a: S; sub: S; start = 0; end: int): int 22 +nim startsWith _._/stringlib/meth.html#startsWith.t,S,char template startsWith[S](a: S; suffix: char): bool 27 +nim startsWith _._/stringlib/meth.html#startsWith.t,char,S template startsWith[S](a: char; suffix: S): bool 29 +nim startsWith _._/stringlib/meth.html#startsWith,S,Tup proc startsWith[S; Tup: tuple](a: S; suffix: Tup): bool 31 +nim startsWith _._/stringlib/meth.html#startsWith,S,Suf,int proc startsWith[S; Suf: S | tuple](a: S; suffix: Suf; start: int): bool 36 +nim startsWith _._/stringlib/meth.html#startsWith,S,Suf,int,int proc startsWith[S; Suf: S | tuple](a: S; suffix: Suf; start, end: int): bool 43 +nim endsWith _._/stringlib/meth.html#endsWith.t,S,char template endsWith[S](a: S; suffix: char): bool 27 +nim endsWith _._/stringlib/meth.html#endsWith.t,char,S template endsWith[S](a: char; suffix: S): bool 29 +nim endsWith _._/stringlib/meth.html#endsWith,S,Tup proc endsWith[S; Tup: tuple](a: S; suffix: Tup): bool 31 +nim endsWith _._/stringlib/meth.html#endsWith,S,Suf,int proc endsWith[S; Suf: S | tuple](a: S; suffix: Suf; start: int): bool 36 +nim endsWith _._/stringlib/meth.html#endsWith,S,Suf,int,int proc endsWith[S; Suf: S | tuple](a: S; suffix: Suf; start, end: int): bool 44 +nim find1 _._/stringlib/meth.html#find1,S,T,int proc find1[S; T](a: S; b: T; start = 0): int 47 +nim find1 _._/stringlib/meth.html#find1,S,T,int,int proc find1[S; T](a: S; b: T; start = 0; end: int): int 55 +nim rfind1 _._/stringlib/meth.html#rfind1,S,T,int,int proc rfind1[S; T](a: S; b: T; start = 0; end: int): int 65 +nim rfind1 _._/stringlib/meth.html#rfind1,S,T,int proc rfind1[S; T](a: S; b: T; start = 0): int 69 +nim find _._/stringlib/meth.html#find,S,T,int proc find[S; T](a: S; b: T; start = 0): int 73 +nim find _._/stringlib/meth.html#find,S,T,int,int proc find[S; T](a: S; b: T; start = 0; end: int): int 81 +nim rfind _._/stringlib/meth.html#rfind,S,T,int proc rfind[S; T](a: S; b: T; start = 0): int 73 +nim rfind _._/stringlib/meth.html#rfind,S,T,int,int proc rfind[S; T](a: S; b: T; start = 0; end: int): int 82 +nim index1 _._/stringlib/meth.html#index1,S,T,int,int proc index1[S; T](a: S; b: T; start = 0; end: int): int 87 +nim index1 _._/stringlib/meth.html#index1,S,T,int proc index1[S; T](a: S; b: T; start = 0): int 90 +nim index _._/stringlib/meth.html#index,S,T,int,int proc index[S; T](a: S; b: T; start = 0; end: int): int 92 +nim index _._/stringlib/meth.html#index,S,T,int proc index[S; T](a: S; b: T; start = 0): int 95 +nim rindex1 _._/stringlib/meth.html#rindex1,S,T,int,int proc rindex1[S; T](a: S; b: T; start = 0; end: int): int 98 +nim rindex1 _._/stringlib/meth.html#rindex1,S,T,int proc rindex1[S; T](a: S; b: T; start = 0): int 101 +nim rindex _._/stringlib/meth.html#rindex,S,T,int,int proc rindex[S; T](a: S; b: T; start = 0; end: int): int 104 +nim rindex _._/stringlib/meth.html#rindex,S,T,int proc rindex[S; T](a: S; b: T; start = 0): int 107 +nim isascii _._/stringlib/meth.html#isascii,char proc isascii(c: char): bool 113 +nim isascii _._/stringlib/meth.html#isascii,string proc isascii(s: string): bool 114 +nim isalpha _._/stringlib/meth.html#isalpha,char proc isalpha(c: char): bool 131 +nim isalpha _._/stringlib/meth.html#isalpha,string proc isalpha(s: string): bool 134 +nim isspace _._/stringlib/meth.html#isspace,char proc isspace(c: char): bool 131 +nim isspace _._/stringlib/meth.html#isspace,string proc isspace(s: string): bool 135 +nim isdigit _._/stringlib/meth.html#isdigit,char proc isdigit(c: char): bool 131 +nim isdigit _._/stringlib/meth.html#isdigit,string proc isdigit(s: string): bool 136 +nim isalnum _._/stringlib/meth.html#isalnum,char proc isalnum(c: char): bool 131 +nim isalnum _._/stringlib/meth.html#isalnum,string proc isalnum(s: string): bool 137 +nim allAlpha _._/stringlib/meth.html#allAlpha.t,typed,typed,typed,, template allAlpha(a, isWhat, isNotWhat: typed; iter, firstItemGetter) 139 +nim istitleImpl _._/stringlib/meth.html#istitleImpl.t,typed,typed,typed,, template istitleImpl(a, isupper, islower: typed; iter, firstItemGetter) 155 +nim center _._/stringlib/meth.html#center,S,int,char proc center[S](a: S; width: int; fillchar = ' '): S 194 +nim ljust _._/stringlib/meth.html#ljust,string,int,char proc ljust(a: string; width: int; fillchar = ' '): string 199 +nim rjust _._/stringlib/meth.html#rjust,string,int,char proc rjust(a: string; width: int; fillchar = ' '): string 201 +nim center _._/stringlib/meth.html#center,S,int,S proc center[S](a: S; width: int; fillchar: S = " "): S 213 +nim ljust _._/stringlib/meth.html#ljust,S,int,S proc ljust[S](a: S; width: int; fillchar: S = " "): S 217 +nim rjust _._/stringlib/meth.html#rjust,S,int,S proc rjust[S](a: S; width: int; fillchar: S = " "): S 222 +nim zfill _._/stringlib/meth.html#zfill,char,int proc zfill(c: char; width: int): string 227 +nim zfill _._/stringlib/meth.html#zfill,string,int proc zfill(a: string; width: int): string 236 +nim removeprefix _._/stringlib/meth.html#removeprefix,S,S proc removeprefix[S](a: S; suffix: S): S 254 +nim removesuffix _._/stringlib/meth.html#removesuffix,S,S proc removesuffix[S](a: S; suffix: S): S 258 +nim replace _._/stringlib/meth.html#replace,S,char,char proc replace[S](a: S; sub, by: char): S 263 +nim replace _._/stringlib/meth.html#replace,S,S,S proc replace[S](a: S; sub, by: S): S 265 +nim replace _._/stringlib/meth.html#replace,S,char,char,int proc replace[S](a: S; sub, by: char; count: int): S 268 +nim replace _._/stringlib/meth.html#replace,S,S,S,int proc replace[S](a: S; sub, by: S; count: int): S 272 +nim expandtabsImpl _._/stringlib/meth.html#expandtabsImpl.t,S,int,int, template expandtabsImpl[S](a: S; tabsize: int; strByteLen: int; iter): string 322 +nim join _._/stringlib/meth.html#join,char,openArray[T] proc join[T](sep: char; a: openArray[T]): string 328 +nim join _._/stringlib/meth.html#join,S,openArray[T] proc join[T, S](sep: S; a: openArray[T]): S 331 +nim partition _._/stringlib/meth.html#partition,S,S proc partition[S](a: S; sep: S): tuple[before, sep, after: S] 344 +nim rpartition _._/stringlib/meth.html#rpartition,S,S proc rpartition[S](a: S; sep: S): tuple[before, sep, after: S] 345 +nimgrp join _._/stringlib/meth.html#join-procs-all proc 328 +nimgrp rindex _._/stringlib/meth.html#rindex-procs-all proc 104 +nimgrp find1 _._/stringlib/meth.html#find1-procs-all proc 47 +nimgrp rfind _._/stringlib/meth.html#rfind-procs-all proc 82 +nimgrp replace _._/stringlib/meth.html#replace-procs-all proc 263 +nimgrp index1 _._/stringlib/meth.html#index1-procs-all proc 87 +nimgrp startswith _._/stringlib/meth.html#startsWith-procs-all proc 43 +nimgrp isdigit _._/stringlib/meth.html#isdigit-procs-all proc 136 +nimgrp index _._/stringlib/meth.html#index-procs-all proc 92 +nimgrp isascii _._/stringlib/meth.html#isascii-procs-all proc 113 +nimgrp isspace _._/stringlib/meth.html#isspace-procs-all proc 135 +nimgrp rfind1 _._/stringlib/meth.html#rfind1-procs-all proc 65 +nimgrp ljust _._/stringlib/meth.html#ljust-procs-all proc 199 +nimgrp rjust _._/stringlib/meth.html#rjust-procs-all proc 201 +nimgrp count _._/stringlib/meth.html#count-procs-all proc 13 +nimgrp isalpha _._/stringlib/meth.html#isalpha-procs-all proc 134 +nimgrp endswith _._/stringlib/meth.html#endsWith-procs-all proc 44 +nimgrp isalnum _._/stringlib/meth.html#isalnum-procs-all proc 137 +nimgrp rindex1 _._/stringlib/meth.html#rindex1-procs-all proc 98 +nimgrp zfill _._/stringlib/meth.html#zfill-procs-all proc 227 +nimgrp center _._/stringlib/meth.html#center-procs-all proc 194 +nimgrp find _._/stringlib/meth.html#find-procs-all proc 81 +nimgrp startswith _._/stringlib/meth.html#startsWith-templates-all template 43 +nimgrp endswith _._/stringlib/meth.html#endsWith-templates-all template 44 diff --git a/Lib/_._/stringlib/replaceWithCount.html b/Lib/_._/stringlib/replaceWithCount.html new file mode 100644 index 000000000..ff6a796c5 --- /dev/null +++ b/Lib/_._/stringlib/replaceWithCount.html @@ -0,0 +1,122 @@ + + + + + + + +src/pylib/stringlib/replaceWithCount + + + + + + + + + + + + + + + + +
+
+

src/pylib/stringlib/replaceWithCount

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

modified from std/strutils, adding count param

+
+

Procs

+
+
+
+
func replace(s: string; sub, by: char; count: Natural): string {....raises: [],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func replace(s: string; sub, by: string; count: Natural): string {....raises: [],
+    tags: [], forbids: [].}
+
+ + count must be Natural + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/stringlib/replaceWithCount.idx b/Lib/_._/stringlib/replaceWithCount.idx new file mode 100644 index 000000000..142eafa17 --- /dev/null +++ b/Lib/_._/stringlib/replaceWithCount.idx @@ -0,0 +1,4 @@ +nimTitle replaceWithCount _._/stringlib/replaceWithCount.html module src/pylib/stringlib/replaceWithCount 0 +nim replace _._/stringlib/replaceWithCount.html#replace,string,char,char,Natural proc replace(s: string; sub, by: char; count: Natural): string 6 +nim replace _._/stringlib/replaceWithCount.html#replace,string,string,string,Natural proc replace(s: string; sub, by: string; count: Natural): string 22 +nimgrp replace _._/stringlib/replaceWithCount.html#replace-procs-all proc 6 diff --git a/Lib/_._/stringlib/split/common.html b/Lib/_._/stringlib/split/common.html new file mode 100644 index 000000000..7d094b446 --- /dev/null +++ b/Lib/_._/stringlib/split/common.html @@ -0,0 +1,236 @@ + + + + + + + +src/pylib/stringlib/split/common + + + + + + + + + + + + + + + + +
+
+

src/pylib/stringlib/split/common

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Types

+
+
+
IsSpaceAt[S] = proc (s: S; pos: int): bool {.nosideEffect.}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Consts

+
+
+
DefSplitCap = 12
+
+ + + Source   +Edit   + +
+
+
+
STRINGLIB_MUTABLE = false
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
func norm_maxsplit(maxsplit: int; str_len, sep_len: int): int {....raises: [],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func suf--(i: var int): int {.inline, ...raises: [], tags: [], forbids: [].}
+
+ + i-- in C + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template norm_maxsplit(maxsplit: int; str_len): int
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template PREPARE_CAP(maxcount): int
+
+ + maxcount shall be Natural + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/stringlib/split/common.idx b/Lib/_._/stringlib/split/common.idx new file mode 100644 index 000000000..f0b5def7a --- /dev/null +++ b/Lib/_._/stringlib/split/common.idx @@ -0,0 +1,8 @@ +nimTitle common _._/stringlib/split/common.html module src/pylib/stringlib/split/common 0 +nim IsSpaceAt _._/stringlib/split/common.html#IsSpaceAt type IsSpaceAt 3 +nim suf-- _._/stringlib/split/common.html#suf--,int proc suf--(i: var int): int 5 +nim STRINGLIB_MUTABLE _._/stringlib/split/common.html#STRINGLIB_MUTABLE const STRINGLIB_MUTABLE 10 +nim norm_maxsplit _._/stringlib/split/common.html#norm_maxsplit.t,int, template norm_maxsplit(maxsplit: int; str_len): int 14 +nim DefSplitCap _._/stringlib/split/common.html#DefSplitCap const DefSplitCap 19 +nim PREPARE_CAP _._/stringlib/split/common.html#PREPARE_CAP.t template PREPARE_CAP(maxcount): int 22 +nim norm_maxsplit _._/stringlib/split/common.html#norm_maxsplit,int,int,int proc norm_maxsplit(maxsplit: int; str_len, sep_len: int): int 27 diff --git a/Lib/_._/stringlib/split/reimporter.html b/Lib/_._/stringlib/split/reimporter.html new file mode 100644 index 000000000..0740b0d53 --- /dev/null +++ b/Lib/_._/stringlib/split/reimporter.html @@ -0,0 +1,96 @@ + + + + + + + +src/pylib/stringlib/split/reimporter + + + + + + + + + + + + + + + + +
+
+

src/pylib/stringlib/split/reimporter

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+ +
+ + +
+
+ + + diff --git a/Lib/_._/stringlib/split/reimporter.idx b/Lib/_._/stringlib/split/reimporter.idx new file mode 100644 index 000000000..d8c2fefd3 --- /dev/null +++ b/Lib/_._/stringlib/split/reimporter.idx @@ -0,0 +1 @@ +nimTitle reimporter _._/stringlib/split/reimporter.html module src/pylib/stringlib/split/reimporter 0 diff --git a/Lib/_._/stringlib/split/rsplit_whitespace.html b/Lib/_._/stringlib/split/rsplit_whitespace.html new file mode 100644 index 000000000..038be9ca5 --- /dev/null +++ b/Lib/_._/stringlib/split/rsplit_whitespace.html @@ -0,0 +1,118 @@ + + + + + + + +src/pylib/stringlib/split/rsplit_whitespace + + + + + + + + + + + + + + + + +
+
+

src/pylib/stringlib/split/rsplit_whitespace

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
proc rsplit_whitespace[S](pystr: S; maxsplit = -1): PyList[S]
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/stringlib/split/rsplit_whitespace.idx b/Lib/_._/stringlib/split/rsplit_whitespace.idx new file mode 100644 index 000000000..8ad7126e9 --- /dev/null +++ b/Lib/_._/stringlib/split/rsplit_whitespace.idx @@ -0,0 +1,2 @@ +nimTitle rsplit_whitespace _._/stringlib/split/rsplit_whitespace.html module src/pylib/stringlib/split/rsplit_whitespace 0 +nim rsplit_whitespace _._/stringlib/split/rsplit_whitespace.html#rsplit_whitespace,S,int proc rsplit_whitespace[S](pystr: S; maxsplit = -1): PyList[S] 46 diff --git a/Lib/_._/stringlib/split/split_whitespace.html b/Lib/_._/stringlib/split/split_whitespace.html new file mode 100644 index 000000000..2a12302db --- /dev/null +++ b/Lib/_._/stringlib/split/split_whitespace.html @@ -0,0 +1,149 @@ + + + + + + + +src/pylib/stringlib/split/split_whitespace + + + + + + + + + + + + + + + + +
+
+

src/pylib/stringlib/split/split_whitespace

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
proc split_whitespace[S](pystr: S; maxsplit = -1): PyList[S]
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Iterators

+
+
+
+
iterator split_whitespace[S](pystr: S; maxsplit = -1): S
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/stringlib/split/split_whitespace.idx b/Lib/_._/stringlib/split/split_whitespace.idx new file mode 100644 index 000000000..6d31b3826 --- /dev/null +++ b/Lib/_._/stringlib/split/split_whitespace.idx @@ -0,0 +1,3 @@ +nimTitle split_whitespace _._/stringlib/split/split_whitespace.html module src/pylib/stringlib/split/split_whitespace 0 +nim split_whitespace _._/stringlib/split/split_whitespace.html#split_whitespace.i,S,int iterator split_whitespace[S](pystr: S; maxsplit = -1): S 46 +nim split_whitespace _._/stringlib/split/split_whitespace.html#split_whitespace,S,int proc split_whitespace[S](pystr: S; maxsplit = -1): PyList[S] 53 diff --git a/Lib/_._/stringlib/split/splitlinesIter.html b/Lib/_._/stringlib/split/splitlinesIter.html new file mode 100644 index 000000000..042d9e14e --- /dev/null +++ b/Lib/_._/stringlib/split/splitlinesIter.html @@ -0,0 +1,121 @@ + + + + + + + +src/pylib/stringlib/split/splitlinesIter + + + + + + + + + + + + + + + + +
+
+

src/pylib/stringlib/split/splitlinesIter

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

We cannot just use strutils.splitLines for str.splitlines, even nor for bytes.splitlines, as Python uses Univeral NewLine as sep.

+

See https://docs.python.org/3/glossary.html#term-universal-newlines

+

For a table of all Universal Newlines, see https://docs.python.org/3/library/stdtypes.html#str.splitlines

+

+
+

Imports

+
+ common +
+
+
+

Iterators

+
+
+
+
iterator splitlines[S](self: S; keepends = false): S
+
+ + mixin IS_CAR_NL, IS_LINEBREAK, [Slice], [int], len + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/stringlib/split/splitlinesIter.idx b/Lib/_._/stringlib/split/splitlinesIter.idx new file mode 100644 index 000000000..f20808080 --- /dev/null +++ b/Lib/_._/stringlib/split/splitlinesIter.idx @@ -0,0 +1,2 @@ +nimTitle splitlinesIter _._/stringlib/split/splitlinesIter.html module src/pylib/stringlib/split/splitlinesIter 0 +nim splitlines _._/stringlib/split/splitlinesIter.html#splitlines.i,S iterator splitlines[S](self: S; keepends = false): S 18 diff --git a/Lib/_._/translateEscape.html b/Lib/_._/translateEscape.html new file mode 100644 index 000000000..51a47149e --- /dev/null +++ b/Lib/_._/translateEscape.html @@ -0,0 +1,141 @@ + + + + + + + +src/pylib/translateEscape + + + + + + + + + + + + + + + + +
+
+

src/pylib/translateEscape

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Procs

+
+
+
+
func translateEscape(pattern: string): string {....raises: [], tags: [],
+    forbids: [].}
+
+ + like translateEscapeWithErr but without lineInfo error msg + Source   +Edit   + +
+
+ +
+ +
+
+
+

Macros

+
+
+
+
macro translateEscapeWithErr(pattern: string): string
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/translateEscape.idx b/Lib/_._/translateEscape.idx new file mode 100644 index 000000000..30d5f34c0 --- /dev/null +++ b/Lib/_._/translateEscape.idx @@ -0,0 +1,3 @@ +nimTitle translateEscape _._/translateEscape.html module src/pylib/translateEscape 0 +nim translateEscape _._/translateEscape.html#translateEscape,string proc translateEscape(pattern: string): string 228 +nim translateEscapeWithErr _._/translateEscape.html#translateEscapeWithErr.m,string macro translateEscapeWithErr(pattern: string): string 233 diff --git a/Lib/_._/version.html b/Lib/_._/version.html new file mode 100644 index 000000000..101856a08 --- /dev/null +++ b/Lib/_._/version.html @@ -0,0 +1,322 @@ + + + + + + + +src/pylib/version + + + + + + + + + + + + + + + + +
+
+

src/pylib/version

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Imports

+
+ versionInfo +
+
+
+

Consts

+
+
+
Version = "0.9.11"
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
func asVersion(v: (int, int)): string {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func asVersion(v: (int, int, int)): string {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func pysince[R](ver: static[float | MajorMinorVersion]; defExpr, elseExpr: R): R {.
+    inline.}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Macros

+
+
+
+
macro pysince(major, minor: static int; def)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
macro templWrapExportSincePy(major, minor: static int; sym: typed)
+
+ + generate template sym*(...): untyped = sym(...) + Source   +Edit   + +
+
+ +
+
+
+
macro wrapExportSincePy(major, minor: static int; sym: typed)
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template asVersion(major, minor, patch: int): string
+
+ + + Source   +Edit   + +
+
+
+
template asVersion(major, minor: int): string
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template exportSincePy(major, minor: int; sym: typed)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template pysince[R](ver: MajorMinorVersion; defExpr, elseExpr: R): R
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ + +
+
+ + +
+
+ + + diff --git a/Lib/_._/version.idx b/Lib/_._/version.idx new file mode 100644 index 000000000..5b5317589 --- /dev/null +++ b/Lib/_._/version.idx @@ -0,0 +1,14 @@ +nimTitle version _._/version.html module src/pylib/version 0 +nim asVersion _._/version.html#asVersion.t,int,int template asVersion(major, minor: int): string 3 +nim asVersion _._/version.html#asVersion.t,int,int,int template asVersion(major, minor, patch: int): string 6 +nim asVersion _._/version.html#asVersion proc asVersion(v: (int, int)): string 9 +nim asVersion _._/version.html#asVersion_2 proc asVersion(v: (int, int, int)): string 10 +nim Version _._/version.html#Version const Version 16 +nim exportSincePy _._/version.html#exportSincePy.t,int,int,typed template exportSincePy(major, minor: int; sym: typed) 17 +nim templWrapExportSincePy _._/version.html#templWrapExportSincePy.m,staticint,staticint,typed macro templWrapExportSincePy(major, minor: static int; sym: typed) 43 +nim pysince _._/version.html#pysince.m,staticint,staticint, macro pysince(major, minor: static int; def) 67 +nim wrapExportSincePy _._/version.html#wrapExportSincePy.m,staticint,staticint,typed macro wrapExportSincePy(major, minor: static int; sym: typed) 91 +nim pysince _._/version.html#pysince.t,MajorMinorVersion,R,R template pysince[R](ver: MajorMinorVersion; defExpr, elseExpr: R): R 109 +nim pysince _._/version.html#pysince,static[],R,R proc pysince[R](ver: static[float | MajorMinorVersion]; defExpr, elseExpr: R): R 123 +nimgrp asversion _._/version.html#asVersion-procs-all proc 9 +nimgrp asversion _._/version.html#asVersion-templates-all template 3 diff --git a/Lib/_._/versionInfo.html b/Lib/_._/versionInfo.html new file mode 100644 index 000000000..cf09697da --- /dev/null +++ b/Lib/_._/versionInfo.html @@ -0,0 +1,229 @@ + + + + + + + +src/pylib/versionInfo + + + + + + + + + + + + + + + + +
+
+

src/pylib/versionInfo

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

to be imported by ./version

+
+

Types

+
+
+
PyReleaseLevelEnum {.pure.} = enum
+  alpha = 10, beta = 11, gamma = 12, final = 15
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Consts

+
+
+
Major = 0
+
+ + + Source   +Edit   + +
+
+
+
Minor = 9
+
+ + + Source   +Edit   + +
+
+
+
Patch = 11
+
+ + + Source   +Edit   + +
+
+
+
PyMajor {.intdefine.} = 3
+
+ + + Source   +Edit   + +
+
+
+
PyMinor {.intdefine.} = 13
+
+ + + Source   +Edit   + +
+
+
+
PyPatch {.intdefine.} = 0
+
+ + + Source   +Edit   + +
+
+
+
PyReleaseLevel = PyReleaseLevelEnum.final
+
+ + + Source   +Edit   + +
+
+
+
PySerial = 0
+
+ + + Source   +Edit   + +
+
+
+
ReleaseLevel = "alpha"
+
+ + + Source   +Edit   + +
+
+
+
Serial = 0
+
+ + + Source   +Edit   + +
+
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/_._/versionInfo.idx b/Lib/_._/versionInfo.idx new file mode 100644 index 000000000..23df6f29e --- /dev/null +++ b/Lib/_._/versionInfo.idx @@ -0,0 +1,12 @@ +nimTitle versionInfo _._/versionInfo.html module src/pylib/versionInfo 0 +nim PyReleaseLevelEnum _._/versionInfo.html#PyReleaseLevelEnum enum PyReleaseLevelEnum 5 +nim Major _._/versionInfo.html#Major const Major 12 +nim Minor _._/versionInfo.html#Minor const Minor 13 +nim Patch _._/versionInfo.html#Patch const Patch 14 +nim ReleaseLevel _._/versionInfo.html#ReleaseLevel const ReleaseLevel 16 +nim Serial _._/versionInfo.html#Serial const Serial 17 +nim PyMajor _._/versionInfo.html#PyMajor const PyMajor 19 +nim PyMinor _._/versionInfo.html#PyMinor const PyMinor 20 +nim PyPatch _._/versionInfo.html#PyPatch const PyPatch 21 +nim PyReleaseLevel _._/versionInfo.html#PyReleaseLevel const PyReleaseLevel 22 +nim PySerial _._/versionInfo.html#PySerial const PySerial 23 diff --git a/Lib/antigravity.html b/Lib/antigravity.html new file mode 100644 index 000000000..a8ab0830d --- /dev/null +++ b/Lib/antigravity.html @@ -0,0 +1,75 @@ + + + + + + + +src/pylib/Lib/antigravity + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/antigravity

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ +
+
+ Source   +Edit   + +
+ +

+ +
+
+ + +
+
+ + + diff --git a/Lib/array.html b/Lib/array.html new file mode 100644 index 000000000..c4fa04d80 --- /dev/null +++ b/Lib/array.html @@ -0,0 +1,1330 @@ + + + + + + + +src/pylib/Lib/array + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/array

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

array

Hint: +considering unicode array is deprecated since Python3.3, and will be removed in Python3.16, it's not implemented
+
Hint: +since python3.13, 'w' (Py_UCS4) array is introduced. here we use Rune in std/unicode as its item type.
+XXX: the extend is used by array(c, ls), And Py_UCS4-array's extend is not generic, so it must be placed before array proc

+ +
+

Types

+
+
+
HasReadNRetBytesLike = concept self
+    self.read(int) is BytesLike
+
+ + + Source   +Edit   + +
+
+
+
HasWriteBytesLike = concept self
+    self.write(BytesLike)
+
+ + + Source   +Edit   + +
+
+
+
Py_UCS4 = Rune
+
+ + inner + Source   +Edit   + +
+
+
+
PyArray[T] = distinct PyList[T]
+
+ + + Source   +Edit   + +
+
+
+
SomeChar = char | cschar | cuchar
+
+ + In C, char, unsigned char, signed char are three distinct types, that's, char is either signed or unsigned, which is implementation-dependent, unlike other integer types, e.g. int is alias of signed int + Source   +Edit   + +
+
+ +
+
+
+

Consts

+
+
+
typecodes = "bBuwhHiIlLqQfd"
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
func `$`(arr: PyArray[Py_UCS4]): string {.inline, ...raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func `$`[T](arr: PyArray[T]): string {.inline.}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func `<`[A, B](arr: PyArray[A]; other: PyArray[B]): bool {.inline.}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func `<=`[A, B](arr: PyArray[A]; other: PyArray[B]): bool {.inline.}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func `==`[A, B](arr: PyArray[A]; other: PyArray[B]): bool {.inline.}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func `@`[T](arr: PyArray[T]): seq[T] {.inline.}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func `[]=`(self: var PyArray[Py_UCS4]; i: int): PyStr {.inline, ...raises: [],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func `[]=`(self: var PyArray[Py_UCS4]; i: int; v: char) {.inline, ...raises: [],
+    tags: [], forbids: [].}
+
+ + +

Example:

+
from std/unicode import Rune
+var a = array('w', "123")
+a[0] = Rune(65)
+a[1] = '3'
+ Source   +Edit   + +
+
+
+
func `[]=`(self: var PyArray[Py_UCS4]; i: int; v: string) {.inline,
+    ...raises: [TypeError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func `[]=`[T](ms: var PyArray[T]; indices: Slice[int]; o: Sequence[T])
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func append(self: var PyArray[Py_UCS4]; s: PyStr) {.inline, ...raises: [TypeError],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func buffer_info[T](arr: PyArray[T]): tuple[address: int, length: int]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func byteswap[T](arr: var PyArray[T])
+
+ +

array.byteswap

+

Currently only compilable for c_* types, a.k.a. not for Nim's int*, e.g. int16

+
Hint: +trial of using this method on PyArray[int*] may lead to compile-error of C compiler.
+ +

Example:

+
when sizeof(cshort) == 2:
+  var arr = array('h', [1, 2])
+  arr.byteswap()
+  assert arr[0] == 256, $arr[0]  # int from \x01\x00
+  assert arr[1] == 512, $arr[1]
+ Source   +Edit   + +
+
+ +
+
+
+
func delitem(ms: var PyArray; indices: PySlice)
+
+ + + Source   +Edit   + +
+
+
+
func delitem(ms: var PyArray; indices: Slice[int])
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func extend(self: var PyArray[Py_UCS4]; s: PyStr) {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func frombytes[C: SomeChar](arr: var PyArray[C]; buffer: BytesLike)
+
+ + append byte from buffer to arr + Source   +Edit   + +
+
+
+
func frombytes[T: not SomeChar](arr: var PyArray[T]; buffer: BytesLike)
+
+ + append byte from buffer to arr +

Example:

+
when sizeof(cshort) == 2:
+  var h = array('h', [1, 2])
+  h.frombytes(b"\x05\x00")
+  when cpuEndian == littleEndian:
+    assert h[2] == 5
+  else:
+    assert h[2] == 1280
+ Source   +Edit   + +
+
+ +
+
+
+
func fromfile[T](arr: var PyArray[T]; f: File; n: int)
+
+ + This variant is optimitized for Nim's File + Source   +Edit   + +
+
+
+
func fromfile[T](self: var PyArray[T]; f: HasReadNRetBytesLike; n: int)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func fromlist[T](arr: var PyArray[T]; ls: PyList[T])
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func fromunicode(self: var PyArray[Py_UCS4]; s: PyStr) {.inline, ...raises: [],
+    tags: [], forbids: [].}
+
+ +
Note: +as PyArray here is static-typed, unlike CPython's, no ValueError will be raised
+ + Source   +Edit   + +
+
+ +
+
+
+
func getPtr[T](arr: sink PyArray[T]; i: Natural | BackwardsIndex): ptr T {.
+    inline.}
+
+ + EXT. unstable. + Source   +Edit   + +
+
+ +
+
+
+
func len[T](arr: PyArray[T]): int
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func newPyArray[T](len = 0): PyArray[T] {.inline.}
+
+ + + Source   +Edit   + +
+
+
+
func newPyArray[T](x: Iterable[T]): PyArray[T] {.inline.}
+
+ + unlike array, when x is a literal, type conversion is always needed. +

Example:

+
discard newPyArray[cint]([1.cint, 2])
+# or write: array('i', [1, 2])
+ Source   +Edit   + +
+
+ +
+
+
+
func newPyArrayOfCap[T](cap: int): PyArray[T] {.inline.}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func repr[T](arr: PyArray[T]): string
+
+ + alias for $arr + Source   +Edit   + +
+
+ +
+
+
+
func setLen[T](arr: var PyArray[T]; n: int)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func tobytes[C: SomeChar](arr: PyArray[C]): PyBytes
+
+ + + Source   +Edit   + +
+
+
+
func tobytes[T: not SomeChar](arr: PyArray[T]): PyBytes
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func tofile[T](arr: var PyArray[T]; f: File)
+
+ + This variant is optimitized for Nim's File + Source   +Edit   + +
+
+
+
func tofile[T](self: PyArray[T]; f: HasWriteBytesLike)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func tolist[T](arr: PyArray[T]): PyList[T]
+
+ + + Source   +Edit   + +
+
+
+
func tolist[T](arr: var PyArray[T]): var PyList[T]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func tounicode(arr: PyArray[Py_UCS4]): PyStr {.inline, ...raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Iterators

+
+
+
+
iterator items[T](arr: PyArray[T]): T
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
iterator mitems[T](arr: var PyArray[T]): var T
+
+ + EXT. +

Example:

+
var arr = array('i', [1, 2])
+for i in arr.mitems:
+  i *= 2
+assert arr == array('i', [2, 4])
+ Source   +Edit   + +
+
+ +
+ +
+
+
+

Macros

+
+
+
+
macro array(typecode: static[char]): PyArray
+
+ + +

Example:

+
var a = array('i')
+assert a.typecode == 'i'
+assert len(a) == 0
+a.append(3)
+assert a.len == 1 and a[0] == 3
+ Source   +Edit   + +
+
+
+
macro array(typecode: static[char]; initializer: typed): PyArray
+
+ +

bytes or bytearray, a Unicode string, or iterable over elements of the appropriate type.

+

initializer can be a bracket stmt, no need to manually add type convert, see examples

+ +

Example:

+
assert array('i', [1, 2])[1] == c_int(2)
+assert array('b', b"123")[2] == c_schar('3')
+ Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template `*=`[T](arr: PyArray[T]; n: int)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template `+=`[T](arr: PyArray[T]; x: untyped)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template `[]`[T](arr: PyArray[T]; i: int): T
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template `[]=`[T](arr: PyArray[T]; i: int; val: T)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template append[T](arr: PyArray[T]; x: T)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template clear[T](arr: PyArray[T])
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template contains[T](arr: PyArray[T]; x: T): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template delitem[T](arr: PyArray[T]; n: int)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template extend[T](arr: PyArray[T]; x: untyped)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template insert[T](arr: PyArray[T]; x: T)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template items[T](arr: PyArray[T]): untyped
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template itemsize[T](arr: PyArray[T]): int
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template pop[T](arr: PyArray[T])
+
+ + + Source   +Edit   + +
+
+
+
template pop[T](arr: PyArray[T]; i: int)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template remove[T](arr: PyArray[T]; x: T)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template reverse[T](arr: PyArray[T])
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template typecode(_: PyArray[cdouble]): char
+
+ + + Source   +Edit   + +
+
+
+
template typecode(_: PyArray[cfloat]): char
+
+ + + Source   +Edit   + +
+
+
+
template typecode(_: PyArray[cint]): char
+
+ + + Source   +Edit   + +
+
+
+
template typecode(_: PyArray[clong]): char
+
+ + + Source   +Edit   + +
+
+
+
template typecode(_: PyArray[clonglong]): char
+
+ + + Source   +Edit   + +
+
+
+
template typecode(_: PyArray[cschar]): char
+
+ + + Source   +Edit   + +
+
+
+
template typecode(_: PyArray[cshort]): char
+
+ + + Source   +Edit   + +
+
+
+
template typecode(_: PyArray[cuchar]): char
+
+ + + Source   +Edit   + +
+
+
+
template typecode(_: PyArray[cuint]): char
+
+ + + Source   +Edit   + +
+
+
+
template typecode(_: PyArray[culong]): char
+
+ + + Source   +Edit   + +
+
+
+
template typecode(_: PyArray[culonglong]): char
+
+ + + Source   +Edit   + +
+
+
+
template typecode(_: PyArray[cushort]): char
+
+ + + Source   +Edit   + +
+
+
+
template typecode(_: PyArray[Py_UCS4]): char
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ + +
+
+ + +
+
+ + + diff --git a/Lib/bisect.html b/Lib/bisect.html new file mode 100644 index 000000000..648227a16 --- /dev/null +++ b/Lib/bisect.html @@ -0,0 +1,230 @@ + + + + + + + +src/pylib/Lib/bisect + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/bisect

+
+ +
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
proc bisect[T; K](a: Sequence[T]; x: K; lo = 0; hi = len(a);
+                  key: NoneType | Key[T, K] = None): int
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc bisect_left[T; K](a: Sequence[T]; x: K; lo = 0; hi = len(a);
+                       key: NoneType | Key[T, K] = None): int
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc bisect_right[T; K](a: Sequence[T]; x: K; lo = 0; hi = len(a);
+                        key: NoneType | Key[T, K] = None): int
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc insort[T; K](a: MutableSequence[T]; x: K; lo = 0; hi = len(a);
+                  key: NoneType | Key[T, K] = None)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc insort_left[T; K](a: MutableSequence[T]; x: K; lo = 0; hi = len(a);
+                       key: NoneType | Key[T, K] = None)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc insort_right[T; K](a: MutableSequence[T]; x: K; lo = 0; hi = len(a);
+                        key: NoneType | Key[T, K] = None)
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ + +
+
+ + +
+
+ + + diff --git a/Lib/builtins.html b/Lib/builtins.html new file mode 100644 index 000000000..9ad11b2f2 --- /dev/null +++ b/Lib/builtins.html @@ -0,0 +1,96 @@ + + + + + + + +src/pylib/Lib/builtins + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/builtins

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Imports

+
+ builtins +
+
+
+

Exports

+
+ min, upper, center, <=, maketrans, repr, min, float, rindex, -=, ==, -, find, ascii, count, int, len, +=, partition, fr, reversed, endsWith, maketrans, checkLenientOps, msg, float, items, osErrorMsgWithPath, min, bytes, remove, slice, raiseExcWithPath, str, clear, filter, [], rindex, format, TranslateTableVal, id, PyByteArray, <=, ==, repr, isdigit, zip, round, print, ==, PyFrozenSet, getPtr, [], byteLen, ascii, rstrip, replace, clear, repr, endsWith, count, indices, contains, ConnectionResetError, GeneratorExit, int, newPyOSError, TranslateTableABC, $, ==, slice, &, len, repr, iter, set, $, raiseErrno, zip, len, +=, bytearray, startsWith, dirImpl, $, toPyDict, max, pyrepr, reversed, <, chars, endsWith, hash, $, contains, pow, newPyList, toNimString, bytes, pydiscard, maketrans, PermissionError, isascii, count, msg, delitem, pyset, float, repr, sorted, items, [], imag=, TranslateValType, osErrorMsgWithPath, round, newPyList, raiseExcWithPath2, /, rstrip, **, *, $, items, lstrip, min, iter, and, clear, bytearray, [], pow, raiseExcWithPath, hasattr, set, *=, []=, rsplit, Fr, istitle, /, FileNotFoundError, map, count, -, min, -, len, setdefault, ==, contains, ==, PyComplex, len, startsWith, []=, real=, BytesLike, FileExistsError, substr, $, toPyStr, splitlines, +, PyDictItemView, split, islower, endsWith, +=, pop, rjust, join, upper, b, /, $, checked_as_integer_ratio, append, issubset, remove, +=, as_integer_ratio, ==, nextImpl, input, repr, newStopIteration, TranslateTable, IsADirectoryError, zip, PyTComplex, lower, <, pyset, isascii, or, round, *, newPyFrozenSet, PyOSError, *=, int, casefold, delitem, repr, +, PyRange, getattr, -, lower, ==, *, add, getattr, ==, newPySet, hex, union, split, ==, pybytes, str, pow, SomePyDictView, isinstance, **, hex, format, sort, difference, max, extend, rpartition, +=, <=, UnicodeError, delitem, symmetric_difference, ProcessLookupError, PyBytes, [], ArithmeticError, set, rb, bytearray, contains, [], split, intersection, symmetric_difference, isspace, str, ascii, mitems, startsWith, rstrip, isalpha, pow, imag, real, to_bytes, NoneType, +, **=, complex, title, replace, len, difference, endsWith, split, count, *, |=, []=, ==, +, repr, abs, errnoMsg, toPySlice, bit_length, b, splitlines, intersection, count, $, items, -=, runeAtPos, +, frozenset, union, ljust, pairs, max, min, PySlice, PyOSError, contains, ZeroDivisionError, <, ChildProcessError, startsWith, add_from_bytes, translate, TypeError, clear, NameError, items, center, dict, KeyboardInterrupt, rsplit, $, pop, +=, +=, int, toNimStr, max, getCharPtr, TypedTranslateTableABC, SomeSinglePyDictView, items, index, isdisjoint, delitem, PyList, NotADirectoryError, symmetric_difference, NotImplementedError, ord1, max, newPyListOfCap, <=, ascii, $, -=, bit_count, int, delitem, reversed, items, hash, slice, [], format, [], delitem, set, iter, chars, repr, Rb, pycomplex, sorted, +, tryOsOp, iter, bytearray, pow, ==, []=, PyDictView, str, repr, min, reverse, PyDictKeyView, rjust, as_integer_ratio, &=, <, casefold, repr, startsWith, frozenset, split, isupper, istitle, max, +=, symmetric_difference, set, bytearray, intersection, hasChar, startsWith, difference_update, oct, +, difference, index, +, SomePySet, partition, +, StopAsyncIteration, toPyDict, index, max, center, int, <, pow, str, rjust, startsWith, reversed, +, isalpha, <, newBlockingIOError, pow, chars, hash, <=, complex, conjugate, discard, br, translate, newUnicodeDecodeError, hash, hash, hash, get, [], reverse, hex, pysetLit, dir, PyDict, bytes, TimeoutError, ljust, TranslateAction, ord, to_chars, toNimComplex, pow, find, complex, is_integer, next, rf, []=, +, StringLike, newPyListOfStr, newPyList, /=, contains, **, endsWith, toNimString, translate, bytes, SomeSet, newUnicodeDecodeError, replace, float_fromhex, removeprefix, toPyBytes, len, sorted, hash, maketrans, newPyList, map, hex, get, Comparable, [], rsplit, <, int, list, PyIterator, count, range, *, update, chr, endsWith, complex, filter, removesuffix, delitem, dir, StopIteration, []=, J, pyset, []=, float, union, count, bytes, ==, rsplit, repr, getattr, popitem, newPyIterator, +, replace, items, contains, newPyOSError, $, repr, ljust, [], ord, **, $, toPyStr, byteLen, pow, copy, newPyList, len, /=, InterruptedError, /, $, @, nextImpl, newStopIteration, startsWith, isascii, *=, +, *, endsWith, pow, **, sort, rpartition, getCharPtr, isspace, as_someinteger_ratio, to_bytes, complex, count, $, splitlines, frozenset, is_integer, items, $, expandtabs, from_bytes, items, AttributeError, Rf, tryOsOp, -=, ==, lstrip, ==, +, []=, []=, frozenset, RuntimeError, PyDictValueView, union, rstrip, runes, StrTypedTranslateTable, newBlockingIOError, not, contains, None, bytes, ljust, find, newPyListOfStr, intersection_update, values, endsWith, UnicodeDecodeError, rsplit, list, range, zfill, min, bytearray, contains, **, endsWith, PyOSError, issuperset, |, from_bytes, tryOsOp, Br, noWeirdTarget, toNimString, raiseExcWithPath, keys, [], bytes, toNimSlice, list, pow, fromhex, translate, raiseExcWithPath, bytes, list, bytes, enumerate, <=, setattr, -, enumerate, 'j, long, filter, round, getChar, *=, newPyByteArray, []=, setattr, rfind, -, union, startsWith, items, split, <=, substr, ConnectionRefusedError, translate, bin, BlockingIOError, copy, u, set, PySlice1, difference, strip, StopIterationT, long, removeprefix, frozenset, *, insert, issubclass, rindex, center, raiseErrnoT, str, filter, /, round, split, $, nimArrayAsList, dirImpl, getChar, ConnectionError, hash, toNimString, count, *=, repr, contains, newPyList, lstrip, -, hasattr, strip, map, capitalize, len, []=, pop, split, +=, pop, append, +=, rfind, pyset, newPyFrozenSet, int, or, capitalize, ==, -, hex, extend, BlockingIOError, items, contains, title, *, intersection, min, [], tryOsOp, +=, items, ==, iter, emptyPyDict, pycomplex, <=, items, substr, PyStr, <, len, isupper, max, index, startsWith, BrokenPipeError, index, int, rjust, hash, conjugate, translate, reverse, next, runeLenAt, /=, list, BlockingIOError, PyLibKey, update, []=, count, getattr, newPyByteArray, range, $, toPyStr, copy, @, u, *, |=, splitlines, expandtabs, ==, ==, not, values, hex, rsplit, |, zfill, keys, fromhex, raiseErrnoWithPath, long, getChar, strip, rfind, strip, newPySet, symmetric_difference, <, removesuffix, islower, lstrip, pop, PySet, extend, <>, ConnectionAbortedError, setLen, intersection, SystemExit, +=, items, iter, max, hash, [], fspath, []=, newPyByteArray, *, j, pop, <=, frozenset, long, f, pyset, join, difference, translate, NimInt, fspath, *, ^, items, nimint, insert +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/cmath.html b/Lib/cmath.html new file mode 100644 index 000000000..a8dbb03a0 --- /dev/null +++ b/Lib/cmath.html @@ -0,0 +1,462 @@ + + + + + + + +src/pylib/Lib/cmath + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/cmath

+
+ +
+ Source   +Edit   + +
+ +

Lib/cmath

+

complex math library for Python's complex

+

+
+

Imports

+
+ complex, n_math +
+
+
+

Consts

+
+
+
infj: PyComplex = (re: 0.0, im: inf)
+
+ + + Source   +Edit   + +
+
+
+
nanj: PyComplex = (re: 0.0, im: nan)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
func isclose(a, b: Complex; rel_tol = 1e-9; abs_tol = 0.0): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func isfinite(z: PyTComplex): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func isnan(z: PyTComplex): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func log[T](z: PyTComplex[T]): PyTComplex[T]
+
+ + ln(z) + Source   +Edit   + +
+
+
+
func log[T](z: PyTComplex[T]; base: SomeNumber | PyTComplex[T]): PyTComplex[T]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func rect[T](r, phi: T): PyTComplex[T]
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template acos(x: PyTComplex): untyped
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template acosh(x: PyTComplex): untyped
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template asin(x: PyTComplex): untyped
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template asinh(x: PyTComplex): untyped
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template atan(x: PyTComplex): untyped
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template atanh(x: PyTComplex): untyped
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template exp(z: PyTComplex): PyTComplex
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template log10(z: PyTComplex): PyTComplex
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template phase(z: PyTComplex): PyTComplex
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template polar(z: PyTComplex): PyTComplex
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template sin(z: PyTComplex): PyTComplex
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template sqrt(z: PyTComplex): PyTComplex
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Exports

+
+ pi, e, tau, inf, nan +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/collections/abc.html b/Lib/collections/abc.html new file mode 100644 index 000000000..3b26d2006 --- /dev/null +++ b/Lib/collections/abc.html @@ -0,0 +1,96 @@ + + + + + + + +src/pylib/Lib/collections/abc + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/collections/abc

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+ +
+ + +
+
+ + + diff --git a/Lib/collections/abc.idx b/Lib/collections/abc.idx new file mode 100644 index 000000000..85a1fb9c2 --- /dev/null +++ b/Lib/collections/abc.idx @@ -0,0 +1 @@ +nimTitle abc collections/abc.html module src/pylib/Lib/collections/abc 0 diff --git a/Lib/datetime.html b/Lib/datetime.html new file mode 100644 index 000000000..0a51a8769 --- /dev/null +++ b/Lib/datetime.html @@ -0,0 +1,312 @@ + + + + + + + +src/pylib/Lib/datetime + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/datetime

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
func `==`(delta: timedelta; n: NoneType): bool {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func `==`(tzinfo: tzinfo; n: NoneType): bool {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func ctime(self: datetime): PyStr {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func isoformat(self: datetime; sep: StringLike = 'T'; timespec = "auto"): PyStr
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func str(self: datetime): PyStr {....raises: [ValueError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func str(self: timedelta): PyStr {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func strftime(self: datetime; format: PyStr): PyStr {....raises: [ValueError],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func tzname(dt: datetime): OptionalObj[PyStr] {....raises: [NotImplementedError],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Methods

+
+
+
+
method tzname(tz: timezone; dt: datetime): PyStr {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
method tzname(tz: tzinfo; dt: datetime): PyStr {.base,
+    ...raises: [NotImplementedError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Converters

+
+
+
+
converter noneToTzInfo(_: NoneType): tzinfo {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ + +
+
+ + +
+
+ + + diff --git a/Lib/datetime.idx b/Lib/datetime.idx new file mode 100644 index 000000000..0edc71259 --- /dev/null +++ b/Lib/datetime.idx @@ -0,0 +1,15 @@ +nimTitle datetime datetime.html module src/pylib/Lib/datetime 0 +nim tzname datetime.html#tzname.e,tzinfo,datetime method tzname(tz: tzinfo; dt: datetime): PyStr 13 +nim tzname datetime.html#tzname.e,timezone,datetime method tzname(tz: timezone; dt: datetime): PyStr 15 +nim tzname datetime.html#tzname,datetime proc tzname(dt: datetime): OptionalObj[PyStr] 17 +nim strftime datetime.html#strftime,,PyStr proc strftime(self: datetime; format: PyStr): PyStr 21 +nim isoformat datetime.html#isoformat,,StringLike,string proc isoformat(self: datetime; sep: StringLike = 'T'; timespec = "auto"): PyStr 22 +nim str datetime.html#str proc str(self: datetime): PyStr 34 +nim str datetime.html#str,timedelta proc str(self: timedelta): PyStr 35 +nim ctime datetime.html#ctime proc ctime(self: datetime): PyStr 36 +nim `==` datetime.html#==,tzinfo,NoneType proc `==`(tzinfo: tzinfo; n: NoneType): bool 38 +nim `==` datetime.html#==,timedelta,NoneType proc `==`(delta: timedelta; n: NoneType): bool 39 +nim noneToTzInfo datetime.html#noneToTzInfo.c,NoneType converter noneToTzInfo(_: NoneType): tzinfo 41 +nimgrp == datetime.html#==-procs-all proc 38 +nimgrp str datetime.html#str-procs-all proc 34 +nimgrp tzname datetime.html#tzname-methods-all method 13 diff --git a/Lib/datetime_impl/consts.html b/Lib/datetime_impl/consts.html new file mode 100644 index 000000000..5ebd83dc8 --- /dev/null +++ b/Lib/datetime_impl/consts.html @@ -0,0 +1,96 @@ + + + + + + + +src/pylib/Lib/datetime_impl/consts + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/datetime_impl/consts

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Exports

+
+ MAXYEAR, MINYEAR, UTC +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/datetime_impl/consts.idx b/Lib/datetime_impl/consts.idx new file mode 100644 index 000000000..78946d168 --- /dev/null +++ b/Lib/datetime_impl/consts.idx @@ -0,0 +1 @@ +nimTitle consts datetime_impl/consts.html module src/pylib/Lib/datetime_impl/consts 0 diff --git a/Lib/datetime_impl/datetime_impl.html b/Lib/datetime_impl/datetime_impl.html new file mode 100644 index 000000000..e431bfafd --- /dev/null +++ b/Lib/datetime_impl/datetime_impl.html @@ -0,0 +1,96 @@ + + + + + + + +src/pylib/Lib/datetime_impl/datetime_impl + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/datetime_impl/datetime_impl

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+ +
+ + +
+
+ + + diff --git a/Lib/datetime_impl/datetime_impl.idx b/Lib/datetime_impl/datetime_impl.idx new file mode 100644 index 000000000..9de46b849 --- /dev/null +++ b/Lib/datetime_impl/datetime_impl.idx @@ -0,0 +1 @@ +nimTitle datetime_impl datetime_impl/datetime_impl.html module src/pylib/Lib/datetime_impl/datetime_impl 0 diff --git a/Lib/datetime_impl/datetime_impl/decl.html b/Lib/datetime_impl/datetime_impl/decl.html new file mode 100644 index 000000000..7950aca8e --- /dev/null +++ b/Lib/datetime_impl/datetime_impl/decl.html @@ -0,0 +1,96 @@ + + + + + + + +src/pylib/Lib/datetime_impl/datetime_impl/decl + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/datetime_impl/datetime_impl/decl

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+ +
+ + +
+
+ + + diff --git a/Lib/datetime_impl/datetime_impl/decl.idx b/Lib/datetime_impl/datetime_impl/decl.idx new file mode 100644 index 000000000..c05fe18bc --- /dev/null +++ b/Lib/datetime_impl/datetime_impl/decl.idx @@ -0,0 +1 @@ +nimTitle decl datetime_impl/datetime_impl/decl.html module src/pylib/Lib/datetime_impl/datetime_impl/decl 0 diff --git a/Lib/datetime_impl/datetime_impl/inner_decl.html b/Lib/datetime_impl/datetime_impl/inner_decl.html new file mode 100644 index 000000000..bc81482a7 --- /dev/null +++ b/Lib/datetime_impl/datetime_impl/inner_decl.html @@ -0,0 +1,374 @@ + + + + + + + +src/pylib/Lib/datetime_impl/datetime_impl/inner_decl + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/datetime_impl/datetime_impl/inner_decl

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Types

+
+
+
datetime = ref object
+  tzinfo*: tzinfo
+
+ + + Source   +Edit   + +
+
+
+
PyDatetime = datetime
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
func asNimDatetime(self: datetime): DateTime {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func day(self: datetime): int {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func fold(self: datetime): int {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func hashcode(self: datetime): int {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func hashcode=(self: datetime; h: int) {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func hour(self: datetime): int {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func isfold(self: datetime): bool {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func microsecond(self: datetime): int {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func minute(self: datetime): int {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func month(self: datetime): int {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func newDatetime(dt: DateTime; tzinfo: tzinfo = nil; isfold = false): datetime {.
+    ...raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc newDatetime(self: datetime; tzinfo: tzinfo = self.tzinfo;
+                 isfold = self.isfold): datetime {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func second(self: datetime): int {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func year(self: datetime): int {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/datetime_impl/datetime_impl/inner_decl.idx b/Lib/datetime_impl/datetime_impl/inner_decl.idx new file mode 100644 index 000000000..3696d451a --- /dev/null +++ b/Lib/datetime_impl/datetime_impl/inner_decl.idx @@ -0,0 +1,18 @@ +nimTitle inner_decl datetime_impl/datetime_impl/inner_decl.html module src/pylib/Lib/datetime_impl/datetime_impl/inner_decl 0 +nim datetime datetime_impl/datetime_impl/inner_decl.html#datetime type datetime 6 +nim PyDatetime datetime_impl/datetime_impl/inner_decl.html#PyDatetime type PyDatetime 11 +nim newDatetime datetime_impl/datetime_impl/inner_decl.html#newDatetime,DateTime,tzinfo proc newDatetime(dt: DateTime; tzinfo: tzinfo = nil; isfold = false): datetime 13 +nim asNimDatetime datetime_impl/datetime_impl/inner_decl.html#asNimDatetime,datetime proc asNimDatetime(self: datetime): DateTime 16 +nim isfold datetime_impl/datetime_impl/inner_decl.html#isfold proc isfold(self: datetime): bool 19 +nim year datetime_impl/datetime_impl/inner_decl.html#year proc year(self: datetime): int 27 +nim month datetime_impl/datetime_impl/inner_decl.html#month proc month(self: datetime): int 28 +nim day datetime_impl/datetime_impl/inner_decl.html#day proc day(self: datetime): int 29 +nim hour datetime_impl/datetime_impl/inner_decl.html#hour proc hour(self: datetime): int 30 +nim minute datetime_impl/datetime_impl/inner_decl.html#minute proc minute(self: datetime): int 31 +nim second datetime_impl/datetime_impl/inner_decl.html#second proc second(self: datetime): int 32 +nim microsecond datetime_impl/datetime_impl/inner_decl.html#microsecond proc microsecond(self: datetime): int 34 +nim fold datetime_impl/datetime_impl/inner_decl.html#fold proc fold(self: datetime): int 35 +nim newDatetime datetime_impl/datetime_impl/inner_decl.html#newDatetime,datetime,tzinfo,bool proc newDatetime(self: datetime; tzinfo: tzinfo = self.tzinfo; isfold = self.isfold): datetime 37 +nim hashcode datetime_impl/datetime_impl/inner_decl.html#hashcode proc hashcode(self: datetime): int 49 +nim hashcode= datetime_impl/datetime_impl/inner_decl.html#hashcode=,,int proc hashcode=(self: datetime; h: int) 50 +nimgrp newdatetime datetime_impl/datetime_impl/inner_decl.html#newDatetime-procs-all proc 13 diff --git a/Lib/datetime_impl/datetime_impl/meth.html b/Lib/datetime_impl/datetime_impl/meth.html new file mode 100644 index 000000000..2e19e39de --- /dev/null +++ b/Lib/datetime_impl/datetime_impl/meth.html @@ -0,0 +1,96 @@ + + + + + + + +src/pylib/Lib/datetime_impl/datetime_impl/meth + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/datetime_impl/datetime_impl/meth

+ + + +
+
+ + + diff --git a/Lib/datetime_impl/datetime_impl/meth.idx b/Lib/datetime_impl/datetime_impl/meth.idx new file mode 100644 index 000000000..69ff84e18 --- /dev/null +++ b/Lib/datetime_impl/datetime_impl/meth.idx @@ -0,0 +1 @@ +nimTitle meth datetime_impl/datetime_impl/meth.html module src/pylib/Lib/datetime_impl/datetime_impl/meth 0 diff --git a/Lib/datetime_impl/datetime_impl/meth/aszone.html b/Lib/datetime_impl/datetime_impl/meth/aszone.html new file mode 100644 index 000000000..0bfd731f5 --- /dev/null +++ b/Lib/datetime_impl/datetime_impl/meth/aszone.html @@ -0,0 +1,120 @@ + + + + + + + +src/pylib/Lib/datetime_impl/datetime_impl/meth/aszone + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/datetime_impl/datetime_impl/meth/aszone

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
proc astimezone(self: datetime; tz = TzNone): datetime {....raises: [ValueError,
+    PyOSError, UnicodeDecodeError, NotImplementedError, TypeError], tags: [],
+    forbids: [].}
+
+ + not the same as DateTime.inZone(Timezone) + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/datetime_impl/datetime_impl/meth/aszone.idx b/Lib/datetime_impl/datetime_impl/meth/aszone.idx new file mode 100644 index 000000000..2689cec68 --- /dev/null +++ b/Lib/datetime_impl/datetime_impl/meth/aszone.idx @@ -0,0 +1,2 @@ +nimTitle aszone datetime_impl/datetime_impl/meth/aszone.html module src/pylib/Lib/datetime_impl/datetime_impl/meth/aszone 0 +nim astimezone datetime_impl/datetime_impl/meth/aszone.html#astimezone,datetime proc astimezone(self: datetime; tz = TzNone): datetime 67 diff --git a/Lib/datetime_impl/datetime_impl/meth/calendar_utils.html b/Lib/datetime_impl/datetime_impl/meth/calendar_utils.html new file mode 100644 index 000000000..f5f681a83 --- /dev/null +++ b/Lib/datetime_impl/datetime_impl/meth/calendar_utils.html @@ -0,0 +1,255 @@ + + + + + + + +src/pylib/Lib/datetime_impl/datetime_impl/meth/calendar_utils + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/datetime_impl/datetime_impl/meth/calendar_utils

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

General calendrical helper functions

+

For each month ordinal in 1..12, the number of days in that month, and the number of days before that month in the same year. These are correct for non-leap years only.

+

+ +
+

Types

+
+
+
YMD = tuple[year, month, day: int]
+
+ + + Source   +Edit   + +
+
+
+
YWD = tuple[year, week, day: int]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
func days_before_month(year, month: int): int {....raises: [], tags: [],
+    forbids: [].}
+
+ + year, month -> number of days in year preceding first day of month + Source   +Edit   + +
+
+ +
+
+
+
proc iso_to_ymd(iso: YWD; ymd: var YMD) {....raises: [ValueError], tags: [],
+    forbids: [].}
+
+ + Year is bounded to 0 < year < 10000 because 9999-12-31 is (9999, 52, 5) + Source   +Edit   + +
+
+ +
+
+
+
proc iso_week1_monday(year: int): int {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc ord_to_ymd(ordinal: int; result: var YMD) {....raises: [], tags: [],
+    forbids: [].}
+
+ + ordinal -> year, month, day, considering 01-Jan-0001 as day 1. + Source   +Edit   + +
+
+ +
+
+
+
proc weekday(year, month, day: int): int {....raises: [], tags: [], forbids: [].}
+
+ + Day of week, where Monday==0, ..., Sunday==6. 1/1/1 was a Monday. + Source   +Edit   + +
+
+ +
+
+
+
func ymd_to_ord(year, month, day: int): int {....raises: [], tags: [], forbids: [].}
+
+ + year, month, day -> ordinal, considering 01-Jan-0001 as day 1. + Source   +Edit   + +
+
+
+
proc ymd_to_ord(ymd: YMD): int {....raises: [], tags: [], forbids: [].}
+
+ + year, month, day -> ordinal, considering 01-Jan-0001 as day 1. + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/datetime_impl/datetime_impl/meth/calendar_utils.idx b/Lib/datetime_impl/datetime_impl/meth/calendar_utils.idx new file mode 100644 index 000000000..9294673bd --- /dev/null +++ b/Lib/datetime_impl/datetime_impl/meth/calendar_utils.idx @@ -0,0 +1,11 @@ +nimTitle calendar_utils datetime_impl/datetime_impl/meth/calendar_utils.html module src/pylib/Lib/datetime_impl/datetime_impl/meth/calendar_utils 0 +nim days_before_month datetime_impl/datetime_impl/meth/calendar_utils.html#days_before_month,int,int proc days_before_month(year, month: int): int 20 +nim ymd_to_ord datetime_impl/datetime_impl/meth/calendar_utils.html#ymd_to_ord,int,int,int proc ymd_to_ord(year, month, day: int): int 40 +nim YMD datetime_impl/datetime_impl/meth/calendar_utils.html#YMD tuple YMD 53 +nim ord_to_ymd datetime_impl/datetime_impl/meth/calendar_utils.html#ord_to_ymd,int,YMD proc ord_to_ymd(ordinal: int; result: var YMD) 56 +nim ymd_to_ord datetime_impl/datetime_impl/meth/calendar_utils.html#ymd_to_ord,YMD proc ymd_to_ord(ymd: YMD): int 125 +nim weekday datetime_impl/datetime_impl/meth/calendar_utils.html#weekday,int,int,int proc weekday(year, month, day: int): int 129 +nim iso_week1_monday datetime_impl/datetime_impl/meth/calendar_utils.html#iso_week1_monday,int proc iso_week1_monday(year: int): int 133 +nim YWD datetime_impl/datetime_impl/meth/calendar_utils.html#YWD tuple YWD 147 +nim iso_to_ymd datetime_impl/datetime_impl/meth/calendar_utils.html#iso_to_ymd,YWD,YMD proc iso_to_ymd(iso: YWD; ymd: var YMD) 151 +nimgrp ymdtoord datetime_impl/datetime_impl/meth/calendar_utils.html#ymd_to_ord-procs-all proc 40 diff --git a/Lib/datetime_impl/datetime_impl/meth/consts.html b/Lib/datetime_impl/datetime_impl/meth/consts.html new file mode 100644 index 000000000..c0578d00f --- /dev/null +++ b/Lib/datetime_impl/datetime_impl/meth/consts.html @@ -0,0 +1,152 @@ + + + + + + + +src/pylib/Lib/datetime_impl/datetime_impl/meth/consts + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/datetime_impl/datetime_impl/meth/consts

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
func max(_: typedesc[datetime]): datetime
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func min(_: typedesc[datetime]): datetime
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func resolution(_: typedesc[datetime]): timedelta
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/datetime_impl/datetime_impl/meth/consts.idx b/Lib/datetime_impl/datetime_impl/meth/consts.idx new file mode 100644 index 000000000..c8342df55 --- /dev/null +++ b/Lib/datetime_impl/datetime_impl/meth/consts.idx @@ -0,0 +1,4 @@ +nimTitle consts datetime_impl/datetime_impl/meth/consts.html module src/pylib/Lib/datetime_impl/datetime_impl/meth/consts 0 +nim max datetime_impl/datetime_impl/meth/consts.html#max,typedesc[datetime] proc max(_: typedesc[datetime]): datetime 7 +nim min datetime_impl/datetime_impl/meth/consts.html#min,typedesc[datetime] proc min(_: typedesc[datetime]): datetime 8 +nim resolution datetime_impl/datetime_impl/meth/consts.html#resolution,typedesc[datetime] proc resolution(_: typedesc[datetime]): timedelta 9 diff --git a/Lib/datetime_impl/datetime_impl/meth/errno_decl.html b/Lib/datetime_impl/datetime_impl/meth/errno_decl.html new file mode 100644 index 000000000..61b1a68c8 --- /dev/null +++ b/Lib/datetime_impl/datetime_impl/meth/errno_decl.html @@ -0,0 +1,128 @@ + + + + + + + +src/pylib/Lib/datetime_impl/datetime_impl/meth/errno_decl + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/datetime_impl/datetime_impl/meth/errno_decl

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Vars

+
+
+
errno {.importc.}: cint
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Lets

+
+
+
EINVAL {.importc.}: cint
+
+ + + Source   +Edit   + +
+
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/datetime_impl/datetime_impl/meth/errno_decl.idx b/Lib/datetime_impl/datetime_impl/meth/errno_decl.idx new file mode 100644 index 000000000..993b5069f --- /dev/null +++ b/Lib/datetime_impl/datetime_impl/meth/errno_decl.idx @@ -0,0 +1,3 @@ +nimTitle errno_decl datetime_impl/datetime_impl/meth/errno_decl.html module src/pylib/Lib/datetime_impl/datetime_impl/meth/errno_decl 0 +nim errno datetime_impl/datetime_impl/meth/errno_decl.html#errno var errno 4 +nim EINVAL datetime_impl/datetime_impl/meth/errno_decl.html#EINVAL let EINVAL 5 diff --git a/Lib/datetime_impl/datetime_impl/meth/format_utcoffset.html b/Lib/datetime_impl/datetime_impl/meth/format_utcoffset.html new file mode 100644 index 000000000..89238d182 --- /dev/null +++ b/Lib/datetime_impl/datetime_impl/meth/format_utcoffset.html @@ -0,0 +1,122 @@ + + + + + + + +src/pylib/Lib/datetime_impl/datetime_impl/meth/format_utcoffset + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/datetime_impl/datetime_impl/meth/format_utcoffset

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
func add_format_utcoffset(s: var string; sep: string; tzinfo: tzinfo;
+                          tzinfoarg: datetime) {....raises: [], tags: [],
+    forbids: [].}
+
+ + tzinfo must not be nil + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/datetime_impl/datetime_impl/meth/format_utcoffset.idx b/Lib/datetime_impl/datetime_impl/meth/format_utcoffset.idx new file mode 100644 index 000000000..3dd306119 --- /dev/null +++ b/Lib/datetime_impl/datetime_impl/meth/format_utcoffset.idx @@ -0,0 +1,2 @@ +nimTitle format_utcoffset datetime_impl/datetime_impl/meth/format_utcoffset.html module src/pylib/Lib/datetime_impl/datetime_impl/meth/format_utcoffset 0 +nim add_format_utcoffset datetime_impl/datetime_impl/meth/format_utcoffset.html#add_format_utcoffset,string,string,tzinfo,datetime proc add_format_utcoffset(s: var string; sep: string; tzinfo: tzinfo;\n tzinfoarg: datetime) 10 diff --git a/Lib/datetime_impl/datetime_impl/meth/formats.html b/Lib/datetime_impl/datetime_impl/meth/formats.html new file mode 100644 index 000000000..c565ef4f6 --- /dev/null +++ b/Lib/datetime_impl/datetime_impl/meth/formats.html @@ -0,0 +1,137 @@ + + + + + + + +src/pylib/Lib/datetime_impl/datetime_impl/meth/formats + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/datetime_impl/datetime_impl/meth/formats

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
func format(self: datetime; format_spec = ""): string {....raises: [ValueError],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func formatValue(result: var string; value: datetime; specifier: string) {.
+    ...raises: [ValueError], tags: [], forbids: [].}
+
+ + for std/strformat's fmt + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/datetime_impl/datetime_impl/meth/formats.idx b/Lib/datetime_impl/datetime_impl/meth/formats.idx new file mode 100644 index 000000000..d8823c600 --- /dev/null +++ b/Lib/datetime_impl/datetime_impl/meth/formats.idx @@ -0,0 +1,3 @@ +nimTitle formats datetime_impl/datetime_impl/meth/formats.html module src/pylib/Lib/datetime_impl/datetime_impl/meth/formats 0 +nim formatValue datetime_impl/datetime_impl/meth/formats.html#formatValue,string,,string proc formatValue(result: var string; value: datetime; specifier: string) 7 +nim format datetime_impl/datetime_impl/meth/formats.html#format,,string proc format(self: datetime; format_spec = ""): string 15 diff --git a/Lib/datetime_impl/datetime_impl/meth/fromisoformat.html b/Lib/datetime_impl/datetime_impl/meth/fromisoformat.html new file mode 100644 index 000000000..0dc6cc381 --- /dev/null +++ b/Lib/datetime_impl/datetime_impl/meth/fromisoformat.html @@ -0,0 +1,119 @@ + + + + + + + +src/pylib/Lib/datetime_impl/datetime_impl/meth/fromisoformat + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/datetime_impl/datetime_impl/meth/fromisoformat

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
proc datetime_fromisoformat(dtstr: string): datetime {....raises: [ValueError],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/datetime_impl/datetime_impl/meth/fromisoformat.idx b/Lib/datetime_impl/datetime_impl/meth/fromisoformat.idx new file mode 100644 index 000000000..5efd8d43a --- /dev/null +++ b/Lib/datetime_impl/datetime_impl/meth/fromisoformat.idx @@ -0,0 +1,2 @@ +nimTitle fromisoformat datetime_impl/datetime_impl/meth/fromisoformat.html module src/pylib/Lib/datetime_impl/datetime_impl/meth/fromisoformat 0 +nim datetime_fromisoformat datetime_impl/datetime_impl/meth/fromisoformat.html#datetime_fromisoformat proc datetime_fromisoformat(dtstr: string): datetime 282 diff --git a/Lib/datetime_impl/datetime_impl/meth/getter.html b/Lib/datetime_impl/datetime_impl/meth/getter.html new file mode 100644 index 000000000..a071dd5c3 --- /dev/null +++ b/Lib/datetime_impl/datetime_impl/meth/getter.html @@ -0,0 +1,157 @@ + + + + + + + +src/pylib/Lib/datetime_impl/datetime_impl/meth/getter + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/datetime_impl/datetime_impl/meth/getter

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

See also: ./getter_requires_op ./getter_of_date

+ +
+

Procs

+
+
+
+
func dst(self: datetime): timedelta {....raises: [NotImplementedError, ValueError],
+                                      tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func tzname(self: datetime): string {....raises: [NotImplementedError], tags: [],
+                                      forbids: [].}
+
+ +
Hint: +this won't returns None, but may return a empty string
+ + Source   +Edit   + +
+
+ +
+
+
+
func utcoffset(self: datetime): timedelta {.
+    ...raises: [NotImplementedError, ValueError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/datetime_impl/datetime_impl/meth/getter.idx b/Lib/datetime_impl/datetime_impl/meth/getter.idx new file mode 100644 index 000000000..f5b8bcfb1 --- /dev/null +++ b/Lib/datetime_impl/datetime_impl/meth/getter.idx @@ -0,0 +1,4 @@ +nimTitle getter datetime_impl/datetime_impl/meth/getter.html module src/pylib/Lib/datetime_impl/datetime_impl/meth/getter 0 +nim utcoffset datetime_impl/datetime_impl/meth/getter.html#utcoffset proc utcoffset(self: datetime): timedelta 10 +nim dst datetime_impl/datetime_impl/meth/getter.html#dst proc dst(self: datetime): timedelta 14 +nim tzname datetime_impl/datetime_impl/meth/getter.html#tzname proc tzname(self: datetime): string 18 diff --git a/Lib/datetime_impl/datetime_impl/meth/getter_of_date.html b/Lib/datetime_impl/datetime_impl/meth/getter_of_date.html new file mode 100644 index 000000000..e2b2c6667 --- /dev/null +++ b/Lib/datetime_impl/datetime_impl/meth/getter_of_date.html @@ -0,0 +1,169 @@ + + + + + + + +src/pylib/Lib/datetime_impl/datetime_impl/meth/getter_of_date + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/datetime_impl/datetime_impl/meth/getter_of_date

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

date

+ +
+

Procs

+
+
+
+
func isocalendar(self: datetime): YWD {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func isoweekday(self: datetime): int {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func toordinal(self: datetime): int {....raises: [], tags: [], forbids: [].}
+
+ + date.toordinal() + Source   +Edit   + +
+
+ +
+
+
+
func weekday(self: datetime): int {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/datetime_impl/datetime_impl/meth/getter_of_date.idx b/Lib/datetime_impl/datetime_impl/meth/getter_of_date.idx new file mode 100644 index 000000000..e81c4be44 --- /dev/null +++ b/Lib/datetime_impl/datetime_impl/meth/getter_of_date.idx @@ -0,0 +1,5 @@ +nimTitle getter_of_date datetime_impl/datetime_impl/meth/getter_of_date.html module src/pylib/Lib/datetime_impl/datetime_impl/meth/getter_of_date 0 +nim toordinal datetime_impl/datetime_impl/meth/getter_of_date.html#toordinal proc toordinal(self: datetime): int 10 +nim weekday datetime_impl/datetime_impl/meth/getter_of_date.html#weekday proc weekday(self: datetime): int 14 +nim isoweekday datetime_impl/datetime_impl/meth/getter_of_date.html#isoweekday proc isoweekday(self: datetime): int 17 +nim isocalendar datetime_impl/datetime_impl/meth/getter_of_date.html#isocalendar proc isocalendar(self: datetime): YWD 21 diff --git a/Lib/datetime_impl/datetime_impl/meth/getter_requires_op.html b/Lib/datetime_impl/datetime_impl/meth/getter_requires_op.html new file mode 100644 index 000000000..0107fdc1a --- /dev/null +++ b/Lib/datetime_impl/datetime_impl/meth/getter_requires_op.html @@ -0,0 +1,119 @@ + + + + + + + +src/pylib/Lib/datetime_impl/datetime_impl/meth/getter_requires_op + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/datetime_impl/datetime_impl/meth/getter_requires_op

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
proc timestamp(self: datetime): float {....raises: [NotImplementedError,
+    ValueError, TypeError, PyOSError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/datetime_impl/datetime_impl/meth/getter_requires_op.idx b/Lib/datetime_impl/datetime_impl/meth/getter_requires_op.idx new file mode 100644 index 000000000..154c08ebd --- /dev/null +++ b/Lib/datetime_impl/datetime_impl/meth/getter_requires_op.idx @@ -0,0 +1,2 @@ +nimTitle getter_requires_op datetime_impl/datetime_impl/meth/getter_requires_op.html module src/pylib/Lib/datetime_impl/datetime_impl/meth/getter_requires_op 0 +nim timestamp datetime_impl/datetime_impl/meth/getter_requires_op.html#timestamp proc timestamp(self: datetime): float 13 diff --git a/Lib/datetime_impl/datetime_impl/meth/hashImpl.html b/Lib/datetime_impl/datetime_impl/meth/hashImpl.html new file mode 100644 index 000000000..e5b7bc8d8 --- /dev/null +++ b/Lib/datetime_impl/datetime_impl/meth/hashImpl.html @@ -0,0 +1,119 @@ + + + + + + + +src/pylib/Lib/datetime_impl/datetime_impl/meth/hashImpl + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/datetime_impl/datetime_impl/meth/hashImpl

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
proc hash(self: datetime): int {....raises: [NotImplementedError, ValueError],
+                                 tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/datetime_impl/datetime_impl/meth/hashImpl.idx b/Lib/datetime_impl/datetime_impl/meth/hashImpl.idx new file mode 100644 index 000000000..d158d645e --- /dev/null +++ b/Lib/datetime_impl/datetime_impl/meth/hashImpl.idx @@ -0,0 +1,2 @@ +nimTitle hashImpl datetime_impl/datetime_impl/meth/hashImpl.html module src/pylib/Lib/datetime_impl/datetime_impl/meth/hashImpl 0 +nim hash datetime_impl/datetime_impl/meth/hashImpl.html#hash,datetime proc hash(self: datetime): int 30 diff --git a/Lib/datetime_impl/datetime_impl/meth/importer.html b/Lib/datetime_impl/datetime_impl/meth/importer.html new file mode 100644 index 000000000..a2df34cb6 --- /dev/null +++ b/Lib/datetime_impl/datetime_impl/meth/importer.html @@ -0,0 +1,96 @@ + + + + + + + +src/pylib/Lib/datetime_impl/datetime_impl/meth/importer + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/datetime_impl/datetime_impl/meth/importer

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+ +
+ + +
+
+ + + diff --git a/Lib/datetime_impl/datetime_impl/meth/importer.idx b/Lib/datetime_impl/datetime_impl/meth/importer.idx new file mode 100644 index 000000000..4bfdf41d9 --- /dev/null +++ b/Lib/datetime_impl/datetime_impl/meth/importer.idx @@ -0,0 +1 @@ +nimTitle importer datetime_impl/datetime_impl/meth/importer.html module src/pylib/Lib/datetime_impl/datetime_impl/meth/importer 0 diff --git a/Lib/datetime_impl/datetime_impl/meth/init.html b/Lib/datetime_impl/datetime_impl/meth/init.html new file mode 100644 index 000000000..cc4b4a6cd --- /dev/null +++ b/Lib/datetime_impl/datetime_impl/meth/init.html @@ -0,0 +1,147 @@ + + + + + + + +src/pylib/Lib/datetime_impl/datetime_impl/meth/init + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/datetime_impl/datetime_impl/meth/init

+
+ +
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
proc datetime(year, month, day: int; hour = 0; minute = 0; second = 0;
+              microsecond = 0; tzinfo: tzinfo = nil; fold = 0): datetime {.
+    ...raises: [ValueError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc replace(self: datetime; year = self.year; month = self.month;
+             day = self.day; hour = self.hour; minute = self.minute;
+             second = self.second; microsecond = self.microsecond;
+             tzinfo = self.tzinfo; fold = 0): datetime {....raises: [ValueError],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/datetime_impl/datetime_impl/meth/init.idx b/Lib/datetime_impl/datetime_impl/meth/init.idx new file mode 100644 index 000000000..17288bf60 --- /dev/null +++ b/Lib/datetime_impl/datetime_impl/meth/init.idx @@ -0,0 +1,3 @@ +nimTitle init datetime_impl/datetime_impl/meth/init.html module src/pylib/Lib/datetime_impl/datetime_impl/meth/init 0 +nim datetime datetime_impl/datetime_impl/meth/init.html#datetime,int,int,int,int,int,int,int,tzinfo,int proc datetime(year, month, day: int; hour = 0; minute = 0; second = 0;\n microsecond = 0; tzinfo: tzinfo = nil; fold = 0): datetime 46 +nim replace datetime_impl/datetime_impl/meth/init.html#replace,datetime,ref tzinfo:ObjectType,int proc replace(self: datetime; year = self.year; month = self.month; day = self.day;\n hour = self.hour; minute = self.minute; second = self.second;\n microsecond = self.microsecond; tzinfo = self.tzinfo; fold = 0): datetime 70 diff --git a/Lib/datetime_impl/datetime_impl/meth/inner_consts.html b/Lib/datetime_impl/datetime_impl/meth/inner_consts.html new file mode 100644 index 000000000..9719c2437 --- /dev/null +++ b/Lib/datetime_impl/datetime_impl/meth/inner_consts.html @@ -0,0 +1,114 @@ + + + + + + + +src/pylib/Lib/datetime_impl/datetime_impl/meth/inner_consts + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/datetime_impl/datetime_impl/meth/inner_consts

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Consts

+
+
+
MAXYEAR = 9999
+
+ + + Source   +Edit   + +
+
+
+
MINYEAR = 1
+
+ + + Source   +Edit   + +
+
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/datetime_impl/datetime_impl/meth/inner_consts.idx b/Lib/datetime_impl/datetime_impl/meth/inner_consts.idx new file mode 100644 index 000000000..94050e765 --- /dev/null +++ b/Lib/datetime_impl/datetime_impl/meth/inner_consts.idx @@ -0,0 +1,3 @@ +nimTitle inner_consts datetime_impl/datetime_impl/meth/inner_consts.html module src/pylib/Lib/datetime_impl/datetime_impl/meth/inner_consts 0 +nim MAXYEAR datetime_impl/datetime_impl/meth/inner_consts.html#MAXYEAR const MAXYEAR 3 +nim MINYEAR datetime_impl/datetime_impl/meth/inner_consts.html#MINYEAR const MINYEAR 4 diff --git a/Lib/datetime_impl/datetime_impl/meth/isoformat.html b/Lib/datetime_impl/datetime_impl/meth/isoformat.html new file mode 100644 index 000000000..bb28e087d --- /dev/null +++ b/Lib/datetime_impl/datetime_impl/meth/isoformat.html @@ -0,0 +1,190 @@ + + + + + + + +src/pylib/Lib/datetime_impl/datetime_impl/meth/isoformat + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/datetime_impl/datetime_impl/meth/isoformat

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Types

+
+
+
IsoFormatTimespec {.pure.} = enum
+  auto, hours, minutes, seconds, milliseconds, microseconds
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
func `$`(self: datetime): string {....raises: [], tags: [], forbids: [].}
+
+ + datetime_str + Source   +Edit   + +
+
+ +
+
+
+
func isoformat(self: datetime; sep: char | string = "T"; timespec = "auto"): string
+
+ + + Source   +Edit   + +
+
+
+
func isoformat(self: datetime; sep: char | string; timespec: IsoFormatTimespec): string
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func repr(self: datetime): string {....raises: [], tags: [], forbids: [].}
+
+ + datetime_repr + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/datetime_impl/datetime_impl/meth/isoformat.idx b/Lib/datetime_impl/datetime_impl/meth/isoformat.idx new file mode 100644 index 000000000..b5741b3f9 --- /dev/null +++ b/Lib/datetime_impl/datetime_impl/meth/isoformat.idx @@ -0,0 +1,7 @@ +nimTitle isoformat datetime_impl/datetime_impl/meth/isoformat.html module src/pylib/Lib/datetime_impl/datetime_impl/meth/isoformat 0 +nim IsoFormatTimespec datetime_impl/datetime_impl/meth/isoformat.html#IsoFormatTimespec enum IsoFormatTimespec 9 +nim isoformat datetime_impl/datetime_impl/meth/isoformat.html#isoformat,,,IsoFormatTimespec proc isoformat(self: datetime; sep: char | string; timespec: IsoFormatTimespec): string 18 +nim isoformat datetime_impl/datetime_impl/meth/isoformat.html#isoformat,,string,string proc isoformat(self: datetime; sep: char | string = "T"; timespec = "auto"): string 49 +nim `$` datetime_impl/datetime_impl/meth/isoformat.html#$ proc `$`(self: datetime): string 53 +nim repr datetime_impl/datetime_impl/meth/isoformat.html#repr proc repr(self: datetime): string 57 +nimgrp isoformat datetime_impl/datetime_impl/meth/isoformat.html#isoformat-procs-all proc 18 diff --git a/Lib/datetime_impl/datetime_impl/meth/op.html b/Lib/datetime_impl/datetime_impl/meth/op.html new file mode 100644 index 000000000..4924e2a0e --- /dev/null +++ b/Lib/datetime_impl/datetime_impl/meth/op.html @@ -0,0 +1,203 @@ + + + + + + + +src/pylib/Lib/datetime_impl/datetime_impl/meth/op + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/datetime_impl/datetime_impl/meth/op

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
proc `+`(self: datetime; delta: timedelta): datetime {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc `-`(self: datetime; delta: timedelta): datetime {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc `-`(self: datetime; dt: datetime): timedelta {.
+    ...raises: [NotImplementedError, ValueError, TypeError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc `<`(self: datetime; dt: datetime): bool {.
+    ...raises: [NotImplementedError, ValueError, TypeError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc `<=`(self: datetime; dt: datetime): bool {.
+    ...raises: [NotImplementedError, ValueError, TypeError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc `==`(self: datetime; dt: datetime): bool {.
+    ...raises: [NotImplementedError, ValueError, TypeError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/datetime_impl/datetime_impl/meth/op.idx b/Lib/datetime_impl/datetime_impl/meth/op.idx new file mode 100644 index 000000000..df8833afc --- /dev/null +++ b/Lib/datetime_impl/datetime_impl/meth/op.idx @@ -0,0 +1,8 @@ +nimTitle op datetime_impl/datetime_impl/meth/op.html module src/pylib/Lib/datetime_impl/datetime_impl/meth/op 0 +nim `+` datetime_impl/datetime_impl/meth/op.html#+,,timedelta proc `+`(self: datetime; delta: timedelta): datetime 11 +nim `-` datetime_impl/datetime_impl/meth/op.html#-,,timedelta proc `-`(self: datetime; delta: timedelta): datetime 14 +nim `-` datetime_impl/datetime_impl/meth/op.html#-,,datetime proc `-`(self: datetime; dt: datetime): timedelta 21 +nim `==` datetime_impl/datetime_impl/meth/op.html#==,,datetime proc `==`(self: datetime; dt: datetime): bool 130 +nim `<=` datetime_impl/datetime_impl/meth/op.html#<=,,datetime proc `<=`(self: datetime; dt: datetime): bool 131 +nim `<` datetime_impl/datetime_impl/meth/op.html#<,,datetime proc `<`(self: datetime; dt: datetime): bool 132 +nimgrp - datetime_impl/datetime_impl/meth/op.html#--procs-all proc 14 diff --git a/Lib/datetime_impl/datetime_impl/meth/platform_utils.html b/Lib/datetime_impl/datetime_impl/meth/platform_utils.html new file mode 100644 index 000000000..556ed5db6 --- /dev/null +++ b/Lib/datetime_impl/datetime_impl/meth/platform_utils.html @@ -0,0 +1,103 @@ + + + + + + + +src/pylib/Lib/datetime_impl/datetime_impl/meth/platform_utils + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/datetime_impl/datetime_impl/meth/platform_utils

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Consts

+
+
+
weridTarget = false
+
+ + + Source   +Edit   + +
+
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/datetime_impl/datetime_impl/meth/platform_utils.idx b/Lib/datetime_impl/datetime_impl/meth/platform_utils.idx new file mode 100644 index 000000000..0bc327bb2 --- /dev/null +++ b/Lib/datetime_impl/datetime_impl/meth/platform_utils.idx @@ -0,0 +1,2 @@ +nimTitle platform_utils datetime_impl/datetime_impl/meth/platform_utils.html module src/pylib/Lib/datetime_impl/datetime_impl/meth/platform_utils 0 +nim weridTarget datetime_impl/datetime_impl/meth/platform_utils.html#weridTarget const weridTarget 2 diff --git a/Lib/datetime_impl/datetime_impl/meth/pytime.html b/Lib/datetime_impl/datetime_impl/meth/pytime.html new file mode 100644 index 000000000..9d8aa7b99 --- /dev/null +++ b/Lib/datetime_impl/datetime_impl/meth/pytime.html @@ -0,0 +1,166 @@ + + + + + + + +src/pylib/Lib/datetime_impl/datetime_impl/meth/pytime + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/datetime_impl/datetime_impl/meth/pytime

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

translated from CPython/Python/pytime.c

+ +
+

Procs

+
+
+
+
proc nPyTime_gmtime(t: time_t; tm: var Tm) {....raises: [PyOSError], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc nPyTime_localtime(t: time_t; tm: var Tm) {....raises: [PyOSError], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func nPyTime_ObjectToTimeval(obj: Timestamp; sec: var time_t; usec: var long;
+                             round: PyTime_round_t)
+
+ + PyTime_ObjectToTimeval but raise OverflowDefect instead of returning -1 i.e. returns nothing. + Source   +Edit   + +
+
+ +
+ +
+
+ + +
+
+ + +
+
+ + + diff --git a/Lib/datetime_impl/datetime_impl/meth/pytime.idx b/Lib/datetime_impl/datetime_impl/meth/pytime.idx new file mode 100644 index 000000000..8bac1bee6 --- /dev/null +++ b/Lib/datetime_impl/datetime_impl/meth/pytime.idx @@ -0,0 +1,4 @@ +nimTitle pytime datetime_impl/datetime_impl/meth/pytime.html module src/pylib/Lib/datetime_impl/datetime_impl/meth/pytime 0 +nim nPyTime_ObjectToTimeval datetime_impl/datetime_impl/meth/pytime.html#nPyTime_ObjectToTimeval,Timestamp,time_t,long,PyTime_round_t proc nPyTime_ObjectToTimeval(obj: Timestamp; sec: var time_t; usec: var long;\n round: PyTime_round_t) 73 +nim nPyTime_localtime datetime_impl/datetime_impl/meth/pytime.html#nPyTime_localtime,time_t,Tm proc nPyTime_localtime(t: time_t; tm: var Tm) 86 +nim nPyTime_gmtime datetime_impl/datetime_impl/meth/pytime.html#nPyTime_gmtime,time_t,Tm proc nPyTime_gmtime(t: time_t; tm: var Tm) 108 diff --git a/Lib/datetime_impl/datetime_impl/meth/require_time_module.html b/Lib/datetime_impl/datetime_impl/meth/require_time_module.html new file mode 100644 index 000000000..637c7c5d6 --- /dev/null +++ b/Lib/datetime_impl/datetime_impl/meth/require_time_module.html @@ -0,0 +1,171 @@ + + + + + + + +src/pylib/Lib/datetime_impl/datetime_impl/meth/require_time_module + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/datetime_impl/datetime_impl/meth/require_time_module

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
func ctime(self: datetime): string {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func strftime(self: datetime; format: string): string {....raises: [ValueError],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func strptime(_: _`gensym4026532122:type; datetime_string, format: string): datetime
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func timetuple(self: datetime): struct_time {....raises: [NotImplementedError],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/datetime_impl/datetime_impl/meth/require_time_module.idx b/Lib/datetime_impl/datetime_impl/meth/require_time_module.idx new file mode 100644 index 000000000..d988b25e7 --- /dev/null +++ b/Lib/datetime_impl/datetime_impl/meth/require_time_module.idx @@ -0,0 +1,5 @@ +nimTitle require_time_module datetime_impl/datetime_impl/meth/require_time_module.html module src/pylib/Lib/datetime_impl/datetime_impl/meth/require_time_module 0 +nim timetuple datetime_impl/datetime_impl/meth/require_time_module.html#timetuple proc timetuple(self: datetime): struct_time 20 +nim strftime datetime_impl/datetime_impl/meth/require_time_module.html#strftime,,string proc strftime(self: datetime; format: string): string 80 +nim strptime datetime_impl/datetime_impl/meth/require_time_module.html#strptime,,string,string proc strptime(_: _`gensym4026532122:type; datetime_string, format: string): datetime 84 +nim ctime datetime_impl/datetime_impl/meth/require_time_module.html#ctime proc ctime(self: datetime): string 93 diff --git a/Lib/datetime_impl/datetime_impl/meth/state_consts.html b/Lib/datetime_impl/datetime_impl/meth/state_consts.html new file mode 100644 index 000000000..b85b8375b --- /dev/null +++ b/Lib/datetime_impl/datetime_impl/meth/state_consts.html @@ -0,0 +1,147 @@ + + + + + + + +src/pylib/Lib/datetime_impl/datetime_impl/meth/state_consts + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/datetime_impl/datetime_impl/meth/state_consts

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Lets

+
+
+
CONST_EPOCH = datetime(1970, 1, 1, 0, 0, 0, 0,
+  bind UTC
+  UTC, 0)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Templates

+
+
+
+
template utc_timezone(): timezone
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/datetime_impl/datetime_impl/meth/state_consts.idx b/Lib/datetime_impl/datetime_impl/meth/state_consts.idx new file mode 100644 index 000000000..0a289cf4f --- /dev/null +++ b/Lib/datetime_impl/datetime_impl/meth/state_consts.idx @@ -0,0 +1,3 @@ +nimTitle state_consts datetime_impl/datetime_impl/meth/state_consts.html module src/pylib/Lib/datetime_impl/datetime_impl/meth/state_consts 0 +nim utc_timezone datetime_impl/datetime_impl/meth/state_consts.html#utc_timezone.t template utc_timezone(): timezone 5 +nim CONST_EPOCH datetime_impl/datetime_impl/meth/state_consts.html#CONST_EPOCH let CONST_EPOCH 9 diff --git a/Lib/datetime_impl/datetime_impl/meth/statics.html b/Lib/datetime_impl/datetime_impl/meth/statics.html new file mode 100644 index 000000000..7a0cc8b35 --- /dev/null +++ b/Lib/datetime_impl/datetime_impl/meth/statics.html @@ -0,0 +1,212 @@ + + + + + + + +src/pylib/Lib/datetime_impl/datetime_impl/meth/statics + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/datetime_impl/datetime_impl/meth/statics

+
+ +
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
proc fromisocalendar(_: _`gensym1744830498:type; year, week, day: int): datetime
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc fromisoformat(_: _`gensym1744830487:type; nonkw: string): datetime
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc fromordinal(_: _`gensym1744830492:type; ordinal: int): datetime
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc fromtimestamp(_: _`gensym1744830592:type; timestamp: Timestamp; tz = TzNone): datetime
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func now(_: _`gensym1744830482:type; tzinfo: tzinfo = TzNone): datetime
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func today(_: _`gensym1744830478:type): datetime
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Exports

+
+ Timestamp +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/datetime_impl/datetime_impl/meth/statics.idx b/Lib/datetime_impl/datetime_impl/meth/statics.idx new file mode 100644 index 000000000..c389ea910 --- /dev/null +++ b/Lib/datetime_impl/datetime_impl/meth/statics.idx @@ -0,0 +1,7 @@ +nimTitle statics datetime_impl/datetime_impl/meth/statics.html module src/pylib/Lib/datetime_impl/datetime_impl/meth/statics 0 +nim today datetime_impl/datetime_impl/meth/statics.html#today proc today(_: _`gensym1744830478:type): datetime 12 +nim now datetime_impl/datetime_impl/meth/statics.html#now,,tzinfo proc now(_: _`gensym1744830482:type; tzinfo: tzinfo = TzNone): datetime 13 +nim fromisoformat datetime_impl/datetime_impl/meth/statics.html#fromisoformat,,string proc fromisoformat(_: _`gensym1744830487:type; nonkw: string): datetime 17 +nim fromordinal datetime_impl/datetime_impl/meth/statics.html#fromordinal,,int proc fromordinal(_: _`gensym1744830492:type; ordinal: int): datetime 18 +nim fromisocalendar datetime_impl/datetime_impl/meth/statics.html#fromisocalendar,,int,int,int proc fromisocalendar(_: _`gensym1744830498:type; year, week, day: int): datetime 25 +nim fromtimestamp datetime_impl/datetime_impl/meth/statics.html#fromtimestamp,,Timestamp proc fromtimestamp(_: _`gensym1744830592:type; timestamp: Timestamp; tz = TzNone): datetime 96 diff --git a/Lib/datetime_impl/datetime_impl/meth/struct_tm_decl.html b/Lib/datetime_impl/datetime_impl/meth/struct_tm_decl.html new file mode 100644 index 000000000..f807902fc --- /dev/null +++ b/Lib/datetime_impl/datetime_impl/meth/struct_tm_decl.html @@ -0,0 +1,253 @@ + + + + + + + +src/pylib/Lib/datetime_impl/datetime_impl/meth/struct_tm_decl + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/datetime_impl/datetime_impl/meth/struct_tm_decl

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Types

+
+
+
struct_tm {.importc: "struct tm", header: "<time.h>", completeStruct.} = object
+
+ + + Source   +Edit   + +
+
+
+
Tm {.importc: "struct tm", header: "<time.h>".} = object
+  tm_year*: int              ## years since 1900
+  tm_mon*: range[0 .. 11]
+  tm_mday*: range[1 .. 31]
+  tm_hour*: range[0 .. 23]
+  tm_min*: range[0 .. 59]
+  tm_sec*: range[0 .. 61]    ## C89 is 0..61, C99 is 0..60
+  tm_wday*: range[0 .. 6]
+  tm_yday*: range[0 .. 365]
+  tm_isdst*: int
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Consts

+
+
+
HAVE_STRUCT_TM_TM_ZONE = false
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
func initTm(): Tm {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func month(tm: Tm): int {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func year(tm: Tm): int {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template initTm(tm: var Tm)
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/datetime_impl/datetime_impl/meth/struct_tm_decl.idx b/Lib/datetime_impl/datetime_impl/meth/struct_tm_decl.idx new file mode 100644 index 000000000..47be9e255 --- /dev/null +++ b/Lib/datetime_impl/datetime_impl/meth/struct_tm_decl.idx @@ -0,0 +1,8 @@ +nimTitle struct_tm_decl datetime_impl/datetime_impl/meth/struct_tm_decl.html module src/pylib/Lib/datetime_impl/datetime_impl/meth/struct_tm_decl 0 +nim struct_tm datetime_impl/datetime_impl/meth/struct_tm_decl.html#struct_tm object struct_tm 7 +nim HAVE_STRUCT_TM_TM_ZONE datetime_impl/datetime_impl/meth/struct_tm_decl.html#HAVE_STRUCT_TM_TM_ZONE const HAVE_STRUCT_TM_TM_ZONE 8 +nim Tm datetime_impl/datetime_impl/meth/struct_tm_decl.html#Tm object Tm 12 +nim year datetime_impl/datetime_impl/meth/struct_tm_decl.html#year,Tm proc year(tm: Tm): int 36 +nim month datetime_impl/datetime_impl/meth/struct_tm_decl.html#month,Tm proc month(tm: Tm): int 37 +nim initTm datetime_impl/datetime_impl/meth/struct_tm_decl.html#initTm proc initTm(): Tm 39 +nim initTm datetime_impl/datetime_impl/meth/struct_tm_decl.html#initTm.t,Tm template initTm(tm: var Tm) 40 diff --git a/Lib/datetime_impl/datetime_impl/meth/struct_tm_helper.html b/Lib/datetime_impl/datetime_impl/meth/struct_tm_helper.html new file mode 100644 index 000000000..14c63dd3b --- /dev/null +++ b/Lib/datetime_impl/datetime_impl/meth/struct_tm_helper.html @@ -0,0 +1,118 @@ + + + + + + + +src/pylib/Lib/datetime_impl/datetime_impl/meth/struct_tm_helper + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/datetime_impl/datetime_impl/meth/struct_tm_helper

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Macros

+
+
+
+
macro cTmToNormCall(call; tm: Tm; kwargs: varargs[untyped]): untyped
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/datetime_impl/datetime_impl/meth/struct_tm_helper.idx b/Lib/datetime_impl/datetime_impl/meth/struct_tm_helper.idx new file mode 100644 index 000000000..dd9533d02 --- /dev/null +++ b/Lib/datetime_impl/datetime_impl/meth/struct_tm_helper.idx @@ -0,0 +1,2 @@ +nimTitle struct_tm_helper datetime_impl/datetime_impl/meth/struct_tm_helper.html module src/pylib/Lib/datetime_impl/datetime_impl/meth/struct_tm_helper 0 +nim cTmToNormCall datetime_impl/datetime_impl/meth/struct_tm_helper.html#cTmToNormCall.m,,Tm,varargs[untyped] macro cTmToNormCall(call; tm: Tm; kwargs: varargs[untyped]): untyped 5 diff --git a/Lib/datetime_impl/datetime_impl/meth/struct_tm_meth.html b/Lib/datetime_impl/datetime_impl/meth/struct_tm_meth.html new file mode 100644 index 000000000..94c062af0 --- /dev/null +++ b/Lib/datetime_impl/datetime_impl/meth/struct_tm_meth.html @@ -0,0 +1,137 @@ + + + + + + + +src/pylib/Lib/datetime_impl/datetime_impl/meth/struct_tm_meth + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/datetime_impl/datetime_impl/meth/struct_tm_meth

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
proc gmtime_r(t: var time_t; tm: var Tm): ptr Tm {.importc, header: "<time.h>",
+    ...raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc localtime_r(t: var time_t; tm: var Tm): ptr Tm {.importc,
+    header: "<time.h>", ...raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/datetime_impl/datetime_impl/meth/struct_tm_meth.idx b/Lib/datetime_impl/datetime_impl/meth/struct_tm_meth.idx new file mode 100644 index 000000000..a78c93b85 --- /dev/null +++ b/Lib/datetime_impl/datetime_impl/meth/struct_tm_meth.idx @@ -0,0 +1,3 @@ +nimTitle struct_tm_meth datetime_impl/datetime_impl/meth/struct_tm_meth.html module src/pylib/Lib/datetime_impl/datetime_impl/meth/struct_tm_meth 0 +nim localtime_r datetime_impl/datetime_impl/meth/struct_tm_meth.html#localtime_r,time_t,Tm proc localtime_r(t: var time_t; tm: var Tm): ptr Tm 9 +nim gmtime_r datetime_impl/datetime_impl/meth/struct_tm_meth.html#gmtime_r,time_t,Tm proc gmtime_r(t: var time_t; tm: var Tm): ptr Tm 10 diff --git a/Lib/datetime_impl/datetime_impl/meth/time_t_decl.html b/Lib/datetime_impl/datetime_impl/meth/time_t_decl.html new file mode 100644 index 000000000..af1498073 --- /dev/null +++ b/Lib/datetime_impl/datetime_impl/meth/time_t_decl.html @@ -0,0 +1,96 @@ + + + + + + + +src/pylib/Lib/datetime_impl/datetime_impl/meth/time_t_decl + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/datetime_impl/datetime_impl/meth/time_t_decl

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Imports

+
+ importer +
+
+
+

Exports

+
+ time_t +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/datetime_impl/datetime_impl/meth/time_t_decl.idx b/Lib/datetime_impl/datetime_impl/meth/time_t_decl.idx new file mode 100644 index 000000000..94188d4d7 --- /dev/null +++ b/Lib/datetime_impl/datetime_impl/meth/time_t_decl.idx @@ -0,0 +1 @@ +nimTitle time_t_decl datetime_impl/datetime_impl/meth/time_t_decl.html module src/pylib/Lib/datetime_impl/datetime_impl/meth/time_t_decl 0 diff --git a/Lib/datetime_impl/datetime_impl/meth/time_utils.html b/Lib/datetime_impl/datetime_impl/meth/time_utils.html new file mode 100644 index 000000000..5ed89ffd8 --- /dev/null +++ b/Lib/datetime_impl/datetime_impl/meth/time_utils.html @@ -0,0 +1,144 @@ + + + + + + + +src/pylib/Lib/datetime_impl/datetime_impl/meth/time_utils + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/datetime_impl/datetime_impl/meth/time_utils

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
proc nTime_gmtime(t: time_t): Tm {....raises: [PyOSError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc nTime_localtime(t: time_t): Tm {....raises: [PyOSError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ + +
+
+ + +
+
+ + + diff --git a/Lib/datetime_impl/datetime_impl/meth/time_utils.idx b/Lib/datetime_impl/datetime_impl/meth/time_utils.idx new file mode 100644 index 000000000..bc54f813f --- /dev/null +++ b/Lib/datetime_impl/datetime_impl/meth/time_utils.idx @@ -0,0 +1,3 @@ +nimTitle time_utils datetime_impl/datetime_impl/meth/time_utils.html module src/pylib/Lib/datetime_impl/datetime_impl/meth/time_utils 0 +nim nTime_localtime datetime_impl/datetime_impl/meth/time_utils.html#nTime_localtime,time_t proc nTime_localtime(t: time_t): Tm 6 +nim nTime_gmtime datetime_impl/datetime_impl/meth/time_utils.html#nTime_gmtime,time_t proc nTime_gmtime(t: time_t): Tm 10 diff --git a/Lib/datetime_impl/datetime_impl/meth/to_seconds_utils.html b/Lib/datetime_impl/datetime_impl/meth/to_seconds_utils.html new file mode 100644 index 000000000..f74d3a9a3 --- /dev/null +++ b/Lib/datetime_impl/datetime_impl/meth/to_seconds_utils.html @@ -0,0 +1,193 @@ + + + + + + + +src/pylib/Lib/datetime_impl/datetime_impl/meth/to_seconds_utils + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/datetime_impl/datetime_impl/meth/to_seconds_utils

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Lets

+
+
+
epoch = 62135683200'i64
+
+ + +NB: date(1970,1,1).toordinal() == 719163 + Source   +Edit   + +
+
+
+
max_fold_seconds = BiggestInt(86400)
+
+ + +As of version 2015f max fold in IANA database is 23 hours at 1969-09-30 13:00:00 in Kwajalein. + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
proc local(u: BiggestInt): BiggestInt {....raises: [PyOSError, ValueError],
+                                        tags: [], forbids: [].}
+
+ + never returns -1, unlike CPython, but may raises OverflowDefect + Source   +Edit   + +
+
+ +
+
+
+
proc local_to_seconds(year, month, day, hour, minute, second: int; fold: int): BiggestInt {.
+    ...raises: [ValueError, PyOSError], tags: [], forbids: [].}
+
+ + never returns -1, unlike CPython, but may raises OverflowDefect + Source   +Edit   + +
+
+ +
+
+
+
func utc_to_seconds(year, month, day, hour, minute, second: int): BiggestInt {.
+    ...raises: [ValueError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/datetime_impl/datetime_impl/meth/to_seconds_utils.idx b/Lib/datetime_impl/datetime_impl/meth/to_seconds_utils.idx new file mode 100644 index 000000000..52ec82fcb --- /dev/null +++ b/Lib/datetime_impl/datetime_impl/meth/to_seconds_utils.idx @@ -0,0 +1,6 @@ +nimTitle to_seconds_utils datetime_impl/datetime_impl/meth/to_seconds_utils.html module src/pylib/Lib/datetime_impl/datetime_impl/meth/to_seconds_utils 0 +nim max_fold_seconds datetime_impl/datetime_impl/meth/to_seconds_utils.html#max_fold_seconds let max_fold_seconds 6 +nim epoch datetime_impl/datetime_impl/meth/to_seconds_utils.html#epoch let epoch 10 +nim utc_to_seconds datetime_impl/datetime_impl/meth/to_seconds_utils.html#utc_to_seconds,int,int,int,int,int,int proc utc_to_seconds(year, month, day, hour, minute, second: int): BiggestInt 13 +nim local datetime_impl/datetime_impl/meth/to_seconds_utils.html#local,BiggestInt proc local(u: BiggestInt): BiggestInt 20 +nim local_to_seconds datetime_impl/datetime_impl/meth/to_seconds_utils.html#local_to_seconds,int,int,int,int,int,int,int proc local_to_seconds(year, month, day, hour, minute, second: int; fold: int): BiggestInt 28 diff --git a/Lib/datetime_impl/datetime_impl/meth/zonename_utils.html b/Lib/datetime_impl/datetime_impl/meth/zonename_utils.html new file mode 100644 index 000000000..1732b4ee7 --- /dev/null +++ b/Lib/datetime_impl/datetime_impl/meth/zonename_utils.html @@ -0,0 +1,153 @@ + + + + + + + +src/pylib/Lib/datetime_impl/datetime_impl/meth/zonename_utils + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/datetime_impl/datetime_impl/meth/zonename_utils

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
proc freeZoneCStr(s: cstring) {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc newZoneCStr(tm: var Tm): cstring {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc zonename(tm: var Tm): string {....raises: [ValueError, UnicodeDecodeError],
+                                    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/datetime_impl/datetime_impl/meth/zonename_utils.idx b/Lib/datetime_impl/datetime_impl/meth/zonename_utils.idx new file mode 100644 index 000000000..c89a174b1 --- /dev/null +++ b/Lib/datetime_impl/datetime_impl/meth/zonename_utils.idx @@ -0,0 +1,4 @@ +nimTitle zonename_utils datetime_impl/datetime_impl/meth/zonename_utils.html module src/pylib/Lib/datetime_impl/datetime_impl/meth/zonename_utils 0 +nim newZoneCStr datetime_impl/datetime_impl/meth/zonename_utils.html#newZoneCStr,Tm proc newZoneCStr(tm: var Tm): cstring 18 +nim freeZoneCStr datetime_impl/datetime_impl/meth/zonename_utils.html#freeZoneCStr,cstring proc freeZoneCStr(s: cstring) 34 +nim zonename datetime_impl/datetime_impl/meth/zonename_utils.html#zonename,Tm proc zonename(tm: var Tm): string 50 diff --git a/Lib/datetime_impl/delta_chk.html b/Lib/datetime_impl/delta_chk.html new file mode 100644 index 000000000..41afefc2d --- /dev/null +++ b/Lib/datetime_impl/delta_chk.html @@ -0,0 +1,118 @@ + + + + + + + +src/pylib/Lib/datetime_impl/delta_chk + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/datetime_impl/delta_chk

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Templates

+
+
+
+
template chkOneDay(delta: timedelta)
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/datetime_impl/delta_chk.idx b/Lib/datetime_impl/delta_chk.idx new file mode 100644 index 000000000..a238adbdb --- /dev/null +++ b/Lib/datetime_impl/delta_chk.idx @@ -0,0 +1,2 @@ +nimTitle delta_chk datetime_impl/delta_chk.html module src/pylib/Lib/datetime_impl/delta_chk 0 +nim chkOneDay datetime_impl/delta_chk.html#chkOneDay.t,timedelta template chkOneDay(delta: timedelta) 14 diff --git a/Lib/datetime_impl/mathutils.html b/Lib/datetime_impl/mathutils.html new file mode 100644 index 000000000..3755ea7b8 --- /dev/null +++ b/Lib/datetime_impl/mathutils.html @@ -0,0 +1,109 @@ + + + + + + + +src/pylib/Lib/datetime_impl/mathutils + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/datetime_impl/mathutils

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Procs

+
+
+
+
func divmod[I](x: I; y: Natural; r: var I): I
+
+ + returns floorDiv(x, y) + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/datetime_impl/mathutils.idx b/Lib/datetime_impl/mathutils.idx new file mode 100644 index 000000000..c8144ce35 --- /dev/null +++ b/Lib/datetime_impl/mathutils.idx @@ -0,0 +1,2 @@ +nimTitle mathutils datetime_impl/mathutils.html module src/pylib/Lib/datetime_impl/mathutils 0 +nim divmod datetime_impl/mathutils.html#divmod,I,Natural,I proc divmod[I](x: I; y: Natural; r: var I): I 3 diff --git a/Lib/datetime_impl/obj_utils.html b/Lib/datetime_impl/obj_utils.html new file mode 100644 index 000000000..94a5c52c6 --- /dev/null +++ b/Lib/datetime_impl/obj_utils.html @@ -0,0 +1,109 @@ + + + + + + + +src/pylib/Lib/datetime_impl/obj_utils + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/datetime_impl/obj_utils

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Procs

+
+
+
+
func `@=`[T](p1, p2: ref T): bool
+
+ + cmp on addr of pointers + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/datetime_impl/obj_utils.idx b/Lib/datetime_impl/obj_utils.idx new file mode 100644 index 000000000..3aa5ab299 --- /dev/null +++ b/Lib/datetime_impl/obj_utils.idx @@ -0,0 +1,2 @@ +nimTitle obj_utils datetime_impl/obj_utils.html module src/pylib/Lib/datetime_impl/obj_utils 0 +nim `@=` datetime_impl/obj_utils.html#@=,ref.T,ref.T proc `@=`[T](p1, p2: ref T): bool 3 diff --git a/Lib/datetime_impl/pyerr.html b/Lib/datetime_impl/pyerr.html new file mode 100644 index 000000000..194df96a0 --- /dev/null +++ b/Lib/datetime_impl/pyerr.html @@ -0,0 +1,127 @@ + + + + + + + +src/pylib/Lib/datetime_impl/pyerr + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/datetime_impl/pyerr

+ + + +
+
+ + + diff --git a/Lib/datetime_impl/pyerr.idx b/Lib/datetime_impl/pyerr.idx new file mode 100644 index 000000000..f68661c74 --- /dev/null +++ b/Lib/datetime_impl/pyerr.idx @@ -0,0 +1,2 @@ +nimTitle pyerr datetime_impl/pyerr.html module src/pylib/Lib/datetime_impl/pyerr 0 +nim notImplErr datetime_impl/pyerr.html#notImplErr.t template notImplErr(meth) 6 diff --git a/Lib/datetime_impl/timedelta_impl.html b/Lib/datetime_impl/timedelta_impl.html new file mode 100644 index 000000000..ac77f669d --- /dev/null +++ b/Lib/datetime_impl/timedelta_impl.html @@ -0,0 +1,96 @@ + + + + + + + +src/pylib/Lib/datetime_impl/timedelta_impl + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/datetime_impl/timedelta_impl

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+ +
+ + +
+
+ + + diff --git a/Lib/datetime_impl/timedelta_impl.idx b/Lib/datetime_impl/timedelta_impl.idx new file mode 100644 index 000000000..2ca79a37a --- /dev/null +++ b/Lib/datetime_impl/timedelta_impl.idx @@ -0,0 +1 @@ +nimTitle timedelta_impl datetime_impl/timedelta_impl.html module src/pylib/Lib/datetime_impl/timedelta_impl 0 diff --git a/Lib/datetime_impl/timedelta_impl/decl.html b/Lib/datetime_impl/timedelta_impl/decl.html new file mode 100644 index 000000000..d9f81cbcb --- /dev/null +++ b/Lib/datetime_impl/timedelta_impl/decl.html @@ -0,0 +1,307 @@ + + + + + + + +src/pylib/Lib/datetime_impl/timedelta_impl/decl + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/datetime_impl/timedelta_impl/decl

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

Hint: +Nim's Duration in std/times has the resolution of nanoseconds, but Python's timedelta's is microseconds But to keep consist with Python, timedelta.resolution is 1 microseconds now.
+

+
+

Types

+
+
+
timedelta = ref object
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Consts

+
+
+
TimeDeltaNone: timedelta = nil
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
func `==`(self: timedelta; o: timedelta): bool {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func asDuration(self: timedelta): Duration {....raises: [], tags: [], forbids: [].}
+
+ + EXT. + Source   +Edit   + +
+
+ +
+
+
+
func flush_hash(self: timedelta) {....raises: [], tags: [], forbids: [].}
+
+ + EXT. calculate hash whatever + Source   +Edit   + +
+
+ +
+
+
+
func hash(self: timedelta): int {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func inMicroseconds(self: timedelta): int64 {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func isTimeDeltaNone(self: timedelta): bool {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func newTimedelta(days, seconds, microseconds: int; normalize = true): timedelta {.
+    ...raises: [], tags: [], forbids: [].}
+
+ + CPython's new_delta C-API (private) + Source   +Edit   + +
+
+
+
func newTimedelta(dur: Duration): timedelta {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Converters

+
+
+
+
converter toBool(self: timedelta): bool {....raises: [], tags: [], forbids: [].}
+
+ + delta_bool + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/datetime_impl/timedelta_impl/decl.idx b/Lib/datetime_impl/timedelta_impl/decl.idx new file mode 100644 index 000000000..a1f14447d --- /dev/null +++ b/Lib/datetime_impl/timedelta_impl/decl.idx @@ -0,0 +1,13 @@ +nimTitle decl datetime_impl/timedelta_impl/decl.html module src/pylib/Lib/datetime_impl/timedelta_impl/decl 0 +nim timedelta datetime_impl/timedelta_impl/decl.html#timedelta type timedelta 14 +nim TimeDeltaNone datetime_impl/timedelta_impl/decl.html#TimeDeltaNone const TimeDeltaNone 18 +nim isTimeDeltaNone datetime_impl/timedelta_impl/decl.html#isTimeDeltaNone,timedelta proc isTimeDeltaNone(self: timedelta): bool 19 +nim newTimedelta datetime_impl/timedelta_impl/decl.html#newTimedelta,Duration proc newTimedelta(dur: Duration): timedelta 21 +nim newTimedelta datetime_impl/timedelta_impl/decl.html#newTimedelta,int,int,int proc newTimedelta(days, seconds, microseconds: int; normalize = true): timedelta 22 +nim asDuration datetime_impl/timedelta_impl/decl.html#asDuration proc asDuration(self: timedelta): Duration 30 +nim inMicroseconds datetime_impl/timedelta_impl/decl.html#inMicroseconds proc inMicroseconds(self: timedelta): int64 34 +nim flush_hash datetime_impl/timedelta_impl/decl.html#flush_hash proc flush_hash(self: timedelta) 43 +nim hash datetime_impl/timedelta_impl/decl.html#hash proc hash(self: timedelta): int 47 +nim toBool datetime_impl/timedelta_impl/decl.html#toBool.c converter toBool(self: timedelta): bool 52 +nim `==` datetime_impl/timedelta_impl/decl.html#==,,timedelta proc `==`(self: timedelta; o: timedelta): bool 56 +nimgrp newtimedelta datetime_impl/timedelta_impl/decl.html#newTimedelta-procs-all proc 21 diff --git a/Lib/datetime_impl/timedelta_impl/getter.html b/Lib/datetime_impl/timedelta_impl/getter.html new file mode 100644 index 000000000..108e31a10 --- /dev/null +++ b/Lib/datetime_impl/timedelta_impl/getter.html @@ -0,0 +1,205 @@ + + + + + + + +src/pylib/Lib/datetime_impl/timedelta_impl/getter + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/datetime_impl/timedelta_impl/getter

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Imports

+
+ decl +
+
+
+

Procs

+
+
+
+
func days(self: timedelta): int64 {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func daysImpl(parts: DurationParts): int64 {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func microseconds(self: timedelta): int64 {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func microsecondsImpl(parts: DurationParts): int64 {....raises: [], tags: [],
+    forbids: [].}
+
+ + result is never negative. In Python, only timedelta.days may be negative + Source   +Edit   + +
+
+ +
+
+
+
func seconds(self: timedelta): int64 {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func secondsImpl(parts: DurationParts): int64 {....raises: [], tags: [],
+    forbids: [].}
+
+ + result is never negative. In Python, only timedelta.days may be negative + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/datetime_impl/timedelta_impl/getter.idx b/Lib/datetime_impl/timedelta_impl/getter.idx new file mode 100644 index 000000000..113e82e5b --- /dev/null +++ b/Lib/datetime_impl/timedelta_impl/getter.idx @@ -0,0 +1,7 @@ +nimTitle getter datetime_impl/timedelta_impl/getter.html module src/pylib/Lib/datetime_impl/timedelta_impl/getter 0 +nim daysImpl datetime_impl/timedelta_impl/getter.html#daysImpl proc daysImpl(parts: DurationParts): int64 10 +nim days datetime_impl/timedelta_impl/getter.html#days proc days(self: timedelta): int64 16 +nim secondsImpl datetime_impl/timedelta_impl/getter.html#secondsImpl proc secondsImpl(parts: DurationParts): int64 18 +nim seconds datetime_impl/timedelta_impl/getter.html#seconds proc seconds(self: timedelta): int64 30 +nim microsecondsImpl datetime_impl/timedelta_impl/getter.html#microsecondsImpl proc microsecondsImpl(parts: DurationParts): int64 32 +nim microseconds datetime_impl/timedelta_impl/getter.html#microseconds proc microseconds(self: timedelta): int64 41 diff --git a/Lib/datetime_impl/timedelta_impl/meth.html b/Lib/datetime_impl/timedelta_impl/meth.html new file mode 100644 index 000000000..6630fcbb7 --- /dev/null +++ b/Lib/datetime_impl/timedelta_impl/meth.html @@ -0,0 +1,534 @@ + + + + + + + +src/pylib/Lib/datetime_impl/timedelta_impl/meth + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/datetime_impl/timedelta_impl/meth

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Types

+
+
+
FI = float | I_in_FI
+
+ + float or int64 + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
func `$`(self: timedelta): string {....raises: [], tags: [], forbids: [].}
+
+ +

for timedelta.__str__

+

[D day[s], ][H]H:MM:SS[.UUUUUU], where D is negative for negative t.

+ + Source   +Edit   + +
+
+ +
+
+
+
func `%`(self, t: timedelta): timedelta {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func `*`(f: float; self: timedelta): timedelta {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func `*`(i: int64; self: timedelta): timedelta {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func `*`(self: timedelta; f: float): timedelta {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func `*`(self: timedelta; i: int64): timedelta {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func `+`(a, b: timedelta): timedelta {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func `+`(self: timedelta): timedelta {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func `+=`(mself; t: timedelta) {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func `-`(a, b: timedelta): timedelta {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func `-`(self: timedelta): timedelta {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func `-=`(mself; t: timedelta) {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func `/`(self: timedelta; i: int | float): timedelta
+
+ + + Source   +Edit   + +
+
+
+
func `/`(self: timedelta; t: timedelta): float {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func `//`(self: timedelta; i: int): timedelta {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func `//`(self: timedelta; t: timedelta): int {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func abs(self: timedelta): timedelta {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func divmod(t1, t2: timedelta): (int64, timedelta) {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func max(_: _`gensym1610612820:type): timedelta
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func min(_: _`gensym1610612816:type): timedelta
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func repr(self: timedelta): string {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func resolution(_: _`gensym1610612824:type): timedelta
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func timedelta(days: FI = 0; seconds: FI = 0; microseconds: FI = 0;
+               milliseconds: FI = 0; minutes: FI = 0; hours: FI = 0;
+               weeks: FI = 0): timedelta
+
+ + + Source   +Edit   + +
+
+
+
func timedelta(days: int64; seconds = 0'i64; microseconds = 0'i64;
+               milliseconds = 0'i64; minutes = 0'i64; hours = 0'i64;
+               weeks = 0'i64): timedelta {....raises: [], tags: [], forbids: [].}
+
+ +

timedelta with int-only arguments

+

See timedelta that accepts mixin float and int as arguments

+
Hint: +if setting default value for days(a.k.a. days=0), timedelta() will fail to be compiled due to ambiguous call
+ + Source   +Edit   + +
+
+ +
+
+
+
func total_seconds(self: timedelta): float {....raises: [], tags: [], forbids: [].}
+
+ + timedelta.total_seconds() + Source   +Edit   + +
+
+ +
+ +
+
+ + +
+
+ + +
+
+ + + diff --git a/Lib/datetime_impl/timedelta_impl/meth.idx b/Lib/datetime_impl/timedelta_impl/meth.idx new file mode 100644 index 000000000..e130a1dbc --- /dev/null +++ b/Lib/datetime_impl/timedelta_impl/meth.idx @@ -0,0 +1,33 @@ +nimTitle meth datetime_impl/timedelta_impl/meth.html module src/pylib/Lib/datetime_impl/timedelta_impl/meth 0 +nim timedelta datetime_impl/timedelta_impl/meth.html#timedelta,int64,int64,int64,int64,int64,int64,int64 proc timedelta(days: int64; seconds = 0'i64; microseconds = 0'i64;\n milliseconds = 0'i64; minutes = 0'i64; hours = 0'i64; weeks = 0'i64): timedelta 11 +nim FI datetime_impl/timedelta_impl/meth.html#FI type FI 36 +nim timedelta datetime_impl/timedelta_impl/meth.html#timedelta,FI,FI,FI,FI,FI,FI,FI proc timedelta(days: FI = 0; seconds: FI = 0; microseconds: FI = 0;\n milliseconds: FI = 0; minutes: FI = 0; hours: FI = 0; weeks: FI = 0): timedelta 92 +nim min datetime_impl/timedelta_impl/meth.html#min proc min(_: _`gensym1610612816:type): timedelta 119 +nim max datetime_impl/timedelta_impl/meth.html#max proc max(_: _`gensym1610612820:type): timedelta 122 +nim resolution datetime_impl/timedelta_impl/meth.html#resolution proc resolution(_: _`gensym1610612824:type): timedelta 126 +nim repr datetime_impl/timedelta_impl/meth.html#repr proc repr(self: timedelta): string 129 +nim `$` datetime_impl/timedelta_impl/meth.html#$ proc `$`(self: timedelta): string 139 +nim total_seconds datetime_impl/timedelta_impl/meth.html#total_seconds proc total_seconds(self: timedelta): float 171 +nim `+` datetime_impl/timedelta_impl/meth.html#+,timedelta,timedelta proc `+`(a, b: timedelta): timedelta 178 +nim `-` datetime_impl/timedelta_impl/meth.html#-,timedelta,timedelta proc `-`(a, b: timedelta): timedelta 179 +nim `*` datetime_impl/timedelta_impl/meth.html#*,,int64 proc `*`(self: timedelta; i: int64): timedelta 181 +nim `*` datetime_impl/timedelta_impl/meth.html#*,int64, proc `*`(i: int64; self: timedelta): timedelta 182 +nim `*` datetime_impl/timedelta_impl/meth.html#*,,float proc `*`(self: timedelta; f: float): timedelta 219 +nim `*` datetime_impl/timedelta_impl/meth.html#*,float, proc `*`(f: float; self: timedelta): timedelta 222 +nim `+` datetime_impl/timedelta_impl/meth.html#+ proc `+`(self: timedelta): timedelta 225 +nim abs datetime_impl/timedelta_impl/meth.html#abs proc abs(self: timedelta): timedelta 229 +nim `-` datetime_impl/timedelta_impl/meth.html#- proc `-`(self: timedelta): timedelta 231 +nim `/` datetime_impl/timedelta_impl/meth.html#/,, proc `/`(self: timedelta; i: int | float): timedelta 235 +nim `/` datetime_impl/timedelta_impl/meth.html#/,,timedelta proc `/`(self: timedelta; t: timedelta): float 240 +nim `//` datetime_impl/timedelta_impl/meth.html#//,,int proc `//`(self: timedelta; i: int): timedelta 246 +nim `//` datetime_impl/timedelta_impl/meth.html#//,,timedelta proc `//`(self: timedelta; t: timedelta): int 249 +nim `%` datetime_impl/timedelta_impl/meth.html#%,timedelta,timedelta proc `%`(self, t: timedelta): timedelta 252 +nim divmod datetime_impl/timedelta_impl/meth.html#divmod,timedelta,timedelta proc divmod(t1, t2: timedelta): (int64, timedelta) 255 +nim `+=` datetime_impl/timedelta_impl/meth.html#+=,,timedelta proc `+=`(mself; t: timedelta) 268 +nim `-=` datetime_impl/timedelta_impl/meth.html#-=,,timedelta proc `-=`(mself; t: timedelta) 269 +nimgrp + datetime_impl/timedelta_impl/meth.html#+-procs-all proc 178 +nimgrp - datetime_impl/timedelta_impl/meth.html#--procs-all proc 179 +nimgrp / datetime_impl/timedelta_impl/meth.html#/-procs-all proc 235 +nimgrp * datetime_impl/timedelta_impl/meth.html#*-procs-all proc 181 +nimgrp // datetime_impl/timedelta_impl/meth.html#//-procs-all proc 246 +nimgrp timedelta datetime_impl/timedelta_impl/meth.html#timedelta-procs-all proc 11 diff --git a/Lib/datetime_impl/timezone_impl.html b/Lib/datetime_impl/timezone_impl.html new file mode 100644 index 000000000..fed98f4e7 --- /dev/null +++ b/Lib/datetime_impl/timezone_impl.html @@ -0,0 +1,96 @@ + + + + + + + +src/pylib/Lib/datetime_impl/timezone_impl + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/datetime_impl/timezone_impl

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+ +
+ + +
+
+ + + diff --git a/Lib/datetime_impl/timezone_impl.idx b/Lib/datetime_impl/timezone_impl.idx new file mode 100644 index 000000000..307be9738 --- /dev/null +++ b/Lib/datetime_impl/timezone_impl.idx @@ -0,0 +1 @@ +nimTitle timezone_impl datetime_impl/timezone_impl.html module src/pylib/Lib/datetime_impl/timezone_impl 0 diff --git a/Lib/datetime_impl/timezone_impl/decl.html b/Lib/datetime_impl/timezone_impl/decl.html new file mode 100644 index 000000000..405a5b1d7 --- /dev/null +++ b/Lib/datetime_impl/timezone_impl/decl.html @@ -0,0 +1,455 @@ + + + + + + + +src/pylib/Lib/datetime_impl/timezone_impl/decl + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/datetime_impl/timezone_impl/decl

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Types

+
+
+
timezone = ref object of tzinfo
+
+ + + Source   +Edit   + +
+
+
+
tzinfo = ref object of RootObj
+
+ + an abstract base class + Source   +Edit   + +
+
+ +
+
+
+

Lets

+
+
+
UTC = timezone(offset: timedelta(0, 0, 0, 0, 0, 0, 0))
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Consts

+
+
+
TzNone: tzinfo = nil
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
func `$`(self: timezone): string {....raises: [], tags: [], forbids: [].}
+
+ + timezone_str + Source   +Edit   + +
+
+ +
+
+
+
func format_utcoffset(parts: DurationParts; sep: string | char = ':';
+                      prefix = "UTC"): string
+
+ + common code of CPython C-API timezone_str and format_utcoffset in _datetimemodule.c + Source   +Edit   + +
+
+ +
+
+
+
func hash(self: timezone): int {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func isTzNone(self: tzinfo): bool {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc newPyTimezone(offset: timedelta): timezone {....raises: [ValueError],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func newPyTimezone(offset: timedelta; name: string): timezone {.
+    ...raises: [ValueError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func offset(self: timezone): timedelta {....raises: [], tags: [], forbids: [].}
+
+ + inner + Source   +Edit   + +
+
+ +
+
+
+
func repr(self: timezone): string {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Methods

+
+
+
+
method repr(self: timezone): string {....raises: [], tags: [], forbids: [].}
+
+ + timezone_repr + Source   +Edit   + +
+
+
+
method repr(self: tzinfo): string {.base, ...raises: [], tags: [], forbids: [].}
+
+ + object.__repr__ + Source   +Edit   + +
+
+ +
+
+
+
method toNimTimezone(self: timezone): Timezone {....raises: [], tags: [],
+    forbids: [].}
+
+ +
Warning: +in Nim, method's self cannot be nil, otherwise a NilAccessDefect will occur. use tzToNimTimezone as a workaround.
+ + Source   +Edit   + +
+
+
+
method toNimTimezone(self: tzinfo): Timezone {.base, ...raises: [], tags: [],
+    forbids: [].}
+
+ +
Warning: +in Nim, method's self cannot be nil, otherwise a NilAccessDefect will occur. use tzToNimTimezone as a workaround.
+ + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template tzToNimTimezone(tz: tzinfo): Timezone
+
+ + EXT. if tz.isTzNone: local() else: tz.toNimTimezone as when tz is None, a.k.a. dispatcher is nil, toNimTimezone will fail when called, raising NilAccessDefect + Source   +Edit   + +
+
+ +
+
+
+
template utc(_: NimTimezoneProc): timezone
+
+ + if import std/times, timezone.utc may matches this. + Source   +Edit   + +
+
+
+
template utc(_: typedesc[timezone]): timezone
+
+ + timezone.utc + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/datetime_impl/timezone_impl/decl.idx b/Lib/datetime_impl/timezone_impl/decl.idx new file mode 100644 index 000000000..521eca895 --- /dev/null +++ b/Lib/datetime_impl/timezone_impl/decl.idx @@ -0,0 +1,24 @@ +nimTitle decl datetime_impl/timezone_impl/decl.html module src/pylib/Lib/datetime_impl/timezone_impl/decl 0 +nim tzinfo datetime_impl/timezone_impl/decl.html#tzinfo type tzinfo 9 +nim timezone datetime_impl/timezone_impl/decl.html#timezone type timezone 10 +nim TzNone datetime_impl/timezone_impl/decl.html#TzNone const TzNone 14 +nim isTzNone datetime_impl/timezone_impl/decl.html#isTzNone,tzinfo proc isTzNone(self: tzinfo): bool 15 +nim offset datetime_impl/timezone_impl/decl.html#offset,timezone proc offset(self: timezone): timedelta 17 +nim hash datetime_impl/timezone_impl/decl.html#hash,timezone proc hash(self: timezone): int 19 +nim toNimTimezone datetime_impl/timezone_impl/decl.html#toNimTimezone.e,tzinfo method toNimTimezone(self: tzinfo): Timezone 22 +nim toNimTimezone datetime_impl/timezone_impl/decl.html#toNimTimezone.e,timezone method toNimTimezone(self: timezone): Timezone 29 +nim tzToNimTimezone datetime_impl/timezone_impl/decl.html#tzToNimTimezone.t,tzinfo template tzToNimTimezone(tz: tzinfo): Timezone 53 +nim UTC datetime_impl/timezone_impl/decl.html#UTC let UTC 61 +nim utc datetime_impl/timezone_impl/decl.html#utc.t,typedesc[timezone] template utc(_: typedesc[timezone]): timezone 62 +nim newPyTimezone datetime_impl/timezone_impl/decl.html#newPyTimezone,timedelta proc newPyTimezone(offset: timedelta): timezone 67 +nim newPyTimezone datetime_impl/timezone_impl/decl.html#newPyTimezone,timedelta,string proc newPyTimezone(offset: timedelta; name: string): timezone 73 +nim utc datetime_impl/timezone_impl/decl.html#utc.t,NimTimezoneProc template utc(_: NimTimezoneProc): timezone 79 +nim repr datetime_impl/timezone_impl/decl.html#repr,timezone proc repr(self: timezone): string 91 +nim format_utcoffset datetime_impl/timezone_impl/decl.html#format_utcoffset,DurationParts,char,string proc format_utcoffset(parts: DurationParts; sep: string | char = ':'; prefix = "UTC"): string 141 +nim `$` datetime_impl/timezone_impl/decl.html#$,timezone proc `$`(self: timezone): string 159 +nim repr datetime_impl/timezone_impl/decl.html#repr.e,tzinfo method repr(self: tzinfo): string 168 +nim repr datetime_impl/timezone_impl/decl.html#repr.e,timezone method repr(self: timezone): string 174 +nimgrp newpytimezone datetime_impl/timezone_impl/decl.html#newPyTimezone-procs-all proc 67 +nimgrp tonimtimezone datetime_impl/timezone_impl/decl.html#toNimTimezone-methods-all method 22 +nimgrp repr datetime_impl/timezone_impl/decl.html#repr-methods-all method 168 +nimgrp utc datetime_impl/timezone_impl/decl.html#utc-templates-all template 62 diff --git a/Lib/datetime_impl/timezone_impl/meth_by_datetime.html b/Lib/datetime_impl/timezone_impl/meth_by_datetime.html new file mode 100644 index 000000000..949ca7cb6 --- /dev/null +++ b/Lib/datetime_impl/timezone_impl/meth_by_datetime.html @@ -0,0 +1,131 @@ + + + + + + + +src/pylib/Lib/datetime_impl/timezone_impl/meth_by_datetime + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/datetime_impl/timezone_impl/meth_by_datetime

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

meth required by datetime class

+ +
+

Methods

+
+
+
+
method fromutc(self: timezone; dt: datetime): datetime {....raises: [ValueError],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
method fromutc(self: tzinfo; dt: datetime): datetime {.base,
+    ...raises: [ValueError, NotImplementedError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/datetime_impl/timezone_impl/meth_by_datetime.idx b/Lib/datetime_impl/timezone_impl/meth_by_datetime.idx new file mode 100644 index 000000000..bf9d42565 --- /dev/null +++ b/Lib/datetime_impl/timezone_impl/meth_by_datetime.idx @@ -0,0 +1,4 @@ +nimTitle meth_by_datetime datetime_impl/timezone_impl/meth_by_datetime.html module src/pylib/Lib/datetime_impl/timezone_impl/meth_by_datetime 0 +nim fromutc datetime_impl/timezone_impl/meth_by_datetime.html#fromutc.e,tzinfo, method fromutc(self: tzinfo; dt: datetime): datetime 19 +nim fromutc datetime_impl/timezone_impl/meth_by_datetime.html#fromutc.e,timezone, method fromutc(self: timezone; dt: datetime): datetime 36 +nimgrp fromutc datetime_impl/timezone_impl/meth_by_datetime.html#fromutc-methods-all method 19 diff --git a/Lib/datetime_impl/timezone_impl/meth_by_datetime_getter.html b/Lib/datetime_impl/timezone_impl/meth_by_datetime_getter.html new file mode 100644 index 000000000..a4bfd6fc2 --- /dev/null +++ b/Lib/datetime_impl/timezone_impl/meth_by_datetime_getter.html @@ -0,0 +1,191 @@ + + + + + + + +src/pylib/Lib/datetime_impl/timezone_impl/meth_by_datetime_getter + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/datetime_impl/timezone_impl/meth_by_datetime_getter

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Methods

+
+
+
+
method dst(self: timezone; _: datetime): timedelta {....raises: [], tags: [],
+    forbids: [].}
+
+ + returns nil + Source   +Edit   + +
+
+
+
method dst(self: tzinfo; dt: datetime): timedelta {.base,
+    ...raises: [NotImplementedError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
method tzname(self: timezone; _: datetime): string {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
method tzname(self: tzinfo; dt: datetime): string {.base,
+    ...raises: [NotImplementedError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
method utcoffset(self: timezone; _: datetime): timedelta {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
method utcoffset(self: tzinfo; dt: datetime): timedelta {.base,
+    ...raises: [NotImplementedError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/datetime_impl/timezone_impl/meth_by_datetime_getter.idx b/Lib/datetime_impl/timezone_impl/meth_by_datetime_getter.idx new file mode 100644 index 000000000..67f49b020 --- /dev/null +++ b/Lib/datetime_impl/timezone_impl/meth_by_datetime_getter.idx @@ -0,0 +1,10 @@ +nimTitle meth_by_datetime_getter datetime_impl/timezone_impl/meth_by_datetime_getter.html module src/pylib/Lib/datetime_impl/timezone_impl/meth_by_datetime_getter 0 +nim utcoffset datetime_impl/timezone_impl/meth_by_datetime_getter.html#utcoffset.e,tzinfo,datetime method utcoffset(self: tzinfo; dt: datetime): timedelta 7 +nim utcoffset datetime_impl/timezone_impl/meth_by_datetime_getter.html#utcoffset.e,timezone,datetime method utcoffset(self: timezone; _: datetime): timedelta 8 +nim dst datetime_impl/timezone_impl/meth_by_datetime_getter.html#dst.e,tzinfo,datetime method dst(self: tzinfo; dt: datetime): timedelta 10 +nim dst datetime_impl/timezone_impl/meth_by_datetime_getter.html#dst.e,timezone,datetime method dst(self: timezone; _: datetime): timedelta 11 +nim tzname datetime_impl/timezone_impl/meth_by_datetime_getter.html#tzname.e,tzinfo,datetime method tzname(self: tzinfo; dt: datetime): string 15 +nim tzname datetime_impl/timezone_impl/meth_by_datetime_getter.html#tzname.e,timezone,datetime method tzname(self: timezone; _: datetime): string 16 +nimgrp tzname datetime_impl/timezone_impl/meth_by_datetime_getter.html#tzname-methods-all method 15 +nimgrp dst datetime_impl/timezone_impl/meth_by_datetime_getter.html#dst-methods-all method 10 +nimgrp utcoffset datetime_impl/timezone_impl/meth_by_datetime_getter.html#utcoffset-methods-all method 7 diff --git a/Lib/datetime_impl/timezone_impl/meth_else.html b/Lib/datetime_impl/timezone_impl/meth_else.html new file mode 100644 index 000000000..b714e5500 --- /dev/null +++ b/Lib/datetime_impl/timezone_impl/meth_else.html @@ -0,0 +1,148 @@ + + + + + + + +src/pylib/Lib/datetime_impl/timezone_impl/meth_else + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/datetime_impl/timezone_impl/meth_else

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
func `==`(self: timezone; o: timezone): bool {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc timezone(offset: timedelta): timezone {....raises: [ValueError], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func timezone(offset: timedelta; name: string): timezone {....raises: [ValueError],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/datetime_impl/timezone_impl/meth_else.idx b/Lib/datetime_impl/timezone_impl/meth_else.idx new file mode 100644 index 000000000..44e870343 --- /dev/null +++ b/Lib/datetime_impl/timezone_impl/meth_else.idx @@ -0,0 +1,5 @@ +nimTitle meth_else datetime_impl/timezone_impl/meth_else.html module src/pylib/Lib/datetime_impl/timezone_impl/meth_else 0 +nim timezone datetime_impl/timezone_impl/meth_else.html#timezone,timedelta proc timezone(offset: timedelta): timezone 8 +nim timezone datetime_impl/timezone_impl/meth_else.html#timezone,timedelta,string proc timezone(offset: timedelta; name: string): timezone 10 +nim `==` datetime_impl/timezone_impl/meth_else.html#==,,timezone proc `==`(self: timezone; o: timezone): bool 16 +nimgrp timezone datetime_impl/timezone_impl/meth_else.html#timezone-procs-all proc 8 diff --git a/Lib/datetime_impl/types.html b/Lib/datetime_impl/types.html new file mode 100644 index 000000000..91f467ea6 --- /dev/null +++ b/Lib/datetime_impl/types.html @@ -0,0 +1,96 @@ + + + + + + + +src/pylib/Lib/datetime_impl/types + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/datetime_impl/types

+ + + +
+
+ + + diff --git a/Lib/datetime_impl/types.idx b/Lib/datetime_impl/types.idx new file mode 100644 index 000000000..77e402940 --- /dev/null +++ b/Lib/datetime_impl/types.idx @@ -0,0 +1 @@ +nimTitle types datetime_impl/types.html module src/pylib/Lib/datetime_impl/types 0 diff --git a/Lib/dochack.js b/Lib/dochack.js new file mode 100644 index 000000000..3166d3c90 --- /dev/null +++ b/Lib/dochack.js @@ -0,0 +1,1718 @@ +/* Generated by the Nim Compiler v2.2.4 */ +var framePtr = null; +var excHandler = 0; +var lastJSError = null; +var NTI33554466 = {size: 0,kind: 1,base: null,node: null,finalizer: null}; +var NTI721420302 = {size: 0, kind: 18, base: null, node: null, finalizer: null}; +var NTI33554435 = {size: 0,kind: 31,base: null,node: null,finalizer: null}; +var NTI956301392 = {size: 0,kind: 31,base: null,node: null,finalizer: null}; +var NTI956301399 = {size: 0, kind: 18, base: null, node: null, finalizer: null}; +var NTI134217745 = {size: 0, kind: 17, base: null, node: null, finalizer: null}; +var NTI134217749 = {size: 0, kind: 17, base: null, node: null, finalizer: null}; +var NTI134217751 = {size: 0, kind: 17, base: null, node: null, finalizer: null}; +var NTI33555167 = {size: 0, kind: 17, base: null, node: null, finalizer: null}; +var NTI33555175 = {size: 0, kind: 22, base: null, node: null, finalizer: null}; +var NTI33554450 = {size: 0,kind: 29,base: null,node: null,finalizer: null}; +var NTI33555174 = {size: 0, kind: 22, base: null, node: null, finalizer: null}; +var NTI33555171 = {size: 0, kind: 17, base: null, node: null, finalizer: null}; +var NTI33555172 = {size: 0, kind: 17, base: null, node: null, finalizer: null}; +var NTI134217741 = {size: 0, kind: 17, base: null, node: null, finalizer: null}; +var NTI134217743 = {size: 0, kind: 17, base: null, node: null, finalizer: null}; +var NTI33554449 = {size: 0,kind: 28,base: null,node: null,finalizer: null}; +var NNI134217743 = {kind: 2, len: 0, offset: 0, typ: null, name: null, sons: []}; +NTI134217743.node = NNI134217743; +var NNI134217741 = {kind: 2, len: 0, offset: 0, typ: null, name: null, sons: []}; +NTI134217741.node = NNI134217741; +var NNI33555172 = {kind: 2, len: 0, offset: 0, typ: null, name: null, sons: []}; +NTI33555172.node = NNI33555172; +NTI33555174.base = NTI33555171; +NTI33555175.base = NTI33555171; +var NNI33555171 = {kind: 2, len: 5, offset: 0, typ: null, name: null, sons: [{kind: 1, offset: "parent", len: 0, typ: NTI33555174, name: "parent", sons: null}, +{kind: 1, offset: "name", len: 0, typ: NTI33554450, name: "name", sons: null}, +{kind: 1, offset: "message", len: 0, typ: NTI33554449, name: "msg", sons: null}, +{kind: 1, offset: "trace", len: 0, typ: NTI33554449, name: "trace", sons: null}, +{kind: 1, offset: "up", len: 0, typ: NTI33555175, name: "up", sons: null}]}; +NTI33555171.node = NNI33555171; +var NNI33555167 = {kind: 2, len: 0, offset: 0, typ: null, name: null, sons: []}; +NTI33555167.node = NNI33555167; +NTI33555171.base = NTI33555167; +NTI33555172.base = NTI33555171; +NTI134217741.base = NTI33555172; +NTI134217743.base = NTI134217741; +var NNI134217751 = {kind: 2, len: 0, offset: 0, typ: null, name: null, sons: []}; +NTI134217751.node = NNI134217751; +NTI134217751.base = NTI33555172; +var NNI134217749 = {kind: 2, len: 0, offset: 0, typ: null, name: null, sons: []}; +NTI134217749.node = NNI134217749; +NTI134217749.base = NTI33555172; +var NNI134217745 = {kind: 2, len: 0, offset: 0, typ: null, name: null, sons: []}; +NTI134217745.node = NNI134217745; +NTI134217745.base = NTI33555172; +var NNI956301399 = {kind: 2, len: 2, offset: 0, typ: null, name: null, sons: [{kind: 1, offset: "a", len: 0, typ: NTI956301392, name: "a", sons: null}, +{kind: 1, offset: "b", len: 0, typ: NTI33554435, name: "b", sons: null}]}; +NTI956301399.node = NNI956301399; +var NNI721420302 = {kind: 2, len: 2, offset: 0, typ: null, name: null, sons: [{kind: 1, offset: "Field0", len: 0, typ: NTI33554435, name: "Field0", sons: null}, +{kind: 1, offset: "Field1", len: 0, typ: NTI33554466, name: "Field1", sons: null}]}; +NTI721420302.node = NNI721420302; + +function setConstr() { + var result = {}; + for (var i = 0; i < arguments.length; ++i) { + var x = arguments[i]; + if (typeof(x) == "object") { + for (var j = x[0]; j <= x[1]; ++j) { + result[j] = true; + } + } else { + result[x] = true; + } + } + return result; + + + +} +var ConstSet1 = setConstr(17, 16, 4, 18, 27, 19, 23, 22, 21); + +function nimCopy(dest_p0, src_p1, ti_p2) { + var result_33557330 = null; + + switch (ti_p2.kind) { + case 21: + case 22: + case 23: + case 5: + if (!(isFatPointer__system_u2878(ti_p2))) { + result_33557330 = src_p1; + } + else { + result_33557330 = [src_p1[0], src_p1[1]]; + } + + break; + case 19: + if (dest_p0 === null || dest_p0 === undefined) { + dest_p0 = {}; + } + else { + for (var key in dest_p0) { delete dest_p0[key]; } + } + for (var key in src_p1) { dest_p0[key] = src_p1[key]; } + result_33557330 = dest_p0; + + break; + case 18: + case 17: + if (!((ti_p2.base == null))) { + result_33557330 = nimCopy(dest_p0, src_p1, ti_p2.base); + } + else { + if ((ti_p2.kind == 17)) { + result_33557330 = (dest_p0 === null || dest_p0 === undefined) ? {m_type: ti_p2} : dest_p0; + } + else { + result_33557330 = (dest_p0 === null || dest_p0 === undefined) ? {} : dest_p0; + } + } + nimCopyAux(result_33557330, src_p1, ti_p2.node); + break; + case 4: + case 16: + if(ArrayBuffer.isView(src_p1)) { + if(dest_p0 === null || dest_p0 === undefined || dest_p0.length != src_p1.length) { + dest_p0 = new src_p1.constructor(src_p1); + } else { + dest_p0.set(src_p1, 0); + } + result_33557330 = dest_p0; + } else { + if (src_p1 === null) { + result_33557330 = null; + } + else { + if (dest_p0 === null || dest_p0 === undefined || dest_p0.length != src_p1.length) { + dest_p0 = new Array(src_p1.length); + } + result_33557330 = dest_p0; + for (var i = 0; i < src_p1.length; ++i) { + result_33557330[i] = nimCopy(result_33557330[i], src_p1[i], ti_p2.base); + } + } + } + + break; + case 24: + case 27: + if (src_p1 === null) { + result_33557330 = null; + } + else { + if (dest_p0 === null || dest_p0 === undefined || dest_p0.length != src_p1.length) { + dest_p0 = new Array(src_p1.length); + } + result_33557330 = dest_p0; + for (var i = 0; i < src_p1.length; ++i) { + result_33557330[i] = nimCopy(result_33557330[i], src_p1[i], ti_p2.base); + } + } + + break; + case 28: + if (src_p1 !== null) { + result_33557330 = src_p1.slice(0); + } + + break; + default: + result_33557330 = src_p1; + break; + } + + return result_33557330; + +} + +function mnewString(len_p0) { + var result = new Array(len_p0); + for (var i = 0; i < len_p0; i++) {result[i] = 0;} + return result; + + + +} + +function isObj(obj_p0, subclass_p1) { + var result_33557443 = false; + + BeforeRet: { + var x_33557444 = obj_p0; + if ((x_33557444 == subclass_p1)) { + result_33557443 = true; + break BeforeRet; + } + + Label1: { + Label2: while (true) { + if (!!((x_33557444 == subclass_p1))) break Label2; + if ((x_33557444 == null)) { + result_33557443 = false; + break BeforeRet; + } + + x_33557444 = x_33557444.base; + } + }; + result_33557443 = true; + break BeforeRet; + }; + + return result_33557443; + +} + +function toJSStr(s_p0) { + var result_33556919 = null; + + var res_33556973 = newSeq__system_u2516((s_p0).length); + var i_33556974 = 0; + var j_33556975 = 0; + Label1: { + Label2: while (true) { + if (!(i_33556974 < (s_p0).length)) break Label2; + var c_33556976 = s_p0[i_33556974]; + if ((c_33556976 < 128)) { + res_33556973[j_33556975] = String.fromCharCode(c_33556976); + i_33556974 += 1; + } + else { + var helper_33557002 = newSeq__system_u2516(0); + Label3: { + Label4: while (true) { + if (!true) break Label4; + var code_33557003 = c_33556976.toString(16); + if ((((code_33557003) == null ? 0 : (code_33557003).length) == 1)) { + helper_33557002.push("%0");; + } + else { + helper_33557002.push("%");; + } + + helper_33557002.push(code_33557003);; + i_33556974 += 1; + if ((((s_p0).length <= i_33556974) || (s_p0[i_33556974] < 128))) { + break Label3; + } + + c_33556976 = s_p0[i_33556974]; + } + }; +++excHandler; + try { + res_33556973[j_33556975] = decodeURIComponent(helper_33557002.join("")); +--excHandler; +} catch (EXCEPTION) { + var prevJSError = lastJSError; + lastJSError = EXCEPTION; + --excHandler; + raiseDefect(); + res_33556973[j_33556975] = helper_33557002.join(""); + lastJSError = prevJSError; + } finally { + } + } + + j_33556975 += 1; + } + }; + if (res_33556973.length < j_33556975) { for (var i = res_33556973.length ; i < j_33556975 ; ++i) res_33556973.push(null); } + else { res_33556973.length = j_33556975; }; + result_33556919 = res_33556973.join(""); + + return result_33556919; + +} + +function raiseException(e_p0, ename_p1) { + e_p0.name = ename_p1; + if ((excHandler == 0)) { + unhandledException(e_p0); + } + + throw e_p0; + + +} + +function addInt(a_p0, b_p1) { + var result = a_p0 + b_p1; + checkOverflowInt(result); + return result; + + + +} + +function chckRange(i_p0, a_p1, b_p2) { + var result_33557370 = 0; + + BeforeRet: { + if (((a_p1 <= i_p0) && (i_p0 <= b_p2))) { + result_33557370 = i_p0; + break BeforeRet; + } + else { + raiseRangeError(); + } + + }; + + return result_33557370; + +} + +function chckIndx(i_p0, a_p1, b_p2) { + var result_33557365 = 0; + + BeforeRet: { + if (((a_p1 <= i_p0) && (i_p0 <= b_p2))) { + result_33557365 = i_p0; + break BeforeRet; + } + else { + raiseIndexError(i_p0, a_p1, b_p2); + } + + }; + + return result_33557365; + +} + +function makeNimstrLit(c_p0) { + var result = []; + for (var i = 0; i < c_p0.length; ++i) { + result[i] = c_p0.charCodeAt(i); + } + return result; + + + +} + +function subInt(a_p0, b_p1) { + var result = a_p0 - b_p1; + checkOverflowInt(result); + return result; + + + +} + +function cstrToNimstr(c_p0) { + var ln = c_p0.length; + var result = new Array(ln); + var r = 0; + for (var i = 0; i < ln; ++i) { + var ch = c_p0.charCodeAt(i); + + if (ch < 128) { + result[r] = ch; + } + else { + if (ch < 2048) { + result[r] = (ch >> 6) | 192; + } + else { + if (ch < 55296 || ch >= 57344) { + result[r] = (ch >> 12) | 224; + } + else { + ++i; + ch = 65536 + (((ch & 1023) << 10) | (c_p0.charCodeAt(i) & 1023)); + result[r] = (ch >> 18) | 240; + ++r; + result[r] = ((ch >> 12) & 63) | 128; + } + ++r; + result[r] = ((ch >> 6) & 63) | 128; + } + ++r; + result[r] = (ch & 63) | 128; + } + ++r; + } + return result; + + + +} +var ConstSet2 = setConstr([65, 90]); +var ConstSet3 = setConstr(95, 32, 46); +var ConstSet4 = setConstr(95, 32, 46); + +function mulInt(a_p0, b_p1) { + var result = a_p0 * b_p1; + checkOverflowInt(result); + return result; + + + +} +var ConstSet5 = setConstr([97, 122]); +var ConstSet6 = setConstr([65, 90], [97, 122]); +var ConstSet7 = setConstr([97, 122]); +var ConstSet8 = setConstr([65, 90]); +var ConstSet9 = setConstr([65, 90], [97, 122]); + +function nimMax(a_p0, b_p1) { + var Temporary1; + + var result_33557157 = 0; + + BeforeRet: { + if ((b_p1 <= a_p0)) { + Temporary1 = a_p0; + } + else { + Temporary1 = b_p1; + } + + result_33557157 = Temporary1; + break BeforeRet; + }; + + return result_33557157; + +} + +function nimMin(a_p0, b_p1) { + var Temporary1; + + var result_33557153 = 0; + + BeforeRet: { + if ((a_p0 <= b_p1)) { + Temporary1 = a_p0; + } + else { + Temporary1 = b_p1; + } + + result_33557153 = Temporary1; + break BeforeRet; + }; + + return result_33557153; + +} + +function addChar(x_p0, c_p1) { + x_p0.push(c_p1); + + +} +var objectID_1174405298 = [0]; + +function setTheme(theme_p0) { + document.documentElement.setAttribute("data-theme", theme_p0); + window.localStorage.setItem("theme", theme_p0); + + +} + +function isFatPointer__system_u2878(ti_p0) { + var result_33557312 = false; + + BeforeRet: { + result_33557312 = !((ConstSet1[ti_p0.base.kind] != undefined)); + break BeforeRet; + }; + + return result_33557312; + +} + +function nimCopyAux(dest_p0, src_p1, n_p2) { + switch (n_p2.kind) { + case 0: + break; + case 1: + dest_p0[n_p2.offset] = nimCopy(dest_p0[n_p2.offset], src_p1[n_p2.offset], n_p2.typ); + + break; + case 2: + for (var i = 0; i < n_p2.sons.length; i++) { + nimCopyAux(dest_p0, src_p1, n_p2.sons[i]); + } + + break; + case 3: + dest_p0[n_p2.offset] = nimCopy(dest_p0[n_p2.offset], src_p1[n_p2.offset], n_p2.typ); + for (var i = 0; i < n_p2.sons.length; ++i) { + nimCopyAux(dest_p0, src_p1, n_p2.sons[i][1]); + } + + break; + } + + +} + +function add__system_u1942(x_p0, x_p0_Idx, y_p1) { + if (x_p0[x_p0_Idx] === null) { x_p0[x_p0_Idx] = []; } + var off = x_p0[x_p0_Idx].length; + x_p0[x_p0_Idx].length += y_p1.length; + for (var i = 0; i < y_p1.length; ++i) { + x_p0[x_p0_Idx][off+i] = y_p1.charCodeAt(i); + } + + + +} + +function newSeq__system_u2516(len_p0) { + var result_33556952 = []; + + result_33556952 = new Array(len_p0); for (var i = 0 ; i < len_p0 ; ++i) { result_33556952[i] = null; } + return result_33556952; + +} + +function isNimException__system_u2017() { + return lastJSError && lastJSError.m_type; + + +} + +function getCurrentException() { + var result_33556452 = null; + + if (isNimException__system_u2017()) { + result_33556452 = lastJSError; + } + + + return result_33556452; + +} + +function raiseDefect() { + if (isNimException__system_u2017()) { + var e_33556664 = getCurrentException(); + if (isObj(e_33556664.m_type, NTI33555172)) { + if ((excHandler == 0)) { + unhandledException(e_33556664); + } + + throw e_33556664; + } + + } + + + +} + +function unhandledException(e_p0) { + var buf_33556658 = [[]]; + if (!(((e_p0.message).length == 0))) { + buf_33556658[0].push.apply(buf_33556658[0], [69,114,114,111,114,58,32,117,110,104,97,110,100,108,101,100,32,101,120,99,101,112,116,105,111,110,58,32]);; + buf_33556658[0].push.apply(buf_33556658[0], e_p0.message);; + } + else { + buf_33556658[0].push.apply(buf_33556658[0], [69,114,114,111,114,58,32,117,110,104,97,110,100,108,101,100,32,101,120,99,101,112,116,105,111,110]);; + } + + buf_33556658[0].push.apply(buf_33556658[0], [32,91]);; + add__system_u1942(buf_33556658, 0, e_p0.name); + buf_33556658[0].push.apply(buf_33556658[0], [93,10]);; + var cbuf_33556659 = toJSStr(buf_33556658[0]); + if (typeof(Error) !== "undefined") { + throw new Error(cbuf_33556659); + } + else { + throw cbuf_33556659; + } + + + +} + +function raiseOverflow() { + raiseException({message: [111,118,101,114,45,32,111,114,32,117,110,100,101,114,102,108,111,119], parent: null, m_type: NTI134217743, name: null, trace: [], up: null}, "OverflowDefect"); + + +} + +function checkOverflowInt(a_p0) { + if (a_p0 > 2147483647 || a_p0 < -2147483648) raiseOverflow(); + + + +} + +function raiseRangeError() { + raiseException({message: [118,97,108,117,101,32,111,117,116,32,111,102,32,114,97,110,103,101], parent: null, m_type: NTI134217751, name: null, trace: [], up: null}, "RangeDefect"); + + +} + +function addChars__stdZprivateZdigitsutils_u202(result_p0, result_p0_Idx, x_p1, start_p2, n_p3) { + var Temporary1; + + var old_301990096 = (result_p0[result_p0_Idx]).length; + if (result_p0[result_p0_Idx].length < (Temporary1 = chckRange(addInt(old_301990096, n_p3), 0, 2147483647), Temporary1)) { for (var i = result_p0[result_p0_Idx].length; i < Temporary1; ++i) result_p0[result_p0_Idx].push(0); } + else {result_p0[result_p0_Idx].length = Temporary1; }; + Label2: { + var iHEX60gensym4_301990110 = 0; + var i_570426583 = 0; + Label3: { + Label4: while (true) { + if (!(i_570426583 < n_p3)) break Label4; + iHEX60gensym4_301990110 = i_570426583; + result_p0[result_p0_Idx][chckIndx(addInt(old_301990096, iHEX60gensym4_301990110), 0, (result_p0[result_p0_Idx]).length - 1)] = x_p1.charCodeAt(chckIndx(addInt(start_p2, iHEX60gensym4_301990110), 0, (x_p1).length - 1)); + i_570426583 = addInt(i_570426583, 1); + } + }; + }; + + +} + +function addChars__stdZprivateZdigitsutils_u198(result_p0, result_p0_Idx, x_p1) { + addChars__stdZprivateZdigitsutils_u202(result_p0, result_p0_Idx, x_p1, 0, ((x_p1) == null ? 0 : (x_p1).length)); + + +} + +function addInt__stdZprivateZdigitsutils_u223(result_p0, result_p0_Idx, x_p1) { + addChars__stdZprivateZdigitsutils_u198(result_p0, result_p0_Idx, ((x_p1) + "")); + + +} + +function addInt__stdZprivateZdigitsutils_u241(result_p0, result_p0_Idx, x_p1) { + addInt__stdZprivateZdigitsutils_u223(result_p0, result_p0_Idx, BigInt(x_p1)); + + +} + +function HEX24__systemZdollars_u14(xHEX60gensym0_p0) { + var result_385875984 = [[]]; + + result_385875984[0] = nimCopy(null, [], NTI33554449); + addInt__stdZprivateZdigitsutils_u241(result_385875984, 0, xHEX60gensym0_p0); + + return result_385875984[0]; + +} + +function raiseIndexError(i_p0, a_p1, b_p2) { + var Temporary1; + + if ((b_p2 < a_p1)) { + Temporary1 = [105,110,100,101,120,32,111,117,116,32,111,102,32,98,111,117,110,100,115,44,32,116,104,101,32,99,111,110,116,97,105,110,101,114,32,105,115,32,101,109,112,116,121]; + } + else { + Temporary1 = ([105,110,100,101,120,32]).concat(HEX24__systemZdollars_u14(i_p0),[32,110,111,116,32,105,110,32],HEX24__systemZdollars_u14(a_p1),[32,46,46,32],HEX24__systemZdollars_u14(b_p2)); + } + + raiseException({message: nimCopy(null, Temporary1, NTI33554449), parent: null, m_type: NTI134217749, name: null, trace: [], up: null}, "IndexDefect"); + + +} + +function sysFatal__stdZassertions_u44(message_p1) { + raiseException({message: nimCopy(null, message_p1, NTI33554449), m_type: NTI134217745, parent: null, name: null, trace: [], up: null}, "AssertionDefect"); + + +} + +function raiseAssert__stdZassertions_u42(msg_p0) { + sysFatal__stdZassertions_u44(msg_p0); + + +} + +function failedAssertImpl__stdZassertions_u84(msg_p0) { + raiseAssert__stdZassertions_u42(msg_p0); + + +} + +function onDOMLoaded(e_p0) { + var Temporary4; + +function HEX3Aanonymous__dochack_u65(event_p0) { + event_p0.target.parentNode.style.display = "none"; + event_p0.target.parentNode.nextSibling.style.display = "inline"; + + +} + + document.getElementById("theme-select").value = window.localStorage.getItem("theme"); + Label1: { + var pragmaDots_570425408 = null; + var colontmp__570426574 = []; + colontmp__570426574 = document.getElementsByClassName("pragmadots"); + var i_570426576 = 0; + var L_570426577 = (colontmp__570426574).length; + Label2: { + Label3: while (true) { + if (!(i_570426576 < L_570426577)) break Label3; + pragmaDots_570425408 = colontmp__570426574[chckIndx(i_570426576, 0, (colontmp__570426574).length - 1)]; + Temporary4 = HEX3Aanonymous__dochack_u65.bind(null); Temporary4.ClP_0 = HEX3Aanonymous__dochack_u65; Temporary4.ClE_0 = null; + pragmaDots_570425408.onclick = Temporary4; + i_570426576 += 1; + if (!(((colontmp__570426574).length == L_570426577))) { + failedAssertImpl__stdZassertions_u84(makeNimstrLit("iterators.nim(254, 11) `len(a) == L` the length of the seq changed while iterating over it")); + } + + } + }; + }; + + +} + +function isWhitespace__dochack_u408(x_p0) { + var result_570425754 = false; + + result_570425754 = (((x_p0.nodeName == "#text") && !/\S/.test(x_p0.textContent)) || (x_p0.nodeName == "#comment")); + + return result_570425754; + +} + +function toToc__dochack_u411(x_p0, father_p1) { + var Temporary5; + var Temporary6; + var Temporary7; + var Temporary8; + var Temporary15; + + if ((x_p0.nodeName == "UL")) { + var f_570425765 = {heading: null, kids: [], sortId: (father_p1.kids).length, doSort: false}; + var i_570425766 = 0; + Label1: { + Label2: while (true) { + if (!(i_570425766 < x_p0.childNodes.length)) break Label2; + var nxt_570425767 = addInt(i_570425766, 1); + Label3: { + Label4: while (true) { + if (!(nxt_570425767 < x_p0.childNodes.length)) Temporary5 = false; else { Temporary5 = isWhitespace__dochack_u408(x_p0.childNodes[nxt_570425767]); } if (!Temporary5) break Label4; + nxt_570425767 = addInt(nxt_570425767, 1); + } + }; + if (!(nxt_570425767 < x_p0.childNodes.length)) Temporary8 = false; else { Temporary8 = (x_p0.childNodes[i_570425766].nodeName == "LI"); } if (!Temporary8) Temporary7 = false; else { Temporary7 = (x_p0.childNodes[i_570425766].childNodes.length == 1); } if (!Temporary7) Temporary6 = false; else { Temporary6 = (x_p0.childNodes[nxt_570425767].nodeName == "UL"); } if (Temporary6) { + var e_570425780 = {heading: x_p0.childNodes[i_570425766].childNodes[0], kids: [], sortId: (f_570425765.kids).length, doSort: false}; + var it_570425781 = x_p0.childNodes[nxt_570425767]; + Label9: { + var j_570425786 = 0; + var colontmp__570426591 = 0; + colontmp__570426591 = it_570425781.childNodes.length; + var i_570426592 = 0; + Label10: { + Label11: while (true) { + if (!(i_570426592 < colontmp__570426591)) break Label11; + j_570425786 = i_570426592; + toToc__dochack_u411(it_570425781.childNodes[j_570425786], e_570425780); + i_570426592 = addInt(i_570426592, 1); + } + }; + }; + f_570425765.kids.push(e_570425780);; + i_570425766 = addInt(nxt_570425767, 1); + } + else { + toToc__dochack_u411(x_p0.childNodes[i_570425766], f_570425765); + i_570425766 = addInt(i_570425766, 1); + } + + } + }; + father_p1.kids.push(f_570425765);; + } + else { + if (isWhitespace__dochack_u408(x_p0)) { + } + else { + if ((x_p0.nodeName == "LI")) { + var idx_570425804 = []; + Label12: { + var i_570425809 = 0; + var colontmp__570426595 = 0; + colontmp__570426595 = x_p0.childNodes.length; + var i_570426596 = 0; + Label13: { + Label14: while (true) { + if (!(i_570426596 < colontmp__570426595)) break Label14; + i_570425809 = i_570426596; + if (!(isWhitespace__dochack_u408(x_p0.childNodes[i_570425809]))) { + idx_570425804.push(i_570425809);; + } + + i_570426596 = addInt(i_570426596, 1); + } + }; + }; + if (!((idx_570425804).length == 2)) Temporary15 = false; else { Temporary15 = (x_p0.childNodes[idx_570425804[chckIndx(1, 0, (idx_570425804).length - 1)]].nodeName == "UL"); } if (Temporary15) { + var e_570425825 = {heading: x_p0.childNodes[idx_570425804[chckIndx(0, 0, (idx_570425804).length - 1)]], kids: [], sortId: (father_p1.kids).length, doSort: false}; + var it_570425826 = x_p0.childNodes[idx_570425804[chckIndx(1, 0, (idx_570425804).length - 1)]]; + Label16: { + var j_570425831 = 0; + var colontmp__570426599 = 0; + colontmp__570426599 = it_570425826.childNodes.length; + var i_570426600 = 0; + Label17: { + Label18: while (true) { + if (!(i_570426600 < colontmp__570426599)) break Label18; + j_570425831 = i_570426600; + toToc__dochack_u411(it_570425826.childNodes[j_570425831], e_570425825); + i_570426600 = addInt(i_570426600, 1); + } + }; + }; + father_p1.kids.push(e_570425825);; + } + else { + Label19: { + var i_570425840 = 0; + var colontmp__570426603 = 0; + colontmp__570426603 = x_p0.childNodes.length; + var i_570426604 = 0; + Label20: { + Label21: while (true) { + if (!(i_570426604 < colontmp__570426603)) break Label21; + i_570425840 = i_570426604; + toToc__dochack_u411(x_p0.childNodes[i_570425840], father_p1); + i_570426604 = addInt(i_570426604, 1); + } + }; + }; + } + + } + else { + father_p1.kids.push({heading: x_p0, kids: [], sortId: (father_p1.kids).length, doSort: false});; + } + }} + + +} + +function extractItems__dochack_u199(x_p0, heading_p1, items_p2, items_p2_Idx) { + BeforeRet: { + if ((x_p0 == null)) { + break BeforeRet; + } + + if ((!((x_p0.heading == null)) && (x_p0.heading.textContent == heading_p1))) { + Label1: { + var i_570425563 = 0; + var colontmp__570426607 = 0; + colontmp__570426607 = (x_p0.kids).length; + var i_570426608 = 0; + Label2: { + Label3: while (true) { + if (!(i_570426608 < colontmp__570426607)) break Label3; + i_570425563 = i_570426608; + items_p2[items_p2_Idx].push(x_p0.kids[chckIndx(i_570425563, 0, (x_p0.kids).length - 1)].heading);; + i_570426608 = addInt(i_570426608, 1); + } + }; + }; + } + else { + Label4: { + var k_570425589 = null; + var i_570426612 = 0; + var L_570426613 = (x_p0.kids).length; + Label5: { + Label6: while (true) { + if (!(i_570426612 < L_570426613)) break Label6; + k_570425589 = x_p0.kids[chckIndx(i_570426612, 0, (x_p0.kids).length - 1)]; + extractItems__dochack_u199(k_570425589, heading_p1, items_p2, items_p2_Idx); + i_570426612 += 1; + if (!(((x_p0.kids).length == L_570426613))) { + failedAssertImpl__stdZassertions_u84(makeNimstrLit("iterators.nim(254, 11) `len(a) == L` the length of the seq changed while iterating over it")); + } + + } + }; + }; + } + + }; + + +} + +function tree__dochack_u130(tag_p0, kids_p1) { + var result_570425477 = null; + + result_570425477 = document.createElement(tag_p0); + Label1: { + var k_570425491 = null; + var i_570426625 = 0; + Label2: { + Label3: while (true) { + if (!(i_570426625 < (kids_p1).length)) break Label3; + k_570425491 = kids_p1[chckIndx(i_570426625, 0, (kids_p1).length - 1)]; + result_570425477.appendChild(k_570425491); + i_570426625 += 1; + } + }; + }; + + return result_570425477; + +} + +function text__dochack_u155(s_p0) { + var result_570425501 = null; + + result_570425501 = document.createTextNode(s_p0); + + return result_570425501; + +} + +function uncovered__dochack_u600(x_p0) { + var Temporary1; + + var result_570425946 = null; + + BeforeRet: { + if ((((x_p0.kids).length == 0) && !((x_p0.heading == null)))) { + if (!(x_p0.heading.hasOwnProperty('__karaxMarker__'))) { + Temporary1 = x_p0; + } + else { + Temporary1 = null; + } + + result_570425946 = Temporary1; + break BeforeRet; + } + + result_570425946 = {heading: x_p0.heading, kids: [], sortId: x_p0.sortId, doSort: x_p0.doSort}; + Label2: { + var k_570425961 = null; + var i_570426632 = 0; + var L_570426633 = (x_p0.kids).length; + Label3: { + Label4: while (true) { + if (!(i_570426632 < L_570426633)) break Label4; + k_570425961 = x_p0.kids[chckIndx(i_570426632, 0, (x_p0.kids).length - 1)]; + var y_570425962 = uncovered__dochack_u600(k_570425961); + if (!((y_570425962 == null))) { + result_570425946.kids.push(y_570425962);; + } + + i_570426632 += 1; + if (!(((x_p0.kids).length == L_570426633))) { + failedAssertImpl__stdZassertions_u84(makeNimstrLit("iterators.nim(254, 11) `len(a) == L` the length of the seq changed while iterating over it")); + } + + } + }; + }; + if (((result_570425946.kids).length == 0)) { + result_570425946 = null; + } + + }; + + return result_570425946; + +} + +function mergeTocs__dochack_u630(orig_p0, news_p1) { + var result_570425977 = null; + + result_570425977 = uncovered__dochack_u600(orig_p0); + if ((result_570425977 == null)) { + result_570425977 = news_p1; + } + else { + Label1: { + var i_570425989 = 0; + var colontmp__570426628 = 0; + colontmp__570426628 = (news_p1.kids).length; + var i_570426629 = 0; + Label2: { + Label3: while (true) { + if (!(i_570426629 < colontmp__570426628)) break Label3; + i_570425989 = i_570426629; + result_570425977.kids.push(news_p1.kids[chckIndx(i_570425989, 0, (news_p1.kids).length - 1)]);; + i_570426629 = addInt(i_570426629, 1); + } + }; + }; + } + + + return result_570425977; + +} + +function buildToc__dochack_u650(orig_p0, types_p1, procs_p2) { + var result_570425998 = null; + + var newStuff_570426003 = {heading: null, kids: [], doSort: true, sortId: 0}; + Label1: { + var t_570426007 = null; + var i_570426620 = 0; + var L_570426621 = (types_p1).length; + Label2: { + Label3: while (true) { + if (!(i_570426620 < L_570426621)) break Label3; + t_570426007 = types_p1[chckIndx(i_570426620, 0, (types_p1).length - 1)]; + var c_570426012 = {heading: t_570426007.cloneNode(true), kids: [], doSort: true, sortId: 0}; + t_570426007.__karaxMarker__ = true; + Label4: { + var p_570426016 = null; + var i_570426617 = 0; + var L_570426618 = (procs_p2).length; + Label5: { + Label6: while (true) { + if (!(i_570426617 < L_570426618)) break Label6; + p_570426016 = procs_p2[chckIndx(i_570426617, 0, (procs_p2).length - 1)]; + if (!(p_570426016.hasOwnProperty('__karaxMarker__'))) { + var xx_570426017 = p_570426016.parentNode.getElementsByClassName("attachedType"); + if ((((xx_570426017).length == 1) && (xx_570426017[chckIndx(0, 0, (xx_570426017).length - 1)].textContent == t_570426007.textContent))) { + var q_570426022 = tree__dochack_u130("A", [text__dochack_u155(p_570426016.title)]); + q_570426022.setAttribute("href", p_570426016.getAttribute("href")); + c_570426012.kids.push({heading: q_570426022, kids: [], sortId: 0, doSort: false});; + p_570426016.__karaxMarker__ = true; + } + + } + + i_570426617 += 1; + if (!(((procs_p2).length == L_570426618))) { + failedAssertImpl__stdZassertions_u84(makeNimstrLit("iterators.nim(254, 11) `len(a) == L` the length of the seq changed while iterating over it")); + } + + } + }; + }; + newStuff_570426003.kids.push(c_570426012);; + i_570426620 += 1; + if (!(((types_p1).length == L_570426621))) { + failedAssertImpl__stdZassertions_u84(makeNimstrLit("iterators.nim(254, 11) `len(a) == L` the length of the seq changed while iterating over it")); + } + + } + }; + }; + result_570425998 = mergeTocs__dochack_u630(orig_p0, newStuff_570426003); + + return result_570425998; + +} + +function add__dochack_u148(parent_p0, kid_p1) { + if (((parent_p0.nodeName == "TR") && ((kid_p1.nodeName == "TD") || (kid_p1.nodeName == "TH")))) { + var k_570425495 = document.createElement("TD"); + k_570425495.appendChild(kid_p1); + parent_p0.appendChild(k_570425495); + } + else { + parent_p0.appendChild(kid_p1); + } + + + +} + +function setClass__dochack_u152(e_p0, value_p1) { + e_p0.setAttribute("class", value_p1); + + +} + +function toHtml__dochack_u278(x_p0, isRoot_p1) { + var Temporary1; + +function HEX3Aanonymous__dochack_u298(a_p0, b_p1) { + var result_570425645 = 0; + + BeforeRet: { + if ((!((a_p0.heading == null)) && !((b_p1.heading == null)))) { + var x_570425654 = a_p0.heading.textContent; + var y_570425655 = b_p1.heading.textContent; + if ((x_570425654 < y_570425655)) { + result_570425645 = (-1); + break BeforeRet; + } + + if ((y_570425655 < x_570425654)) { + result_570425645 = 1; + break BeforeRet; + } + + result_570425645 = 0; + break BeforeRet; + } + else { + result_570425645 = subInt(a_p0.sortId, b_p1.sortId); + break BeforeRet; + } + + }; + + return result_570425645; + +} + + var result_570425625 = null; + + BeforeRet: { + if ((x_p0 == null)) { + result_570425625 = null; + break BeforeRet; + } + + if (((x_p0.kids).length == 0)) { + if ((x_p0.heading == null)) { + result_570425625 = null; + break BeforeRet; + } + + result_570425625 = x_p0.heading.cloneNode(true); + break BeforeRet; + } + + result_570425625 = tree__dochack_u130("DIV", []); + if ((!((x_p0.heading == null)) && !(x_p0.heading.hasOwnProperty('__karaxMarker__')))) { + add__dochack_u148(result_570425625, x_p0.heading.cloneNode(true)); + } + + var ul_570425641 = tree__dochack_u130("UL", []); + if (isRoot_p1) { + setClass__dochack_u152(ul_570425641, "simple simple-toc"); + } + else { + setClass__dochack_u152(ul_570425641, "simple"); + } + + if (x_p0.doSort) { + Temporary1 = HEX3Aanonymous__dochack_u298.bind(null); Temporary1.ClP_0 = HEX3Aanonymous__dochack_u298; Temporary1.ClE_0 = null; + x_p0.kids.sort(Temporary1); + } + + Label2: { + var k_570425667 = null; + var i_570426636 = 0; + var L_570426637 = (x_p0.kids).length; + Label3: { + Label4: while (true) { + if (!(i_570426636 < L_570426637)) break Label4; + k_570425667 = x_p0.kids[chckIndx(i_570426636, 0, (x_p0.kids).length - 1)]; + var y_570425668 = toHtml__dochack_u278(k_570425667, false); + if (!((y_570425668 == null))) { + add__dochack_u148(ul_570425641, tree__dochack_u130("LI", [y_570425668])); + } + + i_570426636 += 1; + if (!(((x_p0.kids).length == L_570426637))) { + failedAssertImpl__stdZassertions_u84(makeNimstrLit("iterators.nim(254, 11) `len(a) == L` the length of the seq changed while iterating over it")); + } + + } + }; + }; + if (!((ul_570425641.childNodes.length == 0))) { + add__dochack_u148(result_570425625, ul_570425641); + } + + if ((result_570425625.childNodes.length == 0)) { + result_570425625 = null; + } + + }; + + return result_570425625; + +} + +function replaceById__dochack_u158(id_p0, newTree_p1) { + var x_570425505 = document.getElementById(id_p0); + x_570425505.parentNode.replaceChild(newTree_p1, x_570425505); + newTree_p1.id = id_p0; + + +} + +function togglevis__dochack_u708(d_p0) { + if ((d_p0.style.display == "none")) { + d_p0.style.display = "inline"; + } + else { + d_p0.style.display = "none"; + } + + + +} + +function groupBy(value_p0) { + var toc_570426056 = document.getElementById("toc-list"); + if ((alternative_570426051[0] == null)) { + var tt_570426064 = {heading: null, kids: [], sortId: 0, doSort: false}; + toToc__dochack_u411(toc_570426056, tt_570426064); + tt_570426064 = tt_570426064.kids[chckIndx(0, 0, (tt_570426064.kids).length - 1)]; + var types_570426069 = [[]]; + var procs_570426074 = [[]]; + extractItems__dochack_u199(tt_570426064, "Types", types_570426069, 0); + extractItems__dochack_u199(tt_570426064, "Procs", procs_570426074, 0); + extractItems__dochack_u199(tt_570426064, "Converters", procs_570426074, 0); + extractItems__dochack_u199(tt_570426064, "Methods", procs_570426074, 0); + extractItems__dochack_u199(tt_570426064, "Templates", procs_570426074, 0); + extractItems__dochack_u199(tt_570426064, "Macros", procs_570426074, 0); + extractItems__dochack_u199(tt_570426064, "Iterators", procs_570426074, 0); + var ntoc_570426075 = buildToc__dochack_u650(tt_570426064, types_570426069[0], procs_570426074[0]); + var x_570426076 = toHtml__dochack_u278(ntoc_570426075, true); + alternative_570426051[0] = tree__dochack_u130("DIV", [x_570426076]); + } + + if ((value_p0 == "type")) { + replaceById__dochack_u158("tocRoot", alternative_570426051[0]); + } + else { + replaceById__dochack_u158("tocRoot", tree__dochack_u130("DIV", [])); + } + + togglevis__dochack_u708(document.getElementById("toc-list")); + + +} + +function HEX5BHEX5D__pureZstrutils_u1307(s_p0, x_p1) { + var result_738198816 = []; + + var a_738198818 = x_p1.a; + var L_738198820 = addInt(subInt(subInt((s_p0).length, x_p1.b), a_738198818), 1); + result_738198816 = nimCopy(null, mnewString(chckRange(L_738198820, 0, 2147483647)), NTI33554449); + Label1: { + var i_738198825 = 0; + var i_570426646 = 0; + Label2: { + Label3: while (true) { + if (!(i_570426646 < L_738198820)) break Label3; + i_738198825 = i_570426646; + result_738198816[chckIndx(i_738198825, 0, (result_738198816).length - 1)] = s_p0[chckIndx(addInt(i_738198825, a_738198818), 0, (s_p0).length - 1)]; + i_570426646 = addInt(i_570426646, 1); + } + }; + }; + + return result_738198816; + +} + +function HEX2EHEX2E__stdZenumutils_u105(a_p0, b_p1) { + var result_956301424 = ({a: 0, b: 0}); + + result_956301424 = nimCopy(result_956301424, {a: a_p0, b: b_p1}, NTI956301399); + + return result_956301424; + +} +async function loadIndex__dochack_u928() { + var result_570426274 = null; + + BeforeRet: { + var indexURL_570426280 = document.getElementById("indexLink").getAttribute("href"); + var rootURL_570426306 = HEX5BHEX5D__pureZstrutils_u1307(cstrToNimstr(indexURL_570426280), HEX2EHEX2E__stdZenumutils_u105(0, 14)); + var resp_570426318 = (await (await fetch(indexURL_570426280)).text()); + var indexElem_570426319 = document.createElement("div"); + indexElem_570426319.innerHTML = resp_570426318; + Label1: { + var href_570426341 = null; + var colontmp__570426640 = []; + colontmp__570426640 = indexElem_570426319.getElementsByClassName("reference"); + var i_570426642 = 0; + var L_570426643 = (colontmp__570426640).length; + Label2: { + Label3: while (true) { + if (!(i_570426642 < L_570426643)) break Label3; + href_570426341 = colontmp__570426640[chckIndx(i_570426642, 0, (colontmp__570426640).length - 1)]; + href_570426341.setAttribute("href", toJSStr((rootURL_570426306).concat(cstrToNimstr(href_570426341.getAttribute("href"))))); + db_570426093[0].push(href_570426341);; + contents_570426094[0].push(href_570426341.getAttribute("data-doc-search-tag"));; + i_570426642 += 1; + if (!(((colontmp__570426640).length == L_570426643))) { + failedAssertImpl__stdZassertions_u84(makeNimstrLit("iterators.nim(254, 11) `len(a) == L` the length of the seq changed while iterating over it")); + } + + } + }; + }; + result_570426274 = undefined; + break BeforeRet; + }; + + return result_570426274; + +} + +function then__dochack_u1107(future_p0, onSuccess_p1, onReject_p2) { + var result_570426457 = null; + + BeforeRet: { + var ret_570426467 = null; + ret_570426467 = future_p0.then(onSuccess_p1, onReject_p2); + result_570426457 = ret_570426467; + break BeforeRet; + }; + + return result_570426457; + +} + +function nsuToLowerAsciiChar(c_p0) { + var result_738197590 = 0; + + if ((ConstSet2[c_p0] != undefined)) { + result_738197590 = (c_p0 ^ 32); + } + else { + result_738197590 = c_p0; + } + + + return result_738197590; + +} + +function fuzzyMatch__fuzzysearch_u16(pattern_p0, str_p1) { + var Temporary4; + var Temporary5; + var Temporary6; + var Temporary7; + var Temporary8; + + var result_721420309 = {Field0: 0, Field1: false}; + + var scoreState_721420310 = (-100); + var headerMatched_721420311 = false; + var unmatchedLeadingCharCount_721420312 = 0; + var consecutiveMatchCount_721420313 = 0; + var strIndex_721420314 = 0; + var patIndex_721420315 = 0; + var score_721420316 = 0; + Label1: { + Label2: while (true) { + if (!((strIndex_721420314 < ((str_p1) == null ? 0 : (str_p1).length)) && (patIndex_721420315 < ((pattern_p0) == null ? 0 : (pattern_p0).length)))) break Label2; + Label3: { + var patternChar_721420319 = nsuToLowerAsciiChar(pattern_p0.charCodeAt(chckIndx(patIndex_721420315, 0, (pattern_p0).length - 1))); + var strChar_721420320 = nsuToLowerAsciiChar(str_p1.charCodeAt(chckIndx(strIndex_721420314, 0, (str_p1).length - 1))); + if ((ConstSet3[patternChar_721420319] != undefined)) { + patIndex_721420315 = addInt(patIndex_721420315, 1); + break Label3; + } + + if ((ConstSet4[strChar_721420320] != undefined)) { + strIndex_721420314 = addInt(strIndex_721420314, 1); + break Label3; + } + + if ((!(headerMatched_721420311) && (strChar_721420320 == 58))) { + headerMatched_721420311 = true; + scoreState_721420310 = (-100); + score_721420316 = ((Math.floor((0.5 * score_721420316))) | 0); + patIndex_721420315 = 0; + strIndex_721420314 = addInt(strIndex_721420314, 1); + break Label3; + } + + if ((strChar_721420320 == patternChar_721420319)) { + switch (scoreState_721420310) { + case (-100): + case 20: + scoreState_721420310 = 10; + break; + case 0: + scoreState_721420310 = 5; + score_721420316 = addInt(score_721420316, scoreState_721420310); + break; + case 10: + case 5: + consecutiveMatchCount_721420313 = addInt(consecutiveMatchCount_721420313, 1); + scoreState_721420310 = 5; + score_721420316 = addInt(score_721420316, mulInt(5, consecutiveMatchCount_721420313)); + if ((scoreState_721420310 == 10)) { + score_721420316 = addInt(score_721420316, 10); + } + + var onBoundary_721420372 = (patIndex_721420315 == ((pattern_p0) == null ? -1 : (pattern_p0).length - 1)); + if ((!(onBoundary_721420372) && (strIndex_721420314 < ((str_p1) == null ? -1 : (str_p1).length - 1)))) { + var nextPatternChar_721420373 = nsuToLowerAsciiChar(pattern_p0.charCodeAt(chckIndx(addInt(patIndex_721420315, 1), 0, (pattern_p0).length - 1))); + var nextStrChar_721420374 = nsuToLowerAsciiChar(str_p1.charCodeAt(chckIndx(addInt(strIndex_721420314, 1), 0, (str_p1).length - 1))); + if (!!((ConstSet5[nextStrChar_721420374] != undefined))) Temporary4 = false; else { Temporary4 = !((nextStrChar_721420374 == nextPatternChar_721420373)); } onBoundary_721420372 = Temporary4; + } + + if (onBoundary_721420372) { + scoreState_721420310 = 20; + score_721420316 = addInt(score_721420316, scoreState_721420310); + } + + break; + case (-1): + case (-3): + if (!((ConstSet6[str_p1.charCodeAt(chckIndx(subInt(strIndex_721420314, 1), 0, (str_p1).length - 1))] != undefined))) Temporary5 = true; else { if (!(ConstSet7[str_p1.charCodeAt(chckIndx(subInt(strIndex_721420314, 1), 0, (str_p1).length - 1))] != undefined)) Temporary6 = false; else { Temporary6 = (ConstSet8[str_p1.charCodeAt(chckIndx(strIndex_721420314, 0, (str_p1).length - 1))] != undefined); } Temporary5 = Temporary6; } var isLeadingChar_721420398 = Temporary5; + if (isLeadingChar_721420398) { + scoreState_721420310 = 10; + } + else { + scoreState_721420310 = 0; + score_721420316 = addInt(score_721420316, scoreState_721420310); + } + + break; + } + patIndex_721420315 = addInt(patIndex_721420315, 1); + } + else { + switch (scoreState_721420310) { + case (-100): + scoreState_721420310 = (-3); + score_721420316 = addInt(score_721420316, scoreState_721420310); + break; + case 5: + scoreState_721420310 = (-1); + score_721420316 = addInt(score_721420316, scoreState_721420310); + consecutiveMatchCount_721420313 = 0; + break; + case (-3): + if ((unmatchedLeadingCharCount_721420312 < 3)) { + scoreState_721420310 = (-3); + score_721420316 = addInt(score_721420316, scoreState_721420310); + } + + unmatchedLeadingCharCount_721420312 = addInt(unmatchedLeadingCharCount_721420312, 1); + break; + default: + scoreState_721420310 = (-1); + score_721420316 = addInt(score_721420316, scoreState_721420310); + break; + } + } + + strIndex_721420314 = addInt(strIndex_721420314, 1); + }; + } + }; + if (!(patIndex_721420315 == ((pattern_p0) == null ? 0 : (pattern_p0).length))) Temporary7 = false; else { if ((strIndex_721420314 == ((str_p1) == null ? 0 : (str_p1).length))) Temporary8 = true; else { Temporary8 = !((ConstSet9[str_p1.charCodeAt(chckIndx(strIndex_721420314, 0, (str_p1).length - 1))] != undefined)); } Temporary7 = Temporary8; } if (Temporary7) { + score_721420316 = addInt(score_721420316, 10); + } + + var colontmp__570426659 = nimMax(0, score_721420316); + var colontmp__570426660 = (0 < score_721420316); + result_721420309 = nimCopy(result_721420309, {Field0: colontmp__570426659, Field1: colontmp__570426660}, NTI721420302); + + return result_721420309; + +} + +function escapeCString__dochack_u751(x_p0, x_p0_Idx) { + var s_570426097 = []; + Label1: { + var c_570426098 = 0; + var iHEX60gensym13_570426663 = 0; + var nHEX60gensym13_570426664 = ((x_p0[x_p0_Idx]) == null ? 0 : (x_p0[x_p0_Idx]).length); + Label2: { + Label3: while (true) { + if (!(iHEX60gensym13_570426663 < nHEX60gensym13_570426664)) break Label3; + c_570426098 = x_p0[x_p0_Idx].charCodeAt(chckIndx(iHEX60gensym13_570426663, 0, (x_p0[x_p0_Idx]).length - 1)); + switch (c_570426098) { + case 60: + s_570426097.push.apply(s_570426097, [38,108,116,59]);; + break; + case 62: + s_570426097.push.apply(s_570426097, [38,103,116,59]);; + break; + default: + addChar(s_570426097, c_570426098);; + break; + } + iHEX60gensym13_570426663 += 1; + } + }; + }; + x_p0[x_p0_Idx] = toJSStr(s_570426097); + + +} + +function dosearch__dochack_u755(value_p0) { + var Temporary5; + +function HEX3Aanonymous__dochack_u783(a_p0, b_p1) { + var result_570426140 = 0; + + result_570426140 = subInt(b_p1["Field1"], a_p0["Field1"]); + + return result_570426140; + +} + + var result_570426101 = null; + + BeforeRet: { + if (((db_570426093[0]).length == 0)) { + break BeforeRet; + } + + var ul_570426105 = tree__dochack_u130("UL", []); + result_570426101 = tree__dochack_u130("DIV", []); + setClass__dochack_u152(result_570426101, "search_results"); + var matches_570426110 = []; + Label1: { + var i_570426118 = 0; + var colontmp__570426650 = 0; + colontmp__570426650 = (db_570426093[0]).length; + var i_570426651 = 0; + Label2: { + Label3: while (true) { + if (!(i_570426651 < colontmp__570426650)) break Label3; + i_570426118 = i_570426651; + Label4: { + var c_570426119 = contents_570426094[0][chckIndx(i_570426118, 0, (contents_570426094[0]).length - 1)]; + if (((c_570426119 == "Examples") || (c_570426119 == "PEG construction"))) { + break Label4; + } + + var tmpTuple_570426120 = fuzzyMatch__fuzzysearch_u16(value_p0, c_570426119); + var score_570426121 = tmpTuple_570426120["Field0"]; + var matched_570426122 = tmpTuple_570426120["Field1"]; + if (matched_570426122) { + matches_570426110.push({Field0: db_570426093[0][chckIndx(i_570426118, 0, (db_570426093[0]).length - 1)], Field1: score_570426121});; + } + + }; + i_570426651 = addInt(i_570426651, 1); + } + }; + }; + Temporary5 = HEX3Aanonymous__dochack_u783.bind(null); Temporary5.ClP_0 = HEX3Aanonymous__dochack_u783; Temporary5.ClE_0 = null; + matches_570426110.sort(Temporary5); + Label6: { + var i_570426157 = 0; + var colontmp__570426654 = 0; + colontmp__570426654 = nimMin((matches_570426110).length, 29); + var i_570426655 = 0; + Label7: { + Label8: while (true) { + if (!(i_570426655 < colontmp__570426654)) break Label8; + i_570426157 = i_570426655; + matches_570426110[chckIndx(i_570426157, 0, (matches_570426110).length - 1)]["Field0"].innerHTML = matches_570426110[chckIndx(i_570426157, 0, (matches_570426110).length - 1)]["Field0"].getAttribute("data-doc-search-tag"); + escapeCString__dochack_u751(matches_570426110[chckIndx(i_570426157, 0, (matches_570426110).length - 1)]["Field0"], "innerHTML"); + add__dochack_u148(ul_570426105, tree__dochack_u130("LI", [matches_570426110[chckIndx(i_570426157, 0, (matches_570426110).length - 1)]["Field0"]])); + i_570426655 = addInt(i_570426655, 1); + } + }; + }; + if ((ul_570426105.childNodes.length == 0)) { + add__dochack_u148(result_570426101, tree__dochack_u130("B", [text__dochack_u155("no search results")])); + } + else { + add__dochack_u148(result_570426101, tree__dochack_u130("B", [text__dochack_u155("search results")])); + add__dochack_u148(result_570426101, ul_570426105); + } + + }; + + return result_570426101; + +} + +function hideSearch__dochack_u1090() { + if (!((oldtoc_570426430[0] == null))) { + replaceById__dochack_u158("tocRoot", oldtoc_570426430[0]); + } + + + +} + +function runSearch__dochack_u1094() { + var elem_570426439 = document.getElementById("searchInput"); + var value_570426440 = elem_570426439.value; + if (!((value_570426440 == ""))) { + if ((oldtoc_570426430[0] == null)) { + oldtoc_570426430[0] = document.getElementById("tocRoot"); + } + + var results_570426444 = dosearch__dochack_u755(value_570426440); + replaceById__dochack_u158("tocRoot", results_570426444); + } + else { + hideSearch__dochack_u1090(); + } + + + +} + +function search() { + var Temporary1; + + if ((loadIndexFut_570426433[0] == null)) { + loadIndexFut_570426433[0] = loadIndex__dochack_u928(); + (then__dochack_u1107(loadIndexFut_570426433[0], runSearch__dochack_u1094, null)); + } + + if (!((timer_570426431[0] == null))) { + clearTimeout(timer_570426431[0]); + } + + Temporary1 = runSearch__dochack_u1094.bind(null); Temporary1.ClP_0 = runSearch__dochack_u1094; Temporary1.ClE_0 = null; + timer_570426431[0] = setTimeout(Temporary1, 400); + + +} + +function copyToClipboard() { + + function updatePreTags() { + + const allPreTags = document.querySelectorAll("pre:not(.line-nums)") + + allPreTags.forEach((e) => { + + const div = document.createElement("div") + div.classList.add("copyToClipBoard") + + const preTag = document.createElement("pre") + preTag.innerHTML = e.innerHTML + + const button = document.createElement("button") + button.value = e.textContent.replace('...', '') + button.classList.add("copyToClipBoardBtn") + button.style.cursor = "pointer" + + div.appendChild(preTag) + div.appendChild(button) + + e.outerHTML = div.outerHTML + + }) + } + + + function copyTextToClipboard(e) { + const clipBoardContent = e.target.value + navigator.clipboard.writeText(clipBoardContent).then(function() { + e.target.style.setProperty("--clipboard-image", "var(--clipboard-image-selected)") + }, function(err) { + console.error("Could not copy text: ", err); + }); + } + + window.addEventListener("click", (e) => { + if (e.target.classList.contains("copyToClipBoardBtn")) { + copyTextToClipboard(e) + } + }) + + window.addEventListener("mouseover", (e) => { + if (e.target.nodeName === "PRE") { + e.target.nextElementSibling.style.setProperty("--clipboard-image", "var(--clipboard-image-normal)") + } + }) + + window.addEventListener("DOMContentLoaded", updatePreTags) + + + + +} +var Temporary1; +var Temporary2; + +function HEX3Aanonymous__dochack_u1175(e_p0) { + if ((e_p0.key == "/")) { + e_p0.preventDefault(); + var searchElem_570426521 = document.getElementById("searchInput"); + searchElem_570426521.focus(); + searchElem_570426521.parentElement.scrollIntoView(); + runSearch__dochack_u1094(); + } + + + +} +var Temporary3; + +function HEX3Aanonymous__dochack_u1210(e_p0) { + hideSearch__dochack_u1090(); + + +} +var Temporary4; +var t_570425383 = window.localStorage.getItem("theme"); +if ((t_570425383 == null)) { +Temporary1 = "auto"; +} +else { +Temporary1 = t_570425383; +} + +setTheme(Temporary1); +var alternative_570426051 = [null]; +var db_570426093 = [[]]; +var contents_570426094 = [[]]; +var oldtoc_570426430 = [null]; +var timer_570426431 = [null]; +var loadIndexFut_570426433 = [null]; +Temporary2 = HEX3Aanonymous__dochack_u1175.bind(null); Temporary2.ClP_0 = HEX3Aanonymous__dochack_u1175; Temporary2.ClE_0 = null; +window.addEventListener("keypress", Temporary2, false); +Temporary3 = HEX3Aanonymous__dochack_u1210.bind(null); Temporary3.ClP_0 = HEX3Aanonymous__dochack_u1210; Temporary3.ClE_0 = null; +window.addEventListener("hashchange", Temporary3, false); +copyToClipboard(); +Temporary4 = onDOMLoaded.bind(null); Temporary4.ClP_0 = onDOMLoaded; Temporary4.ClE_0 = null; +window.addEventListener("DOMContentLoaded", Temporary4, false); diff --git a/Lib/enum_impl/enumType.html b/Lib/enum_impl/enumType.html new file mode 100644 index 000000000..8bfe7f5d9 --- /dev/null +++ b/Lib/enum_impl/enumType.html @@ -0,0 +1,139 @@ + + + + + + + +src/pylib/Lib/enum_impl/enumType + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/enum_impl/enumType

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Templates

+
+
+
+
template GenPyEnumInit(Self, Value: typedesc; sym) {.dirty.}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template GenPyEnumMeth(Self; Value: typedesc; genObjMeth = true;
+                       genInit = false; nameError = NameError; Str = string) {.
+    dirty.}
+
+ + XXX: NIM-BUG: as std/tables is not working with bind once required at compile time, import std/tables is a must before using this template. + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/enum_impl/enumType.idx b/Lib/enum_impl/enumType.idx new file mode 100644 index 000000000..7d368f37d --- /dev/null +++ b/Lib/enum_impl/enumType.idx @@ -0,0 +1,3 @@ +nimTitle enumType enum_impl/enumType.html module src/pylib/Lib/enum_impl/enumType 0 +nim GenPyEnumInit enum_impl/enumType.html#GenPyEnumInit.t,typedesc,typedesc, template GenPyEnumInit(Self, Value: typedesc; sym) 5 +nim GenPyEnumMeth enum_impl/enumType.html#GenPyEnumMeth.t,,typedesc template GenPyEnumMeth(Self; Value: typedesc; genObjMeth = true; genInit = false;\n nameError = NameError; Str = string) 13 diff --git a/Lib/enum_impl/intEnum.html b/Lib/enum_impl/intEnum.html new file mode 100644 index 000000000..3e8dc29e5 --- /dev/null +++ b/Lib/enum_impl/intEnum.html @@ -0,0 +1,137 @@ + + + + + + + +src/pylib/Lib/enum_impl/intEnum + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/enum_impl/intEnum

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Imports

+
+ enumType +
+
+
+

Templates

+
+
+
+
template DeclIntEnumMeth(Self; Int = int; genObjMeth = true; genInit = false) {.
+    dirty.}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template GenIntEnumMeth(Self: typedesc; Int = int; genObjMeth = true;
+                        genInit = false) {.dirty.}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/enum_impl/intEnum.idx b/Lib/enum_impl/intEnum.idx new file mode 100644 index 000000000..482f89086 --- /dev/null +++ b/Lib/enum_impl/intEnum.idx @@ -0,0 +1,3 @@ +nimTitle intEnum enum_impl/intEnum.html module src/pylib/Lib/enum_impl/intEnum 0 +nim GenIntEnumMeth enum_impl/intEnum.html#GenIntEnumMeth.t,typedesc template GenIntEnumMeth(Self: typedesc; Int = int; genObjMeth = true; genInit = false) 7 +nim DeclIntEnumMeth enum_impl/intEnum.html#DeclIntEnumMeth.t template DeclIntEnumMeth(Self; Int = int; genObjMeth = true; genInit = false) 12 diff --git a/Lib/errno.html b/Lib/errno.html new file mode 100644 index 000000000..ffecbd71d --- /dev/null +++ b/Lib/errno.html @@ -0,0 +1,96 @@ + + + + + + + +src/pylib/Lib/errno + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/errno

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Exports

+
+ runeLenAt, not, str, str, toPyStr, contains, substr, byteLen, str, items, StringLike, ==, str, toNimString, +, ==, str, chars, contains, and, getChar, $, len, +=, str, +=, len, toPyStr, PyStr, runes, [], ==, runeAtPos, or, contains, +, toNimStr, fspath, +=, toPyStr, [], [], SomeSinglePyDictView, PyDictItemView, values, PyDictValueView, copy, ==, contains, |, pop, SomePyDictView, repr, toPyDict, contains, toPyDict, $, $, $, PyDict, popitem, values, iter, items, setdefault, items, pop, $, clear, []=, get, contains, PyDictKeyView, items, iter, iter, repr, emptyPyDict, repr, len, len, update, dict, keys, keys, contains, get, delitem, PyDictView, |=, repr, [], EPERM, prepareROErrno, EFAULT, EKEYREJECTED, EHOSTUNREACH, EHOSTDOWN, ECONNRESET, EDQUOT, ENONET, EREMCHG, EISDIR, strerror, ESTRPIPE, EMLINK, ENXIO, ETOOMANYREFS, ENODATA, ENOLCK, ENOTRECOVERABLE, $, ECHILD, EISCONN, ECONNABORTED, ENOTDIR, ESRMNT, ENOTEMPTY, EPROTO, EADDRNOTAVAIL, errno, EXDEV, EBADF, EKEYREVOKED, getErrno, EBFONT, EDEADLK, isErr, ESPIPE, ENOKEY, EDOM, ENOEXEC, ENETDOWN, EACCES, setErrno0, ELNRNG, EBADRQC, ENODEV, ENFILE, ETIMEDOUT, ENOBUFS, ENOCSI, ECHRNG, setErrnoRaw, EINVAL, EMEDIUMTYPE, ESHUTDOWN, ERFKILL, EALREADY, EBADFD, ECANCELED, ERESTART, ESRCH, EL2NSYNC, ENETUNREACH, EPROTONOSUPPORT, EBADMSG, ENOTCONN, EMFILE, ENOSYS, ETIME, setErrno, declErrorcodeWith, EILSEQ, ENOPKG, EROFS, ECONNREFUSED, ELIBMAX, ELOOP, EUSERS, ECOMM, EL2HLT, EIDRM, ENOTBLK, ENOTTY, EOPNOTSUPP, EISNAM, ELIBACC, EIO, EPROTOTYPE, EUCLEAN, ENOSTR, EOVERFLOW, EADDRINUSE, ELIBBAD, ENOENT, EAFNOSUPPORT, EMULTIHOP, ENOSR, exportAllErrnosViaEnumOrImportc, ErrnoCount, EINPROGRESS, E2BIG, ESTALE, EBUSY, ENOMEDIUM, ENOANO, EFBIG, EUNATCH, EOWNERDEAD, ESOCKTNOSUPPORT, EXFULL, ELIBEXEC, ERANGE, EL3HLT, ENOSPC, EBADSLT, EDEADLOCK, EEXIST, ENETRESET, EREMOTEIO, EPFNOSUPPORT, ENOLINK, isErr0, ENOMSG, ENOTSUP, prepareRWErrno, EMSGSIZE, EPIPE, EBADE, ENOMEM, ENOTSOCK, ELIBSCN, ENOPROTOOPT, EDESTADDRREQ, ENOTNAM, EADV, EDOTDOT, EKEYEXPIRED, EINTR, EBADR, EL3RST, EAGAIN, ENOTUNIQ, EWOULDBLOCK, ENAVAIL, ENAMETOOLONG, EREMOTE, ETXTBSY +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/errno.idx b/Lib/errno.idx new file mode 100644 index 000000000..ae106004f --- /dev/null +++ b/Lib/errno.idx @@ -0,0 +1 @@ +nimTitle errno errno.html module src/pylib/Lib/errno 0 diff --git a/Lib/errno_impl/errnoConsts.html b/Lib/errno_impl/errnoConsts.html new file mode 100644 index 000000000..222158f5a --- /dev/null +++ b/Lib/errno_impl/errnoConsts.html @@ -0,0 +1,1564 @@ + + + + + + + +src/pylib/Lib/errno_impl/errnoConsts + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/errno_impl/errnoConsts

+
+ +
+ Source   +Edit   + +
+ +

+ +
+

Lets

+
+
+
E2BIG {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EACCES {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EADDRINUSE {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EADDRNOTAVAIL {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EADV {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EAFNOSUPPORT {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EAGAIN {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EALREADY {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EBADE {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EBADF {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EBADFD {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EBADMSG {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EBADR {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EBADRQC {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EBADSLT {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EBFONT {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EBUSY {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ECANCELED {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ECHILD {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ECHRNG {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ECOMM {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ECONNABORTED {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ECONNREFUSED {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ECONNRESET {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EDEADLK {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EDEADLOCK {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EDESTADDRREQ {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EDOM {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EDOTDOT {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EDQUOT {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EEXIST {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EFAULT {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EFBIG {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EHOSTDOWN {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EHOSTUNREACH {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EIDRM {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EILSEQ {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EINPROGRESS {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EINTR {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EINVAL {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EIO {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EISCONN {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EISDIR {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EISNAM {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EKEYEXPIRED {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EKEYREJECTED {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EKEYREVOKED {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EL2HLT {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EL2NSYNC {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EL3HLT {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EL3RST {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ELIBACC {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ELIBBAD {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ELIBEXEC {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ELIBMAX {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ELIBSCN {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ELNRNG {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ELOOP {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EMEDIUMTYPE {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EMFILE {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+ +
+
EMSGSIZE {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EMULTIHOP {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ENAMETOOLONG {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ENAVAIL {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ENETDOWN {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ENETRESET {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ENETUNREACH {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ENFILE {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ENOANO {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ENOBUFS {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ENOCSI {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ENODATA {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ENODEV {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ENOENT {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ENOEXEC {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ENOKEY {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ENOLCK {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+ +
+
ENOMEDIUM {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ENOMEM {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ENOMSG {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ENONET {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ENOPKG {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ENOPROTOOPT {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ENOSPC {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ENOSR {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ENOSTR {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ENOSYS {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ENOTBLK {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ENOTCONN {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ENOTDIR {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ENOTEMPTY {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ENOTNAM {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ENOTRECOVERABLE {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ENOTSOCK {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ENOTSUP {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ENOTTY {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ENOTUNIQ {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ENXIO {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EOPNOTSUPP {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EOVERFLOW {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EOWNERDEAD {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EPERM {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EPFNOSUPPORT {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EPIPE {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EPROTO {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EPROTONOSUPPORT {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EPROTOTYPE {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ERANGE {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EREMCHG {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EREMOTE {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EREMOTEIO {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ERESTART {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ERFKILL {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EROFS {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ESHUTDOWN {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ESOCKTNOSUPPORT {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ESPIPE {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ESRCH {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ESRMNT {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ESTALE {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ESTRPIPE {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ETIME {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ETIMEDOUT {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ETOOMANYREFS {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ETXTBSY {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EUCLEAN {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EUNATCH {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EUSERS {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EWOULDBLOCK {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EXDEV {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EXFULL {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/errno_impl/errnoConsts.idx b/Lib/errno_impl/errnoConsts.idx new file mode 100644 index 000000000..c5c145277 --- /dev/null +++ b/Lib/errno_impl/errnoConsts.idx @@ -0,0 +1,134 @@ +nimTitle errnoConsts errno_impl/errnoConsts.html module src/pylib/Lib/errno_impl/errnoConsts 0 +nim E2BIG errno_impl/errnoConsts.html#E2BIG let E2BIG 13 +nim EACCES errno_impl/errnoConsts.html#EACCES let EACCES 13 +nim EADDRINUSE errno_impl/errnoConsts.html#EADDRINUSE let EADDRINUSE 13 +nim EADDRNOTAVAIL errno_impl/errnoConsts.html#EADDRNOTAVAIL let EADDRNOTAVAIL 13 +nim EADV errno_impl/errnoConsts.html#EADV let EADV 13 +nim EAFNOSUPPORT errno_impl/errnoConsts.html#EAFNOSUPPORT let EAFNOSUPPORT 13 +nim EAGAIN errno_impl/errnoConsts.html#EAGAIN let EAGAIN 13 +nim EALREADY errno_impl/errnoConsts.html#EALREADY let EALREADY 13 +nim EBADE errno_impl/errnoConsts.html#EBADE let EBADE 13 +nim EBADF errno_impl/errnoConsts.html#EBADF let EBADF 13 +nim EBADFD errno_impl/errnoConsts.html#EBADFD let EBADFD 13 +nim EBADMSG errno_impl/errnoConsts.html#EBADMSG let EBADMSG 13 +nim EBADR errno_impl/errnoConsts.html#EBADR let EBADR 13 +nim EBADRQC errno_impl/errnoConsts.html#EBADRQC let EBADRQC 13 +nim EBADSLT errno_impl/errnoConsts.html#EBADSLT let EBADSLT 13 +nim EBFONT errno_impl/errnoConsts.html#EBFONT let EBFONT 13 +nim EBUSY errno_impl/errnoConsts.html#EBUSY let EBUSY 13 +nim ECANCELED errno_impl/errnoConsts.html#ECANCELED let ECANCELED 13 +nim ECHILD errno_impl/errnoConsts.html#ECHILD let ECHILD 13 +nim ECHRNG errno_impl/errnoConsts.html#ECHRNG let ECHRNG 13 +nim ECOMM errno_impl/errnoConsts.html#ECOMM let ECOMM 13 +nim ECONNABORTED errno_impl/errnoConsts.html#ECONNABORTED let ECONNABORTED 13 +nim ECONNREFUSED errno_impl/errnoConsts.html#ECONNREFUSED let ECONNREFUSED 13 +nim ECONNRESET errno_impl/errnoConsts.html#ECONNRESET let ECONNRESET 13 +nim EDEADLK errno_impl/errnoConsts.html#EDEADLK let EDEADLK 13 +nim EDEADLOCK errno_impl/errnoConsts.html#EDEADLOCK let EDEADLOCK 13 +nim EDESTADDRREQ errno_impl/errnoConsts.html#EDESTADDRREQ let EDESTADDRREQ 13 +nim EDOM errno_impl/errnoConsts.html#EDOM let EDOM 13 +nim EDOTDOT errno_impl/errnoConsts.html#EDOTDOT let EDOTDOT 13 +nim EDQUOT errno_impl/errnoConsts.html#EDQUOT let EDQUOT 13 +nim EEXIST errno_impl/errnoConsts.html#EEXIST let EEXIST 13 +nim EFAULT errno_impl/errnoConsts.html#EFAULT let EFAULT 13 +nim EFBIG errno_impl/errnoConsts.html#EFBIG let EFBIG 13 +nim EHOSTDOWN errno_impl/errnoConsts.html#EHOSTDOWN let EHOSTDOWN 13 +nim EHOSTUNREACH errno_impl/errnoConsts.html#EHOSTUNREACH let EHOSTUNREACH 13 +nim EIDRM errno_impl/errnoConsts.html#EIDRM let EIDRM 13 +nim EILSEQ errno_impl/errnoConsts.html#EILSEQ let EILSEQ 13 +nim EINPROGRESS errno_impl/errnoConsts.html#EINPROGRESS let EINPROGRESS 13 +nim EINTR errno_impl/errnoConsts.html#EINTR let EINTR 13 +nim EINVAL errno_impl/errnoConsts.html#EINVAL let EINVAL 13 +nim EIO errno_impl/errnoConsts.html#EIO let EIO 13 +nim EISCONN errno_impl/errnoConsts.html#EISCONN let EISCONN 13 +nim EISDIR errno_impl/errnoConsts.html#EISDIR let EISDIR 13 +nim EISNAM errno_impl/errnoConsts.html#EISNAM let EISNAM 13 +nim EKEYEXPIRED errno_impl/errnoConsts.html#EKEYEXPIRED let EKEYEXPIRED 13 +nim EKEYREJECTED errno_impl/errnoConsts.html#EKEYREJECTED let EKEYREJECTED 13 +nim EKEYREVOKED errno_impl/errnoConsts.html#EKEYREVOKED let EKEYREVOKED 13 +nim EL2HLT errno_impl/errnoConsts.html#EL2HLT let EL2HLT 13 +nim EL2NSYNC errno_impl/errnoConsts.html#EL2NSYNC let EL2NSYNC 13 +nim EL3HLT errno_impl/errnoConsts.html#EL3HLT let EL3HLT 13 +nim EL3RST errno_impl/errnoConsts.html#EL3RST let EL3RST 13 +nim ELIBACC errno_impl/errnoConsts.html#ELIBACC let ELIBACC 13 +nim ELIBBAD errno_impl/errnoConsts.html#ELIBBAD let ELIBBAD 13 +nim ELIBEXEC errno_impl/errnoConsts.html#ELIBEXEC let ELIBEXEC 13 +nim ELIBMAX errno_impl/errnoConsts.html#ELIBMAX let ELIBMAX 13 +nim ELIBSCN errno_impl/errnoConsts.html#ELIBSCN let ELIBSCN 13 +nim ELNRNG errno_impl/errnoConsts.html#ELNRNG let ELNRNG 13 +nim ELOOP errno_impl/errnoConsts.html#ELOOP let ELOOP 13 +nim EMEDIUMTYPE errno_impl/errnoConsts.html#EMEDIUMTYPE let EMEDIUMTYPE 13 +nim EMFILE errno_impl/errnoConsts.html#EMFILE let EMFILE 13 +nim EMLINK errno_impl/errnoConsts.html#EMLINK let EMLINK 13 +nim EMSGSIZE errno_impl/errnoConsts.html#EMSGSIZE let EMSGSIZE 13 +nim EMULTIHOP errno_impl/errnoConsts.html#EMULTIHOP let EMULTIHOP 13 +nim ENAMETOOLONG errno_impl/errnoConsts.html#ENAMETOOLONG let ENAMETOOLONG 13 +nim ENAVAIL errno_impl/errnoConsts.html#ENAVAIL let ENAVAIL 13 +nim ENETDOWN errno_impl/errnoConsts.html#ENETDOWN let ENETDOWN 13 +nim ENETRESET errno_impl/errnoConsts.html#ENETRESET let ENETRESET 13 +nim ENETUNREACH errno_impl/errnoConsts.html#ENETUNREACH let ENETUNREACH 13 +nim ENFILE errno_impl/errnoConsts.html#ENFILE let ENFILE 13 +nim ENOANO errno_impl/errnoConsts.html#ENOANO let ENOANO 13 +nim ENOBUFS errno_impl/errnoConsts.html#ENOBUFS let ENOBUFS 13 +nim ENOCSI errno_impl/errnoConsts.html#ENOCSI let ENOCSI 13 +nim ENODATA errno_impl/errnoConsts.html#ENODATA let ENODATA 13 +nim ENODEV errno_impl/errnoConsts.html#ENODEV let ENODEV 13 +nim ENOENT errno_impl/errnoConsts.html#ENOENT let ENOENT 13 +nim ENOEXEC errno_impl/errnoConsts.html#ENOEXEC let ENOEXEC 13 +nim ENOKEY errno_impl/errnoConsts.html#ENOKEY let ENOKEY 13 +nim ENOLCK errno_impl/errnoConsts.html#ENOLCK let ENOLCK 13 +nim ENOLINK errno_impl/errnoConsts.html#ENOLINK let ENOLINK 13 +nim ENOMEDIUM errno_impl/errnoConsts.html#ENOMEDIUM let ENOMEDIUM 13 +nim ENOMEM errno_impl/errnoConsts.html#ENOMEM let ENOMEM 13 +nim ENOMSG errno_impl/errnoConsts.html#ENOMSG let ENOMSG 13 +nim ENONET errno_impl/errnoConsts.html#ENONET let ENONET 13 +nim ENOPKG errno_impl/errnoConsts.html#ENOPKG let ENOPKG 13 +nim ENOPROTOOPT errno_impl/errnoConsts.html#ENOPROTOOPT let ENOPROTOOPT 13 +nim ENOSPC errno_impl/errnoConsts.html#ENOSPC let ENOSPC 13 +nim ENOSR errno_impl/errnoConsts.html#ENOSR let ENOSR 13 +nim ENOSTR errno_impl/errnoConsts.html#ENOSTR let ENOSTR 13 +nim ENOSYS errno_impl/errnoConsts.html#ENOSYS let ENOSYS 13 +nim ENOTBLK errno_impl/errnoConsts.html#ENOTBLK let ENOTBLK 13 +nim ENOTCONN errno_impl/errnoConsts.html#ENOTCONN let ENOTCONN 13 +nim ENOTDIR errno_impl/errnoConsts.html#ENOTDIR let ENOTDIR 13 +nim ENOTEMPTY errno_impl/errnoConsts.html#ENOTEMPTY let ENOTEMPTY 13 +nim ENOTNAM errno_impl/errnoConsts.html#ENOTNAM let ENOTNAM 13 +nim ENOTRECOVERABLE errno_impl/errnoConsts.html#ENOTRECOVERABLE let ENOTRECOVERABLE 13 +nim ENOTSOCK errno_impl/errnoConsts.html#ENOTSOCK let ENOTSOCK 13 +nim ENOTSUP errno_impl/errnoConsts.html#ENOTSUP let ENOTSUP 13 +nim ENOTTY errno_impl/errnoConsts.html#ENOTTY let ENOTTY 13 +nim ENOTUNIQ errno_impl/errnoConsts.html#ENOTUNIQ let ENOTUNIQ 13 +nim ENXIO errno_impl/errnoConsts.html#ENXIO let ENXIO 13 +nim EOPNOTSUPP errno_impl/errnoConsts.html#EOPNOTSUPP let EOPNOTSUPP 13 +nim EOVERFLOW errno_impl/errnoConsts.html#EOVERFLOW let EOVERFLOW 13 +nim EOWNERDEAD errno_impl/errnoConsts.html#EOWNERDEAD let EOWNERDEAD 13 +nim EPERM errno_impl/errnoConsts.html#EPERM let EPERM 13 +nim EPFNOSUPPORT errno_impl/errnoConsts.html#EPFNOSUPPORT let EPFNOSUPPORT 13 +nim EPIPE errno_impl/errnoConsts.html#EPIPE let EPIPE 13 +nim EPROTO errno_impl/errnoConsts.html#EPROTO let EPROTO 13 +nim EPROTONOSUPPORT errno_impl/errnoConsts.html#EPROTONOSUPPORT let EPROTONOSUPPORT 13 +nim EPROTOTYPE errno_impl/errnoConsts.html#EPROTOTYPE let EPROTOTYPE 13 +nim ERANGE errno_impl/errnoConsts.html#ERANGE let ERANGE 13 +nim EREMCHG errno_impl/errnoConsts.html#EREMCHG let EREMCHG 13 +nim EREMOTE errno_impl/errnoConsts.html#EREMOTE let EREMOTE 13 +nim EREMOTEIO errno_impl/errnoConsts.html#EREMOTEIO let EREMOTEIO 13 +nim ERESTART errno_impl/errnoConsts.html#ERESTART let ERESTART 13 +nim ERFKILL errno_impl/errnoConsts.html#ERFKILL let ERFKILL 13 +nim EROFS errno_impl/errnoConsts.html#EROFS let EROFS 13 +nim ESHUTDOWN errno_impl/errnoConsts.html#ESHUTDOWN let ESHUTDOWN 13 +nim ESOCKTNOSUPPORT errno_impl/errnoConsts.html#ESOCKTNOSUPPORT let ESOCKTNOSUPPORT 13 +nim ESPIPE errno_impl/errnoConsts.html#ESPIPE let ESPIPE 13 +nim ESRCH errno_impl/errnoConsts.html#ESRCH let ESRCH 13 +nim ESRMNT errno_impl/errnoConsts.html#ESRMNT let ESRMNT 13 +nim ESTALE errno_impl/errnoConsts.html#ESTALE let ESTALE 13 +nim ESTRPIPE errno_impl/errnoConsts.html#ESTRPIPE let ESTRPIPE 13 +nim ETIME errno_impl/errnoConsts.html#ETIME let ETIME 13 +nim ETIMEDOUT errno_impl/errnoConsts.html#ETIMEDOUT let ETIMEDOUT 13 +nim ETOOMANYREFS errno_impl/errnoConsts.html#ETOOMANYREFS let ETOOMANYREFS 13 +nim ETXTBSY errno_impl/errnoConsts.html#ETXTBSY let ETXTBSY 13 +nim EUCLEAN errno_impl/errnoConsts.html#EUCLEAN let EUCLEAN 13 +nim EUNATCH errno_impl/errnoConsts.html#EUNATCH let EUNATCH 13 +nim EUSERS errno_impl/errnoConsts.html#EUSERS let EUSERS 13 +nim EWOULDBLOCK errno_impl/errnoConsts.html#EWOULDBLOCK let EWOULDBLOCK 13 +nim EXDEV errno_impl/errnoConsts.html#EXDEV let EXDEV 13 +nim EXFULL errno_impl/errnoConsts.html#EXFULL let EXFULL 13 diff --git a/Lib/errno_impl/errnoUtils.html b/Lib/errno_impl/errnoUtils.html new file mode 100644 index 000000000..913a8410a --- /dev/null +++ b/Lib/errno_impl/errnoUtils.html @@ -0,0 +1,260 @@ + + + + + + + +src/pylib/Lib/errno_impl/errnoUtils + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/errno_impl/errnoUtils

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

EXT. stable

+ +
+

Procs

+
+
+
+
proc getErrno(): cint {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template isErr(E: untyped): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template isErr0(): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template prepareROErrno() {.dirty.}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template prepareRWErrno() {.dirty.}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template setErrno(v: untyped)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template setErrno0()
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template setErrnoRaw(v: cint)
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ + +
+
+ + +
+
+ + + diff --git a/Lib/errno_impl/errnoUtils.idx b/Lib/errno_impl/errnoUtils.idx new file mode 100644 index 000000000..953a56ae8 --- /dev/null +++ b/Lib/errno_impl/errnoUtils.idx @@ -0,0 +1,9 @@ +nimTitle errnoUtils errno_impl/errnoUtils.html module src/pylib/Lib/errno_impl/errnoUtils 0 +nim prepareRWErrno errno_impl/errnoUtils.html#prepareRWErrno.t template prepareRWErrno() 6 +nim prepareROErrno errno_impl/errnoUtils.html#prepareROErrno.t template prepareROErrno() 8 +nim setErrnoRaw errno_impl/errnoUtils.html#setErrnoRaw.t,cint template setErrnoRaw(v: cint) 12 +nim setErrno errno_impl/errnoUtils.html#setErrno.t,untyped template setErrno(v: untyped) 19 +nim setErrno0 errno_impl/errnoUtils.html#setErrno0.t template setErrno0() 26 +nim getErrno errno_impl/errnoUtils.html#getErrno proc getErrno(): cint 33 +nim isErr errno_impl/errnoUtils.html#isErr.t,untyped template isErr(E: untyped): bool 41 +nim isErr0 errno_impl/errnoUtils.html#isErr0.t template isErr0(): bool 51 diff --git a/Lib/errno_impl/private/clike.html b/Lib/errno_impl/private/clike.html new file mode 100644 index 000000000..ee8a26c59 --- /dev/null +++ b/Lib/errno_impl/private/clike.html @@ -0,0 +1,96 @@ + + + + + + + +src/pylib/Lib/errno_impl/private/clike + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/errno_impl/private/clike

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Exports

+
+ CLike +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/errno_impl/private/clike.idx b/Lib/errno_impl/private/clike.idx new file mode 100644 index 000000000..da4f819b4 --- /dev/null +++ b/Lib/errno_impl/private/clike.idx @@ -0,0 +1 @@ +nimTitle clike errno_impl/private/clike.html module src/pylib/Lib/errno_impl/private/clike 0 diff --git a/Lib/errno_impl/private/errnos.html b/Lib/errno_impl/private/errnos.html new file mode 100644 index 000000000..357f44c7c --- /dev/null +++ b/Lib/errno_impl/private/errnos.html @@ -0,0 +1,340 @@ + + + + + + + +src/pylib/Lib/errno_impl/private/errnos + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/errno_impl/private/errnos

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Types

+
+
+
Errno {.pure.} = enum
+  E_SUCCESS = "success",    ## inner. unstable.
+  E2BIG = "Argument list too long", EACCES = "Permission denied",
+  EADDRINUSE = "Address already in use",
+  EADDRNOTAVAIL = "Cannot assign requested address", EADV = "Advertise error",
+  EAFNOSUPPORT = "Address family not supported by protocol",
+  EAGAIN = "Resource temporarily unavailable",
+  EALREADY = "Operation already in progress", EBADE = "Invalid exchange",
+  EBADF = "Bad file descriptor", EBADFD = "File descriptor in bad state",
+  EBADMSG = "Bad message", EBADR = "Invalid request descriptor",
+  EBADRQC = "Invalid request code", EBADSLT = "Invalid slot",
+  EBFONT = "Bad font file format", EBUSY = "Device or resource busy",
+  ECANCELED = "Operation canceled", ECHILD = "No child processes",
+  ECHRNG = "Channel number out of range", ECOMM = "Communication error on send",
+  ECONNABORTED = "Software caused connection abort",
+  ECONNREFUSED = "Connection refused", ECONNRESET = "Connection reset by peer",
+  EDEADLK = "Resource deadlock avoided",
+  EDEADLOCK = "Resource deadlock avoided",
+  EDESTADDRREQ = "Destination address required",
+  EDOM = "Numerical argument out of domain", EDOTDOT = "RFS specific error",
+  EDQUOT = "Disk quota exceeded", EEXIST = "File exists",
+  EFAULT = "Bad address", EFBIG = "File too large", EHOSTDOWN = "Host is down",
+  EHOSTUNREACH = "No route to host", EIDRM = "Identifier removed",
+  EILSEQ = "Invalid or incomplete multibyte or wide character",
+  EINPROGRESS = "Operation now in progress", EINTR = "Interrupted system call",
+  EINVAL = "Invalid argument", EIO = "Input/output error",
+  EISCONN = "Transport endpoint is already connected",
+  EISDIR = "Is a directory", EISNAM = "Is a named type file",
+  EKEYEXPIRED = "Key has expired", EKEYREJECTED = "Key was rejected by service",
+  EKEYREVOKED = "Key has been revoked", EL2HLT = "Level 2 halted",
+  EL2NSYNC = "Level 2 not synchronized", EL3HLT = "Level 3 halted",
+  EL3RST = "Level 3 reset", ELIBACC = "Can not access a needed shared library",
+  ELIBBAD = "Accessing a corrupted shared library",
+  ELIBEXEC = "Cannot exec a shared library directly",
+  ELIBMAX = "Attempting to link in too many shared libraries",
+  ELIBSCN = ".lib section in a.out corrupted",
+  ELNRNG = "Link number out of range",
+  ELOOP = "Too many levels of symbolic links",
+  EMEDIUMTYPE = "Wrong medium type", EMFILE = "Too many open files",
+  EMLINK = "Too many links", EMSGSIZE = "Message too long",
+  EMULTIHOP = "Multihop attempted", ENAMETOOLONG = "File name too long",
+  ENAVAIL = "No XENIX semaphores available", ENETDOWN = "Network is down",
+  ENETRESET = "Network dropped connection on reset",
+  ENETUNREACH = "Network is unreachable",
+  ENFILE = "Too many open files in system", ENOANO = "No anode",
+  ENOBUFS = "No buffer space available", ENOCSI = "No CSI structure available",
+  ENODATA = "No data available", ENODEV = "No such device",
+  ENOENT = "No such file or directory", ENOEXEC = "Exec format error",
+  ENOKEY = "Required key not available", ENOLCK = "No locks available",
+  ENOLINK = "Link has been severed", ENOMEDIUM = "No medium found",
+  ENOMEM = "Cannot allocate memory", ENOMSG = "No message of desired type",
+  ENONET = "Machine is not on the network", ENOPKG = "Package not installed",
+  ENOPROTOOPT = "Protocol not available", ENOSPC = "No space left on device",
+  ENOSR = "Out of streams resources", ENOSTR = "Device not a stream",
+  ENOSYS = "Function not implemented", ENOTBLK = "Block device required",
+  ENOTCONN = "Transport endpoint is not connected", ENOTDIR = "Not a directory",
+  ENOTEMPTY = "Directory not empty", ENOTNAM = "Not a XENIX named type file",
+  ENOTRECOVERABLE = "State not recoverable",
+  ENOTSOCK = "Socket operation on non-socket",
+  ENOTSUP = "Operation not supported",
+  ENOTTY = "Inappropriate ioctl for device",
+  ENOTUNIQ = "Name not unique on network", ENXIO = "No such device or address",
+  EOPNOTSUPP = "Operation not supported",
+  EOVERFLOW = "Value too large for defined data type",
+  EOWNERDEAD = "Owner died", EPERM = "Operation not permitted",
+  EPFNOSUPPORT = "Protocol family not supported", EPIPE = "Broken pipe",
+  EPROTO = "Protocol error", EPROTONOSUPPORT = "Protocol not supported",
+  EPROTOTYPE = "Protocol wrong type for socket",
+  ERANGE = "Numerical result out of range", EREMCHG = "Remote address changed",
+  EREMOTE = "Object is remote", EREMOTEIO = "Remote I/O error",
+  ERESTART = "Interrupted system call should be restarted",
+  ERFKILL = "Operation not possible due to RF-kill",
+  EROFS = "Read-only file system",
+  ESHUTDOWN = "Cannot send after transport endpoint shutdown",
+  ESOCKTNOSUPPORT = "Socket type not supported", ESPIPE = "Illegal seek",
+  ESRCH = "No such process", ESRMNT = "Srmount error",
+  ESTALE = "Stale file handle", ESTRPIPE = "Streams pipe error",
+  ETIME = "Timer expired", ETIMEDOUT = "Connection timed out",
+  ETOOMANYREFS = "Too many references: cannot splice",
+  ETXTBSY = "Text file busy", EUCLEAN = "Structure needs cleaning",
+  EUNATCH = "Protocol driver not attached", EUSERS = "Too many users",
+  EWOULDBLOCK = "Resource temporarily unavailable",
+  EXDEV = "Invalid cross-device link", EXFULL = "Exchange full"
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Consts

+
+
+
ErrnoCount = 133
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
func `$`(e: Errno): string {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func strerror(e: Errno): string {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/errno_impl/private/errnos.idx b/Lib/errno_impl/private/errnos.idx new file mode 100644 index 000000000..1dedd9d51 --- /dev/null +++ b/Lib/errno_impl/private/errnos.idx @@ -0,0 +1,5 @@ +nimTitle errnos errno_impl/private/errnos.html module src/pylib/Lib/errno_impl/private/errnos 0 +nim Errno errno_impl/private/errnos.html#Errno enum Errno 6 +nim ErrnoCount errno_impl/private/errnos.html#ErrnoCount const ErrnoCount 143 +nim strerror errno_impl/private/errnos.html#strerror,Errno proc strerror(e: Errno): string 145 +nim `$` errno_impl/private/errnos.html#$,Errno proc `$`(e: Errno): string 147 diff --git a/Lib/errno_impl/private/errorcodeInit.html b/Lib/errno_impl/private/errorcodeInit.html new file mode 100644 index 000000000..5fa72342a --- /dev/null +++ b/Lib/errno_impl/private/errorcodeInit.html @@ -0,0 +1,158 @@ + + + + + + + +src/pylib/Lib/errno_impl/private/errorcodeInit + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/errno_impl/private/errorcodeInit

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Macros

+
+
+
+
macro initErrorcodeMap(K, V; res: untyped; initFunc: typed)
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template declErrorcodeWith[K, V](initFunc: typed)
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ + +
+
+ + +
+
+ + + diff --git a/Lib/errno_impl/private/errorcodeInit.idx b/Lib/errno_impl/private/errorcodeInit.idx new file mode 100644 index 000000000..ad885be26 --- /dev/null +++ b/Lib/errno_impl/private/errorcodeInit.idx @@ -0,0 +1,3 @@ +nimTitle errorcodeInit errno_impl/private/errorcodeInit.html module src/pylib/Lib/errno_impl/private/errorcodeInit 0 +nim initErrorcodeMap errno_impl/private/errorcodeInit.html#initErrorcodeMap.m,,,untyped,typed macro initErrorcodeMap(K, V; res: untyped; initFunc: typed) 11 +nim declErrorcodeWith errno_impl/private/errorcodeInit.html#declErrorcodeWith.t,typed template declErrorcodeWith[K, V](initFunc: typed) 45 diff --git a/Lib/errno_impl/private/exportUtils.html b/Lib/errno_impl/private/exportUtils.html new file mode 100644 index 000000000..165176a73 --- /dev/null +++ b/Lib/errno_impl/private/exportUtils.html @@ -0,0 +1,127 @@ + + + + + + + +src/pylib/Lib/errno_impl/private/exportUtils + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/errno_impl/private/exportUtils

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Macros

+
+
+
+
macro exportAllErrnosViaEnumOrImportc()
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ + +
+
+ + +
+
+ + + diff --git a/Lib/errno_impl/private/exportUtils.idx b/Lib/errno_impl/private/exportUtils.idx new file mode 100644 index 000000000..b487f93bb --- /dev/null +++ b/Lib/errno_impl/private/exportUtils.idx @@ -0,0 +1,2 @@ +nimTitle exportUtils errno_impl/private/exportUtils.html module src/pylib/Lib/errno_impl/private/exportUtils 0 +nim exportAllErrnosViaEnumOrImportc errno_impl/private/exportUtils.html#exportAllErrnosViaEnumOrImportc.m macro exportAllErrnosViaEnumOrImportc() 17 diff --git a/Lib/errno_impl/private/loopErrno.html b/Lib/errno_impl/private/loopErrno.html new file mode 100644 index 000000000..08a82eeac --- /dev/null +++ b/Lib/errno_impl/private/loopErrno.html @@ -0,0 +1,135 @@ + + + + + + + +src/pylib/Lib/errno_impl/private/loopErrno + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/errno_impl/private/loopErrno

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Imports

+
+ clike, errnos +
+
+
+

Templates

+
+
+
+
template forErrno(res: NimNode; err; body)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template whenDefErrno(res: NimNode; errnoName: string; body): untyped {.dirty.}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/errno_impl/private/loopErrno.idx b/Lib/errno_impl/private/loopErrno.idx new file mode 100644 index 000000000..0ffc19984 --- /dev/null +++ b/Lib/errno_impl/private/loopErrno.idx @@ -0,0 +1,3 @@ +nimTitle loopErrno errno_impl/private/loopErrno.html module src/pylib/Lib/errno_impl/private/loopErrno 0 +nim whenDefErrno errno_impl/private/loopErrno.html#whenDefErrno.t,NimNode,string, template whenDefErrno(res: NimNode; errnoName: string; body): untyped 14 +nim forErrno errno_impl/private/loopErrno.html#forErrno.t,NimNode,, template forErrno(res: NimNode; err; body) 26 diff --git a/Lib/errno_impl/private/singleton_errno.html b/Lib/errno_impl/private/singleton_errno.html new file mode 100644 index 000000000..08bd62a5b --- /dev/null +++ b/Lib/errno_impl/private/singleton_errno.html @@ -0,0 +1,123 @@ + + + + + + + +src/pylib/Lib/errno_impl/private/singleton_errno + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/errno_impl/private/singleton_errno

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Imports

+
+ clike +
+
+
+

Vars

+
+
+
errno {.importc: "errno", header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
staticErrno {.compileTime.}: cint
+
+ + used compile time + Source   +Edit   + +
+
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/errno_impl/private/singleton_errno.idx b/Lib/errno_impl/private/singleton_errno.idx new file mode 100644 index 000000000..0de260d4c --- /dev/null +++ b/Lib/errno_impl/private/singleton_errno.idx @@ -0,0 +1,3 @@ +nimTitle singleton_errno errno_impl/private/singleton_errno.html module src/pylib/Lib/errno_impl/private/singleton_errno 0 +nim errno errno_impl/private/singleton_errno.html#errno var errno 4 +nim staticErrno errno_impl/private/singleton_errno.html#staticErrno var staticErrno 8 diff --git a/Lib/fractions.html b/Lib/fractions.html new file mode 100644 index 000000000..680fa6860 --- /dev/null +++ b/Lib/fractions.html @@ -0,0 +1,1127 @@ + + + + + + + +src/pylib/Lib/fractions + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/fractions

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Types

+
+
+
FractionInt = int
+
+ + + Source   +Edit   + +
+
+
+
PyFraction = TFraction[FractionInt]
+
+ + + Source   +Edit   + +
+
+
+
TFraction[T] = ref object
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
func `$`(self: PyFraction): string {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func `%`(a, b: PyFraction): PyFraction {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func `%`(a: PyFraction; b: float): float {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func `%`(a: PyFraction; b: int): PyFraction {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func `%`(b: float; a: PyFraction): float {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func `%`(b: int; a: PyFraction): PyFraction {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func `%=`(self: PyFraction; other: PyFraction) {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func `*`(a, b: PyFraction): PyFraction {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func `*`(a: PyFraction; b: float): float {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func `*`(a: PyFraction; b: int): PyFraction {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func `*`(b: float; a: PyFraction): float {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func `*`(b: int; a: PyFraction): PyFraction {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func `*=`(a, b: PyFraction) {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func `*=`(a: PyFraction; b: float) {.error: "Python allowed this but make `self` to a float".}
+
+ + + Source   +Edit   + +
+
+
+
func `*=`(a: PyFraction; b: int) {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func `+`(a, b: PyFraction): PyFraction {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func `+`(a: PyFraction; b: float): float {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func `+`(a: PyFraction; b: int): PyFraction {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func `+`(b: float; a: PyFraction): float {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func `+`(b: int; a: PyFraction): PyFraction {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func `+=`(a, b: PyFraction) {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func `+=`(a: PyFraction; b: float) {.error: "Python allowed this but make `self` to a float".}
+
+ + + Source   +Edit   + +
+
+
+
func `+=`(a: PyFraction; b: int) {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func `-`(a, b: PyFraction): PyFraction {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func `-`(a: PyFraction; b: float): float {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func `-`(a: PyFraction; b: int): PyFraction {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func `-`(b: float; a: PyFraction): float {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func `-`(b: int; a: PyFraction): PyFraction {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func `-=`(a, b: PyFraction) {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func `-=`(a: PyFraction; b: float) {.error: "Python allowed this but make `self` to a float".}
+
+ + + Source   +Edit   + +
+
+
+
func `-=`(a: PyFraction; b: int) {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func `/`(a, b: PyFraction): PyFraction {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func `/`(a: PyFraction; b: float): float {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func `/`(a: PyFraction; b: int): PyFraction {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func `/`(b: float; a: PyFraction): float {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func `/`(b: int; a: PyFraction): PyFraction {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func `//`(a, b: PyFraction): FractionInt {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func `/=`(a, b: PyFraction) {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func `/=`(a: PyFraction; b: float) {.error: "Python allowed this but make `self` to a float".}
+
+ + + Source   +Edit   + +
+
+
+
func `/=`(a: PyFraction; b: int) {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func `<`(a, b: PyFraction): bool {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func `<=`(a, b: PyFraction): bool {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func `==`(a, b: PyFraction): bool {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func abs(self: PyFraction): PyFraction {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func as_integer_ratio(self: PyFraction): (FractionInt, FractionInt) {.
+    ...raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func ceil(self: PyFraction): int {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func denominator(self: PyFraction): FractionInt {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func denominator=(self: PyFraction; v: FractionInt) {.
+    error: "AttributeError: can\'t set attribute".}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func float(self: PyFraction): system.float {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func floor(self: PyFraction): int {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func Fraction(f: float): PyFraction {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func Fraction(numerator = 0; denominator = 1): PyFraction {....raises: [],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func Fraction(other: PyFraction): PyFraction {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func Fraction(str: string): PyFraction {....raises: [ValueError], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func from_float(typ: typedesc[PyFraction]; flt: float): PyFraction
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func hash(self: PyFraction): int {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func is_integer(self: PyFraction): bool {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func newPyFraction(): PyFraction {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func numerator(self: PyFraction): FractionInt {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func numerator=(self: PyFraction; v: FractionInt) {.
+    error: "AttributeError: can\'t set attribute".}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func repr(self: PyFraction): string {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func round(self: PyFraction): int {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func round(self: PyFraction; ndigits: int): float {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func toPyFraction(r: Rational[int]): PyFraction {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func toTFraction[T](r: Rational[T]): PyFraction
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template conjugate(self: PyFraction): PyFraction
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template imag(self: PyFraction): int
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template real(self: PyFraction): PyFraction
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/future.html b/Lib/future.html new file mode 100644 index 000000000..66ef3ce10 --- /dev/null +++ b/Lib/future.html @@ -0,0 +1,103 @@ + + + + + + + +src/pylib/Lib/future + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/future

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Consts

+
+
+
braces = nil
+
+ + + Source   +Edit   + +
+
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/gc.html b/Lib/gc.html new file mode 100644 index 000000000..d9a4275c0 --- /dev/null +++ b/Lib/gc.html @@ -0,0 +1,177 @@ + + + + + + + +src/pylib/Lib/gc + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/gc

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

Lib/gc +

Nim's Memory Management

Since Nim 2.0, ORC becomes the default mm (memory management). In ORC, only a cycle collector will runs at runtime, so enable and disable only affect this cycle collector, a.k.a. collect for objects that not causes cycle cannot be disabled in runtime, as it's determined at compile-time, namely by ARC.

+

Document for Nim's mm.

+

Python's gc is similar with Nim's `refc` mm, which is default for Nim 1.x

+

As Nim's mm is so different from Python's gc, only a few APIs of gc can be ported to Nim.

+

+
+

Consts

+
+
+
GcCollectResult = 0
+
+ + Result of collect + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
proc collect(): int {.discardable, ...raises: [Exception], tags: [RootEffect],
+                      forbids: [].}
+
+ +
Hint: +Do not use the result. As there is no way to get the number of gc-ed objects current implement always returns GcCollectResult
+ + Source   +Edit   + +
+
+ +
+
+
+
proc disable() {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc enable() {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/index.html b/Lib/index.html new file mode 100644 index 000000000..cb3a572c9 --- /dev/null +++ b/Lib/index.html @@ -0,0 +1,122 @@ + + + + + + + +src/pylib/Lib/index + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/index

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+

Lib

Python standard libraries porting in nimpylib

+ +

+
+

Imports

+
+ genIndex +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/inspect.html b/Lib/inspect.html new file mode 100644 index 000000000..e127ea04f --- /dev/null +++ b/Lib/inspect.html @@ -0,0 +1,391 @@ + + + + + + + +src/pylib/Lib/inspect + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/inspect

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Iterators

+
+
+
+
iterator getmembers[T](obj: T): GetMemberType
+
+ + + Source   +Edit   + +
+
+
+
iterator getmembers[T](obj: T; predict: GetMembersPredict): GetMemberType
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template cleandoc(obj: PyStr): PyStr
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template getdoc(obj: untyped): OptionalObj[PyStr]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template getfile(obj: untyped): PyStr
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template getmembers(obj): PyList
+
+ + + Source   +Edit   + +
+
+
+
template getmembers(obj; predict: GetMembersPredict): PyList
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template getmembers_static(obj): untyped
+
+ +
Admonition: +since Python 3.11
+ + Source   +Edit   + +
+
+
+
template getmembers_static(obj; predict: GetMembersPredict): untyped
+
+ +
Admonition: +since Python 3.11
+ + Source   +Edit   + +
+
+ +
+
+
+
template getmodulename(obj: PyStr): OptionalObj[PyStr]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template getsource(obj: untyped): PyStr
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template getsourcefile(obj: untyped): OptionalObj[PyStr]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template getsourcelines(obj: typed): (PyList[PyStr], int)
+
+ + get source code of the object:
  • the first element is the source code
  • +
  • the second element is the line number of the first line of the source code
  • +
+ + Source   +Edit   + +
+
+ +
+
+
+
template isawaitable(obj: typed): bool
+
+ +
Admonition: +since Python 3.5
+ + Source   +Edit   + +
+
+ +
+
+
+
template iscoroutinefunction(obj: typed): bool
+
+ +
Admonition: +since Python 3.5
+ + Source   +Edit   + +
+
+ +
+
+
+
template markcoroutinefunction[T](obj: T): T
+
+ +
Admonition: +since Python 3.12
+ + Source   +Edit   + +
+
+ +
+ +
+
+ + +
+
+ + +
+
+ + + diff --git a/Lib/inspect.idx b/Lib/inspect.idx new file mode 100644 index 000000000..d8b791f20 --- /dev/null +++ b/Lib/inspect.idx @@ -0,0 +1,20 @@ +nimTitle inspect inspect.html module src/pylib/Lib/inspect 0 +nim getmembers inspect.html#getmembers.i,T iterator getmembers[T](obj: T): GetMemberType 20 +nim getmembers inspect.html#getmembers.i,T,GetMembersPredict iterator getmembers[T](obj: T; predict: GetMembersPredict): GetMemberType 21 +nim getmembers inspect.html#getmembers.t template getmembers(obj): PyList 28 +nim getmembers inspect.html#getmembers.t,,GetMembersPredict template getmembers(obj; predict: GetMembersPredict): PyList 32 +nim getmembers_static inspect.html#getmembers_static.t,,GetMembersPredict template getmembers_static(obj; predict: GetMembersPredict): untyped 36 +nim getmembers_static inspect.html#getmembers_static.t template getmembers_static(obj): untyped 36 +nim getmodulename inspect.html#getmodulename.t,PyStr template getmodulename(obj: PyStr): OptionalObj[PyStr] 46 +nim markcoroutinefunction inspect.html#markcoroutinefunction.t,T template markcoroutinefunction[T](obj: T): T 48 +nim iscoroutinefunction inspect.html#iscoroutinefunction.t,typed template iscoroutinefunction(obj: typed): bool 50 +nim isawaitable inspect.html#isawaitable.t,typed_2 template isawaitable(obj: typed): bool 51 +nim cleandoc inspect.html#cleandoc.t,PyStr template cleandoc(obj: PyStr): PyStr 59 +nim getfile inspect.html#getfile.t,untyped template getfile(obj: untyped): PyStr 60 +nim getsourcefile inspect.html#getsourcefile.t,untyped template getsourcefile(obj: untyped): OptionalObj[PyStr] 61 +nim getsource inspect.html#getsource.t,untyped template getsource(obj: untyped): PyStr 62 +nim getdoc inspect.html#getdoc.t,untyped template getdoc(obj: untyped): OptionalObj[PyStr] 63 +nim getsourcelines inspect.html#getsourcelines.t,typed template getsourcelines(obj: typed): (PyList[PyStr], int) 65 +nimgrp getmembers inspect.html#getmembers-iterators-all iterator 20 +nimgrp getmembers inspect.html#getmembers-templates-all template 28 +nimgrp getmembersstatic inspect.html#getmembers_static-templates-all template 84 diff --git a/Lib/inspect_impl/isX.html b/Lib/inspect_impl/isX.html new file mode 100644 index 000000000..7605f50ad --- /dev/null +++ b/Lib/inspect_impl/isX.html @@ -0,0 +1,293 @@ + + + + + + + +src/pylib/Lib/inspect_impl/isX + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/inspect_impl/isX

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Macros

+
+
+
+
macro isbuiltin(obj: typed): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
macro isclass(obj: typed): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
macro iscoroutine(obj: typed): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
macro iscoroutinefunction(obj: typed): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
macro isfunction(obj: typed): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
macro ismethod(obj: typed): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
macro ismodule(obj: typed): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
macro markcoroutinefunction[T](obj: T): T
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template isawaitable(obj: typed): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template isframe(obj: typed): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template istraceback(obj: typed): bool
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/inspect_impl/isX.idx b/Lib/inspect_impl/isX.idx new file mode 100644 index 000000000..000d9d58c --- /dev/null +++ b/Lib/inspect_impl/isX.idx @@ -0,0 +1,12 @@ +nimTitle isX inspect_impl/isX.html module src/pylib/Lib/inspect_impl/isX 0 +nim ismodule inspect_impl/isX.html#ismodule.m,typed macro ismodule(obj: typed): bool 14 +nim isclass inspect_impl/isX.html#isclass.m,typed macro isclass(obj: typed): bool 15 +nim ismethod inspect_impl/isX.html#ismethod.m,typed macro ismethod(obj: typed): bool 16 +nim isfunction inspect_impl/isX.html#isfunction.m,typed macro isfunction(obj: typed): bool 17 +nim markcoroutinefunction inspect_impl/isX.html#markcoroutinefunction.m,T macro markcoroutinefunction[T](obj: T): T 35 +nim iscoroutine inspect_impl/isX.html#iscoroutine.m,typed macro iscoroutine(obj: typed): bool 50 +nim iscoroutinefunction inspect_impl/isX.html#iscoroutinefunction.m,typed macro iscoroutinefunction(obj: typed): bool 53 +nim isawaitable inspect_impl/isX.html#isawaitable.t,typed template isawaitable(obj: typed): bool 58 +nim istraceback inspect_impl/isX.html#istraceback.t,typed template istraceback(obj: typed): bool 61 +nim isframe inspect_impl/isX.html#isframe.t,typed template isframe(obj: typed): bool 62 +nim isbuiltin inspect_impl/isX.html#isbuiltin.m,typed macro isbuiltin(obj: typed): bool 64 diff --git a/Lib/inspect_impl/members.html b/Lib/inspect_impl/members.html new file mode 100644 index 000000000..1a2b76d28 --- /dev/null +++ b/Lib/inspect_impl/members.html @@ -0,0 +1,320 @@ + + + + + + + +src/pylib/Lib/inspect_impl/members + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/inspect_impl/members

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Types

+
+
+
GetMembersPredict = proc (x: MemberType): bool
+
+ + + Source   +Edit   + +
+
+
+
GetMembersType = seq[GetMemberType]
+
+ + + Source   +Edit   + +
+
+
+
GetMemberType = (string, MemberType)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
func `$`(t: MemberType): string {....raises: [Exception], tags: [RootEffect],
+                                  forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Iterators

+
+
+
+
iterator getmembers[T](obj: var T): GetMemberType
+
+ + + Source   +Edit   + +
+
+
+
iterator getmembers[T](obj: var T; predict: GetMembersPredict): GetMemberType
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template allTrue(_): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template gen_getmembers_static(prag): untyped {.dirty.}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template getmembers(obj): seq
+
+ + + Source   +Edit   + +
+
+
+
template getmembers(obj; predict: GetMembersPredict): seq
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template getmembers_static(obj): untyped {.dirty.}
+
+ + + Source   +Edit   + +
+
+
+
template getmembers_static(obj; predict: GetMembersPredict): untyped {.dirty.}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template getmembersImpl[R](obj; predict; initResult): R
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/inspect_impl/members.idx b/Lib/inspect_impl/members.idx new file mode 100644 index 000000000..a0d0fd8a9 --- /dev/null +++ b/Lib/inspect_impl/members.idx @@ -0,0 +1,17 @@ +nimTitle members inspect_impl/members.html module src/pylib/Lib/inspect_impl/members 0 +nim `$` inspect_impl/members.html#$,Any proc `$`(t: MemberType): string 7 +nim GetMemberType inspect_impl/members.html#GetMemberType type GetMemberType 52 +nim GetMembersType inspect_impl/members.html#GetMembersType type GetMembersType 53 +nim GetMembersPredict inspect_impl/members.html#GetMembersPredict type GetMembersPredict 54 +nim getmembers inspect_impl/members.html#getmembers.i,T iterator getmembers[T](obj: var T): GetMemberType 55 +nim getmembers inspect_impl/members.html#getmembers.i,T,GetMembersPredict iterator getmembers[T](obj: var T; predict: GetMembersPredict): GetMemberType 59 +nim getmembersImpl inspect_impl/members.html#getmembersImpl.t,,, template getmembersImpl[R](obj; predict; initResult): R 64 +nim allTrue inspect_impl/members.html#allTrue.t template allTrue(_): bool 72 +nim getmembers inspect_impl/members.html#getmembers.t template getmembers(obj): seq 74 +nim getmembers inspect_impl/members.html#getmembers.t,,GetMembersPredict template getmembers(obj; predict: GetMembersPredict): seq 78 +nim gen_getmembers_static inspect_impl/members.html#gen_getmembers_static.t template gen_getmembers_static(prag): untyped 83 +nim getmembers_static inspect_impl/members.html#getmembers_static.t,,GetMembersPredict template getmembers_static(obj; predict: GetMembersPredict): untyped 84 +nim getmembers_static inspect_impl/members.html#getmembers_static.t template getmembers_static(obj): untyped 89 +nimgrp getmembers inspect_impl/members.html#getmembers-iterators-all iterator 55 +nimgrp getmembers inspect_impl/members.html#getmembers-templates-all template 74 +nimgrp getmembersstatic inspect_impl/members.html#getmembers_static-templates-all template 84 diff --git a/Lib/inspect_impl/modulename.html b/Lib/inspect_impl/modulename.html new file mode 100644 index 000000000..06538d1a8 --- /dev/null +++ b/Lib/inspect_impl/modulename.html @@ -0,0 +1,110 @@ + + + + + + + +src/pylib/Lib/inspect_impl/modulename + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/inspect_impl/modulename

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Procs

+
+
+
+
proc getmodulenameImpl(path: string; res: var string): bool {....raises: [],
+    tags: [], forbids: [].}
+
+ + get the module name for a given file + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/inspect_impl/modulename.idx b/Lib/inspect_impl/modulename.idx new file mode 100644 index 000000000..8b8c44dee --- /dev/null +++ b/Lib/inspect_impl/modulename.idx @@ -0,0 +1,2 @@ +nimTitle modulename inspect_impl/modulename.html module src/pylib/Lib/inspect_impl/modulename 0 +nim getmodulenameImpl inspect_impl/modulename.html#getmodulenameImpl,string,string proc getmodulenameImpl(path: string; res: var string): bool 9 diff --git a/Lib/inspect_impl/sourcegetters.html b/Lib/inspect_impl/sourcegetters.html new file mode 100644 index 000000000..bb588de6b --- /dev/null +++ b/Lib/inspect_impl/sourcegetters.html @@ -0,0 +1,238 @@ + + + + + + + +src/pylib/Lib/inspect_impl/sourcegetters + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/inspect_impl/sourcegetters

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Procs

+
+
+
+
func getdocNoDedentImpl(obj: NimNode): string {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Macros

+
+
+
+
macro getfile(obj: typed): string
+
+ + in Python this may returns path for .pyc, but as Nim doesn't generate vm code, this always returns the actual source file. Thus the same as getsourcefile + Source   +Edit   + +
+
+ +
+
+
+
macro getline(obj: typed): int
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
macro getsource(obj: typed): string
+
+ +
Note: +due to implement limit, the result string is not the extract the same as the origin source code, but those after some transformations, that's something that's allowed to be omitted is added. see below for examples
+ +

Example:

+
func f: int =
+  ## doc
+  1
+static:
+  assert getsource(f) == """
+func f(): int =
+  result =
+    ## doc
+    1
+"""
+ Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template getsourcefile(obj: typed): string
+
+ + see getfile + Source   +Edit   + +
+
+ +
+
+
+
template getsourcelinesImpl(obj: NimNode; splitlines): untyped
+
+ +

get source code of the object

+

the first element is the source code the second element is the line number of the first line of the source code

+ + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/inspect_impl/sourcegetters.idx b/Lib/inspect_impl/sourcegetters.idx new file mode 100644 index 000000000..a62fefe1e --- /dev/null +++ b/Lib/inspect_impl/sourcegetters.idx @@ -0,0 +1,7 @@ +nimTitle sourcegetters inspect_impl/sourcegetters.html module src/pylib/Lib/inspect_impl/sourcegetters 0 +nim getfile inspect_impl/sourcegetters.html#getfile.m,typed macro getfile(obj: typed): string 5 +nim getsourcefile inspect_impl/sourcegetters.html#getsourcefile.t,typed template getsourcefile(obj: typed): string 13 +nim getline inspect_impl/sourcegetters.html#getline.m,typed macro getline(obj: typed): int 21 +nim getsourcelinesImpl inspect_impl/sourcegetters.html#getsourcelinesImpl.t,NimNode, template getsourcelinesImpl(obj: NimNode; splitlines): untyped 34 +nim getsource inspect_impl/sourcegetters.html#getsource.m,typed macro getsource(obj: typed): string 45 +nim getdocNoDedentImpl inspect_impl/sourcegetters.html#getdocNoDedentImpl,NimNode proc getdocNoDedentImpl(obj: NimNode): string 70 diff --git a/Lib/io.html b/Lib/io.html new file mode 100644 index 000000000..d0ad0bc11 --- /dev/null +++ b/Lib/io.html @@ -0,0 +1,970 @@ + + + + + + + +src/pylib/Lib/io + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/io

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

NOTE: not support js currently +

different from Python

+

open

Its param: closefd, opener is not implemented yet

+ +

seek

There is difference that Python's TextIOBase.seek will reset state of encoder at some conditions, while Nim doesn't have access to encoder's state Therefore, seek here doesn't change that

+ +

iter over file

Python's __next__ will yield newline as part of result but Nim's iterator lines does not

+

+ +
+

Types

+
+
+
BufferedIOBase = ref object of IOBase
+
+ + + Source   +Edit   + +
+
+
+
BufferedRandom = ref object of BufferedIOBase
+
+ + + Source   +Edit   + +
+
+
+
BufferedReader = ref object of BufferedIOBase
+
+ + + Source   +Edit   + +
+
+
+
BufferedWriter = ref object of BufferedIOBase
+
+ + + Source   +Edit   + +
+
+
+
FileIO = ref object of RawIOBase
+
+ + + Source   +Edit   + +
+
+
+
IOBase = ref object of RootObj
+  closed*: bool
+
+ + + Source   +Edit   + +
+
+
+
NoEncTextIOBase = ref object of IOBase
+
+ + no encoding conversion is performed on underlying file. used for those stream whose encoding is alreadly utf-8 + Source   +Edit   + +
+
+
+
NoEncTextIOWrapper = ref object of NoEncTextIOBase
+  name*: PyStr
+  mode*: PyStr
+
+ + + Source   +Edit   + +
+
+
+
RawIOBase = ref object of IOBase
+
+ + + Source   +Edit   + +
+
+
+
TextIOWrapper = ref object of NoEncTextIOWrapper
+  ## do not use string, so is always valid
+
+ + + Source   +Edit   + +
+
+
+
UnsupportedOperation = object of PyOSError
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Consts

+
+
+
DEFAULT_BUFFER_SIZE = 8192
+
+ + + Source   +Edit   + +
+
+
+
DefEncoding = ""
+
+ + + Source   +Edit   + +
+
+
+
DefNewLine = "None"
+
+ + here it's used to mean open(...newline=None) in Python (i.e. Universial NewLine) + Source   +Edit   + +
+
+
+
LocaleEncoding = "locale"
+
+ + + Source   +Edit   + +
+
+
+
SEEK_CUR = 1
+
+ + + Source   +Edit   + +
+
+
+
SEEK_END = 2
+
+ + + Source   +Edit   + +
+
+
+
SEEK_SET = 0
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
func encoding(s: TextIOWrapper): PyStr {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func enter[IO: IOBase](self: IO): IO
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func errors(s: TextIOWrapper): PyStr {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc fileno(f: IOBase): int {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc flush(f: IOBase) {....raises: [PyOSError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc initBufAsPy(nfile: var File; buf: int) {....raises: [], tags: [], forbids: [].}
+
+ + init buffering as Python's + Source   +Edit   + +
+
+ +
+
+
+
func isatty(f: IOBase): bool {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc newNoEncTextIO(file: File; name: string; newline = DefNewLine): NoEncTextIOWrapper {.
+    ...raises: [ValueError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc read(self: NoEncTextIOWrapper): PyStr {....raises: [IOError],
+    tags: [ReadIOEffect], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc read(self: NoEncTextIOWrapper; size: int): PyStr {....raises: [IOError],
+    tags: [ReadIOEffect], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc read(self: RawIOBase): PyBytes {....raises: [IOError], tags: [ReadIOEffect],
+                                      forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc read(self: RawIOBase; size: int): PyBytes {....raises: [IOError],
+    tags: [ReadIOEffect], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc read(self: TextIOWrapper): PyStr {....raises: [IOError, Exception],
+                                        tags: [ReadIOEffect, RootEffect],
+                                        forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc read(self: TextIOWrapper; size: int): PyStr {....raises: [IOError, Exception],
+    tags: [ReadIOEffect, RootEffect], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc readline(self: NoEncTextIOWrapper): PyStr {....raises: [IOError],
+    tags: [ReadIOEffect], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc readline(self: NoEncTextIOWrapper; size: int): PyStr {....raises: [IOError],
+    tags: [ReadIOEffect], forbids: [].}
+
+ + ..warning:: size is currently in bytes, not in characters + Source   +Edit   + +
+
+
+
proc readline(self: RawIOBase): PyBytes {....raises: [IOError],
+    tags: [ReadIOEffect], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc readline(self: RawIOBase; size: Natural): PyBytes {....raises: [IOError],
+    tags: [ReadIOEffect], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc readline(self: TextIOWrapper): PyStr {....raises: [IOError, Exception],
+    tags: [ReadIOEffect, RootEffect], forbids: [].}
+
+ + Python's readline +

Example:

+
import std/strutils
+const fn = "tempfiletest"
+proc check(ls: varargs[string], newline: string) =
+  var f = open(fn, newline=newline)
+  for l in ls:
+    let s = f.readline()
+    assert s == l, 
+      "expected $#, but got $#, with newline=$#" % [l.repr, s.repr, newline.repr]
+    
+  f.close()
+
+writeFile fn, "abc\r\n123\n-\r_"
+
+check "abc\n", "123\n", "-\n", "_", newline=DefNewLine
+check "abc\r\n", "123\n", "-\r", "_", newline=""
+check "abc\r", "\n123\n-\r", "_", newline="\r"
+check "abc\r\n", "123\n", "-\r_", newline="\n"
+check "abc\r\n", "123\n-\r_", newline="\r\n"
+ Source   +Edit   + +
+
+
+
proc readline(self: TextIOWrapper; size: Natural): PyStr {.
+    ...raises: [IOError, Exception], tags: [ReadIOEffect, RootEffect], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func tell(f: IOBase): int64 {....raises: [IOError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc truncate(self: IOBase): int {.discardable, ...raises: [IOError, PyOSError],
+                                   tags: [], forbids: [].}
+
+ + +

Example:

+
const fn = "tempfiletest"
+var f = open(fn, "w+")
+discard f.write("123")
+f.seek(0)
+f.truncate()
+assert f.read() == ""
+f.close()
+ Source   +Edit   + +
+
+
+
proc truncate(self: IOBase; size: int64): int64 {.discardable,
+    ...raises: [PyOSError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc write(self: NoEncTextIOWrapper; s: PyStr): int {.discardable,
+    ...raises: [Exception], tags: [RootEffect], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc write(self: RawIOBase; s: PyBytes): int {.discardable, ...raises: [IOError],
+    tags: [WriteIOEffect], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc write(self: TextIOWrapper; s: PyStr): int {.discardable,
+    ...raises: [Exception], tags: [RootEffect], forbids: [].}
+
+ +

Writes the s to the stream and return the number of characters written

+

The following is from Python's doc of open: if newline is None, any 'n' characters written are translated to the system default line separator, os.linesep. If newline is "" or 'n', no translation takes place. If newline is any of the other legal values, any 'n' characters written are translated to the given string.

+ +

Example:

+
const fn = "tempfiletest"
+proc checkW(s, dest: string, newline=DefNewLine, encoding=DefEncoding;
+    writeLen=dest.len  # dest.len returns bytes size
+  ) =
+  var f = open(fn, 'w', newline=newline, encoding=encoding)
+  assert writeLen == f.write s
+  f.close()
+  let res = readFile fn
+  assert dest == res, "expected "&dest.repr&" but got "&res.repr
+checkW "1\n2", when defined(windows): "1\r\n2" else: "1\n2"
+checkW "1\n2", "1\p2"  # same as above
+checkW "1\n2", "1\r2", newline="\r"
+checkW "我", "我", encoding="utf-8", writeLen=1
+ Source   +Edit   + +
+
+ +
+ +
+
+
+

Methods

+
+
+
+
method close(self: IOBase) {.base, ...raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
method close(self: RawIOBase) {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
method close(self: TextIOWrapper) {....raises: [Exception], tags: [RootEffect],
+                                    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
method seek(f: IOBase; cookie: int64; whence = SEEK_SET): int64 {.base,
+    discardable, ...raises: [IOError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
method seek(self: TextIOWrapper; cookie: int64; whence = SEEK_SET): int64 {.
+    discardable,
+    ...raises: [ValueError, UnsupportedOperation, IOError, PyOSError, Exception],
+    tags: [RootEffect], forbids: [].}
+
+ + +

Example:

+
var f = open("tempfiletest", 'w')
+doAssertRaises UnsupportedOperation:
+  f.seek(1, SEEK_CUR)
+f.close()
+ Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template exit(self: IOBase; args: varargs[untyped])
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template open(file: int; mode: static[string | char] = "r"; buffering: int = -1;
+              encoding: string = DefEncoding; errors: string = DefErrors;
+              newline: string | char = DefNewLine): untyped
+
+ + + Source   +Edit   + +
+
+
+
template open[S](file: PathLike[S]; mode: static[string | char] = "r";
+                 buffering: int = -1; encoding: string = DefEncoding;
+                 errors: string = DefErrors; newline: string | char = DefNewLine): untyped
+
+ + WARN:
  • line buffering is not support for Win32
  • +
  • errors is not just ignored, always 'strict'
  • +
+ +

Example:

+
const fn = "tempfiletest"
+const nonfn = r"   \:/ $&* "
+doAssertRaises LookupError:
+  # raise LookupError instead of FileNotFoundError (like Python)
+  discard open(nonfn, encoding="this is a invalid enc")
+doAssertRaises FileNotFoundError:
+  discard io.open(nonfn)  # an invalid filename, never existing
+block Write:
+  var f = open(fn, "w",  encoding="utf-8")
+  let ret = f.write("123\r\n")
+  when defined(windows):
+    assert ret == 6  # Universal Newline, written "123\r\r\n"
+  else:
+    assert ret == 5  # written "123\r\n"
+  assert not f.closed
+  f.close()
+  assert f.closed
+  assert readFile(fn) == (when defined(windows):"123\r\r\n" else:"123\r\n")
+block Read:
+  var f = open(fn, 'r')
+  let uniLineRes = f.read() # Universal Newline, "123\r\n\n" -> "123\n\n"
+  assert uniLineRes == (when defined(windows):"123\n\n" else:"123\n")
+  f.close()
+ Source   +Edit   + +
+
+ +
+ +
+
+ + +
+
+ + +
+
+ + + diff --git a/Lib/io.idx b/Lib/io.idx new file mode 100644 index 000000000..a51f8450e --- /dev/null +++ b/Lib/io.idx @@ -0,0 +1,64 @@ +nimTitle io io.html module src/pylib/Lib/io 0 +nim SEEK_SET io.html#SEEK_SET const SEEK_SET 52 +nim SEEK_CUR io.html#SEEK_CUR const SEEK_CUR 53 +nim SEEK_END io.html#SEEK_END const SEEK_END 54 +nim DefNewLine io.html#DefNewLine const DefNewLine 56 +nim IOBase io.html#IOBase type IOBase 67 +nim UnsupportedOperation io.html#UnsupportedOperation object UnsupportedOperation 72 +nim flush io.html#flush,IOBase proc flush(f: IOBase) 78 +nim tell io.html#tell,IOBase proc tell(f: IOBase): int64 83 +nim isatty io.html#isatty,IOBase proc isatty(f: IOBase): bool 85 +nim fileno io.html#fileno,IOBase proc fileno(f: IOBase): int 87 +nim DEFAULT_BUFFER_SIZE io.html#DEFAULT_BUFFER_SIZE const DEFAULT_BUFFER_SIZE 89 +nim NoEncTextIOBase io.html#NoEncTextIOBase type NoEncTextIOBase 92 +nim NoEncTextIOWrapper io.html#NoEncTextIOWrapper type NoEncTextIOWrapper 96 +nim TextIOWrapper io.html#TextIOWrapper type TextIOWrapper 100 +nim encoding io.html#encoding,TextIOWrapper proc encoding(s: TextIOWrapper): PyStr 104 +nim errors io.html#errors,TextIOWrapper proc errors(s: TextIOWrapper): PyStr 105 +nim RawIOBase io.html#RawIOBase type RawIOBase 108 +nim FileIO io.html#FileIO type FileIO 109 +nim BufferedIOBase io.html#BufferedIOBase type BufferedIOBase 111 +nim BufferedRandom io.html#BufferedRandom type BufferedRandom 112 +nim BufferedReader io.html#BufferedReader type BufferedReader 113 +nim BufferedWriter io.html#BufferedWriter type BufferedWriter 114 +nim seek io.html#seek.e,IOBase,int64 method seek(f: IOBase; cookie: int64; whence = SEEK_SET): int64 132 +nim seek io.html#seek.e,TextIOWrapper,int64 method seek(self: TextIOWrapper; cookie: int64; whence = SEEK_SET): int64 135 +nim readline io.html#readline,RawIOBase proc readline(self: RawIOBase): PyBytes 250 +nim readline io.html#readline,RawIOBase,Natural proc readline(self: RawIOBase; size: Natural): PyBytes 251 +nim readline io.html#readline,NoEncTextIOWrapper proc readline(self: NoEncTextIOWrapper): PyStr 278 +nim readline io.html#readline,NoEncTextIOWrapper,int proc readline(self: NoEncTextIOWrapper; size: int): PyStr 280 +nim readline io.html#readline,TextIOWrapper proc readline(self: TextIOWrapper): PyStr 285 +nim readline io.html#readline,TextIOWrapper,Natural proc readline(self: TextIOWrapper; size: Natural): PyStr 308 +nim read io.html#read,RawIOBase proc read(self: RawIOBase): PyBytes 312 +nim read io.html#read,RawIOBase,int proc read(self: RawIOBase; size: int): PyBytes 315 +nim read io.html#read,NoEncTextIOWrapper proc read(self: NoEncTextIOWrapper): PyStr 324 +nim read io.html#read,TextIOWrapper proc read(self: TextIOWrapper): PyStr 325 +nim read io.html#read,NoEncTextIOWrapper,int proc read(self: NoEncTextIOWrapper; size: int): PyStr 338 +nim read io.html#read,TextIOWrapper,int proc read(self: TextIOWrapper; size: int): PyStr 341 +nim write io.html#write,RawIOBase,PyBytes proc write(self: RawIOBase; s: PyBytes): int 349 +nim write io.html#write,NoEncTextIOWrapper,PyStr proc write(self: NoEncTextIOWrapper; s: PyStr): int 362 +nim write io.html#write,TextIOWrapper,PyStr proc write(self: TextIOWrapper; s: PyStr): int 368 +nim truncate io.html#truncate,IOBase proc truncate(self: IOBase): int 398 +nim truncate io.html#truncate,IOBase,int64 proc truncate(self: IOBase; size: int64): int64 410 +nim close io.html#close.e,IOBase method close(self: IOBase) 423 +nim close io.html#close.e,RawIOBase method close(self: RawIOBase) 424 +nim close io.html#close.e,TextIOWrapper method close(self: TextIOWrapper) 425 +nim enter io.html#enter,IO proc enter[IO: IOBase](self: IO): IO 438 +nim exit io.html#exit.t,IOBase,varargs[untyped] template exit(self: IOBase; args: varargs[untyped]) 441 +nim DefEncoding io.html#DefEncoding const DefEncoding 446 +nim LocaleEncoding io.html#LocaleEncoding const LocaleEncoding 447 +nim newNoEncTextIO io.html#newNoEncTextIO,File,string proc newNoEncTextIO(file: File; name: string; newline = DefNewLine): NoEncTextIOWrapper 487 +nim initBufAsPy io.html#initBufAsPy,File,int proc initBufAsPy(nfile: var File; buf: int) 610 +nim open io.html#open.t,int,static[],int,string,string template open(file: int; mode: static[string | char] = "r"; buffering: int = -1;\n encoding: string = DefEncoding; errors: string = DefErrors;\n newline: string | char = DefNewLine): untyped 654 +nim open io.html#open.t,PathLike[S],static[],int,string,string template open[S](file: PathLike[S]; mode: static[string | char] = "r";\n buffering: int = -1; encoding: string = DefEncoding;\n errors: string = DefErrors; newline: string | char = DefNewLine): untyped 672 +nimgrp write io.html#write-procs-all proc 349 +nimgrp readline io.html#readline-procs-all proc 250 +nimgrp read io.html#read-procs-all proc 312 +nimgrp truncate io.html#truncate-procs-all proc 398 +nimgrp close io.html#close-methods-all method 423 +nimgrp seek io.html#seek-methods-all method 132 +nimgrp open io.html#open-templates-all template 654 +heading different from Python io.html#different-from-python different from Python 0 +heading open io.html#different-from-python-open open 0 +heading seek io.html#different-from-python-seek seek 0 +heading iter over file io.html#different-from-python-iter-over-file iter over file 0 diff --git a/Lib/itertools.html b/Lib/itertools.html new file mode 100644 index 000000000..add74d18d --- /dev/null +++ b/Lib/itertools.html @@ -0,0 +1,217 @@ + + + + + + + +src/pylib/Lib/itertools + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/itertools

+
+ +
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
func accumulate[T](iterable: Iterable[T]; binop: BinOp[T] = binOpAdd;
+                   inital = mayZeroDefault(T)): Accumulate[T]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func combinations[T](iterable: Iterable[T]; r: int): Combinations[T]
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Iterators

+
+
+
+
iterator accumulate[T](iterable: Iterable[T]; binop: BinOp[T] = binOpAdd;
+                       inital = mayZeroDefault(T)): T
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
iterator combinations[T](iterable: Iterable[T]; r: int): PyList[T]
+
+ + XXX: yield list instead of tuple + Source   +Edit   + +
+
+ +
+
+
+
iterator items[T](x: Accumulate[T]): T
+
+ + + Source   +Edit   + +
+
+
+
iterator items[T](x: Combinations[T]): T
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/math.html b/Lib/math.html new file mode 100644 index 000000000..e7d4ab6a6 --- /dev/null +++ b/Lib/math.html @@ -0,0 +1,938 @@ + + + + + + + +src/pylib/Lib/math + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/math

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

Lib/math

+

Wrapper around Lib/n_math, and raises exceptions when math error occurs as CPython behaves.

+

+ +
+

Procs

+
+
+
+
func acos[F: SomeFloat](x: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func acosh[F: SomeFloat](x: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func asin[F: SomeFloat](x: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func asinh[F: SomeFloat](x: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func atan[F: SomeFloat](x: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func atan2[F: SomeFloat](x, y: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func atanh[F: SomeFloat](x: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func cbrt[F: SomeFloat](x: F): F
+
+ +
Admonition: +since Python 3.11
+ +

Example:

+
template chk =
+  assert cbrt(-1.0) == -1.0
+chk()
+static: chk()
+ Source   +Edit   + +
+
+ +
+
+
+
func comb(n, k: int): int {....raises: [ValueError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func copysign[F: SomeFloat](x, y: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func cos[F: SomeFloat](x: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func cosh[F: SomeFloat](x: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func erf[F: SomeFloat](x: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func erfc[F: SomeFloat](x: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func exp[F: SomeFloat](x: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func expm1[F: SomeFloat](x: F): F
+
+ +
Admonition: +since Python 3.11
+ + Source   +Edit   + +
+
+ +
+
+
+
func fabs[F: SomeFloat](x: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func factorial(x: int): int {....raises: [ValueError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func fma[F: SomeFloat](x, y, z: F): F
+
+ +
Admonition: +since Python 3.13
+ + Source   +Edit   + +
+
+ +
+
+
+
func fmod[F: SomeFloat](x: F; y: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func gamma[F: SomeFloat](x: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func isqrt[I: SomeInteger](x: I): int
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func ldexp(x: SomeFloat; i: int): float
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func lgamma[F: SomeFloat](x: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func log[F: SomeFloat](x, base: F): F
+
+ + + Source   +Edit   + +
+
+
+
func log[F: SomeFloat](x: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func log1p[F: SomeFloat](x: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func log2[F: SomeFloat](x: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func log10[F: SomeFloat](x: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func nextafter[F: SomeFloat](x, y: F): F
+
+ +
Admonition: +since Python 3.9
+ + Source   +Edit   + +
+
+
+
func nextafter[F: SomeFloat](x, y: F; steps: int | uint64): F
+
+ +
Admonition: +since Python 3.12
+ + Source   +Edit   + +
+
+ +
+
+
+
func perm(n, k: int): int {....raises: [ValueError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func perm(n: int): int {....raises: [ValueError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func pow[F: SomeFloat](x, y: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func remainder[F: SomeFloat](x, y: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func sin[F: SomeFloat](x: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func sinh[F: SomeFloat](x: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func sqrt[F: SomeFloat](x: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func tan[F: SomeFloat](x: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func tanh[F: SomeFloat](x: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func ulp[F: SomeFloat](x: F): F
+
+ +
Admonition: +since Python 3.9
+ + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template dist[T](p, q: (Iterable[T] and not openArray[T])): float
+
+ +
Admonition: +since Python 3.8
+ + Source   +Edit   + +
+
+
+
template dist[T](p, q: ClosureIter[T]): float
+
+ +
Admonition: +since Python 3.8
+ + Source   +Edit   + +
+
+
+
template dist[T](p, q: list[T]): float
+
+ +
Admonition: +since Python 3.8
+ + Source   +Edit   + +
+
+
+
template dist[T](p, q: openArray[T]): float
+
+ +
Admonition: +since Python 3.8
+ + Source   +Edit   + +
+
+ +
+
+
+
template sumprod[T](p, q: (Iterable[T] and not openArray[T])): float
+
+ +
Admonition: +since Python 3.12
+ + Source   +Edit   + +
+
+
+
template sumprod[T](p, q: ClosureIter[T]): float
+
+ +
Admonition: +since Python 3.12
+ + Source   +Edit   + +
+
+
+
template sumprod[T](p, q: list[T]): float
+
+ +
Admonition: +since Python 3.12
+ + Source   +Edit   + +
+
+
+
template sumprod[T](p, q: openArray[T]): float
+
+ +
Admonition: +since Python 3.12
+ + Source   +Edit   + +
+
+ +
+ +
+
+ + +
+
+ + +
+
+ + + diff --git a/Lib/math.idx b/Lib/math.idx new file mode 100644 index 000000000..ea8148f4d --- /dev/null +++ b/Lib/math.idx @@ -0,0 +1,55 @@ +nimTitle math math.html module src/pylib/Lib/math 0 +nim acos math.html#acos,F proc acos[F: SomeFloat](x: F): F 98 +nim acosh math.html#acosh,F proc acosh[F: SomeFloat](x: F): F 99 +nim asin math.html#asin,F proc asin[F: SomeFloat](x: F): F 100 +nim asinh math.html#asinh,F proc asinh[F: SomeFloat](x: F): F 101 +nim atan math.html#atan,F proc atan[F: SomeFloat](x: F): F 102 +nim atanh math.html#atanh,F proc atanh[F: SomeFloat](x: F): F 103 +nim cbrt math.html#cbrt,F proc cbrt[F: SomeFloat](x: F): F 105 +nim atan2 math.html#atan2,F,F proc atan2[F: SomeFloat](x, y: F): F 115 +nim copysign math.html#copysign,F,F proc copysign[F: SomeFloat](x, y: F): F 117 +nim cos math.html#cos,F proc cos[F: SomeFloat](x: F): F 119 +nim cosh math.html#cosh,F proc cosh[F: SomeFloat](x: F): F 120 +nim erf math.html#erf,F proc erf[F: SomeFloat](x: F): F 122 +nim erfc math.html#erfc,F proc erfc[F: SomeFloat](x: F): F 123 +nim exp math.html#exp,F proc exp[F: SomeFloat](x: F): F 125 +nim expm1 math.html#expm1,F proc expm1[F: SomeFloat](x: F): F 127 +nim fabs math.html#fabs,F proc fabs[F: SomeFloat](x: F): F 130 +nim gamma math.html#gamma,F proc gamma[F: SomeFloat](x: F): F 134 +nim lgamma math.html#lgamma,F proc lgamma[F: SomeFloat](x: F): F 135 +nim log1p math.html#log1p,F proc log1p[F: SomeFloat](x: F): F 137 +nim remainder math.html#remainder,F,F proc remainder[F: SomeFloat](x, y: F): F 138 +nim sin math.html#sin,F proc sin[F: SomeFloat](x: F): F 140 +nim sinh math.html#sinh,F proc sinh[F: SomeFloat](x: F): F 141 +nim sqrt math.html#sqrt,F proc sqrt[F: SomeFloat](x: F): F 142 +nim tan math.html#tan,F proc tan[F: SomeFloat](x: F): F 143 +nim tanh math.html#tanh,F proc tanh[F: SomeFloat](x: F): F 144 +nim isqrt math.html#isqrt,I proc isqrt[I: SomeInteger](x: I): int 148 +nim factorial math.html#factorial,int proc factorial(x: int): int 153 +nim ldexp math.html#ldexp,SomeFloat,int proc ldexp(x: SomeFloat; i: int): float 162 +nim log math.html#log,F proc log[F: SomeFloat](x: F): F 187 +nim log math.html#log,F,F proc log[F: SomeFloat](x, base: F): F 190 +nim log2 math.html#log2,F proc log2[F: SomeFloat](x: F): F 194 +nim log10 math.html#log10,F proc log10[F: SomeFloat](x: F): F 195 +nim fma math.html#fma,F,F,F proc fma[F: SomeFloat](x, y, z: F): F 197 +nim fmod math.html#fmod,F,F proc fmod[F: SomeFloat](x: F; y: F): F 203 +nim dist math.html#dist.t,list[T],list[T] template dist[T](p, q: list[T]): float 216 +nim dist math.html#dist.t,, template dist[T](p, q: (Iterable[T] and not openArray[T])): float 219 +nim dist math.html#dist.t,openArray[T],openArray[T] template dist[T](p, q: openArray[T]): float 222 +nim dist math.html#dist.t,ClosureIter[T],ClosureIter[T] template dist[T](p, q: ClosureIter[T]): float 225 +nim sumprod math.html#sumprod.t,list[T],list[T] template sumprod[T](p, q: list[T]): float 216 +nim sumprod math.html#sumprod.t,, template sumprod[T](p, q: (Iterable[T] and not openArray[T])): float 219 +nim sumprod math.html#sumprod.t,openArray[T],openArray[T] template sumprod[T](p, q: openArray[T]): float 222 +nim sumprod math.html#sumprod.t,ClosureIter[T],ClosureIter[T] template sumprod[T](p, q: ClosureIter[T]): float 225 +nim pow math.html#pow,F,F proc pow[F: SomeFloat](x, y: F): F 238 +nim perm math.html#perm,int proc perm(n: int): int 259 +nim perm math.html#perm,int,int proc perm(n, k: int): int 263 +nim comb math.html#comb,int,int proc comb(n, k: int): int 269 +nim nextafter math.html#nextafter,F,F proc nextafter[F: SomeFloat](x, y: F): F 275 +nim nextafter math.html#nextafter,F,F, proc nextafter[F: SomeFloat](x, y: F; steps: int | uint64): F 276 +nim ulp math.html#ulp,F proc ulp[F: SomeFloat](x: F): F 278 +nimgrp perm math.html#perm-procs-all proc 259 +nimgrp log math.html#log-procs-all proc 187 +nimgrp nextafter math.html#nextafter-procs-all proc 275 +nimgrp dist math.html#dist-templates-all template 231 +nimgrp sumprod math.html#sumprod-templates-all template 233 diff --git a/Lib/math_impl/cbrt.html b/Lib/math_impl/cbrt.html new file mode 100644 index 000000000..57ff3ec39 --- /dev/null +++ b/Lib/math_impl/cbrt.html @@ -0,0 +1,118 @@ + + + + + + + +src/pylib/Lib/math_impl/cbrt + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/math_impl/cbrt

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
func cbrt[F: SomeFloat](x: F): F
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/math_impl/cbrt.idx b/Lib/math_impl/cbrt.idx new file mode 100644 index 000000000..dc176fea9 --- /dev/null +++ b/Lib/math_impl/cbrt.idx @@ -0,0 +1,2 @@ +nimTitle cbrt math_impl/cbrt.html module src/pylib/Lib/math_impl/cbrt 0 +nim cbrt math_impl/cbrt.html#cbrt,F proc cbrt[F: SomeFloat](x: F): F 24 diff --git a/Lib/math_impl/comptime/cbrt.html b/Lib/math_impl/comptime/cbrt.html new file mode 100644 index 000000000..3b7b53d71 --- /dev/null +++ b/Lib/math_impl/comptime/cbrt.html @@ -0,0 +1,129 @@ + + + + + + + +src/pylib/Lib/math_impl/comptime/cbrt + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/math_impl/comptime/cbrt

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

from https://www.netlib.org/cephes/ cmath.tgz cbrt.c And single.tgz cbrtf.c

+

Cube root

+

DESCRIPTION:

+

Returns the cube root of the argument, which may be negative.

+

Range reduction involves determining the power of 2 of the argument. A polynomial of degree 2 applied to the mantissa, and multiplication by the cube root of 1, 2, or 4 approximates the root to within about 0.1%. Then Newton's iteration is used three times to converge to an accurate result.

+

ACCURACY:

+
Relative error:
+

arithmetic domain # trials peak rms DEC -10,10 200000 1.8e-17 6.2e-18 IEEE 0,1e308 30000 1.5e-16 5.0e-17

+

cbrt.c

+

Cephes Math Library Release 2.8: June, 2000 Copyright 1984, 1991, 2000 by Stephen L. Moshier

+

cbrt.nim Copyright litlighilit 2024

+

+ +
+

Procs

+
+
+
+
func cbrt[F: SomeFloat](x: F): F
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/math_impl/comptime/cbrt.idx b/Lib/math_impl/comptime/cbrt.idx new file mode 100644 index 000000000..76c3d3d44 --- /dev/null +++ b/Lib/math_impl/comptime/cbrt.idx @@ -0,0 +1,2 @@ +nimTitle cbrt math_impl/comptime/cbrt.html module src/pylib/Lib/math_impl/comptime/cbrt 0 +nim cbrt math_impl/comptime/cbrt.html#cbrt,F proc cbrt[F: SomeFloat](x: F): F 49 diff --git a/Lib/math_impl/comptime/common.html b/Lib/math_impl/comptime/common.html new file mode 100644 index 000000000..2bb56fc6c --- /dev/null +++ b/Lib/math_impl/comptime/common.html @@ -0,0 +1,219 @@ + + + + + + + +src/pylib/Lib/math_impl/comptime/common + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/math_impl/comptime/common

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Consts

+
+
+
ln2_hi = 0.6931471803691238
+
+ + 3fe62e42 fee00000 + Source   +Edit   + +
+
+
+
ln2_lo = 1.9082149292705877e-10
+
+ + 3dea39ef 35793c76 + Source   +Edit   + +
+
+ +
+
+
+

Templates

+
+
+
+
template GET_FLOAT_WORD(word: var uint32; x: float32)
+
+ + + Source   +Edit   + +
+
+
+
template GET_FLOAT_WORD(x: float32): uint32
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template getLowWord(x: float32): uint16
+
+ + + Source   +Edit   + +
+
+
+
template getLowWord(x: float64): uint32
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template setHighWord(x: float; hi)
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ + +
+
+ + +
+
+ + + diff --git a/Lib/math_impl/comptime/common.idx b/Lib/math_impl/comptime/common.idx new file mode 100644 index 000000000..7b3ce0b24 --- /dev/null +++ b/Lib/math_impl/comptime/common.idx @@ -0,0 +1,10 @@ +nimTitle common math_impl/comptime/common.html module src/pylib/Lib/math_impl/comptime/common 0 +nim ln2_hi math_impl/comptime/common.html#ln2_hi const ln2_hi 10 +nim ln2_lo math_impl/comptime/common.html#ln2_lo const ln2_lo 11 +nim getLowWord math_impl/comptime/common.html#getLowWord.t,float32 template getLowWord(x: float32): uint16 13 +nim getLowWord math_impl/comptime/common.html#getLowWord.t,float64 template getLowWord(x: float64): uint32 14 +nim setHighWord math_impl/comptime/common.html#setHighWord.t,float, template setHighWord(x: float; hi) 17 +nim GET_FLOAT_WORD math_impl/comptime/common.html#GET_FLOAT_WORD.t,float32 template GET_FLOAT_WORD(x: float32): uint32 20 +nim GET_FLOAT_WORD math_impl/comptime/common.html#GET_FLOAT_WORD.t,uint32,float32 template GET_FLOAT_WORD(word: var uint32; x: float32) 21 +nimgrp Getfloatword math_impl/comptime/common.html#GET_FLOAT_WORD-templates-all template 20 +nimgrp getlowword math_impl/comptime/common.html#getLowWord-templates-all template 13 diff --git a/Lib/math_impl/comptime/expm1.html b/Lib/math_impl/comptime/expm1.html new file mode 100644 index 000000000..3d579ad0b --- /dev/null +++ b/Lib/math_impl/comptime/expm1.html @@ -0,0 +1,277 @@ + + + + + + + +src/pylib/Lib/math_impl/comptime/expm1 + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/math_impl/comptime/expm1

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

compiletime/expm1.nim 10/19/2024:

  • translated from and combine s_expm1.c and s_expm1f.c
  • +
  • Also, some formula in the following doc used to have some tabs for indent, I replaced them with spaces.
  • +
+

---

+

@(#)s_expm1.c 1.5 04/04/22 And s_expm1f.c

+

==================================================== Copyright (C) 2004 by Sun Microsystems, Inc. All rights reserved. Copyright (C) 2024 by litlighilit. All rights reserved.

+

Permission to use, copy, modify, and distribute this software is freely granted, provided that this notice is preserved. ==================================================== expm1(x) Returns exp(x)-1, the exponential of x minus 1.

+

+Method
+  1. Argument reduction:
+   Given x, find r and integer k such that
+              
+              x = k*ln2 + r,  |r| <= 0.5*ln2 ~ 0.34658
+     
+     Here a correction term c will be computed to compensate
+   the error in r when rounded to a floating-point number.
+  
+  2. Approximating expm1(r) by a special rational function on
+   the interval [0,0.34658]:
+   Since
+       r*(exp(r)+1)/(exp(r)-1) = 2+ r^2/6 - r^4/360 + ...
+   we define R1(r*r) by
+       r*(exp(r)+1)/(exp(r)-1) = 2+ r^2/6 * R1(r*r)
+   That is,
+       R1(r**2) = 6/r *((exp(r)+1)/(exp(r)-1) - 2/r)
+            = 6/r * ( 1 + 2.0*(1/(exp(r)-1) - 1/r))
+            = 1 - r^2/60 + r^4/2520 - r^6/100800 + ...
+     We use a special Remes algorithm on [0,0.347] to generate
+    a polynomial of degree 5 in r*r to approximate R1. The
+   maximum error of this polynomial approximation is bounded
+   by 2**-61. In other words,
+       R1(z) ~ 1.0 + Q1*z + Q2*z**2 + Q3*z**3 + Q4*z**4 + Q5*z**5
+   where Q1  =  -1.6666666666666567384E-2,
+         Q2  =   3.9682539681370365873E-4,
+         Q3  =  -9.9206344733435987357E-6,
+         Q4  =   2.5051361420808517002E-7,
+         Q5  =  -6.2843505682382617102E-9;
+     (where z=r*r, and the values of Q1 to Q5 are listed below)
+   with error bounded by
+       |                  5           |     -61
+       | 1.0+Q1*z+...+Q5*z   -  R1(z) | <= 2
+       |                              |
+   
+   expm1(r) = exp(r)-1 is then computed by the following
+    specific way which minimize the accumulation rounding error:
+                          2     3
+                         r     r    [ 3 - (R1 + R1*r/2)  ]
+         expm1(r) = r + --- + --- * [--------------------]
+                         2     2    [ 6 - r*(3 - R1*r/2) ]
+   
+   To compensate the error in the argument reduction, we use
+       expm1(r+c) = expm1(r) + c + expm1(r)*c
+              ~ expm1(r) + c + r*c
+   Thus c+r*c will be added in as the correction terms for
+   expm1(r+c). Now rearrange the term to avoid optimization
+    screw up:
+                   (      2                                    2 )
+                   ({  ( r    [ R1 -  (3 - R1*r/2) ]  )  }    r  )
+    expm1(r+c)~r - ({r*(--- * [--------------------]-c)-c} - --- )
+                   ({  ( 2    [ 6 - r*(3 - R1*r/2) ]  )  }    2  )
+                   (                                             )
+          
+          = r - E
+  3. Scale back to obtain expm1(x):
+   From step 1, we have
+      expm1(x) = either 2^k*[expm1(r)+1] - 1
+           = or     2^k*[expm1(r) + (1-2^-k)]
+  4. Implementation notes:
+   (A). To save one multiplication, we scale the coefficient Qi
+        to Qi*2^i, and replace z by (x^2)/2.
+   (B). To achieve maximum accuracy, we compute expm1(x) by
+     (i)   if x < -56*ln2, return -1.0, (raise inexact if x!=inf)
+     (ii)  if k=0, return r-E
+     (iii) if k=-1, return 0.5*(r-E)-0.5
+     (iv)    if k=1 if r < -0.25, return 2*((r+0.5)- E)
+                     else         return  1.0+2.0*(r-E);
+     (v)   if (k<-2||k>56) return 2^k(1-(E-r)) - 1 (or exp(x)-1)
+     (vi)  if k <= 20, return 2^k((1-2^-k)-(E-r)), else
+     (vii) return 2^k(1-((E+2^-k)-r))
+
+Special cases:
+   expm1(INF) is INF, expm1(NaN) is NaN;
+   expm1(-INF) is -1, and
+   for finite argument, only expm1(0)=0 is exact.
+
+Accuracy:
+   according to an error analysis, the error is always less than
+   1 ulp (unit in the last place).
+
+Misc. info.
+   For IEEE double
+       if x >  7.09782712893383973096e+02 then expm1(x) overflow
+

+

Constants: The hexadecimal values are the intended ones for the following constants. The decimal values may be used, provided that the compiler will convert from decimal to binary accurately enough to produce the hexadecimal values shown.

+

+
+

Imports

+
+ common +
+
+
+

Procs

+
+
+
+
proc expm1[F: SomeFloat](x: F): F
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template hugeF[F](): untyped
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template o_threshold[F](): untyped
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template tinyF[F](): untyped
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/math_impl/comptime/expm1.idx b/Lib/math_impl/comptime/expm1.idx new file mode 100644 index 000000000..65dee0957 --- /dev/null +++ b/Lib/math_impl/comptime/expm1.idx @@ -0,0 +1,5 @@ +nimTitle expm1 math_impl/comptime/expm1.html module src/pylib/Lib/math_impl/comptime/expm1 0 +nim hugeF math_impl/comptime/expm1.html#hugeF.t template hugeF[F](): untyped 131 +nim tinyF math_impl/comptime/expm1.html#tinyF.t template tinyF[F](): untyped 132 +nim o_threshold math_impl/comptime/expm1.html#o_threshold.t template o_threshold[F](): untyped 133 +nim expm1 math_impl/comptime/expm1.html#expm1,F proc expm1[F: SomeFloat](x: F): F 144 diff --git a/Lib/math_impl/comptime/log1p.html b/Lib/math_impl/comptime/log1p.html new file mode 100644 index 000000000..9631b0066 --- /dev/null +++ b/Lib/math_impl/comptime/log1p.html @@ -0,0 +1,201 @@ + + + + + + + +src/pylib/Lib/math_impl/comptime/log1p + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/math_impl/comptime/log1p

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

compiletime/log1p.nim 2024/10/19:

+
@(#)s_log1p.c 1.3 95/01/18
+Along with:
+s_log1pf.c -- float version of s_log1p.c.
+Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
+
+
+====================================================
+Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+Copyright (C) 2024 by litlighilit. All rights reserved.
+
+Developed at SunSoft, a Sun Microsystems, Inc. business.
+Permission to use, copy, modify, and distribute this
+software is freely granted, provided that this notice
+is preserved.
+====================================================
+
+double log1p(double x)
+
+Method :
+  1. Argument Reduction: find k and f such that
+			1+x = 2^k * (1+f),
+	   where  sqrt(2)/2 < 1+f < sqrt(2) .
+
+     Note. If k=0, then f=x is exact. However, if k!=0, then f
+	may not be representable exactly. In that case, a correction
+	term is need. Let u=1+x rounded. Let c = (1+x)-u, then
+	log(1+x) - log(u) ~ c/u. Thus, we proceed to compute log(u),
+	and add back the correction term c/u.
+	(Note: when x > 2**53, one can simply return log(x))
+
+  2. Approximation of log1p(f).
+	Let s = f/(2+f) ; based on log(1+f) = log(1+s) - log(1-s)
+		 = 2s + 2/3 s**3 + 2/5 s**5 + .....,
+	     	 = 2s + s*R
+     We use a special Reme algorithm on [0,0.1716] to generate
+	a polynomial of degree 14 to approximate R The maximum error
+	of this polynomial approximation is bounded by 2**-58.45. In
+	other words,
+		        2      4      6      8      10      12      14
+	    R(z) ~ Lp1*s +Lp2*s +Lp3*s +Lp4*s +Lp5*s  +Lp6*s  +Lp7*s
+ 	(the values of Lp1 to Lp7 are listed in the program)
+	and
+	    |      2          14          |     -58.45
+	    | Lp1*s +...+Lp7*s    -  R(z) | <= 2
+	    |                             |
+	Note that 2s = f - s*f = f - hfsq + s*hfsq, where hfsq = f*f/2.
+	In order to guarantee error in log below 1ulp, we compute log
+	by
+		log1p(f) = f - (hfsq - s*(hfsq+R)).
+	
+	3. Finally, log1p(x) = k*ln2 + log1p(f).
+		 	     = k*ln2_hi+(f-(hfsq-(s*(hfsq+R)+k*ln2_lo)))
+	   Here ln2 is split into two floating point number:
+			ln2_hi + ln2_lo,
+	   where n*ln2_hi is always exact for |n| < 2000.
+
+Special cases:
+	log1p(x) is NaN with signal if x < -1 (including -INF) ;
+	log1p(+INF) is +INF; log1p(-1) is -INF with signal;
+	log1p(NaN) is that NaN with no signal.
+
+Accuracy:
+	according to an error analysis, the error is always less than
+	1 ulp (unit in the last place).
+
+Constants:
+The hexadecimal values are the intended ones for the following
+constants. The decimal values may be used, provided that the
+compiler will convert from decimal to binary accurately enough
+to produce the hexadecimal values shown.
+
+
+Note: Assuming log() return accurate answer, the following
+	 algorithm can be used to compute log1p(x) to within a few ULP:
+	
+		u = 1+x;
+		if(u==1.0) return x ; else
+			   return log(u)*(x/(u-1.0));
+
+	 See HP-15C Advanced Functions Handbook, p.193.
+
+

+
+

Imports

+
+ common +
+
+
+

Procs

+
+
+
+
proc log1p[F: SomeFloat](x: F): F
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/math_impl/comptime/log1p.idx b/Lib/math_impl/comptime/log1p.idx new file mode 100644 index 000000000..05a6c0f74 --- /dev/null +++ b/Lib/math_impl/comptime/log1p.idx @@ -0,0 +1,2 @@ +nimTitle log1p math_impl/comptime/log1p.html module src/pylib/Lib/math_impl/comptime/log1p 0 +nim log1p math_impl/comptime/log1p.html#log1p,F proc log1p[F: SomeFloat](x: F): F 100 diff --git a/Lib/math_impl/constsUtils.html b/Lib/math_impl/constsUtils.html new file mode 100644 index 000000000..5b2cd3d42 --- /dev/null +++ b/Lib/math_impl/constsUtils.html @@ -0,0 +1,137 @@ + + + + + + + +src/pylib/Lib/math_impl/constsUtils + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/math_impl/constsUtils

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Templates

+
+
+
+
template genWithArg(sym, v32, v64) {.dirty.}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template genWithBracket(sym, v32, v64)
+
+ + + Source   +Edit   + +
+
+
+
template genWithBracket(sym, v32, v64, Ret) {.dirty.}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/math_impl/constsUtils.idx b/Lib/math_impl/constsUtils.idx new file mode 100644 index 000000000..3cfd230e1 --- /dev/null +++ b/Lib/math_impl/constsUtils.idx @@ -0,0 +1,5 @@ +nimTitle constsUtils math_impl/constsUtils.html module src/pylib/Lib/math_impl/constsUtils 0 +nim genWithArg math_impl/constsUtils.html#genWithArg.t,,, template genWithArg(sym, v32, v64) 7 +nim genWithBracket math_impl/constsUtils.html#genWithBracket.t,,,, template genWithBracket(sym, v32, v64, Ret) 11 +nim genWithBracket math_impl/constsUtils.html#genWithBracket.t,,, template genWithBracket(sym, v32, v64) 15 +nimgrp genwithbracket math_impl/constsUtils.html#genWithBracket-templates-all template 11 diff --git a/Lib/math_impl/err.html b/Lib/math_impl/err.html new file mode 100644 index 000000000..970a2f597 --- /dev/null +++ b/Lib/math_impl/err.html @@ -0,0 +1,223 @@ + + + + + + + +src/pylib/Lib/math_impl/err + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/math_impl/err

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Types

+
+
+
GammaError = enum
+  geOk, geDom = "x in {0, -1, -2, ...}", ## when .
+                                          ## Infinity discontinuity,
+                                          ## which shall produce `Complex Infinity` in SymPy and
+                                          ## means domain error
+  geOverFlow = "x > MAX_GAMMA_X, result overflow as inf",
+  geUnderFlow = "x < MIN_GAMMA_X, result underflow as `-0.0` or `0.0`.", geZeroCantDetSign = "`x < -maxSafeInteger`(exclude -inf), " &
+      "can\'t detect result\'s sign", ## `x` losing unit digit, often not regard as an error
+  geGotNegInf = "x == -inf" ## this is made as a enumerate item as different languages'
+                            ## implementation has different treatment towards -inf
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
func mapRaiseGammaErr(err: GammaError) {....raises: [ValueError], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template raiseDomainErr()
+
+ + + Source   +Edit   + +
+
+
+
template raiseDomainErr(details: string)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template raiseRangeErr()
+
+ + + Source   +Edit   + +
+
+
+
template raiseRangeErr(details: string)
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/math_impl/err.idx b/Lib/math_impl/err.idx new file mode 100644 index 000000000..80b5eba35 --- /dev/null +++ b/Lib/math_impl/err.idx @@ -0,0 +1,15 @@ +nimTitle err math_impl/err.html module src/pylib/Lib/math_impl/err 0 +nim geOk math_impl/err.html#geOk GammaError.geOk 3 +nim geDom math_impl/err.html#geDom GammaError.geDom 3 +nim geOverFlow math_impl/err.html#geOverFlow GammaError.geOverFlow 3 +nim geUnderFlow math_impl/err.html#geUnderFlow GammaError.geUnderFlow 3 +nim geZeroCantDetSign math_impl/err.html#geZeroCantDetSign GammaError.geZeroCantDetSign 3 +nim geGotNegInf math_impl/err.html#geGotNegInf GammaError.geGotNegInf 3 +nim GammaError math_impl/err.html#GammaError enum GammaError 3 +nim raiseDomainErr math_impl/err.html#raiseDomainErr.t template raiseDomainErr() 20 +nim raiseDomainErr math_impl/err.html#raiseDomainErr.t,string template raiseDomainErr(details: string) 24 +nim raiseRangeErr math_impl/err.html#raiseRangeErr.t template raiseRangeErr() 28 +nim raiseRangeErr math_impl/err.html#raiseRangeErr.t,string template raiseRangeErr(details: string) 32 +nim mapRaiseGammaErr math_impl/err.html#mapRaiseGammaErr,GammaError proc mapRaiseGammaErr(err: GammaError) 36 +nimgrp raiserangeerr math_impl/err.html#raiseRangeErr-templates-all template 28 +nimgrp raisedomainerr math_impl/err.html#raiseDomainErr-templates-all template 20 diff --git a/Lib/math_impl/errnoUtils.html b/Lib/math_impl/errnoUtils.html new file mode 100644 index 000000000..97287de8e --- /dev/null +++ b/Lib/math_impl/errnoUtils.html @@ -0,0 +1,96 @@ + + + + + + + +src/pylib/Lib/math_impl/errnoUtils + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/math_impl/errnoUtils

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+ +
+ + +
+
+ + + diff --git a/Lib/math_impl/errnoUtils.idx b/Lib/math_impl/errnoUtils.idx new file mode 100644 index 000000000..a035bd84e --- /dev/null +++ b/Lib/math_impl/errnoUtils.idx @@ -0,0 +1 @@ +nimTitle errnoUtils math_impl/errnoUtils.html module src/pylib/Lib/math_impl/errnoUtils 0 diff --git a/Lib/math_impl/expm1_log1p.html b/Lib/math_impl/expm1_log1p.html new file mode 100644 index 000000000..55333e58b --- /dev/null +++ b/Lib/math_impl/expm1_log1p.html @@ -0,0 +1,149 @@ + + + + + + + +src/pylib/Lib/math_impl/expm1_log1p + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/math_impl/expm1_log1p

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

Hint: +result calculated at compile-time may a little differ those in runtime-time, e.g. For log1p: for i in 1..100, x = float(i), the following are results that differs each other:
+ +

x = 2.0

c_log1p(x) = 1.09861228866811 ct_log1p.log1p(x) = 1.09861228866811 relative_tol = -2.021137094636221e-16

+ +

x = 13.0

c_log1p(x) = 2.639057329615258 ct_log1p.log1p(x) = 2.639057329615259 relative_tol = 1.682756963505621e-16

+ +

x = 47.0

c_log1p(x) = 3.871201010907891 ct_log1p.log1p(x) = 3.871201010907891 relative_tol = -1.147161329516994e-16

+ +

x = 73.0

c_log1p(x) = 4.30406509320417 ct_log1p.log1p(x) = 4.304065093204169 relative_tol = -2.063580360581673e-16

+

+ +
+

Procs

+
+
+
+
func expm1[F: SomeFloat](x: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func log1p[F: SomeFloat](x: F): F
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/math_impl/expm1_log1p.idx b/Lib/math_impl/expm1_log1p.idx new file mode 100644 index 000000000..dd9e36664 --- /dev/null +++ b/Lib/math_impl/expm1_log1p.idx @@ -0,0 +1,7 @@ +nimTitle expm1_log1p math_impl/expm1_log1p.html module src/pylib/Lib/math_impl/expm1_log1p 0 +nim log1p math_impl/expm1_log1p.html#log1p,F proc log1p[F: SomeFloat](x: F): F 50 +nim expm1 math_impl/expm1_log1p.html#expm1,F proc expm1[F: SomeFloat](x: F): F 56 +heading x = 2.0 math_impl/expm1_log1p.html#x-eq-2dot0 x = 2.0 0 +heading x = 13.0 math_impl/expm1_log1p.html#x-eq-13dot0 x = 13.0 0 +heading x = 47.0 math_impl/expm1_log1p.html#x-eq-47dot0 x = 47.0 0 +heading x = 73.0 math_impl/expm1_log1p.html#x-eq-73dot0 x = 73.0 0 diff --git a/Lib/math_impl/frexp.html b/Lib/math_impl/frexp.html new file mode 100644 index 000000000..7506a4188 --- /dev/null +++ b/Lib/math_impl/frexp.html @@ -0,0 +1,157 @@ + + + + + + + +src/pylib/Lib/math_impl/frexp + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/math_impl/frexp

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
func frexp[F: SomeFloat](x: F): (F, int)
+
+ + + Source   +Edit   + +
+
+
+
func frexp[F: SomeFloat](x: F; e: var int): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func n_frexp[F: SomeFloat](x: F): (F, int)
+
+ + + Source   +Edit   + +
+
+
+
func n_frexp[F: SomeFloat](x: F; e: var int): F
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/math_impl/frexp.idx b/Lib/math_impl/frexp.idx new file mode 100644 index 000000000..0ec8d104e --- /dev/null +++ b/Lib/math_impl/frexp.idx @@ -0,0 +1,7 @@ +nimTitle frexp math_impl/frexp.html module src/pylib/Lib/math_impl/frexp 0 +nim n_frexp math_impl/frexp.html#n_frexp,F proc n_frexp[F: SomeFloat](x: F): (F, int) 7 +nim n_frexp math_impl/frexp.html#n_frexp,F,int proc n_frexp[F: SomeFloat](x: F; e: var int): F 8 +nim frexp math_impl/frexp.html#frexp,F proc frexp[F: SomeFloat](x: F): (F, int) 17 +nim frexp math_impl/frexp.html#frexp,F,int proc frexp[F: SomeFloat](x: F; e: var int): F 23 +nimgrp frexp math_impl/frexp.html#frexp-procs-all proc 17 +nimgrp nfrexp math_impl/frexp.html#n_frexp-procs-all proc 7 diff --git a/Lib/math_impl/gammaXRange.html b/Lib/math_impl/gammaXRange.html new file mode 100644 index 000000000..9e6fca208 --- /dev/null +++ b/Lib/math_impl/gammaXRange.html @@ -0,0 +1,159 @@ + + + + + + + +src/pylib/Lib/math_impl/gammaXRange + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/math_impl/gammaXRange

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

Hint: +CPython's uses MAX_GAMMA_X = 200.0 and MIN_GAMMA_X = -200.0, which differs the result above, but that's fine, as that's just a short-cut, there's still further check after that. See pylib#38 comment for details.
+

Thus in fact, these constants are no need to be very accurate, just to ensure they're greater than the actual value is enough.

+

But as such a short-cur is introduced, I think it better to make it accurate.

+

The values are calcuated from tools/math/gamma_x_range.py

+ +

MAX_GAMMA_X

35.040096282958984'f32 0b01000010_00001100_00101001_00001111'f32

+ +

MIN_GAMMA_X

-38.601410000000016'f32
+

0b11000010_00011010_01100111_11011000'f32

+ +

MAX_GAMMA_X

171.6243769563027'f64 0b01000000_01100101_01110011_11111010_11100101_01100001_11110110_01000111'f64

+ +

MIN_GAMMA_X

-177.7807064574756'f64
+

0b11000000_01100110_00111000_11111011_10001100_00011011_11010100_01000111'f64

+ +

others

I found stdlib-js/gamma uses following values: 171.61447887182298

+
-170.5674972726612
+

But what I tested using SymPy was different. If SymPy is right and my method is so, then the old values are uncorrect and shall not be used, as the old checking range for zero/inf result is bigger. (it doesn't matter if that was smaller) So I change to use current values.

+

+
+

Imports

+
+ constsUtils +
+
+
+

Templates

+
+
+
+
template MAX_GAMMA_X[F](_: typedesc[F]): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template MIN_GAMMA_X[F](_: typedesc[F]): F
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/math_impl/gammaXRange.idx b/Lib/math_impl/gammaXRange.idx new file mode 100644 index 000000000..dc1aaa2fa --- /dev/null +++ b/Lib/math_impl/gammaXRange.idx @@ -0,0 +1,8 @@ +nimTitle gammaXRange math_impl/gammaXRange.html module src/pylib/Lib/math_impl/gammaXRange 0 +nim MAX_GAMMA_X math_impl/gammaXRange.html#MAX_GAMMA_X.t,typedesc[F] template MAX_GAMMA_X[F](_: typedesc[F]): F 48 +nim MIN_GAMMA_X math_impl/gammaXRange.html#MIN_GAMMA_X.t,typedesc[F] template MIN_GAMMA_X[F](_: typedesc[F]): F 50 +heading MAX_GAMMA_X math_impl/gammaXRange.html#max-gamma-x MAX_GAMMA_X 0 +heading MIN_GAMMA_X math_impl/gammaXRange.html#min-gamma-x MIN_GAMMA_X 0 +heading MAX_GAMMA_X math_impl/gammaXRange.html#max-gamma-x MAX_GAMMA_X 0 +heading MIN_GAMMA_X math_impl/gammaXRange.html#min-gamma-x MIN_GAMMA_X 0 +heading others math_impl/gammaXRange.html#others others 0 diff --git a/Lib/math_impl/inWordUtils/assertIsLittleEndian.html b/Lib/math_impl/inWordUtils/assertIsLittleEndian.html new file mode 100644 index 000000000..250c4ea8b --- /dev/null +++ b/Lib/math_impl/inWordUtils/assertIsLittleEndian.html @@ -0,0 +1,134 @@ + + + + + + + +src/pylib/Lib/math_impl/inWordUtils/assertIsLittleEndian + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/math_impl/inWordUtils/assertIsLittleEndian

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Consts

+
+
+
compileLittleEndian = true
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
func isLittleEndian(): bool {.compileTime, ...raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/math_impl/inWordUtils/assertIsLittleEndian.idx b/Lib/math_impl/inWordUtils/assertIsLittleEndian.idx new file mode 100644 index 000000000..1b282ad43 --- /dev/null +++ b/Lib/math_impl/inWordUtils/assertIsLittleEndian.idx @@ -0,0 +1,3 @@ +nimTitle assertIsLittleEndian math_impl/inWordUtils/assertIsLittleEndian.html module src/pylib/Lib/math_impl/inWordUtils/assertIsLittleEndian 0 +nim compileLittleEndian math_impl/inWordUtils/assertIsLittleEndian.html#compileLittleEndian const compileLittleEndian 2 +nim isLittleEndian math_impl/inWordUtils/assertIsLittleEndian.html#isLittleEndian proc isLittleEndian(): bool 10 diff --git a/Lib/math_impl/inWordUtils/consts.html b/Lib/math_impl/inWordUtils/consts.html new file mode 100644 index 000000000..19edb57a9 --- /dev/null +++ b/Lib/math_impl/inWordUtils/consts.html @@ -0,0 +1,254 @@ + + + + + + + +src/pylib/Lib/math_impl/inWordUtils/consts + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/math_impl/inWordUtils/consts

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

maxExponent F - 1 = (MAX - 1) - BIAS = 254 - BIAS = 127 or 2046 - BIAS = 10230b1_00000000_1111111 => 32895 0b1_00000000000_11111111111111111111 => 2148532223mask whose exponent is equal to 126, 1022 a.k.a. (BIAS-1): 0b0_01111110_0000000 => 16256 0b0_01111111110_00000000000000000000 => 1071644672HIGH_WORD_EXPONENT_MASK: 0b0_11111111_0000000 0b0_11111111111_00000000000000000000mantissaDigits F - 1

+ +
+

Templates

+
+
+
+
template BIAS[F](_: typedesc[F]): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template CLEAR_EXP_MASK[F](): untyped
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template EXP_MASK[F](): untyped
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template HighWordFracBits[F](): untyped
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template MantissaDigits[F](): untyped
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template MAX_EXPONENT[F](_: typedesc[F]): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template MAX_SUBNORMAL_EXPONENT[F](_: typedesc[F]): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template MIN_SUBNORMAL_EXPONENT[F](_: typedesc[F]): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template SET_EXP_MASK[F](): untyped
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/math_impl/inWordUtils/consts.idx b/Lib/math_impl/inWordUtils/consts.idx new file mode 100644 index 000000000..241631c6b --- /dev/null +++ b/Lib/math_impl/inWordUtils/consts.idx @@ -0,0 +1,10 @@ +nimTitle consts math_impl/inWordUtils/consts.html module src/pylib/Lib/math_impl/inWordUtils/consts 0 +nim BIAS math_impl/inWordUtils/consts.html#BIAS.t,typedesc[F] template BIAS[F](_: typedesc[F]): F 5 +nim MAX_SUBNORMAL_EXPONENT math_impl/inWordUtils/consts.html#MAX_SUBNORMAL_EXPONENT.t,typedesc[F] template MAX_SUBNORMAL_EXPONENT[F](_: typedesc[F]): F 6 +nim MIN_SUBNORMAL_EXPONENT math_impl/inWordUtils/consts.html#MIN_SUBNORMAL_EXPONENT.t,typedesc[F] template MIN_SUBNORMAL_EXPONENT[F](_: typedesc[F]): F 7 +nim MAX_EXPONENT math_impl/inWordUtils/consts.html#MAX_EXPONENT.t,typedesc[F] template MAX_EXPONENT[F](_: typedesc[F]): F 8 +nim CLEAR_EXP_MASK math_impl/inWordUtils/consts.html#CLEAR_EXP_MASK.t template CLEAR_EXP_MASK[F](): untyped 13 +nim SET_EXP_MASK math_impl/inWordUtils/consts.html#SET_EXP_MASK.t template SET_EXP_MASK[F](): untyped 18 +nim EXP_MASK math_impl/inWordUtils/consts.html#EXP_MASK.t template EXP_MASK[F](): untyped 23 +nim HighWordFracBits math_impl/inWordUtils/consts.html#HighWordFracBits.t template HighWordFracBits[F](): untyped 28 +nim MantissaDigits math_impl/inWordUtils/consts.html#MantissaDigits.t template MantissaDigits[F](): untyped 29 diff --git a/Lib/math_impl/inWordUtils/float_view.html b/Lib/math_impl/inWordUtils/float_view.html new file mode 100644 index 000000000..2482774cf --- /dev/null +++ b/Lib/math_impl/inWordUtils/float_view.html @@ -0,0 +1,202 @@ + + + + + + + +src/pylib/Lib/math_impl/inWordUtils/float_view + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/math_impl/inWordUtils/float_view

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

for JS and C-like backends

+

Not for nimvm, see {to,from}Words for impl for nimvm backend

+

+
+

Procs

+
+
+
+
func `[]`(fv: VIEW32; _: range[0 .. 0]): float32 {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func `[]`(fv: VIEW64; _: range[0 .. 0]): float64 {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func `[]=`(fv: var VIEW32; _: range[0 .. 0]; f: float32) {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func `[]=`(fv: var VIEW64; _: range[0 .. 0]; f: float64) {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template init32FloatView(FLOAT32_VIEW, UINT16_VIEW)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template init64FloatView(FLOAT64_VIEW, UINT32_VIEW)
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/math_impl/inWordUtils/float_view.idx b/Lib/math_impl/inWordUtils/float_view.idx new file mode 100644 index 000000000..2820f497a --- /dev/null +++ b/Lib/math_impl/inWordUtils/float_view.idx @@ -0,0 +1,9 @@ +nimTitle float_view math_impl/inWordUtils/float_view.html module src/pylib/Lib/math_impl/inWordUtils/float_view 0 +nim `[]` math_impl/inWordUtils/float_view.html#[],VIEW64,range[] proc `[]`(fv: VIEW64; _: range[0 .. 0]): float64 34 +nim `[]=` math_impl/inWordUtils/float_view.html#[]=,VIEW64,range[],float64 proc `[]=`(fv: var VIEW64; _: range[0 .. 0]; f: float64) 37 +nim `[]` math_impl/inWordUtils/float_view.html#[],VIEW32,range[] proc `[]`(fv: VIEW32; _: range[0 .. 0]): float32 34 +nim `[]=` math_impl/inWordUtils/float_view.html#[]=,VIEW32,range[],float32 proc `[]=`(fv: var VIEW32; _: range[0 .. 0]; f: float32) 38 +nim init64FloatView math_impl/inWordUtils/float_view.html#init64FloatView.t,, template init64FloatView(FLOAT64_VIEW, UINT32_VIEW) 41 +nim init32FloatView math_impl/inWordUtils/float_view.html#init32FloatView.t,, template init32FloatView(FLOAT32_VIEW, UINT16_VIEW) 45 +nimgrp []= math_impl/inWordUtils/float_view.html#[]=-procs-all proc 35 +nimgrp [] math_impl/inWordUtils/float_view.html#[]-procs-all proc 34 diff --git a/Lib/math_impl/inWordUtils/fromWords.html b/Lib/math_impl/inWordUtils/fromWords.html new file mode 100644 index 000000000..e1d7765d7 --- /dev/null +++ b/Lib/math_impl/inWordUtils/fromWords.html @@ -0,0 +1,129 @@ + + + + + + + +src/pylib/Lib/math_impl/inWordUtils/fromWords + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/math_impl/inWordUtils/fromWords

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
proc fromWords(high, low: uint16): float32 {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc fromWords(high, low: uint32): float {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/math_impl/inWordUtils/fromWords.idx b/Lib/math_impl/inWordUtils/fromWords.idx new file mode 100644 index 000000000..9e2b991cb --- /dev/null +++ b/Lib/math_impl/inWordUtils/fromWords.idx @@ -0,0 +1,4 @@ +nimTitle fromWords math_impl/inWordUtils/fromWords.html module src/pylib/Lib/math_impl/inWordUtils/fromWords 0 +nim fromWords math_impl/inWordUtils/fromWords.html#fromWords,uint32,uint32 proc fromWords(high, low: uint32): float 6 +nim fromWords math_impl/inWordUtils/fromWords.html#fromWords,uint16,uint16 proc fromWords(high, low: uint16): float32 17 +nimgrp fromwords math_impl/inWordUtils/fromWords.html#fromWords-procs-all proc 6 diff --git a/Lib/math_impl/inWordUtils/indices.html b/Lib/math_impl/inWordUtils/indices.html new file mode 100644 index 000000000..47d8dd46c --- /dev/null +++ b/Lib/math_impl/inWordUtils/indices.html @@ -0,0 +1,154 @@ + + + + + + + +src/pylib/Lib/math_impl/inWordUtils/indices + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/math_impl/inWordUtils/indices

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Consts

+
+
+
HIGH = 1
+
+ + + Source   +Edit   + +
+
+
+
LOW = 0
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Templates

+
+
+
+
template accessHighLow(body)
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/math_impl/inWordUtils/indices.idx b/Lib/math_impl/inWordUtils/indices.idx new file mode 100644 index 000000000..b72564afc --- /dev/null +++ b/Lib/math_impl/inWordUtils/indices.idx @@ -0,0 +1,4 @@ +nimTitle indices math_impl/inWordUtils/indices.html module src/pylib/Lib/math_impl/inWordUtils/indices 0 +nim HIGH math_impl/inWordUtils/indices.html#HIGH const HIGH 26 +nim LOW math_impl/inWordUtils/indices.html#LOW const LOW 27 +nim accessHighLow math_impl/inWordUtils/indices.html#accessHighLow.t template accessHighLow(body) 29 diff --git a/Lib/math_impl/inWordUtils/toWords.html b/Lib/math_impl/inWordUtils/toWords.html new file mode 100644 index 000000000..62adba51b --- /dev/null +++ b/Lib/math_impl/inWordUtils/toWords.html @@ -0,0 +1,129 @@ + + + + + + + +src/pylib/Lib/math_impl/inWordUtils/toWords + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/math_impl/inWordUtils/toWords

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
func toWords(x: float): (uint32, uint32) {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func toWords(x: float32): (uint16, uint16) {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/math_impl/inWordUtils/toWords.idx b/Lib/math_impl/inWordUtils/toWords.idx new file mode 100644 index 000000000..629e0be5f --- /dev/null +++ b/Lib/math_impl/inWordUtils/toWords.idx @@ -0,0 +1,4 @@ +nimTitle toWords math_impl/inWordUtils/toWords.html module src/pylib/Lib/math_impl/inWordUtils/toWords 0 +nim toWords math_impl/inWordUtils/toWords.html#toWords,float proc toWords(x: float): (uint32, uint32) 5 +nim toWords math_impl/inWordUtils/toWords.html#toWords,float32 proc toWords(x: float32): (uint16, uint16) 17 +nimgrp towords math_impl/inWordUtils/toWords.html#toWords-procs-all proc 5 diff --git a/Lib/math_impl/isX.html b/Lib/math_impl/isX.html new file mode 100644 index 000000000..d2a3f71fc --- /dev/null +++ b/Lib/math_impl/isX.html @@ -0,0 +1,135 @@ + + + + + + + +src/pylib/Lib/math_impl/isX + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/math_impl/isX

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
func isfinite(x: SomeFloat): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func isinf(x: SomeFloat): bool
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/math_impl/isX.idx b/Lib/math_impl/isX.idx new file mode 100644 index 000000000..124d5e714 --- /dev/null +++ b/Lib/math_impl/isX.idx @@ -0,0 +1,3 @@ +nimTitle isX math_impl/isX.html module src/pylib/Lib/math_impl/isX 0 +nim isinf math_impl/isX.html#isinf,SomeFloat proc isinf(x: SomeFloat): bool 33 +nim isfinite math_impl/isX.html#isfinite,SomeFloat proc isfinite(x: SomeFloat): bool 32 diff --git a/Lib/math_impl/ldexp.html b/Lib/math_impl/ldexp.html new file mode 100644 index 000000000..f70f121fd --- /dev/null +++ b/Lib/math_impl/ldexp.html @@ -0,0 +1,135 @@ + + + + + + + +src/pylib/Lib/math_impl/ldexp + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/math_impl/ldexp

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

c_ldexp

+ +
+

Procs

+
+
+
+
func c_ldexp[F: SomeFloat](x: F; exp: cint): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func n_ldexp[F: SomeFloat](x: F; i: int): F
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/math_impl/ldexp.idx b/Lib/math_impl/ldexp.idx new file mode 100644 index 000000000..a1b8faccc --- /dev/null +++ b/Lib/math_impl/ldexp.idx @@ -0,0 +1,3 @@ +nimTitle ldexp math_impl/ldexp.html module src/pylib/Lib/math_impl/ldexp 0 +nim n_ldexp math_impl/ldexp.html#n_ldexp,F,int proc n_ldexp[F: SomeFloat](x: F; i: int): F 14 +nim c_ldexp math_impl/ldexp.html#c_ldexp,F,cint proc c_ldexp[F: SomeFloat](x: F; exp: cint): F 37 diff --git a/Lib/math_impl/nextafter_step.html b/Lib/math_impl/nextafter_step.html new file mode 100644 index 000000000..6dba0fe6e --- /dev/null +++ b/Lib/math_impl/nextafter_step.html @@ -0,0 +1,131 @@ + + + + + + + +src/pylib/Lib/math_impl/nextafter_step + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/math_impl/nextafter_step

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
func nextafter(x, y: float; steps: int): float {....raises: [ValueError], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func nextafter(x, y: float; usteps: uint64): float {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/math_impl/nextafter_step.idx b/Lib/math_impl/nextafter_step.idx new file mode 100644 index 000000000..dc75ac04c --- /dev/null +++ b/Lib/math_impl/nextafter_step.idx @@ -0,0 +1,4 @@ +nimTitle nextafter_step math_impl/nextafter_step.html module src/pylib/Lib/math_impl/nextafter_step 0 +nim nextafter math_impl/nextafter_step.html#nextafter,float,float,uint64 proc nextafter(x, y: float; usteps: uint64): float 90 +nim nextafter math_impl/nextafter_step.html#nextafter,float,float,int proc nextafter(x, y: float; steps: int): float 111 +nimgrp nextafter math_impl/nextafter_step.html#nextafter-procs-all proc 90 diff --git a/Lib/math_impl/nextafter_ulp.html b/Lib/math_impl/nextafter_ulp.html new file mode 100644 index 000000000..7fdbd3eef --- /dev/null +++ b/Lib/math_impl/nextafter_ulp.html @@ -0,0 +1,146 @@ + + + + + + + +src/pylib/Lib/math_impl/nextafter_ulp + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/math_impl/nextafter_ulp

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
func nextafter[F: SomeFloat](x, y: F): F
+
+ + + Source   +Edit   + +
+
+
+
func nextafter[F: SomeFloat](x, y: F; steps: int | uint64): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func ulp[F: SomeFloat](x: F): F
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/math_impl/nextafter_ulp.idx b/Lib/math_impl/nextafter_ulp.idx new file mode 100644 index 000000000..4a7376147 --- /dev/null +++ b/Lib/math_impl/nextafter_ulp.idx @@ -0,0 +1,5 @@ +nimTitle nextafter_ulp math_impl/nextafter_ulp.html module src/pylib/Lib/math_impl/nextafter_ulp 0 +nim nextafter math_impl/nextafter_ulp.html#nextafter,F,F proc nextafter[F: SomeFloat](x, y: F): F 14 +nim nextafter math_impl/nextafter_ulp.html#nextafter,F,F, proc nextafter[F: SomeFloat](x, y: F; steps: int | uint64): F 20 +nim ulp math_impl/nextafter_ulp.html#ulp,F proc ulp[F: SomeFloat](x: F): F 23 +nimgrp nextafter math_impl/nextafter_ulp.html#nextafter-procs-all proc 14 diff --git a/Lib/math_impl/patch/consts.html b/Lib/math_impl/patch/consts.html new file mode 100644 index 000000000..ef470d0a9 --- /dev/null +++ b/Lib/math_impl/patch/consts.html @@ -0,0 +1,176 @@ + + + + + + + +src/pylib/Lib/math_impl/patch/consts + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/math_impl/patch/consts

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

253 - 1 224 - 1

+ +
+

Consts

+
+
+
EULER = 0.5772156649015329
+
+ + euler_gamma + Source   +Edit   + +
+
+
+
Ninf = 0xFFF0000000000000'f64
+
+ + + Source   +Edit   + +
+
+
+
Pinf = 0x7FF0000000000000'f64
+
+ + + Source   +Edit   + +
+
+
+
SQRT_TWO_PI = 2.5066282746310007
+
+ + sqrt(2*PI) <-> sqrt(TAU) + Source   +Edit   + +
+
+ +
+
+
+

Templates

+
+
+
+
template maxSafeInteger[F](_: typedesc[F]): F
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/math_impl/patch/consts.idx b/Lib/math_impl/patch/consts.idx new file mode 100644 index 000000000..381ad0919 --- /dev/null +++ b/Lib/math_impl/patch/consts.idx @@ -0,0 +1,6 @@ +nimTitle consts math_impl/patch/consts.html module src/pylib/Lib/math_impl/patch/consts 0 +nim Pinf math_impl/patch/consts.html#Pinf const Pinf 5 +nim Ninf math_impl/patch/consts.html#Ninf const Ninf 6 +nim EULER math_impl/patch/consts.html#EULER const EULER 8 +nim SQRT_TWO_PI math_impl/patch/consts.html#SQRT_TWO_PI const SQRT_TWO_PI 10 +nim maxSafeInteger math_impl/patch/consts.html#maxSafeInteger.t,typedesc[F] template maxSafeInteger[F](_: typedesc[F]): F 13 diff --git a/Lib/math_impl/patch/fma.html b/Lib/math_impl/patch/fma.html new file mode 100644 index 000000000..4e40e6345 --- /dev/null +++ b/Lib/math_impl/patch/fma.html @@ -0,0 +1,186 @@ + + + + + + + +src/pylib/Lib/math_impl/patch/fma + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/math_impl/patch/fma

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

c_fma means compatible fma, using <math.h> fma when for C

+ +
+

Consts

+
+
+
UNRELIABLE_FMA = true
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
proc c_fma(x, y, z: cdouble): cdouble {.importc: "fma", header: "<math.h>",
+                                        ...raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc c_fma(x, y, z: cfloat): cfloat {.importc: "fmaf", header: "<math.h>",
+                                      ...raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func fma[F: SomeFloat](x, y, z: F): F {....raises: [].}
+
+ +
Warning: +this fma does not touch errno and exception is discarded
+ + Source   +Edit   + +
+
+
+
func fma[F: SomeFloat](x, y, z: F; exc: var ref Exception): F {....raises: [].}
+
+ + EXT. + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/math_impl/patch/fma.idx b/Lib/math_impl/patch/fma.idx new file mode 100644 index 000000000..78a698432 --- /dev/null +++ b/Lib/math_impl/patch/fma.idx @@ -0,0 +1,8 @@ +nimTitle fma math_impl/patch/fma.html module src/pylib/Lib/math_impl/patch/fma 0 +nim UNRELIABLE_FMA math_impl/patch/fma.html#UNRELIABLE_FMA const UNRELIABLE_FMA 8 +nim c_fma math_impl/patch/fma.html#c_fma,cdouble,cdouble,cdouble proc c_fma(x, y, z: cdouble): cdouble 10 +nim c_fma math_impl/patch/fma.html#c_fma,cfloat,cfloat,cfloat proc c_fma(x, y, z: cfloat): cfloat 11 +nim fma math_impl/patch/fma.html#fma,F,F,F,ref.Exception proc fma[F: SomeFloat](x, y, z: F; exc: var ref Exception): F 21 +nim fma math_impl/patch/fma.html#fma,F,F,F proc fma[F: SomeFloat](x, y, z: F): F 41 +nimgrp fma math_impl/patch/fma.html#fma-procs-all proc 21 +nimgrp cfma math_impl/patch/fma.html#c_fma-procs-all proc 10 diff --git a/Lib/math_impl/patch/gamma.html b/Lib/math_impl/patch/gamma.html new file mode 100644 index 000000000..fcca15e40 --- /dev/null +++ b/Lib/math_impl/patch/gamma.html @@ -0,0 +1,233 @@ + + + + + + + +src/pylib/Lib/math_impl/patch/gamma + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/math_impl/patch/gamma

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

Stirling's formula for the gamma function gamma(x) = sqrt(2 pi) x^(x-.5) exp(-x) ( 1 + 1/x P(1/x) )

+

For float32: .028 < 1/x < .1 relative error < 1.9e-11

+

+ +
+

Procs

+
+
+
+
func gamma[F: SomeFloat](x: F): F
+
+ + CPython math.gamma-like, with error message more detailed. +

Example:

+
template chkValueErr(arg) =
+  doAssertRaises ValueError: discard gamma arg
+chkValueErr NegInf
+chkValueErr 0.0
+# Currently +-0.0 result is not consistent with CPython;
+# assert NegInf == 1.0/gamma(-180.5)
+ Source   +Edit   + +
+
+
+
func gamma[T: SomeFloat](x: T; res: var T): GammaError
+
+ + a more error friendly version of gamma + Source   +Edit   + +
+
+ +
+
+
+
func rGamma[F: SomeFloat](x: F): F {....raises: [].}
+
+ + behaviors like R's gamma except for this without any warning. +

Example:

+
from std/math import isNaN
+assert isNaN rgamma NegInf
+assert Inf == 1/rgamma(-180.5)  # never returns -0.0
+ Source   +Edit   + +
+
+ +
+
+
+
func stdlibJsGamma[F: SomeFloat](x: F): F {....raises: [].}
+
+ + behaviors like @stdlib-js/gamma.js + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template MAX_STIRLING[F](_: typedesc[F]): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template UseSmallApprox[F](_: typedesc[F]): F
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Exports

+
+ GammaError +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/math_impl/patch/gamma.idx b/Lib/math_impl/patch/gamma.idx new file mode 100644 index 000000000..30e27303b --- /dev/null +++ b/Lib/math_impl/patch/gamma.idx @@ -0,0 +1,8 @@ +nimTitle gamma math_impl/patch/gamma.html module src/pylib/Lib/math_impl/patch/gamma 0 +nim UseSmallApprox math_impl/patch/gamma.html#UseSmallApprox.t,typedesc[F] template UseSmallApprox[F](_: typedesc[F]): F 29 +nim MAX_STIRLING math_impl/patch/gamma.html#MAX_STIRLING.t,typedesc[F] template MAX_STIRLING[F](_: typedesc[F]): F 34 +nim gamma math_impl/patch/gamma.html#gamma,T,T proc gamma[T: SomeFloat](x: T; res: var T): GammaError 214 +nim gamma math_impl/patch/gamma.html#gamma,F proc gamma[F: SomeFloat](x: F): F 218 +nim rGamma math_impl/patch/gamma.html#rGamma,F proc rGamma[F: SomeFloat](x: F): F 229 +nim stdlibJsGamma math_impl/patch/gamma.html#stdlibJsGamma,F proc stdlibJsGamma[F: SomeFloat](x: F): F 242 +nimgrp gamma math_impl/patch/gamma.html#gamma-procs-all proc 214 diff --git a/Lib/math_impl/patch/inWordUtilsMapper.html b/Lib/math_impl/patch/inWordUtilsMapper.html new file mode 100644 index 000000000..50cb02736 --- /dev/null +++ b/Lib/math_impl/patch/inWordUtilsMapper.html @@ -0,0 +1,109 @@ + + + + + + + +src/pylib/Lib/math_impl/patch/inWordUtilsMapper + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/math_impl/patch/inWordUtilsMapper

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Macros

+
+
+
+
macro wu_import(moduleOrfromExpr)
+
+ + words utils import + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/math_impl/patch/inWordUtilsMapper.idx b/Lib/math_impl/patch/inWordUtilsMapper.idx new file mode 100644 index 000000000..7ad69fed5 --- /dev/null +++ b/Lib/math_impl/patch/inWordUtilsMapper.idx @@ -0,0 +1,2 @@ +nimTitle inWordUtilsMapper math_impl/patch/inWordUtilsMapper.html module src/pylib/Lib/math_impl/patch/inWordUtilsMapper 0 +nim wu_import math_impl/patch/inWordUtilsMapper.html#wu_import.m macro wu_import(moduleOrfromExpr) 30 diff --git a/Lib/math_impl/patch/ldexp_frexp/assertIsInfinite.html b/Lib/math_impl/patch/ldexp_frexp/assertIsInfinite.html new file mode 100644 index 000000000..806500cc8 --- /dev/null +++ b/Lib/math_impl/patch/ldexp_frexp/assertIsInfinite.html @@ -0,0 +1,118 @@ + + + + + + + +src/pylib/Lib/math_impl/patch/ldexp_frexp/assertIsInfinite + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/math_impl/patch/ldexp_frexp/assertIsInfinite

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Imports

+
+ ../../isX +
+
+
+

Templates

+
+
+
+
template isInfinite(f: SomeFloat): bool
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/math_impl/patch/ldexp_frexp/assertIsInfinite.idx b/Lib/math_impl/patch/ldexp_frexp/assertIsInfinite.idx new file mode 100644 index 000000000..3f5a36033 --- /dev/null +++ b/Lib/math_impl/patch/ldexp_frexp/assertIsInfinite.idx @@ -0,0 +1,2 @@ +nimTitle assertIsInfinite math_impl/patch/ldexp_frexp/assertIsInfinite.html module src/pylib/Lib/math_impl/patch/ldexp_frexp/assertIsInfinite 0 +nim isInfinite math_impl/patch/ldexp_frexp/assertIsInfinite.html#isInfinite.t,SomeFloat template isInfinite(f: SomeFloat): bool 4 diff --git a/Lib/math_impl/patch/ldexp_frexp/exponent.html b/Lib/math_impl/patch/ldexp_frexp/exponent.html new file mode 100644 index 000000000..2e94ff397 --- /dev/null +++ b/Lib/math_impl/patch/ldexp_frexp/exponent.html @@ -0,0 +1,118 @@ + + + + + + + +src/pylib/Lib/math_impl/patch/ldexp_frexp/exponent + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/math_impl/patch/ldexp_frexp/exponent

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
func exponent[F: SomeFloat](x: F): BiggestInt
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/math_impl/patch/ldexp_frexp/exponent.idx b/Lib/math_impl/patch/ldexp_frexp/exponent.idx new file mode 100644 index 000000000..7ce705c05 --- /dev/null +++ b/Lib/math_impl/patch/ldexp_frexp/exponent.idx @@ -0,0 +1,2 @@ +nimTitle exponent math_impl/patch/ldexp_frexp/exponent.html module src/pylib/Lib/math_impl/patch/ldexp_frexp/exponent 0 +nim exponent math_impl/patch/ldexp_frexp/exponent.html#exponent,F proc exponent[F: SomeFloat](x: F): BiggestInt 32 diff --git a/Lib/math_impl/patch/ldexp_frexp/frexp.html b/Lib/math_impl/patch/ldexp_frexp/frexp.html new file mode 100644 index 000000000..536c3d0e5 --- /dev/null +++ b/Lib/math_impl/patch/ldexp_frexp/frexp.html @@ -0,0 +1,118 @@ + + + + + + + +src/pylib/Lib/math_impl/patch/ldexp_frexp/frexp + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/math_impl/patch/ldexp_frexp/frexp

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
func frexp[F: SomeFloat](x: F): (F, int)
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/math_impl/patch/ldexp_frexp/frexp.idx b/Lib/math_impl/patch/ldexp_frexp/frexp.idx new file mode 100644 index 000000000..9ecca1e32 --- /dev/null +++ b/Lib/math_impl/patch/ldexp_frexp/frexp.idx @@ -0,0 +1,2 @@ +nimTitle frexp math_impl/patch/ldexp_frexp/frexp.html module src/pylib/Lib/math_impl/patch/ldexp_frexp/frexp 0 +nim frexp math_impl/patch/ldexp_frexp/frexp.html#frexp,F proc frexp[F: SomeFloat](x: F): (F, int) 12 diff --git a/Lib/math_impl/patch/ldexp_frexp/ldexp.html b/Lib/math_impl/patch/ldexp_frexp/ldexp.html new file mode 100644 index 000000000..5ecc82a55 --- /dev/null +++ b/Lib/math_impl/patch/ldexp_frexp/ldexp.html @@ -0,0 +1,118 @@ + + + + + + + +src/pylib/Lib/math_impl/patch/ldexp_frexp/ldexp + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/math_impl/patch/ldexp_frexp/ldexp

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
func ldexp[F: SomeFloat](frac: F; exp: int): F
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/math_impl/patch/ldexp_frexp/ldexp.idx b/Lib/math_impl/patch/ldexp_frexp/ldexp.idx new file mode 100644 index 000000000..5ee29bf3d --- /dev/null +++ b/Lib/math_impl/patch/ldexp_frexp/ldexp.idx @@ -0,0 +1,2 @@ +nimTitle ldexp math_impl/patch/ldexp_frexp/ldexp.html module src/pylib/Lib/math_impl/patch/ldexp_frexp/ldexp 0 +nim ldexp math_impl/patch/ldexp_frexp/ldexp.html#ldexp,F,int proc ldexp[F: SomeFloat](frac: F; exp: int): F 18 diff --git a/Lib/math_impl/patch/ldexp_frexp/normalize.html b/Lib/math_impl/patch/ldexp_frexp/normalize.html new file mode 100644 index 000000000..b55cb4b93 --- /dev/null +++ b/Lib/math_impl/patch/ldexp_frexp/normalize.html @@ -0,0 +1,118 @@ + + + + + + + +src/pylib/Lib/math_impl/patch/ldexp_frexp/normalize + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/math_impl/patch/ldexp_frexp/normalize

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
proc normalize[F: SomeFloat](x: F): (F, int) {.noInit.}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/math_impl/patch/ldexp_frexp/normalize.idx b/Lib/math_impl/patch/ldexp_frexp/normalize.idx new file mode 100644 index 000000000..2bca6b8af --- /dev/null +++ b/Lib/math_impl/patch/ldexp_frexp/normalize.idx @@ -0,0 +1,2 @@ +nimTitle normalize math_impl/patch/ldexp_frexp/normalize.html module src/pylib/Lib/math_impl/patch/ldexp_frexp/normalize 0 +nim normalize math_impl/patch/ldexp_frexp/normalize.html#normalize,F proc normalize[F: SomeFloat](x: F): (F, int) 12 diff --git a/Lib/math_impl/patch/lgamma.html b/Lib/math_impl/patch/lgamma.html new file mode 100644 index 000000000..6e278c6d7 --- /dev/null +++ b/Lib/math_impl/patch/lgamma.html @@ -0,0 +1,285 @@ + + + + + + + +src/pylib/Lib/math_impl/patch/lgamma + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/math_impl/patch/lgamma

+
+ +
+ Source   +Edit   + +
+ +

+

Notice

This module was hand-translated from FreeBSD's lgamma implementation;

+

and with some modification:

+
  • no static data is used, so each function is thread-safe.
  • +
+

The following copyright, license, and long comment were part of the original implementation available as part of FreeBSD

+

Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+
+Developed at SunPro, a Sun Microsystems, Inc. business.
+Permission to use, copy, modify, and distribute this
+software is freely granted, provided that this notice
+is preserved.

+

+ +
+

Procs

+
+
+
+
func lgamma[F: SomeFloat](x: F): F
+
+ +

Evaluates the natural logarithm of the absolute value of gamma function.

+

The following was formatted as Nim-Favor Markdown from FreeBSD `lgamma` source with some minor amendment.

+ +

Method:

+

1. Argument Reduction for 0 < x <= 8

Since gamma(1+s)=s*gamma(s), for x in [0,8], we may
+reduce x to a number in [1.5,2.5] by
+        lgamma(1+s) = log(s) + lgamma(s)
+for example,
+        lgamma(7.3) = log(6.3) + lgamma(6.3)
+                    = log(6.3*5.3) + lgamma(5.3)
+                    = log(6.3*5.3*4.3*3.3*2.3) + lgamma(2.3)

+ +

2. A polynomial approximation of lgamma

Create a polynomial approximation of lgamma around its minimun ymin=1.461632144968362245 to maintain monotonicity.

+

On [ymin-0.23, ymin+0.27] (i.e., [1.23164,1.73163]), use
+        Let z = x-ymin;
+        lgamma(x) = -1.214862905358496078218 + z^2*poly(z)
+where
+        poly(z) is a 14 degree polynomial.

+ +

3. Rational approximation in the primary interval [2,3]

We use the following approximation:
+        s = x-2.0;
+        lgamma(x) = 0.5*s + s*P(s)/Q(s)
+with accuracy
+        |P/Q - (lgamma(x)-0.5s)| < 2**-61.71
+Our algorithms are based on the following observation
+                            
+                            zeta(2)-1    2    zeta(3)-1    3
+lgamma(2+s) = s*(1-Euler) + --------- * s  -  --------- * s  + ...
+                                2                 3

+

where Euler = 0.5771... is the Euler constant, which is very close to 0.5.

+ +

4. For x>=8, ...

For x>=8, we have
+  lgamma(x) ~ (x-0.5)log(x)-x+0.5*log(2pi)+1/(12x)-1/(360x**3)+....
+
+(better formula:
+   lgamma(x) ~ (x-0.5)*(log(x)-1)-.5*(log(2pi)-1) + ...)
+
+Let z = 1/x, then we approximation
+        f(z) = lgamma(x) - (x-0.5)(log(x)-1)
+by
+                            3       5             11
+        w = w0 + w1*z + w2*z  + w3*z  + ... + w6*z
+where
+        |w - f(z)| < 2**-58.74

+ +

5. For negative x, ...

For negative x, since (G is gamma function)
+        -x*G(-x)*G(x) = pi/sin(pi*x),
+we have
+        G(x) = pi/(sin(pi*x)*(-x)*G(-x))
+since G(-x) is positive, sign(G(x)) = sign(sin(pi*x)) for x<0
+Hence, for x<0, signgam = sign(sin(pi*x)) and
+        lgamma(x) = log(|Gamma(x)|)
+                  = log(pi/(|x*sin(pi*x)|)) - lgamma(-x);

+
Note: +one should avoid computing pi*(-x) directly in the computation of sin(pi*(-x)) but using sinpi(-x)
+ +

Special Cases

        lgamma(2+s) ~ s*(1-Euler) for tiny s
+        lgamma(1) = lgamma(2) = 0
+        lgamma(x) ~ -log(|x|) for tiny x
+        lgamma(0) = lgamma(neg.integer) = inf and raise divide-by-zero
+        lgamma(inf) = inf
+        lgamma(-inf) = inf  # see below
For lgamma(-inf),

+
  • some implementations, like CPython's math, R
  • +
+

and C/C++ returns +inf; which is not suitable, as gamma(x) where x < about -200 is always truncated to 0.0 at ieee754 float domain. This behavior was said for bug compatible with C99, and is readlly documented by POSIX man and cppreference.com

+
  • While others like scipy.special.gammaln, Go's math.Lgamma, returns
  • +
+

In my option, ln(|gamma(-oo)|) -[ieee754 float trunc]-> ln(0+) -> -inf

+

But in this function it returns +inf to keep consistent with Python,

+ +

Example:

+
from std/math import isNaN
+assert lgamma(1.0) == 0.0
+assert lgamma(Inf) == Inf
+assert lgamma(NaN).isNaN
+ Source   +Edit   + +
+
+
+
func lgamma[F: SomeFloat](x: F; res: var F): GammaError
+
+ + currently do not return geOverFlow, geUnderFlow + Source   +Edit   + +
+
+ +
+
+
+
func rLgamma[F: SomeFloat](x: F): F {....raises: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func scipyGammaLn[F: SomeFloat](x: F): F {....raises: [].}
+
+ +
Note: +this returns -inf for -inf argument, and raises no math error, just like scipy.special.gammaln
+ + Source   +Edit   + +
+
+ +
+
+
+
func stdlibJsLgamma[F: SomeFloat](x: F): F {....raises: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Exports

+
+ GammaError +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/math_impl/patch/lgamma.idx b/Lib/math_impl/patch/lgamma.idx new file mode 100644 index 000000000..0387886e9 --- /dev/null +++ b/Lib/math_impl/patch/lgamma.idx @@ -0,0 +1,15 @@ +nimTitle lgamma math_impl/patch/lgamma.html module src/pylib/Lib/math_impl/patch/lgamma 0 +nim lgamma math_impl/patch/lgamma.html#lgamma,F,F proc lgamma[F: SomeFloat](x: F; res: var F): GammaError 150 +nim lgamma math_impl/patch/lgamma.html#lgamma,F proc lgamma[F: SomeFloat](x: F): F 278 +nim stdlibJsLgamma math_impl/patch/lgamma.html#stdlibJsLgamma,F proc stdlibJsLgamma[F: SomeFloat](x: F): F 395 +nim rLgamma math_impl/patch/lgamma.html#rLgamma,F proc rLgamma[F: SomeFloat](x: F): F 398 +nim scipyGammaLn math_impl/patch/lgamma.html#scipyGammaLn,F proc scipyGammaLn[F: SomeFloat](x: F): F 400 +nimgrp lgamma math_impl/patch/lgamma.html#lgamma-procs-all proc 150 +heading Method: math_impl/patch/lgamma.html#methodcolon Method: 0 +heading 1. Argument Reduction for 0 < x <= 8 math_impl/patch/lgamma.html#methodcolon-Z1dot-argument-reduction-for-0-lt-x-lteq-8 1. Argument Reduction for 0 < x <= 8 0 +heading 2. A polynomial approximation of lgamma math_impl/patch/lgamma.html#methodcolon-Z2dot-a-polynomial-approximation-of-lgamma 2. A polynomial approximation of lgamma 0 +heading 3. Rational approximation in the primary interval nim[2,3] math_impl/patch/lgamma.html#methodcolon-Z3dot-rational-approximation-in-the-primary-interval-nim-2-3 3. Rational approximation in the primary interval [2,3] 0 +heading 4. For x>=8, ... math_impl/patch/lgamma.html#methodcolon-Z4dot-for-xgteq8-dotdotdot 4. For x>=8, ... 0 +heading 5. For negative x, ... math_impl/patch/lgamma.html#methodcolon-Z5dot-for-negative-x-dotdotdot 5. For negative x, ... 0 +heading Special Cases math_impl/patch/lgamma.html#special-cases Special Cases 0 +heading Notice math_impl/patch/lgamma.html#notice Notice 0 diff --git a/Lib/math_impl/patch/nextafter.html b/Lib/math_impl/patch/nextafter.html new file mode 100644 index 000000000..c4fb00c1e --- /dev/null +++ b/Lib/math_impl/patch/nextafter.html @@ -0,0 +1,121 @@ + + + + + + + +src/pylib/Lib/math_impl/patch/nextafter + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/math_impl/patch/nextafter

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

translated from https://github.com/scijs/nextafter/blob/master/nextafter.js

+

And add respect to the sign of zero, e.g.

+

nextafter(-0.0, 0.0) == 0.0 nextafter(0.0, -0.0) == -0.0

+

+ +
+

Procs

+
+
+
+
func nextafter[F](x, y: F): F
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/math_impl/patch/nextafter.idx b/Lib/math_impl/patch/nextafter.idx new file mode 100644 index 000000000..23a873a73 --- /dev/null +++ b/Lib/math_impl/patch/nextafter.idx @@ -0,0 +1,2 @@ +nimTitle nextafter math_impl/patch/nextafter.html module src/pylib/Lib/math_impl/patch/nextafter 0 +nim nextafter math_impl/patch/nextafter.html#nextafter,F,F proc nextafter[F](x, y: F): F 53 diff --git a/Lib/math_impl/patch/nextafter_step.html b/Lib/math_impl/patch/nextafter_step.html new file mode 100644 index 000000000..c6bfbc129 --- /dev/null +++ b/Lib/math_impl/patch/nextafter_step.html @@ -0,0 +1,119 @@ + + + + + + + +src/pylib/Lib/math_impl/patch/nextafter_step + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/math_impl/patch/nextafter_step

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

XXX: TODO: current Implementation is slow

+
+

Imports

+
+ nextafter +
+
+
+

Procs

+
+
+
+
proc nextafter(x, y: float; usteps: uint64): float {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/math_impl/patch/nextafter_step.idx b/Lib/math_impl/patch/nextafter_step.idx new file mode 100644 index 000000000..50b04be13 --- /dev/null +++ b/Lib/math_impl/patch/nextafter_step.idx @@ -0,0 +1,2 @@ +nimTitle nextafter_step math_impl/patch/nextafter_step.html module src/pylib/Lib/math_impl/patch/nextafter_step 0 +nim nextafter math_impl/patch/nextafter_step.html#nextafter,float,float,uint64 proc nextafter(x, y: float; usteps: uint64): float 5 diff --git a/Lib/math_impl/patch/sinpi.html b/Lib/math_impl/patch/sinpi.html new file mode 100644 index 000000000..6ecb4b4e1 --- /dev/null +++ b/Lib/math_impl/patch/sinpi.html @@ -0,0 +1,109 @@ + + + + + + + +src/pylib/Lib/math_impl/patch/sinpi + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/math_impl/patch/sinpi

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Procs

+
+
+
+
func sinpi[F: SomeFloat](x: F): F
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/math_impl/patch/sinpi.idx b/Lib/math_impl/patch/sinpi.idx new file mode 100644 index 000000000..c89651b09 --- /dev/null +++ b/Lib/math_impl/patch/sinpi.idx @@ -0,0 +1,2 @@ +nimTitle sinpi math_impl/patch/sinpi.html module src/pylib/Lib/math_impl/patch/sinpi 0 +nim sinpi math_impl/patch/sinpi.html#sinpi,F proc sinpi[F: SomeFloat](x: F): F 4 diff --git a/Lib/math_impl/patch/trunc.html b/Lib/math_impl/patch/trunc.html new file mode 100644 index 000000000..9454abd9c --- /dev/null +++ b/Lib/math_impl/patch/trunc.html @@ -0,0 +1,109 @@ + + + + + + + +src/pylib/Lib/math_impl/patch/trunc + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/math_impl/patch/trunc

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Procs

+
+
+
+
func uncheckedTruncToInt[I: SomeInteger](x: SomeFloat): I
+
+ + do not check for nans and infinities + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/math_impl/patch/trunc.idx b/Lib/math_impl/patch/trunc.idx new file mode 100644 index 000000000..3b7cecefb --- /dev/null +++ b/Lib/math_impl/patch/trunc.idx @@ -0,0 +1,2 @@ +nimTitle trunc math_impl/patch/trunc.html module src/pylib/Lib/math_impl/patch/trunc 0 +nim uncheckedTruncToInt math_impl/patch/trunc.html#uncheckedTruncToInt,SomeFloat proc uncheckedTruncToInt[I: SomeInteger](x: SomeFloat): I 2 diff --git a/Lib/math_impl/platformUtils.html b/Lib/math_impl/platformUtils.html new file mode 100644 index 000000000..e7be179af --- /dev/null +++ b/Lib/math_impl/platformUtils.html @@ -0,0 +1,96 @@ + + + + + + + +src/pylib/Lib/math_impl/platformUtils + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/math_impl/platformUtils

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ + + +
+
+ + +
+
+ + + diff --git a/Lib/math_impl/platformUtils.idx b/Lib/math_impl/platformUtils.idx new file mode 100644 index 000000000..07d361e02 --- /dev/null +++ b/Lib/math_impl/platformUtils.idx @@ -0,0 +1 @@ +nimTitle platformUtils math_impl/platformUtils.html module src/pylib/Lib/math_impl/platformUtils 0 diff --git a/Lib/math_impl/polevl.html b/Lib/math_impl/polevl.html new file mode 100644 index 000000000..2ebc925d3 --- /dev/null +++ b/Lib/math_impl/polevl.html @@ -0,0 +1,187 @@ + + + + + + + +src/pylib/Lib/math_impl/polevl + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/math_impl/polevl

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

The implementation uses Horner's rule for more efficient computation.

+
+

Procs

+
+
+
+
func p1evl[F](x: F; coef: openArray[F]; N = coef.high - 1): F
+
+ + Evaluate polynomial when coefficient of x is 1.0. Otherwise same as polevl. + Source   +Edit   + +
+
+ +
+
+
+
func polevl[F](x: F; coef: openArray[F]; N = coef.high): F
+
+ +
  Evaluates polynomial of degree N:
+                      
+                      2          N
+  y  =  C  + C x + C x  +...+ C x
+         0    1     2          N
+  
+  Coefficients are stored in reverse order:
+  
+  coef[0] = C  , ..., coef[N] = C  .
+              N                   0
+ Source   +Edit   + +
+
+ +
+ +
+
+
+

Macros

+
+
+
+
macro polExpd[F](x: F; coef: untyped): F
+
+ +

expand polynomial with coef literal as inline expression.

+

coef shall be literal of a serials of F surrounded by brackets, curly braces or paratheses

+ +

Example:

+
assert 1.0*3.0+2.0 == polExpd(1.0, (3.0, 2.0))
+ Source   +Edit   + +
+
+ +
+
+
+
macro polExpd0[F](x: F; rcoef: untyped): F
+
+ + the same as polExpd except that rcoef is reversed: rcoef[0] is the C_0 constant (a.k.a. muliplied by x^0) + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/math_impl/polevl.idx b/Lib/math_impl/polevl.idx new file mode 100644 index 000000000..42c85a00d --- /dev/null +++ b/Lib/math_impl/polevl.idx @@ -0,0 +1,5 @@ +nimTitle polevl math_impl/polevl.html module src/pylib/Lib/math_impl/polevl 0 +nim polevl math_impl/polevl.html#polevl,F,openArray[F] proc polevl[F](x: F; coef: openArray[F]; N = coef.high): F 7 +nim polExpd math_impl/polevl.html#polExpd.m,F,untyped macro polExpd[F](x: F; coef: untyped): F 27 +nim polExpd0 math_impl/polevl.html#polExpd0.m,F,untyped macro polExpd0[F](x: F; rcoef: untyped): F 45 +nim p1evl math_impl/polevl.html#p1evl,F,openArray[F],typeof(coef.high - 1) proc p1evl[F](x: F; coef: openArray[F]; N = coef.high - 1): F 58 diff --git a/Lib/math_impl/vec_op.html b/Lib/math_impl/vec_op.html new file mode 100644 index 000000000..183e695dd --- /dev/null +++ b/Lib/math_impl/vec_op.html @@ -0,0 +1,96 @@ + + + + + + + +src/pylib/Lib/math_impl/vec_op + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/math_impl/vec_op

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+ +
+ + +
+
+ + + diff --git a/Lib/math_impl/vec_op.idx b/Lib/math_impl/vec_op.idx new file mode 100644 index 000000000..0f4ef9b0e --- /dev/null +++ b/Lib/math_impl/vec_op.idx @@ -0,0 +1 @@ +nimTitle vec_op math_impl/vec_op.html module src/pylib/Lib/math_impl/vec_op 0 diff --git a/Lib/math_impl/vec_op/dist.html b/Lib/math_impl/vec_op/dist.html new file mode 100644 index 000000000..4538fabae --- /dev/null +++ b/Lib/math_impl/vec_op/dist.html @@ -0,0 +1,140 @@ + + + + + + + +src/pylib/Lib/math_impl/vec_op/dist + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/math_impl/vec_op/dist

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
func dist[A, B, C](p, q: (A, B, C)): float {....raises: [].}
+
+ + + Source   +Edit   + +
+
+
+
func dist[A, B](p, q: (A, B)): float {....raises: [].}
+
+ + + Source   +Edit   + +
+
+
+
func dist[T; I: static[int]](p, q: array[I, T]): float {....raises: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/math_impl/vec_op/dist.idx b/Lib/math_impl/vec_op/dist.idx new file mode 100644 index 000000000..d107f509d --- /dev/null +++ b/Lib/math_impl/vec_op/dist.idx @@ -0,0 +1,5 @@ +nimTitle dist math_impl/vec_op/dist.html module src/pylib/Lib/math_impl/vec_op/dist 0 +nim dist math_impl/vec_op/dist.html#dist,array[I,T],array[I,T] proc dist[T; I: static[int]](p, q: array[I, T]): float 221 +nim dist math_impl/vec_op/dist.html#dist,, proc dist[A, B](p, q: (A, B)): float 224 +nim dist math_impl/vec_op/dist.html#dist,,_2 proc dist[A, B, C](p, q: (A, B, C)): float 230 +nimgrp dist math_impl/vec_op/dist.html#dist-procs-all proc 221 diff --git a/Lib/math_impl/vec_op/niter_types.html b/Lib/math_impl/vec_op/niter_types.html new file mode 100644 index 000000000..2ad6be357 --- /dev/null +++ b/Lib/math_impl/vec_op/niter_types.html @@ -0,0 +1,193 @@ + + + + + + + +src/pylib/Lib/math_impl/vec_op/niter_types + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/math_impl/vec_op/niter_types

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Types

+
+
+
ClosureIter[T] = iterator (): T
+
+ + + Source   +Edit   + +
+
+
+
OpenarrayOrNimIter[T] = openArray[T] or ClosureIter[T]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
func dist_checkedSameLen[T](p, q: T): int {.inline.}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template openarray_Check(x): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template toNimIterator[T](x): ClosureIter[T]
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/math_impl/vec_op/niter_types.idx b/Lib/math_impl/vec_op/niter_types.idx new file mode 100644 index 000000000..4c9ebd657 --- /dev/null +++ b/Lib/math_impl/vec_op/niter_types.idx @@ -0,0 +1,6 @@ +nimTitle niter_types math_impl/vec_op/niter_types.html module src/pylib/Lib/math_impl/vec_op/niter_types 0 +nim ClosureIter math_impl/vec_op/niter_types.html#ClosureIter type ClosureIter 3 +nim OpenarrayOrNimIter math_impl/vec_op/niter_types.html#OpenarrayOrNimIter type OpenarrayOrNimIter 5 +nim toNimIterator math_impl/vec_op/niter_types.html#toNimIterator.t template toNimIterator[T](x): ClosureIter[T] 7 +nim openarray_Check math_impl/vec_op/niter_types.html#openarray_Check.t template openarray_Check(x): bool 15 +nim dist_checkedSameLen math_impl/vec_op/niter_types.html#dist_checkedSameLen,T,T proc dist_checkedSameLen[T](p, q: T): int 18 diff --git a/Lib/math_impl/vec_op/private/dl_ops.html b/Lib/math_impl/vec_op/private/dl_ops.html new file mode 100644 index 000000000..842a510c6 --- /dev/null +++ b/Lib/math_impl/vec_op/private/dl_ops.html @@ -0,0 +1,165 @@ + + + + + + + +src/pylib/Lib/math_impl/vec_op/private/dl_ops + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/math_impl/vec_op/private/dl_ops

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Types

+
+
+
DoubleLength = object
+  hi*: float
+  lo*: float
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
proc dl_mul(x: float; y: float): DoubleLength {....raises: [], tags: [],
+    forbids: [].}
+
+ + Dekker (5.12) and mul12() + Source   +Edit   + +
+
+ +
+
+
+
func dl_sum(a, b: float): DoubleLength {....raises: [], tags: [], forbids: [].}
+
+ + Algorithm 3.1 Error-free transformation of the sum + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/math_impl/vec_op/private/dl_ops.idx b/Lib/math_impl/vec_op/private/dl_ops.idx new file mode 100644 index 000000000..f3bf59a5f --- /dev/null +++ b/Lib/math_impl/vec_op/private/dl_ops.idx @@ -0,0 +1,4 @@ +nimTitle dl_ops math_impl/vec_op/private/dl_ops.html module src/pylib/Lib/math_impl/vec_op/private/dl_ops 0 +nim DoubleLength math_impl/vec_op/private/dl_ops.html#DoubleLength object DoubleLength 5 +nim dl_mul math_impl/vec_op/private/dl_ops.html#dl_mul,float,float proc dl_mul(x: float; y: float): DoubleLength 39 +nim dl_sum math_impl/vec_op/private/dl_ops.html#dl_sum,float,float proc dl_sum(a, b: float): DoubleLength 51 diff --git a/Lib/math_impl/vec_op/sumprod.html b/Lib/math_impl/vec_op/sumprod.html new file mode 100644 index 000000000..5faa25cc9 --- /dev/null +++ b/Lib/math_impl/vec_op/sumprod.html @@ -0,0 +1,129 @@ + + + + + + + +src/pylib/Lib/math_impl/vec_op/sumprod + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/math_impl/vec_op/sumprod

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
func sumprod[P, Q](p: openArray[P]; q: openArray[Q]): float
+
+ + a faster version for openarray than that for ClosureIter + Source   +Edit   + +
+
+
+
func sumprod[P, Q](p_it: ClosureIter[P]; q_it: ClosureIter[Q]): float
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/math_impl/vec_op/sumprod.idx b/Lib/math_impl/vec_op/sumprod.idx new file mode 100644 index 000000000..b57ba00bf --- /dev/null +++ b/Lib/math_impl/vec_op/sumprod.idx @@ -0,0 +1,4 @@ +nimTitle sumprod math_impl/vec_op/sumprod.html module src/pylib/Lib/math_impl/vec_op/sumprod 0 +nim sumprod math_impl/vec_op/sumprod.html#sumprod,ClosureIter[P],ClosureIter[Q] proc sumprod[P, Q](p_it: ClosureIter[P]; q_it: ClosureIter[Q]): float 136 +nim sumprod math_impl/vec_op/sumprod.html#sumprod,openArray[P],openArray[Q] proc sumprod[P, Q](p: openArray[P]; q: openArray[Q]): float 155 +nimgrp sumprod math_impl/vec_op/sumprod.html#sumprod-procs-all proc 136 diff --git a/Lib/n_bisect.html b/Lib/n_bisect.html new file mode 100644 index 000000000..e4eab3302 --- /dev/null +++ b/Lib/n_bisect.html @@ -0,0 +1,286 @@ + + + + + + + +src/pylib/Lib/n_bisect + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/n_bisect

+
+ +
+ Source   +Edit   + +
+ +

+
+

Types

+
+
+
Key[T; R] = proc (x: T): R
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
proc bisect[T, K](a: openArray[T]; x: K; lo = 0; hi = a.len; key: Key[T, K]): int
+
+ + + Source   +Edit   + +
+
+
+
proc bisect[T](a: openArray[T]; x: T; lo = 0; hi = a.len): int
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc bisect_left[T, K](a: openArray[T]; x: K; lo = 0; hi = a.len; key: Key[T, K]): int
+
+ + + Source   +Edit   + +
+
+
+
proc bisect_left[T](a: openArray[T]; x: T; lo = 0; hi = a.len): int
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc bisect_right[T, K](a: openArray[T]; x: K; lo = 0; hi = a.len;
+                        key: Key[T, K]): int
+
+ + + Source   +Edit   + +
+
+
+
proc bisect_right[T](a: openArray[T]; x: T; lo = 0; hi = a.len): int
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc insort[T; K](a: var seq[T]; x: K; lo = 0; hi = len(a); key: Key[T, K])
+
+ + + Source   +Edit   + +
+
+
+
proc insort[T](a: var seq[T]; x: T; lo = 0; hi = len(a))
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc insort_left[T; K](a: var seq[T]; x: K; lo = 0; hi = len(a); key: Key[T, K])
+
+ + + Source   +Edit   + +
+
+
+
proc insort_left[T](a: var seq[T]; x: T; lo = 0; hi = len(a))
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc insort_right[T; K](a: var seq[T]; x: K; lo = 0; hi = len(a); key: Key[T, K])
+
+ + + Source   +Edit   + +
+
+
+
proc insort_right[T](a: var seq[T]; x: T; lo = 0; hi = len(a))
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/n_bisect.idx b/Lib/n_bisect.idx new file mode 100644 index 000000000..a280b4ce4 --- /dev/null +++ b/Lib/n_bisect.idx @@ -0,0 +1,20 @@ +nimTitle n_bisect n_bisect.html module src/pylib/Lib/n_bisect 0 +nim Key n_bisect.html#Key type Key 12 +nim bisect n_bisect.html#bisect,openArray[T],T,int proc bisect[T](a: openArray[T]; x: T; lo = 0; hi = a.len): int 30 +nim bisect n_bisect.html#bisect,openArray[T],K,int,Key[T,K] proc bisect[T, K](a: openArray[T]; x: K; lo = 0; hi = a.len; key: Key[T, K]): int 34 +nim bisect_right n_bisect.html#bisect_right,openArray[T],T,int proc bisect_right[T](a: openArray[T]; x: T; lo = 0; hi = a.len): int 30 +nim bisect_right n_bisect.html#bisect_right,openArray[T],K,int,Key[T,K] proc bisect_right[T, K](a: openArray[T]; x: K; lo = 0; hi = a.len; key: Key[T, K]): int 35 +nim bisect_left n_bisect.html#bisect_left,openArray[T],T,int proc bisect_left[T](a: openArray[T]; x: T; lo = 0; hi = a.len): int 30 +nim bisect_left n_bisect.html#bisect_left,openArray[T],K,int,Key[T,K] proc bisect_left[T, K](a: openArray[T]; x: K; lo = 0; hi = a.len; key: Key[T, K]): int 36 +nim insort_left n_bisect.html#insort_left,seq[T],T,int,typeof(len(a)) proc insort_left[T](a: var seq[T]; x: T; lo = 0; hi = len(a)) 39 +nim insort_left n_bisect.html#insort_left,seq[T],K,int,typeof(len(a)),Key[T,K] proc insort_left[T; K](a: var seq[T]; x: K; lo = 0; hi = len(a); key: Key[T, K]) 47 +nim insort_right n_bisect.html#insort_right,seq[T],T,int,typeof(len(a)) proc insort_right[T](a: var seq[T]; x: T; lo = 0; hi = len(a)) 39 +nim insort_right n_bisect.html#insort_right,seq[T],K,int,typeof(len(a)),Key[T,K] proc insort_right[T; K](a: var seq[T]; x: K; lo = 0; hi = len(a); key: Key[T, K]) 48 +nim insort n_bisect.html#insort,seq[T],T,int,typeof(len(a)) proc insort[T](a: var seq[T]; x: T; lo = 0; hi = len(a)) 39 +nim insort n_bisect.html#insort,seq[T],K,int,typeof(len(a)),Key[T,K] proc insort[T; K](a: var seq[T]; x: K; lo = 0; hi = len(a); key: Key[T, K]) 49 +nimgrp bisectright n_bisect.html#bisect_right-procs-all proc 35 +nimgrp bisectleft n_bisect.html#bisect_left-procs-all proc 36 +nimgrp bisect n_bisect.html#bisect-procs-all proc 34 +nimgrp insortright n_bisect.html#insort_right-procs-all proc 48 +nimgrp insortleft n_bisect.html#insort_left-procs-all proc 47 +nimgrp insort n_bisect.html#insort-procs-all proc 49 diff --git a/Lib/n_datetime.html b/Lib/n_datetime.html new file mode 100644 index 000000000..26d586209 --- /dev/null +++ b/Lib/n_datetime.html @@ -0,0 +1,96 @@ + + + + + + + +src/pylib/Lib/n_datetime + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/n_datetime

+ + + +
+
+ + + diff --git a/Lib/n_datetime.idx b/Lib/n_datetime.idx new file mode 100644 index 000000000..4d21cd2d3 --- /dev/null +++ b/Lib/n_datetime.idx @@ -0,0 +1 @@ +nimTitle n_datetime n_datetime.html module src/pylib/Lib/n_datetime 0 diff --git a/Lib/n_errno.html b/Lib/n_errno.html new file mode 100644 index 000000000..f972d655b --- /dev/null +++ b/Lib/n_errno.html @@ -0,0 +1,96 @@ + + + + + + + +src/pylib/Lib/n_errno + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/n_errno

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ + + +
+
+ + +
+
+ + + diff --git a/Lib/n_errno.idx b/Lib/n_errno.idx new file mode 100644 index 000000000..0c6f6fdbf --- /dev/null +++ b/Lib/n_errno.idx @@ -0,0 +1 @@ +nimTitle n_errno n_errno.html module src/pylib/Lib/n_errno 0 diff --git a/Lib/n_inspect.html b/Lib/n_inspect.html new file mode 100644 index 000000000..5186e488a --- /dev/null +++ b/Lib/n_inspect.html @@ -0,0 +1,196 @@ + + + + + + + +src/pylib/Lib/n_inspect + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/n_inspect

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
func cleandoc(s: string): string {.inline, ...raises: [], tags: [], forbids: [].}
+
+ +

Cleans up a docstring by removing leading whitespace and trailing newlines.

+

The first line of the docstring is also removed, as it is assumed to be the docstring's summary.

+

The docstring is also trimmed of leading and trailing whitespace.

+ + Source   +Edit   + +
+
+ +
+
+
+
proc getmodulename(obj: string): string {....raises: [ValueError], tags: [],
+    forbids: [].}
+
+ + PY-DIFF: This cannot returns None, but may raise a ValueError. + Source   +Edit   + +
+
+ +
+ +
+
+
+

Macros

+
+
+
+
macro getdoc(obj: typed): string
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
macro getsourcelines(obj: typed): (seq[string], int)
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ + +
+
+ + +
+
+ + + diff --git a/Lib/n_inspect.idx b/Lib/n_inspect.idx new file mode 100644 index 000000000..85d351074 --- /dev/null +++ b/Lib/n_inspect.idx @@ -0,0 +1,5 @@ +nimTitle n_inspect n_inspect.html module src/pylib/Lib/n_inspect 0 +nim getmodulename n_inspect.html#getmodulename,string proc getmodulename(obj: string): string 13 +nim cleandoc n_inspect.html#cleandoc,string proc cleandoc(s: string): string 21 +nim getsourcelines n_inspect.html#getsourcelines.m,typed macro getsourcelines(obj: typed): (seq[string], int) 32 +nim getdoc n_inspect.html#getdoc.m,typed macro getdoc(obj: typed): string 35 diff --git a/Lib/n_itertools.html b/Lib/n_itertools.html new file mode 100644 index 000000000..6897489e2 --- /dev/null +++ b/Lib/n_itertools.html @@ -0,0 +1,216 @@ + + + + + + + +src/pylib/Lib/n_itertools + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/n_itertools

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Types

+
+
+
BinOp[T] = proc (x, y: T): T
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
proc binOpAdd[T](x, y: T): T
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Iterators

+
+
+
+
iterator accumulate[T](iterable: openArray[T]; binop: BinOp[T] = binOpAdd;
+                       inital = mayZeroDefault(T)): T
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
iterator combinations[T](iterable: openArray[T]; r: int): seq[T]
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template mayZeroDefault[T](t: typedesc[T]): T
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/n_itertools.idx b/Lib/n_itertools.idx new file mode 100644 index 000000000..1be02bb6c --- /dev/null +++ b/Lib/n_itertools.idx @@ -0,0 +1,6 @@ +nimTitle n_itertools n_itertools.html module src/pylib/Lib/n_itertools 0 +nim combinations n_itertools.html#combinations.i,openArray[T],int iterator combinations[T](iterable: openArray[T]; r: int): seq[T] 46 +nim mayZeroDefault n_itertools.html#mayZeroDefault.t,typedesc[T] template mayZeroDefault[T](t: typedesc[T]): T 50 +nim binOpAdd n_itertools.html#binOpAdd,T,T proc binOpAdd[T](x, y: T): T 54 +nim BinOp n_itertools.html#BinOp type BinOp 55 +nim accumulate n_itertools.html#accumulate.i,openArray[T],BinOp[T],typeof(mayZeroDefault(T)) iterator accumulate[T](iterable: openArray[T]; binop: BinOp[T] = binOpAdd;\n inital = mayZeroDefault(T)): T 56 diff --git a/Lib/n_math.html b/Lib/n_math.html new file mode 100644 index 000000000..4c863b965 --- /dev/null +++ b/Lib/n_math.html @@ -0,0 +1,920 @@ + + + + + + + +src/pylib/Lib/n_math + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/n_math

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

Nim's Python-like math, but raises no catchable exception, using errno to report math error. a.k.a. non will be raised (but not for Defects)

+

which allows fast code.

+

For Python-like error handler (exception-based), see Lib/math

+

Also this is not just a module that wraps Nim's std/math,

+

but also providing some extensions that Nim's std/math lacks, for example:

+
  • JavaScript Backend and Compile-time (Nim VM) support for ldexp, frexp, cbrt, etc.
  • +
  • JavaScript Backend support for erf, erfc, gamma, lgamma
  • +
  • fsum, prod, etc.
  • +
+

And fix some non-C99 behavior on some systems, e.g. log(-ve) -> -Inf on Solaris

+

NOTE: Currently int is not acceptable when it comes to float about functions

+

+ +
+

Consts

+
+
+
e = 2.718281828459045
+
+ + + Source   +Edit   + +
+
+
+
inf = 0x7FF0000000000000'f64
+
+ + + Source   +Edit   + +
+
+
+
nan = 0x7FF7FFFFFFFFFFFF'f64
+
+ + + Source   +Edit   + +
+
+
+
pi = 3.141592653589793
+
+ + + Source   +Edit   + +
+
+
+
tau = 6.283185307179586
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
func acos[F: SomeFloat](x: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func acosh[F: SomeFloat](x: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func asin[F: SomeFloat](x: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func asinh[F: SomeFloat](x: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func atan[F: SomeFloat](x: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func atan2[F: SomeFloat](x: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func atanh[F: SomeFloat](x: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func ceil(x: SomeFloat): int
+
+ +
Hint: +unlike C/Nim's returning float, Python's returns int and raises errors for nans and infinities
+ + Source   +Edit   + +
+
+ +
+
+
+
func comb(n, k: int): int {....raises: [], tags: [], forbids: [].}
+
+ +
Hint: +Python's math.comb does not accept negative value for n, k but Nim's std/math.binom allows, so this function allows too. For consistent behavior with Python, see Lib/math.comb
+ + Source   +Edit   + +
+
+ +
+
+
+
func degrees[F: SomeFloat](x: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func fabs[F: SomeFloat](x: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func factorial(x: Natural): int {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func floor(x: SomeFloat): int
+
+ +
Hint: +unlike C/Nim's returning float, Python's returns int and raises errors for nans and infinities
+ + Source   +Edit   + +
+
+ +
+
+
+
func fmod[F: SomeFloat](x: F; y: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func fsum[T: SomeFloat](iterable: Iterable[T]): T
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func gamma[F: SomeFloat](x: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func gcd[I: SomeInteger](x, y, z: I; args: varargs[I]): I
+
+ + + Source   +Edit   + +
+
+
+
func gcd[I: SomeInteger](x, y: I): I
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func hypot[I: SomeFloat](x, y, z: I; args: varargs[I]): I
+
+ + + Source   +Edit   + +
+
+
+
func hypot[I: SomeFloat](x, y: I): I
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func isclose(a, b: SomeFloat; rel_tol = 1e-9; abs_tol = 0.0): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func isqrt(n: Natural): int {....raises: [], tags: [], forbids: [].}
+
+ + +

Example:

+
assert 2 == isqrt 5
+ Source   +Edit   + +
+
+
+
func isqrt[T: SomeFloat](x: T): int {....raises: [].}
+
+ +
Hint: +assuming x > 0 (raise RangeDefect otherwise (if not danger build))
+

use math.isqrt if expecting raising ValueError

+ + Source   +Edit   + +
+
+ +
+
+
+
func isqrtPositive(n: Positive): int {.inline, ...raises: [], tags: [], forbids: [].}
+
+ + EXT: isqrt for Positive only, as we all know, in Python:
  • isqrt(0) == 0
  • +
  • isqrt(-int)
  • +
+ + Source   +Edit   + +
+
+ +
+
+
+
func lcm[I: SomeInteger](x, y, z: I; args: varargs[I]): I
+
+ + + Source   +Edit   + +
+
+
+
func lcm[I: SomeInteger](x, y: I): I
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func ldexp[F: SomeFloat](x: F; i: int): F {....raises: [].}
+
+ +
Hint: +only set errno
+ + Source   +Edit   + +
+
+
+
func ldexp[F: SomeFloat](x: F; i: int; exc: var ref Exception): F {....raises: [].}
+
+ +

set exception to exc instead of raising it

+

exc:

+
  • set to nil if no error
  • +
  • set to suitable exc if some error occurs
  • +
+ + Source   +Edit   + +
+
+ +
+
+
+
func lgamma[F: SomeFloat](x: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func log[F: SomeFloat](x, base: F): F
+
+ + + Source   +Edit   + +
+
+
+
func log[F: SomeFloat](x: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func log2[F: SomeFloat](x: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func log10[F: SomeFloat](x: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func math_is_error(x: SomeFloat; exc: var ref Exception): bool
+
+ +

inner usage (used by Lib/math).

+

Call this when errno != 0, and where x is the result libm returned. This will usually set up an exception and return true, but may return false without setting up an exception.

+ + Source   +Edit   + +
+
+ +
+
+
+
func modf[F: SomeFloat](x: F): tuple[intpart: F, floatpart: F]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func perm(n, k: Natural): int {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func perm(n: int): int {....raises: [], tags: [], forbids: [].}
+
+ + equal to perm(n,n), returns n! + Source   +Edit   + +
+
+ +
+
+
+
func pow[F: SomeFloat](x, y: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func prod[T](iterable: Iterable[T]; start = 1.T): T
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func radians[F: SomeFloat](x: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func remainder[F: SomeFloat](x: F; y: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func trunc(x: SomeFloat): int
+
+ +
Hint: +unlike C/Nim's returning float, Python's returns int and raises errors for nans and infinities
+ + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template py_math_isclose_impl(abs)
+
+ +

inner use. Implementation of isclose.

+

mixin a, b, isinf, rel_tol, abs_tol

+ + Source   +Edit   + +
+
+ +
+ +
+
+ + +
+
+ + +
+
+ + + diff --git a/Lib/n_math.idx b/Lib/n_math.idx new file mode 100644 index 000000000..368ac8da9 --- /dev/null +++ b/Lib/n_math.idx @@ -0,0 +1,56 @@ +nimTitle n_math n_math.html module src/pylib/Lib/n_math 0 +nim nan n_math.html#nan const nan 78 +nim inf n_math.html#inf const inf 78 +nim pi n_math.html#pi const pi 78 +nim tau n_math.html#tau const tau 78 +nim e n_math.html#e const e 78 +nim pow n_math.html#pow,F,F proc pow[F: SomeFloat](x, y: F): F 98 +nim fabs n_math.html#fabs,F proc fabs[F: SomeFloat](x: F): F 150 +nim ceil n_math.html#ceil,SomeFloat proc ceil(x: SomeFloat): int 167 +nim floor n_math.html#floor,SomeFloat proc floor(x: SomeFloat): int 168 +nim trunc n_math.html#trunc,SomeFloat proc trunc(x: SomeFloat): int 169 +nim py_math_isclose_impl n_math.html#py_math_isclose_impl.t template py_math_isclose_impl(abs) 171 +nim isclose n_math.html#isclose,SomeFloat,SomeFloat,float,float proc isclose(a, b: SomeFloat; rel_tol = 1e-9; abs_tol = 0.0): bool 187 +nim gcd n_math.html#gcd,I,I proc gcd[I: SomeInteger](x, y: I): I 191 +nim gcd n_math.html#gcd,I,I,I,varargs[I] proc gcd[I: SomeInteger](x, y, z: I; args: varargs[I]): I 198 +nim lcm n_math.html#lcm,I,I proc lcm[I: SomeInteger](x, y: I): I 191 +nim lcm n_math.html#lcm,I,I,I,varargs[I] proc lcm[I: SomeInteger](x, y, z: I; args: varargs[I]): I 199 +nim hypot n_math.html#hypot,I,I proc hypot[I: SomeFloat](x, y: I): I 191 +nim hypot n_math.html#hypot,I,I,I,varargs[I] proc hypot[I: SomeFloat](x, y, z: I; args: varargs[I]): I 201 +nim gamma n_math.html#gamma,F proc gamma[F: SomeFloat](x: F): F 214 +nim lgamma n_math.html#lgamma,F proc lgamma[F: SomeFloat](x: F): F 222 +nim math_is_error n_math.html#math_is_error,SomeFloat,ref.Exception proc math_is_error(x: SomeFloat; exc: var ref Exception): bool 240 +nim ldexp n_math.html#ldexp,F,int,ref.Exception proc ldexp[F: SomeFloat](x: F; i: int; exc: var ref Exception): F 282 +nim ldexp n_math.html#ldexp,F,int proc ldexp[F: SomeFloat](x: F; i: int): F 316 +nim modf n_math.html#modf,F proc modf[F: SomeFloat](x: F): tuple[intpart: F, floatpart: F] 321 +nim fmod n_math.html#fmod,F,F proc fmod[F: SomeFloat](x: F; y: F): F 330 +nim remainder n_math.html#remainder,F,F proc remainder[F: SomeFloat](x: F; y: F): F 343 +nim prod n_math.html#prod,Iterable[T] proc prod[T](iterable: Iterable[T]; start = 1.T): T 427 +nim fsum n_math.html#fsum,Iterable[T: SomeFloat] proc fsum[T: SomeFloat](iterable: Iterable[T]): T 435 +nim log n_math.html#log,F proc log[F: SomeFloat](x: F): F 569 +nim log n_math.html#log,F,F proc log[F: SomeFloat](x, base: F): F 570 +nim log2 n_math.html#log2,F proc log2[F: SomeFloat](x: F): F 577 +nim log10 n_math.html#log10,F proc log10[F: SomeFloat](x: F): F 578 +nim degrees n_math.html#degrees,F proc degrees[F: SomeFloat](x: F): F 581 +nim radians n_math.html#radians,F proc radians[F: SomeFloat](x: F): F 583 +nim asin n_math.html#asin,F proc asin[F: SomeFloat](x: F): F 593 +nim asinh n_math.html#asinh,F proc asinh[F: SomeFloat](x: F): F 594 +nim acos n_math.html#acos,F proc acos[F: SomeFloat](x: F): F 595 +nim acosh n_math.html#acosh,F proc acosh[F: SomeFloat](x: F): F 596 +nim atan n_math.html#atan,F proc atan[F: SomeFloat](x: F): F 597 +nim atan2 n_math.html#atan2,F proc atan2[F: SomeFloat](x: F): F 598 +nim atanh n_math.html#atanh,F proc atanh[F: SomeFloat](x: F): F 599 +nim comb n_math.html#comb,int,int proc comb(n, k: int): int 602 +nim perm n_math.html#perm,int proc perm(n: int): int 608 +nim perm n_math.html#perm,Natural,Natural proc perm(n, k: Natural): int 612 +nim factorial n_math.html#factorial,Natural proc factorial(x: Natural): int 619 +nim isqrtPositive n_math.html#isqrtPositive,Positive proc isqrtPositive(n: Positive): int 628 +nim isqrt n_math.html#isqrt,Natural proc isqrt(n: Natural): int 648 +nim isqrt n_math.html#isqrt,T proc isqrt[T: SomeFloat](x: T): int 678 +nimgrp isqrt n_math.html#isqrt-procs-all proc 648 +nimgrp hypot n_math.html#hypot-procs-all proc 201 +nimgrp perm n_math.html#perm-procs-all proc 608 +nimgrp log n_math.html#log-procs-all proc 569 +nimgrp ldexp n_math.html#ldexp-procs-all proc 282 +nimgrp lcm n_math.html#lcm-procs-all proc 199 +nimgrp gcd n_math.html#gcd-procs-all proc 198 diff --git a/Lib/n_os.html b/Lib/n_os.html new file mode 100644 index 000000000..c2729bae2 --- /dev/null +++ b/Lib/n_os.html @@ -0,0 +1,152 @@ + + + + + + + +src/pylib/Lib/n_os + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/n_os

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Types

+
+
+
uname_result = tuple[sysname, nodename, release, version, machine: string]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
proc uname(): uname_result {....raises: [PyOSError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Exports

+
+ O_DIRECTORY, O_TMPFILE, O_SYNC, O_DIRECT, O_NONBLOCK, O_TRUNC, O_NOCTTY, O_EXCL, O_CREAT, O_DSYNC, |, name, O_RDONLY, pathsep, O_NOFOLLOW, O_NOATIME, O_CLOEXEC, O_WRONLY, O_APPEND, |=, O_NDELAY, ../pyconfig/os_consts, O_RSYNC, curdir, extsep, linesep, devnull, defpath, O_RDWR, altsep, sep, O_ASYNC, O_PATH, pardir, utime, utime, Py_fstat, genUname, items, closerange, SEEK_DATA, symlink, stat, open, isatty, utime, mkdir, scandir, getpid, TimePair, close, st_atime, fdopendir, exit, close, is_symlink, scandir, stat, getppid, TimeNsPair, symlink, lstat, readlink, SEEK_CUR, stat, st_mtime, st_mtime_ns, fchmod, SEEK_END, lseek, is_file, enter, rename, DirEntry, rmdir, unlink, st_atime_ns, umask, NsUnit, remove, stat_result, close, st_ctime, repr, is_dir, mkdir, scandir, ftruncate, rmdir, Py_fstat_noraise, fdopen, SEEK_SET, is_dir, is_junction, SEEK_HOLE, scandirIter, scandir, truncate, replace, is_file, scandir, ., link, fstat, scandir, st_ctime_ns, chmod, [], system, removedirs, getcwd, chdir, makedirs, getcwdb, normpath, fspath, substr, O_NOCTTY, ==, str, NoneType, getChar, getsize, +=, $, bytes, O_CREAT, TimeoutError, +=, items, osErrorMsgWithPath, altsep, substr, O_APPEND, ProcessLookupError, raiseExcWithPath, tryOsOp, mapPathLike, Serial, BlockingIOError, isfile, dirname, runes, sep, getmtime, ==, repr, noWeirdTarget, O_NOFOLLOW, contains, O_CLOEXEC, O_NOATIME, O_WRONLY, +, wrapExportSincePy, bytes, PySys_Audit, ==, str, O_RDWR, +, PyMinor, pardir, isabs, O_TMPFILE, asVersion, templWrapExportSincePy, O_SYNC, ConnectionError, ConnectionResetError, BlockingIOError, toNimString, +, [], repr, pathrepr, [], PySerial, IsADirectoryError, linesep, runeAtPos, asVersion, fspath, raiseErrno, +=, +=, O_PATH, O_TRUNC, PyMajor, $, SystemExit, tryOsOp, PySys_AddAuditHook, getatime, contains, chars, PyBytes, ChildProcessError, splitdrive, bytes, toNimStr, TypeError, split, newPyOSError, NameError, toNimString, bytes, devnull, +, len, KeyboardInterrupt, str, newPyOSError, [], ConnectionRefusedError, +=, or, [], pybytes, tryOsOp, $, O_ASYNC, PyReleaseLevel, [], Patch, [], osErrorMsgWithPath, byteLen, O_DIRECTORY, getctime, raiseExcWithPath2, PyReleaseLevelEnum, O_DIRECT, AttributeError, exportSincePy, name, substr, PyStr, Minor, and, splitext, $, NotADirectoryError, basename, NotImplementedError, PermissionError, curdir, toPyStr, O_DSYNC, raiseExcWithPath, abspath, getCharPtr, islink, |=, PyOSError, runeLenAt, Version, raiseErrnoT, mapPathLike, CanIOOpenT, FileNotFoundError, BlockingIOError, fspath, pathsep, nestListWithFirst, chars, PathLike, len, $, O_NDELAY, toPyStr, samestat, @, extsep, defpath, str, FileExistsError, toPyStr, asVersion, asVersion, pysince, not, RuntimeError, ../pyconfig/os_consts, PyPatch, InterruptedError, isdir, StringLike, |, pysince, O_RDONLY, newBlockingIOError, not, raiseErrnoWithPath, contains, getChar, errnoMsg, bytes, +=, Major, samefile, hasChar, ==, +, +, pathrepr, None, InJs, O_NONBLOCK, addaudithook, relpath, join, ConnectionAbortedError, str, BrokenPipeError, or, tryOsOp, byteLen, items, PyOSError, audit, PyOSError, newBlockingIOError, len, str, pysince, raiseExcWithPath, O_RSYNC, bytes, +, O_EXCL, join, ReleaseLevel, fspath, raiseExcWithPath, bytes, bytes, $, walk, WalkRes, shallIgnore, walk, walk, OnErrorCb, toTup, repr, walk_symlinks_as_files, walk, [], listdir, urandom, getrandom, wait4, wait3, WTERMSIG, WIFSTOPPED, waitstatus_to_exitcode, WIFSIGNALED, wait, WIFCONTINUED, WEXITED, WNOHANG, WUNTRACED, WEXITSTATUS, WCOREDUMP, WSTOPPED, WNOWAIT, WSTOPSIG, WIFEXITED, WCONTINUED, waitpid, $, >=, contains, supports_fd, supports_dir_fd, issuperset, <=, supports_effective_ids, contains, supports_follow_symlinks, cpu_count, process_cpu_count, get_terminal_size, terminal_size, set_inheritable, get_inheritable +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/n_os.idx b/Lib/n_os.idx new file mode 100644 index 000000000..dd6285cc5 --- /dev/null +++ b/Lib/n_os.idx @@ -0,0 +1,3 @@ +nimTitle n_os n_os.html module src/pylib/Lib/n_os 0 +nim uname_result n_os.html#uname_result tuple uname_result 5 +nim uname n_os.html#uname proc uname(): uname_result 12 diff --git a/Lib/n_pathlib.html b/Lib/n_pathlib.html new file mode 100644 index 000000000..01133e54c --- /dev/null +++ b/Lib/n_pathlib.html @@ -0,0 +1,96 @@ + + + + + + + +src/pylib/Lib/n_pathlib + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/n_pathlib

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+ +
+ + +
+
+ + + diff --git a/Lib/n_pathlib.idx b/Lib/n_pathlib.idx new file mode 100644 index 000000000..3c97fd8df --- /dev/null +++ b/Lib/n_pathlib.idx @@ -0,0 +1 @@ +nimTitle n_pathlib n_pathlib.html module src/pylib/Lib/n_pathlib 0 diff --git a/Lib/n_random.html b/Lib/n_random.html new file mode 100644 index 000000000..489a5a61d --- /dev/null +++ b/Lib/n_random.html @@ -0,0 +1,96 @@ + + + + + + + +src/pylib/Lib/n_random + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/n_random

+ + + +
+
+ + + diff --git a/Lib/n_random.idx b/Lib/n_random.idx new file mode 100644 index 000000000..a110b96fd --- /dev/null +++ b/Lib/n_random.idx @@ -0,0 +1 @@ +nimTitle n_random n_random.html module src/pylib/Lib/n_random 0 diff --git a/Lib/n_shutil.html b/Lib/n_shutil.html new file mode 100644 index 000000000..4e7b4105b --- /dev/null +++ b/Lib/n_shutil.html @@ -0,0 +1,96 @@ + + + + + + + +src/pylib/Lib/n_shutil + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/n_shutil

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+ +
+ + +
+
+ + + diff --git a/Lib/n_shutil.idx b/Lib/n_shutil.idx new file mode 100644 index 000000000..4d95ea8d8 --- /dev/null +++ b/Lib/n_shutil.idx @@ -0,0 +1 @@ +nimTitle n_shutil n_shutil.html module src/pylib/Lib/n_shutil 0 diff --git a/Lib/n_signal.html b/Lib/n_signal.html new file mode 100644 index 000000000..192b30943 --- /dev/null +++ b/Lib/n_signal.html @@ -0,0 +1,75 @@ + + + + + + + +src/pylib/Lib/n_signal + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/n_signal

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ +
+
+ Source   +Edit   + +
+ +

+ +
+
+ + +
+
+ + + diff --git a/Lib/n_signal.idx b/Lib/n_signal.idx new file mode 100644 index 000000000..81b3de22c --- /dev/null +++ b/Lib/n_signal.idx @@ -0,0 +1,3 @@ +nimTitle n_signal n_signal.html module src/pylib/Lib/n_signal 0 +nim NSIG n_signal.html#NSIG let NSIG 6 +nim valid_signals n_signal.html#valid_signals proc valid_signals(): HashSet[int] 15 diff --git a/Lib/n_stat.html b/Lib/n_stat.html new file mode 100644 index 000000000..9f2ebd686 --- /dev/null +++ b/Lib/n_stat.html @@ -0,0 +1,96 @@ + + + + + + + +src/pylib/Lib/n_stat + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/n_stat

+ + + +
+
+ + + diff --git a/Lib/n_stat.idx b/Lib/n_stat.idx new file mode 100644 index 000000000..41933c8f2 --- /dev/null +++ b/Lib/n_stat.idx @@ -0,0 +1 @@ +nimTitle n_stat n_stat.html module src/pylib/Lib/n_stat 0 diff --git a/Lib/n_string.html b/Lib/n_string.html new file mode 100644 index 000000000..945efcea3 --- /dev/null +++ b/Lib/n_string.html @@ -0,0 +1,231 @@ + + + + + + + +src/pylib/Lib/n_string + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/n_string

+
+ +
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
func capwords(a: string): string {....raises: [], tags: [], forbids: [].}
+
+ +

Mimics Python string.capwords(s) -> str:

+

Runs of whitespace characters are replaced by a single space and leading and trailing whitespace are removed.

+ + Source   +Edit   + +
+
+
+
func capwords(a: string; sep: string): string {....raises: [], tags: [],
+    forbids: [].}
+
+ +

Mimics Python string.capwords(s, sep) -> str:

+

Split the argument into words using split, capitalize each word using capitalize, and join the capitalized words using join. sep is used to split and join the words.

+ + Source   +Edit   + +
+
+ +
+
+
+
proc get_identifiers(templ: Template): seq[string] {....raises: [Exception],
+    tags: [RootEffect], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Macros

+
+
+
+
macro safe_substitute(templ: Template; kws: varargs[untyped]): string
+
+ + + Source   +Edit   + +
+
+
+
macro safe_substitute(templ: Template; mapping: Table; kws: varargs[untyped]): string
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
macro substitute(templ: Template; kws: varargs[untyped]): string
+
+ + + Source   +Edit   + +
+
+
+
macro substitute(templ: Template; mapping: Table; kws: varargs[untyped]): string
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ + +
+
+ + +
+
+ + + diff --git a/Lib/n_string.idx b/Lib/n_string.idx new file mode 100644 index 000000000..5110de731 --- /dev/null +++ b/Lib/n_string.idx @@ -0,0 +1,11 @@ +nimTitle n_string n_string.html module src/pylib/Lib/n_string 0 +nim capwords n_string.html#capwords,string proc capwords(a: string): string 4 +nim capwords n_string.html#capwords,string,string proc capwords(a: string; sep: string): string 15 +nim substitute n_string.html#substitute.m,Template,varargs[untyped] macro substitute(templ: Template; kws: varargs[untyped]): string 61 +nim substitute n_string.html#substitute.m,Template,Table,varargs[untyped] macro substitute(templ: Template; mapping: Table; kws: varargs[untyped]): string 19 +nim safe_substitute n_string.html#safe_substitute.m,Template,varargs[untyped] macro safe_substitute(templ: Template; kws: varargs[untyped]): string 61 +nim safe_substitute n_string.html#safe_substitute.m,Template,Table,varargs[untyped] macro safe_substitute(templ: Template; mapping: Table; kws: varargs[untyped]): string 20 +nim get_identifiers n_string.html#get_identifiers,Template proc get_identifiers(templ: Template): seq[string] 22 +nimgrp capwords n_string.html#capwords-procs-all proc 4 +nimgrp safesubstitute n_string.html#safe_substitute-macros-all macro 20 +nimgrp substitute n_string.html#substitute-macros-all macro 19 diff --git a/Lib/n_sys.html b/Lib/n_sys.html new file mode 100644 index 000000000..22aed8e8a --- /dev/null +++ b/Lib/n_sys.html @@ -0,0 +1,278 @@ + + + + + + + +src/pylib/Lib/n_sys + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/n_sys

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Vars

+
+
+
argv: seq[string]
+
+ + + Source   +Edit   + +
+
+
+
orig_argv = newSeqOfCap(argc)
+
+ + + .. hint:: rely on paramCount<https://nim-lang.org/docs/cmdline.html#paramCount>_ and paramStr<https://nim-lang.org/docs/cmdline.html#paramStr%2Cint>_. See their document for availability. + Source   +Edit   + +
+
+ +
+
+
+

Consts

+
+
+
byteorder = "little"
+
+ + + Source   +Edit   + +
+
+ +
+
hexversion = 51577072
+
+ + + Source   +Edit   + +
+
+
+
implementation = ("pynim", (0, 9, 11, "alpha", 0), 51577072,
+                  (val: "", has: false))
+
+ + + Source   +Edit   + +
+
+
+
maxsize = 9223372036854775807'i64
+
+ + + Source   +Edit   + +
+
+
+
platform = "linux"
+
+ +
Note: +the value is standalone for bare system
+

and haiku/netbsd appended with major version instead of "unknown". In short, this won't be "unknown" as Python does.

+ + Source   +Edit   + +
+
+
+
version = "3.13.0"
+
+ + + Source   +Edit   + +
+
+
+
version_info = (major: 3, minor: 13, patch: 0, releaselevel: "final", serial: 0)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Templates

+
+
+
+
template executable(): string
+
+ + returns:
  • when nimscript, path of Nim;
  • +
  • when JavaScript:
    • on browser: empty string
    • +
    • on NodeJS/Deno: executable path of Node/Deno
    • +
    +
  • +
  • otherwise, it's the path of current app/exe.
  • +
+ + Source   +Edit   + +
+
+ +
+ +
+
+ + +
+
+ + +
+
+ + + diff --git a/Lib/n_sys.idx b/Lib/n_sys.idx new file mode 100644 index 000000000..38111ae4a --- /dev/null +++ b/Lib/n_sys.idx @@ -0,0 +1,12 @@ +nimTitle n_sys n_sys.html module src/pylib/Lib/n_sys 0 +nim platform n_sys.html#platform const platform 58 +nim version_info n_sys.html#version_info const version_info 33 +nim implementation n_sys.html#implementation const implementation 47 +nim version n_sys.html#version const version 53 +nim hexversion n_sys.html#hexversion const hexversion 54 +nim maxsize n_sys.html#maxsize const maxsize 56 +nim byteorder n_sys.html#byteorder const byteorder 57 +nim copyright n_sys.html#copyright const copyright 58 +nim orig_argv n_sys.html#orig_argv var orig_argv 34 +nim argv n_sys.html#argv var argv 39 +nim executable n_sys.html#executable.t template executable(): string 61 diff --git a/Lib/n_tempfile.html b/Lib/n_tempfile.html new file mode 100644 index 000000000..81fd7d7d5 --- /dev/null +++ b/Lib/n_tempfile.html @@ -0,0 +1,601 @@ + + + + + + + +src/pylib/Lib/n_tempfile + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/n_tempfile

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

XXX: FIXED-NIM-BUG: though nimAllowNonVarDestructor is defined at least since 2.0.6, it still cannot be compiled till about 2.1.1

+
+

Imports

+
+ n_os, oserr, io +
+
+
+

Types

+
+
+
TemporaryDirectoryWrapper = object
+  name*: string
+
+ + + Source   +Edit   + +
+
+
+
TemporaryFileCloser[IO] = ref object
+  file*: IO
+  name*: string
+
+ + + Source   +Edit   + +
+
+
+
TemporaryFileWrapper[IO] = object
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Vars

+
+
+
tempdir {.threadvar.}: string
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Consts

+
+
+
templ = "tmp"
+
+ + + Source   +Edit   + +
+
+
+
TMP_MAX = 10000
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
proc `=destroy`(self: TemporaryDirectoryWrapper) {....raises: [],
+    tags: [WriteDirEffect, ReadDirEffect], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc cleanup(self: TemporaryDirectoryWrapper) {....raises: [PyOSError],
+    tags: [WriteDirEffect, ReadDirEffect], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc close(self: TemporaryDirectoryWrapper) {....raises: [],
+    tags: [WriteDirEffect, ReadDirEffect], forbids: [].}
+
+ + used to be called in with stmt (Python's doesn't have this) + Source   +Edit   + +
+
+
+
proc close(t: TemporaryFileWrapper)
+
+ + + Source   +Edit   + +
+
+
+
proc close[IO](self: TemporaryFileCloser[IO]; unlink = os.removeFile)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc flush[IO](self: TemporaryFileWrapper[IO])
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc gettempdir(): string {....raises: [ValueError, OSError, NotImplementedError,
+                                     FileNotFoundError], tags: [ReadEnvEffect],
+                            forbids: [].}
+
+ + XXX: TODO: gettempdir() should be considered os.fsencode/fsdecode? + Source   +Edit   + +
+
+ +
+
+
+
proc gettempprefix(): string {....raises: [], tags: [], forbids: [].}
+
+ + Return the default prefix string used by mktemp(). This is 'tmp' on most systems.] + Source   +Edit   + +
+
+ +
+
+
+
proc mkdtemp(suffix = sNone; prefix = sNone; dir = sNone): string {....raises: [
+    ValueError, OSError, NotImplementedError, FileNotFoundError, Exception],
+    tags: [ReadEnvEffect, RootEffect], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc mktemp(suffix = ""; prefix = templ; dir = ""): string {.
+    ...raises: [Exception, FileNotFoundError], tags: [RootEffect], forbids: [].}
+
+ + User-callable function to return a unique temporary file/dir name. The file/dir is not created. + Source   +Edit   + +
+
+ +
+
+
+
proc TemporaryDirectory(suffix = sNone; prefix = sNone; dir = sNone;
+                        ignore_cleanup_errors = False; delete = True): TemporaryDirectoryWrapper {....raises: [
+    ValueError, OSError, NotImplementedError, FileNotFoundError, Exception,
+    IOError], tags: [ReadEnvEffect, RootEffect, WriteDirEffect, ReadDirEffect],
+    forbids: [].}
+
+ + +

Example:

+
import std/os
+let d = TemporaryDirectory()
+assert dirExists d.name
+d.cleanup()
+assert not dirExists d.name
+ Source   +Edit   + +
+
+ +
+ +
+
+
+

Converters

+
+
+
+
converter sToOpt(s: string): SOption {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template name(self: TemporaryFileWrapper): string
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template NamedTemporaryFile(mode: static[string | char] = "w+b"; buffering = -1;
+                            encoding = DefEncoding; newline = DefNewLine;
+                            suffix = sNone; prefix = sNone; dir = sNone;
+                            delete = True; errors = DefErrors): TemporaryFileWrapper
+
+ + +

Example:

+
var tempf = NamedTemporaryFile("w+t")
+let msg = "test"
+tempf.write(msg)
+tempf.flush()
+tempf.seek(0)
+let s = tempf.read()
+assert s == msg
+
+import std/os
+assert fileExists tempf.name
+tempf.close()
+assert not fileExists tempf.name
+ Source   +Edit   + +
+
+ +
+
+
+
template read[IO](self: TemporaryFileWrapper[IO];
+                  args`gensym17: varargs[typed]): untyped
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template readline[IO](self: TemporaryFileWrapper[IO];
+                      args`gensym18: varargs[typed]): untyped
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template seek[IO](self: TemporaryFileWrapper[IO];
+                  args`gensym19: varargs[typed]): untyped
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template tell[IO](self: TemporaryFileWrapper[IO];
+                  args`gensym20: varargs[typed]): untyped
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template write[IO](self: TemporaryFileWrapper[IO];
+                   args`gensym16: varargs[typed]): untyped
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/n_time.html b/Lib/n_time.html new file mode 100644 index 000000000..f75c110e7 --- /dev/null +++ b/Lib/n_time.html @@ -0,0 +1,296 @@ + + + + + + + +src/pylib/Lib/n_time + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/n_time

+
+ +
+ Source   +Edit   + +
+ +

+

time for Nim

the only difference with Python's is where some types in time is str, there is string in n_time's.

+

e.g. n_time.ctime() returns a string

+ +

py diff

Currently, tm_name is either "LOCAL" or "Etc/UTC", due to std/times only returning those two.

+
Warning: +A few of the format directives for strftime/strptime are not supported, and using them causes AssertDefect. They are listed in nstrfptime.NotImplDirectives
+
Hint: +Some directives (only for strftime) whose implementents are platform-depend in CPython are always supported here: '%V' '%G' '%g'
+

+ +
+

Consts

+
+
+
DefaultTimeFormat = "%a %b %d %H:%M:%S %Y"
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
proc asctime(): string {....raises: [], tags: [TimeEffect], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func asctime(t: struct_time): string {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func asctime(tup: struct_time_tuple): typeof(asctime do:
+  bind struct_time
+  struct_time(tm_year: 1900, tm_mon: 1, tm_mday: 1, tm_yday: 1, tm_isdst: -1)) {.
+    ...raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func asctime(tup: struct_time_tuple10): typeof(asctime do:
+  bind struct_time
+  struct_time(tm_year: 1900, tm_mon: 1, tm_mday: 1, tm_yday: 1, tm_isdst: -1)) {.
+    ...raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func asctime(tup: struct_time_tuple11): typeof(asctime do:
+  bind struct_time
+  struct_time(tm_year: 1900, tm_mon: 1, tm_mday: 1, tm_yday: 1, tm_isdst: -1)) {.
+    ...raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc ctime(): string {....raises: [], tags: [TimeEffect], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc ctime(secs: float | int64): string
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc strftime(format: string): string {....raises: [], tags: [TimeEffect],
+                                        forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc strptime(s: string): struct_time {....raises: [ValueError, TimeParseError,
+    TimeFormatParseError], tags: [TimeEffect], forbids: [].}
+
+ +
Warning: +In current implementation, whitespace in format string means itself AS-IS, unlike C or Python, where any whitespace means a serial of any whitespaces. If really wanting the behavior of C's, consider using std/strscan.
+
Warning: +Current strptime is just locale-unaware, when it comes to "the locale's format", like "%x", it always uses the format of "C" locale, no matter what the locale is. a.k.a. Changing locale via C's api in <locale.h> doesn't affect this function.
+ + Source   +Edit   + +
+
+ +
+ +
+
+ + +
+
+ + +
+
+ + + diff --git a/Lib/n_time.idx b/Lib/n_time.idx new file mode 100644 index 000000000..595e9284e --- /dev/null +++ b/Lib/n_time.idx @@ -0,0 +1,15 @@ +nimTitle n_time n_time.html module src/pylib/Lib/n_time 0 +nim DefaultTimeFormat n_time.html#DefaultTimeFormat const DefaultTimeFormat 42 +nim asctime n_time.html#asctime proc asctime(): string 44 +nim asctime n_time.html#asctime,struct_time proc asctime(t: struct_time): string 45 +nim asctime n_time.html#asctime,struct_time_tuple proc asctime(tup: struct_time_tuple): typeof(asctime do:\n bind struct_time\n struct_time(tm_year: 1900, tm_mon: 1, tm_mday: 1, tm_yday: 1, tm_isdst: -1)) 18 +nim asctime n_time.html#asctime,struct_time_tuple10 proc asctime(tup: struct_time_tuple10): typeof(asctime do:\n bind struct_time\n struct_time(tm_year: 1900, tm_mon: 1, tm_mday: 1, tm_yday: 1, tm_isdst: -1)) 19 +nim asctime n_time.html#asctime,struct_time_tuple11 proc asctime(tup: struct_time_tuple11): typeof(asctime do:\n bind struct_time\n struct_time(tm_year: 1900, tm_mon: 1, tm_mday: 1, tm_yday: 1, tm_isdst: -1)) 53 +nim ctime n_time.html#ctime proc ctime(): string 55 +nim ctime n_time.html#ctime_2 proc ctime(secs: float | int64): string 57 +nim strftime n_time.html#strftime,string proc strftime(format: string): string 60 +nim strptime n_time.html#strptime,string proc strptime(s: string): struct_time 63 +nimgrp asctime n_time.html#asctime-procs-all proc 44 +nimgrp ctime n_time.html#ctime-procs-all proc 55 +heading time for Nim n_time.html#time-for-nim time for Nim 0 +heading py diff n_time.html#time-for-nim-py-diff py diff 0 diff --git a/Lib/n_timeit.html b/Lib/n_timeit.html new file mode 100644 index 000000000..1022fccf2 --- /dev/null +++ b/Lib/n_timeit.html @@ -0,0 +1,384 @@ + + + + + + + +src/pylib/Lib/n_timeit + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/n_timeit

+
+ +
+ Source   +Edit   + +
+ +

n_timeit: timeit for Nim.

+

see Lib/timeit for python compatiable APIs

+

+
+

Types

+
+
+
NullaryFunc = concept self
+    self()
+
+ + Callable[[], Any] + Source   +Edit   + +
+
+
+
TimeitParam = string | NullaryFunc
+
+ + + Source   +Edit   + +
+
+
+
Timer = ref object
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Vars

+
+
+
default_timer = default_timer_defval
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Consts

+
+
+
default_number = 1000000
+
+ + + Source   +Edit   + +
+
+
+
default_repeat = 5
+
+ + since python 3.7: default value of repeat parameter is changed from 3 to 5. + Source   +Edit   + +
+
+
+
NullStmt = "discard"
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
proc newTimer(stmt: TimeitParam = NullStmt; setup: TimeitParam = NullStmt;
+              timer = default_timer; number = default_number): Timer
+
+ + + Source   +Edit   + +
+
+ +
+ + +
+
+
+

Templates

+
+
+
+
template autorange(self: Timer;
+                   callable: proc (number: int; time_taken: float) = nil): (int,
+    float)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template repeat(self: Timer; repeat = default_repeat; number = default_number): seq[
+    float]
+
+ + + Source   +Edit   + +
+
+
+
template repeat(stmt: TimeitParam = NullStmt; setup: TimeitParam = NullStmt;
+                timer = default_timer; repeat = default_repeat;
+                number = default_number): seq[float]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template timeit(repetitions: int; statements: untyped)
+
+ +

EXT. unstable.

+

returns nothing but send output to stdout.

+

output shows more information than Pythons.

+ +

Example:

+
var i = 0
+timeit(10):
+  i.inc
+assert i == 10
+ Source   +Edit   + +
+
+
+
template timeit(self: Timer; number = default_number): float
+
+ + + Source   +Edit   + +
+
+
+
template timeit(stmt: TimeitParam = NullStmt; setup: TimeitParam = NullStmt;
+                timer = default_timer; number = default_number): float
+
+ +

timeit(stmt, setup, number=1000000) with globals is globals()|locals()

+

stmt, setup are Callable or str literal

+ +

Example:

+
discard timeit("i.inc", "var i = 0")
+assert i != 0
+
+proc f() = discard
+discard timeit(f)
+proc retf(): int = 1
+discard timeit(retf)
+ Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/ncodec.html b/Lib/ncodec.html new file mode 100644 index 000000000..51e38a021 --- /dev/null +++ b/Lib/ncodec.html @@ -0,0 +1,221 @@ + + + + + + + +src/pylib/Lib/ncodec + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/ncodec

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

EXT. Nim's codec. not the same as Python's codec

+ +
+

Types

+
+
+
EncErrors {.pure.} = enum
+  strict,                   ## - raise a ValueError error (or a subclass)
+  ignore,                   ## - ignore the character and continue with the next
+  replace,                  ## - replace with a suitable replacement character;
+                             ## Python will use the official U+FFFD REPLACEMENT
+                             ## CHARACTER for the builtin Unicode codecs on
+                             ## decoding and "?" on encoding.
+  surrogateescape,          ## - replace with private code points U+DCnn.
+  xmlcharrefreplace,        ## - Replace with the appropriate XML
+                             ##   character reference (only for encoding).
+  backslashreplace,         ## - Replace with backslashed escape sequences.
+  namereplace                ## - Replace with \N{...} escape sequences
+                             ##   (only for encoding).
+
+ + + Source   +Edit   + +
+
+
+
NCodecInfo = object
+  name*: string
+  errors*: string
+  encode*, decode*: EncoderCvt
+  close*: EncoderClose
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Consts

+
+
+
DefErrors = "strict"
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
func initNCodecInfo(encoding: string; errors = DefErrors): NCodecInfo {.
+    ...raises: [LookupError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Exports

+
+ LookupError +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/ncodec.idx b/Lib/ncodec.idx new file mode 100644 index 000000000..e6208ec3c --- /dev/null +++ b/Lib/ncodec.idx @@ -0,0 +1,5 @@ +nimTitle ncodec ncodec.html module src/pylib/Lib/ncodec 0 +nim EncErrors ncodec.html#EncErrors enum EncErrors 10 +nim NCodecInfo ncodec.html#NCodecInfo object NCodecInfo 28 +nim DefErrors ncodec.html#DefErrors const DefErrors 35 +nim initNCodecInfo ncodec.html#initNCodecInfo,string proc initNCodecInfo(encoding: string; errors = DefErrors): NCodecInfo 56 diff --git a/Lib/nimdoc.out.css b/Lib/nimdoc.out.css new file mode 100644 index 000000000..d50f766ed --- /dev/null +++ b/Lib/nimdoc.out.css @@ -0,0 +1,1035 @@ +/* +Stylesheet for use with Docutils/rst2html. + +See http://docutils.sf.net/docs/howto/html-stylesheets.html for how to +customize this style sheet. + +Modified from Chad Skeeters' rst2html-style +https://bitbucket.org/cskeeters/rst2html-style/ + +Modified by Boyd Greenfield and narimiran +*/ + +:root { + --primary-background: #fff; + --secondary-background: ghostwhite; + --third-background: #e8e8e8; + --info-background: #50c050; + --warning-background: #c0a000; + --error-background: #e04040; + --border: #dde; + --text: #222; + --anchor: #07b; + --anchor-focus: #607c9f; + --input-focus: #1fa0eb; + --strong: #3c3c3c; + --hint: #9A9A9A; + --nim-sprite-base64: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAN4AAAA9CAYAAADCt9ebAAAACXBIWXMAAAsTAAALEwEAmpwYAAAFFmlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgNS42LWMxNDggNzkuMTY0MDM2LCAyMDE5LzA4LzEzLTAxOjA2OjU3ICAgICAgICAiPiA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPiA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtbG5zOmRjPSJodHRwOi8vcHVybC5vcmcvZGMvZWxlbWVudHMvMS4xLyIgeG1sbnM6cGhvdG9zaG9wPSJodHRwOi8vbnMuYWRvYmUuY29tL3Bob3Rvc2hvcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RFdnQ9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZUV2ZW50IyIgeG1wOkNyZWF0b3JUb29sPSJBZG9iZSBQaG90b3Nob3AgMjEuMCAoV2luZG93cykiIHhtcDpDcmVhdGVEYXRlPSIyMDE5LTEyLTAzVDAxOjAzOjQ4KzAxOjAwIiB4bXA6TW9kaWZ5RGF0ZT0iMjAxOS0xMi0wM1QwMjoyODo0MSswMTowMCIgeG1wOk1ldGFkYXRhRGF0ZT0iMjAxOS0xMi0wM1QwMjoyODo0MSswMTowMCIgZGM6Zm9ybWF0PSJpbWFnZS9wbmciIHBob3Rvc2hvcDpDb2xvck1vZGU9IjMiIHBob3Rvc2hvcDpJQ0NQcm9maWxlPSJzUkdCIElFQzYxOTY2LTIuMSIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDozMzM0ZjAxYS0yMDExLWE1NGQtOTVjNy1iOTgxMDFlMDFhMmEiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6MzMzNGYwMWEtMjAxMS1hNTRkLTk1YzctYjk4MTAxZTAxYTJhIiB4bXBNTTpPcmlnaW5hbERvY3VtZW50SUQ9InhtcC5kaWQ6MzMzNGYwMWEtMjAxMS1hNTRkLTk1YzctYjk4MTAxZTAxYTJhIj4gPHhtcE1NOkhpc3Rvcnk+IDxyZGY6U2VxPiA8cmRmOmxpIHN0RXZ0OmFjdGlvbj0iY3JlYXRlZCIgc3RFdnQ6aW5zdGFuY2VJRD0ieG1wLmlpZDozMzM0ZjAxYS0yMDExLWE1NGQtOTVjNy1iOTgxMDFlMDFhMmEiIHN0RXZ0OndoZW49IjIwMTktMTItMDNUMDE6MDM6NDgrMDE6MDAiIHN0RXZ0OnNvZnR3YXJlQWdlbnQ9IkFkb2JlIFBob3Rvc2hvcCAyMS4wIChXaW5kb3dzKSIvPiA8L3JkZjpTZXE+IDwveG1wTU06SGlzdG9yeT4gPC9yZGY6RGVzY3JpcHRpb24+IDwvcmRmOlJERj4gPC94OnhtcG1ldGE+IDw/eHBhY2tldCBlbmQ9InIiPz4PsixkAAAJ5klEQVR4nO2dfbBUZR3HP3vvxVD0zo0ACXxBuQMoQjJ1DfMl0NIhNcuSZqQhfGt6UWtK06xJexkrmywVRTQlHCIdtclC0zBJvYIvvEUgZpc3XyC7RVbKlQu1/fHdbc+uu2fPOfs85+y55/nMnBl2z+5zfnc5v/M8z+8119XVRYroAG4HfgvMT1YUR4MMAa4HLkhakCRoSVqAELwLeBY4C7gF+D6QS1QiR1ROAJ4Dzk9akKQwoXhtwL4GxvHjU8AKoNPz3leAu4HBFq+bAyZZHD9rDAK+BywDDklYlkQxoXhfAtYAEw2MVckQYBHwU6or99nA08BBFq49GngUeBIYaWH8rNEJdAOXA60Jy5I4jSreSOBKYDzwBPCJhiUqcSjwe2BWnc9NLnxuvMFrnwqsAqYBBwBfNzh2FpmNfs9jkhakWcg1aFxZiH5UL3cDnwf+Xue7BwFjgFHAOwuv24tyob3cO0LIshP4EbCn8Pq/wKvA9sLxMvCvOmPsA1yDZnHv/nEv2mM+F0IeR4m8z7lM7tMbUbzj0CxX7YfbAXwaWFJ4PRrNIu9FS9KJyEIZN68CG4DnkRJtLBw7gHHAYuDdNb77EDAjBhkHIk7xKoiqeK3IwjilzuceQJvoZjdQ/AMZaeoZiWYgBXSEwyleBW0Rv3cR9ZUO4LSI48fN2wN+bi5wJNBvUZaBSCaVy48oxpVhwDdMC5ISxpJRh6/DLGEUrxXt29YBQ+2IkwquR76ofZIWxJFegireNLSnm48skFmmDfmiVgJHJyuKI620ADOpbWEcDPwYOZKD7OmyxCTkXL+wzueOiEEWR8poQb60V4A7kLm/yFjgKeALuM1xLfYDbkX+zEGe98cAX0Oui6viF8vR7OS6urragW2UZr21wK+Aiwlu7XPoN3sYOAd4H6WH1SnA0qSEcjQnRT/e1bgnsw16kGPez4/lyCBF48oNwL+TFGSAsgCndI4qFBVvJ0owdZhjL3CnxfHzBo8+YBMyol0CHBijrKbHS/LoA7Yio9sPgJNr/QHekLGR6MffL+KP4SjnHmQxtoXNmbQP+CHyV75hYDzTIWNpWkU8iR5mq71vVsZqXgtcFqNQ/wG2IOtfD8oi6AX+Ujj+isKz8sBrnu+1okyGdmD/wnEgcDClTIdRyJRvI1cvCMciq7At4rj5eoCPAusbHCfLigda/VyKgi+AtyreMGAzykGzQQ/wO+BxSlkCuy1dq8hw5OieUjimYT+x9bHCdWwS1823Ez1EXmhgjKwrXpHzkduuanbCtzGX+NkPPAj8GincNkPjNkIO5dadUjiOB95m+BonopQpm8R58/0JJbHWy2eshVM8sRvdbyurKV4Hmoka2WA/iwwLP6d+QmzSdKC92GzK/W9R+Q3woQbHCELcN991wJcjftcpXolngKm18vFmoVonYcgDv0Qz5pqGREuOTuA8lPYUZbndh0LJNpkUqgZx33xvomim7RG+6xSvnOm1gqQXoyiMoKxFs8VZpFfpQHvQK4HDUPnAsBa9bxGP0tUjF+IYCkxFew+/G3owdq20pgjzt3uPRscs/o43IaOhH2f4ZaAPRyZQP6vgbuCbyGext87F0sgIZFI/N8BnlwBnolovcWAjq/uzwM0+55cBJ0UYN84ZL+rfbnLMM4FfUDv7Z1XlCe8FetETbleNL7+CZrnvMjCVDuTOOA84Hf+96ga0PC8qXY50FQsuMg+41+d8p885R4n7gdt8zo+qvDkmUF4fZQXwEbS+99KDMhlWkw0eALqQglXyDDCdcovf+4lv5jPNXJ9zWc/FDMMdPudGVCreRlTWwVtWbynwYVQQCFSp61Q042WJLUjB1nneuw8tvXo97x1Lugvg+j1Mo9boySLVHtJFWqsthx5GlbSGeN5bigrHdqPl52Zj4qWLXvTQWY4KOX2ccgPMBLRcuy9+0YzhguXN4GuYq2Zc2R/NZg+hfYt3/9ZCepdQthmB4vIWIYOTbWyWzGt2Y0izG1fqjlltxnsdpbPMRMmd3lqTTumqMw7FZY5G5mSHw5dalreiRWYGWjbZ7gYUlFa0xOtIWA4vk1E6zWEoI+FvyYrjSAO1FG8DCmQGKd+DJFsGogWVVFiP/GWbga9Svg9NgtPQvnd04fUNCcriSBF+vqZ5nn9PQ+Xs4q401oI6EP0R+BkyXoAeAtcgBfwidnvkVaMVFTO6n1JoWTfqiONw1MVP8e6l3GVwOPJZXW5VItGGiuduAu5CZdOrMQJ1CHqpIFccS+LxaD/3Hcr7vF0Xw7UdAwQ/xduLGkJ6aUMhVAuwU006B3wM+ZLmozJ5QRhWkGs9yjKw1fhwDsq8eE/F+y+i1CeHIxD1wppupXrA5xyUOjQHMzU3cyjTeS2aaaN2Fzoc1bhch3xspuqBTkDulQVUz1q4mYEbNuewQD3FexGFS1VjOLoRHwOOinj9HAooXY2CSidHHKeSI5GFcRWNdSxqR7VH1iHHeTV24R+X53C8hSCBvPPqnD8B+AOygn6OYAm0ORSGthLl8B0d4DtRmIKsoMsJF1U/Hi1dt6DusIN8PrsIlUdwOAITpDFlC6q3MTbgmHm011qGepOvQSXPipyOCujW6rxqk0dRWYsVFe8PRSn5JxWOoEvdfOGzfnF5tnCRK+bGi33MoB1hL0U5d1H5J5oVD6A5mp8sQS6KSWh5e0jEcR4BPmhKqJA4xTM3XuxjBlW8DuRacDU3y0myNbNTPHPjxT5m0GTN15A/zVFiI+HKYzgc/ydMlrRfgmQWuYn0F91xJEQYxVuDnMcOrQAWJi2EI72ErQviwqLEQpQ+5XBEIqzi3YWLwF+BMiMcjshEqYR1Gdk1KmxBsaR9SQviSDdRFK8fxVU+YliWZmcbcq7vSFoQR/qJWvuxD0WgLDYoSzPzAqowtjVhORwDhEaKru4GPoliGgcyy4Hj0DLT4TBCo9WO88jQ8Bns97lLghvRTOfqqDiMYqrM+HyUYdBtaLykeRmlK12C9rQOh1FM1vd/HqUIzaT5e+LVoh/VxByHShs6HFaw0VjjHhTxP5d0LT+fRnu5q3HuAodlbHW02Q5cDByM+sw1642cRylCx6PeZiuTFScUFxK+f19QovaRS+t4tsasxhvABbZbSfUCV6CM7qtQl6Fm4E1U22UqcAYqvZ42fgJMxH6vdYc5nkBlSW6Pq4fbS6hb6jg0u9yGug7FyS5U1+UcVBbwbFSuMM1sQ1bXK4A9CcviqM0e9H80HdUxCpwIa4McygA/GfgAcCJqmGKKXUixupEv7nHsLc2agWNQ0d9OzC+PHNHIo1XeLCoe8kkqXiUtwKFoWXoEKqk3BpWLaC8cXsV8HT1J+tFTZKvn+DMqFZi1knvtyKg1O2lBHADcCVxEedNSAP4HJcsr0NNWHVUAAAAASUVORK5CYII="); + + --keyword: #5e8f60; + --identifier: #222; + --comment: #484a86; + --operator: #155da4; + --punctuation: black; + --other: black; + --escapeSequence: #c4891b; + --number: #252dbe; + --literal: #a4255b; + --program: #6060c0; + --option: #508000; + --raw-data: #a4255b; + + --clipboard-image-normal: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' style='color: black' fill='none' viewBox='0 0 24 24' stroke='currentColor'%3E %3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2' /%3E %3C/svg%3E"); + --clipboard-image-selected: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' style='color: black' viewBox='0 0 20 20' fill='currentColor'%3E %3Cpath d='M8 3a1 1 0 011-1h2a1 1 0 110 2H9a1 1 0 01-1-1z' /%3E %3Cpath d='M6 3a2 2 0 00-2 2v11a2 2 0 002 2h8a2 2 0 002-2V5a2 2 0 00-2-2 3 3 0 01-3 3H9a3 3 0 01-3-3z' /%3E %3C/svg%3E"); + --clipboard-image: var(--clipboard-image-normal) +} + +[data-theme="dark"] { + --primary-background: #171921; + --secondary-background: #1e202a; + --third-background: #2b2e3b; + --info-background: #008000; + --warning-background: #807000; + --error-background: #c03000; + --border: #0e1014; + --text: #fff; + --anchor: #8be9fd; + --anchor-focus: #8be9fd; + --input-focus: #8be9fd; + --strong: #bd93f9; + --hint: #7A7C85; + --nim-sprite-base64: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAARMAAABMCAYAAABOBlMuAAAACXBIWXMAAAsTAAALEwEAmpwYAAAFFmlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgNS42LWMxNDggNzkuMTY0MDM2LCAyMDE5LzA4LzEzLTAxOjA2OjU3ICAgICAgICAiPiA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPiA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtbG5zOmRjPSJodHRwOi8vcHVybC5vcmcvZGMvZWxlbWVudHMvMS4xLyIgeG1sbnM6cGhvdG9zaG9wPSJodHRwOi8vbnMuYWRvYmUuY29tL3Bob3Rvc2hvcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RFdnQ9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZUV2ZW50IyIgeG1wOkNyZWF0b3JUb29sPSJBZG9iZSBQaG90b3Nob3AgMjEuMCAoV2luZG93cykiIHhtcDpDcmVhdGVEYXRlPSIyMDE5LTEyLTAzVDAxOjE4OjIyKzAxOjAwIiB4bXA6TW9kaWZ5RGF0ZT0iMjAxOS0xMi0wM1QwMToyMDoxMCswMTowMCIgeG1wOk1ldGFkYXRhRGF0ZT0iMjAxOS0xMi0wM1QwMToyMDoxMCswMTowMCIgZGM6Zm9ybWF0PSJpbWFnZS9wbmciIHBob3Rvc2hvcDpDb2xvck1vZGU9IjMiIHBob3Rvc2hvcDpJQ0NQcm9maWxlPSJzUkdCIElFQzYxOTY2LTIuMSIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDplZGViMzU3MC1iNmZjLWQyNDQtYTExZi0yMjc5YmY4NDNhYTAiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6ZWRlYjM1NzAtYjZmYy1kMjQ0LWExMWYtMjI3OWJmODQzYWEwIiB4bXBNTTpPcmlnaW5hbERvY3VtZW50SUQ9InhtcC5kaWQ6ZWRlYjM1NzAtYjZmYy1kMjQ0LWExMWYtMjI3OWJmODQzYWEwIj4gPHhtcE1NOkhpc3Rvcnk+IDxyZGY6U2VxPiA8cmRmOmxpIHN0RXZ0OmFjdGlvbj0iY3JlYXRlZCIgc3RFdnQ6aW5zdGFuY2VJRD0ieG1wLmlpZDplZGViMzU3MC1iNmZjLWQyNDQtYTExZi0yMjc5YmY4NDNhYTAiIHN0RXZ0OndoZW49IjIwMTktMTItMDNUMDE6MTg6MjIrMDE6MDAiIHN0RXZ0OnNvZnR3YXJlQWdlbnQ9IkFkb2JlIFBob3Rvc2hvcCAyMS4wIChXaW5kb3dzKSIvPiA8L3JkZjpTZXE+IDwveG1wTU06SGlzdG9yeT4gPC9yZGY6RGVzY3JpcHRpb24+IDwvcmRmOlJERj4gPC94OnhtcG1ldGE+IDw/eHBhY2tldCBlbmQ9InIiPz4JZNR8AAAfG0lEQVR4nO2deViTZ7r/7yxkJaxJ2MK+GCBAMCwS1kgUFQSKK4XWWqsz1jpjp3b0tDP1V+eqU391fqfT/mpPPd20drTFDS0KFEVWJSGAEgLIZpAICBJACIRs549Rj1WILAkBfD/XlevySp68z/0S3+/7vPdzLyidTgcLkU2bd+z39/f/q1gshsrKSoJELFCa2iaEuU9K6kb+8uXxv54/fzE8L/eswNT2zCfQpjbAGKS8lPFKSEjIXiaTCSEhIeDj4xNnapsQ5j6rktZGp6UlfxIdzQVzCplmanvmG1hTG2BIAtlc26CgoDfT0tL2e3l5AQCAjY0NkMnk/a9s2k6rrKw8UV8n1JjYTIQ5RlAw14KzmL3xze1vfJyUuMJaq9UCFovFm9qu+YbBxcSPFUYkk8l2Q0NDsvo6ocrQx5+I8Ih4bz6f/0l8fHyKlZXV4/dRKBQwmcwwMpn8A4FAoPgHhH9bV1sxa488wZxoaycnJ/a9e/duCa5fkc3WvAiTI4Ib77p+XdqHG9anbfLy8gAAgLGxMdBpF+bjvzExqJj4scKI0dHRnwQHB++orq7+AgDeMuTxJ2Jl4rqU9PT0EwEBAUQCgTDuGAaDAampqYepVKpHUHDk325Ulw0a266YuFW+Gzdu/MDPz29jfn7+XgA4aOw5ESZP6kvpCXv3vnM8NiaSamVl+fj9BepGNDoGFRN7e/slcXFxO1xcXMDJyWnH7j//H/fi4uJdgutXmgw5z5O8smn7X9euXbvf29sbMBjMhONQKBRYWVlBbGzsbjMzM3JoOG+/sKKwy1h2rd/4elpGRsYuLy+vaDweD2w2Oy1h5ZrCvEunEaeeiVnMiabyl/F2/+X9P+8JDPQHHA5napMWBAYTk6DgSNuEhIS9DAYDAP7tq1i6dOkqOp3OWbNu0wens44emeoxA9lcWwKBYEMkEm2JRKIdHo+3QKFQWJ1Op8ZgMER3d/dVq1evTnFycpr0MSkUCsTExGzH4/Gk1LTME/39/TI0Go1FoVCg1WrVY2NjipGRkcGRkRH5dPwrEZHLXMPCwjJSUlIy3dzcfB+97+rqGhYSEpIOAIiYmBguN3zL77dt3uPh4W5qUxYUBhMTb2/vjeHh4cvR6P/dILK0tITIyEg7BweHr363/Z3Ampqaf1Zcu/zMKiVsyVJvMplsRyKR7IhEor2FhYUbhUJhJCYm2pFIJB6JRAIymQx4PB7QaDRoNBowMzMDJycnwOOn7icjEokQGxu7icFgbLp///7jFY1WqwWlUgkjIyOgUCgO7Ni5Rz48PCwfHh7uGRkZeaBQKOSjo6ODCoVCXlNVKn/6uCsT13FXrVr1emho6BYKhfLMnP7+/omrU9LPX8g+UThloxEMxqJFXjxESAyPQcSEExrLWLNmzW57e/txP/fw8ABHR8cdDAaDt3xF2ru9vb03sVgs0cbGxs/FxWVZUlISj0aj+dna2oKtrS1M5PcwJCgUCry8vODRrs84vPfoH6OjoyCXy6Gvr+/R6+CWrX9s7evrk/b19bWr1Wqli4sLZ8OGDe95eXmxUSjUuAd0cHDwjoqK2sYKXFIhvnldYYTTQpgU4/8+jyASCYDGoCd+ZkYYF8OICYezl8PhuOkbQyAQIDo62s/NzS2np6cHbGxsgEajAYFAAAwGA1gsFia6CE0NgUAABwcHsLe3B61WC2q1eo9WqwWNRgNKpRLUajUQiUSgUCh6zwGHwwGTydzo5+eXBQBnZu8MEJ5keHhYPqyYWMtHR0ZBpVIhYj9FUDONgOUvT12+du3avMDAQJjssdRqNWCxCyrEZdLodDoQi8Ulx44de628NL/V1Pa8iERE8l2dHB2CJvpcq9Nqbt1qKURWj1Njxld0ZGTkAW9v70kLCQC8sEIC8O/HKx8fn2gmk8kHgCk7pRFmzrWyAikASE1tx0Jj2uH0EZHL/N7YtuvT4OBgzmz4OBYSeDweIiMjt2S++vtMP1YYEmmJsCCY8mNOIJtr6+zsHBcZGXmIw+G4mZubG8m0hU9HRwcUFxe/KxQKTyDRsQjznSmJCS9+dVRERMTfQ0NDo2xtbfUGiSFMjtHRUaitrc3Jzc09kHvxVLmp7UFAmC6oZQkvrZLL5RJhReHtiQb5scKIXC7371FRUX90dnYGIpE4JR8Jgn40Gg20t7fXFxYWfnr9+vWjz8sdYi+Osh4vzgUBwZSgtu94V+fs7Hx7YGCgra6u7khLS0u2RCwYeTQgKmYFh8fj/f/g4OAldnZ2prR1wdPd3Q1CofBQSUnJkdLi3N8E93FCY6k+Pj48FxcXjlar1ZSWlh65VvYr4kREmDNg79+/D3FxcW5OTk5uXl5evNbW1tL0jK3ZXV1d1ykUintycvInoaGhdkj+gvGxs7MDPp+/m0AgWMQvS/lyeHhYTqPRPJycnIJSU1NZ3t7eW2g0Gly/fv2oWq1Gij0hzClQ/gHhpLS0tEM8Hm/7I8Ho7++HlpYWsLa2Bg8PDxOb+OKhUCigqakJ7t+/D25ubuDu7g4oFAp0Oh08ePAAvv7666TTWUdzTG0nAsKTYMU3ryuSU18+4+bmFrZo0SIOAICVlRUsXrx4zkakLnRIJBI8CgJ8MtdJp9NBZ2enqL29XWRC8xAQxgUNAHD+3L8KGhoaCp78ABES04JCoX4jJAAAAwMDUFtbe96YpRMQEKbL41DU5ubmko6Ojj2PSgggzD36+/vrb9y4cX425zzw93/8EBjon2is44+NjSkePBjqGRwc7G5v7xBV19w8U5B/3qgrr9+/uWtXUuKKD/TZ9MXh/066/OuFmunO8dGBQ98HBbGSp/t9U6LRaDXK0dHBoeFhuVzeL22/0yFqamopufjLqRJ933ssJi0tLSXV1dWHGAzGbuObOzs8ubqa71vZKpUKOjo6blwpOF8zm/Mu5cVkLlkSaswprAHAaVihgK7O7oSGxltvfXLon3nXK4RHT2cdN4pfKDCAlZyUuMJan02nTmczAaBmunPw4qI3cbnh0/36XICq0+lgcPABp7OrK629vUP5z8++LLh2XXD05L++yxrvC4/F5EZ12WBS8saLS5Ys2U2lUufUY45SqQSlUgkqlQrUavXj19jYGGg0GtBoNKDT6UCn05VotVq1TqfToFAojFar1eh0Og0Wi8XhcDgeGo1+/PhgZmYGOBwOsFgsmJmZ/eY1F+nt7YXa2trs2Z73wdCQBgCMHp1IJpHA09MdPD3dLRIS+OtKisvWvbP7vf2lZdePVFwzbHTwyMiI3hidkZFRUKvUYzOZ48HQkBIA5nWqBAqFAktLC7C0tADmIh88Pz4uMSyUk7hn776DV4tKPn/6d/lNxp1MJqsRCASf8vn8XdMpOjRTVCoVjI2NgUqlAq1WCyMjI9DX1wf379+Hvr6+/Q8ePOgdGRmRKxSKx0WLFAqFXKlUKnQ6nUar1arHq47mxwrD4/F4Eg6HI2GxWDwej7cgkUjWFAqFam5uTjU3N6eRyeQPLSwswNraGqysrIBAIDwWFywW+zja11Qi29LSclIikeSZZPJZBovBAI8XA8HBQR9kZZ3lR8cmvFZSlGe00p8IkwONRkNERBj4+i7a4+XpHv307/IbMakWlciXJbx0nMPh7Jqo0JGh0el0MDo6Cl1dXSCVSkEmk7177969W319fe1DQ0M9KpVKoVarlWq1WjndNhUPG3ApAWDcOxLTLwSDwWAOotFoDBaLxRMIBAsrKysne3t7Xzqd7k2n0/c4OzsDlUoFHA4364IyMDAATU1NxdWikhcq6tXKyhJezljPJZKI2eERS5cZeoWCMD2srCwhPX0tVzk2djiCG//GtfLLUoBxShB0dHTU3Lx580sLC4vtJBLJKMZoNBqQSqUglUqPdnR01PT09DT19/fLHjx40DM0NNQ72933GiSVGgB4JFQK+LfoSAGgnL04yppEIh2xtLS0t7GxcaFSqR7Ozs4fMRgMcHR0nJX8pJs3b54Ui8UXjT7RHIRMIkFK8irfwcEHPwQELUmqvYHUGJkLmJubw8YNa/i9vfffY/px3myQiDTPiEl9nVDDX576jaenZ7SnpyfLUJNrNBqQyWRw+/bt4x0dHTdkMlltV1dXw/XygjkdEv4wB0YOAK0AUM70C8HQ6fSzdDrdm0qlejg6OrLc3Ny2MBiMadWjfR4PHjyAmzdvZs/1v5MxoVAokJK8iicWS95k+nH+s0EiQhqpzQGoVFtYk5a87ba0XQAA34xbpagg/5zoT7s/OGNnZ8eaaYkBuVwOnZ2d5VKpVNTS0lLS2NhYWFVZ3Dujg5qQh6uY+ocvCAiKIPn4+Jz19PSMdnV15VCpVL6Dg4NBViw6nQ5EItHRpqamqzM+2DzHzo4O69amftLQeKsAZrDLgmBY/PyYsCIhfs+SiKUFE5Y8EwqFx11cXDihoaFTjjFAoVAwPDwMHR0dourq6jNCofDHhZqUVnvjmgIAcgAgJyg40mLRokX8kJCQjT4+PussLS1n1JPl7t27UFxcfHguB6mNjY2B7G4naNRTWyygUCjAYDGAx+PB0sICSCSi3vFYLBbCwjjA8vddBQtATKb7d3saBwc7IJPJBpsHjUGDGRYLJBIJLK0sAfucmyIGg4FFi3y8AwNZtycUk5KiS02vvf7WWQaDkejg4DApQwAeh3xDaWnpPoFAcPxFqnP6sEvgGf+A8Bx3d/cvIyIiNi1evHjT8wpNj8fAwACUlZW9P9dD5+/ckcFbf9gd2dcnn9LNAovF4inmZHtXNxdOdBR3+/JlS33pdP29wolEInA4weuiYxOy5vvuTkeHDHb+8c8xvb33Z3R9/N+Df+uIjYk02DwkEsna2trS1d/fNyGeF7uTyw1/7g3R3t4O2OxA/TVghULhcQqFQk1JSfmYSNR/5wD4d6EfgUBwvLS09IhUKhW9qAV5H9YjKQwJi6uvrKw8ERoamhkSEpKp7w7yJEqlEiQSyZmysrJv53qjdaVSCZdyTk+3qFMrAJRHRPLPN95qeifj5fU7mYt8JhyMRqMhMJDFdnF25gDAvBYTpXIMWlpay2fq/8m5mDcIABYGnEcGAGI/VlhBZWX1yZdSkz55OX0dV5+7w9bGGvz8mPrFpK62QskJjf2GTqd7x8bGbpnID4BCoUAmk0lLSkqOiESik2UleS/MakQflYKrXQDQxY1a3tTe3i6KiIjY5OXlxX7e9+rr6wsuXbr0t4ffn9OgMWjghMZQRcLp+8GulRVI/QPC37Wxtnal0ajJtjY2E451ZjiBra31vE9lR2PQQKFQaAAwo98Yi8Xq9fpPd56HO6rlvKWJv/PwcK+JilyCmajWMw6HAzs7+rMFpQOCIn6zHywSFvXm5eUdFAqFZ9Rq9bgHa2trq79w4cK+zz49cAARkmcpL81v/a/Dhz49d+7c3qqqqjyVSjXuOJ1OBxKJpDw3N/fA5V+zax6978cKw/sHhM/raMrnUVdboSy4fPWQSFSjd5yFBQWIRNKEd2IEw1J4JUd88WL+R51d3XrHWVDMnxUTa2tr1zXrNiUGsrmPf7DS4tymCxcu7Kuurs55+kKQSqVN586d23vs+8NHDXUCC5Wzp3/Iy8rKeruysvLM2Nhvo7VVKhXU1tYWnj17du/T7UOdnZ2D7OzsfGGB09raVi4S1RzXl0eFw+EAj8chYjKLVFffyOrq1C8mJBLpWTFRKBRyDofzC4vFWvXk+1ev/CLOzs7eKxAIslQqFeh0Oujp6enKzs7em/XTd7OayTqfKb56sT4rK+sPAoHg5KO/o0KhAKFQmHXy5MkdF3/5+TeZmctXpIXZ29v7zqVcKWNRX1epuXu3U/y8pEw0GmndOZt0dnXVDw0P6/W5oNHoZ30mQ0NDPb29vfvj4+Pf3rR5B/7od188XnEUXr4gDgmL+0NfX5/U19d3d3l5+YGfTnyDtLmcIhXXLsu4UcvfR6PRGGtra9eysrIjYrE45+kt4Fheou/69es/unnz5vm7d+/Wmsre2WRkZGTQ1DYg/JYGiUiTm1ugBAC9IfHPiEmDpFITE7fqJI/H27lmzZpDq5LWtz55t6wUXO3ihMYerK+vz2tpaUFaM0yT8tL81ujYle+TSCTrvEunBU9/voTLd92wYcPHVCqV39XVdXCu7+oYCp1O90Kc50Jk3I5+xVcv1jc3N5d4enpSMzIyvkpK3sh78nORsKg3++yPBS/q1q+hKCm61DSekERGJ3ikp6d/ERsbm1xVVXWwtbX1hRFtFAqFPMLMUyZsDyoQCI7LZDKIiIjwzczM/GpV0vro2TTsRSUqZoX3+vXrP1u9enXi0NAQiESirIdRtggIc5oJ40zq6uryGhoa8ry8vBJCQ0O9USjU94mrN7yWc+EnvaXb5gJMvxCMp6cnl0Kh2Le1tZVXXLs8L1LXefGrWRkZGZ/x+XyeUqkEkUh0vqenZ14HZyG8OEwoJjdrygd37NxTEBkZmWBtbQ3BwcEeKBTq+/UbX3/355Pfzlmn66qk9dGbN29+k8PhbCSRSNDZ2Snb9ae/HCkpKTksEhbN2QTD5NSX+Vu3bj0cHBzsjcFg4O7du1BWVvbNwxB9BIQ5j94I2Fu3bhXW19cDl8sFLBYLHA7Hg0wmf/e77e84ffXlPz6fLSMnQ2paZkJ4eHjmtm3b+B4eHvZkMhlQKBTY29s72dvbfxgUFJT8x7ffP1NRUfHjXErnZ/qFYKKjo7dt3rz5g8DAQPtH/XHa2tpqGhsbC55/BASEuYFeMblz505NTU3NgfDw8PcwGAygUCjw9fW1IJPJn/1130Hv0tLSI4WXL4hny9inYS+Osvbz80tgMpn8jIwMPovFch2vpoiDgwM4ODhwfH19OYsWLeJv3/Hu+cbGxquzXZz5aZYlvMRJT0/fFhkZue3JZmfd3d0gEolOIr4ShPmEXjFpkFRqXlrzSnFnZ+d7Tk5OjzNfXVxcICMjY6ezszNnVdL6vU8HWhmbgKAIkrOzMyc1NTXz0YU4maAuOp0OK1as4EVFRfGEQqHg1dfePHzr1q2rs71S8WOF4f38/BLS09M/iIyM5DxdxLq5uVlcVVU1bgVwBIS5il4xAQCQyWRigUBwJikpKe3JVGQcDgdLly7l2tranti0ecf7IpEoy9hbxX6sMDydTvdevXr1ltjY2F3u7u6AxT73FJ7B3Nwc4uLiwthsdphQKCzZkL7l0/r6+oKbNeVG90+EhMXZL1++fFtycvKHrq6uz4igUqmE5ubmEiTHCWG+8dwrUXD9imz9xtd/jIuLS7N5KpsTjUZDUFCQE4PB+F4oFGYmJW888Mv5k4UTHGpGxC9LYaenp78VEhKyxdHRESgUyoyOh0KhwNraGuLi4qIDAgKi6+rqyjekb/mHMSN6N6RvSdu+ffseNpsdZm09ftuW+vp6EIvFSB9hhHnHpG7rUqm0orW1tdXS0tLj6TIEaDQaaDQaxMfH811dXTl/3Xfw+JUrVz411J01cfWG6IiIiC07d+5McHNzs7ewMGyOFw6HAwcHB6BSqVx3d/fwz7/4rkAgEBwXCoUnHpZonDGrU9J5MTEx27du3Zrm4uKC0beaqq6u/ry+vj7XEPMiIMwmkxKTimuXZe/u+fCkp6fnexPdUfF4PPj7+1szGIydLi4unF1/+kvenTt3RG1tbRXTqfma8lIG39/fP/HVV19NZrFYHpMpzjQTzMzMwNPTE+Pp6Zng6emZ4Ofnl5CesfV8bW1tznQe3/wDwvFeXl7Rvr6+Ca+88kpaUFCQh74GXzqdDrq7u6GpqankRQmdR1hYTNrhUFVVlcXj8d6ysrKy0OfstLS0hPj4eC6Xy+U2NzeDRCI5/sa2XeX37t1rGhwc7BoYGJBN1P+FFbiE5OzszGaxWImvvvrqpoCAAKfp+ERmCpPJBCaTmcnhcDJLS0u/TE59+YxUKhXoi/lg+oVgrKysGJaWlna2trYeaWlpXDabvTMgIGDSfp2KiorzbW1tL0zoPMLCYtJX6uVfs2u++PKowMPDgz+ZIslEIhECAgKAxWJlajSazJ6eHmhra4PW1tZvtmz9o6Czs7O+r6+vfWxsbFir1WosLCzsV6xYkcnj8d7z9vaelmPV0Hh5eYGnp+f2mJiY7UVFRZ/HL0v5tru7+5ZGo1FisVg8Docj4fF4CxsbG1c+nx/m7e39sYeHB7i4uIC5ufmU6r4ODQ1BZWXlifkSrYuA8DRTumIrKytPent78728vCb9HRQKBVgsFhwcHIBOpwObzd4yNja2RaVSwdDQEHR1dcHo6CjQaDRwdXWdsWPV0KBQKPDw8AA7O7udERERO2tra2FgYACoVCo4OTkBjUYDMpkMeDz+8WuqaLVaaGxsbL19+/YzSX8ICPOFqYrJidDQ0AwvLy/e80c/CwaDARKJBI86BdJoNHB3dwe1Wj0nViL6IJPJwGQywdnZGZRKJRAIBDBUx8OBgQEoLS39BtkORpjPTJg1PB61N64pmpqarvb39xvUiLkuJE9CJpPBxsbGYEICANDZ2SlHgtQQ5jtTEhMAgLq6ulyJRFJvDGNeREZGRkAikRSUFuci2cEI85opi0l+7hmBWCzOeV6dToTJcfv27cHr168jxbgR5j1TFhMAgObm5hKZDNl0MAQtLS3Xzpw6hkS8Isx7piUmUqlUIBAIJuyjgzA5Ojs7QSKRINGuCAuCaYmJsKKw68qVK59KJJIu5HFneiiVSigqKjouEolOmtoWBARDMC0xAQC4+MvPJadOnXq3ra1N8yL0dDEkOp0OSktLy/Pz8w8+3d4CAWG+Mm0xAQA4fuy/jl+8ePGju3fvGsqeBY9Wq4XKysrWU6dOvX31yi8mKyyFgGBoZiQmAAD/79D+fadPn96PCMrz0el0UFVV1frtt9+mj9fiAgFhPjNjMQEAyMvLO3Ds2LE/tLS0INmuerh27Vr9999//xoiJAgLEYOEntbVVigB4PNNm3cMpqSkfMRms50McdyFgkqlgqKiovJTp069nZ97BhEShAWJQePYj373xdF1GzbLFQrFx6Ghob766ne8KNy7dw+KiopO5ubmfmTK4tsICMbG4EkxWT99d35l4rre/v7+D0NCQvh0Ot3QU8wL1Go1SKVSTX5+/sH8/PyDSP8bhIWOUTLsLuVklQcFR65pbGzcvnLlyvfc3NwsCASCMaaac+h0OhgaGoLq6uqaCxcu/OV01tGcTw7uM7VZCAhGx2jpug/vxAd58atzoqKitq1cuXKnvb29saabE+h0Oqiurpbm5eUdrK6uPlspuDrvY0hmO4YIhUIBGq1/X2CmNqFQKL3/79HomZ/z82xEowyy9zFr80zGDqPn/hdeviBmL47ad+fOnRsRERGbQkNDo62srIw97azT2dkJxcXFx0tKSo7Mdh8hY4LD4TDPH2U4MFjMc6tLmZmZzaj+Aw6H0/t9PB4PGCxmRudNJBL0ngeZTAI0Gj3jv+1szfM88Hic8cUEAKCmqlQOAN/ELU2qkEgkySwWK3HRokVcBoMxG9MbDZ1OB83NzdDU1FRQW1t7XiAQHJ+ovu18pbr6Rg6L5ZtoM0EhcUPT0tJW8tWRb0vQqIkvgKqqmhnVfrl2TfANXo+gjKlUio4OWc1M5sjOzjnQUH8rbqLPu3t6moaGhmfc+3q25tGHUqmECoEIUKbIrVkcEkONiIh4jcvlvu7s7OxLo9GmVe7QVCgUCujq6oKGhoaCioqKo9XV1WeM3YDMVPDik1gpyas+XrVyeaKXl8czjyANjbcgI/MNmkg49Q4ECPOH3NyC4RUr+M8IcHt7B1y9WlKRl3/5kElKnD1sfXEoJCzueEBAQGJYWFgGk8nk2djYAIFAgLm4pTw6Ogqjo6Mgl8vhxo0b50tLS4/U19fnLvS2FIWXfxEDQNLmLW9ueW1TxtchHDaQyWRTm4VgYkZHR6G+vhF+/NfP+y5e+vVjiVgwZpKVydOwF0dZW1lZOTGZTD6bzU4LCAiIptPp8HTDL1MwOjoKLS0tUFdXd1IsFudIpdKKgYGB7tloJTrX4MUnsVJTEj9etzY10dHRAQAAGm81wcsZW5CVyQInL69gNCGBjwcAGBx8ANnncypOnTr3H9nn/reD55wovvrQpyIHAHFUzIocGo3mQaPRfBwdHVlubm7bXF1dgcFgABqNNvruglwuh7t374JMJoOOjo7P79y5I+ru7m7q7e1tXQi7MzOh8PIv4pCw2DdaWtte37Au7aPIyCWAxWABjUbPif9HCMbjURtKiaQBfvr5zH9evlJ0uLQ4r/nJMXNiZTIRrMAlJAcHB18HBweWo6Mjy8rKajeJRAJLS0uwtLQECwsLoFAogMfjAYvFgpmZ2XNXMyqVCoaHh2FoaAiGh4cfvwYGBqCvrw+6u7vfvnfvXlNvb29rT09Pq0QsUM7S6c4rNqS/lrZ5U+YPRBKR9M7u9xwqBUUvtNAudH766XSLE8PR49ixE78/8tVnX403Zk7fUR46NUUAIPIPCMdTKJTdNjY2QKPRgE6nA51OB1tbWyCRSIDD4YBAIAAejwcCgfDYUajVakGlUoFarQadTvfY79HX1wf9/f0gl8tBLpfDvXv3HvXw+dxQPYYXMj+d+P7Mmzv+5OHr6/OJWq1GBHeB09TcUiKuq/coKS3/eqIx/wPkiIXC3w6YjAAAAABJRU5ErkJggg=="); + + --keyword: #ff79c6; + --identifier: #f8f8f2; + --comment: #6272a4; + --operator: #ff79c6; + --punctuation: #f8f8f2; + --other: #f8f8f2; + --escapeSequence: #bd93f9; + --number: #bd93f9; + --literal: #f1fa8c; + --program: #9090c0; + --option: #90b010; + --raw-data: #8be9fd; + + --clipboard-image-normal: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' style='color: lightgray' fill='none' viewBox='0 0 24 24' stroke='currentColor'%3E %3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2' /%3E %3C/svg%3E"); + --clipboard-image-selected: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' style='color: lightgray' viewBox='0 0 20 20' fill='currentColor'%3E %3Cpath d='M8 3a1 1 0 011-1h2a1 1 0 110 2H9a1 1 0 01-1-1z' /%3E %3Cpath d='M6 3a2 2 0 00-2 2v11a2 2 0 002 2h8a2 2 0 002-2V5a2 2 0 00-2-2 3 3 0 01-3 3H9a3 3 0 01-3-3z' /%3E %3C/svg%3E"); + --clipboard-image: var(--clipboard-image-normal); +} + +@media (prefers-color-scheme: dark) { + [data-theme="auto"] { + --primary-background: #171921; + --secondary-background: #1e202a; + --third-background: #2b2e3b; + --info-background: #008000; + --warning-background: #807000; + --error-background: #c03000; + --border: #0e1014; + --text: #fff; + --anchor: #8be9fd; + --anchor-focus: #8be9fd; + --input-focus: #8be9fd; + --strong: #bd93f9; + --hint: #7A7C85; + --nim-sprite-base64: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAARMAAABMCAYAAABOBlMuAAAACXBIWXMAAAsTAAALEwEAmpwYAAAFFmlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgNS42LWMxNDggNzkuMTY0MDM2LCAyMDE5LzA4LzEzLTAxOjA2OjU3ICAgICAgICAiPiA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPiA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtbG5zOmRjPSJodHRwOi8vcHVybC5vcmcvZGMvZWxlbWVudHMvMS4xLyIgeG1sbnM6cGhvdG9zaG9wPSJodHRwOi8vbnMuYWRvYmUuY29tL3Bob3Rvc2hvcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RFdnQ9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZUV2ZW50IyIgeG1wOkNyZWF0b3JUb29sPSJBZG9iZSBQaG90b3Nob3AgMjEuMCAoV2luZG93cykiIHhtcDpDcmVhdGVEYXRlPSIyMDE5LTEyLTAzVDAxOjE4OjIyKzAxOjAwIiB4bXA6TW9kaWZ5RGF0ZT0iMjAxOS0xMi0wM1QwMToyMDoxMCswMTowMCIgeG1wOk1ldGFkYXRhRGF0ZT0iMjAxOS0xMi0wM1QwMToyMDoxMCswMTowMCIgZGM6Zm9ybWF0PSJpbWFnZS9wbmciIHBob3Rvc2hvcDpDb2xvck1vZGU9IjMiIHBob3Rvc2hvcDpJQ0NQcm9maWxlPSJzUkdCIElFQzYxOTY2LTIuMSIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDplZGViMzU3MC1iNmZjLWQyNDQtYTExZi0yMjc5YmY4NDNhYTAiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6ZWRlYjM1NzAtYjZmYy1kMjQ0LWExMWYtMjI3OWJmODQzYWEwIiB4bXBNTTpPcmlnaW5hbERvY3VtZW50SUQ9InhtcC5kaWQ6ZWRlYjM1NzAtYjZmYy1kMjQ0LWExMWYtMjI3OWJmODQzYWEwIj4gPHhtcE1NOkhpc3Rvcnk+IDxyZGY6U2VxPiA8cmRmOmxpIHN0RXZ0OmFjdGlvbj0iY3JlYXRlZCIgc3RFdnQ6aW5zdGFuY2VJRD0ieG1wLmlpZDplZGViMzU3MC1iNmZjLWQyNDQtYTExZi0yMjc5YmY4NDNhYTAiIHN0RXZ0OndoZW49IjIwMTktMTItMDNUMDE6MTg6MjIrMDE6MDAiIHN0RXZ0OnNvZnR3YXJlQWdlbnQ9IkFkb2JlIFBob3Rvc2hvcCAyMS4wIChXaW5kb3dzKSIvPiA8L3JkZjpTZXE+IDwveG1wTU06SGlzdG9yeT4gPC9yZGY6RGVzY3JpcHRpb24+IDwvcmRmOlJERj4gPC94OnhtcG1ldGE+IDw/eHBhY2tldCBlbmQ9InIiPz4JZNR8AAAfG0lEQVR4nO2deViTZ7r/7yxkJaxJ2MK+GCBAMCwS1kgUFQSKK4XWWqsz1jpjp3b0tDP1V+eqU391fqfT/mpPPd20drTFDS0KFEVWJSGAEgLIZpAICBJACIRs549Rj1WILAkBfD/XlevySp68z/0S3+/7vPdzLyidTgcLkU2bd+z39/f/q1gshsrKSoJELFCa2iaEuU9K6kb+8uXxv54/fzE8L/eswNT2zCfQpjbAGKS8lPFKSEjIXiaTCSEhIeDj4xNnapsQ5j6rktZGp6UlfxIdzQVzCplmanvmG1hTG2BIAtlc26CgoDfT0tL2e3l5AQCAjY0NkMnk/a9s2k6rrKw8UV8n1JjYTIQ5RlAw14KzmL3xze1vfJyUuMJaq9UCFovFm9qu+YbBxcSPFUYkk8l2Q0NDsvo6ocrQx5+I8Ih4bz6f/0l8fHyKlZXV4/dRKBQwmcwwMpn8A4FAoPgHhH9bV1sxa488wZxoaycnJ/a9e/duCa5fkc3WvAiTI4Ib77p+XdqHG9anbfLy8gAAgLGxMdBpF+bjvzExqJj4scKI0dHRnwQHB++orq7+AgDeMuTxJ2Jl4rqU9PT0EwEBAUQCgTDuGAaDAampqYepVKpHUHDk325Ulw0a266YuFW+Gzdu/MDPz29jfn7+XgA4aOw5ESZP6kvpCXv3vnM8NiaSamVl+fj9BepGNDoGFRN7e/slcXFxO1xcXMDJyWnH7j//H/fi4uJdgutXmgw5z5O8smn7X9euXbvf29sbMBjMhONQKBRYWVlBbGzsbjMzM3JoOG+/sKKwy1h2rd/4elpGRsYuLy+vaDweD2w2Oy1h5ZrCvEunEaeeiVnMiabyl/F2/+X9P+8JDPQHHA5napMWBAYTk6DgSNuEhIS9DAYDAP7tq1i6dOkqOp3OWbNu0wens44emeoxA9lcWwKBYEMkEm2JRKIdHo+3QKFQWJ1Op8ZgMER3d/dVq1evTnFycpr0MSkUCsTExGzH4/Gk1LTME/39/TI0Go1FoVCg1WrVY2NjipGRkcGRkRH5dPwrEZHLXMPCwjJSUlIy3dzcfB+97+rqGhYSEpIOAIiYmBguN3zL77dt3uPh4W5qUxYUBhMTb2/vjeHh4cvR6P/dILK0tITIyEg7BweHr363/Z3Ampqaf1Zcu/zMKiVsyVJvMplsRyKR7IhEor2FhYUbhUJhJCYm2pFIJB6JRAIymQx4PB7QaDRoNBowMzMDJycnwOOn7icjEokQGxu7icFgbLp///7jFY1WqwWlUgkjIyOgUCgO7Ni5Rz48PCwfHh7uGRkZeaBQKOSjo6ODCoVCXlNVKn/6uCsT13FXrVr1emho6BYKhfLMnP7+/omrU9LPX8g+UThloxEMxqJFXjxESAyPQcSEExrLWLNmzW57e/txP/fw8ABHR8cdDAaDt3xF2ru9vb03sVgs0cbGxs/FxWVZUlISj0aj+dna2oKtrS1M5PcwJCgUCry8vODRrs84vPfoH6OjoyCXy6Gvr+/R6+CWrX9s7evrk/b19bWr1Wqli4sLZ8OGDe95eXmxUSjUuAd0cHDwjoqK2sYKXFIhvnldYYTTQpgU4/8+jyASCYDGoCd+ZkYYF8OICYezl8PhuOkbQyAQIDo62s/NzS2np6cHbGxsgEajAYFAAAwGA1gsFia6CE0NgUAABwcHsLe3B61WC2q1eo9WqwWNRgNKpRLUajUQiUSgUCh6zwGHwwGTydzo5+eXBQBnZu8MEJ5keHhYPqyYWMtHR0ZBpVIhYj9FUDONgOUvT12+du3avMDAQJjssdRqNWCxCyrEZdLodDoQi8Ulx44de628NL/V1Pa8iERE8l2dHB2CJvpcq9Nqbt1qKURWj1Njxld0ZGTkAW9v70kLCQC8sEIC8O/HKx8fn2gmk8kHgCk7pRFmzrWyAikASE1tx0Jj2uH0EZHL/N7YtuvT4OBgzmz4OBYSeDweIiMjt2S++vtMP1YYEmmJsCCY8mNOIJtr6+zsHBcZGXmIw+G4mZubG8m0hU9HRwcUFxe/KxQKTyDRsQjznSmJCS9+dVRERMTfQ0NDo2xtbfUGiSFMjtHRUaitrc3Jzc09kHvxVLmp7UFAmC6oZQkvrZLL5RJhReHtiQb5scKIXC7371FRUX90dnYGIpE4JR8Jgn40Gg20t7fXFxYWfnr9+vWjz8sdYi+Osh4vzgUBwZSgtu94V+fs7Hx7YGCgra6u7khLS0u2RCwYeTQgKmYFh8fj/f/g4OAldnZ2prR1wdPd3Q1CofBQSUnJkdLi3N8E93FCY6k+Pj48FxcXjlar1ZSWlh65VvYr4kREmDNg79+/D3FxcW5OTk5uXl5evNbW1tL0jK3ZXV1d1ykUintycvInoaGhdkj+gvGxs7MDPp+/m0AgWMQvS/lyeHhYTqPRPJycnIJSU1NZ3t7eW2g0Gly/fv2oWq1Gij0hzClQ/gHhpLS0tEM8Hm/7I8Ho7++HlpYWsLa2Bg8PDxOb+OKhUCigqakJ7t+/D25ubuDu7g4oFAp0Oh08ePAAvv7666TTWUdzTG0nAsKTYMU3ryuSU18+4+bmFrZo0SIOAICVlRUsXrx4zkakLnRIJBI8CgJ8MtdJp9NBZ2enqL29XWRC8xAQxgUNAHD+3L8KGhoaCp78ABES04JCoX4jJAAAAwMDUFtbe96YpRMQEKbL41DU5ubmko6Ojj2PSgggzD36+/vrb9y4cX425zzw93/8EBjon2is44+NjSkePBjqGRwc7G5v7xBV19w8U5B/3qgrr9+/uWtXUuKKD/TZ9MXh/066/OuFmunO8dGBQ98HBbGSp/t9U6LRaDXK0dHBoeFhuVzeL22/0yFqamopufjLqRJ933ssJi0tLSXV1dWHGAzGbuObOzs8ubqa71vZKpUKOjo6blwpOF8zm/Mu5cVkLlkSaswprAHAaVihgK7O7oSGxltvfXLon3nXK4RHT2cdN4pfKDCAlZyUuMJan02nTmczAaBmunPw4qI3cbnh0/36XICq0+lgcPABp7OrK629vUP5z8++LLh2XXD05L++yxrvC4/F5EZ12WBS8saLS5Ys2U2lUufUY45SqQSlUgkqlQrUavXj19jYGGg0GtBoNKDT6UCn05VotVq1TqfToFAojFar1eh0Og0Wi8XhcDgeGo1+/PhgZmYGOBwOsFgsmJmZ/eY1F+nt7YXa2trs2Z73wdCQBgCMHp1IJpHA09MdPD3dLRIS+OtKisvWvbP7vf2lZdePVFwzbHTwyMiI3hidkZFRUKvUYzOZ48HQkBIA5nWqBAqFAktLC7C0tADmIh88Pz4uMSyUk7hn776DV4tKPn/6d/lNxp1MJqsRCASf8vn8XdMpOjRTVCoVjI2NgUqlAq1WCyMjI9DX1wf379+Hvr6+/Q8ePOgdGRmRKxSKx0WLFAqFXKlUKnQ6nUar1arHq47mxwrD4/F4Eg6HI2GxWDwej7cgkUjWFAqFam5uTjU3N6eRyeQPLSwswNraGqysrIBAIDwWFywW+zja11Qi29LSclIikeSZZPJZBovBAI8XA8HBQR9kZZ3lR8cmvFZSlGe00p8IkwONRkNERBj4+i7a4+XpHv307/IbMakWlciXJbx0nMPh7Jqo0JGh0el0MDo6Cl1dXSCVSkEmk7177969W319fe1DQ0M9KpVKoVarlWq1WjndNhUPG3ApAWDcOxLTLwSDwWAOotFoDBaLxRMIBAsrKysne3t7Xzqd7k2n0/c4OzsDlUoFHA4364IyMDAATU1NxdWikhcq6tXKyhJezljPJZKI2eERS5cZeoWCMD2srCwhPX0tVzk2djiCG//GtfLLUoBxShB0dHTU3Lx580sLC4vtJBLJKMZoNBqQSqUglUqPdnR01PT09DT19/fLHjx40DM0NNQ72933GiSVGgB4JFQK+LfoSAGgnL04yppEIh2xtLS0t7GxcaFSqR7Ozs4fMRgMcHR0nJX8pJs3b54Ui8UXjT7RHIRMIkFK8irfwcEHPwQELUmqvYHUGJkLmJubw8YNa/i9vfffY/px3myQiDTPiEl9nVDDX576jaenZ7SnpyfLUJNrNBqQyWRw+/bt4x0dHTdkMlltV1dXw/XygjkdEv4wB0YOAK0AUM70C8HQ6fSzdDrdm0qlejg6OrLc3Ny2MBiMadWjfR4PHjyAmzdvZs/1v5MxoVAokJK8iicWS95k+nH+s0EiQhqpzQGoVFtYk5a87ba0XQAA34xbpagg/5zoT7s/OGNnZ8eaaYkBuVwOnZ2d5VKpVNTS0lLS2NhYWFVZ3Dujg5qQh6uY+ocvCAiKIPn4+Jz19PSMdnV15VCpVL6Dg4NBViw6nQ5EItHRpqamqzM+2DzHzo4O69amftLQeKsAZrDLgmBY/PyYsCIhfs+SiKUFE5Y8EwqFx11cXDihoaFTjjFAoVAwPDwMHR0dourq6jNCofDHhZqUVnvjmgIAcgAgJyg40mLRokX8kJCQjT4+PussLS1n1JPl7t27UFxcfHguB6mNjY2B7G4naNRTWyygUCjAYDGAx+PB0sICSCSi3vFYLBbCwjjA8vddBQtATKb7d3saBwc7IJPJBpsHjUGDGRYLJBIJLK0sAfucmyIGg4FFi3y8AwNZtycUk5KiS02vvf7WWQaDkejg4DApQwAeh3xDaWnpPoFAcPxFqnP6sEvgGf+A8Bx3d/cvIyIiNi1evHjT8wpNj8fAwACUlZW9P9dD5+/ckcFbf9gd2dcnn9LNAovF4inmZHtXNxdOdBR3+/JlS33pdP29wolEInA4weuiYxOy5vvuTkeHDHb+8c8xvb33Z3R9/N+Df+uIjYk02DwkEsna2trS1d/fNyGeF7uTyw1/7g3R3t4O2OxA/TVghULhcQqFQk1JSfmYSNR/5wD4d6EfgUBwvLS09IhUKhW9qAV5H9YjKQwJi6uvrKw8ERoamhkSEpKp7w7yJEqlEiQSyZmysrJv53qjdaVSCZdyTk+3qFMrAJRHRPLPN95qeifj5fU7mYt8JhyMRqMhMJDFdnF25gDAvBYTpXIMWlpay2fq/8m5mDcIABYGnEcGAGI/VlhBZWX1yZdSkz55OX0dV5+7w9bGGvz8mPrFpK62QskJjf2GTqd7x8bGbpnID4BCoUAmk0lLSkqOiESik2UleS/MakQflYKrXQDQxY1a3tTe3i6KiIjY5OXlxX7e9+rr6wsuXbr0t4ffn9OgMWjghMZQRcLp+8GulRVI/QPC37Wxtnal0ajJtjY2E451ZjiBra31vE9lR2PQQKFQaAAwo98Yi8Xq9fpPd56HO6rlvKWJv/PwcK+JilyCmajWMw6HAzs7+rMFpQOCIn6zHywSFvXm5eUdFAqFZ9Rq9bgHa2trq79w4cK+zz49cAARkmcpL81v/a/Dhz49d+7c3qqqqjyVSjXuOJ1OBxKJpDw3N/fA5V+zax6978cKw/sHhM/raMrnUVdboSy4fPWQSFSjd5yFBQWIRNKEd2IEw1J4JUd88WL+R51d3XrHWVDMnxUTa2tr1zXrNiUGsrmPf7DS4tymCxcu7Kuurs55+kKQSqVN586d23vs+8NHDXUCC5Wzp3/Iy8rKeruysvLM2Nhvo7VVKhXU1tYWnj17du/T7UOdnZ2D7OzsfGGB09raVi4S1RzXl0eFw+EAj8chYjKLVFffyOrq1C8mJBLpWTFRKBRyDofzC4vFWvXk+1ev/CLOzs7eKxAIslQqFeh0Oujp6enKzs7em/XTd7OayTqfKb56sT4rK+sPAoHg5KO/o0KhAKFQmHXy5MkdF3/5+TeZmctXpIXZ29v7zqVcKWNRX1epuXu3U/y8pEw0GmndOZt0dnXVDw0P6/W5oNHoZ30mQ0NDPb29vfvj4+Pf3rR5B/7od188XnEUXr4gDgmL+0NfX5/U19d3d3l5+YGfTnyDtLmcIhXXLsu4UcvfR6PRGGtra9eysrIjYrE45+kt4Fheou/69es/unnz5vm7d+/Wmsre2WRkZGTQ1DYg/JYGiUiTm1ugBAC9IfHPiEmDpFITE7fqJI/H27lmzZpDq5LWtz55t6wUXO3ihMYerK+vz2tpaUFaM0yT8tL81ujYle+TSCTrvEunBU9/voTLd92wYcPHVCqV39XVdXCu7+oYCp1O90Kc50Jk3I5+xVcv1jc3N5d4enpSMzIyvkpK3sh78nORsKg3++yPBS/q1q+hKCm61DSekERGJ3ikp6d/ERsbm1xVVXWwtbX1hRFtFAqFPMLMUyZsDyoQCI7LZDKIiIjwzczM/GpV0vro2TTsRSUqZoX3+vXrP1u9enXi0NAQiESirIdRtggIc5oJ40zq6uryGhoa8ry8vBJCQ0O9USjU94mrN7yWc+EnvaXb5gJMvxCMp6cnl0Kh2Le1tZVXXLs8L1LXefGrWRkZGZ/x+XyeUqkEkUh0vqenZ14HZyG8OEwoJjdrygd37NxTEBkZmWBtbQ3BwcEeKBTq+/UbX3/355Pfzlmn66qk9dGbN29+k8PhbCSRSNDZ2Snb9ae/HCkpKTksEhbN2QTD5NSX+Vu3bj0cHBzsjcFg4O7du1BWVvbNwxB9BIQ5j94I2Fu3bhXW19cDl8sFLBYLHA7Hg0wmf/e77e84ffXlPz6fLSMnQ2paZkJ4eHjmtm3b+B4eHvZkMhlQKBTY29s72dvbfxgUFJT8x7ffP1NRUfHjXErnZ/qFYKKjo7dt3rz5g8DAQPtH/XHa2tpqGhsbC55/BASEuYFeMblz505NTU3NgfDw8PcwGAygUCjw9fW1IJPJn/1130Hv0tLSI4WXL4hny9inYS+Osvbz80tgMpn8jIwMPovFch2vpoiDgwM4ODhwfH19OYsWLeJv3/Hu+cbGxquzXZz5aZYlvMRJT0/fFhkZue3JZmfd3d0gEolOIr4ShPmEXjFpkFRqXlrzSnFnZ+d7Tk5OjzNfXVxcICMjY6ezszNnVdL6vU8HWhmbgKAIkrOzMyc1NTXz0YU4maAuOp0OK1as4EVFRfGEQqHg1dfePHzr1q2rs71S8WOF4f38/BLS09M/iIyM5DxdxLq5uVlcVVU1bgVwBIS5il4xAQCQyWRigUBwJikpKe3JVGQcDgdLly7l2tranti0ecf7IpEoy9hbxX6sMDydTvdevXr1ltjY2F3u7u6AxT73FJ7B3Nwc4uLiwthsdphQKCzZkL7l0/r6+oKbNeVG90+EhMXZL1++fFtycvKHrq6uz4igUqmE5ubmEiTHCWG+8dwrUXD9imz9xtd/jIuLS7N5KpsTjUZDUFCQE4PB+F4oFGYmJW888Mv5k4UTHGpGxC9LYaenp78VEhKyxdHRESgUyoyOh0KhwNraGuLi4qIDAgKi6+rqyjekb/mHMSN6N6RvSdu+ffseNpsdZm09ftuW+vp6EIvFSB9hhHnHpG7rUqm0orW1tdXS0tLj6TIEaDQaaDQaxMfH811dXTl/3Xfw+JUrVz411J01cfWG6IiIiC07d+5McHNzs7ewMGyOFw6HAwcHB6BSqVx3d/fwz7/4rkAgEBwXCoUnHpZonDGrU9J5MTEx27du3Zrm4uKC0beaqq6u/ry+vj7XEPMiIMwmkxKTimuXZe/u+fCkp6fnexPdUfF4PPj7+1szGIydLi4unF1/+kvenTt3RG1tbRXTqfma8lIG39/fP/HVV19NZrFYHpMpzjQTzMzMwNPTE+Pp6Zng6emZ4Ofnl5CesfV8bW1tznQe3/wDwvFeXl7Rvr6+Ca+88kpaUFCQh74GXzqdDrq7u6GpqankRQmdR1hYTNrhUFVVlcXj8d6ysrKy0OfstLS0hPj4eC6Xy+U2NzeDRCI5/sa2XeX37t1rGhwc7BoYGJBN1P+FFbiE5OzszGaxWImvvvrqpoCAAKfp+ERmCpPJBCaTmcnhcDJLS0u/TE59+YxUKhXoi/lg+oVgrKysGJaWlna2trYeaWlpXDabvTMgIGDSfp2KiorzbW1tL0zoPMLCYtJX6uVfs2u++PKowMPDgz+ZIslEIhECAgKAxWJlajSazJ6eHmhra4PW1tZvtmz9o6Czs7O+r6+vfWxsbFir1WosLCzsV6xYkcnj8d7z9vaelmPV0Hh5eYGnp+f2mJiY7UVFRZ/HL0v5tru7+5ZGo1FisVg8Docj4fF4CxsbG1c+nx/m7e39sYeHB7i4uIC5ufmU6r4ODQ1BZWXlifkSrYuA8DRTumIrKytPent78728vCb9HRQKBVgsFhwcHIBOpwObzd4yNja2RaVSwdDQEHR1dcHo6CjQaDRwdXWdsWPV0KBQKPDw8AA7O7udERERO2tra2FgYACoVCo4OTkBjUYDMpkMeDz+8WuqaLVaaGxsbL19+/YzSX8ICPOFqYrJidDQ0AwvLy/e80c/CwaDARKJBI86BdJoNHB3dwe1Wj0nViL6IJPJwGQywdnZGZRKJRAIBDBUx8OBgQEoLS39BtkORpjPTJg1PB61N64pmpqarvb39xvUiLkuJE9CJpPBxsbGYEICANDZ2SlHgtQQ5jtTEhMAgLq6ulyJRFJvDGNeREZGRkAikRSUFuci2cEI85opi0l+7hmBWCzOeV6dToTJcfv27cHr168jxbgR5j1TFhMAgObm5hKZDNl0MAQtLS3Xzpw6hkS8Isx7piUmUqlUIBAIJuyjgzA5Ojs7QSKRINGuCAuCaYmJsKKw68qVK59KJJIu5HFneiiVSigqKjouEolOmtoWBARDMC0xAQC4+MvPJadOnXq3ra1N8yL0dDEkOp0OSktLy/Pz8w8+3d4CAWG+Mm0xAQA4fuy/jl+8ePGju3fvGsqeBY9Wq4XKysrWU6dOvX31yi8mKyyFgGBoZiQmAAD/79D+fadPn96PCMrz0el0UFVV1frtt9+mj9fiAgFhPjNjMQEAyMvLO3Ds2LE/tLS0INmuerh27Vr9999//xoiJAgLEYOEntbVVigB4PNNm3cMpqSkfMRms50McdyFgkqlgqKiovJTp069nZ97BhEShAWJQePYj373xdF1GzbLFQrFx6Ghob766ne8KNy7dw+KiopO5ubmfmTK4tsICMbG4EkxWT99d35l4rre/v7+D0NCQvh0Ot3QU8wL1Go1SKVSTX5+/sH8/PyDSP8bhIWOUTLsLuVklQcFR65pbGzcvnLlyvfc3NwsCASCMaaac+h0OhgaGoLq6uqaCxcu/OV01tGcTw7uM7VZCAhGx2jpug/vxAd58atzoqKitq1cuXKnvb29saabE+h0Oqiurpbm5eUdrK6uPlspuDrvY0hmO4YIhUIBGq1/X2CmNqFQKL3/79HomZ/z82xEowyy9zFr80zGDqPn/hdeviBmL47ad+fOnRsRERGbQkNDo62srIw97azT2dkJxcXFx0tKSo7Mdh8hY4LD4TDPH2U4MFjMc6tLmZmZzaj+Aw6H0/t9PB4PGCxmRudNJBL0ngeZTAI0Gj3jv+1szfM88Hic8cUEAKCmqlQOAN/ELU2qkEgkySwWK3HRokVcBoMxG9MbDZ1OB83NzdDU1FRQW1t7XiAQHJ+ovu18pbr6Rg6L5ZtoM0EhcUPT0tJW8tWRb0vQqIkvgKqqmhnVfrl2TfANXo+gjKlUio4OWc1M5sjOzjnQUH8rbqLPu3t6moaGhmfc+3q25tGHUqmECoEIUKbIrVkcEkONiIh4jcvlvu7s7OxLo9GmVe7QVCgUCujq6oKGhoaCioqKo9XV1WeM3YDMVPDik1gpyas+XrVyeaKXl8czjyANjbcgI/MNmkg49Q4ECPOH3NyC4RUr+M8IcHt7B1y9WlKRl3/5kElKnD1sfXEoJCzueEBAQGJYWFgGk8nk2djYAIFAgLm4pTw6Ogqjo6Mgl8vhxo0b50tLS4/U19fnLvS2FIWXfxEDQNLmLW9ueW1TxtchHDaQyWRTm4VgYkZHR6G+vhF+/NfP+y5e+vVjiVgwZpKVydOwF0dZW1lZOTGZTD6bzU4LCAiIptPp8HTDL1MwOjoKLS0tUFdXd1IsFudIpdKKgYGB7tloJTrX4MUnsVJTEj9etzY10dHRAQAAGm81wcsZW5CVyQInL69gNCGBjwcAGBx8ANnncypOnTr3H9nn/reD55wovvrQpyIHAHFUzIocGo3mQaPRfBwdHVlubm7bXF1dgcFgABqNNvruglwuh7t374JMJoOOjo7P79y5I+ru7m7q7e1tXQi7MzOh8PIv4pCw2DdaWtte37Au7aPIyCWAxWABjUbPif9HCMbjURtKiaQBfvr5zH9evlJ0uLQ4r/nJMXNiZTIRrMAlJAcHB18HBweWo6Mjy8rKajeJRAJLS0uwtLQECwsLoFAogMfjAYvFgpmZ2XNXMyqVCoaHh2FoaAiGh4cfvwYGBqCvrw+6u7vfvnfvXlNvb29rT09Pq0QsUM7S6c4rNqS/lrZ5U+YPRBKR9M7u9xwqBUUvtNAudH766XSLE8PR49ixE78/8tVnX403Zk7fUR46NUUAIPIPCMdTKJTdNjY2QKPRgE6nA51OB1tbWyCRSIDD4YBAIAAejwcCgfDYUajVakGlUoFarQadTvfY79HX1wf9/f0gl8tBLpfDvXv3HvXw+dxQPYYXMj+d+P7Mmzv+5OHr6/OJWq1GBHeB09TcUiKuq/coKS3/eqIx/wPkiIXC3w6YjAAAAABJRU5ErkJggg=="); + + --keyword: #ff79c6; + --identifier: #f8f8f2; + --comment: #6272a4; + --operator: #ff79c6; + --punctuation: #f8f8f2; + --other: #f8f8f2; + --escapeSequence: #bd93f9; + --number: #bd93f9; + --literal: #f1fa8c; + --program: #9090c0; + --option: #90b010; + --raw-data: #8be9fd; + + --clipboard-image-normal: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' style='color: lightgray' fill='none' viewBox='0 0 24 24' stroke='currentColor'%3E %3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2' /%3E %3C/svg%3E"); + --clipboard-image-selected: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' style='color: lightgray' viewBox='0 0 20 20' fill='currentColor'%3E %3Cpath d='M8 3a1 1 0 011-1h2a1 1 0 110 2H9a1 1 0 01-1-1z' /%3E %3Cpath d='M6 3a2 2 0 00-2 2v11a2 2 0 002 2h8a2 2 0 002-2V5a2 2 0 00-2-2 3 3 0 01-3 3H9a3 3 0 01-3-3z' /%3E %3C/svg%3E"); + --clipboard-image: var(--clipboard-image-normal); + } +} + +.theme-select-wrapper { + display: flex; + align-items: center; +} + +html { + font-size: 100%; + -webkit-text-size-adjust: 100%; + -ms-text-size-adjust: 100%; } + +body { + font-family: "Lato", "Helvetica Neue", "HelveticaNeue", Helvetica, Arial, sans-serif; + font-weight: 400; + font-size: 1.125em; + line-height: 1.5; + color: var(--text); + background-color: var(--primary-background); } + +/* Skeleton grid */ +.container { + position: relative; + width: 100%; + max-width: 1050px; + margin: 0 auto; + padding: 0; + box-sizing: border-box; } + +.column, .columns { + width: 100%; + float: left; + box-sizing: border-box; + margin-left: 1%; } + +@media print { + #global-links, .link-seesrc, .theme-switch-wrapper, #searchInputDiv, .search-groupby { + display:none; + } + .columns { + width:100% !important; + } +} + +.column:first-child, .columns:first-child { + margin-left: 0; } + +.container .row { + display: flex; } + +.three.columns { + width: 25.0%; + height: 100vh; + position: sticky; + top: 0px; + overflow-y: auto; + padding: 2px; +} + +.nine.columns { + width: 75.0%; + padding-left: 1.5em; } + +.twelve.columns { + width: 100%; + margin-left: 0; } + +@media screen and (max-width: 860px) { + .three.columns { + display: none; + } + .nine.columns { + width: 98.0%; + } + body { + font-size: 1em; + line-height: 1.35; + } +} + +cite { + font-style: italic !important; } + + +/* Nim search input */ +div#searchInputDiv { + margin-bottom: 1em; +} +input#searchInput { + width: 80%; +} + +/* + * Some custom formatting for input forms. + * This also fixes input form colors on Firefox with a dark system theme on Linux. + */ +input { + -moz-appearance: none; + background-color: var(--secondary-background); + color: var(--text); + border: 1px solid var(--border); + font-family: "Lato", "Helvetica Neue", "HelveticaNeue", Helvetica, Arial, sans-serif; + font-size: 0.9em; + padding: 6px; +} + +input:focus { + border: 1px solid var(--input-focus); + box-shadow: 0 0 3px var(--input-focus); +} + +select { + -moz-appearance: none; + background-color: var(--secondary-background); + color: var(--text); + border: 1px solid var(--border); + font-family: "Lato", "Helvetica Neue", "HelveticaNeue", Helvetica, Arial, sans-serif; + font-size: 0.9em; + padding: 6px; +} + +select:focus { + border: 1px solid var(--input-focus); + box-shadow: 0 0 3px var(--input-focus); +} + +/* Docgen styles */ + +:target { + border: 2px solid #B5651D; + border-style: dotted; +} + +/* Links */ +a { + color: var(--anchor); + text-decoration: none; +} + +a span.Identifier { + text-decoration: underline; + text-decoration-color: #aab; +} + +a.reference-toplevel { + font-weight: bold; +} + +a.nimdoc { + word-spacing: 0.3em; +} + +a.toc-backref { + text-decoration: none; + color: var(--text); +} + +a.link-seesrc { + color: #607c9f; + font-size: 0.9em; + font-style: italic; +} + +a:hover, a:focus { + color: var(--anchor-focus); + text-decoration: underline; +} + +a:hover span.Identifier { + color: var(--anchor); +} + + +sub, sup { + position: relative; + font-size: 75%; + line-height: 0; + vertical-align: baseline; } + +sup { + top: -0.5em; } + +sub { + bottom: -0.25em; } + +img { + width: auto; + height: auto; + max-width: 100%; + vertical-align: middle; + border: 0; + -ms-interpolation-mode: bicubic; } + +@media print { + * { + color: black !important; + text-shadow: none !important; + background: transparent !important; + box-shadow: none !important; } + + a, a:visited { + text-decoration: underline; } + + a[href]:after { + content: " (" attr(href) ")"; } + + abbr[title]:after { + content: " (" attr(title) ")"; } + + .ir a:after, + a[href^="javascript:"]:after, + a[href^="#"]:after { + content: ""; } + + pre, blockquote { + border: 1px solid #999; + page-break-inside: avoid; } + + thead { + display: table-header-group; } + + tr, img { + page-break-inside: avoid; } + + img { + max-width: 100% !important; } + + @page { + margin: 0.5cm; } + + h1 { + page-break-before: always; } + + h1.title { + page-break-before: avoid; } + + p, h2, h3 { + orphans: 3; + widows: 3; } + + h2, h3 { + page-break-after: avoid; } +} + + +p { + margin-top: 0.5em; + margin-bottom: 0.5em; } + +small { + font-size: 85%; } + +strong { + font-weight: 600; + font-size: 0.95em; + color: var(--strong); } + +em { + font-style: italic; } + +h1 { + font-size: 1.8em; + font-weight: 400; + padding-bottom: .25em; + border-bottom: 6px solid var(--third-background); + margin-top: 2.5em; + margin-bottom: 1em; + line-height: 1.2em; } + +h1.title { + padding-bottom: 1em; + border-bottom: 0px; + font-size: 2.5em; + text-align: center; + font-weight: 900; + margin-top: 0.75em; + margin-bottom: 0em; } + +h2 { + font-size: 1.3em; + margin-top: 2em; } + +h2.subtitle { + margin-top: 0em; + text-align: center; } + +h3 { + font-size: 1.125em; + font-style: italic; + margin-top: 1.5em; } + +h4 { + font-size: 1.125em; + margin-top: 1em; } + +h5 { + font-size: 1.125em; + margin-top: 0.75em; } + +h6 { + font-size: 1.1em; } + + +ul, ol { + padding: 0; + margin-top: 0.5em; + margin-left: 0.75em; } + +ul ul, ul ol, ol ol, ol ul { + margin-bottom: 0; + margin-left: 1.25em; } + +ul.simple > li { + list-style-type: circle; } + +ul.simple-boot li { + list-style-type: none; + margin-left: 0em; + margin-bottom: 0.5em; } + +ol.simple > li, ul.simple > li { + margin-bottom: 0.2em; + margin-left: 0.4em } + +ul.simple.simple-toc > li { + margin-top: 1em; } + +ul.simple-toc { + list-style: none; + font-size: 0.9em; + margin-left: -0.3em; + margin-top: 1em; } + +ul.simple-toc > li { + list-style-type: none; } + +ul.simple-toc-section { + list-style-type: circle; + margin-left: 0.8em; + color: #6c9aae; } + +ul.nested-toc-section { + list-style-type: circle; + margin-left: -0.75em; + color: var(--text); } + +ul.nested-toc-section > li { + margin-left: 1.25em; } + + +ol.arabic { + list-style: decimal; } + +ol.loweralpha { + list-style: lower-alpha; } + +ol.upperalpha { + list-style: upper-alpha; } + +ol.lowerroman { + list-style: lower-roman; } + +ol.upperroman { + list-style: upper-roman; } + +ul.auto-toc { + list-style-type: none; } + + +dl { + margin-bottom: 1.5em; } + +dt { + margin-bottom: -0.5em; + margin-left: 0.0em; } + +dd { + margin-left: 2.0em; + margin-bottom: 3.0em; + margin-top: 0.5em; } + + +hr { + margin: 2em 0; + border: 0; + border-top: 1px solid #aaa; } + +hr.footnote { + width: 25%; + border-top: 0.15em solid #999; + margin-bottom: 0.15em; + margin-top: 0.15em; +} +div.footnote-group { + margin-left: 1em; +} +div.footnote-label { + display: inline-block; + min-width: 1.7em; +} + +div.option-list { + border: 0.1em solid var(--border); +} +div.option-list-item { + padding-left: 12em; + padding-right: 0; + padding-bottom: 0.3em; + padding-top: 0.3em; +} +div.odd { + background-color: var(--secondary-background); +} +div.option-list-label { + margin-left: -11.5em; + margin-right: 0em; + min-width: 11.5em; + display: inline-block; + vertical-align: top; +} +div.option-list-description { + width: calc(100% - 1em); + padding-left: 1em; + padding-right: 0; + display: inline-block; +} + +blockquote { + font-size: 0.9em; + font-style: italic; + padding-left: 0.5em; + margin-left: 0; + border-left: 5px solid #bbc; +} + +blockquote.markdown-quote { + font-size: 0.9rem; /* use rem to avoid recursion */ + font-style: normal; +} + +.pre, span.tok { + font-family: "Source Code Pro", Monaco, Menlo, Consolas, "Courier New", monospace; + font-weight: 500; + font-size: 0.85em; + color: var(--text); + background-color: var(--third-background); + padding-left: 3px; + padding-right: 3px; + border-radius: 4px; +} + +span.tok { + border: 1px solid #808080; + padding-bottom: 0.1em; + margin-right: 0.2em; +} + +.copyToClipBoard { + position: relative; +} + +pre { + font-family: "Source Code Pro", Monaco, Menlo, Consolas, "Courier New", monospace; + color: var(--text); + font-weight: 500; + display: inline-block; + box-sizing: border-box; + min-width: 100%; + padding: 0.5em; + margin-top: 0.5em; + margin-bottom: 0.5em; + font-size: 0.85em; + white-space: pre !important; + overflow-y: hidden; + overflow-x: visible; + background-color: var(--secondary-background); + border: 1px solid var(--border); + -webkit-border-radius: 6px; + -moz-border-radius: 6px; + border-radius: 6px; +} + +.copyToClipBoardBtn { + visibility: hidden; + position: absolute; + width: 24px; + border-radius: 4px; + background-image: var(--clipboard-image); + right: 5px; + top: 13px; + background-color: var(--secondary-background); + padding: 11px; + border: 0; +} + +.copyToClipBoard:hover .copyToClipBoardBtn { + visibility: visible; +} + +.pre-scrollable { + max-height: 340px; + overflow-y: scroll; } + + +/* Nim line-numbered tables */ +.line-nums-table { + width: 100%; + table-layout: fixed; } + +table.line-nums-table { + border-radius: 4px; + border: 1px solid var(--border); + background-color: var(--secondary-background); + border-collapse: separate; + margin-top: 15px; + margin-bottom: 25px; } + +.line-nums-table tbody { + border: none; } + +.line-nums-table td pre { + border: none; + background-color: transparent; } + +.line-nums-table td.blob-line-nums { + width: 28px; } + +.line-nums-table td.blob-line-nums pre { + color: #b0b0b0; + -webkit-filter: opacity(75%); + filter: opacity(75%); + text-align: right; + border-color: transparent; + background-color: transparent; + padding-left: 0px; + margin-left: 0px; + padding-right: 0px; + margin-right: 0px; } + + +table { + max-width: 100%; + background-color: transparent; + margin-top: 0.5em; + margin-bottom: 1.5em; + border-collapse: collapse; + border-color: var(--third-background); + border-spacing: 0; +} + +table:not(.line-nums-table) { + font-size: 0.9em; +} + +table th, table td { + padding: 0px 0.5em 0px; + border-color: var(--third-background); +} + +table th { + background-color: var(--third-background); + border-color: var(--third-background); + font-weight: bold; } + +table th.docinfo-name { + background-color: transparent; + text-align: right; +} + +table:not(.line-nums-table) tr:hover { + background-color: var(--third-background); } + + +/* rst2html default used to remove borders from tables and images */ +.borderless, table.borderless td, table.borderless th { + border: 0; } + +table.borderless td, table.borderless th { + /* Override padding for "table.docutils td" with "! important". + The right padding separates the table cells. */ + padding: 0 0.5em 0 0 !important; } + +.admonition { + padding: 0.3em; + background-color: var(--secondary-background); + border-left: 0.4em solid #7f7f84; + margin-bottom: 0.5em; + -webkit-box-shadow: 0 5px 8px -6px rgba(0,0,0,.2); + -moz-box-shadow: 0 5px 8px -6px rgba(0,0,0,.2); + box-shadow: 0 5px 8px -6px rgba(0,0,0,.2); +} +.admonition-info { + border-color: var(--info-background); +} +.admonition-info-text { + color: var(--info-background); +} +.admonition-warning { + border-color: var(--warning-background); +} +.admonition-warning-text { + color: var(--warning-background); +} +.admonition-error { + border-color: var(--error-background); +} +.admonition-error-text { + color: var(--error-background); +} + +.first { + /* Override more specific margin styles with "! important". */ + margin-top: 0 !important; } + +.last, .with-subtitle { + margin-bottom: 0 !important; } + +.hidden { + display: none; } + +blockquote.epigraph { + margin: 2em 5em; } + +dl.docutils dd { + margin-bottom: 0.5em; } + +object[type="image/svg+xml"], object[type="application/x-shockwave-flash"] { + overflow: hidden; } + + +div.figure { + margin-left: 2em; + margin-right: 2em; } + +div.footer, div.header { + clear: both; + text-align: center; + color: #666; + font-size: smaller; } + +div.footer { + padding-top: 5em; } + +div.line-block { + display: block; + margin-top: 1em; + margin-bottom: 1em; } + +div.line-block div.line-block { + margin-top: 0; + margin-bottom: 0; + margin-left: 1.5em; } + +div.topic { + margin: 2em; } + +div.search_results { + background-color: var(--third-background); + padding: 1em; + border: 1px solid #4d4d4d; + position: sticky; + top: 1em; + isolation: isolate; + max-width: calc(100vw - 6em); + z-index: 1; + max-height: calc(100vh - 6em); + overflow-y: scroll;} + +div#global-links ul { + margin-left: 0; + list-style-type: none; } + +div#global-links > simple-boot { + margin-left: 3em; } + +hr.docutils { + width: 75%; } + +img.align-left, .figure.align-left, object.align-left { + clear: left; + float: left; + margin-right: 1em; } + +img.align-right, .figure.align-right, object.align-right { + clear: right; + float: right; + margin-left: 1em; } + +img.align-center, .figure.align-center, object.align-center { + display: block; + margin-left: auto; + margin-right: auto; } + +.align-left { + text-align: left; } + +.align-center { + clear: both; + text-align: center; } + +.align-right { + text-align: right; } + +/* reset inner alignment in figures */ +div.align-right { + text-align: inherit; } + +p.attribution { + text-align: right; + margin-left: 50%; } + +p.caption { + font-style: italic; } + +p.credits { + font-style: italic; + font-size: smaller; } + +p.label { + white-space: nowrap; } + +p.rubric { + font-weight: bold; + font-size: larger; + color: maroon; + text-align: center; } + +p.topic-title { + font-weight: bold; } + +pre.address { + margin-bottom: 0; + margin-top: 0; + font: inherit; } + +pre.literal-block, pre.doctest-block, pre.math, pre.code { + margin-left: 2em; + margin-right: 2em; } + +pre.code .ln { + color: grey; } + +/* line numbers */ +pre.code, code { + background-color: #eeeeee; } + +pre.code .comment, code .comment { + color: #5c6576; } + +pre.code .keyword, code .keyword { + color: #3B0D06; + font-weight: bold; } + +pre.code .literal.string, code .literal.string { + color: #0c5404; } + +pre.code .name.builtin, code .name.builtin { + color: #352b84; } + +pre.code .deleted, code .deleted { + background-color: #DEB0A1; } + +pre.code .inserted, code .inserted { + background-color: #A3D289; } + +span.classifier { + font-style: oblique; } + +span.classifier-delimiter { + font-weight: bold; } + +span.problematic { + color: #b30000; } + +span.section-subtitle { + /* font-size relative to parent (h1..h6 element) */ + font-size: 80%; } + +span.DecNumber { + color: var(--number); } + +span.BinNumber { + color: var(--number); } + +span.HexNumber { + color: var(--number); } + +span.OctNumber { + color: var(--number); } + +span.FloatNumber { + color: var(--number); } + +span.Identifier { + color: var(--identifier); } + +span.Keyword { + font-weight: 600; + color: var(--keyword); } + +span.StringLit { + color: var(--literal); } + +span.LongStringLit { + color: var(--literal); } + +span.CharLit { + color: var(--literal); } + +span.EscapeSequence { + color: var(--escapeSequence); } + +span.Operator { + color: var(--operator); } + +span.Punctuation { + color: var(--punctuation); } + +span.Comment, span.LongComment { + font-style: italic; + font-weight: 400; + color: var(--comment); } + +span.RegularExpression { + color: darkviolet; } + +span.TagStart { + color: darkviolet; } + +span.TagEnd { + color: darkviolet; } + +span.Key { + color: #252dbe; } + +span.Value { + color: #252dbe; } + +span.RawData { + color: var(--raw-data); } + +span.Assembler { + color: #252dbe; } + +span.Preprocessor { + color: #252dbe; } + +span.Directive { + color: #252dbe; } + +span.option { + font-weight: bold; + font-family: "Source Code Pro", Monaco, Menlo, Consolas, "Courier New", monospace; + color: var(--option); } + +span.Prompt { + font-weight: bold; + color: red; } + +span.ProgramOutput { + font-weight: bold; + color: #808080; } + +span.program { + font-weight: bold; + color: var(--program); + text-decoration: underline; + text-decoration-color: var(--hint); + text-decoration-thickness: 0.05em; + text-underline-offset: 0.15em; } + +span.Command, span.Rule, span.Hyperlink, +span.Label, span.Reference, span.Other { + color: var(--other); } + +/* Pop type, const, proc, and iterator defs in nim def blocks */ +dt pre > span.Identifier, dt pre > span.Operator { + color: var(--identifier); + font-weight: 700; } + +dt pre > span.Keyword ~ span.Identifier, dt pre > span.Identifier ~ span.Identifier, +dt pre > span.Operator ~ span.Identifier, dt pre > span.Other ~ span.Identifier { + color: var(--identifier); + font-weight: inherit; } + +/* Nim sprite for the footer (taken from main page favicon) */ +.nim-sprite { + display: inline-block; + width: 51px; + height: 14px; + background-position: 0 0; + background-size: 51px 14px; + -webkit-filter: opacity(50%); + filter: opacity(50%); + background-repeat: no-repeat; + background-image: var(--nim-sprite-base64); + margin-bottom: 5px; } + +span.pragmadots { + /* Position: relative frees us up to make the dots + look really nice without fucking up the layout and + causing bulging in the parent container */ + position: relative; + /* 1px down looks slightly nicer */ + top: 1px; + padding: 2px; + background-color: var(--third-background); + border-radius: 4px; + margin: 0 2px; + cursor: pointer; + font-size: 0.8em; } + +span.pragmadots:hover { + background-color: var(--hint); } + +span.pragmawrap { + display: none; } + +span.attachedType { + display: none; + visibility: hidden; } diff --git a/Lib/os.html b/Lib/os.html new file mode 100644 index 000000000..3869e3dc4 --- /dev/null +++ b/Lib/os.html @@ -0,0 +1,308 @@ + + + + + + + +src/pylib/Lib/os + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/os

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

see docs.python.org/3/library/os.html

+

Also export everything of std/os

+
Warning: +export of std/os will be removed in 0.10.0
+

+ +
+

Types

+
+
+
uname_result = tuple[sysname, nodename, release, version, machine: PyStr]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
proc cpu_count(): OptionalObj[int] {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc getrandom(size: int; flags = 0): PyBytes {....raises: [], tags: [],
+    forbids: [].}
+
+ +
Admonition: +since Python 3.6
+
Hint: +Availability: linux when have_getrandom_syscall
+ + Source   +Edit   + +
+
+ +
+
+
+
proc process_cpu_count(): OptionalObj[int] {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc uname(): uname_result {....raises: [PyOSError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc urandom(size: int): PyBytes {....raises: [ValueError, NotImplementedError,
+    OSError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template close(p: DirEntry)
+
+ +
Admonition: +since Python 3.6
+ + Source   +Edit   + +
+
+ +
+
+
+
template scandir(): untyped
+
+ +
Admonition: +since Python 3.5
+ + Source   +Edit   + +
+
+
+
template scandir(p: int): untyped
+
+ +
Admonition: +since Python 3.5
+ + Source   +Edit   + +
+
+
+
template scandir[T](p: PathLike[T]): untyped
+
+ +
Admonition: +since Python 3.5
+ + Source   +Edit   + +
+
+ +
+ +
+
+
+

Exports

+
+ normpath, newBlockingIOError, WIFSTOPPED, Py_fstat, chars, osErrorMsgWithPath, O_NOCTTY, fspath, ==, contains, getChar, supports_dir_fd, >=, [], +=, bytes, TimeoutError, osErrorMsgWithPath, altsep, WEXITED, bytes, O_APPEND, raiseExcWithPath, set_inheritable, waitstatus_to_exitcode, closerange, WEXITSTATUS, dirname, link, runes, WSTOPSIG, <=, ==, noWeirdTarget, contains, O_NOATIME, O_WRONLY, TimeNsPair, wrapExportSincePy, bytes, WIFSIGNALED, readlink, ==, split, contains, stat, CanIOOpenT, +, WNOHANG, PyMinor, fchmod, errnoMsg, asVersion, is_file, enter, ConnectionResetError, BlockingIOError, [], newPyOSError, pathrepr, unlink, [], supports_fd, getmtime, $, fspath, raiseErrno, +=, O_PATH, templWrapExportSincePy, PyMajor, or, abspath, Py_fstat_noraise, |=, getcwdb, $, splitdrive, bytes, ChildProcessError, $, toNimString, bytes, walk_symlinks_as_files, +, replace, isfile, newPyOSError, PermissionError, None, relpath, repr, O_ASYNC, [], [], utime, utime, byteLen, getctime, raiseExcWithPath2, splitext, O_DIRECT, toPyStr, exportSincePy, walk, rmdir, name, open, InterruptedError, and, utime, $, basename, WUNTRACED, raiseExcWithPath, getCharPtr, islink, walk, O_DSYNC, exit, raiseErrnoT, str, O_NONBLOCK, FileNotFoundError, repr, issuperset, len, st_atime, O_NDELAY, AttributeError, extsep, listdir, defpath, FileExistsError, toPyStr, asVersion, pysince, RuntimeError, isatty, +, isdir, StringLike, WCOREDUMP, WIFCONTINUED, join, newBlockingIOError, not, contains, $, bytes, remove, OnErrorCb, ==, $, pathrepr, IsADirectoryError, InJs, WNOWAIT, fdopen, or, byteLen, SEEK_HOLE, audit, PyOSError, len, shallIgnore, pysince, raiseExcWithPath, O_RSYNC, ., bytes, tryOsOp, raiseExcWithPath, bytes, symlink, substr, PyBytes, str, makedirs, NoneType, system, getsize, mkdir, getpid, +=, PyReleaseLevel, TimePair, substr, ProcessLookupError, SEEK_END, fdopendir, Serial, BlockingIOError, stat, walk, close, PyOSError, BrokenPipeError, samefile, O_NOFOLLOW, str, O_CLOEXEC, getppid, +, lstat, PySys_Audit, str, st_mtime, pardir, O_TMPFILE, O_TRUNC, O_SYNC, ConnectionError, rename, toNimString, +, rmdir, repr, walk, st_atime_ns, PySerial, stat_result, $, linesep, runeAtPos, st_mtime_ns, asVersion, is_dir, chmod, supports_effective_ids, get_terminal_size, PyOSError, getatime, is_file, wait3, is_junction, O_CREAT, toNimStr, TypeError, WIFEXITED, NameError, truncate, devnull, len, KeyboardInterrupt, str, SEEK_SET, +=, fstat, pybytes, tryOsOp, WSTOPPED, st_ctime_ns, +=, Patch, supports_follow_symlinks, wait4, removedirs, PyReleaseLevelEnum, isabs, items, symlink, substr, PyStr, Minor, NotADirectoryError, umask, NotImplementedError, [], curdir, tryOsOp, [], WCONTINUED, items, WTERMSIG, runeLenAt, Version, contains, is_symlink, BlockingIOError, O_DIRECTORY, toTup, fspath, pathsep, nestListWithFirst, stat, chars, repr, PathLike, get_inheritable, toPyStr, samestat, SEEK_CUR, @, mapPathLike, waitpid, asVersion, not, close, NsUnit, PyPatch, |, pysince, O_RDONLY, raiseErrnoWithPath, getChar, wait, +=, Major, close, getcwd, hasChar, st_ctime, +, +, ftruncate, addaudithook, lseek, WalkRes, ConnectionAbortedError, str, ConnectionRefusedError, SystemExit, tryOsOp, is_dir, items, SEEK_DATA, [], PySys_AddAuditHook, fspath, mapPathLike, ../pyconfig/os_consts, O_RDWR, O_EXCL, join, ReleaseLevel, terminal_size, scandirIter, sep, chdir, ==, unsafeGet, is, expOptObjCvt, unsafeToNone, DirEntry +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/os.idx b/Lib/os.idx new file mode 100644 index 000000000..4e86f1b72 --- /dev/null +++ b/Lib/os.idx @@ -0,0 +1,12 @@ +nimTitle os os.html module src/pylib/Lib/os 0 +nim uname_result os.html#uname_result tuple uname_result 5 +nim uname os.html#uname proc uname(): uname_result 20 +nim scandir os.html#scandir.t template scandir(): untyped 21 +nim scandir os.html#scandir.t,PathLike[T] template scandir[T](p: PathLike[T]): untyped 22 +nim scandir os.html#scandir.t,int template scandir(p: int): untyped 23 +nim close os.html#close.t,DirEntry template close(p: DirEntry) 27 +nim urandom os.html#urandom,int proc urandom(size: int): PyBytes 29 +nim getrandom os.html#getrandom,int,int proc getrandom(size: int; flags = 0): PyBytes 33 +nim cpu_count os.html#cpu_count proc cpu_count(): OptionalObj[int] 53 +nim process_cpu_count os.html#process_cpu_count proc process_cpu_count(): OptionalObj[int] 54 +nimgrp scandir os.html#scandir-templates-all template 21 diff --git a/Lib/os_impl/common.html b/Lib/os_impl/common.html new file mode 100644 index 000000000..67c646ecd --- /dev/null +++ b/Lib/os_impl/common.html @@ -0,0 +1,96 @@ + + + + + + + +src/pylib/Lib/os_impl/common + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/os_impl/common

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Exports

+
+ InJs, asVersion, asVersion, Serial, PySerial, PyReleaseLevelEnum, asVersion, exportSincePy, pysince, Minor, Version, wrapExportSincePy, Major, pysince, PyMinor, pysince, PyReleaseLevel, asVersion, ReleaseLevel, PyMajor, PyPatch, templWrapExportSincePy, Patch, audit, PySys_Audit, addaudithook, PySys_AddAuditHook, PathLike, $, mapPathLike, mapPathLike, $, pathrepr, pathrepr, fspath, CanIOOpenT, fspath, osErrorMsgWithPath, raiseExcWithPath2, ConnectionError, ConnectionResetError, PyOSError, newBlockingIOError, raiseErrnoWithPath, InterruptedError, $, NotADirectoryError, errnoMsg, BrokenPipeError, TimeoutError, raiseExcWithPath, osErrorMsgWithPath, raiseErrno, tryOsOp, ProcessLookupError, IsADirectoryError, raiseExcWithPath, tryOsOp, tryOsOp, BlockingIOError, PyOSError, ConnectionAbortedError, ConnectionRefusedError, FileNotFoundError, BlockingIOError, ChildProcessError, BlockingIOError, noWeirdTarget, PyOSError, newPyOSError, raiseExcWithPath, newPyOSError, PermissionError, raiseErrnoT, FileExistsError, tryOsOp, newBlockingIOError, raiseExcWithPath, AttributeError, TypeError, SystemExit, NameError, NotImplementedError, RuntimeError, KeyboardInterrupt, runeLenAt, not, str, str, toPyStr, contains, substr, byteLen, str, items, StringLike, ==, str, toNimString, +, ==, str, chars, contains, and, getChar, $, len, +=, str, +=, len, toPyStr, PyStr, runes, [], ==, runeAtPos, or, contains, +, toNimStr, fspath, +=, toPyStr, [], [], repr, not, [], or, substr, +=, byteLen, pybytes, ==, toNimString, +, [], bytes, @, chars, len, getChar, $, bytes, bytes, +, +=, bytes, bytes, hasChar, bytes, +, +, items, [], PyBytes, +, substr, fspath, +=, bytes, getCharPtr, bytes, repr, None, NoneType +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/os_impl/common.idx b/Lib/os_impl/common.idx new file mode 100644 index 000000000..aeafcbf38 --- /dev/null +++ b/Lib/os_impl/common.idx @@ -0,0 +1 @@ +nimTitle common os_impl/common.html module src/pylib/Lib/os_impl/common 0 diff --git a/Lib/os_impl/consts.html b/Lib/os_impl/consts.html new file mode 100644 index 000000000..fb3a5db6f --- /dev/null +++ b/Lib/os_impl/consts.html @@ -0,0 +1,438 @@ + + + + + + + +src/pylib/Lib/os_impl/consts + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/os_impl/consts

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

SEEK_* is in ./posix_like/seek_c

+ +
+

Lets

+
+
+
altsep = str '/'
+
+ + + Source   +Edit   + +
+
+
+
curdir = str '.'
+
+ + + Source   +Edit   + +
+
+
+
extsep = str '.'
+
+ + + Source   +Edit   + +
+
+
+
linesep = str("\n")
+
+ + + Source   +Edit   + +
+
+
+
O_APPEND {.importc: "O_APPEND", header: "<fcntl.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
O_CLOEXEC {.importc: "O_CLOEXEC", header: "<fcntl.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
O_CREAT {.importc: "O_CREAT", header: "<fcntl.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
O_DSYNC {.importc: "O_DSYNC", header: "<fcntl.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
O_EXCL {.importc: "O_EXCL", header: "<fcntl.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
O_NDELAY {.importc: "O_NDELAY", header: "<fcntl.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
O_NOCTTY {.importc: "O_NOCTTY", header: "<fcntl.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
O_NONBLOCK {.importc: "O_NONBLOCK", header: "<fcntl.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
O_RDONLY {.importc: "O_RDONLY", header: "<fcntl.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
O_RDWR {.importc: "O_RDWR", header: "<fcntl.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
O_RSYNC {.importc: "O_RSYNC", header: "<fcntl.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
O_SYNC {.importc: "O_SYNC", header: "<fcntl.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
O_TRUNC {.importc: "O_TRUNC", header: "<fcntl.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
O_WRONLY {.importc: "O_WRONLY", header: "<fcntl.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
pardir = str ParDir
+
+ + + Source   +Edit   + +
+
+
+
pathsep = str ':'
+
+ + + Source   +Edit   + +
+
+
+
sep = str '/'
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Consts

+
+
+
defpath: PyStr = "<os-dependent-content>"
+
+ + + Source   +Edit   + +
+
+
+
devnull: PyStr = "<os-dependent-content>"
+
+ + + Source   +Edit   + +
+
+
+
name: PyStr = "<os-dependent-content>"
+
+ + "nt" when windows, "posix" when posix;
Note: +when in neither Windows nor POSIX, os.name will be defined as str(hostOS) iff pylibOsName is defined when compiling
+ + Source   +Edit   + +
+
+ +
+
+
+

Templates

+
+
+
+
template `|`(a, b: cint): cint
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template `|=`(a, b: cint)
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ + +
+
+ + +
+
+ + + diff --git a/Lib/os_impl/consts.idx b/Lib/os_impl/consts.idx new file mode 100644 index 000000000..bb200675e --- /dev/null +++ b/Lib/os_impl/consts.idx @@ -0,0 +1,27 @@ +nimTitle consts os_impl/consts.html module src/pylib/Lib/os_impl/consts 0 +nim curdir os_impl/consts.html#curdir let curdir 15 +nim pardir os_impl/consts.html#pardir let pardir 15 +nim extsep os_impl/consts.html#extsep let extsep 15 +nim pathsep os_impl/consts.html#pathsep let pathsep 15 +nim altsep os_impl/consts.html#altsep let altsep 15 +nim linesep os_impl/consts.html#linesep let linesep 24 +nim sep os_impl/consts.html#sep let sep 25 +nim devnull os_impl/consts.html#devnull const devnull 32 +nim defpath os_impl/consts.html#defpath const defpath 33 +nim name os_impl/consts.html#name const name 34 +nim O_RDONLY os_impl/consts.html#O_RDONLY let O_RDONLY 70 +nim O_WRONLY os_impl/consts.html#O_WRONLY let O_WRONLY 70 +nim O_RDWR os_impl/consts.html#O_RDWR let O_RDWR 70 +nim O_APPEND os_impl/consts.html#O_APPEND let O_APPEND 70 +nim O_CREAT os_impl/consts.html#O_CREAT let O_CREAT 70 +nim O_EXCL os_impl/consts.html#O_EXCL let O_EXCL 70 +nim O_TRUNC os_impl/consts.html#O_TRUNC let O_TRUNC 70 +nim O_DSYNC os_impl/consts.html#O_DSYNC let O_DSYNC 70 +nim O_RSYNC os_impl/consts.html#O_RSYNC let O_RSYNC 70 +nim O_SYNC os_impl/consts.html#O_SYNC let O_SYNC 70 +nim O_NDELAY os_impl/consts.html#O_NDELAY let O_NDELAY 70 +nim O_NONBLOCK os_impl/consts.html#O_NONBLOCK let O_NONBLOCK 70 +nim O_NOCTTY os_impl/consts.html#O_NOCTTY let O_NOCTTY 70 +nim O_CLOEXEC os_impl/consts.html#O_CLOEXEC let O_CLOEXEC 70 +nim `|` os_impl/consts.html#|.t,cint,cint template `|`(a, b: cint): cint 116 +nim `|=` os_impl/consts.html#|=.t,cint,cint template `|=`(a, b: cint) 117 diff --git a/Lib/os_impl/cpus.html b/Lib/os_impl/cpus.html new file mode 100644 index 000000000..513c1e432 --- /dev/null +++ b/Lib/os_impl/cpus.html @@ -0,0 +1,135 @@ + + + + + + + +src/pylib/Lib/os_impl/cpus + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/os_impl/cpus

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
proc cpu_count(): int {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc process_cpu_count(): int {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/os_impl/cpus.idx b/Lib/os_impl/cpus.idx new file mode 100644 index 000000000..d52825ff1 --- /dev/null +++ b/Lib/os_impl/cpus.idx @@ -0,0 +1,3 @@ +nimTitle cpus os_impl/cpus.html module src/pylib/Lib/os_impl/cpus 0 +nim cpu_count os_impl/cpus.html#cpu_count proc cpu_count(): int 10 +nim process_cpu_count os_impl/cpus.html#process_cpu_count proc process_cpu_count(): int 22 diff --git a/Lib/os_impl/have_functions.html b/Lib/os_impl/have_functions.html new file mode 100644 index 000000000..3767bc277 --- /dev/null +++ b/Lib/os_impl/have_functions.html @@ -0,0 +1,487 @@ + + + + + + + +src/pylib/Lib/os_impl/have_functions + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/os_impl/have_functions

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Consts

+
+
+
supports_dir_fd = (data: [(0, ""), (0, ""), (-5621059606328173438, "chmod"),
+                          (0, ""), (0, ""), (0, ""), (0, ""), (0, ""), (0, ""),
+                          (0, ""), (0, ""), (0, ""), (0, ""), (0, ""), (0, ""),
+                          (0, ""), (0, ""), (0, ""), (0, ""), (0, ""), (0, ""),
+                          (0, ""), (-8228877975097993322, "stat"), (0, ""),
+                          (0, ""), (0, ""), (0, ""),
+                          (-4711118966769550309, "rmdir"), (0, ""), (0, ""),
+                          (0, ""), (0, ""), (0, ""), (0, ""), (0, ""), (0, ""),
+                          (0, ""), (0, ""), (0, ""), (0, ""), (0, ""), (0, ""),
+                          (0, ""), (0, ""), (0, ""), (0, ""), (0, ""), (0, ""),
+                          (0, ""), (0, ""), (0, ""), (0, ""), (0, ""), (0, ""),
+                          (0, ""), (0, ""), (0, ""), (0, ""), (0, ""), (0, ""),
+                          (2912131129587157308, "unlink"),
+                          (-8854294602768111171, "open"), (0, ""), (0, ""),
+                          (0, ""), (0, ""), (0, ""), (0, ""), (0, ""), (0, ""),
+                          (0, ""), (0, ""), (0, ""), (0, ""), (0, ""), (0, ""),
+                          (0, ""), (0, ""), (0, ""), (0, ""), (0, ""), (0, ""),
+                          (0, ""), (0, ""), (0, ""), (0, ""), (0, ""), (0, ""),
+                          (0, ""), (0, ""), (0, ""), (0, ""), (0, ""), (0, ""),
+                          (0, ""), (0, ""), (0, ""), (0, ""), (0, ""), (0, ""),
+                          (0, ""), (0, ""), (0, ""), (0, ""), (0, ""), (0, ""),
+                          (0, ""), (0, ""), (0, ""), (0, ""), (0, ""), (0, ""),
+                          (0, ""), (0, ""), (0, ""), (0, ""), (0, ""), (0, ""),
+                          (0, ""), (0, ""), (0, ""), (0, ""), (0, ""), (0, ""),
+                          (0, ""), (0, ""), (0, ""), (0, "")], counter: 5)
+
+ + + Source   +Edit   + +
+
+
+
supports_effective_ids = (data: [(0, ""), (0, ""), (0, ""), (0, ""), (0, ""),
+                                 (0, ""), (0, ""), (0, ""), (0, ""), (0, ""),
+                                 (0, ""), (0, ""), (0, ""), (0, ""), (0, ""),
+                                 (0, ""), (0, ""), (0, ""), (0, ""), (0, ""),
+                                 (0, ""), (0, ""), (0, ""), (0, ""), (0, ""),
+                                 (0, ""), (0, ""), (0, ""), (0, ""), (0, ""),
+                                 (0, ""), (0, ""), (0, ""), (0, ""), (0, ""),
+                                 (0, ""), (0, ""), (0, ""), (0, ""), (0, ""),
+                                 (0, ""), (0, ""), (0, ""), (0, ""), (0, ""),
+                                 (0, ""), (0, ""), (0, ""), (0, ""), (0, ""),
+                                 (0, ""), (0, ""), (0, ""), (0, ""), (0, ""),
+                                 (0, ""), (0, ""), (0, ""), (0, ""), (0, ""),
+                                 (0, ""), (0, ""), (0, ""), (0, ""), (0, ""),
+                                 (0, ""), (0, ""), (0, ""), (0, ""), (0, ""),
+                                 (0, ""), (0, ""), (0, ""), (0, ""), (0, ""),
+                                 (0, ""), (0, ""), (0, ""), (0, ""), (0, ""),
+                                 (0, ""), (0, ""), (0, ""), (0, ""), (0, ""),
+                                 (0, ""), (0, ""), (0, ""), (0, ""), (0, ""),
+                                 (0, ""), (0, ""), (0, ""), (0, ""), (0, ""),
+                                 (0, ""), (0, ""), (0, ""), (0, ""), (0, ""),
+                                 (0, ""), (0, ""), (0, ""), (0, ""), (0, ""),
+                                 (0, ""), (0, ""), (0, ""), (0, ""), (0, ""),
+                                 (0, ""), (0, ""), (0, ""), (0, ""), (0, ""),
+                                 (0, ""), (0, ""), (0, ""), (0, ""), (0, ""),
+                                 (0, ""), (0, ""), (0, ""), (0, ""), (0, ""),
+                                 (0, ""), (0, ""), (0, "")], counter: 0)
+
+ + + Source   +Edit   + +
+
+
+
supports_fd = (data: [(0, ""), (0, ""), (-5621059606328173438, "chmod"),
+                      (0, ""), (0, ""), (0, ""), (0, ""), (0, ""), (0, ""),
+                      (0, ""), (0, ""), (0, ""), (0, ""), (0, ""), (0, ""),
+                      (0, ""), (0, ""), (0, ""), (0, ""), (0, ""), (0, ""),
+                      (0, ""), (-8228877975097993322, "stat"), (0, ""),
+                      (0, ""), (0, ""), (0, ""), (0, ""), (0, ""), (0, ""),
+                      (0, ""), (0, ""), (0, ""), (0, ""), (0, ""), (0, ""),
+                      (0, ""), (0, ""), (0, ""), (0, ""), (0, ""), (0, ""),
+                      (0, ""), (0, ""), (0, ""), (0, ""), (0, ""), (0, ""),
+                      (0, ""), (0, ""), (0, ""), (0, ""), (0, ""), (0, ""),
+                      (0, ""), (0, ""), (0, ""), (0, ""), (0, ""), (0, ""),
+                      (0, ""), (0, ""), (0, ""), (0, ""), (0, ""), (0, ""),
+                      (0, ""), (0, ""), (0, ""), (0, ""), (0, ""), (0, ""),
+                      (0, ""), (0, ""), (0, ""), (0, ""), (0, ""), (0, ""),
+                      (0, ""), (0, ""), (0, ""), (0, ""), (0, ""), (0, ""),
+                      (0, ""), (0, ""), (0, ""), (0, ""), (0, ""), (0, ""),
+                      (0, ""), (0, ""), (0, ""), (0, ""), (0, ""), (0, ""),
+                      (0, ""), (0, ""), (0, ""), (0, ""), (0, ""), (0, ""),
+                      (0, ""), (-8294136327585020825, "truncate"), (0, ""),
+                      (0, ""), (6400877751686740842, "scandir"), (0, ""),
+                      (0, ""), (0, ""), (0, ""), (0, ""), (0, ""), (0, ""),
+                      (0, ""), (0, ""), (0, ""), (0, ""), (0, ""), (0, ""),
+                      (0, ""), (0, ""), (0, ""), (0, ""), (0, ""), (0, ""),
+                      (0, ""), (0, "")], counter: 4)
+
+ + + Source   +Edit   + +
+
+ + +
+
+
+

Procs

+
+
+
+
proc `$`(s: HaveFunc): string {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Macros

+
+
+
+
macro contains(s: HaveFunc; fns: varargs[untyped]): bool
+
+ + used for {xxx, ...} <= s + Source   +Edit   + +
+
+ +
+
+
+
macro issuperset(s: HaveFunc; fns: untyped): bool
+
+ + used for {xxx, ...} <= s + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template `<=`(fns: untyped; s: HaveFunc): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template `>=`(s: HaveFunc; fns): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template contains(s: HaveFunc; fn: untyped): bool
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/os_impl/have_functions.idx b/Lib/os_impl/have_functions.idx new file mode 100644 index 000000000..b682a1ba4 --- /dev/null +++ b/Lib/os_impl/have_functions.idx @@ -0,0 +1,11 @@ +nimTitle have_functions os_impl/have_functions.html module src/pylib/Lib/os_impl/have_functions 0 +nim `$` os_impl/have_functions.html#$,HaveFunc proc `$`(s: HaveFunc): string 19 +nim contains os_impl/have_functions.html#contains.t,HaveFunc,untyped template contains(s: HaveFunc; fn: untyped): bool 38 +nim contains os_impl/have_functions.html#contains.m,HaveFunc,varargs[untyped] macro contains(s: HaveFunc; fns: varargs[untyped]): bool 50 +nim issuperset os_impl/have_functions.html#issuperset.m,HaveFunc,untyped macro issuperset(s: HaveFunc; fns: untyped): bool 54 +nim `>=` os_impl/have_functions.html#>=.t,HaveFunc, template `>=`(s: HaveFunc; fns): bool 58 +nim `<=` os_impl/have_functions.html#<=.t,untyped,HaveFunc template `<=`(fns: untyped; s: HaveFunc): bool 63 +nim supports_dir_fd os_impl/have_functions.html#supports_dir_fd const supports_dir_fd 83 +nim supports_effective_ids os_impl/have_functions.html#supports_effective_ids const supports_effective_ids 83 +nim supports_fd os_impl/have_functions.html#supports_fd const supports_fd 83 +nim supports_follow_symlinks os_impl/have_functions.html#supports_follow_symlinks const supports_follow_symlinks 83 diff --git a/Lib/os_impl/inheritable.html b/Lib/os_impl/inheritable.html new file mode 100644 index 000000000..464157e7e --- /dev/null +++ b/Lib/os_impl/inheritable.html @@ -0,0 +1,211 @@ + + + + + + + +src/pylib/Lib/os_impl/inheritable + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/os_impl/inheritable

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
proc get_handle_inheritable(handle: int): bool {....raises: [], tags: [],
+    forbids: [].}
+
+ +
Hint: +Availability: windows
+ + Source   +Edit   + +
+
+ +
+
+
+
proc get_inheritable(fd: int): bool {....raises: [PyOSError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc Py_set_inheritable(fd: int; inheritable: bool; atomic_flag_works: ptr int): int {.
+    ...raises: [PyOSError], tags: [WriteIOEffect], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc set_handle_inheritable(handle: int; inheritable: bool) {....raises: [],
+    tags: [], forbids: [].}
+
+ +
Hint: +Availability: windows
+ + Source   +Edit   + +
+
+ +
+
+
+
proc set_inheritable(fd: int; inheritable: int | bool)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc set_inheritableImpl(fd: int; inheritable: bool) {....raises: [PyOSError],
+    tags: [WriteIOEffect], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/os_impl/inheritable.idx b/Lib/os_impl/inheritable.idx new file mode 100644 index 000000000..89cb98dba --- /dev/null +++ b/Lib/os_impl/inheritable.idx @@ -0,0 +1,7 @@ +nimTitle inheritable os_impl/inheritable.html module src/pylib/Lib/os_impl/inheritable 0 +nim get_handle_inheritable os_impl/inheritable.html#get_handle_inheritable,int proc get_handle_inheritable(handle: int): bool 51 +nim set_handle_inheritable os_impl/inheritable.html#set_handle_inheritable,int,bool proc set_handle_inheritable(handle: int; inheritable: bool) 54 +nim get_inheritable os_impl/inheritable.html#get_inheritable,int proc get_inheritable(fd: int): bool 69 +nim Py_set_inheritable os_impl/inheritable.html#Py_set_inheritable,int,bool,ptr.int proc Py_set_inheritable(fd: int; inheritable: bool; atomic_flag_works: ptr int): int 178 +nim set_inheritableImpl os_impl/inheritable.html#set_inheritableImpl,int,bool proc set_inheritableImpl(fd: int; inheritable: bool) 182 +nim set_inheritable os_impl/inheritable.html#set_inheritable,int, proc set_inheritable(fd: int; inheritable: int | bool) 186 diff --git a/Lib/os_impl/listcommon.html b/Lib/os_impl/listcommon.html new file mode 100644 index 000000000..1f8e0b3ef --- /dev/null +++ b/Lib/os_impl/listcommon.html @@ -0,0 +1,96 @@ + + + + + + + +src/pylib/Lib/os_impl/listcommon + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/os_impl/listcommon

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+ +
+ + +
+
+ + + diff --git a/Lib/os_impl/listcommon.idx b/Lib/os_impl/listcommon.idx new file mode 100644 index 000000000..9eada776b --- /dev/null +++ b/Lib/os_impl/listcommon.idx @@ -0,0 +1 @@ +nimTitle listcommon os_impl/listcommon.html module src/pylib/Lib/os_impl/listcommon 0 diff --git a/Lib/os_impl/listdirx.html b/Lib/os_impl/listdirx.html new file mode 100644 index 000000000..bb91f3cb2 --- /dev/null +++ b/Lib/os_impl/listdirx.html @@ -0,0 +1,118 @@ + + + + + + + +src/pylib/Lib/os_impl/listdirx + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/os_impl/listdirx

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
proc listdir[T](p: PathLike[T] = "."): PyList[T]
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/os_impl/listdirx.idx b/Lib/os_impl/listdirx.idx new file mode 100644 index 000000000..798e1e16a --- /dev/null +++ b/Lib/os_impl/listdirx.idx @@ -0,0 +1,2 @@ +nimTitle listdirx os_impl/listdirx.html module src/pylib/Lib/os_impl/listdirx 0 +nim listdir os_impl/listdirx.html#listdir,PathLike[T] proc listdir[T](p: PathLike[T] = "."): PyList[T] 6 diff --git a/Lib/os_impl/path.html b/Lib/os_impl/path.html new file mode 100644 index 000000000..3414bce7e --- /dev/null +++ b/Lib/os_impl/path.html @@ -0,0 +1,476 @@ + + + + + + + +src/pylib/Lib/os_impl/path + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/os_impl/path

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
proc abspath[T](s: PathLike[T]): T
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func basename[T](s: PathLike[T]): T
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func dirname[T](s: PathLike[T]): T
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc getatime[T](p: PathLike[T]): float
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc getctime[T](p: PathLike[T]): float
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc getmtime[T](p: PathLike[T]): float
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc getsize[T](filename: PathLike[T]): int
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func isabs(s: PathLike): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc isdir(s: PathLike): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc isfile(s: PathLike): bool
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
proc nestListWithFirst(op: NimNode; pack: NimNode; first: NimNode): NimNode {.
+    ...raises: [], tags: [], forbids: [].}
+
+ + [a, b, c] is transformed into op(first, op(a, op(c, d))). note this differs macros.nestList + Source   +Edit   + +
+
+ +
+
+
+
proc normpath[T](s: PathLike[T]): T
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func relpath[T](p: PathLike[T]; start = curdir): T
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func samefile(a, b: PathLike): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc samestat(s1, s2: stat_result): bool {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func split[T](p: PathLike[T]): (T, T)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func splitdrive[T](p: PathLike[T]): (T, T)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func splitext[T](p: PathLike[T]): (T, T)
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Macros

+
+
+
+
macro join[T: PyStr | PyBytes](a: T; ps: varargs[T]): T
+
+ + + Source   +Edit   + +
+
+
+
macro join[T](a: PathLike[T]; ps: varargs[PathLike[T]]): T
+
+ + ..warning:: NIM-BUG: Currently this variant may fail to compile with Error: type mismatch + Source   +Edit   + +
+
+ +
+ +
+
+
+

Exports

+
+ fspath, substr, ==, str, getChar, [], +=, $, bytes, TimeoutError, +=, exportSincePy, osErrorMsgWithPath, substr, ProcessLookupError, raiseExcWithPath, tryOsOp, mapPathLike, Serial, BlockingIOError, runes, ==, None, noWeirdTarget, str, Version, +, wrapExportSincePy, bytes, PySys_Audit, ==, NoneType, str, CanIOOpenT, +, PyMinor, asVersion, templWrapExportSincePy, contains, ConnectionResetError, BlockingIOError, toNimString, +, [], repr, pathrepr, PermissionError, PySerial, errnoMsg, runeAtPos, asVersion, fspath, raiseErrno, +=, +=, PyMajor, $, or, tryOsOp, PyOSError, ConnectionError, chars, PyBytes, ChildProcessError, bytes, tryOsOp, TypeError, repr, NameError, toNimString, bytes, +, len, KeyboardInterrupt, str, newPyOSError, [], NotImplementedError, +=, SystemExit, pybytes, toNimStr, newPyOSError, getCharPtr, [], Patch, [], osErrorMsgWithPath, byteLen, raiseExcWithPath2, PyReleaseLevelEnum, AttributeError, PyReleaseLevel, substr, PyStr, Minor, and, $, NotADirectoryError, BrokenPipeError, toPyStr, raiseExcWithPath, [], items, PyOSError, runeLenAt, raiseErrnoT, str, FileNotFoundError, BlockingIOError, newBlockingIOError, chars, PathLike, len, IsADirectoryError, toPyStr, @, contains, FileExistsError, toPyStr, asVersion, asVersion, pysince, not, RuntimeError, PyPatch, InterruptedError, PySys_AddAuditHook, pysince, newBlockingIOError, not, raiseErrnoWithPath, contains, getChar, $, bytes, +=, Major, hasChar, ==, +, +, pathrepr, $, InJs, addaudithook, ConnectionAbortedError, str, ConnectionRefusedError, or, tryOsOp, byteLen, items, StringLike, audit, PyOSError, fspath, len, mapPathLike, pysince, raiseExcWithPath, bytes, +, ReleaseLevel, fspath, raiseExcWithPath, bytes, bytes, O_DIRECTORY, O_TMPFILE, O_SYNC, O_DIRECT, O_NONBLOCK, O_TRUNC, O_NOCTTY, O_EXCL, O_CREAT, O_DSYNC, |, name, O_RDONLY, pathsep, O_NOFOLLOW, O_NOATIME, O_CLOEXEC, O_WRONLY, O_APPEND, |=, O_NDELAY, ../../pyconfig/os_consts, O_RSYNC, curdir, extsep, linesep, devnull, defpath, O_RDWR, altsep, sep, O_ASYNC, O_PATH, pardir +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/os_impl/path.idx b/Lib/os_impl/path.idx new file mode 100644 index 000000000..dd6a960df --- /dev/null +++ b/Lib/os_impl/path.idx @@ -0,0 +1,23 @@ +nimTitle path os_impl/path.html module src/pylib/Lib/os_impl/path 0 +nim isabs os_impl/path.html#isabs,PathLike proc isabs(s: PathLike): bool 37 +nim isfile os_impl/path.html#isfile,PathLike proc isfile(s: PathLike): bool 38 +nim isdir os_impl/path.html#isdir,PathLike proc isdir(s: PathLike): bool 39 +nim islink os_impl/path.html#islink,PathLike proc islink(s: PathLike): bool 40 +nim dirname os_impl/path.html#dirname,PathLike[T] proc dirname[T](s: PathLike[T]): T 42 +nim basename os_impl/path.html#basename,PathLike[T] proc basename[T](s: PathLike[T]): T 44 +nim abspath os_impl/path.html#abspath,PathLike[T] proc abspath[T](s: PathLike[T]): T 46 +nim normpath os_impl/path.html#normpath,PathLike[T] proc normpath[T](s: PathLike[T]): T 47 +nim relpath os_impl/path.html#relpath,PathLike[T] proc relpath[T](p: PathLike[T]; start = curdir): T 49 +nim getctime os_impl/path.html#getctime,PathLike[T] proc getctime[T](p: PathLike[T]): float 59 +nim getmtime os_impl/path.html#getmtime,PathLike[T] proc getmtime[T](p: PathLike[T]): float 60 +nim getatime os_impl/path.html#getatime,PathLike[T] proc getatime[T](p: PathLike[T]): float 61 +nim getsize os_impl/path.html#getsize,PathLike[T] proc getsize[T](filename: PathLike[T]): int 63 +nim samefile os_impl/path.html#samefile,PathLike,PathLike proc samefile(a, b: PathLike): bool 67 +nim split os_impl/path.html#split,PathLike[T] proc split[T](p: PathLike[T]): (T, T) 75 +nim splitdrive os_impl/path.html#splitdrive,PathLike[T] proc splitdrive[T](p: PathLike[T]): (T, T) 76 +nim splitext os_impl/path.html#splitext,PathLike[T] proc splitext[T](p: PathLike[T]): (T, T) 79 +nim nestListWithFirst os_impl/path.html#nestListWithFirst,NimNode,NimNode,NimNode proc nestListWithFirst(op: NimNode; pack: NimNode; first: NimNode): NimNode 94 +nim join os_impl/path.html#join.m,PathLike[T],varargs[PathLike[T]] macro join[T](a: PathLike[T]; ps: varargs[PathLike[T]]): T 105 +nim join os_impl/path.html#join.m,T,varargs[T] macro join[T: PyStr | PyBytes](a: T; ps: varargs[T]): T 110 +nim samestat os_impl/path.html#samestat,stat_result,stat_result proc samestat(s1, s2: stat_result): bool 113 +nimgrp join os_impl/path.html#join-macros-all macro 105 diff --git a/Lib/os_impl/posix_like.html b/Lib/os_impl/posix_like.html new file mode 100644 index 000000000..bf259ba30 --- /dev/null +++ b/Lib/os_impl/posix_like.html @@ -0,0 +1,96 @@ + + + + + + + +src/pylib/Lib/os_impl/posix_like + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/os_impl/posix_like

+ + + +
+
+ + + diff --git a/Lib/os_impl/posix_like.idx b/Lib/os_impl/posix_like.idx new file mode 100644 index 000000000..98c319847 --- /dev/null +++ b/Lib/os_impl/posix_like.idx @@ -0,0 +1 @@ +nimTitle posix_like os_impl/posix_like.html module src/pylib/Lib/os_impl/posix_like 0 diff --git a/Lib/os_impl/posix_like/chkarg.html b/Lib/os_impl/posix_like/chkarg.html new file mode 100644 index 000000000..ea25ce78d --- /dev/null +++ b/Lib/os_impl/posix_like/chkarg.html @@ -0,0 +1,327 @@ + + + + + + + +src/pylib/Lib/os_impl/posix_like/chkarg + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/os_impl/posix_like/chkarg

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
proc argument_unavailable_error(argument_name: string) {.
+    ...raises: [NotImplementedError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc argument_unavailable_error(function_name: string; argument_name: string) {.
+    ...raises: [NotImplementedError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc dir_fdandfdinvalid(function_name: string; dir_fd: int; fd: int): bool {.
+    discardable, ...raises: [ValueError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc dir_fdandfollow_symlinksinvalid(function_name: string; dir_fd: int;
+                                     follow_symlinks: bool): bool {.discardable,
+    ...raises: [ValueError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc fdandfollow_symlinksinvalid(function_name: string; fd: int;
+                                 follow_symlinks: bool): bool {.discardable,
+    ...raises: [ValueError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
proc pathanddir_fdinvalid(function_name: string; path: Path; dir_fd: int): bool {.
+    discardable.}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template dir_fdandfdinvalid(dir_fd; fd): untyped {.dirty.}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template dir_fdandfollow_symlinksinvalid(dir_fd; follow_symlinks): untyped {.
+    dirty.}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template fdandfollow_symlinksinvalid(fd; follow_symlinks): untyped {.dirty.}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
template pathanddir_fdinvalid(path; dir_fd): untyped {.dirty.}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/os_impl/posix_like/chkarg.idx b/Lib/os_impl/posix_like/chkarg.idx new file mode 100644 index 000000000..6c69d8116 --- /dev/null +++ b/Lib/os_impl/posix_like/chkarg.idx @@ -0,0 +1,14 @@ +nimTitle chkarg os_impl/posix_like/chkarg.html module src/pylib/Lib/os_impl/posix_like/chkarg 0 +nim argument_unavailable_error os_impl/posix_like/chkarg.html#argument_unavailable_error,string,string proc argument_unavailable_error(function_name: string; argument_name: string) 19 +nim argument_unavailable_error os_impl/posix_like/chkarg.html#argument_unavailable_error,string proc argument_unavailable_error(argument_name: string) 27 +nim follow_symlinks_specified os_impl/posix_like/chkarg.html#follow_symlinks_specified,string, proc follow_symlinks_specified(function_name: string; follow_symlinks: bool): bool 39 +nim follow_symlinks_specified os_impl/posix_like/chkarg.html#follow_symlinks_specified.t,bool template follow_symlinks_specified(follow_symlinks: bool): untyped 45 +nim pathanddir_fdinvalid os_impl/posix_like/chkarg.html#pathanddir_fdinvalid,string,, proc pathanddir_fdinvalid(function_name: string; path: Path; dir_fd: int): bool 59 +nim pathanddir_fdinvalid os_impl/posix_like/chkarg.html#pathanddir_fdinvalid.t,, template pathanddir_fdinvalid(path; dir_fd): untyped 73 +nim dir_fdandfdinvalid os_impl/posix_like/chkarg.html#dir_fdandfdinvalid,string,, proc dir_fdandfdinvalid(function_name: string; dir_fd: int; fd: int): bool 59 +nim dir_fdandfdinvalid os_impl/posix_like/chkarg.html#dir_fdandfdinvalid.t,, template dir_fdandfdinvalid(dir_fd; fd): untyped 74 +nim fdandfollow_symlinksinvalid os_impl/posix_like/chkarg.html#fdandfollow_symlinksinvalid,string,, proc fdandfollow_symlinksinvalid(function_name: string; fd: int;\n follow_symlinks: bool): bool 59 +nim fdandfollow_symlinksinvalid os_impl/posix_like/chkarg.html#fdandfollow_symlinksinvalid.t,, template fdandfollow_symlinksinvalid(fd; follow_symlinks): untyped 75 +nim dir_fdandfollow_symlinksinvalid os_impl/posix_like/chkarg.html#dir_fdandfollow_symlinksinvalid,string,, proc dir_fdandfollow_symlinksinvalid(function_name: string; dir_fd: int;\n follow_symlinks: bool): bool 59 +nim dir_fdandfollow_symlinksinvalid os_impl/posix_like/chkarg.html#dir_fdandfollow_symlinksinvalid.t,, template dir_fdandfollow_symlinksinvalid(dir_fd; follow_symlinks): untyped 76 +nimgrp argumentunavailableerror os_impl/posix_like/chkarg.html#argument_unavailable_error-procs-all proc 19 diff --git a/Lib/os_impl/posix_like/chmods.html b/Lib/os_impl/posix_like/chmods.html new file mode 100644 index 000000000..4449fc72c --- /dev/null +++ b/Lib/os_impl/posix_like/chmods.html @@ -0,0 +1,144 @@ + + + + + + + +src/pylib/Lib/os_impl/posix_like/chmods + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/os_impl/posix_like/chmods

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
proc chmod(path: (when HAVE_FCHMODAT:
+  string | int
+else:
+  string); mode: int; dir_fd = DEFAULT_DIR_FD; follow_symlinks = not MS_WINDOWS)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc fchmod(fd: int; mode: int) {....raises: [PyOSError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/os_impl/posix_like/chmods.idx b/Lib/os_impl/posix_like/chmods.idx new file mode 100644 index 000000000..74edb401d --- /dev/null +++ b/Lib/os_impl/posix_like/chmods.idx @@ -0,0 +1,3 @@ +nimTitle chmods os_impl/posix_like/chmods.html module src/pylib/Lib/os_impl/posix_like/chmods 0 +nim chmod os_impl/posix_like/chmods.html#chmod,,int proc chmod(path: (when HAVE_FCHMODAT:\n string | int\nelse:\n string); mode: int; dir_fd = DEFAULT_DIR_FD; follow_symlinks = not MS_WINDOWS) 74 +nim fchmod os_impl/posix_like/chmods.html#fchmod,int,int proc fchmod(fd: int; mode: int) 185 diff --git a/Lib/os_impl/posix_like/errnoRaise.html b/Lib/os_impl/posix_like/errnoRaise.html new file mode 100644 index 000000000..4211265b4 --- /dev/null +++ b/Lib/os_impl/posix_like/errnoRaise.html @@ -0,0 +1,96 @@ + + + + + + + +src/pylib/Lib/os_impl/posix_like/errnoRaise + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/os_impl/posix_like/errnoRaise

+ + + +
+
+ + + diff --git a/Lib/os_impl/posix_like/errnoRaise.idx b/Lib/os_impl/posix_like/errnoRaise.idx new file mode 100644 index 000000000..abc2d118c --- /dev/null +++ b/Lib/os_impl/posix_like/errnoRaise.idx @@ -0,0 +1 @@ +nimTitle errnoRaise os_impl/posix_like/errnoRaise.html module src/pylib/Lib/os_impl/posix_like/errnoRaise 0 diff --git a/Lib/os_impl/posix_like/errnoUtils.html b/Lib/os_impl/posix_like/errnoUtils.html new file mode 100644 index 000000000..83e70fa04 --- /dev/null +++ b/Lib/os_impl/posix_like/errnoUtils.html @@ -0,0 +1,96 @@ + + + + + + + +src/pylib/Lib/os_impl/posix_like/errnoUtils + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/os_impl/posix_like/errnoUtils

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ + + +
+
+ + +
+
+ + + diff --git a/Lib/os_impl/posix_like/errnoUtils.idx b/Lib/os_impl/posix_like/errnoUtils.idx new file mode 100644 index 000000000..3927c2934 --- /dev/null +++ b/Lib/os_impl/posix_like/errnoUtils.idx @@ -0,0 +1 @@ +nimTitle errnoUtils os_impl/posix_like/errnoUtils.html module src/pylib/Lib/os_impl/posix_like/errnoUtils 0 diff --git a/Lib/os_impl/posix_like/fdopen.html b/Lib/os_impl/posix_like/fdopen.html new file mode 100644 index 000000000..e930daf05 --- /dev/null +++ b/Lib/os_impl/posix_like/fdopen.html @@ -0,0 +1,109 @@ + + + + + + + +src/pylib/Lib/os_impl/posix_like/fdopen + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/os_impl/posix_like/fdopen

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

this module depends on io module

+
+

Templates

+
+
+
+
template fdopen(fd: Positive; x: varargs[untyped]): untyped
+
+ + not support JS/NimScript backend + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/os_impl/posix_like/fdopen.idx b/Lib/os_impl/posix_like/fdopen.idx new file mode 100644 index 000000000..9227cb79e --- /dev/null +++ b/Lib/os_impl/posix_like/fdopen.idx @@ -0,0 +1,2 @@ +nimTitle fdopen os_impl/posix_like/fdopen.html module src/pylib/Lib/os_impl/posix_like/fdopen 0 +nim fdopen os_impl/posix_like/fdopen.html#fdopen.t,Positive,varargs[untyped] template fdopen(fd: Positive; x: varargs[untyped]): untyped 6 diff --git a/Lib/os_impl/posix_like/get_id.html b/Lib/os_impl/posix_like/get_id.html new file mode 100644 index 000000000..7d75349a5 --- /dev/null +++ b/Lib/os_impl/posix_like/get_id.html @@ -0,0 +1,126 @@ + + + + + + + +src/pylib/Lib/os_impl/posix_like/get_id + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/os_impl/posix_like/get_id

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Procs

+
+
+
+
proc getpid(): int {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc getppid(): int {....raises: [], tags: [], forbids: [].}
+
+ + Returns the parent's process id. If the parent process has already exited, Windows machines will still return its id; others systems will return the id of the 'init' process (1). + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/os_impl/posix_like/get_id.idx b/Lib/os_impl/posix_like/get_id.idx new file mode 100644 index 000000000..b83e7ed64 --- /dev/null +++ b/Lib/os_impl/posix_like/get_id.idx @@ -0,0 +1,3 @@ +nimTitle get_id os_impl/posix_like/get_id.html module src/pylib/Lib/os_impl/posix_like/get_id 0 +nim getpid os_impl/posix_like/get_id.html#getpid proc getpid(): int 8 +nim getppid os_impl/posix_like/get_id.html#getppid proc getppid(): int 124 diff --git a/Lib/os_impl/posix_like/isatty.html b/Lib/os_impl/posix_like/isatty.html new file mode 100644 index 000000000..cfaa5a1c0 --- /dev/null +++ b/Lib/os_impl/posix_like/isatty.html @@ -0,0 +1,109 @@ + + + + + + + +src/pylib/Lib/os_impl/posix_like/isatty + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/os_impl/posix_like/isatty

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Procs

+
+
+
+
func isatty(fd: int): bool {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/os_impl/posix_like/isatty.idx b/Lib/os_impl/posix_like/isatty.idx new file mode 100644 index 000000000..1436d679c --- /dev/null +++ b/Lib/os_impl/posix_like/isatty.idx @@ -0,0 +1,2 @@ +nimTitle isatty os_impl/posix_like/isatty.html module src/pylib/Lib/os_impl/posix_like/isatty 0 +nim isatty os_impl/posix_like/isatty.html#isatty,int proc isatty(fd: int): bool 11 diff --git a/Lib/os_impl/posix_like/links.html b/Lib/os_impl/posix_like/links.html new file mode 100644 index 000000000..4fb2c30fc --- /dev/null +++ b/Lib/os_impl/posix_like/links.html @@ -0,0 +1,163 @@ + + + + + + + +src/pylib/Lib/os_impl/posix_like/links + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/os_impl/posix_like/links

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Imports

+
+ ../common +
+
+
+

Procs

+
+ + + + +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/os_impl/posix_like/links.idx b/Lib/os_impl/posix_like/links.idx new file mode 100644 index 000000000..0e370159a --- /dev/null +++ b/Lib/os_impl/posix_like/links.idx @@ -0,0 +1,6 @@ +nimTitle links os_impl/posix_like/links.html module src/pylib/Lib/os_impl/posix_like/links 0 +nim readlink os_impl/posix_like/links.html#readlink,PathLike[T] proc readlink[T](path: PathLike[T]): T 241 +nim symlink os_impl/posix_like/links.html#symlink,PathLike[T],PathLike[T],int proc symlink[T](src, dst: PathLike[T]; target_is_directory = false; dir_fd: int) 300 +nim symlink os_impl/posix_like/links.html#symlink,PathLike[T],PathLike[T] proc symlink[T](src, dst: PathLike[T]; target_is_directory = false) 315 +nim link os_impl/posix_like/links.html#link,PathLike[T],PathLike[T] proc link[T](src, dst: PathLike[T]) 319 +nimgrp symlink os_impl/posix_like/links.html#symlink-procs-all proc 300 diff --git a/Lib/os_impl/posix_like/lseek.html b/Lib/os_impl/posix_like/lseek.html new file mode 100644 index 000000000..ae0beec4d --- /dev/null +++ b/Lib/os_impl/posix_like/lseek.html @@ -0,0 +1,121 @@ + + + + + + + +src/pylib/Lib/os_impl/posix_like/lseek + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/os_impl/posix_like/lseek

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
proc lseek(fd: int; position: int64; whence: int): int64 {....raises: [PyOSError],
+    tags: [], forbids: [].}
+
+ +
Hint: +not available in JavaScript, NimScript backend
+ + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/os_impl/posix_like/lseek.idx b/Lib/os_impl/posix_like/lseek.idx new file mode 100644 index 000000000..567aa048a --- /dev/null +++ b/Lib/os_impl/posix_like/lseek.idx @@ -0,0 +1,2 @@ +nimTitle lseek os_impl/posix_like/lseek.html module src/pylib/Lib/os_impl/posix_like/lseek 0 +nim lseek os_impl/posix_like/lseek.html#lseek,int,int64,int proc lseek(fd: int; position: int64; whence: int): int64 14 diff --git a/Lib/os_impl/posix_like/mkrmdir.html b/Lib/os_impl/posix_like/mkrmdir.html new file mode 100644 index 000000000..163e75f24 --- /dev/null +++ b/Lib/os_impl/posix_like/mkrmdir.html @@ -0,0 +1,158 @@ + + + + + + + +src/pylib/Lib/os_impl/posix_like/mkrmdir + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/os_impl/posix_like/mkrmdir

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
proc mkdir(p: PathLike; mode = 0o000000000777)
+
+ + + Source   +Edit   + +
+
+
+
proc mkdir(p: PathLike; mode = 0o000000000777; dir_fd: int) {.
+    error: "not implement".}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc rmdir(p: PathLike; dir_fd: int)
+
+ + + Source   +Edit   + +
+
+
+
proc rmdir(path: PathLike)
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/os_impl/posix_like/mkrmdir.idx b/Lib/os_impl/posix_like/mkrmdir.idx new file mode 100644 index 000000000..d4766d7b9 --- /dev/null +++ b/Lib/os_impl/posix_like/mkrmdir.idx @@ -0,0 +1,7 @@ +nimTitle mkrmdir os_impl/posix_like/mkrmdir.html module src/pylib/Lib/os_impl/posix_like/mkrmdir 0 +nim rmdir os_impl/posix_like/mkrmdir.html#rmdir,PathLike,int proc rmdir(p: PathLike; dir_fd: int) 18 +nim mkdir os_impl/posix_like/mkrmdir.html#mkdir,PathLike,int,int proc mkdir(p: PathLike; mode = 0o000000000777; dir_fd: int) 39 +nim rmdir os_impl/posix_like/mkrmdir.html#rmdir,PathLike proc rmdir(path: PathLike) 41 +nim mkdir os_impl/posix_like/mkrmdir.html#mkdir,PathLike,int proc mkdir(p: PathLike; mode = 0o000000000777) 44 +nimgrp mkdir os_impl/posix_like/mkrmdir.html#mkdir-procs-all proc 39 +nimgrp rmdir os_impl/posix_like/mkrmdir.html#rmdir-procs-all proc 18 diff --git a/Lib/os_impl/posix_like/mkrmdirImpl.html b/Lib/os_impl/posix_like/mkrmdirImpl.html new file mode 100644 index 000000000..dbe92240a --- /dev/null +++ b/Lib/os_impl/posix_like/mkrmdirImpl.html @@ -0,0 +1,137 @@ + + + + + + + +src/pylib/Lib/os_impl/posix_like/mkrmdirImpl + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/os_impl/posix_like/mkrmdirImpl

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Imports

+
+ ../common +
+
+
+

Procs

+
+
+
+
proc rawCreateDir(dp: PathLike; mode = 0o000000000777)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc rawRemoveDir(dp: PathLike)
+
+ +
Hint: +not available in JavaScript, NimScript backend
+ + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/os_impl/posix_like/mkrmdirImpl.idx b/Lib/os_impl/posix_like/mkrmdirImpl.idx new file mode 100644 index 000000000..51ea1e58a --- /dev/null +++ b/Lib/os_impl/posix_like/mkrmdirImpl.idx @@ -0,0 +1,3 @@ +nimTitle mkrmdirImpl os_impl/posix_like/mkrmdirImpl.html module src/pylib/Lib/os_impl/posix_like/mkrmdirImpl 0 +nim rawRemoveDir os_impl/posix_like/mkrmdirImpl.html#rawRemoveDir,PathLike proc rawRemoveDir(dp: PathLike) 27 +nim rawCreateDir os_impl/posix_like/mkrmdirImpl.html#rawCreateDir,PathLike,int proc rawCreateDir(dp: PathLike; mode = 0o000000000777) 39 diff --git a/Lib/os_impl/posix_like/open_close.html b/Lib/os_impl/posix_like/open_close.html new file mode 100644 index 000000000..12b71f64b --- /dev/null +++ b/Lib/os_impl/posix_like/open_close.html @@ -0,0 +1,153 @@ + + + + + + + +src/pylib/Lib/os_impl/posix_like/open_close + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/os_impl/posix_like/open_close

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
proc close(fd: int) {....raises: [PyOSError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc closerange(fd_low, fd_high: int) {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc open(path: PathLike; flags: int; mode = 0o000000000777; dir_fd = -1): int {.
+    ...forbids: [NotImplForNonNode].}
+
+ + dir_fd is ignored under Windows + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/os_impl/posix_like/open_close.idx b/Lib/os_impl/posix_like/open_close.idx new file mode 100644 index 000000000..0ae487807 --- /dev/null +++ b/Lib/os_impl/posix_like/open_close.idx @@ -0,0 +1,4 @@ +nimTitle open_close os_impl/posix_like/open_close.html module src/pylib/Lib/os_impl/posix_like/open_close 0 +nim open os_impl/posix_like/open_close.html#open,PathLike,int,int,int proc open(path: PathLike; flags: int; mode = 0o000000000777; dir_fd = -1): int 62 +nim close os_impl/posix_like/open_close.html#close,int proc close(fd: int) 97 +nim closerange os_impl/posix_like/open_close.html#closerange,int,int proc closerange(fd_low, fd_high: int) 107 diff --git a/Lib/os_impl/posix_like/pyCfg.html b/Lib/os_impl/posix_like/pyCfg.html new file mode 100644 index 000000000..7470f1069 --- /dev/null +++ b/Lib/os_impl/posix_like/pyCfg.html @@ -0,0 +1,127 @@ + + + + + + + +src/pylib/Lib/os_impl/posix_like/pyCfg + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/os_impl/posix_like/pyCfg

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Templates

+
+
+
+
template importConfig(name)
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ + +
+
+ + +
+
+ + + diff --git a/Lib/os_impl/posix_like/pyCfg.idx b/Lib/os_impl/posix_like/pyCfg.idx new file mode 100644 index 000000000..e7a10a2fd --- /dev/null +++ b/Lib/os_impl/posix_like/pyCfg.idx @@ -0,0 +1,2 @@ +nimTitle pyCfg os_impl/posix_like/pyCfg.html module src/pylib/Lib/os_impl/posix_like/pyCfg 0 +nim importConfig os_impl/posix_like/pyCfg.html#importConfig.t template importConfig(name) 2 diff --git a/Lib/os_impl/posix_like/rename.html b/Lib/os_impl/posix_like/rename.html new file mode 100644 index 000000000..24f5fc96a --- /dev/null +++ b/Lib/os_impl/posix_like/rename.html @@ -0,0 +1,135 @@ + + + + + + + +src/pylib/Lib/os_impl/posix_like/rename + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/os_impl/posix_like/rename

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Imports

+
+ ../common +
+
+
+

Procs

+
+
+
+
proc rename[T](src, dst: PathLike[T])
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc replace[T](src, dst: PathLike[T])
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/os_impl/posix_like/rename.idx b/Lib/os_impl/posix_like/rename.idx new file mode 100644 index 000000000..17f5f08c7 --- /dev/null +++ b/Lib/os_impl/posix_like/rename.idx @@ -0,0 +1,3 @@ +nimTitle rename os_impl/posix_like/rename.html module src/pylib/Lib/os_impl/posix_like/rename 0 +nim rename os_impl/posix_like/rename.html#rename,PathLike[T],PathLike[T] proc rename[T](src, dst: PathLike[T]) 18 +nim replace os_impl/posix_like/rename.html#replace,PathLike[T],PathLike[T] proc replace[T](src, dst: PathLike[T]) 23 diff --git a/Lib/os_impl/posix_like/scandirImpl.html b/Lib/os_impl/posix_like/scandirImpl.html new file mode 100644 index 000000000..43b91de41 --- /dev/null +++ b/Lib/os_impl/posix_like/scandirImpl.html @@ -0,0 +1,474 @@ + + + + + + + +src/pylib/Lib/os_impl/posix_like/scandirImpl + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/os_impl/posix_like/scandirImpl

+
+ +
+ Source   +Edit   + +
+ +

+ +
+

Types

+
+
+
DirEntry[T] = ref object of DirEntryImpl[T]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
func close(scandirIter: ScandirIterator)
+
+ + + Source   +Edit   + +
+
+
+
func close(scandirIter: ScandirIterator[int]) {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc fdopendir(fd: cint): ptr DIR {.importc, header: "<dirent.h>", ...raises: [],
+                                    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func is_dir(self: DirEntry): bool
+
+ + follow_symlinks is True on default. + Source   +Edit   + +
+
+
+
func is_dir(self: DirEntry; follow_symlinks: bool): bool
+
+ + result is cached. Python's is cached too. + Source   +Edit   + +
+
+ +
+
+
+
func is_file(self: DirEntry): bool
+
+ + follow_symlinks is True on default. + Source   +Edit   + +
+
+
+
func is_file(self: DirEntry; follow_symlinks: bool): bool
+
+ + result is cached. Python's is cached too. + Source   +Edit   + +
+
+ +
+
+
+
proc is_junction(self: DirEntry): bool
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
func repr(self: DirEntry): string
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc scandir(): ScandirIterator[PyStr] {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc scandir(path: int): ScandirIterator[int] {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc scandir[T](path: PathLike[T]): ScandirIterator[T]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc stat(self: DirEntry; follow_symlinks = true): stat_result
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Iterators

+
+
+
+
iterator items[T](scandirIter: ScandirIterator[T]): DirEntry[T]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
iterator scandir(): DirEntry[PyStr] {....raises: [PyOSError],
+                                      tags: [ReadDirEffect], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
iterator scandir(path: int): DirEntry[int] {....raises: [PyOSError, ValueError],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
iterator scandir[T](path: PathLike[T]): DirEntry[T]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
iterator scandirIter[T](path: T): DirEntry[T] {.closure.}
+
+ + used by os.walk + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template enter(self: ScandirIterator): ScandirIterator
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template exit(self: ScandirIterator; args: varargs[untyped])
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/os_impl/posix_like/scandirImpl.idx b/Lib/os_impl/posix_like/scandirImpl.idx new file mode 100644 index 000000000..4109d9bb0 --- /dev/null +++ b/Lib/os_impl/posix_like/scandirImpl.idx @@ -0,0 +1,28 @@ +nimTitle scandirImpl os_impl/posix_like/scandirImpl.html module src/pylib/Lib/os_impl/posix_like/scandirImpl 0 +nim DirEntry os_impl/posix_like/scandirImpl.html#DirEntry type DirEntry 47 +nim close os_impl/posix_like/scandirImpl.html#close,ScandirIterator proc close(scandirIter: ScandirIterator) 56 +nim close os_impl/posix_like/scandirImpl.html#close,ScandirIterator[int] proc close(scandirIter: ScandirIterator[int]) 57 +nim items os_impl/posix_like/scandirImpl.html#items.i,ScandirIterator[T] iterator items[T](scandirIter: ScandirIterator[T]): DirEntry[T] 61 +nim enter os_impl/posix_like/scandirImpl.html#enter.t,ScandirIterator template enter(self: ScandirIterator): ScandirIterator 65 +nim exit os_impl/posix_like/scandirImpl.html#exit.t,ScandirIterator,varargs[untyped] template exit(self: ScandirIterator; args: varargs[untyped]) 66 +nim repr os_impl/posix_like/scandirImpl.html#repr proc repr(self: DirEntry): string 91 +nim stat os_impl/posix_like/scandirImpl.html#stat proc stat(self: DirEntry; follow_symlinks = true): stat_result 94 +nim is_symlink os_impl/posix_like/scandirImpl.html#is_symlink proc is_symlink(self: DirEntry): bool 132 +nim is_file os_impl/posix_like/scandirImpl.html#is_file proc is_file(self: DirEntry): bool 119 +nim is_file os_impl/posix_like/scandirImpl.html#is_file,,bool proc is_file(self: DirEntry; follow_symlinks: bool): bool 153 +nim is_dir os_impl/posix_like/scandirImpl.html#is_dir proc is_dir(self: DirEntry): bool 119 +nim is_dir os_impl/posix_like/scandirImpl.html#is_dir,,bool proc is_dir(self: DirEntry; follow_symlinks: bool): bool 154 +nim is_junction os_impl/posix_like/scandirImpl.html#is_junction proc is_junction(self: DirEntry): bool 156 +nim fdopendir os_impl/posix_like/scandirImpl.html#fdopendir,cint proc fdopendir(fd: cint): ptr DIR 170 +nim scandir os_impl/posix_like/scandirImpl.html#scandir.i,PathLike[T] iterator scandir[T](path: PathLike[T]): DirEntry[T] 255 +nim scandir os_impl/posix_like/scandirImpl.html#scandir.i,int iterator scandir(path: int): DirEntry[int] 256 +nim scandirIter os_impl/posix_like/scandirImpl.html#scandirIter.i,T iterator scandirIter[T](path: T): DirEntry[T] 259 +nim scandir os_impl/posix_like/scandirImpl.html#scandir.i iterator scandir(): DirEntry[PyStr] 263 +nim scandir os_impl/posix_like/scandirImpl.html#scandir,PathLike[T] proc scandir[T](path: PathLike[T]): ScandirIterator[T] 272 +nim scandir os_impl/posix_like/scandirImpl.html#scandir,int proc scandir(path: int): ScandirIterator[int] 274 +nim scandir os_impl/posix_like/scandirImpl.html#scandir proc scandir(): ScandirIterator[PyStr] 278 +nimgrp close os_impl/posix_like/scandirImpl.html#close-procs-all proc 56 +nimgrp scandir os_impl/posix_like/scandirImpl.html#scandir-procs-all proc 272 +nimgrp isdir os_impl/posix_like/scandirImpl.html#is_dir-procs-all proc 154 +nimgrp isfile os_impl/posix_like/scandirImpl.html#is_file-procs-all proc 153 +nimgrp scandir os_impl/posix_like/scandirImpl.html#scandir-iterators-all iterator 255 diff --git a/Lib/os_impl/posix_like/sched.html b/Lib/os_impl/posix_like/sched.html new file mode 100644 index 000000000..7119ac842 --- /dev/null +++ b/Lib/os_impl/posix_like/sched.html @@ -0,0 +1,96 @@ + + + + + + + +src/pylib/Lib/os_impl/posix_like/sched + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/os_impl/posix_like/sched

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ + + +
+
+ + +
+
+ + + diff --git a/Lib/os_impl/posix_like/sched.idx b/Lib/os_impl/posix_like/sched.idx new file mode 100644 index 000000000..9cb4f893c --- /dev/null +++ b/Lib/os_impl/posix_like/sched.idx @@ -0,0 +1 @@ +nimTitle sched os_impl/posix_like/sched.html module src/pylib/Lib/os_impl/posix_like/sched 0 diff --git a/Lib/os_impl/posix_like/seek_consts.html b/Lib/os_impl/posix_like/seek_consts.html new file mode 100644 index 000000000..ff768f2ee --- /dev/null +++ b/Lib/os_impl/posix_like/seek_consts.html @@ -0,0 +1,211 @@ + + + + + + + +src/pylib/Lib/os_impl/posix_like/seek_consts + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/os_impl/posix_like/seek_consts

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Consts

+
+
+
SEEK_CUR = 1
+
+ + + Source   +Edit   + +
+
+
+
SEEK_END = 2
+
+ + + Source   +Edit   + +
+
+
+
SEEK_SET = 0
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Templates

+
+
+
+
template SEEK_DATA(): int
+
+ +
Admonition: +since Python 3.3
+

not defined in Windows

+
Note: +this is in fact a runtime constant, defined as template only during document generation process. Cannot use as SEEK_DATA() (with parentheses).
+
Hint: +only usable if <unistd.h> in your system defines it,
+
Hint: +only supported on some filesystems, refer to your system's manpage of lseek
+ + Source   +Edit   + +
+
+ +
+
+
+
template SEEK_HOLE(): int
+
+ +
Admonition: +since Python 3.3
+

see SEEK_DATA for hints.

+ + Source   +Edit   + +
+
+ +
+
+
+
template toCSEEK(whence: int): cint
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/os_impl/posix_like/seek_consts.idx b/Lib/os_impl/posix_like/seek_consts.idx new file mode 100644 index 000000000..e8659c19f --- /dev/null +++ b/Lib/os_impl/posix_like/seek_consts.idx @@ -0,0 +1,7 @@ +nimTitle seek_consts os_impl/posix_like/seek_consts.html module src/pylib/Lib/os_impl/posix_like/seek_consts 0 +nim SEEK_SET os_impl/posix_like/seek_consts.html#SEEK_SET const SEEK_SET 6 +nim SEEK_CUR os_impl/posix_like/seek_consts.html#SEEK_CUR const SEEK_CUR 7 +nim SEEK_END os_impl/posix_like/seek_consts.html#SEEK_END const SEEK_END 8 +nim toCSEEK os_impl/posix_like/seek_consts.html#toCSEEK.t,int template toCSEEK(whence: int): cint 39 +nim SEEK_DATA os_impl/posix_like/seek_consts.html#SEEK_DATA.t template SEEK_DATA(): int 45 +nim SEEK_HOLE os_impl/posix_like/seek_consts.html#SEEK_HOLE.t template SEEK_HOLE(): int 56 diff --git a/Lib/os_impl/posix_like/stat.html b/Lib/os_impl/posix_like/stat.html new file mode 100644 index 000000000..25b196625 --- /dev/null +++ b/Lib/os_impl/posix_like/stat.html @@ -0,0 +1,411 @@ + + + + + + + +src/pylib/Lib/os_impl/posix_like/stat + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/os_impl/posix_like/stat

+
+ +
+ Source   +Edit   + +
+ +

+ +
+

Types

+
+
+
stat_result = ref object
+  data*: Stat                ## inner, used by `getattr` of `stat_result`
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
func `[]`(self: stat_result; i: int): BiggestInt {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc fstat(fd: int): stat_result {....raises: [PyOSError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc lstat[T](path: PathLike[T]; dir_fd = DEFAULT_DIR_FD): stat_result
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc Py_fstat(fd: int; status: var Stat) {....raises: [OSError], tags: [],
+    forbids: [].}
+
+ +

EXT.

+

fileutils.c _Py_fstat

+ + Source   +Edit   + +
+
+ +
+
+
+
proc Py_fstat_noraise(fd: int; status: var Stat): cint {....raises: [], tags: [],
+    forbids: [].}
+
+ +

EXT.

+

fileutils.c _Py_fstat_noraise

+ + Source   +Edit   + +
+
+ +
+
+
+
func st_atime(self`gensym1: stat_result): float {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func st_atime_ns(self`gensym1: stat_result): BiggestInt {....raises: [], tags: [],
+    forbids: [].}
+
+ +
Admonition: +since Python 3.3
+ + Source   +Edit   + +
+
+ +
+
+
+
func st_ctime(self`gensym3: stat_result): float {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func st_ctime_ns(self`gensym3: stat_result): BiggestInt {....raises: [], tags: [],
+    forbids: [].}
+
+ +
Admonition: +since Python 3.3
+ + Source   +Edit   + +
+
+ +
+
+
+
func st_mtime(self`gensym2: stat_result): float {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func st_mtime_ns(self`gensym2: stat_result): BiggestInt {....raises: [], tags: [],
+    forbids: [].}
+
+ +
Admonition: +since Python 3.3
+ + Source   +Edit   + +
+
+ +
+
+
+
proc stat(path: int; dir_fd = DEFAULT_DIR_FD; follow_symlinks = true): stat_result {.
+    ...raises: [ValueError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc stat[T](path: PathLike[T]; dir_fd = DEFAULT_DIR_FD; follow_symlinks = true): stat_result
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template `.`(self: stat_result; attr): untyped
+
+ + as Python's __getattr__ + Source   +Edit   + +
+
+ +
+
+
+
template statAttr(path: PathLike | int; attr: untyped): untyped
+
+ + stat(path).attr + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/os_impl/posix_like/stat.idx b/Lib/os_impl/posix_like/stat.idx new file mode 100644 index 000000000..12b1a0a7a --- /dev/null +++ b/Lib/os_impl/posix_like/stat.idx @@ -0,0 +1,18 @@ +nimTitle stat os_impl/posix_like/stat.html module src/pylib/Lib/os_impl/posix_like/stat 0 +nim stat_result os_impl/posix_like/stat.html#stat_result type stat_result 136 +nim st_atime os_impl/posix_like/stat.html#st_atime,stat_result proc st_atime(self`gensym1: stat_result): float 156 +nim st_atime_ns os_impl/posix_like/stat.html#st_atime_ns,stat_result proc st_atime_ns(self`gensym1: stat_result): BiggestInt 174 +nim st_mtime os_impl/posix_like/stat.html#st_mtime,stat_result proc st_mtime(self`gensym2: stat_result): float 156 +nim st_mtime_ns os_impl/posix_like/stat.html#st_mtime_ns,stat_result proc st_mtime_ns(self`gensym2: stat_result): BiggestInt 175 +nim st_ctime os_impl/posix_like/stat.html#st_ctime,stat_result proc st_ctime(self`gensym3: stat_result): float 156 +nim st_ctime_ns os_impl/posix_like/stat.html#st_ctime_ns,stat_result proc st_ctime_ns(self`gensym3: stat_result): BiggestInt 176 +nim `.` os_impl/posix_like/stat.html#..t,stat_result, template `.`(self: stat_result; attr): untyped 179 +nim `[]` os_impl/posix_like/stat.html#[],stat_result,int proc `[]`(self: stat_result; i: int): BiggestInt 201 +nim statAttr os_impl/posix_like/stat.html#statAttr.t,,untyped template statAttr(path: PathLike | int; attr: untyped): untyped 225 +nim Py_fstat_noraise os_impl/posix_like/stat.html#Py_fstat_noraise,int,Stat proc Py_fstat_noraise(fd: int; status: var Stat): cint 554 +nim Py_fstat os_impl/posix_like/stat.html#Py_fstat,int,Stat proc Py_fstat(fd: int; status: var Stat) 606 +nim stat os_impl/posix_like/stat.html#stat,PathLike[T] proc stat[T](path: PathLike[T]; dir_fd = DEFAULT_DIR_FD; follow_symlinks = true): stat_result 669 +nim stat os_impl/posix_like/stat.html#stat,int proc stat(path: int; dir_fd = DEFAULT_DIR_FD; follow_symlinks = true): stat_result 672 +nim lstat os_impl/posix_like/stat.html#lstat,PathLike[T] proc lstat[T](path: PathLike[T]; dir_fd = DEFAULT_DIR_FD): stat_result 675 +nim fstat os_impl/posix_like/stat.html#fstat,int proc fstat(fd: int): stat_result 679 +nimgrp stat os_impl/posix_like/stat.html#stat-procs-all proc 669 diff --git a/Lib/os_impl/posix_like/truncate.html b/Lib/os_impl/posix_like/truncate.html new file mode 100644 index 000000000..38a4d0372 --- /dev/null +++ b/Lib/os_impl/posix_like/truncate.html @@ -0,0 +1,136 @@ + + + + + + + +src/pylib/Lib/os_impl/posix_like/truncate + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/os_impl/posix_like/truncate

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
proc ftruncate(file: Positive; length: Natural) {....raises: [PyOSError], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc truncate(file: CanIOOpenT; length: Natural)
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/os_impl/posix_like/truncate.idx b/Lib/os_impl/posix_like/truncate.idx new file mode 100644 index 000000000..96e0d9b1a --- /dev/null +++ b/Lib/os_impl/posix_like/truncate.idx @@ -0,0 +1,3 @@ +nimTitle truncate os_impl/posix_like/truncate.html module src/pylib/Lib/os_impl/posix_like/truncate 0 +nim ftruncate os_impl/posix_like/truncate.html#ftruncate,Positive,Natural proc ftruncate(file: Positive; length: Natural) 45 +nim truncate os_impl/posix_like/truncate.html#truncate,CanIOOpenT,Natural proc truncate(file: CanIOOpenT; length: Natural) 49 diff --git a/Lib/os_impl/posix_like/umaskImpl.html b/Lib/os_impl/posix_like/umaskImpl.html new file mode 100644 index 000000000..7a1d07de0 --- /dev/null +++ b/Lib/os_impl/posix_like/umaskImpl.html @@ -0,0 +1,119 @@ + + + + + + + +src/pylib/Lib/os_impl/posix_like/umaskImpl + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/os_impl/posix_like/umaskImpl

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Imports

+
+ ../common +
+
+
+

Procs

+
+
+
+
proc umask(mode: int): int {.discardable, ...raises: [PyOSError], tags: [],
+                             forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/os_impl/posix_like/umaskImpl.idx b/Lib/os_impl/posix_like/umaskImpl.idx new file mode 100644 index 000000000..cfe123213 --- /dev/null +++ b/Lib/os_impl/posix_like/umaskImpl.idx @@ -0,0 +1,2 @@ +nimTitle umaskImpl os_impl/posix_like/umaskImpl.html module src/pylib/Lib/os_impl/posix_like/umaskImpl 0 +nim umask os_impl/posix_like/umaskImpl.html#umask,int proc umask(mode: int): int 9 diff --git a/Lib/os_impl/posix_like/unameImpl.html b/Lib/os_impl/posix_like/unameImpl.html new file mode 100644 index 000000000..ecfe98718 --- /dev/null +++ b/Lib/os_impl/posix_like/unameImpl.html @@ -0,0 +1,118 @@ + + + + + + + +src/pylib/Lib/os_impl/posix_like/unameImpl + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/os_impl/posix_like/unameImpl

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Templates

+
+
+
+
template genUname(S) {.dirty.}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/os_impl/posix_like/unameImpl.idx b/Lib/os_impl/posix_like/unameImpl.idx new file mode 100644 index 000000000..45ca9a643 --- /dev/null +++ b/Lib/os_impl/posix_like/unameImpl.idx @@ -0,0 +1,2 @@ +nimTitle unameImpl os_impl/posix_like/unameImpl.html module src/pylib/Lib/os_impl/posix_like/unameImpl 0 +nim genUname os_impl/posix_like/unameImpl.html#genUname.t template genUname(S) 28 diff --git a/Lib/os_impl/posix_like/unlink.html b/Lib/os_impl/posix_like/unlink.html new file mode 100644 index 000000000..d3f9a9fab --- /dev/null +++ b/Lib/os_impl/posix_like/unlink.html @@ -0,0 +1,135 @@ + + + + + + + +src/pylib/Lib/os_impl/posix_like/unlink + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/os_impl/posix_like/unlink

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
proc remove[T](p: PathLike[T]; dir_fd = DEFAULT_DIR_FD)
+
+ + This function is semantically identical to unlink + Source   +Edit   + +
+
+ +
+ + +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/os_impl/posix_like/unlink.idx b/Lib/os_impl/posix_like/unlink.idx new file mode 100644 index 000000000..05d595e26 --- /dev/null +++ b/Lib/os_impl/posix_like/unlink.idx @@ -0,0 +1,3 @@ +nimTitle unlink os_impl/posix_like/unlink.html module src/pylib/Lib/os_impl/posix_like/unlink 0 +nim unlink os_impl/posix_like/unlink.html#unlink,PathLike[T] proc unlink[T](p: PathLike[T]; dir_fd = DEFAULT_DIR_FD) 15 +nim remove os_impl/posix_like/unlink.html#remove,PathLike[T] proc remove[T](p: PathLike[T]; dir_fd = DEFAULT_DIR_FD) 36 diff --git a/Lib/os_impl/posix_like/unlinkImpl.html b/Lib/os_impl/posix_like/unlinkImpl.html new file mode 100644 index 000000000..7d75820d4 --- /dev/null +++ b/Lib/os_impl/posix_like/unlinkImpl.html @@ -0,0 +1,127 @@ + + + + + + + +src/pylib/Lib/os_impl/posix_like/unlinkImpl + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/os_impl/posix_like/unlinkImpl

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Imports

+
+ ../common +
+
+
+

Procs

+
+
+
+
proc unlinkImpl(p: PathLike)
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Exports

+
+ fspath, substr, ==, str, getChar, [], +=, $, bytes, TimeoutError, +=, exportSincePy, osErrorMsgWithPath, substr, ProcessLookupError, raiseExcWithPath, tryOsOp, mapPathLike, Serial, BlockingIOError, runes, ==, None, noWeirdTarget, str, Version, +, wrapExportSincePy, bytes, PySys_Audit, ==, NoneType, str, CanIOOpenT, +, PyMinor, asVersion, templWrapExportSincePy, contains, ConnectionResetError, BlockingIOError, toNimString, +, [], repr, pathrepr, PermissionError, PySerial, errnoMsg, runeAtPos, asVersion, fspath, raiseErrno, +=, +=, PyMajor, $, or, tryOsOp, PyOSError, ConnectionError, chars, PyBytes, ChildProcessError, bytes, tryOsOp, TypeError, repr, NameError, toNimString, bytes, +, len, KeyboardInterrupt, str, newPyOSError, [], NotImplementedError, +=, SystemExit, pybytes, toNimStr, newPyOSError, getCharPtr, [], Patch, [], osErrorMsgWithPath, byteLen, raiseExcWithPath2, PyReleaseLevelEnum, AttributeError, PyReleaseLevel, substr, PyStr, Minor, and, $, NotADirectoryError, BrokenPipeError, toPyStr, raiseExcWithPath, [], items, PyOSError, runeLenAt, raiseErrnoT, str, FileNotFoundError, BlockingIOError, newBlockingIOError, chars, PathLike, len, IsADirectoryError, toPyStr, @, contains, FileExistsError, toPyStr, asVersion, asVersion, pysince, not, RuntimeError, PyPatch, InterruptedError, PySys_AddAuditHook, pysince, newBlockingIOError, not, raiseErrnoWithPath, contains, getChar, $, bytes, +=, Major, hasChar, ==, +, +, pathrepr, $, InJs, addaudithook, ConnectionAbortedError, str, ConnectionRefusedError, or, tryOsOp, byteLen, items, StringLike, audit, PyOSError, fspath, len, mapPathLike, pysince, raiseExcWithPath, bytes, +, ReleaseLevel, fspath, raiseExcWithPath, bytes, bytes +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/os_impl/posix_like/unlinkImpl.idx b/Lib/os_impl/posix_like/unlinkImpl.idx new file mode 100644 index 000000000..4e2f78d6e --- /dev/null +++ b/Lib/os_impl/posix_like/unlinkImpl.idx @@ -0,0 +1,2 @@ +nimTitle unlinkImpl os_impl/posix_like/unlinkImpl.html module src/pylib/Lib/os_impl/posix_like/unlinkImpl 0 +nim unlinkImpl os_impl/posix_like/unlinkImpl.html#unlinkImpl,PathLike proc unlinkImpl(p: PathLike) 74 diff --git a/Lib/os_impl/posix_like/utime.html b/Lib/os_impl/posix_like/utime.html new file mode 100644 index 000000000..e79fe4857 --- /dev/null +++ b/Lib/os_impl/posix_like/utime.html @@ -0,0 +1,190 @@ + + + + + + + +src/pylib/Lib/os_impl/posix_like/utime + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/os_impl/posix_like/utime

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

os.utime

+
+

Imports

+
+ ../common +
+
+
+

Types

+
+
+
NsUnit = BiggestInt
+
+ + + Source   +Edit   + +
+
+
+
TimeNsPair = tuple[atime_ns, mtime_ns: NsUnit]
+
+ + + Source   +Edit   + +
+
+
+
TimePair[F] = tuple[atime, mtime: F]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
proc utime[T; F: SomeFloat](path: PathLike[T]; times: TimePair[F];
+                            follow_symlinks = true)
+
+ + + Source   +Edit   + +
+
+
+
proc utime[T](path: PathLike[T]; follow_symlinks = true)
+
+ + + Source   +Edit   + +
+
+
+
proc utime[T](path: PathLike[T]; ns: TimeNsPair; follow_symlinks = true)
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/os_impl/posix_like/utime.idx b/Lib/os_impl/posix_like/utime.idx new file mode 100644 index 000000000..1ce640515 --- /dev/null +++ b/Lib/os_impl/posix_like/utime.idx @@ -0,0 +1,8 @@ +nimTitle utime os_impl/posix_like/utime.html module src/pylib/Lib/os_impl/posix_like/utime 0 +nim TimePair os_impl/posix_like/utime.html#TimePair tuple TimePair 10 +nim NsUnit os_impl/posix_like/utime.html#NsUnit type NsUnit 13 +nim TimeNsPair os_impl/posix_like/utime.html#TimeNsPair tuple TimeNsPair 15 +nim utime os_impl/posix_like/utime.html#utime,PathLike[T],TimePair[F: SomeFloat] proc utime[T; F: SomeFloat](path: PathLike[T]; times: TimePair[F];\n follow_symlinks = true) 111 +nim utime os_impl/posix_like/utime.html#utime,PathLike[T],TimeNsPair proc utime[T](path: PathLike[T]; ns: TimeNsPair; follow_symlinks = true) 114 +nim utime os_impl/posix_like/utime.html#utime,PathLike[T] proc utime[T](path: PathLike[T]; follow_symlinks = true) 120 +nimgrp utime os_impl/posix_like/utime.html#utime-procs-all proc 111 diff --git a/Lib/os_impl/private/defined_macros.html b/Lib/os_impl/private/defined_macros.html new file mode 100644 index 000000000..3283e738b --- /dev/null +++ b/Lib/os_impl/private/defined_macros.html @@ -0,0 +1,125 @@ + + + + + + + +src/pylib/Lib/os_impl/private/defined_macros + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/os_impl/private/defined_macros

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Consts

+
+
+
InJs = false
+
+ + + Source   +Edit   + +
+
+
+
ms_windows = false
+
+ + + Source   +Edit   + +
+
+
+
MS_WINDOWS = false
+
+ + + Source   +Edit   + +
+
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/os_impl/private/defined_macros.idx b/Lib/os_impl/private/defined_macros.idx new file mode 100644 index 000000000..a3a90d6e4 --- /dev/null +++ b/Lib/os_impl/private/defined_macros.idx @@ -0,0 +1,4 @@ +nimTitle defined_macros os_impl/private/defined_macros.html module src/pylib/Lib/os_impl/private/defined_macros 0 +nim MS_WINDOWS os_impl/private/defined_macros.html#MS_WINDOWS const MS_WINDOWS 2 +nim ms_windows os_impl/private/defined_macros.html#ms_windows_2 const ms_windows 4 +nim InJs os_impl/private/defined_macros.html#InJs const InJs 8 diff --git a/Lib/os_impl/private/iph_utils.html b/Lib/os_impl/private/iph_utils.html new file mode 100644 index 000000000..5234bfde1 --- /dev/null +++ b/Lib/os_impl/private/iph_utils.html @@ -0,0 +1,96 @@ + + + + + + + +src/pylib/Lib/os_impl/private/iph_utils + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/os_impl/private/iph_utils

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ + + +
+
+ + +
+
+ + + diff --git a/Lib/os_impl/private/iph_utils.idx b/Lib/os_impl/private/iph_utils.idx new file mode 100644 index 000000000..760458e23 --- /dev/null +++ b/Lib/os_impl/private/iph_utils.idx @@ -0,0 +1 @@ +nimTitle iph_utils os_impl/private/iph_utils.html module src/pylib/Lib/os_impl/private/iph_utils 0 diff --git a/Lib/os_impl/private/platform_utils.html b/Lib/os_impl/private/platform_utils.html new file mode 100644 index 000000000..dcfe736d3 --- /dev/null +++ b/Lib/os_impl/private/platform_utils.html @@ -0,0 +1,96 @@ + + + + + + + +src/pylib/Lib/os_impl/private/platform_utils + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/os_impl/private/platform_utils

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+ +
+ + +
+
+ + + diff --git a/Lib/os_impl/private/platform_utils.idx b/Lib/os_impl/private/platform_utils.idx new file mode 100644 index 000000000..f5a288833 --- /dev/null +++ b/Lib/os_impl/private/platform_utils.idx @@ -0,0 +1 @@ +nimTitle platform_utils os_impl/private/platform_utils.html module src/pylib/Lib/os_impl/private/platform_utils 0 diff --git a/Lib/os_impl/randoms.html b/Lib/os_impl/randoms.html new file mode 100644 index 000000000..6f045db41 --- /dev/null +++ b/Lib/os_impl/randoms.html @@ -0,0 +1,137 @@ + + + + + + + +src/pylib/Lib/os_impl/randoms + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/os_impl/randoms

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
proc getrandom(size: int; flags = 0): seq[uint8] {....raises: [PyOSError],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc urandom(size: int): seq[uint8] {....raises: [ValueError, NotImplementedError,
+    OSError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/os_impl/randoms.idx b/Lib/os_impl/randoms.idx new file mode 100644 index 000000000..918b79902 --- /dev/null +++ b/Lib/os_impl/randoms.idx @@ -0,0 +1,3 @@ +nimTitle randoms os_impl/randoms.html module src/pylib/Lib/os_impl/randoms 0 +nim urandom os_impl/randoms.html#urandom,int proc urandom(size: int): seq[uint8] 48 +nim getrandom os_impl/randoms.html#getrandom,int,int proc getrandom(size: int; flags = 0): seq[uint8] 71 diff --git a/Lib/os_impl/subp.html b/Lib/os_impl/subp.html new file mode 100644 index 000000000..fb56beb15 --- /dev/null +++ b/Lib/os_impl/subp.html @@ -0,0 +1,118 @@ + + + + + + + +src/pylib/Lib/os_impl/subp + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/os_impl/subp

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Imports

+
+ common +
+
+
+

Procs

+
+
+
+
proc system(cmd: string): int {.discardable, ...raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/os_impl/subp.idx b/Lib/os_impl/subp.idx new file mode 100644 index 000000000..9f8486d7f --- /dev/null +++ b/Lib/os_impl/subp.idx @@ -0,0 +1,2 @@ +nimTitle subp os_impl/subp.html module src/pylib/Lib/os_impl/subp 0 +nim system os_impl/subp.html#system,string proc system(cmd: string): int 6 diff --git a/Lib/os_impl/term.html b/Lib/os_impl/term.html new file mode 100644 index 000000000..0b75b4234 --- /dev/null +++ b/Lib/os_impl/term.html @@ -0,0 +1,137 @@ + + + + + + + +src/pylib/Lib/os_impl/term + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/os_impl/term

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Types

+
+
+
terminal_size = tuple[columns, lines: int]
+
+ + a namedtuple instead of a class + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
proc get_terminal_size(fd = STDOUT_FILENO): terminal_size {....raises: [],
+    tags: [], forbids: [].}
+
+ +

minics Python's os.get_terminal_size.

+

but if you are using Nim's stdlib, terminalSize<https://nim-lang.org/docs/terminal.html#terminalSize> in std/terminal does futher than even Python's shutil.get_terminal_size

+ + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/os_impl/term.idx b/Lib/os_impl/term.idx new file mode 100644 index 000000000..4bcca5aa3 --- /dev/null +++ b/Lib/os_impl/term.idx @@ -0,0 +1,3 @@ +nimTitle term os_impl/term.html module src/pylib/Lib/os_impl/term 0 +nim terminal_size os_impl/term.html#terminal_size tuple terminal_size 8 +nim get_terminal_size os_impl/term.html#get_terminal_size proc get_terminal_size(fd = STDOUT_FILENO): terminal_size 10 diff --git a/Lib/os_impl/touch.html b/Lib/os_impl/touch.html new file mode 100644 index 000000000..89d938fe3 --- /dev/null +++ b/Lib/os_impl/touch.html @@ -0,0 +1,119 @@ + + + + + + + +src/pylib/Lib/os_impl/touch + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/os_impl/touch

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
proc touch(s: string; mode = 0o000000000666; exist_ok = true) {.
+    ...raises: [PyOSError], tags: [TimeEffect], forbids: [].}
+
+ + EXT. used by pathlib Create this file with the given access mode, if it doesn't exist. + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/os_impl/touch.idx b/Lib/os_impl/touch.idx new file mode 100644 index 000000000..434761033 --- /dev/null +++ b/Lib/os_impl/touch.idx @@ -0,0 +1,2 @@ +nimTitle touch os_impl/touch.html module src/pylib/Lib/os_impl/touch 0 +nim touch os_impl/touch.html#touch,string,int proc touch(s: string; mode = 0o000000000666; exist_ok = true) 5 diff --git a/Lib/os_impl/util/handle_signal.html b/Lib/os_impl/util/handle_signal.html new file mode 100644 index 000000000..85b4c8d54 --- /dev/null +++ b/Lib/os_impl/util/handle_signal.html @@ -0,0 +1,118 @@ + + + + + + + +src/pylib/Lib/os_impl/util/handle_signal + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/os_impl/util/handle_signal

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Templates

+
+
+
+
template initVal_with_handle_signal[R](res: var R; resExpr) {.dirty.}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/os_impl/util/handle_signal.idx b/Lib/os_impl/util/handle_signal.idx new file mode 100644 index 000000000..91a7d16f5 --- /dev/null +++ b/Lib/os_impl/util/handle_signal.idx @@ -0,0 +1,2 @@ +nimTitle handle_signal os_impl/util/handle_signal.html module src/pylib/Lib/os_impl/util/handle_signal 0 +nim initVal_with_handle_signal os_impl/util/handle_signal.html#initVal_with_handle_signal.t,R, template initVal_with_handle_signal[R](res: var R; resExpr) 7 diff --git a/Lib/os_impl/utils.html b/Lib/os_impl/utils.html new file mode 100644 index 000000000..590ecc914 --- /dev/null +++ b/Lib/os_impl/utils.html @@ -0,0 +1,186 @@ + + + + + + + +src/pylib/Lib/os_impl/utils + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/os_impl/utils

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
proc chdir(s: PathLike)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc getcwd(): PyStr {....raises: [OSError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc getcwdb(): PyBytes {....raises: [OSError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc makedirs[T](d: PathLike[T]; mode = 0o000000000777; exist_ok = false)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc removedirs(d: PathLike)
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/os_impl/utils.idx b/Lib/os_impl/utils.idx new file mode 100644 index 000000000..8053c9909 --- /dev/null +++ b/Lib/os_impl/utils.idx @@ -0,0 +1,6 @@ +nimTitle utils os_impl/utils.html module src/pylib/Lib/os_impl/utils 0 +nim getcwd os_impl/utils.html#getcwd proc getcwd(): PyStr 18 +nim getcwdb os_impl/utils.html#getcwdb proc getcwdb(): PyBytes 19 +nim chdir os_impl/utils.html#chdir,PathLike proc chdir(s: PathLike) 22 +nim makedirs os_impl/utils.html#makedirs,PathLike[T],int proc makedirs[T](d: PathLike[T]; mode = 0o000000000777; exist_ok = false) 26 +nim removedirs os_impl/utils.html#removedirs,PathLike proc removedirs(d: PathLike) 38 diff --git a/Lib/os_impl/waits.html b/Lib/os_impl/waits.html new file mode 100644 index 000000000..5b76b6b07 --- /dev/null +++ b/Lib/os_impl/waits.html @@ -0,0 +1,418 @@ + + + + + + + +src/pylib/Lib/os_impl/waits + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/os_impl/waits

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Lets

+
+
+
WCONTINUED = int(cWCONTINUED)
+
+ + + Source   +Edit   + +
+
+
+
WEXITED = int(cWEXITED)
+
+ + + Source   +Edit   + +
+
+
+
WNOHANG = int(cWNOHANG)
+
+ + + Source   +Edit   + +
+
+
+
WNOWAIT = int(cWNOWAIT)
+
+ + + Source   +Edit   + +
+
+
+
WSTOPPED = int(cWSTOPPED)
+
+ + + Source   +Edit   + +
+
+
+
WUNTRACED = int(cWUNTRACED)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
proc wait(): tuple[pid: int, status: int] {....raises: [], tags: [], forbids: [].}
+
+ +
Hint: +Availability: not js
+ + Source   +Edit   + +
+
+ +
+
+
+
proc wait3(options: int): tuple[pid: int, status: int, rusage: struct_rusage] {.
+    ...raises: [], tags: [], forbids: [].}
+
+ +
Hint: +Availability: not js
+ + Source   +Edit   + +
+
+ +
+
+
+
proc wait4(pid: int; options: int): tuple[pid: int, status: int,
+    rusage: struct_rusage] {....raises: [], tags: [], forbids: [].}
+
+ +
Hint: +Availability: not js
+ + Source   +Edit   + +
+
+ +
+
+
+
proc waitpid(pid: int; options: int): tuple[pid: int, status: int] {....raises: [],
+    tags: [], forbids: [].}
+
+ +
Hint: +Availability: not js
+ + Source   +Edit   + +
+
+ +
+
+
+
proc waitstatus_to_exitcode(status: int): int {....raises: [], tags: [],
+    forbids: [].}
+
+ +
Hint: +Availability: not js
+ + Source   +Edit   + +
+
+ +
+
+
+
proc WCOREDUMP(status: int): bool {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc WEXITSTATUS(status: int): bool {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc WIFCONTINUED(status: int): bool {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc WIFEXITED(status: int): bool {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc WIFSIGNALED(status: int): bool {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc WIFSTOPPED(status: int): bool {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc WSTOPSIG(status: int): bool {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc WTERMSIG(status: int): bool {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/os_impl/waits.idx b/Lib/os_impl/waits.idx new file mode 100644 index 000000000..9c02ddeec --- /dev/null +++ b/Lib/os_impl/waits.idx @@ -0,0 +1,20 @@ +nimTitle waits os_impl/waits.html module src/pylib/Lib/os_impl/waits 0 +nim WCOREDUMP os_impl/waits.html#WCOREDUMP,int proc WCOREDUMP(status: int): bool 48 +nim WIFCONTINUED os_impl/waits.html#WIFCONTINUED,int proc WIFCONTINUED(status: int): bool 49 +nim WIFSTOPPED os_impl/waits.html#WIFSTOPPED,int proc WIFSTOPPED(status: int): bool 50 +nim WIFSIGNALED os_impl/waits.html#WIFSIGNALED,int proc WIFSIGNALED(status: int): bool 51 +nim WIFEXITED os_impl/waits.html#WIFEXITED,int proc WIFEXITED(status: int): bool 52 +nim WEXITSTATUS os_impl/waits.html#WEXITSTATUS,int proc WEXITSTATUS(status: int): bool 53 +nim WTERMSIG os_impl/waits.html#WTERMSIG,int proc WTERMSIG(status: int): bool 54 +nim WSTOPSIG os_impl/waits.html#WSTOPSIG,int proc WSTOPSIG(status: int): bool 55 +nim WCONTINUED os_impl/waits.html#WCONTINUED let WCONTINUED 59 +nim WEXITED os_impl/waits.html#WEXITED let WEXITED 59 +nim WSTOPPED os_impl/waits.html#WSTOPPED let WSTOPPED 59 +nim WUNTRACED os_impl/waits.html#WUNTRACED let WUNTRACED 59 +nim WNOHANG os_impl/waits.html#WNOHANG let WNOHANG 59 +nim WNOWAIT os_impl/waits.html#WNOWAIT let WNOWAIT 59 +nim waitpid os_impl/waits.html#waitpid,int,int proc waitpid(pid: int; options: int): tuple[pid: int, status: int] 74 +nim wait os_impl/waits.html#wait proc wait(): tuple[pid: int, status: int] 84 +nim wait3 os_impl/waits.html#wait3,int proc wait3(options: int): tuple[pid: int, status: int, rusage: struct_rusage] 102 +nim wait4 os_impl/waits.html#wait4,int,int proc wait4(pid: int; options: int): tuple[pid: int, status: int,\n rusage: struct_rusage] 110 +nim waitstatus_to_exitcode os_impl/waits.html#waitstatus_to_exitcode,int proc waitstatus_to_exitcode(status: int): int 118 diff --git a/Lib/os_impl/walkImpl.html b/Lib/os_impl/walkImpl.html new file mode 100644 index 000000000..d66cbf966 --- /dev/null +++ b/Lib/os_impl/walkImpl.html @@ -0,0 +1,365 @@ + + + + + + + +src/pylib/Lib/os_impl/walkImpl + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/os_impl/walkImpl

+
+ +
+ Source   +Edit   + +
+ +

+ +
+

Types

+
+
+
OnErrorCb = proc (e: ref PyOSError)
+
+ + + Source   +Edit   + +
+
+
+
WalkRes[T] = distinct WalkTup[T]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Lets

+
+ + +
+
+
+

Consts

+
+
+
shallIgnore: OnErrorCb = nil
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
proc walk[T](top: PathLike[T]; topdown = True; onerror = None;
+             followlinks = False): WalkIterator[T]
+
+ + + Source   +Edit   + +
+
+
+
proc walk[T](top: PathLike[T]; topdown = True; onerror = shallIgnore;
+             followlinks = False): WalkIterator[T]
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Iterators

+
+
+
+
iterator walk[T](top: PathLike[T]; topdown = True; onerror = None;
+                 followlinks = False): WalkRes[T]
+
+ + + Source   +Edit   + +
+
+
+
iterator walk[T](top: PathLike[T]; topdown = True; onerror = shallIgnore;
+                 followlinks: bool | WalkSymlinksAsFiles = False): WalkRes[T]
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Converters

+
+
+
+
converter toTup[T](self: WalkRes[T]): WalkTup[T]
+
+ + converts to tuple[T, list[T], list[T]] + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template `$`[T](self: WalkRes[T]): string
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template `[]`[T](self: WalkRes[T]; i: static int): untyped
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template repr[T](self: WalkRes[T]): string
+
+ + returns (xx, [xx], [xx]) as Python's + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/os_impl/walkImpl.idx b/Lib/os_impl/walkImpl.idx new file mode 100644 index 000000000..0f9dc3b6b --- /dev/null +++ b/Lib/os_impl/walkImpl.idx @@ -0,0 +1,15 @@ +nimTitle walkImpl os_impl/walkImpl.html module src/pylib/Lib/os_impl/walkImpl 0 +nim OnErrorCb os_impl/walkImpl.html#OnErrorCb type OnErrorCb 9 +nim WalkRes os_impl/walkImpl.html#WalkRes type WalkRes 14 +nim toTup os_impl/walkImpl.html#toTup.c,WalkRes[T] converter toTup[T](self: WalkRes[T]): WalkTup[T] 15 +nim `[]` os_impl/walkImpl.html#[].t,WalkRes[T],staticint template `[]`[T](self: WalkRes[T]; i: static int): untyped 18 +nim repr os_impl/walkImpl.html#repr.t,WalkRes[T] template repr[T](self: WalkRes[T]): string 25 +nim `$` os_impl/walkImpl.html#$.t,WalkRes[T] template `$`[T](self: WalkRes[T]): string 33 +nim shallIgnore os_impl/walkImpl.html#shallIgnore const shallIgnore 40 +nim walk_symlinks_as_files os_impl/walkImpl.html#walk_symlinks_as_files let walk_symlinks_as_files 66 +nim walk os_impl/walkImpl.html#walk.i,PathLike[T] iterator walk[T](top: PathLike[T]; topdown = True; onerror = shallIgnore;\n followlinks: bool | WalkSymlinksAsFiles = False): WalkRes[T] 69 +nim walk os_impl/walkImpl.html#walk.i,PathLike[T]_2 iterator walk[T](top: PathLike[T]; topdown = True; onerror = None; followlinks = False): WalkRes[\n T] 165 +nim walk os_impl/walkImpl.html#walk,PathLike[T] proc walk[T](top: PathLike[T]; topdown = True; onerror = shallIgnore;\n followlinks = False): WalkIterator[T] 172 +nim walk os_impl/walkImpl.html#walk,PathLike[T]_2 proc walk[T](top: PathLike[T]; topdown = True; onerror = None; followlinks = False): WalkIterator[\n T] 177 +nimgrp walk os_impl/walkImpl.html#walk-procs-all proc 172 +nimgrp walk os_impl/walkImpl.html#walk-iterators-all iterator 69 diff --git a/Lib/pathlib.html b/Lib/pathlib.html new file mode 100644 index 000000000..4340012c7 --- /dev/null +++ b/Lib/pathlib.html @@ -0,0 +1,568 @@ + + + + + + + +src/pylib/Lib/pathlib + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/pathlib

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
func `/`(p: PathLike; self: Path): Path
+
+ + + Source   +Edit   + +
+
+
+
func `/`(self: Path; p: PathLike): Path
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func `/=`(head: var Path; tail: PathLike): Path
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func fspath(self: Path): PyStr {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
func joinpath[P: PathLike](self: Path; pathsegments: varargs[P]): Path
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc mkdir(self: Path; mode = 0o000000000777; parents = false; exist_ok = false) {.
+    ...raises: [OSError, IOError, PyOSError, PyOSError],
+    tags: [WriteDirEffect, ReadDirEffect], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func name(self: Path): PyStr {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func parts(self: Path): PyList[PyStr] {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc Path[P: PathLike](pathsegments: varargs[P]): types.Path
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc read_bytes(self: Path): PyBytes {....raises: [IOError], tags: [ReadIOEffect],
+                                       forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc read_text(self: Path; encoding = DefEncoding; errors = DefErrors): PyStr {.
+    ...raises: [ValueError, LookupError, PyOSError, Exception, IOError],
+    tags: [RootEffect, ReadIOEffect], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
proc rename(self: Path; target: Path): Path {.discardable, ...raises: [PyOSError],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc rename(self: Path; target: string): Path {.discardable,
+    ...raises: [PyOSError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc replace(self: Path; target: Path): Path {.discardable, ...raises: [PyOSError],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc replace(self: Path; target: string): Path {.discardable,
+    ...raises: [PyOSError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc rmdir(self: Path) {....raises: [PyOSError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func stem(self: Path): PyStr {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func suffix(self: Path): PyStr {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func suffixes(self: Path): PyList[PyStr] {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ + +
+
+
proc write_bytes(self: Path; b: PyBytes) {....raises: [IOError],
+    tags: [WriteIOEffect], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc write_text(self: Path; data: PyStr; encoding = DefEncoding;
+                errors = DefErrors): int {.discardable,
+    ...raises: [ValueError, LookupError, PyOSError, Exception], tags: [RootEffect],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template open(self: Path; mode: StringLike = "r"; buffering = -1;
+              encoding = DefEncoding; errors = DefErrors; newline = DefNewLine): untyped
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ + +
+
+ + +
+
+ + + diff --git a/Lib/pathlib.idx b/Lib/pathlib.idx new file mode 100644 index 000000000..6802a24cb --- /dev/null +++ b/Lib/pathlib.idx @@ -0,0 +1,30 @@ +nimTitle pathlib pathlib.html module src/pylib/Lib/pathlib 0 +nim name pathlib.html#name,Path proc name(self: Path): PyStr 28 +nim suffix pathlib.html#suffix,Path proc suffix(self: Path): PyStr 28 +nim stem pathlib.html#stem,Path proc stem(self: Path): PyStr 28 +nim parts pathlib.html#parts,Path proc parts(self: Path): PyList[PyStr] 32 +nim suffixes pathlib.html#suffixes,Path proc suffixes(self: Path): PyList[PyStr] 32 +nim fspath pathlib.html#fspath proc fspath(self: Path): PyStr 49 +nim Path pathlib.html#Path,varargs[P]_2 proc Path[P: PathLike](pathsegments: varargs[P]): types.Path 51 +nim `/` pathlib.html#/,,PathLike proc `/`(self: Path; p: PathLike): Path 55 +nim `/` pathlib.html#/,PathLike, proc `/`(p: PathLike; self: Path): Path 56 +nim `/=` pathlib.html#/=,Path,PathLike proc `/=`(head: var Path; tail: PathLike): Path 57 +nim joinpath pathlib.html#joinpath,,varargs[P]_2 proc joinpath[P: PathLike](self: Path; pathsegments: varargs[P]): Path 59 +nim open pathlib.html#open.t,Path,StringLike,int template open(self: Path; mode: StringLike = "r"; buffering = -1; encoding = DefEncoding;\n errors = DefErrors; newline = DefNewLine): untyped 64 +nim read_text pathlib.html#read_text proc read_text(self: Path; encoding = DefEncoding; errors = DefErrors): PyStr 71 +nim write_text pathlib.html#write_text,,PyStr proc write_text(self: Path; data: PyStr; encoding = DefEncoding; errors = DefErrors): int 76 +nim read_bytes pathlib.html#read_bytes proc read_bytes(self: Path): PyBytes 82 +nim write_bytes pathlib.html#write_bytes,,PyBytes proc write_bytes(self: Path; b: PyBytes) 83 +nim readlink pathlib.html#readlink proc readlink(self: Path): Path 85 +nim symlink_to pathlib.html#symlink_to,, proc symlink_to(self: Path; target: string | Path; target_is_directory = false) 87 +nim hardlink_to pathlib.html#hardlink_to,, proc hardlink_to(self: Path; target: string | Path) 90 +nim unlink pathlib.html#unlink,,bool proc unlink(self: Path; missing_ok: bool) 98 +nim rename pathlib.html#rename,,Path proc rename(self: Path; target: Path): Path 108 +nim rename pathlib.html#rename,,string proc rename(self: Path; target: string): Path 115 +nim replace pathlib.html#replace,,Path proc replace(self: Path; target: Path): Path 108 +nim replace pathlib.html#replace,,string proc replace(self: Path; target: string): Path 116 +nim mkdir pathlib.html#mkdir,,int proc mkdir(self: Path; mode = 0o000000000777; parents = false; exist_ok = false) 123 +nim rmdir pathlib.html#rmdir proc rmdir(self: Path) 135 +nimgrp replace pathlib.html#replace-procs-all proc 116 +nimgrp / pathlib.html#/-procs-all proc 55 +nimgrp rename pathlib.html#rename-procs-all proc 115 diff --git a/Lib/pathlib_impl/init.html b/Lib/pathlib_impl/init.html new file mode 100644 index 000000000..570c10d41 --- /dev/null +++ b/Lib/pathlib_impl/init.html @@ -0,0 +1,118 @@ + + + + + + + +src/pylib/Lib/pathlib_impl/init + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/pathlib_impl/init

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Imports

+
+ types +
+
+
+

Procs

+
+
+
+
proc Path[P](pathsegments: varargs[P]): types.Path
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/pathlib_impl/init.idx b/Lib/pathlib_impl/init.idx new file mode 100644 index 000000000..e2dea58f7 --- /dev/null +++ b/Lib/pathlib_impl/init.idx @@ -0,0 +1,2 @@ +nimTitle init pathlib_impl/init.html module src/pylib/Lib/pathlib_impl/init 0 +nim Path pathlib_impl/init.html#Path,varargs[P] proc Path[P](pathsegments: varargs[P]): types.Path 4 diff --git a/Lib/pathlib_impl/meth.html b/Lib/pathlib_impl/meth.html new file mode 100644 index 000000000..2fd1c4cab --- /dev/null +++ b/Lib/pathlib_impl/meth.html @@ -0,0 +1,490 @@ + + + + + + + +src/pylib/Lib/pathlib_impl/meth + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/pathlib_impl/meth

+
+ +
+ Source   +Edit   + +
+ +

+
+

Imports

+
+ types +
+
+
+

Procs

+
+
+
+
func `/`(p: string; self: Path): Path {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func `/`(self: Path; p: string): Path {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func `/=`(head: var Path; tail: string): Path {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc absolute(self: Path): Path {....raises: [ValueError, OSError], tags: [],
+                                  forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func as_posix(self: Path): Path {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc cwd(_: typedesc[Path]): Path
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc home(_: typedesc[Path]): Path
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc is_absolute(self: Path): bool {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc is_dir(self: Path): bool {....raises: [], tags: [ReadDirEffect], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc is_file(self: Path): bool {....raises: [], tags: [ReadDirEffect], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc is_relative_to(self: Path; other: Path): bool {....raises: [Exception],
+    tags: [RootEffect], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc is_relative_to(self: Path; other: string): bool {....raises: [Exception],
+    tags: [RootEffect], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
proc iterdir(self: Path): IterDirGenerator {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func joinpath[P: string](self: Path; pathsegments: varargs[P]): Path
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc mkdirParentsExistsOk(self: Path) {....raises: [OSError, IOError],
+                                        tags: [WriteDirEffect, ReadDirEffect],
+                                        forbids: [].}
+
+ +

EXT. equal to path.mkdir(parents=True, exists_ok=True)

+

not for JS backend

+ + Source   +Edit   + +
+
+ +
+
+
+
proc open(self: Path; mode: FileMode): File {....raises: [IOError], tags: [],
+    forbids: [].}
+
+ + EXT. + Source   +Edit   + +
+
+ +
+
+
+
proc read_nstring(self: Path): string {....raises: [IOError], tags: [ReadIOEffect],
+                                        forbids: [].}
+
+ + EXT. + Source   +Edit   + +
+
+ +
+
+
+
func relative_to(self: Path; other: string | Path): Path
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func samefile(self: Path; other_path: string | Path): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc write_nstring(self, s: string) {....raises: [IOError], tags: [WriteIOEffect],
+                                      forbids: [].}
+
+ + EXT. + Source   +Edit   + +
+
+ +
+ +
+
+
+

Iterators

+
+
+
+
iterator iterdir(self: Path): Path {....raises: [OSError], tags: [ReadDirEffect],
+                                     forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/pathlib_impl/meth.idx b/Lib/pathlib_impl/meth.idx new file mode 100644 index 000000000..9f446f7bf --- /dev/null +++ b/Lib/pathlib_impl/meth.idx @@ -0,0 +1,25 @@ +nimTitle meth pathlib_impl/meth.html module src/pylib/Lib/pathlib_impl/meth 0 +nim `/` pathlib_impl/meth.html#/,,string proc `/`(self: Path; p: string): Path 12 +nim `/` pathlib_impl/meth.html#/,string, proc `/`(p: string; self: Path): Path 13 +nim `/=` pathlib_impl/meth.html#/=,Path,string proc `/=`(head: var Path; tail: string): Path 15 +nim joinpath pathlib_impl/meth.html#joinpath,,varargs[P] proc joinpath[P: string](self: Path; pathsegments: varargs[P]): Path 17 +nim is_relative_to pathlib_impl/meth.html#is_relative_to,,string proc is_relative_to(self: Path; other: string): bool 22 +nim is_relative_to pathlib_impl/meth.html#is_relative_to,,Path proc is_relative_to(self: Path; other: Path): bool 25 +nim relative_to pathlib_impl/meth.html#relative_to,, proc relative_to(self: Path; other: string | Path): Path 27 +nim absolute pathlib_impl/meth.html#absolute proc absolute(self: Path): Path 30 +nim is_file pathlib_impl/meth.html#is_file proc is_file(self: Path): bool 35 +nim is_dir pathlib_impl/meth.html#is_dir proc is_dir(self: Path): bool 36 +nim is_symlink pathlib_impl/meth.html#is_symlink proc is_symlink(self: Path): bool 37 +nim is_absolute pathlib_impl/meth.html#is_absolute proc is_absolute(self: Path): bool 39 +nim as_posix pathlib_impl/meth.html#as_posix proc as_posix(self: Path): Path 41 +nim samefile pathlib_impl/meth.html#samefile,, proc samefile(self: Path; other_path: string | Path): bool 51 +nim cwd pathlib_impl/meth.html#cwd,typedesc[Path] proc cwd(_: typedesc[Path]): Path 54 +nim home pathlib_impl/meth.html#home,typedesc[Path] proc home(_: typedesc[Path]): Path 55 +nim open pathlib_impl/meth.html#open,,FileMode proc open(self: Path; mode: FileMode): File 57 +nim read_nstring pathlib_impl/meth.html#read_nstring proc read_nstring(self: Path): string 61 +nim write_nstring pathlib_impl/meth.html#write_nstring,string,string proc write_nstring(self, s: string) 65 +nim iterdir pathlib_impl/meth.html#iterdir.i iterator iterdir(self: Path): Path 70 +nim iterdir pathlib_impl/meth.html#iterdir proc iterdir(self: Path): IterDirGenerator 76 +nim mkdirParentsExistsOk pathlib_impl/meth.html#mkdirParentsExistsOk proc mkdirParentsExistsOk(self: Path) 83 +nimgrp / pathlib_impl/meth.html#/-procs-all proc 12 +nimgrp isrelativeto pathlib_impl/meth.html#is_relative_to-procs-all proc 22 diff --git a/Lib/pathlib_impl/os_meth.html b/Lib/pathlib_impl/os_meth.html new file mode 100644 index 000000000..499ba69a0 --- /dev/null +++ b/Lib/pathlib_impl/os_meth.html @@ -0,0 +1,154 @@ + + + + + + + +src/pylib/Lib/pathlib_impl/os_meth + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/pathlib_impl/os_meth

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

rely pylib/Lib/nos

+ +
+

Procs

+
+
+
+
proc stat(self: Path): stat_result {....raises: [ValueError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc touch(self: Path; mode = 0o000000000666; exist_ok = true) {.
+    ...raises: [PyOSError], tags: [TimeEffect], forbids: [].}
+
+ + Create this file with the given access mode, if it doesn't exist. + Source   +Edit   + +
+
+ +
+ + +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/pathlib_impl/os_meth.idx b/Lib/pathlib_impl/os_meth.idx new file mode 100644 index 000000000..70af62dc6 --- /dev/null +++ b/Lib/pathlib_impl/os_meth.idx @@ -0,0 +1,4 @@ +nimTitle os_meth pathlib_impl/os_meth.html module src/pylib/Lib/pathlib_impl/os_meth 0 +nim touch pathlib_impl/os_meth.html#touch,,int proc touch(self: Path; mode = 0o000000000666; exist_ok = true) 10 +nim unlink pathlib_impl/os_meth.html#unlink proc unlink(self: Path) 14 +nim stat pathlib_impl/os_meth.html#stat proc stat(self: Path): stat_result 18 diff --git a/Lib/pathlib_impl/segments.html b/Lib/pathlib_impl/segments.html new file mode 100644 index 000000000..d6158cc66 --- /dev/null +++ b/Lib/pathlib_impl/segments.html @@ -0,0 +1,321 @@ + + + + + + + +src/pylib/Lib/pathlib_impl/segments + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/pathlib_impl/segments

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Imports

+
+ types +
+
+
+

Procs

+
+
+
+
func name(self: Path): string {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func parent(self: Path): Path {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func parents(self: Path): seq[Path] {....raises: [], tags: [], forbids: [].}
+
+ + In Python: returns an immutable Sequence + Source   +Edit   + +
+
+ +
+
+
+
func parts(self: Path): seq[string] {....raises: [], tags: [], forbids: [].}
+
+ + Path.parts + Source   +Edit   + +
+
+ +
+
+
+
func stem(self: Path): string {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func suffix(self: Path): string {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func suffixes(self: Path): seq[string] {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func with_name(self: Path; name: string): Path {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func with_suffix(self: Path; suffix: string): Path {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Iterators

+
+
+
+
iterator parents(self: Path): Path {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
iterator parts(self: Path): string {....raises: [], tags: [], forbids: [].}
+
+ + Path.parts + Source   +Edit   + +
+
+ +
+
+
+
iterator suffixes(self: Path): string {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/pathlib_impl/segments.idx b/Lib/pathlib_impl/segments.idx new file mode 100644 index 000000000..662ad1c6b --- /dev/null +++ b/Lib/pathlib_impl/segments.idx @@ -0,0 +1,13 @@ +nimTitle segments pathlib_impl/segments.html module src/pylib/Lib/pathlib_impl/segments 0 +nim parts pathlib_impl/segments.html#parts.i iterator parts(self: Path): string 17 +nim parts pathlib_impl/segments.html#parts proc parts(self: Path): seq[string] 21 +nim parent pathlib_impl/segments.html#parent proc parent(self: Path): Path 26 +nim parents pathlib_impl/segments.html#parents.i iterator parents(self: Path): Path 29 +nim parents pathlib_impl/segments.html#parents proc parents(self: Path): seq[Path] 33 +nim name pathlib_impl/segments.html#name proc name(self: Path): string 38 +nim with_name pathlib_impl/segments.html#with_name,,string proc with_name(self: Path; name: string): Path 42 +nim suffix pathlib_impl/segments.html#suffix proc suffix(self: Path): string 54 +nim with_suffix pathlib_impl/segments.html#with_suffix,,string proc with_suffix(self: Path; suffix: string): Path 58 +nim suffixes pathlib_impl/segments.html#suffixes.i iterator suffixes(self: Path): string 66 +nim suffixes pathlib_impl/segments.html#suffixes proc suffixes(self: Path): seq[string] 69 +nim stem pathlib_impl/segments.html#stem proc stem(self: Path): string 72 diff --git a/Lib/pathlib_impl/types.html b/Lib/pathlib_impl/types.html new file mode 100644 index 000000000..a21b0a1fa --- /dev/null +++ b/Lib/pathlib_impl/types.html @@ -0,0 +1,185 @@ + + + + + + + +src/pylib/Lib/pathlib_impl/types + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/pathlib_impl/types

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Types

+
+
+
Path = distinct paths.Path
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
func `$`(p: Path): string {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func `/`(head, tail: Path): Path {.borrow, ...raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func `==`(head, tail: Path): bool {.borrow, ...raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func hash(self: Path): int {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/pathlib_impl/types.idx b/Lib/pathlib_impl/types.idx new file mode 100644 index 000000000..472567f38 --- /dev/null +++ b/Lib/pathlib_impl/types.idx @@ -0,0 +1,6 @@ +nimTitle types pathlib_impl/types.html module src/pylib/Lib/pathlib_impl/types 0 +nim Path pathlib_impl/types.html#Path type Path 11 +nim `==` pathlib_impl/types.html#==,Path,Path proc `==`(head, tail: Path): bool 12 +nim hash pathlib_impl/types.html#hash,Path proc hash(self: Path): int 14 +nim `/` pathlib_impl/types.html#/,Path,Path proc `/`(head, tail: Path): Path 23 +nim `$` pathlib_impl/types.html#$,Path proc `$`(p: Path): string 25 diff --git a/Lib/platform.html b/Lib/platform.html new file mode 100644 index 000000000..0c5abeb8b --- /dev/null +++ b/Lib/platform.html @@ -0,0 +1,180 @@ + + + + + + + +src/pylib/Lib/platform + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/platform

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
func machine(): PyStr {.inline, ...raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func python_implementation(): PyStr {.inline, ...raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func system(): PyStr {.inline, ...raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc version(): PyStr {....raises: [OSError, IOError],
+                        tags: [ExecIOEffect, ReadIOEffect, RootEffect],
+                        forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ + +
+
+ + +
+
+ + + diff --git a/Lib/private/platformInfo.html b/Lib/private/platformInfo.html new file mode 100644 index 000000000..440d3746d --- /dev/null +++ b/Lib/private/platformInfo.html @@ -0,0 +1,172 @@ + + + + + + + +src/pylib/Lib/private/platformInfo + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/private/platformInfo

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

used by Lib/os and Lib/platform

+
+

Consts

+
+
+
platform.system = "Linux"
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
proc ac_md_release(): string {....raises: [OSError, IOError],
+                               tags: [ExecIOEffect, ReadIOEffect, RootEffect],
+                               forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc platform.version(): string {....raises: [OSError, IOError], tags: [
+    ExecIOEffect, ReadIOEffect, RootEffect], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc uname_release_major(): string {....raises: [OSError, IOError], tags: [
+    ExecIOEffect, ReadIOEffect, RootEffect], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/private/platformInfo.idx b/Lib/private/platformInfo.idx new file mode 100644 index 000000000..f39c66200 --- /dev/null +++ b/Lib/private/platformInfo.idx @@ -0,0 +1,5 @@ +nimTitle platformInfo private/platformInfo.html module src/pylib/Lib/private/platformInfo 0 +nim platform.system private/platformInfo.html#platform.system const platform.system 18 +nim ac_md_release private/platformInfo.html#ac_md_release proc ac_md_release(): string 38 +nim uname_release_major private/platformInfo.html#uname_release_major proc uname_release_major(): string 53 +nim platform.version private/platformInfo.html#platform.version proc platform.version(): string 57 diff --git a/Lib/private/platformUtils.html b/Lib/private/platformUtils.html new file mode 100644 index 000000000..c4665b24d --- /dev/null +++ b/Lib/private/platformUtils.html @@ -0,0 +1,151 @@ + + + + + + + +src/pylib/Lib/private/platformUtils + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/private/platformUtils

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Consts

+
+
+
CLike = true
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Templates

+
+
+
+
template clikeOr(inCLike, b): untyped
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template impJsOrC(sym, cfloatSym, argSym) {.dirty.}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/private/platformUtils.idx b/Lib/private/platformUtils.idx new file mode 100644 index 000000000..9cd07c854 --- /dev/null +++ b/Lib/private/platformUtils.idx @@ -0,0 +1,4 @@ +nimTitle platformUtils private/platformUtils.html module src/pylib/Lib/private/platformUtils 0 +nim CLike private/platformUtils.html#CLike const CLike 2 +nim clikeOr private/platformUtils.html#clikeOr.t,, template clikeOr(inCLike, b): untyped 4 +nim impJsOrC private/platformUtils.html#impJsOrC.t,,, template impJsOrC(sym, cfloatSym, argSym) 12 diff --git a/Lib/random.html b/Lib/random.html new file mode 100644 index 000000000..472ed1b43 --- /dev/null +++ b/Lib/random.html @@ -0,0 +1,434 @@ + + + + + + + +src/pylib/Lib/random + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/random

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

Note: +global random state is indenpendent from Nim's std/random's
+
Note: +random() algorithm differs Python's, meaning the same seed produces different result
+

TODO: PyRandom uses method; impl SysRandom TODO: commandLine pysince(3,13)

+

+ +
+

Procs

+
+
+
+
func choice[T](self: PyRandom; ls: Sequence[T]): T
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func choices[T](self: PyRandom; population: Sequence[T];
+                weights: NoneType | Sequence[T] = None;
+                cum_weights: NoneType | Sequence[T] = None; k = 1): PyList[T]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func randbytes(self: PyRandom; n: int): PyBytes {....raises: [], tags: [],
+    forbids: [].}
+
+ +
Admonition: +since Python 3.9
+ + Source   +Edit   + +
+
+ +
+
+
+
func sample[T](self: PyRandom; population: Sequence[T]; k: int): PyList[T]
+
+ + + Source   +Edit   + +
+
+
+
func sample[T](self: PyRandom; population: Sequence[T]; k: int;
+               counts: Sequence[T]): PyList[T]
+
+ +
Admonition: +since Python 3.9
+ + Source   +Edit   + +
+
+ +
+
+
+
proc seed(self: PyRandom; _: NoneType) {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc seed(self: PyRandom; val: int64) {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func shuffle[T](self: PyRandom; x: var PyList[T])
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func triangular[F: SomeFloat](self: PyRandom; low: F = 0.0; high: F = 1.0;
+                              mode: F | NoneType = None): F
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template choice[T](ls: Sequence[T]): T
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template choices[T](population: Sequence[T];
+                    weights: NoneType | Sequence[T] = None;
+                    cum_weights: NoneType | Sequence[T] = None; k = 1): PyList[T]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template randbytes(n: int): PyBytes
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template sample[T](population: Sequence[T]; k: int): PyList[T]
+
+ + + Source   +Edit   + +
+
+
+
template sample[T](population: Sequence[T]; k: int; counts: Sequence[T]): PyList[
+    T]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template seed(_: NoneType)
+
+ + + Source   +Edit   + +
+
+
+
template seed(val: int64)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template shuffle[T](x: var PyList[T])
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template triangular[F: SomeFloat](low: F = 0.0; high: F = 1.0;
+                                  mode: F | NoneType = None): F
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ + +
+
+ + +
+
+ + + diff --git a/Lib/random.idx b/Lib/random.idx new file mode 100644 index 000000000..9be1ad8c3 --- /dev/null +++ b/Lib/random.idx @@ -0,0 +1,23 @@ +nimTitle random random.html module src/pylib/Lib/random 0 +nim seed random.html#seed,,NoneType proc seed(self: PyRandom; _: NoneType) 25 +nim seed random.html#seed.t,NoneType template seed(_: NoneType) 25 +nim seed random.html#seed,,int64 proc seed(self: PyRandom; val: int64) 26 +nim seed random.html#seed.t,int64 template seed(val: int64) 26 +nim randbytes random.html#randbytes,,int proc randbytes(self: PyRandom; n: int): PyBytes 28 +nim randbytes random.html#randbytes.t,int template randbytes(n: int): PyBytes 28 +nim shuffle random.html#shuffle,,PyList[T] proc shuffle[T](self: PyRandom; x: var PyList[T]) 31 +nim shuffle random.html#shuffle.t,PyList[T] template shuffle[T](x: var PyList[T]) 31 +nim sample random.html#sample,,Sequence[T],int proc sample[T](self: PyRandom; population: Sequence[T]; k: int): PyList[T] 34 +nim sample random.html#sample.t,Sequence[T],int template sample[T](population: Sequence[T]; k: int): PyList[T] 34 +nim sample random.html#sample,,Sequence[T],int,Sequence[T] proc sample[T](self: PyRandom; population: Sequence[T]; k: int; counts: Sequence[T]): PyList[\n T] 37 +nim sample random.html#sample.t,Sequence[T],int,Sequence[T] template sample[T](population: Sequence[T]; k: int; counts: Sequence[T]): PyList[T] 37 +nim choice random.html#choice,,Sequence[T] proc choice[T](self: PyRandom; ls: Sequence[T]): T 40 +nim choice random.html#choice.t,Sequence[T] template choice[T](ls: Sequence[T]): T 40 +nim choices random.html#choices,,Sequence[T],int proc choices[T](self: PyRandom; population: Sequence[T];\n weights: NoneType | Sequence[T] = None;\n cum_weights: NoneType | Sequence[T] = None; k = 1): PyList[T] 46 +nim choices random.html#choices.t,Sequence[T],int template choices[T](population: Sequence[T]; weights: NoneType | Sequence[T] = None;\n cum_weights: NoneType | Sequence[T] = None; k = 1): PyList[T] 46 +nim triangular random.html#triangular,,F,F proc triangular[F: SomeFloat](self: PyRandom; low: F = 0.0; high: F = 1.0;\n mode: F | NoneType = None): F 61 +nim triangular random.html#triangular.t,F,F template triangular[F: SomeFloat](low: F = 0.0; high: F = 1.0; mode: F | NoneType = None): F 61 +nimgrp sample random.html#sample-procs-all proc 34 +nimgrp seed random.html#seed-procs-all proc 25 +nimgrp sample random.html#sample-templates-all template 34 +nimgrp seed random.html#seed-templates-all template 25 diff --git a/Lib/random_impl/gstate.html b/Lib/random_impl/gstate.html new file mode 100644 index 000000000..027b5e4be --- /dev/null +++ b/Lib/random_impl/gstate.html @@ -0,0 +1,152 @@ + + + + + + + +src/pylib/Lib/random_impl/gstate + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/random_impl/gstate

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Imports

+
+ types +
+
+
+

Vars

+
+
+
gRandom = Random()
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Templates

+
+
+
+
template gRand(): untyped
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ + +
+
+ + +
+
+ + + diff --git a/Lib/random_impl/gstate.idx b/Lib/random_impl/gstate.idx new file mode 100644 index 000000000..ebf4ed264 --- /dev/null +++ b/Lib/random_impl/gstate.idx @@ -0,0 +1,3 @@ +nimTitle gstate random_impl/gstate.html module src/pylib/Lib/random_impl/gstate 0 +nim gRandom random_impl/gstate.html#gRandom var gRandom 5 +nim gRand random_impl/gstate.html#gRand.t template gRand(): untyped 7 diff --git a/Lib/random_impl/justLessThanOneConst.html b/Lib/random_impl/justLessThanOneConst.html new file mode 100644 index 000000000..e763f62c5 --- /dev/null +++ b/Lib/random_impl/justLessThanOneConst.html @@ -0,0 +1,112 @@ + + + + + + + +src/pylib/Lib/random_impl/justLessThanOneConst + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/random_impl/justLessThanOneConst

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

replace justLessThanOne declaration with hard-coded constant if you wanna get rid of n_math dependence

+
+

Imports

+
+ ../n_math +
+
+
+

Consts

+
+
+
justLessThanOne = 0.9999999999999999
+
+ + + Source   +Edit   + +
+
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/random_impl/justLessThanOneConst.idx b/Lib/random_impl/justLessThanOneConst.idx new file mode 100644 index 000000000..9a72b3d11 --- /dev/null +++ b/Lib/random_impl/justLessThanOneConst.idx @@ -0,0 +1,2 @@ +nimTitle justLessThanOneConst random_impl/justLessThanOneConst.html module src/pylib/Lib/random_impl/justLessThanOneConst 0 +nim justLessThanOne random_impl/justLessThanOneConst.html#justLessThanOne const justLessThanOne 5 diff --git a/Lib/random_impl/macroutils.html b/Lib/random_impl/macroutils.html new file mode 100644 index 000000000..ffe638bc7 --- /dev/null +++ b/Lib/random_impl/macroutils.html @@ -0,0 +1,135 @@ + + + + + + + +src/pylib/Lib/random_impl/macroutils + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/random_impl/macroutils

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Imports

+
+ gstate +
+
+
+

Macros

+
+
+
+
macro genGbl(decl)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
macro genGbls(decls)
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/random_impl/macroutils.idx b/Lib/random_impl/macroutils.idx new file mode 100644 index 000000000..c79cfdbda --- /dev/null +++ b/Lib/random_impl/macroutils.idx @@ -0,0 +1,3 @@ +nimTitle macroutils random_impl/macroutils.html module src/pylib/Lib/random_impl/macroutils 0 +nim genGbl random_impl/macroutils.html#genGbl.m macro genGbl(decl) 36 +nim genGbls random_impl/macroutils.html#genGbls.m macro genGbls(decls) 38 diff --git a/Lib/random_impl/proc_dispatched.html b/Lib/random_impl/proc_dispatched.html new file mode 100644 index 000000000..f5520a842 --- /dev/null +++ b/Lib/random_impl/proc_dispatched.html @@ -0,0 +1,494 @@ + + + + + + + +src/pylib/Lib/random_impl/proc_dispatched + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/random_impl/proc_dispatched

+
+ +
+ Source   +Edit   + +
+ +

functions and methods that can be directly dispatched to std/random

+ +
+

Procs

+
+
+
+
func choice[T](self: PyRandom; data: openArray[T]): T
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func genrand_uint32(self: PyRandom): uint32 {....raises: [], tags: [], forbids: [].}
+
+ + inner. + Source   +Edit   + +
+
+ +
+
+
+
proc getstate(): PyRandomState {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func guass(self: PyRandom; mu = 0.0; sigma = 1.0): float {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func randbelow[T: SomeInteger](self: PyRandom; n: T): T
+
+ + _randbelow inner. + Source   +Edit   + +
+
+ +
+
+
+
func randint[T: SomeInteger](self: PyRandom; a, b: T): T
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func randrange[T: SomeInteger](self: PyRandom; start, stop: T): T
+
+ + + Source   +Edit   + +
+
+
+
func randrange[T: SomeInteger](self: PyRandom; stop: T): T
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc setstate(state: PyRandomState) {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func uniform(self: PyRandom; a, b: float): float {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Methods

+
+
+
+
method random(self: PyRandom): float {.base, ...raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
method seed(self: PyRandom; val = none(int64)) {.base, ...raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template choice[T](data: openArray[T]): T
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template genrand_uint32(): uint32
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template guass(mu = 0.0; sigma = 1.0): float
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template randbelow[T: SomeInteger](n: T): T
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template randint[T: SomeInteger](a, b: T): T
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template random(): float
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template randrange[T: SomeInteger](start, stop: T): T
+
+ + + Source   +Edit   + +
+
+
+
template randrange[T: SomeInteger](stop: T): T
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template seed(val = none(int64))
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template uniform(a, b: float): float
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/random_impl/proc_dispatched.idx b/Lib/random_impl/proc_dispatched.idx new file mode 100644 index 000000000..74e159e82 --- /dev/null +++ b/Lib/random_impl/proc_dispatched.idx @@ -0,0 +1,25 @@ +nimTitle proc_dispatched random_impl/proc_dispatched.html module src/pylib/Lib/random_impl/proc_dispatched 0 +nim getstate random_impl/proc_dispatched.html#getstate proc getstate(): PyRandomState 13 +nim setstate random_impl/proc_dispatched.html#setstate,Rand proc setstate(state: PyRandomState) 14 +nim seed random_impl/proc_dispatched.html#seed.e method seed(self: PyRandom; val = none(int64)) 17 +nim seed random_impl/proc_dispatched.html#seed.t template seed(val = none(int64)) 17 +nim choice random_impl/proc_dispatched.html#choice,,openArray[T] proc choice[T](self: PyRandom; data: openArray[T]): T 23 +nim choice random_impl/proc_dispatched.html#choice.t,openArray[T] template choice[T](data: openArray[T]): T 23 +nim genrand_uint32 random_impl/proc_dispatched.html#genrand_uint32 proc genrand_uint32(self: PyRandom): uint32 25 +nim genrand_uint32 random_impl/proc_dispatched.html#genrand_uint32.t template genrand_uint32(): uint32 25 +nim randbelow random_impl/proc_dispatched.html#randbelow,,T proc randbelow[T: SomeInteger](self: PyRandom; n: T): T 26 +nim randbelow random_impl/proc_dispatched.html#randbelow.t,T template randbelow[T: SomeInteger](n: T): T 26 +nim randint random_impl/proc_dispatched.html#randint,,T,T proc randint[T: SomeInteger](self: PyRandom; a, b: T): T 28 +nim randint random_impl/proc_dispatched.html#randint.t,T,T template randint[T: SomeInteger](a, b: T): T 28 +nim randrange random_impl/proc_dispatched.html#randrange,,T proc randrange[T: SomeInteger](self: PyRandom; stop: T): T 30 +nim randrange random_impl/proc_dispatched.html#randrange.t,T template randrange[T: SomeInteger](stop: T): T 30 +nim randrange random_impl/proc_dispatched.html#randrange,,T,T proc randrange[T: SomeInteger](self: PyRandom; start, stop: T): T 34 +nim randrange random_impl/proc_dispatched.html#randrange.t,T,T template randrange[T: SomeInteger](start, stop: T): T 34 +nim random random_impl/proc_dispatched.html#random.e method random(self: PyRandom): float 38 +nim random random_impl/proc_dispatched.html#random.t template random(): float 38 +nim uniform random_impl/proc_dispatched.html#uniform,,float,float proc uniform(self: PyRandom; a, b: float): float 40 +nim uniform random_impl/proc_dispatched.html#uniform.t,float,float template uniform(a, b: float): float 40 +nim guass random_impl/proc_dispatched.html#guass,,float,float proc guass(self: PyRandom; mu = 0.0; sigma = 1.0): float 42 +nim guass random_impl/proc_dispatched.html#guass.t,float,float template guass(mu = 0.0; sigma = 1.0): float 42 +nimgrp randrange random_impl/proc_dispatched.html#randrange-procs-all proc 30 +nimgrp randrange random_impl/proc_dispatched.html#randrange-templates-all template 30 diff --git a/Lib/random_impl/proc_others.html b/Lib/random_impl/proc_others.html new file mode 100644 index 000000000..223a1aacc --- /dev/null +++ b/Lib/random_impl/proc_others.html @@ -0,0 +1,814 @@ + + + + + + + +src/pylib/Lib/random_impl/proc_others + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/random_impl/proc_others

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
func betavariate(self: PyRandom; alpha, beta: float): float {.
+    ...raises: [ValueError], tags: [], forbids: [].}
+
+ +

Beta distribution.

+

Conditions on the parameters are alpha > 0 and beta > 0. Returned values range between 0 and 1.

+

The mean (expected value) and variance of the random variable are:

+

 E[X] = alpha / (alpha + beta)
+ Var[X] = alpha * beta / ((alpha + beta)**2 * (alpha + beta + 1))

+ + Source   +Edit   + +
+
+ +
+
+
+
func binomialvariate(self: PyRandom; n = 1.0; p = 0.5): float {.
+    ...raises: [ValueError], tags: [], forbids: [].}
+
+ +

Binomial random variable.

+

Gives the number of successes for n independent trials with the probability of success in each trial being p:

+

sum(random() < p for i in range(n))

+

Returns an integer in the range: 0 <= X <= n

+

The mean (expected value) and variance of the random variable are:

+

E[X] = n * p
+Var[x] = n * p * (1 - p)

+ + Source   +Edit   + +
+
+ +
+
+
+
func choices[T](self: PyRandom; population: openArray[T];
+                weights = none(openArray[T]);
+                cum_weights = none(openArray[T]); k = 1): seq[T]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func expovariate(self: PyRandom; lambd = 1.0): float {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func gammavariate(self: PyRandom; alpha, beta: float): float {.
+    ...raises: [ValueError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func index[I: Ordinal](x: I): int
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func lognormalvariate(self: PyRandom; mu, sigma: float): float {....raises: [],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func normalvariate(self: PyRandom; mu = 0.0; sigma = 1.0): float {....raises: [],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func paretovariate(self: PyRandom; alpha: float): float {....raises: [], tags: [],
+    forbids: [].}
+
+ + Pareto distribution. alpha is the shape parameter. + Source   +Edit   + +
+
+ +
+
+
+
func randrange[I: SomeInteger](self: PyRandom; istart, istop: I; istep: I): I
+
+ + + Source   +Edit   + +
+
+
+
func randrange[T; I: Indexable[T]](self: PyRandom; start, stop, step: I): T
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func sample[T](self: PyRandom; population: openArray[T]; k: int): seq[T]
+
+ + + Source   +Edit   + +
+
+
+
func sample[T](self: PyRandom; population: openArray[T]; k: int;
+               counts: openArray[T]): seq[T]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func shuffle[T](self: PyRandom; x: var seq[T])
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func triangular[F: SomeFloat](self: PyRandom; low: F = 0.0; high: F = 1.0): F
+
+ + + Source   +Edit   + +
+
+
+
func triangular[F: SomeFloat](self: PyRandom; low: F = 0.0; high: F = 1.0;
+                              mode: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func vonmisesvariate(self: PyRandom; mu, kappa: float): float {....raises: [],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func weibullvariate(self: PyRandom; alpha, beta: float): float {....raises: [],
+    tags: [], forbids: [].}
+
+ +

Weibull distribution.

+

alpha is the scale parameter and beta is the shape parameter.

+ + Source   +Edit   + +
+
+ +
+ +
+
+
+

Methods

+
+
+
+
method getrandbits(self: PyRandom; k: int): int {.base, ...raises: [], tags: [],
+    forbids: [].}
+
+ + _random_Random_getrandbits_impl
Hint: +raises ValueError if k >= 8*sizeof(int)
+ + Source   +Edit   + +
+
+ +
+
+
+
method randbytes(self: PyRandom; n: int): string {.base, ...raises: [], tags: [],
+    forbids: [].}
+
+ + return self.getrandbits(n * 8).to_bytes(n, 'little') here we use _random_Random_getrandbits_impl + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template betavariate(alpha, beta: float): float
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template binomialvariate(n = 1.0; p = 0.5): float
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template choices[T](population: openArray[T]; weights = none(openArray[T]);
+                    cum_weights = none(openArray[T]); k = 1): seq[T]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template expovariate(lambd = 1.0): float
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template gammavariate(alpha, beta: float): float
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template getrandbits(k: int): int
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template lognormalvariate(mu, sigma: float): float
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template normalvariate(mu = 0.0; sigma = 1.0): float
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template paretovariate(alpha: float): float
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template randbytes(n: int): string
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template randrange[I: SomeInteger](istart, istop: I; istep: I): I
+
+ + + Source   +Edit   + +
+
+
+
template randrange[T; I: Indexable[T]](start, stop, step: I): T
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template sample[T](population: openArray[T]; k: int): seq[T]
+
+ + + Source   +Edit   + +
+
+
+
template sample[T](population: openArray[T]; k: int; counts: openArray[T]): seq[
+    T]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template shuffle[T](x: var seq[T])
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template shuffleImpl(self: PyRandom; x)
+
+ + inner. unstable. + Source   +Edit   + +
+
+ +
+
+
+
template triangular[F: SomeFloat](low: F = 0.0; high: F = 1.0): F
+
+ + + Source   +Edit   + +
+
+
+
template triangular[F: SomeFloat](low: F = 0.0; high: F = 1.0; mode: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template vonmisesvariate(mu, kappa: float): float
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template weibullvariate(alpha, beta: float): float
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/random_impl/proc_others.idx b/Lib/random_impl/proc_others.idx new file mode 100644 index 000000000..b47c53d8a --- /dev/null +++ b/Lib/random_impl/proc_others.idx @@ -0,0 +1,47 @@ +nimTitle proc_others random_impl/proc_others.html module src/pylib/Lib/random_impl/proc_others 0 +nim index random_impl/proc_others.html#index,I proc index[I: Ordinal](x: I): int 28 +nim randbytes random_impl/proc_others.html#randbytes.e,,int method randbytes(self: PyRandom; n: int): string 115 +nim randbytes random_impl/proc_others.html#randbytes.t,int template randbytes(n: int): string 115 +nim getrandbits random_impl/proc_others.html#getrandbits.e,,int method getrandbits(self: PyRandom; k: int): int 120 +nim getrandbits random_impl/proc_others.html#getrandbits.t,int template getrandbits(k: int): int 120 +nim randrange random_impl/proc_others.html#randrange,,I,I,I proc randrange[I: SomeInteger](self: PyRandom; istart, istop: I; istep: I): I 140 +nim randrange random_impl/proc_others.html#randrange.t,I,I,I template randrange[I: SomeInteger](istart, istop: I; istep: I): I 140 +nim randrange random_impl/proc_others.html#randrange,,I,I,I_2 proc randrange[T; I: Indexable[T]](self: PyRandom; start, stop, step: I): T 162 +nim randrange random_impl/proc_others.html#randrange.t,I,I,I_2 template randrange[T; I: Indexable[T]](start, stop, step: I): T 162 +nim choices random_impl/proc_others.html#choices,,openArray[T],typeof(none(openArray[T])),typeof(none(openArray[T])),int proc choices[T](self: PyRandom; population: openArray[T];\n weights = none(openArray[T]); cum_weights = none(openArray[T]); k = 1): seq[\n T] 166 +nim choices random_impl/proc_others.html#choices.t,openArray[T],typeof(none(openArray[T])),typeof(none(openArray[T])),int template choices[T](population: openArray[T]; weights = none(openArray[T]);\n cum_weights = none(openArray[T]); k = 1): seq[T] 166 +nim shuffleImpl random_impl/proc_others.html#shuffleImpl.t,PyRandom, template shuffleImpl(self: PyRandom; x) 198 +nim shuffle random_impl/proc_others.html#shuffle,,seq[T] proc shuffle[T](self: PyRandom; x: var seq[T]) 207 +nim shuffle random_impl/proc_others.html#shuffle.t,seq[T] template shuffle[T](x: var seq[T]) 207 +nim sample random_impl/proc_others.html#sample,,openArray[T],int proc sample[T](self: PyRandom; population: openArray[T]; k: int): seq[T] 210 +nim sample random_impl/proc_others.html#sample.t,openArray[T],int template sample[T](population: openArray[T]; k: int): seq[T] 210 +nim sample random_impl/proc_others.html#sample,,openArray[T],int,openArray[T] proc sample[T](self: PyRandom; population: openArray[T]; k: int; counts: openArray[T]): seq[\n T] 268 +nim sample random_impl/proc_others.html#sample.t,openArray[T],int,openArray[T] template sample[T](population: openArray[T]; k: int; counts: openArray[T]): seq[T] 268 +nim triangular random_impl/proc_others.html#triangular,,F,F proc triangular[F: SomeFloat](self: PyRandom; low: F = 0.0; high: F = 1.0): F 296 +nim triangular random_impl/proc_others.html#triangular.t,F,F template triangular[F: SomeFloat](low: F = 0.0; high: F = 1.0): F 296 +nim triangular random_impl/proc_others.html#triangular,,F,F,F proc triangular[F: SomeFloat](self: PyRandom; low: F = 0.0; high: F = 1.0; mode: F): F 299 +nim triangular random_impl/proc_others.html#triangular.t,F,F,F template triangular[F: SomeFloat](low: F = 0.0; high: F = 1.0; mode: F): F 299 +nim normalvariate random_impl/proc_others.html#normalvariate,,float,float proc normalvariate(self: PyRandom; mu = 0.0; sigma = 1.0): float 307 +nim normalvariate random_impl/proc_others.html#normalvariate.t,float,float template normalvariate(mu = 0.0; sigma = 1.0): float 307 +nim lognormalvariate random_impl/proc_others.html#lognormalvariate,,float,float proc lognormalvariate(self: PyRandom; mu, sigma: float): float 324 +nim lognormalvariate random_impl/proc_others.html#lognormalvariate.t,float,float template lognormalvariate(mu, sigma: float): float 324 +nim expovariate random_impl/proc_others.html#expovariate,,float proc expovariate(self: PyRandom; lambd = 1.0): float 327 +nim expovariate random_impl/proc_others.html#expovariate.t,float template expovariate(lambd = 1.0): float 327 +nim vonmisesvariate random_impl/proc_others.html#vonmisesvariate,,float,float proc vonmisesvariate(self: PyRandom; mu, kappa: float): float 330 +nim vonmisesvariate random_impl/proc_others.html#vonmisesvariate.t,float,float template vonmisesvariate(mu, kappa: float): float 330 +nim gammavariate random_impl/proc_others.html#gammavariate,,float,float proc gammavariate(self: PyRandom; alpha, beta: float): float 359 +nim gammavariate random_impl/proc_others.html#gammavariate.t,float,float template gammavariate(alpha, beta: float): float 359 +nim betavariate random_impl/proc_others.html#betavariate,,float,float proc betavariate(self: PyRandom; alpha, beta: float): float 418 +nim betavariate random_impl/proc_others.html#betavariate.t,float,float template betavariate(alpha, beta: float): float 418 +nim paretovariate random_impl/proc_others.html#paretovariate,,float proc paretovariate(self: PyRandom; alpha: float): float 451 +nim paretovariate random_impl/proc_others.html#paretovariate.t,float template paretovariate(alpha: float): float 451 +nim weibullvariate random_impl/proc_others.html#weibullvariate,,float,float proc weibullvariate(self: PyRandom; alpha, beta: float): float 458 +nim weibullvariate random_impl/proc_others.html#weibullvariate.t,float,float template weibullvariate(alpha, beta: float): float 458 +nim binomialvariate random_impl/proc_others.html#binomialvariate,,float,float proc binomialvariate(self: PyRandom; n = 1.0; p = 0.5): float 472 +nim binomialvariate random_impl/proc_others.html#binomialvariate.t,float,float template binomialvariate(n = 1.0; p = 0.5): float 472 +nimgrp triangular random_impl/proc_others.html#triangular-procs-all proc 296 +nimgrp sample random_impl/proc_others.html#sample-procs-all proc 210 +nimgrp randrange random_impl/proc_others.html#randrange-procs-all proc 140 +nimgrp triangular random_impl/proc_others.html#triangular-templates-all template 296 +nimgrp sample random_impl/proc_others.html#sample-templates-all template 210 +nimgrp randrange random_impl/proc_others.html#randrange-templates-all template 140 diff --git a/Lib/random_impl/types.html b/Lib/random_impl/types.html new file mode 100644 index 000000000..ccbc14527 --- /dev/null +++ b/Lib/random_impl/types.html @@ -0,0 +1,224 @@ + + + + + + + +src/pylib/Lib/random_impl/types + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/random_impl/types

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Types

+
+
+
PyRandom = ref object of RootObj
+
+ + + Source   +Edit   + +
+
+
+
PyRandomState = Rand
+
+ + unstable. + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
proc getmstate(self: PyRandom): var PyRandomState {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc Random(): PyRandom {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc Random(x: int64): PyRandom {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Methods

+
+
+
+
method getstate(self: PyRandom): PyRandomState {.base, ...raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
method setstate(self: PyRandom; state: PyRandomState) {.base, ...raises: [],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/random_impl/types.idx b/Lib/random_impl/types.idx new file mode 100644 index 000000000..61c2a503b --- /dev/null +++ b/Lib/random_impl/types.idx @@ -0,0 +1,9 @@ +nimTitle types random_impl/types.html module src/pylib/Lib/random_impl/types 0 +nim PyRandom random_impl/types.html#PyRandom type PyRandom 5 +nim Random random_impl/types.html#Random proc Random(): PyRandom 10 +nim Random random_impl/types.html#Random,int64 proc Random(x: int64): PyRandom 11 +nim PyRandomState random_impl/types.html#PyRandomState type PyRandomState 13 +nim getstate random_impl/types.html#getstate.e method getstate(self: PyRandom): PyRandomState 15 +nim getmstate random_impl/types.html#getmstate proc getmstate(self: PyRandom): var PyRandomState 16 +nim setstate random_impl/types.html#setstate.e,,Rand method setstate(self: PyRandom; state: PyRandomState) 19 +nimgrp Random random_impl/types.html#Random-procs-all proc 10 diff --git a/Lib/resource.html b/Lib/resource.html new file mode 100644 index 000000000..aabb694f5 --- /dev/null +++ b/Lib/resource.html @@ -0,0 +1,96 @@ + + + + + + + +src/pylib/Lib/resource + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/resource

+ + + +
+
+ + + diff --git a/Lib/resource.idx b/Lib/resource.idx new file mode 100644 index 000000000..5cc79e01b --- /dev/null +++ b/Lib/resource.idx @@ -0,0 +1 @@ +nimTitle resource resource.html module src/pylib/Lib/resource 0 diff --git a/Lib/resource_impl/consts.html b/Lib/resource_impl/consts.html new file mode 100644 index 000000000..7d4168456 --- /dev/null +++ b/Lib/resource_impl/consts.html @@ -0,0 +1,335 @@ + + + + + + + +src/pylib/Lib/resource_impl/consts + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/resource_impl/consts

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Imports

+
+ csyms +
+
+
+

Lets

+
+
+
RLIMIT_AS = int(cRLIMIT_AS)
+
+ + + Source   +Edit   + +
+
+
+
RLIMIT_CORE = int(cRLIMIT_CORE)
+
+ + + Source   +Edit   + +
+
+
+
RLIMIT_CPU = int(cRLIMIT_CPU)
+
+ + + Source   +Edit   + +
+
+
+
RLIMIT_DATA = int(cRLIMIT_DATA)
+
+ + + Source   +Edit   + +
+
+
+
RLIMIT_FSIZE = int(cRLIMIT_FSIZE)
+
+ + + Source   +Edit   + +
+
+
+
RLIMIT_MEMLOCK = int(cRLIMIT_MEMLOCK)
+
+ + + Source   +Edit   + +
+
+
+
RLIMIT_MSGQUEUE = int(cRLIMIT_MSGQUEUE)
+
+ + + Source   +Edit   + +
+
+
+
RLIMIT_NICE = int(cRLIMIT_NICE)
+
+ + + Source   +Edit   + +
+
+
+
RLIMIT_NOFILE = int(cRLIMIT_NOFILE)
+
+ + + Source   +Edit   + +
+
+
+
RLIMIT_NPROC = int(cRLIMIT_NPROC)
+
+ + + Source   +Edit   + +
+
+
+
RLIMIT_OFILE = int(cRLIMIT_OFILE)
+
+ + + Source   +Edit   + +
+
+
+
RLIMIT_RSS = int(cRLIMIT_RSS)
+
+ + + Source   +Edit   + +
+
+
+
RLIMIT_RTPRIO = int(cRLIMIT_RTPRIO)
+
+ + + Source   +Edit   + +
+
+
+
RLIMIT_RTTIME = int(cRLIMIT_RTTIME)
+
+ + + Source   +Edit   + +
+
+
+
RLIMIT_SIGPENDING = int(cRLIMIT_SIGPENDING)
+
+ + + Source   +Edit   + +
+
+
+
RLIMIT_STACK = int(cRLIMIT_STACK)
+
+ + + Source   +Edit   + +
+
+
+
RUSAGE_CHILDREN = int(cRUSAGE_CHILDREN)
+
+ + + Source   +Edit   + +
+
+
+
RUSAGE_SELF = int(cRUSAGE_SELF)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Consts

+
+
+
RLIM_INFINITY = 0xFFFFFFFF'u
+
+ + + Source   +Edit   + +
+
+
+
RUSAGE_THREAD = 1
+
+ + + Source   +Edit   + +
+
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/resource_impl/consts.idx b/Lib/resource_impl/consts.idx new file mode 100644 index 000000000..599d4d123 --- /dev/null +++ b/Lib/resource_impl/consts.idx @@ -0,0 +1,21 @@ +nimTitle consts resource_impl/consts.html module src/pylib/Lib/resource_impl/consts 0 +nim RLIM_INFINITY resource_impl/consts.html#RLIM_INFINITY const RLIM_INFINITY 4 +nim RLIMIT_CORE resource_impl/consts.html#RLIMIT_CORE let RLIMIT_CORE 12 +nim RLIMIT_CPU resource_impl/consts.html#RLIMIT_CPU let RLIMIT_CPU 12 +nim RLIMIT_FSIZE resource_impl/consts.html#RLIMIT_FSIZE let RLIMIT_FSIZE 12 +nim RLIMIT_DATA resource_impl/consts.html#RLIMIT_DATA let RLIMIT_DATA 12 +nim RLIMIT_STACK resource_impl/consts.html#RLIMIT_STACK let RLIMIT_STACK 12 +nim RLIMIT_RSS resource_impl/consts.html#RLIMIT_RSS let RLIMIT_RSS 12 +nim RLIMIT_NPROC resource_impl/consts.html#RLIMIT_NPROC let RLIMIT_NPROC 12 +nim RLIMIT_NOFILE resource_impl/consts.html#RLIMIT_NOFILE let RLIMIT_NOFILE 12 +nim RLIMIT_OFILE resource_impl/consts.html#RLIMIT_OFILE let RLIMIT_OFILE 12 +nim RLIMIT_MEMLOCK resource_impl/consts.html#RLIMIT_MEMLOCK let RLIMIT_MEMLOCK 12 +nim RLIMIT_AS resource_impl/consts.html#RLIMIT_AS let RLIMIT_AS 12 +nim RLIMIT_MSGQUEUE resource_impl/consts.html#RLIMIT_MSGQUEUE let RLIMIT_MSGQUEUE 12 +nim RLIMIT_NICE resource_impl/consts.html#RLIMIT_NICE let RLIMIT_NICE 12 +nim RLIMIT_RTPRIO resource_impl/consts.html#RLIMIT_RTPRIO let RLIMIT_RTPRIO 12 +nim RLIMIT_RTTIME resource_impl/consts.html#RLIMIT_RTTIME let RLIMIT_RTTIME 12 +nim RLIMIT_SIGPENDING resource_impl/consts.html#RLIMIT_SIGPENDING let RLIMIT_SIGPENDING 12 +nim RUSAGE_SELF resource_impl/consts.html#RUSAGE_SELF let RUSAGE_SELF 12 +nim RUSAGE_CHILDREN resource_impl/consts.html#RUSAGE_CHILDREN let RUSAGE_CHILDREN 12 +nim RUSAGE_THREAD resource_impl/consts.html#RUSAGE_THREAD const RUSAGE_THREAD 18 diff --git a/Lib/resource_impl/csyms.html b/Lib/resource_impl/csyms.html new file mode 100644 index 000000000..6107c4989 --- /dev/null +++ b/Lib/resource_impl/csyms.html @@ -0,0 +1,96 @@ + + + + + + + +src/pylib/Lib/resource_impl/csyms + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/resource_impl/csyms

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+ +
+ + +
+
+ + + diff --git a/Lib/resource_impl/csyms.idx b/Lib/resource_impl/csyms.idx new file mode 100644 index 000000000..b3dd65aea --- /dev/null +++ b/Lib/resource_impl/csyms.idx @@ -0,0 +1 @@ +nimTitle csyms resource_impl/csyms.html module src/pylib/Lib/resource_impl/csyms 0 diff --git a/Lib/resource_impl/funcs.html b/Lib/resource_impl/funcs.html new file mode 100644 index 000000000..ad6ed8742 --- /dev/null +++ b/Lib/resource_impl/funcs.html @@ -0,0 +1,266 @@ + + + + + + + +src/pylib/Lib/resource_impl/funcs + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/resource_impl/funcs

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Types

+
+
+
py_rlimit = tuple[rlim_cur: int, rlim_max: int]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
proc checked_resource(resource: int): cint {....raises: [ValueError], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc getpagesize(): int {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc getrlimit(resource: int): py_rlimit {....raises: [ValueError, PyOSError],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc getrusage(who: int): struct_rusage {....raises: [ValueError, PyOSError],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc prlimit(pid: int; resource: int): py_rlimit {.discardable,
+    ...raises: [ValueError, PyOSError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template prlimit[T: py_rlimit_abc | py_rlimit](pid: int; resource: int;
+    limits: T): py_rlimit
+
+ +

discardable.

+

this is defined as template. Because if being proc, py_rlimit_abc match cannot work

+ + Source   +Edit   + +
+
+ +
+
+
+
template setrlimit[T: py_rlimit_abc | py_rlimit](resource: int; limits: T)
+
+ + this is defined as template. Because if being proc, py_rlimit_abc match cannot work + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/resource_impl/funcs.idx b/Lib/resource_impl/funcs.idx new file mode 100644 index 000000000..a88a83b7e --- /dev/null +++ b/Lib/resource_impl/funcs.idx @@ -0,0 +1,9 @@ +nimTitle funcs resource_impl/funcs.html module src/pylib/Lib/resource_impl/funcs 0 +nim getrusage resource_impl/funcs.html#getrusage,int proc getrusage(who: int): struct_rusage 9 +nim py_rlimit resource_impl/funcs.html#py_rlimit tuple py_rlimit 18 +nim checked_resource resource_impl/funcs.html#checked_resource,int proc checked_resource(resource: int): cint 43 +nim getrlimit resource_impl/funcs.html#getrlimit,int proc getrlimit(resource: int): py_rlimit 48 +nim setrlimit resource_impl/funcs.html#setrlimit.t,int,T template setrlimit[T: py_rlimit_abc | py_rlimit](resource: int; limits: T) 64 +nim prlimit resource_impl/funcs.html#prlimit,int,int proc prlimit(pid: int; resource: int): py_rlimit 78 +nim prlimit resource_impl/funcs.html#prlimit.t,int,int,T template prlimit[T: py_rlimit_abc | py_rlimit](pid: int; resource: int; limits: T): py_rlimit 95 +nim getpagesize resource_impl/funcs.html#getpagesize proc getpagesize(): int 112 diff --git a/Lib/resource_impl/types.html b/Lib/resource_impl/types.html new file mode 100644 index 000000000..95af4715e --- /dev/null +++ b/Lib/resource_impl/types.html @@ -0,0 +1,167 @@ + + + + + + + +src/pylib/Lib/resource_impl/types + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/resource_impl/types

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Types

+
+
+
struct_rusage = ref object
+  ru_utime*: float
+  ru_stime*: float
+  ru_maxrss*: int
+  ru_ixrss*: int
+  ru_idrss*: int
+  ru_isrss*: int
+  ru_minflt*: int
+  ru_majflt*: int
+  ru_nswap*: int
+  ru_inblock*: int
+  ru_oublock*: int
+  ru_msgsnd*: int
+  ru_msgrcv*: int
+  ru_nsignals*: int
+  ru_nvcsw*: int
+  ru_nivcsw*: int
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
proc toPyObject(rusage: Rusage): struct_rusage {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/resource_impl/types.idx b/Lib/resource_impl/types.idx new file mode 100644 index 000000000..65b6e2ab0 --- /dev/null +++ b/Lib/resource_impl/types.idx @@ -0,0 +1,3 @@ +nimTitle types resource_impl/types.html module src/pylib/Lib/resource_impl/types 0 +nim struct_rusage resource_impl/types.html#struct_rusage type struct_rusage 5 +nim toPyObject resource_impl/types.html#toPyObject,Rusage proc toPyObject(rusage: Rusage): struct_rusage 26 diff --git a/Lib/shutil.html b/Lib/shutil.html new file mode 100644 index 000000000..e0551bff9 --- /dev/null +++ b/Lib/shutil.html @@ -0,0 +1,96 @@ + + + + + + + +src/pylib/Lib/shutil + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/shutil

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Imports

+
+ n_shutil +
+
+ + +
+
+ + +
+
+ + + diff --git a/Lib/shutil.idx b/Lib/shutil.idx new file mode 100644 index 000000000..42cd936a1 --- /dev/null +++ b/Lib/shutil.idx @@ -0,0 +1 @@ +nimTitle shutil shutil.html module src/pylib/Lib/shutil 0 diff --git a/Lib/shutil_impl/copys.html b/Lib/shutil_impl/copys.html new file mode 100644 index 000000000..ddf99de51 --- /dev/null +++ b/Lib/shutil_impl/copys.html @@ -0,0 +1,184 @@ + + + + + + + +src/pylib/Lib/shutil_impl/copys + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/shutil_impl/copys

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Types

+
+
+
SameFileError = object of Error
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
proc copy[T](src`gensym6, dst`gensym6: PathLike[T];
+             follow_symlinks`gensym6 = true)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc copyfile[T](src`gensym5, dst`gensym5: PathLike[T];
+                 follow_symlinks`gensym5 = true)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc copyfileobj(s, d: File; length = COPY_BUFSIZE) {.
+    ...raises: [IOError, OSError], tags: [WriteIOEffect, ReadIOEffect], forbids: [].}
+
+ +

shutil.copyfileobj but for Nim's File

+

if length is negative, it means copying the data without looping over the source data in chunks

+ + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/shutil_impl/copys.idx b/Lib/shutil_impl/copys.idx new file mode 100644 index 000000000..d5b3cb8fd --- /dev/null +++ b/Lib/shutil_impl/copys.idx @@ -0,0 +1,5 @@ +nimTitle copys shutil_impl/copys.html module src/pylib/Lib/shutil_impl/copys 0 +nim copyfileobj shutil_impl/copys.html#copyfileobj,File,File proc copyfileobj(s, d: File; length = COPY_BUFSIZE) 36 +nim SameFileError shutil_impl/copys.html#SameFileError object SameFileError 48 +nim copyfile shutil_impl/copys.html#copyfile,, proc copyfile[T](src`gensym5, dst`gensym5: PathLike[T];\n follow_symlinks`gensym5 = true) 81 +nim copy shutil_impl/copys.html#copy,, proc copy[T](src`gensym6, dst`gensym6: PathLike[T]; follow_symlinks`gensym6 = true) 91 diff --git a/Lib/shutil_impl/rmtreeImpl.html b/Lib/shutil_impl/rmtreeImpl.html new file mode 100644 index 000000000..e0216755e --- /dev/null +++ b/Lib/shutil_impl/rmtreeImpl.html @@ -0,0 +1,123 @@ + + + + + + + +src/pylib/Lib/shutil_impl/rmtreeImpl + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/shutil_impl/rmtreeImpl

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
proc rmtree(path: string; ignore_errors = false; onerror: OnExc = nil;
+            onexc: OnExc = nil; dir_fd = -1) {.
+    ...raises: [Exception, NotImplementedError, ValueError], tags: [RootEffect],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/shutil_impl/rmtreeImpl.idx b/Lib/shutil_impl/rmtreeImpl.idx new file mode 100644 index 000000000..be2f63ead --- /dev/null +++ b/Lib/shutil_impl/rmtreeImpl.idx @@ -0,0 +1,2 @@ +nimTitle rmtreeImpl shutil_impl/rmtreeImpl.html module src/pylib/Lib/shutil_impl/rmtreeImpl 0 +nim rmtree shutil_impl/rmtreeImpl.html#rmtree,string,OnExc,OnExc,int proc rmtree(path: string; ignore_errors = false; onerror: OnExc = nil;\n onexc: OnExc = nil; dir_fd = -1) 207 diff --git a/Lib/shutil_impl/sys.html b/Lib/shutil_impl/sys.html new file mode 100644 index 000000000..dd7ce2c6b --- /dev/null +++ b/Lib/shutil_impl/sys.html @@ -0,0 +1,96 @@ + + + + + + + +src/pylib/Lib/shutil_impl/sys + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/shutil_impl/sys

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Exports

+
+ audit +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/shutil_impl/sys.idx b/Lib/shutil_impl/sys.idx new file mode 100644 index 000000000..63fdc9e54 --- /dev/null +++ b/Lib/shutil_impl/sys.idx @@ -0,0 +1 @@ +nimTitle sys shutil_impl/sys.html module src/pylib/Lib/shutil_impl/sys 0 diff --git a/Lib/shutil_impl/terminals.html b/Lib/shutil_impl/terminals.html new file mode 100644 index 000000000..7f100849c --- /dev/null +++ b/Lib/shutil_impl/terminals.html @@ -0,0 +1,113 @@ + + + + + + + +src/pylib/Lib/shutil_impl/terminals + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/shutil_impl/terminals

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Procs

+
+
+
+
proc get_terminal_size(fallback = (80, 24)): terminal_size {....raises: [],
+    tags: [ReadEnvEffect], forbids: [].}
+
+ +
Hint: +this does not simply refer to environment variable,
+

call os.get_terminal_size. This is a wrapper around terminalSize of std/terminal, which is more steady, returning meaningful result even when stdout is not associatd with a terminal.

+ + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/shutil_impl/terminals.idx b/Lib/shutil_impl/terminals.idx new file mode 100644 index 000000000..990d32c43 --- /dev/null +++ b/Lib/shutil_impl/terminals.idx @@ -0,0 +1,2 @@ +nimTitle terminals shutil_impl/terminals.html module src/pylib/Lib/shutil_impl/terminals 0 +nim get_terminal_size shutil_impl/terminals.html#get_terminal_size,(int, int) proc get_terminal_size(fallback = (80, 24)): terminal_size 7 diff --git a/Lib/signal.html b/Lib/signal.html new file mode 100644 index 000000000..f9506c5ea --- /dev/null +++ b/Lib/signal.html @@ -0,0 +1,184 @@ + + + + + + + +src/pylib/Lib/signal + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/signal

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
proc pthread_sigmask(how: int; mask: Sigset): PySet[int] {....raises: [PyOSError],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc sigpending(): PySet[int] {....raises: [PyOSError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc strsignal(signalnum: int): OptionalObj[PyStr] {....raises: [ValueError],
+    tags: [], forbids: [].}
+
+ +
Admonition: +since Python 3.8
+ + Source   +Edit   + +
+
+ +
+
+
+
proc valid_signals(): PySet[int] {....raises: [PyOSError], tags: [], forbids: [].}
+
+ +
Admonition: +since Python 3.8
+ + Source   +Edit   + +
+
+ +
+ +
+
+ + +
+
+ + +
+
+ + + diff --git a/Lib/signal.idx b/Lib/signal.idx new file mode 100644 index 000000000..e1b34f0dd --- /dev/null +++ b/Lib/signal.idx @@ -0,0 +1,5 @@ +nimTitle signal signal.html module src/pylib/Lib/signal 0 +nim sigpending signal.html#sigpending proc sigpending(): PySet[int] 18 +nim pthread_sigmask signal.html#pthread_sigmask,int,Sigset proc pthread_sigmask(how: int; mask: Sigset): PySet[int] 20 +nim strsignal signal.html#strsignal,int proc strsignal(signalnum: int): OptionalObj[PyStr] 31 +nim valid_signals signal.html#valid_signals proc valid_signals(): PySet[int] 35 diff --git a/Lib/signal_impl/abc_set.html b/Lib/signal_impl/abc_set.html new file mode 100644 index 000000000..4a079531b --- /dev/null +++ b/Lib/signal_impl/abc_set.html @@ -0,0 +1,136 @@ + + + + + + + +src/pylib/Lib/signal_impl/abc_set + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/signal_impl/abc_set

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Types

+
+
+
Set[T] = concept self
+    self.add T
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
proc add(self: var SomeSet[int]; i: int)
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/signal_impl/abc_set.idx b/Lib/signal_impl/abc_set.idx new file mode 100644 index 000000000..f4df2358d --- /dev/null +++ b/Lib/signal_impl/abc_set.idx @@ -0,0 +1,3 @@ +nimTitle abc_set signal_impl/abc_set.html module src/pylib/Lib/signal_impl/abc_set 0 +nim add signal_impl/abc_set.html#add,SomeSet[int],int proc add(self: var SomeSet[int]; i: int) 3 +nim Set signal_impl/abc_set.html#Set type Set 5 diff --git a/Lib/signal_impl/c_api.html b/Lib/signal_impl/c_api.html new file mode 100644 index 000000000..1cfb4c3d6 --- /dev/null +++ b/Lib/signal_impl/c_api.html @@ -0,0 +1,126 @@ + + + + + + + +src/pylib/Lib/signal_impl/c_api + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/signal_impl/c_api

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Procs

+
+
+
+
proc PyErr_CheckSignals(): int {....raises: [], tags: [], forbids: [].}
+
+ + XXX: currently does nothing + Source   +Edit   + +
+
+ +
+
+
+
proc PyErr_CheckSignalsAndRaises() {....raises: [], tags: [], forbids: [].}
+
+ + XXX: currently does nothing + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/signal_impl/c_api.idx b/Lib/signal_impl/c_api.idx new file mode 100644 index 000000000..8eace3034 --- /dev/null +++ b/Lib/signal_impl/c_api.idx @@ -0,0 +1,3 @@ +nimTitle c_api signal_impl/c_api.html module src/pylib/Lib/signal_impl/c_api 0 +nim PyErr_CheckSignals signal_impl/c_api.html#PyErr_CheckSignals proc PyErr_CheckSignals(): int 2 +nim PyErr_CheckSignalsAndRaises signal_impl/c_api.html#PyErr_CheckSignalsAndRaises proc PyErr_CheckSignalsAndRaises() 3 diff --git a/Lib/signal_impl/c_py_handler_cvt.html b/Lib/signal_impl/c_py_handler_cvt.html new file mode 100644 index 000000000..6ac188074 --- /dev/null +++ b/Lib/signal_impl/c_py_handler_cvt.html @@ -0,0 +1,136 @@ + + + + + + + +src/pylib/Lib/signal_impl/c_py_handler_cvt + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/signal_impl/c_py_handler_cvt

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
proc toCSighandler(p: PySigHandler): CSigHandler {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc toPySighandler(p: CSigHandler | NimSigHandler): PySigHandler
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/signal_impl/c_py_handler_cvt.idx b/Lib/signal_impl/c_py_handler_cvt.idx new file mode 100644 index 000000000..929874c43 --- /dev/null +++ b/Lib/signal_impl/c_py_handler_cvt.idx @@ -0,0 +1,3 @@ +nimTitle c_py_handler_cvt signal_impl/c_py_handler_cvt.html module src/pylib/Lib/signal_impl/c_py_handler_cvt 0 +nim toCSighandler signal_impl/c_py_handler_cvt.html#toCSighandler,PySigHandler proc toCSighandler(p: PySigHandler): CSigHandler 4 +nim toPySighandler signal_impl/c_py_handler_cvt.html#toPySighandler proc toPySighandler(p: CSigHandler | NimSigHandler): PySigHandler 10 diff --git a/Lib/signal_impl/chk_util.html b/Lib/signal_impl/chk_util.html new file mode 100644 index 000000000..d1898945e --- /dev/null +++ b/Lib/signal_impl/chk_util.html @@ -0,0 +1,118 @@ + + + + + + + +src/pylib/Lib/signal_impl/chk_util + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/signal_impl/chk_util

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Imports

+
+ pynsig +
+
+
+

Procs

+
+
+
+
func chkSigRng(signalnum: cint | int)
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/signal_impl/chk_util.idx b/Lib/signal_impl/chk_util.idx new file mode 100644 index 000000000..099637d44 --- /dev/null +++ b/Lib/signal_impl/chk_util.idx @@ -0,0 +1,2 @@ +nimTitle chk_util signal_impl/chk_util.html module src/pylib/Lib/signal_impl/chk_util 0 +nim chkSigRng signal_impl/chk_util.html#chkSigRng proc chkSigRng(signalnum: cint | int) 4 diff --git a/Lib/signal_impl/enums.html b/Lib/signal_impl/enums.html new file mode 100644 index 000000000..3bf0d493c --- /dev/null +++ b/Lib/signal_impl/enums.html @@ -0,0 +1,1292 @@ + + + + + + + +src/pylib/Lib/signal_impl/enums + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/signal_impl/enums

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Lets

+
+
+
ITIMER_PROF = int(ITIMER_PROF)
+
+ + + Source   +Edit   + +
+
+
+
ITIMER_REAL = int(ITIMER_REAL)
+
+ + + Source   +Edit   + +
+
+
+
ITIMER_VIRTUAL = int(ITIMER_VIRTUAL)
+
+ + + Source   +Edit   + +
+
+
+
SIG_BLOCK = add_member(Sigmasks, "SIG_BLOCK", 0'i32)
+
+ + + Source   +Edit   + +
+
+
+
SIG_DFL = add_member(Handlers, "SIG_DFL", cast[int](SIG_DFL))
+
+ + + Source   +Edit   + +
+
+
+
SIG_IGN = add_member(Handlers, "SIG_IGN", cast[int](SIG_IGN))
+
+ + + Source   +Edit   + +
+
+
+
SIG_SETMASK = add_member(Sigmasks, "SIG_SETMASK", 2'i32)
+
+ + + Source   +Edit   + +
+
+
+
SIG_UNBLOCK = add_member(Sigmasks, "SIG_UNBLOCK", 1'i32)
+
+ + + Source   +Edit   + +
+
+
+
SIGABRT = add_member(Signals, "SIGABRT", 6'i32)
+
+ + + Source   +Edit   + +
+
+
+
SIGALRM = add_member(Signals, "SIGALRM", 14'i32)
+
+ + + Source   +Edit   + +
+
+
+
SIGBUS = add_member(Signals, "SIGBUS", 7'i32)
+
+ + + Source   +Edit   + +
+
+
+
SIGCHLD = add_member(Signals, "SIGCHLD", 17'i32)
+
+ + + Source   +Edit   + +
+
+
+
SIGCLD = add_member(Signals, "SIGCLD", 17)
+
+ + + Source   +Edit   + +
+
+
+
SIGCONT = add_member(Signals, "SIGCONT", 18'i32)
+
+ + + Source   +Edit   + +
+
+
+
SIGFPE = add_member(Signals, "SIGFPE", 8'i32)
+
+ + + Source   +Edit   + +
+
+
+
SIGHUP = add_member(Signals, "SIGHUP", 1'i32)
+
+ + + Source   +Edit   + +
+
+
+
SIGILL = add_member(Signals, "SIGILL", 4'i32)
+
+ + + Source   +Edit   + +
+
+
+
SIGINT = add_member(Signals, "SIGINT", 2'i32)
+
+ + + Source   +Edit   + +
+
+
+
SIGIO = add_member(Signals, "SIGIO", 29)
+
+ + + Source   +Edit   + +
+
+
+
SIGIOT = add_member(Signals, "SIGIOT", 6)
+
+ + + Source   +Edit   + +
+
+
+
SIGKILL = add_member(Signals, "SIGKILL", 9'i32)
+
+ + + Source   +Edit   + +
+
+
+
SIGPIPE = add_member(Signals, "SIGPIPE", 13'i32)
+
+ + + Source   +Edit   + +
+
+
+
SIGPOLL = add_member(Signals, "SIGPOLL", 29'i32)
+
+ + + Source   +Edit   + +
+
+
+
SIGPROF = add_member(Signals, "SIGPROF", 27'i32)
+
+ + + Source   +Edit   + +
+
+
+
SIGPWR = add_member(Signals, "SIGPWR", 30)
+
+ + + Source   +Edit   + +
+
+
+
SIGQUIT = add_member(Signals, "SIGQUIT", 3'i32)
+
+ + + Source   +Edit   + +
+
+
+
SIGRTMAX = add_member(Signals, "SIGRTMAX", 64)
+
+ + + Source   +Edit   + +
+
+
+
SIGRTMIN = add_member(Signals, "SIGRTMIN", 34)
+
+ + + Source   +Edit   + +
+
+
+
SIGSEGV = add_member(Signals, "SIGSEGV", 11'i32)
+
+ + + Source   +Edit   + +
+
+
+
SIGSTKFLT = add_member(Signals, "SIGSTKFLT", 16)
+
+ + + Source   +Edit   + +
+
+
+
SIGSTOP = add_member(Signals, "SIGSTOP", 19'i32)
+
+ + + Source   +Edit   + +
+
+
+
SIGSYS = add_member(Signals, "SIGSYS", 31'i32)
+
+ + + Source   +Edit   + +
+
+
+
SIGTERM = add_member(Signals, "SIGTERM", 15'i32)
+
+ + + Source   +Edit   + +
+
+
+
SIGTRAP = add_member(Signals, "SIGTRAP", 5'i32)
+
+ + + Source   +Edit   + +
+
+
+
SIGTSTP = add_member(Signals, "SIGTSTP", 20'i32)
+
+ + + Source   +Edit   + +
+
+
+
SIGTTIN = add_member(Signals, "SIGTTIN", 21'i32)
+
+ + + Source   +Edit   + +
+
+
+
SIGTTOU = add_member(Signals, "SIGTTOU", 22'i32)
+
+ + + Source   +Edit   + +
+
+
+
SIGURG = add_member(Signals, "SIGURG", 23'i32)
+
+ + + Source   +Edit   + +
+
+
+
SIGUSR1 = add_member(Signals, "SIGUSR1", 10'i32)
+
+ + + Source   +Edit   + +
+
+
+
SIGUSR2 = add_member(Signals, "SIGUSR2", 12'i32)
+
+ + + Source   +Edit   + +
+
+
+
SIGVTALRM = add_member(Signals, "SIGVTALRM", 26'i32)
+
+ + + Source   +Edit   + +
+
+
+
SIGWINCH = add_member(Signals, "SIGWINCH", 28)
+
+ + + Source   +Edit   + +
+
+
+
SIGXCPU = add_member(Signals, "SIGXCPU", 24'i32)
+
+ + + Source   +Edit   + +
+
+
+
SIGXFSZ = add_member(Signals, "SIGXFSZ", 25'i32)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
proc `$`(self: Handlers): string {....raises: [KeyError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc `$`(self: Sigmasks): string {....raises: [KeyError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc `$`(self: Signals): string {....raises: [KeyError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc `==`(self: Handlers; other: Handlers): bool {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc `==`(self: Sigmasks; other: Sigmasks): bool {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc `==`(self: Signals; other: Signals): bool {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc `[]`(cls: cls:type; name: string): Handlers
+
+ + + Source   +Edit   + +
+
+
+
proc `[]`(cls: cls:type; name: string): Sigmasks
+
+ + + Source   +Edit   + +
+
+
+
proc `[]`(cls: cls:type; name: string): Signals
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc add_alias(self: Handlers; name: string) {....raises: [KeyError, NameError],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc add_alias(self: Sigmasks; name: string) {....raises: [KeyError, NameError],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc add_alias(self: Signals; name: string) {....raises: [KeyError, NameError],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc add_member(enum_class: typedesc[Handlers]; name: string; value: int): Handlers
+
+ + + Source   +Edit   + +
+
+
+
proc add_member(enum_class: typedesc[Sigmasks]; name: string; value: int): Sigmasks
+
+ + + Source   +Edit   + +
+
+
+
proc add_member(enum_class: typedesc[Signals]; name: string; value: int): Signals
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc contains(cls: cls:type; value: int): bool
+
+ + + Source   +Edit   + +
+
+
+
proc contains(cls: cls:type; value: int): bool
+
+ + + Source   +Edit   + +
+
+
+
proc contains(cls: cls:type; value: int): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc Handlers(value: Handlers): Handlers {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc Handlers(value: int): Handlers {....raises: [KeyError, ValueError], tags: [],
+                                      forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc hash(self: Handlers): Hash {....raises: [KeyError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc hash(self: Sigmasks): Hash {....raises: [KeyError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc hash(self: Signals): Hash {....raises: [KeyError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc len(cls: cls:type): int
+
+ + + Source   +Edit   + +
+
+
+
proc len(cls: cls:type): int
+
+ + + Source   +Edit   + +
+
+
+
proc len(cls: cls:type): int
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc name(self: Handlers): string {.inline, ...raises: [KeyError], tags: [],
+                                    forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc name(self: Sigmasks): string {.inline, ...raises: [KeyError], tags: [],
+                                    forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc name(self: Signals): string {.inline, ...raises: [KeyError], tags: [],
+                                   forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc repr(self: Handlers): string {....raises: [KeyError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc repr(self: Sigmasks): string {....raises: [KeyError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc repr(self: Signals): string {....raises: [KeyError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc Sigmasks(value: int): Sigmasks {....raises: [KeyError, ValueError], tags: [],
+                                      forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc Sigmasks(value: Sigmasks): Sigmasks {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc Signals(value: int): Signals {....raises: [KeyError, ValueError], tags: [],
+                                    forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc Signals(value: Signals): Signals {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc value(self: Handlers): int {.inline, ...raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc value(self: Sigmasks): int {.inline, ...raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc value(self: Signals): int {.inline, ...raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Iterators

+
+
+
+
iterator items(cls: cls:type): Handlers
+
+ + + Source   +Edit   + +
+
+
+
iterator items(cls: cls:type): Sigmasks
+
+ + + Source   +Edit   + +
+
+
+
iterator items(cls: cls:type): Signals
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Converters

+
+
+
+
converter toInt(self: Handlers): int {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
converter toInt(self: Sigmasks): int {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
converter toInt(self: Signals): int {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template contains(cls; value: Handlers): bool
+
+ + + Source   +Edit   + +
+
+
+
template contains(cls; value: Sigmasks): bool
+
+ + + Source   +Edit   + +
+
+
+
template contains(cls; value: Signals): bool
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ + +
+
+ + +
+
+ + + diff --git a/Lib/signal_impl/enums.idx b/Lib/signal_impl/enums.idx new file mode 100644 index 000000000..9da9681a6 --- /dev/null +++ b/Lib/signal_impl/enums.idx @@ -0,0 +1,110 @@ +nimTitle enums signal_impl/enums.html module src/pylib/Lib/signal_impl/enums 0 +nim ITIMER_REAL signal_impl/enums.html#ITIMER_REAL let ITIMER_REAL 11 +nim ITIMER_VIRTUAL signal_impl/enums.html#ITIMER_VIRTUAL let ITIMER_VIRTUAL 11 +nim ITIMER_PROF signal_impl/enums.html#ITIMER_PROF let ITIMER_PROF 11 +nim value signal_impl/enums.html#value proc value(self: Signals): int 24 +nim name signal_impl/enums.html#name proc name(self: Signals): string 26 +nim repr signal_impl/enums.html#repr proc repr(self: Signals): string 28 +nim `$` signal_impl/enums.html#$ proc `$`(self: Signals): string 35 +nim hash signal_impl/enums.html#hash proc hash(self: Signals): Hash 37 +nim `==` signal_impl/enums.html#==,,Signals proc `==`(self: Signals; other: Signals): bool 39 +nim add_alias signal_impl/enums.html#add_alias,,string proc add_alias(self: Signals; name: string) 48 +nim add_member signal_impl/enums.html#add_member,typedesc[Signals],string,int proc add_member(enum_class: typedesc[Signals]; name: string; value: int): Signals 54 +nim `[]` signal_impl/enums.html#[],,string proc `[]`(cls: cls:type; name: string): Signals 68 +nim len signal_impl/enums.html#len proc len(cls: cls:type): int 69 +nim items signal_impl/enums.html#items.i iterator items(cls: cls:type): Signals 70 +nim contains signal_impl/enums.html#contains.t,,Signals template contains(cls; value: Signals): bool 73 +nim contains signal_impl/enums.html#contains,,int proc contains(cls: cls:type; value: int): bool 9 +nim toInt signal_impl/enums.html#toInt.c,Signals converter toInt(self: Signals): int 18 +nim Signals signal_impl/enums.html#Signals,Signals proc Signals(value: Signals): Signals 7 +nim Signals signal_impl/enums.html#Signals,int proc Signals(value: int): Signals 22 +nim SIGHUP signal_impl/enums.html#SIGHUP let SIGHUP 25 +nim SIGINT signal_impl/enums.html#SIGINT let SIGINT 25 +nim SIGQUIT signal_impl/enums.html#SIGQUIT let SIGQUIT 25 +nim SIGILL signal_impl/enums.html#SIGILL let SIGILL 25 +nim SIGTRAP signal_impl/enums.html#SIGTRAP let SIGTRAP 25 +nim SIGIOT signal_impl/enums.html#SIGIOT let SIGIOT 25 +nim SIGABRT signal_impl/enums.html#SIGABRT let SIGABRT 25 +nim SIGFPE signal_impl/enums.html#SIGFPE let SIGFPE 25 +nim SIGKILL signal_impl/enums.html#SIGKILL let SIGKILL 25 +nim SIGBUS signal_impl/enums.html#SIGBUS let SIGBUS 25 +nim SIGSEGV signal_impl/enums.html#SIGSEGV let SIGSEGV 25 +nim SIGSYS signal_impl/enums.html#SIGSYS let SIGSYS 25 +nim SIGPIPE signal_impl/enums.html#SIGPIPE let SIGPIPE 25 +nim SIGALRM signal_impl/enums.html#SIGALRM let SIGALRM 25 +nim SIGTERM signal_impl/enums.html#SIGTERM let SIGTERM 25 +nim SIGUSR1 signal_impl/enums.html#SIGUSR1 let SIGUSR1 25 +nim SIGUSR2 signal_impl/enums.html#SIGUSR2 let SIGUSR2 25 +nim SIGCLD signal_impl/enums.html#SIGCLD let SIGCLD 25 +nim SIGCHLD signal_impl/enums.html#SIGCHLD let SIGCHLD 25 +nim SIGPWR signal_impl/enums.html#SIGPWR let SIGPWR 25 +nim SIGIO signal_impl/enums.html#SIGIO let SIGIO 25 +nim SIGURG signal_impl/enums.html#SIGURG let SIGURG 25 +nim SIGWINCH signal_impl/enums.html#SIGWINCH let SIGWINCH 25 +nim SIGPOLL signal_impl/enums.html#SIGPOLL let SIGPOLL 25 +nim SIGSTOP signal_impl/enums.html#SIGSTOP let SIGSTOP 25 +nim SIGTSTP signal_impl/enums.html#SIGTSTP let SIGTSTP 25 +nim SIGCONT signal_impl/enums.html#SIGCONT let SIGCONT 25 +nim SIGTTIN signal_impl/enums.html#SIGTTIN let SIGTTIN 25 +nim SIGTTOU signal_impl/enums.html#SIGTTOU let SIGTTOU 25 +nim SIGVTALRM signal_impl/enums.html#SIGVTALRM let SIGVTALRM 25 +nim SIGPROF signal_impl/enums.html#SIGPROF let SIGPROF 25 +nim SIGXCPU signal_impl/enums.html#SIGXCPU let SIGXCPU 25 +nim SIGXFSZ signal_impl/enums.html#SIGXFSZ let SIGXFSZ 25 +nim SIGRTMIN signal_impl/enums.html#SIGRTMIN let SIGRTMIN 25 +nim SIGRTMAX signal_impl/enums.html#SIGRTMAX let SIGRTMAX 25 +nim SIGSTKFLT signal_impl/enums.html#SIGSTKFLT let SIGSTKFLT 25 +nim value signal_impl/enums.html#value_2 proc value(self: Handlers): int 24 +nim name signal_impl/enums.html#name_2 proc name(self: Handlers): string 26 +nim repr signal_impl/enums.html#repr_2 proc repr(self: Handlers): string 28 +nim `$` signal_impl/enums.html#$_2 proc `$`(self: Handlers): string 35 +nim hash signal_impl/enums.html#hash_2 proc hash(self: Handlers): Hash 37 +nim `==` signal_impl/enums.html#==,,Handlers proc `==`(self: Handlers; other: Handlers): bool 39 +nim add_alias signal_impl/enums.html#add_alias,,string_2 proc add_alias(self: Handlers; name: string) 48 +nim add_member signal_impl/enums.html#add_member,typedesc[Handlers],string,int proc add_member(enum_class: typedesc[Handlers]; name: string; value: int): Handlers 54 +nim `[]` signal_impl/enums.html#[],,string_2 proc `[]`(cls: cls:type; name: string): Handlers 68 +nim len signal_impl/enums.html#len_2 proc len(cls: cls:type): int 69 +nim items signal_impl/enums.html#items.i_2 iterator items(cls: cls:type): Handlers 70 +nim contains signal_impl/enums.html#contains.t,,Handlers template contains(cls; value: Handlers): bool 73 +nim contains signal_impl/enums.html#contains,,int_2 proc contains(cls: cls:type; value: int): bool 9 +nim toInt signal_impl/enums.html#toInt.c,Handlers converter toInt(self: Handlers): int 18 +nim Handlers signal_impl/enums.html#Handlers,Handlers proc Handlers(value: Handlers): Handlers 7 +nim Handlers signal_impl/enums.html#Handlers,int proc Handlers(value: int): Handlers 78 +nim SIG_DFL signal_impl/enums.html#SIG_DFL let SIG_DFL 25 +nim SIG_IGN signal_impl/enums.html#SIG_IGN let SIG_IGN 25 +nim value signal_impl/enums.html#value_3 proc value(self: Sigmasks): int 24 +nim name signal_impl/enums.html#name_3 proc name(self: Sigmasks): string 26 +nim repr signal_impl/enums.html#repr_3 proc repr(self: Sigmasks): string 28 +nim `$` signal_impl/enums.html#$_3 proc `$`(self: Sigmasks): string 35 +nim hash signal_impl/enums.html#hash_3 proc hash(self: Sigmasks): Hash 37 +nim `==` signal_impl/enums.html#==,,Sigmasks proc `==`(self: Sigmasks; other: Sigmasks): bool 39 +nim add_alias signal_impl/enums.html#add_alias,,string_3 proc add_alias(self: Sigmasks; name: string) 48 +nim add_member signal_impl/enums.html#add_member,typedesc[Sigmasks],string,int proc add_member(enum_class: typedesc[Sigmasks]; name: string; value: int): Sigmasks 54 +nim `[]` signal_impl/enums.html#[],,string_3 proc `[]`(cls: cls:type; name: string): Sigmasks 68 +nim len signal_impl/enums.html#len_3 proc len(cls: cls:type): int 69 +nim items signal_impl/enums.html#items.i_3 iterator items(cls: cls:type): Sigmasks 70 +nim contains signal_impl/enums.html#contains.t,,Sigmasks template contains(cls; value: Sigmasks): bool 73 +nim contains signal_impl/enums.html#contains,,int_3 proc contains(cls: cls:type; value: int): bool 9 +nim toInt signal_impl/enums.html#toInt.c,Sigmasks converter toInt(self: Sigmasks): int 18 +nim Sigmasks signal_impl/enums.html#Sigmasks,Sigmasks proc Sigmasks(value: Sigmasks): Sigmasks 7 +nim Sigmasks signal_impl/enums.html#Sigmasks,int proc Sigmasks(value: int): Sigmasks 89 +nim SIG_BLOCK signal_impl/enums.html#SIG_BLOCK let SIG_BLOCK 25 +nim SIG_UNBLOCK signal_impl/enums.html#SIG_UNBLOCK let SIG_UNBLOCK 25 +nim SIG_SETMASK signal_impl/enums.html#SIG_SETMASK let SIG_SETMASK 25 +nimgrp == signal_impl/enums.html#==-procs-all proc 39 +nimgrp $ signal_impl/enums.html#$-procs-all proc 35 +nimgrp Signals signal_impl/enums.html#Signals-procs-all proc 22 +nimgrp Handlers signal_impl/enums.html#Handlers-procs-all proc 78 +nimgrp contains signal_impl/enums.html#contains-procs-all proc 74 +nimgrp repr signal_impl/enums.html#repr-procs-all proc 28 +nimgrp [] signal_impl/enums.html#[]-procs-all proc 68 +nimgrp addalias signal_impl/enums.html#add_alias-procs-all proc 48 +nimgrp len signal_impl/enums.html#len-procs-all proc 69 +nimgrp value signal_impl/enums.html#value-procs-all proc 24 +nimgrp name signal_impl/enums.html#name-procs-all proc 26 +nimgrp Sigmasks signal_impl/enums.html#Sigmasks-procs-all proc 89 +nimgrp addmember signal_impl/enums.html#add_member-procs-all proc 54 +nimgrp hash signal_impl/enums.html#hash-procs-all proc 37 +nimgrp items signal_impl/enums.html#items-iterators-all iterator 70 +nimgrp toint signal_impl/enums.html#toInt-converters-all converter 10 +nimgrp contains signal_impl/enums.html#contains-templates-all template 73 diff --git a/Lib/signal_impl/enums_decl.html b/Lib/signal_impl/enums_decl.html new file mode 100644 index 000000000..36fc39168 --- /dev/null +++ b/Lib/signal_impl/enums_decl.html @@ -0,0 +1,125 @@ + + + + + + + +src/pylib/Lib/signal_impl/enums_decl + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/signal_impl/enums_decl

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Types

+
+
+
Handlers = distinct int
+
+ + + Source   +Edit   + +
+
+
+
Sigmasks = distinct int
+
+ + + Source   +Edit   + +
+
+
+
Signals = distinct int
+
+ + + Source   +Edit   + +
+
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/signal_impl/enums_decl.idx b/Lib/signal_impl/enums_decl.idx new file mode 100644 index 000000000..ee73c1065 --- /dev/null +++ b/Lib/signal_impl/enums_decl.idx @@ -0,0 +1,4 @@ +nimTitle enums_decl signal_impl/enums_decl.html module src/pylib/Lib/signal_impl/enums_decl 0 +nim Signals signal_impl/enums_decl.html#Signals type Signals 3 +nim Handlers signal_impl/enums_decl.html#Handlers type Handlers 3 +nim Sigmasks signal_impl/enums_decl.html#Sigmasks type Sigmasks 3 diff --git a/Lib/signal_impl/errutil.html b/Lib/signal_impl/errutil.html new file mode 100644 index 000000000..dcaad9ddf --- /dev/null +++ b/Lib/signal_impl/errutil.html @@ -0,0 +1,96 @@ + + + + + + + +src/pylib/Lib/signal_impl/errutil + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/signal_impl/errutil

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Exports

+
+ $, prepareROErrno, exportAllErrnosViaEnumOrImportc, setErrno0, ErrnoCount, strerror, Errno, setErrno, isErr0, setErrnoRaw, declErrorcodeWith, getErrno, prepareRWErrno, isErr, initErrorcodeMap, EPERM, EDQUOT, EFAULT, EKEYREJECTED, EHOSTUNREACH, EHOSTDOWN, ECONNRESET, ENOBUFS, ENETRESET, EREMCHG, ECANCELED, ESTRPIPE, EMLINK, ENXIO, ETOOMANYREFS, ENOMEDIUM, ENOLCK, ENOTRECOVERABLE, EAFNOSUPPORT, ECHILD, EISCONN, ECONNABORTED, ENOTDIR, ESRMNT, ENOTEMPTY, EPROTO, EADDRNOTAVAIL, EXDEV, EBADF, EKEYREVOKED, EBFONT, EDEADLK, ESPIPE, ENOTSUP, ENOEXEC, ENETDOWN, EACCES, ELNRNG, EBADRQC, ENODEV, ENFILE, EBUSY, ENOCSI, ECHRNG, EINVAL, EMEDIUMTYPE, EPIPE, ERFKILL, EBADE, EBADFD, ERESTART, ESRCH, EL2NSYNC, ENETUNREACH, EPROTONOSUPPORT, EISDIR, ENOTSOCK, ESTALE, EMFILE, ENOSYS, ETIME, ELIBSCN, EILSEQ, ENOPKG, EROFS, ENOPROTOOPT, ELIBMAX, ELOOP, EUSERS, ECOMM, EL2HLT, EIDRM, ENOTBLK, ENOTTY, EOPNOTSUPP, EISNAM, ELIBACC, ETIMEDOUT, EPROTOTYPE, EUCLEAN, ENOSTR, EOVERFLOW, EADV, EUNATCH, ENOENT, ELIBEXEC, EMULTIHOP, ENOSR, EINPROGRESS, E2BIG, ENOTCONN, EIO, ENODATA, ESHUTDOWN, EFBIG, ELIBBAD, EOWNERDEAD, EXFULL, ESOCKTNOSUPPORT, EINTR, ERANGE, ENOSPC, EBADSLT, EDEADLOCK, EEXIST, ENONET, EREMOTEIO, EPFNOSUPPORT, ENOLINK, ENOMSG, EDOM, EMSGSIZE, ENOTUNIQ, EALREADY, ENOMEM, EBADMSG, ENOKEY, ECONNREFUSED, EDESTADDRREQ, ENOTNAM, EADDRINUSE, ETXTBSY, EKEYEXPIRED, EL3HLT, EBADR, EL3RST, EAGAIN, ENOANO, EWOULDBLOCK, ENAVAIL, ENAMETOOLONG, EREMOTE, EDOTDOT, osErrorMsgWithPath, raiseExcWithPath2, ConnectionError, ConnectionResetError, PyOSError, newBlockingIOError, raiseErrnoWithPath, InterruptedError, $, NotADirectoryError, errnoMsg, BrokenPipeError, TimeoutError, raiseExcWithPath, osErrorMsgWithPath, raiseErrno, tryOsOp, ProcessLookupError, IsADirectoryError, raiseExcWithPath, tryOsOp, tryOsOp, BlockingIOError, PyOSError, ConnectionAbortedError, ConnectionRefusedError, FileNotFoundError, BlockingIOError, ChildProcessError, BlockingIOError, noWeirdTarget, PyOSError, newPyOSError, raiseExcWithPath, newPyOSError, PermissionError, raiseErrnoT, FileExistsError, tryOsOp, newBlockingIOError, raiseExcWithPath, KeyboardInterrupt +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/signal_impl/errutil.idx b/Lib/signal_impl/errutil.idx new file mode 100644 index 000000000..cf22f78da --- /dev/null +++ b/Lib/signal_impl/errutil.idx @@ -0,0 +1 @@ +nimTitle errutil signal_impl/errutil.html module src/pylib/Lib/signal_impl/errutil 0 diff --git a/Lib/signal_impl/frames.html b/Lib/signal_impl/frames.html new file mode 100644 index 000000000..f91406047 --- /dev/null +++ b/Lib/signal_impl/frames.html @@ -0,0 +1,120 @@ + + + + + + + +src/pylib/Lib/signal_impl/frames + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/signal_impl/frames

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Procs

+
+
+
+
proc getFrameOrNil(): PFrame {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc getFrameOrNil(up: int): PFrame {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/signal_impl/frames.idx b/Lib/signal_impl/frames.idx new file mode 100644 index 000000000..08c491c80 --- /dev/null +++ b/Lib/signal_impl/frames.idx @@ -0,0 +1,4 @@ +nimTitle frames signal_impl/frames.html module src/pylib/Lib/signal_impl/frames 0 +nim getFrameOrNil signal_impl/frames.html#getFrameOrNil proc getFrameOrNil(): PFrame 2 +nim getFrameOrNil signal_impl/frames.html#getFrameOrNil,int proc getFrameOrNil(up: int): PFrame 7 +nimgrp getframeornil signal_impl/frames.html#getFrameOrNil-procs-all proc 2 diff --git a/Lib/signal_impl/pyatomic.html b/Lib/signal_impl/pyatomic.html new file mode 100644 index 000000000..e25a0b3e2 --- /dev/null +++ b/Lib/signal_impl/pyatomic.html @@ -0,0 +1,160 @@ + + + + + + + +src/pylib/Lib/signal_impl/pyatomic + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/signal_impl/pyatomic

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Templates

+
+
+
+
template Py_atomic_load[T](obj: T): T
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template Py_atomic_load_ptr[T](obj: ptr T): T
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template Py_atomic_store[T](obj: T; value: T)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template Py_atomic_store_ptr[T](obj: ptr T; value: T)
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/signal_impl/pyatomic.idx b/Lib/signal_impl/pyatomic.idx new file mode 100644 index 000000000..9da5c3661 --- /dev/null +++ b/Lib/signal_impl/pyatomic.idx @@ -0,0 +1,5 @@ +nimTitle pyatomic signal_impl/pyatomic.html module src/pylib/Lib/signal_impl/pyatomic 0 +nim Py_atomic_load_ptr signal_impl/pyatomic.html#Py_atomic_load_ptr.t,ptr.T template Py_atomic_load_ptr[T](obj: ptr T): T 3 +nim Py_atomic_store_ptr signal_impl/pyatomic.html#Py_atomic_store_ptr.t,ptr.T,T template Py_atomic_store_ptr[T](obj: ptr T; value: T) 4 +nim Py_atomic_load signal_impl/pyatomic.html#Py_atomic_load.t,T template Py_atomic_load[T](obj: T): T 6 +nim Py_atomic_store signal_impl/pyatomic.html#Py_atomic_store.t,T,T template Py_atomic_store[T](obj: T; value: T) 11 diff --git a/Lib/signal_impl/pylifecycle.html b/Lib/signal_impl/pylifecycle.html new file mode 100644 index 000000000..e95173f7f --- /dev/null +++ b/Lib/signal_impl/pylifecycle.html @@ -0,0 +1,96 @@ + + + + + + + +src/pylib/Lib/signal_impl/pylifecycle + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/signal_impl/pylifecycle

+ + + +
+
+ + + diff --git a/Lib/signal_impl/pylifecycle.idx b/Lib/signal_impl/pylifecycle.idx new file mode 100644 index 000000000..9112b5287 --- /dev/null +++ b/Lib/signal_impl/pylifecycle.idx @@ -0,0 +1 @@ +nimTitle pylifecycle signal_impl/pylifecycle.html module src/pylib/Lib/signal_impl/pylifecycle 0 diff --git a/Lib/signal_impl/pynsig.html b/Lib/signal_impl/pynsig.html new file mode 100644 index 000000000..cb1763112 --- /dev/null +++ b/Lib/signal_impl/pynsig.html @@ -0,0 +1,96 @@ + + + + + + + +src/pylib/Lib/signal_impl/pynsig + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/signal_impl/pynsig

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+ +
+ + +
+
+ + + diff --git a/Lib/signal_impl/pynsig.idx b/Lib/signal_impl/pynsig.idx new file mode 100644 index 000000000..6a6d1ad90 --- /dev/null +++ b/Lib/signal_impl/pynsig.idx @@ -0,0 +1 @@ +nimTitle pynsig signal_impl/pynsig.html module src/pylib/Lib/signal_impl/pynsig 0 diff --git a/Lib/signal_impl/siginfo_decl.html b/Lib/signal_impl/siginfo_decl.html new file mode 100644 index 000000000..c991309f0 --- /dev/null +++ b/Lib/signal_impl/siginfo_decl.html @@ -0,0 +1,263 @@ + + + + + + + +src/pylib/Lib/signal_impl/siginfo_decl + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/signal_impl/siginfo_decl

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Imports

+
+ pylifecycle +
+
+
+

Types

+
+
+
struct_siginfo = ref object
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
proc fill_siginfo(si: SigInfo): struct_siginfo {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc si_band(self: struct_siginfo): auto {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc si_code(self: struct_siginfo): auto {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc si_errno(self: struct_siginfo): auto {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc si_pid(self: struct_siginfo): auto {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc si_signo(self: struct_siginfo): auto {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc si_status(self: struct_siginfo): auto {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc si_uid(self: struct_siginfo): auto {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/signal_impl/siginfo_decl.idx b/Lib/signal_impl/siginfo_decl.idx new file mode 100644 index 000000000..160fc33b1 --- /dev/null +++ b/Lib/signal_impl/siginfo_decl.idx @@ -0,0 +1,10 @@ +nimTitle siginfo_decl signal_impl/siginfo_decl.html module src/pylib/Lib/signal_impl/siginfo_decl 0 +nim struct_siginfo signal_impl/siginfo_decl.html#struct_siginfo type struct_siginfo 4 +nim si_signo signal_impl/siginfo_decl.html#si_signo,struct_siginfo proc si_signo(self: struct_siginfo): auto 10 +nim si_code signal_impl/siginfo_decl.html#si_code,struct_siginfo proc si_code(self: struct_siginfo): auto 11 +nim si_errno signal_impl/siginfo_decl.html#si_errno,struct_siginfo proc si_errno(self: struct_siginfo): auto 12 +nim si_pid signal_impl/siginfo_decl.html#si_pid,struct_siginfo proc si_pid(self: struct_siginfo): auto 13 +nim si_uid signal_impl/siginfo_decl.html#si_uid,struct_siginfo proc si_uid(self: struct_siginfo): auto 14 +nim si_status signal_impl/siginfo_decl.html#si_status,struct_siginfo proc si_status(self: struct_siginfo): auto 16 +nim si_band signal_impl/siginfo_decl.html#si_band,struct_siginfo proc si_band(self: struct_siginfo): auto 17 +nim fill_siginfo signal_impl/siginfo_decl.html#fill_siginfo,SigInfo proc fill_siginfo(si: SigInfo): struct_siginfo 20 diff --git a/Lib/signal_impl/signal_util.html b/Lib/signal_impl/signal_util.html new file mode 100644 index 000000000..447c32c56 --- /dev/null +++ b/Lib/signal_impl/signal_util.html @@ -0,0 +1,190 @@ + + + + + + + +src/pylib/Lib/signal_impl/signal_util + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/signal_impl/signal_util

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
proc c_raise(signalnum: cint): cint {.importc: "raise", header: "<signal.h>",
+                                      ...raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc getsignal(signalnum: int): PySigHandler {....raises: [ValueError], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc pidfd_send_signal(pid: int; sig: int; siginfo: struct_siginfo = nil;
+                       flags = 0) {....raises: [PyOSError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc raise_signal(signalnum: int) {....raises: [PyOSError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc strsignal(signalnum: int): string {....raises: [ValueError], tags: [],
+    forbids: [].}
+
+ + returns empty string over None + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/signal_impl/signal_util.idx b/Lib/signal_impl/signal_util.idx new file mode 100644 index 000000000..50d8d7674 --- /dev/null +++ b/Lib/signal_impl/signal_util.idx @@ -0,0 +1,6 @@ +nimTitle signal_util signal_impl/signal_util.html module src/pylib/Lib/signal_impl/signal_util 0 +nim getsignal signal_impl/signal_util.html#getsignal,int proc getsignal(signalnum: int): PySigHandler 12 +nim strsignal signal_impl/signal_util.html#strsignal,int proc strsignal(signalnum: int): string 16 +nim c_raise signal_impl/signal_util.html#c_raise,cint proc c_raise(signalnum: cint): cint 50 +nim raise_signal signal_impl/signal_util.html#raise_signal,int proc raise_signal(signalnum: int) 52 +nim pidfd_send_signal signal_impl/signal_util.html#pidfd_send_signal,int,int,struct_siginfo,int proc pidfd_send_signal(pid: int; sig: int; siginfo: struct_siginfo = nil; flags = 0) 66 diff --git a/Lib/signal_impl/signals.html b/Lib/signal_impl/signals.html new file mode 100644 index 000000000..f26adf812 --- /dev/null +++ b/Lib/signal_impl/signals.html @@ -0,0 +1,166 @@ + + + + + + + +src/pylib/Lib/signal_impl/signals + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/signal_impl/signals

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
proc default_int_handler(signalnum: int; frame: PFrame) {.
+    ...raises: [KeyboardInterrupt], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc set_wakeup_signal(signalnum: int): int {....raises: [], tags: [], forbids: [].}
+
+ + XXX: currently -1 is always returned + Source   +Edit   + +
+
+ +
+
+
+
proc signal(signalnum: int; handler: CSigHandler | NimSigHandler | Handlers): PySigHandler {.
+    discardable.}
+
+ + + Source   +Edit   + +
+
+
+
proc signal(signalnum: int; handler: PySigHandler): PySigHandler {.discardable,
+    ...raises: [ValueError, PyOSError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/signal_impl/signals.idx b/Lib/signal_impl/signals.idx new file mode 100644 index 000000000..0f7da977c --- /dev/null +++ b/Lib/signal_impl/signals.idx @@ -0,0 +1,6 @@ +nimTitle signals signal_impl/signals.html module src/pylib/Lib/signal_impl/signals 0 +nim signal signal_impl/signals.html#signal,int,PySigHandler proc signal(signalnum: int; handler: PySigHandler): PySigHandler 54 +nim signal signal_impl/signals.html#signal,int, proc signal(signalnum: int; handler: CSigHandler | NimSigHandler | Handlers): PySigHandler 69 +nim default_int_handler signal_impl/signals.html#default_int_handler,int,PFrame proc default_int_handler(signalnum: int; frame: PFrame) 74 +nim set_wakeup_signal signal_impl/signals.html#set_wakeup_signal,int proc set_wakeup_signal(signalnum: int): int 103 +nimgrp signal signal_impl/signals.html#signal-procs-all proc 54 diff --git a/Lib/signal_impl/sigsetCvt.html b/Lib/signal_impl/sigsetCvt.html new file mode 100644 index 000000000..d0fcb4398 --- /dev/null +++ b/Lib/signal_impl/sigsetCvt.html @@ -0,0 +1,118 @@ + + + + + + + +src/pylib/Lib/signal_impl/sigsetCvt + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/signal_impl/sigsetCvt

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Templates

+
+
+
+
template fromIterable(result: var Sigset; obj)
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/signal_impl/sigsetCvt.idx b/Lib/signal_impl/sigsetCvt.idx new file mode 100644 index 000000000..d96ff1644 --- /dev/null +++ b/Lib/signal_impl/sigsetCvt.idx @@ -0,0 +1,2 @@ +nimTitle sigsetCvt signal_impl/sigsetCvt.html module src/pylib/Lib/signal_impl/sigsetCvt 0 +nim fromIterable signal_impl/sigsetCvt.html#fromIterable.t,Sigset, template fromIterable(result: var Sigset; obj) 17 diff --git a/Lib/signal_impl/sigset_to_set.html b/Lib/signal_impl/sigset_to_set.html new file mode 100644 index 000000000..f578a0288 --- /dev/null +++ b/Lib/signal_impl/sigset_to_set.html @@ -0,0 +1,136 @@ + + + + + + + +src/pylib/Lib/signal_impl/sigset_to_set + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/signal_impl/sigset_to_set

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
proc add_sigset(res: var Set[int]; mask: var Sigset)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc sigset_to_set(mask: var Sigset): HashSet[int] {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/signal_impl/sigset_to_set.idx b/Lib/signal_impl/sigset_to_set.idx new file mode 100644 index 000000000..a12bfb923 --- /dev/null +++ b/Lib/signal_impl/sigset_to_set.idx @@ -0,0 +1,3 @@ +nimTitle sigset_to_set signal_impl/sigset_to_set.html module src/pylib/Lib/signal_impl/sigset_to_set 0 +nim add_sigset signal_impl/sigset_to_set.html#add_sigset,Set[int],Sigset proc add_sigset(res: var Set[int]; mask: var Sigset) 6 +nim sigset_to_set signal_impl/sigset_to_set.html#sigset_to_set,Sigset proc sigset_to_set(mask: var Sigset): HashSet[int] 18 diff --git a/Lib/signal_impl/state.html b/Lib/signal_impl/state.html new file mode 100644 index 000000000..41b86dac9 --- /dev/null +++ b/Lib/signal_impl/state.html @@ -0,0 +1,276 @@ + + + + + + + +src/pylib/Lib/signal_impl/state + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/signal_impl/state

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

XXX: FIXED-NIM-BUG: though nimAllowNonVarDestructor is defined at least since 2.0.6, it still cannot be compiled till abour 2.1.1

+ +
+

Types

+
+
+
signal_state_t = object
+  handlers*: array[Py_NSIG, handler]
+  when DWin:
+    sigint_event*: Handle
+  default_handler*, ignore_handler*: PySigHandler
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Consts

+
+
+
DWin = false
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
proc get_handler(i: cint): PySigHandler {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc initPySignal(install_signal_handlers: bool) {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc PySignal_Fini() {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc set_handler(i: cint; fn: PySigHandler) {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template Handlers(): untyped
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template signal_global_state(): signal_state_t
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/signal_impl/state.idx b/Lib/signal_impl/state.idx new file mode 100644 index 000000000..02c8fa32b --- /dev/null +++ b/Lib/signal_impl/state.idx @@ -0,0 +1,9 @@ +nimTitle state signal_impl/state.html module src/pylib/Lib/signal_impl/state 0 +nim DWin signal_impl/state.html#DWin const DWin 5 +nim signal_state_t signal_impl/state.html#signal_state_t object signal_state_t 13 +nim initPySignal signal_impl/state.html#initPySignal,bool proc initPySignal(install_signal_handlers: bool) 41 +nim signal_global_state signal_impl/state.html#signal_global_state.t template signal_global_state(): signal_state_t 46 +nim Handlers signal_impl/state.html#Handlers.t template Handlers(): untyped 56 +nim get_handler signal_impl/state.html#get_handler,cint proc get_handler(i: cint): PySigHandler 93 +nim set_handler signal_impl/state.html#set_handler,cint,PySigHandler proc set_handler(i: cint; fn: PySigHandler) 95 +nim PySignal_Fini signal_impl/state.html#PySignal_Fini proc PySignal_Fini() 117 diff --git a/Lib/signal_impl/unixs.html b/Lib/signal_impl/unixs.html new file mode 100644 index 000000000..282bb4811 --- /dev/null +++ b/Lib/signal_impl/unixs.html @@ -0,0 +1,374 @@ + + + + + + + +src/pylib/Lib/signal_impl/unixs + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/signal_impl/unixs

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Types

+
+
+
ItimerError = object of PyOSError
+
+ + + Source   +Edit   + +
+
+
+
ItimerVal {.importc: "struct itimerval", header: "<sys/time.h>".} = object
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
proc alarm(seconds: int): int {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc getitimer(which: int): tuple[delay, interval: float] {....raises: [PyOSError],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc pause(): int {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc pthread_kill(thread_id: uint; signalnum: int) {....raises: [PyOSError],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc pthread_sigmask(how: int; mask: Sigset): Set[int] {....raises: [PyOSError],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc setitimer(which: int; seconds: float; interval = 0.0): tuple[
+    delay, interval: float] {....raises: [ValueError, PyOSError], tags: [],
+                              forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc siginterrupt(signalnum, flag: int) {....raises: [ValueError, PyOSError],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc sigpending(): Set[int] {....raises: [PyOSError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc sigtimedwait(sigset: Sigset; timeout: Timestamp): struct_siginfo
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc sigwait(sigset: Sigset): int {....raises: [PyOSError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc sigwaitinfo(sigset: Sigset): struct_siginfo {....raises: [PyOSError],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Converters

+
+
+
+
converter toSigset(oa: openArray[int]): Sigset {.
+    ...raises: [PyOSError, ValueError, IOError], tags: [WriteIOEffect], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ + +
+
+ + +
+
+ + + diff --git a/Lib/signal_impl/unixs.idx b/Lib/signal_impl/unixs.idx new file mode 100644 index 000000000..c076aa0a2 --- /dev/null +++ b/Lib/signal_impl/unixs.idx @@ -0,0 +1,15 @@ +nimTitle unixs signal_impl/unixs.html module src/pylib/Lib/signal_impl/unixs 0 +nim toSigset signal_impl/unixs.html#toSigset.c,openArray[int] converter toSigset(oa: openArray[int]): Sigset 18 +nim alarm signal_impl/unixs.html#alarm,int proc alarm(seconds: int): int 33 +nim pause signal_impl/unixs.html#pause proc pause(): int 34 +nim pthread_kill signal_impl/unixs.html#pthread_kill,uint,int proc pthread_kill(thread_id: uint; signalnum: int) 32 +nim pthread_sigmask signal_impl/unixs.html#pthread_sigmask,int,Sigset proc pthread_sigmask(how: int; mask: Sigset): Set[int] 51 +nim ItimerError signal_impl/unixs.html#ItimerError object ItimerError 60 +nim ItimerVal signal_impl/unixs.html#ItimerVal object ItimerVal 63 +nim setitimer signal_impl/unixs.html#setitimer,int,float,float proc setitimer(which: int; seconds: float; interval = 0.0): tuple[\n delay, interval: float] 82 +nim getitimer signal_impl/unixs.html#getitimer,int proc getitimer(which: int): tuple[delay, interval: float] 93 +nim siginterrupt signal_impl/unixs.html#siginterrupt,int,int proc siginterrupt(signalnum, flag: int) 101 +nim sigpending signal_impl/unixs.html#sigpending proc sigpending(): Set[int] 118 +nim sigwait signal_impl/unixs.html#sigwait,Sigset proc sigwait(sigset: Sigset): int 124 +nim sigwaitinfo signal_impl/unixs.html#sigwaitinfo,Sigset proc sigwaitinfo(sigset: Sigset): struct_siginfo 131 +nim sigtimedwait signal_impl/unixs.html#sigtimedwait,Sigset,Timestamp proc sigtimedwait(sigset: Sigset; timeout: Timestamp): struct_siginfo 152 diff --git a/Lib/signal_impl/valid_signals_impl.html b/Lib/signal_impl/valid_signals_impl.html new file mode 100644 index 000000000..2ad13ca04 --- /dev/null +++ b/Lib/signal_impl/valid_signals_impl.html @@ -0,0 +1,143 @@ + + + + + + + +src/pylib/Lib/signal_impl/valid_signals_impl + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/signal_impl/valid_signals_impl

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Consts

+
+
+
have_valid_signals = true
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
proc fill_valid_signals(res: var Set[int])
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/signal_impl/valid_signals_impl.idx b/Lib/signal_impl/valid_signals_impl.idx new file mode 100644 index 000000000..4ee36c9d2 --- /dev/null +++ b/Lib/signal_impl/valid_signals_impl.idx @@ -0,0 +1,3 @@ +nimTitle valid_signals_impl signal_impl/valid_signals_impl.html module src/pylib/Lib/signal_impl/valid_signals_impl 0 +nim have_valid_signals signal_impl/valid_signals_impl.html#have_valid_signals const have_valid_signals 4 +nim fill_valid_signals signal_impl/valid_signals_impl.html#fill_valid_signals,Set[int] proc fill_valid_signals(res: var Set[int]) 6 diff --git a/Lib/stat.html b/Lib/stat.html new file mode 100644 index 000000000..96a229a01 --- /dev/null +++ b/Lib/stat.html @@ -0,0 +1,129 @@ + + + + + + + +src/pylib/Lib/stat + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/stat

+ + + +
+
+ + + diff --git a/Lib/stat.idx b/Lib/stat.idx new file mode 100644 index 000000000..056b70b2d --- /dev/null +++ b/Lib/stat.idx @@ -0,0 +1,2 @@ +nimTitle stat stat.html module src/pylib/Lib/stat 0 +nim filemode stat.html#filemode proc filemode(omode: int | Mode): PyStr 10 diff --git a/Lib/stat_impl/consts.html b/Lib/stat_impl/consts.html new file mode 100644 index 000000000..14dddb799 --- /dev/null +++ b/Lib/stat_impl/consts.html @@ -0,0 +1,112 @@ + + + + + + + +src/pylib/Lib/stat_impl/consts + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/stat_impl/consts

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Consts

+
+
+
S_IMODE_val {.intdefine: "S_IMODE".} = 0o000000007777
+
+ + + Source   +Edit   + +
+
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/stat_impl/consts.idx b/Lib/stat_impl/consts.idx new file mode 100644 index 000000000..c1631a791 --- /dev/null +++ b/Lib/stat_impl/consts.idx @@ -0,0 +1,2 @@ +nimTitle consts stat_impl/consts.html module src/pylib/Lib/stat_impl/consts 0 +nim S_IMODE_val stat_impl/consts.html#S_IMODE_val const S_IMODE_val 19 diff --git a/Lib/stat_impl/defines.html b/Lib/stat_impl/defines.html new file mode 100644 index 000000000..eeb774d82 --- /dev/null +++ b/Lib/stat_impl/defines.html @@ -0,0 +1,125 @@ + + + + + + + +src/pylib/Lib/stat_impl/defines + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/stat_impl/defines

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Consts

+
+
+
APPLE = false
+
+ + + Source   +Edit   + +
+
+
+
DW = false
+
+ + + Source   +Edit   + +
+
+
+
SYS_STAT_H = "<sys/stat.h>"
+
+ + + Source   +Edit   + +
+
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/stat_impl/defines.idx b/Lib/stat_impl/defines.idx new file mode 100644 index 000000000..b7922a8f8 --- /dev/null +++ b/Lib/stat_impl/defines.idx @@ -0,0 +1,4 @@ +nimTitle defines stat_impl/defines.html module src/pylib/Lib/stat_impl/defines 0 +nim DW stat_impl/defines.html#DW const DW 3 +nim APPLE stat_impl/defines.html#APPLE const APPLE 4 +nim SYS_STAT_H stat_impl/defines.html#SYS_STAT_H const SYS_STAT_H 6 diff --git a/Lib/stat_impl/isX.html b/Lib/stat_impl/isX.html new file mode 100644 index 000000000..ffcc2f568 --- /dev/null +++ b/Lib/stat_impl/isX.html @@ -0,0 +1,336 @@ + + + + + + + +src/pylib/Lib/stat_impl/isX + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/stat_impl/isX

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
proc S_IFMT(omode: int): int {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc S_IFMT(omode: Mode): int {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc S_IMODE(omode: int): int {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc S_IMODE(omode: Mode): int {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc S_ISBLK(omode: int): bool {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc S_ISCHR(omode: int): bool {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc S_ISDIR(omode: int): bool {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc S_ISDOOR(omode: int): bool {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc S_ISFIFO(omode: int): bool {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc S_ISLNK(omode: int): bool {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc S_ISPORT(omode: int): bool {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc S_ISREG(omode: int): bool {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc S_ISSOCK(omode: int): bool {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc S_ISWHT(omode: int): bool {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ + +
+
+ + +
+
+ + + diff --git a/Lib/stat_impl/isX.idx b/Lib/stat_impl/isX.idx new file mode 100644 index 000000000..d7533043f --- /dev/null +++ b/Lib/stat_impl/isX.idx @@ -0,0 +1,17 @@ +nimTitle isX stat_impl/isX.html module src/pylib/Lib/stat_impl/isX 0 +nim S_ISDIR stat_impl/isX.html#S_ISDIR,int proc S_ISDIR(omode: int): bool 11 +nim S_ISCHR stat_impl/isX.html#S_ISCHR,int proc S_ISCHR(omode: int): bool 12 +nim S_ISBLK stat_impl/isX.html#S_ISBLK,int proc S_ISBLK(omode: int): bool 13 +nim S_ISREG stat_impl/isX.html#S_ISREG,int proc S_ISREG(omode: int): bool 14 +nim S_ISFIFO stat_impl/isX.html#S_ISFIFO,int proc S_ISFIFO(omode: int): bool 15 +nim S_ISLNK stat_impl/isX.html#S_ISLNK,int proc S_ISLNK(omode: int): bool 16 +nim S_ISSOCK stat_impl/isX.html#S_ISSOCK,int proc S_ISSOCK(omode: int): bool 17 +nim S_ISDOOR stat_impl/isX.html#S_ISDOOR,int proc S_ISDOOR(omode: int): bool 18 +nim S_ISPORT stat_impl/isX.html#S_ISPORT,int proc S_ISPORT(omode: int): bool 19 +nim S_ISWHT stat_impl/isX.html#S_ISWHT,int proc S_ISWHT(omode: int): bool 20 +nim S_IMODE stat_impl/isX.html#S_IMODE,Mode proc S_IMODE(omode: Mode): int 23 +nim S_IMODE stat_impl/isX.html#S_IMODE,int proc S_IMODE(omode: int): int 25 +nim S_IFMT stat_impl/isX.html#S_IFMT,Mode proc S_IFMT(omode: Mode): int 30 +nim S_IFMT stat_impl/isX.html#S_IFMT,int proc S_IFMT(omode: int): int 33 +nimgrp Simode stat_impl/isX.html#S_IMODE-procs-all proc 23 +nimgrp Sifmt stat_impl/isX.html#S_IFMT-procs-all proc 30 diff --git a/Lib/stat_impl/isXImpl.html b/Lib/stat_impl/isXImpl.html new file mode 100644 index 000000000..dc8f4f7db --- /dev/null +++ b/Lib/stat_impl/isXImpl.html @@ -0,0 +1,302 @@ + + + + + + + +src/pylib/Lib/stat_impl/isXImpl + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/stat_impl/isXImpl

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Imports

+
+ types, defines +
+
+
+

Procs

+
+
+
+
proc int_AsMode_t(value: int): Mode {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template S_ISBLK(mode`gensym3: Mode): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template S_ISCHR(mode`gensym1: Mode): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template S_ISDIR(mode`gensym0: Mode): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template S_ISDOOR(mode: Mode): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template S_ISFIFO(mode`gensym4: Mode): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template S_ISLNK(mode`gensym5: Mode): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template S_ISPORT(mode: Mode): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template S_ISREG(mode`gensym2: Mode): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template S_ISSOCK(mode`gensym6: Mode): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template S_ISWHT(mode: Mode): bool
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/stat_impl/isXImpl.idx b/Lib/stat_impl/isXImpl.idx new file mode 100644 index 000000000..80a3a2820 --- /dev/null +++ b/Lib/stat_impl/isXImpl.idx @@ -0,0 +1,12 @@ +nimTitle isXImpl stat_impl/isXImpl.html module src/pylib/Lib/stat_impl/isXImpl 0 +nim int_AsMode_t stat_impl/isXImpl.html#int_AsMode_t,int proc int_AsMode_t(value: int): Mode 5 +nim S_ISDIR stat_impl/isXImpl.html#S_ISDIR.t,Mode template S_ISDIR(mode`gensym0: Mode): bool 14 +nim S_ISCHR stat_impl/isXImpl.html#S_ISCHR.t,Mode template S_ISCHR(mode`gensym1: Mode): bool 15 +nim S_ISREG stat_impl/isXImpl.html#S_ISREG.t,Mode template S_ISREG(mode`gensym2: Mode): bool 16 +nim S_ISBLK stat_impl/isXImpl.html#S_ISBLK.t,Mode template S_ISBLK(mode`gensym3: Mode): bool 18 +nim S_ISFIFO stat_impl/isXImpl.html#S_ISFIFO.t,Mode template S_ISFIFO(mode`gensym4: Mode): bool 19 +nim S_ISLNK stat_impl/isXImpl.html#S_ISLNK.t,Mode template S_ISLNK(mode`gensym5: Mode): bool 20 +nim S_ISSOCK stat_impl/isXImpl.html#S_ISSOCK.t,Mode template S_ISSOCK(mode`gensym6: Mode): bool 21 +nim S_ISDOOR stat_impl/isXImpl.html#S_ISDOOR.t,Mode template S_ISDOOR(mode: Mode): bool 24 +nim S_ISPORT stat_impl/isXImpl.html#S_ISPORT.t,Mode template S_ISPORT(mode: Mode): bool 25 +nim S_ISWHT stat_impl/isXImpl.html#S_ISWHT.t,Mode template S_ISWHT(mode: Mode): bool 26 diff --git a/Lib/stat_impl/strrepr.html b/Lib/stat_impl/strrepr.html new file mode 100644 index 000000000..e8cde1bec --- /dev/null +++ b/Lib/stat_impl/strrepr.html @@ -0,0 +1,129 @@ + + + + + + + +src/pylib/Lib/stat_impl/strrepr + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/stat_impl/strrepr

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
proc filemode(omode: int): string {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc filemode(omode: Mode): string {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/stat_impl/strrepr.idx b/Lib/stat_impl/strrepr.idx new file mode 100644 index 000000000..d1b645770 --- /dev/null +++ b/Lib/stat_impl/strrepr.idx @@ -0,0 +1,4 @@ +nimTitle strrepr stat_impl/strrepr.html module src/pylib/Lib/stat_impl/strrepr 0 +nim filemode stat_impl/strrepr.html#filemode,Mode proc filemode(omode: Mode): string 38 +nim filemode stat_impl/strrepr.html#filemode,int proc filemode(omode: int): string 45 +nimgrp filemode stat_impl/strrepr.html#filemode-procs-all proc 38 diff --git a/Lib/stat_impl/types.html b/Lib/stat_impl/types.html new file mode 100644 index 000000000..77b8e794c --- /dev/null +++ b/Lib/stat_impl/types.html @@ -0,0 +1,75 @@ + + + + + + + +src/pylib/Lib/stat_impl/types + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/stat_impl/types

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ +
+
+ Source   +Edit   + +
+ +

+ +
+
+ + +
+
+ + + diff --git a/Lib/stat_impl/types.idx b/Lib/stat_impl/types.idx new file mode 100644 index 000000000..095b43cbc --- /dev/null +++ b/Lib/stat_impl/types.idx @@ -0,0 +1 @@ +nimTitle types stat_impl/types.html module src/pylib/Lib/stat_impl/types 0 diff --git a/Lib/string.html b/Lib/string.html new file mode 100644 index 000000000..7fcb219f6 --- /dev/null +++ b/Lib/string.html @@ -0,0 +1,376 @@ + + + + + + + +src/pylib/Lib/string + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/string

+
+ +
+ Source   +Edit   + +
+ +

+ +
+

Consts

+
+
+
ascii_letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
+
+ + + Source   +Edit   + +
+
+
+
ascii_lowercase = "abcdefghijklmnopqrstuvwxyz"
+
+ + + Source   +Edit   + +
+
+
+
ascii_uppercase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+
+ + + Source   +Edit   + +
+
+
+
digits = "0123456789"
+
+ + + Source   +Edit   + +
+
+
+
hexdigits = "0123456789abcdefABCDEF"
+
+ + + Source   +Edit   + +
+
+
+
octdigits = "01234567"
+
+ + + Source   +Edit   + +
+
+
+
printable = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!\"#$%&\\\'()*+,-./:;<=>?@[\\\\]^_`{|}~ \t\n\r\v\f"
+
+ + + Source   +Edit   + +
+
+
+
punctuation = """!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~"""
+
+ + + Source   +Edit   + +
+
+
+
whitespace = " \t\n\r\v\f"
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
func capwords(a: StringLike): PyStr
+
+ +

Mimics Python string.capwords(s) -> str:

+

Runs of whitespace characters are replaced by a single space and leading and trailing whitespace are removed.

+ + Source   +Edit   + +
+
+
+
proc capwords(a: StringLike; _: NoneType): PyStr
+
+ + + Source   +Edit   + +
+
+
+
func capwords(a: StringLike; sep: StringLike): PyStr
+
+ +

Mimics Python string.capwords(s, sep) -> str:

+

Split the argument into words using split, capitalize each word using capitalize, and join the capitalized words using join. sep is used to split and join the words.

+ + Source   +Edit   + +
+
+ +
+
+
+
proc get_identifiers(templ: Template): PyList[PyStr] {....raises: [Exception],
+    tags: [RootEffect], forbids: [].}
+
+ +
Admonition: +since Python 3.11
+ + Source   +Edit   + +
+
+ +
+
+
+
proc is_valid(templ: Template): bool {....raises: [Exception], tags: [RootEffect],
+                                       forbids: [].}
+
+ +
Admonition: +since Python 3.11
+ + Source   +Edit   + +
+
+ +
+ +
+
+
+

Macros

+
+
+
+
macro safe_substitute(templ: Template; kws: varargs[untyped]): PyStr
+
+ + + Source   +Edit   + +
+
+
+
macro safe_substitute(templ: Template; mapping: Mapping; kws: varargs[untyped]): PyStr
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
macro substitute(templ: Template; kws: varargs[untyped]): PyStr
+
+ + + Source   +Edit   + +
+
+
+
macro substitute(templ: Template; mapping: Mapping; kws: varargs[untyped]): PyStr
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Exports

+
+ removeprefix, endsWith, maketrans, substr, ==, str, ascii, NoneType, +=, partition, endsWith, startsWith, maketrans, +=, TranslateAction, ord, translate, str, bin, str, rf, u, TranslateTableVal, StringLike, split, strip, isspace, ==, str, endsWith, rstrip, isalpha, *, rindex, center, ==, Fr, split, contains, ascii, rstrip, replace, endsWith, contains, endsWith, format, toNimString, +, count, repr, lstrip, u, TranslateTableABC, runeAtPos, chr, +=, removesuffix, None, pyrepr, rsplit, capitalize, split, startsWith, startsWith, translate, format, split, center, title, replace, maketrans, [], count, ljust, toNimStr, repr, [], TranslateValType, [], TypedTranslateTableABC, toPyStr, PyStr, and, isupper, $, startsWith, isascii, index, rjust, hex, translate, reversed, rpartition, rsplit, runeLenAt, fr, str, count, chars, istitle, len, toPyStr, Rf, str, splitlines, expandtabs, toPyStr, splitlines, not, islower, runes, casefold, join, upper, ascii, contains, getChar, rfind, ljust, find, strip, oct, +, TranslateTable, lstrip, $, zfill, startsWith, StrTypedTranslateTable, rsplit, isascii, or, translate, byteLen, ord1, items, ascii, len, rjust, f, lower, <>, fspath, *, []=, newPyList, newPyList, sorted, <, <=, nimArrayAsList, []=, list, ==, pop, count, repr, []=, newPyList, <=, sorted, PyList, sort, sorted, clear, $, [], newPyListOfCap, index, append, index, newPyListOfStr, [], checkLenientOps, +=, getPtr, newPyList, <, pop, []=, sort, +=, list, pairs, delitem, delitem, extend, []=, setLen, list, []=, <, items, count, <=, newPyListOfStr, extend, ==, newPyList, *=, []=, newPyList, []=, len, mitems, *, +, insert, ==, @, +, reverse, list, delitem, reverse, repr, *, [], list, [], Template, Template, delimiter +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/string.idx b/Lib/string.idx new file mode 100644 index 000000000..8f4420b56 --- /dev/null +++ b/Lib/string.idx @@ -0,0 +1,22 @@ +nimTitle string string.html module src/pylib/Lib/string 0 +nim ascii_lowercase string.html#ascii_lowercase const ascii_lowercase 19 +nim ascii_uppercase string.html#ascii_uppercase const ascii_uppercase 19 +nim ascii_letters string.html#ascii_letters const ascii_letters 19 +nim digits string.html#digits const digits 19 +nim hexdigits string.html#hexdigits const hexdigits 19 +nim octdigits string.html#octdigits const octdigits 19 +nim punctuation string.html#punctuation const punctuation 19 +nim whitespace string.html#whitespace const whitespace 19 +nim printable string.html#printable const printable 19 +nim capwords string.html#capwords,StringLike proc capwords(a: StringLike): PyStr 4 +nim capwords string.html#capwords,StringLike,StringLike proc capwords(a: StringLike; sep: StringLike): PyStr 32 +nim capwords string.html#capwords,StringLike,NoneType proc capwords(a: StringLike; _: NoneType): PyStr 35 +nim substitute string.html#substitute.m,Template,varargs[untyped] macro substitute(templ: Template; kws: varargs[untyped]): PyStr 61 +nim substitute string.html#substitute.m,Template,Mapping,varargs[untyped] macro substitute(templ: Template; mapping: Mapping; kws: varargs[untyped]): PyStr 55 +nim safe_substitute string.html#safe_substitute.m,Template,varargs[untyped] macro safe_substitute(templ: Template; kws: varargs[untyped]): PyStr 61 +nim safe_substitute string.html#safe_substitute.m,Template,Mapping,varargs[untyped] macro safe_substitute(templ: Template; mapping: Mapping; kws: varargs[untyped]): PyStr 56 +nim is_valid string.html#is_valid,Template proc is_valid(templ: Template): bool 58 +nim get_identifiers string.html#get_identifiers,Template proc get_identifiers(templ: Template): PyList[PyStr] 60 +nimgrp capwords string.html#capwords-procs-all proc 4 +nimgrp safesubstitute string.html#safe_substitute-macros-all macro 56 +nimgrp substitute string.html#substitute-macros-all macro 55 diff --git a/Lib/string_impl/capwordsImpl.html b/Lib/string_impl/capwordsImpl.html new file mode 100644 index 000000000..5f5254165 --- /dev/null +++ b/Lib/string_impl/capwordsImpl.html @@ -0,0 +1,109 @@ + + + + + + + +src/pylib/Lib/string_impl/capwordsImpl + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/string_impl/capwordsImpl

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Templates

+
+
+
+
template genCapwords(Arg, Res, split, split2, capitalize, strip) {.dirty.}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/string_impl/capwordsImpl.idx b/Lib/string_impl/capwordsImpl.idx new file mode 100644 index 000000000..c3d45505c --- /dev/null +++ b/Lib/string_impl/capwordsImpl.idx @@ -0,0 +1,2 @@ +nimTitle capwordsImpl string_impl/capwordsImpl.html module src/pylib/Lib/string_impl/capwordsImpl 0 +nim genCapwords string_impl/capwordsImpl.html#genCapwords.t,,,,,, template genCapwords(Arg, Res, split, split2, capitalize, strip) 3 diff --git a/Lib/string_impl/consts.html b/Lib/string_impl/consts.html new file mode 100644 index 000000000..a0f55a200 --- /dev/null +++ b/Lib/string_impl/consts.html @@ -0,0 +1,191 @@ + + + + + + + +src/pylib/Lib/string_impl/consts + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/string_impl/consts

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Consts

+
+
+
ascii_letters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
+
+ + + Source   +Edit   + +
+
+
+
ascii_lowercase = "abcdefghijklmnopqrstuvwxyz"
+
+ + + Source   +Edit   + +
+
+
+
ascii_uppercase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
+
+ + + Source   +Edit   + +
+
+
+
digits = "0123456789"
+
+ + + Source   +Edit   + +
+
+
+
hexdigits = "0123456789abcdefABCDEF"
+
+ + + Source   +Edit   + +
+
+
+
octdigits = "01234567"
+
+ + + Source   +Edit   + +
+
+
+
printable = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ!\"#$%&\\\'()*+,-./:;<=>?@[\\\\]^_`{|}~ \t\n\r\v\f"
+
+ + + Source   +Edit   + +
+
+
+
punctuation = """!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~"""
+
+ + + Source   +Edit   + +
+
+
+
whitespace = " \t\n\r\v\f"
+
+ + + Source   +Edit   + +
+
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/string_impl/consts.idx b/Lib/string_impl/consts.idx new file mode 100644 index 000000000..76372ff44 --- /dev/null +++ b/Lib/string_impl/consts.idx @@ -0,0 +1,10 @@ +nimTitle consts string_impl/consts.html module src/pylib/Lib/string_impl/consts 0 +nim ascii_lowercase string_impl/consts.html#ascii_lowercase const ascii_lowercase 4 +nim ascii_uppercase string_impl/consts.html#ascii_uppercase const ascii_uppercase 5 +nim ascii_letters string_impl/consts.html#ascii_letters const ascii_letters 6 +nim digits string_impl/consts.html#digits const digits 7 +nim hexdigits string_impl/consts.html#hexdigits const hexdigits 8 +nim octdigits string_impl/consts.html#octdigits const octdigits 9 +nim punctuation string_impl/consts.html#punctuation const punctuation 10 +nim whitespace string_impl/consts.html#whitespace const whitespace 11 +nim printable string_impl/consts.html#printable const printable 12 diff --git a/Lib/string_impl/n_chainmap.html b/Lib/string_impl/n_chainmap.html new file mode 100644 index 000000000..8f2a58864 --- /dev/null +++ b/Lib/string_impl/n_chainmap.html @@ -0,0 +1,168 @@ + + + + + + + +src/pylib/Lib/string_impl/n_chainmap + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/string_impl/n_chainmap

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

a ChainMap version accepting 2 Tables

+
+

Types

+
+
+
ChainMap[K; V] = object
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
proc `[]`[K, V](self: ChainMap[K, V]; k: K): V
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc contains[K, V](self: ChainMap[K, V]; k: K): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc initChainMap[K, V](a, b: Table[K, V]): ChainMap[K, V]
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/string_impl/n_chainmap.idx b/Lib/string_impl/n_chainmap.idx new file mode 100644 index 000000000..ae4197e07 --- /dev/null +++ b/Lib/string_impl/n_chainmap.idx @@ -0,0 +1,5 @@ +nimTitle n_chainmap string_impl/n_chainmap.html module src/pylib/Lib/string_impl/n_chainmap 0 +nim ChainMap string_impl/n_chainmap.html#ChainMap object ChainMap 5 +nim initChainMap string_impl/n_chainmap.html#initChainMap,Table[K,V],Table[K,V] proc initChainMap[K, V](a, b: Table[K, V]): ChainMap[K, V] 8 +nim `[]` string_impl/n_chainmap.html#[],ChainMap[K,V],K proc `[]`[K, V](self: ChainMap[K, V]; k: K): V 11 +nim contains string_impl/n_chainmap.html#contains,ChainMap[K,V],K proc contains[K, V](self: ChainMap[K, V]; k: K): bool 15 diff --git a/Lib/string_impl/substituteImpl.html b/Lib/string_impl/substituteImpl.html new file mode 100644 index 000000000..83c424321 --- /dev/null +++ b/Lib/string_impl/substituteImpl.html @@ -0,0 +1,361 @@ + + + + + + + +src/pylib/Lib/string_impl/substituteImpl + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/string_impl/substituteImpl

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Imports

+
+ n_chainmap +
+
+
+

Types

+
+
+
GetIdent = ref object of SubsCfg
+
+ + for get_identifiers() excHandle shall ignore ValueError, too + Source   +Edit   + +
+
+
+
Subs = ref object of SubsCfg
+
+ + for substitute() + Source   +Edit   + +
+
+
+
SubsCfg = ref object of RootObj
+  delimiter*: char
+  excHandle*: ExcHandle
+
+ + for is_valid() + Source   +Edit   + +
+
+ +
+
+
+

Consts

+
+
+
Delimiter = '$'
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
proc initIgnoreExcHandle(): ExcHandle {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc initRaisesExcHandle(): ExcHandle {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc initSubsCfg(excHandle = initRaisesExcHandle(); delimiter = Delimiter): SubsCfg {.
+    ...raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc isValid(templ: string): bool {....raises: [Exception], tags: [RootEffect],
+                                    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc resetSubsCfg(cfg: SubsCfg; excHandle = initRaisesExcHandle();
+                  delimiter = Delimiter) {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc substituteAux[M](templ: string; m: M; excHandle = initRaisesExcHandle();
+                      delimiter = Delimiter): string
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Iterators

+
+
+
+
iterator getIdentifiers(templ: string): string {....raises: [Exception],
+    tags: [RootEffect], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template handle[M](s: SubsCfg; formatstr: string; m: M; lookup)
+
+ +
Note: +this differs Nim's std/strutils %
+ + Source   +Edit   + +
+
+ +
+ +
+
+
+

Exports

+
+ [], contains +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/string_impl/substituteImpl.idx b/Lib/string_impl/substituteImpl.idx new file mode 100644 index 000000000..2cf9a049b --- /dev/null +++ b/Lib/string_impl/substituteImpl.idx @@ -0,0 +1,13 @@ +nimTitle substituteImpl string_impl/substituteImpl.html module src/pylib/Lib/string_impl/substituteImpl 0 +nim Delimiter string_impl/substituteImpl.html#Delimiter const Delimiter 30 +nim initIgnoreExcHandle string_impl/substituteImpl.html#initIgnoreExcHandle proc initIgnoreExcHandle(): ExcHandle 47 +nim initRaisesExcHandle string_impl/substituteImpl.html#initRaisesExcHandle proc initRaisesExcHandle(): ExcHandle 48 +nim SubsCfg string_impl/substituteImpl.html#SubsCfg type SubsCfg 51 +nim Subs string_impl/substituteImpl.html#Subs type Subs 61 +nim GetIdent string_impl/substituteImpl.html#GetIdent type GetIdent 79 +nim resetSubsCfg string_impl/substituteImpl.html#resetSubsCfg,SubsCfg proc resetSubsCfg(cfg: SubsCfg; excHandle = initRaisesExcHandle();\n delimiter = Delimiter) 87 +nim initSubsCfg string_impl/substituteImpl.html#initSubsCfg proc initSubsCfg(excHandle = initRaisesExcHandle(); delimiter = Delimiter): SubsCfg 91 +nim handle string_impl/substituteImpl.html#handle.t,SubsCfg,string,M, template handle[M](s: SubsCfg; formatstr: string; m: M; lookup) 94 +nim substituteAux string_impl/substituteImpl.html#substituteAux,string,M proc substituteAux[M](templ: string; m: M; excHandle = initRaisesExcHandle();\n delimiter = Delimiter): string 129 +nim isValid string_impl/substituteImpl.html#isValid,string proc isValid(templ: string): bool 139 +nim getIdentifiers string_impl/substituteImpl.html#getIdentifiers.i,string iterator getIdentifiers(templ: string): string 145 diff --git a/Lib/string_impl/templateImpl.html b/Lib/string_impl/templateImpl.html new file mode 100644 index 000000000..93a33421d --- /dev/null +++ b/Lib/string_impl/templateImpl.html @@ -0,0 +1,208 @@ + + + + + + + +src/pylib/Lib/string_impl/templateImpl + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/string_impl/templateImpl

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
proc is_valid(templ: Template): bool {....raises: [Exception], tags: [RootEffect],
+                                       forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc Template(s: string): Template {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Iterators

+
+
+
+
iterator get_identifiersMayDup(templ: Template): string {....raises: [Exception],
+    tags: [RootEffect], forbids: [].}
+
+ + not dedup + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template genSubstitute(M; Key; sym; doExc) {.dirty.}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ + +
+
+ + +
+
+ + + diff --git a/Lib/string_impl/templateImpl.idx b/Lib/string_impl/templateImpl.idx new file mode 100644 index 000000000..fc9323bf9 --- /dev/null +++ b/Lib/string_impl/templateImpl.idx @@ -0,0 +1,5 @@ +nimTitle templateImpl string_impl/templateImpl.html module src/pylib/Lib/string_impl/templateImpl 0 +nim Template string_impl/templateImpl.html#Template,string proc Template(s: string): Template 14 +nim genSubstitute string_impl/templateImpl.html#genSubstitute.t,,,, template genSubstitute(M; Key; sym; doExc) 57 +nim is_valid string_impl/templateImpl.html#is_valid,Template proc is_valid(templ: Template): bool 67 +nim get_identifiersMayDup string_impl/templateImpl.html#get_identifiersMayDup.i,Template iterator get_identifiersMayDup(templ: Template): string 68 diff --git a/Lib/string_impl/template_decl.html b/Lib/string_impl/template_decl.html new file mode 100644 index 000000000..4f797250a --- /dev/null +++ b/Lib/string_impl/template_decl.html @@ -0,0 +1,166 @@ + + + + + + + +src/pylib/Lib/string_impl/template_decl + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/string_impl/template_decl

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Types

+
+
+
Template = ref object of RootObj
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
func `$`(self: Template): string {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Methods

+
+
+
+
method delimiter(self: Template): char {.base, ...raises: [], tags: [], forbids: [].}
+
+ + +.. note:: In Python this is a class attribute + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/string_impl/template_decl.idx b/Lib/string_impl/template_decl.idx new file mode 100644 index 000000000..4756a6c83 --- /dev/null +++ b/Lib/string_impl/template_decl.idx @@ -0,0 +1,4 @@ +nimTitle template_decl string_impl/template_decl.html module src/pylib/Lib/string_impl/template_decl 0 +nim Template string_impl/template_decl.html#Template type Template 2 +nim `$` string_impl/template_decl.html#$,Template proc `$`(self: Template): string 5 +nim delimiter string_impl/template_decl.html#delimiter.e,Template method delimiter(self: Template): char 7 diff --git a/Lib/sys.html b/Lib/sys.html new file mode 100644 index 000000000..a15fd8aa6 --- /dev/null +++ b/Lib/sys.html @@ -0,0 +1,405 @@ + + + + + + + +src/pylib/Lib/sys + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/sys

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

Lib/sys

Hint: +if not defined pylibConfigIsolated, this module will call setlocale(LC_CTYPE, ""), a.k.a. changing locale to user's configure, just as CPython's initialization.
+

+ +
+

Vars

+
+
+
argv: PyList[PyStr]
+
+ + + Source   +Edit   + +
+
+
+
orig_argv = newPyListOfCap(argc)
+
+ + + .. hint:: rely on paramCount<https://nim-lang.org/docs/cmdline.html#paramCount>_ and paramStr<https://nim-lang.org/docs/cmdline.html#paramStr%2Cint>_. See their document for availability. + Source   +Edit   + +
+
+ +
+
+
+

Consts

+
+
+
byteorder = "little"
+
+ + + Source   +Edit   + +
+
+ +
+
float_repr_style = "short"
+
+ + + Source   +Edit   + +
+
+
+
hexversion = 51577072
+
+ + + Source   +Edit   + +
+
+
+
implementation = ("pynim", (0, 9, 11, "alpha", 0), 51577072, false)
+
+ + + Source   +Edit   + +
+
+
+
maxsize = 9223372036854775807'i64
+
+ + + Source   +Edit   + +
+
+
+
platform = "linux"
+
+ +
Note: +the value is standalone for bare system
+

and haiku/netbsd appended with major version instead of "unknown". In short, this won't be "unknown" as Python does.

+ + Source   +Edit   + +
+
+
+
version = "3.13.0"
+
+ + + Source   +Edit   + +
+
+
+
version_info = (3, 13, 0, "final", 0)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
func exit(x: NoneType) {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func exit[T](obj: T)
+
+ +
Warning: +this does not raise SystemExit, which differs Python's
+ + Source   +Edit   + +
+
+ +
+
+
+
proc getdefaultencoding(): PyStr {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc getfilesystemencoding(): PyStr {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template addaudithook(hook: HookProc)
+
+ +
Admonition: +since Python 3.8
+ + Source   +Edit   + +
+
+ +
+
+
+
template audit(event: string; args: varargs[typed])
+
+ +
Admonition: +since Python 3.8
+ + Source   +Edit   + +
+
+ +
+
+
+
template executable(): PyStr
+
+ + returns:
  • when nimscript, path of Nim;
  • +
  • when JavaScript:
    • on browser: empty string
    • +
    • on NodeJS/Deno: executable path of Node/Deno
    • +
    +
  • +
  • otherwise, it's the path of current app/exe.
  • +
+ + Source   +Edit   + +
+
+ +
+ +
+
+ + +
+
+ + +
+
+ + + diff --git a/Lib/sys.idx b/Lib/sys.idx new file mode 100644 index 000000000..6fef37497 --- /dev/null +++ b/Lib/sys.idx @@ -0,0 +1,20 @@ +nimTitle sys sys.html module src/pylib/Lib/sys 0 +nim addaudithook sys.html#addaudithook.t,HookProc template addaudithook(hook: HookProc) 18 +nim audit sys.html#audit.t,string,varargs[typed] template audit(event: string; args: varargs[typed]) 19 +nim float_repr_style sys.html#float_repr_style const float_repr_style 21 +nim platform sys.html#platform const platform 58 +nim version_info sys.html#version_info_2 const version_info 33 +nim implementation sys.html#implementation_2 const implementation 47 +nim version sys.html#version_2 const version 53 +nim hexversion sys.html#hexversion_2 const hexversion 54 +nim maxsize sys.html#maxsize_2 const maxsize 56 +nim byteorder sys.html#byteorder_2 const byteorder 57 +nim copyright sys.html#copyright_2 const copyright 58 +nim orig_argv sys.html#orig_argv_2 var orig_argv 34 +nim argv sys.html#argv_2 var argv 39 +nim executable sys.html#executable.t_2 template executable(): PyStr 61 +nim getfilesystemencoding sys.html#getfilesystemencoding_2 proc getfilesystemencoding(): PyStr 33 +nim getdefaultencoding sys.html#getdefaultencoding_2 proc getdefaultencoding(): PyStr 34 +nim exit sys.html#exit,T proc exit[T](obj: T) 36 +nim exit sys.html#exit,NoneType proc exit(x: NoneType) 40 +nimgrp exit sys.html#exit-procs-all proc 36 diff --git a/Lib/sys_impl/auditImpl.html b/Lib/sys_impl/auditImpl.html new file mode 100644 index 000000000..17462e522 --- /dev/null +++ b/Lib/sys_impl/auditImpl.html @@ -0,0 +1,96 @@ + + + + + + + +src/pylib/Lib/sys_impl/auditImpl + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/sys_impl/auditImpl

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

When not defined(release) or defined(pylibSysAudit), audit will be enabled. Otherwise, it will be disabled.

+ + + +
+
+ + +
+
+ + + diff --git a/Lib/sys_impl/auditImpl.idx b/Lib/sys_impl/auditImpl.idx new file mode 100644 index 000000000..1f2e2a4c2 --- /dev/null +++ b/Lib/sys_impl/auditImpl.idx @@ -0,0 +1 @@ +nimTitle auditImpl sys_impl/auditImpl.html module src/pylib/Lib/sys_impl/auditImpl 0 diff --git a/Lib/sys_impl/auditImpl/cfg.html b/Lib/sys_impl/auditImpl/cfg.html new file mode 100644 index 000000000..d1380a92b --- /dev/null +++ b/Lib/sys_impl/auditImpl/cfg.html @@ -0,0 +1,151 @@ + + + + + + + +src/pylib/Lib/sys_impl/auditImpl/cfg + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/sys_impl/auditImpl/cfg

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Consts

+
+
+
config_should_audit = false
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Templates

+
+
+
+
template whenAuditEnabled(body)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template whenAuditEnabledOr[T](exp, elseExp: T): T
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/sys_impl/auditImpl/cfg.idx b/Lib/sys_impl/auditImpl/cfg.idx new file mode 100644 index 000000000..00248b599 --- /dev/null +++ b/Lib/sys_impl/auditImpl/cfg.idx @@ -0,0 +1,4 @@ +nimTitle cfg sys_impl/auditImpl/cfg.html module src/pylib/Lib/sys_impl/auditImpl/cfg 0 +nim config_should_audit sys_impl/auditImpl/cfg.html#config_should_audit const config_should_audit 3 +nim whenAuditEnabled sys_impl/auditImpl/cfg.html#whenAuditEnabled.t template whenAuditEnabled(body) 7 +nim whenAuditEnabledOr sys_impl/auditImpl/cfg.html#whenAuditEnabledOr.t,T,T template whenAuditEnabledOr[T](exp, elseExp: T): T 12 diff --git a/Lib/sys_impl/auditImpl/main.html b/Lib/sys_impl/auditImpl/main.html new file mode 100644 index 000000000..03f9d7741 --- /dev/null +++ b/Lib/sys_impl/auditImpl/main.html @@ -0,0 +1,169 @@ + + + + + + + +src/pylib/Lib/sys_impl/auditImpl/main + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/sys_impl/auditImpl/main

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Imports

+
+ cfg, types +
+
+
+

Templates

+
+
+
+
template addaudithook(hook: HookProc)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template audit(event: string; args: varargs[typed])
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template PySys_AddAuditHook(hook: HookProc; userData = default Any)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template PySys_Audit(event: string; args: varargs[typed])
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/sys_impl/auditImpl/main.idx b/Lib/sys_impl/auditImpl/main.idx new file mode 100644 index 000000000..cff6b04db --- /dev/null +++ b/Lib/sys_impl/auditImpl/main.idx @@ -0,0 +1,5 @@ +nimTitle main sys_impl/auditImpl/main.html module src/pylib/Lib/sys_impl/auditImpl/main 0 +nim PySys_Audit sys_impl/auditImpl/main.html#PySys_Audit.t,string,varargs[typed] template PySys_Audit(event: string; args: varargs[typed]) 4 +nim PySys_AddAuditHook sys_impl/auditImpl/main.html#PySys_AddAuditHook.t,HookProc template PySys_AddAuditHook(hook: HookProc; userData = default Any) 9 +nim addaudithook sys_impl/auditImpl/main.html#addaudithook.t,HookProc template addaudithook(hook: HookProc) 10 +nim audit sys_impl/auditImpl/main.html#audit.t,string,varargs[typed] template audit(event: string; args: varargs[typed]) 12 diff --git a/Lib/sys_impl/auditImpl/types.html b/Lib/sys_impl/auditImpl/types.html new file mode 100644 index 000000000..c400225b1 --- /dev/null +++ b/Lib/sys_impl/auditImpl/types.html @@ -0,0 +1,114 @@ + + + + + + + +src/pylib/Lib/sys_impl/auditImpl/types + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/sys_impl/auditImpl/types

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Types

+
+
+
HookEntry = tuple[hookCFunction: HookProc, userData: Any]
+
+ + + Source   +Edit   + +
+
+
+
HookProc = proc (event: string; args: varargs[Any])
+
+ + + Source   +Edit   + +
+
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/sys_impl/auditImpl/types.idx b/Lib/sys_impl/auditImpl/types.idx new file mode 100644 index 000000000..4af25bc8f --- /dev/null +++ b/Lib/sys_impl/auditImpl/types.idx @@ -0,0 +1,3 @@ +nimTitle types sys_impl/auditImpl/types.html module src/pylib/Lib/sys_impl/auditImpl/types 0 +nim HookProc sys_impl/auditImpl/types.html#HookProc type HookProc 6 +nim HookEntry sys_impl/auditImpl/types.html#HookEntry tuple HookEntry 7 diff --git a/Lib/sys_impl/exits.html b/Lib/sys_impl/exits.html new file mode 100644 index 000000000..9133bf820 --- /dev/null +++ b/Lib/sys_impl/exits.html @@ -0,0 +1,120 @@ + + + + + + + +src/pylib/Lib/sys_impl/exits + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/sys_impl/exits

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Procs

+
+
+
+
func exit(c: int) {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc exit(s: string) {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/sys_impl/exits.idx b/Lib/sys_impl/exits.idx new file mode 100644 index 000000000..8189182d9 --- /dev/null +++ b/Lib/sys_impl/exits.idx @@ -0,0 +1,4 @@ +nimTitle exits sys_impl/exits.html module src/pylib/Lib/sys_impl/exits 0 +nim exit sys_impl/exits.html#exit,string proc exit(s: string) 2 +nim exit sys_impl/exits.html#exit,int proc exit(c: int) 3 +nimgrp exit sys_impl/exits.html#exit-procs-all proc 2 diff --git a/Lib/sys_impl/fenvs.html b/Lib/sys_impl/fenvs.html new file mode 100644 index 000000000..42d76629a --- /dev/null +++ b/Lib/sys_impl/fenvs.html @@ -0,0 +1,158 @@ + + + + + + + +src/pylib/Lib/sys_impl/fenvs + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/sys_impl/fenvs

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Consts

+
+
+
float_info = (max: 1.7976931348623157e+308, max_exp: 1024, max_10_exp: 308,
+              min: 2.2250738585072014e-308, min_exp: -1021, min_10_exp: -307,
+              dig: 15, mant_dig: 53, epsilon: 2.220446049250313e-16, radix: 2)
+
+ + float_info.rounds is defined as a getter, see rounds + Source   +Edit   + +
+
+
+
float_repr_style = "short"
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Templates

+
+
+
+
template rounds(fi: typeof(float_info)): int
+
+ + not available when nimscript + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/sys_impl/fenvs.idx b/Lib/sys_impl/fenvs.idx new file mode 100644 index 000000000..d66741ba7 --- /dev/null +++ b/Lib/sys_impl/fenvs.idx @@ -0,0 +1,4 @@ +nimTitle fenvs sys_impl/fenvs.html module src/pylib/Lib/sys_impl/fenvs 0 +nim float_repr_style sys_impl/fenvs.html#float_repr_style const float_repr_style 6 +nim float_info sys_impl/fenvs.html#float_info const float_info 15 +nim rounds sys_impl/fenvs.html#rounds.t template rounds(fi: typeof(float_info)): int 31 diff --git a/Lib/sys_impl/flagsImpl.html b/Lib/sys_impl/flagsImpl.html new file mode 100644 index 000000000..ff1cfb072 --- /dev/null +++ b/Lib/sys_impl/flagsImpl.html @@ -0,0 +1,128 @@ + + + + + + + +src/pylib/Lib/sys_impl/flagsImpl + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/sys_impl/flagsImpl

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Lets

+
+
+
flags = (debug: debug, inspect: inspect, interactive: interactive,
+         isolated: isolated, optimize: optimize,
+         dont_write_bytecode: dont_write_bytecode, no_user_site: no_user_site,
+         no_site: no_site, ignore_environment: ignore_environment,
+         verbose: verbose, bytes_warning: bytes_warning, quiet: quiet,
+         hash_randomization: hash_randomization, dev_mode: dev_mode,
+         utf8_mode: utf8_mode, safe_path: safe_path,
+         int_max_str_digits: int_max_str_digits,
+         warn_default_encoding: warn_default_encoding)
+
+ + + Source   +Edit   + +
+
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/sys_impl/flagsImpl.idx b/Lib/sys_impl/flagsImpl.idx new file mode 100644 index 000000000..567f2af82 --- /dev/null +++ b/Lib/sys_impl/flagsImpl.idx @@ -0,0 +1,2 @@ +nimTitle flagsImpl sys_impl/flagsImpl.html module src/pylib/Lib/sys_impl/flagsImpl 0 +nim flags sys_impl/flagsImpl.html#flags let flags 1155 diff --git a/Lib/sys_impl/flagsImpl/ct.html b/Lib/sys_impl/flagsImpl/ct.html new file mode 100644 index 000000000..eb10bd31b --- /dev/null +++ b/Lib/sys_impl/flagsImpl/ct.html @@ -0,0 +1,372 @@ + + + + + + + +src/pylib/Lib/sys_impl/flagsImpl/ct + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/sys_impl/flagsImpl/ct

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

PYTHON* environment variables will be loaded iif pylibUsePyEnv is defined.

+ +
+

Vars

+
+
+
fields {.compileTime.} = newSeqOfCap(18)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Consts

+
+
+
bytes_warning {.intdefine: bytes_warning.toCfgName.} = 0
+
+ + + Source   +Edit   + +
+
+
+
debug {.intdefine: debug.toCfgName.} = 1
+
+ + + Source   +Edit   + +
+
+
+
dev_mode {.booldefine: dev_mode.toCfgName.} = false
+
+ + + Source   +Edit   + +
+
+
+
dont_write_bytecode {.intdefine: dont_write_bytecode.toCfgName.} = 1
+
+ + + Source   +Edit   + +
+
+
+
hash_randomization {.intdefine: hash_randomization.toCfgName.} = 0
+
+ + + Source   +Edit   + +
+
+
+
ignore_environment {.intdefine: ignore_environment.toCfgName.} = 0
+
+ + + Source   +Edit   + +
+
+
+
inspect {.intdefine: inspect.toCfgName.} = 0
+
+ + + Source   +Edit   + +
+
+
+
int_max_str_digits {.intdefine: int_max_str_digits.toCfgName.} = 4300
+
+ + + Source   +Edit   + +
+
+
+
interactive {.intdefine: interactive.toCfgName.} = 0
+
+ + + Source   +Edit   + +
+
+
+
isolated {.intdefine: isolated.toCfgName.} = 0
+
+ + + Source   +Edit   + +
+
+
+
no_site {.intdefine: no_site.toCfgName.} = 0
+
+ + + Source   +Edit   + +
+
+
+
no_user_site {.intdefine: no_user_site.toCfgName.} = 0
+
+ + + Source   +Edit   + +
+
+
+
optimize {.intdefine: optimize.toCfgName.} = 0
+
+ + + Source   +Edit   + +
+
+
+
quiet {.intdefine: quiet.toCfgName.} = 0
+
+ + + Source   +Edit   + +
+
+
+
safe_path {.booldefine: safe_path.toCfgName.} = false
+
+ + + Source   +Edit   + +
+
+
+
utf8_mode {.intdefine: utf8_mode.toCfgName.} = 0
+
+ + + Source   +Edit   + +
+
+
+
verbose {.intdefine: verbose.toCfgName.} = 0
+
+ + + Source   +Edit   + +
+
+
+
warn_default_encoding {.intdefine: warn_default_encoding.toCfgName.} = 0
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Macros

+
+
+
+
macro genFlagsObj()
+
+ + generate let flags* = ... + Source   +Edit   + +
+
+ +
+
+
+
macro redefineFlags(kws: varargs[untyped])
+
+ + used in intermediate file, which wanna define some runtime flags. due to export except's behavior, unknown kws are just ignored. + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/sys_impl/flagsImpl/ct.idx b/Lib/sys_impl/flagsImpl/ct.idx new file mode 100644 index 000000000..ab7fcabfd --- /dev/null +++ b/Lib/sys_impl/flagsImpl/ct.idx @@ -0,0 +1,22 @@ +nimTitle ct sys_impl/flagsImpl/ct.html module src/pylib/Lib/sys_impl/flagsImpl/ct 0 +nim fields sys_impl/flagsImpl/ct.html#fields var fields 9 +nim debug sys_impl/flagsImpl/ct.html#debug const debug 22 +nim inspect sys_impl/flagsImpl/ct.html#inspect const inspect 22 +nim interactive sys_impl/flagsImpl/ct.html#interactive const interactive 22 +nim isolated sys_impl/flagsImpl/ct.html#isolated const isolated 22 +nim optimize sys_impl/flagsImpl/ct.html#optimize const optimize 22 +nim dont_write_bytecode sys_impl/flagsImpl/ct.html#dont_write_bytecode const dont_write_bytecode 22 +nim no_user_site sys_impl/flagsImpl/ct.html#no_user_site const no_user_site 22 +nim no_site sys_impl/flagsImpl/ct.html#no_site const no_site 22 +nim ignore_environment sys_impl/flagsImpl/ct.html#ignore_environment const ignore_environment 22 +nim verbose sys_impl/flagsImpl/ct.html#verbose const verbose 22 +nim bytes_warning sys_impl/flagsImpl/ct.html#bytes_warning const bytes_warning 22 +nim quiet sys_impl/flagsImpl/ct.html#quiet const quiet 22 +nim hash_randomization sys_impl/flagsImpl/ct.html#hash_randomization const hash_randomization 22 +nim dev_mode sys_impl/flagsImpl/ct.html#dev_mode const dev_mode 18 +nim utf8_mode sys_impl/flagsImpl/ct.html#utf8_mode const utf8_mode 22 +nim safe_path sys_impl/flagsImpl/ct.html#safe_path const safe_path 18 +nim int_max_str_digits sys_impl/flagsImpl/ct.html#int_max_str_digits const int_max_str_digits 22 +nim warn_default_encoding sys_impl/flagsImpl/ct.html#warn_default_encoding const warn_default_encoding 22 +nim redefineFlags sys_impl/flagsImpl/ct.html#redefineFlags.m,varargs[untyped] macro redefineFlags(kws: varargs[untyped]) 48 +nim genFlagsObj sys_impl/flagsImpl/ct.html#genFlagsObj.m macro genFlagsObj() 60 diff --git a/Lib/sys_impl/flagsImpl/values.html b/Lib/sys_impl/flagsImpl/values.html new file mode 100644 index 000000000..eb14a909e --- /dev/null +++ b/Lib/sys_impl/flagsImpl/values.html @@ -0,0 +1,233 @@ + + + + + + + +src/pylib/Lib/sys_impl/flagsImpl/values + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/sys_impl/flagsImpl/values

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Lets

+
+
+
debug = ib_i(toPyEnv("debug"), debug)
+
+ + + Source   +Edit   + +
+
+
+
dev_mode = ib_e(toPyEnv("dev_mode"), dev_mode)
+
+ + + Source   +Edit   + +
+
+
+
dont_write_bytecode = ib_b(toPyEnv("dont_write_bytecode"), dont_write_bytecode)
+
+ + + Source   +Edit   + +
+
+
+
inspect = ib_i(toPyEnv("inspect"), inspect)
+
+ + + Source   +Edit   + +
+
+
+
int_max_str_digits = ib_i(toPyEnv("int_max_str_digits"), int_max_str_digits)
+
+ + + Source   +Edit   + +
+
+
+
no_user_site = ib_b(toPyEnv("no_user_site"), no_user_site)
+
+ + + Source   +Edit   + +
+
+
+
optimize = ib_i(toPyEnv("optimize"), optimize)
+
+ + + Source   +Edit   + +
+
+
+
safe_path = ib_e(toPyEnv("safe_path"), safe_path)
+
+ + + Source   +Edit   + +
+
+
+
utf8_mode = ib_i("PYTHONUTF8", utf8_mode)
+
+ + + Source   +Edit   + +
+
+
+
verbose = ib_i(toPyEnv("verbose"), verbose)
+
+ + + Source   +Edit   + +
+
+
+
warn_default_encoding = ib_e(toPyEnv("warn_default_encoding"),
+                             warn_default_encoding)
+
+ + + Source   +Edit   + +
+
+ +
+
+ + +
+
+ + +
+
+ + + diff --git a/Lib/sys_impl/flagsImpl/values.idx b/Lib/sys_impl/flagsImpl/values.idx new file mode 100644 index 000000000..38f0b8f19 --- /dev/null +++ b/Lib/sys_impl/flagsImpl/values.idx @@ -0,0 +1,12 @@ +nimTitle values sys_impl/flagsImpl/values.html module src/pylib/Lib/sys_impl/flagsImpl/values 0 +nim debug sys_impl/flagsImpl/values.html#debug let debug 20 +nim verbose sys_impl/flagsImpl/values.html#verbose let verbose 20 +nim optimize sys_impl/flagsImpl/values.html#optimize let optimize 20 +nim inspect sys_impl/flagsImpl/values.html#inspect let inspect 20 +nim dont_write_bytecode sys_impl/flagsImpl/values.html#dont_write_bytecode let dont_write_bytecode 20 +nim no_user_site sys_impl/flagsImpl/values.html#no_user_site let no_user_site 20 +nim safe_path sys_impl/flagsImpl/values.html#safe_path let safe_path 20 +nim int_max_str_digits sys_impl/flagsImpl/values.html#int_max_str_digits let int_max_str_digits 20 +nim utf8_mode sys_impl/flagsImpl/values.html#utf8_mode let utf8_mode 20 +nim dev_mode sys_impl/flagsImpl/values.html#dev_mode let dev_mode 20 +nim warn_default_encoding sys_impl/flagsImpl/values.html#warn_default_encoding let warn_default_encoding 20 diff --git a/Lib/sys_impl/genargs.html b/Lib/sys_impl/genargs.html new file mode 100644 index 000000000..02653d565 --- /dev/null +++ b/Lib/sys_impl/genargs.html @@ -0,0 +1,109 @@ + + + + + + + +src/pylib/Lib/sys_impl/genargs + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/sys_impl/genargs

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Templates

+
+
+
+
template genArgs(St, Ls; S; lsCopy, lsOfCap) {.dirty.}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/sys_impl/genargs.idx b/Lib/sys_impl/genargs.idx new file mode 100644 index 000000000..536b2f434 --- /dev/null +++ b/Lib/sys_impl/genargs.idx @@ -0,0 +1,2 @@ +nimTitle genargs sys_impl/genargs.html module src/pylib/Lib/sys_impl/genargs 0 +nim genArgs sys_impl/genargs.html#genArgs.t,,,,, template genArgs(St, Ls; S; lsCopy, lsOfCap) 23 diff --git a/Lib/sys_impl/geninfos.html b/Lib/sys_impl/geninfos.html new file mode 100644 index 000000000..b37411cf6 --- /dev/null +++ b/Lib/sys_impl/geninfos.html @@ -0,0 +1,118 @@ + + + + + + + +src/pylib/Lib/sys_impl/geninfos + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/sys_impl/geninfos

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Templates

+
+
+
+
template genInfos(S; cache_tag_val) {.dirty.}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/sys_impl/geninfos.idx b/Lib/sys_impl/geninfos.idx new file mode 100644 index 000000000..6b6697d5e --- /dev/null +++ b/Lib/sys_impl/geninfos.idx @@ -0,0 +1,2 @@ +nimTitle geninfos sys_impl/geninfos.html module src/pylib/Lib/sys_impl/geninfos 0 +nim genInfos sys_impl/geninfos.html#genInfos.t,, template genInfos(S; cache_tag_val) 28 diff --git a/Lib/sys_impl/genplatform.html b/Lib/sys_impl/genplatform.html new file mode 100644 index 000000000..c89e2512c --- /dev/null +++ b/Lib/sys_impl/genplatform.html @@ -0,0 +1,149 @@ + + + + + + + +src/pylib/Lib/sys_impl/genplatform + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/sys_impl/genplatform

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
proc getPlatform(): string {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template genPlatform(S) {.dirty.}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/sys_impl/genplatform.idx b/Lib/sys_impl/genplatform.idx new file mode 100644 index 000000000..ff62263e0 --- /dev/null +++ b/Lib/sys_impl/genplatform.idx @@ -0,0 +1,3 @@ +nimTitle genplatform sys_impl/genplatform.html module src/pylib/Lib/sys_impl/genplatform 0 +nim getPlatform sys_impl/genplatform.html#getPlatform proc getPlatform(): string 21 +nim genPlatform sys_impl/genplatform.html#genPlatform.t template genPlatform(S) 53 diff --git a/Lib/sys_impl/getencodings.html b/Lib/sys_impl/getencodings.html new file mode 100644 index 000000000..13524e057 --- /dev/null +++ b/Lib/sys_impl/getencodings.html @@ -0,0 +1,137 @@ + + + + + + + +src/pylib/Lib/sys_impl/getencodings + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/sys_impl/getencodings

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
proc getdefaultencoding(): string {....raises: [], tags: [], forbids: [].}
+
+ +

Return the current default encoding used by the Unicode implementation.

+

Always "utf-8" in Nim

+ + Source   +Edit   + +
+
+ +
+
+
+
proc getfilesystemencoding(): string {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/sys_impl/getencodings.idx b/Lib/sys_impl/getencodings.idx new file mode 100644 index 000000000..c0e3ca047 --- /dev/null +++ b/Lib/sys_impl/getencodings.idx @@ -0,0 +1,3 @@ +nimTitle getencodings sys_impl/getencodings.html module src/pylib/Lib/sys_impl/getencodings 0 +nim getdefaultencoding sys_impl/getencodings.html#getdefaultencoding proc getdefaultencoding(): string 30 +nim getfilesystemencoding sys_impl/getencodings.html#getfilesystemencoding proc getfilesystemencoding(): string 111 diff --git a/Lib/sys_impl/sizes.html b/Lib/sys_impl/sizes.html new file mode 100644 index 000000000..f1c842c9b --- /dev/null +++ b/Lib/sys_impl/sizes.html @@ -0,0 +1,120 @@ + + + + + + + +src/pylib/Lib/sys_impl/sizes + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/sys_impl/sizes

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Templates

+
+
+
+
template getsizeof(x): int
+
+ + + Source   +Edit   + +
+
+
+
template getsizeof(x; default: int): int
+
+ + may be used when sizeof(x) is a compile-error e.g. func sizeof(x: O): int{.error.} for O + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/sys_impl/sizes.idx b/Lib/sys_impl/sizes.idx new file mode 100644 index 000000000..4bfa26713 --- /dev/null +++ b/Lib/sys_impl/sizes.idx @@ -0,0 +1,4 @@ +nimTitle sizes sys_impl/sizes.html module src/pylib/Lib/sys_impl/sizes 0 +nim getsizeof sys_impl/sizes.html#getsizeof.t template getsizeof(x): int 2 +nim getsizeof sys_impl/sizes.html#getsizeof.t,,int template getsizeof(x; default: int): int 6 +nimgrp getsizeof sys_impl/sizes.html#getsizeof-templates-all template 2 diff --git a/Lib/sys_impl/stdio.html b/Lib/sys_impl/stdio.html new file mode 100644 index 000000000..e404eebc0 --- /dev/null +++ b/Lib/sys_impl/stdio.html @@ -0,0 +1,190 @@ + + + + + + + +src/pylib/Lib/sys_impl/stdio + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/sys_impl/stdio

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Imports

+
+ util, ../io +
+
+
+

Vars

+
+
+
stderr = newNoEncTextIO(stderr, "<stderr>", DefNewLine)
+
+ + + Source   +Edit   + +
+
+
+
stdin = newNoEncTextIO(stdin, "<stdin>", DefNewLine)
+
+ + + Source   +Edit   + +
+
+
+
stdout = newNoEncTextIO(stdout, "<stdout>", DefNewLine)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Lets

+
+
+
dunder_stderr = stderr
+
+ + __stderr__ + Source   +Edit   + +
+
+
+
dunder_stdin = stdin
+
+ + __stdin__ + Source   +Edit   + +
+
+
+
dunder_stdout = stdout
+
+ + __stdout__ + Source   +Edit   + +
+
+ +
+
+ + +
+
+ + +
+
+ + + diff --git a/Lib/sys_impl/stdio.idx b/Lib/sys_impl/stdio.idx new file mode 100644 index 000000000..09b64525f --- /dev/null +++ b/Lib/sys_impl/stdio.idx @@ -0,0 +1,7 @@ +nimTitle stdio sys_impl/stdio.html module src/pylib/Lib/sys_impl/stdio 0 +nim stdin sys_impl/stdio.html#stdin var stdin 11 +nim stdout sys_impl/stdio.html#stdout var stdout 11 +nim stderr sys_impl/stdio.html#stderr var stderr 11 +nim dunder_stdin sys_impl/stdio.html#dunder_stdin let dunder_stdin 23 +nim dunder_stdout sys_impl/stdio.html#dunder_stdout let dunder_stdout 24 +nim dunder_stderr sys_impl/stdio.html#dunder_stderr let dunder_stderr 25 diff --git a/Lib/sys_impl/util.html b/Lib/sys_impl/util.html new file mode 100644 index 000000000..dbf207574 --- /dev/null +++ b/Lib/sys_impl/util.html @@ -0,0 +1,121 @@ + + + + + + + +src/pylib/Lib/sys_impl/util + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/sys_impl/util

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+ +
+ + +
+
+ + + diff --git a/Lib/sys_impl/util.idx b/Lib/sys_impl/util.idx new file mode 100644 index 000000000..bc9f75bac --- /dev/null +++ b/Lib/sys_impl/util.idx @@ -0,0 +1,2 @@ +nimTitle util sys_impl/util.html module src/pylib/Lib/sys_impl/util 0 +nim weirdTarget sys_impl/util.html#weirdTarget const weirdTarget 2 diff --git a/Lib/tempfile.html b/Lib/tempfile.html new file mode 100644 index 000000000..58960b6ae --- /dev/null +++ b/Lib/tempfile.html @@ -0,0 +1,260 @@ + + + + + + + +src/pylib/Lib/tempfile + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/tempfile

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
proc gettempdir(): PyStr {....raises: [ValueError, OSError, NotImplementedError,
+                                    FileNotFoundError], tags: [ReadEnvEffect],
+                           forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc gettempdirb(): PyBytes {....raises: [ValueError, OSError, NotImplementedError,
+                                       FileNotFoundError],
+                              tags: [ReadEnvEffect], forbids: [].}
+
+ +
Admonition: +since Python 3.5
+ + Source   +Edit   + +
+
+ +
+
+
+
proc gettempprefix(): PyStr {....raises: [ValueError, OSError, NotImplementedError,
+                                       FileNotFoundError],
+                              tags: [ReadEnvEffect], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc gettempprefixb(): PyBytes {....raises: [ValueError, OSError,
+    NotImplementedError, FileNotFoundError], tags: [ReadEnvEffect], forbids: [].}
+
+ +
Admonition: +since Python 3.5
+ + Source   +Edit   + +
+
+ +
+
+
+
proc mkdtemp(suffix: PyStr | NoneType = None; prefix: PyStr | NoneType = None;
+             dir: PyStr | NoneType = None): PyStr
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc mktemp(suffix = ""; prefix = templ; dir: PyStr | NoneType = "";
+            checker = fileExists): PyStr
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template name(self: TemporaryFileWrapper): PyStr
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ + +
+
+ + +
+
+ + + diff --git a/Lib/theindex.html b/Lib/theindex.html new file mode 100644 index 000000000..ee67ab308 --- /dev/null +++ b/Lib/theindex.html @@ -0,0 +1,8413 @@ + + + + + + + +Index + + + + + + + + + + + + + + + + +
+
+

Index

+ Modules: ../Python/config_read_env, ../Python/envutils, ../Python/fileutils, ../Python/force_ascii_utils, ../Python/internal/pycore_fileutils, ../Python/localeutils, ../Python/pylifecycle/signal, ../Python/pylifecycle/signal/c_syms, ../Python/pylifecycle/signal/chk_util, ../Python/pylifecycle/signal/handler_types, ../Python/pytime/deadline, ../Python/pytime/exc_util, ../Python/pytime/monotonic, ../Python/pytime/ops, ../Python/pytime/pytimeAsTimeval, ../Python/pytime/pytimeFromSeconds, ../Python/pytime/rounds, ../Python/pytime/time_t_decl, ../Python/pytime/types, ../Python/pytime/units, ../Python/unicodeobject/char_decl, ../Python/unicodeobject/codecs, ../Python/unicodeobject/cstring_ptr_op, ../Python/unicodeobject/locale_codec, ../Python/unicodeobject/ptr_op, ../Python/unicodeobject/ptr_types, ../Python/unicodeobject/utf8_codec, ../Python/unicodeobject/wchar_utils, ../Python/wchar_t, ../builtins/asciiImpl, ../builtins/dict, ../builtins/dict_decl, ../builtins/iter_next, ../builtins/iters, ../builtins/iters/macroutils, ../builtins/iters/mapMacro, ../builtins/iters/zipMacro, ../builtins/list, ../builtins/list_decl, ../builtins/private/mathutils, ../builtins/private/strIter, ../builtins/pyrange, ../builtins/pyslice, ../builtins/reprImpl, ../builtins/set, ../builtins/set_decl, ../collections_abc, ../collections_abc/asyncs, ../collections_abc/collections, ../collections_abc/generators, ../collections_abc/iters, ../collections_abc/private/templ, ../io_abc, ../mutSeqSliceOp, ../nimpatch/abs, ../nimpatch/nansign, ../nimpatch/newUninit, ../nimpatch/utils, ../nimpatch/winOpenFileHandle, ../noneType, ../private/backendMark, ../private/encoding_norm, ../private/inspect_cleandoc, ../private/iph_utils, ../private/iterGen, ../private/platform_utils, ../private/trans_imp, ../pybool, ../pybytes/bytesbltins, ../pybytes/bytesimpl, ../pyconfig/bootstrap_hash, ../pyconfig/chmods, ../pyconfig/floats, ../pyconfig/have_x_runtime, ../pyconfig/os, ../pyconfig/os_consts, ../pyconfig/pycore/pymath, ../pyconfig/pycore/pymath/short_float_repr, ../pyconfig/resource, ../pyconfig/sched, ../pyconfig/signal, ../pyconfig/stats, ../pyconfig/util, ../pyconfig/ver, ../pyerrors, ../pyerrors/aritherr, ../pyerrors/errno, ../pyerrors/lkuperr, ../pyerrors/oserr, ../pyerrors/oserr/errmap, ../pyerrors/oserr/init, ../pyerrors/oserr/oserror_decl, ../pyerrors/oserr/oserror_new, ../pyerrors/oserr/oserror_str, ../pyerrors/oserr/types, ../pyerrors/rterr, ../pyerrors/signals, ../pyerrors/simperr, ../pyerrors/unicode_err, ../pystring, ../pystring/consts, ../pystring/format, ../pystring/fstring, ../pystring/split/common, ../pystring/split/reimporter, ../pystring/split/rsplit, ../pystring/split/rsplit_whitespace, ../pystring/split/split, ../pystring/split/split_whitespace, ../pystring/split/splitlinesIter, ../pystring/strbltins, ../pystring/strimpl, ../pystring/strip, ../pystring/strmeth, ../pystring/strops, ../pystring/strprefix, ../pystring/translate, ../pysugar/pywith, ../stringlib/errHandle, ../stringlib/format, ../stringlib/formats, ../stringlib/meth, ../stringlib/replaceWithCount, ../stringlib/split/common, ../stringlib/split/reimporter, ../stringlib/split/rsplit_whitespace, ../stringlib/split/split_whitespace, ../stringlib/split/splitlinesIter, ../translateEscape, ../version, ../versionInfo, collections/abc, datetime, datetime_impl/consts, datetime_impl/datetime_impl, datetime_impl/datetime_impl/decl, datetime_impl/datetime_impl/inner_decl, datetime_impl/datetime_impl/meth, datetime_impl/datetime_impl/meth/aszone, datetime_impl/datetime_impl/meth/calendar_utils, datetime_impl/datetime_impl/meth/consts, datetime_impl/datetime_impl/meth/errno_decl, datetime_impl/datetime_impl/meth/format_utcoffset, datetime_impl/datetime_impl/meth/formats, datetime_impl/datetime_impl/meth/fromisoformat, datetime_impl/datetime_impl/meth/getter, datetime_impl/datetime_impl/meth/getter_of_date, datetime_impl/datetime_impl/meth/getter_requires_op, datetime_impl/datetime_impl/meth/hashImpl, datetime_impl/datetime_impl/meth/importer, datetime_impl/datetime_impl/meth/init, datetime_impl/datetime_impl/meth/inner_consts, datetime_impl/datetime_impl/meth/isoformat, datetime_impl/datetime_impl/meth/op, datetime_impl/datetime_impl/meth/platform_utils, datetime_impl/datetime_impl/meth/pytime, datetime_impl/datetime_impl/meth/require_time_module, datetime_impl/datetime_impl/meth/state_consts, datetime_impl/datetime_impl/meth/statics, datetime_impl/datetime_impl/meth/struct_tm_decl, datetime_impl/datetime_impl/meth/struct_tm_helper, datetime_impl/datetime_impl/meth/struct_tm_meth, datetime_impl/datetime_impl/meth/time_t_decl, datetime_impl/datetime_impl/meth/time_utils, datetime_impl/datetime_impl/meth/to_seconds_utils, datetime_impl/datetime_impl/meth/zonename_utils, datetime_impl/delta_chk, datetime_impl/mathutils, datetime_impl/obj_utils, datetime_impl/pyerr, datetime_impl/timedelta_impl, datetime_impl/timedelta_impl/decl, datetime_impl/timedelta_impl/getter, datetime_impl/timedelta_impl/meth, datetime_impl/timezone_impl, datetime_impl/timezone_impl/decl, datetime_impl/timezone_impl/meth_by_datetime, datetime_impl/timezone_impl/meth_by_datetime_getter, datetime_impl/timezone_impl/meth_else, datetime_impl/types, enum_impl/enumType, enum_impl/intEnum, errno, errno_impl/errnoConsts, errno_impl/errnoUtils, errno_impl/private/clike, errno_impl/private/errnos, errno_impl/private/errorcodeInit, errno_impl/private/exportUtils, errno_impl/private/loopErrno, errno_impl/private/singleton_errno, inspect, inspect_impl/isX, inspect_impl/members, inspect_impl/modulename, inspect_impl/sourcegetters, io, math, math_impl/cbrt, math_impl/comptime/cbrt, math_impl/comptime/common, math_impl/comptime/expm1, math_impl/comptime/log1p, math_impl/constsUtils, math_impl/err, math_impl/errnoUtils, math_impl/expm1_log1p, math_impl/frexp, math_impl/gammaXRange, math_impl/inWordUtils/assertIsLittleEndian, math_impl/inWordUtils/consts, math_impl/inWordUtils/float_view, math_impl/inWordUtils/fromWords, math_impl/inWordUtils/indices, math_impl/inWordUtils/toWords, math_impl/isX, math_impl/ldexp, math_impl/nextafter_step, math_impl/nextafter_ulp, math_impl/patch/consts, math_impl/patch/fma, math_impl/patch/gamma, math_impl/patch/inWordUtilsMapper, math_impl/patch/ldexp_frexp/assertIsInfinite, math_impl/patch/ldexp_frexp/exponent, math_impl/patch/ldexp_frexp/frexp, math_impl/patch/ldexp_frexp/ldexp, math_impl/patch/ldexp_frexp/normalize, math_impl/patch/lgamma, math_impl/patch/nextafter, math_impl/patch/nextafter_step, math_impl/patch/sinpi, math_impl/patch/trunc, math_impl/platformUtils, math_impl/polevl, math_impl/vec_op, math_impl/vec_op/dist, math_impl/vec_op/niter_types, math_impl/vec_op/private/dl_ops, math_impl/vec_op/sumprod, n_bisect, n_datetime, n_errno, n_inspect, n_itertools, n_math, n_os, n_pathlib, n_random, n_shutil, n_signal, n_stat, n_string, n_sys, n_time, ncodec, os, os_impl/common, os_impl/consts, os_impl/cpus, os_impl/have_functions, os_impl/inheritable, os_impl/listcommon, os_impl/listdirx, os_impl/path, os_impl/posix_like, os_impl/posix_like/chkarg, os_impl/posix_like/chmods, os_impl/posix_like/errnoRaise, os_impl/posix_like/errnoUtils, os_impl/posix_like/fdopen, os_impl/posix_like/get_id, os_impl/posix_like/isatty, os_impl/posix_like/links, os_impl/posix_like/lseek, os_impl/posix_like/mkrmdir, os_impl/posix_like/mkrmdirImpl, os_impl/posix_like/open_close, os_impl/posix_like/pyCfg, os_impl/posix_like/rename, os_impl/posix_like/scandirImpl, os_impl/posix_like/sched, os_impl/posix_like/seek_consts, os_impl/posix_like/stat, os_impl/posix_like/truncate, os_impl/posix_like/umaskImpl, os_impl/posix_like/unameImpl, os_impl/posix_like/unlink, os_impl/posix_like/unlinkImpl, os_impl/posix_like/utime, os_impl/private/defined_macros, os_impl/private/iph_utils, os_impl/private/platform_utils, os_impl/randoms, os_impl/subp, os_impl/term, os_impl/touch, os_impl/util/handle_signal, os_impl/utils, os_impl/waits, os_impl/walkImpl, pathlib, pathlib_impl/init, pathlib_impl/meth, pathlib_impl/os_meth, pathlib_impl/segments, pathlib_impl/types, private/platformInfo, private/platformUtils, random, random_impl/gstate, random_impl/justLessThanOneConst, random_impl/macroutils, random_impl/proc_dispatched, random_impl/proc_others, random_impl/types, resource, resource_impl/consts, resource_impl/csyms, resource_impl/funcs, resource_impl/types, shutil, shutil_impl/copys, shutil_impl/rmtreeImpl, shutil_impl/sys, shutil_impl/terminals, signal, signal_impl/abc_set, signal_impl/c_api, signal_impl/c_py_handler_cvt, signal_impl/chk_util, signal_impl/enums, signal_impl/enums_decl, signal_impl/errutil, signal_impl/frames, signal_impl/pyatomic, signal_impl/pylifecycle, signal_impl/pynsig, signal_impl/siginfo_decl, signal_impl/signal_util, signal_impl/signals, signal_impl/sigsetCvt, signal_impl/sigset_to_set, signal_impl/state, signal_impl/unixs, signal_impl/valid_signals_impl, stat, stat_impl/consts, stat_impl/defines, stat_impl/isX, stat_impl/isXImpl, stat_impl/strrepr, stat_impl/types, string, string_impl/capwordsImpl, string_impl/consts, string_impl/n_chainmap, string_impl/substituteImpl, string_impl/templateImpl, string_impl/template_decl, sys, sys_impl/auditImpl, sys_impl/auditImpl/cfg, sys_impl/auditImpl/main, sys_impl/auditImpl/types, sys_impl/exits, sys_impl/fenvs, sys_impl/flagsImpl, sys_impl/flagsImpl/ct, sys_impl/flagsImpl/values, sys_impl/genargs, sys_impl/geninfos, sys_impl/genplatform, sys_impl/getencodings, sys_impl/sizes, sys_impl/stdio, sys_impl/util, time, time_impl/asctimeImpl, time_impl/converters, time_impl/measures, time_impl/nstrfptime, time_impl/private/doc_utils, time_impl/private/macro_utils, time_impl/sleep_impl, time_impl/strfptime, time_impl/struct_time_funcs, time_impl/types, types, typing_impl/optional_obj, typing_impl/str_optional_obj, warnings.

API symbols

+
`$`:
+
`%`:
+
`&=`:
+
`&`:
+
`*=`:
+
`*`:
+
`+=`:
+
`+`:
+
`-=`:
+
`-`:
+
`.`:
+
`//`:
+
`/=`:
+
`/`:
+
`<%`:
+
`<=%`:
+
`<=`:
+
`<>`:
+
`<`:
+
`==`:
+
`>=`:
+
`@=`:
+
`@`:
+
`[]=`:
+
`[]`:
+
`^`:
+
`and`:
+
`discard`:
+
`is`:
+
`not`:
+
`or`:
+
`xor`:
+
`|=`:
+
`|`:
+
abs:
+
absolute:
+
abspath:
+
accessHighLow:
+
AC_CHECK_FUNC:
+
AC_CHECK_FUNCS:
+
AC_CHECK_HEADER:
+
AC_CHECK_HEADERS:
+
AC_CHECK_HEADER_THEN_FUNCS:
+
accumulate:
+
AC_LINK_IFELSE:
+
aclose:
+
ac_md_release:
+
acos:
+
acosh:
+
AC_RUN_IFELSE:
+
add:
+
add_alias:
+
addaudithook:
+
addEachIter:
+
addFields:
+
add_format_utcoffset:
+
addLoopEach:
+
add_member:
+
addPatch:
+
addResDecl:
+
add_sigset:
+
addYield:
+
alarm:
+
ALIGNOF_SIZE_T:
+
all:
+
allAlpha:
+
allocWcharArr:
+
allTrue:
+
altsep:
+
ANDROID_API:
+
anext:
+
any:
+
append:
+
APPLE:
+
argument_unavailable_error:
+
argv:
+
ArithmeticError:
+
ascii:
+
ASCII_CHAR_MASK:
+
ascii_letters:
+
ascii_lowercase:
+
ascii_uppercase:
+
asctime:
+
asctimeImpl:
+
asDuration:
+
asgSeqToObj:
+
asHashSet:
+
asin:
+
asinh:
+
asNimDatetime:
+
as_posix:
+
asSeq:
+
asTimeval:
+
astimezone:
+
asVersion:
+
AsyncGenerator:
+
AsyncIterable:
+
AsyncIterator:
+
atan:
+
atan2:
+
atanh:
+
AT_REMOVEDIR:
+
AT_SYMLINK_NOFOLLOW:
+
AttributeError:
+
audit:
+
await:
+
Awaitable:
+
AX_C_FLOAT_WORDS_BIGENDIAN:
+
AX_C_FLOAT_WORDS_BIGENDIAN_def:
+
basename:
+
BeforeFixedVer:
+
betavariate:
+
BIAS:
+
bin:
+
binomialvariate:
+
BinOp:
+
binOpAdd:
+
bisect:
+
bisect_left:
+
bisect_right:
+
BlockingIOError:
+
bodySetItem:
+
bool:
+
BrokenPipeError:
+
BufferedIOBase:
+
BufferedRandom:
+
BufferedReader:
+
BufferedWriter:
+
byteLen:
+
byteorder:
+
bytes:
+
bytes_warning:
+
CanIOOpenT:
+
capitalize:
+
capwords:
+
casefold:
+
cbrt:
+
c_defined:
+
ceil:
+
center:
+
c_fma:
+
c_getenv:
+
ChainMap:
+
chars:
+
chdir:
+
checked_resource:
+
check_force_ascii:
+
check_func_runtime:
+
checkLenientOps:
+
ChildProcessError:
+
chkOneDay:
+
chkSigRng:
+
chmod:
+
choice:
+
choices:
+
chr:
+
c_ldexp:
+
cleandoc:
+
clear:
+
CLEAR_EXP_MASK:
+
CLike:
+
clikeOr:
+
close:
+
closeImpl:
+
closerange:
+
ClosureIter:
+
cmpOnField:
+
CmpStragy:
+
Collection:
+
comb:
+
combinations:
+
CompileBackend:
+
compileLittleEndian:
+
config_should_audit:
+
ConnectionAbortedError:
+
ConnectionError:
+
ConnectionRefusedError:
+
ConnectionResetError:
+
CONST_EPOCH:
+
Container:
+
contains:
+
copy:
+
copyfile:
+
copyfileobj:
+
copyright:
+
copysign:
+
Coroutine:
+
cos:
+
cosh:
+
count:
+
cpu_count:
+
c_raise:
+
csEq:
+
c_setlocale:
+
CSigHandler:
+
c_signal:
+
csLhs:
+
csRhs:
+
csShorter:
+
ctime:
+
cTmToNormCall:
+
curdir:
+
cwd:
+
datetime:
+
datetime_fromisoformat:
+
day:
+
days:
+
days_before_month:
+
daysImpl:
+
deallocWcArr:
+
debug:
+
decl_c_int:
+
declErrorcodeWith:
+
DeclIntEnumMeth:
+
declTupleWithNFieldsFrom:
+
DECODE_ERROR:
+
DEFAULT_BUFFER_SIZE:
+
DEFAULT_DIR_FD:
+
default_int_handler:
+
default_oserror:
+
DefaultTimeFormat:
+
DefEncoding:
+
DefErrors:
+
DefNewLine:
+
defpath:
+
DEF_SIG:
+
DefSplitCap:
+
degrees:
+
Delimiter:
+
delimiter:
+
delitem:
+
DeprecationWarning:
+
dev_mode:
+
devnull:
+
dict:
+
difference:
+
difference_update:
+
digits:
+
DirEntry:
+
dir_fdandfdinvalid:
+
dir_fdandfollow_symlinksinvalid:
+
dirname:
+
dist:
+
dist_checkedSameLen:
+
divide:
+
divide_round_up:
+
divmod:
+
dl_mul:
+
dl_sum:
+
docTable:
+
DocTable:
+
dont_write_bytecode:
+
DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754:
+
DOUBLE_IS_BIG_ENDIAN_IEEE754:
+
DOUBLE_IS_LITTLE_ENDIAN_IEEE754:
+
DoubleLength:
+
dst:
+
dtToStructTime:
+
dunder_stderr:
+
dunder_stdin:
+
dunder_stdout:
+
DW:
+
DWin:
+
e:
+
E2BIG:
+
EACCES:
+
EADDRINUSE:
+
EADDRNOTAVAIL:
+
EADV:
+
EAFNOSUPPORT:
+
EAGAIN:
+
EALREADY:
+
EBADE:
+
EBADF:
+
EBADFD:
+
EBADMSG:
+
EBADR:
+
EBADRQC:
+
EBADSLT:
+
EBFONT:
+
EBUSY:
+
ECANCELED:
+
ECHILD:
+
ECHRNG:
+
ECOMM:
+
ECONNABORTED:
+
ECONNREFUSED:
+
ECONNRESET:
+
EDEADLK:
+
EDEADLOCK:
+
EDESTADDRREQ:
+
EDOM:
+
EDOTDOT:
+
EDQUOT:
+
EEXIST:
+
EFAULT:
+
EFBIG:
+
EHOSTDOWN:
+
EHOSTUNREACH:
+
EIDRM:
+
EILSEQ:
+
EINPROGRESS:
+
EINTR:
+
EINVAL:
+
EIO:
+
EISCONN:
+
EISDIR:
+
EISNAM:
+
EKEYEXPIRED:
+
EKEYREJECTED:
+
EKEYREVOKED:
+
EL2HLT:
+
EL2NSYNC:
+
EL3HLT:
+
EL3RST:
+
ELIBACC:
+
ELIBBAD:
+
ELIBEXEC:
+
ELIBMAX:
+
ELIBSCN:
+
ELNRNG:
+
ELOOP:
+
EMEDIUMTYPE:
+
EMFILE:
+
EMLINK:
+
emptyn:
+
emptyPyDict:
+
EMSGSIZE:
+
EMULTIHOP:
+
ENAMETOOLONG:
+
ENAVAIL:
+
EncErrors:
+
encoding:
+
encodings.normalize_encoding:
+
endsWith:
+
ENETDOWN:
+
ENETRESET:
+
ENETUNREACH:
+
ENFILE:
+
ENOANO:
+
ENOBUFS:
+
ENOCSI:
+
ENODATA:
+
ENODEV:
+
ENOENT:
+
ENOEXEC:
+
ENOKEY:
+
ENOLCK:
+
ENOLINK:
+
ENOMEDIUM:
+
ENOMEM:
+
ENOMSG:
+
ENONET:
+
ENOPKG:
+
ENOPROTOOPT:
+
ENOSPC:
+
ENOSR:
+
ENOSTR:
+
ENOSYS:
+
ENOTBLK:
+
ENOTCONN:
+
ENOTDIR:
+
ENOTEMPTY:
+
ENOTNAM:
+
ENOTRECOVERABLE:
+
ENOTSOCK:
+
ENOTSUP:
+
ENOTTY:
+
ENOTUNIQ:
+
enter:
+
enumerate:
+
ENXIO:
+
EOPNOTSUPP:
+
EOVERFLOW:
+
EOWNERDEAD:
+
EPERM:
+
EPFNOSUPPORT:
+
EPIPE:
+
epoch:
+
EPROTO:
+
EPROTONOSUPPORT:
+
EPROTOTYPE:
+
ERANGE:
+
EREMCHG:
+
EREMOTE:
+
EREMOTEIO:
+
ERESTART:
+
erf:
+
erfc:
+
ERFKILL:
+
EROFS:
+
errno:
+
Errno:
+
errno:
+
ErrnoCount:
+
errnomap:
+
errnoMsg:
+
errors:
+
ESHUTDOWN:
+
ESOCKTNOSUPPORT:
+
ESPIPE:
+
ESRCH:
+
ESRMNT:
+
ESTALE:
+
ESTRPIPE:
+
ETIME:
+
ETIMEDOUT:
+
ETOOMANYREFS:
+
ETXTBSY:
+
EUCLEAN:
+
EULER:
+
EUNATCH:
+
EUSERS:
+
EWOULDBLOCK:
+
excl:
+
EXDEV:
+
executable:
+
EXFULL:
+
exit:
+
exp:
+
expandtabs:
+
expandtabsImpl:
+
expm1:
+
EXP_MASK:
+
exponent:
+
expOptObjCvt:
+
exportAllErrnosViaEnumOrImportc:
+
exportSincePy:
+
expovariate:
+
extend:
+
extsep:
+
f:
+
fabs:
+
factorial:
+
False:
+
fchmod:
+
fdandfollow_symlinksinvalid:
+
fdopen:
+
fdopendir:
+
fetchDoc:
+
FI:
+
fields:
+
FileExistsError:
+
FileIO:
+
filemode:
+
fileno:
+
FileNotFoundError:
+
fill_siginfo:
+
fill_valid_signals:
+
filter:
+
find:
+
find1:
+
FixedVer:
+
flags:
+
float_info:
+
float_repr_style:
+
floor:
+
flush:
+
flush_hash:
+
fma:
+
fmod:
+
fold:
+
follow_symlinks_specified:
+
force_ascii:
+
forErrno:
+
format:
+
format_utcoffset:
+
formatValue:
+
fr:
+
Fr:
+
freeZoneCStr:
+
frexp:
+
from_c_int:
+
from_c_int_expr:
+
from_c_int_underlined:
+
fromisocalendar:
+
fromisoformat:
+
fromIterable:
+
fromordinal:
+
fromSecondsObject:
+
fromtimestamp:
+
fromutc:
+
fromWords:
+
frozenset:
+
fspath:
+
fstat:
+
fsum:
+
ftruncate:
+
gamma:
+
GammaError:
+
gammavariate:
+
gcd:
+
geDom:
+
geGotNegInf:
+
genArgs:
+
genCapwords:
+
genDelItem:
+
genDollarRepr:
+
Generator:
+
GeneratorExit:
+
genFlagsObj:
+
genGbl:
+
genGbls:
+
genGenericSetItem:
+
gen_getmembers_static:
+
genInfos:
+
GenIntEnumMeth:
+
genIter:
+
genNonGenericSetItem:
+
genPlatform:
+
GenPyEnumInit:
+
GenPyEnumMeth:
+
genrand_uint32:
+
genSubstitute:
+
genUname:
+
genWithArg:
+
genWithBracket:
+
geOk:
+
geOverFlow:
+
get:
+
getatime:
+
getChar:
+
getCharPtr:
+
getctime:
+
getcwd:
+
getcwdb:
+
getdefaultencoding:
+
getdoc:
+
getdocNoDedentImpl:
+
getErrno:
+
getfile:
+
getfilesystemencoding:
+
GET_FLOAT_WORD:
+
getFrameOrNil:
+
get_handle_inheritable:
+
get_handler:
+
GetIdent:
+
get_identifiers:
+
getIdentifiers:
+
get_identifiersMayDup:
+
get_inheritable:
+
getitimer:
+
getline:
+
getLowWord:
+
getMaxChar:
+
getmembers:
+
getmembersImpl:
+
GetMembersPredict:
+
getmembers_static:
+
GetMembersType:
+
GetMemberType:
+
getmodulename:
+
getmodulenameImpl:
+
getmstate:
+
getmtime:
+
getOrDefault:
+
getpagesize:
+
getpid:
+
getPlatform:
+
getppid:
+
getPtr:
+
getrandbits:
+
getrandom:
+
getrlimit:
+
getrusage:
+
getsignal:
+
getsize:
+
getsizeof:
+
getsource:
+
getsourcefile:
+
getsourcelines:
+
getsourcelinesImpl:
+
getstate:
+
get_terminal_size:
+
geUnderFlow:
+
geZeroCantDetSign:
+
gmtime:
+
gmtime_r:
+
gRand:
+
gRandom:
+
guass:
+
handle:
+
Handlers:
+
hardlink_to:
+
hasBug:
+
hasChar:
+
hash:
+
hashcode:
+
hashcode=:
+
hash_randomization:
+
HAVEalarm:
+
HAVE_BROKEN_PTHREAD_SIGMASK:
+
HAVEchmod:
+
HAVEfchmod:
+
HAVEfchmodat:
+
HAVEfchmodatRUNTIME:
+
HAVEfdopendir:
+
HAVEfdopendirRUNTIME:
+
HAVEfstatat:
+
HAVEfstatatRUNTIME:
+
HAVE_FTRUNCATE:
+
HAVE_GCC_ASM_FOR_MC68881:
+
HAVE_GCC_ASM_FOR_X87:
+
HAVEgetitimer:
+
HAVE_GETPAGESIZE:
+
have_getrandom:
+
have_getrandom_syscall:
+
HAVE_LCHMOD:
+
HAVElstat:
+
HAVE_MBRTOWC:
+
HAVE_OPENAT:
+
HAVEpause:
+
HAVE_PRLIMIT:
+
HAVEpthread_kill:
+
HAVEpthread_sigmask:
+
HAVE_PY_SET_53BIT_PRECISION:
+
HAVE_sched_h:
+
HAVE_sched_setaffinity:
+
HAVEsetitimer:
+
HAVEsigaction:
+
HAVEsigfillset:
+
HAVEsiginterrupt:
+
HAVEsigpending:
+
HAVE_SIGSET_T:
+
HAVEsigtimedwait:
+
HAVEsigwait:
+
HAVEsigwaitinfo:
+
HAVEstrsignal:
+
HAVE_STRUCT_TM_TM_ZONE:
+
HAVE_SYSCONF_PAGE_SIZE:
+
HAVEuname:
+
HAVEunlinkat:
+
HAVEunlinkatRUNTIME:
+
have_valid_signals:
+
hex:
+
hexdigits:
+
hexversion:
+
HIGH:
+
HighWordFracBits:
+
home:
+
HookEntry:
+
HookProc:
+
hour:
+
hugeF:
+
hypot:
+
iadd:
+
ib_b:
+
ib_e:
+
ib_i:
+
ifInvalidOnVcc:
+
ignore_environment:
+
impExp:
+
impJsOrC:
+
implementation:
+
importConfig:
+
inc:
+
incl:
+
INCOMPLETE_CHARACTER:
+
index:
+
index1:
+
indices:
+
inf:
+
init:
+
init32FloatView:
+
init64FloatView:
+
initBufAsPy:
+
initChainMap:
+
initDocTable:
+
initErrorcodeMap:
+
initIgnoreExcHandle:
+
initNCodecInfo:
+
initPySignal:
+
initRaisesExcHandle:
+
initStructTime:
+
initSubsCfg:
+
initTm:
+
initVal_with_handle_signal:
+
InJs:
+
inMicroseconds:
+
insert:
+
insort:
+
insort_left:
+
insort_right:
+
inspect:
+
inspect.cleandoc:
+
int_AsMode_t:
+
interactive:
+
InterruptedError:
+
intersection:
+
intersection_update:
+
int_max_str_digits:
+
IOBase:
+
iPosCeil:
+
isabs:
+
is_absolute:
+
IsADirectoryError:
+
isalnum:
+
isalpha:
+
isascii:
+
isatty:
+
isawaitable:
+
isbuiltin:
+
isclass:
+
isclose:
+
IS_CONTINUATION_BYTE:
+
iscoroutine:
+
iscoroutinefunction:
+
isdigit:
+
isdir:
+
is_dir:
+
isdisjoint:
+
isErr:
+
isErr0:
+
isfile:
+
is_file:
+
isfinite:
+
isfold:
+
isframe:
+
isfunction:
+
isinf:
+
isInfinite:
+
is_junction:
+
islink:
+
isLittleEndian:
+
islower:
+
ismethod:
+
ismodule:
+
isNone:
+
isocalendar:
+
isoformat:
+
IsoFormatTimespec:
+
isolated:
+
iso_to_ymd:
+
iso_week1_monday:
+
isoweekday:
+
isqrt:
+
isqrtPositive:
+
is_relative_to:
+
isSome:
+
ISSPACE:
+
isspace:
+
IsSpaceAt:
+
issubset:
+
issuperset:
+
is_symlink:
+
isTimeDeltaNone:
+
istitle:
+
istitleImpl:
+
istraceback:
+
isTzNone:
+
isupper:
+
isUtcZone:
+
is_valid:
+
isValid:
+
is_valid:
+
is_valid_wide_char:
+
items:
+
iter:
+
Iterable:
+
Iterator:
+
iterdir:
+
ItimerError:
+
ITIMER_PROF:
+
ITIMER_REAL:
+
ItimerVal:
+
ITIMER_VIRTUAL:
+
join:
+
joinpath:
+
JsBigInt64Option:
+
justLessThanOne:
+
Key:
+
KeyboardInterrupt:
+
keys:
+
LC_ALL:
+
LC_CTYPE:
+
lcm:
+
ldexp:
+
len:
+
lgamma:
+
linesep:
+
link:
+
list:
+
listdir:
+
ljust:
+
ln2_hi:
+
ln2_lo:
+
local:
+
LocaleEncoding:
+
localtime:
+
localtime_r:
+
local_to_seconds:
+
log:
+
log10:
+
log1p:
+
log2:
+
lognormalvariate:
+
long:
+
LookupError:
+
LOW:
+
lower:
+
lseek:
+
lstat:
+
lstrip:
+
Major:
+
makedirs:
+
makeIterable:
+
maketrans:
+
MantissaDigits:
+
map:
+
mapIterBodyImpl:
+
mapPathLike:
+
Mapping:
+
mapRaiseGammaErr:
+
markcoroutinefunction:
+
math_is_error:
+
max:
+
MAX_EXPONENT:
+
max_fold_seconds:
+
MAX_GAMMA_X:
+
maxSafeInteger:
+
maxsize:
+
MAX_STIRLING:
+
MAX_SUBNORMAL_EXPONENT:
+
MAX_UNICODE_val:
+
MaxWStrLen:
+
MAXYEAR:
+
mayZeroDefault:
+
mbstate_t:
+
microsecond:
+
microseconds:
+
microsecondsImpl:
+
min:
+
MIN_GAMMA_X:
+
Minor:
+
MIN_SUBNORMAL_EXPONENT:
+
minute:
+
MINYEAR:
+
mitems:
+
mixinOrderOnFields:
+
mkdir:
+
mkdirParentsExistsOk:
+
mktime:
+
modf:
+
monotonic:
+
monotonic_ns:
+
monotonicRaw:
+
month:
+
msg:
+
MS_TO_NS:
+
MS_TO_US:
+
MS_WINDOWS:
+
ms_windows:
+
MutableSequence:
+
name:
+
NameError:
+
nan:
+
NCodecInfo:
+
nestListWithFirst:
+
newBlockingIOError:
+
newDatetime:
+
newLoop:
+
newNoEncTextIO:
+
newNullaryLambdaIter:
+
newOptionalObj:
+
newPyDict:
+
newPyDictImpl:
+
newPyFrozenSet:
+
newPyIterator:
+
newPyList:
+
newPyListOfCap:
+
newPyListOfStr:
+
newPyOSError:
+
newPySet:
+
newPyTimezone:
+
newStopIteration:
+
newStrOptionalObj:
+
newTimedelta:
+
newTuple:
+
newUnicodeDecodeError:
+
newZoneCStr:
+
next:
+
nextafter:
+
nextImpl:
+
n_frexp:
+
nimArrayAsList:
+
NimSigHandler:
+
NimVersionTuple:
+
Ninf:
+
n_ldexp:
+
noBackend:
+
noBackends:
+
noEmptySep:
+
NoEncTextIOBase:
+
NoEncTextIOWrapper:
+
noInitVarDecl:
+
noJsBackend:
+
None:
+
noneToTzInfo:
+
NoneType:
+
noNimsBackend:
+
normalize:
+
normalvariate:
+
norm_maxsplit:
+
normpath:
+
no_site:
+
NotADirectoryError:
+
NotImplDirectives:
+
NotImplementedError:
+
notImplErr:
+
no_user_site:
+
now:
+
noWeirdBackend:
+
noWeirdTarget:
+
nPyTime_gmtime:
+
nPyTime_localtime:
+
nPyTime_ObjectToTimeval:
+
NSIG:
+
NS_TO_100NS:
+
NS_TO_MS:
+
NS_TO_US:
+
NsUnit:
+
nTime_gmtime:
+
nTime_localtime:
+
O_APPEND:
+
O_ASYNC:
+
O_CLOEXEC:
+
O_CREAT:
+
oct:
+
octdigits:
+
O_DIRECT:
+
O_DIRECTORY:
+
O_DSYNC:
+
O_EXCL:
+
offset:
+
O_NDELAY:
+
OnErrorCb:
+
O_NOATIME:
+
O_NOCTTY:
+
O_NOFOLLOW:
+
O_NONBLOCK:
+
O_PATH:
+
open:
+
openarray_Check:
+
OpenarrayOrNimIter:
+
optimize:
+
OptionalObj:
+
ord:
+
ord1:
+
orderOnFields:
+
O_RDONLY:
+
ord_to_ymd:
+
O_RDWR:
+
orig_argv:
+
O_RSYNC:
+
OSErrorArgs:
+
osErrorMsgWithPath:
+
OSError_new:
+
oserror_use_init:
+
O_SYNC:
+
o_threshold:
+
O_TMPFILE:
+
O_TRUNC:
+
O_WRONLY:
+
p1evl:
+
pairs:
+
pardir:
+
parent:
+
parents:
+
paretovariate:
+
partition:
+
parts:
+
Patch:
+
Path:
+
pathanddir_fdinvalid:
+
PathLike:
+
pathrepr:
+
pathsep:
+
pause:
+
perf_counter:
+
perf_counter_ns:
+
perm:
+
PermissionError:
+
pi:
+
pidfd_send_signal:
+
Pinf:
+
platform:
+
platform.system:
+
platform.version:
+
platformAvail:
+
platformAvailWhen:
+
platformNoJs:
+
platformUnavail:
+
polevl:
+
polExpd:
+
polExpd0:
+
pop:
+
popitem:
+
pow:
+
prCeiling:
+
PreBreakCb:
+
preferredGenIterResName:
+
PREPARE_CAP:
+
prepareROErrno:
+
prepareRWErrno:
+
prFLoor:
+
prHalfEven:
+
printable:
+
prlimit:
+
process_cpu_count:
+
ProcessLookupError:
+
process_time:
+
prod:
+
prRoundUp:
+
prTimeout:
+
pthread_kill:
+
pthread_sigmask:
+
ptrdiff_t:
+
punctuation:
+
pyasciiImpl:
+
Py_atomic_load:
+
Py_atomic_load_ptr:
+
Py_atomic_store:
+
Py_atomic_store_ptr:
+
PyBool:
+
pybool:
+
PyBytes:
+
pybytes:
+
PyDatetime:
+
PyDeadline_Get:
+
PyDeadline_Init:
+
Py_DecodeLocaleEx:
+
Py_DecodeUTF8Ex:
+
PyDict:
+
PyDictItemView:
+
PyDictKeyView:
+
PyDictValueView:
+
PyDictView:
+
pydiscard:
+
PyErr_CheckSignals:
+
PyErr_CheckSignalsAndRaises:
+
Py_ERROR_BACKSLASHREPLACE:
+
Py_error_handler:
+
Py_ERROR_IGNORE:
+
Py_ERROR_OTHER:
+
Py_ERROR_REPLACE:
+
Py_ERROR_STRICT:
+
Py_ERROR_SURROGATEESCAPE:
+
Py_ERROR_SURROGATEPASS:
+
Py_ERROR_UNKNOWN:
+
Py_ERROR_XMLCHARREFREPLACE:
+
Py_FORCE_UTF8_FS_ENCODING:
+
Py_FORCE_UTF8_LOCALE:
+
pyformat:
+
pyformatImplAux:
+
PyFrozenSet:
+
Py_fstat:
+
Py_fstat_noraise:
+
Py_GetErrorHandler:
+
Py_GetForceASCII:
+
Py_GetLocaleEncoding:
+
py_getrandom:
+
Py_IS_ALIGNED:
+
PyIterator:
+
PyList:
+
PyMajor:
+
py_math_isclose_impl:
+
Py_mbrtowc:
+
Py_mbstowcs:
+
PyMinor:
+
Py_normalize_encoding:
+
Py_NSIG:
+
PyOSError:
+
PyOS_getsig:
+
PyOS_setsig:
+
PyPatch:
+
PYPTHREAD_SIGMASK:
+
PyRandom:
+
PyRandomState:
+
PyRange:
+
PyReleaseLevel:
+
PyReleaseLevelEnum:
+
pyrepr:
+
pyreprbImpl:
+
pyreprImpl:
+
Py_ResetForceASCII:
+
py_rlimit:
+
PySerial:
+
pyset:
+
PySet:
+
Py_SET_53BIT_PRECISION_END:
+
Py_SET_53BIT_PRECISION_HEADER:
+
Py_SET_53BIT_PRECISION_START:
+
Py_set_inheritable:
+
pysetLit:
+
Py_SetLocaleFromEnv:
+
PySigHandler:
+
PySignal_Fini:
+
pysince:
+
PySlice:
+
PySlice1:
+
PyStr:
+
PySys_AddAuditHook:
+
PySys_Audit:
+
PyTime:
+
PyTime_round_t:
+
PY_TIME_T_MAX:
+
PY_TIME_T_MIN:
+
Py_UCS1:
+
Py_UCS2:
+
Py_UCS4:
+
PyUnicode_DecodeLocale:
+
Py_UNICODE_IS_SURROGATE:
+
quiet:
+
radians:
+
raiseDomainErr:
+
raiseErrno:
+
raiseErrnoT:
+
raiseErrnoWithPath:
+
raiseExcWithPath:
+
raiseExcWithPath2:
+
raiseRangeErr:
+
raise_signal:
+
raiseZipBound:
+
randbelow:
+
randbytes:
+
randint:
+
random:
+
Random:
+
randrange:
+
range:
+
rangeLen:
+
rawCreateDir:
+
RawIOBase:
+
rawRemoveDir:
+
read:
+
read_bytes:
+
readline:
+
readlink:
+
read_nstring:
+
read_text:
+
redefineFlags:
+
relative_to:
+
ReleaseLevel:
+
relpath:
+
remainder:
+
remove:
+
removedirs:
+
removeprefix:
+
removesuffix:
+
rename:
+
replace:
+
repr:
+
resetSubsCfg:
+
resolution:
+
reverse:
+
reversed:
+
rf:
+
Rf:
+
rfind:
+
rfind1:
+
rGamma:
+
rindex:
+
rindex1:
+
rjust:
+
rLgamma:
+
RLIM_INFINITY:
+
RLIMIT_AS:
+
RLIMIT_CORE:
+
RLIMIT_CPU:
+
RLIMIT_DATA:
+
RLIMIT_FSIZE:
+
RLIMIT_MEMLOCK:
+
RLIMIT_MSGQUEUE:
+
RLIMIT_NICE:
+
RLIMIT_NOFILE:
+
RLIMIT_NPROC:
+
RLIMIT_OFILE:
+
RLIMIT_RSS:
+
RLIMIT_RTPRIO:
+
RLIMIT_RTTIME:
+
RLIMIT_SIGPENDING:
+
RLIMIT_STACK:
+
rmdir:
+
rmtree:
+
round:
+
round_half_even:
+
rounds:
+
rpartition:
+
rsplit:
+
rsplit_whitespace:
+
rstrip:
+
runeAtPos:
+
runeLenAt:
+
runes:
+
RuntimeError:
+
RuntimeWarning:
+
RUSAGE_BOTH:
+
RUSAGE_CHILDREN:
+
RUSAGE_SELF:
+
RUSAGE_THREAD:
+
safe_path:
+
safe_substitute:
+
samefile:
+
SameFileError:
+
samestat:
+
sample:
+
scandir:
+
scandirIter:
+
scipyGammaLn:
+
second:
+
seconds:
+
secondsImpl:
+
SEC_TO_MS:
+
SEC_TO_NS:
+
SEC_TO_US:
+
seed:
+
seek:
+
SEEK_CUR:
+
SEEK_DATA:
+
SEEK_END:
+
SEEK_HOLE:
+
SEEK_SET:
+
sep:
+
Sequence:
+
Serial:
+
set:
+
Set:
+
setdefault:
+
setenvOverwrite:
+
setErrno:
+
setErrno0:
+
setErrnoRaw:
+
SET_EXP_MASK:
+
set_handle_inheritable:
+
set_handler:
+
setHighWord:
+
set_inheritable:
+
set_inheritableImpl:
+
setitimer:
+
setLen:
+
setlocale:
+
setrlimit:
+
setstate:
+
set_wakeup_signal:
+
shallIgnore:
+
shuffle:
+
shuffleImpl:
+
si_band:
+
si_code:
+
si_errno:
+
S_IFMT:
+
SIGABRT:
+
sigaction:
+
SIGALRM:
+
SIG_BLOCK:
+
SIGBUS:
+
SIGCHLD:
+
SIGCLD:
+
SIGCONT:
+
SIG_DFL:
+
SIGEMT:
+
SIGFPE:
+
SIGHUP:
+
SIG_IGN:
+
SIGILL:
+
SIGINT:
+
siginterrupt:
+
SIGIO:
+
SIGIOT:
+
SIGKILL:
+
Sigmasks:
+
signal:
+
signal_global_state:
+
Signals:
+
signal_state_t:
+
sigpending:
+
SIGPIPE:
+
SIGPOLL:
+
SIGPROF:
+
SIGPWR:
+
SIGQUIT:
+
SIGRTMAX:
+
SIGRTMIN:
+
SIGSEGV:
+
SIG_SETMASK:
+
sigset_to_set:
+
SIGSTKFLT:
+
SIGSTOP:
+
SIGSYS:
+
SIGTERM:
+
sigtimedwait:
+
SIGTRAP:
+
SIGTSTP:
+
SIGTTIN:
+
SIGTTOU:
+
SIG_UNBLOCK:
+
SIGURG:
+
SIGUSR1:
+
SIGUSR2:
+
SIGVTALRM:
+
sigwait:
+
sigwaitinfo:
+
SIGWINCH:
+
SIGXCPU:
+
SIGXFSZ:
+
S_IMODE:
+
S_IMODE_val:
+
sin:
+
sinh:
+
sinpi:
+
si_pid:
+
S_ISBLK:
+
S_ISCHR:
+
S_ISDIR:
+
S_ISDOOR:
+
S_ISFIFO:
+
si_signo:
+
S_ISLNK:
+
S_ISPORT:
+
S_ISREG:
+
S_ISSOCK:
+
si_status:
+
S_ISWHT:
+
si_uid:
+
size:
+
Sized:
+
SIZEOF_RLIMIT_T:
+
SIZEOF_TIME_T:
+
sleep:
+
slice:
+
SomePyDictView:
+
SomePySet:
+
SomeSet:
+
SomeSinglePyDictView:
+
Some_struct_time:
+
Some_struct_time_tuple:
+
sort:
+
sorted:
+
split:
+
splitdrive:
+
splitext:
+
splitlines:
+
split_whitespace:
+
sqrt:
+
SQRT_TWO_PI:
+
startsWith:
+
stat:
+
statAttr:
+
staticErrno:
+
st_atime:
+
st_atime_ns:
+
stat_result:
+
st_ctime:
+
st_ctime_ns:
+
stderr:
+
stdin:
+
stdlibJsGamma:
+
stdlibJsLgamma:
+
stdout:
+
stem:
+
st_mtime:
+
st_mtime_ns:
+
StopAsyncIteration:
+
StopIteration:
+
StopIterationT:
+
str:
+
strerror:
+
strftime:
+
STRINGLIB_MUTABLE:
+
StringLike:
+
strip:
+
strIterImpl:
+
strptime:
+
strsignal:
+
StrTypedTranslateTable:
+
struct_rusage:
+
struct_siginfo:
+
struct_time:
+
structTimeToDt:
+
struct_time_tuple:
+
struct_time_tuple10:
+
struct_time_tuple11:
+
struct_tm:
+
Subs:
+
SubsCfg:
+
substitute:
+
substituteAux:
+
substr:
+
suf--:
+
suffix:
+
suffixes:
+
sumprod:
+
supports_dir_fd:
+
supports_effective_ids:
+
supports_fd:
+
supports_follow_symlinks:
+
symlink:
+
symlink_to:
+
symmetric_difference:
+
syscall:
+
SYS_getrandom:
+
SYS_STAT_H:
+
system:
+
SystemExit:
+
tan:
+
tanh:
+
tau:
+
tell:
+
Template:
+
templWrapExportSincePy:
+
terminal_size:
+
TextIOWrapper:
+
time:
+
timedelta:
+
TimeDeltaNone:
+
time_ns:
+
TimeNsPair:
+
TimeoutError:
+
TimePair:
+
Timestamp:
+
timestamp:
+
time_t:
+
time_t_overflow:
+
timetuple:
+
timezone:
+
tinyF:
+
title:
+
Tm:
+
toBool:
+
toCSEEK:
+
toCSighandler:
+
today:
+
toInt:
+
toNimBool:
+
toNimIterator:
+
toNimSlice:
+
toNimStr:
+
toNimString:
+
toNimTable:
+
toNimTimezone:
+
toordinal:
+
toPyDict:
+
toPyEnv:
+
toPyObject:
+
toPySighandler:
+
toPySlice:
+
toPyStr:
+
toSigset:
+
total_seconds:
+
toTup:
+
toTuple:
+
touch:
+
toWords:
+
translate:
+
TranslateAction:
+
translateEscape:
+
translateEscapeWithErr:
+
TranslateTable:
+
TranslateTableABC:
+
TranslateTableVal:
+
TranslateValType:
+
triangular:
+
True:
+
trunc:
+
truncate:
+
tryOsOp:
+
TypedTranslateTableABC:
+
TypeError:
+
tzinfo:
+
tzname:
+
TzNone:
+
tzToNimTimezone:
+
u:
+
ulp:
+
umask:
+
uname:
+
uname_release_major:
+
uname_result:
+
uncheckedTruncToInt:
+
UnicodeDecodeError:
+
UnicodeError:
+
unicodeSpaces:
+
uniform:
+
union:
+
unlink:
+
unlinkat:
+
unlinkImpl:
+
UNRELIABLE_FMA:
+
unsafeGet:
+
unsafeToNone:
+
UnsupportedOperation:
+
update:
+
upper:
+
urandom:
+
UserWarning:
+
UseSmallApprox:
+
US_TO_NS:
+
UTC:
+
utc:
+
utcoffset:
+
utc_timezone:
+
utc_to_seconds:
+
Utf8:
+
utf8_decode:
+
utf8_mode:
+
utime:
+
valid_signals:
+
value:
+
values:
+
verbose:
+
Version:
+
version:
+
version_info:
+
vonmisesvariate:
+
wait:
+
wait3:
+
wait4:
+
waitpid:
+
waitstatus_to_exitcode:
+
walk:
+
WalkRes:
+
walk_symlinks_as_files:
+
warn:
+
warn_default_encoding:
+
Warning:
+
wchar_t:
+
WCONTINUED:
+
WCOREDUMP:
+
weekday:
+
weibullvariate:
+
weirdTarget:
+
weridTarget:
+
WEXITED:
+
WEXITSTATUS:
+
whenAuditEnabled:
+
whenAuditEnabledOr:
+
whenDefErrno:
+
whitespace:
+
WIFCONTINUED:
+
WIFEXITED:
+
WIFSIGNALED:
+
WIFSTOPPED:
+
with:
+
with_name:
+
with_Py_SUPPRESS_IPH:
+
with_suffix:
+
WNOHANG:
+
WNOWAIT:
+
WORDS_BIGENDIAN:
+
WORDS_LITTLEENDIAN:
+
wrapExportSincePy:
+
wrapTuple:
+
write:
+
write_bytes:
+
write_nstring:
+
write_text:
+
WSTOPPED:
+
WSTOPSIG:
+
WTERMSIG:
+
wu_import:
+
WUNTRACED:
+
X87_double_rounding:
+
year:
+
YMD:
+
ymd_to_ord:
+
YWD:
+
ZeroDivisionError:
+
zfill:
+
zip:
+
zipIterBodyImpl:
+
zonename:
+
+ +
+
+ + + diff --git a/Lib/time.html b/Lib/time.html new file mode 100644 index 000000000..cc281abf8 --- /dev/null +++ b/Lib/time.html @@ -0,0 +1,251 @@ + + + + + + + +src/pylib/Lib/time + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/time

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

time

+

Currently the implementation is n_time module . The following is its doc:

+
Warning: +A few of the format directives for strftime/strptime are not supported, and using them causes AssertDefect. They are listed in nstrfptime.NotImplDirectives
+
Hint: +Some directives (only for strftime) whose implementents are platform-depend in CPython are always supported here: '%V' '%G' '%g'
+

+ +
+

Consts

+
+
+
DefaultTimeFormat = "%a %b %d %H:%M:%S %Y"
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
proc asctime(): PyStr {....raises: [], tags: [TimeEffect], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func asctime(t: Some_struct_time): PyStr
+
+ + +

Example:

+
assert asctime(gmtime(0)) == "Thu Jan  1 00:00:00 1970"
+ Source   +Edit   + +
+
+ +
+
+
+
proc ctime(): PyStr {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc ctime(secs: float | int64): PyStr
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc strftime(format: PyStr): PyStr {....raises: [], tags: [TimeEffect],
+                                      forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func strftime(format: PyStr; st: Some_struct_time): PyStr
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc strptime(s: PyStr; format = DefaultTimeFormat): struct_time {.
+    ...raises: [ValueError, TimeParseError, TimeFormatParseError],
+    tags: [TimeEffect], forbids: [].}
+
+ +
Warning: +In current implementation, whitespace in format string means itself AS-IS, unlike C or Python, where any whitespace means a serial of any whitespaces. If really wanting the behavior of C's, consider using std/strscan.
+
Warning: +Current strptime is just locale-unaware, when it comes to "the locale's format", like "%x", it always uses the format of "C" locale, no matter what the locale is. a.k.a. Changing locale via C's api in <locale.h> doesn't affect this function.
+ + Source   +Edit   + +
+
+ +
+ +
+
+ + +
+
+ + +
+
+ + + diff --git a/Lib/time.idx b/Lib/time.idx new file mode 100644 index 000000000..c588b25a9 --- /dev/null +++ b/Lib/time.idx @@ -0,0 +1,12 @@ +nimTitle time time.html module src/pylib/Lib/time 0 +nim DefaultTimeFormat time.html#DefaultTimeFormat const DefaultTimeFormat 17 +nim asctime time.html#asctime proc asctime(): PyStr 19 +nim asctime time.html#asctime,Some_struct_time proc asctime(t: Some_struct_time): PyStr 22 +nim ctime time.html#ctime proc ctime(): PyStr 27 +nim ctime time.html#ctime_2 proc ctime(secs: float | int64): PyStr 28 +nim strftime time.html#strftime,PyStr,Some_struct_time proc strftime(format: PyStr; st: Some_struct_time): PyStr 31 +nim strftime time.html#strftime,PyStr proc strftime(format: PyStr): PyStr 34 +nim strptime time.html#strptime,PyStr proc strptime(s: PyStr; format = DefaultTimeFormat): struct_time 38 +nimgrp strftime time.html#strftime-procs-all proc 31 +nimgrp asctime time.html#asctime-procs-all proc 19 +nimgrp ctime time.html#ctime-procs-all proc 27 diff --git a/Lib/time_impl/asctimeImpl.html b/Lib/time_impl/asctimeImpl.html new file mode 100644 index 000000000..5bf1c0e80 --- /dev/null +++ b/Lib/time_impl/asctimeImpl.html @@ -0,0 +1,140 @@ + + + + + + + +src/pylib/Lib/time_impl/asctimeImpl + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/time_impl/asctimeImpl

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

asctime that returns string

+
+

Procs

+
+
+
+
func asctime(dt: DateTime): string {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template asctimeImpl(result: string; dt: DateTime)
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/time_impl/asctimeImpl.idx b/Lib/time_impl/asctimeImpl.idx new file mode 100644 index 000000000..c4ce50a20 --- /dev/null +++ b/Lib/time_impl/asctimeImpl.idx @@ -0,0 +1,3 @@ +nimTitle asctimeImpl time_impl/asctimeImpl.html module src/pylib/Lib/time_impl/asctimeImpl 0 +nim asctimeImpl time_impl/asctimeImpl.html#asctimeImpl.t,string,DateTime template asctimeImpl(result: string; dt: DateTime) 5 +nim asctime time_impl/asctimeImpl.html#asctime,DateTime proc asctime(dt: DateTime): string 15 diff --git a/Lib/time_impl/converters.html b/Lib/time_impl/converters.html new file mode 100644 index 000000000..8c076e3cc --- /dev/null +++ b/Lib/time_impl/converters.html @@ -0,0 +1,253 @@ + + + + + + + +src/pylib/Lib/time_impl/converters + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/time_impl/converters

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
func dtToStructTime(dt: DateTime; res: var struct_time) {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func struct_time(tup`gensym0: struct_time_tuple): struct_time {....raises: [],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func struct_time(tup`gensym2: struct_time_tuple10): struct_time {....raises: [],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func struct_time(tup`gensym4: struct_time_tuple11): struct_time {....raises: [],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func structTimeToDt(st: struct_time; res: var DateTime) {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Converters

+
+
+
+
converter toTuple(st: struct_time): struct_time_tuple {....raises: [], tags: [],
+    forbids: [].}
+
+ + XXX: tuple is Nim's keyword, so no symbol can be named tuple + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template wrapTuple(sym) {.dirty.}
+
+ + wrap a func sym(struct_time) to accept struct_time_tuple*, too. + Source   +Edit   + +
+
+
+
template wrapTuple(sym, tupType) {.dirty.}
+
+ + wrap a func sym(struct_time) to accept tupType too. + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/time_impl/converters.idx b/Lib/time_impl/converters.idx new file mode 100644 index 000000000..a0370cdd3 --- /dev/null +++ b/Lib/time_impl/converters.idx @@ -0,0 +1,11 @@ +nimTitle converters time_impl/converters.html module src/pylib/Lib/time_impl/converters 0 +nim wrapTuple time_impl/converters.html#wrapTuple.t,, template wrapTuple(sym, tupType) 6 +nim wrapTuple time_impl/converters.html#wrapTuple.t template wrapTuple(sym) 15 +nim struct_time time_impl/converters.html#struct_time,struct_time_tuple proc struct_time(tup`gensym0: struct_time_tuple): struct_time 27 +nim struct_time time_impl/converters.html#struct_time,struct_time_tuple10 proc struct_time(tup`gensym2: struct_time_tuple10): struct_time 28 +nim struct_time time_impl/converters.html#struct_time,struct_time_tuple11 proc struct_time(tup`gensym4: struct_time_tuple11): struct_time 29 +nim toTuple time_impl/converters.html#toTuple.c,struct_time converter toTuple(st: struct_time): struct_time_tuple 31 +nim dtToStructTime time_impl/converters.html#dtToStructTime,DateTime,struct_time proc dtToStructTime(dt: DateTime; res: var struct_time) 45 +nim structTimeToDt time_impl/converters.html#structTimeToDt,struct_time,DateTime proc structTimeToDt(st: struct_time; res: var DateTime) 60 +nimgrp structtime time_impl/converters.html#struct_time-procs-all proc 23 +nimgrp wraptuple time_impl/converters.html#wrapTuple-templates-all template 6 diff --git a/Lib/time_impl/measures.html b/Lib/time_impl/measures.html new file mode 100644 index 000000000..1f24ef5d0 --- /dev/null +++ b/Lib/time_impl/measures.html @@ -0,0 +1,213 @@ + + + + + + + +src/pylib/Lib/time_impl/measures + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/time_impl/measures

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

Hint: +all functions are pretended as noSideEffect pramga, as I myself doesn't think noSideEffect means pure function, but pure function is must noSideEffect, the opposite is not true. However, Nim manual seems to mixin them.
+

+
+

Procs

+
+
+
+
func monotonic(): float {....raises: [], tags: [TimeEffect], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func monotonic_ns(): int64 {....raises: [], tags: [TimeEffect], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func perf_counter(): float {....raises: [], tags: [TimeEffect], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func perf_counter_ns(): int64 {....raises: [], tags: [TimeEffect], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func process_time(): float {....raises: [], tags: [TimeEffect], forbids: [].}
+
+ + not available for JS backend, currently. + Source   +Edit   + +
+
+ +
+
+
+
func time(): float {....raises: [], tags: [TimeEffect], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func time_ns(): int64 {....raises: [], tags: [TimeEffect], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/time_impl/measures.idx b/Lib/time_impl/measures.idx new file mode 100644 index 000000000..931f6ee9a --- /dev/null +++ b/Lib/time_impl/measures.idx @@ -0,0 +1,8 @@ +nimTitle measures time_impl/measures.html module src/pylib/Lib/time_impl/measures 0 +nim time time_impl/measures.html#time proc time(): float 11 +nim time_ns time_impl/measures.html#time_ns proc time_ns(): int64 16 +nim process_time time_impl/measures.html#process_time proc process_time(): float 24 +nim monotonic_ns time_impl/measures.html#monotonic_ns proc monotonic_ns(): int64 29 +nim monotonic time_impl/measures.html#monotonic proc monotonic(): float 36 +nim perf_counter time_impl/measures.html#perf_counter proc perf_counter(): float 45 +nim perf_counter_ns time_impl/measures.html#perf_counter_ns proc perf_counter_ns(): int64 46 diff --git a/Lib/time_impl/nstrfptime.html b/Lib/time_impl/nstrfptime.html new file mode 100644 index 000000000..a8b3d20a9 --- /dev/null +++ b/Lib/time_impl/nstrfptime.html @@ -0,0 +1,215 @@ + + + + + + + +src/pylib/Lib/time_impl/nstrfptime + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/time_impl/nstrfptime

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

strftime, strptime

+

platform independent implementation.

+

+ +
+

Lets

+
+
+
docTable {.compileTime.} = docTableInner
+
+ + + used to transport doc string to outer module. + Source   +Edit   + +
+
+ +
+
+
+

Consts

+
+
+
NotImplDirectives = {'y', 'Z'}
+
+ +

Here are their concrete meanings in Python, as well as some notes about why they cannot be directly mapped to Nim's DateTime.format/parse.

+

The direct alternative value when formatting in Nim, if any, is introduced by <-:

+
  • y: Year without century as a decimal number [00,99]. <- DateTime.format"yy" When parsing, C/Python's %y use 20th or 21th centry depending on the value of %y Nim's yy use the current century
  • +
  • Z: Time zone name (no characters if no time zone exists). Deprecated. However, this is supported in Lib/datetime
  • +
+

Following are strftime only currently:

+
  • j: Day of the year as a decimal number [001,366]. <- DateTime.yearday + 1
  • +
  • u: Weekday [0(Monday), 6]. <- DateTime.weekday.int
  • +
  • w: Weekday [0(Sunday),6]. <- (DateTime.weekday.int + 1) mod 7
  • +
  • U: Week number of the year (Sunday as the first day of the week) as a decimal number [00,53]. All days in a new year preceding the first Sunday are considered to be in week 0.
  • +
+ + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
func strftime(format: string; dt: DateTime): string {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc strptime(dt: var DateTime; s: string; format_with_sp_asis: string) {.
+    ...raises: [ValueError, TimeParseError, TimeFormatParseError],
+    tags: [TimeEffect], forbids: [].}
+
+ +
Warning: +In current implementation, whitespace in format string means itself AS-IS, unlike C or Python, where any whitespace means a serial of any whitespaces. If really wanting the behavior of C's, consider using std/strscan.
+
Warning: +Current strptime is just locale-unaware, when it comes to "the locale's format", like "%x", it always uses the format of "C" locale, no matter what the locale is. a.k.a. Changing locale via C's api in <locale.h> doesn't affect this function.
+ + Source   +Edit   + +
+
+ +
+ +
+
+ + +
+
+ + +
+
+ + + diff --git a/Lib/time_impl/nstrfptime.idx b/Lib/time_impl/nstrfptime.idx new file mode 100644 index 000000000..54ed59ee9 --- /dev/null +++ b/Lib/time_impl/nstrfptime.idx @@ -0,0 +1,5 @@ +nimTitle nstrfptime time_impl/nstrfptime.html module src/pylib/Lib/time_impl/nstrfptime 0 +nim docTable time_impl/nstrfptime.html#docTable let docTable 22 +nim NotImplDirectives time_impl/nstrfptime.html#NotImplDirectives const NotImplDirectives 30 +nim strftime time_impl/nstrfptime.html#strftime,string,DateTime proc strftime(format: string; dt: DateTime): string 144 +nim strptime time_impl/nstrfptime.html#strptime,DateTime,string,string proc strptime(dt: var DateTime; s: string; format_with_sp_asis: string) 192 diff --git a/Lib/time_impl/private/doc_utils.html b/Lib/time_impl/private/doc_utils.html new file mode 100644 index 000000000..540043c57 --- /dev/null +++ b/Lib/time_impl/private/doc_utils.html @@ -0,0 +1,179 @@ + + + + + + + +src/pylib/Lib/time_impl/private/doc_utils + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/time_impl/private/doc_utils

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Types

+
+
+
DocTable = object
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
func initDocTable(moduleDoc: string; init: openArray[(string, string)]): DocTable {.
+    compileTime, ...raises: [], tags: [], forbids: [].}
+
+ +
Hint: +key "" stands for the module level doc.
+ + Source   +Edit   + +
+
+ +
+ +
+
+
+

Macros

+
+
+
+
macro fetchDoc(tab: static DocTable)
+
+ + used for fetch module level doc + Source   +Edit   + +
+
+
+
macro fetchDoc(tab: static DocTable; def)
+
+ + used as proc's pragma to fetch doc + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/time_impl/private/doc_utils.idx b/Lib/time_impl/private/doc_utils.idx new file mode 100644 index 000000000..a0dfde78b --- /dev/null +++ b/Lib/time_impl/private/doc_utils.idx @@ -0,0 +1,6 @@ +nimTitle doc_utils time_impl/private/doc_utils.html module src/pylib/Lib/time_impl/private/doc_utils 0 +nim DocTable time_impl/private/doc_utils.html#DocTable object DocTable 4 +nim initDocTable time_impl/private/doc_utils.html#initDocTable,string,openArray[] proc initDocTable(moduleDoc: string; init: openArray[(string, string)]): DocTable 11 +nim fetchDoc time_impl/private/doc_utils.html#fetchDoc.m,staticDocTable macro fetchDoc(tab: static DocTable) 26 +nim fetchDoc time_impl/private/doc_utils.html#fetchDoc.m,staticDocTable, macro fetchDoc(tab: static DocTable; def) 31 +nimgrp fetchdoc time_impl/private/doc_utils.html#fetchDoc-macros-all macro 26 diff --git a/Lib/time_impl/private/macro_utils.html b/Lib/time_impl/private/macro_utils.html new file mode 100644 index 000000000..c87cffdd3 --- /dev/null +++ b/Lib/time_impl/private/macro_utils.html @@ -0,0 +1,235 @@ + + + + + + + +src/pylib/Lib/time_impl/private/macro_utils + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/time_impl/private/macro_utils

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Types

+
+
+
CmpStragy = enum
+  csEq, csLhs, csRhs, csShorter ## stop on the shorter one.
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Macros

+
+
+
+
macro addFields(res: string; obj: typed; noMoreThan: static[int] = int.high)
+
+ +

obj is of object or ref object. when obj is of object and noMoreThan is not given, it's roughly equal to:

+

let startLen = res.len
+for k, v in o.fieldPairs:
+  res.addSep(sep=", ", startLen = startLen)
+  res.add k & '=' & repr v

+ + Source   +Edit   + +
+
+ +
+
+
+
macro asgSeqToObj(tup, obj: typed)
+
+ + obj can be of ref object or object Retionale: there is fields/fieldPairs iterator in std/system, but for tuple/object only, not for ref object. + Source   +Edit   + +
+
+ +
+
+
+
macro cmpOnField(a, b: typed): int
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
macro declTupleWithNFieldsFrom(name: untyped; Cls: typedesc; n: static[int];
+                               exported: static[bool] = true)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
macro mixinOrderOnFields(lhs, rhs: typed; cmpOp;
+                         cmpStragy: static[CmpStragy] = csEq): bool
+
+ +

cmpOnFields but a b can be of different types.

+

e.g. a is tuple and b is object; or a, b are different objects.

+ + Source   +Edit   + +
+
+ +
+
+
+
macro orderOnFields[T](a, b: T; cmpOp): bool
+
+ +

mainly for checking if ref objects are equal on fields

+

when for object/tuple and cmpOp is ==, roughly equal to: a == b

+

but system.== for ref just compare the address.

+ + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/time_impl/private/macro_utils.idx b/Lib/time_impl/private/macro_utils.idx new file mode 100644 index 000000000..073868c5a --- /dev/null +++ b/Lib/time_impl/private/macro_utils.idx @@ -0,0 +1,12 @@ +nimTitle macro_utils time_impl/private/macro_utils.html module src/pylib/Lib/time_impl/private/macro_utils 0 +nim asgSeqToObj time_impl/private/macro_utils.html#asgSeqToObj.m,typed,typed macro asgSeqToObj(tup, obj: typed) 71 +nim declTupleWithNFieldsFrom time_impl/private/macro_utils.html#declTupleWithNFieldsFrom.m,untyped,typedesc,static[int],static[bool] macro declTupleWithNFieldsFrom(name: untyped; Cls: typedesc; n: static[int];\n exported: static[bool] = true) 117 +nim addFields time_impl/private/macro_utils.html#addFields.m,string,typed,static[int] macro addFields(res: string; obj: typed; noMoreThan: static[int] = int.high) 137 +nim csEq time_impl/private/macro_utils.html#csEq CmpStragy.csEq 170 +nim csLhs time_impl/private/macro_utils.html#csLhs CmpStragy.csLhs 170 +nim csRhs time_impl/private/macro_utils.html#csRhs CmpStragy.csRhs 170 +nim csShorter time_impl/private/macro_utils.html#csShorter CmpStragy.csShorter 170 +nim CmpStragy time_impl/private/macro_utils.html#CmpStragy enum CmpStragy 170 +nim mixinOrderOnFields time_impl/private/macro_utils.html#mixinOrderOnFields.m,typed,typed,,static[CmpStragy] macro mixinOrderOnFields(lhs, rhs: typed; cmpOp; cmpStragy: static[CmpStragy] = csEq): bool 206 +nim orderOnFields time_impl/private/macro_utils.html#orderOnFields.m,T,T, macro orderOnFields[T](a, b: T; cmpOp): bool 215 +nim cmpOnField time_impl/private/macro_utils.html#cmpOnField.m,typed,typed macro cmpOnField(a, b: typed): int 257 diff --git a/Lib/time_impl/sleep_impl.html b/Lib/time_impl/sleep_impl.html new file mode 100644 index 000000000..b04de81e8 --- /dev/null +++ b/Lib/time_impl/sleep_impl.html @@ -0,0 +1,118 @@ + + + + + + + +src/pylib/Lib/time_impl/sleep_impl + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/time_impl/sleep_impl

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Templates

+
+
+
+
template sleep(s: int | float)
+
+ + raises ValueError if s < 0 + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/time_impl/sleep_impl.idx b/Lib/time_impl/sleep_impl.idx new file mode 100644 index 000000000..36bf4dad7 --- /dev/null +++ b/Lib/time_impl/sleep_impl.idx @@ -0,0 +1,2 @@ +nimTitle sleep_impl time_impl/sleep_impl.html module src/pylib/Lib/time_impl/sleep_impl 0 +nim sleep time_impl/sleep_impl.html#sleep.t template sleep(s: int | float) 28 diff --git a/Lib/time_impl/strfptime.html b/Lib/time_impl/strfptime.html new file mode 100644 index 000000000..9b34c0b47 --- /dev/null +++ b/Lib/time_impl/strfptime.html @@ -0,0 +1,177 @@ + + + + + + + +src/pylib/Lib/time_impl/strfptime + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/time_impl/strfptime

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

Warning: +A few of the format directives for strftime/strptime are not supported, and using them causes AssertDefect. They are listed in nstrfptime.NotImplDirectives
+
Hint: +Some directives (only for strftime) whose implementents are platform-depend in CPython are always supported here: '%V' '%G' '%g'
+

+ +
+

Procs

+
+
+
+
func strftime(format: string; st: Some_struct_time_tuple): string
+
+ + + Source   +Edit   + +
+
+
+
func strftime(format: string; st: struct_time): string {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func strftime[S](format: S; st: struct_time): S
+
+ + EXT. + Source   +Edit   + +
+
+ +
+
+
+
proc strptime(s: string; f: string): struct_time {.
+    ...raises: [ValueError, TimeParseError, TimeFormatParseError],
+    tags: [TimeEffect], forbids: [].}
+
+ +
Warning: +In current implementation, whitespace in format string means itself AS-IS, unlike C or Python, where any whitespace means a serial of any whitespaces. If really wanting the behavior of C's, consider using std/strscan.
+
Warning: +Current strptime is just locale-unaware, when it comes to "the locale's format", like "%x", it always uses the format of "C" locale, no matter what the locale is. a.k.a. Changing locale via C's api in <locale.h> doesn't affect this function.
+ + Source   +Edit   + +
+
+ +
+ +
+
+ + +
+
+ + +
+
+ + + diff --git a/Lib/time_impl/strfptime.idx b/Lib/time_impl/strfptime.idx new file mode 100644 index 000000000..535089a1d --- /dev/null +++ b/Lib/time_impl/strfptime.idx @@ -0,0 +1,6 @@ +nimTitle strfptime time_impl/strfptime.html module src/pylib/Lib/time_impl/strfptime 0 +nim strftime time_impl/strfptime.html#strftime,string,struct_time proc strftime(format: string; st: struct_time): string 7 +nim strftime time_impl/strfptime.html#strftime,S,struct_time proc strftime[S](format: S; st: struct_time): S 12 +nim strftime time_impl/strfptime.html#strftime,string,Some_struct_time_tuple proc strftime(format: string; st: Some_struct_time_tuple): string 17 +nim strptime time_impl/strfptime.html#strptime,string,string proc strptime(s: string; f: string): struct_time 20 +nimgrp strftime time_impl/strfptime.html#strftime-procs-all proc 7 diff --git a/Lib/time_impl/struct_time_funcs.html b/Lib/time_impl/struct_time_funcs.html new file mode 100644 index 000000000..0be71289c --- /dev/null +++ b/Lib/time_impl/struct_time_funcs.html @@ -0,0 +1,216 @@ + + + + + + + +src/pylib/Lib/time_impl/struct_time_funcs + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/time_impl/struct_time_funcs

+
+ +
+ Source   +Edit   + +
+ +

funcs about struct_time

+

its initializer, and a inverse function mktime

+

+ +
+

Procs

+
+
+
+
proc gmtime(): struct_time {....raises: [], tags: [TimeEffect], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc gmtime(secs: float): struct_time {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc gmtime(secs: int64): struct_time {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc localtime(): struct_time {....raises: [], tags: [TimeEffect], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc localtime(secs: float): struct_time {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc localtime(secs: int64): struct_time {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func mktime(t: struct_time): float {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func mktime(tup: struct_time_tuple): typeof(mktime do:
+  bind struct_time
+  struct_time(tm_year: 1900, tm_mon: 1, tm_mday: 1, tm_yday: 1, tm_isdst: -1)) {.
+    ...raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/time_impl/struct_time_funcs.idx b/Lib/time_impl/struct_time_funcs.idx new file mode 100644 index 000000000..ff7d0d002 --- /dev/null +++ b/Lib/time_impl/struct_time_funcs.idx @@ -0,0 +1,12 @@ +nimTitle struct_time_funcs time_impl/struct_time_funcs.html module src/pylib/Lib/time_impl/struct_time_funcs 0 +nim gmtime time_impl/struct_time_funcs.html#gmtime proc gmtime(): struct_time 8 +nim localtime time_impl/struct_time_funcs.html#localtime proc localtime(): struct_time 9 +nim gmtime time_impl/struct_time_funcs.html#gmtime,int64 proc gmtime(secs: int64): struct_time 11 +nim localtime time_impl/struct_time_funcs.html#localtime,int64 proc localtime(secs: int64): struct_time 16 +nim gmtime time_impl/struct_time_funcs.html#gmtime,float proc gmtime(secs: float): struct_time 21 +nim localtime time_impl/struct_time_funcs.html#localtime,float proc localtime(secs: float): struct_time 26 +nim mktime time_impl/struct_time_funcs.html#mktime,struct_time proc mktime(t: struct_time): float 32 +nim mktime time_impl/struct_time_funcs.html#mktime,struct_time_tuple proc mktime(tup: struct_time_tuple): typeof(mktime do:\n bind struct_time\n struct_time(tm_year: 1900, tm_mon: 1, tm_mday: 1, tm_yday: 1, tm_isdst: -1)) 37 +nimgrp localtime time_impl/struct_time_funcs.html#localtime-procs-all proc 9 +nimgrp mktime time_impl/struct_time_funcs.html#mktime-procs-all proc 32 +nimgrp gmtime time_impl/struct_time_funcs.html#gmtime-procs-all proc 8 diff --git a/Lib/time_impl/types.html b/Lib/time_impl/types.html new file mode 100644 index 000000000..4f03c880f --- /dev/null +++ b/Lib/time_impl/types.html @@ -0,0 +1,497 @@ + + + + + + + +src/pylib/Lib/time_impl/types + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/time_impl/types

+
+ +
+ Source   +Edit   + +
+ +

+ +
+

Types

+
+ + +
+
struct_time = ref object
+  tm_year*: int
+  tm_mon*: range[1 .. 12]
+  tm_mday*: MonthdayRange
+  tm_hour*: HourRange
+  tm_min*: MinuteRange
+  tm_sec*: range[0 .. 61]
+  tm_wday*: range[0 .. 6]
+  tm_yday*: range[1 .. 366]
+  tm_isdst*: int
+  tm_zone*: string           ## .. warning:: curently is only "LOCAL" or "Etc/UTC"
+  tm_gmtoff*: int
+
+ + + Source   +Edit   + +
+
+
+
struct_time_tuple = tuple[tm_year: int, tm_mon: range[1 .. 12],
+                          tm_mday: range[1 .. 31], tm_hour: range[0 .. 23],
+                          tm_min: range[0 .. 59], tm_sec: range[0 .. 61],
+                          tm_wday: range[0 .. 6], tm_yday: range[1 .. 366],
+                          tm_isdst: int]
+
+ + + Source   +Edit   + +
+
+
+
struct_time_tuple10 = tuple[tm_year: int, tm_mon: range[1 .. 12],
+                            tm_mday: range[1 .. 31], tm_hour: range[0 .. 23],
+                            tm_min: range[0 .. 59], tm_sec: range[0 .. 61],
+                            tm_wday: range[0 .. 6], tm_yday: range[1 .. 366],
+                            tm_isdst: int, tm_zone: string]
+
+ + + Source   +Edit   + +
+
+
+
struct_time_tuple11 = tuple[tm_year: int, tm_mon: range[1 .. 12],
+                            tm_mday: range[1 .. 31], tm_hour: range[0 .. 23],
+                            tm_min: range[0 .. 59], tm_sec: range[0 .. 61],
+                            tm_wday: range[0 .. 6], tm_yday: range[1 .. 366],
+                            tm_isdst: int, tm_zone: string, tm_gmtoff: int]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
func `<`(a, b: struct_time): bool {....raises: [], tags: [], forbids: [].}
+
+ + compares based on fields. + Source   +Edit   + +
+
+
+
func `<`(a: struct_time; b: struct_time_tuple11): bool {....raises: [], tags: [],
+    forbids: [].}
+
+ + compares based on fields. + Source   +Edit   + +
+
+
+
func `<`(a: struct_time_tuple11; b: struct_time): bool {....raises: [], tags: [],
+    forbids: [].}
+
+ + compares based on fields. + Source   +Edit   + +
+
+
+
func `<`(st: struct_time; t: tuple): bool
+
+ + + Source   +Edit   + +
+
+
+
func `<`(t: tuple; st: struct_time): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func `<=`(a, b: struct_time): bool {....raises: [], tags: [], forbids: [].}
+
+ + compares based on fields. + Source   +Edit   + +
+
+
+
func `<=`(a: struct_time; b: struct_time_tuple11): bool {....raises: [], tags: [],
+    forbids: [].}
+
+ + compares based on fields. + Source   +Edit   + +
+
+
+
func `<=`(a: struct_time_tuple11; b: struct_time): bool {....raises: [], tags: [],
+    forbids: [].}
+
+ + compares based on fields. + Source   +Edit   + +
+
+
+
func `<=`(st: struct_time; t: tuple): bool
+
+ + + Source   +Edit   + +
+
+
+
func `<=`(t: tuple; st: struct_time): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func `==`(a, b: struct_time): bool {....raises: [], tags: [], forbids: [].}
+
+ + compares based on fields. + Source   +Edit   + +
+
+
+
func `==`(a: struct_time; b: struct_time_tuple11): bool {....raises: [], tags: [],
+    forbids: [].}
+
+ + compares based on fields. + Source   +Edit   + +
+
+
+
func `==`(a: struct_time_tuple11; b: struct_time): bool {....raises: [], tags: [],
+    forbids: [].}
+
+ + compares based on fields. + Source   +Edit   + +
+
+
+
func `==`(st: struct_time; t: tuple): bool {.inline.}
+
+ + + Source   +Edit   + +
+
+
+
func `==`(t: tuple; st: struct_time): bool {.inline.}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func repr(st: struct_time): string {....raises: [], tags: [], forbids: [].}
+
+ +

struct_time.__repr__

+

returns string starting with "time.struct_time" with 9 fields.

+ + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template initStructTime(): struct_time
+
+ + + Source   +Edit   + +
+
+
+
template initStructTime(year, mon, mday, hour, min, sec, wday, yday, isdst,
+                        zone, gmtoff): struct_time
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template isUtcZone(st: struct_time): bool
+
+ + zone is only local or utc + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/time_impl/types.idx b/Lib/time_impl/types.idx new file mode 100644 index 000000000..28125a927 --- /dev/null +++ b/Lib/time_impl/types.idx @@ -0,0 +1,30 @@ +nimTitle types time_impl/types.html module src/pylib/Lib/time_impl/types 0 +nim struct_time time_impl/types.html#struct_time type struct_time 6 +nim struct_time_tuple time_impl/types.html#struct_time_tuple tuple struct_time_tuple 6 +nim struct_time_tuple10 time_impl/types.html#struct_time_tuple10 tuple struct_time_tuple10 6 +nim struct_time_tuple11 time_impl/types.html#struct_time_tuple11 tuple struct_time_tuple11 6 +nim Some_struct_time_tuple time_impl/types.html#Some_struct_time_tuple type Some_struct_time_tuple 26 +nim Some_struct_time time_impl/types.html#Some_struct_time type Some_struct_time 27 +nim isUtcZone time_impl/types.html#isUtcZone.t,struct_time template isUtcZone(st: struct_time): bool 29 +nim initStructTime time_impl/types.html#initStructTime.t template initStructTime(): struct_time 33 +nim initStructTime time_impl/types.html#initStructTime.t,,,,,,,,,,, template initStructTime(year, mon, mday, hour, min, sec, wday, yday, isdst, zone, gmtoff): struct_time 41 +nim repr time_impl/types.html#repr,struct_time proc repr(st: struct_time): string 69 +nim `==` time_impl/types.html#==,struct_time,struct_time proc `==`(a, b: struct_time): bool 84 +nim `==` time_impl/types.html#==,struct_time,struct_time_tuple11 proc `==`(a: struct_time; b: struct_time_tuple11): bool 87 +nim `==` time_impl/types.html#==,struct_time_tuple11,struct_time proc `==`(a: struct_time_tuple11; b: struct_time): bool 94 +nim `<=` time_impl/types.html#<=,struct_time,struct_time proc `<=`(a, b: struct_time): bool 84 +nim `<=` time_impl/types.html#<=,struct_time,struct_time_tuple11 proc `<=`(a: struct_time; b: struct_time_tuple11): bool 87 +nim `<=` time_impl/types.html#<=,struct_time_tuple11,struct_time proc `<=`(a: struct_time_tuple11; b: struct_time): bool 95 +nim `<` time_impl/types.html#<,struct_time,struct_time proc `<`(a, b: struct_time): bool 84 +nim `<` time_impl/types.html#<,struct_time,struct_time_tuple11 proc `<`(a: struct_time; b: struct_time_tuple11): bool 87 +nim `<` time_impl/types.html#<,struct_time_tuple11,struct_time proc `<`(a: struct_time_tuple11; b: struct_time): bool 96 +nim `==` time_impl/types.html#==,, proc `==`(st: struct_time; t: tuple): bool 100 +nim `==` time_impl/types.html#==,,_2 proc `==`(t: tuple; st: struct_time): bool 101 +nim `<` time_impl/types.html#<,, proc `<`(st: struct_time; t: tuple): bool 107 +nim `<` time_impl/types.html#<,,_2 proc `<`(t: tuple; st: struct_time): bool 110 +nim `<=` time_impl/types.html#<=,, proc `<=`(st: struct_time; t: tuple): bool 107 +nim `<=` time_impl/types.html#<=,,_2 proc `<=`(t: tuple; st: struct_time): bool 111 +nimgrp == time_impl/types.html#==-procs-all proc 94 +nimgrp <= time_impl/types.html#<=-procs-all proc 95 +nimgrp < time_impl/types.html#<-procs-all proc 96 +nimgrp initstructtime time_impl/types.html#initStructTime-templates-all template 33 diff --git a/Lib/timeit.html b/Lib/timeit.html new file mode 100644 index 000000000..c825fa2d3 --- /dev/null +++ b/Lib/timeit.html @@ -0,0 +1,262 @@ + + + + + + + +src/pylib/Lib/timeit + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/timeit

+
+ +
+ Source   +Edit   + +
+ +

+ +
+

Vars

+
+
+
default_timer = pysince(3.3, perf_counter, default_timer)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Consts

+
+
+
default_repeat = 5
+
+ + + since python 3.7: default value of repeat parameter is changed from 3 to 5. + Source   +Edit   + +
+
+
+
TimeItUseTime {.booldefine: "timeit.usetime".} = true
+
+ + +disable this if don't wanna depending on Lib/time + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+ + +
+
+
+

Templates

+
+
+
+
template autorange(self: Timer; callable = None): (int, float)
+
+ +
Admonition: +since Python 3.6
+ + Source   +Edit   + +
+
+ +
+
+
+
template repeat(self: Timer; repeat = pysince(3.7, 5, 3);
+                number = default_number): PyList[float]
+
+ + + Source   +Edit   + +
+
+
+
template repeat(stmt: TimeitParam = NullStmt; setup: TimeitParam = NullStmt;
+                timer = default_timer; repeat = pysince(3.7, 5, 3);
+                number = default_number): PyList[float]
+
+ + +

Example:

+
assert len(repeat(repeat=0)) == 0
+ Source   +Edit   + +
+
+ +
+ +
+
+ + +
+
+ + +
+
+ + + diff --git a/Lib/types.html b/Lib/types.html new file mode 100644 index 000000000..05b214309 --- /dev/null +++ b/Lib/types.html @@ -0,0 +1,96 @@ + + + + + + + +src/pylib/Lib/types + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/types

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Exports

+
+ NoneType +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/types.idx b/Lib/types.idx new file mode 100644 index 000000000..1505c3246 --- /dev/null +++ b/Lib/types.idx @@ -0,0 +1 @@ +nimTitle types types.html module src/pylib/Lib/types 0 diff --git a/Lib/typing_impl/optional_obj.html b/Lib/typing_impl/optional_obj.html new file mode 100644 index 000000000..c25df7d8b --- /dev/null +++ b/Lib/typing_impl/optional_obj.html @@ -0,0 +1,301 @@ + + + + + + + +src/pylib/Lib/typing_impl/optional_obj + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/typing_impl/optional_obj

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Types

+
+
+
OptionalObj[T] = distinct Option[T]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
proc `==`(self: OptionalObj; _: NoneType): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc `is`(self: OptionalObj; _: NoneType): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc isNone[T](self: OptionalObj[T]): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc isSome[T](self: OptionalObj[T]): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc newOptionalObj[T](): OptionalObj[T]
+
+ + + Source   +Edit   + +
+
+
+
proc newOptionalObj[T](x: T): OptionalObj[T]
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Converters

+
+
+
+
converter unsafeGet[T](self: OptionalObj[T]): T
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
converter unsafeToNone[T](self: OptionalObj[T]): NoneType
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template expOptObjCvt()
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/typing_impl/optional_obj.idx b/Lib/typing_impl/optional_obj.idx new file mode 100644 index 000000000..ac850522f --- /dev/null +++ b/Lib/typing_impl/optional_obj.idx @@ -0,0 +1,12 @@ +nimTitle optional_obj typing_impl/optional_obj.html module src/pylib/Lib/typing_impl/optional_obj 0 +nim OptionalObj typing_impl/optional_obj.html#OptionalObj type OptionalObj 4 +nim isSome typing_impl/optional_obj.html#isSome,OptionalObj[T] proc isSome[T](self: OptionalObj[T]): bool 9 +nim isNone typing_impl/optional_obj.html#isNone,OptionalObj[T] proc isNone[T](self: OptionalObj[T]): bool 10 +nim `is` typing_impl/optional_obj.html#is,,NoneType proc `is`(self: OptionalObj; _: NoneType): bool 12 +nim `==` typing_impl/optional_obj.html#==,,NoneType proc `==`(self: OptionalObj; _: NoneType): bool 13 +nim unsafeGet typing_impl/optional_obj.html#unsafeGet.c,OptionalObj[T] converter unsafeGet[T](self: OptionalObj[T]): T 15 +nim unsafeToNone typing_impl/optional_obj.html#unsafeToNone.c,OptionalObj[T] converter unsafeToNone[T](self: OptionalObj[T]): NoneType 20 +nim newOptionalObj typing_impl/optional_obj.html#newOptionalObj,T proc newOptionalObj[T](x: T): OptionalObj[T] 23 +nim newOptionalObj typing_impl/optional_obj.html#newOptionalObj proc newOptionalObj[T](): OptionalObj[T] 24 +nim expOptObjCvt typing_impl/optional_obj.html#expOptObjCvt.t template expOptObjCvt() 26 +nimgrp newoptionalobj typing_impl/optional_obj.html#newOptionalObj-procs-all proc 23 diff --git a/Lib/typing_impl/str_optional_obj.html b/Lib/typing_impl/str_optional_obj.html new file mode 100644 index 000000000..37a7b53a9 --- /dev/null +++ b/Lib/typing_impl/str_optional_obj.html @@ -0,0 +1,128 @@ + + + + + + + +src/pylib/Lib/typing_impl/str_optional_obj + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/typing_impl/str_optional_obj

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
proc newStrOptionalObj(x: string): OptionalObj[PyStr] {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ + +
+
+ + +
+
+ + + diff --git a/Lib/typing_impl/str_optional_obj.idx b/Lib/typing_impl/str_optional_obj.idx new file mode 100644 index 000000000..87ecd2cfe --- /dev/null +++ b/Lib/typing_impl/str_optional_obj.idx @@ -0,0 +1,2 @@ +nimTitle str_optional_obj typing_impl/str_optional_obj.html module src/pylib/Lib/typing_impl/str_optional_obj 0 +nim newStrOptionalObj typing_impl/str_optional_obj.html#newStrOptionalObj,string proc newStrOptionalObj(x: string): OptionalObj[PyStr] 7 diff --git a/Lib/unittest.html b/Lib/unittest.html new file mode 100644 index 000000000..c564322ee --- /dev/null +++ b/Lib/unittest.html @@ -0,0 +1,96 @@ + + + + + + + +src/pylib/Lib/unittest + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/unittest

+ + + +
+
+ + + diff --git a/Lib/warnings.html b/Lib/warnings.html new file mode 100644 index 000000000..4818950ff --- /dev/null +++ b/Lib/warnings.html @@ -0,0 +1,136 @@ + + + + + + + +src/pylib/Lib/warnings + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/warnings

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Types

+
+
+
Warning = enum
+  UserWarning, DeprecationWarning, RuntimeWarning
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Templates

+
+
+
+
template warn(message: string; category: Warning = UserWarning; stacklevel = 1)
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/Lib/warnings.idx b/Lib/warnings.idx new file mode 100644 index 000000000..f0e30b977 --- /dev/null +++ b/Lib/warnings.idx @@ -0,0 +1,6 @@ +nimTitle warnings warnings.html module src/pylib/Lib/warnings 0 +nim UserWarning warnings.html#UserWarning Warning.UserWarning 4 +nim DeprecationWarning warnings.html#DeprecationWarning Warning.DeprecationWarning 4 +nim RuntimeWarning warnings.html#RuntimeWarning Warning.RuntimeWarning 4 +nim Warning warnings.html#Warning enum Warning 4 +nim warn warnings.html#warn.t,string,Warning,int template warn(message: string; category: Warning = UserWarning; stacklevel = 1) 11 diff --git a/README.md b/README.md deleted file mode 100644 index 950bc3fde..000000000 --- a/README.md +++ /dev/null @@ -1,525 +0,0 @@ -# NimPylib - -[![C Test](https://github.com/nimpylib/pylib/workflows/testC/badge.svg)](https://github.com/nimpylib/pylib/actions/workflows/testC.yml) -[![JS Test](https://github.com/nimpylib/pylib/workflows/testJs/badge.svg)](https://github.com/nimpylib/pylib/actions/workflows/testJs.yml) -[![Docs](https://github.com/nimpylib/pylib/workflows/docs/badge.svg)](https://github.com/nimpylib/pylib/actions/workflows/docs.yml) -![](https://img.shields.io/github/languages/code-size/nimpylib/pylib?style=flat) -[![Commits](https://img.shields.io/github/last-commit/nimpylib/pylib?style=flat)](https://github.com/nimpylib/pylib/commits/) - - -> Write Python in Nim - -Nimpylib is a collection of Python-like operators/functions and libraries as well as syntax sugars. - - ---- - -[Read Docs](https://nimpylib.github.io/pylib/) -| -[Lib Docs][] -| -[Wiki about History](https://github.com/nimpylib/pylib/wiki/History) -| -[Design Wiki](https://github.com/nimpylib/pylib/wiki/Design) - -[Lib Docs]: https://nimpylib.github.io/pylib/Lib - -## Why NimPyLib? -It helps you to: -- use much Python-like out-of-box API in Nim: - - with no need of any Python dependency (neither dynamic library nor binary). - - even handy for ones who don't use much Python but want more functions in Nim -- translate your Python program to Nim: - - gaining a right-away speed boot of even 700x - - no worry about binary distribution or packaging, just "compile once, distribute everywhere" - - rid of many annoying runtime-errors (which are turned to compile-time error) -- gain a better view into different behaviors between Python and Nim: - - `dynamically-typed` vs `statically-typed` - - unconvertible syntax from Python to Nim, e.g. - [`end` keyword](./doc/mustRewriteExtern/endKeyword.md), - [`not in` syntax](./doc/mustRewriteExtern/not-in.md) - -### Backends - -Thanks to Nim supporting multiply backends, pylib currently officially supports -to compile to C and JavaScript [^JS]. C++ and ObjC backends are currently not tested. - -[^JS]: Some of features (listed - [here](./tests/skipJs.txt)) - and Libs (listed - [here](./src/pylib/Lib/test/skipJs.txt)) -is not available for JS backend yet. - -## Demo - -```nim -import pylib -from pylib/Lib/timeit import timeit -from pylib/Lib/time import sleep -from pylib/Lib/sys import nil # like python's `import sys` -from pylib/Lib/platform import nil # like python's `import platform` -import pylib/Lib/tempfile -# like python's `import tempfile; from tempfile import *` -# more python-stdlib in pylib/Lib/... - -print 42 # print can be used with and without parenthesis too, like Python2. - -# NOTE: from now on, the following is just valid Python3 code! -# only add the following to make it Python: -# import platform -# from timeit import timeit -# from time import sleep -# from tempfile import NamedTemporaryFile, TemporaryDirectory -print( f"{9.0} Hello {42} World {1 + 2}" ) # Python-like string interpolation - -class O: - @staticmethod - def f(): - print("O.f") - -O.f() - -def show_range_list(): - python_like_range = range(0, -10, -2) - print(list(python_like_range)[1:-1]) # [-2, -4, -6] -show_range_list() - -# Why using so many `def`s? -# as in `def`, you can write Nim more Python-like -# e.g. nondeclared assignment - -# func definition -# typing is suppported and optional -def foo(a: int, b = 1, *args) -> int: - def add(a, b): return a + b # nesting - for i in args: print(i) - return add(a, b) - -def show_literals(): - ls = [1, 2] # if outside `def`, `ls` will be an Nim's `array`, - # which is fixed size and "pass by value" - ls_shallow = ls - ls.append(3) - assert len(ls_shallow) == 3 - - s = {"Rachel", "Zack"} # if outside `def`, `s` will be an Nim's `set`, - # which only supports small ordinal type as elements - s.add("Zack") - assert len(s) == 2 - - d = { # if outside `def`, `d` will be an Nim's `array[I, (K, V)]`, - # which even lacks `__getitem__` method - 'S': "kaneki ken" - } - - assert d['S'].title() == "Kaneki Ken" # if outside `def`, - # all double-quotation marked literals will be Nim's `string`, - # which is more like `bytearray` - # and single-quotation marked literals will be Nim's `char`, - # which repesents a single byte (ASCII character) - -show_literals() - - -# python 3.12's type statement -type Number = float | int # which is originally supported by nim-lang itself, however ;) - -for i in range(10): - # 0 1 2 3 4 5 6 7 8 9 - print(i, endl=" ") -print("done!") - -# Python-like variable unpacking -def show_unpack(): - data = list(range(3, 15, 2)) - (first, second, *rest, last) = data - assert (first + second + last) == (3 + 5 + 13) - -show_unpack() - -if (a := 6) > 5: - assert a == 6 - -print("a".center(9)) # " a " - -print("" or "b") # "b" -print("a" or "b") # "a" - -print(not "") # True - -print("Hello,", input("What is your name? "), endl="\n~\n") - -def show_divmod_and_unpack(integer_bytes): - (kilo, bite) = divmod(integer_bytes, 1_024) - (mega, kilo) = divmod(kilo, 1_024) - (giga, mega) = divmod(mega, 1_024) -show_divmod_and_unpack(2_313_354_324) - -def lambda_closure(arg): - anno = lambda: "hello " + arg - return anno() -assert lambda_closure("world") == "hello world" - -print(sys.platform) # "linux" - -print(platform.machine) # "x86_64" - -def allAny(): - truty = all([True, True, False]) - print(truty) # False - - truty = any([True, True, False]) - print(truty) # True -allAny() - -def a_little_sleep(): - "sleep around 0.001 milsecs." - # note Nim's os.sleep's unit is milsec, - # while Python's time.sleep's is second. - sleep(0.001) - -assert timeit(a_little_sleep, number=1000) > 1.0 - -# Support for Python-like with statements -# All objects are closed at the end of the with statement -def test_open(): - with open("some_file.txt", 'w') as file: - _ = file.write("hello world!") - - with open("some_file.txt", 'r') as file: - while True: - s = file.readline() - if s == "": break - print(s) - -test_open() - -def show_tempfile(): - with NamedTemporaryFile() as file: - _ = file.write(b"test!") # in binary mode - - with TemporaryDirectory() as name: - print(name) - -show_tempfile() - -class Example(object): # Mimic simple Python "classes". - """Example class with Python-ish Nim syntax!.""" - start: int - stop: int - step: int - def init(self, start, stop, step=1): - self.start = start - self.stop = stop - self.step = step - - def stopit(self, argument): - """Example function with Python-ish Nim syntax.""" - self.stop = argument - return self.stop - -def exa(): - e = Example(5, 3) - print(e.stopit(5)) - -exa() -``` - -Nimpylib heavily relies on Nim generics, converters, operator overloading, and even on concepts. - -Check the [Examples folder](./examples/) for more examples. -Have more Macros or Templates for Python-like syntax, send [Pull Request](https://github.com/nimpylib/pylib/pulls). - -## Installation - -```shell -nimble install pylib -``` - -> If the installing is stuck with: -`Downloading https://github.com/Yardanico/nimpylib using git` -Please note your nimble package.json is outdated, and that old URL is 404 now [^oldUrl]. -Run `nimble refresh` to fetch a newer `package.json` - -Of course, a workaround is to install with full URL: - -```shell -nimble install https://github.com/nimpylib/pylib -``` - -[^oldUrl]: see [wiki-history](https://github.com/nimpylib/pylib/wiki/History#the-newer-package-url) for details - -Uninstall with `nimble uninstall pylib`. - - -## Requisites - -- [Nim](https://nim-lang.org) - - -## Supported features - -- [x] F-Strings `f"foo {variable} bar {1 + 2} baz"` -- [x] `str` `bytes` `bytearray` `list` `dict` `set` `frozenset()` with their methods -- [x] Python-like variable unpacking -- [x] Math with Float and Int mixed like Python. -- [x] `lambda:` -- [x] `class` Python-like OOP with methods and DocStrings (without multi-inheritance) -- [x] `@classmethod` and `@staticmethod` -- [x] `with open(fn, [, ...]):` Read, write, append, and `read()`, `seek()`, `tell()`, etc. -- [x] `super(...).method(...)` -- [x] `global/nonlocal` (with some limits) -- [x] `True` / `False` -- [x] `pass` -- [x] `del foo[x]` -- [x] `:=` Walrus Operator -- [x] `abs()` -- [x] `all()` -- [x] `any()` -- [x] `ascii()` -- [x] `bin()` -- [x] `chr()` -- [x] `complex()` -- [x] `divmod()` -- [x] `enumerate()` -- [x] `filter()` -- [x] `float()` -- [x] `format()` -- [x] `getattr()` -- [x] `hasattr()` -- [x] `hash()` -- [x] `hex()` -- [x] `id()` -- [x] `input()` -- [x] `int()` -- [x] `isinstance()` -- [x] `issubclass()` -- [x] `iter()` -- [x] `list()` -- [x] `map()` -- [x] `max()` -- [x] `min()` -- [x] `next()` -- [x] `oct()` -- [x] `ord()` -- [x] `open()` (though without close_fd, opener, errors) -- [x] `pow(base, exp, mod=None)` -- [x] `print("foo")` / `print "foo"` Python2 like -- [x] `range()` -- [x] `reversed(iterable)` -- [x] `round()` -- [x] `hasattr()` -- [x] `set()`, also named `pyset()` to distingish with `system.set` -- [x] `slice()` -- [x] `sorted(iterable)` -- [x] `str()` -- [x] `sum()` -- [x] `!=` and Python1 `<>` -- [x] `long()` Python2 like (deprecated) -- [x] `u"string here"` / `u'a'` Python2 like -- [x] `b"string here"` / `b'a'` -- [x] `zip(*iterables, strict=False)` -- [x] (WIP) standard libraries `math`, `random`, `datetime`, `os`, `tempfile`, `timeit`, ... (see [Lib Docs][] for all supported) -- [ ] `aiter` `anext` and `await` (yet `async def` is supported) -- More... - -### Features cannot be implemented -However, due to Nim's AST astrict[^nimInvalidAST], a few syntaxes of Python cannot be implemented. - -See [here](./doc/mustRewriteExtern/) for details and workaround. - -[^nimInvalidAst]: Mostly because they cannot form valid AST in Nim. - -## Other Python-like modules - -- [serach in nimble](https://nimble.directory/search?query=python) -- [metacraft-labs/py2nim](https://github.com/metacraft-labs/py2nim): py2nim transpiler in Nim. -- [py2many/py2many](https://github.com/py2many/py2many): py2nim transpiler in Python. -- [juancarlospaco/cpython](https://github.com/juancarlospaco/cpython): invoke Python Standard Library API in Nim. -- [yglukhov/nimpy](https://github.com/yglukhov/nimpy): Python bridge in Nim. - -## Tests - -This is one snippest from version 0.9.5: - -> as too much tests output is it, -and it's not suitable to list too much content in README, -the following demo -is not likely to be updated from then on. - -```console -$ nimble test -[Suite] datetime - [OK] utcoffset - [OK] attrs - [OK] isoformat - -[Suite] fromisoformat - [OK] if reversible - -[Suite] timedelta - [OK] init - [OK] float init - [OK] normalize - [OK] stringify - -[Suite] date - [OK] fromisocalendar - [OK] fromisocalendar_value_errors - [OK] ordinal_conversion - [OK] replace - [OK] strftime - [OK] ctime - -[Suite] tzinfo - [OK] fromtimestamp - -[Suite] gamma - [OK] gamma(-integer) - -[Suite] ldexp - -[Suite] sumprod - [OK] array - [OK] CPython:test_math.testSumProd - -[Suite] constants - [OK] nan - [OK] inf - -[Suite] classify - [OK] isinf - [OK] isfinite - -[Suite] nextafter_ulp - [OK] nextafter - [OK] ulp - -[Suite] ldexp - [OK] static - [OK] small - [OK] non-normal first arg - [OK] large second arg - -[Suite] ErrnoAttributeTests - [OK] using_errorcode -[OK] touch, unlink, is_file -[OK] Lib/tempfile -[OK] Lib/time -[OK] Lib/timeit - -[Suite] Lib/array - [OK] py3.13: 'w' Py_UCS4 - [OK] bytes - [OK] cmp - [OK] byteswap - -[Suite] os.path - [OK] if export right - [OK] getxtime - -[Suite] Lib/os with no JS support - [OK] mkdir rmdir - [OK] open fdopen close - [OK] get,set_inheritable -[OK] getattr/set/has -[OK] bytearray - -[Suite] bytes - [OK] getitem - [OK] meth - [OK] repr - -[Suite] complex.__init__(str) - [OK] from str - [OK] negative_nans_from_string - -[Suite] complex - [OK] init - [OK] literals - [OK] str - [OK] op - -[Suite] complex.__repr__ - [OK] (N+nanj) - [OK] real == 0.0 - -[Suite] complex.__pow__ - [OK] CPython:test_complex.ComplexTest.test_pow - [OK] with small integer exponents -[OK] decorator -[OK] custom decorator -[OK] dict - -[Suite] float.fromhex - [OK] literals - [OK] nans - [OK] some values - [OK] overflow - [OK] zeros and underflow - [OK] round-half-even - -[Suite] float.fromhex and hex - [OK] roundtrip - -[Suite] float - [OK] hex - [OK] test_nan_signs - [OK] is_integer - [OK] as_integer_ratio - -[Suite] rewrite as py stmt - [OK] rewrite in `def` - [OK] rewrite raise -[OK] Floor division -[OK] int.{from,to}_bytes -[OK] io & with -[OK] bltin iters -[OK] iters as iterable -[OK] iter/next -[OK] random -[OK] Lib/string -[OK] list shallow -[OK] list.sort -[OK] list methods -[OK] Python-like types -[OK] divmod -[OK] pass -[OK] lambda -[OK] walrus operator -[OK] hex() -[OK] chr() -[OK] oct() -[OK] ord() -[OK] bin() -[OK] Modulo operations -[OK] int(x[, base]) -[OK] float(str) -[OK] Range-like Nim procedure -[OK] str.format -[OK] str operations -[OK] str index -[OK] str methods -[OK] str.maketrans&translate -[OK] tonim macro -[OK] unpack macro -[OK] With statement -[OK] generics in func signature -[OK] generics in class's methods -[OK] set -PASS: tests/testaments/builtins/print.nim c ( 1.93 sec) -SKIP: tests/testaments/builtins/print.nim js -PASS: tests/testaments/builtins/print_ct.nim c ( 1.93 sec) -PASS: tests/testaments/builtins/zip_no_seq.nim c ( 1.96 sec) -PASS: tests/testaments/builtins/zip_more_args.nim c ( 0.65 sec) -PASS: tests/testaments/builtins/filter_toseq_deadloop.nim c ( 0.66 sec) -Used D:\software\scoop\shims\nim.exe to run the tests. Use --nim to override. -PASS: tests/testaments/pysugar/colonToSlice.nim c ( 2.75 sec) -SKIP: tests/testaments/pysugar/colonToSlice.nim js -PASS: tests/testaments/pysugar/strlitCat.nim c ( 1.92 sec) -SKIP: tests/testaments/pysugar/strlitCat.nim js -PASS: tests/testaments/pysugar/tripleStrTranslate.nim c ( 0.84 sec) -PASS: tests/testaments/pysugar/autoSetListDict.nim c ( 3.40 sec) -``` diff --git a/changelogs/changelog_0_6_0.md b/changelogs/changelog_0_6_0.md deleted file mode 100644 index 79806e56a..000000000 --- a/changelogs/changelog_0_6_0.md +++ /dev/null @@ -1,41 +0,0 @@ - -# v0.6.0 - 2024-03-09 - -> the first release since forked from Yardanico's repo. - -## Fixes for inconsistence with Python -### ascii - -- for Unicode: use `\uhhhh` or `\UHHHHHHHH` instead of \uddd.. -- use one of single/double quotation marks when another is in the string -- ... - -### range -rename xrange back to range. - -### filter -fix to make it a non-reentrant iterable, just like in Python. - -### str method -- adjust `s.split()` to Python's (treat all unicode whitespace as sep). -- fix `capwords` to support unicode. -- add `capitalize`. -- fix `center` where `width` shall mean the total minimum width, instead of half. - -## Feature additions - -### def & async def -- add support for `def` outside `toNim` macro. -- support `async def`. - - -## Patches for Nim-compatibility - -### print.nim -solve `warning[CStringConv]`. - -### bin -add patches for `bin` to compile: - -- add patch for JS `abs` of BigInt (as `bin` invokes abs), as js in nimv2 uses BigInt for int64 - diff --git a/changelogs/changelog_0_8_0.md b/changelogs/changelog_0_8_0.md deleted file mode 100644 index a45ea1c2e..000000000 --- a/changelogs/changelog_0_8_0.md +++ /dev/null @@ -1,110 +0,0 @@ - -# v0.8.0 - 2024-04-09 - -> the second release since forked from Yardanico's repo. - -## Fixes for inconsistence with Python - -### `%` and `//` -- fix `%` and `//` to behave `floorMod` and `floorDiv`, -see their doc for details -- `divmod` - -### ord -when not `release`, -raises `TypeError` if the string argument contains not only one character - - -### read of Text Stream - -fix `textFile.read` to: - -- respect different NewLine Mode. -- respect `encoding`. - -## Feature additions - -### def in class -#### full support about params -e.g. -```Python -# can compile as Nim via pylib -class C: - def f(self, a: int): return a+1 - def g(self, a) -> int: return a+1 -``` -#### inheritance and `super` -e.g. -```Python -class A: - def f(self): return "A" -class B(A): - def f(self): return super().f() -``` - -### issubclass & isinstance - -### id -returns address as int - -### io -support `open` with more Python's params, e.g. `encoding` (though still not all) - -add `seek` `tell`, and try to minic Python's - -> see comments on `io.nim` for details - - -### pow -`pow(base, exp, modulo)` - -For example, `pow(1234, 20, 73)` results in `9` while `1234^20` is bigger than `high int`, where this function is useful. - - -### math -implement all function in Python 3.10 math - -### tempfile - -mktemp, mkdtemp, - -NamedTemporaryFile, TemporaryDirectory - - -### random -use a inner state - -### os - -system, open, close, fdopen, ... - -truncate, stat, ... - -mkdir, rmdir, getcwd, setcwd - -#### os.path -dirname, abspath, isabs, ... - -## Patches for Nim-compatitability - -> the following used to fail to run under nimv2 - -### pass -nimv2 somehow has a bug - -```Nim -# lib.nim -template pass* = discard -template pass*(_) = discard - -# main.nim -import lib -pass # <- Error: ambiguous identifier: 'pass' -- ... -``` -Then this version passes by this bug - - -### encodings - -see [`fixes: #223481`](https://github.com/nim-lang/Nim/pull/23481) - diff --git a/changelogs/changelog_0_8_2.md b/changelogs/changelog_0_8_2.md deleted file mode 100644 index 34eaffa9e..000000000 --- a/changelogs/changelog_0_8_2.md +++ /dev/null @@ -1,18 +0,0 @@ - -# v0.8.2 - 2024-04-10 - - -## Fixes for inconsistence with Python -- `f"xxx"` is no longer the same as `fr"xxx"` (as it always used to be). The escape chars in string will be translated now. - -- `len` for empty ranges, e.g. `len(range(4,0))` now give `0` as Python does. (instead of an negative result) - -- max/min on empty ranges, e.g. `max(range(4,0))`, now correctly raises `ValueError` - -## Feature additions - -- support `list` when JS -- add `index`, `count` method for range - -## Patches for Nim-compatibility - diff --git a/changelogs/changelog_0_9_0.md b/changelogs/changelog_0_9_0.md deleted file mode 100644 index a365348e3..000000000 --- a/changelogs/changelog_0_9_0.md +++ /dev/null @@ -1,45 +0,0 @@ - -# v0.9.0 - 2024-5-12 - - -## Fixes for inconsistence with Python - -- builtins that shall return `str` now returns `PyStr` over `string` -- move `string` to the Py-stdlib (`pylib/Lib/string`). -- `f"xxx"` is now not `fr"xxx"` (it used to be). -- `list` is equipped with methods. -- `list`/`set` is now of shallow-copy. -- `str` is now unicode-based. -- `int`*`str` now works. -- `repr(str)` fits Python's behavior. -- stringification for `False`/`True` now returns `False`/`True` over `false`/`true` -- `open()` now returns either a FileIO or a TextIOWrapper -based on `PyStr` or `PyBytes`, instead of `string` -- constants in `os` is of `str`, instead of `string` -- `io` is moved to `Lib/` - -## Feature additions - -- support in-place op like `%=` -- support bit shift -- support `bytes` with its methods -- support `dict` and `set` -- support `complex` -- add `Lib/cmath` -- add `os.scandir` -- support `map`, `zip` -- support `getattr`, `setattr`, `hasattr` - -### in `def` (func body) -- partly support `global/nonlocal` stmt -- partly support decorators -- support `raise ErrType[(msg)] -- support unpack-stmt (with restriction of no-omitting para.) - -(see doc of pysugar/stmt/tonim.nim for details) - -## Patches for Nim-compatibility -`Iterable` now longer causes `inner error` -when JS for bracket literals on older Nim compiler. -(see [Nim #9550](https://github.com/nim-lang/Nim/issues/9550) for details) - diff --git a/changelogs/changelog_0_9_1.md b/changelogs/changelog_0_9_1.md deleted file mode 100644 index 228788bf5..000000000 --- a/changelogs/changelog_0_9_1.md +++ /dev/null @@ -1,55 +0,0 @@ - -# v 0.9.1 - 2024-06-21 - - -## Fixes for inconsistence with Python - -- sys.hexversion is now an int instead of a string -- functions in `Lib/os` now raise subclass of `OSError` when it shall -- str/bytes.isupper/islower is no longer `all(map(lambda c: c.islower(), s))`, but only checks alpha. -- `str.title()` now works for Ligatures. -- str.upper, str.lower now use full case mapping instead of simple mapping. -- `str.casefold()` no longer just `toLower()`, but uses lookup table first. - -## Feature additions - -- bytearray() with its methods -- int(x[, base]) with base of 2,8,16 or 0 -- int.from_bytes classmethod and int.to_bytes -- str/bytes: - - translate and maketrans classmethod - - title, istitle - - replace() with `count` parameter -- str.format -- bytes(int|iterable|...) -- builtins - - format - - hash - - iter - - next -- string.Template.substitute -- array Library -- os - - rename - - get_terminal_size - - isatty - - closerange - - link, symlink, readlink - - path: - - getsize - - getctime - - ... - - ... - -- add Lib/: shutil, time, timeit - -## Patches for Nim-compatibility -- support Android (termux) - - -## breaks -- `PyDict` is now a ref object now (used to be a `OrderedTableRef`) - -- deprecate `toNimStr` of `PyStr`, use `toNimString` if needed (a concerter, so in fact is rarely used by name). -- f/u/b... literal prefix is now for literal only (used to for static[char|string]) -- deprcate pylib.timeit, use `pylib/Lib/timeit`'s timeit diff --git a/changelogs/changelog_0_9_10.md b/changelogs/changelog_0_9_10.md deleted file mode 100644 index 8a9817868..000000000 --- a/changelogs/changelog_0_9_10.md +++ /dev/null @@ -1,104 +0,0 @@ - -# v0.9.10 - 2025-04-27 - -## Bug Fixes -- py: - - io.flush raises OSError on SIGXFSZ. (5f2662510) - - audit funcs; .... (1ad6d96d7) - - `with` for os.ScandirIterator; add follow_symlinks for DirEntry.stat. (85ee4ec00) - - OSError([arg]): works. (ac0d45935) - - stat_result lacks st_file_attributes,st_reparse_tag on Windows. (42acad379) - - os.makedirs exist_ok was exists_ok. (e48a60a86) -- bool: - - `echo x` where x has no `$` resulted in pybool called. (9a8d0dc48) - - bypass(NIM-BUG), fixup! feat(bool): pybool cvt works for Option, `bool`-able: `T is SomeNumber` not compile. (3da7e8659) -- pyconfig: - - X87_double_rounding was reverted. (e0f0749b0) - - c_defined reverted;getrandom never declared. (87326ec7c) -- windows: - - CC crash on dtoa:fixup: fix(builtins): round(float[, n]) not to-even (ref #52). (d26c7861a) - - oserr: raiseExcWithPath used wrong error code. (538277f28) - -### Lib -- unittest: - - fixup: skipIf,skipUnless that returns a proc not compile.... (ec62e98d1, 6c51835fe) -- resource: - - not compile on Linux(lack RUSAGE_BOTH,RUSAGE_THREAD). (c54fa07fb) - - getpagesize not compile; prlimit,setrlimit not work for non tuple types. (bad24cce6) -- signal: - - SIGXFSZ not ignored. (54d854407) - - not compile if no Sigset. (10c413cee) - - not compile on Windows. (6f963f587) - - lock was nil on Windows. (364bea5e2) -- stat: - - stat.S_IMODE not compile for Mode. (4625dcc26) -- stat,os.chmod,os.symlink: - - not compile on Windows. (c626c08e7) -- os: - - fixup: 'feat(Lib/os): chmod' errmap not compile on Termux. (cd4faa9cc) - - Windows: unlink not compile. (a331a890e) -- shutils: - - SameFileError not of PyOSError. (e8d93beb8) -- time: - - sleep: add audit; fix 1 ms offset. (4531bb939) - -### JS -- Lib/os: - - getpid() not work on js. (ac405b053) - - not compiles for stat,unlink,chmods,scandir. (2e76c430c) -- oserr/errmap: not compile. (48d0fc3b1) -- os: just import causes not compile. (7fc1a2ec6) -- bypass(NIM-BUG): nim 2.2.4/2.3.1 disallows NonVarDestructor when js. (b3c8121cd) -- denoAttrs:deno detect was reverted, import* not support str as arg. (3153a57e1) - -## Feature additions -### builtins -- ops: bitops for ints. (2025f401d) -- bool: pybool cvt works for Option, `bool`-able. (e9eaf8c3f) - -### Lib -- os: - - chmod. (8b96d9566) - - getppid. (ac405b053) - - umask. (84c218f8b) - - lstat, stat with dir_fd, follow_symlinks & fstat. (01b6095e8) - - exp `supports_*`. (fa4d96974) - - unlink,remove supports dir_fd. (8af12d918) - - rmdir supports dir_fd. (4b14bbfcc) - - scandir supports fd as path. (af5991a9c) - - DirEntry.is_junction. (1b1653d4a) - - walk supports followlinks=walk_symlinks_as_files. (2b58ce25a) - - supports_*.issupperset. (fa0e50041) - - uname. (50156e634) -- os.path: - - samestat. (e979be258) -- unittest: - - self.fail. (5d78aa57f) - - skip* now will output [SKIPPED] if possible, instead of nothing. (a814951cd) -- sys: - - audit, addaudithook. (ed7a25407) - - flags. (04c32a123) -- shutil: - - rmtree. (8110d1adc) -- EXT: - - stat.S_I*(Mode): bool. (86698e412) - -### inner -- pyconfig: builtin_available,check_func_runtime. (ac14e4441) -- version: wrapPySince, templWrapExportSincePy. (d040f7a5f) -- Python/config_read_env. (5d0659dd7) -- sugar: - - raise OSError now raises PyOSError over Nim's.... (7a1586ba9) - - support `except (E,...) [as x]`. (86fbbadaa) - -## impr -- Lib/signal: use AC_CHECK_FUNCS. (8e694468d) - -## refine -- Lib: use wrapExportSincePy if possible. (a0011fa3d) -- win: dedup IO_REPARSE_TAG_SYMLINK,IO_REPARSE_TAG_MOUNT_POINT. (2b26c3057) - -## refactor -- Lib/shutil: split to shutil_impl; add n_shutil. (2544eeaa0) - - diff --git a/changelogs/changelog_0_9_11.md b/changelogs/changelog_0_9_11.md deleted file mode 100644 index 9e2cf3744..000000000 --- a/changelogs/changelog_0_9_11.md +++ /dev/null @@ -1,120 +0,0 @@ - -# v0.9.11 - 2025-05-25 - -## Bug Fixes - -* py: - - * complex: - - * allow pow's 1arg being SomeNumber; add mixin `==`. (f6f5ba590) - * pow: more precise for SomeInteger. (5a456efc1) - - * class: - - * attribute expressions were not rewritten. (6fd516c77) - * top-level classes and methods now properly exported. (a8aeddd91) - * method order corrected for non-auto restype. (131ec42b0) - * `:=` now always declares a new variable. (7d1aed865) -* pysugar/class: - - * `super(typ, obj)` parameters were reversed. (67bf79812) -* sugar: - - * `raise a.b...` didn’t compile. (674943b93) -* bool: - - * caused deadloop for `a==b` when `==` not declared. (9278a5d2c) -* Lib: - - * inspect: getsourcelines did not compile. (e3cb4db47) -* doc: - - * Lib/time fetchDoc not working. (0359fac95) - -## Feature Additions - -### builtins - -* `dir(cls)`. (045c692aa) - -### Lib - -* os: - - * `cpu_count`. (66e693522) - * `sched_{get,set}affinity`, `process_cpu_count`. (8a87354f7) -* unittest: - - * `TestCase.run`. (f8f17f931) - * `main`. (8311af01e) -* typing: - - * `OptionalObj`. (f9d6470a5) - -### class/sugar - -* `cls.dunder.dict.keys` → `cls.__dict__.keys()`. (f48a3fa86) -* auto call `__init_subclass__`. (f65706587) -* support `cls.new` → `cls.__new__`. (3351c5810) -* support `cls(...)` as sugar for `newCls(...)`. (e4db1bab7) -* support chained comparisons (e.g., `1 < x < 3`). (c0b83a61f) -* support Python function calls inside class bodies. (d092211f6) -* support `v: typ` in `def`, where typ can be `Literal`/`Final` → `const`/`let`. (3f2b4d05e) - -### pyconfig - -* `AC_CHECK_HEADER_THEN_FUNCS`, `AC_CHECK_HEADER[S]`. (d1aec1a9c) - -### EXT - -* `newPyListOfStr`. (32740352a) -* `OptionalObj`. (f9d6470a5) - -## Breaking Changes - -* EXT: - - * unexport `io.raiseOsOrFileNotFoundError`. (d9c7dc16c) -* Lib: - - * use `OptionalObj` for `datetime.tzname`, `inspect.*`, `signal.strsignal`, `os.*_cpu_count`. (b4eecd5bb) - -## Improvements - -* sugar/class: - - * enhanced support for top-level export, method reordering, variable declarations, and expression rewriting. (a8aeddd91, 7d1aed865, 131ec42b0, 6fd516c77) -* doc: - - * updated readme to use `Xxx` instead of `newXxx` for class instantiation. (fb91f6b85) - -## Refactor - -* os\_impl: - - * reimplemented `posix_like/errnoUtils`; renamed `errnoHandle` to `errnoRaise`. (b75367d93) -* nimpatch: - - * integrated `nim-lang/Nim#23456` to `nimpatch/`. (337b34676) -* exprRewrite: - - * added `mparser` argument to `toPyExpr`. (e4db1bab7) - -## Chores - -* CI: - - * allow `workflow_dispatch` in docs. (56e3d0d43) -* Nimble: - - * require Nim > 2.0.4; added changelog subcommand; merged logic. (1986af327) - -## Workarounds - -* os.path.join: - - * support for 3+ arguments (ref d1ca7cd7777a3fb160743). (982f819fe) -* compiles macro: - - * now takes effect when modifying macrocache. (ddc447a22) diff --git a/changelogs/changelog_0_9_2.md b/changelogs/changelog_0_9_2.md deleted file mode 100644 index 8aba4c7f2..000000000 --- a/changelogs/changelog_0_9_2.md +++ /dev/null @@ -1,76 +0,0 @@ - -# v0.9.2 - 2024-08-16 - -## Bug fixes -- math.isinf, isfinite didn't consider negative infinity as infinity. -- dict.copy() not compile -- mixing PyBool and bool not compile e.g.`True and true` -- bytearray.toNimString not work - - -## Fixes for inconsistence with Python -- float("-nan") may returns NaN with positive sign bit -- int(obj), float(obj) now works for obj with trunc/index -- complex(obj) for `obj: str or Any` -- input/print uses sys.stdin.sys.stdout as in/out stream -- `dict(k=v)`'s `K` is now str over string -- supports list, set, dict used as type(typedesc) -- os.path.getsize on non-reg is not allowed -- time.strftime supports %j %u %w %U and str{f,p}time supports %F %T -- repr - - uses lower hex alpha instead of upper and repr(bytes) - - repr(bytes) works for char greater than '\127' -- print(..., file=None) will do nothing if sys.stdout == Non -- check for isspace of str now handles '\x1c'..'\x1f' -- Lib - - tempfile - - split Lib/tempfile as n_tempfile, tempfile; fix signatures as py's - - sys - - fix io.flush not export by sys - - io - - DEFAULT_BUFFER_SIZE is exported now - - context mgr for io.IOBase - - os - - stat_result's `__getattr__` returned int over float - -## Feature additions -- int.to_bytes and int.from_bytes classmethod -- int.bit_count -- float.as_integer_ratio -- float.hex and float.fromhex classmethod -- support `**` where rhs is static negative int -- frozenset -- `PyUnicode[Decode]Error` -- Lib/ - - gc - - datetime - - unittest - - sys - - getfilesystemencoding() - - dunder_std{in,out,err} (a.k.a. `__std*__`) - - pathlib.Path: - - rel/abs relative methods - - joinpath,`/` and getters - - open, {write,read}_{text,bytes} - - some of `is_*` - - filesystem-relative method - - timeit.*, (not just .timeit) - - os - - add JS support for most APIs - - `{get,set}_[handle_]inheritable` - - lseek - - `SEEK_*` constants - - getpid - -### Nimscript Support Addition -input print - -### nimvm Support Addition -- math.ldexp,isinf,isfinite - - -## Patches for Nim-compatibility -- supports Debian - -## Python Sugar -- impr: better error msg for `def f:` (without `(`) diff --git a/changelogs/changelog_0_9_3.md b/changelogs/changelog_0_9_3.md deleted file mode 100644 index 5d8bc07d0..000000000 --- a/changelogs/changelog_0_9_3.md +++ /dev/null @@ -1,48 +0,0 @@ - -# v0.9.3 - 2024-09-30 - -## Breaks -- `PyComplex[T]` -> `PyTComplex[T]`; PyComplex is now non-generics (like CPython's `Py_complex`) - -## Bug fixes -- Lib/pathlib: argument order of Path.{sym,hard}link_to was reversed -- os.utime not compile on x86_64 macos - -### math -- expm1, log1p was inaccurate for arg near 0 -- dist's signature was wrong ( used to be `func [F: SomeFloat](x, y: F): F` ) -- `degrees` was typed as `degress` -- log1p, expm1 not accurate for arg near 0; - - -## Fixes for inconsistence with Python -- math.{floor,ceil,trunc} now return int over float -- str for complex(N, nan) was "(Nnanj)" (shall be "nanj") and str(complex) returns something in form of `Complex(re: A, im: B)` -- Lib/math's functions raises exception as Python does when math error occurs -- Lib/math: - - dist's signature wrongly used that of hypot - - `degrees` was typed as degress - -## Feature additions -- pow for complex type - - -### math -- supports objc (not test yet) -- supports compiletime (nimvm) -- for JS: - - math - - gamma, lgamma, erf, erfc are supported - - ldexp is more accurate - -- math: - - cbrt - - sumprod, dist, hypot - - nextafter, ulp - - ... (all APIs in CPython's math) - -- pathlib: - - `/=` for Path - - -## Patches for Nim-compatibility \ No newline at end of file diff --git a/changelogs/changelog_0_9_4.md b/changelogs/changelog_0_9_4.md deleted file mode 100644 index 4712a86bd..000000000 --- a/changelogs/changelog_0_9_4.md +++ /dev/null @@ -1,78 +0,0 @@ - -# v0.9.4 - 2024-10-20 - -## Bug fixes -- os.DirEntry and its methods not exported -- os: closes #34: DirEntry.is_file() for special file was true for special file (on posix) - -- fix(js): - - denoAttrs.importNodeImpl: wrongly used wrong param (sym over module param) - - bypass(NIM-BUG): interpolate via ` in emit in template doesn't respect genSym - - os - - open forgot to return - - utime intermedia overflow - - DirEntry.is_x cannot compile as readlink has sideEffect -- fix(js/nimscript): - - math.pow: wrongly raises because math_impl.errnoUtils Errno.EDOM was 0 (shall be non-zero) - - gamma used to return false result sometimes (ref 78ae12124f140e1528b9aedc6bc1887962109ead) - -- bypass NIM-BUG - - bypass(NIM-BUG): JS: internal error: genTypeInfo - - parentDir cannot work when JS's nimvm - -- fix(windows): os.open cannot compile due to lack of errno -- n_timeit.repeat used wrong index, causing IndexDefect -- sys: Py_FORCE_UTF8_FS_ENCODING ignored; linux vm cannot import - -### nextafter -- fix(vm): patch.nextafter returning word lo,hi was reversed -- fix: for script backend, nextafter didn't respect sign of 0.0 - - -## Fixes for inconsistence with Python -- python errors were not exported -- JS: - - v8 bug: Array misses signbit of NANs (storing all just as `NaN`) - - repr for float/complex makes NaN as "NaN" over "nan" -- rich compare for list, array (array's mixin type comparation respects pylibNoLenient) -- Lib/array: {from,to}file now accepts file-like - -## Feature additions - -- Lib/array: array('w'): python3.13's Py_UCS4 array; add {from,to}unicode -- EXT: - - add `as_someinteger_ratio`: used to bypass intermedia overflow in test - - add `@` method (extension) for array -- functions that now supports JS: - - os.path.get`x`time -- print: vm supports no newline (set endl arg) - -### math functions now accepting float32 -- nextafter -- frexp, ldexp -- gamma - -### math functions now supports nimvm -- expm1, log1p -- cbrt(float32) - -### inner -- version: - - pysince: - - accepts stmtList when nimdoc - - used as condition-expr -- denoAttrs: - - impr(js): denoAttrs allows 2nd param a dotExpr; fix: os.utime cannot compile for JS -- refactor(pyerrors): split to aritherr -- refactor(math_impl): - - split inWordUtils from patch/ldexp_frexp - - - impr(math_impl.{from,to}Words): when JS, support compilte-time; faster impl when C-like - - mv patch/polevl .. - -## opt improvement -- use sink for some functions of `array`,`list`,`bytes`,`bytearray`, and mark them as inline -- array: reduce some forloop as block mem op - -## Patches for Nim-compatibility -- supports nim 2.2.0 diff --git a/changelogs/changelog_0_9_5.md b/changelogs/changelog_0_9_5.md deleted file mode 100644 index 4f6b87c32..000000000 --- a/changelogs/changelog_0_9_5.md +++ /dev/null @@ -1,19 +0,0 @@ - -# v0.9.5 - yyyy-mm-dd - -## breaks - -- deprecate `newPyDictImpl` over `newPyDict`, to be removed since 0.10 - -## Fixes for inconsistence with Python - -## Feature additions -### Lib -errno and n_errno -### Python Syntax -`raise from` statement -#### python 3.13 -- generic function and class -- doc-string will be dedented - -## Patches for Nim-compatibility \ No newline at end of file diff --git a/changelogs/changelog_0_9_6.md b/changelogs/changelog_0_9_6.md deleted file mode 100644 index 4cefebea1..000000000 --- a/changelogs/changelog_0_9_6.md +++ /dev/null @@ -1,35 +0,0 @@ - -# v0.9.6 - 2025-01-18 - -## Bug Fixes -- Lib/errno cannot be compiled in Windows (931a9f50cecf2b75de214) -- `except` claude with no exception type (e.g. `except:`) crashes compiler -- Lib/platform: machine() result fixed for some arch; closes #48 - -## Fixes for inconsistence with Python -- `pass expr` was supported instead of `pass` (:use `discard expr` instead) -- zip: support no-seq args and any number of args over only 2; allow non-static `strict` -- triple strlit won't be escape-translated -- `except` with no exc type (e.g. `except:`) not compile - -## Feature additions -### print -- allow **\`end\`** along with `endl` for keyword - -### in `def` (func body) -- literal will be automatically interpreted as Py list/set/dict/str -- support `__getitem__`, `__setitem__` and `__delitem__` syntax (e.g. `ls[1:3]`) -- strlitCat in def (e.g. `"asds" "sad"`) - -### inner -- doc(pylib.nim): add version info in doc output -- EXT: nextImpl -## Patches for Nim-compatibility - -## CI -- add tests/testament -- doc will be deployed to `docs.nimpylib.org` - -## impr -- tonim: no list will be initialized when unpacking an array -- print: `sep`,`endl`'s default value is now char over string diff --git a/changelogs/changelog_0_9_7.md b/changelogs/changelog_0_9_7.md deleted file mode 100644 index dcdae83e3..000000000 --- a/changelogs/changelog_0_9_7.md +++ /dev/null @@ -1,57 +0,0 @@ - -# v0.9.7 - 2025-03-02 - -## break -- nitertools -> `n_itertools`; use openArray over seq - -## Bug Fixes -- sorted not compile for ptr list, etc and for generics seq -- complex(int,int) not compile -- datetime.timedelta not compile - -## Fixes for inconsistence with Python -- zip: not compile `Iterable[T]` (T differs each other) -- builtins.round(float[, n]) not to-even -- str(Inf) -> Infinity when JS (#44) -- int(char) err msg differs py's - -## Feature additions -### Lib -- collections.abc: include iters, collections, asyncs, generators -- bisect and `n_bisect` -- random (all func besides randint,seed,choice,Random) -- itertools.accumulate -- os.urandom, os.getrandom -- builtins - -### builtins -- allow items(tuple) -- max/min supports iterable & keywords -- format -- dir - -### in `def` (func body) -- support equal sign minus like `x=-1`/`x==-1` - -### EXT -- `@` for Sequence -- bytes: init from openArray[uint8] or Iterable[SomeInteger] - -### inner -- Objects/obmalloc.nim: pyalloc pyfree -- /pyconfig: - - pycore/pymath - - `c_defined`, `py_getrandom` -- `os_impl.platformAvailWhen` - -## Patches for Nim-compatibility -- newUninit for nim before 2.1.1 - -## CI -- update actions/cache@v2 to @v4 -- mv tfloat.nim tests tests/testament - -## impr -- faster int(char) -- numTypes.floats: use faster isfinite from isX - diff --git a/changelogs/changelog_0_9_8.md b/changelogs/changelog_0_9_8.md deleted file mode 100644 index 85457fd49..000000000 --- a/changelogs/changelog_0_9_8.md +++ /dev/null @@ -1,98 +0,0 @@ - -# v0.9.8 - 2025-04-03 - -## break -- chore(nimpatch): now when eq`ver`, patch still added - -## Bug Fixes -- Lib/os not compile: - - getpid - - iter for os.DirEntry -- Lib/string - - Template.substitute(dict): not work - - capwords: with sep had trailing sep -- macos: defined(macosx) shall be always used -- dtoa,pyconfig/floats not compile on arm -- `x**y` when x is not int not complie - -### JS -- Lib/os not compile - - getxtime - - os_impl.waits - - getpid: due to `Error: invalid pragma: importDenoOrProcess` - - scandir - - -## Fixes for inconsistence with Python -- overwrite Nim's SIGINT handler when not defined pylibUseNimIntHandler -- builtins now contains pyerrors -- str(tuple): now call str on each item -- sugar: - - now rewrite `func(k=v)`'s v, `(e, ...)`'s e -- sys.hexversion no release and serial; sys.version_info.releaselevel was string over str -- Lib/string Template.substitute: - - now raises as py - - no longer uses std/strutils.`%` - - Template is now a ref object -- chore(nimpatch): nansign: `nan` might be negative - -### inner -- addPatch,platformAvailWhen repr bool expr only shows "true"/"false" - -## Feature additions - -### builtins -- round(int, int) -- NameError -- KeyboardInterrupt - -### Lib -- signal -- resource -- unittest: - - skipTest - - assertFalse - - assert{[Not]{IsInstance,In},IsNot,{Greater,Less}[Equal]} - - assertRaises(TypeError,...) skipIf,skipUnless -- os: - - O_* consts - - wait* func, W* consts -- sys.float_repr_style -- n_string -- string: Template.is_valid,get_identifiers - -### inner -- Lib/enum_impl: intEnum, enumType -- pyconfig.util from_c_int -- Python/pylifecycle signal -- errno_impl.errnoUtils.setErrnoRaw -- oserr: newErrnoT new raiseErrnoErrT -- refact(os_impl): Py_get_osfhandle_noraise to util/get_osfhandle - -## doc -- comptime/log1p: add origin impl's url -- format: fix warnings -- mustRewriteExtern: condExpr underscore; fix wrong rewrite of strlitQuote -- readme: update old url, use rel url if possible - -## CI -- min max -- Lib/string: more for Template -- mv to testaments/: - - titers,titer_next,tlist - - tfloat.nim - - tdict,tset -- round: more for float - -## impr -- faster int(char) -- numTypes.floats: use faster isfinite from isX - -## refine -- repr,$: dict,list,set: merge similar code to strIter -### Purge warning -- unused: - - due to cond branch - - pyconfig/util.handle_option_bool, jsoserr.jsOs - - tests/tdecorator.nim - - itertools: imported but not used sequtils diff --git a/changelogs/changelog_0_9_9.md b/changelogs/changelog_0_9_9.md deleted file mode 100644 index dcd134c40..000000000 --- a/changelogs/changelog_0_9_9.md +++ /dev/null @@ -1,74 +0,0 @@ - -# v0.9.9 - 2025-04-21 - -## break -- oserr: unexport pathsAsOne, new tryOsOp accepts 2 or 0 paths (3f1f1140) -- slice: toNimSlice is no longer a cvt; cvt toPySlice from PySlice1. (c9518e8f) - -## Bug Fixes -- Lib/sys: - - float_repr_style not export (21b7f793) -- sugar: - - @a.b, @a.b(1) not compile (0fb94267, 1927cef4) - - generic class rewrite was wrong; class O(a.c)/O(a[t]) not compile. (f6c2824b) -- list: - - slice used in get,setitem with negative value causes RangeDefect. (4d33844a) - - fix setitem discarded longer values. (cd9ed64) -- builtins.slice: toNimSlice's assert not work. (903c1cd) -- initVal_with_handle_signal: - - deadloop(d9e0a00938e), os.wait*(f25a731fce5). (a5bae2c6) - - not compile on JS (6534a352) -- fixup! refact(os_impl): Py_get_osfhandle_noraise to util/get_osfhandle. (0f51997b) - - -### JS -- pyerrors.oserr: new catchJsErrAndSetErrno; add defval for raiseErrno,raiseErrnoWithPath (6534a352) -- importDenoOrNodeMod;2-arg importDenoOrProcess. (8f22a68c) -- os.utime not work: "fs is not defined". (47eca906) -- fixup(d7541b8c4): catchJsErrAsCode (used error which is cstring). (694eae8c) - -## Fixes for inconsistence with Python -- Lib/os - - readlink raises not just FileNotFoundEror,OSError... (c7976a54) - - makedirs: if existsts_ok, exception might be raised. (90c9610a) -- n_tempfile: - - js: mktemp raised OSError over FileNotFoundError. (f576b689) - -### inner - -## Feature additions - -### builtins - - -### Lib -- stat (4c8e84e9) -- unittest: - - TestCase: addCleanup,tearDown,setUp,run. (3314d922) - - -### inner -- test: support.os_helper.TESTFN (2c8406a3) -- pyconfig: util.from_c_int_expr,`AC_CHECK_FUNC[S]` (6534a352, be5332b1) -- js: - - jsutils/consts from_js_const (ae1671e6) - - -## doc - -## CI -- testC,testJs: run iff src/,tests/,./*.nimble, !feat-* branch. (2788f60d) - -## impr -- js: os.{open,close}: use importNode over "require...". (f361005c) - -## refine - -## refactor -- refact: mv os_impl/private/platform_util root's private (1d5e2a8e) -- Lib/unittest: split to unittest/case_py (4853b497) -- Lib/sys: split into sys_impl/; add n_sys (34f0cb98) -- Lib/os_impl: dedup MS_WINDOWS, InJs (6534a352) - - -### Purge warning diff --git a/changelogs/changelog_x_xx_x.md b/changelogs/changelog_x_xx_x.md deleted file mode 100644 index 333ad7bfc..000000000 --- a/changelogs/changelog_x_xx_x.md +++ /dev/null @@ -1,9 +0,0 @@ - -# vx.xx.x - yyyy-mm-dd - - -## Fixes for inconsistence with Python - -## Feature additions - -## Patches for Nim-compatibility \ No newline at end of file diff --git a/doc/mustRewriteExtern/README.md b/doc/mustRewriteExtern/README.md deleted file mode 100644 index 3fb737542..000000000 --- a/doc/mustRewriteExtern/README.md +++ /dev/null @@ -1,17 +0,0 @@ - -# Some Python Notations that must be rewritten externally - -This folder collects -some python notations that must be rewritten outside of `NimPyLib`. - -Maybe useful for translating Python code to Nim. - -## file format - -```markdown -## desc -## rewrite -``` - -and `rewrite` section contains several code blocks in BNF format, -with the pattern to match and the rewitten result splitted by `->`. diff --git a/doc/mustRewriteExtern/condExpr.md b/doc/mustRewriteExtern/condExpr.md deleted file mode 100644 index 9f1430d3c..000000000 --- a/doc/mustRewriteExtern/condExpr.md +++ /dev/null @@ -1,13 +0,0 @@ -# condition expression - -## desc - -Python supports what's called `triple operation` in C as `ifExpr if cond else elseExpr` - -## rewrite -``` -ifExpr "if" cond "else" elseExpr -> "if" cond ":" ifExpr "else" ":" elseExpr -``` - - - diff --git a/doc/mustRewriteExtern/conditionalExpr.md b/doc/mustRewriteExtern/conditionalExpr.md deleted file mode 100644 index 6540c33f1..000000000 --- a/doc/mustRewriteExtern/conditionalExpr.md +++ /dev/null @@ -1,12 +0,0 @@ -# Conditional expressions -## desc - -`a if cond else b` - -invalid AST in Nim. - - -## rewrite -``` -expr1 "if" cond "else" expr2 -> "if" cond ": " expr1 "else: " expr2 -``` diff --git a/doc/mustRewriteExtern/endKeyword.md b/doc/mustRewriteExtern/endKeyword.md deleted file mode 100644 index 4468d14aa..000000000 --- a/doc/mustRewriteExtern/endKeyword.md +++ /dev/null @@ -1,18 +0,0 @@ -# `end` keyword - -## desc -In Python, `end` may be used in `print` function (or as a identifier). - -However, in Nim, `end` is a keyword (though unused). - -So such a statement like `print(1, end="")` is an invalid AST of Nim. - -As a workaround, either `endl` or **\`end\`** can be used instead. - -And the latter is recommanded (supported after v0.9.5) -as it never introduces name collision thus being simpler when rewritting. - -## rewrite -``` -"end" -> "`end`" -``` diff --git a/doc/mustRewriteExtern/getsetitemSliceLit.md b/doc/mustRewriteExtern/getsetitemSliceLit.md deleted file mode 100644 index 2ec4098a0..000000000 --- a/doc/mustRewriteExtern/getsetitemSliceLit.md +++ /dev/null @@ -1,31 +0,0 @@ -# slice literal in getitem,setitem - -## desc - -For Python: - - - - -> 4. The slice of *s* from *i* to *j* is defined as the sequence of items with -index k such that *i <= k < j*. If *i* or *j* is greater than `len(s)`, use `len(s)`. -If *i* is omitted or `None`, use `0`. If *j* is omitted or `None`, use `len(s)`. -If *i* is greater than or equal to *j*, the slice is empty. - - -Only `ls[a:b]` is supported in nimpylib, as it's the only one that is a valid AST in Nim. - -Either of slice literal with step nor slice omitting any argument are supported. - -## rewrite -``` -ls "[:" b "]" -> ls "[0:" b "]" -ls "[" a ":]" -> ls "[" a ":len(" ls ")]" -``` - -``` -A ::= if a then a else 0 -B ::= if b then b else "len(" ls ")" -STEP ::= if step then step else "1" -ls "[" a? ":" b? ":" step? "]" -> ls "[slice(" A ", " B ", " STEP ")]" -``` diff --git a/doc/mustRewriteExtern/not-in.md b/doc/mustRewriteExtern/not-in.md deleted file mode 100644 index 8e3e1066c..000000000 --- a/doc/mustRewriteExtern/not-in.md +++ /dev/null @@ -1,11 +0,0 @@ -# not in -## desc -`a not in b` in Python is often written as `a not_in b` in Nim - -And though standalone `a not in b is invalid Nim AST, puting it in either assignment statement or if clause fails the Nim AST parser. (tested via `dumpTree` of `std/macros`) - -## rewrite -``` -a "not" "in" b -> "not" "(" a "in" b ")" -``` - diff --git a/doc/mustRewriteExtern/strlitQuote.md b/doc/mustRewriteExtern/strlitQuote.md deleted file mode 100644 index 9c37652f4..000000000 --- a/doc/mustRewriteExtern/strlitQuote.md +++ /dev/null @@ -1,16 +0,0 @@ - -# quotation mark of string literal - -## desc - -Python allows both `'` and `"` as string literal quotation mark; - -while Nim only allows `"`. (`'` is for character literal) - - -## rewrite -``` -"'" STR_CONTENT "'" -> "\"" STR_CONTENT_TRANS "\"" -``` - -`STR_CONENT_TRANS` = `STR_CONTENT`.replace('\'', '"') diff --git a/doc/mustRewriteExtern/tripleStrLit.md b/doc/mustRewriteExtern/tripleStrLit.md deleted file mode 100644 index a68ebb9fe..000000000 --- a/doc/mustRewriteExtern/tripleStrLit.md +++ /dev/null @@ -1,18 +0,0 @@ - -# triple string literal - -## desc - -For Nim: - - - -> For convenience, when the opening `"""` is followed by a newline (there may be whitespace between the opening `"""` and the newline), the newline (and the preceding whitespace) is not included in the string. - - -## rewrite - -``` -TRIPLE_STRLIT_BEGIN "\p" -> "\"\"\"\\n" -``` - diff --git a/doc/mustRewriteExtern/underscore.md b/doc/mustRewriteExtern/underscore.md deleted file mode 100644 index fe26f91de..000000000 --- a/doc/mustRewriteExtern/underscore.md +++ /dev/null @@ -1,16 +0,0 @@ -# underscore in identifier - -## desc - -In Nim, identifiers are not allowed to start or end with `_`, nor contain `__`. - -Here we recommend to replace `__` with `dunder` and `_` with `sunder`. - - -## rewrite -``` -"_" identifier -> "sunder_" identifier -identifier "_" -> identifier "_sunder" -"__" identifier -> "dunder_" identifier -identifier "__" -> identifier "_dunder" -``` diff --git a/doc/pylib.md b/doc/pylib.md deleted file mode 100644 index 05fbafb71..000000000 --- a/doc/pylib.md +++ /dev/null @@ -1,32 +0,0 @@ -# Nim Pylib - -> Just write Python code in Nim! - -## import pylib -The mostly suggested style is -```Nim -import pkg/pylib -``` - -However, omitting the `pkg/` prefix shall be fine at most cases: - -```Nim -import pylib -``` - -## import Python-like stdlib -Cheatsheet for rough alternative between pylib and Python - -| Nim pylib | Python | -| -------------------------- | -------------------------- | -| `from pylib/Lib/LIB import nil` | `import LIB` | -| `import pylib/Lib/LIB` | `from LIB import *` | -| `from pylib/Lib/LIB import XXX` | `import LIB; from LIB import XXX` | - ------- - -Wondering how many libs are available in NimPylib? - -Here are the -[Lib Docs](Lib/). - diff --git a/dochack.js b/dochack.js new file mode 100644 index 000000000..3166d3c90 --- /dev/null +++ b/dochack.js @@ -0,0 +1,1718 @@ +/* Generated by the Nim Compiler v2.2.4 */ +var framePtr = null; +var excHandler = 0; +var lastJSError = null; +var NTI33554466 = {size: 0,kind: 1,base: null,node: null,finalizer: null}; +var NTI721420302 = {size: 0, kind: 18, base: null, node: null, finalizer: null}; +var NTI33554435 = {size: 0,kind: 31,base: null,node: null,finalizer: null}; +var NTI956301392 = {size: 0,kind: 31,base: null,node: null,finalizer: null}; +var NTI956301399 = {size: 0, kind: 18, base: null, node: null, finalizer: null}; +var NTI134217745 = {size: 0, kind: 17, base: null, node: null, finalizer: null}; +var NTI134217749 = {size: 0, kind: 17, base: null, node: null, finalizer: null}; +var NTI134217751 = {size: 0, kind: 17, base: null, node: null, finalizer: null}; +var NTI33555167 = {size: 0, kind: 17, base: null, node: null, finalizer: null}; +var NTI33555175 = {size: 0, kind: 22, base: null, node: null, finalizer: null}; +var NTI33554450 = {size: 0,kind: 29,base: null,node: null,finalizer: null}; +var NTI33555174 = {size: 0, kind: 22, base: null, node: null, finalizer: null}; +var NTI33555171 = {size: 0, kind: 17, base: null, node: null, finalizer: null}; +var NTI33555172 = {size: 0, kind: 17, base: null, node: null, finalizer: null}; +var NTI134217741 = {size: 0, kind: 17, base: null, node: null, finalizer: null}; +var NTI134217743 = {size: 0, kind: 17, base: null, node: null, finalizer: null}; +var NTI33554449 = {size: 0,kind: 28,base: null,node: null,finalizer: null}; +var NNI134217743 = {kind: 2, len: 0, offset: 0, typ: null, name: null, sons: []}; +NTI134217743.node = NNI134217743; +var NNI134217741 = {kind: 2, len: 0, offset: 0, typ: null, name: null, sons: []}; +NTI134217741.node = NNI134217741; +var NNI33555172 = {kind: 2, len: 0, offset: 0, typ: null, name: null, sons: []}; +NTI33555172.node = NNI33555172; +NTI33555174.base = NTI33555171; +NTI33555175.base = NTI33555171; +var NNI33555171 = {kind: 2, len: 5, offset: 0, typ: null, name: null, sons: [{kind: 1, offset: "parent", len: 0, typ: NTI33555174, name: "parent", sons: null}, +{kind: 1, offset: "name", len: 0, typ: NTI33554450, name: "name", sons: null}, +{kind: 1, offset: "message", len: 0, typ: NTI33554449, name: "msg", sons: null}, +{kind: 1, offset: "trace", len: 0, typ: NTI33554449, name: "trace", sons: null}, +{kind: 1, offset: "up", len: 0, typ: NTI33555175, name: "up", sons: null}]}; +NTI33555171.node = NNI33555171; +var NNI33555167 = {kind: 2, len: 0, offset: 0, typ: null, name: null, sons: []}; +NTI33555167.node = NNI33555167; +NTI33555171.base = NTI33555167; +NTI33555172.base = NTI33555171; +NTI134217741.base = NTI33555172; +NTI134217743.base = NTI134217741; +var NNI134217751 = {kind: 2, len: 0, offset: 0, typ: null, name: null, sons: []}; +NTI134217751.node = NNI134217751; +NTI134217751.base = NTI33555172; +var NNI134217749 = {kind: 2, len: 0, offset: 0, typ: null, name: null, sons: []}; +NTI134217749.node = NNI134217749; +NTI134217749.base = NTI33555172; +var NNI134217745 = {kind: 2, len: 0, offset: 0, typ: null, name: null, sons: []}; +NTI134217745.node = NNI134217745; +NTI134217745.base = NTI33555172; +var NNI956301399 = {kind: 2, len: 2, offset: 0, typ: null, name: null, sons: [{kind: 1, offset: "a", len: 0, typ: NTI956301392, name: "a", sons: null}, +{kind: 1, offset: "b", len: 0, typ: NTI33554435, name: "b", sons: null}]}; +NTI956301399.node = NNI956301399; +var NNI721420302 = {kind: 2, len: 2, offset: 0, typ: null, name: null, sons: [{kind: 1, offset: "Field0", len: 0, typ: NTI33554435, name: "Field0", sons: null}, +{kind: 1, offset: "Field1", len: 0, typ: NTI33554466, name: "Field1", sons: null}]}; +NTI721420302.node = NNI721420302; + +function setConstr() { + var result = {}; + for (var i = 0; i < arguments.length; ++i) { + var x = arguments[i]; + if (typeof(x) == "object") { + for (var j = x[0]; j <= x[1]; ++j) { + result[j] = true; + } + } else { + result[x] = true; + } + } + return result; + + + +} +var ConstSet1 = setConstr(17, 16, 4, 18, 27, 19, 23, 22, 21); + +function nimCopy(dest_p0, src_p1, ti_p2) { + var result_33557330 = null; + + switch (ti_p2.kind) { + case 21: + case 22: + case 23: + case 5: + if (!(isFatPointer__system_u2878(ti_p2))) { + result_33557330 = src_p1; + } + else { + result_33557330 = [src_p1[0], src_p1[1]]; + } + + break; + case 19: + if (dest_p0 === null || dest_p0 === undefined) { + dest_p0 = {}; + } + else { + for (var key in dest_p0) { delete dest_p0[key]; } + } + for (var key in src_p1) { dest_p0[key] = src_p1[key]; } + result_33557330 = dest_p0; + + break; + case 18: + case 17: + if (!((ti_p2.base == null))) { + result_33557330 = nimCopy(dest_p0, src_p1, ti_p2.base); + } + else { + if ((ti_p2.kind == 17)) { + result_33557330 = (dest_p0 === null || dest_p0 === undefined) ? {m_type: ti_p2} : dest_p0; + } + else { + result_33557330 = (dest_p0 === null || dest_p0 === undefined) ? {} : dest_p0; + } + } + nimCopyAux(result_33557330, src_p1, ti_p2.node); + break; + case 4: + case 16: + if(ArrayBuffer.isView(src_p1)) { + if(dest_p0 === null || dest_p0 === undefined || dest_p0.length != src_p1.length) { + dest_p0 = new src_p1.constructor(src_p1); + } else { + dest_p0.set(src_p1, 0); + } + result_33557330 = dest_p0; + } else { + if (src_p1 === null) { + result_33557330 = null; + } + else { + if (dest_p0 === null || dest_p0 === undefined || dest_p0.length != src_p1.length) { + dest_p0 = new Array(src_p1.length); + } + result_33557330 = dest_p0; + for (var i = 0; i < src_p1.length; ++i) { + result_33557330[i] = nimCopy(result_33557330[i], src_p1[i], ti_p2.base); + } + } + } + + break; + case 24: + case 27: + if (src_p1 === null) { + result_33557330 = null; + } + else { + if (dest_p0 === null || dest_p0 === undefined || dest_p0.length != src_p1.length) { + dest_p0 = new Array(src_p1.length); + } + result_33557330 = dest_p0; + for (var i = 0; i < src_p1.length; ++i) { + result_33557330[i] = nimCopy(result_33557330[i], src_p1[i], ti_p2.base); + } + } + + break; + case 28: + if (src_p1 !== null) { + result_33557330 = src_p1.slice(0); + } + + break; + default: + result_33557330 = src_p1; + break; + } + + return result_33557330; + +} + +function mnewString(len_p0) { + var result = new Array(len_p0); + for (var i = 0; i < len_p0; i++) {result[i] = 0;} + return result; + + + +} + +function isObj(obj_p0, subclass_p1) { + var result_33557443 = false; + + BeforeRet: { + var x_33557444 = obj_p0; + if ((x_33557444 == subclass_p1)) { + result_33557443 = true; + break BeforeRet; + } + + Label1: { + Label2: while (true) { + if (!!((x_33557444 == subclass_p1))) break Label2; + if ((x_33557444 == null)) { + result_33557443 = false; + break BeforeRet; + } + + x_33557444 = x_33557444.base; + } + }; + result_33557443 = true; + break BeforeRet; + }; + + return result_33557443; + +} + +function toJSStr(s_p0) { + var result_33556919 = null; + + var res_33556973 = newSeq__system_u2516((s_p0).length); + var i_33556974 = 0; + var j_33556975 = 0; + Label1: { + Label2: while (true) { + if (!(i_33556974 < (s_p0).length)) break Label2; + var c_33556976 = s_p0[i_33556974]; + if ((c_33556976 < 128)) { + res_33556973[j_33556975] = String.fromCharCode(c_33556976); + i_33556974 += 1; + } + else { + var helper_33557002 = newSeq__system_u2516(0); + Label3: { + Label4: while (true) { + if (!true) break Label4; + var code_33557003 = c_33556976.toString(16); + if ((((code_33557003) == null ? 0 : (code_33557003).length) == 1)) { + helper_33557002.push("%0");; + } + else { + helper_33557002.push("%");; + } + + helper_33557002.push(code_33557003);; + i_33556974 += 1; + if ((((s_p0).length <= i_33556974) || (s_p0[i_33556974] < 128))) { + break Label3; + } + + c_33556976 = s_p0[i_33556974]; + } + }; +++excHandler; + try { + res_33556973[j_33556975] = decodeURIComponent(helper_33557002.join("")); +--excHandler; +} catch (EXCEPTION) { + var prevJSError = lastJSError; + lastJSError = EXCEPTION; + --excHandler; + raiseDefect(); + res_33556973[j_33556975] = helper_33557002.join(""); + lastJSError = prevJSError; + } finally { + } + } + + j_33556975 += 1; + } + }; + if (res_33556973.length < j_33556975) { for (var i = res_33556973.length ; i < j_33556975 ; ++i) res_33556973.push(null); } + else { res_33556973.length = j_33556975; }; + result_33556919 = res_33556973.join(""); + + return result_33556919; + +} + +function raiseException(e_p0, ename_p1) { + e_p0.name = ename_p1; + if ((excHandler == 0)) { + unhandledException(e_p0); + } + + throw e_p0; + + +} + +function addInt(a_p0, b_p1) { + var result = a_p0 + b_p1; + checkOverflowInt(result); + return result; + + + +} + +function chckRange(i_p0, a_p1, b_p2) { + var result_33557370 = 0; + + BeforeRet: { + if (((a_p1 <= i_p0) && (i_p0 <= b_p2))) { + result_33557370 = i_p0; + break BeforeRet; + } + else { + raiseRangeError(); + } + + }; + + return result_33557370; + +} + +function chckIndx(i_p0, a_p1, b_p2) { + var result_33557365 = 0; + + BeforeRet: { + if (((a_p1 <= i_p0) && (i_p0 <= b_p2))) { + result_33557365 = i_p0; + break BeforeRet; + } + else { + raiseIndexError(i_p0, a_p1, b_p2); + } + + }; + + return result_33557365; + +} + +function makeNimstrLit(c_p0) { + var result = []; + for (var i = 0; i < c_p0.length; ++i) { + result[i] = c_p0.charCodeAt(i); + } + return result; + + + +} + +function subInt(a_p0, b_p1) { + var result = a_p0 - b_p1; + checkOverflowInt(result); + return result; + + + +} + +function cstrToNimstr(c_p0) { + var ln = c_p0.length; + var result = new Array(ln); + var r = 0; + for (var i = 0; i < ln; ++i) { + var ch = c_p0.charCodeAt(i); + + if (ch < 128) { + result[r] = ch; + } + else { + if (ch < 2048) { + result[r] = (ch >> 6) | 192; + } + else { + if (ch < 55296 || ch >= 57344) { + result[r] = (ch >> 12) | 224; + } + else { + ++i; + ch = 65536 + (((ch & 1023) << 10) | (c_p0.charCodeAt(i) & 1023)); + result[r] = (ch >> 18) | 240; + ++r; + result[r] = ((ch >> 12) & 63) | 128; + } + ++r; + result[r] = ((ch >> 6) & 63) | 128; + } + ++r; + result[r] = (ch & 63) | 128; + } + ++r; + } + return result; + + + +} +var ConstSet2 = setConstr([65, 90]); +var ConstSet3 = setConstr(95, 32, 46); +var ConstSet4 = setConstr(95, 32, 46); + +function mulInt(a_p0, b_p1) { + var result = a_p0 * b_p1; + checkOverflowInt(result); + return result; + + + +} +var ConstSet5 = setConstr([97, 122]); +var ConstSet6 = setConstr([65, 90], [97, 122]); +var ConstSet7 = setConstr([97, 122]); +var ConstSet8 = setConstr([65, 90]); +var ConstSet9 = setConstr([65, 90], [97, 122]); + +function nimMax(a_p0, b_p1) { + var Temporary1; + + var result_33557157 = 0; + + BeforeRet: { + if ((b_p1 <= a_p0)) { + Temporary1 = a_p0; + } + else { + Temporary1 = b_p1; + } + + result_33557157 = Temporary1; + break BeforeRet; + }; + + return result_33557157; + +} + +function nimMin(a_p0, b_p1) { + var Temporary1; + + var result_33557153 = 0; + + BeforeRet: { + if ((a_p0 <= b_p1)) { + Temporary1 = a_p0; + } + else { + Temporary1 = b_p1; + } + + result_33557153 = Temporary1; + break BeforeRet; + }; + + return result_33557153; + +} + +function addChar(x_p0, c_p1) { + x_p0.push(c_p1); + + +} +var objectID_1174405298 = [0]; + +function setTheme(theme_p0) { + document.documentElement.setAttribute("data-theme", theme_p0); + window.localStorage.setItem("theme", theme_p0); + + +} + +function isFatPointer__system_u2878(ti_p0) { + var result_33557312 = false; + + BeforeRet: { + result_33557312 = !((ConstSet1[ti_p0.base.kind] != undefined)); + break BeforeRet; + }; + + return result_33557312; + +} + +function nimCopyAux(dest_p0, src_p1, n_p2) { + switch (n_p2.kind) { + case 0: + break; + case 1: + dest_p0[n_p2.offset] = nimCopy(dest_p0[n_p2.offset], src_p1[n_p2.offset], n_p2.typ); + + break; + case 2: + for (var i = 0; i < n_p2.sons.length; i++) { + nimCopyAux(dest_p0, src_p1, n_p2.sons[i]); + } + + break; + case 3: + dest_p0[n_p2.offset] = nimCopy(dest_p0[n_p2.offset], src_p1[n_p2.offset], n_p2.typ); + for (var i = 0; i < n_p2.sons.length; ++i) { + nimCopyAux(dest_p0, src_p1, n_p2.sons[i][1]); + } + + break; + } + + +} + +function add__system_u1942(x_p0, x_p0_Idx, y_p1) { + if (x_p0[x_p0_Idx] === null) { x_p0[x_p0_Idx] = []; } + var off = x_p0[x_p0_Idx].length; + x_p0[x_p0_Idx].length += y_p1.length; + for (var i = 0; i < y_p1.length; ++i) { + x_p0[x_p0_Idx][off+i] = y_p1.charCodeAt(i); + } + + + +} + +function newSeq__system_u2516(len_p0) { + var result_33556952 = []; + + result_33556952 = new Array(len_p0); for (var i = 0 ; i < len_p0 ; ++i) { result_33556952[i] = null; } + return result_33556952; + +} + +function isNimException__system_u2017() { + return lastJSError && lastJSError.m_type; + + +} + +function getCurrentException() { + var result_33556452 = null; + + if (isNimException__system_u2017()) { + result_33556452 = lastJSError; + } + + + return result_33556452; + +} + +function raiseDefect() { + if (isNimException__system_u2017()) { + var e_33556664 = getCurrentException(); + if (isObj(e_33556664.m_type, NTI33555172)) { + if ((excHandler == 0)) { + unhandledException(e_33556664); + } + + throw e_33556664; + } + + } + + + +} + +function unhandledException(e_p0) { + var buf_33556658 = [[]]; + if (!(((e_p0.message).length == 0))) { + buf_33556658[0].push.apply(buf_33556658[0], [69,114,114,111,114,58,32,117,110,104,97,110,100,108,101,100,32,101,120,99,101,112,116,105,111,110,58,32]);; + buf_33556658[0].push.apply(buf_33556658[0], e_p0.message);; + } + else { + buf_33556658[0].push.apply(buf_33556658[0], [69,114,114,111,114,58,32,117,110,104,97,110,100,108,101,100,32,101,120,99,101,112,116,105,111,110]);; + } + + buf_33556658[0].push.apply(buf_33556658[0], [32,91]);; + add__system_u1942(buf_33556658, 0, e_p0.name); + buf_33556658[0].push.apply(buf_33556658[0], [93,10]);; + var cbuf_33556659 = toJSStr(buf_33556658[0]); + if (typeof(Error) !== "undefined") { + throw new Error(cbuf_33556659); + } + else { + throw cbuf_33556659; + } + + + +} + +function raiseOverflow() { + raiseException({message: [111,118,101,114,45,32,111,114,32,117,110,100,101,114,102,108,111,119], parent: null, m_type: NTI134217743, name: null, trace: [], up: null}, "OverflowDefect"); + + +} + +function checkOverflowInt(a_p0) { + if (a_p0 > 2147483647 || a_p0 < -2147483648) raiseOverflow(); + + + +} + +function raiseRangeError() { + raiseException({message: [118,97,108,117,101,32,111,117,116,32,111,102,32,114,97,110,103,101], parent: null, m_type: NTI134217751, name: null, trace: [], up: null}, "RangeDefect"); + + +} + +function addChars__stdZprivateZdigitsutils_u202(result_p0, result_p0_Idx, x_p1, start_p2, n_p3) { + var Temporary1; + + var old_301990096 = (result_p0[result_p0_Idx]).length; + if (result_p0[result_p0_Idx].length < (Temporary1 = chckRange(addInt(old_301990096, n_p3), 0, 2147483647), Temporary1)) { for (var i = result_p0[result_p0_Idx].length; i < Temporary1; ++i) result_p0[result_p0_Idx].push(0); } + else {result_p0[result_p0_Idx].length = Temporary1; }; + Label2: { + var iHEX60gensym4_301990110 = 0; + var i_570426583 = 0; + Label3: { + Label4: while (true) { + if (!(i_570426583 < n_p3)) break Label4; + iHEX60gensym4_301990110 = i_570426583; + result_p0[result_p0_Idx][chckIndx(addInt(old_301990096, iHEX60gensym4_301990110), 0, (result_p0[result_p0_Idx]).length - 1)] = x_p1.charCodeAt(chckIndx(addInt(start_p2, iHEX60gensym4_301990110), 0, (x_p1).length - 1)); + i_570426583 = addInt(i_570426583, 1); + } + }; + }; + + +} + +function addChars__stdZprivateZdigitsutils_u198(result_p0, result_p0_Idx, x_p1) { + addChars__stdZprivateZdigitsutils_u202(result_p0, result_p0_Idx, x_p1, 0, ((x_p1) == null ? 0 : (x_p1).length)); + + +} + +function addInt__stdZprivateZdigitsutils_u223(result_p0, result_p0_Idx, x_p1) { + addChars__stdZprivateZdigitsutils_u198(result_p0, result_p0_Idx, ((x_p1) + "")); + + +} + +function addInt__stdZprivateZdigitsutils_u241(result_p0, result_p0_Idx, x_p1) { + addInt__stdZprivateZdigitsutils_u223(result_p0, result_p0_Idx, BigInt(x_p1)); + + +} + +function HEX24__systemZdollars_u14(xHEX60gensym0_p0) { + var result_385875984 = [[]]; + + result_385875984[0] = nimCopy(null, [], NTI33554449); + addInt__stdZprivateZdigitsutils_u241(result_385875984, 0, xHEX60gensym0_p0); + + return result_385875984[0]; + +} + +function raiseIndexError(i_p0, a_p1, b_p2) { + var Temporary1; + + if ((b_p2 < a_p1)) { + Temporary1 = [105,110,100,101,120,32,111,117,116,32,111,102,32,98,111,117,110,100,115,44,32,116,104,101,32,99,111,110,116,97,105,110,101,114,32,105,115,32,101,109,112,116,121]; + } + else { + Temporary1 = ([105,110,100,101,120,32]).concat(HEX24__systemZdollars_u14(i_p0),[32,110,111,116,32,105,110,32],HEX24__systemZdollars_u14(a_p1),[32,46,46,32],HEX24__systemZdollars_u14(b_p2)); + } + + raiseException({message: nimCopy(null, Temporary1, NTI33554449), parent: null, m_type: NTI134217749, name: null, trace: [], up: null}, "IndexDefect"); + + +} + +function sysFatal__stdZassertions_u44(message_p1) { + raiseException({message: nimCopy(null, message_p1, NTI33554449), m_type: NTI134217745, parent: null, name: null, trace: [], up: null}, "AssertionDefect"); + + +} + +function raiseAssert__stdZassertions_u42(msg_p0) { + sysFatal__stdZassertions_u44(msg_p0); + + +} + +function failedAssertImpl__stdZassertions_u84(msg_p0) { + raiseAssert__stdZassertions_u42(msg_p0); + + +} + +function onDOMLoaded(e_p0) { + var Temporary4; + +function HEX3Aanonymous__dochack_u65(event_p0) { + event_p0.target.parentNode.style.display = "none"; + event_p0.target.parentNode.nextSibling.style.display = "inline"; + + +} + + document.getElementById("theme-select").value = window.localStorage.getItem("theme"); + Label1: { + var pragmaDots_570425408 = null; + var colontmp__570426574 = []; + colontmp__570426574 = document.getElementsByClassName("pragmadots"); + var i_570426576 = 0; + var L_570426577 = (colontmp__570426574).length; + Label2: { + Label3: while (true) { + if (!(i_570426576 < L_570426577)) break Label3; + pragmaDots_570425408 = colontmp__570426574[chckIndx(i_570426576, 0, (colontmp__570426574).length - 1)]; + Temporary4 = HEX3Aanonymous__dochack_u65.bind(null); Temporary4.ClP_0 = HEX3Aanonymous__dochack_u65; Temporary4.ClE_0 = null; + pragmaDots_570425408.onclick = Temporary4; + i_570426576 += 1; + if (!(((colontmp__570426574).length == L_570426577))) { + failedAssertImpl__stdZassertions_u84(makeNimstrLit("iterators.nim(254, 11) `len(a) == L` the length of the seq changed while iterating over it")); + } + + } + }; + }; + + +} + +function isWhitespace__dochack_u408(x_p0) { + var result_570425754 = false; + + result_570425754 = (((x_p0.nodeName == "#text") && !/\S/.test(x_p0.textContent)) || (x_p0.nodeName == "#comment")); + + return result_570425754; + +} + +function toToc__dochack_u411(x_p0, father_p1) { + var Temporary5; + var Temporary6; + var Temporary7; + var Temporary8; + var Temporary15; + + if ((x_p0.nodeName == "UL")) { + var f_570425765 = {heading: null, kids: [], sortId: (father_p1.kids).length, doSort: false}; + var i_570425766 = 0; + Label1: { + Label2: while (true) { + if (!(i_570425766 < x_p0.childNodes.length)) break Label2; + var nxt_570425767 = addInt(i_570425766, 1); + Label3: { + Label4: while (true) { + if (!(nxt_570425767 < x_p0.childNodes.length)) Temporary5 = false; else { Temporary5 = isWhitespace__dochack_u408(x_p0.childNodes[nxt_570425767]); } if (!Temporary5) break Label4; + nxt_570425767 = addInt(nxt_570425767, 1); + } + }; + if (!(nxt_570425767 < x_p0.childNodes.length)) Temporary8 = false; else { Temporary8 = (x_p0.childNodes[i_570425766].nodeName == "LI"); } if (!Temporary8) Temporary7 = false; else { Temporary7 = (x_p0.childNodes[i_570425766].childNodes.length == 1); } if (!Temporary7) Temporary6 = false; else { Temporary6 = (x_p0.childNodes[nxt_570425767].nodeName == "UL"); } if (Temporary6) { + var e_570425780 = {heading: x_p0.childNodes[i_570425766].childNodes[0], kids: [], sortId: (f_570425765.kids).length, doSort: false}; + var it_570425781 = x_p0.childNodes[nxt_570425767]; + Label9: { + var j_570425786 = 0; + var colontmp__570426591 = 0; + colontmp__570426591 = it_570425781.childNodes.length; + var i_570426592 = 0; + Label10: { + Label11: while (true) { + if (!(i_570426592 < colontmp__570426591)) break Label11; + j_570425786 = i_570426592; + toToc__dochack_u411(it_570425781.childNodes[j_570425786], e_570425780); + i_570426592 = addInt(i_570426592, 1); + } + }; + }; + f_570425765.kids.push(e_570425780);; + i_570425766 = addInt(nxt_570425767, 1); + } + else { + toToc__dochack_u411(x_p0.childNodes[i_570425766], f_570425765); + i_570425766 = addInt(i_570425766, 1); + } + + } + }; + father_p1.kids.push(f_570425765);; + } + else { + if (isWhitespace__dochack_u408(x_p0)) { + } + else { + if ((x_p0.nodeName == "LI")) { + var idx_570425804 = []; + Label12: { + var i_570425809 = 0; + var colontmp__570426595 = 0; + colontmp__570426595 = x_p0.childNodes.length; + var i_570426596 = 0; + Label13: { + Label14: while (true) { + if (!(i_570426596 < colontmp__570426595)) break Label14; + i_570425809 = i_570426596; + if (!(isWhitespace__dochack_u408(x_p0.childNodes[i_570425809]))) { + idx_570425804.push(i_570425809);; + } + + i_570426596 = addInt(i_570426596, 1); + } + }; + }; + if (!((idx_570425804).length == 2)) Temporary15 = false; else { Temporary15 = (x_p0.childNodes[idx_570425804[chckIndx(1, 0, (idx_570425804).length - 1)]].nodeName == "UL"); } if (Temporary15) { + var e_570425825 = {heading: x_p0.childNodes[idx_570425804[chckIndx(0, 0, (idx_570425804).length - 1)]], kids: [], sortId: (father_p1.kids).length, doSort: false}; + var it_570425826 = x_p0.childNodes[idx_570425804[chckIndx(1, 0, (idx_570425804).length - 1)]]; + Label16: { + var j_570425831 = 0; + var colontmp__570426599 = 0; + colontmp__570426599 = it_570425826.childNodes.length; + var i_570426600 = 0; + Label17: { + Label18: while (true) { + if (!(i_570426600 < colontmp__570426599)) break Label18; + j_570425831 = i_570426600; + toToc__dochack_u411(it_570425826.childNodes[j_570425831], e_570425825); + i_570426600 = addInt(i_570426600, 1); + } + }; + }; + father_p1.kids.push(e_570425825);; + } + else { + Label19: { + var i_570425840 = 0; + var colontmp__570426603 = 0; + colontmp__570426603 = x_p0.childNodes.length; + var i_570426604 = 0; + Label20: { + Label21: while (true) { + if (!(i_570426604 < colontmp__570426603)) break Label21; + i_570425840 = i_570426604; + toToc__dochack_u411(x_p0.childNodes[i_570425840], father_p1); + i_570426604 = addInt(i_570426604, 1); + } + }; + }; + } + + } + else { + father_p1.kids.push({heading: x_p0, kids: [], sortId: (father_p1.kids).length, doSort: false});; + } + }} + + +} + +function extractItems__dochack_u199(x_p0, heading_p1, items_p2, items_p2_Idx) { + BeforeRet: { + if ((x_p0 == null)) { + break BeforeRet; + } + + if ((!((x_p0.heading == null)) && (x_p0.heading.textContent == heading_p1))) { + Label1: { + var i_570425563 = 0; + var colontmp__570426607 = 0; + colontmp__570426607 = (x_p0.kids).length; + var i_570426608 = 0; + Label2: { + Label3: while (true) { + if (!(i_570426608 < colontmp__570426607)) break Label3; + i_570425563 = i_570426608; + items_p2[items_p2_Idx].push(x_p0.kids[chckIndx(i_570425563, 0, (x_p0.kids).length - 1)].heading);; + i_570426608 = addInt(i_570426608, 1); + } + }; + }; + } + else { + Label4: { + var k_570425589 = null; + var i_570426612 = 0; + var L_570426613 = (x_p0.kids).length; + Label5: { + Label6: while (true) { + if (!(i_570426612 < L_570426613)) break Label6; + k_570425589 = x_p0.kids[chckIndx(i_570426612, 0, (x_p0.kids).length - 1)]; + extractItems__dochack_u199(k_570425589, heading_p1, items_p2, items_p2_Idx); + i_570426612 += 1; + if (!(((x_p0.kids).length == L_570426613))) { + failedAssertImpl__stdZassertions_u84(makeNimstrLit("iterators.nim(254, 11) `len(a) == L` the length of the seq changed while iterating over it")); + } + + } + }; + }; + } + + }; + + +} + +function tree__dochack_u130(tag_p0, kids_p1) { + var result_570425477 = null; + + result_570425477 = document.createElement(tag_p0); + Label1: { + var k_570425491 = null; + var i_570426625 = 0; + Label2: { + Label3: while (true) { + if (!(i_570426625 < (kids_p1).length)) break Label3; + k_570425491 = kids_p1[chckIndx(i_570426625, 0, (kids_p1).length - 1)]; + result_570425477.appendChild(k_570425491); + i_570426625 += 1; + } + }; + }; + + return result_570425477; + +} + +function text__dochack_u155(s_p0) { + var result_570425501 = null; + + result_570425501 = document.createTextNode(s_p0); + + return result_570425501; + +} + +function uncovered__dochack_u600(x_p0) { + var Temporary1; + + var result_570425946 = null; + + BeforeRet: { + if ((((x_p0.kids).length == 0) && !((x_p0.heading == null)))) { + if (!(x_p0.heading.hasOwnProperty('__karaxMarker__'))) { + Temporary1 = x_p0; + } + else { + Temporary1 = null; + } + + result_570425946 = Temporary1; + break BeforeRet; + } + + result_570425946 = {heading: x_p0.heading, kids: [], sortId: x_p0.sortId, doSort: x_p0.doSort}; + Label2: { + var k_570425961 = null; + var i_570426632 = 0; + var L_570426633 = (x_p0.kids).length; + Label3: { + Label4: while (true) { + if (!(i_570426632 < L_570426633)) break Label4; + k_570425961 = x_p0.kids[chckIndx(i_570426632, 0, (x_p0.kids).length - 1)]; + var y_570425962 = uncovered__dochack_u600(k_570425961); + if (!((y_570425962 == null))) { + result_570425946.kids.push(y_570425962);; + } + + i_570426632 += 1; + if (!(((x_p0.kids).length == L_570426633))) { + failedAssertImpl__stdZassertions_u84(makeNimstrLit("iterators.nim(254, 11) `len(a) == L` the length of the seq changed while iterating over it")); + } + + } + }; + }; + if (((result_570425946.kids).length == 0)) { + result_570425946 = null; + } + + }; + + return result_570425946; + +} + +function mergeTocs__dochack_u630(orig_p0, news_p1) { + var result_570425977 = null; + + result_570425977 = uncovered__dochack_u600(orig_p0); + if ((result_570425977 == null)) { + result_570425977 = news_p1; + } + else { + Label1: { + var i_570425989 = 0; + var colontmp__570426628 = 0; + colontmp__570426628 = (news_p1.kids).length; + var i_570426629 = 0; + Label2: { + Label3: while (true) { + if (!(i_570426629 < colontmp__570426628)) break Label3; + i_570425989 = i_570426629; + result_570425977.kids.push(news_p1.kids[chckIndx(i_570425989, 0, (news_p1.kids).length - 1)]);; + i_570426629 = addInt(i_570426629, 1); + } + }; + }; + } + + + return result_570425977; + +} + +function buildToc__dochack_u650(orig_p0, types_p1, procs_p2) { + var result_570425998 = null; + + var newStuff_570426003 = {heading: null, kids: [], doSort: true, sortId: 0}; + Label1: { + var t_570426007 = null; + var i_570426620 = 0; + var L_570426621 = (types_p1).length; + Label2: { + Label3: while (true) { + if (!(i_570426620 < L_570426621)) break Label3; + t_570426007 = types_p1[chckIndx(i_570426620, 0, (types_p1).length - 1)]; + var c_570426012 = {heading: t_570426007.cloneNode(true), kids: [], doSort: true, sortId: 0}; + t_570426007.__karaxMarker__ = true; + Label4: { + var p_570426016 = null; + var i_570426617 = 0; + var L_570426618 = (procs_p2).length; + Label5: { + Label6: while (true) { + if (!(i_570426617 < L_570426618)) break Label6; + p_570426016 = procs_p2[chckIndx(i_570426617, 0, (procs_p2).length - 1)]; + if (!(p_570426016.hasOwnProperty('__karaxMarker__'))) { + var xx_570426017 = p_570426016.parentNode.getElementsByClassName("attachedType"); + if ((((xx_570426017).length == 1) && (xx_570426017[chckIndx(0, 0, (xx_570426017).length - 1)].textContent == t_570426007.textContent))) { + var q_570426022 = tree__dochack_u130("A", [text__dochack_u155(p_570426016.title)]); + q_570426022.setAttribute("href", p_570426016.getAttribute("href")); + c_570426012.kids.push({heading: q_570426022, kids: [], sortId: 0, doSort: false});; + p_570426016.__karaxMarker__ = true; + } + + } + + i_570426617 += 1; + if (!(((procs_p2).length == L_570426618))) { + failedAssertImpl__stdZassertions_u84(makeNimstrLit("iterators.nim(254, 11) `len(a) == L` the length of the seq changed while iterating over it")); + } + + } + }; + }; + newStuff_570426003.kids.push(c_570426012);; + i_570426620 += 1; + if (!(((types_p1).length == L_570426621))) { + failedAssertImpl__stdZassertions_u84(makeNimstrLit("iterators.nim(254, 11) `len(a) == L` the length of the seq changed while iterating over it")); + } + + } + }; + }; + result_570425998 = mergeTocs__dochack_u630(orig_p0, newStuff_570426003); + + return result_570425998; + +} + +function add__dochack_u148(parent_p0, kid_p1) { + if (((parent_p0.nodeName == "TR") && ((kid_p1.nodeName == "TD") || (kid_p1.nodeName == "TH")))) { + var k_570425495 = document.createElement("TD"); + k_570425495.appendChild(kid_p1); + parent_p0.appendChild(k_570425495); + } + else { + parent_p0.appendChild(kid_p1); + } + + + +} + +function setClass__dochack_u152(e_p0, value_p1) { + e_p0.setAttribute("class", value_p1); + + +} + +function toHtml__dochack_u278(x_p0, isRoot_p1) { + var Temporary1; + +function HEX3Aanonymous__dochack_u298(a_p0, b_p1) { + var result_570425645 = 0; + + BeforeRet: { + if ((!((a_p0.heading == null)) && !((b_p1.heading == null)))) { + var x_570425654 = a_p0.heading.textContent; + var y_570425655 = b_p1.heading.textContent; + if ((x_570425654 < y_570425655)) { + result_570425645 = (-1); + break BeforeRet; + } + + if ((y_570425655 < x_570425654)) { + result_570425645 = 1; + break BeforeRet; + } + + result_570425645 = 0; + break BeforeRet; + } + else { + result_570425645 = subInt(a_p0.sortId, b_p1.sortId); + break BeforeRet; + } + + }; + + return result_570425645; + +} + + var result_570425625 = null; + + BeforeRet: { + if ((x_p0 == null)) { + result_570425625 = null; + break BeforeRet; + } + + if (((x_p0.kids).length == 0)) { + if ((x_p0.heading == null)) { + result_570425625 = null; + break BeforeRet; + } + + result_570425625 = x_p0.heading.cloneNode(true); + break BeforeRet; + } + + result_570425625 = tree__dochack_u130("DIV", []); + if ((!((x_p0.heading == null)) && !(x_p0.heading.hasOwnProperty('__karaxMarker__')))) { + add__dochack_u148(result_570425625, x_p0.heading.cloneNode(true)); + } + + var ul_570425641 = tree__dochack_u130("UL", []); + if (isRoot_p1) { + setClass__dochack_u152(ul_570425641, "simple simple-toc"); + } + else { + setClass__dochack_u152(ul_570425641, "simple"); + } + + if (x_p0.doSort) { + Temporary1 = HEX3Aanonymous__dochack_u298.bind(null); Temporary1.ClP_0 = HEX3Aanonymous__dochack_u298; Temporary1.ClE_0 = null; + x_p0.kids.sort(Temporary1); + } + + Label2: { + var k_570425667 = null; + var i_570426636 = 0; + var L_570426637 = (x_p0.kids).length; + Label3: { + Label4: while (true) { + if (!(i_570426636 < L_570426637)) break Label4; + k_570425667 = x_p0.kids[chckIndx(i_570426636, 0, (x_p0.kids).length - 1)]; + var y_570425668 = toHtml__dochack_u278(k_570425667, false); + if (!((y_570425668 == null))) { + add__dochack_u148(ul_570425641, tree__dochack_u130("LI", [y_570425668])); + } + + i_570426636 += 1; + if (!(((x_p0.kids).length == L_570426637))) { + failedAssertImpl__stdZassertions_u84(makeNimstrLit("iterators.nim(254, 11) `len(a) == L` the length of the seq changed while iterating over it")); + } + + } + }; + }; + if (!((ul_570425641.childNodes.length == 0))) { + add__dochack_u148(result_570425625, ul_570425641); + } + + if ((result_570425625.childNodes.length == 0)) { + result_570425625 = null; + } + + }; + + return result_570425625; + +} + +function replaceById__dochack_u158(id_p0, newTree_p1) { + var x_570425505 = document.getElementById(id_p0); + x_570425505.parentNode.replaceChild(newTree_p1, x_570425505); + newTree_p1.id = id_p0; + + +} + +function togglevis__dochack_u708(d_p0) { + if ((d_p0.style.display == "none")) { + d_p0.style.display = "inline"; + } + else { + d_p0.style.display = "none"; + } + + + +} + +function groupBy(value_p0) { + var toc_570426056 = document.getElementById("toc-list"); + if ((alternative_570426051[0] == null)) { + var tt_570426064 = {heading: null, kids: [], sortId: 0, doSort: false}; + toToc__dochack_u411(toc_570426056, tt_570426064); + tt_570426064 = tt_570426064.kids[chckIndx(0, 0, (tt_570426064.kids).length - 1)]; + var types_570426069 = [[]]; + var procs_570426074 = [[]]; + extractItems__dochack_u199(tt_570426064, "Types", types_570426069, 0); + extractItems__dochack_u199(tt_570426064, "Procs", procs_570426074, 0); + extractItems__dochack_u199(tt_570426064, "Converters", procs_570426074, 0); + extractItems__dochack_u199(tt_570426064, "Methods", procs_570426074, 0); + extractItems__dochack_u199(tt_570426064, "Templates", procs_570426074, 0); + extractItems__dochack_u199(tt_570426064, "Macros", procs_570426074, 0); + extractItems__dochack_u199(tt_570426064, "Iterators", procs_570426074, 0); + var ntoc_570426075 = buildToc__dochack_u650(tt_570426064, types_570426069[0], procs_570426074[0]); + var x_570426076 = toHtml__dochack_u278(ntoc_570426075, true); + alternative_570426051[0] = tree__dochack_u130("DIV", [x_570426076]); + } + + if ((value_p0 == "type")) { + replaceById__dochack_u158("tocRoot", alternative_570426051[0]); + } + else { + replaceById__dochack_u158("tocRoot", tree__dochack_u130("DIV", [])); + } + + togglevis__dochack_u708(document.getElementById("toc-list")); + + +} + +function HEX5BHEX5D__pureZstrutils_u1307(s_p0, x_p1) { + var result_738198816 = []; + + var a_738198818 = x_p1.a; + var L_738198820 = addInt(subInt(subInt((s_p0).length, x_p1.b), a_738198818), 1); + result_738198816 = nimCopy(null, mnewString(chckRange(L_738198820, 0, 2147483647)), NTI33554449); + Label1: { + var i_738198825 = 0; + var i_570426646 = 0; + Label2: { + Label3: while (true) { + if (!(i_570426646 < L_738198820)) break Label3; + i_738198825 = i_570426646; + result_738198816[chckIndx(i_738198825, 0, (result_738198816).length - 1)] = s_p0[chckIndx(addInt(i_738198825, a_738198818), 0, (s_p0).length - 1)]; + i_570426646 = addInt(i_570426646, 1); + } + }; + }; + + return result_738198816; + +} + +function HEX2EHEX2E__stdZenumutils_u105(a_p0, b_p1) { + var result_956301424 = ({a: 0, b: 0}); + + result_956301424 = nimCopy(result_956301424, {a: a_p0, b: b_p1}, NTI956301399); + + return result_956301424; + +} +async function loadIndex__dochack_u928() { + var result_570426274 = null; + + BeforeRet: { + var indexURL_570426280 = document.getElementById("indexLink").getAttribute("href"); + var rootURL_570426306 = HEX5BHEX5D__pureZstrutils_u1307(cstrToNimstr(indexURL_570426280), HEX2EHEX2E__stdZenumutils_u105(0, 14)); + var resp_570426318 = (await (await fetch(indexURL_570426280)).text()); + var indexElem_570426319 = document.createElement("div"); + indexElem_570426319.innerHTML = resp_570426318; + Label1: { + var href_570426341 = null; + var colontmp__570426640 = []; + colontmp__570426640 = indexElem_570426319.getElementsByClassName("reference"); + var i_570426642 = 0; + var L_570426643 = (colontmp__570426640).length; + Label2: { + Label3: while (true) { + if (!(i_570426642 < L_570426643)) break Label3; + href_570426341 = colontmp__570426640[chckIndx(i_570426642, 0, (colontmp__570426640).length - 1)]; + href_570426341.setAttribute("href", toJSStr((rootURL_570426306).concat(cstrToNimstr(href_570426341.getAttribute("href"))))); + db_570426093[0].push(href_570426341);; + contents_570426094[0].push(href_570426341.getAttribute("data-doc-search-tag"));; + i_570426642 += 1; + if (!(((colontmp__570426640).length == L_570426643))) { + failedAssertImpl__stdZassertions_u84(makeNimstrLit("iterators.nim(254, 11) `len(a) == L` the length of the seq changed while iterating over it")); + } + + } + }; + }; + result_570426274 = undefined; + break BeforeRet; + }; + + return result_570426274; + +} + +function then__dochack_u1107(future_p0, onSuccess_p1, onReject_p2) { + var result_570426457 = null; + + BeforeRet: { + var ret_570426467 = null; + ret_570426467 = future_p0.then(onSuccess_p1, onReject_p2); + result_570426457 = ret_570426467; + break BeforeRet; + }; + + return result_570426457; + +} + +function nsuToLowerAsciiChar(c_p0) { + var result_738197590 = 0; + + if ((ConstSet2[c_p0] != undefined)) { + result_738197590 = (c_p0 ^ 32); + } + else { + result_738197590 = c_p0; + } + + + return result_738197590; + +} + +function fuzzyMatch__fuzzysearch_u16(pattern_p0, str_p1) { + var Temporary4; + var Temporary5; + var Temporary6; + var Temporary7; + var Temporary8; + + var result_721420309 = {Field0: 0, Field1: false}; + + var scoreState_721420310 = (-100); + var headerMatched_721420311 = false; + var unmatchedLeadingCharCount_721420312 = 0; + var consecutiveMatchCount_721420313 = 0; + var strIndex_721420314 = 0; + var patIndex_721420315 = 0; + var score_721420316 = 0; + Label1: { + Label2: while (true) { + if (!((strIndex_721420314 < ((str_p1) == null ? 0 : (str_p1).length)) && (patIndex_721420315 < ((pattern_p0) == null ? 0 : (pattern_p0).length)))) break Label2; + Label3: { + var patternChar_721420319 = nsuToLowerAsciiChar(pattern_p0.charCodeAt(chckIndx(patIndex_721420315, 0, (pattern_p0).length - 1))); + var strChar_721420320 = nsuToLowerAsciiChar(str_p1.charCodeAt(chckIndx(strIndex_721420314, 0, (str_p1).length - 1))); + if ((ConstSet3[patternChar_721420319] != undefined)) { + patIndex_721420315 = addInt(patIndex_721420315, 1); + break Label3; + } + + if ((ConstSet4[strChar_721420320] != undefined)) { + strIndex_721420314 = addInt(strIndex_721420314, 1); + break Label3; + } + + if ((!(headerMatched_721420311) && (strChar_721420320 == 58))) { + headerMatched_721420311 = true; + scoreState_721420310 = (-100); + score_721420316 = ((Math.floor((0.5 * score_721420316))) | 0); + patIndex_721420315 = 0; + strIndex_721420314 = addInt(strIndex_721420314, 1); + break Label3; + } + + if ((strChar_721420320 == patternChar_721420319)) { + switch (scoreState_721420310) { + case (-100): + case 20: + scoreState_721420310 = 10; + break; + case 0: + scoreState_721420310 = 5; + score_721420316 = addInt(score_721420316, scoreState_721420310); + break; + case 10: + case 5: + consecutiveMatchCount_721420313 = addInt(consecutiveMatchCount_721420313, 1); + scoreState_721420310 = 5; + score_721420316 = addInt(score_721420316, mulInt(5, consecutiveMatchCount_721420313)); + if ((scoreState_721420310 == 10)) { + score_721420316 = addInt(score_721420316, 10); + } + + var onBoundary_721420372 = (patIndex_721420315 == ((pattern_p0) == null ? -1 : (pattern_p0).length - 1)); + if ((!(onBoundary_721420372) && (strIndex_721420314 < ((str_p1) == null ? -1 : (str_p1).length - 1)))) { + var nextPatternChar_721420373 = nsuToLowerAsciiChar(pattern_p0.charCodeAt(chckIndx(addInt(patIndex_721420315, 1), 0, (pattern_p0).length - 1))); + var nextStrChar_721420374 = nsuToLowerAsciiChar(str_p1.charCodeAt(chckIndx(addInt(strIndex_721420314, 1), 0, (str_p1).length - 1))); + if (!!((ConstSet5[nextStrChar_721420374] != undefined))) Temporary4 = false; else { Temporary4 = !((nextStrChar_721420374 == nextPatternChar_721420373)); } onBoundary_721420372 = Temporary4; + } + + if (onBoundary_721420372) { + scoreState_721420310 = 20; + score_721420316 = addInt(score_721420316, scoreState_721420310); + } + + break; + case (-1): + case (-3): + if (!((ConstSet6[str_p1.charCodeAt(chckIndx(subInt(strIndex_721420314, 1), 0, (str_p1).length - 1))] != undefined))) Temporary5 = true; else { if (!(ConstSet7[str_p1.charCodeAt(chckIndx(subInt(strIndex_721420314, 1), 0, (str_p1).length - 1))] != undefined)) Temporary6 = false; else { Temporary6 = (ConstSet8[str_p1.charCodeAt(chckIndx(strIndex_721420314, 0, (str_p1).length - 1))] != undefined); } Temporary5 = Temporary6; } var isLeadingChar_721420398 = Temporary5; + if (isLeadingChar_721420398) { + scoreState_721420310 = 10; + } + else { + scoreState_721420310 = 0; + score_721420316 = addInt(score_721420316, scoreState_721420310); + } + + break; + } + patIndex_721420315 = addInt(patIndex_721420315, 1); + } + else { + switch (scoreState_721420310) { + case (-100): + scoreState_721420310 = (-3); + score_721420316 = addInt(score_721420316, scoreState_721420310); + break; + case 5: + scoreState_721420310 = (-1); + score_721420316 = addInt(score_721420316, scoreState_721420310); + consecutiveMatchCount_721420313 = 0; + break; + case (-3): + if ((unmatchedLeadingCharCount_721420312 < 3)) { + scoreState_721420310 = (-3); + score_721420316 = addInt(score_721420316, scoreState_721420310); + } + + unmatchedLeadingCharCount_721420312 = addInt(unmatchedLeadingCharCount_721420312, 1); + break; + default: + scoreState_721420310 = (-1); + score_721420316 = addInt(score_721420316, scoreState_721420310); + break; + } + } + + strIndex_721420314 = addInt(strIndex_721420314, 1); + }; + } + }; + if (!(patIndex_721420315 == ((pattern_p0) == null ? 0 : (pattern_p0).length))) Temporary7 = false; else { if ((strIndex_721420314 == ((str_p1) == null ? 0 : (str_p1).length))) Temporary8 = true; else { Temporary8 = !((ConstSet9[str_p1.charCodeAt(chckIndx(strIndex_721420314, 0, (str_p1).length - 1))] != undefined)); } Temporary7 = Temporary8; } if (Temporary7) { + score_721420316 = addInt(score_721420316, 10); + } + + var colontmp__570426659 = nimMax(0, score_721420316); + var colontmp__570426660 = (0 < score_721420316); + result_721420309 = nimCopy(result_721420309, {Field0: colontmp__570426659, Field1: colontmp__570426660}, NTI721420302); + + return result_721420309; + +} + +function escapeCString__dochack_u751(x_p0, x_p0_Idx) { + var s_570426097 = []; + Label1: { + var c_570426098 = 0; + var iHEX60gensym13_570426663 = 0; + var nHEX60gensym13_570426664 = ((x_p0[x_p0_Idx]) == null ? 0 : (x_p0[x_p0_Idx]).length); + Label2: { + Label3: while (true) { + if (!(iHEX60gensym13_570426663 < nHEX60gensym13_570426664)) break Label3; + c_570426098 = x_p0[x_p0_Idx].charCodeAt(chckIndx(iHEX60gensym13_570426663, 0, (x_p0[x_p0_Idx]).length - 1)); + switch (c_570426098) { + case 60: + s_570426097.push.apply(s_570426097, [38,108,116,59]);; + break; + case 62: + s_570426097.push.apply(s_570426097, [38,103,116,59]);; + break; + default: + addChar(s_570426097, c_570426098);; + break; + } + iHEX60gensym13_570426663 += 1; + } + }; + }; + x_p0[x_p0_Idx] = toJSStr(s_570426097); + + +} + +function dosearch__dochack_u755(value_p0) { + var Temporary5; + +function HEX3Aanonymous__dochack_u783(a_p0, b_p1) { + var result_570426140 = 0; + + result_570426140 = subInt(b_p1["Field1"], a_p0["Field1"]); + + return result_570426140; + +} + + var result_570426101 = null; + + BeforeRet: { + if (((db_570426093[0]).length == 0)) { + break BeforeRet; + } + + var ul_570426105 = tree__dochack_u130("UL", []); + result_570426101 = tree__dochack_u130("DIV", []); + setClass__dochack_u152(result_570426101, "search_results"); + var matches_570426110 = []; + Label1: { + var i_570426118 = 0; + var colontmp__570426650 = 0; + colontmp__570426650 = (db_570426093[0]).length; + var i_570426651 = 0; + Label2: { + Label3: while (true) { + if (!(i_570426651 < colontmp__570426650)) break Label3; + i_570426118 = i_570426651; + Label4: { + var c_570426119 = contents_570426094[0][chckIndx(i_570426118, 0, (contents_570426094[0]).length - 1)]; + if (((c_570426119 == "Examples") || (c_570426119 == "PEG construction"))) { + break Label4; + } + + var tmpTuple_570426120 = fuzzyMatch__fuzzysearch_u16(value_p0, c_570426119); + var score_570426121 = tmpTuple_570426120["Field0"]; + var matched_570426122 = tmpTuple_570426120["Field1"]; + if (matched_570426122) { + matches_570426110.push({Field0: db_570426093[0][chckIndx(i_570426118, 0, (db_570426093[0]).length - 1)], Field1: score_570426121});; + } + + }; + i_570426651 = addInt(i_570426651, 1); + } + }; + }; + Temporary5 = HEX3Aanonymous__dochack_u783.bind(null); Temporary5.ClP_0 = HEX3Aanonymous__dochack_u783; Temporary5.ClE_0 = null; + matches_570426110.sort(Temporary5); + Label6: { + var i_570426157 = 0; + var colontmp__570426654 = 0; + colontmp__570426654 = nimMin((matches_570426110).length, 29); + var i_570426655 = 0; + Label7: { + Label8: while (true) { + if (!(i_570426655 < colontmp__570426654)) break Label8; + i_570426157 = i_570426655; + matches_570426110[chckIndx(i_570426157, 0, (matches_570426110).length - 1)]["Field0"].innerHTML = matches_570426110[chckIndx(i_570426157, 0, (matches_570426110).length - 1)]["Field0"].getAttribute("data-doc-search-tag"); + escapeCString__dochack_u751(matches_570426110[chckIndx(i_570426157, 0, (matches_570426110).length - 1)]["Field0"], "innerHTML"); + add__dochack_u148(ul_570426105, tree__dochack_u130("LI", [matches_570426110[chckIndx(i_570426157, 0, (matches_570426110).length - 1)]["Field0"]])); + i_570426655 = addInt(i_570426655, 1); + } + }; + }; + if ((ul_570426105.childNodes.length == 0)) { + add__dochack_u148(result_570426101, tree__dochack_u130("B", [text__dochack_u155("no search results")])); + } + else { + add__dochack_u148(result_570426101, tree__dochack_u130("B", [text__dochack_u155("search results")])); + add__dochack_u148(result_570426101, ul_570426105); + } + + }; + + return result_570426101; + +} + +function hideSearch__dochack_u1090() { + if (!((oldtoc_570426430[0] == null))) { + replaceById__dochack_u158("tocRoot", oldtoc_570426430[0]); + } + + + +} + +function runSearch__dochack_u1094() { + var elem_570426439 = document.getElementById("searchInput"); + var value_570426440 = elem_570426439.value; + if (!((value_570426440 == ""))) { + if ((oldtoc_570426430[0] == null)) { + oldtoc_570426430[0] = document.getElementById("tocRoot"); + } + + var results_570426444 = dosearch__dochack_u755(value_570426440); + replaceById__dochack_u158("tocRoot", results_570426444); + } + else { + hideSearch__dochack_u1090(); + } + + + +} + +function search() { + var Temporary1; + + if ((loadIndexFut_570426433[0] == null)) { + loadIndexFut_570426433[0] = loadIndex__dochack_u928(); + (then__dochack_u1107(loadIndexFut_570426433[0], runSearch__dochack_u1094, null)); + } + + if (!((timer_570426431[0] == null))) { + clearTimeout(timer_570426431[0]); + } + + Temporary1 = runSearch__dochack_u1094.bind(null); Temporary1.ClP_0 = runSearch__dochack_u1094; Temporary1.ClE_0 = null; + timer_570426431[0] = setTimeout(Temporary1, 400); + + +} + +function copyToClipboard() { + + function updatePreTags() { + + const allPreTags = document.querySelectorAll("pre:not(.line-nums)") + + allPreTags.forEach((e) => { + + const div = document.createElement("div") + div.classList.add("copyToClipBoard") + + const preTag = document.createElement("pre") + preTag.innerHTML = e.innerHTML + + const button = document.createElement("button") + button.value = e.textContent.replace('...', '') + button.classList.add("copyToClipBoardBtn") + button.style.cursor = "pointer" + + div.appendChild(preTag) + div.appendChild(button) + + e.outerHTML = div.outerHTML + + }) + } + + + function copyTextToClipboard(e) { + const clipBoardContent = e.target.value + navigator.clipboard.writeText(clipBoardContent).then(function() { + e.target.style.setProperty("--clipboard-image", "var(--clipboard-image-selected)") + }, function(err) { + console.error("Could not copy text: ", err); + }); + } + + window.addEventListener("click", (e) => { + if (e.target.classList.contains("copyToClipBoardBtn")) { + copyTextToClipboard(e) + } + }) + + window.addEventListener("mouseover", (e) => { + if (e.target.nodeName === "PRE") { + e.target.nextElementSibling.style.setProperty("--clipboard-image", "var(--clipboard-image-normal)") + } + }) + + window.addEventListener("DOMContentLoaded", updatePreTags) + + + + +} +var Temporary1; +var Temporary2; + +function HEX3Aanonymous__dochack_u1175(e_p0) { + if ((e_p0.key == "/")) { + e_p0.preventDefault(); + var searchElem_570426521 = document.getElementById("searchInput"); + searchElem_570426521.focus(); + searchElem_570426521.parentElement.scrollIntoView(); + runSearch__dochack_u1094(); + } + + + +} +var Temporary3; + +function HEX3Aanonymous__dochack_u1210(e_p0) { + hideSearch__dochack_u1090(); + + +} +var Temporary4; +var t_570425383 = window.localStorage.getItem("theme"); +if ((t_570425383 == null)) { +Temporary1 = "auto"; +} +else { +Temporary1 = t_570425383; +} + +setTheme(Temporary1); +var alternative_570426051 = [null]; +var db_570426093 = [[]]; +var contents_570426094 = [[]]; +var oldtoc_570426430 = [null]; +var timer_570426431 = [null]; +var loadIndexFut_570426433 = [null]; +Temporary2 = HEX3Aanonymous__dochack_u1175.bind(null); Temporary2.ClP_0 = HEX3Aanonymous__dochack_u1175; Temporary2.ClE_0 = null; +window.addEventListener("keypress", Temporary2, false); +Temporary3 = HEX3Aanonymous__dochack_u1210.bind(null); Temporary3.ClP_0 = HEX3Aanonymous__dochack_u1210; Temporary3.ClE_0 = null; +window.addEventListener("hashchange", Temporary3, false); +copyToClipboard(); +Temporary4 = onDOMLoaded.bind(null); Temporary4.ClP_0 = onDOMLoaded; Temporary4.ClE_0 = null; +window.addEventListener("DOMContentLoaded", Temporary4, false); diff --git a/examples/example.nim b/examples/example.nim deleted file mode 100644 index 96ce0e68d..000000000 --- a/examples/example.nim +++ /dev/null @@ -1,11 +0,0 @@ -import pylib - -let data = range(0, -10, -2) -echo data # range(0, -10, -2) -echo list(data) # [0, -2, -4, -6, -8] - -for i in range(10): - print(i, endl = " ") # 0 1 2 3 4 5 6 7 8 9 - -print("\n~~~") -print("Hello,", input("What is your name? "), endl="\n~~~\n") diff --git a/examples/example2.nim b/examples/example2.nim deleted file mode 100644 index fc672948c..000000000 --- a/examples/example2.nim +++ /dev/null @@ -1,69 +0,0 @@ -import pylib -type Customer = ref object - name: string - balance: float - -class Customer(object): - """A customer of ABC Bank with a checking account. Customers have the - following properties: - - Attributes: - name: A string representing the customer's name. - balance: A float tracking the current balance of the customer's account. - """ - - def init(self, name, balance=0.0): - """Return a Customer object whose name is *name* and starting - balance is *balance*.""" - self.name = name - self.balance = balance - - def withdraw(self, amount): - """Return the balance remaining after withdrawing *amount* - dollars.""" - if amount > self.balance: - raise newException(ValueError, "Amount greater than available balance.") - self.balance -= amount - return self.balance - - def deposit(self, amount): - """Return the balance remaining after depositing *amount* - dollars.""" - self.balance += amount - return self.balance - -let c = newCustomer("Jack", 500.0) -print("Took 250, new balance is $1.".format(c.withdraw(250.0))) -print("Added 1337, new balance is $1.".format(c.deposit(1337.0))) - - -type Shape = ref object - x, y: float - description, author: string - -# An example of a class -class Shape: - def init(self, x, y): - self.x = x - self.y = y - self.description = "This shape has not been described yet" - self.author = "Nobody has claimed to make this shape yet" - - def area(self): - return self.x * self.y - - def perimeter(self): - return 2 * self.x + 2 * self.y - - def describe(self, text): - self.description = text - - def authorName(self, text): - self.author = text - - def scaleSize(self, scale): - self.x = self.x * scale - self.y = self.y * scale - -let sh = newShape(5.0, 15.3) -print("Area is {}".format(sh.area())) diff --git a/examples/nim.cfg b/examples/nim.cfg deleted file mode 100644 index ac5825bc4..000000000 --- a/examples/nim.cfg +++ /dev/null @@ -1 +0,0 @@ ---path:"../src/" \ No newline at end of file diff --git a/examples/readme.nim b/examples/readme.nim deleted file mode 100644 index 1faca76e4..000000000 --- a/examples/readme.nim +++ /dev/null @@ -1,171 +0,0 @@ -import pylib -from pylib/Lib/timeit import timeit -from pylib/Lib/time import sleep -from pylib/Lib/sys import nil # like python's `import sys` -from pylib/Lib/platform import nil # like python's `import platform` -import pylib/Lib/tempfile -# like python's `import tempfile; from tempfile import *` -# more python-stdlib in pylib/Lib/... - -print 42 # print can be used with and without parenthesis too, like Python2. - -# NOTE: from now on, the following is just valid Python3 code! -# only add the following to make it Python: -# import platform -# from timeit import timeit -# from time import sleep -# from tempfile import NamedTemporaryFile, TemporaryDirectory -print( f"{9.0} Hello {42} World {1 + 2}" ) # Python-like string interpolation - -class O: - @staticmethod - def f(): - print("O.f") - -O.f() - -def show_range_list(): - python_like_range = range(0, -10, -2) - print(list(python_like_range)[1:-1]) # [-2, -4, -6] -show_range_list() - -# Why using so many `def`s? -# as in `def`, you can write Nim more Python-like -# e.g. nondeclared assignment -# and all collection literals becomes Python's type - -# func definition -# typing is suppported and optional -def foo(a: int, b = 1, *args) -> int: - def add(a, b): return a + b # nesting - for i in args: print(i) - return add(a, b) - -def show_literals(): - ls = [1, 2] # if outside `def`, `ls` will be an Nim's `array`, - # which is fixed size and "pass by value" - ls_shallow = ls - ls.append(3) - assert len(ls_shallow) == 3 - - s = {"Rachel", "Zack"} # if outside `def`, `s` will be an Nim's `set`, - # which only supports small ordinal type as elements - s.add("Zack") - assert len(s) == 2 - - d = { # if outside `def`, `d` will be an Nim's `array[I, (K, V)]`, - # which even lacks `__getitem__` method - 'a': "kaneki ken" - } - - assert d['a'].title() == "Kaneki Ken" # if outside `def`, - # all double-quotation marked literals will be Nim's `string`, - # which is more like `bytearray` - # and single-quotation marked literals will be Nim's `char`, - # which repesents a single byte (ASCII character) - -show_literals() - - -# python 3.12's type statement -type Number = float | int # which is originally supported by nim-lang itself, however ;) - -for i in range(10): - # 0 1 2 3 4 5 6 7 8 9 - print(i, endl=" ") -print("done!") - -# Python-like variable unpacking -def show_unpack(): - data = list(range(3, 15, 2)) - (first, second, *rest, last) = data - assert (first + second + last) == (3 + 5 + 13) - -show_unpack() - -if (a := 6) > 5: - assert a == 6 - -print("a".center(9)) # " a " - -print("" or "b") # "b" -print("a" or "b") # "a" - -print(not "") # True - -print("Hello,", input("What is your name? "), endl="\n~\n") - -def show_divmod_and_unpack(integer_bytes): - (kilo, bite) = divmod(integer_bytes, 1_024) - (mega, kilo) = divmod(kilo, 1_024) - (giga, mega) = divmod(mega, 1_024) -show_divmod_and_unpack(2_313_354_324) - -def lambda_closure(arg): - anno = lambda: "hello " + arg - return anno() -assert lambda_closure("world") == "hello world" - -print(sys.platform) # "linux" - -print(platform.machine) # "x86_64" - -def allAny(): - truty = all([True, True, False]) - print(truty) # False - - truty = any([True, True, False]) - print(truty) # True -allAny() - -def a_little_sleep(): - "sleep around 0.001 milsecs." - # note Nim's os.sleep's unit is milsec, - # while Python's time.sleep's is second. - sleep(0.001) - -assert timeit(a_little_sleep, number=1000) > 1.0 - -# Support for Python-like with statements -# All objects are closed at the end of the with statement -def test_open(): - with open("some_file.txt", 'w') as file: - _ = file.write("hello world!") - - with open("some_file.txt", 'r') as file: - while True: - s = file.readline() - if s == "": break - print(s) - -test_open() - -def show_tempfile(): - with NamedTemporaryFile() as file: - _ = file.write(b"test!") # in binary mode - - with TemporaryDirectory() as name: - print(name) - -show_tempfile() - -class Example(object): # Mimic simple Python "classes". - """Example class with Python-ish Nim syntax!.""" - start: int - stop: int - step: int - def init(self, start, stop, step=1): - self.start = start - self.stop = stop - self.step = step - - def stopit(self, argument): - """Example function with Python-ish Nim syntax.""" - self.stop = argument - return self.stop - -def exa(): - e = Example(5, 3) - print(e.stopit(5)) - -exa() diff --git a/index.html b/index.html new file mode 100644 index 000000000..025a877a8 --- /dev/null +++ b/index.html @@ -0,0 +1,156 @@ + + + + + + + +src/pylib + + + + + + + + + + + + + + + + +
+
+

src/pylib

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

Welcome to NimPyLib 0.9.11

+ + +

Nim Pylib

Just write Python code in Nim!

+ +

import pylib

The mostly suggested style is

+

import pkg/pylib

+

However, omitting the pkg/ prefix shall be fine at most cases:

+

import pylib

+ +

import Python-like stdlib

Cheatsheet for rough alternative between pylib and Python

+ + + + +
Nim pylibPython
from pylib/Lib/LIB import nilimport LIB
import pylib/Lib/LIBfrom LIB import *
from pylib/Lib/LIB import XXXimport LIB; from LIB import XXX

+

Wondering how many libs are available in NimPylib?

+

Here are the Lib Docs.

+
Warning: +std/lenientops was imported automatically. Compile with -d:pylibNoLenient to disable it if you wish to do int->float conversions yourself
+

+ +
+

Templates

+
+
+
+
template timeit(repetitions: int; statements: untyped): untyped {....deprecated: "will be removed from main pylib since 0.10, import it from `pylib/Lib` instead".}
+
+
+ Deprecated: will be removed from main pylib since 0.10, import it from `pylib/Lib` instead +
+ +

EXT.

+

Mimics Pythons timeit.timeit(), output shows more information than Pythons.

+ + Source   +Edit   + +
+
+ +
+ +
+
+
+

Exports

+
+ write, close, read, read, close, readline, initBufAsPy, readline, write, open, readline, readline, truncate, truncate, read, close, readline, readline, read, write, open, read, seek, read, seek, None, NoneType, or, or, and, not, or, PyBool, ==, bool, toBool, toNimBool, ==, and, repr, pybool, not, and, $, True, is, False, ==, or, and, any, pybool, xor, all, min, upper, center, <=, maketrans, repr, min, float, rindex, -=, ==, -, find, ascii, count, int, len, +=, partition, fr, reversed, endsWith, maketrans, checkLenientOps, msg, float, items, osErrorMsgWithPath, min, bytes, remove, slice, raiseExcWithPath, str, clear, filter, [], rindex, format, TranslateTableVal, id, PyByteArray, <=, ==, repr, isdigit, zip, round, print, ==, PyFrozenSet, getPtr, [], byteLen, ascii, rstrip, replace, clear, repr, endsWith, count, indices, contains, ConnectionResetError, GeneratorExit, int, newPyOSError, TranslateTableABC, $, ==, slice, &, len, repr, iter, set, $, raiseErrno, zip, len, +=, bytearray, startsWith, dirImpl, $, toPyDict, max, pyrepr, reversed, <, chars, endsWith, hash, $, contains, pow, newPyList, toNimString, bytes, pydiscard, maketrans, PermissionError, isascii, count, msg, delitem, pyset, float, repr, sorted, items, [], imag=, TranslateValType, osErrorMsgWithPath, round, newPyList, raiseExcWithPath2, /, rstrip, **, *, $, items, lstrip, min, iter, and, clear, bytearray, [], pow, raiseExcWithPath, hasattr, set, *=, []=, rsplit, Fr, istitle, /, FileNotFoundError, map, count, -, min, -, len, setdefault, ==, contains, ==, PyComplex, len, startsWith, []=, real=, BytesLike, FileExistsError, substr, $, toPyStr, splitlines, +, PyDictItemView, split, islower, endsWith, +=, pop, rjust, join, upper, b, /, $, checked_as_integer_ratio, append, issubset, remove, +=, as_integer_ratio, ==, nextImpl, input, repr, newStopIteration, TranslateTable, IsADirectoryError, zip, PyTComplex, lower, <, pyset, isascii, or, round, *, newPyFrozenSet, PyOSError, *=, int, casefold, delitem, repr, +, PyRange, getattr, -, lower, ==, *, add, getattr, ==, newPySet, hex, union, split, ==, pybytes, str, pow, SomePyDictView, isinstance, **, hex, format, sort, difference, max, extend, rpartition, +=, <=, UnicodeError, delitem, symmetric_difference, ProcessLookupError, PyBytes, [], ArithmeticError, set, rb, bytearray, contains, [], split, intersection, symmetric_difference, isspace, str, ascii, mitems, startsWith, rstrip, isalpha, pow, imag, real, to_bytes, NoneType, +, **=, complex, title, replace, len, difference, endsWith, split, count, *, |=, []=, ==, +, repr, abs, errnoMsg, toPySlice, bit_length, b, splitlines, intersection, count, $, items, -=, runeAtPos, +, frozenset, union, ljust, pairs, max, min, PySlice, PyOSError, contains, ZeroDivisionError, <, ChildProcessError, startsWith, add_from_bytes, translate, TypeError, clear, NameError, items, center, dict, KeyboardInterrupt, rsplit, $, pop, +=, +=, int, toNimStr, max, getCharPtr, TypedTranslateTableABC, SomeSinglePyDictView, items, index, isdisjoint, delitem, PyList, NotADirectoryError, symmetric_difference, NotImplementedError, ord1, max, newPyListOfCap, <=, ascii, $, -=, bit_count, int, delitem, reversed, items, hash, slice, [], format, [], delitem, set, iter, chars, repr, Rb, pycomplex, sorted, +, tryOsOp, iter, bytearray, pow, ==, []=, PyDictView, str, repr, min, reverse, PyDictKeyView, rjust, as_integer_ratio, &=, <, casefold, repr, startsWith, frozenset, split, isupper, istitle, max, +=, symmetric_difference, set, bytearray, intersection, hasChar, startsWith, difference_update, oct, +, difference, index, +, SomePySet, partition, +, StopAsyncIteration, toPyDict, index, max, center, int, <, pow, str, rjust, startsWith, reversed, +, isalpha, <, newBlockingIOError, pow, chars, hash, <=, complex, conjugate, discard, br, translate, newUnicodeDecodeError, hash, hash, hash, get, [], reverse, hex, pysetLit, dir, PyDict, bytes, TimeoutError, ljust, TranslateAction, ord, to_chars, toNimComplex, pow, find, complex, is_integer, next, rf, []=, +, StringLike, newPyListOfStr, newPyList, /=, contains, **, endsWith, toNimString, translate, bytes, SomeSet, newUnicodeDecodeError, replace, float_fromhex, removeprefix, toPyBytes, len, sorted, hash, maketrans, newPyList, map, hex, get, Comparable, [], rsplit, <, int, list, PyIterator, count, range, *, update, chr, endsWith, complex, filter, removesuffix, delitem, dir, StopIteration, []=, J, pyset, []=, float, union, count, bytes, ==, rsplit, repr, getattr, popitem, newPyIterator, +, replace, items, contains, newPyOSError, $, repr, ljust, [], ord, **, $, toPyStr, byteLen, pow, copy, newPyList, len, /=, InterruptedError, /, $, @, nextImpl, newStopIteration, startsWith, isascii, *=, +, *, endsWith, pow, **, sort, rpartition, getCharPtr, isspace, as_someinteger_ratio, to_bytes, complex, count, $, splitlines, frozenset, is_integer, items, $, expandtabs, from_bytes, items, AttributeError, Rf, tryOsOp, -=, ==, lstrip, ==, +, []=, []=, frozenset, RuntimeError, PyDictValueView, union, rstrip, runes, StrTypedTranslateTable, newBlockingIOError, not, contains, None, bytes, ljust, find, newPyListOfStr, intersection_update, values, endsWith, UnicodeDecodeError, rsplit, list, range, zfill, min, bytearray, contains, **, endsWith, PyOSError, issuperset, |, from_bytes, tryOsOp, Br, noWeirdTarget, toNimString, raiseExcWithPath, keys, [], bytes, toNimSlice, list, pow, fromhex, translate, raiseExcWithPath, bytes, list, bytes, enumerate, <=, setattr, -, enumerate, 'j, long, filter, round, getChar, *=, newPyByteArray, []=, setattr, rfind, -, union, startsWith, items, split, <=, substr, ConnectionRefusedError, translate, bin, BlockingIOError, copy, u, set, PySlice1, difference, strip, StopIterationT, long, removeprefix, frozenset, *, insert, issubclass, rindex, center, raiseErrnoT, str, filter, /, round, split, $, nimArrayAsList, dirImpl, getChar, ConnectionError, hash, toNimString, count, *=, repr, contains, newPyList, lstrip, -, hasattr, strip, map, capitalize, len, []=, pop, split, +=, pop, append, +=, rfind, pyset, newPyFrozenSet, int, or, capitalize, ==, -, hex, extend, BlockingIOError, items, contains, title, *, intersection, min, [], tryOsOp, +=, items, ==, iter, emptyPyDict, pycomplex, <=, items, substr, PyStr, <, len, isupper, max, index, startsWith, BrokenPipeError, index, int, rjust, hash, conjugate, translate, reverse, next, runeLenAt, /=, list, BlockingIOError, PyLibKey, update, []=, count, getattr, newPyByteArray, range, $, toPyStr, copy, @, u, *, |=, splitlines, expandtabs, ==, ==, not, values, hex, rsplit, |, zfill, keys, fromhex, raiseErrnoWithPath, long, getChar, strip, rfind, strip, newPySet, symmetric_difference, <, removesuffix, islower, lstrip, pop, PySet, extend, <>, ConnectionAbortedError, setLen, intersection, SystemExit, +=, items, iter, max, hash, [], fspath, []=, newPyByteArray, *, j, pop, <=, frozenset, long, f, pyset, join, difference, translate, NimInt, fspath, *, ^, items, nimint, insert, /, <<, %, <>, <, &, **, &=, **, <, %, ==, <=, |, <<=, **, ^, <=, **, ==, >>=, //=, |=, ~, %, ==, divmod, >>, <>, //, **=, **, ^=, %=, osErrorMsgWithPath, raiseExcWithPath2, RuntimeError, AttributeError, newStopIteration, ConnectionError, BlockingIOError, GeneratorExit, newUnicodeDecodeError, ChildProcessError, newBlockingIOError, raiseErrnoWithPath, InterruptedError, $, NotADirectoryError, newStopIteration, errnoMsg, NotImplementedError, BrokenPipeError, TimeoutError, UnicodeError, TypeError, msg, raiseExcWithPath, osErrorMsgWithPath, UnicodeDecodeError, raiseErrno, tryOsOp, ConnectionRefusedError, IsADirectoryError, raiseExcWithPath, noWeirdTarget, $, ArithmeticError, tryOsOp, BlockingIOError, StopAsyncIteration, PyOSError, ConnectionAbortedError, raiseErrnoT, SystemExit, tryOsOp, FileNotFoundError, PyOSError, ConnectionResetError, BlockingIOError, StopIterationT, tryOsOp, PyOSError, NameError, newBlockingIOError, $, KeyboardInterrupt, raiseExcWithPath, newUnicodeDecodeError, newPyOSError, StopIteration, PermissionError, ProcessLookupError, msg, FileExistsError, newPyOSError, raiseExcWithPath, ZeroDivisionError, async, define, init_subclass, def, new, lambda, PySignatureSupportGenerics, unpack, pass, with, del, :=, class, tonim +
+
+ +
+
+ + +
+
+ + + diff --git a/nimdoc.out.css b/nimdoc.out.css new file mode 100644 index 000000000..d50f766ed --- /dev/null +++ b/nimdoc.out.css @@ -0,0 +1,1035 @@ +/* +Stylesheet for use with Docutils/rst2html. + +See http://docutils.sf.net/docs/howto/html-stylesheets.html for how to +customize this style sheet. + +Modified from Chad Skeeters' rst2html-style +https://bitbucket.org/cskeeters/rst2html-style/ + +Modified by Boyd Greenfield and narimiran +*/ + +:root { + --primary-background: #fff; + --secondary-background: ghostwhite; + --third-background: #e8e8e8; + --info-background: #50c050; + --warning-background: #c0a000; + --error-background: #e04040; + --border: #dde; + --text: #222; + --anchor: #07b; + --anchor-focus: #607c9f; + --input-focus: #1fa0eb; + --strong: #3c3c3c; + --hint: #9A9A9A; + --nim-sprite-base64: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAN4AAAA9CAYAAADCt9ebAAAACXBIWXMAAAsTAAALEwEAmpwYAAAFFmlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgNS42LWMxNDggNzkuMTY0MDM2LCAyMDE5LzA4LzEzLTAxOjA2OjU3ICAgICAgICAiPiA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPiA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtbG5zOmRjPSJodHRwOi8vcHVybC5vcmcvZGMvZWxlbWVudHMvMS4xLyIgeG1sbnM6cGhvdG9zaG9wPSJodHRwOi8vbnMuYWRvYmUuY29tL3Bob3Rvc2hvcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RFdnQ9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZUV2ZW50IyIgeG1wOkNyZWF0b3JUb29sPSJBZG9iZSBQaG90b3Nob3AgMjEuMCAoV2luZG93cykiIHhtcDpDcmVhdGVEYXRlPSIyMDE5LTEyLTAzVDAxOjAzOjQ4KzAxOjAwIiB4bXA6TW9kaWZ5RGF0ZT0iMjAxOS0xMi0wM1QwMjoyODo0MSswMTowMCIgeG1wOk1ldGFkYXRhRGF0ZT0iMjAxOS0xMi0wM1QwMjoyODo0MSswMTowMCIgZGM6Zm9ybWF0PSJpbWFnZS9wbmciIHBob3Rvc2hvcDpDb2xvck1vZGU9IjMiIHBob3Rvc2hvcDpJQ0NQcm9maWxlPSJzUkdCIElFQzYxOTY2LTIuMSIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDozMzM0ZjAxYS0yMDExLWE1NGQtOTVjNy1iOTgxMDFlMDFhMmEiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6MzMzNGYwMWEtMjAxMS1hNTRkLTk1YzctYjk4MTAxZTAxYTJhIiB4bXBNTTpPcmlnaW5hbERvY3VtZW50SUQ9InhtcC5kaWQ6MzMzNGYwMWEtMjAxMS1hNTRkLTk1YzctYjk4MTAxZTAxYTJhIj4gPHhtcE1NOkhpc3Rvcnk+IDxyZGY6U2VxPiA8cmRmOmxpIHN0RXZ0OmFjdGlvbj0iY3JlYXRlZCIgc3RFdnQ6aW5zdGFuY2VJRD0ieG1wLmlpZDozMzM0ZjAxYS0yMDExLWE1NGQtOTVjNy1iOTgxMDFlMDFhMmEiIHN0RXZ0OndoZW49IjIwMTktMTItMDNUMDE6MDM6NDgrMDE6MDAiIHN0RXZ0OnNvZnR3YXJlQWdlbnQ9IkFkb2JlIFBob3Rvc2hvcCAyMS4wIChXaW5kb3dzKSIvPiA8L3JkZjpTZXE+IDwveG1wTU06SGlzdG9yeT4gPC9yZGY6RGVzY3JpcHRpb24+IDwvcmRmOlJERj4gPC94OnhtcG1ldGE+IDw/eHBhY2tldCBlbmQ9InIiPz4PsixkAAAJ5klEQVR4nO2dfbBUZR3HP3vvxVD0zo0ACXxBuQMoQjJ1DfMl0NIhNcuSZqQhfGt6UWtK06xJexkrmywVRTQlHCIdtclC0zBJvYIvvEUgZpc3XyC7RVbKlQu1/fHdbc+uu2fPOfs85+y55/nMnBl2z+5zfnc5v/M8z+8119XVRYroAG4HfgvMT1YUR4MMAa4HLkhakCRoSVqAELwLeBY4C7gF+D6QS1QiR1ROAJ4Dzk9akKQwoXhtwL4GxvHjU8AKoNPz3leAu4HBFq+bAyZZHD9rDAK+BywDDklYlkQxoXhfAtYAEw2MVckQYBHwU6or99nA08BBFq49GngUeBIYaWH8rNEJdAOXA60Jy5I4jSreSOBKYDzwBPCJhiUqcSjwe2BWnc9NLnxuvMFrnwqsAqYBBwBfNzh2FpmNfs9jkhakWcg1aFxZiH5UL3cDnwf+Xue7BwFjgFHAOwuv24tyob3cO0LIshP4EbCn8Pq/wKvA9sLxMvCvOmPsA1yDZnHv/nEv2mM+F0IeR4m8z7lM7tMbUbzj0CxX7YfbAXwaWFJ4PRrNIu9FS9KJyEIZN68CG4DnkRJtLBw7gHHAYuDdNb77EDAjBhkHIk7xKoiqeK3IwjilzuceQJvoZjdQ/AMZaeoZiWYgBXSEwyleBW0Rv3cR9ZUO4LSI48fN2wN+bi5wJNBvUZaBSCaVy48oxpVhwDdMC5ISxpJRh6/DLGEUrxXt29YBQ+2IkwquR76ofZIWxJFegireNLSnm48skFmmDfmiVgJHJyuKI620ADOpbWEcDPwYOZKD7OmyxCTkXL+wzueOiEEWR8poQb60V4A7kLm/yFjgKeALuM1xLfYDbkX+zEGe98cAX0Oui6viF8vR7OS6urragW2UZr21wK+Aiwlu7XPoN3sYOAd4H6WH1SnA0qSEcjQnRT/e1bgnsw16kGPez4/lyCBF48oNwL+TFGSAsgCndI4qFBVvJ0owdZhjL3CnxfHzBo8+YBMyol0CHBijrKbHS/LoA7Yio9sPgJNr/QHekLGR6MffL+KP4SjnHmQxtoXNmbQP+CHyV75hYDzTIWNpWkU8iR5mq71vVsZqXgtcFqNQ/wG2IOtfD8oi6AX+Ujj+isKz8sBrnu+1okyGdmD/wnEgcDClTIdRyJRvI1cvCMciq7At4rj5eoCPAusbHCfLigda/VyKgi+AtyreMGAzykGzQQ/wO+BxSlkCuy1dq8hw5OieUjimYT+x9bHCdWwS1823Ez1EXmhgjKwrXpHzkduuanbCtzGX+NkPPAj8GincNkPjNkIO5dadUjiOB95m+BonopQpm8R58/0JJbHWy2eshVM8sRvdbyurKV4Hmoka2WA/iwwLP6d+QmzSdKC92GzK/W9R+Q3woQbHCELcN991wJcjftcpXolngKm18vFmoVonYcgDv0Qz5pqGREuOTuA8lPYUZbndh0LJNpkUqgZx33xvomim7RG+6xSvnOm1gqQXoyiMoKxFs8VZpFfpQHvQK4HDUPnAsBa9bxGP0tUjF+IYCkxFew+/G3owdq20pgjzt3uPRscs/o43IaOhH2f4ZaAPRyZQP6vgbuCbyGext87F0sgIZFI/N8BnlwBnolovcWAjq/uzwM0+55cBJ0UYN84ZL+rfbnLMM4FfUDv7Z1XlCe8FetETbleNL7+CZrnvMjCVDuTOOA84Hf+96ga0PC8qXY50FQsuMg+41+d8p885R4n7gdt8zo+qvDkmUF4fZQXwEbS+99KDMhlWkw0eALqQglXyDDCdcovf+4lv5jPNXJ9zWc/FDMMdPudGVCreRlTWwVtWbynwYVQQCFSp61Q042WJLUjB1nneuw8tvXo97x1Lugvg+j1Mo9boySLVHtJFWqsthx5GlbSGeN5bigrHdqPl52Zj4qWLXvTQWY4KOX2ccgPMBLRcuy9+0YzhguXN4GuYq2Zc2R/NZg+hfYt3/9ZCepdQthmB4vIWIYOTbWyWzGt2Y0izG1fqjlltxnsdpbPMRMmd3lqTTumqMw7FZY5G5mSHw5dalreiRWYGWjbZ7gYUlFa0xOtIWA4vk1E6zWEoI+FvyYrjSAO1FG8DCmQGKd+DJFsGogWVVFiP/GWbga9Svg9NgtPQvnd04fUNCcriSBF+vqZ5nn9PQ+Xs4q401oI6EP0R+BkyXoAeAtcgBfwidnvkVaMVFTO6n1JoWTfqiONw1MVP8e6l3GVwOPJZXW5VItGGiuduAu5CZdOrMQJ1CHqpIFccS+LxaD/3Hcr7vF0Xw7UdAwQ/xduLGkJ6aUMhVAuwU006B3wM+ZLmozJ5QRhWkGs9yjKw1fhwDsq8eE/F+y+i1CeHIxD1wppupXrA5xyUOjQHMzU3cyjTeS2aaaN2Fzoc1bhch3xspuqBTkDulQVUz1q4mYEbNuewQD3FexGFS1VjOLoRHwOOinj9HAooXY2CSidHHKeSI5GFcRWNdSxqR7VH1iHHeTV24R+X53C8hSCBvPPqnD8B+AOygn6OYAm0ORSGthLl8B0d4DtRmIKsoMsJF1U/Hi1dt6DusIN8PrsIlUdwOAITpDFlC6q3MTbgmHm011qGepOvQSXPipyOCujW6rxqk0dRWYsVFe8PRSn5JxWOoEvdfOGzfnF5tnCRK+bGi33MoB1hL0U5d1H5J5oVD6A5mp8sQS6KSWh5e0jEcR4BPmhKqJA4xTM3XuxjBlW8DuRacDU3y0myNbNTPHPjxT5m0GTN15A/zVFiI+HKYzgc/ydMlrRfgmQWuYn0F91xJEQYxVuDnMcOrQAWJi2EI72ErQviwqLEQpQ+5XBEIqzi3YWLwF+BMiMcjshEqYR1Gdk1KmxBsaR9SQviSDdRFK8fxVU+YliWZmcbcq7vSFoQR/qJWvuxD0WgLDYoSzPzAqowtjVhORwDhEaKru4GPoliGgcyy4Hj0DLT4TBCo9WO88jQ8Bns97lLghvRTOfqqDiMYqrM+HyUYdBtaLykeRmlK12C9rQOh1FM1vd/HqUIzaT5e+LVoh/VxByHShs6HFaw0VjjHhTxP5d0LT+fRnu5q3HuAodlbHW02Q5cDByM+sw1642cRylCx6PeZiuTFScUFxK+f19QovaRS+t4tsasxhvABbZbSfUCV6CM7qtQl6Fm4E1U22UqcAYqvZ42fgJMxH6vdYc5nkBlSW6Pq4fbS6hb6jg0u9yGug7FyS5U1+UcVBbwbFSuMM1sQ1bXK4A9CcviqM0e9H80HdUxCpwIa4McygA/GfgAcCJqmGKKXUixupEv7nHsLc2agWNQ0d9OzC+PHNHIo1XeLCoe8kkqXiUtwKFoWXoEKqk3BpWLaC8cXsV8HT1J+tFTZKvn+DMqFZi1knvtyKg1O2lBHADcCVxEedNSAP4HJcsr0NNWHVUAAAAASUVORK5CYII="); + + --keyword: #5e8f60; + --identifier: #222; + --comment: #484a86; + --operator: #155da4; + --punctuation: black; + --other: black; + --escapeSequence: #c4891b; + --number: #252dbe; + --literal: #a4255b; + --program: #6060c0; + --option: #508000; + --raw-data: #a4255b; + + --clipboard-image-normal: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' style='color: black' fill='none' viewBox='0 0 24 24' stroke='currentColor'%3E %3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2' /%3E %3C/svg%3E"); + --clipboard-image-selected: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' style='color: black' viewBox='0 0 20 20' fill='currentColor'%3E %3Cpath d='M8 3a1 1 0 011-1h2a1 1 0 110 2H9a1 1 0 01-1-1z' /%3E %3Cpath d='M6 3a2 2 0 00-2 2v11a2 2 0 002 2h8a2 2 0 002-2V5a2 2 0 00-2-2 3 3 0 01-3 3H9a3 3 0 01-3-3z' /%3E %3C/svg%3E"); + --clipboard-image: var(--clipboard-image-normal) +} + +[data-theme="dark"] { + --primary-background: #171921; + --secondary-background: #1e202a; + --third-background: #2b2e3b; + --info-background: #008000; + --warning-background: #807000; + --error-background: #c03000; + --border: #0e1014; + --text: #fff; + --anchor: #8be9fd; + --anchor-focus: #8be9fd; + --input-focus: #8be9fd; + --strong: #bd93f9; + --hint: #7A7C85; + --nim-sprite-base64: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAARMAAABMCAYAAABOBlMuAAAACXBIWXMAAAsTAAALEwEAmpwYAAAFFmlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgNS42LWMxNDggNzkuMTY0MDM2LCAyMDE5LzA4LzEzLTAxOjA2OjU3ICAgICAgICAiPiA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPiA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtbG5zOmRjPSJodHRwOi8vcHVybC5vcmcvZGMvZWxlbWVudHMvMS4xLyIgeG1sbnM6cGhvdG9zaG9wPSJodHRwOi8vbnMuYWRvYmUuY29tL3Bob3Rvc2hvcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RFdnQ9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZUV2ZW50IyIgeG1wOkNyZWF0b3JUb29sPSJBZG9iZSBQaG90b3Nob3AgMjEuMCAoV2luZG93cykiIHhtcDpDcmVhdGVEYXRlPSIyMDE5LTEyLTAzVDAxOjE4OjIyKzAxOjAwIiB4bXA6TW9kaWZ5RGF0ZT0iMjAxOS0xMi0wM1QwMToyMDoxMCswMTowMCIgeG1wOk1ldGFkYXRhRGF0ZT0iMjAxOS0xMi0wM1QwMToyMDoxMCswMTowMCIgZGM6Zm9ybWF0PSJpbWFnZS9wbmciIHBob3Rvc2hvcDpDb2xvck1vZGU9IjMiIHBob3Rvc2hvcDpJQ0NQcm9maWxlPSJzUkdCIElFQzYxOTY2LTIuMSIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDplZGViMzU3MC1iNmZjLWQyNDQtYTExZi0yMjc5YmY4NDNhYTAiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6ZWRlYjM1NzAtYjZmYy1kMjQ0LWExMWYtMjI3OWJmODQzYWEwIiB4bXBNTTpPcmlnaW5hbERvY3VtZW50SUQ9InhtcC5kaWQ6ZWRlYjM1NzAtYjZmYy1kMjQ0LWExMWYtMjI3OWJmODQzYWEwIj4gPHhtcE1NOkhpc3Rvcnk+IDxyZGY6U2VxPiA8cmRmOmxpIHN0RXZ0OmFjdGlvbj0iY3JlYXRlZCIgc3RFdnQ6aW5zdGFuY2VJRD0ieG1wLmlpZDplZGViMzU3MC1iNmZjLWQyNDQtYTExZi0yMjc5YmY4NDNhYTAiIHN0RXZ0OndoZW49IjIwMTktMTItMDNUMDE6MTg6MjIrMDE6MDAiIHN0RXZ0OnNvZnR3YXJlQWdlbnQ9IkFkb2JlIFBob3Rvc2hvcCAyMS4wIChXaW5kb3dzKSIvPiA8L3JkZjpTZXE+IDwveG1wTU06SGlzdG9yeT4gPC9yZGY6RGVzY3JpcHRpb24+IDwvcmRmOlJERj4gPC94OnhtcG1ldGE+IDw/eHBhY2tldCBlbmQ9InIiPz4JZNR8AAAfG0lEQVR4nO2deViTZ7r/7yxkJaxJ2MK+GCBAMCwS1kgUFQSKK4XWWqsz1jpjp3b0tDP1V+eqU391fqfT/mpPPd20drTFDS0KFEVWJSGAEgLIZpAICBJACIRs549Rj1WILAkBfD/XlevySp68z/0S3+/7vPdzLyidTgcLkU2bd+z39/f/q1gshsrKSoJELFCa2iaEuU9K6kb+8uXxv54/fzE8L/eswNT2zCfQpjbAGKS8lPFKSEjIXiaTCSEhIeDj4xNnapsQ5j6rktZGp6UlfxIdzQVzCplmanvmG1hTG2BIAtlc26CgoDfT0tL2e3l5AQCAjY0NkMnk/a9s2k6rrKw8UV8n1JjYTIQ5RlAw14KzmL3xze1vfJyUuMJaq9UCFovFm9qu+YbBxcSPFUYkk8l2Q0NDsvo6ocrQx5+I8Ih4bz6f/0l8fHyKlZXV4/dRKBQwmcwwMpn8A4FAoPgHhH9bV1sxa488wZxoaycnJ/a9e/duCa5fkc3WvAiTI4Ib77p+XdqHG9anbfLy8gAAgLGxMdBpF+bjvzExqJj4scKI0dHRnwQHB++orq7+AgDeMuTxJ2Jl4rqU9PT0EwEBAUQCgTDuGAaDAampqYepVKpHUHDk325Ulw0a266YuFW+Gzdu/MDPz29jfn7+XgA4aOw5ESZP6kvpCXv3vnM8NiaSamVl+fj9BepGNDoGFRN7e/slcXFxO1xcXMDJyWnH7j//H/fi4uJdgutXmgw5z5O8smn7X9euXbvf29sbMBjMhONQKBRYWVlBbGzsbjMzM3JoOG+/sKKwy1h2rd/4elpGRsYuLy+vaDweD2w2Oy1h5ZrCvEunEaeeiVnMiabyl/F2/+X9P+8JDPQHHA5napMWBAYTk6DgSNuEhIS9DAYDAP7tq1i6dOkqOp3OWbNu0wens44emeoxA9lcWwKBYEMkEm2JRKIdHo+3QKFQWJ1Op8ZgMER3d/dVq1evTnFycpr0MSkUCsTExGzH4/Gk1LTME/39/TI0Go1FoVCg1WrVY2NjipGRkcGRkRH5dPwrEZHLXMPCwjJSUlIy3dzcfB+97+rqGhYSEpIOAIiYmBguN3zL77dt3uPh4W5qUxYUBhMTb2/vjeHh4cvR6P/dILK0tITIyEg7BweHr363/Z3Ampqaf1Zcu/zMKiVsyVJvMplsRyKR7IhEor2FhYUbhUJhJCYm2pFIJB6JRAIymQx4PB7QaDRoNBowMzMDJycnwOOn7icjEokQGxu7icFgbLp///7jFY1WqwWlUgkjIyOgUCgO7Ni5Rz48PCwfHh7uGRkZeaBQKOSjo6ODCoVCXlNVKn/6uCsT13FXrVr1emho6BYKhfLMnP7+/omrU9LPX8g+UThloxEMxqJFXjxESAyPQcSEExrLWLNmzW57e/txP/fw8ABHR8cdDAaDt3xF2ru9vb03sVgs0cbGxs/FxWVZUlISj0aj+dna2oKtrS1M5PcwJCgUCry8vODRrs84vPfoH6OjoyCXy6Gvr+/R6+CWrX9s7evrk/b19bWr1Wqli4sLZ8OGDe95eXmxUSjUuAd0cHDwjoqK2sYKXFIhvnldYYTTQpgU4/8+jyASCYDGoCd+ZkYYF8OICYezl8PhuOkbQyAQIDo62s/NzS2np6cHbGxsgEajAYFAAAwGA1gsFia6CE0NgUAABwcHsLe3B61WC2q1eo9WqwWNRgNKpRLUajUQiUSgUCh6zwGHwwGTydzo5+eXBQBnZu8MEJ5keHhYPqyYWMtHR0ZBpVIhYj9FUDONgOUvT12+du3avMDAQJjssdRqNWCxCyrEZdLodDoQi8Ulx44de628NL/V1Pa8iERE8l2dHB2CJvpcq9Nqbt1qKURWj1Njxld0ZGTkAW9v70kLCQC8sEIC8O/HKx8fn2gmk8kHgCk7pRFmzrWyAikASE1tx0Jj2uH0EZHL/N7YtuvT4OBgzmz4OBYSeDweIiMjt2S++vtMP1YYEmmJsCCY8mNOIJtr6+zsHBcZGXmIw+G4mZubG8m0hU9HRwcUFxe/KxQKTyDRsQjznSmJCS9+dVRERMTfQ0NDo2xtbfUGiSFMjtHRUaitrc3Jzc09kHvxVLmp7UFAmC6oZQkvrZLL5RJhReHtiQb5scKIXC7371FRUX90dnYGIpE4JR8Jgn40Gg20t7fXFxYWfnr9+vWjz8sdYi+Osh4vzgUBwZSgtu94V+fs7Hx7YGCgra6u7khLS0u2RCwYeTQgKmYFh8fj/f/g4OAldnZ2prR1wdPd3Q1CofBQSUnJkdLi3N8E93FCY6k+Pj48FxcXjlar1ZSWlh65VvYr4kREmDNg79+/D3FxcW5OTk5uXl5evNbW1tL0jK3ZXV1d1ykUintycvInoaGhdkj+gvGxs7MDPp+/m0AgWMQvS/lyeHhYTqPRPJycnIJSU1NZ3t7eW2g0Gly/fv2oWq1Gij0hzClQ/gHhpLS0tEM8Hm/7I8Ho7++HlpYWsLa2Bg8PDxOb+OKhUCigqakJ7t+/D25ubuDu7g4oFAp0Oh08ePAAvv7666TTWUdzTG0nAsKTYMU3ryuSU18+4+bmFrZo0SIOAICVlRUsXrx4zkakLnRIJBI8CgJ8MtdJp9NBZ2enqL29XWRC8xAQxgUNAHD+3L8KGhoaCp78ABES04JCoX4jJAAAAwMDUFtbe96YpRMQEKbL41DU5ubmko6Ojj2PSgggzD36+/vrb9y4cX425zzw93/8EBjon2is44+NjSkePBjqGRwc7G5v7xBV19w8U5B/3qgrr9+/uWtXUuKKD/TZ9MXh/066/OuFmunO8dGBQ98HBbGSp/t9U6LRaDXK0dHBoeFhuVzeL22/0yFqamopufjLqRJ933ssJi0tLSXV1dWHGAzGbuObOzs8ubqa71vZKpUKOjo6blwpOF8zm/Mu5cVkLlkSaswprAHAaVihgK7O7oSGxltvfXLon3nXK4RHT2cdN4pfKDCAlZyUuMJan02nTmczAaBmunPw4qI3cbnh0/36XICq0+lgcPABp7OrK629vUP5z8++LLh2XXD05L++yxrvC4/F5EZ12WBS8saLS5Ys2U2lUufUY45SqQSlUgkqlQrUavXj19jYGGg0GtBoNKDT6UCn05VotVq1TqfToFAojFar1eh0Og0Wi8XhcDgeGo1+/PhgZmYGOBwOsFgsmJmZ/eY1F+nt7YXa2trs2Z73wdCQBgCMHp1IJpHA09MdPD3dLRIS+OtKisvWvbP7vf2lZdePVFwzbHTwyMiI3hidkZFRUKvUYzOZ48HQkBIA5nWqBAqFAktLC7C0tADmIh88Pz4uMSyUk7hn776DV4tKPn/6d/lNxp1MJqsRCASf8vn8XdMpOjRTVCoVjI2NgUqlAq1WCyMjI9DX1wf379+Hvr6+/Q8ePOgdGRmRKxSKx0WLFAqFXKlUKnQ6nUar1arHq47mxwrD4/F4Eg6HI2GxWDwej7cgkUjWFAqFam5uTjU3N6eRyeQPLSwswNraGqysrIBAIDwWFywW+zja11Qi29LSclIikeSZZPJZBovBAI8XA8HBQR9kZZ3lR8cmvFZSlGe00p8IkwONRkNERBj4+i7a4+XpHv307/IbMakWlciXJbx0nMPh7Jqo0JGh0el0MDo6Cl1dXSCVSkEmk7177969W319fe1DQ0M9KpVKoVarlWq1WjndNhUPG3ApAWDcOxLTLwSDwWAOotFoDBaLxRMIBAsrKysne3t7Xzqd7k2n0/c4OzsDlUoFHA4364IyMDAATU1NxdWikhcq6tXKyhJezljPJZKI2eERS5cZeoWCMD2srCwhPX0tVzk2djiCG//GtfLLUoBxShB0dHTU3Lx580sLC4vtJBLJKMZoNBqQSqUglUqPdnR01PT09DT19/fLHjx40DM0NNQ72933GiSVGgB4JFQK+LfoSAGgnL04yppEIh2xtLS0t7GxcaFSqR7Ozs4fMRgMcHR0nJX8pJs3b54Ui8UXjT7RHIRMIkFK8irfwcEHPwQELUmqvYHUGJkLmJubw8YNa/i9vfffY/px3myQiDTPiEl9nVDDX576jaenZ7SnpyfLUJNrNBqQyWRw+/bt4x0dHTdkMlltV1dXw/XygjkdEv4wB0YOAK0AUM70C8HQ6fSzdDrdm0qlejg6OrLc3Ny2MBiMadWjfR4PHjyAmzdvZs/1v5MxoVAokJK8iicWS95k+nH+s0EiQhqpzQGoVFtYk5a87ba0XQAA34xbpagg/5zoT7s/OGNnZ8eaaYkBuVwOnZ2d5VKpVNTS0lLS2NhYWFVZ3Dujg5qQh6uY+ocvCAiKIPn4+Jz19PSMdnV15VCpVL6Dg4NBViw6nQ5EItHRpqamqzM+2DzHzo4O69amftLQeKsAZrDLgmBY/PyYsCIhfs+SiKUFE5Y8EwqFx11cXDihoaFTjjFAoVAwPDwMHR0dourq6jNCofDHhZqUVnvjmgIAcgAgJyg40mLRokX8kJCQjT4+PussLS1n1JPl7t27UFxcfHguB6mNjY2B7G4naNRTWyygUCjAYDGAx+PB0sICSCSi3vFYLBbCwjjA8vddBQtATKb7d3saBwc7IJPJBpsHjUGDGRYLJBIJLK0sAfucmyIGg4FFi3y8AwNZtycUk5KiS02vvf7WWQaDkejg4DApQwAeh3xDaWnpPoFAcPxFqnP6sEvgGf+A8Bx3d/cvIyIiNi1evHjT8wpNj8fAwACUlZW9P9dD5+/ckcFbf9gd2dcnn9LNAovF4inmZHtXNxdOdBR3+/JlS33pdP29wolEInA4weuiYxOy5vvuTkeHDHb+8c8xvb33Z3R9/N+Df+uIjYk02DwkEsna2trS1d/fNyGeF7uTyw1/7g3R3t4O2OxA/TVghULhcQqFQk1JSfmYSNR/5wD4d6EfgUBwvLS09IhUKhW9qAV5H9YjKQwJi6uvrKw8ERoamhkSEpKp7w7yJEqlEiQSyZmysrJv53qjdaVSCZdyTk+3qFMrAJRHRPLPN95qeifj5fU7mYt8JhyMRqMhMJDFdnF25gDAvBYTpXIMWlpay2fq/8m5mDcIABYGnEcGAGI/VlhBZWX1yZdSkz55OX0dV5+7w9bGGvz8mPrFpK62QskJjf2GTqd7x8bGbpnID4BCoUAmk0lLSkqOiESik2UleS/MakQflYKrXQDQxY1a3tTe3i6KiIjY5OXlxX7e9+rr6wsuXbr0t4ffn9OgMWjghMZQRcLp+8GulRVI/QPC37Wxtnal0ajJtjY2E451ZjiBra31vE9lR2PQQKFQaAAwo98Yi8Xq9fpPd56HO6rlvKWJv/PwcK+JilyCmajWMw6HAzs7+rMFpQOCIn6zHywSFvXm5eUdFAqFZ9Rq9bgHa2trq79w4cK+zz49cAARkmcpL81v/a/Dhz49d+7c3qqqqjyVSjXuOJ1OBxKJpDw3N/fA5V+zax6978cKw/sHhM/raMrnUVdboSy4fPWQSFSjd5yFBQWIRNKEd2IEw1J4JUd88WL+R51d3XrHWVDMnxUTa2tr1zXrNiUGsrmPf7DS4tymCxcu7Kuurs55+kKQSqVN586d23vs+8NHDXUCC5Wzp3/Iy8rKeruysvLM2Nhvo7VVKhXU1tYWnj17du/T7UOdnZ2D7OzsfGGB09raVi4S1RzXl0eFw+EAj8chYjKLVFffyOrq1C8mJBLpWTFRKBRyDofzC4vFWvXk+1ev/CLOzs7eKxAIslQqFeh0Oujp6enKzs7em/XTd7OayTqfKb56sT4rK+sPAoHg5KO/o0KhAKFQmHXy5MkdF3/5+TeZmctXpIXZ29v7zqVcKWNRX1epuXu3U/y8pEw0GmndOZt0dnXVDw0P6/W5oNHoZ30mQ0NDPb29vfvj4+Pf3rR5B/7od188XnEUXr4gDgmL+0NfX5/U19d3d3l5+YGfTnyDtLmcIhXXLsu4UcvfR6PRGGtra9eysrIjYrE45+kt4Fheou/69es/unnz5vm7d+/Wmsre2WRkZGTQ1DYg/JYGiUiTm1ugBAC9IfHPiEmDpFITE7fqJI/H27lmzZpDq5LWtz55t6wUXO3ihMYerK+vz2tpaUFaM0yT8tL81ujYle+TSCTrvEunBU9/voTLd92wYcPHVCqV39XVdXCu7+oYCp1O90Kc50Jk3I5+xVcv1jc3N5d4enpSMzIyvkpK3sh78nORsKg3++yPBS/q1q+hKCm61DSekERGJ3ikp6d/ERsbm1xVVXWwtbX1hRFtFAqFPMLMUyZsDyoQCI7LZDKIiIjwzczM/GpV0vro2TTsRSUqZoX3+vXrP1u9enXi0NAQiESirIdRtggIc5oJ40zq6uryGhoa8ry8vBJCQ0O9USjU94mrN7yWc+EnvaXb5gJMvxCMp6cnl0Kh2Le1tZVXXLs8L1LXefGrWRkZGZ/x+XyeUqkEkUh0vqenZ14HZyG8OEwoJjdrygd37NxTEBkZmWBtbQ3BwcEeKBTq+/UbX3/355Pfzlmn66qk9dGbN29+k8PhbCSRSNDZ2Snb9ae/HCkpKTksEhbN2QTD5NSX+Vu3bj0cHBzsjcFg4O7du1BWVvbNwxB9BIQ5j94I2Fu3bhXW19cDl8sFLBYLHA7Hg0wmf/e77e84ffXlPz6fLSMnQ2paZkJ4eHjmtm3b+B4eHvZkMhlQKBTY29s72dvbfxgUFJT8x7ffP1NRUfHjXErnZ/qFYKKjo7dt3rz5g8DAQPtH/XHa2tpqGhsbC55/BASEuYFeMblz505NTU3NgfDw8PcwGAygUCjw9fW1IJPJn/1130Hv0tLSI4WXL4hny9inYS+Osvbz80tgMpn8jIwMPovFch2vpoiDgwM4ODhwfH19OYsWLeJv3/Hu+cbGxquzXZz5aZYlvMRJT0/fFhkZue3JZmfd3d0gEolOIr4ShPmEXjFpkFRqXlrzSnFnZ+d7Tk5OjzNfXVxcICMjY6ezszNnVdL6vU8HWhmbgKAIkrOzMyc1NTXz0YU4maAuOp0OK1as4EVFRfGEQqHg1dfePHzr1q2rs71S8WOF4f38/BLS09M/iIyM5DxdxLq5uVlcVVU1bgVwBIS5il4xAQCQyWRigUBwJikpKe3JVGQcDgdLly7l2tranti0ecf7IpEoy9hbxX6sMDydTvdevXr1ltjY2F3u7u6AxT73FJ7B3Nwc4uLiwthsdphQKCzZkL7l0/r6+oKbNeVG90+EhMXZL1++fFtycvKHrq6uz4igUqmE5ubmEiTHCWG+8dwrUXD9imz9xtd/jIuLS7N5KpsTjUZDUFCQE4PB+F4oFGYmJW888Mv5k4UTHGpGxC9LYaenp78VEhKyxdHRESgUyoyOh0KhwNraGuLi4qIDAgKi6+rqyjekb/mHMSN6N6RvSdu+ffseNpsdZm09ftuW+vp6EIvFSB9hhHnHpG7rUqm0orW1tdXS0tLj6TIEaDQaaDQaxMfH811dXTl/3Xfw+JUrVz411J01cfWG6IiIiC07d+5McHNzs7ewMGyOFw6HAwcHB6BSqVx3d/fwz7/4rkAgEBwXCoUnHpZonDGrU9J5MTEx27du3Zrm4uKC0beaqq6u/ry+vj7XEPMiIMwmkxKTimuXZe/u+fCkp6fnexPdUfF4PPj7+1szGIydLi4unF1/+kvenTt3RG1tbRXTqfma8lIG39/fP/HVV19NZrFYHpMpzjQTzMzMwNPTE+Pp6Zng6emZ4Ofnl5CesfV8bW1tznQe3/wDwvFeXl7Rvr6+Ca+88kpaUFCQh74GXzqdDrq7u6GpqankRQmdR1hYTNrhUFVVlcXj8d6ysrKy0OfstLS0hPj4eC6Xy+U2NzeDRCI5/sa2XeX37t1rGhwc7BoYGJBN1P+FFbiE5OzszGaxWImvvvrqpoCAAKfp+ERmCpPJBCaTmcnhcDJLS0u/TE59+YxUKhXoi/lg+oVgrKysGJaWlna2trYeaWlpXDabvTMgIGDSfp2KiorzbW1tL0zoPMLCYtJX6uVfs2u++PKowMPDgz+ZIslEIhECAgKAxWJlajSazJ6eHmhra4PW1tZvtmz9o6Czs7O+r6+vfWxsbFir1WosLCzsV6xYkcnj8d7z9vaelmPV0Hh5eYGnp+f2mJiY7UVFRZ/HL0v5tru7+5ZGo1FisVg8Docj4fF4CxsbG1c+nx/m7e39sYeHB7i4uIC5ufmU6r4ODQ1BZWXlifkSrYuA8DRTumIrKytPent78728vCb9HRQKBVgsFhwcHIBOpwObzd4yNja2RaVSwdDQEHR1dcHo6CjQaDRwdXWdsWPV0KBQKPDw8AA7O7udERERO2tra2FgYACoVCo4OTkBjUYDMpkMeDz+8WuqaLVaaGxsbL19+/YzSX8ICPOFqYrJidDQ0AwvLy/e80c/CwaDARKJBI86BdJoNHB3dwe1Wj0nViL6IJPJwGQywdnZGZRKJRAIBDBUx8OBgQEoLS39BtkORpjPTJg1PB61N64pmpqarvb39xvUiLkuJE9CJpPBxsbGYEICANDZ2SlHgtQQ5jtTEhMAgLq6ulyJRFJvDGNeREZGRkAikRSUFuci2cEI85opi0l+7hmBWCzOeV6dToTJcfv27cHr168jxbgR5j1TFhMAgObm5hKZDNl0MAQtLS3Xzpw6hkS8Isx7piUmUqlUIBAIJuyjgzA5Ojs7QSKRINGuCAuCaYmJsKKw68qVK59KJJIu5HFneiiVSigqKjouEolOmtoWBARDMC0xAQC4+MvPJadOnXq3ra1N8yL0dDEkOp0OSktLy/Pz8w8+3d4CAWG+Mm0xAQA4fuy/jl+8ePGju3fvGsqeBY9Wq4XKysrWU6dOvX31yi8mKyyFgGBoZiQmAAD/79D+fadPn96PCMrz0el0UFVV1frtt9+mj9fiAgFhPjNjMQEAyMvLO3Ds2LE/tLS0INmuerh27Vr9999//xoiJAgLEYOEntbVVigB4PNNm3cMpqSkfMRms50McdyFgkqlgqKiovJTp069nZ97BhEShAWJQePYj373xdF1GzbLFQrFx6Ghob766ne8KNy7dw+KiopO5ubmfmTK4tsICMbG4EkxWT99d35l4rre/v7+D0NCQvh0Ot3QU8wL1Go1SKVSTX5+/sH8/PyDSP8bhIWOUTLsLuVklQcFR65pbGzcvnLlyvfc3NwsCASCMaaac+h0OhgaGoLq6uqaCxcu/OV01tGcTw7uM7VZCAhGx2jpug/vxAd58atzoqKitq1cuXKnvb29saabE+h0Oqiurpbm5eUdrK6uPlspuDrvY0hmO4YIhUIBGq1/X2CmNqFQKL3/79HomZ/z82xEowyy9zFr80zGDqPn/hdeviBmL47ad+fOnRsRERGbQkNDo62srIw97azT2dkJxcXFx0tKSo7Mdh8hY4LD4TDPH2U4MFjMc6tLmZmZzaj+Aw6H0/t9PB4PGCxmRudNJBL0ngeZTAI0Gj3jv+1szfM88Hic8cUEAKCmqlQOAN/ELU2qkEgkySwWK3HRokVcBoMxG9MbDZ1OB83NzdDU1FRQW1t7XiAQHJ+ovu18pbr6Rg6L5ZtoM0EhcUPT0tJW8tWRb0vQqIkvgKqqmhnVfrl2TfANXo+gjKlUio4OWc1M5sjOzjnQUH8rbqLPu3t6moaGhmfc+3q25tGHUqmECoEIUKbIrVkcEkONiIh4jcvlvu7s7OxLo9GmVe7QVCgUCujq6oKGhoaCioqKo9XV1WeM3YDMVPDik1gpyas+XrVyeaKXl8czjyANjbcgI/MNmkg49Q4ECPOH3NyC4RUr+M8IcHt7B1y9WlKRl3/5kElKnD1sfXEoJCzueEBAQGJYWFgGk8nk2djYAIFAgLm4pTw6Ogqjo6Mgl8vhxo0b50tLS4/U19fnLvS2FIWXfxEDQNLmLW9ueW1TxtchHDaQyWRTm4VgYkZHR6G+vhF+/NfP+y5e+vVjiVgwZpKVydOwF0dZW1lZOTGZTD6bzU4LCAiIptPp8HTDL1MwOjoKLS0tUFdXd1IsFudIpdKKgYGB7tloJTrX4MUnsVJTEj9etzY10dHRAQAAGm81wcsZW5CVyQInL69gNCGBjwcAGBx8ANnncypOnTr3H9nn/reD55wovvrQpyIHAHFUzIocGo3mQaPRfBwdHVlubm7bXF1dgcFgABqNNvruglwuh7t374JMJoOOjo7P79y5I+ru7m7q7e1tXQi7MzOh8PIv4pCw2DdaWtte37Au7aPIyCWAxWABjUbPif9HCMbjURtKiaQBfvr5zH9evlJ0uLQ4r/nJMXNiZTIRrMAlJAcHB18HBweWo6Mjy8rKajeJRAJLS0uwtLQECwsLoFAogMfjAYvFgpmZ2XNXMyqVCoaHh2FoaAiGh4cfvwYGBqCvrw+6u7vfvnfvXlNvb29rT09Pq0QsUM7S6c4rNqS/lrZ5U+YPRBKR9M7u9xwqBUUvtNAudH766XSLE8PR49ixE78/8tVnX403Zk7fUR46NUUAIPIPCMdTKJTdNjY2QKPRgE6nA51OB1tbWyCRSIDD4YBAIAAejwcCgfDYUajVakGlUoFarQadTvfY79HX1wf9/f0gl8tBLpfDvXv3HvXw+dxQPYYXMj+d+P7Mmzv+5OHr6/OJWq1GBHeB09TcUiKuq/coKS3/eqIx/wPkiIXC3w6YjAAAAABJRU5ErkJggg=="); + + --keyword: #ff79c6; + --identifier: #f8f8f2; + --comment: #6272a4; + --operator: #ff79c6; + --punctuation: #f8f8f2; + --other: #f8f8f2; + --escapeSequence: #bd93f9; + --number: #bd93f9; + --literal: #f1fa8c; + --program: #9090c0; + --option: #90b010; + --raw-data: #8be9fd; + + --clipboard-image-normal: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' style='color: lightgray' fill='none' viewBox='0 0 24 24' stroke='currentColor'%3E %3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2' /%3E %3C/svg%3E"); + --clipboard-image-selected: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' style='color: lightgray' viewBox='0 0 20 20' fill='currentColor'%3E %3Cpath d='M8 3a1 1 0 011-1h2a1 1 0 110 2H9a1 1 0 01-1-1z' /%3E %3Cpath d='M6 3a2 2 0 00-2 2v11a2 2 0 002 2h8a2 2 0 002-2V5a2 2 0 00-2-2 3 3 0 01-3 3H9a3 3 0 01-3-3z' /%3E %3C/svg%3E"); + --clipboard-image: var(--clipboard-image-normal); +} + +@media (prefers-color-scheme: dark) { + [data-theme="auto"] { + --primary-background: #171921; + --secondary-background: #1e202a; + --third-background: #2b2e3b; + --info-background: #008000; + --warning-background: #807000; + --error-background: #c03000; + --border: #0e1014; + --text: #fff; + --anchor: #8be9fd; + --anchor-focus: #8be9fd; + --input-focus: #8be9fd; + --strong: #bd93f9; + --hint: #7A7C85; + --nim-sprite-base64: url("data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAARMAAABMCAYAAABOBlMuAAAACXBIWXMAAAsTAAALEwEAmpwYAAAFFmlUWHRYTUw6Y29tLmFkb2JlLnhtcAAAAAAAPD94cGFja2V0IGJlZ2luPSLvu78iIGlkPSJXNU0wTXBDZWhpSHpyZVN6TlRjemtjOWQiPz4gPHg6eG1wbWV0YSB4bWxuczp4PSJhZG9iZTpuczptZXRhLyIgeDp4bXB0az0iQWRvYmUgWE1QIENvcmUgNS42LWMxNDggNzkuMTY0MDM2LCAyMDE5LzA4LzEzLTAxOjA2OjU3ICAgICAgICAiPiA8cmRmOlJERiB4bWxuczpyZGY9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkvMDIvMjItcmRmLXN5bnRheC1ucyMiPiA8cmRmOkRlc2NyaXB0aW9uIHJkZjphYm91dD0iIiB4bWxuczp4bXA9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC8iIHhtbG5zOmRjPSJodHRwOi8vcHVybC5vcmcvZGMvZWxlbWVudHMvMS4xLyIgeG1sbnM6cGhvdG9zaG9wPSJodHRwOi8vbnMuYWRvYmUuY29tL3Bob3Rvc2hvcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvbS94YXAvMS4wL21tLyIgeG1sbnM6c3RFdnQ9Imh0dHA6Ly9ucy5hZG9iZS5jb20veGFwLzEuMC9zVHlwZS9SZXNvdXJjZUV2ZW50IyIgeG1wOkNyZWF0b3JUb29sPSJBZG9iZSBQaG90b3Nob3AgMjEuMCAoV2luZG93cykiIHhtcDpDcmVhdGVEYXRlPSIyMDE5LTEyLTAzVDAxOjE4OjIyKzAxOjAwIiB4bXA6TW9kaWZ5RGF0ZT0iMjAxOS0xMi0wM1QwMToyMDoxMCswMTowMCIgeG1wOk1ldGFkYXRhRGF0ZT0iMjAxOS0xMi0wM1QwMToyMDoxMCswMTowMCIgZGM6Zm9ybWF0PSJpbWFnZS9wbmciIHBob3Rvc2hvcDpDb2xvck1vZGU9IjMiIHBob3Rvc2hvcDpJQ0NQcm9maWxlPSJzUkdCIElFQzYxOTY2LTIuMSIgeG1wTU06SW5zdGFuY2VJRD0ieG1wLmlpZDplZGViMzU3MC1iNmZjLWQyNDQtYTExZi0yMjc5YmY4NDNhYTAiIHhtcE1NOkRvY3VtZW50SUQ9InhtcC5kaWQ6ZWRlYjM1NzAtYjZmYy1kMjQ0LWExMWYtMjI3OWJmODQzYWEwIiB4bXBNTTpPcmlnaW5hbERvY3VtZW50SUQ9InhtcC5kaWQ6ZWRlYjM1NzAtYjZmYy1kMjQ0LWExMWYtMjI3OWJmODQzYWEwIj4gPHhtcE1NOkhpc3Rvcnk+IDxyZGY6U2VxPiA8cmRmOmxpIHN0RXZ0OmFjdGlvbj0iY3JlYXRlZCIgc3RFdnQ6aW5zdGFuY2VJRD0ieG1wLmlpZDplZGViMzU3MC1iNmZjLWQyNDQtYTExZi0yMjc5YmY4NDNhYTAiIHN0RXZ0OndoZW49IjIwMTktMTItMDNUMDE6MTg6MjIrMDE6MDAiIHN0RXZ0OnNvZnR3YXJlQWdlbnQ9IkFkb2JlIFBob3Rvc2hvcCAyMS4wIChXaW5kb3dzKSIvPiA8L3JkZjpTZXE+IDwveG1wTU06SGlzdG9yeT4gPC9yZGY6RGVzY3JpcHRpb24+IDwvcmRmOlJERj4gPC94OnhtcG1ldGE+IDw/eHBhY2tldCBlbmQ9InIiPz4JZNR8AAAfG0lEQVR4nO2deViTZ7r/7yxkJaxJ2MK+GCBAMCwS1kgUFQSKK4XWWqsz1jpjp3b0tDP1V+eqU391fqfT/mpPPd20drTFDS0KFEVWJSGAEgLIZpAICBJACIRs549Rj1WILAkBfD/XlevySp68z/0S3+/7vPdzLyidTgcLkU2bd+z39/f/q1gshsrKSoJELFCa2iaEuU9K6kb+8uXxv54/fzE8L/eswNT2zCfQpjbAGKS8lPFKSEjIXiaTCSEhIeDj4xNnapsQ5j6rktZGp6UlfxIdzQVzCplmanvmG1hTG2BIAtlc26CgoDfT0tL2e3l5AQCAjY0NkMnk/a9s2k6rrKw8UV8n1JjYTIQ5RlAw14KzmL3xze1vfJyUuMJaq9UCFovFm9qu+YbBxcSPFUYkk8l2Q0NDsvo6ocrQx5+I8Ih4bz6f/0l8fHyKlZXV4/dRKBQwmcwwMpn8A4FAoPgHhH9bV1sxa488wZxoaycnJ/a9e/duCa5fkc3WvAiTI4Ib77p+XdqHG9anbfLy8gAAgLGxMdBpF+bjvzExqJj4scKI0dHRnwQHB++orq7+AgDeMuTxJ2Jl4rqU9PT0EwEBAUQCgTDuGAaDAampqYepVKpHUHDk325Ulw0a266YuFW+Gzdu/MDPz29jfn7+XgA4aOw5ESZP6kvpCXv3vnM8NiaSamVl+fj9BepGNDoGFRN7e/slcXFxO1xcXMDJyWnH7j//H/fi4uJdgutXmgw5z5O8smn7X9euXbvf29sbMBjMhONQKBRYWVlBbGzsbjMzM3JoOG+/sKKwy1h2rd/4elpGRsYuLy+vaDweD2w2Oy1h5ZrCvEunEaeeiVnMiabyl/F2/+X9P+8JDPQHHA5napMWBAYTk6DgSNuEhIS9DAYDAP7tq1i6dOkqOp3OWbNu0wens44emeoxA9lcWwKBYEMkEm2JRKIdHo+3QKFQWJ1Op8ZgMER3d/dVq1evTnFycpr0MSkUCsTExGzH4/Gk1LTME/39/TI0Go1FoVCg1WrVY2NjipGRkcGRkRH5dPwrEZHLXMPCwjJSUlIy3dzcfB+97+rqGhYSEpIOAIiYmBguN3zL77dt3uPh4W5qUxYUBhMTb2/vjeHh4cvR6P/dILK0tITIyEg7BweHr363/Z3Ampqaf1Zcu/zMKiVsyVJvMplsRyKR7IhEor2FhYUbhUJhJCYm2pFIJB6JRAIymQx4PB7QaDRoNBowMzMDJycnwOOn7icjEokQGxu7icFgbLp///7jFY1WqwWlUgkjIyOgUCgO7Ni5Rz48PCwfHh7uGRkZeaBQKOSjo6ODCoVCXlNVKn/6uCsT13FXrVr1emho6BYKhfLMnP7+/omrU9LPX8g+UThloxEMxqJFXjxESAyPQcSEExrLWLNmzW57e/txP/fw8ABHR8cdDAaDt3xF2ru9vb03sVgs0cbGxs/FxWVZUlISj0aj+dna2oKtrS1M5PcwJCgUCry8vODRrs84vPfoH6OjoyCXy6Gvr+/R6+CWrX9s7evrk/b19bWr1Wqli4sLZ8OGDe95eXmxUSjUuAd0cHDwjoqK2sYKXFIhvnldYYTTQpgU4/8+jyASCYDGoCd+ZkYYF8OICYezl8PhuOkbQyAQIDo62s/NzS2np6cHbGxsgEajAYFAAAwGA1gsFia6CE0NgUAABwcHsLe3B61WC2q1eo9WqwWNRgNKpRLUajUQiUSgUCh6zwGHwwGTydzo5+eXBQBnZu8MEJ5keHhYPqyYWMtHR0ZBpVIhYj9FUDONgOUvT12+du3avMDAQJjssdRqNWCxCyrEZdLodDoQi8Ulx44de628NL/V1Pa8iERE8l2dHB2CJvpcq9Nqbt1qKURWj1Njxld0ZGTkAW9v70kLCQC8sEIC8O/HKx8fn2gmk8kHgCk7pRFmzrWyAikASE1tx0Jj2uH0EZHL/N7YtuvT4OBgzmz4OBYSeDweIiMjt2S++vtMP1YYEmmJsCCY8mNOIJtr6+zsHBcZGXmIw+G4mZubG8m0hU9HRwcUFxe/KxQKTyDRsQjznSmJCS9+dVRERMTfQ0NDo2xtbfUGiSFMjtHRUaitrc3Jzc09kHvxVLmp7UFAmC6oZQkvrZLL5RJhReHtiQb5scKIXC7371FRUX90dnYGIpE4JR8Jgn40Gg20t7fXFxYWfnr9+vWjz8sdYi+Osh4vzgUBwZSgtu94V+fs7Hx7YGCgra6u7khLS0u2RCwYeTQgKmYFh8fj/f/g4OAldnZ2prR1wdPd3Q1CofBQSUnJkdLi3N8E93FCY6k+Pj48FxcXjlar1ZSWlh65VvYr4kREmDNg79+/D3FxcW5OTk5uXl5evNbW1tL0jK3ZXV1d1ykUintycvInoaGhdkj+gvGxs7MDPp+/m0AgWMQvS/lyeHhYTqPRPJycnIJSU1NZ3t7eW2g0Gly/fv2oWq1Gij0hzClQ/gHhpLS0tEM8Hm/7I8Ho7++HlpYWsLa2Bg8PDxOb+OKhUCigqakJ7t+/D25ubuDu7g4oFAp0Oh08ePAAvv7666TTWUdzTG0nAsKTYMU3ryuSU18+4+bmFrZo0SIOAICVlRUsXrx4zkakLnRIJBI8CgJ8MtdJp9NBZ2enqL29XWRC8xAQxgUNAHD+3L8KGhoaCp78ABES04JCoX4jJAAAAwMDUFtbe96YpRMQEKbL41DU5ubmko6Ojj2PSgggzD36+/vrb9y4cX425zzw93/8EBjon2is44+NjSkePBjqGRwc7G5v7xBV19w8U5B/3qgrr9+/uWtXUuKKD/TZ9MXh/066/OuFmunO8dGBQ98HBbGSp/t9U6LRaDXK0dHBoeFhuVzeL22/0yFqamopufjLqRJ933ssJi0tLSXV1dWHGAzGbuObOzs8ubqa71vZKpUKOjo6blwpOF8zm/Mu5cVkLlkSaswprAHAaVihgK7O7oSGxltvfXLon3nXK4RHT2cdN4pfKDCAlZyUuMJan02nTmczAaBmunPw4qI3cbnh0/36XICq0+lgcPABp7OrK629vUP5z8++LLh2XXD05L++yxrvC4/F5EZ12WBS8saLS5Ys2U2lUufUY45SqQSlUgkqlQrUavXj19jYGGg0GtBoNKDT6UCn05VotVq1TqfToFAojFar1eh0Og0Wi8XhcDgeGo1+/PhgZmYGOBwOsFgsmJmZ/eY1F+nt7YXa2trs2Z73wdCQBgCMHp1IJpHA09MdPD3dLRIS+OtKisvWvbP7vf2lZdePVFwzbHTwyMiI3hidkZFRUKvUYzOZ48HQkBIA5nWqBAqFAktLC7C0tADmIh88Pz4uMSyUk7hn776DV4tKPn/6d/lNxp1MJqsRCASf8vn8XdMpOjRTVCoVjI2NgUqlAq1WCyMjI9DX1wf379+Hvr6+/Q8ePOgdGRmRKxSKx0WLFAqFXKlUKnQ6nUar1arHq47mxwrD4/F4Eg6HI2GxWDwej7cgkUjWFAqFam5uTjU3N6eRyeQPLSwswNraGqysrIBAIDwWFywW+zja11Qi29LSclIikeSZZPJZBovBAI8XA8HBQR9kZZ3lR8cmvFZSlGe00p8IkwONRkNERBj4+i7a4+XpHv307/IbMakWlciXJbx0nMPh7Jqo0JGh0el0MDo6Cl1dXSCVSkEmk7177969W319fe1DQ0M9KpVKoVarlWq1WjndNhUPG3ApAWDcOxLTLwSDwWAOotFoDBaLxRMIBAsrKysne3t7Xzqd7k2n0/c4OzsDlUoFHA4364IyMDAATU1NxdWikhcq6tXKyhJezljPJZKI2eERS5cZeoWCMD2srCwhPX0tVzk2djiCG//GtfLLUoBxShB0dHTU3Lx580sLC4vtJBLJKMZoNBqQSqUglUqPdnR01PT09DT19/fLHjx40DM0NNQ72933GiSVGgB4JFQK+LfoSAGgnL04yppEIh2xtLS0t7GxcaFSqR7Ozs4fMRgMcHR0nJX8pJs3b54Ui8UXjT7RHIRMIkFK8irfwcEHPwQELUmqvYHUGJkLmJubw8YNa/i9vfffY/px3myQiDTPiEl9nVDDX576jaenZ7SnpyfLUJNrNBqQyWRw+/bt4x0dHTdkMlltV1dXw/XygjkdEv4wB0YOAK0AUM70C8HQ6fSzdDrdm0qlejg6OrLc3Ny2MBiMadWjfR4PHjyAmzdvZs/1v5MxoVAokJK8iicWS95k+nH+s0EiQhqpzQGoVFtYk5a87ba0XQAA34xbpagg/5zoT7s/OGNnZ8eaaYkBuVwOnZ2d5VKpVNTS0lLS2NhYWFVZ3Dujg5qQh6uY+ocvCAiKIPn4+Jz19PSMdnV15VCpVL6Dg4NBViw6nQ5EItHRpqamqzM+2DzHzo4O69amftLQeKsAZrDLgmBY/PyYsCIhfs+SiKUFE5Y8EwqFx11cXDihoaFTjjFAoVAwPDwMHR0dourq6jNCofDHhZqUVnvjmgIAcgAgJyg40mLRokX8kJCQjT4+PussLS1n1JPl7t27UFxcfHguB6mNjY2B7G4naNRTWyygUCjAYDGAx+PB0sICSCSi3vFYLBbCwjjA8vddBQtATKb7d3saBwc7IJPJBpsHjUGDGRYLJBIJLK0sAfucmyIGg4FFi3y8AwNZtycUk5KiS02vvf7WWQaDkejg4DApQwAeh3xDaWnpPoFAcPxFqnP6sEvgGf+A8Bx3d/cvIyIiNi1evHjT8wpNj8fAwACUlZW9P9dD5+/ckcFbf9gd2dcnn9LNAovF4inmZHtXNxdOdBR3+/JlS33pdP29wolEInA4weuiYxOy5vvuTkeHDHb+8c8xvb33Z3R9/N+Df+uIjYk02DwkEsna2trS1d/fNyGeF7uTyw1/7g3R3t4O2OxA/TVghULhcQqFQk1JSfmYSNR/5wD4d6EfgUBwvLS09IhUKhW9qAV5H9YjKQwJi6uvrKw8ERoamhkSEpKp7w7yJEqlEiQSyZmysrJv53qjdaVSCZdyTk+3qFMrAJRHRPLPN95qeifj5fU7mYt8JhyMRqMhMJDFdnF25gDAvBYTpXIMWlpay2fq/8m5mDcIABYGnEcGAGI/VlhBZWX1yZdSkz55OX0dV5+7w9bGGvz8mPrFpK62QskJjf2GTqd7x8bGbpnID4BCoUAmk0lLSkqOiESik2UleS/MakQflYKrXQDQxY1a3tTe3i6KiIjY5OXlxX7e9+rr6wsuXbr0t4ffn9OgMWjghMZQRcLp+8GulRVI/QPC37Wxtnal0ajJtjY2E451ZjiBra31vE9lR2PQQKFQaAAwo98Yi8Xq9fpPd56HO6rlvKWJv/PwcK+JilyCmajWMw6HAzs7+rMFpQOCIn6zHywSFvXm5eUdFAqFZ9Rq9bgHa2trq79w4cK+zz49cAARkmcpL81v/a/Dhz49d+7c3qqqqjyVSjXuOJ1OBxKJpDw3N/fA5V+zax6978cKw/sHhM/raMrnUVdboSy4fPWQSFSjd5yFBQWIRNKEd2IEw1J4JUd88WL+R51d3XrHWVDMnxUTa2tr1zXrNiUGsrmPf7DS4tymCxcu7Kuurs55+kKQSqVN586d23vs+8NHDXUCC5Wzp3/Iy8rKeruysvLM2Nhvo7VVKhXU1tYWnj17du/T7UOdnZ2D7OzsfGGB09raVi4S1RzXl0eFw+EAj8chYjKLVFffyOrq1C8mJBLpWTFRKBRyDofzC4vFWvXk+1ev/CLOzs7eKxAIslQqFeh0Oujp6enKzs7em/XTd7OayTqfKb56sT4rK+sPAoHg5KO/o0KhAKFQmHXy5MkdF3/5+TeZmctXpIXZ29v7zqVcKWNRX1epuXu3U/y8pEw0GmndOZt0dnXVDw0P6/W5oNHoZ30mQ0NDPb29vfvj4+Pf3rR5B/7od188XnEUXr4gDgmL+0NfX5/U19d3d3l5+YGfTnyDtLmcIhXXLsu4UcvfR6PRGGtra9eysrIjYrE45+kt4Fheou/69es/unnz5vm7d+/Wmsre2WRkZGTQ1DYg/JYGiUiTm1ugBAC9IfHPiEmDpFITE7fqJI/H27lmzZpDq5LWtz55t6wUXO3ihMYerK+vz2tpaUFaM0yT8tL81ujYle+TSCTrvEunBU9/voTLd92wYcPHVCqV39XVdXCu7+oYCp1O90Kc50Jk3I5+xVcv1jc3N5d4enpSMzIyvkpK3sh78nORsKg3++yPBS/q1q+hKCm61DSekERGJ3ikp6d/ERsbm1xVVXWwtbX1hRFtFAqFPMLMUyZsDyoQCI7LZDKIiIjwzczM/GpV0vro2TTsRSUqZoX3+vXrP1u9enXi0NAQiESirIdRtggIc5oJ40zq6uryGhoa8ry8vBJCQ0O9USjU94mrN7yWc+EnvaXb5gJMvxCMp6cnl0Kh2Le1tZVXXLs8L1LXefGrWRkZGZ/x+XyeUqkEkUh0vqenZ14HZyG8OEwoJjdrygd37NxTEBkZmWBtbQ3BwcEeKBTq+/UbX3/355Pfzlmn66qk9dGbN29+k8PhbCSRSNDZ2Snb9ae/HCkpKTksEhbN2QTD5NSX+Vu3bj0cHBzsjcFg4O7du1BWVvbNwxB9BIQ5j94I2Fu3bhXW19cDl8sFLBYLHA7Hg0wmf/e77e84ffXlPz6fLSMnQ2paZkJ4eHjmtm3b+B4eHvZkMhlQKBTY29s72dvbfxgUFJT8x7ffP1NRUfHjXErnZ/qFYKKjo7dt3rz5g8DAQPtH/XHa2tpqGhsbC55/BASEuYFeMblz505NTU3NgfDw8PcwGAygUCjw9fW1IJPJn/1130Hv0tLSI4WXL4hny9inYS+Osvbz80tgMpn8jIwMPovFch2vpoiDgwM4ODhwfH19OYsWLeJv3/Hu+cbGxquzXZz5aZYlvMRJT0/fFhkZue3JZmfd3d0gEolOIr4ShPmEXjFpkFRqXlrzSnFnZ+d7Tk5OjzNfXVxcICMjY6ezszNnVdL6vU8HWhmbgKAIkrOzMyc1NTXz0YU4maAuOp0OK1as4EVFRfGEQqHg1dfePHzr1q2rs71S8WOF4f38/BLS09M/iIyM5DxdxLq5uVlcVVU1bgVwBIS5il4xAQCQyWRigUBwJikpKe3JVGQcDgdLly7l2tranti0ecf7IpEoy9hbxX6sMDydTvdevXr1ltjY2F3u7u6AxT73FJ7B3Nwc4uLiwthsdphQKCzZkL7l0/r6+oKbNeVG90+EhMXZL1++fFtycvKHrq6uz4igUqmE5ubmEiTHCWG+8dwrUXD9imz9xtd/jIuLS7N5KpsTjUZDUFCQE4PB+F4oFGYmJW888Mv5k4UTHGpGxC9LYaenp78VEhKyxdHRESgUyoyOh0KhwNraGuLi4qIDAgKi6+rqyjekb/mHMSN6N6RvSdu+ffseNpsdZm09ftuW+vp6EIvFSB9hhHnHpG7rUqm0orW1tdXS0tLj6TIEaDQaaDQaxMfH811dXTl/3Xfw+JUrVz411J01cfWG6IiIiC07d+5McHNzs7ewMGyOFw6HAwcHB6BSqVx3d/fwz7/4rkAgEBwXCoUnHpZonDGrU9J5MTEx27du3Zrm4uKC0beaqq6u/ry+vj7XEPMiIMwmkxKTimuXZe/u+fCkp6fnexPdUfF4PPj7+1szGIydLi4unF1/+kvenTt3RG1tbRXTqfma8lIG39/fP/HVV19NZrFYHpMpzjQTzMzMwNPTE+Pp6Zng6emZ4Ofnl5CesfV8bW1tznQe3/wDwvFeXl7Rvr6+Ca+88kpaUFCQh74GXzqdDrq7u6GpqankRQmdR1hYTNrhUFVVlcXj8d6ysrKy0OfstLS0hPj4eC6Xy+U2NzeDRCI5/sa2XeX37t1rGhwc7BoYGJBN1P+FFbiE5OzszGaxWImvvvrqpoCAAKfp+ERmCpPJBCaTmcnhcDJLS0u/TE59+YxUKhXoi/lg+oVgrKysGJaWlna2trYeaWlpXDabvTMgIGDSfp2KiorzbW1tL0zoPMLCYtJX6uVfs2u++PKowMPDgz+ZIslEIhECAgKAxWJlajSazJ6eHmhra4PW1tZvtmz9o6Czs7O+r6+vfWxsbFir1WosLCzsV6xYkcnj8d7z9vaelmPV0Hh5eYGnp+f2mJiY7UVFRZ/HL0v5tru7+5ZGo1FisVg8Docj4fF4CxsbG1c+nx/m7e39sYeHB7i4uIC5ufmU6r4ODQ1BZWXlifkSrYuA8DRTumIrKytPent78728vCb9HRQKBVgsFhwcHIBOpwObzd4yNja2RaVSwdDQEHR1dcHo6CjQaDRwdXWdsWPV0KBQKPDw8AA7O7udERERO2tra2FgYACoVCo4OTkBjUYDMpkMeDz+8WuqaLVaaGxsbL19+/YzSX8ICPOFqYrJidDQ0AwvLy/e80c/CwaDARKJBI86BdJoNHB3dwe1Wj0nViL6IJPJwGQywdnZGZRKJRAIBDBUx8OBgQEoLS39BtkORpjPTJg1PB61N64pmpqarvb39xvUiLkuJE9CJpPBxsbGYEICANDZ2SlHgtQQ5jtTEhMAgLq6ulyJRFJvDGNeREZGRkAikRSUFuci2cEI85opi0l+7hmBWCzOeV6dToTJcfv27cHr168jxbgR5j1TFhMAgObm5hKZDNl0MAQtLS3Xzpw6hkS8Isx7piUmUqlUIBAIJuyjgzA5Ojs7QSKRINGuCAuCaYmJsKKw68qVK59KJJIu5HFneiiVSigqKjouEolOmtoWBARDMC0xAQC4+MvPJadOnXq3ra1N8yL0dDEkOp0OSktLy/Pz8w8+3d4CAWG+Mm0xAQA4fuy/jl+8ePGju3fvGsqeBY9Wq4XKysrWU6dOvX31yi8mKyyFgGBoZiQmAAD/79D+fadPn96PCMrz0el0UFVV1frtt9+mj9fiAgFhPjNjMQEAyMvLO3Ds2LE/tLS0INmuerh27Vr9999//xoiJAgLEYOEntbVVigB4PNNm3cMpqSkfMRms50McdyFgkqlgqKiovJTp069nZ97BhEShAWJQePYj373xdF1GzbLFQrFx6Ghob766ne8KNy7dw+KiopO5ubmfmTK4tsICMbG4EkxWT99d35l4rre/v7+D0NCQvh0Ot3QU8wL1Go1SKVSTX5+/sH8/PyDSP8bhIWOUTLsLuVklQcFR65pbGzcvnLlyvfc3NwsCASCMaaac+h0OhgaGoLq6uqaCxcu/OV01tGcTw7uM7VZCAhGx2jpug/vxAd58atzoqKitq1cuXKnvb29saabE+h0Oqiurpbm5eUdrK6uPlspuDrvY0hmO4YIhUIBGq1/X2CmNqFQKL3/79HomZ/z82xEowyy9zFr80zGDqPn/hdeviBmL47ad+fOnRsRERGbQkNDo62srIw97azT2dkJxcXFx0tKSo7Mdh8hY4LD4TDPH2U4MFjMc6tLmZmZzaj+Aw6H0/t9PB4PGCxmRudNJBL0ngeZTAI0Gj3jv+1szfM88Hic8cUEAKCmqlQOAN/ELU2qkEgkySwWK3HRokVcBoMxG9MbDZ1OB83NzdDU1FRQW1t7XiAQHJ+ovu18pbr6Rg6L5ZtoM0EhcUPT0tJW8tWRb0vQqIkvgKqqmhnVfrl2TfANXo+gjKlUio4OWc1M5sjOzjnQUH8rbqLPu3t6moaGhmfc+3q25tGHUqmECoEIUKbIrVkcEkONiIh4jcvlvu7s7OxLo9GmVe7QVCgUCujq6oKGhoaCioqKo9XV1WeM3YDMVPDik1gpyas+XrVyeaKXl8czjyANjbcgI/MNmkg49Q4ECPOH3NyC4RUr+M8IcHt7B1y9WlKRl3/5kElKnD1sfXEoJCzueEBAQGJYWFgGk8nk2djYAIFAgLm4pTw6Ogqjo6Mgl8vhxo0b50tLS4/U19fnLvS2FIWXfxEDQNLmLW9ueW1TxtchHDaQyWRTm4VgYkZHR6G+vhF+/NfP+y5e+vVjiVgwZpKVydOwF0dZW1lZOTGZTD6bzU4LCAiIptPp8HTDL1MwOjoKLS0tUFdXd1IsFudIpdKKgYGB7tloJTrX4MUnsVJTEj9etzY10dHRAQAAGm81wcsZW5CVyQInL69gNCGBjwcAGBx8ANnncypOnTr3H9nn/reD55wovvrQpyIHAHFUzIocGo3mQaPRfBwdHVlubm7bXF1dgcFgABqNNvruglwuh7t374JMJoOOjo7P79y5I+ru7m7q7e1tXQi7MzOh8PIv4pCw2DdaWtte37Au7aPIyCWAxWABjUbPif9HCMbjURtKiaQBfvr5zH9evlJ0uLQ4r/nJMXNiZTIRrMAlJAcHB18HBweWo6Mjy8rKajeJRAJLS0uwtLQECwsLoFAogMfjAYvFgpmZ2XNXMyqVCoaHh2FoaAiGh4cfvwYGBqCvrw+6u7vfvnfvXlNvb29rT09Pq0QsUM7S6c4rNqS/lrZ5U+YPRBKR9M7u9xwqBUUvtNAudH766XSLE8PR49ixE78/8tVnX403Zk7fUR46NUUAIPIPCMdTKJTdNjY2QKPRgE6nA51OB1tbWyCRSIDD4YBAIAAejwcCgfDYUajVakGlUoFarQadTvfY79HX1wf9/f0gl8tBLpfDvXv3HvXw+dxQPYYXMj+d+P7Mmzv+5OHr6/OJWq1GBHeB09TcUiKuq/coKS3/eqIx/wPkiIXC3w6YjAAAAABJRU5ErkJggg=="); + + --keyword: #ff79c6; + --identifier: #f8f8f2; + --comment: #6272a4; + --operator: #ff79c6; + --punctuation: #f8f8f2; + --other: #f8f8f2; + --escapeSequence: #bd93f9; + --number: #bd93f9; + --literal: #f1fa8c; + --program: #9090c0; + --option: #90b010; + --raw-data: #8be9fd; + + --clipboard-image-normal: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' style='color: lightgray' fill='none' viewBox='0 0 24 24' stroke='currentColor'%3E %3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2' /%3E %3C/svg%3E"); + --clipboard-image-selected: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' style='color: lightgray' viewBox='0 0 20 20' fill='currentColor'%3E %3Cpath d='M8 3a1 1 0 011-1h2a1 1 0 110 2H9a1 1 0 01-1-1z' /%3E %3Cpath d='M6 3a2 2 0 00-2 2v11a2 2 0 002 2h8a2 2 0 002-2V5a2 2 0 00-2-2 3 3 0 01-3 3H9a3 3 0 01-3-3z' /%3E %3C/svg%3E"); + --clipboard-image: var(--clipboard-image-normal); + } +} + +.theme-select-wrapper { + display: flex; + align-items: center; +} + +html { + font-size: 100%; + -webkit-text-size-adjust: 100%; + -ms-text-size-adjust: 100%; } + +body { + font-family: "Lato", "Helvetica Neue", "HelveticaNeue", Helvetica, Arial, sans-serif; + font-weight: 400; + font-size: 1.125em; + line-height: 1.5; + color: var(--text); + background-color: var(--primary-background); } + +/* Skeleton grid */ +.container { + position: relative; + width: 100%; + max-width: 1050px; + margin: 0 auto; + padding: 0; + box-sizing: border-box; } + +.column, .columns { + width: 100%; + float: left; + box-sizing: border-box; + margin-left: 1%; } + +@media print { + #global-links, .link-seesrc, .theme-switch-wrapper, #searchInputDiv, .search-groupby { + display:none; + } + .columns { + width:100% !important; + } +} + +.column:first-child, .columns:first-child { + margin-left: 0; } + +.container .row { + display: flex; } + +.three.columns { + width: 25.0%; + height: 100vh; + position: sticky; + top: 0px; + overflow-y: auto; + padding: 2px; +} + +.nine.columns { + width: 75.0%; + padding-left: 1.5em; } + +.twelve.columns { + width: 100%; + margin-left: 0; } + +@media screen and (max-width: 860px) { + .three.columns { + display: none; + } + .nine.columns { + width: 98.0%; + } + body { + font-size: 1em; + line-height: 1.35; + } +} + +cite { + font-style: italic !important; } + + +/* Nim search input */ +div#searchInputDiv { + margin-bottom: 1em; +} +input#searchInput { + width: 80%; +} + +/* + * Some custom formatting for input forms. + * This also fixes input form colors on Firefox with a dark system theme on Linux. + */ +input { + -moz-appearance: none; + background-color: var(--secondary-background); + color: var(--text); + border: 1px solid var(--border); + font-family: "Lato", "Helvetica Neue", "HelveticaNeue", Helvetica, Arial, sans-serif; + font-size: 0.9em; + padding: 6px; +} + +input:focus { + border: 1px solid var(--input-focus); + box-shadow: 0 0 3px var(--input-focus); +} + +select { + -moz-appearance: none; + background-color: var(--secondary-background); + color: var(--text); + border: 1px solid var(--border); + font-family: "Lato", "Helvetica Neue", "HelveticaNeue", Helvetica, Arial, sans-serif; + font-size: 0.9em; + padding: 6px; +} + +select:focus { + border: 1px solid var(--input-focus); + box-shadow: 0 0 3px var(--input-focus); +} + +/* Docgen styles */ + +:target { + border: 2px solid #B5651D; + border-style: dotted; +} + +/* Links */ +a { + color: var(--anchor); + text-decoration: none; +} + +a span.Identifier { + text-decoration: underline; + text-decoration-color: #aab; +} + +a.reference-toplevel { + font-weight: bold; +} + +a.nimdoc { + word-spacing: 0.3em; +} + +a.toc-backref { + text-decoration: none; + color: var(--text); +} + +a.link-seesrc { + color: #607c9f; + font-size: 0.9em; + font-style: italic; +} + +a:hover, a:focus { + color: var(--anchor-focus); + text-decoration: underline; +} + +a:hover span.Identifier { + color: var(--anchor); +} + + +sub, sup { + position: relative; + font-size: 75%; + line-height: 0; + vertical-align: baseline; } + +sup { + top: -0.5em; } + +sub { + bottom: -0.25em; } + +img { + width: auto; + height: auto; + max-width: 100%; + vertical-align: middle; + border: 0; + -ms-interpolation-mode: bicubic; } + +@media print { + * { + color: black !important; + text-shadow: none !important; + background: transparent !important; + box-shadow: none !important; } + + a, a:visited { + text-decoration: underline; } + + a[href]:after { + content: " (" attr(href) ")"; } + + abbr[title]:after { + content: " (" attr(title) ")"; } + + .ir a:after, + a[href^="javascript:"]:after, + a[href^="#"]:after { + content: ""; } + + pre, blockquote { + border: 1px solid #999; + page-break-inside: avoid; } + + thead { + display: table-header-group; } + + tr, img { + page-break-inside: avoid; } + + img { + max-width: 100% !important; } + + @page { + margin: 0.5cm; } + + h1 { + page-break-before: always; } + + h1.title { + page-break-before: avoid; } + + p, h2, h3 { + orphans: 3; + widows: 3; } + + h2, h3 { + page-break-after: avoid; } +} + + +p { + margin-top: 0.5em; + margin-bottom: 0.5em; } + +small { + font-size: 85%; } + +strong { + font-weight: 600; + font-size: 0.95em; + color: var(--strong); } + +em { + font-style: italic; } + +h1 { + font-size: 1.8em; + font-weight: 400; + padding-bottom: .25em; + border-bottom: 6px solid var(--third-background); + margin-top: 2.5em; + margin-bottom: 1em; + line-height: 1.2em; } + +h1.title { + padding-bottom: 1em; + border-bottom: 0px; + font-size: 2.5em; + text-align: center; + font-weight: 900; + margin-top: 0.75em; + margin-bottom: 0em; } + +h2 { + font-size: 1.3em; + margin-top: 2em; } + +h2.subtitle { + margin-top: 0em; + text-align: center; } + +h3 { + font-size: 1.125em; + font-style: italic; + margin-top: 1.5em; } + +h4 { + font-size: 1.125em; + margin-top: 1em; } + +h5 { + font-size: 1.125em; + margin-top: 0.75em; } + +h6 { + font-size: 1.1em; } + + +ul, ol { + padding: 0; + margin-top: 0.5em; + margin-left: 0.75em; } + +ul ul, ul ol, ol ol, ol ul { + margin-bottom: 0; + margin-left: 1.25em; } + +ul.simple > li { + list-style-type: circle; } + +ul.simple-boot li { + list-style-type: none; + margin-left: 0em; + margin-bottom: 0.5em; } + +ol.simple > li, ul.simple > li { + margin-bottom: 0.2em; + margin-left: 0.4em } + +ul.simple.simple-toc > li { + margin-top: 1em; } + +ul.simple-toc { + list-style: none; + font-size: 0.9em; + margin-left: -0.3em; + margin-top: 1em; } + +ul.simple-toc > li { + list-style-type: none; } + +ul.simple-toc-section { + list-style-type: circle; + margin-left: 0.8em; + color: #6c9aae; } + +ul.nested-toc-section { + list-style-type: circle; + margin-left: -0.75em; + color: var(--text); } + +ul.nested-toc-section > li { + margin-left: 1.25em; } + + +ol.arabic { + list-style: decimal; } + +ol.loweralpha { + list-style: lower-alpha; } + +ol.upperalpha { + list-style: upper-alpha; } + +ol.lowerroman { + list-style: lower-roman; } + +ol.upperroman { + list-style: upper-roman; } + +ul.auto-toc { + list-style-type: none; } + + +dl { + margin-bottom: 1.5em; } + +dt { + margin-bottom: -0.5em; + margin-left: 0.0em; } + +dd { + margin-left: 2.0em; + margin-bottom: 3.0em; + margin-top: 0.5em; } + + +hr { + margin: 2em 0; + border: 0; + border-top: 1px solid #aaa; } + +hr.footnote { + width: 25%; + border-top: 0.15em solid #999; + margin-bottom: 0.15em; + margin-top: 0.15em; +} +div.footnote-group { + margin-left: 1em; +} +div.footnote-label { + display: inline-block; + min-width: 1.7em; +} + +div.option-list { + border: 0.1em solid var(--border); +} +div.option-list-item { + padding-left: 12em; + padding-right: 0; + padding-bottom: 0.3em; + padding-top: 0.3em; +} +div.odd { + background-color: var(--secondary-background); +} +div.option-list-label { + margin-left: -11.5em; + margin-right: 0em; + min-width: 11.5em; + display: inline-block; + vertical-align: top; +} +div.option-list-description { + width: calc(100% - 1em); + padding-left: 1em; + padding-right: 0; + display: inline-block; +} + +blockquote { + font-size: 0.9em; + font-style: italic; + padding-left: 0.5em; + margin-left: 0; + border-left: 5px solid #bbc; +} + +blockquote.markdown-quote { + font-size: 0.9rem; /* use rem to avoid recursion */ + font-style: normal; +} + +.pre, span.tok { + font-family: "Source Code Pro", Monaco, Menlo, Consolas, "Courier New", monospace; + font-weight: 500; + font-size: 0.85em; + color: var(--text); + background-color: var(--third-background); + padding-left: 3px; + padding-right: 3px; + border-radius: 4px; +} + +span.tok { + border: 1px solid #808080; + padding-bottom: 0.1em; + margin-right: 0.2em; +} + +.copyToClipBoard { + position: relative; +} + +pre { + font-family: "Source Code Pro", Monaco, Menlo, Consolas, "Courier New", monospace; + color: var(--text); + font-weight: 500; + display: inline-block; + box-sizing: border-box; + min-width: 100%; + padding: 0.5em; + margin-top: 0.5em; + margin-bottom: 0.5em; + font-size: 0.85em; + white-space: pre !important; + overflow-y: hidden; + overflow-x: visible; + background-color: var(--secondary-background); + border: 1px solid var(--border); + -webkit-border-radius: 6px; + -moz-border-radius: 6px; + border-radius: 6px; +} + +.copyToClipBoardBtn { + visibility: hidden; + position: absolute; + width: 24px; + border-radius: 4px; + background-image: var(--clipboard-image); + right: 5px; + top: 13px; + background-color: var(--secondary-background); + padding: 11px; + border: 0; +} + +.copyToClipBoard:hover .copyToClipBoardBtn { + visibility: visible; +} + +.pre-scrollable { + max-height: 340px; + overflow-y: scroll; } + + +/* Nim line-numbered tables */ +.line-nums-table { + width: 100%; + table-layout: fixed; } + +table.line-nums-table { + border-radius: 4px; + border: 1px solid var(--border); + background-color: var(--secondary-background); + border-collapse: separate; + margin-top: 15px; + margin-bottom: 25px; } + +.line-nums-table tbody { + border: none; } + +.line-nums-table td pre { + border: none; + background-color: transparent; } + +.line-nums-table td.blob-line-nums { + width: 28px; } + +.line-nums-table td.blob-line-nums pre { + color: #b0b0b0; + -webkit-filter: opacity(75%); + filter: opacity(75%); + text-align: right; + border-color: transparent; + background-color: transparent; + padding-left: 0px; + margin-left: 0px; + padding-right: 0px; + margin-right: 0px; } + + +table { + max-width: 100%; + background-color: transparent; + margin-top: 0.5em; + margin-bottom: 1.5em; + border-collapse: collapse; + border-color: var(--third-background); + border-spacing: 0; +} + +table:not(.line-nums-table) { + font-size: 0.9em; +} + +table th, table td { + padding: 0px 0.5em 0px; + border-color: var(--third-background); +} + +table th { + background-color: var(--third-background); + border-color: var(--third-background); + font-weight: bold; } + +table th.docinfo-name { + background-color: transparent; + text-align: right; +} + +table:not(.line-nums-table) tr:hover { + background-color: var(--third-background); } + + +/* rst2html default used to remove borders from tables and images */ +.borderless, table.borderless td, table.borderless th { + border: 0; } + +table.borderless td, table.borderless th { + /* Override padding for "table.docutils td" with "! important". + The right padding separates the table cells. */ + padding: 0 0.5em 0 0 !important; } + +.admonition { + padding: 0.3em; + background-color: var(--secondary-background); + border-left: 0.4em solid #7f7f84; + margin-bottom: 0.5em; + -webkit-box-shadow: 0 5px 8px -6px rgba(0,0,0,.2); + -moz-box-shadow: 0 5px 8px -6px rgba(0,0,0,.2); + box-shadow: 0 5px 8px -6px rgba(0,0,0,.2); +} +.admonition-info { + border-color: var(--info-background); +} +.admonition-info-text { + color: var(--info-background); +} +.admonition-warning { + border-color: var(--warning-background); +} +.admonition-warning-text { + color: var(--warning-background); +} +.admonition-error { + border-color: var(--error-background); +} +.admonition-error-text { + color: var(--error-background); +} + +.first { + /* Override more specific margin styles with "! important". */ + margin-top: 0 !important; } + +.last, .with-subtitle { + margin-bottom: 0 !important; } + +.hidden { + display: none; } + +blockquote.epigraph { + margin: 2em 5em; } + +dl.docutils dd { + margin-bottom: 0.5em; } + +object[type="image/svg+xml"], object[type="application/x-shockwave-flash"] { + overflow: hidden; } + + +div.figure { + margin-left: 2em; + margin-right: 2em; } + +div.footer, div.header { + clear: both; + text-align: center; + color: #666; + font-size: smaller; } + +div.footer { + padding-top: 5em; } + +div.line-block { + display: block; + margin-top: 1em; + margin-bottom: 1em; } + +div.line-block div.line-block { + margin-top: 0; + margin-bottom: 0; + margin-left: 1.5em; } + +div.topic { + margin: 2em; } + +div.search_results { + background-color: var(--third-background); + padding: 1em; + border: 1px solid #4d4d4d; + position: sticky; + top: 1em; + isolation: isolate; + max-width: calc(100vw - 6em); + z-index: 1; + max-height: calc(100vh - 6em); + overflow-y: scroll;} + +div#global-links ul { + margin-left: 0; + list-style-type: none; } + +div#global-links > simple-boot { + margin-left: 3em; } + +hr.docutils { + width: 75%; } + +img.align-left, .figure.align-left, object.align-left { + clear: left; + float: left; + margin-right: 1em; } + +img.align-right, .figure.align-right, object.align-right { + clear: right; + float: right; + margin-left: 1em; } + +img.align-center, .figure.align-center, object.align-center { + display: block; + margin-left: auto; + margin-right: auto; } + +.align-left { + text-align: left; } + +.align-center { + clear: both; + text-align: center; } + +.align-right { + text-align: right; } + +/* reset inner alignment in figures */ +div.align-right { + text-align: inherit; } + +p.attribution { + text-align: right; + margin-left: 50%; } + +p.caption { + font-style: italic; } + +p.credits { + font-style: italic; + font-size: smaller; } + +p.label { + white-space: nowrap; } + +p.rubric { + font-weight: bold; + font-size: larger; + color: maroon; + text-align: center; } + +p.topic-title { + font-weight: bold; } + +pre.address { + margin-bottom: 0; + margin-top: 0; + font: inherit; } + +pre.literal-block, pre.doctest-block, pre.math, pre.code { + margin-left: 2em; + margin-right: 2em; } + +pre.code .ln { + color: grey; } + +/* line numbers */ +pre.code, code { + background-color: #eeeeee; } + +pre.code .comment, code .comment { + color: #5c6576; } + +pre.code .keyword, code .keyword { + color: #3B0D06; + font-weight: bold; } + +pre.code .literal.string, code .literal.string { + color: #0c5404; } + +pre.code .name.builtin, code .name.builtin { + color: #352b84; } + +pre.code .deleted, code .deleted { + background-color: #DEB0A1; } + +pre.code .inserted, code .inserted { + background-color: #A3D289; } + +span.classifier { + font-style: oblique; } + +span.classifier-delimiter { + font-weight: bold; } + +span.problematic { + color: #b30000; } + +span.section-subtitle { + /* font-size relative to parent (h1..h6 element) */ + font-size: 80%; } + +span.DecNumber { + color: var(--number); } + +span.BinNumber { + color: var(--number); } + +span.HexNumber { + color: var(--number); } + +span.OctNumber { + color: var(--number); } + +span.FloatNumber { + color: var(--number); } + +span.Identifier { + color: var(--identifier); } + +span.Keyword { + font-weight: 600; + color: var(--keyword); } + +span.StringLit { + color: var(--literal); } + +span.LongStringLit { + color: var(--literal); } + +span.CharLit { + color: var(--literal); } + +span.EscapeSequence { + color: var(--escapeSequence); } + +span.Operator { + color: var(--operator); } + +span.Punctuation { + color: var(--punctuation); } + +span.Comment, span.LongComment { + font-style: italic; + font-weight: 400; + color: var(--comment); } + +span.RegularExpression { + color: darkviolet; } + +span.TagStart { + color: darkviolet; } + +span.TagEnd { + color: darkviolet; } + +span.Key { + color: #252dbe; } + +span.Value { + color: #252dbe; } + +span.RawData { + color: var(--raw-data); } + +span.Assembler { + color: #252dbe; } + +span.Preprocessor { + color: #252dbe; } + +span.Directive { + color: #252dbe; } + +span.option { + font-weight: bold; + font-family: "Source Code Pro", Monaco, Menlo, Consolas, "Courier New", monospace; + color: var(--option); } + +span.Prompt { + font-weight: bold; + color: red; } + +span.ProgramOutput { + font-weight: bold; + color: #808080; } + +span.program { + font-weight: bold; + color: var(--program); + text-decoration: underline; + text-decoration-color: var(--hint); + text-decoration-thickness: 0.05em; + text-underline-offset: 0.15em; } + +span.Command, span.Rule, span.Hyperlink, +span.Label, span.Reference, span.Other { + color: var(--other); } + +/* Pop type, const, proc, and iterator defs in nim def blocks */ +dt pre > span.Identifier, dt pre > span.Operator { + color: var(--identifier); + font-weight: 700; } + +dt pre > span.Keyword ~ span.Identifier, dt pre > span.Identifier ~ span.Identifier, +dt pre > span.Operator ~ span.Identifier, dt pre > span.Other ~ span.Identifier { + color: var(--identifier); + font-weight: inherit; } + +/* Nim sprite for the footer (taken from main page favicon) */ +.nim-sprite { + display: inline-block; + width: 51px; + height: 14px; + background-position: 0 0; + background-size: 51px 14px; + -webkit-filter: opacity(50%); + filter: opacity(50%); + background-repeat: no-repeat; + background-image: var(--nim-sprite-base64); + margin-bottom: 5px; } + +span.pragmadots { + /* Position: relative frees us up to make the dots + look really nice without fucking up the layout and + causing bulging in the parent container */ + position: relative; + /* 1px down looks slightly nicer */ + top: 1px; + padding: 2px; + background-color: var(--third-background); + border-radius: 4px; + margin: 0 2px; + cursor: pointer; + font-size: 0.8em; } + +span.pragmadots:hover { + background-color: var(--hint); } + +span.pragmawrap { + display: none; } + +span.attachedType { + display: none; + visibility: hidden; } diff --git a/pylib.html b/pylib.html new file mode 100644 index 000000000..025a877a8 --- /dev/null +++ b/pylib.html @@ -0,0 +1,156 @@ + + + + + + + +src/pylib + + + + + + + + + + + + + + + + +
+
+

src/pylib

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

Welcome to NimPyLib 0.9.11

+ + +

Nim Pylib

Just write Python code in Nim!

+ +

import pylib

The mostly suggested style is

+

import pkg/pylib

+

However, omitting the pkg/ prefix shall be fine at most cases:

+

import pylib

+ +

import Python-like stdlib

Cheatsheet for rough alternative between pylib and Python

+ + + + +
Nim pylibPython
from pylib/Lib/LIB import nilimport LIB
import pylib/Lib/LIBfrom LIB import *
from pylib/Lib/LIB import XXXimport LIB; from LIB import XXX

+

Wondering how many libs are available in NimPylib?

+

Here are the Lib Docs.

+
Warning: +std/lenientops was imported automatically. Compile with -d:pylibNoLenient to disable it if you wish to do int->float conversions yourself
+

+ +
+

Templates

+
+
+
+
template timeit(repetitions: int; statements: untyped): untyped {....deprecated: "will be removed from main pylib since 0.10, import it from `pylib/Lib` instead".}
+
+
+ Deprecated: will be removed from main pylib since 0.10, import it from `pylib/Lib` instead +
+ +

EXT.

+

Mimics Pythons timeit.timeit(), output shows more information than Pythons.

+ + Source   +Edit   + +
+
+ +
+ +
+
+
+

Exports

+
+ write, close, read, read, close, readline, initBufAsPy, readline, write, open, readline, readline, truncate, truncate, read, close, readline, readline, read, write, open, read, seek, read, seek, None, NoneType, or, or, and, not, or, PyBool, ==, bool, toBool, toNimBool, ==, and, repr, pybool, not, and, $, True, is, False, ==, or, and, any, pybool, xor, all, min, upper, center, <=, maketrans, repr, min, float, rindex, -=, ==, -, find, ascii, count, int, len, +=, partition, fr, reversed, endsWith, maketrans, checkLenientOps, msg, float, items, osErrorMsgWithPath, min, bytes, remove, slice, raiseExcWithPath, str, clear, filter, [], rindex, format, TranslateTableVal, id, PyByteArray, <=, ==, repr, isdigit, zip, round, print, ==, PyFrozenSet, getPtr, [], byteLen, ascii, rstrip, replace, clear, repr, endsWith, count, indices, contains, ConnectionResetError, GeneratorExit, int, newPyOSError, TranslateTableABC, $, ==, slice, &, len, repr, iter, set, $, raiseErrno, zip, len, +=, bytearray, startsWith, dirImpl, $, toPyDict, max, pyrepr, reversed, <, chars, endsWith, hash, $, contains, pow, newPyList, toNimString, bytes, pydiscard, maketrans, PermissionError, isascii, count, msg, delitem, pyset, float, repr, sorted, items, [], imag=, TranslateValType, osErrorMsgWithPath, round, newPyList, raiseExcWithPath2, /, rstrip, **, *, $, items, lstrip, min, iter, and, clear, bytearray, [], pow, raiseExcWithPath, hasattr, set, *=, []=, rsplit, Fr, istitle, /, FileNotFoundError, map, count, -, min, -, len, setdefault, ==, contains, ==, PyComplex, len, startsWith, []=, real=, BytesLike, FileExistsError, substr, $, toPyStr, splitlines, +, PyDictItemView, split, islower, endsWith, +=, pop, rjust, join, upper, b, /, $, checked_as_integer_ratio, append, issubset, remove, +=, as_integer_ratio, ==, nextImpl, input, repr, newStopIteration, TranslateTable, IsADirectoryError, zip, PyTComplex, lower, <, pyset, isascii, or, round, *, newPyFrozenSet, PyOSError, *=, int, casefold, delitem, repr, +, PyRange, getattr, -, lower, ==, *, add, getattr, ==, newPySet, hex, union, split, ==, pybytes, str, pow, SomePyDictView, isinstance, **, hex, format, sort, difference, max, extend, rpartition, +=, <=, UnicodeError, delitem, symmetric_difference, ProcessLookupError, PyBytes, [], ArithmeticError, set, rb, bytearray, contains, [], split, intersection, symmetric_difference, isspace, str, ascii, mitems, startsWith, rstrip, isalpha, pow, imag, real, to_bytes, NoneType, +, **=, complex, title, replace, len, difference, endsWith, split, count, *, |=, []=, ==, +, repr, abs, errnoMsg, toPySlice, bit_length, b, splitlines, intersection, count, $, items, -=, runeAtPos, +, frozenset, union, ljust, pairs, max, min, PySlice, PyOSError, contains, ZeroDivisionError, <, ChildProcessError, startsWith, add_from_bytes, translate, TypeError, clear, NameError, items, center, dict, KeyboardInterrupt, rsplit, $, pop, +=, +=, int, toNimStr, max, getCharPtr, TypedTranslateTableABC, SomeSinglePyDictView, items, index, isdisjoint, delitem, PyList, NotADirectoryError, symmetric_difference, NotImplementedError, ord1, max, newPyListOfCap, <=, ascii, $, -=, bit_count, int, delitem, reversed, items, hash, slice, [], format, [], delitem, set, iter, chars, repr, Rb, pycomplex, sorted, +, tryOsOp, iter, bytearray, pow, ==, []=, PyDictView, str, repr, min, reverse, PyDictKeyView, rjust, as_integer_ratio, &=, <, casefold, repr, startsWith, frozenset, split, isupper, istitle, max, +=, symmetric_difference, set, bytearray, intersection, hasChar, startsWith, difference_update, oct, +, difference, index, +, SomePySet, partition, +, StopAsyncIteration, toPyDict, index, max, center, int, <, pow, str, rjust, startsWith, reversed, +, isalpha, <, newBlockingIOError, pow, chars, hash, <=, complex, conjugate, discard, br, translate, newUnicodeDecodeError, hash, hash, hash, get, [], reverse, hex, pysetLit, dir, PyDict, bytes, TimeoutError, ljust, TranslateAction, ord, to_chars, toNimComplex, pow, find, complex, is_integer, next, rf, []=, +, StringLike, newPyListOfStr, newPyList, /=, contains, **, endsWith, toNimString, translate, bytes, SomeSet, newUnicodeDecodeError, replace, float_fromhex, removeprefix, toPyBytes, len, sorted, hash, maketrans, newPyList, map, hex, get, Comparable, [], rsplit, <, int, list, PyIterator, count, range, *, update, chr, endsWith, complex, filter, removesuffix, delitem, dir, StopIteration, []=, J, pyset, []=, float, union, count, bytes, ==, rsplit, repr, getattr, popitem, newPyIterator, +, replace, items, contains, newPyOSError, $, repr, ljust, [], ord, **, $, toPyStr, byteLen, pow, copy, newPyList, len, /=, InterruptedError, /, $, @, nextImpl, newStopIteration, startsWith, isascii, *=, +, *, endsWith, pow, **, sort, rpartition, getCharPtr, isspace, as_someinteger_ratio, to_bytes, complex, count, $, splitlines, frozenset, is_integer, items, $, expandtabs, from_bytes, items, AttributeError, Rf, tryOsOp, -=, ==, lstrip, ==, +, []=, []=, frozenset, RuntimeError, PyDictValueView, union, rstrip, runes, StrTypedTranslateTable, newBlockingIOError, not, contains, None, bytes, ljust, find, newPyListOfStr, intersection_update, values, endsWith, UnicodeDecodeError, rsplit, list, range, zfill, min, bytearray, contains, **, endsWith, PyOSError, issuperset, |, from_bytes, tryOsOp, Br, noWeirdTarget, toNimString, raiseExcWithPath, keys, [], bytes, toNimSlice, list, pow, fromhex, translate, raiseExcWithPath, bytes, list, bytes, enumerate, <=, setattr, -, enumerate, 'j, long, filter, round, getChar, *=, newPyByteArray, []=, setattr, rfind, -, union, startsWith, items, split, <=, substr, ConnectionRefusedError, translate, bin, BlockingIOError, copy, u, set, PySlice1, difference, strip, StopIterationT, long, removeprefix, frozenset, *, insert, issubclass, rindex, center, raiseErrnoT, str, filter, /, round, split, $, nimArrayAsList, dirImpl, getChar, ConnectionError, hash, toNimString, count, *=, repr, contains, newPyList, lstrip, -, hasattr, strip, map, capitalize, len, []=, pop, split, +=, pop, append, +=, rfind, pyset, newPyFrozenSet, int, or, capitalize, ==, -, hex, extend, BlockingIOError, items, contains, title, *, intersection, min, [], tryOsOp, +=, items, ==, iter, emptyPyDict, pycomplex, <=, items, substr, PyStr, <, len, isupper, max, index, startsWith, BrokenPipeError, index, int, rjust, hash, conjugate, translate, reverse, next, runeLenAt, /=, list, BlockingIOError, PyLibKey, update, []=, count, getattr, newPyByteArray, range, $, toPyStr, copy, @, u, *, |=, splitlines, expandtabs, ==, ==, not, values, hex, rsplit, |, zfill, keys, fromhex, raiseErrnoWithPath, long, getChar, strip, rfind, strip, newPySet, symmetric_difference, <, removesuffix, islower, lstrip, pop, PySet, extend, <>, ConnectionAbortedError, setLen, intersection, SystemExit, +=, items, iter, max, hash, [], fspath, []=, newPyByteArray, *, j, pop, <=, frozenset, long, f, pyset, join, difference, translate, NimInt, fspath, *, ^, items, nimint, insert, /, <<, %, <>, <, &, **, &=, **, <, %, ==, <=, |, <<=, **, ^, <=, **, ==, >>=, //=, |=, ~, %, ==, divmod, >>, <>, //, **=, **, ^=, %=, osErrorMsgWithPath, raiseExcWithPath2, RuntimeError, AttributeError, newStopIteration, ConnectionError, BlockingIOError, GeneratorExit, newUnicodeDecodeError, ChildProcessError, newBlockingIOError, raiseErrnoWithPath, InterruptedError, $, NotADirectoryError, newStopIteration, errnoMsg, NotImplementedError, BrokenPipeError, TimeoutError, UnicodeError, TypeError, msg, raiseExcWithPath, osErrorMsgWithPath, UnicodeDecodeError, raiseErrno, tryOsOp, ConnectionRefusedError, IsADirectoryError, raiseExcWithPath, noWeirdTarget, $, ArithmeticError, tryOsOp, BlockingIOError, StopAsyncIteration, PyOSError, ConnectionAbortedError, raiseErrnoT, SystemExit, tryOsOp, FileNotFoundError, PyOSError, ConnectionResetError, BlockingIOError, StopIterationT, tryOsOp, PyOSError, NameError, newBlockingIOError, $, KeyboardInterrupt, raiseExcWithPath, newUnicodeDecodeError, newPyOSError, StopIteration, PermissionError, ProcessLookupError, msg, FileExistsError, newPyOSError, raiseExcWithPath, ZeroDivisionError, async, define, init_subclass, def, new, lambda, PySignatureSupportGenerics, unpack, pass, with, del, :=, class, tonim +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib.idx b/pylib.idx new file mode 100644 index 000000000..07df66efc --- /dev/null +++ b/pylib.idx @@ -0,0 +1,5 @@ +nimTitle pylib pylib.html module src/pylib 0 +nim timeit pylib.html#timeit.t,int,untyped template timeit(repetitions: int; statements: untyped): untyped 55 +heading Nim Pylib pylib.html#nim-pylib Nim Pylib 0 +heading import pylib pylib.html#nim-pylib-import-pylib import pylib 0 +heading import Python-like stdlib pylib.html#nim-pylib-import-pythonminuslike-stdlib import Python-like stdlib 0 diff --git a/pylib.nimble b/pylib.nimble deleted file mode 100644 index 9916e1df9..000000000 --- a/pylib.nimble +++ /dev/null @@ -1,166 +0,0 @@ -srcDir = "src" -when fileExists("./src/pylib/version.nim"): # when installing - assert srcDir == "src" - import "./src/pylib/version" as libver - # `import as` to avoid compile error against `version = Version` -else: # after installed - import "pylib/version" as libver - -version = Version -author = "Danil Yarantsev (Yardanico), Juan Carlos (juancarlospaco), lit (litlighilit)" -description = "Nim library with python-like functions and operators" -license = "MIT" -skipDirs = @["examples"] - -requires "nim > 2.0.4" -# 1.6.0: ensure `pydef.nim`c's runnableExamples works -# 2.0.4: `Lib/sys_impl/getencodings` `template importPython(submod, sym) = from ../../Python/submod import sym` doesn't work - -import std/os - -proc runTestament(targets = "c") = - for path in listDirs("./tests/testaments"): - if path.lastPathPart in ["nimcache", "testresults"]: - continue - exec "testament --targets:" & targets.quoteShell & " pat " & quoteShell path - -func getArgs(taskName: string): seq[string] = - ## cmdargs: 1 2 3 4 5 -> 1 4 3 2 5 - var rargs: seq[string] - let argn = paramCount() - for i in countdown(argn, 0): - let arg = paramStr i - if arg == taskName: - break - rargs.add arg - if rargs.len > 1: - swap rargs[^1], rargs[0] # the file must be the last, others' order don't matter - return rargs - -template mytask(name: untyped, taskDesc: string, body){.dirty.} = - task name, taskDesc: - let taskName = astToStr(name) - body - -template taskWithArgs(name, taskDesc, body){.dirty.} = - mytask name, taskDesc: - var args = getArgs taskName - body - -task testJs, "Test JS": - selfExec "js -r -d:nodejs tests/tester" - runTestament "js" - -task testC, "Test C": - selfExec "r --mm:orc tests/tester" - runTestament "c" - -taskWithArgs testament, "Testament": - var targets = args.quoteShellCommand - if targets.len == 0: targets = "c js" - runTestament targets - -let - libDir = srcDir / "pylib/Lib" - -func getSArg(taskName: string): string = quoteShellCommand getArgs taskName - -func handledArgs(args: var seq[string], def_arg: string) = - ## makes args: @[option..., arg/"ALL"] - if args.len == 0: - args.add def_arg - return - let lastArg = args[^1] - if lastArg[0] == '-': args.add def_arg - elif lastArg == "ALL": args[^1] = def_arg - # else, the last shall be a nim file - -func getHandledArg(taskName: string, def_arg: string): string = - ## the last param can be an arg, if given, - ## - ## def_arg is set as the last element when the last is not arg or is "ALL", - ## if no arg, then sets def_arg as the only. - var args = getArgs taskName - args.handledArgs def_arg - result = quoteShellCommand args - -mytask testDoc, "cmdargs: if the last is arg: " & - "ALL: gen for all(default); else: a nim file": - let def_arg = srcDir / "pylib.nim" - let sargs = getHandledArg(taskName, def_arg) - selfExec "doc --project --outdir:docs " & sargs - - -const nimSuf = ".nim" - -proc testLib(fp: string, sargs: string) = - var cmd = "doc" - if fp.endsWith nimSuf: - if (fp[0..(fp.len - nimSuf.len-1)] & "_impl").dirExists: - cmd.add " --project" - selfExec cmd & " --outdir:docs/Lib " & sargs & ' ' & fp - -taskWithArgs testLibDoc, "Test doc-gen and runnableExamples, can pass several args": - let def = "ALL" - args.handledArgs def - let fpOrDef = args.pop() - let sargs = quoteShellCommand args - if fpOrDef == def: - for t in walkDir libDir: - if t.kind in {pcDir, pcLinkToDir}: continue - let fp = t.path - testLib fp, sargs - else: - testLib fpOrDef, sargs - -task testDocAll, "Test doc and Lib's doc": - testDocTask() - testLibDocTask() - -task testBackends, "Test C, Js, ..": - # Test C - testCTask() - # Test JS - testJsTask() - -task test, "Runs the test suite": - testBackendsTask() - # Test all runnableExamples - testDocAllTask() - -task rei, "reinstall, for dev only!": - #[ if uninstalling in cwd, may failed with: -Could not read package info file in ~/.nimble/pkgs2/pylib-xxx/pylib.nimble; - Reading as ini file failed with: - Invalid section: . - Evaluating as NimScript file failed with: - ~/.nimble/pkgs2/pylib-xxx/pylib.nimble(4, 32) Error: cannot open file: ./src/pylib/version -printPkgInfo() failed. -]# - withDir "..": - exec "nimble uninstall -y pylib" - - exec "nimble install" - -taskWithArgs changelog, "output for changelog files": - if args.len == 0: - args.add "HEAD" - template catRng(a, b): string = a & ".." & b - let sufArg = - if args.len == 1: - let arg = args[0] - if ".." in arg: arg - else: - let lastTagExecRes = gorgeEx("git describe --tags --abbrev=0") - assert lastTagExecRes.exitCode == 0 - let lastTag = lastTagExecRes.output - catRng(lastTag, arg) - else: - let - rng2 = args.pop() - rng1 = args.pop() - args.add catRng(rng1, rng2) - quoteShellCommand(args) - - exec """git log --reverse --format="%s. (%h)" """ & sufArg - diff --git a/pylib/Lib/collections/abc.html b/pylib/Lib/collections/abc.html new file mode 100644 index 000000000..c1f4caf85 --- /dev/null +++ b/pylib/Lib/collections/abc.html @@ -0,0 +1,96 @@ + + + + + + + +src/pylib/Lib/collections/abc + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/collections/abc

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+ +
+ + +
+
+ + + diff --git a/pylib/Lib/collections/abc.idx b/pylib/Lib/collections/abc.idx new file mode 100644 index 000000000..51e0b7bd8 --- /dev/null +++ b/pylib/Lib/collections/abc.idx @@ -0,0 +1 @@ +nimTitle abc pylib/Lib/collections/abc.html module src/pylib/Lib/collections/abc 0 diff --git a/pylib/Lib/errno.html b/pylib/Lib/errno.html new file mode 100644 index 000000000..710e48ed0 --- /dev/null +++ b/pylib/Lib/errno.html @@ -0,0 +1,96 @@ + + + + + + + +src/pylib/Lib/errno + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/errno

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Exports

+
+ runeLenAt, not, str, str, toPyStr, contains, substr, byteLen, str, items, StringLike, ==, str, toNimString, +, ==, str, chars, contains, and, getChar, $, len, +=, str, +=, len, toPyStr, PyStr, runes, [], ==, runeAtPos, or, contains, +, toNimStr, fspath, +=, toPyStr, [], [], SomeSinglePyDictView, PyDictItemView, values, PyDictValueView, copy, ==, contains, |, pop, SomePyDictView, repr, toPyDict, contains, toPyDict, $, $, $, PyDict, popitem, values, iter, items, setdefault, items, pop, $, clear, []=, get, contains, PyDictKeyView, items, iter, iter, repr, emptyPyDict, repr, len, len, update, dict, keys, keys, contains, get, delitem, PyDictView, |=, repr, [], EPERM, prepareROErrno, EFAULT, EKEYREJECTED, EHOSTUNREACH, EHOSTDOWN, ECONNRESET, EDQUOT, ENONET, EREMCHG, EISDIR, strerror, ESTRPIPE, EMLINK, ENXIO, ETOOMANYREFS, ENODATA, ENOLCK, ENOTRECOVERABLE, $, ECHILD, EISCONN, ECONNABORTED, ENOTDIR, ESRMNT, ENOTEMPTY, EPROTO, EADDRNOTAVAIL, errno, EXDEV, EBADF, EKEYREVOKED, getErrno, EBFONT, EDEADLK, isErr, ESPIPE, ENOKEY, EDOM, ENOEXEC, ENETDOWN, EACCES, setErrno0, ELNRNG, EBADRQC, ENODEV, ENFILE, ETIMEDOUT, ENOBUFS, ENOCSI, ECHRNG, setErrnoRaw, EINVAL, EMEDIUMTYPE, ESHUTDOWN, ERFKILL, EALREADY, EBADFD, ECANCELED, ERESTART, ESRCH, EL2NSYNC, ENETUNREACH, EPROTONOSUPPORT, EBADMSG, ENOTCONN, EMFILE, ENOSYS, ETIME, setErrno, declErrorcodeWith, EILSEQ, ENOPKG, EROFS, ECONNREFUSED, ELIBMAX, ELOOP, EUSERS, ECOMM, EL2HLT, EIDRM, ENOTBLK, ENOTTY, EOPNOTSUPP, EISNAM, ELIBACC, EIO, EPROTOTYPE, EUCLEAN, ENOSTR, EOVERFLOW, EADDRINUSE, ELIBBAD, ENOENT, EAFNOSUPPORT, EMULTIHOP, ENOSR, exportAllErrnosViaEnumOrImportc, ErrnoCount, EINPROGRESS, E2BIG, ESTALE, EBUSY, ENOMEDIUM, ENOANO, EFBIG, EUNATCH, EOWNERDEAD, ESOCKTNOSUPPORT, EXFULL, ELIBEXEC, ERANGE, EL3HLT, ENOSPC, EBADSLT, EDEADLOCK, EEXIST, ENETRESET, EREMOTEIO, EPFNOSUPPORT, ENOLINK, isErr0, ENOMSG, ENOTSUP, prepareRWErrno, EMSGSIZE, EPIPE, EBADE, ENOMEM, ENOTSOCK, ELIBSCN, ENOPROTOOPT, EDESTADDRREQ, ENOTNAM, EADV, EDOTDOT, EKEYEXPIRED, EINTR, EBADR, EL3RST, EAGAIN, ENOTUNIQ, EWOULDBLOCK, ENAVAIL, ENAMETOOLONG, EREMOTE, ETXTBSY +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/Lib/errno.idx b/pylib/Lib/errno.idx new file mode 100644 index 000000000..e9d4e6571 --- /dev/null +++ b/pylib/Lib/errno.idx @@ -0,0 +1 @@ +nimTitle errno pylib/Lib/errno.html module src/pylib/Lib/errno 0 diff --git a/pylib/Lib/errno_impl/errnoConsts.html b/pylib/Lib/errno_impl/errnoConsts.html new file mode 100644 index 000000000..89026fc50 --- /dev/null +++ b/pylib/Lib/errno_impl/errnoConsts.html @@ -0,0 +1,1564 @@ + + + + + + + +src/pylib/Lib/errno_impl/errnoConsts + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/errno_impl/errnoConsts

+
+ +
+ Source   +Edit   + +
+ +

+ +
+

Lets

+
+
+
E2BIG {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EACCES {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EADDRINUSE {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EADDRNOTAVAIL {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EADV {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EAFNOSUPPORT {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EAGAIN {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EALREADY {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EBADE {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EBADF {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EBADFD {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EBADMSG {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EBADR {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EBADRQC {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EBADSLT {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EBFONT {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EBUSY {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ECANCELED {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ECHILD {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ECHRNG {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ECOMM {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ECONNABORTED {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ECONNREFUSED {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ECONNRESET {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EDEADLK {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EDEADLOCK {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EDESTADDRREQ {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EDOM {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EDOTDOT {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EDQUOT {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EEXIST {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EFAULT {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EFBIG {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EHOSTDOWN {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EHOSTUNREACH {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EIDRM {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EILSEQ {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EINPROGRESS {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EINTR {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EINVAL {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EIO {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EISCONN {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EISDIR {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EISNAM {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EKEYEXPIRED {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EKEYREJECTED {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EKEYREVOKED {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EL2HLT {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EL2NSYNC {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EL3HLT {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EL3RST {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ELIBACC {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ELIBBAD {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ELIBEXEC {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ELIBMAX {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ELIBSCN {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ELNRNG {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ELOOP {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EMEDIUMTYPE {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EMFILE {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+ +
+
EMSGSIZE {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EMULTIHOP {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ENAMETOOLONG {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ENAVAIL {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ENETDOWN {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ENETRESET {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ENETUNREACH {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ENFILE {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ENOANO {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ENOBUFS {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ENOCSI {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ENODATA {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ENODEV {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ENOENT {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ENOEXEC {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ENOKEY {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ENOLCK {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+ +
+
ENOMEDIUM {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ENOMEM {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ENOMSG {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ENONET {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ENOPKG {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ENOPROTOOPT {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ENOSPC {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ENOSR {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ENOSTR {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ENOSYS {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ENOTBLK {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ENOTCONN {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ENOTDIR {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ENOTEMPTY {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ENOTNAM {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ENOTRECOVERABLE {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ENOTSOCK {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ENOTSUP {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ENOTTY {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ENOTUNIQ {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ENXIO {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EOPNOTSUPP {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EOVERFLOW {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EOWNERDEAD {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EPERM {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EPFNOSUPPORT {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EPIPE {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EPROTO {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EPROTONOSUPPORT {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EPROTOTYPE {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ERANGE {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EREMCHG {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EREMOTE {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EREMOTEIO {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ERESTART {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ERFKILL {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EROFS {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ESHUTDOWN {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ESOCKTNOSUPPORT {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ESPIPE {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ESRCH {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ESRMNT {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ESTALE {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ESTRPIPE {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ETIME {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ETIMEDOUT {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ETOOMANYREFS {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ETXTBSY {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EUCLEAN {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EUNATCH {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EUSERS {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EWOULDBLOCK {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EXDEV {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
EXFULL {.importc, header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/Lib/errno_impl/errnoConsts.idx b/pylib/Lib/errno_impl/errnoConsts.idx new file mode 100644 index 000000000..b186ab04f --- /dev/null +++ b/pylib/Lib/errno_impl/errnoConsts.idx @@ -0,0 +1,134 @@ +nimTitle errnoConsts pylib/Lib/errno_impl/errnoConsts.html module src/pylib/Lib/errno_impl/errnoConsts 0 +nim E2BIG pylib/Lib/errno_impl/errnoConsts.html#E2BIG let E2BIG 13 +nim EACCES pylib/Lib/errno_impl/errnoConsts.html#EACCES let EACCES 13 +nim EADDRINUSE pylib/Lib/errno_impl/errnoConsts.html#EADDRINUSE let EADDRINUSE 13 +nim EADDRNOTAVAIL pylib/Lib/errno_impl/errnoConsts.html#EADDRNOTAVAIL let EADDRNOTAVAIL 13 +nim EADV pylib/Lib/errno_impl/errnoConsts.html#EADV let EADV 13 +nim EAFNOSUPPORT pylib/Lib/errno_impl/errnoConsts.html#EAFNOSUPPORT let EAFNOSUPPORT 13 +nim EAGAIN pylib/Lib/errno_impl/errnoConsts.html#EAGAIN let EAGAIN 13 +nim EALREADY pylib/Lib/errno_impl/errnoConsts.html#EALREADY let EALREADY 13 +nim EBADE pylib/Lib/errno_impl/errnoConsts.html#EBADE let EBADE 13 +nim EBADF pylib/Lib/errno_impl/errnoConsts.html#EBADF let EBADF 13 +nim EBADFD pylib/Lib/errno_impl/errnoConsts.html#EBADFD let EBADFD 13 +nim EBADMSG pylib/Lib/errno_impl/errnoConsts.html#EBADMSG let EBADMSG 13 +nim EBADR pylib/Lib/errno_impl/errnoConsts.html#EBADR let EBADR 13 +nim EBADRQC pylib/Lib/errno_impl/errnoConsts.html#EBADRQC let EBADRQC 13 +nim EBADSLT pylib/Lib/errno_impl/errnoConsts.html#EBADSLT let EBADSLT 13 +nim EBFONT pylib/Lib/errno_impl/errnoConsts.html#EBFONT let EBFONT 13 +nim EBUSY pylib/Lib/errno_impl/errnoConsts.html#EBUSY let EBUSY 13 +nim ECANCELED pylib/Lib/errno_impl/errnoConsts.html#ECANCELED let ECANCELED 13 +nim ECHILD pylib/Lib/errno_impl/errnoConsts.html#ECHILD let ECHILD 13 +nim ECHRNG pylib/Lib/errno_impl/errnoConsts.html#ECHRNG let ECHRNG 13 +nim ECOMM pylib/Lib/errno_impl/errnoConsts.html#ECOMM let ECOMM 13 +nim ECONNABORTED pylib/Lib/errno_impl/errnoConsts.html#ECONNABORTED let ECONNABORTED 13 +nim ECONNREFUSED pylib/Lib/errno_impl/errnoConsts.html#ECONNREFUSED let ECONNREFUSED 13 +nim ECONNRESET pylib/Lib/errno_impl/errnoConsts.html#ECONNRESET let ECONNRESET 13 +nim EDEADLK pylib/Lib/errno_impl/errnoConsts.html#EDEADLK let EDEADLK 13 +nim EDEADLOCK pylib/Lib/errno_impl/errnoConsts.html#EDEADLOCK let EDEADLOCK 13 +nim EDESTADDRREQ pylib/Lib/errno_impl/errnoConsts.html#EDESTADDRREQ let EDESTADDRREQ 13 +nim EDOM pylib/Lib/errno_impl/errnoConsts.html#EDOM let EDOM 13 +nim EDOTDOT pylib/Lib/errno_impl/errnoConsts.html#EDOTDOT let EDOTDOT 13 +nim EDQUOT pylib/Lib/errno_impl/errnoConsts.html#EDQUOT let EDQUOT 13 +nim EEXIST pylib/Lib/errno_impl/errnoConsts.html#EEXIST let EEXIST 13 +nim EFAULT pylib/Lib/errno_impl/errnoConsts.html#EFAULT let EFAULT 13 +nim EFBIG pylib/Lib/errno_impl/errnoConsts.html#EFBIG let EFBIG 13 +nim EHOSTDOWN pylib/Lib/errno_impl/errnoConsts.html#EHOSTDOWN let EHOSTDOWN 13 +nim EHOSTUNREACH pylib/Lib/errno_impl/errnoConsts.html#EHOSTUNREACH let EHOSTUNREACH 13 +nim EIDRM pylib/Lib/errno_impl/errnoConsts.html#EIDRM let EIDRM 13 +nim EILSEQ pylib/Lib/errno_impl/errnoConsts.html#EILSEQ let EILSEQ 13 +nim EINPROGRESS pylib/Lib/errno_impl/errnoConsts.html#EINPROGRESS let EINPROGRESS 13 +nim EINTR pylib/Lib/errno_impl/errnoConsts.html#EINTR let EINTR 13 +nim EINVAL pylib/Lib/errno_impl/errnoConsts.html#EINVAL let EINVAL 13 +nim EIO pylib/Lib/errno_impl/errnoConsts.html#EIO let EIO 13 +nim EISCONN pylib/Lib/errno_impl/errnoConsts.html#EISCONN let EISCONN 13 +nim EISDIR pylib/Lib/errno_impl/errnoConsts.html#EISDIR let EISDIR 13 +nim EISNAM pylib/Lib/errno_impl/errnoConsts.html#EISNAM let EISNAM 13 +nim EKEYEXPIRED pylib/Lib/errno_impl/errnoConsts.html#EKEYEXPIRED let EKEYEXPIRED 13 +nim EKEYREJECTED pylib/Lib/errno_impl/errnoConsts.html#EKEYREJECTED let EKEYREJECTED 13 +nim EKEYREVOKED pylib/Lib/errno_impl/errnoConsts.html#EKEYREVOKED let EKEYREVOKED 13 +nim EL2HLT pylib/Lib/errno_impl/errnoConsts.html#EL2HLT let EL2HLT 13 +nim EL2NSYNC pylib/Lib/errno_impl/errnoConsts.html#EL2NSYNC let EL2NSYNC 13 +nim EL3HLT pylib/Lib/errno_impl/errnoConsts.html#EL3HLT let EL3HLT 13 +nim EL3RST pylib/Lib/errno_impl/errnoConsts.html#EL3RST let EL3RST 13 +nim ELIBACC pylib/Lib/errno_impl/errnoConsts.html#ELIBACC let ELIBACC 13 +nim ELIBBAD pylib/Lib/errno_impl/errnoConsts.html#ELIBBAD let ELIBBAD 13 +nim ELIBEXEC pylib/Lib/errno_impl/errnoConsts.html#ELIBEXEC let ELIBEXEC 13 +nim ELIBMAX pylib/Lib/errno_impl/errnoConsts.html#ELIBMAX let ELIBMAX 13 +nim ELIBSCN pylib/Lib/errno_impl/errnoConsts.html#ELIBSCN let ELIBSCN 13 +nim ELNRNG pylib/Lib/errno_impl/errnoConsts.html#ELNRNG let ELNRNG 13 +nim ELOOP pylib/Lib/errno_impl/errnoConsts.html#ELOOP let ELOOP 13 +nim EMEDIUMTYPE pylib/Lib/errno_impl/errnoConsts.html#EMEDIUMTYPE let EMEDIUMTYPE 13 +nim EMFILE pylib/Lib/errno_impl/errnoConsts.html#EMFILE let EMFILE 13 +nim EMLINK pylib/Lib/errno_impl/errnoConsts.html#EMLINK let EMLINK 13 +nim EMSGSIZE pylib/Lib/errno_impl/errnoConsts.html#EMSGSIZE let EMSGSIZE 13 +nim EMULTIHOP pylib/Lib/errno_impl/errnoConsts.html#EMULTIHOP let EMULTIHOP 13 +nim ENAMETOOLONG pylib/Lib/errno_impl/errnoConsts.html#ENAMETOOLONG let ENAMETOOLONG 13 +nim ENAVAIL pylib/Lib/errno_impl/errnoConsts.html#ENAVAIL let ENAVAIL 13 +nim ENETDOWN pylib/Lib/errno_impl/errnoConsts.html#ENETDOWN let ENETDOWN 13 +nim ENETRESET pylib/Lib/errno_impl/errnoConsts.html#ENETRESET let ENETRESET 13 +nim ENETUNREACH pylib/Lib/errno_impl/errnoConsts.html#ENETUNREACH let ENETUNREACH 13 +nim ENFILE pylib/Lib/errno_impl/errnoConsts.html#ENFILE let ENFILE 13 +nim ENOANO pylib/Lib/errno_impl/errnoConsts.html#ENOANO let ENOANO 13 +nim ENOBUFS pylib/Lib/errno_impl/errnoConsts.html#ENOBUFS let ENOBUFS 13 +nim ENOCSI pylib/Lib/errno_impl/errnoConsts.html#ENOCSI let ENOCSI 13 +nim ENODATA pylib/Lib/errno_impl/errnoConsts.html#ENODATA let ENODATA 13 +nim ENODEV pylib/Lib/errno_impl/errnoConsts.html#ENODEV let ENODEV 13 +nim ENOENT pylib/Lib/errno_impl/errnoConsts.html#ENOENT let ENOENT 13 +nim ENOEXEC pylib/Lib/errno_impl/errnoConsts.html#ENOEXEC let ENOEXEC 13 +nim ENOKEY pylib/Lib/errno_impl/errnoConsts.html#ENOKEY let ENOKEY 13 +nim ENOLCK pylib/Lib/errno_impl/errnoConsts.html#ENOLCK let ENOLCK 13 +nim ENOLINK pylib/Lib/errno_impl/errnoConsts.html#ENOLINK let ENOLINK 13 +nim ENOMEDIUM pylib/Lib/errno_impl/errnoConsts.html#ENOMEDIUM let ENOMEDIUM 13 +nim ENOMEM pylib/Lib/errno_impl/errnoConsts.html#ENOMEM let ENOMEM 13 +nim ENOMSG pylib/Lib/errno_impl/errnoConsts.html#ENOMSG let ENOMSG 13 +nim ENONET pylib/Lib/errno_impl/errnoConsts.html#ENONET let ENONET 13 +nim ENOPKG pylib/Lib/errno_impl/errnoConsts.html#ENOPKG let ENOPKG 13 +nim ENOPROTOOPT pylib/Lib/errno_impl/errnoConsts.html#ENOPROTOOPT let ENOPROTOOPT 13 +nim ENOSPC pylib/Lib/errno_impl/errnoConsts.html#ENOSPC let ENOSPC 13 +nim ENOSR pylib/Lib/errno_impl/errnoConsts.html#ENOSR let ENOSR 13 +nim ENOSTR pylib/Lib/errno_impl/errnoConsts.html#ENOSTR let ENOSTR 13 +nim ENOSYS pylib/Lib/errno_impl/errnoConsts.html#ENOSYS let ENOSYS 13 +nim ENOTBLK pylib/Lib/errno_impl/errnoConsts.html#ENOTBLK let ENOTBLK 13 +nim ENOTCONN pylib/Lib/errno_impl/errnoConsts.html#ENOTCONN let ENOTCONN 13 +nim ENOTDIR pylib/Lib/errno_impl/errnoConsts.html#ENOTDIR let ENOTDIR 13 +nim ENOTEMPTY pylib/Lib/errno_impl/errnoConsts.html#ENOTEMPTY let ENOTEMPTY 13 +nim ENOTNAM pylib/Lib/errno_impl/errnoConsts.html#ENOTNAM let ENOTNAM 13 +nim ENOTRECOVERABLE pylib/Lib/errno_impl/errnoConsts.html#ENOTRECOVERABLE let ENOTRECOVERABLE 13 +nim ENOTSOCK pylib/Lib/errno_impl/errnoConsts.html#ENOTSOCK let ENOTSOCK 13 +nim ENOTSUP pylib/Lib/errno_impl/errnoConsts.html#ENOTSUP let ENOTSUP 13 +nim ENOTTY pylib/Lib/errno_impl/errnoConsts.html#ENOTTY let ENOTTY 13 +nim ENOTUNIQ pylib/Lib/errno_impl/errnoConsts.html#ENOTUNIQ let ENOTUNIQ 13 +nim ENXIO pylib/Lib/errno_impl/errnoConsts.html#ENXIO let ENXIO 13 +nim EOPNOTSUPP pylib/Lib/errno_impl/errnoConsts.html#EOPNOTSUPP let EOPNOTSUPP 13 +nim EOVERFLOW pylib/Lib/errno_impl/errnoConsts.html#EOVERFLOW let EOVERFLOW 13 +nim EOWNERDEAD pylib/Lib/errno_impl/errnoConsts.html#EOWNERDEAD let EOWNERDEAD 13 +nim EPERM pylib/Lib/errno_impl/errnoConsts.html#EPERM let EPERM 13 +nim EPFNOSUPPORT pylib/Lib/errno_impl/errnoConsts.html#EPFNOSUPPORT let EPFNOSUPPORT 13 +nim EPIPE pylib/Lib/errno_impl/errnoConsts.html#EPIPE let EPIPE 13 +nim EPROTO pylib/Lib/errno_impl/errnoConsts.html#EPROTO let EPROTO 13 +nim EPROTONOSUPPORT pylib/Lib/errno_impl/errnoConsts.html#EPROTONOSUPPORT let EPROTONOSUPPORT 13 +nim EPROTOTYPE pylib/Lib/errno_impl/errnoConsts.html#EPROTOTYPE let EPROTOTYPE 13 +nim ERANGE pylib/Lib/errno_impl/errnoConsts.html#ERANGE let ERANGE 13 +nim EREMCHG pylib/Lib/errno_impl/errnoConsts.html#EREMCHG let EREMCHG 13 +nim EREMOTE pylib/Lib/errno_impl/errnoConsts.html#EREMOTE let EREMOTE 13 +nim EREMOTEIO pylib/Lib/errno_impl/errnoConsts.html#EREMOTEIO let EREMOTEIO 13 +nim ERESTART pylib/Lib/errno_impl/errnoConsts.html#ERESTART let ERESTART 13 +nim ERFKILL pylib/Lib/errno_impl/errnoConsts.html#ERFKILL let ERFKILL 13 +nim EROFS pylib/Lib/errno_impl/errnoConsts.html#EROFS let EROFS 13 +nim ESHUTDOWN pylib/Lib/errno_impl/errnoConsts.html#ESHUTDOWN let ESHUTDOWN 13 +nim ESOCKTNOSUPPORT pylib/Lib/errno_impl/errnoConsts.html#ESOCKTNOSUPPORT let ESOCKTNOSUPPORT 13 +nim ESPIPE pylib/Lib/errno_impl/errnoConsts.html#ESPIPE let ESPIPE 13 +nim ESRCH pylib/Lib/errno_impl/errnoConsts.html#ESRCH let ESRCH 13 +nim ESRMNT pylib/Lib/errno_impl/errnoConsts.html#ESRMNT let ESRMNT 13 +nim ESTALE pylib/Lib/errno_impl/errnoConsts.html#ESTALE let ESTALE 13 +nim ESTRPIPE pylib/Lib/errno_impl/errnoConsts.html#ESTRPIPE let ESTRPIPE 13 +nim ETIME pylib/Lib/errno_impl/errnoConsts.html#ETIME let ETIME 13 +nim ETIMEDOUT pylib/Lib/errno_impl/errnoConsts.html#ETIMEDOUT let ETIMEDOUT 13 +nim ETOOMANYREFS pylib/Lib/errno_impl/errnoConsts.html#ETOOMANYREFS let ETOOMANYREFS 13 +nim ETXTBSY pylib/Lib/errno_impl/errnoConsts.html#ETXTBSY let ETXTBSY 13 +nim EUCLEAN pylib/Lib/errno_impl/errnoConsts.html#EUCLEAN let EUCLEAN 13 +nim EUNATCH pylib/Lib/errno_impl/errnoConsts.html#EUNATCH let EUNATCH 13 +nim EUSERS pylib/Lib/errno_impl/errnoConsts.html#EUSERS let EUSERS 13 +nim EWOULDBLOCK pylib/Lib/errno_impl/errnoConsts.html#EWOULDBLOCK let EWOULDBLOCK 13 +nim EXDEV pylib/Lib/errno_impl/errnoConsts.html#EXDEV let EXDEV 13 +nim EXFULL pylib/Lib/errno_impl/errnoConsts.html#EXFULL let EXFULL 13 diff --git a/pylib/Lib/errno_impl/errnoUtils.html b/pylib/Lib/errno_impl/errnoUtils.html new file mode 100644 index 000000000..1747ccf75 --- /dev/null +++ b/pylib/Lib/errno_impl/errnoUtils.html @@ -0,0 +1,260 @@ + + + + + + + +src/pylib/Lib/errno_impl/errnoUtils + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/errno_impl/errnoUtils

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

EXT. stable

+ +
+

Procs

+
+
+
+
proc getErrno(): cint {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template isErr(E: untyped): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template isErr0(): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template prepareROErrno() {.dirty.}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template prepareRWErrno() {.dirty.}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template setErrno(v: untyped)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template setErrno0()
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template setErrnoRaw(v: cint)
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ + +
+
+ + +
+
+ + + diff --git a/pylib/Lib/errno_impl/errnoUtils.idx b/pylib/Lib/errno_impl/errnoUtils.idx new file mode 100644 index 000000000..a46d6fe26 --- /dev/null +++ b/pylib/Lib/errno_impl/errnoUtils.idx @@ -0,0 +1,9 @@ +nimTitle errnoUtils pylib/Lib/errno_impl/errnoUtils.html module src/pylib/Lib/errno_impl/errnoUtils 0 +nim prepareRWErrno pylib/Lib/errno_impl/errnoUtils.html#prepareRWErrno.t template prepareRWErrno() 6 +nim prepareROErrno pylib/Lib/errno_impl/errnoUtils.html#prepareROErrno.t template prepareROErrno() 8 +nim setErrnoRaw pylib/Lib/errno_impl/errnoUtils.html#setErrnoRaw.t,cint template setErrnoRaw(v: cint) 12 +nim setErrno pylib/Lib/errno_impl/errnoUtils.html#setErrno.t,untyped template setErrno(v: untyped) 19 +nim setErrno0 pylib/Lib/errno_impl/errnoUtils.html#setErrno0.t template setErrno0() 26 +nim getErrno pylib/Lib/errno_impl/errnoUtils.html#getErrno proc getErrno(): cint 33 +nim isErr pylib/Lib/errno_impl/errnoUtils.html#isErr.t,untyped template isErr(E: untyped): bool 41 +nim isErr0 pylib/Lib/errno_impl/errnoUtils.html#isErr0.t template isErr0(): bool 51 diff --git a/pylib/Lib/errno_impl/private/clike.html b/pylib/Lib/errno_impl/private/clike.html new file mode 100644 index 000000000..491398255 --- /dev/null +++ b/pylib/Lib/errno_impl/private/clike.html @@ -0,0 +1,96 @@ + + + + + + + +src/pylib/Lib/errno_impl/private/clike + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/errno_impl/private/clike

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Exports

+
+ CLike +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/Lib/errno_impl/private/clike.idx b/pylib/Lib/errno_impl/private/clike.idx new file mode 100644 index 000000000..2031b9d7c --- /dev/null +++ b/pylib/Lib/errno_impl/private/clike.idx @@ -0,0 +1 @@ +nimTitle clike pylib/Lib/errno_impl/private/clike.html module src/pylib/Lib/errno_impl/private/clike 0 diff --git a/pylib/Lib/errno_impl/private/errnos.html b/pylib/Lib/errno_impl/private/errnos.html new file mode 100644 index 000000000..509b3c81c --- /dev/null +++ b/pylib/Lib/errno_impl/private/errnos.html @@ -0,0 +1,340 @@ + + + + + + + +src/pylib/Lib/errno_impl/private/errnos + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/errno_impl/private/errnos

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Types

+
+
+
Errno {.pure.} = enum
+  E_SUCCESS = "success",    ## inner. unstable.
+  E2BIG = "Argument list too long", EACCES = "Permission denied",
+  EADDRINUSE = "Address already in use",
+  EADDRNOTAVAIL = "Cannot assign requested address", EADV = "Advertise error",
+  EAFNOSUPPORT = "Address family not supported by protocol",
+  EAGAIN = "Resource temporarily unavailable",
+  EALREADY = "Operation already in progress", EBADE = "Invalid exchange",
+  EBADF = "Bad file descriptor", EBADFD = "File descriptor in bad state",
+  EBADMSG = "Bad message", EBADR = "Invalid request descriptor",
+  EBADRQC = "Invalid request code", EBADSLT = "Invalid slot",
+  EBFONT = "Bad font file format", EBUSY = "Device or resource busy",
+  ECANCELED = "Operation canceled", ECHILD = "No child processes",
+  ECHRNG = "Channel number out of range", ECOMM = "Communication error on send",
+  ECONNABORTED = "Software caused connection abort",
+  ECONNREFUSED = "Connection refused", ECONNRESET = "Connection reset by peer",
+  EDEADLK = "Resource deadlock avoided",
+  EDEADLOCK = "Resource deadlock avoided",
+  EDESTADDRREQ = "Destination address required",
+  EDOM = "Numerical argument out of domain", EDOTDOT = "RFS specific error",
+  EDQUOT = "Disk quota exceeded", EEXIST = "File exists",
+  EFAULT = "Bad address", EFBIG = "File too large", EHOSTDOWN = "Host is down",
+  EHOSTUNREACH = "No route to host", EIDRM = "Identifier removed",
+  EILSEQ = "Invalid or incomplete multibyte or wide character",
+  EINPROGRESS = "Operation now in progress", EINTR = "Interrupted system call",
+  EINVAL = "Invalid argument", EIO = "Input/output error",
+  EISCONN = "Transport endpoint is already connected",
+  EISDIR = "Is a directory", EISNAM = "Is a named type file",
+  EKEYEXPIRED = "Key has expired", EKEYREJECTED = "Key was rejected by service",
+  EKEYREVOKED = "Key has been revoked", EL2HLT = "Level 2 halted",
+  EL2NSYNC = "Level 2 not synchronized", EL3HLT = "Level 3 halted",
+  EL3RST = "Level 3 reset", ELIBACC = "Can not access a needed shared library",
+  ELIBBAD = "Accessing a corrupted shared library",
+  ELIBEXEC = "Cannot exec a shared library directly",
+  ELIBMAX = "Attempting to link in too many shared libraries",
+  ELIBSCN = ".lib section in a.out corrupted",
+  ELNRNG = "Link number out of range",
+  ELOOP = "Too many levels of symbolic links",
+  EMEDIUMTYPE = "Wrong medium type", EMFILE = "Too many open files",
+  EMLINK = "Too many links", EMSGSIZE = "Message too long",
+  EMULTIHOP = "Multihop attempted", ENAMETOOLONG = "File name too long",
+  ENAVAIL = "No XENIX semaphores available", ENETDOWN = "Network is down",
+  ENETRESET = "Network dropped connection on reset",
+  ENETUNREACH = "Network is unreachable",
+  ENFILE = "Too many open files in system", ENOANO = "No anode",
+  ENOBUFS = "No buffer space available", ENOCSI = "No CSI structure available",
+  ENODATA = "No data available", ENODEV = "No such device",
+  ENOENT = "No such file or directory", ENOEXEC = "Exec format error",
+  ENOKEY = "Required key not available", ENOLCK = "No locks available",
+  ENOLINK = "Link has been severed", ENOMEDIUM = "No medium found",
+  ENOMEM = "Cannot allocate memory", ENOMSG = "No message of desired type",
+  ENONET = "Machine is not on the network", ENOPKG = "Package not installed",
+  ENOPROTOOPT = "Protocol not available", ENOSPC = "No space left on device",
+  ENOSR = "Out of streams resources", ENOSTR = "Device not a stream",
+  ENOSYS = "Function not implemented", ENOTBLK = "Block device required",
+  ENOTCONN = "Transport endpoint is not connected", ENOTDIR = "Not a directory",
+  ENOTEMPTY = "Directory not empty", ENOTNAM = "Not a XENIX named type file",
+  ENOTRECOVERABLE = "State not recoverable",
+  ENOTSOCK = "Socket operation on non-socket",
+  ENOTSUP = "Operation not supported",
+  ENOTTY = "Inappropriate ioctl for device",
+  ENOTUNIQ = "Name not unique on network", ENXIO = "No such device or address",
+  EOPNOTSUPP = "Operation not supported",
+  EOVERFLOW = "Value too large for defined data type",
+  EOWNERDEAD = "Owner died", EPERM = "Operation not permitted",
+  EPFNOSUPPORT = "Protocol family not supported", EPIPE = "Broken pipe",
+  EPROTO = "Protocol error", EPROTONOSUPPORT = "Protocol not supported",
+  EPROTOTYPE = "Protocol wrong type for socket",
+  ERANGE = "Numerical result out of range", EREMCHG = "Remote address changed",
+  EREMOTE = "Object is remote", EREMOTEIO = "Remote I/O error",
+  ERESTART = "Interrupted system call should be restarted",
+  ERFKILL = "Operation not possible due to RF-kill",
+  EROFS = "Read-only file system",
+  ESHUTDOWN = "Cannot send after transport endpoint shutdown",
+  ESOCKTNOSUPPORT = "Socket type not supported", ESPIPE = "Illegal seek",
+  ESRCH = "No such process", ESRMNT = "Srmount error",
+  ESTALE = "Stale file handle", ESTRPIPE = "Streams pipe error",
+  ETIME = "Timer expired", ETIMEDOUT = "Connection timed out",
+  ETOOMANYREFS = "Too many references: cannot splice",
+  ETXTBSY = "Text file busy", EUCLEAN = "Structure needs cleaning",
+  EUNATCH = "Protocol driver not attached", EUSERS = "Too many users",
+  EWOULDBLOCK = "Resource temporarily unavailable",
+  EXDEV = "Invalid cross-device link", EXFULL = "Exchange full"
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Consts

+
+
+
ErrnoCount = 133
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
func `$`(e: Errno): string {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func strerror(e: Errno): string {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/Lib/errno_impl/private/errnos.idx b/pylib/Lib/errno_impl/private/errnos.idx new file mode 100644 index 000000000..f4ff5aeba --- /dev/null +++ b/pylib/Lib/errno_impl/private/errnos.idx @@ -0,0 +1,5 @@ +nimTitle errnos pylib/Lib/errno_impl/private/errnos.html module src/pylib/Lib/errno_impl/private/errnos 0 +nim Errno pylib/Lib/errno_impl/private/errnos.html#Errno enum Errno 6 +nim ErrnoCount pylib/Lib/errno_impl/private/errnos.html#ErrnoCount const ErrnoCount 143 +nim strerror pylib/Lib/errno_impl/private/errnos.html#strerror,Errno proc strerror(e: Errno): string 145 +nim `$` pylib/Lib/errno_impl/private/errnos.html#$,Errno proc `$`(e: Errno): string 147 diff --git a/pylib/Lib/errno_impl/private/errorcodeInit.html b/pylib/Lib/errno_impl/private/errorcodeInit.html new file mode 100644 index 000000000..120aee576 --- /dev/null +++ b/pylib/Lib/errno_impl/private/errorcodeInit.html @@ -0,0 +1,158 @@ + + + + + + + +src/pylib/Lib/errno_impl/private/errorcodeInit + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/errno_impl/private/errorcodeInit

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Macros

+
+
+
+
macro initErrorcodeMap(K, V; res: untyped; initFunc: typed)
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template declErrorcodeWith[K, V](initFunc: typed)
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ + +
+
+ + +
+
+ + + diff --git a/pylib/Lib/errno_impl/private/errorcodeInit.idx b/pylib/Lib/errno_impl/private/errorcodeInit.idx new file mode 100644 index 000000000..496d4b0bb --- /dev/null +++ b/pylib/Lib/errno_impl/private/errorcodeInit.idx @@ -0,0 +1,3 @@ +nimTitle errorcodeInit pylib/Lib/errno_impl/private/errorcodeInit.html module src/pylib/Lib/errno_impl/private/errorcodeInit 0 +nim initErrorcodeMap pylib/Lib/errno_impl/private/errorcodeInit.html#initErrorcodeMap.m,,,untyped,typed macro initErrorcodeMap(K, V; res: untyped; initFunc: typed) 11 +nim declErrorcodeWith pylib/Lib/errno_impl/private/errorcodeInit.html#declErrorcodeWith.t,typed template declErrorcodeWith[K, V](initFunc: typed) 45 diff --git a/pylib/Lib/errno_impl/private/exportUtils.html b/pylib/Lib/errno_impl/private/exportUtils.html new file mode 100644 index 000000000..7f7a66da1 --- /dev/null +++ b/pylib/Lib/errno_impl/private/exportUtils.html @@ -0,0 +1,127 @@ + + + + + + + +src/pylib/Lib/errno_impl/private/exportUtils + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/errno_impl/private/exportUtils

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Macros

+
+
+
+
macro exportAllErrnosViaEnumOrImportc()
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ + +
+
+ + +
+
+ + + diff --git a/pylib/Lib/errno_impl/private/exportUtils.idx b/pylib/Lib/errno_impl/private/exportUtils.idx new file mode 100644 index 000000000..aeb5c9767 --- /dev/null +++ b/pylib/Lib/errno_impl/private/exportUtils.idx @@ -0,0 +1,2 @@ +nimTitle exportUtils pylib/Lib/errno_impl/private/exportUtils.html module src/pylib/Lib/errno_impl/private/exportUtils 0 +nim exportAllErrnosViaEnumOrImportc pylib/Lib/errno_impl/private/exportUtils.html#exportAllErrnosViaEnumOrImportc.m macro exportAllErrnosViaEnumOrImportc() 17 diff --git a/pylib/Lib/errno_impl/private/loopErrno.html b/pylib/Lib/errno_impl/private/loopErrno.html new file mode 100644 index 000000000..fe15f962e --- /dev/null +++ b/pylib/Lib/errno_impl/private/loopErrno.html @@ -0,0 +1,135 @@ + + + + + + + +src/pylib/Lib/errno_impl/private/loopErrno + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/errno_impl/private/loopErrno

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Imports

+
+ clike, errnos +
+
+
+

Templates

+
+
+
+
template forErrno(res: NimNode; err; body)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template whenDefErrno(res: NimNode; errnoName: string; body): untyped {.dirty.}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/Lib/errno_impl/private/loopErrno.idx b/pylib/Lib/errno_impl/private/loopErrno.idx new file mode 100644 index 000000000..6b3c26044 --- /dev/null +++ b/pylib/Lib/errno_impl/private/loopErrno.idx @@ -0,0 +1,3 @@ +nimTitle loopErrno pylib/Lib/errno_impl/private/loopErrno.html module src/pylib/Lib/errno_impl/private/loopErrno 0 +nim whenDefErrno pylib/Lib/errno_impl/private/loopErrno.html#whenDefErrno.t,NimNode,string, template whenDefErrno(res: NimNode; errnoName: string; body): untyped 14 +nim forErrno pylib/Lib/errno_impl/private/loopErrno.html#forErrno.t,NimNode,, template forErrno(res: NimNode; err; body) 26 diff --git a/pylib/Lib/errno_impl/private/singleton_errno.html b/pylib/Lib/errno_impl/private/singleton_errno.html new file mode 100644 index 000000000..ac6eff530 --- /dev/null +++ b/pylib/Lib/errno_impl/private/singleton_errno.html @@ -0,0 +1,123 @@ + + + + + + + +src/pylib/Lib/errno_impl/private/singleton_errno + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/errno_impl/private/singleton_errno

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Imports

+
+ clike +
+
+
+

Vars

+
+
+
errno {.importc: "errno", header: "<errno.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
staticErrno {.compileTime.}: cint
+
+ + used compile time + Source   +Edit   + +
+
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/Lib/errno_impl/private/singleton_errno.idx b/pylib/Lib/errno_impl/private/singleton_errno.idx new file mode 100644 index 000000000..0c978e980 --- /dev/null +++ b/pylib/Lib/errno_impl/private/singleton_errno.idx @@ -0,0 +1,3 @@ +nimTitle singleton_errno pylib/Lib/errno_impl/private/singleton_errno.html module src/pylib/Lib/errno_impl/private/singleton_errno 0 +nim errno pylib/Lib/errno_impl/private/singleton_errno.html#errno var errno 4 +nim staticErrno pylib/Lib/errno_impl/private/singleton_errno.html#staticErrno var staticErrno 8 diff --git a/pylib/Lib/io.html b/pylib/Lib/io.html new file mode 100644 index 000000000..481c8c07d --- /dev/null +++ b/pylib/Lib/io.html @@ -0,0 +1,970 @@ + + + + + + + +src/pylib/Lib/io + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/io

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

NOTE: not support js currently +

different from Python

+

open

Its param: closefd, opener is not implemented yet

+ +

seek

There is difference that Python's TextIOBase.seek will reset state of encoder at some conditions, while Nim doesn't have access to encoder's state Therefore, seek here doesn't change that

+ +

iter over file

Python's __next__ will yield newline as part of result but Nim's iterator lines does not

+

+ +
+

Types

+
+
+
BufferedIOBase = ref object of IOBase
+
+ + + Source   +Edit   + +
+
+
+
BufferedRandom = ref object of BufferedIOBase
+
+ + + Source   +Edit   + +
+
+
+
BufferedReader = ref object of BufferedIOBase
+
+ + + Source   +Edit   + +
+
+
+
BufferedWriter = ref object of BufferedIOBase
+
+ + + Source   +Edit   + +
+
+
+
FileIO = ref object of RawIOBase
+
+ + + Source   +Edit   + +
+
+
+
IOBase = ref object of RootObj
+  closed*: bool
+
+ + + Source   +Edit   + +
+
+
+
NoEncTextIOBase = ref object of IOBase
+
+ + no encoding conversion is performed on underlying file. used for those stream whose encoding is alreadly utf-8 + Source   +Edit   + +
+
+
+
NoEncTextIOWrapper = ref object of NoEncTextIOBase
+  name*: PyStr
+  mode*: PyStr
+
+ + + Source   +Edit   + +
+
+
+
RawIOBase = ref object of IOBase
+
+ + + Source   +Edit   + +
+
+
+
TextIOWrapper = ref object of NoEncTextIOWrapper
+  ## do not use string, so is always valid
+
+ + + Source   +Edit   + +
+
+
+
UnsupportedOperation = object of PyOSError
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Consts

+
+
+
DEFAULT_BUFFER_SIZE = 8192
+
+ + + Source   +Edit   + +
+
+
+
DefEncoding = ""
+
+ + + Source   +Edit   + +
+
+
+
DefNewLine = "None"
+
+ + here it's used to mean open(...newline=None) in Python (i.e. Universial NewLine) + Source   +Edit   + +
+
+
+
LocaleEncoding = "locale"
+
+ + + Source   +Edit   + +
+
+
+
SEEK_CUR = 1
+
+ + + Source   +Edit   + +
+
+
+
SEEK_END = 2
+
+ + + Source   +Edit   + +
+
+
+
SEEK_SET = 0
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
func encoding(s: TextIOWrapper): PyStr {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func enter[IO: IOBase](self: IO): IO
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func errors(s: TextIOWrapper): PyStr {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc fileno(f: IOBase): int {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc flush(f: IOBase) {....raises: [PyOSError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc initBufAsPy(nfile: var File; buf: int) {....raises: [], tags: [], forbids: [].}
+
+ + init buffering as Python's + Source   +Edit   + +
+
+ +
+
+
+
func isatty(f: IOBase): bool {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc newNoEncTextIO(file: File; name: string; newline = DefNewLine): NoEncTextIOWrapper {.
+    ...raises: [ValueError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc read(self: NoEncTextIOWrapper): PyStr {....raises: [IOError],
+    tags: [ReadIOEffect], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc read(self: NoEncTextIOWrapper; size: int): PyStr {....raises: [IOError],
+    tags: [ReadIOEffect], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc read(self: RawIOBase): PyBytes {....raises: [IOError], tags: [ReadIOEffect],
+                                      forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc read(self: RawIOBase; size: int): PyBytes {....raises: [IOError],
+    tags: [ReadIOEffect], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc read(self: TextIOWrapper): PyStr {....raises: [IOError, Exception],
+                                        tags: [ReadIOEffect, RootEffect],
+                                        forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc read(self: TextIOWrapper; size: int): PyStr {....raises: [IOError, Exception],
+    tags: [ReadIOEffect, RootEffect], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc readline(self: NoEncTextIOWrapper): PyStr {....raises: [IOError],
+    tags: [ReadIOEffect], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc readline(self: NoEncTextIOWrapper; size: int): PyStr {....raises: [IOError],
+    tags: [ReadIOEffect], forbids: [].}
+
+ + ..warning:: size is currently in bytes, not in characters + Source   +Edit   + +
+
+
+
proc readline(self: RawIOBase): PyBytes {....raises: [IOError],
+    tags: [ReadIOEffect], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc readline(self: RawIOBase; size: Natural): PyBytes {....raises: [IOError],
+    tags: [ReadIOEffect], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc readline(self: TextIOWrapper): PyStr {....raises: [IOError, Exception],
+    tags: [ReadIOEffect, RootEffect], forbids: [].}
+
+ + Python's readline +

Example:

+
import std/strutils
+const fn = "tempfiletest"
+proc check(ls: varargs[string], newline: string) =
+  var f = open(fn, newline=newline)
+  for l in ls:
+    let s = f.readline()
+    assert s == l, 
+      "expected $#, but got $#, with newline=$#" % [l.repr, s.repr, newline.repr]
+    
+  f.close()
+
+writeFile fn, "abc\r\n123\n-\r_"
+
+check "abc\n", "123\n", "-\n", "_", newline=DefNewLine
+check "abc\r\n", "123\n", "-\r", "_", newline=""
+check "abc\r", "\n123\n-\r", "_", newline="\r"
+check "abc\r\n", "123\n", "-\r_", newline="\n"
+check "abc\r\n", "123\n-\r_", newline="\r\n"
+ Source   +Edit   + +
+
+
+
proc readline(self: TextIOWrapper; size: Natural): PyStr {.
+    ...raises: [IOError, Exception], tags: [ReadIOEffect, RootEffect], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func tell(f: IOBase): int64 {....raises: [IOError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc truncate(self: IOBase): int {.discardable, ...raises: [IOError, PyOSError],
+                                   tags: [], forbids: [].}
+
+ + +

Example:

+
const fn = "tempfiletest"
+var f = open(fn, "w+")
+discard f.write("123")
+f.seek(0)
+f.truncate()
+assert f.read() == ""
+f.close()
+ Source   +Edit   + +
+
+
+
proc truncate(self: IOBase; size: int64): int64 {.discardable,
+    ...raises: [PyOSError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc write(self: NoEncTextIOWrapper; s: PyStr): int {.discardable,
+    ...raises: [Exception], tags: [RootEffect], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc write(self: RawIOBase; s: PyBytes): int {.discardable, ...raises: [IOError],
+    tags: [WriteIOEffect], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc write(self: TextIOWrapper; s: PyStr): int {.discardable,
+    ...raises: [Exception], tags: [RootEffect], forbids: [].}
+
+ +

Writes the s to the stream and return the number of characters written

+

The following is from Python's doc of open: if newline is None, any 'n' characters written are translated to the system default line separator, os.linesep. If newline is "" or 'n', no translation takes place. If newline is any of the other legal values, any 'n' characters written are translated to the given string.

+ +

Example:

+
const fn = "tempfiletest"
+proc checkW(s, dest: string, newline=DefNewLine, encoding=DefEncoding;
+    writeLen=dest.len  # dest.len returns bytes size
+  ) =
+  var f = open(fn, 'w', newline=newline, encoding=encoding)
+  assert writeLen == f.write s
+  f.close()
+  let res = readFile fn
+  assert dest == res, "expected "&dest.repr&" but got "&res.repr
+checkW "1\n2", when defined(windows): "1\r\n2" else: "1\n2"
+checkW "1\n2", "1\p2"  # same as above
+checkW "1\n2", "1\r2", newline="\r"
+checkW "我", "我", encoding="utf-8", writeLen=1
+ Source   +Edit   + +
+
+ +
+ +
+
+
+

Methods

+
+
+
+
method close(self: IOBase) {.base, ...raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
method close(self: RawIOBase) {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
method close(self: TextIOWrapper) {....raises: [Exception], tags: [RootEffect],
+                                    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
method seek(f: IOBase; cookie: int64; whence = SEEK_SET): int64 {.base,
+    discardable, ...raises: [IOError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
method seek(self: TextIOWrapper; cookie: int64; whence = SEEK_SET): int64 {.
+    discardable,
+    ...raises: [ValueError, UnsupportedOperation, IOError, PyOSError, Exception],
+    tags: [RootEffect], forbids: [].}
+
+ + +

Example:

+
var f = open("tempfiletest", 'w')
+doAssertRaises UnsupportedOperation:
+  f.seek(1, SEEK_CUR)
+f.close()
+ Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template exit(self: IOBase; args: varargs[untyped])
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template open(file: int; mode: static[string | char] = "r"; buffering: int = -1;
+              encoding: string = DefEncoding; errors: string = DefErrors;
+              newline: string | char = DefNewLine): untyped
+
+ + + Source   +Edit   + +
+
+
+
template open[S](file: PathLike[S]; mode: static[string | char] = "r";
+                 buffering: int = -1; encoding: string = DefEncoding;
+                 errors: string = DefErrors; newline: string | char = DefNewLine): untyped
+
+ + WARN:
  • line buffering is not support for Win32
  • +
  • errors is not just ignored, always 'strict'
  • +
+ +

Example:

+
const fn = "tempfiletest"
+const nonfn = r"   \:/ $&* "
+doAssertRaises LookupError:
+  # raise LookupError instead of FileNotFoundError (like Python)
+  discard open(nonfn, encoding="this is a invalid enc")
+doAssertRaises FileNotFoundError:
+  discard io.open(nonfn)  # an invalid filename, never existing
+block Write:
+  var f = open(fn, "w",  encoding="utf-8")
+  let ret = f.write("123\r\n")
+  when defined(windows):
+    assert ret == 6  # Universal Newline, written "123\r\r\n"
+  else:
+    assert ret == 5  # written "123\r\n"
+  assert not f.closed
+  f.close()
+  assert f.closed
+  assert readFile(fn) == (when defined(windows):"123\r\r\n" else:"123\r\n")
+block Read:
+  var f = open(fn, 'r')
+  let uniLineRes = f.read() # Universal Newline, "123\r\n\n" -> "123\n\n"
+  assert uniLineRes == (when defined(windows):"123\n\n" else:"123\n")
+  f.close()
+ Source   +Edit   + +
+
+ +
+ +
+
+ + +
+
+ + +
+
+ + + diff --git a/pylib/Lib/io.idx b/pylib/Lib/io.idx new file mode 100644 index 000000000..f1ca89c6d --- /dev/null +++ b/pylib/Lib/io.idx @@ -0,0 +1,64 @@ +nimTitle io pylib/Lib/io.html module src/pylib/Lib/io 0 +nim SEEK_SET pylib/Lib/io.html#SEEK_SET const SEEK_SET 52 +nim SEEK_CUR pylib/Lib/io.html#SEEK_CUR const SEEK_CUR 53 +nim SEEK_END pylib/Lib/io.html#SEEK_END const SEEK_END 54 +nim DefNewLine pylib/Lib/io.html#DefNewLine const DefNewLine 56 +nim IOBase pylib/Lib/io.html#IOBase type IOBase 67 +nim UnsupportedOperation pylib/Lib/io.html#UnsupportedOperation object UnsupportedOperation 72 +nim flush pylib/Lib/io.html#flush,IOBase proc flush(f: IOBase) 78 +nim tell pylib/Lib/io.html#tell,IOBase proc tell(f: IOBase): int64 83 +nim isatty pylib/Lib/io.html#isatty,IOBase proc isatty(f: IOBase): bool 85 +nim fileno pylib/Lib/io.html#fileno,IOBase proc fileno(f: IOBase): int 87 +nim DEFAULT_BUFFER_SIZE pylib/Lib/io.html#DEFAULT_BUFFER_SIZE const DEFAULT_BUFFER_SIZE 89 +nim NoEncTextIOBase pylib/Lib/io.html#NoEncTextIOBase type NoEncTextIOBase 92 +nim NoEncTextIOWrapper pylib/Lib/io.html#NoEncTextIOWrapper type NoEncTextIOWrapper 96 +nim TextIOWrapper pylib/Lib/io.html#TextIOWrapper type TextIOWrapper 100 +nim encoding pylib/Lib/io.html#encoding,TextIOWrapper proc encoding(s: TextIOWrapper): PyStr 104 +nim errors pylib/Lib/io.html#errors,TextIOWrapper proc errors(s: TextIOWrapper): PyStr 105 +nim RawIOBase pylib/Lib/io.html#RawIOBase type RawIOBase 108 +nim FileIO pylib/Lib/io.html#FileIO type FileIO 109 +nim BufferedIOBase pylib/Lib/io.html#BufferedIOBase type BufferedIOBase 111 +nim BufferedRandom pylib/Lib/io.html#BufferedRandom type BufferedRandom 112 +nim BufferedReader pylib/Lib/io.html#BufferedReader type BufferedReader 113 +nim BufferedWriter pylib/Lib/io.html#BufferedWriter type BufferedWriter 114 +nim seek pylib/Lib/io.html#seek.e,IOBase,int64 method seek(f: IOBase; cookie: int64; whence = SEEK_SET): int64 132 +nim seek pylib/Lib/io.html#seek.e,TextIOWrapper,int64 method seek(self: TextIOWrapper; cookie: int64; whence = SEEK_SET): int64 135 +nim readline pylib/Lib/io.html#readline,RawIOBase proc readline(self: RawIOBase): PyBytes 250 +nim readline pylib/Lib/io.html#readline,RawIOBase,Natural proc readline(self: RawIOBase; size: Natural): PyBytes 251 +nim readline pylib/Lib/io.html#readline,NoEncTextIOWrapper proc readline(self: NoEncTextIOWrapper): PyStr 278 +nim readline pylib/Lib/io.html#readline,NoEncTextIOWrapper,int proc readline(self: NoEncTextIOWrapper; size: int): PyStr 280 +nim readline pylib/Lib/io.html#readline,TextIOWrapper proc readline(self: TextIOWrapper): PyStr 285 +nim readline pylib/Lib/io.html#readline,TextIOWrapper,Natural proc readline(self: TextIOWrapper; size: Natural): PyStr 308 +nim read pylib/Lib/io.html#read,RawIOBase proc read(self: RawIOBase): PyBytes 312 +nim read pylib/Lib/io.html#read,RawIOBase,int proc read(self: RawIOBase; size: int): PyBytes 315 +nim read pylib/Lib/io.html#read,NoEncTextIOWrapper proc read(self: NoEncTextIOWrapper): PyStr 324 +nim read pylib/Lib/io.html#read,TextIOWrapper proc read(self: TextIOWrapper): PyStr 325 +nim read pylib/Lib/io.html#read,NoEncTextIOWrapper,int proc read(self: NoEncTextIOWrapper; size: int): PyStr 338 +nim read pylib/Lib/io.html#read,TextIOWrapper,int proc read(self: TextIOWrapper; size: int): PyStr 341 +nim write pylib/Lib/io.html#write,RawIOBase,PyBytes proc write(self: RawIOBase; s: PyBytes): int 349 +nim write pylib/Lib/io.html#write,NoEncTextIOWrapper,PyStr proc write(self: NoEncTextIOWrapper; s: PyStr): int 362 +nim write pylib/Lib/io.html#write,TextIOWrapper,PyStr proc write(self: TextIOWrapper; s: PyStr): int 368 +nim truncate pylib/Lib/io.html#truncate,IOBase proc truncate(self: IOBase): int 398 +nim truncate pylib/Lib/io.html#truncate,IOBase,int64 proc truncate(self: IOBase; size: int64): int64 410 +nim close pylib/Lib/io.html#close.e,IOBase method close(self: IOBase) 423 +nim close pylib/Lib/io.html#close.e,RawIOBase method close(self: RawIOBase) 424 +nim close pylib/Lib/io.html#close.e,TextIOWrapper method close(self: TextIOWrapper) 425 +nim enter pylib/Lib/io.html#enter,IO proc enter[IO: IOBase](self: IO): IO 438 +nim exit pylib/Lib/io.html#exit.t,IOBase,varargs[untyped] template exit(self: IOBase; args: varargs[untyped]) 441 +nim DefEncoding pylib/Lib/io.html#DefEncoding const DefEncoding 446 +nim LocaleEncoding pylib/Lib/io.html#LocaleEncoding const LocaleEncoding 447 +nim newNoEncTextIO pylib/Lib/io.html#newNoEncTextIO,File,string proc newNoEncTextIO(file: File; name: string; newline = DefNewLine): NoEncTextIOWrapper 487 +nim initBufAsPy pylib/Lib/io.html#initBufAsPy,File,int proc initBufAsPy(nfile: var File; buf: int) 610 +nim open pylib/Lib/io.html#open.t,int,static[],int,string,string template open(file: int; mode: static[string | char] = "r"; buffering: int = -1;\n encoding: string = DefEncoding; errors: string = DefErrors;\n newline: string | char = DefNewLine): untyped 654 +nim open pylib/Lib/io.html#open.t,PathLike[S],static[],int,string,string template open[S](file: PathLike[S]; mode: static[string | char] = "r";\n buffering: int = -1; encoding: string = DefEncoding;\n errors: string = DefErrors; newline: string | char = DefNewLine): untyped 672 +nimgrp write pylib/Lib/io.html#write-procs-all proc 349 +nimgrp readline pylib/Lib/io.html#readline-procs-all proc 250 +nimgrp read pylib/Lib/io.html#read-procs-all proc 312 +nimgrp truncate pylib/Lib/io.html#truncate-procs-all proc 398 +nimgrp close pylib/Lib/io.html#close-methods-all method 423 +nimgrp seek pylib/Lib/io.html#seek-methods-all method 132 +nimgrp open pylib/Lib/io.html#open-templates-all template 654 +heading different from Python pylib/Lib/io.html#different-from-python different from Python 0 +heading open pylib/Lib/io.html#different-from-python-open open 0 +heading seek pylib/Lib/io.html#different-from-python-seek seek 0 +heading iter over file pylib/Lib/io.html#different-from-python-iter-over-file iter over file 0 diff --git a/pylib/Lib/math.html b/pylib/Lib/math.html new file mode 100644 index 000000000..6d01bd3ad --- /dev/null +++ b/pylib/Lib/math.html @@ -0,0 +1,938 @@ + + + + + + + +src/pylib/Lib/math + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/math

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

Lib/math

+

Wrapper around Lib/n_math, and raises exceptions when math error occurs as CPython behaves.

+

+ +
+

Procs

+
+
+
+
func acos[F: SomeFloat](x: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func acosh[F: SomeFloat](x: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func asin[F: SomeFloat](x: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func asinh[F: SomeFloat](x: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func atan[F: SomeFloat](x: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func atan2[F: SomeFloat](x, y: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func atanh[F: SomeFloat](x: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func cbrt[F: SomeFloat](x: F): F
+
+ +
Admonition: +since Python 3.11
+ +

Example:

+
template chk =
+  assert cbrt(-1.0) == -1.0
+chk()
+static: chk()
+ Source   +Edit   + +
+
+ +
+
+
+
func comb(n, k: int): int {....raises: [ValueError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func copysign[F: SomeFloat](x, y: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func cos[F: SomeFloat](x: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func cosh[F: SomeFloat](x: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func erf[F: SomeFloat](x: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func erfc[F: SomeFloat](x: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func exp[F: SomeFloat](x: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func expm1[F: SomeFloat](x: F): F
+
+ +
Admonition: +since Python 3.11
+ + Source   +Edit   + +
+
+ +
+
+
+
func fabs[F: SomeFloat](x: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func factorial(x: int): int {....raises: [ValueError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func fma[F: SomeFloat](x, y, z: F): F
+
+ +
Admonition: +since Python 3.13
+ + Source   +Edit   + +
+
+ +
+
+
+
func fmod[F: SomeFloat](x: F; y: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func gamma[F: SomeFloat](x: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func isqrt[I: SomeInteger](x: I): int
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func ldexp(x: SomeFloat; i: int): float
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func lgamma[F: SomeFloat](x: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func log[F: SomeFloat](x, base: F): F
+
+ + + Source   +Edit   + +
+
+
+
func log[F: SomeFloat](x: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func log1p[F: SomeFloat](x: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func log2[F: SomeFloat](x: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func log10[F: SomeFloat](x: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func nextafter[F: SomeFloat](x, y: F): F
+
+ +
Admonition: +since Python 3.9
+ + Source   +Edit   + +
+
+
+
func nextafter[F: SomeFloat](x, y: F; steps: int | uint64): F
+
+ +
Admonition: +since Python 3.12
+ + Source   +Edit   + +
+
+ +
+
+
+
func perm(n, k: int): int {....raises: [ValueError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func perm(n: int): int {....raises: [ValueError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func pow[F: SomeFloat](x, y: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func remainder[F: SomeFloat](x, y: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func sin[F: SomeFloat](x: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func sinh[F: SomeFloat](x: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func sqrt[F: SomeFloat](x: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func tan[F: SomeFloat](x: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func tanh[F: SomeFloat](x: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func ulp[F: SomeFloat](x: F): F
+
+ +
Admonition: +since Python 3.9
+ + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template dist[T](p, q: (Iterable[T] and not openArray[T])): float
+
+ +
Admonition: +since Python 3.8
+ + Source   +Edit   + +
+
+
+
template dist[T](p, q: ClosureIter[T]): float
+
+ +
Admonition: +since Python 3.8
+ + Source   +Edit   + +
+
+
+
template dist[T](p, q: list[T]): float
+
+ +
Admonition: +since Python 3.8
+ + Source   +Edit   + +
+
+
+
template dist[T](p, q: openArray[T]): float
+
+ +
Admonition: +since Python 3.8
+ + Source   +Edit   + +
+
+ +
+
+
+
template sumprod[T](p, q: (Iterable[T] and not openArray[T])): float
+
+ +
Admonition: +since Python 3.12
+ + Source   +Edit   + +
+
+
+
template sumprod[T](p, q: ClosureIter[T]): float
+
+ +
Admonition: +since Python 3.12
+ + Source   +Edit   + +
+
+
+
template sumprod[T](p, q: list[T]): float
+
+ +
Admonition: +since Python 3.12
+ + Source   +Edit   + +
+
+
+
template sumprod[T](p, q: openArray[T]): float
+
+ +
Admonition: +since Python 3.12
+ + Source   +Edit   + +
+
+ +
+ +
+
+ + +
+
+ + +
+
+ + + diff --git a/pylib/Lib/math.idx b/pylib/Lib/math.idx new file mode 100644 index 000000000..99758e4ed --- /dev/null +++ b/pylib/Lib/math.idx @@ -0,0 +1,55 @@ +nimTitle math pylib/Lib/math.html module src/pylib/Lib/math 0 +nim acos pylib/Lib/math.html#acos,F proc acos[F: SomeFloat](x: F): F 98 +nim acosh pylib/Lib/math.html#acosh,F proc acosh[F: SomeFloat](x: F): F 99 +nim asin pylib/Lib/math.html#asin,F proc asin[F: SomeFloat](x: F): F 100 +nim asinh pylib/Lib/math.html#asinh,F proc asinh[F: SomeFloat](x: F): F 101 +nim atan pylib/Lib/math.html#atan,F proc atan[F: SomeFloat](x: F): F 102 +nim atanh pylib/Lib/math.html#atanh,F proc atanh[F: SomeFloat](x: F): F 103 +nim cbrt pylib/Lib/math.html#cbrt,F proc cbrt[F: SomeFloat](x: F): F 105 +nim atan2 pylib/Lib/math.html#atan2,F,F proc atan2[F: SomeFloat](x, y: F): F 115 +nim copysign pylib/Lib/math.html#copysign,F,F proc copysign[F: SomeFloat](x, y: F): F 117 +nim cos pylib/Lib/math.html#cos,F proc cos[F: SomeFloat](x: F): F 119 +nim cosh pylib/Lib/math.html#cosh,F proc cosh[F: SomeFloat](x: F): F 120 +nim erf pylib/Lib/math.html#erf,F proc erf[F: SomeFloat](x: F): F 122 +nim erfc pylib/Lib/math.html#erfc,F proc erfc[F: SomeFloat](x: F): F 123 +nim exp pylib/Lib/math.html#exp,F proc exp[F: SomeFloat](x: F): F 125 +nim expm1 pylib/Lib/math.html#expm1,F proc expm1[F: SomeFloat](x: F): F 127 +nim fabs pylib/Lib/math.html#fabs,F proc fabs[F: SomeFloat](x: F): F 130 +nim gamma pylib/Lib/math.html#gamma,F proc gamma[F: SomeFloat](x: F): F 134 +nim lgamma pylib/Lib/math.html#lgamma,F proc lgamma[F: SomeFloat](x: F): F 135 +nim log1p pylib/Lib/math.html#log1p,F proc log1p[F: SomeFloat](x: F): F 137 +nim remainder pylib/Lib/math.html#remainder,F,F proc remainder[F: SomeFloat](x, y: F): F 138 +nim sin pylib/Lib/math.html#sin,F proc sin[F: SomeFloat](x: F): F 140 +nim sinh pylib/Lib/math.html#sinh,F proc sinh[F: SomeFloat](x: F): F 141 +nim sqrt pylib/Lib/math.html#sqrt,F proc sqrt[F: SomeFloat](x: F): F 142 +nim tan pylib/Lib/math.html#tan,F proc tan[F: SomeFloat](x: F): F 143 +nim tanh pylib/Lib/math.html#tanh,F proc tanh[F: SomeFloat](x: F): F 144 +nim isqrt pylib/Lib/math.html#isqrt,I proc isqrt[I: SomeInteger](x: I): int 148 +nim factorial pylib/Lib/math.html#factorial,int proc factorial(x: int): int 153 +nim ldexp pylib/Lib/math.html#ldexp,SomeFloat,int proc ldexp(x: SomeFloat; i: int): float 162 +nim log pylib/Lib/math.html#log,F proc log[F: SomeFloat](x: F): F 187 +nim log pylib/Lib/math.html#log,F,F proc log[F: SomeFloat](x, base: F): F 190 +nim log2 pylib/Lib/math.html#log2,F proc log2[F: SomeFloat](x: F): F 194 +nim log10 pylib/Lib/math.html#log10,F proc log10[F: SomeFloat](x: F): F 195 +nim fma pylib/Lib/math.html#fma,F,F,F proc fma[F: SomeFloat](x, y, z: F): F 197 +nim fmod pylib/Lib/math.html#fmod,F,F proc fmod[F: SomeFloat](x: F; y: F): F 203 +nim dist pylib/Lib/math.html#dist.t,list[T],list[T] template dist[T](p, q: list[T]): float 216 +nim dist pylib/Lib/math.html#dist.t,, template dist[T](p, q: (Iterable[T] and not openArray[T])): float 219 +nim dist pylib/Lib/math.html#dist.t,openArray[T],openArray[T] template dist[T](p, q: openArray[T]): float 222 +nim dist pylib/Lib/math.html#dist.t,ClosureIter[T],ClosureIter[T] template dist[T](p, q: ClosureIter[T]): float 225 +nim sumprod pylib/Lib/math.html#sumprod.t,list[T],list[T] template sumprod[T](p, q: list[T]): float 216 +nim sumprod pylib/Lib/math.html#sumprod.t,, template sumprod[T](p, q: (Iterable[T] and not openArray[T])): float 219 +nim sumprod pylib/Lib/math.html#sumprod.t,openArray[T],openArray[T] template sumprod[T](p, q: openArray[T]): float 222 +nim sumprod pylib/Lib/math.html#sumprod.t,ClosureIter[T],ClosureIter[T] template sumprod[T](p, q: ClosureIter[T]): float 225 +nim pow pylib/Lib/math.html#pow,F,F proc pow[F: SomeFloat](x, y: F): F 238 +nim perm pylib/Lib/math.html#perm,int proc perm(n: int): int 259 +nim perm pylib/Lib/math.html#perm,int,int proc perm(n, k: int): int 263 +nim comb pylib/Lib/math.html#comb,int,int proc comb(n, k: int): int 269 +nim nextafter pylib/Lib/math.html#nextafter,F,F proc nextafter[F: SomeFloat](x, y: F): F 275 +nim nextafter pylib/Lib/math.html#nextafter,F,F, proc nextafter[F: SomeFloat](x, y: F; steps: int | uint64): F 276 +nim ulp pylib/Lib/math.html#ulp,F proc ulp[F: SomeFloat](x: F): F 278 +nimgrp perm pylib/Lib/math.html#perm-procs-all proc 259 +nimgrp log pylib/Lib/math.html#log-procs-all proc 187 +nimgrp nextafter pylib/Lib/math.html#nextafter-procs-all proc 275 +nimgrp dist pylib/Lib/math.html#dist-templates-all template 231 +nimgrp sumprod pylib/Lib/math.html#sumprod-templates-all template 233 diff --git a/pylib/Lib/math_impl/cbrt.html b/pylib/Lib/math_impl/cbrt.html new file mode 100644 index 000000000..0ca2dddf7 --- /dev/null +++ b/pylib/Lib/math_impl/cbrt.html @@ -0,0 +1,118 @@ + + + + + + + +src/pylib/Lib/math_impl/cbrt + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/math_impl/cbrt

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
func cbrt[F: SomeFloat](x: F): F
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/Lib/math_impl/cbrt.idx b/pylib/Lib/math_impl/cbrt.idx new file mode 100644 index 000000000..c37b8980f --- /dev/null +++ b/pylib/Lib/math_impl/cbrt.idx @@ -0,0 +1,2 @@ +nimTitle cbrt pylib/Lib/math_impl/cbrt.html module src/pylib/Lib/math_impl/cbrt 0 +nim cbrt pylib/Lib/math_impl/cbrt.html#cbrt,F proc cbrt[F: SomeFloat](x: F): F 24 diff --git a/pylib/Lib/math_impl/comptime/cbrt.html b/pylib/Lib/math_impl/comptime/cbrt.html new file mode 100644 index 000000000..d95c4256e --- /dev/null +++ b/pylib/Lib/math_impl/comptime/cbrt.html @@ -0,0 +1,129 @@ + + + + + + + +src/pylib/Lib/math_impl/comptime/cbrt + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/math_impl/comptime/cbrt

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

from https://www.netlib.org/cephes/ cmath.tgz cbrt.c And single.tgz cbrtf.c

+

Cube root

+

DESCRIPTION:

+

Returns the cube root of the argument, which may be negative.

+

Range reduction involves determining the power of 2 of the argument. A polynomial of degree 2 applied to the mantissa, and multiplication by the cube root of 1, 2, or 4 approximates the root to within about 0.1%. Then Newton's iteration is used three times to converge to an accurate result.

+

ACCURACY:

+
Relative error:
+

arithmetic domain # trials peak rms DEC -10,10 200000 1.8e-17 6.2e-18 IEEE 0,1e308 30000 1.5e-16 5.0e-17

+

cbrt.c

+

Cephes Math Library Release 2.8: June, 2000 Copyright 1984, 1991, 2000 by Stephen L. Moshier

+

cbrt.nim Copyright litlighilit 2024

+

+ +
+

Procs

+
+
+
+
func cbrt[F: SomeFloat](x: F): F
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/Lib/math_impl/comptime/cbrt.idx b/pylib/Lib/math_impl/comptime/cbrt.idx new file mode 100644 index 000000000..68428cd10 --- /dev/null +++ b/pylib/Lib/math_impl/comptime/cbrt.idx @@ -0,0 +1,2 @@ +nimTitle cbrt pylib/Lib/math_impl/comptime/cbrt.html module src/pylib/Lib/math_impl/comptime/cbrt 0 +nim cbrt pylib/Lib/math_impl/comptime/cbrt.html#cbrt,F proc cbrt[F: SomeFloat](x: F): F 49 diff --git a/pylib/Lib/math_impl/comptime/common.html b/pylib/Lib/math_impl/comptime/common.html new file mode 100644 index 000000000..2f37bcf29 --- /dev/null +++ b/pylib/Lib/math_impl/comptime/common.html @@ -0,0 +1,219 @@ + + + + + + + +src/pylib/Lib/math_impl/comptime/common + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/math_impl/comptime/common

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Consts

+
+
+
ln2_hi = 0.6931471803691238
+
+ + 3fe62e42 fee00000 + Source   +Edit   + +
+
+
+
ln2_lo = 1.9082149292705877e-10
+
+ + 3dea39ef 35793c76 + Source   +Edit   + +
+
+ +
+
+
+

Templates

+
+
+
+
template GET_FLOAT_WORD(word: var uint32; x: float32)
+
+ + + Source   +Edit   + +
+
+
+
template GET_FLOAT_WORD(x: float32): uint32
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template getLowWord(x: float32): uint16
+
+ + + Source   +Edit   + +
+
+
+
template getLowWord(x: float64): uint32
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template setHighWord(x: float; hi)
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ + +
+
+ + +
+
+ + + diff --git a/pylib/Lib/math_impl/comptime/common.idx b/pylib/Lib/math_impl/comptime/common.idx new file mode 100644 index 000000000..0b6f372d3 --- /dev/null +++ b/pylib/Lib/math_impl/comptime/common.idx @@ -0,0 +1,10 @@ +nimTitle common pylib/Lib/math_impl/comptime/common.html module src/pylib/Lib/math_impl/comptime/common 0 +nim ln2_hi pylib/Lib/math_impl/comptime/common.html#ln2_hi const ln2_hi 10 +nim ln2_lo pylib/Lib/math_impl/comptime/common.html#ln2_lo const ln2_lo 11 +nim getLowWord pylib/Lib/math_impl/comptime/common.html#getLowWord.t,float32 template getLowWord(x: float32): uint16 13 +nim getLowWord pylib/Lib/math_impl/comptime/common.html#getLowWord.t,float64 template getLowWord(x: float64): uint32 14 +nim setHighWord pylib/Lib/math_impl/comptime/common.html#setHighWord.t,float, template setHighWord(x: float; hi) 17 +nim GET_FLOAT_WORD pylib/Lib/math_impl/comptime/common.html#GET_FLOAT_WORD.t,float32 template GET_FLOAT_WORD(x: float32): uint32 20 +nim GET_FLOAT_WORD pylib/Lib/math_impl/comptime/common.html#GET_FLOAT_WORD.t,uint32,float32 template GET_FLOAT_WORD(word: var uint32; x: float32) 21 +nimgrp Getfloatword pylib/Lib/math_impl/comptime/common.html#GET_FLOAT_WORD-templates-all template 20 +nimgrp getlowword pylib/Lib/math_impl/comptime/common.html#getLowWord-templates-all template 13 diff --git a/pylib/Lib/math_impl/comptime/expm1.html b/pylib/Lib/math_impl/comptime/expm1.html new file mode 100644 index 000000000..2ebfa6b0d --- /dev/null +++ b/pylib/Lib/math_impl/comptime/expm1.html @@ -0,0 +1,277 @@ + + + + + + + +src/pylib/Lib/math_impl/comptime/expm1 + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/math_impl/comptime/expm1

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

compiletime/expm1.nim 10/19/2024:

  • translated from and combine s_expm1.c and s_expm1f.c
  • +
  • Also, some formula in the following doc used to have some tabs for indent, I replaced them with spaces.
  • +
+

---

+

@(#)s_expm1.c 1.5 04/04/22 And s_expm1f.c

+

==================================================== Copyright (C) 2004 by Sun Microsystems, Inc. All rights reserved. Copyright (C) 2024 by litlighilit. All rights reserved.

+

Permission to use, copy, modify, and distribute this software is freely granted, provided that this notice is preserved. ==================================================== expm1(x) Returns exp(x)-1, the exponential of x minus 1.

+

+Method
+  1. Argument reduction:
+   Given x, find r and integer k such that
+              
+              x = k*ln2 + r,  |r| <= 0.5*ln2 ~ 0.34658
+     
+     Here a correction term c will be computed to compensate
+   the error in r when rounded to a floating-point number.
+  
+  2. Approximating expm1(r) by a special rational function on
+   the interval [0,0.34658]:
+   Since
+       r*(exp(r)+1)/(exp(r)-1) = 2+ r^2/6 - r^4/360 + ...
+   we define R1(r*r) by
+       r*(exp(r)+1)/(exp(r)-1) = 2+ r^2/6 * R1(r*r)
+   That is,
+       R1(r**2) = 6/r *((exp(r)+1)/(exp(r)-1) - 2/r)
+            = 6/r * ( 1 + 2.0*(1/(exp(r)-1) - 1/r))
+            = 1 - r^2/60 + r^4/2520 - r^6/100800 + ...
+     We use a special Remes algorithm on [0,0.347] to generate
+    a polynomial of degree 5 in r*r to approximate R1. The
+   maximum error of this polynomial approximation is bounded
+   by 2**-61. In other words,
+       R1(z) ~ 1.0 + Q1*z + Q2*z**2 + Q3*z**3 + Q4*z**4 + Q5*z**5
+   where Q1  =  -1.6666666666666567384E-2,
+         Q2  =   3.9682539681370365873E-4,
+         Q3  =  -9.9206344733435987357E-6,
+         Q4  =   2.5051361420808517002E-7,
+         Q5  =  -6.2843505682382617102E-9;
+     (where z=r*r, and the values of Q1 to Q5 are listed below)
+   with error bounded by
+       |                  5           |     -61
+       | 1.0+Q1*z+...+Q5*z   -  R1(z) | <= 2
+       |                              |
+   
+   expm1(r) = exp(r)-1 is then computed by the following
+    specific way which minimize the accumulation rounding error:
+                          2     3
+                         r     r    [ 3 - (R1 + R1*r/2)  ]
+         expm1(r) = r + --- + --- * [--------------------]
+                         2     2    [ 6 - r*(3 - R1*r/2) ]
+   
+   To compensate the error in the argument reduction, we use
+       expm1(r+c) = expm1(r) + c + expm1(r)*c
+              ~ expm1(r) + c + r*c
+   Thus c+r*c will be added in as the correction terms for
+   expm1(r+c). Now rearrange the term to avoid optimization
+    screw up:
+                   (      2                                    2 )
+                   ({  ( r    [ R1 -  (3 - R1*r/2) ]  )  }    r  )
+    expm1(r+c)~r - ({r*(--- * [--------------------]-c)-c} - --- )
+                   ({  ( 2    [ 6 - r*(3 - R1*r/2) ]  )  }    2  )
+                   (                                             )
+          
+          = r - E
+  3. Scale back to obtain expm1(x):
+   From step 1, we have
+      expm1(x) = either 2^k*[expm1(r)+1] - 1
+           = or     2^k*[expm1(r) + (1-2^-k)]
+  4. Implementation notes:
+   (A). To save one multiplication, we scale the coefficient Qi
+        to Qi*2^i, and replace z by (x^2)/2.
+   (B). To achieve maximum accuracy, we compute expm1(x) by
+     (i)   if x < -56*ln2, return -1.0, (raise inexact if x!=inf)
+     (ii)  if k=0, return r-E
+     (iii) if k=-1, return 0.5*(r-E)-0.5
+     (iv)    if k=1 if r < -0.25, return 2*((r+0.5)- E)
+                     else         return  1.0+2.0*(r-E);
+     (v)   if (k<-2||k>56) return 2^k(1-(E-r)) - 1 (or exp(x)-1)
+     (vi)  if k <= 20, return 2^k((1-2^-k)-(E-r)), else
+     (vii) return 2^k(1-((E+2^-k)-r))
+
+Special cases:
+   expm1(INF) is INF, expm1(NaN) is NaN;
+   expm1(-INF) is -1, and
+   for finite argument, only expm1(0)=0 is exact.
+
+Accuracy:
+   according to an error analysis, the error is always less than
+   1 ulp (unit in the last place).
+
+Misc. info.
+   For IEEE double
+       if x >  7.09782712893383973096e+02 then expm1(x) overflow
+

+

Constants: The hexadecimal values are the intended ones for the following constants. The decimal values may be used, provided that the compiler will convert from decimal to binary accurately enough to produce the hexadecimal values shown.

+

+
+

Imports

+
+ common +
+
+
+

Procs

+
+
+
+
proc expm1[F: SomeFloat](x: F): F
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template hugeF[F](): untyped
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template o_threshold[F](): untyped
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template tinyF[F](): untyped
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/Lib/math_impl/comptime/expm1.idx b/pylib/Lib/math_impl/comptime/expm1.idx new file mode 100644 index 000000000..e48c8c146 --- /dev/null +++ b/pylib/Lib/math_impl/comptime/expm1.idx @@ -0,0 +1,5 @@ +nimTitle expm1 pylib/Lib/math_impl/comptime/expm1.html module src/pylib/Lib/math_impl/comptime/expm1 0 +nim hugeF pylib/Lib/math_impl/comptime/expm1.html#hugeF.t template hugeF[F](): untyped 131 +nim tinyF pylib/Lib/math_impl/comptime/expm1.html#tinyF.t template tinyF[F](): untyped 132 +nim o_threshold pylib/Lib/math_impl/comptime/expm1.html#o_threshold.t template o_threshold[F](): untyped 133 +nim expm1 pylib/Lib/math_impl/comptime/expm1.html#expm1,F proc expm1[F: SomeFloat](x: F): F 144 diff --git a/pylib/Lib/math_impl/comptime/log1p.html b/pylib/Lib/math_impl/comptime/log1p.html new file mode 100644 index 000000000..ec8258f21 --- /dev/null +++ b/pylib/Lib/math_impl/comptime/log1p.html @@ -0,0 +1,201 @@ + + + + + + + +src/pylib/Lib/math_impl/comptime/log1p + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/math_impl/comptime/log1p

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

compiletime/log1p.nim 2024/10/19:

+
@(#)s_log1p.c 1.3 95/01/18
+Along with:
+s_log1pf.c -- float version of s_log1p.c.
+Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
+
+
+====================================================
+Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+Copyright (C) 2024 by litlighilit. All rights reserved.
+
+Developed at SunSoft, a Sun Microsystems, Inc. business.
+Permission to use, copy, modify, and distribute this
+software is freely granted, provided that this notice
+is preserved.
+====================================================
+
+double log1p(double x)
+
+Method :
+  1. Argument Reduction: find k and f such that
+			1+x = 2^k * (1+f),
+	   where  sqrt(2)/2 < 1+f < sqrt(2) .
+
+     Note. If k=0, then f=x is exact. However, if k!=0, then f
+	may not be representable exactly. In that case, a correction
+	term is need. Let u=1+x rounded. Let c = (1+x)-u, then
+	log(1+x) - log(u) ~ c/u. Thus, we proceed to compute log(u),
+	and add back the correction term c/u.
+	(Note: when x > 2**53, one can simply return log(x))
+
+  2. Approximation of log1p(f).
+	Let s = f/(2+f) ; based on log(1+f) = log(1+s) - log(1-s)
+		 = 2s + 2/3 s**3 + 2/5 s**5 + .....,
+	     	 = 2s + s*R
+     We use a special Reme algorithm on [0,0.1716] to generate
+	a polynomial of degree 14 to approximate R The maximum error
+	of this polynomial approximation is bounded by 2**-58.45. In
+	other words,
+		        2      4      6      8      10      12      14
+	    R(z) ~ Lp1*s +Lp2*s +Lp3*s +Lp4*s +Lp5*s  +Lp6*s  +Lp7*s
+ 	(the values of Lp1 to Lp7 are listed in the program)
+	and
+	    |      2          14          |     -58.45
+	    | Lp1*s +...+Lp7*s    -  R(z) | <= 2
+	    |                             |
+	Note that 2s = f - s*f = f - hfsq + s*hfsq, where hfsq = f*f/2.
+	In order to guarantee error in log below 1ulp, we compute log
+	by
+		log1p(f) = f - (hfsq - s*(hfsq+R)).
+	
+	3. Finally, log1p(x) = k*ln2 + log1p(f).
+		 	     = k*ln2_hi+(f-(hfsq-(s*(hfsq+R)+k*ln2_lo)))
+	   Here ln2 is split into two floating point number:
+			ln2_hi + ln2_lo,
+	   where n*ln2_hi is always exact for |n| < 2000.
+
+Special cases:
+	log1p(x) is NaN with signal if x < -1 (including -INF) ;
+	log1p(+INF) is +INF; log1p(-1) is -INF with signal;
+	log1p(NaN) is that NaN with no signal.
+
+Accuracy:
+	according to an error analysis, the error is always less than
+	1 ulp (unit in the last place).
+
+Constants:
+The hexadecimal values are the intended ones for the following
+constants. The decimal values may be used, provided that the
+compiler will convert from decimal to binary accurately enough
+to produce the hexadecimal values shown.
+
+
+Note: Assuming log() return accurate answer, the following
+	 algorithm can be used to compute log1p(x) to within a few ULP:
+	
+		u = 1+x;
+		if(u==1.0) return x ; else
+			   return log(u)*(x/(u-1.0));
+
+	 See HP-15C Advanced Functions Handbook, p.193.
+
+

+
+

Imports

+
+ common +
+
+
+

Procs

+
+
+
+
proc log1p[F: SomeFloat](x: F): F
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/Lib/math_impl/comptime/log1p.idx b/pylib/Lib/math_impl/comptime/log1p.idx new file mode 100644 index 000000000..82c24b523 --- /dev/null +++ b/pylib/Lib/math_impl/comptime/log1p.idx @@ -0,0 +1,2 @@ +nimTitle log1p pylib/Lib/math_impl/comptime/log1p.html module src/pylib/Lib/math_impl/comptime/log1p 0 +nim log1p pylib/Lib/math_impl/comptime/log1p.html#log1p,F proc log1p[F: SomeFloat](x: F): F 100 diff --git a/pylib/Lib/math_impl/constsUtils.html b/pylib/Lib/math_impl/constsUtils.html new file mode 100644 index 000000000..d28e3db1e --- /dev/null +++ b/pylib/Lib/math_impl/constsUtils.html @@ -0,0 +1,137 @@ + + + + + + + +src/pylib/Lib/math_impl/constsUtils + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/math_impl/constsUtils

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Templates

+
+
+
+
template genWithArg(sym, v32, v64) {.dirty.}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template genWithBracket(sym, v32, v64)
+
+ + + Source   +Edit   + +
+
+
+
template genWithBracket(sym, v32, v64, Ret) {.dirty.}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/Lib/math_impl/constsUtils.idx b/pylib/Lib/math_impl/constsUtils.idx new file mode 100644 index 000000000..cdfdaa285 --- /dev/null +++ b/pylib/Lib/math_impl/constsUtils.idx @@ -0,0 +1,5 @@ +nimTitle constsUtils pylib/Lib/math_impl/constsUtils.html module src/pylib/Lib/math_impl/constsUtils 0 +nim genWithArg pylib/Lib/math_impl/constsUtils.html#genWithArg.t,,, template genWithArg(sym, v32, v64) 7 +nim genWithBracket pylib/Lib/math_impl/constsUtils.html#genWithBracket.t,,,, template genWithBracket(sym, v32, v64, Ret) 11 +nim genWithBracket pylib/Lib/math_impl/constsUtils.html#genWithBracket.t,,, template genWithBracket(sym, v32, v64) 15 +nimgrp genwithbracket pylib/Lib/math_impl/constsUtils.html#genWithBracket-templates-all template 11 diff --git a/pylib/Lib/math_impl/err.html b/pylib/Lib/math_impl/err.html new file mode 100644 index 000000000..6c46ffa3c --- /dev/null +++ b/pylib/Lib/math_impl/err.html @@ -0,0 +1,223 @@ + + + + + + + +src/pylib/Lib/math_impl/err + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/math_impl/err

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Types

+
+
+
GammaError = enum
+  geOk, geDom = "x in {0, -1, -2, ...}", ## when .
+                                          ## Infinity discontinuity,
+                                          ## which shall produce `Complex Infinity` in SymPy and
+                                          ## means domain error
+  geOverFlow = "x > MAX_GAMMA_X, result overflow as inf",
+  geUnderFlow = "x < MIN_GAMMA_X, result underflow as `-0.0` or `0.0`.", geZeroCantDetSign = "`x < -maxSafeInteger`(exclude -inf), " &
+      "can\'t detect result\'s sign", ## `x` losing unit digit, often not regard as an error
+  geGotNegInf = "x == -inf" ## this is made as a enumerate item as different languages'
+                            ## implementation has different treatment towards -inf
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
func mapRaiseGammaErr(err: GammaError) {....raises: [ValueError], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template raiseDomainErr()
+
+ + + Source   +Edit   + +
+
+
+
template raiseDomainErr(details: string)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template raiseRangeErr()
+
+ + + Source   +Edit   + +
+
+
+
template raiseRangeErr(details: string)
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/Lib/math_impl/err.idx b/pylib/Lib/math_impl/err.idx new file mode 100644 index 000000000..f20ca94f1 --- /dev/null +++ b/pylib/Lib/math_impl/err.idx @@ -0,0 +1,15 @@ +nimTitle err pylib/Lib/math_impl/err.html module src/pylib/Lib/math_impl/err 0 +nim geOk pylib/Lib/math_impl/err.html#geOk GammaError.geOk 3 +nim geDom pylib/Lib/math_impl/err.html#geDom GammaError.geDom 3 +nim geOverFlow pylib/Lib/math_impl/err.html#geOverFlow GammaError.geOverFlow 3 +nim geUnderFlow pylib/Lib/math_impl/err.html#geUnderFlow GammaError.geUnderFlow 3 +nim geZeroCantDetSign pylib/Lib/math_impl/err.html#geZeroCantDetSign GammaError.geZeroCantDetSign 3 +nim geGotNegInf pylib/Lib/math_impl/err.html#geGotNegInf GammaError.geGotNegInf 3 +nim GammaError pylib/Lib/math_impl/err.html#GammaError enum GammaError 3 +nim raiseDomainErr pylib/Lib/math_impl/err.html#raiseDomainErr.t template raiseDomainErr() 20 +nim raiseDomainErr pylib/Lib/math_impl/err.html#raiseDomainErr.t,string template raiseDomainErr(details: string) 24 +nim raiseRangeErr pylib/Lib/math_impl/err.html#raiseRangeErr.t template raiseRangeErr() 28 +nim raiseRangeErr pylib/Lib/math_impl/err.html#raiseRangeErr.t,string template raiseRangeErr(details: string) 32 +nim mapRaiseGammaErr pylib/Lib/math_impl/err.html#mapRaiseGammaErr,GammaError proc mapRaiseGammaErr(err: GammaError) 36 +nimgrp raiserangeerr pylib/Lib/math_impl/err.html#raiseRangeErr-templates-all template 28 +nimgrp raisedomainerr pylib/Lib/math_impl/err.html#raiseDomainErr-templates-all template 20 diff --git a/pylib/Lib/math_impl/errnoUtils.html b/pylib/Lib/math_impl/errnoUtils.html new file mode 100644 index 000000000..685401a89 --- /dev/null +++ b/pylib/Lib/math_impl/errnoUtils.html @@ -0,0 +1,96 @@ + + + + + + + +src/pylib/Lib/math_impl/errnoUtils + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/math_impl/errnoUtils

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+ +
+ + +
+
+ + + diff --git a/pylib/Lib/math_impl/errnoUtils.idx b/pylib/Lib/math_impl/errnoUtils.idx new file mode 100644 index 000000000..a0c9dc028 --- /dev/null +++ b/pylib/Lib/math_impl/errnoUtils.idx @@ -0,0 +1 @@ +nimTitle errnoUtils pylib/Lib/math_impl/errnoUtils.html module src/pylib/Lib/math_impl/errnoUtils 0 diff --git a/pylib/Lib/math_impl/expm1_log1p.html b/pylib/Lib/math_impl/expm1_log1p.html new file mode 100644 index 000000000..c3842e0b0 --- /dev/null +++ b/pylib/Lib/math_impl/expm1_log1p.html @@ -0,0 +1,149 @@ + + + + + + + +src/pylib/Lib/math_impl/expm1_log1p + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/math_impl/expm1_log1p

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

Hint: +result calculated at compile-time may a little differ those in runtime-time, e.g. For log1p: for i in 1..100, x = float(i), the following are results that differs each other:
+ +

x = 2.0

c_log1p(x) = 1.09861228866811 ct_log1p.log1p(x) = 1.09861228866811 relative_tol = -2.021137094636221e-16

+ +

x = 13.0

c_log1p(x) = 2.639057329615258 ct_log1p.log1p(x) = 2.639057329615259 relative_tol = 1.682756963505621e-16

+ +

x = 47.0

c_log1p(x) = 3.871201010907891 ct_log1p.log1p(x) = 3.871201010907891 relative_tol = -1.147161329516994e-16

+ +

x = 73.0

c_log1p(x) = 4.30406509320417 ct_log1p.log1p(x) = 4.304065093204169 relative_tol = -2.063580360581673e-16

+

+ +
+

Procs

+
+
+
+
func expm1[F: SomeFloat](x: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func log1p[F: SomeFloat](x: F): F
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/Lib/math_impl/expm1_log1p.idx b/pylib/Lib/math_impl/expm1_log1p.idx new file mode 100644 index 000000000..0169fbc16 --- /dev/null +++ b/pylib/Lib/math_impl/expm1_log1p.idx @@ -0,0 +1,7 @@ +nimTitle expm1_log1p pylib/Lib/math_impl/expm1_log1p.html module src/pylib/Lib/math_impl/expm1_log1p 0 +nim log1p pylib/Lib/math_impl/expm1_log1p.html#log1p,F proc log1p[F: SomeFloat](x: F): F 50 +nim expm1 pylib/Lib/math_impl/expm1_log1p.html#expm1,F proc expm1[F: SomeFloat](x: F): F 56 +heading x = 2.0 pylib/Lib/math_impl/expm1_log1p.html#x-eq-2dot0 x = 2.0 0 +heading x = 13.0 pylib/Lib/math_impl/expm1_log1p.html#x-eq-13dot0 x = 13.0 0 +heading x = 47.0 pylib/Lib/math_impl/expm1_log1p.html#x-eq-47dot0 x = 47.0 0 +heading x = 73.0 pylib/Lib/math_impl/expm1_log1p.html#x-eq-73dot0 x = 73.0 0 diff --git a/pylib/Lib/math_impl/frexp.html b/pylib/Lib/math_impl/frexp.html new file mode 100644 index 000000000..85cb7baa3 --- /dev/null +++ b/pylib/Lib/math_impl/frexp.html @@ -0,0 +1,157 @@ + + + + + + + +src/pylib/Lib/math_impl/frexp + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/math_impl/frexp

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
func frexp[F: SomeFloat](x: F): (F, int)
+
+ + + Source   +Edit   + +
+
+
+
func frexp[F: SomeFloat](x: F; e: var int): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func n_frexp[F: SomeFloat](x: F): (F, int)
+
+ + + Source   +Edit   + +
+
+
+
func n_frexp[F: SomeFloat](x: F; e: var int): F
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/Lib/math_impl/frexp.idx b/pylib/Lib/math_impl/frexp.idx new file mode 100644 index 000000000..b51974568 --- /dev/null +++ b/pylib/Lib/math_impl/frexp.idx @@ -0,0 +1,7 @@ +nimTitle frexp pylib/Lib/math_impl/frexp.html module src/pylib/Lib/math_impl/frexp 0 +nim n_frexp pylib/Lib/math_impl/frexp.html#n_frexp,F proc n_frexp[F: SomeFloat](x: F): (F, int) 7 +nim n_frexp pylib/Lib/math_impl/frexp.html#n_frexp,F,int proc n_frexp[F: SomeFloat](x: F; e: var int): F 8 +nim frexp pylib/Lib/math_impl/frexp.html#frexp,F proc frexp[F: SomeFloat](x: F): (F, int) 17 +nim frexp pylib/Lib/math_impl/frexp.html#frexp,F,int proc frexp[F: SomeFloat](x: F; e: var int): F 23 +nimgrp frexp pylib/Lib/math_impl/frexp.html#frexp-procs-all proc 17 +nimgrp nfrexp pylib/Lib/math_impl/frexp.html#n_frexp-procs-all proc 7 diff --git a/pylib/Lib/math_impl/gammaXRange.html b/pylib/Lib/math_impl/gammaXRange.html new file mode 100644 index 000000000..110b639e7 --- /dev/null +++ b/pylib/Lib/math_impl/gammaXRange.html @@ -0,0 +1,159 @@ + + + + + + + +src/pylib/Lib/math_impl/gammaXRange + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/math_impl/gammaXRange

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

Hint: +CPython's uses MAX_GAMMA_X = 200.0 and MIN_GAMMA_X = -200.0, which differs the result above, but that's fine, as that's just a short-cut, there's still further check after that. See pylib#38 comment for details.
+

Thus in fact, these constants are no need to be very accurate, just to ensure they're greater than the actual value is enough.

+

But as such a short-cur is introduced, I think it better to make it accurate.

+

The values are calcuated from tools/math/gamma_x_range.py

+ +

MAX_GAMMA_X

35.040096282958984'f32 0b01000010_00001100_00101001_00001111'f32

+ +

MIN_GAMMA_X

-38.601410000000016'f32
+

0b11000010_00011010_01100111_11011000'f32

+ +

MAX_GAMMA_X

171.6243769563027'f64 0b01000000_01100101_01110011_11111010_11100101_01100001_11110110_01000111'f64

+ +

MIN_GAMMA_X

-177.7807064574756'f64
+

0b11000000_01100110_00111000_11111011_10001100_00011011_11010100_01000111'f64

+ +

others

I found stdlib-js/gamma uses following values: 171.61447887182298

+
-170.5674972726612
+

But what I tested using SymPy was different. If SymPy is right and my method is so, then the old values are uncorrect and shall not be used, as the old checking range for zero/inf result is bigger. (it doesn't matter if that was smaller) So I change to use current values.

+

+
+

Imports

+
+ constsUtils +
+
+
+

Templates

+
+
+
+
template MAX_GAMMA_X[F](_: typedesc[F]): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template MIN_GAMMA_X[F](_: typedesc[F]): F
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/Lib/math_impl/gammaXRange.idx b/pylib/Lib/math_impl/gammaXRange.idx new file mode 100644 index 000000000..84249abcb --- /dev/null +++ b/pylib/Lib/math_impl/gammaXRange.idx @@ -0,0 +1,8 @@ +nimTitle gammaXRange pylib/Lib/math_impl/gammaXRange.html module src/pylib/Lib/math_impl/gammaXRange 0 +nim MAX_GAMMA_X pylib/Lib/math_impl/gammaXRange.html#MAX_GAMMA_X.t,typedesc[F] template MAX_GAMMA_X[F](_: typedesc[F]): F 48 +nim MIN_GAMMA_X pylib/Lib/math_impl/gammaXRange.html#MIN_GAMMA_X.t,typedesc[F] template MIN_GAMMA_X[F](_: typedesc[F]): F 50 +heading MAX_GAMMA_X pylib/Lib/math_impl/gammaXRange.html#max-gamma-x MAX_GAMMA_X 0 +heading MIN_GAMMA_X pylib/Lib/math_impl/gammaXRange.html#min-gamma-x MIN_GAMMA_X 0 +heading MAX_GAMMA_X pylib/Lib/math_impl/gammaXRange.html#max-gamma-x MAX_GAMMA_X 0 +heading MIN_GAMMA_X pylib/Lib/math_impl/gammaXRange.html#min-gamma-x MIN_GAMMA_X 0 +heading others pylib/Lib/math_impl/gammaXRange.html#others others 0 diff --git a/pylib/Lib/math_impl/inWordUtils/assertIsLittleEndian.html b/pylib/Lib/math_impl/inWordUtils/assertIsLittleEndian.html new file mode 100644 index 000000000..e943eb25f --- /dev/null +++ b/pylib/Lib/math_impl/inWordUtils/assertIsLittleEndian.html @@ -0,0 +1,134 @@ + + + + + + + +src/pylib/Lib/math_impl/inWordUtils/assertIsLittleEndian + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/math_impl/inWordUtils/assertIsLittleEndian

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Consts

+
+
+
compileLittleEndian = true
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
func isLittleEndian(): bool {.compileTime, ...raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/Lib/math_impl/inWordUtils/assertIsLittleEndian.idx b/pylib/Lib/math_impl/inWordUtils/assertIsLittleEndian.idx new file mode 100644 index 000000000..0add38222 --- /dev/null +++ b/pylib/Lib/math_impl/inWordUtils/assertIsLittleEndian.idx @@ -0,0 +1,3 @@ +nimTitle assertIsLittleEndian pylib/Lib/math_impl/inWordUtils/assertIsLittleEndian.html module src/pylib/Lib/math_impl/inWordUtils/assertIsLittleEndian 0 +nim compileLittleEndian pylib/Lib/math_impl/inWordUtils/assertIsLittleEndian.html#compileLittleEndian const compileLittleEndian 2 +nim isLittleEndian pylib/Lib/math_impl/inWordUtils/assertIsLittleEndian.html#isLittleEndian proc isLittleEndian(): bool 10 diff --git a/pylib/Lib/math_impl/inWordUtils/consts.html b/pylib/Lib/math_impl/inWordUtils/consts.html new file mode 100644 index 000000000..1d25760ea --- /dev/null +++ b/pylib/Lib/math_impl/inWordUtils/consts.html @@ -0,0 +1,254 @@ + + + + + + + +src/pylib/Lib/math_impl/inWordUtils/consts + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/math_impl/inWordUtils/consts

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

maxExponent F - 1 = (MAX - 1) - BIAS = 254 - BIAS = 127 or 2046 - BIAS = 10230b1_00000000_1111111 => 32895 0b1_00000000000_11111111111111111111 => 2148532223mask whose exponent is equal to 126, 1022 a.k.a. (BIAS-1): 0b0_01111110_0000000 => 16256 0b0_01111111110_00000000000000000000 => 1071644672HIGH_WORD_EXPONENT_MASK: 0b0_11111111_0000000 0b0_11111111111_00000000000000000000mantissaDigits F - 1

+ +
+

Templates

+
+
+
+
template BIAS[F](_: typedesc[F]): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template CLEAR_EXP_MASK[F](): untyped
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template EXP_MASK[F](): untyped
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template HighWordFracBits[F](): untyped
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template MantissaDigits[F](): untyped
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template MAX_EXPONENT[F](_: typedesc[F]): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template MAX_SUBNORMAL_EXPONENT[F](_: typedesc[F]): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template MIN_SUBNORMAL_EXPONENT[F](_: typedesc[F]): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template SET_EXP_MASK[F](): untyped
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/Lib/math_impl/inWordUtils/consts.idx b/pylib/Lib/math_impl/inWordUtils/consts.idx new file mode 100644 index 000000000..7527d7f93 --- /dev/null +++ b/pylib/Lib/math_impl/inWordUtils/consts.idx @@ -0,0 +1,10 @@ +nimTitle consts pylib/Lib/math_impl/inWordUtils/consts.html module src/pylib/Lib/math_impl/inWordUtils/consts 0 +nim BIAS pylib/Lib/math_impl/inWordUtils/consts.html#BIAS.t,typedesc[F] template BIAS[F](_: typedesc[F]): F 5 +nim MAX_SUBNORMAL_EXPONENT pylib/Lib/math_impl/inWordUtils/consts.html#MAX_SUBNORMAL_EXPONENT.t,typedesc[F] template MAX_SUBNORMAL_EXPONENT[F](_: typedesc[F]): F 6 +nim MIN_SUBNORMAL_EXPONENT pylib/Lib/math_impl/inWordUtils/consts.html#MIN_SUBNORMAL_EXPONENT.t,typedesc[F] template MIN_SUBNORMAL_EXPONENT[F](_: typedesc[F]): F 7 +nim MAX_EXPONENT pylib/Lib/math_impl/inWordUtils/consts.html#MAX_EXPONENT.t,typedesc[F] template MAX_EXPONENT[F](_: typedesc[F]): F 8 +nim CLEAR_EXP_MASK pylib/Lib/math_impl/inWordUtils/consts.html#CLEAR_EXP_MASK.t template CLEAR_EXP_MASK[F](): untyped 13 +nim SET_EXP_MASK pylib/Lib/math_impl/inWordUtils/consts.html#SET_EXP_MASK.t template SET_EXP_MASK[F](): untyped 18 +nim EXP_MASK pylib/Lib/math_impl/inWordUtils/consts.html#EXP_MASK.t template EXP_MASK[F](): untyped 23 +nim HighWordFracBits pylib/Lib/math_impl/inWordUtils/consts.html#HighWordFracBits.t template HighWordFracBits[F](): untyped 28 +nim MantissaDigits pylib/Lib/math_impl/inWordUtils/consts.html#MantissaDigits.t template MantissaDigits[F](): untyped 29 diff --git a/pylib/Lib/math_impl/inWordUtils/float_view.html b/pylib/Lib/math_impl/inWordUtils/float_view.html new file mode 100644 index 000000000..5ed4aa00d --- /dev/null +++ b/pylib/Lib/math_impl/inWordUtils/float_view.html @@ -0,0 +1,202 @@ + + + + + + + +src/pylib/Lib/math_impl/inWordUtils/float_view + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/math_impl/inWordUtils/float_view

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

for JS and C-like backends

+

Not for nimvm, see {to,from}Words for impl for nimvm backend

+

+
+

Procs

+
+
+
+
func `[]`(fv: VIEW32; _: range[0 .. 0]): float32 {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func `[]`(fv: VIEW64; _: range[0 .. 0]): float64 {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func `[]=`(fv: var VIEW32; _: range[0 .. 0]; f: float32) {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func `[]=`(fv: var VIEW64; _: range[0 .. 0]; f: float64) {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template init32FloatView(FLOAT32_VIEW, UINT16_VIEW)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template init64FloatView(FLOAT64_VIEW, UINT32_VIEW)
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/Lib/math_impl/inWordUtils/float_view.idx b/pylib/Lib/math_impl/inWordUtils/float_view.idx new file mode 100644 index 000000000..807213987 --- /dev/null +++ b/pylib/Lib/math_impl/inWordUtils/float_view.idx @@ -0,0 +1,9 @@ +nimTitle float_view pylib/Lib/math_impl/inWordUtils/float_view.html module src/pylib/Lib/math_impl/inWordUtils/float_view 0 +nim `[]` pylib/Lib/math_impl/inWordUtils/float_view.html#[],VIEW64,range[] proc `[]`(fv: VIEW64; _: range[0 .. 0]): float64 34 +nim `[]=` pylib/Lib/math_impl/inWordUtils/float_view.html#[]=,VIEW64,range[],float64 proc `[]=`(fv: var VIEW64; _: range[0 .. 0]; f: float64) 37 +nim `[]` pylib/Lib/math_impl/inWordUtils/float_view.html#[],VIEW32,range[] proc `[]`(fv: VIEW32; _: range[0 .. 0]): float32 34 +nim `[]=` pylib/Lib/math_impl/inWordUtils/float_view.html#[]=,VIEW32,range[],float32 proc `[]=`(fv: var VIEW32; _: range[0 .. 0]; f: float32) 38 +nim init64FloatView pylib/Lib/math_impl/inWordUtils/float_view.html#init64FloatView.t,, template init64FloatView(FLOAT64_VIEW, UINT32_VIEW) 41 +nim init32FloatView pylib/Lib/math_impl/inWordUtils/float_view.html#init32FloatView.t,, template init32FloatView(FLOAT32_VIEW, UINT16_VIEW) 45 +nimgrp []= pylib/Lib/math_impl/inWordUtils/float_view.html#[]=-procs-all proc 35 +nimgrp [] pylib/Lib/math_impl/inWordUtils/float_view.html#[]-procs-all proc 34 diff --git a/pylib/Lib/math_impl/inWordUtils/fromWords.html b/pylib/Lib/math_impl/inWordUtils/fromWords.html new file mode 100644 index 000000000..cf840e0fd --- /dev/null +++ b/pylib/Lib/math_impl/inWordUtils/fromWords.html @@ -0,0 +1,129 @@ + + + + + + + +src/pylib/Lib/math_impl/inWordUtils/fromWords + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/math_impl/inWordUtils/fromWords

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
proc fromWords(high, low: uint16): float32 {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc fromWords(high, low: uint32): float {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/Lib/math_impl/inWordUtils/fromWords.idx b/pylib/Lib/math_impl/inWordUtils/fromWords.idx new file mode 100644 index 000000000..1320fe7b1 --- /dev/null +++ b/pylib/Lib/math_impl/inWordUtils/fromWords.idx @@ -0,0 +1,4 @@ +nimTitle fromWords pylib/Lib/math_impl/inWordUtils/fromWords.html module src/pylib/Lib/math_impl/inWordUtils/fromWords 0 +nim fromWords pylib/Lib/math_impl/inWordUtils/fromWords.html#fromWords,uint32,uint32 proc fromWords(high, low: uint32): float 6 +nim fromWords pylib/Lib/math_impl/inWordUtils/fromWords.html#fromWords,uint16,uint16 proc fromWords(high, low: uint16): float32 17 +nimgrp fromwords pylib/Lib/math_impl/inWordUtils/fromWords.html#fromWords-procs-all proc 6 diff --git a/pylib/Lib/math_impl/inWordUtils/indices.html b/pylib/Lib/math_impl/inWordUtils/indices.html new file mode 100644 index 000000000..b3a79f173 --- /dev/null +++ b/pylib/Lib/math_impl/inWordUtils/indices.html @@ -0,0 +1,154 @@ + + + + + + + +src/pylib/Lib/math_impl/inWordUtils/indices + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/math_impl/inWordUtils/indices

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Consts

+
+
+
HIGH = 1
+
+ + + Source   +Edit   + +
+
+
+
LOW = 0
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Templates

+
+
+
+
template accessHighLow(body)
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/Lib/math_impl/inWordUtils/indices.idx b/pylib/Lib/math_impl/inWordUtils/indices.idx new file mode 100644 index 000000000..53ab0e8a6 --- /dev/null +++ b/pylib/Lib/math_impl/inWordUtils/indices.idx @@ -0,0 +1,4 @@ +nimTitle indices pylib/Lib/math_impl/inWordUtils/indices.html module src/pylib/Lib/math_impl/inWordUtils/indices 0 +nim HIGH pylib/Lib/math_impl/inWordUtils/indices.html#HIGH const HIGH 26 +nim LOW pylib/Lib/math_impl/inWordUtils/indices.html#LOW const LOW 27 +nim accessHighLow pylib/Lib/math_impl/inWordUtils/indices.html#accessHighLow.t template accessHighLow(body) 29 diff --git a/pylib/Lib/math_impl/inWordUtils/toWords.html b/pylib/Lib/math_impl/inWordUtils/toWords.html new file mode 100644 index 000000000..63a18da83 --- /dev/null +++ b/pylib/Lib/math_impl/inWordUtils/toWords.html @@ -0,0 +1,129 @@ + + + + + + + +src/pylib/Lib/math_impl/inWordUtils/toWords + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/math_impl/inWordUtils/toWords

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
func toWords(x: float): (uint32, uint32) {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func toWords(x: float32): (uint16, uint16) {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/Lib/math_impl/inWordUtils/toWords.idx b/pylib/Lib/math_impl/inWordUtils/toWords.idx new file mode 100644 index 000000000..5b46f134a --- /dev/null +++ b/pylib/Lib/math_impl/inWordUtils/toWords.idx @@ -0,0 +1,4 @@ +nimTitle toWords pylib/Lib/math_impl/inWordUtils/toWords.html module src/pylib/Lib/math_impl/inWordUtils/toWords 0 +nim toWords pylib/Lib/math_impl/inWordUtils/toWords.html#toWords,float proc toWords(x: float): (uint32, uint32) 5 +nim toWords pylib/Lib/math_impl/inWordUtils/toWords.html#toWords,float32 proc toWords(x: float32): (uint16, uint16) 17 +nimgrp towords pylib/Lib/math_impl/inWordUtils/toWords.html#toWords-procs-all proc 5 diff --git a/pylib/Lib/math_impl/isX.html b/pylib/Lib/math_impl/isX.html new file mode 100644 index 000000000..f973e7891 --- /dev/null +++ b/pylib/Lib/math_impl/isX.html @@ -0,0 +1,135 @@ + + + + + + + +src/pylib/Lib/math_impl/isX + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/math_impl/isX

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
func isfinite(x: SomeFloat): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func isinf(x: SomeFloat): bool
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/Lib/math_impl/isX.idx b/pylib/Lib/math_impl/isX.idx new file mode 100644 index 000000000..367cb70ea --- /dev/null +++ b/pylib/Lib/math_impl/isX.idx @@ -0,0 +1,3 @@ +nimTitle isX pylib/Lib/math_impl/isX.html module src/pylib/Lib/math_impl/isX 0 +nim isinf pylib/Lib/math_impl/isX.html#isinf,SomeFloat proc isinf(x: SomeFloat): bool 33 +nim isfinite pylib/Lib/math_impl/isX.html#isfinite,SomeFloat proc isfinite(x: SomeFloat): bool 32 diff --git a/pylib/Lib/math_impl/ldexp.html b/pylib/Lib/math_impl/ldexp.html new file mode 100644 index 000000000..f488da3d1 --- /dev/null +++ b/pylib/Lib/math_impl/ldexp.html @@ -0,0 +1,135 @@ + + + + + + + +src/pylib/Lib/math_impl/ldexp + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/math_impl/ldexp

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

c_ldexp

+ +
+

Procs

+
+
+
+
func c_ldexp[F: SomeFloat](x: F; exp: cint): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func n_ldexp[F: SomeFloat](x: F; i: int): F
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/Lib/math_impl/ldexp.idx b/pylib/Lib/math_impl/ldexp.idx new file mode 100644 index 000000000..8ac27d360 --- /dev/null +++ b/pylib/Lib/math_impl/ldexp.idx @@ -0,0 +1,3 @@ +nimTitle ldexp pylib/Lib/math_impl/ldexp.html module src/pylib/Lib/math_impl/ldexp 0 +nim n_ldexp pylib/Lib/math_impl/ldexp.html#n_ldexp,F,int proc n_ldexp[F: SomeFloat](x: F; i: int): F 14 +nim c_ldexp pylib/Lib/math_impl/ldexp.html#c_ldexp,F,cint proc c_ldexp[F: SomeFloat](x: F; exp: cint): F 37 diff --git a/pylib/Lib/math_impl/nextafter_step.html b/pylib/Lib/math_impl/nextafter_step.html new file mode 100644 index 000000000..6a1e7ce07 --- /dev/null +++ b/pylib/Lib/math_impl/nextafter_step.html @@ -0,0 +1,131 @@ + + + + + + + +src/pylib/Lib/math_impl/nextafter_step + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/math_impl/nextafter_step

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
func nextafter(x, y: float; steps: int): float {....raises: [ValueError], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func nextafter(x, y: float; usteps: uint64): float {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/Lib/math_impl/nextafter_step.idx b/pylib/Lib/math_impl/nextafter_step.idx new file mode 100644 index 000000000..87fb5c207 --- /dev/null +++ b/pylib/Lib/math_impl/nextafter_step.idx @@ -0,0 +1,4 @@ +nimTitle nextafter_step pylib/Lib/math_impl/nextafter_step.html module src/pylib/Lib/math_impl/nextafter_step 0 +nim nextafter pylib/Lib/math_impl/nextafter_step.html#nextafter,float,float,uint64 proc nextafter(x, y: float; usteps: uint64): float 90 +nim nextafter pylib/Lib/math_impl/nextafter_step.html#nextafter,float,float,int proc nextafter(x, y: float; steps: int): float 111 +nimgrp nextafter pylib/Lib/math_impl/nextafter_step.html#nextafter-procs-all proc 90 diff --git a/pylib/Lib/math_impl/nextafter_ulp.html b/pylib/Lib/math_impl/nextafter_ulp.html new file mode 100644 index 000000000..9093eb1a8 --- /dev/null +++ b/pylib/Lib/math_impl/nextafter_ulp.html @@ -0,0 +1,146 @@ + + + + + + + +src/pylib/Lib/math_impl/nextafter_ulp + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/math_impl/nextafter_ulp

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
func nextafter[F: SomeFloat](x, y: F): F
+
+ + + Source   +Edit   + +
+
+
+
func nextafter[F: SomeFloat](x, y: F; steps: int | uint64): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func ulp[F: SomeFloat](x: F): F
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/Lib/math_impl/nextafter_ulp.idx b/pylib/Lib/math_impl/nextafter_ulp.idx new file mode 100644 index 000000000..fc55940f2 --- /dev/null +++ b/pylib/Lib/math_impl/nextafter_ulp.idx @@ -0,0 +1,5 @@ +nimTitle nextafter_ulp pylib/Lib/math_impl/nextafter_ulp.html module src/pylib/Lib/math_impl/nextafter_ulp 0 +nim nextafter pylib/Lib/math_impl/nextafter_ulp.html#nextafter,F,F proc nextafter[F: SomeFloat](x, y: F): F 14 +nim nextafter pylib/Lib/math_impl/nextafter_ulp.html#nextafter,F,F, proc nextafter[F: SomeFloat](x, y: F; steps: int | uint64): F 20 +nim ulp pylib/Lib/math_impl/nextafter_ulp.html#ulp,F proc ulp[F: SomeFloat](x: F): F 23 +nimgrp nextafter pylib/Lib/math_impl/nextafter_ulp.html#nextafter-procs-all proc 14 diff --git a/pylib/Lib/math_impl/patch/consts.html b/pylib/Lib/math_impl/patch/consts.html new file mode 100644 index 000000000..3972a2ad3 --- /dev/null +++ b/pylib/Lib/math_impl/patch/consts.html @@ -0,0 +1,176 @@ + + + + + + + +src/pylib/Lib/math_impl/patch/consts + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/math_impl/patch/consts

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

253 - 1 224 - 1

+ +
+

Consts

+
+
+
EULER = 0.5772156649015329
+
+ + euler_gamma + Source   +Edit   + +
+
+
+
Ninf = 0xFFF0000000000000'f64
+
+ + + Source   +Edit   + +
+
+
+
Pinf = 0x7FF0000000000000'f64
+
+ + + Source   +Edit   + +
+
+
+
SQRT_TWO_PI = 2.5066282746310007
+
+ + sqrt(2*PI) <-> sqrt(TAU) + Source   +Edit   + +
+
+ +
+
+
+

Templates

+
+
+
+
template maxSafeInteger[F](_: typedesc[F]): F
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/Lib/math_impl/patch/consts.idx b/pylib/Lib/math_impl/patch/consts.idx new file mode 100644 index 000000000..5f0c9de5a --- /dev/null +++ b/pylib/Lib/math_impl/patch/consts.idx @@ -0,0 +1,6 @@ +nimTitle consts pylib/Lib/math_impl/patch/consts.html module src/pylib/Lib/math_impl/patch/consts 0 +nim Pinf pylib/Lib/math_impl/patch/consts.html#Pinf const Pinf 5 +nim Ninf pylib/Lib/math_impl/patch/consts.html#Ninf const Ninf 6 +nim EULER pylib/Lib/math_impl/patch/consts.html#EULER const EULER 8 +nim SQRT_TWO_PI pylib/Lib/math_impl/patch/consts.html#SQRT_TWO_PI const SQRT_TWO_PI 10 +nim maxSafeInteger pylib/Lib/math_impl/patch/consts.html#maxSafeInteger.t,typedesc[F] template maxSafeInteger[F](_: typedesc[F]): F 13 diff --git a/pylib/Lib/math_impl/patch/fma.html b/pylib/Lib/math_impl/patch/fma.html new file mode 100644 index 000000000..22bbb59b7 --- /dev/null +++ b/pylib/Lib/math_impl/patch/fma.html @@ -0,0 +1,186 @@ + + + + + + + +src/pylib/Lib/math_impl/patch/fma + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/math_impl/patch/fma

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

c_fma means compatible fma, using <math.h> fma when for C

+ +
+

Consts

+
+
+
UNRELIABLE_FMA = true
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
proc c_fma(x, y, z: cdouble): cdouble {.importc: "fma", header: "<math.h>",
+                                        ...raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc c_fma(x, y, z: cfloat): cfloat {.importc: "fmaf", header: "<math.h>",
+                                      ...raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func fma[F: SomeFloat](x, y, z: F): F {....raises: [].}
+
+ +
Warning: +this fma does not touch errno and exception is discarded
+ + Source   +Edit   + +
+
+
+
func fma[F: SomeFloat](x, y, z: F; exc: var ref Exception): F {....raises: [].}
+
+ + EXT. + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/Lib/math_impl/patch/fma.idx b/pylib/Lib/math_impl/patch/fma.idx new file mode 100644 index 000000000..2e9a33f3c --- /dev/null +++ b/pylib/Lib/math_impl/patch/fma.idx @@ -0,0 +1,8 @@ +nimTitle fma pylib/Lib/math_impl/patch/fma.html module src/pylib/Lib/math_impl/patch/fma 0 +nim UNRELIABLE_FMA pylib/Lib/math_impl/patch/fma.html#UNRELIABLE_FMA const UNRELIABLE_FMA 8 +nim c_fma pylib/Lib/math_impl/patch/fma.html#c_fma,cdouble,cdouble,cdouble proc c_fma(x, y, z: cdouble): cdouble 10 +nim c_fma pylib/Lib/math_impl/patch/fma.html#c_fma,cfloat,cfloat,cfloat proc c_fma(x, y, z: cfloat): cfloat 11 +nim fma pylib/Lib/math_impl/patch/fma.html#fma,F,F,F,ref.Exception proc fma[F: SomeFloat](x, y, z: F; exc: var ref Exception): F 21 +nim fma pylib/Lib/math_impl/patch/fma.html#fma,F,F,F proc fma[F: SomeFloat](x, y, z: F): F 41 +nimgrp fma pylib/Lib/math_impl/patch/fma.html#fma-procs-all proc 21 +nimgrp cfma pylib/Lib/math_impl/patch/fma.html#c_fma-procs-all proc 10 diff --git a/pylib/Lib/math_impl/patch/gamma.html b/pylib/Lib/math_impl/patch/gamma.html new file mode 100644 index 000000000..97b869c68 --- /dev/null +++ b/pylib/Lib/math_impl/patch/gamma.html @@ -0,0 +1,233 @@ + + + + + + + +src/pylib/Lib/math_impl/patch/gamma + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/math_impl/patch/gamma

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

Stirling's formula for the gamma function gamma(x) = sqrt(2 pi) x^(x-.5) exp(-x) ( 1 + 1/x P(1/x) )

+

For float32: .028 < 1/x < .1 relative error < 1.9e-11

+

+ +
+

Procs

+
+
+
+
func gamma[F: SomeFloat](x: F): F
+
+ + CPython math.gamma-like, with error message more detailed. +

Example:

+
template chkValueErr(arg) =
+  doAssertRaises ValueError: discard gamma arg
+chkValueErr NegInf
+chkValueErr 0.0
+# Currently +-0.0 result is not consistent with CPython;
+# assert NegInf == 1.0/gamma(-180.5)
+ Source   +Edit   + +
+
+
+
func gamma[T: SomeFloat](x: T; res: var T): GammaError
+
+ + a more error friendly version of gamma + Source   +Edit   + +
+
+ +
+
+
+
func rGamma[F: SomeFloat](x: F): F {....raises: [].}
+
+ + behaviors like R's gamma except for this without any warning. +

Example:

+
from std/math import isNaN
+assert isNaN rgamma NegInf
+assert Inf == 1/rgamma(-180.5)  # never returns -0.0
+ Source   +Edit   + +
+
+ +
+
+
+
func stdlibJsGamma[F: SomeFloat](x: F): F {....raises: [].}
+
+ + behaviors like @stdlib-js/gamma.js + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template MAX_STIRLING[F](_: typedesc[F]): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template UseSmallApprox[F](_: typedesc[F]): F
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Exports

+
+ GammaError +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/Lib/math_impl/patch/gamma.idx b/pylib/Lib/math_impl/patch/gamma.idx new file mode 100644 index 000000000..7c2d8e33e --- /dev/null +++ b/pylib/Lib/math_impl/patch/gamma.idx @@ -0,0 +1,8 @@ +nimTitle gamma pylib/Lib/math_impl/patch/gamma.html module src/pylib/Lib/math_impl/patch/gamma 0 +nim UseSmallApprox pylib/Lib/math_impl/patch/gamma.html#UseSmallApprox.t,typedesc[F] template UseSmallApprox[F](_: typedesc[F]): F 29 +nim MAX_STIRLING pylib/Lib/math_impl/patch/gamma.html#MAX_STIRLING.t,typedesc[F] template MAX_STIRLING[F](_: typedesc[F]): F 34 +nim gamma pylib/Lib/math_impl/patch/gamma.html#gamma,T,T proc gamma[T: SomeFloat](x: T; res: var T): GammaError 214 +nim gamma pylib/Lib/math_impl/patch/gamma.html#gamma,F proc gamma[F: SomeFloat](x: F): F 218 +nim rGamma pylib/Lib/math_impl/patch/gamma.html#rGamma,F proc rGamma[F: SomeFloat](x: F): F 229 +nim stdlibJsGamma pylib/Lib/math_impl/patch/gamma.html#stdlibJsGamma,F proc stdlibJsGamma[F: SomeFloat](x: F): F 242 +nimgrp gamma pylib/Lib/math_impl/patch/gamma.html#gamma-procs-all proc 214 diff --git a/pylib/Lib/math_impl/patch/inWordUtilsMapper.html b/pylib/Lib/math_impl/patch/inWordUtilsMapper.html new file mode 100644 index 000000000..6c19bab82 --- /dev/null +++ b/pylib/Lib/math_impl/patch/inWordUtilsMapper.html @@ -0,0 +1,109 @@ + + + + + + + +src/pylib/Lib/math_impl/patch/inWordUtilsMapper + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/math_impl/patch/inWordUtilsMapper

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Macros

+
+
+
+
macro wu_import(moduleOrfromExpr)
+
+ + words utils import + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/Lib/math_impl/patch/inWordUtilsMapper.idx b/pylib/Lib/math_impl/patch/inWordUtilsMapper.idx new file mode 100644 index 000000000..ed4ba0ab2 --- /dev/null +++ b/pylib/Lib/math_impl/patch/inWordUtilsMapper.idx @@ -0,0 +1,2 @@ +nimTitle inWordUtilsMapper pylib/Lib/math_impl/patch/inWordUtilsMapper.html module src/pylib/Lib/math_impl/patch/inWordUtilsMapper 0 +nim wu_import pylib/Lib/math_impl/patch/inWordUtilsMapper.html#wu_import.m macro wu_import(moduleOrfromExpr) 30 diff --git a/pylib/Lib/math_impl/patch/ldexp_frexp/assertIsInfinite.html b/pylib/Lib/math_impl/patch/ldexp_frexp/assertIsInfinite.html new file mode 100644 index 000000000..1b34f2fcd --- /dev/null +++ b/pylib/Lib/math_impl/patch/ldexp_frexp/assertIsInfinite.html @@ -0,0 +1,118 @@ + + + + + + + +src/pylib/Lib/math_impl/patch/ldexp_frexp/assertIsInfinite + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/math_impl/patch/ldexp_frexp/assertIsInfinite

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Imports

+
+ ../../isX +
+
+
+

Templates

+
+
+
+
template isInfinite(f: SomeFloat): bool
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/Lib/math_impl/patch/ldexp_frexp/assertIsInfinite.idx b/pylib/Lib/math_impl/patch/ldexp_frexp/assertIsInfinite.idx new file mode 100644 index 000000000..5fbc67928 --- /dev/null +++ b/pylib/Lib/math_impl/patch/ldexp_frexp/assertIsInfinite.idx @@ -0,0 +1,2 @@ +nimTitle assertIsInfinite pylib/Lib/math_impl/patch/ldexp_frexp/assertIsInfinite.html module src/pylib/Lib/math_impl/patch/ldexp_frexp/assertIsInfinite 0 +nim isInfinite pylib/Lib/math_impl/patch/ldexp_frexp/assertIsInfinite.html#isInfinite.t,SomeFloat template isInfinite(f: SomeFloat): bool 4 diff --git a/pylib/Lib/math_impl/patch/ldexp_frexp/exponent.html b/pylib/Lib/math_impl/patch/ldexp_frexp/exponent.html new file mode 100644 index 000000000..03c15dd58 --- /dev/null +++ b/pylib/Lib/math_impl/patch/ldexp_frexp/exponent.html @@ -0,0 +1,118 @@ + + + + + + + +src/pylib/Lib/math_impl/patch/ldexp_frexp/exponent + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/math_impl/patch/ldexp_frexp/exponent

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
func exponent[F: SomeFloat](x: F): BiggestInt
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/Lib/math_impl/patch/ldexp_frexp/exponent.idx b/pylib/Lib/math_impl/patch/ldexp_frexp/exponent.idx new file mode 100644 index 000000000..168a07f43 --- /dev/null +++ b/pylib/Lib/math_impl/patch/ldexp_frexp/exponent.idx @@ -0,0 +1,2 @@ +nimTitle exponent pylib/Lib/math_impl/patch/ldexp_frexp/exponent.html module src/pylib/Lib/math_impl/patch/ldexp_frexp/exponent 0 +nim exponent pylib/Lib/math_impl/patch/ldexp_frexp/exponent.html#exponent,F proc exponent[F: SomeFloat](x: F): BiggestInt 32 diff --git a/pylib/Lib/math_impl/patch/ldexp_frexp/frexp.html b/pylib/Lib/math_impl/patch/ldexp_frexp/frexp.html new file mode 100644 index 000000000..aa589f14b --- /dev/null +++ b/pylib/Lib/math_impl/patch/ldexp_frexp/frexp.html @@ -0,0 +1,118 @@ + + + + + + + +src/pylib/Lib/math_impl/patch/ldexp_frexp/frexp + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/math_impl/patch/ldexp_frexp/frexp

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
func frexp[F: SomeFloat](x: F): (F, int)
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/Lib/math_impl/patch/ldexp_frexp/frexp.idx b/pylib/Lib/math_impl/patch/ldexp_frexp/frexp.idx new file mode 100644 index 000000000..7167e6672 --- /dev/null +++ b/pylib/Lib/math_impl/patch/ldexp_frexp/frexp.idx @@ -0,0 +1,2 @@ +nimTitle frexp pylib/Lib/math_impl/patch/ldexp_frexp/frexp.html module src/pylib/Lib/math_impl/patch/ldexp_frexp/frexp 0 +nim frexp pylib/Lib/math_impl/patch/ldexp_frexp/frexp.html#frexp,F proc frexp[F: SomeFloat](x: F): (F, int) 12 diff --git a/pylib/Lib/math_impl/patch/ldexp_frexp/ldexp.html b/pylib/Lib/math_impl/patch/ldexp_frexp/ldexp.html new file mode 100644 index 000000000..fa1cb66cb --- /dev/null +++ b/pylib/Lib/math_impl/patch/ldexp_frexp/ldexp.html @@ -0,0 +1,118 @@ + + + + + + + +src/pylib/Lib/math_impl/patch/ldexp_frexp/ldexp + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/math_impl/patch/ldexp_frexp/ldexp

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
func ldexp[F: SomeFloat](frac: F; exp: int): F
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/Lib/math_impl/patch/ldexp_frexp/ldexp.idx b/pylib/Lib/math_impl/patch/ldexp_frexp/ldexp.idx new file mode 100644 index 000000000..e09563a37 --- /dev/null +++ b/pylib/Lib/math_impl/patch/ldexp_frexp/ldexp.idx @@ -0,0 +1,2 @@ +nimTitle ldexp pylib/Lib/math_impl/patch/ldexp_frexp/ldexp.html module src/pylib/Lib/math_impl/patch/ldexp_frexp/ldexp 0 +nim ldexp pylib/Lib/math_impl/patch/ldexp_frexp/ldexp.html#ldexp,F,int proc ldexp[F: SomeFloat](frac: F; exp: int): F 18 diff --git a/pylib/Lib/math_impl/patch/ldexp_frexp/normalize.html b/pylib/Lib/math_impl/patch/ldexp_frexp/normalize.html new file mode 100644 index 000000000..067249046 --- /dev/null +++ b/pylib/Lib/math_impl/patch/ldexp_frexp/normalize.html @@ -0,0 +1,118 @@ + + + + + + + +src/pylib/Lib/math_impl/patch/ldexp_frexp/normalize + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/math_impl/patch/ldexp_frexp/normalize

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
proc normalize[F: SomeFloat](x: F): (F, int) {.noInit.}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/Lib/math_impl/patch/ldexp_frexp/normalize.idx b/pylib/Lib/math_impl/patch/ldexp_frexp/normalize.idx new file mode 100644 index 000000000..ded341ac5 --- /dev/null +++ b/pylib/Lib/math_impl/patch/ldexp_frexp/normalize.idx @@ -0,0 +1,2 @@ +nimTitle normalize pylib/Lib/math_impl/patch/ldexp_frexp/normalize.html module src/pylib/Lib/math_impl/patch/ldexp_frexp/normalize 0 +nim normalize pylib/Lib/math_impl/patch/ldexp_frexp/normalize.html#normalize,F proc normalize[F: SomeFloat](x: F): (F, int) 12 diff --git a/pylib/Lib/math_impl/patch/lgamma.html b/pylib/Lib/math_impl/patch/lgamma.html new file mode 100644 index 000000000..d9f627766 --- /dev/null +++ b/pylib/Lib/math_impl/patch/lgamma.html @@ -0,0 +1,285 @@ + + + + + + + +src/pylib/Lib/math_impl/patch/lgamma + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/math_impl/patch/lgamma

+
+ +
+ Source   +Edit   + +
+ +

+

Notice

This module was hand-translated from FreeBSD's lgamma implementation;

+

and with some modification:

+
  • no static data is used, so each function is thread-safe.
  • +
+

The following copyright, license, and long comment were part of the original implementation available as part of FreeBSD

+

Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
+
+Developed at SunPro, a Sun Microsystems, Inc. business.
+Permission to use, copy, modify, and distribute this
+software is freely granted, provided that this notice
+is preserved.

+

+ +
+

Procs

+
+
+
+
func lgamma[F: SomeFloat](x: F): F
+
+ +

Evaluates the natural logarithm of the absolute value of gamma function.

+

The following was formatted as Nim-Favor Markdown from FreeBSD `lgamma` source with some minor amendment.

+ +

Method:

+

1. Argument Reduction for 0 < x <= 8

Since gamma(1+s)=s*gamma(s), for x in [0,8], we may
+reduce x to a number in [1.5,2.5] by
+        lgamma(1+s) = log(s) + lgamma(s)
+for example,
+        lgamma(7.3) = log(6.3) + lgamma(6.3)
+                    = log(6.3*5.3) + lgamma(5.3)
+                    = log(6.3*5.3*4.3*3.3*2.3) + lgamma(2.3)

+ +

2. A polynomial approximation of lgamma

Create a polynomial approximation of lgamma around its minimun ymin=1.461632144968362245 to maintain monotonicity.

+

On [ymin-0.23, ymin+0.27] (i.e., [1.23164,1.73163]), use
+        Let z = x-ymin;
+        lgamma(x) = -1.214862905358496078218 + z^2*poly(z)
+where
+        poly(z) is a 14 degree polynomial.

+ +

3. Rational approximation in the primary interval [2,3]

We use the following approximation:
+        s = x-2.0;
+        lgamma(x) = 0.5*s + s*P(s)/Q(s)
+with accuracy
+        |P/Q - (lgamma(x)-0.5s)| < 2**-61.71
+Our algorithms are based on the following observation
+                            
+                            zeta(2)-1    2    zeta(3)-1    3
+lgamma(2+s) = s*(1-Euler) + --------- * s  -  --------- * s  + ...
+                                2                 3

+

where Euler = 0.5771... is the Euler constant, which is very close to 0.5.

+ +

4. For x>=8, ...

For x>=8, we have
+  lgamma(x) ~ (x-0.5)log(x)-x+0.5*log(2pi)+1/(12x)-1/(360x**3)+....
+
+(better formula:
+   lgamma(x) ~ (x-0.5)*(log(x)-1)-.5*(log(2pi)-1) + ...)
+
+Let z = 1/x, then we approximation
+        f(z) = lgamma(x) - (x-0.5)(log(x)-1)
+by
+                            3       5             11
+        w = w0 + w1*z + w2*z  + w3*z  + ... + w6*z
+where
+        |w - f(z)| < 2**-58.74

+ +

5. For negative x, ...

For negative x, since (G is gamma function)
+        -x*G(-x)*G(x) = pi/sin(pi*x),
+we have
+        G(x) = pi/(sin(pi*x)*(-x)*G(-x))
+since G(-x) is positive, sign(G(x)) = sign(sin(pi*x)) for x<0
+Hence, for x<0, signgam = sign(sin(pi*x)) and
+        lgamma(x) = log(|Gamma(x)|)
+                  = log(pi/(|x*sin(pi*x)|)) - lgamma(-x);

+
Note: +one should avoid computing pi*(-x) directly in the computation of sin(pi*(-x)) but using sinpi(-x)
+ +

Special Cases

        lgamma(2+s) ~ s*(1-Euler) for tiny s
+        lgamma(1) = lgamma(2) = 0
+        lgamma(x) ~ -log(|x|) for tiny x
+        lgamma(0) = lgamma(neg.integer) = inf and raise divide-by-zero
+        lgamma(inf) = inf
+        lgamma(-inf) = inf  # see below
For lgamma(-inf),

+
  • some implementations, like CPython's math, R
  • +
+

and C/C++ returns +inf; which is not suitable, as gamma(x) where x < about -200 is always truncated to 0.0 at ieee754 float domain. This behavior was said for bug compatible with C99, and is readlly documented by POSIX man and cppreference.com

+
  • While others like scipy.special.gammaln, Go's math.Lgamma, returns
  • +
+

In my option, ln(|gamma(-oo)|) -[ieee754 float trunc]-> ln(0+) -> -inf

+

But in this function it returns +inf to keep consistent with Python,

+ +

Example:

+
from std/math import isNaN
+assert lgamma(1.0) == 0.0
+assert lgamma(Inf) == Inf
+assert lgamma(NaN).isNaN
+ Source   +Edit   + +
+
+
+
func lgamma[F: SomeFloat](x: F; res: var F): GammaError
+
+ + currently do not return geOverFlow, geUnderFlow + Source   +Edit   + +
+
+ +
+
+
+
func rLgamma[F: SomeFloat](x: F): F {....raises: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func scipyGammaLn[F: SomeFloat](x: F): F {....raises: [].}
+
+ +
Note: +this returns -inf for -inf argument, and raises no math error, just like scipy.special.gammaln
+ + Source   +Edit   + +
+
+ +
+
+
+
func stdlibJsLgamma[F: SomeFloat](x: F): F {....raises: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Exports

+
+ GammaError +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/Lib/math_impl/patch/lgamma.idx b/pylib/Lib/math_impl/patch/lgamma.idx new file mode 100644 index 000000000..cbdc5a34d --- /dev/null +++ b/pylib/Lib/math_impl/patch/lgamma.idx @@ -0,0 +1,15 @@ +nimTitle lgamma pylib/Lib/math_impl/patch/lgamma.html module src/pylib/Lib/math_impl/patch/lgamma 0 +nim lgamma pylib/Lib/math_impl/patch/lgamma.html#lgamma,F,F proc lgamma[F: SomeFloat](x: F; res: var F): GammaError 150 +nim lgamma pylib/Lib/math_impl/patch/lgamma.html#lgamma,F proc lgamma[F: SomeFloat](x: F): F 278 +nim stdlibJsLgamma pylib/Lib/math_impl/patch/lgamma.html#stdlibJsLgamma,F proc stdlibJsLgamma[F: SomeFloat](x: F): F 395 +nim rLgamma pylib/Lib/math_impl/patch/lgamma.html#rLgamma,F proc rLgamma[F: SomeFloat](x: F): F 398 +nim scipyGammaLn pylib/Lib/math_impl/patch/lgamma.html#scipyGammaLn,F proc scipyGammaLn[F: SomeFloat](x: F): F 400 +nimgrp lgamma pylib/Lib/math_impl/patch/lgamma.html#lgamma-procs-all proc 150 +heading Method: pylib/Lib/math_impl/patch/lgamma.html#methodcolon Method: 0 +heading 1. Argument Reduction for 0 < x <= 8 pylib/Lib/math_impl/patch/lgamma.html#methodcolon-Z1dot-argument-reduction-for-0-lt-x-lteq-8 1. Argument Reduction for 0 < x <= 8 0 +heading 2. A polynomial approximation of lgamma pylib/Lib/math_impl/patch/lgamma.html#methodcolon-Z2dot-a-polynomial-approximation-of-lgamma 2. A polynomial approximation of lgamma 0 +heading 3. Rational approximation in the primary interval nim[2,3] pylib/Lib/math_impl/patch/lgamma.html#methodcolon-Z3dot-rational-approximation-in-the-primary-interval-nim-2-3 3. Rational approximation in the primary interval [2,3] 0 +heading 4. For x>=8, ... pylib/Lib/math_impl/patch/lgamma.html#methodcolon-Z4dot-for-xgteq8-dotdotdot 4. For x>=8, ... 0 +heading 5. For negative x, ... pylib/Lib/math_impl/patch/lgamma.html#methodcolon-Z5dot-for-negative-x-dotdotdot 5. For negative x, ... 0 +heading Special Cases pylib/Lib/math_impl/patch/lgamma.html#special-cases Special Cases 0 +heading Notice pylib/Lib/math_impl/patch/lgamma.html#notice Notice 0 diff --git a/pylib/Lib/math_impl/patch/nextafter.html b/pylib/Lib/math_impl/patch/nextafter.html new file mode 100644 index 000000000..affb9b808 --- /dev/null +++ b/pylib/Lib/math_impl/patch/nextafter.html @@ -0,0 +1,121 @@ + + + + + + + +src/pylib/Lib/math_impl/patch/nextafter + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/math_impl/patch/nextafter

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

translated from https://github.com/scijs/nextafter/blob/master/nextafter.js

+

And add respect to the sign of zero, e.g.

+

nextafter(-0.0, 0.0) == 0.0 nextafter(0.0, -0.0) == -0.0

+

+ +
+

Procs

+
+
+
+
func nextafter[F](x, y: F): F
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/Lib/math_impl/patch/nextafter.idx b/pylib/Lib/math_impl/patch/nextafter.idx new file mode 100644 index 000000000..cf2c4c468 --- /dev/null +++ b/pylib/Lib/math_impl/patch/nextafter.idx @@ -0,0 +1,2 @@ +nimTitle nextafter pylib/Lib/math_impl/patch/nextafter.html module src/pylib/Lib/math_impl/patch/nextafter 0 +nim nextafter pylib/Lib/math_impl/patch/nextafter.html#nextafter,F,F proc nextafter[F](x, y: F): F 53 diff --git a/pylib/Lib/math_impl/patch/nextafter_step.html b/pylib/Lib/math_impl/patch/nextafter_step.html new file mode 100644 index 000000000..bf6f28d34 --- /dev/null +++ b/pylib/Lib/math_impl/patch/nextafter_step.html @@ -0,0 +1,119 @@ + + + + + + + +src/pylib/Lib/math_impl/patch/nextafter_step + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/math_impl/patch/nextafter_step

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

XXX: TODO: current Implementation is slow

+
+

Imports

+
+ nextafter +
+
+
+

Procs

+
+
+
+
proc nextafter(x, y: float; usteps: uint64): float {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/Lib/math_impl/patch/nextafter_step.idx b/pylib/Lib/math_impl/patch/nextafter_step.idx new file mode 100644 index 000000000..05c2dc26a --- /dev/null +++ b/pylib/Lib/math_impl/patch/nextafter_step.idx @@ -0,0 +1,2 @@ +nimTitle nextafter_step pylib/Lib/math_impl/patch/nextafter_step.html module src/pylib/Lib/math_impl/patch/nextafter_step 0 +nim nextafter pylib/Lib/math_impl/patch/nextafter_step.html#nextafter,float,float,uint64 proc nextafter(x, y: float; usteps: uint64): float 5 diff --git a/pylib/Lib/math_impl/patch/sinpi.html b/pylib/Lib/math_impl/patch/sinpi.html new file mode 100644 index 000000000..e54142ebd --- /dev/null +++ b/pylib/Lib/math_impl/patch/sinpi.html @@ -0,0 +1,109 @@ + + + + + + + +src/pylib/Lib/math_impl/patch/sinpi + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/math_impl/patch/sinpi

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Procs

+
+
+
+
func sinpi[F: SomeFloat](x: F): F
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/Lib/math_impl/patch/sinpi.idx b/pylib/Lib/math_impl/patch/sinpi.idx new file mode 100644 index 000000000..406ea83f1 --- /dev/null +++ b/pylib/Lib/math_impl/patch/sinpi.idx @@ -0,0 +1,2 @@ +nimTitle sinpi pylib/Lib/math_impl/patch/sinpi.html module src/pylib/Lib/math_impl/patch/sinpi 0 +nim sinpi pylib/Lib/math_impl/patch/sinpi.html#sinpi,F proc sinpi[F: SomeFloat](x: F): F 4 diff --git a/pylib/Lib/math_impl/patch/trunc.html b/pylib/Lib/math_impl/patch/trunc.html new file mode 100644 index 000000000..d40a3a39c --- /dev/null +++ b/pylib/Lib/math_impl/patch/trunc.html @@ -0,0 +1,109 @@ + + + + + + + +src/pylib/Lib/math_impl/patch/trunc + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/math_impl/patch/trunc

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Procs

+
+
+
+
func uncheckedTruncToInt[I: SomeInteger](x: SomeFloat): I
+
+ + do not check for nans and infinities + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/Lib/math_impl/patch/trunc.idx b/pylib/Lib/math_impl/patch/trunc.idx new file mode 100644 index 000000000..6bc8388f3 --- /dev/null +++ b/pylib/Lib/math_impl/patch/trunc.idx @@ -0,0 +1,2 @@ +nimTitle trunc pylib/Lib/math_impl/patch/trunc.html module src/pylib/Lib/math_impl/patch/trunc 0 +nim uncheckedTruncToInt pylib/Lib/math_impl/patch/trunc.html#uncheckedTruncToInt,SomeFloat proc uncheckedTruncToInt[I: SomeInteger](x: SomeFloat): I 2 diff --git a/pylib/Lib/math_impl/platformUtils.html b/pylib/Lib/math_impl/platformUtils.html new file mode 100644 index 000000000..477fd38e7 --- /dev/null +++ b/pylib/Lib/math_impl/platformUtils.html @@ -0,0 +1,96 @@ + + + + + + + +src/pylib/Lib/math_impl/platformUtils + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/math_impl/platformUtils

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ + + +
+
+ + +
+
+ + + diff --git a/pylib/Lib/math_impl/platformUtils.idx b/pylib/Lib/math_impl/platformUtils.idx new file mode 100644 index 000000000..0a3831ab6 --- /dev/null +++ b/pylib/Lib/math_impl/platformUtils.idx @@ -0,0 +1 @@ +nimTitle platformUtils pylib/Lib/math_impl/platformUtils.html module src/pylib/Lib/math_impl/platformUtils 0 diff --git a/pylib/Lib/math_impl/polevl.html b/pylib/Lib/math_impl/polevl.html new file mode 100644 index 000000000..7d6d7fa14 --- /dev/null +++ b/pylib/Lib/math_impl/polevl.html @@ -0,0 +1,187 @@ + + + + + + + +src/pylib/Lib/math_impl/polevl + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/math_impl/polevl

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

The implementation uses Horner's rule for more efficient computation.

+
+

Procs

+
+
+
+
func p1evl[F](x: F; coef: openArray[F]; N = coef.high - 1): F
+
+ + Evaluate polynomial when coefficient of x is 1.0. Otherwise same as polevl. + Source   +Edit   + +
+
+ +
+
+
+
func polevl[F](x: F; coef: openArray[F]; N = coef.high): F
+
+ +
  Evaluates polynomial of degree N:
+                      
+                      2          N
+  y  =  C  + C x + C x  +...+ C x
+         0    1     2          N
+  
+  Coefficients are stored in reverse order:
+  
+  coef[0] = C  , ..., coef[N] = C  .
+              N                   0
+ Source   +Edit   + +
+
+ +
+ +
+
+
+

Macros

+
+
+
+
macro polExpd[F](x: F; coef: untyped): F
+
+ +

expand polynomial with coef literal as inline expression.

+

coef shall be literal of a serials of F surrounded by brackets, curly braces or paratheses

+ +

Example:

+
assert 1.0*3.0+2.0 == polExpd(1.0, (3.0, 2.0))
+ Source   +Edit   + +
+
+ +
+
+
+
macro polExpd0[F](x: F; rcoef: untyped): F
+
+ + the same as polExpd except that rcoef is reversed: rcoef[0] is the C_0 constant (a.k.a. muliplied by x^0) + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/Lib/math_impl/polevl.idx b/pylib/Lib/math_impl/polevl.idx new file mode 100644 index 000000000..ab629c430 --- /dev/null +++ b/pylib/Lib/math_impl/polevl.idx @@ -0,0 +1,5 @@ +nimTitle polevl pylib/Lib/math_impl/polevl.html module src/pylib/Lib/math_impl/polevl 0 +nim polevl pylib/Lib/math_impl/polevl.html#polevl,F,openArray[F] proc polevl[F](x: F; coef: openArray[F]; N = coef.high): F 7 +nim polExpd pylib/Lib/math_impl/polevl.html#polExpd.m,F,untyped macro polExpd[F](x: F; coef: untyped): F 27 +nim polExpd0 pylib/Lib/math_impl/polevl.html#polExpd0.m,F,untyped macro polExpd0[F](x: F; rcoef: untyped): F 45 +nim p1evl pylib/Lib/math_impl/polevl.html#p1evl,F,openArray[F],typeof(coef.high - 1) proc p1evl[F](x: F; coef: openArray[F]; N = coef.high - 1): F 58 diff --git a/pylib/Lib/math_impl/vec_op.html b/pylib/Lib/math_impl/vec_op.html new file mode 100644 index 000000000..94bcaeb27 --- /dev/null +++ b/pylib/Lib/math_impl/vec_op.html @@ -0,0 +1,96 @@ + + + + + + + +src/pylib/Lib/math_impl/vec_op + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/math_impl/vec_op

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+ +
+ + +
+
+ + + diff --git a/pylib/Lib/math_impl/vec_op.idx b/pylib/Lib/math_impl/vec_op.idx new file mode 100644 index 000000000..39340c5af --- /dev/null +++ b/pylib/Lib/math_impl/vec_op.idx @@ -0,0 +1 @@ +nimTitle vec_op pylib/Lib/math_impl/vec_op.html module src/pylib/Lib/math_impl/vec_op 0 diff --git a/pylib/Lib/math_impl/vec_op/dist.html b/pylib/Lib/math_impl/vec_op/dist.html new file mode 100644 index 000000000..cd96bb113 --- /dev/null +++ b/pylib/Lib/math_impl/vec_op/dist.html @@ -0,0 +1,140 @@ + + + + + + + +src/pylib/Lib/math_impl/vec_op/dist + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/math_impl/vec_op/dist

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
func dist[A, B, C](p, q: (A, B, C)): float {....raises: [].}
+
+ + + Source   +Edit   + +
+
+
+
func dist[A, B](p, q: (A, B)): float {....raises: [].}
+
+ + + Source   +Edit   + +
+
+
+
func dist[T; I: static[int]](p, q: array[I, T]): float {....raises: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/Lib/math_impl/vec_op/dist.idx b/pylib/Lib/math_impl/vec_op/dist.idx new file mode 100644 index 000000000..3434dba6b --- /dev/null +++ b/pylib/Lib/math_impl/vec_op/dist.idx @@ -0,0 +1,5 @@ +nimTitle dist pylib/Lib/math_impl/vec_op/dist.html module src/pylib/Lib/math_impl/vec_op/dist 0 +nim dist pylib/Lib/math_impl/vec_op/dist.html#dist,array[I,T],array[I,T] proc dist[T; I: static[int]](p, q: array[I, T]): float 221 +nim dist pylib/Lib/math_impl/vec_op/dist.html#dist,, proc dist[A, B](p, q: (A, B)): float 224 +nim dist pylib/Lib/math_impl/vec_op/dist.html#dist,,_2 proc dist[A, B, C](p, q: (A, B, C)): float 230 +nimgrp dist pylib/Lib/math_impl/vec_op/dist.html#dist-procs-all proc 221 diff --git a/pylib/Lib/math_impl/vec_op/niter_types.html b/pylib/Lib/math_impl/vec_op/niter_types.html new file mode 100644 index 000000000..58b6900ff --- /dev/null +++ b/pylib/Lib/math_impl/vec_op/niter_types.html @@ -0,0 +1,193 @@ + + + + + + + +src/pylib/Lib/math_impl/vec_op/niter_types + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/math_impl/vec_op/niter_types

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Types

+
+
+
ClosureIter[T] = iterator (): T
+
+ + + Source   +Edit   + +
+
+
+
OpenarrayOrNimIter[T] = openArray[T] or ClosureIter[T]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
func dist_checkedSameLen[T](p, q: T): int {.inline.}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template openarray_Check(x): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template toNimIterator[T](x): ClosureIter[T]
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/Lib/math_impl/vec_op/niter_types.idx b/pylib/Lib/math_impl/vec_op/niter_types.idx new file mode 100644 index 000000000..b1ca1cf77 --- /dev/null +++ b/pylib/Lib/math_impl/vec_op/niter_types.idx @@ -0,0 +1,6 @@ +nimTitle niter_types pylib/Lib/math_impl/vec_op/niter_types.html module src/pylib/Lib/math_impl/vec_op/niter_types 0 +nim ClosureIter pylib/Lib/math_impl/vec_op/niter_types.html#ClosureIter type ClosureIter 3 +nim OpenarrayOrNimIter pylib/Lib/math_impl/vec_op/niter_types.html#OpenarrayOrNimIter type OpenarrayOrNimIter 5 +nim toNimIterator pylib/Lib/math_impl/vec_op/niter_types.html#toNimIterator.t template toNimIterator[T](x): ClosureIter[T] 7 +nim openarray_Check pylib/Lib/math_impl/vec_op/niter_types.html#openarray_Check.t template openarray_Check(x): bool 15 +nim dist_checkedSameLen pylib/Lib/math_impl/vec_op/niter_types.html#dist_checkedSameLen,T,T proc dist_checkedSameLen[T](p, q: T): int 18 diff --git a/pylib/Lib/math_impl/vec_op/private/dl_ops.html b/pylib/Lib/math_impl/vec_op/private/dl_ops.html new file mode 100644 index 000000000..0d5c30c3c --- /dev/null +++ b/pylib/Lib/math_impl/vec_op/private/dl_ops.html @@ -0,0 +1,165 @@ + + + + + + + +src/pylib/Lib/math_impl/vec_op/private/dl_ops + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/math_impl/vec_op/private/dl_ops

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Types

+
+
+
DoubleLength = object
+  hi*: float
+  lo*: float
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
proc dl_mul(x: float; y: float): DoubleLength {....raises: [], tags: [],
+    forbids: [].}
+
+ + Dekker (5.12) and mul12() + Source   +Edit   + +
+
+ +
+
+
+
func dl_sum(a, b: float): DoubleLength {....raises: [], tags: [], forbids: [].}
+
+ + Algorithm 3.1 Error-free transformation of the sum + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/Lib/math_impl/vec_op/private/dl_ops.idx b/pylib/Lib/math_impl/vec_op/private/dl_ops.idx new file mode 100644 index 000000000..a5526dba9 --- /dev/null +++ b/pylib/Lib/math_impl/vec_op/private/dl_ops.idx @@ -0,0 +1,4 @@ +nimTitle dl_ops pylib/Lib/math_impl/vec_op/private/dl_ops.html module src/pylib/Lib/math_impl/vec_op/private/dl_ops 0 +nim DoubleLength pylib/Lib/math_impl/vec_op/private/dl_ops.html#DoubleLength object DoubleLength 5 +nim dl_mul pylib/Lib/math_impl/vec_op/private/dl_ops.html#dl_mul,float,float proc dl_mul(x: float; y: float): DoubleLength 39 +nim dl_sum pylib/Lib/math_impl/vec_op/private/dl_ops.html#dl_sum,float,float proc dl_sum(a, b: float): DoubleLength 51 diff --git a/pylib/Lib/math_impl/vec_op/sumprod.html b/pylib/Lib/math_impl/vec_op/sumprod.html new file mode 100644 index 000000000..a705c789e --- /dev/null +++ b/pylib/Lib/math_impl/vec_op/sumprod.html @@ -0,0 +1,129 @@ + + + + + + + +src/pylib/Lib/math_impl/vec_op/sumprod + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/math_impl/vec_op/sumprod

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
func sumprod[P, Q](p: openArray[P]; q: openArray[Q]): float
+
+ + a faster version for openarray than that for ClosureIter + Source   +Edit   + +
+
+
+
func sumprod[P, Q](p_it: ClosureIter[P]; q_it: ClosureIter[Q]): float
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/Lib/math_impl/vec_op/sumprod.idx b/pylib/Lib/math_impl/vec_op/sumprod.idx new file mode 100644 index 000000000..079580e5d --- /dev/null +++ b/pylib/Lib/math_impl/vec_op/sumprod.idx @@ -0,0 +1,4 @@ +nimTitle sumprod pylib/Lib/math_impl/vec_op/sumprod.html module src/pylib/Lib/math_impl/vec_op/sumprod 0 +nim sumprod pylib/Lib/math_impl/vec_op/sumprod.html#sumprod,ClosureIter[P],ClosureIter[Q] proc sumprod[P, Q](p_it: ClosureIter[P]; q_it: ClosureIter[Q]): float 136 +nim sumprod pylib/Lib/math_impl/vec_op/sumprod.html#sumprod,openArray[P],openArray[Q] proc sumprod[P, Q](p: openArray[P]; q: openArray[Q]): float 155 +nimgrp sumprod pylib/Lib/math_impl/vec_op/sumprod.html#sumprod-procs-all proc 136 diff --git a/pylib/Lib/n_errno.html b/pylib/Lib/n_errno.html new file mode 100644 index 000000000..06f89537a --- /dev/null +++ b/pylib/Lib/n_errno.html @@ -0,0 +1,96 @@ + + + + + + + +src/pylib/Lib/n_errno + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/n_errno

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ + + +
+
+ + +
+
+ + + diff --git a/pylib/Lib/n_errno.idx b/pylib/Lib/n_errno.idx new file mode 100644 index 000000000..15652ffb3 --- /dev/null +++ b/pylib/Lib/n_errno.idx @@ -0,0 +1 @@ +nimTitle n_errno pylib/Lib/n_errno.html module src/pylib/Lib/n_errno 0 diff --git a/pylib/Lib/n_math.html b/pylib/Lib/n_math.html new file mode 100644 index 000000000..29480dabe --- /dev/null +++ b/pylib/Lib/n_math.html @@ -0,0 +1,920 @@ + + + + + + + +src/pylib/Lib/n_math + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/n_math

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

Nim's Python-like math, but raises no catchable exception, using errno to report math error. a.k.a. non will be raised (but not for Defects)

+

which allows fast code.

+

For Python-like error handler (exception-based), see Lib/math

+

Also this is not just a module that wraps Nim's std/math,

+

but also providing some extensions that Nim's std/math lacks, for example:

+
  • JavaScript Backend and Compile-time (Nim VM) support for ldexp, frexp, cbrt, etc.
  • +
  • JavaScript Backend support for erf, erfc, gamma, lgamma
  • +
  • fsum, prod, etc.
  • +
+

And fix some non-C99 behavior on some systems, e.g. log(-ve) -> -Inf on Solaris

+

NOTE: Currently int is not acceptable when it comes to float about functions

+

+ +
+

Consts

+
+
+
e = 2.718281828459045
+
+ + + Source   +Edit   + +
+
+
+
inf = 0x7FF0000000000000'f64
+
+ + + Source   +Edit   + +
+
+
+
nan = 0x7FF7FFFFFFFFFFFF'f64
+
+ + + Source   +Edit   + +
+
+
+
pi = 3.141592653589793
+
+ + + Source   +Edit   + +
+
+
+
tau = 6.283185307179586
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
func acos[F: SomeFloat](x: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func acosh[F: SomeFloat](x: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func asin[F: SomeFloat](x: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func asinh[F: SomeFloat](x: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func atan[F: SomeFloat](x: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func atan2[F: SomeFloat](x: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func atanh[F: SomeFloat](x: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func ceil(x: SomeFloat): int
+
+ +
Hint: +unlike C/Nim's returning float, Python's returns int and raises errors for nans and infinities
+ + Source   +Edit   + +
+
+ +
+
+
+
func comb(n, k: int): int {....raises: [], tags: [], forbids: [].}
+
+ +
Hint: +Python's math.comb does not accept negative value for n, k but Nim's std/math.binom allows, so this function allows too. For consistent behavior with Python, see Lib/math.comb
+ + Source   +Edit   + +
+
+ +
+
+
+
func degrees[F: SomeFloat](x: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func fabs[F: SomeFloat](x: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func factorial(x: Natural): int {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func floor(x: SomeFloat): int
+
+ +
Hint: +unlike C/Nim's returning float, Python's returns int and raises errors for nans and infinities
+ + Source   +Edit   + +
+
+ +
+
+
+
func fmod[F: SomeFloat](x: F; y: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func fsum[T: SomeFloat](iterable: Iterable[T]): T
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func gamma[F: SomeFloat](x: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func gcd[I: SomeInteger](x, y, z: I; args: varargs[I]): I
+
+ + + Source   +Edit   + +
+
+
+
func gcd[I: SomeInteger](x, y: I): I
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func hypot[I: SomeFloat](x, y, z: I; args: varargs[I]): I
+
+ + + Source   +Edit   + +
+
+
+
func hypot[I: SomeFloat](x, y: I): I
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func isclose(a, b: SomeFloat; rel_tol = 1e-9; abs_tol = 0.0): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func isqrt(n: Natural): int {....raises: [], tags: [], forbids: [].}
+
+ + +

Example:

+
assert 2 == isqrt 5
+ Source   +Edit   + +
+
+
+
func isqrt[T: SomeFloat](x: T): int {....raises: [].}
+
+ +
Hint: +assuming x > 0 (raise RangeDefect otherwise (if not danger build))
+

use math.isqrt if expecting raising ValueError

+ + Source   +Edit   + +
+
+ +
+
+
+
func isqrtPositive(n: Positive): int {.inline, ...raises: [], tags: [], forbids: [].}
+
+ + EXT: isqrt for Positive only, as we all know, in Python:
  • isqrt(0) == 0
  • +
  • isqrt(-int)
  • +
+ + Source   +Edit   + +
+
+ +
+
+
+
func lcm[I: SomeInteger](x, y, z: I; args: varargs[I]): I
+
+ + + Source   +Edit   + +
+
+
+
func lcm[I: SomeInteger](x, y: I): I
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func ldexp[F: SomeFloat](x: F; i: int): F {....raises: [].}
+
+ +
Hint: +only set errno
+ + Source   +Edit   + +
+
+
+
func ldexp[F: SomeFloat](x: F; i: int; exc: var ref Exception): F {....raises: [].}
+
+ +

set exception to exc instead of raising it

+

exc:

+
  • set to nil if no error
  • +
  • set to suitable exc if some error occurs
  • +
+ + Source   +Edit   + +
+
+ +
+
+
+
func lgamma[F: SomeFloat](x: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func log[F: SomeFloat](x, base: F): F
+
+ + + Source   +Edit   + +
+
+
+
func log[F: SomeFloat](x: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func log2[F: SomeFloat](x: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func log10[F: SomeFloat](x: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func math_is_error(x: SomeFloat; exc: var ref Exception): bool
+
+ +

inner usage (used by Lib/math).

+

Call this when errno != 0, and where x is the result libm returned. This will usually set up an exception and return true, but may return false without setting up an exception.

+ + Source   +Edit   + +
+
+ +
+
+
+
func modf[F: SomeFloat](x: F): tuple[intpart: F, floatpart: F]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func perm(n, k: Natural): int {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func perm(n: int): int {....raises: [], tags: [], forbids: [].}
+
+ + equal to perm(n,n), returns n! + Source   +Edit   + +
+
+ +
+
+
+
func pow[F: SomeFloat](x, y: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func prod[T](iterable: Iterable[T]; start = 1.T): T
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func radians[F: SomeFloat](x: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func remainder[F: SomeFloat](x: F; y: F): F
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func trunc(x: SomeFloat): int
+
+ +
Hint: +unlike C/Nim's returning float, Python's returns int and raises errors for nans and infinities
+ + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template py_math_isclose_impl(abs)
+
+ +

inner use. Implementation of isclose.

+

mixin a, b, isinf, rel_tol, abs_tol

+ + Source   +Edit   + +
+
+ +
+ +
+
+ + +
+
+ + +
+
+ + + diff --git a/pylib/Lib/n_math.idx b/pylib/Lib/n_math.idx new file mode 100644 index 000000000..fe8481312 --- /dev/null +++ b/pylib/Lib/n_math.idx @@ -0,0 +1,56 @@ +nimTitle n_math pylib/Lib/n_math.html module src/pylib/Lib/n_math 0 +nim nan pylib/Lib/n_math.html#nan const nan 78 +nim inf pylib/Lib/n_math.html#inf const inf 78 +nim pi pylib/Lib/n_math.html#pi const pi 78 +nim tau pylib/Lib/n_math.html#tau const tau 78 +nim e pylib/Lib/n_math.html#e const e 78 +nim pow pylib/Lib/n_math.html#pow,F,F proc pow[F: SomeFloat](x, y: F): F 98 +nim fabs pylib/Lib/n_math.html#fabs,F proc fabs[F: SomeFloat](x: F): F 150 +nim ceil pylib/Lib/n_math.html#ceil,SomeFloat proc ceil(x: SomeFloat): int 167 +nim floor pylib/Lib/n_math.html#floor,SomeFloat proc floor(x: SomeFloat): int 168 +nim trunc pylib/Lib/n_math.html#trunc,SomeFloat proc trunc(x: SomeFloat): int 169 +nim py_math_isclose_impl pylib/Lib/n_math.html#py_math_isclose_impl.t template py_math_isclose_impl(abs) 171 +nim isclose pylib/Lib/n_math.html#isclose,SomeFloat,SomeFloat,float,float proc isclose(a, b: SomeFloat; rel_tol = 1e-9; abs_tol = 0.0): bool 187 +nim gcd pylib/Lib/n_math.html#gcd,I,I proc gcd[I: SomeInteger](x, y: I): I 191 +nim gcd pylib/Lib/n_math.html#gcd,I,I,I,varargs[I] proc gcd[I: SomeInteger](x, y, z: I; args: varargs[I]): I 198 +nim lcm pylib/Lib/n_math.html#lcm,I,I proc lcm[I: SomeInteger](x, y: I): I 191 +nim lcm pylib/Lib/n_math.html#lcm,I,I,I,varargs[I] proc lcm[I: SomeInteger](x, y, z: I; args: varargs[I]): I 199 +nim hypot pylib/Lib/n_math.html#hypot,I,I proc hypot[I: SomeFloat](x, y: I): I 191 +nim hypot pylib/Lib/n_math.html#hypot,I,I,I,varargs[I] proc hypot[I: SomeFloat](x, y, z: I; args: varargs[I]): I 201 +nim gamma pylib/Lib/n_math.html#gamma,F proc gamma[F: SomeFloat](x: F): F 214 +nim lgamma pylib/Lib/n_math.html#lgamma,F proc lgamma[F: SomeFloat](x: F): F 222 +nim math_is_error pylib/Lib/n_math.html#math_is_error,SomeFloat,ref.Exception proc math_is_error(x: SomeFloat; exc: var ref Exception): bool 240 +nim ldexp pylib/Lib/n_math.html#ldexp,F,int,ref.Exception proc ldexp[F: SomeFloat](x: F; i: int; exc: var ref Exception): F 282 +nim ldexp pylib/Lib/n_math.html#ldexp,F,int proc ldexp[F: SomeFloat](x: F; i: int): F 316 +nim modf pylib/Lib/n_math.html#modf,F proc modf[F: SomeFloat](x: F): tuple[intpart: F, floatpart: F] 321 +nim fmod pylib/Lib/n_math.html#fmod,F,F proc fmod[F: SomeFloat](x: F; y: F): F 330 +nim remainder pylib/Lib/n_math.html#remainder,F,F proc remainder[F: SomeFloat](x: F; y: F): F 343 +nim prod pylib/Lib/n_math.html#prod,Iterable[T] proc prod[T](iterable: Iterable[T]; start = 1.T): T 427 +nim fsum pylib/Lib/n_math.html#fsum,Iterable[T: SomeFloat] proc fsum[T: SomeFloat](iterable: Iterable[T]): T 435 +nim log pylib/Lib/n_math.html#log,F proc log[F: SomeFloat](x: F): F 569 +nim log pylib/Lib/n_math.html#log,F,F proc log[F: SomeFloat](x, base: F): F 570 +nim log2 pylib/Lib/n_math.html#log2,F proc log2[F: SomeFloat](x: F): F 577 +nim log10 pylib/Lib/n_math.html#log10,F proc log10[F: SomeFloat](x: F): F 578 +nim degrees pylib/Lib/n_math.html#degrees,F proc degrees[F: SomeFloat](x: F): F 581 +nim radians pylib/Lib/n_math.html#radians,F proc radians[F: SomeFloat](x: F): F 583 +nim asin pylib/Lib/n_math.html#asin,F proc asin[F: SomeFloat](x: F): F 593 +nim asinh pylib/Lib/n_math.html#asinh,F proc asinh[F: SomeFloat](x: F): F 594 +nim acos pylib/Lib/n_math.html#acos,F proc acos[F: SomeFloat](x: F): F 595 +nim acosh pylib/Lib/n_math.html#acosh,F proc acosh[F: SomeFloat](x: F): F 596 +nim atan pylib/Lib/n_math.html#atan,F proc atan[F: SomeFloat](x: F): F 597 +nim atan2 pylib/Lib/n_math.html#atan2,F proc atan2[F: SomeFloat](x: F): F 598 +nim atanh pylib/Lib/n_math.html#atanh,F proc atanh[F: SomeFloat](x: F): F 599 +nim comb pylib/Lib/n_math.html#comb,int,int proc comb(n, k: int): int 602 +nim perm pylib/Lib/n_math.html#perm,int proc perm(n: int): int 608 +nim perm pylib/Lib/n_math.html#perm,Natural,Natural proc perm(n, k: Natural): int 612 +nim factorial pylib/Lib/n_math.html#factorial,Natural proc factorial(x: Natural): int 619 +nim isqrtPositive pylib/Lib/n_math.html#isqrtPositive,Positive proc isqrtPositive(n: Positive): int 628 +nim isqrt pylib/Lib/n_math.html#isqrt,Natural proc isqrt(n: Natural): int 648 +nim isqrt pylib/Lib/n_math.html#isqrt,T proc isqrt[T: SomeFloat](x: T): int 678 +nimgrp isqrt pylib/Lib/n_math.html#isqrt-procs-all proc 648 +nimgrp hypot pylib/Lib/n_math.html#hypot-procs-all proc 201 +nimgrp perm pylib/Lib/n_math.html#perm-procs-all proc 608 +nimgrp log pylib/Lib/n_math.html#log-procs-all proc 569 +nimgrp ldexp pylib/Lib/n_math.html#ldexp-procs-all proc 282 +nimgrp lcm pylib/Lib/n_math.html#lcm-procs-all proc 199 +nimgrp gcd pylib/Lib/n_math.html#gcd-procs-all proc 198 diff --git a/pylib/Lib/n_sys.html b/pylib/Lib/n_sys.html new file mode 100644 index 000000000..6e288e16d --- /dev/null +++ b/pylib/Lib/n_sys.html @@ -0,0 +1,278 @@ + + + + + + + +src/pylib/Lib/n_sys + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/n_sys

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Vars

+
+
+
argv: seq[string]
+
+ + + Source   +Edit   + +
+
+
+
orig_argv = newSeqOfCap(argc)
+
+ + + .. hint:: rely on paramCount<https://nim-lang.org/docs/cmdline.html#paramCount>_ and paramStr<https://nim-lang.org/docs/cmdline.html#paramStr%2Cint>_. See their document for availability. + Source   +Edit   + +
+
+ +
+
+
+

Consts

+
+
+
byteorder = "little"
+
+ + + Source   +Edit   + +
+
+ +
+
hexversion = 51577072
+
+ + + Source   +Edit   + +
+
+
+
implementation = ("pynim", (0, 9, 11, "alpha", 0), 51577072,
+                  (val: "", has: false))
+
+ + + Source   +Edit   + +
+
+
+
maxsize = 9223372036854775807'i64
+
+ + + Source   +Edit   + +
+
+
+
platform = "linux"
+
+ +
Note: +the value is standalone for bare system
+

and haiku/netbsd appended with major version instead of "unknown". In short, this won't be "unknown" as Python does.

+ + Source   +Edit   + +
+
+
+
version = "3.13.0"
+
+ + + Source   +Edit   + +
+
+
+
version_info = (major: 3, minor: 13, patch: 0, releaselevel: "final", serial: 0)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Templates

+
+
+
+
template executable(): string
+
+ + returns:
  • when nimscript, path of Nim;
  • +
  • when JavaScript:
    • on browser: empty string
    • +
    • on NodeJS/Deno: executable path of Node/Deno
    • +
    +
  • +
  • otherwise, it's the path of current app/exe.
  • +
+ + Source   +Edit   + +
+
+ +
+ +
+
+ + +
+
+ + +
+
+ + + diff --git a/pylib/Lib/n_sys.idx b/pylib/Lib/n_sys.idx new file mode 100644 index 000000000..0bb99c0e9 --- /dev/null +++ b/pylib/Lib/n_sys.idx @@ -0,0 +1,12 @@ +nimTitle n_sys pylib/Lib/n_sys.html module src/pylib/Lib/n_sys 0 +nim platform pylib/Lib/n_sys.html#platform const platform 58 +nim version_info pylib/Lib/n_sys.html#version_info const version_info 33 +nim implementation pylib/Lib/n_sys.html#implementation const implementation 47 +nim version pylib/Lib/n_sys.html#version const version 53 +nim hexversion pylib/Lib/n_sys.html#hexversion const hexversion 54 +nim maxsize pylib/Lib/n_sys.html#maxsize const maxsize 56 +nim byteorder pylib/Lib/n_sys.html#byteorder const byteorder 57 +nim copyright pylib/Lib/n_sys.html#copyright const copyright 58 +nim orig_argv pylib/Lib/n_sys.html#orig_argv var orig_argv 34 +nim argv pylib/Lib/n_sys.html#argv var argv 39 +nim executable pylib/Lib/n_sys.html#executable.t template executable(): string 61 diff --git a/pylib/Lib/n_time.html b/pylib/Lib/n_time.html new file mode 100644 index 000000000..98c858394 --- /dev/null +++ b/pylib/Lib/n_time.html @@ -0,0 +1,296 @@ + + + + + + + +src/pylib/Lib/n_time + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/n_time

+
+ +
+ Source   +Edit   + +
+ +

+

time for Nim

the only difference with Python's is where some types in time is str, there is string in n_time's.

+

e.g. n_time.ctime() returns a string

+ +

py diff

Currently, tm_name is either "LOCAL" or "Etc/UTC", due to std/times only returning those two.

+
Warning: +A few of the format directives for strftime/strptime are not supported, and using them causes AssertDefect. They are listed in nstrfptime.NotImplDirectives
+
Hint: +Some directives (only for strftime) whose implementents are platform-depend in CPython are always supported here: '%V' '%G' '%g'
+

+ +
+

Consts

+
+
+
DefaultTimeFormat = "%a %b %d %H:%M:%S %Y"
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
proc asctime(): string {....raises: [], tags: [TimeEffect], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func asctime(t: struct_time): string {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func asctime(tup: struct_time_tuple): typeof(asctime do:
+  bind struct_time
+  struct_time(tm_year: 1900, tm_mon: 1, tm_mday: 1, tm_yday: 1, tm_isdst: -1)) {.
+    ...raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func asctime(tup: struct_time_tuple10): typeof(asctime do:
+  bind struct_time
+  struct_time(tm_year: 1900, tm_mon: 1, tm_mday: 1, tm_yday: 1, tm_isdst: -1)) {.
+    ...raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func asctime(tup: struct_time_tuple11): typeof(asctime do:
+  bind struct_time
+  struct_time(tm_year: 1900, tm_mon: 1, tm_mday: 1, tm_yday: 1, tm_isdst: -1)) {.
+    ...raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc ctime(): string {....raises: [], tags: [TimeEffect], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc ctime(secs: float | int64): string
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc strftime(format: string): string {....raises: [], tags: [TimeEffect],
+                                        forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc strptime(s: string): struct_time {....raises: [ValueError, TimeParseError,
+    TimeFormatParseError], tags: [TimeEffect], forbids: [].}
+
+ +
Warning: +In current implementation, whitespace in format string means itself AS-IS, unlike C or Python, where any whitespace means a serial of any whitespaces. If really wanting the behavior of C's, consider using std/strscan.
+
Warning: +Current strptime is just locale-unaware, when it comes to "the locale's format", like "%x", it always uses the format of "C" locale, no matter what the locale is. a.k.a. Changing locale via C's api in <locale.h> doesn't affect this function.
+ + Source   +Edit   + +
+
+ +
+ +
+
+ + +
+
+ + +
+
+ + + diff --git a/pylib/Lib/n_time.idx b/pylib/Lib/n_time.idx new file mode 100644 index 000000000..43fe27440 --- /dev/null +++ b/pylib/Lib/n_time.idx @@ -0,0 +1,15 @@ +nimTitle n_time pylib/Lib/n_time.html module src/pylib/Lib/n_time 0 +nim DefaultTimeFormat pylib/Lib/n_time.html#DefaultTimeFormat const DefaultTimeFormat 42 +nim asctime pylib/Lib/n_time.html#asctime proc asctime(): string 44 +nim asctime pylib/Lib/n_time.html#asctime,struct_time proc asctime(t: struct_time): string 45 +nim asctime pylib/Lib/n_time.html#asctime,struct_time_tuple proc asctime(tup: struct_time_tuple): typeof(asctime do:\n bind struct_time\n struct_time(tm_year: 1900, tm_mon: 1, tm_mday: 1, tm_yday: 1, tm_isdst: -1)) 18 +nim asctime pylib/Lib/n_time.html#asctime,struct_time_tuple10 proc asctime(tup: struct_time_tuple10): typeof(asctime do:\n bind struct_time\n struct_time(tm_year: 1900, tm_mon: 1, tm_mday: 1, tm_yday: 1, tm_isdst: -1)) 19 +nim asctime pylib/Lib/n_time.html#asctime,struct_time_tuple11 proc asctime(tup: struct_time_tuple11): typeof(asctime do:\n bind struct_time\n struct_time(tm_year: 1900, tm_mon: 1, tm_mday: 1, tm_yday: 1, tm_isdst: -1)) 53 +nim ctime pylib/Lib/n_time.html#ctime proc ctime(): string 55 +nim ctime pylib/Lib/n_time.html#ctime_2 proc ctime(secs: float | int64): string 57 +nim strftime pylib/Lib/n_time.html#strftime,string proc strftime(format: string): string 60 +nim strptime pylib/Lib/n_time.html#strptime,string proc strptime(s: string): struct_time 63 +nimgrp asctime pylib/Lib/n_time.html#asctime-procs-all proc 44 +nimgrp ctime pylib/Lib/n_time.html#ctime-procs-all proc 55 +heading time for Nim pylib/Lib/n_time.html#time-for-nim time for Nim 0 +heading py diff pylib/Lib/n_time.html#time-for-nim-py-diff py diff 0 diff --git a/pylib/Lib/n_timeit.html b/pylib/Lib/n_timeit.html new file mode 100644 index 000000000..6b041e4b0 --- /dev/null +++ b/pylib/Lib/n_timeit.html @@ -0,0 +1,384 @@ + + + + + + + +src/pylib/Lib/n_timeit + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/n_timeit

+
+ +
+ Source   +Edit   + +
+ +

n_timeit: timeit for Nim.

+

see Lib/timeit for python compatiable APIs

+

+
+

Types

+
+
+
NullaryFunc = concept self
+    self()
+
+ + Callable[[], Any] + Source   +Edit   + +
+
+
+
TimeitParam = string | NullaryFunc
+
+ + + Source   +Edit   + +
+
+
+
Timer = ref object
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Vars

+
+
+
default_timer = default_timer_defval
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Consts

+
+
+
default_number = 1000000
+
+ + + Source   +Edit   + +
+
+
+
default_repeat = 5
+
+ + since python 3.7: default value of repeat parameter is changed from 3 to 5. + Source   +Edit   + +
+
+
+
NullStmt = "discard"
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
proc newTimer(stmt: TimeitParam = NullStmt; setup: TimeitParam = NullStmt;
+              timer = default_timer; number = default_number): Timer
+
+ + + Source   +Edit   + +
+
+ +
+ + +
+
+
+

Templates

+
+
+
+
template autorange(self: Timer;
+                   callable: proc (number: int; time_taken: float) = nil): (int,
+    float)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template repeat(self: Timer; repeat = default_repeat; number = default_number): seq[
+    float]
+
+ + + Source   +Edit   + +
+
+
+
template repeat(stmt: TimeitParam = NullStmt; setup: TimeitParam = NullStmt;
+                timer = default_timer; repeat = default_repeat;
+                number = default_number): seq[float]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template timeit(repetitions: int; statements: untyped)
+
+ +

EXT. unstable.

+

returns nothing but send output to stdout.

+

output shows more information than Pythons.

+ +

Example:

+
var i = 0
+timeit(10):
+  i.inc
+assert i == 10
+ Source   +Edit   + +
+
+
+
template timeit(self: Timer; number = default_number): float
+
+ + + Source   +Edit   + +
+
+
+
template timeit(stmt: TimeitParam = NullStmt; setup: TimeitParam = NullStmt;
+                timer = default_timer; number = default_number): float
+
+ +

timeit(stmt, setup, number=1000000) with globals is globals()|locals()

+

stmt, setup are Callable or str literal

+ +

Example:

+
discard timeit("i.inc", "var i = 0")
+assert i != 0
+
+proc f() = discard
+discard timeit(f)
+proc retf(): int = 1
+discard timeit(retf)
+ Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/Lib/n_timeit.idx b/pylib/Lib/n_timeit.idx new file mode 100644 index 000000000..2d260b0b3 --- /dev/null +++ b/pylib/Lib/n_timeit.idx @@ -0,0 +1,18 @@ +nimTitle n_timeit pylib/Lib/n_timeit.html module src/pylib/Lib/n_timeit 0 +nim default_number pylib/Lib/n_timeit.html#default_number const default_number 12 +nim default_repeat pylib/Lib/n_timeit.html#default_repeat const default_repeat 13 +nim default_timer pylib/Lib/n_timeit.html#default_timer var default_timer 22 +nim timeit pylib/Lib/n_timeit.html#timeit.t,int,untyped template timeit(repetitions: int; statements: untyped) 27 +nim NullaryFunc pylib/Lib/n_timeit.html#NullaryFunc type NullaryFunc 51 +nim TimeitParam pylib/Lib/n_timeit.html#TimeitParam type TimeitParam 53 +nim NullStmt pylib/Lib/n_timeit.html#NullStmt const NullStmt 54 +nim Timer pylib/Lib/n_timeit.html#Timer type Timer 83 +nim newTimer pylib/Lib/n_timeit.html#newTimer,TimeitParam,TimeitParam proc newTimer(stmt: TimeitParam = NullStmt; setup: TimeitParam = NullStmt;\n timer = default_timer; number = default_number): Timer 87 +nim timeit pylib/Lib/n_timeit.html#timeit.t,Timer template timeit(self: Timer; number = default_number): float 105 +nim timeit pylib/Lib/n_timeit.html#timeit.t,TimeitParam,TimeitParam template timeit(stmt: TimeitParam = NullStmt; setup: TimeitParam = NullStmt;\n timer = default_timer; number = default_number): float 112 +nim repeat pylib/Lib/n_timeit.html#repeat.t,TimeitParam,TimeitParam template repeat(stmt: TimeitParam = NullStmt; setup: TimeitParam = NullStmt;\n timer = default_timer; repeat = default_repeat; number = default_number): seq[\n float] 141 +nim repeat pylib/Lib/n_timeit.html#repeat.t,Timer template repeat(self: Timer; repeat = default_repeat; number = default_number): seq[float] 148 +nim autorange pylib/Lib/n_timeit.html#autorange.t,Timer,proc(int,float) template autorange(self: Timer; callable: proc (number: int; time_taken: float) = nil): (\n int, float) 152 +nim print_exc pylib/Lib/n_timeit.html#print_exc,Timer,auto proc print_exc(self: Timer; file: auto = nil) 170 +nimgrp repeat pylib/Lib/n_timeit.html#repeat-templates-all template 141 +nimgrp timeit pylib/Lib/n_timeit.html#timeit-templates-all template 27 diff --git a/pylib/Lib/ncodec.html b/pylib/Lib/ncodec.html new file mode 100644 index 000000000..90a552470 --- /dev/null +++ b/pylib/Lib/ncodec.html @@ -0,0 +1,221 @@ + + + + + + + +src/pylib/Lib/ncodec + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/ncodec

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

EXT. Nim's codec. not the same as Python's codec

+ +
+

Types

+
+
+
EncErrors {.pure.} = enum
+  strict,                   ## - raise a ValueError error (or a subclass)
+  ignore,                   ## - ignore the character and continue with the next
+  replace,                  ## - replace with a suitable replacement character;
+                             ## Python will use the official U+FFFD REPLACEMENT
+                             ## CHARACTER for the builtin Unicode codecs on
+                             ## decoding and "?" on encoding.
+  surrogateescape,          ## - replace with private code points U+DCnn.
+  xmlcharrefreplace,        ## - Replace with the appropriate XML
+                             ##   character reference (only for encoding).
+  backslashreplace,         ## - Replace with backslashed escape sequences.
+  namereplace                ## - Replace with \N{...} escape sequences
+                             ##   (only for encoding).
+
+ + + Source   +Edit   + +
+
+
+
NCodecInfo = object
+  name*: string
+  errors*: string
+  encode*, decode*: EncoderCvt
+  close*: EncoderClose
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Consts

+
+
+
DefErrors = "strict"
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
func initNCodecInfo(encoding: string; errors = DefErrors): NCodecInfo {.
+    ...raises: [LookupError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Exports

+
+ LookupError +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/Lib/ncodec.idx b/pylib/Lib/ncodec.idx new file mode 100644 index 000000000..0c56cfd37 --- /dev/null +++ b/pylib/Lib/ncodec.idx @@ -0,0 +1,5 @@ +nimTitle ncodec pylib/Lib/ncodec.html module src/pylib/Lib/ncodec 0 +nim EncErrors pylib/Lib/ncodec.html#EncErrors enum EncErrors 10 +nim NCodecInfo pylib/Lib/ncodec.html#NCodecInfo object NCodecInfo 28 +nim DefErrors pylib/Lib/ncodec.html#DefErrors const DefErrors 35 +nim initNCodecInfo pylib/Lib/ncodec.html#initNCodecInfo,string proc initNCodecInfo(encoding: string; errors = DefErrors): NCodecInfo 56 diff --git a/pylib/Lib/os_impl/common.html b/pylib/Lib/os_impl/common.html new file mode 100644 index 000000000..535ee72e0 --- /dev/null +++ b/pylib/Lib/os_impl/common.html @@ -0,0 +1,96 @@ + + + + + + + +src/pylib/Lib/os_impl/common + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/os_impl/common

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Exports

+
+ InJs, asVersion, asVersion, Serial, PySerial, PyReleaseLevelEnum, asVersion, exportSincePy, pysince, Minor, Version, wrapExportSincePy, Major, pysince, PyMinor, pysince, PyReleaseLevel, asVersion, ReleaseLevel, PyMajor, PyPatch, templWrapExportSincePy, Patch, audit, PySys_Audit, addaudithook, PySys_AddAuditHook, PathLike, $, mapPathLike, mapPathLike, $, pathrepr, pathrepr, fspath, CanIOOpenT, fspath, osErrorMsgWithPath, raiseExcWithPath2, ConnectionError, ConnectionResetError, PyOSError, newBlockingIOError, raiseErrnoWithPath, InterruptedError, $, NotADirectoryError, errnoMsg, BrokenPipeError, TimeoutError, raiseExcWithPath, osErrorMsgWithPath, raiseErrno, tryOsOp, ProcessLookupError, IsADirectoryError, raiseExcWithPath, tryOsOp, tryOsOp, BlockingIOError, PyOSError, ConnectionAbortedError, ConnectionRefusedError, FileNotFoundError, BlockingIOError, ChildProcessError, BlockingIOError, noWeirdTarget, PyOSError, newPyOSError, raiseExcWithPath, newPyOSError, PermissionError, raiseErrnoT, FileExistsError, tryOsOp, newBlockingIOError, raiseExcWithPath, AttributeError, TypeError, SystemExit, NameError, NotImplementedError, RuntimeError, KeyboardInterrupt, runeLenAt, not, str, str, toPyStr, contains, substr, byteLen, str, items, StringLike, ==, str, toNimString, +, ==, str, chars, contains, and, getChar, $, len, +=, str, +=, len, toPyStr, PyStr, runes, [], ==, runeAtPos, or, contains, +, toNimStr, fspath, +=, toPyStr, [], [], repr, not, [], or, substr, +=, byteLen, pybytes, ==, toNimString, +, [], bytes, @, chars, len, getChar, $, bytes, bytes, +, +=, bytes, bytes, hasChar, bytes, +, +, items, [], PyBytes, +, substr, fspath, +=, bytes, getCharPtr, bytes, repr, None, NoneType +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/Lib/os_impl/common.idx b/pylib/Lib/os_impl/common.idx new file mode 100644 index 000000000..93b4163a6 --- /dev/null +++ b/pylib/Lib/os_impl/common.idx @@ -0,0 +1 @@ +nimTitle common pylib/Lib/os_impl/common.html module src/pylib/Lib/os_impl/common 0 diff --git a/pylib/Lib/os_impl/consts.html b/pylib/Lib/os_impl/consts.html new file mode 100644 index 000000000..6cddc1bf4 --- /dev/null +++ b/pylib/Lib/os_impl/consts.html @@ -0,0 +1,438 @@ + + + + + + + +src/pylib/Lib/os_impl/consts + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/os_impl/consts

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

SEEK_* is in ./posix_like/seek_c

+ +
+

Lets

+
+
+
altsep = str '/'
+
+ + + Source   +Edit   + +
+
+
+
curdir = str '.'
+
+ + + Source   +Edit   + +
+
+
+
extsep = str '.'
+
+ + + Source   +Edit   + +
+
+
+
linesep = str("\n")
+
+ + + Source   +Edit   + +
+
+
+
O_APPEND {.importc: "O_APPEND", header: "<fcntl.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
O_CLOEXEC {.importc: "O_CLOEXEC", header: "<fcntl.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
O_CREAT {.importc: "O_CREAT", header: "<fcntl.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
O_DSYNC {.importc: "O_DSYNC", header: "<fcntl.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
O_EXCL {.importc: "O_EXCL", header: "<fcntl.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
O_NDELAY {.importc: "O_NDELAY", header: "<fcntl.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
O_NOCTTY {.importc: "O_NOCTTY", header: "<fcntl.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
O_NONBLOCK {.importc: "O_NONBLOCK", header: "<fcntl.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
O_RDONLY {.importc: "O_RDONLY", header: "<fcntl.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
O_RDWR {.importc: "O_RDWR", header: "<fcntl.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
O_RSYNC {.importc: "O_RSYNC", header: "<fcntl.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
O_SYNC {.importc: "O_SYNC", header: "<fcntl.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
O_TRUNC {.importc: "O_TRUNC", header: "<fcntl.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
O_WRONLY {.importc: "O_WRONLY", header: "<fcntl.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
pardir = str ParDir
+
+ + + Source   +Edit   + +
+
+
+
pathsep = str ':'
+
+ + + Source   +Edit   + +
+
+
+
sep = str '/'
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Consts

+
+
+
defpath: PyStr = "<os-dependent-content>"
+
+ + + Source   +Edit   + +
+
+
+
devnull: PyStr = "<os-dependent-content>"
+
+ + + Source   +Edit   + +
+
+
+
name: PyStr = "<os-dependent-content>"
+
+ + "nt" when windows, "posix" when posix;
Note: +when in neither Windows nor POSIX, os.name will be defined as str(hostOS) iff pylibOsName is defined when compiling
+ + Source   +Edit   + +
+
+ +
+
+
+

Templates

+
+
+
+
template `|`(a, b: cint): cint
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template `|=`(a, b: cint)
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ + +
+
+ + +
+
+ + + diff --git a/pylib/Lib/os_impl/consts.idx b/pylib/Lib/os_impl/consts.idx new file mode 100644 index 000000000..b6854d4ca --- /dev/null +++ b/pylib/Lib/os_impl/consts.idx @@ -0,0 +1,27 @@ +nimTitle consts pylib/Lib/os_impl/consts.html module src/pylib/Lib/os_impl/consts 0 +nim curdir pylib/Lib/os_impl/consts.html#curdir let curdir 15 +nim pardir pylib/Lib/os_impl/consts.html#pardir let pardir 15 +nim extsep pylib/Lib/os_impl/consts.html#extsep let extsep 15 +nim pathsep pylib/Lib/os_impl/consts.html#pathsep let pathsep 15 +nim altsep pylib/Lib/os_impl/consts.html#altsep let altsep 15 +nim linesep pylib/Lib/os_impl/consts.html#linesep let linesep 24 +nim sep pylib/Lib/os_impl/consts.html#sep let sep 25 +nim devnull pylib/Lib/os_impl/consts.html#devnull const devnull 32 +nim defpath pylib/Lib/os_impl/consts.html#defpath const defpath 33 +nim name pylib/Lib/os_impl/consts.html#name const name 34 +nim O_RDONLY pylib/Lib/os_impl/consts.html#O_RDONLY let O_RDONLY 70 +nim O_WRONLY pylib/Lib/os_impl/consts.html#O_WRONLY let O_WRONLY 70 +nim O_RDWR pylib/Lib/os_impl/consts.html#O_RDWR let O_RDWR 70 +nim O_APPEND pylib/Lib/os_impl/consts.html#O_APPEND let O_APPEND 70 +nim O_CREAT pylib/Lib/os_impl/consts.html#O_CREAT let O_CREAT 70 +nim O_EXCL pylib/Lib/os_impl/consts.html#O_EXCL let O_EXCL 70 +nim O_TRUNC pylib/Lib/os_impl/consts.html#O_TRUNC let O_TRUNC 70 +nim O_DSYNC pylib/Lib/os_impl/consts.html#O_DSYNC let O_DSYNC 70 +nim O_RSYNC pylib/Lib/os_impl/consts.html#O_RSYNC let O_RSYNC 70 +nim O_SYNC pylib/Lib/os_impl/consts.html#O_SYNC let O_SYNC 70 +nim O_NDELAY pylib/Lib/os_impl/consts.html#O_NDELAY let O_NDELAY 70 +nim O_NONBLOCK pylib/Lib/os_impl/consts.html#O_NONBLOCK let O_NONBLOCK 70 +nim O_NOCTTY pylib/Lib/os_impl/consts.html#O_NOCTTY let O_NOCTTY 70 +nim O_CLOEXEC pylib/Lib/os_impl/consts.html#O_CLOEXEC let O_CLOEXEC 70 +nim `|` pylib/Lib/os_impl/consts.html#|.t,cint,cint template `|`(a, b: cint): cint 116 +nim `|=` pylib/Lib/os_impl/consts.html#|=.t,cint,cint template `|=`(a, b: cint) 117 diff --git a/pylib/Lib/os_impl/posix_like/isatty.html b/pylib/Lib/os_impl/posix_like/isatty.html new file mode 100644 index 000000000..6db43d3ed --- /dev/null +++ b/pylib/Lib/os_impl/posix_like/isatty.html @@ -0,0 +1,109 @@ + + + + + + + +src/pylib/Lib/os_impl/posix_like/isatty + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/os_impl/posix_like/isatty

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Procs

+
+
+
+
func isatty(fd: int): bool {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/Lib/os_impl/posix_like/isatty.idx b/pylib/Lib/os_impl/posix_like/isatty.idx new file mode 100644 index 000000000..aca10ca27 --- /dev/null +++ b/pylib/Lib/os_impl/posix_like/isatty.idx @@ -0,0 +1,2 @@ +nimTitle isatty pylib/Lib/os_impl/posix_like/isatty.html module src/pylib/Lib/os_impl/posix_like/isatty 0 +nim isatty pylib/Lib/os_impl/posix_like/isatty.html#isatty,int proc isatty(fd: int): bool 11 diff --git a/pylib/Lib/os_impl/posix_like/open_close.html b/pylib/Lib/os_impl/posix_like/open_close.html new file mode 100644 index 000000000..4b5b35a1c --- /dev/null +++ b/pylib/Lib/os_impl/posix_like/open_close.html @@ -0,0 +1,153 @@ + + + + + + + +src/pylib/Lib/os_impl/posix_like/open_close + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/os_impl/posix_like/open_close

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
proc close(fd: int) {....raises: [PyOSError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc closerange(fd_low, fd_high: int) {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc open(path: PathLike; flags: int; mode = 0o000000000777; dir_fd = -1): int {.
+    ...forbids: [NotImplForNonNode].}
+
+ + dir_fd is ignored under Windows + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/Lib/os_impl/posix_like/open_close.idx b/pylib/Lib/os_impl/posix_like/open_close.idx new file mode 100644 index 000000000..d2c95c646 --- /dev/null +++ b/pylib/Lib/os_impl/posix_like/open_close.idx @@ -0,0 +1,4 @@ +nimTitle open_close pylib/Lib/os_impl/posix_like/open_close.html module src/pylib/Lib/os_impl/posix_like/open_close 0 +nim open pylib/Lib/os_impl/posix_like/open_close.html#open,PathLike,int,int,int proc open(path: PathLike; flags: int; mode = 0o000000000777; dir_fd = -1): int 62 +nim close pylib/Lib/os_impl/posix_like/open_close.html#close,int proc close(fd: int) 97 +nim closerange pylib/Lib/os_impl/posix_like/open_close.html#closerange,int,int proc closerange(fd_low, fd_high: int) 107 diff --git a/pylib/Lib/os_impl/posix_like/truncate.html b/pylib/Lib/os_impl/posix_like/truncate.html new file mode 100644 index 000000000..2ca027dec --- /dev/null +++ b/pylib/Lib/os_impl/posix_like/truncate.html @@ -0,0 +1,136 @@ + + + + + + + +src/pylib/Lib/os_impl/posix_like/truncate + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/os_impl/posix_like/truncate

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
proc ftruncate(file: Positive; length: Natural) {....raises: [PyOSError], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc truncate(file: CanIOOpenT; length: Natural)
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/Lib/os_impl/posix_like/truncate.idx b/pylib/Lib/os_impl/posix_like/truncate.idx new file mode 100644 index 000000000..3cceb57d1 --- /dev/null +++ b/pylib/Lib/os_impl/posix_like/truncate.idx @@ -0,0 +1,3 @@ +nimTitle truncate pylib/Lib/os_impl/posix_like/truncate.html module src/pylib/Lib/os_impl/posix_like/truncate 0 +nim ftruncate pylib/Lib/os_impl/posix_like/truncate.html#ftruncate,Positive,Natural proc ftruncate(file: Positive; length: Natural) 45 +nim truncate pylib/Lib/os_impl/posix_like/truncate.html#truncate,CanIOOpenT,Natural proc truncate(file: CanIOOpenT; length: Natural) 49 diff --git a/pylib/Lib/os_impl/private/defined_macros.html b/pylib/Lib/os_impl/private/defined_macros.html new file mode 100644 index 000000000..d21a29c71 --- /dev/null +++ b/pylib/Lib/os_impl/private/defined_macros.html @@ -0,0 +1,125 @@ + + + + + + + +src/pylib/Lib/os_impl/private/defined_macros + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/os_impl/private/defined_macros

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Consts

+
+
+
InJs = false
+
+ + + Source   +Edit   + +
+
+
+
ms_windows = false
+
+ + + Source   +Edit   + +
+
+
+
MS_WINDOWS = false
+
+ + + Source   +Edit   + +
+
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/Lib/os_impl/private/defined_macros.idx b/pylib/Lib/os_impl/private/defined_macros.idx new file mode 100644 index 000000000..1a42af414 --- /dev/null +++ b/pylib/Lib/os_impl/private/defined_macros.idx @@ -0,0 +1,4 @@ +nimTitle defined_macros pylib/Lib/os_impl/private/defined_macros.html module src/pylib/Lib/os_impl/private/defined_macros 0 +nim MS_WINDOWS pylib/Lib/os_impl/private/defined_macros.html#MS_WINDOWS const MS_WINDOWS 2 +nim ms_windows pylib/Lib/os_impl/private/defined_macros.html#ms_windows_2 const ms_windows 4 +nim InJs pylib/Lib/os_impl/private/defined_macros.html#InJs const InJs 8 diff --git a/pylib/Lib/private/platformInfo.html b/pylib/Lib/private/platformInfo.html new file mode 100644 index 000000000..a87d03142 --- /dev/null +++ b/pylib/Lib/private/platformInfo.html @@ -0,0 +1,172 @@ + + + + + + + +src/pylib/Lib/private/platformInfo + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/private/platformInfo

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

used by Lib/os and Lib/platform

+
+

Consts

+
+
+
platform.system = "Linux"
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
proc ac_md_release(): string {....raises: [OSError, IOError],
+                               tags: [ExecIOEffect, ReadIOEffect, RootEffect],
+                               forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc platform.version(): string {....raises: [OSError, IOError], tags: [
+    ExecIOEffect, ReadIOEffect, RootEffect], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc uname_release_major(): string {....raises: [OSError, IOError], tags: [
+    ExecIOEffect, ReadIOEffect, RootEffect], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/Lib/private/platformInfo.idx b/pylib/Lib/private/platformInfo.idx new file mode 100644 index 000000000..b3bbc13ff --- /dev/null +++ b/pylib/Lib/private/platformInfo.idx @@ -0,0 +1,5 @@ +nimTitle platformInfo pylib/Lib/private/platformInfo.html module src/pylib/Lib/private/platformInfo 0 +nim platform.system pylib/Lib/private/platformInfo.html#platform.system const platform.system 18 +nim ac_md_release pylib/Lib/private/platformInfo.html#ac_md_release proc ac_md_release(): string 38 +nim uname_release_major pylib/Lib/private/platformInfo.html#uname_release_major proc uname_release_major(): string 53 +nim platform.version pylib/Lib/private/platformInfo.html#platform.version proc platform.version(): string 57 diff --git a/pylib/Lib/private/platformUtils.html b/pylib/Lib/private/platformUtils.html new file mode 100644 index 000000000..8158f2ff2 --- /dev/null +++ b/pylib/Lib/private/platformUtils.html @@ -0,0 +1,151 @@ + + + + + + + +src/pylib/Lib/private/platformUtils + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/private/platformUtils

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Consts

+
+
+
CLike = true
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Templates

+
+
+
+
template clikeOr(inCLike, b): untyped
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template impJsOrC(sym, cfloatSym, argSym) {.dirty.}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/Lib/private/platformUtils.idx b/pylib/Lib/private/platformUtils.idx new file mode 100644 index 000000000..7c3b0196d --- /dev/null +++ b/pylib/Lib/private/platformUtils.idx @@ -0,0 +1,4 @@ +nimTitle platformUtils pylib/Lib/private/platformUtils.html module src/pylib/Lib/private/platformUtils 0 +nim CLike pylib/Lib/private/platformUtils.html#CLike const CLike 2 +nim clikeOr pylib/Lib/private/platformUtils.html#clikeOr.t,, template clikeOr(inCLike, b): untyped 4 +nim impJsOrC pylib/Lib/private/platformUtils.html#impJsOrC.t,,, template impJsOrC(sym, cfloatSym, argSym) 12 diff --git a/pylib/Lib/signal_impl/c_py_handler_cvt.html b/pylib/Lib/signal_impl/c_py_handler_cvt.html new file mode 100644 index 000000000..3fd414f1b --- /dev/null +++ b/pylib/Lib/signal_impl/c_py_handler_cvt.html @@ -0,0 +1,136 @@ + + + + + + + +src/pylib/Lib/signal_impl/c_py_handler_cvt + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/signal_impl/c_py_handler_cvt

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
proc toCSighandler(p: PySigHandler): CSigHandler {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc toPySighandler(p: CSigHandler | NimSigHandler): PySigHandler
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/Lib/signal_impl/c_py_handler_cvt.idx b/pylib/Lib/signal_impl/c_py_handler_cvt.idx new file mode 100644 index 000000000..79e6adfca --- /dev/null +++ b/pylib/Lib/signal_impl/c_py_handler_cvt.idx @@ -0,0 +1,3 @@ +nimTitle c_py_handler_cvt pylib/Lib/signal_impl/c_py_handler_cvt.html module src/pylib/Lib/signal_impl/c_py_handler_cvt 0 +nim toCSighandler pylib/Lib/signal_impl/c_py_handler_cvt.html#toCSighandler,PySigHandler proc toCSighandler(p: PySigHandler): CSigHandler 4 +nim toPySighandler pylib/Lib/signal_impl/c_py_handler_cvt.html#toPySighandler proc toPySighandler(p: CSigHandler | NimSigHandler): PySigHandler 10 diff --git a/pylib/Lib/signal_impl/frames.html b/pylib/Lib/signal_impl/frames.html new file mode 100644 index 000000000..62ca9378b --- /dev/null +++ b/pylib/Lib/signal_impl/frames.html @@ -0,0 +1,120 @@ + + + + + + + +src/pylib/Lib/signal_impl/frames + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/signal_impl/frames

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Procs

+
+
+
+
proc getFrameOrNil(): PFrame {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc getFrameOrNil(up: int): PFrame {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/Lib/signal_impl/frames.idx b/pylib/Lib/signal_impl/frames.idx new file mode 100644 index 000000000..4a24f98b5 --- /dev/null +++ b/pylib/Lib/signal_impl/frames.idx @@ -0,0 +1,4 @@ +nimTitle frames pylib/Lib/signal_impl/frames.html module src/pylib/Lib/signal_impl/frames 0 +nim getFrameOrNil pylib/Lib/signal_impl/frames.html#getFrameOrNil proc getFrameOrNil(): PFrame 2 +nim getFrameOrNil pylib/Lib/signal_impl/frames.html#getFrameOrNil,int proc getFrameOrNil(up: int): PFrame 7 +nimgrp getframeornil pylib/Lib/signal_impl/frames.html#getFrameOrNil-procs-all proc 2 diff --git a/pylib/Lib/signal_impl/pyatomic.html b/pylib/Lib/signal_impl/pyatomic.html new file mode 100644 index 000000000..2c26fa890 --- /dev/null +++ b/pylib/Lib/signal_impl/pyatomic.html @@ -0,0 +1,160 @@ + + + + + + + +src/pylib/Lib/signal_impl/pyatomic + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/signal_impl/pyatomic

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Templates

+
+
+
+
template Py_atomic_load[T](obj: T): T
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template Py_atomic_load_ptr[T](obj: ptr T): T
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template Py_atomic_store[T](obj: T; value: T)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template Py_atomic_store_ptr[T](obj: ptr T; value: T)
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/Lib/signal_impl/pyatomic.idx b/pylib/Lib/signal_impl/pyatomic.idx new file mode 100644 index 000000000..b7003a190 --- /dev/null +++ b/pylib/Lib/signal_impl/pyatomic.idx @@ -0,0 +1,5 @@ +nimTitle pyatomic pylib/Lib/signal_impl/pyatomic.html module src/pylib/Lib/signal_impl/pyatomic 0 +nim Py_atomic_load_ptr pylib/Lib/signal_impl/pyatomic.html#Py_atomic_load_ptr.t,ptr.T template Py_atomic_load_ptr[T](obj: ptr T): T 3 +nim Py_atomic_store_ptr pylib/Lib/signal_impl/pyatomic.html#Py_atomic_store_ptr.t,ptr.T,T template Py_atomic_store_ptr[T](obj: ptr T; value: T) 4 +nim Py_atomic_load pylib/Lib/signal_impl/pyatomic.html#Py_atomic_load.t,T template Py_atomic_load[T](obj: T): T 6 +nim Py_atomic_store pylib/Lib/signal_impl/pyatomic.html#Py_atomic_store.t,T,T template Py_atomic_store[T](obj: T; value: T) 11 diff --git a/pylib/Lib/signal_impl/pylifecycle.html b/pylib/Lib/signal_impl/pylifecycle.html new file mode 100644 index 000000000..6eb7e9193 --- /dev/null +++ b/pylib/Lib/signal_impl/pylifecycle.html @@ -0,0 +1,96 @@ + + + + + + + +src/pylib/Lib/signal_impl/pylifecycle + + + + + + + + + + + + + + + + + + + + diff --git a/pylib/Lib/signal_impl/pylifecycle.idx b/pylib/Lib/signal_impl/pylifecycle.idx new file mode 100644 index 000000000..8d19c7e07 --- /dev/null +++ b/pylib/Lib/signal_impl/pylifecycle.idx @@ -0,0 +1 @@ +nimTitle pylifecycle pylib/Lib/signal_impl/pylifecycle.html module src/pylib/Lib/signal_impl/pylifecycle 0 diff --git a/pylib/Lib/signal_impl/pynsig.html b/pylib/Lib/signal_impl/pynsig.html new file mode 100644 index 000000000..d76b1fb7b --- /dev/null +++ b/pylib/Lib/signal_impl/pynsig.html @@ -0,0 +1,96 @@ + + + + + + + +src/pylib/Lib/signal_impl/pynsig + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/signal_impl/pynsig

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+ +
+ + +
+
+ + + diff --git a/pylib/Lib/signal_impl/pynsig.idx b/pylib/Lib/signal_impl/pynsig.idx new file mode 100644 index 000000000..4e7b98dc2 --- /dev/null +++ b/pylib/Lib/signal_impl/pynsig.idx @@ -0,0 +1 @@ +nimTitle pynsig pylib/Lib/signal_impl/pynsig.html module src/pylib/Lib/signal_impl/pynsig 0 diff --git a/pylib/Lib/signal_impl/state.html b/pylib/Lib/signal_impl/state.html new file mode 100644 index 000000000..a124d9cae --- /dev/null +++ b/pylib/Lib/signal_impl/state.html @@ -0,0 +1,276 @@ + + + + + + + +src/pylib/Lib/signal_impl/state + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/signal_impl/state

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

XXX: FIXED-NIM-BUG: though nimAllowNonVarDestructor is defined at least since 2.0.6, it still cannot be compiled till abour 2.1.1

+ +
+

Types

+
+
+
signal_state_t = object
+  handlers*: array[Py_NSIG, handler]
+  when DWin:
+    sigint_event*: Handle
+  default_handler*, ignore_handler*: PySigHandler
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Consts

+
+
+
DWin = false
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
proc get_handler(i: cint): PySigHandler {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc initPySignal(install_signal_handlers: bool) {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc PySignal_Fini() {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc set_handler(i: cint; fn: PySigHandler) {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template Handlers(): untyped
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template signal_global_state(): signal_state_t
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/Lib/signal_impl/state.idx b/pylib/Lib/signal_impl/state.idx new file mode 100644 index 000000000..aceabe205 --- /dev/null +++ b/pylib/Lib/signal_impl/state.idx @@ -0,0 +1,9 @@ +nimTitle state pylib/Lib/signal_impl/state.html module src/pylib/Lib/signal_impl/state 0 +nim DWin pylib/Lib/signal_impl/state.html#DWin const DWin 5 +nim signal_state_t pylib/Lib/signal_impl/state.html#signal_state_t object signal_state_t 13 +nim initPySignal pylib/Lib/signal_impl/state.html#initPySignal,bool proc initPySignal(install_signal_handlers: bool) 41 +nim signal_global_state pylib/Lib/signal_impl/state.html#signal_global_state.t template signal_global_state(): signal_state_t 46 +nim Handlers pylib/Lib/signal_impl/state.html#Handlers.t template Handlers(): untyped 56 +nim get_handler pylib/Lib/signal_impl/state.html#get_handler,cint proc get_handler(i: cint): PySigHandler 93 +nim set_handler pylib/Lib/signal_impl/state.html#set_handler,cint,PySigHandler proc set_handler(i: cint; fn: PySigHandler) 95 +nim PySignal_Fini pylib/Lib/signal_impl/state.html#PySignal_Fini proc PySignal_Fini() 117 diff --git a/pylib/Lib/sys.html b/pylib/Lib/sys.html new file mode 100644 index 000000000..b33b98ffa --- /dev/null +++ b/pylib/Lib/sys.html @@ -0,0 +1,405 @@ + + + + + + + +src/pylib/Lib/sys + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/sys

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

Lib/sys

Hint: +if not defined pylibConfigIsolated, this module will call setlocale(LC_CTYPE, ""), a.k.a. changing locale to user's configure, just as CPython's initialization.
+

+ +
+

Vars

+
+
+
argv: PyList[PyStr]
+
+ + + Source   +Edit   + +
+
+
+
orig_argv = newPyListOfCap(argc)
+
+ + + .. hint:: rely on paramCount<https://nim-lang.org/docs/cmdline.html#paramCount>_ and paramStr<https://nim-lang.org/docs/cmdline.html#paramStr%2Cint>_. See their document for availability. + Source   +Edit   + +
+
+ +
+
+
+

Consts

+
+
+
byteorder = "little"
+
+ + + Source   +Edit   + +
+
+ +
+
float_repr_style = "short"
+
+ + + Source   +Edit   + +
+
+
+
hexversion = 51577072
+
+ + + Source   +Edit   + +
+
+
+
implementation = ("pynim", (0, 9, 11, "alpha", 0), 51577072, false)
+
+ + + Source   +Edit   + +
+
+
+
maxsize = 9223372036854775807'i64
+
+ + + Source   +Edit   + +
+
+
+
platform = "linux"
+
+ +
Note: +the value is standalone for bare system
+

and haiku/netbsd appended with major version instead of "unknown". In short, this won't be "unknown" as Python does.

+ + Source   +Edit   + +
+
+
+
version = "3.13.0"
+
+ + + Source   +Edit   + +
+
+
+
version_info = (3, 13, 0, "final", 0)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
func exit(x: NoneType) {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func exit[T](obj: T)
+
+ +
Warning: +this does not raise SystemExit, which differs Python's
+ + Source   +Edit   + +
+
+ +
+
+
+
proc getdefaultencoding(): PyStr {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc getfilesystemencoding(): PyStr {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template addaudithook(hook: HookProc)
+
+ +
Admonition: +since Python 3.8
+ + Source   +Edit   + +
+
+ +
+
+
+
template audit(event: string; args: varargs[typed])
+
+ +
Admonition: +since Python 3.8
+ + Source   +Edit   + +
+
+ +
+
+
+
template executable(): PyStr
+
+ + returns:
  • when nimscript, path of Nim;
  • +
  • when JavaScript:
    • on browser: empty string
    • +
    • on NodeJS/Deno: executable path of Node/Deno
    • +
    +
  • +
  • otherwise, it's the path of current app/exe.
  • +
+ + Source   +Edit   + +
+
+ +
+ +
+
+ + +
+
+ + +
+
+ + + diff --git a/pylib/Lib/sys.idx b/pylib/Lib/sys.idx new file mode 100644 index 000000000..6920139e6 --- /dev/null +++ b/pylib/Lib/sys.idx @@ -0,0 +1,20 @@ +nimTitle sys pylib/Lib/sys.html module src/pylib/Lib/sys 0 +nim addaudithook pylib/Lib/sys.html#addaudithook.t,HookProc template addaudithook(hook: HookProc) 18 +nim audit pylib/Lib/sys.html#audit.t,string,varargs[typed] template audit(event: string; args: varargs[typed]) 19 +nim float_repr_style pylib/Lib/sys.html#float_repr_style const float_repr_style 21 +nim platform pylib/Lib/sys.html#platform const platform 58 +nim version_info pylib/Lib/sys.html#version_info_2 const version_info 33 +nim implementation pylib/Lib/sys.html#implementation_2 const implementation 47 +nim version pylib/Lib/sys.html#version_2 const version 53 +nim hexversion pylib/Lib/sys.html#hexversion_2 const hexversion 54 +nim maxsize pylib/Lib/sys.html#maxsize_2 const maxsize 56 +nim byteorder pylib/Lib/sys.html#byteorder_2 const byteorder 57 +nim copyright pylib/Lib/sys.html#copyright_2 const copyright 58 +nim orig_argv pylib/Lib/sys.html#orig_argv_2 var orig_argv 34 +nim argv pylib/Lib/sys.html#argv_2 var argv 39 +nim executable pylib/Lib/sys.html#executable.t_2 template executable(): PyStr 61 +nim getfilesystemencoding pylib/Lib/sys.html#getfilesystemencoding_2 proc getfilesystemencoding(): PyStr 33 +nim getdefaultencoding pylib/Lib/sys.html#getdefaultencoding_2 proc getdefaultencoding(): PyStr 34 +nim exit pylib/Lib/sys.html#exit,T proc exit[T](obj: T) 36 +nim exit pylib/Lib/sys.html#exit,NoneType proc exit(x: NoneType) 40 +nimgrp exit pylib/Lib/sys.html#exit-procs-all proc 36 diff --git a/pylib/Lib/sys_impl/auditImpl.html b/pylib/Lib/sys_impl/auditImpl.html new file mode 100644 index 000000000..a42ca180d --- /dev/null +++ b/pylib/Lib/sys_impl/auditImpl.html @@ -0,0 +1,96 @@ + + + + + + + +src/pylib/Lib/sys_impl/auditImpl + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/sys_impl/auditImpl

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

When not defined(release) or defined(pylibSysAudit), audit will be enabled. Otherwise, it will be disabled.

+ + + +
+
+ + +
+
+ + + diff --git a/pylib/Lib/sys_impl/auditImpl.idx b/pylib/Lib/sys_impl/auditImpl.idx new file mode 100644 index 000000000..2fc09d234 --- /dev/null +++ b/pylib/Lib/sys_impl/auditImpl.idx @@ -0,0 +1 @@ +nimTitle auditImpl pylib/Lib/sys_impl/auditImpl.html module src/pylib/Lib/sys_impl/auditImpl 0 diff --git a/pylib/Lib/sys_impl/auditImpl/cfg.html b/pylib/Lib/sys_impl/auditImpl/cfg.html new file mode 100644 index 000000000..86a99458a --- /dev/null +++ b/pylib/Lib/sys_impl/auditImpl/cfg.html @@ -0,0 +1,151 @@ + + + + + + + +src/pylib/Lib/sys_impl/auditImpl/cfg + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/sys_impl/auditImpl/cfg

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Consts

+
+
+
config_should_audit = false
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Templates

+
+
+
+
template whenAuditEnabled(body)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template whenAuditEnabledOr[T](exp, elseExp: T): T
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/Lib/sys_impl/auditImpl/cfg.idx b/pylib/Lib/sys_impl/auditImpl/cfg.idx new file mode 100644 index 000000000..98644a523 --- /dev/null +++ b/pylib/Lib/sys_impl/auditImpl/cfg.idx @@ -0,0 +1,4 @@ +nimTitle cfg pylib/Lib/sys_impl/auditImpl/cfg.html module src/pylib/Lib/sys_impl/auditImpl/cfg 0 +nim config_should_audit pylib/Lib/sys_impl/auditImpl/cfg.html#config_should_audit const config_should_audit 3 +nim whenAuditEnabled pylib/Lib/sys_impl/auditImpl/cfg.html#whenAuditEnabled.t template whenAuditEnabled(body) 7 +nim whenAuditEnabledOr pylib/Lib/sys_impl/auditImpl/cfg.html#whenAuditEnabledOr.t,T,T template whenAuditEnabledOr[T](exp, elseExp: T): T 12 diff --git a/pylib/Lib/sys_impl/auditImpl/macrohelper.html b/pylib/Lib/sys_impl/auditImpl/macrohelper.html new file mode 100644 index 000000000..4e40ca268 --- /dev/null +++ b/pylib/Lib/sys_impl/auditImpl/macrohelper.html @@ -0,0 +1,144 @@ + + + + + + + +src/pylib/Lib/sys_impl/auditImpl/macrohelper + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/sys_impl/auditImpl/macrohelper

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Imports

+
+ cfg, main +
+
+
+

Templates

+
+
+
+
template addaudit(res: NimNode; event: static string; vargs: varargs[untyped])
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template newStmtWithAudit(event: static string; vargs: varargs[untyped]): NimNode
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ + +
+
+ + +
+
+ + + diff --git a/pylib/Lib/sys_impl/auditImpl/macrohelper.idx b/pylib/Lib/sys_impl/auditImpl/macrohelper.idx new file mode 100644 index 000000000..17901ab46 --- /dev/null +++ b/pylib/Lib/sys_impl/auditImpl/macrohelper.idx @@ -0,0 +1,3 @@ +nimTitle macrohelper pylib/Lib/sys_impl/auditImpl/macrohelper.html module src/pylib/Lib/sys_impl/auditImpl/macrohelper 0 +nim addaudit pylib/Lib/sys_impl/auditImpl/macrohelper.html#addaudit.t,NimNode,staticstring,varargs[untyped] template addaudit(res: NimNode; event: static string; vargs: varargs[untyped]) 12 +nim newStmtWithAudit pylib/Lib/sys_impl/auditImpl/macrohelper.html#newStmtWithAudit.t,staticstring,varargs[untyped] template newStmtWithAudit(event: static string; vargs: varargs[untyped]): NimNode 17 diff --git a/pylib/Lib/sys_impl/auditImpl/main.html b/pylib/Lib/sys_impl/auditImpl/main.html new file mode 100644 index 000000000..0bde13b5e --- /dev/null +++ b/pylib/Lib/sys_impl/auditImpl/main.html @@ -0,0 +1,169 @@ + + + + + + + +src/pylib/Lib/sys_impl/auditImpl/main + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/sys_impl/auditImpl/main

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Imports

+
+ cfg, types +
+
+
+

Templates

+
+
+
+
template addaudithook(hook: HookProc)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template audit(event: string; args: varargs[typed])
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template PySys_AddAuditHook(hook: HookProc; userData = default Any)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template PySys_Audit(event: string; args: varargs[typed])
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/Lib/sys_impl/auditImpl/main.idx b/pylib/Lib/sys_impl/auditImpl/main.idx new file mode 100644 index 000000000..c19d38d4e --- /dev/null +++ b/pylib/Lib/sys_impl/auditImpl/main.idx @@ -0,0 +1,5 @@ +nimTitle main pylib/Lib/sys_impl/auditImpl/main.html module src/pylib/Lib/sys_impl/auditImpl/main 0 +nim PySys_Audit pylib/Lib/sys_impl/auditImpl/main.html#PySys_Audit.t,string,varargs[typed] template PySys_Audit(event: string; args: varargs[typed]) 4 +nim PySys_AddAuditHook pylib/Lib/sys_impl/auditImpl/main.html#PySys_AddAuditHook.t,HookProc template PySys_AddAuditHook(hook: HookProc; userData = default Any) 9 +nim addaudithook pylib/Lib/sys_impl/auditImpl/main.html#addaudithook.t,HookProc template addaudithook(hook: HookProc) 10 +nim audit pylib/Lib/sys_impl/auditImpl/main.html#audit.t,string,varargs[typed] template audit(event: string; args: varargs[typed]) 12 diff --git a/pylib/Lib/sys_impl/auditImpl/types.html b/pylib/Lib/sys_impl/auditImpl/types.html new file mode 100644 index 000000000..1d010b6c9 --- /dev/null +++ b/pylib/Lib/sys_impl/auditImpl/types.html @@ -0,0 +1,114 @@ + + + + + + + +src/pylib/Lib/sys_impl/auditImpl/types + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/sys_impl/auditImpl/types

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Types

+
+
+
HookEntry = tuple[hookCFunction: HookProc, userData: Any]
+
+ + + Source   +Edit   + +
+
+
+
HookProc = proc (event: string; args: varargs[Any])
+
+ + + Source   +Edit   + +
+
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/Lib/sys_impl/auditImpl/types.idx b/pylib/Lib/sys_impl/auditImpl/types.idx new file mode 100644 index 000000000..12c680225 --- /dev/null +++ b/pylib/Lib/sys_impl/auditImpl/types.idx @@ -0,0 +1,3 @@ +nimTitle types pylib/Lib/sys_impl/auditImpl/types.html module src/pylib/Lib/sys_impl/auditImpl/types 0 +nim HookProc pylib/Lib/sys_impl/auditImpl/types.html#HookProc type HookProc 6 +nim HookEntry pylib/Lib/sys_impl/auditImpl/types.html#HookEntry tuple HookEntry 7 diff --git a/pylib/Lib/sys_impl/exits.html b/pylib/Lib/sys_impl/exits.html new file mode 100644 index 000000000..92042573f --- /dev/null +++ b/pylib/Lib/sys_impl/exits.html @@ -0,0 +1,120 @@ + + + + + + + +src/pylib/Lib/sys_impl/exits + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/sys_impl/exits

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Procs

+
+
+
+
func exit(c: int) {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc exit(s: string) {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/Lib/sys_impl/exits.idx b/pylib/Lib/sys_impl/exits.idx new file mode 100644 index 000000000..4a5971e69 --- /dev/null +++ b/pylib/Lib/sys_impl/exits.idx @@ -0,0 +1,4 @@ +nimTitle exits pylib/Lib/sys_impl/exits.html module src/pylib/Lib/sys_impl/exits 0 +nim exit pylib/Lib/sys_impl/exits.html#exit,string proc exit(s: string) 2 +nim exit pylib/Lib/sys_impl/exits.html#exit,int proc exit(c: int) 3 +nimgrp exit pylib/Lib/sys_impl/exits.html#exit-procs-all proc 2 diff --git a/pylib/Lib/sys_impl/fenvs.html b/pylib/Lib/sys_impl/fenvs.html new file mode 100644 index 000000000..f36c95a2d --- /dev/null +++ b/pylib/Lib/sys_impl/fenvs.html @@ -0,0 +1,158 @@ + + + + + + + +src/pylib/Lib/sys_impl/fenvs + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/sys_impl/fenvs

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Consts

+
+
+
float_info = (max: 1.7976931348623157e+308, max_exp: 1024, max_10_exp: 308,
+              min: 2.2250738585072014e-308, min_exp: -1021, min_10_exp: -307,
+              dig: 15, mant_dig: 53, epsilon: 2.220446049250313e-16, radix: 2)
+
+ + float_info.rounds is defined as a getter, see rounds + Source   +Edit   + +
+
+
+
float_repr_style = "short"
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Templates

+
+
+
+
template rounds(fi: typeof(float_info)): int
+
+ + not available when nimscript + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/Lib/sys_impl/fenvs.idx b/pylib/Lib/sys_impl/fenvs.idx new file mode 100644 index 000000000..3f44b2895 --- /dev/null +++ b/pylib/Lib/sys_impl/fenvs.idx @@ -0,0 +1,4 @@ +nimTitle fenvs pylib/Lib/sys_impl/fenvs.html module src/pylib/Lib/sys_impl/fenvs 0 +nim float_repr_style pylib/Lib/sys_impl/fenvs.html#float_repr_style const float_repr_style 6 +nim float_info pylib/Lib/sys_impl/fenvs.html#float_info const float_info 15 +nim rounds pylib/Lib/sys_impl/fenvs.html#rounds.t template rounds(fi: typeof(float_info)): int 31 diff --git a/pylib/Lib/sys_impl/flagsImpl.html b/pylib/Lib/sys_impl/flagsImpl.html new file mode 100644 index 000000000..4cb9af591 --- /dev/null +++ b/pylib/Lib/sys_impl/flagsImpl.html @@ -0,0 +1,128 @@ + + + + + + + +src/pylib/Lib/sys_impl/flagsImpl + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/sys_impl/flagsImpl

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Lets

+
+
+
flags = (debug: debug, inspect: inspect, interactive: interactive,
+         isolated: isolated, optimize: optimize,
+         dont_write_bytecode: dont_write_bytecode, no_user_site: no_user_site,
+         no_site: no_site, ignore_environment: ignore_environment,
+         verbose: verbose, bytes_warning: bytes_warning, quiet: quiet,
+         hash_randomization: hash_randomization, dev_mode: dev_mode,
+         utf8_mode: utf8_mode, safe_path: safe_path,
+         int_max_str_digits: int_max_str_digits,
+         warn_default_encoding: warn_default_encoding)
+
+ + + Source   +Edit   + +
+
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/Lib/sys_impl/flagsImpl.idx b/pylib/Lib/sys_impl/flagsImpl.idx new file mode 100644 index 000000000..adee0c1a9 --- /dev/null +++ b/pylib/Lib/sys_impl/flagsImpl.idx @@ -0,0 +1,2 @@ +nimTitle flagsImpl pylib/Lib/sys_impl/flagsImpl.html module src/pylib/Lib/sys_impl/flagsImpl 0 +nim flags pylib/Lib/sys_impl/flagsImpl.html#flags let flags 1155 diff --git a/pylib/Lib/sys_impl/flagsImpl/ct.html b/pylib/Lib/sys_impl/flagsImpl/ct.html new file mode 100644 index 000000000..b93963041 --- /dev/null +++ b/pylib/Lib/sys_impl/flagsImpl/ct.html @@ -0,0 +1,372 @@ + + + + + + + +src/pylib/Lib/sys_impl/flagsImpl/ct + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/sys_impl/flagsImpl/ct

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

PYTHON* environment variables will be loaded iif pylibUsePyEnv is defined.

+ +
+

Vars

+
+
+
fields {.compileTime.} = newSeqOfCap(18)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Consts

+
+
+
bytes_warning {.intdefine: bytes_warning.toCfgName.} = 0
+
+ + + Source   +Edit   + +
+
+
+
debug {.intdefine: debug.toCfgName.} = 1
+
+ + + Source   +Edit   + +
+
+
+
dev_mode {.booldefine: dev_mode.toCfgName.} = false
+
+ + + Source   +Edit   + +
+
+
+
dont_write_bytecode {.intdefine: dont_write_bytecode.toCfgName.} = 1
+
+ + + Source   +Edit   + +
+
+
+
hash_randomization {.intdefine: hash_randomization.toCfgName.} = 0
+
+ + + Source   +Edit   + +
+
+
+
ignore_environment {.intdefine: ignore_environment.toCfgName.} = 0
+
+ + + Source   +Edit   + +
+
+
+
inspect {.intdefine: inspect.toCfgName.} = 0
+
+ + + Source   +Edit   + +
+
+
+
int_max_str_digits {.intdefine: int_max_str_digits.toCfgName.} = 4300
+
+ + + Source   +Edit   + +
+
+
+
interactive {.intdefine: interactive.toCfgName.} = 0
+
+ + + Source   +Edit   + +
+
+
+
isolated {.intdefine: isolated.toCfgName.} = 0
+
+ + + Source   +Edit   + +
+
+
+
no_site {.intdefine: no_site.toCfgName.} = 0
+
+ + + Source   +Edit   + +
+
+
+
no_user_site {.intdefine: no_user_site.toCfgName.} = 0
+
+ + + Source   +Edit   + +
+
+
+
optimize {.intdefine: optimize.toCfgName.} = 0
+
+ + + Source   +Edit   + +
+
+
+
quiet {.intdefine: quiet.toCfgName.} = 0
+
+ + + Source   +Edit   + +
+
+
+
safe_path {.booldefine: safe_path.toCfgName.} = false
+
+ + + Source   +Edit   + +
+
+
+
utf8_mode {.intdefine: utf8_mode.toCfgName.} = 0
+
+ + + Source   +Edit   + +
+
+
+
verbose {.intdefine: verbose.toCfgName.} = 0
+
+ + + Source   +Edit   + +
+
+
+
warn_default_encoding {.intdefine: warn_default_encoding.toCfgName.} = 0
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Macros

+
+
+
+
macro genFlagsObj()
+
+ + generate let flags* = ... + Source   +Edit   + +
+
+ +
+
+
+
macro redefineFlags(kws: varargs[untyped])
+
+ + used in intermediate file, which wanna define some runtime flags. due to export except's behavior, unknown kws are just ignored. + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/Lib/sys_impl/flagsImpl/ct.idx b/pylib/Lib/sys_impl/flagsImpl/ct.idx new file mode 100644 index 000000000..5eabd1274 --- /dev/null +++ b/pylib/Lib/sys_impl/flagsImpl/ct.idx @@ -0,0 +1,22 @@ +nimTitle ct pylib/Lib/sys_impl/flagsImpl/ct.html module src/pylib/Lib/sys_impl/flagsImpl/ct 0 +nim fields pylib/Lib/sys_impl/flagsImpl/ct.html#fields var fields 9 +nim debug pylib/Lib/sys_impl/flagsImpl/ct.html#debug const debug 22 +nim inspect pylib/Lib/sys_impl/flagsImpl/ct.html#inspect const inspect 22 +nim interactive pylib/Lib/sys_impl/flagsImpl/ct.html#interactive const interactive 22 +nim isolated pylib/Lib/sys_impl/flagsImpl/ct.html#isolated const isolated 22 +nim optimize pylib/Lib/sys_impl/flagsImpl/ct.html#optimize const optimize 22 +nim dont_write_bytecode pylib/Lib/sys_impl/flagsImpl/ct.html#dont_write_bytecode const dont_write_bytecode 22 +nim no_user_site pylib/Lib/sys_impl/flagsImpl/ct.html#no_user_site const no_user_site 22 +nim no_site pylib/Lib/sys_impl/flagsImpl/ct.html#no_site const no_site 22 +nim ignore_environment pylib/Lib/sys_impl/flagsImpl/ct.html#ignore_environment const ignore_environment 22 +nim verbose pylib/Lib/sys_impl/flagsImpl/ct.html#verbose const verbose 22 +nim bytes_warning pylib/Lib/sys_impl/flagsImpl/ct.html#bytes_warning const bytes_warning 22 +nim quiet pylib/Lib/sys_impl/flagsImpl/ct.html#quiet const quiet 22 +nim hash_randomization pylib/Lib/sys_impl/flagsImpl/ct.html#hash_randomization const hash_randomization 22 +nim dev_mode pylib/Lib/sys_impl/flagsImpl/ct.html#dev_mode const dev_mode 18 +nim utf8_mode pylib/Lib/sys_impl/flagsImpl/ct.html#utf8_mode const utf8_mode 22 +nim safe_path pylib/Lib/sys_impl/flagsImpl/ct.html#safe_path const safe_path 18 +nim int_max_str_digits pylib/Lib/sys_impl/flagsImpl/ct.html#int_max_str_digits const int_max_str_digits 22 +nim warn_default_encoding pylib/Lib/sys_impl/flagsImpl/ct.html#warn_default_encoding const warn_default_encoding 22 +nim redefineFlags pylib/Lib/sys_impl/flagsImpl/ct.html#redefineFlags.m,varargs[untyped] macro redefineFlags(kws: varargs[untyped]) 48 +nim genFlagsObj pylib/Lib/sys_impl/flagsImpl/ct.html#genFlagsObj.m macro genFlagsObj() 60 diff --git a/pylib/Lib/sys_impl/flagsImpl/values.html b/pylib/Lib/sys_impl/flagsImpl/values.html new file mode 100644 index 000000000..60b7d1fcc --- /dev/null +++ b/pylib/Lib/sys_impl/flagsImpl/values.html @@ -0,0 +1,233 @@ + + + + + + + +src/pylib/Lib/sys_impl/flagsImpl/values + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/sys_impl/flagsImpl/values

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Lets

+
+
+
debug = ib_i(toPyEnv("debug"), debug)
+
+ + + Source   +Edit   + +
+
+
+
dev_mode = ib_e(toPyEnv("dev_mode"), dev_mode)
+
+ + + Source   +Edit   + +
+
+
+
dont_write_bytecode = ib_b(toPyEnv("dont_write_bytecode"), dont_write_bytecode)
+
+ + + Source   +Edit   + +
+
+
+
inspect = ib_i(toPyEnv("inspect"), inspect)
+
+ + + Source   +Edit   + +
+
+
+
int_max_str_digits = ib_i(toPyEnv("int_max_str_digits"), int_max_str_digits)
+
+ + + Source   +Edit   + +
+
+
+
no_user_site = ib_b(toPyEnv("no_user_site"), no_user_site)
+
+ + + Source   +Edit   + +
+
+
+
optimize = ib_i(toPyEnv("optimize"), optimize)
+
+ + + Source   +Edit   + +
+
+
+
safe_path = ib_e(toPyEnv("safe_path"), safe_path)
+
+ + + Source   +Edit   + +
+
+
+
utf8_mode = ib_i("PYTHONUTF8", utf8_mode)
+
+ + + Source   +Edit   + +
+
+
+
verbose = ib_i(toPyEnv("verbose"), verbose)
+
+ + + Source   +Edit   + +
+
+
+
warn_default_encoding = ib_e(toPyEnv("warn_default_encoding"),
+                             warn_default_encoding)
+
+ + + Source   +Edit   + +
+
+ +
+
+ + +
+
+ + +
+
+ + + diff --git a/pylib/Lib/sys_impl/flagsImpl/values.idx b/pylib/Lib/sys_impl/flagsImpl/values.idx new file mode 100644 index 000000000..ebc05203d --- /dev/null +++ b/pylib/Lib/sys_impl/flagsImpl/values.idx @@ -0,0 +1,12 @@ +nimTitle values pylib/Lib/sys_impl/flagsImpl/values.html module src/pylib/Lib/sys_impl/flagsImpl/values 0 +nim debug pylib/Lib/sys_impl/flagsImpl/values.html#debug let debug 20 +nim verbose pylib/Lib/sys_impl/flagsImpl/values.html#verbose let verbose 20 +nim optimize pylib/Lib/sys_impl/flagsImpl/values.html#optimize let optimize 20 +nim inspect pylib/Lib/sys_impl/flagsImpl/values.html#inspect let inspect 20 +nim dont_write_bytecode pylib/Lib/sys_impl/flagsImpl/values.html#dont_write_bytecode let dont_write_bytecode 20 +nim no_user_site pylib/Lib/sys_impl/flagsImpl/values.html#no_user_site let no_user_site 20 +nim safe_path pylib/Lib/sys_impl/flagsImpl/values.html#safe_path let safe_path 20 +nim int_max_str_digits pylib/Lib/sys_impl/flagsImpl/values.html#int_max_str_digits let int_max_str_digits 20 +nim utf8_mode pylib/Lib/sys_impl/flagsImpl/values.html#utf8_mode let utf8_mode 20 +nim dev_mode pylib/Lib/sys_impl/flagsImpl/values.html#dev_mode let dev_mode 20 +nim warn_default_encoding pylib/Lib/sys_impl/flagsImpl/values.html#warn_default_encoding let warn_default_encoding 20 diff --git a/pylib/Lib/sys_impl/genargs.html b/pylib/Lib/sys_impl/genargs.html new file mode 100644 index 000000000..b4831b25b --- /dev/null +++ b/pylib/Lib/sys_impl/genargs.html @@ -0,0 +1,109 @@ + + + + + + + +src/pylib/Lib/sys_impl/genargs + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/sys_impl/genargs

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Templates

+
+
+
+
template genArgs(St, Ls; S; lsCopy, lsOfCap) {.dirty.}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/Lib/sys_impl/genargs.idx b/pylib/Lib/sys_impl/genargs.idx new file mode 100644 index 000000000..db0dda5e3 --- /dev/null +++ b/pylib/Lib/sys_impl/genargs.idx @@ -0,0 +1,2 @@ +nimTitle genargs pylib/Lib/sys_impl/genargs.html module src/pylib/Lib/sys_impl/genargs 0 +nim genArgs pylib/Lib/sys_impl/genargs.html#genArgs.t,,,,, template genArgs(St, Ls; S; lsCopy, lsOfCap) 23 diff --git a/pylib/Lib/sys_impl/geninfos.html b/pylib/Lib/sys_impl/geninfos.html new file mode 100644 index 000000000..2c414da68 --- /dev/null +++ b/pylib/Lib/sys_impl/geninfos.html @@ -0,0 +1,118 @@ + + + + + + + +src/pylib/Lib/sys_impl/geninfos + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/sys_impl/geninfos

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Templates

+
+
+
+
template genInfos(S; cache_tag_val) {.dirty.}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/Lib/sys_impl/geninfos.idx b/pylib/Lib/sys_impl/geninfos.idx new file mode 100644 index 000000000..3b6ac3116 --- /dev/null +++ b/pylib/Lib/sys_impl/geninfos.idx @@ -0,0 +1,2 @@ +nimTitle geninfos pylib/Lib/sys_impl/geninfos.html module src/pylib/Lib/sys_impl/geninfos 0 +nim genInfos pylib/Lib/sys_impl/geninfos.html#genInfos.t,, template genInfos(S; cache_tag_val) 28 diff --git a/pylib/Lib/sys_impl/genplatform.html b/pylib/Lib/sys_impl/genplatform.html new file mode 100644 index 000000000..b52e7ad65 --- /dev/null +++ b/pylib/Lib/sys_impl/genplatform.html @@ -0,0 +1,149 @@ + + + + + + + +src/pylib/Lib/sys_impl/genplatform + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/sys_impl/genplatform

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
proc getPlatform(): string {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template genPlatform(S) {.dirty.}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/Lib/sys_impl/genplatform.idx b/pylib/Lib/sys_impl/genplatform.idx new file mode 100644 index 000000000..e45cfecc9 --- /dev/null +++ b/pylib/Lib/sys_impl/genplatform.idx @@ -0,0 +1,3 @@ +nimTitle genplatform pylib/Lib/sys_impl/genplatform.html module src/pylib/Lib/sys_impl/genplatform 0 +nim getPlatform pylib/Lib/sys_impl/genplatform.html#getPlatform proc getPlatform(): string 21 +nim genPlatform pylib/Lib/sys_impl/genplatform.html#genPlatform.t template genPlatform(S) 53 diff --git a/pylib/Lib/sys_impl/getencodings.html b/pylib/Lib/sys_impl/getencodings.html new file mode 100644 index 000000000..c08313ce0 --- /dev/null +++ b/pylib/Lib/sys_impl/getencodings.html @@ -0,0 +1,137 @@ + + + + + + + +src/pylib/Lib/sys_impl/getencodings + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/sys_impl/getencodings

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
proc getdefaultencoding(): string {....raises: [], tags: [], forbids: [].}
+
+ +

Return the current default encoding used by the Unicode implementation.

+

Always "utf-8" in Nim

+ + Source   +Edit   + +
+
+ +
+
+
+
proc getfilesystemencoding(): string {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/Lib/sys_impl/getencodings.idx b/pylib/Lib/sys_impl/getencodings.idx new file mode 100644 index 000000000..542913e5a --- /dev/null +++ b/pylib/Lib/sys_impl/getencodings.idx @@ -0,0 +1,3 @@ +nimTitle getencodings pylib/Lib/sys_impl/getencodings.html module src/pylib/Lib/sys_impl/getencodings 0 +nim getdefaultencoding pylib/Lib/sys_impl/getencodings.html#getdefaultencoding proc getdefaultencoding(): string 30 +nim getfilesystemencoding pylib/Lib/sys_impl/getencodings.html#getfilesystemencoding proc getfilesystemencoding(): string 111 diff --git a/pylib/Lib/sys_impl/sizes.html b/pylib/Lib/sys_impl/sizes.html new file mode 100644 index 000000000..230d916e9 --- /dev/null +++ b/pylib/Lib/sys_impl/sizes.html @@ -0,0 +1,120 @@ + + + + + + + +src/pylib/Lib/sys_impl/sizes + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/sys_impl/sizes

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Templates

+
+
+
+
template getsizeof(x): int
+
+ + + Source   +Edit   + +
+
+
+
template getsizeof(x; default: int): int
+
+ + may be used when sizeof(x) is a compile-error e.g. func sizeof(x: O): int{.error.} for O + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/Lib/sys_impl/sizes.idx b/pylib/Lib/sys_impl/sizes.idx new file mode 100644 index 000000000..73739f6b7 --- /dev/null +++ b/pylib/Lib/sys_impl/sizes.idx @@ -0,0 +1,4 @@ +nimTitle sizes pylib/Lib/sys_impl/sizes.html module src/pylib/Lib/sys_impl/sizes 0 +nim getsizeof pylib/Lib/sys_impl/sizes.html#getsizeof.t template getsizeof(x): int 2 +nim getsizeof pylib/Lib/sys_impl/sizes.html#getsizeof.t,,int template getsizeof(x; default: int): int 6 +nimgrp getsizeof pylib/Lib/sys_impl/sizes.html#getsizeof-templates-all template 2 diff --git a/pylib/Lib/sys_impl/stdio.html b/pylib/Lib/sys_impl/stdio.html new file mode 100644 index 000000000..b744f7ef4 --- /dev/null +++ b/pylib/Lib/sys_impl/stdio.html @@ -0,0 +1,190 @@ + + + + + + + +src/pylib/Lib/sys_impl/stdio + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/sys_impl/stdio

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Imports

+
+ util, ../io +
+
+
+

Vars

+
+
+
stderr = newNoEncTextIO(stderr, "<stderr>", DefNewLine)
+
+ + + Source   +Edit   + +
+
+
+
stdin = newNoEncTextIO(stdin, "<stdin>", DefNewLine)
+
+ + + Source   +Edit   + +
+
+
+
stdout = newNoEncTextIO(stdout, "<stdout>", DefNewLine)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Lets

+
+
+
dunder_stderr = stderr
+
+ + __stderr__ + Source   +Edit   + +
+
+
+
dunder_stdin = stdin
+
+ + __stdin__ + Source   +Edit   + +
+
+
+
dunder_stdout = stdout
+
+ + __stdout__ + Source   +Edit   + +
+
+ +
+
+ + +
+
+ + +
+
+ + + diff --git a/pylib/Lib/sys_impl/stdio.idx b/pylib/Lib/sys_impl/stdio.idx new file mode 100644 index 000000000..cb7783713 --- /dev/null +++ b/pylib/Lib/sys_impl/stdio.idx @@ -0,0 +1,7 @@ +nimTitle stdio pylib/Lib/sys_impl/stdio.html module src/pylib/Lib/sys_impl/stdio 0 +nim stdin pylib/Lib/sys_impl/stdio.html#stdin var stdin 11 +nim stdout pylib/Lib/sys_impl/stdio.html#stdout var stdout 11 +nim stderr pylib/Lib/sys_impl/stdio.html#stderr var stderr 11 +nim dunder_stdin pylib/Lib/sys_impl/stdio.html#dunder_stdin let dunder_stdin 23 +nim dunder_stdout pylib/Lib/sys_impl/stdio.html#dunder_stdout let dunder_stdout 24 +nim dunder_stderr pylib/Lib/sys_impl/stdio.html#dunder_stderr let dunder_stderr 25 diff --git a/pylib/Lib/sys_impl/util.html b/pylib/Lib/sys_impl/util.html new file mode 100644 index 000000000..cb2a0b5f6 --- /dev/null +++ b/pylib/Lib/sys_impl/util.html @@ -0,0 +1,121 @@ + + + + + + + +src/pylib/Lib/sys_impl/util + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/sys_impl/util

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+ +
+ + +
+
+ + + diff --git a/pylib/Lib/sys_impl/util.idx b/pylib/Lib/sys_impl/util.idx new file mode 100644 index 000000000..3e1355156 --- /dev/null +++ b/pylib/Lib/sys_impl/util.idx @@ -0,0 +1,2 @@ +nimTitle util pylib/Lib/sys_impl/util.html module src/pylib/Lib/sys_impl/util 0 +nim weirdTarget pylib/Lib/sys_impl/util.html#weirdTarget const weirdTarget 2 diff --git a/pylib/Lib/time.html b/pylib/Lib/time.html new file mode 100644 index 000000000..ff32bd8e7 --- /dev/null +++ b/pylib/Lib/time.html @@ -0,0 +1,251 @@ + + + + + + + +src/pylib/Lib/time + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/time

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

time

+

Currently the implementation is n_time module . The following is its doc:

+
Warning: +A few of the format directives for strftime/strptime are not supported, and using them causes AssertDefect. They are listed in nstrfptime.NotImplDirectives
+
Hint: +Some directives (only for strftime) whose implementents are platform-depend in CPython are always supported here: '%V' '%G' '%g'
+

+ +
+

Consts

+
+
+
DefaultTimeFormat = "%a %b %d %H:%M:%S %Y"
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
proc asctime(): PyStr {....raises: [], tags: [TimeEffect], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func asctime(t: Some_struct_time): PyStr
+
+ + +

Example:

+
assert asctime(gmtime(0)) == "Thu Jan  1 00:00:00 1970"
+ Source   +Edit   + +
+
+ +
+
+
+
proc ctime(): PyStr {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc ctime(secs: float | int64): PyStr
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc strftime(format: PyStr): PyStr {....raises: [], tags: [TimeEffect],
+                                      forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func strftime(format: PyStr; st: Some_struct_time): PyStr
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc strptime(s: PyStr; format = DefaultTimeFormat): struct_time {.
+    ...raises: [ValueError, TimeParseError, TimeFormatParseError],
+    tags: [TimeEffect], forbids: [].}
+
+ +
Warning: +In current implementation, whitespace in format string means itself AS-IS, unlike C or Python, where any whitespace means a serial of any whitespaces. If really wanting the behavior of C's, consider using std/strscan.
+
Warning: +Current strptime is just locale-unaware, when it comes to "the locale's format", like "%x", it always uses the format of "C" locale, no matter what the locale is. a.k.a. Changing locale via C's api in <locale.h> doesn't affect this function.
+ + Source   +Edit   + +
+
+ +
+ +
+
+ + +
+
+ + +
+
+ + + diff --git a/pylib/Lib/time.idx b/pylib/Lib/time.idx new file mode 100644 index 000000000..505d4a588 --- /dev/null +++ b/pylib/Lib/time.idx @@ -0,0 +1,12 @@ +nimTitle time pylib/Lib/time.html module src/pylib/Lib/time 0 +nim DefaultTimeFormat pylib/Lib/time.html#DefaultTimeFormat const DefaultTimeFormat 17 +nim asctime pylib/Lib/time.html#asctime proc asctime(): PyStr 19 +nim asctime pylib/Lib/time.html#asctime,Some_struct_time proc asctime(t: Some_struct_time): PyStr 22 +nim ctime pylib/Lib/time.html#ctime proc ctime(): PyStr 27 +nim ctime pylib/Lib/time.html#ctime_2 proc ctime(secs: float | int64): PyStr 28 +nim strftime pylib/Lib/time.html#strftime,PyStr,Some_struct_time proc strftime(format: PyStr; st: Some_struct_time): PyStr 31 +nim strftime pylib/Lib/time.html#strftime,PyStr proc strftime(format: PyStr): PyStr 34 +nim strptime pylib/Lib/time.html#strptime,PyStr proc strptime(s: PyStr; format = DefaultTimeFormat): struct_time 38 +nimgrp strftime pylib/Lib/time.html#strftime-procs-all proc 31 +nimgrp asctime pylib/Lib/time.html#asctime-procs-all proc 19 +nimgrp ctime pylib/Lib/time.html#ctime-procs-all proc 27 diff --git a/pylib/Lib/time_impl/asctimeImpl.html b/pylib/Lib/time_impl/asctimeImpl.html new file mode 100644 index 000000000..d25399b5f --- /dev/null +++ b/pylib/Lib/time_impl/asctimeImpl.html @@ -0,0 +1,140 @@ + + + + + + + +src/pylib/Lib/time_impl/asctimeImpl + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/time_impl/asctimeImpl

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

asctime that returns string

+
+

Procs

+
+
+
+
func asctime(dt: DateTime): string {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template asctimeImpl(result: string; dt: DateTime)
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/Lib/time_impl/asctimeImpl.idx b/pylib/Lib/time_impl/asctimeImpl.idx new file mode 100644 index 000000000..7572ecc8d --- /dev/null +++ b/pylib/Lib/time_impl/asctimeImpl.idx @@ -0,0 +1,3 @@ +nimTitle asctimeImpl pylib/Lib/time_impl/asctimeImpl.html module src/pylib/Lib/time_impl/asctimeImpl 0 +nim asctimeImpl pylib/Lib/time_impl/asctimeImpl.html#asctimeImpl.t,string,DateTime template asctimeImpl(result: string; dt: DateTime) 5 +nim asctime pylib/Lib/time_impl/asctimeImpl.html#asctime,DateTime proc asctime(dt: DateTime): string 15 diff --git a/pylib/Lib/time_impl/converters.html b/pylib/Lib/time_impl/converters.html new file mode 100644 index 000000000..55289289b --- /dev/null +++ b/pylib/Lib/time_impl/converters.html @@ -0,0 +1,253 @@ + + + + + + + +src/pylib/Lib/time_impl/converters + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/time_impl/converters

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
func dtToStructTime(dt: DateTime; res: var struct_time) {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func struct_time(tup`gensym0: struct_time_tuple): struct_time {....raises: [],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func struct_time(tup`gensym2: struct_time_tuple10): struct_time {....raises: [],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func struct_time(tup`gensym4: struct_time_tuple11): struct_time {....raises: [],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func structTimeToDt(st: struct_time; res: var DateTime) {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Converters

+
+
+
+
converter toTuple(st: struct_time): struct_time_tuple {....raises: [], tags: [],
+    forbids: [].}
+
+ + XXX: tuple is Nim's keyword, so no symbol can be named tuple + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template wrapTuple(sym) {.dirty.}
+
+ + wrap a func sym(struct_time) to accept struct_time_tuple*, too. + Source   +Edit   + +
+
+
+
template wrapTuple(sym, tupType) {.dirty.}
+
+ + wrap a func sym(struct_time) to accept tupType too. + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/Lib/time_impl/converters.idx b/pylib/Lib/time_impl/converters.idx new file mode 100644 index 000000000..ed191a5f2 --- /dev/null +++ b/pylib/Lib/time_impl/converters.idx @@ -0,0 +1,11 @@ +nimTitle converters pylib/Lib/time_impl/converters.html module src/pylib/Lib/time_impl/converters 0 +nim wrapTuple pylib/Lib/time_impl/converters.html#wrapTuple.t,, template wrapTuple(sym, tupType) 6 +nim wrapTuple pylib/Lib/time_impl/converters.html#wrapTuple.t template wrapTuple(sym) 15 +nim struct_time pylib/Lib/time_impl/converters.html#struct_time,struct_time_tuple proc struct_time(tup`gensym0: struct_time_tuple): struct_time 27 +nim struct_time pylib/Lib/time_impl/converters.html#struct_time,struct_time_tuple10 proc struct_time(tup`gensym2: struct_time_tuple10): struct_time 28 +nim struct_time pylib/Lib/time_impl/converters.html#struct_time,struct_time_tuple11 proc struct_time(tup`gensym4: struct_time_tuple11): struct_time 29 +nim toTuple pylib/Lib/time_impl/converters.html#toTuple.c,struct_time converter toTuple(st: struct_time): struct_time_tuple 31 +nim dtToStructTime pylib/Lib/time_impl/converters.html#dtToStructTime,DateTime,struct_time proc dtToStructTime(dt: DateTime; res: var struct_time) 45 +nim structTimeToDt pylib/Lib/time_impl/converters.html#structTimeToDt,struct_time,DateTime proc structTimeToDt(st: struct_time; res: var DateTime) 60 +nimgrp structtime pylib/Lib/time_impl/converters.html#struct_time-procs-all proc 23 +nimgrp wraptuple pylib/Lib/time_impl/converters.html#wrapTuple-templates-all template 6 diff --git a/pylib/Lib/time_impl/measures.html b/pylib/Lib/time_impl/measures.html new file mode 100644 index 000000000..85c6caa89 --- /dev/null +++ b/pylib/Lib/time_impl/measures.html @@ -0,0 +1,213 @@ + + + + + + + +src/pylib/Lib/time_impl/measures + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/time_impl/measures

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

Hint: +all functions are pretended as noSideEffect pramga, as I myself doesn't think noSideEffect means pure function, but pure function is must noSideEffect, the opposite is not true. However, Nim manual seems to mixin them.
+

+
+

Procs

+
+
+
+
func monotonic(): float {....raises: [], tags: [TimeEffect], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func monotonic_ns(): int64 {....raises: [], tags: [TimeEffect], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func perf_counter(): float {....raises: [], tags: [TimeEffect], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func perf_counter_ns(): int64 {....raises: [], tags: [TimeEffect], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func process_time(): float {....raises: [], tags: [TimeEffect], forbids: [].}
+
+ + not available for JS backend, currently. + Source   +Edit   + +
+
+ +
+
+
+
func time(): float {....raises: [], tags: [TimeEffect], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func time_ns(): int64 {....raises: [], tags: [TimeEffect], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/Lib/time_impl/measures.idx b/pylib/Lib/time_impl/measures.idx new file mode 100644 index 000000000..d6e260606 --- /dev/null +++ b/pylib/Lib/time_impl/measures.idx @@ -0,0 +1,8 @@ +nimTitle measures pylib/Lib/time_impl/measures.html module src/pylib/Lib/time_impl/measures 0 +nim time pylib/Lib/time_impl/measures.html#time proc time(): float 11 +nim time_ns pylib/Lib/time_impl/measures.html#time_ns proc time_ns(): int64 16 +nim process_time pylib/Lib/time_impl/measures.html#process_time proc process_time(): float 24 +nim monotonic_ns pylib/Lib/time_impl/measures.html#monotonic_ns proc monotonic_ns(): int64 29 +nim monotonic pylib/Lib/time_impl/measures.html#monotonic proc monotonic(): float 36 +nim perf_counter pylib/Lib/time_impl/measures.html#perf_counter proc perf_counter(): float 45 +nim perf_counter_ns pylib/Lib/time_impl/measures.html#perf_counter_ns proc perf_counter_ns(): int64 46 diff --git a/pylib/Lib/time_impl/nstrfptime.html b/pylib/Lib/time_impl/nstrfptime.html new file mode 100644 index 000000000..3ab96524e --- /dev/null +++ b/pylib/Lib/time_impl/nstrfptime.html @@ -0,0 +1,215 @@ + + + + + + + +src/pylib/Lib/time_impl/nstrfptime + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/time_impl/nstrfptime

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

strftime, strptime

+

platform independent implementation.

+

+ +
+

Lets

+
+
+
docTable {.compileTime.} = docTableInner
+
+ + + used to transport doc string to outer module. + Source   +Edit   + +
+
+ +
+
+
+

Consts

+
+
+
NotImplDirectives = {'y', 'Z'}
+
+ +

Here are their concrete meanings in Python, as well as some notes about why they cannot be directly mapped to Nim's DateTime.format/parse.

+

The direct alternative value when formatting in Nim, if any, is introduced by <-:

+
  • y: Year without century as a decimal number [00,99]. <- DateTime.format"yy" When parsing, C/Python's %y use 20th or 21th centry depending on the value of %y Nim's yy use the current century
  • +
  • Z: Time zone name (no characters if no time zone exists). Deprecated. However, this is supported in Lib/datetime
  • +
+

Following are strftime only currently:

+
  • j: Day of the year as a decimal number [001,366]. <- DateTime.yearday + 1
  • +
  • u: Weekday [0(Monday), 6]. <- DateTime.weekday.int
  • +
  • w: Weekday [0(Sunday),6]. <- (DateTime.weekday.int + 1) mod 7
  • +
  • U: Week number of the year (Sunday as the first day of the week) as a decimal number [00,53]. All days in a new year preceding the first Sunday are considered to be in week 0.
  • +
+ + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
func strftime(format: string; dt: DateTime): string {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc strptime(dt: var DateTime; s: string; format_with_sp_asis: string) {.
+    ...raises: [ValueError, TimeParseError, TimeFormatParseError],
+    tags: [TimeEffect], forbids: [].}
+
+ +
Warning: +In current implementation, whitespace in format string means itself AS-IS, unlike C or Python, where any whitespace means a serial of any whitespaces. If really wanting the behavior of C's, consider using std/strscan.
+
Warning: +Current strptime is just locale-unaware, when it comes to "the locale's format", like "%x", it always uses the format of "C" locale, no matter what the locale is. a.k.a. Changing locale via C's api in <locale.h> doesn't affect this function.
+ + Source   +Edit   + +
+
+ +
+ +
+
+ + +
+
+ + +
+
+ + + diff --git a/pylib/Lib/time_impl/nstrfptime.idx b/pylib/Lib/time_impl/nstrfptime.idx new file mode 100644 index 000000000..f2f40f66e --- /dev/null +++ b/pylib/Lib/time_impl/nstrfptime.idx @@ -0,0 +1,5 @@ +nimTitle nstrfptime pylib/Lib/time_impl/nstrfptime.html module src/pylib/Lib/time_impl/nstrfptime 0 +nim docTable pylib/Lib/time_impl/nstrfptime.html#docTable let docTable 22 +nim NotImplDirectives pylib/Lib/time_impl/nstrfptime.html#NotImplDirectives const NotImplDirectives 30 +nim strftime pylib/Lib/time_impl/nstrfptime.html#strftime,string,DateTime proc strftime(format: string; dt: DateTime): string 144 +nim strptime pylib/Lib/time_impl/nstrfptime.html#strptime,DateTime,string,string proc strptime(dt: var DateTime; s: string; format_with_sp_asis: string) 192 diff --git a/pylib/Lib/time_impl/private/doc_utils.html b/pylib/Lib/time_impl/private/doc_utils.html new file mode 100644 index 000000000..4255449bb --- /dev/null +++ b/pylib/Lib/time_impl/private/doc_utils.html @@ -0,0 +1,179 @@ + + + + + + + +src/pylib/Lib/time_impl/private/doc_utils + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/time_impl/private/doc_utils

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Types

+
+
+
DocTable = object
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
func initDocTable(moduleDoc: string; init: openArray[(string, string)]): DocTable {.
+    compileTime, ...raises: [], tags: [], forbids: [].}
+
+ +
Hint: +key "" stands for the module level doc.
+ + Source   +Edit   + +
+
+ +
+ +
+
+
+

Macros

+
+
+
+
macro fetchDoc(tab: static DocTable)
+
+ + used for fetch module level doc + Source   +Edit   + +
+
+
+
macro fetchDoc(tab: static DocTable; def)
+
+ + used as proc's pragma to fetch doc + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/Lib/time_impl/private/doc_utils.idx b/pylib/Lib/time_impl/private/doc_utils.idx new file mode 100644 index 000000000..7634a1f1d --- /dev/null +++ b/pylib/Lib/time_impl/private/doc_utils.idx @@ -0,0 +1,6 @@ +nimTitle doc_utils pylib/Lib/time_impl/private/doc_utils.html module src/pylib/Lib/time_impl/private/doc_utils 0 +nim DocTable pylib/Lib/time_impl/private/doc_utils.html#DocTable object DocTable 4 +nim initDocTable pylib/Lib/time_impl/private/doc_utils.html#initDocTable,string,openArray[] proc initDocTable(moduleDoc: string; init: openArray[(string, string)]): DocTable 11 +nim fetchDoc pylib/Lib/time_impl/private/doc_utils.html#fetchDoc.m,staticDocTable macro fetchDoc(tab: static DocTable) 26 +nim fetchDoc pylib/Lib/time_impl/private/doc_utils.html#fetchDoc.m,staticDocTable, macro fetchDoc(tab: static DocTable; def) 31 +nimgrp fetchdoc pylib/Lib/time_impl/private/doc_utils.html#fetchDoc-macros-all macro 26 diff --git a/pylib/Lib/time_impl/private/macro_utils.html b/pylib/Lib/time_impl/private/macro_utils.html new file mode 100644 index 000000000..4c1113a15 --- /dev/null +++ b/pylib/Lib/time_impl/private/macro_utils.html @@ -0,0 +1,235 @@ + + + + + + + +src/pylib/Lib/time_impl/private/macro_utils + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/time_impl/private/macro_utils

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Types

+
+
+
CmpStragy = enum
+  csEq, csLhs, csRhs, csShorter ## stop on the shorter one.
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Macros

+
+
+
+
macro addFields(res: string; obj: typed; noMoreThan: static[int] = int.high)
+
+ +

obj is of object or ref object. when obj is of object and noMoreThan is not given, it's roughly equal to:

+

let startLen = res.len
+for k, v in o.fieldPairs:
+  res.addSep(sep=", ", startLen = startLen)
+  res.add k & '=' & repr v

+ + Source   +Edit   + +
+
+ +
+
+
+
macro asgSeqToObj(tup, obj: typed)
+
+ + obj can be of ref object or object Retionale: there is fields/fieldPairs iterator in std/system, but for tuple/object only, not for ref object. + Source   +Edit   + +
+
+ +
+
+
+
macro cmpOnField(a, b: typed): int
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
macro declTupleWithNFieldsFrom(name: untyped; Cls: typedesc; n: static[int];
+                               exported: static[bool] = true)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
macro mixinOrderOnFields(lhs, rhs: typed; cmpOp;
+                         cmpStragy: static[CmpStragy] = csEq): bool
+
+ +

cmpOnFields but a b can be of different types.

+

e.g. a is tuple and b is object; or a, b are different objects.

+ + Source   +Edit   + +
+
+ +
+
+
+
macro orderOnFields[T](a, b: T; cmpOp): bool
+
+ +

mainly for checking if ref objects are equal on fields

+

when for object/tuple and cmpOp is ==, roughly equal to: a == b

+

but system.== for ref just compare the address.

+ + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/Lib/time_impl/private/macro_utils.idx b/pylib/Lib/time_impl/private/macro_utils.idx new file mode 100644 index 000000000..83d98c725 --- /dev/null +++ b/pylib/Lib/time_impl/private/macro_utils.idx @@ -0,0 +1,12 @@ +nimTitle macro_utils pylib/Lib/time_impl/private/macro_utils.html module src/pylib/Lib/time_impl/private/macro_utils 0 +nim asgSeqToObj pylib/Lib/time_impl/private/macro_utils.html#asgSeqToObj.m,typed,typed macro asgSeqToObj(tup, obj: typed) 71 +nim declTupleWithNFieldsFrom pylib/Lib/time_impl/private/macro_utils.html#declTupleWithNFieldsFrom.m,untyped,typedesc,static[int],static[bool] macro declTupleWithNFieldsFrom(name: untyped; Cls: typedesc; n: static[int];\n exported: static[bool] = true) 117 +nim addFields pylib/Lib/time_impl/private/macro_utils.html#addFields.m,string,typed,static[int] macro addFields(res: string; obj: typed; noMoreThan: static[int] = int.high) 137 +nim csEq pylib/Lib/time_impl/private/macro_utils.html#csEq CmpStragy.csEq 170 +nim csLhs pylib/Lib/time_impl/private/macro_utils.html#csLhs CmpStragy.csLhs 170 +nim csRhs pylib/Lib/time_impl/private/macro_utils.html#csRhs CmpStragy.csRhs 170 +nim csShorter pylib/Lib/time_impl/private/macro_utils.html#csShorter CmpStragy.csShorter 170 +nim CmpStragy pylib/Lib/time_impl/private/macro_utils.html#CmpStragy enum CmpStragy 170 +nim mixinOrderOnFields pylib/Lib/time_impl/private/macro_utils.html#mixinOrderOnFields.m,typed,typed,,static[CmpStragy] macro mixinOrderOnFields(lhs, rhs: typed; cmpOp; cmpStragy: static[CmpStragy] = csEq): bool 206 +nim orderOnFields pylib/Lib/time_impl/private/macro_utils.html#orderOnFields.m,T,T, macro orderOnFields[T](a, b: T; cmpOp): bool 215 +nim cmpOnField pylib/Lib/time_impl/private/macro_utils.html#cmpOnField.m,typed,typed macro cmpOnField(a, b: typed): int 257 diff --git a/pylib/Lib/time_impl/sleep_impl.html b/pylib/Lib/time_impl/sleep_impl.html new file mode 100644 index 000000000..e8091b894 --- /dev/null +++ b/pylib/Lib/time_impl/sleep_impl.html @@ -0,0 +1,118 @@ + + + + + + + +src/pylib/Lib/time_impl/sleep_impl + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/time_impl/sleep_impl

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Templates

+
+
+
+
template sleep(s: int | float)
+
+ + raises ValueError if s < 0 + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/Lib/time_impl/sleep_impl.idx b/pylib/Lib/time_impl/sleep_impl.idx new file mode 100644 index 000000000..b66653ee4 --- /dev/null +++ b/pylib/Lib/time_impl/sleep_impl.idx @@ -0,0 +1,2 @@ +nimTitle sleep_impl pylib/Lib/time_impl/sleep_impl.html module src/pylib/Lib/time_impl/sleep_impl 0 +nim sleep pylib/Lib/time_impl/sleep_impl.html#sleep.t template sleep(s: int | float) 28 diff --git a/pylib/Lib/time_impl/strfptime.html b/pylib/Lib/time_impl/strfptime.html new file mode 100644 index 000000000..0045eeef0 --- /dev/null +++ b/pylib/Lib/time_impl/strfptime.html @@ -0,0 +1,177 @@ + + + + + + + +src/pylib/Lib/time_impl/strfptime + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/time_impl/strfptime

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

Warning: +A few of the format directives for strftime/strptime are not supported, and using them causes AssertDefect. They are listed in nstrfptime.NotImplDirectives
+
Hint: +Some directives (only for strftime) whose implementents are platform-depend in CPython are always supported here: '%V' '%G' '%g'
+

+ +
+

Procs

+
+
+
+
func strftime(format: string; st: Some_struct_time_tuple): string
+
+ + + Source   +Edit   + +
+
+
+
func strftime(format: string; st: struct_time): string {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func strftime[S](format: S; st: struct_time): S
+
+ + EXT. + Source   +Edit   + +
+
+ +
+
+
+
proc strptime(s: string; f: string): struct_time {.
+    ...raises: [ValueError, TimeParseError, TimeFormatParseError],
+    tags: [TimeEffect], forbids: [].}
+
+ +
Warning: +In current implementation, whitespace in format string means itself AS-IS, unlike C or Python, where any whitespace means a serial of any whitespaces. If really wanting the behavior of C's, consider using std/strscan.
+
Warning: +Current strptime is just locale-unaware, when it comes to "the locale's format", like "%x", it always uses the format of "C" locale, no matter what the locale is. a.k.a. Changing locale via C's api in <locale.h> doesn't affect this function.
+ + Source   +Edit   + +
+
+ +
+ +
+
+ + +
+
+ + +
+
+ + + diff --git a/pylib/Lib/time_impl/strfptime.idx b/pylib/Lib/time_impl/strfptime.idx new file mode 100644 index 000000000..bac336166 --- /dev/null +++ b/pylib/Lib/time_impl/strfptime.idx @@ -0,0 +1,6 @@ +nimTitle strfptime pylib/Lib/time_impl/strfptime.html module src/pylib/Lib/time_impl/strfptime 0 +nim strftime pylib/Lib/time_impl/strfptime.html#strftime,string,struct_time proc strftime(format: string; st: struct_time): string 7 +nim strftime pylib/Lib/time_impl/strfptime.html#strftime,S,struct_time proc strftime[S](format: S; st: struct_time): S 12 +nim strftime pylib/Lib/time_impl/strfptime.html#strftime,string,Some_struct_time_tuple proc strftime(format: string; st: Some_struct_time_tuple): string 17 +nim strptime pylib/Lib/time_impl/strfptime.html#strptime,string,string proc strptime(s: string; f: string): struct_time 20 +nimgrp strftime pylib/Lib/time_impl/strfptime.html#strftime-procs-all proc 7 diff --git a/pylib/Lib/time_impl/struct_time_funcs.html b/pylib/Lib/time_impl/struct_time_funcs.html new file mode 100644 index 000000000..ca5961a3f --- /dev/null +++ b/pylib/Lib/time_impl/struct_time_funcs.html @@ -0,0 +1,216 @@ + + + + + + + +src/pylib/Lib/time_impl/struct_time_funcs + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/time_impl/struct_time_funcs

+
+ +
+ Source   +Edit   + +
+ +

funcs about struct_time

+

its initializer, and a inverse function mktime

+

+ +
+

Procs

+
+
+
+
proc gmtime(): struct_time {....raises: [], tags: [TimeEffect], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc gmtime(secs: float): struct_time {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc gmtime(secs: int64): struct_time {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc localtime(): struct_time {....raises: [], tags: [TimeEffect], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc localtime(secs: float): struct_time {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc localtime(secs: int64): struct_time {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func mktime(t: struct_time): float {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func mktime(tup: struct_time_tuple): typeof(mktime do:
+  bind struct_time
+  struct_time(tm_year: 1900, tm_mon: 1, tm_mday: 1, tm_yday: 1, tm_isdst: -1)) {.
+    ...raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/Lib/time_impl/struct_time_funcs.idx b/pylib/Lib/time_impl/struct_time_funcs.idx new file mode 100644 index 000000000..803f24c53 --- /dev/null +++ b/pylib/Lib/time_impl/struct_time_funcs.idx @@ -0,0 +1,12 @@ +nimTitle struct_time_funcs pylib/Lib/time_impl/struct_time_funcs.html module src/pylib/Lib/time_impl/struct_time_funcs 0 +nim gmtime pylib/Lib/time_impl/struct_time_funcs.html#gmtime proc gmtime(): struct_time 8 +nim localtime pylib/Lib/time_impl/struct_time_funcs.html#localtime proc localtime(): struct_time 9 +nim gmtime pylib/Lib/time_impl/struct_time_funcs.html#gmtime,int64 proc gmtime(secs: int64): struct_time 11 +nim localtime pylib/Lib/time_impl/struct_time_funcs.html#localtime,int64 proc localtime(secs: int64): struct_time 16 +nim gmtime pylib/Lib/time_impl/struct_time_funcs.html#gmtime,float proc gmtime(secs: float): struct_time 21 +nim localtime pylib/Lib/time_impl/struct_time_funcs.html#localtime,float proc localtime(secs: float): struct_time 26 +nim mktime pylib/Lib/time_impl/struct_time_funcs.html#mktime,struct_time proc mktime(t: struct_time): float 32 +nim mktime pylib/Lib/time_impl/struct_time_funcs.html#mktime,struct_time_tuple proc mktime(tup: struct_time_tuple): typeof(mktime do:\n bind struct_time\n struct_time(tm_year: 1900, tm_mon: 1, tm_mday: 1, tm_yday: 1, tm_isdst: -1)) 37 +nimgrp localtime pylib/Lib/time_impl/struct_time_funcs.html#localtime-procs-all proc 9 +nimgrp mktime pylib/Lib/time_impl/struct_time_funcs.html#mktime-procs-all proc 32 +nimgrp gmtime pylib/Lib/time_impl/struct_time_funcs.html#gmtime-procs-all proc 8 diff --git a/pylib/Lib/time_impl/types.html b/pylib/Lib/time_impl/types.html new file mode 100644 index 000000000..1d48c73fa --- /dev/null +++ b/pylib/Lib/time_impl/types.html @@ -0,0 +1,497 @@ + + + + + + + +src/pylib/Lib/time_impl/types + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/time_impl/types

+
+ +
+ Source   +Edit   + +
+ +

+ +
+

Types

+
+ + +
+
struct_time = ref object
+  tm_year*: int
+  tm_mon*: range[1 .. 12]
+  tm_mday*: MonthdayRange
+  tm_hour*: HourRange
+  tm_min*: MinuteRange
+  tm_sec*: range[0 .. 61]
+  tm_wday*: range[0 .. 6]
+  tm_yday*: range[1 .. 366]
+  tm_isdst*: int
+  tm_zone*: string           ## .. warning:: curently is only "LOCAL" or "Etc/UTC"
+  tm_gmtoff*: int
+
+ + + Source   +Edit   + +
+
+
+
struct_time_tuple = tuple[tm_year: int, tm_mon: range[1 .. 12],
+                          tm_mday: range[1 .. 31], tm_hour: range[0 .. 23],
+                          tm_min: range[0 .. 59], tm_sec: range[0 .. 61],
+                          tm_wday: range[0 .. 6], tm_yday: range[1 .. 366],
+                          tm_isdst: int]
+
+ + + Source   +Edit   + +
+
+
+
struct_time_tuple10 = tuple[tm_year: int, tm_mon: range[1 .. 12],
+                            tm_mday: range[1 .. 31], tm_hour: range[0 .. 23],
+                            tm_min: range[0 .. 59], tm_sec: range[0 .. 61],
+                            tm_wday: range[0 .. 6], tm_yday: range[1 .. 366],
+                            tm_isdst: int, tm_zone: string]
+
+ + + Source   +Edit   + +
+
+
+
struct_time_tuple11 = tuple[tm_year: int, tm_mon: range[1 .. 12],
+                            tm_mday: range[1 .. 31], tm_hour: range[0 .. 23],
+                            tm_min: range[0 .. 59], tm_sec: range[0 .. 61],
+                            tm_wday: range[0 .. 6], tm_yday: range[1 .. 366],
+                            tm_isdst: int, tm_zone: string, tm_gmtoff: int]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
func `<`(a, b: struct_time): bool {....raises: [], tags: [], forbids: [].}
+
+ + compares based on fields. + Source   +Edit   + +
+
+
+
func `<`(a: struct_time; b: struct_time_tuple11): bool {....raises: [], tags: [],
+    forbids: [].}
+
+ + compares based on fields. + Source   +Edit   + +
+
+
+
func `<`(a: struct_time_tuple11; b: struct_time): bool {....raises: [], tags: [],
+    forbids: [].}
+
+ + compares based on fields. + Source   +Edit   + +
+
+
+
func `<`(st: struct_time; t: tuple): bool
+
+ + + Source   +Edit   + +
+
+
+
func `<`(t: tuple; st: struct_time): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func `<=`(a, b: struct_time): bool {....raises: [], tags: [], forbids: [].}
+
+ + compares based on fields. + Source   +Edit   + +
+
+
+
func `<=`(a: struct_time; b: struct_time_tuple11): bool {....raises: [], tags: [],
+    forbids: [].}
+
+ + compares based on fields. + Source   +Edit   + +
+
+
+
func `<=`(a: struct_time_tuple11; b: struct_time): bool {....raises: [], tags: [],
+    forbids: [].}
+
+ + compares based on fields. + Source   +Edit   + +
+
+
+
func `<=`(st: struct_time; t: tuple): bool
+
+ + + Source   +Edit   + +
+
+
+
func `<=`(t: tuple; st: struct_time): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func `==`(a, b: struct_time): bool {....raises: [], tags: [], forbids: [].}
+
+ + compares based on fields. + Source   +Edit   + +
+
+
+
func `==`(a: struct_time; b: struct_time_tuple11): bool {....raises: [], tags: [],
+    forbids: [].}
+
+ + compares based on fields. + Source   +Edit   + +
+
+
+
func `==`(a: struct_time_tuple11; b: struct_time): bool {....raises: [], tags: [],
+    forbids: [].}
+
+ + compares based on fields. + Source   +Edit   + +
+
+
+
func `==`(st: struct_time; t: tuple): bool {.inline.}
+
+ + + Source   +Edit   + +
+
+
+
func `==`(t: tuple; st: struct_time): bool {.inline.}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func repr(st: struct_time): string {....raises: [], tags: [], forbids: [].}
+
+ +

struct_time.__repr__

+

returns string starting with "time.struct_time" with 9 fields.

+ + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template initStructTime(): struct_time
+
+ + + Source   +Edit   + +
+
+
+
template initStructTime(year, mon, mday, hour, min, sec, wday, yday, isdst,
+                        zone, gmtoff): struct_time
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template isUtcZone(st: struct_time): bool
+
+ + zone is only local or utc + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/Lib/time_impl/types.idx b/pylib/Lib/time_impl/types.idx new file mode 100644 index 000000000..c14034518 --- /dev/null +++ b/pylib/Lib/time_impl/types.idx @@ -0,0 +1,30 @@ +nimTitle types pylib/Lib/time_impl/types.html module src/pylib/Lib/time_impl/types 0 +nim struct_time pylib/Lib/time_impl/types.html#struct_time type struct_time 6 +nim struct_time_tuple pylib/Lib/time_impl/types.html#struct_time_tuple tuple struct_time_tuple 6 +nim struct_time_tuple10 pylib/Lib/time_impl/types.html#struct_time_tuple10 tuple struct_time_tuple10 6 +nim struct_time_tuple11 pylib/Lib/time_impl/types.html#struct_time_tuple11 tuple struct_time_tuple11 6 +nim Some_struct_time_tuple pylib/Lib/time_impl/types.html#Some_struct_time_tuple type Some_struct_time_tuple 26 +nim Some_struct_time pylib/Lib/time_impl/types.html#Some_struct_time type Some_struct_time 27 +nim isUtcZone pylib/Lib/time_impl/types.html#isUtcZone.t,struct_time template isUtcZone(st: struct_time): bool 29 +nim initStructTime pylib/Lib/time_impl/types.html#initStructTime.t template initStructTime(): struct_time 33 +nim initStructTime pylib/Lib/time_impl/types.html#initStructTime.t,,,,,,,,,,, template initStructTime(year, mon, mday, hour, min, sec, wday, yday, isdst, zone, gmtoff): struct_time 41 +nim repr pylib/Lib/time_impl/types.html#repr,struct_time proc repr(st: struct_time): string 69 +nim `==` pylib/Lib/time_impl/types.html#==,struct_time,struct_time proc `==`(a, b: struct_time): bool 84 +nim `==` pylib/Lib/time_impl/types.html#==,struct_time,struct_time_tuple11 proc `==`(a: struct_time; b: struct_time_tuple11): bool 87 +nim `==` pylib/Lib/time_impl/types.html#==,struct_time_tuple11,struct_time proc `==`(a: struct_time_tuple11; b: struct_time): bool 94 +nim `<=` pylib/Lib/time_impl/types.html#<=,struct_time,struct_time proc `<=`(a, b: struct_time): bool 84 +nim `<=` pylib/Lib/time_impl/types.html#<=,struct_time,struct_time_tuple11 proc `<=`(a: struct_time; b: struct_time_tuple11): bool 87 +nim `<=` pylib/Lib/time_impl/types.html#<=,struct_time_tuple11,struct_time proc `<=`(a: struct_time_tuple11; b: struct_time): bool 95 +nim `<` pylib/Lib/time_impl/types.html#<,struct_time,struct_time proc `<`(a, b: struct_time): bool 84 +nim `<` pylib/Lib/time_impl/types.html#<,struct_time,struct_time_tuple11 proc `<`(a: struct_time; b: struct_time_tuple11): bool 87 +nim `<` pylib/Lib/time_impl/types.html#<,struct_time_tuple11,struct_time proc `<`(a: struct_time_tuple11; b: struct_time): bool 96 +nim `==` pylib/Lib/time_impl/types.html#==,, proc `==`(st: struct_time; t: tuple): bool 100 +nim `==` pylib/Lib/time_impl/types.html#==,,_2 proc `==`(t: tuple; st: struct_time): bool 101 +nim `<` pylib/Lib/time_impl/types.html#<,, proc `<`(st: struct_time; t: tuple): bool 107 +nim `<` pylib/Lib/time_impl/types.html#<,,_2 proc `<`(t: tuple; st: struct_time): bool 110 +nim `<=` pylib/Lib/time_impl/types.html#<=,, proc `<=`(st: struct_time; t: tuple): bool 107 +nim `<=` pylib/Lib/time_impl/types.html#<=,,_2 proc `<=`(t: tuple; st: struct_time): bool 111 +nimgrp == pylib/Lib/time_impl/types.html#==-procs-all proc 94 +nimgrp <= pylib/Lib/time_impl/types.html#<=-procs-all proc 95 +nimgrp < pylib/Lib/time_impl/types.html#<-procs-all proc 96 +nimgrp initstructtime pylib/Lib/time_impl/types.html#initStructTime-templates-all template 33 diff --git a/pylib/Lib/timeit.html b/pylib/Lib/timeit.html new file mode 100644 index 000000000..07748ce7d --- /dev/null +++ b/pylib/Lib/timeit.html @@ -0,0 +1,262 @@ + + + + + + + +src/pylib/Lib/timeit + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/timeit

+
+ +
+ Source   +Edit   + +
+ +

+ +
+

Vars

+
+
+
default_timer = pysince(3.3, perf_counter, default_timer)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Consts

+
+
+
default_repeat = 5
+
+ + + since python 3.7: default value of repeat parameter is changed from 3 to 5. + Source   +Edit   + +
+
+
+
TimeItUseTime {.booldefine: "timeit.usetime".} = true
+
+ + +disable this if don't wanna depending on Lib/time + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+ + +
+
+
+

Templates

+
+
+
+
template autorange(self: Timer; callable = None): (int, float)
+
+ +
Admonition: +since Python 3.6
+ + Source   +Edit   + +
+
+ +
+
+
+
template repeat(self: Timer; repeat = pysince(3.7, 5, 3);
+                number = default_number): PyList[float]
+
+ + + Source   +Edit   + +
+
+
+
template repeat(stmt: TimeitParam = NullStmt; setup: TimeitParam = NullStmt;
+                timer = default_timer; repeat = pysince(3.7, 5, 3);
+                number = default_number): PyList[float]
+
+ + +

Example:

+
assert len(repeat(repeat=0)) == 0
+ Source   +Edit   + +
+
+ +
+ +
+
+ + +
+
+ + +
+
+ + + diff --git a/pylib/Lib/timeit.idx b/pylib/Lib/timeit.idx new file mode 100644 index 000000000..e557ffb47 --- /dev/null +++ b/pylib/Lib/timeit.idx @@ -0,0 +1,9 @@ +nimTitle timeit pylib/Lib/timeit.html module src/pylib/Lib/timeit 0 +nim TimeItUseTime pylib/Lib/timeit.html#TimeItUseTime const TimeItUseTime 10 +nim default_timer pylib/Lib/timeit.html#default_timer var default_timer 18 +nim default_repeat pylib/Lib/timeit.html#default_repeat const default_repeat 24 +nim repeat pylib/Lib/timeit.html#repeat.t,TimeitParam,TimeitParam template repeat(stmt: TimeitParam = NullStmt; setup: TimeitParam = NullStmt;\n timer = default_timer; repeat = pysince(3.7, 5, 3);\n number = default_number): PyList[float] 27 +nim repeat pylib/Lib/timeit.html#repeat.t,Timer template repeat(self: Timer; repeat = pysince(3.7, 5, 3); number = default_number): PyList[\n float] 45 +nim autorange pylib/Lib/timeit.html#autorange.t,Timer template autorange(self: Timer; callable = None): (int, float) 51 +nim print_exc pylib/Lib/timeit.html#print_exc,Timer,auto proc print_exc(self: Timer; file: auto = None) 56 +nimgrp repeat pylib/Lib/timeit.html#repeat-templates-all template 27 diff --git a/pylib/Lib/typing_impl/easyImpl.html b/pylib/Lib/typing_impl/easyImpl.html new file mode 100644 index 000000000..00fdece32 --- /dev/null +++ b/pylib/Lib/typing_impl/easyImpl.html @@ -0,0 +1,116 @@ + + + + + + + +src/pylib/Lib/typing_impl/easyImpl + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/typing_impl/easyImpl

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Types

+
+
+
Final[T] = T
+
+ + + Source   +Edit   + +
+
+
+
Literal = auto
+
+ + Its __class_getitem__ (e.g. Literal[1, 2]) is (and only is) supported within def or class via rewriteDeclXxx in pysugar/stmt/decl.nim
Note: +bare Literal (without any generic type) is disallowed in mypy, here we support it as we use it to refer to const
+ + Source   +Edit   + +
+
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/Lib/typing_impl/easyImpl.idx b/pylib/Lib/typing_impl/easyImpl.idx new file mode 100644 index 000000000..c984a59ad --- /dev/null +++ b/pylib/Lib/typing_impl/easyImpl.idx @@ -0,0 +1,3 @@ +nimTitle easyImpl pylib/Lib/typing_impl/easyImpl.html module src/pylib/Lib/typing_impl/easyImpl 0 +nim Final pylib/Lib/typing_impl/easyImpl.html#Final type Final 3 +nim Literal pylib/Lib/typing_impl/easyImpl.html#Literal type Literal 4 diff --git a/pylib/Lib/warnings.html b/pylib/Lib/warnings.html new file mode 100644 index 000000000..c8f66c371 --- /dev/null +++ b/pylib/Lib/warnings.html @@ -0,0 +1,136 @@ + + + + + + + +src/pylib/Lib/warnings + + + + + + + + + + + + + + + + +
+
+

src/pylib/Lib/warnings

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Types

+
+
+
Warning = enum
+  UserWarning, DeprecationWarning, RuntimeWarning
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Templates

+
+
+
+
template warn(message: string; category: Warning = UserWarning; stacklevel = 1)
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/Lib/warnings.idx b/pylib/Lib/warnings.idx new file mode 100644 index 000000000..6767d7d22 --- /dev/null +++ b/pylib/Lib/warnings.idx @@ -0,0 +1,6 @@ +nimTitle warnings pylib/Lib/warnings.html module src/pylib/Lib/warnings 0 +nim UserWarning pylib/Lib/warnings.html#UserWarning Warning.UserWarning 4 +nim DeprecationWarning pylib/Lib/warnings.html#DeprecationWarning Warning.DeprecationWarning 4 +nim RuntimeWarning pylib/Lib/warnings.html#RuntimeWarning Warning.RuntimeWarning 4 +nim Warning pylib/Lib/warnings.html#Warning enum Warning 4 +nim warn pylib/Lib/warnings.html#warn.t,string,Warning,int template warn(message: string; category: Warning = UserWarning; stacklevel = 1) 11 diff --git a/pylib/Objects/obmalloc.html b/pylib/Objects/obmalloc.html new file mode 100644 index 000000000..377307d63 --- /dev/null +++ b/pylib/Objects/obmalloc.html @@ -0,0 +1,177 @@ + + + + + + + +src/pylib/Objects/obmalloc + + + + + + + + + + + + + + + + +
+
+

src/pylib/Objects/obmalloc

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Templates

+
+
+
+
template memcpy[T](a, b: ptr T; n: int)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template pyalloc[T](s): ptr T
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template pyallocStr(s): cstring
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template pyfree(p)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template pyfreeStr(p)
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/Objects/obmalloc.idx b/pylib/Objects/obmalloc.idx new file mode 100644 index 000000000..5224da9ee --- /dev/null +++ b/pylib/Objects/obmalloc.idx @@ -0,0 +1,6 @@ +nimTitle obmalloc pylib/Objects/obmalloc.html module src/pylib/Objects/obmalloc 0 +nim pyfree pylib/Objects/obmalloc.html#pyfree.t template pyfree(p) 4 +nim pyalloc pylib/Objects/obmalloc.html#pyalloc.t template pyalloc[T](s): ptr T 10 +nim pyallocStr pylib/Objects/obmalloc.html#pyallocStr.t template pyallocStr(s): cstring 11 +nim pyfreeStr pylib/Objects/obmalloc.html#pyfreeStr.t template pyfreeStr(p) 12 +nim memcpy pylib/Objects/obmalloc.html#memcpy.t,ptr.T,ptr.T,int template memcpy[T](a, b: ptr T; n: int) 14 diff --git a/pylib/Python/config_read_env.html b/pylib/Python/config_read_env.html new file mode 100644 index 000000000..ac24f3a6d --- /dev/null +++ b/pylib/Python/config_read_env.html @@ -0,0 +1,173 @@ + + + + + + + +src/pylib/Python/config_read_env + + + + + + + + + + + + + + + + +
+
+

src/pylib/Python/config_read_env

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Procs

+
+
+
+
proc ib_b(name: string; flagInit: bool): bool {....raises: [],
+    tags: [ReadEnvEffect], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc ib_b(name: string; flagInit: int): int {....raises: [], tags: [ReadEnvEffect],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc ib_e[T](name: string; flagInit: T): T
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc ib_i[T](name: string; flagInit: T): T
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func toPyEnv(name: string): string {.inline, ...raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/Python/config_read_env.idx b/pylib/Python/config_read_env.idx new file mode 100644 index 000000000..f13a37829 --- /dev/null +++ b/pylib/Python/config_read_env.idx @@ -0,0 +1,7 @@ +nimTitle config_read_env pylib/Python/config_read_env.html module src/pylib/Python/config_read_env 0 +nim toPyEnv pylib/Python/config_read_env.html#toPyEnv proc toPyEnv(name: string): string 12 +nim ib_i pylib/Python/config_read_env.html#ib_i,,T proc ib_i[T](name: string; flagInit: T): T 13 +nim ib_e pylib/Python/config_read_env.html#ib_e,,T proc ib_e[T](name: string; flagInit: T): T 23 +nim ib_b pylib/Python/config_read_env.html#ib_b,,int proc ib_b(name: string; flagInit: int): int 24 +nim ib_b pylib/Python/config_read_env.html#ib_b,,bool proc ib_b(name: string; flagInit: bool): bool 25 +nimgrp ibb pylib/Python/config_read_env.html#ib_b-procs-all proc 24 diff --git a/pylib/Python/envutils.html b/pylib/Python/envutils.html new file mode 100644 index 000000000..2400dccdb --- /dev/null +++ b/pylib/Python/envutils.html @@ -0,0 +1,155 @@ + + + + + + + +src/pylib/Python/envutils + + + + + + + + + + + + + + + + +
+
+

src/pylib/Python/envutils

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
proc c_getenv(v: cstring): cstring {.importc: "getenv", header: "<stdlib.h>",
+                                     ...raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc Py_SetLocaleFromEnv(category: cint): cstring {.discardable, ...raises: [],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc setenvOverwrite(key, val: string): bool {....raises: [],
+    tags: [WriteEnvEffect], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/Python/envutils.idx b/pylib/Python/envutils.idx new file mode 100644 index 000000000..e88634756 --- /dev/null +++ b/pylib/Python/envutils.idx @@ -0,0 +1,4 @@ +nimTitle envutils pylib/Python/envutils.html module src/pylib/Python/envutils 0 +nim setenvOverwrite pylib/Python/envutils.html#setenvOverwrite,string,string proc setenvOverwrite(key, val: string): bool 10 +nim c_getenv pylib/Python/envutils.html#c_getenv,cstring proc c_getenv(v: cstring): cstring 17 +nim Py_SetLocaleFromEnv pylib/Python/envutils.html#Py_SetLocaleFromEnv,cint proc Py_SetLocaleFromEnv(category: cint): cstring 22 diff --git a/pylib/Python/fileutils.html b/pylib/Python/fileutils.html new file mode 100644 index 000000000..38c895964 --- /dev/null +++ b/pylib/Python/fileutils.html @@ -0,0 +1,190 @@ + + + + + + + +src/pylib/Python/fileutils + + + + + + + + + + + + + + + + +
+
+

src/pylib/Python/fileutils

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Consts

+
+
+
Utf8 = "utf-8"
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
proc Py_DecodeLocaleEx(arg: cstring; wstr: var ptr wchar_t; wlen: ptr csize_t;
+                       reason: var cstring; current_locale: bool;
+                       errors: Py_error_handler): int {....raises: [], tags: [],
+    forbids: [].}
+
+ +

Decode a byte string from the locale encoding.

+

Use the strict error handler if 'surrogateescape' is zero. Use the surrogateescape error handler if 'surrogateescape' is non-zero: undecodable bytes are decoded as characters in range U+DC80..U+DCFF. If a byte sequence can be decoded as a surrogate character, escape the bytes using the surrogateescape error handler instead of decoding them.

+

On success, return 0 and write the newly allocated wide character string into wstr (use PyMem_RawFree() to free the memory). If wlen is not NULL, write the number of wide characters excluding the null character into wlen.

+

On memory allocation failure, return -1.

+

On decoding error, return -2. Write the start of invalid byte sequence in the input string into wlen. If reason is not NULL, write the decoding error message into reason.

+

Return -3 if the error handler 'errors' is not supported.

+

Use the Py_EncodeLocaleEx() function to encode the character string back to a byte string.

+ + Source   +Edit   + +
+
+ +
+
+
+
proc Py_GetLocaleEncoding(): string {....raises: [], tags: [], forbids: [].}
+
+ + Get the current locale encoding name:
  • Return "utf-8" if Py_FORCE_UTF8_LOCALE is defined (ex: on Android)
  • +
  • Return "utf-8" if the UTF-8 Mode is enabled
  • +
  • On Windows, return the ANSI code page (ex: "cp1250")
  • +
  • Return "utf-8" if nl_langinfo(CODESET) returns an empty string.
  • +
  • Otherwise, return nl_langinfo(CODESET).
  • +
+

See also config_get_locale_encoding()

+ + Source   +Edit   + +
+
+ +
+ +
+
+ + +
+
+ + +
+
+ + + diff --git a/pylib/Python/fileutils.idx b/pylib/Python/fileutils.idx new file mode 100644 index 000000000..70d7a23d0 --- /dev/null +++ b/pylib/Python/fileutils.idx @@ -0,0 +1,4 @@ +nimTitle fileutils pylib/Python/fileutils.html module src/pylib/Python/fileutils 0 +nim Py_DecodeLocaleEx pylib/Python/fileutils.html#Py_DecodeLocaleEx,cstring,ptr.wchar_t,ptr.csize_t,cstring,bool,Py_error_handler proc Py_DecodeLocaleEx(arg: cstring; wstr: var ptr wchar_t; wlen: ptr csize_t;\n reason: var cstring; current_locale: bool;\n errors: Py_error_handler): int 179 +nim Utf8 pylib/Python/fileutils.html#Utf8 const Utf8 236 +nim Py_GetLocaleEncoding pylib/Python/fileutils.html#Py_GetLocaleEncoding proc Py_GetLocaleEncoding(): string 239 diff --git a/pylib/Python/force_ascii_utils.html b/pylib/Python/force_ascii_utils.html new file mode 100644 index 000000000..12d93481e --- /dev/null +++ b/pylib/Python/force_ascii_utils.html @@ -0,0 +1,228 @@ + + + + + + + +src/pylib/Python/force_ascii_utils + + + + + + + + + + + + + + + + +
+
+

src/pylib/Python/force_ascii_utils

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Consts

+
+
+
Py_FORCE_UTF8_FS_ENCODING = false
+
+ + + Source   +Edit   + +
+
+
+
Py_FORCE_UTF8_LOCALE = false
+
+ + CPython/Include/pyport.h: Use UTF-8 as the filesystem encoding. See PyUnicode_DecodeFSDefaultAndSize(), PyUnicode_EncodeFSDefault(), Py_DecodeLocale() and Py_EncodeLocale(). + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
proc check_force_ascii(): bool {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc Py_GetForceASCII(): bool {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc Py_ResetForceASCII() {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template force_ascii(): untyped
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Exports

+
+ Py_mbstowcs +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/Python/force_ascii_utils.idx b/pylib/Python/force_ascii_utils.idx new file mode 100644 index 000000000..bfefca501 --- /dev/null +++ b/pylib/Python/force_ascii_utils.idx @@ -0,0 +1,7 @@ +nimTitle force_ascii_utils pylib/Python/force_ascii_utils.html module src/pylib/Python/force_ascii_utils 0 +nim Py_FORCE_UTF8_LOCALE pylib/Python/force_ascii_utils.html#Py_FORCE_UTF8_LOCALE const Py_FORCE_UTF8_LOCALE 8 +nim Py_FORCE_UTF8_FS_ENCODING pylib/Python/force_ascii_utils.html#Py_FORCE_UTF8_FS_ENCODING const Py_FORCE_UTF8_FS_ENCODING 13 +nim force_ascii pylib/Python/force_ascii_utils.html#force_ascii.t template force_ascii(): untyped 47 +nim check_force_ascii pylib/Python/force_ascii_utils.html#check_force_ascii proc check_force_ascii(): bool 49 +nim Py_GetForceASCII pylib/Python/force_ascii_utils.html#Py_GetForceASCII proc Py_GetForceASCII(): bool 109 +nim Py_ResetForceASCII pylib/Python/force_ascii_utils.html#Py_ResetForceASCII proc Py_ResetForceASCII() 114 diff --git a/pylib/Python/internal/pycore_fileutils.html b/pylib/Python/internal/pycore_fileutils.html new file mode 100644 index 000000000..a9e9ae44a --- /dev/null +++ b/pylib/Python/internal/pycore_fileutils.html @@ -0,0 +1,145 @@ + + + + + + + +src/pylib/Python/internal/pycore_fileutils + + + + + + + + + + + + + + + + +
+
+

src/pylib/Python/internal/pycore_fileutils

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Types

+
+
+
Py_error_handler = enum
+  Py_ERROR_UNKNOWN = "unknown", Py_ERROR_STRICT = "strict",
+  Py_ERROR_SURROGATEESCAPE = "surrogateescape", Py_ERROR_REPLACE = "replace",
+  Py_ERROR_IGNORE = "ignore", Py_ERROR_BACKSLASHREPLACE = "backslashreplace",
+  Py_ERROR_SURROGATEPASS = "surrogatepass",
+  Py_ERROR_XMLCHARREFREPLACE = "xmlcharrefreplace", Py_ERROR_OTHER = "other"
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
proc Py_GetErrorHandler(errors: string): Py_error_handler {....raises: [],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/Python/internal/pycore_fileutils.idx b/pylib/Python/internal/pycore_fileutils.idx new file mode 100644 index 000000000..906e78c92 --- /dev/null +++ b/pylib/Python/internal/pycore_fileutils.idx @@ -0,0 +1,12 @@ +nimTitle pycore_fileutils pylib/Python/internal/pycore_fileutils.html module src/pylib/Python/internal/pycore_fileutils 0 +nim Py_ERROR_UNKNOWN pylib/Python/internal/pycore_fileutils.html#Py_ERROR_UNKNOWN Py_error_handler.Py_ERROR_UNKNOWN 5 +nim Py_ERROR_STRICT pylib/Python/internal/pycore_fileutils.html#Py_ERROR_STRICT Py_error_handler.Py_ERROR_STRICT 5 +nim Py_ERROR_SURROGATEESCAPE pylib/Python/internal/pycore_fileutils.html#Py_ERROR_SURROGATEESCAPE Py_error_handler.Py_ERROR_SURROGATEESCAPE 5 +nim Py_ERROR_REPLACE pylib/Python/internal/pycore_fileutils.html#Py_ERROR_REPLACE Py_error_handler.Py_ERROR_REPLACE 5 +nim Py_ERROR_IGNORE pylib/Python/internal/pycore_fileutils.html#Py_ERROR_IGNORE Py_error_handler.Py_ERROR_IGNORE 5 +nim Py_ERROR_BACKSLASHREPLACE pylib/Python/internal/pycore_fileutils.html#Py_ERROR_BACKSLASHREPLACE Py_error_handler.Py_ERROR_BACKSLASHREPLACE 5 +nim Py_ERROR_SURROGATEPASS pylib/Python/internal/pycore_fileutils.html#Py_ERROR_SURROGATEPASS Py_error_handler.Py_ERROR_SURROGATEPASS 5 +nim Py_ERROR_XMLCHARREFREPLACE pylib/Python/internal/pycore_fileutils.html#Py_ERROR_XMLCHARREFREPLACE Py_error_handler.Py_ERROR_XMLCHARREFREPLACE 5 +nim Py_ERROR_OTHER pylib/Python/internal/pycore_fileutils.html#Py_ERROR_OTHER Py_error_handler.Py_ERROR_OTHER 5 +nim Py_error_handler pylib/Python/internal/pycore_fileutils.html#Py_error_handler enum Py_error_handler 5 +nim Py_GetErrorHandler pylib/Python/internal/pycore_fileutils.html#Py_GetErrorHandler,string proc Py_GetErrorHandler(errors: string): Py_error_handler 16 diff --git a/pylib/Python/localeutils.html b/pylib/Python/localeutils.html new file mode 100644 index 000000000..83a4f57d0 --- /dev/null +++ b/pylib/Python/localeutils.html @@ -0,0 +1,177 @@ + + + + + + + +src/pylib/Python/localeutils + + + + + + + + + + + + + + + + +
+
+

src/pylib/Python/localeutils

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Lets

+
+
+
LC_ALL {.importc.}: cint
+
+ + + Source   +Edit   + +
+
+
+
LC_CTYPE {.importc.}: cint
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
proc c_setlocale(category: cint; v: cstring): cstring {.importc: "setlocale",
+    header: "<locale.h>", ...raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template setlocale(category; v: string): cstring
+
+ + we know setlocale won't modify 2nd param Thus v: string is allowed to convert to cstring implicitly + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/Python/localeutils.idx b/pylib/Python/localeutils.idx new file mode 100644 index 000000000..0bc8f0e41 --- /dev/null +++ b/pylib/Python/localeutils.idx @@ -0,0 +1,5 @@ +nimTitle localeutils pylib/Python/localeutils.html module src/pylib/Python/localeutils 0 +nim LC_ALL pylib/Python/localeutils.html#LC_ALL let LC_ALL 4 +nim LC_CTYPE pylib/Python/localeutils.html#LC_CTYPE let LC_CTYPE 5 +nim c_setlocale pylib/Python/localeutils.html#c_setlocale,cint,cstring proc c_setlocale(category: cint; v: cstring): cstring 6 +nim setlocale pylib/Python/localeutils.html#setlocale.t,,string template setlocale(category; v: string): cstring 9 diff --git a/pylib/Python/pylifecycle/signal.html b/pylib/Python/pylifecycle/signal.html new file mode 100644 index 000000000..712ff1a79 --- /dev/null +++ b/pylib/Python/pylifecycle/signal.html @@ -0,0 +1,145 @@ + + + + + + + +src/pylib/Python/pylifecycle/signal + + + + + + + + + + + + + + + + +
+
+

src/pylib/Python/pylifecycle/signal

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
proc PyOS_getsig(sig: cint): CSigHandler {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc PyOS_setsig(sig: cint; handler: CSigHandler): CSigHandler {....raises: [],
+    tags: [], forbids: [].}
+
+ + Python/pylifecycle.c PyOS_setsig + Source   +Edit   + +
+
+ +
+ +
+
+ + +
+
+ + +
+
+ + + diff --git a/pylib/Python/pylifecycle/signal.idx b/pylib/Python/pylifecycle/signal.idx new file mode 100644 index 000000000..4bdfcb199 --- /dev/null +++ b/pylib/Python/pylifecycle/signal.idx @@ -0,0 +1,3 @@ +nimTitle signal pylib/Python/pylifecycle/signal.html module src/pylib/Python/pylifecycle/signal 0 +nim PyOS_getsig pylib/Python/pylifecycle/signal.html#PyOS_getsig,cint proc PyOS_getsig(sig: cint): CSigHandler 12 +nim PyOS_setsig pylib/Python/pylifecycle/signal.html#PyOS_setsig,cint,CSigHandler proc PyOS_setsig(sig: cint; handler: CSigHandler): CSigHandler 26 diff --git a/pylib/Python/pylifecycle/signal/c_syms.html b/pylib/Python/pylifecycle/signal/c_syms.html new file mode 100644 index 000000000..86c2ce4b9 --- /dev/null +++ b/pylib/Python/pylifecycle/signal/c_syms.html @@ -0,0 +1,241 @@ + + + + + + + +src/pylib/Python/pylifecycle/signal/c_syms + + + + + + + + + + + + + + + + +
+
+

src/pylib/Python/pylifecycle/signal/c_syms

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

XXX: posix/winlean's a2 cannot be nil (a var Sigaction)

+ +
+

Lets

+
+
+
ITIMER_PROF {.importc, header: "<sys/time.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ITIMER_REAL {.importc, header: "<sys/time.h>".}: cint
+
+ + + Source   +Edit   + +
+
+
+
ITIMER_VIRTUAL {.importc, header: "<sys/time.h>".}: cint
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Consts

+
+
+
HAVE_BROKEN_PTHREAD_SIGMASK = false
+
+ + + Source   +Edit   + +
+
+
+
HAVE_SIGSET_T = true
+
+ + + Source   +Edit   + +
+
+
+
PYPTHREAD_SIGMASK = true
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
proc c_signal(a1: cint; a2: CSigHandler): CSigHandler {.importc: "signal",
+    header: "<signal.h>", ...raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc sigaction(a1: cint; a2: ptr Sigaction; a3: var Sigaction): cint {.
+    importc: "sigaction", header: "<sys/signal.h>", ...raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ + +
+
+ + +
+
+ + + diff --git a/pylib/Python/pylifecycle/signal/c_syms.idx b/pylib/Python/pylifecycle/signal/c_syms.idx new file mode 100644 index 000000000..8a33d9b8d --- /dev/null +++ b/pylib/Python/pylifecycle/signal/c_syms.idx @@ -0,0 +1,9 @@ +nimTitle c_syms pylib/Python/pylifecycle/signal/c_syms.html module src/pylib/Python/pylifecycle/signal/c_syms 0 +nim HAVE_BROKEN_PTHREAD_SIGMASK pylib/Python/pylifecycle/signal/c_syms.html#HAVE_BROKEN_PTHREAD_SIGMASK const HAVE_BROKEN_PTHREAD_SIGMASK 5 +nim PYPTHREAD_SIGMASK pylib/Python/pylifecycle/signal/c_syms.html#PYPTHREAD_SIGMASK const PYPTHREAD_SIGMASK 6 +nim HAVE_SIGSET_T pylib/Python/pylifecycle/signal/c_syms.html#HAVE_SIGSET_T const HAVE_SIGSET_T 7 +nim ITIMER_REAL pylib/Python/pylifecycle/signal/c_syms.html#ITIMER_REAL let ITIMER_REAL 35 +nim ITIMER_VIRTUAL pylib/Python/pylifecycle/signal/c_syms.html#ITIMER_VIRTUAL let ITIMER_VIRTUAL 36 +nim ITIMER_PROF pylib/Python/pylifecycle/signal/c_syms.html#ITIMER_PROF let ITIMER_PROF 37 +nim sigaction pylib/Python/pylifecycle/signal/c_syms.html#sigaction,cint,ptr.Sigaction,Sigaction proc sigaction(a1: cint; a2: ptr Sigaction; a3: var Sigaction): cint 43 +nim c_signal pylib/Python/pylifecycle/signal/c_syms.html#c_signal,cint,CSigHandler proc c_signal(a1: cint; a2: CSigHandler): CSigHandler 46 diff --git a/pylib/Python/pylifecycle/signal/chk_util.html b/pylib/Python/pylifecycle/signal/chk_util.html new file mode 100644 index 000000000..4506ab054 --- /dev/null +++ b/pylib/Python/pylifecycle/signal/chk_util.html @@ -0,0 +1,109 @@ + + + + + + + +src/pylib/Python/pylifecycle/signal/chk_util + + + + + + + + + + + + + + + + +
+
+

src/pylib/Python/pylifecycle/signal/chk_util

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Templates

+
+
+
+
template ifInvalidOnVcc(signalnum: cint; handleExc)
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/Python/pylifecycle/signal/chk_util.idx b/pylib/Python/pylifecycle/signal/chk_util.idx new file mode 100644 index 000000000..95d19b598 --- /dev/null +++ b/pylib/Python/pylifecycle/signal/chk_util.idx @@ -0,0 +1,2 @@ +nimTitle chk_util pylib/Python/pylifecycle/signal/chk_util.html module src/pylib/Python/pylifecycle/signal/chk_util 0 +nim ifInvalidOnVcc pylib/Python/pylifecycle/signal/chk_util.html#ifInvalidOnVcc.t,cint, template ifInvalidOnVcc(signalnum: cint; handleExc) 2 diff --git a/pylib/Python/pylifecycle/signal/handler_types.html b/pylib/Python/pylifecycle/signal/handler_types.html new file mode 100644 index 000000000..28254c8b8 --- /dev/null +++ b/pylib/Python/pylifecycle/signal/handler_types.html @@ -0,0 +1,125 @@ + + + + + + + +src/pylib/Python/pylifecycle/signal/handler_types + + + + + + + + + + + + + + + + +
+
+

src/pylib/Python/pylifecycle/signal/handler_types

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Types

+
+
+
CSigHandler = proc (signalnum: cint) {.noconv.}
+
+ + PyOS_sighandler_t + Source   +Edit   + +
+
+
+
NimSigHandler = proc (signalnum: int) {.nimcall.}
+
+ + + Source   +Edit   + +
+
+
+
PySigHandler = proc (signalnum: int; frame: PFrame) {.closure.}
+
+ + + Source   +Edit   + +
+
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/Python/pylifecycle/signal/handler_types.idx b/pylib/Python/pylifecycle/signal/handler_types.idx new file mode 100644 index 000000000..45225e42c --- /dev/null +++ b/pylib/Python/pylifecycle/signal/handler_types.idx @@ -0,0 +1,4 @@ +nimTitle handler_types pylib/Python/pylifecycle/signal/handler_types.html module src/pylib/Python/pylifecycle/signal/handler_types 0 +nim PySigHandler pylib/Python/pylifecycle/signal/handler_types.html#PySigHandler type PySigHandler 3 +nim CSigHandler pylib/Python/pylifecycle/signal/handler_types.html#CSigHandler type CSigHandler 4 +nim NimSigHandler pylib/Python/pylifecycle/signal/handler_types.html#NimSigHandler type NimSigHandler 5 diff --git a/pylib/Python/unicodeobject/char_decl.html b/pylib/Python/unicodeobject/char_decl.html new file mode 100644 index 000000000..09d9a01cc --- /dev/null +++ b/pylib/Python/unicodeobject/char_decl.html @@ -0,0 +1,125 @@ + + + + + + + +src/pylib/Python/unicodeobject/char_decl + + + + + + + + + + + + + + + + +
+
+

src/pylib/Python/unicodeobject/char_decl

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Types

+
+
+
Py_UCS1 = uint8
+
+ + + Source   +Edit   + +
+
+
+
Py_UCS2 = uint16
+
+ + + Source   +Edit   + +
+
+
+
Py_UCS4 = uint32
+
+ + + Source   +Edit   + +
+
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/Python/unicodeobject/char_decl.idx b/pylib/Python/unicodeobject/char_decl.idx new file mode 100644 index 000000000..d7dde968b --- /dev/null +++ b/pylib/Python/unicodeobject/char_decl.idx @@ -0,0 +1,4 @@ +nimTitle char_decl pylib/Python/unicodeobject/char_decl.html module src/pylib/Python/unicodeobject/char_decl 0 +nim Py_UCS1 pylib/Python/unicodeobject/char_decl.html#Py_UCS1 type Py_UCS1 3 +nim Py_UCS2 pylib/Python/unicodeobject/char_decl.html#Py_UCS2 type Py_UCS2 4 +nim Py_UCS4 pylib/Python/unicodeobject/char_decl.html#Py_UCS4 type Py_UCS4 5 diff --git a/pylib/Python/unicodeobject/codecs.html b/pylib/Python/unicodeobject/codecs.html new file mode 100644 index 000000000..181074e01 --- /dev/null +++ b/pylib/Python/unicodeobject/codecs.html @@ -0,0 +1,226 @@ + + + + + + + +src/pylib/Python/unicodeobject/codecs + + + + + + + + + + + + + + + + +
+
+

src/pylib/Python/unicodeobject/codecs

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

Mask to quickly check whether a C 'size_t' contains a non-ASCII, UTF8-encoded char.10xxxxxx

+ +
+

Consts

+
+
+
ALIGNOF_SIZE_T = 8
+
+ + + Source   +Edit   + +
+
+
+
ASCII_CHAR_MASK = 0x80808080'u
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
func getMaxChar[C](): C
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc utf8_decode[STRINGLIB_CHAR](inptr: var (cstring | ptr char);
+                                 end: (cstring | ptr char);
+                                 dest: ptr STRINGLIB_CHAR;
+                                 outpos: var Py_ssize_t): Py_UCS4
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template IS_CONTINUATION_BYTE(ch: untyped): untyped
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template Py_IS_ALIGNED(p: cstring | ptr; a: typeof(ALIGNOF_SIZE_T)): bool
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/Python/unicodeobject/codecs.idx b/pylib/Python/unicodeobject/codecs.idx new file mode 100644 index 000000000..e58b69318 --- /dev/null +++ b/pylib/Python/unicodeobject/codecs.idx @@ -0,0 +1,7 @@ +nimTitle codecs pylib/Python/unicodeobject/codecs.html module src/pylib/Python/unicodeobject/codecs 0 +nim ASCII_CHAR_MASK pylib/Python/unicodeobject/codecs.html#ASCII_CHAR_MASK const ASCII_CHAR_MASK 15 +nim IS_CONTINUATION_BYTE pylib/Python/unicodeobject/codecs.html#IS_CONTINUATION_BYTE.t,untyped template IS_CONTINUATION_BYTE(ch: untyped): untyped 23 +nim ALIGNOF_SIZE_T pylib/Python/unicodeobject/codecs.html#ALIGNOF_SIZE_T const ALIGNOF_SIZE_T 29 +nim Py_IS_ALIGNED pylib/Python/unicodeobject/codecs.html#Py_IS_ALIGNED.t,, template Py_IS_ALIGNED(p: cstring | ptr; a: typeof(ALIGNOF_SIZE_T)): bool 31 +nim getMaxChar pylib/Python/unicodeobject/codecs.html#getMaxChar proc getMaxChar[C](): C 34 +nim utf8_decode pylib/Python/unicodeobject/codecs.html#utf8_decode,,,ptr.STRINGLIB_CHAR,Py_ssize_t proc utf8_decode[STRINGLIB_CHAR](inptr: var (cstring | ptr char);\n end: (cstring | ptr char); dest: ptr STRINGLIB_CHAR;\n outpos: var Py_ssize_t): Py_UCS4 43 diff --git a/pylib/Python/unicodeobject/cstring_ptr_op.html b/pylib/Python/unicodeobject/cstring_ptr_op.html new file mode 100644 index 000000000..cec805b75 --- /dev/null +++ b/pylib/Python/unicodeobject/cstring_ptr_op.html @@ -0,0 +1,186 @@ + + + + + + + +src/pylib/Python/unicodeobject/cstring_ptr_op + + + + + + + + + + + + + + + + +
+
+

src/pylib/Python/unicodeobject/cstring_ptr_op

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Imports

+
+ ptr_types +
+
+
+

Templates

+
+
+
+
template `+`[I: IndexType](s: cstring; i: I): cstring
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template `-`(a, b: cstring): ptrdiff_t
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template `<%`(a, b: cstring): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template `<=%`(a, b: cstring): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template inc(s: cstring; i = 1)
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/Python/unicodeobject/cstring_ptr_op.idx b/pylib/Python/unicodeobject/cstring_ptr_op.idx new file mode 100644 index 000000000..599e9807d --- /dev/null +++ b/pylib/Python/unicodeobject/cstring_ptr_op.idx @@ -0,0 +1,6 @@ +nimTitle cstring_ptr_op pylib/Python/unicodeobject/cstring_ptr_op.html module src/pylib/Python/unicodeobject/cstring_ptr_op 0 +nim `+` pylib/Python/unicodeobject/cstring_ptr_op.html#+.t,cstring,I template `+`[I: IndexType](s: cstring; i: I): cstring 6 +nim inc pylib/Python/unicodeobject/cstring_ptr_op.html#inc.t,cstring,int template inc(s: cstring; i = 1) 9 +nim `-` pylib/Python/unicodeobject/cstring_ptr_op.html#-.t,cstring,cstring template `-`(a, b: cstring): ptrdiff_t 11 +nim `<%` pylib/Python/unicodeobject/cstring_ptr_op.html#<%.t,cstring,cstring template `<%`(a, b: cstring): bool 14 +nim `<=%` pylib/Python/unicodeobject/cstring_ptr_op.html#<=%.t,cstring,cstring template `<=%`(a, b: cstring): bool 17 diff --git a/pylib/Python/unicodeobject/ptr_op.html b/pylib/Python/unicodeobject/ptr_op.html new file mode 100644 index 000000000..95fd0031c --- /dev/null +++ b/pylib/Python/unicodeobject/ptr_op.html @@ -0,0 +1,203 @@ + + + + + + + +src/pylib/Python/unicodeobject/ptr_op + + + + + + + + + + + + + + + + +
+
+

src/pylib/Python/unicodeobject/ptr_op

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Imports

+
+ ptr_types +
+
+
+

Templates

+
+
+
+
template `+`[I: IndexType; T](s: ptr T; i: I): ptr T
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template `-`[T](a, b: ptr T): ptrdiff_t
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template `<%`[T](a, b: ptr T): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template `<=%`[T](a, b: ptr T): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template `[]`[I: IndexType; T](p: ptr T; i: I): T
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template inc[T](s: ptr T; i = 1)
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/Python/unicodeobject/ptr_op.idx b/pylib/Python/unicodeobject/ptr_op.idx new file mode 100644 index 000000000..2baa6b322 --- /dev/null +++ b/pylib/Python/unicodeobject/ptr_op.idx @@ -0,0 +1,7 @@ +nimTitle ptr_op pylib/Python/unicodeobject/ptr_op.html module src/pylib/Python/unicodeobject/ptr_op 0 +nim `+` pylib/Python/unicodeobject/ptr_op.html#+.t,ptr.T,I template `+`[I: IndexType; T](s: ptr T; i: I): ptr T 5 +nim inc pylib/Python/unicodeobject/ptr_op.html#inc.t,ptr.T,int template inc[T](s: ptr T; i = 1) 8 +nim `-` pylib/Python/unicodeobject/ptr_op.html#-.t,ptr.T,ptr.T template `-`[T](a, b: ptr T): ptrdiff_t 10 +nim `<%` pylib/Python/unicodeobject/ptr_op.html#<%.t,ptr.T,ptr.T template `<%`[T](a, b: ptr T): bool 13 +nim `<=%` pylib/Python/unicodeobject/ptr_op.html#<=%.t,ptr.T,ptr.T template `<=%`[T](a, b: ptr T): bool 16 +nim `[]` pylib/Python/unicodeobject/ptr_op.html#[].t,ptr.T,I template `[]`[I: IndexType; T](p: ptr T; i: I): T 19 diff --git a/pylib/Python/unicodeobject/ptr_types.html b/pylib/Python/unicodeobject/ptr_types.html new file mode 100644 index 000000000..1a70770e9 --- /dev/null +++ b/pylib/Python/unicodeobject/ptr_types.html @@ -0,0 +1,103 @@ + + + + + + + +src/pylib/Python/unicodeobject/ptr_types + + + + + + + + + + + + + + + + +
+
+

src/pylib/Python/unicodeobject/ptr_types

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Types

+
+
+
ptrdiff_t = int
+
+ + + Source   +Edit   + +
+
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/Python/unicodeobject/ptr_types.idx b/pylib/Python/unicodeobject/ptr_types.idx new file mode 100644 index 000000000..e52c991ae --- /dev/null +++ b/pylib/Python/unicodeobject/ptr_types.idx @@ -0,0 +1,2 @@ +nimTitle ptr_types pylib/Python/unicodeobject/ptr_types.html module src/pylib/Python/unicodeobject/ptr_types 0 +nim ptrdiff_t pylib/Python/unicodeobject/ptr_types.html#ptrdiff_t type ptrdiff_t 2 diff --git a/pylib/Python/unicodeobject/utf8_codec.html b/pylib/Python/unicodeobject/utf8_codec.html new file mode 100644 index 000000000..add3fed72 --- /dev/null +++ b/pylib/Python/unicodeobject/utf8_codec.html @@ -0,0 +1,152 @@ + + + + + + + +src/pylib/Python/unicodeobject/utf8_codec + + + + + + + + + + + + + + + + +
+
+

src/pylib/Python/unicodeobject/utf8_codec

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Consts

+
+
+
MaxWStrLen = 2305843009213693951
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
proc Py_DecodeUTF8Ex(orig_s: cstring; size: csize_t; wstr: var ptr wchar_t;
+                     wlen: ptr csize_t; reason: var cstring;
+                     errors: Py_error_handler): int {....raises: [], tags: [],
+    forbids: [].}
+
+ +

UTF-8 decoder: use surrogateescape error handler if 'surrogateescape' is non-zero, use strict error handler otherwise.

+

On success, write a pointer to a newly allocated wide character string into wstr (use PyMem_RawFree() to free the memory) and write the output length (in number of wchar_t units) into wlen (if wlen is set).

+

On memory allocation failure, return -1.

+

On decoding error (if surrogateescape is zero), return -2. If wlen is non-NULL, write the start of the illegal byte sequence into wlen. If reason is not NULL, write the decoding error message into reason.

+ + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/Python/unicodeobject/utf8_codec.idx b/pylib/Python/unicodeobject/utf8_codec.idx new file mode 100644 index 000000000..315d97fe3 --- /dev/null +++ b/pylib/Python/unicodeobject/utf8_codec.idx @@ -0,0 +1,3 @@ +nimTitle utf8_codec pylib/Python/unicodeobject/utf8_codec.html module src/pylib/Python/unicodeobject/utf8_codec 0 +nim MaxWStrLen pylib/Python/unicodeobject/utf8_codec.html#MaxWStrLen const MaxWStrLen 10 +nim Py_DecodeUTF8Ex pylib/Python/unicodeobject/utf8_codec.html#Py_DecodeUTF8Ex,cstring,csize_t,ptr.wchar_t,ptr.csize_t,cstring,Py_error_handler proc Py_DecodeUTF8Ex(orig_s: cstring; size: csize_t; wstr: var ptr wchar_t;\n wlen: ptr csize_t; reason: var cstring; errors: Py_error_handler): int 30 diff --git a/pylib/Python/wchar_t.html b/pylib/Python/wchar_t.html new file mode 100644 index 000000000..7dd9283f1 --- /dev/null +++ b/pylib/Python/wchar_t.html @@ -0,0 +1,383 @@ + + + + + + + +src/pylib/Python/wchar_t + + + + + + + + + + + + + + + + +
+
+

src/pylib/Python/wchar_t

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Types

+
+
+
mbstate_t {.importc, header: "wchar.h>".} = object
+
+ + + Source   +Edit   + +
+
+
+
wchar_t {.importc, header: "<wchar.h>".} = uint32
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Consts

+
+
+
DECODE_ERROR = -1
+
+ + + Source   +Edit   + +
+
+
+
HAVE_MBRTOWC = true
+
+ + + Source   +Edit   + +
+
+
+
INCOMPLETE_CHARACTER = -2
+
+ + + Source   +Edit   + +
+
+
+
MAX_UNICODE_val = 0x0010FFFF
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
proc `[]`(p: ptr wchar_t; i: csize_t): wchar_t {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc `[]`(p: ptr wchar_t; i: int): wchar_t {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc `[]=`[I: csize_t | int](p: ptr wchar_t; i: I; val: wchar_t)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc is_valid_wide_char(ch: wchar_t): bool {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func ord(wc: wchar_t): int {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc Py_mbrtowc(wc: PWc; src: cstring; n: csize_t; mbs: var mbstate_t): csize_t
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc Py_mbstowcs(dest: ptr wchar_t; src: cstring; n: csize_t): csize_t {.
+    ...raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template allocWcharArr[I](n: I): ptr wchar_t
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template deallocWcArr(p: ptr wchar_t)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template inc[I](p: var ptr wchar_t; i: I = 1)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template Py_UNICODE_IS_SURROGATE(ch: wchar_t): bool
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/Python/wchar_t.idx b/pylib/Python/wchar_t.idx new file mode 100644 index 000000000..1d6f9b800 --- /dev/null +++ b/pylib/Python/wchar_t.idx @@ -0,0 +1,19 @@ +nimTitle wchar_t pylib/Python/wchar_t.html module src/pylib/Python/wchar_t 0 +nim wchar_t pylib/Python/wchar_t.html#wchar_t type wchar_t 5 +nim ord pylib/Python/wchar_t.html#ord,wchar_t proc ord(wc: wchar_t): int 7 +nim allocWcharArr pylib/Python/wchar_t.html#allocWcharArr.t,I template allocWcharArr[I](n: I): ptr wchar_t 9 +nim deallocWcArr pylib/Python/wchar_t.html#deallocWcArr.t,ptr.wchar_t template deallocWcArr(p: ptr wchar_t) 11 +nim mbstate_t pylib/Python/wchar_t.html#mbstate_t object mbstate_t 14 +nim Py_UNICODE_IS_SURROGATE pylib/Python/wchar_t.html#Py_UNICODE_IS_SURROGATE.t,wchar_t template Py_UNICODE_IS_SURROGATE(ch: wchar_t): bool 18 +nim MAX_UNICODE_val pylib/Python/wchar_t.html#MAX_UNICODE_val const MAX_UNICODE_val 20 +nim is_valid_wide_char pylib/Python/wchar_t.html#is_valid_wide_char,wchar_t proc is_valid_wide_char(ch: wchar_t): bool 26 +nim HAVE_MBRTOWC pylib/Python/wchar_t.html#HAVE_MBRTOWC const HAVE_MBRTOWC 55 +nim DECODE_ERROR pylib/Python/wchar_t.html#DECODE_ERROR const DECODE_ERROR 59 +nim INCOMPLETE_CHARACTER pylib/Python/wchar_t.html#INCOMPLETE_CHARACTER const INCOMPLETE_CHARACTER 60 +nim `[]` pylib/Python/wchar_t.html#[],ptr.wchar_t,csize_t proc `[]`(p: ptr wchar_t; i: csize_t): wchar_t 62 +nim `[]` pylib/Python/wchar_t.html#[],ptr.wchar_t,int proc `[]`(p: ptr wchar_t; i: int): wchar_t 64 +nim `[]=` pylib/Python/wchar_t.html#[]=,ptr.wchar_t,I,wchar_t proc `[]=`[I: csize_t | int](p: ptr wchar_t; i: I; val: wchar_t) 67 +nim inc pylib/Python/wchar_t.html#inc.t,ptr.wchar_t,I template inc[I](p: var ptr wchar_t; i: I = 1) 69 +nim Py_mbstowcs pylib/Python/wchar_t.html#Py_mbstowcs,ptr.wchar_t,cstring,csize_t proc Py_mbstowcs(dest: ptr wchar_t; src: cstring; n: csize_t): csize_t 75 +nim Py_mbrtowc pylib/Python/wchar_t.html#Py_mbrtowc,PWc,cstring,csize_t,mbstate_t proc Py_mbrtowc(wc: PWc; src: cstring; n: csize_t; mbs: var mbstate_t): csize_t 87 +nimgrp [] pylib/Python/wchar_t.html#[]-procs-all proc 62 diff --git a/pylib/builtins.html b/pylib/builtins.html new file mode 100644 index 000000000..a25612491 --- /dev/null +++ b/pylib/builtins.html @@ -0,0 +1,96 @@ + + + + + + + +src/pylib/builtins + + + + + + + + + + + + + + + + +
+
+

src/pylib/builtins

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Exports

+
+ input, print, round, pow, pow, round, round, round, round, pow, **, pow, /, **, +, complex, -=, ==, ==, pycomplex, +, pow, abs, repr, **, /, ==, *=, /, $, +=, +=, -, -, *=, pow, real, -=, *, +, conjugate, +, **, toNimComplex, +=, complex, pow, complex, /=, -, /=, j, -, complex, 'j, **, *, PyTComplex, ==, *=, /=, **, pycomplex, PyComplex, +, J, *, pow, pow, /, imag, ==, -, pow, -=, real=, *, **=, complex, *, /, imag=, pow, id, issubclass, isinstance, getattr, getattr, hasattr, hasattr, getattr, setattr, setattr, getattr, next, enumerate, next, map, items, enumerate, items, map, items, iter, iter, iter, filter, zip, filter, None, reversed, map, items, filter, zip, filter, reversed, items, zip, iter, iter, newPyIterator, nextImpl, PyIterator, nextImpl, next, items, max, max, min, max, max, max, min, min, items, max, min, max, Comparable, min, min, min, min, PyLibKey, max, format, as_integer_ratio, float, int, long, int, fromhex, long, bit_length, int, to_bytes, as_integer_ratio, int, float, to_chars, conjugate, bit_count, int, int, is_integer, as_someinteger_ratio, long, float, int, add_from_bytes, int, is_integer, long, hex, checked_as_integer_ratio, from_bytes, from_bytes, to_bytes, float_fromhex, int, float, nimint, NimInt, []=, not, ascii, <=, maketrans, []=, rindex, upper, ==, Br, translate, center, center, [], b, +=, partition, reversed, endsWith, bytearray, bytes, hex, maketrans, ljust, TranslateAction, ord, chars, bytes, find, clear, rindex, Rf, TranslateTableVal, removesuffix, StringLike, ==, isdigit, br, endsWith, toNimString, translate, bytes, replace, split, removeprefix, rstrip, replace, <=, ascii, maketrans, endsWith, count, contains, hex, str, TranslateTableABC, len, count, chr, endsWith, append, zfill, len, +=, bytearray, removesuffix, None, delitem, pyrepr, str, chars, hex, count, bytearray, bytes, ==, rb, endsWith, repr, toNimString, bytes, +, replace, maketrans, contains, [], isascii, count, ljust, or, repr, TranslateValType, ord, byteLen, toPyStr, lstrip, []=, and, startsWith, bytearray, isascii, *=, toPyBytes, endsWith, rpartition, getCharPtr, rsplit, isspace, fr, count, count, splitlines, $, expandtabs, rf, startsWith, lstrip, BytesLike, toPyStr, splitlines, istitle, <, islower, +, +=, runes, rjust, join, upper, contains, $, bytes, ljust, remove, find, ==, hex, TranslateTable, zfill, startsWith, lower, bytearray, contains, isascii, or, byteLen, [], endsWith, [], casefold, len, translate, toNimString, bytes, capitalize, lower, translate, bytes, bytes, endsWith, split, split, substr, pybytes, str, NoneType, getChar, format, startsWith, strip, newPyByteArray, split, rfind, split, split, rpartition, +=, getCharPtr, substr, toNimStr, bin, Rb, copy, u, [], strip, isspace, str, removeprefix, startsWith, rstrip, isalpha, *, insert, rindex, center, Fr, endsWith, str, +, title, replace, hex, getChar, rsplit, find, format, toNimString, rstrip, count, repr, lstrip, startsWith, splitlines, strip, count, partition, runeAtPos, rstrip, <, +=, ljust, rfind, [], delitem, contains, capitalize, endsWith, startsWith, startsWith, join, split, center, title, str, $, +=, PyBytes, translate, rsplit, TypedTranslateTableABC, ord1, items, ==, substr, PyStr, isupper, index, startsWith, index, rjust, ascii, translate, [], reversed, items, runeLenAt, ==, len, chars, count, newPyByteArray, toPyStr, @, u, *, rsplit, splitlines, expandtabs, reverse, rjust, not, b, rsplit, [], casefold, fromhex, split, isupper, istitle, getChar, rfind, +=, bytearray, strip, hasChar, oct, +, +, islower, lstrip, $, +, pop, delitem, startsWith, <>, rsplit, translate, index, items, PyByteArray, ascii, fspath, []=, newPyByteArray, *, rjust, extend, f, +, StrTypedTranslateTable, isalpha, fspath, *, osErrorMsgWithPath, raiseExcWithPath2, RuntimeError, raiseExcWithPath, newStopIteration, ConnectionError, PyOSError, GeneratorExit, newUnicodeDecodeError, ConnectionResetError, newBlockingIOError, raiseErrnoWithPath, InterruptedError, $, NotADirectoryError, newStopIteration, errnoMsg, ProcessLookupError, BrokenPipeError, TimeoutError, raiseExcWithPath, PyOSError, msg, raiseExcWithPath, osErrorMsgWithPath, UnicodeDecodeError, raiseErrno, tryOsOp, ConnectionRefusedError, IsADirectoryError, raiseExcWithPath, $, ArithmeticError, tryOsOp, BlockingIOError, StopAsyncIteration, PyOSError, ConnectionAbortedError, NotImplementedError, SystemExit, tryOsOp, FileNotFoundError, BlockingIOError, ChildProcessError, BlockingIOError, StopIterationT, noWeirdTarget, TypeError, newPyOSError, NameError, $, KeyboardInterrupt, AttributeError, newUnicodeDecodeError, newPyOSError, StopIteration, PermissionError, raiseErrnoT, msg, FileExistsError, tryOsOp, newBlockingIOError, UnicodeError, ZeroDivisionError, $, len, range, max, index, PyRange, range, items, count, min, repr, range, contains, [], slice, slice, indices, PySlice, <, toNimSlice, PySlice1, <=, ==, repr, toPySlice, slice, []=, newPyList, newPyList, sorted, <, <=, nimArrayAsList, []=, list, ==, pop, count, repr, []=, newPyList, <=, sorted, PyList, sort, sorted, clear, $, [], newPyListOfCap, index, append, index, newPyListOfStr, [], checkLenientOps, +=, getPtr, newPyList, <, pop, []=, sort, +=, list, pairs, delitem, delitem, extend, []=, setLen, list, []=, <, items, count, <=, newPyListOfStr, extend, ==, newPyList, *=, []=, newPyList, []=, len, mitems, *, +, insert, ==, @, +, reverse, list, delitem, reverse, repr, *, [], list, [], SomeSinglePyDictView, PyDictItemView, values, PyDictValueView, copy, ==, contains, |, pop, SomePyDictView, repr, toPyDict, contains, toPyDict, $, $, $, PyDict, popitem, values, iter, items, setdefault, items, pop, $, clear, []=, get, contains, PyDictKeyView, items, iter, iter, repr, emptyPyDict, repr, len, len, update, dict, keys, keys, contains, get, delitem, PyDictView, |=, repr, [], symmetric_difference, add, <, <=, union, set, symmetric_difference, isdisjoint, ==, hash, pyset, ^, set, $, remove, <, $, -, difference_update, pyset, PyFrozenSet, difference, intersection, clear, newPyFrozenSet, set, copy, difference, frozenset, <=, -, symmetric_difference, intersection, ==, issuperset, newPyFrozenSet, symmetric_difference, frozenset, discard, ==, set, pyset, union, update, symmetric_difference, frozenset, SomeSet, &=, |=, set, |, repr, frozenset, <=, contains, $, issubset, PySet, -, intersection, intersection_update, newPySet, set, -=, repr, SomePySet, pop, pyset, pyset, union, pysetLit, intersection, difference, union, <, items, &, frozenset, union, len, pydiscard, frozenset, intersection, difference, difference, newPySet, len, items, hash, hash, hash, hash, hash, hash, hash, hash, hash, dirImpl, dirImpl, dir, dir +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/builtins.idx b/pylib/builtins.idx new file mode 100644 index 000000000..06fca20dc --- /dev/null +++ b/pylib/builtins.idx @@ -0,0 +1 @@ +nimTitle builtins pylib/builtins.html module src/pylib/builtins 0 diff --git a/pylib/builtins/asciiImpl.html b/pylib/builtins/asciiImpl.html new file mode 100644 index 000000000..327629e98 --- /dev/null +++ b/pylib/builtins/asciiImpl.html @@ -0,0 +1,111 @@ + + + + + + + +src/pylib/builtins/asciiImpl + + + + + + + + + + + + + + + + +
+
+

src/pylib/builtins/asciiImpl

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Procs

+
+
+
+
func pyasciiImpl(us: string): string {....raises: [], tags: [], forbids: [].}
+
+ +

Python's ascii impl

+

Note this assumes us is already processed by repr i.e., this only escape the non-ASCII characters in us using x, u, or U escapes and doesn't touch ASCII characters.

+ + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/builtins/asciiImpl.idx b/pylib/builtins/asciiImpl.idx new file mode 100644 index 000000000..8eecc6d42 --- /dev/null +++ b/pylib/builtins/asciiImpl.idx @@ -0,0 +1,2 @@ +nimTitle asciiImpl pylib/builtins/asciiImpl.html module src/pylib/builtins/asciiImpl 0 +nim pyasciiImpl pylib/builtins/asciiImpl.html#pyasciiImpl,string proc pyasciiImpl(us: string): string 10 diff --git a/pylib/builtins/attr.html b/pylib/builtins/attr.html new file mode 100644 index 000000000..f6ee0095a --- /dev/null +++ b/pylib/builtins/attr.html @@ -0,0 +1,207 @@ + + + + + + + +src/pylib/builtins/attr + + + + + + + + + + + + + + + + +
+
+

src/pylib/builtins/attr

+
+ +
+ Source   +Edit   + +
+ +

+ +
+

Macros

+
+
+
+
macro getattr(x; attr: static[PyStr]): untyped
+
+ + + Source   +Edit   + +
+
+
+
macro getattr(x; attr: static[PyStr]; default): untyped
+
+ + + Source   +Edit   + +
+
+
+
macro getattr(x; attr: static[string]): untyped
+
+ + + Source   +Edit   + +
+
+
+
macro getattr(x; attr: static[string]; default): untyped
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
macro hasattr(x; attr: static[PyStr]): bool
+
+ + + Source   +Edit   + +
+
+
+
macro hasattr(x; attr: static[string]): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
macro setattr(x; attr: static[PyStr]; val)
+
+ + + Source   +Edit   + +
+
+
+
macro setattr(x; attr: static[string]; val)
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/builtins/attr.idx b/pylib/builtins/attr.idx new file mode 100644 index 000000000..ea7188506 --- /dev/null +++ b/pylib/builtins/attr.idx @@ -0,0 +1,12 @@ +nimTitle attr pylib/builtins/attr.html module src/pylib/builtins/attr 0 +nim hasattr pylib/builtins/attr.html#hasattr.m,,static[string] macro hasattr(x; attr: static[string]): bool 10 +nim getattr pylib/builtins/attr.html#getattr.m,,static[string] macro getattr(x; attr: static[string]): untyped 14 +nim getattr pylib/builtins/attr.html#getattr.m,,static[string], macro getattr(x; attr: static[string]; default): untyped 20 +nim setattr pylib/builtins/attr.html#setattr.m,,static[string], macro setattr(x; attr: static[string]; val) 36 +nim hasattr pylib/builtins/attr.html#hasattr.m,,static[PyStr] macro hasattr(x; attr: static[PyStr]): bool 10 +nim getattr pylib/builtins/attr.html#getattr.m,,static[PyStr] macro getattr(x; attr: static[PyStr]): untyped 14 +nim getattr pylib/builtins/attr.html#getattr.m,,static[PyStr], macro getattr(x; attr: static[PyStr]; default): untyped 20 +nim setattr pylib/builtins/attr.html#setattr.m,,static[PyStr], macro setattr(x; attr: static[PyStr]; val) 37 +nimgrp setattr pylib/builtins/attr.html#setattr-macros-all macro 30 +nimgrp hasattr pylib/builtins/attr.html#hasattr-macros-all macro 10 +nimgrp getattr pylib/builtins/attr.html#getattr-macros-all macro 14 diff --git a/pylib/builtins/complex.html b/pylib/builtins/complex.html new file mode 100644 index 000000000..45efcdc9c --- /dev/null +++ b/pylib/builtins/complex.html @@ -0,0 +1,1128 @@ + + + + + + + +src/pylib/builtins/complex + + + + + + + + + + + + + + + + +
+
+

src/pylib/builtins/complex

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

builtins.complex and its operators/methods.

+

Use toNimComplex and pycomplex to convert between PyComplex and Complex

+ +

Example:

+
import src/pylib/builtins/complex
+assert complex(1, 3) == complex("1.0+3.0J")
+assert complex(1, 3) == 1 + 3.J
+
+# complex only stores floats, not int,
+# just as Python's
+assert not (type(complex(1, 2).real) is int)

+ +
+

Types

+
+
+
PyComplex = PyTComplex[float]
+
+ + + Source   +Edit   + +
+
+
+
PyTComplex[T] = distinct Complex[T]
+
+ + generics version of PyComplex + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
func `$`(z: PyTComplex): string
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func `'j`(s: static string): PyComplex
+
+ + 1+3'j or 1+3'J
Note: +Nim disallows custom suffixes without '. Therefore, something like 1+3j is not not allowed.
+

Consider using complex or j instead, which are totaly Python syntax compatiable.

+ +

Example:

+
assert 1+3'j == 1.0+3.0'J
+ Source   +Edit   + +
+
+ +
+
+
+
func `**=`[T](self: var PyTComplex[T];
+              x: ComplexPowSecondParamType[T] | SomeInteger)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func abs[T](z: PyTComplex[T]): T
+
+ + builtins.abs for complex + Source   +Edit   + +
+
+ +
+
+
+
func complex(s: string): PyComplex {....raises: [ValueError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func complex[T: SomeFloat](real: T = 0.0; imag: T = 0.0): PyTComplex[T]
+
+ + + Source   +Edit   + +
+
+
+
func complex[T: SomeInteger](real: T = 0; imag: T = 0): PyComplex
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func conjugate[T](z: PyTComplex[T]): PyTComplex[T]
+
+ + complex.conjugate() + Source   +Edit   + +
+
+ +
+
+
+
func repr(z: PyTComplex): string
+
+ + Returns bj/(a+bj)/(a-bj) for complex(a, b) +

Example:

+
assert repr(complex(0.0, 3.0)) == "3j"  # not "(0+3j)", as in Python
+assert repr(complex(-0.0, 3.0)) == "(-0+3j)" # not "3j", as in Python
+
+assert repr(complex(1.0, 2.0)) == "(1+2j)"  # '.0' is removed as Python's
+ Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template `*`[T](a: PyTComplex[T]; b: PyTComplex[T]): untyped
+
+ + + Source   +Edit   + +
+
+
+
template `*`[T](a: PyTComplex[T]; b: SomeInteger): untyped
+
+ + + Source   +Edit   + +
+
+
+
template `*`[T](a: PyTComplex[T]; b: T): untyped
+
+ + + Source   +Edit   + +
+
+
+
template `*`[T](a: SomeInteger; b: PyTComplex[T]): untyped
+
+ + + Source   +Edit   + +
+
+
+
template `*`[T](a: T; b: PyTComplex[T]): untyped
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template `**`[T](a: PyTComplex[T]; b: PyTComplex[T]): untyped
+
+ + + Source   +Edit   + +
+
+
+
template `**`[T](a: PyTComplex[T]; b: T): untyped
+
+ + + Source   +Edit   + +
+
+
+
template `**`[T](a: SomeInteger; b: PyTComplex[T]): untyped
+
+ + + Source   +Edit   + +
+
+
+
template `**`[T](a: T; b: PyTComplex[T]): untyped
+
+ + + Source   +Edit   + +
+
+
+
template `**`[T](self: PyTComplex[T]; x: SomeInteger): PyTComplex[T]
+
+ + + Source   +Edit   + +
+
+
+
template `**`[T](self: PyTComplex[T]; x: static Natural): PyTComplex[T]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template `*=`[T](a: PyTComplex[T]; b: PyTComplex[T]): untyped
+
+ + + Source   +Edit   + +
+
+
+
template `*=`[T](a: PyTComplex[T]; b: SomeInteger): untyped
+
+ + + Source   +Edit   + +
+
+
+
template `*=`[T](a: PyTComplex[T]; b: T): untyped
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template `+`[T](a: PyTComplex[T]; b: PyTComplex[T]): untyped
+
+ + + Source   +Edit   + +
+
+
+
template `+`[T](a: PyTComplex[T]; b: SomeInteger): untyped
+
+ + + Source   +Edit   + +
+
+
+
template `+`[T](a: PyTComplex[T]; b: T): untyped
+
+ + + Source   +Edit   + +
+
+
+
template `+`[T](a: SomeInteger; b: PyTComplex[T]): untyped
+
+ + + Source   +Edit   + +
+
+
+
template `+`[T](a: T; b: PyTComplex[T]): untyped
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template `+=`[T](a: PyTComplex[T]; b: PyTComplex[T]): untyped
+
+ + + Source   +Edit   + +
+
+
+
template `+=`[T](a: PyTComplex[T]; b: SomeInteger): untyped
+
+ + + Source   +Edit   + +
+
+
+
template `+=`[T](a: PyTComplex[T]; b: T): untyped
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template `-`[T](a: PyTComplex[T]; b: PyTComplex[T]): untyped
+
+ + + Source   +Edit   + +
+
+
+
template `-`[T](a: PyTComplex[T]; b: SomeInteger): untyped
+
+ + + Source   +Edit   + +
+
+
+
template `-`[T](a: PyTComplex[T]; b: T): untyped
+
+ + + Source   +Edit   + +
+
+
+
template `-`[T](a: SomeInteger; b: PyTComplex[T]): untyped
+
+ + + Source   +Edit   + +
+
+
+
template `-`[T](a: T; b: PyTComplex[T]): untyped
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template `-=`[T](a: PyTComplex[T]; b: PyTComplex[T]): untyped
+
+ + + Source   +Edit   + +
+
+
+
template `-=`[T](a: PyTComplex[T]; b: SomeInteger): untyped
+
+ + + Source   +Edit   + +
+
+
+
template `-=`[T](a: PyTComplex[T]; b: T): untyped
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template `/`[T](a: PyTComplex[T]; b: PyTComplex[T]): untyped
+
+ + + Source   +Edit   + +
+
+
+
template `/`[T](a: PyTComplex[T]; b: SomeInteger): untyped
+
+ + + Source   +Edit   + +
+
+
+
template `/`[T](a: PyTComplex[T]; b: T): untyped
+
+ + + Source   +Edit   + +
+
+
+
template `/`[T](a: SomeInteger; b: PyTComplex[T]): untyped
+
+ + + Source   +Edit   + +
+
+
+
template `/`[T](a: T; b: PyTComplex[T]): untyped
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template `/=`[T](a: PyTComplex[T]; b: PyTComplex[T]): untyped
+
+ + + Source   +Edit   + +
+
+
+
template `/=`[T](a: PyTComplex[T]; b: SomeInteger): untyped
+
+ + + Source   +Edit   + +
+
+
+
template `/=`[T](a: PyTComplex[T]; b: T): untyped
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template `==`[T](a: PyTComplex[T]; b: PyTComplex[T]): untyped
+
+ + + Source   +Edit   + +
+
+
+
template `==`[T](a: PyTComplex[T]; b: SomeInteger): untyped
+
+ + + Source   +Edit   + +
+
+
+
template `==`[T](a: PyTComplex[T]; b: T): untyped
+
+ + + Source   +Edit   + +
+
+
+
template `==`[T](a: SomeInteger; b: PyTComplex[T]): untyped
+
+ + + Source   +Edit   + +
+
+
+
template `==`[T](a: T; b: PyTComplex[T]): untyped
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template complex(real, imag: HasFloat): PyComplex
+
+ + + Source   +Edit   + +
+
+
+
template complex(real, imag: HasIndex): PyComplex
+
+ +
Admonition: +since Python 3.8
+ + Source   +Edit   + +
+
+ +
+
+
+
template imag[T](z: PyTComplex[T]): T
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template imag=[T](z: PyTComplex[T]; _: T) {.
+    error: "AttributeError: readonly attribute".}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template j(i: int{lit}): PyComplex
+
+ + +

Example:

+
assert complex(1, 3) == 1+3.j
+ Source   +Edit   + +
+
+ +
+
+
+
template J(i: int{lit}): PyComplex
+
+ + the same as j, e.g. 1+3.J + Source   +Edit   + +
+
+ +
+
+
+
template pow[T](a: PyTComplex[T]; b: PyTComplex[T]): untyped
+
+ + + Source   +Edit   + +
+
+
+
template pow[T](a: PyTComplex[T]; b: T): untyped
+
+ + + Source   +Edit   + +
+
+
+
template pow[T](a: SomeInteger; b: PyTComplex[T]): untyped
+
+ + + Source   +Edit   + +
+
+
+
template pow[T](a: T; b: PyTComplex[T]): untyped
+
+ + + Source   +Edit   + +
+
+
+
template pow[T](self: ComplexPowSecondParamType[T] | SomeInteger;
+                x: PyTComplex[T]; _: NoneType): PyTComplex[T]
+
+ + + Source   +Edit   + +
+
+
+
template pow[T](self: PyTComplex[T];
+                x: ComplexPowSecondParamType[T] | SomeInteger; _: NoneType): PyTComplex[
+    T]
+
+ + + Source   +Edit   + +
+
+
+
template pow[T](self: PyTComplex[T]; x: SomeInteger): PyTComplex[T]
+
+ + + Source   +Edit   + +
+
+
+
template pow[T](self: PyTComplex[T]; x: static Natural): PyTComplex[T]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template pycomplex[T](re: T; im = T(0)): PyTComplex[T]
+
+ + alias of complex. Useful when import both std/complex and pylib + Source   +Edit   + +
+
+
+
template pycomplex[T](z: Complex[T]): PyTComplex[T]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template real[T](z: PyTComplex[T]): T
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template real=[T](z: PyTComplex[T]; _: T) {.
+    error: "AttributeError: readonly attribute".}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template toNimComplex[T](z: PyTComplex[T]): Complex[T]
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/builtins/complex.idx b/pylib/builtins/complex.idx new file mode 100644 index 000000000..49ea1d2e9 --- /dev/null +++ b/pylib/builtins/complex.idx @@ -0,0 +1,88 @@ +nimTitle complex pylib/builtins/complex.html module src/pylib/builtins/complex 0 +nim PyTComplex pylib/builtins/complex.html#PyTComplex type PyTComplex 29 +nim PyComplex pylib/builtins/complex.html#PyComplex type PyComplex 30 +nim toNimComplex pylib/builtins/complex.html#toNimComplex.t,PyTComplex[T] template toNimComplex[T](z: PyTComplex[T]): Complex[T] 32 +nim imag pylib/builtins/complex.html#imag.t,PyTComplex[T] template imag[T](z: PyTComplex[T]): T 37 +nim imag= pylib/builtins/complex.html#imag=.t,PyTComplex[T],T template imag=[T](z: PyTComplex[T]; _: T) 43 +nim real pylib/builtins/complex.html#real.t,PyTComplex[T] template real[T](z: PyTComplex[T]): T 37 +nim real= pylib/builtins/complex.html#real=.t,PyTComplex[T],T template real=[T](z: PyTComplex[T]; _: T) 44 +nim repr pylib/builtins/complex.html#repr,PyTComplex proc repr(z: PyTComplex): string 55 +nim `$` pylib/builtins/complex.html#$,PyTComplex proc `$`(z: PyTComplex): string 86 +nim pycomplex pylib/builtins/complex.html#pycomplex.t,Complex[T] template pycomplex[T](z: Complex[T]): PyTComplex[T] 92 +nim complex pylib/builtins/complex.html#complex,T,T proc complex[T: SomeFloat](real: T = 0.0; imag: T = 0.0): PyTComplex[T] 96 +nim complex pylib/builtins/complex.html#complex,T,T_2 proc complex[T: SomeInteger](real: T = 0; imag: T = 0): PyComplex 98 +nim complex pylib/builtins/complex.html#complex.t,HasFloat,HasFloat template complex(real, imag: HasFloat): PyComplex 107 +nim complex pylib/builtins/complex.html#complex.t,HasIndex,HasIndex template complex(real, imag: HasIndex): PyComplex 112 +nim complex pylib/builtins/complex.html#complex,string proc complex(s: string): PyComplex 116 +nim pycomplex pylib/builtins/complex.html#pycomplex.t,T,typeof(T(0)) template pycomplex[T](re: T; im = T(0)): PyTComplex[T] 197 +nim abs pylib/builtins/complex.html#abs,PyTComplex[T] proc abs[T](z: PyTComplex[T]): T 204 +nim conjugate pylib/builtins/complex.html#conjugate,PyTComplex[T] proc conjugate[T](z: PyTComplex[T]): PyTComplex[T] 206 +nim `+` pylib/builtins/complex.html#+.t,, template `+`[T](a: PyTComplex[T]; b: PyTComplex[T]): untyped 227 +nim `+` pylib/builtins/complex.html#+.t,,T template `+`[T](a: PyTComplex[T]; b: T): untyped 229 +nim `+` pylib/builtins/complex.html#+.t,,SomeInteger template `+`[T](a: PyTComplex[T]; b: SomeInteger): untyped 231 +nim `+` pylib/builtins/complex.html#+.t,T, template `+`[T](a: T; b: PyTComplex[T]): untyped 233 +nim `+` pylib/builtins/complex.html#+.t,SomeInteger, template `+`[T](a: SomeInteger; b: PyTComplex[T]): untyped 234 +nim `-` pylib/builtins/complex.html#-.t,, template `-`[T](a: PyTComplex[T]; b: PyTComplex[T]): untyped 227 +nim `-` pylib/builtins/complex.html#-.t,,T template `-`[T](a: PyTComplex[T]; b: T): untyped 229 +nim `-` pylib/builtins/complex.html#-.t,,SomeInteger template `-`[T](a: PyTComplex[T]; b: SomeInteger): untyped 231 +nim `-` pylib/builtins/complex.html#-.t,T, template `-`[T](a: T; b: PyTComplex[T]): untyped 233 +nim `-` pylib/builtins/complex.html#-.t,SomeInteger, template `-`[T](a: SomeInteger; b: PyTComplex[T]): untyped 234 +nim `*` pylib/builtins/complex.html#*.t,, template `*`[T](a: PyTComplex[T]; b: PyTComplex[T]): untyped 227 +nim `*` pylib/builtins/complex.html#*.t,,T template `*`[T](a: PyTComplex[T]; b: T): untyped 229 +nim `*` pylib/builtins/complex.html#*.t,,SomeInteger template `*`[T](a: PyTComplex[T]; b: SomeInteger): untyped 231 +nim `*` pylib/builtins/complex.html#*.t,T, template `*`[T](a: T; b: PyTComplex[T]): untyped 233 +nim `*` pylib/builtins/complex.html#*.t,SomeInteger, template `*`[T](a: SomeInteger; b: PyTComplex[T]): untyped 234 +nim `/` pylib/builtins/complex.html#/.t,, template `/`[T](a: PyTComplex[T]; b: PyTComplex[T]): untyped 227 +nim `/` pylib/builtins/complex.html#/.t,,T template `/`[T](a: PyTComplex[T]; b: T): untyped 229 +nim `/` pylib/builtins/complex.html#/.t,,SomeInteger template `/`[T](a: PyTComplex[T]; b: SomeInteger): untyped 231 +nim `/` pylib/builtins/complex.html#/.t,T, template `/`[T](a: T; b: PyTComplex[T]): untyped 233 +nim `/` pylib/builtins/complex.html#/.t,SomeInteger, template `/`[T](a: SomeInteger; b: PyTComplex[T]): untyped 234 +nim pow pylib/builtins/complex.html#pow.t,, template pow[T](a: PyTComplex[T]; b: PyTComplex[T]): untyped 227 +nim pow pylib/builtins/complex.html#pow.t,,T template pow[T](a: PyTComplex[T]; b: T): untyped 229 +nim pow pylib/builtins/complex.html#pow.t,T, template pow[T](a: T; b: PyTComplex[T]): untyped 233 +nim pow pylib/builtins/complex.html#pow.t,SomeInteger, template pow[T](a: SomeInteger; b: PyTComplex[T]): untyped 234 +nim `**` pylib/builtins/complex.html#**.t,, template `**`[T](a: PyTComplex[T]; b: PyTComplex[T]): untyped 227 +nim `**` pylib/builtins/complex.html#**.t,,T template `**`[T](a: PyTComplex[T]; b: T): untyped 229 +nim `**` pylib/builtins/complex.html#**.t,T, template `**`[T](a: T; b: PyTComplex[T]): untyped 233 +nim `**` pylib/builtins/complex.html#**.t,SomeInteger, template `**`[T](a: SomeInteger; b: PyTComplex[T]): untyped 234 +nim `==` pylib/builtins/complex.html#==.t,, template `==`[T](a: PyTComplex[T]; b: PyTComplex[T]): untyped 227 +nim `==` pylib/builtins/complex.html#==.t,,T template `==`[T](a: PyTComplex[T]; b: T): untyped 229 +nim `==` pylib/builtins/complex.html#==.t,,SomeInteger template `==`[T](a: PyTComplex[T]; b: SomeInteger): untyped 231 +nim `==` pylib/builtins/complex.html#==.t,T, template `==`[T](a: T; b: PyTComplex[T]): untyped 233 +nim `==` pylib/builtins/complex.html#==.t,SomeInteger, template `==`[T](a: SomeInteger; b: PyTComplex[T]): untyped 234 +nim `+=` pylib/builtins/complex.html#+=.t,, template `+=`[T](a: PyTComplex[T]; b: PyTComplex[T]): untyped 227 +nim `+=` pylib/builtins/complex.html#+=.t,,T template `+=`[T](a: PyTComplex[T]; b: T): untyped 229 +nim `+=` pylib/builtins/complex.html#+=.t,,SomeInteger template `+=`[T](a: PyTComplex[T]; b: SomeInteger): untyped 231 +nim `-=` pylib/builtins/complex.html#-=.t,, template `-=`[T](a: PyTComplex[T]; b: PyTComplex[T]): untyped 227 +nim `-=` pylib/builtins/complex.html#-=.t,,T template `-=`[T](a: PyTComplex[T]; b: T): untyped 229 +nim `-=` pylib/builtins/complex.html#-=.t,,SomeInteger template `-=`[T](a: PyTComplex[T]; b: SomeInteger): untyped 231 +nim `*=` pylib/builtins/complex.html#*=.t,, template `*=`[T](a: PyTComplex[T]; b: PyTComplex[T]): untyped 227 +nim `*=` pylib/builtins/complex.html#*=.t,,T template `*=`[T](a: PyTComplex[T]; b: T): untyped 229 +nim `*=` pylib/builtins/complex.html#*=.t,,SomeInteger template `*=`[T](a: PyTComplex[T]; b: SomeInteger): untyped 231 +nim `/=` pylib/builtins/complex.html#/=.t,, template `/=`[T](a: PyTComplex[T]; b: PyTComplex[T]): untyped 227 +nim `/=` pylib/builtins/complex.html#/=.t,,T template `/=`[T](a: PyTComplex[T]; b: T): untyped 229 +nim `/=` pylib/builtins/complex.html#/=.t,,SomeInteger template `/=`[T](a: PyTComplex[T]; b: SomeInteger): untyped 231 +nim pow pylib/builtins/complex.html#pow.t,PyTComplex[T],staticNatural template pow[T](self: PyTComplex[T]; x: static Natural): PyTComplex[T] 255 +nim pow pylib/builtins/complex.html#pow.t,PyTComplex[T],SomeInteger template pow[T](self: PyTComplex[T]; x: SomeInteger): PyTComplex[T] 263 +nim `**` pylib/builtins/complex.html#**.t,PyTComplex[T],staticNatural template `**`[T](self: PyTComplex[T]; x: static Natural): PyTComplex[T] 255 +nim `**` pylib/builtins/complex.html#**.t,PyTComplex[T],SomeInteger template `**`[T](self: PyTComplex[T]; x: SomeInteger): PyTComplex[T] 264 +nim `**=` pylib/builtins/complex.html#**=,PyTComplex[T], proc `**=`[T](self: var PyTComplex[T]; x: ComplexPowSecondParamType[T] | SomeInteger) 268 +nim pow pylib/builtins/complex.html#pow.t,PyTComplex[T],,NoneType template pow[T](self: PyTComplex[T]; x: ComplexPowSecondParamType[T] | SomeInteger;\n _: NoneType): PyTComplex[T] 277 +nim pow pylib/builtins/complex.html#pow.t,,PyTComplex[T],NoneType template pow[T](self: ComplexPowSecondParamType[T] | SomeInteger; x: PyTComplex[T];\n _: NoneType): PyTComplex[T] 278 +nim `'j` pylib/builtins/complex.html#'j,staticstring proc `'j`(s: static string): PyComplex 280 +nim j pylib/builtins/complex.html#j.t template j(i: int{lit}): PyComplex 294 +nim J pylib/builtins/complex.html#J.t_2 template J(i: int{lit}): PyComplex 300 +nimgrp complex pylib/builtins/complex.html#complex-procs-all proc 96 +nimgrp == pylib/builtins/complex.html#==-templates-all template 248 +nimgrp + pylib/builtins/complex.html#+-templates-all template 242 +nimgrp pow pylib/builtins/complex.html#pow-templates-all template 246 +nimgrp - pylib/builtins/complex.html#--templates-all template 243 +nimgrp / pylib/builtins/complex.html#/-templates-all template 245 +nimgrp ** pylib/builtins/complex.html#**-templates-all template 247 +nimgrp -= pylib/builtins/complex.html#-=-templates-all template 250 +nimgrp * pylib/builtins/complex.html#*-templates-all template 244 +nimgrp *= pylib/builtins/complex.html#*=-templates-all template 251 +nimgrp /= pylib/builtins/complex.html#/=-templates-all template 252 +nimgrp complex pylib/builtins/complex.html#complex-templates-all template 107 +nimgrp += pylib/builtins/complex.html#+=-templates-all template 249 +nimgrp pycomplex pylib/builtins/complex.html#pycomplex-templates-all template 92 diff --git a/pylib/builtins/dict.html b/pylib/builtins/dict.html new file mode 100644 index 000000000..3b7968230 --- /dev/null +++ b/pylib/builtins/dict.html @@ -0,0 +1,888 @@ + + + + + + + +src/pylib/builtins/dict + + + + + + + + + + + + + + + + +
+
+

src/pylib/builtins/dict

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Types

+
+
+
PyDictItemView[K; V] = object of PyDictView
+  mapping*: PyDict[K, V]
+
+ + + Source   +Edit   + +
+
+
+
PyDictKeyView[T] = object of PyDictView
+  mapping*: PyDict[T, auto]
+
+ + + Source   +Edit   + +
+
+
+
PyDictValueView[T] = object of PyDictView
+  mapping*: PyDict[auto, T]
+
+ + + Source   +Edit   + +
+
+
+
PyDictView = object of RootObj
+
+ +
Warning: +currently mapping attr is dict itself, i.e. modifiable
+ + Source   +Edit   + +
+
+ +
+
SomeSinglePyDictView[T] = PyDictValueView[T] | PyDictKeyView[T]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
proc `==`[A, B](self, other: PyDict[A, B]): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc `[]`[A, B](t: PyDict[A, B]; key: A): B
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc `[]=`[A, B](t: PyDict[A, B]; key: A; val: sink B)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc clear(self: PyDict)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc contains[A, B](t: PyDict[A, B]; key: A): bool
+
+ + + Source   +Edit   + +
+
+
+
func contains[K, V](t: PyDictItemView[K, V]; x: (K, V)): bool
+
+ + + Source   +Edit   + +
+
+
+
func contains[T](t: PyDictKeyView[T]; x: T): bool
+
+ + + Source   +Edit   + +
+
+
+
func contains[T](t: PyDictValueView[T]; x: T): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func copy[K, V](self: PyDict[K, V]): PyDict[K, V]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc delitem[K, V](self: PyDict[K, V]; k: K)
+
+ + pysugar expect such a proc to hook del d[k] + Source   +Edit   + +
+
+ +
+
+
+
func get[K, V](self: PyDict[K, V]; key: K): V
+
+ + + Source   +Edit   + +
+
+
+
func get[K, V](self: PyDict[K, V]; key: K; default: V): V
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func items[K, V](self: PyDict[K, V]): PyDictItemView[K, V]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func iter[K, V](self: PyDict[K, V]): PyIterator[K]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func keys[K, V](self: PyDict[K, V]): PyDictKeyView[K]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc len(self: PyDict): int
+
+ + dict.__len__ + Source   +Edit   + +
+
+
+
proc len(view: SomePyDictView): int
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func pop[K, V](self: PyDict[K, V]; key: K): V
+
+ + + Source   +Edit   + +
+
+
+
func pop[K, V](self: PyDict[K, V]; key: K; default: V): V
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func popitem[K, V](self: PyDict[K, V]): (K, V)
+
+ +
Warning: +this is currently LILO instead of LIFO
+ + Source   +Edit   + +
+
+ +
+
+
+
func setdefault[K, V](self: PyDict[K, V]; key: K; default = V.default)
+
+ +
Warning: +default defaults to V.default instead of None
+ + Source   +Edit   + +
+
+ +
+
+
+
func toPyDict[K, V](x: not openArray[(K, V)] and Iterable[(K, V)]): PyDict[K, V]
+
+ + + Source   +Edit   + +
+
+
+
func toPyDict[K, V](x: openArray[(K, V)]): PyDict[K, V]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func values[K, V](self: PyDict[K, V]): PyDictValueView[V]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func `|`(a, b: PyDict): PyDict
+
+ + Python-like merge dict operator, a new dict is created from a and b, keys in the second operand override keys in the first operand + Source   +Edit   + +
+
+ +
+
+
+
proc `|=`(a, b: PyDict)
+
+ + Python-like in-place dict update operator. b is added into a, keys in b override same keys from a + Source   +Edit   + +
+
+ +
+ +
+
+
+

Iterators

+
+
+
+
iterator items[K, V](self: PyDict[K, V]): (K, V)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
iterator iter[K, V](self: PyDict[K, V]): K
+
+ +
Warning: +Nim's for stmt calls items implicitly, instead of iter so beware to always write iter for dict in for loop
+ +

Example:

+
let d = dict(a=1)
+for i in iter(d):
+  assert i == "a"
+for i in d:
+  assert i[0] == "a" and i[1] == 1
+ Source   +Edit   + +
+
+ +
+
+
+
iterator keys[K, V](self: PyDict[K, V]): K
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
iterator values[K, V](self: PyDict[K, V]): V
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Macros

+
+
+
+
macro dict(kwargs: varargs[untyped]): PyDict
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
macro update(self: PyDict; kws: varargs[untyped])
+
+ + d.update(**kws) d.update(iterable, **kws) + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template `$`(self: PyDict): string
+
+ + + Source   +Edit   + +
+
+
+
template `$`(self: PyDictItemView): string
+
+ + + Source   +Edit   + +
+
+
+
template `$`(self: PyDictKeyView): string
+
+ + + Source   +Edit   + +
+
+
+
template `$`(self: PyDictValueView): string
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template items(view: SomePyDictView): untyped
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template iter(view: SomePyDictView): untyped
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template repr(self: PyDict): string {.dirty.}
+
+ + + Source   +Edit   + +
+
+
+
template repr(self: PyDictItemView): string {.dirty.}
+
+ + + Source   +Edit   + +
+
+
+
template repr(self: PyDictKeyView): string {.dirty.}
+
+ + + Source   +Edit   + +
+
+
+
template repr(self: PyDictValueView): string {.dirty.}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ + +
+
+ + +
+
+ + + diff --git a/pylib/builtins/dict.idx b/pylib/builtins/dict.idx new file mode 100644 index 000000000..584ec1797 --- /dev/null +++ b/pylib/builtins/dict.idx @@ -0,0 +1,56 @@ +nimTitle dict pylib/builtins/dict.html module src/pylib/builtins/dict 0 +nim PyDictView pylib/builtins/dict.html#PyDictView object PyDictView 14 +nim PyDictKeyView pylib/builtins/dict.html#PyDictKeyView object PyDictKeyView 16 +nim PyDictValueView pylib/builtins/dict.html#PyDictValueView object PyDictValueView 18 +nim PyDictItemView pylib/builtins/dict.html#PyDictItemView object PyDictItemView 20 +nim SomeSinglePyDictView pylib/builtins/dict.html#SomeSinglePyDictView type SomeSinglePyDictView 22 +nim SomePyDictView pylib/builtins/dict.html#SomePyDictView type SomePyDictView 23 +nim contains pylib/builtins/dict.html#contains,PyDict[A,B],A proc contains[A, B](t: PyDict[A, B]; key: A): bool 26 +nim `[]` pylib/builtins/dict.html#[],PyDict[A,B],A proc `[]`[A, B](t: PyDict[A, B]; key: A): B 27 +nim `[]=` pylib/builtins/dict.html#[]=,PyDict[A,B],A,sinkB proc `[]=`[A, B](t: PyDict[A, B]; key: A; val: sink B) 28 +nim repr pylib/builtins/dict.html#repr.t,PyDict template repr(self: PyDict): string 42 +nim `$` pylib/builtins/dict.html#$.t,PyDict template `$`(self: PyDict): string 36 +nim len pylib/builtins/dict.html#len proc len(self: PyDict): int 38 +nim `==` pylib/builtins/dict.html#==,PyDict[A,B],PyDict[A,B] proc `==`[A, B](self, other: PyDict[A, B]): bool 42 +nim clear pylib/builtins/dict.html#clear proc clear(self: PyDict) 44 +nim len pylib/builtins/dict.html#len,SomePyDictView proc len(view: SomePyDictView): int 46 +nim iter pylib/builtins/dict.html#iter.t,SomePyDictView template iter(view: SomePyDictView): untyped 47 +nim items pylib/builtins/dict.html#items.t,SomePyDictView template items(view: SomePyDictView): untyped 48 +nim contains pylib/builtins/dict.html#contains,PyDictKeyView[T],T proc contains[T](t: PyDictKeyView[T]; x: T): bool 49 +nim contains pylib/builtins/dict.html#contains,PyDictValueView[T],T proc contains[T](t: PyDictValueView[T]; x: T): bool 50 +nim contains pylib/builtins/dict.html#contains,PyDictItemView[K,V], proc contains[K, V](t: PyDictItemView[K, V]; x: (K, V)): bool 53 +nim repr pylib/builtins/dict.html#repr.t,PyDictKeyView template repr(self: PyDictKeyView): string 42 +nim `$` pylib/builtins/dict.html#$.t,PyDictKeyView template `$`(self: PyDictKeyView): string 57 +nim repr pylib/builtins/dict.html#repr.t,PyDictValueView template repr(self: PyDictValueView): string 42 +nim `$` pylib/builtins/dict.html#$.t,PyDictValueView template `$`(self: PyDictValueView): string 58 +nim repr pylib/builtins/dict.html#repr.t,PyDictItemView template repr(self: PyDictItemView): string 42 +nim `$` pylib/builtins/dict.html#$.t,PyDictItemView template `$`(self: PyDictItemView): string 59 +nim keys pylib/builtins/dict.html#keys.i,PyDict[K,V] iterator keys[K, V](self: PyDict[K, V]): K 62 +nim iter pylib/builtins/dict.html#iter.i,PyDict[K,V] iterator iter[K, V](self: PyDict[K, V]): K 65 +nim iter pylib/builtins/dict.html#iter,PyDict[K,V] proc iter[K, V](self: PyDict[K, V]): PyIterator[K] 77 +nim values pylib/builtins/dict.html#values.i,PyDict[K,V] iterator values[K, V](self: PyDict[K, V]): V 81 +nim items pylib/builtins/dict.html#items.i,PyDict[K,V] iterator items[K, V](self: PyDict[K, V]): (K, V) 84 +nim keys pylib/builtins/dict.html#keys,PyDict[K,V] proc keys[K, V](self: PyDict[K, V]): PyDictKeyView[K] 87 +nim values pylib/builtins/dict.html#values,PyDict[K,V] proc values[K, V](self: PyDict[K, V]): PyDictValueView[V] 88 +nim items pylib/builtins/dict.html#items,PyDict[K,V] proc items[K, V](self: PyDict[K, V]): PyDictItemView[K, V] 89 +nim toPyDict pylib/builtins/dict.html#toPyDict,openArray[] proc toPyDict[K, V](x: openArray[(K, V)]): PyDict[K, V] 91 +nim toPyDict pylib/builtins/dict.html#toPyDict proc toPyDict[K, V](x: not openArray[(K, V)] and Iterable[(K, V)]): PyDict[K, V] 95 +nim copy pylib/builtins/dict.html#copy,PyDict[K,V] proc copy[K, V](self: PyDict[K, V]): PyDict[K, V] 101 +nim setdefault pylib/builtins/dict.html#setdefault,PyDict[K,V],K proc setdefault[K, V](self: PyDict[K, V]; key: K; default = V.default) 108 +nim get pylib/builtins/dict.html#get,PyDict[K,V],K proc get[K, V](self: PyDict[K, V]; key: K): V 115 +nim get pylib/builtins/dict.html#get,PyDict[K,V],K,V proc get[K, V](self: PyDict[K, V]; key: K; default: V): V 116 +nim pop pylib/builtins/dict.html#pop,PyDict[K,V],K proc pop[K, V](self: PyDict[K, V]; key: K): V 117 +nim pop pylib/builtins/dict.html#pop,PyDict[K,V],K,V proc pop[K, V](self: PyDict[K, V]; key: K; default: V): V 120 +nim popitem pylib/builtins/dict.html#popitem,PyDict[K,V] proc popitem[K, V](self: PyDict[K, V]): (K, V) 124 +nim delitem pylib/builtins/dict.html#delitem,PyDict[K,V],K proc delitem[K, V](self: PyDict[K, V]; k: K) 131 +nim dict pylib/builtins/dict.html#dict.m,varargs[untyped] macro dict(kwargs: varargs[untyped]): PyDict 162 +nim update pylib/builtins/dict.html#update.m,PyDict,varargs[untyped] macro update(self: PyDict; kws: varargs[untyped]) 184 +nim `|` pylib/builtins/dict.html#|,PyDict,PyDict proc `|`(a, b: PyDict): PyDict 206 +nim `|=` pylib/builtins/dict.html#|=,PyDict,PyDict proc `|=`(a, b: PyDict) 214 +nimgrp contains pylib/builtins/dict.html#contains-procs-all proc 26 +nimgrp topydict pylib/builtins/dict.html#toPyDict-procs-all proc 91 +nimgrp get pylib/builtins/dict.html#get-procs-all proc 115 +nimgrp len pylib/builtins/dict.html#len-procs-all proc 38 +nimgrp pop pylib/builtins/dict.html#pop-procs-all proc 117 +nimgrp $ pylib/builtins/dict.html#$-templates-all template 46 +nimgrp repr pylib/builtins/dict.html#repr-templates-all template 42 diff --git a/pylib/builtins/dict_decl.html b/pylib/builtins/dict_decl.html new file mode 100644 index 000000000..c1a55bf61 --- /dev/null +++ b/pylib/builtins/dict_decl.html @@ -0,0 +1,260 @@ + + + + + + + +src/pylib/builtins/dict_decl + + + + + + + + + + + + + + + + +
+
+

src/pylib/builtins/dict_decl

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+
+ Deprecated: use newPyDict, to be removed since 0.10 +
+ +

+
+

Types

+
+
+
dict[K; V] = ref object
+
+ + + Source   +Edit   + +
+
+
+
PyDict[K; V] = dict[K, V]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
func emptyPyDict[K, V](): PyDict[K, V]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc getOrDefault[A, B](t: PyDict[A, B]; key: A): B
+
+ + inner. used to impl get(key, default) + Source   +Edit   + +
+
+ +
+
+
+
func newPyDict[K, V](x: int): PyDict[K, V] {.inline.}
+
+ + + Source   +Edit   + +
+
+
+
func newPyDict[K, V](x: openArray[(K, V)] = []): PyDict[K, V]
+
+ + zero or one arg shall support [], {k:v, ...}, @[(k, v),...] + Source   +Edit   + +
+
+ +
+
+
+
func toNimTable[K, V](self: PyDict[K, V]): var OrderedTable[K, V]
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template newPyDictImpl[K, V](x: int): untyped {.
+    ...deprecated: "use newPyDict, to be removed since 0.10".}
+
+
+ Deprecated: use newPyDict, to be removed since 0.10 +
+ + + Source   +Edit   + +
+
+
+
template newPyDictImpl[K, V](x: openArray[(K, V)] = []): untyped {.
+    ...deprecated: "use newPyDict, to be removed since 0.10".}
+
+
+ Deprecated: use newPyDict, to be removed since 0.10 +
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/builtins/dict_decl.idx b/pylib/builtins/dict_decl.idx new file mode 100644 index 000000000..526dfc8f3 --- /dev/null +++ b/pylib/builtins/dict_decl.idx @@ -0,0 +1,12 @@ +nimTitle dict_decl pylib/builtins/dict_decl.html module src/pylib/builtins/dict_decl 0 +nim dict pylib/builtins/dict_decl.html#dict type dict 5 +nim PyDict pylib/builtins/dict_decl.html#PyDict type PyDict 7 +nim toNimTable pylib/builtins/dict_decl.html#toNimTable,PyDict[K,V] proc toNimTable[K, V](self: PyDict[K, V]): var OrderedTable[K, V] 9 +nim newPyDict pylib/builtins/dict_decl.html#newPyDict,int proc newPyDict[K, V](x: int): PyDict[K, V] 11 +nim newPyDict pylib/builtins/dict_decl.html#newPyDict,openArray[] proc newPyDict[K, V](x: openArray[(K, V)] = []): PyDict[K, V] 15 +nim newPyDictImpl pylib/builtins/dict_decl.html#newPyDictImpl.t,int template newPyDictImpl[K, V](x: int): untyped 22 +nim newPyDictImpl pylib/builtins/dict_decl.html#newPyDictImpl.t,openArray[] template newPyDictImpl[K, V](x: openArray[(K, V)] = []): untyped 26 +nim getOrDefault pylib/builtins/dict_decl.html#getOrDefault,PyDict[A,B],A proc getOrDefault[A, B](t: PyDict[A, B]; key: A): B 31 +nim emptyPyDict pylib/builtins/dict_decl.html#emptyPyDict proc emptyPyDict[K, V](): PyDict[K, V] 34 +nimgrp newpydict pylib/builtins/dict_decl.html#newPyDict-procs-all proc 11 +nimgrp newpydictimpl pylib/builtins/dict_decl.html#newPyDictImpl-templates-all template 22 diff --git a/pylib/builtins/dirImpl.html b/pylib/builtins/dirImpl.html new file mode 100644 index 000000000..3ef3b2bc3 --- /dev/null +++ b/pylib/builtins/dirImpl.html @@ -0,0 +1,183 @@ + + + + + + + +src/pylib/builtins/dirImpl + + + + + + + + + + + + + + + + +
+
+

src/pylib/builtins/dirImpl

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
proc dir(o: o:type): PyList[PyStr]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc dirImpl(o: o:type): seq[string]
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Iterators

+
+
+
+
iterator dir(o: o:type): PyStr
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
iterator dirImpl(o: o:type): string
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/builtins/dirImpl.idx b/pylib/builtins/dirImpl.idx new file mode 100644 index 000000000..8a4d7c73a --- /dev/null +++ b/pylib/builtins/dirImpl.idx @@ -0,0 +1,5 @@ +nimTitle dirImpl pylib/builtins/dirImpl.html module src/pylib/builtins/dirImpl 0 +nim dirImpl pylib/builtins/dirImpl.html#dirImpl.i iterator dirImpl(o: o:type): string 8 +nim dir pylib/builtins/dirImpl.html#dir.i iterator dir(o: o:type): PyStr 11 +nim dirImpl pylib/builtins/dirImpl.html#dirImpl proc dirImpl(o: o:type): seq[string] 14 +nim dir pylib/builtins/dirImpl.html#dir proc dir(o: o:type): PyList[PyStr] 17 diff --git a/pylib/builtins/format.html b/pylib/builtins/format.html new file mode 100644 index 000000000..ed36a335a --- /dev/null +++ b/pylib/builtins/format.html @@ -0,0 +1,118 @@ + + + + + + + +src/pylib/builtins/format + + + + + + + + + + + + + + + + +
+
+

src/pylib/builtins/format

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
proc format[T](self: T; spec: static[string] | string): PyStr
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/builtins/format.idx b/pylib/builtins/format.idx new file mode 100644 index 000000000..e9e8909e5 --- /dev/null +++ b/pylib/builtins/format.idx @@ -0,0 +1,2 @@ +nimTitle format pylib/builtins/format.html module src/pylib/builtins/format 0 +nim format pylib/builtins/format.html#format,T, proc format[T](self: T; spec: static[string] | string): PyStr 5 diff --git a/pylib/builtins/input.html b/pylib/builtins/input.html new file mode 100644 index 000000000..ff25c4bb4 --- /dev/null +++ b/pylib/builtins/input.html @@ -0,0 +1,119 @@ + + + + + + + +src/pylib/builtins/input + + + + + + + + + + + + + + + + +
+
+

src/pylib/builtins/input

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
proc input(prompt = str("")): PyStr {....raises: [RuntimeError, OSError, Exception,
+    PyOSError, IOError], tags: [RootEffect, ReadIOEffect], forbids: [].}
+
+ + when on non-nodejs JavaScript backend, uses prompt + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/builtins/input.idx b/pylib/builtins/input.idx new file mode 100644 index 000000000..93c823410 --- /dev/null +++ b/pylib/builtins/input.idx @@ -0,0 +1,2 @@ +nimTitle input pylib/builtins/input.html module src/pylib/builtins/input 0 +nim input pylib/builtins/input.html#input proc input(prompt = str("")): PyStr 68 diff --git a/pylib/builtins/iter_next.html b/pylib/builtins/iter_next.html new file mode 100644 index 000000000..41fe2cbf6 --- /dev/null +++ b/pylib/builtins/iter_next.html @@ -0,0 +1,247 @@ + + + + + + + +src/pylib/builtins/iter_next + + + + + + + + + + + + + + + + +
+
+

src/pylib/builtins/iter_next

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

builtins.iter

+ +
+

Types

+
+
+
PyIterator[T] = ref object
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
func iter[T](x: Iterable[T]): PyIterator[T]
+
+ + + Source   +Edit   + +
+
+
+
func iter[T](x: Iterator[T]): PyIterator[T]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func newPyIterator[T](it: iterator (): T): PyIterator[T]
+
+ + init with a Nim iterator + Source   +Edit   + +
+
+ +
+
+
+
proc next[T](self: PyIterator[T]): T
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc nextImpl[T](self: PyIterator[T]): Option[T] {.inline.}
+
+ + EXT. Get rid of exception for faster iteration. + Source   +Edit   + +
+
+
+
proc nextImpl[T](self: PyIterator[T]; res: var T): bool {.inline.}
+
+ + EXT. Get rid of exception for faster iteration. + Source   +Edit   + +
+
+ +
+ +
+
+
+

Iterators

+
+
+
+
iterator items[T](self: PyIterator[T]): T
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/builtins/iter_next.idx b/pylib/builtins/iter_next.idx new file mode 100644 index 000000000..bd68ce454 --- /dev/null +++ b/pylib/builtins/iter_next.idx @@ -0,0 +1,11 @@ +nimTitle iter_next pylib/builtins/iter_next.html module src/pylib/builtins/iter_next 0 +nim PyIterator pylib/builtins/iter_next.html#PyIterator type PyIterator 10 +nim newPyIterator pylib/builtins/iter_next.html#newPyIterator proc newPyIterator[T](it: iterator (): T): PyIterator[T] 13 +nim iter pylib/builtins/iter_next.html#iter,Iterable[T] proc iter[T](x: Iterable[T]): PyIterator[T] 17 +nim iter pylib/builtins/iter_next.html#iter,Iterator[T] proc iter[T](x: Iterator[T]): PyIterator[T] 26 +nim items pylib/builtins/iter_next.html#items.i,PyIterator[T] iterator items[T](self: PyIterator[T]): T 35 +nim nextImpl pylib/builtins/iter_next.html#nextImpl,PyIterator[T] proc nextImpl[T](self: PyIterator[T]): Option[T] 39 +nim nextImpl pylib/builtins/iter_next.html#nextImpl,PyIterator[T],T proc nextImpl[T](self: PyIterator[T]; res: var T): bool 44 +nim next pylib/builtins/iter_next.html#next,PyIterator[T] proc next[T](self: PyIterator[T]): T 49 +nimgrp iter pylib/builtins/iter_next.html#iter-procs-all proc 17 +nimgrp nextimpl pylib/builtins/iter_next.html#nextImpl-procs-all proc 39 diff --git a/pylib/builtins/iters.html b/pylib/builtins/iters.html new file mode 100644 index 000000000..a0ee4f4e6 --- /dev/null +++ b/pylib/builtins/iters.html @@ -0,0 +1,439 @@ + + + + + + + +src/pylib/builtins/iters + + + + + + + + + + + + + + + + +
+
+

src/pylib/builtins/iters

+
+ +
+ Source   +Edit   + +
+ +

Some iterable in builtins

+

XXX: For JS backend: Currently due to Nim's inner buys, using of some iterable functions in this modules may result in Error: ...:

+
  • list(...)
  • +
  • filter/map/... as func (using iterator is okey) (solved after Nim-2.1.1)
  • +
+

For details, trace:

+ +

+ +
+

Procs

+
+
+
+
func enumerate[T](x: Iterable[T]; start = 0): Enumerate[T]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func filter[T](comp: NoneType; iter: Iterable[T]): Filter[T]
+
+ + + Source   +Edit   + +
+
+
+
func filter[T](comp: proc (arg: T): bool; iter: Iterable[T]): Filter[T]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func map[T, R](function: proc (x: T): R; iterable: Iterable[T]): Map[T]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func reversed[T](x: Sequence[T]): Reversed[T]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func zip[A, B](it1: Iterable[A]; it2: Iterable[B]; strict = false): Zip[A]
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Iterators

+
+
+
+
iterator enumerate[T](x: Iterable[T]; start = 0): (int, T)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
iterator filter[T](comp: NoneType; iter: Iterable[T]): T
+
+ + + Source   +Edit   + +
+
+
+
iterator filter[T](comp: proc (arg: T): bool; iter: Iterable[T]): T
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
iterator items[T](x: Enumerate[T]): T
+
+ + + Source   +Edit   + +
+
+
+
iterator items[T](x: Filter[T]): T
+
+ + + Source   +Edit   + +
+
+
+
iterator items[T](x: Map[T]): T
+
+ + + Source   +Edit   + +
+
+
+
iterator items[T](x: Reversed[T]): T
+
+ + + Source   +Edit   + +
+
+
+
iterator items[T](x: Zip[T]): T
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
iterator map[T, R](function: proc (x: T): R; iterable: Iterable[T]): R
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
iterator reversed[T](x: Sequence[T]): T
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
iterator zip[A, B](it1: Iterable[A]; it2: Iterable[B]; strict = false): (A, B)
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Macros

+
+
+
+
macro map(function: proc; iterable: typed; iterables: varargs[typed]): Map
+
+ +
Note: +unlike Python, if arguments number does not fit function, instead of runtime error compile-time error occurs, in which a generated temporary name gen_iter_res will be seen
+ + Source   +Edit   + +
+
+ +
+
+
+
macro zip(iterables_or_strict: varargs[untyped]): Zip
+
+ + zip(*args, strict=False)
+

To support its similarity with Python's zip function signature, this macro signature has to be varargs[untyped].

+

So it's designed to be undefined when pylibDisableMoreArgsZip is defined.

+ + Source   +Edit   + +
+
+ +
+ +
+
+
+

Exports

+
+ None, iter, iter, iter, next, next +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/builtins/iters.idx b/pylib/builtins/iters.idx new file mode 100644 index 000000000..50f22f020 --- /dev/null +++ b/pylib/builtins/iters.idx @@ -0,0 +1,23 @@ +nimTitle iters pylib/builtins/iters.html module src/pylib/builtins/iters 0 +nim items pylib/builtins/iters.html#items.i,Filter[T] iterator items[T](x: Filter[T]): T 38 +nim filter pylib/builtins/iters.html#filter,proc(T),Iterable[T] proc filter[T](comp: proc (arg: T): bool; iter: Iterable[T]): Filter[T] 27 +nim filter pylib/builtins/iters.html#filter.i,proc(T),Iterable[T] iterator filter[T](comp: proc (arg: T): bool; iter: Iterable[T]): T 27 +nim filter pylib/builtins/iters.html#filter,NoneType,Iterable[T] proc filter[T](comp: NoneType; iter: Iterable[T]): Filter[T] 32 +nim filter pylib/builtins/iters.html#filter.i,NoneType,Iterable[T] iterator filter[T](comp: NoneType; iter: Iterable[T]): T 32 +nim items pylib/builtins/iters.html#items.i,Enumerate[T] iterator items[T](x: Enumerate[T]): T 38 +nim enumerate pylib/builtins/iters.html#enumerate,Iterable[T],int proc enumerate[T](x: Iterable[T]; start = 0): Enumerate[T] 37 +nim enumerate pylib/builtins/iters.html#enumerate.i,Iterable[T],int iterator enumerate[T](x: Iterable[T]; start = 0): (int, T) 37 +nim items pylib/builtins/iters.html#items.i,Reversed[T] iterator items[T](x: Reversed[T]): T 38 +nim reversed pylib/builtins/iters.html#reversed,Sequence[T] proc reversed[T](x: Sequence[T]): Reversed[T] 43 +nim reversed pylib/builtins/iters.html#reversed.i,Sequence[T] iterator reversed[T](x: Sequence[T]): T 43 +nim items pylib/builtins/iters.html#items.i,Map[T] iterator items[T](x: Map[T]): T 51 +nim map pylib/builtins/iters.html#map,proc(T),Iterable[T] proc map[T, R](function: proc (x: T): R; iterable: Iterable[T]): Map[T] 53 +nim map pylib/builtins/iters.html#map.i,proc(T),Iterable[T] iterator map[T, R](function: proc (x: T): R; iterable: Iterable[T]): R 54 +nim map pylib/builtins/iters.html#map.m,proc,typed,varargs[typed] macro map(function: proc; iterable: typed; iterables: varargs[typed]): Map 64 +nim items pylib/builtins/iters.html#items.i,Zip[T] iterator items[T](x: Zip[T]): T 74 +nim zip pylib/builtins/iters.html#zip,Iterable[A],Iterable[B] proc zip[A, B](it1: Iterable[A]; it2: Iterable[B]; strict = false): Zip[A] 116 +nim zip pylib/builtins/iters.html#zip.i,Iterable[A],Iterable[B] iterator zip[A, B](it1: Iterable[A]; it2: Iterable[B]; strict = false): (A, B) 116 +nim zip pylib/builtins/iters.html#zip.m,varargs[untyped] macro zip(iterables_or_strict: varargs[untyped]): Zip 153 +nimgrp filter pylib/builtins/iters.html#filter-procs-all proc 27 +nimgrp items pylib/builtins/iters.html#items-iterators-all iterator 14 +nimgrp filter pylib/builtins/iters.html#filter-iterators-all iterator 27 diff --git a/pylib/builtins/iters/macroutils.html b/pylib/builtins/iters/macroutils.html new file mode 100644 index 000000000..5ec607c7e --- /dev/null +++ b/pylib/builtins/iters/macroutils.html @@ -0,0 +1,340 @@ + + + + + + + +src/pylib/builtins/iters/macroutils + + + + + + + + + + + + + + + + +
+
+

src/pylib/builtins/iters/macroutils

+
+ +
+ Source   +Edit   + +
+ +

+ +
+

Types

+
+
+
PreBreakCb = proc (i: NimNode): NimNode {.closure.}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Lets

+
+
+
emptyn {.compileTime.} = newEmptyNode()
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Consts

+
+
+
preferredGenIterResName {.strdefine.} = "gen_iter_res"
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
proc addEachIter(loopBody: NimNode; nIt: int; itors, res: NimNode;
+                 preBreakCb: PreBreakCb = noopPreBreakCb) {....raises: [Exception],
+    tags: [RootEffect], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc addLoopEach(loopBody: NimNode; parent: NimNode;
+                 iterables: NimNode | seq[NimNode];
+                 res = ident preferredGenIterResName;
+                 preBreakCb: PreBreakCb = noopPreBreakCb): NimNode {.discardable.}
+
+ + returns res type (a tuple) + Source   +Edit   + +
+
+ +
+
+
+
proc addResDecl(body: NimNode; iterables: NimNode | seq[NimNode];
+                res = ident preferredGenIterResName;
+                iters = genSym(nskLet, "iters")): NimNode {.discardable.}
+
+ + returns res type (a tuple) + Source   +Edit   + +
+
+ +
+
+
+
proc addYield(res, dest: NimNode) {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func newLoop(body: NimNode): NimNode {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc newNullaryLambdaIter(body: NimNode; resType = ident"auto"): NimNode {.
+    ...raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func newTuple(): NimNode {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func noInitVarDecl(name, Type: NimNode): NimNode {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Exports

+
+ iter, iter +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/builtins/iters/macroutils.idx b/pylib/builtins/iters/macroutils.idx new file mode 100644 index 000000000..b2fc7a5db --- /dev/null +++ b/pylib/builtins/iters/macroutils.idx @@ -0,0 +1,12 @@ +nimTitle macroutils pylib/builtins/iters/macroutils.html module src/pylib/builtins/iters/macroutils 0 +nim newTuple pylib/builtins/iters/macroutils.html#newTuple proc newTuple(): NimNode 6 +nim emptyn pylib/builtins/iters/macroutils.html#emptyn let emptyn 7 +nim noInitVarDecl pylib/builtins/iters/macroutils.html#noInitVarDecl,NimNode,NimNode proc noInitVarDecl(name, Type: NimNode): NimNode 10 +nim preferredGenIterResName pylib/builtins/iters/macroutils.html#preferredGenIterResName const preferredGenIterResName 14 +nim addResDecl pylib/builtins/iters/macroutils.html#addResDecl,NimNode, proc addResDecl(body: NimNode; iterables: NimNode | seq[NimNode];\n res = ident preferredGenIterResName; iters = genSym(nskLet, "iters")): NimNode 16 +nim newLoop pylib/builtins/iters/macroutils.html#newLoop,NimNode proc newLoop(body: NimNode): NimNode 33 +nim newNullaryLambdaIter pylib/builtins/iters/macroutils.html#newNullaryLambdaIter,NimNode proc newNullaryLambdaIter(body: NimNode; resType = ident"auto"): NimNode 36 +nim PreBreakCb pylib/builtins/iters/macroutils.html#PreBreakCb type PreBreakCb 39 +nim addEachIter pylib/builtins/iters/macroutils.html#addEachIter,NimNode,int,NimNode,NimNode,PreBreakCb proc addEachIter(loopBody: NimNode; nIt: int; itors, res: NimNode;\n preBreakCb: PreBreakCb = noopPreBreakCb) 43 +nim addYield pylib/builtins/iters/macroutils.html#addYield,NimNode,NimNode proc addYield(res, dest: NimNode) 55 +nim addLoopEach pylib/builtins/iters/macroutils.html#addLoopEach,NimNode,NimNode,,PreBreakCb proc addLoopEach(loopBody: NimNode; parent: NimNode;\n iterables: NimNode | seq[NimNode];\n res = ident preferredGenIterResName;\n preBreakCb: PreBreakCb = noopPreBreakCb): NimNode 59 diff --git a/pylib/builtins/iters/mapMacro.html b/pylib/builtins/iters/mapMacro.html new file mode 100644 index 000000000..cc80f57b4 --- /dev/null +++ b/pylib/builtins/iters/mapMacro.html @@ -0,0 +1,119 @@ + + + + + + + +src/pylib/builtins/iters/mapMacro + + + + + + + + + + + + + + + + +
+
+

src/pylib/builtins/iters/mapMacro

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Imports

+
+ macroutils +
+
+
+

Procs

+
+
+
+
proc mapIterBodyImpl(f: NimNode; iterables: NimNode; res = genSym(nskVar, "res")): NimNode {.
+    ...raises: [Exception], tags: [RootEffect], forbids: [].}
+
+ + res: generated symbol name temporarily storing iteration result and will be used as if f(*res) in Python at each loop; do not use genSym if wanting simpler err msg for arg num mismatch + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/builtins/iters/mapMacro.idx b/pylib/builtins/iters/mapMacro.idx new file mode 100644 index 000000000..3d821a1d9 --- /dev/null +++ b/pylib/builtins/iters/mapMacro.idx @@ -0,0 +1,2 @@ +nimTitle mapMacro pylib/builtins/iters/mapMacro.html module src/pylib/builtins/iters/mapMacro 0 +nim mapIterBodyImpl pylib/builtins/iters/mapMacro.html#mapIterBodyImpl,NimNode,NimNode proc mapIterBodyImpl(f: NimNode; iterables: NimNode; res = genSym(nskVar, "res")): NimNode 6 diff --git a/pylib/builtins/iters/zipMacro.html b/pylib/builtins/iters/zipMacro.html new file mode 100644 index 000000000..70ec84632 --- /dev/null +++ b/pylib/builtins/iters/zipMacro.html @@ -0,0 +1,136 @@ + + + + + + + +src/pylib/builtins/iters/zipMacro + + + + + + + + + + + + + + + + +
+
+

src/pylib/builtins/iters/zipMacro

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Imports

+
+ macroutils +
+
+
+

Procs

+
+
+
+
func raiseZipBound(ordLonger: int) {.inline, ...raises: [ValueError], tags: [],
+                                     forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc zipIterBodyImpl(iterables: NimNode | seq[NimNode]; strict: NimNode): NimNode
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/builtins/iters/zipMacro.idx b/pylib/builtins/iters/zipMacro.idx new file mode 100644 index 000000000..98d054f63 --- /dev/null +++ b/pylib/builtins/iters/zipMacro.idx @@ -0,0 +1,3 @@ +nimTitle zipMacro pylib/builtins/iters/zipMacro.html module src/pylib/builtins/iters/zipMacro 0 +nim raiseZipBound pylib/builtins/iters/zipMacro.html#raiseZipBound,int proc raiseZipBound(ordLonger: int) 5 +nim zipIterBodyImpl pylib/builtins/iters/zipMacro.html#zipIterBodyImpl,,NimNode proc zipIterBodyImpl(iterables: NimNode | seq[NimNode]; strict: NimNode): NimNode 10 diff --git a/pylib/builtins/list.html b/pylib/builtins/list.html new file mode 100644 index 000000000..fc383731a --- /dev/null +++ b/pylib/builtins/list.html @@ -0,0 +1,758 @@ + + + + + + + +src/pylib/builtins/list + + + + + + + + + + + + + + + + +
+
+

src/pylib/builtins/list

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

Python's list with its methods and sorted buitin

+

LIMIT: slice literal is not supported. ls[1:3] has to be rewritten as ls[1..2]

+

+ +
+

Procs

+
+
+
+
func `*`[T](n: Natural; ls: PyList[T]): PyList[T]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func `*=`[T](self: var PyList[T]; n: int)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func `+`[T](self: PyList[T]; x: openArray[T]): PyList[T]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func `+=`[T](self: var PyList[T]; ls: openArray[T])
+
+ + + Source   +Edit   + +
+
+
+
func `+=`[T](self: var PyList[T]; ls: PyList[T])
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func `[]`[T](self: PyList[T]; idx: int): T
+
+ + + Source   +Edit   + +
+
+
+
func `[]`[T](self: PyList[T]; s: BackwardsIndex): T
+
+ + + Source   +Edit   + +
+
+
+
func `[]`[T](self: PyList[T]; s: HSlice): PyList[T]
+
+ + + Source   +Edit   + +
+
+
+
func `[]`[T](self: PyList[T]; s: PySlice): PyList[T]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func `[]=`[T](ms: var PyList[T]; indices: Slice[int]; o: Sequence[T])
+
+ + + Source   +Edit   + +
+
+
+
func `[]=`[T](self: var PyList[T]; idx: int; x: T)
+
+ + + Source   +Edit   + +
+
+
+
func `[]=`[T](self: var PyList[T]; s: BackwardsIndex; x: T)
+
+ + + Source   +Edit   + +
+
+
+
func `[]=`[T](self: var PyList[T]; s: HSlice; x: Iterable[T])
+
+ + + Source   +Edit   + +
+
+
+
func `[]=`[T](self: var PyList[T]; s: HSlice; x: openArray[T])
+
+ + + Source   +Edit   + +
+
+
+
func `[]=`[T](self: var PyList[T]; s: HSlice; x: PyList[T])
+
+ + + Source   +Edit   + +
+
+
+
func `[]=`[T](self: var PyList[T]; s: PySlice;
+              x: not Sequence[T] and Iterable[T])
+
+ + + Source   +Edit   + +
+
+
+
func `[]=`[T](self: var PyList[T]; s: PySlice; x: Sequence[T])
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func append[T](self: var PyList[T]; x: T)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func clear(self: var PyList)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func delitem(ms: var PyList; indices: PySlice)
+
+ + + Source   +Edit   + +
+
+
+
func delitem(ms: var PyList; indices: Slice[int])
+
+ + + Source   +Edit   + +
+
+
+
func delitem(self: var PyList; idx: int)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func extend[T](self: var PyList[T]; ls: openArray[T])
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func insert[T](self: var PyList[T]; idx: int; x: T)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func list[T](): PyList[T]
+
+ + +

Example:

+
assert len(list[int]()) == 0
+ Source   +Edit   + +
+
+
+
func list[T](a: sink openArray[T]): PyList[T]
+
+ + + Source   +Edit   + +
+
+
+
proc list[T](iter: Iterable[T]): PyList[T]
+
+ + + Source   +Edit   + +
+
+
+
func list[T](x: sink seq[T]): PyList[T]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func pop[T](self: var PyList[T]): T {.discardable.}
+
+ + + Source   +Edit   + +
+
+
+
func pop[T](self: var PyList[T]; index: int): T {.discardable.}
+
+ + index can be negative to index backwards. + Source   +Edit   + +
+
+ +
+
+
+
func reverse(self: var PyList)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc sort[T, K](self: var PyList[T]; key: proc (x: T): K; reverse = false)
+
+ + list.sort(key, reverse=False) + Source   +Edit   + +
+
+
+
func sort[T](self: var PyList[T]; reverse = false)
+
+ + list.sort(reverse=False) + Source   +Edit   + +
+
+ +
+
+
+
proc sorted[T, K](x: not Sequence[T] and Iterable[T]; key: proc (x: T): K;
+                  reverse = false): PyList[T]
+
+ + + Source   +Edit   + +
+
+
+
proc sorted[T, K](x: Sequence[T]; key: proc (x: T): K; reverse = false): PyList[
+    T]
+
+ + + Source   +Edit   + +
+
+
+
func sorted[T](self: PyList[T]; reverse = false): PyList[T]
+
+ + sorted(list, reverse=False) + Source   +Edit   + +
+
+ +
+ +
+
+
+

Converters

+
+
+
+
converter nimArrayAsList[T; I](arr: array[I, T]): PyList[T]
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template `$`(self: PyList): string
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template `*`[T](ls: PyList[T]; n: Natural): PyList[T]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template `+`[T](self: var PyList[T]; x: PyList[T]): PyList[T]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template extend[T](self: var PyList[T]; ls: Iterable[T])
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template len(self: PyList): int
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template repr(self: PyList): string {.dirty.}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ + +
+
+ + +
+
+ + + diff --git a/pylib/builtins/list.idx b/pylib/builtins/list.idx new file mode 100644 index 000000000..7322e7500 --- /dev/null +++ b/pylib/builtins/list.idx @@ -0,0 +1,52 @@ +nimTitle list pylib/builtins/list.html module src/pylib/builtins/list 0 +nim nimArrayAsList pylib/builtins/list.html#nimArrayAsList.c,array[I,T] converter nimArrayAsList[T; I](arr: array[I, T]): PyList[T] 23 +nim len pylib/builtins/list.html#len.t,PyList template len(self: PyList): int 26 +nim `[]=` pylib/builtins/list.html#[]=,PyList[T],int,T proc `[]=`[T](self: var PyList[T]; idx: int; x: T) 31 +nim `[]` pylib/builtins/list.html#[],PyList[T],int proc `[]`[T](self: PyList[T]; idx: int): T 33 +nim `[]=` pylib/builtins/list.html#[]=,PyList[T],HSlice,openArray[T] proc `[]=`[T](self: var PyList[T]; s: HSlice; x: openArray[T]) 36 +nim `[]=` pylib/builtins/list.html#[]=,PyList[T],HSlice,PyList[T] proc `[]=`[T](self: var PyList[T]; s: HSlice; x: PyList[T]) 38 +nim `[]=` pylib/builtins/list.html#[]=,PyList[T],BackwardsIndex,T proc `[]=`[T](self: var PyList[T]; s: BackwardsIndex; x: T) 41 +nim list pylib/builtins/list.html#list,Iterable[T] proc list[T](iter: Iterable[T]): PyList[T] 44 +nim `[]=` pylib/builtins/list.html#[]=,PyList[T],HSlice,Iterable[T] proc `[]=`[T](self: var PyList[T]; s: HSlice; x: Iterable[T]) 45 +nim `[]=` pylib/builtins/list.html#[]=,PyList[T],PySlice,Sequence[T] proc `[]=`[T](self: var PyList[T]; s: PySlice; x: Sequence[T]) 54 +nim `[]=` pylib/builtins/list.html#[]=,PyList[T],PySlice, proc `[]=`[T](self: var PyList[T]; s: PySlice; x: not Sequence[T] and Iterable[T]) 68 +nim append pylib/builtins/list.html#append,PyList[T],T proc append[T](self: var PyList[T]; x: T) 74 +nim `+=` pylib/builtins/list.html#+=,PyList[T],openArray[T] proc `+=`[T](self: var PyList[T]; ls: openArray[T]) 75 +nim `+=` pylib/builtins/list.html#+=,PyList[T],PyList[T] proc `+=`[T](self: var PyList[T]; ls: PyList[T]) 76 +nim `[]` pylib/builtins/list.html#[],PyList[T],HSlice proc `[]`[T](self: PyList[T]; s: HSlice): PyList[T] 78 +nim `[]` pylib/builtins/list.html#[],PyList[T],BackwardsIndex proc `[]`[T](self: PyList[T]; s: BackwardsIndex): T 80 +nim `[]` pylib/builtins/list.html#[],PyList[T],PySlice proc `[]`[T](self: PyList[T]; s: PySlice): PyList[T] 83 +nim reverse pylib/builtins/list.html#reverse,PyList proc reverse(self: var PyList) 93 +nim pop pylib/builtins/list.html#pop,PyList[T] proc pop[T](self: var PyList[T]): T 95 +nim pop pylib/builtins/list.html#pop,PyList[T],int proc pop[T](self: var PyList[T]; index: int): T 96 +nim extend pylib/builtins/list.html#extend,PyList[T],openArray[T] proc extend[T](self: var PyList[T]; ls: openArray[T]) 102 +nim extend pylib/builtins/list.html#extend.t,PyList[T],Iterable[T] template extend[T](self: var PyList[T]; ls: Iterable[T]) 105 +nim insert pylib/builtins/list.html#insert,PyList[T],int,T proc insert[T](self: var PyList[T]; idx: int; x: T) 109 +nim delitem pylib/builtins/list.html#delitem,PyList,int proc delitem(self: var PyList; idx: int) 115 +nim clear pylib/builtins/list.html#clear,PyList proc clear(self: var PyList) 118 +nim sort pylib/builtins/list.html#sort,PyList[T] proc sort[T](self: var PyList[T]; reverse = false) 125 +nim sorted pylib/builtins/list.html#sorted,PyList[T] proc sorted[T](self: PyList[T]; reverse = false): PyList[T] 129 +nim `+` pylib/builtins/list.html#+,PyList[T],openArray[T] proc `+`[T](self: PyList[T]; x: openArray[T]): PyList[T] 133 +nim list pylib/builtins/list.html#list,sinkseq[T] proc list[T](x: sink seq[T]): PyList[T] 136 +nim list pylib/builtins/list.html#list,sinkopenArray[T] proc list[T](a: sink openArray[T]): PyList[T] 137 +nim list pylib/builtins/list.html#list_2 proc list[T](): PyList[T] 142 +nim `*` pylib/builtins/list.html#*,Natural,PyList[T] proc `*`[T](n: Natural; ls: PyList[T]): PyList[T] 147 +nim `*` pylib/builtins/list.html#*.t,PyList[T],Natural template `*`[T](ls: PyList[T]; n: Natural): PyList[T] 151 +nim `*=` pylib/builtins/list.html#*=,PyList[T],int proc `*=`[T](self: var PyList[T]; n: int) 154 +nim `+` pylib/builtins/list.html#+.t,PyList[T],PyList[T] template `+`[T](self: var PyList[T]; x: PyList[T]): PyList[T] 158 +nim repr pylib/builtins/list.html#repr.t,PyList template repr(self: PyList): string 42 +nim `$` pylib/builtins/list.html#$.t,PyList template `$`(self: PyList): string 172 +nim sort pylib/builtins/list.html#sort,PyList[T],proc(T) proc sort[T, K](self: var PyList[T]; key: proc (x: T): K; reverse = false) 234 +nim sorted pylib/builtins/list.html#sorted,Sequence[T],proc(T) proc sorted[T, K](x: Sequence[T]; key: proc (x: T): K; reverse = false): PyList[T] 239 +nim sorted pylib/builtins/list.html#sorted,,proc(T) proc sorted[T, K](x: not Sequence[T] and Iterable[T]; key: proc (x: T): K;\n reverse = false): PyList[T] 244 +nim delitem pylib/builtins/list.html#delitem,PyList,Slice[int] proc delitem(ms: var PyList; indices: Slice[int]) 13 +nim delitem pylib/builtins/list.html#delitem,PyList,PySlice proc delitem(ms: var PyList; indices: PySlice) 249 +nim `[]=` pylib/builtins/list.html#[]=,PyList[T],Slice[int],Sequence[T] proc `[]=`[T](ms: var PyList[T]; indices: Slice[int]; o: Sequence[T]) 250 +nimgrp sort pylib/builtins/list.html#sort-procs-all proc 125 +nimgrp []= pylib/builtins/list.html#[]=-procs-all proc 31 +nimgrp list pylib/builtins/list.html#list-procs-all proc 44 +nimgrp sorted pylib/builtins/list.html#sorted-procs-all proc 129 +nimgrp [] pylib/builtins/list.html#[]-procs-all proc 33 +nimgrp += pylib/builtins/list.html#+=-procs-all proc 75 +nimgrp pop pylib/builtins/list.html#pop-procs-all proc 95 +nimgrp delitem pylib/builtins/list.html#delitem-procs-all proc 115 diff --git a/pylib/builtins/list_decl.html b/pylib/builtins/list_decl.html new file mode 100644 index 000000000..8a10c93e9 --- /dev/null +++ b/pylib/builtins/list_decl.html @@ -0,0 +1,601 @@ + + + + + + + +src/pylib/builtins/list_decl + + + + + + + + + + + + + + + + +
+
+

src/pylib/builtins/list_decl

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Types

+
+
+
list[T] = ref object
+
+ + + Source   +Edit   + +
+
+
+
PyList[T] = list[T]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
func `<`[A, B](self: PyList[A]; o: openArray[B]): bool {.inline.}
+
+ + + Source   +Edit   + +
+
+
+
func `<`[A, B](self: PyList[A]; o: PyList[B]): bool {.inline.}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func `<=`[A, B](self: PyList[A]; o: openArray[B]): bool {.inline.}
+
+ + + Source   +Edit   + +
+
+
+
func `<=`[A, B](self: PyList[A]; o: PyList[B]): bool {.inline.}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func `==`[A, B](self: PyList[A]; o: openArray[B]): bool {.inline.}
+
+ + + Source   +Edit   + +
+
+
+
func `==`[A, B](self: PyList[A]; o: PyList[B]): bool {.inline.}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func `@`[T](ls: PyList[T]): seq[T]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func getPtr[T](self: sink PyList[T]; i: Natural | BackwardsIndex): ptr T {.
+    inline.}
+
+ + EXT. unstable. used by Lib/array frombytes and tobytes. + Source   +Edit   + +
+
+ +
+
+
+
func newPyList(a: sink openArray[char]): PyList[char] {.inline, ...raises: [],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func newPyList(a: sink openArray[float]): PyList[float] {.inline, ...raises: [],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func newPyList(a: sink openArray[int]): PyList[int] {.inline, ...raises: [],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func newPyList[T](a: sink openArray[T]): PyList[T] {.inline.}
+
+ + + Source   +Edit   + +
+
+
+
func newPyList[T](len = 0): PyList[T] {.inline.}
+
+ + + Source   +Edit   + +
+
+
+
func newPyList[T](s: sink seq[T]): PyList[T] {.inline.}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func newPyListOfCap[T](cap = 0): PyList[T] {.inline.}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func newPyListOfStr(a: openArray[string]): PyList[PyStr] {.inline, ...raises: [],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func newPyListOfStr(a: PyList[string]): PyList[PyStr] {.inline, ...raises: [],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func repr[T: set | string | openArray](self: PyList[T]): string
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func setLen(self: PyList; len: Natural)
+
+ + EXT. unstable. only works for simple types + Source   +Edit   + +
+
+ +
+ +
+
+
+

Iterators

+
+
+
+
iterator items[T](self: PyList[T]): T
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
iterator mitems[T](self: PyList[T]): var T
+
+ + EXT. + Source   +Edit   + +
+
+ +
+
+
+
iterator pairs[T](self: PyList[T]): (int, T)
+
+ + EXT. Nim's auto-enumerate + Source   +Edit   + +
+
+ +
+ +
+
+
+

Converters

+
+
+
+
converter asSeq[T](self: PyList[T]): seq[T]
+
+ + + Source   +Edit   + +
+
+
+
converter asSeq[T](self: var PyList[T]): var seq[T]
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template `<`[A, B](o: openArray[A]; self: PyList[B]): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template `<=`[A, B](o: openArray[A]; self: PyList[B]): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template `==`[A, B](o: openArray[A]; self: PyList[B]): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template checkLenientOps(A, B)
+
+ + inner. unstable + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/builtins/list_decl.idx b/pylib/builtins/list_decl.idx new file mode 100644 index 000000000..a8f9acca6 --- /dev/null +++ b/pylib/builtins/list_decl.idx @@ -0,0 +1,37 @@ +nimTitle list_decl pylib/builtins/list_decl.html module src/pylib/builtins/list_decl 0 +nim list pylib/builtins/list_decl.html#list type list 5 +nim PyList pylib/builtins/list_decl.html#PyList type PyList 9 +nim asSeq pylib/builtins/list_decl.html#asSeq.c,PyList[T] converter asSeq[T](self: PyList[T]): seq[T] 12 +nim asSeq pylib/builtins/list_decl.html#asSeq.c,PyList[T]_2 converter asSeq[T](self: var PyList[T]): var seq[T] 13 +nim `@` pylib/builtins/list_decl.html#@,PyList[T] proc `@`[T](ls: PyList[T]): seq[T] 15 +nim setLen pylib/builtins/list_decl.html#setLen,PyList,Natural proc setLen(self: PyList; len: Natural) 16 +nim repr pylib/builtins/list_decl.html#repr,PyList[T: set or string or openArray] proc repr[T: set | string | openArray](self: PyList[T]): string 22 +nim newPyList pylib/builtins/list_decl.html#newPyList,sinkseq[T] proc newPyList[T](s: sink seq[T]): PyList[T] 26 +nim newPyList pylib/builtins/list_decl.html#newPyList,sinkopenArray[T] proc newPyList[T](a: sink openArray[T]): PyList[T] 27 +nim newPyListOfStr pylib/builtins/list_decl.html#newPyListOfStr,PyList[string] proc newPyListOfStr(a: PyList[string]): PyList[PyStr] 30 +nim newPyListOfStr pylib/builtins/list_decl.html#newPyListOfStr,openArray[string] proc newPyListOfStr(a: openArray[string]): PyList[PyStr] 31 +nim newPyList pylib/builtins/list_decl.html#newPyList,sinkopenArray[int] proc newPyList(a: sink openArray[int]): PyList[int] 42 +nim newPyList pylib/builtins/list_decl.html#newPyList,sinkopenArray[float] proc newPyList(a: sink openArray[float]): PyList[float] 43 +nim newPyList pylib/builtins/list_decl.html#newPyList,sinkopenArray[char] proc newPyList(a: sink openArray[char]): PyList[char] 44 +nim newPyList pylib/builtins/list_decl.html#newPyList,int proc newPyList[T](len = 0): PyList[T] 46 +nim newPyListOfCap pylib/builtins/list_decl.html#newPyListOfCap,int proc newPyListOfCap[T](cap = 0): PyList[T] 47 +nim items pylib/builtins/list_decl.html#items.i,PyList[T] iterator items[T](self: PyList[T]): T 50 +nim mitems pylib/builtins/list_decl.html#mitems.i,PyList[T] iterator mitems[T](self: PyList[T]): var T 53 +nim pairs pylib/builtins/list_decl.html#pairs.i,PyList[T] iterator pairs[T](self: PyList[T]): (int, T) 57 +nim getPtr pylib/builtins/list_decl.html#getPtr,sinkPyList[T], proc getPtr[T](self: sink PyList[T]; i: Natural | BackwardsIndex): ptr T 67 +nim checkLenientOps pylib/builtins/list_decl.html#checkLenientOps.t,, template checkLenientOps(A, B) 74 +nim `==` pylib/builtins/list_decl.html#==,PyList[A],PyList[B] proc `==`[A, B](self: PyList[A]; o: PyList[B]): bool 103 +nim `==` pylib/builtins/list_decl.html#==,PyList[A],openArray[B] proc `==`[A, B](self: PyList[A]; o: openArray[B]): bool 106 +nim `==` pylib/builtins/list_decl.html#==.t,openArray[A],PyList[B] template `==`[A, B](o: openArray[A]; self: PyList[B]): bool 113 +nim `<=` pylib/builtins/list_decl.html#<=,PyList[A],PyList[B] proc `<=`[A, B](self: PyList[A]; o: PyList[B]): bool 103 +nim `<=` pylib/builtins/list_decl.html#<=,PyList[A],openArray[B] proc `<=`[A, B](self: PyList[A]; o: openArray[B]): bool 106 +nim `<=` pylib/builtins/list_decl.html#<=.t,openArray[A],PyList[B] template `<=`[A, B](o: openArray[A]; self: PyList[B]): bool 114 +nim `<` pylib/builtins/list_decl.html#<,PyList[A],PyList[B] proc `<`[A, B](self: PyList[A]; o: PyList[B]): bool 103 +nim `<` pylib/builtins/list_decl.html#<,PyList[A],openArray[B] proc `<`[A, B](self: PyList[A]; o: openArray[B]): bool 106 +nim `<` pylib/builtins/list_decl.html#<.t,openArray[A],PyList[B] template `<`[A, B](o: openArray[A]; self: PyList[B]): bool 115 +nimgrp == pylib/builtins/list_decl.html#==-procs-all proc 113 +nimgrp newpylistofstr pylib/builtins/list_decl.html#newPyListOfStr-procs-all proc 30 +nimgrp newpylist pylib/builtins/list_decl.html#newPyList-procs-all proc 26 +nimgrp <= pylib/builtins/list_decl.html#<=-procs-all proc 114 +nimgrp < pylib/builtins/list_decl.html#<-procs-all proc 115 +nimgrp asseq pylib/builtins/list_decl.html#asSeq-converters-all converter 12 diff --git a/pylib/builtins/mathfunc.html b/pylib/builtins/mathfunc.html new file mode 100644 index 000000000..fc057aea6 --- /dev/null +++ b/pylib/builtins/mathfunc.html @@ -0,0 +1,141 @@ + + + + + + + +src/pylib/builtins/mathfunc + + + + + + + + + + + + + + + + +
+
+

src/pylib/builtins/mathfunc

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Imports

+
+ modPow, round +
+
+
+

Procs

+
+
+
+
func pow(base, exp, modulo: float): int {.error: "TypeError: pow() 3rd argument not allowed unless all arguments are integers".}
+
+ + raises Error like Python does, but a static error instead of runtime + Source   +Edit   + +
+
+
+
func pow(base: int; exp: Natural): int {....raises: [], tags: [], forbids: [].}
+
+ +
Warning: +pow with a negative exp shall results in float, but for static-type lang it's not possible for a function to return either a float or int, except for using a boxing type.
+

Therefore for pow(base, exp), exp cannot be negative.

+ + Source   +Edit   + +
+
+ +
+ +
+
+ + +
+
+ + +
+
+ + + diff --git a/pylib/builtins/mathfunc.idx b/pylib/builtins/mathfunc.idx new file mode 100644 index 000000000..54b56eea9 --- /dev/null +++ b/pylib/builtins/mathfunc.idx @@ -0,0 +1,4 @@ +nimTitle mathfunc pylib/builtins/mathfunc.html module src/pylib/builtins/mathfunc 0 +nim pow pylib/builtins/mathfunc.html#pow,float,float,float proc pow(base, exp, modulo: float): int 11 +nim pow pylib/builtins/mathfunc.html#pow,int,Natural proc pow(base: int; exp: Natural): int 15 +nimgrp pow pylib/builtins/mathfunc.html#pow-procs-all proc 11 diff --git a/pylib/builtins/min_max.html b/pylib/builtins/min_max.html new file mode 100644 index 000000000..596aedce4 --- /dev/null +++ b/pylib/builtins/min_max.html @@ -0,0 +1,374 @@ + + + + + + + +src/pylib/builtins/min_max + + + + + + + + + + + + + + + + +
+
+

src/pylib/builtins/min_max

+
+ +
+ Source   +Edit   + +
+ +

+ +
+

Types

+
+
+
Comparable = concept ab
+    a < b is bool
+
+ + internal. + Source   +Edit   + +
+
+
+
PyLibKey[T; C] = proc (x: T): C
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
func max[C: Comparable](a, b: C; key: NoneType): C
+
+ + + Source   +Edit   + +
+
+
+
proc max[C: Comparable](it: Iterable[C]; default: C; key = None): C
+
+ + + Source   +Edit   + +
+
+
+
proc max[C: Comparable](it: Iterable[C]; key = None): C
+
+ + + Source   +Edit   + +
+
+
+
func max[T; C](a, b: T; key: PyLibKey[T, C]): T
+
+ + + Source   +Edit   + +
+
+
+
proc max[T; C](it: Iterable[T]; default: T; key: PyLibKey[T, C]): T
+
+ + + Source   +Edit   + +
+
+
+
proc max[T; C](it: Iterable[T]; key: PyLibKey[T, C]): T
+
+ + + Source   +Edit   + +
+
+
+
func max[T](a, b, c: T; args: varargs[T]): T
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func min[C: Comparable](a, b: C; key: NoneType): C
+
+ + + Source   +Edit   + +
+
+
+
proc min[C: Comparable](it: Iterable[C]; default: C; key = None): C
+
+ + + Source   +Edit   + +
+
+
+
proc min[C: Comparable](it: Iterable[C]; key = None): C
+
+ + + Source   +Edit   + +
+
+
+
func min[T; C](a, b: T; key: PyLibKey[T, C]): T
+
+ + + Source   +Edit   + +
+
+
+
proc min[T; C](it: Iterable[T]; default: T; key: PyLibKey[T, C]): T
+
+ + + Source   +Edit   + +
+
+
+
proc min[T; C](it: Iterable[T]; key: PyLibKey[T, C]): T
+
+ + + Source   +Edit   + +
+
+
+
func min[T](a, b, c: T; args: varargs[T]): T
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Macros

+
+
+
+
macro max(kwargs: varargs[untyped]): untyped
+
+ +

for argument list: (*args, key)

+

raises compile-time TypeError when Python does so, in cases:

+
  • () # no arg
  • +
  • (arg[, default][, key]) # only one arg
  • +
  • (*args, default[, key]) # both args and default are given
  • +
+ + Source   +Edit   + +
+
+ +
+
+
+
macro min(kwargs: varargs[untyped]): untyped
+
+ +

for argument list: (*args, key)

+

raises compile-time TypeError when Python does so, in cases:

+
  • () # no arg
  • +
  • (arg[, default][, key]) # only one arg
  • +
  • (*args, default[, key]) # both args and default are given
  • +
+ + Source   +Edit   + +
+
+ +
+ +
+
+
+

Exports

+
+ items +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/builtins/min_max.idx b/pylib/builtins/min_max.idx new file mode 100644 index 000000000..46a39270d --- /dev/null +++ b/pylib/builtins/min_max.idx @@ -0,0 +1,21 @@ +nimTitle min_max pylib/builtins/min_max.html module src/pylib/builtins/min_max 0 +nim Comparable pylib/builtins/min_max.html#Comparable type Comparable 33 +nim PyLibKey pylib/builtins/min_max.html#PyLibKey type PyLibKey 36 +nim max pylib/builtins/min_max.html#max,T,T,PyLibKey[T,C] proc max[T; C](a, b: T; key: PyLibKey[T, C]): T 62 +nim max pylib/builtins/min_max.html#max,C,C,NoneType proc max[C: Comparable](a, b: C; key: NoneType): C 63 +nim max pylib/builtins/min_max.html#max,T,T,T,varargs[T] proc max[T](a, b, c: T; args: varargs[T]): T 65 +nim max pylib/builtins/min_max.html#max,Iterable[C: Comparable] proc max[C: Comparable](it: Iterable[C]; key = None): C 70 +nim max pylib/builtins/min_max.html#max,Iterable[T],PyLibKey[T,C] proc max[T; C](it: Iterable[T]; key: PyLibKey[T, C]): T 73 +nim max pylib/builtins/min_max.html#max,Iterable[C: Comparable],C proc max[C: Comparable](it: Iterable[C]; default: C; key = None): C 78 +nim max pylib/builtins/min_max.html#max,Iterable[T],T,PyLibKey[T,C] proc max[T; C](it: Iterable[T]; default: T; key: PyLibKey[T, C]): T 81 +nim max pylib/builtins/min_max.html#max.m,varargs[untyped] macro max(kwargs: varargs[untyped]): untyped 152 +nim min pylib/builtins/min_max.html#min,T,T,PyLibKey[T,C] proc min[T; C](a, b: T; key: PyLibKey[T, C]): T 62 +nim min pylib/builtins/min_max.html#min,C,C,NoneType proc min[C: Comparable](a, b: C; key: NoneType): C 63 +nim min pylib/builtins/min_max.html#min,T,T,T,varargs[T] proc min[T](a, b, c: T; args: varargs[T]): T 65 +nim min pylib/builtins/min_max.html#min,Iterable[C: Comparable] proc min[C: Comparable](it: Iterable[C]; key = None): C 70 +nim min pylib/builtins/min_max.html#min,Iterable[T],PyLibKey[T,C] proc min[T; C](it: Iterable[T]; key: PyLibKey[T, C]): T 73 +nim min pylib/builtins/min_max.html#min,Iterable[C: Comparable],C proc min[C: Comparable](it: Iterable[C]; default: C; key = None): C 78 +nim min pylib/builtins/min_max.html#min,Iterable[T],T,PyLibKey[T,C] proc min[T; C](it: Iterable[T]; default: T; key: PyLibKey[T, C]): T 81 +nim min pylib/builtins/min_max.html#min.m,varargs[untyped] macro min(kwargs: varargs[untyped]): untyped 153 +nimgrp min pylib/builtins/min_max.html#min-procs-all proc 153 +nimgrp max pylib/builtins/min_max.html#max-procs-all proc 152 diff --git a/pylib/builtins/misc.html b/pylib/builtins/misc.html new file mode 100644 index 000000000..d08acf235 --- /dev/null +++ b/pylib/builtins/misc.html @@ -0,0 +1,126 @@ + + + + + + + +src/pylib/builtins/misc + + + + + + + + + + + + + + + + +
+
+

src/pylib/builtins/misc

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Imports

+
+ ../Lib/sys +
+
+
+

Templates

+
+
+
+
template id(x): int
+
+ + +

Example:

+
let a = 1.0
+var b = 1
+assert id(a) != id(b)
+# not the same as Python's (Python's small int is stored in pool)
+block:
+  var a,b = 1
+  assert id(a) != id(b)
+ Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/builtins/misc.idx b/pylib/builtins/misc.idx new file mode 100644 index 000000000..08e0e2675 --- /dev/null +++ b/pylib/builtins/misc.idx @@ -0,0 +1,2 @@ +nimTitle misc pylib/builtins/misc.html module src/pylib/builtins/misc 0 +nim id pylib/builtins/misc.html#id.t template id(x): int 3 diff --git a/pylib/builtins/modPow.html b/pylib/builtins/modPow.html new file mode 100644 index 000000000..7beaf5792 --- /dev/null +++ b/pylib/builtins/modPow.html @@ -0,0 +1,118 @@ + + + + + + + +src/pylib/builtins/modPow + + + + + + + + + + + + + + + + +
+
+

src/pylib/builtins/modPow

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Procs

+
+
+
+
func pow(base, exp, modulo: int): int {....raises: [ValueError], tags: [],
+                                        forbids: [].}
+
+ + +

Example:

+
assert pow(10, 20, 3) == 1  # 10^20 is bigger than `high int64`
+assert pow(7, 2, 13) == 10
+assert pow(7, 20, 13) == 3
+doAssertRaises ValueError:
+  discard pow(1000, -2, 2)
+  # base is not invertible for the given modulus
+assert pow(1234, 20, 73) == 9
+ Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/builtins/modPow.idx b/pylib/builtins/modPow.idx new file mode 100644 index 000000000..35d198dcc --- /dev/null +++ b/pylib/builtins/modPow.idx @@ -0,0 +1,2 @@ +nimTitle modPow pylib/builtins/modPow.html module src/pylib/builtins/modPow 0 +nim pow pylib/builtins/modPow.html#pow,int,int,int proc pow(base, exp, modulo: int): int 140 diff --git a/pylib/builtins/numTypes.html b/pylib/builtins/numTypes.html new file mode 100644 index 000000000..775689986 --- /dev/null +++ b/pylib/builtins/numTypes.html @@ -0,0 +1,96 @@ + + + + + + + +src/pylib/builtins/numTypes + + + + + + + + + + + + + + + + +
+
+

src/pylib/builtins/numTypes

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+ +
+ + +
+
+ + + diff --git a/pylib/builtins/numTypes.idx b/pylib/builtins/numTypes.idx new file mode 100644 index 000000000..9b6bdee20 --- /dev/null +++ b/pylib/builtins/numTypes.idx @@ -0,0 +1 @@ +nimTitle numTypes pylib/builtins/numTypes.html module src/pylib/builtins/numTypes 0 diff --git a/pylib/builtins/oopFuncs.html b/pylib/builtins/oopFuncs.html new file mode 100644 index 000000000..900e7c390 --- /dev/null +++ b/pylib/builtins/oopFuncs.html @@ -0,0 +1,130 @@ + + + + + + + +src/pylib/builtins/oopFuncs + + + + + + + + + + + + + + + + +
+
+

src/pylib/builtins/oopFuncs

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Templates

+
+
+
+
template isinstance(obj, class_or_tuple): bool
+
+ + +

Example:

+
assert isinstance(1, int)
+assert isinstance(1.0, (int, float))
+assert not isinstance('c', bool)
+ Source   +Edit   + +
+
+ +
+
+
+
template issubclass(obj, class_or_tuple): bool
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/builtins/oopFuncs.idx b/pylib/builtins/oopFuncs.idx new file mode 100644 index 000000000..58d0c6bee --- /dev/null +++ b/pylib/builtins/oopFuncs.idx @@ -0,0 +1,3 @@ +nimTitle oopFuncs pylib/builtins/oopFuncs.html module src/pylib/builtins/oopFuncs 0 +nim isinstance pylib/builtins/oopFuncs.html#isinstance.t,, template isinstance(obj, class_or_tuple): bool 15 +nim issubclass pylib/builtins/oopFuncs.html#issubclass.t,, template issubclass(obj, class_or_tuple): bool 22 diff --git a/pylib/builtins/print.html b/pylib/builtins/print.html new file mode 100644 index 000000000..a3b856072 --- /dev/null +++ b/pylib/builtins/print.html @@ -0,0 +1,120 @@ + + + + + + + +src/pylib/builtins/print + + + + + + + + + + + + + + + + +
+
+

src/pylib/builtins/print

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Macros

+
+ + +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/builtins/print.idx b/pylib/builtins/print.idx new file mode 100644 index 000000000..a4065b355 --- /dev/null +++ b/pylib/builtins/print.idx @@ -0,0 +1,2 @@ +nimTitle print pylib/builtins/print.html module src/pylib/builtins/print 0 +nim print pylib/builtins/print.html#print.m,varargs[untyped] macro print(data: varargs[untyped]): untyped 132 diff --git a/pylib/builtins/private/format_impl.html b/pylib/builtins/private/format_impl.html new file mode 100644 index 000000000..471d87078 --- /dev/null +++ b/pylib/builtins/private/format_impl.html @@ -0,0 +1,120 @@ + + + + + + + +src/pylib/builtins/private/format_impl + + + + + + + + + + + + + + + + +
+
+

src/pylib/builtins/private/format_impl

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Procs

+
+
+
+
func format[T](self: T; spec: static[string]): string
+
+ + builtins that formats at compile time + Source   +Edit   + +
+
+
+
func format[T](self: T; spec: string): string
+
+ + builtins + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/builtins/private/format_impl.idx b/pylib/builtins/private/format_impl.idx new file mode 100644 index 000000000..680b9a3c1 --- /dev/null +++ b/pylib/builtins/private/format_impl.idx @@ -0,0 +1,4 @@ +nimTitle format_impl pylib/builtins/private/format_impl.html module src/pylib/builtins/private/format_impl 0 +nim format pylib/builtins/private/format_impl.html#format,T,static[string] proc format[T](self: T; spec: static[string]): string 4 +nim format pylib/builtins/private/format_impl.html#format,T,string proc format[T](self: T; spec: string): string 9 +nimgrp format pylib/builtins/private/format_impl.html#format-procs-all proc 4 diff --git a/pylib/builtins/private/mathutils.html b/pylib/builtins/private/mathutils.html new file mode 100644 index 000000000..1608ce723 --- /dev/null +++ b/pylib/builtins/private/mathutils.html @@ -0,0 +1,126 @@ + + + + + + + +src/pylib/builtins/private/mathutils + + + + + + + + + + + + + + + + +
+
+

src/pylib/builtins/private/mathutils

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Procs

+
+
+
+
func iPosCeil[I: SomeInteger](x: float): I
+
+ + I(ceil(x)) if x > 0 else 0 + Source   +Edit   + +
+
+ +
+
+
+
func rangeLen[I](start, stop, step: I): I
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/builtins/private/mathutils.idx b/pylib/builtins/private/mathutils.idx new file mode 100644 index 000000000..fc6756b69 --- /dev/null +++ b/pylib/builtins/private/mathutils.idx @@ -0,0 +1,3 @@ +nimTitle mathutils pylib/builtins/private/mathutils.html module src/pylib/builtins/private/mathutils 0 +nim iPosCeil pylib/builtins/private/mathutils.html#iPosCeil,float proc iPosCeil[I: SomeInteger](x: float): I 2 +nim rangeLen pylib/builtins/private/mathutils.html#rangeLen,I,I,I proc rangeLen[I](start, stop, step: I): I 9 diff --git a/pylib/builtins/private/ncomplex_pow.html b/pylib/builtins/private/ncomplex_pow.html new file mode 100644 index 000000000..aa4b6675a --- /dev/null +++ b/pylib/builtins/private/ncomplex_pow.html @@ -0,0 +1,196 @@ + + + + + + + +src/pylib/builtins/private/ncomplex_pow + + + + + + + + + + + + + + + + +
+
+

src/pylib/builtins/private/ncomplex_pow

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

why this module doesn't use pow in std/complex (we call it ncomplex.pow below):

  • For integer 2nd arg, we'll use c_powi or c_powu,
  • +
+

which produce more precious result than ncomplex.pow

+
  • ncomplex.pow doesn't raise any exception
  • +
+

+ +
+

Procs

+
+
+
+
func c_powi[T](x: Complex[T]; i: SomeInteger): Complex[T] {....raises: [], inline.}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func c_powu[T](x: Complex[T]; n: Natural): Complex[T] {....raises: [], inline.}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func pow[T](a, b: Complex[T]): Complex[T]
+
+ + + Source   +Edit   + +
+
+
+
func pow[T](self: Complex[T]; i: SomeInteger): Complex[T]
+
+ + + Source   +Edit   + +
+
+
+
func pow[T](self: Complex[T]; n: static Natural): Complex[T] {.compileTime.}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func powu[T](self: Complex[T]; n: Natural): Complex[T]
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/builtins/private/ncomplex_pow.idx b/pylib/builtins/private/ncomplex_pow.idx new file mode 100644 index 000000000..62cbf7056 --- /dev/null +++ b/pylib/builtins/private/ncomplex_pow.idx @@ -0,0 +1,8 @@ +nimTitle ncomplex_pow pylib/builtins/private/ncomplex_pow.html module src/pylib/builtins/private/ncomplex_pow 0 +nim c_powu pylib/builtins/private/ncomplex_pow.html#c_powu,Complex[T],Natural proc c_powu[T](x: Complex[T]; n: Natural): Complex[T] 137 +nim c_powi pylib/builtins/private/ncomplex_pow.html#c_powi,Complex[T],SomeInteger proc c_powi[T](x: Complex[T]; i: SomeInteger): Complex[T] 139 +nim pow pylib/builtins/private/ncomplex_pow.html#pow,Complex[T],Complex[T] proc pow[T](a, b: Complex[T]): Complex[T] 157 +nim pow pylib/builtins/private/ncomplex_pow.html#pow,Complex[T],SomeInteger proc pow[T](self: Complex[T]; i: SomeInteger): Complex[T] 169 +nim pow pylib/builtins/private/ncomplex_pow.html#pow,Complex[T],staticNatural proc pow[T](self: Complex[T]; n: static Natural): Complex[T] 174 +nim powu pylib/builtins/private/ncomplex_pow.html#powu,Complex[T],Natural proc powu[T](self: Complex[T]; n: Natural): Complex[T] 179 +nimgrp pow pylib/builtins/private/ncomplex_pow.html#pow-procs-all proc 157 diff --git a/pylib/builtins/private/pycore_pymath.html b/pylib/builtins/private/pycore_pymath.html new file mode 100644 index 000000000..8e060f1aa --- /dev/null +++ b/pylib/builtins/private/pycore_pymath.html @@ -0,0 +1,137 @@ + + + + + + + +src/pylib/builtins/private/pycore_pymath + + + + + + + + + + + + + + + + +
+
+

src/pylib/builtins/private/pycore_pymath

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

Only used for ./ncomplex_pow.nim

+

For other of CPython/Include/internal/pycore_pymath.h, see pylib/pyconfig/pycore/pymath.nim

+

+ +
+

Procs

+
+
+
+
proc Py_ADJUST_ERANGE1(x: float) {.inline, ...raises: [], tags: [], forbids: [].}
+
+ + Py_ADJUST_ERANGE1(x) Py_ADJUST_ERANGE2(x, y) Set errno to 0 before calling a libm function, and invoke one of these macros after, passing the function result(s) (_Py_ADJUST_ERANGE2 is useful for functions returning complex results). This makes two kinds of adjustments to errno: (A) If it looks like the platform libm set errno=ERANGE due to underflow, clear errno. (B) If it looks like the platform libm overflowed but didn't set errno, force errno to ERANGE. In effect, we're trying to force a useful implementation of C89 errno behavior. Caution: This isn't reliable. C99 no longer requires libm to set errno under any exceptional condition, but does require +- HUGE_VAL return values on overflow. A 754 box probably maps HUGE_VAL to a double infinity, and we're cool if that's so, unless the input was an infinity and an infinity is the expected result. A C89 system sets errno to ERANGE, so we check for that too. We're out of luck if a C99 754 box doesn't map HUGE_VAL to +Inf, or if the returned result is a NaN, or if a C89 box returns HUGE_VAL in non-overflow cases. + Source   +Edit   + +
+
+ +
+
+
+
proc Py_ADJUST_ERANGE2(x, y: float) {.inline, ...raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/builtins/private/pycore_pymath.idx b/pylib/builtins/private/pycore_pymath.idx new file mode 100644 index 000000000..5343d818a --- /dev/null +++ b/pylib/builtins/private/pycore_pymath.idx @@ -0,0 +1,3 @@ +nimTitle pycore_pymath pylib/builtins/private/pycore_pymath.html module src/pylib/builtins/private/pycore_pymath 0 +nim Py_ADJUST_ERANGE1 pylib/builtins/private/pycore_pymath.html#Py_ADJUST_ERANGE1,float proc Py_ADJUST_ERANGE1(x: float) 12 +nim Py_ADJUST_ERANGE2 pylib/builtins/private/pycore_pymath.html#Py_ADJUST_ERANGE2,float,float proc Py_ADJUST_ERANGE2(x, y: float) 40 diff --git a/pylib/builtins/private/strIter.html b/pylib/builtins/private/strIter.html new file mode 100644 index 000000000..c43f68f03 --- /dev/null +++ b/pylib/builtins/private/strIter.html @@ -0,0 +1,158 @@ + + + + + + + +src/pylib/builtins/private/strIter + + + + + + + + + + + + + + + + +
+
+

src/pylib/builtins/private/strIter

+
+ +
+ Source   +Edit   + +
+ +

+
+

Templates

+
+
+
+
template genDollarRepr(Coll; start, stop: char | string; linear = false;
+                       useIter = true) {.dirty.}
+
+ + + Source   +Edit   + +
+
+
+
template genDollarRepr(Coll; start, stop: char | string; strProc: typed;
+                       linear = false; useIter = true) {.dirty.}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template strIterImpl(it: typed{atom}; strProc; start, stop: char | string;
+                     linear = false; useIter = true): string
+
+ + requires iter(it), it.len, it[int] + Source   +Edit   + +
+
+
+
template strIterImpl(itExpr: typed{~atom}; strProc; start, stop: char | string;
+                     linear = false; useIter = true): string
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/builtins/private/strIter.idx b/pylib/builtins/private/strIter.idx new file mode 100644 index 000000000..f4121ca7f --- /dev/null +++ b/pylib/builtins/private/strIter.idx @@ -0,0 +1,7 @@ +nimTitle strIter pylib/builtins/private/strIter.html module src/pylib/builtins/private/strIter 0 +nim strIterImpl pylib/builtins/private/strIter.html#strIterImpl.t,,,, template strIterImpl(it: typed{atom}; strProc; start, stop: char | string;\n linear = false; useIter = true): string 7 +nim strIterImpl pylib/builtins/private/strIter.html#strIterImpl.t,,,,_2 template strIterImpl(itExpr: typed{~atom}; strProc; start, stop: char | string;\n linear = false; useIter = true): string 32 +nim genDollarRepr pylib/builtins/private/strIter.html#genDollarRepr.t,,,,typed template genDollarRepr(Coll; start, stop: char | string; strProc: typed; linear = false;\n useIter = true) 50 +nim genDollarRepr pylib/builtins/private/strIter.html#genDollarRepr.t,,, template genDollarRepr(Coll; start, stop: char | string; linear = false; useIter = true) 53 +nimgrp gendollarrepr pylib/builtins/private/strIter.html#genDollarRepr-templates-all template 50 +nimgrp striterimpl pylib/builtins/private/strIter.html#strIterImpl-templates-all template 7 diff --git a/pylib/builtins/pyerrors.html b/pylib/builtins/pyerrors.html new file mode 100644 index 000000000..6626636d8 --- /dev/null +++ b/pylib/builtins/pyerrors.html @@ -0,0 +1,96 @@ + + + + + + + +src/pylib/builtins/pyerrors + + + + + + + + + + + + + + + + + + + + diff --git a/pylib/builtins/pyerrors.idx b/pylib/builtins/pyerrors.idx new file mode 100644 index 000000000..9be339c0b --- /dev/null +++ b/pylib/builtins/pyerrors.idx @@ -0,0 +1 @@ +nimTitle pyerrors pylib/builtins/pyerrors.html module src/pylib/builtins/pyerrors 0 diff --git a/pylib/builtins/pyhashes.html b/pylib/builtins/pyhashes.html new file mode 100644 index 000000000..3905e47c1 --- /dev/null +++ b/pylib/builtins/pyhashes.html @@ -0,0 +1,206 @@ + + + + + + + +src/pylib/builtins/pyhashes + + + + + + + + + + + + + + + + +
+
+

src/pylib/builtins/pyhashes

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
proc hash(x: float): int {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc hash(x: int): int {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc hash(x: proc): int
+
+ + + Source   +Edit   + +
+
+
+
proc hash(x: PyDict): int {.error: "TypeError: unhashable type: PyDict".}
+
+ + + Source   +Edit   + +
+
+
+
proc hash(x: PyList): int {.error: "TypeError: unhashable type: PyList".}
+
+ + + Source   +Edit   + +
+
+
+
proc hash(x: PySet): int {.error: "TypeError: unhashable type: PySet".}
+
+ + + Source   +Edit   + +
+
+
+
proc hash(x: PyStr | PyBytes): int
+
+ + + Source   +Edit   + +
+
+
+
proc hash(x: PyTComplex): int
+
+ + + Source   +Edit   + +
+
+
+
proc hash(x: tuple): int
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/builtins/pyhashes.idx b/pylib/builtins/pyhashes.idx new file mode 100644 index 000000000..d840b6c53 --- /dev/null +++ b/pylib/builtins/pyhashes.idx @@ -0,0 +1,11 @@ +nimTitle pyhashes pylib/builtins/pyhashes.html module src/pylib/builtins/pyhashes 0 +nim hash pylib/builtins/pyhashes.html#hash,int proc hash(x: int): int 12 +nim hash pylib/builtins/pyhashes.html#hash,float proc hash(x: float): int 13 +nim hash pylib/builtins/pyhashes.html#hash proc hash(x: tuple): int 14 +nim hash pylib/builtins/pyhashes.html#hash,proc proc hash(x: proc): int 15 +nim hash pylib/builtins/pyhashes.html#hash,PyTComplex proc hash(x: PyTComplex): int 17 +nim hash pylib/builtins/pyhashes.html#hash_2 proc hash(x: PyStr | PyBytes): int 18 +nim hash pylib/builtins/pyhashes.html#hash,PyList proc hash(x: PyList): int 24 +nim hash pylib/builtins/pyhashes.html#hash,PyDict proc hash(x: PyDict): int 25 +nim hash pylib/builtins/pyhashes.html#hash,PySet proc hash(x: PySet): int 26 +nimgrp hash pylib/builtins/pyhashes.html#hash-procs-all proc 10 diff --git a/pylib/builtins/pyrange.html b/pylib/builtins/pyrange.html new file mode 100644 index 000000000..3d228584c --- /dev/null +++ b/pylib/builtins/pyrange.html @@ -0,0 +1,373 @@ + + + + + + + +src/pylib/builtins/pyrange + + + + + + + + + + + + + + + + +
+
+

src/pylib/builtins/pyrange

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Types

+
+
+
PyRange[T] = ref object
+  start*, stop*: T           ## `start`, `stop`, `step` are exported since Python 3.3
+  step*, len: int
+
+ + Python-like range object + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
func `$`[T](rng: PyRange[T]): string
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func `[]`[T](x: PyRange[T]; y: Natural): T {.inline.}
+
+ + Get value from range by its index + Source   +Edit   + +
+
+ +
+
+
+
func contains[T](x: PyRange[T]; y: T): bool
+
+ + Checks if given value is in range + Source   +Edit   + +
+
+ +
+
+
+
func count[T](r: PyRange[T]; x: T): int
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func index[T](r: PyRange[T]; x: T): int
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func max[T](x: PyRange[T]): T {.inline.}
+
+ + Get maximum value from range. Python's max(range(...)) + Source   +Edit   + +
+
+ +
+
+
+
func min[T](x: PyRange[T]): T {.inline.}
+
+ + Get minimum value from range. Python's max(range(...)) + Source   +Edit   + +
+
+ +
+
+
+
func range[T: SomeInteger](start, stop, step: T): PyRange[T]
+
+ + Creates new range object with given start, stop and step of any integer type + Source   +Edit   + +
+
+ +
+
+
+
func repr[T](rng: PyRange[T]): string
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Iterators

+
+
+
+
iterator items[T](rng: PyRange[T]): T
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template len[T](rng: PyRange[T]): int
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template range[T: SomeInteger](start, stop: T): PyRange[T]
+
+ + Shortcut for range(start, stop, 1) + Source   +Edit   + +
+
+
+
template range[T: SomeInteger](stop: T): PyRange[T]
+
+ + Shortcut for range(0, stop, 1) + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/builtins/pyrange.idx b/pylib/builtins/pyrange.idx new file mode 100644 index 000000000..906cb6776 --- /dev/null +++ b/pylib/builtins/pyrange.idx @@ -0,0 +1,16 @@ +nimTitle pyrange pylib/builtins/pyrange.html module src/pylib/builtins/pyrange 0 +nim PyRange pylib/builtins/pyrange.html#PyRange type PyRange 5 +nim `$` pylib/builtins/pyrange.html#$,PyRange[T] proc `$`[T](rng: PyRange[T]): string 9 +nim repr pylib/builtins/pyrange.html#repr,PyRange[T] proc repr[T](rng: PyRange[T]): string 14 +nim range pylib/builtins/pyrange.html#range,T,T,T proc range[T: SomeInteger](start, stop, step: T): PyRange[T] 16 +nim range pylib/builtins/pyrange.html#range.t,T,T template range[T: SomeInteger](start, stop: T): PyRange[T] 24 +nim range pylib/builtins/pyrange.html#range.t,T template range[T: SomeInteger](stop: T): PyRange[T] 29 +nim len pylib/builtins/pyrange.html#len.t,PyRange[T] template len[T](rng: PyRange[T]): int 34 +nim items pylib/builtins/pyrange.html#items.i,PyRange[T] iterator items[T](rng: PyRange[T]): T 37 +nim contains pylib/builtins/pyrange.html#contains,PyRange[T],T proc contains[T](x: PyRange[T]; y: T): bool 49 +nim `[]` pylib/builtins/pyrange.html#[],PyRange[T],Natural proc `[]`[T](x: PyRange[T]; y: Natural): T 58 +nim min pylib/builtins/pyrange.html#min,PyRange[T] proc min[T](x: PyRange[T]): T 63 +nim max pylib/builtins/pyrange.html#max,PyRange[T] proc max[T](x: PyRange[T]): T 69 +nim count pylib/builtins/pyrange.html#count,PyRange[T],T proc count[T](r: PyRange[T]; x: T): int 75 +nim index pylib/builtins/pyrange.html#index,PyRange[T],T proc index[T](r: PyRange[T]; x: T): int 78 +nimgrp range pylib/builtins/pyrange.html#range-templates-all template 24 diff --git a/pylib/builtins/pyslice.html b/pylib/builtins/pyslice.html new file mode 100644 index 000000000..f12a51751 --- /dev/null +++ b/pylib/builtins/pyslice.html @@ -0,0 +1,308 @@ + + + + + + + +src/pylib/builtins/pyslice + + + + + + + + + + + + + + + + +
+
+

src/pylib/builtins/pyslice

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Types

+
+
+
PySlice = ref object of PySlice1
+  step*: int
+
+ + + Source   +Edit   + +
+
+
+
PySlice1 = ref object of RootObj
+  start*, stop*: int
+
+ + slice of 1 step + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
func `<`(self`gensym3: PySlice; o`gensym3: PySlice): bool {....raises: [],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func `<=`(self`gensym6: PySlice; o`gensym6: PySlice): bool {....raises: [],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func `==`(self: PySlice; o: PySlice): bool {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func indices(self: PySlice; length: int): (int, int, int) {.
+    ...raises: [ValueError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func repr(self: PySlice): string {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func slice(start, stop: int): PySlice1 {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func slice(start, stop: int; step: int): PySlice {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func slice(stop: int): PySlice1 {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc toNimSlice(s: PySlice1): Slice[int] {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Converters

+
+
+
+
converter toPySlice(s: PySlice1): PySlice {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/builtins/pyslice.idx b/pylib/builtins/pyslice.idx new file mode 100644 index 000000000..cf4ce708b --- /dev/null +++ b/pylib/builtins/pyslice.idx @@ -0,0 +1,14 @@ +nimTitle pyslice pylib/builtins/pyslice.html module src/pylib/builtins/pyslice 0 +nim PySlice1 pylib/builtins/pyslice.html#PySlice1 type PySlice1 4 +nim PySlice pylib/builtins/pyslice.html#PySlice type PySlice 7 +nim `==` pylib/builtins/pyslice.html#==,PySlice,PySlice proc `==`(self: PySlice; o: PySlice): bool 10 +nim `<` pylib/builtins/pyslice.html#<,PySlice,PySlice proc `<`(self`gensym3: PySlice; o`gensym3: PySlice): bool 19 +nim `<=` pylib/builtins/pyslice.html#<=,PySlice,PySlice proc `<=`(self`gensym6: PySlice; o`gensym6: PySlice): bool 20 +nim slice pylib/builtins/pyslice.html#slice,int,int proc slice(start, stop: int): PySlice1 23 +nim slice pylib/builtins/pyslice.html#slice,int,int,int proc slice(start, stop: int; step: int): PySlice 26 +nim slice pylib/builtins/pyslice.html#slice,int proc slice(stop: int): PySlice1 29 +nim toPySlice pylib/builtins/pyslice.html#toPySlice.c,PySlice1 converter toPySlice(s: PySlice1): PySlice 31 +nim toNimSlice pylib/builtins/pyslice.html#toNimSlice,PySlice1 proc toNimSlice(s: PySlice1): Slice[int] 34 +nim repr pylib/builtins/pyslice.html#repr,PySlice proc repr(self: PySlice): string 39 +nim indices pylib/builtins/pyslice.html#indices,PySlice,int proc indices(self: PySlice; length: int): (int, int, int) 74 +nimgrp slice pylib/builtins/pyslice.html#slice-procs-all proc 23 diff --git a/pylib/builtins/pytuple.html b/pylib/builtins/pytuple.html new file mode 100644 index 000000000..a52ae1e2a --- /dev/null +++ b/pylib/builtins/pytuple.html @@ -0,0 +1,126 @@ + + + + + + + +src/pylib/builtins/pytuple + + + + + + + + + + + + + + + + +
+
+

src/pylib/builtins/pytuple

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

Currently we just use system.tuple for Python's tuple

+
+

Macros

+
+
+
+
macro items(t: tuple): untyped
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
macro len(t: tuple): int
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/builtins/pytuple.idx b/pylib/builtins/pytuple.idx new file mode 100644 index 000000000..6f87f2c15 --- /dev/null +++ b/pylib/builtins/pytuple.idx @@ -0,0 +1,3 @@ +nimTitle pytuple pylib/builtins/pytuple.html module src/pylib/builtins/pytuple 0 +nim items pylib/builtins/pytuple.html#items.m macro items(t: tuple): untyped 5 +nim len pylib/builtins/pytuple.html#len.m macro len(t: tuple): int 20 diff --git a/pylib/builtins/reprImpl.html b/pylib/builtins/reprImpl.html new file mode 100644 index 000000000..fefd67a9e --- /dev/null +++ b/pylib/builtins/reprImpl.html @@ -0,0 +1,133 @@ + + + + + + + +src/pylib/builtins/reprImpl + + + + + + + + + + + + + + + + +
+
+

src/pylib/builtins/reprImpl

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Procs

+
+
+
+
func pyreprbImpl(s: string): string {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func pyreprImpl(s: string; escape127: static[bool] = false): string
+
+ +

Python's repr but returns Nim's string.

+

nim's Escape Char feature can be enabled via -d:useNimCharEsc, in which 'e' (i.e.'x1B' in Nim) will be replaced by "\e"

+ +

Example:

+
# NOTE: string literal's `repr` is `system.repr`, as following. 
+assert repr("\"") == "\"\\\"\""   # string literal of "\""
+# use pyrepr for any StringLike and returns a PyStr
+assert pyreprImpl("\"") == "'\"'"
+ Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/builtins/reprImpl.idx b/pylib/builtins/reprImpl.idx new file mode 100644 index 000000000..6fdd9df90 --- /dev/null +++ b/pylib/builtins/reprImpl.idx @@ -0,0 +1,3 @@ +nimTitle reprImpl pylib/builtins/reprImpl.html module src/pylib/builtins/reprImpl 0 +nim pyreprImpl pylib/builtins/reprImpl.html#pyreprImpl,string,static[bool] proc pyreprImpl(s: string; escape127: static[bool] = false): string 71 +nim pyreprbImpl pylib/builtins/reprImpl.html#pyreprbImpl,string proc pyreprbImpl(s: string): string 85 diff --git a/pylib/builtins/round.html b/pylib/builtins/round.html new file mode 100644 index 000000000..bfcb06a1e --- /dev/null +++ b/pylib/builtins/round.html @@ -0,0 +1,96 @@ + + + + + + + +src/pylib/builtins/round + + + + + + + + + + + + + + + + +
+
+

src/pylib/builtins/round

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ + + +
+
+ + +
+
+ + + diff --git a/pylib/builtins/round.idx b/pylib/builtins/round.idx new file mode 100644 index 000000000..195efd791 --- /dev/null +++ b/pylib/builtins/round.idx @@ -0,0 +1 @@ +nimTitle round pylib/builtins/round.html module src/pylib/builtins/round 0 diff --git a/pylib/builtins/round/PY_SHORT_FLOAT_REPR.html b/pylib/builtins/round/PY_SHORT_FLOAT_REPR.html new file mode 100644 index 000000000..efc95d549 --- /dev/null +++ b/pylib/builtins/round/PY_SHORT_FLOAT_REPR.html @@ -0,0 +1,118 @@ + + + + + + + +src/pylib/builtins/round/PY_SHORT_FLOAT_REPR + + + + + + + + + + + + + + + + +
+
+

src/pylib/builtins/round/PY_SHORT_FLOAT_REPR

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
proc round(dd: float; ndigits: int): float {....raises: [], tags: [], forbids: [].}
+
+ + version of double_round that uses the correctly-rounded string<->double conversions from Python/dtoa.c + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/builtins/round/PY_SHORT_FLOAT_REPR.idx b/pylib/builtins/round/PY_SHORT_FLOAT_REPR.idx new file mode 100644 index 000000000..7bcdeca8e --- /dev/null +++ b/pylib/builtins/round/PY_SHORT_FLOAT_REPR.idx @@ -0,0 +1,2 @@ +nimTitle PY_SHORT_FLOAT_REPR pylib/builtins/round/PY_SHORT_FLOAT_REPR.html module src/pylib/builtins/round/PY_SHORT_FLOAT_REPR 0 +nim round pylib/builtins/round/PY_SHORT_FLOAT_REPR.html#round,float,int proc round(dd: float; ndigits: int): float 10 diff --git a/pylib/builtins/round/int_round.html b/pylib/builtins/round/int_round.html new file mode 100644 index 000000000..c1e04da9a --- /dev/null +++ b/pylib/builtins/round/int_round.html @@ -0,0 +1,130 @@ + + + + + + + +src/pylib/builtins/round/int_round + + + + + + + + + + + + + + + + +
+
+

src/pylib/builtins/round/int_round

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Imports

+
+ ../../ops +
+
+
+

Procs

+
+
+
+
func round(x: int): int {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func round(x: int; ndigit: int): int {....raises: [ZeroDivisionError], tags: [],
+                                       forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/builtins/round/int_round.idx b/pylib/builtins/round/int_round.idx new file mode 100644 index 000000000..ea93098f1 --- /dev/null +++ b/pylib/builtins/round/int_round.idx @@ -0,0 +1,4 @@ +nimTitle int_round pylib/builtins/round/int_round.html module src/pylib/builtins/round/int_round 0 +nim round pylib/builtins/round/int_round.html#round,int proc round(x: int): int 4 +nim round pylib/builtins/round/int_round.html#round,int,int proc round(x: int; ndigit: int): int 20 +nimgrp round pylib/builtins/round/int_round.html#round-procs-all proc 4 diff --git a/pylib/builtins/round/no_ndigit.html b/pylib/builtins/round/no_ndigit.html new file mode 100644 index 000000000..efc081e0b --- /dev/null +++ b/pylib/builtins/round/no_ndigit.html @@ -0,0 +1,114 @@ + + + + + + + +src/pylib/builtins/round/no_ndigit + + + + + + + + + + + + + + + + +
+
+

src/pylib/builtins/round/no_ndigit

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Procs

+
+
+
+
func round[F: SomeFloat](x: F): F
+
+ + if two multiples are equally close, rounding is done toward the even choice a.k.a.round-to-even
Hint: +Nim's round in std/math just does like C's round
+ +

Example:

+
assert round(6.5) == 6
+assert round(7.5) == 8
+ Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/builtins/round/no_ndigit.idx b/pylib/builtins/round/no_ndigit.idx new file mode 100644 index 000000000..bd98fec21 --- /dev/null +++ b/pylib/builtins/round/no_ndigit.idx @@ -0,0 +1,2 @@ +nimTitle no_ndigit pylib/builtins/round/no_ndigit.html module src/pylib/builtins/round/no_ndigit 0 +nim round pylib/builtins/round/no_ndigit.html#round,F proc round[F: SomeFloat](x: F): F 13 diff --git a/pylib/builtins/round/reimporter.html b/pylib/builtins/round/reimporter.html new file mode 100644 index 000000000..5f1c0ebcf --- /dev/null +++ b/pylib/builtins/round/reimporter.html @@ -0,0 +1,161 @@ + + + + + + + +src/pylib/builtins/round/reimporter + + + + + + + + + + + + + + + + +
+
+

src/pylib/builtins/round/reimporter

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Templates

+
+
+
+
template import_dtoa()
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template import_obmalloc()
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template import_pyconfig()
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ + +
+
+ + +
+
+ + + diff --git a/pylib/builtins/round/reimporter.idx b/pylib/builtins/round/reimporter.idx new file mode 100644 index 000000000..a3bdd59ee --- /dev/null +++ b/pylib/builtins/round/reimporter.idx @@ -0,0 +1,4 @@ +nimTitle reimporter pylib/builtins/round/reimporter.html module src/pylib/builtins/round/reimporter 0 +nim import_pyconfig pylib/builtins/round/reimporter.html#import_pyconfig.t template import_pyconfig() 5 +nim import_dtoa pylib/builtins/round/reimporter.html#import_dtoa.t template import_dtoa() 6 +nim import_obmalloc pylib/builtins/round/reimporter.html#import_obmalloc.t template import_obmalloc() 7 diff --git a/pylib/builtins/round_float.html b/pylib/builtins/round_float.html new file mode 100644 index 000000000..d5deffa3b --- /dev/null +++ b/pylib/builtins/round_float.html @@ -0,0 +1,130 @@ + + + + + + + +src/pylib/builtins/round_float + + + + + + + + + + + + + + + + +
+
+

src/pylib/builtins/round_float

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
proc round(x: F; ndigit: int): F {....raises: [], tags: [], forbids: [].}
+
+ + translated from CPython/Objects/floatobject.c:double_round rounds a finite double to the closest multiple of 10**-ndigits; here ndigits is within reasonable bounds (typically, -308 <= ndigits <= 323). Returns a Python float, or sets a Python error and returns NULL on failure (OverflowError and memory errors are possible
Hint: +
+

variant whose F is float32 is not implemented, and won't be unless https://netlib.org/fp/ftoa.c is implemented ( none as of 2025-02-17)

+ + Source   +Edit   + +
+
+ +
+ +
+
+
+

Exports

+
+ round +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/builtins/round_float.idx b/pylib/builtins/round_float.idx new file mode 100644 index 000000000..67926da9f --- /dev/null +++ b/pylib/builtins/round_float.idx @@ -0,0 +1,2 @@ +nimTitle round_float pylib/builtins/round_float.html module src/pylib/builtins/round_float 0 +nim round pylib/builtins/round_float.html#round,F,int proc round(x: F; ndigit: int): F 16 diff --git a/pylib/builtins/round_int.html b/pylib/builtins/round_int.html new file mode 100644 index 000000000..b07d71029 --- /dev/null +++ b/pylib/builtins/round_int.html @@ -0,0 +1,127 @@ + + + + + + + +src/pylib/builtins/round_int + + + + + + + + + + + + + + + + +
+
+

src/pylib/builtins/round_int

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
func round(x: int; _: NoneType): int {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Exports

+
+ round, round +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/builtins/round_int.idx b/pylib/builtins/round_int.idx new file mode 100644 index 000000000..fa02e3545 --- /dev/null +++ b/pylib/builtins/round_int.idx @@ -0,0 +1,2 @@ +nimTitle round_int pylib/builtins/round_int.html module src/pylib/builtins/round_int 0 +nim round pylib/builtins/round_int.html#round,int,NoneType proc round(x: int; _: NoneType): int 5 diff --git a/pylib/builtins/set.html b/pylib/builtins/set.html new file mode 100644 index 000000000..1e8baf288 --- /dev/null +++ b/pylib/builtins/set.html @@ -0,0 +1,1037 @@ + + + + + + + +src/pylib/builtins/set + + + + + + + + + + + + + + + + +
+
+

src/pylib/builtins/set

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

set and its methods. +

set type

set[T] is still for system.set[T], with its restriction of only allowing small ordinal as elements. PySet[T] is used to minic Python's.

+ +

Literal

Something like {1,2} shall be rewritten as pyset([1,2]), please note either pyset((1,2)) or pyset({1,2}) doesn't mean the same.

+

+ +
+

Types

+
+
+
SomeSet[H] = SomePySet[H] or HashSet[H] or OrderedSet[H] or set[H]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
proc `&=`[H; S: SomeSet[H]](self: var SomePySet[H]; s: S)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc `-`[H](self, o: PySet[H]): PySet[H]
+
+ + + Source   +Edit   + +
+
+
+
proc `-`[H](self: PyFrozenSet[H]; o: SomePySet[H]): PyFrozenSet[H]
+
+ + + Source   +Edit   + +
+
+
+
proc `-`[H](self: PySet[H]; o: PyFrozenSet[H]): PyFrozenSet[H]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc `-=`[H; S: SomeSet[H]](self: var SomePySet[H]; s: S)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc `<`[H](s: set[H]; self: SomePySet[H]): bool {.error: "When used, Nim compiler(at least 2.0.0-2.1.2) will complain:\n\'Error: unhandled exception: ccgexprs.nim(1994, 9) `setType.kind == tySet`\', \nConsider using `pyset` instead of set literal.".}
+
+ + + Source   +Edit   + +
+
+
+
proc `<`[H](self: SomePySet[H]; s: set[H]): bool {.error: "When used, Nim compiler(at least 2.0.0-2.1.2) will complain:\n\'Error: unhandled exception: ccgexprs.nim(1994, 9) `setType.kind == tySet`\', \nConsider using `pyset` instead of set literal.".}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc `<=`[H](s: set[H]; self: SomePySet[H]): bool {.error: "When used, Nim compiler(at least 2.0.0-2.1.2) will complain:\n\'Error: unhandled exception: ccgexprs.nim(1994, 9) `setType.kind == tySet`\', \nConsider using `pyset` instead of set literal.".}
+
+ + + Source   +Edit   + +
+
+
+
proc `<=`[H](self: SomePySet[H]; s: set[H]): bool {.error: "When used, Nim compiler(at least 2.0.0-2.1.2) will complain:\n\'Error: unhandled exception: ccgexprs.nim(1994, 9) `setType.kind == tySet`\', \nConsider using `pyset` instead of set literal.".}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc `==`[H](s: set[H]; self: SomePySet[H]): bool {.error: "When used, Nim compiler(at least 2.0.0-2.1.2) will complain:\n\'Error: unhandled exception: ccgexprs.nim(1994, 9) `setType.kind == tySet`\', \nConsider using `pyset` instead of set literal.".}
+
+ + + Source   +Edit   + +
+
+
+
proc `==`[H](self: SomePySet[H]; s: set[H]): bool {.error: "When used, Nim compiler(at least 2.0.0-2.1.2) will complain:\n\'Error: unhandled exception: ccgexprs.nim(1994, 9) `setType.kind == tySet`\', \nConsider using `pyset` instead of set literal.".}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc add[H](self: var PySet[H]; x: H)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc difference[H; Self: SomePySet[H]; S: not PySet[H]](self: Self; s: S): Self
+
+ + + Source   +Edit   + +
+
+
+
proc difference[H; Self: SomePySet[H]; S](self: Self; s1: auto; s2: auto;
+    x: varargs[S]): Self
+
+ + + Source   +Edit   + +
+
+
+
proc difference[H](self, o: PySet[H]): PySet[H]
+
+ + + Source   +Edit   + +
+
+
+
proc difference[H](self: PyFrozenSet[H]; o: SomePySet[H]): PyFrozenSet[H]
+
+ + + Source   +Edit   + +
+
+
+
proc difference[H](self: PySet[H]; o: PyFrozenSet[H]): PyFrozenSet[H]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc difference_update[H; I: Iterable[H]](self: var SomePySet[H]; i: I)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc `discard`[H](self: var PySet[H]; ele: H)
+
+ + discard is keyword of Nim, consider use `discard` or pydiscard + Source   +Edit   + +
+
+ +
+
+
+
proc frozenset[H](): PyFrozenSet[H]
+
+ + + Source   +Edit   + +
+
+
+
proc frozenset[H](arr: openArray[H]): PyFrozenSet[H]
+
+ + + Source   +Edit   + +
+
+
+
proc frozenset[H](it: Iterable[H]): PyFrozenSet[H]
+
+ + + Source   +Edit   + +
+
+
+
proc frozenset[H](s: HashSet[H]): PyFrozenSet[H]
+
+ + + Source   +Edit   + +
+
+
+
proc frozenset[H](s: SomePySet[H]): PyFrozenSet[H]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc intersection[H; Self: SomePySet[H]; S: not PySet[H]](self: Self; s: S): Self
+
+ + + Source   +Edit   + +
+
+
+
proc intersection[H; Self: SomePySet[H]; S](self: Self; s1: auto; s2: auto;
+    x: varargs[S]): Self
+
+ + + Source   +Edit   + +
+
+
+
proc intersection[H](self, o: PySet[H]): PySet[H]
+
+ + + Source   +Edit   + +
+
+
+
proc intersection[H](self: PyFrozenSet[H]; o: SomePySet[H]): PyFrozenSet[H]
+
+ + + Source   +Edit   + +
+
+
+
proc intersection[H](self: PySet[H]; o: PyFrozenSet[H]): PyFrozenSet[H]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc intersection_update[H; I: Iterable[H]](self: var SomePySet[H]; i: I)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func isdisjoint[H, S](self: SomePySet[H]; s: S): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc issubset[H, S](self, o: SomePySet[H]; s: S): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc issuperset[H, S](self, o: SomePySet[H]; s: S): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc pydiscard[H](self: var PySet[H]; ele: H)
+
+ + set.discard(ele) + Source   +Edit   + +
+
+ +
+
+
+
proc pyset[H](): PySet[H]
+
+ + + Source   +Edit   + +
+
+
+
proc pyset[H](arr: openArray[H]): PySet[H]
+
+ + + Source   +Edit   + +
+
+
+
proc pyset[H](iterable: Iterable[H]): PySet[H]
+
+ + + Source   +Edit   + +
+
+
+
proc pyset[H](s: HashSet[H]): PySet[H]
+
+ + + Source   +Edit   + +
+
+
+
proc pyset[H](s: SomePySet[H]): PySet[H]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc remove[H](self: var PySet[H]; ele: H)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc set[H](): PySet[H]
+
+ + + Source   +Edit   + +
+
+
+
proc set[H](arr: openArray[H]): PySet[H]
+
+ + + Source   +Edit   + +
+
+
+
proc set[H](iterable: Iterable[H]): PySet[H]
+
+ + + Source   +Edit   + +
+
+
+
proc set[H](s: HashSet[H]): PySet[H]
+
+ + + Source   +Edit   + +
+
+
+
proc set[H](s: SomePySet[H]): PySet[H]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc symmetric_difference[H; Self: SomePySet[H]; S: not PySet[H]](self: Self;
+    s: S): Self
+
+ + + Source   +Edit   + +
+
+
+
proc symmetric_difference[H; Self: SomePySet[H]; S](self: Self; s1: auto;
+    s2: auto; x: varargs[S]): Self
+
+ + + Source   +Edit   + +
+
+
+
proc symmetric_difference[H](self, o: PySet[H]): PySet[H]
+
+ + + Source   +Edit   + +
+
+
+
proc symmetric_difference[H](self: PyFrozenSet[H]; o: SomePySet[H]): PyFrozenSet[
+    H]
+
+ + + Source   +Edit   + +
+
+
+
proc symmetric_difference[H](self: PySet[H]; o: PyFrozenSet[H]): PyFrozenSet[H]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc union[H; Self: SomePySet[H]; S: not PySet[H]](self: Self; s: S): Self
+
+ + + Source   +Edit   + +
+
+
+
proc union[H; Self: SomePySet[H]; S](self: Self; s1: auto; s2: auto;
+                                     x: varargs[S]): Self
+
+ + + Source   +Edit   + +
+
+
+
proc union[H](self, o: PySet[H]): PySet[H]
+
+ + + Source   +Edit   + +
+
+
+
proc union[H](self: PyFrozenSet[H]; o: SomePySet[H]): PyFrozenSet[H]
+
+ + + Source   +Edit   + +
+
+
+
proc union[H](self: PySet[H]; o: PyFrozenSet[H]): PyFrozenSet[H]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc update[H; I: Iterable[H]](self: var SomePySet[H]; i: I)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc `|=`[H; S: SomeSet[H]](self: var SomePySet[H]; s: S)
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Macros

+
+
+
+
macro pysetLit(lit): PySet
+
+ + To solve: pyset({1,2,3}) is invalid + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template `&`[H; M: SomePySet[H]; S: SomePySet[H]](self: M; s: S): M | S
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template `^`[H; M: SomePySet[H]; S: SomePySet[H]](self: M; s: S): M | S
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template copy[H; S: SomePySet[H]](self): S
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template `|`[H; M: SomePySet[H]; S: SomePySet[H]](self: M; s: S): M | S
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ + +
+
+ + +
+
+ + + diff --git a/pylib/builtins/set.idx b/pylib/builtins/set.idx new file mode 100644 index 000000000..40b7d05a1 --- /dev/null +++ b/pylib/builtins/set.idx @@ -0,0 +1,77 @@ +nimTitle set pylib/builtins/set.html module src/pylib/builtins/set 0 +nim SomeSet pylib/builtins/set.html#SomeSet type SomeSet 18 +nim set pylib/builtins/set.html#set_2 proc set[H](): PySet[H] 29 +nim pyset pylib/builtins/set.html#pyset_2 proc pyset[H](): PySet[H] 29 +nim set pylib/builtins/set.html#set,HashSet[H] proc set[H](s: HashSet[H]): PySet[H] 31 +nim pyset pylib/builtins/set.html#pyset,HashSet[H] proc pyset[H](s: HashSet[H]): PySet[H] 31 +nim set pylib/builtins/set.html#set,SomePySet[H] proc set[H](s: SomePySet[H]): PySet[H] 33 +nim pyset pylib/builtins/set.html#pyset,SomePySet[H] proc pyset[H](s: SomePySet[H]): PySet[H] 33 +nim set pylib/builtins/set.html#set,openArray[H] proc set[H](arr: openArray[H]): PySet[H] 34 +nim pyset pylib/builtins/set.html#pyset,openArray[H] proc pyset[H](arr: openArray[H]): PySet[H] 34 +nim set pylib/builtins/set.html#set,Iterable[H] proc set[H](iterable: Iterable[H]): PySet[H] 35 +nim pyset pylib/builtins/set.html#pyset,Iterable[H] proc pyset[H](iterable: Iterable[H]): PySet[H] 28 +nim frozenset pylib/builtins/set.html#frozenset_2 proc frozenset[H](): PyFrozenSet[H] 40 +nim frozenset pylib/builtins/set.html#frozenset,HashSet[H] proc frozenset[H](s: HashSet[H]): PyFrozenSet[H] 42 +nim frozenset pylib/builtins/set.html#frozenset,SomePySet[H] proc frozenset[H](s: SomePySet[H]): PyFrozenSet[H] 44 +nim frozenset pylib/builtins/set.html#frozenset,openArray[H] proc frozenset[H](arr: openArray[H]): PyFrozenSet[H] 45 +nim frozenset pylib/builtins/set.html#frozenset,Iterable[H] proc frozenset[H](it: Iterable[H]): PyFrozenSet[H] 46 +nim pysetLit pylib/builtins/set.html#pysetLit.m macro pysetLit(lit): PySet 56 +nim copy pylib/builtins/set.html#copy.t template copy[H; S: SomePySet[H]](self): S 67 +nim `-` pylib/builtins/set.html#-,PySet[H],PySet[H] proc `-`[H](self, o: PySet[H]): PySet[H] 71 +nim `-` pylib/builtins/set.html#-,PyFrozenSet[H],SomePySet[H] proc `-`[H](self: PyFrozenSet[H]; o: SomePySet[H]): PyFrozenSet[H] 73 +nim `-` pylib/builtins/set.html#-,PySet[H],PyFrozenSet[H] proc `-`[H](self: PySet[H]; o: PyFrozenSet[H]): PyFrozenSet[H] 83 +nim intersection pylib/builtins/set.html#intersection,PySet[H],PySet[H] proc intersection[H](self, o: PySet[H]): PySet[H] 71 +nim intersection pylib/builtins/set.html#intersection,PyFrozenSet[H],SomePySet[H] proc intersection[H](self: PyFrozenSet[H]; o: SomePySet[H]): PyFrozenSet[H] 73 +nim intersection pylib/builtins/set.html#intersection,PySet[H],PyFrozenSet[H] proc intersection[H](self: PySet[H]; o: PyFrozenSet[H]): PyFrozenSet[H] 83 +nim union pylib/builtins/set.html#union,PySet[H],PySet[H] proc union[H](self, o: PySet[H]): PySet[H] 71 +nim union pylib/builtins/set.html#union,PyFrozenSet[H],SomePySet[H] proc union[H](self: PyFrozenSet[H]; o: SomePySet[H]): PyFrozenSet[H] 73 +nim union pylib/builtins/set.html#union,PySet[H],PyFrozenSet[H] proc union[H](self: PySet[H]; o: PyFrozenSet[H]): PyFrozenSet[H] 83 +nim difference pylib/builtins/set.html#difference,PySet[H],PySet[H] proc difference[H](self, o: PySet[H]): PySet[H] 71 +nim difference pylib/builtins/set.html#difference,PyFrozenSet[H],SomePySet[H] proc difference[H](self: PyFrozenSet[H]; o: SomePySet[H]): PyFrozenSet[H] 73 +nim difference pylib/builtins/set.html#difference,PySet[H],PyFrozenSet[H] proc difference[H](self: PySet[H]; o: PyFrozenSet[H]): PyFrozenSet[H] 83 +nim symmetric_difference pylib/builtins/set.html#symmetric_difference,PySet[H],PySet[H] proc symmetric_difference[H](self, o: PySet[H]): PySet[H] 71 +nim symmetric_difference pylib/builtins/set.html#symmetric_difference,PyFrozenSet[H],SomePySet[H] proc symmetric_difference[H](self: PyFrozenSet[H]; o: SomePySet[H]): PyFrozenSet[H] 73 +nim symmetric_difference pylib/builtins/set.html#symmetric_difference,PySet[H],PyFrozenSet[H] proc symmetric_difference[H](self: PySet[H]; o: PyFrozenSet[H]): PyFrozenSet[H] 83 +nim `==` pylib/builtins/set.html#==,SomePySet[H],set[H] proc `==`[H](self: SomePySet[H]; s: set[H]): bool 90 +nim `==` pylib/builtins/set.html#==,set[H],SomePySet[H] proc `==`[H](s: set[H]; self: SomePySet[H]): bool 95 +nim `<=` pylib/builtins/set.html#<=,SomePySet[H],set[H] proc `<=`[H](self: SomePySet[H]; s: set[H]): bool 90 +nim `<=` pylib/builtins/set.html#<=,set[H],SomePySet[H] proc `<=`[H](s: set[H]; self: SomePySet[H]): bool 96 +nim `<` pylib/builtins/set.html#<,SomePySet[H],set[H] proc `<`[H](self: SomePySet[H]; s: set[H]): bool 90 +nim `<` pylib/builtins/set.html#<,set[H],SomePySet[H] proc `<`[H](s: set[H]; self: SomePySet[H]): bool 97 +nim `^` pylib/builtins/set.html#^.t,M,S template `^`[H; M: SomePySet[H]; S: SomePySet[H]](self: M; s: S): M | S 105 +nim `&` pylib/builtins/set.html#&.t,M,S template `&`[H; M: SomePySet[H]; S: SomePySet[H]](self: M; s: S): M | S 106 +nim `|` pylib/builtins/set.html#|.t,M,S template `|`[H; M: SomePySet[H]; S: SomePySet[H]](self: M; s: S): M | S 107 +nim issuperset pylib/builtins/set.html#issuperset,SomePySet[H],SomePySet[H],S proc issuperset[H, S](self, o: SomePySet[H]; s: S): bool 112 +nim issubset pylib/builtins/set.html#issubset,SomePySet[H],SomePySet[H],S proc issubset[H, S](self, o: SomePySet[H]; s: S): bool 113 +nim intersection pylib/builtins/set.html#intersection,Self,S proc intersection[H; Self: SomePySet[H]; S: not PySet[H]](self: Self; s: S): Self 117 +nim intersection pylib/builtins/set.html#intersection,Self,auto,auto,varargs[S] proc intersection[H; Self: SomePySet[H]; S](self: Self; s1: auto; s2: auto;\n x: varargs[S]): Self 127 +nim union pylib/builtins/set.html#union,Self,S proc union[H; Self: SomePySet[H]; S: not PySet[H]](self: Self; s: S): Self 117 +nim union pylib/builtins/set.html#union,Self,auto,auto,varargs[S] proc union[H; Self: SomePySet[H]; S](self: Self; s1: auto; s2: auto; x: varargs[S]): Self 128 +nim difference pylib/builtins/set.html#difference,Self,S proc difference[H; Self: SomePySet[H]; S: not PySet[H]](self: Self; s: S): Self 117 +nim difference pylib/builtins/set.html#difference,Self,auto,auto,varargs[S] proc difference[H; Self: SomePySet[H]; S](self: Self; s1: auto; s2: auto;\n x: varargs[S]): Self 129 +nim symmetric_difference pylib/builtins/set.html#symmetric_difference,Self,S proc symmetric_difference[H; Self: SomePySet[H]; S: not PySet[H]](self: Self; s: S): Self 117 +nim symmetric_difference pylib/builtins/set.html#symmetric_difference,Self,auto,auto,varargs[S] proc symmetric_difference[H; Self: SomePySet[H]; S](self: Self; s1: auto; s2: auto;\n x: varargs[S]): Self 130 +nim isdisjoint pylib/builtins/set.html#isdisjoint,SomePySet[H],S proc isdisjoint[H, S](self: SomePySet[H]; s: S): bool 132 +nim add pylib/builtins/set.html#add,PySet[H],H proc add[H](self: var PySet[H]; x: H) 135 +nim `discard` pylib/builtins/set.html#discard,PySet[H],H proc `discard`[H](self: var PySet[H]; ele: H) 136 +nim pydiscard pylib/builtins/set.html#pydiscard,PySet[H],H proc pydiscard[H](self: var PySet[H]; ele: H) 139 +nim remove pylib/builtins/set.html#remove,PySet[H],H proc remove[H](self: var PySet[H]; ele: H) 143 +nim `-=` pylib/builtins/set.html#-=,SomePySet[H],S proc `-=`[H; S: SomeSet[H]](self: var SomePySet[H]; s: S) 149 +nim difference_update pylib/builtins/set.html#difference_update,SomePySet[H],I proc difference_update[H; I: Iterable[H]](self: var SomePySet[H]; i: I) 152 +nim `|=` pylib/builtins/set.html#|=,SomePySet[H],S proc `|=`[H; S: SomeSet[H]](self: var SomePySet[H]; s: S) 149 +nim update pylib/builtins/set.html#update,SomePySet[H],I proc update[H; I: Iterable[H]](self: var SomePySet[H]; i: I) 153 +nim `&=` pylib/builtins/set.html#&=,SomePySet[H],S proc `&=`[H; S: SomeSet[H]](self: var SomePySet[H]; s: S) 149 +nim intersection_update pylib/builtins/set.html#intersection_update,SomePySet[H],I proc intersection_update[H; I: Iterable[H]](self: var SomePySet[H]; i: I) 156 +nimgrp == pylib/builtins/set.html#==-procs-all proc 95 +nimgrp - pylib/builtins/set.html#--procs-all proc 83 +nimgrp pyset pylib/builtins/set.html#pyset-procs-all proc 21 +nimgrp symmetricdifference pylib/builtins/set.html#symmetric_difference-procs-all proc 83 +nimgrp frozenset pylib/builtins/set.html#frozenset-procs-all proc 40 +nimgrp <= pylib/builtins/set.html#<=-procs-all proc 96 +nimgrp union pylib/builtins/set.html#union-procs-all proc 83 +nimgrp < pylib/builtins/set.html#<-procs-all proc 97 +nimgrp set pylib/builtins/set.html#set-procs-all proc 29 +nimgrp intersection pylib/builtins/set.html#intersection-procs-all proc 83 +nimgrp difference pylib/builtins/set.html#difference-procs-all proc 83 +heading set type pylib/builtins/set.html#set-type set type 0 +heading Literal pylib/builtins/set.html#literal Literal 0 diff --git a/pylib/builtins/set_decl.html b/pylib/builtins/set_decl.html new file mode 100644 index 000000000..980891307 --- /dev/null +++ b/pylib/builtins/set_decl.html @@ -0,0 +1,536 @@ + + + + + + + +src/pylib/builtins/set_decl + + + + + + + + + + + + + + + + +
+
+

src/pylib/builtins/set_decl

+
+ +
+ Source   +Edit   + +
+ +

+ +
+

Types

+
+
+
frozenset[H] = ref object
+
+ + + Source   +Edit   + +
+
+
+
PyFrozenSet[H] = frozenset[H]
+
+ + + Source   +Edit   + +
+
+
+
PySet[H] = set[H]
+
+ + + Source   +Edit   + +
+
+
+
set[H] = ref object
+
+ + + Source   +Edit   + +
+
+
+
SomePySet[H] = set[H] | frozenset[H]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
func `<`(self, o: SomePySet): int
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func `<=`(self, o: SomePySet): int
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func `==`(self, o: SomePySet): int
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func asHashSet[H](self: SomePySet[H]): HashSet[H]
+
+ + + Source   +Edit   + +
+
+
+
func asHashSet[H](self: var SomePySet[H]): var HashSet[H]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc clear(self: var PySet): int
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func contains[H](self: SomePySet[H]; x: H): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc excl[H](self: var SomePySet[H]; x: H)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func hash[H](self: PyFrozenSet[H]): int
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc incl[H](self: var SomePySet[H]; x: H)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func len(self: SomePySet): int
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func newPyFrozenSet[H](h: HashSet[H]): PyFrozenSet[H]
+
+ + + Source   +Edit   + +
+
+
+
func newPyFrozenSet[H](initialSize = defaultInitialSize): PyFrozenSet[H]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func newPySet[H](h: HashSet[H]): PySet[H]
+
+ + + Source   +Edit   + +
+
+
+
func newPySet[H](initialSize = defaultInitialSize): PySet[H]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc pop[H](self: var PySet[H]): H {.discardable.}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Iterators

+
+
+
+
iterator items[H](self: SomePySet[H]): H
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template `$`(self: PyFrozenSet): string
+
+ + + Source   +Edit   + +
+
+
+
template `$`(self: PySet): string
+
+ + + Source   +Edit   + +
+
+
+
template `$`(self: SomePySet): string
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template repr(self: PyFrozenSet): string {.dirty.}
+
+ + + Source   +Edit   + +
+
+
+
template repr(self: PySet): string {.dirty.}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/builtins/set_decl.idx b/pylib/builtins/set_decl.idx new file mode 100644 index 000000000..557064f36 --- /dev/null +++ b/pylib/builtins/set_decl.idx @@ -0,0 +1,33 @@ +nimTitle set_decl pylib/builtins/set_decl.html module src/pylib/builtins/set_decl 0 +nim frozenset pylib/builtins/set_decl.html#frozenset type frozenset 7 +nim PyFrozenSet pylib/builtins/set_decl.html#PyFrozenSet type PyFrozenSet 9 +nim set pylib/builtins/set_decl.html#set type set 10 +nim PySet pylib/builtins/set_decl.html#PySet type PySet 12 +nim SomePySet pylib/builtins/set_decl.html#SomePySet type SomePySet 13 +nim hash pylib/builtins/set_decl.html#hash,PyFrozenSet[H] proc hash[H](self: PyFrozenSet[H]): int 15 +nim asHashSet pylib/builtins/set_decl.html#asHashSet,SomePySet[H] proc asHashSet[H](self: SomePySet[H]): HashSet[H] 17 +nim asHashSet pylib/builtins/set_decl.html#asHashSet,SomePySet[H]_2 proc asHashSet[H](self: var SomePySet[H]): var HashSet[H] 18 +nim newPySet pylib/builtins/set_decl.html#newPySet,HashSet[H] proc newPySet[H](h: HashSet[H]): PySet[H] 19 +nim newPyFrozenSet pylib/builtins/set_decl.html#newPyFrozenSet,HashSet[H] proc newPyFrozenSet[H](h: HashSet[H]): PyFrozenSet[H] 20 +nim newPySet pylib/builtins/set_decl.html#newPySet proc newPySet[H](initialSize = defaultInitialSize): PySet[H] 21 +nim newPyFrozenSet pylib/builtins/set_decl.html#newPyFrozenSet proc newPyFrozenSet[H](initialSize = defaultInitialSize): PyFrozenSet[H] 23 +nim incl pylib/builtins/set_decl.html#incl,SomePySet[H],H proc incl[H](self: var SomePySet[H]; x: H) 26 +nim excl pylib/builtins/set_decl.html#excl,SomePySet[H],H proc excl[H](self: var SomePySet[H]; x: H) 27 +nim len pylib/builtins/set_decl.html#len,SomePySet proc len(self: SomePySet): int 29 +nim repr pylib/builtins/set_decl.html#repr.t,PySet template repr(self: PySet): string 42 +nim `$` pylib/builtins/set_decl.html#$.t,PySet template `$`(self: PySet): string 31 +nim repr pylib/builtins/set_decl.html#repr.t,PyFrozenSet template repr(self: PyFrozenSet): string 42 +nim `$` pylib/builtins/set_decl.html#$.t,PyFrozenSet template `$`(self: PyFrozenSet): string 32 +nim `$` pylib/builtins/set_decl.html#$.t,SomePySet template `$`(self: SomePySet): string 34 +nim clear pylib/builtins/set_decl.html#clear,PySet proc clear(self: var PySet): int 38 +nim `==` pylib/builtins/set_decl.html#==,SomePySet,SomePySet proc `==`(self, o: SomePySet): int 39 +nim `<=` pylib/builtins/set_decl.html#<=,SomePySet,SomePySet proc `<=`(self, o: SomePySet): int 40 +nim `<` pylib/builtins/set_decl.html#<,SomePySet,SomePySet proc `<`(self, o: SomePySet): int 41 +nim contains pylib/builtins/set_decl.html#contains,SomePySet[H],H proc contains[H](self: SomePySet[H]; x: H): bool 42 +nim pop pylib/builtins/set_decl.html#pop,PySet[H] proc pop[H](self: var PySet[H]): H 43 +nim items pylib/builtins/set_decl.html#items.i,SomePySet[H] iterator items[H](self: SomePySet[H]): H 44 +nimgrp ashashset pylib/builtins/set_decl.html#asHashSet-procs-all proc 17 +nimgrp newpyfrozenset pylib/builtins/set_decl.html#newPyFrozenSet-procs-all proc 20 +nimgrp newpyset pylib/builtins/set_decl.html#newPySet-procs-all proc 19 +nimgrp $ pylib/builtins/set_decl.html#$-templates-all template 46 +nimgrp repr pylib/builtins/set_decl.html#repr-templates-all template 42 diff --git a/pylib/builtins/str_byte.html b/pylib/builtins/str_byte.html new file mode 100644 index 000000000..6b7469709 --- /dev/null +++ b/pylib/builtins/str_byte.html @@ -0,0 +1,96 @@ + + + + + + + +src/pylib/builtins/str_byte + + + + + + + + + + + + + + + + +
+
+

src/pylib/builtins/str_byte

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Exports

+
+ removeprefix, endsWith, maketrans, substr, ==, str, ascii, NoneType, +=, partition, endsWith, startsWith, maketrans, +=, TranslateAction, ord, translate, str, bin, str, rf, u, TranslateTableVal, StringLike, split, strip, isspace, ==, str, endsWith, rstrip, isalpha, *, rindex, center, ==, Fr, split, contains, ascii, rstrip, replace, endsWith, contains, endsWith, format, toNimString, +, count, repr, lstrip, u, TranslateTableABC, runeAtPos, chr, +=, removesuffix, None, pyrepr, rsplit, capitalize, split, startsWith, startsWith, translate, format, split, center, title, replace, maketrans, [], count, ljust, toNimStr, repr, [], TranslateValType, [], TypedTranslateTableABC, toPyStr, PyStr, and, isupper, $, startsWith, isascii, index, rjust, hex, translate, reversed, rpartition, rsplit, runeLenAt, fr, str, count, chars, istitle, len, toPyStr, Rf, str, splitlines, expandtabs, toPyStr, splitlines, not, islower, runes, casefold, join, upper, ascii, contains, getChar, rfind, ljust, find, strip, oct, +, TranslateTable, lstrip, $, zfill, startsWith, StrTypedTranslateTable, rsplit, isascii, or, translate, byteLen, ord1, items, ascii, len, rjust, f, lower, <>, fspath, *, endsWith, b, b, maketrans, substr, PyBytes, rindex, ==, istitle, hex, endsWith, count, bytes, isupper, $, hex, +=, partition, startsWith, isascii, index, bytes, rjust, +=, ord, endsWith, substr, bytes, reversed, rpartition, getCharPtr, find, isspace, rb, Br, title, count, split, isdigit, contains, chars, count, endsWith, Rb, +, isalpha, *, bytes, rindex, center, @, startsWith, split, br, +, splitlines, removeprefix, expandtabs, splitlines, replace, not, islower, rstrip, hex, casefold, toNimString, +, count, join, repr, upper, split, contains, lstrip, getChar, strip, rfind, bytes, ljust, find, strip, hasChar, rstrip, +, lstrip, +=, zfill, rfind, startsWith, rsplit, capitalize, or, translate, byteLen, index, items, hex, count, startsWith, startsWith, endsWith, bytes, translate, split, fromhex, len, bytes, center, rsplit, removesuffix, replace, rjust, rsplit, [], count, +, ljust, lower, [], pybytes, translate, fspath, *, bytes, [], []=, hex, <, <=, maketrans, substr, PyBytes, rindex, ==, Br, endsWith, endsWith, getChar, startsWith, replace, <=, +=, partition, b, bytes, ljust, getCharPtr, ord, substr, bytes, find, clear, rb, copy, bytearray, rstrip, split, strip, ==, isdigit, br, endsWith, toNimString, rstrip, isalpha, *, bytes, rindex, center, len, split, contains, +, removeprefix, +, replace, newPyByteArray, hex, istitle, toNimString, +, count, repr, lstrip, startsWith, [], count, endsWith, +=, pop, +=, bytearray, removesuffix, $, delitem, []=, capitalize, chars, <, hex, count, bytearray, extend, bytes, translate, split, toNimString, bytes, center, title, len, rsplit, [], count, append, delitem, pybytes, translate, [], [], items, []=, insert, isupper, $, startsWith, startsWith, isascii, index, [], rjust, hex, reversed, rpartition, getCharPtr, PyByteArray, isspace, rsplit, count, reverse, chars, count, Rb, newPyByteArray, @, startsWith, BytesLike, splitlines, expandtabs, splitlines, not, split, islower, ljust, casefold, join, fromhex, upper, b, contains, getChar, strip, rfind, bytes, +=, remove, find, bytearray, hasChar, ==, toPyBytes, +, lstrip, rfind, zfill, bytearray, delitem, bytearray, rsplit, or, translate, byteLen, index, items, endsWith, *=, []=, newPyByteArray, rjust, bytes, +, lower, fspath, *, bytes, bytes +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/builtins/str_byte.idx b/pylib/builtins/str_byte.idx new file mode 100644 index 000000000..9a5bc22d6 --- /dev/null +++ b/pylib/builtins/str_byte.idx @@ -0,0 +1 @@ +nimTitle str_byte pylib/builtins/str_byte.html module src/pylib/builtins/str_byte 0 diff --git a/pylib/collections_abc.html b/pylib/collections_abc.html new file mode 100644 index 000000000..868249c8b --- /dev/null +++ b/pylib/collections_abc.html @@ -0,0 +1,96 @@ + + + + + + + +src/pylib/collections_abc + + + + + + + + + + + + + + + + +
+
+

src/pylib/collections_abc

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+ +
+ + +
+
+ + + diff --git a/pylib/collections_abc.idx b/pylib/collections_abc.idx new file mode 100644 index 000000000..b1f45ea24 --- /dev/null +++ b/pylib/collections_abc.idx @@ -0,0 +1 @@ +nimTitle collections_abc pylib/collections_abc.html module src/pylib/collections_abc 0 diff --git a/pylib/collections_abc/asyncs.html b/pylib/collections_abc/asyncs.html new file mode 100644 index 000000000..2b36621e3 --- /dev/null +++ b/pylib/collections_abc/asyncs.html @@ -0,0 +1,301 @@ + + + + + + + +src/pylib/collections_abc/asyncs + + + + + + + + + + + + + + + + +
+
+

src/pylib/collections_abc/asyncs

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+

Coroutine

ref pep of `Coroutines with async and await syntax`, Future-like object is just an alias of Awaitable

+

V = 1
+async def f():
+    return V
+
+c: Coroutine[None, None, int] = f()
+
+try: c.send(None)
+except StopIteraion as s: assert V == s.value
+
+try: c.send(None)
+except RuntimeError as e: assert str(e) == "cannot reuse already awaited coroutine"
+
+# Also: V == await f()

+

pep for Asynchronous Generators

+ +

AsyncGenerator

V = 1
+async def f(): yield V
+ag = f()
+
+ag_asend_obj = ag.asend(None)  #  or `anext(ag)`
+try: ag_asend_obj.send(None)
+except StopIteration as s: assert V == s.value
+
+
+ag_asend_obj = ag.asend(None)  #  or `anext(ag, defval)` if wanting
+# the next `send` raises `StopIteration` and its value to be `defval`
+
+try: ag_asend_obj.send(None)
+except StopAsyncIteration: pass   # iteration end
+
+

+

for ag_asend_obj, ref link of PyAsyncGenASend:

+

PyAsyncGenASend is a coroutine-like object...

+

PyAsyncGenAThrow is very similar to PyAsyncGenASend. The only difference is that PyAsyncGenAThrow.send(), when called first time, throws an exception into the parent agen object (instead of pushing a value into it.)

+

+ +
+

Types

+
+
+
AsyncGenerator[Yield; Send] = concept selfof AsyncIterator[Yield]
+    self.asend(Send) is Awaitable[Yield]
+    self.athrow(CatchableError) is Awaitable[void]
+
+ + type( (async _(): yield)() ) ABC for such a function which returns an asynchronous generator iterator. It looks like a coroutine function defined with async def except that it contains yield expressions for producing a series of values usable in an async for loop. + Source   +Edit   + +
+
+
+
AsyncIterable[T] = concept self
+    aiter(self) is AsyncIterator[T]
+
+ + + Source   +Edit   + +
+
+
+
AsyncIterator[T] = concept selfof AsyncIterable[T]
+    anext(self) is Awaitable[T]
+
+ + + Source   +Edit   + +
+
+
+
Awaitable[T] = concept self
+    T is await self
+
+ + + Source   +Edit   + +
+
+
+
Coroutine[Yield; Send; Return] = concept selfof Awaitable[Return]
+    self.send(Send) is Yield
+    self.throw(CatchableError)
+
+ + type( (async def _(): return Return() )() ) in details: Coroutine[None, None, Return] + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
proc aclose(self: AsyncGenerator): owned(Future[void]) {....stackTrace: false.}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc anext[T](self: AsyncGenerator[T]): Awaitable[T] {.inline.}
+
+ + this shall be an async def + Source   +Edit   + +
+
+
+
proc anext[T](self: AsyncGenerator[T]; default: T): Awaitable[T] {.inline.}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc await[T](self: anextawaitableobject[T]): T
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc close(self: Coroutine)
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/collections_abc/asyncs.idx b/pylib/collections_abc/asyncs.idx new file mode 100644 index 000000000..b9aa2df80 --- /dev/null +++ b/pylib/collections_abc/asyncs.idx @@ -0,0 +1,14 @@ +nimTitle asyncs pylib/collections_abc/asyncs.html module src/pylib/collections_abc/asyncs 0 +nim Awaitable pylib/collections_abc/asyncs.html#Awaitable type Awaitable 69 +nim Coroutine pylib/collections_abc/asyncs.html#Coroutine type Coroutine 71 +nim close pylib/collections_abc/asyncs.html#close,Coroutine proc close(self: Coroutine) 79 +nim AsyncIterable pylib/collections_abc/asyncs.html#AsyncIterable type AsyncIterable 103 +nim AsyncIterator pylib/collections_abc/asyncs.html#AsyncIterator type AsyncIterator 105 +nim AsyncGenerator pylib/collections_abc/asyncs.html#AsyncGenerator type AsyncGenerator 108 +nim anext pylib/collections_abc/asyncs.html#anext,AsyncGenerator[T] proc anext[T](self: AsyncGenerator[T]): Awaitable[T] 119 +nim await pylib/collections_abc/asyncs.html#await,anextawaitableobject[T] proc await[T](self: anextawaitableobject[T]): T 127 +nim anext pylib/collections_abc/asyncs.html#anext,AsyncGenerator[T],T proc anext[T](self: AsyncGenerator[T]; default: T): Awaitable[T] 134 +nim aclose pylib/collections_abc/asyncs.html#aclose,AsyncGenerator proc aclose(self: AsyncGenerator): owned(Future[void]) 137 +nimgrp anext pylib/collections_abc/asyncs.html#anext-procs-all proc 119 +heading Coroutine pylib/collections_abc/asyncs.html#coroutine Coroutine 0 +heading AsyncGenerator pylib/collections_abc/asyncs.html#asyncgenerator AsyncGenerator 0 diff --git a/pylib/collections_abc/collections.html b/pylib/collections_abc/collections.html new file mode 100644 index 000000000..a9c347500 --- /dev/null +++ b/pylib/collections_abc/collections.html @@ -0,0 +1,510 @@ + + + + + + + +src/pylib/collections_abc/collections + + + + + + + + + + + + + + + + +
+
+

src/pylib/collections_abc/collections

+
+ +
+ Source   +Edit   + +
+ +

+
+

Imports

+
+ iters +
+
+
+

Types

+
+
+
Collection[T] = Sized and Container[T] and Iterable[T]
+
+ + + Source   +Edit   + +
+
+
+
Container[T] = concept self
+    T
+    contains(self, T) is bool
+
+ + + Source   +Edit   + +
+
+
+
Mapping[K; V] = concept selfof Collection[K]
+    K
+    V
+    self[K] is V
+
+ + + Source   +Edit   + +
+
+
+
MutableSequence[T] = concept selfof Sequence[T]
+    T
+    self[int] = T
+    self.delitem(int)
+    self.insert(int, T)      ## insert item before index
+
+ + __delitem__ + Source   +Edit   + +
+
+
+
Sequence[T] = concept selfof Collection[T]
+    T
+    self[int] is T
+
+ + + Source   +Edit   + +
+
+
+
Sized = concept self
+    len(self) is int
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
func `==`[K, V](a, b: Mapping[K, V]): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func `@`[T](s: Sequence[T]): seq[T] {.noInit, inline.}
+
+ + EXT. stable. + Source   +Edit   + +
+
+ +
+
+
+
func append[T](ms: MutableSequence[T]; x: T)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func clear(ms: MutableSequence)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func contains[K, V](m: Mapping[K, V]; k: K): bool
+
+ + + Source   +Edit   + +
+
+
+
func contains[T](s: Container[T]; x: T): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func count[T](s: Sequence[T]; x: T): int
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func extend[T](ms: MutableSequence[T]; it: Iterable[T])
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func get[K, V](m: Mapping[K, V]; key: K): V
+
+ + + Source   +Edit   + +
+
+
+
func get[K, V](m: Mapping[K, V]; key: K; default: V): V
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func index[T](s: Sequence[T]; x: T; start = 0; stop = -1): int
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func pop[T](ms: MutableSequence[T]; index = -1): T
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func remove[T](ms: MutableSequence[T]; x: T)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func reverse(ms: MutableSequence)
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Iterators

+
+
+
+
iterator items[K, V](m: Mapping[K, V]): (K, V)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
iterator values[K, V](m: Mapping[K, V]): V
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template keys[K, V](m: Mapping[K, V]): untyped
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/collections_abc/collections.idx b/pylib/collections_abc/collections.idx new file mode 100644 index 000000000..1f0a9a87b --- /dev/null +++ b/pylib/collections_abc/collections.idx @@ -0,0 +1,26 @@ +nimTitle collections pylib/collections_abc/collections.html module src/pylib/collections_abc/collections 0 +nim Sized pylib/collections_abc/collections.html#Sized type Sized 5 +nim Container pylib/collections_abc/collections.html#Container type Container 8 +nim Collection pylib/collections_abc/collections.html#Collection type Collection 14 +nim Sequence pylib/collections_abc/collections.html#Sequence type Sequence 16 +nim MutableSequence pylib/collections_abc/collections.html#MutableSequence type MutableSequence 19 +nim Mapping pylib/collections_abc/collections.html#Mapping type Mapping 25 +nim contains pylib/collections_abc/collections.html#contains,Container[T],T proc contains[T](s: Container[T]; x: T): bool 33 +nim index pylib/collections_abc/collections.html#index,Sequence[T],T,int,int proc index[T](s: Sequence[T]; x: T; start = 0; stop = -1): int 39 +nim count pylib/collections_abc/collections.html#count,Sequence[T],T proc count[T](s: Sequence[T]; x: T): int 48 +nim `@` pylib/collections_abc/collections.html#@,Sequence[T] proc `@`[T](s: Sequence[T]): seq[T] 60 +nim append pylib/collections_abc/collections.html#append,MutableSequence[T],T proc append[T](ms: MutableSequence[T]; x: T) 68 +nim clear pylib/collections_abc/collections.html#clear,MutableSequence proc clear(ms: MutableSequence) 71 +nim reverse pylib/collections_abc/collections.html#reverse,MutableSequence proc reverse(ms: MutableSequence) 75 +nim extend pylib/collections_abc/collections.html#extend,MutableSequence[T],Iterable[T] proc extend[T](ms: MutableSequence[T]; it: Iterable[T]) 80 +nim pop pylib/collections_abc/collections.html#pop,MutableSequence[T],int proc pop[T](ms: MutableSequence[T]; index = -1): T 84 +nim remove pylib/collections_abc/collections.html#remove,MutableSequence[T],T proc remove[T](ms: MutableSequence[T]; x: T) 89 +nim keys pylib/collections_abc/collections.html#keys.t,Mapping[K,V] template keys[K, V](m: Mapping[K, V]): untyped 94 +nim values pylib/collections_abc/collections.html#values.i,Mapping[K,V] iterator values[K, V](m: Mapping[K, V]): V 96 +nim items pylib/collections_abc/collections.html#items.i,Mapping[K,V] iterator items[K, V](m: Mapping[K, V]): (K, V) 98 +nim contains pylib/collections_abc/collections.html#contains,Mapping[K,V],K proc contains[K, V](m: Mapping[K, V]; k: K): bool 101 +nim get pylib/collections_abc/collections.html#get,Mapping[K,V],K proc get[K, V](m: Mapping[K, V]; key: K): V 105 +nim get pylib/collections_abc/collections.html#get,Mapping[K,V],K,V proc get[K, V](m: Mapping[K, V]; key: K; default: V): V 106 +nim `==` pylib/collections_abc/collections.html#==,Mapping[K,V],Mapping[K,V] proc `==`[K, V](a, b: Mapping[K, V]): bool 110 +nimgrp contains pylib/collections_abc/collections.html#contains-procs-all proc 33 +nimgrp get pylib/collections_abc/collections.html#get-procs-all proc 105 diff --git a/pylib/collections_abc/generators.html b/pylib/collections_abc/generators.html new file mode 100644 index 000000000..c3836f4cd --- /dev/null +++ b/pylib/collections_abc/generators.html @@ -0,0 +1,201 @@ + + + + + + + +src/pylib/collections_abc/generators + + + + + + + + + + + + + + + + +
+
+

src/pylib/collections_abc/generators

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Types

+
+
+
Generator[YieldType; SendType; ReturnType] = concept selfof Iterator[YieldType]
+    try:
+      self.send(SendType) is YieldType
+    except StopIterationT[ReturnType]:
+      discard
+    self.throw(CatchableError)
+
+ + type( (def _(): yield)() ) + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
proc close(self: Generator)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc next[T; R](self: Generator[T, NoneType, R]): T {.inline.}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template iter[T; S; R](self: Generator[T, S, R]): Iterator[T]
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/collections_abc/generators.idx b/pylib/collections_abc/generators.idx new file mode 100644 index 000000000..f3d72d904 --- /dev/null +++ b/pylib/collections_abc/generators.idx @@ -0,0 +1,5 @@ +nimTitle generators pylib/collections_abc/generators.html module src/pylib/collections_abc/generators 0 +nim Generator pylib/collections_abc/generators.html#Generator type Generator 8 +nim close pylib/collections_abc/generators.html#close,Generator proc close(self: Generator) 16 +nim iter pylib/collections_abc/generators.html#iter.t,Generator[T,S,R] template iter[T; S; R](self: Generator[T, S, R]): Iterator[T] 20 +nim next pylib/collections_abc/generators.html#next,Generator[T,NoneType,R] proc next[T; R](self: Generator[T, NoneType, R]): T 21 diff --git a/pylib/collections_abc/iters.html b/pylib/collections_abc/iters.html new file mode 100644 index 000000000..2cba058ef --- /dev/null +++ b/pylib/collections_abc/iters.html @@ -0,0 +1,136 @@ + + + + + + + +src/pylib/collections_abc/iters + + + + + + + + + + + + + + + + +
+
+

src/pylib/collections_abc/iters

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Types

+
+
+
Iterable[T] = concept self
+    T
+    when SupportIteratorHit:
+      iterator items(self): T
+    else:
+      when defined(js):
+        typeof(self.items(), ItemTypeMode) is T
+      else:
+        for value in self:
+          value is T
+
+ + Mimic Pythons Iterable. But not checks iter + Source   +Edit   + +
+
+
+
Iterator[T] = concept selfof Iterable[T]
+    T
+    self.next is T
+
+ + + Source   +Edit   + +
+
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/collections_abc/iters.idx b/pylib/collections_abc/iters.idx new file mode 100644 index 000000000..53211b377 --- /dev/null +++ b/pylib/collections_abc/iters.idx @@ -0,0 +1,3 @@ +nimTitle iters pylib/collections_abc/iters.html module src/pylib/collections_abc/iters 0 +nim Iterable pylib/collections_abc/iters.html#Iterable type Iterable 10 +nim Iterator pylib/collections_abc/iters.html#Iterator type Iterator 22 diff --git a/pylib/collections_abc/private/templ.html b/pylib/collections_abc/private/templ.html new file mode 100644 index 000000000..819b27010 --- /dev/null +++ b/pylib/collections_abc/private/templ.html @@ -0,0 +1,109 @@ + + + + + + + +src/pylib/collections_abc/private/templ + + + + + + + + + + + + + + + + +
+
+

src/pylib/collections_abc/private/templ

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Templates

+
+
+
+
template closeImpl(msg: string; throwBody)
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/collections_abc/private/templ.idx b/pylib/collections_abc/private/templ.idx new file mode 100644 index 000000000..5446b8b97 --- /dev/null +++ b/pylib/collections_abc/private/templ.idx @@ -0,0 +1,2 @@ +nimTitle templ pylib/collections_abc/private/templ.html module src/pylib/collections_abc/private/templ 0 +nim closeImpl pylib/collections_abc/private/templ.html#closeImpl.t,string, template closeImpl(msg: string; throwBody) 2 diff --git a/pylib/impure/Python/mysnprintf.html b/pylib/impure/Python/mysnprintf.html new file mode 100644 index 000000000..84611a339 --- /dev/null +++ b/pylib/impure/Python/mysnprintf.html @@ -0,0 +1,110 @@ + + + + + + + +src/pylib/impure/Python/mysnprintf + + + + + + + + + + + + + + + + +
+
+

src/pylib/impure/Python/mysnprintf

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Procs

+
+
+
+
proc PyOS_snprintf(str: cstring; size: csize_t | int): cint {.discardable,
+    importc, cdecl, varargs, ...raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/impure/Python/mysnprintf.idx b/pylib/impure/Python/mysnprintf.idx new file mode 100644 index 000000000..b1e00a22a --- /dev/null +++ b/pylib/impure/Python/mysnprintf.idx @@ -0,0 +1,2 @@ +nimTitle mysnprintf pylib/impure/Python/mysnprintf.html module src/pylib/impure/Python/mysnprintf 0 +nim PyOS_snprintf pylib/impure/Python/mysnprintf.html#PyOS_snprintf,cstring, proc PyOS_snprintf(str: cstring; size: csize_t | int): cint 4 diff --git a/pylib/impure/math/dtoa.html b/pylib/impure/math/dtoa.html new file mode 100644 index 000000000..30444e810 --- /dev/null +++ b/pylib/impure/math/dtoa.html @@ -0,0 +1,228 @@ + + + + + + + +src/pylib/impure/math/dtoa + + + + + + + + + + + + + + + + +
+
+

src/pylib/impure/math/dtoa

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

We use origin dtoa.c over Python's

+ +
+

Procs

+
+
+
+
proc ACQUIRE_DTOA_LOCK(n: cint) {.exportc, ...raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc dtoa(d: cdouble; mode, ndigits: cint; decpt, sign: var cint;
+          rve: var cstring): cstring {.importc: "dtoa", cdecl, discardable,
+                                       ...raises: [], tags: [], forbids: [].}
+
+ +
char* dtoa(double d, int mode, int ndigits, int *decpt, int *sign, char **rve)
+ Source   +Edit   + +
+
+ +
+
+
+
proc dtoa_r(dd: cdouble; mode, ndigits: cint; decpt, sign: var cint;
+            rve: var cstring; buf: cstring; blen: csize_t): cstring {.
+    importc: "dtoa_r", cdecl, discardable, ...raises: [], tags: [], forbids: [].}
+
+ +
char* dtoa_r(double dd, int mode, int ndigits, int *decpt, int *sign, char **rve, char *buf, size_t blen)
+ Source   +Edit   + +
+
+ +
+
+
+
proc FREE_DTOA_LOCK(n: cint) {.exportc, ...raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc freedtoa(s: cstring) {.importc, cdecl, ...raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc getThreadId(): cint {.exportc: "dtoa_get_threadno", ...raises: [], tags: [],
+                           forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc strtod(s00: cstring; se: (var cstring) | (ptr cstring)): cdouble {.
+    importc: "nimpylib_dtoa_strtod", cdecl, ...raises: [], tags: [], forbids: [].}
+
+ +
double strtod(const char *s00, char **se)
+ Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/impure/math/dtoa.idx b/pylib/impure/math/dtoa.idx new file mode 100644 index 000000000..78ad11af4 --- /dev/null +++ b/pylib/impure/math/dtoa.idx @@ -0,0 +1,8 @@ +nimTitle dtoa pylib/impure/math/dtoa.html module src/pylib/impure/math/dtoa 0 +nim ACQUIRE_DTOA_LOCK pylib/impure/math/dtoa.html#ACQUIRE_DTOA_LOCK,cint proc ACQUIRE_DTOA_LOCK(n: cint) 14 +nim FREE_DTOA_LOCK pylib/impure/math/dtoa.html#FREE_DTOA_LOCK,cint proc FREE_DTOA_LOCK(n: cint) 15 +nim getThreadId pylib/impure/math/dtoa.html#getThreadId proc getThreadId(): cint 17 +nim dtoa_r pylib/impure/math/dtoa.html#dtoa_r,cdouble,cint,cint,cint,cint,cstring,cstring,csize_t proc dtoa_r(dd: cdouble; mode, ndigits: cint; decpt, sign: var cint;\n rve: var cstring; buf: cstring; blen: csize_t): cstring 54 +nim dtoa pylib/impure/math/dtoa.html#dtoa,cdouble,cint,cint,cint,cint,cstring proc dtoa(d: cdouble; mode, ndigits: cint; decpt, sign: var cint; rve: var cstring): cstring 63 +nim strtod pylib/impure/math/dtoa.html#strtod,cstring, proc strtod(s00: cstring; se: (var cstring) | (ptr cstring)): cdouble 71 +nim freedtoa pylib/impure/math/dtoa.html#freedtoa,cstring proc freedtoa(s: cstring) 77 diff --git a/pylib/io.html b/pylib/io.html new file mode 100644 index 000000000..f681f825f --- /dev/null +++ b/pylib/io.html @@ -0,0 +1,107 @@ + + + + + + + +src/pylib/io + + + + + + + + + + + + + + + + +
+
+

src/pylib/io

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

NOTE: not support js currently +

different from Python

+

open

Its param: closefd, opener is not implemented yet

+ +

seek

There is difference that Python's TextIOBase.seek will reset state of encoder at some conditions, while Nim doesn't have access to encoder's state Therefore, seek here doesn't change that

+ +

iter over file

Python's __next__ will yield newline as part of result but Nim's iterator lines does not

+

+
+

Imports

+
+ Lib/io +
+
+ + +
+
+ + +
+
+ + + diff --git a/pylib/io.idx b/pylib/io.idx new file mode 100644 index 000000000..81634db00 --- /dev/null +++ b/pylib/io.idx @@ -0,0 +1,5 @@ +nimTitle io pylib/io.html module src/pylib/io 0 +heading different from Python pylib/io.html#different-from-python different from Python 0 +heading open pylib/io.html#different-from-python-open open 0 +heading seek pylib/io.html#different-from-python-seek seek 0 +heading iter over file pylib/io.html#different-from-python-iter-over-file iter over file 0 diff --git a/pylib/io_abc.html b/pylib/io_abc.html new file mode 100644 index 000000000..c7ec90a7e --- /dev/null +++ b/pylib/io_abc.html @@ -0,0 +1,267 @@ + + + + + + + +src/pylib/io_abc + + + + + + + + + + + + + + + + +
+
+

src/pylib/io_abc

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Types

+
+
+
CanIOOpenT[T] = int | PathLike[T]
+
+ + + Source   +Edit   + +
+
+
+
PathLike[T] = concept self
+    T
+    self.fspath is T
+
+ + os.PathLike + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
proc `$`(p: CanIOOpenT): string
+
+ + Mainly for error message + Source   +Edit   + +
+
+
+
func `$`(p: PathLike): string
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func fspath(c: char): PyStr {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func fspath(s: string): PyStr {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func pathrepr(p: PathLike[PyBytes]): string
+
+ + + Source   +Edit   + +
+
+
+
func pathrepr(p: PathLike[PyStr]): string
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template mapPathLike[T](nexpr): T
+
+ + + Source   +Edit   + +
+
+
+
template mapPathLike[T](s: PathLike[T]; nimProc): T
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/io_abc.idx b/pylib/io_abc.idx new file mode 100644 index 000000000..2ce0cb96b --- /dev/null +++ b/pylib/io_abc.idx @@ -0,0 +1,15 @@ +nimTitle io_abc pylib/io_abc.html module src/pylib/io_abc 0 +nim fspath pylib/io_abc.html#fspath,string proc fspath(s: string): PyStr 6 +nim fspath pylib/io_abc.html#fspath,char proc fspath(c: char): PyStr 7 +nim PathLike pylib/io_abc.html#PathLike type PathLike 11 +nim CanIOOpenT pylib/io_abc.html#CanIOOpenT type CanIOOpenT 14 +nim mapPathLike pylib/io_abc.html#mapPathLike.t,PathLike[T], template mapPathLike[T](s: PathLike[T]; nimProc): T 17 +nim mapPathLike pylib/io_abc.html#mapPathLike.t template mapPathLike[T](nexpr): T 20 +nim `$` pylib/io_abc.html#$,PathLike proc `$`(p: PathLike): string 25 +nim `$` pylib/io_abc.html#$,CanIOOpenT proc `$`(p: CanIOOpenT): string 29 +nim pathrepr pylib/io_abc.html#pathrepr,PathLike[PyBytes] proc pathrepr(p: PathLike[PyBytes]): string 34 +nim pathrepr pylib/io_abc.html#pathrepr,PathLike[PyStr] proc pathrepr(p: PathLike[PyStr]): string 35 +nimgrp fspath pylib/io_abc.html#fspath-procs-all proc 6 +nimgrp $ pylib/io_abc.html#$-procs-all proc 25 +nimgrp pathrepr pylib/io_abc.html#pathrepr-procs-all proc 34 +nimgrp mappathlike pylib/io_abc.html#mapPathLike-templates-all template 17 diff --git a/pylib/mutSeqSliceOp.html b/pylib/mutSeqSliceOp.html new file mode 100644 index 000000000..d5e34ddcb --- /dev/null +++ b/pylib/mutSeqSliceOp.html @@ -0,0 +1,169 @@ + + + + + + + +src/pylib/mutSeqSliceOp + + + + + + + + + + + + + + + + +
+
+

src/pylib/mutSeqSliceOp

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

As Python's MutableSequence does not mixin these we place them here.

+ +
+

Templates

+
+
+
+
template bodySetItem(Arr) {.dirty.}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template genDelItem(Arr) {.dirty.}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template genGenericSetItem(Arr, Arr2) {.dirty.}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template genNonGenericSetItem(Arr, Arr2) {.dirty.}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/mutSeqSliceOp.idx b/pylib/mutSeqSliceOp.idx new file mode 100644 index 000000000..e3aba968a --- /dev/null +++ b/pylib/mutSeqSliceOp.idx @@ -0,0 +1,5 @@ +nimTitle mutSeqSliceOp pylib/mutSeqSliceOp.html module src/pylib/mutSeqSliceOp 0 +nim genDelItem pylib/mutSeqSliceOp.html#genDelItem.t template genDelItem(Arr) 11 +nim bodySetItem pylib/mutSeqSliceOp.html#bodySetItem.t template bodySetItem(Arr) 41 +nim genGenericSetItem pylib/mutSeqSliceOp.html#genGenericSetItem.t,, template genGenericSetItem(Arr, Arr2) 63 +nim genNonGenericSetItem pylib/mutSeqSliceOp.html#genNonGenericSetItem.t,, template genNonGenericSetItem(Arr, Arr2) 68 diff --git a/pylib/nimpatch/abs.html b/pylib/nimpatch/abs.html new file mode 100644 index 000000000..9e8a506e5 --- /dev/null +++ b/pylib/nimpatch/abs.html @@ -0,0 +1,134 @@ + + + + + + + +src/pylib/nimpatch/abs + + + + + + + + + + + + + + + + +
+
+

src/pylib/nimpatch/abs

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Imports

+
+ utils +
+
+
+

Consts

+
+
+
BeforeFixedVer = false
+
+ + + Source   +Edit   + +
+
+
+
FixedVer = (2, 1, 1)
+
+ + + Source   +Edit   + +
+
+
+
hasBug = false
+
+ + + Source   +Edit   + +
+
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/nimpatch/abs.idx b/pylib/nimpatch/abs.idx new file mode 100644 index 000000000..874831efa --- /dev/null +++ b/pylib/nimpatch/abs.idx @@ -0,0 +1,4 @@ +nimTitle abs pylib/nimpatch/abs.html module src/pylib/nimpatch/abs 0 +nim FixedVer pylib/nimpatch/abs.html#FixedVer const FixedVer 12 +nim BeforeFixedVer pylib/nimpatch/abs.html#BeforeFixedVer const BeforeFixedVer 13 +nim hasBug pylib/nimpatch/abs.html#hasBug const hasBug 15 diff --git a/pylib/nimpatch/floatdollar.html b/pylib/nimpatch/floatdollar.html new file mode 100644 index 000000000..34c894088 --- /dev/null +++ b/pylib/nimpatch/floatdollar.html @@ -0,0 +1,165 @@ + + + + + + + +src/pylib/nimpatch/floatdollar + + + + + + + + + + + + + + + + +
+
+

src/pylib/nimpatch/floatdollar

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Imports

+
+ utils +
+
+
+

Consts

+
+
+
BeforeFixedVer = true
+
+ + + Source   +Edit   + +
+
+
+
FixedVer = (2, 3, 1)
+
+ + + Source   +Edit   + +
+
+
+
hasBug = false
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
proc `$`(x: SomeFloat): string
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/nimpatch/floatdollar.idx b/pylib/nimpatch/floatdollar.idx new file mode 100644 index 000000000..b9cb5d55f --- /dev/null +++ b/pylib/nimpatch/floatdollar.idx @@ -0,0 +1,5 @@ +nimTitle floatdollar pylib/nimpatch/floatdollar.html module src/pylib/nimpatch/floatdollar 0 +nim FixedVer pylib/nimpatch/floatdollar.html#FixedVer const FixedVer 12 +nim BeforeFixedVer pylib/nimpatch/floatdollar.html#BeforeFixedVer const BeforeFixedVer 13 +nim hasBug pylib/nimpatch/floatdollar.html#hasBug const hasBug 15 +nim `$` pylib/nimpatch/floatdollar.html#$,SomeFloat proc `$`(x: SomeFloat): string 14 diff --git a/pylib/nimpatch/nansign.html b/pylib/nimpatch/nansign.html new file mode 100644 index 000000000..5d46de784 --- /dev/null +++ b/pylib/nimpatch/nansign.html @@ -0,0 +1,134 @@ + + + + + + + +src/pylib/nimpatch/nansign + + + + + + + + + + + + + + + + +
+
+

src/pylib/nimpatch/nansign

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Imports

+
+ utils +
+
+
+

Consts

+
+
+
BeforeFixedVer = true
+
+ + + Source   +Edit   + +
+
+
+
FixedVer = (2, 3, 1)
+
+ + + Source   +Edit   + +
+
+
+
hasBug = true
+
+ + + Source   +Edit   + +
+
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/nimpatch/nansign.idx b/pylib/nimpatch/nansign.idx new file mode 100644 index 000000000..73dc808c5 --- /dev/null +++ b/pylib/nimpatch/nansign.idx @@ -0,0 +1,4 @@ +nimTitle nansign pylib/nimpatch/nansign.html module src/pylib/nimpatch/nansign 0 +nim FixedVer pylib/nimpatch/nansign.html#FixedVer const FixedVer 12 +nim BeforeFixedVer pylib/nimpatch/nansign.html#BeforeFixedVer const BeforeFixedVer 13 +nim hasBug pylib/nimpatch/nansign.html#hasBug const hasBug 15 diff --git a/pylib/nimpatch/newUninit.html b/pylib/nimpatch/newUninit.html new file mode 100644 index 000000000..3a80a62dc --- /dev/null +++ b/pylib/nimpatch/newUninit.html @@ -0,0 +1,134 @@ + + + + + + + +src/pylib/nimpatch/newUninit + + + + + + + + + + + + + + + + +
+
+

src/pylib/nimpatch/newUninit

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Imports

+
+ utils +
+
+
+

Consts

+
+
+
BeforeFixedVer = false
+
+ + + Source   +Edit   + +
+
+
+
FixedVer = (2, 1, 1)
+
+ + + Source   +Edit   + +
+
+
+
hasBug = false
+
+ + + Source   +Edit   + +
+
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/nimpatch/newUninit.idx b/pylib/nimpatch/newUninit.idx new file mode 100644 index 000000000..3d3058e82 --- /dev/null +++ b/pylib/nimpatch/newUninit.idx @@ -0,0 +1,4 @@ +nimTitle newUninit pylib/nimpatch/newUninit.html module src/pylib/nimpatch/newUninit 0 +nim FixedVer pylib/nimpatch/newUninit.html#FixedVer const FixedVer 12 +nim BeforeFixedVer pylib/nimpatch/newUninit.html#BeforeFixedVer const BeforeFixedVer 13 +nim hasBug pylib/nimpatch/newUninit.html#hasBug const hasBug 15 diff --git a/pylib/nimpatch/utils.html b/pylib/nimpatch/utils.html new file mode 100644 index 000000000..cd5615ce8 --- /dev/null +++ b/pylib/nimpatch/utils.html @@ -0,0 +1,146 @@ + + + + + + + +src/pylib/nimpatch/utils + + + + + + + + + + + + + + + + +
+
+

src/pylib/nimpatch/utils

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Consts

+
+
+
JsBigInt64Option = true
+
+ + + Source   +Edit   + +
+
+
+
NimVersionTuple = (2, 2, 4)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Templates

+
+
+
+
template addPatch(ver: (int, int, int); flag: untyped; patchBody: untyped) {.
+    dirty.}
+
+ + flag is a bool expr, here uses untyped to delay evaluation to get its string represent + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/nimpatch/utils.idx b/pylib/nimpatch/utils.idx new file mode 100644 index 000000000..ef7d4c11d --- /dev/null +++ b/pylib/nimpatch/utils.idx @@ -0,0 +1,4 @@ +nimTitle utils pylib/nimpatch/utils.html module src/pylib/nimpatch/utils 0 +nim NimVersionTuple pylib/nimpatch/utils.html#NimVersionTuple const NimVersionTuple 2 +nim JsBigInt64Option pylib/nimpatch/utils.html#JsBigInt64Option const JsBigInt64Option 4 +nim addPatch pylib/nimpatch/utils.html#addPatch.t,,untyped,untyped template addPatch(ver: (int, int, int); flag: untyped; patchBody: untyped) 6 diff --git a/pylib/nimpatch/winOpenFileHandle.html b/pylib/nimpatch/winOpenFileHandle.html new file mode 100644 index 000000000..015f29757 --- /dev/null +++ b/pylib/nimpatch/winOpenFileHandle.html @@ -0,0 +1,134 @@ + + + + + + + +src/pylib/nimpatch/winOpenFileHandle + + + + + + + + + + + + + + + + +
+
+

src/pylib/nimpatch/winOpenFileHandle

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Imports

+
+ utils +
+
+
+

Consts

+
+
+
BeforeFixedVer = false
+
+ + + Source   +Edit   + +
+
+
+
FixedVer = (2, 1, 1)
+
+ + + Source   +Edit   + +
+
+
+
hasBug = false
+
+ + + Source   +Edit   + +
+
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/nimpatch/winOpenFileHandle.idx b/pylib/nimpatch/winOpenFileHandle.idx new file mode 100644 index 000000000..9d8d5f089 --- /dev/null +++ b/pylib/nimpatch/winOpenFileHandle.idx @@ -0,0 +1,4 @@ +nimTitle winOpenFileHandle pylib/nimpatch/winOpenFileHandle.html module src/pylib/nimpatch/winOpenFileHandle 0 +nim FixedVer pylib/nimpatch/winOpenFileHandle.html#FixedVer const FixedVer 12 +nim BeforeFixedVer pylib/nimpatch/winOpenFileHandle.html#BeforeFixedVer const BeforeFixedVer 13 +nim hasBug pylib/nimpatch/winOpenFileHandle.html#hasBug const hasBug 15 diff --git a/pylib/noneType.html b/pylib/noneType.html new file mode 100644 index 000000000..e7f990107 --- /dev/null +++ b/pylib/noneType.html @@ -0,0 +1,128 @@ + + + + + + + +src/pylib/noneType + + + + + + + + + + + + + + + + +
+
+

src/pylib/noneType

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Types

+
+
+
NoneType = distinct bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Consts

+
+
+
None = false
+
+ + Python-like None for special handling + Source   +Edit   + +
+
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/noneType.idx b/pylib/noneType.idx new file mode 100644 index 000000000..ad8cab26b --- /dev/null +++ b/pylib/noneType.idx @@ -0,0 +1,3 @@ +nimTitle noneType pylib/noneType.html module src/pylib/noneType 0 +nim NoneType pylib/noneType.html#NoneType type NoneType 3 +nim None pylib/noneType.html#None const None 8 diff --git a/pylib/numTypes.html b/pylib/numTypes.html new file mode 100644 index 000000000..e34dde855 --- /dev/null +++ b/pylib/numTypes.html @@ -0,0 +1,96 @@ + + + + + + + +src/pylib/numTypes + + + + + + + + + + + + + + + + +
+
+

src/pylib/numTypes

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+ +
+ + +
+
+ + + diff --git a/pylib/numTypes.idx b/pylib/numTypes.idx new file mode 100644 index 000000000..5d5c8ffe7 --- /dev/null +++ b/pylib/numTypes.idx @@ -0,0 +1 @@ +nimTitle numTypes pylib/numTypes.html module src/pylib/numTypes 0 diff --git a/pylib/numTypes/floats.html b/pylib/numTypes/floats.html new file mode 100644 index 000000000..396adaccb --- /dev/null +++ b/pylib/numTypes/floats.html @@ -0,0 +1,236 @@ + + + + + + + +src/pylib/numTypes/floats + + + + + + + + + + + + + + + + +
+
+

src/pylib/numTypes/floats

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
func as_integer_ratio(self: float; n = halfHigh(int)): (int, int) {.
+    ...raises: [ValueError], tags: [], forbids: [].}
+
+ + see as_someinteger_ratio + Source   +Edit   + +
+
+ +
+
+
+
func as_someinteger_ratio[I: SomeInteger](self: float; n = halfHigh(I)): (I, I)
+
+ +

EXT. Calculates the best rational approximation of x, where the denominator is smaller than n (default is the largest possible I for maximal resolution),

+

The algorithm is from toRational of std/rationals, based on the theory of continued fractions. David Eppstein / UC Irvine / 8 Aug 1993 , but raises ValueError or OverflowDefect if x is NaN or Infinity.

+
Hint: +due to lack of arbitrary length integers, its accuracy is not as high as Python's
+ + Source   +Edit   + +
+
+ +
+
+
+
func checked_as_integer_ratio(self: float): (int, int) {....raises: [ValueError],
+    tags: [], forbids: [].}
+
+ + EXT. like as_integer_ratio but raises OverflowDefect when cannot represent accurately. + Source   +Edit   + +
+
+ +
+
+
+
func float_fromhex(s: string): float {....raises: [ValueError, Exception],
+                                       tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func fromhex(_: typedesc[float]; s: string): float
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func hex(x: float): PyStr {....raises: [Exception], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func is_integer(self: float): bool {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Exports

+
+ float, float, float, float +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/numTypes/floats.idx b/pylib/numTypes/floats.idx new file mode 100644 index 000000000..6500325c2 --- /dev/null +++ b/pylib/numTypes/floats.idx @@ -0,0 +1,8 @@ +nimTitle floats pylib/numTypes/floats.html module src/pylib/numTypes/floats 0 +nim hex pylib/numTypes/floats.html#hex,float proc hex(x: float): PyStr 9 +nim fromhex pylib/numTypes/floats.html#fromhex,typedesc[float],string proc fromhex(_: typedesc[float]; s: string): float 12 +nim float_fromhex pylib/numTypes/floats.html#float_fromhex,string proc float_fromhex(s: string): float 14 +nim is_integer pylib/numTypes/floats.html#is_integer,float proc is_integer(self: float): bool 17 +nim as_someinteger_ratio pylib/numTypes/floats.html#as_someinteger_ratio,float proc as_someinteger_ratio[I: SomeInteger](self: float; n = halfHigh(I)): (I, I) 30 +nim as_integer_ratio pylib/numTypes/floats.html#as_integer_ratio,float proc as_integer_ratio(self: float; n = halfHigh(int)): (int, int) 70 +nim checked_as_integer_ratio pylib/numTypes/floats.html#checked_as_integer_ratio,float proc checked_as_integer_ratio(self: float): (int, int) 75 diff --git a/pylib/numTypes/floats/floathex.html b/pylib/numTypes/floats/floathex.html new file mode 100644 index 000000000..24b086316 --- /dev/null +++ b/pylib/numTypes/floats/floathex.html @@ -0,0 +1,136 @@ + + + + + + + +src/pylib/numTypes/floats/floathex + + + + + + + + + + + + + + + + +
+
+

src/pylib/numTypes/floats/floathex

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
func floatFromhexImpl(s: string): float {....raises: [ValueError, Exception],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func hexImpl(x: float): string {....raises: [Exception], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/numTypes/floats/floathex.idx b/pylib/numTypes/floats/floathex.idx new file mode 100644 index 000000000..b345d69f3 --- /dev/null +++ b/pylib/numTypes/floats/floathex.idx @@ -0,0 +1,3 @@ +nimTitle floathex pylib/numTypes/floats/floathex.html module src/pylib/numTypes/floats/floathex 0 +nim hexImpl pylib/numTypes/floats/floathex.html#hexImpl,float proc hexImpl(x: float): string 88 +nim floatFromhexImpl pylib/numTypes/floats/floathex.html#floatFromhexImpl,string proc floatFromhexImpl(s: string): float 101 diff --git a/pylib/numTypes/floats/init.html b/pylib/numTypes/floats/init.html new file mode 100644 index 000000000..a78c96843 --- /dev/null +++ b/pylib/numTypes/floats/init.html @@ -0,0 +1,190 @@ + + + + + + + +src/pylib/numTypes/floats/init + + + + + + + + + + + + + + + + +
+
+

src/pylib/numTypes/floats/init

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
func float(a: PyStr | PyBytes): BiggestFloat
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc repr(x: SomeFloat): string
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template float(a: bool): BiggestFloat
+
+ + + Source   +Edit   + +
+
+
+
template float(number: SomeNumber = 0.0): BiggestFloat
+
+ + + Source   +Edit   + +
+
+
+
template float(obj: HasIndex): BiggestFloat
+
+ +
Admonition: +since Python 3.8
+ + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/numTypes/floats/init.idx b/pylib/numTypes/floats/init.idx new file mode 100644 index 000000000..c0f87884b --- /dev/null +++ b/pylib/numTypes/floats/init.idx @@ -0,0 +1,7 @@ +nimTitle init pylib/numTypes/floats/init.html module src/pylib/numTypes/floats/init 0 +nim repr pylib/numTypes/floats/init.html#repr,SomeFloat proc repr(x: SomeFloat): string 8 +nim float pylib/numTypes/floats/init.html#float.t,SomeNumber template float(number: SomeNumber = 0.0): BiggestFloat 11 +nim float pylib/numTypes/floats/init.html#float proc float(a: PyStr | PyBytes): BiggestFloat 24 +nim float pylib/numTypes/floats/init.html#float.t,bool template float(a: bool): BiggestFloat 26 +nim float pylib/numTypes/floats/init.html#float.t,HasIndex template float(obj: HasIndex): BiggestFloat 31 +nimgrp float pylib/numTypes/floats/init.html#float-templates-all template 11 diff --git a/pylib/numTypes/floats/parse_inf_nan.html b/pylib/numTypes/floats/parse_inf_nan.html new file mode 100644 index 000000000..c5b2909b3 --- /dev/null +++ b/pylib/numTypes/floats/parse_inf_nan.html @@ -0,0 +1,124 @@ + + + + + + + +src/pylib/numTypes/floats/parse_inf_nan + + + + + + + + + + + + + + + + +
+
+

src/pylib/numTypes/floats/parse_inf_nan

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Procs

+
+
+
+
func parse_inf_or_nan(ori_s: openArray[char]; res: var float): int {....raises: [],
+    tags: [], forbids: [].}
+
+ + a variant of _Py_parse_inf_or_nan in Python/pystrtod.c XXX: don't use parseFloat in std/parseutils currently as it does not respect sign bit of NaNs. + Source   +Edit   + +
+
+
+
func parse_inf_or_nan(res: var float; ori_s: openArray[char]): bool {.
+    ...raises: [], tags: [], forbids: [].}
+
+ +

returns if successfully parses returns false when there are chars left after parsed in ori_s

+

XXX: don't use parseFloat in std/strutils currently as it does not respect sign bit of NaNs.

+ + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/numTypes/floats/parse_inf_nan.idx b/pylib/numTypes/floats/parse_inf_nan.idx new file mode 100644 index 000000000..0e19e79ab --- /dev/null +++ b/pylib/numTypes/floats/parse_inf_nan.idx @@ -0,0 +1,4 @@ +nimTitle parse_inf_nan pylib/numTypes/floats/parse_inf_nan.html module src/pylib/numTypes/floats/parse_inf_nan 0 +nim parse_inf_or_nan pylib/numTypes/floats/parse_inf_nan.html#parse_inf_or_nan,openArray[char],float proc parse_inf_or_nan(ori_s: openArray[char]; res: var float): int 4 +nim parse_inf_or_nan pylib/numTypes/floats/parse_inf_nan.html#parse_inf_or_nan,float,openArray[char] proc parse_inf_or_nan(res: var float; ori_s: openArray[char]): bool 35 +nimgrp parseinfornan pylib/numTypes/floats/parse_inf_nan.html#parse_inf_or_nan-procs-all proc 4 diff --git a/pylib/numTypes/floats/parsefloat.html b/pylib/numTypes/floats/parsefloat.html new file mode 100644 index 000000000..d23dd9266 --- /dev/null +++ b/pylib/numTypes/floats/parsefloat.html @@ -0,0 +1,121 @@ + + + + + + + +src/pylib/numTypes/floats/parsefloat + + + + + + + + + + + + + + + + +
+
+

src/pylib/numTypes/floats/parsefloat

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
func parsePyFloat(a: openArray[char]; res: var BiggestFloat): int {....raises: [],
+    tags: [], forbids: [].}
+
+ + Almost the same as parseFloat in std/parseutils but respects the sign of NaNs
Hint: +this does not strip whitespaces, just like parseFloat
+ + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/numTypes/floats/parsefloat.idx b/pylib/numTypes/floats/parsefloat.idx new file mode 100644 index 000000000..421989b5e --- /dev/null +++ b/pylib/numTypes/floats/parsefloat.idx @@ -0,0 +1,2 @@ +nimTitle parsefloat pylib/numTypes/floats/parsefloat.html module src/pylib/numTypes/floats/parsefloat 0 +nim parsePyFloat pylib/numTypes/floats/parsefloat.html#parsePyFloat,openArray[char],BiggestFloat proc parsePyFloat(a: openArray[char]; res: var BiggestFloat): int 5 diff --git a/pylib/numTypes/ints.html b/pylib/numTypes/ints.html new file mode 100644 index 000000000..9685bea23 --- /dev/null +++ b/pylib/numTypes/ints.html @@ -0,0 +1,96 @@ + + + + + + + +src/pylib/numTypes/ints + + + + + + + + + + + + + + + + +
+
+

src/pylib/numTypes/ints

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+ +
+ + +
+
+ + + diff --git a/pylib/numTypes/ints.idx b/pylib/numTypes/ints.idx new file mode 100644 index 000000000..98a784ef2 --- /dev/null +++ b/pylib/numTypes/ints.idx @@ -0,0 +1 @@ +nimTitle ints pylib/numTypes/ints.html module src/pylib/numTypes/ints 0 diff --git a/pylib/numTypes/ints/bitops.html b/pylib/numTypes/ints/bitops.html new file mode 100644 index 000000000..0eabddbdf --- /dev/null +++ b/pylib/numTypes/ints/bitops.html @@ -0,0 +1,112 @@ + + + + + + + +src/pylib/numTypes/ints/bitops + + + + + + + + + + + + + + + + +
+
+

src/pylib/numTypes/ints/bitops

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Templates

+
+
+
+
template exportIntBitOps() {.dirty.}
+
+ +
Warning: +<< causes overflow silently. Yet Python's int never overflows.
+

Currently shr is also arithm shr, but it used to be logic shr

+ + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/numTypes/ints/bitops.idx b/pylib/numTypes/ints/bitops.idx new file mode 100644 index 000000000..f5e462523 --- /dev/null +++ b/pylib/numTypes/ints/bitops.idx @@ -0,0 +1,2 @@ +nimTitle bitops pylib/numTypes/ints/bitops.html module src/pylib/numTypes/ints/bitops 0 +nim exportIntBitOps pylib/numTypes/ints/bitops.html#exportIntBitOps.t template exportIntBitOps() 8 diff --git a/pylib/numTypes/ints/decl.html b/pylib/numTypes/ints/decl.html new file mode 100644 index 000000000..c3c0d70ff --- /dev/null +++ b/pylib/numTypes/ints/decl.html @@ -0,0 +1,103 @@ + + + + + + + +src/pylib/numTypes/ints/decl + + + + + + + + + + + + + + + + +
+
+

src/pylib/numTypes/ints/decl

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Types

+
+
+
NimInt = system.int
+
+ + alias of system.int + Source   +Edit   + +
+
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/numTypes/ints/decl.idx b/pylib/numTypes/ints/decl.idx new file mode 100644 index 000000000..ce5d25af9 --- /dev/null +++ b/pylib/numTypes/ints/decl.idx @@ -0,0 +1,2 @@ +nimTitle decl pylib/numTypes/ints/decl.html module src/pylib/numTypes/ints/decl 0 +nim NimInt pylib/numTypes/ints/decl.html#NimInt type NimInt 2 diff --git a/pylib/numTypes/ints/getter.html b/pylib/numTypes/ints/getter.html new file mode 100644 index 000000000..b8d63c19b --- /dev/null +++ b/pylib/numTypes/ints/getter.html @@ -0,0 +1,192 @@ + + + + + + + +src/pylib/numTypes/ints/getter + + + + + + + + + + + + + + + + +
+
+

src/pylib/numTypes/ints/getter

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Templates

+
+
+
+
template as_integer_ratio(self: NimInt): (NimInt, NimInt)
+
+ +
Admonition: +since Python 3.8
+ + Source   +Edit   + +
+
+ +
+
+
+
template bit_count(self: NimInt): NimInt
+
+ +
Admonition: +since Python 3.10
+ + Source   +Edit   + +
+
+ +
+
+
+
template bit_length(self: NimInt): NimInt
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template conjugate(self: NimInt): NimInt
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template is_integer(_: NimInt): bool
+
+ +
Admonition: +since Python 3.12
+ + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/numTypes/ints/getter.idx b/pylib/numTypes/ints/getter.idx new file mode 100644 index 000000000..1c96dd9f5 --- /dev/null +++ b/pylib/numTypes/ints/getter.idx @@ -0,0 +1,6 @@ +nimTitle getter pylib/numTypes/ints/getter.html module src/pylib/numTypes/ints/getter 0 +nim is_integer pylib/numTypes/ints/getter.html#is_integer.t,NimInt template is_integer(_: NimInt): bool 7 +nim as_integer_ratio pylib/numTypes/ints/getter.html#as_integer_ratio.t,NimInt template as_integer_ratio(self: NimInt): (NimInt, NimInt) 8 +nim bit_length pylib/numTypes/ints/getter.html#bit_length.t,NimInt template bit_length(self: NimInt): NimInt 11 +nim bit_count pylib/numTypes/ints/getter.html#bit_count.t,NimInt template bit_count(self: NimInt): NimInt 15 +nim conjugate pylib/numTypes/ints/getter.html#conjugate.t,NimInt template conjugate(self: NimInt): NimInt 18 diff --git a/pylib/numTypes/ints/init.html b/pylib/numTypes/ints/init.html new file mode 100644 index 000000000..869dd6f25 --- /dev/null +++ b/pylib/numTypes/ints/init.html @@ -0,0 +1,243 @@ + + + + + + + +src/pylib/numTypes/ints/init + + + + + + + + + + + + + + + + +
+
+

src/pylib/numTypes/ints/init

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
func int(a: char): NimInt {....raises: [ValueError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func int(a: PyStr | PyBytes): NimInt
+
+ + + Source   +Edit   + +
+
+
+
func int(a: PyStr | PyBytes; base: int): NimInt
+
+ + allowed base + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template int(a: bool): NimInt
+
+ + + Source   +Edit   + +
+
+
+
template int(f: float): NimInt
+
+ + + Source   +Edit   + +
+
+
+
template int(i: SomeInteger): NimInt
+
+ + + Source   +Edit   + +
+
+
+
template int(obj: HasIndex and HasIndex): NimInt
+
+ + + Source   +Edit   + +
+
+
+
template int(obj: HasIndex): NimInt
+
+ + + Source   +Edit   + +
+
+
+
template int(obj: HasTrunc): NimInt
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template nimint(a): NimInt
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/numTypes/ints/init.idx b/pylib/numTypes/ints/init.idx new file mode 100644 index 000000000..1f4c66660 --- /dev/null +++ b/pylib/numTypes/ints/init.idx @@ -0,0 +1,13 @@ +nimTitle init pylib/numTypes/ints/init.html module src/pylib/numTypes/ints/init 0 +nim int pylib/numTypes/ints/init.html#int.t,SomeInteger template int(i: SomeInteger): NimInt 8 +nim int pylib/numTypes/ints/init.html#int proc int(a: PyStr | PyBytes): NimInt 14 +nim int pylib/numTypes/ints/init.html#int,char proc int(a: char): NimInt 22 +nim int pylib/numTypes/ints/init.html#int.t,bool template int(a: bool): NimInt 27 +nim int pylib/numTypes/ints/init.html#int.t,float template int(f: float): NimInt 28 +nim int pylib/numTypes/ints/init.html#int.t,HasIndex template int(obj: HasIndex): NimInt 36 +nim int pylib/numTypes/ints/init.html#int.t,HasTrunc template int(obj: HasTrunc): NimInt 37 +nim int pylib/numTypes/ints/init.html#int.t template int(obj: HasIndex and HasIndex): NimInt 38 +nim nimint pylib/numTypes/ints/init.html#nimint.t template nimint(a): NimInt 40 +nim int pylib/numTypes/ints/init.html#int,,int proc int(a: PyStr | PyBytes; base: int): NimInt 83 +nimgrp int pylib/numTypes/ints/init.html#int-procs-all proc 14 +nimgrp int pylib/numTypes/ints/init.html#int-templates-all template 8 diff --git a/pylib/numTypes/ints/int_bytes.html b/pylib/numTypes/ints/int_bytes.html new file mode 100644 index 000000000..665209599 --- /dev/null +++ b/pylib/numTypes/ints/int_bytes.html @@ -0,0 +1,212 @@ + + + + + + + +src/pylib/numTypes/ints/int_bytes + + + + + + + + + + + + + + + + +
+
+

src/pylib/numTypes/ints/int_bytes

+
+ +
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
func add_from_bytes(res: var NimInt; bytes: PyBytes; byteorder: Endianness;
+                    signed = false) {....raises: [], tags: [], forbids: [].}
+
+ + EXT. + Source   +Edit   + +
+
+ +
+
+
+
func from_bytes(_: typedesc[NimInt]; bytes: PyBytes;
+                byteorder: static[PyStr] = str("big"); signed = false): NimInt
+
+ +
Admonition: +since Python 3.11
+

this variant uses static param for byteorder

+ + Source   +Edit   + +
+
+
+
func from_bytes(_: typedesc[NimInt]; bytes: PyBytes; byteorder: PyStr;
+                signed = false): NimInt
+
+ +
Admonition: +since Python 3.2
+ + Source   +Edit   + +
+
+ +
+
+
+
func to_bytes(self: NimInt; length: int; byteorder: PyStr; signed = false): PyBytes {.
+    ...raises: [ValueError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func to_bytes(self: NimInt; length: int; byteorder: static[PyStr] = str("big");
+              signed = false): PyBytes
+
+ +
Admonition: +since Python 3.11
+ + Source   +Edit   + +
+
+ +
+
+
+
func to_chars(self: NimInt; length: int; endianness: Endianness; signed = false): seq[
+    char] {....raises: [ValueError], tags: [], forbids: [].}
+
+ + EXT. + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/numTypes/ints/int_bytes.idx b/pylib/numTypes/ints/int_bytes.idx new file mode 100644 index 000000000..a0cbd4300 --- /dev/null +++ b/pylib/numTypes/ints/int_bytes.idx @@ -0,0 +1,9 @@ +nimTitle int_bytes pylib/numTypes/ints/int_bytes.html module src/pylib/numTypes/ints/int_bytes 0 +nim add_from_bytes pylib/numTypes/ints/int_bytes.html#add_from_bytes,NimInt,PyBytes,Endianness proc add_from_bytes(res: var NimInt; bytes: PyBytes; byteorder: Endianness;\n signed = false) 70 +nim from_bytes pylib/numTypes/ints/int_bytes.html#from_bytes,typedesc[NimInt],PyBytes,PyStr proc from_bytes(_: typedesc[NimInt]; bytes: PyBytes; byteorder: PyStr; signed = false): NimInt 107 +nim from_bytes pylib/numTypes/ints/int_bytes.html#from_bytes,typedesc[NimInt],PyBytes,static[PyStr] proc from_bytes(_: typedesc[NimInt]; bytes: PyBytes;\n byteorder: static[PyStr] = str("big"); signed = false): NimInt 113 +nim to_chars pylib/numTypes/ints/int_bytes.html#to_chars,,int,Endianness proc to_chars(self: NimInt; length: int; endianness: Endianness; signed = false): seq[\n char] 120 +nim to_bytes pylib/numTypes/ints/int_bytes.html#to_bytes,,int,PyStr proc to_bytes(self: NimInt; length: int; byteorder: PyStr; signed = false): PyBytes 142 +nim to_bytes pylib/numTypes/ints/int_bytes.html#to_bytes,,int,static[PyStr] proc to_bytes(self: NimInt; length: int; byteorder: static[PyStr] = str("big");\n signed = false): PyBytes 147 +nimgrp frombytes pylib/numTypes/ints/int_bytes.html#from_bytes-procs-all proc 107 +nimgrp tobytes pylib/numTypes/ints/int_bytes.html#to_bytes-procs-all proc 142 diff --git a/pylib/numTypes/ints/longint.html b/pylib/numTypes/ints/longint.html new file mode 100644 index 000000000..78f8c161e --- /dev/null +++ b/pylib/numTypes/ints/longint.html @@ -0,0 +1,175 @@ + + + + + + + +src/pylib/numTypes/ints/longint + + + + + + + + + + + + + + + + +
+
+

src/pylib/numTypes/ints/longint

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+
+ Deprecated: long(a.k.a. PyLong) is not supported, +currently it's just a alias of BiggestInt (e.g. int64 on 64bit system) +
+ +

TODO: later may allow to switch to bigints when compile

+
+

Imports

+
+ init +
+
+
+

Templates

+
+
+
+
template long(a: bool): int {....deprecated: """long(a.k.a. PyLong) is not supported, 
+currently it's just a alias of BiggestInt (e.g. int64 on 64bit system)""".}
+
+
+ Deprecated: long(a.k.a. PyLong) is not supported, +currently it's just a alias of BiggestInt (e.g. int64 on 64bit system) +
+ + + Source   +Edit   + +
+
+
+
template long(a: char): BiggestInt {....deprecated: """long(a.k.a. PyLong) is not supported, 
+currently it's just a alias of BiggestInt (e.g. int64 on 64bit system)""".}
+
+
+ Deprecated: long(a.k.a. PyLong) is not supported, +currently it's just a alias of BiggestInt (e.g. int64 on 64bit system) +
+ + + Source   +Edit   + +
+
+
+
template long(a: string): BiggestInt {....deprecated: """long(a.k.a. PyLong) is not supported, 
+currently it's just a alias of BiggestInt (e.g. int64 on 64bit system)""".}
+
+
+ Deprecated: long(a.k.a. PyLong) is not supported, +currently it's just a alias of BiggestInt (e.g. int64 on 64bit system) +
+ + + Source   +Edit   + +
+
+
+
template long[T: SomeNumber](a: T): BiggestInt {....deprecated: """long(a.k.a. PyLong) is not supported, 
+currently it's just a alias of BiggestInt (e.g. int64 on 64bit system)""".}
+
+
+ Deprecated: long(a.k.a. PyLong) is not supported, +currently it's just a alias of BiggestInt (e.g. int64 on 64bit system) +
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/numTypes/ints/longint.idx b/pylib/numTypes/ints/longint.idx new file mode 100644 index 000000000..4b035fa62 --- /dev/null +++ b/pylib/numTypes/ints/longint.idx @@ -0,0 +1,6 @@ +nimTitle longint pylib/numTypes/ints/longint.html module src/pylib/numTypes/ints/longint 0 +nim long pylib/numTypes/ints/longint.html#long.t,string template long(a: string): BiggestInt 8 +nim long pylib/numTypes/ints/longint.html#long.t,char template long(a: char): BiggestInt 9 +nim long pylib/numTypes/ints/longint.html#long.t,T template long[T: SomeNumber](a: T): BiggestInt 10 +nim long pylib/numTypes/ints/longint.html#long.t,bool template long(a: bool): int 11 +nimgrp long pylib/numTypes/ints/longint.html#long-templates-all template 8 diff --git a/pylib/numTypes/ints/nint_proto.html b/pylib/numTypes/ints/nint_proto.html new file mode 100644 index 000000000..b07e53754 --- /dev/null +++ b/pylib/numTypes/ints/nint_proto.html @@ -0,0 +1,161 @@ + + + + + + + +src/pylib/numTypes/ints/nint_proto + + + + + + + + + + + + + + + + +
+
+

src/pylib/numTypes/ints/nint_proto

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

used by ./int_bytes

+
+

Imports

+
+ decl, getter +
+
+
+

Templates

+
+
+
+
template fitLen(_: var NimInt; nbyte: int): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template getSize(self: NimInt): int
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template newInt(): NimInt
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Exports

+
+ bit_length +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/numTypes/ints/nint_proto.idx b/pylib/numTypes/ints/nint_proto.idx new file mode 100644 index 000000000..316fcbb8c --- /dev/null +++ b/pylib/numTypes/ints/nint_proto.idx @@ -0,0 +1,4 @@ +nimTitle nint_proto pylib/numTypes/ints/nint_proto.html module src/pylib/numTypes/ints/nint_proto 0 +nim newInt pylib/numTypes/ints/nint_proto.html#newInt.t template newInt(): NimInt 7 +nim getSize pylib/numTypes/ints/nint_proto.html#getSize.t,NimInt template getSize(self: NimInt): int 8 +nim fitLen pylib/numTypes/ints/nint_proto.html#fitLen.t,NimInt,int template fitLen(_: var NimInt; nbyte: int): bool 9 diff --git a/pylib/numTypes/reimporter.html b/pylib/numTypes/reimporter.html new file mode 100644 index 000000000..bf46aebc3 --- /dev/null +++ b/pylib/numTypes/reimporter.html @@ -0,0 +1,96 @@ + + + + + + + +src/pylib/numTypes/reimporter + + + + + + + + + + + + + + + + +
+
+

src/pylib/numTypes/reimporter

+ + + +
+
+ + + diff --git a/pylib/numTypes/reimporter.idx b/pylib/numTypes/reimporter.idx new file mode 100644 index 000000000..13b2c3bd7 --- /dev/null +++ b/pylib/numTypes/reimporter.idx @@ -0,0 +1 @@ +nimTitle reimporter pylib/numTypes/reimporter.html module src/pylib/numTypes/reimporter 0 diff --git a/pylib/numTypes/utils/stripOpenArray.html b/pylib/numTypes/utils/stripOpenArray.html new file mode 100644 index 000000000..b612b89eb --- /dev/null +++ b/pylib/numTypes/utils/stripOpenArray.html @@ -0,0 +1,125 @@ + + + + + + + +src/pylib/numTypes/utils/stripOpenArray + + + + + + + + + + + + + + + + +
+
+

src/pylib/numTypes/utils/stripOpenArray

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
func stripAsRange(s: openArray[char]; leading: static[bool] = true;
+                  trailing: static[bool] = true;
+                  runes: openArray[Rune] = unicodeSpaces): tuple[
+    first, last: int]
+
+ + s[first..last] will be stripped data. + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/numTypes/utils/stripOpenArray.idx b/pylib/numTypes/utils/stripOpenArray.idx new file mode 100644 index 000000000..ac3407f2a --- /dev/null +++ b/pylib/numTypes/utils/stripOpenArray.idx @@ -0,0 +1,2 @@ +nimTitle stripOpenArray pylib/numTypes/utils/stripOpenArray.html module src/pylib/numTypes/utils/stripOpenArray 0 +nim stripAsRange pylib/numTypes/utils/stripOpenArray.html#stripAsRange,openArray[char],static[bool],static[bool],openArray[Rune] proc stripAsRange(s: openArray[char]; leading: static[bool] = true;\n trailing: static[bool] = true;\n runes: openArray[Rune] = unicodeSpaces): tuple[first, last: int] 5 diff --git a/pylib/ops.html b/pylib/ops.html new file mode 100644 index 000000000..f68df2eb1 --- /dev/null +++ b/pylib/ops.html @@ -0,0 +1,669 @@ + + + + + + + +src/pylib/ops + + + + + + + + + + + + + + + + +
+
+

src/pylib/ops

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+

why no /= defined?

For

+

template `/=`*(x: var SomeInteger, y: SomeInteger)

+

Nim is static-typed, but /= will cause lhs convert from int to float

+

+ +
+

Procs

+
+
+
+
func `%`[T: SomeNumber](a, b: T): T
+
+ + Python's modulo (a.k.a floor modulo) (quotient)
Hint: +Nim's mod is the same as a - b * (a div b) (remainder), just like C.
+ +

Example:

+
assert 13 % -3 == -2
+assert -13 % 3 == 2
+ Source   +Edit   + +
+
+ +
+
+
+
proc `&=`[I: SomeInteger](a: var I; b: I)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func `//`[A, B: SomeFloat | SomeInteger](a: A; b: B): SomeNumber {.inline.}
+
+ + Python's division (a.k.a. floor division)
Hint: +Nim's div is division with any fractional part discarded (a.k.a."truncation toward zero"), just like C.
+ +

Example:

+
assert 13 // -3 == -5
+assert 13 div -3 == -4
+ Source   +Edit   + +
+
+ +
+
+
+
proc `<<=`[I: SomeInteger](a: var I; b: I)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc `>>=`[I: SomeInteger](a: var I; b: I)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc `^=`[I: SomeInteger](a: var I; b: I)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func divmod[T: SomeNumber](x, y: T): (T, T)
+
+ + differs from std/math divmod, see // and % for details. + Source   +Edit   + +
+
+ +
+
+
+
proc `|=`[I: SomeInteger](a: var I; b: I)
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template `%`[A: SomeFloat; B: SomeInteger](a: A; b: B): A
+
+ + + Source   +Edit   + +
+
+
+
template `%`[A: SomeInteger; B: SomeFloat](a: A; b: B): B
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template `%=`(self: var SomeNumber; x: SomeNumber)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template `&`[I: SomeInteger](a, b: I): I
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template `**`[A: SomeFloat; B: SomeInteger](a: A; b: B): A
+
+ + + Source   +Edit   + +
+
+
+
template `**`[A: SomeInteger; B: SomeFloat](a: A; b: B): B
+
+ + + Source   +Edit   + +
+
+
+
template `**`[T: SomeFloat](a, b: T): T
+
+ + + Source   +Edit   + +
+
+
+
template `**`[T: SomeInteger](a: T; b: static[int]): T | float
+
+ +

power for static int b

+

so that result type can be inferred:

+
  • int if b >= 0
  • +
  • float if b < 0
  • +
+

For non-static int b, `**`(a: T; b: Natural) is used.

+ +

Example:

+
const f = 5 ** -1  # only when the rhs is static[int]
+assert f == 0.2
+const i = 5 ** 2
+assert i == int(25)
+ Source   +Edit   + +
+
+
+
template `**`[T](a: T; b: Natural): T
+
+ +

power for b is a non-static integer:

+

only Natural is acceptable unless b is static, see `**`(a: T; b: static[int])

+ +

Example:

+
var i = -1
+doAssertRaises RangeDefect:
+  discard (5 ** i)
+  ## this runs iff `i` is of static[int]
+  ## e.g. `5 ** -1`
+ Source   +Edit   + +
+
+ +
+
+
+
template `**=`(a: var SomeNumber; b: SomeNumber)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template `/`(x: SomeInteger; y: SomeInteger): float
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template `//=`[A, B: SomeFloat | SomeInteger](a: var A; b: B)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template `<`[A: SomeFloat; B: SomeInteger](a: A; b: B): bool
+
+ + + Source   +Edit   + +
+
+
+
template `<`[A: SomeInteger; B: SomeFloat](a: A; b: B): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template `<<`[I: SomeInteger](a, b: I): I
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template `<=`[A: SomeFloat; B: SomeInteger](a: A; b: B): bool
+
+ + + Source   +Edit   + +
+
+
+
template `<=`[A: SomeInteger; B: SomeFloat](a: A; b: B): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template `<>`[A: SomeFloat; B: SomeInteger](a: A; b: B): bool
+
+ + + Source   +Edit   + +
+
+
+
template `<>`[A: SomeInteger; B: SomeFloat](a: A; b: B): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template `==`(a, b: typedesc): bool
+
+ + Compare 2 typedesc like Python. +

Example:

+
doAssert type(1) == type(2)
+ Source   +Edit   + +
+
+
+
template `==`[A: SomeFloat; B: SomeInteger](a: A; b: B): bool
+
+ + + Source   +Edit   + +
+
+
+
template `==`[A: SomeInteger; B: SomeFloat](a: A; b: B): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template `>>`[I: SomeInteger](a, b: I): I
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template `^`[I: SomeInteger](a, b: I): I
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template `|`[I: SomeInteger](a, b: I): I
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template `~`[I: SomeInteger](a: I): I
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/ops.idx b/pylib/ops.idx new file mode 100644 index 000000000..2521f037f --- /dev/null +++ b/pylib/ops.idx @@ -0,0 +1,42 @@ +nimTitle ops pylib/ops.html module src/pylib/ops 0 +nim `**` pylib/ops.html#**.t,T,Natural template `**`[T](a: T; b: Natural): T 17 +nim `**` pylib/ops.html#**.t,T,static[int] template `**`[T: SomeInteger](a: T; b: static[int]): T | float 31 +nim `~` pylib/ops.html#~.t,I template `~`[I: SomeInteger](a: I): I 14 +nim `^` pylib/ops.html#^.t,I,I template `^`[I: SomeInteger](a, b: I): I 5 +nim `^=` pylib/ops.html#^=,I,I proc `^=`[I: SomeInteger](a: var I; b: I) 15 +nim `&` pylib/ops.html#&.t,I,I template `&`[I: SomeInteger](a, b: I): I 5 +nim `&=` pylib/ops.html#&=,I,I proc `&=`[I: SomeInteger](a: var I; b: I) 16 +nim `|` pylib/ops.html#|.t,I,I template `|`[I: SomeInteger](a, b: I): I 5 +nim `|=` pylib/ops.html#|=,I,I proc `|=`[I: SomeInteger](a: var I; b: I) 17 +nim `<<` pylib/ops.html#<<.t,I,I template `<<`[I: SomeInteger](a, b: I): I 5 +nim `<<=` pylib/ops.html#<<=,I,I proc `<<=`[I: SomeInteger](a: var I; b: I) 18 +nim `>>` pylib/ops.html#>>.t,I,I template `>>`[I: SomeInteger](a, b: I): I 5 +nim `>>=` pylib/ops.html#>>=,I,I proc `>>=`[I: SomeInteger](a: var I; b: I) 53 +nim `**` pylib/ops.html#**.t,T,T template `**`[T: SomeFloat](a, b: T): T 55 +nim `**` pylib/ops.html#**.t,A,B template `**`[A: SomeFloat; B: SomeInteger](a: A; b: B): A 58 +nim `**` pylib/ops.html#**.t,A,B_2 template `**`[A: SomeInteger; B: SomeFloat](a: A; b: B): B 61 +nim `**=` pylib/ops.html#**=.t,SomeNumber,SomeNumber template `**=`(a: var SomeNumber; b: SomeNumber) 65 +nim `<` pylib/ops.html#<.t,A,B template `<`[A: SomeInteger; B: SomeFloat](a: A; b: B): bool 71 +nim `<` pylib/ops.html#<.t,A,B_2 template `<`[A: SomeFloat; B: SomeInteger](a: A; b: B): bool 72 +nim `<=` pylib/ops.html#<=.t,A,B template `<=`[A: SomeInteger; B: SomeFloat](a: A; b: B): bool 74 +nim `<=` pylib/ops.html#<=.t,A,B_2 template `<=`[A: SomeFloat; B: SomeInteger](a: A; b: B): bool 75 +nim `==` pylib/ops.html#==.t,A,B template `==`[A: SomeInteger; B: SomeFloat](a: A; b: B): bool 77 +nim `==` pylib/ops.html#==.t,A,B_2 template `==`[A: SomeFloat; B: SomeInteger](a: A; b: B): bool 78 +nim `<>` pylib/ops.html#<>.t,A,B template `<>`[A: SomeInteger; B: SomeFloat](a: A; b: B): bool 80 +nim `<>` pylib/ops.html#<>.t,A,B_2 template `<>`[A: SomeFloat; B: SomeInteger](a: A; b: B): bool 81 +nim `/` pylib/ops.html#/.t,SomeInteger,SomeInteger template `/`(x: SomeInteger; y: SomeInteger): float 83 +nim `%` pylib/ops.html#%,T,T proc `%`[T: SomeNumber](a, b: T): T 90 +nim `%` pylib/ops.html#%.t,A,B template `%`[A: SomeFloat; B: SomeInteger](a: A; b: B): A 101 +nim `%` pylib/ops.html#%.t,A,B_2 template `%`[A: SomeInteger; B: SomeFloat](a: A; b: B): B 102 +nim `%=` pylib/ops.html#%=.t,SomeNumber,SomeNumber template `%=`(self: var SomeNumber; x: SomeNumber) 104 +nim `//` pylib/ops.html#//,A,B proc `//`[A, B: SomeFloat | SomeInteger](a: A; b: B): SomeNumber 106 +nim `//=` pylib/ops.html#//=.t,A,B template `//=`[A, B: SomeFloat | SomeInteger](a: var A; b: B) 119 +nim divmod pylib/ops.html#divmod,T,T proc divmod[T: SomeNumber](x, y: T): (T, T) 122 +nim `==` pylib/ops.html#==.t,typedesc,typedesc template `==`(a, b: typedesc): bool 126 +nimgrp == pylib/ops.html#==-templates-all template 77 +nimgrp ** pylib/ops.html#**-templates-all template 17 +nimgrp % pylib/ops.html#%-templates-all template 101 +nimgrp <= pylib/ops.html#<=-templates-all template 74 +nimgrp <> pylib/ops.html#<>-templates-all template 80 +nimgrp < pylib/ops.html#<-templates-all template 71 +heading why no nim/= defined? pylib/ops.html#why-no-nimslasheq-definedqmark why no /= defined? 0 diff --git a/pylib/ops/chk_shl.html b/pylib/ops/chk_shl.html new file mode 100644 index 000000000..c6d78c03e --- /dev/null +++ b/pylib/ops/chk_shl.html @@ -0,0 +1,109 @@ + + + + + + + +src/pylib/ops/chk_shl + + + + + + + + + + + + + + + + +
+
+

src/pylib/ops/chk_shl

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Procs

+
+
+
+
func checkedShl[I: SomeInteger](a, b: I): I
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/ops/chk_shl.idx b/pylib/ops/chk_shl.idx new file mode 100644 index 000000000..78721c834 --- /dev/null +++ b/pylib/ops/chk_shl.idx @@ -0,0 +1,2 @@ +nimTitle chk_shl pylib/ops/chk_shl.html module src/pylib/ops/chk_shl 0 +nim checkedShl pylib/ops/chk_shl.html#checkedShl,I,I proc checkedShl[I: SomeInteger](a, b: I): I 7 diff --git a/pylib/private/backendMark.html b/pylib/private/backendMark.html new file mode 100644 index 000000000..3d4d20dda --- /dev/null +++ b/pylib/private/backendMark.html @@ -0,0 +1,206 @@ + + + + + + + +src/pylib/private/backendMark + + + + + + + + + + + + + + + + +
+
+

src/pylib/private/backendMark

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Types

+
+
+
CompileBackend {.pure.} = enum
+  c = "C", cpp = "C++", objc = "Object-C", js = "JavaScript",
+  nimscript = "NimScript"
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Templates

+
+
+
+
template noBackend(backends: untyped; def)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template noBackends(backends: untyped; def)
+
+ + does the same as noBackend(...) + Source   +Edit   + +
+
+ +
+
+
+
template noJsBackend(def)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template noNimsBackend(def)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template noWeirdBackend(def)
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/private/backendMark.idx b/pylib/private/backendMark.idx new file mode 100644 index 000000000..dfffc25bf --- /dev/null +++ b/pylib/private/backendMark.idx @@ -0,0 +1,7 @@ +nimTitle backendMark pylib/private/backendMark.html module src/pylib/private/backendMark 0 +nim CompileBackend pylib/private/backendMark.html#CompileBackend enum CompileBackend 5 +nim noJsBackend pylib/private/backendMark.html#noJsBackend.t template noJsBackend(def) 71 +nim noNimsBackend pylib/private/backendMark.html#noNimsBackend.t template noNimsBackend(def) 75 +nim noBackends pylib/private/backendMark.html#noBackends.t,untyped, template noBackends(backends: untyped; def) 102 +nim noWeirdBackend pylib/private/backendMark.html#noWeirdBackend.t template noWeirdBackend(def) 107 +nim noBackend pylib/private/backendMark.html#noBackend.t,untyped, template noBackend(backends: untyped; def) 117 diff --git a/pylib/private/encoding_norm.html b/pylib/private/encoding_norm.html new file mode 100644 index 000000000..94e202e8f --- /dev/null +++ b/pylib/private/encoding_norm.html @@ -0,0 +1,131 @@ + + + + + + + +src/pylib/private/encoding_norm + + + + + + + + + + + + + + + + +
+
+

src/pylib/private/encoding_norm

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Procs

+
+
+
+
proc encodings.normalize_encoding(encoding: string): string {....raises: [],
+    tags: [], forbids: [].}
+
+ +

Normalize an encoding name.

+

Normalization works as follows: all non-alphanumeric characters except the dot used for Python package names are collapsed and replaced with a single underscore, e.g. ' -;#' becomes '_'. Leading and trailing underscores are removed.

+

Note that encoding names should be ASCII only.

+ + Source   +Edit   + +
+
+ +
+
+
+
proc Py_normalize_encoding(encoding: string): string {....raises: [], tags: [],
+    forbids: [].}
+
+ + Normalize an encoding name: similar to encodings.normalize_encoding(), but also convert to lowercase. + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/private/encoding_norm.idx b/pylib/private/encoding_norm.idx new file mode 100644 index 000000000..d0a872286 --- /dev/null +++ b/pylib/private/encoding_norm.idx @@ -0,0 +1,3 @@ +nimTitle encoding_norm pylib/private/encoding_norm.html module src/pylib/private/encoding_norm 0 +nim Py_normalize_encoding pylib/private/encoding_norm.html#Py_normalize_encoding,string proc Py_normalize_encoding(encoding: string): string 22 +nim encodings.normalize_encoding pylib/private/encoding_norm.html#encodings.normalize_encoding,string proc encodings.normalize_encoding(encoding: string): string 28 diff --git a/pylib/private/inspect_cleandoc.html b/pylib/private/inspect_cleandoc.html new file mode 100644 index 000000000..2bad70dbd --- /dev/null +++ b/pylib/private/inspect_cleandoc.html @@ -0,0 +1,124 @@ + + + + + + + +src/pylib/private/inspect_cleandoc + + + + + + + + + + + + + + + + +
+
+

src/pylib/private/inspect_cleandoc

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
func inspect.cleandoc(doc: openArray[char]): string {....raises: [], tags: [],
+    forbids: [].}
+
+ +

Clean up indentation from docstrings.

+

Any whitespace that can be uniformly removed from the second line onwards is removed.

+
Note: +this is also used as _PyCompile_CleanDoc here. Nim itself will trace the fileno of the file being
+

compiled. no need to keep the leading adn tailing blank lines like Python/compile.c: _PyCompile_CleanDoc does.

+ + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/private/inspect_cleandoc.idx b/pylib/private/inspect_cleandoc.idx new file mode 100644 index 000000000..1f046bfa7 --- /dev/null +++ b/pylib/private/inspect_cleandoc.idx @@ -0,0 +1,2 @@ +nimTitle inspect_cleandoc pylib/private/inspect_cleandoc.html module src/pylib/private/inspect_cleandoc 0 +nim inspect.cleandoc pylib/private/inspect_cleandoc.html#inspect.cleandoc,openArray[char] proc inspect.cleandoc(doc: openArray[char]): string 21 diff --git a/pylib/private/iterGen.html b/pylib/private/iterGen.html new file mode 100644 index 000000000..e1f5a0f88 --- /dev/null +++ b/pylib/private/iterGen.html @@ -0,0 +1,142 @@ + + + + + + + +src/pylib/private/iterGen + + + + + + + + + + + + + + + + +
+
+

src/pylib/private/iterGen

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Macros

+
+
+
+
macro genIter(def)
+
+ +

used as pragma

+

Generates code of non-reentrant iterable, according to an iterator.

+ + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template makeIterable(Typ) {.dirty.}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/private/iterGen.idx b/pylib/private/iterGen.idx new file mode 100644 index 000000000..a1355c255 --- /dev/null +++ b/pylib/private/iterGen.idx @@ -0,0 +1,3 @@ +nimTitle iterGen pylib/private/iterGen.html module src/pylib/private/iterGen 0 +nim makeIterable pylib/private/iterGen.html#makeIterable.t template makeIterable(Typ) 13 +nim genIter pylib/private/iterGen.html#genIter.m macro genIter(def) 17 diff --git a/pylib/private/trans_imp.html b/pylib/private/trans_imp.html new file mode 100644 index 000000000..e3cbd94d0 --- /dev/null +++ b/pylib/private/trans_imp.html @@ -0,0 +1,109 @@ + + + + + + + +src/pylib/private/trans_imp + + + + + + + + + + + + + + + + +
+
+

src/pylib/private/trans_imp

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

import & export helper

+
+

Macros

+
+
+
+
macro impExp(pre; mods: varargs[untyped])
+
+ + gen: import ./pre/[...mods]; export ...mods + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/private/trans_imp.idx b/pylib/private/trans_imp.idx new file mode 100644 index 000000000..dbf388830 --- /dev/null +++ b/pylib/private/trans_imp.idx @@ -0,0 +1,2 @@ +nimTitle trans_imp pylib/private/trans_imp.html module src/pylib/private/trans_imp 0 +nim impExp pylib/private/trans_imp.html#impExp.m,,varargs[untyped] macro impExp(pre; mods: varargs[untyped]) 4 diff --git a/pylib/pybool.html b/pylib/pybool.html new file mode 100644 index 000000000..7011fabac --- /dev/null +++ b/pylib/pybool.html @@ -0,0 +1,553 @@ + + + + + + + +src/pylib/pybool + + + + + + + + + + + + + + + + +
+
+

src/pylib/pybool

+
+ +
+ Source   +Edit   + +
+ +

+ +
+

Types

+
+
+
PyBool = distinct bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Consts

+
+
+
False = false
+
+ + False + Source   +Edit   + +
+
+
+
True = true
+
+ + True + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
func `$`(self: PyBool): string {....raises: [], tags: [], forbids: [].}
+
+ +

alias for repr

+

NOTE: CPython's bool's __str__ is itself not defined, which is inherted from object, which will call obj.__repr__ as fallback. This minics it.

+ + Source   +Edit   + +
+
+ +
+
+
+
func `==`(b: bool; self: PyBool): PyBool {.borrow, ...raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func `==`(self: PyBool; b: bool): PyBool {.borrow, ...raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func `==`(self: PyBool; opyb: PyBool): PyBool {.borrow, ...raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func all[T](iter: Iterable[T]): PyBool
+
+ + Checks if all values in iterable are truthy + Source   +Edit   + +
+
+ +
+
+
+
func `and`(b: bool; self: PyBool): PyBool {.borrow, ...raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func `and`(self: PyBool; b: bool): PyBool {.borrow, ...raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func `and`(self: PyBool; opyb: PyBool): PyBool {.borrow, ...raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func `and`[T](nself, npyb: T): T
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func any[T](iter: Iterable[T]): PyBool
+
+ + Checks if at least one value in iterable is truthy + Source   +Edit   + +
+
+ +
+
+
+
proc bool[T](arg: T): PyBool
+
+ + Alias for pybool + Source   +Edit   + +
+
+ +
+
+
+
func `is`(self: PyBool; opyb: PyBool): PyBool {.borrow, ...raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func `not`(self: PyBool): PyBool {.borrow, ...raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func `not`[T](nself: T): PyBool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func `or`(b: bool; self: PyBool): PyBool {.borrow, ...raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func `or`(self: PyBool; b: bool): PyBool {.borrow, ...raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func `or`(self: PyBool; opyb: PyBool): PyBool {.borrow, ...raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func `or`[T](nself, npyb: T): T
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func repr(self: PyBool): string {....raises: [], tags: [], forbids: [].}
+
+ + Returns "True" or "False" + Source   +Edit   + +
+
+ +
+
+
+
func `xor`(self: PyBool; opyb: PyBool): PyBool {.borrow, ...raises: [], tags: [],
+    forbids: [].}
+
+ + EXT + Source   +Edit   + +
+
+ +
+ +
+
+
+

Converters

+
+
+
+
converter pybool(x: bool): PyBool {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
converter pybool[T](x: T): PyBool
+
+ +

Converts any to PyBool

+

NOTE: In Nim, "implicit converter chain is not support". (See manual.html). Therefore any type can be implicitly converted to PyBool, not bool, which, however, is desired, as if any is convertible to bool, then there'll be ## compile-error for repr(<list>)

+ + Source   +Edit   + +
+
+ +
+
+
+
converter toNimBool(self: PyBool): bool {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template toBool[T](arg: T): bool
+
+ + Converts argument to boolean, checking python-like truthiness. + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/pybool.idx b/pylib/pybool.idx new file mode 100644 index 000000000..e3c2cd499 --- /dev/null +++ b/pylib/pybool.idx @@ -0,0 +1,33 @@ +nimTitle pybool pylib/pybool.html module src/pylib/pybool 0 +nim PyBool pylib/pybool.html#PyBool type PyBool 7 +nim True pylib/pybool.html#True const True 10 +nim False pylib/pybool.html#False const False 11 +nim `==` pylib/pybool.html#==,, proc `==`(self: PyBool; opyb: PyBool): PyBool 15 +nim `==` pylib/pybool.html#==,,bool proc `==`(self: PyBool; b: bool): PyBool 16 +nim `==` pylib/pybool.html#==,bool, proc `==`(b: bool; self: PyBool): PyBool 18 +nim `is` pylib/pybool.html#is,, proc `is`(self: PyBool; opyb: PyBool): PyBool 19 +nim `xor` pylib/pybool.html#xor,, proc `xor`(self: PyBool; opyb: PyBool): PyBool 20 +nim `not` pylib/pybool.html#not proc `not`(self: PyBool): PyBool 21 +nim `and` pylib/pybool.html#and,, proc `and`(self: PyBool; opyb: PyBool): PyBool 15 +nim `and` pylib/pybool.html#and,,bool proc `and`(self: PyBool; b: bool): PyBool 16 +nim `and` pylib/pybool.html#and,bool, proc `and`(b: bool; self: PyBool): PyBool 22 +nim `or` pylib/pybool.html#or,, proc `or`(self: PyBool; opyb: PyBool): PyBool 15 +nim `or` pylib/pybool.html#or,,bool proc `or`(self: PyBool; b: bool): PyBool 16 +nim `or` pylib/pybool.html#or,bool, proc `or`(b: bool; self: PyBool): PyBool 23 +nim repr pylib/pybool.html#repr proc repr(self: PyBool): string 25 +nim `$` pylib/pybool.html#$ proc `$`(self: PyBool): string 30 +nim toBool pylib/pybool.html#toBool.t,T template toBool[T](arg: T): bool 62 +nim toNimBool pylib/pybool.html#toNimBool.c converter toNimBool(self: PyBool): bool 92 +nim pybool pylib/pybool.html#pybool.c,bool converter pybool(x: bool): PyBool 93 +nim pybool pylib/pybool.html#pybool.c,T converter pybool[T](x: T): PyBool 94 +nim `not` pylib/pybool.html#not,T proc `not`[T](nself: T): PyBool 104 +nim `and` pylib/pybool.html#and,T,T proc `and`[T](nself, npyb: T): T 105 +nim `or` pylib/pybool.html#or,T,T proc `or`[T](nself, npyb: T): T 107 +nim bool pylib/pybool.html#bool,T proc bool[T](arg: T): PyBool 110 +nim all pylib/pybool.html#all,Iterable[T] proc all[T](iter: Iterable[T]): PyBool 112 +nim any pylib/pybool.html#any,Iterable[T] proc any[T](iter: Iterable[T]): PyBool 119 +nimgrp == pylib/pybool.html#==-procs-all proc 18 +nimgrp and pylib/pybool.html#and-procs-all proc 22 +nimgrp not pylib/pybool.html#not-procs-all proc 21 +nimgrp or pylib/pybool.html#or-procs-all proc 23 +nimgrp pybool pylib/pybool.html#pybool-converters-all converter 93 diff --git a/pylib/pybytearray.html b/pylib/pybytearray.html new file mode 100644 index 000000000..336b714b8 --- /dev/null +++ b/pylib/pybytearray.html @@ -0,0 +1,843 @@ + + + + + + + +src/pylib/pybytearray + + + + + + + + + + + + + + + + +
+
+

src/pylib/pybytearray

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Types

+
+
+
BytesLike = PyByteArray | PyBytes
+
+ + + Source   +Edit   + +
+
+
+
PyByteArray = ref object
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
func `$`(self: PyByteArray): string {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func `*=`(mself: PyByteArray; n: int) {....raises: [], tags: [], forbids: [].}
+
+ +

bytearray.__imul__

+

Python: if n < 1: self.clear()

+ + Source   +Edit   + +
+
+ +
+
+
+
func `+=`(mself: PyByteArray; other: BytesLike)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func `<`(self: PyByteArray; other: PyByteArray): bool {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func `<`(self: PyByteArray; other: PyBytes): bool {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func `<=`(self: PyByteArray; other: PyByteArray): bool {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func `<=`(self: PyByteArray; other: PyBytes): bool {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func `==`(self: PyByteArray; other: PyByteArray): bool {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func `==`(self: PyByteArray; other: PyBytes): bool {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func `[]`(self: PyByteArray; i: HSlice[int, BackwardsIndex]): PyByteArray {.
+    ...raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func `[]`(self: PyByteArray; i: Slice[int]): PyByteArray {....raises: [], tags: [],
+    forbids: [].}
+
+ + EXT. s[1..2] means s[1:3], and the latter is not valid Nim code + Source   +Edit   + +
+
+ +
+
+
+
func `[]=`(ms: var PyByteArray; indices: Slice[int]; o: Sequence[int])
+
+ + + Source   +Edit   + +
+
+
+
func `[]=`(mself: PyByteArray; i: HSlice[int, BackwardsIndex]; val: BytesLike)
+
+ + + Source   +Edit   + +
+
+
+
func `[]=`(mself: PyByteArray; i: int; val: int) {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func `[]=`(mself: PyByteArray; i: Slice[int]; val: BytesLike)
+
+ + EXT. s[1..2] means s[1:3], and the latter is not valid Nim code + Source   +Edit   + +
+
+ +
+
+
+
func append(mself: PyByteArray; val: int) {....raises: [ValueError], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func bytearray(): PyByteArray {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func bytearray(it: Iterable[char]): PyByteArray
+
+ + EXT. + Source   +Edit   + +
+
+
+
func bytearray(it: Iterable[int]): PyByteArray
+
+ + + Source   +Edit   + +
+
+
+
func bytearray(nbytes: int): PyByteArray {....raises: [ValueError], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func bytearray(o: BytesLike): PyByteArray
+
+ + + Source   +Edit   + +
+
+
+
func bytearray(s: string): PyByteArray {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func bytes(self: sink PyByteArray): PyBytes {.inline, ...raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func clear(mself: PyByteArray) {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func copy(self: PyByteArray): PyByteArray {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func delitem(ms: var PyByteArray; indices: PySlice) {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func delitem(ms: var PyByteArray; indices: Slice[int]) {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func delitem(mself: PyByteArray; i: int) {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func extend(mself: PyByteArray; other: BytesLike)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func getChar(self: PyByteArray; i: Natural): char {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func getCharPtr(self: PyByteArray; i: Natural | Natural): ptr char
+
+ + EXT. unstable. used by Lib/array frombytes and tobytes. + Source   +Edit   + +
+
+ +
+
+
+
func insert(mself: PyByteArray; i: int; val: int) {....raises: [ValueError],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func len(self: PyByteArray): int {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func newPyByteArray(): PyByteArray {.inline, ...raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func newPyByteArray(len: int): PyByteArray {.inline, ...raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func newPyByteArray(s: sink string): PyByteArray {.inline, ...raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func pop(mself: PyByteArray): int {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func remove(mself: PyByteArray; val: int) {....raises: [ValueError], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func reverse(mself: PyByteArray) {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func toNimString(self: PyByteArray): string {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func toNimString(self: var PyByteArray): var string {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Iterators

+
+
+
+
iterator chars(self: PyByteArray): char {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
iterator items(self: PyByteArray): int {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Converters

+
+
+
+
converter toPyBytes(self: PyByteArray): PyBytes {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ + +
+
+ + +
+
+ + + diff --git a/pylib/pybytearray.idx b/pylib/pybytearray.idx new file mode 100644 index 000000000..9e4d3e1f4 --- /dev/null +++ b/pylib/pybytearray.idx @@ -0,0 +1,56 @@ +nimTitle pybytearray pylib/pybytearray.html module src/pylib/pybytearray 0 +nim PyByteArray pylib/pybytearray.html#PyByteArray type PyByteArray 9 +nim BytesLike pylib/pybytearray.html#BytesLike type BytesLike 11 +nim newPyByteArray pylib/pybytearray.html#newPyByteArray proc newPyByteArray(): PyByteArray 16 +nim newPyByteArray pylib/pybytearray.html#newPyByteArray,sinkstring proc newPyByteArray(s: sink string): PyByteArray 17 +nim newPyByteArray pylib/pybytearray.html#newPyByteArray,int proc newPyByteArray(len: int): PyByteArray 18 +nim bytes pylib/pybytearray.html#bytes,sinkPyByteArray proc bytes(self: sink PyByteArray): PyBytes 20 +nim toPyBytes pylib/pybytearray.html#toPyBytes.c converter toPyBytes(self: PyByteArray): PyBytes 25 +nim getCharPtr pylib/pybytearray.html#getCharPtr,,_2 proc getCharPtr(self: PyByteArray; i: Natural | Natural): ptr char 28 +nim `==` pylib/pybytearray.html#==,,PyBytes_2 proc `==`(self: PyByteArray; other: PyBytes): bool 37 +nim `==` pylib/pybytearray.html#==,,PyByteArray proc `==`(self: PyByteArray; other: PyByteArray): bool 40 +nim `<=` pylib/pybytearray.html#<=,,PyBytes proc `<=`(self: PyByteArray; other: PyBytes): bool 37 +nim `<=` pylib/pybytearray.html#<=,,PyByteArray proc `<=`(self: PyByteArray; other: PyByteArray): bool 41 +nim `<` pylib/pybytearray.html#<,,PyBytes proc `<`(self: PyByteArray; other: PyBytes): bool 37 +nim `<` pylib/pybytearray.html#<,,PyByteArray proc `<`(self: PyByteArray; other: PyByteArray): bool 42 +nim `$` pylib/pybytearray.html#$_2 proc `$`(self: PyByteArray): string 44 +nim toNimString pylib/pybytearray.html#toNimString,PyByteArray proc toNimString(self: PyByteArray): string 45 +nim toNimString pylib/pybytearray.html#toNimString,PyByteArray_2 proc toNimString(self: var PyByteArray): var string 46 +nim bytearray pylib/pybytearray.html#bytearray proc bytearray(): PyByteArray 48 +nim bytearray pylib/pybytearray.html#bytearray,BytesLike proc bytearray(o: BytesLike): PyByteArray 49 +nim bytearray pylib/pybytearray.html#bytearray,string proc bytearray(s: string): PyByteArray 50 +nim bytearray pylib/pybytearray.html#bytearray,int proc bytearray(nbytes: int): PyByteArray 52 +nim bytearray pylib/pybytearray.html#bytearray,Iterable[char] proc bytearray(it: Iterable[char]): PyByteArray 57 +nim bytearray pylib/pybytearray.html#bytearray,Iterable[int] proc bytearray(it: Iterable[int]): PyByteArray 63 +nim chars pylib/pybytearray.html#chars.i_2 iterator chars(self: PyByteArray): char 69 +nim items pylib/pybytearray.html#items.i_2 iterator items(self: PyByteArray): int 73 +nim len pylib/pybytearray.html#len_2 proc len(self: PyByteArray): int 77 +nim `[]=` pylib/pybytearray.html#[]=,,int,int proc `[]=`(mself: PyByteArray; i: int; val: int) 90 +nim getChar pylib/pybytearray.html#getChar,,Natural_2 proc getChar(self: PyByteArray; i: Natural): char 93 +nim `[]` pylib/pybytearray.html#[],,Slice[int]_2 proc `[]`(self: PyByteArray; i: Slice[int]): PyByteArray 94 +nim `[]` pylib/pybytearray.html#[],,HSlice[int,BackwardsIndex]_2 proc `[]`(self: PyByteArray; i: HSlice[int, BackwardsIndex]): PyByteArray 101 +nim `[]=` pylib/pybytearray.html#[]=,,Slice[int],BytesLike proc `[]=`(mself: PyByteArray; i: Slice[int]; val: BytesLike) 104 +nim `[]=` pylib/pybytearray.html#[]=,,HSlice[int,BackwardsIndex],BytesLike proc `[]=`(mself: PyByteArray; i: HSlice[int, BackwardsIndex]; val: BytesLike) 111 +nim append pylib/pybytearray.html#append,,int proc append(mself: PyByteArray; val: int) 114 +nim extend pylib/pybytearray.html#extend,,BytesLike proc extend(mself: PyByteArray; other: BytesLike) 115 +nim `+=` pylib/pybytearray.html#+=,,BytesLike proc `+=`(mself: PyByteArray; other: BytesLike) 116 +nim copy pylib/pybytearray.html#copy proc copy(self: PyByteArray): PyByteArray 119 +nim insert pylib/pybytearray.html#insert,,int,int proc insert(mself: PyByteArray; i: int; val: int) 123 +nim pop pylib/pybytearray.html#pop proc pop(mself: PyByteArray): int 127 +nim remove pylib/pybytearray.html#remove,,int proc remove(mself: PyByteArray; val: int) 132 +nim delitem pylib/pybytearray.html#delitem,,int proc delitem(mself: PyByteArray; i: int) 138 +nim clear pylib/pybytearray.html#clear proc clear(mself: PyByteArray) 142 +nim `*=` pylib/pybytearray.html#*=,,int proc `*=`(mself: PyByteArray; n: int) 144 +nim reverse pylib/pybytearray.html#reverse proc reverse(mself: PyByteArray) 156 +nim delitem pylib/pybytearray.html#delitem,PyByteArray,Slice[int] proc delitem(ms: var PyByteArray; indices: Slice[int]) 13 +nim delitem pylib/pybytearray.html#delitem,PyByteArray,PySlice proc delitem(ms: var PyByteArray; indices: PySlice) 161 +nim `[]=` pylib/pybytearray.html#[]=,PyByteArray,Slice[int],Sequence[int] proc `[]=`(ms: var PyByteArray; indices: Slice[int]; o: Sequence[int]) 162 +nimgrp delitem pylib/pybytearray.html#delitem-procs-all proc 138 +nimgrp == pylib/pybytearray.html#==-procs-all proc 40 +nimgrp bytearray pylib/pybytearray.html#bytearray-procs-all proc 48 +nimgrp []= pylib/pybytearray.html#[]=-procs-all proc 90 +nimgrp [] pylib/pybytearray.html#[]-procs-all proc 94 +nimgrp <= pylib/pybytearray.html#<=-procs-all proc 41 +nimgrp < pylib/pybytearray.html#<-procs-all proc 42 +nimgrp newpybytearray pylib/pybytearray.html#newPyByteArray-procs-all proc 16 +nimgrp tonimstring pylib/pybytearray.html#toNimString-procs-all proc 45 diff --git a/pylib/pybytes.html b/pylib/pybytes.html new file mode 100644 index 000000000..66c1b2f18 --- /dev/null +++ b/pylib/pybytes.html @@ -0,0 +1,96 @@ + + + + + + + +src/pylib/pybytes + + + + + + + + + + + + + + + + + + + + diff --git a/pylib/pybytes.idx b/pylib/pybytes.idx new file mode 100644 index 000000000..8ddd2bc7a --- /dev/null +++ b/pylib/pybytes.idx @@ -0,0 +1 @@ +nimTitle pybytes pylib/pybytes.html module src/pylib/pybytes 0 diff --git a/pylib/pybytes/bytesbltins.html b/pylib/pybytes/bytesbltins.html new file mode 100644 index 000000000..bb19f67be --- /dev/null +++ b/pylib/pybytes/bytesbltins.html @@ -0,0 +1,154 @@ + + + + + + + +src/pylib/pybytes/bytesbltins + + + + + + + + + + + + + + + + +
+
+

src/pylib/pybytes/bytesbltins

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
proc ord(a: PyBytes): int {....raises: [TypeError], tags: [], forbids: [].}
+
+ + Raises TypeError if len(a) is not 1. + Source   +Edit   + +
+
+ +
+
+
+
func repr(x: PyBytes): string {....raises: [], tags: [], forbids: [].}
+
+ +

Overwites system.repr for PyBytes

+

minics Python's

+ + Source   +Edit   + +
+
+ +
+
+
+
func reversed(s: PyBytes): PyBytes {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/pybytes/bytesbltins.idx b/pylib/pybytes/bytesbltins.idx new file mode 100644 index 000000000..bdaf715b8 --- /dev/null +++ b/pylib/pybytes/bytesbltins.idx @@ -0,0 +1,4 @@ +nimTitle bytesbltins pylib/pybytes/bytesbltins.html module src/pylib/pybytes/bytesbltins 0 +nim reversed pylib/pybytes/bytesbltins.html#reversed,PyBytes proc reversed(s: PyBytes): PyBytes 7 +nim ord pylib/pybytes/bytesbltins.html#ord,PyBytes proc ord(a: PyBytes): int 10 +nim repr pylib/pybytes/bytesbltins.html#repr,PyBytes proc repr(x: PyBytes): string 20 diff --git a/pylib/pybytes/bytesimpl.html b/pylib/pybytes/bytesimpl.html new file mode 100644 index 000000000..92ffbc6c7 --- /dev/null +++ b/pylib/pybytes/bytesimpl.html @@ -0,0 +1,697 @@ + + + + + + + +src/pylib/pybytes/bytesimpl + + + + + + + + + + + + + + + + +
+
+

src/pylib/pybytes/bytesimpl

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Types

+
+
+
PyBytes = distinct string
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
func `$`(self: PyBytes): string {.borrow, ...raises: [], tags: [], forbids: [].}
+
+ + to Nim string + Source   +Edit   + +
+
+ +
+
+
+
func `+`(o: char; self: PyBytes): PyBytes {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func `+`(o: string; self: PyBytes): PyBytes {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func `+`(self: PyBytes; o: char): PyBytes {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func `+`(self: PyBytes; o: PyBytes): PyBytes {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func `+`(self: PyBytes; o: string): PyBytes {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func `+=`(mself; s: char) {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func `+=`(mself; s: PyBytes) {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func `+=`(mself; s: string) {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func `==`(self: PyBytes; o: PyBytes): bool {.borrow, ...raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func `@`(self: PyBytes): seq[char] {....raises: [], tags: [], forbids: [].}
+
+ +

EXT.

+

Python has no concept of seq (though has list)

+ + Source   +Edit   + +
+
+ +
+
+
+
func `[]`(self: PyBytes; i: HSlice[int, BackwardsIndex]): PyBytes {....raises: [],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func `[]`(self: PyBytes; i: int): int {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func `[]`(self: PyBytes; i: Slice[int]): PyBytes {....raises: [], tags: [],
+    forbids: [].}
+
+ + EXT. s[1..2] means s[1:3], and the latter is not valid Nim code + Source   +Edit   + +
+
+ +
+
+
+
func byteLen(self: PyBytes): int {....raises: [], tags: [], forbids: [].}
+
+ + EXT. the same as len(self) + Source   +Edit   + +
+
+ +
+
+
+
func bytes(): PyBytes {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func bytes(c: char): PyBytes {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func bytes(nLen: int): PyBytes {....raises: [], tags: [], forbids: [].}
+
+ + null bytes of length nLen (a.k.a. b'\0'*nLen) + Source   +Edit   + +
+
+
+
func bytes(s: openArray[char | uint8]): PyBytes
+
+ +

EXT.

+

Python has no concept of openArray

+ + Source   +Edit   + +
+
+
+
func bytes(s: sink string): PyBytes {.inline, ...raises: [], tags: [], forbids: [].}
+
+ + XXX: Currently no encode and errors params + Source   +Edit   + +
+
+
+
func bytes(self: PyBytes): PyBytes {....raises: [], tags: [], forbids: [].}
+
+ + copy + Source   +Edit   + +
+
+
+
func bytes(x: Iterable[char]): PyBytes
+
+ + EXT. as Python has no char type. + Source   +Edit   + +
+
+
+
func bytes(x: Iterable[SomeInteger]): PyBytes
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func fspath(self: PyBytes): PyBytes {....raises: [], tags: [], forbids: [].}
+
+ + make a PathLike + Source   +Edit   + +
+
+ +
+
+
+
func getChar(self: PyBytes; i: Natural): char {....raises: [], tags: [],
+    forbids: [].}
+
+ + EXT. + Source   +Edit   + +
+
+ +
+
+
+
func getCharPtr(self: PyBytes; i: Natural | BackwardsIndex): ptr char
+
+ + EXT. unstable. used by Lib/array frombytes and tobytes + Source   +Edit   + +
+
+ +
+
+
+
func hasChar(a: PyBytes; o: char): bool {....raises: [], tags: [], forbids: [].}
+
+ + EXT. 'c' in b"asc" is allowed + Source   +Edit   + +
+
+ +
+
+
+
func len(self: PyBytes): int {.borrow, ...raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc substr(self: PyBytes; start, last: int): PyBytes {.borrow, ...raises: [],
+    tags: [], forbids: [].}
+
+ + EXT. byte index + Source   +Edit   + +
+
+
+
proc substr(self: PyBytes; start: int): PyBytes {.borrow, ...raises: [], tags: [],
+    forbids: [].}
+
+ + EXT. byte index + Source   +Edit   + +
+
+ +
+ +
+
+
+

Iterators

+
+
+
+
iterator chars(self: PyBytes): char {....raises: [], tags: [], forbids: [].}
+
+ + EXT. + Source   +Edit   + +
+
+ +
+
+
+
iterator items(self: PyBytes): int {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Converters

+
+
+
+
converter toNimString(self: PyBytes): string {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template `not`(s: PyBytes): bool
+
+ + +

Mimics Python not str -> bool.

"not" for strings, return true if the string is not nil or empty.

+ + Source   +Edit   + +
+
+ +
+
+
+
template `or`(a, b: PyBytes): PyBytes
+
+ + Mimics Python str or str -> str. Returns a if a is not empty, otherwise b (even if it's empty) + Source   +Edit   + +
+
+ +
+
+
+
template pybytes[T](x: T): PyBytes
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/pybytes/bytesimpl.idx b/pylib/pybytes/bytesimpl.idx new file mode 100644 index 000000000..c96c9bf28 --- /dev/null +++ b/pylib/pybytes/bytesimpl.idx @@ -0,0 +1,44 @@ +nimTitle bytesimpl pylib/pybytes/bytesimpl.html module src/pylib/pybytes/bytesimpl 0 +nim PyBytes pylib/pybytes/bytesimpl.html#PyBytes type PyBytes 6 +nim bytes pylib/pybytes/bytesimpl.html#bytes proc bytes(): PyBytes 8 +nim bytes pylib/pybytes/bytesimpl.html#bytes,sinkstring proc bytes(s: sink string): PyBytes 9 +nim bytes pylib/pybytes/bytesimpl.html#bytes,openArray[] proc bytes(s: openArray[char | uint8]): PyBytes 12 +nim bytes pylib/pybytes/bytesimpl.html#bytes,char proc bytes(c: char): PyBytes 21 +nim bytes pylib/pybytes/bytesimpl.html#bytes,int proc bytes(nLen: int): PyBytes 23 +nim getCharPtr pylib/pybytes/bytesimpl.html#getCharPtr,, proc getCharPtr(self: PyBytes; i: Natural | BackwardsIndex): ptr char 31 +nim bytes pylib/pybytes/bytesimpl.html#bytes,Iterable[SomeInteger] proc bytes(x: Iterable[SomeInteger]): PyBytes 40 +nim bytes pylib/pybytes/bytesimpl.html#bytes,Iterable[char] proc bytes(x: Iterable[char]): PyBytes 44 +nim bytes pylib/pybytes/bytesimpl.html#bytes_2 proc bytes(self: PyBytes): PyBytes 49 +nim pybytes pylib/pybytes/bytesimpl.html#pybytes.t,T template pybytes[T](x: T): PyBytes 51 +nim `$` pylib/pybytes/bytesimpl.html#$ proc `$`(self: PyBytes): string 55 +nim fspath pylib/pybytes/bytesimpl.html#fspath proc fspath(self: PyBytes): PyBytes 56 +nim toNimString pylib/pybytes/bytesimpl.html#toNimString.c converter toNimString(self: PyBytes): string 57 +nim `==` pylib/pybytes/bytesimpl.html#==,,PyBytes proc `==`(self: PyBytes; o: PyBytes): bool 61 +nim `+` pylib/pybytes/bytesimpl.html#+,,PyBytes proc `+`(self: PyBytes; o: PyBytes): PyBytes 67 +nim `+` pylib/pybytes/bytesimpl.html#+,,string proc `+`(self: PyBytes; o: string): PyBytes 68 +nim `+` pylib/pybytes/bytesimpl.html#+,,char proc `+`(self: PyBytes; o: char): PyBytes 69 +nim `+` pylib/pybytes/bytesimpl.html#+,string, proc `+`(o: string; self: PyBytes): PyBytes 71 +nim `+` pylib/pybytes/bytesimpl.html#+,char, proc `+`(o: char; self: PyBytes): PyBytes 72 +nim `+=` pylib/pybytes/bytesimpl.html#+=,,PyBytes proc `+=`(mself; s: PyBytes) 74 +nim `+=` pylib/pybytes/bytesimpl.html#+=,,char proc `+=`(mself; s: char) 75 +nim `+=` pylib/pybytes/bytesimpl.html#+=,,string proc `+=`(mself; s: string) 76 +nim len pylib/pybytes/bytesimpl.html#len proc len(self: PyBytes): int 79 +nim byteLen pylib/pybytes/bytesimpl.html#byteLen proc byteLen(self: PyBytes): int 80 +nim substr pylib/pybytes/bytesimpl.html#substr,,int,int proc substr(self: PyBytes; start, last: int): PyBytes 82 +nim substr pylib/pybytes/bytesimpl.html#substr,,int proc substr(self: PyBytes; start: int): PyBytes 83 +nim getChar pylib/pybytes/bytesimpl.html#getChar,,Natural proc getChar(self: PyBytes; i: Natural): char 85 +nim hasChar pylib/pybytes/bytesimpl.html#hasChar,PyBytes,char proc hasChar(a: PyBytes; o: char): bool 87 +nim `[]` pylib/pybytes/bytesimpl.html#[],,int proc `[]`(self: PyBytes; i: int): int 90 +nim `[]` pylib/pybytes/bytesimpl.html#[],,Slice[int] proc `[]`(self: PyBytes; i: Slice[int]): PyBytes 94 +nim `[]` pylib/pybytes/bytesimpl.html#[],,HSlice[int,BackwardsIndex] proc `[]`(self: PyBytes; i: HSlice[int, BackwardsIndex]): PyBytes 100 +nim chars pylib/pybytes/bytesimpl.html#chars.i iterator chars(self: PyBytes): char 103 +nim items pylib/pybytes/bytesimpl.html#items.i iterator items(self: PyBytes): int 108 +nim `@` pylib/pybytes/bytesimpl.html#@,PyBytes proc `@`(self: PyBytes): seq[char] 112 +nim `or` pylib/pybytes/bytesimpl.html#or.t,PyBytes,PyBytes template `or`(a, b: PyBytes): PyBytes 126 +nim `not` pylib/pybytes/bytesimpl.html#not.t,PyBytes template `not`(s: PyBytes): bool 131 +nimgrp + pylib/pybytes/bytesimpl.html#+-procs-all proc 67 +nimgrp bytes pylib/pybytes/bytesimpl.html#bytes-procs-all proc 8 +nimgrp [] pylib/pybytes/bytesimpl.html#[]-procs-all proc 90 +nimgrp += pylib/pybytes/bytesimpl.html#+=-procs-all proc 74 +nimgrp substr pylib/pybytes/bytesimpl.html#substr-procs-all proc 82 +heading Mimics Python not str -> bool. pylib/pybytes/bytesimpl.html#mimics-python-not-str-minusgt-booldot Mimics Python not str -> bool. 0 diff --git a/pylib/pybytes/bytesmeth.html b/pylib/pybytes/bytesmeth.html new file mode 100644 index 000000000..f0aef6982 --- /dev/null +++ b/pylib/pybytes/bytesmeth.html @@ -0,0 +1,954 @@ + + + + + + + +src/pylib/pybytes/bytesmeth + + + + + + + + + + + + + + + + +
+
+

src/pylib/pybytes/bytesmeth

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
func capitalize(a: PyBytes): PyBytes {....raises: [], tags: [], forbids: [].}
+
+ + make the first character have upper case and the rest lower case. + Source   +Edit   + +
+
+ +
+
+
+
func center(a: PyBytes; width: int; fillchar = ' '): PyBytes {....raises: [],
+    tags: [], forbids: [].}
+
+ + Mimics Python bytes.center(width: int, fillchar = b" ") -> bytes + Source   +Edit   + +
+
+
+
func center(a: PyBytes; width: int; fillchar: PyBytes): PyBytes {.
+    ...raises: [TypeError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func contains(a: PyBytes; o: int): bool {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func contains(a: PyBytes; o: PyBytes): bool {.borrow, ...raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func count(a: PyBytes; sub: int): int {....raises: [ValueError], tags: [],
+                                        forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func count(a: PyBytes; sub: int; start = 0; end: int): int {.
+    ...raises: [ValueError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func count(a: PyBytes; sub: int; start: int): int {....raises: [ValueError],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func count(a: PyBytes; sub: PyBytes): int {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func count(a: PyBytes; sub: PyBytes; start = 0; end: int): int {....raises: [],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func count(a: PyBytes; sub: PyBytes; start: int): int {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func endsWith(a: PyBytes; suffix: char): bool {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func endsWith(a: PyBytes; suffix: int): bool {....raises: [ValueError], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func endsWith[Suf: PyBytes | tuple](a: PyBytes; suffix: Suf; start, end: int): bool
+
+ + + Source   +Edit   + +
+
+
+
func endsWith[Suf: PyBytes | tuple](a: PyBytes; suffix: Suf; start: int): bool
+
+ + + Source   +Edit   + +
+
+
+
func endsWith[Tup: tuple](a: PyBytes; suffix: Tup): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func expandtabs(a: PyBytes; tabsize = 8): PyBytes {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func find(a: PyBytes; b: int; start = 0; end = len(a)): int {....raises: [],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func find(a: PyBytes; b: PyBytes; start = 0; end = len(a)): int {....raises: [],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func index(a: PyBytes; b: int; start = 0; end = len(a)): int {.
+    ...raises: [ValueError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func index(a: PyBytes; b: PyBytes; start = 0; end = len(a)): int {.
+    ...raises: [Exception], tags: [RootEffect], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func isalpha(a`gensym42: PyBytes): bool {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func isascii(a: PyBytes): bool {....raises: [], tags: [], forbids: [].}
+
+ +
Admonition: +since Python 3.7
+ + Source   +Edit   + +
+
+ +
+
+
+
func isdigit(a`gensym43: PyBytes): bool {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func islower(a: PyBytes): bool {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func isspace(a`gensym41: PyBytes): bool {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func istitle(a: PyBytes): bool {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func isupper(a: PyBytes): bool {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func join[T](sep: PyBytes; a: openArray[T]): PyBytes
+
+ + Mimics Python join() -> bytes + Source   +Edit   + +
+
+ +
+
+
+
func ljust(a: PyBytes; width: int; fillchar = ' '): PyBytes {....raises: [],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func ljust(a: PyBytes; width: int; fillchar: PyBytes): PyBytes {.
+    ...raises: [TypeError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func lower(a: PyBytes): PyBytes {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func partition(a: PyBytes; sep: PyBytes): tuple[before, sep, after: PyBytes] {.
+    ...raises: [ValueError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func removeprefix(a: PyBytes; suffix: PyBytes): PyBytes {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func removesuffix(a: PyBytes; suffix: PyBytes): PyBytes {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func replace(a: PyBytes; sub, by: PyBytes | char): PyBytes
+
+ + + Source   +Edit   + +
+
+
+
func replace(a: PyBytes; sub, by: PyBytes | char; count: int): PyBytes
+
+ +

bytes.replace(sub, by, count = -1)'

+

count may be negative or zero.

+ + Source   +Edit   + +
+
+ +
+
+
+
func rfind(a: PyBytes; b: int; start = 0; end = len(a)): int {....raises: [],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func rfind(a: PyBytes; b: PyBytes; start = 0; end = len(a)): int {....raises: [],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func rindex(a: PyBytes; b: int; start = 0; end = len(a)): int {.
+    ...raises: [ValueError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func rindex(a: PyBytes; b: PyBytes; start = 0; end = len(a)): int {.
+    ...raises: [ValueError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func rjust(a: PyBytes; width: int; fillchar = ' '): PyBytes {....raises: [],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func rjust(a: PyBytes; width: int; fillchar: PyBytes): PyBytes {.
+    ...raises: [TypeError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func rpartition(a: PyBytes; sep: PyBytes): tuple[before, sep, after: PyBytes] {.
+    ...raises: [ValueError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func startsWith(a: PyBytes; suffix: char): bool {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func startsWith(a: PyBytes; suffix: int): bool {....raises: [ValueError], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func startsWith[Suf: PyBytes | tuple](a: PyBytes; suffix: Suf; start, end: int): bool
+
+ + + Source   +Edit   + +
+
+
+
func startsWith[Suf: PyBytes | tuple](a: PyBytes; suffix: Suf; start: int): bool
+
+ + + Source   +Edit   + +
+
+
+
func startsWith[Tup: tuple](a: PyBytes; suffix: Tup): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func title(a: PyBytes): PyBytes {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func upper(a: PyBytes): PyBytes {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func zfill(a: PyBytes; width: int): PyBytes {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template `*`(a: PyBytes; i: int): PyBytes
+
+ + + Source   +Edit   + +
+
+
+
template `*`(i: int; a: PyBytes): PyBytes
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template casefold(a: PyBytes): PyBytes
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ + +
+
+ + +
+
+ + + diff --git a/pylib/pybytes/bytesmeth.idx b/pylib/pybytes/bytesmeth.idx new file mode 100644 index 000000000..d8b1fc594 --- /dev/null +++ b/pylib/pybytes/bytesmeth.idx @@ -0,0 +1,69 @@ +nimTitle bytesmeth pylib/pybytes/bytesmeth.html module src/pylib/pybytes/bytesmeth 0 +nim `*` pylib/pybytes/bytesmeth.html#*.t,PyBytes,int template `*`(a: PyBytes; i: int): PyBytes 10 +nim `*` pylib/pybytes/bytesmeth.html#*.t,int,PyBytes template `*`(i: int; a: PyBytes): PyBytes 13 +nim count pylib/pybytes/bytesmeth.html#count,PyBytes,PyBytes proc count(a: PyBytes; sub: PyBytes): int 17 +nim count pylib/pybytes/bytesmeth.html#count,PyBytes,PyBytes,int proc count(a: PyBytes; sub: PyBytes; start: int): int 20 +nim count pylib/pybytes/bytesmeth.html#count,PyBytes,PyBytes,int,int proc count(a: PyBytes; sub: PyBytes; start = 0; end: int): int 23 +nim count pylib/pybytes/bytesmeth.html#count,PyBytes,int proc count(a: PyBytes; sub: int): int 30 +nim count pylib/pybytes/bytesmeth.html#count,PyBytes,int,int proc count(a: PyBytes; sub: int; start: int): int 31 +nim count pylib/pybytes/bytesmeth.html#count,PyBytes,int,int,int proc count(a: PyBytes; sub: int; start = 0; end: int): int 33 +nim casefold pylib/pybytes/bytesmeth.html#casefold.t,PyBytes template casefold(a: PyBytes): PyBytes 36 +nim lower pylib/pybytes/bytesmeth.html#lower,PyBytes proc lower(a: PyBytes): PyBytes 40 +nim upper pylib/pybytes/bytesmeth.html#upper,PyBytes proc upper(a: PyBytes): PyBytes 41 +nim title pylib/pybytes/bytesmeth.html#title,PyBytes proc title(a: PyBytes): PyBytes 59 +nim capitalize pylib/pybytes/bytesmeth.html#capitalize,PyBytes proc capitalize(a: PyBytes): PyBytes 63 +nim startsWith pylib/pybytes/bytesmeth.html#startsWith,PyBytes,char proc startsWith(a: PyBytes; suffix: char): bool 71 +nim startsWith pylib/pybytes/bytesmeth.html#startsWith,PyBytes,int proc startsWith(a: PyBytes; suffix: int): bool 73 +nim startsWith pylib/pybytes/bytesmeth.html#startsWith,PyBytes,Tup proc startsWith[Tup: tuple](a: PyBytes; suffix: Tup): bool 75 +nim startsWith pylib/pybytes/bytesmeth.html#startsWith,PyBytes,Suf,int proc startsWith[Suf: PyBytes | tuple](a: PyBytes; suffix: Suf; start: int): bool 77 +nim startsWith pylib/pybytes/bytesmeth.html#startsWith,PyBytes,Suf,int,int proc startsWith[Suf: PyBytes | tuple](a: PyBytes; suffix: Suf; start, end: int): bool 83 +nim endsWith pylib/pybytes/bytesmeth.html#endsWith,PyBytes,char proc endsWith(a: PyBytes; suffix: char): bool 71 +nim endsWith pylib/pybytes/bytesmeth.html#endsWith,PyBytes,int proc endsWith(a: PyBytes; suffix: int): bool 73 +nim endsWith pylib/pybytes/bytesmeth.html#endsWith,PyBytes,Tup proc endsWith[Tup: tuple](a: PyBytes; suffix: Tup): bool 75 +nim endsWith pylib/pybytes/bytesmeth.html#endsWith,PyBytes,Suf,int proc endsWith[Suf: PyBytes | tuple](a: PyBytes; suffix: Suf; start: int): bool 77 +nim endsWith pylib/pybytes/bytesmeth.html#endsWith,PyBytes,Suf,int,int proc endsWith[Suf: PyBytes | tuple](a: PyBytes; suffix: Suf; start, end: int): bool 84 +nim find pylib/pybytes/bytesmeth.html#find,PyBytes,int,int proc find(a: PyBytes; b: int; start = 0; end = len(a)): int 86 +nim rfind pylib/pybytes/bytesmeth.html#rfind,PyBytes,int,int proc rfind(a: PyBytes; b: int; start = 0; end = len(a)): int 89 +nim index pylib/pybytes/bytesmeth.html#index,PyBytes,int,int proc index(a: PyBytes; b: int; start = 0; end = len(a)): int 92 +nim rindex pylib/pybytes/bytesmeth.html#rindex,PyBytes,int,int proc rindex(a: PyBytes; b: int; start = 0; end = len(a)): int 95 +nim find pylib/pybytes/bytesmeth.html#find,PyBytes,PyBytes,int proc find(a: PyBytes; b: PyBytes; start = 0; end = len(a)): int 99 +nim rfind pylib/pybytes/bytesmeth.html#rfind,PyBytes,PyBytes,int proc rfind(a: PyBytes; b: PyBytes; start = 0; end = len(a)): int 102 +nim index pylib/pybytes/bytesmeth.html#index,PyBytes,PyBytes,int proc index(a: PyBytes; b: PyBytes; start = 0; end = len(a)): int 105 +nim rindex pylib/pybytes/bytesmeth.html#rindex,PyBytes,PyBytes,int proc rindex(a: PyBytes; b: PyBytes; start = 0; end = len(a)): int 108 +nim contains pylib/pybytes/bytesmeth.html#contains,PyBytes,PyBytes proc contains(a: PyBytes; o: PyBytes): bool 111 +nim contains pylib/pybytes/bytesmeth.html#contains,PyBytes,int proc contains(a: PyBytes; o: int): bool 112 +nim isascii pylib/pybytes/bytesmeth.html#isascii,PyBytes proc isascii(a: PyBytes): bool 117 +nim isspace pylib/pybytes/bytesmeth.html#isspace,PyBytes proc isspace(a`gensym41: PyBytes): bool 118 +nim isalpha pylib/pybytes/bytesmeth.html#isalpha,PyBytes proc isalpha(a`gensym42: PyBytes): bool 119 +nim isdigit pylib/pybytes/bytesmeth.html#isdigit,PyBytes proc isdigit(a`gensym43: PyBytes): bool 120 +nim islower pylib/pybytes/bytesmeth.html#islower,PyBytes proc islower(a: PyBytes): bool 125 +nim isupper pylib/pybytes/bytesmeth.html#isupper,PyBytes proc isupper(a: PyBytes): bool 126 +nim istitle pylib/pybytes/bytesmeth.html#istitle,PyBytes proc istitle(a: PyBytes): bool 127 +nim center pylib/pybytes/bytesmeth.html#center,PyBytes,int,char proc center(a: PyBytes; width: int; fillchar = ' '): PyBytes 130 +nim ljust pylib/pybytes/bytesmeth.html#ljust,PyBytes,int,char proc ljust(a: PyBytes; width: int; fillchar = ' '): PyBytes 134 +nim rjust pylib/pybytes/bytesmeth.html#rjust,PyBytes,int,char proc rjust(a: PyBytes; width: int; fillchar = ' '): PyBytes 136 +nim center pylib/pybytes/bytesmeth.html#center,PyBytes,int,PyBytes proc center(a: PyBytes; width: int; fillchar: PyBytes): PyBytes 139 +nim ljust pylib/pybytes/bytesmeth.html#ljust,PyBytes,int,PyBytes proc ljust(a: PyBytes; width: int; fillchar: PyBytes): PyBytes 142 +nim rjust pylib/pybytes/bytesmeth.html#rjust,PyBytes,int,PyBytes proc rjust(a: PyBytes; width: int; fillchar: PyBytes): PyBytes 145 +nim zfill pylib/pybytes/bytesmeth.html#zfill,PyBytes,int proc zfill(a: PyBytes; width: int): PyBytes 148 +nim removeprefix pylib/pybytes/bytesmeth.html#removeprefix,PyBytes,PyBytes proc removeprefix(a: PyBytes; suffix: PyBytes): PyBytes 151 +nim removesuffix pylib/pybytes/bytesmeth.html#removesuffix,PyBytes,PyBytes proc removesuffix(a: PyBytes; suffix: PyBytes): PyBytes 153 +nim replace pylib/pybytes/bytesmeth.html#replace,PyBytes,, proc replace(a: PyBytes; sub, by: PyBytes | char): PyBytes 156 +nim replace pylib/pybytes/bytesmeth.html#replace,PyBytes,,,int proc replace(a: PyBytes; sub, by: PyBytes | char; count: int): PyBytes 159 +nim expandtabs pylib/pybytes/bytesmeth.html#expandtabs,PyBytes,int proc expandtabs(a: PyBytes; tabsize = 8): PyBytes 165 +nim join pylib/pybytes/bytesmeth.html#join,PyBytes,openArray[T] proc join[T](sep: PyBytes; a: openArray[T]): PyBytes 168 +nim partition pylib/pybytes/bytesmeth.html#partition,PyBytes,PyBytes proc partition(a: PyBytes; sep: PyBytes): tuple[before, sep, after: PyBytes] 172 +nim rpartition pylib/pybytes/bytesmeth.html#rpartition,PyBytes,PyBytes proc rpartition(a: PyBytes; sep: PyBytes): tuple[before, sep, after: PyBytes] 175 +nimgrp rindex pylib/pybytes/bytesmeth.html#rindex-procs-all proc 95 +nimgrp rfind pylib/pybytes/bytesmeth.html#rfind-procs-all proc 89 +nimgrp replace pylib/pybytes/bytesmeth.html#replace-procs-all proc 156 +nimgrp startswith pylib/pybytes/bytesmeth.html#startsWith-procs-all proc 83 +nimgrp index pylib/pybytes/bytesmeth.html#index-procs-all proc 92 +nimgrp contains pylib/pybytes/bytesmeth.html#contains-procs-all proc 111 +nimgrp ljust pylib/pybytes/bytesmeth.html#ljust-procs-all proc 134 +nimgrp rjust pylib/pybytes/bytesmeth.html#rjust-procs-all proc 136 +nimgrp count pylib/pybytes/bytesmeth.html#count-procs-all proc 17 +nimgrp endswith pylib/pybytes/bytesmeth.html#endsWith-procs-all proc 84 +nimgrp center pylib/pybytes/bytesmeth.html#center-procs-all proc 130 +nimgrp find pylib/pybytes/bytesmeth.html#find-procs-all proc 86 +nimgrp * pylib/pybytes/bytesmeth.html#*-templates-all template 10 diff --git a/pylib/pybytes/bytesprefix.html b/pylib/pybytes/bytesprefix.html new file mode 100644 index 000000000..6e4579b50 --- /dev/null +++ b/pylib/pybytes/bytesprefix.html @@ -0,0 +1,211 @@ + + + + + + + +src/pylib/pybytes/bytesprefix + + + + + + + + + + + + + + + + +
+
+

src/pylib/pybytes/bytesprefix

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
func b(c: char{lit}): PyBytes {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func b(s: static[string]{lit}): PyBytes
+
+ + XXX: Currently \Uxxxxxxxx and \uxxxx is supported as an extension. + Source   +Edit   + +
+
+ +
+
+
+
func br(s: string{lit}): PyBytes {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template Br(s): PyBytes
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template Rb(s): PyBytes
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template rb(s): PyBytes
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/pybytes/bytesprefix.idx b/pylib/pybytes/bytesprefix.idx new file mode 100644 index 000000000..1833700f3 --- /dev/null +++ b/pylib/pybytes/bytesprefix.idx @@ -0,0 +1,8 @@ +nimTitle bytesprefix pylib/pybytes/bytesprefix.html module src/pylib/pybytes/bytesprefix 0 +nim b pylib/pybytes/bytesprefix.html#b proc b(c: char{lit}): PyBytes 5 +nim b pylib/pybytes/bytesprefix.html#b_2 proc b(s: static[string]{lit}): PyBytes 6 +nim br pylib/pybytes/bytesprefix.html#br proc br(s: string{lit}): PyBytes 13 +nim rb pylib/pybytes/bytesprefix.html#rb.t template rb(s): PyBytes 21 +nim Rb pylib/pybytes/bytesprefix.html#Rb.t_2 template Rb(s): PyBytes 22 +nim Br pylib/pybytes/bytesprefix.html#Br.t template Br(s): PyBytes 23 +nimgrp b pylib/pybytes/bytesprefix.html#b-procs-all proc 5 diff --git a/pylib/pybytes/hex.html b/pylib/pybytes/hex.html new file mode 100644 index 000000000..6744300f0 --- /dev/null +++ b/pylib/pybytes/hex.html @@ -0,0 +1,170 @@ + + + + + + + +src/pylib/pybytes/hex + + + + + + + + + + + + + + + + +
+
+

src/pylib/pybytes/hex

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
func fromhex(_: typedesc[PyBytes]; s: PyStr): PyBytes
+
+ +

bytes.fromhex(s)

+

spaces are allowed, unlike Nim's strutils.parseHexStr

+ + Source   +Edit   + +
+
+ +
+
+
+
func hex(self: PyBytes): PyStr {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func hex(self: PyBytes; sep: char | PyStr | PyBytes; bytes_per_sep: int): PyStr
+
+ + + Source   +Edit   + +
+
+
+
func hex(self: PyBytes; sep: char): PyStr {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func hex(self: PyBytes; sep: PyStr | PyBytes): PyStr
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/pybytes/hex.idx b/pylib/pybytes/hex.idx new file mode 100644 index 000000000..5ee94c36f --- /dev/null +++ b/pylib/pybytes/hex.idx @@ -0,0 +1,7 @@ +nimTitle hex pylib/pybytes/hex.html module src/pylib/pybytes/hex 0 +nim hex pylib/pybytes/hex.html#hex proc hex(self: PyBytes): PyStr 31 +nim hex pylib/pybytes/hex.html#hex,,char proc hex(self: PyBytes; sep: char): PyStr 37 +nim hex pylib/pybytes/hex.html#hex,, proc hex(self: PyBytes; sep: PyStr | PyBytes): PyStr 43 +nim hex pylib/pybytes/hex.html#hex,,,int proc hex(self: PyBytes; sep: char | PyStr | PyBytes; bytes_per_sep: int): PyStr 47 +nim fromhex pylib/pybytes/hex.html#fromhex,typedesc[PyBytes],PyStr proc fromhex(_: typedesc[PyBytes]; s: PyStr): PyBytes 59 +nimgrp hex pylib/pybytes/hex.html#hex-procs-all proc 31 diff --git a/pylib/pybytes/split/common.html b/pylib/pybytes/split/common.html new file mode 100644 index 000000000..0d899ca54 --- /dev/null +++ b/pylib/pybytes/split/common.html @@ -0,0 +1,127 @@ + + + + + + + +src/pylib/pybytes/split/common + + + + + + + + + + + + + + + + +
+
+

src/pylib/pybytes/split/common

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
func ISSPACE(s: PyBytes; pos: int): bool {....raises: [], tags: [], forbids: [].}
+
+ + Checks unicode space at unicode char's pos + Source   +Edit   + +
+
+ +
+ +
+
+ + +
+
+ + +
+
+ + + diff --git a/pylib/pybytes/split/common.idx b/pylib/pybytes/split/common.idx new file mode 100644 index 000000000..ae538712d --- /dev/null +++ b/pylib/pybytes/split/common.idx @@ -0,0 +1,2 @@ +nimTitle common pylib/pybytes/split/common.html module src/pylib/pybytes/split/common 0 +nim ISSPACE pylib/pybytes/split/common.html#ISSPACE,PyBytes,int proc ISSPACE(s: PyBytes; pos: int): bool 12 diff --git a/pylib/pybytes/split/reimporter.html b/pylib/pybytes/split/reimporter.html new file mode 100644 index 000000000..94051aa5e --- /dev/null +++ b/pylib/pybytes/split/reimporter.html @@ -0,0 +1,96 @@ + + + + + + + +src/pylib/pybytes/split/reimporter + + + + + + + + + + + + + + + + +
+
+

src/pylib/pybytes/split/reimporter

+ + + +
+
+ + + diff --git a/pylib/pybytes/split/reimporter.idx b/pylib/pybytes/split/reimporter.idx new file mode 100644 index 000000000..f2a6d43d0 --- /dev/null +++ b/pylib/pybytes/split/reimporter.idx @@ -0,0 +1 @@ +nimTitle reimporter pylib/pybytes/split/reimporter.html module src/pylib/pybytes/split/reimporter 0 diff --git a/pylib/pybytes/split/rsplit.html b/pylib/pybytes/split/rsplit.html new file mode 100644 index 000000000..d05efdbe7 --- /dev/null +++ b/pylib/pybytes/split/rsplit.html @@ -0,0 +1,164 @@ + + + + + + + +src/pylib/pybytes/split/rsplit + + + + + + + + + + + + + + + + +
+
+

src/pylib/pybytes/split/rsplit

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
proc rsplit(a: PyBytes; sep = None; maxsplit = -1): PyList[PyBytes] {.
+    ...raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc rsplit(a: PyBytes; sep: PyBytes | char; maxsplit = -1): PyList[PyBytes]
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Iterators

+
+
+
+
iterator rsplit(a: PyBytes; sep = None; maxsplit = -1): PyBytes {....raises: [],
+    tags: [], forbids: [].}
+
+ +

with unicode whitespaces as sep.

+

treat runs of whitespaces as one sep (i.e. discard empty strings from result), while Nim's unicode doesn't has rsplit yet

+ + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/pybytes/split/rsplit.idx b/pylib/pybytes/split/rsplit.idx new file mode 100644 index 000000000..60e95807d --- /dev/null +++ b/pylib/pybytes/split/rsplit.idx @@ -0,0 +1,5 @@ +nimTitle rsplit pylib/pybytes/split/rsplit.html module src/pylib/pybytes/split/rsplit 0 +nim rsplit pylib/pybytes/split/rsplit.html#rsplit.i,PyBytes,int iterator rsplit(a: PyBytes; sep = None; maxsplit = -1): PyBytes 9 +nim rsplit pylib/pybytes/split/rsplit.html#rsplit,PyBytes,int proc rsplit(a: PyBytes; sep = None; maxsplit = -1): PyList[PyBytes] 26 +nim rsplit pylib/pybytes/split/rsplit.html#rsplit,PyBytes,,int proc rsplit(a: PyBytes; sep: PyBytes | char; maxsplit = -1): PyList[PyBytes] 37 +nimgrp rsplit pylib/pybytes/split/rsplit.html#rsplit-procs-all proc 26 diff --git a/pylib/pybytes/split/rsplit_whitespace.html b/pylib/pybytes/split/rsplit_whitespace.html new file mode 100644 index 000000000..a3e83478f --- /dev/null +++ b/pylib/pybytes/split/rsplit_whitespace.html @@ -0,0 +1,119 @@ + + + + + + + +src/pylib/pybytes/split/rsplit_whitespace + + + + + + + + + + + + + + + + +
+
+

src/pylib/pybytes/split/rsplit_whitespace

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
proc rsplit_whitespace(pystr: PyBytes; maxsplit = -1): PyList[PyBytes] {.
+    ...raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/pybytes/split/rsplit_whitespace.idx b/pylib/pybytes/split/rsplit_whitespace.idx new file mode 100644 index 000000000..010d45994 --- /dev/null +++ b/pylib/pybytes/split/rsplit_whitespace.idx @@ -0,0 +1,2 @@ +nimTitle rsplit_whitespace pylib/pybytes/split/rsplit_whitespace.html module src/pylib/pybytes/split/rsplit_whitespace 0 +nim rsplit_whitespace pylib/pybytes/split/rsplit_whitespace.html#rsplit_whitespace,PyBytes,int proc rsplit_whitespace(pystr: PyBytes; maxsplit = -1): PyList[PyBytes] 5 diff --git a/pylib/pybytes/split/split.html b/pylib/pybytes/split/split.html new file mode 100644 index 000000000..bb1ca70a0 --- /dev/null +++ b/pylib/pybytes/split/split.html @@ -0,0 +1,202 @@ + + + + + + + +src/pylib/pybytes/split/split + + + + + + + + + + + + + + + + +
+
+

src/pylib/pybytes/split/split

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
proc split(a: PyBytes; sep = None; maxsplit = -1): PyList[PyBytes] {....raises: [],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc split(a: PyBytes; sep: PyBytes | char; maxsplit = -1): PyList[PyBytes]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc splitlines(self: PyBytes; keepends = false): PyList[PyBytes] {....raises: [],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Iterators

+
+
+
+
iterator split(a: PyBytes; sep = None; maxsplit = -1): PyBytes {....raises: [],
+    tags: [], forbids: [].}
+
+ +

with ASCII whitespaces as sep.

+

treat runs of whitespaces as one sep (i.e. discard empty strings from result), while Nim's unicode.split(s) doesn't

+ + Source   +Edit   + +
+
+
+
iterator split(a: PyBytes; sep: PyBytes | char; maxsplit = -1): PyBytes {.inline.}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Exports

+
+ splitlines +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/pybytes/split/split.idx b/pylib/pybytes/split/split.idx new file mode 100644 index 000000000..187dad786 --- /dev/null +++ b/pylib/pybytes/split/split.idx @@ -0,0 +1,8 @@ +nimTitle split pylib/pybytes/split/split.html module src/pylib/pybytes/split/split 0 +nim split pylib/pybytes/split/split.html#split.i,PyBytes,int iterator split(a: PyBytes; sep = None; maxsplit = -1): PyBytes 12 +nim split pylib/pybytes/split/split.html#split.i,PyBytes,,int iterator split(a: PyBytes; sep: PyBytes | char; maxsplit = -1): PyBytes 27 +nim split pylib/pybytes/split/split.html#split,PyBytes,int proc split(a: PyBytes; sep = None; maxsplit = -1): PyList[PyBytes] 32 +nim split pylib/pybytes/split/split.html#split,PyBytes,,int proc split(a: PyBytes; sep: PyBytes | char; maxsplit = -1): PyList[PyBytes] 43 +nim splitlines pylib/pybytes/split/split.html#splitlines,PyBytes proc splitlines(self: PyBytes; keepends = false): PyList[PyBytes] 52 +nimgrp split pylib/pybytes/split/split.html#split-procs-all proc 32 +nimgrp split pylib/pybytes/split/split.html#split-iterators-all iterator 12 diff --git a/pylib/pybytes/split/split_whitespace.html b/pylib/pybytes/split/split_whitespace.html new file mode 100644 index 000000000..cb93af30f --- /dev/null +++ b/pylib/pybytes/split/split_whitespace.html @@ -0,0 +1,151 @@ + + + + + + + +src/pylib/pybytes/split/split_whitespace + + + + + + + + + + + + + + + + +
+
+

src/pylib/pybytes/split/split_whitespace

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
proc split_whitespace(pystr: PyBytes; maxsplit = -1): PyList[PyBytes] {.
+    ...raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Iterators

+
+
+
+
iterator split_whitespace(pystr: PyBytes; maxsplit = -1): PyBytes {....raises: [],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/pybytes/split/split_whitespace.idx b/pylib/pybytes/split/split_whitespace.idx new file mode 100644 index 000000000..9186b4265 --- /dev/null +++ b/pylib/pybytes/split/split_whitespace.idx @@ -0,0 +1,3 @@ +nimTitle split_whitespace pylib/pybytes/split/split_whitespace.html module src/pylib/pybytes/split/split_whitespace 0 +nim split_whitespace pylib/pybytes/split/split_whitespace.html#split_whitespace.i,PyBytes,int iterator split_whitespace(pystr: PyBytes; maxsplit = -1): PyBytes 5 +nim split_whitespace pylib/pybytes/split/split_whitespace.html#split_whitespace,PyBytes,int proc split_whitespace(pystr: PyBytes; maxsplit = -1): PyList[PyBytes] 9 diff --git a/pylib/pybytes/split/splitlinesIter.html b/pylib/pybytes/split/splitlinesIter.html new file mode 100644 index 000000000..a50b07306 --- /dev/null +++ b/pylib/pybytes/split/splitlinesIter.html @@ -0,0 +1,119 @@ + + + + + + + +src/pylib/pybytes/split/splitlinesIter + + + + + + + + + + + + + + + + +
+
+

src/pylib/pybytes/split/splitlinesIter

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Iterators

+
+
+
+
iterator splitlines(self: PyBytes; keepends = false): PyBytes {....raises: [],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/pybytes/split/splitlinesIter.idx b/pylib/pybytes/split/splitlinesIter.idx new file mode 100644 index 000000000..429c6fde0 --- /dev/null +++ b/pylib/pybytes/split/splitlinesIter.idx @@ -0,0 +1,2 @@ +nimTitle splitlinesIter pylib/pybytes/split/splitlinesIter.html module src/pylib/pybytes/split/splitlinesIter 0 +nim splitlines pylib/pybytes/split/splitlinesIter.html#splitlines.i,PyBytes iterator splitlines(self: PyBytes; keepends = false): PyBytes 17 diff --git a/pylib/pybytes/strip.html b/pylib/pybytes/strip.html new file mode 100644 index 000000000..f172997b8 --- /dev/null +++ b/pylib/pybytes/strip.html @@ -0,0 +1,188 @@ + + + + + + + +src/pylib/pybytes/strip + + + + + + + + + + + + + + + + +
+
+

src/pylib/pybytes/strip

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Imports

+
+ bytesimpl +
+
+
+

Procs

+
+
+
+
func lstrip(self: PyBytes): PyBytes {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func lstrip(self: PyBytes; chars: PyBytes): PyBytes {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func rstrip(self: PyBytes): PyBytes {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func rstrip(self: PyBytes; chars: PyBytes): PyBytes {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func strip(self: PyBytes): PyBytes {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func strip(self: PyBytes; chars: PyBytes): PyBytes {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/pybytes/strip.idx b/pylib/pybytes/strip.idx new file mode 100644 index 000000000..a825d335c --- /dev/null +++ b/pylib/pybytes/strip.idx @@ -0,0 +1,10 @@ +nimTitle strip pylib/pybytes/strip.html module src/pylib/pybytes/strip 0 +nim strip pylib/pybytes/strip.html#strip,PyBytes proc strip(self: PyBytes): PyBytes 5 +nim lstrip pylib/pybytes/strip.html#lstrip,PyBytes proc lstrip(self: PyBytes): PyBytes 6 +nim rstrip pylib/pybytes/strip.html#rstrip,PyBytes proc rstrip(self: PyBytes): PyBytes 7 +nim strip pylib/pybytes/strip.html#strip,PyBytes,PyBytes proc strip(self: PyBytes; chars: PyBytes): PyBytes 12 +nim lstrip pylib/pybytes/strip.html#lstrip,PyBytes,PyBytes proc lstrip(self: PyBytes; chars: PyBytes): PyBytes 14 +nim rstrip pylib/pybytes/strip.html#rstrip,PyBytes,PyBytes proc rstrip(self: PyBytes; chars: PyBytes): PyBytes 16 +nimgrp lstrip pylib/pybytes/strip.html#lstrip-procs-all proc 6 +nimgrp strip pylib/pybytes/strip.html#strip-procs-all proc 5 +nimgrp rstrip pylib/pybytes/strip.html#rstrip-procs-all proc 7 diff --git a/pylib/pybytes/translate.html b/pylib/pybytes/translate.html new file mode 100644 index 000000000..7cc4d0f35 --- /dev/null +++ b/pylib/pybytes/translate.html @@ -0,0 +1,160 @@ + + + + + + + +src/pylib/pybytes/translate + + + + + + + + + + + + + + + + +
+
+

src/pylib/pybytes/translate

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
func maketrans(_: typedesc[PyBytes]; frm, to: PyBytes): PyBytes
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func translate(self, table, delete: PyBytes): PyBytes {....raises: [ValueError],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func translate(self, table: PyBytes): PyBytes {....raises: [ValueError], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func translate(self: PyBytes; table: NoneType; delete: PyBytes): PyBytes {.
+    ...raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/pybytes/translate.idx b/pylib/pybytes/translate.idx new file mode 100644 index 000000000..b931b1d88 --- /dev/null +++ b/pylib/pybytes/translate.idx @@ -0,0 +1,6 @@ +nimTitle translate pylib/pybytes/translate.html module src/pylib/pybytes/translate 0 +nim maketrans pylib/pybytes/translate.html#maketrans,typedesc[PyBytes],PyBytes,PyBytes proc maketrans(_: typedesc[PyBytes]; frm, to: PyBytes): PyBytes 6 +nim translate pylib/pybytes/translate.html#translate,PyBytes,PyBytes proc translate(self, table: PyBytes): PyBytes 31 +nim translate pylib/pybytes/translate.html#translate,PyBytes,PyBytes,PyBytes proc translate(self, table, delete: PyBytes): PyBytes 39 +nim translate pylib/pybytes/translate.html#translate,,NoneType,PyBytes proc translate(self: PyBytes; table: NoneType; delete: PyBytes): PyBytes 47 +nimgrp translate pylib/pybytes/translate.html#translate-procs-all proc 31 diff --git a/pylib/pyconfig/floats.html b/pylib/pyconfig/floats.html new file mode 100644 index 000000000..4a6625e7b --- /dev/null +++ b/pylib/pyconfig/floats.html @@ -0,0 +1,249 @@ + + + + + + + +src/pylib/pyconfig/floats + + + + + + + + + + + + + + + + +
+
+

src/pylib/pyconfig/floats

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

--- HAVE_PY_SET_53BIT_PRECISION macro ------------------------------------Inline assembly for getting and setting the 387 FPU control word on GCC/x86.ifdef _Py_MEMORY_SANITIZERendif

+
+

Imports

+
+ util +
+
+
+

Consts

+
+
+
DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754 = false
+
+ + + Source   +Edit   + +
+
+
+
DOUBLE_IS_BIG_ENDIAN_IEEE754 = false
+
+ + + Source   +Edit   + +
+
+
+
DOUBLE_IS_LITTLE_ENDIAN_IEEE754 = true
+
+ + + Source   +Edit   + +
+
+
+
HAVE_GCC_ASM_FOR_MC68881 = false
+
+ + + Source   +Edit   + +
+
+
+
HAVE_GCC_ASM_FOR_X87 = true
+
+ + + Source   +Edit   + +
+
+
+
X87_double_rounding = false
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Templates

+
+
+
+
template HAVE_PY_SET_53BIT_PRECISION(): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template Py_SET_53BIT_PRECISION_END()
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template Py_SET_53BIT_PRECISION_HEADER() {.dirty.}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template Py_SET_53BIT_PRECISION_START()
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/pyconfig/floats.idx b/pylib/pyconfig/floats.idx new file mode 100644 index 000000000..3478274d9 --- /dev/null +++ b/pylib/pyconfig/floats.idx @@ -0,0 +1,11 @@ +nimTitle floats pylib/pyconfig/floats.html module src/pylib/pyconfig/floats 0 +nim X87_double_rounding pylib/pyconfig/floats.html#X87_double_rounding const X87_double_rounding 50 +nim HAVE_GCC_ASM_FOR_X87 pylib/pyconfig/floats.html#HAVE_GCC_ASM_FOR_X87 const HAVE_GCC_ASM_FOR_X87 50 +nim HAVE_GCC_ASM_FOR_MC68881 pylib/pyconfig/floats.html#HAVE_GCC_ASM_FOR_MC68881 const HAVE_GCC_ASM_FOR_MC68881 50 +nim HAVE_PY_SET_53BIT_PRECISION pylib/pyconfig/floats.html#HAVE_PY_SET_53BIT_PRECISION.t template HAVE_PY_SET_53BIT_PRECISION(): bool 85 +nim Py_SET_53BIT_PRECISION_HEADER pylib/pyconfig/floats.html#Py_SET_53BIT_PRECISION_HEADER.t template Py_SET_53BIT_PRECISION_HEADER() 104 +nim Py_SET_53BIT_PRECISION_START pylib/pyconfig/floats.html#Py_SET_53BIT_PRECISION_START.t template Py_SET_53BIT_PRECISION_START() 107 +nim Py_SET_53BIT_PRECISION_END pylib/pyconfig/floats.html#Py_SET_53BIT_PRECISION_END.t template Py_SET_53BIT_PRECISION_END() 112 +nim DOUBLE_IS_BIG_ENDIAN_IEEE754 pylib/pyconfig/floats.html#DOUBLE_IS_BIG_ENDIAN_IEEE754 const DOUBLE_IS_BIG_ENDIAN_IEEE754 201 +nim DOUBLE_IS_LITTLE_ENDIAN_IEEE754 pylib/pyconfig/floats.html#DOUBLE_IS_LITTLE_ENDIAN_IEEE754 const DOUBLE_IS_LITTLE_ENDIAN_IEEE754 201 +nim DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754 pylib/pyconfig/floats.html#DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754 const DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754 201 diff --git a/pylib/pyconfig/main.html b/pylib/pyconfig/main.html new file mode 100644 index 000000000..3c042e9c8 --- /dev/null +++ b/pylib/pyconfig/main.html @@ -0,0 +1,96 @@ + + + + + + + +src/pylib/pyconfig/main + + + + + + + + + + + + + + + + +
+
+

src/pylib/pyconfig/main

+ + + +
+
+ + + diff --git a/pylib/pyconfig/main.idx b/pylib/pyconfig/main.idx new file mode 100644 index 000000000..b2f10b6af --- /dev/null +++ b/pylib/pyconfig/main.idx @@ -0,0 +1 @@ +nimTitle main pylib/pyconfig/main.html module src/pylib/pyconfig/main 0 diff --git a/pylib/pyconfig/os_consts.html b/pylib/pyconfig/os_consts.html new file mode 100644 index 000000000..ed04d754c --- /dev/null +++ b/pylib/pyconfig/os_consts.html @@ -0,0 +1,178 @@ + + + + + + + +src/pylib/pyconfig/os_consts + + + + + + + + + + + + + + + + +
+
+

src/pylib/pyconfig/os_consts

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Imports

+
+ util +
+
+
+

Consts

+
+
+
O_ASYNC = 8192'i32
+
+ + + Source   +Edit   + +
+
+
+
O_DIRECT = 16384'i32
+
+ + + Source   +Edit   + +
+
+
+
O_DIRECTORY = 65536'i32
+
+ + + Source   +Edit   + +
+
+
+
O_NOATIME = 262144'i32
+
+ + + Source   +Edit   + +
+
+
+
O_NOFOLLOW = 131072'i32
+
+ + + Source   +Edit   + +
+
+
+
O_PATH = 2097152'i32
+
+ + + Source   +Edit   + +
+
+
+
O_TMPFILE = 4259840'i32
+
+ + + Source   +Edit   + +
+
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/pyconfig/os_consts.idx b/pylib/pyconfig/os_consts.idx new file mode 100644 index 000000000..82e69af82 --- /dev/null +++ b/pylib/pyconfig/os_consts.idx @@ -0,0 +1,8 @@ +nimTitle os_consts pylib/pyconfig/os_consts.html module src/pylib/pyconfig/os_consts 0 +nim O_ASYNC pylib/pyconfig/os_consts.html#O_ASYNC const O_ASYNC 7 +nim O_DIRECT pylib/pyconfig/os_consts.html#O_DIRECT const O_DIRECT 7 +nim O_DIRECTORY pylib/pyconfig/os_consts.html#O_DIRECTORY const O_DIRECTORY 7 +nim O_NOFOLLOW pylib/pyconfig/os_consts.html#O_NOFOLLOW const O_NOFOLLOW 7 +nim O_NOATIME pylib/pyconfig/os_consts.html#O_NOATIME const O_NOATIME 7 +nim O_PATH pylib/pyconfig/os_consts.html#O_PATH const O_PATH 7 +nim O_TMPFILE pylib/pyconfig/os_consts.html#O_TMPFILE const O_TMPFILE 7 diff --git a/pylib/pyconfig/pycore/pymath.html b/pylib/pyconfig/pycore/pymath.html new file mode 100644 index 000000000..f9b73d4e8 --- /dev/null +++ b/pylib/pyconfig/pycore/pymath.html @@ -0,0 +1,96 @@ + + + + + + + +src/pylib/pyconfig/pycore/pymath + + + + + + + + + + + + + + + + +
+
+

src/pylib/pyconfig/pycore/pymath

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

Py_ADJUST_ERANGE1 and Py_ADJUST_ERANGE2 are defined in pylib/builtins/private/pycore_pymath.nim as they're only required but complex-about routinues

+ + + +
+
+ + +
+
+ + + diff --git a/pylib/pyconfig/pycore/pymath.idx b/pylib/pyconfig/pycore/pymath.idx new file mode 100644 index 000000000..f1a550acd --- /dev/null +++ b/pylib/pyconfig/pycore/pymath.idx @@ -0,0 +1 @@ +nimTitle pymath pylib/pyconfig/pycore/pymath.html module src/pylib/pyconfig/pycore/pymath 0 diff --git a/pylib/pyconfig/pycore/pymath/short_float_repr.html b/pylib/pyconfig/pycore/pymath/short_float_repr.html new file mode 100644 index 000000000..da6088eae --- /dev/null +++ b/pylib/pyconfig/pycore/pymath/short_float_repr.html @@ -0,0 +1,132 @@ + + + + + + + +src/pylib/pyconfig/pycore/pymath/short_float_repr + + + + + + + + + + + + + + + + +
+
+

src/pylib/pyconfig/pycore/pymath/short_float_repr

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

ref https://nim-lang.org/docs/manual.html#types-preminusdefined-floatingminuspoint-types Nim's float XX shall always follows IEEE754 --- _PY_SHORT_FLOAT_REPR macro -------------------------------------------

+ +
+

Consts

+
+
+
WORDS_BIGENDIAN = false
+
+ + + Source   +Edit   + +
+
+
+
WORDS_LITTLEENDIAN = true
+
+ + + Source   +Edit   + +
+
+ +
+
+ + +
+
+ + +
+
+ + + diff --git a/pylib/pyconfig/pycore/pymath/short_float_repr.idx b/pylib/pyconfig/pycore/pymath/short_float_repr.idx new file mode 100644 index 000000000..57b13b71e --- /dev/null +++ b/pylib/pyconfig/pycore/pymath/short_float_repr.idx @@ -0,0 +1,3 @@ +nimTitle short_float_repr pylib/pyconfig/pycore/pymath/short_float_repr.html module src/pylib/pyconfig/pycore/pymath/short_float_repr 0 +nim WORDS_BIGENDIAN pylib/pyconfig/pycore/pymath/short_float_repr.html#WORDS_BIGENDIAN const WORDS_BIGENDIAN 9 +nim WORDS_LITTLEENDIAN pylib/pyconfig/pycore/pymath/short_float_repr.html#WORDS_LITTLEENDIAN const WORDS_LITTLEENDIAN 10 diff --git a/pylib/pyconfig/signal.html b/pylib/pyconfig/signal.html new file mode 100644 index 000000000..c101889b3 --- /dev/null +++ b/pylib/pyconfig/signal.html @@ -0,0 +1,376 @@ + + + + + + + +src/pylib/pyconfig/signal + + + + + + + + + + + + + + + + +
+
+

src/pylib/pyconfig/signal

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Imports

+
+ util +
+
+
+

Consts

+
+
+
DEF_SIG = -1
+
+ + CPython checks SIG* in [0, NSIG) + Source   +Edit   + +
+
+
+
HAVEalarm = true
+
+ + + Source   +Edit   + +
+
+
+
HAVEgetitimer = true
+
+ + + Source   +Edit   + +
+
+
+
HAVEpause = true
+
+ + + Source   +Edit   + +
+
+
+
HAVEpthread_kill = true
+
+ + + Source   +Edit   + +
+
+
+
HAVEpthread_sigmask = true
+
+ + + Source   +Edit   + +
+
+
+
HAVEsetitimer = true
+
+ + + Source   +Edit   + +
+
+
+
HAVEsigaction = true
+
+ + + Source   +Edit   + +
+
+
+
HAVEsigfillset = true
+
+ + + Source   +Edit   + +
+
+
+
HAVEsiginterrupt = true
+
+ + + Source   +Edit   + +
+
+
+
HAVEsigpending = true
+
+ + + Source   +Edit   + +
+
+
+
HAVEsigtimedwait = true
+
+ + + Source   +Edit   + +
+
+
+
HAVEsigwait = true
+
+ + + Source   +Edit   + +
+
+
+
HAVEsigwaitinfo = true
+
+ + + Source   +Edit   + +
+
+
+
HAVEstrsignal = true
+
+ + + Source   +Edit   + +
+
+
+
Py_NSIG = 65
+
+ + + Source   +Edit   + +
+
+
+
SIGCLD = 17
+
+ + + Source   +Edit   + +
+
+
+
SIGEMT = -1
+
+ + + Source   +Edit   + +
+
+
+
SIGIO = 29
+
+ + + Source   +Edit   + +
+
+
+
SIGIOT = 6
+
+ + + Source   +Edit   + +
+
+
+
SIGPWR = 30
+
+ + + Source   +Edit   + +
+
+
+
SIGRTMAX = 64
+
+ + + Source   +Edit   + +
+
+
+
SIGRTMIN = 34
+
+ + + Source   +Edit   + +
+
+
+
SIGSTKFLT = 16
+
+ + + Source   +Edit   + +
+
+
+
SIGWINCH = 28
+
+ + + Source   +Edit   + +
+
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/pyconfig/signal.idx b/pylib/pyconfig/signal.idx new file mode 100644 index 000000000..7f6759cfc --- /dev/null +++ b/pylib/pyconfig/signal.idx @@ -0,0 +1,26 @@ +nimTitle signal pylib/pyconfig/signal.html module src/pylib/pyconfig/signal 0 +nim Py_NSIG pylib/pyconfig/signal.html#Py_NSIG const Py_NSIG 3 +nim HAVEstrsignal pylib/pyconfig/signal.html#HAVEstrsignal const HAVEstrsignal 50 +nim HAVEpthread_kill pylib/pyconfig/signal.html#HAVEpthread_kill const HAVEpthread_kill 50 +nim HAVEalarm pylib/pyconfig/signal.html#HAVEalarm const HAVEalarm 50 +nim HAVEpause pylib/pyconfig/signal.html#HAVEpause const HAVEpause 50 +nim HAVEgetitimer pylib/pyconfig/signal.html#HAVEgetitimer const HAVEgetitimer 50 +nim HAVEsetitimer pylib/pyconfig/signal.html#HAVEsetitimer const HAVEsetitimer 50 +nim HAVEsigaction pylib/pyconfig/signal.html#HAVEsigaction const HAVEsigaction 50 +nim HAVEsigfillset pylib/pyconfig/signal.html#HAVEsigfillset const HAVEsigfillset 50 +nim HAVEsiginterrupt pylib/pyconfig/signal.html#HAVEsiginterrupt const HAVEsiginterrupt 50 +nim HAVEsigpending pylib/pyconfig/signal.html#HAVEsigpending const HAVEsigpending 50 +nim HAVEsigtimedwait pylib/pyconfig/signal.html#HAVEsigtimedwait const HAVEsigtimedwait 50 +nim HAVEsigwait pylib/pyconfig/signal.html#HAVEsigwait const HAVEsigwait 50 +nim HAVEsigwaitinfo pylib/pyconfig/signal.html#HAVEsigwaitinfo const HAVEsigwaitinfo 50 +nim HAVEpthread_sigmask pylib/pyconfig/signal.html#HAVEpthread_sigmask const HAVEpthread_sigmask 50 +nim DEF_SIG pylib/pyconfig/signal.html#DEF_SIG const DEF_SIG 35 +nim SIGIOT pylib/pyconfig/signal.html#SIGIOT const SIGIOT 38 +nim SIGEMT pylib/pyconfig/signal.html#SIGEMT const SIGEMT 38 +nim SIGCLD pylib/pyconfig/signal.html#SIGCLD const SIGCLD 38 +nim SIGPWR pylib/pyconfig/signal.html#SIGPWR const SIGPWR 38 +nim SIGIO pylib/pyconfig/signal.html#SIGIO const SIGIO 38 +nim SIGWINCH pylib/pyconfig/signal.html#SIGWINCH const SIGWINCH 38 +nim SIGRTMIN pylib/pyconfig/signal.html#SIGRTMIN const SIGRTMIN 38 +nim SIGRTMAX pylib/pyconfig/signal.html#SIGRTMAX const SIGRTMAX 38 +nim SIGSTKFLT pylib/pyconfig/signal.html#SIGSTKFLT const SIGSTKFLT 38 diff --git a/pylib/pyconfig/simp.html b/pylib/pyconfig/simp.html new file mode 100644 index 000000000..aef542101 --- /dev/null +++ b/pylib/pyconfig/simp.html @@ -0,0 +1,114 @@ + + + + + + + +src/pylib/pyconfig/simp + + + + + + + + + + + + + + + + +
+
+

src/pylib/pyconfig/simp

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Consts

+
+
+
Py_GIL_DISABLED {.booldefine.} = true
+
+ + + Source   +Edit   + +
+
+
+
Py_USING_MEMORY_DEBUGGER {.booldefine.} = false
+
+ + + Source   +Edit   + +
+
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/pyconfig/simp.idx b/pylib/pyconfig/simp.idx new file mode 100644 index 000000000..33e59d4f3 --- /dev/null +++ b/pylib/pyconfig/simp.idx @@ -0,0 +1,3 @@ +nimTitle simp pylib/pyconfig/simp.html module src/pylib/pyconfig/simp 0 +nim Py_USING_MEMORY_DEBUGGER pylib/pyconfig/simp.html#Py_USING_MEMORY_DEBUGGER const Py_USING_MEMORY_DEBUGGER 3 +nim Py_GIL_DISABLED pylib/pyconfig/simp.html#Py_GIL_DISABLED const Py_GIL_DISABLED 4 diff --git a/pylib/pyconfig/util.html b/pylib/pyconfig/util.html new file mode 100644 index 000000000..d96406638 --- /dev/null +++ b/pylib/pyconfig/util.html @@ -0,0 +1,378 @@ + + + + + + + +src/pylib/pyconfig/util + + + + + + + + + + + + + + + + +
+
+

src/pylib/pyconfig/util

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Macros

+
+
+
+
macro AC_CHECK_FUNCS(xs: varargs[untyped]): untyped
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
macro AC_CHECK_HEADER(header)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
macro AC_CHECK_HEADER_THEN_FUNCS(header; functions)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
macro AC_CHECK_HEADERS(xs: varargs[untyped]): untyped
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
macro from_c_int_expr(cExpr: static[string]; defval: int): int
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
macro from_c_int_underlined(variable: static[string]; defval: int): int
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template AC_CHECK_FUNC(function)
+
+ + + Source   +Edit   + +
+
+
+
template AC_CHECK_FUNC(res, function)
+
+ + export const HAVEfunction + Source   +Edit   + +
+
+ +
+
+
+
template AC_CHECK_HEADER(res, header)
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
template AC_RUN_IFELSE(variable, defval, code)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template AX_C_FLOAT_WORDS_BIGENDIAN(id; doIfTrue, doIfFalse, doIfUnknown) {.
+    dirty.}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template AX_C_FLOAT_WORDS_BIGENDIAN_def(defIfTrue, defIfFalse, doIfUnknown)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template c_defined(variable; c_macro: string; headers: openArray = [])
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template from_c_int(variable; defval: int; precode): int
+
+ + + Source   +Edit   + +
+
+
+
template from_c_int(variable; defvar: int): int
+
+ + + Source   +Edit   + +
+
+
+
template from_c_int(variable; includeFile: static[string]; defval = low(int)): int
+
+ + we know int.low is smaller than low(cint) + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/pyconfig/util.idx b/pylib/pyconfig/util.idx new file mode 100644 index 000000000..dfe5183eb --- /dev/null +++ b/pylib/pyconfig/util.idx @@ -0,0 +1,20 @@ +nimTitle util pylib/pyconfig/util.html module src/pylib/pyconfig/util 0 +nim from_c_int pylib/pyconfig/util.html#from_c_int.t,,int, template from_c_int(variable; defval: int; precode): int 62 +nim from_c_int_underlined pylib/pyconfig/util.html#from_c_int_underlined.m,static[string],int macro from_c_int_underlined(variable: static[string]; defval: int): int 75 +nim from_c_int_expr pylib/pyconfig/util.html#from_c_int_expr.m,static[string],int macro from_c_int_expr(cExpr: static[string]; defval: int): int 79 +nim from_c_int pylib/pyconfig/util.html#from_c_int.t,,static[string] template from_c_int(variable; includeFile: static[string]; defval = low(int)): int 98 +nim from_c_int pylib/pyconfig/util.html#from_c_int.t,,int template from_c_int(variable; defvar: int): int 106 +nim AC_LINK_IFELSE pylib/pyconfig/util.html#AC_LINK_IFELSE.t,,, template AC_LINK_IFELSE(variable, defval, code) 110 +nim AC_RUN_IFELSE pylib/pyconfig/util.html#AC_RUN_IFELSE.t,,, template AC_RUN_IFELSE(variable, defval, code) 111 +nim AX_C_FLOAT_WORDS_BIGENDIAN pylib/pyconfig/util.html#AX_C_FLOAT_WORDS_BIGENDIAN.t,,,, template AX_C_FLOAT_WORDS_BIGENDIAN(id; doIfTrue, doIfFalse, doIfUnknown) 114 +nim AX_C_FLOAT_WORDS_BIGENDIAN_def pylib/pyconfig/util.html#AX_C_FLOAT_WORDS_BIGENDIAN_def.t,,, template AX_C_FLOAT_WORDS_BIGENDIAN_def(defIfTrue, defIfFalse, doIfUnknown) 143 +nim c_defined pylib/pyconfig/util.html#c_defined.t,,string,openArray template c_defined(variable; c_macro: string; headers: openArray = []) 149 +nim AC_CHECK_FUNC pylib/pyconfig/util.html#AC_CHECK_FUNC.t,, template AC_CHECK_FUNC(res, function) 187 +nim AC_CHECK_FUNC pylib/pyconfig/util.html#AC_CHECK_FUNC.t template AC_CHECK_FUNC(function) 206 +nim AC_CHECK_FUNCS pylib/pyconfig/util.html#AC_CHECK_FUNCS.m,varargs[untyped] macro AC_CHECK_FUNCS(xs: varargs[untyped]): untyped 206 +nim AC_CHECK_HEADER pylib/pyconfig/util.html#AC_CHECK_HEADER.t,, template AC_CHECK_HEADER(res, header) 209 +nim AC_CHECK_HEADER pylib/pyconfig/util.html#AC_CHECK_HEADER.m macro AC_CHECK_HEADER(header) 219 +nim AC_CHECK_HEADERS pylib/pyconfig/util.html#AC_CHECK_HEADERS.m,varargs[untyped] macro AC_CHECK_HEADERS(xs: varargs[untyped]): untyped 219 +nim AC_CHECK_HEADER_THEN_FUNCS pylib/pyconfig/util.html#AC_CHECK_HEADER_THEN_FUNCS.m,, macro AC_CHECK_HEADER_THEN_FUNCS(header; functions) 229 +nimgrp Accheckfunc pylib/pyconfig/util.html#AC_CHECK_FUNC-templates-all template 187 +nimgrp fromcint pylib/pyconfig/util.html#from_c_int-templates-all template 62 diff --git a/pylib/pyerrors.html b/pylib/pyerrors.html new file mode 100644 index 000000000..30e42305c --- /dev/null +++ b/pylib/pyerrors.html @@ -0,0 +1,96 @@ + + + + + + + +src/pylib/pyerrors + + + + + + + + + + + + + + + + + + + + diff --git a/pylib/pyerrors.idx b/pylib/pyerrors.idx new file mode 100644 index 000000000..feafa85f3 --- /dev/null +++ b/pylib/pyerrors.idx @@ -0,0 +1 @@ +nimTitle pyerrors pylib/pyerrors.html module src/pylib/pyerrors 0 diff --git a/pylib/pyerrors/aritherr.html b/pylib/pyerrors/aritherr.html new file mode 100644 index 000000000..66f0e9687 --- /dev/null +++ b/pylib/pyerrors/aritherr.html @@ -0,0 +1,114 @@ + + + + + + + +src/pylib/pyerrors/aritherr + + + + + + + + + + + + + + + + +
+
+

src/pylib/pyerrors/aritherr

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Types

+
+
+
ArithmeticError = object of CatchableError
+
+ + + Source   +Edit   + +
+
+
+
ZeroDivisionError = object of ArithmeticError
+
+ + + Source   +Edit   + +
+
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/pyerrors/aritherr.idx b/pylib/pyerrors/aritherr.idx new file mode 100644 index 000000000..994cb3020 --- /dev/null +++ b/pylib/pyerrors/aritherr.idx @@ -0,0 +1,3 @@ +nimTitle aritherr pylib/pyerrors/aritherr.html module src/pylib/pyerrors/aritherr 0 +nim ArithmeticError pylib/pyerrors/aritherr.html#ArithmeticError object ArithmeticError 3 +nim ZeroDivisionError pylib/pyerrors/aritherr.html#ZeroDivisionError object ZeroDivisionError 4 diff --git a/pylib/pyerrors/lkuperr.html b/pylib/pyerrors/lkuperr.html new file mode 100644 index 000000000..9647e1775 --- /dev/null +++ b/pylib/pyerrors/lkuperr.html @@ -0,0 +1,106 @@ + + + + + + + +src/pylib/pyerrors/lkuperr + + + + + + + + + + + + + + + + +
+
+

src/pylib/pyerrors/lkuperr

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Types

+
+
+
LookupError = object of CatchableError
+
+ +
Warning: +Python's KeyError inherits LookupError,
+

but Nim's doesn't, but inherits ValueError instead.

+ + Source   +Edit   + +
+
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/pyerrors/lkuperr.idx b/pylib/pyerrors/lkuperr.idx new file mode 100644 index 000000000..031cf7801 --- /dev/null +++ b/pylib/pyerrors/lkuperr.idx @@ -0,0 +1,2 @@ +nimTitle lkuperr pylib/pyerrors/lkuperr.html module src/pylib/pyerrors/lkuperr 0 +nim LookupError pylib/pyerrors/lkuperr.html#LookupError object LookupError 3 diff --git a/pylib/pyerrors/oserr.html b/pylib/pyerrors/oserr.html new file mode 100644 index 000000000..6ee6f4605 --- /dev/null +++ b/pylib/pyerrors/oserr.html @@ -0,0 +1,363 @@ + + + + + + + +src/pylib/pyerrors/oserr + + + + + + + + + + + + + + + + +
+
+

src/pylib/pyerrors/oserr

+
+ +
+ Source   +Edit   + +
+ +

See CPython's Objects/exceptions.c

+

OSError_new(a.k.a. OSError.__new__) will returns a subclass of OSError, via lookup in state->errnomap, which is initialized by _PyExc_InitState,

+

where key-value pairs are inserted via ADD_ERRNO macro.

+

+ +
+

Procs

+
+
+
+
func errnoMsg(errno: cint): string {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc raiseErrno(errno = getErrno()) {....raises: [PyOSError], tags: [], forbids: [].}
+
+ + may raise subclass of OSError + Source   +Edit   + +
+
+ +
+
+
+
proc raiseErrnoT[T: PyOSError](errno = getErrno())
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc raiseErrnoWithPath[T](p: PathLike[T]; errno = getErrno())
+
+ + raises OSError or its SubError. refer to errno even under Windows. + Source   +Edit   + +
+
+ +
+
+
+
func raiseExcWithPath(fp: PathLike; exc: typedesc; err: OSErrorCode;
+                      additionalInfo: string)
+
+ + + Source   +Edit   + +
+
+
+
proc raiseExcWithPath(fp: PathLike; exc: typedesc; err: OSErrorCode;
+                      osErrorMsgCb: proc = osErrorMsg)
+
+ + + Source   +Edit   + +
+
+
+
proc raiseExcWithPath(p: PathLike) {.sideEffect.}
+
+ + + Source   +Edit   + +
+
+
+
proc raiseExcWithPath(p: PathLike; errCode: OSErrorCode) {.sideEffect.}
+
+ + raises OSError or its one of SubError type + Source   +Edit   + +
+
+ +
+
+
+
proc raiseExcWithPath2(src, dst: PathLike)
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template noWeirdTarget(def)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template osErrorMsgWithPath(fp: PathLike; err: OSErrorCode): string
+
+ + + Source   +Edit   + +
+
+
+
template osErrorMsgWithPath(fp: PathLike; err: OSErrorCode; osErrorMsgCb): string
+
+ + always suffixed with a \n + Source   +Edit   + +
+
+ +
+
+
+
template tryOsOp(p1, p2: PathLike; body)
+
+ + + Source   +Edit   + +
+
+
+
template tryOsOp(p: PathLike; body)
+
+ + + Source   +Edit   + +
+
+
+
template tryOsOp(p: PathLike; raiseCond: bool; body)
+
+ + + Source   +Edit   + +
+
+
+
template tryOsOp(raiseCond: bool; body)
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ + +
+
+ + +
+
+ + + diff --git a/pylib/pyerrors/oserr.idx b/pylib/pyerrors/oserr.idx new file mode 100644 index 000000000..bb8f4c04d --- /dev/null +++ b/pylib/pyerrors/oserr.idx @@ -0,0 +1,20 @@ +nimTitle oserr pylib/pyerrors/oserr.html module src/pylib/pyerrors/oserr 0 +nim osErrorMsgWithPath pylib/pyerrors/oserr.html#osErrorMsgWithPath.t,PathLike,OSErrorCode, template osErrorMsgWithPath(fp: PathLike; err: OSErrorCode; osErrorMsgCb): string 36 +nim osErrorMsgWithPath pylib/pyerrors/oserr.html#osErrorMsgWithPath.t,PathLike,OSErrorCode template osErrorMsgWithPath(fp: PathLike; err: OSErrorCode): string 52 +nim raiseExcWithPath pylib/pyerrors/oserr.html#raiseExcWithPath,PathLike,typedesc,OSErrorCode,proc proc raiseExcWithPath(fp: PathLike; exc: typedesc; err: OSErrorCode;\n osErrorMsgCb: proc = osErrorMsg) 56 +nim raiseExcWithPath pylib/pyerrors/oserr.html#raiseExcWithPath,PathLike,typedesc,OSErrorCode,string proc raiseExcWithPath(fp: PathLike; exc: typedesc; err: OSErrorCode;\n additionalInfo: string) 60 +nim noWeirdTarget pylib/pyerrors/oserr.html#noWeirdTarget.t template noWeirdTarget(def) 66 +nim raiseExcWithPath pylib/pyerrors/oserr.html#raiseExcWithPath,PathLike,OSErrorCode proc raiseExcWithPath(p: PathLike; errCode: OSErrorCode) 71 +nim raiseExcWithPath pylib/pyerrors/oserr.html#raiseExcWithPath,PathLike proc raiseExcWithPath(p: PathLike) 78 +nim raiseExcWithPath2 pylib/pyerrors/oserr.html#raiseExcWithPath2,PathLike,PathLike proc raiseExcWithPath2(src, dst: PathLike) 87 +nim tryOsOp pylib/pyerrors/oserr.html#tryOsOp.t,PathLike, template tryOsOp(p: PathLike; body) 96 +nim tryOsOp pylib/pyerrors/oserr.html#tryOsOp.t,PathLike,bool, template tryOsOp(p: PathLike; raiseCond: bool; body) 101 +nim tryOsOp pylib/pyerrors/oserr.html#tryOsOp.t,bool, template tryOsOp(raiseCond: bool; body) 107 +nim tryOsOp pylib/pyerrors/oserr.html#tryOsOp.t,PathLike,PathLike, template tryOsOp(p1, p2: PathLike; body) 113 +nim errnoMsg pylib/pyerrors/oserr.html#errnoMsg,cint proc errnoMsg(errno: cint): string 122 +nim raiseErrno pylib/pyerrors/oserr.html#raiseErrno proc raiseErrno(errno = getErrno()) 132 +nim raiseErrnoT pylib/pyerrors/oserr.html#raiseErrnoT proc raiseErrnoT[T: PyOSError](errno = getErrno()) 136 +nim raiseErrnoWithPath pylib/pyerrors/oserr.html#raiseErrnoWithPath,PathLike[T] proc raiseErrnoWithPath[T](p: PathLike[T]; errno = getErrno()) 139 +nimgrp raiseexcwithpath pylib/pyerrors/oserr.html#raiseExcWithPath-procs-all proc 56 +nimgrp tryosop pylib/pyerrors/oserr.html#tryOsOp-templates-all template 96 +nimgrp oserrormsgwithpath pylib/pyerrors/oserr.html#osErrorMsgWithPath-templates-all template 36 diff --git a/pylib/pyerrors/oserr/errmap.html b/pylib/pyerrors/oserr/errmap.html new file mode 100644 index 000000000..67d950d89 --- /dev/null +++ b/pylib/pyerrors/oserr/errmap.html @@ -0,0 +1,177 @@ + + + + + + + +src/pylib/pyerrors/oserr/errmap + + + + + + + + + + + + + + + + +
+
+

src/pylib/pyerrors/oserr/errmap

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Vars

+
+
+
errnomap {.compileTime.}: Table[cint,
+                                proc (): ref PyOSError {.nimcall, noSideEffect.}]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
proc default_oserror(): ref PyOSError {.nimcall, noSideEffect, ...raises: [],
+                                        tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template decl_c_int(name, includeFile; defval)
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/pyerrors/oserr/errmap.idx b/pylib/pyerrors/oserr/errmap.idx new file mode 100644 index 000000000..95f590f84 --- /dev/null +++ b/pylib/pyerrors/oserr/errmap.idx @@ -0,0 +1,4 @@ +nimTitle errmap pylib/pyerrors/oserr/errmap.html module src/pylib/pyerrors/oserr/errmap 0 +nim decl_c_int pylib/pyerrors/oserr/errmap.html#decl_c_int.t,,, template decl_c_int(name, includeFile; defval) 30 +nim errnomap pylib/pyerrors/oserr/errmap.html#errnomap var errnomap 37 +nim default_oserror pylib/pyerrors/oserr/errmap.html#default_oserror proc default_oserror(): ref PyOSError 38 diff --git a/pylib/pyerrors/oserr/init.html b/pylib/pyerrors/oserr/init.html new file mode 100644 index 000000000..deb677223 --- /dev/null +++ b/pylib/pyerrors/oserr/init.html @@ -0,0 +1,233 @@ + + + + + + + +src/pylib/pyerrors/oserr/init + + + + + + + + + + + + + + + + +
+
+

src/pylib/pyerrors/oserr/init

+
+ +
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
proc BlockingIOError(myerrno: cint; strerr: string; filename = 0;
+                     winerror: cint = 0; filename2 = ""): ref PyOSError {.
+    ...raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc BlockingIOError(strerr: string = ""): ref PyOSError {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc newBlockingIOError(myerrno: cint; strerr: string; filename = 0;
+                        winerror: cint = 0; filename2 = ""): ref PyOSError {.
+    ...raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc newBlockingIOError(strerr: string = ""): ref PyOSError {....raises: [],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc newPyOSError(myerrno: cint; strerr: string; filename = "";
+                  winerror: cint = 0; filename2 = ""): ref PyOSError {.
+    ...raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc newPyOSError(strerr: string = ""): ref PyOSError {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc PyOSError(myerrno: cint; strerr: string; filename = ""; winerror: cint = 0;
+               filename2 = ""): ref PyOSError {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc PyOSError(strerr: string = ""): ref PyOSError {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/pyerrors/oserr/init.idx b/pylib/pyerrors/oserr/init.idx new file mode 100644 index 000000000..51d904a79 --- /dev/null +++ b/pylib/pyerrors/oserr/init.idx @@ -0,0 +1,13 @@ +nimTitle init pylib/pyerrors/oserr/init.html module src/pylib/pyerrors/oserr/init 0 +nim newPyOSError pylib/pyerrors/oserr/init.html#newPyOSError,cint,string,string,cint,string proc newPyOSError(myerrno: cint; strerr: string; filename = ""; winerror: cint = 0;\n filename2 = ""): ref PyOSError 6 +nim newPyOSError pylib/pyerrors/oserr/init.html#newPyOSError,string proc newPyOSError(strerr: string = ""): ref PyOSError 14 +nim PyOSError pylib/pyerrors/oserr/init.html#PyOSError,cint,string,string,cint,string proc PyOSError(myerrno: cint; strerr: string; filename = ""; winerror: cint = 0;\n filename2 = ""): ref PyOSError 6 +nim PyOSError pylib/pyerrors/oserr/init.html#PyOSError,string proc PyOSError(strerr: string = ""): ref PyOSError 17 +nim newBlockingIOError pylib/pyerrors/oserr/init.html#newBlockingIOError,cint,string,int,cint,string proc newBlockingIOError(myerrno: cint; strerr: string; filename = 0;\n winerror: cint = 0; filename2 = ""): ref PyOSError 6 +nim newBlockingIOError pylib/pyerrors/oserr/init.html#newBlockingIOError,string proc newBlockingIOError(strerr: string = ""): ref PyOSError 14 +nim BlockingIOError pylib/pyerrors/oserr/init.html#BlockingIOError,cint,string,int,cint,string proc BlockingIOError(myerrno: cint; strerr: string; filename = 0; winerror: cint = 0;\n filename2 = ""): ref PyOSError 6 +nim BlockingIOError pylib/pyerrors/oserr/init.html#BlockingIOError,string proc BlockingIOError(strerr: string = ""): ref PyOSError 18 +nimgrp Blockingioerror pylib/pyerrors/oserr/init.html#BlockingIOError-procs-all proc 15 +nimgrp newpyoserror pylib/pyerrors/oserr/init.html#newPyOSError-procs-all proc 14 +nimgrp Pyoserror pylib/pyerrors/oserr/init.html#PyOSError-procs-all proc 15 +nimgrp newblockingioerror pylib/pyerrors/oserr/init.html#newBlockingIOError-procs-all proc 14 diff --git a/pylib/pyerrors/oserr/oserror_decl.html b/pylib/pyerrors/oserr/oserror_decl.html new file mode 100644 index 000000000..ebf10183a --- /dev/null +++ b/pylib/pyerrors/oserr/oserror_decl.html @@ -0,0 +1,113 @@ + + + + + + + +src/pylib/pyerrors/oserr/oserror_decl + + + + + + + + + + + + + + + + +
+
+

src/pylib/pyerrors/oserr/oserror_decl

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Types

+
+
+
PyOSError = object of system.OSError
+  errno* {.exportc: "myerrno".}: cint
+  strerror*, filename*, filename2*: string
+  when defined(windows):
+    winerror*: cint          ## Windows-specific error code
+  characters_written*: int
+
+ + Python-compatible OSError + Source   +Edit   + +
+
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/pyerrors/oserr/oserror_decl.idx b/pylib/pyerrors/oserr/oserror_decl.idx new file mode 100644 index 000000000..28aeffc24 --- /dev/null +++ b/pylib/pyerrors/oserr/oserror_decl.idx @@ -0,0 +1,2 @@ +nimTitle oserror_decl pylib/pyerrors/oserr/oserror_decl.html module src/pylib/pyerrors/oserr/oserror_decl 0 +nim PyOSError pylib/pyerrors/oserr/oserror_decl.html#PyOSError object PyOSError 2 diff --git a/pylib/pyerrors/oserr/oserror_new.html b/pylib/pyerrors/oserr/oserror_new.html new file mode 100644 index 000000000..009bc303a --- /dev/null +++ b/pylib/pyerrors/oserr/oserror_new.html @@ -0,0 +1,206 @@ + + + + + + + +src/pylib/pyerrors/oserr/oserror_new + + + + + + + + + + + + + + + + +
+
+

src/pylib/pyerrors/oserr/oserror_new

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

Where a function has a single filename, such as open() or some of the os module functions, PyErr_SetFromErrnoWithFilename() is called, giving a third argument which is the filename. But, so that old code using in-place unpacking doesn't break, e.g.:

+

except OSError, (errno, strerror):

+

we hack args so that it only contains two items. This also means we need our own __str__() which prints out the filename when it was supplied.

+

(If a function has two filenames, such as rename(), symlink(), or copy(), PyErr_SetFromErrnoWithFilenameObjects() is called, which allows passing in a second filename.)

+

+ +
+

Types

+
+
+
OSErrorArgs[third] = tuple[errno: cint, strerror: string, filename: third,
+                           winerror: cint, filename2: string]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
proc init[E: PyOSError](self: ref E; args: OSErrorArgs)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc OSError_new[E: PyOSError](myerrno: cint; strerr: string;
+                               filename: string | int = ""; winerror: cint = 0;
+                               filename2 = ""; fillMsg: static[bool] = true): ref PyOSError
+
+ + may returns a subclass of OSError + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template oserror_use_init[E: PyOSError](self): bool
+
+ +

When __init__ is defined in an OSError subclass, we want any extraneous argument to __new__ to be ignored. The only reasonable solution, given __new__ takes a variable number of arguments, is to defer arg parsing and initialization to __init__.

+

But when __new__ is overridden as well, it should call our __new__ with the right arguments.

+

(see http://bugs.python.org/issue12555#msg148829 )

+ + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/pyerrors/oserr/oserror_new.idx b/pylib/pyerrors/oserr/oserror_new.idx new file mode 100644 index 000000000..a494c0ca0 --- /dev/null +++ b/pylib/pyerrors/oserr/oserror_new.idx @@ -0,0 +1,5 @@ +nimTitle oserror_new pylib/pyerrors/oserr/oserror_new.html module src/pylib/pyerrors/oserr/oserror_new 0 +nim OSErrorArgs pylib/pyerrors/oserr/oserror_new.html#OSErrorArgs tuple OSErrorArgs 22 +nim oserror_use_init pylib/pyerrors/oserr/oserror_new.html#oserror_use_init.t template oserror_use_init[E: PyOSError](self): bool 40 +nim init pylib/pyerrors/oserr/oserror_new.html#init,ref.E,OSErrorArgs proc init[E: PyOSError](self: ref E; args: OSErrorArgs) 55 +nim OSError_new pylib/pyerrors/oserr/oserror_new.html#OSError_new,cint,string,string,cint,string,static[bool] proc OSError_new[E: PyOSError](myerrno: cint; strerr: string;\n filename: string | int = ""; winerror: cint = 0;\n filename2 = ""; fillMsg: static[bool] = true): ref PyOSError 67 diff --git a/pylib/pyerrors/oserr/oserror_str.html b/pylib/pyerrors/oserr/oserror_str.html new file mode 100644 index 000000000..457469089 --- /dev/null +++ b/pylib/pyerrors/oserr/oserror_str.html @@ -0,0 +1,118 @@ + + + + + + + +src/pylib/pyerrors/oserr/oserror_str + + + + + + + + + + + + + + + + +
+
+

src/pylib/pyerrors/oserr/oserror_str

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Imports

+
+ types +
+
+
+

Procs

+
+
+
+
proc `$`(self: ref PyOSError): string {....raises: [], tags: [], forbids: [].}
+
+ + String representation of OSError + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/pyerrors/oserr/oserror_str.idx b/pylib/pyerrors/oserr/oserror_str.idx new file mode 100644 index 000000000..effd96a3a --- /dev/null +++ b/pylib/pyerrors/oserr/oserror_str.idx @@ -0,0 +1,2 @@ +nimTitle oserror_str pylib/pyerrors/oserr/oserror_str.html module src/pylib/pyerrors/oserr/oserror_str 0 +nim `$` pylib/pyerrors/oserr/oserror_str.html#$,ref.PyOSError proc `$`(self: ref PyOSError): string 5 diff --git a/pylib/pyerrors/oserr/types.html b/pylib/pyerrors/oserr/types.html new file mode 100644 index 000000000..e29cfcd4f --- /dev/null +++ b/pylib/pyerrors/oserr/types.html @@ -0,0 +1,275 @@ + + + + + + + +src/pylib/pyerrors/oserr/types + + + + + + + + + + + + + + + + +
+
+

src/pylib/pyerrors/oserr/types

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Types

+
+
+
BlockingIOError = object of oserror_decl.PyOSError
+
+ + + Source   +Edit   + +
+
+
+
BrokenPipeError = object of ConnectionError
+
+ + + Source   +Edit   + +
+
+
+
ChildProcessError = object of oserror_decl.PyOSError
+
+ + + Source   +Edit   + +
+
+
+
ConnectionAbortedError = object of ConnectionError
+
+ + + Source   +Edit   + +
+
+
+
ConnectionError = object of oserror_decl.PyOSError
+
+ + + Source   +Edit   + +
+
+
+
ConnectionRefusedError = object of ConnectionError
+
+ + + Source   +Edit   + +
+
+
+
ConnectionResetError = object of ConnectionError
+
+ + + Source   +Edit   + +
+
+
+
FileExistsError = object of oserror_decl.PyOSError
+
+ + + Source   +Edit   + +
+
+
+
FileNotFoundError = object of oserror_decl.PyOSError
+
+ + + Source   +Edit   + +
+
+
+
InterruptedError = object of oserror_decl.PyOSError
+
+ + + Source   +Edit   + +
+
+
+
IsADirectoryError = object of oserror_decl.PyOSError
+
+ + + Source   +Edit   + +
+
+
+
NotADirectoryError = object of oserror_decl.PyOSError
+
+ + + Source   +Edit   + +
+
+
+
PermissionError = object of oserror_decl.PyOSError
+
+ + + Source   +Edit   + +
+
+
+
ProcessLookupError = object of oserror_decl.PyOSError
+
+ + + Source   +Edit   + +
+
+
+
TimeoutError = object of oserror_decl.PyOSError
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Exports

+
+ PyOSError +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/pyerrors/oserr/types.idx b/pylib/pyerrors/oserr/types.idx new file mode 100644 index 000000000..e06ec8e0c --- /dev/null +++ b/pylib/pyerrors/oserr/types.idx @@ -0,0 +1,16 @@ +nimTitle types pylib/pyerrors/oserr/types.html module src/pylib/pyerrors/oserr/types 0 +nim BlockingIOError pylib/pyerrors/oserr/types.html#BlockingIOError object BlockingIOError 6 +nim ConnectionError pylib/pyerrors/oserr/types.html#ConnectionError object ConnectionError 6 +nim ChildProcessError pylib/pyerrors/oserr/types.html#ChildProcessError object ChildProcessError 6 +nim BrokenPipeError pylib/pyerrors/oserr/types.html#BrokenPipeError object BrokenPipeError 6 +nim ConnectionAbortedError pylib/pyerrors/oserr/types.html#ConnectionAbortedError object ConnectionAbortedError 6 +nim ConnectionRefusedError pylib/pyerrors/oserr/types.html#ConnectionRefusedError object ConnectionRefusedError 6 +nim ConnectionResetError pylib/pyerrors/oserr/types.html#ConnectionResetError object ConnectionResetError 6 +nim FileExistsError pylib/pyerrors/oserr/types.html#FileExistsError object FileExistsError 6 +nim FileNotFoundError pylib/pyerrors/oserr/types.html#FileNotFoundError object FileNotFoundError 6 +nim IsADirectoryError pylib/pyerrors/oserr/types.html#IsADirectoryError object IsADirectoryError 6 +nim NotADirectoryError pylib/pyerrors/oserr/types.html#NotADirectoryError object NotADirectoryError 6 +nim InterruptedError pylib/pyerrors/oserr/types.html#InterruptedError object InterruptedError 6 +nim PermissionError pylib/pyerrors/oserr/types.html#PermissionError object PermissionError 6 +nim ProcessLookupError pylib/pyerrors/oserr/types.html#ProcessLookupError object ProcessLookupError 6 +nim TimeoutError pylib/pyerrors/oserr/types.html#TimeoutError object TimeoutError 6 diff --git a/pylib/pyerrors/rterr.html b/pylib/pyerrors/rterr.html new file mode 100644 index 000000000..66231543a --- /dev/null +++ b/pylib/pyerrors/rterr.html @@ -0,0 +1,125 @@ + + + + + + + +src/pylib/pyerrors/rterr + + + + + + + + + + + + + + + + +
+
+

src/pylib/pyerrors/rterr

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Types

+
+
+
KeyboardInterrupt = object of CatchableError
+
+ + + Source   +Edit   + +
+
+
+
NotImplementedError = object of RuntimeError
+
+ + + Source   +Edit   + +
+
+
+
RuntimeError = object of CatchableError
+
+ + + Source   +Edit   + +
+
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/pyerrors/rterr.idx b/pylib/pyerrors/rterr.idx new file mode 100644 index 000000000..04cae4fb4 --- /dev/null +++ b/pylib/pyerrors/rterr.idx @@ -0,0 +1,4 @@ +nimTitle rterr pylib/pyerrors/rterr.html module src/pylib/pyerrors/rterr 0 +nim RuntimeError pylib/pyerrors/rterr.html#RuntimeError object RuntimeError 3 +nim NotImplementedError pylib/pyerrors/rterr.html#NotImplementedError object NotImplementedError 4 +nim KeyboardInterrupt pylib/pyerrors/rterr.html#KeyboardInterrupt object KeyboardInterrupt 6 diff --git a/pylib/pyerrors/signals.html b/pylib/pyerrors/signals.html new file mode 100644 index 000000000..13cb0bc8d --- /dev/null +++ b/pylib/pyerrors/signals.html @@ -0,0 +1,247 @@ + + + + + + + +src/pylib/pyerrors/signals + + + + + + + + + + + + + + + + +
+
+

src/pylib/pyerrors/signals

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Imports

+
+ ../noneType +
+
+
+

Types

+
+
+
GeneratorExit = object of CatchableError
+
+ + + Source   +Edit   + +
+
+
+
StopAsyncIteration = object of CatchableError
+
+ + + Source   +Edit   + +
+
+
+
StopIteration = StopIterationT[NoneType]
+
+ +
Note: +CPython's StopIteration is not generics, at least as of 3.13
+ + Source   +Edit   + +
+
+
+
StopIterationT[T] = object of CatchableError
+  value*: T                  ## generator return value
+
+ + EXT. as StopIteraton's value was not statically typed in Python, this must be used for those whose value is not None + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
func `$`(self: StopIteration): string {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func `$`(self: StopIterationT): string
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func msg(self: StopIteration): string {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func msg(self: StopIterationT): string
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func newStopIteration(): ref StopIteration {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func newStopIteration[T](value: T): ref StopIterationT[T]
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/pyerrors/signals.idx b/pylib/pyerrors/signals.idx new file mode 100644 index 000000000..966e56018 --- /dev/null +++ b/pylib/pyerrors/signals.idx @@ -0,0 +1,14 @@ +nimTitle signals pylib/pyerrors/signals.html module src/pylib/pyerrors/signals 0 +nim StopIterationT pylib/pyerrors/signals.html#StopIterationT object StopIterationT 5 +nim StopIteration pylib/pyerrors/signals.html#StopIteration type StopIteration 9 +nim StopAsyncIteration pylib/pyerrors/signals.html#StopAsyncIteration object StopAsyncIteration 12 +nim GeneratorExit pylib/pyerrors/signals.html#GeneratorExit object GeneratorExit 13 +nim newStopIteration pylib/pyerrors/signals.html#newStopIteration proc newStopIteration(): ref StopIteration 15 +nim newStopIteration pylib/pyerrors/signals.html#newStopIteration,T proc newStopIteration[T](value: T): ref StopIterationT[T] 16 +nim `$` pylib/pyerrors/signals.html#$,StopIteration proc `$`(self: StopIteration): string 20 +nim `$` pylib/pyerrors/signals.html#$,StopIterationT proc `$`(self: StopIterationT): string 21 +nim msg pylib/pyerrors/signals.html#msg,StopIteration proc msg(self: StopIteration): string 23 +nim msg pylib/pyerrors/signals.html#msg,StopIterationT proc msg(self: StopIterationT): string 24 +nimgrp msg pylib/pyerrors/signals.html#msg-procs-all proc 23 +nimgrp $ pylib/pyerrors/signals.html#$-procs-all proc 20 +nimgrp newstopiteration pylib/pyerrors/signals.html#newStopIteration-procs-all proc 15 diff --git a/pylib/pyerrors/simperr.html b/pylib/pyerrors/simperr.html new file mode 100644 index 000000000..67467f996 --- /dev/null +++ b/pylib/pyerrors/simperr.html @@ -0,0 +1,136 @@ + + + + + + + +src/pylib/pyerrors/simperr + + + + + + + + + + + + + + + + +
+
+

src/pylib/pyerrors/simperr

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Types

+
+
+
AttributeError = object of CatchableError
+
+ + + Source   +Edit   + +
+
+
+
NameError = object of CatchableError
+
+ + + Source   +Edit   + +
+
+
+
SystemExit = object of CatchableError
+
+ + + Source   +Edit   + +
+
+
+
TypeError = object of CatchableError
+
+ + + Source   +Edit   + +
+
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/pyerrors/simperr.idx b/pylib/pyerrors/simperr.idx new file mode 100644 index 000000000..1efe31b22 --- /dev/null +++ b/pylib/pyerrors/simperr.idx @@ -0,0 +1,5 @@ +nimTitle simperr pylib/pyerrors/simperr.html module src/pylib/pyerrors/simperr 0 +nim TypeError pylib/pyerrors/simperr.html#TypeError object TypeError 3 +nim SystemExit pylib/pyerrors/simperr.html#SystemExit object SystemExit 4 +nim AttributeError pylib/pyerrors/simperr.html#AttributeError object AttributeError 5 +nim NameError pylib/pyerrors/simperr.html#NameError object NameError 6 diff --git a/pylib/pyerrors/unicode_err.html b/pylib/pyerrors/unicode_err.html new file mode 100644 index 000000000..9c1b89a67 --- /dev/null +++ b/pylib/pyerrors/unicode_err.html @@ -0,0 +1,162 @@ + + + + + + + +src/pylib/pyerrors/unicode_err + + + + + + + + + + + + + + + + +
+
+

src/pylib/pyerrors/unicode_err

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Types

+
+
+
UnicodeDecodeError = object of UnicodeError
+
+ + + Source   +Edit   + +
+
+
+
UnicodeError = object of ValueError
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
func newUnicodeDecodeError(codec: string; src: char; start, stop: int;
+                           reason: string): ref UnicodeDecodeError {.
+    ...raises: [ValueError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func newUnicodeDecodeError(codec: string; src: string; start, stop: int;
+                           reason: string): ref UnicodeDecodeError {.
+    ...raises: [ValueError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/pyerrors/unicode_err.idx b/pylib/pyerrors/unicode_err.idx new file mode 100644 index 000000000..bc0a6a8ac --- /dev/null +++ b/pylib/pyerrors/unicode_err.idx @@ -0,0 +1,6 @@ +nimTitle unicode_err pylib/pyerrors/unicode_err.html module src/pylib/pyerrors/unicode_err 0 +nim UnicodeError pylib/pyerrors/unicode_err.html#UnicodeError object UnicodeError 5 +nim UnicodeDecodeError pylib/pyerrors/unicode_err.html#UnicodeDecodeError object UnicodeDecodeError 6 +nim newUnicodeDecodeError pylib/pyerrors/unicode_err.html#newUnicodeDecodeError,string,char,int,int,string proc newUnicodeDecodeError(codec: string; src: char; start, stop: int; reason: string): ref UnicodeDecodeError 8 +nim newUnicodeDecodeError pylib/pyerrors/unicode_err.html#newUnicodeDecodeError,string,string,int,int,string proc newUnicodeDecodeError(codec: string; src: string; start, stop: int;\n reason: string): ref UnicodeDecodeError 27 +nimgrp newunicodedecodeerror pylib/pyerrors/unicode_err.html#newUnicodeDecodeError-procs-all proc 8 diff --git a/pylib/pystring.html b/pylib/pystring.html new file mode 100644 index 000000000..596ad073c --- /dev/null +++ b/pylib/pystring.html @@ -0,0 +1,96 @@ + + + + + + + +src/pylib/pystring + + + + + + + + + + + + + + + + +
+
+

src/pylib/pystring

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Exports

+
+ runeLenAt, not, str, str, toPyStr, contains, substr, byteLen, str, items, StringLike, ==, str, toNimString, +, ==, str, chars, contains, and, getChar, $, len, +=, str, +=, len, toPyStr, PyStr, runes, [], ==, runeAtPos, or, contains, +, toNimStr, fspath, +=, toPyStr, [], [], endsWith, toPyStr, substr, ==, str, endsWith, PyStr, and, isupper, $, +=, rfind, isascii, index, startsWith, split, rjust, ljust, endsWith, rpartition, str, runeLenAt, contains, rsplit, StringLike, count, split, isspace, ==, contains, chars, endsWith, istitle, len, rstrip, isalpha, *, toPyStr, rindex, center, startsWith, split, str, str, expandtabs, splitlines, removeprefix, title, toPyStr, splitlines, replace, not, islower, rsplit, runes, casefold, toNimString, +, count, join, upper, contains, lstrip, getChar, strip, +=, find, strip, ==, runeAtPos, +, lstrip, +=, zfill, partition, startsWith, str, capitalize, or, byteLen, items, startsWith, startsWith, endsWith, split, len, center, str, rstrip, replace, rjust, rsplit, [], isascii, count, removesuffix, ljust, lower, toNimStr, fspath, *, [], [], chr, bin, hex, pyrepr, ord1, oct, ord, ascii, ascii, repr, ascii, reversed, ascii, <>, u, u, rf, fr, f, Fr, Rf, format, format, TypedTranslateTableABC, maketrans, not, toPyStr, substr, contains, ==, str, toNimString, +, StrTypedTranslateTable, PyStr, contains, and, getChar, $, None, +=, +=, $, maketrans, ==, TranslateTableABC, runeAtPos, TranslateAction, +, TranslateTable, +=, translate, translate, runeLenAt, str, str, or, translate, byteLen, items, StringLike, ==, translate, str, chars, repr, len, len, str, maketrans, toPyStr, str, runes, [], NoneType, TranslateTableVal, contains, toNimStr, fspath, toPyStr, [], TranslateValType, [] +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/pystring.idx b/pylib/pystring.idx new file mode 100644 index 000000000..f48e7e2ed --- /dev/null +++ b/pylib/pystring.idx @@ -0,0 +1 @@ +nimTitle pystring pylib/pystring.html module src/pylib/pystring 0 diff --git a/pylib/pystring/consts.html b/pylib/pystring/consts.html new file mode 100644 index 000000000..8f0825c19 --- /dev/null +++ b/pylib/pystring/consts.html @@ -0,0 +1,111 @@ + + + + + + + +src/pylib/pystring/consts + + + + + + + + + + + + + + + + +
+
+

src/pylib/pystring/consts

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Consts

+
+
+
unicodeSpaces = [9'i32, 10'i32, 11'i32, 12'i32, 13'i32, 28'i32, 29'i32, 30'i32,
+                 31'i32, 32'i32, 133'i32, 160'i32, 5760'i32, 8192'i32, 8193'i32,
+                 8194'i32, 8195'i32, 8196'i32, 8197'i32, 8198'i32, 8199'i32,
+                 8200'i32, 8201'i32, 8202'i32, 8232'i32, 8233'i32, 8239'i32,
+                 8287'i32, 12288'i32]
+
+ + This differs Nim's unicodeSpaces(inner symbol) std/unicode. This has foour more characters than the latter: \x1C, \x1D, \x1E, \x1F + Source   +Edit   + +
+
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/pystring/consts.idx b/pylib/pystring/consts.idx new file mode 100644 index 000000000..7b9138751 --- /dev/null +++ b/pylib/pystring/consts.idx @@ -0,0 +1,2 @@ +nimTitle consts pylib/pystring/consts.html module src/pylib/pystring/consts 0 +nim unicodeSpaces pylib/pystring/consts.html#unicodeSpaces const unicodeSpaces 5 diff --git a/pylib/pystring/format.html b/pylib/pystring/format.html new file mode 100644 index 000000000..d0ffc4af6 --- /dev/null +++ b/pylib/pystring/format.html @@ -0,0 +1,131 @@ + + + + + + + +src/pylib/pystring/format + + + + + + + + + + + + + + + + +
+
+

src/pylib/pystring/format

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Templates

+
+
+
+
template format(s: PyStr; argKw: varargs[untyped]): PyStr
+
+ +

str.format

+

NOTE: s must be static (e.g. a str literal), as this will be expanded at compile-time

+ + Source   +Edit   + +
+
+
+
template format[T](value: T; format_spec: PyStr = ""): PyStr
+
+ + builtins.format + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/pystring/format.idx b/pylib/pystring/format.idx new file mode 100644 index 000000000..39ae0fc41 --- /dev/null +++ b/pylib/pystring/format.idx @@ -0,0 +1,4 @@ +nimTitle format pylib/pystring/format.html module src/pylib/pystring/format 0 +nim format pylib/pystring/format.html#format.t,T,PyStr template format[T](value: T; format_spec: PyStr = ""): PyStr 6 +nim format pylib/pystring/format.html#format.t,PyStr,varargs[untyped] template format(s: PyStr; argKw: varargs[untyped]): PyStr 10 +nimgrp format pylib/pystring/format.html#format-templates-all template 6 diff --git a/pylib/pystring/fstring.html b/pylib/pystring/fstring.html new file mode 100644 index 000000000..e98c289cc --- /dev/null +++ b/pylib/pystring/fstring.html @@ -0,0 +1,241 @@ + + + + + + + +src/pylib/pystring/fstring + + + + + + + + + + + + + + + + +
+
+

src/pylib/pystring/fstring

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

f-string

+

a string literal with a prefix of fr, Fr, rf of Rf behaves as if with a prefix of strformat.fmt.

+

and f"xxx" is different, where the escaped literals in string will be interpreted.

+ +

Example:

+
import src/pylib/pystring/fstring
+assert fr"\n" == "\\n"
+assert f"\n" == "\n"
+
+let s = "asd"
+
+assert f"[{s}]" == "[asd]"
+assert not compiles(fr s)

+ +
+

Macros

+
+
+
+
macro Fr(pattern: string{lit}): PyStr
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
macro fr(pattern: string{lit}): PyStr
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
macro rf(pattern: string{lit}): PyStr
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
macro Rf(pattern: string{lit}): PyStr
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template f(s: string{lit}): PyStr
+
+ +

Python F-String.

+

Not the same as Nim's fmt"xxx" as that's equal to fmt r"xxx", a.k.a fr"xx" in Python

+

Any escape-translation error is reported at compile-time, with information of filename and line number

+ +

Unicode

\Uhhhhhhhh is supported as Python's, while Nim's \U{...} is unsupported but \u{...} is reserved

+ +

oct

\\[0-7]{1,3} in f-string will be interpreted as octal digit as Python,

+

instead of decimal as Nim.

+ +

multiline

the following shows the deature of Nim's multiline string which is different from Python's

+

assert "" == """
+"""
+
+## Unicode Names
+`\N{name}` is not supported yet.
+

+ +

Example:

+
assert f"\n" == "\n"
+assert f"123{'a'}\n456" == "123a\n456"
+
+assert f"\U0001f451" == "👑"
+
+assert f"\10" == "\x08"   # nim's "\10" means chr(10)
+
+assert f"""\t123
+""" == "\t123\n"  # even if the source code's newline is crlf.
+ Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/pystring/fstring.idx b/pylib/pystring/fstring.idx new file mode 100644 index 000000000..d5607c692 --- /dev/null +++ b/pylib/pystring/fstring.idx @@ -0,0 +1,9 @@ +nimTitle fstring pylib/pystring/fstring.html module src/pylib/pystring/fstring 0 +nim fr pylib/pystring/fstring.html#fr.m macro fr(pattern: string{lit}): PyStr 29 +nim Fr pylib/pystring/fstring.html#Fr.m_2 macro Fr(pattern: string{lit}): PyStr 30 +nim rf pylib/pystring/fstring.html#rf.m macro rf(pattern: string{lit}): PyStr 31 +nim Rf pylib/pystring/fstring.html#Rf.m_2 macro Rf(pattern: string{lit}): PyStr 32 +nim f pylib/pystring/fstring.html#f.t template f(s: string{lit}): PyStr 34 +heading Unicode pylib/pystring/fstring.html#unicode Unicode 0 +heading oct pylib/pystring/fstring.html#oct oct 0 +heading multiline pylib/pystring/fstring.html#multiline multiline 0 diff --git a/pylib/pystring/split/common.html b/pylib/pystring/split/common.html new file mode 100644 index 000000000..47f52245c --- /dev/null +++ b/pylib/pystring/split/common.html @@ -0,0 +1,127 @@ + + + + + + + +src/pylib/pystring/split/common + + + + + + + + + + + + + + + + +
+
+

src/pylib/pystring/split/common

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
func ISSPACE(s: PyStr; pos: int): bool {....raises: [], tags: [], forbids: [].}
+
+ + Checks unicode space at unicode char's pos + Source   +Edit   + +
+
+ +
+ +
+
+ + +
+
+ + +
+
+ + + diff --git a/pylib/pystring/split/common.idx b/pylib/pystring/split/common.idx new file mode 100644 index 000000000..095f3e325 --- /dev/null +++ b/pylib/pystring/split/common.idx @@ -0,0 +1,2 @@ +nimTitle common pylib/pystring/split/common.html module src/pylib/pystring/split/common 0 +nim ISSPACE pylib/pystring/split/common.html#ISSPACE,PyStr,int proc ISSPACE(s: PyStr; pos: int): bool 8 diff --git a/pylib/pystring/split/reimporter.html b/pylib/pystring/split/reimporter.html new file mode 100644 index 000000000..e88b5f2af --- /dev/null +++ b/pylib/pystring/split/reimporter.html @@ -0,0 +1,96 @@ + + + + + + + +src/pylib/pystring/split/reimporter + + + + + + + + + + + + + + + + +
+
+

src/pylib/pystring/split/reimporter

+ + + +
+
+ + + diff --git a/pylib/pystring/split/reimporter.idx b/pylib/pystring/split/reimporter.idx new file mode 100644 index 000000000..67b9fc3bd --- /dev/null +++ b/pylib/pystring/split/reimporter.idx @@ -0,0 +1 @@ +nimTitle reimporter pylib/pystring/split/reimporter.html module src/pylib/pystring/split/reimporter 0 diff --git a/pylib/pystring/split/rsplit.html b/pylib/pystring/split/rsplit.html new file mode 100644 index 000000000..4de169b2b --- /dev/null +++ b/pylib/pystring/split/rsplit.html @@ -0,0 +1,164 @@ + + + + + + + +src/pylib/pystring/split/rsplit + + + + + + + + + + + + + + + + +
+
+

src/pylib/pystring/split/rsplit

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
proc rsplit(a: PyStr; sep = None; maxsplit = -1): PyList[PyStr] {....raises: [],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc rsplit(a: PyStr; sep: StringLike; maxsplit = -1): PyList[PyStr]
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Iterators

+
+
+
+
iterator rsplit(a: PyStr; sep = None; maxsplit = -1): PyStr {....raises: [],
+    tags: [], forbids: [].}
+
+ +

with unicode whitespaces as sep.

+

treat runs of whitespaces as one sep (i.e. discard empty strings from result), while Nim's unicode doesn't has rsplit yet

+ + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/pystring/split/rsplit.idx b/pylib/pystring/split/rsplit.idx new file mode 100644 index 000000000..d7d02bdb2 --- /dev/null +++ b/pylib/pystring/split/rsplit.idx @@ -0,0 +1,5 @@ +nimTitle rsplit pylib/pystring/split/rsplit.html module src/pylib/pystring/split/rsplit 0 +nim rsplit pylib/pystring/split/rsplit.html#rsplit.i,PyStr,int iterator rsplit(a: PyStr; sep = None; maxsplit = -1): PyStr 9 +nim rsplit pylib/pystring/split/rsplit.html#rsplit,PyStr,int proc rsplit(a: PyStr; sep = None; maxsplit = -1): PyList[PyStr] 26 +nim rsplit pylib/pystring/split/rsplit.html#rsplit,PyStr,StringLike,int proc rsplit(a: PyStr; sep: StringLike; maxsplit = -1): PyList[PyStr] 37 +nimgrp rsplit pylib/pystring/split/rsplit.html#rsplit-procs-all proc 26 diff --git a/pylib/pystring/split/rsplit_whitespace.html b/pylib/pystring/split/rsplit_whitespace.html new file mode 100644 index 000000000..6f623025e --- /dev/null +++ b/pylib/pystring/split/rsplit_whitespace.html @@ -0,0 +1,119 @@ + + + + + + + +src/pylib/pystring/split/rsplit_whitespace + + + + + + + + + + + + + + + + +
+
+

src/pylib/pystring/split/rsplit_whitespace

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
proc rsplit_whitespace(pystr: PyStr; maxsplit = -1): PyList[PyStr] {....raises: [],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/pystring/split/rsplit_whitespace.idx b/pylib/pystring/split/rsplit_whitespace.idx new file mode 100644 index 000000000..755aef128 --- /dev/null +++ b/pylib/pystring/split/rsplit_whitespace.idx @@ -0,0 +1,2 @@ +nimTitle rsplit_whitespace pylib/pystring/split/rsplit_whitespace.html module src/pylib/pystring/split/rsplit_whitespace 0 +nim rsplit_whitespace pylib/pystring/split/rsplit_whitespace.html#rsplit_whitespace,PyStr,int proc rsplit_whitespace(pystr: PyStr; maxsplit = -1): PyList[PyStr] 5 diff --git a/pylib/pystring/split/split.html b/pylib/pystring/split/split.html new file mode 100644 index 000000000..2032119c8 --- /dev/null +++ b/pylib/pystring/split/split.html @@ -0,0 +1,202 @@ + + + + + + + +src/pylib/pystring/split/split + + + + + + + + + + + + + + + + +
+
+

src/pylib/pystring/split/split

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
proc split(a: PyStr; sep = None; maxsplit = -1): PyList[PyStr] {....raises: [],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc split(a: PyStr; sep: StringLike; maxsplit = -1): PyList[PyStr]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc splitlines(self: PyStr; keepends = false): PyList[PyStr] {....raises: [],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Iterators

+
+
+
+
iterator split(a: PyStr; sep = None; maxsplit = -1): PyStr {....raises: [],
+    tags: [], forbids: [].}
+
+ +

with unicode whitespaces as sep.

+

treat runs of whitespaces as one sep (i.e. discard empty strings from result), while Nim's unicode.split(s) doesn't

+ + Source   +Edit   + +
+
+
+
iterator split(a: PyStr; sep: StringLike; maxsplit = -1): PyStr {.inline.}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Exports

+
+ splitlines +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/pystring/split/split.idx b/pylib/pystring/split/split.idx new file mode 100644 index 000000000..b497d5082 --- /dev/null +++ b/pylib/pystring/split/split.idx @@ -0,0 +1,8 @@ +nimTitle split pylib/pystring/split/split.html module src/pylib/pystring/split/split 0 +nim split pylib/pystring/split/split.html#split.i,PyStr,int iterator split(a: PyStr; sep = None; maxsplit = -1): PyStr 12 +nim split pylib/pystring/split/split.html#split.i,PyStr,StringLike,int iterator split(a: PyStr; sep: StringLike; maxsplit = -1): PyStr 27 +nim split pylib/pystring/split/split.html#split,PyStr,int proc split(a: PyStr; sep = None; maxsplit = -1): PyList[PyStr] 32 +nim split pylib/pystring/split/split.html#split,PyStr,StringLike,int proc split(a: PyStr; sep: StringLike; maxsplit = -1): PyList[PyStr] 43 +nim splitlines pylib/pystring/split/split.html#splitlines,PyStr proc splitlines(self: PyStr; keepends = false): PyList[PyStr] 52 +nimgrp split pylib/pystring/split/split.html#split-procs-all proc 32 +nimgrp split pylib/pystring/split/split.html#split-iterators-all iterator 12 diff --git a/pylib/pystring/split/split_whitespace.html b/pylib/pystring/split/split_whitespace.html new file mode 100644 index 000000000..db55b1e18 --- /dev/null +++ b/pylib/pystring/split/split_whitespace.html @@ -0,0 +1,151 @@ + + + + + + + +src/pylib/pystring/split/split_whitespace + + + + + + + + + + + + + + + + +
+
+

src/pylib/pystring/split/split_whitespace

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
proc split_whitespace(pystr: PyStr; maxsplit = -1): PyList[PyStr] {....raises: [],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Iterators

+
+
+
+
iterator split_whitespace(pystr: PyStr; maxsplit = -1): PyStr {....raises: [],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/pystring/split/split_whitespace.idx b/pylib/pystring/split/split_whitespace.idx new file mode 100644 index 000000000..857225c5e --- /dev/null +++ b/pylib/pystring/split/split_whitespace.idx @@ -0,0 +1,3 @@ +nimTitle split_whitespace pylib/pystring/split/split_whitespace.html module src/pylib/pystring/split/split_whitespace 0 +nim split_whitespace pylib/pystring/split/split_whitespace.html#split_whitespace.i,PyStr,int iterator split_whitespace(pystr: PyStr; maxsplit = -1): PyStr 5 +nim split_whitespace pylib/pystring/split/split_whitespace.html#split_whitespace,PyStr,int proc split_whitespace(pystr: PyStr; maxsplit = -1): PyList[PyStr] 9 diff --git a/pylib/pystring/split/splitlinesIter.html b/pylib/pystring/split/splitlinesIter.html new file mode 100644 index 000000000..2f263d4df --- /dev/null +++ b/pylib/pystring/split/splitlinesIter.html @@ -0,0 +1,119 @@ + + + + + + + +src/pylib/pystring/split/splitlinesIter + + + + + + + + + + + + + + + + +
+
+

src/pylib/pystring/split/splitlinesIter

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Iterators

+
+
+
+
iterator splitlines(self: PyStr; keepends = false): PyStr {....raises: [],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/pystring/split/splitlinesIter.idx b/pylib/pystring/split/splitlinesIter.idx new file mode 100644 index 000000000..3a5b7ea87 --- /dev/null +++ b/pylib/pystring/split/splitlinesIter.idx @@ -0,0 +1,2 @@ +nimTitle splitlinesIter pylib/pystring/split/splitlinesIter.html module src/pylib/pystring/split/splitlinesIter 0 +nim splitlines pylib/pystring/split/splitlinesIter.html#splitlines.i,PyStr iterator splitlines(self: PyStr; keepends = false): PyStr 25 diff --git a/pylib/pystring/strbltins.html b/pylib/pystring/strbltins.html new file mode 100644 index 000000000..4cc7da858 --- /dev/null +++ b/pylib/pystring/strbltins.html @@ -0,0 +1,357 @@ + + + + + + + +src/pylib/pystring/strbltins + + + + + + + + + + + + + + + + +
+
+

src/pylib/pystring/strbltins

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
func ascii(us: PyStr): PyStr {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func ascii(us: string): PyStr {....raises: [], tags: [], forbids: [].}
+
+ + +

Example:

+
assert ascii("𐀀") == r"'\U00010000'"
+assert ascii("đ") == r"'\u0111'"
+assert ascii("和") == r"'\u548c'"
+let s = ascii("v我\n\e")
+when not defined(useNimCharEsc):
+  let rs = r"'v\u6211\n\x1b'"
+else:
+  let rs = r"'v\u6211\n\e'"
+assert s == rs
+assert ascii("\"") == "'\"'"
+assert ascii("\"'") == "'\"\\''"
+let s2 = ascii("'")
+when not defined(singQuotedStr):
+  let rs2 = "\"'\""
+else:
+  let rs2 = r"'\''"
+assert s2 == rs2
+ Source   +Edit   + +
+
+ +
+
+
+
func bin(a`gensym13: SomeInteger): PyStr
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func chr(a: SomeInteger): PyStr
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func hex(a`gensym16: SomeInteger): PyStr
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func oct(a`gensym10: SomeInteger): PyStr
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc ord(a: PyStr): int {....raises: [TypeError], tags: [], forbids: [].}
+
+ + Raises TypeError if len(a) is not 1. +

Example:

+
doAssert ord("δ") == 0x03b4
+ Source   +Edit   + +
+
+ +
+
+
+
func ord1(a: PyStr): int {....raises: [], tags: [], forbids: [].}
+
+ + +

Example:

+
assert ord1("123") == ord("1")
+ Source   +Edit   + +
+
+ +
+
+
+
func pyrepr(s: StringLike): PyStr
+
+ + Shortcut for str(pyreprImpl($s))) +

Example:

+
# NOTE: string literal's `repr` is `system.repr`, as following. 
+assert repr("\"") == "\"\\\"\""   # string literal of "\""
+# use pyrepr for any StringLike and returns a PyStr
+assert pyrepr("\"") == "'\"'"
+ Source   +Edit   + +
+
+ +
+
+
+
func repr(x: PyStr): string {....raises: [], tags: [], forbids: [].}
+
+ +

Overwites system.repr for PyStr

+

The same as proc ascii except for unicode chars being remained AS-IS, and returns Nim's string.

+ + Source   +Edit   + +
+
+ +
+
+
+
func reversed(s: PyStr): PyStr {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template ascii(a: untyped): PyStr
+
+ + As repr(), return a string containing a printable representation of an object, but escape the non-ASCII characters in the string returned by repr() using x, u, or U escapes +

Example:

+
assert ascii(6) == "6"
+ Source   +Edit   + +
+
+
+
template ascii(c: char): PyStr
+
+ + we regard 'x' as a str (so as in python) +

Example:

+
assert ascii('c') == "'c'"
+ Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/pystring/strbltins.idx b/pylib/pystring/strbltins.idx new file mode 100644 index 000000000..c243c6a9e --- /dev/null +++ b/pylib/pystring/strbltins.idx @@ -0,0 +1,16 @@ +nimTitle strbltins pylib/pystring/strbltins.html module src/pylib/pystring/strbltins 0 +nim reversed pylib/pystring/strbltins.html#reversed,PyStr proc reversed(s: PyStr): PyStr 9 +nim chr pylib/pystring/strbltins.html#chr,SomeInteger proc chr(a: SomeInteger): PyStr 12 +nim ord1 pylib/pystring/strbltins.html#ord1,PyStr proc ord1(a: PyStr): int 18 +nim ord pylib/pystring/strbltins.html#ord,PyStr proc ord(a: PyStr): int 23 +nim pyrepr pylib/pystring/strbltins.html#pyrepr,StringLike proc pyrepr(s: StringLike): PyStr 35 +nim repr pylib/pystring/strbltins.html#repr,PyStr proc repr(x: PyStr): string 44 +nim ascii pylib/pystring/strbltins.html#ascii,string proc ascii(us: string): PyStr 51 +nim ascii pylib/pystring/strbltins.html#ascii,PyStr proc ascii(us: PyStr): PyStr 72 +nim ascii pylib/pystring/strbltins.html#ascii.t,char template ascii(c: char): PyStr 75 +nim ascii pylib/pystring/strbltins.html#ascii.t,untyped template ascii(a: untyped): PyStr 82 +nim oct pylib/pystring/strbltins.html#oct,SomeInteger proc oct(a`gensym10: SomeInteger): PyStr 110 +nim bin pylib/pystring/strbltins.html#bin,SomeInteger proc bin(a`gensym13: SomeInteger): PyStr 111 +nim hex pylib/pystring/strbltins.html#hex,SomeInteger proc hex(a`gensym16: SomeInteger): PyStr 112 +nimgrp ascii pylib/pystring/strbltins.html#ascii-procs-all proc 51 +nimgrp ascii pylib/pystring/strbltins.html#ascii-templates-all template 75 diff --git a/pylib/pystring/strimpl.html b/pylib/pystring/strimpl.html new file mode 100644 index 000000000..982dbc398 --- /dev/null +++ b/pylib/pystring/strimpl.html @@ -0,0 +1,777 @@ + + + + + + + +src/pylib/pystring/strimpl + + + + + + + + + + + + + + + + +
+
+

src/pylib/pystring/strimpl

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Types

+
+
+
PyStr = distinct string
+
+ + Python str, use func str to get an instance + Source   +Edit   + +
+
+
+
StringLike = string | char | PyStr
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
func `$`(self: PyStr): string {.borrow, ...raises: [], tags: [], forbids: [].}
+
+ + to Nim string + Source   +Edit   + +
+
+ +
+
+
+
func `+`(self: PyStr; s: PyStr): PyStr {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func `+`(self: PyStr; s: StringLike): PyStr
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func `+=`(mself; s: char) {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func `+=`(mself; s: PyStr) {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func `+=`(mself; s: string) {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func `==`(o: string; self: PyStr): bool {.borrow, ...raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func `==`(self: PyStr; o: PyStr): bool {.borrow, ...raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func `==`(self: PyStr; o: string): bool {.borrow, ...raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func `[]`(self: PyStr; i: HSlice[int, BackwardsIndex]): PyStr {....raises: [],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func `[]`(self: PyStr; i: int): PyStr {....raises: [], tags: [], forbids: [].}
+
+ + +

Example:

+
assert str("你好")[1] == str("好")

str.__getitem__(int)

+

i may be negative to index from backward.

+ + Source   +Edit   + +
+
+
+
func `[]`(self: PyStr; i: Slice[int]): PyStr {....raises: [], tags: [], forbids: [].}
+
+ + EXT. s[1..2] means s[1:3], and the latter is not valid Nim code + Source   +Edit   + +
+
+ +
+
+
+
func byteLen(self: PyStr): int {....raises: [], tags: [], forbids: [].}
+
+ + EXT. len of bytes + Source   +Edit   + +
+
+ +
+
+
+
func contains(s: PyStr; c: char): bool {.borrow.}
+
+ + + Source   +Edit   + +
+
+
+
func contains(s: PyStr; c: PyStr): bool {.borrow, ...raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func contains(s: PyStr; c: string): bool {.borrow, ...raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func fspath(self: PyStr): PyStr {....raises: [], tags: [], forbids: [].}
+
+ + make a PathLike + Source   +Edit   + +
+
+ +
+
+
+
func getChar(self: PyStr; i: Natural): char {....raises: [], tags: [], forbids: [].}
+
+ + EXT. get char by byte index. + Source   +Edit   + +
+
+ +
+
+
+
func len(c: char): int {....raises: [], tags: [], forbids: [].}
+
+ + len('c'), always returns 1 + Source   +Edit   + +
+
+
+
func len(self: PyStr): int {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func runeAtPos(self: PyStr; pos: int): Rune {.borrow, ...raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc runeLenAt(self: PyStr; i: Natural): int {.borrow, ...raises: [], tags: [],
+    forbids: [].}
+
+ + EXT. i is byte index + Source   +Edit   + +
+
+ +
+
+
+
func str(a: Rune): PyStr {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func str(c: char): PyStr {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func str(object = ""): PyStr {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func str(self: PyStr): PyStr {....raises: [], tags: [], forbids: [].}
+
+ + copy + Source   +Edit   + +
+
+ +
+
+
+
proc substr(self: PyStr; start, last: int): PyStr {.borrow, ...raises: [],
+    tags: [], forbids: [].}
+
+ + EXT. byte index + Source   +Edit   + +
+
+ +
+
+
+
func toNimStr(self: PyStr): string {....deprecated: "use toNimString instead. will be removed since 0.10",
+                                     raises: [], tags: [], forbids: [].}
+
+
+ Deprecated: use toNimString instead. will be removed since 0.10 +
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Iterators

+
+
+
+
iterator chars(self: PyStr): char {....raises: [], tags: [], forbids: [].}
+
+ + EXT. + Source   +Edit   + +
+
+ +
+
+
+
iterator items(self: PyStr): PyStr {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
iterator runes(self: PyStr): Rune {....raises: [], tags: [], forbids: [].}
+
+ + EXT. + Source   +Edit   + +
+
+ +
+ +
+
+
+

Converters

+
+
+
+
converter toNimString(self: PyStr): string {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
converter toPyStr(s: char): PyStr {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
converter toPyStr(s: Rune): PyStr {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
converter toPyStr(s: string): PyStr {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template `and`(a, b: PyStr): PyStr
+
+ + Mimics Python str and str -> str. Returns a if a is not empty, otherwise b (even if it's empty) + Source   +Edit   + +
+
+ +
+
+
+
template `not`(s: PyStr): bool
+
+ + +

Mimics Python not str -> bool.

"not" for strings, return true if the string is not nil or empty.

+ + Source   +Edit   + +
+
+ +
+
+
+
template `or`(a, b: PyStr): PyStr
+
+ + Mimics Python str or str -> str. Returns a if a is not empty, otherwise b (even if it's empty) + Source   +Edit   + +
+
+ +
+
+
+
template str[O: object](o: O): PyStr
+
+ + + Source   +Edit   + +
+
+
+
template str[T](a: T): PyStr
+
+ +

convert any object based on repr

+

This is alreadly a fallback, used for types without str defined.

+

In Python, if a object's type has no __str__, then it falls to use __repr__

+ + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/pystring/strimpl.idx b/pylib/pystring/strimpl.idx new file mode 100644 index 000000000..ac1c8c45a --- /dev/null +++ b/pylib/pystring/strimpl.idx @@ -0,0 +1,53 @@ +nimTitle strimpl pylib/pystring/strimpl.html module src/pylib/pystring/strimpl 0 +nim PyStr pylib/pystring/strimpl.html#PyStr type PyStr 6 +nim StringLike pylib/pystring/strimpl.html#StringLike type StringLike 8 +nim str pylib/pystring/strimpl.html#str,PyStr proc str(self: PyStr): PyStr 10 +nim str pylib/pystring/strimpl.html#str,string proc str(object = ""): PyStr 11 +nim str pylib/pystring/strimpl.html#str,Rune proc str(a: Rune): PyStr 12 +nim str pylib/pystring/strimpl.html#str,char proc str(c: char): PyStr 13 +nim str pylib/pystring/strimpl.html#str.t,O template str[O: object](o: O): PyStr 15 +nim str pylib/pystring/strimpl.html#str.t,T template str[T](a: T): PyStr 17 +nim `$` pylib/pystring/strimpl.html#$ proc `$`(self: PyStr): string 30 +nim fspath pylib/pystring/strimpl.html#fspath proc fspath(self: PyStr): PyStr 31 +nim toNimStr pylib/pystring/strimpl.html#toNimStr proc toNimStr(self: PyStr): string 32 +nim toNimString pylib/pystring/strimpl.html#toNimString.c converter toNimString(self: PyStr): string 34 +nim toPyStr pylib/pystring/strimpl.html#toPyStr.c,string converter toPyStr(s: string): PyStr 35 +nim toPyStr pylib/pystring/strimpl.html#toPyStr.c,char converter toPyStr(s: char): PyStr 36 +nim toPyStr pylib/pystring/strimpl.html#toPyStr.c,Rune converter toPyStr(s: Rune): PyStr 37 +nim contains pylib/pystring/strimpl.html#contains,PyStr,char proc contains(s: PyStr; c: char): bool 39 +nim contains pylib/pystring/strimpl.html#contains,PyStr,string proc contains(s: PyStr; c: string): bool 40 +nim contains pylib/pystring/strimpl.html#contains,PyStr,PyStr proc contains(s: PyStr; c: PyStr): bool 41 +nim `==` pylib/pystring/strimpl.html#==,,PyStr proc `==`(self: PyStr; o: PyStr): bool 43 +nim `==` pylib/pystring/strimpl.html#==,,string proc `==`(self: PyStr; o: string): bool 44 +nim `==` pylib/pystring/strimpl.html#==,string, proc `==`(o: string; self: PyStr): bool 45 +nim `+` pylib/pystring/strimpl.html#+,,PyStr proc `+`(self: PyStr; s: PyStr): PyStr 50 +nim `+` pylib/pystring/strimpl.html#+,,StringLike proc `+`(self: PyStr; s: StringLike): PyStr 51 +nim `+=` pylib/pystring/strimpl.html#+=,,PyStr proc `+=`(mself; s: PyStr) 53 +nim `+=` pylib/pystring/strimpl.html#+=,,char proc `+=`(mself; s: char) 54 +nim `+=` pylib/pystring/strimpl.html#+=,,string proc `+=`(mself; s: string) 55 +nim len pylib/pystring/strimpl.html#len proc len(self: PyStr): int 57 +nim len pylib/pystring/strimpl.html#len,char proc len(c: char): int 58 +nim byteLen pylib/pystring/strimpl.html#byteLen proc byteLen(self: PyStr): int 59 +nim runeLenAt pylib/pystring/strimpl.html#runeLenAt,,Natural proc runeLenAt(self: PyStr; i: Natural): int 60 +nim substr pylib/pystring/strimpl.html#substr,,int,int proc substr(self: PyStr; start, last: int): PyStr 61 +nim runeAtPos pylib/pystring/strimpl.html#runeAtPos,,int proc runeAtPos(self: PyStr; pos: int): Rune 62 +nim getChar pylib/pystring/strimpl.html#getChar,,Natural proc getChar(self: PyStr; i: Natural): char 72 +nim `[]` pylib/pystring/strimpl.html#[],,int proc `[]`(self: PyStr; i: int): PyStr 73 +nim `[]` pylib/pystring/strimpl.html#[],,Slice[int] proc `[]`(self: PyStr; i: Slice[int]): PyStr 87 +nim `[]` pylib/pystring/strimpl.html#[],,HSlice[int,BackwardsIndex] proc `[]`(self: PyStr; i: HSlice[int, BackwardsIndex]): PyStr 93 +nim items pylib/pystring/strimpl.html#items.i iterator items(self: PyStr): PyStr 96 +nim chars pylib/pystring/strimpl.html#chars.i iterator chars(self: PyStr): char 100 +nim runes pylib/pystring/strimpl.html#runes.i iterator runes(self: PyStr): Rune 104 +nim `and` pylib/pystring/strimpl.html#and.t,PyStr,PyStr template `and`(a, b: PyStr): PyStr 109 +nim `or` pylib/pystring/strimpl.html#or.t,PyStr,PyStr template `or`(a, b: PyStr): PyStr 114 +nim `not` pylib/pystring/strimpl.html#not.t,PyStr template `not`(s: PyStr): bool 119 +nimgrp == pylib/pystring/strimpl.html#==-procs-all proc 43 +nimgrp str pylib/pystring/strimpl.html#str-procs-all proc 10 +nimgrp + pylib/pystring/strimpl.html#+-procs-all proc 50 +nimgrp contains pylib/pystring/strimpl.html#contains-procs-all proc 39 +nimgrp [] pylib/pystring/strimpl.html#[]-procs-all proc 73 +nimgrp len pylib/pystring/strimpl.html#len-procs-all proc 57 +nimgrp += pylib/pystring/strimpl.html#+=-procs-all proc 53 +nimgrp topystr pylib/pystring/strimpl.html#toPyStr-converters-all converter 35 +nimgrp str pylib/pystring/strimpl.html#str-templates-all template 15 +heading Mimics Python not str -> bool. pylib/pystring/strimpl.html#mimics-python-not-str-minusgt-booldot Mimics Python not str -> bool. 0 diff --git a/pylib/pystring/strip.html b/pylib/pystring/strip.html new file mode 100644 index 000000000..731c9f12a --- /dev/null +++ b/pylib/pystring/strip.html @@ -0,0 +1,187 @@ + + + + + + + +src/pylib/pystring/strip + + + + + + + + + + + + + + + + +
+
+

src/pylib/pystring/strip

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Imports

+
+ consts, strimpl +
+
+
+

Procs

+
+
+
+
func lstrip(self: PyStr): PyStr {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func lstrip(self: PyStr; chars: PyStr): PyStr {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func rstrip(self: PyStr): PyStr {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func rstrip(self: PyStr; chars: PyStr): PyStr {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func strip(self: PyStr): PyStr {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func strip(self: PyStr; chars: PyStr): PyStr {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/pystring/strip.idx b/pylib/pystring/strip.idx new file mode 100644 index 000000000..f29ee5051 --- /dev/null +++ b/pylib/pystring/strip.idx @@ -0,0 +1,10 @@ +nimTitle strip pylib/pystring/strip.html module src/pylib/pystring/strip 0 +nim strip pylib/pystring/strip.html#strip,PyStr proc strip(self: PyStr): PyStr 24 +nim lstrip pylib/pystring/strip.html#lstrip,PyStr proc lstrip(self: PyStr): PyStr 25 +nim rstrip pylib/pystring/strip.html#rstrip,PyStr proc rstrip(self: PyStr): PyStr 26 +nim strip pylib/pystring/strip.html#strip,PyStr,PyStr proc strip(self: PyStr; chars: PyStr): PyStr 29 +nim lstrip pylib/pystring/strip.html#lstrip,PyStr,PyStr proc lstrip(self: PyStr; chars: PyStr): PyStr 31 +nim rstrip pylib/pystring/strip.html#rstrip,PyStr,PyStr proc rstrip(self: PyStr; chars: PyStr): PyStr 33 +nimgrp lstrip pylib/pystring/strip.html#lstrip-procs-all proc 25 +nimgrp strip pylib/pystring/strip.html#strip-procs-all proc 24 +nimgrp rstrip pylib/pystring/strip.html#rstrip-procs-all proc 26 diff --git a/pylib/pystring/strmeth.html b/pylib/pystring/strmeth.html new file mode 100644 index 000000000..9c24ba9a9 --- /dev/null +++ b/pylib/pystring/strmeth.html @@ -0,0 +1,864 @@ + + + + + + + +src/pylib/pystring/strmeth + + + + + + + + + + + + + + + + +
+
+

src/pylib/pystring/strmeth

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
func capitalize(a: PyStr): PyStr {....raises: [], tags: [], forbids: [].}
+
+ +

make the first character have title/upper case and the rest lower case.

+

changed when Python 3.8: the first character will have title case.

+

while Nim's unicode.capitalize only make the first character upper-case.

+ + Source   +Edit   + +
+
+ +
+
+
+
func casefold(a: PyStr): PyStr {....raises: [], tags: [], forbids: [].}
+
+ +
Admonition: +since Python 3.3
+

str.casefold()

+

str.lower() is used for most characters, but, for example, Cherokee letters is casefolded to their uppercase counterparts, and some will be converted to their normal case, e.g. "ß" -> "ss"

+ + Source   +Edit   + +
+
+ +
+
+
+
func center(a: PyStr; width: int; fillchar = ' '): PyStr {....raises: [], tags: [],
+    forbids: [].}
+
+ + Mimics Python str.center(width: int, fillchar: str=" ") -> str + Source   +Edit   + +
+
+
+
func center(a: PyStr; width: int; fillchar: PyStr): PyStr {....raises: [TypeError],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func count(a: PyStr; sub: PyStr): int {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func count(a: PyStr; sub: PyStr; start = 0; end: int): int {....raises: [],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func count(a: PyStr; sub: PyStr; start: int): int {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func endsWith(a: char; suffix: PyStr): bool {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func endsWith(a: PyStr; suffix: char): bool {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func endsWith[Suf: PyStr | tuple](a: PyStr; suffix: Suf; start, end: int): bool
+
+ + + Source   +Edit   + +
+
+
+
func endsWith[Suf: PyStr | tuple](a: PyStr; suffix: Suf; start: int): bool
+
+ + + Source   +Edit   + +
+
+
+
func endsWith[Tup: tuple](a: PyStr; suffix: Tup): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func expandtabs(a: PyStr; tabsize = 8): PyStr {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func find(a: PyStr; b: PyStr; start = 0; end = len(a)): int {....raises: [],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func index(a, b: PyStr; start = 0; end = len(a)): int {.
+    ...raises: [ValueError, Exception], tags: [RootEffect], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func isalpha(a: PyStr): bool {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func isascii(a: PyStr): bool {....raises: [], tags: [], forbids: [].}
+
+ +
Admonition: +since Python 3.7
+ + Source   +Edit   + +
+
+
+
func isascii(a: Rune): bool {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func islower(a: PyStr): bool {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func isspace(a: PyStr): bool {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func istitle(a: PyStr): bool {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func isupper(a: PyStr): bool {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func join[T](sep: PyStr; a: openArray[T]): PyStr
+
+ + Mimics Python join() -> string + Source   +Edit   + +
+
+ +
+
+
+
func ljust(a: PyStr; width: int; fillchar = ' '): PyStr {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func ljust(a: PyStr; width: int; fillchar: PyStr): PyStr {....raises: [TypeError],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func lower(a: PyStr): PyStr {....raises: [], tags: [], forbids: [].}
+
+ +

str.lower

+

not the same as Nim's unicode.toLower, see examples

+ +

Example:

+
import std/unicode
+let dotI = Rune 0x0130  # İ  (LATIN CAPITAL LETTER I WITH DOT ABOVE)
+assert str(dotI).lower() == "i\u0307"  ## i̇ (\u0207 is a upper dot)
+assert dotI.toLower() == Rune('i')
+ Source   +Edit   + +
+
+ +
+
+
+
func partition(a: PyStr; sep: PyStr): tuple[before, sep, after: PyStr] {.
+    ...raises: [ValueError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func removeprefix(a: PyStr; suffix: PyStr): PyStr {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func removesuffix(a: PyStr; suffix: PyStr): PyStr {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func replace(a: PyStr; sub, by: PyStr | char): PyStr
+
+ + + Source   +Edit   + +
+
+
+
func replace(a: PyStr; sub, by: PyStr | char; count: int): PyStr
+
+ +

str.replace(sub, by, count = -1)

+

count may be negative or zero.

+ + Source   +Edit   + +
+
+ +
+
+
+
func rfind(a: PyStr; b: PyStr; start = 0; end = len(a)): int {....raises: [],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func rindex(a, b: PyStr; start = 0; end = len(a)): int {.
+    ...raises: [ValueError, Exception], tags: [RootEffect], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func rjust(a: PyStr; width: int; fillchar = ' '): PyStr {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func rjust(a: PyStr; width: int; fillchar: PyStr): PyStr {....raises: [TypeError],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func rpartition(a: PyStr; sep: PyStr): tuple[before, sep, after: PyStr] {.
+    ...raises: [ValueError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func startsWith(a: char; suffix: PyStr): bool {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func startsWith(a: PyStr; suffix: char): bool {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func startsWith[Suf: PyStr | tuple](a: PyStr; suffix: Suf; start, end: int): bool
+
+ + + Source   +Edit   + +
+
+
+
func startsWith[Suf: PyStr | tuple](a: PyStr; suffix: Suf; start: int): bool
+
+ + + Source   +Edit   + +
+
+
+
func startsWith[Tup: tuple](a: PyStr; suffix: Tup): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func title(a: PyStr): PyStr {....raises: [], tags: [], forbids: [].}
+
+ +

str.title()

+

not the same as title proc in std/unicode, see example.

+ +

Example:

+
let s = "lj"  # \u01c9
+let u = str(s)
+assert u.title() == "Lj"  # \u01c8
+import std/unicode
+assert unicode.title(s) == "LJ"  # \u01c7
+ Source   +Edit   + +
+
+ +
+
+
+
func upper(a: PyStr): PyStr {....raises: [], tags: [], forbids: [].}
+
+ +

str.upper

+

not the same as Nim's unicode.toUpper, see examples

+ +

Example:

+
import std/unicode
+let a = "ᾷ"
+# GREEK SMALL LETTER ALPHA WITH PERISPOMENI AND YPOGEGRAMMENI
+assert str(a).upper() == "Α͂Ι"  # 3 chars
+assert a.toUpper() == a   # Nim just maps it as-is.
+# There is more examples... (101 characters in total)
+ Source   +Edit   + +
+
+ +
+
+
+
func zfill(a: PyStr; width: int): PyStr {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template `*`(a: StringLike; i: int): PyStr
+
+ + + Source   +Edit   + +
+
+
+
template `*`(i: int; a: StringLike): PyStr
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ + +
+
+ + +
+
+ + + diff --git a/pylib/pystring/strmeth.idx b/pylib/pystring/strmeth.idx new file mode 100644 index 000000000..5f38a5c6e --- /dev/null +++ b/pylib/pystring/strmeth.idx @@ -0,0 +1,56 @@ +nimTitle strmeth pylib/pystring/strmeth.html module src/pylib/pystring/strmeth 0 +nim `*` pylib/pystring/strmeth.html#*.t,StringLike,int template `*`(a: StringLike; i: int): PyStr 49 +nim `*` pylib/pystring/strmeth.html#*.t,int,StringLike template `*`(i: int; a: StringLike): PyStr 52 +nim count pylib/pystring/strmeth.html#count,PyStr,PyStr proc count(a: PyStr; sub: PyStr): int 56 +nim count pylib/pystring/strmeth.html#count,PyStr,PyStr,int proc count(a: PyStr; sub: PyStr; start: int): int 59 +nim count pylib/pystring/strmeth.html#count,PyStr,PyStr,int,int proc count(a: PyStr; sub: PyStr; start = 0; end: int): int 62 +nim casefold pylib/pystring/strmeth.html#casefold,PyStr proc casefold(a: PyStr): PyStr 70 +nim lower pylib/pystring/strmeth.html#lower,PyStr proc lower(a: PyStr): PyStr 95 +nim upper pylib/pystring/strmeth.html#upper,PyStr proc upper(a: PyStr): PyStr 105 +nim title pylib/pystring/strmeth.html#title,PyStr proc title(a: PyStr): PyStr 141 +nim capitalize pylib/pystring/strmeth.html#capitalize,PyStr proc capitalize(a: PyStr): PyStr 162 +nim startsWith pylib/pystring/strmeth.html#startsWith,PyStr,char proc startsWith(a: PyStr; suffix: char): bool 185 +nim startsWith pylib/pystring/strmeth.html#startsWith,char,PyStr proc startsWith(a: char; suffix: PyStr): bool 187 +nim startsWith pylib/pystring/strmeth.html#startsWith,PyStr,Tup proc startsWith[Tup: tuple](a: PyStr; suffix: Tup): bool 189 +nim startsWith pylib/pystring/strmeth.html#startsWith,PyStr,Suf,int proc startsWith[Suf: PyStr | tuple](a: PyStr; suffix: Suf; start: int): bool 191 +nim startsWith pylib/pystring/strmeth.html#startsWith,PyStr,Suf,int,int proc startsWith[Suf: PyStr | tuple](a: PyStr; suffix: Suf; start, end: int): bool 197 +nim endsWith pylib/pystring/strmeth.html#endsWith,PyStr,char proc endsWith(a: PyStr; suffix: char): bool 185 +nim endsWith pylib/pystring/strmeth.html#endsWith,char,PyStr proc endsWith(a: char; suffix: PyStr): bool 187 +nim endsWith pylib/pystring/strmeth.html#endsWith,PyStr,Tup proc endsWith[Tup: tuple](a: PyStr; suffix: Tup): bool 189 +nim endsWith pylib/pystring/strmeth.html#endsWith,PyStr,Suf,int proc endsWith[Suf: PyStr | tuple](a: PyStr; suffix: Suf; start: int): bool 191 +nim endsWith pylib/pystring/strmeth.html#endsWith,PyStr,Suf,int,int proc endsWith[Suf: PyStr | tuple](a: PyStr; suffix: Suf; start, end: int): bool 198 +nim find pylib/pystring/strmeth.html#find,PyStr,PyStr,int proc find(a: PyStr; b: PyStr; start = 0; end = len(a)): int 200 +nim rfind pylib/pystring/strmeth.html#rfind,PyStr,PyStr,int proc rfind(a: PyStr; b: PyStr; start = 0; end = len(a)): int 206 +nim index pylib/pystring/strmeth.html#index,PyStr,PyStr,int proc index(a, b: PyStr; start = 0; end = len(a)): int 212 +nim rindex pylib/pystring/strmeth.html#rindex,PyStr,PyStr,int proc rindex(a, b: PyStr; start = 0; end = len(a)): int 218 +nim isascii pylib/pystring/strmeth.html#isascii,Rune proc isascii(a: Rune): bool 225 +nim isascii pylib/pystring/strmeth.html#isascii,PyStr proc isascii(a: PyStr): bool 236 +nim isalpha pylib/pystring/strmeth.html#isalpha,PyStr proc isalpha(a: PyStr): bool 239 +nim islower pylib/pystring/strmeth.html#islower,PyStr proc islower(a: PyStr): bool 244 +nim isupper pylib/pystring/strmeth.html#isupper,PyStr proc isupper(a: PyStr): bool 245 +nim istitle pylib/pystring/strmeth.html#istitle,PyStr proc istitle(a: PyStr): bool 246 +nim isspace pylib/pystring/strmeth.html#isspace,PyStr proc isspace(a: PyStr): bool 250 +nim center pylib/pystring/strmeth.html#center,PyStr,int,char proc center(a: PyStr; width: int; fillchar = ' '): PyStr 252 +nim ljust pylib/pystring/strmeth.html#ljust,PyStr,int,char proc ljust(a: PyStr; width: int; fillchar = ' '): PyStr 256 +nim rjust pylib/pystring/strmeth.html#rjust,PyStr,int,char proc rjust(a: PyStr; width: int; fillchar = ' '): PyStr 258 +nim center pylib/pystring/strmeth.html#center,PyStr,int,PyStr proc center(a: PyStr; width: int; fillchar: PyStr): PyStr 261 +nim ljust pylib/pystring/strmeth.html#ljust,PyStr,int,PyStr proc ljust(a: PyStr; width: int; fillchar: PyStr): PyStr 264 +nim rjust pylib/pystring/strmeth.html#rjust,PyStr,int,PyStr proc rjust(a: PyStr; width: int; fillchar: PyStr): PyStr 267 +nim zfill pylib/pystring/strmeth.html#zfill,PyStr,int proc zfill(a: PyStr; width: int): PyStr 270 +nim removeprefix pylib/pystring/strmeth.html#removeprefix,PyStr,PyStr proc removeprefix(a: PyStr; suffix: PyStr): PyStr 273 +nim removesuffix pylib/pystring/strmeth.html#removesuffix,PyStr,PyStr proc removesuffix(a: PyStr; suffix: PyStr): PyStr 275 +nim replace pylib/pystring/strmeth.html#replace,PyStr,, proc replace(a: PyStr; sub, by: PyStr | char): PyStr 278 +nim replace pylib/pystring/strmeth.html#replace,PyStr,,,int proc replace(a: PyStr; sub, by: PyStr | char; count: int): PyStr 281 +nim expandtabs pylib/pystring/strmeth.html#expandtabs,PyStr,int proc expandtabs(a: PyStr; tabsize = 8): PyStr 287 +nim join pylib/pystring/strmeth.html#join,PyStr,openArray[T] proc join[T](sep: PyStr; a: openArray[T]): PyStr 290 +nim partition pylib/pystring/strmeth.html#partition,PyStr,PyStr proc partition(a: PyStr; sep: PyStr): tuple[before, sep, after: PyStr] 294 +nim rpartition pylib/pystring/strmeth.html#rpartition,PyStr,PyStr proc rpartition(a: PyStr; sep: PyStr): tuple[before, sep, after: PyStr] 297 +nimgrp replace pylib/pystring/strmeth.html#replace-procs-all proc 278 +nimgrp startswith pylib/pystring/strmeth.html#startsWith-procs-all proc 197 +nimgrp isascii pylib/pystring/strmeth.html#isascii-procs-all proc 225 +nimgrp ljust pylib/pystring/strmeth.html#ljust-procs-all proc 256 +nimgrp rjust pylib/pystring/strmeth.html#rjust-procs-all proc 258 +nimgrp count pylib/pystring/strmeth.html#count-procs-all proc 56 +nimgrp endswith pylib/pystring/strmeth.html#endsWith-procs-all proc 198 +nimgrp center pylib/pystring/strmeth.html#center-procs-all proc 252 +nimgrp * pylib/pystring/strmeth.html#*-templates-all template 49 diff --git a/pylib/pystring/strops.html b/pylib/pystring/strops.html new file mode 100644 index 000000000..ff512ee29 --- /dev/null +++ b/pylib/pystring/strops.html @@ -0,0 +1,118 @@ + + + + + + + +src/pylib/pystring/strops + + + + + + + + + + + + + + + + +
+
+

src/pylib/pystring/strops

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Imports

+
+ strimpl +
+
+
+

Templates

+
+
+
+
template `<>`[A: StringLike; B: StringLike](a: A; b: B): bool
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/pystring/strops.idx b/pylib/pystring/strops.idx new file mode 100644 index 000000000..d910a8466 --- /dev/null +++ b/pylib/pystring/strops.idx @@ -0,0 +1,2 @@ +nimTitle strops pylib/pystring/strops.html module src/pylib/pystring/strops 0 +nim `<>` pylib/pystring/strops.html#<>.t,A,B template `<>`[A: StringLike; B: StringLike](a: A; b: B): bool 7 diff --git a/pylib/pystring/strprefix.html b/pylib/pystring/strprefix.html new file mode 100644 index 000000000..2af9f039a --- /dev/null +++ b/pylib/pystring/strprefix.html @@ -0,0 +1,129 @@ + + + + + + + +src/pylib/pystring/strprefix + + + + + + + + + + + + + + + + +
+
+

src/pylib/pystring/strprefix

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
func u(a: char{lit}): PyStr {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func u(s: static[string]{lit}): PyStr
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/pystring/strprefix.idx b/pylib/pystring/strprefix.idx new file mode 100644 index 000000000..9dd19bfe2 --- /dev/null +++ b/pylib/pystring/strprefix.idx @@ -0,0 +1,4 @@ +nimTitle strprefix pylib/pystring/strprefix.html module src/pylib/pystring/strprefix 0 +nim u pylib/pystring/strprefix.html#u proc u(s: static[string]{lit}): PyStr 5 +nim u pylib/pystring/strprefix.html#u_2 proc u(a: char{lit}): PyStr 9 +nimgrp u pylib/pystring/strprefix.html#u-procs-all proc 5 diff --git a/pylib/pystring/translate.html b/pylib/pystring/translate.html new file mode 100644 index 000000000..8ebcd37f4 --- /dev/null +++ b/pylib/pystring/translate.html @@ -0,0 +1,396 @@ + + + + + + + +src/pylib/pystring/translate + + + + + + + + + + + + + + + + +
+
+

src/pylib/pystring/translate

+
+ +
+ Source   +Edit   + +
+ +

str.translate


+

NOTE: Nim's KeyError is a subclass of ValueError instead of LookupError. Therefore when writing a custom TranslateTableABC or TypedTranslateTableABC for translate, beware a Nim's KeyError is not considered as a sign to leave such a character untouched, but will be just raised outside.

+

However, TranslateTable or StrTypedTranslateTable is handled via overload. Using them as translate table is fine.

+

+ +
+

Types

+
+
+
StrTypedTranslateTable = TableRef[int, PyStr]
+
+ + result of str.maketrans(keys, values) + Source   +Edit   + +
+
+
+
TranslateAction {.pure.} = enum
+  skip, aOrd, aChr, aStr
+
+ + + Source   +Edit   + +
+
+
+
TranslateTable = TableRef[int, TranslateTableVal]
+
+ + result of maketrans + Source   +Edit   + +
+
+
+
TranslateTableABC = concept self
+    self[int] is TranslateTableVal
+
+ + + Source   +Edit   + +
+
+
+
TranslateTableVal = object
+  case
+  of skip:
+    nil
+  of aOrd:
+    i*: int
+  of aChr:
+    c*: char
+  of aStr:
+    s*: PyStr
+
+ + + Source   +Edit   + +
+
+
+
TranslateValType = int | PyStr | char | NoneType
+
+ + + Source   +Edit   + +
+
+
+
TypedTranslateTableABC[V] = concept self
+    V
+    self[int] is V
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
func repr(table: TranslateTable): string {....raises: [], tags: [], forbids: [].}
+
+ + dict stringification. + Source   +Edit   + +
+
+ +
+
+
+
proc translate(s: PyStr; table: StrTypedTranslateTable): PyStr {.
+    ...raises: [TypeError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc translate(s: PyStr; table: TranslateTable): PyStr {.
+    ...raises: [TypeError, ValueError, KeyError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc translate(s: PyStr; table: TranslateTableABC): PyStr
+
+ + + Source   +Edit   + +
+
+
+
proc translate[K: TranslateValType](s: PyStr; table: TypedTranslateTableABC[K]): PyStr
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Macros

+
+
+
+
macro maketrans(_: typedesc[PyStr]; mapOrLit: untyped): TranslateTable
+
+ + str.maketrans with dict literal or a mapping +

Example:

+
let tbl = PyStr.maketrans({"a": None, "b": "123"})
+assert "axb".translate(tbl) == "x123"
+ Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template `$`(table: TranslateTable): string
+
+ + repr table + Source   +Edit   + +
+
+ +
+
+
+
template maketrans(_: typedesc[PyStr]; frm, to): StrTypedTranslateTable
+
+ +

frm, to shall be string/PyStr.

+

see Nim#23662 for why this is not defined as a proc with typed param-types

+ + Source   +Edit   + +
+
+
+
template maketrans(_: typedesc[PyStr]; frm, to, skip): TranslateTable
+
+ +

frm, to, skip shall be string/PyStr.

+

see Nim#23662 for why this is not defined as a proc with typed param-types

+ + Source   +Edit   + +
+
+ +
+ +
+
+ + +
+
+ + +
+
+ + + diff --git a/pylib/pystring/translate.idx b/pylib/pystring/translate.idx new file mode 100644 index 000000000..c36406970 --- /dev/null +++ b/pylib/pystring/translate.idx @@ -0,0 +1,19 @@ +nimTitle translate pylib/pystring/translate.html module src/pylib/pystring/translate 0 +nim TranslateValType pylib/pystring/translate.html#TranslateValType type TranslateValType 25 +nim TranslateAction pylib/pystring/translate.html#TranslateAction enum TranslateAction 26 +nim TranslateTableVal pylib/pystring/translate.html#TranslateTableVal object TranslateTableVal 28 +nim TranslateTableABC pylib/pystring/translate.html#TranslateTableABC type TranslateTableABC 34 +nim TypedTranslateTableABC pylib/pystring/translate.html#TypedTranslateTableABC type TypedTranslateTableABC 36 +nim TranslateTable pylib/pystring/translate.html#TranslateTable type TranslateTable 40 +nim StrTypedTranslateTable pylib/pystring/translate.html#StrTypedTranslateTable type StrTypedTranslateTable 41 +nim repr pylib/pystring/translate.html#repr,TranslateTable proc repr(table: TranslateTable): string 53 +nim `$` pylib/pystring/translate.html#$.t,TranslateTable template `$`(table: TranslateTable): string 71 +nim translate pylib/pystring/translate.html#translate,PyStr,TranslateTable proc translate(s: PyStr; table: TranslateTable): PyStr 93 +nim translate pylib/pystring/translate.html#translate,PyStr,StrTypedTranslateTable proc translate(s: PyStr; table: StrTypedTranslateTable): PyStr 101 +nim translate pylib/pystring/translate.html#translate,PyStr,TypedTranslateTableABC[K: TranslateValType] proc translate[K: TranslateValType](s: PyStr; table: TypedTranslateTableABC[K]): PyStr 105 +nim translate pylib/pystring/translate.html#translate,PyStr,TranslateTableABC proc translate(s: PyStr; table: TranslateTableABC): PyStr 113 +nim maketrans pylib/pystring/translate.html#maketrans.m,typedesc[PyStr],untyped macro maketrans(_: typedesc[PyStr]; mapOrLit: untyped): TranslateTable 190 +nim maketrans pylib/pystring/translate.html#maketrans.t,typedesc[PyStr],, template maketrans(_: typedesc[PyStr]; frm, to): StrTypedTranslateTable 201 +nim maketrans pylib/pystring/translate.html#maketrans.t,typedesc[PyStr],,, template maketrans(_: typedesc[PyStr]; frm, to, skip): TranslateTable 214 +nimgrp translate pylib/pystring/translate.html#translate-procs-all proc 93 +nimgrp maketrans pylib/pystring/translate.html#maketrans-templates-all template 201 diff --git a/pylib/pysugar.html b/pylib/pysugar.html new file mode 100644 index 000000000..72575a885 --- /dev/null +++ b/pylib/pysugar.html @@ -0,0 +1,202 @@ + + + + + + + +src/pylib/pysugar + + + + + + + + + + + + + + + + +
+
+

src/pylib/pysugar

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Macros

+
+
+
+
macro del(seqIdx: untyped)
+
+ +
  • del ls[idx] -> delitem(ls, idx);
  • +
  • del obj.attr -> compilation-error. Nim is static-typed,
  • +
+

dynamically deleting object's attributes is not allowed.

+ +

for more details.

+
Note: +Nim's del(seq, idx) is an O(1) operation, which moves the last element to idx
+ + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template `:=`[T](name; value: T): T
+
+ + Mimic Pythons Operator. + Source   +Edit   + +
+
+ +
+
+
+
template lambda(code: untyped): untyped
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template pass()
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ + +
+
+ + +
+
+ + + diff --git a/pylib/pysugar.idx b/pylib/pysugar.idx new file mode 100644 index 000000000..355d7be54 --- /dev/null +++ b/pylib/pysugar.idx @@ -0,0 +1,5 @@ +nimTitle pysugar pylib/pysugar.html module src/pylib/pysugar 0 +nim pass pylib/pysugar.html#pass.t template pass() 19 +nim lambda pylib/pysugar.html#lambda.t,untyped template lambda(code: untyped): untyped 21 +nim `:=` pylib/pysugar.html#:=.t,,T template `:=`[T](name; value: T): T 24 +nim del pylib/pysugar.html#del.m,untyped macro del(seqIdx: untyped) 31 diff --git a/pylib/pysugar/class.html b/pylib/pysugar/class.html new file mode 100644 index 000000000..652e2f2a2 --- /dev/null +++ b/pylib/pysugar/class.html @@ -0,0 +1,127 @@ + + + + + + + +src/pylib/pysugar/class + + + + + + + + + + + + + + + + +
+
+

src/pylib/pysugar/class

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Templates

+
+
+
+
template class(obj, body)
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ + +
+
+ + +
+
+ + + diff --git a/pylib/pysugar/class.idx b/pylib/pysugar/class.idx new file mode 100644 index 000000000..75b2359c5 --- /dev/null +++ b/pylib/pysugar/class.idx @@ -0,0 +1,2 @@ +nimTitle class pylib/pysugar/class.html module src/pylib/pysugar/class 0 +nim class pylib/pysugar/class.html#class.t,, template class(obj, body) 36 diff --git a/pylib/pysugar/parserWithCfg.html b/pylib/pysugar/parserWithCfg.html new file mode 100644 index 000000000..97a6c898a --- /dev/null +++ b/pylib/pysugar/parserWithCfg.html @@ -0,0 +1,163 @@ + + + + + + + +src/pylib/pysugar/parserWithCfg + + + + + + + + + + + + + + + + +
+
+

src/pylib/pysugar/parserWithCfg

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Consts

+
+
+
PyDedentDocString = true
+
+ + + Source   +Edit   + +
+
+
+
PySignatureSupportGenerics = true
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
func parserWithDefCfg(): PyAsgnRewriter {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ + +
+
+ + +
+
+ + + diff --git a/pylib/pysugar/parserWithCfg.idx b/pylib/pysugar/parserWithCfg.idx new file mode 100644 index 000000000..39ce15af0 --- /dev/null +++ b/pylib/pysugar/parserWithCfg.idx @@ -0,0 +1,4 @@ +nimTitle parserWithCfg pylib/pysugar/parserWithCfg.html module src/pylib/pysugar/parserWithCfg 0 +nim PySignatureSupportGenerics pylib/pysugar/parserWithCfg.html#PySignatureSupportGenerics const PySignatureSupportGenerics 7 +nim PyDedentDocString pylib/pysugar/parserWithCfg.html#PyDedentDocString const PyDedentDocString 8 +nim parserWithDefCfg pylib/pysugar/parserWithCfg.html#parserWithDefCfg proc parserWithDefCfg(): PyAsgnRewriter 10 diff --git a/pylib/pysugar/pydef.html b/pylib/pysugar/pydef.html new file mode 100644 index 000000000..5553d78db --- /dev/null +++ b/pylib/pysugar/pydef.html @@ -0,0 +1,228 @@ + + + + + + + +src/pylib/pysugar/pydef + + + + + + + + + + + + + + + + +
+
+

src/pylib/pysugar/pydef

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

python's def and async def

+

support:

+
  • param
  • +
  • param: type
  • +
  • param = defval
  • +
  • *args
  • +
  • -> restype
  • +
  • """doc-str""" or "doc-str"
  • +
  • nested def or async def
  • +
+

limits:

+
  • *args can only contain one type's arguments
  • +
  • can't combine type and defval i.e. param: type = defval is unsupported
  • +
  • for async def, only -> Future[void] can be omitted. Refer to std/asyncmacro for details
  • +
  • variables must be declared using let/var/const (this can be solved but is unnecessary)
  • +
+

unsupport:

+
  • generator (yield within def) TODO
  • +
  • **kws
  • +
  • * and / in parameters-list
  • +
+

see codes in runnableExamples for more details

+

+ +
+

Macros

+
+
+
+
macro async(defsign, body): untyped
+
+ + async def ... +

Example:

+
import std/async
+async def af():
+  discard "no restype mean Future[void]"
+async def afi() -> Future[int]:
+  return 3
+when defined(js):
+  await af()
+  echo await afi()
+else:
+  import std/asyncdispatch
+  waitFor af()
+  assert 3 == waitFor(afi())
+ Source   +Edit   + +
+
+ +
+
+
+
macro def(signature, body): untyped
+
+ + +

Example:

+
def add(a,b): return a + b # use auto as argtype and restype
+def addi(a: int, b = 1) -> int: return add(a, b)
+assert addi(3) == 4
+def nested(a):
+  def closure():
+    return a
+  return closure
+assert nested(3)() == 3
+def max(a, b, *args):
+  "This is doc-str: a python-like `max`"
+  def max2(a,b):
+    if a>b: return a
+    else: return b
+  result = max2(a, b)
+  for i in args:
+    result = max2(result, i)
+  return result
+assert max(1,4,2,5,0) == 5
+when PySignatureSupportGenerics:  # pysince 3.13
+  def sub[T](a: T, b: T) -> T:
+    return a - b
+  assert sub(4, 5) == -1
+
+  def f2[A, B](a: A, b: B) -> A:
+    return a + A(b)
+  assert int(2) == f2(1, 1.0)
+ Source   +Edit   + +
+
+ +
+
+
+
macro define(signature, body): untyped
+
+ +

almost the same as def, but is for template instead of proc

+

XXX: nesting define is not supported. If wanting, use template. however, def in define is allowed.

+ +

Example:

+
define templ(a): a+1  # note template has no implicit `result` variable
+assert templ(3) == 4
+ Source   +Edit   + +
+
+ +
+ +
+
+ + +
+
+ + +
+
+ + + diff --git a/pylib/pysugar/pydef.idx b/pylib/pysugar/pydef.idx new file mode 100644 index 000000000..79fa0346d --- /dev/null +++ b/pylib/pysugar/pydef.idx @@ -0,0 +1,4 @@ +nimTitle pydef pylib/pysugar/pydef.html module src/pylib/pysugar/pydef 0 +nim define pylib/pysugar/pydef.html#define.m,, macro define(signature, body): untyped 43 +nim def pylib/pysugar/pydef.html#def.m,, macro def(signature, body): untyped 54 +nim async pylib/pysugar/pydef.html#async.m,, macro async(defsign, body): untyped 86 diff --git a/pylib/pysugar/pywith.html b/pylib/pysugar/pywith.html new file mode 100644 index 000000000..5d71d5dcd --- /dev/null +++ b/pylib/pysugar/pywith.html @@ -0,0 +1,109 @@ + + + + + + + +src/pylib/pysugar/pywith + + + + + + + + + + + + + + + + +
+
+

src/pylib/pysugar/pywith

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Macros

+
+
+
+
macro with(args: varargs[untyped]): untyped
+
+ + Python-like with statement. Supports most of the possible variants Python with statement supports. Context managers are supported but need to use enter() and exit() or open() and close() instead of the underscored names. + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/pysugar/pywith.idx b/pylib/pysugar/pywith.idx new file mode 100644 index 000000000..7af8ad8d9 --- /dev/null +++ b/pylib/pysugar/pywith.idx @@ -0,0 +1,2 @@ +nimTitle pywith pylib/pysugar/pywith.html module src/pylib/pysugar/pywith 0 +nim with pylib/pysugar/pywith.html#with.m,varargs[untyped] macro with(args: varargs[untyped]): untyped 17 diff --git a/pylib/pysugar/stmt/chainCmp.html b/pylib/pysugar/stmt/chainCmp.html new file mode 100644 index 000000000..ec128d6ab --- /dev/null +++ b/pylib/pysugar/stmt/chainCmp.html @@ -0,0 +1,140 @@ + + + + + + + +src/pylib/pysugar/stmt/chainCmp + + + + + + + + + + + + + + + + +
+
+

src/pylib/pysugar/stmt/chainCmp

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Procs

+
+
+
+
proc expandChainImpl(cExp: NimNode): NimNode {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Macros

+
+
+
+
macro expandChain(cExp): bool
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/pysugar/stmt/chainCmp.idx b/pylib/pysugar/stmt/chainCmp.idx new file mode 100644 index 000000000..482134dc5 --- /dev/null +++ b/pylib/pysugar/stmt/chainCmp.idx @@ -0,0 +1,3 @@ +nimTitle chainCmp pylib/pysugar/stmt/chainCmp.html module src/pylib/pysugar/stmt/chainCmp 0 +nim expandChainImpl pylib/pysugar/stmt/chainCmp.html#expandChainImpl,NimNode proc expandChainImpl(cExp: NimNode): NimNode 40 +nim expandChain pylib/pysugar/stmt/chainCmp.html#expandChain.m macro expandChain(cExp): bool 44 diff --git a/pylib/pysugar/stmt/class.html b/pylib/pysugar/stmt/class.html new file mode 100644 index 000000000..9b19c6143 --- /dev/null +++ b/pylib/pysugar/stmt/class.html @@ -0,0 +1,257 @@ + + + + + + + +src/pylib/pysugar/stmt/class + + + + + + + + + + + + + + + + +
+
+

src/pylib/pysugar/stmt/class

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
proc classImpl(parser: var PySyntaxProcesser; obj, body: NimNode;
+               topLevel = true): NimNode
+
+ +

minic Python's class.

+

support def for method with nested def/class supported and super(...).method

+ +

NOTE:

+

Method Overwrite

Now the implement assume each def in each child class overwrite parent class's def, which is surely not always true,

+

What's more, it will be false in some less-noted cases:

+

class O:
+def f(self): return 1
+class O1(O):
+def f(self): return 1.0
The above code will cause Warning: use {.base.} for base methods; baseless methods are deprecated [UseBase]

+

as the rettype of previous one is int, while the latter is float, thus no override and no dynamic dispatch is performed.

+ +

super function

Now support super([self[,SubCls]]).f([arg,...])

+

However, only support the one usage above.

+

That's, neither a=super() nor super().a is supported

+

For the precious one, as now super is implemented via Nim's procCall, it's not easy to bind super()(aka. a SupCls instance) to a variable.

+

For the latter one, as Nim doesn't allow override SupCls's attr (lead to a compile-error), so if wantting the attr inherited from SupCls, just write it as-is (e.g. self.a) (Technologically, it can be implemented via std/macros owner)

+ + Source   +Edit   + +
+
+ +
+
+
+
proc init_subclass[T: ref](cls: typedesc[T])
+
+ + py's object.__init_subclass__ + Source   +Edit   + +
+
+ +
+
+
+
proc recReplaceSuperCall(n: NimNode; defSupCls: NimNode; start = 0;
+                         methKind = mkNorm): NimNode {....raises: [], tags: [],
+    forbids: [].}
+
+ + Recursively maps +

1.

super(...).f(...) to procCall(<SuperClass>(self).f(...))

+

The AST map:

+

Call
+DotExpr
+Call
+  Ident "super"
+  [<SuperClass>]
+  [Ident "self"]
+Ident "f"
+<args>
+
+|
+|
+v
+
+Command
+Ident "procCall"
+Call
+DotExpr
+  Call
+    <SuperClass>
+    Ident "self"
+  Ident "f"
+<args>

+ +

2

super(...).new/init_subclass(...) to <SuperClass>.new/init_subclass(...)

+ +

Example:

+
import std/[macros, strutils]
+macro checkSupSub(resStr: static string; b) =
+  let res = recReplaceSuperCall(b, ident"SupCls")
+  assert resStr == repr(res).strip(), repr(res)
+  result = newStmtList()
+checkSupSub("procCall(SupCls(self).f())"):
+  super().f()
+checkSupSub("procCall(SS(self).f(a, b))"):
+  super(SS, self).f(a, b)
+checkSupSub("a = procCall(SupCls(self).f(a, b))"):
+  a = super().f(a, b)
+checkSupSub("a = procCall(SupCls(self).f(procCall(SupCls(self).m()), b))"):
+  a = super().f(super().m(), b)
+checkSupSub("echo(1)"): echo(1)
+
+# NOTE: the following is not supported, so left unchanged
+checkSupSub("super()"): super()
+checkSupSub("super().a"): super().a
+ Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template new[T; R: ref](_: typedesc[R]; cls: typedesc[T]; _: varargs[untyped]): typedesc[
+    T]
+
+ + py's object.__new__ + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/pysugar/stmt/class.idx b/pylib/pysugar/stmt/class.idx new file mode 100644 index 000000000..85789843f --- /dev/null +++ b/pylib/pysugar/stmt/class.idx @@ -0,0 +1,10 @@ +nimTitle class pylib/pysugar/stmt/class.html module src/pylib/pysugar/stmt/class 0 +nim new pylib/pysugar/stmt/class.html#new.t,typedesc[R],typedesc[T],varargs[untyped] template new[T; R: ref](_: typedesc[R]; cls: typedesc[T]; _: varargs[untyped]): typedesc[\n T] 61 +nim init_subclass pylib/pysugar/stmt/class.html#init_subclass,typedesc[T] proc init_subclass[T: ref](cls: typedesc[T]) 66 +nim recReplaceSuperCall pylib/pysugar/stmt/class.html#recReplaceSuperCall,NimNode,NimNode,int proc recReplaceSuperCall(n: NimNode; defSupCls: NimNode; start = 0; methKind = mkNorm): NimNode 70 +nim classImpl pylib/pysugar/stmt/class.html#classImpl,PySyntaxProcesser,NimNode,NimNode proc classImpl(parser: var PySyntaxProcesser; obj, body: NimNode; topLevel = true): NimNode 286 +heading NOTE: pylib/pysugar/stmt/class.html#notecolon NOTE: 0 +heading Method Overwrite pylib/pysugar/stmt/class.html#notecolon-method-overwrite Method Overwrite 0 +heading nimsuper function pylib/pysugar/stmt/class.html#notecolon-nimsuper-function super function 0 +heading 1. pylib/pysugar/stmt/class.html#Z1dot 1. 0 +heading 2 pylib/pysugar/stmt/class.html#Z2 2 0 diff --git a/pylib/pysugar/stmt/decl.html b/pylib/pysugar/stmt/decl.html new file mode 100644 index 000000000..c0051a92d --- /dev/null +++ b/pylib/pysugar/stmt/decl.html @@ -0,0 +1,204 @@ + + + + + + + +src/pylib/pysugar/stmt/decl + + + + + + + + + + + + + + + + +
+
+

src/pylib/pysugar/stmt/decl

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

Literal[a, b] cannot be implemented in Nim's type system (i.e. via type Literal[...)

+ +
+

Types

+
+
+
DoXxx = untyped
+
+ + Callable in form of proc (name, typ, val: NimNode): NimNode + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
proc parseDeclWithType(def: NimNode): tuple[name, typ, val: NimNode] {.
+    ...raises: [], tags: [], forbids: [].}
+
+ + a: int -> a int <EmptyNode> a: int = 1 -> a int 1 + Source   +Edit   + +
+
+ +
+
+
+
proc rewriteDeclInStmtAux(variable, oriTyp, val: NimNode;
+                          typId = oriTyp.ensureType): NimNode {....raises: [],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template rewriteDeclAux(variable, oriTyp, val: NimNode;
+                        typId = oriTyp.ensureType;
+                        doLiteral: DoXxx = newConstStmtWithType;
+                        doFinal: DoXxx = nnkLetSection.newDecl;
+                        doElse: DoXxx = nnkVarSection.newDecl): NimNode
+
+ + defined as a template to simulate doXxx argument accepting Curried function + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/pysugar/stmt/decl.idx b/pylib/pysugar/stmt/decl.idx new file mode 100644 index 000000000..cadf336af --- /dev/null +++ b/pylib/pysugar/stmt/decl.idx @@ -0,0 +1,5 @@ +nimTitle decl pylib/pysugar/stmt/decl.html module src/pylib/pysugar/stmt/decl 0 +nim parseDeclWithType pylib/pysugar/stmt/decl.html#parseDeclWithType,NimNode proc parseDeclWithType(def: NimNode): tuple[name, typ, val: NimNode] 8 +nim DoXxx pylib/pysugar/stmt/decl.html#DoXxx type DoXxx 55 +nim rewriteDeclAux pylib/pysugar/stmt/decl.html#rewriteDeclAux.t,NimNode,NimNode,NimNode,DoXxx,DoXxx,DoXxx template rewriteDeclAux(variable, oriTyp, val: NimNode; typId = oriTyp.ensureType;\n doLiteral: DoXxx = newConstStmtWithType;\n doFinal: DoXxx = nnkLetSection.newDecl;\n doElse: DoXxx = nnkVarSection.newDecl): NimNode 90 +nim rewriteDeclInStmtAux pylib/pysugar/stmt/decl.html#rewriteDeclInStmtAux,NimNode,NimNode,NimNode proc rewriteDeclInStmtAux(variable, oriTyp, val: NimNode; typId = oriTyp.ensureType): NimNode 101 diff --git a/pylib/pysugar/stmt/decorator.html b/pylib/pysugar/stmt/decorator.html new file mode 100644 index 000000000..ab1ce092a --- /dev/null +++ b/pylib/pysugar/stmt/decorator.html @@ -0,0 +1,178 @@ + + + + + + + +src/pylib/pysugar/stmt/decorator + + + + + + + + + + + + + + + + +
+
+

src/pylib/pysugar/stmt/decorator

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Imports

+
+ frame +
+
+
+

Procs

+
+
+
+
proc consumeDecorator(mparser; procDef: NimNode): NimNode {....raises: [],
+    tags: [], forbids: [].}
+
+ +

gen:

+

block:
+  `procDef`
+  decorator(... (`procDef`))

+ + Source   +Edit   + +
+
+ +
+
+
+
proc extractDottedCalledDecorator(decorator: NimNode): NimNode {....raises: [],
+    tags: [], forbids: [].}
+
+ + Extract dotted call from decorator. e.g. @a.b.c(1, 2) -> a.b.c(1, 2)
Note: +Currently decorator is to be modified in place, while result is still returned
+ + Source   +Edit   + +
+
+ +
+
+
+
proc pushDecorator(mparser; item: NimNode) {....raises: [], tags: [], forbids: [].}
+
+ + parse @<item> + Source   +Edit   + +
+
+ +
+
+
+
proc tryHandleDecorator(mparser; statement: NimNode): bool {....raises: [],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/pysugar/stmt/decorator.idx b/pylib/pysugar/stmt/decorator.idx new file mode 100644 index 000000000..1b31a0e06 --- /dev/null +++ b/pylib/pysugar/stmt/decorator.idx @@ -0,0 +1,5 @@ +nimTitle decorator pylib/pysugar/stmt/decorator.html module src/pylib/pysugar/stmt/decorator 0 +nim pushDecorator pylib/pysugar/stmt/decorator.html#pushDecorator,,NimNode proc pushDecorator(mparser; item: NimNode) 9 +nim tryHandleDecorator pylib/pysugar/stmt/decorator.html#tryHandleDecorator,,NimNode proc tryHandleDecorator(mparser; statement: NimNode): bool 21 +nim consumeDecorator pylib/pysugar/stmt/decorator.html#consumeDecorator,,NimNode proc consumeDecorator(mparser; procDef: NimNode): NimNode 57 +nim extractDottedCalledDecorator pylib/pysugar/stmt/decorator.html#extractDottedCalledDecorator,NimNode proc extractDottedCalledDecorator(decorator: NimNode): NimNode 77 diff --git a/pylib/pysugar/stmt/exprRewrite.html b/pylib/pysugar/stmt/exprRewrite.html new file mode 100644 index 000000000..e052d8b64 --- /dev/null +++ b/pylib/pysugar/stmt/exprRewrite.html @@ -0,0 +1,155 @@ + + + + + + + +src/pylib/pysugar/stmt/exprRewrite + + + + + + + + + + + + + + + + +
+
+

src/pylib/pysugar/stmt/exprRewrite

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
proc callToPyExpr(mparser; e: NimNode): NimNode {....raises: [Exception],
+    tags: [RootEffect], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc toPyExpr(mparser; atm: NimNode): NimNode {....raises: [Exception],
+    tags: [RootEffect], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc toPyExprNoList(mparser; atm: NimNode): NimNode {....raises: [Exception],
+    tags: [RootEffect], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/pysugar/stmt/exprRewrite.idx b/pylib/pysugar/stmt/exprRewrite.idx new file mode 100644 index 000000000..a8e3c961d --- /dev/null +++ b/pylib/pysugar/stmt/exprRewrite.idx @@ -0,0 +1,4 @@ +nimTitle exprRewrite pylib/pysugar/stmt/exprRewrite.html module src/pylib/pysugar/stmt/exprRewrite 0 +nim toPyExpr pylib/pysugar/stmt/exprRewrite.html#toPyExpr,,NimNode proc toPyExpr(mparser; atm: NimNode): NimNode 18 +nim callToPyExpr pylib/pysugar/stmt/exprRewrite.html#callToPyExpr,, proc callToPyExpr(mparser; e: NimNode): NimNode 176 +nim toPyExprNoList pylib/pysugar/stmt/exprRewrite.html#toPyExprNoList,,NimNode proc toPyExprNoList(mparser; atm: NimNode): NimNode 210 diff --git a/pylib/pysugar/stmt/frame.html b/pylib/pysugar/stmt/frame.html new file mode 100644 index 000000000..2ecbc117a --- /dev/null +++ b/pylib/pysugar/stmt/frame.html @@ -0,0 +1,334 @@ + + + + + + + +src/pylib/pysugar/stmt/frame + + + + + + + + + + + + + + + + +
+
+

src/pylib/pysugar/stmt/frame

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

Stack Frame

+
+

Types

+
+
+
Decorator = ref object
+  name*: NimNode
+  case called*: bool
+  of true:
+    args*: seq[NimNode]
+  of false:
+    nil
+
+ + + Source   +Edit   + +
+
+
+
PyAsgnFrame = ref object
+
+ + + Source   +Edit   + +
+
+
+
PyAsgnRewriter = object
+  dedentDoc*: bool
+  supportGenerics*: bool
+  classes*: seq[NimNode]     ## class type, 
+                             ## empty if outside a `class` definition
+  globals*: seq[string]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
proc add(mparser; ident: string) {....raises: [], tags: [], forbids: [].}
+
+ + add ident to current stack frame. + Source   +Edit   + +
+
+ +
+
+
+
proc contains(mparser; ident: string): bool {....raises: [], tags: [], forbids: [].}
+
+ + check if ident is in current stack frame. + Source   +Edit   + +
+
+ +
+
+
+
proc decorators(mparser): var seq[Decorator] {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc newPyAsgnFrame(): PyAsgnFrame {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc newPyAsgnRewriter(supportGenerics = false; dedentDoc = false): PyAsgnRewriter {.
+    ...raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc nonlocalAdd(mparser; ident: string) {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc nonlocalContains(mparser; ident: string): bool {....raises: [], tags: [],
+    forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc onceDeclInFrames(ident: string; mparser): bool {....raises: [], tags: [],
+    forbids: [].}
+
+ + lookup ident throughout all frames but globals. + Source   +Edit   + +
+
+ +
+
+
+
proc pop(mparser) {....raises: [], tags: [], forbids: [].}
+
+ + pop stack frame + Source   +Edit   + +
+
+ +
+
+
+
proc push(mparser) {....raises: [], tags: [], forbids: [].}
+
+ + push stack frame + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/pysugar/stmt/frame.idx b/pylib/pysugar/stmt/frame.idx new file mode 100644 index 000000000..8414a0bbc --- /dev/null +++ b/pylib/pysugar/stmt/frame.idx @@ -0,0 +1,14 @@ +nimTitle frame pylib/pysugar/stmt/frame.html module src/pylib/pysugar/stmt/frame 0 +nim Decorator pylib/pysugar/stmt/frame.html#Decorator type Decorator 4 +nim PyAsgnFrame pylib/pysugar/stmt/frame.html#PyAsgnFrame type PyAsgnFrame 9 +nim PyAsgnRewriter pylib/pysugar/stmt/frame.html#PyAsgnRewriter object PyAsgnRewriter 13 +nim newPyAsgnFrame pylib/pysugar/stmt/frame.html#newPyAsgnFrame proc newPyAsgnFrame(): PyAsgnFrame 21 +nim newPyAsgnRewriter pylib/pysugar/stmt/frame.html#newPyAsgnRewriter proc newPyAsgnRewriter(supportGenerics = false; dedentDoc = false): PyAsgnRewriter 25 +nim decorators pylib/pysugar/stmt/frame.html#decorators proc decorators(mparser): var seq[Decorator] 32 +nim push pylib/pysugar/stmt/frame.html#push proc push(mparser) 35 +nim pop pylib/pysugar/stmt/frame.html#pop proc pop(mparser) 42 +nim add pylib/pysugar/stmt/frame.html#add,,string proc add(mparser; ident: string) 46 +nim contains pylib/pysugar/stmt/frame.html#contains,,string proc contains(mparser; ident: string): bool 49 +nim onceDeclInFrames pylib/pysugar/stmt/frame.html#onceDeclInFrames,string, proc onceDeclInFrames(ident: string; mparser): bool 53 +nim nonlocalContains pylib/pysugar/stmt/frame.html#nonlocalContains,,string proc nonlocalContains(mparser; ident: string): bool 61 +nim nonlocalAdd pylib/pysugar/stmt/frame.html#nonlocalAdd,,string proc nonlocalAdd(mparser; ident: string) 63 diff --git a/pylib/pysugar/stmt/funcSignature.html b/pylib/pysugar/stmt/funcSignature.html new file mode 100644 index 000000000..83b2928b0 --- /dev/null +++ b/pylib/pysugar/stmt/funcSignature.html @@ -0,0 +1,225 @@ + + + + + + + +src/pylib/pysugar/stmt/funcSignature + + + + + + + + + + + + + + + + +
+
+

src/pylib/pysugar/stmt/funcSignature

+
+ +
+ Source   +Edit   + +
+ +

+
+

Procs

+
+
+
+
func newGenericsTree(): NimNode {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func newProc(name, generics: NimNode;
+             params: openArray[NimNode] = [newEmptyNode()]; body = emptyn;
+             procType = nnkProcDef; pragmas = emptyn): NimNode {....raises: [],
+    tags: [], forbids: [].}
+
+ + variant that accept generics + Source   +Edit   + +
+
+
+
func newProc(tup: tuple[name: NimNode, params: seq[NimNode]]; generics: NimNode;
+             body = emptyn; procType = nnkProcDef; pragmas = emptyn): NimNode {.
+    ...raises: [], tags: [], forbids: [].}
+
+ + variant that accept generics, sleamless to work with parseSignature + Source   +Edit   + +
+
+ +
+
+
+
func parseBracketGenericParams(generics: var NimNode; params: NimNode): NimNode {.
+    ...raises: [], tags: [], forbids: [].}
+
+ + returns name + Source   +Edit   + +
+
+ +
+
+
+
func parseGenericParams(generics: var NimNode; params: NimNode): NimNode {.
+    ...raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc parseSignature(generics: var NimNode; signature: NimNode;
+                    deftype = ident"untyped"): tuple[name: NimNode,
+    params: seq[NimNode]] {....raises: [], tags: [], forbids: [].}
+
+ + deftype is for both params and result, but if signature is of arrow expr, then restype will be its rhs. + Source   +Edit   + +
+
+ +
+
+
+
proc parseSignatureNoGenerics(signature: NimNode; deftype = ident"untyped"): tuple[
+    name: NimNode, params: seq[NimNode]] {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/pysugar/stmt/funcSignature.idx b/pylib/pysugar/stmt/funcSignature.idx new file mode 100644 index 000000000..238390c92 --- /dev/null +++ b/pylib/pysugar/stmt/funcSignature.idx @@ -0,0 +1,9 @@ +nimTitle funcSignature pylib/pysugar/stmt/funcSignature.html module src/pylib/pysugar/stmt/funcSignature 0 +nim newGenericsTree pylib/pysugar/stmt/funcSignature.html#newGenericsTree proc newGenericsTree(): NimNode 60 +nim parseGenericParams pylib/pysugar/stmt/funcSignature.html#parseGenericParams,NimNode,NimNode proc parseGenericParams(generics: var NimNode; params: NimNode): NimNode 62 +nim parseBracketGenericParams pylib/pysugar/stmt/funcSignature.html#parseBracketGenericParams,NimNode,NimNode proc parseBracketGenericParams(generics: var NimNode; params: NimNode): NimNode 71 +nim parseSignature pylib/pysugar/stmt/funcSignature.html#parseSignature,NimNode,NimNode proc parseSignature(generics: var NimNode; signature: NimNode;\n deftype = ident"untyped"): tuple[name: NimNode,\n params: seq[NimNode]] 78 +nim newProc pylib/pysugar/stmt/funcSignature.html#newProc,NimNode,NimNode,openArray[NimNode] proc newProc(name, generics: NimNode; params: openArray[NimNode] = [newEmptyNode()];\n body = emptyn; procType = nnkProcDef; pragmas = emptyn): NimNode 103 +nim newProc pylib/pysugar/stmt/funcSignature.html#newProc,tuple[NimNode,seq[NimNode]],NimNode proc newProc(tup: tuple[name: NimNode, params: seq[NimNode]]; generics: NimNode;\n body = emptyn; procType = nnkProcDef; pragmas = emptyn): NimNode 116 +nim parseSignatureNoGenerics pylib/pysugar/stmt/funcSignature.html#parseSignatureNoGenerics,NimNode proc parseSignatureNoGenerics(signature: NimNode; deftype = ident"untyped"): tuple[\n name: NimNode, params: seq[NimNode]] 121 +nimgrp newproc pylib/pysugar/stmt/funcSignature.html#newProc-procs-all proc 103 diff --git a/pylib/pysugar/stmt/pydef.html b/pylib/pysugar/stmt/pydef.html new file mode 100644 index 000000000..eedac2104 --- /dev/null +++ b/pylib/pysugar/stmt/pydef.html @@ -0,0 +1,197 @@ + + + + + + + +src/pylib/pysugar/stmt/pydef + + + + + + + + + + + + + + + + +
+
+

src/pylib/pysugar/stmt/pydef

+
+ +
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
proc asyncImpl(defsign, body: NimNode; parser: var PySyntaxProcesser;
+               procType = nnkProcDef): NimNode
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc defAux(signature, body: NimNode; deftype = ident"untyped";
+            parser: var PySyntaxProcesser; procType = nnkTemplateDef;
+            pragmas = emptyn): NimNode
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc defImpl(signature, body: NimNode; parser: var PySyntaxProcesser;
+             pragmas = emptyn; deftype = ident"auto"; procType = nnkProcDef): NimNode
+
+ + if signature is of arrow expr (like f()->int), then def_restype is ignored + Source   +Edit   + +
+
+ +
+
+
+
proc parseSignatureMayGenerics(parser: var PySyntaxProcesser;
+                               generics: var NimNode; signature: NimNode;
+                               deftype = ident"untyped"): tuple[name: NimNode,
+    params: seq[NimNode]]
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ + +
+
+ + +
+
+ + + diff --git a/pylib/pysugar/stmt/pydef.idx b/pylib/pysugar/stmt/pydef.idx new file mode 100644 index 000000000..20b758d73 --- /dev/null +++ b/pylib/pysugar/stmt/pydef.idx @@ -0,0 +1,5 @@ +nimTitle pydef pylib/pysugar/stmt/pydef.html module src/pylib/pysugar/stmt/pydef 0 +nim defImpl pylib/pysugar/stmt/pydef.html#defImpl,NimNode,NimNode,PySyntaxProcesser proc defImpl(signature, body: NimNode; parser: var PySyntaxProcesser;\n pragmas = emptyn; deftype = ident"auto"; procType = nnkProcDef): NimNode 16 +nim asyncImpl pylib/pysugar/stmt/pydef.html#asyncImpl,NimNode,NimNode,PySyntaxProcesser proc asyncImpl(defsign, body: NimNode; parser: var PySyntaxProcesser;\n procType = nnkProcDef): NimNode 18 +nim parseSignatureMayGenerics pylib/pysugar/stmt/pydef.html#parseSignatureMayGenerics,PySyntaxProcesser,NimNode,NimNode proc parseSignatureMayGenerics(parser: var PySyntaxProcesser; generics: var NimNode;\n signature: NimNode; deftype = ident"untyped"): tuple[\n name: NimNode, params: seq[NimNode]] 21 +nim defAux pylib/pysugar/stmt/pydef.html#defAux,NimNode,NimNode,PySyntaxProcesser proc defAux(signature, body: NimNode; deftype = ident"untyped";\n parser: var PySyntaxProcesser; procType = nnkTemplateDef;\n pragmas = emptyn): NimNode 32 diff --git a/pylib/pysugar/stmt/pyraise.html b/pylib/pysugar/stmt/pyraise.html new file mode 100644 index 000000000..d08d06d45 --- /dev/null +++ b/pylib/pysugar/stmt/pyraise.html @@ -0,0 +1,114 @@ + + + + + + + +src/pylib/pysugar/stmt/pyraise + + + + + + + + + + + + + + + + +
+
+

src/pylib/pysugar/stmt/pyraise

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

Implement NOTE: We cannot define a macro or function called raise, as in Nim, raise, a keyword, will be parsed as part of nnkRaiseStmt.

+
+

Procs

+
+
+
+
proc rewriteRaise(rStmt: NimNode): NimNode {....raises: [], tags: [], forbids: [].}
+
+ +
  • Rewrites raise ErrType/ErrType()/ErrType(msg) to raise newException(ErrType, msg/"")
  • +
  • Rewrites raise XxError[(...)] to raise new[Py]XxError(...)
  • +
  • Rewrites raise XxError[(...)] from P to raise new[Py]OSError(...).add_parent(P)
  • +
+

assume rStmt is nnkRaiseStmt

+ + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/pysugar/stmt/pyraise.idx b/pylib/pysugar/stmt/pyraise.idx new file mode 100644 index 000000000..a236e4a12 --- /dev/null +++ b/pylib/pysugar/stmt/pyraise.idx @@ -0,0 +1,2 @@ +nimTitle pyraise pylib/pysugar/stmt/pyraise.html module src/pylib/pysugar/stmt/pyraise 0 +nim rewriteRaise pylib/pysugar/stmt/pyraise.html#rewriteRaise,NimNode proc rewriteRaise(rStmt: NimNode): NimNode 70 diff --git a/pylib/pysugar/stmt/tonim.html b/pylib/pysugar/stmt/tonim.html new file mode 100644 index 000000000..8e0e2208d --- /dev/null +++ b/pylib/pysugar/stmt/tonim.html @@ -0,0 +1,228 @@ + + + + + + + +src/pylib/pysugar/stmt/tonim + + + + + + + + + + + + + + + + +
+
+

src/pylib/pysugar/stmt/tonim

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+

Limits

+

global/nonlocal for nonexisting variable

In Python using global/nonlocal to declare a new variable is allowed, but here it may be impossible to implement, as Nim is statically-typed, we must know its type when declaring a variable, while getting a type from AST whose type is untyped is almostly impossible.

+ +

global/nonlocal only means not local, with some limited checks

  • Currently using global name where name is declared in previous frames is not supported
  • +
  • Currently using nonlocal name where name is used for globals is not supported
  • +
+

+ +
+

Procs

+
+
+
+
proc parsePyBody(mparser; body: NimNode): NimNode {....raises: [Exception],
+    tags: [RootEffect], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc parsePyBodyWithDoc(mparser; body: NimNode): NimNode {....raises: [Exception],
+    tags: [RootEffect], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
proc parsePyBodyWithDoc(mparser; body: NimNode; docNode: var NimNode): NimNode {.
+    ...raises: [Exception], tags: [RootEffect], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc parsePyExpr(mparser; exp: NimNode): NimNode {....raises: [Exception],
+    tags: [RootEffect], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc parsePyStmt(mparser; statement: NimNode): NimNode {....raises: [Exception],
+    tags: [RootEffect], forbids: [].}
+
+ +

Rewrites statement from Python-favor to Nim

+

statement shall not be nnkStmtList

+ + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template parsePyBody(body: NimNode): NimNode
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/pysugar/stmt/tonim.idx b/pylib/pysugar/stmt/tonim.idx new file mode 100644 index 000000000..d8caa6660 --- /dev/null +++ b/pylib/pysugar/stmt/tonim.idx @@ -0,0 +1,11 @@ +nimTitle tonim pylib/pysugar/stmt/tonim.html module src/pylib/pysugar/stmt/tonim 0 +nim parsePyBody pylib/pysugar/stmt/tonim.html#parsePyBody,,NimNode proc parsePyBody(mparser; body: NimNode): NimNode 32 +nim parsePyBodyWithDoc pylib/pysugar/stmt/tonim.html#parsePyBodyWithDoc,,NimNode proc parsePyBodyWithDoc(mparser; body: NimNode): NimNode 33 +nim parsePyBodyWithDoc pylib/pysugar/stmt/tonim.html#parsePyBodyWithDoc,,NimNode,NimNode proc parsePyBodyWithDoc(mparser; body: NimNode; docNode: var NimNode): NimNode 34 +nim parsePyExpr pylib/pysugar/stmt/tonim.html#parsePyExpr,,NimNode proc parsePyExpr(mparser; exp: NimNode): NimNode 45 +nim parsePyStmt pylib/pysugar/stmt/tonim.html#parsePyStmt,,NimNode proc parsePyStmt(mparser; statement: NimNode): NimNode 58 +nim parsePyBody pylib/pysugar/stmt/tonim.html#parsePyBody.t,NimNode template parsePyBody(body: NimNode): NimNode 251 +nimgrp parsepybodywithdoc pylib/pysugar/stmt/tonim.html#parsePyBodyWithDoc-procs-all proc 33 +heading Limits pylib/pysugar/stmt/tonim.html#limits Limits 0 +heading global/nonlocal for nonexisting variable pylib/pysugar/stmt/tonim.html#limits-globalslashnonlocal-for-nonexisting-variable global/nonlocal for nonexisting variable 0 +heading global/nonlocal only means nimnot local, with some limited checks pylib/pysugar/stmt/tonim.html#limits-globalslashnonlocal-only-means-nimnot-local-with-some-limited-checks global/nonlocal only means not local, with some limited checks 0 diff --git a/pylib/pysugar/stmt/types.html b/pylib/pysugar/stmt/types.html new file mode 100644 index 000000000..cbb98a175 --- /dev/null +++ b/pylib/pysugar/stmt/types.html @@ -0,0 +1,113 @@ + + + + + + + +src/pylib/pysugar/stmt/types + + + + + + + + + + + + + + + + +
+
+

src/pylib/pysugar/stmt/types

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Types

+
+
+
PySyntaxProcesser = concept var self
+    parsePyBodyWithDoc(self, NimNode) is NimNode
+    parsePyBodyWithDoc(self, NimNode, var NimNode) is NimNode
+    parsePyExpr(self, NimNode) is NimNode
+    self.supportGenerics is bool
+    self.dedentDoc is bool
+
+ + One implememted is PyAsgnRewriter in ./frame while its parsePyBody is in ./tonim + Source   +Edit   + +
+
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/pysugar/stmt/types.idx b/pylib/pysugar/stmt/types.idx new file mode 100644 index 000000000..e166039e9 --- /dev/null +++ b/pylib/pysugar/stmt/types.idx @@ -0,0 +1,2 @@ +nimTitle types pylib/pysugar/stmt/types.html module src/pylib/pysugar/stmt/types 0 +nim PySyntaxProcesser pylib/pysugar/stmt/types.html#PySyntaxProcesser type PySyntaxProcesser 3 diff --git a/pylib/pysugar/stmt/unpack.html b/pylib/pysugar/stmt/unpack.html new file mode 100644 index 000000000..b34e32050 --- /dev/null +++ b/pylib/pysugar/stmt/unpack.html @@ -0,0 +1,160 @@ + + + + + + + +src/pylib/pysugar/stmt/unpack + + + + + + + + + + + + + + + + +
+
+

src/pylib/pysugar/stmt/unpack

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Procs

+
+
+
+
proc unpackImpl(data: NimNode; symbols: NimNode): NimNode {....raises: [],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
proc unpackWithLenImpl(data: NimNode; len2unpack: Positive): NimNode {.
+    ...raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template unpackImplRec(data: NimNode; symbols: NimNode; res: var NimNode;
+                       receiver) {.dirty.}
+
+ + res shall be an nnkStmtList, will pass all sym and relative val to recevier + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/pysugar/stmt/unpack.idx b/pylib/pysugar/stmt/unpack.idx new file mode 100644 index 000000000..030682450 --- /dev/null +++ b/pylib/pysugar/stmt/unpack.idx @@ -0,0 +1,4 @@ +nimTitle unpack pylib/pysugar/stmt/unpack.html module src/pylib/pysugar/stmt/unpack 0 +nim unpackWithLenImpl pylib/pysugar/stmt/unpack.html#unpackWithLenImpl,NimNode,Positive proc unpackWithLenImpl(data: NimNode; len2unpack: Positive): NimNode 11 +nim unpackImplRec pylib/pysugar/stmt/unpack.html#unpackImplRec.t,NimNode,NimNode,NimNode, template unpackImplRec(data: NimNode; symbols: NimNode; res: var NimNode; receiver) 29 +nim unpackImpl pylib/pysugar/stmt/unpack.html#unpackImpl,NimNode,NimNode proc unpackImpl(data: NimNode; symbols: NimNode): NimNode 85 diff --git a/pylib/pysugar/tonim.html b/pylib/pysugar/tonim.html new file mode 100644 index 000000000..83e4cd5c4 --- /dev/null +++ b/pylib/pysugar/tonim.html @@ -0,0 +1,139 @@ + + + + + + + +src/pylib/pysugar/tonim + + + + + + + + + + + + + + + + +
+
+

src/pylib/pysugar/tonim

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Imports

+
+ stmt/tonim +
+
+
+

Macros

+
+
+
+
macro tonim(body): untyped
+
+ + +

Example:

+
var GLOBAL = 1
+tonim:
+  (a, b) = (1, 2)  # NOTE these parentheses cannot omitted, unlike Python
+  assert (a, b) == (1, 2)
+  (_, a) = (1, 2)
+  assert a == 2
+  (b, *_, a) = [1,2,3]
+  assert a == 3
+  # see doc of unpack in ./stmt/unpack.nim for details
+
+  num = 8
+  global GLOBAL
+  GLOBAL = 3
+  doAssertRaises ValueError: raise ValueError
+  doAssertRaises ValueError: raise ValueError()
+  doAssertRaises ValueError: raise ValueError("msg")
+  doAssertRaises ValueError:
+    # Nim-favor is remained.
+    raise newException(ValueError,"msg")
+assert GLOBAL == 3
+ Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/pysugar/tonim.idx b/pylib/pysugar/tonim.idx new file mode 100644 index 000000000..6c79a29ea --- /dev/null +++ b/pylib/pysugar/tonim.idx @@ -0,0 +1,2 @@ +nimTitle tonim pylib/pysugar/tonim.html module src/pylib/pysugar/tonim 0 +nim tonim pylib/pysugar/tonim.html#tonim.m macro tonim(body): untyped 4 diff --git a/pylib/pysugar/unpack.html b/pylib/pysugar/unpack.html new file mode 100644 index 000000000..5268883f0 --- /dev/null +++ b/pylib/pysugar/unpack.html @@ -0,0 +1,160 @@ + + + + + + + +src/pylib/pysugar/unpack + + + + + + + + + + + + + + + + +
+
+

src/pylib/pysugar/unpack

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Imports

+
+ stmt/unpack +
+
+
+

Macros

+
+
+
+
macro unpack(data: untyped; values: varargs[untyped]): untyped
+
+ + +

Example:

+
# Simple unpacking - you need to provide the length to unpack
+let (a, b, c) = @[1, 2, 3, 4].unpack(3)
+doAssert (a + b + c) == 6
+
+# When unpacking with length you get a tuple so you can assign it
+# to something like let (a, b, ...) = x later
+doAssert @[1, 2, 3, 5].unpack(2) == (1, 2)
+
+# You can call unpack with variable names so you don't have to provide
+# the length to unpack
+# You can also optionally use `_` for values you don't want to get
+@[1, 2, 3, 5, 6].unpack(g, x, _, _, z)
+doAssert (g + x + z) == 9
+
+# Finally, this macro supports Python-like star expressions
+# for variables:
+let data = @[1, 2, 3, 4, 5, 6]
+data.unpack(valA, valB, valC, *valY, valG)
+doAssert (valA + valB + valC + valG) == 12
+# For star expressions you get sequences
+doAssert valY == @[4, 5]
+
+data.unpack(start, *ends)
+doAssert start == 1
+doAssert ends == @[2, 3, 4, 5, 6]
+
+# *_ means "ignore al values until the next variable"
+data.unpack(k, r, *_, f)
+doAssert k == 1
+doAssert r == 2
+doAssert f == 6
+
+# You're not limited to simple expressions, you can call this
+# macro with somewhat complex expressions or variables
+let values = @[3, 2, 5, 7]
+doAssert values.unpack(4) == (3, 2, 5, 7)
+
+import std/strutils
+"how are you".split().unpack(ca, cb, cc)
+
+doAssert @[ca, cb, cc].join(", ") == "how, are, you"
+ Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/pysugar/unpack.idx b/pylib/pysugar/unpack.idx new file mode 100644 index 000000000..69022a5bc --- /dev/null +++ b/pylib/pysugar/unpack.idx @@ -0,0 +1,2 @@ +nimTitle unpack pylib/pysugar/unpack.html module src/pylib/pysugar/unpack 0 +nim unpack pylib/pysugar/unpack.html#unpack.m,untyped,varargs[untyped] macro unpack(data: untyped; values: varargs[untyped]): untyped 4 diff --git a/pylib/stringlib/errHandle.html b/pylib/stringlib/errHandle.html new file mode 100644 index 000000000..36ef116d5 --- /dev/null +++ b/pylib/stringlib/errHandle.html @@ -0,0 +1,109 @@ + + + + + + + +src/pylib/stringlib/errHandle + + + + + + + + + + + + + + + + +
+
+

src/pylib/stringlib/errHandle

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Templates

+
+
+
+
template noEmptySep(sep)
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/stringlib/errHandle.idx b/pylib/stringlib/errHandle.idx new file mode 100644 index 000000000..7582fe2c2 --- /dev/null +++ b/pylib/stringlib/errHandle.idx @@ -0,0 +1,2 @@ +nimTitle errHandle pylib/stringlib/errHandle.html module src/pylib/stringlib/errHandle 0 +nim noEmptySep pylib/stringlib/errHandle.html#noEmptySep.t template noEmptySep(sep) 2 diff --git a/pylib/stringlib/format.html b/pylib/stringlib/format.html new file mode 100644 index 000000000..0f40be3de --- /dev/null +++ b/pylib/stringlib/format.html @@ -0,0 +1,163 @@ + + + + + + + +src/pylib/stringlib/format + + + + + + + + + + + + + + + + +
+
+

src/pylib/stringlib/format

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

str.format

+

NOTE: only str in Python has format method, not bytes nor bytearray.

+

+
+

Imports

+
+ formats +
+
+
+

Procs

+
+
+
+
proc pyformatImplAux(s: string; args: seq[NimNode]; kw: Kw): NimNode {.
+    ...raises: [ValueError, KeyError], tags: [], forbids: [].}
+
+ +

if -d:pylibUseFormatValue, use formatValue instead of format for formatting.

+

Convertion is not supported yet (like !r).

+ + Source   +Edit   + +
+
+ +
+ +
+
+
+

Macros

+
+
+
+
macro pyformat(s: static[string]; argKw: varargs[untyped]): string
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Exports

+
+ format, format +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/stringlib/format.idx b/pylib/stringlib/format.idx new file mode 100644 index 000000000..b2dfe37fb --- /dev/null +++ b/pylib/stringlib/format.idx @@ -0,0 +1,3 @@ +nimTitle format pylib/stringlib/format.html module src/pylib/stringlib/format 0 +nim pyformatImplAux pylib/stringlib/format.html#pyformatImplAux,string,seq[NimNode],Kw proc pyformatImplAux(s: string; args: seq[NimNode]; kw: Kw): NimNode 43 +nim pyformat pylib/stringlib/format.html#pyformat.m,static[string],varargs[untyped] macro pyformat(s: static[string]; argKw: varargs[untyped]): string 132 diff --git a/pylib/stringlib/formats.html b/pylib/stringlib/formats.html new file mode 100644 index 000000000..81a74501c --- /dev/null +++ b/pylib/stringlib/formats.html @@ -0,0 +1,141 @@ + + + + + + + +src/pylib/stringlib/formats + + + + + + + + + + + + + + + + +
+
+

src/pylib/stringlib/formats

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Procs

+
+
+
+
func format(value: char; format_spec: string = ""): string {.
+    ...raises: [ValueError], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template format[T](value: T; format_spec: string = ""): string
+
+ + wrapper of std/strformat formatValue + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/stringlib/formats.idx b/pylib/stringlib/formats.idx new file mode 100644 index 000000000..4091230cb --- /dev/null +++ b/pylib/stringlib/formats.idx @@ -0,0 +1,3 @@ +nimTitle formats pylib/stringlib/formats.html module src/pylib/stringlib/formats 0 +nim format pylib/stringlib/formats.html#format.t,T,string template format[T](value: T; format_spec: string = ""): string 4 +nim format pylib/stringlib/formats.html#format,char,string proc format(value: char; format_spec: string = ""): string 11 diff --git a/pylib/stringlib/meth.html b/pylib/stringlib/meth.html new file mode 100644 index 000000000..86114fb1b --- /dev/null +++ b/pylib/stringlib/meth.html @@ -0,0 +1,963 @@ + + + + + + + +src/pylib/stringlib/meth + + + + + + + + + + + + + + + + +
+
+

src/pylib/stringlib/meth

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
func center[S](a: S; width: int; fillchar = ' '): S
+
+ + Mimics Python str.center(width: int, fillchar: str=" ") -> str + Source   +Edit   + +
+
+
+
func center[S](a: S; width: int; fillchar: S = " "): S
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func count[S](a: S; sub: S): int
+
+ + + Source   +Edit   + +
+
+
+
func count[S](a: S; sub: S; start = 0; end: int): int
+
+ + + Source   +Edit   + +
+
+
+
func count[S](a: S; sub: S; start: int): int
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func endsWith[S; Suf: S | tuple](a: S; suffix: Suf; start, end: int): bool
+
+ + + Source   +Edit   + +
+
+
+
func endsWith[S; Suf: S | tuple](a: S; suffix: Suf; start: int): bool
+
+ + + Source   +Edit   + +
+
+
+
func endsWith[S; Tup: tuple](a: S; suffix: Tup): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func find[S; T](a: S; b: T; start = 0): int
+
+ + + Source   +Edit   + +
+
+
+
func find[S; T](a: S; b: T; start = 0; end: int): int
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func find1[S; T](a: S; b: T; start = 0): int
+
+ + b shall be one length long. + Source   +Edit   + +
+
+
+
func find1[S; T](a: S; b: T; start = 0; end: int): int
+
+ + b shall be one length long. + Source   +Edit   + +
+
+ +
+
+
+
func index[S; T](a: S; b: T; start = 0): int
+
+ + + Source   +Edit   + +
+
+
+
func index[S; T](a: S; b: T; start = 0; end: int): int
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func index1[S; T](a: S; b: T; start = 0): int
+
+ + + Source   +Edit   + +
+
+
+
func index1[S; T](a: S; b: T; start = 0; end: int): int
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func isalnum(c: char): bool {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func isalnum(s: string): bool {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func isalpha(c: char): bool {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func isalpha(s: string): bool {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func isascii(c: char): bool {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func isascii(s: string): bool {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func isdigit(c: char): bool {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func isdigit(s: string): bool {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func isspace(c: char): bool {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func isspace(s: string): bool {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func join[T, S](sep: S; a: openArray[T]): S
+
+ + Mimics Python join() -> string + Source   +Edit   + +
+
+
+
func join[T](sep: char; a: openArray[T]): string
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func ljust(a: string; width: int; fillchar = ' '): string {....raises: [],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func ljust[S](a: S; width: int; fillchar: S = " "): S
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func partition[S](a: S; sep: S): tuple[before, sep, after: S]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func removeprefix[S](a: S; suffix: S): S
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func removesuffix[S](a: S; suffix: S): S
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func replace[S](a: S; sub, by: char): S
+
+ + + Source   +Edit   + +
+
+
+
func replace[S](a: S; sub, by: char; count: int): S
+
+ + + Source   +Edit   + +
+
+
+
func replace[S](a: S; sub, by: S): S
+
+ + + Source   +Edit   + +
+
+
+
func replace[S](a: S; sub, by: S; count: int): S
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func rfind[S; T](a: S; b: T; start = 0): int
+
+ + + Source   +Edit   + +
+
+
+
func rfind[S; T](a: S; b: T; start = 0; end: int): int
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func rfind1[S; T](a: S; b: T; start = 0): int
+
+ + + Source   +Edit   + +
+
+
+
func rfind1[S; T](a: S; b: T; start = 0; end: int): int
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func rindex[S; T](a: S; b: T; start = 0): int
+
+ + + Source   +Edit   + +
+
+
+
func rindex[S; T](a: S; b: T; start = 0; end: int): int
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func rindex1[S; T](a: S; b: T; start = 0): int
+
+ + + Source   +Edit   + +
+
+
+
func rindex1[S; T](a: S; b: T; start = 0; end: int): int
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func rjust(a: string; width: int; fillchar = ' '): string {....raises: [],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func rjust[S](a: S; width: int; fillchar: S = " "): S
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func rpartition[S](a: S; sep: S): tuple[before, sep, after: S]
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func startsWith[S; Suf: S | tuple](a: S; suffix: Suf; start, end: int): bool
+
+ + + Source   +Edit   + +
+
+
+
func startsWith[S; Suf: S | tuple](a: S; suffix: Suf; start: int): bool
+
+ + + Source   +Edit   + +
+
+
+
func startsWith[S; Tup: tuple](a: S; suffix: Tup): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func zfill(a: string; width: int): string {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func zfill(c: char; width: int): string {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template allAlpha(a, isWhat, isNotWhat: typed; iter, firstItemGetter)
+
+ + used as func body. e.g. func isupper(self: PyBytes): bool = self.allAlpha(isUpperAscii, isLowerAscii, items, [0]) + Source   +Edit   + +
+
+ +
+
+
+
template endsWith[S](a: char; suffix: S): bool
+
+ + + Source   +Edit   + +
+
+
+
template endsWith[S](a: S; suffix: char): bool
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template expandtabsImpl[S](a: S; tabsize: int; strByteLen: int; iter): string
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template istitleImpl(a, isupper, islower: typed; iter, firstItemGetter)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template startsWith[S](a: char; suffix: S): bool
+
+ + + Source   +Edit   + +
+
+
+
template startsWith[S](a: S; suffix: char): bool
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/stringlib/meth.idx b/pylib/stringlib/meth.idx new file mode 100644 index 000000000..d61dc055b --- /dev/null +++ b/pylib/stringlib/meth.idx @@ -0,0 +1,85 @@ +nimTitle meth pylib/stringlib/meth.html module src/pylib/stringlib/meth 0 +nim count pylib/stringlib/meth.html#count,S,S proc count[S](a: S; sub: S): int 13 +nim count pylib/stringlib/meth.html#count,S,S,int proc count[S](a: S; sub: S; start: int): int 17 +nim count pylib/stringlib/meth.html#count,S,S,int,int proc count[S](a: S; sub: S; start = 0; end: int): int 22 +nim startsWith pylib/stringlib/meth.html#startsWith.t,S,char template startsWith[S](a: S; suffix: char): bool 27 +nim startsWith pylib/stringlib/meth.html#startsWith.t,char,S template startsWith[S](a: char; suffix: S): bool 29 +nim startsWith pylib/stringlib/meth.html#startsWith,S,Tup proc startsWith[S; Tup: tuple](a: S; suffix: Tup): bool 31 +nim startsWith pylib/stringlib/meth.html#startsWith,S,Suf,int proc startsWith[S; Suf: S | tuple](a: S; suffix: Suf; start: int): bool 36 +nim startsWith pylib/stringlib/meth.html#startsWith,S,Suf,int,int proc startsWith[S; Suf: S | tuple](a: S; suffix: Suf; start, end: int): bool 43 +nim endsWith pylib/stringlib/meth.html#endsWith.t,S,char template endsWith[S](a: S; suffix: char): bool 27 +nim endsWith pylib/stringlib/meth.html#endsWith.t,char,S template endsWith[S](a: char; suffix: S): bool 29 +nim endsWith pylib/stringlib/meth.html#endsWith,S,Tup proc endsWith[S; Tup: tuple](a: S; suffix: Tup): bool 31 +nim endsWith pylib/stringlib/meth.html#endsWith,S,Suf,int proc endsWith[S; Suf: S | tuple](a: S; suffix: Suf; start: int): bool 36 +nim endsWith pylib/stringlib/meth.html#endsWith,S,Suf,int,int proc endsWith[S; Suf: S | tuple](a: S; suffix: Suf; start, end: int): bool 44 +nim find1 pylib/stringlib/meth.html#find1,S,T,int proc find1[S; T](a: S; b: T; start = 0): int 47 +nim find1 pylib/stringlib/meth.html#find1,S,T,int,int proc find1[S; T](a: S; b: T; start = 0; end: int): int 55 +nim rfind1 pylib/stringlib/meth.html#rfind1,S,T,int,int proc rfind1[S; T](a: S; b: T; start = 0; end: int): int 65 +nim rfind1 pylib/stringlib/meth.html#rfind1,S,T,int proc rfind1[S; T](a: S; b: T; start = 0): int 69 +nim find pylib/stringlib/meth.html#find,S,T,int proc find[S; T](a: S; b: T; start = 0): int 73 +nim find pylib/stringlib/meth.html#find,S,T,int,int proc find[S; T](a: S; b: T; start = 0; end: int): int 81 +nim rfind pylib/stringlib/meth.html#rfind,S,T,int proc rfind[S; T](a: S; b: T; start = 0): int 73 +nim rfind pylib/stringlib/meth.html#rfind,S,T,int,int proc rfind[S; T](a: S; b: T; start = 0; end: int): int 82 +nim index1 pylib/stringlib/meth.html#index1,S,T,int,int proc index1[S; T](a: S; b: T; start = 0; end: int): int 87 +nim index1 pylib/stringlib/meth.html#index1,S,T,int proc index1[S; T](a: S; b: T; start = 0): int 90 +nim index pylib/stringlib/meth.html#index,S,T,int,int proc index[S; T](a: S; b: T; start = 0; end: int): int 92 +nim index pylib/stringlib/meth.html#index,S,T,int proc index[S; T](a: S; b: T; start = 0): int 95 +nim rindex1 pylib/stringlib/meth.html#rindex1,S,T,int,int proc rindex1[S; T](a: S; b: T; start = 0; end: int): int 98 +nim rindex1 pylib/stringlib/meth.html#rindex1,S,T,int proc rindex1[S; T](a: S; b: T; start = 0): int 101 +nim rindex pylib/stringlib/meth.html#rindex,S,T,int,int proc rindex[S; T](a: S; b: T; start = 0; end: int): int 104 +nim rindex pylib/stringlib/meth.html#rindex,S,T,int proc rindex[S; T](a: S; b: T; start = 0): int 107 +nim isascii pylib/stringlib/meth.html#isascii,char proc isascii(c: char): bool 113 +nim isascii pylib/stringlib/meth.html#isascii,string proc isascii(s: string): bool 114 +nim isalpha pylib/stringlib/meth.html#isalpha,char proc isalpha(c: char): bool 131 +nim isalpha pylib/stringlib/meth.html#isalpha,string proc isalpha(s: string): bool 134 +nim isspace pylib/stringlib/meth.html#isspace,char proc isspace(c: char): bool 131 +nim isspace pylib/stringlib/meth.html#isspace,string proc isspace(s: string): bool 135 +nim isdigit pylib/stringlib/meth.html#isdigit,char proc isdigit(c: char): bool 131 +nim isdigit pylib/stringlib/meth.html#isdigit,string proc isdigit(s: string): bool 136 +nim isalnum pylib/stringlib/meth.html#isalnum,char proc isalnum(c: char): bool 131 +nim isalnum pylib/stringlib/meth.html#isalnum,string proc isalnum(s: string): bool 137 +nim allAlpha pylib/stringlib/meth.html#allAlpha.t,typed,typed,typed,, template allAlpha(a, isWhat, isNotWhat: typed; iter, firstItemGetter) 139 +nim istitleImpl pylib/stringlib/meth.html#istitleImpl.t,typed,typed,typed,, template istitleImpl(a, isupper, islower: typed; iter, firstItemGetter) 155 +nim center pylib/stringlib/meth.html#center,S,int,char proc center[S](a: S; width: int; fillchar = ' '): S 194 +nim ljust pylib/stringlib/meth.html#ljust,string,int,char proc ljust(a: string; width: int; fillchar = ' '): string 199 +nim rjust pylib/stringlib/meth.html#rjust,string,int,char proc rjust(a: string; width: int; fillchar = ' '): string 201 +nim center pylib/stringlib/meth.html#center,S,int,S proc center[S](a: S; width: int; fillchar: S = " "): S 213 +nim ljust pylib/stringlib/meth.html#ljust,S,int,S proc ljust[S](a: S; width: int; fillchar: S = " "): S 217 +nim rjust pylib/stringlib/meth.html#rjust,S,int,S proc rjust[S](a: S; width: int; fillchar: S = " "): S 222 +nim zfill pylib/stringlib/meth.html#zfill,char,int proc zfill(c: char; width: int): string 227 +nim zfill pylib/stringlib/meth.html#zfill,string,int proc zfill(a: string; width: int): string 236 +nim removeprefix pylib/stringlib/meth.html#removeprefix,S,S proc removeprefix[S](a: S; suffix: S): S 254 +nim removesuffix pylib/stringlib/meth.html#removesuffix,S,S proc removesuffix[S](a: S; suffix: S): S 258 +nim replace pylib/stringlib/meth.html#replace,S,char,char proc replace[S](a: S; sub, by: char): S 263 +nim replace pylib/stringlib/meth.html#replace,S,S,S proc replace[S](a: S; sub, by: S): S 265 +nim replace pylib/stringlib/meth.html#replace,S,char,char,int proc replace[S](a: S; sub, by: char; count: int): S 268 +nim replace pylib/stringlib/meth.html#replace,S,S,S,int proc replace[S](a: S; sub, by: S; count: int): S 272 +nim expandtabsImpl pylib/stringlib/meth.html#expandtabsImpl.t,S,int,int, template expandtabsImpl[S](a: S; tabsize: int; strByteLen: int; iter): string 322 +nim join pylib/stringlib/meth.html#join,char,openArray[T] proc join[T](sep: char; a: openArray[T]): string 328 +nim join pylib/stringlib/meth.html#join,S,openArray[T] proc join[T, S](sep: S; a: openArray[T]): S 331 +nim partition pylib/stringlib/meth.html#partition,S,S proc partition[S](a: S; sep: S): tuple[before, sep, after: S] 344 +nim rpartition pylib/stringlib/meth.html#rpartition,S,S proc rpartition[S](a: S; sep: S): tuple[before, sep, after: S] 345 +nimgrp join pylib/stringlib/meth.html#join-procs-all proc 328 +nimgrp rindex pylib/stringlib/meth.html#rindex-procs-all proc 104 +nimgrp find1 pylib/stringlib/meth.html#find1-procs-all proc 47 +nimgrp rfind pylib/stringlib/meth.html#rfind-procs-all proc 82 +nimgrp replace pylib/stringlib/meth.html#replace-procs-all proc 263 +nimgrp index1 pylib/stringlib/meth.html#index1-procs-all proc 87 +nimgrp startswith pylib/stringlib/meth.html#startsWith-procs-all proc 43 +nimgrp isdigit pylib/stringlib/meth.html#isdigit-procs-all proc 136 +nimgrp index pylib/stringlib/meth.html#index-procs-all proc 92 +nimgrp isascii pylib/stringlib/meth.html#isascii-procs-all proc 113 +nimgrp isspace pylib/stringlib/meth.html#isspace-procs-all proc 135 +nimgrp rfind1 pylib/stringlib/meth.html#rfind1-procs-all proc 65 +nimgrp ljust pylib/stringlib/meth.html#ljust-procs-all proc 199 +nimgrp rjust pylib/stringlib/meth.html#rjust-procs-all proc 201 +nimgrp count pylib/stringlib/meth.html#count-procs-all proc 13 +nimgrp isalpha pylib/stringlib/meth.html#isalpha-procs-all proc 134 +nimgrp endswith pylib/stringlib/meth.html#endsWith-procs-all proc 44 +nimgrp isalnum pylib/stringlib/meth.html#isalnum-procs-all proc 137 +nimgrp rindex1 pylib/stringlib/meth.html#rindex1-procs-all proc 98 +nimgrp zfill pylib/stringlib/meth.html#zfill-procs-all proc 227 +nimgrp center pylib/stringlib/meth.html#center-procs-all proc 194 +nimgrp find pylib/stringlib/meth.html#find-procs-all proc 81 +nimgrp startswith pylib/stringlib/meth.html#startsWith-templates-all template 43 +nimgrp endswith pylib/stringlib/meth.html#endsWith-templates-all template 44 diff --git a/pylib/stringlib/replaceWithCount.html b/pylib/stringlib/replaceWithCount.html new file mode 100644 index 000000000..534e68417 --- /dev/null +++ b/pylib/stringlib/replaceWithCount.html @@ -0,0 +1,122 @@ + + + + + + + +src/pylib/stringlib/replaceWithCount + + + + + + + + + + + + + + + + +
+
+

src/pylib/stringlib/replaceWithCount

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

modified from std/strutils, adding count param

+
+

Procs

+
+
+
+
func replace(s: string; sub, by: char; count: Natural): string {....raises: [],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func replace(s: string; sub, by: string; count: Natural): string {....raises: [],
+    tags: [], forbids: [].}
+
+ + count must be Natural + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/stringlib/replaceWithCount.idx b/pylib/stringlib/replaceWithCount.idx new file mode 100644 index 000000000..0989cc1c4 --- /dev/null +++ b/pylib/stringlib/replaceWithCount.idx @@ -0,0 +1,4 @@ +nimTitle replaceWithCount pylib/stringlib/replaceWithCount.html module src/pylib/stringlib/replaceWithCount 0 +nim replace pylib/stringlib/replaceWithCount.html#replace,string,char,char,Natural proc replace(s: string; sub, by: char; count: Natural): string 6 +nim replace pylib/stringlib/replaceWithCount.html#replace,string,string,string,Natural proc replace(s: string; sub, by: string; count: Natural): string 22 +nimgrp replace pylib/stringlib/replaceWithCount.html#replace-procs-all proc 6 diff --git a/pylib/stringlib/split/common.html b/pylib/stringlib/split/common.html new file mode 100644 index 000000000..d11a2f97f --- /dev/null +++ b/pylib/stringlib/split/common.html @@ -0,0 +1,236 @@ + + + + + + + +src/pylib/stringlib/split/common + + + + + + + + + + + + + + + + +
+
+

src/pylib/stringlib/split/common

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Types

+
+
+
IsSpaceAt[S] = proc (s: S; pos: int): bool {.nosideEffect.}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Consts

+
+
+
DefSplitCap = 12
+
+ + + Source   +Edit   + +
+
+
+
STRINGLIB_MUTABLE = false
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
func norm_maxsplit(maxsplit: int; str_len, sep_len: int): int {....raises: [],
+    tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func suf--(i: var int): int {.inline, ...raises: [], tags: [], forbids: [].}
+
+ + i-- in C + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template norm_maxsplit(maxsplit: int; str_len): int
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template PREPARE_CAP(maxcount): int
+
+ + maxcount shall be Natural + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/stringlib/split/common.idx b/pylib/stringlib/split/common.idx new file mode 100644 index 000000000..d5b3f8bbb --- /dev/null +++ b/pylib/stringlib/split/common.idx @@ -0,0 +1,8 @@ +nimTitle common pylib/stringlib/split/common.html module src/pylib/stringlib/split/common 0 +nim IsSpaceAt pylib/stringlib/split/common.html#IsSpaceAt type IsSpaceAt 3 +nim suf-- pylib/stringlib/split/common.html#suf--,int proc suf--(i: var int): int 5 +nim STRINGLIB_MUTABLE pylib/stringlib/split/common.html#STRINGLIB_MUTABLE const STRINGLIB_MUTABLE 10 +nim norm_maxsplit pylib/stringlib/split/common.html#norm_maxsplit.t,int, template norm_maxsplit(maxsplit: int; str_len): int 14 +nim DefSplitCap pylib/stringlib/split/common.html#DefSplitCap const DefSplitCap 19 +nim PREPARE_CAP pylib/stringlib/split/common.html#PREPARE_CAP.t template PREPARE_CAP(maxcount): int 22 +nim norm_maxsplit pylib/stringlib/split/common.html#norm_maxsplit,int,int,int proc norm_maxsplit(maxsplit: int; str_len, sep_len: int): int 27 diff --git a/pylib/stringlib/split/reimporter.html b/pylib/stringlib/split/reimporter.html new file mode 100644 index 000000000..d23fe5f5d --- /dev/null +++ b/pylib/stringlib/split/reimporter.html @@ -0,0 +1,96 @@ + + + + + + + +src/pylib/stringlib/split/reimporter + + + + + + + + + + + + + + + + +
+
+

src/pylib/stringlib/split/reimporter

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+ +
+ + +
+
+ + + diff --git a/pylib/stringlib/split/reimporter.idx b/pylib/stringlib/split/reimporter.idx new file mode 100644 index 000000000..431e6eaef --- /dev/null +++ b/pylib/stringlib/split/reimporter.idx @@ -0,0 +1 @@ +nimTitle reimporter pylib/stringlib/split/reimporter.html module src/pylib/stringlib/split/reimporter 0 diff --git a/pylib/stringlib/split/rsplit_whitespace.html b/pylib/stringlib/split/rsplit_whitespace.html new file mode 100644 index 000000000..d08b050d0 --- /dev/null +++ b/pylib/stringlib/split/rsplit_whitespace.html @@ -0,0 +1,118 @@ + + + + + + + +src/pylib/stringlib/split/rsplit_whitespace + + + + + + + + + + + + + + + + +
+
+

src/pylib/stringlib/split/rsplit_whitespace

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
proc rsplit_whitespace[S](pystr: S; maxsplit = -1): PyList[S]
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/stringlib/split/rsplit_whitespace.idx b/pylib/stringlib/split/rsplit_whitespace.idx new file mode 100644 index 000000000..fc82e5cad --- /dev/null +++ b/pylib/stringlib/split/rsplit_whitespace.idx @@ -0,0 +1,2 @@ +nimTitle rsplit_whitespace pylib/stringlib/split/rsplit_whitespace.html module src/pylib/stringlib/split/rsplit_whitespace 0 +nim rsplit_whitespace pylib/stringlib/split/rsplit_whitespace.html#rsplit_whitespace,S,int proc rsplit_whitespace[S](pystr: S; maxsplit = -1): PyList[S] 46 diff --git a/pylib/stringlib/split/split_whitespace.html b/pylib/stringlib/split/split_whitespace.html new file mode 100644 index 000000000..9386358d1 --- /dev/null +++ b/pylib/stringlib/split/split_whitespace.html @@ -0,0 +1,149 @@ + + + + + + + +src/pylib/stringlib/split/split_whitespace + + + + + + + + + + + + + + + + +
+
+

src/pylib/stringlib/split/split_whitespace

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+ +
+

Procs

+
+
+
+
proc split_whitespace[S](pystr: S; maxsplit = -1): PyList[S]
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Iterators

+
+
+
+
iterator split_whitespace[S](pystr: S; maxsplit = -1): S
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/stringlib/split/split_whitespace.idx b/pylib/stringlib/split/split_whitespace.idx new file mode 100644 index 000000000..ddfad47d4 --- /dev/null +++ b/pylib/stringlib/split/split_whitespace.idx @@ -0,0 +1,3 @@ +nimTitle split_whitespace pylib/stringlib/split/split_whitespace.html module src/pylib/stringlib/split/split_whitespace 0 +nim split_whitespace pylib/stringlib/split/split_whitespace.html#split_whitespace.i,S,int iterator split_whitespace[S](pystr: S; maxsplit = -1): S 46 +nim split_whitespace pylib/stringlib/split/split_whitespace.html#split_whitespace,S,int proc split_whitespace[S](pystr: S; maxsplit = -1): PyList[S] 53 diff --git a/pylib/stringlib/split/splitlinesIter.html b/pylib/stringlib/split/splitlinesIter.html new file mode 100644 index 000000000..3a46dab5c --- /dev/null +++ b/pylib/stringlib/split/splitlinesIter.html @@ -0,0 +1,121 @@ + + + + + + + +src/pylib/stringlib/split/splitlinesIter + + + + + + + + + + + + + + + + +
+
+

src/pylib/stringlib/split/splitlinesIter

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

We cannot just use strutils.splitLines for str.splitlines, even nor for bytes.splitlines, as Python uses Univeral NewLine as sep.

+

See https://docs.python.org/3/glossary.html#term-universal-newlines

+

For a table of all Universal Newlines, see https://docs.python.org/3/library/stdtypes.html#str.splitlines

+

+
+

Imports

+
+ common +
+
+
+

Iterators

+
+
+
+
iterator splitlines[S](self: S; keepends = false): S
+
+ + mixin IS_CAR_NL, IS_LINEBREAK, [Slice], [int], len + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/stringlib/split/splitlinesIter.idx b/pylib/stringlib/split/splitlinesIter.idx new file mode 100644 index 000000000..de7869690 --- /dev/null +++ b/pylib/stringlib/split/splitlinesIter.idx @@ -0,0 +1,2 @@ +nimTitle splitlinesIter pylib/stringlib/split/splitlinesIter.html module src/pylib/stringlib/split/splitlinesIter 0 +nim splitlines pylib/stringlib/split/splitlinesIter.html#splitlines.i,S iterator splitlines[S](self: S; keepends = false): S 18 diff --git a/pylib/translateEscape.html b/pylib/translateEscape.html new file mode 100644 index 000000000..302962caa --- /dev/null +++ b/pylib/translateEscape.html @@ -0,0 +1,141 @@ + + + + + + + +src/pylib/translateEscape + + + + + + + + + + + + + + + + +
+
+

src/pylib/translateEscape

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Procs

+
+
+
+
func translateEscape(pattern: string): string {....raises: [], tags: [],
+    forbids: [].}
+
+ + like translateEscapeWithErr but without lineInfo error msg + Source   +Edit   + +
+
+ +
+ +
+
+
+

Macros

+
+
+
+
macro translateEscapeWithErr(pattern: string): string
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/translateEscape.idx b/pylib/translateEscape.idx new file mode 100644 index 000000000..3c1eed3d7 --- /dev/null +++ b/pylib/translateEscape.idx @@ -0,0 +1,3 @@ +nimTitle translateEscape pylib/translateEscape.html module src/pylib/translateEscape 0 +nim translateEscape pylib/translateEscape.html#translateEscape,string proc translateEscape(pattern: string): string 228 +nim translateEscapeWithErr pylib/translateEscape.html#translateEscapeWithErr.m,string macro translateEscapeWithErr(pattern: string): string 233 diff --git a/pylib/version.html b/pylib/version.html new file mode 100644 index 000000000..e9815d2be --- /dev/null +++ b/pylib/version.html @@ -0,0 +1,322 @@ + + + + + + + +src/pylib/version + + + + + + + + + + + + + + + + +
+
+

src/pylib/version

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

+
+

Imports

+
+ versionInfo +
+
+
+

Consts

+
+
+
Version = "0.9.11"
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Procs

+
+
+
+
func asVersion(v: (int, int)): string {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+
+
func asVersion(v: (int, int, int)): string {....raises: [], tags: [], forbids: [].}
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
func pysince[R](ver: static[float | MajorMinorVersion]; defExpr, elseExpr: R): R {.
+    inline.}
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Macros

+
+
+
+
macro pysince(major, minor: static int; def)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
macro templWrapExportSincePy(major, minor: static int; sym: typed)
+
+ + generate template sym*(...): untyped = sym(...) + Source   +Edit   + +
+
+ +
+
+
+
macro wrapExportSincePy(major, minor: static int; sym: typed)
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+
+

Templates

+
+
+
+
template asVersion(major, minor, patch: int): string
+
+ + + Source   +Edit   + +
+
+
+
template asVersion(major, minor: int): string
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template exportSincePy(major, minor: int; sym: typed)
+
+ + + Source   +Edit   + +
+
+ +
+
+
+
template pysince[R](ver: MajorMinorVersion; defExpr, elseExpr: R): R
+
+ + + Source   +Edit   + +
+
+ +
+ +
+
+ + +
+
+ + +
+
+ + + diff --git a/pylib/version.idx b/pylib/version.idx new file mode 100644 index 000000000..c924c1d90 --- /dev/null +++ b/pylib/version.idx @@ -0,0 +1,14 @@ +nimTitle version pylib/version.html module src/pylib/version 0 +nim asVersion pylib/version.html#asVersion.t,int,int template asVersion(major, minor: int): string 3 +nim asVersion pylib/version.html#asVersion.t,int,int,int template asVersion(major, minor, patch: int): string 6 +nim asVersion pylib/version.html#asVersion proc asVersion(v: (int, int)): string 9 +nim asVersion pylib/version.html#asVersion_2 proc asVersion(v: (int, int, int)): string 10 +nim Version pylib/version.html#Version const Version 16 +nim exportSincePy pylib/version.html#exportSincePy.t,int,int,typed template exportSincePy(major, minor: int; sym: typed) 17 +nim templWrapExportSincePy pylib/version.html#templWrapExportSincePy.m,staticint,staticint,typed macro templWrapExportSincePy(major, minor: static int; sym: typed) 43 +nim pysince pylib/version.html#pysince.m,staticint,staticint, macro pysince(major, minor: static int; def) 67 +nim wrapExportSincePy pylib/version.html#wrapExportSincePy.m,staticint,staticint,typed macro wrapExportSincePy(major, minor: static int; sym: typed) 91 +nim pysince pylib/version.html#pysince.t,MajorMinorVersion,R,R template pysince[R](ver: MajorMinorVersion; defExpr, elseExpr: R): R 109 +nim pysince pylib/version.html#pysince,static[],R,R proc pysince[R](ver: static[float | MajorMinorVersion]; defExpr, elseExpr: R): R 123 +nimgrp asversion pylib/version.html#asVersion-procs-all proc 9 +nimgrp asversion pylib/version.html#asVersion-templates-all template 3 diff --git a/pylib/versionInfo.html b/pylib/versionInfo.html new file mode 100644 index 000000000..3d44eacc2 --- /dev/null +++ b/pylib/versionInfo.html @@ -0,0 +1,229 @@ + + + + + + + +src/pylib/versionInfo + + + + + + + + + + + + + + + + +
+
+

src/pylib/versionInfo

+
+
+
+ + +
+ +
+ Search: +
+
+ Group by: + +
+ + +
+
+ Source   +Edit   + +
+ +

to be imported by ./version

+
+

Types

+
+
+
PyReleaseLevelEnum {.pure.} = enum
+  alpha = 10, beta = 11, gamma = 12, final = 15
+
+ + + Source   +Edit   + +
+
+ +
+
+
+

Consts

+
+
+
Major = 0
+
+ + + Source   +Edit   + +
+
+
+
Minor = 9
+
+ + + Source   +Edit   + +
+
+
+
Patch = 11
+
+ + + Source   +Edit   + +
+
+
+
PyMajor {.intdefine.} = 3
+
+ + + Source   +Edit   + +
+
+
+
PyMinor {.intdefine.} = 13
+
+ + + Source   +Edit   + +
+
+
+
PyPatch {.intdefine.} = 0
+
+ + + Source   +Edit   + +
+
+
+
PyReleaseLevel = PyReleaseLevelEnum.final
+
+ + + Source   +Edit   + +
+
+
+
PySerial = 0
+
+ + + Source   +Edit   + +
+
+
+
ReleaseLevel = "alpha"
+
+ + + Source   +Edit   + +
+
+
+
Serial = 0
+
+ + + Source   +Edit   + +
+
+ +
+
+ +
+
+ + +
+
+ + + diff --git a/pylib/versionInfo.idx b/pylib/versionInfo.idx new file mode 100644 index 000000000..879d2be81 --- /dev/null +++ b/pylib/versionInfo.idx @@ -0,0 +1,12 @@ +nimTitle versionInfo pylib/versionInfo.html module src/pylib/versionInfo 0 +nim PyReleaseLevelEnum pylib/versionInfo.html#PyReleaseLevelEnum enum PyReleaseLevelEnum 5 +nim Major pylib/versionInfo.html#Major const Major 12 +nim Minor pylib/versionInfo.html#Minor const Minor 13 +nim Patch pylib/versionInfo.html#Patch const Patch 14 +nim ReleaseLevel pylib/versionInfo.html#ReleaseLevel const ReleaseLevel 16 +nim Serial pylib/versionInfo.html#Serial const Serial 17 +nim PyMajor pylib/versionInfo.html#PyMajor const PyMajor 19 +nim PyMinor pylib/versionInfo.html#PyMinor const PyMinor 20 +nim PyPatch pylib/versionInfo.html#PyPatch const PyPatch 21 +nim PyReleaseLevel pylib/versionInfo.html#PyReleaseLevel const PyReleaseLevel 22 +nim PySerial pylib/versionInfo.html#PySerial const PySerial 23 diff --git a/src/pylib.nim b/src/pylib.nim deleted file mode 100755 index ade56e5c1..000000000 --- a/src/pylib.nim +++ /dev/null @@ -1,62 +0,0 @@ - -const WarnLeniOps = "`std/lenientops` was imported automatically. " & - "Compile with -d:pylibNoLenient to disable it " & - "if you wish to do int->float conversions yourself" - -when not defined(pylibNoLenient): - {.warning: WarnLeniOps.} - import std/lenientops - export lenientops - -when defined(nimdoc): - from pylib/version import Version - import std/macros - import std/strformat - import std/strutils - macro doc(s: static[string]): untyped = newCommentStmtNode s - - template hs(s): string = "https://" & s - const - RepoUrl = hs"github.com/nimpylib/pylib" - ReadmeUrl = RepoUrl & "?tab=readme-ov-file#nimpylib" - WikiUrl = RepoUrl & "/wiki" - template link(name, url: string): string = "[" & name & "](" & url & ")" - - const - homepage{.strdefine.} = hs"nimpylib.github.io/pylib" - func stripDoc(s: string): string = - result = s - var proto: string - const sep = "://" - let ls = s.split(sep, 1) - (proto, result) = (ls[0], ls[1]) - result.removePrefix"docs." - result = proto & sep & result - - doc "> Welcome to **NimPyLib** :sub:`" & Version & "`" # Nim's Markdown is RST-extended - doc fmt"""- link to {link("repo", ReadmeUrl)}, {link("wiki", WikiUrl)}, """ & - link("home", stripDoc homepage) - ## .. include:: ../doc/pylib.md - doc ".. warning:: " & WarnLeniOps - -import pylib/Lib/timeit - -when not defined(js) and not defined(nimscript): - import pylib/io - export io -import pylib/private/trans_imp - -impExp pylib, - noneType, pybool, builtins, - ops, pyerrors, - pysugar - - -template timeit*(repetitions: int, statements: untyped): untyped{.deprecated: - "will be removed from main pylib since 0.10, import it from `pylib/Lib` instead".} = - ## EXT. - ## - ## Mimics Pythons ``timeit.timeit()``, output shows more information than Pythons. - bind timeit - timeit(repetitions): - statements diff --git a/src/pylib/Lib/antigravity.nim b/src/pylib/Lib/antigravity.nim deleted file mode 100644 index e108af877..000000000 --- a/src/pylib/Lib/antigravity.nim +++ /dev/null @@ -1,2 +0,0 @@ -import std/browsers -openDefaultBrowser("https://nim-lang.org") diff --git a/src/pylib/Lib/array.nim b/src/pylib/Lib/array.nim deleted file mode 100644 index 56e0a67c6..000000000 --- a/src/pylib/Lib/array.nim +++ /dev/null @@ -1,599 +0,0 @@ -## array -## -## .. hint:: considering unicode array is deprecated since Python3.3, -## and will be removed in Python3.16, -## it's not implemented -## -## .. hint:: since python3.13, 'w' (Py_UCS4) array is introduced. -## here we use Rune in std/unicode as its item type. - -import ../version -import ../builtins/list -import ../mutSeqSliceOp -import ./collections/abc -import ./sys_impl/auditImpl/macrohelper - -template since_has_Py_UCS4(def) = - pysince(3, 13): def - -since_has_Py_UCS4: - import std/unicode - type Py_UCS4* = Rune ## inner - import ../pystring/strimpl - from ../pyerrors/simperr import TypeError - from ../builtins/reprImpl import pyreprImpl - -import ../pybytes/bytesimpl -import ../pybytearray -export bytesimpl - -import ../pybytes/bytesprefix -export bytesprefix - -import std/[macros, strutils, tables] -const JS = defined(js) -when not JS: - import std/endians -else: - from std/typetraits import toSigned, toUnsigned - type DataView{.pure.} = object - - -type - PyArray*[T] = distinct PyList[T] - -iterator mitems*[T](arr: var PyArray[T]): var T = - ## EXT. - runnableExamples: - var arr = array('i', [1, 2]) - for i in arr.mitems: - i *= 2 - assert arr == array('i', [2, 4]) - for i in PyList[T](arr).mitems(): yield i - -func setLen*[T](arr: var PyArray[T], n: int) = PyList[T](arr).setLen n # EXT. - -func len*[T](arr: PyArray[T]): int = PyList[T](arr).len - -# XXX: if use borrow: `Error: borrow with generic parameter is not supported` -func `@`*[T](arr: PyArray[T]): seq[T]{.inline.} = @(PyList[T](arr)) - -template itemsize*[T](arr: PyArray[T]): int = sizeof(T) - -func newPyArray*[T](len=0): PyArray[T]{.inline.} = PyArray[T] newPyList[T](len) -func newPyArray*[T](x: Iterable[T]): PyArray[T]{.inline.} = - ## unlike `array`_, when `x` is a literal, type conversion is always needed. - runnableExamples: - discard newPyArray[cint]([1.cint, 2]) - # or write: array('i', [1, 2]) - PyArray[T] list[T](x) - -func newPyArrayOfCap*[T](cap: int): PyArray[T]{.inline.} = - PyArray[T] newPyListOfCap[T](cap) - -func fromlist*[T](arr: var PyArray[T], ls: PyList[T]) = - arr.extend ls - -func tolist*[T](arr: PyArray[T]): PyList[T] = PyList[T] arr -func tolist*[T](arr: var PyArray[T]): var PyList[T] = PyList[T] arr - - -template genCmp(op){.dirty.} = - func op*[A, B](arr: PyArray[A], other: PyArray[B]): bool{.inline.} = - bind checkLenientOps - checkLenientOps A, B - list_decl.op(PyList[A](arr), PyList[B](other)) - - #[ -XXX: CPython's returns NotImplement for other mixin cmp, but nimpylib doesn't -go as CPython does, checking NotImplement and then raiseing TypeError, -so we just leave it not defined - ]# - -#[ CPython has special banches for same-type array: ``` -Fast path: - arrays with same types can have their buffers compared directly -``` - -That's because Python is dyn-typed whereas C is static-typed and lacks generics. -In Nim, it's no need to write such a banch on hand thanks to generics. -]# - -genCmp `==` -genCmp `<=` -genCmp `<` - -# ISO-C declare `sizeof(char)` is always 1, but not necessarily 8-bit. -when declared(cuchar): - # cuchar is deprecated long before, may it be removed? - {.push warning[deprecated]: off.} - static: assert cuchar.high.uint8 == uint8.high -else: - type cuchar*{.importc:"unsigned char".} = char ## unsigned char - -type SomeChar* = char|cschar|cuchar ## In C, `char`, `unsigned char`, `signed char` - ## are three distinct types, - ## that's, `char` is either signed or unsigned, - ## which is implementation-dependent, - ## unlike other integer types, - ## e.g. int is alias of `signed int` -when declared(cuchar): {.pop.} - -static: assert char is cchar - -func getPtr*[T](arr: sink PyArray[T]; i: Natural|BackwardsIndex): ptr T{.inline.} = - ## EXT. - ## unstable. - PyList[T](arr).getPtr i - -const has_copyMem = declared(copyMem) - -func frombytes*[C: SomeChar](arr: var PyArray[C], buffer: BytesLike) = - ## append byte from `buffer` to `arr` - let alen = arr.len - arr.setLen alen + buffer.len - when has_copyMem: - copyMem(arr.getPtr aLen, buffer.getCharPtr(0), buffer.len) - else: - var i = alen - for c in buffer.chars: - arr[i] = C(c) - i.inc - - -template getAddr(x): ptr = - when NimMajor == 1: x.unsafeAddr - else: x.addr - -func frombytes*[T: not SomeChar](arr: var PyArray[T], buffer: BytesLike) = - ## append byte from `buffer` to `arr` - runnableExamples: - when sizeof(cshort) == 2: - var h = array('h', [1, 2]) - h.frombytes(b"\x05\x00") - when cpuEndian == littleEndian: - assert h[2] == 5 - else: - assert h[2] == 1280 - - let bLen = buffer.len - if bLen mod arr.itemsize != 0: - raise newException(ValueError, "bytes length not a multiple of item size") - let aLen = arr.len - let aMoreLen = bLen div arr.itemsize - arr.setLen aLen + aMoreLen - when has_copyMem: - copyMem(arr.getPtr aLen, buffer.getCharPtr(0), aMoreLen*arr.itemsize) - else: - var i = alen - for c in buffer.chars: - arr[i] = cast[C](c) # So it does not change its binary - i.inc - -iterator items*[T](arr: PyArray[T]): T = - for i in arr.tolist: yield i - -func tobytes*[C: SomeChar](arr: PyArray[C]): PyBytes = - let - bLen = arr.len - var ba = bytearray bLen - when has_copyMem: - copyMem(ba.getCharPtr(0), arr.getPtr(0), bLen) - else: - var i = 0 - for c in arr: - ba[i] = cast[C](c) # So it does not change its binary - i.inc - bytes ba - -func tobytes*[T: not SomeChar](arr: PyArray[T]): PyBytes = - let - aLen = arr.len - bLen = aLen * arr.itemsize - var ba = bytearray bLen - when has_copyMem: - copyMem(ba.getCharPtr(0), arr.getPtr(0), blen) - else: - var i = 0 - for c in arr: - ba[i] = cast[C](c) # So it does not change its binary - i.inc - bytes ba - -func fromfile*[T](arr: var PyArray[T], f: File, n: int) = - ## This variant is optimitized for Nim's `File` - if n < 0: - raise newException(ValueError, "negative count") - #when declared(readBuffer): - let oldLen = arr.len - arr.setLen oldLen + n - let readBytes = f.readBuffer(arr.getPtr oldLen, n * arr.itemsize) - arr.setLen oldLen + readBytes * arr.itemsize - -func tofile*[T](arr: var PyArray[T], f: File) = - ## This variant is optimitized for Nim's `File` - #when declared(writeBuffer): - f.writeBuffer(arr.getPtr(0), arr.len * arr.itemsize) - -type - HasReadNRetBytesLike* = concept self - self.read(int) is BytesLike - HasWriteBytesLike* = concept self - self.write(BytesLike) - -func fromfile*[T](self: var PyArray[T], f: HasReadNRetBytesLike, n: int) = - if n < 0: - raise newException(ValueError, "negative count") - self.frombytes f.read(n) - -func tofile*[T](self: PyArray[T], f: HasWriteBytesLike) = - f.write(self.tobytes()) - -func mkTypecodes: string{.compileTime.} = - result = "bBu" - since_has_Py_UCS4: - result.add 'w' - result.add "hHiIlLqQfd" - -const typecodes* = mkTypecodes() - -# a table that will be used to map, e.g. 'h' to cshort, 'H' to cushort -const OriginTable = { - # char is treated specially, as `char` may be either signed or unsigned - 'h': "short", - 'i': "int", - 'l': "long", - 'q': "longlong", - # float and double are signed only -} - -const TypeTableSize = 2*OriginTable.len + 2 -func initTypeTable(): Table[char, string]{.compiletime.} = - result = initTable[char, string] TypeTableSize - result['b'] = "cschar"; result['B'] = "cuchar" - result['f'] = "cfloat"; result['d'] = "cdouble" - for (k, v) in OriginTable: - result[k] = 'c' & v - result[ k.toUpperAscii ] = "cu" & v - since_has_Py_UCS4: - result['w'] = "Py_UCS4" - -func initSizeTable(): Table[string, int]{.compiletime.} = - result = initTable[string, int] TypeTableSize - result["cschar"] = sizeof cchar - template genImpl(typS, typ) = - result[ typS ] = sizeof typ - template genU(typ) = - let cbase = astToStr(typ) - genImpl cbase, typ - template genS(typ) = - let - cbase = astToStr(typ) - base = cbase[1..^1] - ubase = "cu" & base - genImpl cbase, typ - genImpl ubase, typ - genS cchar - genS cshort - genS cint - genS clong - genS clonglong - - genU cfloat - genU cdouble - since_has_Py_UCS4: - genU Py_UCS4 -const SizeTable = initSizeTable() - - -const CodeTypeMap = initTypeTable() - -func getType(c: char): string{.inline.} = CodeTypeMap[c] - -template genWithTypeCode(mapper#[: Callable[[NimNode, char], NimNode]#): NimNode = - var result = newStmtList() - for k, v in CodeTypeMap.pairs(): - let typ = ident v - result.add mapper(typ, k) - result - -macro genTypeCodeGetters = - template mapper(typ, k): NimNode{.dirty.} = - # Currently, `char`/`cuchar`, `culong`/`clong` are some types considered as alias. - # who knows if this will change in the future, so just use `when not compiles` - let res = newLit k - quote do: - when not compiles(newPyArray[`typ`]().typecode): - template typecode*(_: PyArray[`typ`]): char = `res` - genWithTypeCode mapper - -genTypeCodeGetters() - -func buffer_info*[T](arr: PyArray[T]): tuple[ - address: int, length: int] = # maybe the address shall be pointer or ptr T? - result.address = cast[typeof result.address](arr[0].addr) - result.length = arr.len - - -template strImplBody[T](arr: PyArray[T], arrToStr) = - result = "array('" - result.add arr.typecode - result.add '\'' - if arr.len != 0: - result.add ", " - result.add arrToStr arr - result.add ')' - -since_has_Py_UCS4: - func tounicode*(arr: PyArray[Py_UCS4]): PyStr{.inline.} = - ## .. note:: as PyArray here is static-typed, - ## unlike CPython's, no ValueError will be raised - unicode.`$` @arr - func `$`*(arr: PyArray[Py_UCS4]): string{.inline.} = - template repr_tounicode(arr): string = pyreprImpl arr.tounicode() - strImplBody arr, repr_tounicode - -func `$`*[T](arr: PyArray[T]): string{.inline.} = - template normArrToStr(a): string = $PyList[T](arr) - strImplBody arr, normArrToStr - -# no need to perform any quote, as there're only integers, -# so repr can just the same as `__str__` -func repr*[T](arr: PyArray[T]): string = $arr ## alias for `$arr` - -since_has_Py_UCS4: - ## XXX: the `extend` is used by `array(c, ls)`, - ## And Py_UCS4-array's extend is not generic, - ## so it must be placed before `array` proc - static: assert Py_UCS4 is Rune - #static: assert compiles(array('w', "1")) - func extend*(self: var PyArray[Py_UCS4], s: PyStr) - -proc arrayTypeParse(typecode: char, typeStr: string): NimNode = - result = newCall( - nnkBracketExpr.newTree( - bindSym"newPyArray", - ident typeStr - ) - ) - -proc arrayTypeParse(typecode: char): NimNode = - arrayTypeParse typecode, getType typecode - -macro array*(typecode: static[char]): PyArray = - runnableExamples: - var a = array('i') - assert a.typecode == 'i' - assert len(a) == 0 - a.append(3) - assert a.len == 1 and a[0] == 3 - arrayTypeParse typecode - -proc parseArrInitLit(lit: NimNode, typeStr: string): NimNode = - if lit.kind != nnkBracket: return lit - let typeId = ident typeStr - result = nnkBracket.newTree: - newCall(typeId, lit[0]) - for i in 1.. 0, "unknown type " & typeStr - res - -template getBitSizeStr(typ): string = $getBitSize($typ) - - -# calls e.g. swapEndian64 -template swapProcForT(T: NimNode): NimNode = - ident "swapEndian" & getBitSizeStr(T) - -template swapByte[C: SomeChar](_: C) = discard # do nothing - -when JS: - proc newDataViewOfN(n: int): DataView{.importjs: "new DataView(new ArrayBuffer(#))".} - proc getUint[Res; N: static[int]](self: DataView, littleEndian: bool = false): Res = - {.emit: [result," = ",self,".getUint" & $N & "(0,",littleEndian,");"].} - proc setUint[N: static[int]](self: DataView, x: SomeUnsignedInt, littleEndian: bool = false) = - # XXX: if importjs: Error: cannot generate code for: N - static: - const Bytes = sizeof(x) * BitPerByte - assert Bytes == N, "using setUint" & $N & " on uint" & $Bytes - {.emit: [self,".setUint" & $N & "(0,",x,", ",littleEndian,");"].} - #proc swapByte(x: ) - -macro genSwapByte() = - template mapper(typ: NimNode; _): NimNode{.dirty.} = - let - procId = swapProcForT typ - quote do: - when not compiles( (var temp:`typ`; temp.swapByte()) ): - template swapByte(x: var `typ`) = - when JS: - const - byteSize = sizeof(`typ`) - bitSize = byteSize * BitPerByte - var dv = newDataViewOfN byteSize - when `typ` is SomeSignedInt: - template nx: untyped = cast[`typ`.toUnsigned](x) - else: - template nx: untyped = x - dv.setUint[:bitSize](nx, true) - x = dv.getUInt[:`typ`, bitSize]() - else: - var tmp: typeof(x) - `procId`(tmp.getAddr, x.getAddr) - x = tmp - genWithTypeCode mapper -genSwapByte() - -func byteswap*[T](arr: var PyArray[T]) = - ## array.byteswap - ## - ## Currently only compilable for `c_*` types, - ## a.k.a. not for Nim's `int*`, e.g. `int16` - ## - ## .. hint:: trial of using this method on `PyArray[int*]` may lead to - ## compile-error of C compiler. - runnableExamples: - when sizeof(cshort) == 2: - var arr = array('h', [1, 2]) - arr.byteswap() - assert arr[0] == 256, $arr[0] # int from \x01\x00 - assert arr[1] == 512, $arr[1] - for x in arr.mitems(): - swapByte x - -# `tolist(var PyArray): PyList` doesn't be called impilitly when array's self-modifiaction -# methods are called - -template EmptyN: NimNode = newEmptyNode() - -proc wrapMethImpl(sym: NimNode; paramColonExprs: openArray[NimNode], resType=EmptyN): NimNode = - ## wrap mutable method - # template sym*[T](arr: PyArray[T], ...) = sym(arr.tolist, arg...) - let emptyn = EmptyN - let self = ident"arr" - let genericType = ident"T" - let selfType = nnkBracketExpr.newTree(ident"PyArray", genericType) - # as this generates a template, no need to mark param as var - #newIdentDefs(self, nnkVarTy.newTree(ident"PyArray")) - var procParams = @[ - resType, - newIdentDefs(self, selfType) - ] - var wrappedCall = newCall: - self.newDotExpr(bindSym"tolist").newCall().newDotExpr(sym) - for colonExpr in paramColonExprs: - expectKind colonExpr, nnkExprColonExpr - let (param, typ) = (colonExpr[0], colonExpr[1]) - procParams.add newIdentDefs(param, typ) - wrappedCall.add param - let body = newStmtList().add( - nnkBindStmt.newTree(sym), - wrappedCall) - let - pragmas = newEmptyNode() - generics = nnkGenericParams.newTree( - newIdentDefs( - genericType, emptyn, emptyn - ) - ) - result = nnkTemplateDef.newTree( - postfix(sym, "*"), - emptyn, # rewrite pattern - generics, - newNimNode(nnkFormalParams).add(procParams), - pragmas, - emptyn, # reserved - body) - -macro wrapMeth(sym: untyped; resType; paramColonExprs: varargs[untyped]) = - var ls: seq[NimNode] - for p in paramColonExprs: ls.add p - wrapMethImpl(sym, ls, resType) -macro wrapMMeth(sym: untyped; paramColonExprs: varargs[untyped]) = - # as wrapMeth generates a template, - # so just use it even though `self` is in fact a var param. - var ls: seq[NimNode] - for p in paramColonExprs: ls.add p - wrapMethImpl(sym, ls) - -# len is defined above -wrapMeth(`[]`, T, i: int) -wrapMeth(contains, bool, x: T) -wrapMeth(items, untyped) - -wrapMMeth(`[]=`, i: int, val: T) -wrapMMeth(delitem, n: int) -wrapMMeth(`+=`, x: untyped) -wrapMMeth(`*=`, n: int) - - -wrapMMeth(append, x: T) -wrapMMeth(extend, x: untyped) -wrapMMeth(insert, x: T) -wrapMMeth(remove, x: T) -wrapMMeth(pop) -wrapMMeth(pop, i: int) -wrapMMeth(reverse) - -pysince(3,13): - wrapMMeth(clear) - -since_has_Py_UCS4: - func `[]=`*(self: var PyArray[Py_UCS4], i: int, v: char){.inline.} = - runnableExamples: - from std/unicode import Rune - var a = array('w', "123") - a[0] = Rune(65) - a[1] = '3' - self[i] = Rune v - func asRune(s: string): Rune = - when not defined(danger): - let le = s.runeLen - if le != 1: - raise newException(TypeError, "array item must be a unicode character, " & - "not a string of length " & $le) - s.runeAt 0 - func `[]=`*(self: var PyArray[Py_UCS4], i: int, v: string){.inline.} = - self[i] = v.asRune - - func w_getitem(self: var PyArray[Py_UCS4], i: int): Py_UCS4{.inline.} = self[i] - func `[]=`*(self: var PyArray[Py_UCS4], i: int): PyStr{.inline.} = str self.w_getitem i - func fromunicode*(self: var PyArray[Py_UCS4], s: PyStr){.inline.} = - ## .. note:: as PyArray here is static-typed, - ## unlike CPython's, no ValueError will be raised - for r in s.runes: - self.append r - func extend*(self: var PyArray[Py_UCS4], s: PyStr) = self.fromunicode s - func append*(self: var PyArray[Py_UCS4], s: PyStr){.inline.} = - self.append s.asRune - -genDelItem PyArray -genGenericSetItem PyArray, Sequence diff --git a/src/pylib/Lib/bisect.nim b/src/pylib/Lib/bisect.nim deleted file mode 100644 index b5d40b263..000000000 --- a/src/pylib/Lib/bisect.nim +++ /dev/null @@ -1,44 +0,0 @@ - -import ./n_bisect -import std/sequtils -import ../noneType - -import ./collections/abc - -template genbi(name){.dirty.} = - proc name*[T; K](a: Sequence[T], x: K, lo=0, hi=len(a), - key: NoneType|Key[T, K] = None): int = - template oa: openArray{.dirty.} = - when compiles(a.toOpenArray(lo, hi)): - let - lo = 0 - hi = len(a) - a.toOpenArray(lo, hi) - elif compiles(@a): - @a - elif compiles(a.toSeq): - a.toSeq - else: - {.error: "not impl".} - when key is NoneType: - n_bisect.name(oa, x, lo, hi) - else: - n_bisect.name(oa, x, lo, hi, key) - -genbi bisect_left -genbi bisect_right -genbi bisect - -export insort, insort_left, insort_right - -template genin(name, bi){.dirty.} = - proc name*[T; K](a: MutableSequence[T], x: K, lo=0, hi=len(a), - key: NoneType|Key[T, K] = None) = - let lohi = bi(a, x, lo, hi) - a.insert(lohi, x) - -genin insort_left, bisect_left -genin insort_right, bisect_right -genin insort, bisect - - diff --git a/src/pylib/Lib/builtins.nim b/src/pylib/Lib/builtins.nim deleted file mode 100644 index b005681f3..000000000 --- a/src/pylib/Lib/builtins.nim +++ /dev/null @@ -1,2 +0,0 @@ -import ../builtins -export builtins diff --git a/src/pylib/Lib/cmath.nim b/src/pylib/Lib/cmath.nim deleted file mode 100644 index 3eaa853e3..000000000 --- a/src/pylib/Lib/cmath.nim +++ /dev/null @@ -1,58 +0,0 @@ -## Lib/cmath -## -## complex math library for [Python's complex](../builtins/complex.html) - -import ../builtins/complex - -import std/complex as ncomplex except complex -from std/math import ln -from ./n_math import - isinf, isfinite, isclose, - pi, e, tau, inf, nan, - py_math_isclose_impl -export pi, e, tau, inf, nan - -const nanj*: PyComplex = complex(0.0, nan) -const infj*: PyComplex = complex(0.0, inf) - - -template expCC(sym){.dirty.} = - template sym*(z: PyTComplex): PyTComplex = - bind toNimComplex, pycomplex, sym - sym(z.toNimComplex).pycomplex - - -func rect*[T](r, phi: T): PyTComplex[T] = - ncomplex.rect(r, phi).toNimComplex - -expCC phase -expCC polar -expCC exp -expCC log10 -expCC sqrt -expCC sin - - -func isclose*(a,b: Complex, rel_tol=1e-09, abs_tol=0.0): bool = - py_math_isclose_impl(abs=abs) - -func log*[T](z: PyTComplex[T]): PyTComplex[T] = ln(z) ## ln(z) -func log*[T](z: PyTComplex[T], base: SomeNumber|PyTComplex[T]): PyTComplex[T] = (ln(z) / ln(base)).pycomplex - -template expAs(sym, alias){.dirty.} = - template alias*(x: PyTComplex): untyped = - bind pycomplex - sym(x).pycomplex - -expAs arccos, acos -expAs arcsin, asin -expAs arctan, atan -expAs arccosh, acosh -expAs arcsinh, asinh -expAs arctanh, atanh - -template both(fn){.dirty.} = - func fn*(z: PyTComplex): bool = z.re.fn and z.im.fn - -both isfinite -both isnan diff --git a/src/pylib/Lib/collections/abc.nim b/src/pylib/Lib/collections/abc.nim deleted file mode 100644 index 90bd6451b..000000000 --- a/src/pylib/Lib/collections/abc.nim +++ /dev/null @@ -1,3 +0,0 @@ - -import ../../collections_abc -export collections_abc diff --git a/src/pylib/Lib/datetime.nim b/src/pylib/Lib/datetime.nim deleted file mode 100644 index f2136a536..000000000 --- a/src/pylib/Lib/datetime.nim +++ /dev/null @@ -1,41 +0,0 @@ - -import ./n_datetime - -export n_datetime except tzname, isoformat, strftime, ctime - -import ../pystring/strimpl -import ../noneType -import ./typing_impl/str_optional_obj -expOptObjCvt() -import ../pyerrors/simperr - - -method tzname*(tz: tzinfo; dt: datetime): PyStr{.base.} = - str n_datetime.tzname(tz, dt) -method tzname*(tz: timezone; dt: datetime): PyStr = - str n_datetime.tzname(tz, dt) -func tzname*(dt: datetime): OptionalObj[PyStr] = - newStrOptionalObj n_datetime.tzname(dt) - -using self: datetime # | date -func strftime*(self; format: PyStr): PyStr = str n_datetime.strftime(self, $format) -func isoformat*(self; sep: StringLike = 'T', timespec="auto"): PyStr = - template lenErr = - raise newException(TypeError, "isoformat() argument 1 must be a unicode character, not str") - when system.`is`(sep, string): - # NIM-BUG: have to prefix by `system` once optional_obj.`is` imported - let sep = str sep - if sep.len != 1: lenErr() - when system.`is`(sep, char): - let ch = sep - else: - let ch = $sep - str n_datetime.isoformat(self, sep=ch, timespec=timespec) -func str*(self): PyStr = self.isoformat(' ') -func str*(self: timedelta): PyStr = $self -func ctime*(self): PyStr = str n_datetime.ctime(self) - -func `==`*(tzinfo: tzinfo, n: NoneType): bool = tzinfo.isTzNone -func `==`*(delta: timedelta, n: NoneType): bool = delta.isTimeDeltaNone - -converter noneToTzInfo*(_: NoneType): tzinfo = TzNone diff --git a/src/pylib/Lib/datetime_impl/consts.nim b/src/pylib/Lib/datetime_impl/consts.nim deleted file mode 100644 index 8d5ea1fd1..000000000 --- a/src/pylib/Lib/datetime_impl/consts.nim +++ /dev/null @@ -1,6 +0,0 @@ - -from ./datetime_impl/meth/inner_consts import MAXYEAR, MINYEAR -from ./timezone_impl/decl import UTC - -export MAXYEAR, MINYEAR, UTC - diff --git a/src/pylib/Lib/datetime_impl/datetime_impl.nim b/src/pylib/Lib/datetime_impl/datetime_impl.nim deleted file mode 100644 index 8ac026814..000000000 --- a/src/pylib/Lib/datetime_impl/datetime_impl.nim +++ /dev/null @@ -1,6 +0,0 @@ - -import ./datetime_impl/[ - decl, meth -] - -export decl, meth diff --git a/src/pylib/Lib/datetime_impl/datetime_impl/decl.nim b/src/pylib/Lib/datetime_impl/datetime_impl/decl.nim deleted file mode 100644 index 0a591682c..000000000 --- a/src/pylib/Lib/datetime_impl/datetime_impl/decl.nim +++ /dev/null @@ -1,8 +0,0 @@ - -import ./inner_decl -export inner_decl except hashcode, `hashcode=`, isfold -#[ - we split decl into inner_decl, decl - and we did not merge this to ./meth.nim as we control export: - ``export inner_decl except hashcode, `hashcode=` `` -]# diff --git a/src/pylib/Lib/datetime_impl/datetime_impl/inner_decl.nim b/src/pylib/Lib/datetime_impl/datetime_impl/inner_decl.nim deleted file mode 100644 index 7a99899aa..000000000 --- a/src/pylib/Lib/datetime_impl/datetime_impl/inner_decl.nim +++ /dev/null @@ -1,50 +0,0 @@ - -import std/times -import ../timezone_impl/decl - -type - datetime* = ref object - dt: Datetime - tzinfo*: tzinfo - isfold: bool - hashcode: int - PyDatetime* = datetime - -func newDatetime*(dt: Datetime, tzinfo: tzinfo = nil, isfold = false): datetime = - datetime(dt: dt, tzinfo: tzinfo, isfold: isfold) - -func asNimDatetime*(self: datetime): DateTime = self.dt - -using self: datetime -func isfold*(self): bool = self.isfold -template wrap(dtA, DtA){.dirty.} = - func dtA*(self): int = self.dt.DtA -template wrap(dtA) = wrap(dtA, dtA) - -template wrap(dtA, DtA, cvt){.dirty.} = - func dtA*(self): int = self.dt.DtA.cvt - -wrap year -wrap month, month, ord -wrap day, monthday -wrap hour -wrap minute -wrap second -template ns2us(ns): untyped = ns div 1000 -wrap microsecond, nanosecond, ns2us -func fold*(self): int = int self.isfold - -proc newDatetime*(self: datetime, - tzinfo: tzinfo = self.tzinfo, isfold = self.isfold): datetime = - newDatetime( - dateTime( - self.dt.year, - self.dt.month, self.dt.monthday, - self.dt.hour, self.dt.minute, self.dt.second, - self.microsecond, - zone = tzToNimTimezone tzinfo - ), tzinfo, isfold - ) - -func hashcode*(self): int = self.hashcode -func `hashcode=`*(self; h: int) = self.hashcode = h diff --git a/src/pylib/Lib/datetime_impl/datetime_impl/meth.nim b/src/pylib/Lib/datetime_impl/datetime_impl/meth.nim deleted file mode 100644 index b29bf3f05..000000000 --- a/src/pylib/Lib/datetime_impl/datetime_impl/meth.nim +++ /dev/null @@ -1,8 +0,0 @@ - -import ./meth/[ - consts, statics, init, getter, getter_requires_op, getter_of_date, - hashImpl, op, aszone, isoformat, require_time_module, formats -] - -export consts, statics, init, getter, getter_requires_op, getter_of_date, - hashImpl, op, aszone, isoformat, require_time_module, formats diff --git a/src/pylib/Lib/datetime_impl/datetime_impl/meth/aszone.nim b/src/pylib/Lib/datetime_impl/datetime_impl/meth/aszone.nim deleted file mode 100644 index 40f192962..000000000 --- a/src/pylib/Lib/datetime_impl/datetime_impl/meth/aszone.nim +++ /dev/null @@ -1,101 +0,0 @@ - -include ./common - -import ../../timedelta_impl/[decl, meth] -import ../../timezone_impl/[decl, meth_by_datetime_getter, meth_by_datetime] - -import ./time_utils, ./zonename_utils, ./to_seconds_utils -from ./state_consts import CONST_EPOCH, utc_timezone -import ./op - -when not HAVE_STRUCT_TM_TM_ZONE: - import ./init - import ./struct_tm_helper # cTmToNormCall - proc newDatetime(tm: Tm): datetime = - cTmToNormCall(datetime, tm, fold=0) - -proc getUtcOffset(local_time_tm: Tm, timestamp: time_t): timedelta = - ## `local_time_tm` shall be getten via `localtime` with `timestamp` as arg - when HAVE_STRUCT_TM_TM_ZONE: - result = newTimedelta(0, local_time_tm.tm_gmtoff, 0, true) - else: - let local_time = newDatetime(local_time_tm) - let utc_time_tm = nTime_gmtime(timestamp) - let utc_time = newDatetime(utc_time_tm) - result = local_time - utc_time - -proc local_timezone_from_timestamp(timestamp: time_t): timezone = - var local_time_tm = nTime_localtime timestamp - let nameo = local_time_tm.zonename - - let delta = local_time_tm.getUtcOffset timestamp - result = newPyTimezone(delta, nameo) - -proc local_timezone(utc_time: datetime): timezone = - let delta = utc_time - CONST_EPOCH - let one_second = newTimedelta(0, 1, 0, false) - let seconds = delta // one_second - let timestamp = time_t(seconds) - return local_timezone_from_timestamp(timestamp) - -proc local_timezone_from_local(local_dt: datetime): timezone = - - template withFold(fold): untyped = - local_to_seconds( - local_dt.year, local_dt.month, local_dt.day, - local_dt.hour, local_dt.minute, local_dt.second, - fold) - let fold = local_dt.fold - var seconds = withFold fold - template invalRaise(sec) = - #if sec == -1: raise newException(OverflowError, - # "timestamp out of range for platform time_t") - # Nim handles overflow and raises OverflowDefect - discard - invalRaise seconds - let seconds2 = withFold int(bool(fold)) - invalRaise seconds2 - # Detect gap - if seconds2 != seconds and (seconds2 > seconds) == bool(fold): - seconds = seconds2 - - let - diff = seconds - epoch - timestamp = time_t(diff) - return local_timezone_from_timestamp(timestamp) - -proc astimezone*(self: datetime; tz = TzNone): datetime = - ## not the same as `DateTime.inZone(Timezone)` - var - tzinfo = tz - self_tzinfo: tzinfo - template setNaive = - self_tzinfo = local_timezone_from_local(self) - if self.tzinfo.isTzNone: - setNaive() - else: - self_tzinfo = self.tzinfo - - # Conversion to self's own time zone is a NOP. - if self_tzinfo == tzinfo: - return self - - # Convert self to UTC. - let offset = self_tzinfo.utcoffset(self) - if offset.isTimeDeltaNone: - setNaive() - result = self - offset - - # Make sure result is aware and UTC. - if result.tzinfo.isTzNone: - result = newDatetime(result, tzinfo=timezone.utc) - else: - # Result is already aware - just replace tzinfo. - result.tzinfo = utc_timezone - - # Attach new tzinfo and let fromutc() do the rest. - if tzinfo.isTzNone: - tzinfo = local_timezone(result) - - result.tzinfo = tzinfo - result = tzinfo.fromutc(result) diff --git a/src/pylib/Lib/datetime_impl/datetime_impl/meth/calendar_utils.nim b/src/pylib/Lib/datetime_impl/datetime_impl/meth/calendar_utils.nim deleted file mode 100644 index 02a1df661..000000000 --- a/src/pylib/Lib/datetime_impl/datetime_impl/meth/calendar_utils.nim +++ /dev/null @@ -1,176 +0,0 @@ -# translated from CPython-3.14.0-alpha/Modules/_datetimemodule.c -##[ - General calendrical helper functions - - For each month ordinal in 1..12, the number of days in that month, - and the number of days before that month in the same year. These - are correct for non-leap years only. -]## - -import std/times -from ./inner_consts import MINYEAR, MAXYEAR - -template days_in_month(year, month: int): int = getDaysInMonth(month.Month, year) - -template is_leap(year): bool = isLeapYear(year) - -const arr_days_before_month: array[1..12, int] = [ - 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334] - -func days_before_month*(year, month: int): int = - ## year, month -> number of days in year preceding first day of month - - assert(month >= 1); - assert(month <= 12); - result = arr_days_before_month[month]; - if month > 2 and is_leap(year): - result.inc - -func days_before_year(year: int): int = - ## year -> number of days before January 1st of year. Remember that we - ## start with year 1, so days_before_year(1) == 0. - let y = year - 1; - #[ This is incorrect if year <= 0; we really want the floor - here. But so long as MINYEAR is 1, the smallest year this - can see is 1. - ]# - assert (year >= 1); - return y*365 + y div 4 - y div 100 + y div 400 - -func ymd_to_ord*(year, month, day: int): int = - ## year, month, day -> ordinal, considering 01-Jan-0001 as day 1. - days_before_year(year) + days_before_month(year, month) + day; - - -const - DI4Y = 1461 ## Number of days in 4, 100, and 400 year cycles. That these have - ## the correct values is asserted in the module init function. - ## - DI100Y = 36524 - DI400Y = 146097 - -type - YMD* = tuple[ - year, month, day: int - ] -proc ord_to_ymd*(ordinal: int, result: var YMD) = - ## ordinal -> year, month, day, considering 01-Jan-0001 as day 1. - - ## ordinal is a 1-based index, starting at 1-Jan-1. The pattern of - ## leap years repeats exactly every 400 years. The basic strategy is - ## to find the closest 400-year boundary at or before ordinal, then - ## work with the offset from that boundary to ordinal. Life is much - ## clearer if we subtract 1 from ordinal first -- then the values - ## of ordinal at 400-year boundaries are exactly those divisible - ## by DI400Y: - ## - ## D M Y n n-1 - ## -- --- ---- ---------- ---------------- - ## 31 Dec -400 -DI400Y -DI400Y -1 - ## 1 Jan -399 -DI400Y +1 -DI400Y 400-year boundary - ## ... - ## 30 Dec 000 -1 -2 - ## 31 Dec 000 0 -1 - ## 1 Jan 001 1 0 400-year boundary - ## 2 Jan 001 2 1 - ## 3 Jan 001 3 2 - ## ... - ## 31 Dec 400 DI400Y DI400Y -1 - ## 1 Jan 401 DI400Y +1 DI400Y 400-year boundary - ## - assert(ordinal >= 1) - let ordinal = ordinal - 1 - let n400 = ordinal div DI400Y - var n = ordinal mod DI400Y - result.year = n400 * 400 + 1 - # Now n is the (non-negative) offset, in days, from January 1 of - # year, to the desired date. Now compute how many 100-year cycles - # precede n. - # Note that it's possible for n100 to equal 4! In that case 4 full - # 100-year cycles precede the desired day, which implies the - # desired day is December 31 at the end of a 400-year cycle. - # - let n100 = n div DI100Y - n = n mod DI100Y - # Now compute how many 4-year cycles precede it. - let n4 = n div DI4Y - n = n mod DI4Y - # And now how many single years. Again n1 can be 4, and again - # meaning that the desired day is December 31 at the end of the - # 4-year cycle. - # - let n1 = n div 365 - n = n mod 365 - inc(result.year, n100 * 100 + n4 * 4 + n1) - if n1 == 4 or n100 == 4: - assert(n == 0) - dec(result.year, 1) - result.month = 12 - result.day = 31 - return - let leapyear = n1 == 3 and (n4 != 24 or n100 == 3) - assert(leapyear == is_leap(result.year)) - result.month = (n + 50) shr 5 - var preceding = (arr_days_before_month[result.month] + - int(result.month > 2 and leapyear)) - if preceding > n: - ## estimate is too large - dec(result.month, 1) - dec(preceding, days_in_month(result.year, result.month)) - dec(n, preceding) - assert(0 <= n) - assert(n < days_in_month(result.year, result.month)) - result.day = n + 1 - -proc ymd_to_ord*(ymd: YMD): int = - ## year, month, day -> ordinal, considering 01-Jan-0001 as day 1. - days_before_year(ymd.year) + days_before_month(ymd.year, ymd.month) + ymd.day - -proc weekday*(year, month, day: int): int = - ## Day of week, where Monday==0, ..., Sunday==6. 1/1/1 was a Monday. - (ymd_to_ord(year, month, day) + 6) mod 7 - -proc iso_week1_monday*(year: int): int = - let - first_day = ymd_to_ord(year, 1, 1) - first_weekday = (first_day + 6) mod 7 - result = first_day - first_weekday - if first_weekday > 3: - result += 7 - -template raiseValErr(pre: string, i: int, suf: string) = - raise newException(ValueError, pre & $i & suf) -template raiseValErr(pre: string, i: int) = - raise newException(ValueError, pre & $i) - -type - YWD* = tuple[ - year, week, day: int - ] - -proc iso_to_ymd*(iso: YWD, ymd: var YMD) = - ## Year is bounded to 0 < year < 10000 because 9999-12-31 is (9999, 52, 5) - if iso.year < MINYEAR or iso.year > MAXYEAR: - raiseValErr "Year is out of range: ", iso.year - - if iso.week <= 0 or iso.week >= 53: - var out_of_range = true - if iso.week == 53: - # ISO years have 53 weeks in it on years starting with a Thursday - # and on leap years starting on Wednesday - let first_weekday = weekday(iso.year, 1, 1) - if first_weekday == 3 or (first_weekday == 2 and is_leap(iso.year)): - out_of_range = false - - if out_of_range: - raiseValErr "Invalid week: ", iso.week - - if iso.day <= 0 or iso.day >= 8: - raiseValErr "Invalid day: ", iso.day, " (range is [1, 7])" - - let - day_1 = iso_week1_monday(iso.year) - day_offset = (iso.week - 1) * 7 + iso.day - 1 - - ord_to_ymd(day_1 + day_offset, ymd) - diff --git a/src/pylib/Lib/datetime_impl/datetime_impl/meth/common.nim b/src/pylib/Lib/datetime_impl/datetime_impl/meth/common.nim deleted file mode 100644 index 0abb468c3..000000000 --- a/src/pylib/Lib/datetime_impl/datetime_impl/meth/common.nim +++ /dev/null @@ -1,2 +0,0 @@ - -import ../decl diff --git a/src/pylib/Lib/datetime_impl/datetime_impl/meth/consts.nim b/src/pylib/Lib/datetime_impl/datetime_impl/meth/consts.nim deleted file mode 100644 index 954007215..000000000 --- a/src/pylib/Lib/datetime_impl/datetime_impl/meth/consts.nim +++ /dev/null @@ -1,9 +0,0 @@ - -include ./common -import ./init -import ./inner_consts -import ../../timedelta_impl/decl - -func max*(_: typedesc[datetime]): datetime = datetime(MAXYEAR, 12, 31, 23, 59, 59, 999999) -func min*(_: typedesc[datetime]): datetime = datetime.datetime(MINYEAR, 1, 1, 0, 0) -func resolution*(_: typedesc[datetime]): timedelta = timedelta.resolution diff --git a/src/pylib/Lib/datetime_impl/datetime_impl/meth/errno_decl.nim b/src/pylib/Lib/datetime_impl/datetime_impl/meth/errno_decl.nim deleted file mode 100644 index 1affe8263..000000000 --- a/src/pylib/Lib/datetime_impl/datetime_impl/meth/errno_decl.nim +++ /dev/null @@ -1,6 +0,0 @@ - - -{.push header: "".} -var errno*{.importc.}: cint -let EINVAL*{.importc.}: cint -{.pop.} diff --git a/src/pylib/Lib/datetime_impl/datetime_impl/meth/format_utcoffset.nim b/src/pylib/Lib/datetime_impl/datetime_impl/meth/format_utcoffset.nim deleted file mode 100644 index e50ad8804..000000000 --- a/src/pylib/Lib/datetime_impl/datetime_impl/meth/format_utcoffset.nim +++ /dev/null @@ -1,17 +0,0 @@ - -include ./common -from std/times import toParts -import ../../timedelta_impl/decl -import ../../timezone_impl/[ - decl as timezone_decl, meth_by_datetime_getter -] -from ./importer import NotImplementedError - -func add_format_utcoffset*(s: var string, sep: string, tzinfo: tzinfo, tzinfoarg: datetime) = - ## `tzinfo` must not be nil - var offset: timedelta - try: - offset = tzinfo.utcoffset(tzinfoarg) - except ValueError, NotImplementedError: - return - s.add format_utcoffset(offset.asDuration.toParts(), sep, prefix="") diff --git a/src/pylib/Lib/datetime_impl/datetime_impl/meth/formats.nim b/src/pylib/Lib/datetime_impl/datetime_impl/meth/formats.nim deleted file mode 100644 index 21726c85c..000000000 --- a/src/pylib/Lib/datetime_impl/datetime_impl/meth/formats.nim +++ /dev/null @@ -1,16 +0,0 @@ - -include ./common -import ./isoformat -import ./require_time_module - -using value: datetime # | date -func formatValue*(result: var string; value; specifier: string) = - ## for std/strformat's fmt - if specifier.len == 0: - result.add isoformat.`$` value - return - result.add value.strftime(specifier) - -using self: datetime # | date -func format*(self; format_spec = ""): string = - result.formatValue(self, format_spec) diff --git a/src/pylib/Lib/datetime_impl/datetime_impl/meth/fromisoformat.nim b/src/pylib/Lib/datetime_impl/datetime_impl/meth/fromisoformat.nim deleted file mode 100644 index 8026d9471..000000000 --- a/src/pylib/Lib/datetime_impl/datetime_impl/meth/fromisoformat.nim +++ /dev/null @@ -1,326 +0,0 @@ - -include ./common -import ./calendar_utils -import ./init -import ../../timezone_impl/decl -import ../../timedelta_impl/decl - -from std/strutils import isDigit # is_digit -from std/parseutils import parseInt -#import std/strscans # cannot for openArray[char], but string only - - -func parse_digits(s: openArray[char], res: var int): int = - parseInt(s, res) - -func parse_digits(s: openArray[char], res: var int, num_digits: int): int = - parseInt(s.toOpenArray(0, num_digits-1), res) - -template parseOr[I: SomeInteger](res: var I; n: int; incVar: var int; destStr; elseDo) = - when I is_not int: - var temp: int - let nparsed = parse_digits(destStr.toOpenArray(incVar, incVar+n-1), - temp) - res = I(temp) - else: - let nparsed = parse_digits(destStr.toOpenArray(incVar, incVar+n-1), - res) - if nparsed != n: - elseDo - incVar.inc nparsed - -using dtstr: string - -func parse_isoformat_date(dtstr; len: int, ymd: var YMD): int = - ##[Parse the date components of the result of date.isoformat() - * - Return codes: - 0: Success - -1: Failed to parse date component - -2: Inconsistent date separator usage - -3: Failed to parse ISO week. - -4: Failed to parse ISO day. - raises ValueError: Failure in iso_to_ymd]## - var parsed = 0 - template parseOr(res: var SomeInteger; n: int; elseDo) = - parseOr(res, n, parsed, dtstr): elseDo - ymd.year.parseOr(4): - return -1 - let uses_separator = dtstr[parsed] == '-' - if uses_separator: - parsed.inc - template chkAndSkipSep = - if uses_separator: - if dtstr[parsed] != '-': - return -2 - parsed.inc - if dtstr[parsed] == 'W': - # This is an isocalendar-style date string - parsed.inc - var ywd: YWD - ywd.year = ymd.year - ywd.week.parseOr(2): - return -3 - if parsed < len: - chkAndSkipSep - ywd.day.parseOr(1): - return -4 - else: - ywd.day = 1 - - iso_to_ymd(ywd, ymd) - else: - ymd.month.parseOr(2): - return -1 - chkAndSkipSep - ymd.day.parseOr(2): - return -1 - -type - HMS = tuple[ - hour, minute, second: int8 - ] - US = int32 - -func parse_hh_mm_ss_ff(arr: openArray[char], hms: var HMS, us: var US, - highIdx = arr.high): int = - ## Parse [HH[:?MM[:?SS]]][Df{1,}][^\d]* where D is either . or , - ## returns 0 if it exceeds the end of the string, judged from `highIdx` - ## returns 1 if it's not the end - - let hi = arr.high - # Parse [HH[:?MM[:?SS]]] - var idx = 0 - template parseOr(res: var SomeInteger, n: int; elseDo) = - parseOr(res, n, idx, arr): elseDo - template chkBound = - if idx >= hi: - return int(idx <= highIdx) - template chk2MoreLeft = - # check there are at least 2 chars to parse - if idx + 1 > hi: - return -3 - template eat(attr) = - parseOr(hms.attr, 2): - return -3 - chkBound - template curIsColon: bool = arr[idx] == ':' - template chkColon = - if has_separator: - if not curIsColon: - return -4 # Malformed time separator - idx.inc - chk2MoreLeft - eat hour - var has_separator = curIsColon - if has_separator: - idx.inc - chk2MoreLeft - eat minute - chkColon - chk2MoreLeft - eat second - - # Parse fractional components - if arr[idx] == '.' or arr[idx] == ',': - idx.inc - - let - len_remains = hi + 1 - idx - to_parse = min(len_remains, 6) - var i = -1 - let parsed = parse_digits(arr.toOpenArray(idx, arr.high), i, to_parse) - if parsed != to_parse: - return -3 - {.push overflowChecks: off, boundChecks: off, rangeChecks: off.} - us = US(i) # we know there will be no overflow - const correction = [US(100000), 10000, 1000, 100, 10] - if to_parse < 6: - # append 0 to end of int - us = us *% correction[to_parse - 1] - {.pop.} - while idx <= hi and is_digit(arr[idx]): - idx.inc - return int(idx <= highIdx) - -func parse_isoformat_time(dtstr: openArray[char]; dtlen: int, - hms: var HMS, us: var US, tzoffset: var int, tzmicrosecond: var US): int = - let hi = dtlen - 1 - var - tzinfo_pos = dtlen # init with an invalid pos - tzinfo_sign_char: char - for i, c in dtstr: - if c == 'Z' or c == '+' or c == '-': - tzinfo_pos = i - tzinfo_sign_char = c - var rv = parse_hh_mm_ss_ff( - dtstr.toOpenArray(0, tzinfo_pos-1), hms, us, - highIdx = hi - ) - - if rv < 0: - return rv - elif tzinfo_pos == dtlen: - # We know that there's no time zone, so if there's stuff at the - # end of the string it's an error. - if rv == 1: - return -5 - else: - return 0 - # Special case UTC / Zulu time. - if tzinfo_sign_char == 'Z': - tzoffset = 0 - tzmicrosecond = 0 - if tzinfo_pos != hi: - return -5 - else: - return 1 - let tzsign = US(if tzinfo_sign_char == '-': -1 else: 1) - tzinfo_pos.inc - var tz_hms: HMS - rv = parse_hh_mm_ss_ff( - dtstr.toOpenArray(tzinfo_pos, hi), - tz_hms, tzmicrosecond) - type Offset = typeof(tzoffset) - tzoffset = tzsign * ((tz_hms.hour.Offset * 3600) + (tz_hms.minute.Offset * 60) + tz_hms.second.Offset) - tzmicrosecond *= tzsign - - return if bool(rv): -5 else: 1 - -func find_isoformat_datetime_separator(dtstr): int = - ##[The valid date formats can all be distinguished by characters 4 and 5 -and further narrowed down by character -which tells us where to look for the separator character. -Format | As-rendered | Position ---------------------------------------- -%Y-%m-%d | YYYY-MM-DD | 10 -%Y%m%d | YYYYMMDD | 8 -%Y-W%V | YYYY-Www | 8 -%YW%V | YYYYWww | 7 -%Y-W%V-%u | YYYY-Www-d | 10 -%YW%V%u | YYYYWwwd | 8 -%Y-%j | YYYY-DDD | 8 -%Y%j | YYYYDDD | 7 - -Note that because we allow *any* character for the separator, in the -case where character 4 is W, it's not straightforward to determine where -the separator is — in the case of YYYY-Www-d, you have actual ambiguity, -e.g. 2020-W01-0000 could be YYYY-Www-D0HH or YYYY-Www-HHMM, when the -separator character is a number in the former case or a hyphen in the -latter case. - -The case of YYYYWww can be distinguished from YYYYWwwd by tracking ahead -to either the end of the string or the first non-numeric character — -since the time components all come in pairs YYYYWww#HH can be -distinguished from YYYYWwwd#HH by the fact that there will always be an -odd number of digits before the first non-digit character in the former -case.]## - let len = dtstr.len # in byte - const - date_separator = '-' - week_indicator = 'W' - if len == 7: - return 7 - if dtstr[4] == date_separator: - # YYYY-??? - if dtstr[5] == week_indicator: - # YYYY-W? - if len < 8: - return -1 - - if len > 8 and dtstr[8] == date_separator: - # YYYY-Www-D (10) or YYYY-Www-HH (8) - if len == 9: return -1 - if len > 10 and is_digit(dtstr[10]): - # This is as far as we'll try to go to resolve the - # ambiguity for the moment — if we have YYYY-Www-##, the - # separator is either a hyphen at 8 or a number at 10. - # We'll assume it's a hyphen at 8 because it's way more - # likely that someone will use a hyphen as a separator - # than a number, but at this point it's really best effort - # because this is an extension of the spec anyway. - return 8 - return 10 - else: - # YYYY-Www (8) - return 8 - else: - # YYYY-MM-DD (10) - return 10 - else: - # YYYY??? - if dtstr[4] == week_indicator: - # YYYYWww (7) or YYYYWwwd (8) - var idx = 7 - while idx < len: - if not is_digit(dtstr[idx]): - idx.inc - break - idx.inc - if idx < 9: - return idx - if idx mod 2 == 0: - # If the index of the last number is even, it's YYYYWww - return 7 - else: - return 8 - else: - # YYYYMMDD (8) - return 8 - -proc tzinfo_from_isoformat_results(rv: int, tzoffset: int, tz_usecond: US): tzinfo = - if rv == 1: - # Create a timezone from offset in seconds (0 returns UTC) - if tzoffset == 0: - return UTC - let delta = newTimedelta(0, tzoffset, tz_usecond, normalize=false) - result = newPyTimezone(delta) - else: - result = TzNone - -import ./isoformat -proc datetime_fromisoformat*(dtstr): datetime = - let len = dtstr.len - - template invalid_string_error = - raise newException(ValueError, "Invalid isoformat string: " & dtstr.repr) - # XXX: we always use Nim's string, - # so we can just skip encoding issues about surrogate characters, - # no need to perform `_sanitize_isoformat_str` - # we just need to check the length: - if len < 7: - invalid_string_error - - let separator_location = find_isoformat_datetime_separator(dtstr) - var - ymd: YMD - hms: HMS - microsecond: US - tzoffset: int - tzusec: US - # date runs up to separator_location - var rv = parse_isoformat_date(dtstr, separator_location, ymd) - - if rv == 0 and len > separator_location: - # In UTF-8, the length of multi-byte characters is encoded in the MSB - let ci = dtstr[separator_location].int - let off = separator_location + ( - # get UTF-8 length from MSB (maybe use `unicode.graphemeLen`) - if (ci and 0x80) == 0: 1 - else: - case (ci and 0xf0) - of 0xe0: 3 - of 0xf0: 4 - else: 2 - ) - let nlen = len - off - rv = parse_isoformat_time(dtstr.toOpenArray(off, dtstr.high), nlen, hms, microsecond, - tzoffset, tzusec) - if rv < 0: - invalid_string_error - let tzinfo = tzinfo_from_isoformat_results(rv, tzoffset, tzusec) - result = datetime( - ymd.year, ymd.month, ymd.day, - hms.hour, hms.minute, hms.second, microsecond, - tzinfo = tzinfo) - diff --git a/src/pylib/Lib/datetime_impl/datetime_impl/meth/getter.nim b/src/pylib/Lib/datetime_impl/datetime_impl/meth/getter.nim deleted file mode 100644 index 9c0fc2ffc..000000000 --- a/src/pylib/Lib/datetime_impl/datetime_impl/meth/getter.nim +++ /dev/null @@ -1,20 +0,0 @@ -## See also: ./getter_requires_op ./getter_of_date - -import ../inner_decl -import ../../timedelta_impl/decl -import ../../timezone_impl/[ - decl, meth_by_datetime_getter] -from ../../delta_chk import chkOneDay - -using self: datetime -func utcoffset*(self): timedelta = - if self.tzinfo.isTzNone: return TimeDeltaNone - result = self.tzinfo.utcoffset(self) - result.chkOneDay() -func dst*(self): timedelta = - if self.tzinfo.isTzNone: return TimeDeltaNone - result = self.tzinfo.dst(self) - result.chkOneDay() -func tzname*(self): string = - ## .. hint:: this won't returns `None`, but may return a empty string - self.tzinfo.tzname(self) diff --git a/src/pylib/Lib/datetime_impl/datetime_impl/meth/getter_of_date.nim b/src/pylib/Lib/datetime_impl/datetime_impl/meth/getter_of_date.nim deleted file mode 100644 index d72c19405..000000000 --- a/src/pylib/Lib/datetime_impl/datetime_impl/meth/getter_of_date.nim +++ /dev/null @@ -1,37 +0,0 @@ - -include ./common -from ../../mathutils import divmod -import std/times -from ./calendar_utils import ymd_to_ord, weekday, YWD, iso_week1_monday -## date - -# XXX: TODO: using self: date -using self: datetime -func toordinal*(self): int = - ## date.toordinal() - ymd_to_ord(self.year, self.month, self.day) - -func weekday*(self): int = - self.asNimDatetime.weekday.int - -func isoweekday*(self): int = - let dow = weekday(self.year, self.month, self.day) - dow + 1 - -func isocalendar*(self): YWD = - var - year = self.year - week1_monday = iso_week1_monday(year) - let - today = ymd_to_ord(year, self.month, self.day) - var day: int - var week = divmod(today - week1_monday, 7, day) - if week < 0: - year.dec - week1_monday = iso_week1_monday(year) - week = divmod(today - week1_monday, 7, day) - elif week >= 52 and today >= iso_week1_monday(year + 1): - year.inc - week = 0 - - result = YWD (year, week+1, day+1) diff --git a/src/pylib/Lib/datetime_impl/datetime_impl/meth/getter_requires_op.nim b/src/pylib/Lib/datetime_impl/datetime_impl/meth/getter_requires_op.nim deleted file mode 100644 index 52f94c438..000000000 --- a/src/pylib/Lib/datetime_impl/datetime_impl/meth/getter_requires_op.nim +++ /dev/null @@ -1,26 +0,0 @@ - -include ./common -import ./op -from ./state_consts import CONST_EPOCH -from ./to_seconds_utils import local_to_seconds -import ../../timezone_impl/decl -import ../../timedelta_impl/meth - -const EPOCH_SECONDS = BiggestInt(719163) * 24 * 60 * 60 -# date(1970,1,1).toordinal() == 719163 - -using self: datetime -proc timestamp*(self): float = - if not self.tzinfo.isTzNone: - let delta = self - CONST_EPOCH - result = delta.total_seconds - else: - let seconds = local_to_seconds( - self.year, self.month, self.day, - self.hour, self.minute, self.second, - self.fold - ) - - result = float(seconds - EPOCH_SECONDS) + self.microsecond / 1_000_000 - - diff --git a/src/pylib/Lib/datetime_impl/datetime_impl/meth/hashImpl.nim b/src/pylib/Lib/datetime_impl/datetime_impl/meth/hashImpl.nim deleted file mode 100644 index ad73637f4..000000000 --- a/src/pylib/Lib/datetime_impl/datetime_impl/meth/hashImpl.nim +++ /dev/null @@ -1,33 +0,0 @@ - -import std/hashes -import ../inner_decl -import ./getter -import ../../timedelta_impl/[decl, meth] # import `-`, init for hash -from ./calendar_utils import ymd_to_ord - -proc hashImpl(self: datetime): int = - let self0 = - if self.isfold: - newDatetime(self, isfold=false) - else: self - let offset = self0.utcoffset() - if offset.isTimeDeltaNone: - result = hash [ - self.year, - self.month, self.day, - self.hour, self.minute, self.second, self.microsecond, - ] - else: - let days = ymd_to_ord( - self.year, self.month, self.day) - let seconds = self.hour * 3600 + - self.minute * 60 + self.second - let temp1 = newTimedelta(days=days, seconds=seconds, - microseconds=self.microsecond, true) - let temp2 = temp1 - offset - result = hash temp2 - -proc hash*(self: datetime): int = - if self.hashcode == -1: - self.hashcode = self.hashImpl() - result = self.hashcode diff --git a/src/pylib/Lib/datetime_impl/datetime_impl/meth/importer.nim b/src/pylib/Lib/datetime_impl/datetime_impl/meth/importer.nim deleted file mode 100644 index ca115d041..000000000 --- a/src/pylib/Lib/datetime_impl/datetime_impl/meth/importer.nim +++ /dev/null @@ -1,9 +0,0 @@ - -import ../../pyerr, ../../obj_utils -import ./calendar_utils -import ../../../../Python/pytime/types as pytime_types -import ../../../../Python/pytime/[units, rounds] -export pytime_types -export units, rounds - -export pyerr, obj_utils, calendar_utils diff --git a/src/pylib/Lib/datetime_impl/datetime_impl/meth/init.nim b/src/pylib/Lib/datetime_impl/datetime_impl/meth/init.nim deleted file mode 100644 index e71124359..000000000 --- a/src/pylib/Lib/datetime_impl/datetime_impl/meth/init.nim +++ /dev/null @@ -1,75 +0,0 @@ - -include ./common - -import std/macros -import std/times -import ../../timezone_impl/decl - -macro getRangeStr(typ: typedesc): string = - let tNode = typ.getType[1] - let t = - if tNode.typeKind == ntyEnum: tNode.getTypeInst - # if use others other than getTypeInst for enum, - # `ord` will always start with 0 (even for enum whose first item is 1-ord) - else: tNode.getTypeImpl - result = quote do: - $`t`.low.ord & ".." & $`t`.high.ord - -template raiseValueError(msg) = - raise newException(ValueError, msg) - -template chkSto(x: typed, aliasX: untyped; typ: typedesc) = - var aliasX: typ - try: - aliasX = typ(x) - except RangeDefect: - raiseValueError(astToStr(x) & " must be in " & typ.getRangeStr) - -func ltoUpper(c: char): char = chr(c.ord + 'A'.ord - 'a'.ord) -func ltoCap(s: string): string = s[0].ltoUpper & s.substr(1) - -macro catRange(x): untyped = - ident(x.strVal.ltoCap & "Range") - -template chkSto(x: typed, aliasX: untyped) = chkSto(x, aliasX, catRange(x)) - -func checkFold(fold: int): bool{.raises: [ValueError].} = - if fold == 1: result = true - elif fold == 0: result = false - else: - raiseValueError("fold must be either 0 or 1") - -{.push warning[ProveInit]: off.} -# for MonthdayRange: -# when `except RangeDefect`, a exception is raised, so the routinue just stops -# so this is safe. -proc datetime*(year, month, day: int, - hour=0, minute=0, second=0, microsecond=0, - tzinfo: tzinfo = nil, fold=0 -): datetime{.raises: [ValueError].} = - chkSto month, mon, Month - - #chkSto day, d, MonthdayRange - if day < 1 or day > getDaysInMonth(mon, year): - raiseValueError "day is out of range for month" - let d = MonthdayRange(day) - - chkSto hour, h - chkSto minute, min - chkSto second, s - let nanosecond = microsecond * 1000 - chkSto nanosecond, ns - - result = newDatetime(times.dateTime( - year, mon, d, h, min, s, ns, - zone = tzToNimTimezone tzinfo - ), tzinfo, fold.checkFold) - -{.pop.} - -proc replace*(self: datetime, - year=self.year, month=self.month, day=self.day, - hour=self.hour, minute=self.minute, second=self.second, - microsecond=self.microsecond, tzinfo=self.tzinfo, fold=0): datetime = - datetime(year, month, day, hour, minute, second, microsecond, tzinfo, - fold=fold) diff --git a/src/pylib/Lib/datetime_impl/datetime_impl/meth/inner_consts.nim b/src/pylib/Lib/datetime_impl/datetime_impl/meth/inner_consts.nim deleted file mode 100644 index 1b9c1a023..000000000 --- a/src/pylib/Lib/datetime_impl/datetime_impl/meth/inner_consts.nim +++ /dev/null @@ -1,4 +0,0 @@ - -const - MAXYEAR* = 9999 - MINYEAR* = 1 \ No newline at end of file diff --git a/src/pylib/Lib/datetime_impl/datetime_impl/meth/isoformat.nim b/src/pylib/Lib/datetime_impl/datetime_impl/meth/isoformat.nim deleted file mode 100644 index 78d5439b3..000000000 --- a/src/pylib/Lib/datetime_impl/datetime_impl/meth/isoformat.nim +++ /dev/null @@ -1,85 +0,0 @@ - -include ./common -import ./format_utcoffset -import ../../timezone_impl/decl as timezone_decl -from std/times import format -from std/strutils import parseEnum - -type - IsoFormatTimespec*{.pure.} = enum - auto - hours - minutes - seconds - milliseconds - microseconds - -using self: datetime # | date -func isoformat*(self; sep: char|string, timespec: IsoFormatTimespec): string = - result = newStringOfCap 29 # 20 + 5 + 4 # the max possible cap # sep is a UTF-8 char, at most 4-bytes - template add(cs: char|string) = result.add cs - template addDtF(s) = - result.add self.asNimDatetime.format s - addDtf "yyyy-MM-dd" - add sep - addDtf "HH" - let us = self.microsecond - let ntspec = - if timespec == IsoFormatTimespec.auto: - if us == 0: seconds - else: microseconds - else: - timespec - case ntspec - of IsoFormatTimespec.auto, hours: discard - of minutes: - addDtF ":mm" - of seconds: - addDtF ":mm:ss" - of milliseconds: - addDtF ":mm:ss'.'fff" - of microseconds: - addDtF ":mm:ss'.'ffffff" - - # We need to append the UTC offset. - if self.tzinfo.isTzNone: - return - result.add_format_utcoffset(sep=":", self.tzinfo, self) - -func isoformat*(self; sep: char|string = "T", timespec="auto"): string = - let ts = parseEnum[IsoFormatTimespec](timespec) - self.isoformat(sep, ts) - -func `$`*(self): string = - ## datetime_str - self.isoformat(' ', IsoFormatTimespec.auto) - -func repr*(self): string = - ## datetime_repr - result = $typeof(self) - result.add '(' - template addA(attr) = result.add $self.attr - template addP = result.add ", " - template addAP(attr) = addA(attr); addP() - addAP year - addAP month - addAP day - addAP hour - if self.microsecond != 0: - addAP minute - addAP second - addA microsecond - elif self.second != 0: - addAP minute - addA second - else: - addA minute - if self.fold != 0: - addP() - result.add "fold=" - addA fold - if not self.tzinfo.isTzNone: - addP() - result.add "tzinfo=" - result.add timezone_decl.repr(self.tzinfo) - result.add ')' diff --git a/src/pylib/Lib/datetime_impl/datetime_impl/meth/js/jstime_utils.nim b/src/pylib/Lib/datetime_impl/datetime_impl/meth/js/jstime_utils.nim deleted file mode 100644 index 136831c71..000000000 --- a/src/pylib/Lib/datetime_impl/datetime_impl/meth/js/jstime_utils.nim +++ /dev/null @@ -1,10 +0,0 @@ - -when not defined(js): - {.error: "JS backend only".} - - -func getTimeZoneName*: cstring = - {.emit: [result, - " = Intl.DateTimeFormat().resolvedOptions().timeZone"].} - - diff --git a/src/pylib/Lib/datetime_impl/datetime_impl/meth/js/struct_tm_meth.nim b/src/pylib/Lib/datetime_impl/datetime_impl/meth/js/struct_tm_meth.nim deleted file mode 100644 index 68322f969..000000000 --- a/src/pylib/Lib/datetime_impl/datetime_impl/meth/js/struct_tm_meth.nim +++ /dev/null @@ -1,83 +0,0 @@ - - -import std/jscore -import std/macros -import ./jstime_utils -from ../calendar_utils import days_before_month -import ../struct_tm_decl - -let tzname = getTimeZoneName() - -#[ -func getFullYear(d: DateTime): int{.importjs.} -func getUTCFullYear(d: DateTime): int{.importjs.} -wrap year, getFullYear -]# -template wrap(name) = - func name(d: DateTime): int{.importcpp.} - -wrap getDate -func getUTCYear(d: DateTime): int = d.getUTCFullYear - 1900 - -func getYearDay(year, month, day: int): int = - # or - #floor((date - new Date(date.getFullYear(), 0, 0)) / 1000 / 60 / 60 / 24) - day + days_before_month(year, month) - -macro initAttrs(utc: static[bool], tm: Tm; dt: DateTime; attrs: varargs[untyped]) = - result = newStmtList() - for t in attrs: - let attr = t[0] - result.add newAssignment( - newDotExpr(tm, attr), - newCall( - if utc: t[2] - else: t[1], - dt) - ) - - -template initWith(tm: Tm; dt: DateTime, utc: static[bool]) = - initAttrs(utc, tm, dt - ,(tm_year ,getYear ,getUTCYear ) - ,(tm_mon ,getMonth ,getUTCMonth ) - ,(tm_mday ,getDate ,getUTCDate ) - ,(tm_wday ,getDay ,getUTCDay ) - - ,(tm_hour ,getHours ,getUTCHours ) - ,(tm_min ,getMinutes,getUTCMinutes) - ,(tm_sec ,getSeconds,getUTCSeconds) - ) - tm.tm_yday = getYearDay(tm.year, tm.month, tm.tm_mday) - -using tm: Tm -func getUtcOffset(dt: DateTime): clong = - -60 * dt.getTimezoneOffset # in minutes -> in seconds - -# ---- required by ./time.nim ---- - -using ordinal: int|int64 - -wrap valueOf -func isNaN(n: int): bool{.importjs: "isNaN(#)".} -proc newCheckedDate(ordinal): DateTime = - result = newDate(ordinal) - when not defined(release): - let val = result.valueOf() - if isNaN(val): - raise newException(OSError, - "Given ordinal value is out of valid value for JS'`new Date`: " & $val) - -proc tm_from_local*(ordinal): Tm = - result.initTm - let date = newCheckedDate(ordinal) - result.initWith date, utc=false - result.tm_gmtoff = date.getUtcOffset - result.tm_zone = tzname - -proc tm_from_utc*(ordinal): Tm = - result.initTm - let date = newCheckedDate(ordinal) - result.initWith date, utc=true - result.tm_gmtoff = 0 - result.tm_zone = "UTC" diff --git a/src/pylib/Lib/datetime_impl/datetime_impl/meth/js/time.nim b/src/pylib/Lib/datetime_impl/datetime_impl/meth/js/time.nim deleted file mode 100644 index 94abcb7d8..000000000 --- a/src/pylib/Lib/datetime_impl/datetime_impl/meth/js/time.nim +++ /dev/null @@ -1,9 +0,0 @@ - -import ../time_t_decl -import ../struct_tm_decl -import ./struct_tm_meth -proc nPyTime_localtime*(t: time_t, tm: var Tm) = - tm = tm_from_local(t) - -proc nPyTime_gmtime*(t: time_t, tm: var Tm) = - tm = tm_from_utc(t) diff --git a/src/pylib/Lib/datetime_impl/datetime_impl/meth/op.nim b/src/pylib/Lib/datetime_impl/datetime_impl/meth/op.nim deleted file mode 100644 index b20efc349..000000000 --- a/src/pylib/Lib/datetime_impl/datetime_impl/meth/op.nim +++ /dev/null @@ -1,132 +0,0 @@ - -import std/times -include ./common -import ./getter -import ../../timedelta_impl/[ - decl, meth] -from ./calendar_utils import ymd_to_ord -from ./importer import `@=`, TypeError - -using self: datetime -proc `+`*(self; delta: timedelta): datetime = - newDatetime(self.asNimDatetime + delta.asDuration, self.tzinfo) - -proc `-`*(self; delta: timedelta): datetime = - newDatetime(self.asNimDatetime - delta.asDuration, self.tzinfo) - -template ymd_to_ord(self: datetime): int = - ymd_to_ord( - self.year, self.month, self.day) - -proc `-`*(self; dt: datetime): timedelta = - var - offset1, offset2: timedelta - - if self.tzinfo @= dt.tzinfo: - offset1 = TimeDeltaNone - offset2 = TimeDeltaNone - else: - offset1 = self.utcoffset() - offset2 = dt.utcoffset() - if ( - not(offset1.isTimeDeltaNone) != not(offset2.isTimeDeltaNone) - ): - raise newException(TypeError, "can't subtract offset-naive and " & - "offset-aware datetimes") - var offdiff: timedelta = TimeDeltaNone - if not (offset1 @= offset2) and offset1 != offset2: - offdiff = offset1 - offset2 - let delta_d = ymd_to_ord(self) - ymd_to_ord(dt) - - #[These can't overflow, since the values are - normalized. At most this gives the number of - seconds in one day. ]# - template diff(a, b: datetime; attr): SomeInteger = - a.attr - b.attr - template diff(attr): untyped = diff(self, dt, attr) - - let delta_s = diff(hour) * 3600 + - diff(minute) * 60 + - diff(second) - - let delta_us = diff microsecond - result = newTimedelta( - days=delta_d, seconds=delta_s, microseconds=delta_us, normalize=true) - if not offdiff.isTimeDeltaNone: - result = result - offdiff - - -# Miscellaneous methods. - -proc flip_fold(dt: datetime): datetime = - newDatetime(dt, isfold = bool dt.fold) - -proc get_flip_fold_offset(dt: datetime): timedelta = - let flip_dt = flip_fold(dt) - result = flip_dt.utcoffset - -proc pep495_eq_exception(self, other: datetime, offset_self, offset_other: timedelta): bool = - ## PEP 495 exception: Whenever one or both of the operands in - ## inter-zone comparison is such that its utcoffset() depends - ## on the value of its fold attribute, the result is False. ## - ## Return 1 if exception applies, 0 if not, and -1 on error. - var flip_offset = get_flip_fold_offset(self) - if not(flip_offset @= offset_self) and - flip_offset != offset_self: - result = true - return - flip_offset = get_flip_fold_offset(other) - if not(flip_offset @= offset_other) and - (flip_offset != offset_other): - result = true - -type - CmpOp = enum - coEQ - coLT - coLE - -func cmp(val1, val2: DateTime, op: CmpOp): bool = - case op - of coEQ: (val1) == (val2) - of coLT: (val1) < (val2) - of coLE: (val1) <= (val2) - -proc cmp(self; other: datetime, op: CmpOp): bool = - if self.tzinfo @= other.tzinfo: - return cmp(self.asNimDatetime, other.asNimDatetime, op) - let - offset1 = self.utcoffset() - offset2 = other.utcoffset() - #[If they're both naive, or both aware and have the same offsets, - we get off cheap. Note that if they're both naive, offset1 == - offset2 == Py_None at this point.]# - template chkRetEqExc = - let ex = pep495_eq_exception(self, other, offset1, offset2) - if ex: - result = true - if (offset1 @= offset2) or offset1 == offset2: - result = cmp(self.asNimDatetime, other.asNimDatetime, op) - if op == coEQ and result: - chkRetEqExc - elif not offset1.isTimeDeltaNone and not offset2.isTimeDeltaNone: - var delta: timedelta - assert offset1 != offset2 - delta = self - other - - var diff = delta.days - - if diff == 0: - diff = delta.seconds or delta.microseconds - - if op == coEQ and diff == 0: - chkRetEqExc - elif op == coEQ: - result = false - else: - raise newException(TypeError, "can't compare offset-naive and " & - "offset-aware datetimes") - -proc `==`*(self; dt: datetime): bool = cmp(self, dt, coEQ) -proc `<=`*(self; dt: datetime): bool = cmp(self, dt, coLE) -proc `<`* (self; dt: datetime): bool = cmp(self, dt, coLT) diff --git a/src/pylib/Lib/datetime_impl/datetime_impl/meth/platform_utils.nim b/src/pylib/Lib/datetime_impl/datetime_impl/meth/platform_utils.nim deleted file mode 100644 index 8db69141e..000000000 --- a/src/pylib/Lib/datetime_impl/datetime_impl/meth/platform_utils.nim +++ /dev/null @@ -1,3 +0,0 @@ - -const weridTarget* = defined(js) or defined(nimscript) - diff --git a/src/pylib/Lib/datetime_impl/datetime_impl/meth/pytime.nim b/src/pylib/Lib/datetime_impl/datetime_impl/meth/pytime.nim deleted file mode 100644 index 1466293db..000000000 --- a/src/pylib/Lib/datetime_impl/datetime_impl/meth/pytime.nim +++ /dev/null @@ -1,122 +0,0 @@ - -## translated from CPython/Python/pytime.c - -import ./platform_utils -when defined(js): - import ./js/time -else: - import ./struct_tm_decl, ./struct_tm_meth - import ./errno_decl - #from ./importer import raiseErrno - -import ./importer -export PyTime_round_t, prTimeout, Timestamp, long - -import std/math - -func float_to_denominator(d: float, sec: var time_t, numerator: var long, - idenominator: long, round: PyTime_round_t) = - ## pytime_double_to_denominator - ## - ## XXX: raise OverflowDefect instead of returning -1 - let denominator = float idenominator - var - intpart, floatpart: float - (intpart, floatpart) = d.splitDecimal - - floatpart *= denominator - floatpart = round(floatpart, round) - if floatpart >= denominator: - floatpart -= denominator - intpart += 1.0 - elif floatpart < 0: - floatpart += denominator - intpart -= 1.0 - assert 0.0 <= floatpart and floatpart < denominator - - # Nim will overflow-check time_t - # the following is from CPython's comments: - - #[Conversion of an out-of-range value to time_t gives undefined behaviour - (C99 §6.3.1.4p1), so we must guard against it. However, checking that - `intpart` is in range is delicate: the obvious expression `intpart <= - PY_TIME_T_MAX` will first convert the value `PY_TIME_T_MAX` to a double, - potentially changing its value and leading to us failing to catch some - UB-inducing values. The code below works correctly under the mild - assumption that time_t is a two's complement integer type with no trap - representation, and that `PY_TIME_T_MIN` is within the representable - range of a C double. - - Note: we want the `if` condition below to be true for NaNs; therefore, - resist any temptation to simplify by applying De Morgan's laws.]# - - sec = time_t intpart - numerator = long floatpart - assert 0 <= numerator and numerator < idenominator - -func object_to_denominator(obj: Timestamp, sec: var time_t, numerator: var long, - denominator: long, round: PyTime_round_t) = - ## pytime_object_to_denominator - assert denominator >= 1 - - when obj is float: - let d = obj - if d.isnan: - numerator = 0 - raise newException(ValueError, "Invalid value NaN (not a number)") - float_to_denominator(d, sec, numerator, - denominator, round) - else: - sec = obj - numerator = 0 - -func nPyTime_ObjectToTimeval*( - obj: Timestamp; sec: var time_t, usec: var long, - round: PyTime_round_t -) = - ## PyTime_ObjectToTimeval but raise OverflowDefect instead of returning -1 - ## i.e. returns nothing. - object_to_denominator(obj, sec, usec, SEC_TO_US, round) - - -when weridTarget: - export time.nPyTime_gmtime, time.nPyTime_localtime -else: - # L1286 _PyTime_localtime - proc nPyTime_localtime*(t: time_t, tm: var Tm) = - var t = t - # as localtime_*'s first param is const pointer, - # so it's fine to pass a local data's pointer - when defined(windows): - var error: int - error = localtime_s(tm, t) - if error != 0: - raiseErrno() - else: - when defined(aix) and SIZEOF_TIME_T < 8: - # bpo-34373: AIX does not return NULL if t is too small or too large - if (t < -2145916800 or # 1902-01-01 - t > 2145916800): # 2038-01-01 - errno = EINVAL - raise newException(OverflowDefect, "localtime argument out of range") - errno = 0 - if localtime_r(t, tm) == nil: - if errno == 0: - errno = EINVAL - raiseErrno() - - proc nPyTime_gmtime*(t: time_t, tm: var Tm) = - var t = t - # as gmtime_*'s first param is const pointer, - # so it's fine to pass a local data's pointer - when defined(windows): - let error = gmtime_s(tm, (t)) - if error != 0: - errno = error - raiseErrno() - else: - if gmtime_r((t), tm) == nil: - when declared(EINVAL): - if errno == 0: - errno = EINVAL - raiseErrno() diff --git a/src/pylib/Lib/datetime_impl/datetime_impl/meth/require_time_module.nim b/src/pylib/Lib/datetime_impl/datetime_impl/meth/require_time_module.nim deleted file mode 100644 index 17461c98f..000000000 --- a/src/pylib/Lib/datetime_impl/datetime_impl/meth/require_time_module.nim +++ /dev/null @@ -1,94 +0,0 @@ - -import ../../../time_impl/[ - types, converters, nstrfptime, asctimeImpl -] - -from std/strutils import multiReplace, replace, align, parseInt -import ../../timedelta_impl/decl -import ../../timezone_impl/[ - decl as timezone_decl, meth_by_datetime_getter -] - -include ./common -from std/times import DateTime, yearday -import ./format_utcoffset -from ./importer import NotImplementedError - -using self: datetime - -# shall also has a `self: date` -func timetuple*(self): struct_time = - var dstflag = -1 - if not self.tzinfo.isTzNone: - let dst = self.tzinfo.dst(self) - if not dst.isTimeDeltaNone: - dstflag = int bool dst - self.asNimDatetime.dtToStructTime result - -using tzinfoarg: datetime - -proc add_somezreplacement(s: var string, sep: string, tzinfo: tzinfo, tzinfoarg) = - s.add_format_utcoffset(sep, tzinfo, tzinfoarg) - -const Py_NORMALIZE_CENTURY = true # since CPython gh-120713 -proc add_Zreplacement(s: var string, tzinfo: tzinfo, tzinfoarg) = - try: - s.add tzinfo.tzname(tzinfoarg) - except NotImplementedError: - return - #[Since the tzname is getting stuffed into the - format, we have to double any % signs so that - strftime doesn't treat them as format codes.]# - s = s.replace("%", "%%") - -func wrap_strftime(self; format: string, tzinfoarg): string = - #[Scan the input format, looking for %z/%Z/%f escapes, building - a new format. Since computing the replacements for those codes - is expensive, don't unless they're actually used.]# - - let tzinfo = self.tzinfo - var z_repl, Z_repl, z_col_repl: string - if not tzinfo.isTzNone: - z_repl.add_somezreplacement("", tzinfo, self) - Z_repl.add_Zreplacement(tzinfo, self) - z_col_repl.add_somezreplacement(":", tzinfo, self) - - let baseRepl = { - "%z": z_repl, - "%Z": Z_repl, - "%:z": z_col_repl, - "%f": align($self.microsecond, 6, '0') - } - when Py_NORMALIZE_CENTURY: - let year = self.year - template pad4(i: SomeInteger): string = - align($i, 4, '0') - let - iG = parseInt(strftime("%G", self.asNimDatetime)) - iY = self.year - let newfmt = format.multiReplace( - @baseRepl & @{ - "%G": iG.pad4, - "%Y": iY.pad4, - } - ) - else: - let newfmt = format.multiReplace(baseRepl) - - strftime(newfmt, self.asNimDatetime) - -func strftime*(self; format: string): string = - wrap_strftime(self, format, self) - -using _: typedesc[datetime] -func strptime*(_; datetime_string, format: string): datetime = - var ndt: DateTime - ndt.strptime(datetime_string, format) - result = newDatetime( - ndt, - ) - -# TODO: easy: support all in nstrfptime.NotImplDirectives, with the help of calendar_utils - -func ctime*(self): string = - asctimeImpl(result, self.asNimDatetime) diff --git a/src/pylib/Lib/datetime_impl/datetime_impl/meth/state_consts.nim b/src/pylib/Lib/datetime_impl/datetime_impl/meth/state_consts.nim deleted file mode 100644 index d6729ec22..000000000 --- a/src/pylib/Lib/datetime_impl/datetime_impl/meth/state_consts.nim +++ /dev/null @@ -1,10 +0,0 @@ - -import ./init - -import ../../timezone_impl/decl -template utc_timezone*: timezone = - bind UTC - UTC -# st = GET_CURRENT_STATE(current_mod); CONST_EPOCH(st) -let CONST_EPOCH* = datetime( - 1970, 1, 1, 0, 0, 0, 0, utc_timezone, fold=0) diff --git a/src/pylib/Lib/datetime_impl/datetime_impl/meth/statics.nim b/src/pylib/Lib/datetime_impl/datetime_impl/meth/statics.nim deleted file mode 100644 index cfb721cdf..000000000 --- a/src/pylib/Lib/datetime_impl/datetime_impl/meth/statics.nim +++ /dev/null @@ -1,101 +0,0 @@ - -include ./common -import ./init -import ./pytime, ./time_utils, ./to_seconds_utils, ./struct_tm_decl -export Timestamp -import ./fromisoformat -from ./calendar_utils import ord_to_ymd, iso_to_ymd, YMD -import ../../timezone_impl/[decl, meth_by_datetime] -import std/times - -using _: typedesc[datetime] -func today*(_): datetime = newDatetime now() -func now*(_; tzinfo: tzinfo = TzNone): datetime = - newDatetime(now(), tzinfo) - - -proc fromisoformat*(_; nonkw: string): datetime = datetime_fromisoformat(nonkw) -proc fromordinal*(_; ordinal: int): datetime = - if ordinal < 1: - raise newException(ValueError, "ordinal must be >= 1") - var ymd: YMD - ord_to_ymd(ordinal, ymd) - init.datetime(ymd.year, ymd.month, ymd.day) - -proc fromisocalendar*(_; year, week, day: int): datetime = - var ymd: YMD - iso_to_ymd((year, week, day), ymd) - init.datetime(ymd.year, ymd.month, ymd.day) - - -# ## fromtimestamp -type - N_TM_FUNC = proc (timer: time_t): Tm - -proc datetime_from_timet_and_us(f: N_TM_FUNC, timet: time_t, us: int, - tzinfo: tzinfo): datetime = - let tm = f(timet) - let timet = BiggestInt timet - let - year = tm.year - month = tm.month - day = tm.tm_mday - hour = tm.tm_hour - minute= tm.tm_min - #[The platform localtime/gmtime may insert leap seconds, - indicated by tm.tm_sec > 59. We don't care about them, - except to the extent that passing them on to the datetime - constructor would raise ValueError for a reason that - made no sense to the user.]# - let - second = min(59, int tm.tm_sec) - var fold = 0 - # local timezone requires to compute fold - var shallCheckFold = tzinfo.isTzNone and f == nTime_localtime - #[On Windows, passing a negative value to local results - in an OSError because localtime_s on Windows does - not support negative timestamps. Unfortunately this - means that fold detection for time values between - 0 and max_fold_seconds will result in an identical - error since we subtract max_fold_seconds to detect a - fold. However, since we know there haven't been any - folds in the interval [0, max_fold_seconds) in any - timezone, we can hackily just forego fold detection - for this time range. ]# - when defined(windows): - shallCheckFold = shallCheckFold and timet - max_fold_seconds > 0 - if shallCheckFold: - var - result_seconds = utc_to_seconds(year, month, day, hour, minute, second) - - # Probe max_fold_seconds to detect a fold. - var probe_seconds = local(epoch + timet - max_fold_seconds) - var transition = result_seconds - probe_seconds - max_fold_seconds - if transition < 0: - probe_seconds = local(epoch + timet + transition) - if probe_seconds == result_seconds: - fold = 1 - - return init.datetime(year, month, day, hour, minute, - second, us, tzinfo, fold) - -proc datetime_from_timestamp(f: N_TM_FUNC, timestamp: Timestamp, tzinfo=TzNone): datetime = - ##[Internal helper. - Build datetime from a Python timestamp. Pass localtime or gmtime for f, - to control the interpretation of the timestamp. Since a double doesn't - have enough bits to cover a datetime's full range of precision, it's - better to call datetime_from_timet_and_us provided you have a way - to get that much precision (e.g., C time() isn't good enough).]## - var - timet: time_t - us: long - - nPyTime_ObjectToTimeval(timestamp, timet, us, prHalfEven) - return datetime_from_timet_and_us(f, timet, us.int, tzinfo) - -proc fromtimestamp*(_; timestamp: Timestamp, tz=TzNone): datetime = - result = datetime_from_timestamp( - if tz.isTzNone: nTime_localtime else: nTime_gmtime, - timestamp, tz) - if not tz.isTzNone: - result = tz.fromutc(result) diff --git a/src/pylib/Lib/datetime_impl/datetime_impl/meth/struct_tm_decl.nim b/src/pylib/Lib/datetime_impl/datetime_impl/meth/struct_tm_decl.nim deleted file mode 100644 index 2b303f9ea..000000000 --- a/src/pylib/Lib/datetime_impl/datetime_impl/meth/struct_tm_decl.nim +++ /dev/null @@ -1,43 +0,0 @@ - - -when defined(js): - const HAVE_STRUCT_TM_TM_ZONE* = true - {.pragma: TmPragma.} -else: - type struct_tm*{.importc: "struct tm", header: "", completeStruct.} = object - const HAVE_STRUCT_TM_TM_ZONE* = sizeof(struct_tm) > 9*sizeof(cint) - {.pragma: TmPragma, importc: "struct tm", header: "".} - -when not HAVE_STRUCT_TM_TM_ZONE: - type Tm*{.TmPragma.} = object - tm_year*: int ## years since 1900 - tm_mon*: range[0 .. 11] - tm_mday*: range[1 .. 31] - tm_hour*: range[0 .. 23] - tm_min*: range[0 .. 59] - tm_sec*: range[0 .. 61] ## C89 is 0..61, C99 is 0..60 - tm_wday*: range[0 .. 6] - tm_yday*: range[0 .. 365] - tm_isdst*: int -else: - type Tm*{.TmPragma.} = object - tm_year*: int ## years since 1900 - tm_mon*: range[0 .. 11] - tm_mday*: range[1 .. 31] - tm_hour*: range[0 .. 23] - tm_min*: range[0 .. 59] - tm_sec*: range[0 .. 61] ## C89 is 0..61, C99 is 0..60 - tm_wday*: range[0 .. 6] - tm_yday*: range[0 .. 365] - tm_isdst*: int - tm_gmtoff*: clong - tm_zone*: cstring - -func year*(tm: Tm): int = tm.tm_year + 1900 -func month*(tm: Tm): int = tm.tm_mon + 1 - -func initTm*: Tm = Tm(tm_mday: 1) -template initTm*(tm: var Tm) = - # a workaround for compile error - bind initTm - tm = initTm() diff --git a/src/pylib/Lib/datetime_impl/datetime_impl/meth/struct_tm_helper.nim b/src/pylib/Lib/datetime_impl/datetime_impl/meth/struct_tm_helper.nim deleted file mode 100644 index 758224c93..000000000 --- a/src/pylib/Lib/datetime_impl/datetime_impl/meth/struct_tm_helper.nim +++ /dev/null @@ -1,15 +0,0 @@ - -import std/macros -import ./struct_tm_decl - -macro cTmToNormCall*(call; tm: Tm; kwargs: varargs[untyped]): untyped = - result = quote do: - `call`( - `tm`.year, - `tm`.month, - `tm`.tm_mday, - `tm`.tm_hour, - `tm`.tm_min, - `tm`.tm_sec,) - for i in kwargs: - result.add i diff --git a/src/pylib/Lib/datetime_impl/datetime_impl/meth/struct_tm_meth.nim b/src/pylib/Lib/datetime_impl/datetime_impl/meth/struct_tm_meth.nim deleted file mode 100644 index 74441f425..000000000 --- a/src/pylib/Lib/datetime_impl/datetime_impl/meth/struct_tm_meth.nim +++ /dev/null @@ -1,11 +0,0 @@ - -import ./time_t_decl, ./struct_tm_decl - -{.push header: "".} -when defined(windows): - proc localtime_s*(tm: var Tm, t: var time_t): cint{.importc.} - proc gmtime_s*(tm: var Tm, t: var time_t): cint{.importc.} -else: - proc localtime_r*(t: var time_t, tm: var Tm): ptr Tm{.importc.} - proc gmtime_r*(t: var time_t, tm: var Tm): ptr Tm{.importc.} -{.pop.} diff --git a/src/pylib/Lib/datetime_impl/datetime_impl/meth/time_t_decl.nim b/src/pylib/Lib/datetime_impl/datetime_impl/meth/time_t_decl.nim deleted file mode 100644 index 94bb7895c..000000000 --- a/src/pylib/Lib/datetime_impl/datetime_impl/meth/time_t_decl.nim +++ /dev/null @@ -1,3 +0,0 @@ -import ./importer -export time_t - diff --git a/src/pylib/Lib/datetime_impl/datetime_impl/meth/time_utils.nim b/src/pylib/Lib/datetime_impl/datetime_impl/meth/time_utils.nim deleted file mode 100644 index 7818dc774..000000000 --- a/src/pylib/Lib/datetime_impl/datetime_impl/meth/time_utils.nim +++ /dev/null @@ -1,12 +0,0 @@ - -import ./time_t_decl, ./struct_tm_decl -export time_t_decl, struct_tm_decl -import ./pytime # nPyTime_localtime, nPyTime_gmtime - -proc nTime_localtime*(t: time_t): Tm = - result.initTm() - nPyTime_localtime(t, result) - -proc nTime_gmtime*(t: time_t): Tm = - result.initTm() - nPyTime_gmtime(t, result) diff --git a/src/pylib/Lib/datetime_impl/datetime_impl/meth/to_seconds_utils.nim b/src/pylib/Lib/datetime_impl/datetime_impl/meth/to_seconds_utils.nim deleted file mode 100644 index a612d598e..000000000 --- a/src/pylib/Lib/datetime_impl/datetime_impl/meth/to_seconds_utils.nim +++ /dev/null @@ -1,71 +0,0 @@ - -from ./inner_consts import MINYEAR, MAXYEAR -from ./calendar_utils import ymd_to_ord -import ./time_utils, ./struct_tm_helper - -let max_fold_seconds* = BiggestInt 24 * 3600 ## \ -## As of version 2015f max fold in IANA database is -## 23 hours at 1969-09-30 13:00:00 in Kwajalein. - -let epoch* = BiggestInt(719163) * 24 * 60 * 60 ## \ -## NB: date(1970,1,1).toordinal() == 719163 - -func utc_to_seconds*(year, month, day, hour, minute, second: int): BiggestInt = - if year < MINYEAR or year > MAXYEAR: - raise newException(ValueError, "year " & $year & " is out of range") - - let ordinal = BiggestInt ymd_to_ord(year, month, day) - return ((ordinal * 24 + hour) * 60 + minute) * 60 + second - -proc local*(u: BiggestInt): BiggestInt = - ## never returns -1, unlike CPython, - ## but may raises OverflowDefect - let t = time_t(u - epoch) - # here Nim will handle overflow - let local_time = nTime_localtime(t) - return cTmToNormCall(utc_to_seconds, local_time) - -proc local_to_seconds*(year, month, day, hour, minute, second: int, fold: int): BiggestInt = - ## never returns -1, unlike CPython, - ## but may raises OverflowDefect - let t = utc_to_seconds(year, month, day, hour, minute, second) - var lt = local(t) - template invalRet(t) = - #if t == -1: return -1 - # do nothing, as `local` won't return -1 - discard - invalRet lt - let - a = lt - t - u1 = t - a - t1 = local(u1) - invalRet t1 - var - u2, b: BiggestInt - if t1 == t: - #[ We found one solution, but it may not be the one we need. - Look for an earlier solution (if `fold` is 0), or a - later one (if `fold` is 1). ]# - if bool(fold): - u2 = u1 + max_fold_seconds - else: - u2 = u1 - max_fold_seconds - lt = local(u2) - invalRet lt - b = lt - u2 - if a == b: - return u1 - else: - b = t1 - u1 - assert a != b - u2 = t - b - let t2 = local(u2) - invalRet t2 - if t2 == t: - return u2 - if t1 == t: - return u1 - - #[ We have found both offsets a and b, but neither t - a nor t - b is - a solution. This means t is in the gap. ]# - return if bool(fold): min(u1, u2) else: max(u1, u2) diff --git a/src/pylib/Lib/datetime_impl/datetime_impl/meth/zonename_utils.nim b/src/pylib/Lib/datetime_impl/datetime_impl/meth/zonename_utils.nim deleted file mode 100644 index 01dd039bd..000000000 --- a/src/pylib/Lib/datetime_impl/datetime_impl/meth/zonename_utils.nim +++ /dev/null @@ -1,53 +0,0 @@ - -import ./struct_tm_decl -import ./time_utils -import ./platform_utils - -when not weridTarget: - proc c_strftime(buf: cstring, len: csize_t, fmt: cstring, tm: var Tm): csize_t{. - importc: "strftime", header: "".} - - template newCCharArr(n): cstring = - cast[cstring]( - when compileOption("threads"): - allocShared(n) - else: - alloc(n) - ) - -proc newZoneCStr*(tm: var Tm): cstring = - when defined(js): - tm.tm_zone - elif defined(nimscript): - {.error:"not available in NimScript".} - "" - else: - when HAVE_STRUCT_TM_TM_ZONE: - let allLen = tm.tm_zone.len + 1 - result = newCCharArr(allLen) - memCopy result, tm.tm_zone, allLen - else: - const max_len = 100 - result = newCCharArr(max_len) - assert 0 != c_strftime(result, max_len, "%Z", tm) - -proc freeZoneCStr*(s: cstring) = - when weridTarget: discard - else: - when compileOption("threads"): - deallocShared(s) - else: - dealloc(s) - -when defined(js): - static: assert HAVE_STRUCT_TM_TM_ZONE - proc zonename*(tm: var Tm): string = - # assuming JS's timezone name is always valid to convert to UTF-8 - $tm.tm_zone -else: - import ../../../../Python/unicodeobject/locale_codec - - proc zonename*(tm: var Tm): string = - var zone = newZoneCStr tm - result = PyUnicode_DecodeLocale(zone, "surrogateescape") - zone.freeZoneCStr() diff --git a/src/pylib/Lib/datetime_impl/delta_chk.nim b/src/pylib/Lib/datetime_impl/delta_chk.nim deleted file mode 100644 index 24927888e..000000000 --- a/src/pylib/Lib/datetime_impl/delta_chk.nim +++ /dev/null @@ -1,19 +0,0 @@ - - -import ./timedelta_impl/decl - -func outOfDay(delta: timedelta): bool = - # if use times.convert - # JS backend does not reach `Microseconds` fineness. - # NIM-BUG: `convert(Days, Microseconds, 1)`: - # times.nim(417, 65) - # Error: illegal conversion from '86400000000' to '[-2147483648..2147483647]' - const OneDayMs = int64(1_000_000) * 3600 * 24 - abs(delta.inMicroseconds) > OneDayMs - -template chkOneDay*(delta: timedelta) = - bind outOfDay - if outOfDay delta: - raise newException(ValueError, "offset must be a timedelta" & - " strictly between -timedelta(hours=24) and" & - " timedelta(hours=24). not " & repr(delta)) diff --git a/src/pylib/Lib/datetime_impl/mathutils.nim b/src/pylib/Lib/datetime_impl/mathutils.nim deleted file mode 100644 index efd7a4ff1..000000000 --- a/src/pylib/Lib/datetime_impl/mathutils.nim +++ /dev/null @@ -1,19 +0,0 @@ - - -func divmod*[I](x: I, y: Natural, r: var I): I = - ## returns floorDiv(x, y) - - ##[Compute Python divmod(x, y), returning the quotient and storing the -remainder into *r. The quotient is the floor of x/y, and that's -the real point of this. C will probably truncate instead (C99 -requires truncation; C89 left it implementation-defined). -Simplification: we *require* that y > 0 here. That's appropriate -for all the uses made of it. This simplifies the code and makes -the overflow case impossible (divmod(LONG_MIN, -1) is the only -overflow case).]## - result = x div y - r = x - result * y - if r < 0: - result.dec - r.inc y - assert 0 <= r and r < y diff --git a/src/pylib/Lib/datetime_impl/obj_utils.nim b/src/pylib/Lib/datetime_impl/obj_utils.nim deleted file mode 100644 index 060e8c671..000000000 --- a/src/pylib/Lib/datetime_impl/obj_utils.nim +++ /dev/null @@ -1,7 +0,0 @@ - - -func `@=`*[T](p1, p2: ref T): bool = - ## cmp on addr of pointers - system.`==` p1, p2 - # See https://github.com/nim-lang/Nim/issues/23850 - # for why not using cast[pointer](p1) == cast[pointer](p2) diff --git a/src/pylib/Lib/datetime_impl/pyerr.nim b/src/pylib/Lib/datetime_impl/pyerr.nim deleted file mode 100644 index 42e3eed14..000000000 --- a/src/pylib/Lib/datetime_impl/pyerr.nim +++ /dev/null @@ -1,7 +0,0 @@ - -import ../../pyerrors/[rterr, simperr, oserr, unicode_err] -export NotImplementedError, TypeError -export oserr, unicode_err - -template notImplErr*(meth) = - raise newException(NotImplementedError, astToStr(meth) & " is not implemented") diff --git a/src/pylib/Lib/datetime_impl/timedelta_impl.nim b/src/pylib/Lib/datetime_impl/timedelta_impl.nim deleted file mode 100644 index 0e4b381a1..000000000 --- a/src/pylib/Lib/datetime_impl/timedelta_impl.nim +++ /dev/null @@ -1,6 +0,0 @@ - -import ./timedelta_impl/[ - decl, meth -] - -export decl, meth diff --git a/src/pylib/Lib/datetime_impl/timedelta_impl/decl.nim b/src/pylib/Lib/datetime_impl/timedelta_impl/decl.nim deleted file mode 100644 index c429c42f0..000000000 --- a/src/pylib/Lib/datetime_impl/timedelta_impl/decl.nim +++ /dev/null @@ -1,64 +0,0 @@ -##[ - -.. hint:: Nim's Duration in std/times has the resolution of - nanoseconds, but Python's timedelta's is microseconds - But to keep consist with Python, timedelta.resolution is 1 microseconds now. - - -]## - -import std/times -import std/hashes - -type - timedelta* = ref object - data: Duration - hashcode: int - -const TimeDeltaNone*: timedelta = nil -func isTimeDeltaNone*(self: timedelta): bool = self == nil - -func newTimedelta*(dur: Duration): timedelta = timedelta(data: dur) -func newTimedelta*(days, seconds, microseconds: int, - normalize = true): timedelta = - ## CPython's new_delta C-API (private) - # TODO: opt for normalize == false - timedelta(data: - initDuration(days=days, seconds=seconds, microseconds=microseconds)) - -using self: timedelta -func asDuration*(self): Duration = - ## EXT. - self.data - -func inMicroseconds*(self): int64 = self.data.inMicroseconds - -func hashImpl(self): int = - let parts = self.asDuration.toParts() - hash( - (parts[Days], parts[Seconds], parts[Microseconds]+1000*parts[Milliseconds]) - ) - - -func flush_hash*(self) = - ## EXT. calculate hash whatever - self.hashcode = self.hashImpl() - -func hash*(self): int = - if self.hashcode == -1: - self.hashcode = self.hashImpl() - result = self.hashcode - -converter toBool*(self): bool = - ## delta_bool - self.inMicroseconds != 0 - -func `==`*(self; o: timedelta): bool = - # required by datetime_impl/meth - let - lNone = self.isTimeDeltaNone - rNone = o.isTimeDeltaNone - # do not write sth like `self == nil`, it deadloops! - if lNone and rNone: return true - if lNone xor rNone: return false - self.inMicroseconds == o.inMicroseconds diff --git a/src/pylib/Lib/datetime_impl/timedelta_impl/getter.nim b/src/pylib/Lib/datetime_impl/timedelta_impl/getter.nim deleted file mode 100644 index 1c2f49371..000000000 --- a/src/pylib/Lib/datetime_impl/timedelta_impl/getter.nim +++ /dev/null @@ -1,41 +0,0 @@ - - -import ./decl -import std/times - -using parts: DurationParts -using self: timedelta - - -func daysImpl*(parts): int64 = - result = parts[Weeks] * 7 + parts[Days] - if result <= 0: - if parts[Hours] < 0 or parts[Minutes] < 0 or parts[Seconds] < 0 or parts[Microseconds] < 0: - result.dec - -func days*(self): int64 = self.asDuration.toParts.daysImpl() - -func secondsImpl*(parts): int64 = - ## result is never negative. In Python, only timedelta.days may be negative - # do not use `.inSeconds()`, as that's a sum - result = parts[Seconds] - result += convert(Hours, Seconds, parts[Hours]) - result += convert(Minutes, Seconds, parts[Minutes]) - let usN0 = parts[Microseconds] + 1000 * parts[Milliseconds] < 0 - if result < 0 or result == 0 and usN0: - result.inc convert(Days, Seconds, 1) - if usN0: - result.dec - -func seconds*(self): int64 = self.asDuration.toParts.secondsImpl() - -func microsecondsImpl*(parts): int64 = - ## result is never negative. In Python, only timedelta.days may be negative - # do not use .inMicroseconds - # nanoseconds part is always 0 for timedelta's Duration attr - result = parts[Microseconds] - result += convert(Milliseconds, Microseconds, parts[Milliseconds]) - if result < 0: - result += 1_000_000 - -func microseconds*(self): int64 = self.asDuration.toParts.microsecondsImpl() diff --git a/src/pylib/Lib/datetime_impl/timedelta_impl/meth.nim b/src/pylib/Lib/datetime_impl/timedelta_impl/meth.nim deleted file mode 100644 index 6850f69be..000000000 --- a/src/pylib/Lib/datetime_impl/timedelta_impl/meth.nim +++ /dev/null @@ -1,269 +0,0 @@ - -import std/times -import std/macros -from ../mathutils import divmod -from std/math import floorDiv, floorMod, splitDecimal, round -import ./decl, ./getter -export getter.days, getter.seconds, getter.microseconds - -using self: timedelta - -func timedelta*(days: int64, seconds=0'i64, microseconds=0'i64, - milliseconds=0'i64, minutes=0'i64, hours=0'i64, weeks=0'i64): timedelta = - ## timedelta with int-only arguments - ## - ## See `timedelta<#timedelta%2CFI%2CFI%2CFI%2CFI%2CFI%2CFI%2CFI>`_ - ## that accepts mixin float and int as arguments - ## - ## .. hint:: if setting default value for `days`(a.k.a. `days=0`), - ## `timedelta()` will fail to be compiled due to `ambiguous call` - - newTimedelta initDuration( - days=days, seconds=seconds, - microseconds=microseconds, milliseconds=milliseconds, - minutes=minutes, hours=hours, - weeks=weeks - ) - -type - IntS = int64 ## int for sofar - FactorT = int64 -func fromMicroseconds(us: int64): timedelta = - newTimedelta initDuration(microseconds=us) - -type - I_in_FI = int64 - FI* = float|I_in_FI ## float or int64 -func accum( - sofar: IntS, ## sofar is the # of microseconds accounted for so far - num: FI, - factor: FactorT, - leftover: var float): IntS = - ##[Fold in the value of the tag ("seconds", "weeks", etc) component of a - timedelta constructor. sofar is the # of microseconds accounted for so far, - and there are factor microseconds per current unit, the number - of which is given by num. num * factor is added to sofar in a - numerically careful way, and that's the result. Any fractional - microseconds left over (this can happen if num is a float type) are - added into `leftover`. - Note that there are many ways this can give an error (NULL) return.]## - when num is_not float: - let prod = num * factor - result = sofar + prod - else: - #[ The Plan: decompose num into an integer part and a - fractional part, num = intpart + fracpart. - Then num * factor == intpart * factor + fracpart * factor - and the LHS can be computed exactly in long arithmetic. - The RHS is again broken into an int part and frac part. - and the frac part is added into *leftover.]# - var (intpart, fracpart) = num.splitDecimal - var x = typeof(sofar) intpart - let prod = x * factor - let sum = sofar + prod - if fracpart == 0.0: - return sum - #[ So far we've lost no information. Dealing with the - fractional part requires float arithmetic, and may - lose a little info.]# - let dnum = factor.float * fracpart - (fracpart, intpart) = dnum.splitDecimal - x = typeof(sofar) intpart - - result = sum + x - leftover += fracpart - -macro accumByFactors(x: IntS; leftover: float; facs: varargs[untyped]) = - result = newStmtList() - for kw in facs: - let - key = kw[0] - val = kw[1] - result.add quote do: - when `key` is SomeInteger: - let nkey = I_in_FI `key` - else: - let nkey = `key` - if `key` != 0: - `x` = accum(`x`, nkey, FactorT `val`, `leftover`) - -const e6int = BiggestInt 1_000_000 - -func timedelta*( - days: FI = 0, seconds: FI = 0, microseconds: FI = 0, - milliseconds: FI = 0, minutes: FI = 0, hours: FI = 0, weeks: FI = 0): timedelta = - bind round # or js backend will fail due to ambiguous call - var leftover_us = 0.0 - var x: IntS - x.accumByFactors(leftover_us, - microseconds = 1, - milliseconds = 1_000, - seconds = e6int, - minutes = 60 * e6int, - hours = 3600 * e6int, - days = 3600 * 24 * e6int, - weeks = 3600 * 24 * 7 * e6int, - ) - if leftover_us != 0.0: - var whole_us = round(leftover_us) - - if abs(whole_us - leftover_us) == 0.5: - let x_is_odd = float((x and 1) == 1) - whole_us = 2.0 * round((leftover_us + x_is_odd) * 0.5) - x_is_odd - - x += IntS whole_us - result = x.fromMicroseconds - -using _: typedesc[timedelta] - -func min*(_): timedelta = - # .. hint:: not `Duration.low` - timedelta(days = -999999999) -func max*(_): timedelta = - timedelta(days=999999999, hours=23, minutes=59, - seconds=59, microseconds=999999) - -func resolution*(_): timedelta = - timedelta(microseconds=1) - -func repr*(self): string = - let parts = self.asDuration.toParts() - template gets(attrImpl): string = $parts.attrImpl - result = "timedelta(days=" & daysImpl.gets & ", seconds=" & secondsImpl.gets & - ", microseconds=" & microsecondsImpl.gets & ')' - -func addRepeat(s: var string, c: char, i: int) = - for _ in 1..i: - s.add c - -func `$`*(self): string = - ## for timedelta.__str__ - ## - ## `[D day[s], ][H]H:MM:SS[.UUUUUU]`, where D is negative for negative t. - let parts = self.asDuration.toParts() - template push(s: string; fill=2) = - let d = fill - s.len - if d > 0: result.addRepeat '0', d - result.add s - template push(i: SomeInteger; fill=2) = push($i, fill) - let d = parts.daysImpl - if d != 0: - result = $d - result.add " day" - if d.abs > 1: result.add 's' - result.add ", " - var secs = parts.secondsImpl - var hrs, mins: int - # here secs is a Natural, so divmod in std/math can be used. - # XXX: no divmod in std/math when JS ? - mins = typeof(mins) divmod(secs, 60, secs) - hrs = typeof(hrs) divmod(mins, 60, mins) - result.add $hrs # hours shall not be padded - result.add ':' - push mins - result.add ':' - push secs - let us = parts.microsecondsImpl - if us != 0: - result.add '.' - push us, 6 - -func total_seconds*(self): float = - ## timedelta.total_seconds() - self.inMicroseconds.float / 1e6 - -template bwBin(op){.dirty.} = - func op*(a, b: timedelta): timedelta = - newTimedelta op(a.asDuration, b.asDuration) -bwBin `+` -bwBin `-` - -func `*`*(self; i: int64): timedelta = newTimedelta(self.asDuration * i) -func `*`*(i: int64, self): timedelta = self * i - -template to_even(result) = - if result > 0: result.inc - else: result.dec - -func is_odd[I](i: I): bool = - abs(i mod 2) == 1 - -func divide_nearest[I: SomeInteger](a, b: I): I = - ## Nearest integer to m / n for integers m and n. Half-integer results - ## are rounded to even. - result = a div b - if b * result != a and - result.is_odd: - result.to_even - -func divide_nearest[I: SomeInteger; F: SomeFloat](a: I, b: F): I = - ## Nearest integer to m / n for integers m and n. Half-integer results - ## are rounded to even. - let resf = a.F / b - result = I resf - if b * resf != a.F and - result.is_odd: - result.to_even - -func multiply_nearest[I: SomeInteger](a: I, f: float): I = - ## rounded to even. - let resf = a.float * f - result = resf.I - if result.is_odd: - if result.float == resf: - return - result.to_even - #result.inc int(result>0) - - -func `*`*(self; f: float): timedelta = - fromMicroseconds multiply_nearest(self.inMicroseconds, f) - -func `*`*(f: float, self): timedelta = self * f - - -func `+`*(self): timedelta = self -template bwUnary(op){.dirty.} = - func op*(self): timedelta = newTimedelta op(self.asDuration) - -bwUnary abs - -func `-`*(self): timedelta = - timedelta(microseconds = -self.inMicroseconds) - - -func `/`*(self; i: int|float): timedelta = - timedelta(microseconds= - divide_nearest(self.inMicroseconds, i) - ) - -func `/`*(self; t: timedelta): float = - when compiles(self.inMicroseconds / t.inMicroseconds): - self.inMicroseconds / t.inMicroseconds - else: - self.inMicroseconds.float / t.inMicroseconds.float - -func `//`*(self; i: int): timedelta = - fromMicroseconds floorDiv(self.inMicroseconds, i) - -func `//`*(self; t: timedelta): int = - floorDiv(self.inMicroseconds, t.inMicroseconds).int - -func `%`*(self, t: timedelta): timedelta = - fromMicroseconds floorMod(self.inMicroseconds, t.inMicroseconds) - -func divmod*(t1, t2: timedelta): (int64, timedelta) = - let - us1 = t1.inMicroseconds - us2 = t2.inMicroseconds - (floorDiv(us1, us2), - fromMicroseconds floorMod(us1, us2)) - -using mself: var timedelta -template iop(Iop, op){.dirty.} = - func Iop*(mself; t: timedelta) = - mself = op(mself, t) - mself.flush_hash() - -iop `+=`, `+` -iop `-=`, `-` \ No newline at end of file diff --git a/src/pylib/Lib/datetime_impl/timezone_impl.nim b/src/pylib/Lib/datetime_impl/timezone_impl.nim deleted file mode 100644 index fee767120..000000000 --- a/src/pylib/Lib/datetime_impl/timezone_impl.nim +++ /dev/null @@ -1,7 +0,0 @@ - - -import ./timezone_impl/[ - decl, meth_else, meth_by_datetime, meth_by_datetime_getter -] - -export decl, meth_else, meth_by_datetime, meth_by_datetime_getter diff --git a/src/pylib/Lib/datetime_impl/timezone_impl/decl.nim b/src/pylib/Lib/datetime_impl/timezone_impl/decl.nim deleted file mode 100644 index ce7c1f7b2..000000000 --- a/src/pylib/Lib/datetime_impl/timezone_impl/decl.nim +++ /dev/null @@ -1,186 +0,0 @@ - -from ../delta_chk import chkOneDay -import ../timedelta_impl/[decl, meth] -import std/times -from std/strutils import toHex - - -type - tzinfo* = ref object of RootObj ## an abstract base class - timezone* = ref object of tzinfo - offset: timedelta - name: string - -const TzNone*: tzinfo = nil -func isTzNone*(self: tzinfo): bool = self == TzNone - -func offset*(self: timezone): timedelta = self.offset ## inner - -func hash*(self: timezone): int = hash self.offset - -{.pragma: benign, tags: [], raises: [], gcsafe.} -method toNimTimezone*(self: tzinfo): Timezone{.base, raises: [].} = - ## .. warning:: in Nim, method's self cannot be nil, - ## otherwise a NilAccessDefect will occur. - ## use `tzToNimTimezone`_ as a workaround. - #notImplErr(tzinfo.toNimTimezone) - local() # XXX: okey? - -method toNimTimezone*(self: timezone): Timezone{.raises: [].} = - ## .. warning:: in Nim, method's self cannot be nil, - ## otherwise a NilAccessDefect will occur. - ## use `tzToNimTimezone`_ as a workaround. - let - offset_dur = self.offset.asDuration - tot_us = offset_dur.inMicroseconds - offset_us = (tot_us mod 1_000_000).int.microseconds - offset_sec = -(tot_us div 1_000_000) - isDst = false - # at least in Nim2.0, isDst doesn't affect the calculation of DateTime - proc localZonedTimeFromTime(t: Time): ZonedTime{.benign.} = - result.time = t + offset_us - result.utcOffset = typeof(result.utcOffset) offset_sec - result.isDst = isDst - proc localZonedTimeFromAdjTime(t: Time): ZonedTime{.benign.} = - result.time = t + offset_us - offset_dur - result.utcOffset = typeof(result.utcOffset) offset_sec - result.isDst = isDst - newTimezone(self.name, - localZonedTimeFromTime, - localZonedTimeFromAdjTime - ) - -template tzToNimTimezone*(tz: tzinfo): Timezone = - ## EXT. - ## `if tz.isTzNone: local() else: tz.toNimTimezone` - ## as when tz is None, a.k.a. dispatcher is nil, - ## `toNimTimezone` will fail when called, raising `NilAccessDefect` - bind local, isTzNone, toNimTimezone - if isTzNone(tz): local() else: toNimTimezone(tz) - -let UTC* = timezone(offset: timedelta(0)) -template utc*(_: typedesc[timezone]): timezone = - ## timezone.utc - bind UTC - UTC - -proc newPyTimezone*(offset: timedelta): timezone = - if bool(offset) == false: - return UTC - offset.chkOneDay - timezone(offset: offset) - -func newPyTimezone*(offset: timedelta; name: string): timezone = - offset.chkOneDay - timezone(offset: offset, name: name) - -type NimTimezoneProc = typeof(times.timezone) -static: assert NimTimezoneProc is proc -template utc*(_: NimTimezoneProc): timezone = - ## if `import std/times`, - ## timezone.utc may matches this. - bind UTC - UTC - -func is_const_utc(tz: timezone): bool = - bind `==`, utc_timezone # `==` for ref, cmp on addr - # utc_timezone is immutable, accessing it is fine - {.noSideEffect.}: - tz == UTC - -func repr*(self: timezone): string = - let type_name = $typeof(self) - if self.is_const_utc: - return type_name & ".utc" - result = type_name & '(' & repr self.offset - if self.name.len != 0: - result.add ", " - result.add self.name - result.add ')' - -func format_utcoffset(hours, minutes, seconds, microseconds: int64, - sep: char|string = ':', prefix="UTC"): string = - var - hours = hours - minutes = minutes - seconds = seconds - microseconds = microseconds - var sign = '+' - if hours < 0 or minutes < 0 or seconds < 0 or microseconds < 0: - template rev(i: var SomeInteger) = - i = -i - sign = '-' - rev hours - rev minutes - rev seconds - rev microseconds - let sepLen = when sep is char: 1 else: sep.len - result = newStringOfCap 7 + prefix.len + 3 * sepLen - result.add prefix - result.add sign - template add(cs: char|string) = result.add cs - template add0Nd(d: SomeInteger, n: int) = - # we know `d` >= 0 - let sd = $d - for _ in 1..(n-sd.len): - result.add '0' - result.add sd - template add02d(d: SomeInteger) = add0Nd(d, 2) - add02d hours - add sep - add02d minutes - if seconds != 0: - add sep - add02d seconds - if microseconds != 0: - # We shall `result.setcap result.len + 7`, - # but it's a little complex to make it - add '.' - add0Nd microseconds, 6 - -func format_utcoffset*(parts: DurationParts, sep: string|char = ':', - prefix="UTC"): string = - ## common code of CPython C-API `timezone_str` and `format_utcoffset` - ## in `_datetimemodule.c` - when not defined(release): - let days = parts[Days] + parts[Weeks] * 7 - assert days == 0, "timezone's init shall check its offset is within one day" - let - hours = parts[Hours] - minutes = parts[Minutes] - seconds = parts[Seconds] - microseconds = parts[Microseconds] + 1000 * parts[Milliseconds] - format_utcoffset(hours, minutes, seconds, microseconds, - sep=sep, prefix=prefix) - -template retIfNone(self) = - if self.isTzNone: return "None" - -func `$`*(self: timezone): string = - ## timezone_str - self.retIfNone - if self.name.len != 0: return self.name - if self.is_const_utc or - bool(self.offset) == false: - return "UTC" - format_utcoffset(self.offset.asDuration.toParts(), sep=':', prefix="UTC") - -method repr*(self: tzinfo): string{.base.} = - ## object.__repr__ - self.retIfNone - let hAddr = cast[int](self).toHex(sizeof(int)*2) - "' - -method repr*(self: timezone): string = - ## timezone_repr - self.retIfNone - result = $typeof(self) - if self.is_const_utc: - result.add ".utc" - return - result.add '(' - result.add meth.repr(self.offset) - if self.name.len != 0: - result.add ", " - result.add self.name.repr - result.add ')' diff --git a/src/pylib/Lib/datetime_impl/timezone_impl/meth_by_datetime.nim b/src/pylib/Lib/datetime_impl/timezone_impl/meth_by_datetime.nim deleted file mode 100644 index 8819f7c6f..000000000 --- a/src/pylib/Lib/datetime_impl/timezone_impl/meth_by_datetime.nim +++ /dev/null @@ -1,38 +0,0 @@ -## meth required by datetime class - -import ../timedelta_impl/[decl, meth] -import ../datetime_impl/inner_decl -import ../datetime_impl/meth/[getter, op] -import ./decl - -using dt: datetime - - -template chk_tzinfo(self: tzinfo; dt) = - if dt.tzinfo != self: - raise newException(ValueError, "fromutc: dt.tzinfo is not self") - -template notNone(td: timedelta) = - if td.isTimeDeltaNone: - raise newException(ValueError, "tzinfo.fromutc: timedelta is None") - -method fromutc*(self: tzinfo; dt): datetime{.base.} = - self.chk_tzinfo(dt) - let dtoff = dt.utcoffset() - dtoff.notNone() - - var dtdst = dt.dst() - dtdst.notNone() - - let delta = dtoff - dtdst - - result = dt + delta - dtdst = result.dst() # dt.tzinfo.dst(result) - dtdst.notNone() - - if bool(dtdst): - result = result + dtdst - -method fromutc*(self: timezone; dt): datetime = - self.chk_tzinfo(dt) - dt + self.offset diff --git a/src/pylib/Lib/datetime_impl/timezone_impl/meth_by_datetime_getter.nim b/src/pylib/Lib/datetime_impl/timezone_impl/meth_by_datetime_getter.nim deleted file mode 100644 index 1820706c9..000000000 --- a/src/pylib/Lib/datetime_impl/timezone_impl/meth_by_datetime_getter.nim +++ /dev/null @@ -1,16 +0,0 @@ - -import ./decl -import ../pyerr -import ../datetime_impl/inner_decl -import ../timedelta_impl/decl - -method utcoffset*(self: tzinfo; dt: datetime): timedelta{.base.} = notImplErr(tzinfo.utcoffset) -method utcoffset*(self: timezone; _: datetime): timedelta = self.offset - -method dst*(self: tzinfo; dt: datetime): timedelta{.base.} = notImplErr(tzinfo.dst) -method dst*(self: timezone; _: datetime): timedelta = - ## returns nil - nil - -method tzname*(self: tzinfo; dt: datetime): string{.base.} = notImplErr(tzinfo.tzname) -method tzname*(self: timezone; _: datetime): string = $self diff --git a/src/pylib/Lib/datetime_impl/timezone_impl/meth_else.nim b/src/pylib/Lib/datetime_impl/timezone_impl/meth_else.nim deleted file mode 100644 index bff242c74..000000000 --- a/src/pylib/Lib/datetime_impl/timezone_impl/meth_else.nim +++ /dev/null @@ -1,17 +0,0 @@ - - -import ./decl -import ../timedelta_impl/decl as td_decl - -using self: tzinfo - -proc timezone*(offset: timedelta): timezone = newPyTimezone(offset) - -func timezone*(offset: timedelta; name: string): timezone = - newPyTimezone(offset, name) - - -using self: timezone - -func `==`*(self; o: timezone): bool = self.offset == o.offset -# `<`, `<=` raises NotImplementedError in CPython diff --git a/src/pylib/Lib/datetime_impl/types.nim b/src/pylib/Lib/datetime_impl/types.nim deleted file mode 100644 index 2daf66d53..000000000 --- a/src/pylib/Lib/datetime_impl/types.nim +++ /dev/null @@ -1,6 +0,0 @@ - - - -import ./datetime_impl, ./timedelta_impl, ./timezone_impl - -export datetime_impl, timedelta_impl, timezone_impl diff --git a/src/pylib/Lib/enum_impl/enumType.nim b/src/pylib/Lib/enum_impl/enumType.nim deleted file mode 100644 index 6bceb5c08..000000000 --- a/src/pylib/Lib/enum_impl/enumType.nim +++ /dev/null @@ -1,77 +0,0 @@ -# -import std/[hashes, tables, strformat] -import ../../pyerrors/simperr - -template GenPyEnumInit*(Self, Value: typedesc; sym){.dirty.} = - bind `[]` - proc sym*(value: Self): Self = value - proc sym*(value: Value): Self = - `Self.names`.withValue value, name: - return `Self.member_map`[name[]] - raise newException(ValueError, repr(value) & " is not a valid " & $Self) - -template GenPyEnumMeth*(Self; Value: typedesc; genObjMeth = true, genInit = false, nameError = NameError, Str = string){.dirty.} = - ## XXX: NIM-BUG: as `std/tables` is not working with `bind` once required at compile time, - ## `import std/tables` is a must before using this template. - bind contains, `[]` - bind hash, Table, Hash, withValue, `[]=`, `$`, items, len, fmt, formatValue - var `Self.names`{.compileTime.}: Table[Value, string] ## self._name_ - var `Self.member_map`{.compileTime.}: Table[Str, Self] ## cls._member_map_ - bind GenPyEnumInit - - using self: Self - using cls: typedesc[Self] - proc value*(self): Value{.inline.} = Value(self) - - proc name*(self): Str{.inline.} = `Self.names`[self.value] - proc `name=`(self; name: Str){.inline.} = `Self.names`[self.value] = name - proc repr*(self): Str = - let vr = when compiles(typeof(self).value_repr(self.value)): - typeof(self).value_repr(self.value) - else: - repr(self.value) - fmt"<{$typeof(self)} {self.name}: {vr}>" - - proc `$`*(self): string = - fmt"{$typeof(self)}.{self.name}" - proc hash*(self): Hash = hash(`Self.names`[self.value]) - when genObjMeth: - proc `==`*(self; other: Self): bool = self.value == other.value - proc add_member(cls; name: Str, self) = - if name in `Self.member_map`: - if `Self.member_map`[name] != self: - let s = repr(`Self.member_map`[name]) - raise newException(nameError, fmt"{repr(name)} is already bound: {s}") - return - # XXX: Python here also need to handle property and class attribute - `Self.member_map`[name] = self - proc add_alias*(self; name: Str) = Self.add_member(name, self) - when genInit: - GenPyEnumInit(Self, Value, Self) - - - # _simple_enum's convert_class's Enum / IntEnum / StrEnum branch - proc add_member*(enum_class: typedesc[Self]; name: Str, value: Value): Self = - let member = Self(value) - `Self.member_map`.withValue name, contained: - # an alias to an existing member - contained[].add_alias(name) - result = contained[] - do: - # finish creating member - member.name = name - enum_class.add_member(name, member) - result = member - - - - proc `[]`*(cls; name: string): Self = `Self.member_map`[name] - proc len*(cls): int = len `Self.names` - iterator items*(cls): Self = - for k in `Self.names`.keys(): yield k - - template contains*(cls; value: Self): bool = true - proc contains*(cls; value: Value): bool = - `Self.names`.withValue value, name: - return name in `Self.member_map` - diff --git a/src/pylib/Lib/enum_impl/intEnum.nim b/src/pylib/Lib/enum_impl/intEnum.nim deleted file mode 100644 index 65feda3ef..000000000 --- a/src/pylib/Lib/enum_impl/intEnum.nim +++ /dev/null @@ -1,15 +0,0 @@ - -import ./enumType - - - - -template GenIntEnumMeth*(Self: typedesc; Int = int, genObjMeth = true, genInit = false){.dirty.} = - bind GenPyEnumMeth - GenPyEnumMeth(Self, Int, genObjMeth, genInit) - converter toInt*(self: Self): Int = self.Int - -template DeclIntEnumMeth*(Self; Int = int, genObjMeth = true, genInit = false){.dirty.} = - bind GenIntEnumMeth - type Self = distinct Int - GenIntEnumMeth(Self, Int, genObjMeth, genInit) diff --git a/src/pylib/Lib/errno.nim b/src/pylib/Lib/errno.nim deleted file mode 100644 index 0546e6c7d..000000000 --- a/src/pylib/Lib/errno.nim +++ /dev/null @@ -1,12 +0,0 @@ - -import ../builtins/dict as dictLib -import ../builtins/dict_decl -import ../pystring/strimpl -export strimpl -export dictLib - -import ./n_errno except errorcode -export n_errno except errorcode - -declErrorcodeWith[int, PyStr] newPyDict -export errorcode diff --git a/src/pylib/Lib/errno_impl/errnoConsts.nim b/src/pylib/Lib/errno_impl/errnoConsts.nim deleted file mode 100644 index 0857ca4be..000000000 --- a/src/pylib/Lib/errno_impl/errnoConsts.nim +++ /dev/null @@ -1,3 +0,0 @@ - -import ./private/exportUtils -exportAllErrnosViaEnumOrImportc() diff --git a/src/pylib/Lib/errno_impl/errnoUtils.nim b/src/pylib/Lib/errno_impl/errnoUtils.nim deleted file mode 100644 index 0f1d73f2b..000000000 --- a/src/pylib/Lib/errno_impl/errnoUtils.nim +++ /dev/null @@ -1,53 +0,0 @@ -## EXT. stable - -import ./private/[exportUtils, errorcodeInit, singleton_errno] -export errorcodeInit, exportAllErrnosViaEnumOrImportc - -template prepareRWErrno*{.dirty.} = discard - -template prepareROErrno*{.dirty.} = - prepareRWErrno - - -template setErrnoRaw*(v: cint) = {.noSideEffect.}: - bind errno, staticErrno - when nimvm: - staticErrno = v - else: - errno = v # as v, for example, ERANGE, is global `let` - -template setErrno*(v: untyped) = {.noSideEffect.}: - bind errno, staticErrno - when nimvm: - staticErrno = cint ord Errno.v - else: - errno = v # as v, for example, ERANGE, is global `let` - -template setErrno0* = {.noSideEffect.}: - bind errno, staticErrno - when nimvm: - staticErrno = 0 - else: - errno = 0 - -proc getErrno*(): cint = {.noSideEffect.}: - bind errno, staticErrno - block: - when nimvm: - result = staticErrno - else: - result = errno - -template isErr*(E: untyped): bool = - bind getErrno - var c: cint - {.noSideEffect.}: - when nimvm: - c = cint ord Errno.E - else: - c = E - getErrno() == c - -template isErr0*(): bool = - bind getErrno - getErrno() == 0 diff --git a/src/pylib/Lib/errno_impl/private/clike.nim b/src/pylib/Lib/errno_impl/private/clike.nim deleted file mode 100644 index e9d4fc6b6..000000000 --- a/src/pylib/Lib/errno_impl/private/clike.nim +++ /dev/null @@ -1,4 +0,0 @@ - -from ../../private/platformUtils import CLike -export CLike - diff --git a/src/pylib/Lib/errno_impl/private/errnos.nim b/src/pylib/Lib/errno_impl/private/errnos.nim deleted file mode 100644 index 60d5fe677..000000000 --- a/src/pylib/Lib/errno_impl/private/errnos.nim +++ /dev/null @@ -1,149 +0,0 @@ - - -import std/enumutils - - -type Errno*{.pure.} = enum - E_SUCCESS = "success" ## inner. unstable. - E2BIG = "Argument list too long" - EACCES = "Permission denied" - EADDRINUSE = "Address already in use" - EADDRNOTAVAIL = "Cannot assign requested address" - EADV = "Advertise error" - EAFNOSUPPORT = "Address family not supported by protocol" - EAGAIN = "Resource temporarily unavailable" - EALREADY = "Operation already in progress" - EBADE = "Invalid exchange" - EBADF = "Bad file descriptor" - EBADFD = "File descriptor in bad state" - EBADMSG = "Bad message" - EBADR = "Invalid request descriptor" - EBADRQC = "Invalid request code" - EBADSLT = "Invalid slot" - EBFONT = "Bad font file format" - EBUSY = "Device or resource busy" - ECANCELED = "Operation canceled" - ECHILD = "No child processes" - ECHRNG = "Channel number out of range" - ECOMM = "Communication error on send" - ECONNABORTED = "Software caused connection abort" - ECONNREFUSED = "Connection refused" - ECONNRESET = "Connection reset by peer" - EDEADLK = "Resource deadlock avoided" - EDEADLOCK = "Resource deadlock avoided" - EDESTADDRREQ = "Destination address required" - EDOM = "Numerical argument out of domain" - EDOTDOT = "RFS specific error" - EDQUOT = "Disk quota exceeded" - EEXIST = "File exists" - EFAULT = "Bad address" - EFBIG = "File too large" - EHOSTDOWN = "Host is down" - EHOSTUNREACH = "No route to host" - EIDRM = "Identifier removed" - EILSEQ = "Invalid or incomplete multibyte or wide character" - EINPROGRESS = "Operation now in progress" - EINTR = "Interrupted system call" - EINVAL = "Invalid argument" - EIO = "Input/output error" - EISCONN = "Transport endpoint is already connected" - EISDIR = "Is a directory" - EISNAM = "Is a named type file" - EKEYEXPIRED = "Key has expired" - EKEYREJECTED = "Key was rejected by service" - EKEYREVOKED = "Key has been revoked" - EL2HLT = "Level 2 halted" - EL2NSYNC = "Level 2 not synchronized" - EL3HLT = "Level 3 halted" - EL3RST = "Level 3 reset" - ELIBACC = "Can not access a needed shared library" - ELIBBAD = "Accessing a corrupted shared library" - ELIBEXEC = "Cannot exec a shared library directly" - ELIBMAX = "Attempting to link in too many shared libraries" - ELIBSCN = ".lib section in a.out corrupted" - ELNRNG = "Link number out of range" - ELOOP = "Too many levels of symbolic links" - EMEDIUMTYPE = "Wrong medium type" - EMFILE = "Too many open files" - EMLINK = "Too many links" - EMSGSIZE = "Message too long" - EMULTIHOP = "Multihop attempted" - ENAMETOOLONG = "File name too long" - ENAVAIL = "No XENIX semaphores available" - ENETDOWN = "Network is down" - ENETRESET = "Network dropped connection on reset" - ENETUNREACH = "Network is unreachable" - ENFILE = "Too many open files in system" - ENOANO = "No anode" - ENOBUFS = "No buffer space available" - ENOCSI = "No CSI structure available" - ENODATA = "No data available" - ENODEV = "No such device" - ENOENT = "No such file or directory" - ENOEXEC = "Exec format error" - ENOKEY = "Required key not available" - ENOLCK = "No locks available" - ENOLINK = "Link has been severed" - ENOMEDIUM = "No medium found" - ENOMEM = "Cannot allocate memory" - ENOMSG = "No message of desired type" - ENONET = "Machine is not on the network" - ENOPKG = "Package not installed" - ENOPROTOOPT = "Protocol not available" - ENOSPC = "No space left on device" - ENOSR = "Out of streams resources" - ENOSTR = "Device not a stream" - ENOSYS = "Function not implemented" - ENOTBLK = "Block device required" - ENOTCONN = "Transport endpoint is not connected" - ENOTDIR = "Not a directory" - ENOTEMPTY = "Directory not empty" - ENOTNAM = "Not a XENIX named type file" - ENOTRECOVERABLE = "State not recoverable" - ENOTSOCK = "Socket operation on non-socket" - ENOTSUP = "Operation not supported" - ENOTTY = "Inappropriate ioctl for device" - ENOTUNIQ = "Name not unique on network" - ENXIO = "No such device or address" - EOPNOTSUPP = "Operation not supported" - EOVERFLOW = "Value too large for defined data type" - EOWNERDEAD = "Owner died" - EPERM = "Operation not permitted" - EPFNOSUPPORT = "Protocol family not supported" - EPIPE = "Broken pipe" - EPROTO = "Protocol error" - EPROTONOSUPPORT = "Protocol not supported" - EPROTOTYPE = "Protocol wrong type for socket" - ERANGE = "Numerical result out of range" - EREMCHG = "Remote address changed" - EREMOTE = "Object is remote" - EREMOTEIO = "Remote I/O error" - ERESTART = "Interrupted system call should be restarted" - ERFKILL = "Operation not possible due to RF-kill" - EROFS = "Read-only file system" - ESHUTDOWN = "Cannot send after transport endpoint shutdown" - ESOCKTNOSUPPORT = "Socket type not supported" - ESPIPE = "Illegal seek" - ESRCH = "No such process" - ESRMNT = "Srmount error" - ESTALE = "Stale file handle" - ESTRPIPE = "Streams pipe error" - ETIME = "Timer expired" - ETIMEDOUT = "Connection timed out" - ETOOMANYREFS = "Too many references: cannot splice" - ETXTBSY = "Text file busy" - EUCLEAN = "Structure needs cleaning" - EUNATCH = "Protocol driver not attached" - EUSERS = "Too many users" - EWOULDBLOCK = "Resource temporarily unavailable" - EXDEV = "Invalid cross-device link" - EXFULL = "Exchange full" - -static: assert Errno is Ordinal -const ErrnoCount* = 1 + ord(high Errno) - 1 # exclude E_SUCCESS - -func strerror*(e: Errno): string = system.`$` e - -func `$`*(e: Errno): string = symbolName e - - diff --git a/src/pylib/Lib/errno_impl/private/errorcodeInit.nim b/src/pylib/Lib/errno_impl/private/errorcodeInit.nim deleted file mode 100644 index 1ced63455..000000000 --- a/src/pylib/Lib/errno_impl/private/errorcodeInit.nim +++ /dev/null @@ -1,47 +0,0 @@ - - -import ./errnos -import ./loopErrno -import ./clike -export errnos - -import std/enumutils -import std/macros - -macro initErrorcodeMap*(K, V; res: untyped, initFunc: typed) = - mixin `[]=` - result = newStmtList() - let N = newLit ErrnoCount - result.add quote do: - var `res` = `initFunc`[`K`, `V`](`N`) - #[ - XXX: NIM-BUG: if using `let` in forErrno loop (in Windows): - errorcodeInit.nim(18, 7) Error: redefinition of 'errName'; previous declaration here: errorcodeInit.nim(18, 7) - ]# - var - errName: string - errNameNode, errId: NimNode - result.forErrno e: - errName = symbolName e - errNameNode = newLit errName - errId = ident errName - when CLike: - let addErrnoId = genSym(nskProc, errName) - # NOTE: just wrap in `res`[`errId`] = `errNameNode` directly in `#ifdef` - # doesn't work, as `#ifdef .. #endif` will not be placed right - # around stmt, but - # very early in the C file. - # so we use a proc. - result.add quote do: - proc `addErrnoId`(){.inline.} = - {.emit: "\n#ifdef " & `errNameNode` & "\n".} - `res`[`errId`] = `errNameNode` - {.emit: "\n#endif\n".} - result.add newCall(addErrnoId) - else: - result.add quote do: - `res`[`errId`] = `errNameNode` - -template declErrorcodeWith*[K, V](initFunc: typed) = - bind initErrorcodeMap - initErrorcodeMap K, V,errorcode, initFunc diff --git a/src/pylib/Lib/errno_impl/private/exportUtils.nim b/src/pylib/Lib/errno_impl/private/exportUtils.nim deleted file mode 100644 index 90ec98086..000000000 --- a/src/pylib/Lib/errno_impl/private/exportUtils.nim +++ /dev/null @@ -1,23 +0,0 @@ - -import ./clike -import ./loopErrno -import ./errnos -export errnos - -import std/macros - -import std/enumutils - -template eno(E) = - when CLike: - let E*{.importc, header: "".}: cint - else: - const E*: cint = cint ord Errno.E - -macro exportAllErrnosViaEnumOrImportc*() = - result = newStmtList() - result.forErrno e: - result.add newCall(bindSym"eno", ident symbolName e) - - - diff --git a/src/pylib/Lib/errno_impl/private/loopErrno.nim b/src/pylib/Lib/errno_impl/private/loopErrno.nim deleted file mode 100644 index 0e1bc6a3b..000000000 --- a/src/pylib/Lib/errno_impl/private/loopErrno.nim +++ /dev/null @@ -1,35 +0,0 @@ -import std/macros -import std/enumutils -import ./clike -import ./errnos - -template emitPragma(body: string): NimNode = - nnkPragma.newTree( - nnkExprColonExpr.newTree( - newIdentNode("emit"), - newLit(body) - ) - ) - -template whenDefErrno*(res: NimNode; errnoName: string; body): untyped{.dirty.} = - bind CLike, add, quote, emitPragma - when CLike: - # hint: following takes the responsibility to make declaration of errnoName - # to be wrapped by `#ifdef` - res.add emitPragma "\n#ifdef " & errnoName & '\n' - body - res.add emitPragma "\n#endif\n" - else: - body - -const ErrnoHigh = high(Errno) -template forErrno*(res: NimNode; err; body) = - bind whenDefErrno, Errno, ErrnoHigh - for err{.inject.} in succ(Errno.E_SUCCESS)..ErrnoHigh: - # XXX: NIM-BUG: with `bind Errno` above, use `high(Errno)` here makes Nim - # consider Errno as a value instead of a type, thus leading to a warning - #[Deprecated since v1.4; there should not be `high(value)`. Use `high(type)`.; high is deprecated]# - - #if err == Errno.E_SUCCESS: continue - result.whenDefErrno symbolName err: - body diff --git a/src/pylib/Lib/errno_impl/private/singleton_errno.nim b/src/pylib/Lib/errno_impl/private/singleton_errno.nim deleted file mode 100644 index 958922476..000000000 --- a/src/pylib/Lib/errno_impl/private/singleton_errno.nim +++ /dev/null @@ -1,8 +0,0 @@ - -import ./clike -when CLike: - var errno*{.importc: "errno", header: "".}: cint -else: - var errno*{.threadvar.}: cint - -var staticErrno*{.compileTime.}: cint ## used compile time diff --git a/src/pylib/Lib/fractions.nim b/src/pylib/Lib/fractions.nim deleted file mode 100644 index 0f5c6c437..000000000 --- a/src/pylib/Lib/fractions.nim +++ /dev/null @@ -1,143 +0,0 @@ - -import std/rationals -import std/math -import std/strutils - -type - FractionInt* = int - TFraction*[T] = ref object - data: Rational[T] - PyFraction* = TFraction[FractionInt] - -func newPyFraction*: PyFraction = new result -func toTFraction*[T](r: Rational[T]): PyFraction = - result = newPyFraction() - result.data = r -func toPyFraction*(r: Rational[int]): PyFraction = - toTFraction r - -template wrapBinary(sym, tosym; Res){.dirty.} = - func sym*(a, b: PyFraction): Res = - tosym(a.data, b.data) - -template wrapBinary(sym, tosym){.dirty.} = - func sym*(a, b: PyFraction): PyFraction = - toPyFraction tosym(a.data, b.data) - func sym*(a: PyFraction, b: int): PyFraction = - toPyFraction tosym(a.data, toRational b) - func sym*(b: int, a: PyFraction): PyFraction = - toPyFraction tosym(a.data, toRational b) - func sym*(a: PyFraction, b: float): float = - tosym(a.data.toFloat, b) - func sym*(b: float, a: PyFraction): float = - tosym(a.data.toFloat, b) - - -template wrapBinary(sym) = wrapBinary sym, sym - -template wrapBinaryNoRet(sym, tosym){.dirty.} = - func sym*(a, b: PyFraction) = - tosym(a.data, b.data) - func sym*(a: PyFraction, b: int) = - tosym(a.data, toRational b) - func sym*(a: PyFraction, b: float){.error: - "Python allowed this but make `self` to a float".} -template wrapBinaryNoRet(sym) = wrapBinaryNoRet sym, sym - -using self: PyFraction - -func numerator*(self): FractionInt = - self.data.num -func denominator*(self): FractionInt = - self.data.den - -func is_integer*(self): bool = self.data.den == 1 - -template cannotSet(a){.dirty.} = - func `a=`*(self; v: FractionInt){.error: "AttributeError: can't set attribute".} - -cannotSet numerator -cannotSet denominator - -func hash*(self): int = self.data.hash.int - -func Fraction*(other: PyFraction): PyFraction = - result = toPyFraction other.data - -func Fraction*(f: float): PyFraction = toPyFraction toRational f -func from_float*(typ: typedesc[PyFraction], flt: float): PyFraction = - Fraction flt - -func Fraction*(numerator = 0, denominator = 1): PyFraction = - toPyFraction initRational(num=numerator, den=denominator) - -func parseIntFraction(res: var Rational[int], str: string): bool = - let idx = str.find '/' - if idx == -1: return false - res.num = parseInt str[0..", line 1 -SyntaxError: not a chance -""" diff --git a/src/pylib/Lib/gc.nim b/src/pylib/Lib/gc.nim deleted file mode 100644 index ccc4cd75b..000000000 --- a/src/pylib/Lib/gc.nim +++ /dev/null @@ -1,35 +0,0 @@ -## Lib/gc -## -## ## Nim's Memory Management -## -## Since Nim 2.0, ORC becomes the default mm (memory management). -## In ORC, only a cycle collector will runs at runtime, -## so `enable`_ and `disable`_ only affect this cycle collector, -## a.k.a. `collect` for objects that not causes cycle cannot be -## disabled in runtime, as it's determined at compile-time, namely by ARC. -## -## Document for Nim's [mm](https://nim-lang.org/docs/mm.html). -## -## Python's gc is similar with -## Nim's [`refc`](https://nim-lang.org/docs/refc.html) mm, -## which is default for Nim 1.x -## -## As Nim's mm is so different from Python's gc, -## only a few APIs of `gc` can be ported to Nim. - -proc enable*() = - when defined(gcOrc): GC_enableOrc() - else: GC_enable() -proc disable*() = - when defined(gcOrc): GC_disableOrc() - else: GC_disable() - -const GcCollectResult* = 0 ## Result of `collect`_ - -proc collect*(): int{.discardable.} = - ## .. hint:: Do not use the result. - ## As there is no way to get - ## the number of `gc`-ed objects - ## current implement always returns `GcCollectResult`_ - GC_fullCollect() - GcCollectResult diff --git a/src/pylib/Lib/index.nim b/src/pylib/Lib/index.nim deleted file mode 100644 index 423cfd11b..000000000 --- a/src/pylib/Lib/index.nim +++ /dev/null @@ -1,9 +0,0 @@ -import ./private/doc_utils/genIndex -##[ -# Lib - -Python standard libraries -porting in nimpylib - -]## -genIndexHere() \ No newline at end of file diff --git a/src/pylib/Lib/inspect.nim b/src/pylib/Lib/inspect.nim deleted file mode 100644 index e1d0eedea..000000000 --- a/src/pylib/Lib/inspect.nim +++ /dev/null @@ -1,75 +0,0 @@ - -import std/macros -import ./n_inspect -export n_inspect.getline - -from ./inspect_impl/sourcegetters import getsourcelinesImpl, getdocNoDedentImpl -import ./inspect_impl/members -export isX except markcoroutinefunction - -import ../builtins/list_decl -export list_decl - -import ../pystring/strimpl -export strimpl -import ./typing_impl/str_optional_obj -expOptObjCvt() -from ../pystring/strmeth import splitlines -import ../version - -iterator getmembers*[T](obj: T): GetMemberType = members.getmembers(obj) -iterator getmembers*[T](obj: T, predict: GetMembersPredict): GetMemberType = - members.getmembers(obj, predict) - - -template add(self: PyList, item: GetMemberType) = - self.append(item) - -template getmembers*(obj): PyList = - bind getmembersImpl, allTrue, add, newPyList - getmembersImpl[GetMembersType](obj, allTrue, newPyList[GetMembersType]) - -template getmembers*(obj; predict: GetMembersPredict): PyList = - bind getmembersImpl, add, newPyList - getmembersImpl[GetMembersType](obj, predict, newPyList[GetMembersType]) - -gen_getmembers_static pysince(3,11) - - -template wrapPyStr1(fun; T){.dirty.} = - template fun*(obj: T): PyStr = - str n_inspect.fun(obj) -template wrapPyOptStr1(fun; T){.dirty.} = - template fun*(obj: T): OptionalObj[PyStr] = - newStrOptionalObj n_inspect.fun(obj) - -wrapPyOptStr1 getmodulename, PyStr - -wrapExportSincePy(3,12, markcoroutinefunction) - -wrapExportSincePy(3,5, iscoroutinefunction) -wrapExportSincePy(3,5, isawaitable) - -# isasyncgenfunction 3.6 - - -template wrapPyStr1(fun){.dirty.} = wrapPyStr1(fun, untyped) -template wrapPyOptStr1(fun){.dirty.} = wrapPyOptStr1(fun, untyped) - -wrapPyStr1 cleandoc, PyStr -wrapPyStr1 getfile -wrapPyOptStr1 getsourcefile -wrapPyStr1 getsource -wrapPyOptStr1 getdoc - -template getsourcelines*(obj: typed): (PyList[PyStr], int) = - ## get source code of the object: - ## - ## - the first element is the source code - ## - the second element is the line number of the first line of the source code - bind splitlines, getsourcelinesImpl - getsourcelinesImpl(obj, splitlines) - -# TODO: -# https://docs.python.org/3/library/inspect.html#introspecting-callables-with-the-signature-object -# https://docs.python.org/3/library/inspect.html#classes-and-functions diff --git a/src/pylib/Lib/inspect_impl/isX.nim b/src/pylib/Lib/inspect_impl/isX.nim deleted file mode 100644 index 055c2969a..000000000 --- a/src/pylib/Lib/inspect_impl/isX.nim +++ /dev/null @@ -1,74 +0,0 @@ -# DEV-NOTE: this definitions is in order of python's doc, -# also this's not a complete implementation - -import std/macros - -template genIsX(isX, typ){.dirty.} = - macro isX*(obj: typed): bool = - newLit obj.symKind == typ - -func `==`(t: NimSymKind, expects: tuple[a, b: NimSymKind]): bool = - t == expects[0] or t == expects[1] - -const typeForPyDef = (nskProc, nskFunc) -genIsX ismodule, nskModule -genIsX isclass, nskType -genIsX ismethod, nskMethod -genIsX isfunction,typeForPyDef - -# TODO: after Python Generator is supported -# isgeneratorfunction -# isgenerator -# isasyncgenfunction 3.6 -# isasyncgen -# ismethodwrapper 3.11 -# isroutine -# isabstract -# ismethoddescriptor -# isdatadescriptor -# isgetsetdescriptor -# ismemberdescriptor - - -template nimpylib_is_coroutine_mark{.pragma.} - -macro markcoroutinefunction*[T](obj: T): T = - expectKind obj, RoutineNodes - result = obj - result.addPragma ident"nimpylib_is_coroutine_mark" - -func iscoroutineImpl(obj: NimNode): bool = - if obj.symKind != typeForPyDef: - return - # TODO: FIXME: I haven't found a way to get a symbol, but a untyped node - let res = obj.getTypeInst().params[0] - if res.kind == nnkBracketExpr: - return res[0].eqIdent "Future" - if res.eqIdent "Future": - return true - -macro iscoroutine*(obj: typed): bool = - newLit iscoroutineImpl obj - -macro iscoroutinefunction*(obj: typed): bool = - result = newLit iscoroutineImpl obj - if obj.hasCustomPragma nimpylib_is_coroutine_mark: - return newLit true - -template isawaitable*(obj: typed): bool = compiles(await obj) - -# TODO: support them when types.PyFrame, PyTraceback are supported -template istraceback*(obj: typed): bool = obj is StackTraceEntry -template isframe*(obj: typed): bool = obj is TFrame - -macro isbuiltin*(obj: typed): bool = - newLit obj.getImpl().isNil - - -when isMainModule: - import std/asyncdispatch - proc f(){.inline,async.} = discard - proc g() = discard - static: - echo iscoroutinefunction f - echo iscoroutinefunction g diff --git a/src/pylib/Lib/inspect_impl/members.nim b/src/pylib/Lib/inspect_impl/members.nim deleted file mode 100644 index dc97984aa..000000000 --- a/src/pylib/Lib/inspect_impl/members.nim +++ /dev/null @@ -1,96 +0,0 @@ -# TODO: add support for mixin ops between types and then better support `predict` param -import std/macros -import std/typeinfo except isNil - -type MemberType = Any - -func `$`*(t: MemberType): string = - case t.kind - of akInt: result = $t.getInt - of akInt8: result = $t.getInt8 - of akInt16: result = $t.getInt16 - of akInt32: result = $t.getInt32 - of akInt64: result = $t.getInt64 - of akUInt: result = $t.getUInt - of akUInt8: result = $t.getUInt8 - of akUInt16: result = $t.getUInt16 - of akUInt32: result = $t.getUInt32 - of akUInt64: result = $t.getUInt64 - - of akFloat: result = $t.getFloat - of akFloat32: result = $t.getFloat32 - of akFloat64: result = $t.getFloat64 - of akFloat128: - doAssert false, "float128 not supported" - - of akString: result = t.getString - of akCString: result = $t.getCString - of akBool: - result = $t.getBool - of akChar: - result = $t.getChar - of akEnum: - result = $t.getEnumField - of akObject, akTuple: - t.setObjectRuntimeType - for i in t.fields: - result.add $i - of akArray, akSequence: - for i in 0..".} -proc flush*(f: IOBase) = - let ret = f.c_fflush() - if ret != 0: - raiseErrno() - -func tell*(f: IOBase): int64 = f.getFilePos() - -func isatty*(f: IOBase): bool = f.isatty() - -proc fileno*(f: IOBase): int = int getFileHandle f - -const DEFAULT_BUFFER_SIZE* = 8192 - -type - NoEncTextIOBase* = ref object of IOBase - ## no encoding conversion is performed on underlying file. - ## used for those stream whose encoding is alreadly utf-8 - newline: NewlineType - NoEncTextIOWrapper* = ref object of NoEncTextIOBase - name*: PyStr - mode*: PyStr - - TextIOWrapper* = ref object of NoEncTextIOWrapper - encErrors: EncErrors ## do not use string, so is always valid - codec: NCodecInfo - -func encoding*(s: TextIOWrapper): PyStr = s.codec.name -func errors*(s: TextIOWrapper): PyStr = s.codec.errors - -type - RawIOBase* = ref object of IOBase - FileIO* = ref object of RawIOBase - - BufferedIOBase* = ref object of IOBase - BufferedRandom* = ref object of BufferedIOBase - BufferedReader* = ref object of BufferedIOBase - BufferedWriter* = ref object of BufferedIOBase - -proc parseNewLineType(nl: string): NewLineType = - case nl - of DefNewLine: nlUniversal - of "": nlUniversalAsIs - of "\n": nlReturn - of "\r\n": nlCarriageReturn - of "\r": nlCarriage - else: # err like Python - raise newException(ValueError, "illegal newline value: " & nl) - -proc initNewLineMode(self: NoEncTextIOBase, newline: string) = - self.newline = parseNewLineType newline - -template Raise(exc; msg): untyped = - raise newException(exc, msg) - -method seek*(f: IOBase, cookie: int64, whence=SEEK_SET): int64{.base, discardable.} = - f.setFilePos(cookie, FileSeekPos(whence)) - result = f.getFilePos() -method seek*(self: TextIOWrapper, cookie: int64, whence=SEEK_SET): int64{.discardable.} = - runnableExamples: - var f = open("tempfiletest", 'w') - doAssertRaises UnsupportedOperation: - f.seek(1, SEEK_CUR) - f.close() - if self.closed: - Raise ValueError, ("tell on closed file") - var - mwhence = whence - mcookie = cookie - case whence - of SEEK_CUR: - if cookie != 0: - Raise UnsupportedOperation, ("can't do nonzero end-relative seeks") - # Seeking to the current position should attempt to - # sync the underlying buffer with the current position. - mwhence = 0 - mcookie = self.tell() - of SEEK_END: - if cookie != 0: - Raise UnsupportedOperation, ("can't do nonzero end-relative seeks") - self.flush() - return procCall seek(IOBase(self), 0, whence) - else: discard - if whence != SEEK_SET: - Raise ValueError, ("unsupported whence ($#)" % $whence) - # whence == SEEK_SET - if cookie < 0: - Raise ValueError, ("negative seek position '$#'" % $cookie) - self.flush() - - # XXX: Python has accessment to its encoder state, - # but not Nim, thus here is no state reset or relative behavior... - # the following is Python's doc comment: - - # The strategy of seek() is to go back to the safe start point - # and replay the effect of read(chars_to_skip) from there. - return procCall seek(IOBase(self), 0, whence) - -proc c_fgetc(stream: File): cint {. - importc: "fgetc", header: "", tags: [].} -proc c_ungetc(c: cint, f: File): cint {. - importc: "ungetc", header: "", tags: [].} - -proc peekChar(self: IOBase): char = - let ci = c_fgetc(self.file) - if ci < 0.cint: raise newException(EOFError, "") - discard c_ungetc(ci, self.file) - result = char ci - -template Iencode = - result = self.codec.decode(result).data - -const NoneChar = '\0' # means None -type - NL_t = array[2, char] - sNL_t = static NL_t -template only1nl(c): untyped = [c, NoneChar] -const AllNL = [NoneChar, NoneChar] - -proc add(s: var string, nl: NL_t) = - if nl[0] == NoneChar: return - s.add nl[0] - if nl[1] != NoneChar: - s.add nl[1] - -# TODO: re-impl using `_get_decoded_chars` (like Python) -template t_readlineTill(res; cond: bool, till: sNL_t = only1nl('\n')): NL_t = - # a very slowish impl... - var nlRes: NL_t - try: - while cond: - nlRes[0] = self.readChar() - when till == AllNL: - if nlRes[0] == '\n': - nlRes = only1nl '\n' - break - elif nlRes[0] == '\r': - if self.peekChar() == '\n': - nlRes[1] = self.readChar() - else: - nlRes[1] = NoneChar - break - else: - res.add nlRes[0] - - else: - if nlRes[0] == till[0]: - when till[1] == NoneChar: - nlRes[1] = NoneChar - break - else: - if self.peekChar() == till[1]: - nlRes[1] = self.readChar() - break - else: - res.add nlRes[0] - else: - res.add nlRes[0] - - except EOFError: - for e in nlRes.mitems: - if e notin {'\r', '\n'}: - e = NoneChar - nlRes - -proc readlineTill(self: IOBase, res: var string, cond: bool, till: sNL_t = only1nl('\n')): NL_t = - t_readlineTill res, cond, till - -template readlineImpl(self: RawIOBase; cond): untyped{.dirty.} = - ## The line terminator is always bytes '\n' for binary files - var res: string - res.add self.readlineTill(res, cond) - res -proc readline*(self: RawIOBase): PyBytes = bytes readlineImpl(self, true) -proc readline*(self: RawIOBase, size: Natural): PyBytes = - bytes readlineImpl(self, res.len 0: - let s = self.readline(left) - left.dec s.len - if s == "": break - result.add s - -proc read*(self: NoEncTextIOWrapper, size: int): PyStr = - result = self.readImpl(size) - -proc read*(self: TextIOWrapper, size: int): PyStr = - result = self.readImpl(size) - Iencode - -proc write(self: IOBase, s: string): int{.discardable.} = - self.file.write s - s.len - -proc write*(self: RawIOBase, s: PyBytes): int{.discardable.} = - write(IOBase(self), $s) - -proc writeImpl(self: NoEncTextIOWrapper, s: string, cvtRet: proc(s: string): int): int{.discardable.} = - proc retSubs(toNewLine: string): int = cvtRet(s.replace("\n", toNewLine)) - case self.newline - of nlUniversalAsIs, nlReturn: - # no translation takes place. - cvtRet s - of nlUniversal: retSubs "\p" - of nlCarriage: retSubs "\r" - of nlCarriageReturn: retSubs "\r\n" - -proc write*(self: NoEncTextIOWrapper, s: PyStr): int{.discardable.} = - proc cvtRet(oriStr: string): int = - discard write(IOBase(self), s) - s.len - writeImpl(self, s, cvtRet) - -proc write*(self: TextIOWrapper, s: PyStr): int{.discardable.} = - ## Writes the `s` to the stream and return the number of characters written - ## - ## The following is from Python's doc of `open`: - ## if newline is None, any '\n' characters written are translated to - ## the system default line separator, os.linesep. - ## If newline is "" or '\n', no translation takes place. - ## If newline is any of the other legal values, - ## any '\n' characters written are translated to the given string. - runnableExamples: - const fn = "tempfiletest" - proc checkW(s, dest: string, newline=DefNewLine, encoding=DefEncoding; - writeLen=dest.len # dest.len returns bytes size - ) = - var f = open(fn, 'w', newline=newline, encoding=encoding) - assert writeLen == f.write s - f.close() - let res = readFile fn - assert dest == res, "expected "&dest.repr&" but got "&res.repr - checkW "1\n2", when defined(windows): "1\r\n2" else: "1\n2" - checkW "1\n2", "1\p2" # same as above - checkW "1\n2", "1\r2", newline="\r" - checkW "我", "我", encoding="utf-8", writeLen=1 - - proc cvtRet(oriStr: string): int = - let t = self.codec.encode(oriStr) - discard write(IOBase(self), t.data) - t.len - writeImpl(self, s, cvtRet) - -proc truncate*(self: IOBase): int{.discardable.} = - runnableExamples: - const fn = "tempfiletest" - var f = open(fn, "w+") - discard f.write("123") - f.seek(0) - f.truncate() - assert f.read() == "" - f.close() - result = self.tell().int - truncate self.fileno, result - -proc truncate*(self: IOBase, size: int64): int64{.discardable.} = - truncate self.fileno, size - size - -# workaround, -# a Nim's bug: when ref object+method+var+procCall -# error: 'self_p0' is a pointer to pointer; did you mean to dereference it before applying '->' to it? -# close__6958ZprogramZutilsZnimpylibZsrcZpylibZio_u643(&self_p0->Sup); -template base_close() = - if self.closed: return - self.closed = true - self.file.close() - -method close*(self: IOBase){.base.} = base_close() -method close*(self: RawIOBase) = base_close() -method close*(self: TextIOWrapper) = - #procCall close IOBase(self) - base_close() - self.codec.close() - -template raise_ValueError(s) = raise newException(ValueError, s) - -func checkClosed(self: IOBase, msg: string) = - if self.closed: - raise_ValueError(msg) -func checkClosed(self: IOBase) = self.checkClosed( - "I/O operation on closed file.") - -func enter*[IO: IOBase](self: IO): IO = - self.checkClosed() - self -template exit*(self: IOBase, args: varargs[untyped]) = self.close() - -proc parseErrors(s: string): EncErrors = parseEnum[EncErrors](s, EncErrors.strict) -proc getPreferredEncoding(): string = getCurrentEncoding(true) ## concrete ANSI when on Windows -const - DefEncoding* = "" - LocaleEncoding* = "locale" - -proc toSet(s: string): set[char] = - for c in s: result.incl c - -const False=false -const True=true - -template getBlkSize(p: PathLike): int = - getFileInfo($p, followSymlink=true).blockSize - -template getBlkSize(fd: int): int = 0 # TODO: use fstat instead! - -proc isatty(p: CanIOOpenT): bool = - when p is int: - result = p.isatty() - else: - var f: File - if f.open($p, fmRead): - result = f.isatty() - f.close() - -proc norm_buffering(file: CanIOOpenT, buffering: var int): bool = - ## returns line_buffering - var line_buffering = False # not used yet here - if buffering == 1 or buffering < 0 and file.isatty(): - buffering = -1 - line_buffering = True - if buffering < 0: - buffering = DEFAULT_BUFFER_SIZE - try: - #bs = os.fstat(raw.fileno()).st_blksize - let bs = getBlkSize file - if bs > 1: buffering = bs - except OSError: discard - if buffering < 0: raise_ValueError("invalid buffering size") - result = line_buffering - -proc `file=`[I: IOBase](self: var I, file: File) = self.file = file # EXT. - -proc newNoEncTextIO*(file: File, name: string, - newline=DefNewLine): NoEncTextIOWrapper = - result = NoEncTextIOWrapper(name: name, file: file) - result.initNewLineMode(newline) - -proc initTextIO(encoding, errors, smode, newline: string): TextIOWrapper = - var enc = encoding - if enc == DefEncoding: enc = LocaleEncoding - if enc == LocaleEncoding: enc = getPreferredEncoding() - - let ncodec = initNCodecInfo(enc, errors) - result = TextIOWrapper( - encErrors: parseErrors errors, - codec: ncodec, - mode: smode - ) - result.initNewLineMode(newline) - -template genOpenInfo(result: untyped; file; mode: static string, - buffering: var int, - encoding, - errors, - newline: string, - resMode: var FileMode -) = - ## returns is binary - bind toSet, raise_ValueError, repr, warn, - True, False, DeprecationWarning, RuntimeWarning, - initTextIO, - TextIOWrapper, - RawIOBase, BufferedIOBase, BufferedReader, BufferedWriter, BufferedRandom, - DefErrors, DefEncoding, norm_buffering, - FileMode, PathLike, fileExists - const - modes = toSet mode - allSet = toSet("axrwb+tU") - when len(modes - allSet)!=0 or len(mode) > len(modes): - raise_ValueError("invalid mode: $#" % mode.repr) - const - creating = 'x' in modes - writing = 'w' in modes - appending = 'a' in modes - updating = '+' in modes - text = 't' in modes - binary = 'b' in modes - const - reading = - when 'U' in modes: - when creating or writing or appending or updating: - raise_ValueError("mode U cannot be combined with 'x', 'w', 'a', or '+'") - warn("'U' mode is deprecated", - DeprecationWarning, 2) - True - else: - 'r' in modes - when text and binary: - raise_ValueError("can't have text and binary mode at once") - when int(creating) + int(reading) + int(writing) + int(appending) > 1: - raise_ValueError("can't have read/write/append mode at once") - when not (creating or reading or writing or appending): - raise_ValueError("must have exactly one of read/write/append mode") - when binary: - if (encoding != DefEncoding): - raise_ValueError("binary mode doesn't take an encoding argument") - when binary: - if (errors != DefErrors): - raise_ValueError("binary mode doesn't take an errors argument") - #if binary and newline is not None: raise_ValueError("binary mode doesn't take a newline argument") - when binary: - if buffering == 1: - warn("line buffering (buffering=1) isn't supported in binary " & - "mode, the default buffer size will be used", - RuntimeWarning, 2) - # raw = FileIO( ... ) - let _ = norm_buffering(file, buffering) # line_buffering is not used yet - when not binary: - if buffering == 0: - raise_ValueError("can't have unbuffered text I/O") - - when binary: - var result: RawIOBase - if buffering == 0: - result = FileIO() - else: - result = FileIO() # XXX: currently it's FileIO but is buffered in fact - #[ - when updating: - result = BufferedRandom() - elif creating or writing or appending: - result = BufferedWriter() - elif reading: - result = BufferedReader() - else: - raise_ValueError("unknown mode: $#" % mode.repr) - ]# - else: - var result = initTextIO(encoding, errors, mode, newline) - # TextIOWrapper( ...line_buffering) - - let nmode = - when updating: FileMode.fmReadWrite - elif creating: - when file is PathLike: - if fileExists $file: - raise_FileExistsError("File exists: $#" % file.repr) - FileMode.fmWrite - elif reading: FileMode.fmRead - elif writing: FileMode.fmWrite - elif appending: FileMode.fmAppend - else: doAssert false;FileMode.fmRead # impossible - resMode = nmode - -proc c_setvbuf(f: File, buf: pointer, mode: cint, size: csize_t): cint {. - importc: "setvbuf", header: "".} -let - IOFBF {.importc: "_IOFBF", nodecl.}: cint - IOLBF {.importc: "_IOLBF", nodecl.}: cint - # NOTE: For Win32, the behavior is the same as _IOFBF - Full Buffering - IONBF {.importc: "_IONBF", nodecl.}: cint - -proc raiseOsOrFileNotFoundError[T](file: PathLike[T]) = file.raiseExcWithPath() -proc raiseOsOrFileNotFoundError(file: int) = raiseExcWithPath($file) - -proc initBufAsPy*(nfile: var File, buf: int) = - ## init buffering as Python's - var (bfMode, bfSize) = - if buf == 1: (IOLBF, 0) - elif buf > 0 and buf.uint <= high(uint): - (IOFBF, buf) - elif buf == 0: - (IONBF, 0) - else: doAssert false;(typeof(IOFBF)(0), 0) - discard c_setvbuf(nfile, nil, bfMode, cast[csize_t](bfSize)) - -template openImpl(result: untyped; - file, mode1; - buffering: int, - encoding1, - errors1, - newline1: typed - #,closefd=True, opener -) = - bind genOpenInfo, initTextIO, - FileMode, FileHandle, - open, `file=` - - var buf = buffering - var - nmode: FileMode - const smode = $mode1 - genOpenInfo(result, file, smode, buf, - encoding = encoding1, errors=errors1, newline=newline1, resMode=nmode) - - var nfile: File - sys.audit("open", file, smode) ## XXX: PY-DIFF: 3rd arg shall be flags - when file is int: - let succ = open(nfile, FileHandle file, mode=nmode) - else: - let succ = open(nfile, $file, mode=nmode) - # Nim/Python: - # The file handle associated with the resulting File is not inheritable. - if not succ: - file.raiseOsOrFileNotFoundError() - nfile.initBufAsPy(buf) - - `file=` result, nfile # cannot write as .file= - -template open*( - file: int, mode: static[string|char] = "r", - buffering: int = -1, - encoding: string = DefEncoding, - errors: string = DefErrors, # in Python, the default None/invalid string means "strict" - newline: string|char = DefNewLine, - #closefd=True, opener -): untyped = - bind openImpl - block: - openImpl(res, - file, mode, - buffering, - encoding, - errors, - newline) - res - -template open*[S]( - file: PathLike[S], mode: static[string|char] = "r", - buffering: int = -1, - encoding: string = DefEncoding, - errors: string = DefErrors, # in Python, the default None/invalid string means "strict" - newline: string|char = DefNewLine, - #closefd=True, opener -): untyped = - ## WARN: - ## - ## - `line buffering` is not support for Win32 - ## - `errors` is not just ignored, always 'strict' - - # TODO: impl line_buffering, at least for write - runnableExamples: - const fn = "tempfiletest" - const nonfn = r" \:/ $&* " - doAssertRaises LookupError: - # raise LookupError instead of FileNotFoundError (like Python) - discard open(nonfn, encoding="this is a invalid enc") - doAssertRaises FileNotFoundError: - discard io.open(nonfn) # an invalid filename, never existing - block Write: - var f = open(fn, "w", encoding="utf-8") - let ret = f.write("123\r\n") - when defined(windows): - assert ret == 6 # Universal Newline, written "123\r\r\n" - else: - assert ret == 5 # written "123\r\n" - assert not f.closed - f.close() - assert f.closed - assert readFile(fn) == (when defined(windows):"123\r\r\n" else:"123\r\n") - block Read: - var f = open(fn, 'r') - let uniLineRes = f.read() # Universal Newline, "123\r\n\n" -> "123\n\n" - assert uniLineRes == (when defined(windows):"123\n\n" else:"123\n") - f.close() - bind openImpl - block: - openImpl(res, - file, mode, - buffering, - encoding, - errors, - newline) - res - diff --git a/src/pylib/Lib/itertools.nim b/src/pylib/Lib/itertools.nim deleted file mode 100644 index 6e02e5c12..000000000 --- a/src/pylib/Lib/itertools.nim +++ /dev/null @@ -1,30 +0,0 @@ - -import std/sequtils # toSeq -import ./n_itertools -import ../builtins/list -import ../private/iterGen -import ../collections_abc - -template asgnToSeq[T](sequ; it: Iterable[T]){.dirty.} = - bind toSeq - when compiles(it.toSeq): - sequ = it.toSeq - else: - when compiles(iterable.len): - sequ = newSeqOfCap(iterable.len) - for i in iterable: - sequ.add i - -iterator combinations*[T](iterable: Iterable[T], r: int): PyList[T]{.genIter.} = - ## XXX: yield list instead of tuple - var sequ: seq[T] - asgnToSeq sequ, iterable - for s in n_itertools.combinations(sequ, r): - yield newPyList(s) - -iterator accumulate*[T](iterable: Iterable[T], - binop: BinOp[T] = binOpAdd; inital = mayZeroDefault(T)): T{.genIter.} = - var sequ: seq[T] - asgnToSeq sequ, iterable - n_itertools.accumulate(sequ, binop, inital) - diff --git a/src/pylib/Lib/math.nim b/src/pylib/Lib/math.nim deleted file mode 100644 index bbecae4b0..000000000 --- a/src/pylib/Lib/math.nim +++ /dev/null @@ -1,282 +0,0 @@ -## Lib/math -## -## Wrapper around `Lib/n_math`_, and raises exceptions -## when math error occurs as CPython behaves. -## - -import ../version -from ./collections/abc import Iterable -from ../builtins/list_decl import `@`, list - -import ./n_math -export nan -export inf -export pi -export tau -export e - -from ./math_impl/err import raiseDomainErr, raiseRangeErr -from ./math_impl/errnoUtils import setErrno0, setErrno, isErr0, EDOM, ERANGE -from ./math_impl/vec_op/niter_types import toNimIterator, ClosureIter - -template checkErrno(result, exc): bool = - not isErr0() and math_is_error(result, exc) - -template checkErrnoAndRaise(result) = - var exc: ref Exception - if not isErr0() and math_is_error(result, exc): - raise exc - -template math_1_body(x; fun; can_overflow: bool) = - setErrno0 - result = fun(x) - if isnan(result) and not isnan(x): - raiseDomainErr() # invalid arg - if isinf(result) and isfinite(x): - when can_overflow: - raise newException(OverflowDefect, "math range error") # overflow - else: - raiseDomainErr() # singularity - var exc: ref Exception - if isfinite(result) and result.checkErrno exc: - # this branch unnecessary on most platforms - raise exc - -template FUNC_math_1(funcname; fun; can_overflow: bool){.dirty.} = - ## FUNC1 with math_1_body - func funcname*[F: SomeFloat](x: F): F = - math_1_body(x, can_overflow) - - -template FUNC_math_1a(funcname; fun){.dirty.} = - ##[variant of math_1_body, to be used when the function being wrapped is known to - set errno properly (that is, errno = EDOM for invalid or divide-by-zero, - errno = ERANGE for overflow).]## - func funcname*[F: SomeFloat](x: F): F = - setErrno0 - result = fun(x) - result.checkErrnoAndRaise - -template FUNC_math_2(funcname; fun){.dirty.} = - ## FUNC1 with math_1_body - func funcname*[F: SomeFloat](x, y: F): F = - setErrno0 - result = fun(x, y) - if isnan(result): - if not isnan(x) and not isnan(y): - setErrno EDOM - else: - setErrno0 - elif isinf(result): - if isfinite(x) and isfinite(y): - setErrno ERANGE - else: - setErrno0 - result.checkErrnoAndRaise - -template FUNC_math_1(fun; can_overflow: bool){.dirty.} = - ## wrap n_math's - FUNC_math_1(fun, n_math.fun, can_overflow) - -template FUNC_math_1a(fun){.dirty.} = - ## wrap n_math's - FUNC_math_1a(fun, n_math.fun) - -template FUNC_math_2(fun){.dirty.} = - ## wrap n_math's - FUNC_math_2(fun, n_math.fun) - -template expN(sym) = export n_math.sym - -template genDunder(sym) = - # Nim cannot write dunder (double under) - # so we just export AS-IS - export n_math.sym - -# NOTE: the following is the same with CPython's - -FUNC_math_1 acos, false -FUNC_math_1 acosh, false -FUNC_math_1 asin, false -FUNC_math_1 asinh, false -FUNC_math_1 atan, false -FUNC_math_1 atanh, false - -func cbrt*[F: SomeFloat](x: F): F{.pysince(3,11).} = - runnableExamples: - template chk = - assert cbrt(-1.0) == -1.0 - chk() - static: chk() - math_1_body(x, n_math.cbrt, false) # check for underflow - -genDunder ceil - -FUNC_math_2 atan2 - -FUNC_math_2 copysign - -FUNC_math_1 cos, false -FUNC_math_1 cosh, true - -FUNC_math_1a erf -FUNC_math_1a erfc - -FUNC_math_1 exp, true - -func expm1*[F: SomeFloat](x: F): F{.pysince(3,11).} = - math_1_body(x, expm1, true) - -FUNC_math_1 fabs, false - -genDunder floor - -FUNC_math_1a gamma -FUNC_math_1a lgamma - -FUNC_math_1 log1p, false -FUNC_math_2 remainder - -FUNC_math_1 sin, false -FUNC_math_1 sinh, true -FUNC_math_1 sqrt, false -FUNC_math_1 tan, false -FUNC_math_1 tanh, false - -expN fsum - -func isqrt*[I: SomeInteger](x: I): int = - if x < 0: - raise newException(ValueError, "isqrt() argument must be nonnegative") - n_math.isqrt(cast[Natural](int(x))) - -func factorial*(x: int): int = - if x < 0: - raise newException(ValueError, "factorial() not defined for negative values") - n_math.factorial(cast[Natural](x)) - -genDunder trunc - -expN frexp # XXX: CPython's math_frexp_impl does not check errno - -func ldexp*(x: SomeFloat, i: int): float = - var exc: ref Exception - result = ldexp(x, i, exc) - if exc.isNil: return - raise exc - -expN modf # XXX: CPython's math_modf_impl does not check errno - - -func loghelper[F](arg: SomeNumber, fun: proc (x: F)): F = - when arg is SomeInteger: - if arg <= 0: - raiseDomainErr() - # XXX: CPython said following: - #[/*Here the conversion to double overflowed, but it's possible - to compute the log anyway. Clear the exception and continue. */]# - # but that's for Python's `int`, and is it impossible for C's fixed int to overflow double - let x = float arg - result = fun(x) - else: - math_1_body(arg, fun, false) - - -template logImpl[F](x: F): F = loghelper(x, n_math.log) - -func log*[F: SomeFloat](x: F): F = - logImpl x - -func log*[F: SomeFloat](x, base: F): F = - logImpl(x) / logImpl(base) - - -func log2*[F: SomeFloat](x: F): F = loghelper(x, n_math.log2) -func log10*[F: SomeFloat](x: F): F = loghelper(x, n_math.log10) - -func fma*[F: SomeFloat](x, y, z: F): F{.pysince(3,13).} = - var exc: ref Exception - result = n_math.fma(x, y, z, exc) - if not exc.isNil: - raise exc - -func fmod*[F: SomeFloat](x: F, y: F): F = - result = n_math.fmod(x, y) - # not check `isinf(result)` here - result.checkErrnoAndRaise - - -proc iterToFloatSeq[T](it: Iterable[T]): seq[float] = - for e in it: - result.add: - when T is SomeFloat: e.float - else: e.toFloat - -template gen2pointsGetFloat(sym; pypatch: int; listOp; iterOp; oaOp; niterOp){.dirty.} = - template sym*[T](p, q: list[T]): float {.pysince(3,pypatch).} = - bind listOp - n_math.sym(listOp p, listOp q) - template sym*[T](p, q: (Iterable[T] and not openarray[T])): float {.pysince(3,pypatch).} = - bind iterOp - n_math.sym(iterOp[T](p), iterOp[T](q)) - template sym*[T](p, q: openarray[T]): float {.pysince(3,pypatch).} = - bind oaOp - n_math.sym(oaOp(p), oaOp(q)) - template sym*[T](p, q: ClosureIter[T]): float {.pysince(3,pypatch).} = - bind niterOp - n_math.sym(niterOp(p), niterOp(q)) - -template asisOp[T](x: T): T = x - -gen2pointsGetFloat dist, 8, `@`, iterToFloatSeq, asisOp, iterToFloatSeq - -gen2pointsGetFloat sumprod ,12, `@`, toNimIterator, asisOp, asisOp - - -expN hypot - -func pow*[F: SomeFloat](x, y: F): F = - result = n_math.pow(x, y) - result.checkErrnoAndRaise - -expN degrees -expN radians - -expN isfinite -expN isnan -expN isinf - -expN isclose # n_math.isclose alreadly make it - -expN prod - -template chkValNe(x): Natural = - if x < 0: - raise newException(ValueError, astToStr(x) & - " must be a non-negative integer") - cast[Natural](x) - -func perm*(n: int): int = - let nn = chkValNe n - n_math.factorial nn - -func perm*(n, k: int): int = - let - nn = chkValNe n - nk = chkValNe k - n_math.perm(nn, nk) - -func comb*(n, k: int): int = - let - nn = chkValNe n - nk = chkValNe k - n_math.comb(nn, nk) - -func nextafter*[F: SomeFloat](x, y: F): F{.pysince(3,9).} = n_math.nextafter(x, y) -func nextafter*[F: SomeFloat](x, y: F; steps: int|uint64): F{.pysince(3,12).} = - n_math.nextafter(x, y, steps) -func ulp*[F: SomeFloat](x: F): F{.pysince(3,9).} = n_math.ulp(x) - -expN gcd -expN lcm - diff --git a/src/pylib/Lib/math_impl/cbrt.nim b/src/pylib/Lib/math_impl/cbrt.nim deleted file mode 100644 index 2d97130f0..000000000 --- a/src/pylib/Lib/math_impl/cbrt.nim +++ /dev/null @@ -1,27 +0,0 @@ - -from ./platformUtils import CLike -import ./comptime/cbrt as cbrtLib - -when CLike: - {.push header: "".} - proc c_cbrt(x: cdouble): cdouble{.importc: "cbrt".} - proc c_cbrt(x: cfloat): cfloat{.importc: "cbrtf".} - {.pop.} -elif defined(js): - proc c_cbrt(x: cdouble): cdouble{.importjs: "Math.cbrt(#)".} - proc c_cbrt(x: cfloat): cfloat = cfloat(c_cbrt(cdouble(x))) - -#[ -proc round_cbrt[F: SomeFloat](x: F): F{.compileTime.} = - result = x - var sign = 1.0 - if x < 0.0: - sign = -1.0 - result = -result - result = sign * pow(x, 1/3) -]# - -func cbrt*[F: SomeFloat](x: F): F = - when nimvm: cbrtLib.cbrt(x) - else: c_cbrt(x) - diff --git a/src/pylib/Lib/math_impl/comptime/cbrt.nim b/src/pylib/Lib/math_impl/comptime/cbrt.nim deleted file mode 100644 index 9397183fc..000000000 --- a/src/pylib/Lib/math_impl/comptime/cbrt.nim +++ /dev/null @@ -1,113 +0,0 @@ -## from https://www.netlib.org/cephes/ -## cmath.tgz cbrt.c -## And -## single.tgz cbrtf.c -## -## Cube root -## -## DESCRIPTION: -## -## Returns the cube root of the argument, which may be negative. -## -## Range reduction involves determining the power of 2 of -## the argument. A polynomial of degree 2 applied to the -## mantissa, and multiplication by the cube root of 1, 2, or 4 -## approximates the root to within about 0.1%. Then Newton's -## iteration is used three times to converge to an accurate -## result. -## -## -## -## ACCURACY: -## -## Relative error: -## arithmetic domain # trials peak rms -## DEC -10,10 200000 1.8e-17 6.2e-18 -## IEEE 0,1e308 30000 1.5e-16 5.0e-17 -## -## -## cbrt.c -## -## Cephes Math Library Release 2.8: June, 2000 -## Copyright 1984, 1991, 2000 by Stephen L. Moshier -## -## cbrt.nim -## Copyright litlighilit 2024 - -const CBRT2 = 1.2599210498948731647672 -const CBRT4 = 1.5874010519681994747517 -const CBRT2I = 0.79370052598409973737585 -const CBRT4I = 0.62996052494743658238361 - -from std/math import classify, FloatClass - -# XXX: std/math.frexp cannot use in VM - -from ../frexp import n_frexp -from ../ldexp import n_ldexp - -func cbrt*[F: SomeFloat](x: F): F = - let fc = classify x - if fc != fcNormal and fc != fcSubNormal: - return x - var - e: int - sign: int - result = x - if x >= 0: - sign = 1 - else: - sign = -1 - result = -x - let z = result - ## extract power of 2, leaving - ## mantissa between 0.5 and 1 - ## - - result = n_frexp(result, e) - ## Approximate cube root of number between .5 and 1, - ## peak relative error = 9.2e-6 - ## - - result = (((-(1.3466110473359520655053e-1 * result) + 5.4664601366395524503440e-1) * result - - 9.5438224771509446525043e-1) * result + 1.1399983354717293273738e0) * result + - 4.0238979564544752126924e-1 - ## exponent divided by 3 - when F is float64: - const - c2 = CBRT2 - c4 = CBRT4 - else: - const - c2 = CBRT2I - c4 = CBRT4I - - var rem: int - if e >= 0: - rem = e - e = e div 3 - dec(rem, 3 * e) - if rem == 1: - result *= CBRT2 - elif rem == 2: - result *= CBRT4 - else: # argument less than 1 - e = -e - rem = e - e = e div 3 - rem -= 3 * e - if rem == 1: - result *= c2 - elif rem == 2: - result *= c4 - e = -e - ## multiply by power of 2 - - result = n_ldexp(result, e) - ## Newton iteration - - result -= (result - (z / (result * result))) * 0.33333333333333333333 - when F is float64: - result -= (result - (z / (result * result))) * 0.33333333333333333333 - if sign < 0: - result = -result diff --git a/src/pylib/Lib/math_impl/comptime/common.nim b/src/pylib/Lib/math_impl/comptime/common.nim deleted file mode 100644 index 8db435d74..000000000 --- a/src/pylib/Lib/math_impl/comptime/common.nim +++ /dev/null @@ -1,22 +0,0 @@ -import ../inWordUtils/[fromWords, toWords] -import ../constsUtils -import ../polevl - -export fromWords, toWords, - constsUtils, - polExpd0 - -const - ln2_hi* = 6.93147180369123816490e-01 ## 3fe62e42 fee00000 - ln2_lo* = 1.90821492927058770002e-10 ## 3dea39ef 35793c76 - -template getLowWord*(x: float32): uint16 = cast[uint16](cast[uint32](x)) -template getLowWord*(x: float64): uint32 = cast[uint32](cast[uint64](x)) - - -template setHighWord*(x: float; hi) = - x = fromWords(hi, x.getLowWord) - -template GET_FLOAT_WORD*(x: float32): uint32 = cast[uint32](x) -template GET_FLOAT_WORD*(word: var uint32, x: float32) = word = GET_FLOAT_WORD(x) - diff --git a/src/pylib/Lib/math_impl/comptime/expm1.nim b/src/pylib/Lib/math_impl/comptime/expm1.nim deleted file mode 100644 index 8fced813d..000000000 --- a/src/pylib/Lib/math_impl/comptime/expm1.nim +++ /dev/null @@ -1,314 +0,0 @@ -##[ - compiletime/expm1.nim 10/19/2024: - - translated from and combine s_expm1.c and s_expm1f.c - - Also, some formula in the following doc used to have some tabs for indent, - I replaced them with spaces. - - --- - - @(#)s_expm1.c 1.5 04/04/22 - And s_expm1f.c - - ==================================================== - Copyright (C) 2004 by Sun Microsystems, Inc. All rights reserved. - Copyright (C) 2024 by litlighilit. All rights reserved. - - Permission to use, copy, modify, and distribute this - software is freely granted, provided that this notice - is preserved. - ==================================================== - expm1(x) - Returns exp(x)-1, the exponential of x minus 1. - -``` - - Method - 1. Argument reduction: - Given x, find r and integer k such that - - x = k*ln2 + r, |r| <= 0.5*ln2 ~ 0.34658 - - Here a correction term c will be computed to compensate - the error in r when rounded to a floating-point number. - - 2. Approximating expm1(r) by a special rational function on - the interval [0,0.34658]: - Since - r*(exp(r)+1)/(exp(r)-1) = 2+ r^2/6 - r^4/360 + ... - we define R1(r*r) by - r*(exp(r)+1)/(exp(r)-1) = 2+ r^2/6 * R1(r*r) - That is, - R1(r**2) = 6/r *((exp(r)+1)/(exp(r)-1) - 2/r) - = 6/r * ( 1 + 2.0*(1/(exp(r)-1) - 1/r)) - = 1 - r^2/60 + r^4/2520 - r^6/100800 + ... - We use a special Remes algorithm on [0,0.347] to generate - a polynomial of degree 5 in r*r to approximate R1. The - maximum error of this polynomial approximation is bounded - by 2**-61. In other words, - R1(z) ~ 1.0 + Q1*z + Q2*z**2 + Q3*z**3 + Q4*z**4 + Q5*z**5 - where Q1 = -1.6666666666666567384E-2, - Q2 = 3.9682539681370365873E-4, - Q3 = -9.9206344733435987357E-6, - Q4 = 2.5051361420808517002E-7, - Q5 = -6.2843505682382617102E-9; - (where z=r*r, and the values of Q1 to Q5 are listed below) - with error bounded by - | 5 | -61 - | 1.0+Q1*z+...+Q5*z - R1(z) | <= 2 - | | - - expm1(r) = exp(r)-1 is then computed by the following - specific way which minimize the accumulation rounding error: - 2 3 - r r [ 3 - (R1 + R1*r/2) ] - expm1(r) = r + --- + --- * [--------------------] - 2 2 [ 6 - r*(3 - R1*r/2) ] - - To compensate the error in the argument reduction, we use - expm1(r+c) = expm1(r) + c + expm1(r)*c - ~ expm1(r) + c + r*c - Thus c+r*c will be added in as the correction terms for - expm1(r+c). Now rearrange the term to avoid optimization - screw up: - ( 2 2 ) - ({ ( r [ R1 - (3 - R1*r/2) ] ) } r ) - expm1(r+c)~r - ({r*(--- * [--------------------]-c)-c} - --- ) - ({ ( 2 [ 6 - r*(3 - R1*r/2) ] ) } 2 ) - ( ) - - = r - E - 3. Scale back to obtain expm1(x): - From step 1, we have - expm1(x) = either 2^k*[expm1(r)+1] - 1 - = or 2^k*[expm1(r) + (1-2^-k)] - 4. Implementation notes: - (A). To save one multiplication, we scale the coefficient Qi - to Qi*2^i, and replace z by (x^2)/2. - (B). To achieve maximum accuracy, we compute expm1(x) by - (i) if x < -56*ln2, return -1.0, (raise inexact if x!=inf) - (ii) if k=0, return r-E - (iii) if k=-1, return 0.5*(r-E)-0.5 - (iv) if k=1 if r < -0.25, return 2*((r+0.5)- E) - else return 1.0+2.0*(r-E); - (v) if (k<-2||k>56) return 2^k(1-(E-r)) - 1 (or exp(x)-1) - (vi) if k <= 20, return 2^k((1-2^-k)-(E-r)), else - (vii) return 2^k(1-((E+2^-k)-r)) - - Special cases: - expm1(INF) is INF, expm1(NaN) is NaN; - expm1(-INF) is -1, and - for finite argument, only expm1(0)=0 is exact. - - Accuracy: - according to an error analysis, the error is always less than - 1 ulp (unit in the last place). - - Misc. info. - For IEEE double - if x > 7.09782712893383973096e+02 then expm1(x) overflow - -``` - - Constants: - The hexadecimal values are the intended ones for the following - constants. The decimal values may be used, provided that the - compiler will convert from decimal to binary accurately enough - to produce the hexadecimal values shown. -]## - -import ./common - -#[unused: -template getHighWord(x: float): uint32 = cast[uint32](cast[uint64](x) shr 32) -template incHighWord(x: float; inc_hi) = - let (hi, lo) = x.toWords - x = fromWords(hi + inc_hi, lo) -]# - -# NOTE: for nimvm, two step's cast is necessary - - -genWithBracket hugeF, 1.0e+300, 1.0e+30 -genWithBracket tinyF, 1.0e-300, 1.0e-30 -genWithBracket o_threshold, - 7.09782712893383973096e+02, ## 0x40862E42, 0xFEFA39EF - 8.8721679688e+01 ## 0x42b17180 - -const - one = 1.0 - invln2 = 1.44269504088896338700e+00 ## 0x3ff71547, 0x652b82fe - -template SET_FLOAT_WORD(u: uint32): float32 = cast[float32](u) -template SET_FLOAT_WORD(x: var float32, u: uint32) = x = SET_FLOAT_WORD(u) - -proc expm1*[F: SomeFloat](x: F): F = - const - huge = hugeF[F] - tiny = tinyF[F] - const isFloat32 = F is float32 - template f2[T](f64, f32: T): T = - when isFloat32: f32 else: f64 - template f2Do(f64; f32) = - when isFloat32: f32 else: f64 - when isFloat32: - var hx: uint32 - GET_FLOAT_WORD(hx, x) - const hxLimits = [ # |x| >= - 0x4195b844u32, # 56*ln2 - 0x7f800000, # 709.78 - 0x7f800000, - ] - const xLimitsWhenReduce = [ # |x| - 0x3eb17218u32, # > 0.5 ln2 - 0x3F851592, # < 1.5 ln2 - ] - # must be template to delay evalution - template checkNaNByHx: bool = hx > 0x7f800000 - template checkInfByHxAfterNaN: bool = hx > 0x7f800000 - else: - var (hx, lx) = x.toWords() - const hxLimits = [ # |x|>= - 0x4043687Au32, # 27*ln2 = 18.714... - 0x40862E42, # 88.721... - 0x7ff00000, - ] - const xLimitsWhenReduce = [ # |x| - 0x3fd62e42u32, # > 0.5 ln2 - 0x3FF0A2B2 # < 1.5 ln2 - ] - # must be template to delay evalution - template checkNaNByHx: bool = ((hx and 0xfffff) or lx) != 0 - template checkInfByHxAfterNaN: bool = true - - let xsb = hx and 0x80000000'u32 # sign bit of x - let xsb0 = xsb == 0 - result = if xsb0: x else: -x # result = |x| - hx = hx and 0x7fffffff'u32 # high word of |x|, discard signbit - - ## filter out huge and non-finite argument - if hx >= hxLimits[0]: - if hx >= hxLimits[1]: - if hx >= hxLimits[2]: - if checkNaNByHx: # NaN - return x + x - if checkInfByHxAfterNaN: # inf - return if xsb0: x else: -1.0 - # exp(+-inf)={inf,-1} - if x > o_threshold[F]: - return huge * huge # overflow - if not xsb0: - ## x < -56*ln2.float64 | -27*ln2.float32, return -1.0 with inexact - if x + tiny < 0.0: # raise inexact - return tiny - one # return -1 - - var - c: F - t: F - k: int32 - template asUnsigned(x: int32): uint32 = cast[uint32](x) - # argument reduction - var x = x # shallow x to make it mutable - var hi, lo: F - if hx > xLimitsWhenReduce[0]: - if hx < xLimitsWhenReduce[1]: - if xsb0: - hi = x - ln2_hi - lo = ln2_lo - k = 1 - else: - hi = x + ln2_hi - lo = -ln2_lo - k = -1 - else: - k = typeof(k) invln2 * x + (if xsb0: 0.5 else: -0.5) - t = typeof(t) k - hi = x - t * ln2_hi - ## t*ln2_hi is exact here - lo = t * ln2_lo - x = hi - lo - c = (hi - x) - lo - elif hx < f2(0x3c900000, 0x33000000): - ## when |x|<2**-54|2**-25, return x - t = huge + x - ## return x with inexact flags when x!=0 - return x - (t - (huge + x)) - else: - k = 0 - ## x is now in primary range - let - hfx = 0.5 * x - hxs = x * hfx - r1 = f2( # scaled coefficients related to expm1 - polExpd0(hxs, [ - one - ,-3.33333333333331316428e-02 # BFA11111 111110F4 - ,1.58730158725481460165e-03 # 3F5A01A0 19FE5585 - ,-7.93650757867487942473e-05 # BF14CE19 9EAADBB7 - ,4.00821782732936239552e-06 # 3ED0CFCA 86E65239 - ,-2.01099218183624371326e-07 # BE8AFDB7 6E09C32D - ]), - polExpd0(hxs, [ - one.F - ,-3.3333212137e-2 # -0x888868.0p-28 - ,1.5807170421e-3 # 0xcf3010.0p-33 - ]#[Domain [-0.34568, 0.34568], range ~[-6.694e-10, 6.696e-10]: - |6 / x * (1 + 2 * (1 / (exp(x) - 1) - 1 / x)) - q(x)| < 2**-30.04 - Scaled coefficients: Qn_here = 2**n * Qn_for_q (see s_expm1.c)]# - ) - ) - - t = 3.0 - r1 * hfx - var e = hxs * ((r1 - t) / (6.0 - x * t)) - const kShift = f2(20, 23) - if k == 0: - return x - (x * e - hxs) - else: - let twopk = f2( - fromWords( 0x3ff00000 + (k.asUnsigned shl kShift), 0), - SET_FLOAT_WORD(0x3f800000 + (k.asUnsigned shl kShift)) - ) - e = (x * (e - c) - c) - e -= hxs - if k == -1: - return 0.5 * (x - e) - 0.5 - if k == 1: - if x < -0.25: - return -(2.0 * (e - (x + 0.5))) - else: - return one + 2.0 * (x - e) - if k <= -2 or k > 56: - # suffice to return exp(x)-1 - result = one - (e - x) - # For float64, the following is the same as: - # incHighWord(result, UInt(k shl 20)) # add k to result's exponent - if k == f2(1024, 128): - template mul(f: F) = - result = result * 2.0 * f - f2Do( - mul(0x7FE0000000000000'f64), # 0x1p+1023 - mul(0x7F000000'f32) # 0x1p+127 - ) - else: - result *= twopk - return result - one - t = one - if k < kShift: - f2Do( - setHighWord(t, 0x3ff00000'u32 - (0x200000'u32 shr k)), - SET_FLOAT_WORD(t, 0x3f800000'u32 - (0x1000000'u32 shr k)) - ) - ## t=1-2^-k - - result = t - (e - x) - else: - f2Do( - setHighWord(t, (0x3ff'u32 - k.asUnsigned) shl kShift), - SET_FLOAT_WORD(t, (0x7f'u32 - k.asUnsigned) shl kShift) - ) - ## 2^-k - result = x - (e + t) - result += one - result *= twopk - # For float64 above is the same as: - # incHighWord(result, UInt(k shl 20)) # add k to result's exponent - diff --git a/src/pylib/Lib/math_impl/comptime/log1p.nim b/src/pylib/Lib/math_impl/comptime/log1p.nim deleted file mode 100644 index fda24564c..000000000 --- a/src/pylib/Lib/math_impl/comptime/log1p.nim +++ /dev/null @@ -1,206 +0,0 @@ -##[ -compiletime/log1p.nim 2024/10/19: - - - translated from and combine - [s_log1p.c](https://netlib.org/fdlibm/s_log1p.c) and - [s_log1pf.c](https://cygwin.com/cgit/newlib-cygwin/plain/newlib/libm/common/sf_log1p.c) - -]## - -##[ - @(#)s_log1p.c 1.3 95/01/18 - Along with: - s_log1pf.c -- float version of s_log1p.c. - Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com. - - - ==================================================== - Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - Copyright (C) 2024 by litlighilit. All rights reserved. - - Developed at SunSoft, a Sun Microsystems, Inc. business. - Permission to use, copy, modify, and distribute this - software is freely granted, provided that this notice - is preserved. - ==================================================== - - double log1p(double x) - - Method : - 1. Argument Reduction: find k and f such that - 1+x = 2^k * (1+f), - where sqrt(2)/2 < 1+f < sqrt(2) . - - Note. If k=0, then f=x is exact. However, if k!=0, then f - may not be representable exactly. In that case, a correction - term is need. Let u=1+x rounded. Let c = (1+x)-u, then - log(1+x) - log(u) ~ c/u. Thus, we proceed to compute log(u), - and add back the correction term c/u. - (Note: when x > 2**53, one can simply return log(x)) - - 2. Approximation of log1p(f). - Let s = f/(2+f) ; based on log(1+f) = log(1+s) - log(1-s) - = 2s + 2/3 s**3 + 2/5 s**5 + ....., - = 2s + s*R - We use a special Reme algorithm on [0,0.1716] to generate - a polynomial of degree 14 to approximate R The maximum error - of this polynomial approximation is bounded by 2**-58.45. In - other words, - 2 4 6 8 10 12 14 - R(z) ~ Lp1*s +Lp2*s +Lp3*s +Lp4*s +Lp5*s +Lp6*s +Lp7*s - (the values of Lp1 to Lp7 are listed in the program) - and - | 2 14 | -58.45 - | Lp1*s +...+Lp7*s - R(z) | <= 2 - | | - Note that 2s = f - s*f = f - hfsq + s*hfsq, where hfsq = f*f/2. - In order to guarantee error in log below 1ulp, we compute log - by - log1p(f) = f - (hfsq - s*(hfsq+R)). - - 3. Finally, log1p(x) = k*ln2 + log1p(f). - = k*ln2_hi+(f-(hfsq-(s*(hfsq+R)+k*ln2_lo))) - Here ln2 is split into two floating point number: - ln2_hi + ln2_lo, - where n*ln2_hi is always exact for |n| < 2000. - - Special cases: - log1p(x) is NaN with signal if x < -1 (including -INF) ; - log1p(+INF) is +INF; log1p(-1) is -INF with signal; - log1p(NaN) is that NaN with no signal. - - Accuracy: - according to an error analysis, the error is always less than - 1 ulp (unit in the last place). - - Constants: - The hexadecimal values are the intended ones for the following - constants. The decimal values may be used, provided that the - compiler will convert from decimal to binary accurately enough - to produce the hexadecimal values shown. - - - Note: Assuming log() return accurate answer, the following - algorithm can be used to compute log1p(x) to within a few ULP: - - u = 1+x; - if(u==1.0) return x ; else - return log(u)*(x/(u-1.0)); - - See HP-15C Advanced Functions Handbook, p.193. -]## - -import ./common - -const - zero = 0.0 - -template getHighWord(x: float): uint32 = cast[uint32](cast[uint64](x) shr 32) - -proc log1p*[F: SomeFloat](x: F): F = - var hu: uint32 - const isFloat32 = F is float32 - template f2[T](f64, f32: T): T = - when isFloat32: f32 else: f64 - - when isFloat32: - const twoX = 3.355443200e+07 ## two25 - else: - const twoX = 1.80143985094819840000e+16 ## two54 43500000 00000000 - let hx = f2(getHighWord(x), GET_FLOAT_WORD(x)) - ## high word of x - let ax = hx and 0x7fffffff - var - k: typeof(hu) = 1 - f: F - if hx < f2(0x3FDA827A, 0x3ed413d0): # 1+x < sqrt(2)+ - ## x < 0.41422 - if ax >= f2(0x3ff00000, 0x3f800000): # x <= -1.0 - if x == -1.0: - return -(twoX / zero) ## log1p(-1) = +inf - else: - return (x - x) / (x - x) ## log1p(x<-1)=NaN - if ax < f2(0x3e200000, 0x38000000): ## |x| < 2**-{29,15} - if twoX + x > zero and ax < f2(0x3c900000, 0x33800000): ## |x| < 2**-{54,24} - return x - else: - return x - x * x * 0.5 - if hx > 0 or hx <= f2(0xbfd2bec3'u32, 0xbe95f619'u32): - k = 0 - f = x - hu = 1 - if hx >= f2(0x7ff00000, 0x7f800000): - return x + x - var c: F - if k != 0: - var u: F - if hx < f2(0x43400000, 0x5a000000): - u = 1.0 + x - hu = getHighWord(u) - ## high word of u - k = f2( - (hu shr 20) - 1023, - (hu shr 23) - 127 - ) - ## correction term - c = if (k > 0): 1.0 - (u - x) else: x - (u - 1.0) - c = c / u - else: - u = x - hu = getHighWord(u) - ## high word of u - k = f2( - (hu shr 20) - 1023, - (hu shr 23) - 127 - ) - c = 0 - hu = hu and f2(0x000fffff, 0x3504f4) - if hu < f2(0x6a09e, 0x3504f4): # u < sqrt(2) - setHighWord(u, hu or f2(0x3ff00000,0x3f800000)) # normalize u - else: - k += 1 - setHighWord(u, hu or f2(0x3fe00000, 0x3f000000)) # normalize u/2 - hu = (0x00100000 - hu) shr 2 - f = u - 1.0 - var hfsq = 0.5 * f * f - if hu == 0: - ## |f| < 2**-20 - if f == zero: - if k == 0: - return zero - else: - c += k.F * ln2_lo - return k.F * ln2_hi + c - let R = hfsq * (1.0 - 0.66666666666666666 * f) - if k == 0: - return f - R - else: - return k.F * ln2_hi - ((R - (k.F * ln2_lo + c)) - f) - let - s = f / (2.0 + f) - z = s * s - let R = polExpd0(z, [0 -, 6.666666666666735130e-01 # 3FE55555 55555593 -, 3.999999999940941908e-01 # 3FD99999 9997FA04 -, 2.857142874366239149e-01 # 3FD24924 94229359 -, 2.222219843214978396e-01 # 3FCC71C5 1D8E78AF -, 1.818357216161805012e-01 # 3FC74664 96CB03DE -, 1.531383769920937332e-01 # 3FC39A09 D078C69F -, 1.479819860511658591e-01 # 3FC2F112 DF3E5244 - ]) - if k == 0: - return f - (hfsq - s * (hfsq + R)) - else: - return k.F * ln2_hi - ((hfsq - (s * (hfsq + R) + (k.F * ln2_lo + c))) - f) - - -when isMainModule: - from std/math import ln - from std/sugar import dump - static: - for i in 1..100: - let x = float i - if log1p(x) == ln(x+1): continue - dump x - dump ln(1+x) - dump log1p(x) diff --git a/src/pylib/Lib/math_impl/constsUtils.nim b/src/pylib/Lib/math_impl/constsUtils.nim deleted file mode 100644 index 9861fb0f1..000000000 --- a/src/pylib/Lib/math_impl/constsUtils.nim +++ /dev/null @@ -1,17 +0,0 @@ - - -template genBody(F, v32, v64): untyped = - when F is float64: v64 - else: v32 - -template genWithArg*(sym, v32, v64){.dirty.} = - bind genBody - template sym*[F](_: typedesc[F]): F = genBody(F, v32, v64) - -template genWithBracket*(sym, v32, v64, Ret){.dirty.} = - bind genBody - template sym*[F]: Ret = genBody(F, v32, v64) - -template genWithBracket*(sym, v32, v64) = - bind genWithBracket - genWithBracket(sym, v32, v64, untyped) diff --git a/src/pylib/Lib/math_impl/err.nim b/src/pylib/Lib/math_impl/err.nim deleted file mode 100644 index 939613ad6..000000000 --- a/src/pylib/Lib/math_impl/err.nim +++ /dev/null @@ -1,42 +0,0 @@ - - -type GammaError* = enum - geOk - geDom = "x in {0, -1, -2, ...}" ##[ when . -Infinity discontinuity, -which shall produce `Complex Infinity` in SymPy and -means domain error]## - geOverFlow = "x > MAX_GAMMA_X, result overflow as inf" - geUnderFlow = "x < MIN_GAMMA_X, result underflow as `-0.0` or `0.0`." - geZeroCantDetSign = "`x < -maxSafeInteger`(exclude -inf), " & - "can't detect result's sign" ## `x` losing unit digit, often not regard as an error - geGotNegInf = "x == -inf" ## this is made as a enumerate item as different languages' - ## implementation has different treatment towards -inf - -const - DEMsg = "math domain error" - REMsg = "math range error" - -template raiseDomainErr* = - bind DEMsg - raise newException(ValueError, DEMsg) - -template raiseDomainErr*(details: string) = - bind DEMsg - raise newException(ValueError, DEMsg & ": " & details) - -template raiseRangeErr* = - bind REMsg - raise newException(OverflowDefect, REMsg) - -template raiseRangeErr*(details: string) = - bind REMsg - raise newException(OverflowDefect, REMsg & ": " & details) - -func mapRaiseGammaErr*(err: GammaError) = - case err - of geOverFlow, geUnderFlow: - raiseRangeErr $err - of geDom, geGotNegInf: - raiseDomainErr $err - of geOk, geZeroCantDetSign: discard diff --git a/src/pylib/Lib/math_impl/errnoUtils.nim b/src/pylib/Lib/math_impl/errnoUtils.nim deleted file mode 100644 index afd4f7482..000000000 --- a/src/pylib/Lib/math_impl/errnoUtils.nim +++ /dev/null @@ -1,5 +0,0 @@ - -import ../errno_impl/errnoUtils -export errnoUtils -from ../errno_impl/errnoConsts import EDOM, ERANGE -export EDOM, ERANGE diff --git a/src/pylib/Lib/math_impl/expm1_log1p.nim b/src/pylib/Lib/math_impl/expm1_log1p.nim deleted file mode 100644 index 02118e8bf..000000000 --- a/src/pylib/Lib/math_impl/expm1_log1p.nim +++ /dev/null @@ -1,78 +0,0 @@ -##[ - -.. hint:: - result calculated at compile-time may a little differ those in runtime-time, - e.g. For log1p: for i in 1..100, x = float(i), the following are results that differs each other: - -x = 2.0 -======== -c_log1p(x) = 1.09861228866811 -ct_log1p.log1p(x) = 1.09861228866811 -relative_tol = -2.021137094636221e-16 - -x = 13.0 -======== -c_log1p(x) = 2.639057329615258 -ct_log1p.log1p(x) = 2.639057329615259 -relative_tol = 1.682756963505621e-16 - -x = 47.0 -======== -c_log1p(x) = 3.871201010907891 -ct_log1p.log1p(x) = 3.871201010907891 -relative_tol = -1.147161329516994e-16 - -x = 73.0 -======== -c_log1p(x) = 4.30406509320417 -ct_log1p.log1p(x) = 4.304065093204169 -relative_tol = -2.063580360581673e-16 - - -]## -from ./platformUtils import impJsOrC, clikeOr -import ./comptime/expm1 as ct_expm1 -import ./comptime/log1p as ct_log1p - -impJsOrC log1p, log1pf, x_native - -func c_log1p[F](x: F): F{.inline.} = - #[ from CPython/Modules/_math.h _Py_log1p: - /*Some platforms (e.g. MacOS X 10.8, see gh-59682) supply a log1p function -but don't respect the sign of zero: log1p(-0.0) gives 0.0 instead of -the correct result of -0.0. - -To save fiddling with configure tests and platform checks, we handle the -special case of zero input directly on all platforms.*/]# - if unlikely(x == 0.0): x # respect its sign - else: log1p(x_native=x) - -func log1p*[F: SomeFloat](x: F): F = - clikeOr(c_log1p(x), ct_log1p.log1p) - - -impJsOrC expm1, expm1f, native_x - -func expm1*[F: SomeFloat](x: F): F = - clikeOr( - expm1(native_x=x), - ct_expm1.expm1(x) - ) - -when isMainModule: - from std/sugar import dump - block: - for i in 1..100: - let x = float i - let - dest = c_log1p(x) - res = ct_log1p.log1p(x) - if dest == res: continue - - dump x - echo "========" - dump c_log1p(x) - dump ct_log1p.log1p(x) - let relative_tol = (res - dest) / dest - dump relative_tol - echo "" diff --git a/src/pylib/Lib/math_impl/frexp.nim b/src/pylib/Lib/math_impl/frexp.nim deleted file mode 100644 index 7e36abbe5..000000000 --- a/src/pylib/Lib/math_impl/frexp.nim +++ /dev/null @@ -1,26 +0,0 @@ - -from ./platformUtils import clikeOr -from ./isX import isnan, isinf -import ./patch/ldexp_frexp/frexp as pure_frexp -import std/math as std_math # frexp - -func n_frexp*[F: SomeFloat](x: F): (F, int) = pure_frexp.frexp(x) -func n_frexp*[F: SomeFloat](x: F, e: var int): F = (result, e) = n_frexp(x) - -func frexpImpl[F](x: F): (F, int){.inline.} = - #[ deal with special cases directly, to sidestep platform - differences ]# - if isnan(x) or isinf(x) or x == 0: - return (x, 0) - result = std_math.frexp(x) - -func frexp*[F: SomeFloat](x: F): (F, int) = - clikeOr( - frexpImpl(x), - n_frexp(x) - ) - -func frexp*[F: SomeFloat](x: F; e: var int): F = - (result, e) = frexp(x) - - diff --git a/src/pylib/Lib/math_impl/gammaXRange.nim b/src/pylib/Lib/math_impl/gammaXRange.nim deleted file mode 100644 index 2efc4e109..000000000 --- a/src/pylib/Lib/math_impl/gammaXRange.nim +++ /dev/null @@ -1,50 +0,0 @@ - -##[ - -.. hint:: CPython's uses MAX_GAMMA_X = 200.0 and MIN_GAMMA_X = -200.0, - which differs the result above, but that's fine, as that's just a short-cut, - there's still further check after that. - See `pylib#38 comment`_ for details. - -Thus in fact, these constants are no need to be very accurate, -just to ensure they're greater than the actual value is enough. - -But as such a short-cur is introduced, I think it better to make it accurate. - -The values are calcuated from tools/math/gamma_x_range.py - -## MAX_GAMMA_X -35.040096282958984'f32 -0b01000010_00001100_00101001_00001111'f32 - -## MIN_GAMMA_X --38.601410000000016'f32 -0b11000010_00011010_01100111_11011000'f32 - -## MAX_GAMMA_X -171.6243769563027'f64 -0b01000000_01100101_01110011_11111010_11100101_01100001_11110110_01000111'f64 - -## MIN_GAMMA_X --177.7807064574756'f64 -0b11000000_01100110_00111000_11111011_10001100_00011011_11010100_01000111'f64 - -## others - -I found stdlib-js/gamma uses following values: -171.61447887182298 --170.5674972726612 -But what I tested using SymPy was different. -If SymPy is right and my method is so, -then the old values are uncorrect and shall not be used, - as the old checking range for zero/inf result is bigger. - (it doesn't matter if that was smaller) -So I change to use current values. - -]## - -from ./constsUtils import genWithArg - -genWithArg MAX_GAMMA_X, 35.04009704589844'f32, 171.6243769563027 - -genWithArg MIN_GAMMA_X, -38.601410000000016'f32, -177.7807064574756 diff --git a/src/pylib/Lib/math_impl/inWordUtils/assertIsLittleEndian.nim b/src/pylib/Lib/math_impl/inWordUtils/assertIsLittleEndian.nim deleted file mode 100644 index 53d8df0e2..000000000 --- a/src/pylib/Lib/math_impl/inWordUtils/assertIsLittleEndian.nim +++ /dev/null @@ -1,34 +0,0 @@ - -const compileLittleEndian* = cpuEndian == littleEndian - -when defined(js): - template wrapVM(body): bool = - when nimvm: compileLittleEndian - else: body - -when not defined(js): - func isLittleEndian*: bool{.compileTime.} = compileLittleEndian - -elif defined(nodejs): - when defined(es6): - let jsLittleEndianExpr{.importjs: "(await import('node:os')).endianness() == 'LE'".}: bool - let jsLittleEndian = jsLittleEndianExpr # force no inline in case `await` appears in function - func isLittleEndian*: bool = - wrapVM: - {.noSideEffect.}: - jsLittleEndian - else: - proc os_endianness(): cstring{.importjs: "require('node:os').endianness()".} - func isLittleEndian*: bool = - wrapVM os_endianness() == "LE" -else: - import ./jsTypedArray - func isLittleEndian*: bool = - wrapVM: - # 4660 => 0x1234 => 0x12 0x34 => '00010010 00110100' => (0x12,0x34) == (18,52) - var uint16view = newUint16Array(1) - uint16view[0] = 0x1234 - var uint8view = newUint8Array(uint16view.buffer) - # If little endian, the least significant byte will be first... - uint8view[0] == 0x34 - diff --git a/src/pylib/Lib/math_impl/inWordUtils/consts.nim b/src/pylib/Lib/math_impl/inWordUtils/consts.nim deleted file mode 100644 index e405fe936..000000000 --- a/src/pylib/Lib/math_impl/inWordUtils/consts.nim +++ /dev/null @@ -1,30 +0,0 @@ - - -import ../constsUtils - -genWithArg BIAS, 127, 1023 ## 2^{k-1} - 1, here, k = 8, 11 -genWithArg MAX_SUBNORMAL_EXPONENT, -127, -1023 ## 0 - BIAS -genWithArg MIN_SUBNORMAL_EXPONENT, -149, -1074 ## 1-BIAS-N_frac = -(BIAS+(52-1)) = -(1023+51) = -1074 -genWithArg MAX_EXPONENT, 127, 1023 -## maxExponent F - 1 = (MAX - 1) - BIAS -## = 254 - BIAS = 127 or 2046 - BIAS = 1023 - - -genWithBracket CLEAR_EXP_MASK, 32895, 2148532223 -## 0b1_00000000_1111111 => 32895 -## 0b1_00000000000_11111111111111111111 => 2148532223 - - -genWithBracket SET_EXP_MASK, 16256, 1071644672 -## mask whose exponent is equal to 126, 1022 a.k.a. (BIAS-1): -## 0b0_01111110_0000000 => 16256 -## 0b0_01111111110_00000000000000000000 => 1071644672 - -genWithBracket EXP_MASK, 0x7f80, 0x7ff00000 -## HIGH_WORD_EXPONENT_MASK: -## 0b0_11111111_0000000 -## 0b0_11111111111_00000000000000000000 - -genWithBracket HighWordFracBits, 7, 20 -genWithBracket MantissaDigits, 23, 52 -## mantissaDigits F - 1 diff --git a/src/pylib/Lib/math_impl/inWordUtils/float_view.nim b/src/pylib/Lib/math_impl/inWordUtils/float_view.nim deleted file mode 100644 index b2b6b9025..000000000 --- a/src/pylib/Lib/math_impl/inWordUtils/float_view.nim +++ /dev/null @@ -1,48 +0,0 @@ -## for JS and C-like backends -## -## Not for nimvm, see {to,from}Words for impl for nimvm backend - -when defined(js): - import ./jsTypedArray - export jsTypedArray - - template init64FloatView*(FLOAT64_VIEW, UINT32_VIEW) = - let - FLOAT64_VIEW = newFloat64Array(1) - UINT32_VIEW = newUint32Array(FLOAT64_VIEW.buffer) - - template init32FloatView*(FLOAT32_VIEW, UINT16_VIEW) = - let - FLOAT32_VIEW = newFloat32Array(1) - UINT16_VIEW = newUint16Array(FLOAT32_VIEW.buffer) - -else: - # this section is for C-like's Nim impl, as union objects are only implemented for them - # - # However, maybe ./{to,from}Words's implementation is at least more effecient than this? - # (or at least much simpler) - # TODO: check it - type - VIEW64 {.union.}= object - uint*: array[2, uint32] - float: float - VIEW32 {.union.}= object - uint*: array[2, uint16] - float: float32 - - template genSlice(FView, F, II, I){.dirty.} = - func `[]`*(fv: FView, _: range[0..0]): F = fv.float - func `[]=`*(fv: var FView, _: range[0..0], f: F) = fv.float = f - - genSlice VIEW64, float64, uint64, uint32 - genSlice VIEW32, float32, uint32, uint16 - - - template init64FloatView*(FLOAT64_VIEW, UINT32_VIEW) = - bind VIEW64 - var FLOAT64_VIEW: VIEW64 - template UINT32_VIEW: untyped = FLOAT64_VIEW.uint - template init32FloatView*(FLOAT32_VIEW, UINT16_VIEW) = - bind VIEW32 - var FLOAT32_VIEW: VIEW32 - template UINT16_VIEW: untyped = FLOAT32_VIEW.uint diff --git a/src/pylib/Lib/math_impl/inWordUtils/fromWords.nim b/src/pylib/Lib/math_impl/inWordUtils/fromWords.nim deleted file mode 100644 index 2cfde694a..000000000 --- a/src/pylib/Lib/math_impl/inWordUtils/fromWords.nim +++ /dev/null @@ -1,49 +0,0 @@ - - -import ./float_view -import ./indices - -proc fromWords*(high, low: uint32): float = - when nimvm: - let u = (uint64(high) shl 32) or uint64(low) - result = cast[float](u) - else: - init64FloatView FLOAT64_VIEW, UINT32_VIEW - accessHighLow: - UINT32_VIEW[HIGH] = high - UINT32_VIEW[LOW] = low - return FLOAT64_VIEW[0] - -proc fromWords*(high, low: uint16): float32 = - when nimvm: - let u = (high.uint32 shl 16) or low.uint32 - result = cast[float32](u) - else: - init32FloatView FLOAT32_VIEW, UINT16_VIEW - accessHighLow: - UINT16_VIEW[HIGH] = high - UINT16_VIEW[LOW] = low - return FLOAT32_VIEW[0] - -when isMainModule: - assert 0 == fromWords(0u32, 0u32) - assert -3.141592653589793 == fromWords( 3221823995u32, 1413754136u32 ) - assert NegInf == 1/fromWords( 2147483648u32, 0u32 ) - import std/math - assert isNaN fromWords( 2146959360u32, 0 ) - assert Inf == fromWords( 2146435072u32, 0 ) - assert NegInf == fromWords( 4293918720u32, 0 ) - -#[ -{.emit: """ -function fromWords( high, low ) { - const FLOAT64_VIEW = new Float64Array( 1 ); - const UINT32_VIEW = new Uint32Array( FLOAT64_VIEW.buffer ); - const HIGH = indices.HIGH; - const LOW = indices.LOW; - UINT32_VIEW[ HIGH ] = high; - UINT32_VIEW[ LOW ] = low; - return FLOAT64_VIEW[ 0 ]; -""".} -}]# - diff --git a/src/pylib/Lib/math_impl/inWordUtils/indices.nim b/src/pylib/Lib/math_impl/inWordUtils/indices.nim deleted file mode 100644 index 4384a2255..000000000 --- a/src/pylib/Lib/math_impl/inWordUtils/indices.nim +++ /dev/null @@ -1,29 +0,0 @@ - -import ./assertIsLittleEndian - -when defined(js): - var HIGHv, LOWv: cint - - if isLittleEndian(): - HIGHv = 1; # second index - LOWv = 0; # first index - else: - HIGHv = 0; # first index - LOWv = 1; # second index - - template HIGH*: cint = - when nimvm: int(isLittleEndian()) - else: HIGHv - template LOW*: cint = - when nimvm: int(not isLittleEndian()) - else: LOWv - template accessHighLow*(body) = - {.noSideEffect.}: - body - -else: - const - HIGH* = int(isLittleEndian()) - LOW* = int(not isLittleEndian()) - - template accessHighLow*(body) = body diff --git a/src/pylib/Lib/math_impl/inWordUtils/jsTypedArray.nim b/src/pylib/Lib/math_impl/inWordUtils/jsTypedArray.nim deleted file mode 100644 index a59d5f981..000000000 --- a/src/pylib/Lib/math_impl/inWordUtils/jsTypedArray.nim +++ /dev/null @@ -1,31 +0,0 @@ - -import std/macros - -# {.noInit.} for TypedArray caused compile-error in Nim 2.0.8 (not in 2.1.9) -type - TypedArray*[T] = object of JsRoot - -func buffer*(self: TypedArray): JsRoot{.importjs: "(#).buffer".} - -func capName(s: string): string{.compileTime.} = - char(s[0].int and ord('_')) & s[1..^1] - -macro genNewTA(T: typedesc) = - let - s = capName(repr(T)) & "Array" - typeName = newLit s - sym = ident("new" & s) - result = quote do: - func `sym`*(x: auto): TypedArray[`T`]{.importjs: "new " & `typeName` & "(#)".} - -#func newTypedArray*[T](x: auto): TypedArray[T]{.importjs: "new " & toArrName($T) & "(#)".} - -genNewTA uint8 -genNewTA uint16 -genNewTA uint32 - -genNewTA float32 -genNewTA float64 - -func `[]`*[T](x: TypedArray[T], i: cint): T{.importjs: "#[#]".} -func `[]=`*[T](x: TypedArray[T], i: cint, val: T){.importjs: "#[#]=#;".} diff --git a/src/pylib/Lib/math_impl/inWordUtils/toWords.nim b/src/pylib/Lib/math_impl/inWordUtils/toWords.nim deleted file mode 100644 index 3e4c794ed..000000000 --- a/src/pylib/Lib/math_impl/inWordUtils/toWords.nim +++ /dev/null @@ -1,30 +0,0 @@ - -import ./float_view -import ./indices - -func toWords*(x: float): (uint32, uint32) = - when nimvm: - let u = cast[uint64](x) - result[0] = cast[uint32](u shr 32) - result[1] = cast[uint32](u) - else: - init64FloatView FLOAT64_VIEW, UINT32_VIEW - FLOAT64_VIEW[ 0 ] = x - accessHighLow: - result[0] = UINT32_VIEW[ HIGH ] - result[1] = UINT32_VIEW[ LOW ] - -func toWords*(x: float32): (uint16, uint16) = - when nimvm: - let u = cast[uint32](x) - result[0] = cast[uint16](u shr 16) - result[1] = cast[uint16](u) - else: - init32FloatView FLOAT32_VIEW, UINT16_VIEW - FLOAT32_VIEW[ 0 ] = x - accessHighLow: - result[0] = UINT16_VIEW[ HIGH ] - result[1] = UINT16_VIEW[ LOW ] - -when isMainModule: - assert toWords(3.14e201) == (1774486211u32, 2479577218u32) diff --git a/src/pylib/Lib/math_impl/isX.nim b/src/pylib/Lib/math_impl/isX.nim deleted file mode 100644 index 92fe0c043..000000000 --- a/src/pylib/Lib/math_impl/isX.nim +++ /dev/null @@ -1,36 +0,0 @@ - -import std/math -from ./platformUtils import CLike - -template expM(x) = export math.x - -expM isnan - -func n_isfinite(x: SomeFloat): bool{.used.} = - let cls = classify(x) - result = cls != fcInf and cls != fcNegInf and cls != fcNan - -func n_isinf(x: SomeFloat): bool{.used.} = - x == Inf or x == NegInf - -when defined(js): - func js_isfiniteImpl(x: float): bool{.importjs: "Number.isFinite(#)".} - func js_isfinite(x: SomeFloat): bool = float(x).js_isfiniteImpl - func js_isinf(x: SomeFloat): bool = - not x.isnan and not x.js_isfinite - -template wrap(sym, c_sym, n_sym, js_sym){.dirty.} = - func c_sym(x: c_double|c_float): c_int{.importc: astToStr(sym), header: "".} - func sym(x: SomeFloat): bool = - when nimvm: n_sym(x) - else: - when CLike: - bool c_sym (when x is float32: x.c_float else: x.c_double) - elif defined(js): js_sym x - else: n_sym(x) - -wrap isfinite, c_isfinite, n_isfinite, js_isfinite -wrap isinf, c_isinf, n_isinf, js_isinf - -export isinf -export isfinite diff --git a/src/pylib/Lib/math_impl/ldexp.nim b/src/pylib/Lib/math_impl/ldexp.nim deleted file mode 100644 index 479ef22f8..000000000 --- a/src/pylib/Lib/math_impl/ldexp.nim +++ /dev/null @@ -1,42 +0,0 @@ -## c_ldexp - -from ./platformUtils import CLike, clikeOr - -when CLike: - {.push header: "".} - proc ldexpf(arg: c_float, exp: c_int): c_float{.importc.} - proc ldexp(arg: c_double, exp: c_int): c_double{.importc.} - {.pop.} - -import ./patch/ldexp_frexp/ldexp as pure_ldexp - -# not very effective, anyway -func n_ldexp*[F: SomeFloat](x: F, i: int): F = F pure_ldexp.ldexp(x.float, i) - -#[ -func js_ldexp[F: SomeFloat](x: F, i: int): F = - pure_ldexp.ldexp(x.float, i) -func round_ldexp(x: SomeFloat, i: int): float = - ## a version of `ldexp`_ that's implemented in pure Nim, used by ldexp in weridTarget - ## - ## translated from - ## https://blog.codefrau.net/2014/08/deconstructing-floats-frexp-and-ldexp.html - ## which is for JS. - ## XXX: Not sure if suitable for Obj-C - let steps = min(3, int ceil(abs(i)/1023) ) - result = x - for step in 0.. ay: ## same sign - if ax - ay >= usteps: - ux.i -= usteps - return ux.f - else: - return uy.f - else: - if ay - ax >= usteps: - ux.i += usteps - return ux.f - else: - return uy.f - -func nextafter*(x, y: float; - usteps: uint64): float = - clikeOr( - c_nextafter(x, y, usteps), - nextafter_stepLib.nextafter(x, y, usteps), - ) - -when culonglong is_not uint64: - proc nextafter*(x, y: float; - usteps_ull: culonglong): float = - let usteps = - if usteps_ull >= UINT64_MAX: - ## This branch includes the case where an error occurred, since - ## (unsigned long long)(-1) = ULLONG_MAX >= UINT64_MAX. Note that - ## usteps_ull can be strictly larger than UINT64_MAX on a machine - ## where unsigned long long has width > 64 bits. - UINT64_MAX - else: - cast[uint64](usteps_ull) - nextafter(x, y, uint64 ustep) - -func nextafter*(x, y: float; - steps: int): float = - if steps < 0: - raise newException(ValueError, "steps must be a non-negative integer") - nextafter(x, y, uint64 steps) diff --git a/src/pylib/Lib/math_impl/nextafter_ulp.nim b/src/pylib/Lib/math_impl/nextafter_ulp.nim deleted file mode 100644 index fd9796748..000000000 --- a/src/pylib/Lib/math_impl/nextafter_ulp.nim +++ /dev/null @@ -1,33 +0,0 @@ - - -from ./platformUtils import CLike, clikeOr -import ./patch/nextafter as n_nextafterLib -import ./nextafter_step -from ./isX import isnan, isinf - -when CLike: - {.push header: "".} - proc c_nextafter(frm, to: c_double): c_double{.importc: "nextafter".} - proc c_nextafter(frm, to: c_float): c_float{.importc: "nextafterf".} - {.pop.} - -func nextafter*[F: SomeFloat](x, y: F): F = - clikeOr( - c_nextafter(x, y), - n_nextafterLib.nextafter(x, y) - ) - -func nextafter*[F: SomeFloat](x, y: F; steps: int|uint64): F = - nextafter_step.nextafter(x, y, steps) - -func ulp*[F: SomeFloat](x: F): F = - bind nextafter - if isnan(x): return x - let x = abs(x) - if isinf(x): return x - result = nextafter(x, Inf) - if isinf(result): - # special case: x is the largest positive representable float - result = nextafter(x, NegInf) - return x - result - result -= x diff --git a/src/pylib/Lib/math_impl/patch/consts.nim b/src/pylib/Lib/math_impl/patch/consts.nim deleted file mode 100644 index 25cb528fa..000000000 --- a/src/pylib/Lib/math_impl/patch/consts.nim +++ /dev/null @@ -1,15 +0,0 @@ - -import ../constsUtils - -const - Pinf* = Inf - Ninf* = NegInf - - EULER* = ## euler_gamma - 0.577215664901532860606512090082402431042 - SQRT_TWO_PI* = ## `sqrt(2*PI)` <-> `sqrt(TAU)` - 2.506628274631000502415765284811045253 - -genWithArg maxSafeInteger, 16777215.0, 9007199254740991.0 -## 2**53 - 1 -## 2**24 - 1 diff --git a/src/pylib/Lib/math_impl/patch/erf.nim b/src/pylib/Lib/math_impl/patch/erf.nim deleted file mode 100644 index 5d69b0e68..000000000 --- a/src/pylib/Lib/math_impl/patch/erf.nim +++ /dev/null @@ -1,128 +0,0 @@ - -# CPython's manual implememtation for erf and erfc was removed since -# `gh-101678: refactor the math module to use special functions from c11 -# (...GH-101679)` - - -#[ the following is CPython's comment - Implementations of the error function erf(x) and the complementary error - function erfc(x). - Method: we use a series approximation for erf for small x, and a continued - fraction approximation for erfc(x) for larger x; - combined with the relations erf(-x) = -erf(x) and erfc(x) = 1.0 - erf(x), - this gives us erf(x) and erfc(x) for all x. - The series expansion used is: - erf(x) = x*exp(-x*x)/sqrt(pi) * [ - 2/1 + 4/3 x**2 + 8/15 x**4 + 16/105 x**6 + ...] - The coefficient of x**(2k-2) here is 4**k*factorial(k)/factorial(2*k). - This series converges well for smallish x, but slowly for larger x. - The continued fraction expansion used is: - erfc(x) = x*exp(-x*x)/sqrt(pi) * [1/(0.5 + x**2 -) 0.5/(2.5 + x**2 - ) - 3.0/(4.5 + x**2 - ) 7.5/(6.5 + x**2 - ) ...] - after the first term, the general term has the form: - k*(k-0.5)/(2*k+0.5 + x**2 - ...). - This expansion converges fast for larger x, but convergence becomes - infinitely slow as x approaches 0.0. The (somewhat naive) continued - fraction evaluation algorithm used below also risks overflow for large x; - but for large x, erfc(x) == 0.0 to within machine precision. (For - example, erfc(30.0) is approximately 2.56e-393). - Parameters: use series expansion for abs(x) < ERF_SERIES_CUTOFF and - continued fraction expansion for ERF_SERIES_CUTOFF <= abs(x) < - ERFC_CONTFRAC_CUTOFF. ERFC_SERIES_TERMS and ERFC_CONTFRAC_TERMS are the - numbers of terms to use for the relevant expansions. -]# - -from std/math import exp, isNaN - -const - sqrtpi = 1.772453850905516027298167483341145182798 - -const - ERF_SERIES_CUTOFF = 1.5 - ERF_SERIES_TERMS = 25 - ERFC_CONTFRAC_CUTOFF = 30.0 - ERFC_CONTFRAC_TERMS = 50 - -proc m_erf_series[F](x: F): F = - ## - ## Error function, via power series. - ## Given a finite float x, return an approximation to erf(x). - ## Converges reasonably fast for small x. - ## - let x2 = x * x - var - acc = 0.0 - fk = cast[F](ERF_SERIES_TERMS) + 0.5 - for i in 0.. 2.0), and should be safe from - ## overflow if x and nterms are not too large. On an IEEE 754 machine, with x - ## <= 30.0, we're safe up to nterms = 100. For x >= 30.0, erfc(x) is smaller - ## than the smallest representable nonzero float. - ## - if x >= ERFC_CONTFRAC_CUTOFF: - return 0.0 - let x2 = x * x - var - a = 0.0 - da = 0.5 - p = 1.0 - p_last = 0.0 - q = da + x2 - q_last = 1.0 - var - temp: F - b: F - for i in 0.. 0.0: 1.0 - cf else: cf - 1.0 - -proc erfc*[F: SomeFloat](x: F): F = - ## Complementary error function erfc(x), for general x. - if isNaN(x): - return x - let absx = abs(x) - if absx < ERF_SERIES_CUTOFF: - 1.0 - m_erf_series(x) - else: - let cf = m_erfc_contfrac(absx) - if x > 0.0: cf else: 2.0 - cf - -when isMainModule and defined(js) and defined(es6): # for test - func erf*(x: float): float{.exportc.} = erf[float](x) - func erfc*(x: float): float{.exportc.} = erfc[float](x) - {.emit: """export {erf, erfc};""".} diff --git a/src/pylib/Lib/math_impl/patch/fma.nim b/src/pylib/Lib/math_impl/patch/fma.nim deleted file mode 100644 index 1c8071e59..000000000 --- a/src/pylib/Lib/math_impl/patch/fma.nim +++ /dev/null @@ -1,44 +0,0 @@ -## -## c_fma means compatible fma, using `` `fma` when for C - -from ../platformUtils import CLike -from ../isX import isfinite, isnan - -when CLike: - const UNRELIABLE_FMA* = true - {.push header: "".} - proc c_fma*(x, y, z: cdouble): cdouble{.importc: "fma".} - proc c_fma*(x, y, z: cfloat): cfloat{.importc: "fmaf".} - {.pop.} - -else: - const UNRELIABLE_FMA* = false - func c_fma*[F: SomeFloat](x, y, z: F): F = - #{.error: "not impl for weird target".} - {.warning: "not accurate for weird target".} - x * y + z - -func fma*[F: SomeFloat](x, y, z: F, exc: var ref Exception): F{.raises: [].} = - ## EXT. - result = c_fma(x, y, z) - - # Fast path: if we got a finite result, we're done. - if isfinite(result): - return result - template all3(f): bool = - f(x) and f(y) and f(z) - template notNaN(x): bool = not isnan(x) - - # Non-finite result. Raise an exception if appropriate, else return r. - if isnan(result): - if all3 notNaN: - # NaN result from non-NaN inputs. - exc = newException(ValueError, "invalid operation in fma") - return - elif all3 isfinite: - exc = newException(OverflowDefect, "overflow in fma") - return -func fma*[F: SomeFloat](x, y, z: F): F{.raises: [].} = - ## .. warning:: this fma does not touch errno and exception is discarded - var exc_unused: ref Exception - fma(x, y, z, exc_unused) diff --git a/src/pylib/Lib/math_impl/patch/gamma.nim b/src/pylib/Lib/math_impl/patch/gamma.nim deleted file mode 100644 index 220760647..000000000 --- a/src/pylib/Lib/math_impl/patch/gamma.nim +++ /dev/null @@ -1,254 +0,0 @@ - -#[ - The original C code, copyright, license, and constants are from - [Cephes](http://www.netlib.org/cephes)'s cprob/gamma.c - The implementation follows the original, but has been modified a lot - for Nim and add support for Python/R/stdlib-js's behaviors. - - ``` - Copyright 1984, 1987, 1989, 1992, 2000 by Stephen L. Moshier - - Some software in this archive may be from the book _Methods and Programs for Mathematical Functions_ (Prentice-Hall or Simon & Schuster International, 1989) or from the Cephes Mathematical Library, a commercial product. In either event, it is copyrighted by the author. What you see here may be used freely but it comes with no support or guarantee. - - Stephen L. Moshier - moshier@na-net.ornl.gov - ``` -]# - -import std/math -import ./consts -import ./sinpi -from ./trunc import uncheckedTruncToInt -from ../polevl import polExpd0 -from ../err import mapRaiseGammaErr, GammaError -from ../gammaXRange import MAX_GAMMA_X, MIN_GAMMA_X -import ../constsUtils - -export GammaError - -genWithArg UseSmallApprox, 1.0e-4, 1.0e-9 -func smallApprox[T: SomeFloat](x, z: T): T = - z / ((1.0+( EULER*x )) * x) - - -genWithArg MAX_STIRLING, 26.7, 143.01608 - -##[ Stirling's formula for the gamma function - gamma(x) = sqrt(2 pi) x^(x-.5) exp(-x) ( 1 + 1/x P(1/x) ) - -For float32: - .028 < 1/x < .1 - relative error < 1.9e-11 - ]## - -func stirlingApprox[F: SomeFloat](x: F): F = - ## Evaluates the gamma function using Stirling's formula. - ## The polynomial is valid for 33 <= x <= 172 - - var w, y: F - w = 1.0 / x - when F is float32: - w = w.polExpd0 [ - 1.0, - 8.333331788340907E-002, - 3.473255786154910E-003, - -2.705194986674176E-003, - ] - else: - w = w.polExpd0 [ - 1.0, - 0.08333333333334822, - 0.0034722222160545866, - -0.0026813261780578124, - -0.00022954996161337813, - 0.0007873113957930937, - ] - y = exp(x) - - if x > MAX_STIRLING F: # Avoid overflow in pow() - let v = pow(x, ( 0.5*x ) - 0.25) - y = v * (v/y) - else: - y = pow(x, x-0.5) / y - return SQRT_TWO_PI * y * w - - -func isEven[F: SomeFloat](positive: F): int = - ## check if a positive float intpart is even. - ## returns: - ## -1 if cannot detect, 0/1 for yes/no - assert positive > 0.0 - if positive < F.maxSafeInteger: - # maxSafeInteger is less than BiggestInt.high - cast[int]((cast[BiggestInt](positive) and 1)) - else: -1 - - -func gammaImpl[F: SomeFloat](x: F, res: var F, fc: FloatClass): GammaError = - template ret(st; rt=geOk) = - ## set to res & return - res = st - return rt - let - isPositive = x > 0.0 - ax = if isPositive: x else: -x - var axIpart = floor(ax) # note here p still may be non-finite - - case fc - of fcNan: ret NaN - of fcNegInf: ret 0.0, geGotNegInf - elif not isPositive and ax == axIpart: # 0 -1 -2 ... (non-positive integer) - # XXX: though in ieee754 there're both `-0.0` and `0.0`, - # we just come along with mainstream like SymPy, R, etc and - # simply return NaN and introduce domain error. - ret NaN, geDom - elif x > MAX_GAMMA_X F: - ret PINF, geOverFlow - else: discard - - # now `x` is a normal, non-zero, non-negative-integer float - - template chkGetSign(ax: F): F = - ## used for `gamma` with negative value, - ## panic if `ax` is not positive. - ## - ## if `ax` is even, gets -1.0; if odd, gets 1.0; - ## And makes outer functions returns geZeroCantDetSign if cannot detect - let even: int = ax.isEven - if even == -1: - ret 0.0, geZeroCantDetSign - block: - if even == 1: -1.0 - else: 1.0 - var sign: F - if x < MIN_GAMMA_X F: - # `\lim\limits_{x->-\infty} |\Gamma(x)| != 0`, - # but for ieee754 float, when x < `MIN_GAMMA_X`, - # for any value close to integer(get via `nextafter()`), - # it just be truncated as zero. - sign = chkGetSign ax - ret sign * 0.0, geUnderFlow - var z: F - var ix: int - if ax > 33.0: - if isPositive: - ret stirlingApprox(x) - - # axIpart == ax condition has been checked above - - sign = chkGetSign axIpart - - # calcuate the delta between nearest integer - z = ax - axIpart - if z > 0.5: - axIpart += 1.0 - z = ax - axIpart - # now z is in (-0.5, 0.5] - - z = ax * sinpi(z) - if z == 0.0: ret sign * PINF - else: ret sign * PI / ( abs(z)*stirlingApprox(ax) ) - elif isPositive: - # then x is in `(0.0, 33.0]` - template asInt(x: F, res: var int): bool = - res = uncheckedTruncToInt[int](x) - # NIM-BUG: using cast above results in rt-err when JS in `math.fac` - res.F == x - const - NGAMMA_INTEGRAL = ## length of `fac`'s inner table - when sizeof(int) == 2: 5 - elif sizeof(int) == 4: 13 - else: 21 - if x.asInt(ix) and ix < NGAMMA_INTEGRAL: - # fast-path: `gamma(x) = (x-1)!`, when x is positive integer. - ret F fac(ix-1) - - # Reduce `x`... - z = 1.0; - var x = x - while x >= 3.0: - x -= 1.0 - z *= x - - while x < 0.0: - if x > -UseSmallApprox F: - ret smallApprox(x, z) - z /= x - x += 1.0 - - while x < 2.0: - if x < UseSmallApprox F: - ret smallApprox(x, z) - z /= x - x += 1.0 - - if x == 2.0: - ret z - - x -= 2.0 - - # here `x` is in (0.0, 1.0) - - let - p = x.polExpd0 [ - 9.99999999999999996796E-1, - 0.4942148268014971, - 0.20744822764843598, - 0.04763678004571372, - 0.010421379756176158, - 0.0011913514700658638, - 0.00016011952247675185, - ] - q = x.polExpd0 [ - 1.00000000000000000320E0, - 0.0714304917030273, - -0.23459179571824335, - 0.035823639860549865, - 0.011813978522206043, - -0.004456419138517973, - 0.0005396055804933034, - -0.000023158187332412014, - ] - ret z * p / q - -func gamma*[T: SomeFloat](x: T, res: var T): GammaError = - ## a more error friendly version of gamma - gammaImpl x, res, classify(x) - -func gamma*[F: SomeFloat](x: F): F = - ## CPython `math.gamma`-like, with error message more detailed. - runnableExamples: - template chkValueErr(arg) = - doAssertRaises ValueError: discard gamma arg - chkValueErr NegInf - chkValueErr 0.0 - # Currently +-0.0 result is not consistent with CPython; - # assert NegInf == 1.0/gamma(-180.5) - mapRaiseGammaErr x.gamma result - -func rGamma*[F: SomeFloat](x: F): F{.raises: [].} = - ## behaviors like R's `gamma` except for this without any warning. - runnableExamples: - from std/math import isNaN - assert isNaN rgamma NegInf - assert Inf == 1/rgamma(-180.5) # never returns -0.0 - case x.gamma result - of geGotNegInf: - result = NaN - of geUnderFlow: - result = 0.0 ## always returns +0.0 - else: discard - -func stdlibJsGamma*[F: SomeFloat](x: F): F{.raises: [].} = - ## behaviors like `@stdlib-js/gamma.js` - let fc = classify(x) - case fc - of fcNegZero: return NINF - of fcZero: return PINF - of fcNegInf: return NaN - else: discard - discard x.gammaImpl(result, fc) - -when isMainModule and defined(js) and defined(es6): # for test - func gamma*(x: float): float{.exportc.} = stdlibJsGamma[float](x) - {.emit: """export {gamma};""".} diff --git a/src/pylib/Lib/math_impl/patch/inWordUtilsMapper.nim b/src/pylib/Lib/math_impl/patch/inWordUtilsMapper.nim deleted file mode 100644 index 46833c8d8..000000000 --- a/src/pylib/Lib/math_impl/patch/inWordUtilsMapper.nim +++ /dev/null @@ -1,47 +0,0 @@ - -import std/macros - -when not defined(js): - from std/os import parentDir, `/../` - -const - wuDirPart = "inWordUtils" - -const dunder_file = currentSourcePath() -when defined(js): - from std/strutils import rfind - func restrict_parentDir(s: string): string {.compileTime.}= - var idx = s.rfind '/' - if idx == -1: idx = s.rfind '\\' - assert idx != -1, "unreachable: not abs path from currentSourcePath()" - debugEcho s[0.. MAX_EXPONENT F: - if frac < 0.0: - return NegInf - return Inf - - # Check for a subnormal and scale accordingly to retain precision... - let m = - if exp <= MAX_SUBNORMAL_EXPONENT F: - exp += MantissaDigits F - TWO52_INV - else: - 1.0 - - # Split the fraction into higher and lower order words: - let WORDS = toWords( frac ) - var high = WORDS[ 0 ] - type UI = typeof high - - # Clear the exponent bits within the higher order word: - high = high and CLEAR_EXP_MASK[F].UI - - # Set the exponent bits to the new exponent: - high = high or (UI(exp+BIAS F) shl 20) - - # Create a new floating-point number: - return m * fromWords( high, WORDS[ 1 ] ) - -when isMainModule and defined(js): - func jsldexp( frac: float, exp: cint ): float{.used, exportc: "ldexp".} = ldexp(frac, exp.int) - when defined(es6): - # for test - {.emit: """export {ldexp};""".} - else: - {.emit: "module.exports = ldexp;".} diff --git a/src/pylib/Lib/math_impl/patch/ldexp_frexp/normalize.nim b/src/pylib/Lib/math_impl/patch/ldexp_frexp/normalize.nim deleted file mode 100644 index bf0b64cdd..000000000 --- a/src/pylib/Lib/math_impl/patch/ldexp_frexp/normalize.nim +++ /dev/null @@ -1,16 +0,0 @@ - -#from std/math import classify, FloatClass -from std/fenv import minimumPositiveValue -import ../inWordUtilsMapper -wu_import MantissaDigits from consts - -template SCALAR[T](x: typedesc[T]): T = - ## 1 shl (mantissaDigits(T) - 1) - when T is float64: 4503599627370496.0 ## 1 shl 52 - else: 8388608'f32 ## 1 shl 23 - -proc normalize*[F: SomeFloat](x: F): (F, int){.noInit.} = - if ( x != 0.0 and abs( x ) < minimumPositiveValue F ): # subnormal - (x * SCALAR F, -MantissaDigits F) - else: - (x, 0) diff --git a/src/pylib/Lib/math_impl/patch/lgamma.nim b/src/pylib/Lib/math_impl/patch/lgamma.nim deleted file mode 100644 index fb4c3bcc1..000000000 --- a/src/pylib/Lib/math_impl/patch/lgamma.nim +++ /dev/null @@ -1,409 +0,0 @@ - -##[ -## Notice - -This module was hand-translated from [FreeBSD's lgamma]( -https://svnweb.freebsd.org/base/release/12.2.0/lib/msun/src/e_lgamma_r.c) implementation; - -and with some modification: - -- no static data is used, so each function is thread-safe. - - -The following copyright, license, and long comment were part of - the original implementation available as part of - FreeBSD - -``` -Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved. - -Developed at SunPro, a Sun Microsystems, Inc. business. -Permission to use, copy, modify, and distribute this -software is freely granted, provided that this notice -is preserved. -``` - -]## - - -from std/math import ln, classify, FloatClass, Pi -import ./trunc, ./sinpi, ./consts -from ../polevl import polExpd0 -from ../err import mapRaiseGammaErr, GammaError - -export GammaError - -const - WC = 4.18938533204672725052e-01 ## 0x3FDACFE390C97D69 - - YMIN = 1.461632144968362245 - - TWO56 = 72057594037927936'i64 ## 2**56 - - TINY = 1.3877787807814457e-17 - - TC = 1.46163214496836224576e+00 ## 0x3FF762D86356BE3F - TF = -1.21486290535849611461e-01 ## 0xBFBF19B9BCC38A42 - - TT = -3.63867699703950536541e-18 ## 0xBC50C7CAA48A971F - ## => `TT = -(tail of TF)` - -proc polyvalA1[F](x: F): F = - x.polExpd0 [ - 7.72156649015328655494e-02, - 0.06735230105312927, - 0.007385550860814029, - 0.0011927076318336207, - 0.00022086279071390839, - 0.000025214456545125733, - ] - -proc polyvalA2[F](x: F): F = - x.polExpd0 [ - 3.22467033424113591611e-01, - 0.020580808432516733, - 0.0028905138367341563, - 0.0005100697921535113, - 0.00010801156724758394, - 0.000044864094961891516, - ] - -proc polyvalR[F](x: F): F = - x.polExpd0 [ - 1.0, - 1.3920053346762105, - 0.7219355475671381, - 0.17193386563280308, - 0.01864591917156529, - 0.0007779424963818936, - 0.000007326684307446256, - ] - -proc polyvalS[F](x: F): F = - x.polExpd0 [ - -7.72156649015328655494e-02, # 0xBFB3C467E37DB0C8 - 0.21498241596060885, - 0.325778796408931, - 0.14635047265246445, - 0.02664227030336386, - 0.0018402845140733772, - 0.00003194753265841009, - ] - -proc polyvalT1[F](x: F): F = - x.polExpd0 [ - 4.83836122723810047042e-01, # 0x3FDEF72BC8EE38A2 - -0.032788541075985965, - 0.006100538702462913, - -0.0014034646998923284, - 0.00031563207090362595, - ] - -proc polyvalT2[F](x: F): F = - x.polExpd0 [ - -1.47587722994593911752e-01, # 0xBFC2E4278DC6C509 - 0.01797067508118204, - -0.0036845201678113826, - 0.000881081882437654, - -0.00031275416837512086, - ] - -proc polyvalT3[F](x: F): F = - x.polExpd0 [ - 6.46249402391333854778e-02, # 0x3FB08B4294D5419B - -0.010314224129834144, - 0.0022596478090061247, - -0.0005385953053567405, - 0.0003355291926355191, - ] - -proc polyvalU[F](x: F): F = - x.polExpd0 [ - -7.72156649015328655494e-02, # 0xBFB3C467E37DB0C8 - 0.6328270640250934, - 1.4549225013723477, - 0.9777175279633727, - 0.22896372806469245, - 0.013381091853678766, - ] - -proc polyvalV[F](x: F): F = - x.polExpd0 [ - 1.0, - 2.4559779371304113, - 2.128489763798934, - 0.7692851504566728, - 0.10422264559336913, - 0.003217092422824239, - ] - -proc polyvalW[F](x: F): F = - x.polExpd0 [ - 0.08333333333333297, - -0.0027777777772877554, - 0.0007936505586430196, - -0.00059518755745034, - 0.0008363399189962821, - -0.0016309293409657527, - ] - -func lgamma*[F: SomeFloat](x: F, res: var F): GammaError = - ## currently do not return geOverFlow, geUnderFlow - var flg: int32 - var p, q: F - var w, y, z, r: F - - template ret(st; rt=geOk) = - res = st - return rt - # purge +-Inf, NaN - let fc = classify(x) - if fc == fcNan: - ret x - if fc == fcNegInf: - ## R/CPython/C's lgamma(-Inf) returns Inf - ret Pinf, geGotNegInf - if fc == fcInf: - ret Pinf - if x == 0.0: - ret Pinf, geDom - var - xc = x - isNegative = false - if xc < 0.0: - isNegative = true - xc = -xc - - # purge tiny argument - # If |x| < 2**-56, return -ln(|x|) - if xc < TINY: - ret -ln(xc) - - var t, nadj: F - # purge negative integers and start evaluation for other x < 0 - if isNegative: - # If |x| > maxSafeInteger, then x lost - # the accuracy of unit digit, so it becomes a -integer - # XXX: the original C uses: /* |x|>=2**52, must be -integer */ - # where the 2**52 comes from? - if xc > F.maxSafeInteger: - ret NINF, geZeroCantDetSign - t = sinpi(xc) - if t == 0.0: # -integer - ret Pinf, geDom - nadj = ln(Pi / abs(t * xc)) - - # purge 1 and 2 - if xc == 1.0 or xc == 2.0: - ret 0.0 - - # for x < 2.0 - if xc < 2.0: - if xc <= 0.9: # lgamma(x) = lgamma(x+1)-log(x) - r = -ln(xc) - if xc >= (YMIN - 1.0 + 0.27): - ## 0.7316 <= x <= 0.9 - y = 1.0 - xc - flg = 0 - elif xc >= (YMIN - 1.0 - 0.27): - ## 0.2316 <= x < 0.7316 - y = xc - (TC - 1.0) - flg = 1 - else: - ## 0 < x < 0.2316 - y = xc - flg = 2 - else: - r = 0.0 - if xc >= (YMIN + 0.27): - ## 1.7316 <= x < 2 - y = 2.0 - xc - flg = 0 - elif xc >= (YMIN - 0.27): - ## 1.2316 <= x < 1.7316 - y = xc - TC - flg = 1 - else: - ## 0.9 < x < 1.2316 - y = xc - 1.0 - flg = 2 - var p1, p2, p3: F - case flg - of 0: - z = y * y - p1 = polyvalA1(z) - p2 = z * polyvalA2(z) - p = (y * p1) + p2 - r += (p - (0.5 * y)) - of 1: - z = y * y - w = z * y - p1 = polyvalT1(w) - p2 = polyvalT2(w) - p3 = polyvalT3(w) - p = (z * p1) - (TT - (w * (p2 + (y * p3)))) - r += (TF + p) - of 2: - p1 = y * polyvalU(y) - p2 = polyvalV(y) - r += (-(0.5 * y)) + (p1 / p2) - else: discard - elif xc < 8.0: - ## 2 <= x < 8 - flg = uncheckedTruncToInt[typeof(flg)](xc) - y = xc - F flg - p = y * polyvalS(y) - q = polyvalR(y) - r = (0.5 * y) + (p / q) - z = 1.0 - ## gammaln(1+s) = ln(s) + gammaln(s) - if flg in 3..7: - for i in countdown(flg-1, 2): - z = z * (y + F i) - r += ln(z) - elif xc < F TWO56: - ## 8 <= x < 2**56 - t = ln(xc) - z = 1.0 / xc - y = z * z - w = WC + (z * polyvalW(y)) - r = ((xc - 0.5) * (t - 1.0)) + w - else: - ## 2**56 <= x <= Inf - r = xc * (ln(xc) - 1.0) - if isNegative: - r = nadj - r - ret r - -func lgamma*[F: SomeFloat](x: F): F = - ##[ Evaluates the natural logarithm of the absolute value of gamma function. - - The following was formatted as Nim-Favor Markdown from - [FreeBSD `lgamma` source](https://svnweb.freebsd.org/base/release/12.2.0/lib/msun/src/e_lgamma_r.c) - with some minor amendment. - - - ## Method: - - ### 1. Argument Reduction for 0 < x <= 8 - ``` - Since gamma(1+s)=s*gamma(s), for x in [0,8], we may - reduce x to a number in [1.5,2.5] by - lgamma(1+s) = log(s) + lgamma(s) - for example, - lgamma(7.3) = log(6.3) + lgamma(6.3) - = log(6.3*5.3) + lgamma(5.3) - = log(6.3*5.3*4.3*3.3*2.3) + lgamma(2.3) - ``` - - ### 2. A polynomial approximation of lgamma - Create a polynomial approximation of lgamma around its - minimun `ymin=1.461632144968362245` to maintain monotonicity. - - ``` - On [ymin-0.23, ymin+0.27] (i.e., [1.23164,1.73163]), use - Let z = x-ymin; - lgamma(x) = -1.214862905358496078218 + z^2*poly(z) - where - poly(z) is a 14 degree polynomial. - ``` - - ### 3. Rational approximation in the primary interval `[2,3]` - -``` - We use the following approximation: - s = x-2.0; - lgamma(x) = 0.5*s + s*P(s)/Q(s) - with accuracy - |P/Q - (lgamma(x)-0.5s)| < 2**-61.71 - Our algorithms are based on the following observation - - zeta(2)-1 2 zeta(3)-1 3 - lgamma(2+s) = s*(1-Euler) + --------- * s - --------- * s + ... - 2 3 -``` - - where `Euler = 0.5771...` is the Euler constant, which is very - close to 0.5. - - ### 4. For x>=8, ... - -``` - For x>=8, we have - lgamma(x) ~ (x-0.5)log(x)-x+0.5*log(2pi)+1/(12x)-1/(360x**3)+.... - - (better formula: - lgamma(x) ~ (x-0.5)*(log(x)-1)-.5*(log(2pi)-1) + ...) - - Let z = 1/x, then we approximation - f(z) = lgamma(x) - (x-0.5)(log(x)-1) - by - 3 5 11 - w = w0 + w1*z + w2*z + w3*z + ... + w6*z - where - |w - f(z)| < 2**-58.74 -``` - - ### 5. For negative x, ... - - ``` - For negative x, since (G is gamma function) - -x*G(-x)*G(x) = pi/sin(pi*x), - we have - G(x) = pi/(sin(pi*x)*(-x)*G(-x)) - since G(-x) is positive, sign(G(x)) = sign(sin(pi*x)) for x<0 - Hence, for x<0, signgam = sign(sin(pi*x)) and - lgamma(x) = log(|Gamma(x)|) - = log(pi/(|x*sin(pi*x)|)) - lgamma(-x); - ``` - - .. note:: one should avoid computing `pi*(-x)` directly in the - computation of `sin(pi*(-x))` but using `sinpi(-x)` - - ## Special Cases - ``` - lgamma(2+s) ~ s*(1-Euler) for tiny s - lgamma(1) = lgamma(2) = 0 - lgamma(x) ~ -log(|x|) for tiny x - lgamma(0) = lgamma(neg.integer) = inf and raise divide-by-zero - lgamma(inf) = inf - lgamma(-inf) = inf # see below - ``` - For `lgamma(-inf)`, - - some implementations, like CPython's math, R - and C/C++ returns +inf; - which is not suitable, as gamma(x) where x < about -200 - is always truncated to 0.0 at ieee754 float domain. - This behavior was said for bug compatible with C99, and is readlly documented by [POSIX man]( - https://www.man7.org/linux/man-pages/man3/lgamma.3.html - ) and [cppreference.com](https://en.cppreference.com/w/c/numeric/math/lgamma) - - While others like `scipy.special.gammaln`, Go's `math.Lgamma`, returns - - In my option, `ln(|gamma(-oo)|) -[ieee754 float trunc]-> ln(0+) -> -inf` - - But in this function it returns +inf to keep consistent with Python, - - ]## - - runnableExamples: - from std/math import isNaN - assert lgamma(1.0) == 0.0 - assert lgamma(Inf) == Inf - assert lgamma(NaN).isNaN - mapRaiseGammaErr x.lgamma result - -func stdlibJsLgamma*[F: SomeFloat](x: F): F{.raises: [].} = - discard x.lgamma result - -func rLgamma*[F: SomeFloat](x: F): F{.raises: [].} = stdlibJsLgamma(x) - -func scipyGammaLn*[F: SomeFloat](x: F): F{.raises: [].} = - ## .. note:: this returns -inf for -inf argument, and raises no math error, - ## just like `scipy.special.gammaln` - let err = x.lgamma result - if err == geGotNegInf: - return NINF - -when isMainModule and defined(js) and defined(es6): # for test - func gammaln*(x: float): float{.exportc.} = stdlibJsLgamma(x) - {.emit: """export {gammaln};""".} diff --git a/src/pylib/Lib/math_impl/patch/nextafter.nim b/src/pylib/Lib/math_impl/patch/nextafter.nim deleted file mode 100644 index be0455160..000000000 --- a/src/pylib/Lib/math_impl/patch/nextafter.nim +++ /dev/null @@ -1,83 +0,0 @@ - -##[ - translated from https://github.com/scijs/nextafter/blob/master/nextafter.js - - And add respect to the sign of zero, e.g. - - nextafter(-0.0, 0.0) == 0.0 - nextafter(0.0, -0.0) == -0.0 -]## - -#[ -The MIT License (MIT) - -Copyright (c) 2013 Mikola Lysenko - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in -all copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -THE SOFTWARE. -]# - -import ./inWordUtilsMapper - -wu_import fromWords from fromWords -wu_import toWords from toWords - -from std/math import pow, classify, FloatClass - -const - UINT_MAX = high uint32 - - # 2 ^ (1-BIAS-N_frac) - dbl_SMALLEST_DENORM = cast[float64](1u64) ## pow(2.0, -1074) a.k.a. 2^(1 - 1023 - 52) - flt_SMALLEST_DENORM = cast[float32](1u32) ## pow(2f, -149) a.k.a. 2^(1 - 127 - 23) - -template SMALLEST_DENORM[T](t: typedesc[T]): T = - when T is float64: dbl_SMALLEST_DENORM - else: flt_SMALLEST_DENORM - -func nextafter*[F](x, y: F): F = - let - xFc = classify x - yFc = classify y - if xFc == fcNan: return x - if yFc == fcNan: return y - let x0 = x == 0 - if x == y: - if x0 and xFc != yFc: ## x, y is +-0.0 and their signs differ - return y - return x - if x0: - if y < 0: - return -F.SMALLEST_DENORM - else: - return F.SMALLEST_DENORM - var (hi, lo) = toWords(x) - if (y > x) == (x > 0): - if(lo == UINT_MAX): - hi += 1 - lo = 0 - else: - lo += 1 - else: - if(lo == 0): - lo = UINT_MAX - hi -= 1 - else: - lo -= 1 - - return fromWords(hi, lo) diff --git a/src/pylib/Lib/math_impl/patch/nextafter_step.nim b/src/pylib/Lib/math_impl/patch/nextafter_step.nim deleted file mode 100644 index b7704f14c..000000000 --- a/src/pylib/Lib/math_impl/patch/nextafter_step.nim +++ /dev/null @@ -1,10 +0,0 @@ -## XXX: TODO: current Implementation is slow - -import ./nextafter - -proc nextafter*(x, y: float; - usteps: uint64): float = - result = x - for _ in 1..usteps: - result = nextafter(result, y) - diff --git a/src/pylib/Lib/math_impl/patch/sinpi.nim b/src/pylib/Lib/math_impl/patch/sinpi.nim deleted file mode 100644 index 95d8a4e90..000000000 --- a/src/pylib/Lib/math_impl/patch/sinpi.nim +++ /dev/null @@ -1,31 +0,0 @@ - -from std/math import cos, sin, PI, copySign, classify, FloatClass, `mod` - -func sinpi*[F: SomeFloat](x: F): F = - let fc = classify(x) - if fc == fcNan or fc == fcInf or fc == fcNegInf: - return NaN - # Argument reduction (reduce to [0,2)) - var r, ar: F - r = x mod 2.0 - ar = abs(r) - - # If `x` is an integer, the mod is an Integer... - if ar == 0.0 or ar == 1.0: - return copySign(0.0, r) - if ar < 0.25: - return sin(PI*r) - - # In each pf the following, we further reduce to [-pi/4. pi/4]... - if ar < 0.75: - ar = 0.5 - ar - copySign(cos(PI*ar), r) - elif ar < 1.25: - r = copySign(1.0, r) - r - sin(PI*r) - elif ar < 1.75: - ar -= 1.5 - -copySign(cos(PI*ar), r) - else: - r -= copySign(2.0, r) - sin(PI*r) diff --git a/src/pylib/Lib/math_impl/patch/trunc.nim b/src/pylib/Lib/math_impl/patch/trunc.nim deleted file mode 100644 index 7e19b70d4..000000000 --- a/src/pylib/Lib/math_impl/patch/trunc.nim +++ /dev/null @@ -1,4 +0,0 @@ - -func uncheckedTruncToInt*[I: SomeInteger](x: SomeFloat): I = - ## do not check for nans and infinities - I x diff --git a/src/pylib/Lib/math_impl/platformUtils.nim b/src/pylib/Lib/math_impl/platformUtils.nim deleted file mode 100644 index cb352be4f..000000000 --- a/src/pylib/Lib/math_impl/platformUtils.nim +++ /dev/null @@ -1,3 +0,0 @@ - -import ../private/platformUtils -export platformUtils diff --git a/src/pylib/Lib/math_impl/polevl.nim b/src/pylib/Lib/math_impl/polevl.nim deleted file mode 100644 index 7d3a60d80..000000000 --- a/src/pylib/Lib/math_impl/polevl.nim +++ /dev/null @@ -1,61 +0,0 @@ -##[ - The implementation uses [Horner's rule]( - https://www.geeksforgeeks.org/horners-method-polynomial-evaluation/) - for more efficient computation. -]## - -func polevl*[F](x: F, coef: openArray[F], N = coef.high): F = - ##[ -``` - Evaluates polynomial of degree N: - - 2 N - y = C + C x + C x +...+ C x - 0 1 2 N - - Coefficients are stored in reverse order: - - coef[0] = C , ..., coef[N] = C . - N 0 -``` - ]## - result = coef[0] - for i in 1..N: - result = result * x + coef[i]; - -import std/macros -macro polExpd*[F](x: F, coef: untyped): F = - ## expand polynomial with coef literal - ## as inline expression. - ## - ## `coef` shall be literal of a serials of `F` surrounded by - ## brackets, curly braces or paratheses - runnableExamples: - assert 1.0*3.0+2.0 == polExpd(1.0, (3.0, 2.0)) - - expectKind coef, {nnkBracket, nnkCurly, nnkTupleConstr} - result = coef[0] - for i in 1..= abs(b)) - let x = a + b - let y = (a - x) + b - return DoubleLength(hi: x , lo: y) - -type Py_ssize_t = int -const DBL_MIN = minimumPositiveValue float - -proc vector_norm[F](n: Py_ssize_t; vec: var openarray[F]; max: F; found_nan: bool): F {. - inline.} = - ## - ## Given a *vec* of values, compute the vector norm: - ## - ## sqrt(sum(x ** 2 for x in vec)) - ## - ## The *max* variable should be equal to the largest abs(x). - ## The *n* variable is the length of *vec*. - ## If n==0, then *max* should be 0.0. - ## If an infinity is present in the vec, *max* should be INF. - ## The *found_nan* variable indicates whether some member of - ## the *vec* is a NaN. - ## - ## To avoid overflow/underflow and to achieve high accuracy giving results - ## that are almost always correctly rounded, four techniques are used: - ## - ## lossless scaling using a power-of-two scaling factor - ## accurate squaring using Veltkamp-Dekker splitting [1] - ## or an equivalent with an fma() call - ## compensated summation using a variant of the Neumaier algorithm [2] - ## differential correction of the square root [3] - ## - ## The usual presentation of the Neumaier summation algorithm has an - ## expensive branch depending on which operand has the larger - ## magnitude. We avoid this cost by arranging the calculation so that - ## abs(csum) is always as large as abs(x). - ## - ## To establish the invariant, *csum* is initialized to 1.0 which is - ## always larger than x**2 after scaling or after division by *max*. - ## After the loop is finished, the initial 1.0 is subtracted out for a - ## net zero effect on the final sum. Since *csum* will be greater than - ## 1.0, the subtraction of 1.0 will not cause fractional digits to be - ## dropped from *csum*. - ## - ## To get the full benefit from compensated summation, the largest - ## addend should be in the range: 0.5 <= |x| <= 1.0. Accordingly, - ## scaling or division by *max* should not be skipped even if not - ## otherwise needed to prevent overflow or loss of precision. - ## - ## The assertion that hi*hi <= 1.0 is a bit subtle. Each vector element - ## gets scaled to a magnitude below 1.0. The Veltkamp-Dekker splitting - ## algorithm gives a *hi* value that is correctly rounded to half - ## precision. When a value at or below 1.0 is correctly rounded, it - ## never goes above 1.0. And when values at or below 1.0 are squared, - ## they remain at or below 1.0, thus preserving the summation invariant. - ## - ## Another interesting assertion is that csum+lo*lo == csum. In the loop, - ## each scaled vector element has a magnitude less than 1.0. After the - ## Veltkamp split, *lo* has a maximum value of 2**-27. So the maximum - ## value of *lo* squared is 2**-54. The value of ulp(1.0)/2.0 is 2**-53. - ## Given that csum >= 1.0, we have: - ## lo**2 <= 2**-54 < 2**-53 == 1/2*ulp(1.0) <= ulp(csum)/2 - ## Since lo**2 is less than 1/2 ulp(csum), we have csum+lo*lo == csum. - ## - ## To minimize loss of information during the accumulation of fractional - ## values, each term has a separate accumulator. This also breaks up - ## sequential dependencies in the inner loop so the CPU can maximize - ## floating point throughput. [4] On an Apple M1 Max, hypot(*vec) - ## takes only 3.33 µsec when len(vec) == 1000. - ## - ## The square root differential correction is needed because a - ## correctly rounded square root of a correctly rounded sum of - ## squares can still be off by as much as one ulp. - ## - ## The differential correction starts with a value *x* that is - ## the difference between the square of *h*, the possibly inaccurately - ## rounded square root, and the accurately computed sum of squares. - ## The correction is the first order term of the Maclaurin series - ## expansion of sqrt(h**2 + x) == h + x/(2*h) + O(x**2). [5] - ## - ## Essentially, this differential correction is equivalent to one - ## refinement step in Newton's divide-and-average square root - ## algorithm, effectively doubling the number of accurate bits. - ## This technique is used in Dekker's SQRT2 algorithm and again in - ## Borges' ALGORITHM 4 and 5. - ## - ## The hypot() function is faithfully rounded (less than 1 ulp error) - ## and usually correctly rounded (within 1/2 ulp). The squaring - ## step is exact. The Neumaier summation computes as if in doubled - ## precision (106 bits) and has the advantage that its input squares - ## are non-negative so that the condition number of the sum is one. - ## The square root with a differential correction is likewise computed - ## as if in doubled precision. - ## - ## For n <= 1000, prior to the final addition that rounds the overall - ## result, the internal accuracy of "h" together with its correction of - ## "x / (2.0 * h)" is at least 100 bits. [6] Also, hypot() was tested - ## against a Decimal implementation with prec=300. After 100 million - ## trials, no incorrectly rounded examples were found. In addition, - ## perfect commutativity (all permutations are exactly equal) was - ## verified for 1 billion random inputs with n=5. [7] - ## - ## References: - ## - ## 1. Veltkamp-Dekker splitting: http://csclub.uwaterloo.ca/~pbarfuss/dekker1971.pdf - ## 2. Compensated summation: http://www.ti3.tu-harburg.de/paper/rump/Ru08b.pdf - ## 3. Square root differential correction: https://arxiv.org/pdf/1904.09481.pdf - ## 4. Data dependency graph: https://bugs.python.org/file49439/hypot.png - ## 5. https://www.wolframalpha.com/input/?i=Maclaurin+series+sqrt%28h**2+%2B+x%29+at+x%3D0 - ## 6. Analysis of internal accuracy: https://bugs.python.org/file49484/best_frac.py - ## 7. Commutativity test: https://bugs.python.org/file49448/test_hypot_commutativity.py - ## - ## - var max_e: c_int - if isinf(max): - return max - if found_nan: - return NaN - if max == 0.0 or n <= 1: - return max - var max_e_int: int - discard frexp(max, max_e_int) - max_e = c_int max_e_int - if max_e < -1023: - # When max_e < -1023, ldexp(1.0, -max_e) would overflow. - for e in vec.mitems: - e = e / DBL_MIN - # convert subnormals to normals - return DBL_MIN * vector_norm(n, vec, max / DBL_MIN, found_nan) - let scale = c_ldexp(1.0, -max_e) - assert(max * scale >= 0.5) - assert(max * scale < 1.0) - var - csum: float = 1.0 - frac1: float = 0.0 - frac2: float = 0.0 - var - pr: DoubleLength - sm: DoubleLength - for ori_x in vec: - assert(isfinite(ori_x) and abs(ori_x) <= max) - let x = ori_x * scale - # lossless scaling - assert(abs(x) < 1.0) - pr = dl_mul(x, x) - # lossless squaring - assert(pr.hi <= 1.0) - sm = dl_fast_sum(csum, pr.hi) - # lossless addition - csum = sm.hi - frac1 += pr.lo - # lossy addition - frac2 += sm.lo - # lossy addition - var h = sqrt(csum - 1.0 + (frac1 + frac2)) - pr = dl_mul(-h, h) - sm = dl_fast_sum(csum, pr.hi) - csum = sm.hi - frac1 += pr.lo - frac2 += sm.lo - let x = csum - 1.0 + (frac1 + frac2) - h += x / (2.0 * h) - # differential correction - return h / scale - -template toFloat(x: float): float = x -template toFloat(x: float32): float = float x - -proc math_dist_impl[T](p, q: openarray[T], n: Py_ssize_t): float = - ## [clinic input] - ## math.dist - ## - ## p: object - ## q: object - ## / - ## - ## Return the Euclidean distance between two points p and q. - ## - ## The points should be specified as sequences (or iterables) of - ## coordinates. Both inputs must have the same dimension. - ## - ## Roughly equivalent to: - ## sqrt(sum((px - qx) ** 2.0 for px, qx in zip(p, q))) - ## [clinic start generated code] - ## [clinic end generated code: output=56bd9538d06bbcfe input=74e85e1b6092e68e] - var diffs = newSeq[float](n) - var max = 0.0 - var found_nan = false - {.push boundChecks: off.} - for i in 0 ..< n: - let - px = p[i].toFloat - qx = q[i].toFloat - let - x = abs(px - qx) - diffs[i] = x - found_nan = found_nan or isnan(x) - if x > max: - max = x - {.pop.} - result = vector_norm(n, diffs, max, found_nan) - - -func math_dist_impl[T](p, q: OpenarrayOrNimIter[T]): float = - when not openarray_Check(p): - let p = toSeq(p) - when not openarray_Check(q): - let q = toSeq(q) - math_dist_impl(p, q, dist_checkedSameLen(p, q)) - -func dist*[T; I: static[int]](p, q: array[I, T]): float{.raises: [].} = - math_dist_impl(p, q, I) - -func dist*[A, B](p, q: (A, B)): float{.raises: [].} = - math_dist_impl( - [p[0].toFloat, p[1].toFloat], - [q[0].toFloat, q[1].toFloat], - 2) - -func dist*[A, B, C](p, q: (A, B, C)): float{.raises: [].} = - math_dist_impl( - [p[0].toFloat, p[1].toFloat, p[2].toFloat], - [q[0].toFloat, q[1].toFloat, q[2].toFloat], - 3) diff --git a/src/pylib/Lib/math_impl/vec_op/niter_types.nim b/src/pylib/Lib/math_impl/vec_op/niter_types.nim deleted file mode 100644 index 55b280f72..000000000 --- a/src/pylib/Lib/math_impl/vec_op/niter_types.nim +++ /dev/null @@ -1,22 +0,0 @@ - - -type ClosureIter*[T] = iterator (): T -#type NimIterator*[T] = ClosureIter[T] or iterable[T] -type OpenarrayOrNimIter*[T] = openarray[T] or ClosureIter[T] - -template toNimIterator*[T](x): ClosureIter[T] = - iterator (): T = - for i in x: - yield i - -from std/sequtils import toSeq -export toSeq - -template openarray_Check*(x): bool = - x is openarray - -func dist_checkedSameLen*[T](p, q: T): int{.inline.} = - result = len(p) - if result != len(q): - raise newException(ValueError, - "both points must have the same number of dimensions") diff --git a/src/pylib/Lib/math_impl/vec_op/private/dl_ops.nim b/src/pylib/Lib/math_impl/vec_op/private/dl_ops.nim deleted file mode 100644 index 9444551e0..000000000 --- a/src/pylib/Lib/math_impl/vec_op/private/dl_ops.nim +++ /dev/null @@ -1,56 +0,0 @@ - -from ../../patch/fma import c_fma, UNRELIABLE_FMA - -type - DoubleLength* = object - hi*: float - lo*: float - -when not UNRELIABLE_FMA: - proc dl_mul*(x: float; y: float): DoubleLength = - ## Algorithm 3.5. Error-free transformation of a product - let z = x * y - let zz = c_fma(x, y, -z) - return DoubleLength(hi: z , lo: zz) -else: - proc dl_split(x: float): DoubleLength = - ## - ## The default implementation of dl_mul() depends on the C math library - ## having an accurate fma() function as required by § 7.12.13.1 of the - ## C99 standard. - ## - ## The UNRELIABLE_FMA option is provided as a slower but accurate - ## alternative for builds where the fma() function is found wanting. - ## The speed penalty may be modest (17% slower on an Apple M1 Max), - ## so don't hesitate to enable this build option. - ## - ## The algorithms are from the T. J. Dekker paper: - ## A Floating-Point Technique for Extending the Available Precision - ## https://csclub.uwaterloo.ca/~pbarfuss/dekker1971.pdf - ## - ## Dekker (5.5) and (5.6). - let t = x * 134217729.0 - ## Veltkamp constant = 2.0 ** 27 + 1 - let - hi = t - (t - x) - lo = x - hi - result = DoubleLength(hi: hi, lo: lo) - - proc dl_mul*(x: float; y: float): DoubleLength = - ## Dekker (5.12) and mul12() - let xx = dl_split(x) - let yy = dl_split(y) - let - p = xx.hi * yy.hi - q = xx.hi * yy.lo + xx.lo * yy.hi - z = p + q - zz = p - z + q + xx.lo * yy.lo - result = DoubleLength(hi: z, lo: zz) - - -func dl_sum*(a, b: float): DoubleLength = - ## Algorithm 3.1 Error-free transformation of the sum - let x = a + b - let z = x - a - let y = (a - (x - z)) + (b - z) - DoubleLength(hi: x, lo: y); diff --git a/src/pylib/Lib/math_impl/vec_op/sumprod.nim b/src/pylib/Lib/math_impl/vec_op/sumprod.nim deleted file mode 100644 index d626bba52..000000000 --- a/src/pylib/Lib/math_impl/vec_op/sumprod.nim +++ /dev/null @@ -1,168 +0,0 @@ - - -from ../isX import isfinite -from ./niter_types import OpenarrayOrNimIter, toNimIterator, ClosureIter -from ./private/dl_ops import DoubleLength, dl_mul, dl_sum - -type TripleLength = object - hi, lo, tiny: float - -template tl_zero: TripleLength = TripleLength() - -func tl_fma(x, y: float; total: TripleLength): TripleLength = - ## Algorithm 5.10 with SumKVert for K=3 - let - pr: DoubleLength = dl_mul(x, y) - sm: DoubleLength = dl_sum(total.hi, pr.hi) - r1: DoubleLength = dl_sum(total.lo, pr.lo) - r2: DoubleLength = dl_sum(r1.hi, sm.lo) - TripleLength(hi: sm.hi , lo: r2.hi , tiny: total.tiny + r1.lo + r2.lo) - -func tl_to_d(total: TripleLength): float = - let last = dl_sum(total.lo, total.hi) - total.tiny + last.lo + last.hi - - -template bool_Check(x): bool = x is bool - -template isIntegerType(T): bool = T is SomeInteger -template isFloatType(T): bool = T is SomeFloat - - -template PyFloat_AS_DOUBLE(x: SomeFloat): float = float x -template PyLong_AS_DOUBLE(x: SomeInteger or bool): float = float x - -#template PyNumber_Add[F: SomeNumber](a, b: F): F = system.`+` a, b -#template PyNumber_Add(a, b): untyped = mixOps.`+` a, b - -template number_iAdd[F: SomeNumber](a, b: F) = system.`+=` a, b -template number_iAdd(a: float, b: int) = a += float b - -template mixin_Multiply_Add[P, Q](res: var float, a: P, b: Q) = - mixin `+=`, `*` - `+=`(res, `*`(a, b)) - -template n_next[T](p: ClosureIter[T]): T = p() -template n_iterStopped(p: ClosureIter): bool = finished p - -template sumprodImplWithDoEach[P, Q](p_i: P, q_i: Q; body) = - ## [clinic input] - ## - ## Return the sum of products of values from two iterables p and q. - ## - ## Roughly equivalent to: - ## - ## sum(itertools.starmap(operator.mul, zip(p, q, strict=True))) - ## - ## For float and mixed int/float inputs, the intermediate products - ## and sums are computed with extended precision. - ## [clinic start generated code] - ## [clinic end generated code: output=6722dbfe60664554 input=82be54fe26f87e30] - const - p_type_int = isIntegerType(P) - q_type_int = isIntegerType(Q) - use_int_path = p_type_int and q_type_int - when use_int_path: - # we're in static-typed implementation - #var int_path_enabled = true - #var int_total_in_use = false - var int_total = 0 - else: - const - p_type_float = isFloatType(P) - q_type_float = isFloatType(Q) - # we're in static-typed implementation - #var flt_path_enabled = true - var flt_total_in_use = false - var flt_total: TripleLength - - template Ret{.inject.} = return # return result - template doEach(finished{.inject.}: bool; Continue){.inject.} = - when use_int_path: - if not finished: - int_total.inc(p_i * q_i) - Continue - # We're finished - result.number_iAdd int_total - int_total = 0 - Ret - else: - template push_flt_total = - # We're finished, or got a non-finite value - if flt_total_in_use: - result.number_iAdd tl_to_d(flt_total) - flt_total = tl_zero - flt_total_in_use = false - - if not finished: - template gen_flt_fast_path(do_p, do_q) = - let - flt_p = do_p p_i - flt_q = do_p q_i - new_flt_total = tl_fma(flt_p, flt_q, flt_total) - if isfinite(new_flt_total.hi): - flt_total = new_flt_total - flt_total_in_use = true - Continue - push_flt_total - when p_type_float and q_type_float: - gen_flt_fast_path PyFloat_AS_DOUBLE, PyFloat_AS_DOUBLE - elif p_type_float and (q_type_int or bool_Check(q_i)): - ## We care about float/int pairs and int/float pairs because - ## they arise naturally in several use cases such as price - ## times quantity, measurements with integer weights, or - ## data selected by a vector of bools. - gen_flt_fast_path PyFloat_AS_DOUBLE, PyLong_AsDouble - elif (p_type_int or bool_Check(p_i)) and q_type_float: - gen_flt_fast_path PyLong_AsDouble, PyFloat_AS_DOUBLE - - ## not in `flt_fast_path` - # We have a non-float value or non-finite - # XXX: here no need for nimpylib to check `flt_total` - # as this implementation is static-typed - assert not flt_total_in_use - result.mixin_Multiply_Add(p_i, q_i) - else: - push_flt_total - Ret - - body - -template raiseNotSameLen = - raise newException(ValueError, "Inputs are not the same length") - -template Continue = continue - -func sumprod*[P, Q](p_it: ClosureIter[P]; q_it: ClosureIter[Q]): float = - var - p_i: P - q_i: Q - var - finished: bool - p_stopped = false - q_stopped = false - sumprodImplWithDoEach(p_i, q_i): - while true: - p_i = n_next(p_it) - p_stopped = n_iterStopped p_it - q_i = n_next(q_it) - q_stopped = n_iterStopped q_it - if p_stopped != q_stopped: - raiseNotSameLen - finished = p_stopped and q_stopped - doEach finished, Continue - -func sumprod*[P, Q](p: openarray[P]; q: openarray[Q]): float = - ## a faster version for openarray than that for ClosureIter - var - p_i: P - q_i: Q - sumprodImplWithDoEach(p_i, q_i): - let le = p.len - if le != q.len: - raiseNotSameLen - for i in 0.. b: 1 - else: -1 - -#[ NIM-BUG: -if using `hi=len(a)`: -system.nim(667, 41) -`func len*[TOpenArray: openArray|varargs](x: TOpenArray): int {.magic: "LengthOpenArray".}` -Error: invalid type: 'T' in this context: 'proc (x: openArray[T]): int{.noSideEffect, gcsafe.}' for proc -]# - -template genbi(name, nimName){.dirty.} = - proc name*[T](a: openArray[T]; x: T; lo=0; hi=a.len): int = nimName a[lo.. n: - break doYield - - var indices = toSeq 0..`_ -## -## Also -## this is not just a module that wraps -## Nim's `std/math`_, -## -## but also providing some extensions that Nim's std/math lacks, for example: -## -## - JavaScript Backend and Compile-time (Nim VM) support for `ldexp`, `frexp`, `cbrt`, etc. -## - JavaScript Backend support for `erf`, `erfc`, `gamma`_, `lgamma`_ -## - `fsum`_, `prod`_, etc. -## -## And fix some non-C99 behavior on some systems, -## e.g. log(-ve) -> -Inf on Solaris -## -## *NOTE*: Currently int is not acceptable when it comes to float about functions - -import ../nimpatch/nansign -import std/math -import std/bitops -import std/macros -from ./math_impl/platformUtils import CLike, clikeOr, impJsOrC -from ./math_impl/errnoUtils import - prepareRWErrno, prepareROErrno, setErrno, setErrno0, getErrno, isErr, isErr0 -from ./math_impl/ldexp import c_ldexp -from ./math_impl/cbrt import cbrt -import ./math_impl/expm1_log1p -export expm1_log1p -import ./math_impl/frexp as frexpLib -import ./math_impl/nextafter_ulp -from ./errno import ERANGE, EDOM - -export cbrt -export nextafter, ulp - -macro impPatch(sym) = - #import ./math_impl/patch/sym - # HINT: using `template (sym) = import ./math_impl/patch/sym` - # may fail on some platforms like Android (termux) and nimdoc on Ubuntu - nnkImportStmt.newTree( - infix( - nnkPrefix.newTree(ident"./", - ident"math_impl/patch" - ), - "/", - sym - ) - ) - - -template impExpPatch(sym) = - impPatch sym - export sym - -impExpPatch fma - -import ./math_impl/vec_op -export vec_op - - -template aCap(s: var string) = - let c = s[0] - let nc = char(uint8(c) xor 0b0010_0000'u8) - s[0] = nc - -macro expUp(x) = - var s = x.strVal - aCap s - let nId = ident s - result = quote do: - const `x`* = `nId` - -# consts: -expUp nan # system.NaN -expUp inf # system.Inf -expUp pi -expUp tau -expup e - -template expM(x) = export math.x - -import ./math_impl/isX -export isX - -template c_fmod[F: SomeFloat](x: F, y: F): F = - ## equal to `x - x*trunc(x/y)` - x mod y # math.`mod` - # nim's math.`mod` does what fmod does. - # in C backend, it just `importc` fmod - -func pow*[F: SomeFloat](x, y: F): F = - #[/*deal directly with IEEE specials, to cope with problems on various - platforms whose semantics don't exactly match C99 */]# - if not isfinite(x) or not isfinite(y): - setErrno0 - result = - if isnan(x): - if y == 0.0: 1.0 else: x # NaN**0 = 1 - elif isnan(y): - if x == 1.0: 1.0 else: y # 1**NaN = 1 - elif isinf(x): - let odd_y = isfinite(y) and c_fmod(abs(y), 2.0) == 1.0 - if y > 0.0: - if odd_y: x else: abs(x) - elif y == 0.0: - 1.0 - else: - if odd_y: math.copySign(0.0, x) else: 0.0 - else: - assert isinf(y) - let abs_x = abs(x) - if abs_x == 1.0: 1.0 - elif y > 0.0 and abs_x > 1.0: y - elif y < 0.0 and abs_x < 1.0: -y # result is +inf - else: 0.0 - else: - # let libm handle finite**finite - setErrno0 - result = math.pow(x, y) - #[a NaN result should arise only from (-ve)**(finite - non-integer); in this case we want to raise ValueError.]# - if not isfinite(result): - if isnan(result): - if isnan(result): - setErrno EDOM - #[ - an infinite result here arises either from: - (A) (+/-0.)**negative (-> divide-by-zero) - (B) overflow of x**y with x and y finite - ]# - elif isinf(result): - if x == 0.0: - setErrno EDOM - else: - setErrno ERANGE - - -expM copysign - -template aliasFF(fn, nimfn){.dirty.} = - func fn*[F: SomeFloat](x: F): F = nimfn(x) - -aliasFF fabs, abs # system.abs, limited for float only - -func chkIntFromFloat(x: float) = - ## check impl of `PyLong_FromDouble` - if x.isnan: - raise newException(ValueError, "cannot convert float NaN to integer") - if x.isinf: - raise newException(OverflowDefect, - "cannot convert float infinity to integer") - -template genToInt(sym){.dirty.} = - func sym*(x: SomeFloat): int = - ## .. hint:: unlike C/Nim's returning float, - ## Python's returns `int` and raises errors for nans and infinities - chkIntFromFloat x - int sym x - -genToInt ceil -genToInt floor -genToInt trunc - -template py_math_isclose_impl*(abs) = - ## inner use. Implementation of isclose. - ## - ## mixin a, b, isinf, rel_tol, abs_tol - if rel_tol < 0.0 or abs_tol < 0.0: - raise newException(ValueError, "tolerances must be non-negative") - if a == b: - return 1 - if isinf(a) or isinf(b): - return 0 - let diff = fabs(b - a) - result = - diff <= fabs(rel_tol * b) or - diff <= fabs(rel_tol * a) or - diff <= abs_tol - -func isclose*(a,b: SomeFloat, rel_tol=1e-09, abs_tol=0.0): bool = - py_math_isclose_impl(abs=fabs) - -template reduceGen(sym; Constr){.dirty.} = - func sym*[I: Constr](x, y: I): I = math.sym(x, y) - func sym*[I: Constr](x, y, z: I, args: varargs[I]): I = - result = sym(x, y) - result = sym(result, z) - for i in args: - result = sym(result, i) - -reduceGen gcd, SomeInteger -reduceGen lcm, SomeInteger - -reduceGen hypot, SomeFloat - -when not defined(js): - # Those in std/math are not available for JS - expM erf - expM erfc -else: - impExpPatch erf - export erfc - -impPatch gamma -impPatch lgamma - -func gamma*[F: SomeFloat](x: F): F = - let err = x.gamma result - case err - of geDom, geGotNegInf: setErrno EDOM - of geOverFlow: setErrno ERANGE - of geUnderFlow, geZeroCantDetSign: discard - of geOk: discard - -func lgamma*[F: SomeFloat](x: F): F = - let err = x.lgamma result - case err - of geOverFlow, geUnderFlow: doAssert false, "unreachable" - of geDom: setErrno EDOM - of geGotNegInf: discard # math_impl/patch.lgamma alreadly returns +inf - of geZeroCantDetSign: setErrno EDOM - of geOk: discard - -expM exp - -when CLike: - proc c_strerror(code: cint): cstring{.importc: "strerror", header: "".} - func errnoMsg(errnoCode: cint): string = $c_strerror(errnoCode) -elif defined(js): - func errnoMsg(errnoCode: cint): string = - doAssert false, "unreachable (see errnoUtils.Errno enum shall be count out)" - -func math_is_error*(x: SomeFloat, exc: var ref Exception): bool = - ##[ inner usage (used by Lib/math). - - Call this when errno != 0, and where x is the result libm -returned. This will usually set up an exception and return -true, but may return false without setting up an exception.]## - prepareROErrno - result = true # presumption of guilt - assert not isErr0() # non-zero errno is a precondition for calling - if isErr EDOM: - exc = newException(ValueError, "math domain error") - elif isErr ERANGE: - #[ ANSI C generally requires libm functions to set ERANGE - on overflow, but also generally *allows* them to set - ERANGE on underflow too. There's no consistency about - the latter across platforms. - Alas, C99 never requires that errno be set. - Here we suppress the underflow errors (libm functions - should return a zero on underflow, and +- HUGE_VAL on - overflow, so testing the result for zero suffices to - distinguish the cases). - - On some platforms (Ubuntu/ia64) it seems that errno can be - set to ERANGE for subnormal results that do *not* underflow - to zero. So to be safe, we'll ignore ERANGE whenever the - function result is less than 1.5 in absolute value. - - bpo-46018: Changed to 1.5 to ensure underflows in expm1() - are correctly detected, since the function may underflow - toward -1.0 rather than 0.0. - ]# - if abs(x) < 1.5: - result = false - else: - exc = newException(OverflowDefect, - "math range error") - else: - # Unexpected math error - exc = newException(ValueError, errnoMsg(getErrno())) - -export frexpLib.frexp - -func ldexp*[F: SomeFloat](x: F, i: int, exc: var ref Exception): F{.raises: [].} = - ## set exception to `exc` instead of raising it - ## - ## `exc`: - ## - ## - set to nil if no error - ## - set to suitable exc if some error occurs - # translated from CPython's `math_ldexp_impl` - - # NaNs, zeros and infinities are returned unchanged - prepareRWErrno - if x == 0.0 or not isfinite(x): - # Nim's int is not Python's `LongObject` - # and we can leave Overflow for Nim to handle - result = x - setErrno0 - elif i > typeof(i)(high c_int): - result = copySign(Inf, x) - setErrno ERANGE - elif i < typeof(i)(low c_int): - # underflow to +-0 - result = copySign(0.0, x) - setErrno0 - else: - setErrno0 - let exp = cast[c_int](i) # we have checked range above. - result = - c_ldexp(x, exp) - if isinf(result): - setErrno ERANGE - if not isErr0() and math_is_error(result, exc): - return - exc = nil - -func ldexp*[F: SomeFloat](x: F, i: int): F{.raises: [].} = - ## .. hint:: only set errno - var exc_unused: ref Exception - ldexp(x, i, exc_unused) - -func modf*[F: SomeFloat](x: F): tuple[intpart: F, floatpart: F] = - #[ Though C99 specifies it: - /*some platforms don't do the right thing for NaNs and - infinities, so we take care of special cases directly. */]# - if isinf(x): return (math.copySign(0.0, x), x) - if isnan(x): return (x, x) - setErrno0 - result = splitDecimal x - -func fmod*[F: SomeFloat](x: F, y: F): F = - # fmod(x, +/-Inf) returns x for finite x. - if isinf(y) and isfinite(x): - return x - setErrno0 - result = c_fmod(x, y) - if isnan(result): - if isnan(result): - if not isnan(x) and not isnan(y): - setErrno EDOM - else: - setErrno0 - -func remainder*[F: SomeFloat](x: F, y: F): F = - #[ the simplest but not exact impl: - let - fx = y.float - fy = x.float - fx - fy * round(fx/fy) - ]# - # Deal with most common case first. - if isfinite(x) and isfinite(y): - if y == 0: - return NaN - let - absx = abs(x) - absy = abs(y) - m = c_fmod(absx, absy) - #[ /* - Warning: some subtlety here. What we *want* to know at this point is - whether the remainder m is less than, equal to, or greater than half - of absy. However, we can't do that comparison directly because we - can't be sure that 0.5*absy is representable (the multiplication - might incur precision loss due to underflow). So instead we compare - m with the complement c = absy - m: m < 0.5*absy if and only if m < - c, and so on. The catch is that absy - m might also not be - representable, but it turns out that it doesn't matter: - - - if m > 0.5*absy then absy - m is exactly representable, by - Sterbenz's lemma, so m > c - - if m == 0.5*absy then again absy - m is exactly representable - and m == c - - if m < 0.5*absy then either (i) 0.5*absy is exactly representable, - in which case 0.5*absy < absy - m, so 0.5*absy <= c and hence m < - c, or (ii) absy is tiny, either subnormal or in the lowest normal - binade. Then absy - m is exactly representable and again m < c. - */]# - let c = absy - m - if m < c: - result = m - elif m > c: - result = -c - else: - #[/* - Here absx is exactly halfway between two multiples of absy, - and we need to choose the even multiple. x now has the form - - absx = n * absy + m - - for some integer n (recalling that m = 0.5*absy at this point). - If n is even we want to return m; if n is odd, we need to - return -m. - - So - - 0.5 * (absx - m) = (n/2) * absy - - and now reducing modulo absy gives us: - - | m, if n is odd - fmod(0.5 * (absx - m), absy) = | - | 0, if n is even - - Now m - 2.0 * fmod(...) gives the desired result: m - if n is even, -m if m is odd. - - Note that all steps in fmod(0.5 * (absx - m), absy) - will be computed exactly, with no rounding error - introduced.*/]# - assert m == c - result = m - 2.0 * c_fmod(0.5 * (absx - m), absy) - return math.copySign(1.0, x) * result - - # Special values. - if isnan(x): return x - if isnan(y): return y - if isinf(x): return NaN - assert isinf(y) - result = x - -type - # same as pylib.nim's - Iterable[T] = concept x - for value in x: - value is T - - -func prod*[T](iterable: Iterable[T], start=1.T): T = - result = start - for i in iterable: - result *= i - - -const NUM_PARTIALS = 32 - -func fsum*[T: SomeFloat](iterable: Iterable[T]): T = - - # translated from CPython v3.10.5 `Modules/mathmodule.c` - - type Size = BiggestUint - var n = 0.Size # len - var m: Size = NUM_PARTIALS # cap - - var x, y: T - var p = newSeq[T](NUM_PARTIALS) - - var xsave: T - var special_sum, inf_sum: T = 0.0 - var hi, yr, lo{.volatile.}: T - - for orix in iterable: # for x in iterable - assert(0 <= n and n <= m); - #assert((m == NUM_PARTIALS && p == ps) ||(m > NUM_PARTIALS && p != nil)); - - x = orix # as ox is immutable - xsave = x - var i: Size = 0 - for j in 0..= m: - #_fsum_realloc(&p, n, ps, &m) - m *= 2 - # XXX: Python raises MemeryError on lack of memory; - # But in Nim, by default OutOfMemDefect won't be raised unless - # system.outOfMemHook is accordingly set. - # But we set it here is not suitable as we don't know how to reset it. - p.setLen m - #except OutOfMemDefect: - # raise newException(MemoryError, "math.fsum partials") - else: - p[n] = x - n.inc - - if special_sum != 0.0: - if isnan(inf_sum): - raise newException(ValueError, - "-inf + inf in fsum"); - else: - result = special_sum - return - - hi = 0.0 - if n > 0: - n.dec - hi = p[n] - #[ sum_exact(ps, hi) from the top, stop when the sum becomes - inexact. ]# - while n > 0: - x = hi - n.dec - y = p[n] - assert(abs(y) < abs(x)) - hi = x + y - yr = hi - x - lo = y - yr - if (lo != 0.0): - break - #[ Make half-even rounding work across multiple partials. - Needed so that sum([1e-16, 1, 1e16]) will round-up the last - digit to two instead of down to zero (the 1e-16 makes the 1 - slightly closer to two). With a potential 1 ULP rounding - error fixed-up, math.fsum() can guarantee commutativity. ]# - if (n > 0 and ((lo < 0.0 and p[n-1] < 0.0) or - (lo > 0.0 and p[n-1] > 0.0))): - y = lo * 2.0 - x = hi + y - yr = x - hi - if y == yr: - hi = x - - result = hi - - -template genLog(fun, nimFunc){.dirty.} = - ##[ - /*Various platforms (Solaris, OpenBSD) do nonstandard things for log(0), -log(-ve), log(NaN). Here are wrappers for log and log10 that deal with -special values directly, passing positive non-special values through to -the system log/log10.*/ - And, as I tested on Solaris 11.4, using `Sun C 5.13 SunOS_i386 2014/10/20`: - - log(-ve) -> -Inf, - and errno is set to ERANGE (instead of EDOM)! - ]## - func fun*[F: SomeFloat](x: F): F = - if isfinite(x): - if x > 0.0: - return math.nimFunc(x) - setErrno EDOM - if x == 0.0: - return NegInf # log(0) = -inf - else: - return NaN # log(-ve) = nan - elif isnan(x): - return x # log(nan) = nan - elif x > 0.0: - return x # log(inf) = inf - else: - setErrno EDOM - return NaN # log(-inf) = nan - -genLog log, ln -func log*[F: SomeFloat](x, base: F): F = - let - num = log(x) - den = log(base) - result = num / den - - -genLog log2, log2 -genLog log10, log10 - - -aliasFF degrees, radToDeg - -aliasFF radians, degToRad - -expM sin -expM sinh -expM cos -expM cosh -expM tan -expM tanh - - -aliasFF asin, arcsin -aliasFF asinh, arcsinh -aliasFF acos, arccos -aliasFF acosh, arccosh -aliasFF atan, arctan -aliasFF atan2, arctan2 -aliasFF atanh, arctanh - - -func comb*(n, k: int): int = - ## .. hint:: Python's math.comb does not accept negative value for n, k - ## but Nim's std/math.binom allows, so this function allows too. - ## For consistent behavior with Python, see `Lib/math.comb<./math.html#comb>`_ - binom(n, k) - -func perm*(n: int): int = - ## equal to `perm(n,n)`, returns `n!` - fac n - -func perm*(n, k: Natural): int = - if k > n: return 0 - result = n - for i in 1..> 2*(c - d)) < (a+1)**2 - let e = d - d = c shr s - a = (a shl d - e - 1) + (n shr (2*c) - e - d + 1) div a - - result = a - if (a*a > n): - result.dec - -func isqrt*(n: Natural): int{.raises: [].} = - runnableExamples: - assert 2 == isqrt 5 - #[ the following is from CPython 3.10.5 source `Modules/mathmodule.c`: - - Here's Python code: - - def isqrt(n): - """ - Return the integer part of the square root of the input. - """ - n = operator.index(n) - - if n < 0: raise ValueError("isqrt() argument must be nonnegative") - if n == 0: return 0 - - c = (n.bit_length() - 1) // 2 - a = 1 - d = 0 - for s in reversed(range(c.bit_length())): - # Loop invariant: (a-1)**2 < (n >> 2*(c - d)) < (a+1)**2 - e = d - d = c >> s - a = (a << d - e - 1) + (n >> 2*c - e - d + 1) // a - - return a - (a*a > n)]# - if n == 0: 0 - else: isqrtPositive(n) - - -func isqrt*[T: SomeFloat](x: T): int{.raises: [].} = - ## .. hint:: assuming x > 0 (raise `RangeDefect` otherwise (if not danger build)) - ## use math.isqrt if expecting raising `ValueError` - let i = Natural(x) - isqrt i - - diff --git a/src/pylib/Lib/n_os.nim b/src/pylib/Lib/n_os.nim deleted file mode 100644 index e84725e17..000000000 --- a/src/pylib/Lib/n_os.nim +++ /dev/null @@ -1,20 +0,0 @@ - -import ../private/trans_imp -impExp os_impl, - consts, posix_like, subp, utils, path, walkImpl, listdirx, randoms, waits, - have_functions, cpus - -when not defined(js): - import ./os_impl/[ - term, inheritable] - export term, set_inheritable, get_inheritable - -genUname string -import ./os_impl/posix_like/sched -when HAVE_SCHED_SETAFFINITY: - proc sched_setaffinity*(pid: int, mask: openArray[int]) = - sched_setaffinityImpl(pid, mask) - proc sched_getaffinity*(pid: int): seq[int] = - sched_getaffinityImpl(pid) do (x: cint): - result.add int x - diff --git a/src/pylib/Lib/n_pathlib.nim b/src/pylib/Lib/n_pathlib.nim deleted file mode 100644 index 4ab5ecea1..000000000 --- a/src/pylib/Lib/n_pathlib.nim +++ /dev/null @@ -1,8 +0,0 @@ - - -import ./pathlib_impl/[ - types, init, segments, meth, os_meth -] - -export types, init, segments, meth, os_meth - diff --git a/src/pylib/Lib/n_random.nim b/src/pylib/Lib/n_random.nim deleted file mode 100644 index cdca2c613..000000000 --- a/src/pylib/Lib/n_random.nim +++ /dev/null @@ -1,7 +0,0 @@ - -import ./random_impl/[ - types, proc_dispatched, proc_others -] - -export types except getmstate -export proc_dispatched, proc_others diff --git a/src/pylib/Lib/n_shutil.nim b/src/pylib/Lib/n_shutil.nim deleted file mode 100644 index c20782bf0..000000000 --- a/src/pylib/Lib/n_shutil.nim +++ /dev/null @@ -1,6 +0,0 @@ - - -import ../private/trans_imp -impExp shutil_impl, - terminals, copys, rmtreeImpl - diff --git a/src/pylib/Lib/n_signal.nim b/src/pylib/Lib/n_signal.nim deleted file mode 100644 index 8dfe6557b..000000000 --- a/src/pylib/Lib/n_signal.nim +++ /dev/null @@ -1,21 +0,0 @@ - -import ./signal_impl/[ - pynsig, signals, signal_util, valid_signals_impl, enums -] - -let NSIG* = int Py_NSIG -export signals, signal_util, enums -export SIG_DFL, SIG_IGN - -import ./signal_impl/unixs -export unixs - -when have_valid_signals: - import std/sets - proc valid_signals*(): HashSet[int] = - result = initHashSet[int]() - result.fill_valid_signals() - -#proc getsignal*(signalnum: int): int = -when isMainModule: - signal(1, SIG_IGN) diff --git a/src/pylib/Lib/n_stat.nim b/src/pylib/Lib/n_stat.nim deleted file mode 100644 index 6b8957212..000000000 --- a/src/pylib/Lib/n_stat.nim +++ /dev/null @@ -1,10 +0,0 @@ - -import ./stat_impl/[ - consts, - isX, - strrepr -] - -export consts except S_IMODE_val, S_IFMT_val -export isX -export strrepr diff --git a/src/pylib/Lib/n_string.nim b/src/pylib/Lib/n_string.nim deleted file mode 100644 index f02ad8e85..000000000 --- a/src/pylib/Lib/n_string.nim +++ /dev/null @@ -1,25 +0,0 @@ - -from std/unicode import nil -from std/strutils import nil -import std/tables -import ../pystring - - -import string_impl/[ - capwordsImpl, consts, templateImpl - ] -export genCapwords -export consts -export templateImpl except genSubstitute - -genCapwords string, string, - unicode.split, strutils.split, unicode.capitalize, strutils.strip - - -genSubstitute(Table, string, substitute, initRaisesExcHandle) -genSubstitute(Table, string, safe_substitute, initIgnoreExcHandle) - -proc get_identifiers*(templ: Template): seq[string] = - for i in get_identifiersMayDup(templ): - if i not_in result: - result.add i diff --git a/src/pylib/Lib/n_sys.nim b/src/pylib/Lib/n_sys.nim deleted file mode 100644 index c2c9dc3f3..000000000 --- a/src/pylib/Lib/n_sys.nim +++ /dev/null @@ -1,23 +0,0 @@ - -import std/options -import ../private/trans_imp - -import ./sys_impl/[ - genplatform, geninfos, genargs -] -template asis[T](x: T): T = x -genPlatform(asis) -genInfos(asis, none(string)) -template append(x: seq, y) = x.add y -genArgs string, seq, asis, asis, newSeqOfCap - -impExp sys_impl, - fenvs, - stdio, - exits, - getencodings, - sizes, - flagsImpl, - auditImpl - - diff --git a/src/pylib/Lib/n_tempfile.nim b/src/pylib/Lib/n_tempfile.nim deleted file mode 100644 index c105e2473..000000000 --- a/src/pylib/Lib/n_tempfile.nim +++ /dev/null @@ -1,309 +0,0 @@ - -import std/os -import std/random -import std/options - -import ./n_os -import ../pyerrors/oserr - -when defined(js): {.error: "pylib tempfile not support JS currently".} -import ./io - -const - True = true - False = false -const - TMP_MAX* = 10000 - -type RandomNameSequence = object - rng_pid: int - rng: Rand - -var name_sequence{.threadvar.}: RandomNameSequence - -const RandChars = "abcdefghijklmnopqrstuvwxyz0123456789_" - -proc initRandomNameSequence(self: var RandomNameSequence) = - let cur_pid = n_os.getpid() - if cur_pid != self.rng_pid: - self.rng = initRand() - self.rng_pid = cur_pid - -iterator items(self: var RandomNameSequence, times: int): string = - self.initRandomNameSequence() - for _ in 1..times: - var letters = newString(8) - for i in 0 ..< 8: - let c = self.rng.sample(RandChars) - letters[i] = c - yield letters - -const templ* = "tmp" # Py's `tempfile.template` - -proc mktempWithChecker(suffix="", prefix=templ, dir = "", checker: proc (s: string): bool=fileExists): string = - for name in name_sequence.items(times=TMP_MAX): - let file = dir / prefix & name & suffix - if not checker file: - return file - raise newException(FileNotFoundError, "No usable temporary filename found") - -proc mktemp*(suffix="", prefix=templ, dir = ""): string = - ## User-callable function to return a unique temporary file/dir name. The - ## file/dir is not created. - mktempWithChecker(suffix, prefix, dir, fileExists) - - -proc candidate_tempdir_list(): seq[string] = - ##[Generate a list of candidate temporary directories which - _get_default_tempdir will try.]## - - # First, try the environment. - for envname in ["TMPDIR", "TEMP", "TMP"]: - let dirname = getenv(envname) - if dirname.len > 0: result.add dirname - - # Failing that, try OS-specific locations. - when n_os.name == "nt": - result.add [ expandTilde(r"~\AppData\Local\Temp"), - getenv("SYSTEMROOT")/"Temp", - r"c:\temp", r"c:\tmp", r"\temp", r"\tmp" ] - else: - result.add [ "/tmp", "/var/tmp", "/usr/tmp" ] - - # As a last resort, the current directory. - try: - result.add n_os.getcwd() - except (#[AttributeError, ]# OSError): - result.add n_os.curdir - -proc init_text_openflags: cint{.inline.} = - result = n_os.O_RDWR or n_os.O_CREAT or n_os.O_EXCL - when declared(n_os.O_NOFOLLOW): - result = result or n_os.O_NOFOLLOW - -let - text_openflags = init_text_openflags() - bin_openflags = - when compiles(n_os.O_BINARY): text_openflags or n_os.O_BINARY - else: text_openflags - -const DWin = defined(windows) - -when DWin: - const W_OK = 2 - proc c_access(path: cstring, mode: cint): cint{.importc: "_access", header: "".} - proc access(path: string, mode: cint): bool = - c_access(path.cstring, mode) == 0 - - -proc get_default_tempdir(): string = - ##[Calculate the default directory to use for temporary files. - This routine should be called exactly once. - - We determine whether or not a candidate temp dir is usable by - trying to create and write to a file in that directory. If this - is successful, the test file is deleted. To prevent denial of - service, the name of the test file must be randomized.]## - - var namer: RandomNameSequence - namer.initRandomNameSequence() - var dirlist = candidate_tempdir_list() - - for ori_dir in dirlist: - let dir = if ori_dir != n_os.curdir: - n_os.path.abspath(ori_dir) - else: - ori_dir - # Try only a few names per directory. - for name in namer.items 100: - let filename = path.join(dir, name) - try: - let fd = n_os.open(filename, bin_openflags, 0o600) - try: - # CPython does followings, - # but I cannot understand why to do so. - # try: - # write(fd, b"blat") - # finally: - # n_os.close(fd) - n_os.close(fd) - finally: - unlink(filename) - return dir - except FileExistsError: - discard - # except PermissionError: - except OSError: - when defined(windows): - if n_os.path.isdir(dir) and - access(dir, W_OK): - # This exception is thrown when a directory with the chosen name - # already exists on windows. - continue - break # no point trying more names in this directory - raise newException(FileNotFoundError, "No usable temporary directory found in " & - $dirlist) - - -when not defined(js) and not defined(nimscript): - import std/locks - var lock: Lock - lock.initLock() - template lock_tempdir(body) = - withLock lock: body -else: - template lock_tempdir(body) = body - -var tempdir*{.threadvar.}: string - -proc gettempdir*(): string = - ## XXX: TODO: gettempdir() should be considered os.fsencode/fsdecode? - if tempdir.len == 0: - lock_tempdir: - tempdir = get_default_tempdir() - return tempdir - -proc gettempprefix*(): string = - ## Return the default prefix string used by mktemp(). - ## This is 'tmp' on most systems.] - return templ - -type SOption = Option[string] - -const sNone = none[string]() - -converter sToOpt*(s: string): SOption = - some[string](s) - -proc sanitize_params(prefix, suffix, dir: SOption): tuple[prefix, suffix, dir: string] = - - result.suffix = suffix.get("") - result.prefix = prefix.get templ - result.dir = dir.get gettempdir() - -type - TemporaryFileCloser*[IO: IOBase] = ref object - file*: IO - name*: string - delete, close_called: bool - - TemporaryFileWrapper*[IO] = object - closer: TemporaryFileCloser[IO] - -template name*(self: TemporaryFileWrapper): string = self.closer.name - -import std/macros -macro gen(opName: untyped): untyped = - let selfId = ident"self" - quote do: - template `opName`*[IO](`selfId`: TemporaryFileWrapper[IO], - args: varargs[typed]): untyped = unpackVarargs `selfId`.closer.file.`opName`, args - -gen write -proc flush*[IO](self: TemporaryFileWrapper[IO]) = flush(self.closer.file) -gen read -gen readline -gen seek -gen tell - -proc close*[IO](self: TemporaryFileCloser[IO], unlink=os.removeFile) = - try: - var f = self.file - f.close() - finally: - if self.delete: - unlink(self.name) - -proc close*(t: TemporaryFileWrapper) = - t.closer.close() - - -proc newTemporaryFileCloser[IO](file: IO, name: string, delete=True): TemporaryFileCloser[IO] = - new result - result.file = file - result.name = name - result.delete = delete - result.close_called = false - - -proc newTemporaryFileWrapper[IO](closer: TemporaryFileCloser[IO]): TemporaryFileWrapper[IO] = - result.closer = closer - -template NamedTemporaryFile*(mode: static[string|char] = "w+b", buffering = -1, - encoding=DefEncoding, - newline=DefNewLine, suffix=sNone, prefix=sNone, - dir=sNone, delete=True, errors=DefErrors): TemporaryFileWrapper = - runnableExamples: - var tempf = NamedTemporaryFile("w+t") - let msg = "test" - tempf.write(msg) - tempf.flush() - tempf.seek(0) - let s = tempf.read() - assert s == msg - - import std/os - assert fileExists tempf.name - tempf.close() - assert not fileExists tempf.name - bind TemporaryFileWrapper, newTemporaryFileWrapper, open, sNone, sanitize_params, mktemp - let - tup = sanitize_params(prefix, suffix, dir) - name = mktemp(tup[1], tup[0], tup[2]) - - var file = open(name, mode, buffering, - encoding, errors, newline) - var closer = newTemporaryFileCloser[typeof(file)](file, name, delete) - var result = newTemporaryFileWrapper closer - result - - -type TemporaryDirectoryWrapper* = object - name*: string - ignore_cleanup_errors, delete: bool - -proc auditThenDirExists(s: string): bool = - sys.audit("tempfile.mkdtemp", s) - dirExists(s) - -proc mkdtemp*(suffix=sNone, prefix=sNone, dir=sNone): string = - let tup = sanitize_params(prefix=prefix, suffix=suffix, dir=dir) - mktempWithChecker(dir=tup.dir, suffix=tup.suffix, prefix=tup.prefix, - checker=auditThenDirExists) - -proc TemporaryDirectory*(suffix=sNone, prefix=sNone, dir=sNone, ignore_cleanup_errors=False, - delete=True): TemporaryDirectoryWrapper = - runnableExamples: - import std/os - let d = TemporaryDirectory() - assert dirExists d.name - d.cleanup() - assert not dirExists d.name - let tup = sanitize_params(suffix=suffix, prefix=prefix, dir=dir) - result.name = mkdtemp(suffix=tup.suffix, prefix=tup.prefix, dir=tup.dir) - result.delete = delete - result.ignore_cleanup_errors = ignore_cleanup_errors - createDir result.name - - -proc cleanup*(self: TemporaryDirectoryWrapper) = - if self.delete: - tryOsOp not self.ignore_cleanup_errors: - removeDir self.name - # XXX: see Py's TemporaryDirectory._rmtree for real impl - -proc close*(self: TemporaryDirectoryWrapper) = - ## used to be called in `with` stmt (Python's doesn't have this) - try: self.cleanup() - except Exception: discard - -template sinceNim(ma, mi, pa): bool = - (NimMajor, NimMinor, NimPatch) >= (ma, mi, pa) -const Js = defined(js) -when not Js and sinceNim(2,1,1) or - Js and sinceNim(2,3,2): - ## XXX: FIXED-NIM-BUG: though nimAllowNonVarDestructor is defined at least since 2.0.6, - ## it still cannot be compiled till about 2.1.1 - proc `=destroy`*(self: TemporaryDirectoryWrapper) = self.close() -else: - proc `=destroy`*(self: var TemporaryDirectoryWrapper) = self.close() diff --git a/src/pylib/Lib/n_time.nim b/src/pylib/Lib/n_time.nim deleted file mode 100644 index 79b511bb2..000000000 --- a/src/pylib/Lib/n_time.nim +++ /dev/null @@ -1,66 +0,0 @@ -##[ -# time for Nim - -the only difference with Python's is where some types in time is `str`, -there is `string` in `n_time`'s. - -e.g. `n_time.ctime()` returns a string - -## py diff - -Currently, -`tm_name` is either "LOCAL" or "Etc/UTC", due to std/times only returning those two. - - -]## - -#[ -## impl note -Some note about implement details the different between std/times and Python's times - -std/times DateTime's utcOffset is opposed to struct_time.tm_gmtoff -e.g. in the east, DateTime.utcOffset is negative. -]# - -import std/times -import ./time_impl/[ - types, converters, strfptime, asctimeImpl, - struct_time_funcs, - sleep_impl, measures -] -fetchDoc(docTable) -export fetchDoc, docTable - -export sleep, measures -export types except isUtcZone, initStructTime -export toTuple -export struct_time_funcs - -export strfptime - - -const DefaultTimeFormat* = "%a %b %d %H:%M:%S %Y" - -proc asctime*(): string = asctime now() -func asctime*(t: struct_time): string = - # do not use: - # strftime DefaultTimeFormat, t - # as %d is not space-padding, but '0'-padding - var dt: DateTime - structTimeToDt t, dt - asctime dt - -wrapTuple asctime - -proc ctime*(): string = asctime now() - -proc ctime*(secs: float|int64): string = - asctime localtime secs - -proc strftime*(format: string): string{.fetchDoc(docTable).} = - strftime(format, localtime()) - -proc strptime*(s: string): struct_time{.fetchDoc(docTable).} = - strptime(s, DefaultTimeFormat) - - diff --git a/src/pylib/Lib/n_timeit.nim b/src/pylib/Lib/n_timeit.nim deleted file mode 100644 index baf2e0bd2..000000000 --- a/src/pylib/Lib/n_timeit.nim +++ /dev/null @@ -1,181 +0,0 @@ -## n_timeit: timeit for Nim. -## -## see `Lib/timeit`_ for python compatiable APIs - - -import std/[ - strutils, times, macros -] - - -const - default_number* = 1000000 - default_repeat* = 5 ## since python 3.7: default value of `repeat` parameter is changed from 3 to 5. - - -func default_timer_defval(): float = - ## default value of default_timer - {.noSideEffect.}: - let t = getTime() - t.toUnixFloat - -var default_timer* = default_timer_defval - -template cpuTimeImpl(): untyped = - when defined(js): now() else: cpuTime() - -template timeit*(repetitions: int, statements: untyped) = - ## EXT. - ## unstable. - ## - ## returns nothing but send output to stdout. - ## - ## output shows more information than Pythons. - runnableExamples: - var i = 0 - timeit(10): - i.inc - assert i == 10 - bind times.`$`, times.`-`, now, format, cpuTimeImpl - let - started = now() - cpuStarted = cpuTimeImpl() - for _ in 1 .. repetitions: - statements - echo "$1 TimeIt: $2 Repetitions on $3, CPU Time $4.".format( - $now(), repetitions, $(now() - started), $(cpuTimeImpl() - cpuStarted)) - -macro exec(s: static[string]) = parseStmt s - -type - NullaryFunc* = concept self ## `Callable[[], Any]` - self() - TimeitParam* = string|NullaryFunc -const NullStmt* = "discard" - -template execTP(s: TimeitParam) = - bind exec - when compiles((let _ = s())): - let _ = s() - elif compiles(s()): s() - else: exec s - -type - Code = object - f: proc() - -proc newCode(tp: TimeitParam): Code = - when tp is string: - {.error: """ -here TimeitParam cannot be string, -because Nim is a compile-language, storing code at runtime is impossible, -and implementing compile-time functionality is not worthy""".} - else: - result.f = proc() = - when compiles((let _ = tp())): - let _ = tp() - else: tp() - -template parseCode(c: Code): untyped = - c.f() - -type - Timer* = ref object - timer: typeof(default_timer) - stmt, setup: Code - -proc newTimer*( - stmt: TimeitParam = NullStmt; - setup: TimeitParam = NullStmt; - timer=default_timer, number=default_number): Timer = - Timer( - timer: timer, - stmt: newCode stmt, - setup: newCode setup, - ) - -template timeitImpl(number: int; timer: typed; setupBody, stmtBody): float = - setupBody - let started = timer() - for _ in 1 .. number: - stmtBody - timer() - started - - -template timeit*(self: Timer, number=default_number): float = - bind timeitImpl, parseCode - timeitImpl(number, self.timer, - (parseCode self.setup), - (parseCode self.stmt) - ) - -template timeit*( - stmt: TimeitParam = NullStmt; - setup: TimeitParam = NullStmt; - timer=default_timer, number=default_number): float = - ## timeit(stmt, setup, number=1000000) with globals is `globals()|locals()` - ## - ## stmt, setup are Callable or str literal - ## - runnableExamples: - discard timeit("i.inc", "var i = 0") - assert i != 0 - - proc f() = discard - discard timeit(f) - proc retf(): int = 1 - discard timeit(retf) - bind execTP, timeitImpl - timeitImpl(number, timer, - (execTP setup), - (execTP stmt) - ) - - -template repeatImpl(repeatExpr: int; doBody): seq[float] = - var r = newSeq[float](repeatExpr) - for i in 0..r.high: - r[i] = doBody - r - -template repeat*( - stmt: TimeitParam = NullStmt; - setup: TimeitParam = NullStmt; - timer=default_timer, repeat=default_repeat, number=default_number): seq[float] = - bind repeatImpl, timeit - repeatImpl(repeat, timeit(stmt, setup, timer, number)) - -template repeat*(self: Timer, repeat=default_repeat, number=default_number): seq[float] = - bind repeatImpl, timeit - repeatImpl(repeat, timeit(self, number)) - -template autorange*(self: Timer, callable: - proc(number: int, time_taken: float) = nil): (int, float) = - bind timeit - var i = 1 - var - number: int - time_taken: float - while true: - for j in [1, 2, 5]: - number = i * j - time_taken = timeit(self, number) - if not callback.isNil: - callback(number, time_taken) - if time_taken >= 0.2: - return (number, time_taken) - i *= 10 - -when defined(nimdoc): - proc print_exc*(self: Timer, file: auto = nil) = - ## .. hint:: Currently its implementation is based - ## on `system.getStackTrace`, which is different from Python's -else: - when not defined(debug): - proc print_exc*(self: Timer, file: auto = nil){.error: "only available on debug build".} - else: - proc print_exc*(self:Timer, file: auto = nil) = - when file.isNil: - writeStackTrace() - else: - file.write getStackTrace() diff --git a/src/pylib/Lib/ncodec.nim b/src/pylib/Lib/ncodec.nim deleted file mode 100644 index d924e1d36..000000000 --- a/src/pylib/Lib/ncodec.nim +++ /dev/null @@ -1,81 +0,0 @@ -## EXT. Nim's codec. -## not the same as Python's codec - -import std/encodings -import std/unicode -import ../pyerrors/lkuperr -export LookupError - -# XXX: not take effect yet -type EncErrors*{.pure.} = enum - strict ## - raise a ValueError error (or a subclass) - ignore ## - ignore the character and continue with the next - replace ##[ - replace with a suitable replacement character; - Python will use the official U+FFFD REPLACEMENT - CHARACTER for the builtin Unicode codecs on - decoding and "?" on encoding.]## - surrogateescape ## - replace with private code points U+DCnn. - xmlcharrefreplace ## - Replace with the appropriate XML - ## character reference (only for encoding). - backslashreplace ## - Replace with backslashed escape sequences. - namereplace ## - Replace with \N{...} escape sequences - ## (only for encoding). - -type - CvtRes = tuple[data: string, len: int] - EncoderCvt = proc (s: string): CvtRes - EncoderClose = proc () - NCodecInfo* = object - name*: string - errors*: string - encode*, decode*: EncoderCvt - close*: EncoderClose - -const - DefErrors* = "strict" - -# patch -# nim's implementation assumed iconv_open returns NULL on failure, -# which is `(iconv_t) -1` in fact. -const openFixed = (NimMajor, NimMinor, NimPatch) > (2, 1, 1) -proc encodings_open( - destEncoding = "UTF-8"; srcEncoding = "CP1252"; - errors=DefErrors # XXX: just ignored - ): EncodingConverter = - when openFixed or defined(windows): - encodings.open(destEncoding=destEncoding, srcEncoding=srcEncoding) - else: - let cvt = encodings.open(destEncoding=destEncoding, srcEncoding=srcEncoding) - if cvt == cast[EncodingConverter](-1): - raise newException(EncodingError, - "cannot create encoding converter from " & - srcEncoding & " to " & destEncoding) - cvt - -const innerEnc = "UTF-8" -func initNCodecInfo*(encoding: string, errors = DefErrors): NCodecInfo = - result.name = encoding - var iEncCvt, oEncCvt: EncodingConverter - try: - iEncCvt = encodings_open( - destEncoding = innerEnc, - srcEncoding = encoding, - errors = errors - ) - oEncCvt = encodings_open( - destEncoding = encoding, - srcEncoding = innerEnc, - errors = errors - ) - except EncodingError: - raise newException(LookupError, "unknown encoding: " & encoding) - result.encode = proc (s: string): CvtRes = - result.data = oEncCvt.convert(s) - result.len = s.runeLen - result.decode = proc(s: string): CvtRes = - result.data = iEncCvt.convert(s) - result.len = s.len - result.close = proc() = - oEncCvt.close() - iEncCvt.close() - diff --git a/src/pylib/Lib/os.nim b/src/pylib/Lib/os.nim deleted file mode 100644 index fcfef16c7..000000000 --- a/src/pylib/Lib/os.nim +++ /dev/null @@ -1,54 +0,0 @@ -## see docs.python.org/3/library/os.html -## -## Also export everything of std/os -## -## .. warning:: export of std/os will be removed in 0.10.0 - -import std/os as std_os -export std_os - -import ./os_impl/private/platform_utils -import ../pyconfig/bootstrap_hash - -import ./n_os -export n_os except scandir, DirEntry, urandom, getrandom, genUname, uname, uname_result, - sched_getaffinity, sched_setaffinity, - cpu_count, process_cpu_count -import ./typing_impl/optional_obj -expOptObjCvt() -import ../version -genUname PyStr -template scandir*(): untyped{.pysince(3,5).} = n_os.scandir() -template scandir*[T](p: PathLike[T]): untyped{.pysince(3,5).} = n_os.scandir(p) -template scandir*(p: int): untyped{.pysince(3,5).} = n_os.scandir(p) -pysince(3,5): - export DirEntry - -template close*(p: DirEntry){.pysince(3,6).} = discard - -proc urandom*(size: int): PyBytes = - bytes n_os.urandom(size) - -proc getrandom*(size: int, flags = 0): PyBytes{. - platformAvailWhen(linux, have_getrandom_syscall), pysince(3,6).} = - bytes n_os.getrandom(size, flags) - -import ./os_impl/posix_like/sched -when HAVE_SCHED_SETAFFINITY: - from ./collections/abc import Iterable - import ../builtins/set - proc sched_setaffinity*(pid: int, mask: Iterable[int]) = - sched_setaffinityImpl(pid, mask) - proc sched_getaffinity*(pid: int): PySet[int] = - result = newPySet[int]() - sched_getaffinityImpl(pid) do (x: cint): - result.add int x - -template wrapMayNone(name){.dirty.} = - proc name*(): OptionalObj[int] = - let res = n_os.name() - if res > 0: newOptionalObj(res) - else: newOptionalObj[int]() - -wrapMayNone cpu_count -wrapMayNone process_cpu_count diff --git a/src/pylib/Lib/os_impl/README.md b/src/pylib/Lib/os_impl/README.md deleted file mode 100644 index bb4a9413c..000000000 --- a/src/pylib/Lib/os_impl/README.md +++ /dev/null @@ -1,9 +0,0 @@ - -`os` as a directory is because: - -os and io mutually depends on each other: - -- os.fdopen depends on io.open (as io.open has implemented the case where its first argument `file` is int) -- io depends on some os's functions, like `ftruncate` - -To handle this circular dependency, os is splited as several modules into this directory. diff --git a/src/pylib/Lib/os_impl/common.nim b/src/pylib/Lib/os_impl/common.nim deleted file mode 100644 index e4b0d1e38..000000000 --- a/src/pylib/Lib/os_impl/common.nim +++ /dev/null @@ -1,21 +0,0 @@ - -import ./private/defined_macros -import ../sys_impl/auditImpl as sys -export InJs -import ../../pyerrors/[oserr, simperr, rterr] -when defined(js): - import ../../pyerrors/jsoserr - export jsoserr - - import ../../jsutils/denoAttrs - export denoAttrs -import ../../io_abc -import ../../noneType -import ../../pystring/[strimpl, strbltins] -import ../../pybytes/[bytesimpl, bytesbltins] -import ../../version -export version -export sys -export io_abc, oserr, simperr, rterr, strimpl, strbltins.repr, bytesimpl, bytesbltins.repr -export noneType - diff --git a/src/pylib/Lib/os_impl/consts.nim b/src/pylib/Lib/os_impl/consts.nim deleted file mode 100644 index fe9f2830b..000000000 --- a/src/pylib/Lib/os_impl/consts.nim +++ /dev/null @@ -1,117 +0,0 @@ - -import std/os -import std/macros -import ./common -import ../../pyconfig/os_consts -export os_consts - -## SEEK_* is in ./posix_like/seek_c - -macro expLower(sym) = - var s = sym.strVal - s[0] = char(s[0].int - 32) - let toId = ident s - quote do: - let `sym`* = str `toId` - -expLower curdir -expLower pardir -expLower extsep -expLower pathsep -expLower altsep - -let - linesep* = str("\p") - sep* = str DirSep - -const DW = defined(windows) - -when defined(nimdoc): - const - OsDifferContent = "" - devnull*: PyStr = OsDifferContent - defpath*: PyStr = OsDifferContent - name*: PyStr = OsDifferContent ##[ - -"nt" when windows, "posix" when posix; - -.. note:: when in neither Windows nor POSIX, - os.name will be defined as `str(hostOS)` iff - `pylibOsName` is defined when compiling -]## - -else: - when DW: - const - name* = str "nt" - devnull* = str "nul" - defpath* = str ".;C:\\bin" - else: - when defined(posix): - const name* = str "posix" - elif defined(pylibOsName): - const name* = str hostOs - const - devnull* = str "/dev/null" - defpath* = str "/bin:/usr/bin" - -macro pwULexp(i; header: string = "") = - ## POSIX/Windows `importc` and export - ## add prefix underline when `importc` under Windows - when defined(js): - result = quote do: - let `i`*{.importNode(fs, constants.`i`).}: cint - else: - let - strv = i.strVal - cn = when DW: '_' & strv else: strv - cnn = newLit cn - result = quote do: - let `i`*{.importc: `cnn`, header: `header`.}: cint - -pwULexp O_RDONLY -pwULexp O_WRONLY -pwULexp O_RDWR -pwULexp O_APPEND -pwULexp O_CREAT -pwULexp O_EXCL -pwULexp O_TRUNC - -when DW: - macro uLexp(i; header: string = "") = - ## POSIX/Windows `importc` and export - ## add prefix underline when `importc` under Windows - let - strv = i.strVal - cn = '_' & strv - cnn = newLit cn - result = quote do: - let `i`*{.importc: `cnn`, header: `header`.}: cint - - uLexp O_BINARY - uLexp O_NOINHERIT - uLexp O_SHORT_LIVED - pwULexp O_TEMPORARY - pwULexp O_RANDOM - pwULexp O_SEQUENTIAL - pwULexp O_TEXT -elif defined(unix): - # no underline: `importc: "O_*"` - pwULexp O_DSYNC - pwULexp O_RSYNC - pwULexp O_SYNC - pwULexp O_NDELAY - pwULexp O_NONBLOCK - pwULexp O_NOCTTY - pwULexp O_CLOEXEC - -when defined(macosx): - pwULexp O_EVTONLY - pwULexp O_FSYNC - pwULexp O_SYMLINK - pwULexp O_NOFOLLOW_ANY - - - -template `|`*(a,b: cint): cint = a or b -template `|=`*(a,b: cint) = a = a or b diff --git a/src/pylib/Lib/os_impl/cpus.nim b/src/pylib/Lib/os_impl/cpus.nim deleted file mode 100644 index 4e15d5226..000000000 --- a/src/pylib/Lib/os_impl/cpus.nim +++ /dev/null @@ -1,22 +0,0 @@ - -import std/cpuinfo - -const vxworks = defined(vxworks) - -when vxworks: - import std/bitops - proc vxCpuEnabledGet(): uint32{.importc, header: "".} - -proc cpu_count*(): int = - when vxworks: - popcount vxCpuEnabledGet() - else: - countProcessors() - -import ./posix_like/sched -when HAVE_SCHED_SETAFFINITY: - proc process_cpu_count*(): int = - sched_getaffinityImpl(0) do (_: cint): - inc result -else: - proc process_cpu_count*(): int = cpu_count() diff --git a/src/pylib/Lib/os_impl/have_functions.nim b/src/pylib/Lib/os_impl/have_functions.nim deleted file mode 100644 index 58e05b03a..000000000 --- a/src/pylib/Lib/os_impl/have_functions.nim +++ /dev/null @@ -1,178 +0,0 @@ - -import ../../pyconfig/[ - os, chmods, stats, -] -{.push warning[UnusedImport]: off.} -import ./posix_like # used at compile-time -{.pop.} - -import std/sets -import std/macros - -type - HaveFuncOrig = HashSet[string] - HaveFunc = distinct HaveFuncOrig -proc incl(s: var HaveFunc, i: string){.borrow.} -proc contains(s: HaveFunc, i: string): bool{.borrow.} -proc len(s: HaveFunc): int{.borrow.} - -proc `$`*(s: HaveFunc): string = - result = "{" - if s.len == 0: - result.add '}' - return - for i in HaveFuncOrig s: - result.add i # no quote - result.add ", " - let le1s = result.len-1 - result.setLen le1s - result[le1s-1] = '}' - -func removeOsPrefix(fn: string): string = - if fn.len < 3: - return fn - if fn[0] == 'o' and fn[1] == 's' and fn[2] == '.': - return fn[3..^1] - fn - -template contains*(s: HaveFunc; fn: untyped): bool = - bind contains, removeOsPrefix - s.contains astToStr(fn).removeOsPrefix - -proc multiContainsImpl(s, fns: NimNode): NimNode = - result = newLit(true) - for fn in fns: - result = infix(result, - "and", - newCall(bindSym"contains", s, fn), - ) - -macro contains*(s: HaveFunc; fns: varargs[untyped]): bool = - ## used for `{xxx, ...} <= s` - multiContainsImpl(s, fns) - -macro issuperset*(s: HaveFunc; fns: untyped): bool = - ## used for `{xxx, ...} <= s` - multiContainsImpl(s, fns) - -template `>=`*(s: HaveFunc, fns): bool = - bind issuperset - s.issuperset(fns) - -# Not work for even `(x, ...) <= s`: -template `<=`*(fns: untyped; s: HaveFunc): bool = - bind issuperset - s.issuperset(fns) - -const MS_WINDOWS = defined(windows) -template reset_set(name){.dirty.} = - var `v name`{.compileTime.} = HaveFunc initHashSet[string]() - template sset: untyped{.redefine.} = `v name` - -template sset_add(fn) = - static: - sset.add astToStr fn - -template sadd(str, fn) = - when declared(fn) and declared(str): - when str: - static: - sset_add fn - -template exp(n) = - const n* = `v n` - -#[ -reset_set supports_dir_fd -sadd HAVE_OPENAT, os.open, os.stat, os.unlink, os.rmdir} - -reset_set supports_fd -sadd HAVE_FDOPENDIR, scandir - -os.stat in os.supports_follow_symlinks -]# - - -when true: - reset_set supports_dir_fd - template add(s: HaveFunc; fn: string) = - bind incl - s.incl fn - - sadd(HAVE_FACCESSAT, access) - sadd(HAVE_FCHMODAT, chmod) - sadd(HAVE_FCHOWNAT, chown) - sadd(HAVE_FSTATAT, stat) - sadd(HAVE_FUTIMESAT, utime) - sadd(HAVE_LINKAT, link) - sadd(HAVE_MKDIRAT, mkdir) - sadd(HAVE_MKFIFOAT, mkfifo) - sadd(HAVE_MKNODAT, mknod) - sadd(HAVE_OPENAT, open) - sadd(HAVE_READLINKAT, readlink) - sadd(HAVE_RENAMEAT, rename) - sadd(HAVE_SYMLINKAT, symlink) - sadd(HAVE_UNLINKAT, unlink) - sadd(HAVE_UNLINKAT, rmdir) - sadd(HAVE_UTIMENSAT, utime) - - reset_set supports_effective_ids - sadd(HAVE_FACCESSAT, access) - - reset_set supports_fd - sadd(HAVE_FCHDIR, chdir) - sadd(HAVE_FCHMOD, chmod) - sadd(MS_WINDOWS, chmod) - sadd(HAVE_FCHOWN, chown) - sadd(HAVE_FDOPENDIR, listdir) - sadd(HAVE_FDOPENDIR, scandir) - sadd(HAVE_FEXECVE, execve) - sset_add(stat) # fstat always works - sadd(HAVE_FTRUNCATE, truncate) - sadd(HAVE_FUTIMENS, utime) - sadd(HAVE_FUTIMES, utime) - sadd(HAVE_FPATHCONF, pathconf) - if declared(statvfs) and declared(fstatvfs): # mac os x10.3 - sadd(HAVE_FSTATVFS, statvfs) - - reset_set supports_follow_symlinks - sadd(HAVE_FACCESSAT, access) - # Some platforms don't support lchmod(). Often the function exists - # anyway, as a stub that always returns ENOSUP or perhaps EOPNOTSUPP. - # (No, I don't know why that's a good design.) ./configure will detect - # this and reject it--so HAVE_LCHMOD still won't be defined on such - # platforms. This is Very Helpful. - # - # However, sometimes platforms without a working lchmod() *do* have - # fchmodat(). (Examples: Linux kernel 3.2 with glibc 2.15, - # OpenIndiana 3.x.) And fchmodat() has a flag that theoretically makes - # it behave like lchmod(). So in theory it would be a suitable - # replacement for lchmod(). But when lchmod() doesn't work, fchmodat()'s - # flag doesn't work *either*. Sadly ./configure isn't sophisticated - # enough to detect this condition--it only determines whether or not - # fchmodat() minimally works. - # - # Therefore we simply ignore fchmodat() when deciding whether or not - # os.chmod supports follow_symlinks. Just checking lchmod() is - # sufficient. After all--if you have a working fchmodat(), your - # lchmod() almost certainly works too. - # - # sadd(HAVE_FCHMODAT, chmod) - sadd(HAVE_FCHOWNAT, chown) - sadd(HAVE_FSTATAT, stat) - sadd(HAVE_LCHFLAGS, chflags) - sadd(HAVE_LCHMOD, chmod) - sadd(MS_WINDOWS, chmod) - if declared(lchown): # mac os x10.3 - sadd(HAVE_LCHOWN, chown) - sadd(HAVE_LINKAT, link) - sadd(HAVE_LUTIMES, utime) - sadd(HAVE_LSTAT, stat) - sadd(HAVE_FSTATAT, stat) - sadd(HAVE_UTIMENSAT, utime) - sadd(MS_WINDOWS, stat) - -exp supports_dir_fd -exp supports_effective_ids -exp supports_fd -exp supports_follow_symlinks diff --git a/src/pylib/Lib/os_impl/inheritable.nim b/src/pylib/Lib/os_impl/inheritable.nim deleted file mode 100644 index 0a891452c..000000000 --- a/src/pylib/Lib/os_impl/inheritable.nim +++ /dev/null @@ -1,187 +0,0 @@ - -# XXX: this shall work `when defined(freertos) or defined(zephyr)` -# but is is meaningful? -import ./private/[platform_utils, iph_utils, defined_macros] -import ../../pyerrors/oserr - -when MS_WINDOWS: - import std/winlean - from std/os import raiseOSError - import ./util/get_osfhandle - -else: - import std/posix - const SupportIoctlInheritCtl = (defined(linux) or defined(bsd)) and - not defined(nimscript) - # XXX: hard to express as following in Nim - # defined(HAVE_SYS_IOCTL_H) && defined(FIOCLEX) && defined(FIONCLEX) - when SupportIoctlInheritCtl: - {.push header: "".} - let FIOCLEX{.importc.}: uint - let FIONCLEX{.importc.}: uint - {.pop.} - -# === get_inheritable === - -template ifRaiseThenErrnoOrN1 = - if ifRaise: - raiseErrno() - return -1 - -when MS_WINDOWS: - template ifRaiseThenWinErr0OrN1(ifRaise: bool) = - if ifRaise: - # in Windows, raiseOSError raises Windows Error - raiseOSError OSErrorCode 0 - return -1 - - proc get_handle_inheritableImpl(handle: Handle, ifRaise: bool): int = - var flags: DWORD - if not bool getHandleInformation(handle, flags.addr): - ifRaiseThenWinErr0OrN1 ifRaise - return flags.int and HANDLE_FLAG_INHERIT.int - - proc set_handle_inheritableImpl(handle: Handle, inheritable, ifRaise: bool): int = - let flags = DWORD: - if inheritable: HANDLE_FLAG_INHERIT else: 0 - if not bool setHandleInformation(handle, HANDLE_FLAG_INHERIT, flags): - ifRaiseThenWinErr0OrN1 ifRaise - return 0 - -proc get_handle_inheritable*(handle: int): bool{.platformAvail(windows).} = - bool get_handle_inheritableImpl(Handle handle, true) - -proc set_handle_inheritable*(handle: int, inheritable: bool){.platformAvail(windows).} = - discard set_handle_inheritableImpl(Handle handle, inheritable, true) - -proc get_inheritable(fd: int, ifRaise: bool): int = - when MS_WINDOWS: - let handle = Py_get_osfhandle_noraise fd - if handle == INVALID_HANDLE_VALUE: - ifRaiseThenErrnoOrN1 - return get_handle_inheritableImpl(handle, ifRaise) - else: - let flags = fcntl(fd.cint, F_GETFD) - if flags == -1: - ifRaiseThenErrnoOrN1 - return int(not bool(flags and FD_CLOEXEC)) - -proc get_inheritable*(fd: int): bool = - with_Py_SUPPRESS_IPH: - result = bool get_inheritable(fd, true) - # as ifRaise == true, the returned value cannot be -1, - # but raise Exception on error - -# === set_inheritable === - -when not MS_WINDOWS: - {.emit:"""/*VARSECTION*/ - static const int _defined_O_PATH = - #if defined(O_PATH) - 1 - #else - 0 - #endif - ; // defined shall only occur after #if/#elif - """.} - - let - c_defined_O_PATH{.importc: "_defined_O_PATH", nodecl.}: cint - defined_O_PATH = bool c_defined_O_PATH - - #import std/sysatomics # already export by system - - proc Py_atomic_load_relaxed[T](obj: ptr T): T = - atomicLoadN obj, ATOMIC_RELAXED - proc Py_atomic_store_relaxed[T](obj: ptr T, value: T) = - atomicStoreN obj, value, ATOMIC_RELAXED - -proc set_inheritable(fd: int, inheritable: bool, ifRaise: bool, atomic_flag_works: ptr int): int = - ##[ there are setInheritable in std/syncio, - which, however: - - not available for evary platform. - - accept Handle which still need get_osfhandle/fcntl to get from `fd` - - don't try "fast-path" and try fallback - - don't respect what we do in `block check_errno` - ]## - # atomic_flag_works can only be used to make the file descriptor - # non-inheritable - let atomic_fw_nNil = not atomic_flag_works.isNil - assert not (atomic_fw_nNil and inheritable) - if atomic_fw_nNil and not inheritable: - if atomic_flag_works[] == -1: - let isInheritable = get_inheritable(fd, ifRaise) - if isInheritable == -1: - return -1 - atomic_flag_works[] = int bool isInheritable - - if bool atomic_flag_works[]: - return 0 - when MS_WINDOWS: - let handle = Py_get_osfhandle_noraise FileHandle fd - if handle == INVALID_HANDLE_VALUE: - ifRaiseThenErrnoOrN1 - return set_handle_inheritableImpl(handle, inheritable, ifRaise) - else: - let fd = cint fd - when SupportIoctlInheritCtl: - var ioctl_works{.global.} = -1 - if ifRaise and Py_atomic_load_relaxed(ioctl_works.addr) != 0: - # fast-path: ioctl() only requires one syscall - #[ caveat: raise=0 is an indicator that we must be async-signal-safe - thus avoid using ioctl() so we skip the fast-path. ]# - let requested = - if inheritable: FIONCLEX - else: FIOCLEX - let err = ioctl(fd, requested, nil) - if err == 0: - if Py_atomic_load_relaxed(ioctl_works.addr) == -1: - Py_atomic_store_relaxed(ioctl_works.addr, 1) - return 0 - - block check_errno: - if errno != ENOTTY and errno != EACCES: - if defined_O_PATH: - if errno == EBADF: - #[bpo-44849: On Linux and FreeBSD, ioctl(FIOCLEX) fails with EBADF - on O_PATH file descriptors. Fall through to the fcntl() - implementation. ]# - break check_errno - ifRaiseThenErrnoOrN1 - else: - #[Issue #22258: Here, ENOTTY means "Inappropriate ioctl for - device". The ioctl is declared but not supported by the kernel. - Remember that ioctl() doesn't work. It is the case on - Illumos-based OS for example. - - Issue #27057: When SELinux policy disallows ioctl it will fail - with EACCES. While FIOCLEX is safe operation it may be - unavailable because ioctl was denied altogether. - This can be the case on Android.]# - Py_atomic_store_relaxed(ioctl_works.addr, 0) - # fallback to fcntl() if ioctl() does not work - # low-path: fcntl() requires two syscalls - let flags = fcntl(fd, F_GETFD) - if flags < 0: - ifRaiseThenErrnoOrN1 - let new_flags = - if inheritable: flags and not FD_CLOEXEC - else: flags or FD_CLOEXEC - if new_flags == flags: - # FD_CLOEXEC flag already set/cleared: nothing to do - return 0 - let res = fcntl(fd, F_SETFD, new_flags) - if res < 0: - ifRaiseThenErrnoOrN1 - return 0 - -proc Py_set_inheritable*(fd: int, inheritable: bool, atomic_flag_works: ptr int): int = - # used by socket, etc - set_inheritable(fd, inheritable, true, atomic_flag_works) - -proc set_inheritableImpl*(fd: int; inheritable: bool) = - with_Py_SUPPRESS_IPH: - discard Py_set_inheritable(fd, inheritable, nil) - -proc set_inheritable*(fd: int; inheritable: int|bool) = - set_inheritableImpl(fd, bool inheritable) diff --git a/src/pylib/Lib/os_impl/listcommon.nim b/src/pylib/Lib/os_impl/listcommon.nim deleted file mode 100644 index a5b7c03de..000000000 --- a/src/pylib/Lib/os_impl/listcommon.nim +++ /dev/null @@ -1,3 +0,0 @@ - -import ../../builtins/list as listlib -export listlib diff --git a/src/pylib/Lib/os_impl/listdirx.nim b/src/pylib/Lib/os_impl/listdirx.nim deleted file mode 100644 index 698560e5f..000000000 --- a/src/pylib/Lib/os_impl/listdirx.nim +++ /dev/null @@ -1,11 +0,0 @@ - -import std/os -import ./common -import ./listcommon - -proc listdir*[T](p: PathLike[T] = "."): PyList[T] = - sys.audit("os.listdir", p) - result = newPyList[T]() - p.tryOsOp: - for i in walkDir($p, relative=true, checkDir=true): - result.append i.path diff --git a/src/pylib/Lib/os_impl/osJsPatch.nim b/src/pylib/Lib/os_impl/osJsPatch.nim deleted file mode 100644 index 34d051311..000000000 --- a/src/pylib/Lib/os_impl/osJsPatch.nim +++ /dev/null @@ -1,33 +0,0 @@ - - -when defined(js): - import std/jsffi - from ./common import catchJsErrAsCode, catchJsErrAndRaise, PathLike - import ./posix_like/jsStat - template existsWrap(existsX, isX) = - proc existsX*(d: string): bool = - var s: Stat - let err = catchJsErrAsCode: - s = statSync(cstring d) - if err != 0: return false - else: s.isX() - existsWrap dirExists, isDirectory - existsWrap fileExists, isFile - existsWrap symlinkExists, isSymbolicLink - - # easy to impl getCreationTime, etc. - # but that'll introduce the conversions between `DateTime`, which is no need, - # we just impl the used `get?time` - func valueOf(obj: Date): c_double{.importcpp.} - template gen_getxtime(getxtime, attr) = - proc getxtime*(p: PathLike): float = - var s: Stat - let cs = cstring($p) - catchJsErrAndRaise proc() = - s = statSync(cs) - s.attr.valueOf() / 1000 - gen_getxtime getctime, ctime - gen_getxtime getmtime, mtime - gen_getxtime getatime, atime - - diff --git a/src/pylib/Lib/os_impl/path.nim b/src/pylib/Lib/os_impl/path.nim deleted file mode 100644 index 689099448..000000000 --- a/src/pylib/Lib/os_impl/path.nim +++ /dev/null @@ -1,115 +0,0 @@ - -import std/os as nos -import std/times as ntimes -import std/macros -import ./posix_like/stat - -import ./common -export common -when InJs: - import ./osJsPatch - -import ./consts -export consts - -template templfExp(nam, nimProc, resType){.dirty.} = - func nam*(s: PathLike): resType = nimProc s.fspath -template templpExp(nam, nimProc, resType){.dirty.} = - proc nam*(s: PathLike): resType = nimProc s.fspath - -template templfExpRetT(nam, nimProc){.dirty.} = - func nam*[T](s: PathLike[T]): T = - s.mapPathLike nimProc -template templpExpRetT(nam, nimProc){.dirty.} = - proc nam*[T](s: PathLike[T]): T = - s.mapPathLike nimProc - -template fbExp(nam, nimProc) = - templfExp(nam, nimProc, bool) -template pbExp(nam, nimProc){.dirty.} = - templpExp(nam, nimProc, bool) - -template fsExp(nam, nimProc){.dirty.} = - templfExpRetT(nam, nimProc) -template psExp(nam, nimProc){.dirty.} = - templpExpRetT(nam, nimProc) - -fbExp isabs, isAbsolute -pbExp isfile, fileExists -pbExp isdir, dirExists -pbExp islink, symlinkExists - -fsExp dirname, parentDir - -fsExp basename, extractFilename # instead of lastPathPart - -psExp abspath, absolutePath -psExp normpath, normalizedPath - -func relpath*[T](p: PathLike[T], start=curdir): T = - mapPathLike[T] relativePath($p, $start) - -when InJS: - export getatime, getmtime, getctime -else: - template expFRetTAsF(nam, nimProc){.dirty.} = - ## returns Time as float - proc nam*[T](p: PathLike[T]): float = - p.tryOsOp: result = nimProc($p).toUnixFloat - expFRetTAsF getctime, getCreationTime - expFRetTAsF getmtime, getLastModificationTime - expFRetTAsF getatime, getLastAccessTime - -proc getsize*[T](filename: PathLike[T]): int = - # std/os.`getFileSize` doesn't work for directory - int statAttr(filename, st_size) - -func samefile*(a, b: PathLike): bool = - tryOsOp(a, b): result = samefile(a.fspath, b.fspath) - -template split2Via(p, fn) = - let t = fn $p - result[0] = mapPathLike[T] t[0] - result[1] = mapPathLike[T] t[1] - -func split*[T](p: PathLike[T]): (T, T) = p.split2Via nos.splitPath -func splitdrive*[T](p: PathLike[T]): (T, T) = p.split2Via nos.splitDrive -# Nim's os.splitDrive is adapted from Python's alreadly. - -func splitext*[T](p: PathLike[T]): (T, T) = - let t = p.fspath - let s = $t - let idx = s.searchExtPos(s) - if idx == -1: - return (t, mapPathLike[T]("")) - result = ( - mapPathLike[T](s[0.. 0 -template valid_dir_fd(dir_fd: int): bool = - bind DEFAULT_DIR_FD - dir_fd != DEFAULT_DIR_FD -template valid_path[T: Path](path: T): bool = T is_not int ## only for path_and_dir_fd_invalid, meaning !path->wide && !path->narrow - -template gen_invalid(a, b; msg: string){.dirty.} = - proc `a and b invalid`*(function_name: string, a; b): bool{.discardable.} = - if `valid a`(a) and `valid b`(b): - raise newException(ValueError, function_name & ": " & msg) - return true - template `a and b invalid`*(a; b): untyped{.dirty.} = - bind getProcName - `a and b invalid`(getProcName(), a, b) - -template nonTogether(a, b: string): string = - "cannot use " & a & " and " & b & " together" - -template gen_invalid(a, b){.dirty.} = - gen_invalid(a, b, nonTogether(astToStr(a), astToStr(b))) - -gen_invalid path, dir_fd, "can't specify dir_fd without matching path" -gen_invalid dir_fd, fd, "can't specify both dir_fd and fd" -gen_invalid fd, follow_symlinks -gen_invalid dir_fd, follow_symlinks diff --git a/src/pylib/Lib/os_impl/posix_like/chmods.nim b/src/pylib/Lib/os_impl/posix_like/chmods.nim deleted file mode 100644 index 9e398ec78..000000000 --- a/src/pylib/Lib/os_impl/posix_like/chmods.nim +++ /dev/null @@ -1,204 +0,0 @@ - -import ../common -import ./errnoUtils -import ./pyCfg -importConfig [ - chmods, - os -] -when InJs: - template decl(f, val) = - const `HAVE f` = val - decl chmod, true - decl fchmod, true - decl lchmod, false - decl fchmodat, false - -when HAVE_FCHMODAT or not (HAVE_FCHMODAT or HAVE_FCHMOD or useMS_WINDOWSproc): - import ./chkarg -when HAVE_FCHMOD: - import ../util/handle_signal - -when InJS: - import ./chmodsJs as posix - template raiseErrnoWithPath(path: string) = - raiseErrnoWithPath(path, res) -elif not useMS_WINDOWSproc: - import std/posix - when Mode isnot int: - template chmod(path: cstring, mode: int): cint = posix.chmod(path, Mode mode) - when HAVEfchmodatRUNTIME and not declared(fchmodat): - proc fchmodat(dir_fd: cint, path: cstring, mode: Mode, flag: cint): cint{. - importc, header: "".} - template fchmodat(dir_fd: int, path: cstring, mode: int, flag: int): cint = - fchmodat(cint dir_fd, path, Mode mode, flag) -else: # MS_WINDOWS and not JS - import ../util/mywinlean - import std/widestrs - import ../../stat_impl/consts - - - proc SetFileInformationByHandle( - hfile: Handle, infoClass: FILE_INFO_BY_HANDLE_CLASS, lpBuffer: pointer, dwBufferSize: DWORD - ): bool {.importc, header: "".} - proc win32_lchmod(path: WideCString, mode: int): bool = - var attr = GetFileAttributesW(path) - if attr == INVALID_FILE_ATTRIBUTES: - return false - if (mode and S_IWRITE) != 0: - attr = attr and (not FILE_ATTRIBUTE_READONLY) - else: - attr = attr or FILE_ATTRIBUTE_READONLY - return SetFileAttributesW(path, attr) != 0 - - proc win32_hchmod(hfile: Handle, mode: int): bool = - var info: FILE_BASIC_INFO - if not GetFileBasicInformationByHandleEx(hfile, info): - return false - if (mode and S_IWRITE) != 0: - info.FileAttributes = info.FileAttributes and (not FILE_ATTRIBUTE_READONLY) - else: - info.FileAttributes = info.FileAttributes or FILE_ATTRIBUTE_READONLY - return SetFileInformationByHandle(hfile, FILE_INFO_BY_HANDLE_CLASS.FileBasicInfo, - addr info, DWORD sizeof(info)) - - proc win32_fchmod(fd: int, mode: int): bool = - let hfile = Py_get_osfhandle_noraise(fd) - if hfile == INVALID_HANDLE_VALUE: - setLastError(ERROR_INVALID_HANDLE) - return false - return win32_hchmod(hfile, mode) - -template narrow(path: string): cstring = cstring path - -proc chmod*( - path: (when HAVE_FCHMODAT: string|int else: string), - mode: int, - dir_fd = DEFAULT_DIR_FD, - follow_symlinks = not MS_WINDOWS) = - when not (HAVE_FCHMODAT or HAVE_FCHMOD or useMS_WINDOWSproc): - if follow_symlinks_specified(follow_symlinks): - return - sys.audit("os.chmod", path, mode, dir_fd) - when useMS_WINDOWSproc: - var res = false - when path is int: - if win32_fchmod(fd, mode): - raiseExcWithPath path - else: - if follow_symlinks: - let hfile = createFileW(newWideCString path, - FILE_READ_ATTRIBUTES or FILE_WRITE_ATTRIBUTES, - 0, nil, - OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, 0) - if hfile != INVALID_HANDLE_VALUE: - res = win32_hchmod(hfile, mode) - discard closeHandle(hfile) - else: - res = win32_lchmod(newWideCString(path), mode) - if not res: - raiseErrnoWithPath path - else: - var res = cint(0) - when HAVE_FCHMODAT: - var fchmodat_unsupported, fchmodat_nofollow_unsupported = false - let dir_fd_not_default = dir_fd != DEFAULT_DIR_FD - template handleFchmodatRuntime() = - when HAVE_FCHMODAT_RUNTIME: - # fchmodat() doesn't currently support AT_SYMLINK_NOFOLLOW! - # The documentation specifically shows how to use it, - # and then says it isn't implemented yet. - # (true on linux with glibc 2.15, and openindiana 3.x) - # - # Once it is supported, os.chmod will automatically - # support dir_fd and follow_symlinks=False. (Hopefully.) - # Until then, we need to be careful what exception we raise. - res = fchmodat(dir_fd, path.narrow, mode, - if follow_symlinks: 0 else: AT_SYMLINK_NOFOLLOW) - # But wait! We can't throw the exception without allowing threads, - # and we can't do that in this nested scope. (Macro trickery, sigh.) - fchmodat_nofollow_unsupported = res != 0 and - ((isErr(ENOTSUP) or isErr(EOPNOTSUPP)) and - not follow_symlinks) - else: - fchmodat_unsupported = true - fchmodat_nofollow_unsupported = true - res = -1 - - template handleChmodFallback() = - when HAVE_CHMOD: - res = chmod(path.narrow, mode) - elif defined(wasi): - # WASI SDK 15.0 does not support chmod. - # Ignore missing syscall for now. - res = 0 - else: - when defined(pylibForceRTErr): - res = -1 - setErrno(ENOSYS) # will raises OSError below - else: - static:assert false, "chmod not implement on you platform" - - template handleFchmodat() = - when HAVE_FCHMODAT: - if dir_fd_not_default or not follow_symlinks: - handleFchmodatRuntime() - else: - handleChmodFallback() - else: - handleChmodFallback() - - template handleLchmodOrFchmod() = - when HAVE_LCHMOD: - if not follow_symlinks and not dir_fd_not_default: - res = lchmod(path.narrow, mode) - else: - handleFchmodat() - else: - handleFchmodat() - - when HAVE_FCHMOD: - when path is int: - res = fchmod(path, mode) - else: - handleLchmodOrFchmod() - else: - handleLchmodOrFchmod() - - if res != 0: - when HAVE_FCHMODAT: - if fchmodat_unsupported and dir_fd_not_default: - argument_unavailable_error("dir_fd") - elif fchmodat_nofollow_unsupported: - if not follow_symlinks and dir_fd_not_default: - # dir_fd_and_follow_symlinks_invalid - raise newException(ValueError, - "chmod: cannot use dir_fd and follow_symlinks together") - else: - follow_symlinks_specified(follow_symlinks) - else: - raiseErrnoWithPath path - else: - raiseErrnoWithPath path - -when HAVE_FCHMOD or useMS_WINDOWSproc: - proc fchmod*(fd: int, mode: int) = - sys.audit("os.chmod", fd, mode, -1) - when useMS_WINDOWSproc: - if not win32_fchmod(fd, mode): - raiseErrno() - else: - var res: int - initVal_with_handle_signal(res, posix.fchmod(cint fd, Mode mode)) - - -when HAVE_LCHMOD or useMS_WINDOWSproc: - proc lchmod*(path: string, mode: int) = - sys.audit("os.chmod", path, mode, -1) - when useMS_WINDOWSproc: - if not win32_lchmod(newWideCString(path), mode): - raiseErrnoWithPath path - else: - let res = lchmod(path, mode) - if res < 0: - raiseErrnoWithPath path diff --git a/src/pylib/Lib/os_impl/posix_like/chmodsJs.nim b/src/pylib/Lib/os_impl/posix_like/chmodsJs.nim deleted file mode 100644 index 48600ee03..000000000 --- a/src/pylib/Lib/os_impl/posix_like/chmodsJs.nim +++ /dev/null @@ -1,19 +0,0 @@ - - -when defined(js): - import ../common - - type Mode* = int - using mode: Mode - proc chmodImpl(path: cstring, mode){.importDenoOrNodeMod(fs, chmodSync).} - proc lchmodImpl(path: cstring, mode){.importNode(fs, lchmodSync).} ## XXX: nodejs: only works on macos - proc fchmodImpl(fd: int, mode){.importNode(fs, fchmodSync).} - var chmodExcMsg*: string - template gen(name; A){.dirty.} = - proc name*(arg: A, mode: int): cint = - catchJsErrAsCode(chmodExcMsg, `name Impl`(arg, mode)) - gen chmod, cstring - gen lchmod, cstring - gen fchmod, int - - diff --git a/src/pylib/Lib/os_impl/posix_like/errnoRaise.nim b/src/pylib/Lib/os_impl/posix_like/errnoRaise.nim deleted file mode 100644 index 7fdc31f07..000000000 --- a/src/pylib/Lib/os_impl/posix_like/errnoRaise.nim +++ /dev/null @@ -1,6 +0,0 @@ - -import ../../../pyerrors -import ../../../pyerrors/errno as errnoMod -export pyerrors, errnoMod - - diff --git a/src/pylib/Lib/os_impl/posix_like/errnoUtils.nim b/src/pylib/Lib/os_impl/posix_like/errnoUtils.nim deleted file mode 100644 index b78001d23..000000000 --- a/src/pylib/Lib/os_impl/posix_like/errnoUtils.nim +++ /dev/null @@ -1,2 +0,0 @@ -import ../../errno_impl/[errnoUtils, errnoConsts] -export errnoUtils, errnoConsts diff --git a/src/pylib/Lib/os_impl/posix_like/fdopen.nim b/src/pylib/Lib/os_impl/posix_like/fdopen.nim deleted file mode 100644 index 505e9bc1d..000000000 --- a/src/pylib/Lib/os_impl/posix_like/fdopen.nim +++ /dev/null @@ -1,26 +0,0 @@ - -## this module depends on `io` module - - -when defined(nimdoc) or defined(js) or defined(nimscript): - template fdopen*(fd: Positive; x: varargs[untyped]): untyped = - ## not support JS/NimScript backend - static: doAssert false, "unsupport JS/NimScript backend" -else: - import std/macros - import ../../../io - export io # for open, write,... - - macro unpackVarargsWith1(callee, arg1: untyped; otherArgs: varargs[untyped]): untyped = - result = newCall(callee, arg1) - for i in 0 ..< otherArgs.len: - result.add otherArgs[i] - - template fdopen*(fd: Positive; x: varargs[untyped]): untyped = - ## Return an open file object connected to the file descriptor fd. - ## - ## This is an alias of the io.open() function and accepts the same arguments. - ## The only difference is that the first argument of fdopen() must always be an integer. - bind io.open - unpackVarargsWith1 io.open, fd, x - # support kw (will be of kind: nnkExprEqExpr) diff --git a/src/pylib/Lib/os_impl/posix_like/get_id.nim b/src/pylib/Lib/os_impl/posix_like/get_id.nim deleted file mode 100644 index a80d1aa5a..000000000 --- a/src/pylib/Lib/os_impl/posix_like/get_id.nim +++ /dev/null @@ -1,130 +0,0 @@ - -import std/os -const JS = defined(js) -when JS: - import ../common - let pid{.importDenoOrProcess(pid).}: int - -proc getpid*(): int = - when JS: pid else: getCurrentProcessId() - -when defined(windows): - import std/winlean - - type - ULONG = uint32 - ULONG_PTR = ULONG - NTSTATUS = uint32 ##\ - ## https://learn.microsoft.com/en-us/openspecs/windows_protocols/ms-erref/87fba13e-bf06-450e-83b1-9241dc81e781 - KPRIORITY{.importc, header: "".} = object - PriorityClass, PrioritySubClass: ULONG - type - ProcessBasicInformationFull = object - ## `_PROCESS_BASIC_INFORMATION` - ## https://learn.microsoft.com/en-us/windows/win32/api/winternl/nf-winternl-ntqueryinformationprocess#process_basic_information - ExitStatus: NTSTATUS - PebBaseAddress: pointer ## `PEB *` in `` - AffinityMask: ULONG_PTR - BasePriority: KPRIORITY - UniqueProcessId: ULONG_PTR - InheritedFromUniqueProcessId: ULONG_PTR - - PROCESSINFOCLASS = enum - ProcessBasicInformation = cint 0 - - PNT_QUERY_INFORMATION_PROCESS = proc(handle: Handle, infoClass: PROCESSINFOCLASS, - info: pointer, infoLen: ULONG, retLen: ptr ULONG): NTSTATUS {.stdcall.} - HMODULE = Handle - - FARPROC = pointer ## XXX: pointer to function in C - - proc NT_SUCCESS(status: NTSTATUS): bool{.importc, nodecl.} - - proc GetModuleHandleA(lpModuleName: cstring): HMODULE {.importc, header: "", stdcall.} ## \ - ## DO NOT pass result to FreeLibrary, - ## ref https://learn.microsoft.com/en-us/windows/win32/api/libloaderapi/nf-libloaderapi-getmodulehandlew - proc GetProcAddress(hModule: HMODULE, lpProcName: cstring): FARPROC {.importc, header: "", stdcall.} - - var cachedPpid: ULONG = 0 - proc win32_getppid_fast(): uint = - ## This function returns the process ID of the parent process. - ## Returns 0 on failure. - if cachedPpid != 0: - return cachedPpid - - let ntdll = GetModuleHandleA("ntdll.dll") - if ntdll == 0: - return 0 - - let pNtQueryInformationProcess = cast[PNT_QUERY_INFORMATION_PROCESS]( - GetProcAddress(ntdll, "NtQueryInformationProcess")) - ## https://learn.microsoft.com/en-us/windows/win32/api/winternl/nf-winternl-ntqueryinformationprocess - if pNtQueryInformationProcess.isNil: - return 0 - - var basicInfo: ProcessBasicInformationFull - let status = pNtQueryInformationProcess(getCurrentProcess(), ProcessBasicInformation, - addr basicInfo, sizeof(basicInfo).ULONG, nil) - - if not NT_SUCCESS(status): - return 0 - # Perform sanity check on the parent process ID we received from NtQueryInformationProcess. - # The check covers values which exceed the 32-bit range (if running on x64) as well as - # zero and (ULONG) -1. - - if basicInfo.InheritedFromUniqueProcessId == 0 or - basicInfo.InheritedFromUniqueProcessId >= ULONG.high: - return 0 - - cachedPpid = ULONG basicInfo.InheritedFromUniqueProcessId - return cachedPpid - - type - PSS_CAPTURE_FLAGS = enum - PSS_CAPTURE_NONE = cint 0 - PSS_QUERY_INFORMATION_CLASS = enum - PSS_QUERY_PROCESS_INFORMATION = cint 0 - const - ERROR_SUCCESS = 0 - {.push header: "".} - {.push stdcall.} - proc PssCaptureSnapshot(process: Handle, flags: PSS_CAPTURE_FLAGS, - snapshotFlags: uint32, snapshot: ptr Handle): uint32 {.importc.} - proc PssQuerySnapshot(snapshot: Handle, infoClass: PSS_QUERY_INFORMATION_CLASS, - info: pointer, infoLen: uint32): uint32 {.importc.} - proc PssFreeSnapshot(process: Handle, snapshot: Handle): uint32 {.importc, discardable.} - {.pop.} - type PSS_PROCESS_INFORMATION{.importc.} = object - ParentProcessId{.importc.}: uint32 - {.pop.} - - proc win32_getppid(): int = - let pid = win32_getppid_fast() - if pid != 0: - return int(pid) - - # Fallback to PSS API if fast method fails - var snapshot: Handle - let process = getCurrentProcess() - let error = PssCaptureSnapshot(process, PSS_CAPTURE_NONE, 0, addr snapshot) - if error != ERROR_SUCCESS: - return 0 - - var info: PSS_PROCESS_INFORMATION - let queryError = PssQuerySnapshot(snapshot, PSS_QUERY_PROCESS_INFORMATION, - addr info, uint32(sizeof(info))) - result = if queryError == ERROR_SUCCESS: int(info.ParentProcessId) - else: 0 - - PssFreeSnapshot(process, snapshot) -elif defined(js): - let ppid{.importDenoOrProcess(ppid).}: int -else: - import std/posix -proc getppid*(): int = - ## Returns the parent's process id. - ## If the parent process has already exited, Windows machines will still - ## return its id; others systems will return the id of the 'init' process (1). - when defined(windows): win32_getppid() - elif JS: ppid - else: int posix.getppid() diff --git a/src/pylib/Lib/os_impl/posix_like/isatty.nim b/src/pylib/Lib/os_impl/posix_like/isatty.nim deleted file mode 100644 index 785b69d5d..000000000 --- a/src/pylib/Lib/os_impl/posix_like/isatty.nim +++ /dev/null @@ -1,12 +0,0 @@ - -# imported by Lib/io - -when defined(posix): - proc isatty(fildes: cint): cint {. - importc: "isatty", header: "".} -else: - proc isatty(fildes: cint): cint {. - importc: "_isatty", header: "".} - -func isatty*(fd: int): bool = - isatty(fd.cint) != 0 diff --git a/src/pylib/Lib/os_impl/posix_like/jsStat.nim b/src/pylib/Lib/os_impl/posix_like/jsStat.nim deleted file mode 100644 index d5b150592..000000000 --- a/src/pylib/Lib/os_impl/posix_like/jsStat.nim +++ /dev/null @@ -1,26 +0,0 @@ - -when defined(js): - import std/jsffi - import std/jscore - type Date* = DateTime - from ../common import importNode, importDenoOrNodeMod - const InNode = defined(nodejs) - type Stat*#[{.importByNodeOrDeno("require('fs').Stats", "Deno.FileInfo").}]# = ref object of JsObject - ## Stat in node, FileInfo in deno - ctime*, mtime*, atime*: Date - using self: Stat - template impIsXNoNull(isX; isMeth = InNode){.dirty.} = - ## `is*` is method in NodeJs but attr in Deno. - ## this can only used for isDirectory, isFile, isSymbolicLink - ## as their result are non-null. - proc isX*(self): bool{.importjs:"(#)." & astToStr(isX) & ( - when isMeth: "()" else: "" - ).} - impIsXNoNull isDirectory - impIsXNoNull isFile - impIsXNoNull isSymbolicLink - - proc statSync*(p: cstring): Stat{.importDenoOrNodeMod(fs, statSync).} - proc fstatSync*(fd: cint): Stat{.importNode(fs, fstatSync).} - proc lstatSync*(p: cstring): Stat{.importDenoOrNodeMod(fs, lstatSync).} - diff --git a/src/pylib/Lib/os_impl/posix_like/links.nim b/src/pylib/Lib/os_impl/posix_like/links.nim deleted file mode 100644 index e1968cc92..000000000 --- a/src/pylib/Lib/os_impl/posix_like/links.nim +++ /dev/null @@ -1,321 +0,0 @@ - - -import std/os -import ../common - -when InJs: - proc readlinkSync(p: cstring): cstring{.importNode(fs, readlinkSync).} - proc readlink*(p: string): string = - var res: cstring = "" - catchJsErrAndRaise: - res = readlinkSync(cstring p) - $res - proc symlinkSync(target, path, `type`: cstring){.importNode(fs, symlinkSync).} - proc symlinkImpl[T](src, dst: PathLike[T], target_is_directory = false) = - catchJsErrAndRaise: - symlinkSync( - cstring $dst, cstring $dst, - if target_is_directory: "dir" else: "file" - ) - - proc linkSync(target, path, `type`: cstring){.importNode(fs, linkSync).} - proc linkImpl[T](src, dst: PathLike[T]) = - catchJsErrAndRaise: - linkSync( - cstring $dst, cstring $dst, - ) -else: - when defined(windows): - import ../util/mywinlean - type - LPVOID = pointer - LPDWORD = ptr DWORD - LPOVERLAPPED = pointer # we don't use it - let FSCTL_GET_REPARSE_POINT{.importc, header: "".}: DWORD - proc deviceIoControl(hDevice: HANDLE; dwIoControlCode: DWORD; - lpInBuffer: LPVOID; nInBufferSize: DWORD; - lpOutBuffer: LPVOID; nOutBufferSize: DWORD; - lpBytesReturned: LPDWORD; lpOverlapped: LPOVERLAPPED): WINBOOL{. - importc: "DeviceIoControl", header: "".} - - type - USHORT = uint16 - WCHAR = winlean.WinChar - UCHAR = uint8 - - ULONG = uint32 - # XXX: winlean.ULONG is defined as int32 - - ## The following structure was translated7474 from - ## http://msdn.microsoft.com/en-us/library/ff552012.aspx as the required - ## include km\ntifs.h isn't present in the Windows SDK (at least as included - ## with Visual Studio Express). Use unique names to avoid conflicting with - ## the structure as defined by Min GW. - - type - INNER_C_STRUCT_Py_REPARSE_DATA_BUFFER_6 {.bycopy.} = object - SubstituteNameOffset: USHORT - SubstituteNameLength: USHORT - PrintNameOffset: USHORT - PrintNameLength: USHORT - Flags: ULONG - PathBuffer: UncheckedArray[WCHAR] - - INNER_C_STRUCT_Py_REPARSE_DATA_BUFFER_7 {.bycopy.} = object - SubstituteNameOffset: USHORT - SubstituteNameLength: USHORT - PrintNameOffset: USHORT - PrintNameLength: USHORT - PathBuffer: UncheckedArray[WCHAR] - - INNER_C_STRUCT_Py_REPARSE_DATA_BUFFER_8 {.bycopy.} = object - DataBuffer: UncheckedArray[UCHAR] - - INNER_C_UNION_Py_REPARSE_DATA_BUFFER_5 {.bycopy, union.} = object - SymbolicLinkReparseBuffer: INNER_C_STRUCT_Py_REPARSE_DATA_BUFFER_6 - MountPointReparseBuffer: INNER_C_STRUCT_Py_REPARSE_DATA_BUFFER_7 - GenericReparseBuffer: INNER_C_STRUCT_Py_REPARSE_DATA_BUFFER_8 - - Py_REPARSE_DATA_BUFFER {.bycopy.} = object - ReparseTag: ULONG - ReparseDataLength: USHORT - Reserved: USHORT - inner_c_union: INNER_C_UNION_Py_REPARSE_DATA_BUFFER_5 - - Py_PREPARSE_DATA_BUFFER = ptr Py_REPARSE_DATA_BUFFER - - Py_ssize_t = int # XXX: not the same, just minic - wchar_t = WCHAR - Wstr = ptr wchar_t - func `==`(a, b: wchar_t): bool = int16(a) == int16(b) - template atN(p: Wstr, i: int): Wstr = - cast[Wstr]( - cast[Py_ssize_t](p) + Py_ssize_t(i * sizeof(wchar_t)) - ) - proc `[]`(p: Wstr, i: int): wchar_t = p.atN(i)[] - proc `[]=`(p: Wstr, i: int, x: wchar_t) = - let np = p.atN i - np[] = x - proc startsWith(s: Wstr, sub: cstring, n: int): bool = - # assert s's length is no less than n - # assert sub is all ASCII. - result = true - for i in 0..= UNI_SUR_HIGH_START and ch <= UNI_SUR_HIGH_END: - # If the 16 bits following the high surrogate are in the source buffer... - let ch2 = ord(w[i]) - - # If it's a low surrogate, convert to UTF32: - if ch2 >= UNI_SUR_LOW_START and ch2 <= UNI_SUR_LOW_END: - ch = (((ch and halfMask) shl halfShift) + (ch2 and halfMask)) + halfBase - inc i - else: - #invalid UTF-16 - ch = replacement - elif ch >= UNI_SUR_LOW_START and ch <= UNI_SUR_LOW_END: - #invalid UTF-16 - ch = replacement - - if ch < 0x80: - result.add chr(ch) - elif ch < 0x800: - result.add chr((ch shr 6) or 0xc0) - result.add chr((ch and 0x3f) or 0x80) - elif ch < 0x10000: - result.add chr((ch shr 12) or 0xe0) - result.add chr(((ch shr 6) and 0x3f) or 0x80) - result.add chr((ch and 0x3f) or 0x80) - elif ch <= 0x10FFFF: - result.add chr((ch shr 18) or 0xf0) - result.add chr(((ch shr 12) and 0x3f) or 0x80) - result.add chr(((ch shr 6) and 0x3f) or 0x80) - result.add chr((ch and 0x3f) or 0x80) - else: - # replacement char(in case user give very large number): - result.add chr(0xFFFD shr 12 or 0b1110_0000) - result.add chr(0xFFFD shr 6 and ones(6) or 0b10_0000_00) - result.add chr(0xFFFD and ones(6) or 0b10_0000_00) - - # _Py_MAXIMUM_REPARSE_DATA_BUFFER_SIZE ( 16 * 1024 ) - - const REPARSE_BUFSIZE = 16 * 1024 - proc readlinkWinImpl(path: string): string = - ## returns utf-8 encoded path - # ref posixmodule.c L10129 - - let wstr = newWideCString path - var - n_bytes_returned: DWORD - io_result: WINBOOL - target_buffer: pointer - when compileOption("threads"): - target_buffer = allocShared(REPARSE_BUFSIZE) - defer: target_buffer.deallocShared() - else: - target_buffer = alloc(REPARSE_BUFSIZE) - defer: target_buffer.dealloc() - # In CPython's impl, target_buffer is on the stack... - # So no need to deallocate manually. - # But if we do so in Nim, we have to use a lot `addr` as - # in C, array converts to pointer implicitly, but not in Nim. - - var rdb = cast[Py_PREPARSE_DATA_BUFFER](target_buffer) - let reparse_point_handle = createFileW( wstr, - 0, 0, nil, - OPEN_EXISTING, - FILE_FLAG_OPEN_REPARSE_POINT or FILE_FLAG_BACKUP_SEMANTICS, - 0) - if (reparse_point_handle != INVALID_HANDLE_VALUE): - io_result = deviceIoControl(reparse_point_handle, - FSCTL_GET_REPARSE_POINT, - nil, 0, # in buffer - target_buffer, REPARSE_BUFSIZE, - addr n_bytes_returned, - nil # we're not using OVERLAPPED_IO - ) - discard closeHandle(reparse_point_handle) - if io_result == WINBOOL(0): - raiseOSError(osLastError()) - - var - name: ptr wchar_t = nil - nameLen: Py_ssize_t = 0 - template add_char_ptr(a, b): ptr wchar_t = - cast[ptr wchar_t]( - cast[int](a) + cast[int](b) - ) - - template rdbAs(union): untyped = rdb.inner_c_union.union - template calLen(nameLength: USHORT): untyped = - Py_ssize_t(nameLength) div Py_ssize_t sizeof((wchar_t)) - template extractName(rbuf) = - name = add_char_ptr(rbuf.PathBuffer, - rbuf.SubstituteNameOffset) - nameLen = calLen rbuf.SubstituteNameLength - case rdb.ReparseTag - of IO_REPARSE_TAG_SYMLINK: - template rbuf: untyped = rdbAs SymbolicLinkReparseBuffer - rbuf.extractName() - of IO_REPARSE_TAG_MOUNT_POINT: - template rbuf: untyped = rdbAs MountPointReparseBuffer - rbuf.extractName() - else: - raise newException(ValueError, "not a symbolic link") - if name != nil: - if nameLen > 4 and name.startsWith(cstring"\\??\\", 4): - ## Our buffer is mutable, so this is okay - name[1] = wchar_t('\\') - result = $(name, nameLen) - return result - - - proc readlinkImpl(path: string): string = - when defined(windows): - result = readlinkWinImpl path - else: - result = expandSymlink(path) - - - proc readlink*[T](path: PathLike[T]): T = - tryOsOp(path): - result = mapPathLike[T] readlinkImpl $path - - when defined(windows): - proc check_dir(src_resolved: string): bool = - # do not use dirExists(), as it follows symlink - # but GetFileAttributesW doesn't - let src_resolvedW = newWideCString src_resolved - - let res = GetFileAttributesW(src_resolvedW) - result = res == FILE_ATTRIBUTE_DIRECTORY - - var windows_has_symlink_unprivileged_flag = true - # Assumed true, set to false if detected to not be available. - proc os_symlink_impl(src, dst: string, target_is_directory: bool = false): bool = - ## returns if error ocurrs - const - SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE = 2 - ERROR_INVALID_PARAMETER = 87 - var flags: int32 = 0 - if windows_has_symlink_unprivileged_flag: - flags = flags or SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE - - let - dest_parent = parentDir dst - src_resolved = joinPath(dest_parent, src) - var wSrc = newWideCString(src) - var wDst = newWideCString(dst) - if target_is_directory or check_dir(src_resolved): - flags = flags or SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE - - # allows anyone with developer mode on to create a link - var ret = createSymbolicLinkW(wDst, wSrc, flags) - if windows_has_symlink_unprivileged_flag and ret == 0 and - getLastError() == ERROR_INVALID_PARAMETER: - #[This error might be caused by - SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE not being supported. - Try again, and update windows_has_symlink_unprivileged_flag if we - are successful this time. - - NOTE: There is a risk of a race condition here if there are other - conditions than the flag causing ERROR_INVALID_PARAMETER, and - another process (or thread) changes that condition in between our - calls to CreateSymbolicLink.]# - flags = flags and not SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE - ret = createSymbolicLinkW(wDst, wSrc, flags) - - if ret != 0 or ERROR_INVALID_PARAMETER != getLastError(): - windows_has_symlink_unprivileged_flag = false - - if ret == 0: - result = true - else: - proc c_symlink(target, linkpath: cstring): cint{.importc: "symlink", header: "".} - proc c_symlinkat(target, newdirfd: cint, linkpath: cstring): cint{.importc: "symlinkat", header: "".} - proc os_symlink_impl(src, dst: string, target_is_directory: bool = false): bool = - if c_symlink(src.cstring, dst.cstring) != 0: - result = true - proc symlink*[T](src, dst: PathLike[T], target_is_directory = false, dir_fd: int) = - ## target_is_directory is ignored. - if c_symlinkat(src.cstring, dir_fd.cint, dst.cstring) != 0: - raiseExcWithPath2(src, dst) - - proc symlinkImpl[T](src, dst: PathLike[T], target_is_directory = false) = - # std/os createSymlink on Windows will raise OSError if - # SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE is not supported yet - if os_symlink_impl($src, $dst, target_is_directory): - raiseExcWithPath2(src, dst) - - proc linkImpl[T](src, dst: PathLike[T]) = - tryOsOp(src, dst): - createHardlink($src, $dst) - -proc symlink*[T](src, dst: PathLike[T], target_is_directory = false) = - sys.audit("os.symlink", src, dst, -1) - symlinkImpl(src, dst, target_is_directory) - -proc link*[T](src, dst: PathLike[T]) = - sys.audit("os.link", src, dst, -1, -1) - linkImpl(src, dst) diff --git a/src/pylib/Lib/os_impl/posix_like/lseek.nim b/src/pylib/Lib/os_impl/posix_like/lseek.nim deleted file mode 100644 index bd6aed04c..000000000 --- a/src/pylib/Lib/os_impl/posix_like/lseek.nim +++ /dev/null @@ -1,32 +0,0 @@ - -import ../private/[iph_utils, defined_macros] -import ./errnoRaise -const weirdTarget = defined(js) or defined(nimscript) -when not weirdTarget: - import ./seek_consts - -when MS_WINDOWS: - proc lseek(fd: cint, offset: int64, origin: cint): int64 {. - importc: "_lseeki64", header: "".} -elif not weirdTarget: - import std/posix - -proc lseek*(fd: int, position: int64, whence: int): int64{.noWeirdTarget.} = - let how = whence.toCSEEK - with_Py_SUPPRESS_IPH: - when MS_WINDOWS: - result = lseek( - fd.cint, - position, - how - ).int64 - else: - result = lseek( - fd.cint, - position.Off, - how - ) - if result < 0: - raiseErrno() - - diff --git a/src/pylib/Lib/os_impl/posix_like/mkrmdir.nim b/src/pylib/Lib/os_impl/posix_like/mkrmdir.nim deleted file mode 100644 index 264e4e8a4..000000000 --- a/src/pylib/Lib/os_impl/posix_like/mkrmdir.nim +++ /dev/null @@ -1,63 +0,0 @@ - - -import ../common -import ./mkrmdirImpl - -import ./pyCfg -import ./chkarg - -when not InJS: - importConfig [ - os - ] -else: - template decl(f, val) = - const `HAVE f` = val - decl unlinkat, false - -proc rmdir*(p: PathLike, dir_fd: int) = - sys.audit("os.rmdir", p, dir_fd) - var res: cint - when HAVE_UNLINKAT: - var unlinkat_unavailable = false - if dir_fd != DEFAULT_DIR_FD: - when HAVE_UNLINKAT_RUNTIME: - res = unlinkat(dir_fd.cint, cstring $p, AT_REMOVEDIR) - else: - unlinkat_unavailable = true - res = -1 - else: - rawRemoveDir(p) - else: - rawRemoveDir(p) - when HAVE_UNLINKAT: - if unlinkat_unavailable: - argument_unavailable_error("dir_fd") - if res != 0: - raiseExcWithPath(p) - -proc mkdir*(p: PathLike, mode=0o777, dir_fd: int){.error: "not implement".} - -proc rmdir*(path: PathLike) = - sys.audit("os.rmdir", path, -1) - rawRemoveDir(path) -proc mkdir*(p: PathLike, mode=0o777) = - sys.audit("os.mkdir", p, mode, -1) - rawCreateDir(p, mode) - -#[ A version of `mkdir` that does not support `mode` -proc mkdir*(p: PathLike, mode: int){.error: "not implement".} -let ENOENT{.importc, header: "".}: cint -template isNoEnt(e: int32): bool = - when defined(windows): e == 3 # ERROR_PATH_NOT_FOUND - else: e == ENOENT.int32 - -proc mkdir*(p: PathLike) = - var exists: bool - try: exists = existsOrCreateDir $p - except OSError as e: - if e.errorCode.isNoEnt: p.raiseFileNotFoundError(e.errCode.OSErrorCode) - else: raise - if exists: raiseFileExistsError p -]# - diff --git a/src/pylib/Lib/os_impl/posix_like/mkrmdirImpl.nim b/src/pylib/Lib/os_impl/posix_like/mkrmdirImpl.nim deleted file mode 100644 index 328ddeb4f..000000000 --- a/src/pylib/Lib/os_impl/posix_like/mkrmdirImpl.nim +++ /dev/null @@ -1,58 +0,0 @@ - -import ../common - -when InJs: - proc rmdirSync(path: cstring){.importNode(fs, rmdirSync).} - proc mkdirSync(path: cstring, mode: cint){.importNode(fs, mkdirSync).} - proc rawRemoveDir*(dp: PathLike) = - let cs = cstring $dp - catchJsErrAndRaise: - rmdirSync(cs) - proc rawCreateDir*(dp: PathLike, mode=0o777) = - let cs = cstring($dp) - catchJsErrAndRaise: - mkdirSync(cs, cint mode) - -else: - include ./ncommon - when defined(windows): - template wrapUnary*(varname, winApiProc, arg: untyped) = - var varname = winApiProc(newWideCString(arg)) - else: - proc mkdir(s: string, mode: int): int32 = - mkdir(s.cstring, mode.Mode) - - # from nim-2.1.2 lib/std/private/osdirs.nim#L329 - # but `raise FileNotFoundError` when shall and change param - proc rawRemoveDir*(dp: PathLike) {.noWeirdTarget.} = - let dir = $dp - when defined(windows): - wrapUnary(res, removeDirectoryW, dir) - if res == 0'i32: - dp.raiseExcWithPath() - else: - if rmdir(cstring dir) != 0'i32: - dp.raiseExcWithPath() - - # from nim-2.1.2 lib/std/private/osdirs.nim#L364 - # but raise FileNotFoundError and FileExistsError when shall and change param - proc rawCreateDir*(dp: PathLike, mode=0o777) = - # Try to create one directory (not the whole path). - # - # This is a thin wrapper over mkDir (or alternatives on other systems), - # so in case of a pre-existing path we don't check that it is a directory. - let dir = $dp - when defined(solaris): - let res = mkdir(dir, mode) - if res != 0'i32: - dp.raiseExcWithPath() - elif defined(haiku) or defined(posix): - let res = mkdir(dir, mode) - if res != 0'i32: - dp.raiseExcWithPath() - else: - # TODO: consider mode as Python does. - wrapUnary(res, createDirectoryW, dir) - - if res == 0'i32: # res is in fact of `BOOL` - dp.raiseExcWithPath() diff --git a/src/pylib/Lib/os_impl/posix_like/ncommon.nim b/src/pylib/Lib/os_impl/posix_like/ncommon.nim deleted file mode 100644 index 54b8c5310..000000000 --- a/src/pylib/Lib/os_impl/posix_like/ncommon.nim +++ /dev/null @@ -1,11 +0,0 @@ - -const weirdTarget = defined(nimscript) or defined(js) - -when weirdTarget: - discard -elif defined(windows): - when defined(nimPreviewSlimSystem): - import std/widestrs - import std/winlean -elif defined(posix): - import std/posix diff --git a/src/pylib/Lib/os_impl/posix_like/open_close.nim b/src/pylib/Lib/os_impl/posix_like/open_close.nim deleted file mode 100644 index dd1c2bc10..000000000 --- a/src/pylib/Lib/os_impl/posix_like/open_close.nim +++ /dev/null @@ -1,109 +0,0 @@ - -import std/os - -import ../common -import ../consts - -type NotImplForNonNode = object of RootEffect - -when defined(js): - template notImpl = raise newException(NotImplementedError, "") - when defined(nodejs): - proc openSync(path: cstring, flags, mode: cint): cint{.importNode(fs, openSync).} - # in fact flags, mode is optional and accepts cstring, but we don't need such variants here - proc closeSync(fd: cint){.importNode(fs, closeSync).} - proc c_close(fd: cint): int = - catchJsErrAsCode closeSync(fd) - - proc c_close(fd: cint, msg: var string): int = - ## compat close - catchJsErrAsCode msg, closeSync(fd) - else: - const openNotImpl = "not impl for non-nodejs JS engine" - proc openSync(path: cstring, flags, mode: cint): cint{.tags: [NotImplForNonNode].} = - # XXX: Deno.openSync returns FsFile instead of integer - notImpl - proc c_close(fd: cint): int{.tags: [NotImplForNonNode].} = notImpl - proc c_close(fd: cint, msg: var string): int{.tags: [NotImplForNonNode].} = notImpl - -else: - let EINTR{.importc, header: "".}: cint - var errno{.importc, header: "".}: cint - - when defined(windows): - when defined(nimPreviewSlimSystem): - import std/widestrs - - proc c_wopen(path: WideCString, flags: cint): cint{. - varargs, importc:"_wopen", header:"".} - - # if `fd` is invalide, functions returns -1 and errno is set to EBADF. - proc c_close(fd: cint): cint{.importc:"_close", header:"".} - else: - import std/posix - - proc c_openat( - dirfd: cint, pathname: cstring, flags: cint - ): cint{.varargs, importc: "openat", header: "".} - - template c_close(fd): cint = posix.close(fd) - - {.emit:""" - /*VARSECTION*/ - #ifdef AT_FDCWD - #define DEFAULT_DIR_FD (int)AT_FDCWD - #else - #define DEFAULT_DIR_FD (-100) - #endif - """ .} - let DEFAULT_DIR_FD{.importc, nodecl.}: cint - - -proc open*(path: PathLike, flags: int, mode=0o777, dir_fd = -1): int{.forbids: [NotImplForNonNode].} = - ## `dir_fd` is ignored under Windows - sys.audit("open", path, mode, flags) - when defined(js): - var msg: string - let - p = cstring($path) - f = flags.cint - m = mode.cint - var result_cint: cint - catchJsErrAndRaise: - result_cint = openSync(p, f, m) - result = int result_cint - else: - var fd: cint - let spath = $path - while true: - when defined(windows): - let cflags = flags.cint or O_NOINHERIT - fd = c_wopen(newWideCString(spath), cflags, mode) - else: - let cflags = flags.cint or O_CLOEXEC - if dir_fd != -1 and dir_fd != DEFAULT_DIR_FD: - fd = c_openat(dir_fd.cint, spath.cstring, cflags, mode) - else: - fd = posix.open(spath.cstring, cflags, Mode mode) - discard setInheritable(FileHandle fd, false) - if not ( - fd < 0 and errno == EINTR - ): break - if fd < 0: - path.raiseErrnoWithPath() - result = fd - - -proc close*(fd: int) = - when defined(js): - var msg = "" - let res = c_close(fd.cint, msg) - if res != 0: - raise newException(OSError, msg & ", close fd: " & $fd) - else: - if c_close(fd.cint) == -1.cint: - raiseErrno() - -proc closerange*(fd_low, fd_high: int) = - for fd in fd_low..".} - proc internal_rename[T](src, dst: PathLike[T], is_replace: static[bool]): bool = - result = c_rename(cstring $src, cstring $dst) == 0.cint - -proc rename*[T](src, dst: PathLike[T]) = - sys.audit("os.rename", src, dst, -1, -1) - if not internal_rename(src, dst, false): - raiseExcWithPath2(src, dst) - -proc replace*[T](src, dst: PathLike[T]) = - if not internal_rename(src, dst, true): - raiseExcWithPath2(src, dst) diff --git a/src/pylib/Lib/os_impl/posix_like/scandirImpl.nim b/src/pylib/Lib/os_impl/posix_like/scandirImpl.nim deleted file mode 100644 index 2e1725ba8..000000000 --- a/src/pylib/Lib/os_impl/posix_like/scandirImpl.nim +++ /dev/null @@ -1,279 +0,0 @@ - -import std/os -import ../common -import ./stat - -when not InJs: - import ../../n_stat -import ./pyCfg -importConfig [os] -when HAVE_FDOPENDIR: - when HAVE_FDOPENDIR_RUNTIME: - import ./errnoUtils - -when InJs: - import std/jsffi - import ./links - type - Dir = JsObject ## fs.Dir - Dirent = JsObject ## fs.Dirent - from ./jsStat import Stat, statSync -elif defined(posix): - import ./links - import std/posix except S_ISREG, S_ISDIR, S_ISLNK -when declared(readlink): - func func_readlink(x: string): string = - {.noSideEffect.}: - result = readlink(x) - -type - DirEntryImpl[T] = ref object of RootObj - when T is int: - name*, path*: PyStr - else: - name*, path*: T - stat_res: ref stat_result - -when InJs: - type HasIsX = JsObject - template impIsX(isX){.dirty.} = - func isX(self: HasIsX): bool{.importcpp.} - impIsX isFile - impIsX isDirectory - impIsX isSymbolicLink - type DirEntry*[T] = ref object of DirEntryImpl[T] - statObj: HasIsX -else: - type DirEntry*[T] = ref object of DirEntryImpl[T] - kind: PathComponent -const havePDir = declared(Dir) -type ScandirIterator[T] = ref object - when havePDir: - when T is int: - dirp: ptr Dir - iter: iterator(): DirEntry[T] - -func close*(scandirIter: ScandirIterator) = discard -func close*(scandirIter: ScandirIterator[int]) = - when havePDir and not InJs: - discard closedir scandirIter.dirp - scandirIter.dirp = nil -iterator items*[T](scandirIter: ScandirIterator[T]): DirEntry[T] = - for i in scandirIter.iter(): - yield i - -template enter*(self: ScandirIterator): ScandirIterator = self -template exit*(self: ScandirIterator; args: varargs[untyped]) = - bind close - self.close() - -using self: DirEntry - -when InJs: - proc newDirEntry[T](name: string, dir: string, hasIsFileDir: JsObject - ): DirEntry[T] = - new result - result.name = mapPathLike[T] name - result.path = mapPathLike[T] joinPath(dir, name) - result.statObj = hasIsFileDir -else: - proc newDirEntry[T](name: string, dir: string|int, kind: PathComponent - ): DirEntry[T] = - new result - when T is int: - result.name = str name - result.path = result.name - else: - result.name = mapPathLike[T] name - result.path = mapPathLike[T](joinPath(dir, name)) - result.kind = kind - -func repr*(self): string = - "' - -proc stat*(self; follow_symlinks=true): stat_result = - static: assert not compiles(self.dir_fd) # currently impl assumes no dir_fd - if self.stat_res != nil: - return self.stat_res[] - result = stat(self.path, follow_symlinks=follow_symlinks) - new self.stat_res - self.stat_res[] = result - -when InJs: - func is_symlink*(self): bool = self.statObj.isSymbolicLink() - template gen_is_x(is_x, jsAttr){.dirty.} = - func is_x*(self): bool = - ## follow_symlinks is True on default. - if self.is_symlink(): - let p = func_readlink $self.path - statSync(p).jsAttr() - else: - self.statObj.jsAttr() - func is_x*(self; follow_symlinks: bool): bool = - if follow_symlinks: self.is_x() - else: self.statObj.jsAttr() - gen_is_x is_file, isFile - gen_is_x is_dir, isDirectory -else: - template gen_is_xAux(is_x, chk_pcX, chk_pcLinkToX){.dirty.} = - func is_x*(self): bool = - ## follow_symlinks is True on default. - chk_pcX(self) or chk_pcLinkToX self - func is_x*(self; follow_symlinks: bool): bool = - ## result is cached. Python's is cached too. - result = chk_pcX self - if follow_symlinks: - return result or chk_pcLinkToX self - template gen_is_x(is_x, pcX, pcLinkToX) = - template isPcX(self): bool = self.kind == pcX - template isPcLinkX(self): bool = self.kind == pcLinkToX - gen_is_xAux(is_x, isPcX, isPcLinkX) - - func is_symlink*(self): bool = - ## ..warning:: this may differ Python's - self.kind == pcLinkToDir or self.kind == pcLinkToFile - when defined(windows): - gen_is_x is_file, pcFile, pcLinkToFile - else: - func isFReg(mode: Mode): bool{.inline.} = - {.noSideEffect.}: - result = mode.S_ISREG - func chk_isfile(self: DirEntry): bool{.inline.} = - result = self.kind == pcFile - if not result: return - result = self.stat().st_mode.isFReg - func isLinkToFile(path: string; dir_fd=DEFAULT_DIR_FD): bool{.inline.} = - let p = func_readlink path - {.noSideEffect.}: - result = stat(p, dir_fd=dir_fd).st_mode.isFReg - func chk_isSymlinkToFile(self: DirEntry): bool{.inline.} = - result = self.is_symlink() - if not result: return - isLinkToFile $self.path - gen_is_xAux is_file, chk_isfile, chk_isSymlinkToFile - gen_is_x is_dir, pcDir, pcLinkToDir - -proc is_junction*(self): bool = - when not defined(windows): false - else: - stat(self).st_reparse_tag == IO_REPARSE_TAG_MOUNT_POINT - -when defined(js): - # readdirSync returns array, which might be too expensive. - proc opendirSync(p: cstring): Dir{.importNode(fs, opendirSync).} - proc closeSync(self: Dir){.importcpp.} - proc readSync(self: Dir): Dirent{.importcpp.} - -when HAVE_FDOPENDIR: - when HAVE_FDOPENDIR_RUNTIME: - when not declared(fdopendir): - proc fdopendir*(fd: cint): ptr Dir{.importc, header: "".} - const HAVE_DIRENT_D_TYPE = compiles(Dirent().d_type) - - proc nimPCKindFromDirent(dir_fd: int, name: string, direntp: ptr Dirent): PathComponent = - ## Determine the PathComponent kind based on the Dirent structure. - when HAVE_DIRENT_D_TYPE: - case direntp.d_type - of DT_DIR: - return pcDir - of DT_REG: - return pcFile - of DT_LNK: - return pcLinkToFile # Assuming symbolic links are treated as links to files - of DT_UNKNOWN: - discard # Fall back to stat if d_type is unknown - else: - discard # Unsupported d_type, fallback to stat - # If d_type is not available, fallback to stat - let st = stat(name, dir_fd=dir_fd) - if S_ISDIR(st.st_mode): - return pcDir - elif S_ISREG(st.st_mode): - return pcFile - elif S_ISLNK(st.st_mode): - if isLinkToFile(name, dir_fd=dir_fd): - return pcLinkToFile - else: - return pcLinkToDir - else: - doAssert false, "unreachable" - -type ScandirNotSupportFd = object of RootEffect -proc eScandirType{.tags: [ScandirNotSupportFd].} = - raise newException(TypeError, - "scandir: path should be string, bytes, os.PathLike or None, not int") -template scandirImpl(path){.dirty.} = - sys.audit("os.scandir", path) - when path is int: - when HAVE_FDOPENDIR: - when HAVE_FDOPENDIR_RUNTIME: - var dirp = fdopendir(cint path) - if dirp.isNil: - raiseErrnoWithPath($path) - # ScandirIterator_iternext - while true: - setErrno0() - var direntp = dirp.readdir() - if direntp.isNil: - if isErr0(): - break - raiseErrnoWithPath($path) - let cname = direntp.d_name - let is_dot = cname[0] == '.' and ( - cname[1] == '\0' or (cname[1] == '.' and cname[2] == '\0') - ) - if not is_dot: - let name = $cname - let de = newDirEntry[T](name = name, dir = path, - kind=nimPCKindFromDirent(path, name, direntp)) - yield de - else: - eScandirType() - else: - eScandirType() - else: - let spath = $path - when defined(js): - var dir: Dir - let cs = cstring($path) - catchJsErrAndRaise: - dir = opendirSync(cs) - var dirent: Dirent - while true: - dirent = dir.readSync() - if dirent.isNull: break - let de = newDirEntry[T](name = $dirent["name"].to(cstring), dir = spath, hasIsFileDir=dirent) - yield de - dir.closeSync - - else: - tryOsOp(spath): - for t in walkDir(spath, relative=true, checkDir=true): - let de = newDirEntry[T](name = t.path, dir = spath, kind = t.kind) - yield de - -iterator scandir*[T](path: PathLike[T]): DirEntry[T] = scandirImpl path -iterator scandir*(path: int): DirEntry[int] = - type T = int - scandirImpl path -iterator scandirIter*[T](path: T): DirEntry[T]{.closure.} = - ## used by os.walk - scandirImpl path - -iterator scandir*(): DirEntry[PyStr] = - for de in scandir[PyStr](str('.')): - yield de - -template scandirProcImpl(path){.dirty.} = - new result - result.iter = iterator(): DirEntry[T] = - for de in scandir(path): yield de - -proc scandir*[T](path: PathLike[T]): ScandirIterator[T] = - scandirProcImpl(path) -proc scandir*(path: int): ScandirIterator[int] = - type T = int - scandirProcImpl(path) - -proc scandir*(): ScandirIterator[PyStr] = - scandir[PyStr](str('.')) diff --git a/src/pylib/Lib/os_impl/posix_like/sched.nim b/src/pylib/Lib/os_impl/posix_like/sched.nim deleted file mode 100644 index 5131ffb10..000000000 --- a/src/pylib/Lib/os_impl/posix_like/sched.nim +++ /dev/null @@ -1,98 +0,0 @@ - -import ./[pyCfg] -importConfig [sched] -export HAVE_SCHED_SETAFFINITY -when HAVE_SCHED_SETAFFINITY: - import ./[errnoUtils, errnoRaise] - type size_t = uint - const NCPUS_START = cint sizeof(culong) * 8 ##\ - ## The minimum number of CPUs allocated in a cpu_set_t - {.push header: "".} - proc CPU_ALLOC(ncpus: cint): ptr CpuSet {.importc.} - proc CPU_ALLOC_SIZE(ncpus: cint): size_t {.importc.} - proc CPU_FREE(set: ptr CpuSet) {.importc.} - proc CPU_ZERO_S(setsize: size_t, set: ptr CpuSet) {.importc.} - proc CPU_SET_S(cpu: cint, setsize: size_t, set: ptr CpuSet) {.importc.} - proc CPU_ISSET_S(cpu: cint, setsize: size_t, set: ptr CpuSet): cint {.importc.} - proc CPU_COUNT_S(setsize: size_t, set: ptr CpuSet): cint {.importc.} - {.pop.} - - template PyErr_NoMemory = - raise newException(OutOfMemDefect, "No memory available") - - template raiseOverflowError(msg) = - raise newException(OverflowDefect, msg) - - proc sched_setaffinityImpl*[T](pid: int, mask: T#[Iterable[int]]#) = - let pid = Pid pid - var ncpus = NCPUS_START - var setsize = CPU_ALLOC_SIZE(ncpus) - var cpu_set = CPU_ALLOC(ncpus) - if cpu_set.isNil: - PyErr_NoMemory() - CPU_ZERO_S(setsize, cpu_set) - - template error = - if not cpu_set.isNil: - CPU_FREE(cpu_set) - for cpu in mask: - if cpu < 0: - error - raise newException(ValueError, "Negative CPU number") - if cpu > cint.high.int - 1: - error - raiseOverflowError("CPU number too large") - let cpu = cast[cint](cpu) - if cpu >= ncpus: - # Grow CPU mask to fit the CPU number - var newncpus = ncpus - while newncpus <= cpu: - if newncpus > typeof(newncpus).high div 2: - newncpus = cpu + 1 - else: - newncpus *= 2 - let newmask = CPU_ALLOC(newncpus) - if newmask.isNil: - error - PyErr_NoMemory() - let newsetsize = CPU_ALLOC_SIZE(newncpus) - CPU_ZERO_S(newsetsize, newmask) - copyMem(newmask, cpu_set, setsize) - CPU_FREE(cpu_set) - setsize = newsetsize - cpu_set = newmask - ncpus = newncpus - CPU_SET_S(cpu, setsize, cpu_set) - - if sched_setaffinity(pid, setsize, cpu_set) != 0: - CPU_FREE(cpu_set) - raiseErrno() - CPU_FREE(cpu_set) - - proc sched_getaffinityImpl*(pid: int, cb: proc (cpu: cint)) = - let pid = Pid pid - var ncpus = NCPUS_START - var setsize: size_t - var mask: ptr CpuSet - - while true: - setsize = CPU_ALLOC_SIZE(ncpus) - mask = CPU_ALLOC(ncpus) - if mask.isNil: - PyErr_NoMemory() - if sched_getaffinity(pid, setsize, mask) == 0: - break - CPU_FREE(mask) - if not isErr EINVAL: - raiseErrno() - #if ncpus > int.high div 2: raise newException(OverflowError, "Could not allocate a large enough CPU set") - ncpus *= 2 - - var cpu = cint 0 - var count = CPU_COUNT_S(setsize, mask) - while count > 0: - if 0 != CPU_ISSET_S(cpu, setsize, mask): - cb cpu - dec count - inc cpu - CPU_FREE(mask) diff --git a/src/pylib/Lib/os_impl/posix_like/seek_consts.nim b/src/pylib/Lib/os_impl/posix_like/seek_consts.nim deleted file mode 100644 index 2b9146a96..000000000 --- a/src/pylib/Lib/os_impl/posix_like/seek_consts.nim +++ /dev/null @@ -1,71 +0,0 @@ - -when defined(nimdoc): - import ../../../version - -const - SEEK_SET* = 0 - SEEK_CUR* = 1 - SEEK_END* = 2 - -const notSEEK012 = false #[ Currently I've found none, trace -https://stackoverflow.com/questions/78819022/ -will-seek-set-seek-cur-seek-end-not-be-0-1-2-on-any-c-lib/78821517]# -when notSEEK012: - {.push header: "".} - # though lseek's `SEEK_*` is said to be in - # it's impossible for them to differ those in - let - SEEK_SET{.importc.}: cint - SEEK_CUR{.importc.}: cint - SEEK_END{.importc.}: cint - {.pop.} - let ordSEEK = - SEEK_SET == 0 and - SEEK_SET == 1 and - SEEK_END == 2 -when notSEEK012: - proc toCSEEK*(whence: int): cint = - if ordSEEK: whence.cint - else: - case whence - of 0: SEEK_SET - of 1: SEEK_CUR - of 2: SEEK_END - else: - # err is handled below; - # also, SEEK_HOLE, SEEL_DATA may be accepted too - whence.cint -else: - template toCSEEK*(whence: int): cint = - whence.cint - - -when defined(nimdoc): - # Currently no way add document comment node to let via macro - template SEEK_DATA*: int{.pysince(3,3).} = - ## not defined in Windows - ## - ## .. note:: this is in fact a runtime constant, - ## defined as template only during document generation process. - ## **Cannot** use as `SEEK_DATA()` (with parentheses). - ## - ## .. hint:: only usable if `` in your system defines it, - ## - ## .. hint:: only supported on some filesystems, - ## refer to your system's manpage of `lseek` - template SEEK_HOLE*: int{.pysince(3,3).} = - ## see `SEEK_DATA`_ for hints. -else: - when not defined(js) and not defined(windows): - {.emit: """ - /*INCLUDE_SECTION*/ - #define _GNU_SOURCE - """.} - {.push header: "".} - let - sdata{.importc: "SEEK_DATA".}: cint - shole{.importc: "SEEK_HOLE".}: cint - {.pop.} - let - SEEK_DATA* = int sdata - SEEK_HOLE* = int shole diff --git a/src/pylib/Lib/os_impl/posix_like/stat.nim b/src/pylib/Lib/os_impl/posix_like/stat.nim deleted file mode 100644 index 09859ea30..000000000 --- a/src/pylib/Lib/os_impl/posix_like/stat.nim +++ /dev/null @@ -1,683 +0,0 @@ - -from std/os import raiseOSError, osLastError - -import ../common -import ./pyCfg -import ../util/handle_signal - -importConfig [ - stats, - os -] -when InJS: - template decl(f, val) = - const `HAVE f` = val - decl lstat, true - decl fstatat, false - -const NO_FOLLOW_SYMLINKS = not (HAVE_FSTATAT or HAVE_LSTAT or useMS_WINDOWSproc) -import ./chkarg -import std/macros - - -#[ XXX: extact from CPython-3.13-alpha/Modules/posix L1829 - /* The CRT of Windows has a number of flaws wrt. its stat() implementation: - - time stamps are restricted to second resolution - - file modification times suffer from forth-and-back conversions between - UTC and local time - Therefore, we implement our own stat, based on the Win32 API directly. -*/ -TODO: impl our own stat... Get rid of `_wstat` -]# - -const DWin = defined(windows) -when InJs: - import std/jsffi - import ./jsStat - template impStatTAttr[T](attr; dstAttr; cvt: typed) = - func attr*(self: Stat): T = - let res = self.dstAttr - if res.isNull: - raise newException(AttributeError, - "'os.stat_result' object has no attribute '" & astToStr(attr) & '\'') - result = cvt[T] res - template jsToT[T](jsObj: JsObject): T = jsObj.to T - template impStatTAttr[T](attr; dstAttr) = - impStatTAttr[T](attr, dstAttr, jsToT) - - template impStatIAttr(attr; dstAttr; typ) = - type typ = cdouble - impStatTAttr[typ](attr, dstAttr) - template impStatIAttr(attr; dstAttr) = impStatTAttr[cdouble](attr, dstAttr) - impStatIAttr st_ino, ino, Ino - impStatIAttr st_mode, mode, Mode - impStatIAttr st_nlink, nlink, Nlink - impStatIAttr st_uid, uid, Uid - impStatIAttr st_gid, gid, Gid - impStatIAttr st_dev, dev, Dev - impStatIAttr st_rdev, rdev - impStatIAttr st_size, size, Off - impStatIAttr st_blocks, blocks, Blkcnt - impStatIAttr st_blksize,blksize,Blksize - - func rawValueOf(obj: Date): c_double{.importjs: "(#).valueOf()".} - template chkDate(obj: Date) = - if obj.isNull: # may be null on some platform - raise newException(OSError, - "get date from stat_result is supported in your platform") - func dateToSec(obj: Date): float = - # the number of milliseconds for this date since the epoch - chkDate obj - obj.rawValueOf().float / 1000 - func dateToNs(obj: Date): BiggestInt = - chkDate obj - BiggestInt obj.rawValueOf() - - -else: - when DWin: - import ../util/[ - mywinlean, getFileInfo] - import ../../../pyerrors/oserr/PC_errmap - import ./errnoUtils - import ../../n_stat - import ../../stat_impl/consts except FILE_ATTRIBUTE_DIRECTORY, - BY_HANDLE_FILE_INFORMATION, FILE_ATTRIBUTE_REPARSE_POINT - import ../util/get_osfhandle - #type Time64 = int64 - when defined(nimPreviewSlimSystem): - import std/widestrs - type - Dev = uint64 - Ino = uint64 - Mode = cushort - Nlink = cuint ## CPython uses cint, but BY_HANDLE_FILE_INFORMATION.nNumberOfLinks is unsigned - Uid = cint - Gid = cint - Rdev = uint32 - Size = int64 - Time{.importc: "time_t", header: "".} = int64 ## int32 ifdef _USE_32BIT_TIME_T - Nsec = cint - FileAttributes = uint32 - ReparseTag = uint32 - InoHigh = uint64 - - Stat = object - st_dev*: Dev - st_ino*: Ino - st_mode*: Mode - st_nlink*: Nlink - st_uid*: Uid - st_gid*: Gid - st_rdev*: Rdev - st_size*: Size - st_atime*: Time - st_atime_nsec*: Nsec - st_mtime*: Time - st_mtime_nsec*: Nsec - st_ctime*: Time - st_ctime_nsec*: Nsec - st_birthtime*: Time - st_birthtime_nsec*: Nsec - st_file_attributes*: FileAttributes - st_reparse_tag*: ReparseTag - st_ino_high: InoHigh - else: - import std/posix - - when HAVEfstatatRUNTIME and not declared(fstatat): - proc fstatat(dir_fd: cint, path: cstring, st: var Stat, - flag: cint): cint{.importc, header: "".} - template fstatat(dir_fd: int, path: cstring, st: var Stat, - flag: int): cint = - fstatat(cint dir_fd, path, st, cint flag) - -type - stat_result* = ref object - data*: Stat ## inner, used by `getattr` of `stat_result` - -macro genTimeGetter(amc: static[char]) = - result = newStmtList() - let - js_s_xtime = amc & "time" - js_xtime = ident js_s_xtime - js_getxtime = ident("get" & js_s_xtime) - let s_st_xtim = "st_" & amc & "tim" - let - xtim = ident s_st_xtim - xtime = ident(s_st_xtim & 'e') - let - xtime_ns = ident(s_st_xtim & "e_ns") - result = quote do: - when InJs: - func `js_getxtime`*(s: Stat): float = - ## inner, used by os.path - s.`js_xtime`.dateToSec() - func `xtime`*(self: stat_result): float = - when InJs: - `js_getxtime` self.data - else: - when compiles(self.data.`xtim`): - self.data.`xtim`.tv_sec.float + self.data.`xtim`.tv_nsec/1_000_000_000 - else: - self.data.`xtime`.float - func `xtime_ns`*(self: stat_result): BiggestInt{.pysince(3,3).} = - when InJs: - self.data.`js_xtime`.dateToNs() - else: - when compiles(self.data.`xtim`): - self.data.`xtim`.tv_sec.BiggestInt * 1_000_000_000 + - self.data.`xtim`.tv_nsec.BiggestInt - else: - self.data.`xtime`.BiggestInt * 1_000_000_000 - -genTimeGetter 'a' -genTimeGetter 'm' -genTimeGetter 'c' - -{.experimental: "dotOperators".} -template `.`*(self: stat_result; attr): untyped = - ## as Python's `__getattr__` - self.data.attr - -const visible_size = 10 - -func getitem(self: stat_result, i: int): BiggestInt = - # this proc was once generated by macro - case i - of 0: result = BiggestInt self.data.st_ino - of 1: result = BiggestInt self.data.st_mode - of 2: result = BiggestInt self.data.st_nlink - of 3: result = BiggestInt self.data.st_uid - of 4: result = BiggestInt self.data.st_gid - of 5: result = BiggestInt self.data.st_dev - of 6: result = BiggestInt self.data.st_size - of 7: result = BiggestInt self.st_atime - of 8: result = BiggestInt self.st_mtime - of 9: result = BiggestInt self.st_ctime - else: - raise newException(IndexDefect, "tuple index out of range") - -func `[]`*(self: stat_result, i: int): BiggestInt = - self.getitem(if i < 0: visible_size + i else: i) - -func to_result(s: sink Stat): stat_result = - result = stat_result(data: s) - -when InJs: - proc statAux(st: var Stat, path: int|string) = - catchJsErrAndRaise: - st = - when path is int: - fstatSync(path.cint) - else: - let cs = cstring(path) - statSync(cs) - proc fstatAux(st: var Stat, fd: int) = - catchJsErrAndRaise: - st = fstatSync(fd.cint) - proc lstatAux(st: var Stat, path: PathLike) = - catchJsErrAndRaise: - st = block: - let cs = cstring($path) - lstatSync(cs) - -template statAttr*(path: PathLike|int, attr: untyped): untyped = - ## stat(`path`).`attr` - var st{.noinit.}: Stat - statAux st, path - st.attr - - -when DWin: - const secs_between_epochs = 11644473600'i64 # Seconds between 1.1.1601 and 1.1.1970 - - proc FILE_TIME_to_time_t_nsec(in_ptr: FILETIME, time_out: var Time, nsec_out: var cint) = - let i = cast[int64](in_ptr) - nsec_out = cint((i mod 10_000_000) * 100) # FILETIME is in units of 100 nsec. - time_out = Time((i div 10_000_000) - secs_between_epochs) - - proc LARGE_INTEGER_to_time_t_nsec(in_ptr: LARGE_INTEGER, time_out: var Time, nsec_out: var cint) = - nsec_out = cint((in_ptr.QuadPart mod 10_000_000) * 100) # FILETIME is in units of 100 nsec. - time_out = Time((in_ptr.QuadPart div 10_000_000) - secs_between_epochs) - - - template M(i): Mode = cast[Mode](i) - proc attributes_to_mode(attr: DWORD): Mode = - result = - if (attr and DWORD FILE_ATTRIBUTE_DIRECTORY) != 0: - result or S_IFDIR.M or 0o111 # IFEXEC for user, group, other - else: - result or S_IFREG.M - result = - if (attr and DWORD FILE_ATTRIBUTE_READONLY) != 0: - result or 0o444 - else: - result or 0o666 - - - type id_128_to_ino = object - case split: bool - of false: - id: FILE_ID_128 - of true: - st_ino: uint64 - st_ino_high: uint64 - - proc Py_attribute_data_to_stat(info: var BY_HANDLE_FILE_INFORMATION, reparse_tag: ULONG, - basic_info: ptr FILE_BASIC_INFO, id_info: ptr FILE_ID_INFO, - result: var Stat) = - - result = Stat() - result.st_mode = attributes_to_mode(info.dwFileAttributes) - result.st_size = (int64(info.nFileSizeHigh) shl 32) + int64(info.nFileSizeLow) - result.st_dev = (if not id_info.isNil: id_info.VolumeSerialNumber.Dev else: info.dwVolumeSerialNumber.Dev) - #result.st_rdev = 0 - - if not basic_info.isNil: - LARGE_INTEGER_to_time_t_nsec(basic_info.CreationTime, result.st_birthtime, result.st_birthtime_nsec) - LARGE_INTEGER_to_time_t_nsec(basic_info.ChangeTime, result.st_ctime, result.st_ctime_nsec) - LARGE_INTEGER_to_time_t_nsec(basic_info.LastWriteTime, result.st_mtime, result.st_mtime_nsec) - LARGE_INTEGER_to_time_t_nsec(basic_info.LastAccessTime, result.st_atime, result.st_atime_nsec) - else: - FILE_TIME_to_time_t_nsec(info.ftCreationTime, result.st_birthtime, result.st_birthtime_nsec) - FILE_TIME_to_time_t_nsec(info.ftLastWriteTime, result.st_mtime, result.st_mtime_nsec) - FILE_TIME_to_time_t_nsec(info.ftLastAccessTime, result.st_atime, result.st_atime_nsec) - - result.st_nlink = info.nNumberOfLinks - - if not id_info.isNil: - var file_id: id_128_to_ino - file_id.id = id_info.FileId - file_id.split = true - result.st_ino = file_id.st_ino - result.st_ino_high = file_id.st_ino_high - - if result.st_ino == 0 and result.st_ino_high == 0: - result.st_ino = (uint64(info.nFileIndexHigh) shl 32) + uint64(info.nFileIndexLow) - - if (info.dwFileAttributes and DWORD FILE_ATTRIBUTE_REPARSE_POINT) != 0 and (reparse_tag == ULONG IO_REPARSE_TAG_SYMLINK): - result.st_mode = (result.st_mode and not Mode S_IFMT_val) or S_IFLNK.Mode - - result.st_file_attributes = info.dwFileAttributes - - proc Py_stat_basic_info_to_stat(info: var FILE_STAT_BASIC_INFORMATION, result: var Stat) = - result = Stat() - result.st_mode = attributes_to_mode(info.FileAttributes) - result.st_size = info.EndOfFile.QuadPart - LARGE_INTEGER_to_time_t_nsec(info.CreationTime, result.st_birthtime, result.st_birthtime_nsec) - LARGE_INTEGER_to_time_t_nsec(info.ChangeTime, result.st_ctime, result.st_ctime_nsec) - LARGE_INTEGER_to_time_t_nsec(info.LastWriteTime, result.st_mtime, result.st_mtime_nsec) - LARGE_INTEGER_to_time_t_nsec(info.LastAccessTime, result.st_atime, result.st_atime_nsec) - result.st_nlink = info.NumberOfLinks - result.st_dev = info.VolumeSerialNumber.QuadPart.Dev - - var file_id: id_128_to_ino - file_id.id = info.FileId128 - file_id.split = true - result.st_ino = file_id.st_ino - result.st_ino_high = file_id.st_ino_high - - result.st_reparse_tag = info.ReparseTag - if (info.FileAttributes and DWORD FILE_ATTRIBUTE_REPARSE_POINT) != 0 and - info.ReparseTag == ULONG IO_REPARSE_TAG_SYMLINK: - result.st_mode = (result.st_mode and not Mode S_IFMT_val) or S_IFLNK.Mode - - result.st_file_attributes = info.FileAttributes - - case info.DeviceType - of FILE_DEVICE_DISK, FILE_DEVICE_VIRTUAL_DISK, FILE_DEVICE_DFS, - FILE_DEVICE_CD_ROM, FILE_DEVICE_CONTROLLER, FILE_DEVICE_DATALINK: - discard - of FILE_DEVICE_DISK_FILE_SYSTEM, FILE_DEVICE_CD_ROM_FILE_SYSTEM, FILE_DEVICE_NETWORK_FILE_SYSTEM: - result.st_mode = (result.st_mode and not Mode S_IFMT_val) or 0x6000.Mode - of FILE_DEVICE_CONSOLE, FILE_DEVICE_NULL, FILE_DEVICE_KEYBOARD, - FILE_DEVICE_MODEM, FILE_DEVICE_MOUSE, FILE_DEVICE_PARALLEL_PORT, - FILE_DEVICE_PRINTER, FILE_DEVICE_SCREEN, FILE_DEVICE_SERIAL_PORT, - FILE_DEVICE_SOUND: - result.st_mode = (result.st_mode and not Mode S_IFMT_val) or S_IFCHR.Mode - of FILE_DEVICE_NAMED_PIPE: - result.st_mode = (result.st_mode and not Mode S_IFMT_val) or S_IFIFO.Mode - else: - if (info.FileAttributes and DWORD FILE_ATTRIBUTE_DIRECTORY) != 0: - result.st_mode = (result.st_mode and not Mode S_IFMT_val) or S_IFDIR.Mode - -when DWin: - proc findDataToFileInfo(pFileData: WIN32_FIND_DATAW, - info: var BY_HANDLE_FILE_INFORMATION, - reparseTag: var ULONG) = - info = BY_HANDLE_FILE_INFORMATION() - info.dwFileAttributes = pFileData.dwFileAttributes - info.ftCreationTime = pFileData.ftCreationTime - info.ftLastAccessTime = pFileData.ftLastAccessTime - info.ftLastWriteTime = pFileData.ftLastWriteTime - info.nFileSizeHigh = pFileData.nFileSizeHigh - info.nFileSizeLow = pFileData.nFileSizeLow - if (pFileData.dwFileAttributes and DWORD FILE_ATTRIBUTE_REPARSE_POINT) != 0: - reparseTag = pFileData.dwReserved0 - else: - reparseTag = 0 - - template `==`(wc: Utf16Char, c: char): bool = cast[uint16](wc) == uint16(c) - template L(c: char): Utf16Char = Utf16Char(c) - template L(s: string): WideCString = newWideCString(s) - proc attributesFromDir(pszFile: WideCString, - info: var BY_HANDLE_FILE_INFORMATION, - reparseTag: var ULONG): bool = - var hFindFile: HANDLE - var fileData: WIN32_FIND_DATAW - var filename = pszFile - var n = pszFile.len - if n > 0 and (pszFile[n - 1] == '\\' or pszFile[n - 1] == '/'): - filename = cast[WideCString](alloc((n + 1) * sizeof(filename[0]))) - if filename.isNil: - setLastError(ERROR_NOT_ENOUGH_MEMORY) - return false - copyMem(filename, pszFile, n+1) - while n > 0 and (filename[n - 1] == '\\' or filename[n - 1] == '/'): - filename[n - 1] = L'\0' - dec n - if n == 0 or (n == 1 and filename[1] == ':'): - dealloc(filename) - return false - hFindFile = FindFirstFileW(filename, fileData) - if pszFile != filename: - dealloc(filename) - if hFindFile == INVALID_HANDLE_VALUE: - return false - findClose(hFindFile) - findDataToFileInfo(fileData, info, reparseTag) - return true - - proc wcsrchr(wcs: WideCString, c: Utf16Char): WideCString{.importc, header: "".} - proc wcsicmp(s1, s2: WideCString): int{.importc, header: "".} - - proc updateStModeFromPath(path: LPCWSTR, attr: DWORD, - status: var Stat) = - if (attr and DWORD FILE_ATTRIBUTE_DIRECTORY) == 0: - let fileExtension = wcsrchr(path, L'.') - if not fileExtension.isNil: - if wcsicmp(fileExtension, L".exe") == 0 or - wcsicmp(fileExtension, L".bat") == 0 or - wcsicmp(fileExtension, L".cmd") == 0 or - wcsicmp(fileExtension, L".com") == 0: - status.st_mode = status.st_mode or 0o111 - - proc win32_xstat_slow_impl(path: LPCWSTR, status: var Stat, - traverse: bool): cint = - - var traverse = traverse - - var hFile: HANDLE - var fileInfo: BY_HANDLE_FILE_INFORMATION - var basicInfo: FILE_BASIC_INFO - var pBasicInfo: ptr FILE_BASIC_INFO = nil - var idInfo: FILE_ID_INFO - var pIdInfo: ptr FILE_ID_INFO = nil - var tagInfo: FILE_ATTRIBUTE_TAG_INFO - var fileType, error: DWORD - var isUnhandledTag = false - var retval = cint 0 - template goto_cleanup = - if hFile != INVALID_HANDLE_VALUE: - error = if retval != 0: GetLastError() else: 0 - if closeHandle(hFile) == 0: - retval = -1 - elif retval != 0: - SetLastError(error) - return retval - - var access = DWORD FILE_READ_ATTRIBUTES - var flags = DWORD FILE_FLAG_BACKUP_SEMANTICS - if not traverse: - flags = flags or DWORD FILE_FLAG_OPEN_REPARSE_POINT - - hFile = CreateFileW(path, access, 0, nil, OPEN_EXISTING, flags, 0) - if hFile == INVALID_HANDLE_VALUE: - error = GetLastError() - case error - of ERROR_ACCESS_DENIED, ERROR_SHARING_VIOLATION: - if not attributesFromDir(path, fileInfo, tagInfo.ReparseTag): - return -1 - of ERROR_INVALID_PARAMETER: - hFile = CreateFileW(path, access or GENERIC_READ, - FILE_SHARE_READ or FILE_SHARE_WRITE, nil, - OPEN_EXISTING, flags, 0) - if hFile == INVALID_HANDLE_VALUE: - return -1 - of ERROR_CANT_ACCESS_FILE: - if traverse: - traverse = false - isUnhandledTag = true - hFile = CreateFileW(path, access, 0, nil, OPEN_EXISTING, - flags or FILE_FLAG_OPEN_REPARSE_POINT, 0) - if hFile == INVALID_HANDLE_VALUE: - return -1 - else: - return -1 - - if hFile != INVALID_HANDLE_VALUE: - fileType = GetFileType(hFile) - if fileType != FILE_TYPE_DISK: - if fileType == FILE_TYPE_UNKNOWN and getLastError() != 0: - retval = -1 - goto_cleanup - let fileAttributes = GetFileAttributesW(path) - status = Stat() - if fileAttributes != INVALID_FILE_ATTRIBUTES and - (fileAttributes and FILE_ATTRIBUTE_DIRECTORY) != 0: - status.st_mode = M S_IFDIR - elif fileType == FILE_TYPE_CHAR: - status.st_mode = M S_IFCHR - elif fileType == FILE_TYPE_PIPE: - status.st_mode = M S_IFIFO - goto_cleanup - - if not traverse: - if not GetFileInformationByHandleEx(hFile, FILE_INFO_BY_HANDLE_CLASS.FileAttributeTagInfo, - tagInfo): - retval = -1 - goto_cleanup - - if not GetFileInformationByHandle(hFile, fileInfo) or - not GetFileBasicInformationByHandleEx(hFile, basicInfo): - retval = -1 - goto_cleanup - - pBasicInfo = addr basicInfo - if GetFileInformationByHandleEx(hFile, FILE_INFO_BY_HANDLE_CLASS.FileIdInfo, idInfo): - pIdInfo = addr idInfo - - Py_attribute_data_to_stat(fileInfo, tagInfo.ReparseTag, pBasicInfo, pIdInfo, status) - updateStModeFromPath(path, fileInfo.dwFileAttributes, status) - - goto_cleanup - - - proc win32_xstat_impl(path: LPCWSTR, status: var Stat, traverse: bool): cint = - var statInfo: FILE_STAT_BASIC_INFORMATION - if Py_GetFileInformationByName(path, FileStatBasicByNameInfo, addr statInfo, sizeof(statInfo).DWORD): - if (statInfo.FileAttributes and DWORD FILE_ATTRIBUTE_REPARSE_POINT) == 0 or - (not traverse and IsReparseTagNameSurrogate(statInfo.ReparseTag)): - Py_stat_basic_info_to_stat(statInfo, status) - updateStModeFromPath(path, statInfo.FileAttributes, status) - return 0 - else: - case GetLastError() - of ERROR_FILE_NOT_FOUND, ERROR_PATH_NOT_FOUND, ERROR_NOT_READY, ERROR_BAD_NET_NAME: - # These errors aren't worth retrying with the slow path - return -1 - #of ERROR_NOT_SUPPORTED: # Indicates the API couldn't be loaded - else: - discard - - return win32_xstat_slow_impl(path, status, traverse) - - proc win32_xstat(path: WideCString, status: var Stat, traverse: bool): cint = - #[Protocol violation: we explicitly clear errno, instead of - setting it to a POSIX error. Callers should use GetLastError.]# - result = win32_xstat_impl(path, status, traverse) - setErrno0 - - # ctime is only deprecated from 3.12, so we copy birthtime across - status.st_ctime = status.st_birthtime - status.st_ctime_nsec = status.st_birthtime_nsec - -template def3STAT(S, L, F){.dirty.} = - template STATf(p: string, s): cint= S - template LSTAT(p: string, s): cint = L - template FSTAT(p: int, s): cint = F - - -when DWin: - def3STAT( - win32_xstat(newWideCString p, s, true), - win32_xstat(newWideCString p, s, false), - Py_fstat_noraise(p, s), - ) -elif InJs: - template ret0(body): cint = - body - 0 - def3STAT( - ret0 statAux(s, p), - ret0 lstatAux(s, p), - ret0 fstatAux(s, p), - ) -else: - def3STAT( - posix.stat(cstring p, s), - posix.lstat(cstring p, s), - posix.fstat(cint p, s), - ) - -proc Py_fstat_noraise*(fd: int, status: var Stat): cint = - ## EXT. - ## - ## fileutils.c `_Py_fstat_noraise` - when DWin: - var - info: BY_HANDLE_FILE_INFORMATION - basicInfo: FILE_BASIC_INFO - idInfo: FILE_ID_INFO - pIdInfo = addr idInfo - - h = Py_get_osfhandle_noraise(fd) - - if h == INVALID_HANDLE_VALUE: - #[ errno is already set by _get_osfhandle, but we also set - the Win32 error for callers who expect that]# - setLastError ERROR_INVALID_HANDLE - return -1 - - status = Stat() - - let typ = GetFileType(h) - if typ == FILE_TYPE_UNKNOWN: - let error = cint getLastError() - if error != 0: - setErrnoRaw winerror_to_errno error - return -1 - # else: valid but unknown file - - if typ != FILE_TYPE_DISK: - if typ == FILE_TYPE_CHAR: - status.st_mode = M S_IFCHR - elif typ == FILE_TYPE_PIPE: - status.st_mode = M S_IFIFO - return 0 - - if GetFileInformationByHandle(h, info) == FALSE or - !GetFileBasicInformationByHandleEx(h, basicInfo): - #[The Win32 error is already set, but we also set errno for - callers who expect it]# - setErrnoRaw winerror_to_errno cint getLastError() - return -1 - - if !GetFileBasicInformationByHandleEx(h, basicInfo): - # Failed to get FileIdInfo, so do not pass it along - pIdInfo = nil - - Py_attribute_data_to_stat(info, 0, addr basicInfo, pIdInfo, status) - return 0 - elif InJS: - int FSTAT(fd, status) - -proc Py_fstat*(fd: int, status: var Stat) = - ## EXT. - ## - ## fileutils.c `_Py_fstat` - if Py_fstat_noraise(fd, status) != 0: - raiseOSError osLastError() - -proc do_stat_impl(result: var Stat; function_name: string, path: string|int, dir_fd: int, follow_symlinks: bool) = - when HAVE_FSTATAT: - var fstatat_unavailable = false - var res: cint - when NO_FOLLOW_SYMLINKS: - if follow_symlinks_specified(function_name, follow_symlinks): - return - template doStat = - res = STATf(path, result) - template doFstatat = - when HAVE_FSTATAT: - if dir_fd != DEFAULT_DIR_FD or not follow_symlinks: - when HAVE_FSTATAT_RUNTIME: - res = fstatat(dir_fd, cstring path, result, - if follow_symlinks: 0 else: AT_SYMLINK_NOFOLLOW) - else: - fstat_unavailable = true - else: - doStat() - else: - doStat() - - let path_fd = (when path is int: path else: -1) - if function_name == "stat": - if path_and_dir_fd_invalid("stat", path, dir_fd) or - dir_fd_and_fd_invalid("stat", dir_fd, path_fd) or - fd_and_follow_symlinks_invalid("stat", path_fd, follow_symlinks): - return - let path = (when path is int :"" else: path) - if path_fd != -1: - res = FSTAT(path_fd, result) - else: - when DWin: - if follow_symlinks: - res = STATf(path, result) - else: - res = LSTAT(path, result) - else: - when HAVE_LSTAT: - if not follow_symlinks and dir_fd == DEFAULT_DIR_FD: - res = LSTAT(path, result) - else: - doFstatat - else: - doFstatat - -template withSt(body): stat_result{.dirty.} = - bind to_result, Stat - var st{.noinit.}: Stat - body - to_result st - -proc do_stat(function_name: string, path: string|int, dir_fd = DEFAULT_DIR_FD, follow_symlinks = true): stat_result = - withSt: - st.do_stat_impl(function_name, path, dir_fd, follow_symlinks) - -proc stat*[T](path: PathLike[T], dir_fd = DEFAULT_DIR_FD, follow_symlinks = true): stat_result = - do_stat("stat", $path, dir_fd, follow_symlinks) - -proc stat*(path: int, dir_fd = DEFAULT_DIR_FD, follow_symlinks = true): stat_result = - do_stat("stat", path, dir_fd, follow_symlinks) - -proc lstat*[T](path: PathLike[T], dir_fd = DEFAULT_DIR_FD): stat_result = - do_stat("lstat", $path, dir_fd, false) - - -proc fstat*(fd: int): stat_result = - let fd = cint fd - var res: cint - withSt: - initVal_with_handle_signal(res, FSTAT(fd, st)) diff --git a/src/pylib/Lib/os_impl/posix_like/truncate.nim b/src/pylib/Lib/os_impl/posix_like/truncate.nim deleted file mode 100644 index 9f2eae9c0..000000000 --- a/src/pylib/Lib/os_impl/posix_like/truncate.nim +++ /dev/null @@ -1,52 +0,0 @@ - -import ../common - -when defined(js): - proc ftruncateSync(file: cint; len: cint){.importNode(fs, ftruncateSync).} - proc ftruncateImpl(file: Positive; length: Natural) = - catchJsErrAndRaise ftruncateSync(file.cint, length.cint) - proc truncateSync(file: cstring; len: cint){.importNode(fs, truncateSync).} - proc truncateImpl(file: CanIOOpenT; length: Natural) = - when file is int: - ftruncateImpl file, length - else: - catchJsErrAndRaise truncateSync(file.cstring, length.cint) - -else: - import std/os - import ./open_close - when defined(windows): - # errno_t _chsize_s(int _FileHandle, __int64 _Size); - proc chsize_s(fd: cint, size: int64): cint{.importc:"_chsize_s", header:"".} - else: - import std/posix - - template ftruncateImplAux(file: Positive, length: int64): cint = - when defined(windows): - chsize_s(file.cint, length) - else: - posix.ftruncate(file.cint, length.Off) - - proc ftruncateImpl(file: Positive, length: int64) = - let err = ftruncateImplAux(file, length) - if err.int != 0: - raiseErrno err - - proc truncateImpl(file: CanIOOpenT, length: Natural) = - when file is int: - ftruncateImpl file, length - else: - let fd = open(file, os.O_WDONLY) - let err = ftruncateImpl(fd, length) - if 0 != err: - file.raiseErrnoWithPath err - close(fd) - -proc ftruncate*(file: Positive, length: Natural) = - sys.audit("os.truncate", file, length) - ftruncateImpl(file, length) - -proc truncate*(file: CanIOOpenT, length: Natural) = - sys.audit("os.truncate", file, length) - truncateImpl(file, length) - diff --git a/src/pylib/Lib/os_impl/posix_like/umaskImpl.nim b/src/pylib/Lib/os_impl/posix_like/umaskImpl.nim deleted file mode 100644 index becd2685b..000000000 --- a/src/pylib/Lib/os_impl/posix_like/umaskImpl.nim +++ /dev/null @@ -1,14 +0,0 @@ - -when defined(windows): - proc umask(mode: cint): cint {.importc: "_umask", header: "".} -else: - import std/posix - -import ../common # raiseErrno - -proc umask*(mode: int): int{.discardable.} = - result = - when defined(windows): int umask(mode.cint) - else: int posix.umask(mode.Mode) - if result < 0: - raiseErrno() diff --git a/src/pylib/Lib/os_impl/posix_like/unameImpl.nim b/src/pylib/Lib/os_impl/posix_like/unameImpl.nim deleted file mode 100644 index 899422638..000000000 --- a/src/pylib/Lib/os_impl/posix_like/unameImpl.nim +++ /dev/null @@ -1,75 +0,0 @@ - -import ./pyCfg -importConfig [os] -template genUnameResult(S){.dirty.} = - type uname_result* = tuple[ - sysname, - nodename, - release, - version, - machine: S - ] -when HAVE_UNAME: - import std/posix - import ./errnoRaise - proc utsFieldToString[T](field: T): string = - # Implementation of utsFieldToString goes here - when T is array: # array of char - result = newStringOfCap(field.len) - var i = 0 - while field[i] != '\0': - assert i < field.len - result.add field[i] - i.inc - else: $field - template posix_uname(u): cint = - bind uname - uname(u) - template genUname*(S){.dirty.} = - bind posix_uname, utsFieldToString, Utsname - bind genUnameResult - genUnameResult(S) - proc uname*(): uname_result = - var u{.noInit.}: Utsname - let res = posix_uname(u) - if res < 0: - raiseErrno() - template SET(field) = - result.field = S utsFieldToString(u.field) - {.push hint[ConvFromXtoItselfNotNeeded]: off.} - SET sysname - SET nodename - SET release - SET version - SET machine - {.pop.} - -elif InJs: - import ../common - template genUname*(S){.dirty.} = - bind genUnameResult - genUnameResult(S) - proc uname*(): uname_result = - proc getSysname: cstring{.importInNodeModOrDeno(os, "type", "build.os$").} - proc getNodename: cstring{.importDenoOrNodeMod(os, hostname).} - proc getRelease: cstring{.importInNodeModOrDeno(os, release, osRelease).} - proc getVersion: cstring{.importNode(os, version).} - proc getMachine: cstring{.importInNodeModOrDeno(os, machine, "build.arch$").} - template SET(field) = - result.field = S $`get field`() - SET sysname - SET nodename - SET release - SET version - SET machine - - #SET sysname, `type`, `build.os` # attr # "windows": "Windows_NT", caption -else: - template genUname*(S){.dirty.} = - bind genUnameResult - genUnameResult(S) - # do nothing other than define the type - -when isMainModule: - genUname string - echo uname() diff --git a/src/pylib/Lib/os_impl/posix_like/unlink.nim b/src/pylib/Lib/os_impl/posix_like/unlink.nim deleted file mode 100644 index 517befcba..000000000 --- a/src/pylib/Lib/os_impl/posix_like/unlink.nim +++ /dev/null @@ -1,38 +0,0 @@ - -import ./unlinkImpl -import ./pyCfg -import ./chkarg -import ../private/iph_utils - -importConfig [ - os -] -when InJs: - template decl(f, val) = - const `HAVE f` = val - decl unlinkat, false - -proc unlink*[T](p: PathLike[T], dir_fd=DEFAULT_DIR_FD) = - sys.audit("os.remove", p, if dir_fd==DEFAULT_DIR_FD: -1 else: dir_fd) - var res: cint - with_Py_SUPPRESS_IPH: - when HAVE_UNLINKAT: - var unlinkat_unavailable = false - if dir_fd != DEFAULT_DIR_FD: - when HAVE_UNLINKAT_RUNTIME: - res = unlinkat(dir_fd.cint, cstring $p, 0) - else: - unlinkat_unavailable = true - else: - unlinkImpl(p) - else: - unlinkImpl(p) - when HAVE_UNLINKAT: - if unlinkat_unavailable: - argument_unavailable_error("dir_fd") - if res != 0: - raiseExcWithPath(p) - -proc remove*[T](p: PathLike[T], dir_fd=DEFAULT_DIR_FD) = - ## This function is semantically identical to `unlink`_ - unlink(p, dir_fd) diff --git a/src/pylib/Lib/os_impl/posix_like/unlinkImpl.nim b/src/pylib/Lib/os_impl/posix_like/unlinkImpl.nim deleted file mode 100644 index b576f0d14..000000000 --- a/src/pylib/Lib/os_impl/posix_like/unlinkImpl.nim +++ /dev/null @@ -1,76 +0,0 @@ - -import ../common -include ./ncommon -export common - - -when InJs: - proc unlinkSync(path: cstring){.importNode(fs, unlinkSync).} - proc unlinkImpl*(p: PathLike) = - let cs = cstring $p - catchJsErrAndRaise: - unlinkSync cs - #[ XXX: NIM-BUG: if as follows, when JS, - Error: internal error: genTypeInfo(tyUserTypeClassInst) - catchJsErrAndRaise: - unlinkSync(cstring($p)) - ]# -else: - when defined(windows): - import ../util/mywinlean - type - GET_FILEEX_INFO_LEVELS = enum - GetFileExInfoStandard = cint 0 - GetFileExMaxInfoLevel = cint 1 - WIN32_FILE_ATTRIBUTE_DATA{.importc, header: "", - incompleteStruct.} = object - dwFileAttributes: mywinlean.DWORD - - proc GetFileAttributesExW(lpFileName: LPCWSTR, fInfoLevelId: GET_FILEEX_INFO_LEVELS, - lpFileInformation: pointer): BOOL{.importc, header: "".} - proc Py_DeleteFileW*(lpFileName: LPCWSTR): BOOL = - var info: WIN32_FILE_ATTRIBUTE_DATA - var find_data: WIN32_FIND_DATAW - var is_directory = false - var is_link = false - - if GetFileAttributesExW(lpFileName, GetFileExInfoStandard, addr info): - is_directory = bool info.dwFileAttributes and FILE_ATTRIBUTE_DIRECTORY - - # Get WIN32_FIND_DATA structure for the path to determine if it is a symlink - if is_directory and (info.dwFileAttributes and FILE_ATTRIBUTE_REPARSE_POINT) != 0: - let find_data_handle = FindFirstFileW(lpFileName, find_data) - - if find_data_handle != INVALID_HANDLE_VALUE: - # IO_REPARSE_TAG_SYMLINK if it is a symlink and - # IO_REPARSE_TAG_MOUNT_POINT if it is a junction point. - is_link = (find_data.dwReserved0 == IO_REPARSE_TAG_SYMLINK) or - (find_data.dwReserved0 == IO_REPARSE_TAG_MOUNT_POINT) - FindClose(find_data_handle) - - if is_directory and is_link: - return BOOL removeDirectoryW(lpFileName) - - return BOOL deleteFileW(lpFileName) - - # from nim-2.1.2/lib/std/private/osfiles.nim `proc tryRemoveFile` - proc unlinkAux[T](p: PathLike[T] - ): bool {.noWeirdTarget.} = - ## Removes the file at `p`. - ## - ## If this fails, returns `false`. - ## This raises `FileNotFoundError` - ## if the file never existed. - ## - ## On Windows, ignores the read-only attribute. - ## - let file = $p - when defined(windows): - let f = newWideCString(file) - if Py_DeleteFileW(f): ## returns TRUE - return true - else: - if unlink(cstring file) == 0'i32: return true # success - proc unlinkImpl*(p: PathLike) = - if not unlinkAux(p): - p.raiseExcWithPath() \ No newline at end of file diff --git a/src/pylib/Lib/os_impl/posix_like/utime.nim b/src/pylib/Lib/os_impl/posix_like/utime.nim deleted file mode 100644 index 16723257d..000000000 --- a/src/pylib/Lib/os_impl/posix_like/utime.nim +++ /dev/null @@ -1,126 +0,0 @@ -## os.utime - -import std/os -import std/times -import std/macros -import ../common -include ./ncommon - -type - TimePair*[F: SomeFloat] = tuple - atime, mtime: F - -type NsUnit* = BiggestInt - -type TimeNsPair* = tuple - atime_ns, mtime_ns: NsUnit - -const `ns/s` = 1_000_000_000 - -when InJs: - type Time = cdouble - proc utimesSync(path: cstring, atime, ctime: Time){.importDenoOrNodeMod(fs, utimesSync).} - proc lutimesSync(path: cstring, atime, ctime: Time){.importDenoOrNodeMod(fs, lutimesSync).} - - type TimeTuple = tuple - atime, ctime: Time - template stoTime[N: int|float](t: (N, N)): TimeTuple = (Time(t[0]), Time(t[1])) - #[ XXX: - We use Time, a.k.a cdouble in intermediate operations because: - 1. even using BiggestInt and jsBitint64 is on, - Nim still treats it as int64 instead of a really bigint, - so intermediate overflow may raises by Nim's overflowcheck; - 2. [l]utimesSync expects cdouble (Js's Number) - ]# - template nstoTime(t: TimeNsPair): TimeTuple = (Time(`ns/s`) * t[0].Time, Time(`ns/s`) * t[1].Time) - template utimeImpl(mapper; path: PathLike, times; follow_symlinks=true) = - let - jsS = cstring $path - tup = mapper times - catchJsErrAndRaise: - if follow_symlinks: - utimesSync jsS, tup.atime, tup.ctime - else: - lutimesSync jsS, tup.atime, tup.ctime - -else: - func divmod(x, y: int): (int, int) = - ## for Positive only - (x div y, x mod y) - - when defined(windows): - template stoTime(s: int): times.Time = fromUnix(s) - template stoTime(s_ns: float): times.Time = fromUnixFloat s_ns - - proc nstoTime(tot_ns: int): times.Time = - let (s, ns) = divmod(tot_ns, `ns/s`) - initTime(s, ns) - const FILE_WRITE_ATTRIBUTES = 0x100 - proc openHandle(path: string, follow_symlinks=true): Handle = - var flags = FILE_FLAG_BACKUP_SEMANTICS or FILE_ATTRIBUTE_NORMAL - if not follow_symlinks: - flags = flags or FILE_FLAG_OPEN_REPARSE_POINT - - result = createFileW( - newWideCString(path), FILE_WRITE_ATTRIBUTES, 0, - nil, OPEN_EXISTING, flags, 0 - ) - proc utimeAux(file: string, times: tuple[atime, mtime: times.Time], follow_symlinks=true): bool = - let h = openHandle(file, follow_symlinks=follow_symlinks) - if h == INVALID_HANDLE_VALUE: - return true - var - lastAccess = times.atime.toWinTime.toFILETIME - lastWrite = times.mtime.toWinTime.toFILETIME - let res = setFileTime(h, nil, lastAccess.addr, lastWrite.addr) - discard h.closeHandle - if res == 0'i32: - return true - else: - template initTimeval(s, us): untyped = - Timeval(tv_sec: posix.Time(s), tv_usec: Suseconds us) - func stoTime(s: int): Timeval = initTimeval(s, 0) - func stoTime(s_ns: float): Timeval = - let - s_int = BiggestInt s_ns - us = (s_ns - s_int.float) * 1e6 - initTimeval(s_int, us) - func nstoTime(ns: int): Timeval = - let tot_us = ns div 1000 - let (s_int, us_int) = divmod(tot_us, 1_000_000) - initTimeval(s_int, us_int) - - proc utimeAux(file: string, timevals: tuple[aTimeval, mTimeval: posix.Timeval], follow_symlinks=true): bool = - # [last access, last modification] - var arr = [timevals[0], timevals[1]] - if utimes(file, arr.addr) != 0: - return true - - macro mapTup(tup: tuple, mapper): tuple = - ## t -> (t[0].mapper, ...) - expectKind tup, {nnkIdent, nnkSym} # no literal allowed! - result = newNimNode nnkTupleConstr - for i in 0..".} - let ENOENT,ENXIO,ENODEV,EACCES: cint - {.pop.} - - -proc urandom*(size: int): seq[uint8] = - if size < 0: - raise newException(ValueError, "negative argument not allowed") - let size = cast[Natural](size) - result.setLenUninit size - if sysrand.urandom(result): - return - - ## raises as CPython does - when mayUseDevUrandom: - if isErr(ENOENT) or isErr(ENXIO) or isErr(ENODEV) or isErr(EACCES): - raise_NotImplementedError("/dev/urandom (or equivalent) not found") - ## Win: win32_urandom -> PyErr_SetFromWindowsErr(0); - ## else: PyErr_SetFromErrno(PyExc_OSError); - raise newOSError osLastError() - -when have_getrandom_syscall: - import ../errno_impl/errnoConsts - when not defined(ImportErrnoUtils): - import ../errno_impl/errnoUtils - import ../signal_impl/c_api - import ../../pyerrors/oserr - - proc getrandom*(size: int, flags = 0): seq[uint8] = - - if size < 0: - #$setErrno EINVAL - raiseErrno EINVAL - - var n: int - result = newSeqUninit[uint8](size) - - while true: - n = syscall(SYS_getrandom, - result[0].addr, - result.len, - flags - ) - if n < 0 and isErr EINTR: - if PyErr_CheckSignals() < 0: - raiseErrno() - - # getrandom() was interrupted by a signal: retry - continue - - break - - if n < 0: - raiseErrno() - - if n != size: - result.setLen n diff --git a/src/pylib/Lib/os_impl/subp.nim b/src/pylib/Lib/os_impl/subp.nim deleted file mode 100644 index 7a84878e8..000000000 --- a/src/pylib/Lib/os_impl/subp.nim +++ /dev/null @@ -1,27 +0,0 @@ - -import ./common -when not defined(js): - proc c_system(cmd: cstring): cint{.importc: "system", header: "".} - -proc system*(cmd: string): int{.discardable.} = - ## os.system - runnableExamples: - const - # can use `os.devnull` - mydevnull = when defined(windows): "nul" else: "/dev/null" - e2null = "echo 1 >" & mydevnull - assert system(e2null) == 0 - - sys.audit("os.system", cmd) - when defined(js): - let jsStr = cmd.cstring - var res: c_int - asm """ - const {exec} = require('node:child_process'); - let childProcess = exec(`jsStr`); - `res` = childProcess.exitCode; - """ - result = res.int - else: - c_system cmd.cstring - diff --git a/src/pylib/Lib/os_impl/term.nim b/src/pylib/Lib/os_impl/term.nim deleted file mode 100644 index 2ce0965f1..000000000 --- a/src/pylib/Lib/os_impl/term.nim +++ /dev/null @@ -1,19 +0,0 @@ - -import std/terminal -when defined(nimPreviewSlimSystem): - import std/syncio - -template fileno(f: File): int = int getFileHandle f -template STDOUT_FILENO: int = fileno(stdout) -type terminal_size* = tuple[columns, lines: int] ## a namedtuple - ## instead of a class -proc get_terminal_size*(fd=STDOUT_FILENO): terminal_size = - ## minics Python's os.get_terminal_size. - ## - ## but if you are using Nim's stdlib, - ## `terminalSize` - ## in std/terminal does futher than even - ## Python's `shutil.get_terminal_size` - # We do not refer to env-vars, as Python's does not. - result.columns = terminalWidthIoctl([fd]) - result.lines = terminalHeightIoctl([fd]) diff --git a/src/pylib/Lib/os_impl/touch.nim b/src/pylib/Lib/os_impl/touch.nim deleted file mode 100644 index 96543ce5e..000000000 --- a/src/pylib/Lib/os_impl/touch.nim +++ /dev/null @@ -1,25 +0,0 @@ - -import ./posix_like -import ./consts - -proc touch*(s: string; mode=0o666, exist_ok=true) = - ## EXT. - ## used by pathlib - ## Create this file with the given access mode, if it doesn't exist. - - if exist_ok: - # First try to bump modification time - # Implementation note: GNU touch uses the UTIME_NOW option of - # the utimensat() / futimens() functions. - try: - utime(s) - return - except OSError: - # Avoid exception chaining - discard - var flags = O_CREAT | O_WRONLY - if not exist_ok: - flags |= O_EXCL - let fd = open(s, flags, mode) - close(fd) - diff --git a/src/pylib/Lib/os_impl/util/getFileInfo.nim b/src/pylib/Lib/os_impl/util/getFileInfo.nim deleted file mode 100644 index 57f365820..000000000 --- a/src/pylib/Lib/os_impl/util/getFileInfo.nim +++ /dev/null @@ -1,59 +0,0 @@ -## pycore_fileutils_windows.h - -import ./mywinlean -import std/dynlib - -type - FILE_STAT_BASIC_INFORMATION* = object - FileId*: LARGE_INTEGER - CreationTime*, LastAccessTime*, LastWriteTime*, ChangeTime*: LARGE_INTEGER - AllocationSize*, EndOfFile*: LARGE_INTEGER - FileAttributes*: ULONG - ReparseTag*: ULONG - NumberOfLinks*: ULONG - DeviceType*, DeviceCharacteristics*: ULONG - Reserved: ULONG - VolumeSerialNumber*: LARGE_INTEGER - FileId128*: FILE_ID_128 - - FileInfoByNameClass* = enum - # Define the enum values corresponding to FILE_INFO_BY_NAME_CLASS - # Add the appropriate values here based on your use case. - FileStatByNameInfo = cint(0) - FileStatLxByNameInfo - FileCaseSensitiveByNameInfo - FileStatBasicByNameInfo - MaximumFileInfoByNameClass - - PGetFileInformationByName = proc( - FileName: WideCString, - FileInformationClass: FileInfoByNameClass, - FileInfoBuffer: pointer, - FileInfoBufferSize: ULONG - ): bool {.stdcall.} - -var - GetFileInformationByName: PGetFileInformationByName = nil - GetFileInformationByNameInit: int = -1 - -proc Py_GetFileInformationByName*( - FileName: WideCString, - FileInformationClass: FileInfoByNameClass, - FileInfoBuffer: pointer, - FileInfoBufferSize: ULONG -): bool = - if GetFileInformationByNameInit < 0: - let hMod = loadLib("api-ms-win-core-file-l2-1-4") - GetFileInformationByNameInit = 0 - if hMod != nil: - GetFileInformationByName = cast[PGetFileInformationByName](symAddr(hMod, "GetFileInformationByName")) - if GetFileInformationByName != nil: - GetFileInformationByNameInit = 1 - else: - unloadLib(hMod) - - if GetFileInformationByNameInit <= 0: - SetLastError(ERROR_NOT_SUPPORTED) - return false - - return GetFileInformationByName(FileName, FileInformationClass, FileInfoBuffer, FileInfoBufferSize) diff --git a/src/pylib/Lib/os_impl/util/get_osfhandle.nim b/src/pylib/Lib/os_impl/util/get_osfhandle.nim deleted file mode 100644 index b415537de..000000000 --- a/src/pylib/Lib/os_impl/util/get_osfhandle.nim +++ /dev/null @@ -1,7 +0,0 @@ - -when defined(windows): - import std/winlean - import ../private/iph_utils - proc Py_get_osfhandle_noraise*(fd: int): Handle = - with_Py_SUPPRESS_IPH: - result = get_osfhandle FileHandle fd diff --git a/src/pylib/Lib/os_impl/util/handle_signal.nim b/src/pylib/Lib/os_impl/util/handle_signal.nim deleted file mode 100644 index d1dfa2c05..000000000 --- a/src/pylib/Lib/os_impl/util/handle_signal.nim +++ /dev/null @@ -1,19 +0,0 @@ - -import ../../n_errno -import ../../signal_impl/c_api -from ../../errno_impl/errnoUtils import getErrno -from ../common import raiseErrno - -template initVal_with_handle_signal*[R](res: var R; resExpr){.dirty.} = - bind isErr, EINTR, PyErr_CheckSignals, raiseErrno, getErrno - var async_err: int - - while true: - res = resExpr - if res >= 0 or not isErr(EINTR): - break - async_err = PyErr_CheckSignals() - if async_err == 0: - break - if res < 0: - raiseErrno getErrno() diff --git a/src/pylib/Lib/os_impl/util/mywinlean.nim b/src/pylib/Lib/os_impl/util/mywinlean.nim deleted file mode 100644 index 99acb332c..000000000 --- a/src/pylib/Lib/os_impl/util/mywinlean.nim +++ /dev/null @@ -1,213 +0,0 @@ - -import std/winlean except DWORD, ULONG -export winlean except DWORD, ULONG, - OPEN_EXISTING, FILE_SHARE_READ, FILE_SHARE_WRITE, - FILE_FLAG_OPEN_REPARSE_POINT, FILE_ATTRIBUTE_DIRECTORY, - FILE_ATTRIBUTE_READONLY, FILE_ATTRIBUTE_REPARSE_POINT, - BY_HANDLE_FILE_INFORMATION, INVALID_FILE_ATTRIBUTES -import ./get_osfhandle -export get_osfhandle -type - BOOL* = enum - FALSE = cint 0 - TRUE = cint 1 - -converter toBool*(b: BOOL): bool = b != FALSE -template `!`*(b: BOOL): bool = b == FALSE - -type - LPCWSTR* = WideCString - ULONG* = uint32 - DWORD* = uint32 - WORD* = uint16 - LARGE_INTEGER*{.pure, importc, header: "".} = object - ##[ We simplify the definition of LARGE_INTEGER, which is defined as: - -- DWORD is uint32 -- LONG is int32 -- LONGLONG is int64 - -```c -typedef union _LARGE_INTEGER { - struct { - DWORD LowPart; - LONG HighPart; - } DUMMYSTRUCTNAME; - struct { - DWORD LowPart; - LONG HighPart; - } u; - LONGLONG QuadPart; -} LARGE_INTEGER; -``` -]## - QuadPart*: int64 - FILE_BASIC_INFO*{.pure, importc, header: "".} = object - CreationTime*, LastAccessTime*, LastWriteTime*, ChangeTime*: LARGE_INTEGER - FileAttributes*: DWORD - - FILE_ID_128*{.pure, importc, header: "".} = object - Identifier*: array[16, BYTE] - FILE_ID_INFO*{.pure, importc, header: "".} = object - VolumeSerialNumber*: uint64 - FileId*: FILE_ID_128 - - FILE_INFO_BY_HANDLE_CLASS*{.pure.} = enum - FileBasicInfo = cint(0) # to avoid conflict with FILE_BASIC_INFO type - FileAttributeTagInfo = cint(9) - - FileIdInfo = cint(19) - # ... - - WCHAR* = uint16 - - WIN32_FIND_DATAW*{.importc, header: "" # MinGW error if using - .} = object - dwFileAttributes*: DWORD - ftCreationTime*: FILETIME - ftLastAccessTime*: FILETIME - ftLastWriteTime*: FILETIME - nFileSizeHigh*: DWORD - nFileSizeLow*: DWORD - dwReserved0*: DWORD - dwReserved1*: DWORD - cFileName*: array[MAX_PATH, WCHAR] - cAlternateFileName*: array[14, WCHAR] - dwFileType*: DWORD ## Obsolete. Do not use. - dwCreatorType*: DWORD ## Obsolete. Do not use. - wFinderFlags*: WORD ## Obsolete. Do not use. - - BY_HANDLE_FILE_INFORMATION*{.importc, header: "".} = object - dwFileAttributes*: DWORD - ftCreationTime*: FILETIME - ftLastAccessTime*: FILETIME - ftLastWriteTime*: FILETIME - dwVolumeSerialNumber*: DWORD - nFileSizeHigh*: DWORD - nFileSizeLow*: DWORD - nNumberOfLinks*: DWORD - nFileIndexHigh*: DWORD - nFileIndexLow*: DWORD - - FILE_ATTRIBUTE_TAG_INFO*{.importc, header: "".} = object - FileAttributes*, ReparseTag*: DWORD -const - ERROR_INVALID_HANDLE* = 6 - ERROR_NOT_ENOUGH_MEMORY* = 8 - - ERROR_NOT_READY* = 21 - ERROR_BAD_NET_NAME* = 67 - - - ERROR_SHARING_VIOLATION* = 32 - ERROR_NOT_SUPPORTED* = 50 - ERROR_INVALID_PARAMETER* = 87 - - ERROR_CANT_ACCESS_FILE* = 110 - - - - FILE_TYPE_CHAR* = 2 - FILE_TYPE_DISK* = 1 - FILE_TYPE_PIPE* = 3 - - FILE_TYPE_UNKNOWN* = 0 - - OPEN_EXISTING* = 3 - - FILE_SHARE_READ* = 1 - FILE_SHARE_WRITE* = 2 - - FILE_FLAG_OPEN_REPARSE_POINT* = 0x00200000 - - FILE_DEVICE_CD_ROM* = 2 - FILE_DEVICE_CD_ROM_FILE_SYSTEM* = 3 - FILE_DEVICE_CONTROLLER* = 4 - FILE_DEVICE_DATALINK* = 5 - FILE_DEVICE_DFS* = 6 - FILE_DEVICE_DISK* = 7 - FILE_DEVICE_DISK_FILE_SYSTEM* = 8 - FILE_DEVICE_NETWORK_FILE_SYSTEM* = 0x14 - FILE_DEVICE_VIRTUAL_DISK* = 0x24 - - FILE_DEVICE_NAMED_PIPE* = 0x11 - - FILE_DEVICE_CONSOLE* = 0x00000050 - FILE_DEVICE_NULL* = 0x00000015 - FILE_DEVICE_KEYBOARD* = 0x0000000b - FILE_DEVICE_MODEM* = 0x0000002b - FILE_DEVICE_MOUSE* = 0x0000000f - FILE_DEVICE_PARALLEL_PORT* = 0x00000016 - FILE_DEVICE_PRINTER* = 0x00000018 - FILE_DEVICE_SCREEN* = 0x0000001c - FILE_DEVICE_SERIAL_PORT* = 0x0000001b - FILE_DEVICE_SOUND* = 0x0000001d - - FILE_ATTRIBUTE_READONLY* = cast[DWORD](1) - FILE_ATTRIBUTE_DIRECTORY* = cast[DWORD](0x10) - - GENERIC_READ* = cast[DWORD](0x80000000) - - IO_REPARSE_TAG_SYMLINK* = cast[DWORD](0xA000000C) - - FILE_READ_ATTRIBUTES* = 128 - FILE_WRITE_ATTRIBUTES* = 0x100 - - FILE_ATTRIBUTE_REPARSE_POINT* = cast[DWORD](0x400) - IO_REPARSE_TAG_MOUNT_POINT* = cast[DWORD](0xA0000003) - -let - INVALID_FILE_ATTRIBUTES*{.importc, header: "".}: DWORD - -proc GetFileAttributesW*(lpFileName: LPCWSTR): DWORD {. - stdcall, header: "", importc.} -proc SetFileAttributesW*(lsFileName: LPCWSTR, attr: DWORD): WINBOOL {. - stdcall, header: "", importc.} - -proc GetFileType*(h: Handle): DWORD{.importc, header: "".} - -proc GetFileInformationByHandle*(hfile: Handle, - lpFileInformation: var BY_HANDLE_FILE_INFORMATION): BOOL {. - stdcall, header: "", importc.} -proc GetFileInformationByHandleEx*( - hfile: Handle, infoClass: FILE_INFO_BY_HANDLE_CLASS, lpBuffer: pointer, dwBufferSize: DWORD -): BOOL {.importc, header: "".} - -proc GetFileInformationByHandleEx*[T]( - hfile: Handle, infoClass: FILE_INFO_BY_HANDLE_CLASS, lpBuffer: var T -): BOOL = GetFileInformationByHandleEx( - hfile, infoClass, addr lpBuffer, DWORD sizeof(T) -) - -template GetFileBasicInformationByHandleEx*( - hfile: Handle, lpBuffer: FILE_BASIC_INFO -): BOOL = - bind GetFileInformationByHandleEx, FILE_INFO_BY_HANDLE_CLASS, DWORD - GetFileInformationByHandleEx( - hfile, FILE_INFO_BY_HANDLE_CLASS.FileBasicInfo, addr lpBuffer, DWORD sizeof(FILE_BASIC_INFO) - ) - - -proc FindFirstFileW*(lpFileName: WideCString, - lpFindFileData: var WIN32_FIND_DATAW): Handle {. - stdcall, dynlib: "kernel32", importc, sideEffect.} - -proc GetLastError*(): DWORD {. - stdcall, header: "", importc, sideEffect.} - -proc SetLastError*(err: DWORD) {. - stdcall, header: "", importc, sideEffect.} - - -proc CreateFileW*( - lpFileName: WideCString, dwDesiredAccess: DWORD, dwShareMode: DWORD, - lpSecurityAttributes: pointer, dwCreationDisposition: DWORD, - dwFlagsAndAttributes: DWORD, hTemplateFile: Handle -): Handle {.stdcall, header: "", importc.} - - -proc IsReparseTagNameSurrogate*(tag: DWORD): BOOL {. - importc, header: "".} - -proc FindClose*(hFindFile: Handle): BOOL{.discardable, - importc, header: "".} diff --git a/src/pylib/Lib/os_impl/utils.nim b/src/pylib/Lib/os_impl/utils.nim deleted file mode 100644 index 902761540..000000000 --- a/src/pylib/Lib/os_impl/utils.nim +++ /dev/null @@ -1,49 +0,0 @@ - -# reference source: Modules/posixmodule.c - -import std/os - -import ./common -import ./posix_like/mkrmdir - -when InJs: - import ./osJsPatch - proc cwd(): cstring{.importDenoOrProcess(cwd).} - proc getcwd*(): PyStr = str cwd() - proc getcwdb*(): PyBytes = bytes cwd() - proc chdir(d: cstring){.importDenoOrProcess(chdir).} - proc chdirImpl(s: PathLike) = chdir cstring $s - -else: - proc getcwd*(): PyStr = str getCurrentDir() - proc getcwdb*(): PyBytes = bytes getCurrentDir() - proc chdirImpl(s: PathLike) = setCurrentDir $s - -proc chdir*(s: PathLike) = - sys.audit("os.chdir", s) - chdirImpl(s) - -proc makedirs*[T](d: PathLike[T], mode=0o777, exist_ok=false) = - let dir = $d - if dir == "": - return - var omitNext = isAbsolute(dir) - for p in parentDirs(dir, fromRoot=true): - if omitNext: - omitNext = false - else: - p.tryOsOp not exist_ok or not dirExists(p): - mkdir(p, mode) - -proc removedirs*(d: PathLike) = - let dir = $d - if dir == "": - return - # raises OSError if the leaf directory could not be successfully removed. - rmdir(d) - var omitNext = isAbsolute(dir) - try: - for p in parentDirs(dir, inclusive=false): - rmdir(p) - except OSError: - discard diff --git a/src/pylib/Lib/os_impl/waits.nim b/src/pylib/Lib/os_impl/waits.nim deleted file mode 100644 index 77cf303e3..000000000 --- a/src/pylib/Lib/os_impl/waits.nim +++ /dev/null @@ -1,152 +0,0 @@ - -import ../resource_impl/types -from ./common import raiseErrno -import ./util/handle_signal -import ./private/platform_utils -import ./private/defined_macros -when MS_WINDOWS: - import ../../private/iph_utils # with_Py_SUPPRESS_IPH -else: - from std/posix import Pid - -when MS_WINDOWS: - type Res = int - type WAIT_TYPE = cint - proc cwait(termstat: var cint, pid: cint, options: cint): Res{.importc: "_cwait", header: "".} - proc c_waitpid(pid: cint, status: var WAIT_TYPE, options: cint): Res = - with_Py_SUPPRESS_IPH: - result = cwait(status, pid, options) - template handle_status(res: Res): int = status shl 8 - template decl_STATUS_INIT(status; val: cint = 0) = - var status: WAIT_TYPE = val - -elif defined(unix): - type Res = cint - type WAIT_TYPE{.importc.} = cint # also may be union - proc c_waitpid(pid: cint, status: var WAIT_TYPE, options: cint): Res{.importc: "waitpid", header: "".} - template handle_status(res: Res): int = status.int - - template decl_STATUS_INIT(status; val: cint = 0) = - var status{.noInit.}: WAIT_TYPE - {.emit: ["WAIT_STATUS_INIT(", status, ") = ", val, ");"].} - - proc WAIT_STATUS_INT(status: WAIT_TYPE): cint{.inline.} = - {.emit: [result, "= WAIT_STATUS_INT(", status, ")"].} -else: - type Res = cint - type WAIT_TYPE = cint - template decl_STATUS_INIT(status; val: cint = 0) = - var status: WAIT_TYPE = val - -when not MS_WINDOWS and not defined(js) and not defined(nimscript): - template genW(name){.dirty.} = - proc name(status: WAIT_TYPE): cint{.importc, header: "".} - proc name*(status: int): bool = - decl_STATUS_INIT(wait_status, status.cint) - name(wait_status) != 0 - - genW WCOREDUMP - genW WIFCONTINUED - genW WIFSTOPPED - genW WIFSIGNALED - genW WIFEXITED - genW WEXITSTATUS - genW WTERMSIG - genW WSTOPSIG - - template genWConst(name){.dirty.} = - let `c name`{.importc: astToStr(name), header: "".}: cint - let name* = int `c name` - - genWConst WCONTINUED - genWConst WEXITED - genWConst WSTOPPED - genWConst WUNTRACED - genWConst WNOHANG - genWConst WNOWAIT - - -template waitX_impl[R](res, status: untyped; resExpr){.dirty.} = - decl_STATUS_INIT(status) - initVal_with_handle_signal(res, resExpr) - -when declared(c_waitpid): - proc waitpid*(pid: int, options: int): tuple[pid: int, status: int]{.platformNoJs.} = - let - options = options.cint - pid = pid.cint - var res: Res - waitX_impl[Res](res, status, c_waitpid(pid, status, options)) - (res.int, handle_status(status)) - -when not MS_WINDOWS: - proc wait(status: var WAIT_TYPE): Res{.importc, header: "".} - proc wait*(): tuple[pid: int, status: int]{.platformNoJs.} = - var res: Pid - waitX_impl[Pid](res, status, wait(status)) - (res.int, WAIT_STATUS_INT status) - - proc wait_helper(pid: Pid, status: cint, rusage: var posix.RUsage): - tuple[pid: int, status: int, rusage: struct_rusage]{.platformNoJs.} = - if pid == -1: - raiseErrno() - - #[If wait succeeded but no child was ready to report status, ru will not - have been populated.]# - if pid == 0: - zeroMem(addr rusage, sizeof(rusage)) - let res = rusage.toPyObject() - (pid.int, status.int, res) - - proc wait3(status: var WAIT_TYPE, options: cint, rusage: var posix.RUsage): Res{.importc, header: "".} - proc wait3*(options: int): tuple[pid: int, status: int, rusage: struct_rusage]{.platformNoJs.} = - var - res: Pid - ru: posix.RUsage - waitX_impl[Pid](res, status, wait3(status, options.cint, ru)) - wait_helper(res, WAIT_STATUS_INT(status), ru) - - proc wait4(pid: Pid, status: var WAIT_TYPE, options: cint, rusage: var posix.RUsage): Res{.importc, header: "".} - proc wait4*(pid: int, options: int): tuple[pid: int, status: int, rusage: struct_rusage]{.platformNoJs.} = - var - res: Pid - ru: posix.RUsage - let pid = pid.Pid - waitX_impl[Pid](res, status, wait4(pid, status, options.cint, ru)) - wait_helper(res, WAIT_STATUS_INT(status), ru) - -proc waitstatus_to_exitcode*(status: int): int{.platformNoJs.} = - when not MS_WINDOWS: - decl_STATUS_INIT(wait_status, status.cint) - var exitcode: cint - if bool WIFEXITED(wait_status): - exitcode = WEXITSTATUS(wait_status) - # Sanity check to provide warranty on the function behavior. - # It should not occur in practice - if exitcode < 0: - raise newException(ValueError, "invalid WEXITSTATUS: " & $exitcode) - elif bool WIFSIGNALED(wait_status): - let signum = WTERMSIG(wait_status) - # Sanity check to provide warranty on the function behavior. - # It should not occur in practice - if signum <= 0: - raise newException(ValueError, "invalid WTERMSIG: " & $signum) - exitcode = -signum - elif bool WIFSTOPPED(wait_status): - # Status only received if the process is being traced - # or if waitpid() was called with WUNTRACED option. - let signum = WSTOPSIG(wait_status) - raise newException(ValueError, "process stopped by delivery of signal " & $signum) - else: - raise newException(ValueError, "invalid wait status: " & $status) - result = int exitcode - else: - # Windows implementation: see os.waitpid() implementation - # which uses _cwait(). - let exitcode = (status.uint64 shr 8) - # ExitProcess() accepts an UINT type: - # reject exit code which doesn't fit in an UINT - if exitcode > cuint.high.uint64: - raise newException(ValueError, "invalid exit code: " & $exitcode) - result = exitcode.int - diff --git a/src/pylib/Lib/os_impl/walkImpl.nim b/src/pylib/Lib/os_impl/walkImpl.nim deleted file mode 100644 index 68a5da8b2..000000000 --- a/src/pylib/Lib/os_impl/walkImpl.nim +++ /dev/null @@ -1,182 +0,0 @@ - - -import ./common -import ./listcommon -import ./posix_like/scandirImpl -import ./path - -type - OnErrorCb* = proc (e: ref PyOSError) - WalkTup[T] = tuple[dirpath: T, dirnames, filenames: PyList[T]] - ## used for type conversion - - # We use distinct to hook `repr` - WalkRes*[T] = distinct WalkTup[T] -converter toTup*[T](self: WalkRes[T]): WalkTup[T] = - ## converts to `tuple[T, list[T], list[T]]` - WalkTup[T](self) -template `[]`*[T](self: WalkRes[T], i: static int): untyped = - bind WalkTup - const idx = - if i < 0: 3 - i - else: i - (WalkTup[T](self))[idx] -const sep = ", " -template repr*[T](self: WalkRes[T]): string = - ## returns `(xx, [xx], [xx])` as Python's - bind sep - var result = "(" - result.add self[0].repr & sep - result.add self[1].repr & sep - result.add self[2].repr & ')' - result -template `$`*[T](self: WalkRes[T]): string = self.repr - -iterator reversed[T](ls: PyList[T]): T = - for i in countdown(len(ls)-1, 0): - yield ls[i] - -const - shallIgnore*: OnErrorCb = nil - # we do not use PyBool on pylib's os - True = true - False = false - -type - UnionItem[A, B] = object - case isA: bool - of true: a: A - of false: b: B - UnionList[A, B] = PyList[UnionItem[A, B]] -proc newUnionList[A, B](): UnionList[A, B] = list[UnionItem[A, B]]() - -func isinstance[A,B](i: UnionItem[A, B], t: typedesc[A|B]): bool = - when t is A: i.isA - else: not i.isA - -template append[A, B](ls: UnionList[A, B], x: A) = - ls.append UnionItem[A, B](isA: true, a: x) -template append[A, B](ls: UnionList[A, B], x: B) = - ls.append UnionItem[A, B](isA: false, b: x) - -type ScanDir[T] = iterator (path: T): DirEntry[T]{.closure.} - -type WalkSymlinksAsFiles = distinct proc(){.noconv.} -converter toBool(self: WalkSymlinksAsFiles): bool{.used.} = true -let walk_symlinks_as_files* = WalkSymlinksAsFiles proc(){.noconv.} = discard ## _walk_symlinks_as_files - -# translated from CPython-3.13-alpha/Lib/os.py L284 -iterator walk*[T](top: PathLike[T], topdown=True, - onerror=shallIgnore, followlinks: bool|WalkSymlinksAsFiles=False - ): WalkRes[T] = - sys.audit("os.walk", top, topdown, onerror, followlinks) - var stack = newUnionList[T, WalkRes[T]]() - stack.append(fspath(top)) - - while len(stack) != 0: - let utop = stack.pop() - if isinstance(utop, WalkRes[T]): - yield utop.b - continue - let top = utop.a - var - dirs = list[T]() - nondirs = list[T]() - walk_dirs = list[T]() - - # We may not have read permission for top, in which case we can't - # get a list of the files the directory contains. - # We suppress the exception here, rather than blow up for a - # minor reason when (say) a thousand readable directories are still - # left to visit. - var scandir_it: ScanDir[T] = scandirIter - - var cont = False - #with scandir_it: - when True: - while True: - var entry: DirEntry[T] - try: - entry = scandir_it(top) - if scandir_it.finished(): - break - except OSError as error: - if onerror != shallIgnore: - onerror(newPyOSError(error.errorCode.cint, error.msg)) - cont = True - break - let isdir = - try: - when followlinks is WalkSymlinksAsFiles: - entry.is_dir(follow_symlinks=True) and not entry.is_junction() - else: - entry.is_dir() - except OSError: - # If is_dir() raises an OSError, consider the entry not to - # be a directory, same behaviour as os.path.isdir(). - False - - if is_dir: - dirs.append(entry.name) - else: - nondirs.append(entry.name) - - if not topdown and is_dir: - # Bottom-up: traverse into sub-directory, but exclude - # symlinks to directories if followlinks is False - let walk_into = - if followlinks: - True - else: - let issymlink = - try: - entry.is_symlink() - except OSError: - # If is_symlink() raises an OSError, consider the - # entry not to be a symbolic link, same behaviour - # as os.path.islink(). - False - not is_symlink - - if walk_into: - walk_dirs.append(entry.path) - if cont: - continue - - if topdown: - # Yield before sub-directory traversal if going top down - yield WalkRes[T]((top, dirs, nondirs)) - # Traverse into sub-directories - for dirname in reversed(dirs): - let new_path = join(top, dirname) - # bpo-23605: os.path.islink() is used instead of caching - # entry.is_symlink() result during the loop on os.scandir() because - # the caller can replace the directory entry during the "yield" - # above. - if followlinks or not islink(new_path): - stack.append(new_path) - else: - # Yield after sub-directory traversal if going bottom up - stack.append(WalkRes[T]((top, dirs, nondirs))) - # Traverse into sub-directories - for new_path in reversed(walk_dirs): - stack.append(new_path) - -iterator walk*[T](top: PathLike[T], topdown=True, - onerror=None, followlinks=False): WalkRes[T] = - for i in walk(top, topdown, shallIgnore, followlinks): yield i - - -type WalkIterator[T] = ref object - iter: iterator(): WalkRes[T]{.closure.} -proc walk*[T](top: PathLike[T], topdown=True, - onerror=shallIgnore, followlinks=False): WalkIterator[T] = - new result - result.iter = iterator(): WalkRes[T] = - for i in walk(top, topdown, onerror, followlinks): yield i -proc walk*[T](top: PathLike[T], topdown=True, - onerror=None, followlinks=False): WalkIterator[T] = - new result - result.iter = iterator(): WalkRes[T] = - for i in walk(top, topdown, onerror, followlinks): yield i - diff --git a/src/pylib/Lib/pathlib.nim b/src/pylib/Lib/pathlib.nim deleted file mode 100644 index ea45e6e7f..000000000 --- a/src/pylib/Lib/pathlib.nim +++ /dev/null @@ -1,140 +0,0 @@ - -import std/macros - -import ./[ - os, io -] - -import ../io_abc -import ../pystring/strimpl -#[ TODO: -import ../pybytes/bytesimpl - -func bytes*(self): PyBytes = os.fsencode($self) -]# - -import ../builtins/list -import ../version - -import ./n_pathlib - -macro wrapStr(aString: untyped, strings: untyped; excludes: untyped) = - let nlib = ident "n_pathlib" - result = newStmtList() - var exp = nnkExportExceptStmt.newTree nlib - let argName = ident"self" - for a in aString: - exp.add a - result.add quote do: - func `a`*(`argName`: types.Path): PyStr = str `nlib`.`a` `argName` - for a in strings: - exp.add a - result.add quote do: - func `a`*(`argName`: types.Path): PyList[PyStr] = - result = newPyList[PyStr]() - for i in `nlib`.`a` `argName`: - result.append str i - for i in excludes: exp.add i - result.add exp - -wrapStr [ - name, suffix, stem - ], [ - parts, suffixes - ], [ - read_nstring, write_nstring - ] - -using self: Path -func fspath*(self): PyStr = str $self - -proc Path*[P: PathLike](pathsegments: varargs[P]): types.Path = - for i in pathsegments: - result = result / i - -func `/`*(self; p: PathLike): Path = n_pathlib.`/` self, $p -func `/`*(p: PathLike; self): Path = n_pathlib.`/` $p, self -func `/=`*(head: var Path, tail: PathLike): Path = n_pathlib.`/=` head, tail - -func joinpath*[P: PathLike](self; pathsegments: varargs[P]): Path = - result = self - for i in pathsegments: - result = result / i - -template open*(self: Path, mode: StringLike = "r", - buffering = -1, - encoding=DefEncoding, errors=DefErrors, newline=DefNewLine): untyped = - bind open - open($self, mode, buffering, encoding, errors, newline) - - -proc read_text*(self; encoding=DefEncoding, errors=DefErrors): PyStr = - var f = open($self, encoding=encoding, errors=errors) - defer: f.close() - result = f.read() - -proc write_text*(self; data: PyStr, encoding=DefEncoding, errors=DefErrors - ): int{.discardable.} = - var f = open($self, encoding=encoding, errors=errors) - defer: f.close() - result = f.write(data) - -proc read_bytes*(self): PyBytes = bytes readFile $self -proc write_bytes*(self; b: PyBytes) = writeFile $self, $b - -proc readlink*(self): Path = Path os.readlink $self - -proc symlink_to*(self; target: string|Path; target_is_directory=false) = - os.symlink($target, $self, target_is_directory) - -proc hardlink_to*(self; target: string|Path){.pysince(3,10).} = - os.link($target, $self) - - -static:assert pathlib.Path is_not string, "this avoids recusive call(dead loop)" -# following implementations rely on this assertion - - -proc unlink*(self; missing_ok: bool) = - if not missing_ok: - self.unlink - return - try: - unlink $self - except FileNotFoundError: - discard - -template reXX(rename){.dirty.} = - proc rename*(self; target: Path): Path{.discardable.} = - rename($self, $target) - target - - proc rename*(self; target: string): Path{.discardable.} = - rename(self, Path(target)) - -reXX rename -reXX replace - -proc mkdirParents(self; exist_ok=false) = - ## for parents==False - if not exist_ok and existsOrCreateDir $self: - raiseExcWithPath $self - -proc mkdir*(self; mode = 0o777; parents=false, exist_ok=false) = - if parents: - self.mkdirParents exist_ok - else: - if not exist_ok: - os.mkdir($self, mode=mode) - return - try: - os.mkdir($self, mode=mode) - except FileExistsError: - discard - -proc rmdir*(self) = os.rmdir $self - - - -# TODO: stat(..., follow_symlinks), see os -# and exists diff --git a/src/pylib/Lib/pathlib_impl/init.nim b/src/pylib/Lib/pathlib_impl/init.nim deleted file mode 100644 index f28ff4de0..000000000 --- a/src/pylib/Lib/pathlib_impl/init.nim +++ /dev/null @@ -1,7 +0,0 @@ - -import ./types - -proc Path*[P](pathsegments: varargs[P]): types.Path = - for i in pathsegments: - result = result / i - diff --git a/src/pylib/Lib/pathlib_impl/meth.nim b/src/pylib/Lib/pathlib_impl/meth.nim deleted file mode 100644 index a0c1f1a8b..000000000 --- a/src/pylib/Lib/pathlib_impl/meth.nim +++ /dev/null @@ -1,88 +0,0 @@ - - -import ./types -import std/os -when defined(js): - from ../os_impl/osJsPatch import fileExists, dirExists, symlinkExists - -import std/strutils - -using self: types.Path - -func `/`*(self; p: string): Path = self / Path($p) -func `/`*(p: string; self): Path = Path(p) / self - -func `/=`*(head: var Path, tail: string): Path = head = head / tail - -func joinpath*[P: string](self; pathsegments: varargs[P]): Path = - result = self - for i in pathsegments: - result = result / i - -proc is_relative_to*(self; other: string): bool = - isRelativeTo($self, other) - -proc is_relative_to*(self; other: Path): bool = self.is_relative_to $other - -func relative_to*(self; other: string|Path): Path = - Path relativePath($self, $other) - -proc absolute*(self): Path = Path absolutePath $self - -template wrapPred(op, nop){.dirty.} = - proc op*(self): bool = nop $self - -wrapPred is_file, fileExists -wrapPred is_dir, dirExists -wrapPred is_symlink, symlinkExists - -wrapPred is_absolute, isAbsolute - -func as_posix*(self): Path = - Path replace($self, DirSep, '/') - -#[ TODO(after urllib.parse.quote_from_bytes) -func as_uri*(self): Path = - if not self.is_absolute(): - raise newException( - ValueError, "relative path can't be expressed as a file URI") -]# - -func samefile*(self; other_path: string|Path): bool = - sameFile($self, $other_path) - -proc cwd*(_: typedesc[Path]): Path = Path getCurrentDir() -proc home*(_: typedesc[Path]): Path = Path getHomeDir() - -proc open*(self; mode: FileMode): File = - ## EXT. - open($self, mode) - -proc read_nstring*(self): string = - ## EXT. - readFile $self - -proc write_nstring*(self, s: string) = - ## EXT. - writeFile $self, s - - -iterator iterdir*(self): Path = - for i in walkDir($self, relative=true, checkDir=true): - yield self / Path(i.path) - -type IterDirGenerator = ref object - iter: iterator(): Path -proc iterdir*(self): IterDirGenerator = - result = IterDirGenerator(iter: iterator (): Path = - for i in self.iterdir(): - yield i - ) - -when not defined(js): - proc mkdirParentsExistsOk*(self) = - ## EXT. equal to `path.mkdir(parents=True, exists_ok=True)` - ## - ## not for JS backend - createDir $self - diff --git a/src/pylib/Lib/pathlib_impl/os_meth.nim b/src/pylib/Lib/pathlib_impl/os_meth.nim deleted file mode 100644 index bf67d9a21..000000000 --- a/src/pylib/Lib/pathlib_impl/os_meth.nim +++ /dev/null @@ -1,18 +0,0 @@ -## rely pylib/Lib/nos - -import ../os_impl/touch as touchLib -import ../os_impl/posix_like/unlink as unlinkLib -import ../os_impl/posix_like/stat as statLib -import ./types - -using self: Path - -proc touch*(self; mode=0o666, exist_ok=true) = - ## Create this file with the given access mode, if it doesn't exist. - touchLib.touch($self, mode, exist_ok) - -proc unlink*(self) = - ## for missing_ok==False - unlinkLib.unlink $self - -proc stat*(self): stat_result = statLib.stat($self) \ No newline at end of file diff --git a/src/pylib/Lib/pathlib_impl/segments.nim b/src/pylib/Lib/pathlib_impl/segments.nim deleted file mode 100644 index 7e4a123a9..000000000 --- a/src/pylib/Lib/pathlib_impl/segments.nim +++ /dev/null @@ -1,75 +0,0 @@ - -import std/os -import ./types - -using self: types.Path - - -template yield_splitWith(self; - partitionFunc #[: proc(s: string): (string, string)): string]#) = - var - left = $self - cur: string - while left.len != 0: - (left, cur) = left.partitionFunc - yield cur - -iterator parts*(self): string = - ## Path.parts - self.yield_splitWith splitPath - -func parts*(self): seq[string] = - ## Path.parts - for i in self.parts: - result.add i - -func parent*(self): Path = - Path parentDir $self - -iterator parents*(self): Path = - for i in parentDirs($self, inclusive=false): - yield Path i - -func parents*(self): seq[Path] = - ## In Python: returns an immutable Sequence - for i in self.parents: - result.add i - -func name*(self): string = - # XXX: has ignored drive and UNC ? - lastPathPart $self - -func with_name*(self; name: string): Path = - self.parent / Path(name) - -func partitionSuffix(s: string, lhs: static bool): string = - let pos = s.searchExtPos - template orelse(a, b): string = - when lhs: a else: b - if pos == -1: - orelse s, "" - else: - orelse s[0.. 1 or compiles(paths.Path("").hash): - func hash*(self: Path): int = int hash(paths.Path(self)) - else: - import std/hashes - func hash*(self: Path): int = - var p = paths.Path(self) - p.normalizePath - int hash(string p) - - -func `/`*(head, tail: Path): Path{.borrow.} - -func `$`*(p: Path): string = string p diff --git a/src/pylib/Lib/platform.nim b/src/pylib/Lib/platform.nim deleted file mode 100644 index faa9ce2a9..000000000 --- a/src/pylib/Lib/platform.nim +++ /dev/null @@ -1,52 +0,0 @@ - - -import ./private/platformInfo -import ../pystring/strimpl -export strimpl - -proc version*(): PyStr = str `platform.version`() - -func python_implementation*(): PyStr{.inline.} = str "PyNim" -func system*(): PyStr{.inline.} = str `platform.system` - -const machineS = hostCPU -#[ doc says: - -``` -Possible values: - "i386", "amd64", - "powerpc", "powerpc64", "powerpc64el", - - "alpha", "sparc", "loongarch64". - "mips", "mipsel", "mips64", "mips64el", - "arm", "arm64", "riscv32", "riscv64", -``` -]# -# refer to compiler/platform.nim, -# there're more - -# compiler/semfold.nim -# proc getConstExpr(m: PSym, n: PNode; idgen: IdGenerator; g: ModuleGraph): PNode -# of mHostCPU: result = newStrNodeT(platform.CPU[g.config.target.targetCPU].name.toLowerAscii, n, g) - -when defined(windows): - import std/strutils - template winNormMachine(machine): string = - case machine - of "i386": "x86" - of "alpha": "Alpha" - elif machine.startsWith"powerpc": "PowerPC" - elif machine.startsWith"mips": "MIPS" - #elif machine.startsWith"arm": machine.toUpperAscii - else: # including ia64, arm[64], amd64 - machine - -func machine*(): PyStr{.inline.} = - when defined(windows): - winNormMachine machineS - else: - case machineS - of "amd64": "x86_64" - of "arm64": "aarch64" - else: machineS - diff --git a/src/pylib/Lib/private/doc_utils/genIndex.nim b/src/pylib/Lib/private/doc_utils/genIndex.nim deleted file mode 100644 index a37aa531a..000000000 --- a/src/pylib/Lib/private/doc_utils/genIndex.nim +++ /dev/null @@ -1,25 +0,0 @@ - -import std/macros -import std/strutils -import std/os - -proc nimpylibLibFilter*(t: tuple[kind: PathComponent, path: string]): bool = - t.kind != pcDir and t.kind != pcLinkToDir and - t.path != "index.nim" and - not t.path.endsWith"_impl" and - not t.path.startsWith"n_" - -type PathFilter* = typeof nimpylibLibFilter ## path is relative - -proc indexAsMdStr*(dir: string, filter=nimpylibLibFilter): string = - for t in dir.walkDir(relative=true): - if filter(t): - let - fn = t.path - libn = fn.changeFileExt("") - url = fn.changeFileExt("html") - result.add "- [$#]($#)\n".format(libn, url) - - -macro genIndexHere*(filter: static[PathFilter] = nimpylibLibFilter) = - newCommentStmtNode indexAsMdStr(getProjectPath(), filter) diff --git a/src/pylib/Lib/private/platformInfo.nim b/src/pylib/Lib/private/platformInfo.nim deleted file mode 100644 index 2fb2b9187..000000000 --- a/src/pylib/Lib/private/platformInfo.nim +++ /dev/null @@ -1,69 +0,0 @@ -## used by Lib/os and Lib/platform - -const weirdTarget = defined(nimscript) or defined(js) -when not weirdTarget: - import std/osproc -import std/strutils - -template unchkUpperAscii(c: char): char = - char(uint8(c) xor 0b0010_0000'u8) -func capitalizeAscii1(s: string): string = - ## like strutils.capitalize, but assert s.len > 1 - let c = s[0] - if c in 'a'..'z': c.unchkUpperAscii & s.substr(1) - else: s - -const Solaris = defined(solaris) - -const `platform.system`* = - when Solaris: "SunOS" - else: hostOS.capitalizeAscii1 - - - -proc check_output_s(cmd: string): string = - ## a simple `subprocess.check_output`, - ## but arg is string instead of vararg/seq - let t = when weirdTarget: gorgeEx(cmd) else: execCmdEx(cmd) - assert t.exitCode == 0 - result = t.output - -when not defined(windows): - func without(s: string, chars: set[char]): string = - for c in s: - if c not_in chars: - result.add c - - # translated from CPython/configure when setting `ac_md_release` - proc ac_md_release*(): string = - result = check_output_s( - when defined(aix) or defined(UnixWare) or defined(OpenUNIX): "uname -v" - # though UnixWare, OpenUNIX are not officially supported by Nim currently. - else: "uname -r" - ) - result.removeSuffix '\n' - - # tr -d '/ ' - result = result.without {'/', ' '} - - # sed 's/^[A-Z]\.//' - result.removeSuffix {'A'..'Z'} - result.removePrefix '.' - - proc uname_release_major*(): string = - ac_md_release().split('.', 1)[0] # sed 's/\..*//'` - - -proc `platform.version`*(): string = - when defined(windows): - # ver -> "\r\nMicrosoft Windows [Version x.x.xxxxx.xxxx]\r\n" - let s = check_output_s("cmd /c ver").strip(chars={'\r', '\n'}) - let idx = s.find('[') - assert idx != -1 and s[^1] == ']', - "platform.version's impl for Windows is undue now!" - result = s[idx+1..^2] - result = result.split(' ', 1)[1] - else: - result = ac_md_release() - # XXX: TODO: maybe not suitable, see CPython's Lib/platform - diff --git a/src/pylib/Lib/private/platformUtils.nim b/src/pylib/Lib/private/platformUtils.nim deleted file mode 100644 index 499ef0ebc..000000000 --- a/src/pylib/Lib/private/platformUtils.nim +++ /dev/null @@ -1,27 +0,0 @@ - -const CLike* = defined(c) or defined(cpp) or defined(objc) - -template clikeOr*(inCLike, b): untyped = - # for nimvm-able expr - bind CLike - when nimvm: b - else: - when CLike: inCLike - else: b - -template impJsOrC*(sym, cfloatSym, argSym){.dirty.} = - bind CLike - when defined(js): - func sym(argSym: float): float{.importjs: "Math." & astToStr(sym) & "(#)".} - func sym(argSym: float32): float32 = float32(sym(float argSym)) - elif CLike: - {.push header: "".} - func sym(arg: c_double): c_double{.importc.} - func cfloatSym(arg: c_float): c_float{.importc.} - {.pop.} - func sym(argSym: float): float = float sym(arg=c_double(argSym)) - func sym(argSym: float32): float32 = float32 cfloatSym c_float(argSym) - else: - {.error: "unreachable".} - - diff --git a/src/pylib/Lib/random.nim b/src/pylib/Lib/random.nim deleted file mode 100644 index 26717b91b..000000000 --- a/src/pylib/Lib/random.nim +++ /dev/null @@ -1,63 +0,0 @@ -## .. note:: global random state is indenpendent from Nim's std/random's -## -## .. note:: `random()` algorithm differs Python's, -## meaning the same seed produces different result -## -## TODO: PyRandom uses method; impl SysRandom -## TODO: commandLine pysince(3,13) - -import std/options - -import ../version -import ../noneType -import ../builtins/list -import ../pybytes/bytesimpl -import ./collections/abc - -import ./n_random -import ./random_impl/macroutils - -using self: PyRandom - -export n_random except randbytes, choices, triangular - -genGbls: - proc seed*(self; _: NoneType) = self.seed() - proc seed*(self; val: int64) = self.seed(some(val)) - - func randbytes*(self; n: int): PyBytes{.pysince(3,9).} = - bytes n_random.randbytes(self, n) - - func shuffle*[T](self; x: var PyList[T]) = - n_random.shuffleImpl(self, x) - - func sample*[T](self; population: Sequence[T], k: int): PyList[T] = - list n_random.sample(self, @population, k) - - func sample*[T](self; population: Sequence[T], k: int, counts: Sequence[T]): PyList[T]{.pysince(3,9).} = - list n_random.sample(self, @population, k, @counts) - - func choice*[T](self; ls: Sequence[T]): T = - if ls.len == 0: - raise newException(IndexError, "Cannot choose from an empty sequence") - - ls[self.randint(0, len(ls))] - - func choices*[T](self; population: Sequence[T]; - weights: NoneType|Sequence[T] = None; - cum_weights: NoneType|Sequence[T] = None; - k=1): PyList[T] = - when cum_weights is NoneType: - let cum_weights = none(openArray[T]) - when weights is NoneType: - let weights = cum_weights - elif not (weights is NoneType): - # when weights is_not NoneType and cum_weights is_not NoneType: - {.error: "Cannot specify both weights and cumulative weights".} - template `@`(x: Option): Option = x - - list n_random.choices(self, @population, @weights, @cum_weights, k=k) - - func triangular*[F: SomeFloat](self; low: F = 0.0, high: F = 1.0; mode: F|NoneType = None): F = - when mode is NoneType: n_random.triangular(self, low, high) - else: n_random.triangular(self, low, high, mode) diff --git a/src/pylib/Lib/random_impl/gstate.nim b/src/pylib/Lib/random_impl/gstate.nim deleted file mode 100644 index 2d04b20dd..000000000 --- a/src/pylib/Lib/random_impl/gstate.nim +++ /dev/null @@ -1,9 +0,0 @@ - -import ./types -export types - -var gRandom* = Random() - -template gRand*: untyped = - bind gRandom, getmstate - gRandom.getmstate() diff --git a/src/pylib/Lib/random_impl/justLessThanOneConst.nim b/src/pylib/Lib/random_impl/justLessThanOneConst.nim deleted file mode 100644 index 089e33287..000000000 --- a/src/pylib/Lib/random_impl/justLessThanOneConst.nim +++ /dev/null @@ -1,5 +0,0 @@ -## replace `justLessThanOne`_ declaration with hard-coded constant -## if you wanna get rid of `n_math` dependence - -from ../../Lib/n_math import nextafter -const justLessThanOne* = nextafter(1.0, 0.0) diff --git a/src/pylib/Lib/random_impl/macroutils.nim b/src/pylib/Lib/random_impl/macroutils.nim deleted file mode 100644 index 0711fcc91..000000000 --- a/src/pylib/Lib/random_impl/macroutils.nim +++ /dev/null @@ -1,41 +0,0 @@ - -import std/macros - -import ./gstate - -func newProc(name, params, body: NimNode; procType: NimNodeKind, generics: NimNode): NimNode = - result = newNimNode(procType).add( - name, - newEmptyNode(), - generics, - params, - newEmptyNode(), - newEmptyNode(), - body) - -template mkExported(name: NimNode): NimNode = postfix(name, "*") - -func genGblImpl(decl: NimNode): NimNode = - result = newStmtList decl - let name = decl.name - var params = decl.params.copyNimTree - assert params[1][0].eqIdent "self", $params[1][0] - params.del 1 - - const gName = "gRandom" - var body = newStmtList nnkBindStmt.newTree(bindSym(gName), name) - var call = newCall(name, ident(gName)) - for i in 1..= 8*sizeof(int)` - if k == 0: - return 0 - type R = int - const - MaxSize = sizeof(R) - MaxBit = 8 * MaxSize ## XXX: as result is signed, MaxBit shall not be included - assert k < MaxBit - - var res: seq[uint8] - res.fromU32s self.getrandbits_impl k - res.setLen MaxSize - result = cast[ptr R](res[0].addr)[] - when PyLittleEndian: - result = result shr (MaxBit - k) - - func randrange*[I: SomeInteger](self; istart, istop: I; istep: I): I = # This code is a bit messy to make it fast for the - # common case while still doing adequate error checking. - let - width = istop - istart - # Fast path. - if istep == 1: - if width > 0: - return istart + self.randbelow(width) - raise_ValueError(fmt"empty range in randrange({start}, {stop})") - - # Non-unit step argument supplied. - let n = - if istep > 0: - (width + istep - 1) div istep - elif istep < 0: - (width + istep + 1) div istep - else: - raise_ValueError("zero step for randrange()") - if n <= 0: - raise_ValueError(fmt"empty range in randrange({start}, {stop}, {step})") - return istart + istep * self.randbelow(n) - - func randrange*[T; I: Indexable[T]](self; start, stop, step: I): T = - self.randrange(index(start), index(stop), index(step)) - - - func choices*[T](self; population: openArray[T]; - weights = none(openArray[T]); - cum_weights = none(openArray[T]); - k=1): seq[T] = - bind_random_self - let n = len(population) - let cum_weights = - if cum_weights.isNone: - if weights.isNone: - let n = float(n) # convert to float for a small speed improvement - return collect: - for _ in 1..k: - population[floor(random() * n)] - toSeq(accumulate(weights.unsafeGet)) - elif not weights.isNone: - raise_TypeError("Cannot specify both weights and cumulative weights") - else: - cum_weights.unsafeGet - - if len(cum_weights) != n: - raise_ValueError("The number of weights does not match the population") - let total = cum_weights[^1].float # convert to float - if total <= 0.0: - raise_ValueError("Total of weights must be greater than zero") - if not isfinite(total): - raise_ValueError("Total of weights must be finite") - let hi = n - 1 - return collect: - for _ in 1..k: - population[bisect(cum_weights, random() * total, 0, hi)] - - -template shuffleImpl*(self: PyRandom; x) = - ## inner. unstable. - for i in countdown(len(x)-1, 1): - # pick an element in x[:i+1] with which to exchange x[i] - let j = self.randbelow(i + 1) - (x[i], x[j]) = (x[j], x[i]) - - -genGbls: - func shuffle*[T](self; x: var seq[T]) = - self.shuffleImpl x - - func sample*[T](self; population: openArray[T], k: int): seq[T] = - # Sampling without replacement entails tracking either potential - # selections (the pool) in a list or previous selections in a set. - - # When the number of selections is small compared to the - # population, then tracking selections is efficient, requiring - # only a small set and an occasional reselection. For - # a larger number of selections, the pool tracking method is - # preferred since the list takes less space than the - # set and it doesn't suffer from frequent reselections. - - # The number of calls to _randbelow() is kept at or near k, the - # theoretical minimum. This is important because running time - # is dominated by _randbelow() and because it extracts the - # least entropy from the underlying random number generators. - - # Memory requirements are kept to the smaller of a k-length - # set or an n-length list. - - # There are other sampling algorithms that do not require - # auxiliary memory, but they were rejected because they made - # too many calls to _randbelow(), making them slower and - # causing them to eat more entropy than necessary. - - - #if not isinstance(population, _Sequence): - # raise_TypeError("Population must be a sequence. " - # "For dicts or sets, use sorted(d).") - let n = len(population) - - template randbelow(x): untyped = self.randbelow(x) - if not (0 <= k and k <= n): - raise_ValueError("Sample larger than population or is negative") - result = - when compiles(newSeqUninit[T](k)): newSeqUninit[T](k) - else: newSeq[T](k) - var setsize = 21 # size of a small set minus size of an empty list - if k > 5: - setsize += 4 ** ceil(log(k * 3, 4)) # table size for big sets - if n <= setsize: - # An n-length list is smaller than a k-length set. - # Invariant: non-selected at pool[0 : n-i] - var pool = toSeq(population) - for i in 0.. c: - u = 1.0 - u - c = 1.0 - c - (low, high) = (high, low) - return low + (high - low) * sqrt(u * c) - -genGbls: - func triangular*[F: SomeFloat](self; low: F = 0.0, high: F = 1.0): F = - triangularImpl: - const c = 0.5 - func triangular*[F: SomeFloat](self; low: F = 0.0, high: F = 1.0; mode: F): F = - triangularImpl: - let d = high - low - if d == 0: - return low - let c = (mode - low) / d - - - func normalvariate*(self; mu=0.0, sigma=1.0): float = - # Uses Kinderman and Monahan method. Reference: Kinderman, - # A.J. and Monahan, J.F., "Computer generation of random - # variables using the ratio of uniform deviates", ACM Trans - # Math Software, 3, (1977), pp257-260. - - const NV_MAGICCONST = 4 * exp(-0.5) / sqrt(2.0) - var u1, u2, z, zz: float - while true: - u1 = self.random() - u2 = 1.0 - self.random() - z = NV_MAGICCONST * (u1 - 0.5) / u2 - zz = z * z / 4.0 - if zz <= -log(u2): - break - return mu + z * sigma - - func lognormalvariate*(self; mu, sigma: float): float = - exp(self.normalvariate(mu, sigma)) - - func expovariate*(self; lambd=1.0): float = - -log(1.0 - self.random()) / lambd - - func vonmisesvariate*(self; mu, kappa: float): float = - bind_random_self - if kappa <= 1e-6: - return TWOPI * random() - - let - s = 0.5 / kappa - r = s + sqrt(1.0 + s * s) - - var z: float - while true: - let u1 = random() - z = cos(pi * u1) - - let - d = z / (r + z) - u2 = random() - if u2 < 1.0 - d * d or u2 <= (1.0 - d) * exp(d): - break - - let - q = 1.0 / r - f = (q + z) / (1.0 + q * z) - u3 = random() - if u3 > 0.5: - (mu + acos(f)) % TWOPI - else: - (mu - acos(f)) % TWOPI - - func gammavariate*(self; alpha, beta: float): float = - if alpha <= 0.0 or beta <= 0.0: - raise_ValueError("gammavariate: alpha and beta must be > 0.0") - - bind_random_self - if alpha > 1.0: - - # Uses R.C.H. Cheng, "The generation of Gamma - # variables with non-integral shape parameters", - # Applied Statistics, (1977), 26, No. 1, p71-74 - - const - LOG4 = log(4.0) - SG_MAGICCONST = 1.0 + log(4.5) - let - ainv = sqrt(2.0 * alpha - 1.0) - bbb = alpha - LOG4 - ccc = alpha + ainv - - var u1: float - while true: - u1 = random() - if not (1e-7 < u1 and u1 < 0.9999999): - continue - let - u2 = 1.0 - random() - v = log(u1 / (1.0 - u1)) / ainv - x = alpha * exp(v) - z = u1 * u1 * u2 - r = bbb + ccc * v - x - if r + SG_MAGICCONST - 4.5 * z >= 0.0 or r >= log(z): - return x * beta - - elif alpha == 1.0: - # expovariate(1/beta) - return -log(1.0 - random()) * beta - - else: - # alpha is between 0 and 1 (exclusive) - # Uses ALGORITHM GS of Statistical Computing - Kennedy & Gentle - var x: float - while true: - let - u = random() - b = (e + alpha) / e - p = b * u - u1 = random() - x = - if p <= 1.0: - p ** (1.0 / alpha) - else: - -log((b - p) / alpha) - if p > 1.0: - if u1 <= x ** (alpha - 1.0): - break - elif u1 <= exp(-x): - break - return x * beta - - func betavariate*(self; alpha, beta: float): float = - ##[Beta distribution. - - Conditions on the parameters are alpha > 0 and beta > 0. - Returned values range between 0 and 1. - - The mean (expected value) and variance of the random variable are: - - ```python - E[X] = alpha / (alpha + beta) - Var[X] = alpha * beta / ((alpha + beta)**2 * (alpha + beta + 1)) - ``` - ]## - ## See - ## http://mail.python.org/pipermail/python-bugs-list/2001-January/003752.html - ## for Ivan Frohne's insightful analysis of why the original implementation: - ## - ## def betavariate(self, alpha, beta): - ## # Discrete Event Simulation in C, pp 87-88. - ## - ## y = self.expovariate(alpha) - ## z = self.expovariate(1.0/beta) - ## return z/(y+z) - ## - ## was dead wrong, and how it probably got that way. - - # This version due to Janne Sinkkonen, and matches all the std - # texts (e.g., Knuth Vol 2 Ed 3 pg 134 "the beta distribution"). - let y = self.gammavariate(alpha, 1.0) - if y != 0: - return y / (y + self.gammavariate(beta, 1.0)) - return 0.0 - - func paretovariate*(self; alpha: float): float = - ## Pareto distribution. alpha is the shape parameter. - # Jain, pg. 495 - - let u = 1.0 - self.random() - return u ** (-1.0 / alpha) - - func weibullvariate*(self; alpha, beta: float): float = - ##[ Weibull distribution. - - alpha is the scale parameter and beta is the shape parameter. - - ]## - # Jain, pg. 499; bug fix courtesy Bill Arms - - let u = 1.0 - self.random() - return alpha * (-log(u)) ** (1.0 / beta) - - - # -------------------- discrete distributions --------------------- - - func binomialvariate*(self; n=1.0, p=0.5): float = - ##[ Binomial random variable. - - Gives the number of successes for *n* independent trials - with the probability of success in each trial being *p*: - - sum(random() < p for i in range(n)) - - Returns an integer in the range: 0 <= X <= n - - The mean (expected value) and variance of the random variable are: - - ``` - E[X] = n * p - Var[x] = n * p * (1 - p) - ``` - - ]### - # Error check inputs and handle edge cases - if n < 0: - raise_ValueError("n must be non-negative") - if p <= 0.0 or p >= 1.0: - if p == 0.0: - return 0 - if p == 1.0: - return n - raise_ValueError("p must be in the range 0.0 <= p <= 1.0") - - bind_random_self - - # Fast path for a common case - if n == 1: - return float(index(random() < p)) - - # Exploit symmetry to establish: p <= 0.5 - if p > 0.5: - return n - self.binomialvariate(n, 1.0 - p) - - if n * p < 10.0: - # BG: Geometric method by Devroye with running time of O(np). - # https://dl.acm.org/doi/pdf/10.1145/42372.42381 - var - x = 0 - y = 0 - let c = log2(1.0 - p) - if c == 0: - return float(x) - while true: - y += floor(log2(random()) / c) + 1 - if float(y) > n: - return float(x) - x += 1 - - # BTRS: Transformed rejection with squeeze method by Wolfgang Hörmann - # https://citeseerx.ist.psu.edu/viewdoc/download?doi=10.1.1.47.8407&rep=rep1&type=pdf - assert n*p >= 10.0 and p <= 0.5 - var - setup_complete = false - - - spq = sqrt(n * p * (1.0 - p)) # Standard deviation of the distribution - b = 1.15 + 2.53 * spq - a = -0.0873 + 0.0248 * b + 0.01 * p - c = n * p + 0.5 - vr = 0.92 - 4.2 / b - - - var - m, - alpha, lpq, - h: float - while true: - var u = random() - u -= 0.5 - let us = 0.5 - fabs(u) - let k = float(floor((2.0 * a / us + b) * u + c)) - if k < 0 or k > n: - continue - - # The early-out "squeeze" test substantially reduces - # the number of acceptance condition evaluations. - var v = random() - if us >= 0.07 and v <= vr: - return k - - # Acceptance-rejection test. - # Note, the original paper erroneously omits the call to log(v) - # when comparing to the log of the rescaled binomial distribution. - if not setup_complete: - alpha = (2.83 + 5.1 / b) * spq - lpq = log(p / (1.0 - p)) - m = float(floor((n + 1) * p)) # Mode of the distribution - h = lgamma(m + 1) + lgamma(n - m + 1) - setup_complete = true # Only needs to be done once - v *= alpha / (a / (us * us) + b) - if log(v) <= h - lgamma(k + 1) - lgamma(n - k + 1) + (k - m) * lpq: - return k - diff --git a/src/pylib/Lib/random_impl/sysrand.nim b/src/pylib/Lib/random_impl/sysrand.nim deleted file mode 100644 index 4e7d251b4..000000000 --- a/src/pylib/Lib/random_impl/sysrand.nim +++ /dev/null @@ -1,51 +0,0 @@ - -import std/options -from std/math import pow -import ./types -#import ./[proc_dispatched, proc_others] -from ../os import urandom -import ../../numTypes/ints -from ../../pyerrors/rterr import NotImplementedError - -type - PySysRandom* = ref object of PyRandom - -proc SysRandom*(): PySysRandom = PySysRandom Random() -proc SysRandom*(seed: int64): PySysRandom = PySysRandom Random(seed) - -const - BPF = 53 # Number of bits in a float - RECIP_BPF = pow(float(2), -BPF) ## 2 ** -BPF - -using self: PySysRandom - -method random*(self): float = - ## Get the next random number in the range 0.0 <= X < 1.0. - float(int.from_bytes(urandom(7)) shr 3) * RECIP_BPF - -template raise_ValueError(msg) = raise newException(ValueError, msg) - -method getrandbits*(self; k: int): int = - if k < 0: - raise_ValueError("number of bits must be non-negative") - let - numbytes = (k + 7) div 8 # bits / 8 and rounded up - x = int.from_bytes(urandom(numbytes)) - return x shr (numbytes * 8 - k) # trim excess bits - -method randbytes*(self; n: int): string = - # os.urandom(n) fails with ValueError for n < 0 - # and returns an empty bytes string for n == 0. - urandom(n) - -method seed*(self; _ = none(int64)) = - ## Stub method. Not used for a system random number generator." - discard - -## Method should not be called for a system random number generator. -template notimplemented = - raise newException(NotImplementedError, - "System entropy source does not have state.") - -method getstate*(self): PyRandomState = notimplemented -method setstate*(self; _: PyRandomState) = notimplemented diff --git a/src/pylib/Lib/random_impl/types.nim b/src/pylib/Lib/random_impl/types.nim deleted file mode 100644 index 7686c5ea2..000000000 --- a/src/pylib/Lib/random_impl/types.nim +++ /dev/null @@ -1,20 +0,0 @@ - -import std/random - -type - PyRandom* = ref object of RootObj - state: Rand - -template newPyRandom(r: Rand): PyRandom = PyRandom(state: r) - -proc Random*(): PyRandom = newPyRandom initRand() -proc Random*(x: int64): PyRandom = newPyRandom initRand(x) - -type PyRandomState* = Rand ## unstable. -using self: PyRandom -method getstate*(self): PyRandomState{.base.} = self.state -proc getmstate*(self): var PyRandomState = - ## unstable. inner. Do not use - self.state -method setstate*(self; state: PyRandomState){.base.} = self.state = state - diff --git a/src/pylib/Lib/resource.nim b/src/pylib/Lib/resource.nim deleted file mode 100644 index 987adc95b..000000000 --- a/src/pylib/Lib/resource.nim +++ /dev/null @@ -1,6 +0,0 @@ - -import ./resource_impl/[ - funcs, consts, types -] - -export funcs, consts, types diff --git a/src/pylib/Lib/resource_impl/consts.nim b/src/pylib/Lib/resource_impl/consts.nim deleted file mode 100644 index 674f838b0..000000000 --- a/src/pylib/Lib/resource_impl/consts.nim +++ /dev/null @@ -1,47 +0,0 @@ - -from ./csyms import SIZEOF_RLIMIT_T, RUSAGE_BOTH, RUSAGE_THREAD - -const RLIM_INFINITY* = - when SIZEOF_RLIMIT_T == 8: - 0xffffffffffffffffu - else: - 0xffffffffu - -template wrap(name){.dirty.} = - let `c name`{.importc: astToStr(name), header: "".}: cint - let name* = int `c name` -template wrap(name, os){.dirty.} = - when defined(os): - wrap(name) -template wrapIfE(name){.dirty.} = - when declared(name) and name != low(int): - const name* = int name - -wrap(RLIMIT_CORE) -wrap(RLIMIT_CPU) -wrap(RLIMIT_FSIZE) -wrap(RLIMIT_DATA) -wrap(RLIMIT_STACK) -wrap(RLIMIT_RSS) -wrap(RLIMIT_NPROC) -wrap(RLIMIT_NOFILE) -wrap(RLIMIT_OFILE) -wrap(RLIMIT_MEMLOCK) -wrap(RLIMIT_VMEM, freebsd) -wrap(RLIMIT_AS) -when defined(linux): - wrap(RLIMIT_MSGQUEUE) - wrap(RLIMIT_NICE) - wrap(RLIMIT_RTPRIO) - wrap(RLIMIT_RTTIME) - wrap(RLIMIT_SIGPENDING) -when defined(freebsd): - wrap(RLIMIT_SBSIZE) - wrap(RLIMIT_SWAP) - wrap(RLIMIT_NPTS) - wrap(RLIMIT_KQUEUES) - -wrap(RUSAGE_SELF) -wrap(RUSAGE_CHILDREN) -wrapIfE(RUSAGE_BOTH) -wrapIfE(RUSAGE_THREAD) diff --git a/src/pylib/Lib/resource_impl/csyms.nim b/src/pylib/Lib/resource_impl/csyms.nim deleted file mode 100644 index 841b4de14..000000000 --- a/src/pylib/Lib/resource_impl/csyms.nim +++ /dev/null @@ -1,3 +0,0 @@ - -import ../../pyconfig/resource -export resource diff --git a/src/pylib/Lib/resource_impl/funcs.nim b/src/pylib/Lib/resource_impl/funcs.nim deleted file mode 100644 index 13be22e68..000000000 --- a/src/pylib/Lib/resource_impl/funcs.nim +++ /dev/null @@ -1,117 +0,0 @@ - -import ./types -import std/posix except EINVAL, EPERM -import ../n_errno -import ../sys_impl/auditImpl as sys -import ../../pyerrors/oserr -from ./csyms import HAVE_PRLIMIT, HAVE_GETPAGESIZE, HAVE_SYSCONF_PAGE_SIZE - -proc getrusage*(who: int): struct_rusage = - var ru: posix.RUsage - if getrusage(who.cint, addr ru) == -1: - if isErr(EINVAL): - raise newException(ValueError, "Invalid who value") - raiseErrno() - ru.toPyObject() - -type - py_rlimit* = tuple - rlim_cur: int - rlim_max: int - py_rlimit_abc = concept self - self.len is int - self[int] is int - -# XXX: NIM-BUG: rlim_cur and rlim_max are int over unsigned in std/posix - -proc py2rlimit(limits: py_rlimit, rl_out: var RLimit) = - rl_out.rlim_cur = limits.rlim_cur - rl_out.rlim_max = limits.rlim_max - -template py2rlimit[T](limits: T{atom}, rl_out: var RLimit) = - assert limits.len == 2 - rl_out.rlim_cur = limits[0] - rl_out.rlim_max = limits[1] -template py2rlimit[T](limits: T, rl_out: var RLimit) = - let li = limits - py2rlimit(li, rl_out) - -proc rlimit2py(rl_in: RLimit): py_rlimit = (rl_in.rlim_cur, rl_in.rlim_max) - -let RLIM_NLIMITS{.importc, header: "".}: cint - -proc checked_resource*(resource: int): cint = - if resource < 0 or resource >= RLIM_NLIMITS: - raise newException(ValueError, "Invalid resource specified") - cast[cint](resource) - -proc getrlimit*(resource: int): py_rlimit = - var rl: RLimit - if getrlimit(checked_resource(resource), rl) == -1: - raiseErrno() - rlimit2py(rl) - -proc raise_inval = - raise newException(ValueError, "current limit exceeds maximum limit") - -proc setrlimitWrap(resource: int, rl: var RLimit) = - if setrlimit(checked_resource(resource), rl) == -1: - if isErr(EINVAL): raise_inval() - elif isErr(EPERM): - raise newException(ValueError, "not allowed to raise maximum limit") - raiseErrno() - -template setrlimit*[T: py_rlimit_abc|py_rlimit](resource: int, limits: T) = - ## this is defined as `template`. - ## Because if being `proc`, py_rlimit_abc match cannot work - bind py2rlimit, setrlimitWrap, audit - mixin len, `[]` - sys.audit("resource.setrlimit", resource, limits) - var rl: RLimit - py2rlimit(limits, rl) - setrlimitWrap(resource, rl) - -when HAVE_PRLIMIT: - proc prlimit(pid: Pid, resource: cint, new_limit: ptr RLimit, old_limit: var RLimit): cint {. - importc, header: "".} - - proc prlimit*(pid: int, resource: int): py_rlimit{.discardable.} = - let - pid = Pid pid - resource = checked_resource(resource) - var old_limit: RLimit - if prlimit(pid, resource, nil, old_limit) == -1: - if isErr(EINVAL): raise_inval() - raiseErrno() - rlimit2py(old_limit) - - proc prlimitWrap(pid: Pid, resource: cint, new_limit: var RLimit): py_rlimit{.discardable.} = - var old_limit: RLimit - if prlimit(pid, resource, addr new_limit, old_limit) == -1: - if isErr(EINVAL): raise_inval() - raiseErrno() - rlimit2py(old_limit) - - template prlimit*[T: py_rlimit_abc|py_rlimit](pid: int, resource: int, limits: T): py_rlimit = - ## discardable. - ## - ## this is defined as `template`. - ## Because if being `proc`, py_rlimit_abc match cannot work - bind Pid, checked_resource, RLimit, py2rlimit, prlimitWrap - mixin len, `[]` - let - tpid = Pid pid - tresource = checked_resource(resource) - sys.audit("resource.prlimit", pid, resource, limits) - var new_limit: RLimit - py2rlimit(limits, new_limit) - prlimitWrap(tpid, tresource, new_limit) - -when HAVE_GETPAGESIZE: - proc c_getpagesize(): cint{.importc: "getpagesize", header: "".} - proc getpagesize*(): int = int c_getpagesize() -elif HAVE_SYSCONF_PAGE_SIZE: - let SC_PAGE_SIZE{.importc, header: "".}: cint - proc c_sysconf(name: cint): cint{.importc, header: "".} - proc getpagesize*(): int = int c_sysconf(SC_PAGE_SIZE) - diff --git a/src/pylib/Lib/resource_impl/types.nim b/src/pylib/Lib/resource_impl/types.nim deleted file mode 100644 index 481f6348d..000000000 --- a/src/pylib/Lib/resource_impl/types.nim +++ /dev/null @@ -1,44 +0,0 @@ - -import std/posix - -type - struct_rusage* = ref object - ru_utime*: float - ru_stime*: float - ru_maxrss*: int - ru_ixrss*: int - ru_idrss*: int - ru_isrss*: int - ru_minflt*: int - ru_majflt*: int - ru_nswap*: int - ru_inblock*: int - ru_oublock*: int - ru_msgsnd*: int - ru_msgrcv*: int - ru_nsignals*: int - ru_nvcsw*: int - ru_nivcsw*: int - -template doubletime(tv: TimeVal): float = - float(tv.tv_sec) + float(tv.tv_usec) / 1000000.0 - -proc toPyObject*(rusage: RUsage): struct_rusage = - struct_rusage( - ru_utime: doubletime(rusage.ru_utime), - ru_stime: doubletime(rusage.ru_stime), - ru_maxrss: rusage.ru_maxrss, - ru_ixrss: rusage.ru_ixrss, - ru_idrss: rusage.ru_idrss, - ru_isrss: rusage.ru_isrss, - ru_minflt: rusage.ru_minflt, - ru_majflt: rusage.ru_majflt, - ru_nswap: rusage.ru_nswap, - ru_inblock: rusage.ru_inblock, - ru_oublock: rusage.ru_oublock, - ru_msgsnd: rusage.ru_msgsnd, - ru_msgrcv: rusage.ru_msgrcv, - ru_nsignals: rusage.ru_nsignals, - ru_nvcsw: rusage.ru_nvcsw, - ru_nivcsw: rusage.ru_nivcsw - ) diff --git a/src/pylib/Lib/shutil.nim b/src/pylib/Lib/shutil.nim deleted file mode 100644 index 43f55e05d..000000000 --- a/src/pylib/Lib/shutil.nim +++ /dev/null @@ -1,4 +0,0 @@ - -import ./n_shutil -export n_shutil - diff --git a/src/pylib/Lib/shutil_impl/copys.nim b/src/pylib/Lib/shutil_impl/copys.nim deleted file mode 100644 index 77d29bf4d..000000000 --- a/src/pylib/Lib/shutil_impl/copys.nim +++ /dev/null @@ -1,91 +0,0 @@ - -import std/os -when defined(posix): - import std/posix -import ../../pyerrors/oserr -import ../../io_abc -import ./sys - -const COPY_BUFSIZE = when defined(windows): 64 * 1024 else: 16 * 1024 -# Python uses as followings, but it seems too large -# when defined(windows): 1024 * 1024 else: 64 * 1024 - -proc copyfileobjImpl(s, d: File, length=COPY_BUFSIZE) = - ## shutil.copyfileobj but for Nim's `File`, here length must be positive - let bufferSize = length - # The following is modified from Nim-2.1.1/Lib/std/private/osfiles.nim L241 - # generic version of copyFile which works for any platform: - - # Hints for kernel-level aggressive sequential low-fragmentation read-aheads: - # https://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_fadvise.html - when defined(linux) or defined(osx): - discard posix_fadvise(getFileHandle(d), 0.cint, 0.cint, POSIX_FADV_SEQUENTIAL) - discard posix_fadvise(getFileHandle(s), 0.cint, 0.cint, POSIX_FADV_SEQUENTIAL) - var buf = alloc(bufferSize) - while true: - var bytesread = readBuffer(s, buf, bufferSize) - if bytesread > 0: - var byteswritten = writeBuffer(d, buf, bytesread) - if bytesread != byteswritten: - dealloc(buf) - raiseOSError(osLastError()) - if bytesread != bufferSize: break - dealloc(buf) - flushFile(d) - -proc copyfileobj*(s, d: File, length=COPY_BUFSIZE) = - ## shutil.copyfileobj but for Nim's `File` - ## - ## if `length` is negative, it means copying the data - ## without looping over the source data in chunks - if length < 0: - d.write(s.readAll()) - return - copyfileobjImpl(s, d, length) - -type - Error = object of PyOSError ## python's shutil.Error - SameFileError* = object of Error -template copyFileImpl(src, dst: string; options: CopyFlag) = - ## called by copyfile - bind copyFile, copyfileobjImpl - when defined(windows): - # std/os's `copyFile` under Windows calls copyFileW, - # which will copy file attributes too. - # so we use another implementation instead. - let isSymlink = src.symlinkExists - if isSymlink and cfSymlinkAsIs in options: - createSymlink(expandSymlink(source), dest) - return - var - fsrc = open(src) - fdst = open(dst, fmWrite) - defer: - fsrc.close() - fdst.close() - copyfileobjImpl(fsrc, dst) - else: - copyFile(src, dst, options) - -template copyGen(pyname, impl) = - proc pyname*[T](src, dst: PathLike[T], follow_symlinks=true) = - sys.audit("shutil.copyfile", src, dst) - let - ssrc = $src - sdst = $dst - cpOptions = if follow_symlinks: {cfSymlinkFollow} else: {cfSymlinkAsIs} - if sameFile(ssrc, sdst): - raise newException(SameFileError, pth) - tryOsOp(src, dst): impl(ssrc, sdst, options=cpOptions) - -copyGen copyfile, copyFileImpl - -proc copyWithPermissions(src, dst: string, - options={cfSymlinkFollow}) = - let dstFile = if dst.dirExists: dst / src.lastPathPart - else: dst - copyFileWithPermissions(src, dstFile, - false, # we do not `ignorePermissionErrors` - options) - -copyGen copy, copyWithPermissions \ No newline at end of file diff --git a/src/pylib/Lib/shutil_impl/rmtreeImpl.nim b/src/pylib/Lib/shutil_impl/rmtreeImpl.nim deleted file mode 100644 index e7d72ef51..000000000 --- a/src/pylib/Lib/shutil_impl/rmtreeImpl.nim +++ /dev/null @@ -1,242 +0,0 @@ -import ./sys -import ../os -const use_fd_functions = ( - os.supports_dir_fd >= {os.open, os.stat, os.unlink, os.rmdir} and - #(os.open, os.stat, os.unlink, os.rmdir) <= os.supports_dir_fd and - os.scandir in os.supports_fd and - os.stat in os.supports_follow_symlinks) -when not use_fd_functions: - import ../stat - -type P = string -type - #Path1Proc = proc (p: string) - Path1ProcKind = enum - os_close - os_rmdir - os_lstat - os_open - os_unlink - os_path_islink - os_scandir - OnExc = proc ( - p: Path1ProcKind, - fullpath: P, - exc: ref OSError - ) - -type Stack[T] = seq[ - tuple[fun: Path1ProcKind, dirfd: int, path: T, orig_entry: DirEntry[int]] -] -using onexc: OnExc -template isinstance(e; t): bool = e of t -const - False = false -template pass = discard -template `is`(a, b: Path1ProcKind): bool = a == b -template `is_not`(a, b: Path1ProcKind): bool = a != b -#template `is`(a: DirEntry, b: NoneType): bool = a.isNone -when use_fd_functions: - import ../../pysugar/pywith - import std/sequtils - type List[T] = seq[T] - template append[T](s: seq[T]; e: T) = s.add e - template list(s): untyped = toSeq(s) - const - None = nil - proc rmtree_safe_fd_step(stack: var Stack[P]; onexc) = - # Each stack item has four elements: - # * func: The first operation to perform: os.lstat, os.close or os.rmdir. - # Walking a directory starts with an os.lstat() to detect symlinks; in - # this case, func is updated before subsequent operations and passed to - # onexc() if an error occurs. - # * dirfd: Open file descriptor, or None if we're processing the top-level - # directory given to rmtree() and the user didn't supply dir_fd. - # * path: Path of file to operate upon. This is passed to onexc() if an - # error occurs. - # * orig_entry: os.DirEntry, or None if we're processing the top-level - # directory given to rmtree(). We used the cached stat() of the entry to - # save a call to os.lstat() when walking subdirectories. - var - entries: List[DirEntry[int]] - orig_st: stat_result - topfd: int - name: P - fullname: P - (fun, dirfd, path, orig_entry) = stack.pop() - - name = if orig_entry is None: path else: orig_entry.name - try: - if fun is os_close: - os.close(dirfd) - return - if fun is os_rmdir: - os.rmdir(name, dir_fd=dirfd) - return - - # Note: To guard against symlink races, we use the standard - # lstat()/open()/fstat() trick. - assert fun is os_lstat - if orig_entry is None: - orig_st = os.lstat(name, dir_fd=dirfd) - else: - orig_st = orig_entry.stat(follow_symlinks=False) - - fun = os_open # For error reporting. - topfd = os.open(name, os.O_RDONLY | os.O_NONBLOCK, dir_fd=dirfd) - - fun = os_path_islink # For error reporting. - try: - if not os.path.samestat(orig_st, os.fstat(topfd)): - # Symlinks to directories are forbidden, see GH-46010. - raise newPyOSError("Cannot call rmtree on a symbolic link") - stack.append((os_rmdir, dirfd, path, orig_entry)) - finally: - stack.append((os_close, topfd, path, orig_entry)) - - fun = os_scandir # For error reporting. - with os.scandir(topfd) as scandir_it: - entries = list(scandir_it) - for entry in entries: - fullname = os.path.join(path, entry.name) - try: - if entry.is_dir(follow_symlinks=False): - # Traverse into sub-directory. - stack.append((os_lstat, topfd, fullname, entry)) - continue - except FileNotFoundError: - continue - except OSError: - pass - try: - unlink(entry.name, dir_fd=topfd) - except FileNotFoundError: - continue - except OSError as err: - onexc(os_unlink, fullname, err) - except FileNotFoundError as err: - if orig_entry is None or fun is os_close: - err.filename = path - onexc(fun, path, err) - except OSError as err: - if isinstance(err, PyOSError): - let e = (ref PyOSError)(err) - e.filename = path - onexc(fun, path, err) - - # _rmtree_safe_fd - proc rmtreeImpl[P](path: P, dir_fd: int, onexc) = - ## Version using fd-based APIs to protect against races - # While the unsafe rmtree works fine on bytes, the fd based does not. - #if isinstance(path, bytes): - when P is_not string: - let path = os.fsdecode(path) - var stack: Stack[P] = @[(os_lstat, dir_fd, path, DirEntry[int](None))] - try: - while len(stack) != 0: - rmtree_safe_fd_step(stack, onexc) - finally: - # Close any file descriptors still on the stack. - while len(stack) != 0: - let (fun, fd, path, _) = stack.pop() - if fun is_not os_close: - continue - try: - os.close(fd) - except OSError as err: - onexc(os_close, path, err) -else: - when defined(windows): # hasattr(os.stat_result, 'st_file_attributes'): - proc rmtree_islink(st: stat_result): bool = - return (stat.S_ISLNK(st.st_mode) or - (bool(st.st_file_attributes and stat.FILE_ATTRIBUTE_REPARSE_POINT) and - st.st_reparse_tag == stat.IO_REPARSE_TAG_MOUNT_POINT)) - else: - proc rmtree_islink(st: stat_result): bool = - return stat.S_ISLNK(st.st_mode) - - # _rmtree_unsafe - proc rmtreeImpl[P](path: P, dir_fd: int, onexc) = - when dir_fd is_not NoneType: - static: - raise newException(NotImplementedError, "dir_fd unavailable on this platform") - var st: stat_result - try: - st = os.lstat(path) - except OSError as err: - onexc(os_lstat, path, err) - return - try: - if rmtree_islink(st): - # symlinks to directories are forbidden, see bug #1669 - raise newPyOSError("Cannot call rmtree on a symbolic link") - except OSError as err: - onexc(os_path_islink, path, err) - # can't continue even if onexc hook returns - return - proc onerror(err) = - if not isinstance(err, FileNotFoundError): - onexc(os_scandir, err.filename, err) - results = os.walk(path, topdown=False, onerror=onerror, - followlinks=os.walk_symlinks_as_files) - for (dirpath, dirnames, filenames) in results: - for name in dirnames: - fullname = os.path.join(dirpath, name) - try: - os.rmdir(fullname) - except FileNotFoundError: - continue - except OSError as err: - onexc(os.rmdir, fullname, err) - for name in filenames: - fullname = os.path.join(dirpath, name) - try: - os.unlink(fullname) - except FileNotFoundError: - continue - except OSError as err: - onexc(os.unlink, fullname, err) - try: - os.rmdir(path) - except FileNotFoundError: - pass - except OSError as err: - onexc(os_rmdir, path, err) - - -proc rmtree*(path: string, ignore_errors=false; - onerror: OnExc=nil; # deprecated - onexc: OnExc = nil, - dir_fd = -1 - ) = - sys.audit("shutil.rmtree", path, dir_fd) - template defonexc(body){.dirty.} = - onexc = proc ( - fun: Path1ProcKind, - path: P, - exc: ref OSError - ) = body - var onexc = onexc - if ignore_errors: - def_onexc: pass - - elif onerror is None and onexc is None: - def_onexc: - raise - elif onexc is None: - if onerror is None: - def_onexc: - raise - else: - # delegate to onerror - def_onexc: - #[ - func, path, exc = args - if exc is None: - exc_info = None, None, None - else: - exc_info = type(exc), exc, exc.__traceback__ - ]# - let exc_info = exc - onerror(fun, path, exc_info) - rmtreeImpl(path, dir_fd, onexc) diff --git a/src/pylib/Lib/shutil_impl/sys.nim b/src/pylib/Lib/shutil_impl/sys.nim deleted file mode 100644 index 1ea87a4cf..000000000 --- a/src/pylib/Lib/shutil_impl/sys.nim +++ /dev/null @@ -1,3 +0,0 @@ - -import ../sys_impl/auditImpl -export audit diff --git a/src/pylib/Lib/shutil_impl/terminals.nim b/src/pylib/Lib/shutil_impl/terminals.nim deleted file mode 100644 index 1c852a532..000000000 --- a/src/pylib/Lib/shutil_impl/terminals.nim +++ /dev/null @@ -1,19 +0,0 @@ - -import std/terminal - -# Nim consider it's the same as os.terminal_size, -# as they are both tuple of Nim -type terminal_size = tuple[columns, lines: int] -proc get_terminal_size*(fallback=(80, 24)): terminal_size = - ## .. hint:: this does not simply refer to environment variable, - ## call `os.get_terminal_size`. This is a wrapper around - ## `terminalSize` of `std/terminal`, which is more steady, - ## returning meaningful result even when stdout is not associatd with - ## a terminal. - result.columns = terminalWidth() - if result.columns == 0: - result.columns = fallback[0] - result.lines = terminalHeight() - if result.lines == 0: - result.lines = fallback[1] - diff --git a/src/pylib/Lib/signal.nim b/src/pylib/Lib/signal.nim deleted file mode 100644 index 734663708..000000000 --- a/src/pylib/Lib/signal.nim +++ /dev/null @@ -1,37 +0,0 @@ - -import ./n_signal -import ./signal_impl/valid_signals_impl - -import ../builtins/set -import ../pystring/strimpl -import ./typing_impl/str_optional_obj -expOptObjCvt() -import ../version - -export n_signal except sigpending, pthread_sigmask, strsignal, valid_signals - -import std/macros -macro mayUndef(def) = - let cond = newCall("declared", def.name) - result = nnkWhenStmt.newTree(nnkElifBranch.newTree(cond, def)) - -proc sigpending*(): PySet[int]{.mayUndef.} = newPySet n_signal.sigpending() - -proc pthread_sigmask*(how: int, mask: Sigset): PySet[int]{.mayUndef.} = - newPySet n_signal.pthread_sigmask(how, mask) - - #[ XXX: NIM-BUG: compiler stuck here - import ./signal_impl/sigsetCvt - import ./collections/abc - converter toSigset*(oa: Iterable[int]): Sigset = - ## Py_Sigset_Converter - result.fromIterable oa - ]# - -proc strsignal*(signalnum: int): OptionalObj[PyStr]{.pysince(3,8).} = - newStrOptionalObj n_signal.strsignal signalnum - -when have_valid_signals: - proc valid_signals*(): PySet[int]{.pysince(3,8).} = - result = newPySet[int]() - result.fill_valid_signals() diff --git a/src/pylib/Lib/signal_impl/abc_set.nim b/src/pylib/Lib/signal_impl/abc_set.nim deleted file mode 100644 index 52c440278..000000000 --- a/src/pylib/Lib/signal_impl/abc_set.nim +++ /dev/null @@ -1,6 +0,0 @@ - -import std/sets -proc add*(self: var SomeSet[int], i: int) = self.incl i - -type Set*[T] = concept self - self.add T diff --git a/src/pylib/Lib/signal_impl/c_api.nim b/src/pylib/Lib/signal_impl/c_api.nim deleted file mode 100644 index 3409c402a..000000000 --- a/src/pylib/Lib/signal_impl/c_api.nim +++ /dev/null @@ -1,4 +0,0 @@ - -proc PyErr_CheckSignals*(): int = 0 ## XXX: currently does nothing -proc PyErr_CheckSignalsAndRaises* = discard ## XXX: currently does nothing - diff --git a/src/pylib/Lib/signal_impl/c_py_handler_cvt.nim b/src/pylib/Lib/signal_impl/c_py_handler_cvt.nim deleted file mode 100644 index 4ffc7006e..000000000 --- a/src/pylib/Lib/signal_impl/c_py_handler_cvt.nim +++ /dev/null @@ -1,12 +0,0 @@ - -import ./[pylifecycle, frames] - -proc toCSighandler*(p: PySigHandler): CSigHandler = - proc (signalnum: cint){.noconv.} = - let frame = getFrameOrNil(2) - p(signalnum, frame) - - -proc toPySighandler*(p: CSigHandler|NimSigHandler): PySigHandler = - proc (signalnum: int, _: PFrame){.closure.} = - p(cint signalnum) diff --git a/src/pylib/Lib/signal_impl/chk_util.nim b/src/pylib/Lib/signal_impl/chk_util.nim deleted file mode 100644 index 8c354eabb..000000000 --- a/src/pylib/Lib/signal_impl/chk_util.nim +++ /dev/null @@ -1,6 +0,0 @@ - -import ./pynsig - -func chkSigRng*(signalnum: cint|int) = - if signalnum < 1 or signalnum >= Py_NSIG: - raise newException(ValueError, "signal number out of range") diff --git a/src/pylib/Lib/signal_impl/enums.nim b/src/pylib/Lib/signal_impl/enums.nim deleted file mode 100644 index 638b8e492..000000000 --- a/src/pylib/Lib/signal_impl/enums.nim +++ /dev/null @@ -1,100 +0,0 @@ - -import std/tables -import ./pylifecycle except SigInfo -import ./pynsig -import ../enum_impl/[intEnum, enumType] -import ./enums_decl - -# ITIMER* (not enum) -template Exp(sym) = - when declared(sym): - let sym* = int sym - -Exp ITIMER_REAL -Exp ITIMER_VIRTUAL -Exp ITIMER_PROF - -template genEnum(name) = - GenIntEnumMeth name - GenPyEnumInit(name, int, name) - -# SIG* -genEnum Signals - -template add_enum(E, sym, val) = - let sym* = enums_decl.E.add_member(astToStr(sym), val) - -template add_sig(sym) = - when declared(sym): - when sym != DEF_SIG: - add_enum(Signals, sym, sym) - -when true: # just convenient for code folding - add_sig CTRL_C_EVENT - add_sig CTRL_BREAK_EVENT - - add_sig SIGHUP - add_sig SIGINT - add_sig SIGBREAK - add_sig SIGQUIT - add_sig SIGILL - add_sig SIGTRAP - add_sig SIGIOT - add_sig SIGABRT - add_sig SIGEMT - add_sig SIGFPE - add_sig SIGKILL - add_sig SIGBUS - add_sig SIGSEGV - add_sig SIGSYS - add_sig SIGPIPE - add_sig SIGALRM - add_sig SIGTERM - add_sig SIGUSR1 - add_sig SIGUSR2 - add_sig SIGCLD - add_sig SIGCHLD - add_sig SIGPWR - add_sig SIGIO - add_sig SIGURG - add_sig SIGWINCH - add_sig SIGPOLL - add_sig SIGSTOP - add_sig SIGTSTP - add_sig SIGCONT - add_sig SIGTTIN - add_sig SIGTTOU - add_sig SIGVTALRM - add_sig SIGPROF - add_sig SIGXCPU - add_sig SIGXFSZ - add_sig SIGRTMIN - add_sig SIGRTMAX - add_sig SIGINFO - add_sig SIGSTKFLT - - -# SIG_* -genEnum Handlers - -template add_handler(sym) = - when declared(sym): - add_enum(Handlers, sym, cast[int](sym)) - -add_handler SIG_DFL -add_handler SIG_IGN - - -# Sigmasks -genEnum Sigmasks - -template add_sigmask(sym) = - when declared(sym): - add_enum(Sigmasks, sym, sym) - -when not defined(windows): - add_sigmask SIG_BLOCK - add_sigmask SIG_UNBLOCK - add_sigmask SIG_SETMASK - -export Signals, Handlers, Sigmasks diff --git a/src/pylib/Lib/signal_impl/enums_decl.nim b/src/pylib/Lib/signal_impl/enums_decl.nim deleted file mode 100644 index 58196f871..000000000 --- a/src/pylib/Lib/signal_impl/enums_decl.nim +++ /dev/null @@ -1,7 +0,0 @@ - -template decl(name) = - type name* = distinct int - -decl Signals -decl Handlers -decl Sigmasks diff --git a/src/pylib/Lib/signal_impl/errutil.nim b/src/pylib/Lib/signal_impl/errutil.nim deleted file mode 100644 index 791698476..000000000 --- a/src/pylib/Lib/signal_impl/errutil.nim +++ /dev/null @@ -1,8 +0,0 @@ - -import ../errno_impl/[errnoUtils, errnoConsts] -import ../../pyerrors/[oserr, rterr] - -export errnoUtils, errnoConsts, oserr, KeyboardInterrupt - - - diff --git a/src/pylib/Lib/signal_impl/frames.nim b/src/pylib/Lib/signal_impl/frames.nim deleted file mode 100644 index 7bd6c5ff2..000000000 --- a/src/pylib/Lib/signal_impl/frames.nim +++ /dev/null @@ -1,12 +0,0 @@ - -proc getFrameOrNil*(): PFrame = - when declared(getFrame): getFrame() - else: nil # for JS/nims - - -proc getFrameOrNil*(up: int): PFrame = - when declared(getFrame): - result = getFrame() - for _ in 1..up: - result = result.prev - else: nil # for JS/nims diff --git a/src/pylib/Lib/signal_impl/pyatomic.nim b/src/pylib/Lib/signal_impl/pyatomic.nim deleted file mode 100644 index f9ab83a4a..000000000 --- a/src/pylib/Lib/signal_impl/pyatomic.nim +++ /dev/null @@ -1,14 +0,0 @@ - - -template Py_atomic_load_ptr*[T](obj: ptr T): T = atomicLoadN(obj, ATOMIC_SEQ_CST) -template Py_atomic_store_ptr*[T](obj: ptr T, value: T) = atomicStoreN(obj, value, ATOMIC_SEQ_CST) - -template Py_atomic_load*[T](obj: T): T = - bind Py_atomic_load_ptr - Py_atomic_load_ptr(obj.addr) - - -template Py_atomic_store*[T](obj: T, value: T) = - bind Py_atomic_store_ptr - Py_atomic_store_ptr(obj.addr, value) - diff --git a/src/pylib/Lib/signal_impl/pylifecycle.nim b/src/pylib/Lib/signal_impl/pylifecycle.nim deleted file mode 100644 index 48a52d297..000000000 --- a/src/pylib/Lib/signal_impl/pylifecycle.nim +++ /dev/null @@ -1,4 +0,0 @@ - -import ../../Python/pylifecycle/signal -import ../../Python/pylifecycle/signal/[c_syms, chk_util] -export signal, c_syms, chk_util diff --git a/src/pylib/Lib/signal_impl/pynsig.nim b/src/pylib/Lib/signal_impl/pynsig.nim deleted file mode 100644 index 49d117672..000000000 --- a/src/pylib/Lib/signal_impl/pynsig.nim +++ /dev/null @@ -1,2 +0,0 @@ -import ../../pyconfig/signal -export signal diff --git a/src/pylib/Lib/signal_impl/siginfo_decl.nim b/src/pylib/Lib/signal_impl/siginfo_decl.nim deleted file mode 100644 index 2f519248a..000000000 --- a/src/pylib/Lib/signal_impl/siginfo_decl.nim +++ /dev/null @@ -1,20 +0,0 @@ - -import ./pylifecycle - -type struct_siginfo* = ref object - a: SigInfo - -template getter(field){.dirty.} = - proc field*(self: struct_siginfo): auto = self.a.field - -getter si_signo -getter si_code -getter si_errno -getter si_pid -getter si_uid -#getter si_addr -getter si_status -getter si_band -#getter si_value - -proc fill_siginfo*(si: SigInfo): struct_siginfo = struct_siginfo(a: si) diff --git a/src/pylib/Lib/signal_impl/signal_util.nim b/src/pylib/Lib/signal_impl/signal_util.nim deleted file mode 100644 index 92f00edf2..000000000 --- a/src/pylib/Lib/signal_impl/signal_util.nim +++ /dev/null @@ -1,71 +0,0 @@ -import ../../private/iph_utils -import ../../pyconfig/ver -import ./siginfo_decl -import ./[state, chk_util, pylifecycle, pynsig, c_api] - -when HAVE_STRSIGNAL: - import ./errutil - proc strsignal(signalnum: cint): cstring {.importc, header: "".} - - proc strstr(s, subs: cstring): ptr char{.importc, header: "".} - -proc getsignal*(signalnum: int): PySigHandler = - signalnum.chkSigRng - result = get_handler(cast[cint](signalnum)) - -proc strsignal*(signalnum: int): string = - ## returns empty string over `None` - signalnum.chkSigRng - let signalnum = cast[cint](signalnum) - when HAVE_STRSIGNAL: - setErrno0() - let res = strsignal(signalnum) - - if getErrno() != 0 or res.isNil or - not strstr(res, "Unknown signal").isNil: - return - - result = $res - else: - # Though being a UNIX, HP-UX does not provide strsignal(3). - const DEF = "" - result = case signalnum: - of SIGINT: "Interrupt" - of SIGILL: "Illegal instruction" - of SIGABRT: "Aborted" - of SIGFPE: "Float-point exception" - of SIGSEGV: "Segmentation fault" - of SIGTERM: "Terminated" - elif not defined(windows): - case signalnum - of SIGHUP: "Hangup" - of SIGALRM: "Alarm clock" - of SIGPIPE: "Broken pipe" - of SIGQUIT: "Quit" - of SIGCHLD: "Child exited" - else: DEF - else: DEF - - -proc c_raise*(signalnum: cint): cint {.importc: "raise", header: "".} - -proc raise_signal*(signalnum: int) = - let signalnum = cast[cint](signalnum) - var err: cint - with_Py_SUPPRESS_IPH: - err = c_raise(signalnum) - if err != 0: - raiseErrno() - PyErr_CheckSignalsAndRaises() - -when defined(linux) and not ( - defined(android) and ANDROID_API < 31): - proc syscall(sysno: cint): cint {.varargs, importc: "syscall", header: "".} - let NR_pidfd_send_signal{.importc: "__NR_pidfd_send_signal", header: "".}: cint - # SYS_pidfd_send_signal is its newer name - proc pidfd_send_signal*(pid: int, sig: int, - siginfo: struct_siginfo = nil, flags = 0) = - let pid = cint(pid) - let sig = cint(sig) - if syscall(NR_pidfd_send_signal, pid, sig, nil, flags) < 0: - raiseErrno() diff --git a/src/pylib/Lib/signal_impl/signals.nim b/src/pylib/Lib/signal_impl/signals.nim deleted file mode 100644 index 770dfbb36..000000000 --- a/src/pylib/Lib/signal_impl/signals.nim +++ /dev/null @@ -1,105 +0,0 @@ - -import ./[pynsig, errutil, state, chk_util, pylifecycle, c_py_handler_cvt, frames] -import ./pyatomic - -import ./enums -template toPySigHandler(handler: Handlers): PySigHandler = - toPySigHandler( - if handler == enums.SIG_DFL: - pylifecycle.SIG_DFL - else: # handler == enums.SIG_IGN: - pylifecycle.SIG_IGN - ) - -proc trip_signal(sig_num: cint){.inline.} = - Py_atomic_store(Handlers[sig_num].tripped, true) - - # CPython has to handle Exeption in C level - # but here we're in Nim, so no need - - # We minic `_PyErr_CheckSignalsTstate` here - assert not Handlers[sig_num].fn.isNil - Handlers[sig_num].fn(sig_num, getFrameOrNil(2)) - - -proc signal_handler(sig_num: cint){.noconv.} = - let save_errno = getErrno() - - trip_signal(sig_num) - - when not HAVE_SIGACTION: - #[To avoid infinite recursion, this signal remains - reset until explicit re-instated. - Don't clear the 'func' field as it is our pointer - to the Python handler...]# - when declared(SIGCHLD): - #[If the handler was not set up with sigaction, reinstall it. - See Python/pylifecycle.c for the implementation of PyOS_setsig - which makes this true. See also issue8354.]# - if sig_num != SIGCHLD: - PyOS_setsig(sig_num, signal_handler) - else: - PyOS_setsig(sig_num, signal_handler) - - #[Issue #10311: asynchronously executing signal handlers should not - mutate errno under the feet of unsuspecting C code.]# - setErrnoRaw save_errno - - when DWin: - if sig_num == SIGINT: - setEvent(global_sigint_event) - - - -proc signal*(signalnum: int, handler: PySigHandler): PySigHandler{.discardable.} = - let signalnum = signalnum.cint - signalnum.ifInvalidOnVcc: - raise newException(ValueError, "invalid signal value") - - chkSigRng signalnum - - let fn = signal_handler - - if PyOS_setsig(signalnum, fn) == SIG_ERR: - raiseErrno() - - result = get_handler(signalnum) - set_handler(signalnum, handler) - -proc signal*(signalnum: int, handler: CSigHandler|NimSigHandler|Handlers -): PySigHandler{.discardable.} = - signal(signalnum, handler.toPySighandler) - - -proc default_int_handler*(signalnum: int, frame: PFrame) = - raise newException(KeyboardInterrupt, "") - -proc signal_get_set_handlers(state: signal_state_t) = - for signum in cint(1)..= Py_NSIG: - if overflow or signum != -1: - raise newException(ValueError, - "signal number $# out of range [1; $#]".format( - signum, Py_NSIG - 1) - ) - #error - if sigaddset(result, signum) != 0: - if isErr EINVAL: - # Probably impossible - raiseErrno() - #[For backwards compatibility, allow idioms such as - `range(1, NSIG)` but warn about invalid signal numbers]# - warn("invalid signal number $#, please use valid_signals()".format(signum), RuntimeWarning, 1) diff --git a/src/pylib/Lib/signal_impl/sigset_to_set.nim b/src/pylib/Lib/signal_impl/sigset_to_set.nim deleted file mode 100644 index 45bb00cd0..000000000 --- a/src/pylib/Lib/signal_impl/sigset_to_set.nim +++ /dev/null @@ -1,20 +0,0 @@ - - -import std/sets -import ./[pynsig, pylifecycle, abc_set] - -proc add_sigset*(res: var Set[int], mask: var Sigset) = - for sig in cint(1)..= (2, 1, 1): - ## XXX: FIXED-NIM-BUG: though nimAllowNonVarDestructor is defined at least since 2.0.6, - ## it still cannot be compiled till abour 2.1.1 - using destSelf: signal_state_t -else: - using destSelf: var signal_state_t - -proc PySignal_Fini(destSelf) = - for signum in cint(1) ..< Py_NSIG.cint: - let fn = get_handler(signum) - Py_atomic_store(Handlers[signum].tripped, false) - set_handler(signum, nil) - if not fn.isNil and fn != destSelf.default_handler and - fn != destSelf.ignore_handler: - discard PyOS_setsig(signum, SIG_DFL) - when DWin: - if destSelf.sigint_event != Handle(0): - discard closeHandle(destSelf.sigint_event) - -proc PySignal_Fini*() = PySignal_Fini state - -proc `=destroy`(destSelf) = - PySignal_Fini(destSelf) - deinitLock lock diff --git a/src/pylib/Lib/signal_impl/unixs.nim b/src/pylib/Lib/signal_impl/unixs.nim deleted file mode 100644 index 89d487de9..000000000 --- a/src/pylib/Lib/signal_impl/unixs.nim +++ /dev/null @@ -1,182 +0,0 @@ - -import std/sets -import std/macros -import ./[ - errutil, - c_api, - chk_util, - pylifecycle, - siginfo_decl -] -import ../sys_impl/auditImpl as sys -when HAVE_SIGSET_T: - import ./[ - sigsetCvt, - sigset_to_set, - ] - export Sigset - converter toSigset*(oa: openArray[int]): Sigset = result.fromIterable oa - -export siginfo_decl except fill_siginfo -import ../../Python/pytime/[deadline, pytimeFromSeconds, pytimeAsTimeval] - -proc mayUndefImpl(def: NimNode): NimNode = - let cond = ident "HAVE_" & def.name.strVal - result = nnkWhenStmt.newTree(nnkElifBranch.newTree(cond, def)) -macro mayUndef(def) = mayUndefImpl(def) -macro mayUndefs(defs) = - result = newStmtList() - for def in defs: - result.add mayUndefimpl(def) - -mayUndefs: - proc alarm*(seconds: int): int = int alarm seconds.cint - proc pause*(): int = int posix.pause() - - proc pthread_kill*(thread_id: uint, signalnum: int) = - sys.audit("signal.pthread_kill", thread_id, signalnum) - let err = pthread_kill(Pthread thread_id, cint signalnum) - if err != 0: - raiseErrno() - - PyErr_CheckSignalsAndRaises() - -type - Set[T] = HashSet[T] - - -template markVar(sym) = - var sym = sym - -proc pthread_sigmask*(how: int, mask: Sigset): Set[int]{.mayUndef.} = - var previous: Sigset - markVar mask - let err = pthread_sigmask(how.cint, mask, previous) - if err != 0: - raiseErrno err - PyErr_CheckSignalsAndRaises() - sigset_to_set(previous) - -type ItimerError* = object of PyOSError - -when HAVE_SETITIMER or HAVE_GETITIMER: - type ItimerVal*{.importc: "struct itimerval", header: "".} = object - it_interval, it_value: Timeval - type ItimerWhich = cint # enum - func toFloat(tv: Timeval): float = - tv.tv_sec.float + tv.tv_usec.float / 1_000_000.0 - - proc itimer_retval(old: ItimerVal): tuple[delay, interval: float] = - (old.it_value.toFloat, old.it_interval.toFloat) - - -when HAVE_SETITIMER: - proc setitimer(which: ItimerWhich, `new`, old: ItimerVal): cint {.importc, header: "".} - proc toTimeval(obj: float): Timeval = - ## timeval_from_double - var t: PyTime - t.fromSecondsObject(obj, prCeiling) - t.asTimeval(prCeiling) - - - proc setitimer*(which: int, seconds: float; interval=0.0): tuple[delay, interval: float] = - var n: ItimerVal - n.it_value = seconds.toTimeval - n.it_interval = interval.toTimeval - var old: ItimerVal - if setitimer(which.cint, n, old) != 0: - raiseErrnoT[ItimerError]() - itimer_retval old - -when HAVE_GETITIMER: - proc getitimer(which: ItimerWhich, old: ItimerVal): cint {.importc, header: "".} - proc getitimer*(which: int): tuple[delay, interval: float] = - var old: ItimerVal - if getitimer(which.cint, old) != 0: - raiseErrnoT[ItimerError]() - - itimer_retval old - - -proc siginterrupt*(signalnum, flag: int){.mayUndef.} = - let csignalnum = cint signalnum - csignalnum.chkSigRng - when HAVE_SIGACTION: - var act: Sigaction - discard sigaction(csignalnum, nil, act) - if flag != 0: - act.sa_flags = act.sa_flags and not SA_RESTART - else: - act.sa_flags = act.sa_flags or SA_RESTART - if sigaction(csignalnum, act, nil) < 0: - raiseErrno() - else: - if siginterrupt(csignalnum, flag.cint) < 0: - raiseErrno() - - -proc sigpending*(): Set[int]{.mayUndef.} = - var mask: Sigset - if 0 != sigpending(mask): - raiseErrno() - sigset_to_set mask - -proc sigwait*(sigset: Sigset): int{.mayUndef.} = - var signum: cint - markVar sigset - let err = sigwait(sigset, signum) - if err != 0: - raiseErrno err - -proc sigwaitinfo*(sigset: Sigset): struct_siginfo{.mayUndef.} = - var err: cint - var si: SigInfo - var async_err = 0 - markVar sigset - while true: - err = sigwaitinfo(sigset, si) - if err == -1 and isErr(EINTR) and ( - (async_err = PyErr_CheckSignals(); async_err == 0) - ): - continue - break - if err == -1: - #if async_err == 0: - raiseErrno() - - fill_siginfo(si) - -proc PyTime_AsTimespec(x: TimeStamp): Timespec = - x.nPyTime_ObjectToTimeval(result.tv_sec, result.tv_usec, prCeiling) - -proc sigtimedwait*(sigset: Sigset, timeout: TimeStamp): struct_siginfo{.mayUndef.} = - var si: SigInfo - markVar sigset - var to: PyTime - to.fromSecondsObject(timeout, prCeiling) - if to < 0: - raise newException(ValueError, "timeout must be non-negative") - - let deadline = PyDeadline_Init(to) - var si: SigInfo - - while true: - var ts = PyTime_AsTimespec timeout - let res = sigtimedwait(sigset, si, ts) - - if res != -1: - break - - if not isErr EINTR: - if isErr ERANGE: - return - raiseErrno() - - # sigtimedwait() was interrupted by a signal (EINTR) - PyErr_CheckSignalsAndRaises() - - timeout = PyDeadline_Get(deadline) - if timeout < 0: - break - - fill_siginfo(si) diff --git a/src/pylib/Lib/signal_impl/valid_signals_impl.nim b/src/pylib/Lib/signal_impl/valid_signals_impl.nim deleted file mode 100644 index 945e5b0c4..000000000 --- a/src/pylib/Lib/signal_impl/valid_signals_impl.nim +++ /dev/null @@ -1,17 +0,0 @@ - -import ./[pylifecycle, sigset_to_set, errutil, abc_set] - -const have_valid_signals* = defined(windows) or HAVE_SIGFILLSET and HAVE_SIGSET_T -when have_valid_signals: - proc fill_valid_signals*(res: var Set[int]) = - when defined(windows): - for i in [SIGABRT, SIGFPE, - SIGILL, SIGINT, SIGSEGV, SIGTERM]: - res.add int i - when declared(SIGBREAK): - res.add int SIGBREAK - else: - var mask: SigSet - if sigemptyset(mask) != 0 or sigfillset(mask) != 0: - raiseErrno() - res.add_sigset mask diff --git a/src/pylib/Lib/stat.nim b/src/pylib/Lib/stat.nim deleted file mode 100644 index 693864388..000000000 --- a/src/pylib/Lib/stat.nim +++ /dev/null @@ -1,12 +0,0 @@ - -import ./n_stat -import ./stat_impl/types - -export n_stat except filemode - -import ../pystring/strimpl -import ../version - -proc filemode*(omode: int|Mode): PyStr{.pysince(3,3).} = - str n_stat.filemode(omode) - diff --git a/src/pylib/Lib/stat_impl/consts.nim b/src/pylib/Lib/stat_impl/consts.nim deleted file mode 100644 index 4b1a81ec1..000000000 --- a/src/pylib/Lib/stat_impl/consts.nim +++ /dev/null @@ -1,144 +0,0 @@ - - -import ./defines -import ../../pyconfig/util - - -template genIntImpl(name, cname; defval: int, header = SYS_STAT_H) = - const name = from_c_int(cname, defval, header) - -template genInt(name; defval: int, header = SYS_STAT_H) = - genIntImpl(name, name, defval, header) - export name - -when DW: - genInt FILE_ATTRIBUTE_INTEGRITY_STREAM, 0x8000, WINNT_H - genInt FILE_ATTRIBUTE_NO_SCRUB_DATA, 0x20000, WINNT_H - genInt IO_REPARSE_TAG_APPEXECLINK, 0x8000001B, WINNT_H - -const S_IMODE_val*{.intdefine: "S_IMODE".} = 0o7777 - -#[S_IFXXX constants (file types) - -Only the names are defined by POSIX but not their value. All common file -types seems to have the same numeric value on all platforms, though. - -pyport.h guarantees S_IFMT, S_IFDIR, S_IFCHR, S_IFREG and S_IFLNK]# - -# File type constants - -genIntImpl S_IFMT_val, S_IFMT, 0o170000 # File type mask -export S_IFMT_val -genInt S_IFDIR, 0o040000 # Directory -genInt S_IFCHR, 0o020000 # Character device -genInt S_IFBLK, 0o060000 # Block device -genInt S_IFREG, 0o100000 # Regular file -genInt S_IFIFO, 0o010000 # FIFO -genInt S_IFLNK, 0o120000 # Symbolic link -genInt S_IFSOCK, 0o140000 # Socket -genInt S_IFDOOR, 0 # Door -genInt S_IFPORT, 0 # Event port -genInt S_IFWHT, 0 # Whiteout - - -# S_I* file permission -# The permission bits value are defined by POSIX standards. - -# Permission bits -genInt S_ISUID, 0o4000 # Set UID -genInt S_ISGID, 0o2000 # Set GID -genInt S_ENFMT, S_ISGID # File locking enforcement -genInt S_ISVTX, 0o1000 # Sticky bit -genInt S_IREAD, 0o0400 # Read by owner -genInt S_IWRITE, 0o0200 # Write by owner -genInt S_IEXEC, 0o0100 # Execute by owner -genInt S_IRWXU, 0o0700 # Owner mask -genInt S_IRUSR, 0o0400 # Read by owner -genInt S_IWUSR, 0o0200 # Write by owner -genInt S_IXUSR, 0o0100 # Execute by owner -genInt S_IRWXG, 0o0070 # Group mask -genInt S_IRGRP, 0o0040 # Read by group -genInt S_IWGRP, 0o0020 # Write by group -genInt S_IXGRP, 0o0010 # Execute by group -genInt S_IRWXO, 0o0007 # Others mask -genInt S_IROTH, 0o0004 # Read by others -genInt S_IWOTH, 0o0002 # Write by others -genInt S_IXOTH, 0o0001 # Execute by others - -# File flags -genInt UF_SETTABLE, 0x0000ffff -genInt UF_NODUMP, 0x00000001 -genInt UF_IMMUTABLE, 0x00000002 -genInt UF_APPEND, 0x00000004 -genInt UF_OPAQUE, 0x00000008 -genInt UF_NOUNLINK, 0x00000010 -genInt UF_COMPRESSED, 0x00000020 -genInt UF_TRACKED, 0x00000040 -genInt UF_DATAVAULT, 0x00000080 -genInt UF_HIDDEN, 0x00008000 -when not APPLE: - genInt SF_SETTABLE, 0xffff0000 -genInt SF_ARCHIVED, 0x00010000 -genInt SF_IMMUTABLE, 0x00020000 -genInt SF_APPEND, 0x00040000 -genInt SF_NOUNLINK, 0x00100000 -genInt SF_SNAPSHOT, 0x00200000 -genInt SF_FIRMLINK, 0x00800000 -genInt SF_DATALESS, 0x40000000 - -when APPLE: - #[On older macOS versions the definition of SF_SUPPORTED is different -from that on newer versions. - * -Provide a consistent experience by redefining. - * -None of bit bits set in the actual SF_SUPPORTED but not in this -definition are defined on these versions of macOS.]# - const invSup = int.high - genIntImpl tSF_SUPPORTED, SF_SUPPORTED, invSup - when tSF_SUPPORTED != invSup: # :c:`defined(SF_SUPPORTED)` - const SF_SUPPORTED* = tSF_SUPPORTED - template addIntIfDefined(name) = - genIntImpl name, name, invSup - when name != invSup: - export name - addIntIfDefined SF_SETTABLE - addIntIfDefined SF_SYNTHETIC - else: - const - SF_SUPPORTED* = 0x009f0000 - SF_SETTABLE* = 0x3fff0000 - SF_SYNTHETIC* = 0xc0000000 - - -#const stat_filemode_doc = "Convert a file's mode to a string of the form '-rwxrwxrwx'" - -when DW: - import ../os_impl/util/mywinlean - template exp(name) = - export name - template impExp(name) = - let name*{.importc: astToStr(name), header: WINNT_H.}: DWORD - # Add Windows-specific constants - # the following commented out constants are defined above. - impExp(FILE_ATTRIBUTE_ARCHIVE) - impExp(FILE_ATTRIBUTE_COMPRESSED) - impExp(FILE_ATTRIBUTE_DEVICE) - exp(FILE_ATTRIBUTE_DIRECTORY) - impExp(FILE_ATTRIBUTE_ENCRYPTED) - impExp(FILE_ATTRIBUTE_HIDDEN) - #impExp(FILE_ATTRIBUTE_INTEGRITY_STREAM) - impExp(FILE_ATTRIBUTE_NORMAL) - impExp(FILE_ATTRIBUTE_NOT_CONTENT_INDEXED) - #impExp(FILE_ATTRIBUTE_NO_SCRUB_DATA) - impExp(FILE_ATTRIBUTE_OFFLINE) - exp(FILE_ATTRIBUTE_READONLY) - exp(FILE_ATTRIBUTE_REPARSE_POINT) - impExp(FILE_ATTRIBUTE_SPARSE_FILE) - impExp(FILE_ATTRIBUTE_SYSTEM) - impExp(FILE_ATTRIBUTE_TEMPORARY) - impExp(FILE_ATTRIBUTE_VIRTUAL) - - exp(IO_REPARSE_TAG_SYMLINK) - exp(IO_REPARSE_TAG_MOUNT_POINT) - #impExp(IO_REPARSE_TAG_APPEXECLINK) diff --git a/src/pylib/Lib/stat_impl/defines.nim b/src/pylib/Lib/stat_impl/defines.nim deleted file mode 100644 index 7a9cfd207..000000000 --- a/src/pylib/Lib/stat_impl/defines.nim +++ /dev/null @@ -1,10 +0,0 @@ - -const - DW* = defined(windows) - APPLE* = defined(macosx) -const - SYS_STAT_H* = "" - - -when DW: - const WINNT_H* = "" diff --git a/src/pylib/Lib/stat_impl/isX.nim b/src/pylib/Lib/stat_impl/isX.nim deleted file mode 100644 index d0fe53053..000000000 --- a/src/pylib/Lib/stat_impl/isX.nim +++ /dev/null @@ -1,36 +0,0 @@ - -import ./isXImpl -import ./[consts, types] - -template makeSIsFuncTemplate(name: untyped) {.dirty.} = - export isXImpl.`S_IS name` - proc `S_IS name`*(omode: int): bool = - `S_IS name` int_AsMode_t(omode) - -# Generate S_IS* functions -makeSIsFuncTemplate(DIR) -makeSIsFuncTemplate(CHR) -makeSIsFuncTemplate(BLK) -makeSIsFuncTemplate(REG) -makeSIsFuncTemplate(FIFO) -makeSIsFuncTemplate(LNK) -makeSIsFuncTemplate(SOCK) -makeSIsFuncTemplate(DOOR) -makeSIsFuncTemplate(PORT) -makeSIsFuncTemplate(WHT) - - -proc S_IMODE*(omode: Mode): int = - int(omode and S_IMODE_val) -proc S_IMODE*(omode: int): int = - S_IMODE(int_AsMode_t(omode)) - -# const stat_S_IMODE_doc = "Return the portion of the file's mode that can be set by os.chmod()." - -proc S_IFMT*(omode: Mode): int = - int(omode and Mode S_IFMT_val) - -proc S_IFMT*(omode: int): int = - S_IFMT(int_AsMode_t(omode)) - -# const stat_S_IFMT_doc = "Return the portion of the file's mode that describes the file type." diff --git a/src/pylib/Lib/stat_impl/isXImpl.nim b/src/pylib/Lib/stat_impl/isXImpl.nim deleted file mode 100644 index 5578fcee2..000000000 --- a/src/pylib/Lib/stat_impl/isXImpl.nim +++ /dev/null @@ -1,26 +0,0 @@ - - -import ./[types, defines] - -proc int_AsMode_t*(value: int): Mode = - if value == typeof(value).high: - return Mode.high - result = Mode(value) - -template impChk(name) = - proc `c name`(mode: Mode): cint{.importc: astToStr(name), header: SYS_STAT_H.} - template `name`*(mode: Mode): bool = `c name`(mode) != 0 - -impChk S_ISDIR -impChk S_ISCHR -impChk S_ISREG - -impChk S_ISBLK -impChk S_ISFIFO -impChk S_ISLNK -impChk S_ISSOCK - - -template S_ISDOOR*(mode: Mode): bool = false -template S_ISPORT*(mode: Mode): bool = false -template S_ISWHT*(mode: Mode): bool = false diff --git a/src/pylib/Lib/stat_impl/strrepr.nim b/src/pylib/Lib/stat_impl/strrepr.nim deleted file mode 100644 index 5af7e7cf9..000000000 --- a/src/pylib/Lib/stat_impl/strrepr.nim +++ /dev/null @@ -1,46 +0,0 @@ - -import ./[consts, types, isXImpl] - -proc filetype(mode: Mode): char = - if S_ISREG(mode): '-' - elif S_ISDIR(mode): 'd' - elif S_ISLNK(mode): 'l' - elif S_ISBLK(mode): 'b' - elif S_ISCHR(mode): 'c' - elif S_ISFIFO(mode): 'p' - elif S_ISSOCK(mode): 's' - elif S_ISDOOR(mode): 'D' - elif S_ISPORT(mode): 'P' - elif S_ISWHT(mode): 'w' - else: '?' - -proc fileperm[start: static[int]](mode: Mode, buf: var (array[start+9, char]|string)) = - let mode = int(mode) - buf[start] = if (mode and S_IRUSR) != 0: 'r' else: '-' - buf[start+1] = if (mode and S_IWUSR) != 0: 'w' else: '-' - buf[start+2] = if (mode and S_ISUID) != 0: - if (mode and S_IXUSR) != 0: 's' else: 'S' - else: - if (mode and S_IXUSR) != 0: 'x' else: '-' - buf[start+3] = if (mode and S_IRGRP) != 0: 'r' else: '-' - buf[start+4] = if (mode and S_IWGRP) != 0: 'w' else: '-' - buf[start+5] = if (mode and S_ISGID) != 0: - if (mode and S_IXGRP) != 0: 's' else: 'S' - else: - if (mode and S_IXGRP) != 0: 'x' else: '-' - buf[start+6] = if (mode and S_IROTH) != 0: 'r' else: '-' - buf[start+7] = if (mode and S_IWOTH) != 0: 'w' else: '-' - buf[start+8] = if (mode and S_ISVTX) != 0: - if (mode and S_IXOTH) != 0: 't' else: 'T' - else: - if (mode and S_IXOTH) != 0: 'x' else: '-' - -proc filemode*(omode: Mode): string = - #var buf: array[10, char] - var buf = newString(10) - buf[0] = filetype(omode) - fileperm[1](omode, buf) - result = buf - -proc filemode*(omode: int): string = - filemode(int_AsMode_t(omode)) diff --git a/src/pylib/Lib/stat_impl/types.nim b/src/pylib/Lib/stat_impl/types.nim deleted file mode 100644 index 40ed6a0d8..000000000 --- a/src/pylib/Lib/stat_impl/types.nim +++ /dev/null @@ -1,6 +0,0 @@ - -when defined(windows): - type Mode = cushort -else: - from std/posix import Mode -export Mode diff --git a/src/pylib/Lib/string.nim b/src/pylib/Lib/string.nim deleted file mode 100644 index 28d444baa..000000000 --- a/src/pylib/Lib/string.nim +++ /dev/null @@ -1,64 +0,0 @@ - -import std/macros -import std/tables -import ../pystring -import ../noneType -import ../builtins/[dict, list] -export pystring, list -import ./collections/abc - -import ../version - -import ./n_string -import string_impl/[ - templateImpl -] -export Template, delimiter - -template expStr(sym) = - const sym* = str n_string.sym - -expStr ascii_lowercase -expStr ascii_uppercase -expStr ascii_letters -expStr digits -expStr hexdigits -expStr octdigits -expStr punctuation -expStr whitespace -expStr printable - - -genCapwords StringLike, PyStr, - pystring.split, pystring.split, pystring.capitalize, pystring.strip - -proc capwords*(a: StringLike; _: NoneType): PyStr = capwords(a) - -template genToTab(M){.dirty.} = - proc toTable[K, V](ls: M[K, V]): Table[K, V] = - ## .. note:: we use `string` as value type internally anyway. - result = initTable[K, V](ls.len) - for (k, v) in ls.items(): - result[k] = v - -when not defined(js): - genToTab Mapping -else: - #[ XXX: NIM-BUG: Error: internal error: genTypeInfo(tyInferred) - compiler/jstypes.nim(135) genTypeInfo - context: - p.prc.name.s = toTable - typ[i] = PyStr - ]# - genToTab PyDict - -genSubstitute(Mapping, PyStr, substitute, initRaisesExcHandle) -genSubstitute(Mapping, PyStr, safe_substitute, initIgnoreExcHandle) - -wrapExportSincePy(3,11, is_valid) - -proc get_identifiers*(templ: Template): PyList[PyStr]{.pysince(3,11).} = - result = newPyList[PyStr]() - for i in get_identifiersMayDup(templ): - if i not_in result: - result.append i diff --git a/src/pylib/Lib/string_impl/capwordsImpl.nim b/src/pylib/Lib/string_impl/capwordsImpl.nim deleted file mode 100644 index f9af32e80..000000000 --- a/src/pylib/Lib/string_impl/capwordsImpl.nim +++ /dev/null @@ -1,29 +0,0 @@ - - -template genCapwords*(Arg, Res, split, split2, capitalize, strip){.dirty.} = - func capwords*(a: Arg): Res = - ## Mimics Python string.capwords(s) -> str: - ## - ## Runs of whitespace characters are replaced by a single space - ## and leading and trailing whitespace are removed. - var res = newStringOfCap (when compiles(a.byteLen): a.byteLen else: a.len) - for word in split(a): - res.add capitalize(word) - res.add ' ' - res = strip(res) - res - - - func capwords*(a: Arg, sep: Arg): Res = - ## Mimics Python string.capwords(s, sep) -> str: - ## - ## Split the argument into words using split, capitalize each - ## word using `capitalize`, and join the capitalized words using - ## `join`. `sep` is used to split and join the words. - let ssep = $sep - var res = newStringOfCap (when compiles(a.byteLen): a.byteLen else: a.len) - for word in split2(a, ssep): - res.add capitalize(word) - res.add ssep - res.setLen res.len - ssep.len - res diff --git a/src/pylib/Lib/string_impl/consts.nim b/src/pylib/Lib/string_impl/consts.nim deleted file mode 100644 index 244edcf99..000000000 --- a/src/pylib/Lib/string_impl/consts.nim +++ /dev/null @@ -1,12 +0,0 @@ - - -const - ascii_lowercase* = "abcdefghijklmnopqrstuvwxyz" - ascii_uppercase* = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - ascii_letters* = ascii_lowercase & ascii_uppercase - digits* = "0123456789" - hexdigits* = "0123456789abcdefABCDEF" - octdigits* = "01234567" - punctuation* = """!"#$%&\'()*+,-./:;<=>?@[\\]^_`{|}~""" - whitespace* = " \t\n\r\x0b\x0c" - printable* = digits & ascii_letters & punctuation & whitespace diff --git a/src/pylib/Lib/string_impl/n_chainmap.nim b/src/pylib/Lib/string_impl/n_chainmap.nim deleted file mode 100644 index 427595214..000000000 --- a/src/pylib/Lib/string_impl/n_chainmap.nim +++ /dev/null @@ -1,16 +0,0 @@ -## a ChainMap version accepting 2 Tables -import std/tables - -type - ChainMap*[K, V] = object - a, b: Table[K, V] - -proc initChainMap*[K, V](a, b: Table[K, V]): ChainMap[K, V] = - ChainMap[K, V](a: a, b: b) - -proc `[]`*[K, V](self: ChainMap[K, V], k: K): V = - if self.a.hasKey(k): self.a[k] - else: self.b[k] - -proc contains*[K, V](self: ChainMap[K, V], k: K): bool = - self.a.contains(k) or self.b.contains(k) diff --git a/src/pylib/Lib/string_impl/substituteImpl.nim b/src/pylib/Lib/string_impl/substituteImpl.nim deleted file mode 100644 index 5327b4316..000000000 --- a/src/pylib/Lib/string_impl/substituteImpl.nim +++ /dev/null @@ -1,148 +0,0 @@ - -import std/strutils -import std/options -from std/tables import contains -import ./n_chainmap -export n_chainmap.`[]`, n_chainmap.contains - -template splitlines(a; keepends = false): untyped = - a.splitLines(keepEol = keepends) - -proc lenSumExceptLast(a: openArray[string]): int = - for i in a.toOpenArray(0, a.high - 1): - result += i.len - -proc invalidFormatString(formatstr: string, i: int) = - let - lines = formatStr[0..^i].splitlines(keepends=true) - (colno, lineno) = - if lines.len == 0: (1, 1) - else: (i - lenSumExceptLast(lines), len(lines)) - raise newException(ValueError, - "Invalid placeholder in string: line " & $lineno & - ", col " & $colno - ) - -proc raiseKeyError(key: string) = - raise newException(KeyError, $key) - -const - Delimiter* = '$' - Braces = (start:'{', stop:'}') - -type ExcHandle = ref object of RootObj - hasExc*: bool -using self: ExcHandle -proc flagExc(self) = self.hasExc = true -method invalidKey(self; key: string){.base.} = self.flagExc -method invalidFormatString(self; formatstr: string, idx: int){.base.} = self.flagExc - -type RaisesExcHandle = ref object of ExcHandle -using self: RaisesExcHandle -method invalidKey(self; key: string) = self.flagExc; raiseKeyError(key) -method invalidFormatString(self; formatstr: string, idx: int) = - self.flagExc - invalidFormatString(formatstr, idx) - -proc initIgnoreExcHandle*: ExcHandle = ExcHandle() -proc initRaisesExcHandle*: ExcHandle = RaisesExcHandle() - -type - SubsCfg* = ref object of RootObj - ## for `is_valid()` - delimiter*: char - excHandle*: ExcHandle -using self: SubsCfg -template noop = discard -method addSnippet(self; s: string){.base.} = noop() -proc addSnippet(self; c: char) = self.addSnippet $c ## XXX: impr-me -template nolookup[M](self; a: M; key: string; hasBrace: static[bool]) = noop() - -type Subs* = ref object of SubsCfg - ## for `substitute()` - res: string -using self: Subs -#proc `$`(self): string = self.res -method addSnippet(self; s: string) = self.res.add s -proc lookup[M](self; a: M; key: string; hasBrace: static[bool]) = - if key in a: - self.res.add: - when compiles(str(a[key])): $str(a[key]) - else: $a[key] - else: - self.excHandle.invalidKey(key) - self.addSnippet self.delimiter - when hasBrace: self.addSnippet Braces.start - self.addSnippet key - when hasBrace: self.addSnippet Braces.stop - -type GetIdent* = ref object of SubsCfg - ## for `get_identifiers()` - ## excHandle shall ignore ValueError, too -using self: GetIdent -method addSnippet(self; s: string) = discard -template nolookupButAdd(self; _: auto; key: string; _: static[bool]) = - yield key - -proc resetSubsCfg*(cfg: SubsCfg; excHandle = initRaisesExcHandle(), delimiter = Delimiter) = - cfg.excHandle = excHandle - cfg.delimiter = delimiter - -proc initSubsCfg*(excHandle = initRaisesExcHandle(), delimiter = Delimiter): SubsCfg = - result.resetSubsCfg(excHandle, delimiter) - -template handle*[M](s: SubsCfg, formatstr: string, m: M; - lookup#[: proc(self: SubsCfg; a: M; key: string; hasBrace: static[bool])]#) = - ## .. note:: this differs Nim's std/strutils `%` - const - PatternStartChars = {'a'..'z', 'A'..'Z', '\128'..'\255', '_'} - PatternChars = PatternStartChars + { '0'..'9' } - var i = 0 - - template lookupBy(offset = 0) = - var j = i+1+offset - while j < formatstr.len and formatstr[j] in PatternChars: inc(j) - let key = substr(formatstr, i+1+offset, j-1) - s.lookup m, key, offset == 1 - i = j + offset - - while i < len(formatstr): - if formatstr[i] == s.delimiter and i+1 < len(formatstr): - let cur = formatstr[i+1] - case cur - of Braces.start: - let curIdx = i - lookupBy 1 - if formatstr[i-1] != Braces.stop: - s.excHandle.invalidFormatString(formatstr, curIdx) - of PatternStartChars: lookupBy 0 - elif cur == s.delimiter: - s.addSnippet s.delimiter - inc(i, 2) - else: - s.excHandle.invalidFormatString(formatstr, i) - inc(i) - else: - s.addSnippet formatstr[i] - inc(i) - -proc substituteAux*[M](templ: string, m: M; - excHandle = initRaisesExcHandle(); delimiter = Delimiter -): string = - let cfg = Subs() - cfg.resetSubsCfg(excHandle, delimiter) - cfg.handle templ, m, lookup - cfg.res - -const DummyM = 0 - -proc isValid*(templ: string): bool = - let cfg = SubsCfg() - cfg.resetSubsCfg(initIgnoreExcHandle()) - cfg.handle templ, DummyM, nolookup - not cfg.excHandle.hasExc - -iterator getIdentifiers*(templ: string): string = - let cfg = SubsCfg() - cfg.resetSubsCfg(initIgnoreExcHandle()) - cfg.handle templ, DummyM, nolookupButAdd diff --git a/src/pylib/Lib/string_impl/templateImpl.nim b/src/pylib/Lib/string_impl/templateImpl.nim deleted file mode 100644 index 380035b33..000000000 --- a/src/pylib/Lib/string_impl/templateImpl.nim +++ /dev/null @@ -1,71 +0,0 @@ - - -import std/macros -import std/tables - -import ./n_chainmap -export n_chainmap.`[]`, n_chainmap.contains -import ./substituteImpl -import ./template_decl - -export template_decl -export initRaisesExcHandle, initIgnoreExcHandle - -proc Template*(s: string): Template = - new result - result.`template` = s - -#func substitute*(templ: Template): PyStr = str templ - -proc toTableNode[K](kws: NimNode): NimNode#[Table]# = - let kNode = ident $K - if kws.len == 0: - let vNode = bindSym"string" - result = newCall: - nnkBracketExpr.newTree(bindSym"initTable", kNode, vNode) - return - result = newNimNode nnkTableConstr - for kw in kws.items: - expectKind kw, nnkExprEqExpr - result.add nnkExprColonExpr.newTree( - newCall(kNode, newLit $kw[0]), - kw[1], - ) - result = newCall(bindSym"toTable", result) - -proc toTableNode[K](mapping: NimNode#[Mapping]#, - kws: NimNode): NimNode#[Table]# = - result = newCall(bindSym"toTable", mapping) - if kws.len == 0: - return - let kwsVal = toTableNode[K](kws) - result = newCall(bindSym"initChainMap", - kwsVal, - result - ) - -using oaNode: NimNode - -proc formatAux(templ: NimNode; oaNode; doExc: NimNode): NimNode = - newCall(bindSym"substituteAux", - newCall(bindSym"$", templ), - oaNode, doExc, - newDotExpr(templ, ident"delimiter") - ) - - -template genSubstitute*(M; Key; sym; doExc){.dirty.} = - mixin toTable - bind bindSym, newCall - bind formatAux, toTableNode, initChainMap - macro sym*(templ: Template, kws: varargs[untyped]): Key = - formatAux templ, toTableNode[Key](kws), newCall bindSym(astToStr doExc) - - macro sym*(templ: Template, mapping: M, kws: varargs[untyped]): Key = - formatAux templ, toTableNode[Key](mapping, kws), newCall bindSym(astToStr doExc) - -proc is_valid*(templ: Template): bool = isValid($templ) -iterator get_identifiersMayDup*(templ: Template): string = - ## not dedup - for i in getIdentifiers $templ: yield i - diff --git a/src/pylib/Lib/string_impl/template_decl.nim b/src/pylib/Lib/string_impl/template_decl.nim deleted file mode 100644 index 9e98914a8..000000000 --- a/src/pylib/Lib/string_impl/template_decl.nim +++ /dev/null @@ -1,8 +0,0 @@ - -type Template* = ref object of RootObj - `template`*: string - -func `$`*(self: Template): string = self.`template` - -method delimiter*(self: Template): char{.base.} = '$' ## \ -## .. note:: In Python this is a class attribute diff --git a/src/pylib/Lib/sys.nim b/src/pylib/Lib/sys.nim deleted file mode 100644 index 1422068d8..000000000 --- a/src/pylib/Lib/sys.nim +++ /dev/null @@ -1,41 +0,0 @@ -## Lib/sys -## -## .. hint:: if not defined `pylibConfigIsolated`, -## this module will call `setlocale(LC_CTYPE, "")`, -## a.k.a. changing locale to user's configure, -## just as CPython's initialization. - -import ../builtins/list -import ../noneType -import ../pystring/strimpl -import ../version as verionLib - -import ./n_sys -export n_sys except float_repr_style, platform, getencodings, addaudithook, audit - -import ./sys_impl/[genplatform, geninfos, genargs] - -wrapExportSincePy(3,8, addaudithook) -wrapExportSincePy(3,8, audit) - -const float_repr_style* = str(n_sys.float_repr_style) -genPlatform(str) -genInfos(str, None) -genArgs PyStr, PyList, str, list, newPyListOfCap -export list, strimpl - -when declared(sys_impl_stdio.stdout): - converter noneStdstream*(n: NoneType): typeof(sys_impl_stdio.stdout) = nil - -template wrapStrProc(fun) = - proc fun*(): PyStr = str n_sys.fun() - -wrapStrProc getfilesystemencoding -wrapStrProc getdefaultencoding - -func exit*[T](obj: T) = - ## .. warning:: this does not raise SystemExit, - ## which differs Python's - exit(str(obj)) -func exit*(x: NoneType) = quit(0) - diff --git a/src/pylib/Lib/sys_impl/auditImpl.nim b/src/pylib/Lib/sys_impl/auditImpl.nim deleted file mode 100644 index 976e2282b..000000000 --- a/src/pylib/Lib/sys_impl/auditImpl.nim +++ /dev/null @@ -1,4 +0,0 @@ -## When `not defined(release) or defined(pylibSysAudit)`, audit will be enabled. -## Otherwise, it will be disabled. -import ./auditImpl/main -export main diff --git a/src/pylib/Lib/sys_impl/auditImpl/cfg.nim b/src/pylib/Lib/sys_impl/auditImpl/cfg.nim deleted file mode 100644 index dcf75f869..000000000 --- a/src/pylib/Lib/sys_impl/auditImpl/cfg.nim +++ /dev/null @@ -1,17 +0,0 @@ - - -const config_should_audit* = - not defined(nimdoc) and # NIM-BUG: see ./yesImpl - not defined(release) or defined(pylibSysAudit) - -template whenAuditEnabled*(body) = - bind config_should_audit - when config_should_audit: - body - -template whenAuditEnabledOr*[T](exp, elseExp: T): T = - bind config_should_audit - when config_should_audit: - exp - else: - elseExp diff --git a/src/pylib/Lib/sys_impl/auditImpl/macrohelper.nim b/src/pylib/Lib/sys_impl/auditImpl/macrohelper.nim deleted file mode 100644 index 5b695dc0c..000000000 --- a/src/pylib/Lib/sys_impl/auditImpl/macrohelper.nim +++ /dev/null @@ -1,19 +0,0 @@ - - -import ./cfg -export whenAuditEnabled - -import ./main -export audit -template callAudit(event: static string; vargs: varargs[untyped]): NimNode = - whenAuditEnabledOr( - newCall(bindSym"audit", newLit event, vargs), newEmptyNode()) - -template addaudit*(res: NimNode; event: static string; vargs: varargs[untyped]) = - bind whenAuditEnabled, callAudit - whenAuditEnabled: - res.add callAudit(event, vargs) - -template newStmtWithAudit*(event: static string; vargs: varargs[untyped]): NimNode = - bind whenAuditEnabled, callAudit - whenAuditEnabledOr(newStmtList callAudit(event, vargs), newStmtList()) diff --git a/src/pylib/Lib/sys_impl/auditImpl/main.nim b/src/pylib/Lib/sys_impl/auditImpl/main.nim deleted file mode 100644 index 44fa5e494..000000000 --- a/src/pylib/Lib/sys_impl/auditImpl/main.nim +++ /dev/null @@ -1,6 +0,0 @@ - -import ./cfg -when config_should_audit: - include ./yesImpl -else: - include ./noImpl diff --git a/src/pylib/Lib/sys_impl/auditImpl/noImpl.nim b/src/pylib/Lib/sys_impl/auditImpl/noImpl.nim deleted file mode 100644 index dbcd06db8..000000000 --- a/src/pylib/Lib/sys_impl/auditImpl/noImpl.nim +++ /dev/null @@ -1,12 +0,0 @@ - -import ./types - -template PySys_Audit*(event: string, args: varargs[typed]) = discard - -template reportNoAudit() = - {.warning: "audit not enabled, enable via `-d:pylibSysAudit` in release build mode".} - -template PySys_AddAuditHook*(hook: HookProc, userData = default Any) = bind reportNoAudit; reportNoAudit -template addaudithook*(hook: HookProc) = bind reportNoAudit; reportNoAudit - -template audit*(event: string, args: varargs[typed]) = discard diff --git a/src/pylib/Lib/sys_impl/auditImpl/types.nim b/src/pylib/Lib/sys_impl/auditImpl/types.nim deleted file mode 100644 index d3260e4ff..000000000 --- a/src/pylib/Lib/sys_impl/auditImpl/types.nim +++ /dev/null @@ -1,11 +0,0 @@ - -import std/typeinfo -export typeinfo - -type - HookProc* = proc (event: string; args: varargs[Any]) - HookEntry* = tuple[ - hookCFunction: HookProc, - userData: Any, - ] - diff --git a/src/pylib/Lib/sys_impl/auditImpl/yesImpl.nim b/src/pylib/Lib/sys_impl/auditImpl/yesImpl.nim deleted file mode 100644 index e44c9d415..000000000 --- a/src/pylib/Lib/sys_impl/auditImpl/yesImpl.nim +++ /dev/null @@ -1,122 +0,0 @@ - -import ./types -import ../../../pyerrors/rterr -import std/lists -import std/locks -import std/macros - -template mytoAny[T](x: T): Any = - bind toAny - var tx = x - toAny(tx) - -proc nodeToAny(n: NimNode): NimNode = newCall(bindSym"mytoAny", n) - -proc callVarargImpl(call, arg1, vargs: NimNode): NimNode = - # NIM-BUG: vargs will become Sym of nil when doc - expectKind vargs, nnkBracket - result = newCall(call, arg1) - for i in vargs: - result.add i.nodeToAny - -macro callVararg(call, arg1, vargs: typed) = - callVarargImpl(call, arg1, vargs) - -macro callWithExtraVararg(call, arg1, vargs: typed, extra: Any) = - result = callVarargImpl(call, arg1, vargs) - result.add extra - -template initHookList(): SinglyLinkedList[HookEntry] = initSinglyLinkedList[HookEntry]() -template toHookEntry(v: HookProc, userData: Any): HookEntry = (v, userData) - -type - PyRuntimeState = object - audit_hooks*: tuple[ - head: SinglyLinkedList[HookEntry], - mutex: Lock, - ] - -var runtime = PyRuntimeState( - audit_hooks: ( - head: initHookList(), - mutex: Lock(), - ) -) -runtime.audit_hooks.mutex.initLock() - -var interp = ( - audit_hooks: newSeq[HookProc]() -) -proc PyDTrace_AUDIT_ENABLED(): bool = false ## Currently not implemented -proc should_audit(): bool{.inline.} = - not runtime.audit_hooks.head.head.isNil or - interp.audit_hooks.len > 0 or - PyDTrace_AUDIT_ENABLED() - -template PySys_AuditImpl(event: string, args: untyped) = - ## `PySys_Audit`/`sys_audit_tstate` EXT. CPython C-API - bind runtime, callWithExtraVararg, callVararg, items - for e in runtime.audit_hooks.head.items: - callWithExtraVararg( - e.hookCFunction, - event, args, e.userData) - - #[if dtrace: ...]# - - # Call interpreter hooks - for hook in interp.audit_hooks: - callVararg(hook, event, args) - -template PySys_Audit*(event: string, args: varargs[typed]) = - bind PySys_AuditImpl - PySys_AuditImpl(event, args) - -proc add_audit_hook_entry_unlocked(runtime: var PyRuntimeState, entry: HookEntry) = - runtime.audit_hooks.head.append entry - -template auditAddAuditHook(exc){.dirty.} = - ## `PySys_Audit` EXT. CPython C-API - try: - PySys_Audit("sys.addaudithook") - except exc: - # We do not report errors derived from exc - discard - -proc PySys_AddAuditHook*(hook: HookProc, userData = default Any) = - ## `PySys_Audit` EXT. CPython C-API - auditAddAuditHook RuntimeError - - withLock runtime.audit_hooks.mutex: - add_audit_hook_entry_unlocked(runtime, hook.toHookEntry userData) - - -proc addaudithook*(hook: HookProc) = - auditAddAuditHook CatchableError - interp.audit_hooks.add hook - -template audit*(event: string, args: varargs[typed]) = - bind should_audit, PySys_AuditImpl - if should_audit(): - PySys_AuditImpl(event, args) - -const ClearAuditHooksName = "cpython._PySys_ClearAuditHooks" -proc PySys_ClearAuditHooks() = - # TODO: after config.verbose - #if config.verbose: PySys_WriteStderr("# clear sys.audit hooks\n") - try: PySys_Audit(ClearAuditHooksName) - except Exception: discard - -template sinceNim(ma, mi, pa): bool = - (NimMajor, NimMinor, NimPatch) >= (ma, mi, pa) -const Js = defined(js) -when not Js and sinceNim(2,1,1) or - Js and sinceNim(2,3,2): - ## XXX: FIXED-NIM-BUG: though nimAllowNonVarDestructor is defined at least since 2.0.6, - ## it still cannot be compiled till about 2.1.1 - proc `=destroy`*(self: PyRuntimeState) = PySys_ClearAuditHooks() -else: - proc `=destroy`*(self: var PyRuntimeState) = PySys_ClearAuditHooks() - -when isMainModule: - addaudithook do (event: string, _: varargs[Any]): - assert event == ClearAuditHooksName diff --git a/src/pylib/Lib/sys_impl/exits.nim b/src/pylib/Lib/sys_impl/exits.nim deleted file mode 100644 index 8bb76c005..000000000 --- a/src/pylib/Lib/sys_impl/exits.nim +++ /dev/null @@ -1,3 +0,0 @@ - -proc exit*(s: string) = quit(s) -func exit*(c: int) = quit(c) diff --git a/src/pylib/Lib/sys_impl/fenvs.nim b/src/pylib/Lib/sys_impl/fenvs.nim deleted file mode 100644 index adf972011..000000000 --- a/src/pylib/Lib/sys_impl/fenvs.nim +++ /dev/null @@ -1,40 +0,0 @@ - -import std/fenv -import ./util -import ../../pyconfig/pycore/pymath - -const float_repr_style* = - when PY_SHORT_FLOAT_REPR: "short" else: "legacy" ##\ -## .. note:: when JS, this is "legacy" but -## currently `$float` is still of short style. -## this only affects other function like `round(float, int)` - - -type FT = float -const - float_info* = ( - max: maximumPositiveValue FT, - max_exp: maxExponent FT, - max_10_exp: max10Exponent FT, - min: minimumPositiveValue FT, - min_exp: minExponent FT, - min_10_exp: min10Exponent FT, - dig: digits FT, - mant_dig: mantissaDigits FT, - epsilon: epsilon FT, - radix: fpRadix, - #rounds: 1 - ) ## float_info.rounds is defined as a `getter`, see `rounds`_ - -when not weirdTarget: - let fiRound = fegetround().int - template rounds*(fi: typeof(float_info)): int = - ## not available when nimscript - bind fiRound - fiRound -else: - template rounds*(fi: typeof(float_info)): int = - {.error: "not available for nimscript/JavaScript/compile-time".} - - - diff --git a/src/pylib/Lib/sys_impl/flagsImpl.nim b/src/pylib/Lib/sys_impl/flagsImpl.nim deleted file mode 100644 index e6c7cc173..000000000 --- a/src/pylib/Lib/sys_impl/flagsImpl.nim +++ /dev/null @@ -1,5 +0,0 @@ - - -import ./flagsImpl/values - -genFlagsObj() diff --git a/src/pylib/Lib/sys_impl/flagsImpl/ct.nim b/src/pylib/Lib/sys_impl/flagsImpl/ct.nim deleted file mode 100644 index fd09b9228..000000000 --- a/src/pylib/Lib/sys_impl/flagsImpl/ct.nim +++ /dev/null @@ -1,69 +0,0 @@ -## `PYTHON*` environment variables will be loaded iif pylibUsePyEnv is defined. -import ../../../version -import std/macros -#[ -import std/macrocache -const fields = CacheSeq"sys.flags-fields" -export macrocache -]# -var fields*{.compileTime.} = newSeqOfCap[NimNode](18) - -template addField(f) = - static: - const fname = astToStr(f) - fields.add ident fname - -template toCfgName(f): string = "pylibConfig" & astToStr(f) -template flag(f; defval=false) = - const f*{.booldefine: f.toCfgName.} = defval - addField f - -template flagi(f; defval=0) = - const f*{.intdefine: f.toCfgName.} = defval - addField f - -const PY_LONG_DEFAULT_MAX_STR_DIGITS = 4300 ## PY-DIFF: no use (PyLong is not implemented) - -# Following defvals are according to Python/initconfig.c:_PyConfig_Read `if (config->isolated) {...` -flagi debug, int(not defined(release)) -flagi inspect -flagi interactive -pysince(3,4): flagi isolated -flagi optimize, defined(release).int + defined(danger).int -flagi dont_write_bytecode, 1 ## PY_DIFF: default is 1, as we doesn't produce .pyc -flagi no_user_site, isolated -flagi no_site -flagi ignore_environment, int(defined(pylibUsePyEnv) or bool isolated) ## PY-DIFF: we ignore `PYTHON*` env by default -flagi verbose -flagi bytes_warning -pysince(3,2): flagi quiet -flagi hash_randomization -pysince(3,7): flag dev_mode -flagi utf8_mode -pysince(3,11): flag safe_path, isolated!=0 -pysince(3,11): flagi int_max_str_digits, PY_LONG_DEFAULT_MAX_STR_DIGITS -pysince(3,10): flagi warn_default_encoding - - -macro redefineFlags*(kws: varargs[untyped]) = - ## used in intermediate file, which wanna define some runtime flags. - ## due to `export except`'s behavior, unknown kws are just ignored. - result = newStmtList() - var exp = nnkExportExceptStmt.newTree ident"ct" - for kw in kws: - exp.add kw[0] - result.add newLetStmt( - kw[0].postfix"*", kw[1] - ) - result.add exp - -macro genFlagsObj* = - ## generate `let flags* = ...` - var ntup = newNimNode nnkTupleConstr - for f in ct.fields: - let val = ident(f.strVal) - ntup.add nnkExprColonExpr.newTree( - f, val - ) - result = newLetStmt(ident("flags").postfix"*", ntup) - diff --git a/src/pylib/Lib/sys_impl/flagsImpl/values.nim b/src/pylib/Lib/sys_impl/flagsImpl/values.nim deleted file mode 100644 index a7e024f7d..000000000 --- a/src/pylib/Lib/sys_impl/flagsImpl/values.nim +++ /dev/null @@ -1,57 +0,0 @@ - - -import ./ct -when ignore_environment == 0: - #const use_environment = true - import std/macros - import ../../../Python/config_read_env - var call{.compileTime.} = newCall("redefineFlags") - proc envImpl(name, fn, envName: NimNode): NimNode = - call.add nnkExprEqExpr.newTree(name, - newCall(fn, - envName, - name) - ) - result = newEmptyNode() - - macro env(fn; name) = envImpl(name, fn, newCall("toPyEnv", newLit name.strVal)) - macro env(fn; name; envName) = envImpl(name, fn, envName) - template envE(name) = env ib_e , name - template envI(name) = env ib_i, name - template envB(name) = env ib_b, name - - # Python/initconfig.c:config_read_env_vars - envI debug - envI verbose - envI optimize - envI inspect - - envB dont_write_bytecode - envB no_user_site - - envE safe_path - - # Python/initconfig.c:config_read_complex_options -> - # Python/initconfig.c:config_init_int_max_str_digits - envI int_max_str_digits - - # Python/preconfig.c:preconfig_init_utf8_mode - env ib_i, utf8_mode, "PYTHONUTF8" # XXX: PY-DIFF: python will crash if PYTHONUTF8 is neither 0 nor 1 - - # Python/preconfig.c:_PyPreCmdline_Read - envE dev_mode - #[ - XXX: PY-BUG: as of v3.14.0a7, https://docs.python.org/3/library/devmode.html#devmode says - "setting the PYTHONDEVMODE environment variable to 1." - but it's just implemented as checking existence of PYTHONDEVMODE, whatever it's set: 0, -1 ,etc - ]# - envE warn_default_encoding - - macro genCall = call - genCall() - -#[ -const PY_LONG_DEFAULT_MAX_STR_DIGITS = - len $high(int) - ## 4300 ## PY-DIFF: no use (PyLong is not implemented) -]# diff --git a/src/pylib/Lib/sys_impl/genargs.nim b/src/pylib/Lib/sys_impl/genargs.nim deleted file mode 100644 index 7275a7607..000000000 --- a/src/pylib/Lib/sys_impl/genargs.nim +++ /dev/null @@ -1,69 +0,0 @@ - -import std/os -when defined(js): - import ../../jsutils/denoAttrs - -const - hasArgn = declared(paramCount) - hasArgs = declared(paramStr) - -when defined(js): - when defined(nodejs): - let execPath{.importjs: "process.execPath".}: cstring - else: - func getExecPath: cstring = - # Deno.execPath() may ask permission, - # so we only invoke it when called - {.noSideEffect.}: - if inDeno: - asm "`result` = Deno.execPath()" - else: result = "" - - -template genArgs*(St, Ls; S; lsCopy, lsOfCap){.dirty.} = - bind hasArgn, hasArgs, - paramCount, paramStr - - when hasArgn and hasArgs: - ## under shared lib in POSIX, paramStr and paramCount are not available - - let - argn = paramCount() - argc = argn + 1 - var - orig_argv* = lsOfCap[St](argc) ##\ - ## .. hint:: rely on - ## `paramCount`_ and - ## `paramStr`_. - ## See their document for availability. - argv*: Ls[St] - - for i in 0..argn: - orig_argv.append S paramStr i - when defined(nimscript): - if argn > 0: - argv = - if orig_argv[1] == "e": - orig_argv[2..^1] - else: - assert orig_argv[1][^5..^1] == ".nims" or - orig_argv[1].startsWith "-" # [--opt...] --eval:cmd - orig_argv[1..^1] - else: argv = lsCopy(orig_argv) - - when defined(nimscript): - template executable*: St = S getCurrentCompilerExe() - elif defined(js): - template executable*: St = - let execPath{.importByNodeOrDeno("process?.execPath", "execPath()")}: cstring - S $execPath - else: - template executable*: St = - ## returns: - ## - ## - when nimscript, path of `Nim`; - ## - when JavaScript: - ## - on browser: empty string - ## - on NodeJS/Deno: executable path of Node/Deno - ## - otherwise, it's the path of current app/exe. - S getAppFilename() diff --git a/src/pylib/Lib/sys_impl/geninfos.nim b/src/pylib/Lib/sys_impl/geninfos.nim deleted file mode 100644 index 3d1e3028f..000000000 --- a/src/pylib/Lib/sys_impl/geninfos.nim +++ /dev/null @@ -1,59 +0,0 @@ - - -import ../../version as libversion - -func int2hex(x: int): int = - ## 10 -> 0x10 - ## and assert 0 <= x < 100 - if x < 10: return x - let - hi = x div 10 - lo = x mod 10 - hi shl 4 + lo # hi * 16 + lo - -template toHexversion(versionInfo: tuple): int = - let v = versionInfo - var res = v[0].int2hex - res = (res shl 8) or v[1].int2hex - res = (res shl 8) or v[2].int2hex - res = (res shl 4) or (PyReleaseLevel.int and 0xf) - (res shl 4) or (PySerial and 0xf) - -const - ## we maps import as Nim's, - ## we ourselves do not have cache on `import` - - ## Version information (SemVer). - -template genInfos*(S; cache_tag_val){.dirty.} = - bind PyMajor, PyMinor, PyPatch, PyReleaseLevel, PySerial, - Major, Minor, Patch, ReleaseLevel, Serial, - asVersion, toHexversion - const - version_info* = ( - major: PyMajor, - minor: PyMinor, - patch: PyPatch, - releaselevel: S $PyReleaseLevel, - serial: PySerial - ) - implVersion = ( - major: Major, - minor: Minor, - micro: Patch, - releaselevel: S ReleaseLevel, - serial: Serial - ) - implementation* = ( - name: S "pynim", - version: implVersion, - hexversion: toHexversion(version_info), - cache_tag: cache_tag_val - ) - version* = S asVersion((PyMajor, PyMinor, PyPatch)) - hexversion* = toHexversion(version_info) - - maxsize* = high(BiggestInt) - byteorder* = S(if cpuEndian == littleEndian: "little" else: "big") - copyright* = S "MIT" - #api_version* = NimVersion diff --git a/src/pylib/Lib/sys_impl/genplatform.nim b/src/pylib/Lib/sys_impl/genplatform.nim deleted file mode 100644 index 6fee2f974..000000000 --- a/src/pylib/Lib/sys_impl/genplatform.nim +++ /dev/null @@ -1,61 +0,0 @@ - -# CPython-3.13.0's sys.platform is getten from Python/getplatform.c Py_GetPlatform, -# which returns PLATFORM macro, -# which is defined in Makefile.pre.in L1808 as "$(MACHDEP)" -# and MACHDEP is defined in configure.ac L313 - -import ./util - -when defined(js) and not defined(nodejs): - from std/strutils import toLowerAscii, startsWith - -when defined(linux) or defined(aix): - import ../private/platformInfo - - template sufBefore(pre: string, ver: (int, int)): string = - when (PyMajor, PyMinor) < ver: - pre & uname_release_major() - else: - pre - -proc getPlatform*(): string = - when defined(js): - when defined(nodejs): - proc `os.platform`(): cstring{.importjs: - "require('os').platform()".} - return `os.platform`().`$` - else: - let `navigator.platform`{.importjs: "(navigator.platform||process.platform)".}: cstring - result = `navigator.platform`.`$`.toLowerAscii - result = - if result.startsWith "win32": "win32" - elif result.startsWith "linux": "linux" - elif result.startsWith "mac": "darwin" - else: result## XXX: TODO - else: - when defined(windows): "win32" # hostOS is windows - elif defined(macosx): "darwin" # hostOS is macosx - elif defined(android): "android" - elif defined(linux): "linux".sufBefore (3,3) - elif defined(aix): "aix".sufBefore (3,8) - else: - when defined(solaris): - # Only solaris (SunOS 5) is supported by Nim, as of Nim 2.1.1, - # and SunOS's dev team in Oracle had been disbanded years ago - # Thus SunOS's version would never excceed 5 ... - "sunos5" # hostOS is solaris - elif hostOS == "standalone": - hostOS - else: - # XXX: haiku, netbsd ok ? - hostOS & uname_release_major() - -template genPlatform*(S){.dirty.} = - bind getPlatform - when defined(js): - let platform* = S getPlatform() - else: - const platform* = S getPlatform() - ## .. note:: the value is standalone for bare system - ## and haiku/netbsd appended with major version instead of "unknown". - ## In short, this won't be "unknown" as Python does. diff --git a/src/pylib/Lib/sys_impl/getencodings.nim b/src/pylib/Lib/sys_impl/getencodings.nim deleted file mode 100644 index ce6989b2c..000000000 --- a/src/pylib/Lib/sys_impl/getencodings.nim +++ /dev/null @@ -1,111 +0,0 @@ - - -import ./util - -template importPython(submod) = - import ../../Python/submod -template importPython(submod, sym) = - from ../../Python/submod import sym - - -importPython force_ascii_utils, Py_FORCE_UTF8_FS_ENCODING -when defined(js) and not defined(nodejs) or - not (Py_FORCE_UTF8_FS_ENCODING or defined(windows)) or - defined(nimscript): - import std/strutils # toLowerAscii startsWith -when defined(nimPreviewSlimSystem): - import std/assertions - -when defined(js): - import std/jsffi -when not weirdTarget: - const inFileSystemUtf8os = defined(macosx) or defined(android) or defined(vxworks) - when not inFileSystemUtf8os: - importPython(fileutils) - importPython envutils - importPython localeutils # setlocale, LC_CTYPE - -const - Utf8 = "utf-8" -proc getdefaultencoding*(): string = - ## Return the current default encoding used by the Unicode implementation. - ## - ## Always "utf-8" in Nim - Utf8 - -#[ gdb Python3.13.0b2: -watch _PyRuntime->_main_interpreter.config.filesystem_encoding -then we can get a trace: -]# -#[ TODO: after codecs - Python/pylifecycle.c - pyinit_main - Py_InitializeFromConfig - Object/unicodeobject.c - _PyUnicode_InitEncodings - init_fs_encoding - config_get_codec_name - Python/codecs.c _PyCodec_Lookup -]# - - -# ref: -# https://docs.python.org/3/c-api/init_config.html#c.PyConfig.filesystem_encoding -when not weirdTarget and (PyMajor, PyPatch) < (3, 15): - #[ - Py_PreInitialize - _Py_PreInitializeFromPyArgv - [_PyPreConfig_Write] (3.13) - _Py_SetLocaleFromEnv - ]# - # config ref: (PEP 587) and enhence (PEP 741) - when not defined(pylibConfigIsolated): - # TODO: consider coerce_c_locale: - # _PyPreConfig_Read -> preconfig_read -> preconfig_init_coerce_c_locale - proc simple_Py_PreInitialize = - Py_SetLocaleFromEnv(LC_CTYPE) - simple_Py_PreInitialize() - - # source: - # cpython/Python/initconfig.c - # config_init_fs_encoding & config_get_fs_encoding - when inFileSystemUtf8os: - template getfilesystemencodingImpl(): string = Utf8 - else: - proc getfilesystemencodingImpl(): string = - # modified from initconfig.c config_get_fs_encoding - when Py_FORCE_UTF8_FS_ENCODING: - return Utf8 - elif defined(windows): - return - when false: #0 != preconfig.legacy_windows_fs_encoding: - ## Legacy Windows filesystem encoding: mbcs/replace - "mbcs" - else: - ## Windows defaults to utf-8/surrogatepass (PEP 529) - Utf8 - else: - template normEncoding(s: string): string = - ## XXX: see above, currently it's only for - ## UTF-8 (got in Debian) -> utf-8 - s.toLowerAscii - # As currently there is no preconfig, we skip the following line. - #if(preconfig->utf8_mode)... // use utf-8 - if force_ascii_utils.Py_GetForceASCII(): - return "ascii" - normEncoding Py_GetLocaleEncoding() - when (PyMajor, PyMinor) >= (3,7): - let filesystem_encoding = block: - let loc = c_setlocale(LC_CTYPE, nil) - if loc != nil and loc == "C" or loc == "POSIX": - # utf-8 mode (PEP 540) - Utf8 - else: - getfilesystemencodingImpl() - else: - let filesystem_encoding: string = getfilesystemencodingImpl() -else: - # utf-8 mode is enabled by default since 3.15 (pep 686). - const filesystem_encoding = Utf8 - -proc getfilesystemencoding*(): string = filesystem_encoding diff --git a/src/pylib/Lib/sys_impl/sizes.nim b/src/pylib/Lib/sys_impl/sizes.nim deleted file mode 100644 index 40915ece3..000000000 --- a/src/pylib/Lib/sys_impl/sizes.nim +++ /dev/null @@ -1,11 +0,0 @@ - -template getsizeof*(x): int = - mixin sizeof - sizeof(x) - -template getsizeof*(x; default: int): int = - ## may be used when `sizeof(x)` is a compile-error - ## e.g. `func sizeof(x: O): int{.error.}` for `O` - mixin sizeof - when compiles(sizeof(x)): sizeof(x) - else: default diff --git a/src/pylib/Lib/sys_impl/stdio.nim b/src/pylib/Lib/sys_impl/stdio.nim deleted file mode 100644 index 128416e10..000000000 --- a/src/pylib/Lib/sys_impl/stdio.nim +++ /dev/null @@ -1,25 +0,0 @@ - -import ./util - -when not weirdTarget: - when not defined(pylibSysNoStdio): - # CPython's stdio is init-ed by create_stdio in Python/pylifecycle.c - import ../io - export io.read, io.readline, io.write, io.fileno, io.isatty, io.flush - - template wrap(ioe): untyped = - var ioe* = newNoEncTextIO( - name = '<' & astToStr(ioe) & '>', - file = system.ioe, newline=DefNewLine) - # XXX: NIM-BUG: under Windows, system.stdin.readChar for non-ASCII is buggy, - # returns a random char for one unicode. - wrap stdin - wrap stdout - wrap stderr - stdin.mode = "r" - stdout.mode = "w" - stderr.mode = "w" - let - dunder_stdin* = stdin ## __stdin__ - dunder_stdout* = stdout ## __stdout__ - dunder_stderr* = stderr ## __stderr__ diff --git a/src/pylib/Lib/sys_impl/util.nim b/src/pylib/Lib/sys_impl/util.nim deleted file mode 100644 index 934ea2787..000000000 --- a/src/pylib/Lib/sys_impl/util.nim +++ /dev/null @@ -1,5 +0,0 @@ - -const weirdTarget* = defined(js) or defined(nimscript) - -import ../../version as libversion -export libversion diff --git a/src/pylib/Lib/tempfile.nim b/src/pylib/Lib/tempfile.nim deleted file mode 100644 index 32b274ce1..000000000 --- a/src/pylib/Lib/tempfile.nim +++ /dev/null @@ -1,41 +0,0 @@ - -import std/options -from std/os import fileExists -import ./n_tempfile -export n_tempfile except mktemp, mkdtemp, name, templ, gettempdir, gettempprefix -import ../pystring/strimpl -import ../pybytes/bytesimpl -import ../noneType -import ../version - -# TODO: SpooledTemporaryFile - -proc mktemp*(suffix="", prefix=templ, dir: PyStr|NoneType = "", checker=fileExists): PyStr = - when dir is NoneType: - let dir = "" - str n_tempfile.mktemp(suffix, prefix, dir, checker) - -template name*(self: TemporaryFileWrapper): PyStr = - bind str, name - str name self - -type SOption = Option[string] -proc mkdtemp*( - suffix: PyStr|NoneType = None, - prefix: PyStr|NoneType = None, - dir: PyStr|NoneType = None): PyStr = - converter optstr2nim(o: PyStr|NoneType): SOption = - when o is NoneType: return none - else: return some o - str n_tempfile.mkdtemp(suffix, prefix, dir) - -template gen_s2bs(s, b) = - proc s*(): PyStr = - str n_tempfile.gettempdir() - - proc b*(): PyBytes{.pysince(3,5).} = - bytes n_tempfile.gettempdir() - - -gen_s2bs gettempdir, gettempdirb -gen_s2bs gettempprefix, gettempprefixb diff --git a/src/pylib/Lib/test/import_utils.nim b/src/pylib/Lib/test/import_utils.nim deleted file mode 100644 index ec928a5a9..000000000 --- a/src/pylib/Lib/test/import_utils.nim +++ /dev/null @@ -1,13 +0,0 @@ - -template pyimport*(nam) = - import ../nam - -template importPyLib* = import ../../../pylib - -template importPyLib*(lib) = - importPyLib() - pyimport lib - -template importTestPyLib*(lib) = - import std/unittest - importPyLib lib diff --git a/src/pylib/Lib/test/main.nim b/src/pylib/Lib/test/main.nim deleted file mode 100644 index 1bd13cff4..000000000 --- a/src/pylib/Lib/test/main.nim +++ /dev/null @@ -1,43 +0,0 @@ - -import std/strutils -import std/os -const SourceDir = currentSourcePath().parentDir -when defined(js): - const jsExcludes = ("skipJs.txt").slurp.strip().splitLines() - -import std/macros - -var allTests{.compileTime.}: seq[string] -static: - # walkFiles is {.error.} when nims - for t in walkDir(SourceDir): - if t.kind == pcDir or t.kind == pcLinkToDir: continue - let name = t.path.lastPathPart - if name[0] != 't' or name.startsWith "temp": continue - when defined(js): - var nname = name - nname.removeSuffix(".nim") - nname.removePrefix("t") - nname.removePrefix("_") - if nname in jsExcludes: continue - nname.removePrefix("est_") - if nname in jsExcludes: continue - allTests.add t.path - -macro testAll* = - ## .. warning:: this causes `{.warning[UnusedImport]: off.}` - ## .. hint:: this generates `import` stmt, thus must be on top level - result = newNimNode nnkImportStmt - for i in allTests: - let strNode = newLit i - #[ # the following doesn't compile - result.add quote do: - `strNode`{.used.} - ]# - result.add strNode - result = quote do: - {.warning[UnusedImport]: off.} - `result` - -when isMainModule: - testAll() diff --git a/src/pylib/Lib/test/skipJs.txt b/src/pylib/Lib/test/skipJs.txt deleted file mode 100644 index 180fb02a0..000000000 --- a/src/pylib/Lib/test/skipJs.txt +++ /dev/null @@ -1,4 +0,0 @@ - -tempfile -os_nojs -pathlib_nojs \ No newline at end of file diff --git a/src/pylib/Lib/test/support/os_helper.nim b/src/pylib/Lib/test/support/os_helper.nim deleted file mode 100644 index 1bbccc3d1..000000000 --- a/src/pylib/Lib/test/support/os_helper.nim +++ /dev/null @@ -1,5 +0,0 @@ - -import std/os - -const - TESTFN* = currentSourcePath().parentDir()/../"tempfiletest" diff --git a/src/pylib/Lib/test/test_array.nim b/src/pylib/Lib/test/test_array.nim deleted file mode 100644 index 462c216fe..000000000 --- a/src/pylib/Lib/test/test_array.nim +++ /dev/null @@ -1,67 +0,0 @@ - -import ./import_utils -importTestPyLib array - -suite "Lib/array": - #test "init": - when compiles(array('w', "123")): - test "py3.13: 'w' Py_UCS4": - const s = "12为" - var arr = array('w', s) - check arr[2] == "为" - check arr.tounicode() == s - test "bytes": - let arr = array('b', b"123") - check arr.len == 3 - check arr[2] == cschar '3' - check arr.tobytes() == b"123" - test "cmp": - let - a = array('i', [1,2]) - b = array('i', [1,2]) - check a == b - check a >= b - check not (a > b) - template ccmp[A; A2](c: char, a: A, op; b: A2) = - check op(array(c, a), array(c, b)) - ccmp 'i', [1, 3], `<`, [1, 4] - ccmp 'i', [1, 3, 2], `<`, [1, 4] - ccmp 'i', [1, 3, 2], `>`, [1, 3] - test "byteswap": - const - One = 0x01 - Two = 0x10 - template safeShl[R](x, n): untyped = (when n == 0: x.R else: x.R shl n) - - template testType(Typ) = - const - TypeSize = sizeof(Typ) - Shift = 8 * (TypeSize - 1) - - var arr = newPyArray[Typ]() - arr.append Typ One - arr.append Typ Two - - arr.byteswap() - check arr[0] == One.safeShl[:Typ](Shift) - check arr[1] == Two.safeShl[:Typ](Shift) - - - testType cshort - testType cushort - - testType cint - #testType cuint # bug on Windows x86_64 - - # bug on Linux x86_64 - #testType clong - #testType culong - #[ XXX: NIM-BUG: -~/.cache/nim/test_array_d/@m..@s..@sbuiltins@slist_decl.nim.c:1394:15: error: incompatible types when assigning to type ‘tySequence__lBgZ7a89beZGYPl8PiANMTA’ from type ‘tySequence__UlOHMDjVW8svdcOWlYMPHA’ - 1394 | (*T1_).data = colontmpD_; - | ^~~~~~~~~~ - -T1_ is of seq[int] (colontmpD_ is of seq[clong]) -Why? - - ]# diff --git a/src/pylib/Lib/test/test_datetime.nim b/src/pylib/Lib/test/test_datetime.nim deleted file mode 100644 index e867aaa3a..000000000 --- a/src/pylib/Lib/test/test_datetime.nim +++ /dev/null @@ -1,674 +0,0 @@ - -import ./import_utils -importTestPyLib datetime - -let - #ZERO = timedelta(0) - #MINUTE = timedelta(minutes=1) - HOUR = timedelta(hours=1) - #DAY = timedelta(days=1) - DT = datetime(1970, 1, 1) - -template assertEqual(a, b) = check a == b - -template theclass: untyped = PyDatetime -template theclass(x: untyped, xs: varargs[untyped]): untyped = - init.datetime(x, xs) -from std/sugar import collect -suite "datetime": - test "utcoffset": - def test_utcoffset(): - dummy = DT - for h in [0.0, 1.5, 12.0]: - offset = h * HOUR - assertEqual(offset, timezone(offset).utcoffset(dummy)) - assertEqual(-offset, timezone(-offset).utcoffset(dummy)) - test_utcoffset() - - test "attrs": - def test_trivial(): - dt = datetime(1, 2, 3, 4, 5, 6, 7) - assertEqual(dt.year, 1) - assertEqual(dt.month, 2) - assertEqual(dt.day, 3) - assertEqual(dt.hour, 4) - assertEqual(dt.minute, 5) - assertEqual(dt.second, 6) - assertEqual(dt.microsecond, 7) - assertEqual(dt.tzinfo, None) - test_trivial() - - test "isoformat": - let t = datetime(1, 2, 3, 4, 5, 1, 123) - assertEqual(t.isoformat(), "0001-02-03T04:05:01.000123") - assertEqual(t.isoformat("T"), "0001-02-03T04:05:01.000123") - assertEqual(t.isoformat(" "), "0001-02-03 04:05:01.000123") - assertEqual(t.isoformat("\x00"), "0001-02-03\x0004:05:01.000123") - # bpo-34482: Check that surrogates are handled properly. - assertEqual(t.isoformat("\ud800"), - "0001-02-03\ud80004:05:01.000123") - assertEqual(t.isoformat(timespec="hours"), "0001-02-03T04") - assertEqual(t.isoformat(timespec="minutes"), "0001-02-03T04:05") - assertEqual(t.isoformat(timespec="seconds"), "0001-02-03T04:05:01") - assertEqual(t.isoformat(timespec="milliseconds"), "0001-02-03T04:05:01.000") - assertEqual(t.isoformat(timespec="microseconds"), "0001-02-03T04:05:01.000123") - assertEqual(t.isoformat(timespec="auto"), "0001-02-03T04:05:01.000123") - assertEqual(t.isoformat(sep=" ", timespec="minutes"), "0001-02-03 04:05") - expect(ValueError): - discard t.isoformat(timespec="foo") - # bpo-34482: Check that surrogates are handled properly. - expect(ValueError): - discard t.isoformat(timespec="\ud800") - # str is ISO format with the separator forced to a blank. - assertEqual(str(t), "0001-02-03 04:05:01.000123") - - def test_isoformat_timezone(): - tzoffsets = [ - ("05:00", timedelta(hours=5)), - ("02:00", timedelta(hours=2)), - ("06:27", timedelta(hours=6, minutes=27)), - ("12:32:30", timedelta(hours=12, minutes=32, seconds=30)), - ("02:04:09.123456", timedelta(hours=2, minutes=4, seconds=9, microseconds=123456)) - ] - # XXX: NIM-BUG: - # if using list here on debian when JS, you will get: - # Error: internal error: genTypeInfo(tyInferred) - tmp_tzinfos = ([ - (str(""), None.noneToTzInfo), - (str("+00:00"), UTC), - (str("+00:00"), timezone(timedelta(0))), - ]) - #when defined(js) and defined(debian): - tzinfos = @tmp_tzinfos - - for (expected, td) in tzoffsets: - for (prefix, sign) in [("-", -1), ("+", 1)]: - tzinfos.add( - (prefix + expected, tzinfo(timezone(sign * td))) - ) - dt_base = theclass(2016, 4, 1, 12, 37, 9) - exp_base = "2016-04-01T12:37:09" - - for (exp_tz, tzi) in tzinfos: - dt = dt_base.replace(tzinfo=tzi) - exp = exp_base + exp_tz - check dt.isoformat() == exp - test_isoformat_timezone() - - suite "fromisoformat": - test "if reversible": - let - # XXX: NIM-BUG: if places following in `def` without `let`: -#[ nim-2.2.0 -error: too few arguments to function eqcopy___OOZsrcZpylibZ76ibZdatetime95implZtimezone95implZdecl_u375' - 1688 | nimlf_(161, "E:\\program\\utils\\pylib\\src\\pylib\\Lib\\datetime_impl\\timezone_impl\\decl.nim"); eqcopy___OOZsrcZpylibZ76ibZdatetime95implZtimezone95implZdecl_u375(&v, v_2); - | - ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -]# - tzinfos = [None.noneToTzInfo, datetime.UTC, - timezone(timedelta(hours = -5)), - timezone(timedelta(hours = 2))] - def test_fromisoformat_datetime(): - # Test that isoformat() is reversible - base_dates = [ - (1, 1, 1), - (1900, 1, 1), - (2004, 11, 12), - (2017, 5, 30) - ] - - base_times = [ - (0, 0, 0, 0), - (0, 0, 0, 241000), - (0, 0, 0, 234567), - (12, 30, 45, 234567) - ] - - separators = [' ', 'T'] - - dts = collect: - for date_tuple in base_dates: - for time_tuple in base_times: - for tzi in tzinfos: - theclass( - date_tuple[0], date_tuple[1], date_tuple[2], - time_tuple[0], time_tuple[1], time_tuple[2], time_tuple[3], - tzinfo=tzi - ) - - for dt in dts: - for sep in separators: - dtstr = dt.isoformat(sep=sep) - dt_rt = theclass.fromisoformat(dtstr) - assertEqual(dt, dt_rt) - test_fromisoformat_datetime() - - #[ C compile error in list([timedelta(..)...]) - def test_fromisoformat_timezone(): - base_dt = theclass(2014, 12, 30, 12, 30, 45, 217456) - - tzoffsets = list([ - timedelta(hours=5), timedelta(hours=2), - timedelta(hours=6, minutes=27), - timedelta(hours=12, minutes=32, seconds=30), - timedelta(hours=2, minutes=4, seconds=9, microseconds=123456) - ]) - - for td in tzoffsets: - tzoffsets.append(-1 * td) - - tzinfos = list([None.noneToTzInfo, UTC, - timezone(timedelta(hours=0))]) - - for td in tzoffsets: - tzinfos.append(timezone(td)) - - for tzi in tzinfos: - dt = base_dt.replace(tzinfo=tzi) - dtstr = dt.isoformat() - - dt_rt = theclass.fromisoformat(dtstr) - check dt == dt_rt - test_fromisoformat_timezone() - ]# - - def test_fromisoformat_separators(): - separators = [ - " ", "T", "\u007f", # 1-bit widths - "\u0080", "ʁ", # 2-bit widths - "ᛇ", "時", # 3-bit widths - "🐍", # 4-bit widths - "\ud800", # bpo-34454: Surrogate code point - ] - - for sep in separators: - dt = theclass(2018, 1, 31, 23, 59, 47, 124789) - dtstr = dt.isoformat(sep=sep) - - dt_rt = theclass.fromisoformat(dtstr) - assertEqual(dt, dt_rt) - test_fromisoformat_separators() - - def test_fromisoformat_ambiguous(): - # Test strings like 2018-01-31+12:15 (where +12:15 is not a time zone) - separators = ['+', '-'] - for sep in separators: - dt = theclass(2018, 1, 31, 12, 15) - dtstr = dt.isoformat(sep=sep) - - block: - dt_rt = theclass.fromisoformat(dtstr) - assertEqual(dt, dt_rt) - test_fromisoformat_ambiguous() - - #[ hard to rewrite - def test_fromisoformat_timespecs(): - datetime_bases = [ - (2009, 12, 4, 8, 17, 45, 123456), - (2009, 12, 4, 8, 17, 45, 0)] - - tzinfos = [None, timezone.utc, - timezone(timedelta(hours=-5)), - timezone(timedelta(hours=2)), - timezone(timedelta(hours=6, minutes=27))] - - timespecs = ["hours", "minutes", "seconds", - "milliseconds", "microseconds"] - - for ip, ts in enumerate(timespecs): - for tzi in tzinfos: - for dt_tuple in datetime_bases: - if ts == "milliseconds": - new_microseconds = 1000 * (dt_tuple[6] // 1000) - dt_tuple = dt_tuple[0:6] + (new_microseconds,) - - dt = theclass(*(dt_tuple[0:(4 + ip)]), tzinfo=tzi) - dtstr = dt.isoformat(timespec=ts) - block: - dt_rt = theclass.fromisoformat(dtstr) - assertEqual(dt, dt_rt) - test_fromisoformat_timespecs() - ]# - - def test_fromisoformat_datetime_examples(): - BST = timezone(timedelta(hours=1), "BST") - EST = timezone(timedelta(hours = -5), "EST") - EDT = timezone(timedelta(hours = -4), "EDT") - examples = [ - ("2025-01-02", theclass(2025, 1, 2, 0, 0)), - ("2025-01-02T03", theclass(2025, 1, 2, 3, 0)), - ("2025-01-02T03:04", theclass(2025, 1, 2, 3, 4)), - ("2025-01-02T0304", theclass(2025, 1, 2, 3, 4)), - ("2025-01-02T03:04:05", theclass(2025, 1, 2, 3, 4, 5)), - ("2025-01-02T030405", theclass(2025, 1, 2, 3, 4, 5)), - ("2025-01-02T03:04:05.6", - theclass(2025, 1, 2, 3, 4, 5, 600000)), - ("2025-01-02T03:04:05,6", - theclass(2025, 1, 2, 3, 4, 5, 600000)), - ("2025-01-02T03:04:05.678", - theclass(2025, 1, 2, 3, 4, 5, 678000)), - ("2025-01-02T03:04:05.678901", - theclass(2025, 1, 2, 3, 4, 5, 678901)), - ("2025-01-02T03:04:05,678901", - theclass(2025, 1, 2, 3, 4, 5, 678901)), - ("2025-01-02T030405.678901", - theclass(2025, 1, 2, 3, 4, 5, 678901)), - ("2025-01-02T030405,678901", - theclass(2025, 1, 2, 3, 4, 5, 678901)), - ("2025-01-02T03:04:05.6789010", - theclass(2025, 1, 2, 3, 4, 5, 678901)), - ("2009-04-19T03:15:45.2345", - theclass(2009, 4, 19, 3, 15, 45, 234500)), - ("2009-04-19T03:15:45.1234567", - theclass(2009, 4, 19, 3, 15, 45, 123456)), - ("2025-01-02T03:04:05,678", - theclass(2025, 1, 2, 3, 4, 5, 678000)), - ("20250102", theclass(2025, 1, 2, 0, 0)), - ("20250102T03", theclass(2025, 1, 2, 3, 0)), - ("20250102T03:04", theclass(2025, 1, 2, 3, 4)), - ("20250102T03:04:05", theclass(2025, 1, 2, 3, 4, 5)), - ("20250102T030405", theclass(2025, 1, 2, 3, 4, 5)), - ("20250102T03:04:05.6", - theclass(2025, 1, 2, 3, 4, 5, 600000)), - ("20250102T03:04:05,6", - theclass(2025, 1, 2, 3, 4, 5, 600000)), - ("20250102T03:04:05.678", - theclass(2025, 1, 2, 3, 4, 5, 678000)), - ("20250102T03:04:05,678", - theclass(2025, 1, 2, 3, 4, 5, 678000)), - ("20250102T03:04:05.678901", - theclass(2025, 1, 2, 3, 4, 5, 678901)), - ("20250102T030405.678901", - theclass(2025, 1, 2, 3, 4, 5, 678901)), - ("20250102T030405,678901", - theclass(2025, 1, 2, 3, 4, 5, 678901)), - ("20250102T030405.6789010", - theclass(2025, 1, 2, 3, 4, 5, 678901)), - ("2022W01", theclass(2022, 1, 3)), - ("2022W52520", theclass(2022, 12, 26, 20, 0)), - ("2022W527520", theclass(2023, 1, 1, 20, 0)), # meaning 2022W527T20, a.k.a. 5 before 20 is just a sep - ("2026W01516", theclass(2025, 12, 29, 16, 0)), - ("2026W013516", theclass(2025, 12, 31, 16, 0)), - ("2025W01503", theclass(2024, 12, 30, 3, 0)), - ("2025W014503", theclass(2025, 1, 2, 3, 0)), - ("2025W01512", theclass(2024, 12, 30, 12, 0)), - ("2025W014512", theclass(2025, 1, 2, 12, 0)), - ("2025W014T121431", theclass(2025, 1, 2, 12, 14, 31)), - ("2026W013T162100", theclass(2025, 12, 31, 16, 21)), - ("2026W013 162100", theclass(2025, 12, 31, 16, 21)), - ("2022W527T202159", theclass(2023, 1, 1, 20, 21, 59)), - ("2022W527 202159", theclass(2023, 1, 1, 20, 21, 59)), - ("2025W014 121431", theclass(2025, 1, 2, 12, 14, 31)), - ("2025W014T030405", theclass(2025, 1, 2, 3, 4, 5)), - ("2025W014 030405", theclass(2025, 1, 2, 3, 4, 5)), - ("2020-W53-6T03:04:05", theclass(2021, 1, 2, 3, 4, 5)), - ("2020W537 03:04:05", theclass(2021, 1, 3, 3, 4, 5)), - ("2025-W01-4T03:04:05", theclass(2025, 1, 2, 3, 4, 5)), - ("2025-W01-4T03:04:05.678901", - theclass(2025, 1, 2, 3, 4, 5, 678901)), - ("2025-W01-4T12:14:31", theclass(2025, 1, 2, 12, 14, 31)), - ("2025-W01-4T12:14:31.012345", - theclass(2025, 1, 2, 12, 14, 31, 12345)), - ("2026-W01-3T16:21:00", theclass(2025, 12, 31, 16, 21)), - ("2026-W01-3T16:21:00.000000", theclass(2025, 12, 31, 16, 21)), - ("2022-W52-7T20:21:59", - theclass(2023, 1, 1, 20, 21, 59)), - ("2022-W52-7T20:21:59.999999", - theclass(2023, 1, 1, 20, 21, 59, 999999)), - ("2025-W01003+00", - theclass(2024, 12, 30, 3, 0, tzinfo=UTC)), - ("2025-01-02T03:04:05+00", - theclass(2025, 1, 2, 3, 4, 5, tzinfo=UTC)), - ("2025-01-02T03:04:05Z", - theclass(2025, 1, 2, 3, 4, 5, tzinfo=UTC)), - ("2025-01-02003:04:05,6+00:00:00.00", - theclass(2025, 1, 2, 3, 4, 5, 600000, tzinfo=UTC)), - ("2000-01-01T00+21", - theclass(2000, 1, 1, 0, 0, tzinfo=timezone(timedelta(hours=21)))), - ("2025-01-02T03:05:06+0300", - theclass(2025, 1, 2, 3, 5, 6, - tzinfo=timezone(timedelta(hours=3)))), - ("2025-01-02T03:05:06-0300", - theclass(2025, 1, 2, 3, 5, 6, - tzinfo=timezone(timedelta(hours = -3)))), - ("2025-01-02T03:04:05+0000", - theclass(2025, 1, 2, 3, 4, 5, tzinfo=UTC)), - ("2025-01-02T03:05:06+03", - theclass(2025, 1, 2, 3, 5, 6, - tzinfo=timezone(timedelta(hours=3)))), - ("2025-01-02T03:05:06-03", - theclass(2025, 1, 2, 3, 5, 6, - tzinfo=timezone(timedelta(hours = -3)))), - ("2020-01-01T03:05:07.123457-05:00", - theclass(2020, 1, 1, 3, 5, 7, 123457, tzinfo=EST)), - ("2020-01-01T03:05:07.123457-0500", - theclass(2020, 1, 1, 3, 5, 7, 123457, tzinfo=EST)), - ("2020-06-01T04:05:06.111111-04:00", - theclass(2020, 6, 1, 4, 5, 6, 111111, tzinfo=EDT)), - ("2020-06-01T04:05:06.111111-0400", - theclass(2020, 6, 1, 4, 5, 6, 111111, tzinfo=EDT)), - ("2021-10-31T01:30:00.000000+01:00", - theclass(2021, 10, 31, 1, 30, tzinfo=BST)), - ("2021-10-31T01:30:00.000000+0100", - theclass(2021, 10, 31, 1, 30, tzinfo=BST)), - ("2025-01-02T03:04:05,6+000000.00", - theclass(2025, 1, 2, 3, 4, 5, 600000, tzinfo=UTC)), - ("2025-01-02T03:04:05,678+00:00:10", - theclass(2025, 1, 2, 3, 4, 5, 678000, - tzinfo=timezone(timedelta(seconds=10)))), - ] - - for (input_str, expected) in examples: - block: - actual = theclass.fromisoformat(input_str) - assertEqual(actual, expected) - test_fromisoformat_datetime_examples() - - def test_fromisoformat_fails_datetime(): - # Test that fromisoformat() fails on invalid values - bad_strs = [ - "", # Empty string - "\ud800", # bpo-34454: Surrogate code point - "2009.04-19T03", # Wrong first separator - "2009-04.19T03", # Wrong second separator - "2009-04-19T0a", # Invalid hours - "2009-04-19T03:1a:45", # Invalid minutes - "2009-04-19T03:15:4a", # Invalid seconds - "2009-04-19T03;15:45", # Bad first time separator - "2009-04-19T03:15;45", # Bad second time separator - "2009-04-19T03:15:4500:00", # Bad time zone separator - "2009-04-19T03:15:45.123456+24:30", # Invalid time zone offset - "2009-04-19T03:15:45.123456-24:30", # Invalid negative offset - "2009-04-10ᛇᛇᛇᛇᛇ12:15", # Too many unicode separators - "2009-04\ud80010T12:15", # Surrogate char in date - "2009-04-10T12\ud80015", # Surrogate char in time - "2009-04-19T1", # Incomplete hours - "2009-04-19T12:3", # Incomplete minutes - "2009-04-19T12:30:4", # Incomplete seconds - "2009-04-19T12:", # Ends with time separator - "2009-04-19T12:30:", # Ends with time separator - "2009-04-19T12:30:45.", # Ends with time separator - "2009-04-19T12:30:45.123456+", # Ends with timzone separator - "2009-04-19T12:30:45.123456-", # Ends with timzone separator - "2009-04-19T12:30:45.123456-05:00a", # Extra text - "2009-04-19T12:30:45.123-05:00a", # Extra text - "2009-04-19T12:30:45-05:00a", # Extra text - ] - - for bad_str in bad_strs: - block: - expect(ValueError): - _ = theclass.fromisoformat(bad_str) - test_fromisoformat_fails_datetime() - - def test_fromisoformat_utc(): - dt_str = "2014-04-19T13:21:13+00:00" - dt = theclass.fromisoformat(dt_str) - - assertEqual(dt.tzinfo, UTC) - test_fromisoformat_fails_datetime() - test_fromisoformat_utc() - -class FixedOffset(tzinfo): - offset: timedelta - name: PyStr - dstoffset: timedelta - def init(self, offset: int, name, dstoffset=42): - offset = timedelta(days=0, minutes=offset) - dstoffset = timedelta(days=0, minutes=dstoffset) - self.offset = offset - self.name = name - self.dstoffset = dstoffset - def repr(self): - return self.name.lower() - def utcoffset(self, dt: datetime): - return self.offset - def tzname(self, dt: datetime): - return self.name - def dst(self, dt: datetime): - return self.dstoffset - -suite "timedelta": - test "init": - template eq(a, b) = check a == b - - # Check keyword args to constructor - eq(timedelta(1), timedelta(days=1)) - eq(timedelta(0, 1), timedelta(seconds=1)) - eq(timedelta(0, 0, 1), timedelta(microseconds=1)) - eq(timedelta(weeks=1), timedelta(days=7)) - eq(timedelta(days=1), timedelta(hours=24)) - eq(timedelta(hours=1), timedelta(minutes=60)) - eq(timedelta(minutes=1), timedelta(seconds=60)) - eq(timedelta(seconds=1), timedelta(milliseconds=1000)) - eq(timedelta(milliseconds=1), timedelta(microseconds=1000)) - - test "float init": - template eq(a, b) = check a == b - # from CPython/tests/datetimetester.py - eq(timedelta(weeks=1.0/7), timedelta(days=1)) - eq(timedelta(days=1.0/24), timedelta(hours=1)) - eq(timedelta(hours=1.0/60), timedelta(minutes=1)) - eq(timedelta(minutes=1.0/60), timedelta(seconds=1)) - eq(timedelta(seconds=0.001), timedelta(milliseconds=1)) - eq(timedelta(milliseconds=0.001), timedelta(microseconds=1)) - - test "normalize": - proc tG(delta: timedelta, days, seconds, microseconds: int64) = - check delta.days == days - check delta.seconds == seconds - check delta.microseconds == microseconds - tG timedelta(microseconds = -1), -1, 86399, 999999 - tG timedelta(days = -1, hours = -1, seconds = -59, microseconds = -1), - days = -2, seconds=82740, microseconds=999999 - tG timedelta(days = -2, hours = -3, seconds = -4559, microseconds = -5), - days = -3, seconds=71040, microseconds=999995 - tG timedelta(days = 2, hours = -3, seconds = -4, microseconds = -5), - days=1, seconds=75595, microseconds=999995 - - test "stringify": - template eq(a, b) = check a == b - def test_str(): - - eq(str(timedelta(1)), "1 day, 0:00:00") - eq(str(timedelta(-1)), "-1 day, 0:00:00") - eq(str(timedelta(2)), "2 days, 0:00:00") - eq(str(timedelta(-2)), "-2 days, 0:00:00") - - eq(str(timedelta(hours=12, minutes=58, seconds=59)), "12:58:59") - eq(str(timedelta(hours=2, minutes=3, seconds=4)), "2:03:04") - eq(str(timedelta(weeks = -30, hours=23, minutes=12, seconds=34)), - "-210 days, 23:12:34") - - eq(str(timedelta(milliseconds=1)), "0:00:00.001000") - eq(str(timedelta(microseconds=3)), "0:00:00.000003") - - # may overflow int64 - #eq(str(timedelta(days=999999999, hours=23, minutes=59, seconds=59, - # microseconds=999999)), - # "999999999 days, 23:59:59.999999") - test_str() - - -import std/macros -suite "date": - test "fromisocalendar": - def test_fromisocalendar(): - # For each test case, assert that fromisocalendar is the - # inverse of the isocalendar function - dates = [ - (2016, 4, 3), - (2005, 1, 2), # (2004, 53, 7) - (2008, 12, 30), # (2009, 1, 2) - (2010, 1, 2), # (2009, 53, 6) - (2009, 12, 31), # (2009, 53, 4) - (1900, 1, 1), # Unusual non-leap year (year % 100 == 0) - (1900, 12, 31), - (2000, 1, 1), # Unusual leap year (year % 400 == 0) - (2000, 12, 31), - (2004, 1, 1), # Leap year - (2004, 12, 31), - (1, 1, 1), - (9999, 12, 31), - (MINYEAR, 1, 1), - (MAXYEAR, 12, 31), - ] - - for datecomps in dates: - dobj = theclass(datecomps[0], datecomps[1], datecomps[2]) - isocal = dobj.isocalendar() - - d_roundtrip = theclass.fromisocalendar(isocal[0], isocal[1], isocal[2]) - - assertEqual(dobj, d_roundtrip) - test_fromisocalendar() - - test "fromisocalendar_value_errors": - def test_fromisocalendar_value_errors(): - isocals = [ - (2019, 0, 1), - (2019, -1, 1), - (2019, 54, 1), - (2019, 1, 0), - (2019, 1, -1), - (2019, 1, 8), - (2019, 53, 1), - (10000, 1, 1), - (0, 1, 1), - (9999999, 1, 1), - (2<<32, 1, 1), - (2019, 2<<32, 1), - (2019, 1, 2<<32), - ] - - for isocal in isocals: - expect(ValueError): - _ = PyDatetime.fromisocalendar(isocal[0], isocal[1], isocal[2]) - test_fromisocalendar_value_errors() - - test "ordinal_conversion": - def test_ordinal_conversions(): - # Check some fixed values. - for tup in [(1, 1, 1, 1), # calendar origin - (1, 12, 31, 365), - (2, 1, 1, 366), - # first example from "Calendrical Calculations" - (1945, 11, 12, 710347)]: - (y, m, day, n) = tup - d = theclass(y, m, day) - assertEqual(n, d.toordinal()) - fromord = theclass.fromordinal(n) - assertEqual(d, fromord) - if hasattr(fromord, "hour"): - # if we're checking something fancier than a date, verify - # the extra fields have been zeroed out - assertEqual(fromord.hour, 0) - assertEqual(fromord.minute, 0) - assertEqual(fromord.second, 0) - assertEqual(fromord.microsecond, 0) - - # Check first and last days of year spottily across the whole - # range of years supported. - for year in range(MINYEAR, MAXYEAR+1, 7): - # Verify (year, 1, 1) -> ordinal -> y, m, d is identity. - d1 = theclass(year, 1, 1) - n1 = d1.toordinal() - d2 = theclass.fromordinal(n1) - assertEqual(d1, d2) - # Verify that moving back a day gets to the end of year-1. - if year > 1: - d1 = theclass.fromordinal(n1-1) - d2 = theclass(year-1, 12, 31) - assertEqual(d1, d2) - assertEqual(d2.toordinal(), n1-1) - - # Test every day in a leap-year and a non-leap year. - dim = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31] - for (year, isleap) in [(2000, True), (2002, False)]: - n2 = theclass(year, 1, 1).toordinal() - for month, rmaxday in zip(range(1, 13), dim): - maxday = rmaxday - if month == 2 and isleap: - maxday += 1 - for day in range(1, maxday+1): - d3 = theclass(year, month, day) - assertEqual(d3.toordinal(), n2) - assertEqual(d3, theclass.fromordinal(n2)) - n2 += 1 - test_ordinal_conversions() - - test "replace": - macro replaceWith(dt: datetime, name: static string, x): datetime = - let nameId = ident name - result = quote do: - `dt`.replace(`nameId`=`x`) - const - changes = [("year", 2), - ("month", 3), - ("day", 4)] - args = [1, 2, 3] - macro test_replaceWith(base: datetime) = - result = newStmtList() - var i = 0 - for (name, newval) in changes: - let iD = newLit i - let - nameId = newLit name - newvalId = newLit newval - result.add quote do: - block: - var newargs = args - newargs[`iD`] = `newvalId` - let expected = theclass(newargs[0], newargs[1], newargs[2]) - assertEqual(replaceWith(`base`, `nameId`, `newvalId`), expected) - i += 1 - - def test_replace(): - base = theclass(args[0], args[1], args[2]) - assertEqual(base.replace(), base) - - test_replaceWith base - - # Out of bounds. - base = theclass(2000, 2, 29) - expect(ValueError): - _ = base.replace(year=2001) - test_replace() - - test "strftime": - def test_strftime(): - t = theclass(2005, 3, 2) - assertEqual(t.strftime("m:%m d:%d y:%Y"), "m:03 d:02 y:2005") - assertEqual(t.strftime(""), "") # SF bug #761337 - assertEqual(t.strftime('x'*1000), 'x'*1000) # SF bug #1556784 - - check not compiles(t.strftime) # needs an arg - check not compiles(t.strftime("one", "two")) # too many args - check not compiles(t.strftime(42)) # arg wrong type - - # test that unicode input is allowed (issue 2782) - assertEqual(t.strftime("%m"), "03") - - # A naive object replaces %z, %:z and %Z w/ empty strings. - assertEqual(t.strftime("'%z' '%:z' '%Z'"), "'' '' ''") - test_strftime() - test "ctime": - let t = theclass(2002, 3, 2) - assertEqual(t.ctime(), "Sat Mar 2 00:00:00 2002") - -importPyLib time -suite "tzinfo": - test "fromtimestamp": - template meth(xs: varargs[untyped]): datetime = - datetime.PyDatetime.fromtimestamp(xs) - def test_tzinfo_fromtimestamp(): - ts = time.time() - # Ensure it doesn't require tzinfo (i.e., that this doesn't blow up). - #base = meth(ts) - # Try with and without naming the keyword. - off42 = newFixedOffset(42, "42") - another = meth(ts, off42) - #again = meth(ts, tz=off42) - #assertIs(another.tzinfo, again.tzinfo) - assertEqual(another.utcoffset(), timedelta(minutes=42)) - test_tzinfo_fromtimestamp() diff --git a/src/pylib/Lib/test/test_errno.nim b/src/pylib/Lib/test/test_errno.nim deleted file mode 100644 index c82babc0b..000000000 --- a/src/pylib/Lib/test/test_errno.nim +++ /dev/null @@ -1,30 +0,0 @@ -##[Test the errno module - Roger E. Masse -]## - -import ./import_utils -importTestPyLib errno - -# std_c_errors = ["EDOM", "ERANGE"] - -template errnoEq(sym) = - let s = astToStr(sym) - check s == errorcode[sym] - -suite "ErrnoAttributeTests": - test "using_errorcode": - # Every key value in errno.errorcode should be on the module. - #for value in errno.errorcode.values(): check hasattr(errno, value) - errnoEq EDOM - errnoEq ERANGE - - -#[ -suite "ErrorcodeTests": - test "attributes_in_errorcode": - for attribute in errno.__dict__.keys(): - if attribute.isupper(): - self.assertIn(getattr(errno, attribute), errno.errorcode, - "no %s attr in errno.errorcode" % attribute) -]# - diff --git a/src/pylib/Lib/test/test_math.nim b/src/pylib/Lib/test/test_math.nim deleted file mode 100644 index 37d0b7ce3..000000000 --- a/src/pylib/Lib/test/test_math.nim +++ /dev/null @@ -1,331 +0,0 @@ -## Given many funcs in math wraps std/math, -## we only tests others - -import ./import_utils -importPyLib math -importPyLib sys -pyimport unittest -from std/unittest import suiteStarted, TestStatus, testStarted, suiteEnded, checkpoint, fail, TestResult, - suite, test, check, expect - -const - NINF = NegInf -const - # cached - F_INF = Inf - F_NINF = NegInf - F_NAN = NaN - -suite "gamma": - test "gamma(-integer)": - for i in (-1)..(-1000): - check isnan gamma float i - # XXX: TODO: PY-DIFF expect DomainError: discard gamma float i - -suite "ldexp": - proc test_call(): bool = - let res = ldexp(1.5, 2) - result = res == 6.0 - if not result: - echo "ldexp(", 1.5, ", ", 2, "), expected ", 6.0, " got ", res - check test_call() - const res = test_call() - check res - -suite "sumprod": - test "array": - let a = [1,2,3] - check 14.0 == sumprod(a,a) - - test "CPython:test_math.testSumProd": - template sumprod(a, b): untyped = math.sumprod(a, b) - def testSumProd(): - -#[ TODOL Decimal is not implemented (as of 0.9.3) - Decimal = decimal.Decimal - Fraction = fractions.Fraction -]# - - # Core functionality - #assertEqual(sumprod(iter([10, 20, 30]), (1, 2, 3)), 140) - assertEqual(sumprod([1.5, 2.5], [3.5, 4.5]), 16.5) - empI = [0] - assertEqual(sumprod(empI, empI), 0) - assertEqual(sumprod([-1.0], [1.0]), -1) - assertEqual(sumprod([1], [-1]), -1) - - -#[ : nim is static-typed - # Type preservation and coercion - for v in [ - (10, 20, 30), - (1.5, -2.5), - (Fraction(3, 5), Fraction(4, 5)), - (Decimal(3.5), Decimal(4.5)), - (2.5, 10), # float/int - (2.5, Fraction(3, 5)), # float/fraction - (25, Fraction(3, 5)), # int/fraction - (25, Decimal(4.5)), # int/decimal - ]: - for p, q in [(v, v), (v, v[::-1])]: - with subTest(p=p, q=q): - expected = sum(p_i * q_i for p_i, q_i in zip(p, q, strict=True)) - actual = sumprod(p, q) - assertEqual(expected, actual) - assertEqual(type(expected), type(actual)) -]# - - # Bad arguments - check not compiles(sumprod()) # No args - check not compiles(sumprod([0])) # One arg - check not compiles(sumprod([0], [0], [0])) # Three args - check not compiles(sumprod(None, [10])) # Non-iterable - check not compiles(sumprod([10], None)) # Non-iterable - check not compiles(sumprod(['x'], [1.0])) - - # Uneven lengths - expect(ValueError): discard sumprod([10, 20], [30]) - expect(ValueError): discard sumprod([10], [20, 30]) - - # Overflows -#[ : nim's int overflow - assertEqual(sumprod([10**20], [1]), 10**20) - assertEqual(sumprod([1], [10**20]), 10**20) - - assertRaises(OverflowError, sumprod, [10**1000], [1.0]) - assertRaises(OverflowError, sumprod, [1.0], [10**1000]) -]# - - assertEqual(sumprod([10**3], [10**3]), 10**6) - - -# SYNTAX-BUG: assertEqual(sumprod([10**7]*10**5, [10**7]*10**5), 10**19) - -#[ : static-typed - type ARuntimeError = object of CatchableError - # Error in iterator - def raise_after(n): - for i in range(n): - yield i - raise ARuntimeError - with assertRaises(ARuntimeError): - sumprod(range(10), raise_after(5)) - with assertRaises(ARuntimeError): - sumprod(raise_after(5), range(10)) -]# - -#[ - from test.test_iter import BasicIterClass - - assertEqual(sumprod(BasicIterClass(1), [1]), 0) - assertEqual(sumprod([1], BasicIterClass(1)), 0) -]# - -#[ : static-typed TODO - # Error in multiplication - type - MultiplyType = ref object of RootObj - BadMultiplyType = object of BadMultiplyType - - method `*`(self: MultiplyType) - func BadMultiply: BadMultiplyType = BadMultiplyType 0 - def `*`(self: BadMultiplyType, other): - raise ARuntimeError - def `*`(other: auto, self: BadMultiplyType): - raise ARuntimeError - expect (ARuntimeError): - sumprod([10, BadMultiply(), 30], [1, 2, 3]) - expect (ARuntimeError): - sumprod([1, 2, 3], [10, BadMultiply(), 30]) -]# - - - #[ - # Error in addition - with assertRaises(TypeError): - sumprod(['abc', 3], [5, 10]) - with assertRaises(TypeError): - sumprod([5, 10], ['abc', 3]) - ]# - - # Special values should give the same as the pure python recipe - assertEqual(sumprod([10.1, math.inf], [20.2, 30.3]), math.inf) - assertEqual(sumprod([10.1, math.inf], [math.inf, 30.3]), math.inf) - assertEqual(sumprod([10.1, math.inf], [math.inf, math.inf]), math.inf) - assertEqual(sumprod([10.1, -math.inf], [20.2, 30.3]), -math.inf) - assertTrue(math.isnan(sumprod([10.1, math.inf], [-math.inf, math.inf]))) - assertTrue(math.isnan(sumprod([10.1, math.nan], [20.2, 30.3]))) - assertTrue(math.isnan(sumprod([10.1, math.inf], [math.nan, 30.3]))) - assertTrue(math.isnan(sumprod([10.1, math.inf], [20.3, math.nan]))) - -#[ XXX: in nimpylib, result is -7.5 instead of 0.0 - # Error cases that arose during development - assertEqual( - sumprod( [-5.0, -5.0, 10.0], [1.5, 4611686018427387904.0, 2305843009213693952.0] ), - 0.0) -]# - testSumProd() - -suite "constants": - test "nan": - # `math.nan` must be a quiet NaN with positive sign bit - check (isnan(math.nan)) - check (copysign(1.0, nan) == 1.0) - test "inf": - check: - isinf(inf) - inf > 0.0 - inf == F_INF - -inf == F_NINF - -suite "classify": - # test "isnan": discard # isnan is alias of that in std/math - test "isinf": - check (isinf(F_INF)) - check (isinf(F_NINF)) - check (isinf(1E400)) - check (isinf(-1E400)) - check not (isinf(F_NAN)) - check not (isinf(0.0)) - check not (isinf(1.0)) - test "isfinite": - check: - isfinite(0.0) - isfinite(-0.0) - isfinite(1.0) - isfinite(-1.0) - not (isfinite(F_NAN)) - not (isfinite(F_INF)) - not (isfinite(F_NINF)) - -suite "nextafter_ulp": - template assertEqualSign(a, b) = - let - sa = copysign(1.0, a) - sb = copysign(1.0, b) - check sa == sb - template assertIsNaN(x) = - check isnan(x) - test "nextafter": - #@requires_IEEE_754 - def test_nextafter(): - # around 2^52 and 2^63 - assertEqual(math.nextafter(4503599627370496.0, -INF), - 4503599627370495.5) - assertEqual(math.nextafter(4503599627370496.0, INF), - 4503599627370497.0) - assertEqual(math.nextafter(9223372036854775808.0, 0.0), - 9223372036854774784.0) - assertEqual(math.nextafter(-9223372036854775808.0, 0.0), - -9223372036854774784.0) - - # around 1.0 - assertEqual(math.nextafter(1.0, -INF), - float_fromhex("0x1.fffffffffffffp-1")) - assertEqual(math.nextafter(1.0, INF), - float_fromhex("0x1.0000000000001p+0")) - assertEqual(math.nextafter(1.0, -INF, steps=1), - float_fromhex("0x1.fffffffffffffp-1")) - assertEqual(math.nextafter(1.0, INF, steps=1), - float_fromhex("0x1.0000000000001p+0")) - assertEqual(math.nextafter(1.0, -INF, steps=3), - float_fromhex("0x1.ffffffffffffdp-1")) - assertEqual(math.nextafter(1.0, INF, steps=3), - float_fromhex("0x1.0000000000003p+0")) - - # x == y: y is returned - for steps in range(1, 5): - assertEqual(math.nextafter(2.0, 2.0, steps=steps), 2.0) - assertEqualSign(math.nextafter(-0.0, +0.0, steps=steps), +0.0) - assertEqualSign(math.nextafter(+0.0, -0.0, steps=steps), -0.0) - - # around 0.0 - smallest_subnormal = sys.float_info.min * sys.float_info.epsilon - assertEqual(math.nextafter(+0.0, INF), smallest_subnormal) - assertEqual(math.nextafter(-0.0, INF), smallest_subnormal) - assertEqual(math.nextafter(+0.0, -INF), -smallest_subnormal) - assertEqual(math.nextafter(-0.0, -INF), -smallest_subnormal) - assertEqualSign(math.nextafter(smallest_subnormal, +0.0), +0.0) - assertEqualSign(math.nextafter(-smallest_subnormal, +0.0), -0.0) - assertEqualSign(math.nextafter(smallest_subnormal, -0.0), +0.0) - assertEqualSign(math.nextafter(-smallest_subnormal, -0.0), -0.0) - - # around infinity - largest_normal = sys.float_info.max - assertEqual(math.nextafter(INF, 0.0), largest_normal) - assertEqual(math.nextafter(-INF, 0.0), -largest_normal) - assertEqual(math.nextafter(largest_normal, INF), INF) - assertEqual(math.nextafter(-largest_normal, -INF), -INF) - - # NaN - assertIsNaN(math.nextafter(NAN, 1.0)) - assertIsNaN(math.nextafter(1.0, NAN)) - assertIsNaN(math.nextafter(NAN, NAN)) - - assertEqual(1.0, math.nextafter(1.0, INF, steps=0)) - expect(ValueError): - discard math.nextafter(1.0, INF, steps = -1) - test_nextafter() - test "ulp": - const FLOAT_MAX = high float64 - #@requires_IEEE_754 - def test_ulp(): - assertEqual(math.ulp(1.0), sys.float_info.epsilon) - # use int ** int rather than float ** int to not rely on pow() accuracy - assertEqual(math.ulp(2.0 ** 52), 1.0) - assertEqual(math.ulp(2.0 ** 53), 2.0) - assertEqual(math.ulp(2.0 ** 64), 4096.0) - - # min and max - assertEqual(math.ulp(0.0), - sys.float_info.min * sys.float_info.epsilon) - assertEqual(math.ulp(FLOAT_MAX), - FLOAT_MAX - math.nextafter(FLOAT_MAX, -INF)) - - # special cases - assertEqual(math.ulp(INF), INF) - assertIsNaN(math.ulp(math.nan)) - - # negative number: ulp(-x) == ulp(x) - for x in [0.0, 1.0, 2.0 ** 52, 2.0 ** 64, INF]: - #with subTest(x=x): - assertEqual(math.ulp(-x), math.ulp(x)) - test_ulp() - -suite "ldexp": - test "static": - const f = ldexp(1.0, 2) - static: assert f == 4.0, $f - test "small": - check: - ldexp(0.0, 1) == 0 - ldexp(1.0, 1) == 2 - ldexp(1.0, -1) == 0.5 - ldexp(-1.0, 1) == -2 - test "non-normal first arg": - check: - ldexp(INF, 30) == INF - ldexp(NINF, -213) == NINF - isnan(ldexp(NAN, 0)) - when c_int is int32: - test "large second arg": - # the following code from CPython is only for - # platform where c_int is int32 - for f in [1e5, 1e10]: - let n = int(f) - check: - ldexp(INF, -n) == INF - ldexp(NINF, -n) == NINF - ldexp(1.0, -n) == 0.0 - ldexp(-1.0, -n) == -0.0 - ldexp(0.0, -n) == 0.0 - ldexp(-0.0, -n) == -0.0 - isnan(math.ldexp(NAN, -n)) - expect OverflowDefect: discard ldexp(1.0, n) - expect OverflowDefect: discard ldexp(-1.0, n) - check: - ldexp(0.0, n) == 0.0 - ldexp(-0.0, n) == -0.0 - ldexp(INF, n) == INF - ldexp(NINF, n) == NINF - isnan(ldexp(NAN, n)) diff --git a/src/pylib/Lib/test/test_os.nim b/src/pylib/Lib/test/test_os.nim deleted file mode 100644 index 427a8abd2..000000000 --- a/src/pylib/Lib/test/test_os.nim +++ /dev/null @@ -1,15 +0,0 @@ - -import ./import_utils -importTestPyLib os - -suite "os.path": - test "if export right": - ## only test if os.path is correctly export - let s = os.path.dirname("1/2") - check s == "1" - check os.path.isdir(".") - assert os.path.join("12", "ab") == str("12") + os.sep + "ab" - - test "getxtime": - # TODO: more tests - discard getctime(".") diff --git a/src/pylib/Lib/test/test_os_nojs.nim b/src/pylib/Lib/test/test_os_nojs.nim deleted file mode 100644 index e541a752a..000000000 --- a/src/pylib/Lib/test/test_os_nojs.nim +++ /dev/null @@ -1,40 +0,0 @@ - -import ./import_utils -importTestPyLib os - -suite "Lib/os with no JS support": - const fn = "tempfiletest" - test "mkdir rmdir": - ## XXX: TODO: js's op currently only raises OSError itself - const invalidDir = "No one will name such a dir" - checkpoint "rmdir" - expect FileNotFoundError: - os.rmdir(invalidDir) - - checkpoint "mkdir" - expect FileNotFoundError: - # parent dir is not found - os.mkdir(invalidDir + os.sep + "non-file") - test "open fdopen close": - - template open(fd: int, s: string): untyped{.used.} = # this won't be called - doAssert false - io.open(fd, s) - let fd = open(fn, O_RDWR|O_CREAT|O_TRUNC) - var f = fdopen(fd, "w+") - ## XXX: only "w+" is not enough to make it perform trunc, - ## the fd must be opened with O_TRUNC - let s = "123" - f.write(s) - f.seek(0) - let res = f.read() - f.close() - check res == s - - test "get,set_inheritable": - let fd = os.open(fn, os.O_RDONLY) - defer: os.close(fd) - check not os.get_inheritable(fd) - - os.set_inheritable(fd, True) - check os.get_inheritable(fd) \ No newline at end of file diff --git a/src/pylib/Lib/test/test_pathlib.nim b/src/pylib/Lib/test/test_pathlib.nim deleted file mode 100644 index d21f49f11..000000000 --- a/src/pylib/Lib/test/test_pathlib.nim +++ /dev/null @@ -1,16 +0,0 @@ - - -import ./import_utils -importTestPyLib n_pathlib - -const pre = "__nimpylib_test_pathlib_" - -test "touch, unlink, is_file": - def f(): - p = Path(pre+"file") - assert not p.is_file() - p.touch() - check p.is_file() - p.unlink() - check not p.is_file() - f() diff --git a/src/pylib/Lib/test/test_pathlib_nojs.nim b/src/pylib/Lib/test/test_pathlib_nojs.nim deleted file mode 100644 index 14b4f37ed..000000000 --- a/src/pylib/Lib/test/test_pathlib_nojs.nim +++ /dev/null @@ -1,31 +0,0 @@ - - -import ./import_utils -importTestPyLib pathlib - -const pre = "__nimpylib_test_pathlib_" - - -when defined(posix): - test "touch, symlink_to, is_file, is_symlink, unlink": - def f(): - home = pathlib.Path.home() - ## XXX: do not use cwd, as there may not support create symlink - fn1 = pre + "file" - fn2 = pre + "symlink" - p1 = home / fn1 - p2 = home / fn2 - - assert not p1.is_file() - assert not p2.is_file() - p1.touch() - check(p1.is_file()) - p2.symlink_to(p1) - check(p2.is_symlink()) - - p1.unlink() - p2.unlink() - check(not p1.is_file()) - check(not p2.is_symlink()) - f() - diff --git a/src/pylib/Lib/test/test_string.nim b/src/pylib/Lib/test/test_string.nim deleted file mode 100644 index b75d4d65a..000000000 --- a/src/pylib/Lib/test/test_string.nim +++ /dev/null @@ -1,229 +0,0 @@ - - -import ./import_utils -importTestPyLib string -pyimport unittest - -var self = newTestCase() - -block test_capwords: - check "hello δδ".capwords == "Hello Δδ" ## support Unicode - check "01234".capwords == "01234" - - self.assertEqual(string.capwords("abc def ghi"), "Abc Def Ghi") - self.assertEqual(string.capwords("abc\tdef\nghi"), "Abc Def Ghi") - self.assertEqual(string.capwords("abc\t def \nghi"), "Abc Def Ghi") - self.assertEqual(string.capwords("ABC DEF GHI"), "Abc Def Ghi") - self.assertEqual(string.capwords("ABC-DEF-GHI", "-"), "Abc-Def-Ghi") - self.assertEqual(string.capwords("ABC-def DEF-ghi GHI"), "Abc-def Def-ghi Ghi") - self.assertEqual(string.capwords(" aBc DeF "), "Abc Def") - self.assertEqual(string.capwords("\taBc\tDeF\t"), "Abc Def") - self.assertEqual(string.capwords("\taBc\tDeF\t", "\t"), "\tAbc\tDef\t") - -block TestTemplate: - var - s: Template - block test_regular_templates: - s = Template("$who likes to eat a bag of $what worth $$100") - - self.assertEqual(s.substitute(dict(who="tim", what="ham")), - "tim likes to eat a bag of ham worth $100") - #self.assertRaises(KeyError, s.substitute, dict(who="tim")) - #self.assertRaises(TypeError, Template.substitute) - - expect KeyError: - let d = dict(who="tim") - discard s.substitute(d) - - template eq(a, b) = - mixin self; self.assertEqual(a, b) - template raises(t, c; args: varargs[untyped]) = - mixin self; self.assertRaises(t, c, args) - - def test_regular_templates_with_braces(self): - s = Template("$who likes ${what} for ${meal}") - d = dict(who="tim", what="ham", meal="dinner") - self.assertEqual(s.substitute(d), "tim likes ham for dinner") - #self.assertRaises(KeyError, s.substitute, - # dict(who="tim", what="ham")) - expect KeyError: - discard s.substitute dict(who="tim", what="ham") - - def test_regular_templates_with_upper_case(self): - s = Template("$WHO likes ${WHAT} for ${MEAL}") - d = dict(WHO="tim", WHAT="ham", MEAL="dinner") - self.assertEqual(s.substitute(d), "tim likes ham for dinner") - - def test_stringification(self): - - s = Template("tim has eaten $count bags of ham today") - d = dict(count=7) - eq(s.substitute(d), "tim has eaten 7 bags of ham today") - eq(s.safe_substitute(d), "tim has eaten 7 bags of ham today") - s = Template("tim has eaten ${count} bags of ham today") - eq(s.substitute(d), "tim has eaten 7 bags of ham today") - - def test_tupleargs(self): - - s = Template("$who ate ${meal}") - d = dict(who=("tim", "fred"), meal=("ham", "kung pao")) - eq(s.substitute(d), "('tim', 'fred') ate ('ham', 'kung pao')") - eq(s.safe_substitute(d), "('tim', 'fred') ate ('ham', 'kung pao')") - - def test_SafeTemplate(self): - - s = Template("$who likes ${what} for ${meal}") - eq(s.safe_substitute(dict(who="tim")), "tim likes ${what} for ${meal}") - eq(s.safe_substitute(dict(what="ham")), "$who likes ham for ${meal}") - eq(s.safe_substitute(dict(what="ham", meal="dinner")), - "$who likes ham for dinner") - eq(s.safe_substitute(dict(who="tim", what="ham")), - "tim likes ham for ${meal}") - eq(s.safe_substitute(dict(who="tim", what="ham", meal="dinner")), - "tim likes ham for dinner") - - def test_keyword_arguments(self): - - s = Template("$who likes $what") - eq(s.substitute(who="tim", what="ham"), "tim likes ham") - eq(s.substitute(dict(who="tim"), what="ham"), "tim likes ham") - eq(s.substitute(dict(who="fred", what="kung pao"), - who="tim", what="ham"), - "tim likes ham") - s = Template("the mapping is $mapping") - eq(s.substitute(dict(foo="none"), mapping="bozo"), - "the mapping is bozo") - eq(s.substitute(dict(mapping="one"), mapping="two"), - "the mapping is two") - - s = Template("the self is $self") - eq(s.substitute(self="bozo"), "the self is bozo") - - def test_keyword_arguments_safe(self): - - - s = Template("$who likes $what") - eq(s.safe_substitute(who="tim", what="ham"), "tim likes ham") - eq(s.safe_substitute(dict(who="tim"), what="ham"), "tim likes ham") - eq(s.safe_substitute(dict(who="fred", what="kung pao"), - who="tim", what="ham"), - "tim likes ham") - s = Template("the mapping is $mapping") - eq(s.safe_substitute(dict(foo="none"), mapping="bozo"), - "the mapping is bozo") - eq(s.safe_substitute(dict(mapping="one"), mapping="two"), - "the mapping is two") - d = dict(mapping="one") - raises(TypeError, s.substitute, d, {}) - raises(TypeError, s.safe_substitute, d, {}) - - s = Template("the self is $self") - eq(s.safe_substitute(self="bozo"), "the self is bozo") - - #[ - def test_delimiter_override(self): - - - class AmpersandTemplate(Template): - delimiter = "&" - s = AmpersandTemplate("this &gift is for &{who} &&") - eq(s.substitute(gift="bud", who="you"), "this bud is for you &") - raises(KeyError, s.substitute) - eq(s.safe_substitute(gift="bud", who="you"), "this bud is for you &") - eq(s.safe_substitute(), "this &gift is for &{who} &") - s = AmpersandTemplate("this &gift is for &{who} &") - raises(ValueError, s.substitute, dict(gift="bud", who="you")) - eq(s.safe_substitute(), "this &gift is for &{who} &") - - class PieDelims(Template): - delimiter = "@" - s = PieDelims("@who likes to eat a bag of @{what} worth $100") - self.assertEqual(s.substitute(dict(who="tim", what="ham")), - "tim likes to eat a bag of ham worth $100") - ]# - - def test_is_valid(self): - - s = Template("$who likes to eat a bag of ${what} worth $$100") - self.assertTrue(s.is_valid()) - - s = Template("$who likes to eat a bag of ${what} worth $100") - self.assertFalse(s.is_valid()) - - #[ - # if the pattern has an unrecognized capture group, - # it should raise ValueError like substitute and safe_substitute do - class BadPattern(Template): - pattern = r""" - (?P.*) | - (?P@{2}) | - @(?P[_a-z][._a-z0-9]*) | - @{(?P[_a-z][._a-z0-9]*)} | - (?P@) | - """ - s = BadPattern("@bag.foo.who likes to eat a bag of @bag.what") - self.assertRaises(ValueError, s.is_valid) - ]# - - #[ - XXX: NIM-BUG: as of - - Nim#1af88a2d20add67e3c376f0bc7144f9a0a843183 (@2.3.1) - - pylib#d8e3a84ecc270f43c219e823a88cb137029fd44b (@0.9.7) - - the following code lead Nim compile crash due to "call depth limit reached", - the recusive one is `compiler/sigmatch.nim(1269) typeRel` - ```nim - def f(x): ls = [0] - f(0) - ``` - - One workaround is to mark that argument's type, - so does following. - ]# - - def test_get_identifiers(self: TestCase): - ls = ["who", "what"] - - s = Template("$who likes to eat a bag of ${what} worth $$100") - ids = s.get_identifiers() - - eq(ids, ls) - - # repeated identifiers only included once - s = Template("$who likes to eat a bag of ${what} worth $$100; ${who} likes to eat a bag of $what worth $$100") - ids = s.get_identifiers() - eq(ids, ls) - - # invalid identifiers are ignored - s = Template("$who likes to eat a bag of ${what} worth $100") - ids = s.get_identifiers() - eq(ids, ls) - - #[ - # if the pattern has an unrecognized capture group, - # it should raise ValueError like substitute and safe_substitute do - class BadPattern(Template): - pattern = r""" - (?P.*) | - (?P@{2}) | - @(?P[_a-z][._a-z0-9]*) | - @{(?P[_a-z][._a-z0-9]*)} | - (?P@) | - """ - s = BadPattern("@bag.foo.who likes to eat a bag of @bag.what") - self.assertRaises(ValueError, s.get_identifiers) - ]# - - self.test_regular_templates_with_braces() - self.test_regular_templates_with_upper_case() - self.test_stringification() - self.test_tupleargs() - self.test_SafeTemplate() - - self.test_keyword_arguments() - self.test_keyword_arguments_safe() - - #self.test_delimiter_override() - self.test_is_valid() - self.test_get_identifiers() - diff --git a/src/pylib/Lib/test/test_tempfile.nim b/src/pylib/Lib/test/test_tempfile.nim deleted file mode 100644 index 19e63c36f..000000000 --- a/src/pylib/Lib/test/test_tempfile.nim +++ /dev/null @@ -1,15 +0,0 @@ - -import ./import_utils -importTestPyLib tempfile -from std/os import fileExists -test "Lib/tempfile": - var tname = "" - const cont = b"content" - with NamedTemporaryFile() as f: # open in binary mode by default - tname = f.name - f.write(cont) - f.flush() - check fileExists f.name - f.seek(0) - check f.read() == cont - check not fileExists tname diff --git a/src/pylib/Lib/test/test_time.nim b/src/pylib/Lib/test/test_time.nim deleted file mode 100644 index 3afd16d0d..000000000 --- a/src/pylib/Lib/test/test_time.nim +++ /dev/null @@ -1,42 +0,0 @@ - -import ./import_utils -importTestPyLib time - -test "Lib/time": - checkpoint "struct_time.__repr__" - check str(gmtime(0)) == "time.struct_time(tm_year=1970, tm_mon=1, tm_mday=1, tm_hour=0, tm_min=0, tm_sec=0, tm_wday=3, tm_yday=1, tm_isdst=0)" - type Self = object - t: float - let self = Self(t: time()) - - checkpoint "test_conversions" - - check int(time.mktime(time.localtime(self.t))) == int(self.t) - - check gmtime(0) == gmtime(0) - - checkpoint "strftime" - # the followings as can be run by Python just with one predefinition: - # def check(b): assert b - def chkEq(st, fmt, res): check(strftime(fmt, st) == res) - - def t_strfptime_date(): - st = strptime("1-6+2024", "%d-%m+%Y") - chkEq(st, "in %Y", "in 2024") - chkEq(st, "on %b.%d", "on Jun.01") - t_strfptime_date() - - def t_strfptime_time(): - st = strptime("2:<25:<06", "%S:<%M:<%H") - chkEq(st, "at %H o'clock", "at 06 o'clock") - chkEq(st, "with %S seconds", "with 02 seconds") - chkEq(st, "minutes: %M", "minutes: 25") - t_strfptime_time() - - def t_misc(): - "check date and time, as well as '%%'" - st = strptime("12:%:2 5$", "%m:%%:%d %H$") - chkEq(st, "%m %% %d", "12 % 02") - chkEq(st, "%H hours", "05 hours") - chkEq(st, "%M", "00") - t_misc() \ No newline at end of file diff --git a/src/pylib/Lib/test/test_timeit.nim b/src/pylib/Lib/test/test_timeit.nim deleted file mode 100644 index 9eeb320a4..000000000 --- a/src/pylib/Lib/test/test_timeit.nim +++ /dev/null @@ -1,13 +0,0 @@ - -import ./import_utils -importTestPyLib timeit -importPyLib time - -test "Lib/timeit": - def a_little_sleep(): - "sleep around 0.001 milsecs." - # note Nim's os.sleep's unit is milsec, - # while Python's time.sleep's is second. - sleep(0.001) - - check timeit(a_little_sleep, number=10) >= 0.01 \ No newline at end of file diff --git a/src/pylib/Lib/time.nim b/src/pylib/Lib/time.nim deleted file mode 100644 index fca959ac2..000000000 --- a/src/pylib/Lib/time.nim +++ /dev/null @@ -1,40 +0,0 @@ -##[ time - -Currently the implementation is `n_time module`_ . -The following is its doc: - -]## -import ./n_time -fetchDoc(docTable) - -import ../pystring/strimpl - -export sleep, measures -export types except isUtcZone, initStructTime -export toTuple -export struct_time_funcs - -const DefaultTimeFormat* = str DefaultTimeFormat - -proc asctime*(): PyStr = str n_time.asctime() - - -func asctime*(t: Some_struct_time): PyStr = - runnableExamples: - assert asctime(gmtime(0)) == "Thu Jan 1 00:00:00 1970" - str n_time.asctime t - -proc ctime*(): PyStr = str ctime() -proc ctime*(secs: float|int64): PyStr = - str n_time.ctime secs - -func strftime*(format: PyStr, st: Some_struct_time): PyStr{.fetchDoc(docTable).} = - str n_time.strftime($format, st) - -proc strftime*(format: PyStr): PyStr{.fetchDoc(docTable).} = - strftime format, localtime() - -proc strptime*(s: PyStr; format = DefaultTimeFormat): struct_time - {.fetchDoc(docTable).} = - n_time.strptime($s, $format) - diff --git a/src/pylib/Lib/time_impl/asctimeImpl.nim b/src/pylib/Lib/time_impl/asctimeImpl.nim deleted file mode 100644 index feb241012..000000000 --- a/src/pylib/Lib/time_impl/asctimeImpl.nim +++ /dev/null @@ -1,16 +0,0 @@ -## asctime that returns string - -import std/times - -template asctimeImpl*(result: string, dt: DateTime) = - result.add dt.format "ddd MMM " - # %2d - let day = dt.monthday.int - if day < 10: - result.add ' ' - result.add $day - result.add ' ' - result.add dt.format "HH:mm:ss uuuu" - -func asctime*(dt: DateTime): string = - asctimeImpl(result, dt) diff --git a/src/pylib/Lib/time_impl/converters.nim b/src/pylib/Lib/time_impl/converters.nim deleted file mode 100644 index 54c87e8e0..000000000 --- a/src/pylib/Lib/time_impl/converters.nim +++ /dev/null @@ -1,72 +0,0 @@ - -import ./types -import ./private/macro_utils -import std/times - -template wrapTuple*(sym, tupType){.dirty.} = - ## wrap a func `sym(struct_time)` - ## to accept `tupType` too. - bind asgSeqToObj, initStructTime - func sym*(tup: tupType): typeof(sym(initStructTime())) = - var st = initStructTime() - asgSeqToObj(tup, st) - sym st - -template wrapTuple*(sym){.dirty.} = - ## wrap a func `sym(struct_time)` - ## to accept `struct_time_tuple*`, too. - wrapTuple sym, struct_time_tuple - wrapTuple sym, struct_time_tuple10 - wrapTuple sym, struct_time_tuple11 - -template gen_init(tupType) = - func struct_time*(tup: tupType): struct_time = - result = initStructTime() - asgSeqToObj(tup, result) - -gen_init struct_time_tuple -gen_init struct_time_tuple10 -gen_init struct_time_tuple11 - -converter toTuple*(st: struct_time): struct_time_tuple = - ## XXX: `tuple` is Nim's keyword, so no symbol can be named `tuple` - ( - st.tm_year, - st.tm_mon, - st.tm_mday, - st.tm_hour, - st.tm_min, - st.tm_sec, - st.tm_wday, - st.tm_yday, - st.tm_isdst, - ) - -func dtToStructTime*(dt: DateTime, res: var struct_time) = - res = initStructTime( - dt.year, - dt.month.int, - dt.monthday, - dt.hour, - dt.minute, - dt.second, - dt.weekday.int, - dt.yearday + 1, - dt.isDst.int, - dt.timezone.name, - -dt.utcOffset - ) - -func structTimeToDt*(st: struct_time, res: var DateTime) = - let mon = st.tm_mon.Month - {.noSideEffect.}: - res = dateTime( - st.tm_year, - mon, - st.tm_mday, - st.tm_hour, - st.tm_min, - st.tm_sec, - zone=(if st.isUtcZone: utc() else: local()) - ) - assert st.tm_wday == res.weekday.int diff --git a/src/pylib/Lib/time_impl/doc/nstrfptime.rst b/src/pylib/Lib/time_impl/doc/nstrfptime.rst deleted file mode 100644 index 7afec2c11..000000000 --- a/src/pylib/Lib/time_impl/doc/nstrfptime.rst +++ /dev/null @@ -1,5 +0,0 @@ -.. warning:: A few of the format directives for `strftime`/`strptime` are not supported, - and using them causes `AssertDefect`. They are listed in - `nstrfptime.NotImplDirectives`_ -.. hint:: Some directives (only for strftime) whose implementents are platform-depend - in CPython are always supported here: '%V' '%G' '%g' \ No newline at end of file diff --git a/src/pylib/Lib/time_impl/doc/nstrptime.rst b/src/pylib/Lib/time_impl/doc/nstrptime.rst deleted file mode 100644 index 3b3f36aca..000000000 --- a/src/pylib/Lib/time_impl/doc/nstrptime.rst +++ /dev/null @@ -1,10 +0,0 @@ -.. warning:: In current implementation, - whitespace in format string means itself AS-IS, unlike C or Python, - where any whitespace means a serial of any whitespaces. If really - wanting the behavior of C's, consider using `std/strscan`. - -.. warning:: Current `strptime` - is just locale-unaware, when it comes to - "the locale's format", like `"%x"`, it always uses the format of - `"C" locale`, no matter what the locale is. a.k.a. Changing - locale via C's api in `` doesn't affect this function. diff --git a/src/pylib/Lib/time_impl/measures.nim b/src/pylib/Lib/time_impl/measures.nim deleted file mode 100644 index c7989fca8..000000000 --- a/src/pylib/Lib/time_impl/measures.nim +++ /dev/null @@ -1,47 +0,0 @@ -## .. hint:: -## all functions are pretended as `noSideEffect` pramga, -## as I myself doesn't think noSideEffect means pure function, -## but pure function is must noSideEffect, the opposite is not true. -## However, Nim manual seems to mixin them. -## - -import std/times -import std/monotimes - -func time*(): float = - {.noSideEffect.}: - epochTime() # getTime().toUnixFloat() - -const ns_per_s = 1_000_000_000 -func time_ns*(): int64 = - {.noSideEffect.}: - let t = getTime() - type R = typeof(result) - result = R t.nanosecond - result += R(t.toUnix) * ns_per_s - -when not defined(js): - func process_time*(): float = - ## not available for JS backend, currently. - {.noSideEffect.}: - cpuTime() - -func monotonic_ns*(): int64 = - template impl: untyped = getMonoTime().ticks() - when defined(windows): impl - else: - {.noSideEffect.}: - result = impl - -func monotonic*(): float = - when defined(js): - monotonic_ns().float / ns_per_s - # see Nim#23746 - # JS only: without `.float`, compile fail - # JS failed to compile `int64/int64` - else: - monotonic_ns().float / ns_per_s - -func perf_counter*(): float = monotonic() -func perf_counter_ns*(): int64 = monotonic_ns() - diff --git a/src/pylib/Lib/time_impl/nstrfptime.nim b/src/pylib/Lib/time_impl/nstrfptime.nim deleted file mode 100644 index 877c4e631..000000000 --- a/src/pylib/Lib/time_impl/nstrfptime.nim +++ /dev/null @@ -1,194 +0,0 @@ -## strftime, strptime -## -## platform independent implementation. -import ./private/doc_utils - -# if let:`const docTable = initDocTable(...)` shown in doc, -# a large lump of data will occur in doc. -let docTableInner{.compileTime.} = - when defined(nimdoc): - const - strfpDoc = slurp"./doc/nstrfptime.rst" - strpDoc = slurp"./doc/nstrptime.rst" - static: # `slurp` will fail silently if such a file doesn't exist - assert strfpDoc.len != 0 - assert strpDoc.len != 0 - initDocTable( - strfpDoc, { - "strptime": strpDoc - }) - else: - default DocTable -let docTable*{.compileTime.} = docTableInner ##\ -## used to transport doc string to outer module. - -export fetchDoc - -import std/strutils -import std/times - -const NotImplDirectives* = {'y', 'Z' -} ## Here are their concrete meanings in Python, - ## as well as some notes about why they cannot be directly mapped to - ## Nim's DateTime.format/parse. - ## - ## The direct alternative value when formatting in Nim, - ## if any, is introduced by `<-`: - ## - ## - y: Year without century as a decimal number `[00,99]`. <- DateTime.format"yy" - ## When parsing, C/Python's %y use 20th or 21th centry - ## depending on the value of %y - ## Nim's yy use the current century - ## - Z: Time zone name (no characters if no time zone exists). Deprecated. - ## However, this is supported in Lib/datetime - ## - ## Following are strftime only currently: - ## - ## - j: Day of the year as a decimal number `[001,366]`. <- DateTime.yearday + 1 - ## - u: Weekday `[0(Monday), 6]`. <- DateTime.weekday.int - ## - w: Weekday `[0(Sunday),6]`. <- (DateTime.weekday.int + 1) mod 7 - ## - U: Week number of the year (Sunday as the first day of the week) - ## as a decimal number `[00,53]`. - ## All days in a new year preceding the first Sunday are considered - ## to be in week 0. - -func notImplErr(c: char) = - var msg = "not implement format directives: %" & c - if c == 'Z': - msg.add ", which is deprecated by Python." - assert false, msg - -template raiseUnknownDirective(c: char, fmt: string) = - raise newException(ValueError, "'$#' is a bad directive in format format: $#".format(c, repr(fmt))) - -template raiseStrayPercent(fmt: string) = - raise newException(ValueError, "stray % in format " & repr(fmt)) - -const - Tp = "H:m:s" - Tf = "HH:mm:ss" - `%Y` = "uuuu" -const - `xp` = "ddd M d" - `xf` = "ddd MM dd" - `Xp` = Tp - `Xf` = Tf - `space%Y` = ' ' & `%Y` - `cp` = xp & ' ' & Xp & `space%Y` - `cf` = xf & ' ' & Xf & `space%Y` - -template cStyle(cstr: string; - handleSnippet; # Callable[[string, int, int], void] - doWith; # Callable[[string], void]; handle Nim's formatStr - handlePercent; # Callable[[], void] - noNimEquivHandle = notImplErr, - handleUnknownDirective = raiseUnknownDirective, - forParse: static[bool] = false, - ) = - let le = cstr.len - template fmtOrP(fmt): string = - when forParse: fmt[1..^1] else: fmt - template fmtOrP(fmt, parse): string = - when forParse: parse else: fmt - let hi = le - 1 - var i = 0 - while i < le: - let idx = cstr.find('%', i) - if idx == -1: - handleSnippet cstr, i, le - return - if idx == hi: - when forParse: - raiseStrayPercent cstr - if unlikely idx != 0: - handleSnippet cstr, i, idx - - i = idx + 1 - let c = cstr[i] - case c - of '%': handlePercent() - # Year - of 'Y': doWith `%Y` - # Month - of 'b': doWith "MMM" - of 'B': doWith "MMMM" - of 'm': doWith fmtOrP "MM" - # Day - of 'd': doWith fmtOrP "dd" - # Weekday - of 'a': doWith "ddd" - of 'A': doWith "dddd" - # Hour, Minute, Second - of 'H': doWith fmtOrP "HH" - of 'I': doWith fmtOrP "hh" - of 'M': doWith fmtOrP "mm" - of 'S': doWith fmtOrP "ss" - # Microsecond - of 'f': doWith "ffffff" # XXX: on Python %f is not for time.strftime() - # Other - of 'z': doWith "ZZZ" - of 'p': doWith "tt" - of 'x': doWith fmtOrP(xf, xp) - of 'X': doWith fmtOrP(Xf, Xp) - of 'c': doWith fmtOrP(cf, cp) - of 'F': doWith fmtOrP(`%Y` & "-MM-dd", `%Y` & "-M-d") - of 'T': doWith fmtOrP(Tf, Tp) - of NotImplDirectives: - noNimEquivHandle c - else: - handleUnknownDirective(c, cstr) - i.inc - - -func strftime*(format: string, dt: DateTime): string - {.fetchDoc(docTable).} = - result = newStringOfCap format.len - template handleSnippet(s, start, stop) = - result.add s[start.. aLen: - error $obj & " takes an at most $#-sequence ($#-sequence given)" - .format(aLen, tupLen) - #const BetterTypeMismatchErrMsg = true - when false: #BetterTypeMismatchErrMsg: - let namedTuple = tupType.kind == nnkTupleTy - for i in 0.. 0: - result[0] = bAttrs - -func attrList(a, b: NimNode, stragy: CmpStragy): AttrList = - case stragy - of csLhs: a.getAttrList - of csRhs: b.getAttrList - of csEq: getEqAttrList(a, b) - of csShorter: getShorterAttrList(a, b)[0] - -proc orderOnFieldsImpl(a, b: NimNode; cs: CmpStragy = csEq, - cmpOp=ident"=="): NimNode = - let attrs = attrList(a, b, cs) - result = newLit true - for attr in attrs: - let - aVal = attr - bVal = newDotExpr(b, attr[1]) - let eq = newNimNode(nnkInfix).add(cmpOp, aVal, bVal) - result = infix(result, "and", eq) - -macro mixinOrderOnFields*( - lhs, rhs: typed; - cmpOp; cmpStragy: static[CmpStragy] = csEq): bool = - ## cmpOnFields but `a` `b` can be of different types. - ## - ## e.g. a is tuple and b is object; or a, b are different objects. - ## - orderOnFieldsImpl lhs, rhs, cmpStragy, cmpOp - -macro orderOnFields*[T](a, b: T; - cmpOp): bool = - ## mainly for checking if ref objects are equal on fields - ## - ## when for object/tuple and cmpOp is `==`, roughly equal to: a == b - ## - ## but system.`==` for ref just compare the address. - orderOnFieldsImpl a, b, csLhs, cmpOp - -proc cmpOnFieldsImpl(a, b: NimNode; cmpOp=ident"cmp"): NimNode = - let - aAttr = a.getAttrList - bAttr = b.getAttrList - aLen = aAttr.len - bLen = bAttr.len - lenDiff = aLen - bLen - minLen = if lenDiff > 0: bLen else: aLen - result = newStmtList() - let res = genSym(nskVar, "cmpRes") - result.add newVarStmt(res, newLit 0) - let blkLab = genSym(nskLabel, "blkLab") - var blkBody = newStmtList() - let brkBlk = nnkBreakStmt.newTree blkLab - for i in 0..= new Date()){} - """.} -template sleep*(s: int|float) = - ## raises ValueError if s < 0 - bind sleep, sleep_neg_raise_or2ms, audit - sys.audit("time.sleep", s) - # also prevent `s` being eval-ed twice. - let ms = sleep_neg_raise_or2ms(s) - sleep(milsecs=ms) # param name based overload diff --git a/src/pylib/Lib/time_impl/strfptime.nim b/src/pylib/Lib/time_impl/strfptime.nim deleted file mode 100644 index beaf6203b..000000000 --- a/src/pylib/Lib/time_impl/strfptime.nim +++ /dev/null @@ -1,23 +0,0 @@ -import std/times -import ./types, ./converters, ./nstrfptime - -fetchDoc(docTable) -export fetchDoc, docTable - -func strftime*(format: string, st: struct_time): string{.fetchDoc(docTable).} = - var dt: DateTime - structTimeToDt st, dt - strftime format, dt - -func strftime*[S](format: S, st: struct_time): S = - ## EXT. - S(strftime($format, st)) - -func strftime*(format: string, st: Some_struct_time_tuple): string - {.fetchDoc(docTable).} = - strftime format, struct_time st - -proc strptime*(s: string, f: string): struct_time{.fetchDoc(docTable).} = - var dt: DateTime - dt.strptime(s, f) - dtToStructTime dt, result diff --git a/src/pylib/Lib/time_impl/struct_time_funcs.nim b/src/pylib/Lib/time_impl/struct_time_funcs.nim deleted file mode 100644 index 30d98eabe..000000000 --- a/src/pylib/Lib/time_impl/struct_time_funcs.nim +++ /dev/null @@ -1,37 +0,0 @@ -## funcs about struct_time -## -## its initializer, and a inverse function `mktime` - -import std/times -import ./types, ./converters - -proc gmtime*(): struct_time = dtToStructTime(now().inZone(utc()), result) -proc localtime*(): struct_time = dtToStructTime(now(), result) - -proc gmtime*(secs: int64): struct_time = - let t = fromUnix secs - let dt = t.utc() - dtToStructTime(dt, result) - -proc localtime*(secs: int64): struct_time = - let t = fromUnix secs - let dt = t.local() - dtToStructTime(dt, result) - -proc gmtime*(secs: float): struct_time = - let t = fromUnixFloat secs - let dt = t.utc() - dtToStructTime(dt, result) - -proc localtime*(secs: float): struct_time = - let t = fromUnixFloat secs - let dt = t.local() - dtToStructTime(dt, result) - - -func mktime*(t: struct_time): float = - var dt: DateTime - structTimeToDt(t, dt) - dt.toTime().toUnixFloat() - -wrapTuple mktime, struct_time_tuple diff --git a/src/pylib/Lib/time_impl/types.nim b/src/pylib/Lib/time_impl/types.nim deleted file mode 100644 index aef08363d..000000000 --- a/src/pylib/Lib/time_impl/types.nim +++ /dev/null @@ -1,111 +0,0 @@ - -import std/times -import ./private/macro_utils - -type - struct_time* = ref object - tm_year*: int - tm_mon*: range[1 .. 12] - tm_mday*: MonthdayRange - tm_hour*: HourRange - tm_min*: MinuteRange - tm_sec*: range[0 .. 61] # SecondRange is range[0 .. 60] - tm_wday*: range[0 .. 6] - tm_yday*: range[1 .. 366] # YeardayRange is range[0 .. 365] - tm_isdst*: int - tm_zone*: string ## .. warning:: curently is only "LOCAL" or "Etc/UTC" - tm_gmtoff*: int - -const STRUCT_TM_ITEMS = 9 - -declTupleWithNFieldsFrom(struct_time_tuple, struct_time, STRUCT_TM_ITEMS) -declTupleWithNFieldsFrom(struct_time_tuple10, struct_time, STRUCT_TM_ITEMS+1) -declTupleWithNFieldsFrom(struct_time_tuple11, struct_time, STRUCT_TM_ITEMS+2) - -type - Some_struct_time_tuple* = struct_time_tuple | struct_time_tuple10 | struct_time_tuple11 - Some_struct_time* = struct_time | Some_struct_time_tuple - -template isUtcZone*(st: struct_time): bool = - ## zone is only local or utc - st.tm_gmtoff == 0 - -template initStructTime*(): struct_time = - bind struct_time - struct_time( - tm_year: 1900, - tm_mon: 1, tm_mday: 1, - tm_yday: 1, - tm_isdst: -1) - -template initStructTime*( - year, - mon, - mday, - hour, - min, - sec, - wday, - yday, - isdst, - zone, - gmtoff -): struct_time = - bind struct_time - struct_time( - tm_year: year, - tm_mon: mon, - tm_mday: mday, - tm_hour: hour, - tm_min: min, - tm_sec: sec, - tm_wday: wday, - tm_yday: yday, - tm_isdst: isdst, - tm_zone: zone, - tm_gmtoff:gmtoff - ) - -func repr*(st: struct_time): string = - ## struct_time.__repr__ - ## - ## returns string starting with `"time.struct_time"` - ## with 9 fields. - # len "time.struct_time()": 18 - # fields' names: 61; equal signs: 9; ", ": 16; fields' value: <=20 - # sum up to 124 - result = newStringOfCap 124 - result.add "time.struct_time(" - result.addFields(st, STRUCT_TM_ITEMS) - result.add ")" - - -template genOrder(cmpOp){.dirty.} = - func cmpOp*(a, b: struct_time): bool = - ## compares based on fields. - orderOnFields a, b, cmpOp - func cmpOp*(a: struct_time, b: struct_time_tuple11): bool = - ## compares based on fields. - mixinOrderOnFields a, b, cmpOp, cmpStragy=csLhs - func cmpOp*(a: struct_time_tuple11, b: struct_time): bool = - ## compares based on fields. - mixinOrderOnFields a, b, cmpOp, cmpStragy=csRhs - -genOrder `==` -genOrder `<=` -genOrder `<` - -using st: struct_time - -func `==`*(st; t: tuple): bool{.inline.} = false -func `==`*(t: tuple; st): bool{.inline.} = false - -func cmp(st; t: tuple): int = cmpOnField st, t -func cmp(t: tuple; st): int = -cmp(st, t) - -template genOrderOnCmp(cmpOp){.dirty.} = - func cmpOp*(st; t: tuple): bool = cmpOp cmp(st, t), 0 - func cmpOp*(t: tuple; st): bool = cmpOp cmp(t, st), 0 - -genOrderOnCmp `<` -genOrderOnCmp `<=` diff --git a/src/pylib/Lib/timeit.nim b/src/pylib/Lib/timeit.nim deleted file mode 100644 index 4ecae878d..000000000 --- a/src/pylib/Lib/timeit.nim +++ /dev/null @@ -1,61 +0,0 @@ - -import ./n_timeit -import ../noneType -import ../builtins/list -import ../version -import ./sys -export list, noneType - -pysince(3,3): - const TimeItUseTime*{.booldefine: "timeit.usetime".} = true ## \ - ## disable this if don't wanna depending on `Lib/time` - when TimeItUseTime: - import ./time - -export n_timeit except newTimer, repeat, print_exc, default_repeat, default_timer - -when TimeItUseTime: - var default_timer* = pysince(3.3, time.perf_counter, n_timeit.default_timer) -else: export n_timeit.default_timer - -template repeatImpl(xs: varargs[untyped]): untyped = n_timeit.repeat(xs) ##\ -## to avoid `repeat`'s repeat param being replaced - -const default_repeat* = pysince(3.7, 5, 3) ##\ - ## since python 3.7: default value of `repeat` parameter is changed from 3 to 5. - -template repeat*( - stmt: TimeitParam = NullStmt; - setup: TimeitParam = NullStmt; - timer=default_timer, repeat=pysince(3.7, 5, 3), #[here uses inline for clearer doc]# - number=default_number): PyList[float] = - runnableExamples: - assert len(repeat(repeat=0)) == 0 - bind repeatImpl, list - var repeatVal{.noInit.} = repeat - ##[ XXX: NIM-BUG: - currently NIM will unconditionally init `repeatVal` (a.k.a. firstly set to 0) - even though it's marked as `let` (readonly variable). - if using `let repeatVal = ...`, C' compile complains sth like: - `error: assignment of read-only variable 'repeatValX60gensym0___timeit95examples951_u5'` - ]## - list repeatImpl(stmt, setup, timer, repeatVal, number) - - -template repeat*(self: Timer, repeat=pysince(3.7, 5, 3), #[here uses inline for clearer doc]# - number=default_number): PyList[float] = - bind list - var repeatVal{.noInit.} = repeat - list n_timeit.repeat(self, repeatVal,number) - -template autorange*(self: Timer, callable=None): (int, float){.pysince(3,6).} = - bind autorange - autorange(self, nil) - -template sys_stderr: untyped = sys.stderr -proc print_exc*(self: Timer, file: auto = None) = - bind print_exc, sys_stderr - print_exc(self, - when file is NoneType: sys_stderr - else: file - ) diff --git a/src/pylib/Lib/types.nim b/src/pylib/Lib/types.nim deleted file mode 100644 index 2c33c85b8..000000000 --- a/src/pylib/Lib/types.nim +++ /dev/null @@ -1,10 +0,0 @@ - - -import ../version -import ../noneType - -const PyVer = (PyMajor, PyMinor) -when PyVer > (3, 10): - export NoneType - - diff --git a/src/pylib/Lib/types_impl/debugs.nim b/src/pylib/Lib/types_impl/debugs.nim deleted file mode 100644 index a22917717..000000000 --- a/src/pylib/Lib/types_impl/debugs.nim +++ /dev/null @@ -1,128 +0,0 @@ - -##[ - .. note:: almost all functionalities here is only available in debug mode, - e.g. not when `-d:release` -]## - - -#[ -# dev-manual - -## types -StackTraceEntry = object - procname*: cstring ## Name of the proc that is currently executing. - line*: int ## Line number of the proc that is currently executing. - filename*: cstring ## Filename of the proc that is currently executing. - ... - -PFrame = ptr TFrame -TFrame {.importc, nodecl, final.} = object - prev*: PFrame ## Previous frame; used for chaining the call stack. - procname*: cstring ## Name of the proc that is currently executing. - line*: int ## Line number of the proc that is currently executing. - filename*: cstring ## Filename of the proc that is currently executing. - len*: int16 ## Length of the inspectable slots. - calldepth*: int16 ## Used for max call depth checking. - -## procs - -proc getStackTraceEntries([e: ref Exception]): seq[StackTraceEntry] -proc getFrame(): PFrame - -]# - -type - FrameType*{.acyclic.} = ref object - # RO - f_back: FrameType - #[f_code*: - f_locals*: - f_globals*: - f_builtins*: ]# - f_lasti*: int ## Always 0 here, see `TracebackType`_ for details - - # RW - f_lineno*: int - - TracebackType*{.acyclic.} = ref object - # RO - tb_frame: FrameType - tb_lineno: int - tb_lasti*: int ## .. note:: as Nim is a compile-language, - ## no opcode here, so this attr is always 0 - - # RW - tb_next*: TracebackType - -func f_back*(f: FrameType): FrameType = self.f_back - - -func tb_frame*(tb: TracebackType): FrameType = self.tb_frame -func tb_lineno*(tb: TracebackType): FrameType = self.tb_lineno - - -proc newPyFrame*(f: PFrame = getFrame()): FrameType = - FrameType( - f_back: f.prev, - f_lineno: f.line - ) -proc newPyFrame*(f: StackTraceEntry, f_back: FrameType = nil, f_lasti=0): FrameType = - FrameType( - f_back: f_back, - f_lineno: f.line, - f_lasti: f_lasti, - ) - -proc newPyTraceback*(st: StackTraceEntry, f: PFrame, tb_next: TracebackType = nil): TracebackType = - let pyf = newPyFrame f - TracebackType( - tb_frame: pyf, - tb_lineno: f.line, - tb_lasti: pyf.f_lasti, - tb_next: tb_next - ) - -proc newPyTraceback*(st: seq[StackTraceEntry] = getStackTraceEntries() -): TracebackType = - ## may used to implement traceback.print_* - for i in countdown(st.high, 0): - result = newPyTraceback(st[i], newPyFrame(st), - tb_next=result) - -proc `traceback.print_stack`*(f: FrameType = newPyFrame() - file=stderr) = - let st = getStackTraceEntries() - for i in countdown(st.high, max(0, st.high-limit)): - let s = st[i] - file.write "File $#, line $#, in $#\n".format( - s.filename, f.line, f.procname) - - -func newPyTraceback*(tb_next: TracebackType, - tb_frame: FrameType, tb_lasti, tb_lineno: int): TracebackType = - TracebackType( - tb_frame: tb_frame, - tb_lineno: tb_lineno, - tb_lasti: tb_lasti, - tb_next: tb_next, - ) - -#[ -# Graph - -## Python -f1 f2 - <- .f_back -^ -| -.tb_frame -tb1 tb2 -.tb_next -> - -## Nim - -getStackTraceEntries([e: ref Exception]) -> [GlobalScope, ..., PreviousStack, CurrentStack] - -]# - -proc getLastTraceback*() diff --git a/src/pylib/Lib/typing_impl/easyImpl.nim b/src/pylib/Lib/typing_impl/easyImpl.nim deleted file mode 100644 index 7e800b525..000000000 --- a/src/pylib/Lib/typing_impl/easyImpl.nim +++ /dev/null @@ -1,11 +0,0 @@ - -type - Final*[T] = T - Literal* = auto ##[ - Its `__class_getitem__` (e.g. `Literal[1, 2]`) is (and only is) supported within `def` or `class` via - `rewriteDeclXxx` in `pysugar/stmt/decl.nim` - - .. note:: - bare `Literal` (without any generic type) is disallowed in mypy, - here we support it as we use it to refer to `const` - ]## diff --git a/src/pylib/Lib/typing_impl/optional_obj.nim b/src/pylib/Lib/typing_impl/optional_obj.nim deleted file mode 100644 index dd2ca9d5f..000000000 --- a/src/pylib/Lib/typing_impl/optional_obj.nim +++ /dev/null @@ -1,27 +0,0 @@ -import std/options -import ../../noneType -type - OptionalObj*[T] = distinct Option[T] - -using self: OptionalObj -template wrap(meth){.dirty.} = - proc meth*[T](self: OptionalObj[T]): bool = Option[T](self).meth -wrap isSome -wrap isNone - -proc `is`*(self; _: NoneType): bool = self.isNone -proc `==`*(self; _: NoneType): bool = self.isNone - -converter unsafeGet*[T](self: OptionalObj[T]): T = - assert self.isSome, self.repr & " cannot be None" - Option[T](self).unsafeGet - - -converter unsafeToNone*[T](self: OptionalObj[T]): NoneType = - assert self.isNone - -proc newOptionalObj*[T](x: T): OptionalObj[T] = OptionalObj[T] some(x) -proc newOptionalObj*[T](): OptionalObj[T] = OptionalObj[T] none[T]() - -template expOptObjCvt* = - export optional_obj except newOptionalObj, isSome, isNone, OptionalObj diff --git a/src/pylib/Lib/typing_impl/str_optional_obj.nim b/src/pylib/Lib/typing_impl/str_optional_obj.nim deleted file mode 100644 index 5f6bbb985..000000000 --- a/src/pylib/Lib/typing_impl/str_optional_obj.nim +++ /dev/null @@ -1,9 +0,0 @@ - -import ./optional_obj -export optional_obj -import ../../pystring/strimpl -export strimpl - -proc newStrOptionalObj*(x: string): OptionalObj[PyStr] = - if x.len == 0: newOptionalObj[PyStr]() - else: newOptionalObj[PyStr](str x) diff --git a/src/pylib/Lib/unittest.nim b/src/pylib/Lib/unittest.nim deleted file mode 100644 index 6a9c739b7..000000000 --- a/src/pylib/Lib/unittest.nim +++ /dev/null @@ -1,5 +0,0 @@ - -import ../private/trans_imp -impExp unittest, - case_py, main_impl - diff --git a/src/pylib/Lib/unittest/case_py.nim b/src/pylib/Lib/unittest/case_py.nim deleted file mode 100644 index 9005e8e73..000000000 --- a/src/pylib/Lib/unittest/case_py.nim +++ /dev/null @@ -1,94 +0,0 @@ -## Lib/unittest -## -## .. hint:: Currently `self: TestCase` in all functions is only a placeholder, -## the actual implementation just replies the std/unittest. -## - -import std/unittest -import std/macros -from ../../pyerrors/simperr import TypeError -export TypeError - -import ./case_py/[ - types, - util, - prc_main, - prc_cleanup, - meth, - skips, - sig_exc, -] -export types, meth, prc_main, prc_cleanup, meth, skips, sig_exc - -template gen1(name, op){.dirty.} = - bind check - template name*(a){.genSelf.} = - check op(a) - -template asis[T](a: T): T = a -template gen1(name){.dirty.} = - gen1 name, asis - -template gen2(name, op){.dirty.} = - bind check - template name*(a, b){.genSelf.} = - check op(a, b) - -export fail -template fail*(self: TestCase) = - bind fail - fail() - -template fail*(msg: string){.genSelf.} = - bind fail, checkpoint - checkpoint msg - fail() - -gen1 assertFalse, `not` -gen1 assertTrue - -template assertRaises*(typ: typedesc, cb: typed, va: varargs[untyped]){.genSelf.} = - bind expect - expect typ: - when compiles((let _ = cb(va))): discard cb(va) - else: cb(va) - -template assertRaises*(typ: typedesc[TypeError], cb: typed, va: varargs[untyped]){.genSelf.} = - bind expect - when compiles((let _ = cb(va))): - expect typ: discard cb(va) - elif compiles(cb(va)): - expect typ: cb(va) - else: - discard ## "not compile" is seen as Compile-time TypeError - -gen2 assertEqual, `==` -gen2 assertNotEqual, `!=` - -gen2 assertIn, `in` -gen2 assertNotIn, `not_in` - -template assertIsOrNotIs[T](a, b: T; op){.genSelf.} = - bind check - when T is (pointer|ptr|ref|proc|iterator): - check a op b - elif a is static or b is static: - check a op b - else: - check a.addr op b.addr - -template assertIs*[T](a, b: T){.genSelf.} = - bind assertIsOrNotIs - assertIsOrNotIs(a, b, `==`) - -template assertIsNot*[T](a, b: T){.genSelf.} = - bind assertIsOrNotIs - assertIsOrNotIs(a, b, `!=`) - -gen2 assertLess, `<` -gen2 assertLessEqual, `<=` -gen2 assertGreater, `>` -gen2 assertGreaterEqual, `>=` - -gen2 assertIsInstance, `is` -gen2 assertNotIsInstance, `is_not` diff --git a/src/pylib/Lib/unittest/case_py/meth.nim b/src/pylib/Lib/unittest/case_py/meth.nim deleted file mode 100644 index 0a7674a2f..000000000 --- a/src/pylib/Lib/unittest/case_py/meth.nim +++ /dev/null @@ -1,8 +0,0 @@ - -import ./types - -method setup*(self: TestCase){.base.} = - discard - -method teardown*(self: TestCase){.base.} = - discard diff --git a/src/pylib/Lib/unittest/case_py/prc_cleanup.nim b/src/pylib/Lib/unittest/case_py/prc_cleanup.nim deleted file mode 100644 index f6dd6e5c1..000000000 --- a/src/pylib/Lib/unittest/case_py/prc_cleanup.nim +++ /dev/null @@ -1,25 +0,0 @@ - -import std/macros -import ./types - -macro addCleanup*(self: TestCase; cleanup: proc, - argsOrKws: varargs[untyped]) = - let attr = newDotExpr(self, ident("private.cleanups")) - let cb = - if argsOrKws.len == 0: cleanup - else: quote do: - proc() = `cleanup`(`argsOrKws`) - result = newCall("add", attr, cb) - -proc doCleanups*(self: TestCase) = - for cleanup in self.`private.cleanups`: - cleanup() - -when isMainModule: - var self = newTestCase() - var glb = 0 - self.addCleanup(proc() = glb += 1) - self.addCleanup(proc(x, y: int) = glb += x+y, 1, y=3) - assert glb == 0 - self.doCleanups() - assert glb == 5 diff --git a/src/pylib/Lib/unittest/case_py/prc_main.nim b/src/pylib/Lib/unittest/case_py/prc_main.nim deleted file mode 100644 index 4e647f5ff..000000000 --- a/src/pylib/Lib/unittest/case_py/prc_main.nim +++ /dev/null @@ -1,53 +0,0 @@ - -import std/macros -import std/unittest -import std/strutils -import ./[types, prc_cleanup, meth, skips, sig_exc] - -proc newTestCall(call, self: NimNode): NimNode = - #let e = genSym(nskLet, "skipTestExc") - let e = ident"skipTestExc" - result = newCall(bindSym"test", newLit call.strVal, - nnkTryStmt.newTree( - newCall(call, self), - nnkExceptBranch.newTree( - infix(bindSym"SkipTest", "as", e), - newCall(bindSym"skipTest", self, - newDotExpr(e, ident"msg") - ) - ) - ) - ) - ## XXX: FIXME: skip*() now will discard body on if cond is static, - ## so such a `test_*` is not defined - result = quote do: - when declared(`call`): - `result` - -macro runAux(self; meths: static openArray[string]) = - result = newStmtList() - template call(self, meth): NimNode = newCall(bindSym(astToStr(meth)), self) - result.add call(self, setup) - for fn in meths: - if fn.startsWith("test_"): - let fnIdent = ident(fn) - result.add newTestCall(fnIdent, self) - result.add call(self, teardown) - - let doCleanupsId = bindSym("doCleanups") - result = quote do: - try: - `result` - finally: - `self`.`doCleanupsId`() - -macro methsName(T: static string): untyped = parseExpr('`' & $T & ".dunder.dict.keys()`") - -template runImpl(T; self) = - #when not declared(`T.dunder.dict.keys`): {.error: "TestCase must be subclassed via `class` pysugar, but " & $T & " is not".} - #else: - runAux(self, methsName(T)) - -proc run*[T: TestCase](self: T) = - bind runImpl - runImpl($typeof(self), self) diff --git a/src/pylib/Lib/unittest/case_py/sig_exc.nim b/src/pylib/Lib/unittest/case_py/sig_exc.nim deleted file mode 100644 index 217b98351..000000000 --- a/src/pylib/Lib/unittest/case_py/sig_exc.nim +++ /dev/null @@ -1,3 +0,0 @@ - -type - SkipTest* = object of CatchableError diff --git a/src/pylib/Lib/unittest/case_py/skips.nim b/src/pylib/Lib/unittest/case_py/skips.nim deleted file mode 100644 index 24f78e5fb..000000000 --- a/src/pylib/Lib/unittest/case_py/skips.nim +++ /dev/null @@ -1,78 +0,0 @@ -import std/macros -import std/unittest -import ./[util, sig_exc] - -func fmtSkip(name, reason: string): string = name & ": " & reason - -template skipTest*(reason: string){.genSelf.} = - bind skip, fmtSkip - let msg = fmtSkip(astToStr(self), reason) - checkpoint msg - ## XXX: TODO: not really python-like - raise newException(SkipTest, reason) - -proc skipTest(reason, testStmt: NimNode): NimNode = - if testStmt.kind == nnkCommand: - result = newNimNode nnkCommand - result.add testStmt[0] - let name = testStmt[1] - result.add newCall(bindSym"fmtSkip", name, reason) - result.add newStmtList( - newCall(bindSym"skip") - ) - else: - result = newCall(bindSym"skipTest", reason) - -template skip*(reason; body) = - ## EXT. - bind skipTest - skipTest(reason, body) - -template skip*(reason: string): untyped = - bind skip, fmtSkip - proc temp(p: proc) = - test fmtSkip(astToStr(p), reason): - skip() - temp - -proc asis_id[P: proc](x: P): P = x - -template skipIf*(condition: bool, reason: string): proc = - bind asis_id, skip - if condition: skip(reason) - else: asis_id - -macro makeSkip(cond: bool; reason: string; body; staticBanch: static[bool]) = - result = newNimNode(if staticBanch: nnkWhenStmt else: nnkIfStmt) - result.add nnkElifBranch.newTree( - cond, body - ) - var elseBody = newStmtList() - if body.kind == nnkStmtList: - for s in body: - elseBody.add skipTest(reason, s) - elif body.kind == nnkCommand and body[0].eqIdent "test": - # test "xxx" - elseBody.add skipTest(reason, body) - result.add nnkElse.newTree elseBody - -template doOrSkip(cond: bool; reason: string; body) = - bind makeSkip - makeSkip cond, reason, body, false -template doOrSkip(cond: static bool; reason: string; body) = - bind makeSkip - makeSkip cond, reason, body, true - -template skipIf*(condition: bool, reason: string; body) = - ## EXT. - bind doOrSkip - doOrSkip not condition, reason, body - -template skipUnless*(condition: bool, reason: string): proc = - bind skipIf - skipIf(not condition, reason) - -template skipUnless*(condition: bool, reason: string; body) = - ## EXT. - bind skipIf - skipIf(not condition, reason, body) diff --git a/src/pylib/Lib/unittest/case_py/types.nim b/src/pylib/Lib/unittest/case_py/types.nim deleted file mode 100644 index 299f4a57f..000000000 --- a/src/pylib/Lib/unittest/case_py/types.nim +++ /dev/null @@ -1,10 +0,0 @@ - -type - Cleanup = proc () - TestCase* = ref object of RootObj - `private.testMethodName`*: string - `private.cleanups`*: seq[Cleanup] - -func newTestCase*(methodName="runTest"): TestCase = - result = TestCase() - result.`private.testMethodName` = methodName diff --git a/src/pylib/Lib/unittest/case_py/util.nim b/src/pylib/Lib/unittest/case_py/util.nim deleted file mode 100644 index 433859633..000000000 --- a/src/pylib/Lib/unittest/case_py/util.nim +++ /dev/null @@ -1,9 +0,0 @@ -import std/macros -import ./types - -macro genSelf*(templ) = - result = newStmtList() - result.add templ - var nTempl = copyNimTree templ - nTempl.params.insert 1, newIdentDefs(ident"self", bindSym"TestCase") - result.add nTempl diff --git a/src/pylib/Lib/unittest/main_impl.nim b/src/pylib/Lib/unittest/main_impl.nim deleted file mode 100644 index 6f7629a45..000000000 --- a/src/pylib/Lib/unittest/main_impl.nim +++ /dev/null @@ -1,26 +0,0 @@ - -import std/macros -import std/macrocache -import ./case_py/[ - types, -] -const TestCaseSubclasses = CacheSeq"TestCaseSubclasses" - -macro init_subclass*[T: TestCase](cls: typedesc[T]) = - TestCaseSubclasses.add( - if cls.kind == nnkTypeOfExpr: cls[0] - else: cls - ) - -macro main*() = - result = newStmtList() - for c in TestCaseSubclasses: - result.add newCall( - newDotExpr( - newCall ident("new" & c.strVal) - #nnkObjConstr.newTree c - , - ident"run") - ) - - diff --git a/src/pylib/Lib/warnings.nim b/src/pylib/Lib/warnings.nim deleted file mode 100644 index f757b89e0..000000000 --- a/src/pylib/Lib/warnings.nim +++ /dev/null @@ -1,19 +0,0 @@ - -import std/strutils - -type Warning* = enum - UserWarning, DeprecationWarning, RuntimeWarning -# some simple impl for Python's warnings - -proc formatwarning(message: string, category: Warning, filename: string, lineno: int, ): string = - "$#:$#: $#: $#\n" % [filename, $lineno, $category, message] # can use strformat.fmt - -template warn*(message: string, category: Warning = UserWarning - , stacklevel=1 #, source = None - )= - bind formatwarning - let - pos = instantiationInfo(index = stacklevel-2) # XXX: correct ? - lineno = pos.line - file = pos.filename - stderr.write formatwarning(message, category, file, lineno) diff --git a/src/pylib/Objects/obmalloc.nim b/src/pylib/Objects/obmalloc.nim deleted file mode 100644 index 76648bb5a..000000000 --- a/src/pylib/Objects/obmalloc.nim +++ /dev/null @@ -1,14 +0,0 @@ - -when compileOption"threads": - template allocImpl(T, s): untyped = cast[ptr T](allocShared(s)) - template pyfree(p) = freeShared p -else: - template allocImpl(T, s): untyped = cast[ptr T](alloc(s)) - template pyfree(p) = dealloc p -export pyfree - -template pyalloc*[T](s): ptr T = allocImpl(T, s) -template pyallocStr*(s): cstring = cast[cstring](pyalloc[cchar](s)) -template pyfreeStr*(p) = pyfree cast[ptr cchar](p) - -template memcpy*[T](a, b: ptr T, n: int) = copyMem(a, b, n) diff --git a/src/pylib/Python/config_read_env.nim b/src/pylib/Python/config_read_env.nim deleted file mode 100644 index 808d7b0f8..000000000 --- a/src/pylib/Python/config_read_env.nim +++ /dev/null @@ -1,25 +0,0 @@ - - -import std/os -import std/strutils - -using name: string -func toAllUpper(name): string {.inline.} = - for c in name: - case c - of 'a'..'z': result.add chr(ord(c) or 0b100000) - else: discard # '_' is discarded, so for other chars -func toPyEnv*(name): string {.inline.} = "PYTHON" & name.toAllUpper -proc ib_i*[T](name; flagInit: T): T = - let v = getEnv(name) - if v.len == 0: return - max(flagInit, T( - try: - let val = parseInt(v) - if val < 0: 1 # PYTHONDEBUG=text and PYTHONDEBUG=-2 behave as PYTHONDEBUG=1 - else: val - except ValueError: 1 - )) -proc ib_e*[T](name; flagInit: T): T = flagInit or T existsEnv name -proc ib_b*(name; flagInit: int): int = min 1, ib_i(name, flagInit) -proc ib_b*(name; flagInit: bool): bool = ib_i(name, flagInit) diff --git a/src/pylib/Python/envutils.nim b/src/pylib/Python/envutils.nim deleted file mode 100644 index 914680956..000000000 --- a/src/pylib/Python/envutils.nim +++ /dev/null @@ -1,64 +0,0 @@ - -when NimMajor > 1: - import std/envvars -else: - import std/os - -import ./force_ascii_utils -import ./localeutils - -proc setenvOverwrite*(key, val: string): bool = - try: - putEnv(key, val) - result = true - except OSError: - result = false - -proc c_getenv*(v: cstring): cstring{.importc: "getenv", header: "".} - - -# Python/pylifecycle.c L319 -# _Py_SetLocaleFromEnv -proc Py_SetLocaleFromEnv*(category: cint): cstring{.discardable.} = - when defined(android): - var locale: cstring - - when defined(PY_COERCE_C_LOCALE): - var coerce_c_locale: cstring - - const utf8_locale = cstring"C.UTF-8" - let env_var_set = [ - cstring"LC_ALL", - cstring"LC_CTYPE", - cstring"LANG", - ] - #[Android setlocale(category, "") doesn't check the environment variables - and incorrectly sets the "C" locale at API 24 and older APIs. We only - check the environment variables listed in env_var_set. */]# - - for evar in env_var_set: - locale = c_getenv(evar) - if locale != nil: - if locale == utf8_locale or - locale == cstring"en_US.UTF-8": - return c_setlocale(category, utf8_locale) - return c_setlocale(category, "C") - #[ Android uses UTF-8, so explicitly set the locale to C.UTF-8 if none of - LC_ALL, LC_CTYPE, or LANG is set to a non-empty string. - Quote from POSIX section "8.2 Internationalization Variables": - "4. If the LANG environment variable is not set or is set to the empty - string, the implementation-defined default locale shall be used." ]# - when defined(PY_COERCE_C_LOCALE): - # FIT(py): we currently do not get affected by Python's env - #coerce_c_locale = c_getenv("PYTHONCOERCECLOCALE") - #if coerce_c_locale == nil or coerce_c_locale == "0": - if not setenvOverwrite("LC_CTYPE", utf8_locale): - stderr.write "Warning: failed setting the LC_CTYPE " & - "environment variable to "&utf8_locale&'\n' - result = c_setlocale(category, utf8_locale) - else: - result = c_setlocale(category, "") - - Py_ResetForceASCII() - - diff --git a/src/pylib/Python/fileutils.nim b/src/pylib/Python/fileutils.nim deleted file mode 100644 index 846c2f706..000000000 --- a/src/pylib/Python/fileutils.nim +++ /dev/null @@ -1,271 +0,0 @@ - -# translated from CPython-3.13-alpha/Python/fileutils.c - -import ./force_ascii_utils -import ./unicodeobject/utf8_codec - -const - MBSTOWCS_DEST_MAY_NULL = defined(posix) or defined(windows) - HAVE_BROKEN_MBSTOWCS = not MBSTOWCS_DEST_MAY_NULL - -import ./wchar_t as wchar_t_utils -export wchar_t_utils -import ./internal/pycore_fileutils - -when not defined(windows): - import std/posix # nl_langinfo, CODESET - -# L61 -proc get_surrogateescape(errors: Py_error_handler, surrogateescape: var bool): int = - case errors - of Py_ERROR_STRICT: - surrogateescape = false - of Py_ERROR_SURROGATEESCAPE: - surrogateescape = true - else: - return -1 - -# L176 -const USE_FORCE_ASCII = not Py_FORCE_UTF8_FS_ENCODING and not defined(windows) - - - -template `-`(a, b: ptr|cstring): csize_t = - cast[int](a).csize_t - cast[int](b).csize_t - -proc decode_current_locale(arg: cstring, wstr: var ptr wchar_t, wlen: ptr csize_t, - reason: var cstring, errors: Py_error_handler): int = - var - res: ptr wchar_t - argsize, count: csize_t - var - inp: cstring - outp: ptr wchar_t - mbs: mbstate_t - var surrogateescape: bool - if get_surrogateescape(errors, surrogateescape) < 0: - return -3 - argsize = - when HAVE_BROKEN_MBSTOWCS: arg.len - else: Py_mbstowcs(nil, arg, 0) - if argsize != DECODE_ERROR: - if argsize > MaxWStrLen - 1: - return -1 - res = allocWcharArr(argsize+1) - if res == nil: - return -1 - count = Py_mbstowcs(res, arg, argsize + 1) - if count != DECODE_ERROR: - wstr = res - if wlen != nil: - wlen[] = count - return 0 - res.deallocWcArr() - - # Conversion failed. Fall back to escaping with surrogateescape. - - # Try conversion with mbrtwoc (C99), and escape non-decodable bytes. - - #[Overallocate; as multi-byte characters are in the argument, the - actual output could use less memory.]# - argsize = typeof(argsize) arg.len + 1 - if argsize > MaxWStrLen: - return -1 - res = allocWcharArr argsize - if res == nil: - return -1 - inp = arg - outp = res - - # `var mbs: mbstate_t` has set mbs `0` alreadly. - - template inc[I: SomeInteger](s: cstring, i: I = 1) = - s = cast[cstring](I(cast[int](s)) + i) - block decode_no_error: - while argsize != 0: - let converted = Py_mbrtowc(outp, inp, argsize, mbs) - if converted == 0: - break - - if converted == INCOMPLETE_CHARACTER: - #[Incomplete character. This should never happen, - since we provide everything that we have - - unless there is a bug in the C library, or I - misunderstood how mbrtowc works. ]# - break decode_no_error - - if converted == DECODE_ERROR: - if not surrogateescape: - break decode_no_error - - #[Decoding error. Escape as UTF-8b, and start over in the initial - shift state.]# - - outp[0] = wchar_t(0xdc00) + wchar_t(inp[0]) - inp.inc - outp.inc - - argsize.dec - - mbs = mbstate_t() - continue - - # _Py_mbrtowc() reject lone surrogate characters - assert not Py_UNICODE_IS_SURROGATE outp[] - - # successfully converted some bytes - inp.inc converted - argsize -= converted - outp.inc - if wlen != nil: - wlen[] = outp - res - wstr = res - return 0 - - # deode_error: - res.deallocWcArr() - if wlen != nil: - wlen[] = inp - arg - reason = "decoding error" - return -2 - - -when not HAVE_MBRTOWC or USE_FORCE_ASCII: - # L401 decode_ascii - proc decode_ascii(arg: cstring, wstr: var ptr wchar_t, wlen: ptr csize_t, - reason: var cstring, errors: Py_error_handler): int = - - type uchar = byte ## unsigned char - var - res: ptr wchar_t - argsize = arg.len + 1 - inp: ptr uchar - outp: ptr wchar_t - var surrogateescape: bool - if get_surrogateescape(errors, surrogateescape) < 0: - return -3 - - if argsize > MaxWStrLen: - return -1 - res = allocWcharArr argsize - if res == nil: - return -1 - outp = res - inp = cast[ptr uchar](arg) - template inc(p: ptr uchar, i=0) = - p = cast[ptr uchar](cast[int](p) + i) - while inp[] != uchar(0): - let ch = inp[] - if ch < wchar_t(128): - outp[] = ch - outp.inc - else: - if not surrogateescape: - res.deallocWcArr() - if wlen != nil: - wlen[] = inp - cast[typeof(inp)](arg) - reason = "decoding error" - return -2 - outp[] = typeof(outp[])(0xdc00) + - typeof(outp[])(ch) - outp.inc - - inp.inc - - outp[] = typeof(outp[])(0) - - -# L602 _Py_DecodeLocaleEx -proc Py_DecodeLocaleEx*(arg: cstring, wstr: var ptr wchar_t, wlen: ptr csize_t, reason: var cstring, - current_locale: bool, errors: Py_error_handler): int = - ##[Decode a byte string from the locale encoding. - - Use the strict error handler if 'surrogateescape' is zero. Use the - surrogateescape error handler if 'surrogateescape' is non-zero: undecodable - bytes are decoded as characters in range U+DC80..U+DCFF. If a byte sequence - can be decoded as a surrogate character, escape the bytes using the - surrogateescape error handler instead of decoding them. - - On success, return 0 and write the newly allocated wide character string into - `wstr` (use PyMem_RawFree() to free the memory). If wlen is not NULL, write - the number of wide characters excluding the null character into `wlen`. - - On memory allocation failure, return -1. - - On decoding error, return -2. Write the start of - invalid byte sequence in the input string into `wlen`. If reason is not NULL, - write the decoding error message into `reason`. - - Return -3 if the error handler 'errors' is not supported. - - Use the Py_EncodeLocaleEx() function to encode the character string back to - a byte string.]## - template retUtf8 = - return Py_DecodeUTF8Ex(arg, arg.len.csize_t, wstr, wlen, reason, errors) - template retCurLocale = - return decode_current_locale(arg, wstr, wlen, reason, errors) - if current_locale: - when Py_FORCE_UTF8_LOCALE: - retUtf8 - else: - retCurLocale - - when Py_FORCE_UTF8_FS_ENCODING: - retUtf8 - else: - var `PyRuntime.preconfig.utf8_mode` = -1 # _PyRuntime.preconfig.utf8_mode - when defined(windows): - var `PyRuntime.preconfig.legacy_windows_fs_encoding` = 0 # _PyRuntime.preconfig.legacy_windows_fs_encoding - var use_utf8 = (`PyRuntime.preconfig.utf8_mode` >= 1) - when defined(windows): - use_utf8 = use_utf8 or `PyRuntime.preconfig.legacy_windows_fs_encoding` == 0 - - if bool use_utf8: - retUtf8 - - when USE_FORCE_ASCII: - if force_ascii == -1: - force_ascii = int check_force_ascii() - - if bool force_ascii: - # force ASCII encoding to workaround mbstowcs() issue - return decode_ascii(arg, wstr, wlen, reason, errors) - - retCurLocale - -const Utf8* = "utf-8" - -# L903 _Py_GetLocaleEncoding -proc Py_GetLocaleEncoding*(): string = - ## Get the current locale encoding name: - ## - ## - Return "utf-8" if Py_FORCE_UTF8_LOCALE is defined (ex: on Android) - ## - Return "utf-8" if the UTF-8 Mode is enabled - ## - On Windows, return the ANSI code page (ex: "cp1250") - ## - Return "utf-8" if nl_langinfo(CODESET) returns an empty string. - ## - Otherwise, return nl_langinfo(CODESET). - ## - ## - ## See also config_get_locale_encoding() - when Py_FORCE_UTF8_LOCALE: - ## On Android langinfo.h and CODESET are missing, - ## and UTF-8 is always used in mbstowcs() and wcstombs(). - return Utf8 - else: - when defined(windows): - proc getACP(): cuint{.importc, header: "".} - var ansi_codepage: cuint = getACP() - let encoding = "cp" & $ansi_codepage - return encoding - else: - let encoding: cstring = nl_langinfo(CODESET) - if encoding == nil or encoding[0] == '\x00': - ## Use UTF-8 if nl_langinfo() returns an empty string. It can happen on - ## macOS if the LC_CTYPE locale is not supported. - return Utf8 - # Here CPython does followings, but we just do not use widestr, - # so no need to convert - # decode_current_locale(encoding, addr(wstr), nil, nil, - # _Py_ERROR_SURROGATEESCAPE) - return $encoding - diff --git a/src/pylib/Python/force_ascii_utils.nim b/src/pylib/Python/force_ascii_utils.nim deleted file mode 100644 index a9fc7183c..000000000 --- a/src/pylib/Python/force_ascii_utils.nim +++ /dev/null @@ -1,119 +0,0 @@ - -# translated from Python/fileutils.c - -import ./wchar_t -export Py_mbstowcs - -const - Py_FORCE_UTF8_LOCALE* = defined(android) or defined(vxworks) ##[ - CPython/Include/pyport.h: - Use UTF-8 as the filesystem encoding. - See PyUnicode_DecodeFSDefaultAndSize(), PyUnicode_EncodeFSDefault(), - Py_DecodeLocale() and Py_EncodeLocale().]## - Py_FORCE_UTF8_FS_ENCODING* = Py_FORCE_UTF8_LOCALE or defined(macosx) - -when not (Py_FORCE_UTF8_FS_ENCODING) and not defined(windows): - import ../private/encoding_norm - import std/posix # setlocale - - #[ Workaround FreeBSD and OpenIndiana locale encoding issue with the C locale - and POSIX locale. nl_langinfo(CODESET) announces an alias of the - ASCII encoding, whereas mbstowcs() and wcstombs() functions use the - ISO-8859-1 encoding. The problem is that os.fsencode() and os.fsdecode() use - locale.getpreferredencoding() codec. For example, if command line arguments - are decoded by mbstowcs() and encoded back by os.fsencode(), we get a - UnicodeEncodeError instead of retrieving the original byte string. - - The workaround is enabled if setlocale(LC_CTYPE, NULL) returns "C", - nl_langinfo(CODESET) announces "ascii" (or an alias to ASCII), and at least - one byte in range 0x80-0xff can be decoded from the locale encoding. The - workaround is also enabled on error, for example if getting the locale - failed. - - On HP-UX with the C locale or the POSIX locale, nl_langinfo(CODESET) - announces "roman8" but mbstowcs() uses Latin1 in practice. Force also the - ASCII encoding in this case. - - Values of force_ascii: - - 1: the workaround is used: Py_EncodeLocale() uses - encode_ascii_surrogateescape() and Py_DecodeLocale() uses - decode_ascii() - 0: the workaround is not used: Py_EncodeLocale() uses wcstombs() and - Py_DecodeLocale() uses mbstowcs() - -1: unknown, need to call check_force_ascii() to get the value - ]# - var `PyRuntime.fileutils.force_ascii` = -1 # _PyRuntime.fileutils.force_ascii - template force_ascii*: untyped = `PyRuntime.fileutils.force_ascii` - - proc check_force_ascii*(): bool = - block noerror: - let loc = setlocale(LC_CTYPE, nil) - if loc == nil: - break noerror - if loc != cstring"C" and loc != cstring"POSIX": - ## the LC_CTYPE locale is different than C and POSIX - return false - when declared(nl_langinfo) and declared(CODESET): - let codeset: cstring = nl_langinfo(CODESET) - if codeset == nil or codeset[0] == '\x00': - ## CODESET is not set or empty - break noerror - ## longest name: "iso_646.irv_1991\0" - let encoding = Py_normalize_encoding($codeset) - when defined(hpux): - if encoding == "roman8": - var ch: array[2, cchar] - var wch: wchar_t - var res: csize_t - ch[0] = cast[cchar](0xA7) - res = Py_mbstowcs(addr(wch), cast[cstring](addr(ch[0])), 1) - if res != DECODE_ERROR and wch == wchar_t('\xA7'): - # On HP-UX with C locale or the POSIX locale, - # nl_langinfo(CODESET) announces "roman8", whereas mbstowcs() uses - # Latin1 encoding in practice. Force ASCII in this case. - # - # Roman8 decodes 0xA7 to U+00CF. Latin1 decodes 0xA7 to U+00A7. - return true - else: - const ascii_aliases = ["ascii", "646", - "ansi_x3.4_1968", "ansi_x3.4_1986", "ansi_x3_4_1968", "cp367", - "csascii", "ibm367", "iso646_us", "iso_646.irv_1991", "iso_ir_6", - "us", "us_ascii"] - let is_ascii = encoding in ascii_aliases - if not is_ascii: - ## nl_langinfo(CODESET) is not "ascii" or an alias of ASCII - return false - var i: cuint = 0x80 - while i <= 0xff: - var ch: array[2, char] - var wch: array[1, wchar_t] - var res: csize_t - var uch = cast[cchar](i) - ch[0] = cast[char](uch) - res = Py_mbstowcs(wch[0].addr, cast[cstring](ch[0].addr), 1) - if res != DECODE_ERROR: - # decoding a non-ASCII character from the locale encoding succeed: - # the locale encoding is not ASCII, force ASCII - return true - inc(i) - # None of the bytes in the range 0x80-0xff can be decoded from the - # locale encoding: the locale encoding is really ASCII - return false - else: - # nl_langinfo(CODESET) is not available: always force ASCII - return true - # if an error occurred, force the ASCII encoding - return true - - proc Py_GetForceASCII*(): bool = - if force_ascii == -1: - force_ascii = typeof(force_ascii) check_force_ascii() - return bool force_ascii - - proc Py_ResetForceASCII*() = - force_ascii = -1 -else: - proc Py_GetForceASCII*(): bool = - return false - proc Py_ResetForceASCII*() = discard diff --git a/src/pylib/Python/internal/pycore_fileutils.nim b/src/pylib/Python/internal/pycore_fileutils.nim deleted file mode 100644 index 3adacbe5b..000000000 --- a/src/pylib/Python/internal/pycore_fileutils.nim +++ /dev/null @@ -1,19 +0,0 @@ - -import std/strutils - -type - Py_error_handler* = enum - Py_ERROR_UNKNOWN = "unknown" - Py_ERROR_STRICT = "strict" - Py_ERROR_SURROGATEESCAPE = "surrogateescape" - Py_ERROR_REPLACE = "replace" - Py_ERROR_IGNORE = "ignore" - Py_ERROR_BACKSLASHREPLACE = "backslashreplace" - Py_ERROR_SURROGATEPASS = "surrogatepass" - Py_ERROR_XMLCHARREFREPLACE = "xmlcharrefreplace" - Py_ERROR_OTHER = "other" - -proc Py_GetErrorHandler*(errors: string): Py_error_handler = - if errors == "unknown": result = Py_ERROR_OTHER - else: result = parseEnum(errors, Py_ERROR_OTHER) - diff --git a/src/pylib/Python/localeutils.nim b/src/pylib/Python/localeutils.nim deleted file mode 100644 index f3193bd29..000000000 --- a/src/pylib/Python/localeutils.nim +++ /dev/null @@ -1,13 +0,0 @@ - - -{.push header: "".} -let LC_ALL*{.importc.}: cint -let LC_CTYPE*{.importc.}: cint -proc c_setlocale*(category: cint, v: cstring): cstring{.importc: "setlocale".} -{.pop.} - -template setlocale*(category; v: string): cstring = - ## we know setlocale won't modify 2nd param - ## Thus `v: string` is allowed to convert to cstring implicitly - bind c_setlocale - c_setlocale category, v diff --git a/src/pylib/Python/pylifecycle/signal.nim b/src/pylib/Python/pylifecycle/signal.nim deleted file mode 100644 index 06267e1cc..000000000 --- a/src/pylib/Python/pylifecycle/signal.nim +++ /dev/null @@ -1,45 +0,0 @@ - - -import ./signal/[ - handler_types, c_syms -] - -when not HAVE_SIGACTION: - import ./signal/chk_util - -export handler_types - -proc PyOS_getsig*(sig: cint): CSighandler = - when HAVE_SIGACTION: - var context: Sigaction - if sigaction(sig, nil, context) == -1: - return SIG_ERR - return context.sa_handler - else: - sig.ifInvalidOnVcc: - return SIG_ERR - - result = c_signal(sig, SIG_IGN) - if result != SIG_ERR: - discard c_signal(sig, result) - -proc PyOS_setsig*(sig: cint, handler: CSighandler): CSighandler = - ## Python/pylifecycle.c PyOS_setsig - when HAVE_SIGACTION: - #[Some code in Modules/signalmodule.c depends on sigaction() being - used here if HAVE_SIGACTION is defined. Fix that if this code - changes to invalidate that assumption.]# - var context, ocontext: Sigaction - context.sa_handler = handler - discard sigemptyset(context.sa_mask) - #[Using SA_ONSTACK is friendlier to other C/C++/Golang-VM code that - extension module or embedding code may use where tiny thread stacks - are used. https://bugs.python.org/issue43390 */]# - context.sa_flags = SA_ONSTACK - if sigaction(sig, context, ocontext) == -1: - return SIG_ERR - return ocontext.sa_handler - else: - result = c_signal(sig, handler) - when declared(siginterrupt): - siginterrupt(sig, 1) diff --git a/src/pylib/Python/pylifecycle/signal/c_syms.nim b/src/pylib/Python/pylifecycle/signal/c_syms.nim deleted file mode 100644 index 2735ff1da..000000000 --- a/src/pylib/Python/pylifecycle/signal/c_syms.nim +++ /dev/null @@ -1,48 +0,0 @@ - -import ../../../pyconfig/signal -export signal -const - HAVE_BROKEN_PTHREAD_SIGMASK* = defined(cygwin) # XXX: cygwin not supported - PYPTHREAD_SIGMASK* = HAVE_PTHREAD_SIGMASK and not HAVE_BROKEN_PTHREAD_SIGMASK - HAVE_SIGSET_T* = PYPTHREAD_SIGMASK or HAVE_SIGWAIT or - HAVE_SIGWAITINFO or HAVE_SIGTIMEDWAIT - -when defined(windows): - import std/winlean - export winlean - import ./handler_types - template sig(sym) = - let sym*{.importc, header: "".}: cint - - sig SIGBREAK - sig SIGABRT - sig SIGFPE - sig SIGILL - sig SIGINT - sig SIGSEGV - sig SIGTERM - let - CTRL_C_EVENT*{.importc, header: "".}: cint - CTRL_BREAK_EVENT*{.importc, header: "".}: cint - let - SIG_DFL*{.importc, header: "".}: CSighandler - SIG_IGN*{.importc, header: "".}: CSighandler - SIG_ERR*{.importc, header: "".}: CSighandler -else: - import std/posix except EINTR, ERANGE - export posix except EINTR, ERANGE - let - ITIMER_REAL*{.importc, header: "".}: cint - ITIMER_VIRTUAL*{.importc, header: "".}: cint - ITIMER_PROF*{.importc, header: "".}: cint - -import ./handler_types - - -when HAVE_SIGACTION: - proc sigaction*(a1: cint; a2: ptr Sigaction; a3: var Sigaction): cint{.importc: "sigaction", header: "".} - ## XXX: posix/winlean's a2 cannot be nil (a var Sigaction) - -proc c_signal*(a1: cint, a2: CSighandler): CSighandler {. - importc: "signal", header: "".} # XXX: std/posix's lacks restype - diff --git a/src/pylib/Python/pylifecycle/signal/chk_util.nim b/src/pylib/Python/pylifecycle/signal/chk_util.nim deleted file mode 100644 index 176ee08cd..000000000 --- a/src/pylib/Python/pylifecycle/signal/chk_util.nim +++ /dev/null @@ -1,7 +0,0 @@ - -template ifInvalidOnVcc*(signalnum: cint, handleExc) = - when defined(windows): - if signalnum in {SIGABRT, SIGBREAK, SIGFPE, SIGILL, SIGINT, SIGSEGV, SIGTERM}: discard - else: - handleExc - diff --git a/src/pylib/Python/pylifecycle/signal/handler_types.nim b/src/pylib/Python/pylifecycle/signal/handler_types.nim deleted file mode 100644 index a9f630452..000000000 --- a/src/pylib/Python/pylifecycle/signal/handler_types.nim +++ /dev/null @@ -1,5 +0,0 @@ - -type - PySigHandler* = proc (signalnum: int, frame: PFrame){.closure.} - CSigHandler* = proc (signalnum: cint) {.noconv.} ## PyOS_sighandler_t - NimSigHandler* = proc (signalnum: int){.nimcall.} diff --git a/src/pylib/Python/pytime.nim b/src/pylib/Python/pytime.nim deleted file mode 100644 index a1daf0d46..000000000 --- a/src/pylib/Python/pytime.nim +++ /dev/null @@ -1,9 +0,0 @@ - -import ./pytime/[units, types, - pytimeFromSeconds, pytimeAsTimeval, - deadline, monotonic, - ] -export types, units - -export pytimeFromSeconds, pytimeAsTimeval, deadline, monotonic - diff --git a/src/pylib/Python/pytime/deadline.nim b/src/pylib/Python/pytime/deadline.nim deleted file mode 100644 index 9e08ed68f..000000000 --- a/src/pylib/Python/pytime/deadline.nim +++ /dev/null @@ -1,12 +0,0 @@ - -import ./monotonic, ./types, ./ops -export types - -proc PyDeadline_Init*(timeout: PyTime): PyTime = - discard monotonicRaw(result) - discard result.iadd timeout - -proc PyDeadline_Get*(deadline: PyTime): PyTime = - discard monotonicRaw(result) - result = deadline - result - diff --git a/src/pylib/Python/pytime/exc_util.nim b/src/pylib/Python/pytime/exc_util.nim deleted file mode 100644 index 93ebe5cfd..000000000 --- a/src/pylib/Python/pytime/exc_util.nim +++ /dev/null @@ -1,4 +0,0 @@ - -proc time_t_overflow* = - ## pytime_time_t_overflow - raise newException(OverflowDefect, "timestamp out of range for platform time_t") diff --git a/src/pylib/Python/pytime/monotonic.nim b/src/pylib/Python/pytime/monotonic.nim deleted file mode 100644 index 8be2e33ba..000000000 --- a/src/pylib/Python/pytime/monotonic.nim +++ /dev/null @@ -1,14 +0,0 @@ - -import std/monotimes -import ./types - -template py_get_monotonic(tp: var PyTime): bool = - ## py_get_monotonic(res, NULL, 1) - tp = getMonoTime().ticks - true - -proc monotonicRaw*(res: var PyTime): bool = - if not py_get_monotonic(res): - res = 0 - return true - diff --git a/src/pylib/Python/pytime/ops.nim b/src/pylib/Python/pytime/ops.nim deleted file mode 100644 index 3a8aa697e..000000000 --- a/src/pylib/Python/pytime/ops.nim +++ /dev/null @@ -1,73 +0,0 @@ - -import ./types - - -proc iadd*(t1: var PyTime, t2: PyTime): bool = - ## pytime_add - if t2 > 0 and t1 > PyTime.high - t2: - t1 = PyTime.high - false - elif t2 < 0 and t1 < PyTime.low - t2: - t1 = PyTime.low - false - else: - t1 += t2 - true - -proc add*(t1, t2: PyTime): PyTime = - ## `_PyTime_Add` - result = t1 - discard result.iadd t2 - -proc divide_round_up*(t, k: PyTime): PyTime = - assert k > 1 - # Don't use (t +- k - 1) / k to avoid integer overflow - # if t is equal to PyTime_{MAX,MIN} - result = t div k - if t mod k != 0: - if t >= 0: - result.inc - else: - result.dec - - -proc divide*(t, k: PyTime, round: PyTime_round_t): PyTime = - assert k > 1 - template retNNegOr(a, b) = - if t >= 0: return a - else: return b - case round - of prHalfEven: - result = t div k - let - r = t mod k - abs_r = abs(r) - k2 = k div 2 - if abs_r > k2 or (abs_r == k2 and (abs(result) and 1) == 1): - if t >= 0: result.inc - else: result.dec - of prCeiling: - retNNegOr divide_round_up(t, k), t div k - of prFloor: - retNNegOr t div k, divide_round_up(t, k) - else: - result = divide_round_up(t, k) - -proc divmod*(t, k: PyTime, pq, pr: var PyTime): bool = - assert k > 1 - var - q = t div k - r = t mod k - if r < 0: - if q == low PyTime: - pq = low PyTime - pr = 0 - return false - r.inc k - q.dec - assert 0 <= r and r < k - - pq = q - pr = r - return true - diff --git a/src/pylib/Python/pytime/pytimeAsTimeval.nim b/src/pylib/Python/pytime/pytimeAsTimeval.nim deleted file mode 100644 index b7f20bd7e..000000000 --- a/src/pylib/Python/pytime/pytimeAsTimeval.nim +++ /dev/null @@ -1,60 +0,0 @@ - -# import Timeval -const DWin = defined(windows) -when DWin: - import std/winlean -else: - import std/posix - -import ./[types, ops, units, exc_util] - -const - BAD = false ## -1 in CPython - GOOD = true ## 0 in CPython -type Status = bool - - -using round: PyTime_round_t -using t: PyTime - -proc asTimeval(ns: PyTime, tv_sec: var PyTime, tv_usec: var int, round): Status = - ## pytime_as_timeval - let us = divide(ns, PyTime US_TO_NS, round) - - var ttv_usec: PyTime - result = divmod(us, SEC_TO_US, tv_sec, ttv_usec) - tv_usec = cast[int](ttv_usec) # won't overflow - -proc asT[T](t; t2: var T): Status = - when sizeof(T) < sizeof(PyTime): - if PyTime(high T) < t: - t2 = high T - return BAD - if t < PyTime(low T): - t2 = low T - return BAD - t2 = cast[T](t) - return GOOD - -proc as_timeval_struct(t; round; raise_exc: bool): Timeval = - var - tv_sec: PyTime - tv_usec: int - let - res = t.asTimeval(tv_sec, tv_usec, round) - res2 = - when DWin: - tv_sec.asT[:long](result.tv_sec) - else: - tv_sec.asT[:Time](result.tv_sec) - if res2 == BAD: - tv_usec = 0 - result.tv_usec = tv_usec - - if raise_exc and (res == BAD or res2 == BAD): - time_t_overflow() - - -proc asTimeval*(t; round): Timeval = - ## _PyTime_AsTimeval - t.as_timeval_struct(round, true) diff --git a/src/pylib/Python/pytime/pytimeFromSeconds.nim b/src/pylib/Python/pytime/pytimeFromSeconds.nim deleted file mode 100644 index 7d90218c9..000000000 --- a/src/pylib/Python/pytime/pytimeFromSeconds.nim +++ /dev/null @@ -1,38 +0,0 @@ - -from std/math import isNaN -import ./[types, rounds, exc_util, units] - -using round: PyTime_round_t -using t: PyTime -using tp: var PyTime - -proc from_float(tp; value: float, round; unit_to_ns: int) = - ## pytime_from_double - # volatile avoids optimization changing how numbers are rounded - var d{.volatile.}: float - - # convert to a number of nanoseconds - d = value - d *= float unit_to_ns - d = round(d, round) - - # See comments in `float_to_denominator` - if not ( PyTime.low.float <= d and d < -PyTime.high.float): - tp = 0 - time_t_overflow() - tp = Pytime d - -proc from_object(tp; obj: Timestamp, round; unit_to_ns: int) = - ## pytime_from_object - when obj is SomeFloat: - if isNaN(obj): - raise newException(ValueError, "Invalid value NaN (not a number)") - tp.from_float(obj, round, unit_to_ns) - else: - let ns = PyTime obj - ns *= PyTime unit_to_ns - tp = ns - -proc fromSecondsObject*(tp; obj: Timestamp; round) = - ## _PyTime_FromSecondsObject - tp.from_object(obj, round, SEC_TO_NS) diff --git a/src/pylib/Python/pytime/rounds.nim b/src/pylib/Python/pytime/rounds.nim deleted file mode 100644 index ddaae1017..000000000 --- a/src/pylib/Python/pytime/rounds.nim +++ /dev/null @@ -1,19 +0,0 @@ - -from std/math import round, ceil, floor -import ./types - -func round_half_even*(x: float): float = - result = round(x) - if abs(x-result) == 0.5: - # halfway case: round to even - result = 2.0 * round(x / 2.0) - -func round*(x: float, round: PyTime_round_t): float = - var d{.volatile.}: float - - d = case round - of prHalfEven: round_half_even(x) - of prCeiling: ceil(x) - of prFLoor: floor(x) - of prRoundUp: (if x >= 0: ceil(x) else: floor(x)) - return d \ No newline at end of file diff --git a/src/pylib/Python/pytime/time_t_decl.nim b/src/pylib/Python/pytime/time_t_decl.nim deleted file mode 100644 index 1ac583633..000000000 --- a/src/pylib/Python/pytime/time_t_decl.nim +++ /dev/null @@ -1,24 +0,0 @@ - - -#import ./platform_utils -# may use {posix,winlean}.Time -const weridTarget = defined(js) or defined(nimscript) -when weridTarget: - type time_t* = int # js number, used as `new Date(value)`'s value -else: - const - LP64 = sizeof(int) == sizeof(int64) - - {.push header: "".} - when LP64: - type time_t*{.importc.} = int64 - elif sizeof(int) == sizeof(int32): - type time_t*{.importc.} = int32 - else: - {.error: "unsupported time_t size, only support 64bit and 32 bit system".} - {.pop.} - -const - SIZEOF_TIME_T* = sizeof time_t - PY_TIME_T_MAX* = time_t high time_t - PY_TIME_T_MIN* = time_t low time_t diff --git a/src/pylib/Python/pytime/types.nim b/src/pylib/Python/pytime/types.nim deleted file mode 100644 index 20607971f..000000000 --- a/src/pylib/Python/pytime/types.nim +++ /dev/null @@ -1,21 +0,0 @@ - - -import ./time_t_decl -export time_t_decl -type - long* = clong - -type - Timestamp* = int|float - PyTime* = int64 ## `PyTime_t`, time in ns - -# pycore_time.h -# L91 -type - PyTime_round_t* = enum ## _PyTime_round_t - prFLoor - prCeiling - prHalfEven - prRoundUp - -const prTimeout* = prRoundUp diff --git a/src/pylib/Python/pytime/units.nim b/src/pylib/Python/pytime/units.nim deleted file mode 100644 index 3b91711a2..000000000 --- a/src/pylib/Python/pytime/units.nim +++ /dev/null @@ -1,14 +0,0 @@ - -const - SEC_TO_MS* = 1000 - - MS_TO_US* = 1000 - SEC_TO_US* = SEC_TO_MS * MS_TO_US - - US_TO_NS* = 1000 - MS_TO_NS* = MS_TO_US * US_TO_NS - SEC_TO_NS* = SEC_TO_MS * MS_TO_NS - - NS_TO_MS* = 1000 * 1000 - NS_TO_US* = 1000 - NS_TO_100NS* = 100 diff --git a/src/pylib/Python/unicodeobject/char_decl.nim b/src/pylib/Python/unicodeobject/char_decl.nim deleted file mode 100644 index 981e8008c..000000000 --- a/src/pylib/Python/unicodeobject/char_decl.nim +++ /dev/null @@ -1,6 +0,0 @@ - -type - Py_UCS1* = uint8 - Py_UCS2* = uint16 - Py_UCS4* = uint32 - diff --git a/src/pylib/Python/unicodeobject/codecs.nim b/src/pylib/Python/unicodeobject/codecs.nim deleted file mode 100644 index e8105b995..000000000 --- a/src/pylib/Python/unicodeobject/codecs.nim +++ /dev/null @@ -1,237 +0,0 @@ - -type Py_ssize_t = int -import ./ptr_op, ./char_decl, ./cstring_ptr_op - -# CPython-3.14-alpha/stringlib/codecs.h - -## Mask to quickly check whether a C 'size_t' contains a -## non-ASCII, UTF8-encoded char. -const - SIZEOF_SIZE_T = sizeof(csize_t) - PY_LITTLE_ENDIAN = cpuEndian == littleEndian - -when (SIZEOF_SIZE_T == 8): - const - ASCII_CHAR_MASK* = 0x8080808080808080'u -elif (SIZEOF_SIZE_T == 4): - const - ASCII_CHAR_MASK* = 0x80808080 -else: - {.error: "C 'size_t' size should be either 4 or 8!".} -## 10xxxxxx - -template IS_CONTINUATION_BYTE*(ch: untyped): untyped = - ((ch) >= 0x80 and (ch) < 0xC0) - -type uintptr_t = uint - -const - ALIGNOF_SIZE_T* = alignof(csize_t) - -template Py_IS_ALIGNED*(p: cstring|ptr, a: typeof(ALIGNOF_SIZE_T)): bool = - (not bool(cast[uintptr_t](p) and (cast[uintptr_t](a) - 1))) - -func getMaxChar*[C](): C = - when C is char: char(0x7f) - elif C is Py_UCS1: Py_UCS1(0xff) - elif C is Py_UCS2: Py_UCS2(0xffff) - elif C is Py_UCS4: Py_UCS4(0x10fff) - else: - {.error: "invalid Char type".} - -# L23 -proc utf8_decode*[STRINGLIB_CHAR](inptr: var (cstring|ptr char); `end`: (cstring|ptr char); - dest: ptr STRINGLIB_CHAR; outpos: var Py_ssize_t): Py_UCS4 = - const STRINGLIB_MAX_CHAR = getMaxChar[STRINGLIB_CHAR]() - type S = typeof(inptr) - var ch: Py_UCS4 - var s: ptr char = when inptr is cstring: cast[ptr char](inptr) else: inptr - var p: ptr STRINGLIB_CHAR = dest + outpos - type cuchar = byte - - template Return = - inptr = cast[S](s) - outpos = p - dest - return ch - template InvalidContinuation(n) = - ch = n+1 - Return - template InvalidStart = InvalidContinuation 0 - while s < `end`: - ch = cast[cuchar](s[]) - if ch < 0x80: - ## Fast path for runs of ASCII characters. Given that common UTF-8 - ## input will consist of an overwhelming majority of ASCII - ## characters, we try to optimize for this case by checking - ## as many characters as a C 'size_t' can contain. - ## First, check if we can do an aligned read, as most CPUs have - ## a penalty for unaligned reads. - ## - if Py_IS_ALIGNED(s, ALIGNOF_SIZE_T): - ## Help register allocation - var n_s: cstring = when s is cstring: s else: cast[cstring](s) - var n_p: ptr STRINGLIB_CHAR = p - while n_s + SIZEOF_SIZE_T <=% `end`: - ## Read a whole size_t at a time (either 4 or 8 bytes), - ## and do a fast unrolled copy if it only contains ASCII - ## characters. - var value: csize_t = cast[ptr csize_t](n_s)[] - if bool(value and ASCII_CHAR_MASK): - break - when PY_LITTLE_ENDIAN: - n_p[0] = (STRINGLIB_CHAR)(value and 0xFF) - n_p[1] = (STRINGLIB_CHAR)((value shr 8) and 0xFF) - n_p[2] = (STRINGLIB_CHAR)((value shr 16) and 0xFF) - n_p[3] = (STRINGLIB_CHAR)((value shr 24) and 0xFF) - when SIZEOF_SIZE_T == 8: - n_p[4] = (STRINGLIB_CHAR)((value shr 32) and 0xFF) - n_p[5] = (STRINGLIB_CHAR)((value shr 40) and 0xFF) - n_p[6] = (STRINGLIB_CHAR)((value shr 48) and 0xFF) - n_p[7] = (STRINGLIB_CHAR)((value shr 56) and 0xFF) - else: - when SIZEOF_SIZE_T == 8: - n_p[0] = (STRINGLIB_CHAR)((value shr 56) and 0xFF) - n_p[1] = (STRINGLIB_CHAR)((value shr 48) and 0xFF) - n_p[2] = (STRINGLIB_CHAR)((value shr 40) and 0xFF) - n_p[3] = (STRINGLIB_CHAR)((value shr 32) and 0xFF) - n_p[4] = (STRINGLIB_CHAR)((value shr 24) and 0xFF) - n_p[5] = (STRINGLIB_CHAR)((value shr 16) and 0xFF) - n_p[6] = (STRINGLIB_CHAR)((value shr 8) and 0xFF) - n_p[7] = (STRINGLIB_CHAR)(value and 0xFF) - else: - n_p[0] = (STRINGLIB_CHAR)((value shr 24) and 0xFF) - n_p[1] = (STRINGLIB_CHAR)((value shr 16) and 0xFF) - n_p[2] = (STRINGLIB_CHAR)((value shr 8) and 0xFF) - n_p[3] = (STRINGLIB_CHAR)(value and 0xFF) - inc(n_s, SIZEOF_SIZE_T) - inc(n_p, SIZEOF_SIZE_T) - s = cast[ptr char](n_s) - p = cast[ptr STRINGLIB_CHAR](n_p) - if s == `end`: - break - ch = cast[cuchar](s[]) - if ch < 0x80: - inc(s) - p[] = cast[STRINGLIB_CHAR](ch) - inc(p) - continue - if ch < 0xE0: - ## \xC2\x80-\xDF\xBF -- 0080-07FF - var ch2: Py_UCS4 - if ch < 0xC2: - ## invalid sequence - ## \x80-\xBF -- continuation byte - ## \xC0-\xC1 -- fake 0000-007F - InvalidStart - if `end` - s < 2: - ## unexpected end of data: the caller will decide whether - ## it's an error or not - break - ch2 = cast[cuchar](s[1]) - if not IS_CONTINUATION_BYTE(ch2): - InvalidContinuation 1 - ch = (ch shl 6) + ch2 - ((0xC0 shl 6) + 0x80) - assert((ch > 0x007F) and (ch <= 0x07FF)) - inc(s, 2) - if STRINGLIB_MAX_CHAR <= 0x007F or - (STRINGLIB_MAX_CHAR < 0x07FF and ch > STRINGLIB_MAX_CHAR): - # Out-of-range - Return - p[] = cast[STRINGLIB_CHAR](ch) - inc(p) - continue - if ch < 0xF0: - ## \xE0\xA0\x80-\xEF\xBF\xBF -- 0800-FFFF - var - ch2: Py_UCS4 - ch3: Py_UCS4 - if `end` - s < 3: - ## unexpected end of data: the caller will decide whether - ## it's an error or not - if `end` - s < 2: - break - ch2 = cast[cuchar](s[1]) - if not IS_CONTINUATION_BYTE(ch2) or - (if ch2 < 0xA0: ch == 0xE0 else: ch == 0xED): - InvalidContinuation 1 - break - ch2 = cast[cuchar](s[1]) - ch3 = cast[cuchar](s[2]) - if not IS_CONTINUATION_BYTE(ch2): - ## invalid continuation byte - InvalidContinuation 1 - if ch == 0xE0: - if ch2 < 0xA0: - InvalidContinuation 1 - elif ch == 0xED and ch2 >= 0xA0: - ## Decoding UTF-8 sequences in range \xED\xA0\x80-\xED\xBF\xBF - ## will result in surrogates in range D800-DFFF. Surrogates are - ## not valid UTF-8 so they are rejected. - ## See https://www.unicode.org/versions/Unicode5.2.0/ch03.pdf - ## (table 3-7) and http://www.rfc-editor.org/rfc/rfc3629.txt - InvalidContinuation 1 - if not IS_CONTINUATION_BYTE(ch3): - ## invalid continuation byte - InvalidContinuation 2 - ch = (ch shl 12) + (ch2 shl 6) + ch3 - ((0xE0 shl 12) + (0x80 shl 6) + 0x80) - assert((ch > 0x07FF) and (ch <= 0xFFFF)) - inc(s, 3) - if STRINGLIB_MAX_CHAR <= 0x07FF or - (STRINGLIB_MAX_CHAR < 0xFFFF and ch > STRINGLIB_MAX_CHAR): - Return - p[] = cast[STRINGLIB_CHAR](ch) - inc(p) - continue - if ch < 0xF5: - ## \xF0\x90\x80\x80-\xF4\x8F\xBF\xBF -- 10000-10FFFF - var - ch2: Py_UCS4 - ch3: Py_UCS4 - ch4: Py_UCS4 - if `end` - s < 4: - ## unexpected end of data: the caller will decide whether - ## it's an error or not - if `end` - s < 2: - break - ch2 = cast[cuchar](s[1]) - if not IS_CONTINUATION_BYTE(ch2) or - (if ch2 < 0x90: ch == 0xF0 else: ch == 0xF4): - InvalidContinuation 1 - if `end` - s < 3: - break - ch3 = cast[cuchar](s[2]) - if not IS_CONTINUATION_BYTE(ch3): - InvalidContinuation 2 - break - ch2 = cast[cuchar](s[1]) - ch3 = cast[cuchar](s[2]) - ch4 = cast[cuchar](s[3]) - if not IS_CONTINUATION_BYTE(ch2): - ## invalid continuation byte - InvalidContinuation 1 - if ch == 0xF0: - if ch2 < 0x90: - InvalidContinuation 1 - elif ch == 0xF4 and ch2 >= 0x90: - ## invalid sequence - ## \xF4\x90\x80\x80- -- 110000- overflow - InvalidContinuation 1 - if not IS_CONTINUATION_BYTE(ch3): - ## invalid continuation byte - InvalidContinuation 2 - if not IS_CONTINUATION_BYTE(ch4): - ## invalid continuation byte - InvalidContinuation 3 - ch = (ch shl 18) + (ch2 shl 12) + (ch3 shl 6) + ch4 - - ((0xF0 shl 18) + (0x80 shl 12) + (0x80 shl 6) + 0x80) - assert((ch > 0xFFFF) and (ch <= 0x10FFFF)) - inc(s, 4) - if STRINGLIB_MAX_CHAR <= 0xFFFF or - (STRINGLIB_MAX_CHAR < 0x10FFFF and ch > STRINGLIB_MAX_CHAR): - Return - p[] = cast[STRINGLIB_CHAR](ch) - inc(p) - continue - InvalidStart - ch = 0 - Return diff --git a/src/pylib/Python/unicodeobject/cstring_ptr_op.nim b/src/pylib/Python/unicodeobject/cstring_ptr_op.nim deleted file mode 100644 index d54eb7973..000000000 --- a/src/pylib/Python/unicodeobject/cstring_ptr_op.nim +++ /dev/null @@ -1,18 +0,0 @@ - -import ./ptr_types - -type IndexType = int|int64|csize_t - -template `+`*[I: IndexType](s: cstring, i: I): cstring = - cast[cstring](cast[I](s)+i) - -template inc*(s: cstring; i=1) = s = s+i - -template `-`*(a, b: cstring): ptrdiff_t = - cast[ptrdiff_t](a) - cast[ptrdiff_t](b) - -template `<%`*(a, b: cstring): bool = - cast[int](a) < cast[int](b) - -template `<=%`*(a, b: cstring): bool = - cast[int](a) <= cast[int](b) diff --git a/src/pylib/Python/unicodeobject/locale_codec.nim b/src/pylib/Python/unicodeobject/locale_codec.nim deleted file mode 100644 index 59a6ba497..000000000 --- a/src/pylib/Python/unicodeobject/locale_codec.nim +++ /dev/null @@ -1,42 +0,0 @@ - -import ./wchar_utils -import ../../pyerrors/unicode_err -import ../internal/pycore_fileutils -import ../fileutils - -type - PyStrData = cstring - -# unicodeobject.c - -# L3980 -proc unicode_decode_locale(str: PyStrData, len: int, - errors: Py_error_handler, current_locale: bool): string = - if str[len] != '\0' or len != str.len: - raise newException(ValueError, "embedded null byte") - var - wstr: ptr wchar_t - wlen: csize_t - reason: cstring - let res = Py_DecodeLocaleEx(str, wstr, wlen.addr, reason, - current_locale, errors) - - if res != 0: - if res == -2: - raise newUnicodeDecodeError( - "locale", str[wlen], wlen.int, int wlen+1, $reason - ) - elif res == -3: - raise newException(ValueError, "unsupported error handler") - else: - raise newException(OutOfMemDefect, "unicode_decode_locale") - - result = wstr $ wlen - wstr.deallocWcArr() - -# L4029 -proc PyUnicode_DecodeLocale*(str: PyStrData, errors: string): string = - let size = str.len - let error_handler = Py_GetErrorHandler(errors) - return unicode_decode_locale(str, size, error_handler, true) - diff --git a/src/pylib/Python/unicodeobject/ptr_op.nim b/src/pylib/Python/unicodeobject/ptr_op.nim deleted file mode 100644 index 39579f583..000000000 --- a/src/pylib/Python/unicodeobject/ptr_op.nim +++ /dev/null @@ -1,21 +0,0 @@ - -import ./ptr_types -type IndexType = int|int64|csize_t - -template `+`*[I: IndexType; T](s: ptr T, i: I): ptr T = - cast[ptr T](cast[I](s)+i) - -template inc*[T](s: ptr T; i=1) = s = s+i - -template `-`*[T](a, b: ptr T): ptrdiff_t = - cast[ptrdiff_t](a) - cast[ptrdiff_t](b) - -template `<%`*[T](a, b: ptr T): bool = - cast[int](a) < cast[int](b) - -template `<=%`*[T](a, b: ptr T): bool = - cast[int](a) <= cast[int](b) - -template `[]`*[I: IndexType; T](p: ptr T; i: I): T = - (p+i)[] - diff --git a/src/pylib/Python/unicodeobject/ptr_types.nim b/src/pylib/Python/unicodeobject/ptr_types.nim deleted file mode 100644 index 51b490e3a..000000000 --- a/src/pylib/Python/unicodeobject/ptr_types.nim +++ /dev/null @@ -1,2 +0,0 @@ - -type ptrdiff_t* = int \ No newline at end of file diff --git a/src/pylib/Python/unicodeobject/utf8_codec.nim b/src/pylib/Python/unicodeobject/utf8_codec.nim deleted file mode 100644 index e9e9518fe..000000000 --- a/src/pylib/Python/unicodeobject/utf8_codec.nim +++ /dev/null @@ -1,129 +0,0 @@ - -# unicodeobject.C - -import ./ptr_op, ./char_decl -import ../wchar_t as wchar_t_lib except inc -import ../internal/pycore_fileutils -import ./codecs - -const - MaxWStrLen* = high(int) div sizeof(wchar_t) - -# unicodeobject.h - -const WC4 = sizeof(wchar_t) == 4 -when not WC4: - # L35 - proc Py_UNICODE_HIGH_SURROGATE(ch: Py_UCS4): Py_UCS4 = - ## High surrogate = top 10 bits added to 0xD800. - ## The character must be in the range [U+10000; U+10ffff]. - assert(0x10000 <= ch.ord and ch.ord <= 0x10ffff) - result = Py_UCS4(0xD800 - (0x10000 shr 10) + (ch.ord shr 10)) - - proc Py_UNICODE_LOW_SURROGATE(ch: Py_UCS4): Py_UCS4 = - ## Low surrogate = bottom 10 bits added to 0xDC00. - ## The character must be in the range [U+10000; U+10ffff]. - assert(0x10000 <= ch.ord and ch.ord <= 0x10ffff) - result = Py_UCS4(0xDC00 + (ch.ord and 0x3FF)) - -# L5268 _Py_DecodeUTF8Ex -proc Py_DecodeUTF8Ex*(orig_s: cstring, size: csize_t, - wstr: var ptr wchar_t, wlen: ptr csize_t, reason: var cstring, - errors: Py_error_handler): int = - ##[ - UTF-8 decoder: use surrogateescape error handler if 'surrogateescape' is - non-zero, use strict error handler otherwise. - - On success, write a pointer to a newly allocated wide character string into - `wstr` (use PyMem_RawFree() to free the memory) and write the output length - (in number of wchar_t units) into `wlen` (if wlen is set). - - On memory allocation failure, return -1. - - On decoding error (if surrogateescape is zero), return -2. If wlen is - non-NULL, write the start of the illegal byte sequence into `wlen`. If reason - is not NULL, write the decoding error message into `reason`.]## - - var surrogateescape, surrogatepass: bool - - case errors - of Py_ERROR_STRICT: discard - of Py_ERROR_SURROGATEESCAPE: - surrogateescape = true - of Py_ERROR_SURROGATEPASS: - surrogatepass = true - else: - return -3 - - # Note: size will always be longer than the resulting Unicode character count - if MaxWStrLen > size: - return -1 - - - # XXX: maybe consider using std/encoding - # but may be a little inefficient: - # - convert between string and cstring/ptr wchar_t - # - handle error via catching exception - - var unicode = allocWcharArr size+1 - - if unicode == nil: - return -1 - - # Unpack UTF-8 encoded data - var s = cast[ptr char](orig_s) - let e = s + size - var outpos = 0 - type WlenType = typeof(wlen[]) - while s <% e: - var ch: Py_UCS4 - when WC4: - ch = utf8_decode[Py_UCS4](s, e, unicode, outpos) - else: - ch = utf8_decode[Py_UCS2](s, e, (ptr Py_UCS2)unicode, outpos) - - if ch.ord > 0xFF: - when WC4: - doAssert false, "unreachable" - else: - assert ch.ord > 0xFFFF and ch.int <= MAX_UNICODE_val - # write a surrogate pair - unicode[outpos] = wchar_t Py_UNICODE_HIGH_SURROGATE(ch) - outpos.inc - unicode[outpos] = wchar_t Py_UNICODE_LOW_SURROGATE(ch) - outpos.inc - else: - if not bool(ch) and s == e: - break - if surrogateescape: - unicode[outpos] = wchar_t(0xDC00 + byte s[]) - s.inc - outpos.inc - else: - template `and`(c: char, i: int): int = int(c) and i - if (surrogatepass and - (e - s) >= 3 and - (s[0] and 0xf0) == 0xe0 and - (s[1] and 0xc0) == 0x80 and - (s[2] and 0xc0) == 0x80): - ch = typeof(ch) ((s[0] and 0x0f) shl 12) + ((s[1] and 0x3f) shl 6) + (s[2] and 0x3f) - s.inc 3 - unicode[outpos] = cast[wchar_t](ch) - outpos.inc - else: - unicode.deallocWcArr() - reason = case ch.ord - of 0: cstring"unexpected end of data" - of 1: cstring"invalid start byte" - else: cstring"invalid continuation byte" - - if wlen != nil: - wlen[] = cast[WlenType](s) - cast[WlenType](orig_s) - - return -2 - - unicode[outpos] = wchar_t 0 - if wlen != nil: - wlen[] = WlenType outpos - wstr = unicode - return 0 diff --git a/src/pylib/Python/unicodeobject/wchar_utils.nim b/src/pylib/Python/unicodeobject/wchar_utils.nim deleted file mode 100644 index 28a330ce9..000000000 --- a/src/pylib/Python/unicodeobject/wchar_utils.nim +++ /dev/null @@ -1,34 +0,0 @@ - -import ../wchar_t as wchar_t_lib -export wchar_t_lib -import std/unicode - -using s: ptr wchar_t - -proc len*(s): int = - result = 0 - while s[result] != wchar_t(0): result.inc - -proc size*(s): csize_t = - result = 0 - while s[result] != wchar_t(0): result.inc - -iterator items*(s): wchar_t = - var - i = 0 - ch = s[i] - while ch != wchar_t(0): - yield ch - i.inc - ch = s[i] - -template dollarImpl = - result = newStringOfCap le # maybe shall be more - for wc in s: - result.add Rune(wc.ord) -proc `$`*(s; size = s.size): string = - ## .. warning:: as equal to `s$Natural(size)` - let le = Natural(size) - dollarImpl - -proc `$`*(s; le: int): string = dollarImpl diff --git a/src/pylib/Python/wchar_t.nim b/src/pylib/Python/wchar_t.nim deleted file mode 100644 index 228452076..000000000 --- a/src/pylib/Python/wchar_t.nim +++ /dev/null @@ -1,96 +0,0 @@ - -when defined(windows): - type wchar_t*{.importc, header: "".} = uint16 -else: - type wchar_t*{.importc, header: "".} = uint32 - -func ord*(wc: wchar_t): int = int(wc) - -template allocWcharArr*[I](n: I): ptr wchar_t = - createU(wchar_t, Natural n) -template deallocWcArr*(p: ptr wchar_t) = p.dealloc() - -type - mbstate_t*{.importc, header: "wchar.h>"} = object - -# unicodeobject.c -# #define Py_UNICODE_IS_SURROGATE(ch) (0xD800 <= (ch) && (ch) <= 0xDFFF) -template Py_UNICODE_IS_SURROGATE*(ch: wchar_t): bool = - (0xD800.wchar_t <= (ch) and (ch) <= 0xDFFF.wchar_t) -const MAX_UNICODE_val* = 0x10ffff - -# ref -# https://github.com/python/cpython/commit/d3cc6890#diff-90d08e583c4c9c6f391b2ae90f819f600a6326928ea9512c9e0c6d98e9f29ac2R15126 -const HAVE_NON_UNICODE_WCHAR_T_REPRESENTATION = defined(solaris) - -proc is_valid_wide_char*(ch: wchar_t): bool = - when HAVE_NON_UNICODE_WCHAR_T_REPRESENTATION: - # Oracle Solaris doesn't use Unicode code points as wchar_t encoding - # for non-Unicode locales, which makes values higher than MAX_UNICODE - # possibly valid. - return true - if Py_UNICODE_IS_SURROGATE(ch): - # Reject lone surrogate characters - return false - if ch.int > MAX_UNICODE_val: - # bpo-35883: Reject characters outside [U+0000; U+10ffff] range. - # The glibc mbstowcs() UTF-8 decoder does not respect the RFC 3629, - # it creates characters outside the [U+0000; U+10ffff] range: - # https://sourceware.org/bugzilla/show_bug.cgi?id=2373 - return false - return true - -type PWc = (var wchar_t)|(ptr wchar_t) - -#[ size_t mbstowcs( - wchar_t * __restrict__ _Dest, - const char * __restrict__ _Source,size_t _MaxCount); ]# -proc mbstowcs(dest: ptr wchar_t, src: cstring, maxcount: csize_t): csize_t{. - importc, header: "".} - -#[size_t mbrtowc( wchar_t* pwc, const char* s, size_t n, mbstate_t* ps );]# -proc mbrtowc(wc: PWc, src: cstring, maxcount: csize_t, - mbs: var mbstate_t): csize_t{.importc, header: "".} - -const HAVE_MBRTOWC* = true - -# mbstowcs() and mbrtowc() errors -const - DECODE_ERROR* = cast[csize_t](-1) - INCOMPLETE_CHARACTER* = cast[csize_t](-2) - -proc `[]`*(p: ptr wchar_t, i: csize_t): wchar_t = - (cast[ptr wchar_t](cast[csize_t](p)+i))[] -proc `[]`*(p: ptr wchar_t, i: int): wchar_t = - (cast[ptr wchar_t](cast[int](p)+i))[] - -proc `[]=`*[I: csize_t|int](p: ptr wchar_t, i: I, val: wchar_t) = - (cast[ptr wchar_t](cast[I](p)+i))[]=val -template inc*[I](p: var ptr wchar_t, i: I = 1) = - p = (cast[ptr wchar_t](cast[I](p)+i)) - -# fileutils.c - -# L143 _Py_mbstowcs -proc Py_mbstowcs*(dest: ptr wchar_t; src: cstring; n: csize_t): csize_t = - var count: csize_t = mbstowcs(dest, src, n) - if dest != nil and count != DECODE_ERROR: - var i: csize_t = 0 - while i < count: - var ch: wchar_t = dest[i] - if not is_valid_wide_char(ch): - return DECODE_ERROR - inc(i) - return count - -# L160 _Py_mbrtowc -proc Py_mbrtowc*(wc: PWc; src: cstring; n: csize_t, - mbs: var mbstate_t): csize_t = - when wc is ptr: - assert wc != nil - var count: csize_t = mbrtowc(wc, src, n, mbs) - if count != 0 and count != DECODE_ERROR and count != INCOMPLETE_CHARACTER: - if not is_valid_wide_char(when wc is ptr: wc[] else: wc): - return DECODE_ERROR - return count - diff --git a/src/pylib/builtins.nim b/src/pylib/builtins.nim deleted file mode 100644 index 672f61a2f..000000000 --- a/src/pylib/builtins.nim +++ /dev/null @@ -1,8 +0,0 @@ - -import ./private/trans_imp - -impExp builtins, - input, print, mathfunc, complex, misc, oopFuncs, attr, - iters, iter_next, min_max, format, numTypes, str_byte, pyerrors, - pyrange, pyslice, list, dict, set, pytuple, pyhashes, - dirImpl diff --git a/src/pylib/builtins/asciiImpl.nim b/src/pylib/builtins/asciiImpl.nim deleted file mode 100644 index a1f96e0c5..000000000 --- a/src/pylib/builtins/asciiImpl.nim +++ /dev/null @@ -1,31 +0,0 @@ - - -import std/[strutils, unicode] - -func ord1(a: string): int = - runnableExamples: - assert ord1("123") == ord("1") - result = system.int(a.runeAt(0)) - -func pyasciiImpl*(us: string): string = - ## Python's `ascii` impl - ## - ## Note this assumes `us` is already processed - ## by `repr` - ## i.e., this only escape - ## the non-ASCII characters in `us` using \x, \u, or \U escapes - ## and doesn't touch ASCII characters. - for s in us.utf8: - if s.len == 1: # is a ascii char - let - c = s[0] - cOrd = c.uint8 - if cOrd > 127: - result.add r"\x" & cOrd.toHex(2).toLowerAscii - else: - result.add c - elif s.len < 4: - result.add r"\u" & ord1(s).toHex(4).toLowerAscii - else: - result.add r"\U" & ord1(s).toHex(8) - diff --git a/src/pylib/builtins/attr.nim b/src/pylib/builtins/attr.nim deleted file mode 100644 index 630b8cbcb..000000000 --- a/src/pylib/builtins/attr.nim +++ /dev/null @@ -1,38 +0,0 @@ - -import std/macros -import ../pystring/strimpl -import ../Lib/sys_impl/auditImpl/macrohelper - -proc newDotExpr(x: NimNode, attr: string): NimNode = - newDotExpr(x, ident attr) - -template gen(S){.dirty.} = - macro hasattr*(x; attr: static[S]): bool = - let dot = newDotExpr(x, attr) - newCall("compiles", dot) - - macro getattr*(x; attr: static[S]): untyped = - result = newStmtWithAudit( - "object.__getattr__", # sys.audit("object.__getattr__", attr) - attr.newLit) - result.add newDotExpr(x, attr) - - macro getattr*(x; attr: static[S], default): untyped = - result = newStmtWithAudit( - "object.__getattr__", # sys.audit("object.__getattr__", attr) - attr.newLit) - let val = newDotExpr(x, attr) - let attrS = newLit attr - result.add quote do: - when not hasattr(`x`, `attrS`): `default` - else: `val` - - macro setattr*(x; attr: static[S], val) = - result = newStmtWithAudit( - "object.__setattr__", # sys.audit("object.__setattr__", attr, val) - attr.newLit, val) - result.add newAssignment(newDotExpr(x, attr), val) - -gen string -gen PyStr - diff --git a/src/pylib/builtins/complex.nim b/src/pylib/builtins/complex.nim deleted file mode 100644 index 894d165f3..000000000 --- a/src/pylib/builtins/complex.nim +++ /dev/null @@ -1,303 +0,0 @@ -## builtins.complex and its operators/methods. -## -## Use `toNimComplex` and `pycomplex` to convert between PyComplex and Complex - -runnableExamples: - assert complex(1, 3) == complex("1.0+3.0J") - assert complex(1, 3) == 1 + 3.J - - # complex only stores floats, not int, - # just as Python's - assert not (type(complex(1, 2).real) is int) - -import std/complex as ncomplex except im, complex, pow -export ncomplex.`/` # XXX: NIM-BUG: or -#[ lib/pure/complex.nim's `func inv*[T](z: Complex[T])` will: -Error: type mismatch -Expression: conjugate(z) / abs2(z) - [1] conjugate(z): Complex[system.float64] - [2] abs2(z): float64]# -from std/math import copySign, isNaN -import ./private/ncomplex_pow -from ../numTypes/floats/parsefloat import parsePyFloat -import ../numTypes/utils/stripOpenArray -from ../noneType import NoneType -import ../version -import ../nimpatch/floatdollar - -type - PyTComplex*[T] = distinct Complex[T] ## generics version of `PyComplex`_ - PyComplex* = PyTComplex[float] - -template toNimComplex*[T](z: PyTComplex[T]): Complex[T] = Complex[T] z - -template borrowAttr(expAs, attr){.dirty.} = - ## borrow postfix, assuming returns T, - ## and forbid setter - template expAs*[T](z: PyTComplex[T]): T = - bind toNimComplex - z.toNimComplex.attr - template `expAs=`*[T](z: PyTComplex[T], _: T){.error: - "AttributeError: readonly attribute".} = discard - -borrowAttr imag, im -borrowAttr real, re - -func cut2str[T: SomeFloat](x: T): string = - # Nim's Complex's elements can only be of float - result = floatdollar.`$` x - # removesuffix('.0') - # We know $ will be at least 3 chars (e.g. "0.0", "inf") - let lm2 = result.len - 2 - if result[lm2+1] == '0' and result[lm2] == '.': - result.setLen lm2 - -func repr*(z: PyTComplex): string = - ## Returns `bj/(a+bj)`/`(a-bj)` for `complex(a, b)` - ## - runnableExamples: - assert repr(complex(0.0, 3.0)) == "3j" # not "(0+3j)", as in Python - assert repr(complex(-0.0, 3.0)) == "(-0+3j)" # not "3j", as in Python - - assert repr(complex(1.0, 2.0)) == "(1+2j)" # '.0' is removed as Python's - let - real = z.real - imag = z.imag - template addImag = result.add imag.cut2str & 'j' - if real == 0.0 and copySign(1.0, real) == 1.0: # +0.0 - #[/* Real part is +0.0: just output the imaginary part and do not - include parens. */]# - addImag - return - result.add '(' - result.add real.cut2str - template requirePlus(x: float): bool = - # act as `PyOS_double_to_string` with flag of `Py_DTSF_SIGN` - x >= 0 or x.isNaN - # NOTE: CPython's implementation does not care the sign of NaN here, - # unconsistent with cases in other places - # (CPython is used to caring a lot the sign of NaN) - if requirePlus imag: - result.add '+' - # if negative, `-` will be prefix-ed by `$` - addImag - result.add ')' - -func `$`*(z: PyTComplex): string = repr z - -template toPyComplex[T](z: ncomplex.Complex[T]): PyTComplex[T] = - ## Convert Nim's Complex in std/complex to PyTComplex - bind PyTComplex - PyTComplex[T] z -template pycomplex*[T](z: ncomplex.Complex[T]): PyTComplex[T] = - bind toPyComplex - toPyComplex z - -func complex*[T: SomeFloat](real: T = 0.0, imag: T = 0.0): PyTComplex[T] = - pycomplex ncomplex.complex(real, imag) -func complex*[T: SomeInteger](real: T = 0, imag: T = 0): PyComplex = - pycomplex ncomplex.complex(real.BiggestFloat, imag.BiggestFloat) - -type - HasIndex = concept self - self.index() is SomeInteger - HasFloat = concept self - float(self) is BiggestFloat - -template complex*(real, imag: HasFloat): PyComplex = - bind complex - complex(float(real), float(imag)) - -template complex*(real, imag: HasIndex): PyComplex{. - pysince(3,8).} = - bind complex - complex(real.index().BiggestFloat, imag.index().BiggestFloat) - -func complex*(s: string): PyComplex = - const errMsgPre = "complex() arg is a malformed string, reason: " - template malformedArg(msg: string) = - raise newException(ValueError, errMsgPre & msg) - if s.len == 0: malformedArg("got empty string") - # cleanup leading and trailing whitespaces and parentheses. - var (m, n) = s.stripAsRange - let begParen = s[m] == '(' - let endParan = s[n] == ')' - if begParen: - m.inc - if endParan: - n.dec - if begParen and not endParan: malformedArg("missing closing parentheses") - if endParan and not begParen: - malformedArg("missing beginning parentheses") - let offset = s.toOpenArray(m, n).stripAsRange - var cur = m + offset[0] - n = m + offset[1] - template leftS: untyped = (s).toOpenArray(cur, n) - template curChar: char = - if cur > n: - malformedArg("expecting more chars at end") - s[cur] - - # now whitespaces and parentheses are cleanup. - var - re, im: float - nParsed: int - template isJ(c: char): bool = - c == 'j' or c == 'J' - template isOp(c: char): bool = - c == '+' or c == '-' - template checkSuffix = - if cur > n: - malformedArg("expect 'j' or 'J', but got nothing at index: " & $cur) - let suffix = s[cur] - if not suffix.isJ: - malformedArg("expect 'j' or 'J', but got " & suffix.repr & " at index " & $cur) - cur.inc - nParsed = leftS.parsePyFloat re - - if nParsed != 0: - # all 4 forms starting with land here - cur.inc nParsed - if cur > n: - # - return complex(re, im) - let infix = curChar - if infix.isOp: - # j | j - nParsed = leftS.parsePyFloat im - if nParsed != 0: - # j - cur.inc nParsed - else: - # j - im = if infix == '+': 1.0 else: -1.0 - cur.inc - checkSuffix - elif curChar.isJ: - # j - cur.inc - swap im, re - else: - discard # is handled above - else: - # not starting with ; must be j or j - let prefix = curChar - if prefix.isOp: - # j - im = if prefix == '+': 1.0 else: -1.0 - cur.inc - else: - # j - im = 1.0 - checkSuffix - if cur != n+1: - malformedArg("superfluous chars in range " & $(cur..(n+1))) - result = complex(re, im) - -template pycomplex*[T](re: T; im = T(0)): PyTComplex[T] = - ## alias of `complex`. - ## Useful when import both std/complex and pylib - complex(re, im) - -template pycomplex(z: SomeInteger): PyComplex = pycomplex(float(z)) - -func abs*[T](z: PyTComplex[T]): T = abs(z.toNimComplex) ## builtins.abs for complex - -func conjugate*[T](z: PyTComplex[T]): PyTComplex[T] = - ## complex.conjugate() - pycomplex conjugate(z.toNimComplex) - -template AsIs[T](x: T): T = x - -template toNimCallArg[T](x: PyTComplex[T]): ncomplex.Complex[T] = x.toNimComplex -template toNimCallArg[F: SomeFloat](x: F): ncomplex.Complex[F] = ncomplex.complex(x) -template toNimCallArg[F: SomeFloat](x: SomeInteger): ncomplex.Complex[F] = toNimCallArg(F x) - -template toNimCall[T](op; a, b): untyped = - bind toNimComplex - op(a.toNimCallArg[:T], b.toNimCallArg[:T]) - -template genBinOpT(name, op, TA, TB: untyped, retMap: typed){.dirty.} = - ## borrow binary op, do not care result type - template name*[T](a: TA, b: TB): untyped = - bind op, toNimCall, retMap - retMap toNimCall[T](op, a, b) - -template borrowBin(name; op; transSelf=true, retMap: typed=AsIs, arg2Int=true) = - genBinOpT name, op, PyTComplex[T], PyTComplex[T], retMap - when not defined(pylibNoLenient): - genBinOpT name, op, PyTComplex[T], T, retMap - when arg2Int: - genBinOpT name, op, PyTComplex[T], SomeInteger, retMap - when transSelf: - genBinOpT name, op, T, PyTComplex[T], retMap - genBinOpT name, op, SomeInteger, PyTComplex[T], retMap - -template borrowBinIop(op) = borrowBin(op, op, transSelf=false) -template borrowBinRet(name; op; arg2I=true) = - borrowBin(name, op, transSelf=true, retMap=toPyComplex, arg2Int=arg2I) - -template borrowBinRet(op; arg2I=true) = borrowBinRet(op, op, arg2I) - -borrowBinRet `+` -borrowBinRet `-` -borrowBinRet `*` -borrowBinRet `/` -borrowBinRet pow, arg2I=false -borrowBinRet `**`, op=pow, arg2I=false -borrowBin `==`, `==` -borrowBinIop `+=` -borrowBinIop `-=` -borrowBinIop `*=` -borrowBinIop `/=` - -template genPow(name){.dirty.} = - template name*[T](self: PyTComplex[T], x: static Natural): PyTComplex[T] = - bind pycomplex, toNimComplex - pycomplex ncomplex_pow.powu(self.toNimComplex, x) - - template name*[T](self: PyTComplex[T], x: SomeInteger): PyTComplex[T] = - bind pycomplex, toNimComplex - pycomplex ncomplex_pow.pow(self.toNimComplex, x) - -genPow pow -genPow `**` - -type ComplexPowSecondParamType[T] = T or PyTComplex[T] - -func `**=`*[T](self: var PyTComplex[T]; x: ComplexPowSecondParamType[T]|SomeInteger) = - bind `**` - self = self ** x - -template genPow3(TA, TB){.dirty} = - template pow*[T](self: TA, x: TB, _: NoneType): PyTComplex[T] = - bind pow - pow(self, x) - -genPow3 PyTComplex[T], ComplexPowSecondParamType[T]|SomeInteger -genPow3 ComplexPowSecondParamType[T]|SomeInteger, PyTComplex[T] - -func `'j`*(s: static string): PyComplex = - ## 1+3'j or 1+3'J - ## - ## .. note:: Nim disallows custom suffixes without `'`. - ## Therefore, something like `1+3j` is not not allowed. - ## - ## Consider using `complex` or `j`_ instead, - ## which are totaly Python syntax compatiable. - runnableExamples: - assert 1+3'j == 1.0+3.0'J - var imPart: BiggestFloat - assert s.len == s.parsePyFloat imPart - complex(0.0, imPart) - -template j*(i: int{lit}): PyComplex = - runnableExamples: - assert complex(1, 3) == 1+3.j - bind complex - complex(0.0, float(i)) - -template J*(i: int{lit}): PyComplex = - ## the same as `j`_, e.g. `1+3.J` - bind complex - complex(0.0, float(i)) diff --git a/src/pylib/builtins/dict.nim b/src/pylib/builtins/dict.nim deleted file mode 100644 index 4a19fb62a..000000000 --- a/src/pylib/builtins/dict.nim +++ /dev/null @@ -1,218 +0,0 @@ - -import std/tables -import std/macros -import ../collections_abc -import ./iter_next -import ../pystring/strimpl -import ./dict_decl -import ./private/strIter - -export dict, PyDict -export emptyPyDict - -type - PyDictView* = object of RootObj ## .. warning:: currently `mapping` attr - ## is dict itself, i.e. modifiable - PyDictKeyView*[T] = object of PyDictView - mapping*: PyDict[T, auto] - PyDictValueView*[T] = object of PyDictView - mapping*: PyDict[auto, T] - PyDictItemView*[K, V] = object of PyDictView - mapping*: PyDict[K, V] - SomeSinglePyDictView*[T] = PyDictValueView[T]|PyDictKeyView[T] - SomePyDictView* = PyDictKeyView | PyDictValueView | PyDictItemView - - -proc contains*[A, B](t: PyDict[A, B], key: A): bool = contains(t.toNimTable, key) -proc `[]`*[A, B](t: PyDict[A, B], key: A): B = `[]`(t.toNimTable, key) -proc `[]=`*[A, B](t: PyDict[A, B], key: A, val: sink B) = - `[]=`(t.toNimTable, key, val) - -using self: PyDict - -template strBy(d; k): string{.dirty.} = - k.repr & ": " & d[k].repr - -PyDict.genDollarRepr '{', '}', strBy - -proc len*(self): int = - ## dict.__len__ - self.toNimTable.len - -proc `==`*[A, B](self, other: PyDict[A, B]): bool = self.toNimTable == other.toNimTable - -proc clear*(self) = self.toNimTable.clear - -proc len*(view: SomePyDictView): int = view.mapping.len -template iter*(view: SomePyDictView): untyped = view.mapping.iter -template items*(view: SomePyDictView): untyped = view.iter -func contains*[T](t: PyDictKeyView[T], x: T): bool = contains(t.mapping, x) -func contains*[T](t: PyDictValueView[T], x: T): bool = - for v in t.mapping.values(): - if v == x: return true -func contains*[K, V](t: PyDictItemView[K, V], x: (K, V)): bool = - if x[0] in t.mapping: - return x[1] == t.mapping[x[0]] - -PyDictKeyView.genDollarRepr "dict_keys([", "])" -PyDictValueView.genDollarRepr "dict_values([", "])" -PyDictItemView.genDollarRepr "dict_items([", "])" - - -iterator keys*[K, V](self: PyDict[K ,V]): K = - for i in self.toNimTable.keys(): yield i - -iterator iter*[K, V](self: PyDict[K ,V]): K = - ## .. warning:: Nim's for stmt calls `items` implicitly, instead of iter - ## so beware to always write `iter` for dict in for loop - runnableExamples: - let d = dict(a=1) - for i in iter(d): - assert i == "a" - for i in d: - assert i[0] == "a" and i[1] == 1 - - for i in self.keys(): yield i - -func iter*[K, V](self: PyDict[K, V]): PyIterator[K] = - newPyIterator[K](iterator (): K = - for k in self.keys(): yield k) - -iterator values*[K, V](self: PyDict[K ,V]): V = - for i in self.toNimTable.values(): yield i - -iterator items*[K, V](self: PyDict[K ,V]): (K, V) = - for i in self.toNimTable.pairs(): yield i - -func keys*[K, V](self: PyDict[K ,V]): PyDictKeyView[K] = result.mapping = self -func values*[K, V](self: PyDict[K ,V]): PyDictValueView[V] = result.mapping = self -func items*[K, V](self: PyDict[K ,V]): PyDictItemView[K, V] = result.mapping = self - -func toPyDict*[K, V](x: openArray[(K, V)]): PyDict[K, V] = - # NOTE: in Nim, `{k:v, ...}` is of `array[(type(k), type(v))]` - result = newPyDict[K, V](x) - -func toPyDict*[K, V](x: - not openArray[(K, V)] and Iterable[(K, V)]): PyDict[K, V] = - result = newPyDict[K, V]() - for (k, v) in x: - result[k] = v - -func copy*[K, V](self: PyDict[K, V]): PyDict[K, V] = - result = newPyDict[K, V](len(self)) - for k, v in self.items(): - result[k] = v - -# as PyDict is of `ref` type, no need to use `var PyDict` for param type - -func setdefault*[K, V](self: PyDict[K, V], key: K, default = V.default) = - ## .. warning:: `default` defaults to `V.default` instead of `None` - if key in self: - return self[key] - self[key] = default - return default - -func get*[K, V](self: PyDict[K ,V], key: K): V = self[key] -func get*[K, V](self: PyDict[K ,V], key: K, default: V): V = self.getOrDefault(key, default) -func pop*[K, V](self: PyDict[K, V], key: K): V = - if not self.pop(key, result): - raise newException(KeyError, $key) -func pop*[K, V](self: PyDict[K, V], key: K, default: V): V = - if not self.toNimTable.pop(key, result): - result = default - -func popitem*[K, V](self: PyDict[K, V]): (K, V) = - ## .. warning:: this is currently LILO instead of LIFO - for i in self.toNimTable.keys(): - result[0] = i - break - discard self.pop(result[0], result[1]) - -proc delitem*[K, V](self: PyDict[K, V], k: K) = - ## pysugar expect such a proc to hook `del d[k]` - self.toNimTable.del k - - -template PyDictProc: NimNode = ident "toPyDict" # the proc must be exported - - -proc parseKeyValues(kwargs: NimNode|seq[NimNode]): NimNode = - # k=v,... -> [("k", v),...] - when kwargs is NimNode: - expectKind kwargs, nnkArgList - result = newNimNode nnkBracket - for kw in kwargs: - expectKind(kw, nnkExprEqExpr) - let (k, v) = (kw[0], kw[1]) - result.add newTree(nnkTupleConstr, newCall(bindSym"str", newLit $k), v) - -proc dictByKw(kws: NimNode): NimNode = - let arr = parseKeyValues kws - result = newCall(PyDictProc, arr) - -proc dictByIterKw(iter: NimNode; kwargs: NimNode|seq[NimNode]): NimNode = - when kwargs is NimNode: - expectKind kwargs, nnkArgList - let lhs = newCall(PyDictProc, iter) - let arr = parseKeyValues kwargs - let rhs = newCall(PyDictProc, arr) - result = infix(lhs, "|", rhs) - -# Why cannot...: func dict*[K, V](): PyDict[K, V] = emptyPyDict[K, V]() -macro dict*(kwargs: varargs[untyped]): PyDict = - case kwargs.len - of 0: - # Can't we get generic args? - error "use emptyPyDict" # TODO: support it - of 1: - let arg = kwargs[0] - result = - if arg.kind == nnkExprEqExpr: - dictByKw kwargs - else: - newCall(PyDictProc, arg) - else: - let first = kwargs[0] - result = - if first.kind == nnkExprEqExpr: - dictByKw kwargs - else: - dictByIterKw(first, kwargs[1..^1]) - -# if using overload, [("a", 1), ...] will be not supported -#macro update*(self: PyDict, iterable: Iterable, kws: varargs[untyped]) = -macro update*(self: PyDict, kws: varargs[untyped]) = - ## `d.update(**kws)` - ## `d.update(iterable, **kws)` - if kws.len == 0: # `d.update()` - return newEmptyNode() - result = newStmtList() - let first = kws[0] - let is1stIter = first.kind != nnkExprEqExpr - var startKw = 0 - let setitem = bindSym"[]=" - if is1stIter: - result.add quote do: - when compiles(`first`.keys()): - for k in `first`.keys(): - `setitem` `self`, k, `first`[k] - else: - for t in `first`: - `setitem` `self`, t[0], t[1] - startKw = 1 - for kv in kws[startKw..^1]: - result.add newCall(setitem, self, newLit $kv[0], kv[1]) - -func `|`*(a, b: PyDict): PyDict = - ## Python-like merge dict operator, - ## a new dict is created from `a` and `b`, keys in the second - ## operand override keys in the first operand - result = a.copy() - for key, val in b.items(): - result[key] = val - -proc `|=`*(a, b: PyDict) = - ## Python-like in-place dict update operator. - ## `b` is added into `a`, keys in `b` override same keys from `a` - for key, val in b.items(): - a[key] = val diff --git a/src/pylib/builtins/dict_decl.nim b/src/pylib/builtins/dict_decl.nim deleted file mode 100644 index 680e581fc..000000000 --- a/src/pylib/builtins/dict_decl.nim +++ /dev/null @@ -1,34 +0,0 @@ - -import std/tables - -type - dict*[K, V] = ref object - data: OrderedTable[K, V] - PyDict*[K, V] = dict[K, V] - -func toNimTable*[K, V](self: PyDict[K,V]): var OrderedTable[K, V] = self.data - -func newPyDict*[K, V](x: int): PyDict[K, V]{.inline.} = - bind initOrderedTable - PyDict[K, V](data: initOrderedTable[K, V](x)) - -func newPyDict*[K, V](x: openArray[(K, V)] = []): PyDict[K, V] = - ## zero or one arg - ## shall support `[]`, `{k:v, ...}`, `@[(k, v),...]` - bind toOrderedTable - PyDict[K, V](data: toOrderedTable[K, V](x)) - -{.push deprecated: "use newPyDict, to be removed since 0.10".} -template newPyDictImpl*[K, V](x: int): untyped = - bind newPyDict - newPyDict(x) - -template newPyDictImpl*[K, V](x: openArray[(K, V)] = []): untyped = - bind newPyDict - newPyDict(x) -{.pop.} - -proc getOrDefault*[A, B](t: PyDict[A, B], key: A): B = - ## inner. used to impl get(key, default) - t.toNimTable.getOrDefault key -func emptyPyDict*[K, V](): PyDict[K, V] = newPyDictImpl[K, V]([]) diff --git a/src/pylib/builtins/dirImpl.nim b/src/pylib/builtins/dirImpl.nim deleted file mode 100644 index 28cabeb64..000000000 --- a/src/pylib/builtins/dirImpl.nim +++ /dev/null @@ -1,19 +0,0 @@ - -import ../pystring/strimpl -import ./list - -using o: object|tuple|ref object -template fieldPairs[T](r: ref T): untyped = r[].fieldPairs - -iterator dirImpl*(o): string = - for i, _ in o.fieldPairs: yield i - -iterator dir*(o): PyStr = - for i in o.dirImpl: yield i - -proc dirImpl*(o): seq[string] = - for i in o.dirImpl: result.add i - -proc dir*(o): PyList[PyStr] = - result = list[PyStr]() - for i in o.dir: result.append i diff --git a/src/pylib/builtins/format.nim b/src/pylib/builtins/format.nim deleted file mode 100644 index c54a17950..000000000 --- a/src/pylib/builtins/format.nim +++ /dev/null @@ -1,6 +0,0 @@ - -import ../pystring/strimpl -import ./private/format_impl - -proc format*[T](self: T, spec: static[string]|string): PyStr = - str format_impl.format(self, spec) diff --git a/src/pylib/builtins/input.nim b/src/pylib/builtins/input.nim deleted file mode 100644 index 79c5a14c8..000000000 --- a/src/pylib/builtins/input.nim +++ /dev/null @@ -1,77 +0,0 @@ - -import ./print -import ../pystring/strimpl -import ../Lib/sys - -const hasStdio = declared(sys.stdin) and declared(sys.stdout) - -when hasStdio: - import ../pyerrors/rterr - template lost(std) = raise newException(RuntimeError, "input() lost " & std) - -proc inputImpl: PyStr = - when defined(nimscript): - # XXX: currently sys.stdin is not available on nimscript - static: assert not compiles(sys.stdin) - readLineFromStdin() - elif defined(js): - when not defined(nodejs): - {.warning: "assuming NodeJs but nodejs is not defined".} - var jsResStr: cstring - asm """// XXX: FIXME: only support ASCII charset now. - const fs = require('fs'); - let fd = (process.platform == 'win32') ? - process.stdin.fd : - fs.openSync('/dev/tty', 'rs'); - let buf = Buffer.alloc(4); - let str = '', read; - while (true) { - read = fs.readSync(fd, buf, 0, 1); - if(read==0) continue; - let chr = buf[0]; - - // catch the newline character - if (chr == 10) { - fs.closeSync(fd); - break; - } - str += buf.slice(0,1).toString(); - } - `jsResStr` = str; - """ - #[ - asm """ ;{ - let rlmod = require("readline") - let rlinter = rlmod.createInterface( - {input: process.stdin, output: process.stdout}); - rlinter.question(`jsPs`, inp=>{ - rlinter.close(); - `jsResStr` = inp // XXX: this is executed asynchronously... - // So `result` will be just null when returned - }); - } - """]# - result = str $jsResStr - else: - sys.stdin.readline() - - -proc inputImpl(prompt: string): PyStr = - when defined(js) and not defined(nodejs):# browesr or deno - proc prompt(ps: cstring): cstring{.importjs: "prompt(#)".} - return str $prompt(cstring prompt) - else: - if prompt.len != 0: - print(prompt, endl="") - inputImpl() - -proc input*(prompt = str("")): PyStr = - ## - ## when on non-nodejs JavaScript backend, - ## uses `prompt` - sys.audit("builtins.input", prompt) - when hasStdio: - if sys.stdin.isNil: lost "stdin" - if sys.stdout.isNil: lost "stdout" - inputImpl prompt - diff --git a/src/pylib/builtins/iter_next.nim b/src/pylib/builtins/iter_next.nim deleted file mode 100644 index d006bfd11..000000000 --- a/src/pylib/builtins/iter_next.nim +++ /dev/null @@ -1,53 +0,0 @@ -## builtins.iter - -import ../collections_abc -import ../pyerrors/signals -import std/options - -#iterator items*[T](it: PyIterable[T]): T = for i in it.iter: yield i - -type - PyIterator*[T] = ref object - iter: iterator (): T - -func newPyIterator*[T](it: iterator (): T): PyIterator[T] = - ## init with a Nim iterator - PyIterator[T](iter: it) - -func iter*[T](x: Iterable[T]): PyIterator[T] = - when x.items is "closure": - result = newPyIterator[T](x.items) - else: - result = newPyIterator[T](iterator (): T = - for i in x: - yield i - ) - -func iter*[T](x: Iterator[T]): PyIterator[T] = - result = newPyIterator[T](iterator (): T = - while true: - try: - yield x.next - except StopIteration: - break - ) - -iterator items*[T](self: PyIterator[T]): T = - for i in self.iter(): - yield i - -proc nextImpl*[T](self: PyIterator[T]): Option[T]{.inline.} = - ## EXT. Get rid of exception for faster iteration. - result = some self.iter() - if self.iter.finished(): result = none(T) - -proc nextImpl*[T](self: PyIterator[T], res: var T): bool{.inline.} = - ## EXT. Get rid of exception for faster iteration. - res = self.iter() - not self.iter.finished() - -proc next*[T](self: PyIterator[T]): T = - # see manual, sysmte.finished shall validate after a value is getten from iterator. - if not self.nextImpl result: - raise newStopIteration() - diff --git a/src/pylib/builtins/iters.nim b/src/pylib/builtins/iters.nim deleted file mode 100644 index 2905a7536..000000000 --- a/src/pylib/builtins/iters.nim +++ /dev/null @@ -1,178 +0,0 @@ -## Some iterable in builtins -## -## XXX: For JS backend: -## Currently due to Nim's inner buys, using of some iterable functions in this modules -## may result in `Error: ...`: -## -## - list(...) -## - filter/map/... as func (using iterator is okey) (solved after Nim-2.1.1) -## -## For details, trace: -## -## - closure iterator: https://github.com/nim-lang/Nim/issues/4695 (solved after Nim-2.1.1) -## - `concept` about `for loop`: -## https://github.com/nim-lang/Nim/issues/9550#issuecomment-2045173674 - -import ../collections_abc -from ../pybool import toBool -import ../private/iterGen -import ./iters/[mapMacro, zipMacro] -import ./iter_next -import ../noneType -export noneType.None -export iter, next - -import std/macros - -iterator filter*[T](comp: proc(arg: T): bool, iter: Iterable[T]): T{.genIter.} = - for item in iter: - if comp(item): - yield item - -iterator filter*[T](comp: NoneType, iter: Iterable[T]): T{.genIter.} = - for item in iter: - if toBool(item): - yield item - -iterator enumerate*[T](x: Iterable[T], start=0): (int, T){.genIter.} = - var i = start - for v in x: - yield (i, v) - i.inc - -iterator reversed*[T](x: Sequence[T]): T{.genIter.} = - let le = len(x) - for i in countdown(le-1, 0): - yield x[i] - - -type Map[R] = object - iter: iterator (): R -makeIterable Map - -iterator map*[T, R](function: proc (x: T): R, - iterable: Iterable[T]): R{.genIter.} = - for i in iterable: - yield function(i) - -template genInitor(funcName, Type){.dirty.} = - ## used for macro - func funcName[T](iter: iterator (): T): Type[T]{.inline.} = Type[T](iter: iter) - -genInitor initMap, Map - -macro map*(function: proc, iterable: typed, iterables: varargs[typed]): Map = - ## .. note:: unlike Python, if arguments number does not fit `function`, - ## instead of runtime error compile-time error occurs, in which - ## a generated temporary name `gen_iter_res` will be seen - let its = nnkBracket.newTree(iterable) - iterables.copyChildrenTo its - newCall(bindSym"initMap", mapIterBodyImpl(function, its, ident"gen_iter_res")) - -type Zip[T] = object - iter: iterator (): T -makeIterable Zip -genInitor initZip, Zip - -#[ -XXX: NIM-BUG: - -If using the following approach: - -```Nim -type SizedGetitem[T] = concept self - self is Sized - self[int] is T -templat isSizedGetitem[T](it): bool = it is SizedGetitem[T] -``` -the compiler will report error for one case: - - it1 or it2 is `HashSet` - -The Error: - -``` -Expression: it1[i] - [1] it1: Iterable[int, Iterable] - [2] i: int -``` -One reason is that `HashSet` defines: - -```Nim - proc `[]`*[A](s: var HashSet[A], key: A): var A -``` - -Anyway in turn,a `it: HashSet` will be always matched as a `SizedGetitem` -but `it[0]` cannot be compiled. - -That's why the following approach is used for now. - -]# -#iterator zip*[A](it: Iterable[A], strict: static[bool]=false): (A){.genIter.} = - -template isSizedGetitem[T](it): bool = - it is Sized and compiles((let _ = it[0])) - -iterator zip*[A, B](it1: Iterable[A], it2: Iterable[B], strict = false): (A, B){.genIter.} = - template handleBound(ordLonger) = - if strict: raiseZipBound ordLonger - else: break - when it1.isSizedGetitem[:A]: - let le = it1.len - for i, v in enumerate(it2): - if i == le: handleBound 2 - yield (it1[i], v) - elif it2.isSizedGetitem[:B]: - let le = it2.len - for i, v in enumerate(it1): - if i == le: handleBound 1 - yield (v, it2[i]) - else: - var - itor1 = iter(it1) - itor2 = iter(it2) - - var res: (A,B) - var s1, s2: bool - - while true: - s1 = itor1.nextImpl res[0] - s2 = itor2.nextImpl res[1] - if s1 and s2: - yield res - continue - if strict: - if not s2: raiseZipBound 2 - if not s1: raiseZipBound 1 - break - -template onlyDefinedWhen(cond: static[bool]; body): untyped = - when cond: body - -macro zip*(iterables_or_strict: varargs[untyped]): Zip{. - onlyDefinedWhen(not defined(pylibDisableMoreArgsZip)).} = - ## `zip(*args, strict=False)` - ## - ## ------ - ## - ## To support its similarity with Python's `zip` function signature, - ## this macro signature has to be `varargs[untyped]`. - ## - ## So it's designed to be undefined - ## when `pylibDisableMoreArgsZip` is defined. - let last = iterables_or_strict.last - var nIt = iterables_or_strict.len - let strict = - #if last.getType.typeKind == ntyBool: - if last.kind == nnkExprEqExpr: - let keyId = last[0].strVal - if keyId != "strict": - error "TypeError: zip() got an unexpected keyword argument '" & - keyId & "'." - nIt.dec - last[1] - else: newLit false - - result = newCall(bindSym"initZip", - zipIterbodyImpl(iterables_or_strict[0.. Slice -func `[]`*[T](self: PyList[T], s: PySlice): PyList[T] = - let s = normSlice(s, self.len) - if s.step == 1: - return self[s.toNimSlice] - result = newPyList[T]() - for i in pyrange.range(s.start, s.stop, s.step): - result.append self[i] - - - -func reverse*(self: var PyList) = reverse(self.asSeq) - -func pop*[T](self: var PyList[T]): T{.discardable.} = self.asSeq.pop() -func pop*[T](self: var PyList[T], index: int): T{.discardable.} = - ## `index` can be negative to index backwards. - let idx = if index < 0: self.len + index else: index - result = self.asSeq[idx] - self.asSeq.delete(idx) - -func extend*[T](self: var PyList[T], ls: openArray[T]) = - self.asSeq.add ls - -template extend*[T](self: var PyList[T], ls: Iterable[T]) = - for i in ls: - self.append(i) - -func insert*[T](self: var PyList[T], idx: int, x: T) = - if idx > self.len: - self.append(x) - else: - system.insert(self.asSeq, x, normIdx(idx, self)) - -func delitem*(self: var PyList, idx: int) = - self.asSeq.delete normIdx(idx, self) - -func clear*(self: var PyList) = - self.asSeq.setLen 0 - -template rev2ord(reverse: bool): algorithm.SortOrder = - if reverse: Descending - else: Ascending - -func sort*[T](self: var PyList[T], reverse=false) = - ## list.sort(reverse=False) - self.asSeq.sort(order=rev2ord(reverse)) - -func sorted*[T](self: PyList[T], reverse=false): PyList[T] = - ## sorted(list, reverse=False) - newPyList self.asSeq.sorted(order=rev2ord(reverse)) - -func `+`*[T](self: PyList[T], x: openArray[T]): PyList[T] = - list(self.asSeq & x) - -func list*[T](x: sink seq[T]): PyList[T] = newPyList x -func list*[T](a: sink openArray[T]): PyList[T] = newPyList a -# Impl end - -# the following does nothing with how PyList is implemented. - -func list*[T](): PyList[T] = - runnableExamples: - assert len(list[int]()) == 0 - newPyList[T]() - -func `*`*[T](n: Natural, ls: PyList[T]): PyList[T] = - for _ in 1..n: - result.extend ls - -template `*`*[T](ls: PyList[T], n: Natural): PyList[T] = - ls * n - -func `*=`*[T](self: var PyList[T], n: int) = - if n < 1: self.clear() - self.extend self * (n-1) - -template `+`*[T](self: var PyList[T], x: PyList[T]): PyList[T] = - self.extend x - -# it has side effects as it may call `items` -proc list*[T](iter: Iterable[T]): PyList[T] = - when iter is Sized: - result = newPyList[T](len(iter)) - for i, v in enumerate(iter): - result[i] = v - else: - result = newPyList[T]() - for i in iter: - result.append(i) - -PyList.genDollarRepr '[', ']', linear=true - -type - SortKey[K] = object of RootObj - key: K - SortIdx[K] = object of SortKey[K] - idx: int - SortItem[T, K] = object of SortKey[K] - data: T - -func cmpKey[T; S: SortKey[T]](a, b: S): int = cmp(a.key, b.key) - -template seqSortWithKeyImpl[T, K]( - target, source; - # if write as following, will - # `SIGSEGV: Illegal storage access. (Attempt to read from nil?)` - # when compiling - # target: MutableSequence[T], source: Sequence[T]; - reverse: bool; same: static[bool]) = - # target, source cannot be one obj, unless `same` is true - # target must be lager or equal than source - bind cmpKey - mixin key - template sameOr(a,b): untyped = - when same: a else: b - - when same: - var temp = newSeq[SortItem[T, K]](len(source)) - else: - var temp = newSeq[SortIdx[K]](len(source)) - for i, v in enumerate(source): - temp[i] = sameOr( - SortItem[T, K](key: key(v), data: v), - SortIdx[K](key: key(v), idx: i) - ) - temp.sort(cmp=cmpKey, order=rev2ord(reverse)) - for i, t in temp: - target[i] = sameOr(t.data, source[t.idx]) - -template iterSortWithKeyImpl[T, K]( - target; source; - #target: MutableSequence[T], source: not Sequence[T] and Iterable[T]; - reverse: bool) = - # target, source can be one obj - # target will be overwritten. - bind cmpKey - mixin key - var temp: seq[SortItem[T, K]] - var mIdx = 0 - for v in source: - temp.add SortItem[typeof(key(v)), typeof(v)](key: key(v), data: v) - mIdx.inc - temp.sort(cmp=cmpKey, order=rev2ord(reverse)) - const canSetLen = compiles(target.setLen(1)) - when canSetLen: - target.setLen(mIdx) - for i, t in temp: - target[i] = t.data - else: - for t in temp: - target.append(t.data) - -proc sort*[T, K](self: var PyList[T], - key: proc (x: T): K, reverse=false) = - ## list.sort(key, reverse=False) - seqSortWithKeyImpl[T, K](self, self, reverse, same=true) - -proc sorted*[T, K](x: Sequence[T], - key: proc (x: T): K, reverse=false): PyList[T] = - result = newPyList[T](len(x)) - seqSortWithKeyImpl[T, K](result, x, reverse, same=false) - -proc sorted*[T, K](x: not Sequence[T] and Iterable[T], - key: proc (x: T): K, reverse=false): PyList[T] = - result = newPyList[T]() - iterSortWithKeyImpl[T, K](result, x, reverse) - -genDelItem PyList -genGenericSetItem PyList, Sequence diff --git a/src/pylib/builtins/list_decl.nim b/src/pylib/builtins/list_decl.nim deleted file mode 100644 index d31a4929b..000000000 --- a/src/pylib/builtins/list_decl.nim +++ /dev/null @@ -1,115 +0,0 @@ - -import std/typetraits -import ../pystring/strimpl -type - list*[T] = ref object - data: seq[T] - # shall be a distinct type of seq, as some routiues has different signature - # for example, `seq[T].insert(T, int)` and `list[T].insert(int, T)` -type PyList*[T] = list[T] - - -converter asSeq*[T](self: PyList[T]): seq[T] = self.data -converter asSeq*[T](self: var PyList[T]): var seq[T] = self.data - -func `@`*[T](ls: PyList[T]): seq[T] = ls.data -func setLen*(self: PyList, len: Natural) = - ## EXT. - ## unstable. only works for simple types - # used by Lib/array frombytes - system.setLen(self.data, len) - -func repr*[T: set|string|openArray](self: PyList[T]): string = - system.repr self.data.toOpenArray(0, len(self)-1) -# `repr` defined for other elements' type is in about L160 - -func newPyList*[T](s: sink seq[T]): PyList[T]{.inline.} = PyList[T](data: s) -func newPyList*[T](a: sink openArray[T]): PyList[T]{.inline.} = PyList[T](data: @a) - -static: assert PyStr.distinctBase is string, "current impl of newPyListOfStr assumes PyStr is distinct string" -func newPyListOfStr*(a: PyList[string]): PyList[PyStr]{.inline.} = cast[PyList[PyStr]](a) -func newPyListOfStr*(a: openArray[string]): PyList[PyStr]{.inline.} = newPyListOfStr(newPyList a) - -when true: - #[ XXX: NIM-BUG: as of 2.3.1, without following, compile for a module that imports both test_datetime and test_array - crashes with C compiler error: - - @m..@s..@sbuiltins@slist_decl.nim.c:1250:15: error: incompatible types when assigning to type ‘tySequence__MkqYvXY8u0yYYH9auGhczBw’ from type ‘tySequence__lBgZ7a89beZGYPl8PiANMTA’ - 1250 | (*T1_).data = at___test95datetime_u2909(a_p0, a_p0Len_0); - ]# - template gen(T){.dirty.} = - func newPyList*(a: sink openArray[T]): PyList[T]{.inline.} = PyList[T](data: @a) - gen int - gen float - gen char - -func newPyList*[T](len=0): PyList[T]{.inline.} = newPyList newSeq[T](len) -func newPyListOfCap*[T](cap=0): PyList[T]{.inline.} = - newPyList newSeqOfCap[T](cap) - -iterator items*[T](self: PyList[T]): T = - for i in self.data: yield i - -iterator mitems*[T](self: PyList[T]): var T = - ## EXT. - for i in self.data.mitems: yield i - -iterator pairs*[T](self: PyList[T]): (int, T) = - ## EXT. Nim's auto-enumerate - for (i, e) in self.data.pairs: yield (i, e) - -template getPtr[T](self: seq[T], i: int): ptr T = - when NimMajor == 1: - self[i].unsafeAddr - else: - self[i].addr - -func getPtr*[T](self: sink PyList[T], i: Natural|BackwardsIndex): ptr T{.inline.} = - ## EXT. - ## unstable. - ## used by Lib/array `frombytes` and `tobytes`. - self.data.getPtr i - - -template checkLenientOps*(A, B) = - ## inner. unstable - when defined(pylibNoLenient): - when A is_not B: - {.error: "once pylibNoLenient is defined, " & - " mixin ops between types is forbidden".} - -template cmpBody(op, a, b) = - bind checkLenientOps - checkLenientOps A, B - const opS = astToStr(op) - # Shortcut: if the lengths differ, the arrays differ - when opS == "==": - if a.len != b.len: return - elif opS == "!=": - if a.len != b.len: return true - - for i, e in a: - if e != b[i]: - # We have an item that differs. - result = op(e, b[i]) - return - # No more items to compare -- compare sizes - result = op(a.len, b.len) - -func `<=`[A, B](a: openarray[A], b: openarray[B]): bool = cmpBody `<=`, a, b -func `<` [A, B](a: openarray[A], b: openarray[B]): bool = cmpBody `<`, a, b - -template genMixCmp(op){.dirty.} = - func op*[A, B](self: PyList[A], o: PyList[B]): bool{.inline.} = - bind op - op self.asSeq, o.asSeq - func op*[A, B](self: PyList[A], o: openArray[B]): bool{.inline.} = - bind op - op self.asSeq, o - template op*[A, B](o: openArray[A], self: PyList[B]): bool = - bind op - op(self, o) - -genMixCmp `==` -genMixCmp `<=` -genMixCmp `<` diff --git a/src/pylib/builtins/mathfunc.nim b/src/pylib/builtins/mathfunc.nim deleted file mode 100644 index ec3cbc592..000000000 --- a/src/pylib/builtins/mathfunc.nim +++ /dev/null @@ -1,22 +0,0 @@ - -import math -export math.pow # pow for float - -import ./modPow -export modPow.pow - -import ./round -export round.round - -func pow*(base, exp, modulo: float): int{.error: - "TypeError: pow() 3rd argument not allowed unless all arguments are integers".} - ## raises Error like Python does, but a static error instead of runtime - -func pow*(base: int, exp: Natural): int = - ## .. warning:: `pow` with a negative `exp` shall results in float, - ## but for static-type lang it's not possible for a function to return - ## either a float or int, except for using a boxing type. - ## Therefore for `pow(base, exp)`, `exp` cannot be negative. - - base ^ exp - \ No newline at end of file diff --git a/src/pylib/builtins/min_max.nim b/src/pylib/builtins/min_max.nim deleted file mode 100644 index 6dde4235b..000000000 --- a/src/pylib/builtins/min_max.nim +++ /dev/null @@ -1,157 +0,0 @@ - -import std/macros -import std/tables -import std/hashes - -import std/options - -import ../collections_abc -import ../noneType -import ./iter_next -export iter_next.items - -proc hash(nn: NimNode): Hash = - if nn.len == 0: - if nn.kind == nnkSym: - hash signatureHash(nn) ## for table - else: - hash nn.strVal - else: - hash "" - -template noDefault(kw; symName) = - if ident"default" in kw: - error "TypeError: Cannot specify a default for " & symName & "() with multiple positional arguments" - -let keyId{.compileTime.} = ident"key" - -template addKeyIfExist(result; kw) = - if keyId in kw: - result.add nnkExprEqExpr.newTree(keyId, kw[keyId]) - -type - Comparable* = concept a, b - ## internal. - a < b is bool - PyLibKey*[T; C: Comparable] = proc (x: T): C - -template withDefaultImpl(resultExpr){.dirty.} = - result = default - for i in it: - result = resultExpr - -template withoutDefaultImpl(resultExpr; symName){.dirty.} = - let ite = iter(it) - var res = nextImpl ite - if res.isNone: - raise newException(ValueError, symName & "() iterable argument is empty") - result = res.unsafeGet - while true: - res = nextImpl(ite) - if res.isNone: - return - result = resultExpr - -template cmpByKey[T](dir, key; a, b: T): T = - if dir(key(a), key(b)): a - else: b - - -template gen(sym, dir, symName){.dirty.} = - ## min/max(a, b) for builtin types and `not SomeFloat` is alreadly defined by `system` - func sym*[T; C](a, b: T; key: PyLibKey[T, C]): T = cmpByKey(dir, key, a, b) - func sym*[C: Comparable](a, b: C; key: NoneType): C = sym(a, b) - - func sym*[T](a, b, c: T; args: varargs[T]): T = - result = sym(sym(a, b), c) - for i in args: result = sym(result, i) - - - proc sym*[C: Comparable](it: Iterable[C], key = None): C = - withoutDefaultImpl sym(result, res.unsafeGet), symName - - proc sym*[T; C](it: Iterable[T], - key: PyLibKey[T, C]): T = - withoutDefaultImpl cmpByKey(dir, key, result, res.unsafeGet), symName - - - proc sym*[C: Comparable](it: Iterable[C]; default: C, key = None): C = - withDefaultImpl sym(result, i) - - proc sym*[T; C](it: Iterable[T]; default: T; - key: PyLibKey[T, C]): T = - withDefaultImpl cmpByKey(dir, key, result, i) - - macro sym*(kwargs: varargs[untyped]): untyped = - ## for argument list: `(*args, key)` - ## - ## raises *compile-time* `TypeError` when Python does so, in cases: - ## - ## - `()` # no arg - ## - `(arg[, default][, key])` # only one arg - ## - `(*args, default[, key])` # both args and default are given - let nka = kwargs.len - - var - args = newSeqOfCap[NimNode] nka - kw = newTable[NimNode, NimNode]() - for i in kwargs: - if i.kind == nnkExprEqExpr: - kw[i[0]] = i[1] - else: - args.add i - - let - nargs = args.len - symId = bindSym symName - - case nargs - of 0: - error "TypeError: " & symName & " expected at least 1 argument, got 0", kwargs - of 1: - # return newCall(symId, kwargs) - let - obj = args[0] - res = newCall(symId, kwargs) - err = nnkPragma.newTree nnkExprColonExpr.newTree( - ident"error", - quote do: - "TypeError: '" & $typeof(`obj`) & "' object is not iterable" - ) # {.error: ... .} - # NOTE: do not use `quote do` for pragma directly (like above), - # which causes error message `lineInfo` pointing here - # over source code - return quote do: - when compiles(`res`): - # Why not "`obj` of Iterable": - # Error (Iterable's generic type has to be explictly written) - `res` - else: - `err` - of 2: - noDefault kw, symName - - result = newCall( - symId, - args[0], args[1] - ) - - result.addKeyIfExist kw - else: - noDefault kw, symName - - result = newStmtList() - let resId = genSym(nskVar, symName) - result.add newVarStmt(resId, args[0]) - for i in 1..`, "max" -gen min, `<`, "min" - -when isMainModule: - let ls = [1, 2, -1] - echo max ls diff --git a/src/pylib/builtins/misc.nim b/src/pylib/builtins/misc.nim deleted file mode 100644 index b03ee20b5..000000000 --- a/src/pylib/builtins/misc.nim +++ /dev/null @@ -1,18 +0,0 @@ - -import ../Lib/sys -template id*(x): int = - runnableExamples: - let a = 1.0 - var b = 1 - assert id(a) != id(b) - # not the same as Python's (Python's small int is stored in pool) - block: - var a,b = 1 - assert id(a) != id(b) - bind audit - sys.audit("builtins.id", x) - cast[int]( - when x is ref|ptr|proc|pointer: x - elif NimMajor > 1: x.addr - else: x.unsafeAddr - ) diff --git a/src/pylib/builtins/modPow.nim b/src/pylib/builtins/modPow.nim deleted file mode 100644 index d00dee854..000000000 --- a/src/pylib/builtins/modPow.nim +++ /dev/null @@ -1,149 +0,0 @@ -# `pow` with mod, imported by `./mathfunc` - -import std/math -import std/bitops - -func long_invmod(aa, nn: int): int = - - # translated from CPython3.10.5 `Objetcs/longobject.c` `long_invmod` - var - a = aa - n = nn - - # Should only ever be called for positive n - assert n > 0 - - var b = 1 - var c = 0 - - while n != 0: - let - q = floorDiv(a, n) - r = floorMod(a, n) - a = n - n = r - let t = q * c - let s = b - t - - b = c - c = s - - if a != 1: - # a != 1 we don't have an inverse. - raise newException(ValueError, - "base is not invertible for the given modulus") - # a == 1; b gives an inverse modulo n - return b - -type Long = int ## XXX: current only used in `table` - -const FIVEARY_CUTOFF = 8 - -type Digit = uint8 - -const BitPerByte = 8 - -func bit_length(x: SomeInteger): int = - sizeof(x) * BitPerByte - bitops.countLeadingZeroBits x - -# Py_SIZE -template get_ob_size(x): int = ceilDiv(x.bit_length(), sizeof(Digit)*BitPerByte) - -template get_ob_digit(x, i): Digit = cast[UncheckedArray[Digit]](x)[i] - -# XXX: PyLong_SHIFT is 15 or 30 -const Long_SHIFT = sizeof(Digit) * BitPerByte - 1 # 7 - -func long_pow(v, w, x: int): int = - - # translated from CPython3.10.5 `Objetcs/longobject.c` `long_pow` - var (a, b, c) = (v, w, x) - var negativeOutput = false # if x<0 return negative output - - if c == 0: - raise newException(ValueError, "pow() 3rd argument cannot be 0") - elif c < 0: - negativeOutput = true - c = -c - elif c == 1: - return 0 - - #[ if exponent is negative, negate the exponent and - replace the base with a modular inverse ]# - if b < 0: - b = -b - a = long_invmod(a, c) - - #[ Reduce base by modulus in some cases: - 1. If base < 0. Forcing the base non-negative makes things easier. - 2. If base is obviously larger than the modulus. The "small - exponent" case later can multiply directly by base repeatedly, - while the "large exponent" case multiplies directly by base 31 - times. It can be unboundedly faster to multiply by - base % modulus instead. - We could _always_ do this reduction, but - we can also do it when it buys something. ]# - if (a < 0 or a > c): - a = floorMod(a, c) - - var z = 1 # accumulated result - template REDUCE(X) = - #[ Perform a modular reduction, X = X % c /* , but leave X alone if c - is not given. */ (Currently `c` is always given) ]# - X = floorMod(X, c) - template MULT(X, Y, result) = - #[ Multiply two values, then reduce the result: - result = X*Y % c. - /* If c is NULL, skip the mod. */ (Currently `c` is always given) ]# - result = X*Y - REDUCE(result) - - let bs = b.get_ob_size() - if bs <= FIVEARY_CUTOFF: - # Left-to-right binary exponentiation (HAC Algorithm 14.79) - # http://www.cacr.math.uwaterloo.ca/hac/about/chap14.pdf - for i in countdown(bs-1, 0): - let bi = b.get_ob_digit i - for ji in countdown(Long_SHIFT, 0): - MULT(z, z, z) - if bi.testBit(ji): - MULT(z, a, z) - - else: - # XXX: Currently this branch is impossible - # as we don't use variable-length integer in Nim - - #[ 5-ary values. If the exponent is large enough, table is - * precomputed so that table[i] == a**i % c for i in range(32). - ]# - var table: array[32, Long] - - #[ Left-to-right 5-ary exponentiation (HAC Algorithm 14.82) ]# - table[0] = z - for i in 1..31: - MULT(table[i-1], a, table[i]) - - for i in countdown(bs - 1, 0): - let bi = b.get_ob_digit i - - for j in countdown(Long_SHIFT - 5, 0, 5): - let index = (bi shr j.Digit) and 0x1f - for k in 0..<5: - MULT(z, z, z) - if index != 0: - MULT(z, table[index], z) - - if negativeOutput and z != 0: - z = z - c - result = z - -func pow*(base, exp, modulo: int): int = - runnableExamples: - assert pow(10, 20, 3) == 1 # 10^20 is bigger than `high int64` - assert pow(7, 2, 13) == 10 - assert pow(7, 20, 13) == 3 - doAssertRaises ValueError: - discard pow(1000, -2, 2) - # base is not invertible for the given modulus - assert pow(1234, 20, 73) == 9 - long_pow(base, exp, modulo) diff --git a/src/pylib/builtins/numTypes.nim b/src/pylib/builtins/numTypes.nim deleted file mode 100644 index 6c21ff6ee..000000000 --- a/src/pylib/builtins/numTypes.nim +++ /dev/null @@ -1,3 +0,0 @@ - -import ../numTypes -export numTypes diff --git a/src/pylib/builtins/oopFuncs.nim b/src/pylib/builtins/oopFuncs.nim deleted file mode 100644 index 3f97757af..000000000 --- a/src/pylib/builtins/oopFuncs.nim +++ /dev/null @@ -1,25 +0,0 @@ - - -import std/macros - -macro wrapop(op: static[string], obj, class_or_tuple): bool = - if class_or_tuple.kind == nnkTupleConstr: - template iOr(a,b): untyped = infix(a,"or",b) - result = infix(obj, op, class_or_tuple[0]) - for i in 1.. 0 else 0 - if x > 0: - let more = (x - float(I(x)) > 0) - I(x) + I(more) - else: I(0) - -func rangeLen*[I](start, stop, step: I): I = - iPosCeil[I]((stop - start) / step) diff --git a/src/pylib/builtins/private/ncomplex_pow.nim b/src/pylib/builtins/private/ncomplex_pow.nim deleted file mode 100644 index 05fe13011..000000000 --- a/src/pylib/builtins/private/ncomplex_pow.nim +++ /dev/null @@ -1,182 +0,0 @@ -## why this module doesn't use `pow` in std/complex (we call it `ncomplex.pow` below): -## -## - For integer 2nd arg, we'll use `c_powi`_ or `c_powu`, -## which produce more precious result than ncomplex.pow -## - ncomplex.pow doesn't raise any exception -from std/complex as ncomplex import Complex -from std/math import copysign, hypot, pow, arctan2, exp, ln, cos, sin, floor -template atan2(x, y): untyped = arctan2(x, y) -from ../../Lib/math_impl/isX import isnan, isinf, isfinite -from ../../Lib/math_impl/errnoUtils import prepareRWErrno, setErrno, setErrno0, isErr, isErr0, - ERANGE, EDOM -from ./pycore_pymath import Py_ADJUST_ERANGE2 -from ../../pyerrors/aritherr import ZeroDivisionError - -template opt_ARM64_patch(s) = - ## Avoid bad optimization on Windows ARM64 until the compiler is fixed - when not defined(js) and not defined(nimscript): - {.emit: "\n#ifdef _M_ARM64\n#pragma optimize(\"\", " & s & - ")\n#endif\n".} -template push_ARM64_patch = opt_ARM64_patch "off" -template pop_ARM64_patch = opt_ARM64_patch "on" - -proc Py_c_quot[T](a, b: Complex[T]): Complex[T] = - ## as ncomplex.`/` is just almost the same as "the original algorithm" describled below, - ## so we do not use it here. - ## The following is CPython's comment: - ## - ## **************************************************************** - ## This was the original algorithm. It's grossly prone to spurious - ## overflow and underflow errors. It also merrily divides by 0 despite - ## checking for that(!). The code still serves a doc purpose here, as - ## the algorithm following is a simple by-cases transformation of this - ## one: - ## - ## Py_complex r; - ## double d = b.re*b.re + b.im*b.im; - ## if (d == 0.) - ## errno = EDOM; - ## r.re = (a.re*b.re + a.im*b.im)/d; - ## r.im = (a.im*b.re - a.re*b.im)/d; - ## return r; - ## **************************************************************** - ## This algorithm is better, and is pretty obvious: first divide the - ## numerators and denominator by whichever of {b.re, b.im} has - ## larger magnitude. The earliest reference I found was to CACM - ## Algorithm 116 (Complex Division, Robert L. Smith, Stanford - ## University). - push_ARM64_patch - prepareRWErrno - - let abs_breal = if b.re < 0: -b.re else: b.re - let abs_bimag = if b.im < 0: -b.im else: b.im - if abs_breal >= abs_bimag: - ## divide tops and bottom by b.re - if abs_breal == 0: - setErrno EDOM - result.re = 0 - result.im = 0 - else: - let ratio = b.im / b.re - let denom = b.re + b.im * ratio - result.re = (a.re + a.im * ratio) / denom - result.im = (a.im - a.re * ratio) / denom - elif abs_bimag >= abs_breal: - ## divide tops and bottom by b.im - let ratio = b.re / b.im - let denom = b.re * ratio + b.im - assert(b.im != 0) - result.re = (a.re * ratio + a.im) / denom - result.im = (a.im * ratio - a.re) / denom - else: - ## At least one of b.re or b.im is a NaN - result.re = NaN - result.im = NaN - ## Recover infinities and zeros that computed as nan+nanj. See e.g. - ## the C11, Annex G.5.2, routine _Cdivd(). - if isnan(result.re) and isnan(result.im): - if (isinf(a.re) or isinf(a.im)) and isfinite(b.re) and isfinite(b.im): - let x = copysign(if isinf(a.re): 1.0 else: 0.0, a.re) - let y = copysign(if isinf(a.im): 1.0 else: 0.0, a.im) - result.re = Inf * (x * b.re + y * b.im) - result.im = Inf * (y * b.re - x * b.im) - elif (isinf(abs_breal) or isinf(abs_bimag)) and isfinite(a.re) and - isfinite(a.im): - let x = copysign(if isinf(b.re): 1.0 else: 0.0, b.re) - let y = copysign(if isinf(b.im): 1.0 else: 0.0, b.im) - result.re = 0.0 * (a.re * x + a.im * y) - result.im = 0.0 * (a.im * x - a.re * y) - pop_ARM64_patch - -proc Py_c_pow[T](a, b: Complex[T]): Complex[T] = - ## `std/complex`.pow does never set errno - prepareRWErrno - if b.re == 0.0 and b.im == 0.0: - result.re = 1.0 - result.im = 0.0 - elif a.re == 0.0 and a.im == 0.0: - if b.im != 0.0 or b.re < 0.0: - setErrno EDOM - result.re = 0.0 - result.im = 0.0 - else: - let - vabs = hypot(a.re, a.im) - at = atan2(a.im, a.re) - var - len = pow(vabs, b.re) - phase = at * b.re - if b.im != 0.0: - len = len / exp(at * b.im) - phase += b.im * ln(vabs) - result.re = len * cos(phase) - result.im = len * sin(phase) - Py_ADJUST_ERANGE2(result.re, result.im) - -template c_prod(a: var Complex, b) = - ## inplace complex product - ncomplex.`*=`(a, b) - -template c_1[T]: Complex[T] = ncomplex.complex[T](1, 0) - -func c_powuImpl[T](x: Complex[T]; n: SomeInteger): Complex[T] = - # assuming n > 0 - var - p = x - mask = typeof(n) 1 - result = c_1[T]() - - # multiply in step of binary system - while 0 < mask and mask <= n: - # mask 1..n in power of 2 - if bool(n and mask): - result.c_prod p - mask = mask shl 1 - p.c_prod p - -func c_powu*[T](x: Complex[T]; n: Natural): Complex[T]{.raises:[], inline.} = c_powuImpl(x, n) - -func c_powi*[T](x: Complex[T], i: SomeInteger): Complex[T]{.raises:[], inline.} = - if i > 0: c_powuImpl(x, i) - else: Py_c_quot(c_1[T](), c_powuImpl(x, -i)) - -template Py_c_pow(a, b): Complex = ncomplex.pow(a, b) - -template checkedPowBody(powImplBody) = - prepareRWErrno - setErrno0 - powImplBody - if isErr EDOM: - raise newException(ZeroDivisionError, - "zero to a negative or complex power"); - - elif isErr ERANGE: - raise newException(OverflowDefect, - "complex exponentiation"); - -func pow*[T](a, b: Complex[T]): Complex[T] = - checkedPowBody: - # Check whether the exponent has a small integer value, and if so use - # a faster and more accurate algorithm. - if b.im == 0.0 and b.re == floor(b.re) and # b.re still may be infinite till here - abs(b.re) <= 100.0: - # b.re is a finite float of [-100, 100] - result = c_powi(a, int(b.re)) - Py_ADJUST_ERANGE2(result.re, result.im) - else: - result = Py_c_pow(a, b) - -func pow*[T](self: Complex[T], i: SomeInteger): Complex[T] = - checkedPowBody: - result = c_powi(self, i) - Py_ADJUST_ERANGE2(result.re, result.im) - -func pow*[T](self: Complex[T], n: static Natural): Complex[T]{.compileTime.} = - checkedPowBody: - result = c_powu(self, n) - Py_ADJUST_ERANGE2(result.re, result.im) - -func powu*[T](self: Complex[T], n: Natural): Complex[T] = - checkedPowBody: - result = c_powu(self, n) - Py_ADJUST_ERANGE2(result.re, result.im) diff --git a/src/pylib/builtins/private/pycore_pymath.nim b/src/pylib/builtins/private/pycore_pymath.nim deleted file mode 100644 index 5945b5189..000000000 --- a/src/pylib/builtins/private/pycore_pymath.nim +++ /dev/null @@ -1,46 +0,0 @@ - -## Only used for ./ncomplex_pow.nim -## -## For other of CPython/Include/internal/pycore_pymath.h, see pylib/pyconfig/pycore/pymath.nim - -from ../../Lib/math_impl/errnoUtils import prepareRWErrno, setErrno, setErrno0, isErr, isErr0, ERANGE, EDOM - -const - Py_HUGE_VAL = Inf # As Nim alreadly uses Infinity, so the host system shall always support `INFINITY`, not just HUGE_VAL - - -proc Py_ADJUST_ERANGE1*(x: float) {.inline.} = - ## Py_ADJUST_ERANGE1(x) - ## Py_ADJUST_ERANGE2(x, y) - ## Set errno to 0 before calling a libm function, and invoke one of these - ## macros after, passing the function result(s) (_Py_ADJUST_ERANGE2 is useful - ## for functions returning complex results). This makes two kinds of - ## adjustments to errno: (A) If it looks like the platform libm set - ## errno=ERANGE due to underflow, clear errno. (B) If it looks like the - ## platform libm overflowed but didn't set errno, force errno to ERANGE. In - ## effect, we're trying to force a useful implementation of C89 errno - ## behavior. - ## Caution: - ## This isn't reliable. C99 no longer requires libm to set errno under - ## any exceptional condition, but does require +- HUGE_VAL return - ## values on overflow. A 754 box *probably* maps HUGE_VAL to a - ## double infinity, and we're cool if that's so, unless the input - ## was an infinity and an infinity is the expected result. A C89 - ## system sets errno to ERANGE, so we check for that too. We're - ## out of luck if a C99 754 box doesn't map HUGE_VAL to +Inf, or - ## if the returned result is a NaN, or if a C89 box returns HUGE_VAL - ## in non-overflow cases. - ## - if isErr0: - if x == Py_HUGE_VAL or x == -Py_HUGE_VAL: - setErrno ERANGE - elif isErr(ERANGE) and x == 0.0: - setErrno0 - -proc Py_ADJUST_ERANGE2*(x, y: float) {.inline.} = - if x == Py_HUGE_VAL or x == -Py_HUGE_VAL or y == Py_HUGE_VAL or y == -Py_HUGE_VAL: - if isErr0: - setErrno ERANGE - elif isErr ERANGE: - setErrno0 - diff --git a/src/pylib/builtins/private/strIter.nim b/src/pylib/builtins/private/strIter.nim deleted file mode 100644 index 1492e73c9..000000000 --- a/src/pylib/builtins/private/strIter.nim +++ /dev/null @@ -1,59 +0,0 @@ - -# as strimpl export len(c: char), -# we use another name to prevent `Error: ambiguous call` -template calLen(cs: char): int = 1 -template calLen(cs: string): int = cs.len - -template strIterImpl*(it: typed{atom}; strProc; - start, stop: char|string; linear = false; useIter = true): string = - ## requires `iter(it)`, `it.len`, `it[int]` - bind calLen - let le = it.len - var result = newStringOfCap(calLen(start) + 3*le + calLen(stop) - 2) - result.add start - when linear: - if le != 0: - result.add it[0].strProc - for i in 1.. 0: - while res <= (rng.stop - 1): - yield res - res += rng.step - else: - let opposite = -rng.step - while res >= (rng.stop + 1): - yield res - res -= opposite - -func contains*[T](x: PyRange[T], y: T): bool = - ## Checks if given value is in range - result = - if x.step > 0: - y >= x.start and y < x.stop - else: - y > x.stop and y <= x.start - result = result and ((y - x.start) mod x.step == 0) - -func `[]`*[T](x: PyRange[T], y: Natural): T {.inline.} = - ## Get value from range by its index - assert y < x.len, "Index out of bounds" - result = x.start + (x.step * y) - -func min*[T](x: PyRange[T]): T {.inline.} = - ## Get minimum value from range. Python's `max(range(...))` - if unlikely(x.len == 0): - raise newException(ValueError, "min() arg is an empty sequence") - x[if x.step > 0: 0 else: x.len - 1] - -func max*[T](x: PyRange[T]): T {.inline.} = - ## Get maximum value from range. Python's `max(range(...))` - if unlikely(x.len == 0): - raise newException(ValueError, "max() arg is an empty sequence") - x[if x.step > 0: x.len - 1 else: 0] - -func count*[T](r: PyRange[T], x: T): int = - int(x in r) - -func index*[T](r: PyRange[T], x: T): int = - if x notin r: - raise newException(ValueError, $x & " is not in range") - int((x - r.start) div r.step) - - -func `==`[T](x, y: PyRange[T]): bool = - ## Since Python 3.3: - ## Compares based on the sequence of values they define - ## (instead of comparing based on object identity). - let eqLen = x.len == y.len - if eqLen and x.len == 0: return true # empty ranges are equal - - if x.start == y.start and x.step == y.step: - if x.stop == y.stop: return true - return eqLen diff --git a/src/pylib/builtins/pyslice.nim b/src/pylib/builtins/pyslice.nim deleted file mode 100644 index 9e7ab0c6d..000000000 --- a/src/pylib/builtins/pyslice.nim +++ /dev/null @@ -1,79 +0,0 @@ - - -type - PySlice1* = ref object of RootObj ## slice of 1 step - start*, stop*: int - - PySlice* = ref object of PySlice1 - step*: int - -func `==`*(self: PySlice, o: PySlice): bool = - template eq(a): bool = self.a == o.a - eq(start) and eq(stop) and eq(step) - -template richcmp(op) = - func op*(self: PySlice, o: PySlice): bool = - template unpack(s): tuple = (s.start, s.stop, s.step) - op unpack(self), unpack(o) - -richcmp `<` -richcmp `<=` -# other cmp ops are handled by system's template - -func slice*(start, stop: int): PySlice1 = - PySlice1(start: start, stop: stop) - -func slice*(start, stop: int, step: int): PySlice = - PySlice(start: start, stop: stop, step: step) - -func slice*(stop: int): PySlice1 = slice(0, stop) - -converter toPySlice*(s: PySlice1): PySlice = - result = PySlice(start: s.start, stop: s.stop, step: 1) - -proc toNimSlice*(s: PySlice1): Slice[int] = - result.b = s.stop - 1 - result.a = s.start - assert result.a >= 0 and result.b >= 0 - -func repr*(self: PySlice): string = - result = "slice(" & $self.start & ", " - result.add $self.stop & ", " - result.add $self.step & ')' - - -func getLongIndices(self: PySlice, length: int): - tuple[start, stop, step: int] = - let step = self.step - let step_is_negative = step < 0 - - var lower, upper: int - if step_is_negative: - lower = -1 - upper = length + lower - else: - lower = 0 - upper = length - - template cal(st) = - var st = self.st - if st < 0: - st.inc length - - if st < lower: - st = lower - else: - if st > upper: - st = upper - cal start - cal stop - result.start = start - result.stop = stop - result.step = step - -func indices*(self: PySlice, length: int): (int, int, int) = - if length < 0: - raise newException(ValueError, "length should not be negative") - getLongIndices(self, length) - - diff --git a/src/pylib/builtins/pytuple.nim b/src/pylib/builtins/pytuple.nim deleted file mode 100644 index b000601f5..000000000 --- a/src/pylib/builtins/pytuple.nim +++ /dev/null @@ -1,36 +0,0 @@ -## Currently we just use `system.tuple` for Python's tuple - -import std/macros - -macro items*(t: tuple): untyped = - result = newNimNode nnkBracket - if t.len != 0: - for i in t: - result.add i - else: - let nElem = t.getTypeImpl.len - if nElem == 0: - return parseExpr( - "items(array[0, int]([]))" - ) # any type shall be ok - for i in 0.. "[Field0 = 1]" when JS - genDollarRepr tuple, '(', ')', useIter=false - -when isMainModule: - # not compile: - #for i in (1, 2.0): echo i - - for i in (): echo i - - for i in (1, 2): echo i - let t = (1, 2) - for i in t: - echo i diff --git a/src/pylib/builtins/reprImpl.nim b/src/pylib/builtins/reprImpl.nim deleted file mode 100644 index 36844efc2..000000000 --- a/src/pylib/builtins/reprImpl.nim +++ /dev/null @@ -1,86 +0,0 @@ - -const - q = '\'' - Q = '"' - Qq = {Q, q} - - -func Py_addEscapedChar(result: var string, c: char, - escapeQuotationMark: static[set[char]] = Qq) = - ## snippet from CPython-3.14.0-alpha/Objects/bytesobject.c - ## PyBytes_Repr - template slash(c: char) = - result.add '\\' - result.add c - template push(c: char) = - result.add c - case c - of '\\': slash '\\' - of '\t': slash 't' - of '\n': slash 'n' - of '\r': slash 'r' - of escapeQuotationMark: - slash c - elif c < ' ' or c.ord > 0x7f: - const hexdigits = "0123456789abcdef" - slash 'x' - let ci = c.ord - push hexdigits[(ci and 0xf0) shr 4] - push hexdigits[(ci and 0xf)] - else: - when defined(useNimCharEsc): - if c == '\e': result.add "\\x1b" - else: push c - else: push c - -func raw_repr(us: string - ,escapeQuotationMark: static[set[char]] = Qq - ,escape127: static[bool] = false # if to escape char greater than `\127` -): string = - template addMayEscape(s: string, c: char) = - result.Py_addEscapedChar c, escapeQuotationMark - for c in us: - template addEscaped = - result.addMayEscape c - when escape127: - addEscaped - else: - if c > '\127': - result.add c # add non-ASCII utf-8 AS-IS - else: - addEscaped - -func mycontains(s: string, c: char): bool = - # NIM-BUG: once using `c in s` when `nimble testC/JS`, it hangs forever - for i in s: - if i == c: return true - -template implWith(a; rawImpl; arg_escape127: bool): untyped = - let us = a # if a is an expr, avoid `a` being evaluated multiply times - when defined(singQuotedStr): - q & rawImpl(us, escape127=arg_escape127) & q - else: - if us.mycontains Q: - q & rawImpl(us, escapeQuotationMark={q}, escape127=arg_escape127) & q - else: - if us.mycontains q: - Q & rawImpl(us, escapeQuotationMark={Q}, escape127=arg_escape127) & Q - else: # neither ' nor " - q & rawImpl(us, escape127=arg_escape127) & q - -func pyreprImpl*(s: string, escape127: static[bool] = false): string = - ## Python's `repr` - ## but returns Nim's string. - ## - ## nim's Escape Char feature can be enabled via `-d:useNimCharEsc`, - ## in which '\e' (i.e.'\x1B' in Nim) will be replaced by "\\e" - ## - runnableExamples: - # NOTE: string literal's `repr` is `system.repr`, as following. - assert repr("\"") == "\"\\\"\"" # string literal of "\"" - # use pyrepr for any StringLike and returns a PyStr - assert pyreprImpl("\"") == "'\"'" - implWith(s, raw_repr, escape127) - -func pyreprbImpl*(s: string): string = - 'b' & s.pyreprImpl(true) diff --git a/src/pylib/builtins/round.nim b/src/pylib/builtins/round.nim deleted file mode 100644 index e99c44915..000000000 --- a/src/pylib/builtins/round.nim +++ /dev/null @@ -1,3 +0,0 @@ - -import ./[round_float, round_int] -export round_float, round_int diff --git a/src/pylib/builtins/round/NOT_PY_SHORT_FLOAT_REPR.nim b/src/pylib/builtins/round/NOT_PY_SHORT_FLOAT_REPR.nim deleted file mode 100644 index 9dd64159b..000000000 --- a/src/pylib/builtins/round/NOT_PY_SHORT_FLOAT_REPR.nim +++ /dev/null @@ -1,40 +0,0 @@ - - -import std/math # math.round -from ./reimporter import isfinite - -proc round*(x: float, ndigits: int): float = - ##[ fallback version, to be used when correctly rounded binary<->decimal - conversions aren't available]## - var - pow1: cdouble - pow2: cdouble - y: cdouble - if ndigits >= 0: - if ndigits > 22: - # pow1 and pow2 are each safe from overflow, but - # pow1*pow2 ~= pow(10.0, ndigits) might overflow - pow1 = pow(10.0, cdouble(ndigits - 22)) - pow2 = 1e22 - else: - pow1 = pow(10.0, cdouble(ndigits)) - pow2 = 1.0 - y = (x * pow1) * pow2 - # if y overflows, then rounded value is exactly x - if not isfinite(y): - return x - else: - pow1 = pow(10.0, cdouble -ndigits) - pow2 = 1.0 - ## unused; silences a gcc compiler warning - y = x / pow1 - result = math.round(y) - if abs(y - result) == 0.5: - result = 2.0 * math.round(y / 2.0) - if ndigits >= 0: - result = (result / pow2) / pow1 - else: - result = result * pow1 - # if computation resulted in overflow, raise OverflowError - if not isfinite(result): - raise newException(OverflowDefect, "overflow occurred during round") diff --git a/src/pylib/builtins/round/PY_SHORT_FLOAT_REPR.nim b/src/pylib/builtins/round/PY_SHORT_FLOAT_REPR.nim deleted file mode 100644 index 1053e84d0..000000000 --- a/src/pylib/builtins/round/PY_SHORT_FLOAT_REPR.nim +++ /dev/null @@ -1,64 +0,0 @@ - -import ./reimporter - -import_pyconfig -import_dtoa -import_obmalloc - -# Include/internal/pycore_pymath.h - -proc round*(dd: float, ndigits: int): float = - ##[ version of double_round that uses the correctly-rounded string<->double - conversions from Python/dtoa.c ]## - const mode = 3 - const MyBufLen = 100 - var - mybuflen = MyBufLen - buf, buf_end: cstring - shortbuf: array[MyBufLen, cchar] - mybuf: cstring = cast[cstring](addr shortbuf[0]) - decpt, sign: c_int - - Py_SET_53BIT_PRECISION_HEADER - - # round to a decimal string - - Py_SET_53BIT_PRECISION_START - buf = dtoa(dd.cdouble, mode.cint, ndigits.cint, decpt, sign, buf_end) - Py_SET_53BIT_PRECISION_END - template preexit = - freedtoa buf - template chkNoMem(p: ptr|cstring) = - if p.isNil: - preexit - raise newException(OutOfMemDefect, "") - buf.chkNoMem - - #[Get new buffer if shortbuf is too small. Space needed <= buf_end - - buf + 8: (1 extra for '0', 1 for sign, 5 for exp, 1 for '\0').]# - let buflen = cast[int](buf_end) - cast[int](buf) - if buflen + 8 > mybuflen: - mybuflen = buflen + 8 - mybuf = pyallocStr mybuflen - mybuf.chkNoMem - - # copy buf to mybuf, adding exponent, sign and leading 0 - PyOS_snprintf(mybuf, mybuflen, "%s0%se%d", - (if sign.bool: cstring"-" else: cstring""), - buf, cast[cint](decpt) - buflen.cint) - - # and convert the resulting string back to a double - prepareRWErrno - setErrno0 - Py_SET_53BIT_PRECISION_START - result = strtod(mybuf, nil) - Py_SET_53BIT_PRECISION_END - - if isErr(ERANGE) and abs(result) >= 1: - raise newException(OverflowDefect, "rounded value too large to represent") - - # done computin value - if cast[ptr cchar](mybuf) != shortbuf[0].addr: - pyfreeStr mybuf - - preexit diff --git a/src/pylib/builtins/round/int_round.nim b/src/pylib/builtins/round/int_round.nim deleted file mode 100644 index 98609a810..000000000 --- a/src/pylib/builtins/round/int_round.nim +++ /dev/null @@ -1,28 +0,0 @@ - -from ../../ops import divmod, `**`, `%` - -func round*(x: int): int = x - -func divmodNear(a, b: int): tuple[q, r: int] = - var (q, r) = divmod(a, b) - - # round up if either r / b > 0.5, or r / b == 0.5 and q is odd. - # The expression r / b > 0.5 is equivalent to 2 * r > b if b is - # positive, 2 * r < b if b negative. - let - greater_than_half = if b > 0: 2*r > b else: 2*r < b - exactly_half = 2*r == b - if greater_than_half or exactly_half and q % 2 == 1: - q += 1 - r -= b - return (q, r) - -func round*(x: int, ndigit: int): int = - if ndigit >= 0: return x - let ndigit = -ndigit - var x10: typeof(10 ** ndigit) - try: - x10 = 10 ** ndigit - except OverflowDefect: - return 0 - x - divmodNear(x, x10).r diff --git a/src/pylib/builtins/round/no_ndigit.nim b/src/pylib/builtins/round/no_ndigit.nim deleted file mode 100644 index 13c526c98..000000000 --- a/src/pylib/builtins/round/no_ndigit.nim +++ /dev/null @@ -1,28 +0,0 @@ - -import std/math # math.round - -template chkAsPy[F](x: F) = - ## used to keep along with Python's error handle - ## check if x can be converted to PyLong - template err(f) = raise newException(ValueError, "cannot convert float " & f & " to integer") - case x.classify - of fcNan: err "NaN" - of fcInf, fcNegInf: err "infinity" - else: discard - -func round*[F: SomeFloat](x: F): F = - ## if two multiples are equally close, rounding is done toward the even choice - ## a.k.a.round-to-even - ## - ## .. hint:: Nim's `round` in `std/math` just does like C's round - ## - runnableExamples: - assert round(6.5) == 6 - assert round(7.5) == 8 - result = math.round(x) - if abs(x-result) == 0.5: - # halfway case: round to even - result = 2.0*round(x/2.0) - - # return PyLong_FromDouble.... - result.chkAsPy diff --git a/src/pylib/builtins/round/reimporter.nim b/src/pylib/builtins/round/reimporter.nim deleted file mode 100644 index 2b60aec05..000000000 --- a/src/pylib/builtins/round/reimporter.nim +++ /dev/null @@ -1,18 +0,0 @@ - -template gen(name, lib){.dirty.} = - template name* = import lib - -gen import_pyconfig, ../../pyconfig/main -gen import_dtoa, ../../impure/math/dtoa -gen import_obmalloc, ../../Objects/obmalloc - -from ../../Lib/math_impl/errnoUtils import prepareRWErrno, setErrno0, isErr, ERANGE -import ../../impure/Python/mysnprintf - -export - prepareRWErrno, setErrno0, isErr, ERANGE, - mysnprintf - - -from ../../Lib/math_impl/isX import isfinite -export isfinite diff --git a/src/pylib/builtins/round_float.nim b/src/pylib/builtins/round_float.nim deleted file mode 100644 index 37b38565e..000000000 --- a/src/pylib/builtins/round_float.nim +++ /dev/null @@ -1,40 +0,0 @@ - -import std/fenv - -from ../Lib/math_impl/isX import isfinite -import ../pyconfig/pycore/pymath/short_float_repr -import ./round/no_ndigit -export no_ndigit.round - -const weirdTarget = defined(nimscript) or defined(js) -when not weirdTarget and PY_SHORT_FLOAT_REPR: - import ./round/PY_SHORT_FLOAT_REPR as impl # not support JS yet -else: - import ./round/NOT_PY_SHORT_FLOAT_REPR as impl - -type F = float -proc round*(x: F, ndigit: int): F = - ##[ translated from CPython/Objects/floatobject.c:double_round - rounds a finite double to the closest multiple of - `10**-ndigits`; here ndigits is within reasonable bounds (typically, -308 <= - ndigits <= 323). Returns a Python float, or sets a Python error and - returns NULL on failure (OverflowError and memory errors are possible - - .. hint:: - variant whose `F` is `float32` is not implemented, - and won't be unless https://netlib.org/fp/ftoa.c is implemented ( - none as of 2025-02-17) - ]## - if not x.isfinite: - return x - - #[ Deal with extreme values for ndigits. For ndigits > NDIGITS_MAX, x - always rounds to itself. For ndigits < NDIGITS_MIN, x always - rounds to +-0.0. Here 0.30103 is an upper bound for log10(2). ]# - const - NDIGITS_MAX = int (F.mantissaDigits-F.minExponent) * 0.30103 - NDIGITS_MIN = -int (F.maxExponent + 1) * 0.30103 - - if ndigit > NDIGITS_MAX: x - elif ndigit < NDIGITS_MIN: 0.0 * x # return 0.0, but with sign of x - else: impl.round x, ndigit diff --git a/src/pylib/builtins/round_int.nim b/src/pylib/builtins/round_int.nim deleted file mode 100644 index 41e165248..000000000 --- a/src/pylib/builtins/round_int.nim +++ /dev/null @@ -1,7 +0,0 @@ - -import ./round/int_round -import ../noneType - -func round*(x: int, _: NoneType): int = int_round.round(x) -export int_round.round - diff --git a/src/pylib/builtins/set.nim b/src/pylib/builtins/set.nim deleted file mode 100644 index 3be376d8a..000000000 --- a/src/pylib/builtins/set.nim +++ /dev/null @@ -1,157 +0,0 @@ -## set and its methods. -## -## ## set type -## `set[T]` is still for `system.set[T]`, -## with its restriction of only allowing small ordinal as elements. -## `PySet[T]` is used to minic Python's. -## -## ## Literal -## Something like `{1,2}` shall be rewritten as `pyset([1,2])`, -## please note either `pyset((1,2))` or `pyset({1,2})` doesn't mean the same. -import std/sets -import std/macros -from ../collections_abc import Iterable -import ./set_decl -export set_decl except asHashSet, incl, excl - -type - SomeSet*[H] = SomePySet[H] or HashSet[H] or OrderedSet[H] or system.set[H] - -macro genpysets(defs) = - let name = ident"pyset" - result = newStmtList() - for def in defs: - var nDef = def.copyNimTree() - nDef[0][^1] = name - result.add(def, nDef) - -genpysets: - proc set*[H](): PySet[H] = - newPySet initHashSet[H]() - proc set*[H](s: HashSet[H]): PySet[H] = - newPySet s - proc set*[H](s: SomePySet[H]): PySet[H] = set(s.asHashSet) - proc set*[H](arr: openArray[H]): PySet[H] = set arr.toHashSet - proc set*[H](iterable: Iterable[H]): PySet[H] = - result = set[H]() - for i in iterable: - result.incl i - -proc frozenset*[H](): PyFrozenSet[H] = - newPyFrozenSet initHashSet[H]() -proc frozenset*[H](s: HashSet[H]): PyFrozenSet[H] = - newPyFrozenSet s -proc frozenset*[H](s: SomePySet[H]): PyFrozenSet[H] = frozenset(s.asHashSet) -proc frozenset*[H](arr: openArray[H]): PyFrozenSet[H] = frozenset arr.toHashSet -proc frozenset*[H](it: Iterable[H]): PyFrozenSet[H] = - # NIM-BUG: - # sth like: when compiles(iterable.len): set[H](iterable.len) else: .. - # causes compile error - result = frozenset[H]() - for i in it: - result.incl i - -# Q: Why not define as `set` or `pyset` -# A: That makes empty set impossible. -macro pysetLit*(lit): PySet = - ## To solve: `pyset({1,2,3})` is invalid - expectKind lit, nnkCurly - var ls = newNimNode nnkBracket - for i in lit: - ls.add i - result = newCall("pyset", ls) - -template somepyset[H](S: typedesc[PySet[H]], s: typed): S = pyset[H](s) -template somepyset[H](S: typedesc[PyFrozenSet[H]], s: typed): S = frozenset[H](s) - -template copy*[H; S: SomePySet[H]](self): S = - bind somepyset; somepyset(S, self) - -template doBinData(op){.dirty.} = - proc op*[H](self, o: PySet[H]): PySet[H] = - pyset op(self.asHashSet, o.asHashSet) - proc op*[H](self: PyFrozenSet[H]; o: SomePySet[H]): PyFrozenSet[H] = - frozenset op(self.asHashSet, o.asHashSet) - proc op*[H](self: PySet[H]; o: PyFrozenSet[H]): PyFrozenSet[H] = - frozenset op(self.asHashSet, o.asHashSet) - -macro doBinDatas(syms: varargs[untyped]) = - result = newStmtList() - for sym in syms: - result.add newCall(ident"doBinData", sym) - -doBinDatas `-`, intersection, union, difference, symmetric_difference - -const SetLitBugMsg = "When used, Nim compiler(at least 2.0.0-2.1.2) will complain:\n" & """ -'Error: unhandled exception: ccgexprs.nim(1994, 9) `setType.kind == tySet`', -Consider using `pyset` instead of set literal.""" -template genBinSys(ret, op){.dirty.} = - # XXX: see below - proc op*[H](self: SomePySet[H], s: system.set[H]): ret{.error: SetLitBugMsg.} = - op self, pyset(s) - proc op*[H](s: system.set[H], self: SomePySet[H]): ret{.error: SetLitBugMsg.} = op self, s -template genBinSysBool(op) = genBinSys(bool, op) - -genBinSysBool `==` -genBinSysBool `<=` -genBinSysBool `<` - - -template aliasBin(alias, old){.dirty.} = - # binary op's rhs must be set too - template alias*[H; M: SomePySet[H]; S: SomePySet[H]]( - self: M, s: S): M|S = old(self, s) - -aliasBin `^`, symmetric_difference -aliasBin `&`, intersection -aliasBin `|`, union - -template boolAliasBin(alias, old){.dirty.} = - proc alias*[H, S](self, o: SomePySet[H], s: S): bool = old(self, s) - -boolAliasBin issuperset, `>=` -boolAliasBin issubset, `<=` - -template fold(op){.dirty.} = - # set.op(*others) - proc op*[H; Self: SomePySet[H]; S: not PySet[H]]( - self: Self, s: S): Self = - op(self, somepyset(Self, s)) - proc op*[H; Self: SomePySet[H]; S](self: Self, s1: auto, s2: auto; - x: varargs[S]): Self = - result = op(self, s1) - result = op(result, s2) - for i in x: - result = op(result, i) - -fold intersection -fold union -fold difference -fold symmetric_difference - -func isdisjoint*[H, S](self: SomePySet[H], s: S): bool = - len(self.intersection(s)) == 0 - -proc add*[H](self: var PySet[H], x: H) = self.incl x -proc `discard`*[H](self: var PySet[H], ele: H) = - ## `discard` is keyword of Nim, consider use `\`discard\`` or pydiscard - self.excl ele -proc pydiscard*[H](self: var PySet[H], ele: H) = - ## set.discard(ele) - self.`discard` ele - -proc remove*[H](self: var PySet[H], ele: H) = - if self.missingOrExcl ele: - raise newException(KeyError, $ele) - - -template genUpdate(sysOp, op, fun){.dirty.} = - proc op*[H; S: SomeSet[H]](self: var SomePySet[H]; s: S) = sysop self, s - proc fun*[H; I: Iterable[H]](self: var SomePySet[H]; i: I) = sysop self, pyset(i) - -genUpdate excl, `-=`, difference_update -genUpdate incl, `|=`, update - -proc isec[S: SomeSet; S2: SomeSet](self: var S, s: S2) = self = self * s -genUpdate isec, `&=`, intersection_update - diff --git a/src/pylib/builtins/set_decl.nim b/src/pylib/builtins/set_decl.nim deleted file mode 100644 index a06db510f..000000000 --- a/src/pylib/builtins/set_decl.nim +++ /dev/null @@ -1,46 +0,0 @@ - -import std/hashes -import std/sets -import ./private/strIter - -type - frozenset*[H] = ref object - data: HashSet[H] - PyFrozenSet*[H] = frozenset[H] - set*[H] = ref object # in Python, they are distinct types. - data: HashSet[H] - PySet*[H] = set_decl.set[H] - SomePySet*[H] = set_decl.set[H] | frozenset[H] - -func hash*[H](self: PyFrozenSet[H]): int = int hash self.data - -func asHashSet*[H](self: SomePySet[H]): HashSet[H] = self.data -func asHashSet*[H](self: var SomePySet[H]): var HashSet[H] = self.data -func newPySet*[H](h: HashSet[H]): PySet[H] = PySet[H](data: h) -func newPyFrozenSet*[H](h: HashSet[H]): PyFrozenSet[H] = PyFrozenSet[H](data: h) -func newPySet*[H](initialSize = defaultInitialSize): PySet[H] = - PySet[H](data: initHashSet[H](initialSize)) -func newPyFrozenSet*[H](initialSize = defaultInitialSize): PyFrozenSet[H] = - PyFrozenSet[H](data: initHashSet[H](initialSize)) - -proc incl*[H](self: var SomePySet[H], x: H) = self.data.incl x -proc excl*[H](self: var SomePySet[H], x: H) = self.data.excl x - -func len*(self: SomePySet): int = self.data.len - -PySet.genDollarRepr '{', '}' -PyFrozenSet.genDollarRepr "frozenset({", "})" - -template `$`*(self: SomePySet): string = - bind repr - repr self - -proc clear*(self: var PySet): int = self.data.clear() -func `==`*(self, o: SomePySet): int = self.data == o.data -func `<=`*(self, o: SomePySet): int = self.data <= o.data -func `<`*(self, o: SomePySet): int = self.data < o.data -func contains*[H](self: SomePySet[H], x: H): bool = self.data.contains x -proc pop*[H](self: var PySet[H]): H{.discardable.} = self.data.pop() -iterator items*[H](self: SomePySet[H]): H = - for i in self.data: yield i -export sets.items diff --git a/src/pylib/builtins/str_byte.nim b/src/pylib/builtins/str_byte.nim deleted file mode 100644 index 52cebc3a7..000000000 --- a/src/pylib/builtins/str_byte.nim +++ /dev/null @@ -1,3 +0,0 @@ - -import ../[pystring, pybytes, pybytearray] -export pystring, pybytes, pybytearray diff --git a/src/pylib/codec/std_patch/README.md b/src/pylib/codec/std_patch/README.md deleted file mode 100644 index 0dfc87aba..000000000 --- a/src/pylib/codec/std_patch/README.md +++ /dev/null @@ -1,15 +0,0 @@ - -As Nim's `std/encodings` currently (as of 2.2.1) lacks `errors`-handler, -you cannot control how encoding error is handled as freely as in Python. - -And such a patch is hard to just as an extension around Nim's `std/encodings`, -so a copy is made here: - -Copied from Nim's `std/encodings`, when Nim's version is 2.2.1 and: - -```shell -~/.../src/Nim $ git log -1 --oneline -b534f34e9 adds noise to important_packages (#24352) -~/.../src/Nim $ git log -1 --oneline -- lib/pure/encodings.nim -c23d6a3cb Update encodings.nim, fix `open` with bad arg raising no `EncodingError` (#23481) -``` diff --git a/src/pylib/codec/std_patch/std_encodings.nim b/src/pylib/codec/std_patch/std_encodings.nim deleted file mode 100644 index bbadca655..000000000 --- a/src/pylib/codec/std_patch/std_encodings.nim +++ /dev/null @@ -1,511 +0,0 @@ -# -# -# Nim's Runtime Library -# (c) Copyright 2015 Andreas Rumpf -# -# See the file "copying.txt", included in this -# distribution, for details about the copyright. -# - -## Routines for converting between different character encodings. On UNIX, this uses -## the `iconv`:idx: library, on Windows the Windows API. -## -## The following example shows how to change character encodings. -runnableExamples: - when defined(windows): - let - orig = "öäüß" - # convert `orig` from "UTF-8" to "CP1252" - cp1252 = convert(orig, "CP1252", "UTF-8") - # convert `cp1252` from "CP1252" to "ibm850" - ibm850 = convert(cp1252, "ibm850", "CP1252") - current = getCurrentEncoding() - assert orig == "\195\182\195\164\195\188\195\159" - assert ibm850 == "\148\132\129\225" - assert convert(ibm850, current, "ibm850") == orig - -## The example below uses a reuseable `EncodingConverter` object which is -## created by `open` with `destEncoding` and `srcEncoding` specified. You can use -## `convert` on this object multiple times. -runnableExamples: - when defined(windows): - var fromGB2312 = open("utf-8", "gb2312") - let first = "\203\173\197\194\163\191\210\187" & - "\203\242\209\204\211\234\200\206\198\189\201\250" - assert fromGB2312.convert(first) == "谁怕?一蓑烟雨任平生" - - let second = "\211\208\176\215\205\183\200\231" & - "\208\194\163\172\199\227\184\199\200\231\185\202" - assert fromGB2312.convert(second) == "有白头如新,倾盖如故" - - -import std/os -when defined(nimPreviewSlimSystem): - import std/assertions - -when not defined(windows): - type - ConverterObj = object - EncodingConverter* = ptr ConverterObj ## Can convert between two character sets. - -else: - type - CodePage = distinct int32 - EncodingConverter* = object - dest, src: CodePage - -type - EncodingError* = object of ValueError ## Exception that is raised - ## for encoding errors. - -when defined(windows): - import std/[parseutils, strutils] - proc eqEncodingNames(a, b: string): bool = - var i = 0 - var j = 0 - while i < a.len and j < b.len: - if a[i] in {'-', '_'}: inc i - if b[j] in {'-', '_'}: inc j - if i < a.len and j < b.len and - a[i].toLowerAscii != b[j].toLowerAscii: - return false - inc i - inc j - result = i == a.len and j == b.len - - const - winEncodings = [ - (1, "OEMCP"), # current OEM codepage - (037, "IBM037"), # IBM EBCDIC US-Canada - (437, "IBM437"), # OEM United States - (500, "IBM500"), # IBM EBCDIC International - (708, "ASMO-708"), # Arabic (ASMO 708) - (709, "ASMO_449"), # Arabic (ASMO-449+, BCON V4) - (710, ""), # Arabic - Transparent Arabic - (720, "DOS-720"), # Arabic (Transparent ASMO); Arabic (DOS) - (737, "ibm737"), # OEM Greek (formerly 437G); Greek (DOS) - (775, "ibm775"), # OEM Baltic; Baltic (DOS) - (850, "ibm850"), # OEM Multilingual Latin 1; Western European (DOS) - (852, "ibm852"), # OEM Latin 2; Central European (DOS) - (855, "IBM855"), # OEM Cyrillic (primarily Russian) - (857, "ibm857"), # OEM Turkish; Turkish (DOS) - (858, "IBM00858"), # OEM Multilingual Latin 1 + Euro symbol - (860, "IBM860"), # OEM Portuguese; Portuguese (DOS) - (861, "ibm861"), # OEM Icelandic; Icelandic (DOS) - (862, "DOS-862"), # OEM Hebrew; Hebrew (DOS) - (863, "IBM863"), # OEM French Canadian; French Canadian (DOS) - (864, "IBM864"), # OEM Arabic; Arabic (864) - (865, "IBM865"), # OEM Nordic; Nordic (DOS) - (866, "cp866"), # OEM Russian; Cyrillic (DOS) - (869, "ibm869"), # OEM Modern Greek; Greek, Modern (DOS) - (870, "IBM870"), # IBM EBCDIC Multilingual/ROECE (Latin 2); IBM EBCDIC Multilingual Latin 2 - (874, "windows-874"), # ANSI/OEM Thai (same as 28605, ISO 8859-15); Thai (Windows) - (875, "cp875"), # IBM EBCDIC Greek Modern - (932, "shift_jis"), # ANSI/OEM Japanese; Japanese (Shift-JIS) - (936, "gb2312"), # ANSI/OEM Simplified Chinese (PRC, Singapore); Chinese Simplified (GB2312) - (936, "gbk"), # Alias for GB2312 encoding - (949, "ks_c_5601-1987"), # ANSI/OEM Korean (Unified Hangul Code) - (950, "big5"), # ANSI/OEM Traditional Chinese (Taiwan; Hong Kong SAR, PRC); Chinese Traditional (Big5) - (1026, "IBM1026"), # IBM EBCDIC Turkish (Latin 5) - (1047, "IBM01047"), # IBM EBCDIC Latin 1/Open System - (1140, "IBM01140"), # IBM EBCDIC US-Canada (037 + Euro symbol); IBM EBCDIC (US-Canada-Euro) - (1141, "IBM01141"), # IBM EBCDIC Germany (20273 + Euro symbol); IBM EBCDIC (Germany-Euro) - (1142, "IBM01142"), # IBM EBCDIC Denmark-Norway (20277 + Euro symbol); IBM EBCDIC (Denmark-Norway-Euro) - (1143, "IBM01143"), # IBM EBCDIC Finland-Sweden (20278 + Euro symbol); IBM EBCDIC (Finland-Sweden-Euro) - (1144, "IBM01144"), # IBM EBCDIC Italy (20280 + Euro symbol); IBM EBCDIC (Italy-Euro) - (1145, "IBM01145"), # IBM EBCDIC Latin America-Spain (20284 + Euro symbol); IBM EBCDIC (Spain-Euro) - (1146, "IBM01146"), # IBM EBCDIC United Kingdom (20285 + Euro symbol); IBM EBCDIC (UK-Euro) - (1147, "IBM01147"), # IBM EBCDIC France (20297 + Euro symbol); IBM EBCDIC (France-Euro) - (1148, "IBM01148"), # IBM EBCDIC International (500 + Euro symbol); IBM EBCDIC (International-Euro) - (1149, "IBM01149"), # IBM EBCDIC Icelandic (20871 + Euro symbol); IBM EBCDIC (Icelandic-Euro) - (1200, "utf-16"), # Unicode UTF-16, little endian byte order (BMP of ISO 10646); available only to managed applications - (1201, "unicodeFFFE"), # Unicode UTF-16, big endian byte order; available only to managed applications - (1250, "windows-1250"), # ANSI Central European; Central European (Windows) - (1251, "windows-1251"), # ANSI Cyrillic; Cyrillic (Windows) - (1252, "windows-1252"), # ANSI Latin 1; Western European (Windows) - (1253, "windows-1253"), # ANSI Greek; Greek (Windows) - (1254, "windows-1254"), # ANSI Turkish; Turkish (Windows) - (1255, "windows-1255"), # ANSI Hebrew; Hebrew (Windows) - (1256, "windows-1256"), # ANSI Arabic; Arabic (Windows) - (1257, "windows-1257"), # ANSI Baltic; Baltic (Windows) - (1258, "windows-1258"), # ANSI/OEM Vietnamese; Vietnamese (Windows) - - (1250, "cp-1250"), # ANSI Central European; Central European (Windows) - (1251, "cp-1251"), # ANSI Cyrillic; Cyrillic (Windows) - (1252, "cp-1252"), # ANSI Latin 1; Western European (Windows) - (1253, "cp-1253"), # ANSI Greek; Greek (Windows) - (1254, "cp-1254"), # ANSI Turkish; Turkish (Windows) - (1255, "cp-1255"), # ANSI Hebrew; Hebrew (Windows) - (1256, "cp-1256"), # ANSI Arabic; Arabic (Windows) - (1257, "cp-1257"), # ANSI Baltic; Baltic (Windows) - (1258, "cp-1258"), # ANSI/OEM Vietnamese; Vietnamese (Windows) - - (1361, "Johab"), # Korean (Johab) - (10000, "macintosh"), # MAC Roman; Western European (Mac) - (10001, "x-mac-japanese"), # Japanese (Mac) - (10002, "x-mac-chinesetrad"), # MAC Traditional Chinese (Big5); Chinese Traditional (Mac) - (10003, "x-mac-korean"), # Korean (Mac) - (10004, "x-mac-arabic"), # Arabic (Mac) - (10005, "x-mac-hebrew"), # Hebrew (Mac) - (10006, "x-mac-greek"), # Greek (Mac) - (10007, "x-mac-cyrillic"), # Cyrillic (Mac) - (10008, "x-mac-chinesesimp"), # MAC Simplified Chinese (GB 2312); Chinese Simplified (Mac) - (10010, "x-mac-romanian"), # Romanian (Mac) - (10017, "x-mac-ukrainian"), # Ukrainian (Mac) - (10021, "x-mac-thai"), # Thai (Mac) - (10029, "x-mac-ce"), # MAC Latin 2; Central European (Mac) - (10079, "x-mac-icelandic"), # Icelandic (Mac) - (10081, "x-mac-turkish"), # Turkish (Mac) - (10082, "x-mac-croatian"), # Croatian (Mac) - (12000, "utf-32"), # Unicode UTF-32, little endian byte order; available only to managed applications - (12001, "utf-32BE"), # Unicode UTF-32, big endian byte order; available only to managed applications - (20000, "x-Chinese_CNS"), # CNS Taiwan; Chinese Traditional (CNS) - (20001, "x-cp20001"), # TCA Taiwan - (20002, "x_Chinese-Eten"), # Eten Taiwan; Chinese Traditional (Eten) - (20003, "x-cp20003"), # IBM5550 Taiwan - (20004, "x-cp20004"), # TeleText Taiwan - (20005, "x-cp20005"), # Wang Taiwan - (20105, "x-IA5"), # IA5 (IRV International Alphabet No. 5, 7-bit); Western European (IA5) - (20106, "x-IA5-German"), # IA5 German (7-bit) - (20107, "x-IA5-Swedish"), # IA5 Swedish (7-bit) - (20108, "x-IA5-Norwegian"), # IA5 Norwegian (7-bit) - (20127, "us-ascii"), # US-ASCII (7-bit) - (20261, "x-cp20261"), # T.61 - (20269, "x-cp20269"), # ISO 6937 Non-Spacing Accent - (20273, "IBM273"), # IBM EBCDIC Germany - (20277, "IBM277"), # IBM EBCDIC Denmark-Norway - (20278, "IBM278"), # IBM EBCDIC Finland-Sweden - (20280, "IBM280"), # IBM EBCDIC Italy - (20284, "IBM284"), # IBM EBCDIC Latin America-Spain - (20285, "IBM285"), # IBM EBCDIC United Kingdom - (20290, "IBM290"), # IBM EBCDIC Japanese Katakana Extended - (20297, "IBM297"), # IBM EBCDIC France - (20420, "IBM420"), # IBM EBCDIC Arabic - (20423, "IBM423"), # IBM EBCDIC Greek - (20424, "IBM424"), # IBM EBCDIC Hebrew - (20833, "x-EBCDIC-KoreanExtended"), # IBM EBCDIC Korean Extended - (20838, "IBM-Thai"), # IBM EBCDIC Thai - (20866, "koi8-r"), # Russian (KOI8-R); Cyrillic (KOI8-R) - (20871, "IBM871"), # IBM EBCDIC Icelandic - (20880, "IBM880"), # IBM EBCDIC Cyrillic Russian - (20905, "IBM905"), # IBM EBCDIC Turkish - (20924, "IBM00924"), # IBM EBCDIC Latin 1/Open System (1047 + Euro symbol) - (20932, "EUC-JP"), # Japanese (JIS 0208-1990 and 0121-1990) - (20936, "x-cp20936"), # Simplified Chinese (GB2312); Chinese Simplified (GB2312-80) - (20949, "x-cp20949"), # Korean Wansung - (21025, "cp1025"), # IBM EBCDIC Cyrillic Serbian-Bulgarian - (21027, ""), # (deprecated) - (21866, "koi8-u"), # Ukrainian (KOI8-U); Cyrillic (KOI8-U) - (28591, "iso-8859-1"), # ISO 8859-1 Latin 1; Western European (ISO) - (28592, "iso-8859-2"), # ISO 8859-2 Central European; Central European (ISO) - (28593, "iso-8859-3"), # ISO 8859-3 Latin 3 - (28594, "iso-8859-4"), # ISO 8859-4 Baltic - (28595, "iso-8859-5"), # ISO 8859-5 Cyrillic - (28596, "iso-8859-6"), # ISO 8859-6 Arabic - (28597, "iso-8859-7"), # ISO 8859-7 Greek - (28598, "iso-8859-8"), # ISO 8859-8 Hebrew; Hebrew (ISO-Visual) - (28599, "iso-8859-9"), # ISO 8859-9 Turkish - (28603, "iso-8859-13"), # ISO 8859-13 Estonian - (28605, "iso-8859-15"), # ISO 8859-15 Latin 9 - (29001, "x-Europa"), # Europa 3 - (38598, "iso-8859-8-i"), # ISO 8859-8 Hebrew; Hebrew (ISO-Logical) - (50220, "iso-2022-jp"), # ISO 2022 Japanese with no halfwidth Katakana; Japanese (JIS) - (50221, "csISO2022JP"), # ISO 2022 Japanese with halfwidth Katakana; Japanese (JIS-Allow 1 byte Kana) - (50222, "iso-2022-jp"), # ISO 2022 Japanese JIS X 0201-1989; Japanese (JIS-Allow 1 byte Kana - SO/SI) - (50225, "iso-2022-kr"), # ISO 2022 Korean - (50227, "x-cp50227"), # ISO 2022 Simplified Chinese; Chinese Simplified (ISO 2022) - (50229, ""), # ISO 2022 Traditional Chinese - (50930, ""), # EBCDIC Japanese (Katakana) Extended - (50931, ""), # EBCDIC US-Canada and Japanese - (50933, ""), # EBCDIC Korean Extended and Korean - (50935, ""), # EBCDIC Simplified Chinese Extended and Simplified Chinese - (50936, ""), # EBCDIC Simplified Chinese - (50937, ""), # EBCDIC US-Canada and Traditional Chinese - (50939, ""), # EBCDIC Japanese (Latin) Extended and Japanese - (51932, "euc-jp"), # EUC Japanese - (51936, "EUC-CN"), # EUC Simplified Chinese; Chinese Simplified (EUC) - (51949, "euc-kr"), # EUC Korean - (51950, ""), # EUC Traditional Chinese - (52936, "hz-gb-2312"), # HZ-GB2312 Simplified Chinese; Chinese Simplified (HZ) - (54936, "GB18030"), # Windows XP and later: GB18030 Simplified Chinese (4 byte); Chinese Simplified (GB18030) - (57002, "x-iscii-de"), # ISCII Devanagari - (57003, "x-iscii-be"), # ISCII Bengali - (57004, "x-iscii-ta"), # ISCII Tamil - (57005, "x-iscii-te"), # ISCII Telugu - (57006, "x-iscii-as"), # ISCII Assamese - (57007, "x-iscii-or"), # ISCII Oriya - (57008, "x-iscii-ka"), # ISCII Kannada - (57009, "x-iscii-ma"), # ISCII Malayalam - (57010, "x-iscii-gu"), # ISCII Gujarati - (57011, "x-iscii-pa"), # ISCII Punjabi - (65000, "utf-7"), # Unicode (UTF-7) - (65001, "utf-8")] # Unicode (UTF-8) - - when false: - # not needed yet: - type - CpInfo = object - maxCharSize: int32 - defaultChar: array[0..1, char] - leadByte: array[0..12-1, char] - - proc getCPInfo(codePage: CodePage, lpCPInfo: var CpInfo): int32 {. - stdcall, importc: "GetCPInfo", dynlib: "kernel32".} - - proc nameToCodePage*(name: string): CodePage = - var nameAsInt: int - if parseInt(name, nameAsInt) == 0: nameAsInt = -1 - for no, na in items(winEncodings): - if no == nameAsInt or eqEncodingNames(na, name): return CodePage(no) - result = CodePage(-1) - - proc codePageToName*(c: CodePage): string = - for no, na in items(winEncodings): - if no == int(c): - return if na.len != 0: na else: $no - result = "" - - proc getACP(): CodePage {.stdcall, importc: "GetACP", dynlib: "kernel32".} - proc getGetConsoleCP(): CodePage {.stdcall, importc: "GetConsoleCP", - dynlib: "kernel32".} - - proc multiByteToWideChar( - codePage: CodePage, - dwFlags: int32, - lpMultiByteStr: cstring, - cbMultiByte: cint, - lpWideCharStr: cstring, - cchWideChar: cint): cint {. - stdcall, importc: "MultiByteToWideChar", dynlib: "kernel32".} - - proc wideCharToMultiByte( - codePage: CodePage, - dwFlags: int32, - lpWideCharStr: cstring, - cchWideChar: cint, - lpMultiByteStr: cstring, - cbMultiByte: cint, - lpDefaultChar: cstring = nil, - lpUsedDefaultChar: pointer = nil): cint {. - stdcall, importc: "WideCharToMultiByte", dynlib: "kernel32".} - -else: - when defined(haiku): - const iconvDll = "libiconv.so" - elif defined(macosx): - const iconvDll = "libiconv.dylib" - else: - const iconvDll = "(libc.so.6|libiconv.so)" - - const - E2BIG = 7.cint - EINVAL = 22.cint - when defined(linux): - const EILSEQ = 84.cint - elif defined(macosx): - const EILSEQ = 92.cint - elif defined(bsd): - const EILSEQ = 86.cint - elif defined(solaris): - const EILSEQ = 88.cint - elif defined(haiku): - const EILSEQ = -2147454938.cint - - var errno {.importc, header: "".}: cint - - when defined(bsd): - {.pragma: importIconv, cdecl, header: "".} - when defined(openbsd): - {.passL: "-liconv".} - else: - {.pragma: importIconv, cdecl, dynlib: iconvDll.} - - proc iconvOpen(tocode, fromcode: cstring): EncodingConverter {. - importc: "iconv_open", importIconv.} - proc iconvClose(c: EncodingConverter) {. - importc: "iconv_close", importIconv.} - proc iconv(c: EncodingConverter, inbuf: ptr cstring, inbytesLeft: ptr csize_t, - outbuf: ptr cstring, outbytesLeft: ptr csize_t): csize_t {. - importc: "iconv", importIconv.} - -proc getCurrentEncoding*(uiApp = false): string = - ## Retrieves the current encoding. On Unix, "UTF-8" is always returned. - ## The `uiApp` parameter is Windows specific. If true, the UI's code-page - ## is returned, if false, the Console's code-page is returned. - when defined(windows): - result = codePageToName(if uiApp: getACP() else: getGetConsoleCP()) - else: - result = "UTF-8" - -proc open*(destEncoding = "UTF-8", srcEncoding = "CP1252"): EncodingConverter = - ## Opens a converter that can convert from `srcEncoding` to `destEncoding`. - ## Raises `EncodingError` if it cannot fulfill the request. - when not defined(windows): - result = iconvOpen(destEncoding, srcEncoding) - if result == cast[EncodingConverter](-1): - raise newException(EncodingError, - "cannot create encoding converter from " & - srcEncoding & " to " & destEncoding) - else: - result.dest = nameToCodePage(destEncoding) - result.src = nameToCodePage(srcEncoding) - if int(result.dest) == -1: - raise newException(EncodingError, - "cannot find encoding " & destEncoding) - if int(result.src) == -1: - raise newException(EncodingError, - "cannot find encoding " & srcEncoding) - -proc close*(c: EncodingConverter) = - ## Frees the resources the converter `c` holds. - when not defined(windows): - iconvClose(c) - -when defined(windows): - proc convertToWideString(codePage: CodePage, s: string): string = - # educated guess of capacity: - var cap = s.len + s.len shr 2 - result = newString(cap*2) - # convert to utf-16 LE - var m = multiByteToWideChar(codePage, - dwFlags = 0'i32, - lpMultiByteStr = cstring(s), - cbMultiByte = cint(s.len), - lpWideCharStr = cstring(result), - cchWideChar = cint(cap)) - if m == 0: - # try again; ask for capacity: - cap = multiByteToWideChar(codePage, - dwFlags = 0'i32, - lpMultiByteStr = cstring(s), - cbMultiByte = cint(s.len), - lpWideCharStr = nil, - cchWideChar = cint(0)) - # and do the conversion properly: - result = newString(cap*2) - m = multiByteToWideChar(codePage, - dwFlags = 0'i32, - lpMultiByteStr = cstring(s), - cbMultiByte = cint(s.len), - lpWideCharStr = cstring(result), - cchWideChar = cint(cap)) - if m == 0: raiseOSError(osLastError()) - setLen(result, m*2) - elif m <= cap: - setLen(result, m*2) - else: - assert(false) # cannot happen - - proc convertFromWideString(codePage: CodePage, s: string): string = - let charCount = s.len div 2 - var cap = s.len + s.len shr 2 - result = newString(cap) - var m = wideCharToMultiByte(codePage, - dwFlags = 0'i32, - lpWideCharStr = cstring(s), - cchWideChar = cint(charCount), - lpMultiByteStr = cstring(result), - cbMultiByte = cap.cint) - if m == 0: - # try again; ask for capacity: - cap = wideCharToMultiByte(codePage, - dwFlags = 0'i32, - lpWideCharStr = cstring(s), - cchWideChar = cint(charCount), - lpMultiByteStr = nil, - cbMultiByte = cint(0)) - # and do the conversion properly: - result = newString(cap) - m = wideCharToMultiByte(codePage, - dwFlags = 0'i32, - lpWideCharStr = cstring(s), - cchWideChar = cint(charCount), - lpMultiByteStr = cstring(result), - cbMultiByte = cap.cint) - if m == 0: raiseOSError(osLastError()) - setLen(result, m) - elif m <= cap: - setLen(result, m) - else: - assert(false) # cannot happen - - proc convertWin(codePageFrom: CodePage, codePageTo: CodePage, - s: string): string = - # special case: empty string: needed because MultiByteToWideChar, WideCharToMultiByte - # return 0 in case of error - if s.len == 0: return "" - # multiByteToWideChar does not support encoding from code pages below - let unsupported = [1201, 12000, 12001] - - if int(codePageFrom) in unsupported: - let message = "encoding from " & codePageToName(codePageFrom) & " is not supported on windows" - raise newException(EncodingError, message) - - if int(codePageTo) in unsupported: - let message = "encoding to " & codePageToName(codePageTo) & " is not supported on windows" - raise newException(EncodingError, message) - - # in case it's already UTF-16 little endian - conversion can be simplified - let wideString = if int(codePageFrom) == 1200: s - else: convertToWideString(codePageFrom, s) - return if int(codePageTo) == 1200: wideString - else: convertFromWideString(codePageTo, wideString) - - proc convert*(c: EncodingConverter, s: string): string = - result = convertWin(c.src, c.dest, s) -else: - proc convert*(c: EncodingConverter, s: string): string = - ## Converts `s` to `destEncoding` that was given to the converter `c`. It - ## assumes that `s` is in `srcEncoding`. - ## - ## .. warning:: UTF-16BE and UTF-32 conversions are not supported on Windows. - result = newString(s.len) - var inLen = csize_t len(s) - var outLen = csize_t len(result) - var src = cstring(s) - var dst = cstring(result) - var iconvres: csize_t - while inLen > 0: - iconvres = iconv(c, addr src, addr inLen, addr dst, addr outLen) - if iconvres == high(csize_t): - var lerr = errno - if lerr == EILSEQ or lerr == EINVAL: - # unknown char, skip - dst[0] = src[0] - src = cast[cstring](cast[int](src) + 1) - dst = cast[cstring](cast[int](dst) + 1) - dec(inLen) - dec(outLen) - elif lerr == E2BIG: - var offset = cast[int](dst) - cast[int](cstring(result)) - setLen(result, len(result) + inLen.int * 2 + 5) - # 5 is minimally one utf-8 char - dst = cast[cstring](cast[int](cstring(result)) + offset) - outLen = csize_t(len(result) - offset) - else: - raiseOSError(lerr.OSErrorCode) - # iconv has a buffer that needs flushing, specially if the last char is - # not '\0' - discard iconv(c, nil, nil, addr dst, addr outLen) - if iconvres == high(csize_t) and errno == E2BIG: - var offset = cast[int](dst) - cast[int](cstring(result)) - setLen(result, len(result) + inLen.int * 2 + 5) - # 5 is minimally one utf-8 char - dst = cast[cstring](cast[int](cstring(result)) + offset) - outLen = csize_t(len(result) - offset) - discard iconv(c, nil, nil, addr dst, addr outLen) - # trim output buffer - setLen(result, len(result) - outLen.int) - -proc convert*(s: string, destEncoding = "UTF-8", - srcEncoding = "CP1252"): string = - ## Converts `s` to `destEncoding`. It assumed that `s` is in `srcEncoding`. - ## This opens a converter, uses it and closes it again and is thus more - ## convenient but also likely less efficient than re-using a converter. - ## - ## .. warning:: UTF-16BE and UTF-32 conversions are not supported on Windows. - var c = open(destEncoding, srcEncoding) - try: - result = convert(c, s) - finally: - close(c) diff --git a/src/pylib/collections_abc.nim b/src/pylib/collections_abc.nim deleted file mode 100644 index 0d90ef00d..000000000 --- a/src/pylib/collections_abc.nim +++ /dev/null @@ -1,4 +0,0 @@ - -import ./private/trans_imp -impExp collections_abc, - asyncs, iters, collections, generators diff --git a/src/pylib/collections_abc/asyncs.nim b/src/pylib/collections_abc/asyncs.nim deleted file mode 100644 index 3d36f5212..000000000 --- a/src/pylib/collections_abc/asyncs.nim +++ /dev/null @@ -1,139 +0,0 @@ -##[ - -## Coroutine - -ref [pep of `Coroutines with async and await syntax`](https://peps.python.org/pep-0492/), -`Future-like object` is just an alias of `Awaitable`_ - -```python -V = 1 -async def f(): - return V - -c: Coroutine[None, None, int] = f() - -try: c.send(None) -except StopIteraion as s: assert V == s.value - -try: c.send(None) -except RuntimeError as e: assert str(e) == "cannot reuse already awaited coroutine" - -# Also: V == await f() -``` - - -[pep for Asynchronous Generators](https://peps.python.org/pep-0525/) - -## AsyncGenerator - -```python -V = 1 -async def f(): yield V -ag = f() - -ag_asend_obj = ag.asend(None) # or `anext(ag)` -try: ag_asend_obj.send(None) -except StopIteration as s: assert V == s.value - - -ag_asend_obj = ag.asend(None) # or `anext(ag, defval)` if wanting -# the next `send` raises `StopIteration` and its value to be `defval` - -try: ag_asend_obj.send(None) -except StopAsyncIteration: pass # iteration end - - -``` - -for `ag_asend_obj`, ref [link of PyAsyncGenASend]( -https://peps.python.org/pep-0525/#pyasyncgenasend-and-pyasyncgenathrow): - -> `PyAsyncGenASend` is a coroutine-like object... - -> `PyAsyncGenAThrow` is very similar to `PyAsyncGenASend`. -The only difference is that `PyAsyncGenAThrow.send()`, when called first time, -throws an exception into the parent `agen` object -(instead of pushing a value into it.) - -]## - - -import std/asyncfutures -import std/asyncmacro - -import ../pyerrors/signals -import ../noneType -import ./private/templ - -type - Awaitable*[T] = concept self - T is await self - Coroutine*[Yield, Send, Return] = - concept self of Awaitable[Return] - ## `type( (async def _(): return Return() )() )` - ## in details: `Coroutine[None, None, Return]` - self.send(Send) is Yield - self.throw(CatchableError) - - -proc close*(self: Coroutine) = - closeImpl("coroutinue"): - self.throw(GeneratorExit) - -#[ TODO: support after PyTrceback is impl -import ../noneType -when (PyMajor, PyMinor) >= (3,12): - {.pragma deprThrowVariant, warning: - "The signature (type[, value[, traceback]]) is deprecated and " & - " may be removed in a future version of Python.".} -else: - {.pragma deprThrowVariant.} - -proc throw*[E](self: Coroutine, - `type`: typedesc[E], val: E; tb: PyTraceback | NoneType = None){.deprThrowVariant.} = - when tb is_not NoneType: - val = val.with_traceback(tb) - raise val - -proc throw*[E](self: Coroutine, - `type`: E, val: NoneType; tb: PyTraceback | NoneType = None){.deprThrowVariant.} = -]# - -type - AsyncIterable*[T] = concept self - aiter(self) is AsyncIterator[T] - AsyncIterator*[T] = concept self of AsyncIterable[T] - anext(self) is Awaitable[T] - - AsyncGenerator*[Yield; Send = NoneType] = concept self of AsyncIterator[Yield] - ##[ - `type( (async _(): yield)() )` - ABC for such a function which returns an asynchronous generator iterator. - It looks like a coroutine function defined with async def except - that it contains yield expressions for producing a series of - values usable in an async for loop. - ]## - self.asend(Send) is Awaitable[Yield] - self.athrow(CatchableError) is Awaitable[void] - -proc anext*[T](self: AsyncGenerator[T]): Awaitable[T]{.inline.} = - ## this shall be an `async def` - self.asend(None) - -type anextawaitableobject[T] = object - wrapped: AsyncGenerator[T] - default_value: T - -proc await*[T](self: anextawaitableobject[T]): T = - try: - result = await self.wrapped.asend(None) - except StopAsyncIteration: - #raise newStopIteration(default) - result = default - -proc anext*[T](self: AsyncGenerator[T], default: T): Awaitable[T]{.inline.} = - anextawaitableobject(wrapped: self, default: default) - -proc aclose*(self: AsyncGenerator){.async.} = - closeImpl("asunchronous generator"): - await self.athrow(GeneratorExit) diff --git a/src/pylib/collections_abc/collections.nim b/src/pylib/collections_abc/collections.nim deleted file mode 100644 index 3f1b271d2..000000000 --- a/src/pylib/collections_abc/collections.nim +++ /dev/null @@ -1,115 +0,0 @@ - -import ./iters - -type - Sized* = concept self - len(self) is int - - Container*[T] = concept self - # NIM-BUG: if only a `contains(self, T) is bool`, - # Nim will wrongly complain `'T' is declared but not used` - T - contains(self, T) is bool - - Collection*[T] = Sized and Container[T] and Iterable[T] - - Sequence*[T] = concept self of Collection[T] - T # NIM-BUG: see above. - self[int] is T - MutableSequence*[T] = concept self of Sequence[T] - T # NIM-BUG: see above. - self[int] = T - self.delitem(int) ## __delitem__ - self.insert(int, T) ## insert item before index - - Mapping*[K, V] = concept self of Collection[K] - K # NIM-BUG: see above. - V - self[K] is V - - -when not defined(js) or (NimMajor, NimMinor, NimPatch) > (2, 1, 0): - # NIM-BUG - func contains*[T](s: Container[T], x: T): bool = - for i in s: - if x == i: return true - -#func reversed*[S: Sequence](s: S): Iterable - -func index*[T](s: Sequence[T], x: T, start=0, stop = -1): int = - let last = if stop == -1: s.len-1 else: stop - result = start - for i in start..last: - if x == s[i]: - return result - result.inc - raise newException(ValueError, $x & " is not in sequence") - -func count*[T](s: Sequence[T], x: T): int = - for i in s: - if i == x: - result.inc - -template useOr(use, els): untyped = - when compiles(use): use - else: els - -template newSeqMayUninit[T](len): seq[T] = - useOr newSeqUninit[T](len), newSeq[T](len) - -func `@`*[T](s: Sequence[T]): seq[T]{.noInit, inline.} = - ## EXT. stable. - result = newSeqMayUninit[T](s.len) - var i = 0 - for ele in s: - result[i] = ele - i.inc - -func append*[T](ms: MutableSequence[T], x: T) = - ms.insert(ms.len, x) - -func clear*(ms: MutableSequence) = - for i in 0..= (2, 1, 2) and NimVer < (2, 1, 9) - -const ItemTypeMode = typeOfIter -type - Iterable*[T] = concept self ## Mimic Pythons Iterable. But not checks `iter` - #for value in self: value is T - # Above may cause inner error when JS backend on older Nim - T # see below - when SupportIteratorHit: - iterator items(self): T - else: - #typeof(self.items(), typeOfIter) is T - when defined(js): - typeof(self.items(), ItemTypeMode) is T - else: - for value in self: value is T - Iterator*[T] = concept self of Iterable[T] - T - self.next is T - diff --git a/src/pylib/collections_abc/private/templ.nim b/src/pylib/collections_abc/private/templ.nim deleted file mode 100644 index d29677979..000000000 --- a/src/pylib/collections_abc/private/templ.nim +++ /dev/null @@ -1,7 +0,0 @@ - -template closeImpl*(msg: string; throwBody) = - try: - throwBody - raise newException(RuntimeError, msg & " ignored GeneratorExit") - except (GeneratorExit, StopIteration): - discard diff --git a/src/pylib/impure/Python/Python.h b/src/pylib/impure/Python/Python.h deleted file mode 100644 index d3a63e75d..000000000 --- a/src/pylib/impure/Python/Python.h +++ /dev/null @@ -1,12 +0,0 @@ -/* -Only ones used by this directory (pylib/impure/Python/*.c) are declared here - */ - -#include -#include -#include -#include -#include - -int -PyOS_vsnprintf(char *str, size_t size, const char *format, va_list va); diff --git a/src/pylib/impure/Python/mysnprintf.c b/src/pylib/impure/Python/mysnprintf.c deleted file mode 100644 index 6aba17139..000000000 --- a/src/pylib/impure/Python/mysnprintf.c +++ /dev/null @@ -1,80 +0,0 @@ -#include "Python.h" - -/* snprintf() and vsnprintf() wrappers. - - If the platform has vsnprintf, we use it, else we - emulate it in a half-hearted way. Even if the platform has it, we wrap - it because platforms differ in what vsnprintf does in case the buffer - is too small: C99 behavior is to return the number of characters that - would have been written had the buffer not been too small, and to set - the last byte of the buffer to \0. At least MS _vsnprintf returns a - negative value instead, and fills the entire buffer with non-\0 data. - Unlike C99, our wrappers do not support passing a null buffer. - - The wrappers ensure that str[size-1] is always \0 upon return. - - PyOS_snprintf and PyOS_vsnprintf never write more than size bytes - (including the trailing '\0') into str. - - Return value (rv): - - When 0 <= rv < size, the output conversion was unexceptional, and - rv characters were written to str (excluding a trailing \0 byte at - str[rv]). - - When rv >= size, output conversion was truncated, and a buffer of - size rv+1 would have been needed to avoid truncation. str[size-1] - is \0 in this case. - - When rv < 0, "something bad happened". str[size-1] is \0 in this - case too, but the rest of str is unreliable. It could be that - an error in format codes was detected by libc, or on platforms - with a non-C99 vsnprintf simply that the buffer wasn't big enough - to avoid truncation, or on platforms without any vsnprintf that - PyMem_Malloc couldn't obtain space for a temp buffer. - - CAUTION: Unlike C99, str != NULL and size > 0 are required. - Also, size must be smaller than INT_MAX. -*/ - -int -PyOS_snprintf(char *str, size_t size, const char *format, ...) -{ - int rc; - va_list va; - - va_start(va, format); - rc = PyOS_vsnprintf(str, size, format, va); - va_end(va); - return rc; -} - -int -PyOS_vsnprintf(char *str, size_t size, const char *format, va_list va) -{ - assert(str != NULL); - assert(size > 0); - assert(size <= (INT_MAX - 1)); - assert(format != NULL); - - int len; /* # bytes written, excluding \0 */ - /* We take a size_t as input but return an int. Sanity check - * our input so that it won't cause an overflow in the - * vsnprintf return value. */ - if (size > INT_MAX - 1) { - len = -666; - goto Done; - } - -#if defined(_MSC_VER) - len = _vsnprintf(str, size, format, va); -#else - len = vsnprintf(str, size, format, va); -#endif - -Done: - if (size > 0) { - str[size-1] = '\0'; - } - return len; -} \ No newline at end of file diff --git a/src/pylib/impure/Python/mysnprintf.nim b/src/pylib/impure/Python/mysnprintf.nim deleted file mode 100644 index 783b14065..000000000 --- a/src/pylib/impure/Python/mysnprintf.nim +++ /dev/null @@ -1,4 +0,0 @@ - -{.compile: "./mysnprintf.c".} - -proc PyOS_snprintf*(str: cstring, size: csize_t|int): cint{.discardable, importc, cdecl, varargs.} diff --git a/src/pylib/impure/Python/mysnprintf.toml b/src/pylib/impure/Python/mysnprintf.toml deleted file mode 100644 index a0255e023..000000000 --- a/src/pylib/impure/Python/mysnprintf.toml +++ /dev/null @@ -1,2 +0,0 @@ -date = 2025-02-17T01:15:56+08:00 -commit = "655fc8a0fce3396fc1af3f7bc8f5c94ca8ec377" \ No newline at end of file diff --git a/src/pylib/impure/math/dtoa-nim.c b/src/pylib/impure/math/dtoa-nim.c deleted file mode 100644 index 86f7d602e..000000000 --- a/src/pylib/impure/math/dtoa-nim.c +++ /dev/null @@ -1,12 +0,0 @@ - -#include - -void ACQUIRE_DTOA_LOCK(int); -void FREE_DTOA_LOCK(int); - -int dtoa_get_threadno(void); - -// avoid MinGW complaining conflict with strtod of -#define strtod nimpylib_dtoa_strtod -#include "./dtoa.c" -#undef strtod diff --git a/src/pylib/impure/math/dtoa.c b/src/pylib/impure/math/dtoa.c deleted file mode 100644 index 5ad2fa580..000000000 --- a/src/pylib/impure/math/dtoa.c +++ /dev/null @@ -1,6250 +0,0 @@ -/**************************************************************** - * - * The author of this software is David M. Gay. - * - * Copyright (c) 1991, 2000, 2001 by Lucent Technologies. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose without fee is hereby granted, provided that this entire notice - * is included in all copies of any software which is or includes a copy - * or modification of this software and in all copies of the supporting - * documentation for such software. - * - * THIS SOFTWARE IS BEING PROVIDED "AS IS", WITHOUT ANY EXPRESS OR IMPLIED - * WARRANTY. IN PARTICULAR, NEITHER THE AUTHOR NOR LUCENT MAKES ANY - * REPRESENTATION OR WARRANTY OF ANY KIND CONCERNING THE MERCHANTABILITY - * OF THIS SOFTWARE OR ITS FITNESS FOR ANY PARTICULAR PURPOSE. - * - ***************************************************************/ - -/* Please send bug reports to David M. Gay (dmg at acm dot org, - * with " at " changed at "@" and " dot " changed to "."). */ - -/* On a machine with IEEE extended-precision registers, it is - * necessary to specify double-precision (53-bit) rounding precision - * before invoking strtod or dtoa. If the machine uses (the equivalent - * of) Intel 80x87 arithmetic, the call - * _control87(PC_53, MCW_PC); - * does this with many compilers. Whether this or another call is - * appropriate depends on the compiler; for this to work, it may be - * necessary to #include "float.h" or another system-dependent header - * file. When needed, this call avoids double rounding, which can - * cause one bit errors, e.g., with strtod on 8.3e26 or 6.3876e-16. - */ - -/* strtod for IEEE-, VAX-, and IBM-arithmetic machines. - * (Note that IEEE arithmetic is disabled by gcc's -ffast-math flag.) - * - * This strtod returns a nearest machine number to the input decimal - * string (or sets errno to ERANGE). With IEEE arithmetic, ties are - * broken by the IEEE round-even rule. Otherwise ties are broken by - * biased rounding (add half and chop). - * - * Inspired loosely by William D. Clinger's paper "How to Read Floating - * Point Numbers Accurately" [Proc. ACM SIGPLAN '90, pp. 92-101]. - * - * Modifications: - * - * 1. We only require IEEE, IBM, or VAX double-precision - * arithmetic (not IEEE double-extended). - * 2. We get by with floating-point arithmetic in a case that - * Clinger missed -- when we're computing d * 10^n - * for a small integer d and the integer n is not too - * much larger than 22 (the maximum integer k for which - * we can represent 10^k exactly), we may be able to - * compute (d*10^k) * 10^(e-k) with just one roundoff. - * 3. Rather than a bit-at-a-time adjustment of the binary - * result in the hard case, we use floating-point - * arithmetic to determine the adjustment to within - * one bit; only in really hard cases do we need to - * compute a second residual. - * 4. Because of 3., we don't need a large table of powers of 10 - * for ten-to-e (just some small tables, e.g. of 10^k - * for 0 <= k <= 22). - */ - -/* - * #define IEEE_8087 for IEEE-arithmetic machines where the least - * significant byte has the lowest address. - * #define IEEE_MC68k for IEEE-arithmetic machines where the most - * significant byte has the lowest address. - * #define Long int on machines with 32-bit ints and 64-bit longs. - * #define IBM for IBM mainframe-style floating-point arithmetic. - * #define VAX for VAX-style floating-point arithmetic (D_floating). - * #define No_leftright to omit left-right logic in fast floating-point - * computation of dtoa. This will cause dtoa modes 4 and 5 to be - * treated the same as modes 2 and 3 for some inputs. - * #define Honor_FLT_ROUNDS if FLT_ROUNDS can assume the values 2 or 3 - * and strtod and dtoa should round accordingly. Unless Trust_FLT_ROUNDS - * is also #defined, fegetround() will be queried for the rounding mode. - * Note that both FLT_ROUNDS and fegetround() are specified by the C99 - * standard (and are specified to be consistent, with fesetround() - * affecting the value of FLT_ROUNDS), but that some (Linux) systems - * do not work correctly in this regard, so using fegetround() is more - * portable than using FLT_ROUNDS directly. - * #define Check_FLT_ROUNDS if FLT_ROUNDS can assume the values 2 or 3 - * and Honor_FLT_ROUNDS is not #defined. - * #define RND_PRODQUOT to use rnd_prod and rnd_quot (assembly routines - * that use extended-precision instructions to compute rounded - * products and quotients) with IBM. - * #define ROUND_BIASED for IEEE-format with biased rounding and arithmetic - * that rounds toward +Infinity. - * #define ROUND_BIASED_without_Round_Up for IEEE-format with biased - * rounding when the underlying floating-point arithmetic uses - * unbiased rounding. This prevent using ordinary floating-point - * arithmetic when the result could be computed with one rounding error. - * #define Inaccurate_Divide for IEEE-format with correctly rounded - * products but inaccurate quotients, e.g., for Intel i860. - * #define NO_LONG_LONG on machines that do not have a "long long" - * integer type (of >= 64 bits). On such machines, you can - * #define Just_16 to store 16 bits per 32-bit Long when doing - * high-precision integer arithmetic. Whether this speeds things - * up or slows things down depends on the machine and the number - * being converted. If long long is available and the name is - * something other than "long long", #define Llong to be the name, - * and if "unsigned Llong" does not work as an unsigned version of - * Llong, #define #ULLong to be the corresponding unsigned type. - * #define Bad_float_h if your system lacks a float.h or if it does not - * define some or all of DBL_DIG, DBL_MAX_10_EXP, DBL_MAX_EXP, - * FLT_RADIX, FLT_ROUNDS, and DBL_MAX. - * #define MALLOC your_malloc, where your_malloc(n) acts like malloc(n) - * if memory is available and otherwise does something you deem - * appropriate. If MALLOC is undefined, malloc will be invoked - * directly -- and assumed always to succeed. Similarly, if you - * want something other than the system's free() to be called to - * recycle memory acquired from MALLOC, #define FREE to be the - * name of the alternate routine. (FREE or free is only called in - * pathological cases, e.g., in a dtoa call after a dtoa return in - * mode 3 with thousands of digits requested.) - * #define Omit_Private_Memory to omit logic (added Jan. 1998) for making - * memory allocations from a private pool of memory when possible. - * When used, the private pool is PRIVATE_MEM bytes long: 2304 bytes, - * unless #defined to be a different length. This default length - * suffices to get rid of MALLOC calls except for unusual cases, - * such as decimal-to-binary conversion of a very long string of - * digits. The longest string dtoa can return is about 751 bytes - * long. For conversions by strtod of strings of 800 digits and - * all dtoa conversions in single-threaded executions with 8-byte - * pointers, PRIVATE_MEM >= 7400 appears to suffice; with 4-byte - * pointers, PRIVATE_MEM >= 7112 appears adequate. - * #define NO_INFNAN_CHECK if you do not wish to have INFNAN_CHECK - * #defined automatically on IEEE systems. On such systems, - * when INFNAN_CHECK is #defined, strtod checks - * for Infinity and NaN (case insensitively). On some systems - * (e.g., some HP systems), it may be necessary to #define NAN_WORD0 - * appropriately -- to the most significant word of a quiet NaN. - * (On HP Series 700/800 machines, -DNAN_WORD0=0x7ff40000 works.) - * When INFNAN_CHECK is #defined and No_Hex_NaN is not #defined, - * strtod also accepts (case insensitively) strings of the form - * NaN(x), where x is a string of hexadecimal digits and spaces; - * if there is only one string of hexadecimal digits, it is taken - * for the 52 fraction bits of the resulting NaN; if there are two - * or more strings of hex digits, the first is for the high 20 bits, - * the second and subsequent for the low 32 bits, with intervening - * white space ignored; but if this results in none of the 52 - * fraction bits being on (an IEEE Infinity symbol), then NAN_WORD0 - * and NAN_WORD1 are used instead. - * #define MULTIPLE_THREADS if the system offers preemptively scheduled - * multiple threads. In this case, you must provide (or suitably - * #define) two locks, acquired by ACQUIRE_DTOA_LOCK(n) and freed - * by FREE_DTOA_LOCK(n) for n = 0 or 1. (The second lock, accessed - * in pow5mult, ensures lazy evaluation of only one copy of high - * powers of 5; omitting this lock would introduce a small - * probability of wasting memory, but would otherwise be harmless.) - * You must also invoke freedtoa(s) to free the value s returned by - * dtoa. You may do so whether or not MULTIPLE_THREADS is #defined. - - * When MULTIPLE_THREADS is #defined, this source file provides - * void set_max_dtoa_threads(unsigned int n); - * and expects - * unsigned int dtoa_get_threadno(void); - * to be available (possibly provided by - * #define dtoa_get_threadno omp_get_thread_num - * if OpenMP is in use or by - * #define dtoa_get_threadno pthread_self - * if Pthreads is in use), to return the current thread number. - * If set_max_dtoa_threads(n) was called and the current thread - * number is k with k < n, then calls on ACQUIRE_DTOA_LOCK(...) and - * FREE_DTOA_LOCK(...) are avoided; instead each thread with thread - * number < n has a separate copy of relevant data structures. - * After set_max_dtoa_threads(n), a call set_max_dtoa_threads(m) - * with m <= n has has no effect, but a call with m > n is honored. - * Such a call invokes REALLOC (assumed to be "realloc" if REALLOC - * is not #defined) to extend the size of the relevant array. - - * #define NO_IEEE_Scale to disable new (Feb. 1997) logic in strtod that - * avoids underflows on inputs whose result does not underflow. - * If you #define NO_IEEE_Scale on a machine that uses IEEE-format - * floating-point numbers and flushes underflows to zero rather - * than implementing gradual underflow, then you must also #define - * Sudden_Underflow. - * #define USE_LOCALE to use the current locale's decimal_point value. - * #define SET_INEXACT if IEEE arithmetic is being used and extra - * computation should be done to set the inexact flag when the - * result is inexact and avoid setting inexact when the result - * is exact. In this case, dtoa.c must be compiled in - * an environment, perhaps provided by #include "dtoa.c" in a - * suitable wrapper, that defines two functions, - * int get_inexact(void); - * void clear_inexact(void); - * such that get_inexact() returns a nonzero value if the - * inexact bit is already set, and clear_inexact() sets the - * inexact bit to 0. When SET_INEXACT is #defined, strtod - * also does extra computations to set the underflow and overflow - * flags when appropriate (i.e., when the result is tiny and - * inexact or when it is a numeric value rounded to +-infinity). - * #define NO_ERRNO if strtod should not assign errno = ERANGE when - * the result overflows to +-Infinity or underflows to 0. - * When errno should be assigned, under seemingly rare conditions - * it may be necessary to define Set_errno(x) suitably, e.g., in - * a local errno.h, such as - * #include - * #define Set_errno(x) _set_errno(x) - * #define NO_HEX_FP to omit recognition of hexadecimal floating-point - * values by strtod. - * #define NO_STRTOD_BIGCOMP (on IEEE-arithmetic systems only for now) - * to disable logic for "fast" testing of very long input strings - * to strtod. This testing proceeds by initially truncating the - * input string, then if necessary comparing the whole string with - * a decimal expansion to decide close cases. This logic is only - * used for input more than STRTOD_DIGLIM digits long (default 40). - */ - -#ifndef Long -#define Long int -#endif -#ifndef ULong -typedef unsigned Long ULong; -#endif - -#ifdef DEBUG -#include -#include "stdio.h" -#define Bug(x) {fprintf(stderr, "%s\n", x); exit(1);} -#define Debug(x) x -int dtoa_stats[7]; /* strtod_{64,96,bigcomp},dtoa_{exact,64,96,bigcomp} */ -#else -#define assert(x) /*nothing*/ -#define Debug(x) /*nothing*/ -#endif - -#include "stdlib.h" -#include "string.h" - -#ifdef USE_LOCALE -#include "locale.h" -#endif - -#ifdef Honor_FLT_ROUNDS -#ifndef Trust_FLT_ROUNDS -#include -#endif -#endif - -#ifdef __cplusplus -extern "C" { -#endif -#ifdef MALLOC -extern void *MALLOC(size_t); -#else -#define MALLOC malloc -#endif - -#ifdef REALLOC -extern void *REALLOC(void*,size_t); -#else -#define REALLOC realloc -#endif - -#ifndef FREE -#define FREE free -#endif - -#ifdef __cplusplus - } -#endif - -#ifndef Omit_Private_Memory -#ifndef PRIVATE_MEM -#define PRIVATE_MEM 2304 -#endif -#define PRIVATE_mem ((PRIVATE_MEM+sizeof(double)-1)/sizeof(double)) -static double private_mem[PRIVATE_mem], *pmem_next = private_mem; -#endif - -#undef IEEE_Arith -#undef Avoid_Underflow -#ifdef IEEE_MC68k -#define IEEE_Arith -#endif -#ifdef IEEE_8087 -#define IEEE_Arith -#endif - -#ifdef IEEE_Arith -#ifndef NO_INFNAN_CHECK -#undef INFNAN_CHECK -#define INFNAN_CHECK -#endif -#else -#undef INFNAN_CHECK -#define NO_STRTOD_BIGCOMP -#endif - -#include "errno.h" - -#ifdef NO_ERRNO /*{*/ -#undef Set_errno -#define Set_errno(x) -#else -#ifndef Set_errno -#define Set_errno(x) errno = x -#endif -#endif /*}*/ - -#ifdef Bad_float_h - -#ifdef IEEE_Arith -#define DBL_DIG 15 -#define DBL_MAX_10_EXP 308 -#define DBL_MAX_EXP 1024 -#define FLT_RADIX 2 -#endif /*IEEE_Arith*/ - -#ifdef IBM -#define DBL_DIG 16 -#define DBL_MAX_10_EXP 75 -#define DBL_MAX_EXP 63 -#define FLT_RADIX 16 -#define DBL_MAX 7.2370055773322621e+75 -#endif - -#ifdef VAX -#define DBL_DIG 16 -#define DBL_MAX_10_EXP 38 -#define DBL_MAX_EXP 127 -#define FLT_RADIX 2 -#define DBL_MAX 1.7014118346046923e+38 -#endif - -#ifndef LONG_MAX -#define LONG_MAX 2147483647 -#endif - -#else /* ifndef Bad_float_h */ -#include "float.h" -#endif /* Bad_float_h */ - -#ifndef __MATH_H__ -#include "math.h" -#endif - -#ifdef __cplusplus -extern "C" { -#endif - -#if defined(IEEE_8087) + defined(IEEE_MC68k) + defined(VAX) + defined(IBM) != 1 -Exactly one of IEEE_8087, IEEE_MC68k, VAX, or IBM should be defined. -#endif - -#undef USE_BF96 - -#ifdef NO_LONG_LONG /*{{*/ -#undef ULLong -#ifdef Just_16 -#undef Pack_32 -/* When Pack_32 is not defined, we store 16 bits per 32-bit Long. - * This makes some inner loops simpler and sometimes saves work - * during multiplications, but it often seems to make things slightly - * slower. Hence the default is now to store 32 bits per Long. - */ -#endif -#else /*}{ long long available */ -#ifndef Llong -#define Llong long long -#endif -#ifndef ULLong -#define ULLong unsigned Llong -#endif -#ifndef NO_BF96 /*{*/ -#define USE_BF96 - -#ifdef SET_INEXACT -#define dtoa_divmax 27 -#else -int dtoa_divmax = 2; /* Permit experimenting: on some systems, 64-bit integer */ - /* division is slow enough that we may sometimes want to */ - /* avoid using it. We assume (but do not check) that */ - /* dtoa_divmax <= 27.*/ -#endif - -typedef struct BF96 { /* Normalized 96-bit software floating point numbers */ - unsigned int b0,b1,b2; /* b0 = most significant, binary point just to its left */ - int e; /* number represented = b * 2^e, with .5 <= b < 1 */ - } BF96; - - static BF96 pten[667] = { - { 0xeef453d6, 0x923bd65a, 0x113faa29, -1136 }, - { 0x9558b466, 0x1b6565f8, 0x4ac7ca59, -1132 }, - { 0xbaaee17f, 0xa23ebf76, 0x5d79bcf0, -1129 }, - { 0xe95a99df, 0x8ace6f53, 0xf4d82c2c, -1126 }, - { 0x91d8a02b, 0xb6c10594, 0x79071b9b, -1122 }, - { 0xb64ec836, 0xa47146f9, 0x9748e282, -1119 }, - { 0xe3e27a44, 0x4d8d98b7, 0xfd1b1b23, -1116 }, - { 0x8e6d8c6a, 0xb0787f72, 0xfe30f0f5, -1112 }, - { 0xb208ef85, 0x5c969f4f, 0xbdbd2d33, -1109 }, - { 0xde8b2b66, 0xb3bc4723, 0xad2c7880, -1106 }, - { 0x8b16fb20, 0x3055ac76, 0x4c3bcb50, -1102 }, - { 0xaddcb9e8, 0x3c6b1793, 0xdf4abe24, -1099 }, - { 0xd953e862, 0x4b85dd78, 0xd71d6dad, -1096 }, - { 0x87d4713d, 0x6f33aa6b, 0x8672648c, -1092 }, - { 0xa9c98d8c, 0xcb009506, 0x680efdaf, -1089 }, - { 0xd43bf0ef, 0xfdc0ba48, 0x0212bd1b, -1086 }, - { 0x84a57695, 0xfe98746d, 0x014bb630, -1082 }, - { 0xa5ced43b, 0x7e3e9188, 0x419ea3bd, -1079 }, - { 0xcf42894a, 0x5dce35ea, 0x52064cac, -1076 }, - { 0x818995ce, 0x7aa0e1b2, 0x7343efeb, -1072 }, - { 0xa1ebfb42, 0x19491a1f, 0x1014ebe6, -1069 }, - { 0xca66fa12, 0x9f9b60a6, 0xd41a26e0, -1066 }, - { 0xfd00b897, 0x478238d0, 0x8920b098, -1063 }, - { 0x9e20735e, 0x8cb16382, 0x55b46e5f, -1059 }, - { 0xc5a89036, 0x2fddbc62, 0xeb2189f7, -1056 }, - { 0xf712b443, 0xbbd52b7b, 0xa5e9ec75, -1053 }, - { 0x9a6bb0aa, 0x55653b2d, 0x47b233c9, -1049 }, - { 0xc1069cd4, 0xeabe89f8, 0x999ec0bb, -1046 }, - { 0xf148440a, 0x256e2c76, 0xc00670ea, -1043 }, - { 0x96cd2a86, 0x5764dbca, 0x38040692, -1039 }, - { 0xbc807527, 0xed3e12bc, 0xc6050837, -1036 }, - { 0xeba09271, 0xe88d976b, 0xf7864a44, -1033 }, - { 0x93445b87, 0x31587ea3, 0x7ab3ee6a, -1029 }, - { 0xb8157268, 0xfdae9e4c, 0x5960ea05, -1026 }, - { 0xe61acf03, 0x3d1a45df, 0x6fb92487, -1023 }, - { 0x8fd0c162, 0x06306bab, 0xa5d3b6d4, -1019 }, - { 0xb3c4f1ba, 0x87bc8696, 0x8f48a489, -1016 }, - { 0xe0b62e29, 0x29aba83c, 0x331acdab, -1013 }, - { 0x8c71dcd9, 0xba0b4925, 0x9ff0c08b, -1009 }, - { 0xaf8e5410, 0x288e1b6f, 0x07ecf0ae, -1006 }, - { 0xdb71e914, 0x32b1a24a, 0xc9e82cd9, -1003 }, - { 0x892731ac, 0x9faf056e, 0xbe311c08, -999 }, - { 0xab70fe17, 0xc79ac6ca, 0x6dbd630a, -996 }, - { 0xd64d3d9d, 0xb981787d, 0x092cbbcc, -993 }, - { 0x85f04682, 0x93f0eb4e, 0x25bbf560, -989 }, - { 0xa76c5823, 0x38ed2621, 0xaf2af2b8, -986 }, - { 0xd1476e2c, 0x07286faa, 0x1af5af66, -983 }, - { 0x82cca4db, 0x847945ca, 0x50d98d9f, -979 }, - { 0xa37fce12, 0x6597973c, 0xe50ff107, -976 }, - { 0xcc5fc196, 0xfefd7d0c, 0x1e53ed49, -973 }, - { 0xff77b1fc, 0xbebcdc4f, 0x25e8e89c, -970 }, - { 0x9faacf3d, 0xf73609b1, 0x77b19161, -966 }, - { 0xc795830d, 0x75038c1d, 0xd59df5b9, -963 }, - { 0xf97ae3d0, 0xd2446f25, 0x4b057328, -960 }, - { 0x9becce62, 0x836ac577, 0x4ee367f9, -956 }, - { 0xc2e801fb, 0x244576d5, 0x229c41f7, -953 }, - { 0xf3a20279, 0xed56d48a, 0x6b435275, -950 }, - { 0x9845418c, 0x345644d6, 0x830a1389, -946 }, - { 0xbe5691ef, 0x416bd60c, 0x23cc986b, -943 }, - { 0xedec366b, 0x11c6cb8f, 0x2cbfbe86, -940 }, - { 0x94b3a202, 0xeb1c3f39, 0x7bf7d714, -936 }, - { 0xb9e08a83, 0xa5e34f07, 0xdaf5ccd9, -933 }, - { 0xe858ad24, 0x8f5c22c9, 0xd1b3400f, -930 }, - { 0x91376c36, 0xd99995be, 0x23100809, -926 }, - { 0xb5854744, 0x8ffffb2d, 0xabd40a0c, -923 }, - { 0xe2e69915, 0xb3fff9f9, 0x16c90c8f, -920 }, - { 0x8dd01fad, 0x907ffc3b, 0xae3da7d9, -916 }, - { 0xb1442798, 0xf49ffb4a, 0x99cd11cf, -913 }, - { 0xdd95317f, 0x31c7fa1d, 0x40405643, -910 }, - { 0x8a7d3eef, 0x7f1cfc52, 0x482835ea, -906 }, - { 0xad1c8eab, 0x5ee43b66, 0xda324365, -903 }, - { 0xd863b256, 0x369d4a40, 0x90bed43e, -900 }, - { 0x873e4f75, 0xe2224e68, 0x5a7744a6, -896 }, - { 0xa90de353, 0x5aaae202, 0x711515d0, -893 }, - { 0xd3515c28, 0x31559a83, 0x0d5a5b44, -890 }, - { 0x8412d999, 0x1ed58091, 0xe858790a, -886 }, - { 0xa5178fff, 0x668ae0b6, 0x626e974d, -883 }, - { 0xce5d73ff, 0x402d98e3, 0xfb0a3d21, -880 }, - { 0x80fa687f, 0x881c7f8e, 0x7ce66634, -876 }, - { 0xa139029f, 0x6a239f72, 0x1c1fffc1, -873 }, - { 0xc9874347, 0x44ac874e, 0xa327ffb2, -870 }, - { 0xfbe91419, 0x15d7a922, 0x4bf1ff9f, -867 }, - { 0x9d71ac8f, 0xada6c9b5, 0x6f773fc3, -863 }, - { 0xc4ce17b3, 0x99107c22, 0xcb550fb4, -860 }, - { 0xf6019da0, 0x7f549b2b, 0x7e2a53a1, -857 }, - { 0x99c10284, 0x4f94e0fb, 0x2eda7444, -853 }, - { 0xc0314325, 0x637a1939, 0xfa911155, -850 }, - { 0xf03d93ee, 0xbc589f88, 0x793555ab, -847 }, - { 0x96267c75, 0x35b763b5, 0x4bc1558b, -843 }, - { 0xbbb01b92, 0x83253ca2, 0x9eb1aaed, -840 }, - { 0xea9c2277, 0x23ee8bcb, 0x465e15a9, -837 }, - { 0x92a1958a, 0x7675175f, 0x0bfacd89, -833 }, - { 0xb749faed, 0x14125d36, 0xcef980ec, -830 }, - { 0xe51c79a8, 0x5916f484, 0x82b7e127, -827 }, - { 0x8f31cc09, 0x37ae58d2, 0xd1b2ecb8, -823 }, - { 0xb2fe3f0b, 0x8599ef07, 0x861fa7e6, -820 }, - { 0xdfbdcece, 0x67006ac9, 0x67a791e0, -817 }, - { 0x8bd6a141, 0x006042bd, 0xe0c8bb2c, -813 }, - { 0xaecc4991, 0x4078536d, 0x58fae9f7, -810 }, - { 0xda7f5bf5, 0x90966848, 0xaf39a475, -807 }, - { 0x888f9979, 0x7a5e012d, 0x6d8406c9, -803 }, - { 0xaab37fd7, 0xd8f58178, 0xc8e5087b, -800 }, - { 0xd5605fcd, 0xcf32e1d6, 0xfb1e4a9a, -797 }, - { 0x855c3be0, 0xa17fcd26, 0x5cf2eea0, -793 }, - { 0xa6b34ad8, 0xc9dfc06f, 0xf42faa48, -790 }, - { 0xd0601d8e, 0xfc57b08b, 0xf13b94da, -787 }, - { 0x823c1279, 0x5db6ce57, 0x76c53d08, -783 }, - { 0xa2cb1717, 0xb52481ed, 0x54768c4b, -780 }, - { 0xcb7ddcdd, 0xa26da268, 0xa9942f5d, -777 }, - { 0xfe5d5415, 0x0b090b02, 0xd3f93b35, -774 }, - { 0x9efa548d, 0x26e5a6e1, 0xc47bc501, -770 }, - { 0xc6b8e9b0, 0x709f109a, 0x359ab641, -767 }, - { 0xf867241c, 0x8cc6d4c0, 0xc30163d2, -764 }, - { 0x9b407691, 0xd7fc44f8, 0x79e0de63, -760 }, - { 0xc2109436, 0x4dfb5636, 0x985915fc, -757 }, - { 0xf294b943, 0xe17a2bc4, 0x3e6f5b7b, -754 }, - { 0x979cf3ca, 0x6cec5b5a, 0xa705992c, -750 }, - { 0xbd8430bd, 0x08277231, 0x50c6ff78, -747 }, - { 0xece53cec, 0x4a314ebd, 0xa4f8bf56, -744 }, - { 0x940f4613, 0xae5ed136, 0x871b7795, -740 }, - { 0xb9131798, 0x99f68584, 0x28e2557b, -737 }, - { 0xe757dd7e, 0xc07426e5, 0x331aeada, -734 }, - { 0x9096ea6f, 0x3848984f, 0x3ff0d2c8, -730 }, - { 0xb4bca50b, 0x065abe63, 0x0fed077a, -727 }, - { 0xe1ebce4d, 0xc7f16dfb, 0xd3e84959, -724 }, - { 0x8d3360f0, 0x9cf6e4bd, 0x64712dd7, -720 }, - { 0xb080392c, 0xc4349dec, 0xbd8d794d, -717 }, - { 0xdca04777, 0xf541c567, 0xecf0d7a0, -714 }, - { 0x89e42caa, 0xf9491b60, 0xf41686c4, -710 }, - { 0xac5d37d5, 0xb79b6239, 0x311c2875, -707 }, - { 0xd77485cb, 0x25823ac7, 0x7d633293, -704 }, - { 0x86a8d39e, 0xf77164bc, 0xae5dff9c, -700 }, - { 0xa8530886, 0xb54dbdeb, 0xd9f57f83, -697 }, - { 0xd267caa8, 0x62a12d66, 0xd072df63, -694 }, - { 0x8380dea9, 0x3da4bc60, 0x4247cb9e, -690 }, - { 0xa4611653, 0x8d0deb78, 0x52d9be85, -687 }, - { 0xcd795be8, 0x70516656, 0x67902e27, -684 }, - { 0x806bd971, 0x4632dff6, 0x00ba1cd8, -680 }, - { 0xa086cfcd, 0x97bf97f3, 0x80e8a40e, -677 }, - { 0xc8a883c0, 0xfdaf7df0, 0x6122cd12, -674 }, - { 0xfad2a4b1, 0x3d1b5d6c, 0x796b8057, -671 }, - { 0x9cc3a6ee, 0xc6311a63, 0xcbe33036, -667 }, - { 0xc3f490aa, 0x77bd60fc, 0xbedbfc44, -664 }, - { 0xf4f1b4d5, 0x15acb93b, 0xee92fb55, -661 }, - { 0x99171105, 0x2d8bf3c5, 0x751bdd15, -657 }, - { 0xbf5cd546, 0x78eef0b6, 0xd262d45a, -654 }, - { 0xef340a98, 0x172aace4, 0x86fb8971, -651 }, - { 0x9580869f, 0x0e7aac0e, 0xd45d35e6, -647 }, - { 0xbae0a846, 0xd2195712, 0x89748360, -644 }, - { 0xe998d258, 0x869facd7, 0x2bd1a438, -641 }, - { 0x91ff8377, 0x5423cc06, 0x7b6306a3, -637 }, - { 0xb67f6455, 0x292cbf08, 0x1a3bc84c, -634 }, - { 0xe41f3d6a, 0x7377eeca, 0x20caba5f, -631 }, - { 0x8e938662, 0x882af53e, 0x547eb47b, -627 }, - { 0xb23867fb, 0x2a35b28d, 0xe99e619a, -624 }, - { 0xdec681f9, 0xf4c31f31, 0x6405fa00, -621 }, - { 0x8b3c113c, 0x38f9f37e, 0xde83bc40, -617 }, - { 0xae0b158b, 0x4738705e, 0x9624ab50, -614 }, - { 0xd98ddaee, 0x19068c76, 0x3badd624, -611 }, - { 0x87f8a8d4, 0xcfa417c9, 0xe54ca5d7, -607 }, - { 0xa9f6d30a, 0x038d1dbc, 0x5e9fcf4c, -604 }, - { 0xd47487cc, 0x8470652b, 0x7647c320, -601 }, - { 0x84c8d4df, 0xd2c63f3b, 0x29ecd9f4, -597 }, - { 0xa5fb0a17, 0xc777cf09, 0xf4681071, -594 }, - { 0xcf79cc9d, 0xb955c2cc, 0x7182148d, -591 }, - { 0x81ac1fe2, 0x93d599bf, 0xc6f14cd8, -587 }, - { 0xa21727db, 0x38cb002f, 0xb8ada00e, -584 }, - { 0xca9cf1d2, 0x06fdc03b, 0xa6d90811, -581 }, - { 0xfd442e46, 0x88bd304a, 0x908f4a16, -578 }, - { 0x9e4a9cec, 0x15763e2e, 0x9a598e4e, -574 }, - { 0xc5dd4427, 0x1ad3cdba, 0x40eff1e1, -571 }, - { 0xf7549530, 0xe188c128, 0xd12bee59, -568 }, - { 0x9a94dd3e, 0x8cf578b9, 0x82bb74f8, -564 }, - { 0xc13a148e, 0x3032d6e7, 0xe36a5236, -561 }, - { 0xf18899b1, 0xbc3f8ca1, 0xdc44e6c3, -558 }, - { 0x96f5600f, 0x15a7b7e5, 0x29ab103a, -554 }, - { 0xbcb2b812, 0xdb11a5de, 0x7415d448, -551 }, - { 0xebdf6617, 0x91d60f56, 0x111b495b, -548 }, - { 0x936b9fce, 0xbb25c995, 0xcab10dd9, -544 }, - { 0xb84687c2, 0x69ef3bfb, 0x3d5d514f, -541 }, - { 0xe65829b3, 0x046b0afa, 0x0cb4a5a3, -538 }, - { 0x8ff71a0f, 0xe2c2e6dc, 0x47f0e785, -534 }, - { 0xb3f4e093, 0xdb73a093, 0x59ed2167, -531 }, - { 0xe0f218b8, 0xd25088b8, 0x306869c1, -528 }, - { 0x8c974f73, 0x83725573, 0x1e414218, -524 }, - { 0xafbd2350, 0x644eeacf, 0xe5d1929e, -521 }, - { 0xdbac6c24, 0x7d62a583, 0xdf45f746, -518 }, - { 0x894bc396, 0xce5da772, 0x6b8bba8c, -514 }, - { 0xab9eb47c, 0x81f5114f, 0x066ea92f, -511 }, - { 0xd686619b, 0xa27255a2, 0xc80a537b, -508 }, - { 0x8613fd01, 0x45877585, 0xbd06742c, -504 }, - { 0xa798fc41, 0x96e952e7, 0x2c481138, -501 }, - { 0xd17f3b51, 0xfca3a7a0, 0xf75a1586, -498 }, - { 0x82ef8513, 0x3de648c4, 0x9a984d73, -494 }, - { 0xa3ab6658, 0x0d5fdaf5, 0xc13e60d0, -491 }, - { 0xcc963fee, 0x10b7d1b3, 0x318df905, -488 }, - { 0xffbbcfe9, 0x94e5c61f, 0xfdf17746, -485 }, - { 0x9fd561f1, 0xfd0f9bd3, 0xfeb6ea8b, -481 }, - { 0xc7caba6e, 0x7c5382c8, 0xfe64a52e, -478 }, - { 0xf9bd690a, 0x1b68637b, 0x3dfdce7a, -475 }, - { 0x9c1661a6, 0x51213e2d, 0x06bea10c, -471 }, - { 0xc31bfa0f, 0xe5698db8, 0x486e494f, -468 }, - { 0xf3e2f893, 0xdec3f126, 0x5a89dba3, -465 }, - { 0x986ddb5c, 0x6b3a76b7, 0xf8962946, -461 }, - { 0xbe895233, 0x86091465, 0xf6bbb397, -458 }, - { 0xee2ba6c0, 0x678b597f, 0x746aa07d, -455 }, - { 0x94db4838, 0x40b717ef, 0xa8c2a44e, -451 }, - { 0xba121a46, 0x50e4ddeb, 0x92f34d62, -448 }, - { 0xe896a0d7, 0xe51e1566, 0x77b020ba, -445 }, - { 0x915e2486, 0xef32cd60, 0x0ace1474, -441 }, - { 0xb5b5ada8, 0xaaff80b8, 0x0d819992, -438 }, - { 0xe3231912, 0xd5bf60e6, 0x10e1fff6, -435 }, - { 0x8df5efab, 0xc5979c8f, 0xca8d3ffa, -431 }, - { 0xb1736b96, 0xb6fd83b3, 0xbd308ff8, -428 }, - { 0xddd0467c, 0x64bce4a0, 0xac7cb3f6, -425 }, - { 0x8aa22c0d, 0xbef60ee4, 0x6bcdf07a, -421 }, - { 0xad4ab711, 0x2eb3929d, 0x86c16c98, -418 }, - { 0xd89d64d5, 0x7a607744, 0xe871c7bf, -415 }, - { 0x87625f05, 0x6c7c4a8b, 0x11471cd7, -411 }, - { 0xa93af6c6, 0xc79b5d2d, 0xd598e40d, -408 }, - { 0xd389b478, 0x79823479, 0x4aff1d10, -405 }, - { 0x843610cb, 0x4bf160cb, 0xcedf722a, -401 }, - { 0xa54394fe, 0x1eedb8fe, 0xc2974eb4, -398 }, - { 0xce947a3d, 0xa6a9273e, 0x733d2262, -395 }, - { 0x811ccc66, 0x8829b887, 0x0806357d, -391 }, - { 0xa163ff80, 0x2a3426a8, 0xca07c2dc, -388 }, - { 0xc9bcff60, 0x34c13052, 0xfc89b393, -385 }, - { 0xfc2c3f38, 0x41f17c67, 0xbbac2078, -382 }, - { 0x9d9ba783, 0x2936edc0, 0xd54b944b, -378 }, - { 0xc5029163, 0xf384a931, 0x0a9e795e, -375 }, - { 0xf64335bc, 0xf065d37d, 0x4d4617b5, -372 }, - { 0x99ea0196, 0x163fa42e, 0x504bced1, -368 }, - { 0xc06481fb, 0x9bcf8d39, 0xe45ec286, -365 }, - { 0xf07da27a, 0x82c37088, 0x5d767327, -362 }, - { 0x964e858c, 0x91ba2655, 0x3a6a07f8, -358 }, - { 0xbbe226ef, 0xb628afea, 0x890489f7, -355 }, - { 0xeadab0ab, 0xa3b2dbe5, 0x2b45ac74, -352 }, - { 0x92c8ae6b, 0x464fc96f, 0x3b0b8bc9, -348 }, - { 0xb77ada06, 0x17e3bbcb, 0x09ce6ebb, -345 }, - { 0xe5599087, 0x9ddcaabd, 0xcc420a6a, -342 }, - { 0x8f57fa54, 0xc2a9eab6, 0x9fa94682, -338 }, - { 0xb32df8e9, 0xf3546564, 0x47939822, -335 }, - { 0xdff97724, 0x70297ebd, 0x59787e2b, -332 }, - { 0x8bfbea76, 0xc619ef36, 0x57eb4edb, -328 }, - { 0xaefae514, 0x77a06b03, 0xede62292, -325 }, - { 0xdab99e59, 0x958885c4, 0xe95fab36, -322 }, - { 0x88b402f7, 0xfd75539b, 0x11dbcb02, -318 }, - { 0xaae103b5, 0xfcd2a881, 0xd652bdc2, -315 }, - { 0xd59944a3, 0x7c0752a2, 0x4be76d33, -312 }, - { 0x857fcae6, 0x2d8493a5, 0x6f70a440, -308 }, - { 0xa6dfbd9f, 0xb8e5b88e, 0xcb4ccd50, -305 }, - { 0xd097ad07, 0xa71f26b2, 0x7e2000a4, -302 }, - { 0x825ecc24, 0xc873782f, 0x8ed40066, -298 }, - { 0xa2f67f2d, 0xfa90563b, 0x72890080, -295 }, - { 0xcbb41ef9, 0x79346bca, 0x4f2b40a0, -292 }, - { 0xfea126b7, 0xd78186bc, 0xe2f610c8, -289 }, - { 0x9f24b832, 0xe6b0f436, 0x0dd9ca7d, -285 }, - { 0xc6ede63f, 0xa05d3143, 0x91503d1c, -282 }, - { 0xf8a95fcf, 0x88747d94, 0x75a44c63, -279 }, - { 0x9b69dbe1, 0xb548ce7c, 0xc986afbe, -275 }, - { 0xc24452da, 0x229b021b, 0xfbe85bad, -272 }, - { 0xf2d56790, 0xab41c2a2, 0xfae27299, -269 }, - { 0x97c560ba, 0x6b0919a5, 0xdccd879f, -265 }, - { 0xbdb6b8e9, 0x05cb600f, 0x5400e987, -262 }, - { 0xed246723, 0x473e3813, 0x290123e9, -259 }, - { 0x9436c076, 0x0c86e30b, 0xf9a0b672, -255 }, - { 0xb9447093, 0x8fa89bce, 0xf808e40e, -252 }, - { 0xe7958cb8, 0x7392c2c2, 0xb60b1d12, -249 }, - { 0x90bd77f3, 0x483bb9b9, 0xb1c6f22b, -245 }, - { 0xb4ecd5f0, 0x1a4aa828, 0x1e38aeb6, -242 }, - { 0xe2280b6c, 0x20dd5232, 0x25c6da63, -239 }, - { 0x8d590723, 0x948a535f, 0x579c487e, -235 }, - { 0xb0af48ec, 0x79ace837, 0x2d835a9d, -232 }, - { 0xdcdb1b27, 0x98182244, 0xf8e43145, -229 }, - { 0x8a08f0f8, 0xbf0f156b, 0x1b8e9ecb, -225 }, - { 0xac8b2d36, 0xeed2dac5, 0xe272467e, -222 }, - { 0xd7adf884, 0xaa879177, 0x5b0ed81d, -219 }, - { 0x86ccbb52, 0xea94baea, 0x98e94712, -215 }, - { 0xa87fea27, 0xa539e9a5, 0x3f2398d7, -212 }, - { 0xd29fe4b1, 0x8e88640e, 0x8eec7f0d, -209 }, - { 0x83a3eeee, 0xf9153e89, 0x1953cf68, -205 }, - { 0xa48ceaaa, 0xb75a8e2b, 0x5fa8c342, -202 }, - { 0xcdb02555, 0x653131b6, 0x3792f412, -199 }, - { 0x808e1755, 0x5f3ebf11, 0xe2bbd88b, -195 }, - { 0xa0b19d2a, 0xb70e6ed6, 0x5b6aceae, -192 }, - { 0xc8de0475, 0x64d20a8b, 0xf245825a, -189 }, - { 0xfb158592, 0xbe068d2e, 0xeed6e2f0, -186 }, - { 0x9ced737b, 0xb6c4183d, 0x55464dd6, -182 }, - { 0xc428d05a, 0xa4751e4c, 0xaa97e14c, -179 }, - { 0xf5330471, 0x4d9265df, 0xd53dd99f, -176 }, - { 0x993fe2c6, 0xd07b7fab, 0xe546a803, -172 }, - { 0xbf8fdb78, 0x849a5f96, 0xde985204, -169 }, - { 0xef73d256, 0xa5c0f77c, 0x963e6685, -166 }, - { 0x95a86376, 0x27989aad, 0xdde70013, -162 }, - { 0xbb127c53, 0xb17ec159, 0x5560c018, -159 }, - { 0xe9d71b68, 0x9dde71af, 0xaab8f01e, -156 }, - { 0x92267121, 0x62ab070d, 0xcab39613, -152 }, - { 0xb6b00d69, 0xbb55c8d1, 0x3d607b97, -149 }, - { 0xe45c10c4, 0x2a2b3b05, 0x8cb89a7d, -146 }, - { 0x8eb98a7a, 0x9a5b04e3, 0x77f3608e, -142 }, - { 0xb267ed19, 0x40f1c61c, 0x55f038b2, -139 }, - { 0xdf01e85f, 0x912e37a3, 0x6b6c46de, -136 }, - { 0x8b61313b, 0xbabce2c6, 0x2323ac4b, -132 }, - { 0xae397d8a, 0xa96c1b77, 0xabec975e, -129 }, - { 0xd9c7dced, 0x53c72255, 0x96e7bd35, -126 }, - { 0x881cea14, 0x545c7575, 0x7e50d641, -122 }, - { 0xaa242499, 0x697392d2, 0xdde50bd1, -119 }, - { 0xd4ad2dbf, 0xc3d07787, 0x955e4ec6, -116 }, - { 0x84ec3c97, 0xda624ab4, 0xbd5af13b, -112 }, - { 0xa6274bbd, 0xd0fadd61, 0xecb1ad8a, -109 }, - { 0xcfb11ead, 0x453994ba, 0x67de18ed, -106 }, - { 0x81ceb32c, 0x4b43fcf4, 0x80eacf94, -102 }, - { 0xa2425ff7, 0x5e14fc31, 0xa1258379, -99 }, - { 0xcad2f7f5, 0x359a3b3e, 0x096ee458, -96 }, - { 0xfd87b5f2, 0x8300ca0d, 0x8bca9d6e, -93 }, - { 0x9e74d1b7, 0x91e07e48, 0x775ea264, -89 }, - { 0xc6120625, 0x76589dda, 0x95364afe, -86 }, - { 0xf79687ae, 0xd3eec551, 0x3a83ddbd, -83 }, - { 0x9abe14cd, 0x44753b52, 0xc4926a96, -79 }, - { 0xc16d9a00, 0x95928a27, 0x75b7053c, -76 }, - { 0xf1c90080, 0xbaf72cb1, 0x5324c68b, -73 }, - { 0x971da050, 0x74da7bee, 0xd3f6fc16, -69 }, - { 0xbce50864, 0x92111aea, 0x88f4bb1c, -66 }, - { 0xec1e4a7d, 0xb69561a5, 0x2b31e9e3, -63 }, - { 0x9392ee8e, 0x921d5d07, 0x3aff322e, -59 }, - { 0xb877aa32, 0x36a4b449, 0x09befeb9, -56 }, - { 0xe69594be, 0xc44de15b, 0x4c2ebe68, -53 }, - { 0x901d7cf7, 0x3ab0acd9, 0x0f9d3701, -49 }, - { 0xb424dc35, 0x095cd80f, 0x538484c1, -46 }, - { 0xe12e1342, 0x4bb40e13, 0x2865a5f2, -43 }, - { 0x8cbccc09, 0x6f5088cb, 0xf93f87b7, -39 }, - { 0xafebff0b, 0xcb24aafe, 0xf78f69a5, -36 }, - { 0xdbe6fece, 0xbdedd5be, 0xb573440e, -33 }, - { 0x89705f41, 0x36b4a597, 0x31680a88, -29 }, - { 0xabcc7711, 0x8461cefc, 0xfdc20d2b, -26 }, - { 0xd6bf94d5, 0xe57a42bc, 0x3d329076, -23 }, - { 0x8637bd05, 0xaf6c69b5, 0xa63f9a49, -19 }, - { 0xa7c5ac47, 0x1b478423, 0x0fcf80dc, -16 }, - { 0xd1b71758, 0xe219652b, 0xd3c36113, -13 }, - { 0x83126e97, 0x8d4fdf3b, 0x645a1cac, -9 }, - { 0xa3d70a3d, 0x70a3d70a, 0x3d70a3d7, -6 }, - { 0xcccccccc, 0xcccccccc, 0xcccccccc, -3 }, - { 0x80000000, 0x00000000, 0x00000000, 1 }, - { 0xa0000000, 0x00000000, 0x00000000, 4 }, - { 0xc8000000, 0x00000000, 0x00000000, 7 }, - { 0xfa000000, 0x00000000, 0x00000000, 10 }, - { 0x9c400000, 0x00000000, 0x00000000, 14 }, - { 0xc3500000, 0x00000000, 0x00000000, 17 }, - { 0xf4240000, 0x00000000, 0x00000000, 20 }, - { 0x98968000, 0x00000000, 0x00000000, 24 }, - { 0xbebc2000, 0x00000000, 0x00000000, 27 }, - { 0xee6b2800, 0x00000000, 0x00000000, 30 }, - { 0x9502f900, 0x00000000, 0x00000000, 34 }, - { 0xba43b740, 0x00000000, 0x00000000, 37 }, - { 0xe8d4a510, 0x00000000, 0x00000000, 40 }, - { 0x9184e72a, 0x00000000, 0x00000000, 44 }, - { 0xb5e620f4, 0x80000000, 0x00000000, 47 }, - { 0xe35fa931, 0xa0000000, 0x00000000, 50 }, - { 0x8e1bc9bf, 0x04000000, 0x00000000, 54 }, - { 0xb1a2bc2e, 0xc5000000, 0x00000000, 57 }, - { 0xde0b6b3a, 0x76400000, 0x00000000, 60 }, - { 0x8ac72304, 0x89e80000, 0x00000000, 64 }, - { 0xad78ebc5, 0xac620000, 0x00000000, 67 }, - { 0xd8d726b7, 0x177a8000, 0x00000000, 70 }, - { 0x87867832, 0x6eac9000, 0x00000000, 74 }, - { 0xa968163f, 0x0a57b400, 0x00000000, 77 }, - { 0xd3c21bce, 0xcceda100, 0x00000000, 80 }, - { 0x84595161, 0x401484a0, 0x00000000, 84 }, - { 0xa56fa5b9, 0x9019a5c8, 0x00000000, 87 }, - { 0xcecb8f27, 0xf4200f3a, 0x00000000, 90 }, - { 0x813f3978, 0xf8940984, 0x40000000, 94 }, - { 0xa18f07d7, 0x36b90be5, 0x50000000, 97 }, - { 0xc9f2c9cd, 0x04674ede, 0xa4000000, 100 }, - { 0xfc6f7c40, 0x45812296, 0x4d000000, 103 }, - { 0x9dc5ada8, 0x2b70b59d, 0xf0200000, 107 }, - { 0xc5371912, 0x364ce305, 0x6c280000, 110 }, - { 0xf684df56, 0xc3e01bc6, 0xc7320000, 113 }, - { 0x9a130b96, 0x3a6c115c, 0x3c7f4000, 117 }, - { 0xc097ce7b, 0xc90715b3, 0x4b9f1000, 120 }, - { 0xf0bdc21a, 0xbb48db20, 0x1e86d400, 123 }, - { 0x96769950, 0xb50d88f4, 0x13144480, 127 }, - { 0xbc143fa4, 0xe250eb31, 0x17d955a0, 130 }, - { 0xeb194f8e, 0x1ae525fd, 0x5dcfab08, 133 }, - { 0x92efd1b8, 0xd0cf37be, 0x5aa1cae5, 137 }, - { 0xb7abc627, 0x050305ad, 0xf14a3d9e, 140 }, - { 0xe596b7b0, 0xc643c719, 0x6d9ccd05, 143 }, - { 0x8f7e32ce, 0x7bea5c6f, 0xe4820023, 147 }, - { 0xb35dbf82, 0x1ae4f38b, 0xdda2802c, 150 }, - { 0xe0352f62, 0xa19e306e, 0xd50b2037, 153 }, - { 0x8c213d9d, 0xa502de45, 0x4526f422, 157 }, - { 0xaf298d05, 0x0e4395d6, 0x9670b12b, 160 }, - { 0xdaf3f046, 0x51d47b4c, 0x3c0cdd76, 163 }, - { 0x88d8762b, 0xf324cd0f, 0xa5880a69, 167 }, - { 0xab0e93b6, 0xefee0053, 0x8eea0d04, 170 }, - { 0xd5d238a4, 0xabe98068, 0x72a49045, 173 }, - { 0x85a36366, 0xeb71f041, 0x47a6da2b, 177 }, - { 0xa70c3c40, 0xa64e6c51, 0x999090b6, 180 }, - { 0xd0cf4b50, 0xcfe20765, 0xfff4b4e3, 183 }, - { 0x82818f12, 0x81ed449f, 0xbff8f10e, 187 }, - { 0xa321f2d7, 0x226895c7, 0xaff72d52, 190 }, - { 0xcbea6f8c, 0xeb02bb39, 0x9bf4f8a6, 193 }, - { 0xfee50b70, 0x25c36a08, 0x02f236d0, 196 }, - { 0x9f4f2726, 0x179a2245, 0x01d76242, 200 }, - { 0xc722f0ef, 0x9d80aad6, 0x424d3ad2, 203 }, - { 0xf8ebad2b, 0x84e0d58b, 0xd2e08987, 206 }, - { 0x9b934c3b, 0x330c8577, 0x63cc55f4, 210 }, - { 0xc2781f49, 0xffcfa6d5, 0x3cbf6b71, 213 }, - { 0xf316271c, 0x7fc3908a, 0x8bef464e, 216 }, - { 0x97edd871, 0xcfda3a56, 0x97758bf0, 220 }, - { 0xbde94e8e, 0x43d0c8ec, 0x3d52eeed, 223 }, - { 0xed63a231, 0xd4c4fb27, 0x4ca7aaa8, 226 }, - { 0x945e455f, 0x24fb1cf8, 0x8fe8caa9, 230 }, - { 0xb975d6b6, 0xee39e436, 0xb3e2fd53, 233 }, - { 0xe7d34c64, 0xa9c85d44, 0x60dbbca8, 236 }, - { 0x90e40fbe, 0xea1d3a4a, 0xbc8955e9, 240 }, - { 0xb51d13ae, 0xa4a488dd, 0x6babab63, 243 }, - { 0xe264589a, 0x4dcdab14, 0xc696963c, 246 }, - { 0x8d7eb760, 0x70a08aec, 0xfc1e1de5, 250 }, - { 0xb0de6538, 0x8cc8ada8, 0x3b25a55f, 253 }, - { 0xdd15fe86, 0xaffad912, 0x49ef0eb7, 256 }, - { 0x8a2dbf14, 0x2dfcc7ab, 0x6e356932, 260 }, - { 0xacb92ed9, 0x397bf996, 0x49c2c37f, 263 }, - { 0xd7e77a8f, 0x87daf7fb, 0xdc33745e, 266 }, - { 0x86f0ac99, 0xb4e8dafd, 0x69a028bb, 270 }, - { 0xa8acd7c0, 0x222311bc, 0xc40832ea, 273 }, - { 0xd2d80db0, 0x2aabd62b, 0xf50a3fa4, 276 }, - { 0x83c7088e, 0x1aab65db, 0x792667c6, 280 }, - { 0xa4b8cab1, 0xa1563f52, 0x577001b8, 283 }, - { 0xcde6fd5e, 0x09abcf26, 0xed4c0226, 286 }, - { 0x80b05e5a, 0xc60b6178, 0x544f8158, 290 }, - { 0xa0dc75f1, 0x778e39d6, 0x696361ae, 293 }, - { 0xc913936d, 0xd571c84c, 0x03bc3a19, 296 }, - { 0xfb587849, 0x4ace3a5f, 0x04ab48a0, 299 }, - { 0x9d174b2d, 0xcec0e47b, 0x62eb0d64, 303 }, - { 0xc45d1df9, 0x42711d9a, 0x3ba5d0bd, 306 }, - { 0xf5746577, 0x930d6500, 0xca8f44ec, 309 }, - { 0x9968bf6a, 0xbbe85f20, 0x7e998b13, 313 }, - { 0xbfc2ef45, 0x6ae276e8, 0x9e3fedd8, 316 }, - { 0xefb3ab16, 0xc59b14a2, 0xc5cfe94e, 319 }, - { 0x95d04aee, 0x3b80ece5, 0xbba1f1d1, 323 }, - { 0xbb445da9, 0xca61281f, 0x2a8a6e45, 326 }, - { 0xea157514, 0x3cf97226, 0xf52d09d7, 329 }, - { 0x924d692c, 0xa61be758, 0x593c2626, 333 }, - { 0xb6e0c377, 0xcfa2e12e, 0x6f8b2fb0, 336 }, - { 0xe498f455, 0xc38b997a, 0x0b6dfb9c, 339 }, - { 0x8edf98b5, 0x9a373fec, 0x4724bd41, 343 }, - { 0xb2977ee3, 0x00c50fe7, 0x58edec91, 346 }, - { 0xdf3d5e9b, 0xc0f653e1, 0x2f2967b6, 349 }, - { 0x8b865b21, 0x5899f46c, 0xbd79e0d2, 353 }, - { 0xae67f1e9, 0xaec07187, 0xecd85906, 356 }, - { 0xda01ee64, 0x1a708de9, 0xe80e6f48, 359 }, - { 0x884134fe, 0x908658b2, 0x3109058d, 363 }, - { 0xaa51823e, 0x34a7eede, 0xbd4b46f0, 366 }, - { 0xd4e5e2cd, 0xc1d1ea96, 0x6c9e18ac, 369 }, - { 0x850fadc0, 0x9923329e, 0x03e2cf6b, 373 }, - { 0xa6539930, 0xbf6bff45, 0x84db8346, 376 }, - { 0xcfe87f7c, 0xef46ff16, 0xe6126418, 379 }, - { 0x81f14fae, 0x158c5f6e, 0x4fcb7e8f, 383 }, - { 0xa26da399, 0x9aef7749, 0xe3be5e33, 386 }, - { 0xcb090c80, 0x01ab551c, 0x5cadf5bf, 389 }, - { 0xfdcb4fa0, 0x02162a63, 0x73d9732f, 392 }, - { 0x9e9f11c4, 0x014dda7e, 0x2867e7fd, 396 }, - { 0xc646d635, 0x01a1511d, 0xb281e1fd, 399 }, - { 0xf7d88bc2, 0x4209a565, 0x1f225a7c, 402 }, - { 0x9ae75759, 0x6946075f, 0x3375788d, 406 }, - { 0xc1a12d2f, 0xc3978937, 0x0052d6b1, 409 }, - { 0xf209787b, 0xb47d6b84, 0xc0678c5d, 412 }, - { 0x9745eb4d, 0x50ce6332, 0xf840b7ba, 416 }, - { 0xbd176620, 0xa501fbff, 0xb650e5a9, 419 }, - { 0xec5d3fa8, 0xce427aff, 0xa3e51f13, 422 }, - { 0x93ba47c9, 0x80e98cdf, 0xc66f336c, 426 }, - { 0xb8a8d9bb, 0xe123f017, 0xb80b0047, 429 }, - { 0xe6d3102a, 0xd96cec1d, 0xa60dc059, 432 }, - { 0x9043ea1a, 0xc7e41392, 0x87c89837, 436 }, - { 0xb454e4a1, 0x79dd1877, 0x29babe45, 439 }, - { 0xe16a1dc9, 0xd8545e94, 0xf4296dd6, 442 }, - { 0x8ce2529e, 0x2734bb1d, 0x1899e4a6, 446 }, - { 0xb01ae745, 0xb101e9e4, 0x5ec05dcf, 449 }, - { 0xdc21a117, 0x1d42645d, 0x76707543, 452 }, - { 0x899504ae, 0x72497eba, 0x6a06494a, 456 }, - { 0xabfa45da, 0x0edbde69, 0x0487db9d, 459 }, - { 0xd6f8d750, 0x9292d603, 0x45a9d284, 462 }, - { 0x865b8692, 0x5b9bc5c2, 0x0b8a2392, 466 }, - { 0xa7f26836, 0xf282b732, 0x8e6cac77, 469 }, - { 0xd1ef0244, 0xaf2364ff, 0x3207d795, 472 }, - { 0x8335616a, 0xed761f1f, 0x7f44e6bd, 476 }, - { 0xa402b9c5, 0xa8d3a6e7, 0x5f16206c, 479 }, - { 0xcd036837, 0x130890a1, 0x36dba887, 482 }, - { 0x80222122, 0x6be55a64, 0xc2494954, 486 }, - { 0xa02aa96b, 0x06deb0fd, 0xf2db9baa, 489 }, - { 0xc83553c5, 0xc8965d3d, 0x6f928294, 492 }, - { 0xfa42a8b7, 0x3abbf48c, 0xcb772339, 495 }, - { 0x9c69a972, 0x84b578d7, 0xff2a7604, 499 }, - { 0xc38413cf, 0x25e2d70d, 0xfef51385, 502 }, - { 0xf46518c2, 0xef5b8cd1, 0x7eb25866, 505 }, - { 0x98bf2f79, 0xd5993802, 0xef2f773f, 509 }, - { 0xbeeefb58, 0x4aff8603, 0xaafb550f, 512 }, - { 0xeeaaba2e, 0x5dbf6784, 0x95ba2a53, 515 }, - { 0x952ab45c, 0xfa97a0b2, 0xdd945a74, 519 }, - { 0xba756174, 0x393d88df, 0x94f97111, 522 }, - { 0xe912b9d1, 0x478ceb17, 0x7a37cd56, 525 }, - { 0x91abb422, 0xccb812ee, 0xac62e055, 529 }, - { 0xb616a12b, 0x7fe617aa, 0x577b986b, 532 }, - { 0xe39c4976, 0x5fdf9d94, 0xed5a7e85, 535 }, - { 0x8e41ade9, 0xfbebc27d, 0x14588f13, 539 }, - { 0xb1d21964, 0x7ae6b31c, 0x596eb2d8, 542 }, - { 0xde469fbd, 0x99a05fe3, 0x6fca5f8e, 545 }, - { 0x8aec23d6, 0x80043bee, 0x25de7bb9, 549 }, - { 0xada72ccc, 0x20054ae9, 0xaf561aa7, 552 }, - { 0xd910f7ff, 0x28069da4, 0x1b2ba151, 555 }, - { 0x87aa9aff, 0x79042286, 0x90fb44d2, 559 }, - { 0xa99541bf, 0x57452b28, 0x353a1607, 562 }, - { 0xd3fa922f, 0x2d1675f2, 0x42889b89, 565 }, - { 0x847c9b5d, 0x7c2e09b7, 0x69956135, 569 }, - { 0xa59bc234, 0xdb398c25, 0x43fab983, 572 }, - { 0xcf02b2c2, 0x1207ef2e, 0x94f967e4, 575 }, - { 0x8161afb9, 0x4b44f57d, 0x1d1be0ee, 579 }, - { 0xa1ba1ba7, 0x9e1632dc, 0x6462d92a, 582 }, - { 0xca28a291, 0x859bbf93, 0x7d7b8f75, 585 }, - { 0xfcb2cb35, 0xe702af78, 0x5cda7352, 588 }, - { 0x9defbf01, 0xb061adab, 0x3a088813, 592 }, - { 0xc56baec2, 0x1c7a1916, 0x088aaa18, 595 }, - { 0xf6c69a72, 0xa3989f5b, 0x8aad549e, 598 }, - { 0x9a3c2087, 0xa63f6399, 0x36ac54e2, 602 }, - { 0xc0cb28a9, 0x8fcf3c7f, 0x84576a1b, 605 }, - { 0xf0fdf2d3, 0xf3c30b9f, 0x656d44a2, 608 }, - { 0x969eb7c4, 0x7859e743, 0x9f644ae5, 612 }, - { 0xbc4665b5, 0x96706114, 0x873d5d9f, 615 }, - { 0xeb57ff22, 0xfc0c7959, 0xa90cb506, 618 }, - { 0x9316ff75, 0xdd87cbd8, 0x09a7f124, 622 }, - { 0xb7dcbf53, 0x54e9bece, 0x0c11ed6d, 625 }, - { 0xe5d3ef28, 0x2a242e81, 0x8f1668c8, 628 }, - { 0x8fa47579, 0x1a569d10, 0xf96e017d, 632 }, - { 0xb38d92d7, 0x60ec4455, 0x37c981dc, 635 }, - { 0xe070f78d, 0x3927556a, 0x85bbe253, 638 }, - { 0x8c469ab8, 0x43b89562, 0x93956d74, 642 }, - { 0xaf584166, 0x54a6babb, 0x387ac8d1, 645 }, - { 0xdb2e51bf, 0xe9d0696a, 0x06997b05, 648 }, - { 0x88fcf317, 0xf22241e2, 0x441fece3, 652 }, - { 0xab3c2fdd, 0xeeaad25a, 0xd527e81c, 655 }, - { 0xd60b3bd5, 0x6a5586f1, 0x8a71e223, 658 }, - { 0x85c70565, 0x62757456, 0xf6872d56, 662 }, - { 0xa738c6be, 0xbb12d16c, 0xb428f8ac, 665 }, - { 0xd106f86e, 0x69d785c7, 0xe13336d7, 668 }, - { 0x82a45b45, 0x0226b39c, 0xecc00246, 672 }, - { 0xa34d7216, 0x42b06084, 0x27f002d7, 675 }, - { 0xcc20ce9b, 0xd35c78a5, 0x31ec038d, 678 }, - { 0xff290242, 0xc83396ce, 0x7e670471, 681 }, - { 0x9f79a169, 0xbd203e41, 0x0f0062c6, 685 }, - { 0xc75809c4, 0x2c684dd1, 0x52c07b78, 688 }, - { 0xf92e0c35, 0x37826145, 0xa7709a56, 691 }, - { 0x9bbcc7a1, 0x42b17ccb, 0x88a66076, 695 }, - { 0xc2abf989, 0x935ddbfe, 0x6acff893, 698 }, - { 0xf356f7eb, 0xf83552fe, 0x0583f6b8, 701 }, - { 0x98165af3, 0x7b2153de, 0xc3727a33, 705 }, - { 0xbe1bf1b0, 0x59e9a8d6, 0x744f18c0, 708 }, - { 0xeda2ee1c, 0x7064130c, 0x1162def0, 711 }, - { 0x9485d4d1, 0xc63e8be7, 0x8addcb56, 715 }, - { 0xb9a74a06, 0x37ce2ee1, 0x6d953e2b, 718 }, - { 0xe8111c87, 0xc5c1ba99, 0xc8fa8db6, 721 }, - { 0x910ab1d4, 0xdb9914a0, 0x1d9c9892, 725 }, - { 0xb54d5e4a, 0x127f59c8, 0x2503beb6, 728 }, - { 0xe2a0b5dc, 0x971f303a, 0x2e44ae64, 731 }, - { 0x8da471a9, 0xde737e24, 0x5ceaecfe, 735 }, - { 0xb10d8e14, 0x56105dad, 0x7425a83e, 738 }, - { 0xdd50f199, 0x6b947518, 0xd12f124e, 741 }, - { 0x8a5296ff, 0xe33cc92f, 0x82bd6b70, 745 }, - { 0xace73cbf, 0xdc0bfb7b, 0x636cc64d, 748 }, - { 0xd8210bef, 0xd30efa5a, 0x3c47f7e0, 751 }, - { 0x8714a775, 0xe3e95c78, 0x65acfaec, 755 }, - { 0xa8d9d153, 0x5ce3b396, 0x7f1839a7, 758 }, - { 0xd31045a8, 0x341ca07c, 0x1ede4811, 761 }, - { 0x83ea2b89, 0x2091e44d, 0x934aed0a, 765 }, - { 0xa4e4b66b, 0x68b65d60, 0xf81da84d, 768 }, - { 0xce1de406, 0x42e3f4b9, 0x36251260, 771 }, - { 0x80d2ae83, 0xe9ce78f3, 0xc1d72b7c, 775 }, - { 0xa1075a24, 0xe4421730, 0xb24cf65b, 778 }, - { 0xc94930ae, 0x1d529cfc, 0xdee033f2, 781 }, - { 0xfb9b7cd9, 0xa4a7443c, 0x169840ef, 784 }, - { 0x9d412e08, 0x06e88aa5, 0x8e1f2895, 788 }, - { 0xc491798a, 0x08a2ad4e, 0xf1a6f2ba, 791 }, - { 0xf5b5d7ec, 0x8acb58a2, 0xae10af69, 794 }, - { 0x9991a6f3, 0xd6bf1765, 0xacca6da1, 798 }, - { 0xbff610b0, 0xcc6edd3f, 0x17fd090a, 801 }, - { 0xeff394dc, 0xff8a948e, 0xddfc4b4c, 804 }, - { 0x95f83d0a, 0x1fb69cd9, 0x4abdaf10, 808 }, - { 0xbb764c4c, 0xa7a4440f, 0x9d6d1ad4, 811 }, - { 0xea53df5f, 0xd18d5513, 0x84c86189, 814 }, - { 0x92746b9b, 0xe2f8552c, 0x32fd3cf5, 818 }, - { 0xb7118682, 0xdbb66a77, 0x3fbc8c33, 821 }, - { 0xe4d5e823, 0x92a40515, 0x0fabaf3f, 824 }, - { 0x8f05b116, 0x3ba6832d, 0x29cb4d87, 828 }, - { 0xb2c71d5b, 0xca9023f8, 0x743e20e9, 831 }, - { 0xdf78e4b2, 0xbd342cf6, 0x914da924, 834 }, - { 0x8bab8eef, 0xb6409c1a, 0x1ad089b6, 838 }, - { 0xae9672ab, 0xa3d0c320, 0xa184ac24, 841 }, - { 0xda3c0f56, 0x8cc4f3e8, 0xc9e5d72d, 844 }, - { 0x88658996, 0x17fb1871, 0x7e2fa67c, 848 }, - { 0xaa7eebfb, 0x9df9de8d, 0xddbb901b, 851 }, - { 0xd51ea6fa, 0x85785631, 0x552a7422, 854 }, - { 0x8533285c, 0x936b35de, 0xd53a8895, 858 }, - { 0xa67ff273, 0xb8460356, 0x8a892aba, 861 }, - { 0xd01fef10, 0xa657842c, 0x2d2b7569, 864 }, - { 0x8213f56a, 0x67f6b29b, 0x9c3b2962, 868 }, - { 0xa298f2c5, 0x01f45f42, 0x8349f3ba, 871 }, - { 0xcb3f2f76, 0x42717713, 0x241c70a9, 874 }, - { 0xfe0efb53, 0xd30dd4d7, 0xed238cd3, 877 }, - { 0x9ec95d14, 0x63e8a506, 0xf4363804, 881 }, - { 0xc67bb459, 0x7ce2ce48, 0xb143c605, 884 }, - { 0xf81aa16f, 0xdc1b81da, 0xdd94b786, 887 }, - { 0x9b10a4e5, 0xe9913128, 0xca7cf2b4, 891 }, - { 0xc1d4ce1f, 0x63f57d72, 0xfd1c2f61, 894 }, - { 0xf24a01a7, 0x3cf2dccf, 0xbc633b39, 897 }, - { 0x976e4108, 0x8617ca01, 0xd5be0503, 901 }, - { 0xbd49d14a, 0xa79dbc82, 0x4b2d8644, 904 }, - { 0xec9c459d, 0x51852ba2, 0xddf8e7d6, 907 }, - { 0x93e1ab82, 0x52f33b45, 0xcabb90e5, 911 }, - { 0xb8da1662, 0xe7b00a17, 0x3d6a751f, 914 }, - { 0xe7109bfb, 0xa19c0c9d, 0x0cc51267, 917 }, - { 0x906a617d, 0x450187e2, 0x27fb2b80, 921 }, - { 0xb484f9dc, 0x9641e9da, 0xb1f9f660, 924 }, - { 0xe1a63853, 0xbbd26451, 0x5e7873f8, 927 }, - { 0x8d07e334, 0x55637eb2, 0xdb0b487b, 931 }, - { 0xb049dc01, 0x6abc5e5f, 0x91ce1a9a, 934 }, - { 0xdc5c5301, 0xc56b75f7, 0x7641a140, 937 }, - { 0x89b9b3e1, 0x1b6329ba, 0xa9e904c8, 941 }, - { 0xac2820d9, 0x623bf429, 0x546345fa, 944 }, - { 0xd732290f, 0xbacaf133, 0xa97c1779, 947 }, - { 0x867f59a9, 0xd4bed6c0, 0x49ed8eab, 951 }, - { 0xa81f3014, 0x49ee8c70, 0x5c68f256, 954 }, - { 0xd226fc19, 0x5c6a2f8c, 0x73832eec, 957 }, - { 0x83585d8f, 0xd9c25db7, 0xc831fd53, 961 }, - { 0xa42e74f3, 0xd032f525, 0xba3e7ca8, 964 }, - { 0xcd3a1230, 0xc43fb26f, 0x28ce1bd2, 967 }, - { 0x80444b5e, 0x7aa7cf85, 0x7980d163, 971 }, - { 0xa0555e36, 0x1951c366, 0xd7e105bc, 974 }, - { 0xc86ab5c3, 0x9fa63440, 0x8dd9472b, 977 }, - { 0xfa856334, 0x878fc150, 0xb14f98f6, 980 }, - { 0x9c935e00, 0xd4b9d8d2, 0x6ed1bf9a, 984 }, - { 0xc3b83581, 0x09e84f07, 0x0a862f80, 987 }, - { 0xf4a642e1, 0x4c6262c8, 0xcd27bb61, 990 }, - { 0x98e7e9cc, 0xcfbd7dbd, 0x8038d51c, 994 }, - { 0xbf21e440, 0x03acdd2c, 0xe0470a63, 997 }, - { 0xeeea5d50, 0x04981478, 0x1858ccfc, 1000 }, - { 0x95527a52, 0x02df0ccb, 0x0f37801e, 1004 }, - { 0xbaa718e6, 0x8396cffd, 0xd3056025, 1007 }, - { 0xe950df20, 0x247c83fd, 0x47c6b82e, 1010 }, - { 0x91d28b74, 0x16cdd27e, 0x4cdc331d, 1014 }, - { 0xb6472e51, 0x1c81471d, 0xe0133fe4, 1017 }, - { 0xe3d8f9e5, 0x63a198e5, 0x58180fdd, 1020 }, - { 0x8e679c2f, 0x5e44ff8f, 0x570f09ea, 1024 }, - { 0xb201833b, 0x35d63f73, 0x2cd2cc65, 1027 }, - { 0xde81e40a, 0x034bcf4f, 0xf8077f7e, 1030 }, - { 0x8b112e86, 0x420f6191, 0xfb04afaf, 1034 }, - { 0xadd57a27, 0xd29339f6, 0x79c5db9a, 1037 }, - { 0xd94ad8b1, 0xc7380874, 0x18375281, 1040 }, - { 0x87cec76f, 0x1c830548, 0x8f229391, 1044 }, - { 0xa9c2794a, 0xe3a3c69a, 0xb2eb3875, 1047 }, - { 0xd433179d, 0x9c8cb841, 0x5fa60692, 1050 }, - { 0x849feec2, 0x81d7f328, 0xdbc7c41b, 1054 }, - { 0xa5c7ea73, 0x224deff3, 0x12b9b522, 1057 }, - { 0xcf39e50f, 0xeae16bef, 0xd768226b, 1060 }, - { 0x81842f29, 0xf2cce375, 0xe6a11583, 1064 }, - { 0xa1e53af4, 0x6f801c53, 0x60495ae3, 1067 }, - { 0xca5e89b1, 0x8b602368, 0x385bb19c, 1070 }, - { 0xfcf62c1d, 0xee382c42, 0x46729e03, 1073 }, - { 0x9e19db92, 0xb4e31ba9, 0x6c07a2c2, 1077 } - }; - static short int Lhint[2098] = { - /*18,*/19, 19, 19, 19, 20, 20, 20, 21, 21, - 21, 22, 22, 22, 23, 23, 23, 23, 24, 24, - 24, 25, 25, 25, 26, 26, 26, 26, 27, 27, - 27, 28, 28, 28, 29, 29, 29, 29, 30, 30, - 30, 31, 31, 31, 32, 32, 32, 32, 33, 33, - 33, 34, 34, 34, 35, 35, 35, 35, 36, 36, - 36, 37, 37, 37, 38, 38, 38, 38, 39, 39, - 39, 40, 40, 40, 41, 41, 41, 41, 42, 42, - 42, 43, 43, 43, 44, 44, 44, 44, 45, 45, - 45, 46, 46, 46, 47, 47, 47, 47, 48, 48, - 48, 49, 49, 49, 50, 50, 50, 51, 51, 51, - 51, 52, 52, 52, 53, 53, 53, 54, 54, 54, - 54, 55, 55, 55, 56, 56, 56, 57, 57, 57, - 57, 58, 58, 58, 59, 59, 59, 60, 60, 60, - 60, 61, 61, 61, 62, 62, 62, 63, 63, 63, - 63, 64, 64, 64, 65, 65, 65, 66, 66, 66, - 66, 67, 67, 67, 68, 68, 68, 69, 69, 69, - 69, 70, 70, 70, 71, 71, 71, 72, 72, 72, - 72, 73, 73, 73, 74, 74, 74, 75, 75, 75, - 75, 76, 76, 76, 77, 77, 77, 78, 78, 78, - 78, 79, 79, 79, 80, 80, 80, 81, 81, 81, - 82, 82, 82, 82, 83, 83, 83, 84, 84, 84, - 85, 85, 85, 85, 86, 86, 86, 87, 87, 87, - 88, 88, 88, 88, 89, 89, 89, 90, 90, 90, - 91, 91, 91, 91, 92, 92, 92, 93, 93, 93, - 94, 94, 94, 94, 95, 95, 95, 96, 96, 96, - 97, 97, 97, 97, 98, 98, 98, 99, 99, 99, - 100, 100, 100, 100, 101, 101, 101, 102, 102, 102, - 103, 103, 103, 103, 104, 104, 104, 105, 105, 105, - 106, 106, 106, 106, 107, 107, 107, 108, 108, 108, - 109, 109, 109, 110, 110, 110, 110, 111, 111, 111, - 112, 112, 112, 113, 113, 113, 113, 114, 114, 114, - 115, 115, 115, 116, 116, 116, 116, 117, 117, 117, - 118, 118, 118, 119, 119, 119, 119, 120, 120, 120, - 121, 121, 121, 122, 122, 122, 122, 123, 123, 123, - 124, 124, 124, 125, 125, 125, 125, 126, 126, 126, - 127, 127, 127, 128, 128, 128, 128, 129, 129, 129, - 130, 130, 130, 131, 131, 131, 131, 132, 132, 132, - 133, 133, 133, 134, 134, 134, 134, 135, 135, 135, - 136, 136, 136, 137, 137, 137, 137, 138, 138, 138, - 139, 139, 139, 140, 140, 140, 141, 141, 141, 141, - 142, 142, 142, 143, 143, 143, 144, 144, 144, 144, - 145, 145, 145, 146, 146, 146, 147, 147, 147, 147, - 148, 148, 148, 149, 149, 149, 150, 150, 150, 150, - 151, 151, 151, 152, 152, 152, 153, 153, 153, 153, - 154, 154, 154, 155, 155, 155, 156, 156, 156, 156, - 157, 157, 157, 158, 158, 158, 159, 159, 159, 159, - 160, 160, 160, 161, 161, 161, 162, 162, 162, 162, - 163, 163, 163, 164, 164, 164, 165, 165, 165, 165, - 166, 166, 166, 167, 167, 167, 168, 168, 168, 169, - 169, 169, 169, 170, 170, 170, 171, 171, 171, 172, - 172, 172, 172, 173, 173, 173, 174, 174, 174, 175, - 175, 175, 175, 176, 176, 176, 177, 177, 177, 178, - 178, 178, 178, 179, 179, 179, 180, 180, 180, 181, - 181, 181, 181, 182, 182, 182, 183, 183, 183, 184, - 184, 184, 184, 185, 185, 185, 186, 186, 186, 187, - 187, 187, 187, 188, 188, 188, 189, 189, 189, 190, - 190, 190, 190, 191, 191, 191, 192, 192, 192, 193, - 193, 193, 193, 194, 194, 194, 195, 195, 195, 196, - 196, 196, 197, 197, 197, 197, 198, 198, 198, 199, - 199, 199, 200, 200, 200, 200, 201, 201, 201, 202, - 202, 202, 203, 203, 203, 203, 204, 204, 204, 205, - 205, 205, 206, 206, 206, 206, 207, 207, 207, 208, - 208, 208, 209, 209, 209, 209, 210, 210, 210, 211, - 211, 211, 212, 212, 212, 212, 213, 213, 213, 214, - 214, 214, 215, 215, 215, 215, 216, 216, 216, 217, - 217, 217, 218, 218, 218, 218, 219, 219, 219, 220, - 220, 220, 221, 221, 221, 221, 222, 222, 222, 223, - 223, 223, 224, 224, 224, 224, 225, 225, 225, 226, - 226, 226, 227, 227, 227, 228, 228, 228, 228, 229, - 229, 229, 230, 230, 230, 231, 231, 231, 231, 232, - 232, 232, 233, 233, 233, 234, 234, 234, 234, 235, - 235, 235, 236, 236, 236, 237, 237, 237, 237, 238, - 238, 238, 239, 239, 239, 240, 240, 240, 240, 241, - 241, 241, 242, 242, 242, 243, 243, 243, 243, 244, - 244, 244, 245, 245, 245, 246, 246, 246, 246, 247, - 247, 247, 248, 248, 248, 249, 249, 249, 249, 250, - 250, 250, 251, 251, 251, 252, 252, 252, 252, 253, - 253, 253, 254, 254, 254, 255, 255, 255, 256, 256, - 256, 256, 257, 257, 257, 258, 258, 258, 259, 259, - 259, 259, 260, 260, 260, 261, 261, 261, 262, 262, - 262, 262, 263, 263, 263, 264, 264, 264, 265, 265, - 265, 265, 266, 266, 266, 267, 267, 267, 268, 268, - 268, 268, 269, 269, 269, 270, 270, 270, 271, 271, - 271, 271, 272, 272, 272, 273, 273, 273, 274, 274, - 274, 274, 275, 275, 275, 276, 276, 276, 277, 277, - 277, 277, 278, 278, 278, 279, 279, 279, 280, 280, - 280, 280, 281, 281, 281, 282, 282, 282, 283, 283, - 283, 283, 284, 284, 284, 285, 285, 285, 286, 286, - 286, 287, 287, 287, 287, 288, 288, 288, 289, 289, - 289, 290, 290, 290, 290, 291, 291, 291, 292, 292, - 292, 293, 293, 293, 293, 294, 294, 294, 295, 295, - 295, 296, 296, 296, 296, 297, 297, 297, 298, 298, - 298, 299, 299, 299, 299, 300, 300, 300, 301, 301, - 301, 302, 302, 302, 302, 303, 303, 303, 304, 304, - 304, 305, 305, 305, 305, 306, 306, 306, 307, 307, - 307, 308, 308, 308, 308, 309, 309, 309, 310, 310, - 310, 311, 311, 311, 311, 312, 312, 312, 313, 313, - 313, 314, 314, 314, 315, 315, 315, 315, 316, 316, - 316, 317, 317, 317, 318, 318, 318, 318, 319, 319, - 319, 320, 320, 320, 321, 321, 321, 321, 322, 322, - 322, 323, 323, 323, 324, 324, 324, 324, 325, 325, - 325, 326, 326, 326, 327, 327, 327, 327, 328, 328, - 328, 329, 329, 329, 330, 330, 330, 330, 331, 331, - 331, 332, 332, 332, 333, 333, 333, 333, 334, 334, - 334, 335, 335, 335, 336, 336, 336, 336, 337, 337, - 337, 338, 338, 338, 339, 339, 339, 339, 340, 340, - 340, 341, 341, 341, 342, 342, 342, 342, 343, 343, - 343, 344, 344, 344, 345, 345, 345, 346, 346, 346, - 346, 347, 347, 347, 348, 348, 348, 349, 349, 349, - 349, 350, 350, 350, 351, 351, 351, 352, 352, 352, - 352, 353, 353, 353, 354, 354, 354, 355, 355, 355, - 355, 356, 356, 356, 357, 357, 357, 358, 358, 358, - 358, 359, 359, 359, 360, 360, 360, 361, 361, 361, - 361, 362, 362, 362, 363, 363, 363, 364, 364, 364, - 364, 365, 365, 365, 366, 366, 366, 367, 367, 367, - 367, 368, 368, 368, 369, 369, 369, 370, 370, 370, - 370, 371, 371, 371, 372, 372, 372, 373, 373, 373, - 374, 374, 374, 374, 375, 375, 375, 376, 376, 376, - 377, 377, 377, 377, 378, 378, 378, 379, 379, 379, - 380, 380, 380, 380, 381, 381, 381, 382, 382, 382, - 383, 383, 383, 383, 384, 384, 384, 385, 385, 385, - 386, 386, 386, 386, 387, 387, 387, 388, 388, 388, - 389, 389, 389, 389, 390, 390, 390, 391, 391, 391, - 392, 392, 392, 392, 393, 393, 393, 394, 394, 394, - 395, 395, 395, 395, 396, 396, 396, 397, 397, 397, - 398, 398, 398, 398, 399, 399, 399, 400, 400, 400, - 401, 401, 401, 402, 402, 402, 402, 403, 403, 403, - 404, 404, 404, 405, 405, 405, 405, 406, 406, 406, - 407, 407, 407, 408, 408, 408, 408, 409, 409, 409, - 410, 410, 410, 411, 411, 411, 411, 412, 412, 412, - 413, 413, 413, 414, 414, 414, 414, 415, 415, 415, - 416, 416, 416, 417, 417, 417, 417, 418, 418, 418, - 419, 419, 419, 420, 420, 420, 420, 421, 421, 421, - 422, 422, 422, 423, 423, 423, 423, 424, 424, 424, - 425, 425, 425, 426, 426, 426, 426, 427, 427, 427, - 428, 428, 428, 429, 429, 429, 429, 430, 430, 430, - 431, 431, 431, 432, 432, 432, 433, 433, 433, 433, - 434, 434, 434, 435, 435, 435, 436, 436, 436, 436, - 437, 437, 437, 438, 438, 438, 439, 439, 439, 439, - 440, 440, 440, 441, 441, 441, 442, 442, 442, 442, - 443, 443, 443, 444, 444, 444, 445, 445, 445, 445, - 446, 446, 446, 447, 447, 447, 448, 448, 448, 448, - 449, 449, 449, 450, 450, 450, 451, 451, 451, 451, - 452, 452, 452, 453, 453, 453, 454, 454, 454, 454, - 455, 455, 455, 456, 456, 456, 457, 457, 457, 457, - 458, 458, 458, 459, 459, 459, 460, 460, 460, 461, - 461, 461, 461, 462, 462, 462, 463, 463, 463, 464, - 464, 464, 464, 465, 465, 465, 466, 466, 466, 467, - 467, 467, 467, 468, 468, 468, 469, 469, 469, 470, - 470, 470, 470, 471, 471, 471, 472, 472, 472, 473, - 473, 473, 473, 474, 474, 474, 475, 475, 475, 476, - 476, 476, 476, 477, 477, 477, 478, 478, 478, 479, - 479, 479, 479, 480, 480, 480, 481, 481, 481, 482, - 482, 482, 482, 483, 483, 483, 484, 484, 484, 485, - 485, 485, 485, 486, 486, 486, 487, 487, 487, 488, - 488, 488, 488, 489, 489, 489, 490, 490, 490, 491, - 491, 491, 492, 492, 492, 492, 493, 493, 493, 494, - 494, 494, 495, 495, 495, 495, 496, 496, 496, 497, - 497, 497, 498, 498, 498, 498, 499, 499, 499, 500, - 500, 500, 501, 501, 501, 501, 502, 502, 502, 503, - 503, 503, 504, 504, 504, 504, 505, 505, 505, 506, - 506, 506, 507, 507, 507, 507, 508, 508, 508, 509, - 509, 509, 510, 510, 510, 510, 511, 511, 511, 512, - 512, 512, 513, 513, 513, 513, 514, 514, 514, 515, - 515, 515, 516, 516, 516, 516, 517, 517, 517, 518, - 518, 518, 519, 519, 519, 520, 520, 520, 520, 521, - 521, 521, 522, 522, 522, 523, 523, 523, 523, 524, - 524, 524, 525, 525, 525, 526, 526, 526, 526, 527, - 527, 527, 528, 528, 528, 529, 529, 529, 529, 530, - 530, 530, 531, 531, 531, 532, 532, 532, 532, 533, - 533, 533, 534, 534, 534, 535, 535, 535, 535, 536, - 536, 536, 537, 537, 537, 538, 538, 538, 538, 539, - 539, 539, 540, 540, 540, 541, 541, 541, 541, 542, - 542, 542, 543, 543, 543, 544, 544, 544, 544, 545, - 545, 545, 546, 546, 546, 547, 547, 547, 548, 548, - 548, 548, 549, 549, 549, 550, 550, 550, 551, 551, - 551, 551, 552, 552, 552, 553, 553, 553, 554, 554, - 554, 554, 555, 555, 555, 556, 556, 556, 557, 557, - 557, 557, 558, 558, 558, 559, 559, 559, 560, 560, - 560, 560, 561, 561, 561, 562, 562, 562, 563, 563, - 563, 563, 564, 564, 564, 565, 565, 565, 566, 566, - 566, 566, 567, 567, 567, 568, 568, 568, 569, 569, - 569, 569, 570, 570, 570, 571, 571, 571, 572, 572, - 572, 572, 573, 573, 573, 574, 574, 574, 575, 575, - 575, 575, 576, 576, 576, 577, 577, 577, 578, 578, - 578, 579, 579, 579, 579, 580, 580, 580, 581, 581, - 581, 582, 582, 582, 582, 583, 583, 583, 584, 584, - 584, 585, 585, 585, 585, 586, 586, 586, 587, 587, - 587, 588, 588, 588, 588, 589, 589, 589, 590, 590, - 590, 591, 591, 591, 591, 592, 592, 592, 593, 593, - 593, 594, 594, 594, 594, 595, 595, 595, 596, 596, - 596, 597, 597, 597, 597, 598, 598, 598, 599, 599, - 599, 600, 600, 600, 600, 601, 601, 601, 602, 602, - 602, 603, 603, 603, 603, 604, 604, 604, 605, 605, - 605, 606, 606, 606, 607, 607, 607, 607, 608, 608, - 608, 609, 609, 609, 610, 610, 610, 610, 611, 611, - 611, 612, 612, 612, 613, 613, 613, 613, 614, 614, - 614, 615, 615, 615, 616, 616, 616, 616, 617, 617, - 617, 618, 618, 618, 619, 619, 619, 619, 620, 620, - 620, 621, 621, 621, 622, 622, 622, 622, 623, 623, - 623, 624, 624, 624, 625, 625, 625, 625, 626, 626, - 626, 627, 627, 627, 628, 628, 628, 628, 629, 629, - 629, 630, 630, 630, 631, 631, 631, 631, 632, 632, - 632, 633, 633, 633, 634, 634, 634, 634, 635, 635, - 635, 636, 636, 636, 637, 637, 637, 638, 638, 638, - 638, 639, 639, 639, 640, 640, 640, 641, 641, 641, - 641, 642, 642, 642, 643, 643, 643, 644, 644, 644, - 644, 645, 645, 645, 646, 646, 646, 647, 647, 647, - 647, 648, 648, 648, 649, 649, 649, 650, 650 }; - static ULLong pfive[27] = { - 5ll, - 25ll, - 125ll, - 625ll, - 3125ll, - 15625ll, - 78125ll, - 390625ll, - 1953125ll, - 9765625ll, - 48828125ll, - 244140625ll, - 1220703125ll, - 6103515625ll, - 30517578125ll, - 152587890625ll, - 762939453125ll, - 3814697265625ll, - 19073486328125ll, - 95367431640625ll, - 476837158203125ll, - 2384185791015625ll, - 11920928955078125ll, - 59604644775390625ll, - 298023223876953125ll, - 1490116119384765625ll, - 7450580596923828125ll - }; - - static int pfivebits[25] = {3, 5, 7, 10, 12, 14, 17, 19, 21, 24, 26, 28, 31, - 33, 35, 38, 40, 42, 45, 47, 49, 52, 54, 56, 59}; -#endif /*}*/ -#endif /*}} NO_LONG_LONG */ - -typedef union { double d; ULong L[2]; -#ifdef USE_BF96 - ULLong LL; -#endif - } U; - -#ifdef IEEE_8087 -#define word0(x) (x)->L[1] -#define word1(x) (x)->L[0] -#else -#define word0(x) (x)->L[0] -#define word1(x) (x)->L[1] -#endif -#define dval(x) (x)->d -#define LLval(x) (x)->LL - -#ifndef STRTOD_DIGLIM -#define STRTOD_DIGLIM 40 -#endif - -#ifdef DIGLIM_DEBUG -extern int strtod_diglim; -#else -#define strtod_diglim STRTOD_DIGLIM -#endif - -/* The following definition of Storeinc is appropriate for MIPS processors. - * An alternative that might be better on some machines is - * #define Storeinc(a,b,c) (*a++ = b << 16 | c & 0xffff) - */ -#if defined(IEEE_8087) + defined(VAX) -#define Storeinc(a,b,c) (((unsigned short *)a)[1] = (unsigned short)b, \ -((unsigned short *)a)[0] = (unsigned short)c, a++) -#else -#define Storeinc(a,b,c) (((unsigned short *)a)[0] = (unsigned short)b, \ -((unsigned short *)a)[1] = (unsigned short)c, a++) -#endif - -/* #define P DBL_MANT_DIG */ -/* Ten_pmax = floor(P*log(2)/log(5)) */ -/* Bletch = (highest power of 2 < DBL_MAX_10_EXP) / 16 */ -/* Quick_max = floor((P-1)*log(FLT_RADIX)/log(10) - 1) */ -/* Int_max = floor(P*log(FLT_RADIX)/log(10) - 1) */ - -#ifdef IEEE_Arith -#define Exp_shift 20 -#define Exp_shift1 20 -#define Exp_msk1 0x100000 -#define Exp_msk11 0x100000 -#define Exp_mask 0x7ff00000 -#define P 53 -#define Nbits 53 -#define Bias 1023 -#define Emax 1023 -#define Emin (-1022) -#define Exp_1 0x3ff00000 -#define Exp_11 0x3ff00000 -#define Ebits 11 -#define Frac_mask 0xfffff -#define Frac_mask1 0xfffff -#define Ten_pmax 22 -#define Bletch 0x10 -#define Bndry_mask 0xfffff -#define Bndry_mask1 0xfffff -#define LSB 1 -#define Sign_bit 0x80000000 -#define Log2P 1 -#define Tiny0 0 -#define Tiny1 1 -#define Quick_max 14 -#define Int_max 14 -#ifndef NO_IEEE_Scale -#define Avoid_Underflow -#ifdef Flush_Denorm /* debugging option */ -#undef Sudden_Underflow -#endif -#endif - -#ifndef Flt_Rounds -#ifdef FLT_ROUNDS -#define Flt_Rounds FLT_ROUNDS -#else -#define Flt_Rounds 1 -#endif -#endif /*Flt_Rounds*/ - -#ifdef Honor_FLT_ROUNDS -#undef Check_FLT_ROUNDS -#define Check_FLT_ROUNDS -#else -#define Rounding Flt_Rounds -#endif - -#else /* ifndef IEEE_Arith */ -#undef Check_FLT_ROUNDS -#undef Honor_FLT_ROUNDS -#undef SET_INEXACT -#undef Sudden_Underflow -#define Sudden_Underflow -#ifdef IBM -#undef Flt_Rounds -#define Flt_Rounds 0 -#define Exp_shift 24 -#define Exp_shift1 24 -#define Exp_msk1 0x1000000 -#define Exp_msk11 0x1000000 -#define Exp_mask 0x7f000000 -#define P 14 -#define Nbits 56 -#define Bias 65 -#define Emax 248 -#define Emin (-260) -#define Exp_1 0x41000000 -#define Exp_11 0x41000000 -#define Ebits 8 /* exponent has 7 bits, but 8 is the right value in b2d */ -#define Frac_mask 0xffffff -#define Frac_mask1 0xffffff -#define Bletch 4 -#define Ten_pmax 22 -#define Bndry_mask 0xefffff -#define Bndry_mask1 0xffffff -#define LSB 1 -#define Sign_bit 0x80000000 -#define Log2P 4 -#define Tiny0 0x100000 -#define Tiny1 0 -#define Quick_max 14 -#define Int_max 15 -#else /* VAX */ -#undef Flt_Rounds -#define Flt_Rounds 1 -#define Exp_shift 23 -#define Exp_shift1 7 -#define Exp_msk1 0x80 -#define Exp_msk11 0x800000 -#define Exp_mask 0x7f80 -#define P 56 -#define Nbits 56 -#define Bias 129 -#define Emax 126 -#define Emin (-129) -#define Exp_1 0x40800000 -#define Exp_11 0x4080 -#define Ebits 8 -#define Frac_mask 0x7fffff -#define Frac_mask1 0xffff007f -#define Ten_pmax 24 -#define Bletch 2 -#define Bndry_mask 0xffff007f -#define Bndry_mask1 0xffff007f -#define LSB 0x10000 -#define Sign_bit 0x8000 -#define Log2P 1 -#define Tiny0 0x80 -#define Tiny1 0 -#define Quick_max 15 -#define Int_max 15 -#endif /* IBM, VAX */ -#endif /* IEEE_Arith */ - -#ifndef IEEE_Arith -#define ROUND_BIASED -#else -#ifdef ROUND_BIASED_without_Round_Up -#undef ROUND_BIASED -#define ROUND_BIASED -#endif -#endif - -#ifdef RND_PRODQUOT -#define rounded_product(a,b) a = rnd_prod(a, b) -#define rounded_quotient(a,b) a = rnd_quot(a, b) -extern double rnd_prod(double, double), rnd_quot(double, double); -#else -#define rounded_product(a,b) a *= b -#define rounded_quotient(a,b) a /= b -#endif - -#define Big0 (Frac_mask1 | Exp_msk1*(DBL_MAX_EXP+Bias-1)) -#define Big1 0xffffffff - -#ifndef Pack_32 -#define Pack_32 -#endif - -typedef struct BCinfo BCinfo; - struct -BCinfo { int dp0, dp1, dplen, dsign, e0, inexact, nd, nd0, rounding, scale, uflchk; }; - -#define FFFFFFFF 0xffffffffUL - -#ifdef MULTIPLE_THREADS -#define MTa , PTI -#define MTb , &TI -#define MTd , ThInfo **PTI -static unsigned int maxthreads = 0; -#else -#define MTa /*nothing*/ -#define MTb /*nothing*/ -#define MTd /*nothing*/ -#endif - -#define Kmax 7 - -#ifdef __cplusplus -extern "C" double strtod(const char *s00, char **se); -extern "C" char *dtoa(double d, int mode, int ndigits, - int *decpt, int *sign, char **rve); -#endif - - struct -Bigint { - struct Bigint *next; - int k, maxwds, sign, wds; - ULong x[1]; - }; - - typedef struct Bigint Bigint; - typedef struct -ThInfo { - Bigint *Freelist[Kmax+1]; - Bigint *P5s; - } ThInfo; - - static ThInfo TI0; - -#ifdef MULTIPLE_THREADS - static ThInfo *TI1; - static int TI0_used; - - void -set_max_dtoa_threads(unsigned int n) -{ - size_t L; - - if (n > maxthreads) { - L = n*sizeof(ThInfo); - if (TI1) { - TI1 = (ThInfo*)REALLOC(TI1, L); - memset(TI1 + maxthreads, 0, (n-maxthreads)*sizeof(ThInfo)); - } - else { - TI1 = (ThInfo*)MALLOC(L); - if (TI0_used) { - memcpy(TI1, &TI0, sizeof(ThInfo)); - if (n > 1) - memset(TI1 + 1, 0, L - sizeof(ThInfo)); - memset(&TI0, 0, sizeof(ThInfo)); - } - else - memset(TI1, 0, L); - } - maxthreads = n; - } - } - - static ThInfo* -get_TI(void) -{ - unsigned int thno = dtoa_get_threadno(); - if (thno < maxthreads) - return TI1 + thno; - if (thno == 0) - TI0_used = 1; - return &TI0; - } -#define freelist TI->Freelist -#define p5s TI->P5s -#else -#define freelist TI0.Freelist -#define p5s TI0.P5s -#endif - - static Bigint * -Balloc(int k MTd) -{ - int x; - Bigint *rv; -#ifndef Omit_Private_Memory - unsigned int len; -#endif -#ifdef MULTIPLE_THREADS - ThInfo *TI; - - if (!(TI = *PTI)) - *PTI = TI = get_TI(); - if (TI == &TI0) - ACQUIRE_DTOA_LOCK(0); -#endif - /* The k > Kmax case does not need ACQUIRE_DTOA_LOCK(0), */ - /* but this case seems very unlikely. */ - if (k <= Kmax && (rv = freelist[k])) - freelist[k] = rv->next; - else { - x = 1 << k; -#ifdef Omit_Private_Memory - rv = (Bigint *)MALLOC(sizeof(Bigint) + (x-1)*sizeof(ULong)); -#else - len = (sizeof(Bigint) + (x-1)*sizeof(ULong) + sizeof(double) - 1) - /sizeof(double); - if (k <= Kmax && pmem_next - private_mem + len <= PRIVATE_mem -#ifdef MULTIPLE_THREADS - && TI == TI1 -#endif - ) { - rv = (Bigint*)pmem_next; - pmem_next += len; - } - else - rv = (Bigint*)MALLOC(len*sizeof(double)); -#endif - rv->k = k; - rv->maxwds = x; - } -#ifdef MULTIPLE_THREADS - if (TI == &TI0) - FREE_DTOA_LOCK(0); -#endif - rv->sign = rv->wds = 0; - return rv; - } - - static void -Bfree(Bigint *v MTd) -{ -#ifdef MULTIPLE_THREADS - ThInfo *TI; -#endif - if (v) { - if (v->k > Kmax) - FREE((void*)v); - else { -#ifdef MULTIPLE_THREADS - if (!(TI = *PTI)) - *PTI = TI = get_TI(); - if (TI == &TI0) - ACQUIRE_DTOA_LOCK(0); -#endif - v->next = freelist[v->k]; - freelist[v->k] = v; -#ifdef MULTIPLE_THREADS - if (TI == &TI0) - FREE_DTOA_LOCK(0); -#endif - } - } - } - -#define Bcopy(x,y) memcpy((char *)&x->sign, (char *)&y->sign, \ -y->wds*sizeof(Long) + 2*sizeof(int)) - - static Bigint * -multadd(Bigint *b, int m, int a MTd) /* multiply by m and add a */ -{ - int i, wds; -#ifdef ULLong - ULong *x; - ULLong carry, y; -#else - ULong carry, *x, y; -#ifdef Pack_32 - ULong xi, z; -#endif -#endif - Bigint *b1; - - wds = b->wds; - x = b->x; - i = 0; - carry = a; - do { -#ifdef ULLong - y = *x * (ULLong)m + carry; - carry = y >> 32; - *x++ = y & FFFFFFFF; -#else -#ifdef Pack_32 - xi = *x; - y = (xi & 0xffff) * m + carry; - z = (xi >> 16) * m + (y >> 16); - carry = z >> 16; - *x++ = (z << 16) + (y & 0xffff); -#else - y = *x * m + carry; - carry = y >> 16; - *x++ = y & 0xffff; -#endif -#endif - } - while(++i < wds); - if (carry) { - if (wds >= b->maxwds) { - b1 = Balloc(b->k+1 MTa); - Bcopy(b1, b); - Bfree(b MTa); - b = b1; - } - b->x[wds++] = carry; - b->wds = wds; - } - return b; - } - - static Bigint * -s2b(const char *s, int nd0, int nd, ULong y9, int dplen MTd) -{ - Bigint *b; - int i, k; - Long x, y; - - x = (nd + 8) / 9; - for(k = 0, y = 1; x > y; y <<= 1, k++) ; -#ifdef Pack_32 - b = Balloc(k MTa); - b->x[0] = y9; - b->wds = 1; -#else - b = Balloc(k+1 MTa); - b->x[0] = y9 & 0xffff; - b->wds = (b->x[1] = y9 >> 16) ? 2 : 1; -#endif - - i = 9; - if (9 < nd0) { - s += 9; - do b = multadd(b, 10, *s++ - '0' MTa); - while(++i < nd0); - s += dplen; - } - else - s += dplen + 9; - for(; i < nd; i++) - b = multadd(b, 10, *s++ - '0' MTa); - return b; - } - - static int -hi0bits(ULong x) -{ - int k = 0; - - if (!(x & 0xffff0000)) { - k = 16; - x <<= 16; - } - if (!(x & 0xff000000)) { - k += 8; - x <<= 8; - } - if (!(x & 0xf0000000)) { - k += 4; - x <<= 4; - } - if (!(x & 0xc0000000)) { - k += 2; - x <<= 2; - } - if (!(x & 0x80000000)) { - k++; - if (!(x & 0x40000000)) - return 32; - } - return k; - } - - static int -lo0bits(ULong *y) -{ - int k; - ULong x = *y; - - if (x & 7) { - if (x & 1) - return 0; - if (x & 2) { - *y = x >> 1; - return 1; - } - *y = x >> 2; - return 2; - } - k = 0; - if (!(x & 0xffff)) { - k = 16; - x >>= 16; - } - if (!(x & 0xff)) { - k += 8; - x >>= 8; - } - if (!(x & 0xf)) { - k += 4; - x >>= 4; - } - if (!(x & 0x3)) { - k += 2; - x >>= 2; - } - if (!(x & 1)) { - k++; - x >>= 1; - if (!x) - return 32; - } - *y = x; - return k; - } - - static Bigint * -i2b(int i MTd) -{ - Bigint *b; - - b = Balloc(1 MTa); - b->x[0] = i; - b->wds = 1; - return b; - } - - static Bigint * -mult(Bigint *a, Bigint *b MTd) -{ - Bigint *c; - int k, wa, wb, wc; - ULong *x, *xa, *xae, *xb, *xbe, *xc, *xc0; - ULong y; -#ifdef ULLong - ULLong carry, z; -#else - ULong carry, z; -#ifdef Pack_32 - ULong z2; -#endif -#endif - - if (a->wds < b->wds) { - c = a; - a = b; - b = c; - } - k = a->k; - wa = a->wds; - wb = b->wds; - wc = wa + wb; - if (wc > a->maxwds) - k++; - c = Balloc(k MTa); - for(x = c->x, xa = x + wc; x < xa; x++) - *x = 0; - xa = a->x; - xae = xa + wa; - xb = b->x; - xbe = xb + wb; - xc0 = c->x; -#ifdef ULLong - for(; xb < xbe; xc0++) { - if ((y = *xb++)) { - x = xa; - xc = xc0; - carry = 0; - do { - z = *x++ * (ULLong)y + *xc + carry; - carry = z >> 32; - *xc++ = z & FFFFFFFF; - } - while(x < xae); - *xc = carry; - } - } -#else -#ifdef Pack_32 - for(; xb < xbe; xb++, xc0++) { - if ((y = *xb & 0xffff)) { - x = xa; - xc = xc0; - carry = 0; - do { - z = (*x & 0xffff) * y + (*xc & 0xffff) + carry; - carry = z >> 16; - z2 = (*x++ >> 16) * y + (*xc >> 16) + carry; - carry = z2 >> 16; - Storeinc(xc, z2, z); - } - while(x < xae); - *xc = carry; - } - if ((y = *xb >> 16)) { - x = xa; - xc = xc0; - carry = 0; - z2 = *xc; - do { - z = (*x & 0xffff) * y + (*xc >> 16) + carry; - carry = z >> 16; - Storeinc(xc, z, z2); - z2 = (*x++ >> 16) * y + (*xc & 0xffff) + carry; - carry = z2 >> 16; - } - while(x < xae); - *xc = z2; - } - } -#else - for(; xb < xbe; xc0++) { - if (y = *xb++) { - x = xa; - xc = xc0; - carry = 0; - do { - z = *x++ * y + *xc + carry; - carry = z >> 16; - *xc++ = z & 0xffff; - } - while(x < xae); - *xc = carry; - } - } -#endif -#endif - for(xc0 = c->x, xc = xc0 + wc; wc > 0 && !*--xc; --wc) ; - c->wds = wc; - return c; - } - - static Bigint * -pow5mult(Bigint *b, int k MTd) -{ - Bigint *b1, *p5, *p51; -#ifdef MULTIPLE_THREADS - ThInfo *TI; -#endif - int i; - static int p05[3] = { 5, 25, 125 }; - - if ((i = k & 3)) - b = multadd(b, p05[i-1], 0 MTa); - - if (!(k >>= 2)) - return b; -#ifdef MULTIPLE_THREADS - if (!(TI = *PTI)) - *PTI = TI = get_TI(); -#endif - if (!(p5 = p5s)) { - /* first time */ -#ifdef MULTIPLE_THREADS - if (!(TI = *PTI)) - *PTI = TI = get_TI(); - if (TI == &TI0) - ACQUIRE_DTOA_LOCK(1); - if (!(p5 = p5s)) { - p5 = p5s = i2b(625 MTa); - p5->next = 0; - } - if (TI == &TI0) - FREE_DTOA_LOCK(1); -#else - p5 = p5s = i2b(625 MTa); - p5->next = 0; -#endif - } - for(;;) { - if (k & 1) { - b1 = mult(b, p5 MTa); - Bfree(b MTa); - b = b1; - } - if (!(k >>= 1)) - break; - if (!(p51 = p5->next)) { -#ifdef MULTIPLE_THREADS - if (!TI && !(TI = *PTI)) - *PTI = TI = get_TI(); - if (TI == &TI0) - ACQUIRE_DTOA_LOCK(1); - if (!(p51 = p5->next)) { - p51 = p5->next = mult(p5,p5 MTa); - p51->next = 0; - } - if (TI == &TI0) - FREE_DTOA_LOCK(1); -#else - p51 = p5->next = mult(p5,p5); - p51->next = 0; -#endif - } - p5 = p51; - } - return b; - } - - static Bigint * -lshift(Bigint *b, int k MTd) -{ - int i, k1, n, n1; - Bigint *b1; - ULong *x, *x1, *xe, z; - -#ifdef Pack_32 - n = k >> 5; -#else - n = k >> 4; -#endif - k1 = b->k; - n1 = n + b->wds + 1; - for(i = b->maxwds; n1 > i; i <<= 1) - k1++; - b1 = Balloc(k1 MTa); - x1 = b1->x; - for(i = 0; i < n; i++) - *x1++ = 0; - x = b->x; - xe = x + b->wds; -#ifdef Pack_32 - if (k &= 0x1f) { - k1 = 32 - k; - z = 0; - do { - *x1++ = *x << k | z; - z = *x++ >> k1; - } - while(x < xe); - if ((*x1 = z)) - ++n1; - } -#else - if (k &= 0xf) { - k1 = 16 - k; - z = 0; - do { - *x1++ = *x << k & 0xffff | z; - z = *x++ >> k1; - } - while(x < xe); - if (*x1 = z) - ++n1; - } -#endif - else do - *x1++ = *x++; - while(x < xe); - b1->wds = n1 - 1; - Bfree(b MTa); - return b1; - } - - static int -cmp(Bigint *a, Bigint *b) -{ - ULong *xa, *xa0, *xb, *xb0; - int i, j; - - i = a->wds; - j = b->wds; -#ifdef DEBUG - if (i > 1 && !a->x[i-1]) - Bug("cmp called with a->x[a->wds-1] == 0"); - if (j > 1 && !b->x[j-1]) - Bug("cmp called with b->x[b->wds-1] == 0"); -#endif - if (i -= j) - return i; - xa0 = a->x; - xa = xa0 + j; - xb0 = b->x; - xb = xb0 + j; - for(;;) { - if (*--xa != *--xb) - return *xa < *xb ? -1 : 1; - if (xa <= xa0) - break; - } - return 0; - } - - static Bigint * -diff(Bigint *a, Bigint *b MTd) -{ - Bigint *c; - int i, wa, wb; - ULong *xa, *xae, *xb, *xbe, *xc; -#ifdef ULLong - ULLong borrow, y; -#else - ULong borrow, y; -#ifdef Pack_32 - ULong z; -#endif -#endif - - i = cmp(a,b); - if (!i) { - c = Balloc(0 MTa); - c->wds = 1; - c->x[0] = 0; - return c; - } - if (i < 0) { - c = a; - a = b; - b = c; - i = 1; - } - else - i = 0; - c = Balloc(a->k MTa); - c->sign = i; - wa = a->wds; - xa = a->x; - xae = xa + wa; - wb = b->wds; - xb = b->x; - xbe = xb + wb; - xc = c->x; - borrow = 0; -#ifdef ULLong - do { - y = (ULLong)*xa++ - *xb++ - borrow; - borrow = y >> 32 & (ULong)1; - *xc++ = y & FFFFFFFF; - } - while(xb < xbe); - while(xa < xae) { - y = *xa++ - borrow; - borrow = y >> 32 & (ULong)1; - *xc++ = y & FFFFFFFF; - } -#else -#ifdef Pack_32 - do { - y = (*xa & 0xffff) - (*xb & 0xffff) - borrow; - borrow = (y & 0x10000) >> 16; - z = (*xa++ >> 16) - (*xb++ >> 16) - borrow; - borrow = (z & 0x10000) >> 16; - Storeinc(xc, z, y); - } - while(xb < xbe); - while(xa < xae) { - y = (*xa & 0xffff) - borrow; - borrow = (y & 0x10000) >> 16; - z = (*xa++ >> 16) - borrow; - borrow = (z & 0x10000) >> 16; - Storeinc(xc, z, y); - } -#else - do { - y = *xa++ - *xb++ - borrow; - borrow = (y & 0x10000) >> 16; - *xc++ = y & 0xffff; - } - while(xb < xbe); - while(xa < xae) { - y = *xa++ - borrow; - borrow = (y & 0x10000) >> 16; - *xc++ = y & 0xffff; - } -#endif -#endif - while(!*--xc) - wa--; - c->wds = wa; - return c; - } - - static double -ulp(U *x) -{ - Long L; - U u; - - L = (word0(x) & Exp_mask) - (P-1)*Exp_msk1; -#ifndef Avoid_Underflow -#ifndef Sudden_Underflow - if (L > 0) { -#endif -#endif -#ifdef IBM - L |= Exp_msk1 >> 4; -#endif - word0(&u) = L; - word1(&u) = 0; -#ifndef Avoid_Underflow -#ifndef Sudden_Underflow - } - else { - L = -L >> Exp_shift; - if (L < Exp_shift) { - word0(&u) = 0x80000 >> L; - word1(&u) = 0; - } - else { - word0(&u) = 0; - L -= Exp_shift; - word1(&u) = L >= 31 ? 1 : 1 << 31 - L; - } - } -#endif -#endif - return dval(&u); - } - - static double -b2d(Bigint *a, int *e) -{ - ULong *xa, *xa0, w, y, z; - int k; - U d; -#ifdef VAX - ULong d0, d1; -#else -#define d0 word0(&d) -#define d1 word1(&d) -#endif - - xa0 = a->x; - xa = xa0 + a->wds; - y = *--xa; -#ifdef DEBUG - if (!y) Bug("zero y in b2d"); -#endif - k = hi0bits(y); - *e = 32 - k; -#ifdef Pack_32 - if (k < Ebits) { - d0 = Exp_1 | y >> (Ebits - k); - w = xa > xa0 ? *--xa : 0; - d1 = y << ((32-Ebits) + k) | w >> (Ebits - k); - goto ret_d; - } - z = xa > xa0 ? *--xa : 0; - if (k -= Ebits) { - d0 = Exp_1 | y << k | z >> (32 - k); - y = xa > xa0 ? *--xa : 0; - d1 = z << k | y >> (32 - k); - } - else { - d0 = Exp_1 | y; - d1 = z; - } -#else - if (k < Ebits + 16) { - z = xa > xa0 ? *--xa : 0; - d0 = Exp_1 | y << k - Ebits | z >> Ebits + 16 - k; - w = xa > xa0 ? *--xa : 0; - y = xa > xa0 ? *--xa : 0; - d1 = z << k + 16 - Ebits | w << k - Ebits | y >> 16 + Ebits - k; - goto ret_d; - } - z = xa > xa0 ? *--xa : 0; - w = xa > xa0 ? *--xa : 0; - k -= Ebits + 16; - d0 = Exp_1 | y << k + 16 | z << k | w >> 16 - k; - y = xa > xa0 ? *--xa : 0; - d1 = w << k + 16 | y << k; -#endif - ret_d: -#ifdef VAX - word0(&d) = d0 >> 16 | d0 << 16; - word1(&d) = d1 >> 16 | d1 << 16; -#else -#undef d0 -#undef d1 -#endif - return dval(&d); - } - - static Bigint * -d2b(U *d, int *e, int *bits MTd) -{ - Bigint *b; - int de, k; - ULong *x, y, z; -#ifndef Sudden_Underflow - int i; -#endif -#ifdef VAX - ULong d0, d1; - d0 = word0(d) >> 16 | word0(d) << 16; - d1 = word1(d) >> 16 | word1(d) << 16; -#else -#define d0 word0(d) -#define d1 word1(d) -#endif - -#ifdef Pack_32 - b = Balloc(1 MTa); -#else - b = Balloc(2 MTa); -#endif - x = b->x; - - z = d0 & Frac_mask; - d0 &= 0x7fffffff; /* clear sign bit, which we ignore */ -#ifdef Sudden_Underflow - de = (int)(d0 >> Exp_shift); -#ifndef IBM - z |= Exp_msk11; -#endif -#else - if ((de = (int)(d0 >> Exp_shift))) - z |= Exp_msk1; -#endif -#ifdef Pack_32 - if ((y = d1)) { - if ((k = lo0bits(&y))) { - x[0] = y | z << (32 - k); - z >>= k; - } - else - x[0] = y; -#ifndef Sudden_Underflow - i = -#endif - b->wds = (x[1] = z) ? 2 : 1; - } - else { - k = lo0bits(&z); - x[0] = z; -#ifndef Sudden_Underflow - i = -#endif - b->wds = 1; - k += 32; - } -#else - if (y = d1) { - if (k = lo0bits(&y)) - if (k >= 16) { - x[0] = y | z << 32 - k & 0xffff; - x[1] = z >> k - 16 & 0xffff; - x[2] = z >> k; - i = 2; - } - else { - x[0] = y & 0xffff; - x[1] = y >> 16 | z << 16 - k & 0xffff; - x[2] = z >> k & 0xffff; - x[3] = z >> k+16; - i = 3; - } - else { - x[0] = y & 0xffff; - x[1] = y >> 16; - x[2] = z & 0xffff; - x[3] = z >> 16; - i = 3; - } - } - else { -#ifdef DEBUG - if (!z) - Bug("Zero passed to d2b"); -#endif - k = lo0bits(&z); - if (k >= 16) { - x[0] = z; - i = 0; - } - else { - x[0] = z & 0xffff; - x[1] = z >> 16; - i = 1; - } - k += 32; - } - while(!x[i]) - --i; - b->wds = i + 1; -#endif -#ifndef Sudden_Underflow - if (de) { -#endif -#ifdef IBM - *e = (de - Bias - (P-1) << 2) + k; - *bits = 4*P + 8 - k - hi0bits(word0(d) & Frac_mask); -#else - *e = de - Bias - (P-1) + k; - *bits = P - k; -#endif -#ifndef Sudden_Underflow - } - else { - *e = de - Bias - (P-1) + 1 + k; -#ifdef Pack_32 - *bits = 32*i - hi0bits(x[i-1]); -#else - *bits = (i+2)*16 - hi0bits(x[i]); -#endif - } -#endif - return b; - } -#undef d0 -#undef d1 - - static double -ratio(Bigint *a, Bigint *b) -{ - U da, db; - int k, ka, kb; - - dval(&da) = b2d(a, &ka); - dval(&db) = b2d(b, &kb); -#ifdef Pack_32 - k = ka - kb + 32*(a->wds - b->wds); -#else - k = ka - kb + 16*(a->wds - b->wds); -#endif -#ifdef IBM - if (k > 0) { - word0(&da) += (k >> 2)*Exp_msk1; - if (k &= 3) - dval(&da) *= 1 << k; - } - else { - k = -k; - word0(&db) += (k >> 2)*Exp_msk1; - if (k &= 3) - dval(&db) *= 1 << k; - } -#else - if (k > 0) - word0(&da) += k*Exp_msk1; - else { - k = -k; - word0(&db) += k*Exp_msk1; - } -#endif - return dval(&da) / dval(&db); - } - - static const double -tens[] = { - 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, - 1e10, 1e11, 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19, - 1e20, 1e21, 1e22 -#ifdef VAX - , 1e23, 1e24 -#endif - }; - - static const double -#ifdef IEEE_Arith -bigtens[] = { 1e16, 1e32, 1e64, 1e128, 1e256 }; -static const double tinytens[] = { 1e-16, 1e-32, 1e-64, 1e-128, -#ifdef Avoid_Underflow - 9007199254740992.*9007199254740992.e-256 - /* = 2^106 * 1e-256 */ -#else - 1e-256 -#endif - }; -/* The factor of 2^53 in tinytens[4] helps us avoid setting the underflow */ -/* flag unnecessarily. It leads to a song and dance at the end of strtod. */ -#define Scale_Bit 0x10 -#define n_bigtens 5 -#else -#ifdef IBM -bigtens[] = { 1e16, 1e32, 1e64 }; -static const double tinytens[] = { 1e-16, 1e-32, 1e-64 }; -#define n_bigtens 3 -#else -bigtens[] = { 1e16, 1e32 }; -static const double tinytens[] = { 1e-16, 1e-32 }; -#define n_bigtens 2 -#endif -#endif - -#undef Need_Hexdig -#ifdef INFNAN_CHECK -#ifndef No_Hex_NaN -#define Need_Hexdig -#endif -#endif - -#ifndef Need_Hexdig -#ifndef NO_HEX_FP -#define Need_Hexdig -#endif -#endif - -#ifdef Need_Hexdig /*{*/ -#if 0 -static unsigned char hexdig[256]; - - static void -htinit(unsigned char *h, unsigned char *s, int inc) -{ - int i, j; - for(i = 0; (j = s[i]) !=0; i++) - h[j] = i + inc; - } - - static void -hexdig_init(void) /* Use of hexdig_init omitted 20121220 to avoid a */ - /* race condition when multiple threads are used. */ -{ -#define USC (unsigned char *) - htinit(hexdig, USC "0123456789", 0x10); - htinit(hexdig, USC "abcdef", 0x10 + 10); - htinit(hexdig, USC "ABCDEF", 0x10 + 10); - } -#else -static unsigned char hexdig[256] = { - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 16,17,18,19,20,21,22,23,24,25,0,0,0,0,0,0, - 0,26,27,28,29,30,31,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,26,27,28,29,30,31,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, - 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 - }; -#endif -#endif /* } Need_Hexdig */ - -#ifdef INFNAN_CHECK - -#ifndef NAN_WORD0 -#define NAN_WORD0 0x7ff80000 -#endif - -#ifndef NAN_WORD1 -#define NAN_WORD1 0 -#endif - - static int -match(const char **sp, const char *t) -{ - int c, d; - const char *s = *sp; - - while((d = *t++)) { - if ((c = *++s) >= 'A' && c <= 'Z') - c += 'a' - 'A'; - if (c != d) - return 0; - } - *sp = s + 1; - return 1; - } - -#ifndef No_Hex_NaN - static void -hexnan(U *rvp, const char **sp) -{ - ULong c, x[2]; - const char *s; - int c1, havedig, udx0, xshift; - - /**** if (!hexdig['0']) hexdig_init(); ****/ - x[0] = x[1] = 0; - havedig = xshift = 0; - udx0 = 1; - s = *sp; - /* allow optional initial 0x or 0X */ - while((c = *(const unsigned char*)(s+1)) && c <= ' ') - ++s; - if (s[1] == '0' && (s[2] == 'x' || s[2] == 'X')) - s += 2; - while((c = *(const unsigned char*)++s)) { - if ((c1 = hexdig[c])) - c = c1 & 0xf; - else if (c <= ' ') { - if (udx0 && havedig) { - udx0 = 0; - xshift = 1; - } - continue; - } -#ifdef GDTOA_NON_PEDANTIC_NANCHECK - else if (/*(*/ c == ')' && havedig) { - *sp = s + 1; - break; - } - else - return; /* invalid form: don't change *sp */ -#else - else { - do { - if (/*(*/ c == ')') { - *sp = s + 1; - break; - } - } while((c = *++s)); - break; - } -#endif - havedig = 1; - if (xshift) { - xshift = 0; - x[0] = x[1]; - x[1] = 0; - } - if (udx0) - x[0] = (x[0] << 4) | (x[1] >> 28); - x[1] = (x[1] << 4) | c; - } - if ((x[0] &= 0xfffff) || x[1]) { - word0(rvp) = Exp_mask | x[0]; - word1(rvp) = x[1]; - } - } -#endif /*No_Hex_NaN*/ -#endif /* INFNAN_CHECK */ - -#ifdef Pack_32 -#define ULbits 32 -#define kshift 5 -#define kmask 31 -#else -#define ULbits 16 -#define kshift 4 -#define kmask 15 -#endif - -#if !defined(NO_HEX_FP) || defined(Honor_FLT_ROUNDS) /*{*/ - static Bigint * -increment(Bigint *b MTd) -{ - ULong *x, *xe; - Bigint *b1; - - x = b->x; - xe = x + b->wds; - do { - if (*x < (ULong)0xffffffffL) { - ++*x; - return b; - } - *x++ = 0; - } while(x < xe); - { - if (b->wds >= b->maxwds) { - b1 = Balloc(b->k+1 MTa); - Bcopy(b1,b); - Bfree(b MTa); - b = b1; - } - b->x[b->wds++] = 1; - } - return b; - } - -#endif /*}*/ - -#ifndef NO_HEX_FP /*{*/ - - static void -rshift(Bigint *b, int k) -{ - ULong *x, *x1, *xe, y; - int n; - - x = x1 = b->x; - n = k >> kshift; - if (n < b->wds) { - xe = x + b->wds; - x += n; - if (k &= kmask) { - n = 32 - k; - y = *x++ >> k; - while(x < xe) { - *x1++ = (y | (*x << n)) & 0xffffffff; - y = *x++ >> k; - } - if ((*x1 = y) !=0) - x1++; - } - else - while(x < xe) - *x1++ = *x++; - } - if ((b->wds = x1 - b->x) == 0) - b->x[0] = 0; - } - - static ULong -any_on(Bigint *b, int k) -{ - int n, nwds; - ULong *x, *x0, x1, x2; - - x = b->x; - nwds = b->wds; - n = k >> kshift; - if (n > nwds) - n = nwds; - else if (n < nwds && (k &= kmask)) { - x1 = x2 = x[n]; - x1 >>= k; - x1 <<= k; - if (x1 != x2) - return 1; - } - x0 = x; - x += n; - while(x > x0) - if (*--x) - return 1; - return 0; - } - -enum { /* rounding values: same as FLT_ROUNDS */ - Round_zero = 0, - Round_near = 1, - Round_up = 2, - Round_down = 3 - }; - - void -gethex(const char **sp, U *rvp, int rounding, int sign MTd) -{ - Bigint *b; - char d; - const unsigned char *decpt, *s0, *s, *s1; - Long e, e1; - ULong L, lostbits, *x; - int big, denorm, esign, havedig, k, n, nb, nbits, nz, up, zret; -#ifdef IBM - int j; -#endif - enum { -#ifdef IEEE_Arith /*{{*/ - emax = 0x7fe - Bias - P + 1, - emin = Emin - P + 1 -#else /*}{*/ - emin = Emin - P, -#ifdef VAX - emax = 0x7ff - Bias - P + 1 -#endif -#ifdef IBM - emax = 0x7f - Bias - P -#endif -#endif /*}}*/ - }; -#ifdef IEEE_Arith - int check_denorm = 0; -#endif -#ifdef USE_LOCALE - int i; -#ifdef NO_LOCALE_CACHE - const unsigned char *decimalpoint = (unsigned char*) - localeconv()->decimal_point; -#else - const unsigned char *decimalpoint; - static unsigned char *decimalpoint_cache; - if (!(s0 = decimalpoint_cache)) { - s0 = (unsigned char*)localeconv()->decimal_point; - if ((decimalpoint_cache = (unsigned char*) - MALLOC(strlen((const char*)s0) + 1))) { - strcpy((char*)decimalpoint_cache, (const char*)s0); - s0 = decimalpoint_cache; - } - } - decimalpoint = s0; -#endif -#endif - - /**** if (!hexdig['0']) hexdig_init(); ****/ - havedig = 0; - s0 = *(const unsigned char **)sp + 2; - while(s0[havedig] == '0') - havedig++; - s0 += havedig; - s = s0; - decpt = 0; - zret = 0; - e = 0; - if (hexdig[*s]) - havedig++; - else { - zret = 1; -#ifdef USE_LOCALE - for(i = 0; decimalpoint[i]; ++i) { - if (s[i] != decimalpoint[i]) - goto pcheck; - } - decpt = s += i; -#else - if (*s != '.') - goto pcheck; - decpt = ++s; -#endif - if (!hexdig[*s]) - goto pcheck; - while(*s == '0') - s++; - if (hexdig[*s]) - zret = 0; - havedig = 1; - s0 = s; - } - while(hexdig[*s]) - s++; -#ifdef USE_LOCALE - if (*s == *decimalpoint && !decpt) { - for(i = 1; decimalpoint[i]; ++i) { - if (s[i] != decimalpoint[i]) - goto pcheck; - } - decpt = s += i; -#else - if (*s == '.' && !decpt) { - decpt = ++s; -#endif - while(hexdig[*s]) - s++; - }/*}*/ - if (decpt) - e = -(((Long)(s-decpt)) << 2); - pcheck: - s1 = s; - big = esign = 0; - switch(*s) { - case 'p': - case 'P': - switch(*++s) { - case '-': - esign = 1; - /* no break */ - case '+': - s++; - } - if ((n = hexdig[*s]) == 0 || n > 0x19) { - s = s1; - break; - } - e1 = n - 0x10; - while((n = hexdig[*++s]) !=0 && n <= 0x19) { - if (e1 & 0xf8000000) - big = 1; - e1 = 10*e1 + n - 0x10; - } - if (esign) - e1 = -e1; - e += e1; - } - *sp = (char*)s; - if (!havedig) - *sp = (char*)s0 - 1; - if (zret) - goto retz1; - if (big) { - if (esign) { -#ifdef IEEE_Arith - switch(rounding) { - case Round_up: - if (sign) - break; - goto ret_tiny; - case Round_down: - if (!sign) - break; - goto ret_tiny; - } -#endif - goto retz; -#ifdef IEEE_Arith - ret_tinyf: - Bfree(b MTa); - ret_tiny: - Set_errno(ERANGE); - word0(rvp) = 0; - word1(rvp) = 1; - return; -#endif /* IEEE_Arith */ - } - switch(rounding) { - case Round_near: - goto ovfl1; - case Round_up: - if (!sign) - goto ovfl1; - goto ret_big; - case Round_down: - if (sign) - goto ovfl1; - goto ret_big; - } - ret_big: - word0(rvp) = Big0; - word1(rvp) = Big1; - return; - } - n = s1 - s0 - 1; - for(k = 0; n > (1 << (kshift-2)) - 1; n >>= 1) - k++; - b = Balloc(k MTa); - x = b->x; - havedig = n = nz = 0; - L = 0; -#ifdef USE_LOCALE - for(i = 0; decimalpoint[i+1]; ++i); -#endif - while(s1 > s0) { -#ifdef USE_LOCALE - if (*--s1 == decimalpoint[i]) { - s1 -= i; - continue; - } -#else - if (*--s1 == '.') - continue; -#endif - if ((d = hexdig[*s1])) - havedig = 1; - else if (!havedig) { - e += 4; - continue; - } - if (n == ULbits) { - *x++ = L; - L = 0; - n = 0; - } - L |= (d & 0x0f) << n; - n += 4; - } - *x++ = L; - b->wds = n = x - b->x; - nb = ULbits*n - hi0bits(L); - nbits = Nbits; - lostbits = 0; - x = b->x; - if (nb > nbits) { - n = nb - nbits; - if (any_on(b,n)) { - lostbits = 1; - k = n - 1; - if (x[k>>kshift] & 1 << (k & kmask)) { - lostbits = 2; - if (k > 0 && any_on(b,k)) - lostbits = 3; - } - } - rshift(b, n); - e += n; - } - else if (nb < nbits) { - n = nbits - nb; - b = lshift(b, n MTa); - e -= n; - x = b->x; - } - if (e > emax) { - ovfl: - Bfree(b MTa); - ovfl1: - Set_errno(ERANGE); -#ifdef Honor_FLT_ROUNDS - switch (rounding) { - case Round_zero: - goto ret_big; - case Round_down: - if (!sign) - goto ret_big; - break; - case Round_up: - if (sign) - goto ret_big; - } -#endif - word0(rvp) = Exp_mask; - word1(rvp) = 0; - return; - } - denorm = 0; - if (e < emin) { - denorm = 1; - n = emin - e; - if (n >= nbits) { -#ifdef IEEE_Arith /*{*/ - switch (rounding) { - case Round_near: - if (n == nbits && (n < 2 || lostbits || any_on(b,n-1))) - goto ret_tinyf; - break; - case Round_up: - if (!sign) - goto ret_tinyf; - break; - case Round_down: - if (sign) - goto ret_tinyf; - } -#endif /* } IEEE_Arith */ - Bfree(b MTa); - retz: - Set_errno(ERANGE); - retz1: - rvp->d = 0.; - return; - } - k = n - 1; -#ifdef IEEE_Arith - if (!k) { - switch(rounding) { - case Round_near: - if (((b->x[0] & 3) == 3) || (lostbits && (b->x[0] & 1))) { - multadd(b, 1, 1 MTa); - emin_check: - if (b->x[1] == (1 << (Exp_shift + 1))) { - rshift(b,1); - e = emin; - goto normal; - } - } - break; - case Round_up: - if (!sign && (lostbits || (b->x[0] & 1))) { - incr_denorm: - multadd(b, 1, 2 MTa); - check_denorm = 1; - lostbits = 0; - goto emin_check; - } - break; - case Round_down: - if (sign && (lostbits || (b->x[0] & 1))) - goto incr_denorm; - break; - } - } -#endif - if (lostbits) - lostbits = 1; - else if (k > 0) - lostbits = any_on(b,k); -#ifdef IEEE_Arith - else if (check_denorm) - goto no_lostbits; -#endif - if (x[k>>kshift] & 1 << (k & kmask)) - lostbits |= 2; -#ifdef IEEE_Arith - no_lostbits: -#endif - nbits -= n; - rshift(b,n); - e = emin; - } - if (lostbits) { - up = 0; - switch(rounding) { - case Round_zero: - break; - case Round_near: - if (lostbits & 2 - && (lostbits & 1) | (x[0] & 1)) - up = 1; - break; - case Round_up: - up = 1 - sign; - break; - case Round_down: - up = sign; - } - if (up) { - k = b->wds; - b = increment(b MTa); - x = b->x; - if (!denorm && (b->wds > k - || ((n = nbits & kmask) !=0 - && hi0bits(x[k-1]) < 32-n))) { - rshift(b,1); - if (++e > Emax) - goto ovfl; - } - } - } -#ifdef IEEE_Arith - if (denorm) - word0(rvp) = b->wds > 1 ? b->x[1] & ~0x100000 : 0; - else { - normal: - word0(rvp) = (b->x[1] & ~0x100000) | ((e + 0x3ff + 52) << 20); - } - word1(rvp) = b->x[0]; -#endif -#ifdef IBM - if ((j = e & 3)) { - k = b->x[0] & ((1 << j) - 1); - rshift(b,j); - if (k) { - switch(rounding) { - case Round_up: - if (!sign) - increment(b); - break; - case Round_down: - if (sign) - increment(b); - break; - case Round_near: - j = 1 << (j-1); - if (k & j && ((k & (j-1)) | lostbits)) - increment(b); - } - } - } - e >>= 2; - word0(rvp) = b->x[1] | ((e + 65 + 13) << 24); - word1(rvp) = b->x[0]; -#endif -#ifdef VAX - /* The next two lines ignore swap of low- and high-order 2 bytes. */ - /* word0(rvp) = (b->x[1] & ~0x800000) | ((e + 129 + 55) << 23); */ - /* word1(rvp) = b->x[0]; */ - word0(rvp) = ((b->x[1] & ~0x800000) >> 16) | ((e + 129 + 55) << 7) | (b->x[1] << 16); - word1(rvp) = (b->x[0] >> 16) | (b->x[0] << 16); -#endif - Bfree(b MTa); - } -#endif /*!NO_HEX_FP}*/ - - static int -dshift(Bigint *b, int p2) -{ - int rv = hi0bits(b->x[b->wds-1]) - 4; - if (p2 > 0) - rv -= p2; - return rv & kmask; - } - - static int -quorem(Bigint *b, Bigint *S) -{ - int n; - ULong *bx, *bxe, q, *sx, *sxe; -#ifdef ULLong - ULLong borrow, carry, y, ys; -#else - ULong borrow, carry, y, ys; -#ifdef Pack_32 - ULong si, z, zs; -#endif -#endif - - n = S->wds; -#ifdef DEBUG - /*debug*/ if (b->wds > n) - /*debug*/ Bug("oversize b in quorem"); -#endif - if (b->wds < n) - return 0; - sx = S->x; - sxe = sx + --n; - bx = b->x; - bxe = bx + n; - q = *bxe / (*sxe + 1); /* ensure q <= true quotient */ -#ifdef DEBUG -#ifdef NO_STRTOD_BIGCOMP - /*debug*/ if (q > 9) -#else - /* An oversized q is possible when quorem is called from bigcomp and */ - /* the input is near, e.g., twice the smallest denormalized number. */ - /*debug*/ if (q > 15) -#endif - /*debug*/ Bug("oversized quotient in quorem"); -#endif - if (q) { - borrow = 0; - carry = 0; - do { -#ifdef ULLong - ys = *sx++ * (ULLong)q + carry; - carry = ys >> 32; - y = *bx - (ys & FFFFFFFF) - borrow; - borrow = y >> 32 & (ULong)1; - *bx++ = y & FFFFFFFF; -#else -#ifdef Pack_32 - si = *sx++; - ys = (si & 0xffff) * q + carry; - zs = (si >> 16) * q + (ys >> 16); - carry = zs >> 16; - y = (*bx & 0xffff) - (ys & 0xffff) - borrow; - borrow = (y & 0x10000) >> 16; - z = (*bx >> 16) - (zs & 0xffff) - borrow; - borrow = (z & 0x10000) >> 16; - Storeinc(bx, z, y); -#else - ys = *sx++ * q + carry; - carry = ys >> 16; - y = *bx - (ys & 0xffff) - borrow; - borrow = (y & 0x10000) >> 16; - *bx++ = y & 0xffff; -#endif -#endif - } - while(sx <= sxe); - if (!*bxe) { - bx = b->x; - while(--bxe > bx && !*bxe) - --n; - b->wds = n; - } - } - if (cmp(b, S) >= 0) { - q++; - borrow = 0; - carry = 0; - bx = b->x; - sx = S->x; - do { -#ifdef ULLong - ys = *sx++ + carry; - carry = ys >> 32; - y = *bx - (ys & FFFFFFFF) - borrow; - borrow = y >> 32 & (ULong)1; - *bx++ = y & FFFFFFFF; -#else -#ifdef Pack_32 - si = *sx++; - ys = (si & 0xffff) + carry; - zs = (si >> 16) + (ys >> 16); - carry = zs >> 16; - y = (*bx & 0xffff) - (ys & 0xffff) - borrow; - borrow = (y & 0x10000) >> 16; - z = (*bx >> 16) - (zs & 0xffff) - borrow; - borrow = (z & 0x10000) >> 16; - Storeinc(bx, z, y); -#else - ys = *sx++ + carry; - carry = ys >> 16; - y = *bx - (ys & 0xffff) - borrow; - borrow = (y & 0x10000) >> 16; - *bx++ = y & 0xffff; -#endif -#endif - } - while(sx <= sxe); - bx = b->x; - bxe = bx + n; - if (!*bxe) { - while(--bxe > bx && !*bxe) - --n; - b->wds = n; - } - } - return q; - } - -#if defined(Avoid_Underflow) || !defined(NO_STRTOD_BIGCOMP) /*{*/ - static double -sulp(U *x, BCinfo *bc) -{ - U u; - double rv; - int i; - - rv = ulp(x); - if (!bc->scale || (i = 2*P + 1 - ((word0(x) & Exp_mask) >> Exp_shift)) <= 0) - return rv; /* Is there an example where i <= 0 ? */ - word0(&u) = Exp_1 + (i << Exp_shift); - word1(&u) = 0; - return rv * u.d; - } -#endif /*}*/ - -#ifndef NO_STRTOD_BIGCOMP - static void -bigcomp(U *rv, const char *s0, BCinfo *bc MTd) -{ - Bigint *b, *d; - int b2, bbits, d2, dd, dig, dsign, i, j, nd, nd0, p2, p5, speccase; - - dsign = bc->dsign; - nd = bc->nd; - nd0 = bc->nd0; - p5 = nd + bc->e0 - 1; - speccase = 0; -#ifndef Sudden_Underflow - if (rv->d == 0.) { /* special case: value near underflow-to-zero */ - /* threshold was rounded to zero */ - b = i2b(1 MTa); - p2 = Emin - P + 1; - bbits = 1; -#ifdef Avoid_Underflow - word0(rv) = (P+2) << Exp_shift; -#else - word1(rv) = 1; -#endif - i = 0; -#ifdef Honor_FLT_ROUNDS - if (bc->rounding == 1) -#endif - { - speccase = 1; - --p2; - dsign = 0; - goto have_i; - } - } - else -#endif - b = d2b(rv, &p2, &bbits MTa); -#ifdef Avoid_Underflow - p2 -= bc->scale; -#endif - /* floor(log2(rv)) == bbits - 1 + p2 */ - /* Check for denormal case. */ - i = P - bbits; - if (i > (j = P - Emin - 1 + p2)) { -#ifdef Sudden_Underflow - Bfree(b MTa); - b = i2b(1 MTa); - p2 = Emin; - i = P - 1; -#ifdef Avoid_Underflow - word0(rv) = (1 + bc->scale) << Exp_shift; -#else - word0(rv) = Exp_msk1; -#endif - word1(rv) = 0; -#else - i = j; -#endif - } -#ifdef Honor_FLT_ROUNDS - if (bc->rounding != 1) { - if (i > 0) - b = lshift(b, i MTa); - if (dsign) - b = increment(b MTa); - } - else -#endif - { - b = lshift(b, ++i MTa); - b->x[0] |= 1; - } -#ifndef Sudden_Underflow - have_i: -#endif - p2 -= p5 + i; - d = i2b(1 MTa); - /* Arrange for convenient computation of quotients: - * shift left if necessary so divisor has 4 leading 0 bits. - */ - if (p5 > 0) - d = pow5mult(d, p5 MTa); - else if (p5 < 0) - b = pow5mult(b, -p5 MTa); - if (p2 > 0) { - b2 = p2; - d2 = 0; - } - else { - b2 = 0; - d2 = -p2; - } - i = dshift(d, d2); - if ((b2 += i) > 0) - b = lshift(b, b2 MTa); - if ((d2 += i) > 0) - d = lshift(d, d2 MTa); - - /* Now b/d = exactly half-way between the two floating-point values */ - /* on either side of the input string. Compute first digit of b/d. */ - - if (!(dig = quorem(b,d))) { - b = multadd(b, 10, 0 MTa); /* very unlikely */ - dig = quorem(b,d); - } - - /* Compare b/d with s0 */ - - for(i = 0; i < nd0; ) { - if ((dd = s0[i++] - '0' - dig)) - goto ret; - if (!b->x[0] && b->wds == 1) { - if (i < nd) - dd = 1; - goto ret; - } - b = multadd(b, 10, 0 MTa); - dig = quorem(b,d); - } - for(j = bc->dp1; i++ < nd;) { - if ((dd = s0[j++] - '0' - dig)) - goto ret; - if (!b->x[0] && b->wds == 1) { - if (i < nd) - dd = 1; - goto ret; - } - b = multadd(b, 10, 0 MTa); - dig = quorem(b,d); - } - if (dig > 0 || b->x[0] || b->wds > 1) - dd = -1; - ret: - Bfree(b MTa); - Bfree(d MTa); -#ifdef Honor_FLT_ROUNDS - if (bc->rounding != 1) { - if (dd < 0) { - if (bc->rounding == 0) { - if (!dsign) - goto retlow1; - } - else if (dsign) - goto rethi1; - } - else if (dd > 0) { - if (bc->rounding == 0) { - if (dsign) - goto rethi1; - goto ret1; - } - if (!dsign) - goto rethi1; - dval(rv) += 2.*sulp(rv,bc); - } - else { - bc->inexact = 0; - if (dsign) - goto rethi1; - } - } - else -#endif - if (speccase) { - if (dd <= 0) - rv->d = 0.; - } - else if (dd < 0) { - if (!dsign) /* does not happen for round-near */ -retlow1: - dval(rv) -= sulp(rv,bc); - } - else if (dd > 0) { - if (dsign) { - rethi1: - dval(rv) += sulp(rv,bc); - } - } - else { - /* Exact half-way case: apply round-even rule. */ - if ((j = ((word0(rv) & Exp_mask) >> Exp_shift) - bc->scale) <= 0) { - i = 1 - j; - if (i <= 31) { - if (word1(rv) & (0x1 << i)) - goto odd; - } - else if (word0(rv) & (0x1 << (i-32))) - goto odd; - } - else if (word1(rv) & 1) { - odd: - if (dsign) - goto rethi1; - goto retlow1; - } - } - -#ifdef Honor_FLT_ROUNDS - ret1: -#endif - return; - } -#endif /* NO_STRTOD_BIGCOMP */ - - double -strtod(const char *s00, char **se) -{ - int bb2, bb5, bbe, bd2, bd5, bbbits, bs2, c, e, e1; - int esign, i, j, k, nd, nd0, nf, nz, nz0, nz1, sign; - const char *s, *s0, *s1; - double aadj, aadj1; - Long L; - U aadj2, adj, rv, rv0; - ULong y, z; - BCinfo bc; - Bigint *bb, *bb1, *bd, *bd0, *bs, *delta; -#ifdef USE_BF96 - ULLong bhi, blo, brv, t00, t01, t02, t10, t11, terv, tg, tlo, yz; - const BF96 *p10; - int bexact, erv; -#endif -#ifdef Avoid_Underflow - ULong Lsb, Lsb1; -#endif -#ifdef SET_INEXACT - int oldinexact; -#endif -#ifndef NO_STRTOD_BIGCOMP - int req_bigcomp = 0; -#endif -#ifdef MULTIPLE_THREADS - ThInfo *TI = 0; -#endif -#ifdef Honor_FLT_ROUNDS /*{*/ -#ifdef Trust_FLT_ROUNDS /*{{ only define this if FLT_ROUNDS really works! */ - bc.rounding = Flt_Rounds; -#else /*}{*/ - bc.rounding = 1; - switch(fegetround()) { - case FE_TOWARDZERO: bc.rounding = 0; break; - case FE_UPWARD: bc.rounding = 2; break; - case FE_DOWNWARD: bc.rounding = 3; - } -#endif /*}}*/ -#endif /*}*/ -#ifdef USE_LOCALE - const char *s2; -#endif - - sign = nz0 = nz1 = nz = bc.dplen = bc.uflchk = 0; - dval(&rv) = 0.; - for(s = s00;;s++) switch(*s) { - case '-': - sign = 1; - /* no break */ - case '+': - if (*++s) - goto break2; - /* no break */ - case 0: - goto ret0; - case '\t': - case '\n': - case '\v': - case '\f': - case '\r': - case ' ': - continue; - default: - goto break2; - } - break2: - if (*s == '0') { -#ifndef NO_HEX_FP /*{*/ - switch(s[1]) { - case 'x': - case 'X': -#ifdef Honor_FLT_ROUNDS - gethex(&s, &rv, bc.rounding, sign MTb); -#else - gethex(&s, &rv, 1, sign MTb); -#endif - goto ret; - } -#endif /*}*/ - nz0 = 1; - while(*++s == '0') ; - if (!*s) - goto ret; - } - s0 = s; - nd = nf = 0; -#ifdef USE_BF96 - yz = 0; - for(; (c = *s) >= '0' && c <= '9'; nd++, s++) - if (nd < 19) - yz = 10*yz + c - '0'; -#else - y = z = 0; - for(; (c = *s) >= '0' && c <= '9'; nd++, s++) - if (nd < 9) - y = 10*y + c - '0'; - else if (nd < DBL_DIG + 2) - z = 10*z + c - '0'; -#endif - nd0 = nd; - bc.dp0 = bc.dp1 = s - s0; - for(s1 = s; s1 > s0 && *--s1 == '0'; ) - ++nz1; -#ifdef USE_LOCALE - s1 = localeconv()->decimal_point; - if (c == *s1) { - c = '.'; - if (*++s1) { - s2 = s; - for(;;) { - if (*++s2 != *s1) { - c = 0; - break; - } - if (!*++s1) { - s = s2; - break; - } - } - } - } -#endif - if (c == '.') { - c = *++s; - bc.dp1 = s - s0; - bc.dplen = bc.dp1 - bc.dp0; - if (!nd) { - for(; c == '0'; c = *++s) - nz++; - if (c > '0' && c <= '9') { - bc.dp0 = s0 - s; - bc.dp1 = bc.dp0 + bc.dplen; - s0 = s; - nf += nz; - nz = 0; - goto have_dig; - } - goto dig_done; - } - for(; c >= '0' && c <= '9'; c = *++s) { - have_dig: - nz++; - if (c -= '0') { - nf += nz; - i = 1; -#ifdef USE_BF96 - for(; i < nz; ++i) { - if (++nd <= 19) - yz *= 10; - } - if (++nd <= 19) - yz = 10*yz + c; -#else - for(; i < nz; ++i) { - if (nd++ < 9) - y *= 10; - else if (nd <= DBL_DIG + 2) - z *= 10; - } - if (nd++ < 9) - y = 10*y + c; - else if (nd <= DBL_DIG + 2) - z = 10*z + c; -#endif - nz = nz1 = 0; - } - } - } - dig_done: - e = 0; - if (c == 'e' || c == 'E') { - if (!nd && !nz && !nz0) { - goto ret0; - } - s00 = s; - esign = 0; - switch(c = *++s) { - case '-': - esign = 1; - case '+': - c = *++s; - } - if (c >= '0' && c <= '9') { - while(c == '0') - c = *++s; - if (c > '0' && c <= '9') { - L = c - '0'; - while((c = *++s) >= '0' && c <= '9') { - if (L <= 19999) - L = 10*L + c - '0'; - } - if (L > 19999) - /* Avoid confusion from exponents - * so large that e might overflow. - */ - e = 19999; /* safe for 16 bit ints */ - else - e = (int)L; - if (esign) - e = -e; - } - else - e = 0; - } - else - s = s00; - } - if (!nd) { - if (!nz && !nz0) { -#ifdef INFNAN_CHECK /*{*/ - /* Check for Nan and Infinity */ - if (!bc.dplen) - switch(c) { - case 'i': - case 'I': - if (match(&s,"nf")) { - --s; - if (!match(&s,"inity")) - ++s; - word0(&rv) = 0x7ff00000; - word1(&rv) = 0; - goto ret; - } - break; - case 'n': - case 'N': - if (match(&s, "an")) { - word0(&rv) = NAN_WORD0; - word1(&rv) = NAN_WORD1; -#ifndef No_Hex_NaN - if (*s == '(') /*)*/ - hexnan(&rv, &s); -#endif - goto ret; - } - } -#endif /*} INFNAN_CHECK */ - ret0: - s = s00; - sign = 0; - } - goto ret; - } - bc.e0 = e1 = e -= nf; - - /* Now we have nd0 digits, starting at s0, followed by a - * decimal point, followed by nd-nd0 digits. The number we're - * after is the integer represented by those digits times - * 10**e */ - - if (!nd0) - nd0 = nd; -#ifndef USE_BF96 - k = nd < DBL_DIG + 2 ? nd : DBL_DIG + 2; - dval(&rv) = y; - if (k > 9) { -#ifdef SET_INEXACT - if (k > DBL_DIG) - oldinexact = get_inexact(); -#endif - dval(&rv) = tens[k - 9] * dval(&rv) + z; - } -#endif - bd0 = 0; - if (nd <= DBL_DIG -#ifndef RND_PRODQUOT -#ifndef Honor_FLT_ROUNDS - && Flt_Rounds == 1 -#endif -#endif - ) { -#ifdef USE_BF96 - dval(&rv) = yz; -#endif - if (!e) - goto ret; -#ifndef ROUND_BIASED_without_Round_Up - if (e > 0) { - if (e <= Ten_pmax) { -#ifdef SET_INEXACT - bc.inexact = 0; - oldinexact = 1; -#endif -#ifdef VAX - goto vax_ovfl_check; -#else -#ifdef Honor_FLT_ROUNDS - /* round correctly FLT_ROUNDS = 2 or 3 */ - if (sign) { - rv.d = -rv.d; - sign = 0; - } -#endif - /* rv = */ rounded_product(dval(&rv), tens[e]); - goto ret; -#endif - } - i = DBL_DIG - nd; - if (e <= Ten_pmax + i) { - /* A fancier test would sometimes let us do - * this for larger i values. - */ -#ifdef SET_INEXACT - bc.inexact = 0; - oldinexact = 1; -#endif -#ifdef Honor_FLT_ROUNDS - /* round correctly FLT_ROUNDS = 2 or 3 */ - if (sign) { - rv.d = -rv.d; - sign = 0; - } -#endif - e -= i; - dval(&rv) *= tens[i]; -#ifdef VAX - /* VAX exponent range is so narrow we must - * worry about overflow here... - */ - vax_ovfl_check: - word0(&rv) -= P*Exp_msk1; - /* rv = */ rounded_product(dval(&rv), tens[e]); - if ((word0(&rv) & Exp_mask) - > Exp_msk1*(DBL_MAX_EXP+Bias-1-P)) - goto ovfl; - word0(&rv) += P*Exp_msk1; -#else - /* rv = */ rounded_product(dval(&rv), tens[e]); -#endif - goto ret; - } - } -#ifndef Inaccurate_Divide - else if (e >= -Ten_pmax) { -#ifdef SET_INEXACT - bc.inexact = 0; - oldinexact = 1; -#endif -#ifdef Honor_FLT_ROUNDS - /* round correctly FLT_ROUNDS = 2 or 3 */ - if (sign) { - rv.d = -rv.d; - sign = 0; - } -#endif - /* rv = */ rounded_quotient(dval(&rv), tens[-e]); - goto ret; - } -#endif -#endif /* ROUND_BIASED_without_Round_Up */ - } -#ifdef USE_BF96 - k = nd < 19 ? nd : 19; -#endif - e1 += nd - k; /* scale factor = 10^e1 */ - -#ifdef IEEE_Arith -#ifdef SET_INEXACT - bc.inexact = 1; -#ifndef USE_BF96 - if (k <= DBL_DIG) -#endif - oldinexact = get_inexact(); -#endif -#ifdef Honor_FLT_ROUNDS - if (bc.rounding >= 2) { - if (sign) - bc.rounding = bc.rounding == 2 ? 0 : 2; - else - if (bc.rounding != 2) - bc.rounding = 0; - } -#endif -#endif /*IEEE_Arith*/ - -#ifdef USE_BF96 /*{*/ - Debug(++dtoa_stats[0]); - i = e1 + 342; - if (i < 0) - goto undfl; - if (i > 650) - goto ovfl; - p10 = &pten[i]; - brv = yz; - /* shift brv left, with i = number of bits shifted */ - i = 0; - if (!(brv & 0xffffffff00000000ull)) { - i = 32; - brv <<= 32; - } - if (!(brv & 0xffff000000000000ull)) { - i += 16; - brv <<= 16; - } - if (!(brv & 0xff00000000000000ull)) { - i += 8; - brv <<= 8; - } - if (!(brv & 0xf000000000000000ull)) { - i += 4; - brv <<= 4; - } - if (!(brv & 0xc000000000000000ull)) { - i += 2; - brv <<= 2; - } - if (!(brv & 0x8000000000000000ull)) { - i += 1; - brv <<= 1; - } - erv = (64 + 0x3fe) + p10->e - i; - if (erv <= 0 && nd > 19) - goto many_digits; /* denormal: may need to look at all digits */ - bhi = brv >> 32; - blo = brv & 0xffffffffull; - /* Unsigned 32-bit ints lie in [0,2^32-1] and */ - /* unsigned 64-bit ints lie in [0, 2^64-1]. The product of two unsigned */ - /* 32-bit ints is <= 2^64 - 2*2^32-1 + 1 = 2^64 - 1 - 2*(2^32 - 1), so */ - /* we can add two unsigned 32-bit ints to the product of two such ints, */ - /* and 64 bits suffice to contain the result. */ - t01 = bhi * p10->b1; - t10 = blo * p10->b0 + (t01 & 0xffffffffull); - t00 = bhi * p10->b0 + (t01 >> 32) + (t10 >> 32); - if (t00 & 0x8000000000000000ull) { - if ((t00 & 0x3ff) && (~t00 & 0x3fe)) { /* unambiguous result? */ - if (nd > 19 && ((t00 + (1< 19 && ((t00 + (1<b2; - t11 = blo * p10->b1 + (t02 & 0xffffffffull); - bexact = 1; - if (e1 < 0 || e1 > 41 || (t10 | t11) & 0xffffffffull || nd > 19) - bexact = 0; - tlo = (t10 & 0xffffffffull) + (t02 >> 32) + (t11 >> 32); - if (!bexact && (tlo + 0x10) >> 32 > tlo >> 32) - goto many_digits; - t00 += tlo >> 32; - if (t00 & 0x8000000000000000ull) { - if (erv <= 0) { /* denormal result */ - if (nd >= 20 || !((tlo & 0xfffffff0) | (t00 & 0x3ff))) - goto many_digits; - denormal: - if (erv <= -52) { -#ifdef Honor_FLT_ROUNDS - switch(bc.rounding) { - case 0: goto undfl; - case 2: goto tiniest; - } -#endif - if (erv < -52 || !(t00 & 0x7fffffffffffffffull)) - goto undfl; - goto tiniest; - } - tg = 1ull << (11 - erv); - t00 &= ~(tg - 1); /* clear low bits */ -#ifdef Honor_FLT_ROUNDS - switch(bc.rounding) { - case 0: goto noround_den; - case 2: goto roundup_den; - } -#endif - if (t00 & tg) { -#ifdef Honor_FLT_ROUNDS - roundup_den: -#endif - t00 += tg << 1; - if (!(t00 & 0x8000000000000000ull)) { - if (++erv > 0) - goto smallest_normal; - t00 = 0x8000000000000000ull; - } - } -#ifdef Honor_FLT_ROUNDS - noround_den: -#endif - LLval(&rv) = t00 >> (12 - erv); - Set_errno(ERANGE); - goto ret; - } - if (bexact) { -#ifdef SET_INEXACT - if (!(t00 & 0x7ff) && !(tlo & 0xffffffffull)) { - bc.inexact = 0; - goto noround; - } -#endif -#ifdef Honor_FLT_ROUNDS - switch(bc.rounding) { - case 2: - if (t00 & 0x7ff) - goto roundup; - case 0: goto noround; - } -#endif - if (t00 & 0x400 && (tlo & 0xffffffff) | (t00 & 0xbff)) - goto roundup; - goto noround; - } - if ((tlo & 0xfffffff0) | (t00 & 0x3ff) - && (nd <= 19 || ((t00 + (1ull << i)) & 0xfffffffffffffc00ull) - == (t00 & 0xfffffffffffffc00ull))) { - /* Unambiguous result. */ - /* If nd > 19, then incrementing the 19th digit */ - /* does not affect rv. */ -#ifdef Honor_FLT_ROUNDS - switch(bc.rounding) { - case 0: goto noround; - case 2: goto roundup; - } -#endif - if (t00 & 0x400) { /* round up */ - roundup: - t00 += 0x800; - if (!(t00 & 0x8000000000000000ull)) { - /* rounded up to a power of 2 */ - if (erv >= 0x7fe) - goto ovfl; - terv = erv + 1; - LLval(&rv) = terv << 52; - goto ret; - } - } - noround: - if (erv >= 0x7ff) - goto ovfl; - terv = erv; - LLval(&rv) = (terv << 52) | ((t00 & 0x7ffffffffffff800ull) >> 11); - goto ret; - } - } - else { - if (erv <= 1) { /* denormal result */ - if (nd >= 20 || !((tlo & 0xfffffff0) | (t00 & 0x1ff))) - goto many_digits; - denormal1: - if (erv <= -51) { -#ifdef Honor_FLT_ROUNDS - switch(bc.rounding) { - case 0: goto undfl; - case 2: goto tiniest; - } -#endif - if (erv < -51 || !(t00 & 0x3fffffffffffffffull)) - goto undfl; - tiniest: - LLval(&rv) = 1; - Set_errno(ERANGE); - goto ret; - } - tg = 1ull << (11 - erv); -#ifdef Honor_FLT_ROUNDS - switch(bc.rounding) { - case 0: goto noround1_den; - case 2: goto roundup1_den; - } -#endif - if (t00 & tg) { -#ifdef Honor_FLT_ROUNDS - roundup1_den: -#endif - if (0x8000000000000000ull & (t00 += (tg<<1)) && erv == 1) { - - smallest_normal: - LLval(&rv) = 0x0010000000000000ull; - goto ret; - } - } -#ifdef Honor_FLT_ROUNDS - noround1_den: -#endif - if (erv <= -52) - goto undfl; - LLval(&rv) = t00 >> (12 - erv); - Set_errno(ERANGE); - goto ret; - } - if (bexact) { -#ifdef SET_INEXACT - if (!(t00 & 0x3ff) && !(tlo & 0xffffffffull)) { - bc.inexact = 0; - goto noround1; - } -#endif -#ifdef Honor_FLT_ROUNDS - switch(bc.rounding) { - case 2: - if (t00 & 0x3ff) - goto roundup1; - case 0: goto noround1; - } -#endif - if (t00 & 0x200 && (t00 & 0x5ff || tlo)) - goto roundup1; - goto noround1; - } - if ((tlo & 0xfffffff0) | (t00 & 0x1ff) - && (nd <= 19 || ((t00 + (1ull << i)) & 0x7ffffffffffffe00ull) - == (t00 & 0x7ffffffffffffe00ull))) { - /* Unambiguous result. */ -#ifdef Honor_FLT_ROUNDS - switch(bc.rounding) { - case 0: goto noround1; - case 2: goto roundup1; - } -#endif - if (t00 & 0x200) { /* round up */ - roundup1: - t00 += 0x400; - if (!(t00 & 0x4000000000000000ull)) { - /* rounded up to a power of 2 */ - if (erv >= 0x7ff) - goto ovfl; - terv = erv; - LLval(&rv) = terv << 52; - goto ret; - } - } - noround1: - if (erv >= 0x800) - goto ovfl; - terv = erv - 1; - LLval(&rv) = (terv << 52) | ((t00 & 0x3ffffffffffffc00ull) >> 10); - goto ret; - } - } - many_digits: - Debug(++dtoa_stats[2]); - if (nd > 17) { - if (nd > 18) { - yz /= 100; - e1 += 2; - } - else { - yz /= 10; - e1 += 1; - } - y = yz / 100000000; - } - else if (nd > 9) { - i = nd - 9; - y = (yz >> i) / pfive[i-1]; - } - else - y = yz; - dval(&rv) = yz; -#endif /*}*/ - -#ifdef IEEE_Arith -#ifdef Avoid_Underflow - bc.scale = 0; -#endif -#endif /*IEEE_Arith*/ - - /* Get starting approximation = rv * 10**e1 */ - - if (e1 > 0) { - if ((i = e1 & 15)) - dval(&rv) *= tens[i]; - if (e1 &= ~15) { - if (e1 > DBL_MAX_10_EXP) { - ovfl: - /* Can't trust HUGE_VAL */ -#ifdef IEEE_Arith -#ifdef Honor_FLT_ROUNDS - switch(bc.rounding) { - case 0: /* toward 0 */ - case 3: /* toward -infinity */ - word0(&rv) = Big0; - word1(&rv) = Big1; - break; - default: - word0(&rv) = Exp_mask; - word1(&rv) = 0; - } -#else /*Honor_FLT_ROUNDS*/ - word0(&rv) = Exp_mask; - word1(&rv) = 0; -#endif /*Honor_FLT_ROUNDS*/ -#ifdef SET_INEXACT - /* set overflow bit */ - dval(&rv0) = 1e300; - dval(&rv0) *= dval(&rv0); -#endif -#else /*IEEE_Arith*/ - word0(&rv) = Big0; - word1(&rv) = Big1; -#endif /*IEEE_Arith*/ - range_err: - if (bd0) { - Bfree(bb MTb); - Bfree(bd MTb); - Bfree(bs MTb); - Bfree(bd0 MTb); - Bfree(delta MTb); - } - Set_errno(ERANGE); - goto ret; - } - e1 >>= 4; - for(j = 0; e1 > 1; j++, e1 >>= 1) - if (e1 & 1) - dval(&rv) *= bigtens[j]; - /* The last multiplication could overflow. */ - word0(&rv) -= P*Exp_msk1; - dval(&rv) *= bigtens[j]; - if ((z = word0(&rv) & Exp_mask) - > Exp_msk1*(DBL_MAX_EXP+Bias-P)) - goto ovfl; - if (z > Exp_msk1*(DBL_MAX_EXP+Bias-1-P)) { - /* set to largest number */ - /* (Can't trust DBL_MAX) */ - word0(&rv) = Big0; - word1(&rv) = Big1; - } - else - word0(&rv) += P*Exp_msk1; - } - } - else if (e1 < 0) { - e1 = -e1; - if ((i = e1 & 15)) - dval(&rv) /= tens[i]; - if (e1 >>= 4) { - if (e1 >= 1 << n_bigtens) - goto undfl; -#ifdef Avoid_Underflow - if (e1 & Scale_Bit) - bc.scale = 2*P; - for(j = 0; e1 > 0; j++, e1 >>= 1) - if (e1 & 1) - dval(&rv) *= tinytens[j]; - if (bc.scale && (j = 2*P + 1 - ((word0(&rv) & Exp_mask) - >> Exp_shift)) > 0) { - /* scaled rv is denormal; clear j low bits */ - if (j >= 32) { - if (j > 54) - goto undfl; - word1(&rv) = 0; - if (j >= 53) - word0(&rv) = (P+2)*Exp_msk1; - else - word0(&rv) &= 0xffffffff << (j-32); - } - else - word1(&rv) &= 0xffffffff << j; - } -#else - for(j = 0; e1 > 1; j++, e1 >>= 1) - if (e1 & 1) - dval(&rv) *= tinytens[j]; - /* The last multiplication could underflow. */ - dval(&rv0) = dval(&rv); - dval(&rv) *= tinytens[j]; - if (!dval(&rv)) { - dval(&rv) = 2.*dval(&rv0); - dval(&rv) *= tinytens[j]; -#endif - if (!dval(&rv)) { - undfl: - dval(&rv) = 0.; -#ifdef Honor_FLT_ROUNDS - if (bc.rounding == 2) - word1(&rv) = 1; -#endif - goto range_err; - } -#ifndef Avoid_Underflow - word0(&rv) = Tiny0; - word1(&rv) = Tiny1; - /* The refinement below will clean - * this approximation up. - */ - } -#endif - } - } - - /* Now the hard part -- adjusting rv to the correct value.*/ - - /* Put digits into bd: true value = bd * 10^e */ - - bc.nd = nd - nz1; -#ifndef NO_STRTOD_BIGCOMP - bc.nd0 = nd0; /* Only needed if nd > strtod_diglim, but done here */ - /* to silence an erroneous warning about bc.nd0 */ - /* possibly not being initialized. */ - if (nd > strtod_diglim) { - /* ASSERT(strtod_diglim >= 18); 18 == one more than the */ - /* minimum number of decimal digits to distinguish double values */ - /* in IEEE arithmetic. */ - i = j = 18; - if (i > nd0) - j += bc.dplen; - for(;;) { - if (--j < bc.dp1 && j >= bc.dp0) - j = bc.dp0 - 1; - if (s0[j] != '0') - break; - --i; - } - e += nd - i; - nd = i; - if (nd0 > nd) - nd0 = nd; - if (nd < 9) { /* must recompute y */ - y = 0; - for(i = 0; i < nd0; ++i) - y = 10*y + s0[i] - '0'; - for(j = bc.dp1; i < nd; ++i) - y = 10*y + s0[j++] - '0'; - } - } -#endif - bd0 = s2b(s0, nd0, nd, y, bc.dplen MTb); - - for(;;) { - bd = Balloc(bd0->k MTb); - Bcopy(bd, bd0); - bb = d2b(&rv, &bbe, &bbbits MTb); /* rv = bb * 2^bbe */ - bs = i2b(1 MTb); - - if (e >= 0) { - bb2 = bb5 = 0; - bd2 = bd5 = e; - } - else { - bb2 = bb5 = -e; - bd2 = bd5 = 0; - } - if (bbe >= 0) - bb2 += bbe; - else - bd2 -= bbe; - bs2 = bb2; -#ifdef Honor_FLT_ROUNDS - if (bc.rounding != 1) - bs2++; -#endif -#ifdef Avoid_Underflow - Lsb = LSB; - Lsb1 = 0; - j = bbe - bc.scale; - i = j + bbbits - 1; /* logb(rv) */ - j = P + 1 - bbbits; - if (i < Emin) { /* denormal */ - i = Emin - i; - j -= i; - if (i < 32) - Lsb <<= i; - else if (i < 52) - Lsb1 = Lsb << (i-32); - else - Lsb1 = Exp_mask; - } -#else /*Avoid_Underflow*/ -#ifdef Sudden_Underflow -#ifdef IBM - j = 1 + 4*P - 3 - bbbits + ((bbe + bbbits - 1) & 3); -#else - j = P + 1 - bbbits; -#endif -#else /*Sudden_Underflow*/ - j = bbe; - i = j + bbbits - 1; /* logb(rv) */ - if (i < Emin) /* denormal */ - j += P - Emin; - else - j = P + 1 - bbbits; -#endif /*Sudden_Underflow*/ -#endif /*Avoid_Underflow*/ - bb2 += j; - bd2 += j; -#ifdef Avoid_Underflow - bd2 += bc.scale; -#endif - i = bb2 < bd2 ? bb2 : bd2; - if (i > bs2) - i = bs2; - if (i > 0) { - bb2 -= i; - bd2 -= i; - bs2 -= i; - } - if (bb5 > 0) { - bs = pow5mult(bs, bb5 MTb); - bb1 = mult(bs, bb MTb); - Bfree(bb MTb); - bb = bb1; - } - if (bb2 > 0) - bb = lshift(bb, bb2 MTb); - if (bd5 > 0) - bd = pow5mult(bd, bd5 MTb); - if (bd2 > 0) - bd = lshift(bd, bd2 MTb); - if (bs2 > 0) - bs = lshift(bs, bs2 MTb); - delta = diff(bb, bd MTb); - bc.dsign = delta->sign; - delta->sign = 0; - i = cmp(delta, bs); -#ifndef NO_STRTOD_BIGCOMP /*{*/ - if (bc.nd > nd && i <= 0) { - if (bc.dsign) { - /* Must use bigcomp(). */ - req_bigcomp = 1; - break; - } -#ifdef Honor_FLT_ROUNDS - if (bc.rounding != 1) { - if (i < 0) { - req_bigcomp = 1; - break; - } - } - else -#endif - i = -1; /* Discarded digits make delta smaller. */ - } -#endif /*}*/ -#ifdef Honor_FLT_ROUNDS /*{*/ - if (bc.rounding != 1) { - if (i < 0) { - /* Error is less than an ulp */ - if (!delta->x[0] && delta->wds <= 1) { - /* exact */ -#ifdef SET_INEXACT - bc.inexact = 0; -#endif - break; - } - if (bc.rounding) { - if (bc.dsign) { - adj.d = 1.; - goto apply_adj; - } - } - else if (!bc.dsign) { - adj.d = -1.; - if (!word1(&rv) - && !(word0(&rv) & Frac_mask)) { - y = word0(&rv) & Exp_mask; -#ifdef Avoid_Underflow - if (!bc.scale || y > 2*P*Exp_msk1) -#else - if (y) -#endif - { - delta = lshift(delta,Log2P MTb); - if (cmp(delta, bs) <= 0) - adj.d = -0.5; - } - } - apply_adj: -#ifdef Avoid_Underflow /*{*/ - if (bc.scale && (y = word0(&rv) & Exp_mask) - <= 2*P*Exp_msk1) - word0(&adj) += (2*P+1)*Exp_msk1 - y; -#else -#ifdef Sudden_Underflow - if ((word0(&rv) & Exp_mask) <= - P*Exp_msk1) { - word0(&rv) += P*Exp_msk1; - dval(&rv) += adj.d*ulp(dval(&rv)); - word0(&rv) -= P*Exp_msk1; - } - else -#endif /*Sudden_Underflow*/ -#endif /*Avoid_Underflow}*/ - dval(&rv) += adj.d*ulp(&rv); - } - break; - } - adj.d = ratio(delta, bs); - if (adj.d < 1.) - adj.d = 1.; - if (adj.d <= 0x7ffffffe) { - /* adj = rounding ? ceil(adj) : floor(adj); */ - y = adj.d; - if (y != adj.d) { - if (!((bc.rounding>>1) ^ bc.dsign)) - y++; - adj.d = y; - } - } -#ifdef Avoid_Underflow /*{*/ - if (bc.scale && (y = word0(&rv) & Exp_mask) <= 2*P*Exp_msk1) - word0(&adj) += (2*P+1)*Exp_msk1 - y; -#else -#ifdef Sudden_Underflow - if ((word0(&rv) & Exp_mask) <= P*Exp_msk1) { - word0(&rv) += P*Exp_msk1; - adj.d *= ulp(dval(&rv)); - if (bc.dsign) - dval(&rv) += adj.d; - else - dval(&rv) -= adj.d; - word0(&rv) -= P*Exp_msk1; - goto cont; - } -#endif /*Sudden_Underflow*/ -#endif /*Avoid_Underflow}*/ - adj.d *= ulp(&rv); - if (bc.dsign) { - if (word0(&rv) == Big0 && word1(&rv) == Big1) - goto ovfl; - dval(&rv) += adj.d; - } - else - dval(&rv) -= adj.d; - goto cont; - } -#endif /*}Honor_FLT_ROUNDS*/ - - if (i < 0) { - /* Error is less than half an ulp -- check for - * special case of mantissa a power of two. - */ - if (bc.dsign || word1(&rv) || word0(&rv) & Bndry_mask -#ifdef IEEE_Arith /*{*/ -#ifdef Avoid_Underflow - || (word0(&rv) & Exp_mask) <= (2*P+1)*Exp_msk1 -#else - || (word0(&rv) & Exp_mask) <= Exp_msk1 -#endif -#endif /*}*/ - ) { -#ifdef SET_INEXACT - if (!delta->x[0] && delta->wds <= 1) - bc.inexact = 0; -#endif - break; - } - if (!delta->x[0] && delta->wds <= 1) { - /* exact result */ -#ifdef SET_INEXACT - bc.inexact = 0; -#endif - break; - } - delta = lshift(delta,Log2P MTb); - if (cmp(delta, bs) > 0) - goto drop_down; - break; - } - if (i == 0) { - /* exactly half-way between */ - if (bc.dsign) { - if ((word0(&rv) & Bndry_mask1) == Bndry_mask1 - && word1(&rv) == ( -#ifdef Avoid_Underflow - (bc.scale && (y = word0(&rv) & Exp_mask) <= 2*P*Exp_msk1) - ? (0xffffffff & (0xffffffff << (2*P+1-(y>>Exp_shift)))) : -#endif - 0xffffffff)) { - /*boundary case -- increment exponent*/ - if (word0(&rv) == Big0 && word1(&rv) == Big1) - goto ovfl; - word0(&rv) = (word0(&rv) & Exp_mask) - + Exp_msk1 -#ifdef IBM - | Exp_msk1 >> 4 -#endif - ; - word1(&rv) = 0; -#ifdef Avoid_Underflow - bc.dsign = 0; -#endif - break; - } - } - else if (!(word0(&rv) & Bndry_mask) && !word1(&rv)) { - drop_down: - /* boundary case -- decrement exponent */ -#ifdef Sudden_Underflow /*{{*/ - L = word0(&rv) & Exp_mask; -#ifdef IBM - if (L < Exp_msk1) -#else -#ifdef Avoid_Underflow - if (L <= (bc.scale ? (2*P+1)*Exp_msk1 : Exp_msk1)) -#else - if (L <= Exp_msk1) -#endif /*Avoid_Underflow*/ -#endif /*IBM*/ - { - if (bc.nd >nd) { - bc.uflchk = 1; - break; - } - goto undfl; - } - L -= Exp_msk1; -#else /*Sudden_Underflow}{*/ -#ifdef Avoid_Underflow - if (bc.scale) { - L = word0(&rv) & Exp_mask; - if (L <= (2*P+1)*Exp_msk1) { - if (L > (P+2)*Exp_msk1) - /* round even ==> */ - /* accept rv */ - break; - /* rv = smallest denormal */ - if (bc.nd >nd) { - bc.uflchk = 1; - break; - } - goto undfl; - } - } -#endif /*Avoid_Underflow*/ - L = (word0(&rv) & Exp_mask) - Exp_msk1; -#endif /*Sudden_Underflow}}*/ - word0(&rv) = L | Bndry_mask1; - word1(&rv) = 0xffffffff; -#ifdef IBM - goto cont; -#else -#ifndef NO_STRTOD_BIGCOMP - if (bc.nd > nd) - goto cont; -#endif - break; -#endif - } -#ifndef ROUND_BIASED -#ifdef Avoid_Underflow - if (Lsb1) { - if (!(word0(&rv) & Lsb1)) - break; - } - else if (!(word1(&rv) & Lsb)) - break; -#else - if (!(word1(&rv) & LSB)) - break; -#endif -#endif - if (bc.dsign) -#ifdef Avoid_Underflow - dval(&rv) += sulp(&rv, &bc); -#else - dval(&rv) += ulp(&rv); -#endif -#ifndef ROUND_BIASED - else { -#ifdef Avoid_Underflow - dval(&rv) -= sulp(&rv, &bc); -#else - dval(&rv) -= ulp(&rv); -#endif -#ifndef Sudden_Underflow - if (!dval(&rv)) { - if (bc.nd >nd) { - bc.uflchk = 1; - break; - } - goto undfl; - } -#endif - } -#ifdef Avoid_Underflow - bc.dsign = 1 - bc.dsign; -#endif -#endif - break; - } - if ((aadj = ratio(delta, bs)) <= 2.) { - if (bc.dsign) - aadj = aadj1 = 1.; - else if (word1(&rv) || word0(&rv) & Bndry_mask) { -#ifndef Sudden_Underflow - if (word1(&rv) == Tiny1 && !word0(&rv)) { - if (bc.nd >nd) { - bc.uflchk = 1; - break; - } - goto undfl; - } -#endif - aadj = 1.; - aadj1 = -1.; - } - else { - /* special case -- power of FLT_RADIX to be */ - /* rounded down... */ - - if (aadj < 2./FLT_RADIX) - aadj = 1./FLT_RADIX; - else - aadj *= 0.5; - aadj1 = -aadj; - } - } - else { - aadj *= 0.5; - aadj1 = bc.dsign ? aadj : -aadj; -#ifdef Check_FLT_ROUNDS - switch(bc.rounding) { - case 2: /* towards +infinity */ - aadj1 -= 0.5; - break; - case 0: /* towards 0 */ - case 3: /* towards -infinity */ - aadj1 += 0.5; - } -#else - if (Flt_Rounds == 0) - aadj1 += 0.5; -#endif /*Check_FLT_ROUNDS*/ - } - y = word0(&rv) & Exp_mask; - - /* Check for overflow */ - - if (y == Exp_msk1*(DBL_MAX_EXP+Bias-1)) { - dval(&rv0) = dval(&rv); - word0(&rv) -= P*Exp_msk1; - adj.d = aadj1 * ulp(&rv); - dval(&rv) += adj.d; - if ((word0(&rv) & Exp_mask) >= - Exp_msk1*(DBL_MAX_EXP+Bias-P)) { - if (word0(&rv0) == Big0 && word1(&rv0) == Big1) - goto ovfl; - word0(&rv) = Big0; - word1(&rv) = Big1; - goto cont; - } - else - word0(&rv) += P*Exp_msk1; - } - else { -#ifdef Avoid_Underflow - if (bc.scale && y <= 2*P*Exp_msk1) { - if (aadj <= 0x7fffffff) { - if ((z = aadj) <= 0) - z = 1; - aadj = z; - aadj1 = bc.dsign ? aadj : -aadj; - } - dval(&aadj2) = aadj1; - word0(&aadj2) += (2*P+1)*Exp_msk1 - y; - aadj1 = dval(&aadj2); - adj.d = aadj1 * ulp(&rv); - dval(&rv) += adj.d; - if (rv.d == 0.) -#ifdef NO_STRTOD_BIGCOMP - goto undfl; -#else - { - req_bigcomp = 1; - break; - } -#endif - } - else { - adj.d = aadj1 * ulp(&rv); - dval(&rv) += adj.d; - } -#else -#ifdef Sudden_Underflow - if ((word0(&rv) & Exp_mask) <= P*Exp_msk1) { - dval(&rv0) = dval(&rv); - word0(&rv) += P*Exp_msk1; - adj.d = aadj1 * ulp(&rv); - dval(&rv) += adj.d; -#ifdef IBM - if ((word0(&rv) & Exp_mask) < P*Exp_msk1) -#else - if ((word0(&rv) & Exp_mask) <= P*Exp_msk1) -#endif - { - if (word0(&rv0) == Tiny0 - && word1(&rv0) == Tiny1) { - if (bc.nd >nd) { - bc.uflchk = 1; - break; - } - goto undfl; - } - word0(&rv) = Tiny0; - word1(&rv) = Tiny1; - goto cont; - } - else - word0(&rv) -= P*Exp_msk1; - } - else { - adj.d = aadj1 * ulp(&rv); - dval(&rv) += adj.d; - } -#else /*Sudden_Underflow*/ - /* Compute adj so that the IEEE rounding rules will - * correctly round rv + adj in some half-way cases. - * If rv * ulp(rv) is denormalized (i.e., - * y <= (P-1)*Exp_msk1), we must adjust aadj to avoid - * trouble from bits lost to denormalization; - * example: 1.2e-307 . - */ - if (y <= (P-1)*Exp_msk1 && aadj > 1.) { - aadj1 = (double)(int)(aadj + 0.5); - if (!bc.dsign) - aadj1 = -aadj1; - } - adj.d = aadj1 * ulp(&rv); - dval(&rv) += adj.d; -#endif /*Sudden_Underflow*/ -#endif /*Avoid_Underflow*/ - } - z = word0(&rv) & Exp_mask; -#ifndef SET_INEXACT - if (bc.nd == nd) { -#ifdef Avoid_Underflow - if (!bc.scale) -#endif - if (y == z) { - /* Can we stop now? */ - L = (Long)aadj; - aadj -= L; - /* The tolerances below are conservative. */ - if (bc.dsign || word1(&rv) || word0(&rv) & Bndry_mask) { - if (aadj < .4999999 || aadj > .5000001) - break; - } - else if (aadj < .4999999/FLT_RADIX) - break; - } - } -#endif - cont: - Bfree(bb MTb); - Bfree(bd MTb); - Bfree(bs MTb); - Bfree(delta MTb); - } - Bfree(bb MTb); - Bfree(bd MTb); - Bfree(bs MTb); - Bfree(bd0 MTb); - Bfree(delta MTb); -#ifndef NO_STRTOD_BIGCOMP - if (req_bigcomp) { - bd0 = 0; - bc.e0 += nz1; - bigcomp(&rv, s0, &bc MTb); - y = word0(&rv) & Exp_mask; - if (y == Exp_mask) - goto ovfl; - if (y == 0 && rv.d == 0.) - goto undfl; - } -#endif -#ifdef Avoid_Underflow - if (bc.scale) { - word0(&rv0) = Exp_1 - 2*P*Exp_msk1; - word1(&rv0) = 0; - dval(&rv) *= dval(&rv0); -#ifndef NO_ERRNO - /* try to avoid the bug of testing an 8087 register value */ -#ifdef IEEE_Arith - if (!(word0(&rv) & Exp_mask)) -#else - if (word0(&rv) == 0 && word1(&rv) == 0) -#endif - Set_errno(ERANGE); -#endif - } -#endif /* Avoid_Underflow */ - ret: -#ifdef SET_INEXACT - if (bc.inexact) { - if (!(word0(&rv) & Exp_mask)) { - /* set underflow and inexact bits */ - dval(&rv0) = 1e-300; - dval(&rv0) *= dval(&rv0); - } - else if (!oldinexact) { - word0(&rv0) = Exp_1 + (70 << Exp_shift); - word1(&rv0) = 0; - dval(&rv0) += 1.; - } - } - else if (!oldinexact) - clear_inexact(); -#endif - if (se) - *se = (char *)s; - return sign ? -dval(&rv) : dval(&rv); - } - -#ifndef MULTIPLE_THREADS - static char *dtoa_result; -#endif - - static char * -rv_alloc(int i MTd) -{ - int j, k, *r; - - j = sizeof(ULong); - for(k = 0; - sizeof(Bigint) - sizeof(ULong) - sizeof(int) + j <= i; - j <<= 1) - k++; - r = (int*)Balloc(k MTa); - *r = k; - return -#ifndef MULTIPLE_THREADS - dtoa_result = -#endif - (char *)(r+1); - } - - static char * -nrv_alloc(const char *s, char *s0, size_t s0len, char **rve, int n MTd) -{ - char *rv, *t; - - if (!s0) - s0 = rv_alloc(n MTa); - else if (s0len <= n) { - rv = 0; - t = rv + n; - goto rve_chk; - } - t = rv = s0; - while((*t = *s++)) - ++t; - rve_chk: - if (rve) - *rve = t; - return rv; - } - -/* freedtoa(s) must be used to free values s returned by dtoa - * when MULTIPLE_THREADS is #defined. It should be used in all cases, - * but for consistency with earlier versions of dtoa, it is optional - * when MULTIPLE_THREADS is not defined. - */ - - void -freedtoa(char *s) -{ -#ifdef MULTIPLE_THREADS - ThInfo *TI = 0; -#endif - Bigint *b = (Bigint *)((int *)s - 1); - b->maxwds = 1 << (b->k = *(int*)b); - Bfree(b MTb); -#ifndef MULTIPLE_THREADS - if (s == dtoa_result) - dtoa_result = 0; -#endif - } - -/* dtoa for IEEE arithmetic (dmg): convert double to ASCII string. - * - * Inspired by "How to Print Floating-Point Numbers Accurately" by - * Guy L. Steele, Jr. and Jon L. White [Proc. ACM SIGPLAN '90, pp. 112-126]. - * - * Modifications: - * 1. Rather than iterating, we use a simple numeric overestimate - * to determine k = floor(log10(d)). We scale relevant - * quantities using O(log2(k)) rather than O(k) multiplications. - * 2. For some modes > 2 (corresponding to ecvt and fcvt), we don't - * try to generate digits strictly left to right. Instead, we - * compute with fewer bits and propagate the carry if necessary - * when rounding the final digit up. This is often faster. - * 3. Under the assumption that input will be rounded nearest, - * mode 0 renders 1e23 as 1e23 rather than 9.999999999999999e22. - * That is, we allow equality in stopping tests when the - * round-nearest rule will give the same floating-point value - * as would satisfaction of the stopping test with strict - * inequality. - * 4. We remove common factors of powers of 2 from relevant - * quantities. - * 5. When converting floating-point integers less than 1e16, - * we use floating-point arithmetic rather than resorting - * to multiple-precision integers. - * 6. When asked to produce fewer than 15 digits, we first try - * to get by with floating-point arithmetic; we resort to - * multiple-precision integer arithmetic only if we cannot - * guarantee that the floating-point calculation has given - * the correctly rounded result. For k requested digits and - * "uniformly" distributed input, the probability is - * something like 10^(k-15) that we must resort to the Long - * calculation. - */ - - char * -dtoa_r(double dd, int mode, int ndigits, int *decpt, int *sign, char **rve, char *buf, size_t blen) -{ - /* Arguments ndigits, decpt, sign are similar to those - of ecvt and fcvt; trailing zeros are suppressed from - the returned string. If not null, *rve is set to point - to the end of the return value. If d is +-Infinity or NaN, - then *decpt is set to 9999. - - mode: - 0 ==> shortest string that yields d when read in - and rounded to nearest. - 1 ==> like 0, but with Steele & White stopping rule; - e.g. with IEEE P754 arithmetic , mode 0 gives - 1e23 whereas mode 1 gives 9.999999999999999e22. - 2 ==> max(1,ndigits) significant digits. This gives a - return value similar to that of ecvt, except - that trailing zeros are suppressed. - 3 ==> through ndigits past the decimal point. This - gives a return value similar to that from fcvt, - except that trailing zeros are suppressed, and - ndigits can be negative. - 4,5 ==> similar to 2 and 3, respectively, but (in - round-nearest mode) with the tests of mode 0 to - possibly return a shorter string that rounds to d. - With IEEE arithmetic and compilation with - -DHonor_FLT_ROUNDS, modes 4 and 5 behave the same - as modes 2 and 3 when FLT_ROUNDS != 1. - 6-9 ==> Debugging modes similar to mode - 4: don't try - fast floating-point estimate (if applicable). - - Values of mode other than 0-9 are treated as mode 0. - - When not NULL, buf is an output buffer of length blen, which must - be large enough to accommodate suppressed trailing zeros and a trailing - null byte. If blen is too small, rv = NULL is returned, in which case - if rve is not NULL, a subsequent call with blen >= (*rve - rv) + 1 - should succeed in returning buf. - - When buf is NULL, sufficient space is allocated for the return value, - which, when done using, the caller should pass to freedtoa(). - - USE_BF is automatically defined when neither NO_LONG_LONG nor NO_BF96 - is defined. - */ - -#ifdef MULTIPLE_THREADS - ThInfo *TI = 0; -#endif - int bbits, b2, b5, be, dig, i, ilim, ilim1, - j, j1, k, leftright, m2, m5, s2, s5, spec_case; -#if !defined(Sudden_Underflow) || defined(USE_BF96) - int denorm; -#endif - Bigint *b, *b1, *delta, *mlo, *mhi, *S; - U u; - char *s; -#ifdef SET_INEXACT - int inexact, oldinexact; -#endif -#ifdef USE_BF96 /*{{*/ - BF96 *p10; - ULLong dbhi, dbits, dblo, den, hb, rb, rblo, res, res0, res3, reslo, sres, - sulp, tv0, tv1, tv2, tv3, ulp, ulplo, ulpmask, ures, ureslo, zb; - int eulp, k1, n2, ulpadj, ulpshift; -#else /*}{*/ -#ifndef Sudden_Underflow - ULong x; -#endif - Long L; - U d2, eps; - double ds; - int ieps, ilim0, k0, k_check, try_quick; -#ifndef No_leftright -#ifdef IEEE_Arith - U eps1; -#endif -#endif -#endif /*}}*/ -#ifdef Honor_FLT_ROUNDS /*{*/ - int Rounding; -#ifdef Trust_FLT_ROUNDS /*{{ only define this if FLT_ROUNDS really works! */ - Rounding = Flt_Rounds; -#else /*}{*/ - Rounding = 1; - switch(fegetround()) { - case FE_TOWARDZERO: Rounding = 0; break; - case FE_UPWARD: Rounding = 2; break; - case FE_DOWNWARD: Rounding = 3; - } -#endif /*}}*/ -#endif /*}*/ - - u.d = dd; - if (word0(&u) & Sign_bit) { - /* set sign for everything, including 0's and NaNs */ - *sign = 1; - word0(&u) &= ~Sign_bit; /* clear sign bit */ - } - else - *sign = 0; - -#if defined(IEEE_Arith) + defined(VAX) -#ifdef IEEE_Arith - if ((word0(&u) & Exp_mask) == Exp_mask) -#else - if (word0(&u) == 0x8000) -#endif - { - /* Infinity or NaN */ - *decpt = 9999; -#ifdef IEEE_Arith - if (!word1(&u) && !(word0(&u) & 0xfffff)) - return nrv_alloc("Infinity", buf, blen, rve, 8 MTb); -#endif - return nrv_alloc("NaN", buf, blen, rve, 3 MTb); - } -#endif -#ifdef IBM - dval(&u) += 0; /* normalize */ -#endif - if (!dval(&u)) { - *decpt = 1; - return nrv_alloc("0", buf, blen, rve, 1 MTb); - } - -#ifdef SET_INEXACT -#ifndef USE_BF96 - try_quick = -#endif - oldinexact = get_inexact(); - inexact = 1; -#endif -#ifdef Honor_FLT_ROUNDS - if (Rounding >= 2) { - if (*sign) - Rounding = Rounding == 2 ? 0 : 2; - else - if (Rounding != 2) - Rounding = 0; - } -#endif -#ifdef USE_BF96 /*{{*/ - dbits = (u.LL & 0xfffffffffffffull) << 11; /* fraction bits */ - if ((be = u.LL >> 52)) /* biased exponent; nonzero ==> normal */ { - dbits |= 0x8000000000000000ull; - denorm = ulpadj = 0; - } - else { - denorm = 1; - ulpadj = be + 1; - dbits <<= 1; - if (!(dbits & 0xffffffff00000000ull)) { - dbits <<= 32; - be -= 32; - } - if (!(dbits & 0xffff000000000000ull)) { - dbits <<= 16; - be -= 16; - } - if (!(dbits & 0xff00000000000000ull)) { - dbits <<= 8; - be -= 8; - } - if (!(dbits & 0xf000000000000000ull)) { - dbits <<= 4; - be -= 4; - } - if (!(dbits & 0xc000000000000000ull)) { - dbits <<= 2; - be -= 2; - } - if (!(dbits & 0x8000000000000000ull)) { - dbits <<= 1; - be -= 1; - } - assert(be >= -51); - ulpadj -= be; - } - j = Lhint[be + 51]; - p10 = &pten[j]; - dbhi = dbits >> 32; - dblo = dbits & 0xffffffffull; - i = be - 0x3fe; - if (i < p10->e - || (i == p10->e && (dbhi < p10->b0 || (dbhi == p10->b0 && dblo < p10->b1)))) - --j; - k = j - 342; - - /* now 10^k <= dd < 10^(k+1) */ - -#else /*}{*/ - - b = d2b(&u, &be, &bbits MTb); -#ifdef Sudden_Underflow - i = (int)(word0(&u) >> Exp_shift1 & (Exp_mask>>Exp_shift1)); -#else - if ((i = (int)(word0(&u) >> Exp_shift1 & (Exp_mask>>Exp_shift1)))) { -#endif - dval(&d2) = dval(&u); - word0(&d2) &= Frac_mask1; - word0(&d2) |= Exp_11; -#ifdef IBM - if (j = 11 - hi0bits(word0(&d2) & Frac_mask)) - dval(&d2) /= 1 << j; -#endif - - /* log(x) ~=~ log(1.5) + (x-1.5)/1.5 - * log10(x) = log(x) / log(10) - * ~=~ log(1.5)/log(10) + (x-1.5)/(1.5*log(10)) - * log10(d) = (i-Bias)*log(2)/log(10) + log10(d2) - * - * This suggests computing an approximation k to log10(d) by - * - * k = (i - Bias)*0.301029995663981 - * + ( (d2-1.5)*0.289529654602168 + 0.176091259055681 ); - * - * We want k to be too large rather than too small. - * The error in the first-order Taylor series approximation - * is in our favor, so we just round up the constant enough - * to compensate for any error in the multiplication of - * (i - Bias) by 0.301029995663981; since |i - Bias| <= 1077, - * and 1077 * 0.30103 * 2^-52 ~=~ 7.2e-14, - * adding 1e-13 to the constant term more than suffices. - * Hence we adjust the constant term to 0.1760912590558. - * (We could get a more accurate k by invoking log10, - * but this is probably not worthwhile.) - */ - - i -= Bias; -#ifdef IBM - i <<= 2; - i += j; -#endif -#ifndef Sudden_Underflow - denorm = 0; - } - else { - /* d is denormalized */ - - i = bbits + be + (Bias + (P-1) - 1); - x = i > 32 ? word0(&u) << (64 - i) | word1(&u) >> (i - 32) - : word1(&u) << (32 - i); - dval(&d2) = x; - word0(&d2) -= 31*Exp_msk1; /* adjust exponent */ - i -= (Bias + (P-1) - 1) + 1; - denorm = 1; - } -#endif - ds = (dval(&d2)-1.5)*0.289529654602168 + 0.1760912590558 + i*0.301029995663981; - k = (int)ds; - if (ds < 0. && ds != k) - k--; /* want k = floor(ds) */ - k_check = 1; - if (k >= 0 && k <= Ten_pmax) { - if (dval(&u) < tens[k]) - k--; - k_check = 0; - } - j = bbits - i - 1; - if (j >= 0) { - b2 = 0; - s2 = j; - } - else { - b2 = -j; - s2 = 0; - } - if (k >= 0) { - b5 = 0; - s5 = k; - s2 += k; - } - else { - b2 -= k; - b5 = -k; - s5 = 0; - } -#endif /*}}*/ - if (mode < 0 || mode > 9) - mode = 0; - -#ifndef USE_BF96 -#ifndef SET_INEXACT -#ifdef Check_FLT_ROUNDS - try_quick = Rounding == 1; -#else - try_quick = 1; -#endif -#endif /*SET_INEXACT*/ -#endif /*USE_BF96*/ - - if (mode > 5) { - mode -= 4; -#ifndef USE_BF96 - try_quick = 0; -#endif - } - leftright = 1; - ilim = ilim1 = -1; /* Values for cases 0 and 1; done here to */ - /* silence erroneous "gcc -Wall" warning. */ - switch(mode) { - case 0: - case 1: - i = 18; - ndigits = 0; - break; - case 2: - leftright = 0; - /* no break */ - case 4: - if (ndigits <= 0) - ndigits = 1; - ilim = ilim1 = i = ndigits; - break; - case 3: - leftright = 0; - /* no break */ - case 5: - i = ndigits + k + 1; - ilim = i; - ilim1 = i - 1; - if (i <= 0) - i = 1; - } - if (!buf) { - buf = rv_alloc(i MTb); - blen = sizeof(Bigint) + ((1 << ((int*)buf)[-1]) - 1)*sizeof(ULong) - sizeof(int); - } - else if (blen <= i) { - buf = 0; - if (rve) - *rve = buf + i; - return buf; - } - s = buf; - - /* Check for special case that d is a normalized power of 2. */ - - spec_case = 0; - if (mode < 2 || (leftright -#ifdef Honor_FLT_ROUNDS - && Rounding == 1 -#endif - )) { - if (!word1(&u) && !(word0(&u) & Bndry_mask) -#ifndef Sudden_Underflow - && word0(&u) & (Exp_mask & ~Exp_msk1) -#endif - ) { - /* The special case */ - spec_case = 1; - } - } - -#ifdef USE_BF96 /*{*/ - b = 0; - if (ilim < 0 && (mode == 3 || mode == 5)) { - S = mhi = 0; - goto no_digits; - } - i = 1; - j = 52 + 0x3ff - be; - ulpshift = 0; - ulplo = 0; - /* Can we do an exact computation with 64-bit integer arithmetic? */ - if (k < 0) { - if (k < -25) - goto toobig; - res = dbits >> 11; - n2 = pfivebits[k1 = -(k + 1)] + 53; - j1 = j; - if (n2 > 61) { - ulpshift = n2 - 61; - if (res & (ulpmask = (1ull << ulpshift) - 1)) - goto toobig; - j -= ulpshift; - res >>= ulpshift; - } - /* Yes. */ - res *= ulp = pfive[k1]; - if (ulpshift) { - ulplo = ulp; - ulp >>= ulpshift; - } - j += k; - if (ilim == 0) { - S = mhi = 0; - if (res > (5ull << j)) - goto one_digit; - goto no_digits; - } - goto no_div; - } - if (ilim == 0 && j + k >= 0) { - S = mhi = 0; - if ((dbits >> 11) > (pfive[k-1] << j)) - goto one_digit; - goto no_digits; - } - if (k <= dtoa_divmax && j + k >= 0) { - /* Another "yes" case -- we will use exact integer arithmetic. */ - use_exact: - Debug(++dtoa_stats[3]); - res = dbits >> 11; /* residual */ - ulp = 1; - if (k <= 0) - goto no_div; - j1 = j + k + 1; - den = pfive[k-i] << (j1 - i); - for(;;) { - dig = res / den; - *s++ = '0' + dig; - if (!(res -= dig*den)) { -#ifdef SET_INEXACT - inexact = 0; - oldinexact = 1; -#endif - goto retc; - } - if (ilim < 0) { - ures = den - res; - if (2*res <= ulp - && (spec_case ? 4*res <= ulp : (2*res < ulp || dig & 1))) - goto ulp_reached; - if (2*ures < ulp) - goto Roundup; - } - else if (i == ilim) { - switch(Rounding) { - case 0: goto retc; - case 2: goto Roundup; - } - ures = 2*res; - if (ures > den - || (ures == den && dig & 1) - || (spec_case && res <= ulp && 2*res >= ulp)) - goto Roundup; - goto retc; - } - if (j1 < ++i) { - res *= 10; - ulp *= 10; - } - else { - if (i > k) - break; - den = pfive[k-i] << (j1 - i); - } - } - no_div: - for(;;) { - dig = den = res >> j; - *s++ = '0' + dig; - if (!(res -= den << j)) { -#ifdef SET_INEXACT - inexact = 0; - oldinexact = 1; -#endif - goto retc; - } - if (ilim < 0) { - ures = (1ull << j) - res; - if (2*res <= ulp - && (spec_case ? 4*res <= ulp : (2*res < ulp || dig & 1))) { - ulp_reached: - if (ures < res - || (ures == res && dig & 1) - || (dig == 9 && 2*ures <= ulp)) - goto Roundup; - goto retc; - } - if (2*ures < ulp) - goto Roundup; - } - --j; - if (i == ilim) { -#ifdef Honor_FLT_ROUNDS - switch(Rounding) { - case 0: goto retc; - case 2: goto Roundup; - } -#endif - hb = 1ull << j; - if (res & hb && (dig & 1 || res & (hb-1))) - goto Roundup; - if (spec_case && res <= ulp && 2*res >= ulp) { - Roundup: - while(*--s == '9') - if (s == buf) { - ++k; - *s++ = '1'; - goto ret1; - } - ++*s++; - goto ret1; - } - goto retc; - } - ++i; - res *= 5; - if (ulpshift) { - ulplo = 5*(ulplo & ulpmask); - ulp = 5*ulp + (ulplo >> ulpshift); - } - else - ulp *= 5; - } - } - toobig: - if (ilim > 28) - goto Fast_failed1; - /* Scale by 10^-k */ - p10 = &pten[342-k]; - tv0 = p10->b2 * dblo; /* rarely matters, but does, e.g., for 9.862818194192001e18 */ - tv1 = p10->b1 * dblo + (tv0 >> 32); - tv2 = p10->b2 * dbhi + (tv1 & 0xffffffffull); - tv3 = p10->b0 * dblo + (tv1>>32) + (tv2>>32); - res3 = p10->b1 * dbhi + (tv3 & 0xffffffffull); - res = p10->b0 * dbhi + (tv3>>32) + (res3>>32); - be += p10->e - 0x3fe; - eulp = j1 = be - 54 + ulpadj; - if (!(res & 0x8000000000000000ull)) { - --be; - res3 <<= 1; - res = (res << 1) | ((res3 & 0x100000000ull) >> 32); - } - res0 = res; /* save for Fast_failed */ -#if !defined(SET_INEXACT) && !defined(NO_DTOA_64) /*{*/ - if (ilim > 19) - goto Fast_failed; - Debug(++dtoa_stats[4]); - assert(be >= 0 && be <= 4); /* be = 0 is rare, but possible, e.g., for 1e20 */ - res >>= 4 - be; - ulp = p10->b0; /* ulp */ - ulp = (ulp << 29) | (p10->b1 >> 3); - /* scaled ulp = ulp * 2^(eulp - 60) */ - /* We maintain 61 bits of the scaled ulp. */ - if (ilim == 0) { - if (!(res & 0x7fffffffffffffeull) - || !((~res) & 0x7fffffffffffffeull)) - goto Fast_failed1; - S = mhi = 0; - if (res >= 0x5000000000000000ull) - goto one_digit; - goto no_digits; - } - rb = 1; /* upper bound on rounding error */ - for(;;++i) { - dig = res >> 60; - *s++ = '0' + dig; - res &= 0xfffffffffffffffull; - if (ilim < 0) { - ures = 0x1000000000000000ull - res; - if (eulp > 0) { - assert(eulp <= 4); - sulp = ulp << (eulp - 1); - if (res <= ures) { - if (res + rb > ures - rb) - goto Fast_failed; - if (res < sulp) - goto retc; - } - else { - if (res - rb <= ures + rb) - goto Fast_failed; - if (ures < sulp) - goto Roundup; - } - } - else { - zb = -(1ull << (eulp + 63)); - if (!(zb & res)) { - sres = res << (1 - eulp); - if (sres < ulp && (!spec_case || 2*sres < ulp)) { - if ((res+rb) << (1 - eulp) >= ulp) - goto Fast_failed; - if (ures < res) { - if (ures + rb >= res - rb) - goto Fast_failed; - goto Roundup; - } - if (ures - rb < res + rb) - goto Fast_failed; - goto retc; - } - } - if (!(zb & ures) && ures << -eulp < ulp) { - if (ures << (1 - eulp) < ulp) - goto Roundup; - goto Fast_failed; - } - } - } - else if (i == ilim) { - ures = 0x1000000000000000ull - res; - if (ures < res) { - if (ures <= rb || res - rb <= ures + rb) { - if (j + k >= 0 && k >= 0 && k <= 27) - goto use_exact1; - goto Fast_failed; - } -#ifdef Honor_FLT_ROUNDS - if (Rounding == 0) - goto retc; -#endif - goto Roundup; - } - if (res <= rb || ures - rb <= res + rb) { - if (j + k >= 0 && k >= 0 && k <= 27) { - use_exact1: - s = buf; - i = 1; - goto use_exact; - } - goto Fast_failed; - } -#ifdef Honor_FLT_ROUNDS - if (Rounding == 2) - goto Roundup; -#endif - goto retc; - } - rb *= 10; - if (rb >= 0x1000000000000000ull) - goto Fast_failed; - res *= 10; - ulp *= 5; - if (ulp & 0x8000000000000000ull) { - eulp += 4; - ulp >>= 3; - } - else { - eulp += 3; - ulp >>= 2; - } - } -#endif /*}*/ -#ifndef NO_BF96 - Fast_failed: -#endif - Debug(++dtoa_stats[5]); - s = buf; - i = 4 - be; - res = res0 >> i; - reslo = 0xffffffffull & res3; - if (i) - reslo = (res0 << (64 - i)) >> 32 | (reslo >> i); - rb = 0; - rblo = 4; /* roundoff bound */ - ulp = p10->b0; /* ulp */ - ulp = (ulp << 29) | (p10->b1 >> 3); - eulp = j1; - for(i = 1;;++i) { - dig = res >> 60; - *s++ = '0' + dig; - res &= 0xfffffffffffffffull; -#ifdef SET_INEXACT - if (!res && !reslo) { - if (!(res3 & 0xffffffffull)) { - inexact = 0; - oldinexact = 1; - } - goto retc; - } -#endif - if (ilim < 0) { - ures = 0x1000000000000000ull - res; - ureslo = 0; - if (reslo) { - ureslo = 0x100000000ull - reslo; - --ures; - } - if (eulp > 0) { - assert(eulp <= 4); - sulp = (ulp << (eulp - 1)) - rb; - if (res <= ures) { - if (res < sulp) { - if (res+rb < ures-rb) - goto retc; - } - } - else if (ures < sulp) { - if (res-rb > ures+rb) - goto Roundup; - } - goto Fast_failed1; - } - else { - zb = -(1ull << (eulp + 60)); - if (!(zb & (res + rb))) { - sres = (res - rb) << (1 - eulp); - if (sres < ulp && (!spec_case || 2*sres < ulp)) { - sres = res << (1 - eulp); - if ((j = eulp + 31) > 0) - sres += (rblo + reslo) >> j; - else - sres += (rblo + reslo) << -j; - if (sres + (rb << (1 - eulp)) >= ulp) - goto Fast_failed1; - if (sres >= ulp) - goto more96; - if (ures < res - || (ures == res && ureslo < reslo)) { - if (ures + rb >= res - rb) - goto Fast_failed1; - goto Roundup; - } - if (ures - rb <= res + rb) - goto Fast_failed1; - goto retc; - } - } - if (!(zb & ures) && (ures-rb) << (1 - eulp) < ulp) { - if ((ures + rb) << (2 - eulp) < ulp) - goto Roundup; - goto Fast_failed1; - } - } - } - else if (i == ilim) { - ures = 0x1000000000000000ull - res; - sres = ureslo = 0; - if (reslo) { - ureslo = 0x100000000ull - reslo; - --ures; - sres = (reslo + rblo) >> 31; - } - sres += 2*rb; - if (ures <= res) { - if (ures <=sres || res - ures <= sres) - goto Fast_failed1; -#ifdef Honor_FLT_ROUNDS - if (Rounding == 0) - goto retc; -#endif - goto Roundup; - } - if (res <= sres || ures - res <= sres) - goto Fast_failed1; -#ifdef Honor_FLT_ROUNDS - if (Rounding == 2) - goto Roundup; -#endif - goto retc; - } - more96: - rblo *= 10; - rb = 10*rb + (rblo >> 32); - rblo &= 0xffffffffull; - if (rb >= 0x1000000000000000ull) - goto Fast_failed1; - reslo *= 10; - res = 10*res + (reslo >> 32); - reslo &= 0xffffffffull; - ulp *= 5; - if (ulp & 0x8000000000000000ull) { - eulp += 4; - ulp >>= 3; - } - else { - eulp += 3; - ulp >>= 2; - } - } - Fast_failed1: - Debug(++dtoa_stats[6]); - S = mhi = mlo = 0; -#ifdef USE_BF96 - b = d2b(&u, &be, &bbits MTb); -#endif - s = buf; - i = (int)(word0(&u) >> Exp_shift1 & (Exp_mask>>Exp_shift1)); - i -= Bias; - if (ulpadj) - i -= ulpadj - 1; - j = bbits - i - 1; - if (j >= 0) { - b2 = 0; - s2 = j; - } - else { - b2 = -j; - s2 = 0; - } - if (k >= 0) { - b5 = 0; - s5 = k; - s2 += k; - } - else { - b2 -= k; - b5 = -k; - s5 = 0; - } -#endif /*}*/ - -#ifdef Honor_FLT_ROUNDS - if (mode > 1 && Rounding != 1) - leftright = 0; -#endif - -#ifndef USE_BF96 /*{*/ - if (ilim >= 0 && ilim <= Quick_max && try_quick) { - - /* Try to get by with floating-point arithmetic. */ - - i = 0; - dval(&d2) = dval(&u); - j1 = -(k0 = k); - ilim0 = ilim; - ieps = 2; /* conservative */ - if (k > 0) { - ds = tens[k&0xf]; - j = k >> 4; - if (j & Bletch) { - /* prevent overflows */ - j &= Bletch - 1; - dval(&u) /= bigtens[n_bigtens-1]; - ieps++; - } - for(; j; j >>= 1, i++) - if (j & 1) { - ieps++; - ds *= bigtens[i]; - } - dval(&u) /= ds; - } - else if (j1 > 0) { - dval(&u) *= tens[j1 & 0xf]; - for(j = j1 >> 4; j; j >>= 1, i++) - if (j & 1) { - ieps++; - dval(&u) *= bigtens[i]; - } - } - if (k_check && dval(&u) < 1. && ilim > 0) { - if (ilim1 <= 0) - goto fast_failed; - ilim = ilim1; - k--; - dval(&u) *= 10.; - ieps++; - } - dval(&eps) = ieps*dval(&u) + 7.; - word0(&eps) -= (P-1)*Exp_msk1; - if (ilim == 0) { - S = mhi = 0; - dval(&u) -= 5.; - if (dval(&u) > dval(&eps)) - goto one_digit; - if (dval(&u) < -dval(&eps)) - goto no_digits; - goto fast_failed; - } -#ifndef No_leftright - if (leftright) { - /* Use Steele & White method of only - * generating digits needed. - */ - dval(&eps) = 0.5/tens[ilim-1] - dval(&eps); -#ifdef IEEE_Arith - if (j1 >= 307) { - eps1.d = 1.01e256; /* 1.01 allows roundoff in the next few lines */ - word0(&eps1) -= Exp_msk1 * (Bias+P-1); - dval(&eps1) *= tens[j1 & 0xf]; - for(i = 0, j = (j1-256) >> 4; j; j >>= 1, i++) - if (j & 1) - dval(&eps1) *= bigtens[i]; - if (eps.d < eps1.d) - eps.d = eps1.d; - if (10. - u.d < 10.*eps.d && eps.d < 1.) { - /* eps.d < 1. excludes trouble with the tiniest denormal */ - *s++ = '1'; - ++k; - goto ret1; - } - } -#endif - for(i = 0;;) { - L = dval(&u); - dval(&u) -= L; - *s++ = '0' + (int)L; - if (1. - dval(&u) < dval(&eps)) - goto bump_up; - if (dval(&u) < dval(&eps)) - goto retc; - if (++i >= ilim) - break; - dval(&eps) *= 10.; - dval(&u) *= 10.; - } - } - else { -#endif - /* Generate ilim digits, then fix them up. */ - dval(&eps) *= tens[ilim-1]; - for(i = 1;; i++, dval(&u) *= 10.) { - L = (Long)(dval(&u)); - if (!(dval(&u) -= L)) - ilim = i; - *s++ = '0' + (int)L; - if (i == ilim) { - if (dval(&u) > 0.5 + dval(&eps)) - goto bump_up; - else if (dval(&u) < 0.5 - dval(&eps)) - goto retc; - break; - } - } -#ifndef No_leftright - } -#endif - fast_failed: - s = buf; - dval(&u) = dval(&d2); - k = k0; - ilim = ilim0; - } - - /* Do we have a "small" integer? */ - - if (be >= 0 && k <= Int_max) { - /* Yes. */ - ds = tens[k]; - if (ndigits < 0 && ilim <= 0) { - S = mhi = 0; - if (ilim < 0 || dval(&u) <= 5*ds) - goto no_digits; - goto one_digit; - } - for(i = 1;; i++, dval(&u) *= 10.) { - L = (Long)(dval(&u) / ds); - dval(&u) -= L*ds; -#ifdef Check_FLT_ROUNDS - /* If FLT_ROUNDS == 2, L will usually be high by 1 */ - if (dval(&u) < 0) { - L--; - dval(&u) += ds; - } -#endif - *s++ = '0' + (int)L; - if (!dval(&u)) { -#ifdef SET_INEXACT - inexact = 0; -#endif - break; - } - if (i == ilim) { -#ifdef Honor_FLT_ROUNDS - if (mode > 1) - switch(Rounding) { - case 0: goto retc; - case 2: goto bump_up; - } -#endif - dval(&u) += dval(&u); -#ifdef ROUND_BIASED - if (dval(&u) >= ds) -#else - if (dval(&u) > ds || (dval(&u) == ds && L & 1)) -#endif - { - bump_up: - while(*--s == '9') - if (s == buf) { - k++; - *s = '0'; - break; - } - ++*s++; - } - break; - } - } - goto retc; - } - -#endif /*}*/ - m2 = b2; - m5 = b5; - mhi = mlo = 0; - if (leftright) { - i = -#ifndef Sudden_Underflow - denorm ? be + (Bias + (P-1) - 1 + 1) : -#endif -#ifdef IBM - 1 + 4*P - 3 - bbits + ((bbits + be - 1) & 3); -#else - 1 + P - bbits; -#endif - b2 += i; - s2 += i; - mhi = i2b(1 MTb); - } - if (m2 > 0 && s2 > 0) { - i = m2 < s2 ? m2 : s2; - b2 -= i; - m2 -= i; - s2 -= i; - } - if (b5 > 0) { - if (leftright) { - if (m5 > 0) { - mhi = pow5mult(mhi, m5 MTb); - b1 = mult(mhi, b MTb); - Bfree(b MTb); - b = b1; - } - if ((j = b5 - m5)) - b = pow5mult(b, j MTb); - } - else - b = pow5mult(b, b5 MTb); - } - S = i2b(1 MTb); - if (s5 > 0) - S = pow5mult(S, s5 MTb); - - if (spec_case) { - b2 += Log2P; - s2 += Log2P; - } - - /* Arrange for convenient computation of quotients: - * shift left if necessary so divisor has 4 leading 0 bits. - * - * Perhaps we should just compute leading 28 bits of S once - * and for all and pass them and a shift to quorem, so it - * can do shifts and ors to compute the numerator for q. - */ - i = dshift(S, s2); - b2 += i; - m2 += i; - s2 += i; - if (b2 > 0) - b = lshift(b, b2 MTb); - if (s2 > 0) - S = lshift(S, s2 MTb); -#ifndef USE_BF96 - if (k_check) { - if (cmp(b,S) < 0) { - k--; - b = multadd(b, 10, 0 MTb); /* we botched the k estimate */ - if (leftright) - mhi = multadd(mhi, 10, 0 MTb); - ilim = ilim1; - } - } -#endif - if (ilim <= 0 && (mode == 3 || mode == 5)) { - if (ilim < 0 || cmp(b,S = multadd(S,5,0 MTb)) <= 0) { - /* no digits, fcvt style */ - no_digits: - k = -1 - ndigits; - goto ret; - } - one_digit: - *s++ = '1'; - ++k; - goto ret; - } - if (leftright) { - if (m2 > 0) - mhi = lshift(mhi, m2 MTb); - - /* Compute mlo -- check for special case - * that d is a normalized power of 2. - */ - - mlo = mhi; - if (spec_case) { - mhi = Balloc(mhi->k MTb); - Bcopy(mhi, mlo); - mhi = lshift(mhi, Log2P MTb); - } - - for(i = 1;;i++) { - dig = quorem(b,S) + '0'; - /* Do we yet have the shortest decimal string - * that will round to d? - */ - j = cmp(b, mlo); - delta = diff(S, mhi MTb); - j1 = delta->sign ? 1 : cmp(b, delta); - Bfree(delta MTb); -#ifndef ROUND_BIASED - if (j1 == 0 && mode != 1 && !(word1(&u) & 1) -#ifdef Honor_FLT_ROUNDS - && (mode <= 1 || Rounding >= 1) -#endif - ) { - if (dig == '9') - goto round_9_up; - if (j > 0) - dig++; -#ifdef SET_INEXACT - else if (!b->x[0] && b->wds <= 1) - inexact = 0; -#endif - *s++ = dig; - goto ret; - } -#endif - if (j < 0 || (j == 0 && mode != 1 -#ifndef ROUND_BIASED - && !(word1(&u) & 1) -#endif - )) { - if (!b->x[0] && b->wds <= 1) { -#ifdef SET_INEXACT - inexact = 0; -#endif - goto accept_dig; - } -#ifdef Honor_FLT_ROUNDS - if (mode > 1) - switch(Rounding) { - case 0: goto accept_dig; - case 2: goto keep_dig; - } -#endif /*Honor_FLT_ROUNDS*/ - if (j1 > 0) { - b = lshift(b, 1 MTb); - j1 = cmp(b, S); -#ifdef ROUND_BIASED - if (j1 >= 0 /*)*/ -#else - if ((j1 > 0 || (j1 == 0 && dig & 1)) -#endif - && dig++ == '9') - goto round_9_up; - } - accept_dig: - *s++ = dig; - goto ret; - } - if (j1 > 0) { -#ifdef Honor_FLT_ROUNDS - if (!Rounding && mode > 1) - goto accept_dig; -#endif - if (dig == '9') { /* possible if i == 1 */ - round_9_up: - *s++ = '9'; - goto roundoff; - } - *s++ = dig + 1; - goto ret; - } -#ifdef Honor_FLT_ROUNDS - keep_dig: -#endif - *s++ = dig; - if (i == ilim) - break; - b = multadd(b, 10, 0 MTb); - if (mlo == mhi) - mlo = mhi = multadd(mhi, 10, 0 MTb); - else { - mlo = multadd(mlo, 10, 0 MTb); - mhi = multadd(mhi, 10, 0 MTb); - } - } - } - else - for(i = 1;; i++) { - dig = quorem(b,S) + '0'; - *s++ = dig; - if (!b->x[0] && b->wds <= 1) { -#ifdef SET_INEXACT - inexact = 0; -#endif - goto ret; - } - if (i >= ilim) - break; - b = multadd(b, 10, 0 MTb); - } - - /* Round off last digit */ - -#ifdef Honor_FLT_ROUNDS - if (mode > 1) - switch(Rounding) { - case 0: goto ret; - case 2: goto roundoff; - } -#endif - b = lshift(b, 1 MTb); - j = cmp(b, S); -#ifdef ROUND_BIASED - if (j >= 0) -#else - if (j > 0 || (j == 0 && dig & 1)) -#endif - { - roundoff: - while(*--s == '9') - if (s == buf) { - k++; - *s++ = '1'; - goto ret; - } - ++*s++; - } - ret: - Bfree(S MTb); - if (mhi) { - if (mlo && mlo != mhi) - Bfree(mlo MTb); - Bfree(mhi MTb); - } - retc: - while(s > buf && s[-1] == '0') - --s; - ret1: - if (b) - Bfree(b MTb); - *s = 0; - *decpt = k + 1; - if (rve) - *rve = s; -#ifdef SET_INEXACT - if (inexact) { - if (!oldinexact) { - word0(&u) = Exp_1 + (70 << Exp_shift); - word1(&u) = 0; - dval(&u) += 1.; - } - } - else if (!oldinexact) - clear_inexact(); -#endif - return buf; - } - - char * -dtoa(double dd, int mode, int ndigits, int *decpt, int *sign, char **rve) -{ - /* Sufficient space is allocated to the return value - to hold the suppressed trailing zeros. - See dtoa_r() above for details on the other arguments. - */ -#ifndef MULTIPLE_THREADS - if (dtoa_result) - freedtoa(dtoa_result); -#endif - return dtoa_r(dd, mode, ndigits, decpt, sign, rve, 0, 0); - } - -#ifdef __cplusplus -} -#endif diff --git a/src/pylib/impure/math/dtoa.nim b/src/pylib/impure/math/dtoa.nim deleted file mode 100644 index d6ebb6ee4..000000000 --- a/src/pylib/impure/math/dtoa.nim +++ /dev/null @@ -1,78 +0,0 @@ -##[ - We use origin dtoa.c over Python's -]## - -import ../../pyconfig/pycore/pymath - -const threads = compileOption("threads") -when threads: - import std/locks - var dtoa_locks: array[2, Lock] - for l in dtoa_locks.mitems: - l.initLock - - proc ACQUIRE_DTOA_LOCK*(n: c_int){.exportc.} = dtoa_locks[n].acquire() - proc FREE_DTOA_LOCK*(n: c_int){.exportc.} = dtoa_locks[n].release() - const threadnoInC = "dtoa_get_threadno" - proc getThreadId*: c_int{.exportc: threadnoInC.} = c_int system.getThreadId() - -const Cflags = block: - var cflags = "" - const Dpre = # TODO: use `#define` to C code, maybe there's compiler rejects /D,-D - when defined(vcc): " /D" - else: " -D" - - template addD(sym) = - cflags.add Dpre - cflags.add astToStr sym - template define(sym, cond) = - when cond: - addD sym - - template defineVal(sym, val) = - addD sym - cflags.add "=" - cflags.add val - template defineVal(sym) = defineVal(sym, astToStr sym) - - define MULTIPLE_THREADS, threads - when threads: - # need to define ACQUIRE_DTOA_LOCK(n) and FREE_DTOA_LOCK(n) where n is 0 or 1 - defineVal ACQUIRE_DTOA_LOCK - defineVal FREE_DTOA_LOCK - defineVal dtoa_get_threadno, threadnoInC - - #[ This code should also work for ARM mixed-endian format on little-endian - machines, where doubles have byte order 45670123 (in increasing address - order, 0 being the least significant byte). ]# - define IEEE_8087, DOUBLE_IS_LITTLE_ENDIAN_IEEE754 - define IEEE_MC68k, DOUBLE_IS_BIG_ENDIAN_IEEE754 or DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754 - cflags - -{.compile("dtoa-nim.c", Cflags).} - -proc dtoa_r*( - dd: cdouble, - mode, ndigits: cint, - decpt, sign: var cint, rve: var cstring, - buf: cstring; blen: csize_t -): cstring {.importc: "dtoa_r", cdecl, discardable.} ##[ ```c -char* dtoa_r(double dd, int mode, int ndigits, int *decpt, int *sign, char **rve, char *buf, size_t blen) -```]## - -proc dtoa*( - d: cdouble, - mode, ndigits: cint, - decpt, sign: var cint, rve: var cstring - ): cstring{.importc: "dtoa", cdecl, discardable.} ##[ ```c -char* dtoa(double d, int mode, int ndigits, int *decpt, int *sign, char **rve) -```]## - -proc strtod*( - s00: cstring, se: (var cstring)|(ptr cstring) # for `strtod(s, nil)` -): cdouble{.importc: "nimpylib_dtoa_strtod", cdecl.} ##[ ```c -double strtod(const char *s00, char **se) -```]## - -proc freedtoa*(s: cstring){.importc, cdecl.} - diff --git a/src/pylib/impure/math/dtoa.toml b/src/pylib/impure/math/dtoa.toml deleted file mode 100644 index 2599694f3..000000000 --- a/src/pylib/impure/math/dtoa.toml +++ /dev/null @@ -1,2 +0,0 @@ -date = 2025-02-17T02:19:42+08:00 -url = "https://www.netlib.org/fp/dtoa.c" \ No newline at end of file diff --git a/src/pylib/io.nim b/src/pylib/io.nim deleted file mode 100644 index 5178ca75e..000000000 --- a/src/pylib/io.nim +++ /dev/null @@ -1,26 +0,0 @@ -##[ - -*NOTE*: not support js currently - -## different from Python - -### open -Its param: `closefd, opener` -is not implemented yet - -### seek -There is difference that Python's `TextIOBase.seek` -will reset state of encoder at some conditions, -while Nim doesn't have access to encoder's state -Therefore, `seek` here doesn't change that - -### iter over file -Python's `__next__` will yield newline as part of result -but Nim's `iterator lines` does not - -]## - -import ./Lib/io - -export io.open, io.close, io.seek, io.read, io.readline, io.write, io.truncate -export io.initBufAsPy diff --git a/src/pylib/io_abc.nim b/src/pylib/io_abc.nim deleted file mode 100644 index bc4e51722..000000000 --- a/src/pylib/io_abc.nim +++ /dev/null @@ -1,35 +0,0 @@ - -import ./pystring/strimpl -import ./pybytes/bytesimpl -import ./builtins/reprImpl - -func fspath*(s: string): PyStr = str s -func fspath*(c: char): PyStr = str c - -type - FsPath = PyStr|PyBytes - PathLike*[T: FsPath] = concept self ## os.PathLike - T # XXX: still to prevent wrong compiler hint: `T is not used` - self.fspath is T - CanIOOpenT*[T] = int | PathLike[T] - - -template mapPathLike*[T](s: PathLike[T], nimProc): T = - when T is PyStr: str nimProc s.fspath - else: bytes nimProc s.fspath -template mapPathLike*[T](nexpr): T = - when T is PyStr: str nexpr - else: bytes nexpr - - -func `$`*(p: PathLike): string = - $p.fspath - - -proc `$`*(p: CanIOOpenT): string = - ## Mainly for error message - when p is int: "fd: " & $int(p) - else: $p - -func pathrepr*(p: PathLike[PyBytes]): string = p.pyreprbImpl -func pathrepr*(p: PathLike[PyStr]): string = p.pyreprImpl diff --git a/src/pylib/jsutils/consts.nim b/src/pylib/jsutils/consts.nim deleted file mode 100644 index 72ee3d5e3..000000000 --- a/src/pylib/jsutils/consts.nim +++ /dev/null @@ -1,13 +0,0 @@ - -const - InNodeJs = defined(nodejs) -import std/jsffi -when InNodeJs: - let econsts = require("constants") -else: - let econsts{.importjs: """(await import("node:constants"))""".}: JsObject - -template from_js_const*(name; defval: int): int = - bind econsts, isUndefined, to, `[]` - let n = econsts[astToStr(name)] - if n.isUndefined: defVal else: n.to(int) diff --git a/src/pylib/jsutils/deno.nim b/src/pylib/jsutils/deno.nim deleted file mode 100644 index ba6a428ee..000000000 --- a/src/pylib/jsutils/deno.nim +++ /dev/null @@ -1,8 +0,0 @@ - -const DenoDetectedJsExpr* = "typeof Deno !== 'undefined'" -when defined(js): - when defined(nodejs): - let inDeno* = false - else: - let inDeno*{.importjs: DenoDetectedJsExpr.}: bool - diff --git a/src/pylib/jsutils/denoAttrs.nim b/src/pylib/jsutils/denoAttrs.nim deleted file mode 100644 index 082618573..000000000 --- a/src/pylib/jsutils/denoAttrs.nim +++ /dev/null @@ -1,89 +0,0 @@ -##[ - This module is intended to merge some similar code between NodeJs and Deno. - - For example, - - process.pid Deno.pid - fs.openSync Deno.openSync -]## - -import ./deno -export deno - -when defined(js): - import std/macros - when not defined(nodejs): - from std/strutils import `%` - proc importByNodeOrDenoImpl(def: NimNode; nodeExpr, denoExpr: string): NimNode = - var - nodeExpr = nodeExpr - denoExpr = denoExpr - template JsExpr: NimNode = # lazy eval on nodeExpr, denoExpr - newLit: - when defined(nodejs): # fast-path when defined nodejs - nodeExpr - else: - DenoDetectedJsExpr & ("?$1:$2" % [denoExpr, nodeExpr]) - template JsPragma: NimNode = # lazy eval on `JsExpr` - nnkExprColonExpr.newTree(ident"importjs", JsExpr) - - case def.kind - of nnkLetSection, nnkVarSection: - if def[0][0].kind == nnkPragmaExpr: - def[0][0][1].add JsPragma - else: - def[0][0] = nnkPragmaExpr.newTree(def[0][0], nnkPragma.newTree JsPragma) - of RoutineNodes: - func addParamsIfNotAttr(s: var string) = - if s[^1] == '$': s.setLen s.len-1 - else: s.add "(@)" - nodeExpr.addParamsIfNotAttr() - denoExpr.addParamsIfNotAttr() - def.addPragma JsPragma - else: - error "only var/let and procs is supported, but got " & $def.kind, def - def - macro importByNodeOrDeno*(node, deno: static[string]; def) = - ## pragma - importByNodeOrDenoImpl(def, nodeExpr=node, denoExpr=deno) - proc myrepr(n: NimNode): string = - if n.kind in nnkStrLit..nnkTripleStrLit: n.strVal - else: repr n - proc importDenoOrImpl(def: NimNode; objInNode: string; - denoAttr: NimNode, nodeAttr=denoAttr): NimNode = - let - denoAttr = myrepr denoAttr - nodeAttr = myrepr nodeAttr - importByNodeOrDenoImpl(def, - nodeExpr=objInNode&'.'&nodeAttr, - denoExpr="Deno."&denoAttr - ) - - func requireExpr(module: string): string = "require('" & module & "')" - macro importDenoOrNodeMod*(modInNode, attr; def) = - importDenoOrImpl(def, requireExpr $modInNode, attr) - macro importInNodeModOrDeno*(modInNode, attrNode, attrDeno; def) = - importDenoOrImpl(def, requireExpr $modInNode, attrDeno, attrNode) - macro importDenoOr*(objInNode, attr; def) = - importDenoOrImpl(def, $objInNode, attr) - - proc importNodeImpl(def: NimNode, module, symExpr: string): NimNode = - importByNodeOrDenoImpl(def, - requireExpr(module) & '.' & symExpr, - "(await import('node:" & module & "'))." & symExpr - ) - - proc importDenoOrProcessAux(denoAttr, nodeAttr, def: NimNode): NimNode = - importDenoOrImpl(def, "process", denoAttr, nodeAttr) - - macro importDenoOrProcess*(denoAttr, nodeAttr; def) = - importDenoOrProcessAux(denoAttr, nodeAttr, def) - macro importDenoOrProcess*(attr; def) = - importDenoOrProcessAux(attr, attr, def) - - macro importNode*(module, symExpr; def) = - let ssym = case symExpr.kind - of nnkStrLit, nnkRStrLit, nnkTripleStrLit, nnkIdent: symExpr.strVal # also allows dotExpr - of nnkDotExpr: symExpr[0].strVal & '.' & symExpr[1].strVal - else: error "invalid nim node type " & $symExpr.kind - importNodeImpl(def, module.strVal, ssym) diff --git a/src/pylib/mutSeqSliceOp.nim b/src/pylib/mutSeqSliceOp.nim deleted file mode 100644 index f54bdfd2d..000000000 --- a/src/pylib/mutSeqSliceOp.nim +++ /dev/null @@ -1,71 +0,0 @@ -## As Python's `MutableSequence` does not mixin these -## we place them here. - -import ./builtins/pyslice - -template loopDown(a, b; step) = - ## .. also reverse to avoid indices changing - for i in countdown(min(len(ms)-1, a), max(0, b), step): - ms.delitem(i) - -template genDelItem*(Arr){.dirty.} = - bind PySlice, toNimSlice, loopDown - func delitem*(ms: var Arr, indices: Slice[int]) = - loopDown indices.b, indices.a, 1 - - func delitem*(ms: var Arr, indices: PySlice) = - if indices.step == 1: - ms.delitem(toNimSlice(indices)) - return - let b = indices.stop - 1 - if indices.step < 0: - loopDown(indices.start, b, indices.step) - else: - loopDown(b, indices.start, indices.step) - -template moveItems(ms, dest, frm, n) = - ## .. also reverse to avoid indices changing - when declared(moveMem): - when compiles(addr ms[dest]): - moveMem(addr ms[dest], addr ms[frm], n*sizeof(ms[0])) - else: - moveMem(ms.getPtr dest, ms.getPtr frm, n*sizeof(ms[0])) - else: - if frm > dest: - for i in 0..= 0 - let n = o.len - let d = n - norig - let le = ms.len - if le + d == 0: - ms.clear() - return - if d < 0: # Delete -d items - moveItems(ms, ihigh+d, ihigh, le-ihigh) - ms.setLen le+d - elif d > 0: # Insert d items - ms.setLen le+d - moveItems(ms, ihigh+d, ihigh, le-ihigh) - for k in 0.. 0: "inf" else: "-inf" - else: system.`$` x - -when not hasBug: - proc `$`*(x: SomeFloat): string = system.`$`(x) diff --git a/src/pylib/nimpatch/nansign.nim b/src/pylib/nimpatch/nansign.nim deleted file mode 100644 index cd5a22ea7..000000000 --- a/src/pylib/nimpatch/nansign.nim +++ /dev/null @@ -1,25 +0,0 @@ -{.used.} -import ./utils -addPatch((2,3,1), defined(c) or defined(cpp)): - # fixes in nim-lang/Nim#24774 - from std/os import quoteShell # compileTime only - const HUGE_ENUF = "1e+300" - - template use(s: string; optPre: char) = - {.passC: optPre&"DNAN=" & quoteShell(s).} - - template useBltin(optPre = '-'){.used.} = - ## use `__builtin_nanf` which is faster, if available - use """(__builtin_nanf(""))""", optPre - template useCaled(optPre = '-'){.used.} = - const NAN_INFINITY = "((float)("&HUGE_ENUF&'*'&HUGE_ENUF&"))" - use "(-(float)("&NAN_INFINITY&"*0.0F))", optPre - when defined(gcc): useBltin - elif defined(clang): - # XXX: check "__has_builtin (__builtin_nanf)" is hard here, - # we just use fallback - useCaled - elif defined(vcc): - useCaled'/' - else: - useCaled diff --git a/src/pylib/nimpatch/newUninit.nim b/src/pylib/nimpatch/newUninit.nim deleted file mode 100644 index 3fab929b1..000000000 --- a/src/pylib/nimpatch/newUninit.nim +++ /dev/null @@ -1,21 +0,0 @@ -{.used.} -import ./utils -addPatch((2,1,1), true): - # introduced in nim-lang/Nim#22572 - proc newStringUninit*(len: Natural): string = - ## just fallback - newString(len) - - proc newSeqUninit*[T](len: Natural): seq[T] = - when declared(newSeqUninitialized): - newSeqUninitialized[T](len) - elif declared(setLenUninit): - result.setLenUninit(len) - else: - newSeq[T](len) - - proc setLenUninit*[T](s: var seq[T], newlen: Natural) = s.setLen newLen - -when (defined(js) or defined(nims)) and - not declared(setLenUninit): # XXX: currently (as of 2.3.1), no such for JS - proc setLenUninit*[T](s: var seq[T], newlen: Natural) = s.setLen newLen diff --git a/src/pylib/nimpatch/utils.nim b/src/pylib/nimpatch/utils.nim deleted file mode 100644 index 4853ab2f4..000000000 --- a/src/pylib/nimpatch/utils.nim +++ /dev/null @@ -1,22 +0,0 @@ - -const NimVersionTuple* = (NimMajor, NimMinor, NimPatch) - -const JsBigInt64Option* = NimVersionTuple > (1, 6, 0) and compileOption("jsBigInt64") - -template addPatch*(ver: (int, int, int), - flag: untyped#[bool, use untyped to make flagExprRepr work]#, - patchBody: untyped){.dirty.} = - ## flag is a bool expr, here uses untyped to delay evaluation - ## to get its string represent - const - FixedVer* = ver - BeforeFixedVer* = NimVersionTuple <= FixedVer - Flag = flag - hasBug* = BeforeFixedVer and Flag - when hasBug: - patchBody - else: - const flagExprRepr = astToStr(flag) - {.warning: currentSourcePath() & " patch only takes effect before " & $FixedVer & - " or without flags: " & flagExprRepr.} - \ No newline at end of file diff --git a/src/pylib/nimpatch/winOpenFileHandle.nim b/src/pylib/nimpatch/winOpenFileHandle.nim deleted file mode 100644 index 9c0173956..000000000 --- a/src/pylib/nimpatch/winOpenFileHandle.nim +++ /dev/null @@ -1,38 +0,0 @@ -{.used.} -import ./utils -addPatch((2,1,1), defined(windows)): - ## introduced in nim-lang/Nim#23456 - # patch for system/io.nim or std/syncio.nim, - # see https://github.com/nim-lang/Nim/pull/23456 - when defined(nimPreviewSlimSystem): - import std/syncio - const - NoInheritFlag = - # Platform specific flag for creating a File without inheritance. - when not defined(nimInheritHandles): - when defined(windows): "" - elif defined(linux) or defined(bsd): "e" - else: "" - else: "" - FormatOpen: array[FileMode, cstring] = [ - cstring("rb" & NoInheritFlag), "wb" & NoInheritFlag, "w+b" & NoInheritFlag, - "r+b" & NoInheritFlag, "ab" & NoInheritFlag - ] - when defined(windows): - proc getOsfhandle(fd: cint): int {. - importc: "_get_osfhandle", header: "".} - proc c_fdopen(filehandle: cint, mode: cstring): File {. - importc: "_fdopen", header: "".} - else: - proc c_fdopen(filehandle: cint, mode: cstring): File {. - importc: "fdopen", header: "".} - proc open*(f: var File, filehandle: FileHandle, - mode: FileMode = fmRead): bool {.tags: [], raises: [].} = - when not defined(nimInheritHandles) and declared(setInheritable): - let oshandle = when defined(windows): FileHandle getOsfhandle(filehandle) - else: filehandle - if not setInheritable(oshandle, false): - return false - let fop = FormatOpen[mode] - f = c_fdopen(filehandle, fop) - result = f != nil diff --git a/src/pylib/noneType.nim b/src/pylib/noneType.nim deleted file mode 100644 index e10d02e39..000000000 --- a/src/pylib/noneType.nim +++ /dev/null @@ -1,8 +0,0 @@ - -type - NoneType* = distinct bool - -const - # Python-like boolean literals - - None* = NoneType(false) ## Python-like None for special handling diff --git a/src/pylib/numTypes.nim b/src/pylib/numTypes.nim deleted file mode 100644 index 287fb2bdc..000000000 --- a/src/pylib/numTypes.nim +++ /dev/null @@ -1,3 +0,0 @@ - -import ./numTypes/[floats, ints] -export floats, ints diff --git a/src/pylib/numTypes/floats.nim b/src/pylib/numTypes/floats.nim deleted file mode 100644 index 24be51702..000000000 --- a/src/pylib/numTypes/floats.nim +++ /dev/null @@ -1,100 +0,0 @@ - -import std/math -import ../pystring/strimpl -import ./floats/[init, floathex] -export init.float -import ../ops/chk_shl -from ../Lib/math_impl/isX import isfinite - -func hex*(x: float): PyStr = - str x.hexImpl - -func fromhex*(_: typedesc[float], s: string): float = - floatFromhexImpl s -func float_fromhex*(s: string): float = - floatFromhexImpl s - -func is_integer*(self: float): bool = - if not self.isfinite: false - else: floor(self) == self - -func as_integer_ratio_check(self: float){.inline.} = - let fc = classify self - if fc == fcInf or fc == fcNegInf: raise newException(OverflowDefect, - "cannot convert Infinity to integer ratio") - if fc == fcNan: raise newException(ValueError, - "cannot convert NaN to integer ratio") - -template halfHigh[I]: untyped = high(I) shr (sizeof(I) div 2 * 8) - -func as_someinteger_ratio*[I: SomeInteger](self: float, - n = halfHigh[I]): (I, I) = - ## EXT. - ## Calculates the best rational approximation of `x`, - ## where the denominator is smaller than `n` - ## (default is the largest possible `I` for maximal resolution), - ## - ## The algorithm is from `toRational` of std/rationals, - ## based on `the theory of continued fractions. David Eppstein / - ## UC Irvine / 8 Aug 1993`_ , - ## but raises ValueError or OverflowDefect if x is NaN or Infinity. - ## - ## .. hint:: due to lack of arbitrary length integers, - ## its accuracy is not as high as Python's - self.as_integer_ratio_check() - let - self_neg = self < 0.0 - # if not doing so, negative values - # like `-0.875` even doesn't returns `(-7, 8)` - abs_self = - if self_neg: -self - else: self - var - m11, m22: I = 1 - m12, m21: I = 0 - ai = I(abs_self) - x = abs_self - while m21 * ai + m22 <= n: - swap m12, m11 - swap m22, m21 - m11 = m12 * ai + m11 - m21 = m22 * ai + m21 - if x == float(ai): break # division by zero - x = 1 / (x - float(ai)) - if x > float(halfHigh[I]): break # representation failure - ai = I(x) - if self_neg: - m11 = -m11 - result = (m11, m21) - -func as_integer_ratio*(self: float, - n = halfHigh[int]): (int, int) = - ## see `as_someinteger_ratio`_ - as_someinteger_ratio[int] self, n - -func checked_as_integer_ratio*(self: float): (int, int) = - ## EXT. - ## like `as_integer_ratio`_ but - ## raises OverflowDefect when cannot represent accurately. - self.as_integer_ratio_check() - var (float_part, exponent) = frexp(self) - for _ in 0..299: - if float_part == floor(float_part): - break - float_part *= 2.0 - exponent.dec - #[ self == float_part * 2**exponent exactly and float_part is integral. - If FLT_RADIX != 2, the 300 steps may leave a tiny fractional part - to be truncated by PyLong_FromDouble().]# - var numerator, denominator, py_exponent: int - numerator = int float_part - denominator = 1 - py_exponent = abs exponent - - # fold in 2**exponent - if exponent > 0: - numerator = checkedShl(numerator, py_exponent) - else: - denominator = checkedShl(denominator, py_exponent) - result = (numerator, denominator) - diff --git a/src/pylib/numTypes/floats/floathex.nim b/src/pylib/numTypes/floats/floathex.nim deleted file mode 100644 index 351ffaa1d..000000000 --- a/src/pylib/numTypes/floats/floathex.nim +++ /dev/null @@ -1,332 +0,0 @@ - -import std/parseutils # skipWhile, parseInt, parseBiggestInt -from std/strutils import find, initSkipTable, isSpaceAscii, toLowerAscii, - HexDigits -import std/fenv -from std/math import frexp, classify, FloatClass -from ../../Lib/math import ldexp -import ./parse_inf_nan - -#[ we can use sprintf(.., %a ..) here, but it may be less effective and less error-reportable: -when defined(c) or defined(cpp): - proc sprintf(buf: cstring, fmt: cstring): c_int{.importc, header: "", varargs.} - func hexImpl(f: float): string = - var buf = cast[cstring](alloc(HEX_BUF)) - let ret = sprintf(buf, "%a", f.c_double) - assert ret == 1 - result = $buf - buf.dealloc -]# -const - DBL_MANT_DIG = float64.mantissaDigits - DBL_MIN_EXP = float64.minExponent - DBL_MAX_EXP = float64.maxExponent -const - TOHEX_NBITS = DBL_MANT_DIG + 3 - (DBL_MANT_DIG+2) mod 4 - #HEX_BUF = (TOHEX_NBITS-1)/4+3 # not sure if too long - -const Py_hexdigits = "0123456789abcdef" - -func char_from_hex(x: int): char = Py_hexdigits[x] -func hex_from_char(c: char): int = - case c - of '0': 0 - of '1': 1 - of '2': 2 - of '3': 3 - of '4': 4 - of '5': 5 - of '6': 6 - of '7': 7 - of '8': 8 - of '9': 9 - of 'a', 'A': 10 - of 'b', 'B': 11 - of 'c', 'C': 12 - of 'd', 'D': 13 - of 'e', 'E': 14 - of 'f', 'F': 15 - else: -1 - -func normalFloatHexImpl(x: float): string = - var (m, e) = frexp(abs(x)) - let shift = 1 - max(DBL_MIN_EXP - e, 0) - m = ldexp(m, shift) - e -= shift - - #[ Space for 1+(TOHEX_NBITS-1)/4 digits, a decimal point.]# - const nDigits = (TOHEX_NBITS-1) div 4 - var s = newString nDigits + 2 - var si = 0 - s[si] = char_from_hex int m - si.inc - template dropIntPart(f: float) = - f = f - float int f - m.dropIntPart - s[si] = '.' - si.inc - for i in 0.. LONG_MAX/2 then the value of the hex string is - guaranteed to overflow (provided it's nonzero) - * - (2) if exp < LONG_MIN/2 then the value of the hex string is - guaranteed to underflow to 0. - * - (3) if LONG_MIN/2 <= exp <= LONG_MAX/2 then there's no danger of - overflow in the calculation of exp and top_exp below. - * - More specifically, ndigits is assumed to satisfy the following - inequalities: - * - 4*ndigits <= DBL_MIN_EXP - DBL_MANT_DIG - LONG_MIN/2 - 4*ndigits <= LONG_MAX/2 + 1 - DBL_MAX_EXP - * - If either of these inequalities is not satisfied, a ValueError is - raised. Otherwise, write x for the value of the hex string, and - assume x is nonzero. Then - * - 2**(exp-4*ndigits) <= |x| < 2**(exp+4*ndigits). - * - Now if exp > LONG_MAX/2 then: - * - exp - 4*ndigits >= LONG_MAX/2 + 1 - (LONG_MAX/2 + 1 - DBL_MAX_EXP) - = DBL_MAX_EXP - * - so |x| >= 2**DBL_MAX_EXP, which is too large to be stored in C - double, so overflows. If exp < LONG_MIN/2, then - * - exp + 4*ndigits <= LONG_MIN/2 - 1 + ( - DBL_MIN_EXP - DBL_MANT_DIG - LONG_MIN/2) - = DBL_MIN_EXP - DBL_MANT_DIG - 1 - * - and so |x| < 2**(DBL_MIN_EXP-DBL_MANT_DIG-1), hence underflows to 0 - when converted to a C double. - * - It's easy to show that if LONG_MIN/2 <= exp <= LONG_MAX/2 then both - exp+4*ndigits and exp-4*ndigits are within the range of a long. - ]# - let - s_hi = s.high - s_end = s.len - when sizeof(int) >= 8: - var exp: int - const intExp = true - else: - var exp: BiggestInt - const intExp = false - type TExp = typeof(exp) - const - LONG_MAXd2 = high(TExp) div 2 - LONG_MINd2 = low(TExp) div 2 - var negate = false - - - template raiseValueError(msg) = - raise newException(ValueError, msg) - template parse_error = - raiseValueError "invalid hexadecimal floating-point string" - template overflow_error = - raise newException(OverflowDefect, - "hexadecimal value too large to represent as a float") - template insane_length_error = - raiseValueError "hexadecimal string too long to convert" - - #[ - Parse the string - ]# - var curIdx = 0 - template inBound: bool = curIdx < s_end - template cur: char = s[curIdx] - template step = curIdx.inc - template stepi(i) = curIdx.inc i - template resetCur(i) = curIdx = i - - # leading whitespace - while cur.IS_SPACE: - step - - if result.parse_inf_or_nan s.toOpenArray(curIdx, s_hi): - return - - # optional sign - let first = cur - if first == '-': negate=true; step - elif first == '+': step - - var s_store = curIdx - # [0x|X] - if cur == '0': - step - if cur == 'x' or cur == 'X': - step - else: - resetCur s_store - - # coefficient: [. ] - let coeff_start = curIdx - stepi skipWhile(s, HexDigits, start=curIdx) - s_store = curIdx - let coeff_end = - if inBound and cur == '.': - step - stepi skipWhile(s, HexDigits, start=curIdx) - curIdx - 1 - else: - curIdx - - #[ ndigits = total # of hex digits - fdigits = # after point ]# - var ndigits = coeff_end - coeff_start - let fdigits = coeff_end - s_store - if ndigits == 0: - parse_error - if ndigits > min(DBL_MIN_EXP - DBL_MANT_DIG - LONG_MINd2, - LONG_MAXd2 + 1 - DBL_MAX_EXP) div 4: - insane_length_error - - # [p ] - template curIsOr(a, b: char): bool = - inBound and (cur == a or cur == b) - if curIsOr('p', 'P'): - step - let exp_start = curIdx - if curIsOr('-', '+'): - step - if not inBound or cur not_in '0'..'9': - parse_error - step - while inBound and cur in '0'..'9': - step - let n = - when intExp: parseInt(s, exp, exp_start) - else: parseBiggestInt(s, exp, exp_start) - assert n != 0 - else: - exp = 0 - - # for 0 <= j < ndigits, HEX_DIGIT(j) gives the jth most significant digit - template HEX_DIGIT(j: int): int = - hex_from_char(s[ - if j < fdigits: coeff_end-j - else: coeff_end-1-j - ]) - #[ - Compute rounded value of the hex string - ]# - - template finished = - while inBound and cur.IS_SPACE: - step - if curIdx != s_end: - parse_error - if negate: result = -result - return - - # Discard leading zeros, and catch extreme overflow and underflow - while ndigits > 0 and HEX_DIGIT(ndigits-1) == 0: - ndigits.dec - if ndigits == 0 or exp < LONG_MINd2: - result = 0.0 - finished - if exp > LONG_MAXd2: - overflow_error - - # Adjust exponent for fractional part. - exp -= TExp 4*fdigits - - # top_exp = 1 more than exponent of most sig. bit of coefficient - var top_exp = exp + 4*(ndigits.TExp - 1) - var digits = HEX_DIGIT(ndigits-1) - while digits != 0: - top_exp.inc - digits = digits div 2 - - # catch almost all nonextreme cases of overflow and underflow here - if top_exp < DBL_MIN_EXP - DBL_MANT_DIG: - result = 0.0 - finished - if top_exp > DBL_MAX_EXP: - overflow_error - - # lsb = exponent of least significant bit of the *rounded* value - # This is top_exp - DBL_MANT_DIG unless result is subnormal. - let lsb = max(top_exp, DBL_MIN_EXP.TExp) - TExp DBL_MANT_DIG - - result = 0.0 - template handleInTill(till) = - for i in countdown(ndigits-1, till): - result = 16.0*result + float HEX_DIGIT(i) - if exp >= lsb: - # no rounding required - handleInTill 0 - result = ldexp(result, exp.int) - finished - # rounding required. key_digit is the index of the hex digit - # containing the first bit to be rounded away. - let - half_eps = 1 shl (cast[int](lsb - exp - 1) mod 4) - key_digit = int(lsb - exp - 1) div 4 - handleInTill key_digit+1 - let digit = HEX_DIGIT(key_digit) - result = 16.0*result + float(digit.TExp and (16-2*half_eps)) - - # round-half-even: round up if bit lsb-1 is 1 and at least one of - # bits lsb, lsb-2, lsb-3, lsb-4, ... is 1. - if (digit and half_eps) != 0: - var round_up = false - if (digit and (3*half_eps-1)) != 0 or ( - half_eps == 8 and - key_digit+1 < ndigits and - (HEX_DIGIT(key_digit+1) and 1) != 0): - round_up = true - else: - for i in countdown(key_digit-1, 0): - if HEX_DIGIT(i) != 0: - round_up = true - break - if round_up: - result += float 2*half_eps - if top_exp == DBL_MAX_EXP and - result == ldexp(float(2*half_eps), DBL_MANT_DIG): - # overflow corner case: - # pre-rounded value < 2**DBL_MAX_EXP; rounded=2**DBL_MAX_EXP. - overflow_error - result = ldexp(result, int exp+4*key_digit) - finished diff --git a/src/pylib/numTypes/floats/init.nim b/src/pylib/numTypes/floats/init.nim deleted file mode 100644 index a042852d1..000000000 --- a/src/pylib/numTypes/floats/init.nim +++ /dev/null @@ -1,31 +0,0 @@ - - -import ./parsefloat -import ../utils/stripOpenArray -import ../reimporter -import ../../nimpatch/floatdollar - -proc repr*(x: SomeFloat): string = - floatdollar.`$` x - -template float*(number: SomeNumber = 0.0): BiggestFloat = BiggestFloat number - -func pyfloat(a: string|PyStr|PyBytes): BiggestFloat = - ## `PyFloat_FromString`. - ## the same as `float(str|bytes)` - # used by builtins.complex - let sa = $a - let (m, n) = sa.stripAsRange - let ni = parsePyFloat(sa.toOpenArray(m, n), result) - if ni != n - m + 1: - raise newException(ValueError, - "could not convert string to float: " & repr(a)) - -func float*(a: PyStr|PyBytes): BiggestFloat = pyfloat(a) - -template float*(a: bool): BiggestFloat = (if a: 1.0 else: 0.0) - -type HasIndex = concept self - self.index() is SomeInteger - -template float*(obj: HasIndex): BiggestFloat{.pysince(3,8).} = BiggestFloat obj.index() diff --git a/src/pylib/numTypes/floats/parse_inf_nan.nim b/src/pylib/numTypes/floats/parse_inf_nan.nim deleted file mode 100644 index 88764ba76..000000000 --- a/src/pylib/numTypes/floats/parse_inf_nan.nim +++ /dev/null @@ -1,42 +0,0 @@ - -from std/strutils import toLowerAscii - -func parse_inf_or_nan*(ori_s: openArray[char], res: var float): int = - ## a variant of `_Py_parse_inf_or_nan` in Python/pystrtod.c - ## XXX: don't use parseFloat in std/parseutils currently as it does not - ## respect sign bit of `NaN`s. - func iStartsWith(a, b: openArray[char], start=0): bool = - ## b must be in lower case - if b.len > a.len - start: return false - result = true - for i, c in b: - if a[i+start].toLowerAscii != c: - return false - var negate = false - let first = ori_s[0] - result = - if first == '-': negate = true; 1 - elif first == '+': 1 - else: 0 - - template curIStart(s): bool = - ori_s.iStartsWith(s, result) - if curIStart "inf": - result.inc 3 - if curIStart "inity": - result.inc 5 - res = if negate: NegInf else: Inf - elif curIStart "nan": - result.inc 3 - res = if negate: -abs(NaN) else: abs(NaN) - else: - result = 0 - -func parse_inf_or_nan*(res: var float, ori_s: openArray[char]): bool = - ## returns if successfully parses - ## returns false when there are chars left after parsed in `ori_s` - ## - ## XXX: don't use parseFloat in std/strutils currently as it does not - ## respect sign bit of `NaN`s. - let le = ori_s.len - le != 0 and le == ori_s.parse_inf_or_nan res diff --git a/src/pylib/numTypes/floats/parsefloat.nim b/src/pylib/numTypes/floats/parsefloat.nim deleted file mode 100644 index 423ab932c..000000000 --- a/src/pylib/numTypes/floats/parsefloat.nim +++ /dev/null @@ -1,18 +0,0 @@ - - -from std/parseutils import parseFloat -import ./parse_inf_nan -func parsePyFloat*(a: openArray[char], res: var BiggestFloat): int = - ## Almost the same as parseFloat in std/parseutils - ## but respects the sign of NaNs - ## - ## .. hint:: this does not strip whitespaces, just like parseFloat - if a.len == 0: return 0 - result = a.parse_inf_or_nan(res) - if result != 0: return - when nimvm: - # NIM-BUG: https://github.com/nim-lang/Nim/issues/23936 - # bypass - result = parseFloat(a.toOpenArray(0, a.high), res) - else: - result = parseFloat(a, res) diff --git a/src/pylib/numTypes/ints.nim b/src/pylib/numTypes/ints.nim deleted file mode 100644 index b6a04daac..000000000 --- a/src/pylib/numTypes/ints.nim +++ /dev/null @@ -1,8 +0,0 @@ - -import ./ints/[decl, init, getter, int_bytes] - -export init.int, init.nimint -export decl, getter, int_bytes - -import ./ints/longint -export longint diff --git a/src/pylib/numTypes/ints/bitops.nim b/src/pylib/numTypes/ints/bitops.nim deleted file mode 100644 index ab59c1d94..000000000 --- a/src/pylib/numTypes/ints/bitops.nim +++ /dev/null @@ -1,20 +0,0 @@ - -template una(dest, src){.dirty.} = - template dest*[I: SomeInteger](a: I): I = src(a) -template bin(dest, src, idest){.dirty.} = - template dest*[I: SomeInteger](a, b: I): I = src(a, b) - proc idest*[I: SomeInteger](a: var I, b: I) = a = src(a, b) - -template exportIntBitOps*{.dirty.} = - ## - ## .. warning:: `<<` causes overflow silently. - ## Yet Python's int never overflows. - ## Currently `shr` is also `arithm shr`, but it used to be `logic shr` - bind una, bin - una `~`, `not` - bin `^`, `xor`, `^=` - bin `&`, `and`, `&=` - bin `|`, `or`, `|=` - bin `<<`, `shl`, `<<=` - bin `>>`, `shr`, `>>=` - diff --git a/src/pylib/numTypes/ints/decl.nim b/src/pylib/numTypes/ints/decl.nim deleted file mode 100644 index ee3921392..000000000 --- a/src/pylib/numTypes/ints/decl.nim +++ /dev/null @@ -1,2 +0,0 @@ - -type NimInt* = system.int ## alias of system.int diff --git a/src/pylib/numTypes/ints/getter.nim b/src/pylib/numTypes/ints/getter.nim deleted file mode 100644 index 8a79502c2..000000000 --- a/src/pylib/numTypes/ints/getter.nim +++ /dev/null @@ -1,18 +0,0 @@ - - -import std/bitops -import ./decl -import ../reimporter - -template is_integer*(_: NimInt): bool{.pysince(3,12).} = true -template as_integer_ratio*(self: NimInt): (NimInt, NimInt){.pysince(3,8).} = (self, 1) - - -template bit_length*(self: NimInt): NimInt = - bind fastLog2, abs - 1 + fastLog2 abs(self) - -template bit_count*(self: NimInt): NimInt{.pysince(3,10).} = - self.countSetBits() - -template conjugate*(self: NimInt): NimInt = self diff --git a/src/pylib/numTypes/ints/init.nim b/src/pylib/numTypes/ints/init.nim deleted file mode 100644 index 1ec2db961..000000000 --- a/src/pylib/numTypes/ints/init.nim +++ /dev/null @@ -1,91 +0,0 @@ - -import ./decl -import ../reimporter -import ../utils/stripOpenArray -from std/strutils import toLowerAscii -from std/parseutils import parseInt, parseBin, parseOct, parseHex - -template int*(i: SomeInteger): NimInt = system.int(i) - -func invalidInt(s: string, base: int) = - raise newException(ValueError, - "invalid literal for int() with base " & $base & ": " & s) - -func int*(a: PyStr|PyBytes): NimInt = - let sa = $a - let (m, n) = (sa).stripAsRange - template stripped: untyped = (sa).toOpenArray(m, n) - let ni = parseInt(stripped, result) - if ni == 0: - invalidInt(repr(a), 10) - -func int*(a: char): NimInt = - result = system.int(a) -% system.int('0') # never overflow, so use `-%` - if result not_in 0..9: - invalidInt(repr(a), 10) - -template int*(a: bool): NimInt = (if a: 1 else: 0) -template int*(f: float): NimInt = system.int(f) - - -type HasIndex = concept self - self.index() is SomeInteger -type HasTrunc = concept self - self.trunc() is SomeInteger - -template int*(obj: HasIndex): NimInt = NimInt obj.index() -template int*(obj: HasTrunc): NimInt = NimInt obj.trunc() -template int*(obj: HasIndex and HasIndex): NimInt = NimInt obj.index() - -template nimint*(a): NimInt = - bind int - int(a) - -func parseIntPrefix(x: openArray[char]): int = - ## returns: - ## - ## * -1 if no prefix found - ## * -2 if invald prefix - ## - ## Never returns 0 - if x[0] == '0': - case x[1].toLowerAscii - of 'b': 2 - of 'o': 8 - of 'x': 16 - else: -2 - else: -1 - -type ParseIntError = object of CatchableError - base*: int - -func parseIntWithBase(x: openArray[char], base: int): int = - template invalidInt(base_arg: int) = - raise (ref ParseIntError)(base: base_arg) - template chk(i: int) = - if i != x.len: - invalidInt(base) - case base - of 2: chk x.parseBin result - of 8: chk x.parseOct result - of 16: chk x.parseHex result - of 0: - let prefixBase = parseIntPrefix x - if prefixBase < 0: - invalidInt 0 - result = parseIntWithBase(x, prefixBase) - elif base in 3..32: - raise newException(NotImplementedError, - "only 2, 8, 16 based int parsing is supported currently") - else: - raise newException(ValueError, "int() base must be >= 2 and <= 36, or 0") - -func int*(a: PyStr|PyBytes; base: int): NimInt = - ## allowed base - let sa = $a - let (m, n) = (sa).stripAsRange - try: - template stripped: untyped = (sa).toOpenArray(m, n) - result = parseIntWithBase(stripped, base) - except ParseIntError as e: - invalidInt(repr(a), e.base) diff --git a/src/pylib/numTypes/ints/int_bytes.nim b/src/pylib/numTypes/ints/int_bytes.nim deleted file mode 100644 index 9f21c45a6..000000000 --- a/src/pylib/numTypes/ints/int_bytes.nim +++ /dev/null @@ -1,149 +0,0 @@ - -from std/math import ceilDiv -import ./decl -import ./nint_proto -import ../reimporter -const weridTarget = defined(js) or defined(nimscript) - -func parseByteOrder(byteorder: string): Endianness = - if byteorder == "little": result = littleEndian - elif byteorder == "big": result = bigEndian - else: raise newException(ValueError, "byteorder must be either 'little' or 'big'") - -template highByte(b: PyBytes, endian: Endianness, hi = b.len-1): uint8 = - uint8: - if endian == bigEndian : b.getChar 0 - else: b.getChar hi - -template signbitSet(b: uint8): bool = - (b and 0b1000_0000'u8) == 0b1000_0000'u8 - -const arrNotCvtableInt = weridTarget - -when arrNotCvtableInt: - template charPart(i: NimInt): char = - when compileOption("jsBigInt64"): - # NIM-BUG: When char is unsigned, if only `cast[char](i)` - # you'll get surprising a char with negative `ord` result! - # (and converting it to int results in a negative int) - char cast[uint8](i) - else: - cast[char](i) - template loopRangeWithIt(bHi: int, byteorder: Endianness, body: untyped){.dirty.} = - if byteorder == bigEndian: - for it{.inject.} in countdown(bHi, 0): body - else: - for it{.inject.} in 0 .. bHi: body -else: - const BigEndian = cpuEndian == bigEndian - proc transInOrder(outBuf: var openArray[char], inBuf: openArray[char], endianness: Endianness, - length, totLen: int) = - template asgnWithI(inp, outp){.dirty.} = - for i in 0.. length: - raise newException(OverflowDefect, "int too big to convert") - - when arrNotCvtableInt: - result = newSeqOfCap[char](length) - loopRangeWithIt(length - 1, endianness): - result.add (self shr (it*8)).charPart - else: - const totByteLen = getSize(self) - result = newSeq[char](length) - let cstr = cast[array[totByteLen, char]](self) - transInOrder result, cstr, endianness, length = length, totLen = totByteLen - -func to_bytes*(self; length: int, byteorder: PyStr, signed=false): PyBytes = - let endianness = parseByteOrder $byteorder - bytes self.to_chars(length, endianness, signed=signed) - -func to_bytes*(self; length: int, byteorder: static[PyStr] = str("big"), signed=false - ): PyBytes{.pysince(3,11).} = - const endianness = parseByteOrder $byteorder - bytes self.to_chars(length, endianness, signed=signed) diff --git a/src/pylib/numTypes/ints/longint.nim b/src/pylib/numTypes/ints/longint.nim deleted file mode 100644 index aa8d2633c..000000000 --- a/src/pylib/numTypes/ints/longint.nim +++ /dev/null @@ -1,11 +0,0 @@ - -import ./init -## TODO: later may allow to switch to bigints when compile -{.pragma: unsupLong, deprecated: - """long(a.k.a. PyLong) is not supported, -currently it's just a alias of BiggestInt (e.g. int64 on 64bit system)""".} - -template long*(a: string): BiggestInt{.unsupLong.} = bind init; init.int(a) -template long*(a: char): BiggestInt{.unsupLong.} = bind init; init.int($a) -template long*[T: SomeNumber](a: T): BiggestInt{.unsupLong.} = BiggestInt(a) -template long*(a: bool): int{.unsupLong.} = BiggestInt(if a: 1 else: 0) diff --git a/src/pylib/numTypes/ints/nint_proto.nim b/src/pylib/numTypes/ints/nint_proto.nim deleted file mode 100644 index a15a9ff71..000000000 --- a/src/pylib/numTypes/ints/nint_proto.nim +++ /dev/null @@ -1,9 +0,0 @@ -## used by ./int_bytes - -import ./decl -from ./getter import bit_length -export bit_length - -template newInt*(): NimInt = NimInt(0) -template getSize*(self: NimInt): int = sizeof(NimInt) # sizeof cannot be overloaded -template fitLen*(_: var NimInt, nbyte: int): bool = nbyte <= sizeof(NimInt) diff --git a/src/pylib/numTypes/reimporter.nim b/src/pylib/numTypes/reimporter.nim deleted file mode 100644 index 020dba0c4..000000000 --- a/src/pylib/numTypes/reimporter.nim +++ /dev/null @@ -1,6 +0,0 @@ - -import ../version -import ../pystring/strimpl -import ../pybytes/bytesimpl -import ../pyerrors/rterr -export version, strimpl, bytesimpl, rterr diff --git a/src/pylib/numTypes/utils/stripOpenArray.nim b/src/pylib/numTypes/utils/stripOpenArray.nim deleted file mode 100644 index 72be0a3ba..000000000 --- a/src/pylib/numTypes/utils/stripOpenArray.nim +++ /dev/null @@ -1,43 +0,0 @@ - -import std/unicode except strip -import ../../pystring/consts - -func stripAsRange*(s: openArray[char], - leading: static[bool] = true, - trailing: static[bool] = true, - runes: openArray[Rune] = unicodeSpaces): tuple[first, last: int] = - ## `s[first..last]` will be stripped data. - var - sI = 0 ## starting index into string ``s`` - eI = s.high ## ending index into ``s``, where the last ``Rune`` starts - var - i, xI: int ## value of ``sI`` at the beginning of the iteration - rune: Rune - when leading: - while i < len(s): - xI = i - fastRuneAt(s, i, rune) - sI = i # Assume to start from next rune - if not runes.contains(rune): - sI = xI # Go back to where the current rune starts - break - when trailing: - i = eI - while i >= 0: - xI = i - fastRuneAt(s, xI, rune) - var yI = i - 1 - while yI >= 0: - var - yIend = yI - pRune: Rune - fastRuneAt(s, yIend, pRune) - if yIend < xI: break - i = yI - rune = pRune - dec(yI) - if not runes.contains(rune): - eI = xI - 1 - break - dec(i) - (sI, eI) diff --git a/src/pylib/ops.nim b/src/pylib/ops.nim deleted file mode 100644 index 4e4144874..000000000 --- a/src/pylib/ops.nim +++ /dev/null @@ -1,129 +0,0 @@ - -import std/math -from ./pyerrors/aritherr import ZeroDivisionError -import ./numTypes/ints/bitops - -## ## why no `/=` defined? -## For -## -## ```Nim -## template `/=`*(x: var SomeInteger, y: SomeInteger) -## ``` -## -## Nim is static-typed, but `/=` will cause lhs convert from int to float - - -# Power templates for different types of arguments -template `**`*[T](a: T, b: Natural): T = - ## power for `b` is a non-static integer: - ## - ## only Natural is acceptable unless `b` is static, - ## see `\`**\`(a: T; b: static[int])`_ - runnableExamples: - var i = -1 - doAssertRaises RangeDefect: - discard (5 ** i) - ## this runs iff `i` is of static[int] - ## e.g. `5 ** -1` - bind `^` - a ^ b - -template `**`*[T: SomeInteger](a: T; b: static[int]): T|float = - ## power for static int `b` - ## - ## so that result type can be inferred: - ## - ## - int if `b >= 0` - ## - float if `b < 0` - ## - ## For non-static int `b`, `\`**\`(a: T; b: Natural)`_ is used. - runnableExamples: - const f = 5 ** -1 # only when the rhs is static[int] - assert f == 0.2 - const i = 5 ** 2 - assert i == int(25) - when b < 0: - bind pow - pow(a.float, b.float) # returns float - else: - bind `^` - a ^ b # returns int - -# must after a ^ b -exportIntBitOps() - -template `**`*[T: SomeFloat](a, b: T): T = - bind pow - pow(a, b) -template `**`*[A: SomeFloat, B: SomeInteger](a: A, b: B): A = - bind pow - pow(a, A(b)) -template `**`*[A: SomeInteger; B: SomeFloat](a: A, b: B): B = - bind pow - pow(B(a), b) - -template `**=`*(a: var SomeNumber, b: SomeNumber) = - bind `**` - a = a**b - -# Comparasion operators. We only need 3 of them :<, <=, ==. -# Other comparasion operators are just shortcuts to these -template `<`*[A: SomeInteger, B: SomeFloat](a: A, b: B): bool = B(a) < b -template `<`*[A: SomeFloat, B: SomeInteger](a: A, b: B): bool = a < A(b) - -template `<=`*[A: SomeInteger, B: SomeFloat](a: A, b: B): bool = B(a) <= b -template `<=`*[A: SomeFloat, B: SomeInteger](a: A, b: B): bool = a <= A(b) - -template `==`*[A: SomeInteger, B: SomeFloat](a: A, b: B): bool = B(a) == b -template `==`*[A: SomeFloat, B: SomeInteger](a: A, b: B): bool = a == A(b) - -template `<>`*[A: SomeInteger, B: SomeFloat](a: A, b: B): bool = B(a) != b # Python 1.x and 2.x -template `<>`*[A: SomeFloat, B: SomeInteger](a: A, b: B): bool = a != A(b) # Python 1.x and 2.x - -template `/`*(x: SomeInteger, y: SomeInteger): float = system.`/`(float(x), float(y)) - - -template zeRaise(x) = - if x == typeof(x)(0): - raise newException(ZeroDivisionError, "division or modulo by zero") - -func `%`*[T: SomeNumber](a, b: T): T = - ## Python's modulo (a.k.a `floor modulo`) (`quotient`) - ## - ## .. hint:: Nim's `mod` is the same as `a - b * (a div b)` (`remainder`), - ## just like `C`. - runnableExamples: - assert 13 % -3 == -2 - assert -13 % 3 == 2 - zeRaise b - floorMod a,b - -template `%`*[A: SomeFloat, B: SomeInteger](a: A, b: B): A = a % A(b) -template `%`*[A: SomeInteger; B: SomeFloat](a: A, b: B): B = B(a) % b - -template `%=`*(self: var SomeNumber, x: SomeNumber) = self = self % x - -func `//`*[A, B: SomeFloat | SomeInteger](a: A, b: B): SomeNumber {.inline.} = - ## Python's division (a.k.a. `floor division`) - ## - ## .. hint:: Nim's `div` is division with any fractional part discarded - ## (a.k.a."truncation toward zero"), just like `C`. - runnableExamples: - assert 13 // -3 == -5 - assert 13 div -3 == -4 - when A is SomeInteger and B is SomeInteger: - (a - a % b) div b - else: - (a.float - a % b) / b.float - -template `//=`*[A, B: SomeFloat | SomeInteger](a: var A, b: B)= - a = a//b - -func divmod*[T: SomeNumber](x, y: T): (T, T) = - ## differs from `std/math` `divmod`, see `//`_ and `%`_ for details. - (x//y, x%y) - -template `==`*(a, b: typedesc): bool = - ## Compare 2 typedesc like Python. - runnableExamples: doAssert type(1) == type(2) - a is b diff --git a/src/pylib/ops/chk_shl.nim b/src/pylib/ops/chk_shl.nim deleted file mode 100644 index 2db607ed7..000000000 --- a/src/pylib/ops/chk_shl.nim +++ /dev/null @@ -1,9 +0,0 @@ - -func shlByMul[I: SomeInteger](a, b: I): I{.used.} = - result = a - for _ in 1..b: - result *= 2 - -func checkedShl*[I: SomeInteger](a, b: I): I = - when compileOption("overflowChecks"): shlByMul(a, b) - else: `shl`(a, b) diff --git a/src/pylib/private/backendMark.nim b/src/pylib/private/backendMark.nim deleted file mode 100644 index 1edc2a3e5..000000000 --- a/src/pylib/private/backendMark.nim +++ /dev/null @@ -1,125 +0,0 @@ - -import std/macros - -type - CompileBackend*{.pure.} = enum - # keep consist with `defined` name - c = "C" - cpp = "C++" - objc = "Object-C" - js = "JavaScript" - nimscript = "NimScript" - -const - BackendsDet: array[CompileBackend, bool] = [ - defined(c), - defined(cpp), - defined(objc), - defined(js), - defined(nimscript), - ] - -template inBackend(backend: CompileBackend): bool = BackendsDet[backend] -func inBackend(backends: openArray[CompileBackend]): bool = - result = false - for b in backends: - if BackendsDet[b]: - return true - -const NotSupportMsgTempl = "The symbol is not supported in the backend: " -template notSupportMsgNode(s): NimNode = newLit(NotSupportMsgTempl & s) -const - DocSep = "\n\n" - NotSupportDocTempl = ".. hint:: not available in " -template notSupportDoc(s): untyped = NotSupportDocTempl & s & " backend" - -func wrap1Impl(back: NimNode): NimNode = - quote do: CompileBackend.`back` - -macro wrap1(back): CompileBackend = wrap1Impl back - -func insertNotSuppPragma(res: NimNode, backendName: string) = - res.addPragma nnkExprColonExpr.newTree( - ident"error", - notSupportMsgNode(backendName) - ) - -func refineDoc(res: NimNode, backendName: string) = - let n = notSupportDoc backendName - var body = res.body - if body[0].kind != nnkCommentStmt: - body.insert(0, newCommentStmtNode n) - else: body[0].strVal = body[0].strVal & DocSep & n - -template noBackendImplBody(def, backend) = - result = def - let backendName = $backend - result.refineDoc backendName - if not inBackend backend: - return - result.insertNotSuppPragma backendName -func noBackendImpl(def: NimNode, backend: CompileBackend): NimNode = - noBackendImplBody def, backend - -macro noBackendAux(backend: static[CompileBackend]; def) = - noBackendImpl(def, backend) - -template noBackend1(targetBackend; def): untyped = - bind noBackendAux, wrap1 - noBackendAux(def, wrap1(targetBackend)) - -template noJsBackend*(def) = - bind noBackend1 - noBackend1(js, def) - -template noNimsBackend*(def) = - bind noBackend1 - noBackend1(nimscript, def) - -type Backends = openArray[CompileBackend] -func `$`(backends: Backends): string = - let le = backends.len - if unlikely(le == 0): return - result.add $backends[0] - for i in 1.. 0: - # let indent = le - content # then in fact indent = nLeading - margin = min(margin, nLeading) - # Remove indentation. - if lines.len > 0: - lines[0] = lines[0].lstripSpaces() - if margin < sys_maxsize: # then there was some indentation - for i in 1 .. hi: - lines[i] = lines[i].substr margin - # Remove any trailing or leading blank lines. - var - start = 0 - stop = hi - while stop > 0 and lines[^stop].len == 0: - dec stop - while start < hi and lines[start].len == 0: - inc start - ## a inline and faster version of: - ## '\n'.join lines.toOpenArray(start, stop) - result = lines[start] - inc start - for i in start..stop: - result.add '\n' - result.add lines[i] - -when isMainModule: - # from test_inspecty.py: test_cleandoc - const - cleandoc_testdata = [ - # first line should have different margin - (" An\n indented\n docstring.", "An\nindented\n docstring."), - # trailing whitespace are not removed. - (" An \n \n indented \n docstring. ", - "An \n \nindented \n docstring. "), - #[ XXX: TODO: std/strutils.split doesn't support NUL very well, - just gives `["doc\0string", "", " second\0line", " third\0line\0"]` - # NUL is not termination. - ("doc\0string\n\n second\0line\n third\0line\0", - "doc\0string\n\nsecond\0line\nthird\0line\0"), - ]# - # first line is lstrip()-ped. other lines are kept when no margin.[w: - (" ", ""), - # compiler.cleandoc() doesn"t strip leading/trailing newlines - # to keep maximum backward compatibility. - # inspect.cleandoc() removes them. - ("\n\n\n first paragraph\n\n second paragraph\n\n", - "\n\n\nfirst paragraph\n\n second paragraph\n\n"), - (" \n \n \n ", "\n \n \n "), - ] - - import std/enumerate - block: - for i, (input, expected) in enumerate(cleandoc_testdata): - # only inspect.cleandoc() strip \n - #expected = expected.strip("\n") - if (`inspect.cleandoc`(input) == expected.strip(chars={'\n'})): continue - echo repr `inspect.cleandoc`(input) - echo repr expected.strip(chars={'\n'}) diff --git a/src/pylib/private/iph_utils.nim b/src/pylib/private/iph_utils.nim deleted file mode 100644 index 6d0941de9..000000000 --- a/src/pylib/private/iph_utils.nim +++ /dev/null @@ -1,34 +0,0 @@ -##[ Macros to protect CRT calls against instant termination when passed an - invalid parameter (bpo-23524). IPH stands for Invalid Parameter Handler. - -CPython/Include/internal/pycore_fileutils.h -]## - -const MS_WINDOWS = defined(windows) - -when MS_WINDOWS and defined(vcc): - let MSC_VER{.importc: "_MSC_VER", nodecl.}: cint - type - wchar_t{.importc, header: "".} = int16 - uintptr_t{.importc, header: ""} = ( - when sizeof(cuint) == 4: uint64 else: cuint) - type wcharp = ptr wchar_t - proc slientInvalParamHandler( - expression, function, file: wcharp, - line: cuint, pReserved: uintptr_t){.cdecl.} = discard - type InvalParamHandler{.importc: "_invalid_parameter_handler".} = - typeof slientInvalParamHandler - proc setTLinvalParamHandler(pNewL: InvalParamHandler): InvalParamHandler{. - importc: "_set_thread_local_invalid_parameter_handler", - header: "".} - template with_Py_SUPPRESS_IPH*(body) = - bind setTLinvalParamHandler, slientInvalParamHandler - if MSC_VER >= 1900: - let oldHandler = setTLinvalParamHandler slientInvalParamHandler - body - discard setTLinvalParamHandler oldHandler - else: - body -else: - template with_Py_SUPPRESS_IPH*(body) = body - diff --git a/src/pylib/private/iterGen.nim b/src/pylib/private/iterGen.nim deleted file mode 100644 index 9a81363e4..000000000 --- a/src/pylib/private/iterGen.nim +++ /dev/null @@ -1,57 +0,0 @@ - -import std/macros - - -func capital(s: string): string = - ## assume s[0].isLowerAscii() - char(s[0].ord - 32) & s.substr(1) - -# XXX: NIM-BUG: do not implememt via `template items`. -# otherwise, when `for i in zip...`, -# zip object initialization will be -# wrongly placed in loop body -template makeIterable*(Typ){.dirty.} = - iterator items*[T](x: Typ[T]): T = - for i in x.iter(): yield i - -macro genIter*(def) = - ## used as pragma - ## - ## Generates code of non-reentrant iterable, - ## according to an iterator. - expectKind def, nnkIteratorDef - let nameAstr = def[0] - expectKind nameAstr, nnkPostfix - let name = nameAstr[1] - let - genericParams = def[2] - r_params = def[3] - otherPragmas = def[4] - body = def.body # def[5] - - let rtype = r_params[0] - - let sName = name.strVal - let typId = ident sName.capital() - let makeIterableId = bindSym"makeIterable" - result = newStmtList() - result.add quote do: - when not declared(`typId`): # XXX: allow overload/defined types - type `typId`[T] = object - iter*: iterator(): `rtype` - `makeIterableId` `typId` - - var funcDef = newProc(nameAstr, procType=nnkFuncDef, pragmas=otherPragmas) - funcDef[2] = genericParams - funcDef[3] = r_params.copy() - # genericParams[0].kind == nnkIdentDefs - let funcResType = genericParams[0][0] - funcDef[3][0] = nnkBracketExpr.newTree(typId, funcResType) - # no need to strip doc manually, - # as `body` is of lambda iterator. - let funcBody = quote do: - result.iter = iterator(): `rtype` = `body` - funcDef.body = funcBody - result.add funcDef - - result.add def diff --git a/src/pylib/private/platform_utils.nim b/src/pylib/private/platform_utils.nim deleted file mode 100644 index 0d94b0023..000000000 --- a/src/pylib/private/platform_utils.nim +++ /dev/null @@ -1,42 +0,0 @@ - -import std/macros - -const nimDoc = defined(nimdoc) -macro platformAvailImpl(inPlat: static[bool]; platStr: static[string]; def) = - if nimDoc: - def.body = newStmtList( - newCommentStmtNode ".. hint:: `Availability" & - "`_: " & - platStr, - nnkDiscardStmt.newTree newEmptyNode() - ) - return def - if inPlat: - return def - result = def - result.body = newEmptyNode() - result.addPragma newColonExpr( - ident"error", - newLit "this is only available on platform: " & platStr & '.' - ) - -template platformAvail*(platform; def) = - ## Pragma on procs to generate doc of sth like `Availability: Windows.` - ## - ## Currently, `platform` must be something - ## that can be put within `defined`. - bind platformAvailImpl - platformAvailImpl(defined(platform), astToStr(platform), def) - -template platformAvailWhen*(platform; cond: bool; def) = - bind platformAvailImpl - platformAvailImpl(defined(platform) and cond, - astToStr(platform) & " when " & astToStr(cond), def) - -template platformUnavail*(platform; def) = - bind platformAvailImpl - platformAvailImpl(not defined(platform), "not " & astToStr(platform), def) - -template platformNoJs*(def) = - bind platformUnavail - platformUnavail(js, def) diff --git a/src/pylib/private/trans_imp.nim b/src/pylib/private/trans_imp.nim deleted file mode 100644 index 1438ccf97..000000000 --- a/src/pylib/private/trans_imp.nim +++ /dev/null @@ -1,20 +0,0 @@ -## import & export helper -import std/macros - -macro impExp*(pre; mods: varargs[untyped]) = - ## gen: `import ./pre/[...mods]; export ...mods` - result = newStmtList() - var imp = newNimNode nnkImportStmt - var modsList = newNimNode nnkBracket - for m in mods: modsList.add m - - var impMods = infix(prefix(pre, "./"), "/", modsList) - - imp.add impMods - result.add imp - - var exp = newNimNode nnkExportStmt - for m in mods: - exp.add m - result.add exp - diff --git a/src/pylib/pybool.nim b/src/pylib/pybool.nim deleted file mode 100644 index d04d6d577..000000000 --- a/src/pylib/pybool.nim +++ /dev/null @@ -1,124 +0,0 @@ - -from ./collections_abc import Iterable -import ./noneType -import std/options - -type - PyBool* = distinct bool - -const - True* = PyBool true ## True - False* = PyBool false ## False - -using self, opyb: PyBool -template genBin(op){.dirty.} = - func op*(self; opyb): PyBool{.borrow.} - func op*(self; b: bool): PyBool{.borrow.} - func op*(b: bool, self): PyBool{.borrow.} -genBin `==` -func `is`*(self; opyb): PyBool{.borrow.} -func `xor`*(self; opyb): PyBool{.borrow.} ## EXT -func `not`*(self): PyBool{.borrow.} -genBin `and` -genBin `or` - -func repr*(self): string = - ## Returns "True" or "False" - if bool(self == True): "True" - else: "False" - -func `$`*(self): string = - ## alias for `repr`_ - ## - ## NOTE: CPython's `bool`'s `__str__` is itself not defined, - ## which is inherted from `object`, - ## which will call `obj.__repr__` as fallback. - ## This minics it. - repr self - -# https://github.com/nim-lang/Nim/issues/8197 -#[ -type - HasLen = concept x - x.len is int - - HasNotEqual = concept x - x != 0 is bool - - HasMoreThan = concept x - x > 0 is bool - - CanCompToNil = concept x - x == nil is bool - -converter bool*(arg: HasLen): bool = arg.len > 0 -converter bool*(arg: HasNotEqual): bool = arg != 0 -converter bool*(arg: HasMoreThan): bool = arg > 0 or arg < 0 -converter bool*(arg: CanCompToNil): bool = arg != nil -]# - -proc optionToBool[T](arg: Option[T]): bool - -template toBool*[T](arg: T): bool = - ## Converts argument to boolean, checking python-like truthiness. - bind None, isSome, Option, optionToBool, NoneType - # If we have len proc for this object - when compiles(arg.len): - arg.len > 0 - elif system.`is`(arg, SomeNumber): - # If we can compare if it's not 0 - arg != 0 # works for NaN - # If we can compare if it's greater than 0 - elif compiles(arg > 0): - arg > 0 or arg < 0 - # Initialized variables only - elif compiles(arg.isNil): - not arg.isNil - elif system.`is`(T, NoneType): - false #arg != None - elif compiles(arg.isNone): - not arg.isNone - elif compiles(bool(arg)): - bool(arg) - elif system.`is`(T, Option): - arg.optionToBool - else: - # XXX: is this correct? - true - -proc optionToBool[T](arg: Option[T]): bool = - arg.isSome and arg.unsafeGet.toBool - -converter toNimBool*(self): bool = bool(self) -converter pybool*(x: bool): PyBool = PyBool(x) -converter pybool*[T](x: T): PyBool = - ## Converts any to `PyBool` - ## - ## NOTE: In Nim, "implicit converter chain is not support". - ## (See `manual.html`_). - ## Therefore any type can be implicitly converted to `PyBool`, not `bool`, - ## which, however, is desired, as if any is convertible to bool, - ## then there'll be ## compile-error for `repr()` - PyBool toBool x - -func `not`*[T](nself: T): PyBool = not nself.pybool -func `and`*[T](nself, npyb: T): T = - if nself.pybool: npyb else: nself -func `or` *[T](nself, npyb: T): T = - if nself.pybool: nself else: npyb - -proc bool*[T](arg: T): PyBool = pybool(arg) ## Alias for `pybool`_ - -func all*[T](iter: Iterable[T]): PyBool = - ## Checks if all values in iterable are truthy - result = true - for element in iter: - if not bool(element): - return false - -func any*[T](iter: Iterable[T]): PyBool = - ## Checks if at least one value in iterable is truthy - result = false - for element in iter: - if bool(element): - return true diff --git a/src/pylib/pybytearray.nim b/src/pylib/pybytearray.nim deleted file mode 100644 index cf8d06c1a..000000000 --- a/src/pylib/pybytearray.nim +++ /dev/null @@ -1,162 +0,0 @@ - -import ./pybytes -export pybytes -import ./collections_abc, ./mutSeqSliceOp -import std/strutils - -# Begin impl -type - PyByteArray* = ref object - data: string - BytesLike* = PyByteArray | PyBytes - -using self: PyByteArray -using mself: PyByteArray - -func newPyByteArray*: PyByteArray{.inline.} = PyByteArray() -func newPyByteArray*(s: sink string): PyByteArray{.inline.} = PyByteArray(data: s) -func newPyByteArray*(len: int): PyByteArray{.inline.} = PyByteArray(data: newString(len)) - -func bytes*(self: sink PyByteArray): PyBytes{.inline.} = bytes(self.data) - -template asNim(self: PyByteArray): string = - ## returns a mutable var - self.data -converter toPyBytes*(self): PyBytes = bytes self.data -# then all non-inplace method are dispatched to PyBytes - -func getCharPtr*(self; i: Natural|Natural): ptr char = - ## EXT. - ## unstable. - ## used by Lib/array `frombytes` and `tobytes`. - self.data[i].addr - -# End impl - -template wrapCmp(op){.dirty.} = - func op*(self; other: PyBytes): bool = op self.asNim, $other - func op*(self; other: PyByteArray): bool = op self.asNim, other.asNim - -wrapCmp `==` -wrapCmp `<=` -wrapCmp `<` - -func `$`*(self): string = self.asNim -func toNimString*(self: PyByteArray): string = self.asNim -func toNimString*(self: var PyByteArray): var string = self.asNim - -func bytearray*: PyByteArray = newPyByteArray() -func bytearray*(o: BytesLike): PyByteArray = newPyByteArray(o) -func bytearray*(s: string): PyByteArray = newPyByteArray s - -func bytearray*(nbytes: int): PyByteArray = - when not defined(release): - if nbytes < 0: - raise newException(ValueError, "negative count") - newPyByteArray nbytes -func bytearray*(it: Iterable[char]): PyByteArray = - ## EXT. - var res: string - for c in it: - res.add it - newPyByteArray res -func bytearray*(it: Iterable[int]): PyByteArray = - var res: string - for i in it: - res.add i.chkChar - newPyByteArray res - -iterator chars*(self): char = - for c in self.asNim: - yield c - -iterator items*(self): int = - for c in self.chars: - yield int(c) - -func len*(self): int = self.asNim.len -when defined(danger): - template chkChar(c: int): char = cast[char](c) -elif defined(release): - template chkChar(c: int): char = char(c) -else: - func chkChar(c: int): char = - if c not_in 0..255: - raise newException(ValueError, "byte must be in range(0, 256)") - char(c) - -template normIdx(i; self): int = - if i < 0: self.len + i else: i -func `[]=`*(mself; i: int; val: int) = - `[]=` mself.asNim, i.normIdx mself, val.char - -func getChar*(self; i: Natural): char = self.asNim[i] -func `[]`*(self; i: Slice[int]): PyByteArray = - ## EXT. - ## `s[1..2]` means `s[1:3]`, and the latter is not valid Nim code - let le = i.b + 1 - i.a - if le <= 0: bytearray() - else: bytearray ($self)[i] - -func `[]`*(self; i: HSlice[int, BackwardsIndex]): PyByteArray = - self[i.a .. len(self) - int(i.b) ] - -func `[]=`*(mself; i: Slice[int], val: BytesLike) = - ## EXT. - ## `s[1..2]` means `s[1:3]`, and the latter is not valid Nim code - let le = i.b + 1 - i.a - if le <= 0: return - else: (mself.asNim)[i] = val.toNimString - -func `[]=`*(mself; i: HSlice[int, BackwardsIndex], val: BytesLike) = - mself[i.a .. len(mself) - int(i.b) ] = val - -func append*(mself; val: int) = add mself.asNim, val.chkChar -func extend*(mself; other: BytesLike) = add mself.asNim, other.toNimString -func `+=`*(mself; other: BytesLike) = mself.extend other - - -func copy*(self): PyByteArray = newPyByteArray(self.data) - -# why system has no such a proc: `insert(string, char, i)`... - -func insert*(mself; i: int, val: int) = - # note nim's arg order differs Python's - insert mself.asNim, $val.chkChar, i.normIdx mself - -func pop*(mself): int = - let hi = mself.len - 1 - result = mself[hi] - mself.asNim.setLen hi - -func remove*(mself; val: int) = - let c = val.chkChar - let idx = mself.asNim.find c - if idx == -1: return - mself.asNim.delete idx..idx - -func delitem*(mself; i: int) = - let idx = i.normIdx mself - mself.asNim.delete idx..idx - -func clear*(mself) = mself.asNim.setLen 0 - -func `*=`*(mself; n: int) = - ## bytearray.__imul__ - ## - ## Python: if n < 1: self.clear() - if n < 1: - mself.clear() - return - if n == 1: return - mself += bytes mself.data.repeat n-1 - -func getCharRef(mself; i: int): var char = mself.asNim[i] - -func reverse*(mself) = - let hi = mself.len - 1 - for i in 0 .. hi div 2: - swap mself.getCharRef(i), mself.getCharRef hi-i - -genDelItem PyByteArray -genNonGenericSetItem PyByteArray, Sequence[int] diff --git a/src/pylib/pybytes.nim b/src/pylib/pybytes.nim deleted file mode 100644 index 796ee0645..000000000 --- a/src/pylib/pybytes.nim +++ /dev/null @@ -1,6 +0,0 @@ - - -import ./private/trans_imp - -impExp pybytes, - bytesimpl, bytesmeth, bytesbltins, bytesprefix, translate, hex diff --git a/src/pylib/pybytes/bytesbltins.nim b/src/pylib/pybytes/bytesbltins.nim deleted file mode 100644 index 95f7eadd8..000000000 --- a/src/pylib/pybytes/bytesbltins.nim +++ /dev/null @@ -1,25 +0,0 @@ - -from std/algorithm import reversed -import ./bytesimpl -from ../pyerrors import TypeError -import ../builtins/reprImpl - -func reversed*(s: PyBytes): PyBytes = - pybytes reversed $s - -proc ord*(a: PyBytes): int = - ## Raises TypeError if len(a) is not 1. - - when not defined(release): - let ulen = a.len - if ulen != 1: - raise newException(TypeError, - "TypeError: ord() expected a character, but string of length " & $ulen & " found") - result = a[0] - -func repr*(x: PyBytes): string = - ## Overwites `system.repr` for `PyBytes` - ## - ## minics Python's - pyreprbImpl $x - diff --git a/src/pylib/pybytes/bytesimpl.nim b/src/pylib/pybytes/bytesimpl.nim deleted file mode 100644 index 776cb8541..000000000 --- a/src/pylib/pybytes/bytesimpl.nim +++ /dev/null @@ -1,134 +0,0 @@ - -import ../collections_abc -import ../nimpatch/newUninit - -type - PyBytes* = distinct string - -func bytes*(): PyBytes = PyBytes "" -func bytes*(s: sink string): PyBytes{.inline.} = PyBytes s ## XXX: Currently no - ## `encode` and `errors` params - -func bytes*(s: openArray[char|uint8]): PyBytes = - ## EXT. - ## - ## Python has no concept of openArray - var res = newStringUninit s.len - for i, c in s: - res[i] = char(c) - bytes res - -func bytes*(c: char): PyBytes = PyBytes $c - -func bytes*(nLen: int): PyBytes = - ## null bytes of length `nLen` (a.k.a. `b'\0'*nLen`) - var s = newString(nLen) - PyBytes $s - -using self: PyBytes -using mself: var PyBytes - -func getCharPtr*(self; i: Natural|BackwardsIndex): ptr char = - ## EXT. - ## unstable. - ## used by Lib/array `frombytes` and `tobytes` - string(self)[i].addr - -func add(mself; s: string){.borrow.} # inner use -func add(mself; s: char){.borrow.} # inner use - -func bytes*(x: Iterable[SomeInteger]): PyBytes = - for i in x: - result.add char(i) - -func bytes*(x: Iterable[char]): PyBytes = - ## EXT. as Python has no `char` type. - for c in x: - result.add c - -func bytes*(self): PyBytes = self ## copy - -template pybytes*[T](x: T): PyBytes = - mixin bytes - bytes(x) - -func `$`*(self): string{.borrow.} ## to Nim string -func fspath*(self): PyBytes = self ## make a PathLike -converter toNimString*(self): string = $self - -# contains(PyBytes, int|PyButes): bool is in bytesmeth - -func `==`*(self; o: PyBytes): bool{.borrow.} - -func `&`(self; o: PyBytes): PyBytes{.borrow.} -func `&`(self; o: string): PyBytes{.borrow.} -func `&`(self; o: char): PyBytes{.borrow.} - -func `+`*(self; o: PyBytes): PyBytes = self & o -func `+`*(self; o: string): PyBytes = self & o -func `+`*(self; o: char): PyBytes = self & o - -func `+`*(o: string, self): PyBytes = self & o -func `+`*(o: char, self): PyBytes = self & o - -func `+=`*(mself; s: PyBytes) = mself.add $s -func `+=`*(mself; s: char) = mself.add s -func `+=`*(mself; s: string) = mself.add s - - -func len*(self): int{.borrow.} -func byteLen*(self): int = system.len self ## EXT. the same as len(self) - -proc substr*(self; start, last: int): PyBytes{.borrow.} ## EXT. byte index -proc substr*(self; start: int): PyBytes{.borrow.} ## EXT. byte index - -func getChar*(self; i: Natural): char = cast[string](self)[i] ## EXT. -func contains(a: PyBytes, o: char): bool{.borrow.} ## for hasChar only. -func hasChar*(a: PyBytes, o: char): bool = o in a ## EXT. 'c' in b"asc" is allowed -# other versions of contains is in ./bytesmeth - -func `[]`*(self; i: int): int = - let c = self.getChar(if i < 0: len(self) + i else: i) - cast[int](c) - -func `[]`*(self; i: Slice[int]): PyBytes = - ## EXT. - ## `s[1..2]` means `s[1:3]`, and the latter is not valid Nim code - let le = i.b + 1 - i.a - if le <= 0: bytes() - else: bytes ($self)[i] -func `[]`*(self; i: HSlice[int, BackwardsIndex]): PyBytes = - self[i.a .. len(self) - int(i.b) ] - -iterator chars*(self): char = - ## EXT. - for c in self.string: - yield c - -iterator items*(self): int = - for c in self.string: - yield cast[int](c) - -func `@`*(self: PyBytes): seq[char] = - ## EXT. - ## - ## Python has no concept of seq (though has list) - when declared(newSeqUninit): - # only newer Nim declares it. - result = newSeqUninit[char] self.len - else: - result = newSeq[char] self.len - var i = 0 - for c in self.chars: - result[i] = c - i.inc - -template `or`*(a, b: PyBytes): PyBytes = - ## Mimics Python str or str -> str. - ## Returns `a` if `a` is not empty, otherwise b (even if it's empty) - if a.byteLen > 0: a else: b - -template `not`*(s: PyBytes): bool = - ## # Mimics Python not str -> bool. - ## "not" for strings, return true if the string is not nil or empty. - s.byteLen == 0 diff --git a/src/pylib/pybytes/bytesmeth.nim b/src/pylib/pybytes/bytesmeth.nim deleted file mode 100644 index 68724cf71..000000000 --- a/src/pylib/pybytes/bytesmeth.nim +++ /dev/null @@ -1,178 +0,0 @@ - -import std/strutils except rsplit, split, strip -import ./bytesimpl -import ./strip, ./split/[split, rsplit] -export strip, split, rsplit -import ../stringlib/meth -import ../version - - -template `*`*(a: PyBytes; i: int): PyBytes = - bind repeat, PyBytes - PyBytes repeat($a, i) -template `*`*(i: int, a: PyBytes): PyBytes = - bind `*` - a * i - -func count*(a: PyBytes, sub: PyBytes): int = - meth.count(a, sub) - -func count*(a: PyBytes, sub: PyBytes, start: int): int = - meth.count(a, sub, start) - -func count*(a: PyBytes, sub: PyBytes, start=0, `end`: int): int = - meth.count(a, sub, start, `end`) - -template chkChr(i): char = - if i not_in 0..256: - raise newException(ValueError, "ValueError: byte must be in range(0, 256)") - cast[char](i) -func count*(a: PyBytes, sub: int): int = count($a, chkChr sub) -func count*(a: PyBytes, sub: int, start: int): int = - count(($a)[start..^1], chkChr sub) -func count*(a: PyBytes, sub: int, start=0, `end`: int): int = - count(($a)[start..^`end`], chkChr sub) - -template casefold*(a: PyBytes): PyBytes = - bind pybytes - pybytes strutils.toLowerAscii(a) - -func lower*(a: PyBytes): PyBytes = pybytes toLowerAscii $a -func upper*(a: PyBytes): PyBytes = pybytes toUpperAscii $a - -template titleImpl(result; s, isupper, islower, upper, lower, iter, adder) = - var previous_is_cased = false - for c in s.iter: - var nc: typeof(c) - if islower(c): - if not previous_is_cased: - nc = upper(c) - previous_is_cased = true - elif isupper(c): - if previous_is_cased: - nc = lower(c) - previous_is_cased = true - else: - previous_is_cased = false - result.adder nc - -func title*(a: PyBytes): PyBytes = - result.titleImpl a, isUpperAscii, isLowerAscii, - toUpperAscii, toLowerAscii, chars, `+=` - -func capitalize*(a: PyBytes): PyBytes = - ## make the first character have upper case and the rest lower case. - ## - if len(a) == 0: - return pybytes "" - result = a.getChar(0).toUpperAscii() + substr(a, 1).lower() - -template seWith(seWith){.dirty.} = - func sewith*(a: PyBytes, suffix: char): bool = - meth.seWith(a, suffix) - func sewith*(a: PyBytes, suffix: int): bool = - meth.seWith(a, chkChr suffix) - func sewith*[Tup: tuple](a: PyBytes, suffix: Tup): bool = - meth.seWith(a, suffix) - func sewith*[Suf: PyBytes | tuple](a: PyBytes, suffix: Suf, start: int): bool = - meth.seWith(a, suffix, start) - func sewith*[Suf: PyBytes | tuple](a: PyBytes, suffix: Suf, - start, `end`: int): bool = - meth.seWith(a, suffix, start, `end`) - -seWith startsWith -seWith endsWith - -func find*(a: PyBytes, b: int, start = 0, `end` = len(a)): int = - meth.find1(a, b, start, `end`) - -func rfind*(a: PyBytes, b: int, start = 0, `end` = len(a)): int = - meth.rfind1(a, b, start, `end`) - -func index*(a: PyBytes, b: int, start = 0, `end` = len(a)): int = - meth.index1(a, b, start) - -func rindex*(a: PyBytes, b: int, start = 0, `end` = len(a)): int = - meth.rindex1(a, b, start, `end`) - - -func find*(a: PyBytes, b: PyBytes, start = 0, `end` = len(a)): int = - meth.find(a, b, start, `end`) - -func rfind*(a: PyBytes, b: PyBytes, start = 0, `end` = len(a)): int = - meth.rfind(a, b, start, `end`) - -func index*(a: PyBytes, b: PyBytes, start = 0, `end` = len(a)): int = - meth.index(a, b, start) - -func rindex*(a: PyBytes, b: PyBytes, start = 0, `end` = len(a)): int = - meth.rindex(a, b, start, `end`) - -func contains*(a: PyBytes, o: PyBytes): bool{.borrow.} -func contains*(a: PyBytes, o: int): bool = a.find(o) != -1 - -template W(isX) = - func isX*(a: PyBytes): bool = meth.isX($a) - -func isascii*(a: PyBytes): bool{.pysince(3,7).} = meth.isascii($a) -W isspace -W isalpha -W isdigit - -template firstChar(s: PyBytes): char = s.getChar 0 -template bytesAllAlpha(s: PyBytes, isWhat, notWhat): untyped = - s.allAlpha isWhat, notWhat, chars, firstChar -func islower*(a: PyBytes): bool = a.bytesAllAlpha isLowerAscii, isUpperAscii -func isupper*(a: PyBytes): bool = a.bytesAllAlpha isUpperAscii, isLowerAscii -func istitle*(a: PyBytes): bool = - a.istitleImpl isUpperAscii, isLowerAscii, chars, firstChar - -func center*(a: PyBytes, width: int, fillchar = ' '): PyBytes = - ## Mimics Python bytes.center(width: int, fillchar = b" ") -> bytes - pybytes meth.center(a, width, fillchar) - -func ljust*(a: PyBytes, width: int, fillchar = ' ' ): PyBytes = - pybytes meth.ljust(a, width, fillchar) -func rjust*(a: PyBytes, width: int, fillchar = ' ' ): PyBytes = - pybytes meth.rjust(a, width, fillchar) - -func center*(a: PyBytes, width: int, fillchar: PyBytes): PyBytes = - meth.center(a, width, fillchar) - -func ljust*(a: PyBytes, width: int, fillchar: PyBytes): PyBytes = - meth.ljust(a, width, fillchar) - -func rjust*(a: PyBytes, width: int, fillchar: PyBytes ): PyBytes = - meth.rjust(a, width, fillchar) - -func zfill*(a: PyBytes, width: int): PyBytes = - PyBytes meth.zfill($a, width) - -func removeprefix*(a: PyBytes, suffix: PyBytes): PyBytes = - meth.removeprefix(a, suffix) -func removesuffix*(a: PyBytes, suffix: PyBytes): PyBytes = - meth.removesuffix(a, suffix) - -func replace*(a: PyBytes, sub, by: PyBytes|char): PyBytes = - meth.replace(a, sub, by) - -func replace*(a: PyBytes, sub, by: PyBytes|char, count: int): PyBytes = - ## bytes.replace(sub, by, count = -1)' - ## - ## count may be negative or zero. - meth.replace(a, sub, by, count) - -func expandtabs*(a: PyBytes, tabsize=8): PyBytes = - bytes expandtabsImpl(a, tabsize, a.len, chars) - -func join*[T](sep: PyBytes, a: openArray[T]): PyBytes = - ## Mimics Python join() -> bytes - meth.join(sep, a) - -func partition*(a: PyBytes, sep: PyBytes): tuple[before, sep, after: PyBytes] = - meth.partition(a, sep) - -func rpartition*(a: PyBytes, sep: PyBytes): tuple[before, sep, after: PyBytes] = - meth.rpartition(a, sep) - - diff --git a/src/pylib/pybytes/bytesprefix.nim b/src/pylib/pybytes/bytesprefix.nim deleted file mode 100644 index b95c8d4f8..000000000 --- a/src/pylib/pybytes/bytesprefix.nim +++ /dev/null @@ -1,23 +0,0 @@ - -import ./bytesimpl -import ../translateEscape - -func b*(c: char{lit}): PyBytes = pybytes c -func b*(s: static[string]{lit}): PyBytes = - ## XXX: Currently - ## `\Uxxxxxxxx` and `\uxxxx` - ## is supported as an extension. - const ns = translateEscape s - pybytes ns - -func br*(s: string{lit}): PyBytes = - pybytes s - -template rawB(pre){.dirty.} = - template pre*(s): PyBytes = - bind br - br s - -rawB rb -rawB Rb -rawB Br diff --git a/src/pylib/pybytes/hex.nim b/src/pylib/pybytes/hex.nim deleted file mode 100644 index c28f21da3..000000000 --- a/src/pylib/pybytes/hex.nim +++ /dev/null @@ -1,66 +0,0 @@ - -import ./bytesimpl -import ../pystring/strimpl -import std/strutils - -const hexChars = "0123456789abcdef" - -template setHex(result; c: char, base: int) = - var n = ord(c) - result[base + 1] = hexChars[n and 0xF] - n = n shr 4 - result[base] = hexChars[n] - -func toLowerHex(s: string): string = - result = newString(s.len * 2) - for pos, c in s: - result.setHex c, 2 * pos - -func toLowerHex(s: string; sep: char): string = - let le = s.len - if le == 0: return "" - if le == 1: return s.toLowerHex - result = newString le * 3 - 1 - result.setHex s[0], 0 - for i in 1..".} - var buffer: char - let buflen = uint 1 - let flags = cuint 0 - # ignore the result, Python checks for ENOSYS at runtime - discard getrandom(addr buffer, buflen, flags) - - template syscalChkAndExport(def){.dirty.} = - AC_LINK_IFELSE have_getrandom_syscall, false: - def - var buffer: char - let buflen = uint 1 - let flags{.importc: "GRND_NONBLOCK", header: "".}: cint - # ignore the result, Python checks for ENOSYS at runtime - discard syscall(SYS_getrandom, addr buffer, buflen, flags) - when have_getrandom_syscall: - def - - syscalChkAndExport: - let SYS_getrandom* {.importc, header: "".}: clong - const syscallHeader = """#include - #include """ - proc syscall*(n: clong): clong {. - importc: "syscall", varargs, header: syscallHeader.} -else: - const - have_getrandom* = false - have_getrandom_syscall* = false - -const py_getrandom* = have_getrandom or have_getrandom_syscall diff --git a/src/pylib/pyconfig/builtin_available.nim b/src/pylib/pyconfig/builtin_available.nim deleted file mode 100644 index da094c4f4..000000000 --- a/src/pylib/pyconfig/builtin_available.nim +++ /dev/null @@ -1,35 +0,0 @@ - -when defined(macosx): - import ./util - const - HAVE_BUILTIN_AVAILABLE_int = from_c_int(HAVE_BUILTIN_AVAILABLE, 0): - {.emit: """ - #if defined(__has_builtin) - #if __has_builtin(__builtin_available) - #define HAVE_BUILTIN_AVAILABLE 1 - #endif - #endif - """.} - HAVE_BUILTIN_AVAILABLE* = HAVE_BUILTIN_AVAILABLE_int != 0 - when HAVE_BUILTIN_AVAILABLE: - const ANY_VER* = 0.0 - template add_target_version(res, os, ver) = - when ver != ANY_VER: - res.add os - res.add ' ' - res.add $ver - res.add ',' - - func builtin_available_expr(macos, ios, tvos, watchos = ANY_VER): string = - result = "__builtin_available(" - add_target_version(result, "macOS", macos) - add_target_version(result, "iOS", ios) - add_target_version(result, "tvOS", tvos) - add_target_version(result, "watchOS", watchos) - result.add "*)" - - template builtin_available*(macos, ios, tvos, watchos = ANY_VER): bool = - bind from_c_int_expr, builtin_available_expr - from_c_int_expr(builtin_available_expr(macos, ios, tvos, watchos), 0) != 0 - - diff --git a/src/pylib/pyconfig/chmods.nim b/src/pylib/pyconfig/chmods.nim deleted file mode 100644 index 58a063ba1..000000000 --- a/src/pylib/pyconfig/chmods.nim +++ /dev/null @@ -1,20 +0,0 @@ - -import ./util -import ./have_x_runtime - -AC_CHECK_FUNCS( - chmod, - fchmod, - fchmodat, -) - -when defined(linux): - # Force lchmod off for Linux. Linux disallows changing the mode of symbolic - # links. Some libc implementations have a stub lchmod implementation that always - # returns an error. - const HAVE_LCHMOD* = false -else: - AC_CHECK_FUNC(lchmod) - -check_func_runtime fchmodat, 10.10, 8.0 - diff --git a/src/pylib/pyconfig/floats.nim b/src/pylib/pyconfig/floats.nim deleted file mode 100644 index c4892f939..000000000 --- a/src/pylib/pyconfig/floats.nim +++ /dev/null @@ -1,205 +0,0 @@ - - -import ./util - -AC_RUN_IFELSE X87_double_rounding, false: - # On IEEE 754, test should return 1 if rounding mode is round-to-nearest. - # maybe following is enough, but I still put origin C code below - import std/fenv;quit int(fegetround()==FE_TONEAREST) -#[ - Detect whether system arithmetic is subject to x87-style double - rounding issues. The result of this test has little meaning on non - IEEE 754 platforms. On IEEE 754, test should return 1 if rounding - mode is round-to-nearest and double rounding issues are present, and - 0 otherwise. See https://github.com/python/cpython/issues/47186 for more info. -[for x87-style double rounding], [ac_cv_x87_double_rounding], -# $BASECFLAGS may affect the result - -#include -#include -int main(void) { - volatile double x, y, z; - /* 1./(1-2**-53) -> 1+2**-52 (correct), 1.0 (double rounding) */ - x = 0.99999999999999989; /* 1-2**-53 */ - y = 1./x; - if (y != 1.) - exit(0); - /* 1e16+2.99999 -> 1e16+2. (correct), 1e16+4. (double rounding) */ - x = 1e16; - y = 2.99999; - z = x + y; - if (z != 1e16+4.) - exit(0); - /* both tests show evidence of double rounding */ - exit(1); -} -]# - -AC_LINK_IFELSE HAVE_GCC_ASM_FOR_X87, false: - func main = - {.emit:""" -unsigned short cw; -__asm__ __volatile__ ("fnstcw %0" : "=m" (cw)); -__asm__ __volatile__ ("fldcw %0" : : "m" (cw)); -""".} - main() - -AC_LINK_IFELSE HAVE_GCC_ASM_FOR_MC68881, false: - func main = - var fpcr: c_uint - {.emit: """ - __asm__ __volatile__ ("fmove.l %%fpcr,%0" : "=g" (`fpcr`)); - __asm__ __volatile__ ("fmove.l %0,%%fpcr" : : "g" (`fpcr`)); - """.} - main() - -## --- HAVE_PY_SET_53BIT_PRECISION macro ------------------------------------ -#[ - The functions _Py_dg_strtod() and _Py_dg_dtoa() in Python/dtoa.c (which are - required to support the short float repr introduced in Python 3.1) require - that the floating-point unit that's being used for arithmetic operations on - C doubles is set to use 53-bit precision. It also requires that the FPU - rounding mode is round-half-to-even, but that's less often an issue. - - If your FPU isn't already set to 53-bit precision/round-half-to-even, and - you want to make use of _Py_dg_strtod() and _Py_dg_dtoa(), then you should: - - #define HAVE_PY_SET_53BIT_PRECISION 1 - - and also give appropriate definitions for the following three macros: - - * _Py_SET_53BIT_PRECISION_HEADER: any variable declarations needed to - use the two macros below. - * _Py_SET_53BIT_PRECISION_START: store original FPU settings, and - set FPU to 53-bit precision/round-half-to-even - * _Py_SET_53BIT_PRECISION_END: restore original FPU settings - - The macros are designed to be used within a single C function: see - Python/pystrtod.c for an example of their use. -]# - - -# Get and set x87 control word for gcc/x86 - -when HAVE_GCC_ASM_FOR_X87: - template HAVE_PY_SET_53BIT_PRECISION*: bool = true - - # Functions defined in Python/pymath.c - ## Inline assembly for getting and setting the 387 FPU control word on - ## GCC/x86. - - ##ifdef _Py_MEMORY_SANITIZER - #__attribute__((no_sanitize_memory)) - ##endif - proc Py_get_387controlword: c_ushort = - {.emit: """ - __asm__ __volatile__ ("fnstcw %0" : "=m" (`result`)); - """.} - - proc Py_set_387controlword(cw: c_ushort) = - {.emit: """ - __asm__ __volatile__ ("fldcw %0" : : "m" (`cw`)); - """.} - - template Py_SET_53BIT_PRECISION_HEADER*{.dirty.} = - type ControlWord = c_ushort - var old_387controlword, new_387controlword: ControlWord - template Py_SET_53BIT_PRECISION_START* = - old_387controlword = Py_get_387controlword(); - new_387controlword = (old_387controlword and not 0x0f00.ControlWord) or 0x0200 - if new_387controlword != old_387controlword: - Py_set_387controlword(new_387controlword) - template Py_SET_53BIT_PRECISION_END* = - if new_387controlword != old_387controlword: - Py_set_387controlword(old_387controlword) - -# Get and set x87 control word for VisualStudio/x86. -# x87 is not supported in 64-bit or ARM. -when defined(vcc) and - #[ && !defined(_WIN64) && !defined(_M_ARM) ]# - defined(windows) and not defined(arm64): - template HAVE_PY_SET_53BIT_PRECISION*: bool = true - - {.push header: "".} - proc c_control87_2( - `new`, mask: c_uint; x86_cw, sse2_cw: ptr c_uint - ): c_int{.discardable, importc: "__control87_2".} - let - c_MCW_PC{.importc: "_MCW_PC".}, - c_MCW_RC{.importc: "_MCW_RC".}, - c_PC_53{.importc: "_PC_53".}, - c_RC_NEAR{.importc: "_RC_NEAR".}: c_uint - {.pop.} - - template Py_SET_53BIT_PRECISION_HEADER*{.dirty.} = - var old_387controlword, new_387controlword, out_387controlword: c_uint - # We use the __control87_2 function to set only the x87 control word. - # The SSE control word is unaffected. - - template Py_SET_53BIT_PRECISION_START* = - c_control87_2(0, 0, old_387controlword.addr, nil) - new_387controlword = - (old_387controlword and not(c_MCW_PC or c_MCW_RC)) or - (c_PC_53 or c_RC_NEAR) - if new_387controlword != old_387controlword: - c_control87_2(new_387controlword, c_MCW_PC or c_MCW_RC, - out_387controlword.addr, nil) - template Py_SET_53BIT_PRECISION_END* = - if new_387controlword != old_387controlword: - c_control87_2(old_387controlword, c_MCW_PC or c_MCW_RC, - out_387controlword.addr, nil) - - -# MC68881 - -when HAVE_GCC_ASM_FOR_MC68881: - template HAVE_PY_SET_53BIT_PRECISION*: bool{.redefine.} = true - {.push redefine.} - template Py_SET_53BIT_PRECISION_HEADER*{.dirty.} = - var old_fpcr, new_fpcr: c_uint - template Py_SET_53BIT_PRECISION_START* = - asm """ "fmove.l %%fpcr,%0" : "=g" (old_fpcr)""" - # Set double precision / round to nearest. - new_fpcr = (old_fpcr and not cuint(0xf0)) or cuint(0x80) - if new_fpcr != old_fpcr: - {.emit: """ - __asm__ volatile ("fmove.l %0,%%fpcr" : : "g" (new_fpcr)); - """.} - template Py_SET_53BIT_PRECISION_END* = - if new_fpcr != old_fpcr: - {.emit: """ - __asm__ volatile ("fmove.l %0,%%fpcr" : : "g" (old_fpcr)); - """.} - {.pop.} - -# Default definitions are empty -when not declared(Py_SET_53BIT_PRECISION_HEADER): - template HAVE_PY_SET_53BIT_PRECISION*: bool = false - template noop(name) = - template name* = discard - noop Py_SET_53BIT_PRECISION_HEADER - noop Py_SET_53BIT_PRECISION_START - noop Py_SET_53BIT_PRECISION_END - - - - -# ref: https://www.gnu.org/software/autoconf-archive/ax_c_float_words_bigendian.html - -AX_C_FLOAT_WORDS_BIGENDIAN_def DOUBLE_IS_BIG_ENDIAN_IEEE754, DOUBLE_IS_LITTLE_ENDIAN_IEEE754: - when not defined(js) and not defined(nimscript): - from std/strutils import contains - when "arm" in hostCPU: - def DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754 ## CPython/configure.ac - else: - {.error: """unknown float word ordering. - You need to manually -d:DOUBLE_IS_BIG_ENDIAN_IEEE754 or -d:DOUBLE_IS_LITTLE_ENDIAN_IEEE754 - or -d:DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754 - """.} - -template expAsSym(sym) = - const sym* = defined(sym) - -expAsSym DOUBLE_IS_BIG_ENDIAN_IEEE754 -expAsSym DOUBLE_IS_LITTLE_ENDIAN_IEEE754 -expAsSym DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754 diff --git a/src/pylib/pyconfig/have_x_runtime.nim b/src/pylib/pyconfig/have_x_runtime.nim deleted file mode 100644 index 567550620..000000000 --- a/src/pylib/pyconfig/have_x_runtime.nim +++ /dev/null @@ -1,17 +0,0 @@ - - -when defined(macosx): - import ./util - import ./builtin_available - template check_func_runtime*(fn; macos, ios, tvos, watchos = ANY_VER) = - ## export const HAVE_`fn`_RUNTIME - const fn_str = astToStr(fn) - const `HAVE fn RUNTIME`* = from_c_int_expr("HAVE_" & fn_str & "_RUNTIME", - when HAVE_BUILTIN_AVAILABLE: - builtin_available_expr(macos, ios, tvos, watchos) - else: - fn_str & " != NULL") -else: - template check_func_runtime*(fn; versionsOfApple: varargs[untyped]) = - ## export const HAVE_`fn`_RUNTIME - const `HAVE fn RUNTIME`* = true diff --git a/src/pylib/pyconfig/main.nim b/src/pylib/pyconfig/main.nim deleted file mode 100644 index 182ac71ac..000000000 --- a/src/pylib/pyconfig/main.nim +++ /dev/null @@ -1,2 +0,0 @@ -import ./floats, ./simp -export floats, simp diff --git a/src/pylib/pyconfig/os.nim b/src/pylib/pyconfig/os.nim deleted file mode 100644 index f180de93a..000000000 --- a/src/pylib/pyconfig/os.nim +++ /dev/null @@ -1,24 +0,0 @@ - -import ./util -import ./have_x_runtime -const - DEFAULT_DIR_FD* = from_c_int(AT_FDCWD, "", -100) - AT_SYMLINK_NOFOLLOW* = from_c_int(AT_SYMLINK_NOFOLLOW, "", 0x100) - - HAVE_OPENAT* = true - HAVE_FTRUNCATE* = true - -AC_CHECK_FUNCS( - uname, - unlinkat, - fdopendir, -) - -check_func_runtime unlinkat, 10.10, 8.0 -check_func_runtime fdopendir, 10.10, 8.0 - -when HAVE_UNLINKAT_RUNTIME and not declared(unlinkat): - proc unlinkat*(dir_fd: cint, path: cstring, flag: cint): cint{.importc, - header: "".} - let AT_REMOVEDIR*{.importc, header: "".}: cint - diff --git a/src/pylib/pyconfig/os_consts.nim b/src/pylib/pyconfig/os_consts.nim deleted file mode 100644 index 5c760f520..000000000 --- a/src/pylib/pyconfig/os_consts.nim +++ /dev/null @@ -1,17 +0,0 @@ - -import ./util - -template o(name) = - const `bare name` = from_c_int(name, "") - when `bare name` != int.low: - const name* = cint `bare name` - -o O_ASYNC -o O_DIRECT -o O_DIRECTORY -o O_NOFOLLOW -o O_NOATIME -o O_PATH -o O_TMPFILE -o O_SHLOCK -o O_EXLOCK diff --git a/src/pylib/pyconfig/pycore/pymath.nim b/src/pylib/pyconfig/pycore/pymath.nim deleted file mode 100644 index 8e2cfa571..000000000 --- a/src/pylib/pyconfig/pycore/pymath.nim +++ /dev/null @@ -1,7 +0,0 @@ -## Py_ADJUST_ERANGE1 and Py_ADJUST_ERANGE2 are defined in pylib/builtins/private/pycore_pymath.nim -## as they're only required but complex-about routinues - -import ../../private/trans_imp - -impExp pymath, - short_float_repr diff --git a/src/pylib/pyconfig/pycore/pymath/short_float_repr.nim b/src/pylib/pyconfig/pycore/pymath/short_float_repr.nim deleted file mode 100644 index 5af354b82..000000000 --- a/src/pylib/pyconfig/pycore/pymath/short_float_repr.nim +++ /dev/null @@ -1,45 +0,0 @@ - -import ../../floats -export - X87_DOUBLE_ROUNDING, HAVE_PY_SET_53BIT_PRECISION, - DOUBLE_IS_LITTLE_ENDIAN_IEEE754, DOUBLE_IS_BIG_ENDIAN_IEEE754, - DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754 - -const - WORDS_BIGENDIAN* = cpuEndian == bigEndian - WORDS_LITTLEENDIAN* = cpuEndian == littleEndian - - -##[ - ref https://nim-lang.org/docs/manual.html#types-preminusdefined-floatingminuspoint-types - Nim's float XX shall always follows IEEE754 -]## - - -## --- _PY_SHORT_FLOAT_REPR macro ------------------------------------------- - -# If we can't guarantee 53-bit precision, don't use the code -# in Python/dtoa.c, but fall back to standard code. This -# means that repr of a float will be long (17 significant digits). -# -# Realistically, there are two things that could go wrong: -# -# (1) doubles aren't IEEE 754 doubles, or -# (2) we're on x86 with the rounding precision set to 64-bits -# (extended precision), and we don't know how to change -# the rounding precision. -when not defined(DOUBLE_IS_LITTLE_ENDIAN_IEEE754) and - not defined(DOUBLE_IS_BIG_ENDIAN_IEEE754) and - not defined(DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754): - const PY_SHORT_FLOAT_REPR = false - -# Double rounding is symptomatic of use of extended precision on x86. -# If we're seeing double rounding, and we don't have any mechanism available -# for changing the FPU rounding precision, then don't use Python/dtoa.c. -when X87_DOUBLE_ROUNDING and not HAVE_PY_SET_53BIT_PRECISION: - const PY_SHORT_FLOAT_REPR = false - -when not declared(PY_SHORT_FLOAT_REPR): - const PY_SHORT_FLOAT_REPR = true - -export PY_SHORT_FLOAT_REPR diff --git a/src/pylib/pyconfig/resource.nim b/src/pylib/pyconfig/resource.nim deleted file mode 100644 index dddd2f3e1..000000000 --- a/src/pylib/pyconfig/resource.nim +++ /dev/null @@ -1,27 +0,0 @@ - -import ./util - -const - RUSAGE_BOTH* = from_c_int(RUSAGE_BOTH, "") - RUSAGE_THREAD* = from_c_int(RUSAGE_THREAD, "") - -const SIZEOF_RLIMIT_T* = from_c_int(SIZEOF_RLIMIT_T, 8): - {.emit: """/*INCLUDESECTION*/ -#include -#define SIZEOF_RLIMIT_T sizeof(rlim_t) -""".} - -AC_LINK_IFELSE HAVE_PRLIMIT, false: - import std/posix - proc prlimit(pid: Pid, resource: cint, new_limit, old_limit: ptr RLimit): cint {. - importc, header: "".} - discard prlimit(0, 0, nil, nil) - -AC_LINK_IFELSE HAVE_GETPAGESIZE, false: - proc getpagesize(): cint {.importc, header: "".} - discard getpagesize() - -AC_LINK_IFELSE HAVE_SYSCONF_PAGE_SIZE, false: - let SC_PAGE_SIZE{.importc, header: "".}: cint - proc sysconf(name: cint): cint {.importc, header: "".} - discard sysconf(SC_PAGE_SIZE) diff --git a/src/pylib/pyconfig/sched.nim b/src/pylib/pyconfig/sched.nim deleted file mode 100644 index 937be1a92..000000000 --- a/src/pylib/pyconfig/sched.nim +++ /dev/null @@ -1,13 +0,0 @@ - -import ./util - -AC_CHECK_HEADER_THEN_FUNCS sched.h, [sched_setaffinity] - -when HAVEsched_setaffinity: - import std/posix - export Pid - type CpuSet*{.importc: "cpu_set_t", header: "".} = object - proc sched_setaffinity*(pid: Pid, cpusetsize: uint, mask: ptr CpuSet): cint{.importc, header: "".} - proc sched_getaffinity*(pid: Pid, cpusetsize: uint, mask: ptr CpuSet): cint{.importc, header: "".} - - diff --git a/src/pylib/pyconfig/signal.nim b/src/pylib/pyconfig/signal.nim deleted file mode 100644 index fe5075a29..000000000 --- a/src/pylib/pyconfig/signal.nim +++ /dev/null @@ -1,48 +0,0 @@ - -import ./util -const Py_NSIG* = from_c_int(Py_NSIG, 64): - {.emit: -"""/*INCLUDESECTION*/ -#include -""".} - {.emit: -"""/*VARSECTION*/ -#ifdef _SIG_MAXSIG - // gh-91145: On FreeBSD, defines NSIG as 32: it doesn't include - // realtime signals: [SIGRTMIN,SIGRTMAX]. Use _SIG_MAXSIG instead. For - // example on x86-64 FreeBSD 13, SIGRTMAX is 126 and _SIG_MAXSIG is 128. -# define Py_NSIG _SIG_MAXSIG -#elif defined(NSIG) -# define Py_NSIG NSIG -#elif defined(_NSIG) -# define Py_NSIG _NSIG // BSD/SysV -#elif defined(_SIGMAX) -# define Py_NSIG (_SIGMAX + 1) // QNX -#elif defined(SIGMAX) -# define Py_NSIG (SIGMAX + 1) // djgpp -#else -# define Py_NSIG 64 // Use a reasonable default value -#endif -""".} - -AC_CHECK_FUNCS(strsignal, pthread_kill, alarm, pause, -getitimer, -setitimer, -sigaction, #sigaltstack \ - sigfillset, siginterrupt, sigpending, #[sigrelse,]# sigtimedwait, sigwait, - sigwaitinfo) -AC_CHECK_FUNC(pthread_sigmask) -const DEF_SIG* = -1 ## CPython checks `SIG*` in [0, NSIG) -when not defined(windows): - template SIG(sym) = - const sym* = from_c_int(sym, "", DEF_SIG) - - SIG SIGIOT - SIG SIGEMT - SIG SIGCLD - SIG SIGPWR - SIG SIGIO - SIG SIGWINCH - SIG SIGRTMIN - SIG SIGRTMAX - SIG SIGSTKFLT diff --git a/src/pylib/pyconfig/simp.nim b/src/pylib/pyconfig/simp.nim deleted file mode 100644 index b77354713..000000000 --- a/src/pylib/pyconfig/simp.nim +++ /dev/null @@ -1,6 +0,0 @@ - -const - Py_USING_MEMORY_DEBUGGER*{.booldefine.} = false - Py_GIL_DISABLED*{.booldefine.} = true - - diff --git a/src/pylib/pyconfig/stats.nim b/src/pylib/pyconfig/stats.nim deleted file mode 100644 index 49b3281fa..000000000 --- a/src/pylib/pyconfig/stats.nim +++ /dev/null @@ -1,10 +0,0 @@ - -import ./util -import ./have_x_runtime - -AC_CHECK_FUNCS( - lstat, - fstatat, -) - -check_func_runtime fstatat, 10.10, 8.0 diff --git a/src/pylib/pyconfig/util.nim b/src/pylib/pyconfig/util.nim deleted file mode 100644 index 407bbd7bd..000000000 --- a/src/pylib/pyconfig/util.nim +++ /dev/null @@ -1,243 +0,0 @@ - - -import std/os -from std/strutils import parseInt, strip, multiReplace, replace -import std/macros - -const weirdTarget = defined(js) or defined(nimscript) -const pylibDebug = defined(pylibDebugPyConfig) -const cacheDir = currentSourcePath()/../".cfgcache" -when not weirdTarget: - static: - createDir cacheDir # noop if cacheDir dirExists -template cfgCache(fn): string = cacheDir/fn -const - nimExePath = getCurrentCompilerExe() - nimExeQuotedPath = when declared(quoteShell): nimExePath.quoteShell - else: nimExePath.quoteShellWindows # when JS -template decl_ac_implAux(handle; subcmd; variable; defval; doWithExecRes; code): untyped = - bind nimExeQuotedPath - when weirdTarget: - handle variable, defval - else: - const fp = cfgCache astToStr variable - when fileExists fp: handle variable, fp.slurp - else: - const - scode = astToStr code - res = gorgeEx( nimExeQuotedPath & ' ' & subcmd & " --hints:"&(when pylibDebug: "on" else: "off")&" --eval:" & quoteShell(scode) ) - resCodeS = doWithExecRes res - when pylibDebug: - static:echo scode - fp.writeFile resCodeS - handle variable, resCodeS - -template decl_ac_implAux(handle; subcmd; variable; defval; code): untyped = - template handle_exec_res(res): string{.genSym, used.} = - when pylibDebug: - echo res.output - $res.exitCode - decl_ac_implAux(handle, subcmd, variable, defval, handle_exec_res, code) - - -template decl_ac_implAuxGetOutput(handle; subcmd; variable; defval: int; code): untyped = - template handle_exec_res(res): string{.genSym, used.} = - if res.exitCode != 0: $defval - else: res.output - decl_ac_implAux(handle, subcmd, variable, defval, handle_exec_res, code) - -template decl_global(variable; val: bool) = - const variable* = val -template decl_global(variable; val: string) = decl_global variable, val == "0" - -template decl_ac_impl(subcmd; variable; defval; code) = - decl_ac_implAux decl_global, subcmd, variable, defval, code -const RunSubCmd = 'r' - -template handle_int_or_strint(_; val: int|string): int = - bind parseInt - when val is int: val - else: parseInt val - -template from_c_int*(variable; defval: int; precode): int = - bind handle_int_or_strint - decl_ac_implAuxGetOutput(handle_int_or_strint, 'r', variable, defval): - precode - let variable{.importc, nodecl.}: cint - stdout.write variable - -proc from_c_int_expr(cacheName, cexpr: string; defval: NimNode): NimNode = - let pureVarId = newLit cacheName - result = quote do: - from_c_int(`cexpr`, `defval`): - {.emit: ["/*VARSECTION*/\n#define ", `pureVarId`, " ", `cexpr`, "\n"].} -#" <- for code lint -macro from_c_int_underlined*(variable: static[string]; defval: int): int = - let pureVar = variable.strip(chars = {'_'}) - from_c_int_expr(pureVar, variable, defval) - -macro from_c_int_expr*(cExpr: static[string]; defval: int): int = - let pureVar = cExpr.multiReplace( - ("_", ""), - ("(", "%28"), - (")", "%29"), - (" ", "%20"), - (",", "%2C"), - ("<", "%3C"), - (">", "%3E"), - (":", "%3A"), - ("\"", "%22"), - ("/", "%2F"), - ("\\", "%5C"), - ("|", "%7C"), - ("?", "%3F"), - ("*", "%2A"), - ) - from_c_int_expr(pureVar, cExpr, defval) - -template from_c_int*(variable; includeFile: static[string], defval = low(int)): int = - ## we know int.low is smaller than low(cint) - bind handle_int_or_strint - decl_ac_implAuxGetOutput(handle_int_or_strint, 'r', variable, defval): - let variable{.importc, header: includeFile.}: cint - stdout.write variable - -template noop = discard -template from_c_int*(variable; defvar: int): int = - bind noop - from_c_int(variable, defvar, noop) - -template AC_LINK_IFELSE*(variable, defval, code) = decl_ac_impl('c', variable, defval, code) ## variable = whether code exits with 0 -template AC_RUN_IFELSE*(variable, defval, code) = decl_ac_impl(RunSubCmd, variable, defval, code) - - -template AX_C_FLOAT_WORDS_BIGENDIAN*(id; doIfTrue, doIfFalse, doIfUnknown){.dirty.} = - bind decl_ac_implAux, RunSubCmd, weirdTarget - when weirdTarget: - template handle_option_bool(_; val: bool){.genSym.} = - doIfUnknown - else: - template handle_option_bool(_; val: string){.genSym.} = - const v = val - when v == "1": doIfTrue - elif v == "0": doIfFalse - else: doIfUnknown - - decl_ac_implAux handle_option_bool, RunSubCmd, id, false: - proc floatPatAsStr: cstring = - {.emit: [ - "static double m[] = {9.090423496703681e+223, 0.0};\n", - result, " = (char*)m;\n" - #" <- for code lint - ].} - let staticPtr = floatPatAsStr() - quit: - case staticPtr - of "noonsees": 1 # bigEndian - of "seesnoon": 0 # littleEndian - else: 2 - - -template def(sym) = {.define(sym).} - -template AX_C_FLOAT_WORDS_BIGENDIAN_def*(defIfTrue, defIfFalse, doIfUnknown) = - bind def - template ifDo{.genSym.} = def defIfTrue - template elseDo{.genSym.} = def defIfFalse - AX_C_FLOAT_WORDS_BIGENDIAN(defIfTrue, ifDo, elseDo, doIfUnknown) - -template c_defined*(variable; c_macro: string; headers: openArray = []) = - const Pre{.used.} = # NIM-BUG: must be marked by used pragma - static: - var pre = "/*INCLUDESECTION*/\n" - pre.add "#include \n" - for h in headers: - pre.add "#include " - pre.add h - pre.add "\n" - pre - AC_RUN_IFELSE variable, false: - {.emit: Pre.} - proc main{.noReturn.} = {.emit: - """ - exit( - #if defined(""" & c_macro & """) - 0 - #else - 1 - #endif - ); - """.} - main() - -template gen_checks_by_name(name){.dirty.} = - macro `name S`*(xs: varargs[untyped]): untyped = - result = newStmtList() - for x in xs: - result.add quote do: - name(`x`) - -macro gen_checks(def) = - let name = def.name - result = newStmtList( - def, - newCall(bindSym"gen_checks_by_name", name) - ) - -template AC_CHECK_FUNC*(res, function) = - ## export const HAVE_`function` - AC_LINK_IFELSE res, false: - const fname{.inject.} = astToStr(function) - {.emit: [ - "/*INCLUDESECTION*/\n", - "#include \n", - "#undef ", fname, "\n", - """/* The GNU C library defines this for functions which it implements - to always fail with ENOSYS. Some functions are actually named - something starting with __ and the normal name is an alias. */ -#if defined __stub_""", fname, " || defined __stub___", fname, "\n", """ -choke me -#endif -""" - ].} #""" <- for code lint - proc function(): cchar{.importc, cdecl.} - discard function() - -template AC_CHECK_FUNC*(function){.gen_checks.} = - AC_CHECK_FUNC(`HAVE function`, function) - -template AC_CHECK_HEADER*(res, header) = - AC_LINK_IFELSE res, false: - {.emit: [ - "/*INCLUDESECTION*/\n", - "#include <", header ,">\n", - ].} #" <- for code lint - -func haveHeaderIdent(ori: NimNode): NimNode{.compileTime.} = - ident "HAVE_" & ori.repr.replace('.', '_') - -macro AC_CHECK_HEADER*(header){.gen_checks.} = - let - id = haveHeaderIdent header - result = newCall(bindSym"AC_CHECK_HEADER", id, header) - -proc adds(h, args: NimNode): NimNode = - result = h - for i in args: - result.add i - -macro AC_CHECK_HEADER_THEN_FUNCS*(header; functions) = - result = newStmtList() - let headerHaveId = haveHeaderIdent header - result.add newCall(bindSym"AC_CHECK_HEADER", headerHaveId, header) - result.add nnkWhenStmt.newTree( - nnkElifBranch.newTree(headerHaveId, - newCall(bindSym"AC_CHECK_FUNCS").adds(functions) - ), - nnkElse.newTree do: - var ls = newStmtList() - for f in functions: - ls.add newConstStmt(ident("HAVE_" & f.strVal).postfix"*", newLit(false)) - ls - ) - diff --git a/src/pylib/pyconfig/ver.nim b/src/pylib/pyconfig/ver.nim deleted file mode 100644 index 7ac80f62e..000000000 --- a/src/pylib/pyconfig/ver.nim +++ /dev/null @@ -1,7 +0,0 @@ - - -when defined(android): - import ./util - const ANDROID_API* = from_c_int_underlined("__ANDROID_API__", 0) -else: - const ANDROID_API* = 0 diff --git a/src/pylib/pyerrors.nim b/src/pylib/pyerrors.nim deleted file mode 100644 index 7f1ed2c74..000000000 --- a/src/pylib/pyerrors.nim +++ /dev/null @@ -1,7 +0,0 @@ - -import ./private/trans_imp - -impExp pyerrors, - oserr, simperr, - rterr, signals, - aritherr, unicode_err diff --git a/src/pylib/pyerrors/aritherr.nim b/src/pylib/pyerrors/aritherr.nim deleted file mode 100644 index a22c5c535..000000000 --- a/src/pylib/pyerrors/aritherr.nim +++ /dev/null @@ -1,4 +0,0 @@ - -type - ArithmeticError* = object of CatchableError - ZeroDivisionError* = object of ArithmeticError diff --git a/src/pylib/pyerrors/errno.nim b/src/pylib/pyerrors/errno.nim deleted file mode 100644 index 3d255a5b6..000000000 --- a/src/pylib/pyerrors/errno.nim +++ /dev/null @@ -1,9 +0,0 @@ - -when defined(js): - template errno*: cint{.error: "get errno from Error's attr".} = 0 -elif defined(windows): - # std/posix has defined `errno` - var errno*{.importc, header: "".}: cint -else: - import std/posix - export errno diff --git a/src/pylib/pyerrors/jsoserr.nim b/src/pylib/pyerrors/jsoserr.nim deleted file mode 100644 index ca4ebf963..000000000 --- a/src/pylib/pyerrors/jsoserr.nim +++ /dev/null @@ -1,82 +0,0 @@ - -when NimMajor > 1: - from std/oserrors import OSErrorCode -else: - from std/os import OSErrorCode - -const - InNodeJs* = defined(nodejs) - -import ../jsutils/consts - -const DEF_INT = low(int) -let - ErrExist* = from_js_const(EEXIST, DEF_INT) - ErrNoent* = from_js_const(ENOENT, DEF_INT) - ErrIsdir* = from_js_const(EISDIR, DEF_INT) - -proc jsErrnoMsg*(errorCode: OSErrorCode): string = - let ie = errorCode.int - if ie == ErrExist: "File exists" - elif ie == ErrNoent: "No such file or directory" - elif ie == ErrIsdir: "Is a directory" - else: "" - - -template catchJsErrAsCode*(doBody: static string): int = - var - res: cint = 0 - {.emit: ["try{", doBody, "} catch(e) {", - res, " = -e.errno; }" - #" <- for code lint - ].} - int -res # nodejs's errno is oppsite? - -template catchJsErrAsCode*(prc: proc ()): cint = - var res: cint = 0 - block: - {.emit: ["try{", prc, "();", - "} catch(e) {", - res, """= -e.errno; - } - """].} - #"""] <- for code lint - res - -template catchJsErrAsCode*(doBody): cint = - bind catchJsErrAsCode - proc temp{.genSym.} = doBody - catchJsErrAsCode(prc=temp) - -template catchJsErrAsCode*(errMsg: var string; doBody: static string): cint = - var - jsRes: cstring - res: cint = 0 - {.emit: ["try{", doBody, """ - } catch(e) { - """, res, "= -e.errno;", - jsRes,"""= e.message; - } - """].} - #"""] <- for code lint - if res != 0: errMsg = $jsRes - res - -template catchJsErrAsCode*(errMsg: var string; prc: proc): cint = - var - jsRes: cstring - res: cint = 0 - block: - {.emit: ["try{", prc, """(); - } catch(e) { - """,res, " = -e.errno;", - jsRes,"""= e.message; - } - """].} - #"""] <- for code lint - if res != 0: errMsg = $jsRes - res - -template catchJsErrAsCode*(errMsg: var string; doBody): cint = - proc temp = doBody - catchJsErrAsCode errMsg, prc=temp diff --git a/src/pylib/pyerrors/lkuperr.nim b/src/pylib/pyerrors/lkuperr.nim deleted file mode 100644 index 16be3abba..000000000 --- a/src/pylib/pyerrors/lkuperr.nim +++ /dev/null @@ -1,6 +0,0 @@ - -type - LookupError* = object of CatchableError ##[ - .. warning:: Python's KeyError inherits LookupError, - but Nim's doesn't, but inherits ValueError instead. - ]## diff --git a/src/pylib/pyerrors/oserr.nim b/src/pylib/pyerrors/oserr.nim deleted file mode 100644 index 0cdd244af..000000000 --- a/src/pylib/pyerrors/oserr.nim +++ /dev/null @@ -1,165 +0,0 @@ -##[ -See CPython's Objects/exceptions.c - -`OSError_new`(a.k.a. `OSError.__new__`) will returns a subclass of OSError, -via lookup in `state->errnomap`, which is initialized by `_PyExc_InitState`, - -where key-value pairs are inserted via `ADD_ERRNO` macro. -]## -when NimMajor > 1: - import std/oserrors -else: - import std/os -when defined(windows): - import std/winlean -else: - import std/posix - -const InJs = defined(js) -when InJs: - import ./jsoserr - -import ../io_abc -import ../private/backendMark -import ../Lib/errno_impl/errnoUtils -export OSErrorCode -import ./oserr/[ - types as oserrors_types, errmap, oserror_new, init as oserrors_init, oserror_str -] -export oserrors_types, oserror_str, oserrors_init -when defined(windows): - import ./oserr/PC_errmap - - -const weirdTarget{.used.} = defined(nimscript) or defined(js) - -template osErrorMsgWithPath*(fp: PathLike, err: OSErrorCode, osErrorMsgCb): string = - ## always suffixed with a `\n` - var msg = osErrorMsgCb(err) - if msg == "": - msg = "unknown OS error" - if msg.len > 0 and msg[^1] != '\n': - msg.setLen msg.len - 1 - msg.add ": " - msg.add fp.pathrepr - msg - -when InJs: - func osErrorMsgWithPath*(fp: PathLike, err: OSErrorCode): string{.error: "not impl".} - #bind osErrorMsgWithPath, errnoMsgOSErr - #osErrorMsgWithPath(fp, err, errnoMsgOSErr) -else: - template osErrorMsgWithPath*(fp: PathLike, err: OSErrorCode): string = - bind osErrorMsgWithPath, osErrorMsg - osErrorMsgWithPath(fp, err, osErrorMsg) - -proc raiseExcWithPath*(fp: PathLike, exc: typedesc, err: OSErrorCode, - osErrorMsgCb: proc = osErrorMsg) = - raise newException(exc, fp.osErrorMsgWithPath(err, osErrorMsgCb)) - -func raiseExcWithPath*(fp: PathLike, exc: typedesc, err: OSErrorCode, additionalInfo: string) = - var msg = fp.osErrorMsgWithPath(err) - msg.add "Additional info: " - msg.add additionalInfo - raise newException(exc, msg) - -template noWeirdTarget*(def) = - bind noWeirdBackend - noWeirdBackend(def) - - -proc raiseExcWithPath*(p: PathLike, errCode: OSErrorCode){.sideEffect.} = - ## raises OSError or its one of SubError type - raise when defined(windows): - OSError_new[oserrors_types.PyOSError](0, p.fspath, winerror=errCode.cint) - else: - OSError_new[oserrors_types.PyOSError](errCode.cint, p.fspath) - -proc raiseExcWithPath*(p: PathLike){.sideEffect.} = - let oserr = osLastError() - p.raiseExcWithPath(oserr) - -func pathsAsOne[T](a, b: PathLike[T], sep = " -> "): string = - ## used when there are two pathes that needs to be reported in error message. - ## called by `raiseExcWithPath2`_ - a.pathrepr & sep & b.pathrepr - -proc raiseExcWithPath2*(src, dst: PathLike) = - pathsAsOne(src, dst).raiseExcWithPath() - -template tryOsOpAux(body, excHandleBody){.dirty.} = - bind raiseExcWithPath - try: body - except OSError as e: - excHandleBody - -template tryOsOp*(p: PathLike, body) = - bind tryOsOpAux - tryOsOpAux(body): - p.raiseExcWithPath(e.errorCode.OSErrorCode) - -template tryOsOp*(p: PathLike, raiseCond: bool, body) = - bind raiseExcWithPath - tryOsOpAux(body): - if raiseCond: - p.raiseExcWithPath(e.errorCode.OSErrorCode) - -template tryOsOp*(raiseCond: bool, body) = - bind raiseExcWithPath - tryOsOpAux(body): - if raiseCond: - raise newPyOSError(e.errorCode.cint, e.msg) - -template tryOsOp*(p1, p2: PathLike, body) = - bind pathsAsOne - pathsAsOne(p1, p2).tryOsOp body - -when InJs: - proc errnoMsg*(errno: cint): string = jsErrnoMsg(errno.OSErrorCode) -elif not weirdTarget: - proc c_strerror(code: cint): cstring{.importc: "strerror", header: "".} - - func errnoMsg*(errno: cint): string = $c_strerror(errno) - -proc newErrnoErrT[E: PyOSError](errno=getErrno(), strerr: string): owned(ref PyOSError) = - OSError_new[E](errno, strerr) -proc newErrnoErrT[E: PyOSError](errno=getErrno()): owned(ref PyOSError) = - newErrnoErrT[E](errno, errnoMsg(errno)) - -proc newErrnoErr(errno=getErrno()): owned(ref PyOSError) = - newErrnoErrT[oserrors_types.PyOSError](errno) - -proc raiseErrno*(errno=getErrno()) = - ## may raise subclass of OSError - raise newErrnoErr(errno) - -proc raiseErrnoT*[T: PyOSError](errno=getErrno()) = - raise newErrnoErrT[T](errno) - -proc raiseErrnoWithPath*[T](p: PathLike[T]; errno = getErrno()) = - ## raises OSError or its SubError. - ## refer to errno even under Windows. - raise OSError_new[oserrors_types.PyOSError](errno, errnoMsg(errno), p.fspath) - -when InJs: - proc raiseErrnoWithMsg*(errno: cint, errMsg: string) = - raise OSError_new[oserrors_types.PyOSError](errno, errMsg, fillMsg=false) - - template catchJsErrAndDo(doSth; doErr) = - var errMsg = "" - let err = catchJsErrAsCode errMsg: - doSth - if err != 0: doErr err, errMsg - template catchJsErrAndRaise*(doSth) = - bind catchJsErrAndDo, raiseErrnoWithMsg - template doErr(err, errMsg) = - raiseErrnoWithMsg err, errMsg - catchJsErrAndDo doSth, doErr - - template catchJsErrAndSetErrno*(doSth) = - bind catchJsErrAndDo, setErrnoRaw - template doErr(err, errMsg) = - setErrnoRaw err - catchJsErrAndDo doSth, doErr - - diff --git a/src/pylib/pyerrors/oserr/PC_errmap.nim b/src/pylib/pyerrors/oserr/PC_errmap.nim deleted file mode 100644 index fab9f6bde..000000000 --- a/src/pylib/pyerrors/oserr/PC_errmap.nim +++ /dev/null @@ -1,205 +0,0 @@ -## PC/errmap.h -import std/winlean -import ./errmap - -const - WSAEBADF = 10003 - WSAEACCES = 10013 - WSAEFAULT = 10014 - WSAEINVAL = 10022 - WSAEMFILE = 10024 - - ERROR_INVALID_DRIVE = 15 - ERROR_BAD_NETPATH = 53 - ERROR_BAD_NET_NAME = 67 - ERROR_BAD_PATHNAME = 161 - ERROR_FILENAME_EXCED_RANGE = 206 - - ERROR_BAD_ENVIRONMENT = 10 - - ERROR_BAD_FORMAT = 11 - ERROR_INVALID_STARTING_CODESEG = 188 - ERROR_INVALID_STACKSEG = 189 - ERROR_INVALID_MODULETYPE = 190 - ERROR_INVALID_EXE_SIGNATURE = 191 - ERROR_EXE_MARKED_INVALID = 192 - - ERROR_BAD_EXE_FORMAT = 193 - ERROR_ITERATED_DATA_EXCEEDS_64k = 194 - ERROR_INVALID_MINALLOCSIZE = 195 - ERROR_DYNLINK_FROM_INVALID_RING = 196 - ERROR_IOPL_NOT_ENABLED = 197 - ERROR_INVALID_SEGDPL = 198 - - ERROR_AUTODATASEG_EXCEEDS_64k = 199 - ERROR_RING2SEG_MUST_BE_MOVABLE = 200 - - - ERROR_RELOC_CHAIN_XEEDS_SEGLIM = 201 - ERROR_INFLOOP_IN_RELOC_CHAIN = 202 - - - ERROR_INVALID_HANDLE = 6 - ERROR_INVALID_TARGET_HANDLE = 114 - ERROR_DIRECT_ACCESS_HANDLE = 130 - - ERROR_WAIT_NO_CHILDREN = 128 - ERROR_CHILD_NOT_COMPLETE = 129 - - - ERROR_NO_PROC_SLOTS = 89 - ERROR_MAX_THRDS_REACHED = 164 - ERROR_NESTING_NOT_ALLOWED = 215 - - ERROR_ARENA_TRASHED = 7 - ERROR_NOT_ENOUGH_MEMORY = 8 - ERROR_INVALID_BLOCK = 9 - ERROR_NOT_ENOUGH_QUOTA = 1816 - - ERROR_CURRENT_DIRECTORY = 16 - ERROR_WRITE_PROTECT = 19 - ERROR_BAD_UNIT = 20 - ERROR_NOT_READY = 21 - ERROR_BAD_COMMAND = 22 - ERROR_CRC = 23 - - ERROR_BAD_LENGTH = 24 - ERROR_SEEK = 25 - ERROR_NOT_DOS_DISK = 26 - ERROR_SECTOR_NOT_FOUND = 27 - ERROR_OUT_OF_PAPER = 28 - ERROR_WRITE_FAULT = 29 - ERROR_READ_FAULT = 30 - ERROR_GEN_FAILURE = 31 - - ERROR_SHARING_VIOLATION = 32 - ERROR_LOCK_VIOLATION = 33 - ERROR_WRONG_DISK = 34 - ERROR_SHARING_BUFFER_EXCEEDED = 36 - ERROR_NETWORK_ACCESS_DENIED = 65 - - ERROR_CANNOT_MAKE = 82 - ERROR_FAIL_I24 = 83 - - ERROR_DRIVE_LOCKED = 108 - ERROR_SEEK_ON_DEVICE = 132 - ERROR_NOT_LOCKED = 158 - ERROR_LOCK_FAILED = 167 - - - ERROR_ALREADY_EXISTS = 183 - - ERROR_NOT_SAME_DEVICE = 17 - - ERROR_DIRECTORY = 267 # bpo-12802 - - ERROR_TOO_MANY_OPEN_FILES = 4 - - ERROR_DISK_FULL = 112 - - ERROR_BROKEN_PIPE = 109 - ERROR_NO_DATA = 232 # bpo-13063 - - ERROR_DIR_NOT_EMPTY = 145 - - ERROR_NO_UNICODE_TRANSLATION = 1113 - - ERROR_INVALID_FUNCTION = 1 - - ERROR_INVALID_ACCESS = 12 - ERROR_INVALID_DATA = 13 - ERROR_INVALID_PARAMETER = 87 - ERROR_NEGATIVE_SEEK = 131 - - -proc winerror_to_errno*(winerror: cint): cint = - # Unwrap FACILITY_WIN32 HRESULT errors - var winerror = winerror - if (winerror and 0xFFFF0000) == 0x80070000: - winerror = winerror and 0x0000FFFF - - # Winsock error codes (10000-11999) are errno values - if winerror >= 10000 and winerror < 12000: - case winerror - of WSAEINTR, WSAEBADF, WSAEACCES, WSAEFAULT, WSAEINVAL, WSAEMFILE: - # Winsock definitions of errno values. See WinSock2.h - return winerror - 10000 - else: - return winerror - - case winerror - of ERROR_FILE_NOT_FOUND, ERROR_PATH_NOT_FOUND, ERROR_INVALID_DRIVE, - ERROR_NO_MORE_FILES, ERROR_BAD_NETPATH, ERROR_BAD_NET_NAME, - ERROR_BAD_PATHNAME, ERROR_FILENAME_EXCED_RANGE: - ENOENT - - of ERROR_BAD_ENVIRONMENT: - E2BIG - - of ERROR_BAD_FORMAT, ERROR_INVALID_STARTING_CODESEG, ERROR_INVALID_STACKSEG, - ERROR_INVALID_MODULETYPE, ERROR_INVALID_EXE_SIGNATURE, ERROR_EXE_MARKED_INVALID, - ERROR_BAD_EXE_FORMAT, ERROR_ITERATED_DATA_EXCEEDS_64k, ERROR_INVALID_MINALLOCSIZE, - ERROR_DYNLINK_FROM_INVALID_RING, ERROR_IOPL_NOT_ENABLED, ERROR_INVALID_SEGDPL, - ERROR_AUTODATASEG_EXCEEDS_64k, ERROR_RING2SEG_MUST_BE_MOVABLE, - ERROR_RELOC_CHAIN_XEEDS_SEGLIM, ERROR_INFLOOP_IN_RELOC_CHAIN: - ENOEXEC - - of ERROR_INVALID_HANDLE, ERROR_INVALID_TARGET_HANDLE, ERROR_DIRECT_ACCESS_HANDLE: - EBADF - - of ERROR_WAIT_NO_CHILDREN, ERROR_CHILD_NOT_COMPLETE: - ECHILD - - of ERROR_NO_PROC_SLOTS, ERROR_MAX_THRDS_REACHED, ERROR_NESTING_NOT_ALLOWED: - EAGAIN - - of ERROR_ARENA_TRASHED, ERROR_NOT_ENOUGH_MEMORY, ERROR_INVALID_BLOCK, - ERROR_NOT_ENOUGH_QUOTA: - ENOMEM - - of ERROR_ACCESS_DENIED, ERROR_CURRENT_DIRECTORY, ERROR_WRITE_PROTECT, - ERROR_BAD_UNIT, ERROR_NOT_READY, ERROR_BAD_COMMAND, ERROR_CRC, - ERROR_BAD_LENGTH, ERROR_SEEK, ERROR_NOT_DOS_DISK, ERROR_SECTOR_NOT_FOUND, - ERROR_OUT_OF_PAPER, ERROR_WRITE_FAULT, ERROR_READ_FAULT, ERROR_GEN_FAILURE, - ERROR_SHARING_VIOLATION, ERROR_LOCK_VIOLATION, ERROR_WRONG_DISK, - ERROR_SHARING_BUFFER_EXCEEDED, ERROR_NETWORK_ACCESS_DENIED, ERROR_CANNOT_MAKE, - ERROR_FAIL_I24, ERROR_DRIVE_LOCKED, ERROR_SEEK_ON_DEVICE, ERROR_NOT_LOCKED, - ERROR_LOCK_FAILED, 35: - EACCES - - of ERROR_FILE_EXISTS, ERROR_ALREADY_EXISTS: - EEXIST - - of ERROR_NOT_SAME_DEVICE: - EXDEV - - of ERROR_DIRECTORY: - ENOTDIR - - of ERROR_TOO_MANY_OPEN_FILES: - EMFILE - - of ERROR_DISK_FULL: - ENOSPC - - of ERROR_BROKEN_PIPE, ERROR_NO_DATA: - EPIPE - - of ERROR_DIR_NOT_EMPTY: - ENOTEMPTY - - of ERROR_NO_UNICODE_TRANSLATION: - EILSEQ - - of WAIT_TIMEOUT: - ETIMEDOUT - - of ERROR_INVALID_FUNCTION, ERROR_INVALID_ACCESS, ERROR_INVALID_DATA, - ERROR_INVALID_PARAMETER, ERROR_NEGATIVE_SEEK: - EINVAL - - else: - EINVAL - -when isMainModule: - echo winerror_to_errno(ERROR_FILE_NOT_FOUND) diff --git a/src/pylib/pyerrors/oserr/errmap.nim b/src/pylib/pyerrors/oserr/errmap.nim deleted file mode 100644 index 86a3b707d..000000000 --- a/src/pylib/pyerrors/oserr/errmap.nim +++ /dev/null @@ -1,113 +0,0 @@ - -import std/tables -export tables - -when defined(windows): - import std/winlean -elif not defined(js): - import std/posix -import ./types -const DEF_INT = low(int) -when defined(js): - import ../../jsutils/consts - template asgn_cint(name, val){.used.} = - let name = val - template decl_c_intImpl(variable, name, _; defval) = - let variable = from_js_const(name, defval) - {.pragma: ErrnoMapAttr.} - template ifHasErr(name: int; body) = - if name != DEF_INT: body -else: - import ../../pyconfig/util - template asgn_cint(name, val){.used.} = - const name = val - template decl_c_intImpl(variable, name, includeFile; defval) = - const variable = from_c_int(name, includeFile, defval) - {.pragma: ErrnoMapAttr, compileTime.} - template ifHasErr(name: int; body) = - when name != DEF_INT: body - -template decl_c_int*(name, includeFile; defval) = - bind decl_c_intImpl - decl_c_intImpl(name, name, includeFile, defval) - export name - -{.pragma: OSErrorInitAttrs, nimcall, noSideEffect.} - -var errnomap*{.ErrnoMapAttr.}: Table[cint, proc(): ref PyOSError{.OSErrorInitAttrs.}] -proc default_oserror*(): ref PyOSError{.OSErrorInitAttrs.} = - new PyOSError - -template decl_err(variable, err){.dirty.} = - decl_c_intImpl(variable, err, "", DEF_INT) - -template isConst(e): bool = compiles((const _=err)) - -template asgExp(err; nerr: int; doSth) = - asgn_cint err, cast[cint](nerr) - export err - doSth - -template decl_err_cint(err, doIfDefined){.dirty.} = - ## generate `const err*: cint = ...` if err defined in `` - bind asgExp - when isConst(err): - export err - doIfDefined - else: - decl_err(`n err`, err) - when defined(js): asgExp err, `n err`, doIfDefined - else: - ifHasErr `n err`: asgExp err, `n err`, doIfDefined - -template decl_err_cint(err) = - ## generate `const err*: cint = ...` if err defined in `` - bind decl_err_cint - decl_err_cint(err): discard - -decl_err_cint E2BIG -decl_err_cint ENOEXEC -decl_err_cint EBADF -decl_err_cint ENOMEM -decl_err_cint EXDEV -decl_err_cint EMFILE -decl_err_cint ENOSPC -decl_err_cint ENOTEMPTY -decl_err_cint EILSEQ -decl_err_cint EINVAL - -when true: # PyExc_InitState - template ADD_ERRNO(exc, err){.dirty.} = - decl_err_cint err: - errnomap[err] = proc(): ref PyOSError = new exc -# The following is just copied from CPython's PyExc_InitState AS-IS. - - ADD_ERRNO(BlockingIOError, EAGAIN); - ADD_ERRNO(BlockingIOError, EALREADY); - ADD_ERRNO(BlockingIOError, EINPROGRESS); - ADD_ERRNO(BlockingIOError, EWOULDBLOCK); - ADD_ERRNO(BrokenPipeError, EPIPE); -#ifdef ESHUTDOWN - ADD_ERRNO(BrokenPipeError, ESHUTDOWN); -#endif - ADD_ERRNO(ChildProcessError, ECHILD); - ADD_ERRNO(ConnectionAbortedError, ECONNABORTED); - ADD_ERRNO(ConnectionRefusedError, ECONNREFUSED); - ADD_ERRNO(ConnectionResetError, ECONNRESET); - ADD_ERRNO(FileExistsError, EEXIST); - ADD_ERRNO(FileNotFoundError, ENOENT); - ADD_ERRNO(IsADirectoryError, EISDIR); - ADD_ERRNO(NotADirectoryError, ENOTDIR); - ADD_ERRNO(InterruptedError, EINTR); - ADD_ERRNO(PermissionError, EACCES); - ADD_ERRNO(PermissionError, EPERM); -#ifdef ENOTCAPABLE - # Extension for WASI capability-based security. Process lacks - # capability to access a resource. - ADD_ERRNO(PermissionError, ENOTCAPABLE); -#endif - ADD_ERRNO(ProcessLookupError, ESRCH); - ADD_ERRNO(TimeoutError, ETIMEDOUT); -#ifdef WSAETIMEDOUT - ADD_ERRNO(TimeoutError, WSAETIMEDOUT); -#endif diff --git a/src/pylib/pyerrors/oserr/init.nim b/src/pylib/pyerrors/oserr/init.nim deleted file mode 100644 index 7ba83c51c..000000000 --- a/src/pylib/pyerrors/oserr/init.nim +++ /dev/null @@ -1,18 +0,0 @@ - -import ./types -import ./oserror_new - -template gen(name, typ, thirdDefVal){.dirty.} = - proc name*(myerrno: cint, strerr: string, - filename = thirdDefVal, winerror: cint = 0, filename2 = ""): ref PyOSError = - OSError_new[types.typ](myerrno, strerr, filename, winerror, filename2) - proc name*(strerr: string = ""): ref PyOSError = - new result - result.strerror = strerr - -template gen(typ, thirdDefVal){.dirty.} = - gen(`new typ`, typ, thirdDefVal) - gen(`typ`, typ, thirdDefVal) - -gen PyOSError, "" -gen BlockingIOError, 0 diff --git a/src/pylib/pyerrors/oserr/oserror_decl.nim b/src/pylib/pyerrors/oserr/oserror_decl.nim deleted file mode 100644 index a64ca1e9d..000000000 --- a/src/pylib/pyerrors/oserr/oserror_decl.nim +++ /dev/null @@ -1,12 +0,0 @@ - -type PyOSError* = object of system.OSError - ## Python-compatible OSError - errno*{.exportc: "myerrno".}: cint - strerror*, - filename*, - filename2*: string - when defined(windows): - winerror*: cint ## Windows-specific error code - characters_written*: int - -#type OSError* = PyOSError diff --git a/src/pylib/pyerrors/oserr/oserror_new.nim b/src/pylib/pyerrors/oserr/oserror_new.nim deleted file mode 100644 index 79e74a351..000000000 --- a/src/pylib/pyerrors/oserr/oserror_new.nim +++ /dev/null @@ -1,88 +0,0 @@ -##[ -Where a function has a single filename, such as open() or some -of the os module functions, PyErr_SetFromErrnoWithFilename() is -called, giving a third argument which is the filename. But, so -that old code using in-place unpacking doesn't break, e.g.: - -except OSError, (errno, strerror): - -we hack args so that it only contains two items. This also -means we need our own __str__() which prints out the filename -when it was supplied. - -(If a function has two filenames, such as rename(), symlink(), -or copy(), PyErr_SetFromErrnoWithFilenameObjects() is called, -which allows passing in a second filename.) -]## - -import ./[types, errmap, oserror_str] -when defined(windows): - import ./PC_errmap -type - OSErrorArgs*[third: string|int] = tuple - errno: cint - strerror: string - filename: third - winerror: cint - filename2: string -template PyNumber_Check(x): bool = x is int -template PyNumber_AsSsize_t(x, _): int = x - -template parseOSErrorArgs(args: var OSErrorArgs, useWinError) = - ## Parses arguments for OSError construction - ## Returns tuple containing errno, strerror, filename, filename2, and winerror (on Windows) - ## Note: This function doesn't cleanup on error, the caller should - when defined(windows): - args.winerror = winerror - if useWinError: - args.errno = winerror_to_errno(args.winerror) - -template oserror_use_init*[E: PyOSError](self): bool = - ##[ - When __init__ is defined in an OSError subclass, we want any - extraneous argument to __new__ to be ignored. The only reasonable - solution, given __new__ takes a variable number of arguments, - is to defer arg parsing and initialization to __init__. - - But when __new__ is overridden as well, it should call our __new__ - with the right arguments. - - (see http://bugs.python.org/issue12555#msg148829 ) - ]## - compiles( - (cast[ref E](self)).init(0, "")) - -proc init*[E: PyOSError](self: ref E, args: OSErrorArgs) = - when E is BlockingIOError: - if PyNumber_Check(args.filename): - self.characters_written = PyNumber_AsSsize_t(args.filename, ValueError) - else: - self.filename = args.filename - self.filename2 = args.filename2 - self.errno = args.errno - self.strerror = args.strerror - when defined(windows): - self.winerror = args.winerror - -proc OSError_new*[E: PyOSError](myerrno: cint, strerr: string, - filename: string|int = "", winerror: cint = 0, filename2 = "", fillMsg: static[bool] = true): ref PyOSError = - ## may returns a subclass of OSError - type Third = typeof(filename) - var args: OSErrorArgs[Third] = (myerrno, strerr, filename, winerror, filename2) - var newtype = proc (): ref PyOSError = new E - let use_init = oserror_use_init[E](result) - if not use_init: - let useWinError = winerror != 0 - if useWinError: - parseOSErrorArgs(args, useWinError) - when E is PyOSError: - newtype = errnomap.getOrDefault(args.errno, default_oserror) - result = newtype() - result.characters_written = -1 - - if not use_init: - result.init(args) - - when fillMsg: - result.msg = $result - diff --git a/src/pylib/pyerrors/oserr/oserror_str.nim b/src/pylib/pyerrors/oserr/oserror_str.nim deleted file mode 100644 index c58922917..000000000 --- a/src/pylib/pyerrors/oserr/oserror_str.nim +++ /dev/null @@ -1,24 +0,0 @@ - -import ./types -import std/strformat - -proc `$`*(self: ref PyOSError): string = - ## String representation of OSError - template orNone(x: string): string = - if x.len > 0: x else: "None" - template orNone(x: int): string = (if x != 0: $x else: "None") - - when defined(windows): - # If available, winerror has priority over errno - if self.winerror != 0: - result = fmt"[WinError {self.winerror}]" - if result.len == 0: - result = fmt"[Errno {orNone(self.errno)}]" - result.add ' ' - result.add orNone(self.filename) - if self.filename.len > 0: - result.add ": " - result.add self.filename - if self.filename2.len > 0: - result.add " -> " - result.add self.filename2 diff --git a/src/pylib/pyerrors/oserr/types.nim b/src/pylib/pyerrors/oserr/types.nim deleted file mode 100644 index 5cc05ff81..000000000 --- a/src/pylib/pyerrors/oserr/types.nim +++ /dev/null @@ -1,26 +0,0 @@ - -import ./oserror_decl -export oserror_decl - -template decl(exc; sup){.dirty.} = - type exc* = object of sup - -template decl(exc){.dirty.} = decl(exc, oserror_decl.PyOSError) - -decl BlockingIOError -decl ConnectionError -decl ChildProcessError -decl BrokenPipeError, ConnectionError -decl ConnectionAbortedError, ConnectionError -decl ConnectionRefusedError, ConnectionError -decl ConnectionResetError, ConnectionError - -decl FileExistsError -decl FileNotFoundError -decl IsADirectoryError -decl NotADirectoryError -decl InterruptedError -decl PermissionError -decl ProcessLookupError -decl TimeoutError - diff --git a/src/pylib/pyerrors/rterr.nim b/src/pylib/pyerrors/rterr.nim deleted file mode 100644 index e63080174..000000000 --- a/src/pylib/pyerrors/rterr.nim +++ /dev/null @@ -1,6 +0,0 @@ - -type - RuntimeError* = object of CatchableError - NotImplementedError* = object of RuntimeError - - KeyboardInterrupt* = object of CatchableError diff --git a/src/pylib/pyerrors/signals.nim b/src/pylib/pyerrors/signals.nim deleted file mode 100644 index adaedecf0..000000000 --- a/src/pylib/pyerrors/signals.nim +++ /dev/null @@ -1,24 +0,0 @@ - -import ../noneType - -type - StopIterationT*[T = NoneType] = object of CatchableError - ## EXT. as `StopIteraton`'s `value` was not statically typed in Python, this must be - ## used for those whose `value` is not None - value*: T ## generator return value - StopIteration* = StopIterationT[NoneType] - ## .. note:: CPython's StopIteration is not generics, at least as of 3.13 - - StopAsyncIteration* = object of CatchableError - GeneratorExit* = object of CatchableError - -func newStopIteration*(): ref StopIteration = newException(StopIteration, "") -func newStopIteration*[T](value: T): ref StopIterationT[T] = - result = newException(StopIterationT[T], "") - result.value = value - -func `$`*(self: StopIteration): string = "" -func `$`*(self: StopIterationT): string = $self.value - -func msg*(self: StopIteration): string = "StopIteration" -func msg*(self: StopIterationT): string = "StopIteration: " & $self.value diff --git a/src/pylib/pyerrors/simperr.nim b/src/pylib/pyerrors/simperr.nim deleted file mode 100644 index 3a298098d..000000000 --- a/src/pylib/pyerrors/simperr.nim +++ /dev/null @@ -1,6 +0,0 @@ - -type - TypeError* = object of CatchableError - SystemExit* = object of CatchableError - AttributeError* = object of CatchableError - NameError* = object of CatchableError diff --git a/src/pylib/pyerrors/unicode_err.nim b/src/pylib/pyerrors/unicode_err.nim deleted file mode 100644 index cc5fa4979..000000000 --- a/src/pylib/pyerrors/unicode_err.nim +++ /dev/null @@ -1,31 +0,0 @@ - -import std/strutils - -type - UnicodeError* = object of ValueError - UnicodeDecodeError* = object of UnicodeError - -func newUnicodeDecodeError*( - codec: string, src: char, - start, stop: int, reason: string -): ref UnicodeDecodeError = - let stop = stop - 1 - var msg = "'$#' codec can't decode " % codec - if stop == start: - msg.add "byte " - msg.add $toHex(ord(src)) - msg.add " in position " - msg.add $stop - else: - msg.add "bytes " - msg.add " in position " - msg.add "$#-$#".format(start, stop) - msg.add ": " - msg.add reason - newException(UnicodeDecodeError, msg) - -func newUnicodeDecodeError*( - codec: string, src: string, - start, stop: int, reason: string -): ref UnicodeDecodeError = - newUnicodeDecodeError(codec, src[stop], start, stop, reason) diff --git a/src/pylib/pystring.nim b/src/pylib/pystring.nim deleted file mode 100644 index faf51f01e..000000000 --- a/src/pylib/pystring.nim +++ /dev/null @@ -1,7 +0,0 @@ - -import ./private/trans_imp - -impExp pystring, - strimpl, strmeth, strbltins, strops, strprefix, - fstring, format, translate - diff --git a/src/pylib/pystring/consts.nim b/src/pylib/pystring/consts.nim deleted file mode 100644 index 6ef5559fe..000000000 --- a/src/pylib/pystring/consts.nim +++ /dev/null @@ -1,40 +0,0 @@ - -import std/unicode - -const - unicodeSpaces* = [ - Rune 0x00009, - Rune 0x0000A, - Rune 0x0000B, - Rune 0x0000C, - Rune 0x0000D, - Rune 0x0001C, - Rune 0x0001D, - Rune 0x0001E, - Rune 0x0001F, - Rune 0x00020, - Rune 0x00085, - Rune 0x000A0, - Rune 0x01680, - Rune 0x02000, - Rune 0x02001, - Rune 0x02002, - Rune 0x02003, - Rune 0x02004, - Rune 0x02005, - Rune 0x02006, - Rune 0x02007, - Rune 0x02008, - Rune 0x02009, - Rune 0x0200A, - Rune 0x02028, - Rune 0x02029, - Rune 0x0202F, - Rune 0x0205F, - Rune 0x03000, - ] ##[ - This differs Nim's unicodeSpaces(inner symbol) std/unicode. - This has foour more characters than the latter: - `\x1C`, `\x1D`, `\x1E`, `\x1F` - ]## - diff --git a/src/pylib/pystring/format.nim b/src/pylib/pystring/format.nim deleted file mode 100644 index f08e8800f..000000000 --- a/src/pylib/pystring/format.nim +++ /dev/null @@ -1,16 +0,0 @@ - -import ./strimpl -import ../stringlib/format as pyformatlib -import std/macros - -template format*[T](value: T, format_spec: PyStr = ""): PyStr = - ## builtins.format - str pyformatlib.format(value, $format_spec) - -template format*(s: PyStr, argKw: varargs[untyped]): PyStr = - ## str.format - ## - ## NOTE: `s` must be static (e.g. a str literal), - ## as this will be expanded at compile-time - str pyformat($s, argKw) - diff --git a/src/pylib/pystring/fstring.nim b/src/pylib/pystring/fstring.nim deleted file mode 100644 index f58647e7c..000000000 --- a/src/pylib/pystring/fstring.nim +++ /dev/null @@ -1,73 +0,0 @@ -## f-string -## -## a string literal with a prefix of fr, Fr, rf of Rf -## behaves as if with a prefix of `strformat.fmt`. -## -## and f"xxx" is different, -## where the escaped literals in string will be interpreted. -## - -runnableExamples: - assert fr"\n" == "\\n" - assert f"\n" == "\n" - - let s = "asd" - - assert f"[{s}]" == "[asd]" - assert not compiles(fr s) - -from std/strformat import fmt -import std/macros -import ./strimpl -import ../translateEscape - -template genFR(sym){.dirty.} = - macro sym*(pattern: string{lit}): PyStr = - let fmtNoEscape = bindSym"fmt" - result = nnkCallStrLit.newTree(fmtNoEscape, pattern) - -genFR fr -genFR Fr -genFR rf -genFR Rf - -template f*(s: string{lit}): PyStr = - ## Python F-String. - ## - ## *Not* the same as Nim's fmt"xxx" - ## as that's equal to `fmt r"xxx"`, a.k.a fr"xx" in Python - ## - ## Any escape-translation error is reported at compile-time, - ## with information of filename and line number - ## - ## ## Unicode - ## `\Uhhhhhhhh` is supported as Python's, - ## while Nim's `\U{...}` is unsupported but `\u{...}` is reserved - ## - ## ## oct - ## `\\[0-7]{1,3}` in f-string will be interpreted as octal digit as Python, - ## instead of decimal as Nim. - ## - ## ## multiline - ## the following shows the deature of Nim's multiline string - ## which is different from Python's - ## ```Nim - ## assert "" == """ - ## """ - ## - ## ## Unicode Names - ## `\N{name}` is not supported yet. - ## - ## ``` - runnableExamples: - assert f"\n" == "\n" - assert f"123{'a'}\n456" == "123a\n456" - - assert f"\U0001f451" == "👑" - - assert f"\10" == "\x08" # nim's "\10" means chr(10) - - assert f"""\t123 -""" == "\t123\n" # even if the source code's newline is crlf. - bind fmt, translateEscapeWithErr - fmt translateEscapeWithErr s diff --git a/src/pylib/pystring/split/common.nim b/src/pylib/pystring/split/common.nim deleted file mode 100644 index 89db35ee8..000000000 --- a/src/pylib/pystring/split/common.nim +++ /dev/null @@ -1,13 +0,0 @@ - -import ../strimpl -export strimpl -import ../../stringlib/split/common as ncommon -export ncommon -import ../consts - -func ISSPACE*(s: PyStr, pos: int): bool = - ## Checks unicode space at unicode char's `pos` - s.runeAtPos(pos) in unicodeSpaces - - - diff --git a/src/pylib/pystring/split/reimporter.nim b/src/pylib/pystring/split/reimporter.nim deleted file mode 100644 index c5be6ff00..000000000 --- a/src/pylib/pystring/split/reimporter.nim +++ /dev/null @@ -1,8 +0,0 @@ - - -import ../../stringlib/split/[ - split_whitespace, rsplit_whitespace, splitlinesIter] -import ../../stringlib/split/reimporter as nrep -export errHandle, nrep, noneType -export split_whitespace, rsplit_whitespace, splitlinesIter - diff --git a/src/pylib/pystring/split/rsplit.nim b/src/pylib/pystring/split/rsplit.nim deleted file mode 100644 index 3346b08d6..000000000 --- a/src/pylib/pystring/split/rsplit.nim +++ /dev/null @@ -1,45 +0,0 @@ - -import ./common -import std/strutils -import ./reimporter - -import ./rsplit_whitespace - - -iterator rsplit*(a: PyStr, sep = None, maxsplit = -1): PyStr = - ## with unicode whitespaces as sep. - ## - ## treat runs of whitespaces as one sep (i.e. - ## discard empty strings from result), - ## while Nim's `unicode` doesn't has `rsplit` yet - ## - for i in rsplit_whitespace.rsplit_whitespace(a, maxsplit=maxsplit): - yield i - -iterator rsplitNoCheck(s: string, sep: char|string, maxsplit = -1): PyStr{.inline.} = - ## in reversed order - for i in strutils.rsplit(s, sep, maxsplit): yield i -iterator rsplitNoCheck(s: string, sep: PyStr, maxsplit = -1): PyStr{.inline.} = - ## in reversed order - for i in strutils.rsplit(s, $sep, maxsplit): yield i - -proc rsplit*(a: PyStr, sep = None, maxsplit = -1): PyList[PyStr] = - a.rsplit_whitespace(maxsplit) - -# strutils.rsplit func does not use any predicted capacity. - -template initRes(maxcount) = - result = newPyListOfCap[PyStr](PREPARE_CAP maxcount) - -template byteLen(s: string): int = s.len -template byteLen(c: char): int = 1 - -proc rsplit*(a: PyStr, sep: StringLike, maxsplit = -1): PyList[PyStr] = - noEmptySep sep - # CPython uses unicode len, here using byte-len shall be fine. - let - str_len = a.byteLen - sep_len = sep.byteLen - initRes norm_maxsplit(maxsplit, str_len=str_len, sep_len=sep_len) - for i in rsplitNoCheck($a, sep, maxsplit): result.append i - result.reverse() diff --git a/src/pylib/pystring/split/rsplit_whitespace.nim b/src/pylib/pystring/split/rsplit_whitespace.nim deleted file mode 100644 index c38a355ff..000000000 --- a/src/pylib/pystring/split/rsplit_whitespace.nim +++ /dev/null @@ -1,6 +0,0 @@ - -import ./common -import ./reimporter - -proc rsplit_whitespace*(pystr: PyStr, maxsplit = -1): PyList[PyStr] = - rsplit_whitespace(pystr, maxsplit=maxsplit) diff --git a/src/pylib/pystring/split/split.nim b/src/pylib/pystring/split/split.nim deleted file mode 100644 index de95e0a63..000000000 --- a/src/pylib/pystring/split/split.nim +++ /dev/null @@ -1,64 +0,0 @@ - -import ./common -import std/strutils -import ./reimporter - -import ./split_whitespace - -import ./splitlinesIter -export splitlinesIter - - -iterator split*(a: PyStr, sep = None, maxsplit = -1): PyStr = - ## with unicode whitespaces as sep. - ## - ## treat runs of whitespaces as one sep (i.e. - ## discard empty strings from result), - ## while Nim's `unicode.split(s)` doesn't - ## - for i in split_whitespace.split_whitespace(a, maxsplit=maxsplit): - yield i - -iterator splitNoCheck(s: string, sep: char|string, maxsplit = -1): PyStr{.inline.} = - for i in strutils.split(s, sep, maxsplit): yield i -iterator splitNoCheck(s: string, sep: PyStr, maxsplit = -1): PyStr{.inline.} = - for i in strutils.split(s, $sep, maxsplit): yield i - -iterator split*(a: PyStr, - sep: StringLike, maxsplit = -1): PyStr{.inline.} = - noEmptySep sep - for i in splitNoCheck($a, sep, maxsplit): yield i - -proc split*(a: PyStr, sep = None, maxsplit = -1): PyList[PyStr] = - a.split_whitespace(maxsplit) - -# strutils.split func does not use any predicted capacity. - -template initRes(maxcount) = - result = newPyListOfCap[PyStr](PREPARE_CAP maxcount) - -template byteLen(s: string): int = s.len -template byteLen(c: char): int = 1 - -proc split*(a: PyStr, sep: StringLike, maxsplit = -1): PyList[PyStr] = - noEmptySep sep - # CPython uses unicode len, here using byte-len shall be fine. - let - str_len = a.byteLen - sep_len = sep.byteLen - initRes norm_maxsplit(maxsplit, str_len=str_len, sep_len=sep_len) - for i in splitNoCheck($a, sep, maxsplit): result.append i - -proc splitlines*(self: PyStr, keepends=false): PyList[PyStr] = - - #[ From split.h splitlines L340 - /* This does not use the preallocated list because splitlines is - usually run with hundreds of newlines. The overhead of - switching between PyList_SET_ITEM and append causes about a - 2-3% slowdown for that common case. A smarter implementation - could move the if check out, so the SET_ITEMs are done first - and the appends only done when the prealloc buffer is full. - That's too much work for little gain.*/]# - result = newPyList[PyStr]() - for i in splitlinesIter.splitlines(self, keepends=keepends): - result.append i diff --git a/src/pylib/pystring/split/split_whitespace.nim b/src/pylib/pystring/split/split_whitespace.nim deleted file mode 100644 index c68776478..000000000 --- a/src/pylib/pystring/split/split_whitespace.nim +++ /dev/null @@ -1,10 +0,0 @@ - -import ./common -import ./reimporter - -iterator split_whitespace*(pystr: PyStr, maxsplit = -1): PyStr = - for i in split_whitespace[PyStr](pystr, maxsplit=maxsplit): - yield i - -proc split_whitespace*(pystr: PyStr, maxsplit = -1): PyList[PyStr] = - split_whitespace[PyStr](pystr, maxsplit=maxsplit) diff --git a/src/pylib/pystring/split/splitlinesIter.nim b/src/pylib/pystring/split/splitlinesIter.nim deleted file mode 100644 index ac1de1425..000000000 --- a/src/pylib/pystring/split/splitlinesIter.nim +++ /dev/null @@ -1,27 +0,0 @@ - -from std/unicode import Rune -import ./common -from ./reimporter import splitlines - -# Table of https://docs.python.org/3/library/stdtypes.html#str.splitlines -const LineBreaks = [ - Rune '\r', - Rune '\n', - Rune '\v', - Rune '\x1c', - Rune '\x1d', - Rune '\x1e', - Rune '\x85', - Rune 0x2028, - Rune 0x2029 -] - -template IS_LINKBREAK(str: PyStr, pos): bool = - str.runeAtPos(pos) in LineBreaks - -template IS_CAR_NL(s: PyStr, pos, str_len): bool = - s[pos] == '\r' and pos + 1 < str_len and self[pos+1] == '\n' - -iterator splitlines*(self: PyStr, keepends = false): PyStr = - for i in splitlines[PyStr](self, keepends): - yield i diff --git a/src/pylib/pystring/strbltins.nim b/src/pylib/pystring/strbltins.nim deleted file mode 100644 index f98b621b4..000000000 --- a/src/pylib/pystring/strbltins.nim +++ /dev/null @@ -1,112 +0,0 @@ - -import std/strutils -from std/unicode import runeAt, utf8, runeLen, Rune, `$` -import ./strimpl -from ../pyerrors import TypeError -import ../builtins/[reprImpl, asciiImpl] -import ../nimpatch/abs - -func reversed*(s: PyStr): PyStr = - unicode.reversed s - -func chr*(a: SomeInteger): PyStr = - if a.int notin 0..0x110000: - raise newException(ValueError, "chr() arg not in range(0x110000)") - result = $Rune(a) - - -func ord1*(a: PyStr): int = - runnableExamples: - assert ord1("123") == ord("1") - result = system.int(a.runeAt(0)) - -proc ord*(a: PyStr): int = - ## Raises TypeError if len(a) is not 1. - runnableExamples: - doAssert ord("δ") == 0x03b4 - - when not defined(release): - let ulen = a.len - if ulen != 1: - raise newException(TypeError, - "TypeError: ord() expected a character, but string of length " & $ulen & " found") - result = ord1 a - -func pyrepr*(s: StringLike): PyStr = - ## Shortcut for `str(pyreprImpl($s)))` - runnableExamples: - # NOTE: string literal's `repr` is `system.repr`, as following. - assert repr("\"") == "\"\\\"\"" # string literal of "\"" - # use pyrepr for any StringLike and returns a PyStr - assert pyrepr("\"") == "'\"'" - str pyreprImpl $s - -func repr*(x: PyStr): string = - ## Overwites `system.repr` for `PyStr` - ## - ## The same as `proc ascii`_ except for unicode chars being remained AS-IS, - ## and returns Nim's `string`. - pyreprImpl $x - -func ascii*(us: string): PyStr = - runnableExamples: - assert ascii("𐀀") == r"'\U00010000'" - assert ascii("đ") == r"'\u0111'" - assert ascii("和") == r"'\u548c'" - let s = ascii("v我\n\e") - when not defined(useNimCharEsc): - let rs = r"'v\u6211\n\x1b'" - else: - let rs = r"'v\u6211\n\e'" - assert s == rs - assert ascii("\"") == "'\"'" - assert ascii("\"'") == "'\"\\''" - let s2 = ascii("'") - when not defined(singQuotedStr): - let rs2 = "\"'\"" - else: - let rs2 = r"'\''" - assert s2 == rs2 - str pyasciiImpl pyreprImpl us - -func ascii*(us: PyStr): PyStr = - str pyasciiImpl repr us - -template ascii*(c: char): PyStr = - ## we regard 'x' as a str (so as in python) - runnableExamples: - assert ascii('c') == "'c'" - bind pyasciiImpl, str, pyreprImpl - str pyasciiImpl(pyreprImpl($c)) - -template ascii*(a: untyped): PyStr = - ## As repr(), return a string containing a printable representation - ## of an object, but escape the non-ASCII characters in the string returned - ## by repr() using \x, \u, or \U escapes - runnableExamples: - assert ascii(6) == "6" - bind pyasciiImpl, str - str pyasciiImpl(repr(a)) - -template makeConv(name, call: untyped, len: int, pfix: string) = - func `name`*(a: SomeInteger): PyStr = - # Special case - if a == 0: - return `pfix` & "0" - var res = call( - when a isnot SomeUnsignedInt: - abs(a) - else: - a, - `len`).toLowerAscii().strip(chars = {'0'}, trailing = false) - # Do it like in Python - add - sign - res.insert(`pfix`) - when a isnot SomeUnsignedInt: # optimization - if a < 0: - res.insert "-" - result = str res - -# Max length is derived from the max value for uint64 -makeConv(oct, toOct, 30, "0o") -makeConv(bin, toBin, 70, "0b") -makeConv(hex, toHex, 20, "0x") diff --git a/src/pylib/pystring/strimpl.nim b/src/pylib/pystring/strimpl.nim deleted file mode 100644 index a374fbbf8..000000000 --- a/src/pylib/pystring/strimpl.nim +++ /dev/null @@ -1,122 +0,0 @@ - - -import std/unicode -from std/strutils import contains -type - PyStr* = distinct string ## Python `str`, use `func str` to get an instance - -type StringLike* = string | char | PyStr - -func str*(self: PyStr): PyStr = self ## copy -func str*(`object` = ""): PyStr = PyStr(`object`) -func str*(a: Rune): PyStr = str $a -func str*(c: char): PyStr = str $c - -template str*[O: object](o: O): PyStr = - '<' & $O & " object at " & $o.addr & '>' -template str*[T](a: T): PyStr = - ## convert any object based on `repr` - ## - ## This is alreadly a fallback, - ## used for types without `str` defined. - ## - ## In Python, if a object's type has no `__str__`, - ## then it falls to use `__repr__` - mixin repr - str repr a - -using self: PyStr -using mself: var PyStr -func `$`*(self): string{.borrow.} ## to Nim string -func fspath*(self): PyStr = self ## make a PathLike -func toNimStr*(self): string{.deprecated: - "use toNimString instead. will be removed since 0.10".} = $self -converter toNimString*(self): string = $self -converter toPyStr*(s: string): PyStr = str(s) -converter toPyStr*(s: char): PyStr = str(s) -converter toPyStr*(s: Rune): PyStr = str(s) - -func contains*(s: PyStr, c: char): bool{.borrow.} -func contains*(s: PyStr; c: string): bool{.borrow.} -func contains*(s: PyStr; c: PyStr): bool{.borrow.} - -func `==`*(self; o: PyStr): bool{.borrow.} -func `==`*(self; o: string): bool{.borrow.} -func `==`*(o: string; self): bool{.borrow.} -func add(mself; s: string){.borrow.} # inner use -func add(mself; s: char){.borrow.} # inner use -func `&`(self; s: PyStr): string{.borrow.} # inner use - -func `+`*(self; s: PyStr): PyStr = PyStr(self & s) -func `+`*(self; s: StringLike): PyStr = self + str(s) - -func `+=`*(mself; s: PyStr) = mself.add $s -func `+=`*(mself; s: char) = mself.add s -func `+=`*(mself; s: string) = mself.add s - -func len*(self): int = runeLen $self -func len*(c: char): int = 1 ## len('c'), always returns 1 -func byteLen*(self): int = system.len self ## EXT. len of bytes -proc runeLenAt*(self; i: Natural): int{.borrow.} ## EXT. `i` is byte index -proc substr*(self; start, last: int): PyStr{.borrow.} ## EXT. byte index -func runeAtPos*(self; pos: int): Rune{.borrow.} - -func strBackIndex(s: string, pos: int): string{.inline.} = - ## pos: Positive - let (o, _) = s.runeReverseOffset(pos) - if o < 0: - raise newException(IndexDefect, "string index out of range") - let last = o + s.runeLenAt(o) - result = str s[o ..< last] - -func getChar*(self; i: Natural): char = (string(self))[i] ## EXT. get char by byte index. -func `[]`*(self; i: int): PyStr = - runnableExamples: - assert str("你好")[1] == str("好") - ## str.__getitem__(int) - ## - ## `i` may be negative to index from backward. - ## - # a simplest but not very effective impl: - #str string(self).runeStrAtPos(if i < 0: len(self)+i else: i) - if i < 0: - result = str string(self).strBackIndex(-i) - else: - result = str string(self).runeStrAtPos(i) - -func `[]`*(self; i: Slice[int]): PyStr = - ## EXT. - ## `s[1..2]` means `s[1:3]`, and the latter is not valid Nim code - let le = i.b + 1 - i.a - if le <= 0: str() - else: str string(self).runeSubStr(i.a, le) -func `[]`*(self; i: HSlice[int, BackwardsIndex]): PyStr = - self[i.a .. len(self) - int(i.b) ] - -iterator items*(self): PyStr = - for r in self.runes: - yield str r - -iterator chars*(self): char = - ## EXT. - for c in string(self): yield c - -iterator runes*(self): Rune = - ## EXT. - for r in self.string.runes: - yield r - -template `and`*(a, b: PyStr): PyStr = - ## Mimics Python str and str -> str. - ## Returns `a` if `a` is not empty, otherwise b (even if it's empty) - if a.byteLen > 0: b else: a - -template `or`*(a, b: PyStr): PyStr = - ## Mimics Python str or str -> str. - ## Returns `a` if `a` is not empty, otherwise b (even if it's empty) - if a.byteLen > 0: a else: b - -template `not`*(s: PyStr): bool = - ## # Mimics Python not str -> bool. - ## "not" for strings, return true if the string is not nil or empty. - s.byteLen == 0 diff --git a/src/pylib/pystring/strip.nim b/src/pylib/pystring/strip.nim deleted file mode 100644 index eb0d70dbc..000000000 --- a/src/pylib/pystring/strip.nim +++ /dev/null @@ -1,34 +0,0 @@ - -import ./consts -import ./strimpl -from std/unicode import toRunes, Rune - -func strip(s: PyStr, leading: static[bool] = true, trailing: static[bool] = true, - chars: openArray[Rune] = unicodeSpaces): PyStr = - ## Strips leading or trailing `chars` (default: whitespace characters) - ## from `s` and returns the resulting string. - ## - ## If `leading` is true (default), leading `chars` are stripped. - ## If `trailing` is true (default), trailing `chars` are stripped. - ## If both are false, the string is returned unchanged. - - var - first = 0 - last = len(s)-1 - when leading: - while first <= last and s.runeAtPos(first) in chars: inc(first) - when trailing: - while last >= first and s.runeAtPos(last) in chars: dec(last) - result = s[first .. last] - -func strip*(self: PyStr): PyStr = self.strip(true, true) -func lstrip*(self: PyStr): PyStr = self.strip(trailing=false) -func rstrip*(self: PyStr): PyStr = self.strip(leading=false) - -converter asSet(s: PyStr): seq[Rune] = s.toRunes -func strip*(self: PyStr, chars: PyStr): PyStr = - self.strip(chars=chars.asSet) -func lstrip*(self: PyStr, chars: PyStr): PyStr = - self.strip(trailing=false, chars=chars.asSet) -func rstrip*(self: PyStr, chars: PyStr): PyStr = - self.strip(leading=false, chars=chars.asSet) diff --git a/src/pylib/pystring/strmeth.nim b/src/pylib/pystring/strmeth.nim deleted file mode 100644 index b72cc28fc..000000000 --- a/src/pylib/pystring/strmeth.nim +++ /dev/null @@ -1,299 +0,0 @@ - -import std/unicode except split -import std/strutils except strip, split, rsplit -import std/tables - -import ./strimpl -export strimpl # for runnableExamples -import ./strip, ./split/[split, rsplit] -export strip, split, rsplit -import ../stringlib/meth -import ../version - -import ./consts -include ./unicase/[ - toUpperMapper, casefoldMapper -] - -const - OneUpperToMoreTable = toTable OneUpperToMoreTableLit - -type - RuneI = int32 - CasefoldInnerTab[K, V] = Table[K, V] - CasefoldTableT = object - common: CasefoldInnerTab[RuneI, RuneI] - full: CasefoldInnerTab[RuneI, string] - -const CasefoldTable = CasefoldTableT( - common: toTable CommonMapper, - full: toTable FullMapper -) - -func addCasefold(res: var string, k: Rune) = - template tab: untyped = CasefoldTable - template add(s: var string, ri: RuneI) = - s.add Rune ri - let runeI = RuneI k - template addIfIn(table) = - let val = table.getOrDefault runeI - if val != default typeof val: - res.add val - return - addIfIn tab.common - addIfIn tab.full - res.add k - -# str.format is in ./format - -template `*`*(a: StringLike, i: int): PyStr = - bind repeat - a.repeat(i) -template `*`*(i: int, a: StringLike): PyStr = - bind `*` - a * i - -func count*(a: PyStr, sub: PyStr): int = - meth.count(a, sub) - -func count*(a: PyStr, sub: PyStr, start: int): int = - meth.count(a, sub, start) - -func count*(a: PyStr, sub: PyStr, start=0, `end`: int): int = - meth.count(a, sub, start, `end`) - -func casefoldImpl(s: string): string = - ## Mimics Python str.casefold() -> str - for ch in s.runes: - result.addCasefold ch - -func casefold*(a: PyStr): PyStr{.pysince(3,3).} = - ## str.casefold() - ## - ## `str.lower()` is used for most characters, but, for example, - ## Cherokee letters is casefolded to their uppercase counterparts, - ## and some will be converted to their normal case, e.g. "ß" -> "ss" - str casefoldImpl $a - -func py_toLower(s: string): string = - result = newStringOfCap s.len - for ch in s.runes: - if ch == Rune(304): - result.add "i\u0307" - continue - result.add toLower ch - -func py_toUpper(s: string): string = - result = newStringOfCap s.len - for ch in s.runes: - let s = OneUpperToMoreTable.getOrDefault ch.int32 - if s.len == 0: - result.add ch.toUpper - else: - result.add s - -func lower*(a: PyStr): PyStr = - ## str.lower - ## - ## not the same as Nim's `unicode.toLower`, see examples - runnableExamples: - import std/unicode - let dotI = Rune 0x0130 # İ (LATIN CAPITAL LETTER I WITH DOT ABOVE) - assert str(dotI).lower() == "i\u0307" ## i̇ (\u0207 is a upper dot) - assert dotI.toLower() == Rune('i') - str py_toLower $a -func upper*(a: PyStr): PyStr = - ## str.upper - ## - ## not the same as Nim's `unicode.toUpper`, see examples - runnableExamples: - import std/unicode - let a = "ᾷ" - # GREEK SMALL LETTER ALPHA WITH PERISPOMENI AND YPOGEGRAMMENI - assert str(a).upper() == "Α͂Ι" # 3 chars - assert a.toUpper() == a # Nim just maps it as-is. - # There is more examples... (101 characters in total) - str py_toUpper $a - -func isCased(r: Rune): bool = - ## Unicode standard 5.0 introduce `isCased` - r.isLower or r.isUpper or r.isTitle - -type RuneImpl = int32 -proc py_toTitle(r: Rune): Rune = - ## unicode.toTitle only respect those whose - ## titlecase differs uppercase. - ## e.g. - ## not respect ascii - var c = RuneImpl(r) - if c <= RuneImpl high char: - return cast[char](c).toUpperAscii.Rune - result = r.toTitle() - if result == r: - # Nim's toTitle only convert those whose titlecase differs uppercase. - return r.toUpper() - ## when it comes to Ligatures, - ## toUpper() will do what `title()` in Python does - ## for example, `'ῃ'.upper()` gives `'HI'` in Python (length becomes 2) - ## but Nim's `toUpper`'s result is always of 1 length, and - ## `"ῃ".runeAt(0).toUpper` gives `ῌ`, a.k.a. `'ῃ'.title()` in Python. - -func title*(a: PyStr): PyStr = - ## str.title() - ## - ## not the same as `title proc` in std/unicode, see example. - runnableExamples: - let s = "lj" # \u01c9 - let u = str(s) - assert u.title() == "Lj" # \u01c8 - import std/unicode - assert unicode.title(s) == "LJ" # \u01c7 - # currently titleImpl is ok for ascii only. - #result.titleImpl a, isUpper, isLower, toUpper, toLower, runes, `+=` - var previous_is_cased = false - var res = newStringOfCap a.byteLen - for ch in a.runes: - res.add: - if previous_is_cased: ch.toLower - else: ch.py_toTitle - previous_is_cased = ch.isCased - result = str res - -func capitalize*(a: PyStr): PyStr = - ## make the first character have title/upper case and the rest lower case. - ## - ## changed when Python 3.8: the first character will have title case. - ## - ## while Nim's `unicode.capitalize` only make the first character upper-case. - let s = $a - if len(s) == 0: - return "" - var - rune: Rune - i = 0 - fastRuneAt(s, i, rune, doInc = true) - let first = when (PyMajor, PyMinor) < (3,8): - py_toUpper(rune) - else: - py_toTitle(rune) - result = $first + substr(s, i).lower() - - -export strutils.startsWith, strutils.endsWith - -template seWith(seWith){.dirty.} = - func sewith*(a: PyStr, suffix: char): bool = - meth.seWith(a, suffix) - func sewith*(a: char, suffix: PyStr): bool = - meth.seWith(a, suffix) - func sewith*[Tup: tuple](a: PyStr, suffix: Tup): bool = - meth.seWith(a, suffix) - func sewith*[Suf: PyStr | tuple](a: PyStr, suffix: Suf, start: int): bool = - meth.seWith(a, suffix, start) - func sewith*[Suf: PyStr | tuple](a: PyStr, suffix: Suf, - start, `end`: int): bool = - meth.seWith(a, suffix, start, `end`) - -seWith startsWith -seWith endsWith - -func find*(a: PyStr, b: PyStr, start = 0, `end` = len(a)): int = - if b.len == 1: - meth.find1(a, b, start) - else: - meth.find(a, b, start) - -func rfind*(a: PyStr, b: PyStr, start = 0, `end` = len(a)): int = - if b.len == 1: - meth.rfind1(a, b, start) - else: - meth.rfind(a, b, start) - -func index*(a, b: PyStr, start = 0, `end` = len(a)): int = - if b.len == 1: - meth.index1(a, b, start) - else: - meth.index(a, b, start) - -func rindex*(a, b: PyStr, start = 0, `end` = len(a)): int = - if b.len == 1: - meth.rindex1(a, b, start) - else: - meth.rindex(a, b, start) - -const AsciiOrdRange = 0..0x7F -func isascii*(a: Rune): bool = ord(a) in AsciiOrdRange - -template runeCheck(s: PyStr, runePredict; zeroLenTrue: static[bool]) = - ## Common code for isascii and isspace. - result = when zeroLenTrue: true - else: - if s.byteLen == 0: false else: true - for r in s.runes: - if not runePredict r: - return false - -func isascii*(a: PyStr): bool{.pysince(3,7).} = - a.runeCheck isascii, zeroLenTrue=true - -func isalpha*(a: PyStr): bool = unicode.isAlpha($a) - -template firstChar(s: PyStr): Rune = s.runeAt 0 -template strAllAlpha(s: PyStr, isWhat, notWhat): untyped = - s.allAlpha isWhat, notWhat, runes, firstChar -func islower*(a: PyStr): bool = a.strAllAlpha isLower, isUpper -func isupper*(a: PyStr): bool = a.strAllAlpha isUpper, isLower -func istitle*(a: PyStr): bool = - a.istitleImpl isUpper, isLower, runes, firstChar - -func isPySpace(r: Rune): bool = r in unicodeSpaces -func isspace*(a: PyStr): bool = a.runeCheck isPySpace, zeroLenTrue=false - -func center*(a: PyStr, width: int, fillchar = ' '): PyStr = - ## Mimics Python str.center(width: int, fillchar: str=" ") -> str - meth.center(a, width, fillchar) - -func ljust*(a: PyStr, width: int, fillchar = ' ' ): PyStr = - meth.ljust a, width, fillchar -func rjust*(a: PyStr, width: int, fillchar = ' ' ): PyStr = - meth.rjust a, width, fillchar - -func center*(a: PyStr, width: int, fillchar: PyStr): PyStr = - meth.center(a, width, fillchar) - -func ljust*(a: PyStr, width: int, fillchar: PyStr): PyStr = - meth.ljust(a, width, fillchar) - -func rjust*(a: PyStr, width: int, fillchar: PyStr ): PyStr = - meth.rjust(a, width, fillchar) - -func zfill*(a: PyStr, width: int): PyStr = - str meth.zfill($a, width) - -func removeprefix*(a: PyStr, suffix: PyStr): PyStr = - meth.removeprefix(a, suffix) -func removesuffix*(a: PyStr, suffix: PyStr): PyStr = - meth.removesuffix(a, suffix) - -func replace*(a: PyStr, sub, by: PyStr|char): PyStr = - meth.replace(a, sub, by) - -func replace*(a: PyStr, sub, by: PyStr|char, count: int): PyStr = - ## str.replace(sub, by, count = -1) - ## - ## count may be negative or zero. - meth.replace(a, sub, by, count) - -func expandtabs*(a: PyStr, tabsize=8): PyStr = - str expandtabsImpl(a, tabsize, a.byteLen, runes) - -func join*[T](sep: PyStr, a: openArray[T]): PyStr = - ## Mimics Python join() -> string - meth.join(sep, a) - -func partition*(a: PyStr, sep: PyStr): tuple[before, sep, after: PyStr] = - meth.partition(a, sep) - -func rpartition*(a: PyStr, sep: PyStr): tuple[before, sep, after: PyStr] = - meth.rpartition(a, sep) - diff --git a/src/pylib/pystring/strops.nim b/src/pylib/pystring/strops.nim deleted file mode 100644 index 27c7c2412..000000000 --- a/src/pylib/pystring/strops.nim +++ /dev/null @@ -1,7 +0,0 @@ - -import ./strimpl - - - -# Python 1.x and 2.x -template `<>`*[A: StringLike, B: StringLike](a: A, b: B): bool = $a != $b diff --git a/src/pylib/pystring/strprefix.nim b/src/pylib/pystring/strprefix.nim deleted file mode 100644 index 8466d1ff6..000000000 --- a/src/pylib/pystring/strprefix.nim +++ /dev/null @@ -1,9 +0,0 @@ - -import ./strimpl -import ../translateEscape - -func u*(s: static[string]{lit}): PyStr = - const ns = translateEscape s - str(ns) - -func u*(a: char{lit}): PyStr = str(a) diff --git a/src/pylib/pystring/translate.nim b/src/pylib/pystring/translate.nim deleted file mode 100644 index 2d7a293b8..000000000 --- a/src/pylib/pystring/translate.nim +++ /dev/null @@ -1,227 +0,0 @@ -## str.translate -## -## ------ -## -## NOTE: Nim's KeyError is a subclass of ValueError instead of LookupError. -## Therefore when writing a custom ``_ or ``_ -## for ``_, beware a Nim's KeyError is not considered -## as a sign to leave such a character untouched, but will be just raised outside. -## -## However, ``_ or ``_ is handled via overload. -## Using them as translate table is fine. -## - -import ./strimpl -import ./strbltins -import ../noneType -import ../pyerrors/lkuperr -import ../collections_abc -import std/tables -import std/macros - -export strimpl, noneType # for runnableExample - -type - TranslateValType* = int|PyStr|char|NoneType - TranslateAction*{.pure.} = enum - skip, aOrd, aChr, aStr - TranslateTableVal* = object - case action: TranslateAction - of skip: discard - of aOrd: i*: int - of aChr: c*: char - of aStr: s*: PyStr - TranslateTableABC* = concept self - self[int] is TranslateTableVal - TypedTranslateTableABC*[V] = concept self - V # NIM-BUG - self[int] is V - - TranslateTable* = TableRef[int, TranslateTableVal] ## result of maketrans - StrTypedTranslateTable* = TableRef[int, PyStr] ##[ - result of `str.maketrans(keys, values)<#maketrans,typedesc[PyStr],,>`_ - ]## - -static: assert StrTypedTranslateTable is TypedTranslateTableABC[PyStr] - -export tables.`[]`, tables.len - - -template newTranslateTable(cap: int): TranslateTable = - newTable[int, TranslateTableVal](cap) - -func repr*(table: TranslateTable): string = - ## dict stringification. - let le = table.len - result = newStringOfCap le * 5 - result.add "{" - var i = 0 - for k, v in table.pairs(): - result.add k.repr - result.add ": " - result.add case v.action - of skip: "None" - of aChr: $v.c - of aStr: repr v.s - of aOrd: $v.i - i.inc - if i != le: - result.add ", " - result.add "}" -template `$`*(table: TranslateTable): string = - ## repr table - bind repr - repr table - -template newStrTypedTranslateTable(cap: int): StrTypedTranslateTable = - newTable[int, PyStr](cap) - -func addVal(s: var PyStr, val: TranslateTableVal) = - case val.action - of skip: discard - of aOrd: s += strbltins.chr(val.i) - of aChr: s += val.c - of aStr: s += val.s - -template addValue[K: TranslateValType](s: var PyStr, value: K) = - when K is NoneType: discard - elif K is int: - s += strbltins.chr(value) - else: - s += value - -proc translate*(s: PyStr, table: TranslateTable): PyStr = - for uni in s: - let o = ord(uni) - if o in table: - result.addVal table[o] - else: - result += uni - -proc translate*(s: PyStr, table: StrTypedTranslateTable): PyStr = - for uni in s: - result += table.getOrDefault(ord(uni), uni) - -proc translate*[K: TranslateValType]( - s: PyStr, table: TypedTranslateTableABC[K]): PyStr = - for uni in s: - try: - result.addValue table[ord(uni)] - except LookupError: - result += uni - -proc translate*(s: PyStr, table: TranslateTableABC): PyStr = - for uni in s: - try: - let nval = table[ord(uni)] - result.addVal nval - except LookupError: - result += uni - -template initVal: untyped = - TranslateTableVal(action: TranslateAction.skip) -template initVal(act, attr, v): untyped = - TranslateTableVal(action: TranslateAction.act, attr: v) - -template initValWithV(v; V: typedesc): untyped = - when V is NoneType: - initVal() - elif V is int: - initVal(aOrd, i, v) - elif V is char: - initVal(aChr, c, v) - elif V is PyStr: - initVal(aStr, s, v) - elif V is string: - initVal(aStr, s, str v) - else: - {.error: "initValWithV with invalid type".} - -func maketransWithMapping[K: PyStr|int|char, V: TranslateValType]( - map: Mapping[K, V]): TranslateTable = - result = newTranslateTable len(map) - for k, v in map.items(): - let val = initValWithV(v, V) - template normK = - when K is int: k - else: ord(k) - result[normK] = val - -proc TranslateTableFromDictLit(lit: NimNode): NimNode = - ## {1: 2, ...} -> ``` - ## var = newTranslateTable() - ## [] = - ## ... - ## - ## ``` - expectKind lit, nnkTableConstr - result = newStmtList() - let resId = genSym(nskVar, "transTable") - result.add newVarStmt(resId, - newCall( - bindSym"newTranslateTable", - newLit lit.len - ) - ) - let tabSetitem = bindSym"[]=" - template setitem(k, v) = - result.add newCall(tabSetitem, resId, k, v) - let initVId = bindSym"initValWithV" - let ordId = bindSym"ord" - for item in lit: - var nitem = item - if item.kind == nnkHiddenSubConv: - # HiddenSubConv Empty - expectKind item[0], nnkEmpty - nitem = item[1] - expectKind nitem, nnkExprColonExpr - let (key, val) = (nitem[0], nitem[1]) - var normKey: NimNode - if key.kind in {nnkStrLit, nnkCharLit}: - normKey = newCall(ordId, key) - else: - if key.kind in nnkCallKinds: - warning "Currently only literal for key is fully supported", key - normKey = key - let normVal = newCall(initVId, val, newCall("typeof", val)) - setitem normKey, normVal - result.add resId - -macro maketrans*(_: typedesc[PyStr], mapOrLit: untyped): TranslateTable = - ## str.maketrans with dict literal or a mapping - runnableExamples: - let tbl = PyStr.maketrans({"a": None, "b": "123"}) - assert "axb".translate(tbl) == "x123" - if mapOrLit.kind in {nnkTableConstr, nnkBracket}: - let table = TranslateTableFromDictLit mapOrLit - result = table - else: - result = newCall(bindSym"maketransWithMapping", mapOrLit) - -template maketrans*(_: typedesc[PyStr], frm, to): StrTypedTranslateTable = - ## `frm`, `to` shall be string/PyStr. - ## - ## see `Nim#23662`_ - ## for why this is not defined as a proc with typed param-types - bind newStrTypedTranslateTable, ord, len - let le = frm.len - assert le == to.len - var result = newStrTypedTranslateTable(le) - for i, uni in frm: - result[ord(uni)] = to[i] - result - -template maketrans*(_: typedesc[PyStr], frm, to, skip): TranslateTable = - ## `frm`, `to`, `skip` shall be string/PyStr. - ## - ## see `Nim#23662`_ - ## for why this is not defined as a proc with typed param-types - bind newTranslateTable, initVal, ord, len - let le = frm.len - assert le == to.len - var result = newTranslateTable(le) - for i, uni in frm: - result[ord(uni)] = initVal(aStr, s, to[i]) - for uni in skip: - result[ord(uni)] = initVal() - result diff --git a/src/pylib/pystring/unicase/casefoldMapper.nim b/src/pylib/pystring/unicase/casefoldMapper.nim deleted file mode 100644 index 697787847..000000000 --- a/src/pylib/pystring/unicase/casefoldMapper.nim +++ /dev/null @@ -1,1537 +0,0 @@ -# Generated by /tools/unicodedata/casefold_parse.nim -# where `/` refers to the root path of this project. -# to be included. -const CommonMapper = { - 65'i32: 97'i32, - 66'i32: 98'i32, - 67'i32: 99'i32, - 68'i32: 100'i32, - 69'i32: 101'i32, - 70'i32: 102'i32, - 71'i32: 103'i32, - 72'i32: 104'i32, - 73'i32: 105'i32, - 74'i32: 106'i32, - 75'i32: 107'i32, - 76'i32: 108'i32, - 77'i32: 109'i32, - 78'i32: 110'i32, - 79'i32: 111'i32, - 80'i32: 112'i32, - 81'i32: 113'i32, - 82'i32: 114'i32, - 83'i32: 115'i32, - 84'i32: 116'i32, - 85'i32: 117'i32, - 86'i32: 118'i32, - 87'i32: 119'i32, - 88'i32: 120'i32, - 89'i32: 121'i32, - 90'i32: 122'i32, - 181'i32: 956'i32, - 192'i32: 224'i32, - 193'i32: 225'i32, - 194'i32: 226'i32, - 195'i32: 227'i32, - 196'i32: 228'i32, - 197'i32: 229'i32, - 198'i32: 230'i32, - 199'i32: 231'i32, - 200'i32: 232'i32, - 201'i32: 233'i32, - 202'i32: 234'i32, - 203'i32: 235'i32, - 204'i32: 236'i32, - 205'i32: 237'i32, - 206'i32: 238'i32, - 207'i32: 239'i32, - 208'i32: 240'i32, - 209'i32: 241'i32, - 210'i32: 242'i32, - 211'i32: 243'i32, - 212'i32: 244'i32, - 213'i32: 245'i32, - 214'i32: 246'i32, - 216'i32: 248'i32, - 217'i32: 249'i32, - 218'i32: 250'i32, - 219'i32: 251'i32, - 220'i32: 252'i32, - 221'i32: 253'i32, - 222'i32: 254'i32, - 256'i32: 257'i32, - 258'i32: 259'i32, - 260'i32: 261'i32, - 262'i32: 263'i32, - 264'i32: 265'i32, - 266'i32: 267'i32, - 268'i32: 269'i32, - 270'i32: 271'i32, - 272'i32: 273'i32, - 274'i32: 275'i32, - 276'i32: 277'i32, - 278'i32: 279'i32, - 280'i32: 281'i32, - 282'i32: 283'i32, - 284'i32: 285'i32, - 286'i32: 287'i32, - 288'i32: 289'i32, - 290'i32: 291'i32, - 292'i32: 293'i32, - 294'i32: 295'i32, - 296'i32: 297'i32, - 298'i32: 299'i32, - 300'i32: 301'i32, - 302'i32: 303'i32, - 306'i32: 307'i32, - 308'i32: 309'i32, - 310'i32: 311'i32, - 313'i32: 314'i32, - 315'i32: 316'i32, - 317'i32: 318'i32, - 319'i32: 320'i32, - 321'i32: 322'i32, - 323'i32: 324'i32, - 325'i32: 326'i32, - 327'i32: 328'i32, - 330'i32: 331'i32, - 332'i32: 333'i32, - 334'i32: 335'i32, - 336'i32: 337'i32, - 338'i32: 339'i32, - 340'i32: 341'i32, - 342'i32: 343'i32, - 344'i32: 345'i32, - 346'i32: 347'i32, - 348'i32: 349'i32, - 350'i32: 351'i32, - 352'i32: 353'i32, - 354'i32: 355'i32, - 356'i32: 357'i32, - 358'i32: 359'i32, - 360'i32: 361'i32, - 362'i32: 363'i32, - 364'i32: 365'i32, - 366'i32: 367'i32, - 368'i32: 369'i32, - 370'i32: 371'i32, - 372'i32: 373'i32, - 374'i32: 375'i32, - 376'i32: 255'i32, - 377'i32: 378'i32, - 379'i32: 380'i32, - 381'i32: 382'i32, - 383'i32: 115'i32, - 385'i32: 595'i32, - 386'i32: 387'i32, - 388'i32: 389'i32, - 390'i32: 596'i32, - 391'i32: 392'i32, - 393'i32: 598'i32, - 394'i32: 599'i32, - 395'i32: 396'i32, - 398'i32: 477'i32, - 399'i32: 601'i32, - 400'i32: 603'i32, - 401'i32: 402'i32, - 403'i32: 608'i32, - 404'i32: 611'i32, - 406'i32: 617'i32, - 407'i32: 616'i32, - 408'i32: 409'i32, - 412'i32: 623'i32, - 413'i32: 626'i32, - 415'i32: 629'i32, - 416'i32: 417'i32, - 418'i32: 419'i32, - 420'i32: 421'i32, - 422'i32: 640'i32, - 423'i32: 424'i32, - 425'i32: 643'i32, - 428'i32: 429'i32, - 430'i32: 648'i32, - 431'i32: 432'i32, - 433'i32: 650'i32, - 434'i32: 651'i32, - 435'i32: 436'i32, - 437'i32: 438'i32, - 439'i32: 658'i32, - 440'i32: 441'i32, - 444'i32: 445'i32, - 452'i32: 454'i32, - 453'i32: 454'i32, - 455'i32: 457'i32, - 456'i32: 457'i32, - 458'i32: 460'i32, - 459'i32: 460'i32, - 461'i32: 462'i32, - 463'i32: 464'i32, - 465'i32: 466'i32, - 467'i32: 468'i32, - 469'i32: 470'i32, - 471'i32: 472'i32, - 473'i32: 474'i32, - 475'i32: 476'i32, - 478'i32: 479'i32, - 480'i32: 481'i32, - 482'i32: 483'i32, - 484'i32: 485'i32, - 486'i32: 487'i32, - 488'i32: 489'i32, - 490'i32: 491'i32, - 492'i32: 493'i32, - 494'i32: 495'i32, - 497'i32: 499'i32, - 498'i32: 499'i32, - 500'i32: 501'i32, - 502'i32: 405'i32, - 503'i32: 447'i32, - 504'i32: 505'i32, - 506'i32: 507'i32, - 508'i32: 509'i32, - 510'i32: 511'i32, - 512'i32: 513'i32, - 514'i32: 515'i32, - 516'i32: 517'i32, - 518'i32: 519'i32, - 520'i32: 521'i32, - 522'i32: 523'i32, - 524'i32: 525'i32, - 526'i32: 527'i32, - 528'i32: 529'i32, - 530'i32: 531'i32, - 532'i32: 533'i32, - 534'i32: 535'i32, - 536'i32: 537'i32, - 538'i32: 539'i32, - 540'i32: 541'i32, - 542'i32: 543'i32, - 544'i32: 414'i32, - 546'i32: 547'i32, - 548'i32: 549'i32, - 550'i32: 551'i32, - 552'i32: 553'i32, - 554'i32: 555'i32, - 556'i32: 557'i32, - 558'i32: 559'i32, - 560'i32: 561'i32, - 562'i32: 563'i32, - 570'i32: 11365'i32, - 571'i32: 572'i32, - 573'i32: 410'i32, - 574'i32: 11366'i32, - 577'i32: 578'i32, - 579'i32: 384'i32, - 580'i32: 649'i32, - 581'i32: 652'i32, - 582'i32: 583'i32, - 584'i32: 585'i32, - 586'i32: 587'i32, - 588'i32: 589'i32, - 590'i32: 591'i32, - 837'i32: 953'i32, - 880'i32: 881'i32, - 882'i32: 883'i32, - 886'i32: 887'i32, - 895'i32: 1011'i32, - 902'i32: 940'i32, - 904'i32: 941'i32, - 905'i32: 942'i32, - 906'i32: 943'i32, - 908'i32: 972'i32, - 910'i32: 973'i32, - 911'i32: 974'i32, - 913'i32: 945'i32, - 914'i32: 946'i32, - 915'i32: 947'i32, - 916'i32: 948'i32, - 917'i32: 949'i32, - 918'i32: 950'i32, - 919'i32: 951'i32, - 920'i32: 952'i32, - 921'i32: 953'i32, - 922'i32: 954'i32, - 923'i32: 955'i32, - 924'i32: 956'i32, - 925'i32: 957'i32, - 926'i32: 958'i32, - 927'i32: 959'i32, - 928'i32: 960'i32, - 929'i32: 961'i32, - 931'i32: 963'i32, - 932'i32: 964'i32, - 933'i32: 965'i32, - 934'i32: 966'i32, - 935'i32: 967'i32, - 936'i32: 968'i32, - 937'i32: 969'i32, - 938'i32: 970'i32, - 939'i32: 971'i32, - 962'i32: 963'i32, - 975'i32: 983'i32, - 976'i32: 946'i32, - 977'i32: 952'i32, - 981'i32: 966'i32, - 982'i32: 960'i32, - 984'i32: 985'i32, - 986'i32: 987'i32, - 988'i32: 989'i32, - 990'i32: 991'i32, - 992'i32: 993'i32, - 994'i32: 995'i32, - 996'i32: 997'i32, - 998'i32: 999'i32, - 1000'i32: 1001'i32, - 1002'i32: 1003'i32, - 1004'i32: 1005'i32, - 1006'i32: 1007'i32, - 1008'i32: 954'i32, - 1009'i32: 961'i32, - 1012'i32: 952'i32, - 1013'i32: 949'i32, - 1015'i32: 1016'i32, - 1017'i32: 1010'i32, - 1018'i32: 1019'i32, - 1021'i32: 891'i32, - 1022'i32: 892'i32, - 1023'i32: 893'i32, - 1024'i32: 1104'i32, - 1025'i32: 1105'i32, - 1026'i32: 1106'i32, - 1027'i32: 1107'i32, - 1028'i32: 1108'i32, - 1029'i32: 1109'i32, - 1030'i32: 1110'i32, - 1031'i32: 1111'i32, - 1032'i32: 1112'i32, - 1033'i32: 1113'i32, - 1034'i32: 1114'i32, - 1035'i32: 1115'i32, - 1036'i32: 1116'i32, - 1037'i32: 1117'i32, - 1038'i32: 1118'i32, - 1039'i32: 1119'i32, - 1040'i32: 1072'i32, - 1041'i32: 1073'i32, - 1042'i32: 1074'i32, - 1043'i32: 1075'i32, - 1044'i32: 1076'i32, - 1045'i32: 1077'i32, - 1046'i32: 1078'i32, - 1047'i32: 1079'i32, - 1048'i32: 1080'i32, - 1049'i32: 1081'i32, - 1050'i32: 1082'i32, - 1051'i32: 1083'i32, - 1052'i32: 1084'i32, - 1053'i32: 1085'i32, - 1054'i32: 1086'i32, - 1055'i32: 1087'i32, - 1056'i32: 1088'i32, - 1057'i32: 1089'i32, - 1058'i32: 1090'i32, - 1059'i32: 1091'i32, - 1060'i32: 1092'i32, - 1061'i32: 1093'i32, - 1062'i32: 1094'i32, - 1063'i32: 1095'i32, - 1064'i32: 1096'i32, - 1065'i32: 1097'i32, - 1066'i32: 1098'i32, - 1067'i32: 1099'i32, - 1068'i32: 1100'i32, - 1069'i32: 1101'i32, - 1070'i32: 1102'i32, - 1071'i32: 1103'i32, - 1120'i32: 1121'i32, - 1122'i32: 1123'i32, - 1124'i32: 1125'i32, - 1126'i32: 1127'i32, - 1128'i32: 1129'i32, - 1130'i32: 1131'i32, - 1132'i32: 1133'i32, - 1134'i32: 1135'i32, - 1136'i32: 1137'i32, - 1138'i32: 1139'i32, - 1140'i32: 1141'i32, - 1142'i32: 1143'i32, - 1144'i32: 1145'i32, - 1146'i32: 1147'i32, - 1148'i32: 1149'i32, - 1150'i32: 1151'i32, - 1152'i32: 1153'i32, - 1162'i32: 1163'i32, - 1164'i32: 1165'i32, - 1166'i32: 1167'i32, - 1168'i32: 1169'i32, - 1170'i32: 1171'i32, - 1172'i32: 1173'i32, - 1174'i32: 1175'i32, - 1176'i32: 1177'i32, - 1178'i32: 1179'i32, - 1180'i32: 1181'i32, - 1182'i32: 1183'i32, - 1184'i32: 1185'i32, - 1186'i32: 1187'i32, - 1188'i32: 1189'i32, - 1190'i32: 1191'i32, - 1192'i32: 1193'i32, - 1194'i32: 1195'i32, - 1196'i32: 1197'i32, - 1198'i32: 1199'i32, - 1200'i32: 1201'i32, - 1202'i32: 1203'i32, - 1204'i32: 1205'i32, - 1206'i32: 1207'i32, - 1208'i32: 1209'i32, - 1210'i32: 1211'i32, - 1212'i32: 1213'i32, - 1214'i32: 1215'i32, - 1216'i32: 1231'i32, - 1217'i32: 1218'i32, - 1219'i32: 1220'i32, - 1221'i32: 1222'i32, - 1223'i32: 1224'i32, - 1225'i32: 1226'i32, - 1227'i32: 1228'i32, - 1229'i32: 1230'i32, - 1232'i32: 1233'i32, - 1234'i32: 1235'i32, - 1236'i32: 1237'i32, - 1238'i32: 1239'i32, - 1240'i32: 1241'i32, - 1242'i32: 1243'i32, - 1244'i32: 1245'i32, - 1246'i32: 1247'i32, - 1248'i32: 1249'i32, - 1250'i32: 1251'i32, - 1252'i32: 1253'i32, - 1254'i32: 1255'i32, - 1256'i32: 1257'i32, - 1258'i32: 1259'i32, - 1260'i32: 1261'i32, - 1262'i32: 1263'i32, - 1264'i32: 1265'i32, - 1266'i32: 1267'i32, - 1268'i32: 1269'i32, - 1270'i32: 1271'i32, - 1272'i32: 1273'i32, - 1274'i32: 1275'i32, - 1276'i32: 1277'i32, - 1278'i32: 1279'i32, - 1280'i32: 1281'i32, - 1282'i32: 1283'i32, - 1284'i32: 1285'i32, - 1286'i32: 1287'i32, - 1288'i32: 1289'i32, - 1290'i32: 1291'i32, - 1292'i32: 1293'i32, - 1294'i32: 1295'i32, - 1296'i32: 1297'i32, - 1298'i32: 1299'i32, - 1300'i32: 1301'i32, - 1302'i32: 1303'i32, - 1304'i32: 1305'i32, - 1306'i32: 1307'i32, - 1308'i32: 1309'i32, - 1310'i32: 1311'i32, - 1312'i32: 1313'i32, - 1314'i32: 1315'i32, - 1316'i32: 1317'i32, - 1318'i32: 1319'i32, - 1320'i32: 1321'i32, - 1322'i32: 1323'i32, - 1324'i32: 1325'i32, - 1326'i32: 1327'i32, - 1329'i32: 1377'i32, - 1330'i32: 1378'i32, - 1331'i32: 1379'i32, - 1332'i32: 1380'i32, - 1333'i32: 1381'i32, - 1334'i32: 1382'i32, - 1335'i32: 1383'i32, - 1336'i32: 1384'i32, - 1337'i32: 1385'i32, - 1338'i32: 1386'i32, - 1339'i32: 1387'i32, - 1340'i32: 1388'i32, - 1341'i32: 1389'i32, - 1342'i32: 1390'i32, - 1343'i32: 1391'i32, - 1344'i32: 1392'i32, - 1345'i32: 1393'i32, - 1346'i32: 1394'i32, - 1347'i32: 1395'i32, - 1348'i32: 1396'i32, - 1349'i32: 1397'i32, - 1350'i32: 1398'i32, - 1351'i32: 1399'i32, - 1352'i32: 1400'i32, - 1353'i32: 1401'i32, - 1354'i32: 1402'i32, - 1355'i32: 1403'i32, - 1356'i32: 1404'i32, - 1357'i32: 1405'i32, - 1358'i32: 1406'i32, - 1359'i32: 1407'i32, - 1360'i32: 1408'i32, - 1361'i32: 1409'i32, - 1362'i32: 1410'i32, - 1363'i32: 1411'i32, - 1364'i32: 1412'i32, - 1365'i32: 1413'i32, - 1366'i32: 1414'i32, - 4256'i32: 11520'i32, - 4257'i32: 11521'i32, - 4258'i32: 11522'i32, - 4259'i32: 11523'i32, - 4260'i32: 11524'i32, - 4261'i32: 11525'i32, - 4262'i32: 11526'i32, - 4263'i32: 11527'i32, - 4264'i32: 11528'i32, - 4265'i32: 11529'i32, - 4266'i32: 11530'i32, - 4267'i32: 11531'i32, - 4268'i32: 11532'i32, - 4269'i32: 11533'i32, - 4270'i32: 11534'i32, - 4271'i32: 11535'i32, - 4272'i32: 11536'i32, - 4273'i32: 11537'i32, - 4274'i32: 11538'i32, - 4275'i32: 11539'i32, - 4276'i32: 11540'i32, - 4277'i32: 11541'i32, - 4278'i32: 11542'i32, - 4279'i32: 11543'i32, - 4280'i32: 11544'i32, - 4281'i32: 11545'i32, - 4282'i32: 11546'i32, - 4283'i32: 11547'i32, - 4284'i32: 11548'i32, - 4285'i32: 11549'i32, - 4286'i32: 11550'i32, - 4287'i32: 11551'i32, - 4288'i32: 11552'i32, - 4289'i32: 11553'i32, - 4290'i32: 11554'i32, - 4291'i32: 11555'i32, - 4292'i32: 11556'i32, - 4293'i32: 11557'i32, - 4295'i32: 11559'i32, - 4301'i32: 11565'i32, - 5112'i32: 5104'i32, - 5113'i32: 5105'i32, - 5114'i32: 5106'i32, - 5115'i32: 5107'i32, - 5116'i32: 5108'i32, - 5117'i32: 5109'i32, - 7296'i32: 1074'i32, - 7297'i32: 1076'i32, - 7298'i32: 1086'i32, - 7299'i32: 1089'i32, - 7300'i32: 1090'i32, - 7301'i32: 1090'i32, - 7302'i32: 1098'i32, - 7303'i32: 1123'i32, - 7304'i32: 42571'i32, - 7312'i32: 4304'i32, - 7313'i32: 4305'i32, - 7314'i32: 4306'i32, - 7315'i32: 4307'i32, - 7316'i32: 4308'i32, - 7317'i32: 4309'i32, - 7318'i32: 4310'i32, - 7319'i32: 4311'i32, - 7320'i32: 4312'i32, - 7321'i32: 4313'i32, - 7322'i32: 4314'i32, - 7323'i32: 4315'i32, - 7324'i32: 4316'i32, - 7325'i32: 4317'i32, - 7326'i32: 4318'i32, - 7327'i32: 4319'i32, - 7328'i32: 4320'i32, - 7329'i32: 4321'i32, - 7330'i32: 4322'i32, - 7331'i32: 4323'i32, - 7332'i32: 4324'i32, - 7333'i32: 4325'i32, - 7334'i32: 4326'i32, - 7335'i32: 4327'i32, - 7336'i32: 4328'i32, - 7337'i32: 4329'i32, - 7338'i32: 4330'i32, - 7339'i32: 4331'i32, - 7340'i32: 4332'i32, - 7341'i32: 4333'i32, - 7342'i32: 4334'i32, - 7343'i32: 4335'i32, - 7344'i32: 4336'i32, - 7345'i32: 4337'i32, - 7346'i32: 4338'i32, - 7347'i32: 4339'i32, - 7348'i32: 4340'i32, - 7349'i32: 4341'i32, - 7350'i32: 4342'i32, - 7351'i32: 4343'i32, - 7352'i32: 4344'i32, - 7353'i32: 4345'i32, - 7354'i32: 4346'i32, - 7357'i32: 4349'i32, - 7358'i32: 4350'i32, - 7359'i32: 4351'i32, - 7680'i32: 7681'i32, - 7682'i32: 7683'i32, - 7684'i32: 7685'i32, - 7686'i32: 7687'i32, - 7688'i32: 7689'i32, - 7690'i32: 7691'i32, - 7692'i32: 7693'i32, - 7694'i32: 7695'i32, - 7696'i32: 7697'i32, - 7698'i32: 7699'i32, - 7700'i32: 7701'i32, - 7702'i32: 7703'i32, - 7704'i32: 7705'i32, - 7706'i32: 7707'i32, - 7708'i32: 7709'i32, - 7710'i32: 7711'i32, - 7712'i32: 7713'i32, - 7714'i32: 7715'i32, - 7716'i32: 7717'i32, - 7718'i32: 7719'i32, - 7720'i32: 7721'i32, - 7722'i32: 7723'i32, - 7724'i32: 7725'i32, - 7726'i32: 7727'i32, - 7728'i32: 7729'i32, - 7730'i32: 7731'i32, - 7732'i32: 7733'i32, - 7734'i32: 7735'i32, - 7736'i32: 7737'i32, - 7738'i32: 7739'i32, - 7740'i32: 7741'i32, - 7742'i32: 7743'i32, - 7744'i32: 7745'i32, - 7746'i32: 7747'i32, - 7748'i32: 7749'i32, - 7750'i32: 7751'i32, - 7752'i32: 7753'i32, - 7754'i32: 7755'i32, - 7756'i32: 7757'i32, - 7758'i32: 7759'i32, - 7760'i32: 7761'i32, - 7762'i32: 7763'i32, - 7764'i32: 7765'i32, - 7766'i32: 7767'i32, - 7768'i32: 7769'i32, - 7770'i32: 7771'i32, - 7772'i32: 7773'i32, - 7774'i32: 7775'i32, - 7776'i32: 7777'i32, - 7778'i32: 7779'i32, - 7780'i32: 7781'i32, - 7782'i32: 7783'i32, - 7784'i32: 7785'i32, - 7786'i32: 7787'i32, - 7788'i32: 7789'i32, - 7790'i32: 7791'i32, - 7792'i32: 7793'i32, - 7794'i32: 7795'i32, - 7796'i32: 7797'i32, - 7798'i32: 7799'i32, - 7800'i32: 7801'i32, - 7802'i32: 7803'i32, - 7804'i32: 7805'i32, - 7806'i32: 7807'i32, - 7808'i32: 7809'i32, - 7810'i32: 7811'i32, - 7812'i32: 7813'i32, - 7814'i32: 7815'i32, - 7816'i32: 7817'i32, - 7818'i32: 7819'i32, - 7820'i32: 7821'i32, - 7822'i32: 7823'i32, - 7824'i32: 7825'i32, - 7826'i32: 7827'i32, - 7828'i32: 7829'i32, - 7835'i32: 7777'i32, - 7840'i32: 7841'i32, - 7842'i32: 7843'i32, - 7844'i32: 7845'i32, - 7846'i32: 7847'i32, - 7848'i32: 7849'i32, - 7850'i32: 7851'i32, - 7852'i32: 7853'i32, - 7854'i32: 7855'i32, - 7856'i32: 7857'i32, - 7858'i32: 7859'i32, - 7860'i32: 7861'i32, - 7862'i32: 7863'i32, - 7864'i32: 7865'i32, - 7866'i32: 7867'i32, - 7868'i32: 7869'i32, - 7870'i32: 7871'i32, - 7872'i32: 7873'i32, - 7874'i32: 7875'i32, - 7876'i32: 7877'i32, - 7878'i32: 7879'i32, - 7880'i32: 7881'i32, - 7882'i32: 7883'i32, - 7884'i32: 7885'i32, - 7886'i32: 7887'i32, - 7888'i32: 7889'i32, - 7890'i32: 7891'i32, - 7892'i32: 7893'i32, - 7894'i32: 7895'i32, - 7896'i32: 7897'i32, - 7898'i32: 7899'i32, - 7900'i32: 7901'i32, - 7902'i32: 7903'i32, - 7904'i32: 7905'i32, - 7906'i32: 7907'i32, - 7908'i32: 7909'i32, - 7910'i32: 7911'i32, - 7912'i32: 7913'i32, - 7914'i32: 7915'i32, - 7916'i32: 7917'i32, - 7918'i32: 7919'i32, - 7920'i32: 7921'i32, - 7922'i32: 7923'i32, - 7924'i32: 7925'i32, - 7926'i32: 7927'i32, - 7928'i32: 7929'i32, - 7930'i32: 7931'i32, - 7932'i32: 7933'i32, - 7934'i32: 7935'i32, - 7944'i32: 7936'i32, - 7945'i32: 7937'i32, - 7946'i32: 7938'i32, - 7947'i32: 7939'i32, - 7948'i32: 7940'i32, - 7949'i32: 7941'i32, - 7950'i32: 7942'i32, - 7951'i32: 7943'i32, - 7960'i32: 7952'i32, - 7961'i32: 7953'i32, - 7962'i32: 7954'i32, - 7963'i32: 7955'i32, - 7964'i32: 7956'i32, - 7965'i32: 7957'i32, - 7976'i32: 7968'i32, - 7977'i32: 7969'i32, - 7978'i32: 7970'i32, - 7979'i32: 7971'i32, - 7980'i32: 7972'i32, - 7981'i32: 7973'i32, - 7982'i32: 7974'i32, - 7983'i32: 7975'i32, - 7992'i32: 7984'i32, - 7993'i32: 7985'i32, - 7994'i32: 7986'i32, - 7995'i32: 7987'i32, - 7996'i32: 7988'i32, - 7997'i32: 7989'i32, - 7998'i32: 7990'i32, - 7999'i32: 7991'i32, - 8008'i32: 8000'i32, - 8009'i32: 8001'i32, - 8010'i32: 8002'i32, - 8011'i32: 8003'i32, - 8012'i32: 8004'i32, - 8013'i32: 8005'i32, - 8025'i32: 8017'i32, - 8027'i32: 8019'i32, - 8029'i32: 8021'i32, - 8031'i32: 8023'i32, - 8040'i32: 8032'i32, - 8041'i32: 8033'i32, - 8042'i32: 8034'i32, - 8043'i32: 8035'i32, - 8044'i32: 8036'i32, - 8045'i32: 8037'i32, - 8046'i32: 8038'i32, - 8047'i32: 8039'i32, - 8120'i32: 8112'i32, - 8121'i32: 8113'i32, - 8122'i32: 8048'i32, - 8123'i32: 8049'i32, - 8126'i32: 953'i32, - 8136'i32: 8050'i32, - 8137'i32: 8051'i32, - 8138'i32: 8052'i32, - 8139'i32: 8053'i32, - 8152'i32: 8144'i32, - 8153'i32: 8145'i32, - 8154'i32: 8054'i32, - 8155'i32: 8055'i32, - 8168'i32: 8160'i32, - 8169'i32: 8161'i32, - 8170'i32: 8058'i32, - 8171'i32: 8059'i32, - 8172'i32: 8165'i32, - 8184'i32: 8056'i32, - 8185'i32: 8057'i32, - 8186'i32: 8060'i32, - 8187'i32: 8061'i32, - 8486'i32: 969'i32, - 8490'i32: 107'i32, - 8491'i32: 229'i32, - 8498'i32: 8526'i32, - 8544'i32: 8560'i32, - 8545'i32: 8561'i32, - 8546'i32: 8562'i32, - 8547'i32: 8563'i32, - 8548'i32: 8564'i32, - 8549'i32: 8565'i32, - 8550'i32: 8566'i32, - 8551'i32: 8567'i32, - 8552'i32: 8568'i32, - 8553'i32: 8569'i32, - 8554'i32: 8570'i32, - 8555'i32: 8571'i32, - 8556'i32: 8572'i32, - 8557'i32: 8573'i32, - 8558'i32: 8574'i32, - 8559'i32: 8575'i32, - 8579'i32: 8580'i32, - 9398'i32: 9424'i32, - 9399'i32: 9425'i32, - 9400'i32: 9426'i32, - 9401'i32: 9427'i32, - 9402'i32: 9428'i32, - 9403'i32: 9429'i32, - 9404'i32: 9430'i32, - 9405'i32: 9431'i32, - 9406'i32: 9432'i32, - 9407'i32: 9433'i32, - 9408'i32: 9434'i32, - 9409'i32: 9435'i32, - 9410'i32: 9436'i32, - 9411'i32: 9437'i32, - 9412'i32: 9438'i32, - 9413'i32: 9439'i32, - 9414'i32: 9440'i32, - 9415'i32: 9441'i32, - 9416'i32: 9442'i32, - 9417'i32: 9443'i32, - 9418'i32: 9444'i32, - 9419'i32: 9445'i32, - 9420'i32: 9446'i32, - 9421'i32: 9447'i32, - 9422'i32: 9448'i32, - 9423'i32: 9449'i32, - 11264'i32: 11312'i32, - 11265'i32: 11313'i32, - 11266'i32: 11314'i32, - 11267'i32: 11315'i32, - 11268'i32: 11316'i32, - 11269'i32: 11317'i32, - 11270'i32: 11318'i32, - 11271'i32: 11319'i32, - 11272'i32: 11320'i32, - 11273'i32: 11321'i32, - 11274'i32: 11322'i32, - 11275'i32: 11323'i32, - 11276'i32: 11324'i32, - 11277'i32: 11325'i32, - 11278'i32: 11326'i32, - 11279'i32: 11327'i32, - 11280'i32: 11328'i32, - 11281'i32: 11329'i32, - 11282'i32: 11330'i32, - 11283'i32: 11331'i32, - 11284'i32: 11332'i32, - 11285'i32: 11333'i32, - 11286'i32: 11334'i32, - 11287'i32: 11335'i32, - 11288'i32: 11336'i32, - 11289'i32: 11337'i32, - 11290'i32: 11338'i32, - 11291'i32: 11339'i32, - 11292'i32: 11340'i32, - 11293'i32: 11341'i32, - 11294'i32: 11342'i32, - 11295'i32: 11343'i32, - 11296'i32: 11344'i32, - 11297'i32: 11345'i32, - 11298'i32: 11346'i32, - 11299'i32: 11347'i32, - 11300'i32: 11348'i32, - 11301'i32: 11349'i32, - 11302'i32: 11350'i32, - 11303'i32: 11351'i32, - 11304'i32: 11352'i32, - 11305'i32: 11353'i32, - 11306'i32: 11354'i32, - 11307'i32: 11355'i32, - 11308'i32: 11356'i32, - 11309'i32: 11357'i32, - 11310'i32: 11358'i32, - 11311'i32: 11359'i32, - 11360'i32: 11361'i32, - 11362'i32: 619'i32, - 11363'i32: 7549'i32, - 11364'i32: 637'i32, - 11367'i32: 11368'i32, - 11369'i32: 11370'i32, - 11371'i32: 11372'i32, - 11373'i32: 593'i32, - 11374'i32: 625'i32, - 11375'i32: 592'i32, - 11376'i32: 594'i32, - 11378'i32: 11379'i32, - 11381'i32: 11382'i32, - 11390'i32: 575'i32, - 11391'i32: 576'i32, - 11392'i32: 11393'i32, - 11394'i32: 11395'i32, - 11396'i32: 11397'i32, - 11398'i32: 11399'i32, - 11400'i32: 11401'i32, - 11402'i32: 11403'i32, - 11404'i32: 11405'i32, - 11406'i32: 11407'i32, - 11408'i32: 11409'i32, - 11410'i32: 11411'i32, - 11412'i32: 11413'i32, - 11414'i32: 11415'i32, - 11416'i32: 11417'i32, - 11418'i32: 11419'i32, - 11420'i32: 11421'i32, - 11422'i32: 11423'i32, - 11424'i32: 11425'i32, - 11426'i32: 11427'i32, - 11428'i32: 11429'i32, - 11430'i32: 11431'i32, - 11432'i32: 11433'i32, - 11434'i32: 11435'i32, - 11436'i32: 11437'i32, - 11438'i32: 11439'i32, - 11440'i32: 11441'i32, - 11442'i32: 11443'i32, - 11444'i32: 11445'i32, - 11446'i32: 11447'i32, - 11448'i32: 11449'i32, - 11450'i32: 11451'i32, - 11452'i32: 11453'i32, - 11454'i32: 11455'i32, - 11456'i32: 11457'i32, - 11458'i32: 11459'i32, - 11460'i32: 11461'i32, - 11462'i32: 11463'i32, - 11464'i32: 11465'i32, - 11466'i32: 11467'i32, - 11468'i32: 11469'i32, - 11470'i32: 11471'i32, - 11472'i32: 11473'i32, - 11474'i32: 11475'i32, - 11476'i32: 11477'i32, - 11478'i32: 11479'i32, - 11480'i32: 11481'i32, - 11482'i32: 11483'i32, - 11484'i32: 11485'i32, - 11486'i32: 11487'i32, - 11488'i32: 11489'i32, - 11490'i32: 11491'i32, - 11499'i32: 11500'i32, - 11501'i32: 11502'i32, - 11506'i32: 11507'i32, - 42560'i32: 42561'i32, - 42562'i32: 42563'i32, - 42564'i32: 42565'i32, - 42566'i32: 42567'i32, - 42568'i32: 42569'i32, - 42570'i32: 42571'i32, - 42572'i32: 42573'i32, - 42574'i32: 42575'i32, - 42576'i32: 42577'i32, - 42578'i32: 42579'i32, - 42580'i32: 42581'i32, - 42582'i32: 42583'i32, - 42584'i32: 42585'i32, - 42586'i32: 42587'i32, - 42588'i32: 42589'i32, - 42590'i32: 42591'i32, - 42592'i32: 42593'i32, - 42594'i32: 42595'i32, - 42596'i32: 42597'i32, - 42598'i32: 42599'i32, - 42600'i32: 42601'i32, - 42602'i32: 42603'i32, - 42604'i32: 42605'i32, - 42624'i32: 42625'i32, - 42626'i32: 42627'i32, - 42628'i32: 42629'i32, - 42630'i32: 42631'i32, - 42632'i32: 42633'i32, - 42634'i32: 42635'i32, - 42636'i32: 42637'i32, - 42638'i32: 42639'i32, - 42640'i32: 42641'i32, - 42642'i32: 42643'i32, - 42644'i32: 42645'i32, - 42646'i32: 42647'i32, - 42648'i32: 42649'i32, - 42650'i32: 42651'i32, - 42786'i32: 42787'i32, - 42788'i32: 42789'i32, - 42790'i32: 42791'i32, - 42792'i32: 42793'i32, - 42794'i32: 42795'i32, - 42796'i32: 42797'i32, - 42798'i32: 42799'i32, - 42802'i32: 42803'i32, - 42804'i32: 42805'i32, - 42806'i32: 42807'i32, - 42808'i32: 42809'i32, - 42810'i32: 42811'i32, - 42812'i32: 42813'i32, - 42814'i32: 42815'i32, - 42816'i32: 42817'i32, - 42818'i32: 42819'i32, - 42820'i32: 42821'i32, - 42822'i32: 42823'i32, - 42824'i32: 42825'i32, - 42826'i32: 42827'i32, - 42828'i32: 42829'i32, - 42830'i32: 42831'i32, - 42832'i32: 42833'i32, - 42834'i32: 42835'i32, - 42836'i32: 42837'i32, - 42838'i32: 42839'i32, - 42840'i32: 42841'i32, - 42842'i32: 42843'i32, - 42844'i32: 42845'i32, - 42846'i32: 42847'i32, - 42848'i32: 42849'i32, - 42850'i32: 42851'i32, - 42852'i32: 42853'i32, - 42854'i32: 42855'i32, - 42856'i32: 42857'i32, - 42858'i32: 42859'i32, - 42860'i32: 42861'i32, - 42862'i32: 42863'i32, - 42873'i32: 42874'i32, - 42875'i32: 42876'i32, - 42877'i32: 7545'i32, - 42878'i32: 42879'i32, - 42880'i32: 42881'i32, - 42882'i32: 42883'i32, - 42884'i32: 42885'i32, - 42886'i32: 42887'i32, - 42891'i32: 42892'i32, - 42893'i32: 613'i32, - 42896'i32: 42897'i32, - 42898'i32: 42899'i32, - 42902'i32: 42903'i32, - 42904'i32: 42905'i32, - 42906'i32: 42907'i32, - 42908'i32: 42909'i32, - 42910'i32: 42911'i32, - 42912'i32: 42913'i32, - 42914'i32: 42915'i32, - 42916'i32: 42917'i32, - 42918'i32: 42919'i32, - 42920'i32: 42921'i32, - 42922'i32: 614'i32, - 42923'i32: 604'i32, - 42924'i32: 609'i32, - 42925'i32: 620'i32, - 42926'i32: 618'i32, - 42928'i32: 670'i32, - 42929'i32: 647'i32, - 42930'i32: 669'i32, - 42931'i32: 43859'i32, - 42932'i32: 42933'i32, - 42934'i32: 42935'i32, - 42936'i32: 42937'i32, - 42938'i32: 42939'i32, - 42940'i32: 42941'i32, - 42942'i32: 42943'i32, - 42944'i32: 42945'i32, - 42946'i32: 42947'i32, - 42948'i32: 42900'i32, - 42949'i32: 642'i32, - 42950'i32: 7566'i32, - 42951'i32: 42952'i32, - 42953'i32: 42954'i32, - 42960'i32: 42961'i32, - 42966'i32: 42967'i32, - 42968'i32: 42969'i32, - 42997'i32: 42998'i32, - 43888'i32: 5024'i32, - 43889'i32: 5025'i32, - 43890'i32: 5026'i32, - 43891'i32: 5027'i32, - 43892'i32: 5028'i32, - 43893'i32: 5029'i32, - 43894'i32: 5030'i32, - 43895'i32: 5031'i32, - 43896'i32: 5032'i32, - 43897'i32: 5033'i32, - 43898'i32: 5034'i32, - 43899'i32: 5035'i32, - 43900'i32: 5036'i32, - 43901'i32: 5037'i32, - 43902'i32: 5038'i32, - 43903'i32: 5039'i32, - 43904'i32: 5040'i32, - 43905'i32: 5041'i32, - 43906'i32: 5042'i32, - 43907'i32: 5043'i32, - 43908'i32: 5044'i32, - 43909'i32: 5045'i32, - 43910'i32: 5046'i32, - 43911'i32: 5047'i32, - 43912'i32: 5048'i32, - 43913'i32: 5049'i32, - 43914'i32: 5050'i32, - 43915'i32: 5051'i32, - 43916'i32: 5052'i32, - 43917'i32: 5053'i32, - 43918'i32: 5054'i32, - 43919'i32: 5055'i32, - 43920'i32: 5056'i32, - 43921'i32: 5057'i32, - 43922'i32: 5058'i32, - 43923'i32: 5059'i32, - 43924'i32: 5060'i32, - 43925'i32: 5061'i32, - 43926'i32: 5062'i32, - 43927'i32: 5063'i32, - 43928'i32: 5064'i32, - 43929'i32: 5065'i32, - 43930'i32: 5066'i32, - 43931'i32: 5067'i32, - 43932'i32: 5068'i32, - 43933'i32: 5069'i32, - 43934'i32: 5070'i32, - 43935'i32: 5071'i32, - 43936'i32: 5072'i32, - 43937'i32: 5073'i32, - 43938'i32: 5074'i32, - 43939'i32: 5075'i32, - 43940'i32: 5076'i32, - 43941'i32: 5077'i32, - 43942'i32: 5078'i32, - 43943'i32: 5079'i32, - 43944'i32: 5080'i32, - 43945'i32: 5081'i32, - 43946'i32: 5082'i32, - 43947'i32: 5083'i32, - 43948'i32: 5084'i32, - 43949'i32: 5085'i32, - 43950'i32: 5086'i32, - 43951'i32: 5087'i32, - 43952'i32: 5088'i32, - 43953'i32: 5089'i32, - 43954'i32: 5090'i32, - 43955'i32: 5091'i32, - 43956'i32: 5092'i32, - 43957'i32: 5093'i32, - 43958'i32: 5094'i32, - 43959'i32: 5095'i32, - 43960'i32: 5096'i32, - 43961'i32: 5097'i32, - 43962'i32: 5098'i32, - 43963'i32: 5099'i32, - 43964'i32: 5100'i32, - 43965'i32: 5101'i32, - 43966'i32: 5102'i32, - 43967'i32: 5103'i32, - 65313'i32: 65345'i32, - 65314'i32: 65346'i32, - 65315'i32: 65347'i32, - 65316'i32: 65348'i32, - 65317'i32: 65349'i32, - 65318'i32: 65350'i32, - 65319'i32: 65351'i32, - 65320'i32: 65352'i32, - 65321'i32: 65353'i32, - 65322'i32: 65354'i32, - 65323'i32: 65355'i32, - 65324'i32: 65356'i32, - 65325'i32: 65357'i32, - 65326'i32: 65358'i32, - 65327'i32: 65359'i32, - 65328'i32: 65360'i32, - 65329'i32: 65361'i32, - 65330'i32: 65362'i32, - 65331'i32: 65363'i32, - 65332'i32: 65364'i32, - 65333'i32: 65365'i32, - 65334'i32: 65366'i32, - 65335'i32: 65367'i32, - 65336'i32: 65368'i32, - 65337'i32: 65369'i32, - 65338'i32: 65370'i32, - 66560'i32: 66600'i32, - 66561'i32: 66601'i32, - 66562'i32: 66602'i32, - 66563'i32: 66603'i32, - 66564'i32: 66604'i32, - 66565'i32: 66605'i32, - 66566'i32: 66606'i32, - 66567'i32: 66607'i32, - 66568'i32: 66608'i32, - 66569'i32: 66609'i32, - 66570'i32: 66610'i32, - 66571'i32: 66611'i32, - 66572'i32: 66612'i32, - 66573'i32: 66613'i32, - 66574'i32: 66614'i32, - 66575'i32: 66615'i32, - 66576'i32: 66616'i32, - 66577'i32: 66617'i32, - 66578'i32: 66618'i32, - 66579'i32: 66619'i32, - 66580'i32: 66620'i32, - 66581'i32: 66621'i32, - 66582'i32: 66622'i32, - 66583'i32: 66623'i32, - 66584'i32: 66624'i32, - 66585'i32: 66625'i32, - 66586'i32: 66626'i32, - 66587'i32: 66627'i32, - 66588'i32: 66628'i32, - 66589'i32: 66629'i32, - 66590'i32: 66630'i32, - 66591'i32: 66631'i32, - 66592'i32: 66632'i32, - 66593'i32: 66633'i32, - 66594'i32: 66634'i32, - 66595'i32: 66635'i32, - 66596'i32: 66636'i32, - 66597'i32: 66637'i32, - 66598'i32: 66638'i32, - 66599'i32: 66639'i32, - 66736'i32: 66776'i32, - 66737'i32: 66777'i32, - 66738'i32: 66778'i32, - 66739'i32: 66779'i32, - 66740'i32: 66780'i32, - 66741'i32: 66781'i32, - 66742'i32: 66782'i32, - 66743'i32: 66783'i32, - 66744'i32: 66784'i32, - 66745'i32: 66785'i32, - 66746'i32: 66786'i32, - 66747'i32: 66787'i32, - 66748'i32: 66788'i32, - 66749'i32: 66789'i32, - 66750'i32: 66790'i32, - 66751'i32: 66791'i32, - 66752'i32: 66792'i32, - 66753'i32: 66793'i32, - 66754'i32: 66794'i32, - 66755'i32: 66795'i32, - 66756'i32: 66796'i32, - 66757'i32: 66797'i32, - 66758'i32: 66798'i32, - 66759'i32: 66799'i32, - 66760'i32: 66800'i32, - 66761'i32: 66801'i32, - 66762'i32: 66802'i32, - 66763'i32: 66803'i32, - 66764'i32: 66804'i32, - 66765'i32: 66805'i32, - 66766'i32: 66806'i32, - 66767'i32: 66807'i32, - 66768'i32: 66808'i32, - 66769'i32: 66809'i32, - 66770'i32: 66810'i32, - 66771'i32: 66811'i32, - 66928'i32: 66967'i32, - 66929'i32: 66968'i32, - 66930'i32: 66969'i32, - 66931'i32: 66970'i32, - 66932'i32: 66971'i32, - 66933'i32: 66972'i32, - 66934'i32: 66973'i32, - 66935'i32: 66974'i32, - 66936'i32: 66975'i32, - 66937'i32: 66976'i32, - 66938'i32: 66977'i32, - 66940'i32: 66979'i32, - 66941'i32: 66980'i32, - 66942'i32: 66981'i32, - 66943'i32: 66982'i32, - 66944'i32: 66983'i32, - 66945'i32: 66984'i32, - 66946'i32: 66985'i32, - 66947'i32: 66986'i32, - 66948'i32: 66987'i32, - 66949'i32: 66988'i32, - 66950'i32: 66989'i32, - 66951'i32: 66990'i32, - 66952'i32: 66991'i32, - 66953'i32: 66992'i32, - 66954'i32: 66993'i32, - 66956'i32: 66995'i32, - 66957'i32: 66996'i32, - 66958'i32: 66997'i32, - 66959'i32: 66998'i32, - 66960'i32: 66999'i32, - 66961'i32: 67000'i32, - 66962'i32: 67001'i32, - 66964'i32: 67003'i32, - 66965'i32: 67004'i32, - 68736'i32: 68800'i32, - 68737'i32: 68801'i32, - 68738'i32: 68802'i32, - 68739'i32: 68803'i32, - 68740'i32: 68804'i32, - 68741'i32: 68805'i32, - 68742'i32: 68806'i32, - 68743'i32: 68807'i32, - 68744'i32: 68808'i32, - 68745'i32: 68809'i32, - 68746'i32: 68810'i32, - 68747'i32: 68811'i32, - 68748'i32: 68812'i32, - 68749'i32: 68813'i32, - 68750'i32: 68814'i32, - 68751'i32: 68815'i32, - 68752'i32: 68816'i32, - 68753'i32: 68817'i32, - 68754'i32: 68818'i32, - 68755'i32: 68819'i32, - 68756'i32: 68820'i32, - 68757'i32: 68821'i32, - 68758'i32: 68822'i32, - 68759'i32: 68823'i32, - 68760'i32: 68824'i32, - 68761'i32: 68825'i32, - 68762'i32: 68826'i32, - 68763'i32: 68827'i32, - 68764'i32: 68828'i32, - 68765'i32: 68829'i32, - 68766'i32: 68830'i32, - 68767'i32: 68831'i32, - 68768'i32: 68832'i32, - 68769'i32: 68833'i32, - 68770'i32: 68834'i32, - 68771'i32: 68835'i32, - 68772'i32: 68836'i32, - 68773'i32: 68837'i32, - 68774'i32: 68838'i32, - 68775'i32: 68839'i32, - 68776'i32: 68840'i32, - 68777'i32: 68841'i32, - 68778'i32: 68842'i32, - 68779'i32: 68843'i32, - 68780'i32: 68844'i32, - 68781'i32: 68845'i32, - 68782'i32: 68846'i32, - 68783'i32: 68847'i32, - 68784'i32: 68848'i32, - 68785'i32: 68849'i32, - 68786'i32: 68850'i32, - 71840'i32: 71872'i32, - 71841'i32: 71873'i32, - 71842'i32: 71874'i32, - 71843'i32: 71875'i32, - 71844'i32: 71876'i32, - 71845'i32: 71877'i32, - 71846'i32: 71878'i32, - 71847'i32: 71879'i32, - 71848'i32: 71880'i32, - 71849'i32: 71881'i32, - 71850'i32: 71882'i32, - 71851'i32: 71883'i32, - 71852'i32: 71884'i32, - 71853'i32: 71885'i32, - 71854'i32: 71886'i32, - 71855'i32: 71887'i32, - 71856'i32: 71888'i32, - 71857'i32: 71889'i32, - 71858'i32: 71890'i32, - 71859'i32: 71891'i32, - 71860'i32: 71892'i32, - 71861'i32: 71893'i32, - 71862'i32: 71894'i32, - 71863'i32: 71895'i32, - 71864'i32: 71896'i32, - 71865'i32: 71897'i32, - 71866'i32: 71898'i32, - 71867'i32: 71899'i32, - 71868'i32: 71900'i32, - 71869'i32: 71901'i32, - 71870'i32: 71902'i32, - 71871'i32: 71903'i32, - 93760'i32: 93792'i32, - 93761'i32: 93793'i32, - 93762'i32: 93794'i32, - 93763'i32: 93795'i32, - 93764'i32: 93796'i32, - 93765'i32: 93797'i32, - 93766'i32: 93798'i32, - 93767'i32: 93799'i32, - 93768'i32: 93800'i32, - 93769'i32: 93801'i32, - 93770'i32: 93802'i32, - 93771'i32: 93803'i32, - 93772'i32: 93804'i32, - 93773'i32: 93805'i32, - 93774'i32: 93806'i32, - 93775'i32: 93807'i32, - 93776'i32: 93808'i32, - 93777'i32: 93809'i32, - 93778'i32: 93810'i32, - 93779'i32: 93811'i32, - 93780'i32: 93812'i32, - 93781'i32: 93813'i32, - 93782'i32: 93814'i32, - 93783'i32: 93815'i32, - 93784'i32: 93816'i32, - 93785'i32: 93817'i32, - 93786'i32: 93818'i32, - 93787'i32: 93819'i32, - 93788'i32: 93820'i32, - 93789'i32: 93821'i32, - 93790'i32: 93822'i32, - 93791'i32: 93823'i32, - 125184'i32: 125218'i32, - 125185'i32: 125219'i32, - 125186'i32: 125220'i32, - 125187'i32: 125221'i32, - 125188'i32: 125222'i32, - 125189'i32: 125223'i32, - 125190'i32: 125224'i32, - 125191'i32: 125225'i32, - 125192'i32: 125226'i32, - 125193'i32: 125227'i32, - 125194'i32: 125228'i32, - 125195'i32: 125229'i32, - 125196'i32: 125230'i32, - 125197'i32: 125231'i32, - 125198'i32: 125232'i32, - 125199'i32: 125233'i32, - 125200'i32: 125234'i32, - 125201'i32: 125235'i32, - 125202'i32: 125236'i32, - 125203'i32: 125237'i32, - 125204'i32: 125238'i32, - 125205'i32: 125239'i32, - 125206'i32: 125240'i32, - 125207'i32: 125241'i32, - 125208'i32: 125242'i32, - 125209'i32: 125243'i32, - 125210'i32: 125244'i32, - 125211'i32: 125245'i32, - 125212'i32: 125246'i32, - 125213'i32: 125247'i32, - 125214'i32: 125248'i32, - 125215'i32: 125249'i32, - 125216'i32: 125250'i32, - 125217'i32: 125251'i32, -} -const FullMapper = { - 223'i32: "ss", - 304'i32: "i̇", - 329'i32: "ʼn", - 496'i32: "ǰ", - 912'i32: "ΐ", - 944'i32: "ΰ", - 1415'i32: "եւ", - 7830'i32: "ẖ", - 7831'i32: "ẗ", - 7832'i32: "ẘ", - 7833'i32: "ẙ", - 7834'i32: "aʾ", - 7838'i32: "ss", - 8016'i32: "ὐ", - 8018'i32: "ὒ", - 8020'i32: "ὔ", - 8022'i32: "ὖ", - 8064'i32: "ἀι", - 8065'i32: "ἁι", - 8066'i32: "ἂι", - 8067'i32: "ἃι", - 8068'i32: "ἄι", - 8069'i32: "ἅι", - 8070'i32: "ἆι", - 8071'i32: "ἇι", - 8072'i32: "ἀι", - 8073'i32: "ἁι", - 8074'i32: "ἂι", - 8075'i32: "ἃι", - 8076'i32: "ἄι", - 8077'i32: "ἅι", - 8078'i32: "ἆι", - 8079'i32: "ἇι", - 8080'i32: "ἠι", - 8081'i32: "ἡι", - 8082'i32: "ἢι", - 8083'i32: "ἣι", - 8084'i32: "ἤι", - 8085'i32: "ἥι", - 8086'i32: "ἦι", - 8087'i32: "ἧι", - 8088'i32: "ἠι", - 8089'i32: "ἡι", - 8090'i32: "ἢι", - 8091'i32: "ἣι", - 8092'i32: "ἤι", - 8093'i32: "ἥι", - 8094'i32: "ἦι", - 8095'i32: "ἧι", - 8096'i32: "ὠι", - 8097'i32: "ὡι", - 8098'i32: "ὢι", - 8099'i32: "ὣι", - 8100'i32: "ὤι", - 8101'i32: "ὥι", - 8102'i32: "ὦι", - 8103'i32: "ὧι", - 8104'i32: "ὠι", - 8105'i32: "ὡι", - 8106'i32: "ὢι", - 8107'i32: "ὣι", - 8108'i32: "ὤι", - 8109'i32: "ὥι", - 8110'i32: "ὦι", - 8111'i32: "ὧι", - 8114'i32: "ὰι", - 8115'i32: "αι", - 8116'i32: "άι", - 8118'i32: "ᾶ", - 8119'i32: "ᾶι", - 8124'i32: "αι", - 8130'i32: "ὴι", - 8131'i32: "ηι", - 8132'i32: "ήι", - 8134'i32: "ῆ", - 8135'i32: "ῆι", - 8140'i32: "ηι", - 8146'i32: "ῒ", - 8147'i32: "ΐ", - 8150'i32: "ῖ", - 8151'i32: "ῗ", - 8162'i32: "ῢ", - 8163'i32: "ΰ", - 8164'i32: "ῤ", - 8166'i32: "ῦ", - 8167'i32: "ῧ", - 8178'i32: "ὼι", - 8179'i32: "ωι", - 8180'i32: "ώι", - 8182'i32: "ῶ", - 8183'i32: "ῶι", - 8188'i32: "ωι", - 64256'i32: "ff", - 64257'i32: "fi", - 64258'i32: "fl", - 64259'i32: "ffi", - 64260'i32: "ffl", - 64261'i32: "st", - 64262'i32: "st", - 64275'i32: "մն", - 64276'i32: "մե", - 64277'i32: "մի", - 64278'i32: "վն", - 64279'i32: "մխ", -} diff --git a/src/pylib/pystring/unicase/toUpperMapper.nim b/src/pylib/pystring/unicase/toUpperMapper.nim deleted file mode 100644 index 8449d0028..000000000 --- a/src/pylib/pystring/unicase/toUpperMapper.nim +++ /dev/null @@ -1,110 +0,0 @@ -# Generated by /tools/unicodedata/gen_upper_map.py -# where `/` refers to the root path of this project. -# to be included - -# only one character that will be extended to more characters when tolower: -# chr(304) a.k.a. LATIN CAPITAL LETTER I WITH DOT ABOVE -const OneUpperToMoreTableLit = { - 223'i32: "SS", - 329'i32: "\u02bcN", - 496'i32: "J\u030c", - 912'i32: "\u0399\u0308\u0301", - 944'i32: "\u03a5\u0308\u0301", - 1415'i32: "\u0535\u0552", - 7830'i32: "H\u0331", - 7831'i32: "T\u0308", - 7832'i32: "W\u030a", - 7833'i32: "Y\u030a", - 7834'i32: "A\u02be", - 8016'i32: "\u03a5\u0313", - 8018'i32: "\u03a5\u0313\u0300", - 8020'i32: "\u03a5\u0313\u0301", - 8022'i32: "\u03a5\u0313\u0342", - 8064'i32: "\u1f08\u0399", - 8065'i32: "\u1f09\u0399", - 8066'i32: "\u1f0a\u0399", - 8067'i32: "\u1f0b\u0399", - 8068'i32: "\u1f0c\u0399", - 8069'i32: "\u1f0d\u0399", - 8070'i32: "\u1f0e\u0399", - 8071'i32: "\u1f0f\u0399", - 8072'i32: "\u1f08\u0399", - 8073'i32: "\u1f09\u0399", - 8074'i32: "\u1f0a\u0399", - 8075'i32: "\u1f0b\u0399", - 8076'i32: "\u1f0c\u0399", - 8077'i32: "\u1f0d\u0399", - 8078'i32: "\u1f0e\u0399", - 8079'i32: "\u1f0f\u0399", - 8080'i32: "\u1f28\u0399", - 8081'i32: "\u1f29\u0399", - 8082'i32: "\u1f2a\u0399", - 8083'i32: "\u1f2b\u0399", - 8084'i32: "\u1f2c\u0399", - 8085'i32: "\u1f2d\u0399", - 8086'i32: "\u1f2e\u0399", - 8087'i32: "\u1f2f\u0399", - 8088'i32: "\u1f28\u0399", - 8089'i32: "\u1f29\u0399", - 8090'i32: "\u1f2a\u0399", - 8091'i32: "\u1f2b\u0399", - 8092'i32: "\u1f2c\u0399", - 8093'i32: "\u1f2d\u0399", - 8094'i32: "\u1f2e\u0399", - 8095'i32: "\u1f2f\u0399", - 8096'i32: "\u1f68\u0399", - 8097'i32: "\u1f69\u0399", - 8098'i32: "\u1f6a\u0399", - 8099'i32: "\u1f6b\u0399", - 8100'i32: "\u1f6c\u0399", - 8101'i32: "\u1f6d\u0399", - 8102'i32: "\u1f6e\u0399", - 8103'i32: "\u1f6f\u0399", - 8104'i32: "\u1f68\u0399", - 8105'i32: "\u1f69\u0399", - 8106'i32: "\u1f6a\u0399", - 8107'i32: "\u1f6b\u0399", - 8108'i32: "\u1f6c\u0399", - 8109'i32: "\u1f6d\u0399", - 8110'i32: "\u1f6e\u0399", - 8111'i32: "\u1f6f\u0399", - 8114'i32: "\u1fba\u0399", - 8115'i32: "\u0391\u0399", - 8116'i32: "\u0386\u0399", - 8118'i32: "\u0391\u0342", - 8119'i32: "\u0391\u0342\u0399", - 8124'i32: "\u0391\u0399", - 8130'i32: "\u1fca\u0399", - 8131'i32: "\u0397\u0399", - 8132'i32: "\u0389\u0399", - 8134'i32: "\u0397\u0342", - 8135'i32: "\u0397\u0342\u0399", - 8140'i32: "\u0397\u0399", - 8146'i32: "\u0399\u0308\u0300", - 8147'i32: "\u0399\u0308\u0301", - 8150'i32: "\u0399\u0342", - 8151'i32: "\u0399\u0308\u0342", - 8162'i32: "\u03a5\u0308\u0300", - 8163'i32: "\u03a5\u0308\u0301", - 8164'i32: "\u03a1\u0313", - 8166'i32: "\u03a5\u0342", - 8167'i32: "\u03a5\u0308\u0342", - 8178'i32: "\u1ffa\u0399", - 8179'i32: "\u03a9\u0399", - 8180'i32: "\u038f\u0399", - 8182'i32: "\u03a9\u0342", - 8183'i32: "\u03a9\u0342\u0399", - 8188'i32: "\u03a9\u0399", - 64256'i32: "FF", - 64257'i32: "FI", - 64258'i32: "FL", - 64259'i32: "FFI", - 64260'i32: "FFL", - 64261'i32: "ST", - 64262'i32: "ST", - 64275'i32: "\u0544\u0546", - 64276'i32: "\u0544\u0535", - 64277'i32: "\u0544\u053b", - 64278'i32: "\u054e\u0546", - 64279'i32: "\u0544\u053d", -} diff --git a/src/pylib/pysugar.nim b/src/pylib/pysugar.nim deleted file mode 100644 index ec5e8adca..000000000 --- a/src/pylib/pysugar.nim +++ /dev/null @@ -1,57 +0,0 @@ - -import std/macros - -import ./pysugar/[ - pywith, tonim, class, pydef, unpack -] - -export pywith, tonim, class, pydef, unpack - -# if trying to support `pass expr`: -# nimv2 somehow has a bug -# # lib.nim -# template pass* = discard -# template pass*(_) = discard -# -# # main.nim -# import lib -# pass # <- Error: ambiguous identifier: 'pass' -- ... -template pass* = discard - -template lambda*(code: untyped): untyped = - (proc (): auto = code) # Mimic Pythons Lambda - -template `:=`*[T](name; value: T): T = - ## Mimic Pythons Operator. - when compiles((var name: T)): - var name: T - name = value - name - -macro del*(seqIdx: untyped) = - ##[ - - `del ls[idx]` -> `delitem(ls, idx)`; - - `del obj.attr` -> compilation-error. Nim is static-typed, - dynamically deleting object's attributes is not allowed. - - `del ls[1:3]` (only supported in `def` body) - - see [list of unsupported notations]( -https://github.com/nimpylib/pylib/blob/master/doc%2FmustRewriteExtern%2FgetsetitemSliceLit.md) - for more details. - - .. note:: Nim's `del(seq, idx)` is an O(1) operation, - which moves the last element to `idx` - ]## - result = newCall(newDotExpr(ident"system", ident"del"), seqIdx) - var seqV, idx: NimNode - if seqIdx.kind == nnkBracketExpr: - # XXX: why this branch is not entered but the next? - seqV = seqIdx[0] - idx = seqIdx[1] - elif seqIdx.kind == nnkCall: - if seqIdx[0].repr != "[]": - return - seqV = seqIdx[1] - idx = seqIdx[2] - else: - return # do not affect Nim system `del ls, idx` - result = newCall("delitem", seqV, idx) diff --git a/src/pylib/pysugar/class.nim b/src/pylib/pysugar/class.nim deleted file mode 100644 index dcc02f293..000000000 --- a/src/pylib/pysugar/class.nim +++ /dev/null @@ -1,42 +0,0 @@ - -import ./stmt/class -export class.new, class.init_subclass -import ./parserWithCfg - -macro classAux(obj, body: untyped, topLevel: static[bool]): untyped = - ## wrapper of `classImpl proc<./stmt/tonim.html>`_ - runnableExamples: - class O: - "doc" - a: int - b = 2 - c: int = 1 - def f(self): return self.b - assert O().f() == 2 - - class O1(O): - a1 = -1 - def f(self): return self.a1 - assert O1().a == 0 - assert O(O1()).f() == -1 - - # will error: class OO(O1, O): aaa = 1 - - class C: - def f(self, b: float) -> int: return 1+int(b) - assert C().f(2) == 3 - - class CC(C): - def f(self, b: float): - return super().f(b) - assert CC().f(2) == 3 - var parser = parserWithDefCfg() - parser.classImpl(obj, body, topLevel) - -template class*(obj, body) = - bind classAux - classAux(obj, body, - instantiationInfo().column == 0 - # cannot handle `when` - ) - diff --git a/src/pylib/pysugar/parserWithCfg.nim b/src/pylib/pysugar/parserWithCfg.nim deleted file mode 100644 index 3bcfd51c4..000000000 --- a/src/pylib/pysugar/parserWithCfg.nim +++ /dev/null @@ -1,13 +0,0 @@ - -import ../version -import ./stmt/[pydef, tonim] -export parsePyBody, parsePyBodyWithDoc, parsePyExpr - -const - PySignatureSupportGenerics* = (PyMajor, PyMinor) >= (3, 12) - PyDedentDocString* = (PyMajor, PyMinor) >= (3, 13) - -func parserWithDefCfg*: PyAsgnRewriter = - bind PyAsgnRewriter, parsePyBody, parsePyBodyWithDoc - static: assert PyAsgnRewriter is PySyntaxProcesser - newPyAsgnRewriter(PySignatureSupportGenerics, PyDedentDocString) diff --git a/src/pylib/pysugar/pydef.nim b/src/pylib/pysugar/pydef.nim deleted file mode 100644 index c258819e8..000000000 --- a/src/pylib/pysugar/pydef.nim +++ /dev/null @@ -1,103 +0,0 @@ -##[ python's def and async def - -support: - - param - - param: type - - param = defval - - `*args` - - -> restype - - """doc-str""" or "doc-str" - - nested def or async def - -limits: - - `*args` can only contain one type's arguments - - can't combine type and defval i.e. `param: type = defval` is unsupported - - for async def, only `-> Future[void]` can be omitted. Refer to std/asyncmacro for details - - variables must be declared using `let`/`var`/`const` (this can be solved but is unnecessary) - -unsupport: - - generator (yield within def) *TODO* - - `**kws` - - `*` and `/` in parameters-list -see codes in `runnableExamples` for more details -]## - -#[def has AST structure like this: - Command - Ident !"def" - Call - Ident !"argument" - Ident !"second_argument" - ExprEqExpr - Ident !"default_arg" - FloatLit 0.0 - StmtList - procedure body here -]# - -import std/macros -import ./stmt/[pydef, tonim] -import ./parserWithCfg -export PySignatureSupportGenerics - -macro define*(signature, body): untyped = - ## almost the same as `def`, but is for `template` instead of `proc` - ## - ## XXX: nesting `define` is not supported. If wanting, use `template`. - ## however, `def` in `define` is allowed. - runnableExamples: - define templ(a): a+1 # note template has no implicit `result` variable - assert templ(3) == 4 - var parser = parserWithDefCfg() - defAux(signature, body, parser=parser, deftype=ident"untyped", procType=nnkTemplateDef) - -macro def*(signature, body): untyped = - runnableExamples: - def add(a,b): return a + b # use auto as argtype and restype - def addi(a: int, b = 1) -> int: return add(a, b) - assert addi(3) == 4 - def nested(a): - def closure(): - return a - return closure - assert nested(3)() == 3 - def max(a, b, *args): - "This is doc-str: a python-like `max`" - def max2(a,b): - if a>b: return a - else: return b - result = max2(a, b) - for i in args: - result = max2(result, i) - return result - assert max(1,4,2,5,0) == 5 - when PySignatureSupportGenerics: # pysince 3.13 - def sub[T](a: T, b: T) -> T: - return a - b - assert sub(4, 5) == -1 - - def f2[A, B](a: A, b: B) -> A: - return a + A(b) - assert int(2) == f2(1, 1.0) - var parser = parserWithDefCfg() - defImpl(signature, body, parser=parser) - - -macro async*(defsign, body): untyped = - ## `async def ...` - runnableExamples: - import std/async - async def af(): - discard "no restype mean Future[void]" - async def afi() -> Future[int]: - return 3 - when defined(js): - await af() - echo await afi() - else: - import std/asyncdispatch - waitFor af() - assert 3 == waitFor(afi()) - var parser = parserWithDefCfg() - asyncImpl defsign, body, parser=parser - diff --git a/src/pylib/pysugar/pywith.nim b/src/pylib/pysugar/pywith.nim deleted file mode 100644 index 7256142f3..000000000 --- a/src/pylib/pysugar/pywith.nim +++ /dev/null @@ -1,90 +0,0 @@ -import std/macros - -# Python-like with -# Should support both normal Nim types that have a `close` proc defined -# or Python-like context managers (hasn't been tested thoroughly) - -type - # I tried doing matching with `compiles` but it didn't work... - CtxManagerPy[T] = concept c - c.enter() is T - c.exit() - - CtxManager[T] = concept c - c.open() is T - c.close() - -macro with*(args: varargs[untyped]): untyped = - ## Python-like with statement. Supports most of the possible - ## variants Python with statement supports. Context managers - ## are supported but need to use `enter()` and `exit()` or `open()` - ## and `close()` instead of the underscored names. - # Body of the with statement - let body = args[^1] - - # Code to be inserted before the body - var beforeStmt = newStmtList() - # Code to be inserted in the finally branch of the try: finally: - var finallyStmt = newStmtList() - - # Skip last element (the body) - for i in 0 ..< args.len - 1: - let arg = args[i] - # nnkInfix -> "with A() as a:" - # nnkIdent -> "with something:" - # otherwise - calls like "with myCall():", etc - let (name, exp) = - if arg.kind == nnkInfix: (arg[2], arg[1]) - elif arg.kind == nnkIdent: (newEmptyNode(), arg) - else: (newEmptyNode(), arg) - - # Variable name for the context manager itself (if it exists) - var ctx = - if exp.kind == nnkIdent: exp - else: genSym(nskVar, "ctxMgr") - - # Variable name for the injected variable. If the name is empty, then - # the user won't see it, but we generate it anyway so that you can - # "discard" context managers or values in `with` as in Python - var varName = - if name.kind != nnkEmpty: name - else: genSym(nskVar, "injectedVar") - - # Cache if this expression is a context manager (python style or normal) - var isCtxOpen = genSym(nskConst, $ctx & "IsOpen") - var isCtxEnter = genSym(nskConst, $ctx & "IsEnter") - - # If it's a context manager, we create an additional variable for it - # and get the variable via the open call - # Otherwise just assign the variable to the expression - beforeStmt.add quote do: - {.push hint[XDeclaredButNotUsed]: off.} - const `isCtxOpen` = `exp` is CtxManager - const `isCtxEnter` = `exp` is CtxManagerPy - {.pop.} - - when `isCtxOpen` or `isCtxEnter`: - var `ctx` = `exp` - var `varName` = when `isCtxOpen`: `ctx`.open() else: `ctx`.enter() - else: - var `varName` = `exp` - - # Use insert instead of add so that finally statements are inserted - # in the reverse order - consistent with what Python does - finallyStmt.insert(0, quote do: - when `isCtxOpen` or `isCtxEnter`: - when `isCtxOpen`: `ctx`.close() else: `ctx`.exit() - else: - `varName`.close() - ) - - result = quote do: - block: - `beforeStmt` - try: - `body` - finally: - `finallyStmt` - - when defined(pylibDebug): - echo repr result diff --git a/src/pylib/pysugar/stmt/README.md b/src/pylib/pysugar/stmt/README.md deleted file mode 100644 index 3a37cd02e..000000000 --- a/src/pylib/pysugar/stmt/README.md +++ /dev/null @@ -1,8 +0,0 @@ -# Some Notes - -## pydef.nim and tonim -are implementation of ../pydef.nim and ../tonim.nim, respectively. - -## funcSignature.nim -rewrites `def` (Python-favor) function signature to Nim's `proc` signature. - diff --git a/src/pylib/pysugar/stmt/chainCmp.nim b/src/pylib/pysugar/stmt/chainCmp.nim deleted file mode 100644 index ecf98afe6..000000000 --- a/src/pylib/pysugar/stmt/chainCmp.nim +++ /dev/null @@ -1,58 +0,0 @@ - -import std/macros -from std/strutils import nimIdentNormalize, toLowerAscii - -proc isOfComparisions(op: NimNode): bool = - ##[ "<" | ">" | "==" | ">=" | "<=" | "!=" - | "is" ["not"] | ["not"] "in"]## - if not op.len == 0: return - let sop = $op - case sop.len - of 1: - sop[0] in {'<', '>'} - of 2: - sop in ["==", ">=", "<=", "!="] or - sop[0] == 'i' and sop[1].toLowerAscii in {'s', 'n'} # is/in - else: - sop.nimIdentNormalize in ["is_not", "not_in"] - -proc newInfix(op, l, r: NimNode): NimNode = nnkInfix.newTree(op, l, r) - -proc expandChainImpl(resStmt: NimNode, cExp: NimNode): NimNode = - let - op = cExp[0] - lhs = cExp[1] - rhs = cExp[2] - template shallChain: bool = - lhs.len == 3 and op.isOfComparisions and lhs[0].isOfComparisions - if shallChain: - let med = lhs[2] - if med.len != 0: - let id = genSym(nskLet, "cmpMed") - resStmt.add newLetStmt(id, med) - lhs[2] = id - nnkInfix.newTree(bindSym"and", - expandChainImpl(resStmt, lhs), - newInfix(op, lhs[2], rhs)) - else: # if isCmpOp: # but lhs is not - cExp - -proc expandChainImpl*(cExp: NimNode): NimNode = - result = newStmtList() - result.add expandChainImpl(result, cExp) - -macro expandChain*(cExp): bool = - expectKind cExp, nnkInfix - expandChainImpl(cExp) - -when isMainModule: - template tCmp(m) = - assert expandChain(1 < m <= 3) - assert expandChain(1 < m > 2) - tCmp 3 - var g = 0 - proc f(): int = - g.inc - 3 - tCmp f() - assert g == 2, $g diff --git a/src/pylib/pysugar/stmt/class.nim b/src/pylib/pysugar/stmt/class.nim deleted file mode 100644 index 75eed7e89..000000000 --- a/src/pylib/pysugar/stmt/class.nim +++ /dev/null @@ -1,563 +0,0 @@ - -import std/macros -import ./frame, ./funcSignature, ./decorator, ./types, ./decl -import ./pydef -import ../../noneType -import ../../pystring/[strimpl] -import ../../builtins/[list] -proc getNoneTypeNode: NimNode = bindSym"NoneType" -template emptyn: NimNode = newEmptyNode() - -#proc mapSuper(nCall: NimNode): NimNode = discard - -type - MethKind = enum - mkNorm - mkCls - mkStatic - -proc replaceSuperCall(n: var NimNode, defSupCls: NimNode, methKind: MethKind): bool = - template nret(cond): untyped = - if not cond: - return - nret n.kind == nnkCall - nret n[0].kind == nnkDotExpr - let callSup = n[0][0] - nret callSup.kind == nnkCall - nret callSup[0].eqIdent "super" - - var cArgLen = callSup.len - 1 - let supCls = - if cArgLen > 1: - if cArgLen > 2: error "super([[, self]]) expected, but got too many args" - callSup[1] - else: - if cArgLen == 0: - callSup.add defSupCls - cArgLen.inc - defSupCls - - template expectLastOrAdd(id: string) = - if cArgLen == 2: - expectIdent callSup[2], id - else: - callSup.add ident id - cArgLen.inc - - if methKind == mkCls: - expectLastOrAdd "cls" - n = newDotExpr(supCls, n[0][1]).newCall(callSup[2]) - elif methKind == mkNorm: - expectLastOrAdd "self" - n[0][0] = newCall(supCls, callSup[2]) - - #let meth = n[0][1] - #let args = n[1..^1] - - n = newCall(ident"procCall", n) - - result = true - -template new*[T; R: ref](_: typedesc[R], cls: typedesc[T], - _: varargs[untyped]): typedesc[T] = - ## py's `object.__new__` - cls - -proc init_subclass*[T: ref](cls: typedesc[T]) = - ## py's `object.__init_subclass__` - discard - -proc recReplaceSuperCall*(n: NimNode, defSupCls: NimNode, start=0, methKind=mkNorm): NimNode = - ##[ Recursively maps - -### 1. - -`super(...).f(...)` - to `procCall((self).f(...))` - -The AST map: -``` - Call - DotExpr - Call - Ident "super" - [] - [Ident "self"] - Ident "f" - - - | - | - v - - Command - Ident "procCall" - Call - DotExpr - Call - - Ident "self" - Ident "f" - -``` - -### 2 -`super(...).new/init_subclass(...)` - to `.new/init_subclass(...)` -]## - runnableExamples: - import std/[macros, strutils] - macro checkSupSub(resStr: static string; b) = - let res = recReplaceSuperCall(b, ident"SupCls") - assert resStr == repr(res).strip(), repr(res) - result = newStmtList() - checkSupSub("procCall(SupCls(self).f())"): - super().f() - checkSupSub("procCall(SS(self).f(a, b))"): - super(SS, self).f(a, b) - checkSupSub("a = procCall(SupCls(self).f(a, b))"): - a = super().f(a, b) - checkSupSub("a = procCall(SupCls(self).f(procCall(SupCls(self).m()), b))"): - a = super().f(super().m(), b) - checkSupSub("echo(1)"): echo(1) - - # NOTE: the following is not supported, so left unchanged - checkSupSub("super()"): super() - checkSupSub("super().a"): super().a - - result = n.copy() - var i = start - while i def f(_`gensym: typedesc[Cls],...) - - @classmethod - def f(cls...) -> def f(cls: typedesc[Cls]...) - ]# - template withType(procTyp) = - procType = procTyp - if mparser.decorators.len == 0: - withType(nnkMethodDef) - return false - - template curClass: NimNode = - if mparser.classes.len == 0: - error "TypeError: invalid context. not in class", decor.name - mparser.classes[^1] - - let decor = mparser.decorators.pop() - template retFalse(procType=nnkMethodDef) = - withType(procType) - mparser.decorators.add decor # add back - return false - template purgeBase = - if mparser.decorators.len != 0: - # NIM-BUG: - #[ -```Nim -type - O = object - Func = proc (t: typedesc[O]): int - -func as_is(f: Func): Func = return f - -let f = block: - proc f(t: typedesc[O]): int = return 3 - as_is(f) -``` -will error as below. - -if change `as_is(f)` in `let f = block:...` to `f`, -then you will find it compile but `O.f()` gives `0` instead of `3` -]# - warning "There may be a error like: " & - "`Error: cannot instantiate: '_`gensymXXX:type'`" - pragmas.rmBase - template clsType: NimNode = - typedescOf(curClass()) - - if decor.name.len != 0: - return false - case $decor.name - of "staticmethod": - methKind = mkStatic - purgeBase() - args.insert(newIdentDefs(ident"_", clsType), 1) - of "classmethod": - methKind = mkCls - purgeBase() - args[1][1] = clsType - else: - retFalse() - withType(nnkProcDef) - return true - -template mkPragma(pragmas: openArray[NimNode]): NimNode = - if pragmas.len == 0: emptyn - else: nnkPragma.newNimNode.add pragmas - -proc newMethAsProc(name, generics: NimNode, params: openArray[NimNode], body: NimNode, procType = nnkProcDef, pragmas: openArray[NimNode]): NimNode = - let procType = (if procType == nnkMethodDef: nnkProcDef else: procType) - var pragmas = @pragmas - pragmas.rmBase - newProc(name, generics, params, body, procType, pragmas.mkPragma) - -proc mkExport(n: NimNode): NimNode = n.postfix"*" - -proc newMethProc(topLevel: bool, name, generics: NimNode, params: openArray[NimNode], body: NimNode, procType = nnkProcDef, pragmas: openArray[NimNode]): NimNode = - if topLevel: - var pragmas = @pragmas - pragmas.rmBase - result = newProc(name.mkExport, generics, params, body, procType, pragmas.mkPragma) - else: - result = newMethAsProc(name, generics, params, body, procType, pragmas) - result.addPragma ident"used" - -proc newProc(topLevel: bool, name, generics: NimNode, params: openArray[NimNode], body: NimNode, procType = nnkProcDef, pragmas: openArray[NimNode]=[]): NimNode = - if topLevel: - result = newProc(name.mkExport, generics, params, body, procType, pragmas.mkPragma) - else: - result = newProc(name, generics, params, body, procType, pragmas.mkPragma) - result.addPragma ident"used" - -proc genNewCls(topLevel: bool, classNewProcName, classId, generics: NimNode, initArgs, initPragmas: openArray[NimNode]): NimNode = - ## returns decl of proc - var newArgs = @[classId] - var body = newStmtList() - let resId = ident"result" - var callNew = newCall(newDotExpr(classId, ident"new"), newCall("typeof", classId)) - let defInit = initArgs.len > 0 - var callInit: NimNode - if defInit: - #var init = newCall(ident"init", resId) - callInit = newCall(resId.newDotExpr(ident"init")) - for i in 2.. 1: - error "multi-inhert is not allowed in Nim, " & - "i.e. only one super class is expected, got " & $supLen - elif supLen == 1: - # class O(SupCls) - supCls = supClses[0] - if not supCls.eqIdent"RootObj": # not `class O(object)` - if not topLevel: - error "non-topLevel class cannot inherit currently " & - "(as Nim's method must be top-level)", obj[1] - defPragmas.rmBase - of nnkBracketExpr: - parseGenerics obj - else: - error "unexpected class syntax, got: ", obj - let supClsNode = nnkOfInherit.newTree supCls - - let className = $classId - var - genericsClassId = classId - concreteGenericsClassId = classId - if generics.len != 0: - genericsClassId = nnkBracketExpr.newTree(classId) - concreteGenericsClassId = nnkBracketExpr.newTree(classId) - - for i in generics.items(): - # i.kind == nnkIdentDef - genericsClassId.add i[0] - concreteGenericsClassId.add( - if i[2].kind != nnkEmpty: i[2] - elif i[1].kind != nnkEmpty: i[1] - else: bindSym"char" # any is okey. - ) - initSubClassArgs[0] = newCall(bindSym"typeof", concreteGenericsClassId) - template exportIfTop(n: NimNode): NimNode = - if topLevel: n.mkExport - else: - nnkPragmaExpr.newTree(n, nnkPragma.newTree ident"used") - result = newStmtList() - parser.classes.add classId - let dunderDirId = ident className & ".dunder.dict.keys()" # `classId.__dict__.keys()` - var dunderDirVal = newNimNode(nnkBracket) - var typDefLs = nnkRecList.newTree() - template addAttr(name; typ=emptyn, defVal=emptyn) = - #bind typDefLs # XXX: NIM-BUG: as of Nim-2.3.1, adding this line causes Nim compiler think `typDefLs: void` - typDefLs.add newIdentDefs(name, typ, defVal) - var defs = newStmtList() - var decls = newStmtList() - template addMeth(def: NimNode) = defs.add def - template addMethWithDecl(def: NimNode) = - defs.add def - var decl = def.copyNimNode - let lastI = def.len - 1 - for i in 0.. 1 and args[1][0].eqIdent "self": - markSelfType - if args[0].eqIdent"None": - args[0] = getNoneTypeNode() - pragmas.add ident"discardable" - # Function body - var docNode: NimNode - var parsedbody = recReplaceSuperCall( - parser.parsePyBodyWithDoc(def[2], docNode), supCls, - methKind=methKind) - if docNode.len != 0: - body.insert(0, docNode) - # Add statement which will occur before function body - body.add parsedBody - parser.pop() - - # Finally create a procedure and add it to result! - var procType: NimNodeKind - discard parser.tryPreClsBltinDecorater( - args, procType, pragmas=pragmas, methKind=methKind - ) - if methKind != mkNorm: - procType = nnkProcDef - elif isConstructor: - initPragmas = pragmas - initGenerics = generics_cpy - let nDef = parser.consumeDecorator( - newProc(topLevel, procName, generics_cpy, args, body, - procType, pragmas=pragmas) - ) - if args[0].eqIdent"auto": - # return type 'auto' cannot be used in forward declarations - addMeth nDef - else: - addMethWithDecl nDef - - of nnkStrLit, nnkRStrLit, nnkTripleStrLit: - result.add newCommentStmtNode $def - of nnkPrefix, nnkDotExpr: - if not parser.tryHandleDecorator def: - result.add def - else: - result.add def # AS-IS - - addMethWithDecl genNewCls(topLevel, ident("new" & classId.strVal), classId, initGenerics, initArgs, initPragmas) - - let ty = nnkRefTy.newTree nnkObjectTy.newTree(emptyn, supClsNode, typDefLs) - let typDef = nnkTypeSection.newTree nnkTypeDef.newTree(classId.exportIfTop, generics, ty) - result.add: - nnkWhenStmt.newTree( - nnkElifBranch.newTree( - prefix(newCall("declaredInScope", classId), "not"), - newStmtList typDef - ) - ) - - # result.add quote do: - # when not declaredInScope `classId`: - # `typDef` - - result.add decls - result.add defs - - result.add newConstStmt( - dunderDirId.exportIfTop, dunderDirVal - ) - result.add newProc(topLevel, - ident("dir"), emptyn, - [bracketExpr(getPyList(), getPyStr()), - newIdentDefs(ident"_", typedescOf(classId))], - newCall( #bracketExpr(getlist(), getPyStr()) - getnewPyListOfStr() - , dunderDirId) - ) - let initSub = newCall("init_subclass").add initSubClassArgs - result.add initSub - - discard parser.classes.pop() - # Echo generated code - # echo result.toStrLit diff --git a/src/pylib/pysugar/stmt/decl.nim b/src/pylib/pysugar/stmt/decl.nim deleted file mode 100644 index ae6016e3e..000000000 --- a/src/pylib/pysugar/stmt/decl.nim +++ /dev/null @@ -1,126 +0,0 @@ -## `Literal[a, b]` cannot be implemented in Nim's type system (i.e. via `type Literal[...`) - -import std/macros -import std/typetraits -import ../../Lib/typing_impl/easyImpl as typing - -template emptyn: NimNode = newEmptyNode() -proc parseDeclWithType*(def: NimNode): tuple[name, typ, val: NimNode] = - ## a: int -> a int - ## a: int = 1 -> a int 1 - expectLen def, 2 - let - name = def[0] - rhs = def[1] - expectKind rhs, nnkStmtList - expectLen rhs, 1 - let inner = rhs[0] - let (typ, defVal) = if inner.kind == nnkAsgn: # a: int = 1 - (inner[0], inner[1]) - else: # a: int - (inner, emptyn) - result.name = name - result.typ = typ - result.val = defVal - -# we wanna type in st of `tonimDecl` to be resolved(typed) while others are untyped, -# so `tonimDecl` generates a call to `rewriteDecl` - -proc isX(x: typedesc, typ: NimNode): bool = - bindSym($x) == typ - -proc isLiteral(typId: NimNode): bool = isX(Literal, typId) -proc isFinal(typId: NimNode): bool = isX(Final, typId) - -proc ensureType(typId: NimNode): NimNode = - if typId.kind in {nnkIdent, nnkSym, nnkClosedSymChoice} and typId.repr in ["int", "float"]: - newDotExpr(ident"system", typId) - elif typId.kind == nnkBracketExpr and "Literal" == ( - if typId[0].kind == nnkDotExpr: typId[0][1] # .Literal - else: typId[0] - ).strVal: - typId[0] - else: - typId - -proc newDecl(k: NimNodeKind, variable, typ, val: NimNode, defKind=nnkIdentDefs): NimNode = - k.newTree(defKind.newTree(variable, typ, val)) - -proc newConstStmtWithType(name, typ, val: NimNode): NimNode = - nnkConstSection.newDecl(name, typ, val, nnkConstDef) - -proc isBracketExpr(typId: NimNode): bool = - typId.kind == nnkBracketExpr - -type DoXxx* = untyped ## Callable in form of `proc (name, typ, val: NimNode): NimNode` - -template rewriteDeclImpl(variable, oriTyp, val, t: NimNode - ,doLiteral - ,doFinal - ,doElse: DoXxx): NimNode {.dirty.}#[to make `quote do` work]# = - bind isBracketExpr, ensureType, emptyn, isX, isLiteral, isFinal, - quote, newTree, nnkStaticExpr, nnkCommand, newConstStmt - let tBracket = isBracketExpr t - let (headT, baseType) = if tBracket: - (t[0], ensureType oriTyp[1]) - else: - (t, ensureType t) - if isLiteral(headT): - let nVal = - if isBracketExpr oriTyp: - # generate `static: assert a == 1 or a == 2` for `Literal[1, 2]` - var chk = infix(variable, "==", oriTyp[1]) - for i in 2..` - var dec: Decorator - case item.kind - of nnkIdent, nnkDotExpr: - dec = Decorator(name: item, called: false) - of nnkCall: - dec = Decorator(name: item[0], called: true, args: item[1..^1]) - else: - error "bad decorator", item - mparser.decorators.add dec - -proc tryHandleDecorator*(mparser; statement: NimNode): bool = - if statement[0].eqIdent "@": - # TODO: enter a state that enforce the following stmt is decorator and - # exit when a function definition is met. - # Currently, something like this is still valid: - # @a print(1) - # print(1) -> @a - # def f(): pass def f(): pass - let item = statement[1] - mparser.pushDecorator item - return true - elif statement.kind == nnkDotExpr: - #[ @module.decorator -> -DotExpr - Prefix - Ident "@" - Ident "module" - Ident "decorator"]# - let pre = statement[0] - if pre.kind == nnkPrefix and pre[0].eqIdent "@": - mparser.pushDecorator newDotExpr(pre[1], statement[1]) - return true - -proc unpackCall(callee: NimNode, arg: seq[NimNode]): NimNode = - result = newCall callee - for i in arg: - result.add i - -proc genByDecor(mparser; d: Decorator, callee: NimNode, - originalProcDef: NimNode): NimNode = - if d.called: - let callDec = unpackCall(d.name, d.args) - result = newCall(callDec, callee) - else: - result = newCall(d.name, callee) - -proc consumeDecorator*(mparser; procDef: NimNode): NimNode = - ## gen: - ## ```Nim - ## block: - ## `procDef` - ## decorator(... (`procDef`)) - ## ``` - if mparser.decorators.len == 0: - return procDef - var blkExpr = newStmtList() - blkExpr.add procDef - let procName = procDef.name - var call = procName - while mparser.decorators.len != 0: - let decor = mparser.decorators.pop() - call = mparser.genByDecor(decor, call, procDef) - blkExpr.add call - let blk = newBlockStmt blkExpr - result = newLetStmt(procName, blk) - -proc extractDottedCalledDecorator*(decorator: NimNode): NimNode = - ## Extract dotted call from `decorator`. - ## e.g. `@a.b.c(1, 2)` -> `a.b.c(1, 2)` - ## - ## .. note:: Currently `decorator` is to be modified in place, while result is still returned - expectKind decorator, nnkCall - expectMinLen decorator, 2 - result = decorator - var cur = decorator - while cur[0].kind != nnkPrefix: - cur = cur[0] - assert cur[0][0].eqIdent "@" - cur[0] = cur[0][1] diff --git a/src/pylib/pysugar/stmt/exprRewrite.nim b/src/pylib/pysugar/stmt/exprRewrite.nim deleted file mode 100644 index d92d33bde..000000000 --- a/src/pylib/pysugar/stmt/exprRewrite.nim +++ /dev/null @@ -1,263 +0,0 @@ - -import std/macros -import std/macrocache -from std/strutils import toLowerAscii, normalize -import ../../pystring/[strimpl, strprefix] -import ../../builtins/[list_decl, set, dict, pyslice] -import ./frame, ./chainCmp - -const CollectionSyms = CacheSeq"CollectionSyms" -static: - CollectionSyms.add bindSym"list" - CollectionSyms.add bindSym"pyset" - CollectionSyms.add bindSym"toPyDict" - CollectionSyms.add bindSym"slice" - -using e: NimNode -using mparser: var PyAsgnRewriter -proc toPyExpr*(mparser; atm: NimNode): NimNode - -template newSlice(a, b: NimNode): NimNode = - newCall(CollectionSyms[3], a, b) - -proc colonToSlice(mparser; colonExpr: NimNode): NimNode = - ## a:b -> slice(a,b) - newSlice(mparser.toPyExpr colonExpr[0], mparser.toPyExpr colonExpr[1]) - -proc rewriteSliceInBracket(mparser; bracketExpr: NimNode): NimNode = - result = bracketExpr.copyNimNode - result.add mparser.toPyExpr bracketExpr[0] - for i in 1.. x == -1 - ## x=-1 -> x = -1 - - let lhs = mparser.toPyExpr e[1] - template rhs: NimNode = newCall("-", mparser.toPyExpr e[2]) - template ret(n: NimNode) = - res = n - return true - if e[0].eqIdent"=-": - ret k.newTree(lhs, rhs) - elif e[0].eqIdent"==-": - ret newCall("==", lhs, rhs) - - -proc rewriteInfix(mparser; e; k=nnkAsgn): NimNode = - if mparser.tryRewriteEqualMinus(e, result, k=k): - return - result = expandChainImpl(e) - -proc callToPyExpr*(mparser; e): NimNode - -template toPyExprImpl(mparser; atm: NimNode; toListCb; equalMinusAs=nnkAsgn): NimNode = - case atm.kind - of nnkExprEqExpr: - nnkExprEqExpr.newTree(atm[0], mparser.toPyExpr atm[1]) - of nnkBracketExpr: - mparser.rewriteSliceInBracket atm - of nnkCommand: - mparser.rewriteStrLitCat atm - of nnkCall: - mparser.callToPyExpr atm - of nnkPrefix: - nnkPrefix.newTree atm[0], mparser.toPyExpr atm[1] - of nnkPar: - nnkPar.newTree mparser.toPyExpr atm[0] - of nnkInfix: - mparser.rewriteInfix atm, equalMinusAs - - of nnkTripleStrLit, - nnkStrLit, nnkRStrLit: - atm.toStr - #of nnkCallStrLit: - # NOTE: f"xxx" does perform `translateEscape` - # so we don't perform translation here - - of nnkBracket: mparser.toListCb atm - of nnkCurly: mparser.toSet atm - of nnkTableConstr:mparser.toDict atm - of nnkTupleConstr:mparser.toTuple atm - else: - atm - -proc toPyExpr*(mparser; atm: NimNode): NimNode = mparser.toPyExprImpl atm, toList -proc toPyExprNoList*(mparser; atm: NimNode): NimNode = mparser.toPyExprImpl atm, rewriteEachEle - -proc argInCallToPyExpr(mparser; atm: NimNode): NimNode = - ## f(x=-1) needs to be rewritten as Call(ExprEqExpr(Ident"x", -1)) - mparser.toPyExprImpl atm, toList, nnkExprEqExpr - -proc preNew(n: NimNode): NimNode = - ident("new" & n.strVal) - -proc callToPyExpr*(mparser; e): NimNode = - ## In addition, it will rewrite `cls(xxx)` to `newCls(xxx)` - let callee = e[0] - template addArg(addArgCb) = - for i in 1..") - name_params = signature[1] - restype = signature[2] - - -func addGenericParam(generics: var NimNode, it: NimNode) = - var typ: NimNode - case it.kind - of nnkIdent: typ = newIdentDefs(it, emptyn, emptyn) - of nnkExprColonExpr: typ = newIdentDefs(it[0], it[1], emptyn) - of nnkExprEqExpr: typ = newIdentDefs(it[0], emptyn, it[1]) - else: - error "The generics format like `T` or `T: int` or `T = int` are supported, " & - " things like `T: int = int` cannot be parsed by Nim", it - generics.add typ - -func newGenericsTree*: NimNode = newNimNode nnkGenericParams - -func parseGenericParams*(generics: var NimNode, params: NimNode): NimNode = - if generics.len == 0: - generics = newGenericsTree() - result = params[0] - for i in 1..int), then def_restype is ignored -proc asyncImpl*(defsign, body: NimNode, parser: var PySyntaxProcesser; - procType=nnkProcDef): NimNode - -proc parseSignatureMayGenerics*(parser: var PySyntaxProcesser; - generics: var NimNode; signature: NimNode, - deftype = ident"untyped", - ): tuple[name: NimNode, params: seq[NimNode]] = - if parser.supportGenerics: - parseSignature(generics, signature, deftype=deftype) - else: - generics = emptyn - parseSignatureNoGenerics(signature, deftype=deftype) - - -proc defAux*(signature, body: NimNode, - deftype = ident"untyped", - parser: var PySyntaxProcesser; - procType = nnkTemplateDef, pragmas = emptyn): NimNode = - var generics: NimNode - let tup = parser.parseSignatureMayGenerics(generics, signature, deftype=deftype) - let nbody = parser.parsePyBodyWithDoc body - result = newProc(tup, generics, nbody, procType, pragmas) - -proc defImpl(signature, body: NimNode, parser: var PySyntaxProcesser; pragmas = emptyn, deftype = ident"auto", procType=nnkProcDef): NimNode = - defAux(signature, body, parser=parser, deftype=deftype, procType=procType, pragmas=pragmas) - -proc asyncImpl(defsign, body: NimNode; parser: var PySyntaxProcesser; - procType=nnkProcDef): NimNode = - let - pre = defsign[0] - signature = defsign[1] - expectIdent(pre,"def") - let - apragma = newNimNode(nnkPragma).add(bindSym"async") - restype = newNimNode(nnkBracketExpr).add(bindSym"Future", ident"void") - defImpl(signature, body, parser=parser, pragmas=apragma, deftype=restype, procType=procType) diff --git a/src/pylib/pysugar/stmt/pyraise.nim b/src/pylib/pysugar/stmt/pyraise.nim deleted file mode 100644 index 4eea19292..000000000 --- a/src/pylib/pysugar/stmt/pyraise.nim +++ /dev/null @@ -1,94 +0,0 @@ -## Implement NOTE: We cannot define a macro or function called `raise`, -## as in Nim, `raise`, a keyword, will be parsed as part of `nnkRaiseStmt`. - -import std/macros - -proc add_parent(e: ref Exception; e2: ref Exception): ref Exception = - result = e - result.parent = e2 - -func identFrom(pre: string, typ: NimNode): NimNode = - if typ.kind == nnkDotExpr: - newDotExpr(typ[0], ident(pre & typ[1].strVal)) - else: - ident(pre & typ.strVal) - -func rewriteRaiseImpl(res: var NimNode, raiseCont: NimNode, parent=newNilLit()): bool = - var msg = newLit "" - res = newNimNode nnkWhenStmt - template callIfValid(chkDest, dest) = - res.add nnkElifExpr.newTree( - newCall("compiles", chkDest), - dest - ) - template callAddParent(ori) = - callIfValid(ori, - newCall(bindSym"add_parent", ori, parent) - ) - template rewriteWith(err: NimNode){.dirty.} = - callAddParent( - newCall(identFrom("newPy", err), msg)) - callAddParent( - newCall(identFrom("new", err), msg)) - let nExc = newCall("newException", err, msg, parent) - callIfValid(nExc, nExc) - res.add( - # User may define some routinues that are used in `raise`, - nnkElseExpr.newTree( - raiseCont - ) - ) - #[ - when ... - elif compiles(`nExc`): - `nExc` - else: - `raiseCont` - ]# - return true - - case raiseCont.kind - of nnkCall: - # raise ErrType([...]) - let err = raiseCont[0] - let contLen = raiseCont.len - if contLen > 2: - # cannot be python-like `raise` - res = raiseCont - return true - if contLen == 2: - # raise ErrType(msg) - msg = raiseCont[1] - rewriteWith err - of nnkIdent: # raise XxError - let err = raiseCont - rewriteWith err # in case `raise ` - else: - res = raiseCont - return - -proc rewriteRaise*(rStmt: NimNode): NimNode = - ## - Rewrites `raise ErrType/ErrType()/ErrType(msg)` - ## to `raise newException(ErrType, msg/"")` - ## - Rewrites `raise XxError[(...)]` to `raise new[Py]XxError(...)` - ## - Rewrites `raise XxError[(...)] from P` to `raise new[Py]OSError(...).add_parent(P)` - ## - ## assume `rStmt` is nnkRaiseStmt - var res: NimNode - block rewriteRaise: - let raiseCont = rStmt[0] - let succ = rewriteRaiseImpl(res, raiseCont) - if succ: break rewriteRaise - elif raiseCont.kind == nnkInfix and raiseCont[0].eqIdent"from": - # raise xxx from yyy - var parent = newNilLit() - let _ = rewriteRaiseImpl(parent, raiseCont[2]) - let _ = rewriteRaiseImpl(res, raiseCont[1], parent) - else: - #of nnkEmpty: # leave `raise` as-is - #error "only call/ident shall be passed here", raiseCont - result = rStmt - return - result = nnkRaiseStmt.newTree(res) - - diff --git a/src/pylib/pysugar/stmt/tonim.nim b/src/pylib/pysugar/stmt/tonim.nim deleted file mode 100644 index 15d892b6c..000000000 --- a/src/pylib/pysugar/stmt/tonim.nim +++ /dev/null @@ -1,253 +0,0 @@ - -## -## ## Limits -## ### global/nonlocal for nonexisting variable -## In Python using global/nonlocal to declare a new variable is allowed, -## but here it may be impossible to implement, as Nim is statically-typed, -## we must know its type when declaring a variable, -## while getting a type from AST -## whose type is `untyped`_ -## is almostly impossible. -## -## ### global/nonlocal only means `not local`, with some limited checks -## - Currently using `global name` -## where name is declared in *previous* frames is not supported -## - Currently using `nonlocal name` -## where name is used for globals is not supported - -# TODO: implement Python's nonblock scope -# -# that's: -# ```Python -# if True: a=1 -# print(a) -# ``` - -import std/macros -import ./pyraise, ./frame, ./pydef, ./unpack, ./decorator, ./exprRewrite, ./decl -import ./class -import ../../private/inspect_cleandoc - -using mparser: var PyAsgnRewriter -proc parsePyBody*(mparser; body: NimNode): NimNode # front decl -proc parsePyBodyWithDoc*(mparser; body: NimNode): NimNode # front decl -proc parsePyBodyWithDoc*(mparser; body: NimNode, docNode: var NimNode): NimNode # front decl - -proc tryHandleDocStr(res: var NimNode; n: NimNode, dedent=false): bool = - if n.kind in nnkStrLit..nnkTripleStrLit: - let s = $n - res.add newCommentStmtNode( - if dedent: `inspect.cleandoc` s - else: s - ) - return true - -proc parsePyExpr*(mparser; exp: NimNode): NimNode = - bind toPyExpr - toPyExpr(mparser, exp) - -template parseBodyOnlyLast(ele): NimNode = - ## parse body only for last but apply `toPyExpr`_ for remaining - var subStmt = newNimNode ele.kind - let last = ele.len - 1 - for i in 0.. except exc, ... as Nim disallows the former. - let excs = first - if excBranch.len != 2: - errNotParenExcs excs - excBranch = newExceptBranch(excs, nExcBranchStmts) - nStmt.add excBranch - elif first.kind == nnkInfix and first[0].eqIdent"as": - if first[1].kind != nnkTupleConstr: - errNotParenExcs first[2] - - let exc = first[2] - var nBody = newStmtList(newLetStmt(exc, newCall(bindSym"getCurrentException"))) - for i in nExcBranchStmts: nBody.add i - - var nExcBranch = newExceptBranch(first[1], nBody) - nStmt.add nExcBranch - else: - excBranch[^1] = nExcBranchStmts - nStmt.add excBranch - result.add nStmt - of nnkInfix: - result.add statement - of nnkCall: - if statement[^1].kind == nnkStmtList: - if statement.len == 2 and statement[0].kind == nnkIdent and statement[1].len == 1: - # a: int|a: int = 1 - let tup = parseDeclWithType(statement) - result.add rewriteDeclInStmtAux(tup.name, tup.typ, mparser.parsePyExpr tup.val) - else: - result.add parseBodyOnlyLast statement - else: - result.add mparser.callToPyExpr statement - of nnkForStmt, nnkWhileStmt: - result.add parseBodyOnlyLast statement - elif statement.len == 0: - result.add mparser.parsePyExpr statement - else: - # XXX: maybe no use - var nStmt = newNimNode statement.kind - - for e in statement: - case e.kind - # no need to specify `nnkWhileStmt`, - # as it's handled by branch of `of nnkStmtList` and `else` - of nnkStmtList: - nStmt.add mparser.parsePyBody e - of nnkOfBranch, nnkElifBranch, nnkElse, nnkForStmt: - result.add parseBodyOnlyLast e - else: nStmt.add mparser.parsePyExpr e - result.add nStmt - - -proc parsePyBody*(mparser; body: NimNode): NimNode = - result = newStmtList() - for ele in body: - result.add mparser.parsePyStmt ele - -proc parsePyBodyWithDoc*(mparser; body: NimNode): NimNode = - result = newStmtList() - let start = - if result.tryHandleDocStr(body[0], mparser.dedentDoc): 1 - else: 0 - for i in start...add('')` in generated code - # TODO: rewrite to add via substr - template addNode(res: NimNode, expAdd: NimNode, format_spec: NimNode) = - result.add when defined(pylibUseFormatValue): - newCall(formatCallIdent, res, - expAdd, - format_spec - ) - else: - let strAdd = newCall(formatAltCallIdent, expAdd, format_spec) - newCall("add", res, strAdd) - - let res = genSym(nskVar, "formatRes") - result = newStmtList() - result.add newVarStmt(res, newCall(bindSym"newStringOfCap", - newLit(s.len))) - template parseSpec: string = - var format_spec = "" - if s[curIdx] == SpecSep: - curIdx.inc s.parseUntil(format_spec, EndCh, curIdx) - format_spec - - template pushIdent(identS: string) = - let fspec = parseSpec() - res.addNode kw[ ident(identS) ], newLit fspec - template pushIdx(idx: int) = - let fspec = parseSpec() - res.addNode args[idx], newLit fspec - - template add(_: NimNode, cs: char|string) = - result.add newCall(bindSym"add", res, newLit(cs)) - # minic that `result` is a string - var curIdx = 0 - var - varIdx = -1 - varAutoIdx = 0 - varIdent: string - let slen = s.len - while curIdx < slen: - let c = s[curIdx] - if c == BegCh: - curIdx.inc - case s[curIdx] - of BegCh: - result.add BegCh - curIdx.inc - continue - of '0'..'9': - let nDigits = parseInt(s, varIdx, curIdx) - if nDigits == 0: - raiseFormatError(s, curIdx, "int index expected") - curIdx.inc nDigits - pushIdx varIdx - varIdx = -1 - else: - let nAlpha = parseIdent(s, varIdent, curIdx) - if nAlpha != 0: - curIdx.inc nAlpha - pushIdent varIdent - else: - case s[curIdx] - of {SpecSep, EndCh}: - pushIdx varAutoIdx - varAutoIdx.inc - else: - raiseFormatError(s, curIdx) - - expectCh s, curIdx, EndCh - curIdx.inc - - elif c == EndCh: - result.add c - curIdx.inc - expectCh(s, curIdx, EndCh) - curIdx.inc - else: - result.add c - curIdx.inc - result.add res - result = newBlockStmt result - -macro pyformat*(s: static[string], argKw: varargs[untyped]): string = - let - leArgKw = argKw.len - leKw = leArgKw div 3 - leArg = leArgKw - leKw - var - args = newSeqOfCap[NimNode] leArg - kw = newKw leKw - - for i in argKw: - case i.kind - of nnkExprEqExpr: - kw[i[0]] = i[1] - of nnkIdent: - args.add i - else: - # maybe some checks here? - args.add i - - result = s.pyformatImplAux(args, kw) - - -when isMainModule: - template check(b) = - static: - assert b - check "ad 3 e" == "ad {} e".pyformat("3") - check "ad 3 e 3" == "ad {0} e {0}".pyformat(3) - check "ad 3 e 5 3" == "ad {0} e {a} {0}".pyformat(3, a=5) - check "5,a" == "{},{}".pyformat(3+2,'a') - let aa = 'c' - assert "5,c" == "{},{}".pyformat(3+2, aa) diff --git a/src/pylib/stringlib/formats.nim b/src/pylib/stringlib/formats.nim deleted file mode 100644 index 4c2063986..000000000 --- a/src/pylib/stringlib/formats.nim +++ /dev/null @@ -1,12 +0,0 @@ -# import and exported via ./format -import std/strformat - -template format*[T](value: T, format_spec: string = ""): string = - ## wrapper of std/strformat `formatValue` - bind formatValue - var result: string - formatValue(result, value, format_spec) - result - -func format*(value: char, format_spec: string = ""): string = - format($value, format_spec) diff --git a/src/pylib/stringlib/meth.nim b/src/pylib/stringlib/meth.nim deleted file mode 100644 index 126df3d86..000000000 --- a/src/pylib/stringlib/meth.nim +++ /dev/null @@ -1,345 +0,0 @@ - -import std/strutils except strip, split, rsplit - -import ./replaceWithCount -import ./errHandle -import ../pyerrors/simperr - - -template norm_idx(i, s): int = - if i < 0: len(s) + i - else: i - -func count*[S](a: S, sub: S): int = - if sub.len == 0: return a.len + 1 - count($a, $sub) - -func count*[S](a: S, sub: S, start: int): int = - let subA = substr($a, start.norm_idx(a)) - if sub.len == 0: return subA.len + 1 - count($a, $sub) - -func count*[S](a: S, sub: S, start=0, `end`: int): int = - count(substr($a, start.norm_idx(a), `end`.norm_idx(a) - 1), $sub) - - -template seWith(seWith){.dirty.} = - template sewith*[S](a: S, suffix: char): bool = - seWith($a, suffix) - template sewith*[S](a: char, suffix: S): bool = - suffix.len == 1 and a == suffix[0] - func sewith*[S; Tup: tuple](a: S, suffix: Tup): bool = - let s = $a - for _, suf in suffix.fieldPairs: - if s.sewith suf: - return true - func sewith*[S; Suf: S | tuple](a: S, suffix: Suf, start: int): bool = - let s = $a - substr(s, start.norm_idx(a)).sewith(suffix) - func sewith*[S; Suf: S | tuple](a: S, suffix: Suf, - start, `end`: int): bool = - substr($a, start.norm_idx(a), `end`.norm_idx(a) - 1).sewith(suffix) - -seWith startsWith -seWith endsWith - - -func find1*[S; T](a: S, b: T, start = 0): int = - ## `b` shall be one length long. - var i = start.norm_idx(a) - for s in a: - if s == b: return i - i.inc - return -1 - -func find1*[S; T](a: S, b: T, start = 0, `end`: int): int = - ## `b` shall be one length long. - var i = start.norm_idx(a) - let last = `end`.norm_idx(a) - 1 - for s in a: - if i == last: break - if s == b: return i - i.inc - return -1 - -func rfind1*[S; T](a: S, b: T, start = 0, `end`: int): int = - for i in countdown(`end`.norm_idx(a) - 1, start.norm_idx(a)): - if a[i] == b: return i - return -1 -func rfind1*[S; T](a: S, b: T, start = 0): int = - rfind1(a, b, start, len(a)) - -template gen_find(find){.dirty.} = - func find*[S; T](a: S, b: T, start = 0): int = - let i = start.norm_idx(a) - strutils.find($a, $b, i) - func find*[S; T](a: S, b: T, start = 0, `end`: int): int = - let i = start.norm_idx(a) - let last = `end`.norm_idx(a) - 1 - strutils.find($a, $b, i, last) - -gen_find find -gen_find rfind - -func rNoIdx{.inline.} = - raise newException(ValueError, "substring not found") - -func index1*[S; T](a: S, b: T, start = 0, `end`: int): int = - result = a.find1(b, start, `end`) - if result == -1: rNoIdx() -func index1*[S; T](a: S, b: T, start = 0): int = - index1 a, b, start, len(a) -func index*[S; T](a: S, b: T, start = 0, `end`: int): int = - result = a.find(b, start, `end`) - if result == -1: rNoIdx() -func index*[S; T](a: S, b: T, start = 0): int = - index a, b, start, len(a) - -func rindex1*[S; T](a: S, b: T, start = 0, `end`: int): int = - result = a.rfind1(b, start, `end`) - if result == -1: rNoIdx() -func rindex1*[S; T](a: S, b: T, start = 0): int = - rindex1 a, b, start, len(a) - -func rindex*[S; T](a: S, b: T, start = 0, `end`: int): int = - result = a.rfind(b, start, `end`) - if result == -1: rNoIdx() -func rindex*[S; T](a: S, b: T, start = 0): int = - rindex a, b, start, len(a) - - -const AsciiOrdRange = 0..0x7F - -func isascii*(c: char): bool = ord(c) in AsciiOrdRange -func isascii*(s: string): bool = - result = true - if s.len == 0: return - for c in s: - if not c.isascii(): return false - -template isspaceImpl(c: char): bool = c in Whitespace -template isdigitImpl(c: char): bool = strutils.isDigit(c) # just alias - -template all(a: string, isX){.dirty.} = - if a.len == 0: return - result = true - for c in a: - if not c.isX(): - return false - -template wrap2(isX, wrap){.dirty.} = - func isX*(c: char): bool = c.wrap - func isX*(s: string): bool = all(s, wrap) - -wrap2 isalpha, isAlphaAscii -wrap2 isspace, isspaceImpl -wrap2 isdigit, isdigitImpl -wrap2 isalnum, isAlphaNumeric - -template allAlpha*(a, isWhat, isNotWhat: typed, iter, firstItemGetter) = - ## used as func body. - ## e.g. - ## func isupper(self: PyBytes): bool = - ## self.allAlpha(isUpperAscii, isLowerAscii, items, `[0]`) - let le = len(a) - if le == 1: return isWhat(a.firstItemGetter) - if le == 0: return false - var notRes = true - for r in a.iter: - if r.isNotWhat: - return false - elif notRes and r.isWhat: - notRes = false - result = not notRes - -template istitleImpl*(a, isupper, islower: typed, iter, firstItemGetter) = - let le = len(a) - if le == 1: - let c = a.firstItemGetter - if c.isupper: return true - return false - if le == 0: return false - - var cased, previous_cased: bool - - for ch in a.iter: - if ch.isupper: - if previous_cased: - return false - previous_cased = true - cased = true - elif ch.islower: - if not previous_cased: - return false - previous_cased = true - cased = true - else: - previous_cased = false - result = cased - -template retIfWider[S](a: S) = - if len(a) >= width: - return a - -template `*`(c: char, i: int): string = - bind repeat - c.repeat i - -template centerImpl(a, width, fillchar) = - let - hWidth = (width-len(a)) div 2 - half = fillchar * hWidth - result = half + a + half - -func center*[S](a: S, width: int, fillchar = ' '): S = - ## Mimics Python str.center(width: int, fillchar: str=" ") -> str - retIfWider a - centerImpl a, width, fillchar - -func ljust*(a: string, width: int, fillchar = ' ' ): string = - alignLeft $a, width, fillchar -func rjust*(a: string, width: int, fillchar = ' ' ): string = - align $a, width, fillchar - -template chkLen(a): int = - ## 1. returns if wider; 2. raises if not 1 len; 3. length as result - retIfWider a - let le = len(fillchar) - if le != 1: - raise newException(TypeError, - "The fill character must be exactly one character long") - le - -func center*[S](a: S, width: int, fillchar: S = " "): S = - discard chkLen a - centerImpl(a, width, fillchar) - -func ljust*[S](a: S, width: int, fillchar: S = " "): S = - let le = chkLen a - let fills = (width - le) * fillchar - result = a + fills - -func rjust*[S](a: S, width: int, fillchar: S = " "): S = - let le = chkLen a - let fills = (width - le) * fillchar - result = fills + a - -func zfill*(c: char, width: int): string = - if 1 >= width: - return $c - # Now `width` is at least 2. - let zeroes = '0'.repeat(width-1) - if c == '+' or c == '-': - return c & zeroes - result = zeroes & c - -func zfill*(a: string, width: int): string = - let le = len(a) - var res = a - if le >= width: - return res - let fill = width - le - let zeroes = '0'.repeat(fill) - if le == 0: - return zeroes - - let first = res[0] - res = zeroes & res - if first == '+' or first == '-': - # move sign to beginning of string - res[fill] = '0' - res[0] = first - result = res - -func removeprefix*[S](a: S, suffix: S): S = - var res = $a - strutils.removePrefix(res, suffix) - S res -func removesuffix*[S](a: S, suffix: S): S = - var res = $a - strutils.removeSuffix(res, suffix) - S res - -func replace*[S](a: S, sub, by: char): S = - S strutils.replace($a, sub, by) -func replace*[S](a: S, sub, by: S): S = - S strutils.replace($a, $sub, $by) - -func replace*[S](a: S, sub, by: char, count: int): S = - if count < 0: a.replace(sub, by) - else: replaceWithCount.replace($a, sub, by, count) - -func replace*[S](a: S, sub, by: S, count: int): S = - if count < 0: a.replace(sub, by) - else: replaceWithCount.replace($a, $sub, $by, count) - -template expandtabsAux[S](a: S, tabsize#[: is a Positive]#; - strByteLen: int; iter; -): string = - # modified from CPython's Objects/unicodeobject.c unicode_expandtabs_impl - # with some refinement: - # - # 1. here `tabsize` is assumed to be Positive, - # get rid of making comparing within loop, that's what CPython does: - # two `if (tabsize > 0)` in two for loop. - # 2. by using Nim's string, we use the strategy of - # dynamically memory allocation, so no need to - # firstly perform one loop to just count the length of the result. - # 3. we use case-branch instead of if-branch within the loop. - # - # Also, we get some opt inspiration from std/strmisc's expandTabs - # - with cap of `le + le shl 2`. - # - add spaces via loop, which reduces space complexity. - mixin add - var column = 0 - var res = newStringOfCap(strByteLen + strByteLen shl 2) - for c in a.iter: - type C = typeof(c) - template addChars(res;c: C; n) = - for _ in 1..n: - res.add c - case c - of C('\r'), C('\n'): - res.add c - column = 0 - of C('\t'): - let incr = (tabsize - column mod tabsize) - column.inc incr - if incr > 0: - res.addChars C(' '), incr - else: - res.add c - column.inc - res - -template removeAll[S](a: S, toRM: char; strByteLen: int; iter): string = - var result = newStringOfCap strByteLen - for c in a.iter: - if c != typeof(c)(toRM): - result.add c - result - -template expandtabsImpl*[S](a: S, tabsize: int; - strByteLen: int; iter; -): string = - if tabsize > 0: expandtabsAux(a, tabsize, strByteLen, iter) - else: removeAll(a, '\t', strByteLen, iter) - -func join*[T](sep: char, a: openArray[T]): string = - a.join(sep) - -func join*[T, S](sep: S, a: openArray[T]): S = - ## Mimics Python join() -> string - S a.join($(sep)) - -template partitionGen(name; find){.dirty.} = - func name*[S](a: S, sep: S): tuple[before, sep, after: S] = - noEmptySep(sep) - let idx = a.find(sep) - if idx == -1: - result.before = a - return - result = (a[0.. 0: - while i >= 0 and pystr.ISSPACE(i): - i.dec - if i < 0: break - j = i; i.dec - while i >= 0 and not pystr.ISSPACE(i): - i.dec - when not STRINGLIB_MUTABLE: - if j == str_len - 1 and i < 0: - # here CPython checks `STRINGLIB_CHECK_EXACT` (L74) - # as they need to use `PyUnicode_CheckExact` to ensure - # `str_obj` is extractly a `str`, which we has ensured. - SPLIT_ADD pystr - break - SPLIT_ADD pystr, i+1, j+1 - - if i >= 0: - while i >= 0 and pystr.ISSPACE(i): - i.dec - if i >= 0: - SPLIT_ADD pystr, 0, i+1 - - -proc rsplit_whitespace*[S](pystr: S, maxsplit = -1): PyList[S] = - let - str_len = len(pystr) - maxcount = norm_maxsplit(maxsplit, str_len) - result = newPyListOfCap[S](PREPARE_CAP(maxcount)) - for i in pystr.rsplit_whitespace_impl(str_len=str_len, maxsplit=maxcount): - result.append i - result.reverse() diff --git a/src/pylib/stringlib/split/split_whitespace.nim b/src/pylib/stringlib/split/split_whitespace.nim deleted file mode 100644 index 1a580fe76..000000000 --- a/src/pylib/stringlib/split/split_whitespace.nim +++ /dev/null @@ -1,59 +0,0 @@ - -import ./common -import ./reimporter -# translated from CPython-3.13-alpha.6/Objects/ -# stringlib/split.h -# unicodeobject.c - - -# stringlib/split.h split_whitespace L54 - -# split.h split* have param of `PyObject* str_obj, const STRINGLIB_CHAR* str`, -# where `str` is unicode version of `str_obj` -iterator split_whitespace_impl[S](pystr: S, maxsplit, str_len: int; - ): S = - ## mixin ISSPACE - ## `maxsplit` must be Natural - template SPLIT_ADD(s, i, j) = yield s[i.. 0: - while i < str_len and pystr.ISSPACE(i): - i.inc - if i == str_len: break - j = i; i.inc - while i < str_len and not pystr.ISSPACE(i): - i.inc - when not STRINGLIB_MUTABLE: - if j == 0 and i == str_len: - # here CPython checks `STRINGLIB_CHECK_EXACT` (L74) - # as they need to use `PyUnicode_CheckExact` to ensure - # `str_obj` is extractly a `str`, which we has ensured. - SPLIT_ADD pystr - break - SPLIT_ADD pystr, j, i - - if i < str_len: - while i < str_len and pystr.ISSPACE(i): - i.inc - if i != str_len: - SPLIT_ADD pystr, i, str_len - - -iterator split_whitespace*[S](pystr: S, maxsplit = -1): S = - let str_len = len(pystr) - let maxcount = norm_maxsplit(maxsplit, str_len) - - for i in pystr.split_whitespace_impl(str_len=str_len, maxsplit=maxcount): - yield i - -proc split_whitespace*[S](pystr: S, maxsplit = -1): PyList[S] = - let - str_len = len(pystr) - maxcount = norm_maxsplit(maxsplit, str_len) - result = newPyListOfCap[S](PREPARE_CAP(maxcount)) - for i in pystr.split_whitespace_impl(str_len=str_len, maxsplit=maxcount): - result.append i diff --git a/src/pylib/stringlib/split/splitlinesIter.nim b/src/pylib/stringlib/split/splitlinesIter.nim deleted file mode 100644 index 6d8024986..000000000 --- a/src/pylib/stringlib/split/splitlinesIter.nim +++ /dev/null @@ -1,45 +0,0 @@ -## We cannot just use `strutils.splitLines` for str.splitlines, -## even nor for `bytes.splitlines`, -## as Python uses Univeral NewLine as sep. -## -## See https://docs.python.org/3/glossary.html#term-universal-newlines -## -## For a table of all Universal Newlines, -## see https://docs.python.org/3/library/stdtypes.html#str.splitlines - -# So again, we refer to CPython's source. - -# translated from CPython-3.13-alpha.6/Objects/ -# stringlib/split.h - -import ./common -# L336 - -iterator splitlines*[S](self: S, keepends = false): S = - ## mixin IS_CAR_NL, IS_LINEBREAK, `[Slice]`, `[int]`, len - template SPLIT_ADD(s, i, j) = yield s[i.. 0x10FFFF: - uniOverErr L.buf[start..L.bufpos-2] - addUnicodeCodePoint(tok.literal, xi) - of 'u': - inc(L.bufpos) - var xi = 0 - if L.buf[L.bufpos] == '{': - inc(L.bufpos) - let start = L.bufpos - while L.buf[L.bufpos] != '}': - handleHexChar(L, xi, 0) - if start == L.bufpos: - lexMessage(L, errGenerated, - "Unicode codepoint cannot be empty") - inc(L.bufpos) - if xi > 0x10FFFF: - uniOverErr L.buf[start..L.bufpos-2] - else: - handleHexChar(L, xi, 1) - handleHexChar(L, xi, 2) - handleHexChar(L, xi, 3) - handleHexChar(L, xi, 4) - addUnicodeCodePoint(tok.literal, xi) - of '0'..'7': - var xi = 0 - handleOctChars(L, xi) - tok.literal.add(chr(xi)) - else: lexMessage(L, errGenerated, "invalid character constant") - -func getString(L: var Lexer, tok: var Token) = - var pos = L.bufpos - - while pos < L.bufLen: - let c = L.buf[pos] - if c == '\\': - L.bufpos = pos - getEscapedChar(L, tok) - pos = L.bufpos - else: - tok.literal.add(c) - pos.inc - L.bufpos = pos - -func getString(L: var Lexer): Token = - L.getString result - -func translateEscape*(pattern: string): string = - ## like `translateEscapeWithErr` but without lineInfo error msg - var L = newLexer pattern - L.getString().literal - -macro translateEscapeWithErr*(pattern: string): string = - let info = pattern.lineInfoObj - let linfo = lexLineInfoFrom info - let sPattern = pattern.strVal - var L = newLexer sPattern - L.lineInfo = linfo - let s = L.getString().literal - result = newLit s diff --git a/src/pylib/version.nim b/src/pylib/version.nim deleted file mode 100644 index 1dc497ef6..000000000 --- a/src/pylib/version.nim +++ /dev/null @@ -1,126 +0,0 @@ - -const sep = '.' -template asVersion*(major, minor: int): string = - bind sep - $major & sep & $minor -template asVersion*(major, minor, patch: int): string = - bind sep - $major & sep & $minor & sep & $patch -func asVersion*(v: (int, int)): string = asVersion(v[0], v[1]) -func asVersion*(v: (int, int, int)): string = asVersion(v[0], v[1], v[2]) - -import ./versionInfo -export versionInfo - -const - Version* = asVersion(Major, Minor, Patch) -template exportSincePy*(major, minor: int, sym: typed) = - bind PyMajor, PyMinor - when (PyMajor, PyMinor) >= (major, minor): - export sym - -import std/macros -proc newCallFrom(sym, params: NimNode): NimNode = - result = newCall(sym) - for i in 1..= (major, minor): - def - template wrapExportSincePy*(major, minor: int, sym: typed) = - bind exportSincePy - exportSincePy(major, minor, sym) - -type MajorMinorVersion = tuple[major, minor: int] - -template pysince*[R](ver: MajorMinorVersion, defExpr, elseExpr: R): R = - bind PyMajor, PyMinor - when (PyMajor, PyMinor) >= ver: defExpr - else: elseExpr - -template toVer(s: MajorMinorVersion): MajorMinorVersion = s -func toVer(s: static float): MajorMinorVersion{.compileTime.} = - result.major = int(s) - let minorF = 10 * (s - float int(s)) - assert minorF.int.float - minorF < 1e10, # 1e10 is a picked not very strictly. - "must be in format of major.minor, " & "but got " & $s & - " debug: delta=" & $(minorF.int.float - minorF) - result.minor = int minorF - -func pysince*[R](ver: static[float|MajorMinorVersion]; defExpr, elseExpr: R): R{.inline.} = - bind PyMajor, PyMinor, toVer - when (PyMajor, PyMinor) >= toVer(ver): defExpr - else: elseExpr diff --git a/src/pylib/versionInfo.nim b/src/pylib/versionInfo.nim deleted file mode 100644 index 9d886723e..000000000 --- a/src/pylib/versionInfo.nim +++ /dev/null @@ -1,23 +0,0 @@ -## to be imported by ./version -# Values for PY_RELEASE_LEVEL */ - -type - PyReleaseLevelEnum*{.pure.} = enum - alpha = 0xA - beta = 0xB - gamma = 0xC - final = 0xF - -const - Major* = 0 - Minor* = 9 - Patch* = 11 - - ReleaseLevel* = "alpha" - Serial* = 0 - - PyMajor*{.intdefine.} = 3 - PyMinor*{.intdefine.} = 13 - PyPatch*{.intdefine.} = 0 - PyReleaseLevel* = PyReleaseLevelEnum.final - PySerial* = 0 diff --git a/tests/nim.cfg b/tests/nim.cfg deleted file mode 100644 index ac5825bc4..000000000 --- a/tests/nim.cfg +++ /dev/null @@ -1 +0,0 @@ ---path:"../src/" \ No newline at end of file diff --git a/tests/skipJs.txt b/tests/skipJs.txt deleted file mode 100644 index b2eadf6a1..000000000 --- a/tests/skipJs.txt +++ /dev/null @@ -1,4 +0,0 @@ -iters -iter_next -io -set \ No newline at end of file diff --git a/tests/tattr.nim b/tests/tattr.nim deleted file mode 100644 index ee37abe1e..000000000 --- a/tests/tattr.nim +++ /dev/null @@ -1,16 +0,0 @@ - -test "getattr/set/has": - type - O = object - a: int - - var o = O() - - let aVal = 2 - setattr(o, "a", aVal) - - check 3 == getattr(o, "b", 3) - - check aVal == getattr(o, "a") - - check not hasattr(o, "b") diff --git a/tests/tbytearray.nim b/tests/tbytearray.nim deleted file mode 100644 index f2fc1adb6..000000000 --- a/tests/tbytearray.nim +++ /dev/null @@ -1,16 +0,0 @@ - -test "bytearray": - var ba = bytearray() - - check ba.len == 0 - ba += b"abc" - - check ba[2] == ord('c') - - checkpoint "check byte-like method" - - check ba.isascii() - - ba.reverse() - - check ba == b"cba" diff --git a/tests/tbytes.nim b/tests/tbytes.nim deleted file mode 100644 index 8c6fcca97..000000000 --- a/tests/tbytes.nim +++ /dev/null @@ -1,27 +0,0 @@ - -suite "bytes": - test "getitem": - def t_getitem(): - byt = b"asd" - assert byt[1] == ord('s') - - t_getitem() - - test "meth": - def t_splitlines(): - ls = b"asd\r\nfdfg".splitlines() - assert ls == [b"asd", b"fdfg"] - t_splitlines() - - let btab = PyBytes.maketrans(b"bc", b"23") - - check b"HbOa".translate(btab, b"a") == b"H2O" - - check b"0123456789".isdigit() - check not b"a".isdigit() - - test "repr": - check repr(b"\xfe\xff") == "b'\\xfe\\xff'" - #check repr(b"\xfe\"\xff") == "b'\\xfe\"\\xff'" - # XXX: b"\xfe\"\xff" in Nim is parsed as `b"\xfe\"` `\xff"` instead of one string lit. - check repr(b"\xfe'\xff") == "b\"\\xfe'\\xff\"" diff --git a/tests/tclass.nim b/tests/tclass.nim deleted file mode 100644 index f7d9b23ca..000000000 --- a/tests/tclass.nim +++ /dev/null @@ -1,42 +0,0 @@ -#test "Class macro":# method cannot within `test` block, which is not top-level scope -when true: - type Customer = ref object - name: string - balance: float - checkpoint "Class creation" - class Customer(object): - """A customer of ABC Bank with a checking account. Customers have the - following properties: - - Attributes: - name: A string representing the customer's name. - balance: A float tracking the current balance of the customer's account. - """ - - def init(self, name, balance=0.0): - """Return a Customer object whose name is *name* and starting - balance is *balance*.""" - self.name = name - self.balance = balance - - def withdraw(self, amount): - """Return the balance remaining after withdrawing *amount* - dollars.""" - if amount > self.balance: - raise ValueError("Amount greater than available balance.") - self.balance -= amount - return self.balance - - def deposit(self, amount): - """Return the balance remaining after depositing *amount* - dollars.""" - self.balance += amount - return self.balance - checkpoint "Initialisation" - let c = newCustomer("Daniil", 500.0) - checkpoint "Fields" - check c.name == "Daniil" - check c.balance == 500 - checkpoint "'Methods' (procedures)" - check c.withdraw(250.0) == 250.0 - check c.deposit(1337.0) == 1587.0 \ No newline at end of file diff --git a/tests/tdecorator.nim b/tests/tdecorator.nim deleted file mode 100644 index 89ef64241..000000000 --- a/tests/tdecorator.nim +++ /dev/null @@ -1,38 +0,0 @@ - -test "decorator": - class O: - @staticmethod - def sm(): - return 1 - @classmethod - def cm(cls): - assert(cls == O) - return 2 - - check(O.sm()==1) - check(O.cm()==2) - -test "custom decorator": - type - - Func = proc(): int - var glob = 0 - - def as_is(f: Func) -> Func: - return f - - def inc_global(f: Func) -> Func: - global glob - glob = 1 - return f - tonim: - @as_is - def f() -> int: - return 3 - @inc_global - def g() -> int: - return 2 - - check(f() == 3) - check(g() == 2) - check(glob == 1) diff --git a/tests/testaments/.gitignore b/tests/testaments/.gitignore deleted file mode 100644 index 8a419ba1e..000000000 --- a/tests/testaments/.gitignore +++ /dev/null @@ -1,7 +0,0 @@ -*/* -/megatest -/megatest.exe -/testresults/ -!*.nim -!*.nims -!*.md \ No newline at end of file diff --git a/tests/testaments/README.md b/tests/testaments/README.md deleted file mode 100644 index 31e2d17b9..000000000 --- a/tests/testaments/README.md +++ /dev/null @@ -1 +0,0 @@ -tests for testament \ No newline at end of file diff --git a/tests/testaments/builtins/dict.nim b/tests/testaments/builtins/dict.nim deleted file mode 100644 index 7c9d04238..000000000 --- a/tests/testaments/builtins/dict.nim +++ /dev/null @@ -1,19 +0,0 @@ - -import pylib/builtins -import std/unittest - -test "dict": - var d = dict(k=1) - var dd = d.copy() - check d["k"] == 1 - - d.update(k=3) - d.update([("k2", 2)]) - - check len(d) == 2 - - check len(dd) == 1 - - # XXX: the following cannot run if included in ../../tester.nim - # why? - check str(dict([(1,2)])) == str("{1: 2}") diff --git a/tests/testaments/builtins/filter_toseq_deadloop.nim b/tests/testaments/builtins/filter_toseq_deadloop.nim deleted file mode 100644 index aa9f860b5..000000000 --- a/tests/testaments/builtins/filter_toseq_deadloop.nim +++ /dev/null @@ -1,11 +0,0 @@ -discard """ - output: ''' -@[1, 3] -''' - timeout: 5 -""" - -# issue #3 -import pylib/builtins/iters -import std/sequtils -echo filter(None, [1, 0, 3]).toSeq diff --git a/tests/testaments/builtins/list.nim b/tests/testaments/builtins/list.nim deleted file mode 100644 index 918be1250..000000000 --- a/tests/testaments/builtins/list.nim +++ /dev/null @@ -1,71 +0,0 @@ - -import pylib - -import std/unittest - -test "list shallow": - var ls = list([1,2,3]) - var ls1 = ls - ls1[0] = 3 - check ls[0] == 3 - -test "list.sort": - - template chkSorted(x) = - mixin cmp - var pre = x[0] - for i in 1.. 0: check false - pre = x[i] - var nums = list([1,2,4,6,0,3]) - nums.sort() - chkSorted nums - - when not defined(js): - ## XXX: compile err when JS - ## about Iterable concept's item match - type O = tuple - nouse: float - key: int - func cmp(a, b: O): int = a.key - b.key - var ls = list([ - (1.0, 10), (3.0, 8), (2.0, 9) - ]) - ls.sort(key=proc (o: O): int = o.key) - chkSorted(ls) - - -test "list methods": - var ls = list([-1,2,3]) - ls.append(4) - check len(ls) == 4 - - ls.extend([1,2,3]) - del ls[0] - check len(ls) == 6 - - when not defined(js): - block: - checkpoint "to check slice as index" - var ls = list([1,2,3,4]) - check ls[slice(2)] == [1, 2] - ls[slice(0, 3, 2)] = [5,1] - check ls == [5,2,1,4] - - expect ValueError: - ls[slice(0, 3, 2)] = [1] - expect ValueError: - ls[slice(0, 2, 2)] = range(4) - - -test "list slice": - def emptySlice(): - ls = [1,2,3,4] - return ls[1:-1] - check emptySlice() == [2,3] - - def s(): - ls = [1,2,3,4] - return ls[-4:-1] - check s() == [1,2,3] - diff --git a/tests/testaments/builtins/map_zip.nim b/tests/testaments/builtins/map_zip.nim deleted file mode 100644 index e66c138ee..000000000 --- a/tests/testaments/builtins/map_zip.nim +++ /dev/null @@ -1,31 +0,0 @@ -discard """ - output: ''' -1 4 -5 -2 5 -7 -1 -2 -3 -(1, 4, 'a') -(2, 5, 'b') -''' -""" -import pylib/builtins/iters - -let - it1 = [1, 2, 3] - it2 = [4, 5] - -func f(a, b: int): int = - debugEcho a, ' ', b - a+b - -for i in map(f, it1, it2): echo i - - - -func f(a: int): int = a -for i in map(f, it1): echo i - -for i in zip(it1, it2, "abc"): echo i diff --git a/tests/testaments/builtins/min_max_ct_err.nim b/tests/testaments/builtins/min_max_ct_err.nim deleted file mode 100644 index 99bdbddc2..000000000 --- a/tests/testaments/builtins/min_max_ct_err.nim +++ /dev/null @@ -1,19 +0,0 @@ -discard """ - matrix: "--hints:off --errorMax:0 --styleCheck:error" -""" - - -import pylib/builtins/min_max - - -min() #[tt.Error - ^ TypeError: min expected at least 1 argument, got 0]# - -max() #[tt.Error - ^ TypeError: max expected at least 1 argument, got 0]# - -max(1)#[tt.Error - ^ TypeError: 'int' object is not iterable]# - -min(1)#[tt.Error - ^ TypeError: 'int' object is not iterable]# diff --git a/tests/testaments/builtins/min_max_rt_err.nim b/tests/testaments/builtins/min_max_rt_err.nim deleted file mode 100644 index 0ba5aab51..000000000 --- a/tests/testaments/builtins/min_max_rt_err.nim +++ /dev/null @@ -1,14 +0,0 @@ -discard """ - joinable: true - batchable: true -""" - -import pylib/builtins/min_max - -template assertRaisesString[T](exc: typedesc[T]; errMsg: string; body) = - try: body - except exc as e: assert e.msg == errMsg, e.msg - - -assertRaisesString(ValueError, "max() iterable argument is empty"): discard max("") -assertRaisesString(ValueError, "min() iterable argument is empty"): discard min("") diff --git a/tests/testaments/builtins/print.nim b/tests/testaments/builtins/print.nim deleted file mode 100644 index 56b20c34a..000000000 --- a/tests/testaments/builtins/print.nim +++ /dev/null @@ -1,19 +0,0 @@ -discard """ - action: "run" - targets: "c js" - - joinable: true - - batchable: true - - output: ''' -34 321 -''' -""" - -import pylib -print(34, endl=' ') -print(32, `end`="") -print(1) - - diff --git a/tests/testaments/builtins/print_ct.nim b/tests/testaments/builtins/print_ct.nim deleted file mode 100644 index a171d45c6..000000000 --- a/tests/testaments/builtins/print_ct.nim +++ /dev/null @@ -1,14 +0,0 @@ -discard """ - cmd: "nim c --hints:off -d:testing $options $file" - nimout: ''' -abc -''' -""" - -import pylib - -static: - #print("a1 ", endl="") # XXX: cannot impl - print("abc") - - diff --git a/tests/testaments/builtins/round_float.nim b/tests/testaments/builtins/round_float.nim deleted file mode 100644 index 728fb447e..000000000 --- a/tests/testaments/builtins/round_float.nim +++ /dev/null @@ -1,113 +0,0 @@ -discard """ - action: "run" - targets: "c js" - - # output: "" this test also uses unittest.task -""" - -import pylib/builtins # /[round, attr] - - -import pylib/builtins/[pyrange, complex, format] -import pylib/numTypes/floats - -import pylib/Lib/[unittest, math, random, sys] -import std/unittest as std_unittest -import ../../utils - -when intOver64b: - from pylib/ops import `**` - -template withIfInt64(init, more): untyped = - when intOver64b: @init & @more - else: init - -# Lib/test/test_float.py - -proc assertFloatsAreIdentical(self: TestCase, x, y: float) = - template `<->`(a, b: bool): bool = a == b - self.assertTrue (x.isnan <-> y.isnan) or - x == y and (x != 0.0 or copySign(1.0, x) == copySign(1.0, y)) - -#@support.requires_IEEE_754 -#class RoundTestCase(unittest.TestCase, FloatsAreIdenticalMixin): -block: - var self = newTestCase() - #[ - block: #def test_inf_nan(self): - self.assertRaises(OverflowError, round, INF) - self.assertRaises(OverflowError, round, -INF) - self.assertRaises(ValueError, round, NAN) - self.assertRaises(TypeError, round, INF, 0.0) - self.assertRaises(TypeError, round, -INF, 1.0) - self.assertRaises(TypeError, round, NAN, "ceci n'est pas un integer") - self.assertRaises(TypeError, round, -0.0, complex(0, 1)) -]# - block: #def test_inf_nan_ndigits(self): - self.assertEqual(round(INF, 0), INF) - self.assertEqual(round(-INF, 0), -INF) - self.assertTrue(math.isnan(round(NAN, 0))) - - block: #def test_large_n(self): - for n in withIfInt64([324, 325, 400], [2**31-1, 2**31, 2**32, #[2**100]# ]): - self.assertEqual(round(123.456, n), 123.456) - self.assertEqual(round(-123.456, n), -123.456) - self.assertEqual(round(1e300, n), 1e300) - self.assertEqual(round(1e-320, n), 1e-320) - self.assertEqual(round(1e150, 300), 1e150) - self.assertEqual(round(1e300, 307), 1e300) - self.assertEqual(round(-3.1415, 308), -3.1415) - self.assertEqual(round(1e150, 309), 1e150) - self.assertEqual(round(1.4e-315, 315), 1e-315) - - block: #def test_small_n(self): - for n in withIfInt64([-308, -309, -400], [1-2**31, -2**31, -2**31-1, #[-2**100]# ]): - self.assertFloatsAreIdentical(round(123.456, n), 0.0) - self.assertFloatsAreIdentical(round(-123.456, n), -0.0) - self.assertFloatsAreIdentical(round(1e300, n), 0.0) - self.assertFloatsAreIdentical(round(1e-320, n), 0.0) - -#[ - block: #def test_overflow(self): - self.assertRaises(OverflowError, round, 1.6e308, -308) - self.assertRaises(OverflowError, round, -1.7e308, -308) -]# - unittest.skipUnless(getattr(sys, "float_repr_style", "") == "short", - "applies only when using short float repr style"): - test "previous_round_bugs": - self.assertEqual(round(562949953421312.5, 1), - 562949953421312.5) - - self.assertEqual(round(56294995342131.5, 3), - 56294995342131.5) - - block: - # round-half-even - self.assertEqual(round(25.0, -1), 20.0) - self.assertEqual(round(35.0, -1), 40.0) - self.assertEqual(round(45.0, -1), 40.0) - self.assertEqual(round(55.0, -1), 60.0) - self.assertEqual(round(65.0, -1), 60.0) - self.assertEqual(round(75.0, -1), 80.0) - self.assertEqual(round(85.0, -1), 80.0) - self.assertEqual(round(95.0, -1), 100.0) - - - - unittest.skipUnless(getattr(sys, "float_repr_style", "") == "short", - "applies only when using short float repr style"): - test "matches_float_format": - # round should give the same results as float formatting - proc chk(x: float) = - self.assertEqual(float(format(x, ".0f")), round(x, 0)) - self.assertEqual(float(format(x, ".1f")), round(x, 1)) - self.assertEqual(float(format(x, ".2f")), round(x, 2)) - self.assertEqual(float(format(x, ".3f")), round(x, 3)) - for i in range(500): - chk(i/1000) - - for i in range(5, 5000, 10): - chk(i/1000) - - for i in range(500): - chk(random.random()) diff --git a/tests/testaments/builtins/round_int.nim b/tests/testaments/builtins/round_int.nim deleted file mode 100644 index 03a18b781..000000000 --- a/tests/testaments/builtins/round_int.nim +++ /dev/null @@ -1,98 +0,0 @@ -discard """ - action: "run" - targets: "c js" - - output: "" -""" -import pylib/builtins -import pylib/ops -import pylib/Lib/random - -import std/unittest - -import ../../utils - -var self = 0 -template assertEqual(_: typeof(self); a, b: auto) = check(a == b) - -block test_round: - # check round-half-even algorithm. For round to nearest ten; - # rounding map is invariant under adding multiples of 20 - let test_dict = [0, 0, 0, 0, 0, 0, - 10, 10, 10, 10, 10, 10, 10, 10, 10, - 20, 20, 20, 20, 20] - var - got, expected: int - expect, x: int - - for offset in range(-520, 520, 20): - for k, v in test_dict.pairs(): - got = round(k+offset, -1) - expected = v+offset - self.assertEqual(got, expected) - - # larger second argument - self.assertEqual(round(-150, -2), -200) - self.assertEqual(round(-149, -2), -100) - self.assertEqual(round(-51, -2), -100) - self.assertEqual(round(-50, -2), 0) - self.assertEqual(round(-49, -2), 0) - self.assertEqual(round(-1, -2), 0) - self.assertEqual(round(0, -2), 0) - self.assertEqual(round(1, -2), 0) - self.assertEqual(round(49, -2), 0) - self.assertEqual(round(50, -2), 0) - self.assertEqual(round(51, -2), 100) - self.assertEqual(round(149, -2), 100) - self.assertEqual(round(150, -2), 200) - self.assertEqual(round(250, -2), 200) - self.assertEqual(round(251, -2), 300) - self.assertEqual(round(172500, -3), 172000) - self.assertEqual(round(173500, -3), 174000) - when intOver64b: - self.assertEqual(round(31415926535, -1), 31415926540) - self.assertEqual(round(31415926535, -2), 31415926500) - self.assertEqual(round(31415926535, -3), 31415927000) - self.assertEqual(round(31415926535, -4), 31415930000) - self.assertEqual(round(31415926535, -5), 31415900000) - self.assertEqual(round(31415926535, -6), 31416000000) - self.assertEqual(round(31415926535, -7), 31420000000) - self.assertEqual(round(31415926535, -8), 31400000000) - self.assertEqual(round(31415926535, -9), 31000000000) - self.assertEqual(round(31415926535, -10), 30000000000) - self.assertEqual(round(31415926535, -11), 0) - self.assertEqual(round(31415926535, -12), 0) - self.assertEqual(round(31415926535, -999), 0) - - # should get correct results even for huge inputs - # 10**11 > int32.high; 10**20 > int64.high - when intOver64b: - for k in range(10, 19): - got = round(10**k + 324678, -3) - expect = 10**k + 325000 - self.assertEqual(got, expect) - - # nonnegative second argument: round(x, n) should just return x - for n in range(5): - for i in range(100): - x = random.randrange(-10000, 10000) - got = round(x, n) - self.assertEqual(got, x) - - when intOver64b: - for huge_n in [2**31-1, 2**31, - # 2**63-1, 2**63, 2**100, 10**100 - ]: - self.assertEqual(round(8979323, huge_n), 8979323) - - # omitted second argument - for i in range(100): - x = random.randrange(-10000, 10000) - got = round(x) - self.assertEqual(got, x) - - - # bad second argument - #bad_exponents = ("brian", 2.0, 0j) - #for e in bad_exponents: - # self.assertRaises(TypeError, round, 3, e) diff --git a/tests/testaments/builtins/set.nim b/tests/testaments/builtins/set.nim deleted file mode 100644 index 5b5057074..000000000 --- a/tests/testaments/builtins/set.nim +++ /dev/null @@ -1,34 +0,0 @@ - -import std/unittest -import pylib/builtins -import pylib/pysugar - -test "set": - def t_shallow(): - s1 = set([1,2,3]) - s2 = s1 - s2.pop() - check(len(s1)==2) - t_shallow() - def fun(): - s = pyset([2, 3]) - check(len(s.union([1]))==3) - check(len(s.intersection(@[1,2,3]))==2) - fun() - def op(): - s = pyset([2, 3]) - # XXX: s.union("1") will cause Nim complain... - check(len(s | pyset([1]))==3) - check(len(s & pyset([1,2,3]))==2) - op() - - proc lit() = - let s = pysetLit({1,2,3}) - check(len(s) == 3) - lit() - - proc stringify() = - let s = pysetLit({u"1"}) - check str(s) == "{'1'}" - - stringify() diff --git a/tests/testaments/builtins/tcomplex.nim b/tests/testaments/builtins/tcomplex.nim deleted file mode 100644 index d9df987f9..000000000 --- a/tests/testaments/builtins/tcomplex.nim +++ /dev/null @@ -1,254 +0,0 @@ - - -import pylib -import pylib/Lib/unittest -import std/unittest -import std/math except divmod -proc assertFloatsAreIdentical(x, y: float) = - template `<->`(a, b: bool): bool = not (a xor b) - check (x.isnan <-> y.isnan) or - x == y and (x != 0.0 or copySign(1.0, x) == copySign(1.0, y)) - -template check(c: PyComplex; r, i) = - let nc = c - assertFloatsAreIdentical nc.real, r - assertFloatsAreIdentical nc.imag, i - -suite "complex.__init__(str)": - test "from str": - check(complex("1"), 1.0, 0.0) - check(complex("1j"), 0.0, 1.0) - check(complex("-1"), -1.0, 0.0) - check(complex("+1"), 1.0, 0.0) - check(complex("1+2j"), 1.0, 2.0) - check(complex("(1+2j)"), 1.0, 2.0) - check(complex("(1.5+4.25j)"), 1.5, 4.25) - check(complex("4.25+1J"), 4.25, 1.0) - check(complex(" ( +4.25-6J )"), 4.25, -6.0) - check(complex(" ( +4.25-J )"), 4.25, -1.0) - check(complex(" ( +4.25+j )"), 4.25, 1.0) - check(complex("J"), 0.0, 1.0) - check(complex("( j )"), 0.0, 1.0) - check(complex("+J"), 0.0, 1.0) - check(complex("( -j)"), 0.0, -1.0) - check(complex("1-1j"), 1.0, -1.0) - check(complex("1J"), 0.0, 1.0) - - check(complex("1e-500"), 0.0, 0.0) - check(complex("-1e-500j"), 0.0, -0.0) - check(complex("1e-500+1e-500j"), 0.0, 0.0) - check(complex("-1e-500+1e-500j"), -0.0, 0.0) - check(complex("1e-500-1e-500j"), 0.0, -0.0) - check(complex("-1e-500-1e-500j"), -0.0, -0.0) - - # SF bug 543840: complex(string) accepts strings with \0 - # Fixed in 2.3. - assertRaises(ValueError, complex, "1+1j\0j") - assertRaises(ValueError, complex, "") - assertRaises(ValueError, complex, "\0") - assertRaises(ValueError, complex, "3\x009") - assertRaises(ValueError, complex, "1+") - assertRaises(ValueError, complex, "1+1j+1j") - assertRaises(ValueError, complex, "--") - assertRaises(ValueError, complex, "(1+2j") - assertRaises(ValueError, complex, "1+2j)") - assertRaises(ValueError, complex, "1+(2j)") - assertRaises(ValueError, complex, "(1+2j)123") - assertRaises(ValueError, complex, "x") - assertRaises(ValueError, complex, "1j+2") - assertRaises(ValueError, complex, "1e1ej") - assertRaises(ValueError, complex, "1e++1ej") - assertRaises(ValueError, complex, ")1+2j(") - # the following three are accepted by Python 2.6 - assertRaises(ValueError, complex, "1..1j") - assertRaises(ValueError, complex, "1.11.1j") - assertRaises(ValueError, complex, "1e1.1j") - - # check whitespace processing - assertEqual(complex("\u2003(\u20021+1j ) "), complex(1, 1)) - # Invalid unicode string - # See bpo-34087 - assertRaises(ValueError, complex, "\u3053\u3093\u306b\u3061\u306f") - - when not defined(js): - # V8 derived JS runtime like node/deno doesn't reservse NANs' bit representation. - # when it comes to `Array`, all NANs becomes `NaN` (signbit is 0); - # To make it a problem, Nim implements `var` param just by passing arg as an Array. - # So we say JS backend cannot confirm the signbit is right. - # Here is code demo: https://gist.github.com/litlighilit/e05f3d7c59b69b753f2f77a6ad72467d - test "negative_nans_from_string": - assertEqual(copysign(1.0, complex("nan").real), 1.0) - assertEqual(copysign(1.0, complex("-nan").real), -1.0) - assertEqual(copysign(1.0, complex("-nanj").imag), -1.0) - assertEqual(copysign(1.0, complex("-nan-nanj").real), -1.0) - assertEqual(copysign(1.0, complex("-nan-nanj").imag), -1.0) - -suite "complex": - test "init": - let z = complex(3.0, -4.0) - check z.imag == -4.0 - check(complex(imag=1.5), 0.0, 1.5) - check(complex(real=4.25, imag=1.5), 4.25, 1.5) - check(complex(4.25, imag=1.5), 4.25, 1.5) - test "literals": - check 1-3.j == complex(1, -3) - checkpoint "at compile-time" - const c = -3-1.j - check c.real == -3 - check c.imag == -1 - test "str": - let z = complex(3.0, -4.0) - check $z == "(3-4j)" - test "op": - let z = complex(3.0, -4.0) - check z.conjugate() == complex(3.0, 4.0) - check abs(z) == 5.0 - -suite "complex.__repr__": - test "(N+nanj)": - # there's once a bug str(complex(1, NaN)) == "(1nanj)" - - for i in range(1, 4): - assertEqual str(complex(float(i), NaN)), "(" + str(i) + "+nanj)" - test "real == 0.0": - assertEqual str(complex(0.0, NaN)), "nanj" - assertEqual str(complex(-0.0, NaN)), "(-0+nanj)" - - -type OverflowError = OverflowDefect - -suite "complex.__pow__": - template assertAlmostEqual(a, b: float) = - check almostEqual(a, b) - const sys_maxsize = sizeof system.int - - def assertAlmostEqual(a, b): - when isinstance(a, PyComplex): - when isinstance(b, PyComplex): - assertAlmostEqual(a.real, b.real) - assertAlmostEqual(a.imag, b.imag) - else: - assertAlmostEqual(a.real, b) - assertAlmostEqual(a.imag, 0.0) - else: - when isinstance(b, PyComplex): - assertAlmostEqual(a, b.real) - assertAlmostEqual(0.0, b.imag) - else: - assertAlmostEqual(a, b) - test "CPython:test_complex.ComplexTest.test_pow": - def test_pow(): - assertAlmostEqual(pow(1+1.j, 0+0.j), 1.0) - assertAlmostEqual(pow(0+0.j, 2+0.j), 0.0) - assertEqual(pow(0+0.j, 2000+0.j), 0.j) - - assertEqual(pow(0, 0+0.j), 1.0) - assertEqual(pow(-1, 0+0.j), 1.0) - - assertRaises(ZeroDivisionError, pow, 0+0.j, 1.j) - assertRaises(OverflowError, pow, 1e200+1.j, 1e200+1.j) - assertRaises(ZeroDivisionError, pow, 0+0.j, -1000) - assertAlmostEqual(pow(1.j, -1), 1/1.j) - assertAlmostEqual(pow(1.j, 200), complex(1)) - #assertRaises(ValueError, pow, 1+1.j, 1+1.j, 1+1.j) - #assertRaises(TypeError, pow, 1.j, None) - #assertRaises(TypeError, pow, None, 1.j) - assertAlmostEqual(pow(1.j, 0.5), 0.7071067811865476+0.7071067811865475'j) - - a = 3.33+4.43'j - c1 = complex(1) - assertEqual(a ** 0.j, c1) - assertEqual(a ** (0.0+0.j), c1) ## NOTE: `a ** 0.0+0.0'J` will cause compile error - - assertEqual(3.j ** 0.j, c1) - assertEqual(3.j ** 0, c1) - - try: - discard 0.j ** a - fail() # "should fail 0.0 to negative or complex power") - except ZeroDivisionError: - discard - - try: - discard 0.j ** (3-2.j) - fail() # "should fail 0.0 to negative or complex power") - except ZeroDivisionError: - discard - - # The following is used to exercise certain code paths - assertEqual(a ** 105, a ** 105) - assertEqual(a ** -105, a ** -105) - assertEqual(a ** -30, a ** -30) - - assertEqual(0.j ** 0, c1) - - b = 5.1+2.3'j - #assertRaises(ValueError, pow, a, b, 0) - - # Check some boundary conditions; some of these used to invoke - # undefined behaviour (https://bugs.python.org/issue44698). We're - # not actually checking the results of these operations, just making - # sure they don't crash (for example when using clang's - # UndefinedBehaviourSanitizer). - values = [sys_maxsize, sys_maxsize+1, sys_maxsize-1, - -sys_maxsize, -sys_maxsize+1, -sys_maxsize+1] - for real in values: - for imag in values: - #with subTest(real=real, imag=imag): - c = complex(real, imag) - try: - discard c ** real - except OverflowError: - discard - try: - _ = c ** c - except OverflowError: - discard - test_pow() - - test "with small integer exponents": - def test_pow_with_small_integer_exponents(): - # Check that small integer exponents are handled identically - # regardless of their type. - values = [ - complex(5.0, 12.0), - complex(5.0e100, 12.0e100), - complex(-4.0, INF), - complex(INF, 0.0), - ] - exponents = [-19, -5, -3, -2, -1, 0, 1, 2, 3, 5, 19] - - emp0 = complex(0) - int_pow = emp0 - float_pow = int_pow - complex_pow = int_pow - for value in values: - for exponent in exponents: - #with subTest(value=value, exponent=exponent): - try: - int_pow = value**exponent - except OverflowError: - int_pow = emp0 - try: - float_pow = value**float(exponent) - except OverflowError: - float_pow = emp0 - try: - complex_pow = value**complex(exponent) - except OverflowError: - complex_pow = emp0 - template assertComplexEqual(a, b) = - if a.real.isNaN or b.real.isNaN or a.imag.isNaN or b.imag.isNaN: - assertEqual(str(a), str(b)) - if str(a) != str(b): - echo value - echo exponent - else: - assertEqual(a, b) - if (a) != (b): - echo value - echo exponent - assertComplexEqual(float_pow, int_pow) - assertComplexEqual(complex_pow, int_pow) - - test_pow_with_small_integer_exponents() diff --git a/tests/testaments/builtins/tfloat.nim b/tests/testaments/builtins/tfloat.nim deleted file mode 100644 index 6852493fa..000000000 --- a/tests/testaments/builtins/tfloat.nim +++ /dev/null @@ -1,371 +0,0 @@ - -import pylib -import std/unittest -import std/math as std_math except divmod -import std/random as std_random - -from pylib/Lib/math import ldexp - -randomize() - - -template fromHex(s: string): float = - float_fromhex(s) -template toHex(f: float): string = f.hex() - -const - MAX = fromHex("0x.fffffffffffff8p+1024") # max normal - MIN = fromHex("0x1p-1022") # min normal - TINY = fromHex("0x0.0000000000001p-1022") # min subnormal - EPS = fromHex("0x0.0000000000001p0") # diff between 1.0 and next float up - -proc identical(x, y: float) = - template `<->`(a, b: bool): bool = not (a xor b) - check (x.isnan <-> y.isnan) or - x == y and (x != 0.0 or copySign(1.0, x) == copySign(1.0, y)) - -suite "float.fromhex": - test "literals": - # two spellings of infinity, with optional signs; case-insensitive - identical(fromHex("inf"), INF) - identical(fromHex("+Inf"), INF) - identical(fromHex("-INF"), -INF) - identical(fromHex("iNf"), INF) - identical(fromHex("Infinity"), INF) - identical(fromHex("+INFINITY"), INF) - identical(fromHex("-infinity"), -INF) - identical(fromHex("-iNFiNitY"), -INF) - test "nans": - # nans with optional sign; case insensitive - identical(fromHex("nan"), NAN) - identical(fromHex("+NaN"), NAN) - identical(fromHex("-NaN"), NAN) - identical(fromHex("-nAN"), NAN) - test "some values": - # variations in input format - identical(fromHex("1"), 1.0) - identical(fromHex("+1"), 1.0) - identical(fromHex("1."), 1.0) - identical(fromHex("1.0"), 1.0) - identical(fromHex("1.0p0"), 1.0) - identical(fromHex("01"), 1.0) - identical(fromHex("01."), 1.0) - identical(fromHex("0x1"), 1.0) - identical(fromHex("0x1."), 1.0) - identical(fromHex("0x1.0"), 1.0) - identical(fromHex("+0x1.0"), 1.0) - identical(fromHex("0x1p0"), 1.0) - identical(fromHex("0X1p0"), 1.0) - identical(fromHex("0X1P0"), 1.0) - identical(fromHex("0x1P0"), 1.0) - identical(fromHex("0x1.p0"), 1.0) - identical(fromHex("0x1.0p0"), 1.0) - identical(fromHex("0x.1p4"), 1.0) - identical(fromHex("0x.1p04"), 1.0) - identical(fromHex("0x.1p004"), 1.0) - identical(fromHex("0x1p+0"), 1.0) - identical(fromHex("0x1P-0"), 1.0) - identical(fromHex("+0x1p0"), 1.0) - identical(fromHex("0x01p0"), 1.0) - identical(fromHex("0x1p00"), 1.0) - identical(fromHex(" 0x1p0 "), 1.0) - identical(fromHex("\n 0x1p0"), 1.0) - identical(fromHex("0x1p0 \t"), 1.0) - identical(fromHex("0xap0"), 10.0) - identical(fromHex("0xAp0"), 10.0) - identical(fromHex("0xaP0"), 10.0) - identical(fromHex("0xAP0"), 10.0) - identical(fromHex("0xbep0"), 190.0) - identical(fromHex("0xBep0"), 190.0) - identical(fromHex("0xbEp0"), 190.0) - identical(fromHex("0XBE0P-4"), 190.0) - identical(fromHex("0xBEp0"), 190.0) - identical(fromHex("0xB.Ep4"), 190.0) - identical(fromHex("0x.BEp8"), 190.0) - identical(fromHex("0x.0BEp12"), 190.0) - - # moving the point around - const pi = fromHex("0x1.921fb54442d18p1") - identical(fromHex("0x.006487ed5110b46p11"), pi) - identical(fromHex("0x.00c90fdaa22168cp10"), pi) - identical(fromHex("0x.01921fb54442d18p9"), pi) - identical(fromHex("0x.03243f6a8885a3p8"), pi) - identical(fromHex("0x.06487ed5110b46p7"), pi) - identical(fromHex("0x.0c90fdaa22168cp6"), pi) - identical(fromHex("0x.1921fb54442d18p5"), pi) - identical(fromHex("0x.3243f6a8885a3p4"), pi) - identical(fromHex("0x.6487ed5110b46p3"), pi) - identical(fromHex("0x.c90fdaa22168cp2"), pi) - identical(fromHex("0x1.921fb54442d18p1"), pi) - identical(fromHex("0x3.243f6a8885a3p0"), pi) - identical(fromHex("0x6.487ed5110b46p-1"), pi) - identical(fromHex("0xc.90fdaa22168cp-2"), pi) - identical(fromHex("0x19.21fb54442d18p-3"), pi) - identical(fromHex("0x32.43f6a8885a3p-4"), pi) - identical(fromHex("0x64.87ed5110b46p-5"), pi) - identical(fromHex("0xc9.0fdaa22168cp-6"), pi) - identical(fromHex("0x192.1fb54442d18p-7"), pi) - identical(fromHex("0x324.3f6a8885a3p-8"), pi) - identical(fromHex("0x648.7ed5110b46p-9"), pi) - identical(fromHex("0xc90.fdaa22168cp-10"), pi) - identical(fromHex("0x1921.fb54442d18p-11"), pi) - # ... - identical(fromHex("0x1921fb54442d1.8p-47"), pi) - identical(fromHex("0x3243f6a8885a3p-48"), pi) - identical(fromHex("0x6487ed5110b46p-49"), pi) - identical(fromHex("0xc90fdaa22168cp-50"), pi) - identical(fromHex("0x1921fb54442d18p-51"), pi) - identical(fromHex("0x3243f6a8885a30p-52"), pi) - identical(fromHex("0x6487ed5110b460p-53"), pi) - identical(fromHex("0xc90fdaa22168c0p-54"), pi) - identical(fromHex("0x1921fb54442d180p-55"), pi) - test "overflow": - # results that should overflow... - expect(OverflowDefect): discard fromHex "-0x1p1024" - expect(OverflowDefect): discard fromHex "0x1p+1025" - expect(OverflowDefect): discard fromHex "+0X1p1030" - expect(OverflowDefect): discard fromHex "-0x1p+1100" - expect(OverflowDefect): discard fromHex "0X1p123456789123456789" - expect(OverflowDefect): discard fromHex "+0X.8p+1025" - expect(OverflowDefect): discard fromHex "+0x0.8p1025" - expect(OverflowDefect): discard fromHex "-0x0.4p1026" - expect(OverflowDefect): discard fromHex "0X2p+1023" - expect(OverflowDefect): discard fromHex "0x2.p1023" - expect(OverflowDefect): discard fromHex "-0x2.0p+1023" - expect(OverflowDefect): discard fromHex "+0X4p+1022" - expect(OverflowDefect): discard fromHex "0x1.ffffffffffffffp+1023" - expect(OverflowDefect): discard fromHex "-0X1.fffffffffffff9p1023" - expect(OverflowDefect): discard fromHex "0X1.fffffffffffff8p1023" - expect(OverflowDefect): discard fromHex "+0x3.fffffffffffffp1022" - expect(OverflowDefect): discard fromHex "0x3fffffffffffffp+970" - expect(OverflowDefect): discard fromHex "0x10000000000000000p960" - expect(OverflowDefect): discard fromHex "-0Xffffffffffffffffp960" - - # ...and those that round to +-max float - identical(fromHex("+0x1.fffffffffffffp+1023"), MAX) - identical(fromHex("-0X1.fffffffffffff7p1023"), -MAX) - identical(fromHex("0X1.fffffffffffff7fffffffffffffp1023"), MAX) - test "zeros and underflow": - # zeros - identical(fromHex("0x0p0"), 0.0) - identical(fromHex("0x0p1000"), 0.0) - identical(fromHex("-0x0p1023"), -0.0) - identical(fromHex("0X0p1024"), 0.0) - identical(fromHex("-0x0p1025"), -0.0) - identical(fromHex("0X0p2000"), 0.0) - identical(fromHex("0x0p123456789123456789"), 0.0) - identical(fromHex("-0X0p-0"), -0.0) - identical(fromHex("-0X0p-1000"), -0.0) - identical(fromHex("0x0p-1023"), 0.0) - identical(fromHex("-0X0p-1024"), -0.0) - identical(fromHex("-0x0p-1025"), -0.0) - identical(fromHex("-0x0p-1072"), -0.0) - identical(fromHex("0X0p-1073"), 0.0) - identical(fromHex("-0x0p-1074"), -0.0) - identical(fromHex("0x0p-1075"), 0.0) - identical(fromHex("0X0p-1076"), 0.0) - identical(fromHex("-0X0p-2000"), -0.0) - identical(fromHex("-0x0p-123456789123456789"), -0.0) - test "round-half-even": - identical(fromHex("0x1p-1076"), 0.0) - identical(fromHex("0X2p-1076"), 0.0) - identical(fromHex("0X3p-1076"), TINY) - identical(fromHex("0x4p-1076"), TINY) - identical(fromHex("0X5p-1076"), TINY) - identical(fromHex("0X6p-1076"), 2*TINY) - identical(fromHex("0x7p-1076"), 2*TINY) - identical(fromHex("0X8p-1076"), 2*TINY) - identical(fromHex("0X9p-1076"), 2*TINY) - identical(fromHex("0xap-1076"), 2*TINY) - identical(fromHex("0Xbp-1076"), 3*TINY) - identical(fromHex("0xcp-1076"), 3*TINY) - identical(fromHex("0Xdp-1076"), 3*TINY) - identical(fromHex("0Xep-1076"), 4*TINY) - identical(fromHex("0xfp-1076"), 4*TINY) - identical(fromHex("0x10p-1076"), 4*TINY) - identical(fromHex("-0x1p-1076"), -0.0) - identical(fromHex("-0X2p-1076"), -0.0) - identical(fromHex("-0x3p-1076"), -TINY) - identical(fromHex("-0X4p-1076"), -TINY) - identical(fromHex("-0x5p-1076"), -TINY) - identical(fromHex("-0x6p-1076"), -2*TINY) - identical(fromHex("-0X7p-1076"), -2*TINY) - identical(fromHex("-0X8p-1076"), -2*TINY) - identical(fromHex("-0X9p-1076"), -2*TINY) - identical(fromHex("-0Xap-1076"), -2*TINY) - identical(fromHex("-0xbp-1076"), -3*TINY) - identical(fromHex("-0xcp-1076"), -3*TINY) - identical(fromHex("-0Xdp-1076"), -3*TINY) - identical(fromHex("-0xep-1076"), -4*TINY) - identical(fromHex("-0Xfp-1076"), -4*TINY) - identical(fromHex("-0X10p-1076"), -4*TINY) - - # and near MIN ... - identical(fromHex("0x0.ffffffffffffd6p-1022"), MIN-3*TINY) - identical(fromHex("0x0.ffffffffffffd8p-1022"), MIN-2*TINY) - identical(fromHex("0x0.ffffffffffffdap-1022"), MIN-2*TINY) - identical(fromHex("0x0.ffffffffffffdcp-1022"), MIN-2*TINY) - identical(fromHex("0x0.ffffffffffffdep-1022"), MIN-2*TINY) - identical(fromHex("0x0.ffffffffffffe0p-1022"), MIN-2*TINY) - identical(fromHex("0x0.ffffffffffffe2p-1022"), MIN-2*TINY) - identical(fromHex("0x0.ffffffffffffe4p-1022"), MIN-2*TINY) - identical(fromHex("0x0.ffffffffffffe6p-1022"), MIN-2*TINY) - identical(fromHex("0x0.ffffffffffffe8p-1022"), MIN-2*TINY) - identical(fromHex("0x0.ffffffffffffeap-1022"), MIN-TINY) - identical(fromHex("0x0.ffffffffffffecp-1022"), MIN-TINY) - identical(fromHex("0x0.ffffffffffffeep-1022"), MIN-TINY) - identical(fromHex("0x0.fffffffffffff0p-1022"), MIN-TINY) - identical(fromHex("0x0.fffffffffffff2p-1022"), MIN-TINY) - identical(fromHex("0x0.fffffffffffff4p-1022"), MIN-TINY) - identical(fromHex("0x0.fffffffffffff6p-1022"), MIN-TINY) - identical(fromHex("0x0.fffffffffffff8p-1022"), MIN) - identical(fromHex("0x0.fffffffffffffap-1022"), MIN) - identical(fromHex("0x0.fffffffffffffcp-1022"), MIN) - identical(fromHex("0x0.fffffffffffffep-1022"), MIN) - identical(fromHex("0x1.00000000000000p-1022"), MIN) - identical(fromHex("0x1.00000000000002p-1022"), MIN) - identical(fromHex("0x1.00000000000004p-1022"), MIN) - identical(fromHex("0x1.00000000000006p-1022"), MIN) - identical(fromHex("0x1.00000000000008p-1022"), MIN) - identical(fromHex("0x1.0000000000000ap-1022"), MIN+TINY) - identical(fromHex("0x1.0000000000000cp-1022"), MIN+TINY) - identical(fromHex("0x1.0000000000000ep-1022"), MIN+TINY) - identical(fromHex("0x1.00000000000010p-1022"), MIN+TINY) - identical(fromHex("0x1.00000000000012p-1022"), MIN+TINY) - identical(fromHex("0x1.00000000000014p-1022"), MIN+TINY) - identical(fromHex("0x1.00000000000016p-1022"), MIN+TINY) - identical(fromHex("0x1.00000000000018p-1022"), MIN+2*TINY) - - # and near 1.0. - identical(fromHex("0x0.fffffffffffff0p0"), 1.0-EPS) - identical(fromHex("0x0.fffffffffffff1p0"), 1.0-EPS) - identical(fromHex("0X0.fffffffffffff2p0"), 1.0-EPS) - identical(fromHex("0x0.fffffffffffff3p0"), 1.0-EPS) - identical(fromHex("0X0.fffffffffffff4p0"), 1.0-EPS) - identical(fromHex("0X0.fffffffffffff5p0"), 1.0-EPS/2) - identical(fromHex("0X0.fffffffffffff6p0"), 1.0-EPS/2) - identical(fromHex("0x0.fffffffffffff7p0"), 1.0-EPS/2) - identical(fromHex("0x0.fffffffffffff8p0"), 1.0-EPS/2) - identical(fromHex("0X0.fffffffffffff9p0"), 1.0-EPS/2) - identical(fromHex("0X0.fffffffffffffap0"), 1.0-EPS/2) - identical(fromHex("0x0.fffffffffffffbp0"), 1.0-EPS/2) - identical(fromHex("0X0.fffffffffffffcp0"), 1.0) - identical(fromHex("0x0.fffffffffffffdp0"), 1.0) - identical(fromHex("0X0.fffffffffffffep0"), 1.0) - identical(fromHex("0x0.ffffffffffffffp0"), 1.0) - identical(fromHex("0X1.00000000000000p0"), 1.0) - identical(fromHex("0X1.00000000000001p0"), 1.0) - identical(fromHex("0x1.00000000000002p0"), 1.0) - identical(fromHex("0X1.00000000000003p0"), 1.0) - identical(fromHex("0x1.00000000000004p0"), 1.0) - identical(fromHex("0X1.00000000000005p0"), 1.0) - identical(fromHex("0X1.00000000000006p0"), 1.0) - identical(fromHex("0X1.00000000000007p0"), 1.0) - identical(fromHex("0x1.00000000000007ffffffffffffffffffffp0"), - 1.0) - identical(fromHex("0x1.00000000000008p0"), 1.0) - identical(fromHex("0x1.00000000000008000000000000000001p0"), - 1+EPS) - identical(fromHex("0X1.00000000000009p0"), 1.0+EPS) - identical(fromHex("0x1.0000000000000ap0"), 1.0+EPS) - identical(fromHex("0x1.0000000000000bp0"), 1.0+EPS) - identical(fromHex("0X1.0000000000000cp0"), 1.0+EPS) - identical(fromHex("0x1.0000000000000dp0"), 1.0+EPS) - identical(fromHex("0x1.0000000000000ep0"), 1.0+EPS) - identical(fromHex("0X1.0000000000000fp0"), 1.0+EPS) - identical(fromHex("0x1.00000000000010p0"), 1.0+EPS) - identical(fromHex("0X1.00000000000011p0"), 1.0+EPS) - identical(fromHex("0x1.00000000000012p0"), 1.0+EPS) - identical(fromHex("0X1.00000000000013p0"), 1.0+EPS) - identical(fromHex("0X1.00000000000014p0"), 1.0+EPS) - identical(fromHex("0x1.00000000000015p0"), 1.0+EPS) - identical(fromHex("0x1.00000000000016p0"), 1.0+EPS) - identical(fromHex("0X1.00000000000017p0"), 1.0+EPS) - identical(fromHex("0x1.00000000000017ffffffffffffffffffffp0"), - 1.0+EPS) - identical(fromHex("0x1.00000000000018p0"), 1.0+2*EPS) - identical(fromHex("0X1.00000000000018000000000000000001p0"), - 1.0+2*EPS) - identical(fromHex("0x1.00000000000019p0"), 1.0+2*EPS) - identical(fromHex("0X1.0000000000001ap0"), 1.0+2*EPS) - identical(fromHex("0X1.0000000000001bp0"), 1.0+2*EPS) - identical(fromHex("0x1.0000000000001cp0"), 1.0+2*EPS) - identical(fromHex("0x1.0000000000001dp0"), 1.0+2*EPS) - identical(fromHex("0x1.0000000000001ep0"), 1.0+2*EPS) - identical(fromHex("0X1.0000000000001fp0"), 1.0+2*EPS) - identical(fromHex("0x1.00000000000020p0"), 1.0+2*EPS) - when false: # TODO - test "bpo 44954": - identical(fromHex("0x.8p-1074"), 0.0) - identical(fromHex("0x.80p-1074"), 0.0) - identical(fromHex("0x.81p-1074"), TINY) - identical(fromHex("0x8p-1078"), 0.0) - identical(fromHex("0x8.0p-1078"), 0.0) - identical(fromHex("0x8.1p-1078"), TINY) - identical(fromHex("0x80p-1082"), 0.0) - identical(fromHex("0x81p-1082"), TINY) - identical(fromHex(".8p-1074"), 0.0) - identical(fromHex("8p-1078"), 0.0) - identical(fromHex("-.8p-1074"), -0.0) - identical(fromHex("+8p-1078"), 0.0) - -suite "float.fromhex and hex": - test "roundtrip": - def roundtrip(x): - return fromHex(toHex(x)) - for x in [NAN, INF, MAX, MIN, MIN-TINY, TINY, 0.0]: - identical(x, roundtrip(x)) - identical(-x, roundtrip(-x)) - for i in range(10000): - let - e = rand(-1200 .. 1200) - m = rand 1.0 - s = [1.0, -1.0][rand(1)] - try: - let x = s*ldexp(m, e) - identical(x, fromHex(toHex(x))) - except OverflowDefect: - discard - -suite "float": - test "hex": - check (-0.1).hex() == "-0x1.999999999999ap-4" - check 3.14159.hex() == "0x1.921f9f01b866ep+1" - test "test_nan_signs": - # The sign of float("nan") should be predictable. - check copysign(1.0, float("nan")) == 1.0 - check copysign(1.0, float("-nan")) == -1.0 - test "is_integer": - check not ((1.1).is_integer()) - check ((1.0).is_integer()) - check not (float("nan").is_integer()) - check not (float("inf").is_integer()) - test "as_integer_ratio": - for (f, ratio) in [ - (0.875, (7, 8)), - (-0.875, (-7, 8)), - (0.0, (0, 1)), - (11.5, (23, 2)), - ]: - check f.as_integer_ratio() == ratio - - for _ in range(10000): - var f = rand 1.0 - f *= pow(10.0, float rand(2 .. 10)) - #let (n, d) = f.as_integer_ratio() - let (n, d) = as_someinteger_ratio[BiggestInt](f) # if using as_integer_ratio when JS, will raise OverflowDefect - check almostEqual(n/d, f, unitsInLastPlace=5) - - check (0, 1) == float(0.0).as_integer_ratio() - check (5, 2) == float(2.5).as_integer_ratio() - check (1, 2) == float(0.5).as_integer_ratio() - when false and sizeof(system.int) > 4: # cannot pass - check ((system.int 4728779608739021, system.int 2251799813685248) == - (float(2.1).as_integer_ratio())) - check ((system.int -4728779608739021, system.int 2251799813685248) == - (float(-2.1).as_integer_ratio())) - check (-2100, 1) == float(-2100.0).as_integer_ratio() - - expect(OverflowDefect): discard Inf.as_integer_ratio() - expect(OverflowDefect): discard (-Inf).as_integer_ratio() - expect(ValueError): discard (NaN).as_integer_ratio() diff --git a/tests/testaments/builtins/titer_next.nim b/tests/testaments/builtins/titer_next.nim deleted file mode 100644 index 2400a138c..000000000 --- a/tests/testaments/builtins/titer_next.nim +++ /dev/null @@ -1,25 +0,0 @@ - -import pylib/builtins - -import std/unittest - -test "iter/next": - - let ls = list([1]) - - for i in iter(ls): check i == 1 - for i in iter(ls): check i == 1 - - let it = iter(ls) - - check next(it) == 1 - - expect StopIteration: - discard next(it) - - checkpoint "dict" - - let d = dict(a=1) - let dit = iter(d) - for i in dit: - check i == "a" diff --git a/tests/testaments/builtins/titers.nim b/tests/testaments/builtins/titers.nim deleted file mode 100644 index 9556b48f5..000000000 --- a/tests/testaments/builtins/titers.nim +++ /dev/null @@ -1,88 +0,0 @@ - -import pylib/builtins - -import std/unittest - -test "bltin iters": - var t: seq[(int, char)] - let res = list([(1,'a'), (2, 'b')]) - - template chk(name, body) = - checkpoint astToStr name - block: - body - t.setLen 0 - chk zip: - for i in zip([1, 2], "ab"): t.add i - check t == res - chk "enumerate(x, start)": - for i in enumerate("ab", start=1): t.add i - check t == res - -test "iters as iterable": - # function that filters vowels - proc fun(variable: char): bool = - return variable in ['a', 'e', 'i', 'o', 'u'] - - # sequence - let sequence = ['g', 'e', 'e', 'j', 'k', 'i', 's', 'p', 'r', 'e', 'o'] - template genFiltered(): untyped = filter(fun, sequence) - let filtered = genFiltered() - let res = @['e', 'e', 'i', 'e', 'o'] - var data: seq[char] - for s in filtered: - data.add s - - check data == res - - let nFiltered = genFiltered() - check list(nFiltered) == res - - let otherData = @[0, 1, 2, 3, 4, 5, 6, 7, 8, -1, 12412, 0, 31254, 0] - - let other = filter(None, otherData) - - check list(other) == @[1, 2, 3, 4, 5, 6, 7, 8, -1, 12412, 31254] - - -test "bltin iters": - var t: seq[(int, char)] - let res = list([(1,'a'), (2, 'b')]) - - template chk(name, body) = - checkpoint astToStr name - block: - body - t.setLen 0 - chk zip: - for i in zip([1, 2], "ab"): t.add i - check t == res - chk "enumerate(x, start)": - for i in enumerate("ab", start=1): t.add i - check t == res - -test "iters as iterable": - # function that filters vowels - proc fun(variable: char): bool = - return variable in ['a', 'e', 'i', 'o', 'u'] - - # sequence - let sequence = ['g', 'e', 'e', 'j', 'k', 'i', 's', 'p', 'r', 'e', 'o'] - template genFiltered(): untyped = filter(fun, sequence) - let filtered = genFiltered() - let res = @['e', 'e', 'i', 'e', 'o'] - var data: seq[char] - for s in filtered: - data.add s - - check data == res - - let nFiltered = genFiltered() - check list(nFiltered) == res - - let otherData = @[0, 1, 2, 3, 4, 5, 6, 7, 8, -1, 12412, 0, 31254, 0] - - let other = filter(None, otherData) - - check list(other) == @[1, 2, 3, 4, 5, 6, 7, 8, -1, 12412, 31254] - diff --git a/tests/testaments/builtins/tnumTypes.nim b/tests/testaments/builtins/tnumTypes.nim deleted file mode 100644 index 0cc667fd6..000000000 --- a/tests/testaments/builtins/tnumTypes.nim +++ /dev/null @@ -1,25 +0,0 @@ - -import pylib/builtins -import std/unittest - - -test "int(x[, base])": - let i = int("12") - check i == 12 - - var ii{.used.}: seq[int] ## test if int can be used as a type - - check int("a", 16) == 10 - - expect ValueError: - discard int("1", 33) - - checkpoint "with whitespace" - - check int(" -3") == -3 - -test "float(str)": - check NegInf == float("-INF") - let na = float("naN") - check na != na # NaN != NaN - diff --git a/tests/testaments/builtins/zip_more_args.nim b/tests/testaments/builtins/zip_more_args.nim deleted file mode 100644 index c1034fe0f..000000000 --- a/tests/testaments/builtins/zip_more_args.nim +++ /dev/null @@ -1,22 +0,0 @@ -discard """ - output: ''' -(1, 1, 1) -(2, 2, 2) -(3, 3, 3) -(1,) -(2,) -(3,) -true -''' - - #disable: defined(pylibDisableMoreArgsZip) XXX: not work -""" - -import pylib/builtins/iters - -let l = 1..3 - -for i in zip(l, l, l): echo i -for i in zip(l): echo i -echo compiles(zip(l, strict=false)) - diff --git a/tests/testaments/builtins/zip_no_seq.nim b/tests/testaments/builtins/zip_no_seq.nim deleted file mode 100644 index 188bdcb9f..000000000 --- a/tests/testaments/builtins/zip_no_seq.nim +++ /dev/null @@ -1,22 +0,0 @@ -discard """ - output: ''' -(1, 4) -(2, 5) -(3, 6) - -(1, 4) -(2, 5) -(3, 6) - -''' -""" -import pylib - -template test(a, b) = - for i in zip(a, b): - echo i - echo "" # newline - -test 1..3, 4..6 -test range(1,4), range(4,7) - diff --git a/tests/testaments/config.nims b/tests/testaments/config.nims deleted file mode 100644 index ac5825bc4..000000000 --- a/tests/testaments/config.nims +++ /dev/null @@ -1 +0,0 @@ ---path:"../src/" \ No newline at end of file diff --git a/tests/testaments/pysugar/autoSetListDict.nim b/tests/testaments/pysugar/autoSetListDict.nim deleted file mode 100644 index 550b9f50f..000000000 --- a/tests/testaments/pysugar/autoSetListDict.nim +++ /dev/null @@ -1,34 +0,0 @@ -discard """ - output: ''' -1 -1 -1 -''' -""" - -import pylib - - -def g(): - values = [ - complex(5.0, 12.0), - ] - aset = {5, 6} - - v = values[0] - - d = { - "v": v ** 1 - } - - ls = [ - "\ud800" - ] - - print(int(type(aset.pop()) == int)) - print(int(type(ls[0]) == type(u""))) - print(int(d["v"] == v)) - - -g() - diff --git a/tests/testaments/pysugar/colonToSlice.nim b/tests/testaments/pysugar/colonToSlice.nim deleted file mode 100644 index 849599809..000000000 --- a/tests/testaments/pysugar/colonToSlice.nim +++ /dev/null @@ -1,18 +0,0 @@ -discard """ - targets: "c js" - output: ''' -[2] -[1, 3, 4, 34] -4 -''' -""" -import pylib - -def f(): - ls = list([1, 2, 34]) - print(ls[1:2]) - ls[1:2] = [3, 4] - print(ls) - print(ls[2]) -f() - diff --git a/tests/testaments/pysugar/delitem.nim b/tests/testaments/pysugar/delitem.nim deleted file mode 100644 index 09b2a5140..000000000 --- a/tests/testaments/pysugar/delitem.nim +++ /dev/null @@ -1,18 +0,0 @@ -discard """ - output: ''' -[4] -''' -""" -import pylib - - -def f(): - ls = [1, 2, 3] - del ls[-1] - - ls.append(4) - - del ls[0:2] - print(ls) - -f() diff --git a/tests/testaments/pysugar/equalMinus.nim b/tests/testaments/pysugar/equalMinus.nim deleted file mode 100644 index f946e4cf1..000000000 --- a/tests/testaments/pysugar/equalMinus.nim +++ /dev/null @@ -1,23 +0,0 @@ - -discard """ - output: ''' --1 -''' -""" - -import pylib - - -def g(): - def f(x): - return x - - print(f(x=-1)) - - x = 3==-1 - assert not(5==-1) ## NOTE: par is a must! - ## or it'll be `not(5) == -1` in Nim - assert not x - -g() - diff --git a/tests/testaments/pysugar/strlitCat.nim b/tests/testaments/pysugar/strlitCat.nim deleted file mode 100644 index 6f4a0e611..000000000 --- a/tests/testaments/pysugar/strlitCat.nim +++ /dev/null @@ -1,20 +0,0 @@ -discard """ - targets: "c js" - output: ''' -abccd -1234abccd5\n -false -''' -""" -import pylib - -def f(): - s = f"abc" "cd" - print(s) - - ss = "123" f"4{s}5" fr"\n" - print(ss) - -f() - -echo compiles("sada" "asdsa") # outside `def` diff --git a/tests/testaments/pysugar/tripleStrTranslate.nim b/tests/testaments/pysugar/tripleStrTranslate.nim deleted file mode 100644 index ccb9ebe39..000000000 --- a/tests/testaments/pysugar/tripleStrTranslate.nim +++ /dev/null @@ -1,19 +0,0 @@ - -discard """ - output: ''' -true -true -''' -""" - -import pylib/pysugar - -def f(): return """\r""" - -def g(): - """NOTE: in Python this returns '\n\r' """ - return """ -\r""" - -echo f() == "\r" -echo g() == "\r" diff --git a/tests/testaments/pysugar/tsignature_generics.nim b/tests/testaments/pysugar/tsignature_generics.nim deleted file mode 100644 index b8c35f1b3..000000000 --- a/tests/testaments/pysugar/tsignature_generics.nim +++ /dev/null @@ -1,29 +0,0 @@ -discard """ - action: "compile" -""" -import pylib/pysugar -when PySignatureSupportGenerics: # pysince 3.13 - # "generics in func signature": - def f2[A, B](a: A, b: B) -> A: - # python cannot do: - return a + A(b) - - # "generics in class's methods": - - class O: - @staticmethod - def f2[A, B](a: A, b: B) -> A: - # python cannot do: - return a - A(b) - class X[T]: - x: T - def init(self, x: T): self.x = x - - - class C[T]: - def init[B](self, x: T, y: B) : - discard - - static: - assert f2(1.0, 1) == 2.0 - assert O.f2(int(1), float(1.0)) == 0 diff --git a/tests/tester.nim b/tests/tester.nim deleted file mode 100644 index 7c336f7d0..000000000 --- a/tests/tester.nim +++ /dev/null @@ -1,41 +0,0 @@ -import std/macros -import std/os as nos -from std/strutils import splitLines, strip, endsWith - -import pylib -import pylib/Lib/unittest - -when defined(js): - const jsExclude = slurp("./skipJs.txt").strip(chars={'\n'}).splitLines() - -# XXX: pyset just error on JS due to Nim-bug - -import std/unittest - -func mySplitFile(path: string): tuple[dir, last: string] = - # if JS on Windows, DirSep is '/' - # As a result: - # - os.parentDir() results in `.` - # - lastPathPart() results in origin args - let ls = strutils.rsplit(path, {DirSep, AltSep, '\\'}, 1) - (ls[0], ls[1]) - -macro gen = - result = newNimNode nnkIncludeStmt - let thisFile = currentSourcePath() - let thisDir = mySplitFile(thisFile)[0] #parentDir - for de in walkDir(thisDir): - if de.kind == pcDir: - continue - let fp = de.path - let fn = fp.mySplitFile()[1] #lastPathPart - if fp == thisFile: continue # avoid self-inclusion - if fn[0] == 't' and fn.endswith ".nim": - when defined(js): - let pureName = fn[1 ..< ^len".nim"] - if pureName in jsExclude: - continue - result.add newLit fp - #echo result.repr - -gen() diff --git a/tests/tfuncBody.nim b/tests/tfuncBody.nim deleted file mode 100644 index f40159775..000000000 --- a/tests/tfuncBody.nim +++ /dev/null @@ -1,35 +0,0 @@ - - -suite "rewrite as py stmt": - test "rewrite in `def`": - var c: int - # the following is typical Python code, with `check(x)` meaning assert. - def f(a, b): - c = a + b - return c - check(f(1, 2) == 3) - check(c == 0) - def inc_global(): - global c - c += 1 - inc_global() - check(c == 1) - - test "rewrite raise": - template pyexpect(exc; raise_body) = - block: - # HINT: `def`'s name won't be mangled bt template, - # so there's a block - def f(): - raise_body - expect exc: - f() - pyexpect ValueError: raise ValueError("foo") - pyexpect ValueError: raise ValueError - let exc = newException(OSError, "foo") - def f(): - raise ValueError from exc - try: f() - except ValueError as e: - check e.parent == exc - diff --git a/tests/tint_bytes_cvt.nim b/tests/tint_bytes_cvt.nim deleted file mode 100644 index c74753675..000000000 --- a/tests/tint_bytes_cvt.nim +++ /dev/null @@ -1,16 +0,0 @@ - -test "int.{from,to}_bytes": - checkpoint "int.to_bytes" - check (1).to_bytes(1, "big") == b"\x01" - check (1).to_bytes(2, "big") == b"\x00\x01" - check (1).to_bytes(2, "little") == b"\x01\x00" - check (-2).to_bytes(2, "little", signed=true) == b"\xfe\xff" - - checkpoint "int.from_bytes" - check NimInt.from_bytes(b"", "big", signed=true) == 0 - check NimInt.from_bytes(b"", "big", signed=true) == 0 - check NimInt.from_bytes(b"\x01\x00", "little") == 1 - check NimInt.from_bytes(b"\x00\x01", "big") == 1 - check NimInt.from_bytes(b"\xfe\xff", "little", signed=true) == -2 - check NimInt.from_bytes(b"\xfe\xff", "big", signed=true) == -257 - check NimInt.from_bytes(b"\x00\xff", "big", signed=true) == 255 diff --git a/tests/tintdiv.nim b/tests/tintdiv.nim deleted file mode 100644 index 88be79eaf..000000000 --- a/tests/tintdiv.nim +++ /dev/null @@ -1,9 +0,0 @@ -test "Floor division": - check(5.0 // 2 == 2.0) - check(5 // 2 == 2) - check(5 // 7 == 0) - check(-10 // 3 == -4) - check(5 // -6 == -1) - check(5 // -2 == -3) - check(5 // -3 == -2) - check(5 // -3.0 == -2.0) diff --git a/tests/tio.nim b/tests/tio.nim deleted file mode 100644 index 56f5d8b82..000000000 --- a/tests/tio.nim +++ /dev/null @@ -1,14 +0,0 @@ - - -test "io & with": - const fn = "tempfiletest" - with open(fn, "w") as f: - let nchar = f.write("c") - check nchar == 1 - check readFile(fn) == "c" - block: - var f = open(fn, "w+b") - f.write(br"123") - f.seek(0) - assert f.read() == br"123" - f.close() diff --git a/tests/tlib.nim b/tests/tlib.nim deleted file mode 100644 index 6a3b3509c..000000000 --- a/tests/tlib.nim +++ /dev/null @@ -1,31 +0,0 @@ -# XXX: While the coverage is rather low, -# considering many `Lib` of nimpylib are mostly wrapper around Nim's stdlib, -# we shall mainly focus on the cases where Python differs Nim, -# and leave the rest to Nim's own stdlib test. - - -const dunder_file = currentSourcePath() -when defined(js): - - func restrict_parentDir(s: string): string {.compileTime.}= - var idx = s.rfind '/' - if idx == -1: idx = s.rfind '\\' - assert idx != -1, "unreachable: not abs path from currentSourcePath()" - debugEcho s[0.. 5: - assert a == 6 - - if (b := 42.0) > 5.0: - assert b == 42.0 - - if (c := "hello") == "hello": - assert c == "hello" - - if (d := 'z') == 'z': - assert d == 'z' - -test "hex()": - check hex(23) == "0x17" - check hex(ord('a')) == "0x61" - check hex(231582835) == "0xdcdac73" - -test "chr()": - check chr(65) == 'A' - check chr(0x1F451) == "👑" - -test "oct()": - check oct(8) == "0o10" - check oct(-56) == "-0o70" - check oct(0) == "0o0" - -test "ord()": - check ord("👑") == 0x1F451 - check ord('A') == 65 - - -test "bin()": - check bin(1) == "0b1" - check bin(6) == "0b110" - when NimMajor > 1: - when compileOption("jsBigInt64"): - check bin(32587328532) == "0b11110010110010110110010110000010100" - check bin(-140140140140) == "-0b10000010100001000000001101011001101100" diff --git a/tests/tmodulo.nim b/tests/tmodulo.nim deleted file mode 100644 index babf2a23b..000000000 --- a/tests/tmodulo.nim +++ /dev/null @@ -1,50 +0,0 @@ -# import std/math # this has been done by `pylib` in `tester.nim` - - -test "Modulo operations": - check 6 % 2 == 0 - check 7 % 2 == 1 - check -5 % 3 == 1 - check -5 % -3 == -2 - check 12 % 7 == 5 - const results = @[ - "0: %4 %3 %2", "1:", "2: %2", "3: %3", "4: %4 %2", - "5:", "6: %3 %2", "7:", "8: %4 %2", "9: %3" - ] - - checkpoint "Evenly divisible numbers from 0 to 9" - var compare = newSeq[system.string]() - # XXX: For several months, I just cannot figure out - # why this string has to be prefixed. - # Or you will get "Error: expression 'string' has no type (or is ambiguous)" - for i in range(0, 10): - var line = $i & ":" - - if (i % 4) == 0: - line &= " %4" - - if (i % 3) == 0: - line &= " %3" - - if (i % 2) == 0: - line &= " %2" - compare.add(line) - check results == compare - - checkpoint "Even and odd operations with module" - const checkdata = @[ - (-3, false, true), (-2, true, false), (-1, false, true), - (0, true, false), (1, false, true), (2, true, false) - ] - var data = newSeq[tuple[a: int, b, c: bool]]() - proc even(number: int): bool = - ## Even numbers have no remainder when divided by 2. - return (number % 2) == 0 - - proc odd(number: int): bool = - ## Odd numbers have 1 or -1 remainder when divided by 2. - return (number % 2) != 0 - - for value in range(-3, 3): - data.add((value, even(value), odd(value))) - check checkdata == data diff --git a/tests/trange.nim b/tests/trange.nim deleted file mode 100644 index cd6065bc7..000000000 --- a/tests/trange.nim +++ /dev/null @@ -1,36 +0,0 @@ -from std/sequtils import toSeq - -test "Range-like Nim procedure": - # We don't need to check if iterators work because these "range" calls are - # just templates calling toSeq(range iterator(arguments)) - checkpoint "One argument - stop" - check len(range(1)) == 1 - check len(range(4,0)) == 0 - check toSeq(range(5)) == @[0, 1, 2, 3, 4] - checkpoint "Two arguments - start and stop" - check toSeq(range(3, 5)) == @[3, 4] - checkpoint "Negative start and positive stop" - check toSeq(range(-7, 3)) == @[-7, -6, -5, -4, -3, -2, -1, 0, 1, 2] - checkpoint "3 positive arguments" - check toSeq(range(1, 10, 3)) == @[1, 4, 7] - checkpoint "Positive start, negative stop and step" - check toSeq(range(0, -10, -2)) == @[0, -2, -4, -6, -8] - check toSeq(range(5, -5, -3)) == @[5, 2, -1, -4] - checkpoint "Variables" - const a = 10 - check toSeq(range(a, a + 2)) == @[a, a + 1] - checkpoint "Zero step" - expect ValueError: - discard toSeq(range(1, 2, 0)) - checkpoint "For loop" - var data: seq[int] = @[] - for x in range(0, -10, -2): - data.add(x) - check data == @[0, -2, -4, -6, -8] - let myrange = range(0, 41412423, 4122) - check 11566332 in myrange - check 1 notin myrange - check len(myrange) == 10047 - check myrange[5123] == 21117006 - check max(myrange) == 41409612 - check min(myrange) == 0 diff --git a/tests/tstrformat.nim b/tests/tstrformat.nim deleted file mode 100644 index a1182d1db..000000000 --- a/tests/tstrformat.nim +++ /dev/null @@ -1,4 +0,0 @@ - -test "str.format": - check "a {} b".format(1) == "a 1 b" - check "{0}0{0}".format(3) == "303" diff --git a/tests/tstring.nim b/tests/tstring.nim deleted file mode 100644 index 072d712da..000000000 --- a/tests/tstring.nim +++ /dev/null @@ -1,154 +0,0 @@ -test "str operations": - check "x" * 5 == "xxxxx" - check 'h' * 2 == "hh" - check 'h' == "h" - check 'h' + "ell" + 'o' == "hello" - check '0' + "1" + '2' == "012" - check ' '.join(["hello", "world"]) == "hello world" - check "\t\n ".isspace() - -test "str index": - let mixedStr = str("aδ_Δ") - check mixedStr[-1] == str("Δ") - check mixedStr[1] == str("δ") - check mixedStr[2] == str("_") - - -test "str methods": - checkpoint "split whitespace" - template eqList(a, b) = - check @a == @b - eqList str("a\u2000 \u2000b").split(), [str("a"),str("b")] ## \u2000 is of Unicode spaces - eqList str("1 2 3").split(maxsplit=1), [str("1"), str("2 3")] - - checkpoint "split with char sep" - eqList str("1 _2_ 3").split('_'), [str"1 ", str"2", str" 3"] - - checkpoint "split with str sep" - eqList "1 _2_ 3".split("_ "), [str"1 _2", str" 3"] - - checkpoint "rsplit" - eqList str("abc.list.txt").rsplit('.', 1), [str"abc.list", str"txt"] - - checkpoint "splitlines" - eqList str("1\u20282").splitlines(), [str"1", str"2"] - eqList str("1\u20282").splitlines(keepends=True), [str("1\u2028"), str"2"] - - check "Hi U".istitle() - - check "HELLO WORLD".isupper() - check not "c A".isupper() - check "hello ".islower() - - block: - let u = str("lj") # \u01c9 - check u.title() == "Lj" # \u01c8 - - check str("ῃ").title() == "ῌ" # \u1fcc - check str("aNd What").title() == "And What" - - check capitalize("aBΔ") == "Abδ" - check "HELLO WORLD".casefold() == "hello world" - - check "a".center(9) == " a " - check "a".center(1) == "a" - - check " ".join([1, 2, 3, 4, 5, 6, 7, 8, 9]) == "1 2 3 4 5 6 7 8 9" - check " ".join(['a', 'b', 'c', 'd', 'e']) == "a b c d e" - - check "".isascii() - check not "".isspace() - check "\x1c\x1d\x1e\x1f".isspace() - check " ".isspace() - check " ".isspace() - check " \u2000 ".isspace() - - check "hello world".index("w") == 6 - - # XXX: do not write: - #[ - check "a" or "b" == "a" - check "" or "b" == "b" - ]# - # which do not mean what you think from Python - - check ("a" or "b") == "a" - check ("" or "b") == "b" - - check fr"{666.0} Hello {42} World {true} ! {1 + 2}" == "666.0 Hello 42 World true ! 3" - check fr"" == "" - check fr" " == " " - check fr"""""" == "" - check fr""" """ == " " - check fr"hello {42}" & " world" == "hello 42 world" - - check not "abc".endswith("bc", 0, 2) - check "abc".endswith("bc", 0, 3) - - check "abc".endswith(("1", "c")) - - check "123".count("") == 4 - -test "str.maketrans&translate": - let self = (1,) # just a placeholder - template checkequalnofix(s: typeof(self), res, self: PyStr, args: varargs[untyped]) = - check self.translate(args) == res - template assertEqual(s: typeof(self), a, b) = - check a == b - - # copied from CPython/Lib/test/test_str.py StrTest.test_maketrans_translate - # with a little modification. - - # NOTE: some of the following tests takes the feature of untyped params, - # parsing dict literal with mixin value of NoneType, str, int - - # these work with plain translate() - self.checkequalnofix("bbbc", "abababc", PyStr.maketrans {'a': None}) - self.checkequalnofix("iiix", "abababc", - PyStr.maketrans {'a': None, 'b': 'i', 'c': "x"}) - self.checkequalnofix("c", "abababc", - PyStr.maketrans {'a': None, 'b': ""}) - - self.checkequalnofix("xyyx", "xzx", - PyStr.maketrans {'z': "yy"}) - - self.checkequalnofix("aaac", "abababc", - PyStr.maketrans {"b": ""}) - let tbl = PyStr.maketrans({"a": None, "b": ""}) - self.checkequalnofix("c", "abababc", tbl) - # test alternative way of calling maketrans() - let tbl2 = PyStr.maketrans("abc", "xyz", "d") - self.checkequalnofix("xyzzy", "abdcdcbdddd", tbl2) - - # various tests switching from ASCII to latin1 or the opposite; - # same length, remove a letter, or replace with a longer string. - self.assertEqual("[a]".translate(PyStr.maketrans("a", "X")), - "[X]") - self.assertEqual("[a]".translate(PyStr.maketrans({"a": "X"})), - "[X]") - self.assertEqual("[a]".translate(PyStr.maketrans({"a": None})), - "[]") - self.assertEqual("[a]".translate(PyStr.maketrans({"a": "XXX"})), - "[XXX]") - self.assertEqual("[a]".translate(PyStr.maketrans({"a": "\xe9"})), - "[\xe9]") - self.assertEqual("axb".translate(PyStr.maketrans({"a": None, "b": "123"})), - "x123") - self.assertEqual("axb".translate(PyStr.maketrans({"a": None, "b": "\xe9"})), - "x\xe9") - - # test non-ASCII (don't take the fast-path) - self.assertEqual("[a]".translate(PyStr.maketrans({"a": "<\xe9>"})), - "[<\xe9>]") - self.assertEqual("[\xe9]".translate(PyStr.maketrans({"\xe9": "a"})), - "[a]") - self.assertEqual("[\xe9]".translate(PyStr.maketrans({"\xe9": None})), - "[]") - self.assertEqual("[\xe9]".translate(PyStr.maketrans({"\xe9": "123"})), - "[123]") - self.assertEqual("[a\u03b1]".translate(PyStr.maketrans({"a": "<\u20ac>"})), - "[<\u20ac>\u03b1]") - - # CPython's test here uses `\xe9`, which is of Extended ASCII, - # and is in fact not UTF-8, (its UTF-8 binary reperentation is `\xxc3\xa9`) - # so I use `\u03b1` instead. diff --git a/tests/ttonim.nim b/tests/ttonim.nim deleted file mode 100644 index 113328d2e..000000000 --- a/tests/ttonim.nim +++ /dev/null @@ -1,23 +0,0 @@ -test "tonim macro": - tonim: - def add(x, y): - return x + y - - def subtract(x, y): - return x - y - - def multiply(x, y): - return x * y - - def divide(x, y): - return x / y - - def default_arg(x, y = 5): - return "hello" * y - - check add(5, 3) == 8 - check subtract(6, 3) == 3 - check multiply(5, 7) == 35 - check divide(35, 7) == 5 - check default_arg(0) == "hellohellohellohellohello" - diff --git a/tests/tunpack.nim b/tests/tunpack.nim deleted file mode 100644 index 224bdb292..000000000 --- a/tests/tunpack.nim +++ /dev/null @@ -1,41 +0,0 @@ -test "unpack macro": - block: - let data = @[1, 2, 3, 4] - let (a, b, c) = data.unpack(3) - check (a + b + c) == 6 - - block: - let data = "hello" - let (a, b, c) = data.unpack(3) - check (a & b & c) == "hel" - - block: - let data = @[1, 2, 3, 4, 5, 6] - data.unpack(a, b, c, *y, g) - check (a + b + c + g) == 12 - check y == @[4, 5] - - data.unpack(start, *ends) - check start == 1 - check ends == @[2, 3, 4, 5, 6] - - block: - let data = @[1, 2, 3, 4, 5, 6, 7] - data.unpack(a, *c, d, f) - check a == 1 - check c == @[2, 3, 4, 5] - check d == 6 - check f == 7 - - block: - let data = @[3, 1, 4, 2, 2, 8] - data.unpack(a, b, *_, c) - check (a + b + c) == (3 + 1 + 8) - - block: - type A = object - b: seq[int] - let c = A(b: @[1, 2, 2, 3, 4]) - - c.b.unpack(a, b, *_) - check (a + b) == 3 diff --git a/tests/twith.nim b/tests/twith.nim deleted file mode 100644 index 157a915c7..000000000 --- a/tests/twith.nim +++ /dev/null @@ -1,65 +0,0 @@ -import std/locks -import std/streams - -test "With statement": - let cont = "just a test" - template newStream(): untyped = newStringStream(cont) - - with newStream() as f: - check f.readLine() == "just a test" - - template open(l: Lock): untyped = l.acquire() - template close(l: Lock): untyped = l.release() - - var lck: Lock - lck.initLock() - - with lck: - check true - - type - SomeCtxManager = object - f: Stream - SomeOtherManager = object - - proc makeSomeCtxManager(): SomeCtxManager = - SomeCtxManager(f: newStream()) - - proc enter(s: SomeCtxManager): Stream = - s.f - - proc exit(s: SomeCtxManager) = - s.f.close() - - proc open(o: SomeOtherManager): string = - result = "Something else" - - proc close(o: SomeOtherManager) = - discard - - with makeSomeCtxManager() as f: - check f.readAll() == "just a test" - - with SomeOtherManager() as some: - check some == "Something else" - - # Nested - with newStream() as f1: - with newStream() as f2: - check f1.readLine() == f2.readLine() == "just a test" - - var ctx = makeSomeCtxManager() - var f = newStream() - # Multiple - with newStream() as f1, newStream(), - newStream() as f2, makeSomeCtxManager(), - ctx, f: - check f1.readLine() == f2.readLine() == f.readLine() == "just a test" - - # Discard context manager - with makeSomeCtxManager(): - discard - - # Discard a normal value - with newStream(): - discard \ No newline at end of file diff --git a/tests/utils.nim b/tests/utils.nim deleted file mode 100644 index 2d853a7c0..000000000 --- a/tests/utils.nim +++ /dev/null @@ -1,3 +0,0 @@ - -const - intOver64b* = 31415926535'i64 <= int64 high int diff --git a/theindex.html b/theindex.html new file mode 100644 index 000000000..2818b00ca --- /dev/null +++ b/theindex.html @@ -0,0 +1,6615 @@ + + + + + + + +Index + + + + + + + + + + + + + + + + +
+
+

Index

+ Modules:
pylib, pylib/Lib/collections/abc, pylib/Lib/errno, pylib/Lib/errno_impl/errnoConsts, pylib/Lib/errno_impl/errnoUtils, pylib/Lib/errno_impl/private/clike, pylib/Lib/errno_impl/private/errnos, pylib/Lib/errno_impl/private/errorcodeInit, pylib/Lib/errno_impl/private/exportUtils, pylib/Lib/errno_impl/private/loopErrno, pylib/Lib/errno_impl/private/singleton_errno, pylib/Lib/io, pylib/Lib/math, pylib/Lib/math_impl/cbrt, pylib/Lib/math_impl/comptime/cbrt, pylib/Lib/math_impl/comptime/common, pylib/Lib/math_impl/comptime/expm1, pylib/Lib/math_impl/comptime/log1p, pylib/Lib/math_impl/constsUtils, pylib/Lib/math_impl/err, pylib/Lib/math_impl/errnoUtils, pylib/Lib/math_impl/expm1_log1p, pylib/Lib/math_impl/frexp, pylib/Lib/math_impl/gammaXRange, pylib/Lib/math_impl/inWordUtils/assertIsLittleEndian, pylib/Lib/math_impl/inWordUtils/consts, pylib/Lib/math_impl/inWordUtils/float_view, pylib/Lib/math_impl/inWordUtils/fromWords, pylib/Lib/math_impl/inWordUtils/indices, pylib/Lib/math_impl/inWordUtils/toWords, pylib/Lib/math_impl/isX, pylib/Lib/math_impl/ldexp, pylib/Lib/math_impl/nextafter_step, pylib/Lib/math_impl/nextafter_ulp, pylib/Lib/math_impl/patch/consts, pylib/Lib/math_impl/patch/fma, pylib/Lib/math_impl/patch/gamma, pylib/Lib/math_impl/patch/inWordUtilsMapper, pylib/Lib/math_impl/patch/ldexp_frexp/assertIsInfinite, pylib/Lib/math_impl/patch/ldexp_frexp/exponent, pylib/Lib/math_impl/patch/ldexp_frexp/frexp, pylib/Lib/math_impl/patch/ldexp_frexp/ldexp, pylib/Lib/math_impl/patch/ldexp_frexp/normalize, pylib/Lib/math_impl/patch/lgamma, pylib/Lib/math_impl/patch/nextafter, pylib/Lib/math_impl/patch/nextafter_step, pylib/Lib/math_impl/patch/sinpi, pylib/Lib/math_impl/patch/trunc, pylib/Lib/math_impl/platformUtils, pylib/Lib/math_impl/polevl, pylib/Lib/math_impl/vec_op, pylib/Lib/math_impl/vec_op/dist, pylib/Lib/math_impl/vec_op/niter_types, pylib/Lib/math_impl/vec_op/private/dl_ops, pylib/Lib/math_impl/vec_op/sumprod, pylib/Lib/n_errno, pylib/Lib/n_math, pylib/Lib/n_sys, pylib/Lib/n_time, pylib/Lib/n_timeit, pylib/Lib/ncodec, pylib/Lib/os_impl/common, pylib/Lib/os_impl/consts, pylib/Lib/os_impl/posix_like/isatty, pylib/Lib/os_impl/posix_like/open_close, pylib/Lib/os_impl/posix_like/truncate, pylib/Lib/os_impl/private/defined_macros, pylib/Lib/private/platformInfo, pylib/Lib/private/platformUtils, pylib/Lib/signal_impl/c_py_handler_cvt, pylib/Lib/signal_impl/frames, pylib/Lib/signal_impl/pyatomic, pylib/Lib/signal_impl/pylifecycle, pylib/Lib/signal_impl/pynsig, pylib/Lib/signal_impl/state, pylib/Lib/sys, pylib/Lib/sys_impl/auditImpl, pylib/Lib/sys_impl/auditImpl/cfg, pylib/Lib/sys_impl/auditImpl/macrohelper, pylib/Lib/sys_impl/auditImpl/main, pylib/Lib/sys_impl/auditImpl/types, pylib/Lib/sys_impl/exits, pylib/Lib/sys_impl/fenvs, pylib/Lib/sys_impl/flagsImpl, pylib/Lib/sys_impl/flagsImpl/ct, pylib/Lib/sys_impl/flagsImpl/values, pylib/Lib/sys_impl/genargs, pylib/Lib/sys_impl/geninfos, pylib/Lib/sys_impl/genplatform, pylib/Lib/sys_impl/getencodings, pylib/Lib/sys_impl/sizes, pylib/Lib/sys_impl/stdio, pylib/Lib/sys_impl/util, pylib/Lib/time, pylib/Lib/time_impl/asctimeImpl, pylib/Lib/time_impl/converters, pylib/Lib/time_impl/measures, pylib/Lib/time_impl/nstrfptime, pylib/Lib/time_impl/private/doc_utils, pylib/Lib/time_impl/private/macro_utils, pylib/Lib/time_impl/sleep_impl, pylib/Lib/time_impl/strfptime, pylib/Lib/time_impl/struct_time_funcs, pylib/Lib/time_impl/types, pylib/Lib/timeit, pylib/Lib/typing_impl/easyImpl, pylib/Lib/warnings, pylib/Objects/obmalloc, pylib/Python/config_read_env, pylib/Python/envutils, pylib/Python/fileutils, pylib/Python/force_ascii_utils, pylib/Python/internal/pycore_fileutils, pylib/Python/localeutils, pylib/Python/pylifecycle/signal, pylib/Python/pylifecycle/signal/c_syms, pylib/Python/pylifecycle/signal/chk_util, pylib/Python/pylifecycle/signal/handler_types, pylib/Python/unicodeobject/char_decl, pylib/Python/unicodeobject/codecs, pylib/Python/unicodeobject/cstring_ptr_op, pylib/Python/unicodeobject/ptr_op, pylib/Python/unicodeobject/ptr_types, pylib/Python/unicodeobject/utf8_codec, pylib/Python/wchar_t, pylib/builtins, pylib/builtins/asciiImpl, pylib/builtins/attr, pylib/builtins/complex, pylib/builtins/dict, pylib/builtins/dict_decl, pylib/builtins/dirImpl, pylib/builtins/format, pylib/builtins/input, pylib/builtins/iter_next, pylib/builtins/iters, pylib/builtins/iters/macroutils, pylib/builtins/iters/mapMacro, pylib/builtins/iters/zipMacro, pylib/builtins/list, pylib/builtins/list_decl, pylib/builtins/mathfunc, pylib/builtins/min_max, pylib/builtins/misc, pylib/builtins/modPow, pylib/builtins/numTypes, pylib/builtins/oopFuncs, pylib/builtins/print, pylib/builtins/private/format_impl, pylib/builtins/private/mathutils, pylib/builtins/private/ncomplex_pow, pylib/builtins/private/pycore_pymath, pylib/builtins/private/strIter, pylib/builtins/pyerrors, pylib/builtins/pyhashes, pylib/builtins/pyrange, pylib/builtins/pyslice, pylib/builtins/pytuple, pylib/builtins/reprImpl, pylib/builtins/round, pylib/builtins/round/PY_SHORT_FLOAT_REPR, pylib/builtins/round/int_round, pylib/builtins/round/no_ndigit, pylib/builtins/round/reimporter, pylib/builtins/round_float, pylib/builtins/round_int, pylib/builtins/set, pylib/builtins/set_decl, pylib/builtins/str_byte, pylib/collections_abc, pylib/collections_abc/asyncs, pylib/collections_abc/collections, pylib/collections_abc/generators, pylib/collections_abc/iters, pylib/collections_abc/private/templ, pylib/impure/Python/mysnprintf, pylib/impure/math/dtoa, pylib/io, pylib/io_abc, pylib/mutSeqSliceOp, pylib/nimpatch/abs, pylib/nimpatch/floatdollar, pylib/nimpatch/nansign, pylib/nimpatch/newUninit, pylib/nimpatch/utils, pylib/nimpatch/winOpenFileHandle, pylib/noneType, pylib/numTypes, pylib/numTypes/floats, pylib/numTypes/floats/floathex, pylib/numTypes/floats/init, pylib/numTypes/floats/parse_inf_nan, pylib/numTypes/floats/parsefloat, pylib/numTypes/ints, pylib/numTypes/ints/bitops, pylib/numTypes/ints/decl, pylib/numTypes/ints/getter, pylib/numTypes/ints/init, pylib/numTypes/ints/int_bytes, pylib/numTypes/ints/longint, pylib/numTypes/ints/nint_proto, pylib/numTypes/reimporter, pylib/numTypes/utils/stripOpenArray, pylib/ops, pylib/ops/chk_shl, pylib/private/backendMark, pylib/private/encoding_norm, pylib/private/inspect_cleandoc, pylib/private/iterGen, pylib/private/trans_imp, pylib/pybool, pylib/pybytearray, pylib/pybytes, pylib/pybytes/bytesbltins, pylib/pybytes/bytesimpl, pylib/pybytes/bytesmeth, pylib/pybytes/bytesprefix, pylib/pybytes/hex, pylib/pybytes/split/common, pylib/pybytes/split/reimporter, pylib/pybytes/split/rsplit, pylib/pybytes/split/rsplit_whitespace, pylib/pybytes/split/split, pylib/pybytes/split/split_whitespace, pylib/pybytes/split/splitlinesIter, pylib/pybytes/strip, pylib/pybytes/translate, pylib/pyconfig/floats, pylib/pyconfig/main, pylib/pyconfig/os_consts, pylib/pyconfig/pycore/pymath, pylib/pyconfig/pycore/pymath/short_float_repr, pylib/pyconfig/signal, pylib/pyconfig/simp, pylib/pyconfig/util, pylib/pyerrors, pylib/pyerrors/aritherr, pylib/pyerrors/lkuperr, pylib/pyerrors/oserr, pylib/pyerrors/oserr/errmap, pylib/pyerrors/oserr/init, pylib/pyerrors/oserr/oserror_decl, pylib/pyerrors/oserr/oserror_new, pylib/pyerrors/oserr/oserror_str, pylib/pyerrors/oserr/types, pylib/pyerrors/rterr, pylib/pyerrors/signals, pylib/pyerrors/simperr, pylib/pyerrors/unicode_err, pylib/pystring, pylib/pystring/consts, pylib/pystring/format, pylib/pystring/fstring, pylib/pystring/split/common, pylib/pystring/split/reimporter, pylib/pystring/split/rsplit, pylib/pystring/split/rsplit_whitespace, pylib/pystring/split/split, pylib/pystring/split/split_whitespace, pylib/pystring/split/splitlinesIter, pylib/pystring/strbltins, pylib/pystring/strimpl, pylib/pystring/strip, pylib/pystring/strmeth, pylib/pystring/strops, pylib/pystring/strprefix, pylib/pystring/translate, pylib/pysugar, pylib/pysugar/class, pylib/pysugar/parserWithCfg, pylib/pysugar/pydef, pylib/pysugar/pywith, pylib/pysugar/stmt/chainCmp, pylib/pysugar/stmt/class, pylib/pysugar/stmt/decl, pylib/pysugar/stmt/decorator, pylib/pysugar/stmt/exprRewrite, pylib/pysugar/stmt/frame, pylib/pysugar/stmt/funcSignature, pylib/pysugar/stmt/pydef, pylib/pysugar/stmt/pyraise, pylib/pysugar/stmt/tonim, pylib/pysugar/stmt/types, pylib/pysugar/stmt/unpack, pylib/pysugar/tonim, pylib/pysugar/unpack, pylib/stringlib/errHandle, pylib/stringlib/format, pylib/stringlib/formats, pylib/stringlib/meth, pylib/stringlib/replaceWithCount, pylib/stringlib/split/common, pylib/stringlib/split/reimporter, pylib/stringlib/split/rsplit_whitespace, pylib/stringlib/split/split_whitespace, pylib/stringlib/split/splitlinesIter, pylib/translateEscape, pylib/version, pylib/versionInfo.

API symbols

+
`$`:
+
`%=`:
+
`%`:
+
`&=`:
+
`&`:
+
`'j`:
+
`**=`:
+
`**`:
+
`*=`:
+
`*`:
+
`+=`:
+
`+`:
+
`-=`:
+
`-`:
+
`//=`:
+
`//`:
+
`/=`:
+
`/`:
+
`:=`:
+
`<%`:
+
`<<=`:
+
`<<`:
+
`<=%`:
+
`<=`:
+
`<>`:
+
`<`:
+
`==`:
+
`>>=`:
+
`>>`:
+
`@`:
+
`[]=`:
+
`[]`:
+
`^=`:
+
`^`:
+
`and`:
+
`discard`:
+
`is`:
+
`not`:
+
`or`:
+
`xor`:
+
`|=`:
+
`|`:
+
`~`:
+
abs:
+
accessHighLow:
+
AC_CHECK_FUNC:
+
AC_CHECK_FUNCS:
+
AC_CHECK_HEADER:
+
AC_CHECK_HEADERS:
+
AC_CHECK_HEADER_THEN_FUNCS:
+
AC_LINK_IFELSE:
+
aclose:
+
ac_md_release:
+
acos:
+
acosh:
+
ACQUIRE_DTOA_LOCK:
+
AC_RUN_IFELSE:
+
add:
+
addaudit:
+
addaudithook:
+
addEachIter:
+
addFields:
+
add_from_bytes:
+
addLoopEach:
+
addPatch:
+
addResDecl:
+
addYield:
+
ALIGNOF_SIZE_T:
+
all:
+
allAlpha:
+
allocWcharArr:
+
altsep:
+
anext:
+
any:
+
append:
+
argv:
+
ArithmeticError:
+
ascii:
+
ASCII_CHAR_MASK:
+
asctime:
+
asctimeImpl:
+
asgSeqToObj:
+
asHashSet:
+
asin:
+
asinh:
+
as_integer_ratio:
+
asSeq:
+
as_someinteger_ratio:
+
asVersion:
+
async:
+
AsyncGenerator:
+
asyncImpl:
+
AsyncIterable:
+
AsyncIterator:
+
atan:
+
atan2:
+
atanh:
+
AttributeError:
+
audit:
+
autorange:
+
await:
+
Awaitable:
+
AX_C_FLOAT_WORDS_BIGENDIAN:
+
AX_C_FLOAT_WORDS_BIGENDIAN_def:
+
b:
+
BeforeFixedVer:
+
BIAS:
+
bin:
+
bit_count:
+
bit_length:
+
BlockingIOError:
+
bodySetItem:
+
bool:
+
br:
+
Br:
+
BrokenPipeError:
+
BufferedIOBase:
+
BufferedRandom:
+
BufferedReader:
+
BufferedWriter:
+
bytearray:
+
byteLen:
+
byteorder:
+
bytes:
+
BytesLike:
+
bytes_warning:
+
callToPyExpr:
+
CanIOOpenT:
+
capitalize:
+
casefold:
+
cbrt:
+
c_defined:
+
ceil:
+
center:
+
c_fma:
+
c_getenv:
+
chars:
+
checked_as_integer_ratio:
+
checkedShl:
+
check_force_ascii:
+
checkLenientOps:
+
ChildProcessError:
+
chr:
+
class:
+
classImpl:
+
c_ldexp:
+
clear:
+
CLEAR_EXP_MASK:
+
CLike:
+
clikeOr:
+
close:
+
closeImpl:
+
closerange:
+
ClosureIter:
+
cmpOnField:
+
CmpStragy:
+
Collection:
+
comb:
+
Comparable:
+
CompileBackend:
+
compileLittleEndian:
+
complex:
+
config_should_audit:
+
conjugate:
+
ConnectionAbortedError:
+
ConnectionError:
+
ConnectionRefusedError:
+
ConnectionResetError:
+
consumeDecorator:
+
Container:
+
contains:
+
copy:
+
copyright:
+
copysign:
+
Coroutine:
+
cos:
+
cosh:
+
count:
+
c_powi:
+
c_powu:
+
csEq:
+
c_setlocale:
+
CSigHandler:
+
c_signal:
+
csLhs:
+
csRhs:
+
csShorter:
+
ctime:
+
curdir:
+
deallocWcArr:
+
debug:
+
decl_c_int:
+
declErrorcodeWith:
+
declTupleWithNFieldsFrom:
+
DECODE_ERROR:
+
Decorator:
+
decorators:
+
def:
+
DEFAULT_BUFFER_SIZE:
+
default_number:
+
default_oserror:
+
default_repeat:
+
DefaultTimeFormat:
+
default_timer:
+
defAux:
+
DefEncoding:
+
DefErrors:
+
defImpl:
+
define:
+
DefNewLine:
+
defpath:
+
DEF_SIG:
+
DefSplitCap:
+
degrees:
+
del:
+
delitem:
+
DeprecationWarning:
+
dev_mode:
+
devnull:
+
dict:
+
difference:
+
difference_update:
+
dir:
+
dirImpl:
+
dist:
+
dist_checkedSameLen:
+
divmod:
+
dl_mul:
+
dl_sum:
+
docTable:
+
DocTable:
+
dont_write_bytecode:
+
DOUBLE_IS_ARM_MIXED_ENDIAN_IEEE754:
+
DOUBLE_IS_BIG_ENDIAN_IEEE754:
+
DOUBLE_IS_LITTLE_ENDIAN_IEEE754:
+
DoubleLength:
+
DoXxx:
+
dtoa:
+
dtoa_r:
+
dtToStructTime:
+
dunder_stderr:
+
dunder_stdin:
+
dunder_stdout:
+
DWin:
+
e:
+
E2BIG:
+
EACCES:
+
EADDRINUSE:
+
EADDRNOTAVAIL:
+
EADV:
+
EAFNOSUPPORT:
+
EAGAIN:
+
EALREADY:
+
EBADE:
+
EBADF:
+
EBADFD:
+
EBADMSG:
+
EBADR:
+
EBADRQC:
+
EBADSLT:
+
EBFONT:
+
EBUSY:
+
ECANCELED:
+
ECHILD:
+
ECHRNG:
+
ECOMM:
+
ECONNABORTED:
+
ECONNREFUSED:
+
ECONNRESET:
+
EDEADLK:
+
EDEADLOCK:
+
EDESTADDRREQ:
+
EDOM:
+
EDOTDOT:
+
EDQUOT:
+
EEXIST:
+
EFAULT:
+
EFBIG:
+
EHOSTDOWN:
+
EHOSTUNREACH:
+
EIDRM:
+
EILSEQ:
+
EINPROGRESS:
+
EINTR:
+
EINVAL:
+
EIO:
+
EISCONN:
+
EISDIR:
+
EISNAM:
+
EKEYEXPIRED:
+
EKEYREJECTED:
+
EKEYREVOKED:
+
EL2HLT:
+
EL2NSYNC:
+
EL3HLT:
+
EL3RST:
+
ELIBACC:
+
ELIBBAD:
+
ELIBEXEC:
+
ELIBMAX:
+
ELIBSCN:
+
ELNRNG:
+
ELOOP:
+
EMEDIUMTYPE:
+
EMFILE:
+
EMLINK:
+
emptyn:
+
emptyPyDict:
+
EMSGSIZE:
+
EMULTIHOP:
+
ENAMETOOLONG:
+
ENAVAIL:
+
EncErrors:
+
encoding:
+
encodings.normalize_encoding:
+
endsWith:
+
ENETDOWN:
+
ENETRESET:
+
ENETUNREACH:
+
ENFILE:
+
ENOANO:
+
ENOBUFS:
+
ENOCSI:
+
ENODATA:
+
ENODEV:
+
ENOENT:
+
ENOEXEC:
+
ENOKEY:
+
ENOLCK:
+
ENOLINK:
+
ENOMEDIUM:
+
ENOMEM:
+
ENOMSG:
+
ENONET:
+
ENOPKG:
+
ENOPROTOOPT:
+
ENOSPC:
+
ENOSR:
+
ENOSTR:
+
ENOSYS:
+
ENOTBLK:
+
ENOTCONN:
+
ENOTDIR:
+
ENOTEMPTY:
+
ENOTNAM:
+
ENOTRECOVERABLE:
+
ENOTSOCK:
+
ENOTSUP:
+
ENOTTY:
+
ENOTUNIQ:
+
enter:
+
enumerate:
+
ENXIO:
+
EOPNOTSUPP:
+
EOVERFLOW:
+
EOWNERDEAD:
+
EPERM:
+
EPFNOSUPPORT:
+
EPIPE:
+
EPROTO:
+
EPROTONOSUPPORT:
+
EPROTOTYPE:
+
ERANGE:
+
EREMCHG:
+
EREMOTE:
+
EREMOTEIO:
+
ERESTART:
+
erf:
+
erfc:
+
ERFKILL:
+
EROFS:
+
Errno:
+
errno:
+
ErrnoCount:
+
errnomap:
+
errnoMsg:
+
errors:
+
ESHUTDOWN:
+
ESOCKTNOSUPPORT:
+
ESPIPE:
+
ESRCH:
+
ESRMNT:
+
ESTALE:
+
ESTRPIPE:
+
ETIME:
+
ETIMEDOUT:
+
ETOOMANYREFS:
+
ETXTBSY:
+
EUCLEAN:
+
EULER:
+
EUNATCH:
+
EUSERS:
+
EWOULDBLOCK:
+
excl:
+
EXDEV:
+
executable:
+
EXFULL:
+
exit:
+
exp:
+
expandChain:
+
expandChainImpl:
+
expandtabs:
+
expandtabsImpl:
+
expm1:
+
EXP_MASK:
+
exponent:
+
exportAllErrnosViaEnumOrImportc:
+
exportIntBitOps:
+
exportSincePy:
+
extend:
+
extractDottedCalledDecorator:
+
extsep:
+
f:
+
fabs:
+
factorial:
+
False:
+
fetchDoc:
+
fields:
+
FileExistsError:
+
FileIO:
+
fileno:
+
FileNotFoundError:
+
filter:
+
Final:
+
find:
+
find1:
+
fitLen:
+
FixedVer:
+
flags:
+
float:
+
float_fromhex:
+
floatFromhexImpl:
+
float_info:
+
float_repr_style:
+
floor:
+
flush:
+
fma:
+
fmod:
+
force_ascii:
+
forErrno:
+
format:
+
fr:
+
Fr:
+
freedtoa:
+
FREE_DTOA_LOCK:
+
frexp:
+
from_bytes:
+
from_c_int:
+
from_c_int_expr:
+
from_c_int_underlined:
+
fromhex:
+
fromWords:
+
frozenset:
+
fspath:
+
fsum:
+
ftruncate:
+
gamma:
+
GammaError:
+
gcd:
+
geDom:
+
geGotNegInf:
+
genArgs:
+
genDelItem:
+
genDollarRepr:
+
Generator:
+
GeneratorExit:
+
genFlagsObj:
+
genGenericSetItem:
+
genInfos:
+
genIter:
+
genNonGenericSetItem:
+
genPlatform:
+
genWithArg:
+
genWithBracket:
+
geOk:
+
geOverFlow:
+
get:
+
getattr:
+
getChar:
+
getCharPtr:
+
getdefaultencoding:
+
getErrno:
+
getfilesystemencoding:
+
GET_FLOAT_WORD:
+
getFrameOrNil:
+
get_handler:
+
getLowWord:
+
getMaxChar:
+
getOrDefault:
+
getPlatform:
+
getPtr:
+
getSize:
+
getsizeof:
+
getThreadId:
+
geUnderFlow:
+
geZeroCantDetSign:
+
gmtime:
+
Handlers:
+
hasattr:
+
hasBug:
+
hasChar:
+
hash:
+
hash_randomization:
+
HAVEalarm:
+
HAVE_BROKEN_PTHREAD_SIGMASK:
+
HAVE_GCC_ASM_FOR_MC68881:
+
HAVE_GCC_ASM_FOR_X87:
+
HAVEgetitimer:
+
HAVE_MBRTOWC:
+
HAVEpause:
+
HAVEpthread_kill:
+
HAVEpthread_sigmask:
+
HAVE_PY_SET_53BIT_PRECISION:
+
HAVEsetitimer:
+
HAVEsigaction:
+
HAVEsigfillset:
+
HAVEsiginterrupt:
+
HAVEsigpending:
+
HAVE_SIGSET_T:
+
HAVEsigtimedwait:
+
HAVEsigwait:
+
HAVEsigwaitinfo:
+
HAVEstrsignal:
+
hex:
+
hexImpl:
+
hexversion:
+
HIGH:
+
HighWordFracBits:
+
HookEntry:
+
HookProc:
+
hugeF:
+
hypot:
+
ib_b:
+
ib_e:
+
ib_i:
+
id:
+
ifInvalidOnVcc:
+
ignore_environment:
+
imag:
+
imag=:
+
impExp:
+
impJsOrC:
+
implementation:
+
import_dtoa:
+
import_obmalloc:
+
import_pyconfig:
+
inc:
+
incl:
+
INCOMPLETE_CHARACTER:
+
index:
+
index1:
+
indices:
+
inf:
+
init:
+
init32FloatView:
+
init64FloatView:
+
initBufAsPy:
+
initDocTable:
+
initErrorcodeMap:
+
initNCodecInfo:
+
initPySignal:
+
initStructTime:
+
init_subclass:
+
InJs:
+
input:
+
insert:
+
inspect:
+
inspect.cleandoc:
+
int:
+
interactive:
+
InterruptedError:
+
intersection:
+
intersection_update:
+
int_max_str_digits:
+
IOBase:
+
iPosCeil:
+
IsADirectoryError:
+
isalnum:
+
isalpha:
+
isascii:
+
isatty:
+
isclose:
+
IS_CONTINUATION_BYTE:
+
isdigit:
+
isdisjoint:
+
isErr:
+
isErr0:
+
isfinite:
+
isinf:
+
isInfinite:
+
isinstance:
+
is_integer:
+
isLittleEndian:
+
islower:
+
isolated:
+
isqrt:
+
isqrtPositive:
+
isspace:
+
ISSPACE:
+
isspace:
+
IsSpaceAt:
+
issubclass:
+
issubset:
+
issuperset:
+
istitle:
+
istitleImpl:
+
isupper:
+
isUtcZone:
+
is_valid_wide_char:
+
items:
+
iter:
+
Iterable:
+
Iterator:
+
ITIMER_PROF:
+
ITIMER_REAL:
+
ITIMER_VIRTUAL:
+
j:
+
J:
+
join:
+
JsBigInt64Option:
+
KeyboardInterrupt:
+
keys:
+
lambda:
+
LC_ALL:
+
LC_CTYPE:
+
lcm:
+
ldexp:
+
len:
+
lgamma:
+
linesep:
+
list:
+
Literal:
+
ljust:
+
ln2_hi:
+
ln2_lo:
+
LocaleEncoding:
+
localtime:
+
log:
+
log10:
+
log1p:
+
log2:
+
long:
+
LookupError:
+
LOW:
+
lower:
+
lstrip:
+
Major:
+
makeIterable:
+
maketrans:
+
MantissaDigits:
+
map:
+
mapIterBodyImpl:
+
mapPathLike:
+
Mapping:
+
mapRaiseGammaErr:
+
math_is_error:
+
max:
+
MAX_EXPONENT:
+
MAX_GAMMA_X:
+
maxSafeInteger:
+
maxsize:
+
MAX_STIRLING:
+
MAX_SUBNORMAL_EXPONENT:
+
MAX_UNICODE_val:
+
MaxWStrLen:
+
mbstate_t:
+
memcpy:
+
min:
+
MIN_GAMMA_X:
+
Minor:
+
MIN_SUBNORMAL_EXPONENT:
+
mitems:
+
mixinOrderOnFields:
+
mktime:
+
modf:
+
monotonic:
+
monotonic_ns:
+
msg:
+
MS_WINDOWS:
+
ms_windows:
+
MutableSequence:
+
name:
+
NameError:
+
nan:
+
NCodecInfo:
+
new:
+
newBlockingIOError:
+
newGenericsTree:
+
newInt:
+
newLoop:
+
newNoEncTextIO:
+
newNullaryLambdaIter:
+
newProc:
+
newPyAsgnFrame:
+
newPyAsgnRewriter:
+
newPyByteArray:
+
newPyDict:
+
newPyDictImpl:
+
newPyFrozenSet:
+
newPyIterator:
+
newPyList:
+
newPyListOfCap:
+
newPyListOfStr:
+
newPyOSError:
+
newPySet:
+
newStmtWithAudit:
+
newStopIteration:
+
newTimer:
+
newTuple:
+
newUnicodeDecodeError:
+
next:
+
nextafter:
+
nextImpl:
+
n_frexp:
+
nimArrayAsList:
+
NimInt:
+
nimint:
+
NimSigHandler:
+
NimVersionTuple:
+
Ninf:
+
n_ldexp:
+
noBackend:
+
noBackends:
+
noEmptySep:
+
NoEncTextIOBase:
+
NoEncTextIOWrapper:
+
noInitVarDecl:
+
noJsBackend:
+
None:
+
NoneType:
+
noNimsBackend:
+
nonlocalAdd:
+
nonlocalContains:
+
normalize:
+
norm_maxsplit:
+
no_site:
+
NotADirectoryError:
+
NotImplDirectives:
+
NotImplementedError:
+
no_user_site:
+
noWeirdBackend:
+
noWeirdTarget:
+
NullaryFunc:
+
NullStmt:
+
O_APPEND:
+
O_ASYNC:
+
O_CLOEXEC:
+
O_CREAT:
+
oct:
+
O_DIRECT:
+
O_DIRECTORY:
+
O_DSYNC:
+
O_EXCL:
+
onceDeclInFrames:
+
O_NDELAY:
+
O_NOATIME:
+
O_NOCTTY:
+
O_NOFOLLOW:
+
O_NONBLOCK:
+
O_PATH:
+
open:
+
openarray_Check:
+
OpenarrayOrNimIter:
+
optimize:
+
ord:
+
ord1:
+
orderOnFields:
+
O_RDONLY:
+
O_RDWR:
+
orig_argv:
+
O_RSYNC:
+
OSErrorArgs:
+
osErrorMsgWithPath:
+
OSError_new:
+
oserror_use_init:
+
O_SYNC:
+
o_threshold:
+
O_TMPFILE:
+
O_TRUNC:
+
O_WRONLY:
+
p1evl:
+
pairs:
+
pardir:
+
parseBracketGenericParams:
+
parseDeclWithType:
+
parseGenericParams:
+
parse_inf_or_nan:
+
parsePyBody:
+
parsePyBodyWithDoc:
+
parsePyExpr:
+
parsePyFloat:
+
parsePyStmt:
+
parserWithDefCfg:
+
parseSignature:
+
parseSignatureMayGenerics:
+
parseSignatureNoGenerics:
+
partition:
+
pass:
+
Patch:
+
PathLike:
+
pathrepr:
+
pathsep:
+
perf_counter:
+
perf_counter_ns:
+
perm:
+
PermissionError:
+
pi:
+
Pinf:
+
platform:
+
platform.system:
+
platform.version:
+
polevl:
+
polExpd:
+
polExpd0:
+
pop:
+
popitem:
+
pow:
+
powu:
+
PreBreakCb:
+
preferredGenIterResName:
+
PREPARE_CAP:
+
prepareROErrno:
+
prepareRWErrno:
+
print:
+
print_exc:
+
ProcessLookupError:
+
process_time:
+
prod:
+
ptrdiff_t:
+
push:
+
pushDecorator:
+
Py_ADJUST_ERANGE1:
+
Py_ADJUST_ERANGE2:
+
pyalloc:
+
pyallocStr:
+
pyasciiImpl:
+
PyAsgnFrame:
+
PyAsgnRewriter:
+
Py_atomic_load:
+
Py_atomic_load_ptr:
+
Py_atomic_store:
+
Py_atomic_store_ptr:
+
PyBool:
+
pybool:
+
PyByteArray:
+
PyBytes:
+
pybytes:
+
PyComplex:
+
pycomplex:
+
Py_DecodeLocaleEx:
+
Py_DecodeUTF8Ex:
+
PyDedentDocString:
+
PyDict:
+
PyDictItemView:
+
PyDictKeyView:
+
PyDictValueView:
+
PyDictView:
+
pydiscard:
+
Py_ERROR_BACKSLASHREPLACE:
+
Py_error_handler:
+
Py_ERROR_IGNORE:
+
Py_ERROR_OTHER:
+
Py_ERROR_REPLACE:
+
Py_ERROR_STRICT:
+
Py_ERROR_SURROGATEESCAPE:
+
Py_ERROR_SURROGATEPASS:
+
Py_ERROR_UNKNOWN:
+
Py_ERROR_XMLCHARREFREPLACE:
+
Py_FORCE_UTF8_FS_ENCODING:
+
Py_FORCE_UTF8_LOCALE:
+
pyformat:
+
pyformatImplAux:
+
pyfree:
+
pyfreeStr:
+
PyFrozenSet:
+
Py_GetErrorHandler:
+
Py_GetForceASCII:
+
Py_GetLocaleEncoding:
+
Py_GIL_DISABLED:
+
Py_IS_ALIGNED:
+
PyIterator:
+
PyLibKey:
+
PyList:
+
PyMajor:
+
py_math_isclose_impl:
+
Py_mbrtowc:
+
Py_mbstowcs:
+
PyMinor:
+
Py_normalize_encoding:
+
Py_NSIG:
+
PyOSError:
+
PyOS_getsig:
+
PyOS_setsig:
+
PyOS_snprintf:
+
PyPatch:
+
PYPTHREAD_SIGMASK:
+
PyRange:
+
PyReleaseLevel:
+
PyReleaseLevelEnum:
+
pyrepr:
+
pyreprbImpl:
+
pyreprImpl:
+
Py_ResetForceASCII:
+
PySerial:
+
pyset:
+
PySet:
+
Py_SET_53BIT_PRECISION_END:
+
Py_SET_53BIT_PRECISION_HEADER:
+
Py_SET_53BIT_PRECISION_START:
+
pysetLit:
+
Py_SetLocaleFromEnv:
+
PySigHandler:
+
PySignal_Fini:
+
PySignatureSupportGenerics:
+
pysince:
+
PySlice:
+
PySlice1:
+
PyStr:
+
PySyntaxProcesser:
+
PySys_AddAuditHook:
+
PySys_Audit:
+
PyTComplex:
+
Py_UCS1:
+
Py_UCS2:
+
Py_UCS4:
+
Py_UNICODE_IS_SURROGATE:
+
Py_USING_MEMORY_DEBUGGER:
+
quiet:
+
radians:
+
raiseDomainErr:
+
raiseErrno:
+
raiseErrnoT:
+
raiseErrnoWithPath:
+
raiseExcWithPath:
+
raiseExcWithPath2:
+
raiseRangeErr:
+
raiseZipBound:
+
range:
+
rangeLen:
+
RawIOBase:
+
rb:
+
Rb:
+
read:
+
readline:
+
real:
+
real=:
+
recReplaceSuperCall:
+
redefineFlags:
+
ReleaseLevel:
+
remainder:
+
remove:
+
removeprefix:
+
removesuffix:
+
repeat:
+
replace:
+
repr:
+
reverse:
+
reversed:
+
rewriteDeclAux:
+
rewriteDeclInStmtAux:
+
rewriteRaise:
+
rf:
+
Rf:
+
rfind:
+
rfind1:
+
rGamma:
+
rindex:
+
rindex1:
+
rjust:
+
rLgamma:
+
round:
+
rounds:
+
rpartition:
+
rsplit:
+
rsplit_whitespace:
+
rstrip:
+
runeAtPos:
+
runeLenAt:
+
runes:
+
RuntimeError:
+
RuntimeWarning:
+
safe_path:
+
scipyGammaLn:
+
seek:
+
SEEK_CUR:
+
SEEK_END:
+
SEEK_SET:
+
sep:
+
Sequence:
+
Serial:
+
set:
+
setattr:
+
setdefault:
+
setenvOverwrite:
+
setErrno:
+
setErrno0:
+
setErrnoRaw:
+
SET_EXP_MASK:
+
set_handler:
+
setHighWord:
+
setLen:
+
setlocale:
+
sigaction:
+
SIGCLD:
+
SIGEMT:
+
SIGIO:
+
SIGIOT:
+
signal_global_state:
+
signal_state_t:
+
SIGPWR:
+
SIGRTMAX:
+
SIGRTMIN:
+
SIGSTKFLT:
+
SIGWINCH:
+
sin:
+
sinh:
+
sinpi:
+
Sized:
+
sleep:
+
slice:
+
SomePyDictView:
+
SomePySet:
+
SomeSet:
+
SomeSinglePyDictView:
+
Some_struct_time:
+
Some_struct_time_tuple:
+
sort:
+
sorted:
+
split:
+
splitlines:
+
split_whitespace:
+
sqrt:
+
SQRT_TWO_PI:
+
startsWith:
+
staticErrno:
+
stderr:
+
stdin:
+
stdlibJsGamma:
+
stdlibJsLgamma:
+
stdout:
+
StopAsyncIteration:
+
StopIteration:
+
StopIterationT:
+
str:
+
strerror:
+
strftime:
+
STRINGLIB_MUTABLE:
+
StringLike:
+
strip:
+
stripAsRange:
+
strIterImpl:
+
strptime:
+
strtod:
+
StrTypedTranslateTable:
+
struct_time:
+
structTimeToDt:
+
struct_time_tuple:
+
struct_time_tuple10:
+
struct_time_tuple11:
+
substr:
+
suf--:
+
sumprod:
+
symmetric_difference:
+
SystemExit:
+
tan:
+
tanh:
+
tau:
+
tell:
+
templWrapExportSincePy:
+
TextIOWrapper:
+
time:
+
timeit:
+
TimeitParam:
+
TimeItUseTime:
+
time_ns:
+
TimeoutError:
+
Timer:
+
tinyF:
+
title:
+
toBool:
+
to_bytes:
+
to_chars:
+
toCSighandler:
+
tonim:
+
toNimBool:
+
toNimComplex:
+
toNimIterator:
+
toNimSlice:
+
toNimStr:
+
toNimString:
+
toNimTable:
+
toPyBytes:
+
toPyDict:
+
toPyEnv:
+
toPyExpr:
+
toPyExprNoList:
+
toPySighandler:
+
toPySlice:
+
toPyStr:
+
toTuple:
+
toWords:
+
translate:
+
TranslateAction:
+
translateEscape:
+
translateEscapeWithErr:
+
TranslateTable:
+
TranslateTableABC:
+
TranslateTableVal:
+
TranslateValType:
+
True:
+
trunc:
+
truncate:
+
tryHandleDecorator:
+
tryOsOp:
+
TypedTranslateTableABC:
+
TypeError:
+
u:
+
ulp:
+
uname_release_major:
+
uncheckedTruncToInt:
+
UnicodeDecodeError:
+
UnicodeError:
+
unicodeSpaces:
+
union:
+
unpack:
+
unpackImpl:
+
unpackImplRec:
+
unpackWithLenImpl:
+
UNRELIABLE_FMA:
+
UnsupportedOperation:
+
update:
+
upper:
+
UserWarning:
+
UseSmallApprox:
+
Utf8:
+
utf8_decode:
+
utf8_mode:
+
values:
+
verbose:
+
version:
+
Version:
+
version_info:
+
warn:
+
warn_default_encoding:
+
Warning:
+
wchar_t:
+
weirdTarget:
+
whenAuditEnabled:
+
whenAuditEnabledOr:
+
whenDefErrno:
+
with:
+
WORDS_BIGENDIAN:
+
WORDS_LITTLEENDIAN:
+
wrapExportSincePy:
+
wrapTuple:
+
write:
+
wu_import:
+
X87_double_rounding:
+
ZeroDivisionError:
+
zfill:
+
zip:
+
zipIterBodyImpl:
+
+ +
+
+ + + diff --git a/tools/math/gamma_x_range.py b/tools/math/gamma_x_range.py deleted file mode 100644 index d7a562218..000000000 --- a/tools/math/gamma_x_range.py +++ /dev/null @@ -1,121 +0,0 @@ -'''calculate the very x in gamma(x) where gamma(x) haven't -over-underflow - -''' - -# result: -''' -''' - -from math import inf -from struct import pack, calcsize -from enum import Enum -from sys import byteorder -FloatType = Enum('FloatType', 'f32 f64') - -def in_bin_with_prefix(x: float, ftype): - ## returns 0b...'f32|f64 - if ftype==FloatType.f32: - format_ = 'f' - size = 32 - else: - format_ = 'd' - size = 64 - assert calcsize(format_) * 8 == size - format_ = '>' + format_ - - bs = pack(format_, x) - res = '0b' - for i in bs: - res += '{:b}'.format(i).zfill(8) + '_' - res = res[:-1] - #i = int.from_bytes(b, byteorder=byteorder, signed=True) - #res = '{:b}'.format(i).zfill(size) # '{:#{n}b}' cannot help - #if i < 0.0: - # assert res[0]=='-' - # res = res[1:] - return res - -# from sympy import gamma;tgamma = lambda x: float(gamma(x)) -from ctypes import cdll, c_double, c_float -libm = cdll['libm.so.6'] -def imp_f(func_name, Args = (c_float,), Res=(c_float)): - res = libm[func_name] - res.argtypes = Args - res.restype = Res - return res - -tgammaf = imp_f("tgammaf") -nextafterf = imp_f("nextafterf", (c_float, )*2) -tgamma = imp_f("tgamma", (c_double,), c_double) -nextafter = imp_f("nextafter", (c_double, )*2, c_double) - -def get_shreshold(neg): return 0.0 if neg else inf - -def main(): - def cal_and_print(ftype, tgamma, nextafter, ori_x): - suffix = ftype.name - (x, nx) = cal_very_x(tgamma, nextafter, ori_x) - - shreshold = get_shreshold(x<0.0) - assert tgamma(x) != shreshold - assert tgamma(nx) == shreshold - - pre = "MIN" if x < 0 else "MAX" - print( "## "+ pre + "_GAMMA_X" ) # header - - suffix = "'" + suffix - - print('',x, suffix, sep='') - #print('nextafter: ',nx,suffix, sep='') - print(in_bin_with_prefix(x, ftype),suffix, sep='') - print() - - def cal_f32(x): cal_and_print(FloatType.f32, tgammaf, nextafterf, x) - def cal_f64(x): cal_and_print(FloatType.f64, tgamma, nextafter, x) - cal_f32( "34.9" ) - cal_f32( "-38.6" ) - - cal_f64( "171.6") - cal_f64( "-177.7") - - -factor = 10 # this value is not that important, just a value greater than 1 -def cal_very_x(tgamma, nextafter, x, step=None): - assert x != 0.0 - if step is None: - #assert isinstance(x, (str, Fraction, Decimal)) - assert isinstance(x, str) # float might lost some accuracy from digit format - idx = x.rfind('.') - if idx == -1: pre = 1.0 - else: - istep = len(x) -1 - x.rfind('.') - pre = 10.0**(-istep) - x = float(x) - if x < 0.0: - pre = -pre - x = x - neg = x < 0.0 - shreshold = get_shreshold(neg) - direct = -inf if neg else inf - mini_step = lambda x: nextafter(x, direct) - x - while abs(pre) > abs(mini_step(x)): - x += pre - if tgamma(x) == shreshold: - x -= pre - pre /= factor - - # the following is necessary - # as float isn't incresing by digit - # but by method specified by IEEE-754 - nx = x - while tgamma(nx) != shreshold: - x = nx - nx = nextafter(x, direct) - - return x, nx - - -if __name__ == '__main__': - main() - diff --git a/tools/unicodedata/casefold_parse.nim b/tools/unicodedata/casefold_parse.nim deleted file mode 100644 index d7c83eca3..000000000 --- a/tools/unicodedata/casefold_parse.nim +++ /dev/null @@ -1,110 +0,0 @@ - -## parse -## https://www.unicode.org/Public/UCD/latest/ucd/CaseFolding.txt -## -## -## We use status of C and F, excluding T - -when not defined(ssl): - {.error: "compile using -d:ssl, or change CaseFoldingTxtUrl to `http` scheme".} -import std/os -const - CurSourcePath = currentSourcePath() - CurSourceDir = CurSourcePath.parentDir() - CurSourceName = CurSourcePath.lastPathPart() - -const - CaseFoldingTxtUrl{.strdefine.} ="https://www.unicode.org/Public/UCD/latest/ucd/CaseFolding.txt" - outfile{.strdefine.} = slurp(CurSourceDir/"unicase_outdir.txt") / "casefoldMapper.nim" - -import std/unicode -import std/strutils -import std/parseutils -import std/streams -type - RuneI = int32 - -var - CommonMapper: seq[(RuneI, RuneI)] - FullMapper: seq[(RuneI, string)] - -template assume(cond) = - when not defined(release): - assert cond - -proc parse(s: Stream) = - var - code, mapping1: RuneI - mappingStr: string - for line in s.lines: - if line.len == 0 or line[0] == '#': continue - - let ls = line.split(';') - let (codeS, statusS, mappingS) = (ls[0], ls[1], ls[2]) - - var parseRet: int - template getHex(i: int, s: string, start=0) = - parseRet = parseHex(s, i, start) - assume parseRet != 0 - - code.getHex codeS - assume statusS[0] == ' ' and mappingS[0] == ' ' - let status = statusS[1] - - case status - of 'C': - mapping1.getHex(mappingS, 1) - CommonMapper.add (code, mapping1) - of 'F': - let ls = mappingS.split(' ') - assume ls[0].len == 0 - mappingStr.setLen 0 - for i in 1..{ucs:>12}') - -print("}") - -ofile.close() diff --git a/tools/unicodedata/nim.cfg b/tools/unicodedata/nim.cfg deleted file mode 100644 index c2122709b..000000000 --- a/tools/unicodedata/nim.cfg +++ /dev/null @@ -1,2 +0,0 @@ ---define:"ssl" ---outdir:"../bin/" \ No newline at end of file diff --git a/tools/unicodedata/unicase_outdir.txt b/tools/unicodedata/unicase_outdir.txt deleted file mode 100644 index 24fcd6f91..000000000 --- a/tools/unicodedata/unicase_outdir.txt +++ /dev/null @@ -1 +0,0 @@ -src/pylib/pystring/unicase \ No newline at end of file