Compare commits
No commits in common. "devel" and "gh-pages" have entirely different histories.
4199 changed files with 330556 additions and 531503 deletions
9
.gitattributes
vendored
9
.gitattributes
vendored
|
|
@ -1,9 +0,0 @@
|
|||
# Avoids changelog conflicts by assuming additions-only, which is by far the common case.
|
||||
# In the rare case where branch b1 rebases against branch b2 and both branches
|
||||
# modified the same changelog entry, you'll end up with that changelog entry
|
||||
# duplicated, which is easily identifiable and fixable.
|
||||
/changelog.md merge=union
|
||||
|
||||
# bug https://github.com/dom96/choosenim/issues/256 for WSL CRLF
|
||||
*.sh text eol=lf
|
||||
/config/build_config.txt text eol=lf
|
||||
12
.github/FUNDING.yml
vendored
12
.github/FUNDING.yml
vendored
|
|
@ -1,12 +0,0 @@
|
|||
# These are supported funding model platforms
|
||||
|
||||
github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
|
||||
patreon: 'araq' # Replace with a single Patreon username
|
||||
open_collective: 'nim' # 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
|
||||
otechie: # Replace with a single Otechie username
|
||||
custom: 'https://nim-lang.org/donate.html' # Replace with a single custom sponsorship URL
|
||||
75
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
75
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
|
|
@ -1,75 +0,0 @@
|
|||
name: "Bug Report"
|
||||
description: "Create a new bug report. Have you found an unexpected behavior? Use this form."
|
||||
title: "Think about the title, twice."
|
||||
labels: ["unconfirmed"]
|
||||
body:
|
||||
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
- **Please provide a minimal code example that reproduces the Bug!** :bug:
|
||||
Reports with a reproducible example and descriptive detailed information will likely receive fixes faster.
|
||||
|
||||
- type: textarea
|
||||
id: description
|
||||
attributes:
|
||||
label: Description
|
||||
description: |
|
||||
Use DETAILED DESCRIPTIVE information about the problem.
|
||||
Here, you go into more details about your Bug report. This section can be a few paragraphs long.
|
||||
placeholder: Bug reports with reproducible code and detailed information will be fixed faster.
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: nim-version
|
||||
attributes:
|
||||
label: Nim Version
|
||||
description: Copy and paste the output of `nim -v` on the command line. For development versions, make sure to include the commit hash.
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: current-logs
|
||||
attributes:
|
||||
label: Current Output
|
||||
description: Please copy and paste any relevant log output. This will be automatically formatted into code, so no need for backticks.
|
||||
placeholder: Bug reports with reproducible code and detailed information will be fixed faster.
|
||||
render: text
|
||||
|
||||
- type: textarea
|
||||
id: expected-logs
|
||||
attributes:
|
||||
label: Expected Output
|
||||
description: Please copy and paste any relevant log output. This will be automatically formatted into code, so no need for backticks.
|
||||
placeholder: Bug reports with reproducible code and detailed information will be fixed faster.
|
||||
render: text
|
||||
|
||||
- type: textarea
|
||||
id: possible-solution
|
||||
attributes:
|
||||
label: Possible Solution
|
||||
description: Propose a possible solution.
|
||||
validations:
|
||||
required: false
|
||||
|
||||
- type: textarea
|
||||
id: extra-info
|
||||
attributes:
|
||||
label: Additional Information
|
||||
description: Any additional relevant information.
|
||||
validations:
|
||||
required: false
|
||||
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
- Thanks for your contributions!, your Bug report will receive feedback from the community soon...
|
||||
- Please check whether the problem still exists in the devel branch, see [rebuilding the compiler](https://nim-lang.github.io/Nim/intern.html#rebuilding-the-compiler).
|
||||
- Consider writing a PR targetting devel branch after filing this, see [contributing](https://nim-lang.github.io/Nim/contributing.html).
|
||||
- If it's a pre-existing compiler bug, see [Debugging the compiler](https://nim-lang.github.io/Nim/intern.html#debugging-the-compiler)
|
||||
which should give more context on a compiler crash.
|
||||
- If it's a regression, you can help us by identifying which version introduced the bug,
|
||||
see [Bisecting for regressions](https://nim-lang.github.io/Nim/intern.html#bisecting-for-regressions),
|
||||
or at least try known past releases (eg `choosenim 1.2.0`).
|
||||
- [Please, consider a Donation for the Nim project.](https://nim-lang.org/donate.html)
|
||||
10
.github/ISSUE_TEMPLATE/config.yml
vendored
10
.github/ISSUE_TEMPLATE/config.yml
vendored
|
|
@ -1,10 +0,0 @@
|
|||
contact_links:
|
||||
- name: Forum
|
||||
url: https://forum.nim-lang.org
|
||||
about: Please ask and answer questions here.
|
||||
- name: Discord
|
||||
url: https://discord.gg/nim
|
||||
about: Please ask and answer questions here.
|
||||
- name: Stack Overflow
|
||||
url: https://stackoverflow.com/questions/tagged/nim-lang
|
||||
about: Please ask and answer questions here.
|
||||
72
.github/ISSUE_TEMPLATE/feature_request.yml
vendored
72
.github/ISSUE_TEMPLATE/feature_request.yml
vendored
|
|
@ -1,72 +0,0 @@
|
|||
name: "Feature request"
|
||||
description: "Create a new Feature Request. Do you want to suggest a new feature? Use this form."
|
||||
title: "Think about the title, twice."
|
||||
labels: ["unconfirmed"]
|
||||
body:
|
||||
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
- Please provide a minimal code example that illustrates the basic idea behind your feature request.
|
||||
Reports with full repro code and descriptive detailed information will likely receive feedback faster.
|
||||
- There is a separate repository for the detailed RFCs and proposals: https://github.com/nim-lang/RFCs.
|
||||
If you have a simple feature request, you can post it here using this form,
|
||||
but bear in mind that adding new features to the language is currently a low priority.
|
||||
|
||||
- type: textarea
|
||||
id: summary
|
||||
attributes:
|
||||
label: Summary
|
||||
description: |
|
||||
Use DETAILED DESCRIPTIVE information about the feature request.
|
||||
Here, you go into more details about your ideas. This section can be a few paragraphs long.
|
||||
placeholder: Short summary of your proposed feature.
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: description
|
||||
attributes:
|
||||
label: Description
|
||||
description: Describe your solution, what problem does it fix?
|
||||
validations:
|
||||
required: true
|
||||
|
||||
- type: textarea
|
||||
id: alternatives
|
||||
attributes:
|
||||
label: Alternatives
|
||||
description: Are there any alternatives you've considered?
|
||||
validations:
|
||||
required: false
|
||||
|
||||
- type: textarea
|
||||
id: Examples
|
||||
attributes:
|
||||
label: Examples
|
||||
description: Provide examples for your feature request here.
|
||||
placeholder: Example code here.
|
||||
|
||||
- type: textarea
|
||||
id: incompatibility
|
||||
attributes:
|
||||
label: Backwards Compatibility
|
||||
description: If your Feature Request introduces backward-incompatible changes, describe them and propose how to deal with them.
|
||||
validations:
|
||||
required: false
|
||||
|
||||
- type: textarea
|
||||
id: links
|
||||
attributes:
|
||||
label: Links
|
||||
description: Please copy and paste any relevant links to projects, issues, discussions, technical documentations, code samples, etc.
|
||||
validations:
|
||||
required: false
|
||||
|
||||
- type: markdown
|
||||
attributes:
|
||||
value: |
|
||||
- Thanks for your contributions!, your ideas will receive feedback from the community soon...
|
||||
- **Remember to :star: Star the Nim project on GitHub!.**
|
||||
- Consider writing a PR targetting devel branch after filing this, see [contributing](https://nim-lang.github.io/Nim/contributing.html).
|
||||
- [Please, consider a Donation for the Nim project.](https://nim-lang.org/donate.html)
|
||||
69
.github/stale.yml
vendored
69
.github/stale.yml
vendored
|
|
@ -1,69 +0,0 @@
|
|||
# Configuration for probot-stale - https://github.com/probot/stale
|
||||
|
||||
# Number of days of inactivity before an Issue or Pull Request becomes stale
|
||||
daysUntilStale: 365
|
||||
|
||||
# Number of days of inactivity before an Issue or Pull Request with the stale label is closed.
|
||||
# Set to false to disable. If disabled, issues still need to be closed manually, but will remain marked as stale.
|
||||
daysUntilClose: 30
|
||||
|
||||
# Only issues or pull requests with all of these labels are check if stale. Defaults to `[]` (disabled)
|
||||
onlyLabels: []
|
||||
|
||||
# Issues or Pull Requests with these labels will never be considered stale. Set to `[]` to disable
|
||||
exemptLabels:
|
||||
- ARC
|
||||
- bounty
|
||||
- Codegen
|
||||
- Crash
|
||||
- Generics
|
||||
- High Priority
|
||||
- Macros
|
||||
- Next release
|
||||
- Showstopper
|
||||
- Static[T]
|
||||
|
||||
# Set to true to ignore issues in a project (defaults to false)
|
||||
exemptProjects: false
|
||||
|
||||
# Set to true to ignore issues in a milestone (defaults to false)
|
||||
exemptMilestones: false
|
||||
|
||||
# Set to true to ignore issues with an assignee (defaults to false)
|
||||
exemptAssignees: false
|
||||
|
||||
# Label to use when marking as stale
|
||||
staleLabel: stale
|
||||
|
||||
# Comment to post when marking as stale. Set to `false` to disable
|
||||
markComment: >
|
||||
This pull request has been automatically marked as stale because it has not had
|
||||
recent activity.
|
||||
If you think it is still a valid PR, please rebase it on the latest devel;
|
||||
otherwise it will be closed. Thank you for your contributions.
|
||||
|
||||
# Comment to post when removing the stale label.
|
||||
# unmarkComment: >
|
||||
# Your comment here.
|
||||
|
||||
# Comment to post when closing a stale Issue or Pull Request.
|
||||
# closeComment: >
|
||||
# Your comment here.
|
||||
|
||||
# Limit the number of actions per hour, from 1-30. Default is 30
|
||||
limitPerRun: 20
|
||||
|
||||
# Limit to only `issues` or `pulls`
|
||||
only: pulls
|
||||
|
||||
# Optionally, specify configuration settings that are specific to just 'issues' or 'pulls':
|
||||
# pulls:
|
||||
# daysUntilStale: 30
|
||||
# markComment: >
|
||||
# This pull request has been automatically marked as stale because it has not had
|
||||
# recent activity. It will be closed if no further activity occurs. Thank you
|
||||
# for your contributions.
|
||||
|
||||
# issues:
|
||||
# exemptLabels:
|
||||
# - confirmed
|
||||
118
.github/workflows/ci_docs.yml
vendored
118
.github/workflows/ci_docs.yml
vendored
|
|
@ -1,118 +0,0 @@
|
|||
name: Nim Docs CI
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- 'compiler/docgen.nim'
|
||||
- 'compiler/renderverbatim.nim'
|
||||
- 'config/nimdoc.cfg'
|
||||
- 'doc/**.rst'
|
||||
- 'doc/**.md'
|
||||
- 'doc/nimdoc.css'
|
||||
- 'lib/**.nim'
|
||||
- 'nimdoc/testproject/expected/testproject.html'
|
||||
- 'tools/dochack/dochack.nim'
|
||||
- 'tools/kochdocs.nim'
|
||||
- '.github/workflows/ci_docs.yml'
|
||||
- 'koch.nim'
|
||||
|
||||
pull_request:
|
||||
# Run only on changes on these files.
|
||||
paths:
|
||||
- 'compiler/docgen.nim'
|
||||
- 'compiler/renderverbatim.nim'
|
||||
- 'config/nimdoc.cfg'
|
||||
- 'doc/**.rst'
|
||||
- 'doc/**.md'
|
||||
- 'doc/nimdoc.css'
|
||||
- 'lib/**.nim'
|
||||
- 'nimdoc/testproject/expected/testproject.html'
|
||||
- 'tools/dochack/dochack.nim'
|
||||
- 'tools/kochdocs.nim'
|
||||
- '.github/workflows/ci_docs.yml'
|
||||
- 'koch.nim'
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
build:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
target: [linux, windows, osx]
|
||||
include:
|
||||
- target: linux
|
||||
os: ubuntu-20.04
|
||||
- target: windows
|
||||
os: windows-2019
|
||||
- target: osx
|
||||
os: macos-11
|
||||
|
||||
name: ${{ matrix.target }}
|
||||
runs-on: ${{ matrix.os }}
|
||||
timeout-minutes: 60 # refs bug #18178
|
||||
|
||||
steps:
|
||||
- name: 'Checkout'
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 2
|
||||
|
||||
- name: 'Install build dependencies (macOS)'
|
||||
if: runner.os == 'macOS'
|
||||
run: brew install make
|
||||
|
||||
- name: 'Install build dependencies (Windows)'
|
||||
if: runner.os == 'Windows'
|
||||
shell: bash
|
||||
run: |
|
||||
set -e
|
||||
. ci/funs.sh
|
||||
nimInternalInstallDepsWindows
|
||||
echo "${{ github.workspace }}/dist/mingw64/bin" >> "${GITHUB_PATH}"
|
||||
|
||||
- name: 'Add build binaries to PATH'
|
||||
shell: bash
|
||||
run: echo "${{ github.workspace }}/bin" >> "${GITHUB_PATH}"
|
||||
|
||||
- name: 'System information'
|
||||
shell: bash
|
||||
run: . ci/funs.sh && nimCiSystemInfo
|
||||
|
||||
- name: 'Build csourcesAny (posix)'
|
||||
# this would work on windows and other CI use this on windows,
|
||||
# but we ensure here that `ci/build_autogen.bat` keeps working on windows.
|
||||
if: runner.os != 'Windows'
|
||||
shell: bash
|
||||
run: . ci/funs.sh && nimBuildCsourcesIfNeeded CC=gcc
|
||||
# was previously using caching via `actions/cache@v1` but this wasn't
|
||||
# used in other CI pipelines and it's unclear the added complexity
|
||||
# was worth the saving; can be revisited if needed.
|
||||
|
||||
- name: 'Build csourcesAny (windows)'
|
||||
if: runner.os == 'Windows'
|
||||
shell: cmd
|
||||
run: ci/build_autogen.bat
|
||||
|
||||
- name: 'Build koch'
|
||||
shell: bash
|
||||
run: nim c koch
|
||||
|
||||
- name: 'Build the real compiler'
|
||||
shell: bash
|
||||
run: ./koch boot -d:release
|
||||
|
||||
- name: 'Build documentation'
|
||||
shell: bash
|
||||
run: ./koch doc --git.commit:devel
|
||||
|
||||
- name: 'Publish documentation to Github Pages'
|
||||
if: |
|
||||
github.event_name == 'push' && github.ref == 'refs/heads/devel' &&
|
||||
matrix.target == 'linux'
|
||||
uses: crazy-max/ghaction-github-pages@v3
|
||||
with:
|
||||
build_dir: doc/html
|
||||
env:
|
||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
74
.github/workflows/ci_packages.yml
vendored
74
.github/workflows/ci_packages.yml
vendored
|
|
@ -1,74 +0,0 @@
|
|||
name: Packages CI
|
||||
on:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- 'devel'
|
||||
- 'version-2-0'
|
||||
- 'version-1-6'
|
||||
- 'version-1-2'
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
build:
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-20.04, macos-11]
|
||||
cpu: [amd64]
|
||||
batch: ["allowed_failures", "0_3", "1_3", "2_3"] # list of `index_num`
|
||||
name: '${{ matrix.os }} (batch: ${{ matrix.batch }})'
|
||||
runs-on: ${{ matrix.os }}
|
||||
timeout-minutes: 60 # refs bug #18178
|
||||
env:
|
||||
NIM_TEST_PACKAGES: "1"
|
||||
NIM_TESTAMENT_BATCH: ${{ matrix.batch }}
|
||||
steps:
|
||||
- name: 'Checkout'
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 2
|
||||
|
||||
- name: 'Install node.js 16.x'
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: '16.x'
|
||||
|
||||
- name: 'Install dependencies (Linux amd64)'
|
||||
if: runner.os == 'Linux' && matrix.cpu == 'amd64'
|
||||
run: |
|
||||
sudo apt-fast update -qq
|
||||
DEBIAN_FRONTEND='noninteractive' \
|
||||
sudo apt-fast install --no-install-recommends -yq \
|
||||
libcurl4-openssl-dev libgc-dev libsdl1.2-dev libsfml-dev \
|
||||
valgrind libc6-dbg libblas-dev xorg-dev
|
||||
- name: 'Install dependencies (macOS)'
|
||||
if: runner.os == 'macOS'
|
||||
run: brew install boehmgc make sfml gtk+3
|
||||
- name: 'Install dependencies (Windows)'
|
||||
if: runner.os == 'Windows'
|
||||
shell: bash
|
||||
run: |
|
||||
set -e
|
||||
. ci/funs.sh
|
||||
nimInternalInstallDepsWindows
|
||||
echo_run echo "${{ github.workspace }}/dist/mingw64/bin" >> "${GITHUB_PATH}"
|
||||
|
||||
- name: 'Add build binaries to PATH'
|
||||
shell: bash
|
||||
run: echo "${{ github.workspace }}/bin" >> "${GITHUB_PATH}"
|
||||
|
||||
- name: 'System information'
|
||||
shell: bash
|
||||
run: . ci/funs.sh && nimCiSystemInfo
|
||||
|
||||
- name: 'Build csourcesAny'
|
||||
shell: bash
|
||||
run: . ci/funs.sh && nimBuildCsourcesIfNeeded CC=gcc ucpu='${{ matrix.cpu }}'
|
||||
|
||||
- name: 'koch, Run CI'
|
||||
shell: bash
|
||||
run: . ci/funs.sh && nimInternalBuildKochAndRunCI
|
||||
90
.github/workflows/ci_publish.yml
vendored
90
.github/workflows/ci_publish.yml
vendored
|
|
@ -1,90 +0,0 @@
|
|||
name: Tracking orc-booting compiler memory usage
|
||||
|
||||
on:
|
||||
pull_request_target:
|
||||
types: [closed]
|
||||
|
||||
|
||||
jobs:
|
||||
build:
|
||||
if: github.event.pull_request.merged == true
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
os: [ubuntu-20.04]
|
||||
cpu: [amd64]
|
||||
name: '${{ matrix.os }}'
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- name: 'Checkout'
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
fetch-depth: 2
|
||||
|
||||
- name: 'Install node.js 16.x'
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: '16.x'
|
||||
|
||||
- name: 'Install dependencies (Linux amd64)'
|
||||
if: runner.os == 'Linux' && matrix.cpu == 'amd64'
|
||||
run: |
|
||||
sudo apt-fast update -qq
|
||||
DEBIAN_FRONTEND='noninteractive' \
|
||||
sudo apt-fast install --no-install-recommends -yq \
|
||||
libcurl4-openssl-dev libgc-dev libsdl1.2-dev libsfml-dev \
|
||||
valgrind libc6-dbg libblas-dev xorg-dev
|
||||
- name: 'Install dependencies (macOS)'
|
||||
if: runner.os == 'macOS'
|
||||
run: brew install boehmgc make sfml gtk+3
|
||||
- name: 'Install dependencies (Windows)'
|
||||
if: runner.os == 'Windows'
|
||||
shell: bash
|
||||
run: |
|
||||
set -e
|
||||
. ci/funs.sh
|
||||
nimInternalInstallDepsWindows
|
||||
echo_run echo "${{ github.workspace }}/dist/mingw64/bin" >> "${GITHUB_PATH}"
|
||||
|
||||
- name: 'Add build binaries to PATH'
|
||||
shell: bash
|
||||
run: echo "${{ github.workspace }}/bin" >> "${GITHUB_PATH}"
|
||||
|
||||
- name: 'System information'
|
||||
shell: bash
|
||||
run: . ci/funs.sh && nimCiSystemInfo
|
||||
|
||||
- name: 'Build csourcesAny'
|
||||
shell: bash
|
||||
run: . ci/funs.sh && nimBuildCsourcesIfNeeded CC=gcc ucpu='${{ matrix.cpu }}'
|
||||
|
||||
- name: 'Build koch'
|
||||
shell: bash
|
||||
run: nim c koch
|
||||
|
||||
- name: 'Build Nim'
|
||||
shell: bash
|
||||
run: ./koch boot -d:release -d:nimStrictMode --lib:lib
|
||||
|
||||
- name: 'Action'
|
||||
shell: bash
|
||||
run: nim c -r -d:release ci/action.nim
|
||||
|
||||
- name: 'Comment'
|
||||
uses: actions/github-script@v6
|
||||
with:
|
||||
script: |
|
||||
const fs = require('fs');
|
||||
|
||||
try {
|
||||
const data = fs.readFileSync('ci/nimcache/results.txt', 'utf8');
|
||||
github.rest.issues.createComment({
|
||||
issue_number: context.issue.number,
|
||||
owner: context.repo.owner,
|
||||
repo: context.repo.repo,
|
||||
body: data
|
||||
})
|
||||
} catch (err) {
|
||||
console.error(err);
|
||||
}
|
||||
|
||||
112
.gitignore
vendored
112
.gitignore
vendored
|
|
@ -1,112 +0,0 @@
|
|||
*
|
||||
!**/
|
||||
!*.*
|
||||
|
||||
# Cache
|
||||
nimcache*/
|
||||
rnimcache*/
|
||||
dnimcache*/
|
||||
|
||||
*.o
|
||||
!/icons/*.o
|
||||
*.obj
|
||||
*.ilk
|
||||
*.exp
|
||||
*.pdb
|
||||
*.lib
|
||||
*.dll
|
||||
*.exe
|
||||
*.so
|
||||
*.dylib
|
||||
*.zip
|
||||
*.iss
|
||||
*.log
|
||||
*.pdb
|
||||
|
||||
mapping.txt
|
||||
tags
|
||||
install.sh
|
||||
deinstall.sh
|
||||
|
||||
doc/html/
|
||||
doc/*.html
|
||||
doc/pdf
|
||||
doc/*.idx
|
||||
/web/upload
|
||||
/build/*
|
||||
bin/*
|
||||
|
||||
# iOS specific wildcards.
|
||||
*.mode1v3
|
||||
*.pbxuser
|
||||
*.perspective
|
||||
*.perspectivev3
|
||||
*.swp
|
||||
.DS_Store
|
||||
.tags
|
||||
project.xcworkspace/
|
||||
xcuserdata/
|
||||
|
||||
# Generated files.
|
||||
/compile.json
|
||||
/compiler/nim.dot
|
||||
/reject.json
|
||||
/run.json
|
||||
/tools/dochack/dochack.js
|
||||
*.json
|
||||
/pkgstemp/**/*
|
||||
# for `nim doc foo.nim`
|
||||
/*.html
|
||||
lib/**/*.html
|
||||
#/testresults.html #covered by /*.html
|
||||
|
||||
/testresults.json
|
||||
testament.db
|
||||
/tests/**/*.json
|
||||
/tests/**/*.js
|
||||
|
||||
/csources
|
||||
/csources_v1
|
||||
/csources_v2
|
||||
|
||||
/dist/
|
||||
# /lib/fusion # fusion is now unbundled; `git status` should reveal if it's there so users can act on it
|
||||
|
||||
# Private directories and files (IDEs)
|
||||
.*/
|
||||
~*
|
||||
|
||||
# testament cruft; TODO: generate these in a gitignore'd dir (./build) in the first place.
|
||||
testresults/
|
||||
test.txt
|
||||
/test.ini
|
||||
|
||||
tweeter.db
|
||||
tweeter_test.db
|
||||
|
||||
/tests/megatest.nim
|
||||
/tests/ic/*_temp.nim
|
||||
/tests/navigator/*_temp.nim
|
||||
|
||||
|
||||
/outputExpected.txt
|
||||
/outputGotten.txt
|
||||
/t15148.txt
|
||||
/tests/vm/tfile_rw.txt
|
||||
|
||||
/lib/pure/*.js
|
||||
|
||||
!/.builds/
|
||||
|
||||
!/.github
|
||||
|
||||
# ignore debug dirs generated by dsymutil on OSX
|
||||
*.dSYM
|
||||
|
||||
# for `nim c -r nimdoc/tester` etc; this can be in multiple places
|
||||
htmldocs
|
||||
|
||||
## these are not needed anymore unless checkout old older versions
|
||||
nimdoc.out.css
|
||||
# except here:
|
||||
!/nimdoc/testproject/expected/*
|
||||
|
|
@ -1,62 +0,0 @@
|
|||
# xxx unused, out of date
|
||||
|
||||
image: ubuntu:18.04
|
||||
|
||||
stages:
|
||||
- pre-build
|
||||
- build
|
||||
- deploy
|
||||
- test
|
||||
|
||||
.linux_set_path: &linux_set_path_def
|
||||
before_script:
|
||||
- export PATH=$(pwd)/bin${PATH:+:$PATH}
|
||||
tags:
|
||||
- linux
|
||||
|
||||
.windows_set_path: &win_set_path_def
|
||||
before_script:
|
||||
- set PATH=%CD%\bin;%PATH%
|
||||
tags:
|
||||
- windows
|
||||
|
||||
|
||||
build-windows:
|
||||
stage: build
|
||||
script:
|
||||
- ci\build.bat
|
||||
artifacts:
|
||||
paths:
|
||||
- bin\nim.exe
|
||||
- bin\nimd.exe
|
||||
- compiler\nim.exe
|
||||
- koch.exe
|
||||
expire_in: 1 week
|
||||
tags:
|
||||
- windows
|
||||
|
||||
deploy-windows:
|
||||
stage: deploy
|
||||
script:
|
||||
- koch.exe winrelease
|
||||
artifacts:
|
||||
paths:
|
||||
- build/*.exe
|
||||
- build/*.zip
|
||||
expire_in: 1 week
|
||||
tags:
|
||||
- windows
|
||||
- fast
|
||||
|
||||
|
||||
|
||||
test-windows:
|
||||
stage: test
|
||||
<<: *win_set_path_def
|
||||
script:
|
||||
- call ci\deps.bat
|
||||
- nim c testament\tester
|
||||
- testament\tester.exe all
|
||||
tags:
|
||||
- windows
|
||||
- fast
|
||||
979
algorithm.html
Normal file
979
algorithm.html
Normal file
|
|
@ -0,0 +1,979 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<!-- This file is generated by Nim. -->
|
||||
<html xmlns="https://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>std/algorithm</title>
|
||||
|
||||
<!-- Favicon -->
|
||||
<link rel="shortcut icon" href="data:image/x-icon;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAUAAAAF////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAIAAABbAAAAlQAAAKIAAACbAAAAmwAAAKIAAACVAAAAWwAAAAL///8A////AP///wD///8A////AAAAABQAAADAAAAAYwAAAA3///8A////AP///wD///8AAAAADQAAAGMAAADAAAAAFP///wD///8A////AP///wAAAACdAAAAOv///wD///8A////AP///wD///8A////AP///wD///8AAAAAOgAAAJ3///8A////AP///wAAAAAnAAAAcP///wAAAAAoAAAASv///wD///8A////AP///wAAAABKAAAAKP///wAAAABwAAAAJ////wD///8AAAAAgQAAABwAAACIAAAAkAAAAJMAAACtAAAAFQAAABUAAACtAAAAkwAAAJAAAACIAAAAHAAAAIH///8A////AAAAAKQAAACrAAAAaP///wD///8AAAAARQAAANIAAADSAAAARf///wD///8AAAAAaAAAAKsAAACk////AAAAADMAAACcAAAAnQAAABj///8A////AP///wAAAAAYAAAAGP///wD///8A////AAAAABgAAACdAAAAnAAAADMAAAB1AAAAwwAAAP8AAADpAAAAsQAAAE4AAAAb////AP///wAAAAAbAAAATgAAALEAAADpAAAA/wAAAMMAAAB1AAAAtwAAAOkAAAD/AAAA/wAAAP8AAADvAAAA3gAAAN4AAADeAAAA3gAAAO8AAAD/AAAA/wAAAP8AAADpAAAAtwAAAGUAAAA/AAAA3wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAADfAAAAPwAAAGX///8A////AAAAAEgAAADtAAAAvwAAAL0AAADGAAAA7wAAAO8AAADGAAAAvQAAAL8AAADtAAAASP///wD///8A////AP///wD///8AAAAAO////wD///8A////AAAAAIcAAACH////AP///wD///8AAAAAO////wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A//8AAP//AAD4HwAA7/cAAN/7AAD//wAAoYUAAJ55AACf+QAAh+EAAAAAAADAAwAA4AcAAP5/AAD//wAA//8AAA=="/>
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAA3XAAAN1wFCKJt4AAAAB3RJTUUH4QQQEwksSS9ZWwAAAk1JREFUWMPtll2ITVEUx39nn/O7Y5qR8f05wtCUUr6ZIS++8pEnkZInPImneaCQ5METNdOkeFBKUhMPRIkHKfEuUZSUlGlKPN2TrgfncpvmnntnmlEyq1Z7t89/rf9a6+y99oZxGZf/XeIq61EdtgKXgdXA0xrYAvBjOIF1AI9zvjcC74BSpndrJPkBWDScTF8Aa4E3wDlgHbASaANmVqlcCnwHvgDvgVfAJ+AikAAvgfVZwLnSVZHZaOuKoQi3ZOMi4NkYkpe1p4J7A8BpYAD49hfIy/oqG0+hLomiKP2L5L+1ubn5115S+3OAn4EnwBlgMzCjyt6ZAnQCJ4A7wOs88iRJHvw50HoujuPBoCKwHWiosy8MdfZnAdcHk8dxXFJ3VQbQlCTJvRBCGdRbD4M6uc5glpY3eAihpN5S5w12diSEcCCEcKUO4ljdr15T76ur1FDDLIQQ3qv71EdDOe3Kxj3leRXyk+pxdWnFWod6Wt2bY3de3aSuUHcPBVimHs7mK9WrmeOF6lR1o9qnzskh2ar2qm1qizpfXaPeVGdlmGN5pb09qMxz1Xb1kLqgzn1RyH7JUXW52lr5e/Kqi9qpto7V1atuUzfnARrV7jEib1T76gG2qxdGmXyiekkt1GswPTtek0aBfJp6YySGBfWg2tPQ0FAYgf1stUfdmdcjarbYJEniKIq6gY/Aw+zWHAC+p2labGpqiorFYgGYCEzN7oQdQClN07O1/EfDyGgC0ALMBdYAi4FyK+4H3gLPsxfR1zRNi+NP7nH5J+QntnXe5B5mpfQAAAAASUVORK5CYII=">
|
||||
|
||||
<!-- CSS -->
|
||||
<link rel="stylesheet" type="text/css" href="nimdoc.out.css">
|
||||
|
||||
<!-- JS -->
|
||||
<script type="text/javascript" src="dochack.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="document" id="documentId">
|
||||
<div class="container">
|
||||
<h1 class="title">std/algorithm</h1>
|
||||
<div class="row">
|
||||
<div class="three columns">
|
||||
<div class="theme-select-wrapper">
|
||||
<label for="theme-select">Theme: </label>
|
||||
<select id="theme-select" onchange="setTheme(this.value)">
|
||||
<option value="auto">🌗 Match OS</option>
|
||||
<option value="dark">🌑 Dark</option>
|
||||
<option value="light">🌕 Light</option>
|
||||
</select>
|
||||
</div>
|
||||
<div id="global-links">
|
||||
<ul class="simple-boot">
|
||||
<li><a href="manual.html">Manual</a></li>
|
||||
<li><a href="lib.html">Standard library</a></li>
|
||||
<li> <a id="indexLink" href="theindex.html">Index</a></li>
|
||||
<li><a href="compiler/theindex.html">Compiler docs</a></li>
|
||||
<li><a href="https://nim-lang.github.io/fusion/theindex.html">Fusion docs</a></li>
|
||||
<li><a href="https://nim-lang.github.io/Nim/">devel</a>, <a href="https://nim-lang.org/documentation.html">stable</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="searchInputDiv">
|
||||
Search: <input type="search" id="searchInput"
|
||||
onkeyup="search()" />
|
||||
</div>
|
||||
|
||||
<ul class="simple simple-toc" id="toc-list">
|
||||
<li><a class="reference" id="basic-usage_toc" href="#basic-usage">Basic usage</a></li>
|
||||
<li><a class="reference" id="see-also_toc" href="#see-also">See also</a></li>
|
||||
<li>
|
||||
<a class="reference reference-toplevel" href="#6" id="56">Imports</a>
|
||||
</li>
|
||||
<li>
|
||||
<details open>
|
||||
<summary><a class="reference reference-toplevel" href="#7" id="57">Types</a></summary>
|
||||
<ul class="simple simple-toc-section">
|
||||
<li><a class="reference" href="#SortOrder" title="SortOrder = enum
|
||||
Descending, Ascending">SortOrder</a></li>
|
||||
|
||||
</ul>
|
||||
</details>
|
||||
</li>
|
||||
<li>
|
||||
<details open>
|
||||
<summary><a class="reference reference-toplevel" href="#12" id="62">Procs</a></summary>
|
||||
<ul class="simple simple-toc-section">
|
||||
<ul class="simple nested-toc-section">*
|
||||
<li><a class="reference" href="#%2A%2Cint%2CSortOrder" title="`*`(x: int; order: SortOrder): int">`*`(x: int; order: SortOrder): int</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">binarySearch
|
||||
<li><a class="reference" href="#binarySearch%2CopenArray%5BT%5D%2CK%2Cproc%28T%2CK%29" title="binarySearch[T, K](a: openArray[T]; key: K;
|
||||
cmp: proc (x: T; y: K): int {.closure.}): int">binarySearch[T, K](a: openArray[T]; key: K;
|
||||
cmp: proc (x: T; y: K): int {.closure.}): int</a></li>
|
||||
<li><a class="reference" href="#binarySearch%2CopenArray%5BT%5D%2CT" title="binarySearch[T](a: openArray[T]; key: T): int">binarySearch[T](a: openArray[T]; key: T): int</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">fill
|
||||
<li><a class="reference" href="#fill%2CopenArray%5BT%5D%2CNatural%2CNatural%2CT" title="fill[T](a: var openArray[T]; first, last: Natural; value: T)">fill[T](a: var openArray[T]; first, last: Natural; value: T)</a></li>
|
||||
<li><a class="reference" href="#fill%2CopenArray%5BT%5D%2CT" title="fill[T](a: var openArray[T]; value: T)">fill[T](a: var openArray[T]; value: T)</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">isSorted
|
||||
<li><a class="reference" href="#isSorted%2CopenArray%5BT%5D%2Cproc%28T%2CT%29" title="isSorted[T](a: openArray[T]; cmp: proc (x, y: T): int {.closure.};
|
||||
order = SortOrder.Ascending): bool">isSorted[T](a: openArray[T]; cmp: proc (x, y: T): int {.closure.};
|
||||
order = SortOrder.Ascending): bool</a></li>
|
||||
<li><a class="reference" href="#isSorted%2CopenArray%5BT%5D" title="isSorted[T](a: openArray[T]; order = SortOrder.Ascending): bool">isSorted[T](a: openArray[T]; order = SortOrder.Ascending): bool</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">lowerBound
|
||||
<li><a class="reference" href="#lowerBound%2CopenArray%5BT%5D%2CK%2Cproc%28T%2CK%29" title="lowerBound[T, K](a: openArray[T]; key: K; cmp: proc (x: T; k: K): int {.closure.}): int">lowerBound[T, K](a: openArray[T]; key: K; cmp: proc (x: T; k: K): int {.closure.}): int</a></li>
|
||||
<li><a class="reference" href="#lowerBound%2CopenArray%5BT%5D%2CT" title="lowerBound[T](a: openArray[T]; key: T): int">lowerBound[T](a: openArray[T]; key: T): int</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">merge
|
||||
<li><a class="reference" href="#merge%2Cseq%5BT%5D%2CopenArray%5BT%5D%2CopenArray%5BT%5D" title="merge[T](result: var seq[T]; x, y: openArray[T])">merge[T](result: var seq[T]; x, y: openArray[T])</a></li>
|
||||
<li><a class="reference" href="#merge%2Cseq%5BT%5D%2CopenArray%5BT%5D%2CopenArray%5BT%5D%2Cproc%28T%2CT%29" title="merge[T](result: var seq[T]; x, y: openArray[T];
|
||||
cmp: proc (x, y: T): int {.closure.})">merge[T](result: var seq[T]; x, y: openArray[T];
|
||||
cmp: proc (x, y: T): int {.closure.})</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">nextPermutation
|
||||
<li><a class="reference" href="#nextPermutation%2CopenArray%5BT%5D" title="nextPermutation[T](x: var openArray[T]): bool">nextPermutation[T](x: var openArray[T]): bool</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">prevPermutation
|
||||
<li><a class="reference" href="#prevPermutation%2CopenArray%5BT%5D" title="prevPermutation[T](x: var openArray[T]): bool">prevPermutation[T](x: var openArray[T]): bool</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">product
|
||||
<li><a class="reference" href="#product%2CopenArray%5Bseq%5BT%5D%5D" title="product[T](x: openArray[seq[T]]): seq[seq[T]]">product[T](x: openArray[seq[T]]): seq[seq[T]]</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">reverse
|
||||
<li><a class="reference" href="#reverse%2CopenArray%5BT%5D" title="reverse[T](a: var openArray[T])">reverse[T](a: var openArray[T])</a></li>
|
||||
<li><a class="reference" href="#reverse%2CopenArray%5BT%5D%2CNatural%2CNatural" title="reverse[T](a: var openArray[T]; first, last: Natural)">reverse[T](a: var openArray[T]; first, last: Natural)</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">reversed
|
||||
<li><a class="reference" href="#reversed%2CopenArray%5BT%5D" title="reversed[T](a: openArray[T]): seq[T]">reversed[T](a: openArray[T]): seq[T]</a></li>
|
||||
<li><a class="reference" href="#reversed%2CopenArray%5BT%5D%2CNatural%2Cint" title="reversed[T](a: openArray[T]; first: Natural; last: int): seq[T]">reversed[T](a: openArray[T]; first: Natural; last: int): seq[T]</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">rotatedLeft
|
||||
<li><a class="reference" href="#rotatedLeft%2CopenArray%5BT%5D%2Cint" title="rotatedLeft[T](arg: openArray[T]; dist: int): seq[T]">rotatedLeft[T](arg: openArray[T]; dist: int): seq[T]</a></li>
|
||||
<li><a class="reference" href="#rotatedLeft%2CopenArray%5BT%5D%2CHSlice%5Bint%2Cint%5D%2Cint" title="rotatedLeft[T](arg: openArray[T]; slice: HSlice[int, int]; dist: int): seq[T]">rotatedLeft[T](arg: openArray[T]; slice: HSlice[int, int]; dist: int): seq[T]</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">rotateLeft
|
||||
<li><a class="reference" href="#rotateLeft%2CopenArray%5BT%5D%2Cint" title="rotateLeft[T](arg: var openArray[T]; dist: int): int">rotateLeft[T](arg: var openArray[T]; dist: int): int</a></li>
|
||||
<li><a class="reference" href="#rotateLeft%2CopenArray%5BT%5D%2CHSlice%5Bint%2Cint%5D%2Cint" title="rotateLeft[T](arg: var openArray[T]; slice: HSlice[int, int]; dist: int): int">rotateLeft[T](arg: var openArray[T]; slice: HSlice[int, int]; dist: int): int</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">sort
|
||||
<li><a class="reference" href="#sort%2CopenArray%5BT%5D%2Cproc%28T%2CT%29" title="sort[T](a: var openArray[T]; cmp: proc (x, y: T): int {.closure.};
|
||||
order = SortOrder.Ascending)">sort[T](a: var openArray[T]; cmp: proc (x, y: T): int {.closure.};
|
||||
order = SortOrder.Ascending)</a></li>
|
||||
<li><a class="reference" href="#sort%2CopenArray%5BT%5D" title="sort[T](a: var openArray[T]; order = SortOrder.Ascending)">sort[T](a: var openArray[T]; order = SortOrder.Ascending)</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">sorted
|
||||
<li><a class="reference" href="#sorted%2CopenArray%5BT%5D%2Cproc%28T%2CT%29" title="sorted[T](a: openArray[T]; cmp: proc (x, y: T): int {.closure.};
|
||||
order = SortOrder.Ascending): seq[T]">sorted[T](a: openArray[T]; cmp: proc (x, y: T): int {.closure.};
|
||||
order = SortOrder.Ascending): seq[T]</a></li>
|
||||
<li><a class="reference" href="#sorted%2CopenArray%5BT%5D" title="sorted[T](a: openArray[T]; order = SortOrder.Ascending): seq[T]">sorted[T](a: openArray[T]; order = SortOrder.Ascending): seq[T]</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">upperBound
|
||||
<li><a class="reference" href="#upperBound%2CopenArray%5BT%5D%2CK%2Cproc%28T%2CK%29" title="upperBound[T, K](a: openArray[T]; key: K; cmp: proc (x: T; k: K): int {.closure.}): int">upperBound[T, K](a: openArray[T]; key: K; cmp: proc (x: T; k: K): int {.closure.}): int</a></li>
|
||||
<li><a class="reference" href="#upperBound%2CopenArray%5BT%5D%2CT" title="upperBound[T](a: openArray[T]; key: T): int">upperBound[T](a: openArray[T]; key: T): int</a></li>
|
||||
|
||||
</ul>
|
||||
|
||||
</ul>
|
||||
</details>
|
||||
</li>
|
||||
<li>
|
||||
<details open>
|
||||
<summary><a class="reference reference-toplevel" href="#18" id="68">Templates</a></summary>
|
||||
<ul class="simple simple-toc-section">
|
||||
<ul class="simple nested-toc-section">sortedByIt
|
||||
<li><a class="reference" href="#sortedByIt.t%2Cuntyped%2Cuntyped" title="sortedByIt(seq1, op: untyped): untyped">sortedByIt(seq1, op: untyped): untyped</a></li>
|
||||
|
||||
</ul>
|
||||
|
||||
</ul>
|
||||
</details>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
<div class="nine columns" id="content">
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/algorithm.nim#L1" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/algorithm.nim#L1" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
<div id="tocRoot"></div>
|
||||
|
||||
<p class="module-desc">This module implements some common generic algorithms on <tt class="docutils literal"><span class="pre"><span class="Identifier">openArray</span></span></tt>s.
|
||||
<h1><a class="toc-backref" id="basic-usage" href="#basic-usage">Basic usage</a></h1>
|
||||
<p><strong class="examples_text">Example:</strong></p>
|
||||
<pre class="listing"><span class="Keyword">import</span> <span class="Identifier">std</span><span class="Operator">/</span><span class="Identifier">algorithm</span>
|
||||
<span class="Keyword">type</span> <span class="Identifier">People</span> <span class="Operator">=</span> <span class="Keyword">tuple</span>
|
||||
<span class="Identifier">year</span><span class="Punctuation">:</span> <span class="Identifier">int</span>
|
||||
<span class="Identifier">name</span><span class="Punctuation">:</span> <span class="Identifier">string</span>
|
||||
|
||||
<span class="Keyword">var</span> <span class="Identifier">a</span><span class="Punctuation">:</span> <span class="Identifier">seq</span><span class="Punctuation">[</span><span class="Identifier">People</span><span class="Punctuation">]</span>
|
||||
|
||||
<span class="Identifier">a</span><span class="Operator">.</span><span class="Identifier">add</span><span class="Punctuation">(</span><span class="Punctuation">(</span><span class="DecNumber">2000</span><span class="Punctuation">,</span> <span class="StringLit">"John"</span><span class="Punctuation">)</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">a</span><span class="Operator">.</span><span class="Identifier">add</span><span class="Punctuation">(</span><span class="Punctuation">(</span><span class="DecNumber">2005</span><span class="Punctuation">,</span> <span class="StringLit">"Marie"</span><span class="Punctuation">)</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">a</span><span class="Operator">.</span><span class="Identifier">add</span><span class="Punctuation">(</span><span class="Punctuation">(</span><span class="DecNumber">2010</span><span class="Punctuation">,</span> <span class="StringLit">"Jane"</span><span class="Punctuation">)</span><span class="Punctuation">)</span>
|
||||
|
||||
<span class="Comment"># Sorting with default system.cmp</span>
|
||||
<span class="Identifier">a</span><span class="Operator">.</span><span class="Identifier">sort</span><span class="Punctuation">(</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">a</span> <span class="Operator">==</span> <span class="Operator">@</span><span class="Punctuation">[</span><span class="Punctuation">(</span><span class="Identifier">year</span><span class="Punctuation">:</span> <span class="DecNumber">2000</span><span class="Punctuation">,</span> <span class="Identifier">name</span><span class="Punctuation">:</span> <span class="StringLit">"John"</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Punctuation">(</span><span class="Identifier">year</span><span class="Punctuation">:</span> <span class="DecNumber">2005</span><span class="Punctuation">,</span> <span class="Identifier">name</span><span class="Punctuation">:</span> <span class="StringLit">"Marie"</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
|
||||
<span class="Punctuation">(</span><span class="Identifier">year</span><span class="Punctuation">:</span> <span class="DecNumber">2010</span><span class="Punctuation">,</span> <span class="Identifier">name</span><span class="Punctuation">:</span> <span class="StringLit">"Jane"</span><span class="Punctuation">)</span><span class="Punctuation">]</span>
|
||||
|
||||
<span class="Keyword">proc</span> <span class="Identifier">myCmp</span><span class="Punctuation">(</span><span class="Identifier">x</span><span class="Punctuation">,</span> <span class="Identifier">y</span><span class="Punctuation">:</span> <span class="Identifier">People</span><span class="Punctuation">)</span><span class="Punctuation">:</span> <span class="Identifier">int</span> <span class="Operator">=</span>
|
||||
<span class="Identifier">cmp</span><span class="Punctuation">(</span><span class="Identifier">x</span><span class="Operator">.</span><span class="Identifier">name</span><span class="Punctuation">,</span> <span class="Identifier">y</span><span class="Operator">.</span><span class="Identifier">name</span><span class="Punctuation">)</span>
|
||||
|
||||
<span class="Comment"># Sorting with custom proc</span>
|
||||
<span class="Identifier">a</span><span class="Operator">.</span><span class="Identifier">sort</span><span class="Punctuation">(</span><span class="Identifier">myCmp</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">a</span> <span class="Operator">==</span> <span class="Operator">@</span><span class="Punctuation">[</span><span class="Punctuation">(</span><span class="Identifier">year</span><span class="Punctuation">:</span> <span class="DecNumber">2010</span><span class="Punctuation">,</span> <span class="Identifier">name</span><span class="Punctuation">:</span> <span class="StringLit">"Jane"</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Punctuation">(</span><span class="Identifier">year</span><span class="Punctuation">:</span> <span class="DecNumber">2000</span><span class="Punctuation">,</span> <span class="Identifier">name</span><span class="Punctuation">:</span> <span class="StringLit">"John"</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
|
||||
<span class="Punctuation">(</span><span class="Identifier">year</span><span class="Punctuation">:</span> <span class="DecNumber">2005</span><span class="Punctuation">,</span> <span class="Identifier">name</span><span class="Punctuation">:</span> <span class="StringLit">"Marie"</span><span class="Punctuation">)</span><span class="Punctuation">]</span></pre>
|
||||
<h1><a class="toc-backref" id="see-also" href="#see-also">See also</a></h1><ul class="simple"><li><a class="reference external" href="sequtils.html">sequtils module</a> for working with the built-in seq type</li>
|
||||
<li><a class="reference external" href="tables.html">tables module</a> for sorting tables</li>
|
||||
</ul>
|
||||
</p>
|
||||
<div class="section" id="6">
|
||||
<h1><a class="toc-backref" href="#6">Imports</a></h1>
|
||||
<dl class="item">
|
||||
<a class="reference external" href="since.html">since</a>, <a class="reference external" href="assertions.html">assertions</a>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="section" id="7">
|
||||
<h1><a class="toc-backref" href="#7">Types</a></h1>
|
||||
<dl class="item">
|
||||
<div id="SortOrder">
|
||||
<dt><pre><a href="algorithm.html#SortOrder"><span class="Identifier">SortOrder</span></a> <span class="Other">=</span> <span class="Keyword">enum</span>
|
||||
<span class="Identifier">Descending</span><span class="Other">,</span> <span class="Identifier">Ascending</span></pre></dt>
|
||||
<dd>
|
||||
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/algorithm.nim#L52" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/algorithm.nim#L52" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</dl>
|
||||
</div>
|
||||
<div class="section" id="12">
|
||||
<h1><a class="toc-backref" href="#12">Procs</a></h1>
|
||||
<dl class="item">
|
||||
<div id="*-procs-all">
|
||||
<div id="*,int,SortOrder">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#%2A%2Cint%2CSortOrder"><span class="Identifier">`*`</span></a><span class="Other">(</span><span class="Identifier">x</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a><span class="Other">;</span> <span class="Identifier">order</span><span class="Other">:</span> <a href="algorithm.html#SortOrder"><span class="Identifier">SortOrder</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a> {.<span class="Identifier">inline</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
|
||||
<span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Flips the sign of <tt class="docutils literal"><span class="pre"><span class="Identifier">x</span></span></tt> if <tt class="docutils literal"><span class="pre"><span class="Identifier">order</span> <span class="Operator">==</span> <span class="Identifier">Descending</span></span></tt>. If <tt class="docutils literal"><span class="pre"><span class="Identifier">order</span> <span class="Operator">==</span> <span class="Identifier">Ascending</span></span></tt> then <tt class="docutils literal"><span class="pre"><span class="Identifier">x</span></span></tt> is returned.</p>
|
||||
<p><tt class="docutils literal"><span class="pre"><span class="Identifier">x</span></span></tt> is supposed to be the result of a comparator, i.e.<p><tt class="docutils literal"><span class="pre"><span class="Operator"><</span> <span class="DecNumber">0</span></span></tt> for <em>less than</em>,<br/><tt class="docutils literal"><span class="pre"><span class="Operator">==</span> <span class="DecNumber">0</span></span></tt> for <em>equal</em>,<br/><tt class="docutils literal"><span class="pre"><span class="Operator">></span> <span class="DecNumber">0</span></span></tt> for <em>greater than</em>.<br/></p></p>
|
||||
|
||||
<p><strong class="examples_text">Example:</strong></p>
|
||||
<pre class="listing"><span class="Identifier">assert</span> <span class="Operator">-</span><span class="DecNumber">123</span> <span class="Operator">*</span> <span class="Identifier">Descending</span> <span class="Operator">==</span> <span class="DecNumber">123</span>
|
||||
<span class="Identifier">assert</span> <span class="DecNumber">123</span> <span class="Operator">*</span> <span class="Identifier">Descending</span> <span class="Operator">==</span> <span class="Operator">-</span><span class="DecNumber">123</span>
|
||||
<span class="Identifier">assert</span> <span class="Operator">-</span><span class="DecNumber">123</span> <span class="Operator">*</span> <span class="Identifier">Ascending</span> <span class="Operator">==</span> <span class="Operator">-</span><span class="DecNumber">123</span>
|
||||
<span class="Identifier">assert</span> <span class="DecNumber">123</span> <span class="Operator">*</span> <span class="Identifier">Ascending</span> <span class="Operator">==</span> <span class="DecNumber">123</span></pre>
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/algorithm.nim#L55" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/algorithm.nim#L55" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="binarySearch-procs-all">
|
||||
<div id="binarySearch,openArray[T],K,proc(T,K)">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#binarySearch%2CopenArray%5BT%5D%2CK%2Cproc%28T%2CK%29"><span class="Identifier">binarySearch</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">,</span> <span class="Identifier">K</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">a</span><span class="Other">:</span> <a href="system.html#openArray"><span class="Identifier">openArray</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">key</span><span class="Other">:</span> <span class="Identifier">K</span><span class="Other">;</span>
|
||||
<span class="Identifier">cmp</span><span class="Other">:</span> <span class="Keyword">proc</span> <span class="Other">(</span><span class="Identifier">x</span><span class="Other">:</span> <span class="Identifier">T</span><span class="Other">;</span> <span class="Identifier">y</span><span class="Other">:</span> <span class="Identifier">K</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a> {.<span class="Identifier">closure</span>.}<span class="Other">)</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a> {.
|
||||
<span class="Identifier">effectsOf</span><span class="Other">:</span> <span class="Identifier">cmp</span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Binary search for <tt class="docutils literal"><span class="pre"><span class="Identifier">key</span></span></tt> in <tt class="docutils literal"><span class="pre"><span class="Identifier">a</span></span></tt>. Return the index of <tt class="docutils literal"><span class="pre"><span class="Identifier">key</span></span></tt> or -1 if not found. Assumes that <tt class="docutils literal"><span class="pre"><span class="Identifier">a</span></span></tt> is sorted according to <tt class="docutils literal"><span class="pre"><span class="Identifier">cmp</span></span></tt>.</p>
|
||||
<p><tt class="docutils literal"><span class="pre"><span class="Identifier">cmp</span></span></tt> is the comparator function to use, the expected return values are the same as those of system.cmp.</p>
|
||||
|
||||
<p><strong class="examples_text">Example:</strong></p>
|
||||
<pre class="listing"><span class="Identifier">assert</span> <span class="Identifier">binarySearch</span><span class="Punctuation">(</span><span class="Punctuation">[</span><span class="StringLit">"a"</span><span class="Punctuation">,</span> <span class="StringLit">"b"</span><span class="Punctuation">,</span> <span class="StringLit">"c"</span><span class="Punctuation">,</span> <span class="StringLit">"d"</span><span class="Punctuation">]</span><span class="Punctuation">,</span> <span class="StringLit">"d"</span><span class="Punctuation">,</span> <span class="Identifier">system</span><span class="Operator">.</span><span class="Identifier">cmp</span><span class="Punctuation">[</span><span class="Identifier">string</span><span class="Punctuation">]</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">3</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">binarySearch</span><span class="Punctuation">(</span><span class="Punctuation">[</span><span class="StringLit">"a"</span><span class="Punctuation">,</span> <span class="StringLit">"b"</span><span class="Punctuation">,</span> <span class="StringLit">"c"</span><span class="Punctuation">,</span> <span class="StringLit">"d"</span><span class="Punctuation">]</span><span class="Punctuation">,</span> <span class="StringLit">"c"</span><span class="Punctuation">,</span> <span class="Identifier">system</span><span class="Operator">.</span><span class="Identifier">cmp</span><span class="Punctuation">[</span><span class="Identifier">string</span><span class="Punctuation">]</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">2</span></pre>
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/algorithm.nim#L159" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/algorithm.nim#L159" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
<div id="binarySearch,openArray[T],T">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#binarySearch%2CopenArray%5BT%5D%2CT"><span class="Identifier">binarySearch</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">a</span><span class="Other">:</span> <a href="system.html#openArray"><span class="Identifier">openArray</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">key</span><span class="Other">:</span> <span class="Identifier">T</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a></pre></dt>
|
||||
<dd>
|
||||
|
||||
Binary search for <tt class="docutils literal"><span class="pre"><span class="Identifier">key</span></span></tt> in <tt class="docutils literal"><span class="pre"><span class="Identifier">a</span></span></tt>. Return the index of <tt class="docutils literal"><span class="pre"><span class="Identifier">key</span></span></tt> or -1 if not found. Assumes that <tt class="docutils literal"><span class="pre"><span class="Identifier">a</span></span></tt> is sorted.
|
||||
<p><strong class="examples_text">Example:</strong></p>
|
||||
<pre class="listing"><span class="Identifier">assert</span> <span class="Identifier">binarySearch</span><span class="Punctuation">(</span><span class="Punctuation">[</span><span class="DecNumber">0</span><span class="Punctuation">,</span> <span class="DecNumber">1</span><span class="Punctuation">,</span> <span class="DecNumber">2</span><span class="Punctuation">,</span> <span class="DecNumber">3</span><span class="Punctuation">,</span> <span class="DecNumber">4</span><span class="Punctuation">]</span><span class="Punctuation">,</span> <span class="DecNumber">4</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">4</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">binarySearch</span><span class="Punctuation">(</span><span class="Punctuation">[</span><span class="DecNumber">0</span><span class="Punctuation">,</span> <span class="DecNumber">1</span><span class="Punctuation">,</span> <span class="DecNumber">2</span><span class="Punctuation">,</span> <span class="DecNumber">3</span><span class="Punctuation">,</span> <span class="DecNumber">4</span><span class="Punctuation">]</span><span class="Punctuation">,</span> <span class="DecNumber">2</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">2</span></pre>
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/algorithm.nim#L210" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/algorithm.nim#L210" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="fill-procs-all">
|
||||
<div id="fill,openArray[T],Natural,Natural,T">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#fill%2CopenArray%5BT%5D%2CNatural%2CNatural%2CT"><span class="Identifier">fill</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">a</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="system.html#openArray"><span class="Identifier">openArray</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">first</span><span class="Other">,</span> <span class="Identifier">last</span><span class="Other">:</span> <a href="system.html#Natural"><span class="Identifier">Natural</span></a><span class="Other">;</span> <span class="Identifier">value</span><span class="Other">:</span> <span class="Identifier">T</span><span class="Other">)</span></pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Assigns <tt class="docutils literal"><span class="pre"><span class="Identifier">value</span></span></tt> to all elements of the slice <tt class="docutils literal"><span class="pre"><span class="Identifier">a</span><span class="Punctuation">[</span><span class="Identifier">first</span><span class="Operator">..</span><span class="Identifier">last</span><span class="Punctuation">]</span></span></tt>.</p>
|
||||
<p>If an invalid range is passed, it raises <tt class="docutils literal"><span class="pre"><span class="Identifier">IndexDefect</span></span></tt>.</p>
|
||||
|
||||
<p><strong class="examples_text">Example:</strong></p>
|
||||
<pre class="listing"><span class="Keyword">var</span> <span class="Identifier">a</span><span class="Punctuation">:</span> <span class="Identifier">array</span><span class="Punctuation">[</span><span class="DecNumber">6</span><span class="Punctuation">,</span> <span class="Identifier">int</span><span class="Punctuation">]</span>
|
||||
<span class="Identifier">a</span><span class="Operator">.</span><span class="Identifier">fill</span><span class="Punctuation">(</span><span class="DecNumber">1</span><span class="Punctuation">,</span> <span class="DecNumber">3</span><span class="Punctuation">,</span> <span class="DecNumber">9</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">a</span> <span class="Operator">==</span> <span class="Punctuation">[</span><span class="DecNumber">0</span><span class="Punctuation">,</span> <span class="DecNumber">9</span><span class="Punctuation">,</span> <span class="DecNumber">9</span><span class="Punctuation">,</span> <span class="DecNumber">9</span><span class="Punctuation">,</span> <span class="DecNumber">0</span><span class="Punctuation">,</span> <span class="DecNumber">0</span><span class="Punctuation">]</span>
|
||||
<span class="Identifier">a</span><span class="Operator">.</span><span class="Identifier">fill</span><span class="Punctuation">(</span><span class="DecNumber">3</span><span class="Punctuation">,</span> <span class="DecNumber">5</span><span class="Punctuation">,</span> <span class="DecNumber">7</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">a</span> <span class="Operator">==</span> <span class="Punctuation">[</span><span class="DecNumber">0</span><span class="Punctuation">,</span> <span class="DecNumber">9</span><span class="Punctuation">,</span> <span class="DecNumber">9</span><span class="Punctuation">,</span> <span class="DecNumber">7</span><span class="Punctuation">,</span> <span class="DecNumber">7</span><span class="Punctuation">,</span> <span class="DecNumber">7</span><span class="Punctuation">]</span>
|
||||
<span class="Identifier">doAssertRaises</span><span class="Punctuation">(</span><span class="Identifier">IndexDefect</span><span class="Punctuation">,</span> <span class="Identifier">a</span><span class="Operator">.</span><span class="Identifier">fill</span><span class="Punctuation">(</span><span class="DecNumber">1</span><span class="Punctuation">,</span> <span class="DecNumber">7</span><span class="Punctuation">,</span> <span class="DecNumber">9</span><span class="Punctuation">)</span><span class="Punctuation">)</span></pre>
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/algorithm.nim#L77" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/algorithm.nim#L77" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
<div id="fill,openArray[T],T">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#fill%2CopenArray%5BT%5D%2CT"><span class="Identifier">fill</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">a</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="system.html#openArray"><span class="Identifier">openArray</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">value</span><span class="Other">:</span> <span class="Identifier">T</span><span class="Other">)</span></pre></dt>
|
||||
<dd>
|
||||
|
||||
Assigns <tt class="docutils literal"><span class="pre"><span class="Identifier">value</span></span></tt> to all elements of the container <tt class="docutils literal"><span class="pre"><span class="Identifier">a</span></span></tt>.
|
||||
<p><strong class="examples_text">Example:</strong></p>
|
||||
<pre class="listing"><span class="Keyword">var</span> <span class="Identifier">a</span><span class="Punctuation">:</span> <span class="Identifier">array</span><span class="Punctuation">[</span><span class="DecNumber">6</span><span class="Punctuation">,</span> <span class="Identifier">int</span><span class="Punctuation">]</span>
|
||||
<span class="Identifier">a</span><span class="Operator">.</span><span class="Identifier">fill</span><span class="Punctuation">(</span><span class="DecNumber">9</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">a</span> <span class="Operator">==</span> <span class="Punctuation">[</span><span class="DecNumber">9</span><span class="Punctuation">,</span> <span class="DecNumber">9</span><span class="Punctuation">,</span> <span class="DecNumber">9</span><span class="Punctuation">,</span> <span class="DecNumber">9</span><span class="Punctuation">,</span> <span class="DecNumber">9</span><span class="Punctuation">,</span> <span class="DecNumber">9</span><span class="Punctuation">]</span>
|
||||
<span class="Identifier">a</span><span class="Operator">.</span><span class="Identifier">fill</span><span class="Punctuation">(</span><span class="DecNumber">4</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">a</span> <span class="Operator">==</span> <span class="Punctuation">[</span><span class="DecNumber">4</span><span class="Punctuation">,</span> <span class="DecNumber">4</span><span class="Punctuation">,</span> <span class="DecNumber">4</span><span class="Punctuation">,</span> <span class="DecNumber">4</span><span class="Punctuation">,</span> <span class="DecNumber">4</span><span class="Punctuation">,</span> <span class="DecNumber">4</span><span class="Punctuation">]</span></pre>
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/algorithm.nim#L90" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/algorithm.nim#L90" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="isSorted-procs-all">
|
||||
<div id="isSorted,openArray[T],proc(T,T)">
|
||||
<dt><pre><span class="Keyword">func</span> <a href="#isSorted%2CopenArray%5BT%5D%2Cproc%28T%2CT%29"><span class="Identifier">isSorted</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">a</span><span class="Other">:</span> <a href="system.html#openArray"><span class="Identifier">openArray</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">cmp</span><span class="Other">:</span> <span class="Keyword">proc</span> <span class="Other">(</span><span class="Identifier">x</span><span class="Other">,</span> <span class="Identifier">y</span><span class="Other">:</span> <span class="Identifier">T</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a> {.<span class="Identifier">closure</span>.}<span class="Other">;</span>
|
||||
<span class="Identifier">order</span> <span class="Other">=</span> <a href="algorithm.html#SortOrder"><span class="Identifier">SortOrder</span></a><span class="Other">.</span><span class="Identifier">Ascending</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#bool"><span class="Identifier">bool</span></a> {.<span class="Identifier">effectsOf</span><span class="Other">:</span> <span class="Identifier">cmp</span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Checks to see whether <tt class="docutils literal"><span class="pre"><span class="Identifier">a</span></span></tt> is already sorted in <tt class="docutils literal"><span class="pre"><span class="Identifier">order</span></span></tt> using <tt class="docutils literal"><span class="pre"><span class="Identifier">cmp</span></span></tt> for the comparison. The parameters are identical to <tt class="docutils literal"><span class="pre"><span class="Identifier">sort</span></span></tt>. Requires O(n) time.</p>
|
||||
<p><strong>See also:</strong></p>
|
||||
<ul class="simple"><li><a class="reference external" href="#isSorted,openArray[T]">isSorted proc</a></li>
|
||||
</ul>
|
||||
|
||||
<p><strong class="examples_text">Example:</strong></p>
|
||||
<pre class="listing"><span class="Keyword">let</span>
|
||||
<span class="Identifier">a</span> <span class="Operator">=</span> <span class="Punctuation">[</span><span class="DecNumber">2</span><span class="Punctuation">,</span> <span class="DecNumber">3</span><span class="Punctuation">,</span> <span class="DecNumber">1</span><span class="Punctuation">,</span> <span class="DecNumber">5</span><span class="Punctuation">,</span> <span class="DecNumber">4</span><span class="Punctuation">]</span>
|
||||
<span class="Identifier">b</span> <span class="Operator">=</span> <span class="Punctuation">[</span><span class="DecNumber">1</span><span class="Punctuation">,</span> <span class="DecNumber">2</span><span class="Punctuation">,</span> <span class="DecNumber">3</span><span class="Punctuation">,</span> <span class="DecNumber">4</span><span class="Punctuation">,</span> <span class="DecNumber">5</span><span class="Punctuation">]</span>
|
||||
<span class="Identifier">c</span> <span class="Operator">=</span> <span class="Punctuation">[</span><span class="DecNumber">5</span><span class="Punctuation">,</span> <span class="DecNumber">4</span><span class="Punctuation">,</span> <span class="DecNumber">3</span><span class="Punctuation">,</span> <span class="DecNumber">2</span><span class="Punctuation">,</span> <span class="DecNumber">1</span><span class="Punctuation">]</span>
|
||||
<span class="Identifier">d</span> <span class="Operator">=</span> <span class="Punctuation">[</span><span class="StringLit">"adam"</span><span class="Punctuation">,</span> <span class="StringLit">"brian"</span><span class="Punctuation">,</span> <span class="StringLit">"cat"</span><span class="Punctuation">,</span> <span class="StringLit">"dande"</span><span class="Punctuation">]</span>
|
||||
<span class="Identifier">e</span> <span class="Operator">=</span> <span class="Punctuation">[</span><span class="StringLit">"adam"</span><span class="Punctuation">,</span> <span class="StringLit">"dande"</span><span class="Punctuation">,</span> <span class="StringLit">"brian"</span><span class="Punctuation">,</span> <span class="StringLit">"cat"</span><span class="Punctuation">]</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">isSorted</span><span class="Punctuation">(</span><span class="Identifier">a</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="Identifier">false</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">isSorted</span><span class="Punctuation">(</span><span class="Identifier">b</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="Identifier">true</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">isSorted</span><span class="Punctuation">(</span><span class="Identifier">c</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="Identifier">false</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">isSorted</span><span class="Punctuation">(</span><span class="Identifier">c</span><span class="Punctuation">,</span> <span class="Identifier">Descending</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="Identifier">true</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">isSorted</span><span class="Punctuation">(</span><span class="Identifier">d</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="Identifier">true</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">isSorted</span><span class="Punctuation">(</span><span class="Identifier">e</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="Identifier">false</span></pre>
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/algorithm.nim#L507" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/algorithm.nim#L507" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
<div id="isSorted,openArray[T]">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#isSorted%2CopenArray%5BT%5D"><span class="Identifier">isSorted</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">a</span><span class="Other">:</span> <a href="system.html#openArray"><span class="Identifier">openArray</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">order</span> <span class="Other">=</span> <a href="algorithm.html#SortOrder"><span class="Identifier">SortOrder</span></a><span class="Other">.</span><span class="Identifier">Ascending</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#bool"><span class="Identifier">bool</span></a></pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Shortcut version of <tt class="docutils literal"><span class="pre"><span class="Identifier">isSorted</span></span></tt> that uses <tt class="docutils literal"><span class="pre"><span class="Identifier">system</span><span class="Operator">.</span><span class="Identifier">cmp</span><span class="Punctuation">[</span><span class="Identifier">T</span><span class="Punctuation">]</span></span></tt> as the comparison function.</p>
|
||||
<p><strong>See also:</strong></p>
|
||||
<ul class="simple"><li><a class="reference external" href="#isSorted,openArray[T],proc(T,T)">isSorted func</a></li>
|
||||
</ul>
|
||||
|
||||
<p><strong class="examples_text">Example:</strong></p>
|
||||
<pre class="listing"><span class="Keyword">let</span>
|
||||
<span class="Identifier">a</span> <span class="Operator">=</span> <span class="Punctuation">[</span><span class="DecNumber">2</span><span class="Punctuation">,</span> <span class="DecNumber">3</span><span class="Punctuation">,</span> <span class="DecNumber">1</span><span class="Punctuation">,</span> <span class="DecNumber">5</span><span class="Punctuation">,</span> <span class="DecNumber">4</span><span class="Punctuation">]</span>
|
||||
<span class="Identifier">b</span> <span class="Operator">=</span> <span class="Punctuation">[</span><span class="DecNumber">1</span><span class="Punctuation">,</span> <span class="DecNumber">2</span><span class="Punctuation">,</span> <span class="DecNumber">3</span><span class="Punctuation">,</span> <span class="DecNumber">4</span><span class="Punctuation">,</span> <span class="DecNumber">5</span><span class="Punctuation">]</span>
|
||||
<span class="Identifier">c</span> <span class="Operator">=</span> <span class="Punctuation">[</span><span class="DecNumber">5</span><span class="Punctuation">,</span> <span class="DecNumber">4</span><span class="Punctuation">,</span> <span class="DecNumber">3</span><span class="Punctuation">,</span> <span class="DecNumber">2</span><span class="Punctuation">,</span> <span class="DecNumber">1</span><span class="Punctuation">]</span>
|
||||
<span class="Identifier">d</span> <span class="Operator">=</span> <span class="Punctuation">[</span><span class="StringLit">"adam"</span><span class="Punctuation">,</span> <span class="StringLit">"brian"</span><span class="Punctuation">,</span> <span class="StringLit">"cat"</span><span class="Punctuation">,</span> <span class="StringLit">"dande"</span><span class="Punctuation">]</span>
|
||||
<span class="Identifier">e</span> <span class="Operator">=</span> <span class="Punctuation">[</span><span class="StringLit">"adam"</span><span class="Punctuation">,</span> <span class="StringLit">"dande"</span><span class="Punctuation">,</span> <span class="StringLit">"brian"</span><span class="Punctuation">,</span> <span class="StringLit">"cat"</span><span class="Punctuation">]</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">isSorted</span><span class="Punctuation">(</span><span class="Identifier">a</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="Identifier">false</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">isSorted</span><span class="Punctuation">(</span><span class="Identifier">b</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="Identifier">true</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">isSorted</span><span class="Punctuation">(</span><span class="Identifier">c</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="Identifier">false</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">isSorted</span><span class="Punctuation">(</span><span class="Identifier">c</span><span class="Punctuation">,</span> <span class="Identifier">Descending</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="Identifier">true</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">isSorted</span><span class="Punctuation">(</span><span class="Identifier">d</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="Identifier">true</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">isSorted</span><span class="Punctuation">(</span><span class="Identifier">e</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="Identifier">false</span></pre>
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/algorithm.nim#L534" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/algorithm.nim#L534" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="lowerBound-procs-all">
|
||||
<div id="lowerBound,openArray[T],K,proc(T,K)">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#lowerBound%2CopenArray%5BT%5D%2CK%2Cproc%28T%2CK%29"><span class="Identifier">lowerBound</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">,</span> <span class="Identifier">K</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">a</span><span class="Other">:</span> <a href="system.html#openArray"><span class="Identifier">openArray</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">key</span><span class="Other">:</span> <span class="Identifier">K</span><span class="Other">;</span>
|
||||
<span class="Identifier">cmp</span><span class="Other">:</span> <span class="Keyword">proc</span> <span class="Other">(</span><span class="Identifier">x</span><span class="Other">:</span> <span class="Identifier">T</span><span class="Other">;</span> <span class="Identifier">k</span><span class="Other">:</span> <span class="Identifier">K</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a> {.<span class="Identifier">closure</span>.}<span class="Other">)</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a> {.
|
||||
<span class="Identifier">effectsOf</span><span class="Other">:</span> <span class="Identifier">cmp</span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Returns the index of the first element in <tt class="docutils literal"><span class="pre"><span class="Identifier">a</span></span></tt> that is not less than (i.e. greater or equal to) <tt class="docutils literal"><span class="pre"><span class="Identifier">key</span></span></tt>, or last if no such element is found. In other words if you have a sorted sequence and you call <tt class="docutils literal"><span class="pre"><span class="Identifier">insert</span><span class="Punctuation">(</span><span class="Identifier">thing</span><span class="Punctuation">,</span> <span class="Identifier">elm</span><span class="Punctuation">,</span> <span class="Identifier">lowerBound</span><span class="Punctuation">(</span><span class="Identifier">thing</span><span class="Punctuation">,</span> <span class="Identifier">elm</span><span class="Punctuation">)</span><span class="Punctuation">)</span></span></tt> the sequence will still be sorted. Assumes that <tt class="docutils literal"><span class="pre"><span class="Identifier">a</span></span></tt> is sorted according to <tt class="docutils literal"><span class="pre"><span class="Identifier">cmp</span></span></tt>.</p>
|
||||
<p>If an invalid range is passed, it raises <tt class="docutils literal"><span class="pre"><span class="Identifier">IndexDefect</span></span></tt>.</p>
|
||||
<p>This version uses <tt class="docutils literal"><span class="pre"><span class="Identifier">cmp</span></span></tt> to compare the elements. The expected return values are the same as those of <tt class="docutils literal"><span class="pre"><span class="Identifier">system</span><span class="Operator">.</span><span class="Identifier">cmp</span></span></tt>.</p>
|
||||
<p><strong>See also:</strong></p>
|
||||
<ul class="simple"><li><a class="reference external" href="#upperBound,openArray[T],K,proc(T,K)">upperBound proc</a> sorted by <tt class="docutils literal"><span class="pre"><span class="Identifier">cmp</span></span></tt> in the specified order</li>
|
||||
<li><a class="reference external" href="#upperBound,openArray[T],T">upperBound proc</a></li>
|
||||
</ul>
|
||||
|
||||
<p><strong class="examples_text">Example:</strong></p>
|
||||
<pre class="listing"><span class="Keyword">var</span> <span class="Identifier">arr</span> <span class="Operator">=</span> <span class="Operator">@</span><span class="Punctuation">[</span><span class="DecNumber">1</span><span class="Punctuation">,</span> <span class="DecNumber">2</span><span class="Punctuation">,</span> <span class="DecNumber">3</span><span class="Punctuation">,</span> <span class="DecNumber">5</span><span class="Punctuation">,</span> <span class="DecNumber">6</span><span class="Punctuation">,</span> <span class="DecNumber">7</span><span class="Punctuation">,</span> <span class="DecNumber">8</span><span class="Punctuation">,</span> <span class="DecNumber">9</span><span class="Punctuation">]</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">arr</span><span class="Operator">.</span><span class="Identifier">lowerBound</span><span class="Punctuation">(</span><span class="DecNumber">3</span><span class="Punctuation">,</span> <span class="Identifier">system</span><span class="Operator">.</span><span class="Identifier">cmp</span><span class="Punctuation">[</span><span class="Identifier">int</span><span class="Punctuation">]</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">2</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">arr</span><span class="Operator">.</span><span class="Identifier">lowerBound</span><span class="Punctuation">(</span><span class="DecNumber">4</span><span class="Punctuation">,</span> <span class="Identifier">system</span><span class="Operator">.</span><span class="Identifier">cmp</span><span class="Punctuation">[</span><span class="Identifier">int</span><span class="Punctuation">]</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">3</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">arr</span><span class="Operator">.</span><span class="Identifier">lowerBound</span><span class="Punctuation">(</span><span class="DecNumber">5</span><span class="Punctuation">,</span> <span class="Identifier">system</span><span class="Operator">.</span><span class="Identifier">cmp</span><span class="Punctuation">[</span><span class="Identifier">int</span><span class="Punctuation">]</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">3</span>
|
||||
<span class="Identifier">arr</span><span class="Operator">.</span><span class="Identifier">insert</span><span class="Punctuation">(</span><span class="DecNumber">4</span><span class="Punctuation">,</span> <span class="Identifier">arr</span><span class="Operator">.</span><span class="Identifier">lowerBound</span><span class="Punctuation">(</span><span class="DecNumber">4</span><span class="Punctuation">,</span> <span class="Identifier">system</span><span class="Operator">.</span><span class="Identifier">cmp</span><span class="Punctuation">[</span><span class="Identifier">int</span><span class="Punctuation">]</span><span class="Punctuation">)</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">arr</span> <span class="Operator">==</span> <span class="Punctuation">[</span><span class="DecNumber">1</span><span class="Punctuation">,</span> <span class="DecNumber">2</span><span class="Punctuation">,</span> <span class="DecNumber">3</span><span class="Punctuation">,</span> <span class="DecNumber">4</span><span class="Punctuation">,</span> <span class="DecNumber">5</span><span class="Punctuation">,</span> <span class="DecNumber">6</span><span class="Punctuation">,</span> <span class="DecNumber">7</span><span class="Punctuation">,</span> <span class="DecNumber">8</span><span class="Punctuation">,</span> <span class="DecNumber">9</span><span class="Punctuation">]</span></pre>
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/algorithm.nim#L221" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/algorithm.nim#L221" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
<div id="lowerBound,openArray[T],T">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#lowerBound%2CopenArray%5BT%5D%2CT"><span class="Identifier">lowerBound</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">a</span><span class="Other">:</span> <a href="system.html#openArray"><span class="Identifier">openArray</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">key</span><span class="Other">:</span> <span class="Identifier">T</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a></pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Returns the index of the first element in <tt class="docutils literal"><span class="pre"><span class="Identifier">a</span></span></tt> that is not less than (i.e. greater or equal to) <tt class="docutils literal"><span class="pre"><span class="Identifier">key</span></span></tt>, or last if no such element is found. In other words if you have a sorted sequence and you call <tt class="docutils literal"><span class="pre"><span class="Identifier">insert</span><span class="Punctuation">(</span><span class="Identifier">thing</span><span class="Punctuation">,</span> <span class="Identifier">elm</span><span class="Punctuation">,</span> <span class="Identifier">lowerBound</span><span class="Punctuation">(</span><span class="Identifier">thing</span><span class="Punctuation">,</span> <span class="Identifier">elm</span><span class="Punctuation">)</span><span class="Punctuation">)</span></span></tt> the sequence will still be sorted. Assumes that <tt class="docutils literal"><span class="pre"><span class="Identifier">a</span></span></tt> is sorted.</p>
|
||||
<p>This version uses the default comparison function <tt class="docutils literal"><span class="pre"><span class="Identifier">cmp</span></span></tt>.</p>
|
||||
<p><strong>See also:</strong></p>
|
||||
<ul class="simple"><li><a class="reference external" href="#upperBound,openArray[T],K,proc(T,K)">upperBound proc</a> sorted by <tt class="docutils literal"><span class="pre"><span class="Identifier">cmp</span></span></tt> in the specified order</li>
|
||||
<li><a class="reference external" href="#upperBound,openArray[T],T">upperBound proc</a></li>
|
||||
</ul>
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/algorithm.nim#L257" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/algorithm.nim#L257" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="merge-procs-all">
|
||||
<div id="merge,seq[T],openArray[T],openArray[T]">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#merge%2Cseq%5BT%5D%2CopenArray%5BT%5D%2CopenArray%5BT%5D"><span class="Identifier">merge</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">result</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="system.html#seq"><span class="Identifier">seq</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">x</span><span class="Other">,</span> <span class="Identifier">y</span><span class="Other">:</span> <a href="system.html#openArray"><span class="Identifier">openArray</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">)</span> {.<span class="Identifier">inline</span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Shortcut version of <tt class="docutils literal"><span class="pre"><span class="Identifier">merge</span></span></tt> that uses <tt class="docutils literal"><span class="pre"><span class="Identifier">system</span><span class="Operator">.</span><span class="Identifier">cmp</span><span class="Punctuation">[</span><span class="Identifier">T</span><span class="Punctuation">]</span></span></tt> as the comparison function.</p>
|
||||
<p><strong>See also:</strong></p>
|
||||
<ul class="simple"><li><a class="reference external" href="#merge,seq[T],openArray[T],openArray[T],proc(T,T)">merge proc</a></li>
|
||||
</ul>
|
||||
|
||||
<p><strong class="examples_text">Example:</strong></p>
|
||||
<pre class="listing"><span class="Keyword">let</span> <span class="Identifier">x</span> <span class="Operator">=</span> <span class="Punctuation">[</span><span class="DecNumber">5</span><span class="Punctuation">,</span> <span class="DecNumber">10</span><span class="Punctuation">,</span> <span class="DecNumber">15</span><span class="Punctuation">,</span> <span class="DecNumber">20</span><span class="Punctuation">,</span> <span class="DecNumber">25</span><span class="Punctuation">]</span>
|
||||
<span class="Keyword">let</span> <span class="Identifier">y</span> <span class="Operator">=</span> <span class="Punctuation">[</span><span class="DecNumber">50</span><span class="Punctuation">,</span> <span class="DecNumber">40</span><span class="Punctuation">,</span> <span class="DecNumber">30</span><span class="Punctuation">,</span> <span class="DecNumber">20</span><span class="Punctuation">,</span> <span class="DecNumber">10</span><span class="Punctuation">]</span><span class="Operator">.</span><span class="Identifier">sorted</span>
|
||||
|
||||
<span class="Keyword">var</span> <span class="Identifier">merged</span><span class="Punctuation">:</span> <span class="Identifier">seq</span><span class="Punctuation">[</span><span class="Identifier">int</span><span class="Punctuation">]</span>
|
||||
<span class="Identifier">merged</span><span class="Operator">.</span><span class="Identifier">merge</span><span class="Punctuation">(</span><span class="Identifier">x</span><span class="Punctuation">,</span> <span class="Identifier">y</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">merged</span><span class="Operator">.</span><span class="Identifier">isSorted</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">merged</span> <span class="Operator">==</span> <span class="Operator">@</span><span class="Punctuation">[</span><span class="DecNumber">5</span><span class="Punctuation">,</span> <span class="DecNumber">10</span><span class="Punctuation">,</span> <span class="DecNumber">10</span><span class="Punctuation">,</span> <span class="DecNumber">15</span><span class="Punctuation">,</span> <span class="DecNumber">20</span><span class="Punctuation">,</span> <span class="DecNumber">20</span><span class="Punctuation">,</span> <span class="DecNumber">25</span><span class="Punctuation">,</span> <span class="DecNumber">30</span><span class="Punctuation">,</span> <span class="DecNumber">40</span><span class="Punctuation">,</span> <span class="DecNumber">50</span><span class="Punctuation">]</span></pre>
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/algorithm.nim#L631" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/algorithm.nim#L631" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
<div id="merge,seq[T],openArray[T],openArray[T],proc(T,T)">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#merge%2Cseq%5BT%5D%2CopenArray%5BT%5D%2CopenArray%5BT%5D%2Cproc%28T%2CT%29"><span class="Identifier">merge</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">result</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="system.html#seq"><span class="Identifier">seq</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">x</span><span class="Other">,</span> <span class="Identifier">y</span><span class="Other">:</span> <a href="system.html#openArray"><span class="Identifier">openArray</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span>
|
||||
<span class="Identifier">cmp</span><span class="Other">:</span> <span class="Keyword">proc</span> <span class="Other">(</span><span class="Identifier">x</span><span class="Other">,</span> <span class="Identifier">y</span><span class="Other">:</span> <span class="Identifier">T</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a> {.<span class="Identifier">closure</span>.}<span class="Other">)</span> {.<span class="Identifier">effectsOf</span><span class="Other">:</span> <span class="Identifier">cmp</span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Merges two sorted <tt class="docutils literal"><span class="pre"><span class="Identifier">openArray</span></span></tt>. <tt class="docutils literal"><span class="pre"><span class="Identifier">x</span></span></tt> and <tt class="docutils literal"><span class="pre"><span class="Identifier">y</span></span></tt> are assumed to be sorted. If you do not wish to provide your own <tt class="docutils literal"><span class="pre"><span class="Identifier">cmp</span></span></tt>, you may use <tt class="docutils literal"><span class="pre"><span class="Identifier">system</span><span class="Operator">.</span><span class="Identifier">cmp</span></span></tt> or instead call the overloaded version of <tt class="docutils literal"><span class="pre"><span class="Identifier">merge</span></span></tt>, which uses <tt class="docutils literal"><span class="pre"><span class="Identifier">system</span><span class="Operator">.</span><span class="Identifier">cmp</span></span></tt>.<div class="admonition admonition-info"><span class="admonition-info-text"><b>Note:</b></span>
|
||||
The original data of <tt class="docutils literal"><span class="pre"><span class="Identifier">result</span></span></tt> is not cleared, new data is appended to <tt class="docutils literal"><span class="pre"><span class="Identifier">result</span></span></tt>.</div>
|
||||
<p><strong>See also:</strong></p>
|
||||
<ul class="simple"><li><a class="reference external" href="#merge,seq[T],openArray[T],openArray[T]">merge proc</a></li>
|
||||
</ul>
|
||||
|
||||
<p><strong class="examples_text">Example:</strong></p>
|
||||
<pre class="listing"><span class="Keyword">let</span> <span class="Identifier">x</span> <span class="Operator">=</span> <span class="Operator">@</span><span class="Punctuation">[</span><span class="DecNumber">1</span><span class="Punctuation">,</span> <span class="DecNumber">3</span><span class="Punctuation">,</span> <span class="DecNumber">6</span><span class="Punctuation">]</span>
|
||||
<span class="Keyword">let</span> <span class="Identifier">y</span> <span class="Operator">=</span> <span class="Operator">@</span><span class="Punctuation">[</span><span class="DecNumber">2</span><span class="Punctuation">,</span> <span class="DecNumber">3</span><span class="Punctuation">,</span> <span class="DecNumber">4</span><span class="Punctuation">]</span>
|
||||
|
||||
<span class="Keyword">block</span><span class="Punctuation">:</span>
|
||||
<span class="Keyword">var</span> <span class="Identifier">merged</span> <span class="Operator">=</span> <span class="Operator">@</span><span class="Punctuation">[</span><span class="DecNumber">7</span><span class="Punctuation">]</span> <span class="Comment"># new data is appended to merged sequence</span>
|
||||
<span class="Identifier">merged</span><span class="Operator">.</span><span class="Identifier">merge</span><span class="Punctuation">(</span><span class="Identifier">x</span><span class="Punctuation">,</span> <span class="Identifier">y</span><span class="Punctuation">,</span> <span class="Identifier">system</span><span class="Operator">.</span><span class="Identifier">cmp</span><span class="Punctuation">[</span><span class="Identifier">int</span><span class="Punctuation">]</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">merged</span> <span class="Operator">==</span> <span class="Operator">@</span><span class="Punctuation">[</span><span class="DecNumber">7</span><span class="Punctuation">,</span> <span class="DecNumber">1</span><span class="Punctuation">,</span> <span class="DecNumber">2</span><span class="Punctuation">,</span> <span class="DecNumber">3</span><span class="Punctuation">,</span> <span class="DecNumber">3</span><span class="Punctuation">,</span> <span class="DecNumber">4</span><span class="Punctuation">,</span> <span class="DecNumber">6</span><span class="Punctuation">]</span>
|
||||
|
||||
<span class="Keyword">block</span><span class="Punctuation">:</span>
|
||||
<span class="Keyword">var</span> <span class="Identifier">merged</span> <span class="Operator">=</span> <span class="Operator">@</span><span class="Punctuation">[</span><span class="DecNumber">7</span><span class="Punctuation">]</span> <span class="Comment"># if you only want new data, clear merged sequence first</span>
|
||||
<span class="Identifier">merged</span><span class="Operator">.</span><span class="Identifier">setLen</span><span class="Punctuation">(</span><span class="DecNumber">0</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">merged</span><span class="Operator">.</span><span class="Identifier">merge</span><span class="Punctuation">(</span><span class="Identifier">x</span><span class="Punctuation">,</span> <span class="Identifier">y</span><span class="Punctuation">,</span> <span class="Identifier">system</span><span class="Operator">.</span><span class="Identifier">cmp</span><span class="Punctuation">[</span><span class="Identifier">int</span><span class="Punctuation">]</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">merged</span><span class="Operator">.</span><span class="Identifier">isSorted</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">merged</span> <span class="Operator">==</span> <span class="Operator">@</span><span class="Punctuation">[</span><span class="DecNumber">1</span><span class="Punctuation">,</span> <span class="DecNumber">2</span><span class="Punctuation">,</span> <span class="DecNumber">3</span><span class="Punctuation">,</span> <span class="DecNumber">3</span><span class="Punctuation">,</span> <span class="DecNumber">4</span><span class="Punctuation">,</span> <span class="DecNumber">6</span><span class="Punctuation">]</span>
|
||||
|
||||
<span class="Keyword">import</span> <span class="Identifier">std</span><span class="Operator">/</span><span class="Identifier">sugar</span>
|
||||
|
||||
<span class="Keyword">var</span> <span class="Identifier">res</span><span class="Punctuation">:</span> <span class="Identifier">seq</span><span class="Punctuation">[</span><span class="Punctuation">(</span><span class="Identifier">int</span><span class="Punctuation">,</span> <span class="Identifier">int</span><span class="Punctuation">)</span><span class="Punctuation">]</span>
|
||||
<span class="Identifier">res</span><span class="Operator">.</span><span class="Identifier">merge</span><span class="Punctuation">(</span><span class="Punctuation">[</span><span class="Punctuation">(</span><span class="DecNumber">1</span><span class="Punctuation">,</span> <span class="DecNumber">1</span><span class="Punctuation">)</span><span class="Punctuation">]</span><span class="Punctuation">,</span> <span class="Punctuation">[</span><span class="Punctuation">(</span><span class="DecNumber">1</span><span class="Punctuation">,</span> <span class="DecNumber">2</span><span class="Punctuation">)</span><span class="Punctuation">]</span><span class="Punctuation">,</span> <span class="Punctuation">(</span><span class="Identifier">a</span><span class="Punctuation">,</span> <span class="Identifier">b</span><span class="Punctuation">)</span> <span class="Operator">=></span> <span class="Identifier">a</span><span class="Punctuation">[</span><span class="DecNumber">0</span><span class="Punctuation">]</span> <span class="Operator">-</span> <span class="Identifier">b</span><span class="Punctuation">[</span><span class="DecNumber">0</span><span class="Punctuation">]</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">res</span> <span class="Operator">==</span> <span class="Operator">@</span><span class="Punctuation">[</span><span class="Punctuation">(</span><span class="DecNumber">1</span><span class="Punctuation">,</span> <span class="DecNumber">1</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Punctuation">(</span><span class="DecNumber">1</span><span class="Punctuation">,</span> <span class="DecNumber">2</span><span class="Punctuation">)</span><span class="Punctuation">]</span>
|
||||
|
||||
<span class="Identifier">assert</span> <span class="Identifier">seq</span><span class="Punctuation">[</span><span class="Identifier">int</span><span class="Punctuation">]</span><span class="Operator">.</span><span class="Identifier">default</span><span class="Operator">.</span><span class="Identifier">dup</span><span class="Punctuation">(</span><span class="Identifier">merge</span><span class="Punctuation">(</span><span class="Punctuation">[</span><span class="DecNumber">1</span><span class="Punctuation">,</span> <span class="DecNumber">3</span><span class="Punctuation">]</span><span class="Punctuation">,</span> <span class="Punctuation">[</span><span class="DecNumber">2</span><span class="Punctuation">,</span> <span class="DecNumber">4</span><span class="Punctuation">]</span><span class="Punctuation">)</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="Operator">@</span><span class="Punctuation">[</span><span class="DecNumber">1</span><span class="Punctuation">,</span> <span class="DecNumber">2</span><span class="Punctuation">,</span> <span class="DecNumber">3</span><span class="Punctuation">,</span> <span class="DecNumber">4</span><span class="Punctuation">]</span></pre>
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/algorithm.nim#L554" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/algorithm.nim#L554" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="nextPermutation-procs-all">
|
||||
<div id="nextPermutation,openArray[T]">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#nextPermutation%2CopenArray%5BT%5D"><span class="Identifier">nextPermutation</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">x</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="system.html#openArray"><span class="Identifier">openArray</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#bool"><span class="Identifier">bool</span></a> {.<span class="Identifier">discardable</span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Calculates the next lexicographic permutation, directly modifying <tt class="docutils literal"><span class="pre"><span class="Identifier">x</span></span></tt>. The result is whether a permutation happened, otherwise we have reached the last-ordered permutation.</p>
|
||||
<p>If you start with an unsorted array/seq, the repeated permutations will <strong>not</strong> give you all permutations but stop with the last.</p>
|
||||
<p><strong>See also:</strong></p>
|
||||
<ul class="simple"><li><a class="reference external" href="#prevPermutation,openArray[T]">prevPermutation proc</a></li>
|
||||
</ul>
|
||||
|
||||
<p><strong class="examples_text">Example:</strong></p>
|
||||
<pre class="listing"><span class="Keyword">var</span> <span class="Identifier">v</span> <span class="Operator">=</span> <span class="Operator">@</span><span class="Punctuation">[</span><span class="DecNumber">0</span><span class="Punctuation">,</span> <span class="DecNumber">1</span><span class="Punctuation">,</span> <span class="DecNumber">2</span><span class="Punctuation">,</span> <span class="DecNumber">3</span><span class="Punctuation">]</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">v</span><span class="Operator">.</span><span class="Identifier">nextPermutation</span><span class="Punctuation">(</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="Identifier">true</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">v</span> <span class="Operator">==</span> <span class="Operator">@</span><span class="Punctuation">[</span><span class="DecNumber">0</span><span class="Punctuation">,</span> <span class="DecNumber">1</span><span class="Punctuation">,</span> <span class="DecNumber">3</span><span class="Punctuation">,</span> <span class="DecNumber">2</span><span class="Punctuation">]</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">v</span><span class="Operator">.</span><span class="Identifier">nextPermutation</span><span class="Punctuation">(</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="Identifier">true</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">v</span> <span class="Operator">==</span> <span class="Operator">@</span><span class="Punctuation">[</span><span class="DecNumber">0</span><span class="Punctuation">,</span> <span class="DecNumber">2</span><span class="Punctuation">,</span> <span class="DecNumber">1</span><span class="Punctuation">,</span> <span class="DecNumber">3</span><span class="Punctuation">]</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">v</span><span class="Operator">.</span><span class="Identifier">prevPermutation</span><span class="Punctuation">(</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="Identifier">true</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">v</span> <span class="Operator">==</span> <span class="Operator">@</span><span class="Punctuation">[</span><span class="DecNumber">0</span><span class="Punctuation">,</span> <span class="DecNumber">1</span><span class="Punctuation">,</span> <span class="DecNumber">3</span><span class="Punctuation">,</span> <span class="DecNumber">2</span><span class="Punctuation">]</span>
|
||||
<span class="Identifier">v</span> <span class="Operator">=</span> <span class="Operator">@</span><span class="Punctuation">[</span><span class="DecNumber">3</span><span class="Punctuation">,</span> <span class="DecNumber">2</span><span class="Punctuation">,</span> <span class="DecNumber">1</span><span class="Punctuation">,</span> <span class="DecNumber">0</span><span class="Punctuation">]</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">v</span><span class="Operator">.</span><span class="Identifier">nextPermutation</span><span class="Punctuation">(</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="Identifier">false</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">v</span> <span class="Operator">==</span> <span class="Operator">@</span><span class="Punctuation">[</span><span class="DecNumber">3</span><span class="Punctuation">,</span> <span class="DecNumber">2</span><span class="Punctuation">,</span> <span class="DecNumber">1</span><span class="Punctuation">,</span> <span class="DecNumber">0</span><span class="Punctuation">]</span></pre>
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/algorithm.nim#L683" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/algorithm.nim#L683" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="prevPermutation-procs-all">
|
||||
<div id="prevPermutation,openArray[T]">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#prevPermutation%2CopenArray%5BT%5D"><span class="Identifier">prevPermutation</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">x</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="system.html#openArray"><span class="Identifier">openArray</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#bool"><span class="Identifier">bool</span></a> {.<span class="Identifier">discardable</span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Calculates the previous lexicographic permutation, directly modifying <tt class="docutils literal"><span class="pre"><span class="Identifier">x</span></span></tt>. The result is whether a permutation happened, otherwise we have reached the first-ordered permutation.</p>
|
||||
<p><strong>See also:</strong></p>
|
||||
<ul class="simple"><li><a class="reference external" href="#nextPermutation,openArray[T]">nextPermutation proc</a></li>
|
||||
</ul>
|
||||
|
||||
<p><strong class="examples_text">Example:</strong></p>
|
||||
<pre class="listing"><span class="Keyword">var</span> <span class="Identifier">v</span> <span class="Operator">=</span> <span class="Operator">@</span><span class="Punctuation">[</span><span class="DecNumber">0</span><span class="Punctuation">,</span> <span class="DecNumber">1</span><span class="Punctuation">,</span> <span class="DecNumber">2</span><span class="Punctuation">,</span> <span class="DecNumber">3</span><span class="Punctuation">]</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">v</span><span class="Operator">.</span><span class="Identifier">prevPermutation</span><span class="Punctuation">(</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="Identifier">false</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">v</span> <span class="Operator">==</span> <span class="Operator">@</span><span class="Punctuation">[</span><span class="DecNumber">0</span><span class="Punctuation">,</span> <span class="DecNumber">1</span><span class="Punctuation">,</span> <span class="DecNumber">2</span><span class="Punctuation">,</span> <span class="DecNumber">3</span><span class="Punctuation">]</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">v</span><span class="Operator">.</span><span class="Identifier">nextPermutation</span><span class="Punctuation">(</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="Identifier">true</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">v</span> <span class="Operator">==</span> <span class="Operator">@</span><span class="Punctuation">[</span><span class="DecNumber">0</span><span class="Punctuation">,</span> <span class="DecNumber">1</span><span class="Punctuation">,</span> <span class="DecNumber">3</span><span class="Punctuation">,</span> <span class="DecNumber">2</span><span class="Punctuation">]</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">v</span><span class="Operator">.</span><span class="Identifier">prevPermutation</span><span class="Punctuation">(</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="Identifier">true</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">v</span> <span class="Operator">==</span> <span class="Operator">@</span><span class="Punctuation">[</span><span class="DecNumber">0</span><span class="Punctuation">,</span> <span class="DecNumber">1</span><span class="Punctuation">,</span> <span class="DecNumber">2</span><span class="Punctuation">,</span> <span class="DecNumber">3</span><span class="Punctuation">]</span></pre>
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/algorithm.nim#L723" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/algorithm.nim#L723" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="product-procs-all">
|
||||
<div id="product,openArray[seq[T]]">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#product%2CopenArray%5Bseq%5BT%5D%5D"><span class="Identifier">product</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">x</span><span class="Other">:</span> <a href="system.html#openArray"><span class="Identifier">openArray</span></a><span class="Other">[</span><a href="system.html#seq"><span class="Identifier">seq</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#seq"><span class="Identifier">seq</span></a><span class="Other">[</span><a href="system.html#seq"><span class="Identifier">seq</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">]</span></pre></dt>
|
||||
<dd>
|
||||
|
||||
Produces the Cartesian product of the array. Every element of the result is a combination of one element from each seq in <tt class="docutils literal"><span class="pre"><span class="Identifier">x</span></span></tt>, with the ith element coming from <tt class="docutils literal"><span class="pre"><span class="Identifier">x</span><span class="Punctuation">[</span><span class="Identifier">i</span><span class="Punctuation">]</span></span></tt>.<div class="admonition admonition-warning"><span class="admonition-warning-text"><b>Warning:</b></span>
|
||||
complexity may explode.</div>
|
||||
|
||||
<p><strong class="examples_text">Example:</strong></p>
|
||||
<pre class="listing"><span class="Identifier">assert</span> <span class="Identifier">product</span><span class="Punctuation">(</span><span class="Operator">@</span><span class="Punctuation">[</span><span class="Operator">@</span><span class="Punctuation">[</span><span class="DecNumber">1</span><span class="Punctuation">]</span><span class="Punctuation">,</span> <span class="Operator">@</span><span class="Punctuation">[</span><span class="DecNumber">2</span><span class="Punctuation">]</span><span class="Punctuation">]</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="Operator">@</span><span class="Punctuation">[</span><span class="Operator">@</span><span class="Punctuation">[</span><span class="DecNumber">1</span><span class="Punctuation">,</span> <span class="DecNumber">2</span><span class="Punctuation">]</span><span class="Punctuation">]</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">product</span><span class="Punctuation">(</span><span class="Operator">@</span><span class="Punctuation">[</span><span class="Operator">@</span><span class="Punctuation">[</span><span class="StringLit">"A"</span><span class="Punctuation">,</span> <span class="StringLit">"K"</span><span class="Punctuation">]</span><span class="Punctuation">,</span> <span class="Operator">@</span><span class="Punctuation">[</span><span class="StringLit">"Q"</span><span class="Punctuation">]</span><span class="Punctuation">]</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="Operator">@</span><span class="Punctuation">[</span><span class="Operator">@</span><span class="Punctuation">[</span><span class="StringLit">"K"</span><span class="Punctuation">,</span> <span class="StringLit">"Q"</span><span class="Punctuation">]</span><span class="Punctuation">,</span> <span class="Operator">@</span><span class="Punctuation">[</span><span class="StringLit">"A"</span><span class="Punctuation">,</span> <span class="StringLit">"Q"</span><span class="Punctuation">]</span><span class="Punctuation">]</span></pre>
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/algorithm.nim#L646" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/algorithm.nim#L646" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="reverse-procs-all">
|
||||
<div id="reverse,openArray[T]">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#reverse%2CopenArray%5BT%5D"><span class="Identifier">reverse</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">a</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="system.html#openArray"><span class="Identifier">openArray</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">)</span></pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Reverses the contents of the container <tt class="docutils literal"><span class="pre"><span class="Identifier">a</span></span></tt>.</p>
|
||||
<p><strong>See also:</strong></p>
|
||||
<ul class="simple"><li><a class="reference external" href="#reversed,openArray[T],Natural,int">reversed proc</a> reverse a slice and returns a <tt class="docutils literal"><span class="pre"><span class="Identifier">seq</span><span class="Punctuation">[</span><span class="Identifier">T</span><span class="Punctuation">]</span></span></tt></li>
|
||||
<li><a class="reference external" href="#reversed,openArray[T]">reversed proc</a> reverse and returns a <tt class="docutils literal"><span class="pre"><span class="Identifier">seq</span><span class="Punctuation">[</span><span class="Identifier">T</span><span class="Punctuation">]</span></span></tt></li>
|
||||
</ul>
|
||||
|
||||
<p><strong class="examples_text">Example:</strong></p>
|
||||
<pre class="listing"><span class="Keyword">var</span> <span class="Identifier">a</span> <span class="Operator">=</span> <span class="Punctuation">[</span><span class="DecNumber">1</span><span class="Punctuation">,</span> <span class="DecNumber">2</span><span class="Punctuation">,</span> <span class="DecNumber">3</span><span class="Punctuation">,</span> <span class="DecNumber">4</span><span class="Punctuation">,</span> <span class="DecNumber">5</span><span class="Punctuation">,</span> <span class="DecNumber">6</span><span class="Punctuation">]</span>
|
||||
<span class="Identifier">a</span><span class="Operator">.</span><span class="Identifier">reverse</span><span class="Punctuation">(</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">a</span> <span class="Operator">==</span> <span class="Punctuation">[</span><span class="DecNumber">6</span><span class="Punctuation">,</span> <span class="DecNumber">5</span><span class="Punctuation">,</span> <span class="DecNumber">4</span><span class="Punctuation">,</span> <span class="DecNumber">3</span><span class="Punctuation">,</span> <span class="DecNumber">2</span><span class="Punctuation">,</span> <span class="DecNumber">1</span><span class="Punctuation">]</span>
|
||||
<span class="Identifier">a</span><span class="Operator">.</span><span class="Identifier">reverse</span><span class="Punctuation">(</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">a</span> <span class="Operator">==</span> <span class="Punctuation">[</span><span class="DecNumber">1</span><span class="Punctuation">,</span> <span class="DecNumber">2</span><span class="Punctuation">,</span> <span class="DecNumber">3</span><span class="Punctuation">,</span> <span class="DecNumber">4</span><span class="Punctuation">,</span> <span class="DecNumber">5</span><span class="Punctuation">,</span> <span class="DecNumber">6</span><span class="Punctuation">]</span></pre>
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/algorithm.nim#L123" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/algorithm.nim#L123" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
<div id="reverse,openArray[T],Natural,Natural">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#reverse%2CopenArray%5BT%5D%2CNatural%2CNatural"><span class="Identifier">reverse</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">a</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="system.html#openArray"><span class="Identifier">openArray</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">first</span><span class="Other">,</span> <span class="Identifier">last</span><span class="Other">:</span> <a href="system.html#Natural"><span class="Identifier">Natural</span></a><span class="Other">)</span></pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Reverses the slice <tt class="docutils literal"><span class="pre"><span class="Identifier">a</span><span class="Punctuation">[</span><span class="Identifier">first</span><span class="Operator">..</span><span class="Identifier">last</span><span class="Punctuation">]</span></span></tt>.</p>
|
||||
<p>If an invalid range is passed, it raises <tt class="docutils literal"><span class="pre"><span class="Identifier">IndexDefect</span></span></tt>.</p>
|
||||
<p><strong>See also:</strong></p>
|
||||
<ul class="simple"><li><a class="reference external" href="#reversed,openArray[T],Natural,int">reversed proc</a> reverse a slice and returns a <tt class="docutils literal"><span class="pre"><span class="Identifier">seq</span><span class="Punctuation">[</span><span class="Identifier">T</span><span class="Punctuation">]</span></span></tt></li>
|
||||
<li><a class="reference external" href="#reversed,openArray[T]">reversed proc</a> reverse and returns a <tt class="docutils literal"><span class="pre"><span class="Identifier">seq</span><span class="Punctuation">[</span><span class="Identifier">T</span><span class="Punctuation">]</span></span></tt></li>
|
||||
</ul>
|
||||
|
||||
<p><strong class="examples_text">Example:</strong></p>
|
||||
<pre class="listing"><span class="Keyword">var</span> <span class="Identifier">a</span> <span class="Operator">=</span> <span class="Punctuation">[</span><span class="DecNumber">1</span><span class="Punctuation">,</span> <span class="DecNumber">2</span><span class="Punctuation">,</span> <span class="DecNumber">3</span><span class="Punctuation">,</span> <span class="DecNumber">4</span><span class="Punctuation">,</span> <span class="DecNumber">5</span><span class="Punctuation">,</span> <span class="DecNumber">6</span><span class="Punctuation">]</span>
|
||||
<span class="Identifier">a</span><span class="Operator">.</span><span class="Identifier">reverse</span><span class="Punctuation">(</span><span class="DecNumber">1</span><span class="Punctuation">,</span> <span class="DecNumber">3</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">a</span> <span class="Operator">==</span> <span class="Punctuation">[</span><span class="DecNumber">1</span><span class="Punctuation">,</span> <span class="DecNumber">4</span><span class="Punctuation">,</span> <span class="DecNumber">3</span><span class="Punctuation">,</span> <span class="DecNumber">2</span><span class="Punctuation">,</span> <span class="DecNumber">5</span><span class="Punctuation">,</span> <span class="DecNumber">6</span><span class="Punctuation">]</span>
|
||||
<span class="Identifier">a</span><span class="Operator">.</span><span class="Identifier">reverse</span><span class="Punctuation">(</span><span class="DecNumber">1</span><span class="Punctuation">,</span> <span class="DecNumber">3</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">a</span> <span class="Operator">==</span> <span class="Punctuation">[</span><span class="DecNumber">1</span><span class="Punctuation">,</span> <span class="DecNumber">2</span><span class="Punctuation">,</span> <span class="DecNumber">3</span><span class="Punctuation">,</span> <span class="DecNumber">4</span><span class="Punctuation">,</span> <span class="DecNumber">5</span><span class="Punctuation">,</span> <span class="DecNumber">6</span><span class="Punctuation">]</span>
|
||||
<span class="Identifier">doAssertRaises</span><span class="Punctuation">(</span><span class="Identifier">IndexDefect</span><span class="Punctuation">,</span> <span class="Identifier">a</span><span class="Operator">.</span><span class="Identifier">reverse</span><span class="Punctuation">(</span><span class="DecNumber">1</span><span class="Punctuation">,</span> <span class="DecNumber">7</span><span class="Punctuation">)</span><span class="Punctuation">)</span></pre>
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/algorithm.nim#L101" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/algorithm.nim#L101" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="reversed-procs-all">
|
||||
<div id="reversed,openArray[T]">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#reversed%2CopenArray%5BT%5D"><span class="Identifier">reversed</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">a</span><span class="Other">:</span> <a href="system.html#openArray"><span class="Identifier">openArray</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#seq"><span class="Identifier">seq</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span> {.<span class="Identifier">inline</span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Returns the elements of <tt class="docutils literal"><span class="pre"><span class="Identifier">a</span></span></tt> in reverse order.</p>
|
||||
<p><strong>See also:</strong></p>
|
||||
<ul class="simple"><li><a class="reference external" href="#reverse,openArray[T]">reverse proc</a></li>
|
||||
</ul>
|
||||
|
||||
<p><strong class="examples_text">Example:</strong></p>
|
||||
<pre class="listing"><span class="Identifier">assert</span> <span class="Punctuation">[</span><span class="DecNumber">10</span><span class="Punctuation">,</span> <span class="DecNumber">11</span><span class="Punctuation">,</span> <span class="DecNumber">12</span><span class="Punctuation">]</span><span class="Operator">.</span><span class="Identifier">reversed</span> <span class="Operator">==</span> <span class="Operator">@</span><span class="Punctuation">[</span><span class="DecNumber">12</span><span class="Punctuation">,</span> <span class="DecNumber">11</span><span class="Punctuation">,</span> <span class="DecNumber">10</span><span class="Punctuation">]</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">seq</span><span class="Punctuation">[</span><span class="Identifier">string</span><span class="Punctuation">]</span><span class="Operator">.</span><span class="Identifier">default</span><span class="Operator">.</span><span class="Identifier">reversed</span> <span class="Operator">==</span> <span class="Operator">@</span><span class="Punctuation">[</span><span class="Punctuation">]</span></pre>
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/algorithm.nim#L138" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/algorithm.nim#L138" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
<div id="reversed,openArray[T],Natural,int">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#reversed%2CopenArray%5BT%5D%2CNatural%2Cint"><span class="Identifier">reversed</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">a</span><span class="Other">:</span> <a href="system.html#openArray"><span class="Identifier">openArray</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">first</span><span class="Other">:</span> <a href="system.html#Natural"><span class="Identifier">Natural</span></a><span class="Other">;</span> <span class="Identifier">last</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#seq"><span class="Identifier">seq</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span> {.<span class="Identifier">inline</span><span class="Other">,</span>
|
||||
<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">deprecated</span><span class="Other">:</span> <span class="StringLit">"use: `reversed(toOpenArray(a, first, last))`"</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
<div class="deprecation-message">
|
||||
<b>Deprecated:</b> use: `reversed(toOpenArray(a, first, last))`
|
||||
</div>
|
||||
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/algorithm.nim#L150" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/algorithm.nim#L150" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="rotatedLeft-procs-all">
|
||||
<div id="rotatedLeft,openArray[T],int">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#rotatedLeft%2CopenArray%5BT%5D%2Cint"><span class="Identifier">rotatedLeft</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">arg</span><span class="Other">:</span> <a href="system.html#openArray"><span class="Identifier">openArray</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">dist</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#seq"><span class="Identifier">seq</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span></pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Same as <tt class="docutils literal"><span class="pre"><span class="Identifier">rotateLeft</span></span></tt>, just with the difference that it does not modify the argument. It creates a new <tt class="docutils literal"><span class="pre"><span class="Identifier">seq</span></span></tt> instead.</p>
|
||||
<p><strong>See also:</strong></p>
|
||||
<ul class="simple"><li><a class="reference external" href="#rotateLeft,openArray[T],int">rotateLeft proc</a> for the in-place version of this proc</li>
|
||||
<li><a class="reference external" href="#rotatedLeft,openArray[T],HSlice[int,int],int">rotatedLeft proc</a> for a version which rotates a range</li>
|
||||
</ul>
|
||||
|
||||
<p><strong class="examples_text">Example:</strong></p>
|
||||
<pre class="listing"><span class="Keyword">var</span> <span class="Identifier">a</span> <span class="Operator">=</span> <span class="Operator">@</span><span class="Punctuation">[</span><span class="DecNumber">1</span><span class="Punctuation">,</span> <span class="DecNumber">2</span><span class="Punctuation">,</span> <span class="DecNumber">3</span><span class="Punctuation">,</span> <span class="DecNumber">4</span><span class="Punctuation">,</span> <span class="DecNumber">5</span><span class="Punctuation">]</span>
|
||||
<span class="Identifier">a</span> <span class="Operator">=</span> <span class="Identifier">rotatedLeft</span><span class="Punctuation">(</span><span class="Identifier">a</span><span class="Punctuation">,</span> <span class="DecNumber">2</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">a</span> <span class="Operator">==</span> <span class="Operator">@</span><span class="Punctuation">[</span><span class="DecNumber">3</span><span class="Punctuation">,</span> <span class="DecNumber">4</span><span class="Punctuation">,</span> <span class="DecNumber">5</span><span class="Punctuation">,</span> <span class="DecNumber">1</span><span class="Punctuation">,</span> <span class="DecNumber">2</span><span class="Punctuation">]</span>
|
||||
<span class="Identifier">a</span> <span class="Operator">=</span> <span class="Identifier">rotatedLeft</span><span class="Punctuation">(</span><span class="Identifier">a</span><span class="Punctuation">,</span> <span class="DecNumber">4</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">a</span> <span class="Operator">==</span> <span class="Operator">@</span><span class="Punctuation">[</span><span class="DecNumber">2</span><span class="Punctuation">,</span> <span class="DecNumber">3</span><span class="Punctuation">,</span> <span class="DecNumber">4</span><span class="Punctuation">,</span> <span class="DecNumber">5</span><span class="Punctuation">,</span> <span class="DecNumber">1</span><span class="Punctuation">]</span>
|
||||
<span class="Identifier">a</span> <span class="Operator">=</span> <span class="Identifier">rotatedLeft</span><span class="Punctuation">(</span><span class="Identifier">a</span><span class="Punctuation">,</span> <span class="Operator">-</span><span class="DecNumber">6</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">a</span> <span class="Operator">==</span> <span class="Operator">@</span><span class="Punctuation">[</span><span class="DecNumber">1</span><span class="Punctuation">,</span> <span class="DecNumber">2</span><span class="Punctuation">,</span> <span class="DecNumber">3</span><span class="Punctuation">,</span> <span class="DecNumber">4</span><span class="Punctuation">,</span> <span class="DecNumber">5</span><span class="Punctuation">]</span></pre>
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/algorithm.nim#L900" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/algorithm.nim#L900" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
<div id="rotatedLeft,openArray[T],HSlice[int,int],int">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#rotatedLeft%2CopenArray%5BT%5D%2CHSlice%5Bint%2Cint%5D%2Cint"><span class="Identifier">rotatedLeft</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">arg</span><span class="Other">:</span> <a href="system.html#openArray"><span class="Identifier">openArray</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">slice</span><span class="Other">:</span> <a href="system.html#HSlice"><span class="Identifier">HSlice</span></a><span class="Other">[</span><a href="system.html#int"><span class="Identifier">int</span></a><span class="Other">,</span> <a href="system.html#int"><span class="Identifier">int</span></a><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">dist</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#seq"><span class="Identifier">seq</span></a><span class="Other">[</span>
|
||||
<span class="Identifier">T</span><span class="Other">]</span></pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Same as <tt class="docutils literal"><span class="pre"><span class="Identifier">rotateLeft</span></span></tt>, just with the difference that it does not modify the argument. It creates a new <tt class="docutils literal"><span class="pre"><span class="Identifier">seq</span></span></tt> instead.</p>
|
||||
<p>Elements outside of <tt class="docutils literal"><span class="pre"><span class="Identifier">slice</span></span></tt> will be left unchanged. If an invalid range (<tt class="docutils literal"><span class="pre"><span class="Identifier">HSlice</span></span></tt>) is passed, it raises <tt class="docutils literal"><span class="pre"><span class="Identifier">IndexDefect</span></span></tt>.</p>
|
||||
<dl class="docutils"><dt><tt class="docutils literal"><span class="pre"><span class="Identifier">slice</span></span></tt></dt>
|
||||
<dd>The indices of the element range that should be rotated.</dd>
|
||||
<dt><tt class="docutils literal"><span class="pre"><span class="Identifier">dist</span></span></tt></dt>
|
||||
<dd>The distance in amount of elements that the data should be rotated. Can be negative, can be any number.</dd>
|
||||
</dl>
|
||||
<p><strong>See also:</strong></p>
|
||||
<ul class="simple"><li><a class="reference external" href="#rotateLeft,openArray[T],HSlice[int,int],int">rotateLeft proc</a> for the in-place version of this proc</li>
|
||||
<li><a class="reference external" href="#rotatedLeft,openArray[T],int">rotatedLeft proc</a> for a version which rotates the whole container</li>
|
||||
</ul>
|
||||
|
||||
<p><strong class="examples_text">Example:</strong></p>
|
||||
<pre class="listing"><span class="Keyword">var</span> <span class="Identifier">a</span> <span class="Operator">=</span> <span class="Operator">@</span><span class="Punctuation">[</span><span class="DecNumber">1</span><span class="Punctuation">,</span> <span class="DecNumber">2</span><span class="Punctuation">,</span> <span class="DecNumber">3</span><span class="Punctuation">,</span> <span class="DecNumber">4</span><span class="Punctuation">,</span> <span class="DecNumber">5</span><span class="Punctuation">]</span>
|
||||
<span class="Identifier">a</span> <span class="Operator">=</span> <span class="Identifier">rotatedLeft</span><span class="Punctuation">(</span><span class="Identifier">a</span><span class="Punctuation">,</span> <span class="DecNumber">1</span> <span class="Operator">..</span> <span class="DecNumber">4</span><span class="Punctuation">,</span> <span class="DecNumber">3</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">a</span> <span class="Operator">==</span> <span class="Operator">@</span><span class="Punctuation">[</span><span class="DecNumber">1</span><span class="Punctuation">,</span> <span class="DecNumber">5</span><span class="Punctuation">,</span> <span class="DecNumber">2</span><span class="Punctuation">,</span> <span class="DecNumber">3</span><span class="Punctuation">,</span> <span class="DecNumber">4</span><span class="Punctuation">]</span>
|
||||
<span class="Identifier">a</span> <span class="Operator">=</span> <span class="Identifier">rotatedLeft</span><span class="Punctuation">(</span><span class="Identifier">a</span><span class="Punctuation">,</span> <span class="DecNumber">1</span> <span class="Operator">..</span> <span class="DecNumber">3</span><span class="Punctuation">,</span> <span class="DecNumber">2</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">a</span> <span class="Operator">==</span> <span class="Operator">@</span><span class="Punctuation">[</span><span class="DecNumber">1</span><span class="Punctuation">,</span> <span class="DecNumber">3</span><span class="Punctuation">,</span> <span class="DecNumber">5</span><span class="Punctuation">,</span> <span class="DecNumber">2</span><span class="Punctuation">,</span> <span class="DecNumber">4</span><span class="Punctuation">]</span>
|
||||
<span class="Identifier">a</span> <span class="Operator">=</span> <span class="Identifier">rotatedLeft</span><span class="Punctuation">(</span><span class="Identifier">a</span><span class="Punctuation">,</span> <span class="DecNumber">1</span> <span class="Operator">..</span> <span class="DecNumber">3</span><span class="Punctuation">,</span> <span class="Operator">-</span><span class="DecNumber">2</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">a</span> <span class="Operator">==</span> <span class="Operator">@</span><span class="Punctuation">[</span><span class="DecNumber">1</span><span class="Punctuation">,</span> <span class="DecNumber">5</span><span class="Punctuation">,</span> <span class="DecNumber">2</span><span class="Punctuation">,</span> <span class="DecNumber">3</span><span class="Punctuation">,</span> <span class="DecNumber">4</span><span class="Punctuation">]</span></pre>
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/algorithm.nim#L870" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/algorithm.nim#L870" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="rotateLeft-procs-all">
|
||||
<div id="rotateLeft,openArray[T],int">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#rotateLeft%2CopenArray%5BT%5D%2Cint"><span class="Identifier">rotateLeft</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">arg</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="system.html#openArray"><span class="Identifier">openArray</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">dist</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a> {.<span class="Identifier">discardable</span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Same as <tt class="docutils literal"><span class="pre"><span class="Identifier">rotateLeft</span></span></tt>, but with default arguments for slice, so that this procedure operates on the entire <tt class="docutils literal"><span class="pre"><span class="Identifier">arg</span></span></tt>, and not just on a part of it.</p>
|
||||
<p><strong>See also:</strong></p>
|
||||
<ul class="simple"><li><a class="reference external" href="#rotateLeft,openArray[T],HSlice[int,int],int">rotateLeft proc</a> for a version which rotates a range</li>
|
||||
<li><a class="reference external" href="#rotatedLeft,openArray[T],int">rotatedLeft proc</a> for a version which returns a <tt class="docutils literal"><span class="pre"><span class="Identifier">seq</span><span class="Punctuation">[</span><span class="Identifier">T</span><span class="Punctuation">]</span></span></tt></li>
|
||||
</ul>
|
||||
|
||||
<p><strong class="examples_text">Example:</strong></p>
|
||||
<pre class="listing"><span class="Keyword">var</span> <span class="Identifier">a</span> <span class="Operator">=</span> <span class="Punctuation">[</span><span class="DecNumber">1</span><span class="Punctuation">,</span> <span class="DecNumber">2</span><span class="Punctuation">,</span> <span class="DecNumber">3</span><span class="Punctuation">,</span> <span class="DecNumber">4</span><span class="Punctuation">,</span> <span class="DecNumber">5</span><span class="Punctuation">]</span>
|
||||
<span class="Identifier">a</span><span class="Operator">.</span><span class="Identifier">rotateLeft</span><span class="Punctuation">(</span><span class="DecNumber">2</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">a</span> <span class="Operator">==</span> <span class="Punctuation">[</span><span class="DecNumber">3</span><span class="Punctuation">,</span> <span class="DecNumber">4</span><span class="Punctuation">,</span> <span class="DecNumber">5</span><span class="Punctuation">,</span> <span class="DecNumber">1</span><span class="Punctuation">,</span> <span class="DecNumber">2</span><span class="Punctuation">]</span>
|
||||
<span class="Identifier">a</span><span class="Operator">.</span><span class="Identifier">rotateLeft</span><span class="Punctuation">(</span><span class="DecNumber">4</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">a</span> <span class="Operator">==</span> <span class="Punctuation">[</span><span class="DecNumber">2</span><span class="Punctuation">,</span> <span class="DecNumber">3</span><span class="Punctuation">,</span> <span class="DecNumber">4</span><span class="Punctuation">,</span> <span class="DecNumber">5</span><span class="Punctuation">,</span> <span class="DecNumber">1</span><span class="Punctuation">]</span>
|
||||
<span class="Identifier">a</span><span class="Operator">.</span><span class="Identifier">rotateLeft</span><span class="Punctuation">(</span><span class="Operator">-</span><span class="DecNumber">6</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">a</span> <span class="Operator">==</span> <span class="Punctuation">[</span><span class="DecNumber">1</span><span class="Punctuation">,</span> <span class="DecNumber">2</span><span class="Punctuation">,</span> <span class="DecNumber">3</span><span class="Punctuation">,</span> <span class="DecNumber">4</span><span class="Punctuation">,</span> <span class="DecNumber">5</span><span class="Punctuation">]</span></pre>
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/algorithm.nim#L850" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/algorithm.nim#L850" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
<div id="rotateLeft,openArray[T],HSlice[int,int],int">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#rotateLeft%2CopenArray%5BT%5D%2CHSlice%5Bint%2Cint%5D%2Cint"><span class="Identifier">rotateLeft</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">arg</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="system.html#openArray"><span class="Identifier">openArray</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">slice</span><span class="Other">:</span> <a href="system.html#HSlice"><span class="Identifier">HSlice</span></a><span class="Other">[</span><a href="system.html#int"><span class="Identifier">int</span></a><span class="Other">,</span> <a href="system.html#int"><span class="Identifier">int</span></a><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">dist</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a> {.
|
||||
<span class="Identifier">discardable</span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Performs a left rotation on a range of elements. If you want to rotate right, use a negative <tt class="docutils literal"><span class="pre"><span class="Identifier">dist</span></span></tt>. Specifically, <tt class="docutils literal"><span class="pre"><span class="Identifier">rotateLeft</span></span></tt> rotates the elements at <tt class="docutils literal"><span class="pre"><span class="Identifier">slice</span></span></tt> by <tt class="docutils literal"><span class="pre"><span class="Identifier">dist</span></span></tt> positions.<p>The element at index <tt class="docutils literal"><span class="pre"><span class="Identifier">slice</span><span class="Operator">.</span><span class="Identifier">a</span> <span class="Operator">+</span> <span class="Identifier">dist</span></span></tt> will be at index <tt class="docutils literal"><span class="pre"><span class="Identifier">slice</span><span class="Operator">.</span><span class="Identifier">a</span></span></tt>.<br/>The element at index <tt class="docutils literal"><span class="pre"><span class="Identifier">slice</span><span class="Operator">.</span><span class="Identifier">b</span></span></tt> will be at <tt class="docutils literal"><span class="pre"><span class="Identifier">slice</span><span class="Operator">.</span><span class="Identifier">a</span> <span class="Operator">+</span> <span class="Identifier">dist</span> <span class="Operator">-</span> <span class="DecNumber">1</span></span></tt>.<br/>The element at index <tt class="docutils literal"><span class="pre"><span class="Identifier">slice</span><span class="Operator">.</span><span class="Identifier">a</span></span></tt> will be at <tt class="docutils literal"><span class="pre"><span class="Identifier">slice</span><span class="Operator">.</span><span class="Identifier">b</span> <span class="Operator">+</span> <span class="DecNumber">1</span> <span class="Operator">-</span> <span class="Identifier">dist</span></span></tt>.<br/>The element at index <tt class="docutils literal"><span class="pre"><span class="Identifier">slice</span><span class="Operator">.</span><span class="Identifier">a</span> <span class="Operator">+</span> <span class="Identifier">dist</span> <span class="Operator">-</span> <span class="DecNumber">1</span></span></tt> will be at <tt class="docutils literal"><span class="pre"><span class="Identifier">slice</span><span class="Operator">.</span><span class="Identifier">b</span></span></tt>.<br/></p><p>Elements outside of <tt class="docutils literal"><span class="pre"><span class="Identifier">slice</span></span></tt> will be left unchanged. The time complexity is linear to <tt class="docutils literal"><span class="pre"><span class="Identifier">slice</span><span class="Operator">.</span><span class="Identifier">b</span> <span class="Operator">-</span> <span class="Identifier">slice</span><span class="Operator">.</span><span class="Identifier">a</span> <span class="Operator">+</span> <span class="DecNumber">1</span></span></tt>. If an invalid range (<tt class="docutils literal"><span class="pre"><span class="Identifier">HSlice</span></span></tt>) is passed, it raises <tt class="docutils literal"><span class="pre"><span class="Identifier">IndexDefect</span></span></tt>.</p>
|
||||
<dl class="docutils"><dt><tt class="docutils literal"><span class="pre"><span class="Identifier">slice</span></span></tt></dt>
|
||||
<dd>The indices of the element range that should be rotated.</dd>
|
||||
<dt><tt class="docutils literal"><span class="pre"><span class="Identifier">dist</span></span></tt></dt>
|
||||
<dd>The distance in amount of elements that the data should be rotated. Can be negative, can be any number.</dd>
|
||||
</dl>
|
||||
<p><strong>See also:</strong></p>
|
||||
<ul class="simple"><li><a class="reference external" href="#rotateLeft,openArray[T],int">rotateLeft proc</a> for a version which rotates the whole container</li>
|
||||
<li><a class="reference external" href="#rotatedLeft,openArray[T],HSlice[int,int],int">rotatedLeft proc</a> for a version which returns a <tt class="docutils literal"><span class="pre"><span class="Identifier">seq</span><span class="Punctuation">[</span><span class="Identifier">T</span><span class="Punctuation">]</span></span></tt></li>
|
||||
</ul>
|
||||
|
||||
<p><strong class="examples_text">Example:</strong></p>
|
||||
<pre class="listing"><span class="Keyword">var</span> <span class="Identifier">a</span> <span class="Operator">=</span> <span class="Punctuation">[</span><span class="DecNumber">0</span><span class="Punctuation">,</span> <span class="DecNumber">1</span><span class="Punctuation">,</span> <span class="DecNumber">2</span><span class="Punctuation">,</span> <span class="DecNumber">3</span><span class="Punctuation">,</span> <span class="DecNumber">4</span><span class="Punctuation">,</span> <span class="DecNumber">5</span><span class="Punctuation">]</span>
|
||||
<span class="Identifier">a</span><span class="Operator">.</span><span class="Identifier">rotateLeft</span><span class="Punctuation">(</span><span class="DecNumber">1</span> <span class="Operator">..</span> <span class="DecNumber">4</span><span class="Punctuation">,</span> <span class="DecNumber">3</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">a</span> <span class="Operator">==</span> <span class="Punctuation">[</span><span class="DecNumber">0</span><span class="Punctuation">,</span> <span class="DecNumber">4</span><span class="Punctuation">,</span> <span class="DecNumber">1</span><span class="Punctuation">,</span> <span class="DecNumber">2</span><span class="Punctuation">,</span> <span class="DecNumber">3</span><span class="Punctuation">,</span> <span class="DecNumber">5</span><span class="Punctuation">]</span>
|
||||
<span class="Identifier">a</span><span class="Operator">.</span><span class="Identifier">rotateLeft</span><span class="Punctuation">(</span><span class="DecNumber">1</span> <span class="Operator">..</span> <span class="DecNumber">4</span><span class="Punctuation">,</span> <span class="DecNumber">3</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">a</span> <span class="Operator">==</span> <span class="Punctuation">[</span><span class="DecNumber">0</span><span class="Punctuation">,</span> <span class="DecNumber">3</span><span class="Punctuation">,</span> <span class="DecNumber">4</span><span class="Punctuation">,</span> <span class="DecNumber">1</span><span class="Punctuation">,</span> <span class="DecNumber">2</span><span class="Punctuation">,</span> <span class="DecNumber">5</span><span class="Punctuation">]</span>
|
||||
<span class="Identifier">a</span><span class="Operator">.</span><span class="Identifier">rotateLeft</span><span class="Punctuation">(</span><span class="DecNumber">1</span> <span class="Operator">..</span> <span class="DecNumber">4</span><span class="Punctuation">,</span> <span class="Operator">-</span><span class="DecNumber">3</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">a</span> <span class="Operator">==</span> <span class="Punctuation">[</span><span class="DecNumber">0</span><span class="Punctuation">,</span> <span class="DecNumber">4</span><span class="Punctuation">,</span> <span class="DecNumber">1</span><span class="Punctuation">,</span> <span class="DecNumber">2</span><span class="Punctuation">,</span> <span class="DecNumber">3</span><span class="Punctuation">,</span> <span class="DecNumber">5</span><span class="Punctuation">]</span>
|
||||
<span class="Identifier">doAssertRaises</span><span class="Punctuation">(</span><span class="Identifier">IndexDefect</span><span class="Punctuation">,</span> <span class="Identifier">a</span><span class="Operator">.</span><span class="Identifier">rotateLeft</span><span class="Punctuation">(</span><span class="DecNumber">1</span> <span class="Operator">..</span> <span class="DecNumber">7</span><span class="Punctuation">,</span> <span class="DecNumber">2</span><span class="Punctuation">)</span><span class="Punctuation">)</span></pre>
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/algorithm.nim#L812" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/algorithm.nim#L812" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="sort-procs-all">
|
||||
<div id="sort,openArray[T],proc(T,T)">
|
||||
<dt><pre><span class="Keyword">func</span> <a href="#sort%2CopenArray%5BT%5D%2Cproc%28T%2CT%29"><span class="Identifier">sort</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">a</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="system.html#openArray"><span class="Identifier">openArray</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">cmp</span><span class="Other">:</span> <span class="Keyword">proc</span> <span class="Other">(</span><span class="Identifier">x</span><span class="Other">,</span> <span class="Identifier">y</span><span class="Other">:</span> <span class="Identifier">T</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a> {.<span class="Identifier">closure</span>.}<span class="Other">;</span>
|
||||
<span class="Identifier">order</span> <span class="Other">=</span> <a href="algorithm.html#SortOrder"><span class="Identifier">SortOrder</span></a><span class="Other">.</span><span class="Identifier">Ascending</span><span class="Other">)</span> {.<span class="Identifier">effectsOf</span><span class="Other">:</span> <span class="Identifier">cmp</span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Default Nim sort (an implementation of merge sort). The sorting is guaranteed to be stable (that is, equal elements stay in the same order) and the worst case is guaranteed to be O(n log n). Sorts by <tt class="docutils literal"><span class="pre"><span class="Identifier">cmp</span></span></tt> in the specified <tt class="docutils literal"><span class="pre"><span class="Identifier">order</span></span></tt>.</p>
|
||||
<p>The current implementation uses an iterative mergesort to achieve this. It uses a temporary sequence of length <tt class="docutils literal"><span class="pre"><span class="Identifier">a</span><span class="Operator">.</span><span class="Identifier">len</span> <span class="Keyword">div</span> <span class="DecNumber">2</span></span></tt>. If you do not wish to provide your own <tt class="docutils literal"><span class="pre"><span class="Identifier">cmp</span></span></tt>, you may use <tt class="docutils literal"><span class="pre"><span class="Identifier">system</span><span class="Operator">.</span><span class="Identifier">cmp</span></span></tt> or instead call the overloaded version of <tt class="docutils literal"><span class="pre"><span class="Identifier">sort</span></span></tt>, which uses <tt class="docutils literal"><span class="pre"><span class="Identifier">system</span><span class="Operator">.</span><span class="Identifier">cmp</span></span></tt>.</p>
|
||||
<p><pre class="listing">
|
||||
<span class="Identifier">sort</span><span class="Punctuation">(</span><span class="Identifier">myIntArray</span><span class="Punctuation">,</span> <span class="Identifier">system</span><span class="Operator">.</span><span class="Identifier">cmp</span><span class="Punctuation">[</span><span class="Identifier">int</span><span class="Punctuation">]</span><span class="Punctuation">)</span>
|
||||
<span class="Comment"># do not use cmp[string] here as we want to use the specialized</span>
|
||||
<span class="Comment"># overload:</span>
|
||||
<span class="Identifier">sort</span><span class="Punctuation">(</span><span class="Identifier">myStrArray</span><span class="Punctuation">,</span> <span class="Identifier">system</span><span class="Operator">.</span><span class="Identifier">cmp</span><span class="Punctuation">)</span></pre></p>
|
||||
<p>You can inline adhoc comparison procs with the <a class="reference external" href="manual_experimental.html#do-notation">do notation</a>. Example:</p>
|
||||
<p><pre class="listing">
|
||||
<span class="Identifier">people</span><span class="Operator">.</span><span class="Identifier">sort</span> <span class="Keyword">do</span> <span class="Punctuation">(</span><span class="Identifier">x</span><span class="Punctuation">,</span> <span class="Identifier">y</span><span class="Punctuation">:</span> <span class="Identifier">Person</span><span class="Punctuation">)</span> <span class="Operator">-></span> <span class="Identifier">int</span><span class="Punctuation">:</span>
|
||||
<span class="Identifier">result</span> <span class="Operator">=</span> <span class="Identifier">cmp</span><span class="Punctuation">(</span><span class="Identifier">x</span><span class="Operator">.</span><span class="Identifier">surname</span><span class="Punctuation">,</span> <span class="Identifier">y</span><span class="Operator">.</span><span class="Identifier">surname</span><span class="Punctuation">)</span>
|
||||
<span class="Keyword">if</span> <span class="Identifier">result</span> <span class="Operator">==</span> <span class="DecNumber">0</span><span class="Punctuation">:</span>
|
||||
<span class="Identifier">result</span> <span class="Operator">=</span> <span class="Identifier">cmp</span><span class="Punctuation">(</span><span class="Identifier">x</span><span class="Operator">.</span><span class="Identifier">name</span><span class="Punctuation">,</span> <span class="Identifier">y</span><span class="Operator">.</span><span class="Identifier">name</span><span class="Punctuation">)</span></pre></p>
|
||||
<p><strong>See also:</strong></p>
|
||||
<ul class="simple"><li><a class="reference external" href="#sort,openArray[T]">sort proc</a></li>
|
||||
<li><a class="reference external" href="#sorted,openArray[T],proc(T,T)">sorted proc</a> sorted by <tt class="docutils literal"><span class="pre"><span class="Identifier">cmp</span></span></tt> in the specified order</li>
|
||||
<li><a class="reference external" href="#sorted,openArray[T]">sorted proc</a></li>
|
||||
<li><a class="reference external" href="#sortedByIt.t,untyped,untyped">sortedByIt template</a></li>
|
||||
</ul>
|
||||
|
||||
<p><strong class="examples_text">Example:</strong></p>
|
||||
<pre class="listing"><span class="Keyword">var</span> <span class="Identifier">d</span> <span class="Operator">=</span> <span class="Punctuation">[</span><span class="StringLit">"boo"</span><span class="Punctuation">,</span> <span class="StringLit">"fo"</span><span class="Punctuation">,</span> <span class="StringLit">"barr"</span><span class="Punctuation">,</span> <span class="StringLit">"qux"</span><span class="Punctuation">]</span>
|
||||
<span class="Keyword">proc</span> <span class="Identifier">myCmp</span><span class="Punctuation">(</span><span class="Identifier">x</span><span class="Punctuation">,</span> <span class="Identifier">y</span><span class="Punctuation">:</span> <span class="Identifier">string</span><span class="Punctuation">)</span><span class="Punctuation">:</span> <span class="Identifier">int</span> <span class="Operator">=</span>
|
||||
<span class="Keyword">if</span> <span class="Identifier">x</span><span class="Operator">.</span><span class="Identifier">len</span><span class="Punctuation">(</span><span class="Punctuation">)</span> <span class="Operator">></span> <span class="Identifier">y</span><span class="Operator">.</span><span class="Identifier">len</span><span class="Punctuation">(</span><span class="Punctuation">)</span> <span class="Keyword">or</span> <span class="Identifier">x</span><span class="Operator">.</span><span class="Identifier">len</span><span class="Punctuation">(</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="Identifier">y</span><span class="Operator">.</span><span class="Identifier">len</span><span class="Punctuation">(</span><span class="Punctuation">)</span><span class="Punctuation">:</span> <span class="DecNumber">1</span>
|
||||
<span class="Keyword">else</span><span class="Punctuation">:</span> <span class="Operator">-</span><span class="DecNumber">1</span>
|
||||
<span class="Identifier">sort</span><span class="Punctuation">(</span><span class="Identifier">d</span><span class="Punctuation">,</span> <span class="Identifier">myCmp</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">d</span> <span class="Operator">==</span> <span class="Punctuation">[</span><span class="StringLit">"fo"</span><span class="Punctuation">,</span> <span class="StringLit">"qux"</span><span class="Punctuation">,</span> <span class="StringLit">"boo"</span><span class="Punctuation">,</span> <span class="StringLit">"barr"</span><span class="Punctuation">]</span></pre>
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/algorithm.nim#L368" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/algorithm.nim#L368" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
<div id="sort,openArray[T]">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#sort%2CopenArray%5BT%5D"><span class="Identifier">sort</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">a</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="system.html#openArray"><span class="Identifier">openArray</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">order</span> <span class="Other">=</span> <a href="algorithm.html#SortOrder"><span class="Identifier">SortOrder</span></a><span class="Other">.</span><span class="Identifier">Ascending</span><span class="Other">)</span></pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Shortcut version of <tt class="docutils literal"><span class="pre"><span class="Identifier">sort</span></span></tt> that uses <tt class="docutils literal"><span class="pre"><span class="Identifier">system</span><span class="Operator">.</span><span class="Identifier">cmp</span><span class="Punctuation">[</span><span class="Identifier">T</span><span class="Punctuation">]</span></span></tt> as the comparison function.</p>
|
||||
<p><strong>See also:</strong></p>
|
||||
<ul class="simple"><li><a class="reference external" href="#sort,openArray[T],proc(T,T)">sort func</a></li>
|
||||
<li><a class="reference external" href="#sorted,openArray[T],proc(T,T)">sorted proc</a> sorted by <tt class="docutils literal"><span class="pre"><span class="Identifier">cmp</span></span></tt> in the specified order</li>
|
||||
<li><a class="reference external" href="#sorted,openArray[T]">sorted proc</a></li>
|
||||
<li><a class="reference external" href="#sortedByIt.t,untyped,untyped">sortedByIt template</a></li>
|
||||
</ul>
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/algorithm.nim#L421" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/algorithm.nim#L421" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="sorted-procs-all">
|
||||
<div id="sorted,openArray[T],proc(T,T)">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#sorted%2CopenArray%5BT%5D%2Cproc%28T%2CT%29"><span class="Identifier">sorted</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">a</span><span class="Other">:</span> <a href="system.html#openArray"><span class="Identifier">openArray</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">cmp</span><span class="Other">:</span> <span class="Keyword">proc</span> <span class="Other">(</span><span class="Identifier">x</span><span class="Other">,</span> <span class="Identifier">y</span><span class="Other">:</span> <span class="Identifier">T</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a> {.<span class="Identifier">closure</span>.}<span class="Other">;</span>
|
||||
<span class="Identifier">order</span> <span class="Other">=</span> <a href="algorithm.html#SortOrder"><span class="Identifier">SortOrder</span></a><span class="Other">.</span><span class="Identifier">Ascending</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#seq"><span class="Identifier">seq</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span> {.<span class="Identifier">effectsOf</span><span class="Other">:</span> <span class="Identifier">cmp</span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Returns <tt class="docutils literal"><span class="pre"><span class="Identifier">a</span></span></tt> sorted by <tt class="docutils literal"><span class="pre"><span class="Identifier">cmp</span></span></tt> in the specified <tt class="docutils literal"><span class="pre"><span class="Identifier">order</span></span></tt>.</p>
|
||||
<p><strong>See also:</strong></p>
|
||||
<ul class="simple"><li><a class="reference external" href="#sort,openArray[T],proc(T,T)">sort func</a></li>
|
||||
<li><a class="reference external" href="#sort,openArray[T]">sort proc</a></li>
|
||||
<li><a class="reference external" href="#sortedByIt.t,untyped,untyped">sortedByIt template</a></li>
|
||||
</ul>
|
||||
|
||||
<p><strong class="examples_text">Example:</strong></p>
|
||||
<pre class="listing"><span class="Keyword">let</span>
|
||||
<span class="Identifier">a</span> <span class="Operator">=</span> <span class="Punctuation">[</span><span class="DecNumber">2</span><span class="Punctuation">,</span> <span class="DecNumber">3</span><span class="Punctuation">,</span> <span class="DecNumber">1</span><span class="Punctuation">,</span> <span class="DecNumber">5</span><span class="Punctuation">,</span> <span class="DecNumber">4</span><span class="Punctuation">]</span>
|
||||
<span class="Identifier">b</span> <span class="Operator">=</span> <span class="Identifier">sorted</span><span class="Punctuation">(</span><span class="Identifier">a</span><span class="Punctuation">,</span> <span class="Identifier">system</span><span class="Operator">.</span><span class="Identifier">cmp</span><span class="Punctuation">[</span><span class="Identifier">int</span><span class="Punctuation">]</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">c</span> <span class="Operator">=</span> <span class="Identifier">sorted</span><span class="Punctuation">(</span><span class="Identifier">a</span><span class="Punctuation">,</span> <span class="Identifier">system</span><span class="Operator">.</span><span class="Identifier">cmp</span><span class="Punctuation">[</span><span class="Identifier">int</span><span class="Punctuation">]</span><span class="Punctuation">,</span> <span class="Identifier">Descending</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">d</span> <span class="Operator">=</span> <span class="Identifier">sorted</span><span class="Punctuation">(</span><span class="Punctuation">[</span><span class="StringLit">"adam"</span><span class="Punctuation">,</span> <span class="StringLit">"dande"</span><span class="Punctuation">,</span> <span class="StringLit">"brian"</span><span class="Punctuation">,</span> <span class="StringLit">"cat"</span><span class="Punctuation">]</span><span class="Punctuation">,</span> <span class="Identifier">system</span><span class="Operator">.</span><span class="Identifier">cmp</span><span class="Punctuation">[</span><span class="Identifier">string</span><span class="Punctuation">]</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">b</span> <span class="Operator">==</span> <span class="Operator">@</span><span class="Punctuation">[</span><span class="DecNumber">1</span><span class="Punctuation">,</span> <span class="DecNumber">2</span><span class="Punctuation">,</span> <span class="DecNumber">3</span><span class="Punctuation">,</span> <span class="DecNumber">4</span><span class="Punctuation">,</span> <span class="DecNumber">5</span><span class="Punctuation">]</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">c</span> <span class="Operator">==</span> <span class="Operator">@</span><span class="Punctuation">[</span><span class="DecNumber">5</span><span class="Punctuation">,</span> <span class="DecNumber">4</span><span class="Punctuation">,</span> <span class="DecNumber">3</span><span class="Punctuation">,</span> <span class="DecNumber">2</span><span class="Punctuation">,</span> <span class="DecNumber">1</span><span class="Punctuation">]</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">d</span> <span class="Operator">==</span> <span class="Operator">@</span><span class="Punctuation">[</span><span class="StringLit">"adam"</span><span class="Punctuation">,</span> <span class="StringLit">"brian"</span><span class="Punctuation">,</span> <span class="StringLit">"cat"</span><span class="Punctuation">,</span> <span class="StringLit">"dande"</span><span class="Punctuation">]</span></pre>
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/algorithm.nim#L431" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/algorithm.nim#L431" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
<div id="sorted,openArray[T]">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#sorted%2CopenArray%5BT%5D"><span class="Identifier">sorted</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">a</span><span class="Other">:</span> <a href="system.html#openArray"><span class="Identifier">openArray</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">order</span> <span class="Other">=</span> <a href="algorithm.html#SortOrder"><span class="Identifier">SortOrder</span></a><span class="Other">.</span><span class="Identifier">Ascending</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#seq"><span class="Identifier">seq</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span></pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Shortcut version of <tt class="docutils literal"><span class="pre"><span class="Identifier">sorted</span></span></tt> that uses <tt class="docutils literal"><span class="pre"><span class="Identifier">system</span><span class="Operator">.</span><span class="Identifier">cmp</span><span class="Punctuation">[</span><span class="Identifier">T</span><span class="Punctuation">]</span></span></tt> as the comparison function.</p>
|
||||
<p><strong>See also:</strong></p>
|
||||
<ul class="simple"><li><a class="reference external" href="#sort,openArray[T],proc(T,T)">sort func</a></li>
|
||||
<li><a class="reference external" href="#sort,openArray[T]">sort proc</a></li>
|
||||
<li><a class="reference external" href="#sortedByIt.t,untyped,untyped">sortedByIt template</a></li>
|
||||
</ul>
|
||||
|
||||
<p><strong class="examples_text">Example:</strong></p>
|
||||
<pre class="listing"><span class="Keyword">let</span>
|
||||
<span class="Identifier">a</span> <span class="Operator">=</span> <span class="Punctuation">[</span><span class="DecNumber">2</span><span class="Punctuation">,</span> <span class="DecNumber">3</span><span class="Punctuation">,</span> <span class="DecNumber">1</span><span class="Punctuation">,</span> <span class="DecNumber">5</span><span class="Punctuation">,</span> <span class="DecNumber">4</span><span class="Punctuation">]</span>
|
||||
<span class="Identifier">b</span> <span class="Operator">=</span> <span class="Identifier">sorted</span><span class="Punctuation">(</span><span class="Identifier">a</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">c</span> <span class="Operator">=</span> <span class="Identifier">sorted</span><span class="Punctuation">(</span><span class="Identifier">a</span><span class="Punctuation">,</span> <span class="Identifier">Descending</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">d</span> <span class="Operator">=</span> <span class="Identifier">sorted</span><span class="Punctuation">(</span><span class="Punctuation">[</span><span class="StringLit">"adam"</span><span class="Punctuation">,</span> <span class="StringLit">"dande"</span><span class="Punctuation">,</span> <span class="StringLit">"brian"</span><span class="Punctuation">,</span> <span class="StringLit">"cat"</span><span class="Punctuation">]</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">b</span> <span class="Operator">==</span> <span class="Operator">@</span><span class="Punctuation">[</span><span class="DecNumber">1</span><span class="Punctuation">,</span> <span class="DecNumber">2</span><span class="Punctuation">,</span> <span class="DecNumber">3</span><span class="Punctuation">,</span> <span class="DecNumber">4</span><span class="Punctuation">,</span> <span class="DecNumber">5</span><span class="Punctuation">]</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">c</span> <span class="Operator">==</span> <span class="Operator">@</span><span class="Punctuation">[</span><span class="DecNumber">5</span><span class="Punctuation">,</span> <span class="DecNumber">4</span><span class="Punctuation">,</span> <span class="DecNumber">3</span><span class="Punctuation">,</span> <span class="DecNumber">2</span><span class="Punctuation">,</span> <span class="DecNumber">1</span><span class="Punctuation">]</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">d</span> <span class="Operator">==</span> <span class="Operator">@</span><span class="Punctuation">[</span><span class="StringLit">"adam"</span><span class="Punctuation">,</span> <span class="StringLit">"brian"</span><span class="Punctuation">,</span> <span class="StringLit">"cat"</span><span class="Punctuation">,</span> <span class="StringLit">"dande"</span><span class="Punctuation">]</span></pre>
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/algorithm.nim#L453" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/algorithm.nim#L453" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="upperBound-procs-all">
|
||||
<div id="upperBound,openArray[T],K,proc(T,K)">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#upperBound%2CopenArray%5BT%5D%2CK%2Cproc%28T%2CK%29"><span class="Identifier">upperBound</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">,</span> <span class="Identifier">K</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">a</span><span class="Other">:</span> <a href="system.html#openArray"><span class="Identifier">openArray</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">key</span><span class="Other">:</span> <span class="Identifier">K</span><span class="Other">;</span>
|
||||
<span class="Identifier">cmp</span><span class="Other">:</span> <span class="Keyword">proc</span> <span class="Other">(</span><span class="Identifier">x</span><span class="Other">:</span> <span class="Identifier">T</span><span class="Other">;</span> <span class="Identifier">k</span><span class="Other">:</span> <span class="Identifier">K</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a> {.<span class="Identifier">closure</span>.}<span class="Other">)</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a> {.
|
||||
<span class="Identifier">effectsOf</span><span class="Other">:</span> <span class="Identifier">cmp</span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Returns the index of the first element in <tt class="docutils literal"><span class="pre"><span class="Identifier">a</span></span></tt> that is greater than <tt class="docutils literal"><span class="pre"><span class="Identifier">key</span></span></tt>, or last if no such element is found. In other words if you have a sorted sequence and you call <tt class="docutils literal"><span class="pre"><span class="Identifier">insert</span><span class="Punctuation">(</span><span class="Identifier">thing</span><span class="Punctuation">,</span> <span class="Identifier">elm</span><span class="Punctuation">,</span> <span class="Identifier">upperBound</span><span class="Punctuation">(</span><span class="Identifier">thing</span><span class="Punctuation">,</span> <span class="Identifier">elm</span><span class="Punctuation">)</span><span class="Punctuation">)</span></span></tt> the sequence will still be sorted. Assumes that <tt class="docutils literal"><span class="pre"><span class="Identifier">a</span></span></tt> is sorted according to <tt class="docutils literal"><span class="pre"><span class="Identifier">cmp</span></span></tt>.</p>
|
||||
<p>If an invalid range is passed, it raises <tt class="docutils literal"><span class="pre"><span class="Identifier">IndexDefect</span></span></tt>.</p>
|
||||
<p>This version uses <tt class="docutils literal"><span class="pre"><span class="Identifier">cmp</span></span></tt> to compare the elements. The expected return values are the same as those of <tt class="docutils literal"><span class="pre"><span class="Identifier">system</span><span class="Operator">.</span><span class="Identifier">cmp</span></span></tt>.</p>
|
||||
<p><strong>See also:</strong></p>
|
||||
<ul class="simple"><li><a class="reference external" href="#lowerBound,openArray[T],K,proc(T,K)">lowerBound proc</a> sorted by <tt class="docutils literal"><span class="pre"><span class="Identifier">cmp</span></span></tt> in the specified order</li>
|
||||
<li><a class="reference external" href="#lowerBound,openArray[T],T">lowerBound proc</a></li>
|
||||
</ul>
|
||||
|
||||
<p><strong class="examples_text">Example:</strong></p>
|
||||
<pre class="listing"><span class="Keyword">var</span> <span class="Identifier">arr</span> <span class="Operator">=</span> <span class="Operator">@</span><span class="Punctuation">[</span><span class="DecNumber">1</span><span class="Punctuation">,</span> <span class="DecNumber">2</span><span class="Punctuation">,</span> <span class="DecNumber">3</span><span class="Punctuation">,</span> <span class="DecNumber">5</span><span class="Punctuation">,</span> <span class="DecNumber">6</span><span class="Punctuation">,</span> <span class="DecNumber">7</span><span class="Punctuation">,</span> <span class="DecNumber">8</span><span class="Punctuation">,</span> <span class="DecNumber">9</span><span class="Punctuation">]</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">arr</span><span class="Operator">.</span><span class="Identifier">upperBound</span><span class="Punctuation">(</span><span class="DecNumber">2</span><span class="Punctuation">,</span> <span class="Identifier">system</span><span class="Operator">.</span><span class="Identifier">cmp</span><span class="Punctuation">[</span><span class="Identifier">int</span><span class="Punctuation">]</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">2</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">arr</span><span class="Operator">.</span><span class="Identifier">upperBound</span><span class="Punctuation">(</span><span class="DecNumber">3</span><span class="Punctuation">,</span> <span class="Identifier">system</span><span class="Operator">.</span><span class="Identifier">cmp</span><span class="Punctuation">[</span><span class="Identifier">int</span><span class="Punctuation">]</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">3</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">arr</span><span class="Operator">.</span><span class="Identifier">upperBound</span><span class="Punctuation">(</span><span class="DecNumber">4</span><span class="Punctuation">,</span> <span class="Identifier">system</span><span class="Operator">.</span><span class="Identifier">cmp</span><span class="Punctuation">[</span><span class="Identifier">int</span><span class="Punctuation">]</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">3</span>
|
||||
<span class="Identifier">arr</span><span class="Operator">.</span><span class="Identifier">insert</span><span class="Punctuation">(</span><span class="DecNumber">4</span><span class="Punctuation">,</span> <span class="Identifier">arr</span><span class="Operator">.</span><span class="Identifier">upperBound</span><span class="Punctuation">(</span><span class="DecNumber">3</span><span class="Punctuation">,</span> <span class="Identifier">system</span><span class="Operator">.</span><span class="Identifier">cmp</span><span class="Punctuation">[</span><span class="Identifier">int</span><span class="Punctuation">]</span><span class="Punctuation">)</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">arr</span> <span class="Operator">==</span> <span class="Punctuation">[</span><span class="DecNumber">1</span><span class="Punctuation">,</span> <span class="DecNumber">2</span><span class="Punctuation">,</span> <span class="DecNumber">3</span><span class="Punctuation">,</span> <span class="DecNumber">4</span><span class="Punctuation">,</span> <span class="DecNumber">5</span><span class="Punctuation">,</span> <span class="DecNumber">6</span><span class="Punctuation">,</span> <span class="DecNumber">7</span><span class="Punctuation">,</span> <span class="DecNumber">8</span><span class="Punctuation">,</span> <span class="DecNumber">9</span><span class="Punctuation">]</span></pre>
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/algorithm.nim#L271" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/algorithm.nim#L271" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
<div id="upperBound,openArray[T],T">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#upperBound%2CopenArray%5BT%5D%2CT"><span class="Identifier">upperBound</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">a</span><span class="Other">:</span> <a href="system.html#openArray"><span class="Identifier">openArray</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">key</span><span class="Other">:</span> <span class="Identifier">T</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a></pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Returns the index of the first element in <tt class="docutils literal"><span class="pre"><span class="Identifier">a</span></span></tt> that is greater than <tt class="docutils literal"><span class="pre"><span class="Identifier">key</span></span></tt>, or last if no such element is found. In other words if you have a sorted sequence and you call <tt class="docutils literal"><span class="pre"><span class="Identifier">insert</span><span class="Punctuation">(</span><span class="Identifier">thing</span><span class="Punctuation">,</span> <span class="Identifier">elm</span><span class="Punctuation">,</span> <span class="Identifier">upperBound</span><span class="Punctuation">(</span><span class="Identifier">thing</span><span class="Punctuation">,</span> <span class="Identifier">elm</span><span class="Punctuation">)</span><span class="Punctuation">)</span></span></tt> the sequence will still be sorted. Assumes that <tt class="docutils literal"><span class="pre"><span class="Identifier">a</span></span></tt> is sorted.</p>
|
||||
<p>This version uses the default comparison function <tt class="docutils literal"><span class="pre"><span class="Identifier">cmp</span></span></tt>.</p>
|
||||
<p><strong>See also:</strong></p>
|
||||
<ul class="simple"><li><a class="reference external" href="#lowerBound,openArray[T],K,proc(T,K)">lowerBound proc</a> sorted by <tt class="docutils literal"><span class="pre"><span class="Identifier">cmp</span></span></tt> in the specified order</li>
|
||||
<li><a class="reference external" href="#lowerBound,openArray[T],T">lowerBound proc</a></li>
|
||||
</ul>
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/algorithm.nim#L307" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/algorithm.nim#L307" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</dl>
|
||||
</div>
|
||||
<div class="section" id="18">
|
||||
<h1><a class="toc-backref" href="#18">Templates</a></h1>
|
||||
<dl class="item">
|
||||
<div id="sortedByIt-templates-all">
|
||||
<div id="sortedByIt.t,untyped,untyped">
|
||||
<dt><pre><span class="Keyword">template</span> <a href="#sortedByIt.t%2Cuntyped%2Cuntyped"><span class="Identifier">sortedByIt</span></a><span class="Other">(</span><span class="Identifier">seq1</span><span class="Other">,</span> <span class="Identifier">op</span><span class="Other">:</span> <a href="system.html#untyped"><span class="Identifier">untyped</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#untyped"><span class="Identifier">untyped</span></a></pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Convenience template around the <tt class="docutils literal"><span class="pre"><span class="Identifier">sorted</span></span></tt> proc to reduce typing.</p>
|
||||
<p>The template injects the <tt class="docutils literal"><span class="pre"><span class="Identifier">it</span></span></tt> variable which you can use directly in an expression.</p>
|
||||
<p>Because the underlying <tt class="docutils literal"><span class="pre"><span class="Identifier">cmp</span><span class="Punctuation">(</span><span class="Punctuation">)</span></span></tt> is defined for tuples you can also do a nested sort.</p>
|
||||
<p><strong>See also:</strong></p>
|
||||
<ul class="simple"><li><a class="reference external" href="#sort,openArray[T],proc(T,T)">sort func</a></li>
|
||||
<li><a class="reference external" href="#sort,openArray[T]">sort proc</a></li>
|
||||
<li><a class="reference external" href="#sorted,openArray[T],proc(T,T)">sorted proc</a> sorted by <tt class="docutils literal"><span class="pre"><span class="Identifier">cmp</span></span></tt> in the specified order</li>
|
||||
<li><a class="reference external" href="#sorted,openArray[T]">sorted proc</a></li>
|
||||
</ul>
|
||||
|
||||
<p><strong class="examples_text">Example:</strong></p>
|
||||
<pre class="listing"><span class="Keyword">type</span> <span class="Identifier">Person</span> <span class="Operator">=</span> <span class="Keyword">tuple</span><span class="Punctuation">[</span><span class="Identifier">name</span><span class="Punctuation">:</span> <span class="Identifier">string</span><span class="Punctuation">,</span> <span class="Identifier">age</span><span class="Punctuation">:</span> <span class="Identifier">int</span><span class="Punctuation">]</span>
|
||||
<span class="Keyword">var</span>
|
||||
<span class="Identifier">p1</span><span class="Punctuation">:</span> <span class="Identifier">Person</span> <span class="Operator">=</span> <span class="Punctuation">(</span><span class="Identifier">name</span><span class="Punctuation">:</span> <span class="StringLit">"p1"</span><span class="Punctuation">,</span> <span class="Identifier">age</span><span class="Punctuation">:</span> <span class="DecNumber">60</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">p2</span><span class="Punctuation">:</span> <span class="Identifier">Person</span> <span class="Operator">=</span> <span class="Punctuation">(</span><span class="Identifier">name</span><span class="Punctuation">:</span> <span class="StringLit">"p2"</span><span class="Punctuation">,</span> <span class="Identifier">age</span><span class="Punctuation">:</span> <span class="DecNumber">20</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">p3</span><span class="Punctuation">:</span> <span class="Identifier">Person</span> <span class="Operator">=</span> <span class="Punctuation">(</span><span class="Identifier">name</span><span class="Punctuation">:</span> <span class="StringLit">"p3"</span><span class="Punctuation">,</span> <span class="Identifier">age</span><span class="Punctuation">:</span> <span class="DecNumber">30</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">p4</span><span class="Punctuation">:</span> <span class="Identifier">Person</span> <span class="Operator">=</span> <span class="Punctuation">(</span><span class="Identifier">name</span><span class="Punctuation">:</span> <span class="StringLit">"p4"</span><span class="Punctuation">,</span> <span class="Identifier">age</span><span class="Punctuation">:</span> <span class="DecNumber">30</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">people</span> <span class="Operator">=</span> <span class="Operator">@</span><span class="Punctuation">[</span><span class="Identifier">p1</span><span class="Punctuation">,</span> <span class="Identifier">p2</span><span class="Punctuation">,</span> <span class="Identifier">p4</span><span class="Punctuation">,</span> <span class="Identifier">p3</span><span class="Punctuation">]</span>
|
||||
|
||||
<span class="Identifier">assert</span> <span class="Identifier">people</span><span class="Operator">.</span><span class="Identifier">sortedByIt</span><span class="Punctuation">(</span><span class="Identifier">it</span><span class="Operator">.</span><span class="Identifier">name</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="Operator">@</span><span class="Punctuation">[</span><span class="Punctuation">(</span><span class="Identifier">name</span><span class="Punctuation">:</span> <span class="StringLit">"p1"</span><span class="Punctuation">,</span> <span class="Identifier">age</span><span class="Punctuation">:</span> <span class="DecNumber">60</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Punctuation">(</span><span class="Identifier">name</span><span class="Punctuation">:</span> <span class="StringLit">"p2"</span><span class="Punctuation">,</span>
|
||||
<span class="Identifier">age</span><span class="Punctuation">:</span> <span class="DecNumber">20</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Punctuation">(</span><span class="Identifier">name</span><span class="Punctuation">:</span> <span class="StringLit">"p3"</span><span class="Punctuation">,</span> <span class="Identifier">age</span><span class="Punctuation">:</span> <span class="DecNumber">30</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Punctuation">(</span><span class="Identifier">name</span><span class="Punctuation">:</span> <span class="StringLit">"p4"</span><span class="Punctuation">,</span> <span class="Identifier">age</span><span class="Punctuation">:</span> <span class="DecNumber">30</span><span class="Punctuation">)</span><span class="Punctuation">]</span>
|
||||
<span class="Comment"># Nested sort</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">people</span><span class="Operator">.</span><span class="Identifier">sortedByIt</span><span class="Punctuation">(</span><span class="Punctuation">(</span><span class="Identifier">it</span><span class="Operator">.</span><span class="Identifier">age</span><span class="Punctuation">,</span> <span class="Identifier">it</span><span class="Operator">.</span><span class="Identifier">name</span><span class="Punctuation">)</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="Operator">@</span><span class="Punctuation">[</span><span class="Punctuation">(</span><span class="Identifier">name</span><span class="Punctuation">:</span> <span class="StringLit">"p2"</span><span class="Punctuation">,</span> <span class="Identifier">age</span><span class="Punctuation">:</span> <span class="DecNumber">20</span><span class="Punctuation">)</span><span class="Punctuation">,</span>
|
||||
<span class="Punctuation">(</span><span class="Identifier">name</span><span class="Punctuation">:</span> <span class="StringLit">"p3"</span><span class="Punctuation">,</span> <span class="Identifier">age</span><span class="Punctuation">:</span> <span class="DecNumber">30</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Punctuation">(</span><span class="Identifier">name</span><span class="Punctuation">:</span> <span class="StringLit">"p4"</span><span class="Punctuation">,</span> <span class="Identifier">age</span><span class="Punctuation">:</span> <span class="DecNumber">30</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Punctuation">(</span><span class="Identifier">name</span><span class="Punctuation">:</span> <span class="StringLit">"p1"</span><span class="Punctuation">,</span> <span class="Identifier">age</span><span class="Punctuation">:</span> <span class="DecNumber">60</span><span class="Punctuation">)</span><span class="Punctuation">]</span></pre>
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/algorithm.nim#L471" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/algorithm.nim#L471" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="twelve-columns footer">
|
||||
<span class="nim-sprite"></span>
|
||||
<br>
|
||||
<small style="color: var(--hint);">Made with Nim. Generated: 2023-03-13 00:19:38 UTC</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script defer data-domain="nim-lang.org" src="https://plausible.io/js/plausible.js"></script>
|
||||
|
||||
<!-- Google fonts -->
|
||||
<link href='https://fonts.googleapis.com/css?family=Lato:400,600,900' rel='stylesheet' type='text/css'/>
|
||||
<link href='https://fonts.googleapis.com/css?family=Source+Code+Pro:400,500,600' rel='stylesheet' type='text/css'/>
|
||||
</body>
|
||||
</html>
|
||||
47
algorithm.idx
Normal file
47
algorithm.idx
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
nimTitle algorithm algorithm.html module std/algorithm 0
|
||||
nim Descending algorithm.html#Descending SortOrder.Descending 52
|
||||
nim Ascending algorithm.html#Ascending SortOrder.Ascending 52
|
||||
nim SortOrder algorithm.html#SortOrder enum SortOrder 52
|
||||
nim `*` algorithm.html#*,int,SortOrder proc `*`(x: int; order: SortOrder): int 55
|
||||
nim fill algorithm.html#fill,openArray[T],Natural,Natural,T proc fill[T](a: var openArray[T]; first, last: Natural; value: T) 77
|
||||
nim fill algorithm.html#fill,openArray[T],T proc fill[T](a: var openArray[T]; value: T) 90
|
||||
nim reverse algorithm.html#reverse,openArray[T],Natural,Natural proc reverse[T](a: var openArray[T]; first, last: Natural) 101
|
||||
nim reverse algorithm.html#reverse,openArray[T] proc reverse[T](a: var openArray[T]) 123
|
||||
nim reversed algorithm.html#reversed,openArray[T] proc reversed[T](a: openArray[T]): seq[T] 138
|
||||
nim reversed algorithm.html#reversed,openArray[T],Natural,int proc reversed[T](a: openArray[T]; first: Natural; last: int): seq[T] 150
|
||||
nim binarySearch algorithm.html#binarySearch,openArray[T],K,proc(T,K) proc binarySearch[T, K](a: openArray[T]; key: K;\n cmp: proc (x: T; y: K): int {.closure.}): int 159
|
||||
nim binarySearch algorithm.html#binarySearch,openArray[T],T proc binarySearch[T](a: openArray[T]; key: T): int 210
|
||||
nim lowerBound algorithm.html#lowerBound,openArray[T],K,proc(T,K) proc lowerBound[T, K](a: openArray[T]; key: K; cmp: proc (x: T; k: K): int {.closure.}): int 221
|
||||
nim lowerBound algorithm.html#lowerBound,openArray[T],T proc lowerBound[T](a: openArray[T]; key: T): int 257
|
||||
nim upperBound algorithm.html#upperBound,openArray[T],K,proc(T,K) proc upperBound[T, K](a: openArray[T]; key: K; cmp: proc (x: T; k: K): int {.closure.}): int 271
|
||||
nim upperBound algorithm.html#upperBound,openArray[T],T proc upperBound[T](a: openArray[T]; key: T): int 307
|
||||
nim sort algorithm.html#sort,openArray[T],proc(T,T) proc sort[T](a: var openArray[T]; cmp: proc (x, y: T): int {.closure.};\n order = SortOrder.Ascending) 368
|
||||
nim sort algorithm.html#sort,openArray[T] proc sort[T](a: var openArray[T]; order = SortOrder.Ascending) 421
|
||||
nim sorted algorithm.html#sorted,openArray[T],proc(T,T) proc sorted[T](a: openArray[T]; cmp: proc (x, y: T): int {.closure.};\n order = SortOrder.Ascending): seq[T] 431
|
||||
nim sorted algorithm.html#sorted,openArray[T] proc sorted[T](a: openArray[T]; order = SortOrder.Ascending): seq[T] 453
|
||||
nim sortedByIt algorithm.html#sortedByIt.t,untyped,untyped template sortedByIt(seq1, op: untyped): untyped 471
|
||||
nim isSorted algorithm.html#isSorted,openArray[T],proc(T,T) proc isSorted[T](a: openArray[T]; cmp: proc (x, y: T): int {.closure.};\n order = SortOrder.Ascending): bool 507
|
||||
nim isSorted algorithm.html#isSorted,openArray[T] proc isSorted[T](a: openArray[T]; order = SortOrder.Ascending): bool 534
|
||||
nim merge algorithm.html#merge,seq[T],openArray[T],openArray[T],proc(T,T) proc merge[T](result: var seq[T]; x, y: openArray[T];\n cmp: proc (x, y: T): int {.closure.}) 554
|
||||
nim merge algorithm.html#merge,seq[T],openArray[T],openArray[T] proc merge[T](result: var seq[T]; x, y: openArray[T]) 631
|
||||
nim product algorithm.html#product,openArray[seq[T]] proc product[T](x: openArray[seq[T]]): seq[seq[T]] 646
|
||||
nim nextPermutation algorithm.html#nextPermutation,openArray[T] proc nextPermutation[T](x: var openArray[T]): bool 683
|
||||
nim prevPermutation algorithm.html#prevPermutation,openArray[T] proc prevPermutation[T](x: var openArray[T]): bool 723
|
||||
nim rotateLeft algorithm.html#rotateLeft,openArray[T],HSlice[int,int],int proc rotateLeft[T](arg: var openArray[T]; slice: HSlice[int, int]; dist: int): int 812
|
||||
nim rotateLeft algorithm.html#rotateLeft,openArray[T],int proc rotateLeft[T](arg: var openArray[T]; dist: int): int 850
|
||||
nim rotatedLeft algorithm.html#rotatedLeft,openArray[T],HSlice[int,int],int proc rotatedLeft[T](arg: openArray[T]; slice: HSlice[int, int]; dist: int): seq[T] 870
|
||||
nim rotatedLeft algorithm.html#rotatedLeft,openArray[T],int proc rotatedLeft[T](arg: openArray[T]; dist: int): seq[T] 900
|
||||
heading Basic usage algorithm.html#basic-usage Basic usage 0
|
||||
heading See also algorithm.html#see-also See also 0
|
||||
nimgrp reversed algorithm.html#reversed-procs-all proc 138
|
||||
nimgrp sorted algorithm.html#sorted-procs-all proc 431
|
||||
nimgrp issorted algorithm.html#isSorted-procs-all proc 507
|
||||
nimgrp fill algorithm.html#fill-procs-all proc 77
|
||||
nimgrp upperbound algorithm.html#upperBound-procs-all proc 271
|
||||
nimgrp rotateleft algorithm.html#rotateLeft-procs-all proc 812
|
||||
nimgrp binarysearch algorithm.html#binarySearch-procs-all proc 159
|
||||
nimgrp lowerbound algorithm.html#lowerBound-procs-all proc 221
|
||||
nimgrp rotatedleft algorithm.html#rotatedLeft-procs-all proc 870
|
||||
nimgrp merge algorithm.html#merge-procs-all proc 554
|
||||
nimgrp sort algorithm.html#sort-procs-all proc 368
|
||||
nimgrp reverse algorithm.html#reverse-procs-all proc 101
|
||||
91
apis.html
Normal file
91
apis.html
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<!-- This file is generated by Nim. -->
|
||||
<html xmlns="https://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>API naming design</title>
|
||||
|
||||
<!-- Favicon -->
|
||||
<link rel="shortcut icon" href="data:image/x-icon;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAUAAAAF////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAIAAABbAAAAlQAAAKIAAACbAAAAmwAAAKIAAACVAAAAWwAAAAL///8A////AP///wD///8A////AAAAABQAAADAAAAAYwAAAA3///8A////AP///wD///8AAAAADQAAAGMAAADAAAAAFP///wD///8A////AP///wAAAACdAAAAOv///wD///8A////AP///wD///8A////AP///wD///8AAAAAOgAAAJ3///8A////AP///wAAAAAnAAAAcP///wAAAAAoAAAASv///wD///8A////AP///wAAAABKAAAAKP///wAAAABwAAAAJ////wD///8AAAAAgQAAABwAAACIAAAAkAAAAJMAAACtAAAAFQAAABUAAACtAAAAkwAAAJAAAACIAAAAHAAAAIH///8A////AAAAAKQAAACrAAAAaP///wD///8AAAAARQAAANIAAADSAAAARf///wD///8AAAAAaAAAAKsAAACk////AAAAADMAAACcAAAAnQAAABj///8A////AP///wAAAAAYAAAAGP///wD///8A////AAAAABgAAACdAAAAnAAAADMAAAB1AAAAwwAAAP8AAADpAAAAsQAAAE4AAAAb////AP///wAAAAAbAAAATgAAALEAAADpAAAA/wAAAMMAAAB1AAAAtwAAAOkAAAD/AAAA/wAAAP8AAADvAAAA3gAAAN4AAADeAAAA3gAAAO8AAAD/AAAA/wAAAP8AAADpAAAAtwAAAGUAAAA/AAAA3wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAADfAAAAPwAAAGX///8A////AAAAAEgAAADtAAAAvwAAAL0AAADGAAAA7wAAAO8AAADGAAAAvQAAAL8AAADtAAAASP///wD///8A////AP///wD///8AAAAAO////wD///8A////AAAAAIcAAACH////AP///wD///8AAAAAO////wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A//8AAP//AAD4HwAA7/cAAN/7AAD//wAAoYUAAJ55AACf+QAAh+EAAAAAAADAAwAA4AcAAP5/AAD//wAA//8AAA=="/>
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAA3XAAAN1wFCKJt4AAAAB3RJTUUH4QQQEwksSS9ZWwAAAk1JREFUWMPtll2ITVEUx39nn/O7Y5qR8f05wtCUUr6ZIS++8pEnkZInPImneaCQ5METNdOkeFBKUhMPRIkHKfEuUZSUlGlKPN2TrgfncpvmnntnmlEyq1Z7t89/rf9a6+y99oZxGZf/XeIq61EdtgKXgdXA0xrYAvBjOIF1AI9zvjcC74BSpndrJPkBWDScTF8Aa4E3wDlgHbASaANmVqlcCnwHvgDvgVfAJ+AikAAvgfVZwLnSVZHZaOuKoQi3ZOMi4NkYkpe1p4J7A8BpYAD49hfIy/oqG0+hLomiKP2L5L+1ubn5115S+3OAn4EnwBlgMzCjyt6ZAnQCJ4A7wOs88iRJHvw50HoujuPBoCKwHWiosy8MdfZnAdcHk8dxXFJ3VQbQlCTJvRBCGdRbD4M6uc5glpY3eAihpN5S5w12diSEcCCEcKUO4ljdr15T76ur1FDDLIQQ3qv71EdDOe3Kxj3leRXyk+pxdWnFWod6Wt2bY3de3aSuUHcPBVimHs7mK9WrmeOF6lR1o9qnzskh2ar2qm1qizpfXaPeVGdlmGN5pb09qMxz1Xb1kLqgzn1RyH7JUXW52lr5e/Kqi9qpto7V1atuUzfnARrV7jEib1T76gG2qxdGmXyiekkt1GswPTtek0aBfJp6YySGBfWg2tPQ0FAYgf1stUfdmdcjarbYJEniKIq6gY/Aw+zWHAC+p2labGpqiorFYgGYCEzN7oQdQClN07O1/EfDyGgC0ALMBdYAi4FyK+4H3gLPsxfR1zRNi+NP7nH5J+QntnXe5B5mpfQAAAAASUVORK5CYII=">
|
||||
|
||||
<!-- CSS -->
|
||||
<link rel="stylesheet" type="text/css" href="nimdoc.out.css">
|
||||
|
||||
<!-- JS -->
|
||||
<script type="text/javascript" src="dochack.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="document" id="documentId">
|
||||
<div class="container">
|
||||
<h1 class="title">API naming design</h1>
|
||||
<p>The API is designed to be <strong>easy to use</strong> and consistent. Ease of use is measured by the number of calls to achieve a concrete high-level action.</p>
|
||||
|
||||
<h1 id="naming-scheme">Naming scheme</h1><p>The library uses a simple naming scheme that makes use of common abbreviations to keep the names short but meaningful. Since version 0.8.2 many symbols have been renamed to fit this scheme. The ultimate goal is that the programmer can <em>guess</em> a name.</p>
|
||||
<table border="1" class="docutils"><tr><th>English word</th><th>To use</th><th>Notes</th></tr>
|
||||
<tr><td>initialize</td><td>initT </td><td><tt class="docutils literal"><span class="pre"><span class="Identifier">init</span></span></tt> is used to create a value type <tt class="docutils literal"><span class="pre"><span class="Identifier">T</span></span></tt></td></tr>
|
||||
<tr><td>new</td><td>newP </td><td><tt class="docutils literal"><span class="pre"><span class="Identifier">new</span></span></tt> is used to create a reference type <tt class="docutils literal"><span class="pre"><span class="Identifier">P</span></span></tt></td></tr>
|
||||
<tr><td>find</td><td>find</td><td>should return the position where something was found; for a bool result use <tt class="docutils literal"><span class="pre"><span class="Identifier">contains</span></span></tt></td></tr>
|
||||
<tr><td>contains</td><td>contains</td><td>often short for <tt class="docutils literal"><span class="pre"><span class="Identifier">find</span><span class="Punctuation">(</span><span class="Punctuation">)</span> <span class="Operator">>=</span> <span class="DecNumber">0</span></span></tt></td></tr>
|
||||
<tr><td>append</td><td>add</td><td>use <tt class="docutils literal"><span class="pre"><span class="Identifier">add</span></span></tt> instead of <tt class="docutils literal"><span class="pre"><span class="Identifier">append</span></span></tt></td></tr>
|
||||
<tr><td>compare</td><td>cmp</td><td>should return an int with the <tt class="docutils literal"><span class="pre"><span class="Operator"><</span> <span class="DecNumber">0</span></span></tt> <tt class="docutils literal"><span class="pre"><span class="Operator">==</span> <span class="DecNumber">0</span></span></tt> or <tt class="docutils literal"><span class="pre"><span class="Operator">></span> <span class="DecNumber">0</span></span></tt> semantics; for a bool result use <tt class="docutils literal"><span class="pre"><span class="Identifier">sameXYZ</span></span></tt></td></tr>
|
||||
<tr><td>put</td><td>put, <tt class="docutils literal"><span class="pre"><span class="Punctuation">[</span><span class="Punctuation">]</span><span class="Operator">=</span></span></tt></td><td>consider overloading <tt class="docutils literal"><span class="pre"><span class="Punctuation">[</span><span class="Punctuation">]</span><span class="Operator">=</span></span></tt> for put</td></tr>
|
||||
<tr><td>get</td><td>get, <tt class="docutils literal"><span class="pre"><span class="Punctuation">[</span><span class="Punctuation">]</span></span></tt></td><td>consider overloading <tt class="docutils literal"><span class="pre"><span class="Punctuation">[</span><span class="Punctuation">]</span></span></tt> for get; consider to not use <tt class="docutils literal"><span class="pre"><span class="Identifier">get</span></span></tt> as a prefix: <tt class="docutils literal"><span class="pre"><span class="Identifier">len</span></span></tt> instead of <tt class="docutils literal"><span class="pre"><span class="Identifier">getLen</span></span></tt></td></tr>
|
||||
<tr><td>length</td><td>len</td><td>also used for <em>number of elements</em></td></tr>
|
||||
<tr><td>size</td><td>size, len</td><td>size should refer to a byte size</td></tr>
|
||||
<tr><td>capacity</td><td>cap</td><td></td></tr>
|
||||
<tr><td>memory</td><td>mem</td><td>implies a low-level operation</td></tr>
|
||||
<tr><td>items</td><td>items</td><td>default iterator over a collection</td></tr>
|
||||
<tr><td>pairs</td><td>pairs</td><td>iterator over (key, value) pairs</td></tr>
|
||||
<tr><td>delete</td><td>delete, del</td><td>del is supposed to be faster than delete, because it does not keep the order; delete keeps the order</td></tr>
|
||||
<tr><td>remove</td><td>delete, del</td><td>inconsistent right now</td></tr>
|
||||
<tr><td>remove-and-return</td><td>pop</td><td><tt class="docutils literal"><span class="pre"><span class="Identifier">Table</span></span></tt>/<tt class="docutils literal"><span class="pre"><span class="Identifier">TableRef</span></span></tt> alias to <tt class="docutils literal"><span class="pre"><span class="Identifier">take</span></span></tt></td></tr>
|
||||
<tr><td>include</td><td>incl</td><td></td></tr>
|
||||
<tr><td>exclude</td><td>excl</td><td></td></tr>
|
||||
<tr><td>command</td><td>cmd</td><td></td></tr>
|
||||
<tr><td>execute</td><td>exec</td><td></td></tr>
|
||||
<tr><td>environment</td><td>env</td><td></td></tr>
|
||||
<tr><td>variable</td><td>var</td><td></td></tr>
|
||||
<tr><td>value</td><td>value, val </td><td>val is preferred, inconsistent right now</td></tr>
|
||||
<tr><td>executable</td><td>exe</td><td></td></tr>
|
||||
<tr><td>directory</td><td>dir</td><td></td></tr>
|
||||
<tr><td>path</td><td>path</td><td>path is the string "/usr/bin" (for example), dir is the content of "/usr/bin"; inconsistent right now</td></tr>
|
||||
<tr><td>extension</td><td>ext</td><td></td></tr>
|
||||
<tr><td>separator</td><td>sep</td><td></td></tr>
|
||||
<tr><td>column</td><td>col, column </td><td>col is preferred, inconsistent right now</td></tr>
|
||||
<tr><td>application</td><td>app</td><td></td></tr>
|
||||
<tr><td>configuration</td><td>cfg</td><td></td></tr>
|
||||
<tr><td>message</td><td>msg</td><td></td></tr>
|
||||
<tr><td>argument</td><td>arg</td><td></td></tr>
|
||||
<tr><td>object</td><td>obj</td><td></td></tr>
|
||||
<tr><td>parameter</td><td>param</td><td></td></tr>
|
||||
<tr><td>operator</td><td>opr</td><td></td></tr>
|
||||
<tr><td>procedure</td><td>proc</td><td></td></tr>
|
||||
<tr><td>function</td><td>func</td><td></td></tr>
|
||||
<tr><td>coordinate</td><td>coord</td><td></td></tr>
|
||||
<tr><td>rectangle</td><td>rect</td><td></td></tr>
|
||||
<tr><td>point</td><td>point</td><td></td></tr>
|
||||
<tr><td>symbol</td><td>sym</td><td></td></tr>
|
||||
<tr><td>literal</td><td>lit</td><td></td></tr>
|
||||
<tr><td>string</td><td>str</td><td></td></tr>
|
||||
<tr><td>identifier</td><td>ident</td><td></td></tr>
|
||||
<tr><td>indentation</td><td>indent</td><td></td></tr>
|
||||
</table>
|
||||
|
||||
|
||||
<div class="twelve-columns footer">
|
||||
<span class="nim-sprite"></span>
|
||||
<br>
|
||||
<small style="color: var(--hint);">Made with Nim. Generated: 2023-03-13 00:18:42 UTC</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script defer data-domain="nim-lang.org" src="https://plausible.io/js/plausible.js"></script>
|
||||
|
||||
<!-- Google fonts -->
|
||||
<link href='https://fonts.googleapis.com/css?family=Lato:400,600,900' rel='stylesheet' type='text/css'/>
|
||||
<link href='https://fonts.googleapis.com/css?family=Source+Code+Pro:400,500,600' rel='stylesheet' type='text/css'/>
|
||||
</body>
|
||||
</html>
|
||||
2
apis.idx
Normal file
2
apis.idx
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
markupTitle API naming design apis.html API naming design 0
|
||||
heading Naming scheme apis.html#naming-scheme Naming scheme 0
|
||||
221
appdirs.html
Normal file
221
appdirs.html
Normal file
|
|
@ -0,0 +1,221 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<!-- This file is generated by Nim. -->
|
||||
<html xmlns="https://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>std/appdirs</title>
|
||||
|
||||
<!-- Favicon -->
|
||||
<link rel="shortcut icon" href="data:image/x-icon;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAUAAAAF////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAIAAABbAAAAlQAAAKIAAACbAAAAmwAAAKIAAACVAAAAWwAAAAL///8A////AP///wD///8A////AAAAABQAAADAAAAAYwAAAA3///8A////AP///wD///8AAAAADQAAAGMAAADAAAAAFP///wD///8A////AP///wAAAACdAAAAOv///wD///8A////AP///wD///8A////AP///wD///8AAAAAOgAAAJ3///8A////AP///wAAAAAnAAAAcP///wAAAAAoAAAASv///wD///8A////AP///wAAAABKAAAAKP///wAAAABwAAAAJ////wD///8AAAAAgQAAABwAAACIAAAAkAAAAJMAAACtAAAAFQAAABUAAACtAAAAkwAAAJAAAACIAAAAHAAAAIH///8A////AAAAAKQAAACrAAAAaP///wD///8AAAAARQAAANIAAADSAAAARf///wD///8AAAAAaAAAAKsAAACk////AAAAADMAAACcAAAAnQAAABj///8A////AP///wAAAAAYAAAAGP///wD///8A////AAAAABgAAACdAAAAnAAAADMAAAB1AAAAwwAAAP8AAADpAAAAsQAAAE4AAAAb////AP///wAAAAAbAAAATgAAALEAAADpAAAA/wAAAMMAAAB1AAAAtwAAAOkAAAD/AAAA/wAAAP8AAADvAAAA3gAAAN4AAADeAAAA3gAAAO8AAAD/AAAA/wAAAP8AAADpAAAAtwAAAGUAAAA/AAAA3wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAADfAAAAPwAAAGX///8A////AAAAAEgAAADtAAAAvwAAAL0AAADGAAAA7wAAAO8AAADGAAAAvQAAAL8AAADtAAAASP///wD///8A////AP///wD///8AAAAAO////wD///8A////AAAAAIcAAACH////AP///wD///8AAAAAO////wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A//8AAP//AAD4HwAA7/cAAN/7AAD//wAAoYUAAJ55AACf+QAAh+EAAAAAAADAAwAA4AcAAP5/AAD//wAA//8AAA=="/>
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAA3XAAAN1wFCKJt4AAAAB3RJTUUH4QQQEwksSS9ZWwAAAk1JREFUWMPtll2ITVEUx39nn/O7Y5qR8f05wtCUUr6ZIS++8pEnkZInPImneaCQ5METNdOkeFBKUhMPRIkHKfEuUZSUlGlKPN2TrgfncpvmnntnmlEyq1Z7t89/rf9a6+y99oZxGZf/XeIq61EdtgKXgdXA0xrYAvBjOIF1AI9zvjcC74BSpndrJPkBWDScTF8Aa4E3wDlgHbASaANmVqlcCnwHvgDvgVfAJ+AikAAvgfVZwLnSVZHZaOuKoQi3ZOMi4NkYkpe1p4J7A8BpYAD49hfIy/oqG0+hLomiKP2L5L+1ubn5115S+3OAn4EnwBlgMzCjyt6ZAnQCJ4A7wOs88iRJHvw50HoujuPBoCKwHWiosy8MdfZnAdcHk8dxXFJ3VQbQlCTJvRBCGdRbD4M6uc5glpY3eAihpN5S5w12diSEcCCEcKUO4ljdr15T76ur1FDDLIQQ3qv71EdDOe3Kxj3leRXyk+pxdWnFWod6Wt2bY3de3aSuUHcPBVimHs7mK9WrmeOF6lR1o9qnzskh2ar2qm1qizpfXaPeVGdlmGN5pb09qMxz1Xb1kLqgzn1RyH7JUXW52lr5e/Kqi9qpto7V1atuUzfnARrV7jEib1T76gG2qxdGmXyiekkt1GswPTtek0aBfJp6YySGBfWg2tPQ0FAYgf1stUfdmdcjarbYJEniKIq6gY/Aw+zWHAC+p2labGpqiorFYgGYCEzN7oQdQClN07O1/EfDyGgC0ALMBdYAi4FyK+4H3gLPsxfR1zRNi+NP7nH5J+QntnXe5B5mpfQAAAAASUVORK5CYII=">
|
||||
|
||||
<!-- CSS -->
|
||||
<link rel="stylesheet" type="text/css" href="nimdoc.out.css">
|
||||
|
||||
<!-- JS -->
|
||||
<script type="text/javascript" src="dochack.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="document" id="documentId">
|
||||
<div class="container">
|
||||
<h1 class="title">std/appdirs</h1>
|
||||
<div class="row">
|
||||
<div class="three columns">
|
||||
<div class="theme-select-wrapper">
|
||||
<label for="theme-select">Theme: </label>
|
||||
<select id="theme-select" onchange="setTheme(this.value)">
|
||||
<option value="auto">🌗 Match OS</option>
|
||||
<option value="dark">🌑 Dark</option>
|
||||
<option value="light">🌕 Light</option>
|
||||
</select>
|
||||
</div>
|
||||
<div id="global-links">
|
||||
<ul class="simple-boot">
|
||||
<li><a href="manual.html">Manual</a></li>
|
||||
<li><a href="lib.html">Standard library</a></li>
|
||||
<li> <a id="indexLink" href="theindex.html">Index</a></li>
|
||||
<li><a href="compiler/theindex.html">Compiler docs</a></li>
|
||||
<li><a href="https://nim-lang.github.io/fusion/theindex.html">Fusion docs</a></li>
|
||||
<li><a href="https://nim-lang.github.io/Nim/">devel</a>, <a href="https://nim-lang.org/documentation.html">stable</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="searchInputDiv">
|
||||
Search: <input type="search" id="searchInput"
|
||||
onkeyup="search()" />
|
||||
</div>
|
||||
|
||||
<ul class="simple simple-toc" id="toc-list">
|
||||
<li>
|
||||
<a class="reference reference-toplevel" href="#6" id="56">Imports</a>
|
||||
</li>
|
||||
<li>
|
||||
<details open>
|
||||
<summary><a class="reference reference-toplevel" href="#12" id="62">Procs</a></summary>
|
||||
<ul class="simple simple-toc-section">
|
||||
<ul class="simple nested-toc-section">getCacheDir
|
||||
<li><a class="reference" href="#getCacheDir" title="getCacheDir(): Path">getCacheDir(): Path</a></li>
|
||||
<li><a class="reference" href="#getCacheDir%2CPath" title="getCacheDir(app: Path): Path">getCacheDir(app: Path): Path</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">getConfigDir
|
||||
<li><a class="reference" href="#getConfigDir" title="getConfigDir(): Path">getConfigDir(): Path</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">getHomeDir
|
||||
<li><a class="reference" href="#getHomeDir" title="getHomeDir(): Path">getHomeDir(): Path</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">getTempDir
|
||||
<li><a class="reference" href="#getTempDir" title="getTempDir(): Path">getTempDir(): Path</a></li>
|
||||
|
||||
</ul>
|
||||
|
||||
</ul>
|
||||
</details>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
<div class="nine columns" id="content">
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/std/appdirs.nim#L1" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/appdirs.nim#L1" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
<div id="tocRoot"></div>
|
||||
|
||||
<p class="module-desc">This module implements helpers for determining special directories used by apps.</p>
|
||||
<div class="section" id="6">
|
||||
<h1><a class="toc-backref" href="#6">Imports</a></h1>
|
||||
<dl class="item">
|
||||
<a class="reference external" href="osappdirs.html">osappdirs</a>, <a class="reference external" href="paths.html">paths</a>, <a class="reference external" href="envvars.html">envvars</a>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="section" id="12">
|
||||
<h1><a class="toc-backref" href="#12">Procs</a></h1>
|
||||
<dl class="item">
|
||||
<div id="getCacheDir-procs-all">
|
||||
<div id="getCacheDir">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#getCacheDir"><span class="Identifier">getCacheDir</span></a><span class="Other">(</span><span class="Other">)</span><span class="Other">:</span> <a href="paths.html#Path"><span class="Identifier">Path</span></a> {.<span class="Identifier">inline</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ReadEnvEffect</span><span class="Other">]</span><span class="Other">,</span>
|
||||
<span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Returns the cache directory of the current user for applications.</p>
|
||||
<p>This makes use of the following environment variables:</p>
|
||||
<ul class="simple"><li>On Windows: <tt class="docutils literal"><span class="pre"><span class="Identifier">getEnv</span><span class="Punctuation">(</span><span class="StringLit">"LOCALAPPDATA"</span><span class="Punctuation">)</span></span></tt></li>
|
||||
<li>On macOS: <tt class="docutils literal"><span class="pre"><span class="Identifier">getEnv</span><span class="Punctuation">(</span><span class="StringLit">"XDG_CACHE_HOME"</span><span class="Punctuation">,</span> <span class="Identifier">getEnv</span><span class="Punctuation">(</span><span class="StringLit">"HOME"</span><span class="Punctuation">)</span> <span class="Operator">/</span> <span class="StringLit">"Library/Caches"</span><span class="Punctuation">)</span></span></tt></li>
|
||||
<li>On other platforms: <tt class="docutils literal"><span class="pre"><span class="Identifier">getEnv</span><span class="Punctuation">(</span><span class="StringLit">"XDG_CACHE_HOME"</span><span class="Punctuation">,</span> <span class="Identifier">getEnv</span><span class="Punctuation">(</span><span class="StringLit">"HOME"</span><span class="Punctuation">)</span> <span class="Operator">/</span> <span class="StringLit">".cache"</span><span class="Punctuation">)</span></span></tt></li>
|
||||
</ul>
|
||||
<p><strong>See also:</strong></p>
|
||||
<ul class="simple"><li><a class="reference internal nimdoc" title="proc getHomeDir(): Path" href="#getHomeDir">getHomeDir proc</a></li>
|
||||
<li><a class="reference internal nimdoc" title="proc getTempDir(): Path" href="#getTempDir">getTempDir proc</a></li>
|
||||
<li><a class="reference internal nimdoc" title="proc getConfigDir(): Path" href="#getConfigDir">getConfigDir proc</a></li>
|
||||
</ul>
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/std/appdirs.nim#L36" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/appdirs.nim#L36" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
<div id="getCacheDir,Path">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#getCacheDir%2CPath"><span class="Identifier">getCacheDir</span></a><span class="Other">(</span><span class="Identifier">app</span><span class="Other">:</span> <a href="paths.html#Path"><span class="Identifier">Path</span></a><span class="Other">)</span><span class="Other">:</span> <a href="paths.html#Path"><span class="Identifier">Path</span></a> {.<span class="Identifier">inline</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ReadEnvEffect</span><span class="Other">]</span><span class="Other">,</span>
|
||||
<span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Returns the cache directory for an application <tt class="docutils literal"><span class="pre"><span class="Identifier">app</span></span></tt>.<ul class="simple"><li>On Windows, this uses: <tt class="docutils literal"><span class="pre"><span class="Identifier">getCacheDir</span><span class="Punctuation">(</span><span class="Punctuation">)</span> <span class="Operator">/</span> <span class="Identifier">app</span> <span class="Operator">/</span> <span class="StringLit">"cache"</span></span></tt></li>
|
||||
<li>On other platforms, this uses: <tt class="docutils literal"><span class="pre"><span class="Identifier">getCacheDir</span><span class="Punctuation">(</span><span class="Punctuation">)</span> <span class="Operator">/</span> <span class="Identifier">app</span></span></tt></li>
|
||||
</ul>
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/std/appdirs.nim#L54" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/appdirs.nim#L54" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="getConfigDir-procs-all">
|
||||
<div id="getConfigDir">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#getConfigDir"><span class="Identifier">getConfigDir</span></a><span class="Other">(</span><span class="Other">)</span><span class="Other">:</span> <a href="paths.html#Path"><span class="Identifier">Path</span></a> {.<span class="Identifier">inline</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><a href="envvars.html#ReadEnvEffect"><span class="Identifier">ReadEnvEffect</span></a><span class="Other">,</span> <a href="exceptions.html#ReadIOEffect"><span class="Identifier">ReadIOEffect</span></a><span class="Other">]</span><span class="Other">,</span>
|
||||
<span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Returns the config directory of the current user for applications.</p>
|
||||
<p>On non-Windows OSs, this proc conforms to the XDG Base Directory spec. Thus, this proc returns the value of the <tt class="docutils literal"><span class="pre"><span class="Identifier">XDG_CONFIG_HOME</span></span></tt> environment variable if it is set, otherwise it returns the default configuration directory ("~/.config/").</p>
|
||||
<p>An OS-dependent trailing slash is always present at the end of the returned string: <tt class="docutils literal"><span class="pre"><span class="Operator">\\</span></span></tt> on Windows and <tt class="docutils literal"><span class="pre"><span class="Operator">/</span></span></tt> on all other OSs.</p>
|
||||
<p>See also:</p>
|
||||
<ul class="simple"><li><a class="reference internal nimdoc" title="proc getHomeDir(): Path" href="#getHomeDir">getHomeDir proc</a></li>
|
||||
<li><a class="reference internal nimdoc" title="proc getTempDir(): Path" href="#getTempDir">getTempDir proc</a></li>
|
||||
</ul>
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/std/appdirs.nim#L20" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/appdirs.nim#L20" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="getHomeDir-procs-all">
|
||||
<div id="getHomeDir">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#getHomeDir"><span class="Identifier">getHomeDir</span></a><span class="Other">(</span><span class="Other">)</span><span class="Other">:</span> <a href="paths.html#Path"><span class="Identifier">Path</span></a> {.<span class="Identifier">inline</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><a href="envvars.html#ReadEnvEffect"><span class="Identifier">ReadEnvEffect</span></a><span class="Other">,</span> <a href="exceptions.html#ReadIOEffect"><span class="Identifier">ReadIOEffect</span></a><span class="Other">]</span><span class="Other">,</span>
|
||||
<span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Returns the home directory of the current user.</p>
|
||||
<p>This proc is wrapped by the <a class="reference external" href="./paths.html#expandTilde,Path">paths: expandTilde proc</a> for the convenience of processing paths coming from user configuration files.</p>
|
||||
<p>See also:</p>
|
||||
<ul class="simple"><li><a class="reference internal nimdoc" title="proc getConfigDir(): Path" href="#getConfigDir">getConfigDir proc</a></li>
|
||||
<li><a class="reference internal nimdoc" title="proc getTempDir(): Path" href="#getTempDir">getTempDir proc</a></li>
|
||||
</ul>
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/std/appdirs.nim#L9" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/appdirs.nim#L9" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="getTempDir-procs-all">
|
||||
<div id="getTempDir">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#getTempDir"><span class="Identifier">getTempDir</span></a><span class="Other">(</span><span class="Other">)</span><span class="Other">:</span> <a href="paths.html#Path"><span class="Identifier">Path</span></a> {.<span class="Identifier">inline</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><a href="envvars.html#ReadEnvEffect"><span class="Identifier">ReadEnvEffect</span></a><span class="Other">,</span> <a href="exceptions.html#ReadIOEffect"><span class="Identifier">ReadIOEffect</span></a><span class="Other">]</span><span class="Other">,</span>
|
||||
<span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Returns the temporary directory of the current user for applications to save temporary files in.</p>
|
||||
<p>On Windows, it calls <a class="reference external" href="https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-gettemppathw">GetTempPath</a>. On Posix based platforms, it will check <tt class="docutils literal"><span class="pre"><span class="Identifier">TMPDIR</span></span></tt>, <tt class="docutils literal"><span class="pre"><span class="Identifier">TEMP</span></span></tt>, <tt class="docutils literal"><span class="pre"><span class="Identifier">TMP</span></span></tt> and <tt class="docutils literal"><span class="pre"><span class="Identifier">TEMPDIR</span></span></tt> environment variables in order. On all platforms, <tt class="docutils literal"><span class="pre"><span class="Operator">/</span><span class="Identifier">tmp</span></span></tt> will be returned if the procs fails.</p>
|
||||
<p>You can override this implementation by adding <tt class="docutils literal"><span class="pre"><span class="Operator">-</span><span class="Identifier">d</span><span class="Punctuation">:</span><span class="Identifier">tempDir</span><span class="Operator">=</span><span class="Identifier">mytempname</span></span></tt> to your compiler invocation.</p>
|
||||
<div class="admonition admonition-info"><span class="admonition-info-text"><b>Note:</b></span>
|
||||
This proc does not check whether the returned path exists.</div>
|
||||
<p>See also:</p>
|
||||
<ul class="simple"><li><a class="reference internal nimdoc" title="proc getHomeDir(): Path" href="#getHomeDir">getHomeDir proc</a></li>
|
||||
<li><a class="reference internal nimdoc" title="proc getConfigDir(): Path" href="#getConfigDir">getConfigDir proc</a></li>
|
||||
</ul>
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/std/appdirs.nim#L61" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/appdirs.nim#L61" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="twelve-columns footer">
|
||||
<span class="nim-sprite"></span>
|
||||
<br>
|
||||
<small style="color: var(--hint);">Made with Nim. Generated: 2023-03-13 00:19:50 UTC</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script defer data-domain="nim-lang.org" src="https://plausible.io/js/plausible.js"></script>
|
||||
|
||||
<!-- Google fonts -->
|
||||
<link href='https://fonts.googleapis.com/css?family=Lato:400,600,900' rel='stylesheet' type='text/css'/>
|
||||
<link href='https://fonts.googleapis.com/css?family=Source+Code+Pro:400,500,600' rel='stylesheet' type='text/css'/>
|
||||
</body>
|
||||
</html>
|
||||
7
appdirs.idx
Normal file
7
appdirs.idx
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
nimTitle appdirs appdirs.html module std/appdirs 0
|
||||
nim getHomeDir appdirs.html#getHomeDir proc getHomeDir(): Path 9
|
||||
nim getConfigDir appdirs.html#getConfigDir proc getConfigDir(): Path 20
|
||||
nim getCacheDir appdirs.html#getCacheDir proc getCacheDir(): Path 36
|
||||
nim getCacheDir appdirs.html#getCacheDir,Path proc getCacheDir(app: Path): Path 54
|
||||
nim getTempDir appdirs.html#getTempDir proc getTempDir(): Path 61
|
||||
nimgrp getcachedir appdirs.html#getCacheDir-procs-all proc 36
|
||||
172
asciitables.html
Normal file
172
asciitables.html
Normal file
|
|
@ -0,0 +1,172 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<!-- This file is generated by Nim. -->
|
||||
<html xmlns="https://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>std/private/asciitables</title>
|
||||
|
||||
<!-- Favicon -->
|
||||
<link rel="shortcut icon" href="data:image/x-icon;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAUAAAAF////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAIAAABbAAAAlQAAAKIAAACbAAAAmwAAAKIAAACVAAAAWwAAAAL///8A////AP///wD///8A////AAAAABQAAADAAAAAYwAAAA3///8A////AP///wD///8AAAAADQAAAGMAAADAAAAAFP///wD///8A////AP///wAAAACdAAAAOv///wD///8A////AP///wD///8A////AP///wD///8AAAAAOgAAAJ3///8A////AP///wAAAAAnAAAAcP///wAAAAAoAAAASv///wD///8A////AP///wAAAABKAAAAKP///wAAAABwAAAAJ////wD///8AAAAAgQAAABwAAACIAAAAkAAAAJMAAACtAAAAFQAAABUAAACtAAAAkwAAAJAAAACIAAAAHAAAAIH///8A////AAAAAKQAAACrAAAAaP///wD///8AAAAARQAAANIAAADSAAAARf///wD///8AAAAAaAAAAKsAAACk////AAAAADMAAACcAAAAnQAAABj///8A////AP///wAAAAAYAAAAGP///wD///8A////AAAAABgAAACdAAAAnAAAADMAAAB1AAAAwwAAAP8AAADpAAAAsQAAAE4AAAAb////AP///wAAAAAbAAAATgAAALEAAADpAAAA/wAAAMMAAAB1AAAAtwAAAOkAAAD/AAAA/wAAAP8AAADvAAAA3gAAAN4AAADeAAAA3gAAAO8AAAD/AAAA/wAAAP8AAADpAAAAtwAAAGUAAAA/AAAA3wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAADfAAAAPwAAAGX///8A////AAAAAEgAAADtAAAAvwAAAL0AAADGAAAA7wAAAO8AAADGAAAAvQAAAL8AAADtAAAASP///wD///8A////AP///wD///8AAAAAO////wD///8A////AAAAAIcAAACH////AP///wD///8AAAAAO////wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A//8AAP//AAD4HwAA7/cAAN/7AAD//wAAoYUAAJ55AACf+QAAh+EAAAAAAADAAwAA4AcAAP5/AAD//wAA//8AAA=="/>
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAA3XAAAN1wFCKJt4AAAAB3RJTUUH4QQQEwksSS9ZWwAAAk1JREFUWMPtll2ITVEUx39nn/O7Y5qR8f05wtCUUr6ZIS++8pEnkZInPImneaCQ5METNdOkeFBKUhMPRIkHKfEuUZSUlGlKPN2TrgfncpvmnntnmlEyq1Z7t89/rf9a6+y99oZxGZf/XeIq61EdtgKXgdXA0xrYAvBjOIF1AI9zvjcC74BSpndrJPkBWDScTF8Aa4E3wDlgHbASaANmVqlcCnwHvgDvgVfAJ+AikAAvgfVZwLnSVZHZaOuKoQi3ZOMi4NkYkpe1p4J7A8BpYAD49hfIy/oqG0+hLomiKP2L5L+1ubn5115S+3OAn4EnwBlgMzCjyt6ZAnQCJ4A7wOs88iRJHvw50HoujuPBoCKwHWiosy8MdfZnAdcHk8dxXFJ3VQbQlCTJvRBCGdRbD4M6uc5glpY3eAihpN5S5w12diSEcCCEcKUO4ljdr15T76ur1FDDLIQQ3qv71EdDOe3Kxj3leRXyk+pxdWnFWod6Wt2bY3de3aSuUHcPBVimHs7mK9WrmeOF6lR1o9qnzskh2ar2qm1qizpfXaPeVGdlmGN5pb09qMxz1Xb1kLqgzn1RyH7JUXW52lr5e/Kqi9qpto7V1atuUzfnARrV7jEib1T76gG2qxdGmXyiekkt1GswPTtek0aBfJp6YySGBfWg2tPQ0FAYgf1stUfdmdcjarbYJEniKIq6gY/Aw+zWHAC+p2labGpqiorFYgGYCEzN7oQdQClN07O1/EfDyGgC0ALMBdYAi4FyK+4H3gLPsxfR1zRNi+NP7nH5J+QntnXe5B5mpfQAAAAASUVORK5CYII=">
|
||||
|
||||
<!-- CSS -->
|
||||
<link rel="stylesheet" type="text/css" href="nimdoc.out.css">
|
||||
|
||||
<!-- JS -->
|
||||
<script type="text/javascript" src="dochack.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="document" id="documentId">
|
||||
<div class="container">
|
||||
<h1 class="title">std/private/asciitables</h1>
|
||||
<div class="row">
|
||||
<div class="three columns">
|
||||
<div class="theme-select-wrapper">
|
||||
<label for="theme-select">Theme: </label>
|
||||
<select id="theme-select" onchange="setTheme(this.value)">
|
||||
<option value="auto">🌗 Match OS</option>
|
||||
<option value="dark">🌑 Dark</option>
|
||||
<option value="light">🌕 Light</option>
|
||||
</select>
|
||||
</div>
|
||||
<div id="global-links">
|
||||
<ul class="simple-boot">
|
||||
<li><a href="manual.html">Manual</a></li>
|
||||
<li><a href="lib.html">Standard library</a></li>
|
||||
<li> <a id="indexLink" href="theindex.html">Index</a></li>
|
||||
<li><a href="compiler/theindex.html">Compiler docs</a></li>
|
||||
<li><a href="https://nim-lang.github.io/fusion/theindex.html">Fusion docs</a></li>
|
||||
<li><a href="https://nim-lang.github.io/Nim/">devel</a>, <a href="https://nim-lang.org/documentation.html">stable</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="searchInputDiv">
|
||||
Search: <input type="search" id="searchInput"
|
||||
onkeyup="search()" />
|
||||
</div>
|
||||
|
||||
<ul class="simple simple-toc" id="toc-list">
|
||||
<li>
|
||||
<details open>
|
||||
<summary><a class="reference reference-toplevel" href="#7" id="57">Types</a></summary>
|
||||
<ul class="simple simple-toc-section">
|
||||
<li><a class="reference" href="#Cell" title="Cell = object
|
||||
text*: string
|
||||
width*, row*, col*, ncols*, nrows*: int">Cell</a></li>
|
||||
|
||||
</ul>
|
||||
</details>
|
||||
</li>
|
||||
<li>
|
||||
<details open>
|
||||
<summary><a class="reference reference-toplevel" href="#12" id="62">Procs</a></summary>
|
||||
<ul class="simple simple-toc-section">
|
||||
<ul class="simple nested-toc-section">alignTable
|
||||
<li><a class="reference" href="#alignTable%2Cstring%2Cchar%2Cchar%2Cstring" title="alignTable(s: string; delim = '\t'; fill = ' '; sep = " "): string">alignTable(s: string; delim = '\t'; fill = ' '; sep = " "): string</a></li>
|
||||
|
||||
</ul>
|
||||
|
||||
</ul>
|
||||
</details>
|
||||
</li>
|
||||
<li>
|
||||
<details open>
|
||||
<summary><a class="reference reference-toplevel" href="#15" id="65">Iterators</a></summary>
|
||||
<ul class="simple simple-toc-section">
|
||||
<ul class="simple nested-toc-section">parseTableCells
|
||||
<li><a class="reference" href="#parseTableCells.i%2Cstring%2Cchar" title="parseTableCells(s: string; delim = '\t'): Cell">parseTableCells(s: string; delim = '\t'): Cell</a></li>
|
||||
|
||||
</ul>
|
||||
|
||||
</ul>
|
||||
</details>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
<div class="nine columns" id="content">
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/std/private/asciitables.nim#L1" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/private/asciitables.nim#L1" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
<div id="tocRoot"></div>
|
||||
|
||||
<p class="module-desc"></p>
|
||||
<div class="section" id="7">
|
||||
<h1><a class="toc-backref" href="#7">Types</a></h1>
|
||||
<dl class="item">
|
||||
<div id="Cell">
|
||||
<dt><pre><a href="asciitables.html#Cell"><span class="Identifier">Cell</span></a> <span class="Other">=</span> <span class="Keyword">object</span>
|
||||
<span class="Identifier">text</span><span class="Operator">*</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a>
|
||||
<span class="Identifier">width</span><span class="Operator">*</span><span class="Other">,</span> <span class="Identifier">row</span><span class="Operator">*</span><span class="Other">,</span> <span class="Identifier">col</span><span class="Operator">*</span><span class="Other">,</span> <span class="Identifier">ncols</span><span class="Operator">*</span><span class="Other">,</span> <span class="Identifier">nrows</span><span class="Operator">*</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a>
|
||||
</pre></dt>
|
||||
<dd>
|
||||
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/std/private/asciitables.nim#L6" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/private/asciitables.nim#L6" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</dl>
|
||||
</div>
|
||||
<div class="section" id="12">
|
||||
<h1><a class="toc-backref" href="#12">Procs</a></h1>
|
||||
<dl class="item">
|
||||
<div id="alignTable-procs-all">
|
||||
<div id="alignTable,string,char,char,string">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#alignTable%2Cstring%2Cchar%2Cchar%2Cstring"><span class="Identifier">alignTable</span></a><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">delim</span> <span class="Other">=</span> <span class="CharLit">'\t'</span><span class="Other">;</span> <span class="Identifier">fill</span> <span class="Other">=</span> <span class="CharLit">' '</span><span class="Other">;</span> <span class="Identifier">sep</span> <span class="Other">=</span> <span class="StringLit">" "</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> {.
|
||||
<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Formats a <tt class="docutils literal"><span class="pre"><span class="Identifier">delim</span></span></tt>-delimited <tt class="docutils literal"><span class="pre"><span class="Identifier">s</span></span></tt> representing a table; each cell is aligned to a width that's computed for each column; consecutive columns are delimited by <tt class="docutils literal"><span class="pre"><span class="Identifier">sep</span></span></tt>, and alignment space is filled using <tt class="docutils literal"><span class="pre"><span class="Identifier">fill</span></span></tt>. More customized formatting can be done by calling <tt class="docutils literal"><span class="pre"><span class="Identifier">parseTableCells</span></span></tt> directly.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/std/private/asciitables.nim#L71" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/private/asciitables.nim#L71" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</dl>
|
||||
</div>
|
||||
<div class="section" id="15">
|
||||
<h1><a class="toc-backref" href="#15">Iterators</a></h1>
|
||||
<dl class="item">
|
||||
<div id="parseTableCells-iterators-all">
|
||||
<div id="parseTableCells.i,string,char">
|
||||
<dt><pre><span class="Keyword">iterator</span> <a href="#parseTableCells.i%2Cstring%2Cchar"><span class="Identifier">parseTableCells</span></a><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">delim</span> <span class="Other">=</span> <span class="CharLit">'\t'</span><span class="Other">)</span><span class="Other">:</span> <a href="asciitables.html#Cell"><span class="Identifier">Cell</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
|
||||
<span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Iterates over all cells in a <tt class="docutils literal"><span class="pre"><span class="Identifier">delim</span></span></tt>-delimited <tt class="docutils literal"><span class="pre"><span class="Identifier">s</span></span></tt>, after a 1st pass that computes number of rows, columns, and width of each column.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/std/private/asciitables.nim#L10" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/private/asciitables.nim#L10" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="twelve-columns footer">
|
||||
<span class="nim-sprite"></span>
|
||||
<br>
|
||||
<small style="color: var(--hint);">Made with Nim. Generated: 2023-03-13 00:20:04 UTC</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script defer data-domain="nim-lang.org" src="https://plausible.io/js/plausible.js"></script>
|
||||
|
||||
<!-- Google fonts -->
|
||||
<link href='https://fonts.googleapis.com/css?family=Lato:400,600,900' rel='stylesheet' type='text/css'/>
|
||||
<link href='https://fonts.googleapis.com/css?family=Source+Code+Pro:400,500,600' rel='stylesheet' type='text/css'/>
|
||||
</body>
|
||||
</html>
|
||||
4
asciitables.idx
Normal file
4
asciitables.idx
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
nimTitle asciitables asciitables.html module std/private/asciitables 0
|
||||
nim Cell asciitables.html#Cell object Cell 6
|
||||
nim parseTableCells asciitables.html#parseTableCells.i,string,char iterator parseTableCells(s: string; delim = '\t'): Cell 10
|
||||
nim alignTable asciitables.html#alignTable,string,char,char,string proc alignTable(s: string; delim = '\t'; fill = ' '; sep = " "): string 71
|
||||
240
assertions.html
Normal file
240
assertions.html
Normal file
|
|
@ -0,0 +1,240 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<!-- This file is generated by Nim. -->
|
||||
<html xmlns="https://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>std/assertions</title>
|
||||
|
||||
<!-- Favicon -->
|
||||
<link rel="shortcut icon" href="data:image/x-icon;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAUAAAAF////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAIAAABbAAAAlQAAAKIAAACbAAAAmwAAAKIAAACVAAAAWwAAAAL///8A////AP///wD///8A////AAAAABQAAADAAAAAYwAAAA3///8A////AP///wD///8AAAAADQAAAGMAAADAAAAAFP///wD///8A////AP///wAAAACdAAAAOv///wD///8A////AP///wD///8A////AP///wD///8AAAAAOgAAAJ3///8A////AP///wAAAAAnAAAAcP///wAAAAAoAAAASv///wD///8A////AP///wAAAABKAAAAKP///wAAAABwAAAAJ////wD///8AAAAAgQAAABwAAACIAAAAkAAAAJMAAACtAAAAFQAAABUAAACtAAAAkwAAAJAAAACIAAAAHAAAAIH///8A////AAAAAKQAAACrAAAAaP///wD///8AAAAARQAAANIAAADSAAAARf///wD///8AAAAAaAAAAKsAAACk////AAAAADMAAACcAAAAnQAAABj///8A////AP///wAAAAAYAAAAGP///wD///8A////AAAAABgAAACdAAAAnAAAADMAAAB1AAAAwwAAAP8AAADpAAAAsQAAAE4AAAAb////AP///wAAAAAbAAAATgAAALEAAADpAAAA/wAAAMMAAAB1AAAAtwAAAOkAAAD/AAAA/wAAAP8AAADvAAAA3gAAAN4AAADeAAAA3gAAAO8AAAD/AAAA/wAAAP8AAADpAAAAtwAAAGUAAAA/AAAA3wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAADfAAAAPwAAAGX///8A////AAAAAEgAAADtAAAAvwAAAL0AAADGAAAA7wAAAO8AAADGAAAAvQAAAL8AAADtAAAASP///wD///8A////AP///wD///8AAAAAO////wD///8A////AAAAAIcAAACH////AP///wD///8AAAAAO////wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A//8AAP//AAD4HwAA7/cAAN/7AAD//wAAoYUAAJ55AACf+QAAh+EAAAAAAADAAwAA4AcAAP5/AAD//wAA//8AAA=="/>
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAA3XAAAN1wFCKJt4AAAAB3RJTUUH4QQQEwksSS9ZWwAAAk1JREFUWMPtll2ITVEUx39nn/O7Y5qR8f05wtCUUr6ZIS++8pEnkZInPImneaCQ5METNdOkeFBKUhMPRIkHKfEuUZSUlGlKPN2TrgfncpvmnntnmlEyq1Z7t89/rf9a6+y99oZxGZf/XeIq61EdtgKXgdXA0xrYAvBjOIF1AI9zvjcC74BSpndrJPkBWDScTF8Aa4E3wDlgHbASaANmVqlcCnwHvgDvgVfAJ+AikAAvgfVZwLnSVZHZaOuKoQi3ZOMi4NkYkpe1p4J7A8BpYAD49hfIy/oqG0+hLomiKP2L5L+1ubn5115S+3OAn4EnwBlgMzCjyt6ZAnQCJ4A7wOs88iRJHvw50HoujuPBoCKwHWiosy8MdfZnAdcHk8dxXFJ3VQbQlCTJvRBCGdRbD4M6uc5glpY3eAihpN5S5w12diSEcCCEcKUO4ljdr15T76ur1FDDLIQQ3qv71EdDOe3Kxj3leRXyk+pxdWnFWod6Wt2bY3de3aSuUHcPBVimHs7mK9WrmeOF6lR1o9qnzskh2ar2qm1qizpfXaPeVGdlmGN5pb09qMxz1Xb1kLqgzn1RyH7JUXW52lr5e/Kqi9qpto7V1atuUzfnARrV7jEib1T76gG2qxdGmXyiekkt1GswPTtek0aBfJp6YySGBfWg2tPQ0FAYgf1stUfdmdcjarbYJEniKIq6gY/Aw+zWHAC+p2labGpqiorFYgGYCEzN7oQdQClN07O1/EfDyGgC0ALMBdYAi4FyK+4H3gLPsxfR1zRNi+NP7nH5J+QntnXe5B5mpfQAAAAASUVORK5CYII=">
|
||||
|
||||
<!-- CSS -->
|
||||
<link rel="stylesheet" type="text/css" href="nimdoc.out.css">
|
||||
|
||||
<!-- JS -->
|
||||
<script type="text/javascript" src="dochack.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="document" id="documentId">
|
||||
<div class="container">
|
||||
<h1 class="title">std/assertions</h1>
|
||||
<div class="row">
|
||||
<div class="three columns">
|
||||
<div class="theme-select-wrapper">
|
||||
<label for="theme-select">Theme: </label>
|
||||
<select id="theme-select" onchange="setTheme(this.value)">
|
||||
<option value="auto">🌗 Match OS</option>
|
||||
<option value="dark">🌑 Dark</option>
|
||||
<option value="light">🌕 Light</option>
|
||||
</select>
|
||||
</div>
|
||||
<div id="global-links">
|
||||
<ul class="simple-boot">
|
||||
<li><a href="manual.html">Manual</a></li>
|
||||
<li><a href="lib.html">Standard library</a></li>
|
||||
<li> <a id="indexLink" href="theindex.html">Index</a></li>
|
||||
<li><a href="compiler/theindex.html">Compiler docs</a></li>
|
||||
<li><a href="https://nim-lang.github.io/fusion/theindex.html">Fusion docs</a></li>
|
||||
<li><a href="https://nim-lang.github.io/Nim/">devel</a>, <a href="https://nim-lang.org/documentation.html">stable</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="searchInputDiv">
|
||||
Search: <input type="search" id="searchInput"
|
||||
onkeyup="search()" />
|
||||
</div>
|
||||
|
||||
<ul class="simple simple-toc" id="toc-list">
|
||||
<li>
|
||||
<a class="reference reference-toplevel" href="#6" id="56">Imports</a>
|
||||
</li>
|
||||
<li>
|
||||
<details open>
|
||||
<summary><a class="reference reference-toplevel" href="#12" id="62">Procs</a></summary>
|
||||
<ul class="simple simple-toc-section">
|
||||
<ul class="simple nested-toc-section">failedAssertImpl
|
||||
<li><a class="reference" href="#failedAssertImpl%2Cstring" title="failedAssertImpl(msg: string)">failedAssertImpl(msg: string)</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">raiseAssert
|
||||
<li><a class="reference" href="#raiseAssert%2Cstring" title="raiseAssert(msg: string)">raiseAssert(msg: string)</a></li>
|
||||
|
||||
</ul>
|
||||
|
||||
</ul>
|
||||
</details>
|
||||
</li>
|
||||
<li>
|
||||
<details open>
|
||||
<summary><a class="reference reference-toplevel" href="#18" id="68">Templates</a></summary>
|
||||
<ul class="simple simple-toc-section">
|
||||
<ul class="simple nested-toc-section">assert
|
||||
<li><a class="reference" href="#assert.t%2Cuntyped%2Cstring" title="assert(cond: untyped; msg = "")">assert(cond: untyped; msg = "")</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">doAssert
|
||||
<li><a class="reference" href="#doAssert.t%2Cuntyped%2Cstring" title="doAssert(cond: untyped; msg = "")">doAssert(cond: untyped; msg = "")</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">doAssertRaises
|
||||
<li><a class="reference" href="#doAssertRaises.t%2Ctypedesc%2Cuntyped" title="doAssertRaises(exception: typedesc; code: untyped)">doAssertRaises(exception: typedesc; code: untyped)</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">onFailedAssert
|
||||
<li><a class="reference" href="#onFailedAssert.t%2Cuntyped%2Cuntyped" title="onFailedAssert(msg, code: untyped): untyped">onFailedAssert(msg, code: untyped): untyped</a></li>
|
||||
|
||||
</ul>
|
||||
|
||||
</ul>
|
||||
</details>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
<div class="nine columns" id="content">
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/std/assertions.nim#L1" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/assertions.nim#L1" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
<div id="tocRoot"></div>
|
||||
|
||||
<p class="module-desc">This module implements assertion handling.</p>
|
||||
<div class="section" id="6">
|
||||
<h1><a class="toc-backref" href="#6">Imports</a></h1>
|
||||
<dl class="item">
|
||||
<a class="reference external" href="miscdollars.html">miscdollars</a>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="section" id="12">
|
||||
<h1><a class="toc-backref" href="#12">Procs</a></h1>
|
||||
<dl class="item">
|
||||
<div id="failedAssertImpl-procs-all">
|
||||
<div id="failedAssertImpl,string">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#failedAssertImpl%2Cstring"><span class="Identifier">failedAssertImpl</span></a><span class="Other">(</span><span class="Identifier">msg</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Raises an <tt class="docutils literal"><span class="pre"><span class="Identifier">AssertionDefect</span></span></tt> with <tt class="docutils literal"><span class="pre"><span class="Identifier">msg</span></span></tt>, but this is hidden from the effect system. Called when an assertion failed.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/std/assertions.nim#L38" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/assertions.nim#L38" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="raiseAssert-procs-all">
|
||||
<div id="raiseAssert,string">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#raiseAssert%2Cstring"><span class="Identifier">raiseAssert</span></a><span class="Other">(</span><span class="Identifier">msg</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">)</span> {.<span class="Identifier">noinline</span><span class="Other">,</span> <span class="Identifier">noreturn</span><span class="Other">,</span> <span class="Identifier">nosinks</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
|
||||
<span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Raises an <tt class="docutils literal"><span class="pre"><span class="Identifier">AssertionDefect</span></span></tt> with <tt class="docutils literal"><span class="pre"><span class="Identifier">msg</span></span></tt>.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/std/assertions.nim#L31" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/assertions.nim#L31" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</dl>
|
||||
</div>
|
||||
<div class="section" id="18">
|
||||
<h1><a class="toc-backref" href="#18">Templates</a></h1>
|
||||
<dl class="item">
|
||||
<div id="assert-templates-all">
|
||||
<div id="assert.t,untyped,string">
|
||||
<dt><pre><span class="Keyword">template</span> <a href="#assert.t%2Cuntyped%2Cstring"><span class="Identifier">assert</span></a><span class="Other">(</span><span class="Identifier">cond</span><span class="Other">:</span> <a href="system.html#untyped"><span class="Identifier">untyped</span></a><span class="Other">;</span> <span class="Identifier">msg</span> <span class="Other">=</span> <span class="StringLit">""</span><span class="Other">)</span></pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Raises <tt class="docutils literal"><span class="pre"><span class="Identifier">AssertionDefect</span></span></tt> with <tt class="docutils literal"><span class="pre"><span class="Identifier">msg</span></span></tt> if <tt class="docutils literal"><span class="pre"><span class="Identifier">cond</span></span></tt> is false. Note that <tt class="docutils literal"><span class="pre"><span class="Identifier">AssertionDefect</span></span></tt> is hidden from the effect system, so it doesn't produce <tt class="docutils literal"><span class="pre"><span class="Punctuation">{</span><span class="Operator">.</span><span class="Identifier">raises</span><span class="Punctuation">:</span> <span class="Punctuation">[</span><span class="Identifier">AssertionDefect</span><span class="Punctuation">]</span><span class="Operator">.</span><span class="Punctuation">}</span></span></tt>. This exception is only supposed to be caught by unit testing frameworks.</p>
|
||||
<p>No code will be generated for <tt class="docutils literal"><span class="pre"><span class="Identifier">assert</span></span></tt> when passing <tt class="docutils literal"><span class="pre"><span class="Operator">-</span><span class="Identifier">d</span><span class="Punctuation">:</span><span class="Identifier">danger</span></span></tt> (implied by <tt class="docutils literal"><span class="pre"><span class="Operator">--</span><span class="Identifier">assertions</span><span class="Punctuation">:</span><span class="Identifier">off</span></span></tt>). See <a class="reference external" href="nimc.html#compiler-usage-commandminusline-switches">command line switches</a>.</p>
|
||||
|
||||
<p><strong class="examples_text">Example:</strong></p>
|
||||
<pre class="listing"><span class="Identifier">assert</span> <span class="DecNumber">1</span> <span class="Operator">==</span> <span class="DecNumber">1</span></pre>
|
||||
<p><strong class="examples_text">Example: cmd: --assertions:off</strong></p>
|
||||
<pre class="listing"><span class="Identifier">assert</span> <span class="DecNumber">1</span> <span class="Operator">==</span> <span class="DecNumber">2</span> <span class="Comment"># no code generated, no failure here</span></pre>
|
||||
<p><strong class="examples_text">Example: cmd: -d:danger</strong></p>
|
||||
<pre class="listing"><span class="Identifier">assert</span> <span class="DecNumber">1</span> <span class="Operator">==</span> <span class="DecNumber">2</span> <span class="Comment"># ditto</span></pre>
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/std/assertions.nim#L59" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/assertions.nim#L59" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="doAssert-templates-all">
|
||||
<div id="doAssert.t,untyped,string">
|
||||
<dt><pre><span class="Keyword">template</span> <a href="#doAssert.t%2Cuntyped%2Cstring"><span class="Identifier">doAssert</span></a><span class="Other">(</span><span class="Identifier">cond</span><span class="Other">:</span> <a href="system.html#untyped"><span class="Identifier">untyped</span></a><span class="Other">;</span> <span class="Identifier">msg</span> <span class="Other">=</span> <span class="StringLit">""</span><span class="Other">)</span></pre></dt>
|
||||
<dd>
|
||||
|
||||
Similar to <a class="reference external" href="#assert.t,untyped,string">assert</a> but is always turned on regardless of <tt class="docutils literal"><span class="pre"><span class="Operator">--</span><span class="Identifier">assertions</span></span></tt>.
|
||||
<p><strong class="examples_text">Example:</strong></p>
|
||||
<pre class="listing"><span class="Identifier">doAssert</span> <span class="DecNumber">1</span> <span class="Operator">==</span> <span class="DecNumber">1</span> <span class="Comment"># generates code even when built with `-d:danger` or `--assertions:off`</span></pre>
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/std/assertions.nim#L73" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/assertions.nim#L73" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="doAssertRaises-templates-all">
|
||||
<div id="doAssertRaises.t,typedesc,untyped">
|
||||
<dt><pre><span class="Keyword">template</span> <a href="#doAssertRaises.t%2Ctypedesc%2Cuntyped"><span class="Identifier">doAssertRaises</span></a><span class="Other">(</span><span class="Identifier">exception</span><span class="Other">:</span> <a href="system.html#typedesc"><span class="Identifier">typedesc</span></a><span class="Other">;</span> <span class="Identifier">code</span><span class="Other">:</span> <a href="system.html#untyped"><span class="Identifier">untyped</span></a><span class="Other">)</span></pre></dt>
|
||||
<dd>
|
||||
|
||||
Raises <tt class="docutils literal"><span class="pre"><span class="Identifier">AssertionDefect</span></span></tt> if specified <tt class="docutils literal"><span class="pre"><span class="Identifier">code</span></span></tt> does not raise <tt class="docutils literal"><span class="pre"><span class="Identifier">exception</span></span></tt>.
|
||||
<p><strong class="examples_text">Example:</strong></p>
|
||||
<pre class="listing"><span class="Identifier">doAssertRaises</span><span class="Punctuation">(</span><span class="Identifier">ValueError</span><span class="Punctuation">)</span><span class="Punctuation">:</span> <span class="Keyword">raise</span> <span class="Identifier">newException</span><span class="Punctuation">(</span><span class="Identifier">ValueError</span><span class="Punctuation">,</span> <span class="StringLit">"Hello World"</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">doAssertRaises</span><span class="Punctuation">(</span><span class="Identifier">CatchableError</span><span class="Punctuation">)</span><span class="Punctuation">:</span> <span class="Keyword">raise</span> <span class="Identifier">newException</span><span class="Punctuation">(</span><span class="Identifier">ValueError</span><span class="Punctuation">,</span> <span class="StringLit">"Hello World"</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">doAssertRaises</span><span class="Punctuation">(</span><span class="Identifier">AssertionDefect</span><span class="Punctuation">)</span><span class="Punctuation">:</span> <span class="Identifier">doAssert</span> <span class="Identifier">false</span></pre>
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/std/assertions.nim#L96" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/assertions.nim#L96" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="onFailedAssert-templates-all">
|
||||
<div id="onFailedAssert.t,untyped,untyped">
|
||||
<dt><pre><span class="Keyword">template</span> <a href="#onFailedAssert.t%2Cuntyped%2Cuntyped"><span class="Identifier">onFailedAssert</span></a><span class="Other">(</span><span class="Identifier">msg</span><span class="Other">,</span> <span class="Identifier">code</span><span class="Other">:</span> <a href="system.html#untyped"><span class="Identifier">untyped</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#untyped"><span class="Identifier">untyped</span></a> {.<span class="Identifier">dirty</span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Sets an assertion failure handler that will intercept any assert statements following <tt class="docutils literal"><span class="pre"><span class="Identifier">onFailedAssert</span></span></tt> in the current scope.
|
||||
<p><strong class="examples_text">Example:</strong></p>
|
||||
<pre class="listing"><span class="Keyword">type</span> <span class="Identifier">MyError</span> <span class="Operator">=</span> <span class="Keyword">object</span> <span class="Keyword">of</span> <span class="Identifier">CatchableError</span>
|
||||
<span class="Identifier">lineinfo</span><span class="Punctuation">:</span> <span class="Keyword">tuple</span><span class="Punctuation">[</span><span class="Identifier">filename</span><span class="Punctuation">:</span> <span class="Identifier">string</span><span class="Punctuation">,</span> <span class="Identifier">line</span><span class="Punctuation">:</span> <span class="Identifier">int</span><span class="Punctuation">,</span> <span class="Identifier">column</span><span class="Punctuation">:</span> <span class="Identifier">int</span><span class="Punctuation">]</span>
|
||||
<span class="Comment"># block-wide policy to change the failed assert exception type in order to</span>
|
||||
<span class="Comment"># include a lineinfo</span>
|
||||
<span class="Identifier">onFailedAssert</span><span class="Punctuation">(</span><span class="Identifier">msg</span><span class="Punctuation">)</span><span class="Punctuation">:</span>
|
||||
<span class="Keyword">raise</span> <span class="Punctuation">(</span><span class="Keyword">ref</span> <span class="Identifier">MyError</span><span class="Punctuation">)</span><span class="Punctuation">(</span><span class="Identifier">msg</span><span class="Punctuation">:</span> <span class="Identifier">msg</span><span class="Punctuation">,</span> <span class="Identifier">lineinfo</span><span class="Punctuation">:</span> <span class="Identifier">instantiationInfo</span><span class="Punctuation">(</span><span class="Operator">-</span><span class="DecNumber">2</span><span class="Punctuation">)</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">doAssertRaises</span><span class="Punctuation">(</span><span class="Identifier">MyError</span><span class="Punctuation">)</span><span class="Punctuation">:</span> <span class="Identifier">doAssert</span> <span class="Identifier">false</span></pre>
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/std/assertions.nim#L79" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/assertions.nim#L79" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="twelve-columns footer">
|
||||
<span class="nim-sprite"></span>
|
||||
<br>
|
||||
<small style="color: var(--hint);">Made with Nim. Generated: 2023-03-13 00:19:58 UTC</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script defer data-domain="nim-lang.org" src="https://plausible.io/js/plausible.js"></script>
|
||||
|
||||
<!-- Google fonts -->
|
||||
<link href='https://fonts.googleapis.com/css?family=Lato:400,600,900' rel='stylesheet' type='text/css'/>
|
||||
<link href='https://fonts.googleapis.com/css?family=Source+Code+Pro:400,500,600' rel='stylesheet' type='text/css'/>
|
||||
</body>
|
||||
</html>
|
||||
7
assertions.idx
Normal file
7
assertions.idx
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
nimTitle assertions assertions.html module std/assertions 0
|
||||
nim raiseAssert assertions.html#raiseAssert,string proc raiseAssert(msg: string) 31
|
||||
nim failedAssertImpl assertions.html#failedAssertImpl,string proc failedAssertImpl(msg: string) 38
|
||||
nim assert assertions.html#assert.t,untyped,string template assert(cond: untyped; msg = "") 59
|
||||
nim doAssert assertions.html#doAssert.t,untyped,string template doAssert(cond: untyped; msg = "") 73
|
||||
nim onFailedAssert assertions.html#onFailedAssert.t,untyped,untyped template onFailedAssert(msg, code: untyped): untyped 79
|
||||
nim doAssertRaises assertions.html#doAssertRaises.t,typedesc,untyped template doAssertRaises(exception: typedesc; code: untyped) 96
|
||||
96
async.html
Normal file
96
async.html
Normal file
|
|
@ -0,0 +1,96 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<!-- This file is generated by Nim. -->
|
||||
<html xmlns="https://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>std/async</title>
|
||||
|
||||
<!-- Favicon -->
|
||||
<link rel="shortcut icon" href="data:image/x-icon;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAUAAAAF////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAIAAABbAAAAlQAAAKIAAACbAAAAmwAAAKIAAACVAAAAWwAAAAL///8A////AP///wD///8A////AAAAABQAAADAAAAAYwAAAA3///8A////AP///wD///8AAAAADQAAAGMAAADAAAAAFP///wD///8A////AP///wAAAACdAAAAOv///wD///8A////AP///wD///8A////AP///wD///8AAAAAOgAAAJ3///8A////AP///wAAAAAnAAAAcP///wAAAAAoAAAASv///wD///8A////AP///wAAAABKAAAAKP///wAAAABwAAAAJ////wD///8AAAAAgQAAABwAAACIAAAAkAAAAJMAAACtAAAAFQAAABUAAACtAAAAkwAAAJAAAACIAAAAHAAAAIH///8A////AAAAAKQAAACrAAAAaP///wD///8AAAAARQAAANIAAADSAAAARf///wD///8AAAAAaAAAAKsAAACk////AAAAADMAAACcAAAAnQAAABj///8A////AP///wAAAAAYAAAAGP///wD///8A////AAAAABgAAACdAAAAnAAAADMAAAB1AAAAwwAAAP8AAADpAAAAsQAAAE4AAAAb////AP///wAAAAAbAAAATgAAALEAAADpAAAA/wAAAMMAAAB1AAAAtwAAAOkAAAD/AAAA/wAAAP8AAADvAAAA3gAAAN4AAADeAAAA3gAAAO8AAAD/AAAA/wAAAP8AAADpAAAAtwAAAGUAAAA/AAAA3wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAADfAAAAPwAAAGX///8A////AAAAAEgAAADtAAAAvwAAAL0AAADGAAAA7wAAAO8AAADGAAAAvQAAAL8AAADtAAAASP///wD///8A////AP///wD///8AAAAAO////wD///8A////AAAAAIcAAACH////AP///wD///8AAAAAO////wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A//8AAP//AAD4HwAA7/cAAN/7AAD//wAAoYUAAJ55AACf+QAAh+EAAAAAAADAAwAA4AcAAP5/AAD//wAA//8AAA=="/>
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAA3XAAAN1wFCKJt4AAAAB3RJTUUH4QQQEwksSS9ZWwAAAk1JREFUWMPtll2ITVEUx39nn/O7Y5qR8f05wtCUUr6ZIS++8pEnkZInPImneaCQ5METNdOkeFBKUhMPRIkHKfEuUZSUlGlKPN2TrgfncpvmnntnmlEyq1Z7t89/rf9a6+y99oZxGZf/XeIq61EdtgKXgdXA0xrYAvBjOIF1AI9zvjcC74BSpndrJPkBWDScTF8Aa4E3wDlgHbASaANmVqlcCnwHvgDvgVfAJ+AikAAvgfVZwLnSVZHZaOuKoQi3ZOMi4NkYkpe1p4J7A8BpYAD49hfIy/oqG0+hLomiKP2L5L+1ubn5115S+3OAn4EnwBlgMzCjyt6ZAnQCJ4A7wOs88iRJHvw50HoujuPBoCKwHWiosy8MdfZnAdcHk8dxXFJ3VQbQlCTJvRBCGdRbD4M6uc5glpY3eAihpN5S5w12diSEcCCEcKUO4ljdr15T76ur1FDDLIQQ3qv71EdDOe3Kxj3leRXyk+pxdWnFWod6Wt2bY3de3aSuUHcPBVimHs7mK9WrmeOF6lR1o9qnzskh2ar2qm1qizpfXaPeVGdlmGN5pb09qMxz1Xb1kLqgzn1RyH7JUXW52lr5e/Kqi9qpto7V1atuUzfnARrV7jEib1T76gG2qxdGmXyiekkt1GswPTtek0aBfJp6YySGBfWg2tPQ0FAYgf1stUfdmdcjarbYJEniKIq6gY/Aw+zWHAC+p2labGpqiorFYgGYCEzN7oQdQClN07O1/EfDyGgC0ALMBdYAi4FyK+4H3gLPsxfR1zRNi+NP7nH5J+QntnXe5B5mpfQAAAAASUVORK5CYII=">
|
||||
|
||||
<!-- CSS -->
|
||||
<link rel="stylesheet" type="text/css" href="nimdoc.out.css">
|
||||
|
||||
<!-- JS -->
|
||||
<script type="text/javascript" src="dochack.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="document" id="documentId">
|
||||
<div class="container">
|
||||
<h1 class="title">std/async</h1>
|
||||
<div class="row">
|
||||
<div class="three columns">
|
||||
<div class="theme-select-wrapper">
|
||||
<label for="theme-select">Theme: </label>
|
||||
<select id="theme-select" onchange="setTheme(this.value)">
|
||||
<option value="auto">🌗 Match OS</option>
|
||||
<option value="dark">🌑 Dark</option>
|
||||
<option value="light">🌕 Light</option>
|
||||
</select>
|
||||
</div>
|
||||
<div id="global-links">
|
||||
<ul class="simple-boot">
|
||||
<li><a href="manual.html">Manual</a></li>
|
||||
<li><a href="lib.html">Standard library</a></li>
|
||||
<li> <a id="indexLink" href="theindex.html">Index</a></li>
|
||||
<li><a href="compiler/theindex.html">Compiler docs</a></li>
|
||||
<li><a href="https://nim-lang.github.io/fusion/theindex.html">Fusion docs</a></li>
|
||||
<li><a href="https://nim-lang.github.io/Nim/">devel</a>, <a href="https://nim-lang.org/documentation.html">stable</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="searchInputDiv">
|
||||
Search: <input type="search" id="searchInput"
|
||||
onkeyup="search()" />
|
||||
</div>
|
||||
|
||||
<ul class="simple simple-toc" id="toc-list">
|
||||
<li>
|
||||
<a class="reference reference-toplevel" href="#6" id="56">Imports</a>
|
||||
</li>
|
||||
<li>
|
||||
<a class="reference reference-toplevel" href="#19" id="69">Exports</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
<div class="nine columns" id="content">
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/async.nim#L1" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/async.nim#L1" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
<div id="tocRoot"></div>
|
||||
|
||||
<p class="module-desc">Exports <a class="reference external" href="asyncmacro.html">asyncmacro</a> and <a class="reference external" href="asyncfutures.html">asyncfutures</a> for native backends, and <a class="reference external" href="asyncjs.html">asyncjs</a> on the JS backend. </p>
|
||||
<div class="section" id="6">
|
||||
<h1><a class="toc-backref" href="#6">Imports</a></h1>
|
||||
<dl class="item">
|
||||
<a class="reference external" href="asyncmacro.html">asyncmacro</a>, <a class="reference external" href="asyncfutures.html">asyncfutures</a>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="section" id="19">
|
||||
<h1><a class="toc-backref" href="#19">Exports</a></h1>
|
||||
<dl class="item">
|
||||
<a href="asyncmacro.html#multisync.m,untyped"><span class="Identifier">multisync</span></a>, <a href="asyncmacro.html#await.t,Future[T]"><span class="Identifier">await</span></a>, <a href="asyncmacro.html#async.m,untyped"><span class="Identifier">async</span></a>, <a href="asyncmacro.html#await.t,typed"><span class="Identifier">await</span></a>, <a href="asyncfutures.html#and,Future[T],Future[Y]"><span class="Identifier">and</span></a>, <a href="asyncfutures.html#addCallback,FutureBase,proc)"><span class="Identifier">addCallback</span></a>, <a href="asyncfutures.html#asyncCheck,Future[T]"><span class="Identifier">asyncCheck</span></a>, <a href="asyncfutures.html#or,Future[T],Future[Y]"><span class="Identifier">or</span></a>, <a href="asyncfutures.html#read"><span class="Identifier">read</span></a>, <a href="asyncfutures.html#fail,Future[T],ref.Exception"><span class="Identifier">fail</span></a>, <a href="asyncfutures.html#setCallSoonProc"><span class="Identifier">setCallSoonProc</span></a>, <a href="asyncfutures.html#callSoon,proc)"><span class="Identifier">callSoon</span></a>, <a href="asyncfutures.html#addCallback,Future[T],proc(Future[T])"><span class="Identifier">addCallback</span></a>, <a href="asyncfutures.html#clean,FutureVar[T]"><span class="Identifier">clean</span></a>, <a href="asyncfutures.html#clearCallbacks,FutureBase"><span class="Identifier">clearCallbacks</span></a>, <a href="asyncfutures.html#newFutureVar,string"><span class="Identifier">newFutureVar</span></a>, <a href="asyncfutures.html#mget,FutureVar[T]"><span class="Identifier">mget</span></a>, <a href="asyncfutures.html#Future"><span class="Identifier">Future</span></a>, <a href="asyncfutures.html#failed,FutureBase"><span class="Identifier">failed</span></a>, <a href="asyncfutures.html#$,seq[StackTraceEntry]"><span class="Identifier">$</span></a>, <a href="asyncfutures.html#callback=,FutureBase,proc)"><span class="Identifier">callback=</span></a>, <a href="asyncfutures.html#complete,FutureVar[T],T"><span class="Identifier">complete</span></a>, <a href="asyncfutures.html#callback=,Future[T],proc(Future[T])"><span class="Identifier">callback=</span></a>, <a href="asyncfutures.html#NimAsyncContinueSuffix"><span class="Identifier">NimAsyncContinueSuffix</span></a>, <a href="asyncfutures.html#FutureBase"><span class="Identifier">FutureBase</span></a>, <a href="asyncfutures.html#all,varargs[Future[T]]"><span class="Identifier">all</span></a>, <a href="asyncfutures.html#complete,FutureVar[T]"><span class="Identifier">complete</span></a>, <a href="asyncfutures.html#FutureError"><span class="Identifier">FutureError</span></a>, <a href="asyncfutures.html#getCallSoonProc"><span class="Identifier">getCallSoonProc</span></a>, <a href="asyncfutures.html#FutureVar"><span class="Identifier">FutureVar</span></a>, <a href="asyncfutures.html#isFutureLoggingEnabled"><span class="Identifier">isFutureLoggingEnabled</span></a>, <a href="asyncfutures.html#complete,Future[void]"><span class="Identifier">complete</span></a>, <a href="asyncfutures.html#readError,Future[T]"><span class="Identifier">readError</span></a>, <a href="asyncfutures.html#complete,Future[T],T"><span class="Identifier">complete</span></a>, <a href="asyncfutures.html#newFuture,string"><span class="Identifier">newFuture</span></a>, <a href="asyncfutures.html#finished"><span class="Identifier">finished</span></a>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="twelve-columns footer">
|
||||
<span class="nim-sprite"></span>
|
||||
<br>
|
||||
<small style="color: var(--hint);">Made with Nim. Generated: 2023-03-13 00:19:41 UTC</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script defer data-domain="nim-lang.org" src="https://plausible.io/js/plausible.js"></script>
|
||||
|
||||
<!-- Google fonts -->
|
||||
<link href='https://fonts.googleapis.com/css?family=Lato:400,600,900' rel='stylesheet' type='text/css'/>
|
||||
<link href='https://fonts.googleapis.com/css?family=Source+Code+Pro:400,500,600' rel='stylesheet' type='text/css'/>
|
||||
</body>
|
||||
</html>
|
||||
1
async.idx
Normal file
1
async.idx
Normal file
|
|
@ -0,0 +1 @@
|
|||
nimTitle async async.html module std/async 0
|
||||
1100
asyncdispatch.html
Normal file
1100
asyncdispatch.html
Normal file
File diff suppressed because it is too large
Load diff
63
asyncdispatch.idx
Normal file
63
asyncdispatch.idx
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
nimTitle asyncdispatch asyncdispatch.html module std/asyncdispatch 0
|
||||
nim callSoon asyncdispatch.html#callSoon,proc) proc callSoon(cbproc: proc () {.gcsafe.}) 286
|
||||
nim CompletionData asyncdispatch.html#CompletionData object CompletionData 309
|
||||
nim PDispatcher asyncdispatch.html#PDispatcher type PDispatcher 317
|
||||
nim CustomRef asyncdispatch.html#CustomRef type CustomRef 324
|
||||
nim AsyncFD asyncdispatch.html#AsyncFD type AsyncFD 326
|
||||
nim AsyncEvent asyncdispatch.html#AsyncEvent type AsyncEvent 339
|
||||
nim Callback asyncdispatch.html#Callback type Callback 341
|
||||
nim `==` asyncdispatch.html#==,AsyncFD,AsyncFD proc `==`(x: AsyncFD; y: AsyncFD): bool 344
|
||||
nim newDispatcher asyncdispatch.html#newDispatcher proc newDispatcher(): owned PDispatcher 346
|
||||
nim setGlobalDispatcher asyncdispatch.html#setGlobalDispatcher,sinkPDispatcher proc setGlobalDispatcher(disp: sink PDispatcher) 356
|
||||
nim getGlobalDispatcher asyncdispatch.html#getGlobalDispatcher proc getGlobalDispatcher(): PDispatcher 362
|
||||
nim getIoHandler asyncdispatch.html#getIoHandler,PDispatcher proc getIoHandler(disp: PDispatcher): Handle 367
|
||||
nim register asyncdispatch.html#register,AsyncFD proc register(fd: AsyncFD) 372
|
||||
nim hasPendingOperations asyncdispatch.html#hasPendingOperations proc hasPendingOperations(): bool 390
|
||||
nim newCustom asyncdispatch.html#newCustom proc newCustom(): CustomRef 487
|
||||
nim recv asyncdispatch.html#recv,AsyncFD,int proc recv(socket: AsyncFD; size: int; flags = {SafeDisconn}): owned(Future[string]) 494
|
||||
nim recvInto asyncdispatch.html#recvInto,AsyncFD,pointer,int proc recvInto(socket: AsyncFD; buf: pointer; size: int; flags = {SafeDisconn}): owned(\n Future[int]) 567
|
||||
nim send asyncdispatch.html#send,AsyncFD,pointer,int proc send(socket: AsyncFD; buf: pointer; size: int; flags = {SafeDisconn}): owned(\n Future[void]) 633
|
||||
nim sendTo asyncdispatch.html#sendTo,AsyncFD,pointer,int,ptr.SockAddr,SockLen proc sendTo(socket: AsyncFD; data: pointer; size: int; saddr: ptr SockAddr;\n saddrLen: SockLen; flags = {SafeDisconn}): owned(Future[void]) 678
|
||||
nim recvFromInto asyncdispatch.html#recvFromInto,AsyncFD,pointer,int,ptr.SockAddr,ptr.SockLen proc recvFromInto(socket: AsyncFD; data: pointer; size: int; saddr: ptr SockAddr;\n saddrLen: ptr SockLen; flags = {SafeDisconn}): owned(Future[int]) 723
|
||||
nim acceptAddr asyncdispatch.html#acceptAddr,AsyncFD proc acceptAddr(socket: AsyncFD; flags = {SafeDisconn};\n inheritable = defined(nimInheritHandles)): owned(\n Future[tuple[address: string, client: AsyncFD]]) 771
|
||||
nim setInheritable asyncdispatch.html#setInheritable,AsyncFD,bool proc setInheritable(fd: AsyncFD; inheritable: bool): bool 868
|
||||
nim closeSocket asyncdispatch.html#closeSocket,AsyncFD proc closeSocket(socket: AsyncFD) 870
|
||||
nim unregister asyncdispatch.html#unregister,AsyncFD proc unregister(fd: AsyncFD) 875
|
||||
nim contains asyncdispatch.html#contains,PDispatcher,AsyncFD proc contains(disp: PDispatcher; fd: AsyncFD): bool 879
|
||||
nim addRead asyncdispatch.html#addRead,AsyncFD,Callback proc addRead(fd: AsyncFD; cb: Callback) 974
|
||||
nim addWrite asyncdispatch.html#addWrite,AsyncFD,Callback proc addWrite(fd: AsyncFD; cb: Callback) 992
|
||||
nim addTimer asyncdispatch.html#addTimer,int,bool,Callback proc addTimer(timeout: int; oneshot: bool; cb: Callback) 1045
|
||||
nim addProcess asyncdispatch.html#addProcess,int,Callback proc addProcess(pid: int; cb: Callback) 1079
|
||||
nim newAsyncEvent asyncdispatch.html#newAsyncEvent proc newAsyncEvent(): AsyncEvent 1098
|
||||
nim trigger asyncdispatch.html#trigger,AsyncEvent proc trigger(ev: AsyncEvent) 1113
|
||||
nim unregister asyncdispatch.html#unregister,AsyncEvent proc unregister(ev: AsyncEvent) 1118
|
||||
nim close asyncdispatch.html#close,AsyncEvent proc close(ev: AsyncEvent) 1129
|
||||
nim addEvent asyncdispatch.html#addEvent,AsyncEvent,Callback proc addEvent(ev: AsyncEvent; cb: Callback) 1136
|
||||
nim drain asyncdispatch.html#drain,int proc drain(timeout = 500) 1695
|
||||
nim poll asyncdispatch.html#poll,int proc poll(timeout = 500) 1707
|
||||
nim createAsyncNativeSocket asyncdispatch.html#createAsyncNativeSocket,cint,cint,cint proc createAsyncNativeSocket(domain: cint; sockType: cint; protocol: cint;\n inheritable = defined(nimInheritHandles)): AsyncFD 1724
|
||||
nim createAsyncNativeSocket asyncdispatch.html#createAsyncNativeSocket,Domain,SockType,Protocol proc createAsyncNativeSocket(domain: Domain = Domain.AF_INET;\n sockType: SockType = SOCK_STREAM;\n protocol: Protocol = IPPROTO_TCP;\n inheritable = defined(nimInheritHandles)): AsyncFD 1729
|
||||
nim dial asyncdispatch.html#dial,string,Port,Protocol proc dial(address: string; port: Port; protocol: Protocol = IPPROTO_TCP): owned(\n Future[AsyncFD]) 1889
|
||||
nim connect asyncdispatch.html#connect,AsyncFD,string,Port proc connect(socket: AsyncFD; address: string; port: Port; domain = Domain.AF_INET): owned(\n Future[void]) 1904
|
||||
nim sleepAsync asyncdispatch.html#sleepAsync proc sleepAsync(ms: int | float): owned(Future[void]) 1919
|
||||
nim withTimeout asyncdispatch.html#withTimeout,Future[T],int proc withTimeout[T](fut: Future[T]; timeout: int): owned(Future[bool]) 1931
|
||||
nim accept asyncdispatch.html#accept,AsyncFD proc accept(socket: AsyncFD; flags = {SafeDisconn};\n inheritable = defined(nimInheritHandles)): owned(Future[AsyncFD]) 1953
|
||||
nim send asyncdispatch.html#send,AsyncFD,string proc send(socket: AsyncFD; data: string; flags = {SafeDisconn}): owned(Future[void]) 1977
|
||||
nim readAll asyncdispatch.html#readAll,FutureStream[string] proc readAll(future: FutureStream[string]): owned(Future[string]) 2000
|
||||
nim runForever asyncdispatch.html#runForever proc runForever() 2014
|
||||
nim waitFor asyncdispatch.html#waitFor,Future[T] proc waitFor[T](fut: Future[T]): T 2019
|
||||
nim activeDescriptors asyncdispatch.html#activeDescriptors proc activeDescriptors(): int 2026
|
||||
nim maxDescriptors asyncdispatch.html#maxDescriptors proc maxDescriptors(): int 2039
|
||||
heading Asynchronous procedures asyncdispatch.html#asynchronous-procedures Asynchronous procedures 0
|
||||
heading Handling Exceptions asyncdispatch.html#asynchronous-procedures-handling-exceptions Handling Exceptions 0
|
||||
heading Discarding futures asyncdispatch.html#discarding-futures Discarding futures 0
|
||||
heading Handling futures asyncdispatch.html#handling-futures Handling futures 0
|
||||
heading Examples asyncdispatch.html#examples Examples 0
|
||||
heading Investigating pending futures asyncdispatch.html#investigating-pending-futures Investigating pending futures 0
|
||||
heading Limitations/Bugs asyncdispatch.html#limitationsslashbugs Limitations/Bugs 0
|
||||
heading Multiple async backend support asyncdispatch.html#multiple-async-backend-support Multiple async backend support 0
|
||||
idx epoll asyncdispatch.html#epoll_1 Multiple async backend support 0
|
||||
idx kqueue asyncdispatch.html#kqueue_1 Multiple async backend support 0
|
||||
nimgrp createasyncnativesocket asyncdispatch.html#createAsyncNativeSocket-procs-all proc 1724
|
||||
nimgrp unregister asyncdispatch.html#unregister-procs-all proc 875
|
||||
nimgrp send asyncdispatch.html#send-procs-all proc 633
|
||||
418
asyncfile.html
Normal file
418
asyncfile.html
Normal file
|
|
@ -0,0 +1,418 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<!-- This file is generated by Nim. -->
|
||||
<html xmlns="https://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>std/asyncfile</title>
|
||||
|
||||
<!-- Favicon -->
|
||||
<link rel="shortcut icon" href="data:image/x-icon;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAUAAAAF////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAIAAABbAAAAlQAAAKIAAACbAAAAmwAAAKIAAACVAAAAWwAAAAL///8A////AP///wD///8A////AAAAABQAAADAAAAAYwAAAA3///8A////AP///wD///8AAAAADQAAAGMAAADAAAAAFP///wD///8A////AP///wAAAACdAAAAOv///wD///8A////AP///wD///8A////AP///wD///8AAAAAOgAAAJ3///8A////AP///wAAAAAnAAAAcP///wAAAAAoAAAASv///wD///8A////AP///wAAAABKAAAAKP///wAAAABwAAAAJ////wD///8AAAAAgQAAABwAAACIAAAAkAAAAJMAAACtAAAAFQAAABUAAACtAAAAkwAAAJAAAACIAAAAHAAAAIH///8A////AAAAAKQAAACrAAAAaP///wD///8AAAAARQAAANIAAADSAAAARf///wD///8AAAAAaAAAAKsAAACk////AAAAADMAAACcAAAAnQAAABj///8A////AP///wAAAAAYAAAAGP///wD///8A////AAAAABgAAACdAAAAnAAAADMAAAB1AAAAwwAAAP8AAADpAAAAsQAAAE4AAAAb////AP///wAAAAAbAAAATgAAALEAAADpAAAA/wAAAMMAAAB1AAAAtwAAAOkAAAD/AAAA/wAAAP8AAADvAAAA3gAAAN4AAADeAAAA3gAAAO8AAAD/AAAA/wAAAP8AAADpAAAAtwAAAGUAAAA/AAAA3wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAADfAAAAPwAAAGX///8A////AAAAAEgAAADtAAAAvwAAAL0AAADGAAAA7wAAAO8AAADGAAAAvQAAAL8AAADtAAAASP///wD///8A////AP///wD///8AAAAAO////wD///8A////AAAAAIcAAACH////AP///wD///8AAAAAO////wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A//8AAP//AAD4HwAA7/cAAN/7AAD//wAAoYUAAJ55AACf+QAAh+EAAAAAAADAAwAA4AcAAP5/AAD//wAA//8AAA=="/>
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAA3XAAAN1wFCKJt4AAAAB3RJTUUH4QQQEwksSS9ZWwAAAk1JREFUWMPtll2ITVEUx39nn/O7Y5qR8f05wtCUUr6ZIS++8pEnkZInPImneaCQ5METNdOkeFBKUhMPRIkHKfEuUZSUlGlKPN2TrgfncpvmnntnmlEyq1Z7t89/rf9a6+y99oZxGZf/XeIq61EdtgKXgdXA0xrYAvBjOIF1AI9zvjcC74BSpndrJPkBWDScTF8Aa4E3wDlgHbASaANmVqlcCnwHvgDvgVfAJ+AikAAvgfVZwLnSVZHZaOuKoQi3ZOMi4NkYkpe1p4J7A8BpYAD49hfIy/oqG0+hLomiKP2L5L+1ubn5115S+3OAn4EnwBlgMzCjyt6ZAnQCJ4A7wOs88iRJHvw50HoujuPBoCKwHWiosy8MdfZnAdcHk8dxXFJ3VQbQlCTJvRBCGdRbD4M6uc5glpY3eAihpN5S5w12diSEcCCEcKUO4ljdr15T76ur1FDDLIQQ3qv71EdDOe3Kxj3leRXyk+pxdWnFWod6Wt2bY3de3aSuUHcPBVimHs7mK9WrmeOF6lR1o9qnzskh2ar2qm1qizpfXaPeVGdlmGN5pb09qMxz1Xb1kLqgzn1RyH7JUXW52lr5e/Kqi9qpto7V1atuUzfnARrV7jEib1T76gG2qxdGmXyiekkt1GswPTtek0aBfJp6YySGBfWg2tPQ0FAYgf1stUfdmdcjarbYJEniKIq6gY/Aw+zWHAC+p2labGpqiorFYgGYCEzN7oQdQClN07O1/EfDyGgC0ALMBdYAi4FyK+4H3gLPsxfR1zRNi+NP7nH5J+QntnXe5B5mpfQAAAAASUVORK5CYII=">
|
||||
|
||||
<!-- CSS -->
|
||||
<link rel="stylesheet" type="text/css" href="nimdoc.out.css">
|
||||
|
||||
<!-- JS -->
|
||||
<script type="text/javascript" src="dochack.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="document" id="documentId">
|
||||
<div class="container">
|
||||
<h1 class="title">std/asyncfile</h1>
|
||||
<div class="row">
|
||||
<div class="three columns">
|
||||
<div class="theme-select-wrapper">
|
||||
<label for="theme-select">Theme: </label>
|
||||
<select id="theme-select" onchange="setTheme(this.value)">
|
||||
<option value="auto">🌗 Match OS</option>
|
||||
<option value="dark">🌑 Dark</option>
|
||||
<option value="light">🌕 Light</option>
|
||||
</select>
|
||||
</div>
|
||||
<div id="global-links">
|
||||
<ul class="simple-boot">
|
||||
<li><a href="manual.html">Manual</a></li>
|
||||
<li><a href="lib.html">Standard library</a></li>
|
||||
<li> <a id="indexLink" href="theindex.html">Index</a></li>
|
||||
<li><a href="compiler/theindex.html">Compiler docs</a></li>
|
||||
<li><a href="https://nim-lang.github.io/fusion/theindex.html">Fusion docs</a></li>
|
||||
<li><a href="https://nim-lang.github.io/Nim/">devel</a>, <a href="https://nim-lang.org/documentation.html">stable</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="searchInputDiv">
|
||||
Search: <input type="search" id="searchInput"
|
||||
onkeyup="search()" />
|
||||
</div>
|
||||
|
||||
<ul class="simple simple-toc" id="toc-list">
|
||||
<li>
|
||||
<a class="reference reference-toplevel" href="#6" id="56">Imports</a>
|
||||
</li>
|
||||
<li>
|
||||
<details open>
|
||||
<summary><a class="reference reference-toplevel" href="#7" id="57">Types</a></summary>
|
||||
<ul class="simple simple-toc-section">
|
||||
<li><a class="reference" href="#AsyncFile" title="AsyncFile = ref object">AsyncFile</a></li>
|
||||
|
||||
</ul>
|
||||
</details>
|
||||
</li>
|
||||
<li>
|
||||
<details open>
|
||||
<summary><a class="reference reference-toplevel" href="#12" id="62">Procs</a></summary>
|
||||
<ul class="simple simple-toc-section">
|
||||
<ul class="simple nested-toc-section">close
|
||||
<li><a class="reference" href="#close%2CAsyncFile" title="close(f: AsyncFile)">close(f: AsyncFile)</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">getFilePos
|
||||
<li><a class="reference" href="#getFilePos%2CAsyncFile" title="getFilePos(f: AsyncFile): int64">getFilePos(f: AsyncFile): int64</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">getFileSize
|
||||
<li><a class="reference" href="#getFileSize%2CAsyncFile" title="getFileSize(f: AsyncFile): int64">getFileSize(f: AsyncFile): int64</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">newAsyncFile
|
||||
<li><a class="reference" href="#newAsyncFile%2CAsyncFD" title="newAsyncFile(fd: AsyncFD): AsyncFile">newAsyncFile(fd: AsyncFD): AsyncFile</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">openAsync
|
||||
<li><a class="reference" href="#openAsync%2Cstring" title="openAsync(filename: string; mode = fmRead): AsyncFile">openAsync(filename: string; mode = fmRead): AsyncFile</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">read
|
||||
<li><a class="reference" href="#read%2CAsyncFile%2Cint" title="read(f: AsyncFile; size: int): Future[string]">read(f: AsyncFile; size: int): Future[string]</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">readAll
|
||||
<li><a class="reference" href="#readAll%2CAsyncFile" title="readAll(f: AsyncFile): Future[string]">readAll(f: AsyncFile): Future[string]</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">readBuffer
|
||||
<li><a class="reference" href="#readBuffer%2CAsyncFile%2Cpointer%2Cint" title="readBuffer(f: AsyncFile; buf: pointer; size: int): Future[int]">readBuffer(f: AsyncFile; buf: pointer; size: int): Future[int]</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">readLine
|
||||
<li><a class="reference" href="#readLine%2CAsyncFile" title="readLine(f: AsyncFile): Future[string]">readLine(f: AsyncFile): Future[string]</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">readToStream
|
||||
<li><a class="reference" href="#readToStream%2CAsyncFile%2CFutureStream%5Bstring%5D" title="readToStream(f: AsyncFile; fs: FutureStream[string]): owned(Future[void])">readToStream(f: AsyncFile; fs: FutureStream[string]): owned(Future[void])</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">setFilePos
|
||||
<li><a class="reference" href="#setFilePos%2CAsyncFile%2Cint64" title="setFilePos(f: AsyncFile; pos: int64)">setFilePos(f: AsyncFile; pos: int64)</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">setFileSize
|
||||
<li><a class="reference" href="#setFileSize%2CAsyncFile%2Cint64" title="setFileSize(f: AsyncFile; length: int64)">setFileSize(f: AsyncFile; length: int64)</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">write
|
||||
<li><a class="reference" href="#write%2CAsyncFile%2Cstring" title="write(f: AsyncFile; data: string): Future[void]">write(f: AsyncFile; data: string): Future[void]</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">writeBuffer
|
||||
<li><a class="reference" href="#writeBuffer%2CAsyncFile%2Cpointer%2Cint" title="writeBuffer(f: AsyncFile; buf: pointer; size: int): Future[void]">writeBuffer(f: AsyncFile; buf: pointer; size: int): Future[void]</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">writeFromStream
|
||||
<li><a class="reference" href="#writeFromStream%2CAsyncFile%2CFutureStream%5Bstring%5D" title="writeFromStream(f: AsyncFile; fs: FutureStream[string]): owned(Future[void])">writeFromStream(f: AsyncFile; fs: FutureStream[string]): owned(Future[void])</a></li>
|
||||
|
||||
</ul>
|
||||
|
||||
</ul>
|
||||
</details>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
<div class="nine columns" id="content">
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncfile.nim#L1" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncfile.nim#L1" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
<div id="tocRoot"></div>
|
||||
|
||||
<p class="module-desc"><p>This module implements asynchronous file reading and writing.</p>
|
||||
<p><pre class="listing">
|
||||
<span class="Keyword">import</span> <span class="Identifier">std</span><span class="Operator">/</span><span class="Punctuation">[</span><span class="Identifier">asyncfile</span><span class="Punctuation">,</span> <span class="Identifier">asyncdispatch</span><span class="Punctuation">,</span> <span class="Identifier">os</span><span class="Punctuation">]</span>
|
||||
|
||||
<span class="Keyword">proc</span> <span class="Identifier">main</span><span class="Punctuation">(</span><span class="Punctuation">)</span> <span class="Punctuation">{</span><span class="Operator">.</span><span class="Identifier">async</span><span class="Operator">.</span><span class="Punctuation">}</span> <span class="Operator">=</span>
|
||||
<span class="Keyword">var</span> <span class="Identifier">file</span> <span class="Operator">=</span> <span class="Identifier">openAsync</span><span class="Punctuation">(</span><span class="Identifier">getTempDir</span><span class="Punctuation">(</span><span class="Punctuation">)</span> <span class="Operator">/</span> <span class="StringLit">"foobar.txt"</span><span class="Punctuation">,</span> <span class="Identifier">fmReadWrite</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">await</span> <span class="Identifier">file</span><span class="Operator">.</span><span class="Identifier">write</span><span class="Punctuation">(</span><span class="StringLit">"test"</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">file</span><span class="Operator">.</span><span class="Identifier">setFilePos</span><span class="Punctuation">(</span><span class="DecNumber">0</span><span class="Punctuation">)</span>
|
||||
<span class="Keyword">let</span> <span class="Identifier">data</span> <span class="Operator">=</span> <span class="Identifier">await</span> <span class="Identifier">file</span><span class="Operator">.</span><span class="Identifier">readAll</span><span class="Punctuation">(</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">doAssert</span> <span class="Identifier">data</span> <span class="Operator">==</span> <span class="StringLit">"test"</span>
|
||||
<span class="Identifier">file</span><span class="Operator">.</span><span class="Identifier">close</span><span class="Punctuation">(</span><span class="Punctuation">)</span>
|
||||
|
||||
<span class="Identifier">waitFor</span> <span class="Identifier">main</span><span class="Punctuation">(</span><span class="Punctuation">)</span></pre></p>
|
||||
</p>
|
||||
<div class="section" id="6">
|
||||
<h1><a class="toc-backref" href="#6">Imports</a></h1>
|
||||
<dl class="item">
|
||||
<a class="reference external" href="asyncdispatch.html">asyncdispatch</a>, <a class="reference external" href="os.html">os</a>, <a class="reference external" href="assertions.html">assertions</a>, <a class="reference external" href="syncio.html">syncio</a>, <a class="reference external" href="widestrs.html">widestrs</a>, <a class="reference external" href="winlean.html">winlean</a>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="section" id="7">
|
||||
<h1><a class="toc-backref" href="#7">Types</a></h1>
|
||||
<dl class="item">
|
||||
<div id="AsyncFile">
|
||||
<dt><pre><a href="asyncfile.html#AsyncFile"><span class="Identifier">AsyncFile</span></a> <span class="Other">=</span> <span class="Keyword">ref</span> <span class="Keyword">object</span>
|
||||
</pre></dt>
|
||||
<dd>
|
||||
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncfile.nim#L41" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncfile.nim#L41" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</dl>
|
||||
</div>
|
||||
<div class="section" id="12">
|
||||
<h1><a class="toc-backref" href="#12">Procs</a></h1>
|
||||
<dl class="item">
|
||||
<div id="close-procs-all">
|
||||
<div id="close,AsyncFile">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#close%2CAsyncFile"><span class="Identifier">close</span></a><span class="Other">(</span><span class="Identifier">f</span><span class="Other">:</span> <a href="asyncfile.html#AsyncFile"><span class="Identifier">AsyncFile</span></a><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">OSError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Closes the file specified.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncfile.nim#L503" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncfile.nim#L503" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="getFilePos-procs-all">
|
||||
<div id="getFilePos,AsyncFile">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#getFilePos%2CAsyncFile"><span class="Identifier">getFilePos</span></a><span class="Other">(</span><span class="Identifier">f</span><span class="Other">:</span> <a href="asyncfile.html#AsyncFile"><span class="Identifier">AsyncFile</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#int64"><span class="Identifier">int64</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Retrieves the current position of the file pointer that is used to read from the specified file. The file's first byte has the index zero.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncfile.nim#L312" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncfile.nim#L312" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="getFileSize-procs-all">
|
||||
<div id="getFileSize,AsyncFile">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#getFileSize%2CAsyncFile"><span class="Identifier">getFileSize</span></a><span class="Other">(</span><span class="Identifier">f</span><span class="Other">:</span> <a href="asyncfile.html#AsyncFile"><span class="Identifier">AsyncFile</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#int64"><span class="Identifier">int64</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">OSError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Retrieves the specified file's size.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncfile.nim#L78" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncfile.nim#L78" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="newAsyncFile-procs-all">
|
||||
<div id="newAsyncFile,AsyncFD">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#newAsyncFile%2CAsyncFD"><span class="Identifier">newAsyncFile</span></a><span class="Other">(</span><span class="Identifier">fd</span><span class="Other">:</span> <a href="asyncdispatch.html#AsyncFD"><span class="Identifier">AsyncFD</span></a><span class="Other">)</span><span class="Other">:</span> <a href="asyncfile.html#AsyncFile"><span class="Identifier">AsyncFile</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">OSError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
|
||||
<span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Creates <tt class="docutils literal"><span class="pre"><span class="Identifier">AsyncFile</span></span></tt> with a previously opened file descriptor <tt class="docutils literal"><span class="pre"><span class="Identifier">fd</span></span></tt>.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncfile.nim#L92" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncfile.nim#L92" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="openAsync-procs-all">
|
||||
<div id="openAsync,string">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#openAsync%2Cstring"><span class="Identifier">openAsync</span></a><span class="Other">(</span><span class="Identifier">filename</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">mode</span> <span class="Other">=</span> <span class="Identifier">fmRead</span><span class="Other">)</span><span class="Other">:</span> <a href="asyncfile.html#AsyncFile"><span class="Identifier">AsyncFile</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">OSError</span><span class="Other">]</span><span class="Other">,</span>
|
||||
<span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Opens a file specified by the path in <tt class="docutils literal"><span class="pre"><span class="Identifier">filename</span></span></tt> using the specified FileMode <tt class="docutils literal"><span class="pre"><span class="Identifier">mode</span></span></tt> asynchronously.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncfile.nim#L98" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncfile.nim#L98" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="read-procs-all">
|
||||
<div id="read,AsyncFile,int">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#read%2CAsyncFile%2Cint"><span class="Identifier">read</span></a><span class="Other">(</span><span class="Identifier">f</span><span class="Other">:</span> <a href="asyncfile.html#AsyncFile"><span class="Identifier">AsyncFile</span></a><span class="Other">;</span> <span class="Identifier">size</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a><span class="Other">)</span><span class="Other">:</span> <a href="asyncfutures.html#Future"><span class="Identifier">Future</span></a><span class="Other">[</span><a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">]</span> {.
|
||||
<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ValueError</span><span class="Other">,</span> <span class="Identifier">Exception</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">RootEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Read <tt class="docutils literal"><span class="pre"><span class="Identifier">size</span></span></tt> bytes from the specified file asynchronously starting at the current position of the file pointer. <tt class="docutils literal"><span class="pre"><span class="Identifier">size</span></span></tt> should be greater than zero.</p>
|
||||
<p>If the file pointer is past the end of the file then an empty string is returned.</p>
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncfile.nim#L204" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncfile.nim#L204" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="readAll-procs-all">
|
||||
<div id="readAll,AsyncFile">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#readAll%2CAsyncFile"><span class="Identifier">readAll</span></a><span class="Other">(</span><span class="Identifier">f</span><span class="Other">:</span> <a href="asyncfile.html#AsyncFile"><span class="Identifier">AsyncFile</span></a><span class="Other">)</span><span class="Other">:</span> <a href="asyncfutures.html#Future"><span class="Identifier">Future</span></a><span class="Other">[</span><a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">]</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">stackTrace</span><span class="Other">:</span> <span class="DecNumber">false</span><span class="Other">,</span>
|
||||
<span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">Exception</span><span class="Other">,</span> <span class="Identifier">ValueError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">RootEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Reads all data from the specified file.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncfile.nim#L327" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncfile.nim#L327" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="readBuffer-procs-all">
|
||||
<div id="readBuffer,AsyncFile,pointer,int">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#readBuffer%2CAsyncFile%2Cpointer%2Cint"><span class="Identifier">readBuffer</span></a><span class="Other">(</span><span class="Identifier">f</span><span class="Other">:</span> <a href="asyncfile.html#AsyncFile"><span class="Identifier">AsyncFile</span></a><span class="Other">;</span> <span class="Identifier">buf</span><span class="Other">:</span> <a href="system.html#pointer"><span class="Identifier">pointer</span></a><span class="Other">;</span> <span class="Identifier">size</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a><span class="Other">)</span><span class="Other">:</span> <a href="asyncfutures.html#Future"><span class="Identifier">Future</span></a><span class="Other">[</span><a href="system.html#int"><span class="Identifier">int</span></a><span class="Other">]</span> {.
|
||||
<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ValueError</span><span class="Other">,</span> <span class="Identifier">Exception</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">RootEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Read <tt class="docutils literal"><span class="pre"><span class="Identifier">size</span></span></tt> bytes from the specified file asynchronously starting at the current position of the file pointer.</p>
|
||||
<p>If the file pointer is past the end of the file then zero is returned and no bytes are read into <tt class="docutils literal"><span class="pre"><span class="Identifier">buf</span></span></tt></p>
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncfile.nim#L127" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncfile.nim#L127" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="readLine-procs-all">
|
||||
<div id="readLine,AsyncFile">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#readLine%2CAsyncFile"><span class="Identifier">readLine</span></a><span class="Other">(</span><span class="Identifier">f</span><span class="Other">:</span> <a href="asyncfile.html#AsyncFile"><span class="Identifier">AsyncFile</span></a><span class="Other">)</span><span class="Other">:</span> <a href="asyncfutures.html#Future"><span class="Identifier">Future</span></a><span class="Other">[</span><a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">]</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">stackTrace</span><span class="Other">:</span> <span class="DecNumber">false</span><span class="Other">,</span>
|
||||
<span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">Exception</span><span class="Other">,</span> <span class="Identifier">ValueError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">RootEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Reads a single line from the specified file asynchronously.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncfile.nim#L299" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncfile.nim#L299" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="readToStream-procs-all">
|
||||
<div id="readToStream,AsyncFile,FutureStream[string]">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#readToStream%2CAsyncFile%2CFutureStream%5Bstring%5D"><span class="Identifier">readToStream</span></a><span class="Other">(</span><span class="Identifier">f</span><span class="Other">:</span> <a href="asyncfile.html#AsyncFile"><span class="Identifier">AsyncFile</span></a><span class="Other">;</span> <span class="Identifier">fs</span><span class="Other">:</span> <a href="asyncstreams.html#FutureStream"><span class="Identifier">FutureStream</span></a><span class="Other">[</span><a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#owned"><span class="Identifier">owned</span></a><span class="Other">(</span>
|
||||
<a href="asyncfutures.html#Future"><span class="Identifier">Future</span></a><span class="Other">[</span><a href="system.html#void"><span class="Identifier">void</span></a><span class="Other">]</span><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">stackTrace</span><span class="Other">:</span> <span class="DecNumber">false</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">Exception</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">RootEffect</span><span class="Other">]</span><span class="Other">,</span>
|
||||
<span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Writes data to the specified future stream as the file is read.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncfile.nim#L527" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncfile.nim#L527" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="setFilePos-procs-all">
|
||||
<div id="setFilePos,AsyncFile,int64">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#setFilePos%2CAsyncFile%2Cint64"><span class="Identifier">setFilePos</span></a><span class="Other">(</span><span class="Identifier">f</span><span class="Other">:</span> <a href="asyncfile.html#AsyncFile"><span class="Identifier">AsyncFile</span></a><span class="Other">;</span> <span class="Identifier">pos</span><span class="Other">:</span> <a href="system.html#int64"><span class="Identifier">int64</span></a><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Sets the position of the file pointer that is used for read/write operations. The file's first byte has the index zero.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncfile.nim#L318" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncfile.nim#L318" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="setFileSize-procs-all">
|
||||
<div id="setFileSize,AsyncFile,int64">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#setFileSize%2CAsyncFile%2Cint64"><span class="Identifier">setFileSize</span></a><span class="Other">(</span><span class="Identifier">f</span><span class="Other">:</span> <a href="asyncfile.html#AsyncFile"><span class="Identifier">AsyncFile</span></a><span class="Other">;</span> <span class="Identifier">length</span><span class="Other">:</span> <a href="system.html#int64"><span class="Identifier">int64</span></a><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">OSError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
|
||||
<span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Set a file length.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncfile.nim#L486" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncfile.nim#L486" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="write-procs-all">
|
||||
<div id="write,AsyncFile,string">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#write%2CAsyncFile%2Cstring"><span class="Identifier">write</span></a><span class="Other">(</span><span class="Identifier">f</span><span class="Other">:</span> <a href="asyncfile.html#AsyncFile"><span class="Identifier">AsyncFile</span></a><span class="Other">;</span> <span class="Identifier">data</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">)</span><span class="Other">:</span> <a href="asyncfutures.html#Future"><span class="Identifier">Future</span></a><span class="Other">[</span><a href="system.html#void"><span class="Identifier">void</span></a><span class="Other">]</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">Exception</span><span class="Other">]</span><span class="Other">,</span>
|
||||
<span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">RootEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Writes <tt class="docutils literal"><span class="pre"><span class="Identifier">data</span></span></tt> to the file specified asynchronously.</p>
|
||||
<p>The returned Future will complete once all data has been written to the specified file.</p>
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncfile.nim#L405" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncfile.nim#L405" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="writeBuffer-procs-all">
|
||||
<div id="writeBuffer,AsyncFile,pointer,int">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#writeBuffer%2CAsyncFile%2Cpointer%2Cint"><span class="Identifier">writeBuffer</span></a><span class="Other">(</span><span class="Identifier">f</span><span class="Other">:</span> <a href="asyncfile.html#AsyncFile"><span class="Identifier">AsyncFile</span></a><span class="Other">;</span> <span class="Identifier">buf</span><span class="Other">:</span> <a href="system.html#pointer"><span class="Identifier">pointer</span></a><span class="Other">;</span> <span class="Identifier">size</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a><span class="Other">)</span><span class="Other">:</span> <a href="asyncfutures.html#Future"><span class="Identifier">Future</span></a><span class="Other">[</span><a href="system.html#void"><span class="Identifier">void</span></a><span class="Other">]</span> {.
|
||||
<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">Exception</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">RootEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Writes <tt class="docutils literal"><span class="pre"><span class="Identifier">size</span></span></tt> bytes from <tt class="docutils literal"><span class="pre"><span class="Identifier">buf</span></span></tt> to the file specified asynchronously.</p>
|
||||
<p>The returned Future will complete once all data has been written to the specified file.</p>
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncfile.nim#L336" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncfile.nim#L336" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="writeFromStream-procs-all">
|
||||
<div id="writeFromStream,AsyncFile,FutureStream[string]">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#writeFromStream%2CAsyncFile%2CFutureStream%5Bstring%5D"><span class="Identifier">writeFromStream</span></a><span class="Other">(</span><span class="Identifier">f</span><span class="Other">:</span> <a href="asyncfile.html#AsyncFile"><span class="Identifier">AsyncFile</span></a><span class="Other">;</span> <span class="Identifier">fs</span><span class="Other">:</span> <a href="asyncstreams.html#FutureStream"><span class="Identifier">FutureStream</span></a><span class="Other">[</span><a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#owned"><span class="Identifier">owned</span></a><span class="Other">(</span>
|
||||
<a href="asyncfutures.html#Future"><span class="Identifier">Future</span></a><span class="Other">[</span><a href="system.html#void"><span class="Identifier">void</span></a><span class="Other">]</span><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">stackTrace</span><span class="Other">:</span> <span class="DecNumber">false</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">Exception</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">RootEffect</span><span class="Other">]</span><span class="Other">,</span>
|
||||
<span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Reads data from the specified future stream until it is completed. The data which is read is written to the file immediately and freed from memory.</p>
|
||||
<p>This procedure is perfect for saving streamed data to a file without wasting memory.</p>
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncfile.nim#L513" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncfile.nim#L513" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="twelve-columns footer">
|
||||
<span class="nim-sprite"></span>
|
||||
<br>
|
||||
<small style="color: var(--hint);">Made with Nim. Generated: 2023-03-13 00:19:43 UTC</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script defer data-domain="nim-lang.org" src="https://plausible.io/js/plausible.js"></script>
|
||||
|
||||
<!-- Google fonts -->
|
||||
<link href='https://fonts.googleapis.com/css?family=Lato:400,600,900' rel='stylesheet' type='text/css'/>
|
||||
<link href='https://fonts.googleapis.com/css?family=Source+Code+Pro:400,500,600' rel='stylesheet' type='text/css'/>
|
||||
</body>
|
||||
</html>
|
||||
17
asyncfile.idx
Normal file
17
asyncfile.idx
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
nimTitle asyncfile asyncfile.html module std/asyncfile 0
|
||||
nim AsyncFile asyncfile.html#AsyncFile type AsyncFile 41
|
||||
nim getFileSize asyncfile.html#getFileSize,AsyncFile proc getFileSize(f: AsyncFile): int64 78
|
||||
nim newAsyncFile asyncfile.html#newAsyncFile,AsyncFD proc newAsyncFile(fd: AsyncFD): AsyncFile 92
|
||||
nim openAsync asyncfile.html#openAsync,string proc openAsync(filename: string; mode = fmRead): AsyncFile 98
|
||||
nim readBuffer asyncfile.html#readBuffer,AsyncFile,pointer,int proc readBuffer(f: AsyncFile; buf: pointer; size: int): Future[int] 127
|
||||
nim read asyncfile.html#read,AsyncFile,int proc read(f: AsyncFile; size: int): Future[string] 204
|
||||
nim readLine asyncfile.html#readLine,AsyncFile proc readLine(f: AsyncFile): Future[string] 299
|
||||
nim getFilePos asyncfile.html#getFilePos,AsyncFile proc getFilePos(f: AsyncFile): int64 312
|
||||
nim setFilePos asyncfile.html#setFilePos,AsyncFile,int64 proc setFilePos(f: AsyncFile; pos: int64) 318
|
||||
nim readAll asyncfile.html#readAll,AsyncFile proc readAll(f: AsyncFile): Future[string] 327
|
||||
nim writeBuffer asyncfile.html#writeBuffer,AsyncFile,pointer,int proc writeBuffer(f: AsyncFile; buf: pointer; size: int): Future[void] 336
|
||||
nim write asyncfile.html#write,AsyncFile,string proc write(f: AsyncFile; data: string): Future[void] 405
|
||||
nim setFileSize asyncfile.html#setFileSize,AsyncFile,int64 proc setFileSize(f: AsyncFile; length: int64) 486
|
||||
nim close asyncfile.html#close,AsyncFile proc close(f: AsyncFile) 503
|
||||
nim writeFromStream asyncfile.html#writeFromStream,AsyncFile,FutureStream[string] proc writeFromStream(f: AsyncFile; fs: FutureStream[string]): owned(Future[void]) 513
|
||||
nim readToStream asyncfile.html#readToStream,AsyncFile,FutureStream[string] proc readToStream(f: AsyncFile; fs: FutureStream[string]): owned(Future[void]) 527
|
||||
560
asyncftpclient.html
Normal file
560
asyncftpclient.html
Normal file
|
|
@ -0,0 +1,560 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<!-- This file is generated by Nim. -->
|
||||
<html xmlns="https://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>src/asyncftpclient</title>
|
||||
|
||||
<!-- Favicon -->
|
||||
<link rel="shortcut icon" href="data:image/x-icon;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAUAAAAF////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAIAAABbAAAAlQAAAKIAAACbAAAAmwAAAKIAAACVAAAAWwAAAAL///8A////AP///wD///8A////AAAAABQAAADAAAAAYwAAAA3///8A////AP///wD///8AAAAADQAAAGMAAADAAAAAFP///wD///8A////AP///wAAAACdAAAAOv///wD///8A////AP///wD///8A////AP///wD///8AAAAAOgAAAJ3///8A////AP///wAAAAAnAAAAcP///wAAAAAoAAAASv///wD///8A////AP///wAAAABKAAAAKP///wAAAABwAAAAJ////wD///8AAAAAgQAAABwAAACIAAAAkAAAAJMAAACtAAAAFQAAABUAAACtAAAAkwAAAJAAAACIAAAAHAAAAIH///8A////AAAAAKQAAACrAAAAaP///wD///8AAAAARQAAANIAAADSAAAARf///wD///8AAAAAaAAAAKsAAACk////AAAAADMAAACcAAAAnQAAABj///8A////AP///wAAAAAYAAAAGP///wD///8A////AAAAABgAAACdAAAAnAAAADMAAAB1AAAAwwAAAP8AAADpAAAAsQAAAE4AAAAb////AP///wAAAAAbAAAATgAAALEAAADpAAAA/wAAAMMAAAB1AAAAtwAAAOkAAAD/AAAA/wAAAP8AAADvAAAA3gAAAN4AAADeAAAA3gAAAO8AAAD/AAAA/wAAAP8AAADpAAAAtwAAAGUAAAA/AAAA3wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAADfAAAAPwAAAGX///8A////AAAAAEgAAADtAAAAvwAAAL0AAADGAAAA7wAAAO8AAADGAAAAvQAAAL8AAADtAAAASP///wD///8A////AP///wD///8AAAAAO////wD///8A////AAAAAIcAAACH////AP///wD///8AAAAAO////wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A//8AAP//AAD4HwAA7/cAAN/7AAD//wAAoYUAAJ55AACf+QAAh+EAAAAAAADAAwAA4AcAAP5/AAD//wAA//8AAA=="/>
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAA3XAAAN1wFCKJt4AAAAB3RJTUUH4QQQEwksSS9ZWwAAAk1JREFUWMPtll2ITVEUx39nn/O7Y5qR8f05wtCUUr6ZIS++8pEnkZInPImneaCQ5METNdOkeFBKUhMPRIkHKfEuUZSUlGlKPN2TrgfncpvmnntnmlEyq1Z7t89/rf9a6+y99oZxGZf/XeIq61EdtgKXgdXA0xrYAvBjOIF1AI9zvjcC74BSpndrJPkBWDScTF8Aa4E3wDlgHbASaANmVqlcCnwHvgDvgVfAJ+AikAAvgfVZwLnSVZHZaOuKoQi3ZOMi4NkYkpe1p4J7A8BpYAD49hfIy/oqG0+hLomiKP2L5L+1ubn5115S+3OAn4EnwBlgMzCjyt6ZAnQCJ4A7wOs88iRJHvw50HoujuPBoCKwHWiosy8MdfZnAdcHk8dxXFJ3VQbQlCTJvRBCGdRbD4M6uc5glpY3eAihpN5S5w12diSEcCCEcKUO4ljdr15T76ur1FDDLIQQ3qv71EdDOe3Kxj3leRXyk+pxdWnFWod6Wt2bY3de3aSuUHcPBVimHs7mK9WrmeOF6lR1o9qnzskh2ar2qm1qizpfXaPeVGdlmGN5pb09qMxz1Xb1kLqgzn1RyH7JUXW52lr5e/Kqi9qpto7V1atuUzfnARrV7jEib1T76gG2qxdGmXyiekkt1GswPTtek0aBfJp6YySGBfWg2tPQ0FAYgf1stUfdmdcjarbYJEniKIq6gY/Aw+zWHAC+p2labGpqiorFYgGYCEzN7oQdQClN07O1/EfDyGgC0ALMBdYAi4FyK+4H3gLPsxfR1zRNi+NP7nH5J+QntnXe5B5mpfQAAAAASUVORK5CYII=">
|
||||
|
||||
<!-- CSS -->
|
||||
<link rel="stylesheet" type="text/css" href="nimdoc.out.css">
|
||||
|
||||
<!-- JS -->
|
||||
<script type="text/javascript" src="dochack.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="document" id="documentId">
|
||||
<div class="container">
|
||||
<h1 class="title">src/asyncftpclient</h1>
|
||||
<div class="row">
|
||||
<div class="three columns">
|
||||
<div class="theme-select-wrapper">
|
||||
<label for="theme-select">Theme: </label>
|
||||
<select id="theme-select" onchange="setTheme(this.value)">
|
||||
<option value="auto">🌗 Match OS</option>
|
||||
<option value="dark">🌑 Dark</option>
|
||||
<option value="light">🌕 Light</option>
|
||||
</select>
|
||||
</div>
|
||||
<div id="global-links">
|
||||
<ul class="simple-boot">
|
||||
<li><a href="manual.html">Manual</a></li>
|
||||
<li><a href="lib.html">Standard library</a></li>
|
||||
<li> <a id="indexLink" href="theindex.html">Index</a></li>
|
||||
<li><a href="compiler/theindex.html">Compiler docs</a></li>
|
||||
<li><a href="https://nim-lang.github.io/fusion/theindex.html">Fusion docs</a></li>
|
||||
<li><a href="https://nim-lang.github.io/Nim/">devel</a>, <a href="https://nim-lang.org/documentation.html">stable</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="searchInputDiv">
|
||||
Search: <input type="search" id="searchInput"
|
||||
onkeyup="search()" />
|
||||
</div>
|
||||
|
||||
<ul class="simple simple-toc" id="toc-list">
|
||||
<li><a class="reference" id="connecting-to-an-ftp-server_toc" href="#connecting-to-an-ftp-server">Connecting to an FTP server</a></li>
|
||||
<li><a class="reference" id="uploading-a-new-file_toc" href="#uploading-a-new-file">Uploading a new file</a></li>
|
||||
<li><a class="reference" id="checking-the-progress-of-a-file-transfer_toc" href="#checking-the-progress-of-a-file-transfer">Checking the progress of a file transfer</a></li>
|
||||
<li>
|
||||
<details open>
|
||||
<summary><a class="reference reference-toplevel" href="#7" id="57">Types</a></summary>
|
||||
<ul class="simple simple-toc-section">
|
||||
<li><a class="reference" href="#AsyncFtpClient" title="AsyncFtpClient = ref object
|
||||
csock*: AsyncSocket
|
||||
dsock*: AsyncSocket
|
||||
user*, pass*: string
|
||||
address*: string
|
||||
port*: Port
|
||||
jobInProgress*: bool
|
||||
job*: FtpJob
|
||||
dsockConnected*: bool">AsyncFtpClient</a></li>
|
||||
<li><a class="reference" href="#FtpEvent" title="FtpEvent = object
|
||||
filename*: string">FtpEvent</a></li>
|
||||
<li><a class="reference" href="#FtpEventType" title="FtpEventType = enum
|
||||
EvTransferProgress, EvLines, EvRetr, EvStore">FtpEventType</a></li>
|
||||
<li><a class="reference" href="#FtpJobType" title="FtpJobType = enum
|
||||
JRetrText, JRetr, JStore">FtpJobType</a></li>
|
||||
<li><a class="reference" href="#ProgressChangedProc" title="ProgressChangedProc = proc (total, progress: BiggestInt; speed: float): Future[
|
||||
void] {.closure, gcsafe.}">ProgressChangedProc</a></li>
|
||||
<li><a class="reference" href="#ReplyError" title="ReplyError = object of IOError">ReplyError</a></li>
|
||||
|
||||
</ul>
|
||||
</details>
|
||||
</li>
|
||||
<li>
|
||||
<details open>
|
||||
<summary><a class="reference reference-toplevel" href="#12" id="62">Procs</a></summary>
|
||||
<ul class="simple simple-toc-section">
|
||||
<ul class="simple nested-toc-section">cd
|
||||
<li><a class="reference" href="#cd%2CAsyncFtpClient%2Cstring" title="cd(ftp: AsyncFtpClient; dir: string): owned(Future[void])">cd(ftp: AsyncFtpClient; dir: string): owned(Future[void])</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">cdup
|
||||
<li><a class="reference" href="#cdup%2CAsyncFtpClient" title="cdup(ftp: AsyncFtpClient): owned(Future[void])">cdup(ftp: AsyncFtpClient): owned(Future[void])</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">chmod
|
||||
<li><a class="reference" href="#chmod%2CAsyncFtpClient%2Cstring%2Cset%5BFilePermission%5D" title="chmod(ftp: AsyncFtpClient; path: string; permissions: set[FilePermission]): owned(
|
||||
Future[void])">chmod(ftp: AsyncFtpClient; path: string; permissions: set[FilePermission]): owned(
|
||||
Future[void])</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">connect
|
||||
<li><a class="reference" href="#connect%2CAsyncFtpClient" title="connect(ftp: AsyncFtpClient): owned(Future[void])">connect(ftp: AsyncFtpClient): owned(Future[void])</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">createDir
|
||||
<li><a class="reference" href="#createDir%2CAsyncFtpClient%2Cstring" title="createDir(ftp: AsyncFtpClient; dir: string; recursive = false): owned(
|
||||
Future[void])">createDir(ftp: AsyncFtpClient; dir: string; recursive = false): owned(
|
||||
Future[void])</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">defaultOnProgressChanged
|
||||
<li><a class="reference" href="#defaultOnProgressChanged%2CBiggestInt%2CBiggestInt%2Cfloat" title="defaultOnProgressChanged(total, progress: BiggestInt; speed: float): Future[void]">defaultOnProgressChanged(total, progress: BiggestInt; speed: float): Future[void]</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">fileExists
|
||||
<li><a class="reference" href="#fileExists%2CAsyncFtpClient%2Cstring" title="fileExists(ftp: AsyncFtpClient; file: string): Future[bool]">fileExists(ftp: AsyncFtpClient; file: string): Future[bool]</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">list
|
||||
<li><a class="reference" href="#list%2CAsyncFtpClient%2Cstring" title="list(ftp: AsyncFtpClient; dir = ""): Future[string]">list(ftp: AsyncFtpClient; dir = ""): Future[string]</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">listDirs
|
||||
<li><a class="reference" href="#listDirs%2CAsyncFtpClient%2Cstring" title="listDirs(ftp: AsyncFtpClient; dir = ""): Future[seq[string]]">listDirs(ftp: AsyncFtpClient; dir = ""): Future[seq[string]]</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">newAsyncFtpClient
|
||||
<li><a class="reference" href="#newAsyncFtpClient%2Cstring%2Cstring%2Cstring%2Cint%2CSslContext" title="newAsyncFtpClient(address: string; port = Port(21); user, pass = "";
|
||||
progressInterval: int = 1000; useTls = false;
|
||||
sslContext: SslContext = nil): AsyncFtpClient">newAsyncFtpClient(address: string; port = Port(21); user, pass = "";
|
||||
progressInterval: int = 1000; useTls = false;
|
||||
sslContext: SslContext = nil): AsyncFtpClient</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">pwd
|
||||
<li><a class="reference" href="#pwd%2CAsyncFtpClient" title="pwd(ftp: AsyncFtpClient): Future[string]">pwd(ftp: AsyncFtpClient): Future[string]</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">removeDir
|
||||
<li><a class="reference" href="#removeDir%2CAsyncFtpClient%2Cstring" title="removeDir(ftp: AsyncFtpClient; dir: string): owned(Future[void])">removeDir(ftp: AsyncFtpClient; dir: string): owned(Future[void])</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">removeFile
|
||||
<li><a class="reference" href="#removeFile%2CAsyncFtpClient%2Cstring" title="removeFile(ftp: AsyncFtpClient; filename: string): owned(Future[void])">removeFile(ftp: AsyncFtpClient; filename: string): owned(Future[void])</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">rename
|
||||
<li><a class="reference" href="#rename%2CAsyncFtpClient%2Cstring%2Cstring" title="rename(ftp: AsyncFtpClient; nameFrom: string; nameTo: string): owned(
|
||||
Future[void])">rename(ftp: AsyncFtpClient; nameFrom: string; nameTo: string): owned(
|
||||
Future[void])</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">retrFile
|
||||
<li><a class="reference" href="#retrFile%2CAsyncFtpClient%2Cstring%2Cstring%2CProgressChangedProc" title="retrFile(ftp: AsyncFtpClient; file, dest: string;
|
||||
onProgressChanged: ProgressChangedProc = defaultOnProgressChanged): owned(
|
||||
Future[void])">retrFile(ftp: AsyncFtpClient; file, dest: string;
|
||||
onProgressChanged: ProgressChangedProc = defaultOnProgressChanged): owned(
|
||||
Future[void])</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">retrText
|
||||
<li><a class="reference" href="#retrText%2CAsyncFtpClient%2Cstring" title="retrText(ftp: AsyncFtpClient; file: string): Future[string]">retrText(ftp: AsyncFtpClient; file: string): Future[string]</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">send
|
||||
<li><a class="reference" href="#send%2CAsyncFtpClient%2Cstring" title="send(ftp: AsyncFtpClient; m: string): Future[string]">send(ftp: AsyncFtpClient; m: string): Future[string]</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">store
|
||||
<li><a class="reference" href="#store%2CAsyncFtpClient%2Cstring%2Cstring%2CProgressChangedProc" title="store(ftp: AsyncFtpClient; file, dest: string;
|
||||
onProgressChanged: ProgressChangedProc = defaultOnProgressChanged): owned(
|
||||
Future[void])">store(ftp: AsyncFtpClient; file, dest: string;
|
||||
onProgressChanged: ProgressChangedProc = defaultOnProgressChanged): owned(
|
||||
Future[void])</a></li>
|
||||
|
||||
</ul>
|
||||
|
||||
</ul>
|
||||
</details>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
<div class="nine columns" id="content">
|
||||
|
||||
<div id="tocRoot"></div>
|
||||
|
||||
<p class="module-desc"><div class="admonition admonition-info"><span class="admonition-info-text"><b>Note:</b></span>
|
||||
In order to use this module, run <tt class="docutils literal"><span class="pre"><span class="Identifier">nimble</span> <span class="Identifier">install</span> <span class="Identifier">asyncftpclient</span></span></tt>.</div>
|
||||
<p>This module implements an asynchronous FTP client. It allows you to connect to an FTP server and perform operations on it such as for example:</p>
|
||||
<ul class="simple"><li>The upload of new files.</li>
|
||||
<li>The removal of existing files.</li>
|
||||
<li>Download of files.</li>
|
||||
<li>Changing of files' permissions.</li>
|
||||
<li>Navigation through the FTP server's directories.</li>
|
||||
</ul>
|
||||
|
||||
<h1><a class="toc-backref" id="connecting-to-an-ftp-server" href="#connecting-to-an-ftp-server">Connecting to an FTP server</a></h1><p>In order to begin any sort of transfer of files you must first connect to an FTP server. You can do so with the <tt class="docutils literal"><span class="pre"><span class="Identifier">connect</span></span></tt> procedure.</p>
|
||||
<p><pre class="listing">
|
||||
<span class="Keyword">import</span> <span class="Identifier">std</span><span class="Operator">/</span><span class="Identifier">asyncdispatch</span>
|
||||
<span class="Keyword">import</span> <span class="Identifier">pkg</span><span class="Operator">/</span><span class="Identifier">asyncftpclient</span>
|
||||
<span class="Keyword">proc</span> <span class="Identifier">main</span><span class="Punctuation">(</span><span class="Punctuation">)</span> <span class="Punctuation">{</span><span class="Operator">.</span><span class="Identifier">async</span><span class="Operator">.</span><span class="Punctuation">}</span> <span class="Operator">=</span>
|
||||
<span class="Keyword">var</span> <span class="Identifier">ftp</span> <span class="Operator">=</span> <span class="Identifier">newAsyncFtpClient</span><span class="Punctuation">(</span><span class="StringLit">"example.com"</span><span class="Punctuation">,</span> <span class="Identifier">user</span> <span class="Operator">=</span> <span class="StringLit">"test"</span><span class="Punctuation">,</span> <span class="Identifier">pass</span> <span class="Operator">=</span> <span class="StringLit">"test"</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">await</span> <span class="Identifier">ftp</span><span class="Operator">.</span><span class="Identifier">connect</span><span class="Punctuation">(</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">echo</span><span class="Punctuation">(</span><span class="StringLit">"Connected"</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">waitFor</span><span class="Punctuation">(</span><span class="Identifier">main</span><span class="Punctuation">(</span><span class="Punctuation">)</span><span class="Punctuation">)</span></pre></p>
|
||||
<p>A new <tt class="docutils literal"><span class="pre"><span class="Identifier">main</span></span></tt> async procedure must be declared to allow the use of the <tt class="docutils literal"><span class="pre"><span class="Identifier">await</span></span></tt> keyword. The connection will complete asynchronously and the client will be connected after the <tt class="docutils literal"><span class="pre"><span class="Identifier">await</span> <span class="Identifier">ftp</span><span class="Operator">.</span><span class="Identifier">connect</span><span class="Punctuation">(</span><span class="Punctuation">)</span></span></tt> call.</p>
|
||||
|
||||
<h1><a class="toc-backref" id="uploading-a-new-file" href="#uploading-a-new-file">Uploading a new file</a></h1><p>After a connection is made you can use the <tt class="docutils literal"><span class="pre"><span class="Identifier">store</span></span></tt> procedure to upload a new file to the FTP server. Make sure to check you are in the correct working directory before you do so with the <tt class="docutils literal"><span class="pre"><span class="Identifier">pwd</span></span></tt> procedure, you can also instead specify an absolute path.</p>
|
||||
<p><pre class="listing">
|
||||
<span class="Keyword">import</span> <span class="Identifier">std</span><span class="Operator">/</span><span class="Identifier">asyncdispatch</span>
|
||||
<span class="Keyword">import</span> <span class="Identifier">pkg</span><span class="Operator">/</span><span class="Identifier">asyncftpclient</span>
|
||||
<span class="Keyword">proc</span> <span class="Identifier">main</span><span class="Punctuation">(</span><span class="Punctuation">)</span> <span class="Punctuation">{</span><span class="Operator">.</span><span class="Identifier">async</span><span class="Operator">.</span><span class="Punctuation">}</span> <span class="Operator">=</span>
|
||||
<span class="Keyword">var</span> <span class="Identifier">ftp</span> <span class="Operator">=</span> <span class="Identifier">newAsyncFtpClient</span><span class="Punctuation">(</span><span class="StringLit">"example.com"</span><span class="Punctuation">,</span> <span class="Identifier">user</span> <span class="Operator">=</span> <span class="StringLit">"test"</span><span class="Punctuation">,</span> <span class="Identifier">pass</span> <span class="Operator">=</span> <span class="StringLit">"test"</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">await</span> <span class="Identifier">ftp</span><span class="Operator">.</span><span class="Identifier">connect</span><span class="Punctuation">(</span><span class="Punctuation">)</span>
|
||||
<span class="Keyword">let</span> <span class="Identifier">currentDir</span> <span class="Operator">=</span> <span class="Identifier">await</span> <span class="Identifier">ftp</span><span class="Operator">.</span><span class="Identifier">pwd</span><span class="Punctuation">(</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">currentDir</span> <span class="Operator">==</span> <span class="StringLit">"/home/user/"</span>
|
||||
<span class="Identifier">await</span> <span class="Identifier">ftp</span><span class="Operator">.</span><span class="Identifier">store</span><span class="Punctuation">(</span><span class="StringLit">"file.txt"</span><span class="Punctuation">,</span> <span class="StringLit">"file.txt"</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">echo</span><span class="Punctuation">(</span><span class="StringLit">"File finished uploading"</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">waitFor</span><span class="Punctuation">(</span><span class="Identifier">main</span><span class="Punctuation">(</span><span class="Punctuation">)</span><span class="Punctuation">)</span></pre></p>
|
||||
|
||||
<h1><a class="toc-backref" id="checking-the-progress-of-a-file-transfer" href="#checking-the-progress-of-a-file-transfer">Checking the progress of a file transfer</a></h1><p>The progress of either a file upload or a file download can be checked by specifying a <tt class="docutils literal"><span class="pre"><span class="Identifier">onProgressChanged</span></span></tt> procedure to the <tt class="docutils literal"><span class="pre"><span class="Identifier">store</span></span></tt> or <tt class="docutils literal"><span class="pre"><span class="Identifier">retrFile</span></span></tt> procedures.</p>
|
||||
<p>Procs that take an <tt class="docutils literal"><span class="pre"><span class="Identifier">onProgressChanged</span></span></tt> callback will call this every <tt class="docutils literal"><span class="pre"><span class="Identifier">progressInterval</span></span></tt> milliseconds.</p>
|
||||
<p><pre class="listing">
|
||||
<span class="Keyword">import</span> <span class="Identifier">std</span><span class="Operator">/</span><span class="Identifier">asyncdispatch</span>
|
||||
<span class="Keyword">import</span> <span class="Identifier">pkg</span><span class="Operator">/</span><span class="Identifier">asyncftpclient</span>
|
||||
|
||||
<span class="Keyword">proc</span> <span class="Identifier">onProgressChanged</span><span class="Punctuation">(</span><span class="Identifier">total</span><span class="Punctuation">,</span> <span class="Identifier">progress</span><span class="Punctuation">:</span> <span class="Identifier">BiggestInt</span><span class="Punctuation">,</span>
|
||||
<span class="Identifier">speed</span><span class="Punctuation">:</span> <span class="Identifier">float</span><span class="Punctuation">)</span> <span class="Punctuation">{</span><span class="Operator">.</span><span class="Identifier">async</span><span class="Operator">.</span><span class="Punctuation">}</span> <span class="Operator">=</span>
|
||||
<span class="Identifier">echo</span><span class="Punctuation">(</span><span class="StringLit">"Uploaded "</span><span class="Punctuation">,</span> <span class="Identifier">progress</span><span class="Punctuation">,</span> <span class="StringLit">" of "</span><span class="Punctuation">,</span> <span class="Identifier">total</span><span class="Punctuation">,</span> <span class="StringLit">" bytes"</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">echo</span><span class="Punctuation">(</span><span class="StringLit">"Current speed: "</span><span class="Punctuation">,</span> <span class="Identifier">speed</span><span class="Punctuation">,</span> <span class="StringLit">" kb/s"</span><span class="Punctuation">)</span>
|
||||
|
||||
<span class="Keyword">proc</span> <span class="Identifier">main</span><span class="Punctuation">(</span><span class="Punctuation">)</span> <span class="Punctuation">{</span><span class="Operator">.</span><span class="Identifier">async</span><span class="Operator">.</span><span class="Punctuation">}</span> <span class="Operator">=</span>
|
||||
<span class="Keyword">var</span> <span class="Identifier">ftp</span> <span class="Operator">=</span> <span class="Identifier">newAsyncFtpClient</span><span class="Punctuation">(</span><span class="StringLit">"example.com"</span><span class="Punctuation">,</span> <span class="Identifier">user</span> <span class="Operator">=</span> <span class="StringLit">"test"</span><span class="Punctuation">,</span> <span class="Identifier">pass</span> <span class="Operator">=</span> <span class="StringLit">"test"</span><span class="Punctuation">,</span> <span class="Identifier">progressInterval</span> <span class="Operator">=</span> <span class="DecNumber">500</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">await</span> <span class="Identifier">ftp</span><span class="Operator">.</span><span class="Identifier">connect</span><span class="Punctuation">(</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">await</span> <span class="Identifier">ftp</span><span class="Operator">.</span><span class="Identifier">store</span><span class="Punctuation">(</span><span class="StringLit">"file.txt"</span><span class="Punctuation">,</span> <span class="StringLit">"/home/user/file.txt"</span><span class="Punctuation">,</span> <span class="Identifier">onProgressChanged</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">echo</span><span class="Punctuation">(</span><span class="StringLit">"File finished uploading"</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">waitFor</span><span class="Punctuation">(</span><span class="Identifier">main</span><span class="Punctuation">(</span><span class="Punctuation">)</span><span class="Punctuation">)</span></pre></p>
|
||||
</p>
|
||||
<div class="section" id="7">
|
||||
<h1><a class="toc-backref" href="#7">Types</a></h1>
|
||||
<dl class="item">
|
||||
<div id="AsyncFtpClient">
|
||||
<dt><pre><a href="asyncftpclient.html#AsyncFtpClient"><span class="Identifier">AsyncFtpClient</span></a> <span class="Other">=</span> <span class="Keyword">ref</span> <span class="Keyword">object</span>
|
||||
<span class="Identifier">csock</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">AsyncSocket</span>
|
||||
<span class="Identifier">dsock</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">AsyncSocket</span>
|
||||
<span class="Identifier">user</span><span class="Operator">*</span><span class="Other">,</span> <span class="Identifier">pass</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">string</span>
|
||||
<span class="Identifier">address</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">string</span>
|
||||
<span class="Identifier">port</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">Port</span>
|
||||
<span class="Identifier">jobInProgress</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">bool</span>
|
||||
<span class="Identifier">job</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">FtpJob</span>
|
||||
<span class="Identifier">dsockConnected</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">bool</span>
|
||||
</pre></dt>
|
||||
<dd>
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
<div id="FtpEvent">
|
||||
<dt><pre><a href="asyncftpclient.html#FtpEvent"><span class="Identifier">FtpEvent</span></a> <span class="Other">=</span> <span class="Keyword">object</span>
|
||||
<span class="Identifier">filename</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">string</span>
|
||||
</pre></dt>
|
||||
<dd>
|
||||
|
||||
Event
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
<div id="FtpEventType">
|
||||
<dt><pre><a href="asyncftpclient.html#FtpEventType"><span class="Identifier">FtpEventType</span></a> <span class="Other">=</span> <span class="Keyword">enum</span>
|
||||
<span class="Identifier">EvTransferProgress</span><span class="Other">,</span> <span class="Identifier">EvLines</span><span class="Other">,</span> <span class="Identifier">EvRetr</span><span class="Other">,</span> <span class="Identifier">EvStore</span></pre></dt>
|
||||
<dd>
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
<div id="FtpJobType">
|
||||
<dt><pre><a href="asyncftpclient.html#FtpJobType"><span class="Identifier">FtpJobType</span></a> <span class="Other">=</span> <span class="Keyword">enum</span>
|
||||
<span class="Identifier">JRetrText</span><span class="Other">,</span> <span class="Identifier">JRetr</span><span class="Other">,</span> <span class="Identifier">JStore</span></pre></dt>
|
||||
<dd>
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
<div id="ProgressChangedProc">
|
||||
<dt><pre><a href="asyncftpclient.html#ProgressChangedProc"><span class="Identifier">ProgressChangedProc</span></a> <span class="Other">=</span> <span class="Keyword">proc</span> <span class="Other">(</span><span class="Identifier">total</span><span class="Other">,</span> <span class="Identifier">progress</span><span class="Other">:</span> <span class="Identifier">BiggestInt</span><span class="Other">;</span> <span class="Identifier">speed</span><span class="Other">:</span> <span class="Identifier">float</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">Future</span><span class="Other">[</span>
|
||||
<span class="Identifier">void</span><span class="Other">]</span> {.<span class="Identifier">closure</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
<div id="ReplyError">
|
||||
<dt><pre><a href="asyncftpclient.html#ReplyError"><span class="Identifier">ReplyError</span></a> <span class="Other">=</span> <span class="Keyword">object</span> <span class="Keyword">of</span> <span class="Identifier">IOError</span></pre></dt>
|
||||
<dd>
|
||||
|
||||
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</dl>
|
||||
</div>
|
||||
<div class="section" id="12">
|
||||
<h1><a class="toc-backref" href="#12">Procs</a></h1>
|
||||
<dl class="item">
|
||||
<div id="cd-procs-all">
|
||||
<div id="cd,AsyncFtpClient,string">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#cd%2CAsyncFtpClient%2Cstring"><span class="Identifier">cd</span></a><span class="Other">(</span><span class="Identifier">ftp</span><span class="Other">:</span> <a href="asyncftpclient.html#AsyncFtpClient"><span class="Identifier">AsyncFtpClient</span></a><span class="Other">;</span> <span class="Identifier">dir</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">owned</span><span class="Other">(</span><span class="Identifier">Future</span><span class="Other">[</span><span class="Identifier">void</span><span class="Other">]</span><span class="Other">)</span> {.
|
||||
<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">stackTrace</span><span class="Other">:</span> <span class="DecNumber">false</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">Exception</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">RootEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Changes the current directory on the remote FTP server to <tt class="docutils literal"><span class="pre"><span class="Identifier">dir</span></span></tt>.
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="cdup-procs-all">
|
||||
<div id="cdup,AsyncFtpClient">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#cdup%2CAsyncFtpClient"><span class="Identifier">cdup</span></a><span class="Other">(</span><span class="Identifier">ftp</span><span class="Other">:</span> <a href="asyncftpclient.html#AsyncFtpClient"><span class="Identifier">AsyncFtpClient</span></a><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">owned</span><span class="Other">(</span><span class="Identifier">Future</span><span class="Other">[</span><span class="Identifier">void</span><span class="Other">]</span><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">stackTrace</span><span class="Other">:</span> <span class="DecNumber">false</span><span class="Other">,</span>
|
||||
<span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">Exception</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">RootEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Changes the current directory to the parent of the current directory.
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="chmod-procs-all">
|
||||
<div id="chmod,AsyncFtpClient,string,set[FilePermission]">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#chmod%2CAsyncFtpClient%2Cstring%2Cset%5BFilePermission%5D"><span class="Identifier">chmod</span></a><span class="Other">(</span><span class="Identifier">ftp</span><span class="Other">:</span> <a href="asyncftpclient.html#AsyncFtpClient"><span class="Identifier">AsyncFtpClient</span></a><span class="Other">;</span> <span class="Identifier">path</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">;</span> <span class="Identifier">permissions</span><span class="Other">:</span> <span class="Identifier">set</span><span class="Other">[</span><span class="Identifier">FilePermission</span><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">owned</span><span class="Other">(</span>
|
||||
<span class="Identifier">Future</span><span class="Other">[</span><span class="Identifier">void</span><span class="Other">]</span><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">stackTrace</span><span class="Other">:</span> <span class="DecNumber">false</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">Exception</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">RootEffect</span><span class="Other">]</span><span class="Other">,</span>
|
||||
<span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Changes permission of <tt class="docutils literal"><span class="pre"><span class="Identifier">path</span></span></tt> to <tt class="docutils literal"><span class="pre"><span class="Identifier">permissions</span></span></tt>.
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="connect-procs-all">
|
||||
<div id="connect,AsyncFtpClient">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#connect%2CAsyncFtpClient"><span class="Identifier">connect</span></a><span class="Other">(</span><span class="Identifier">ftp</span><span class="Other">:</span> <a href="asyncftpclient.html#AsyncFtpClient"><span class="Identifier">AsyncFtpClient</span></a><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">owned</span><span class="Other">(</span><span class="Identifier">Future</span><span class="Other">[</span><span class="Identifier">void</span><span class="Other">]</span><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">stackTrace</span><span class="Other">:</span> <span class="DecNumber">false</span><span class="Other">,</span>
|
||||
<span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">Exception</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">RootEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Connect to the FTP server specified by <tt class="docutils literal"><span class="pre"><span class="Identifier">ftp</span></span></tt>.
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="createDir-procs-all">
|
||||
<div id="createDir,AsyncFtpClient,string">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#createDir%2CAsyncFtpClient%2Cstring"><span class="Identifier">createDir</span></a><span class="Other">(</span><span class="Identifier">ftp</span><span class="Other">:</span> <a href="asyncftpclient.html#AsyncFtpClient"><span class="Identifier">AsyncFtpClient</span></a><span class="Other">;</span> <span class="Identifier">dir</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">;</span> <span class="Identifier">recursive</span> <span class="Other">=</span> <span class="Identifier">false</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">owned</span><span class="Other">(</span>
|
||||
<span class="Identifier">Future</span><span class="Other">[</span><span class="Identifier">void</span><span class="Other">]</span><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">stackTrace</span><span class="Other">:</span> <span class="DecNumber">false</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">Exception</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">RootEffect</span><span class="Other">]</span><span class="Other">,</span>
|
||||
<span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Creates a directory <tt class="docutils literal"><span class="pre"><span class="Identifier">dir</span></span></tt>. If <tt class="docutils literal"><span class="pre"><span class="Identifier">recursive</span></span></tt> is true, the topmost subdirectory of <tt class="docutils literal"><span class="pre"><span class="Identifier">dir</span></span></tt> will be created first, following the secondmost... etc. this allows you to give a full path as the <tt class="docutils literal"><span class="pre"><span class="Identifier">dir</span></span></tt> without worrying about subdirectories not existing.
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="defaultOnProgressChanged-procs-all">
|
||||
<div id="defaultOnProgressChanged,BiggestInt,BiggestInt,float">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#defaultOnProgressChanged%2CBiggestInt%2CBiggestInt%2Cfloat"><span class="Identifier">defaultOnProgressChanged</span></a><span class="Other">(</span><span class="Identifier">total</span><span class="Other">,</span> <span class="Identifier">progress</span><span class="Other">:</span> <span class="Identifier">BiggestInt</span><span class="Other">;</span> <span class="Identifier">speed</span><span class="Other">:</span> <span class="Identifier">float</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">Future</span><span class="Other">[</span>
|
||||
<span class="Identifier">void</span><span class="Other">]</span> {.<span class="Identifier">nimcall</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">Exception</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">RootEffect</span><span class="Other">]</span><span class="Other">,</span>
|
||||
<span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Default FTP <tt class="docutils literal"><span class="pre"><span class="Identifier">onProgressChanged</span></span></tt> handler. Does nothing.
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="fileExists-procs-all">
|
||||
<div id="fileExists,AsyncFtpClient,string">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#fileExists%2CAsyncFtpClient%2Cstring"><span class="Identifier">fileExists</span></a><span class="Other">(</span><span class="Identifier">ftp</span><span class="Other">:</span> <a href="asyncftpclient.html#AsyncFtpClient"><span class="Identifier">AsyncFtpClient</span></a><span class="Other">;</span> <span class="Identifier">file</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">Future</span><span class="Other">[</span><span class="Identifier">bool</span><span class="Other">]</span> {.
|
||||
<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">stackTrace</span><span class="Other">:</span> <span class="DecNumber">false</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">Exception</span><span class="Other">,</span> <span class="Identifier">ValueError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">RootEffect</span><span class="Other">]</span><span class="Other">,</span>
|
||||
<span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Determines whether <tt class="docutils literal"><span class="pre"><span class="Identifier">file</span></span></tt> exists.
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="list-procs-all">
|
||||
<div id="list,AsyncFtpClient,string">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#list%2CAsyncFtpClient%2Cstring"><span class="Identifier">list</span></a><span class="Other">(</span><span class="Identifier">ftp</span><span class="Other">:</span> <a href="asyncftpclient.html#AsyncFtpClient"><span class="Identifier">AsyncFtpClient</span></a><span class="Other">;</span> <span class="Identifier">dir</span> <span class="Other">=</span> <span class="StringLit">""</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">Future</span><span class="Other">[</span><span class="Identifier">string</span><span class="Other">]</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">stackTrace</span><span class="Other">:</span> <span class="DecNumber">false</span><span class="Other">,</span>
|
||||
<span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">Exception</span><span class="Other">,</span> <span class="Identifier">ValueError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">RootEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Lists all files in <tt class="docutils literal"><span class="pre"><span class="Identifier">dir</span></span></tt>. If <tt class="docutils literal"><span class="pre"><span class="Identifier">dir</span></span></tt> is <tt class="docutils literal"><span class="pre"><span class="StringLit">""</span></span></tt>, uses the current working directory.
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="listDirs-procs-all">
|
||||
<div id="listDirs,AsyncFtpClient,string">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#listDirs%2CAsyncFtpClient%2Cstring"><span class="Identifier">listDirs</span></a><span class="Other">(</span><span class="Identifier">ftp</span><span class="Other">:</span> <a href="asyncftpclient.html#AsyncFtpClient"><span class="Identifier">AsyncFtpClient</span></a><span class="Other">;</span> <span class="Identifier">dir</span> <span class="Other">=</span> <span class="StringLit">""</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">Future</span><span class="Other">[</span><span class="Identifier">seq</span><span class="Other">[</span><span class="Identifier">string</span><span class="Other">]</span><span class="Other">]</span> {.
|
||||
<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">stackTrace</span><span class="Other">:</span> <span class="DecNumber">false</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">Exception</span><span class="Other">,</span> <span class="Identifier">ValueError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">RootEffect</span><span class="Other">]</span><span class="Other">,</span>
|
||||
<span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Returns a list of filenames in the given directory. If <tt class="docutils literal"><span class="pre"><span class="Identifier">dir</span></span></tt> is "", the current directory is used. If <tt class="docutils literal"><span class="pre"><span class="Identifier">async</span></span></tt> is true, this function will return immediately and it will be your job to use asyncdispatch's <tt class="docutils literal"><span class="pre"><span class="Identifier">poll</span></span></tt> to progress this operation.
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="newAsyncFtpClient-procs-all">
|
||||
<div id="newAsyncFtpClient,string,string,string,int,SslContext">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#newAsyncFtpClient%2Cstring%2Cstring%2Cstring%2Cint%2CSslContext"><span class="Identifier">newAsyncFtpClient</span></a><span class="Other">(</span><span class="Identifier">address</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">;</span> <span class="Identifier">port</span> <span class="Other">=</span> <span class="Identifier">Port</span><span class="Other">(</span><span class="DecNumber">21</span><span class="Other">)</span><span class="Other">;</span> <span class="Identifier">user</span><span class="Other">,</span> <span class="Identifier">pass</span> <span class="Other">=</span> <span class="StringLit">""</span><span class="Other">;</span>
|
||||
<span class="Identifier">progressInterval</span><span class="Other">:</span> <span class="Identifier">int</span> <span class="Other">=</span> <span class="DecNumber">1000</span><span class="Other">;</span> <span class="Identifier">useTls</span> <span class="Other">=</span> <span class="Identifier">false</span><span class="Other">;</span>
|
||||
<span class="Identifier">sslContext</span><span class="Other">:</span> <span class="Identifier">SslContext</span> <span class="Other">=</span> <span class="Keyword">nil</span><span class="Other">)</span><span class="Other">:</span> <a href="asyncftpclient.html#AsyncFtpClient"><span class="Identifier">AsyncFtpClient</span></a> {.
|
||||
<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">OSError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Creates a new <tt class="docutils literal"><span class="pre"><span class="Identifier">AsyncFtpClient</span></span></tt> object.
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="pwd-procs-all">
|
||||
<div id="pwd,AsyncFtpClient">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#pwd%2CAsyncFtpClient"><span class="Identifier">pwd</span></a><span class="Other">(</span><span class="Identifier">ftp</span><span class="Other">:</span> <a href="asyncftpclient.html#AsyncFtpClient"><span class="Identifier">AsyncFtpClient</span></a><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">Future</span><span class="Other">[</span><span class="Identifier">string</span><span class="Other">]</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">stackTrace</span><span class="Other">:</span> <span class="DecNumber">false</span><span class="Other">,</span>
|
||||
<span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">Exception</span><span class="Other">,</span> <span class="Identifier">ValueError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">RootEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Returns the current working directory.
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="removeDir-procs-all">
|
||||
<div id="removeDir,AsyncFtpClient,string">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#removeDir%2CAsyncFtpClient%2Cstring"><span class="Identifier">removeDir</span></a><span class="Other">(</span><span class="Identifier">ftp</span><span class="Other">:</span> <a href="asyncftpclient.html#AsyncFtpClient"><span class="Identifier">AsyncFtpClient</span></a><span class="Other">;</span> <span class="Identifier">dir</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">owned</span><span class="Other">(</span><span class="Identifier">Future</span><span class="Other">[</span><span class="Identifier">void</span><span class="Other">]</span><span class="Other">)</span> {.
|
||||
<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">stackTrace</span><span class="Other">:</span> <span class="DecNumber">false</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">Exception</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">RootEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Delete a directory <tt class="docutils literal"><span class="pre"><span class="Identifier">dir</span></span></tt> on the remote FTP server
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="removeFile-procs-all">
|
||||
<div id="removeFile,AsyncFtpClient,string">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#removeFile%2CAsyncFtpClient%2Cstring"><span class="Identifier">removeFile</span></a><span class="Other">(</span><span class="Identifier">ftp</span><span class="Other">:</span> <a href="asyncftpclient.html#AsyncFtpClient"><span class="Identifier">AsyncFtpClient</span></a><span class="Other">;</span> <span class="Identifier">filename</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">owned</span><span class="Other">(</span><span class="Identifier">Future</span><span class="Other">[</span><span class="Identifier">void</span><span class="Other">]</span><span class="Other">)</span> {.
|
||||
<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">stackTrace</span><span class="Other">:</span> <span class="DecNumber">false</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">Exception</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">RootEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Delete a file <tt class="docutils literal"><span class="pre"><span class="Identifier">filename</span></span></tt> on the remote FTP server
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="rename-procs-all">
|
||||
<div id="rename,AsyncFtpClient,string,string">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#rename%2CAsyncFtpClient%2Cstring%2Cstring"><span class="Identifier">rename</span></a><span class="Other">(</span><span class="Identifier">ftp</span><span class="Other">:</span> <a href="asyncftpclient.html#AsyncFtpClient"><span class="Identifier">AsyncFtpClient</span></a><span class="Other">;</span> <span class="Identifier">nameFrom</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">;</span> <span class="Identifier">nameTo</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">owned</span><span class="Other">(</span>
|
||||
<span class="Identifier">Future</span><span class="Other">[</span><span class="Identifier">void</span><span class="Other">]</span><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">stackTrace</span><span class="Other">:</span> <span class="DecNumber">false</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">Exception</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">RootEffect</span><span class="Other">]</span><span class="Other">,</span>
|
||||
<span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Rename a file or directory on the remote FTP Server from current name <tt class="docutils literal"><span class="pre"><span class="Identifier">name_from</span></span></tt> to new name <tt class="docutils literal"><span class="pre"><span class="Identifier">name_to</span></span></tt>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="retrFile-procs-all">
|
||||
<div id="retrFile,AsyncFtpClient,string,string,ProgressChangedProc">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#retrFile%2CAsyncFtpClient%2Cstring%2Cstring%2CProgressChangedProc"><span class="Identifier">retrFile</span></a><span class="Other">(</span><span class="Identifier">ftp</span><span class="Other">:</span> <a href="asyncftpclient.html#AsyncFtpClient"><span class="Identifier">AsyncFtpClient</span></a><span class="Other">;</span> <span class="Identifier">file</span><span class="Other">,</span> <span class="Identifier">dest</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">;</span>
|
||||
<span class="Identifier">onProgressChanged</span><span class="Other">:</span> <a href="asyncftpclient.html#ProgressChangedProc"><span class="Identifier">ProgressChangedProc</span></a> <span class="Other">=</span> <span class="Identifier">defaultOnProgressChanged</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">owned</span><span class="Other">(</span>
|
||||
<span class="Identifier">Future</span><span class="Other">[</span><span class="Identifier">void</span><span class="Other">]</span><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">stackTrace</span><span class="Other">:</span> <span class="DecNumber">false</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">Exception</span><span class="Other">]</span><span class="Other">,</span>
|
||||
<span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">RootEffect</span><span class="Other">,</span> <span class="Identifier">TimeEffect</span><span class="Other">,</span> <span class="Identifier">WriteIOEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Downloads <tt class="docutils literal"><span class="pre"><span class="Identifier">file</span></span></tt> and saves it to <tt class="docutils literal"><span class="pre"><span class="Identifier">dest</span></span></tt>. The <tt class="docutils literal"><span class="pre"><span class="Identifier">EvRetr</span></span></tt> event is passed to the specified <tt class="docutils literal"><span class="pre"><span class="Identifier">handleEvent</span></span></tt> function when the download is finished. The event's <tt class="docutils literal"><span class="pre"><span class="Identifier">filename</span></span></tt> field will be equal to <tt class="docutils literal"><span class="pre"><span class="Identifier">file</span></span></tt>.
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="retrText-procs-all">
|
||||
<div id="retrText,AsyncFtpClient,string">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#retrText%2CAsyncFtpClient%2Cstring"><span class="Identifier">retrText</span></a><span class="Other">(</span><span class="Identifier">ftp</span><span class="Other">:</span> <a href="asyncftpclient.html#AsyncFtpClient"><span class="Identifier">AsyncFtpClient</span></a><span class="Other">;</span> <span class="Identifier">file</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">Future</span><span class="Other">[</span><span class="Identifier">string</span><span class="Other">]</span> {.
|
||||
<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">stackTrace</span><span class="Other">:</span> <span class="DecNumber">false</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">Exception</span><span class="Other">,</span> <span class="Identifier">ValueError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">RootEffect</span><span class="Other">]</span><span class="Other">,</span>
|
||||
<span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Retrieves <tt class="docutils literal"><span class="pre"><span class="Identifier">file</span></span></tt>. File must be ASCII text.
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="send-procs-all">
|
||||
<div id="send,AsyncFtpClient,string">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#send%2CAsyncFtpClient%2Cstring"><span class="Identifier">send</span></a><span class="Other">(</span><span class="Identifier">ftp</span><span class="Other">:</span> <a href="asyncftpclient.html#AsyncFtpClient"><span class="Identifier">AsyncFtpClient</span></a><span class="Other">;</span> <span class="Identifier">m</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">Future</span><span class="Other">[</span><span class="Identifier">string</span><span class="Other">]</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">stackTrace</span><span class="Other">:</span> <span class="DecNumber">false</span><span class="Other">,</span>
|
||||
<span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">Exception</span><span class="Other">,</span> <span class="Identifier">ValueError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">RootEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Send a message to the server, and wait for a primary reply. <tt class="docutils literal"><span class="pre"><span class="Operator">\</span><span class="Identifier">c</span><span class="Operator">\</span><span class="Identifier">L</span></span></tt> is added for you.</p>
|
||||
<p>You need to make sure that the message <tt class="docutils literal"><span class="pre"><span class="Identifier">m</span></span></tt> doesn't contain any newline characters. Failing to do so will raise <tt class="docutils literal"><span class="pre"><span class="Identifier">AssertionDefect</span></span></tt>.</p>
|
||||
<p><strong>Note:</strong> The server may return multiple lines of coded replies.</p>
|
||||
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="store-procs-all">
|
||||
<div id="store,AsyncFtpClient,string,string,ProgressChangedProc">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#store%2CAsyncFtpClient%2Cstring%2Cstring%2CProgressChangedProc"><span class="Identifier">store</span></a><span class="Other">(</span><span class="Identifier">ftp</span><span class="Other">:</span> <a href="asyncftpclient.html#AsyncFtpClient"><span class="Identifier">AsyncFtpClient</span></a><span class="Other">;</span> <span class="Identifier">file</span><span class="Other">,</span> <span class="Identifier">dest</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">;</span>
|
||||
<span class="Identifier">onProgressChanged</span><span class="Other">:</span> <a href="asyncftpclient.html#ProgressChangedProc"><span class="Identifier">ProgressChangedProc</span></a> <span class="Other">=</span> <span class="Identifier">defaultOnProgressChanged</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">owned</span><span class="Other">(</span>
|
||||
<span class="Identifier">Future</span><span class="Other">[</span><span class="Identifier">void</span><span class="Other">]</span><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">stackTrace</span><span class="Other">:</span> <span class="DecNumber">false</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">Exception</span><span class="Other">]</span><span class="Other">,</span>
|
||||
<span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">RootEffect</span><span class="Other">,</span> <span class="Identifier">ReadIOEffect</span><span class="Other">,</span> <span class="Identifier">TimeEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Uploads <tt class="docutils literal"><span class="pre"><span class="Identifier">file</span></span></tt> to <tt class="docutils literal"><span class="pre"><span class="Identifier">dest</span></span></tt> on the remote FTP server. Usage of this function asynchronously is recommended to view the progress of the download. The <tt class="docutils literal"><span class="pre"><span class="Identifier">EvStore</span></span></tt> event is passed to the specified <tt class="docutils literal"><span class="pre"><span class="Identifier">handleEvent</span></span></tt> function when the upload is finished, and the <tt class="docutils literal"><span class="pre"><span class="Identifier">filename</span></span></tt> field will be equal to <tt class="docutils literal"><span class="pre"><span class="Identifier">file</span></span></tt>.
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="twelve-columns footer">
|
||||
<span class="nim-sprite"></span>
|
||||
<br>
|
||||
<small style="color: var(--hint);">Made with Nim. Generated: 2023-03-13 00:20:09 UTC</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script defer data-domain="nim-lang.org" src="https://plausible.io/js/plausible.js"></script>
|
||||
|
||||
<!-- Google fonts -->
|
||||
<link href='https://fonts.googleapis.com/css?family=Lato:400,600,900' rel='stylesheet' type='text/css'/>
|
||||
<link href='https://fonts.googleapis.com/css?family=Source+Code+Pro:400,500,600' rel='stylesheet' type='text/css'/>
|
||||
</body>
|
||||
</html>
|
||||
35
asyncftpclient.idx
Normal file
35
asyncftpclient.idx
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
nimTitle asyncftpclient asyncftpclient.html module src/asyncftpclient 0
|
||||
nim AsyncFtpClient asyncftpclient.html#AsyncFtpClient type AsyncFtpClient 110
|
||||
nim JRetrText asyncftpclient.html#JRetrText FtpJobType.JRetrText 124
|
||||
nim JRetr asyncftpclient.html#JRetr FtpJobType.JRetr 124
|
||||
nim JStore asyncftpclient.html#JStore FtpJobType.JStore 124
|
||||
nim FtpJobType asyncftpclient.html#FtpJobType enum FtpJobType 124
|
||||
nim EvTransferProgress asyncftpclient.html#EvTransferProgress FtpEventType.EvTransferProgress 141
|
||||
nim EvLines asyncftpclient.html#EvLines FtpEventType.EvLines 141
|
||||
nim EvRetr asyncftpclient.html#EvRetr FtpEventType.EvRetr 141
|
||||
nim EvStore asyncftpclient.html#EvStore FtpEventType.EvStore 141
|
||||
nim FtpEventType asyncftpclient.html#FtpEventType enum FtpEventType 141
|
||||
nim FtpEvent asyncftpclient.html#FtpEvent object FtpEvent 144
|
||||
nim ReplyError asyncftpclient.html#ReplyError object ReplyError 157
|
||||
nim ProgressChangedProc asyncftpclient.html#ProgressChangedProc type ProgressChangedProc 159
|
||||
nim send asyncftpclient.html#send,AsyncFtpClient,string proc send(ftp: AsyncFtpClient; m: string): Future[string] 177
|
||||
nim connect asyncftpclient.html#connect,AsyncFtpClient proc connect(ftp: AsyncFtpClient): owned(Future[void]) 224
|
||||
nim pwd asyncftpclient.html#pwd,AsyncFtpClient proc pwd(ftp: AsyncFtpClient): Future[string] 259
|
||||
nim cd asyncftpclient.html#cd,AsyncFtpClient,string proc cd(ftp: AsyncFtpClient; dir: string): owned(Future[void]) 265
|
||||
nim cdup asyncftpclient.html#cdup,AsyncFtpClient proc cdup(ftp: AsyncFtpClient): owned(Future[void]) 269
|
||||
nim listDirs asyncftpclient.html#listDirs,AsyncFtpClient,string proc listDirs(ftp: AsyncFtpClient; dir = ""): Future[seq[string]] 286
|
||||
nim fileExists asyncftpclient.html#fileExists,AsyncFtpClient,string proc fileExists(ftp: AsyncFtpClient; file: string): Future[bool] 297
|
||||
nim createDir asyncftpclient.html#createDir,AsyncFtpClient,string proc createDir(ftp: AsyncFtpClient; dir: string; recursive = false): owned(\n Future[void]) 303
|
||||
nim chmod asyncftpclient.html#chmod,AsyncFtpClient,string,set[FilePermission] proc chmod(ftp: AsyncFtpClient; path: string; permissions: set[FilePermission]): owned(\n Future[void]) 321
|
||||
nim list asyncftpclient.html#list,AsyncFtpClient,string proc list(ftp: AsyncFtpClient; dir = ""): Future[string] 342
|
||||
nim retrText asyncftpclient.html#retrText,AsyncFtpClient,string proc retrText(ftp: AsyncFtpClient; file: string): Future[string] 352
|
||||
nim defaultOnProgressChanged asyncftpclient.html#defaultOnProgressChanged,BiggestInt,BiggestInt,float proc defaultOnProgressChanged(total, progress: BiggestInt; speed: float): Future[void] 388
|
||||
nim retrFile asyncftpclient.html#retrFile,AsyncFtpClient,string,string,ProgressChangedProc proc retrFile(ftp: AsyncFtpClient; file, dest: string;\n onProgressChanged: ProgressChangedProc = defaultOnProgressChanged): owned(\n Future[void]) 396
|
||||
nim store asyncftpclient.html#store,AsyncFtpClient,string,string,ProgressChangedProc proc store(ftp: AsyncFtpClient; file, dest: string;\n onProgressChanged: ProgressChangedProc = defaultOnProgressChanged): owned(\n Future[void]) 448
|
||||
nim rename asyncftpclient.html#rename,AsyncFtpClient,string,string proc rename(ftp: AsyncFtpClient; nameFrom: string; nameTo: string): owned(\n Future[void]) 463
|
||||
nim removeFile asyncftpclient.html#removeFile,AsyncFtpClient,string proc removeFile(ftp: AsyncFtpClient; filename: string): owned(Future[void]) 469
|
||||
nim removeDir asyncftpclient.html#removeDir,AsyncFtpClient,string proc removeDir(ftp: AsyncFtpClient; dir: string): owned(Future[void]) 473
|
||||
nim newAsyncFtpClient asyncftpclient.html#newAsyncFtpClient,string,string,string,int,SslContext proc newAsyncFtpClient(address: string; port = Port(21); user, pass = "";\n progressInterval: int = 1000; useTls = false;\n sslContext: SslContext = nil): AsyncFtpClient 477
|
||||
heading Connecting to an FTP server asyncftpclient.html#connecting-to-an-ftp-server Connecting to an FTP server 0
|
||||
heading Uploading a new file asyncftpclient.html#uploading-a-new-file Uploading a new file 0
|
||||
heading Checking the progress of a file transfer asyncftpclient.html#checking-the-progress-of-a-file-transfer Checking the progress of a file transfer 0
|
||||
658
asyncfutures.html
Normal file
658
asyncfutures.html
Normal file
|
|
@ -0,0 +1,658 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<!-- This file is generated by Nim. -->
|
||||
<html xmlns="https://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>std/asyncfutures</title>
|
||||
|
||||
<!-- Favicon -->
|
||||
<link rel="shortcut icon" href="data:image/x-icon;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAUAAAAF////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAIAAABbAAAAlQAAAKIAAACbAAAAmwAAAKIAAACVAAAAWwAAAAL///8A////AP///wD///8A////AAAAABQAAADAAAAAYwAAAA3///8A////AP///wD///8AAAAADQAAAGMAAADAAAAAFP///wD///8A////AP///wAAAACdAAAAOv///wD///8A////AP///wD///8A////AP///wD///8AAAAAOgAAAJ3///8A////AP///wAAAAAnAAAAcP///wAAAAAoAAAASv///wD///8A////AP///wAAAABKAAAAKP///wAAAABwAAAAJ////wD///8AAAAAgQAAABwAAACIAAAAkAAAAJMAAACtAAAAFQAAABUAAACtAAAAkwAAAJAAAACIAAAAHAAAAIH///8A////AAAAAKQAAACrAAAAaP///wD///8AAAAARQAAANIAAADSAAAARf///wD///8AAAAAaAAAAKsAAACk////AAAAADMAAACcAAAAnQAAABj///8A////AP///wAAAAAYAAAAGP///wD///8A////AAAAABgAAACdAAAAnAAAADMAAAB1AAAAwwAAAP8AAADpAAAAsQAAAE4AAAAb////AP///wAAAAAbAAAATgAAALEAAADpAAAA/wAAAMMAAAB1AAAAtwAAAOkAAAD/AAAA/wAAAP8AAADvAAAA3gAAAN4AAADeAAAA3gAAAO8AAAD/AAAA/wAAAP8AAADpAAAAtwAAAGUAAAA/AAAA3wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAADfAAAAPwAAAGX///8A////AAAAAEgAAADtAAAAvwAAAL0AAADGAAAA7wAAAO8AAADGAAAAvQAAAL8AAADtAAAASP///wD///8A////AP///wD///8AAAAAO////wD///8A////AAAAAIcAAACH////AP///wD///8AAAAAO////wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A//8AAP//AAD4HwAA7/cAAN/7AAD//wAAoYUAAJ55AACf+QAAh+EAAAAAAADAAwAA4AcAAP5/AAD//wAA//8AAA=="/>
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAA3XAAAN1wFCKJt4AAAAB3RJTUUH4QQQEwksSS9ZWwAAAk1JREFUWMPtll2ITVEUx39nn/O7Y5qR8f05wtCUUr6ZIS++8pEnkZInPImneaCQ5METNdOkeFBKUhMPRIkHKfEuUZSUlGlKPN2TrgfncpvmnntnmlEyq1Z7t89/rf9a6+y99oZxGZf/XeIq61EdtgKXgdXA0xrYAvBjOIF1AI9zvjcC74BSpndrJPkBWDScTF8Aa4E3wDlgHbASaANmVqlcCnwHvgDvgVfAJ+AikAAvgfVZwLnSVZHZaOuKoQi3ZOMi4NkYkpe1p4J7A8BpYAD49hfIy/oqG0+hLomiKP2L5L+1ubn5115S+3OAn4EnwBlgMzCjyt6ZAnQCJ4A7wOs88iRJHvw50HoujuPBoCKwHWiosy8MdfZnAdcHk8dxXFJ3VQbQlCTJvRBCGdRbD4M6uc5glpY3eAihpN5S5w12diSEcCCEcKUO4ljdr15T76ur1FDDLIQQ3qv71EdDOe3Kxj3leRXyk+pxdWnFWod6Wt2bY3de3aSuUHcPBVimHs7mK9WrmeOF6lR1o9qnzskh2ar2qm1qizpfXaPeVGdlmGN5pb09qMxz1Xb1kLqgzn1RyH7JUXW52lr5e/Kqi9qpto7V1atuUzfnARrV7jEib1T76gG2qxdGmXyiekkt1GswPTtek0aBfJp6YySGBfWg2tPQ0FAYgf1stUfdmdcjarbYJEniKIq6gY/Aw+zWHAC+p2labGpqiorFYgGYCEzN7oQdQClN07O1/EfDyGgC0ALMBdYAi4FyK+4H3gLPsxfR1zRNi+NP7nH5J+QntnXe5B5mpfQAAAAASUVORK5CYII=">
|
||||
|
||||
<!-- CSS -->
|
||||
<link rel="stylesheet" type="text/css" href="nimdoc.out.css">
|
||||
|
||||
<!-- JS -->
|
||||
<script type="text/javascript" src="dochack.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="document" id="documentId">
|
||||
<div class="container">
|
||||
<h1 class="title">std/asyncfutures</h1>
|
||||
<div class="row">
|
||||
<div class="three columns">
|
||||
<div class="theme-select-wrapper">
|
||||
<label for="theme-select">Theme: </label>
|
||||
<select id="theme-select" onchange="setTheme(this.value)">
|
||||
<option value="auto">🌗 Match OS</option>
|
||||
<option value="dark">🌑 Dark</option>
|
||||
<option value="light">🌕 Light</option>
|
||||
</select>
|
||||
</div>
|
||||
<div id="global-links">
|
||||
<ul class="simple-boot">
|
||||
<li><a href="manual.html">Manual</a></li>
|
||||
<li><a href="lib.html">Standard library</a></li>
|
||||
<li> <a id="indexLink" href="theindex.html">Index</a></li>
|
||||
<li><a href="compiler/theindex.html">Compiler docs</a></li>
|
||||
<li><a href="https://nim-lang.github.io/fusion/theindex.html">Fusion docs</a></li>
|
||||
<li><a href="https://nim-lang.github.io/Nim/">devel</a>, <a href="https://nim-lang.org/documentation.html">stable</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="searchInputDiv">
|
||||
Search: <input type="search" id="searchInput"
|
||||
onkeyup="search()" />
|
||||
</div>
|
||||
|
||||
<ul class="simple simple-toc" id="toc-list">
|
||||
<li>
|
||||
<a class="reference reference-toplevel" href="#6" id="56">Imports</a>
|
||||
</li>
|
||||
<li>
|
||||
<details open>
|
||||
<summary><a class="reference reference-toplevel" href="#7" id="57">Types</a></summary>
|
||||
<ul class="simple simple-toc-section">
|
||||
<li><a class="reference" href="#Future" title="Future[T] = ref object of FutureBase">Future</a></li>
|
||||
<li><a class="reference" href="#FutureBase" title="FutureBase = ref object of RootObj
|
||||
error*: ref Exception ## Stored exception
|
||||
errorStackTrace*: string">FutureBase</a></li>
|
||||
<li><a class="reference" href="#FutureError" title="FutureError = object of Defect
|
||||
cause*: FutureBase">FutureError</a></li>
|
||||
<li><a class="reference" href="#FutureVar" title="FutureVar[T] = distinct Future[T]">FutureVar</a></li>
|
||||
|
||||
</ul>
|
||||
</details>
|
||||
</li>
|
||||
<li>
|
||||
<details open>
|
||||
<summary><a class="reference reference-toplevel" href="#10" id="60">Consts</a></summary>
|
||||
<ul class="simple simple-toc-section">
|
||||
<li><a class="reference" href="#isFutureLoggingEnabled" title="isFutureLoggingEnabled = false">isFutureLoggingEnabled</a></li>
|
||||
<li><a class="reference" href="#NimAsyncContinueSuffix" title="NimAsyncContinueSuffix = "NimAsyncContinue"">NimAsyncContinueSuffix</a></li>
|
||||
|
||||
</ul>
|
||||
</details>
|
||||
</li>
|
||||
<li>
|
||||
<details open>
|
||||
<summary><a class="reference reference-toplevel" href="#12" id="62">Procs</a></summary>
|
||||
<ul class="simple simple-toc-section">
|
||||
<ul class="simple nested-toc-section">$
|
||||
<li><a class="reference" href="#%24%2Cseq%5BStackTraceEntry%5D" title="`$`(stackTraceEntries: seq[StackTraceEntry]): string">`$`(stackTraceEntries: seq[StackTraceEntry]): string</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">addCallback
|
||||
<li><a class="reference" href="#addCallback%2CFutureBase%2Cproc%29" title="addCallback(future: FutureBase; cb: proc () {.closure, gcsafe.})">addCallback(future: FutureBase; cb: proc () {.closure, gcsafe.})</a></li>
|
||||
<li><a class="reference" href="#addCallback%2CFuture%5BT%5D%2Cproc%28Future%5BT%5D%29" title="addCallback[T](future: Future[T];
|
||||
cb: proc (future: Future[T]) {.closure, gcsafe.})">addCallback[T](future: Future[T];
|
||||
cb: proc (future: Future[T]) {.closure, gcsafe.})</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">all
|
||||
<li><a class="reference" href="#all%2Cvarargs%5BFuture%5BT%5D%5D" title="all[T](futs: varargs[Future[T]]): auto">all[T](futs: varargs[Future[T]]): auto</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">and
|
||||
<li><a class="reference" href="#and%2CFuture%5BT%5D%2CFuture%5BY%5D" title="`and`[T, Y](fut1: Future[T]; fut2: Future[Y]): Future[void]">`and`[T, Y](fut1: Future[T]; fut2: Future[Y]): Future[void]</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">asyncCheck
|
||||
<li><a class="reference" href="#asyncCheck%2CFuture%5BT%5D" title="asyncCheck[T](future: Future[T])">asyncCheck[T](future: Future[T])</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">callback=
|
||||
<li><a class="reference" href="#callback%3D%2CFutureBase%2Cproc%29" title="callback=(future: FutureBase; cb: proc () {.closure, gcsafe.})">callback=(future: FutureBase; cb: proc () {.closure, gcsafe.})</a></li>
|
||||
<li><a class="reference" href="#callback%3D%2CFuture%5BT%5D%2Cproc%28Future%5BT%5D%29" title="callback=[T](future: Future[T]; cb: proc (future: Future[T]) {.closure, gcsafe.})">callback=[T](future: Future[T]; cb: proc (future: Future[T]) {.closure, gcsafe.})</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">callSoon
|
||||
<li><a class="reference" href="#callSoon%2Cproc%29" title="callSoon(cbproc: proc () {.gcsafe.})">callSoon(cbproc: proc () {.gcsafe.})</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">clean
|
||||
<li><a class="reference" href="#clean%2CFutureVar%5BT%5D" title="clean[T](future: FutureVar[T])">clean[T](future: FutureVar[T])</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">clearCallbacks
|
||||
<li><a class="reference" href="#clearCallbacks%2CFutureBase" title="clearCallbacks(future: FutureBase)">clearCallbacks(future: FutureBase)</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">complete
|
||||
<li><a class="reference" href="#complete%2CFuture%5Bvoid%5D" title="complete(future: Future[void]; val = Future[void].default)">complete(future: Future[void]; val = Future[void].default)</a></li>
|
||||
<li><a class="reference" href="#complete%2CFuture%5BT%5D%2CT" title="complete[T](future: Future[T]; val: T)">complete[T](future: Future[T]; val: T)</a></li>
|
||||
<li><a class="reference" href="#complete%2CFutureVar%5BT%5D" title="complete[T](future: FutureVar[T])">complete[T](future: FutureVar[T])</a></li>
|
||||
<li><a class="reference" href="#complete%2CFutureVar%5BT%5D%2CT" title="complete[T](future: FutureVar[T]; val: T)">complete[T](future: FutureVar[T]; val: T)</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">fail
|
||||
<li><a class="reference" href="#fail%2CFuture%5BT%5D%2Cref.Exception" title="fail[T](future: Future[T]; error: ref Exception)">fail[T](future: Future[T]; error: ref Exception)</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">failed
|
||||
<li><a class="reference" href="#failed%2CFutureBase" title="failed(future: FutureBase): bool">failed(future: FutureBase): bool</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">finished
|
||||
<li><a class="reference" href="#finished" title="finished(future: FutureBase | FutureVar): bool">finished(future: FutureBase | FutureVar): bool</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">getCallSoonProc
|
||||
<li><a class="reference" href="#getCallSoonProc" title="getCallSoonProc(): (proc (cbproc: proc ()) {.gcsafe.})">getCallSoonProc(): (proc (cbproc: proc ()) {.gcsafe.})</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">mget
|
||||
<li><a class="reference" href="#mget%2CFutureVar%5BT%5D" title="mget[T](future: FutureVar[T]): var T">mget[T](future: FutureVar[T]): var T</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">newFuture
|
||||
<li><a class="reference" href="#newFuture%2Cstring" title="newFuture[T](fromProc: string = "unspecified"): owned(Future[T])">newFuture[T](fromProc: string = "unspecified"): owned(Future[T])</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">newFutureVar
|
||||
<li><a class="reference" href="#newFutureVar%2Cstring" title="newFutureVar[T](fromProc = "unspecified"): owned(FutureVar[T])">newFutureVar[T](fromProc = "unspecified"): owned(FutureVar[T])</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">or
|
||||
<li><a class="reference" href="#or%2CFuture%5BT%5D%2CFuture%5BY%5D" title="`or`[T, Y](fut1: Future[T]; fut2: Future[Y]): Future[void]">`or`[T, Y](fut1: Future[T]; fut2: Future[Y]): Future[void]</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">read
|
||||
<li><a class="reference" href="#read" title="read[T](future: Future[T] | FutureVar[T]): T">read[T](future: Future[T] | FutureVar[T]): T</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">readError
|
||||
<li><a class="reference" href="#readError%2CFuture%5BT%5D" title="readError[T](future: Future[T]): ref Exception">readError[T](future: Future[T]): ref Exception</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">setCallSoonProc
|
||||
<li><a class="reference" href="#setCallSoonProc" title="setCallSoonProc(p: (proc (cbproc: proc ()) {.gcsafe.}))">setCallSoonProc(p: (proc (cbproc: proc ()) {.gcsafe.}))</a></li>
|
||||
|
||||
</ul>
|
||||
|
||||
</ul>
|
||||
</details>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
<div class="nine columns" id="content">
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncfutures.nim#L1" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncfutures.nim#L1" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
<div id="tocRoot"></div>
|
||||
|
||||
<p class="module-desc"></p>
|
||||
<div class="section" id="6">
|
||||
<h1><a class="toc-backref" href="#6">Imports</a></h1>
|
||||
<dl class="item">
|
||||
<a class="reference external" href="os.html">os</a>, <a class="reference external" href="tables.html">tables</a>, <a class="reference external" href="strutils.html">strutils</a>, <a class="reference external" href="times.html">times</a>, <a class="reference external" href="heapqueue.html">heapqueue</a>, <a class="reference external" href="options.html">options</a>, <a class="reference external" href="deques.html">deques</a>, <a class="reference external" href="cstrutils.html">cstrutils</a>, <a class="reference external" href="stacktraces.html">stacktraces</a>, <a class="reference external" href="objectdollar.html">objectdollar</a>, <a class="reference external" href="assertions.html">assertions</a>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="section" id="7">
|
||||
<h1><a class="toc-backref" href="#7">Types</a></h1>
|
||||
<dl class="item">
|
||||
<div id="Future">
|
||||
<dt><pre><a href="asyncfutures.html#Future"><span class="Identifier">Future</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span> <span class="Other">=</span> <span class="Keyword">ref</span> <span class="Keyword">object</span> <span class="Keyword">of</span> <a href="asyncfutures.html#FutureBase"><span class="Identifier">FutureBase</span></a>
|
||||
</pre></dt>
|
||||
<dd>
|
||||
|
||||
Typed future.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncfutures.nim#L37" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncfutures.nim#L37" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
<div id="FutureBase">
|
||||
<dt><pre><a href="asyncfutures.html#FutureBase"><span class="Identifier">FutureBase</span></a> <span class="Other">=</span> <span class="Keyword">ref</span> <span class="Keyword">object</span> <span class="Keyword">of</span> <a href="system.html#RootObj"><span class="Identifier">RootObj</span></a>
|
||||
<span class="Identifier">error</span><span class="Operator">*</span><span class="Other">:</span> <span class="Keyword">ref</span> <a href="system.html#Exception"><span class="Identifier">Exception</span></a> <span class="Comment">## Stored exception</span>
|
||||
<span class="Identifier">errorStackTrace</span><span class="Operator">*</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a>
|
||||
</pre></dt>
|
||||
<dd>
|
||||
|
||||
Untyped future.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncfutures.nim#L26" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncfutures.nim#L26" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
<div id="FutureError">
|
||||
<dt><pre><a href="asyncfutures.html#FutureError"><span class="Identifier">FutureError</span></a> <span class="Other">=</span> <span class="Keyword">object</span> <span class="Keyword">of</span> <a href="system.html#Defect"><span class="Identifier">Defect</span></a>
|
||||
<span class="Identifier">cause</span><span class="Operator">*</span><span class="Other">:</span> <a href="asyncfutures.html#FutureBase"><span class="Identifier">FutureBase</span></a>
|
||||
</pre></dt>
|
||||
<dd>
|
||||
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncfutures.nim#L42" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncfutures.nim#L42" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
<div id="FutureVar">
|
||||
<dt><pre><a href="asyncfutures.html#FutureVar"><span class="Identifier">FutureVar</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span> <span class="Other">=</span> <span class="Keyword">distinct</span> <a href="asyncfutures.html#Future"><span class="Identifier">Future</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span></pre></dt>
|
||||
<dd>
|
||||
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncfutures.nim#L40" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncfutures.nim#L40" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</dl>
|
||||
</div>
|
||||
<div class="section" id="10">
|
||||
<h1><a class="toc-backref" href="#10">Consts</a></h1>
|
||||
<dl class="item">
|
||||
<div id="isFutureLoggingEnabled">
|
||||
<dt><pre><a href="asyncfutures.html#isFutureLoggingEnabled"><span class="Identifier">isFutureLoggingEnabled</span></a> <span class="Other">=</span> <span class="DecNumber">false</span></pre></dt>
|
||||
<dd>
|
||||
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncfutures.nim#L48" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncfutures.nim#L48" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
<div id="NimAsyncContinueSuffix">
|
||||
<dt><pre><a href="asyncfutures.html#NimAsyncContinueSuffix"><span class="Identifier">NimAsyncContinueSuffix</span></a> <span class="Other">=</span> <span class="StringLit">"NimAsyncContinue"</span></pre></dt>
|
||||
<dd>
|
||||
|
||||
For internal usage. Do not use.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncfutures.nim#L51" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncfutures.nim#L51" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</dl>
|
||||
</div>
|
||||
<div class="section" id="12">
|
||||
<h1><a class="toc-backref" href="#12">Procs</a></h1>
|
||||
<dl class="item">
|
||||
<div id="$-procs-all">
|
||||
<div id="$,seq[StackTraceEntry]">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#%24%2Cseq%5BStackTraceEntry%5D"><span class="Identifier">`$`</span></a><span class="Other">(</span><span class="Identifier">stackTraceEntries</span><span class="Other">:</span> <a href="system.html#seq"><span class="Identifier">seq</span></a><span class="Other">[</span><a href="system.html#StackTraceEntry"><span class="Identifier">StackTraceEntry</span></a><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> {.
|
||||
<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ValueError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncfutures.nim#L314" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncfutures.nim#L314" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="addCallback-procs-all">
|
||||
<div id="addCallback,FutureBase,proc)">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#addCallback%2CFutureBase%2Cproc%29"><span class="Identifier">addCallback</span></a><span class="Other">(</span><span class="Identifier">future</span><span class="Other">:</span> <a href="asyncfutures.html#FutureBase"><span class="Identifier">FutureBase</span></a><span class="Other">;</span> <span class="Identifier">cb</span><span class="Other">:</span> <span class="Keyword">proc</span> <span class="Other">(</span><span class="Other">)</span> {.<span class="Identifier">closure</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span></span>.}<span class="Other">)</span> {.
|
||||
<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">Exception</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">RootEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Adds the callbacks proc to be called when the future completes.</p>
|
||||
<p>If future has already completed then <tt class="docutils literal"><span class="pre"><span class="Identifier">cb</span></span></tt> will be called immediately.</p>
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncfutures.nim#L249" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncfutures.nim#L249" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
<div id="addCallback,Future[T],proc(Future[T])">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#addCallback%2CFuture%5BT%5D%2Cproc%28Future%5BT%5D%29"><span class="Identifier">addCallback</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">future</span><span class="Other">:</span> <a href="asyncfutures.html#Future"><span class="Identifier">Future</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span>
|
||||
<span class="Identifier">cb</span><span class="Other">:</span> <span class="Keyword">proc</span> <span class="Other">(</span><span class="Identifier">future</span><span class="Other">:</span> <a href="asyncfutures.html#Future"><span class="Identifier">Future</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">)</span> {.<span class="Identifier">closure</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span></span>.}<span class="Other">)</span></pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Adds the callbacks proc to be called when the future completes.</p>
|
||||
<p>If future has already completed then <tt class="docutils literal"><span class="pre"><span class="Identifier">cb</span></span></tt> will be called immediately.</p>
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncfutures.nim#L259" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncfutures.nim#L259" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="all-procs-all">
|
||||
<div id="all,varargs[Future[T]]">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#all%2Cvarargs%5BFuture%5BT%5D%5D"><span class="Identifier">all</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">futs</span><span class="Other">:</span> <a href="system.html#varargs"><span class="Identifier">varargs</span></a><span class="Other">[</span><a href="asyncfutures.html#Future"><span class="Identifier">Future</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#auto"><span class="Identifier">auto</span></a></pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Returns a future which will complete once all futures in <tt class="docutils literal"><span class="pre"><span class="Identifier">futs</span></span></tt> complete. If the argument is empty, the returned future completes immediately.</p>
|
||||
<p>If the awaited futures are not <tt class="docutils literal"><span class="pre"><span class="Identifier">Future</span><span class="Punctuation">[</span><span class="Identifier">void</span><span class="Punctuation">]</span></span></tt>, the returned future will hold the values of all awaited futures in a sequence.</p>
|
||||
<p>If the awaited futures <em>are</em> <tt class="docutils literal"><span class="pre"><span class="Identifier">Future</span><span class="Punctuation">[</span><span class="Identifier">void</span><span class="Punctuation">]</span></span></tt>, this proc returns <tt class="docutils literal"><span class="pre"><span class="Identifier">Future</span><span class="Punctuation">[</span><span class="Identifier">void</span><span class="Punctuation">]</span></span></tt>.</p>
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncfutures.nim#L464" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncfutures.nim#L464" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="and-procs-all">
|
||||
<div id="and,Future[T],Future[Y]">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#and%2CFuture%5BT%5D%2CFuture%5BY%5D"><span class="Identifier">`and`</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">,</span> <span class="Identifier">Y</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">fut1</span><span class="Other">:</span> <a href="asyncfutures.html#Future"><span class="Identifier">Future</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">fut2</span><span class="Other">:</span> <a href="asyncfutures.html#Future"><span class="Identifier">Future</span></a><span class="Other">[</span><span class="Identifier">Y</span><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <a href="asyncfutures.html#Future"><span class="Identifier">Future</span></a><span class="Other">[</span><a href="system.html#void"><span class="Identifier">void</span></a><span class="Other">]</span></pre></dt>
|
||||
<dd>
|
||||
|
||||
Returns a future which will complete once both <tt class="docutils literal"><span class="pre"><span class="Identifier">fut1</span></span></tt> and <tt class="docutils literal"><span class="pre"><span class="Identifier">fut2</span></span></tt> complete.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncfutures.nim#L436" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncfutures.nim#L436" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="asyncCheck-procs-all">
|
||||
<div id="asyncCheck,Future[T]">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#asyncCheck%2CFuture%5BT%5D"><span class="Identifier">asyncCheck</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">future</span><span class="Other">:</span> <a href="asyncfutures.html#Future"><span class="Identifier">Future</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">)</span></pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Sets a callback on <tt class="docutils literal"><span class="pre"><span class="Identifier">future</span></span></tt> which raises an exception if the future finished with an error.</p>
|
||||
<p>This should be used instead of <tt class="docutils literal"><span class="pre"><span class="Keyword">discard</span></span></tt> to discard void futures, or use <tt class="docutils literal"><span class="pre"><span class="Identifier">waitFor</span></span></tt> if you need to wait for the future's completion.</p>
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncfutures.nim#L421" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncfutures.nim#L421" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="callback=-procs-all">
|
||||
<div id="callback=,FutureBase,proc)">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#callback%3D%2CFutureBase%2Cproc%29"><span class="Identifier">callback=</span></a><span class="Other">(</span><span class="Identifier">future</span><span class="Other">:</span> <a href="asyncfutures.html#FutureBase"><span class="Identifier">FutureBase</span></a><span class="Other">;</span> <span class="Identifier">cb</span><span class="Other">:</span> <span class="Keyword">proc</span> <span class="Other">(</span><span class="Other">)</span> {.<span class="Identifier">closure</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span></span>.}<span class="Other">)</span> {.
|
||||
<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">Exception</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">RootEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Clears the list of callbacks and sets the callback proc to be called when the future completes.</p>
|
||||
<p>If future has already completed then <tt class="docutils literal"><span class="pre"><span class="Identifier">cb</span></span></tt> will be called immediately.</p>
|
||||
<p>It's recommended to use <tt class="docutils literal"><span class="pre"><span class="Identifier">addCallback</span></span></tt> or <tt class="docutils literal"><span class="pre"><span class="Identifier">then</span></span></tt> instead.</p>
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncfutures.nim#L269" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncfutures.nim#L269" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
<div id="callback=,Future[T],proc(Future[T])">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#callback%3D%2CFuture%5BT%5D%2Cproc%28Future%5BT%5D%29"><span class="Identifier">callback=</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">future</span><span class="Other">:</span> <a href="asyncfutures.html#Future"><span class="Identifier">Future</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span>
|
||||
<span class="Identifier">cb</span><span class="Other">:</span> <span class="Keyword">proc</span> <span class="Other">(</span><span class="Identifier">future</span><span class="Other">:</span> <a href="asyncfutures.html#Future"><span class="Identifier">Future</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">)</span> {.<span class="Identifier">closure</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span></span>.}<span class="Other">)</span></pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Sets the callback proc to be called when the future completes.</p>
|
||||
<p>If future has already completed then <tt class="docutils literal"><span class="pre"><span class="Identifier">cb</span></span></tt> will be called immediately.</p>
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncfutures.nim#L278" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncfutures.nim#L278" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="callSoon-procs-all">
|
||||
<div id="callSoon,proc)">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#callSoon%2Cproc%29"><span class="Identifier">callSoon</span></a><span class="Other">(</span><span class="Identifier">cbproc</span><span class="Other">:</span> <span class="Keyword">proc</span> <span class="Other">(</span><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span></span>.}<span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">Exception</span><span class="Other">]</span><span class="Other">,</span>
|
||||
<span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">RootEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Call <tt class="docutils literal"><span class="pre"><span class="Identifier">cbproc</span></span></tt> "soon".</p>
|
||||
<p>If async dispatcher is running, <tt class="docutils literal"><span class="pre"><span class="Identifier">cbproc</span></span></tt> will be executed during next dispatcher tick.</p>
|
||||
<p>If async dispatcher is not running, <tt class="docutils literal"><span class="pre"><span class="Identifier">cbproc</span></span></tt> will be executed immediately.</p>
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncfutures.nim#L100" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncfutures.nim#L100" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="clean-procs-all">
|
||||
<div id="clean,FutureVar[T]">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#clean%2CFutureVar%5BT%5D"><span class="Identifier">clean</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">future</span><span class="Other">:</span> <a href="asyncfutures.html#FutureVar"><span class="Identifier">FutureVar</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">)</span></pre></dt>
|
||||
<dd>
|
||||
|
||||
Resets the <tt class="docutils literal"><span class="pre"><span class="Identifier">finished</span></span></tt> status of <tt class="docutils literal"><span class="pre"><span class="Identifier">future</span></span></tt>.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncfutures.nim#L139" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncfutures.nim#L139" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="clearCallbacks-procs-all">
|
||||
<div id="clearCallbacks,FutureBase">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#clearCallbacks%2CFutureBase"><span class="Identifier">clearCallbacks</span></a><span class="Other">(</span><span class="Identifier">future</span><span class="Other">:</span> <a href="asyncfutures.html#FutureBase"><span class="Identifier">FutureBase</span></a><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncfutures.nim#L245" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncfutures.nim#L245" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="complete-procs-all">
|
||||
<div id="complete,Future[void]">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#complete%2CFuture%5Bvoid%5D"><span class="Identifier">complete</span></a><span class="Other">(</span><span class="Identifier">future</span><span class="Other">:</span> <a href="asyncfutures.html#Future"><span class="Identifier">Future</span></a><span class="Other">[</span><a href="system.html#void"><span class="Identifier">void</span></a><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">val</span> <span class="Other">=</span> <a href="asyncfutures.html#Future"><span class="Identifier">Future</span></a><span class="Other">[</span><a href="system.html#void"><span class="Identifier">void</span></a><span class="Other">]</span><span class="Other">.</span><span class="Identifier">default</span><span class="Other">)</span> {.
|
||||
<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">Exception</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">RootEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncfutures.nim#L210" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncfutures.nim#L210" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
<div id="complete,Future[T],T">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#complete%2CFuture%5BT%5D%2CT"><span class="Identifier">complete</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">future</span><span class="Other">:</span> <a href="asyncfutures.html#Future"><span class="Identifier">Future</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">val</span><span class="Other">:</span> <span class="Identifier">T</span><span class="Other">)</span></pre></dt>
|
||||
<dd>
|
||||
|
||||
Completes <tt class="docutils literal"><span class="pre"><span class="Identifier">future</span></span></tt> with value <tt class="docutils literal"><span class="pre"><span class="Identifier">val</span></span></tt>.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncfutures.nim#L206" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncfutures.nim#L206" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
<div id="complete,FutureVar[T]">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#complete%2CFutureVar%5BT%5D"><span class="Identifier">complete</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">future</span><span class="Other">:</span> <a href="asyncfutures.html#FutureVar"><span class="Identifier">FutureVar</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">)</span></pre></dt>
|
||||
<dd>
|
||||
|
||||
Completes a <tt class="docutils literal"><span class="pre"><span class="Identifier">FutureVar</span></span></tt>.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncfutures.nim#L213" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncfutures.nim#L213" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
<div id="complete,FutureVar[T],T">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#complete%2CFutureVar%5BT%5D%2CT"><span class="Identifier">complete</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">future</span><span class="Other">:</span> <a href="asyncfutures.html#FutureVar"><span class="Identifier">FutureVar</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">val</span><span class="Other">:</span> <span class="Identifier">T</span><span class="Other">)</span></pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Completes a <tt class="docutils literal"><span class="pre"><span class="Identifier">FutureVar</span></span></tt> with value <tt class="docutils literal"><span class="pre"><span class="Identifier">val</span></span></tt>.</p>
|
||||
<p>Any previously stored value will be overwritten.</p>
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncfutures.nim#L222" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncfutures.nim#L222" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="fail-procs-all">
|
||||
<div id="fail,Future[T],ref.Exception">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#fail%2CFuture%5BT%5D%2Cref.Exception"><span class="Identifier">fail</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">future</span><span class="Other">:</span> <a href="asyncfutures.html#Future"><span class="Identifier">Future</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">error</span><span class="Other">:</span> <span class="Keyword">ref</span> <a href="system.html#Exception"><span class="Identifier">Exception</span></a><span class="Other">)</span></pre></dt>
|
||||
<dd>
|
||||
|
||||
Completes <tt class="docutils literal"><span class="pre"><span class="Identifier">future</span></span></tt> with <tt class="docutils literal"><span class="pre"><span class="Identifier">error</span></span></tt>.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncfutures.nim#L234" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncfutures.nim#L234" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="failed-procs-all">
|
||||
<div id="failed,FutureBase">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#failed%2CFutureBase"><span class="Identifier">failed</span></a><span class="Other">(</span><span class="Identifier">future</span><span class="Other">:</span> <a href="asyncfutures.html#FutureBase"><span class="Identifier">FutureBase</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#bool"><span class="Identifier">bool</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Determines whether <tt class="docutils literal"><span class="pre"><span class="Identifier">future</span></span></tt> completed with an error.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncfutures.nim#L417" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncfutures.nim#L417" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="finished-procs-all">
|
||||
<div id="finished">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#finished"><span class="Identifier">finished</span></a><span class="Other">(</span><span class="Identifier">future</span><span class="Other">:</span> <a href="asyncfutures.html#FutureBase"><span class="Identifier">FutureBase</span></a> <span class="Operator">|</span> <a href="asyncfutures.html#FutureVar"><span class="Identifier">FutureVar</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#bool"><span class="Identifier">bool</span></a></pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Determines whether <tt class="docutils literal"><span class="pre"><span class="Identifier">future</span></span></tt> has completed.</p>
|
||||
<p><tt class="docutils literal"><span class="pre"><span class="Identifier">True</span></span></tt> may indicate an error or a value. Use <tt class="docutils literal"><span class="pre"><span class="Identifier">failed</span></span></tt> to distinguish.</p>
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncfutures.nim#L408" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncfutures.nim#L408" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="getCallSoonProc-procs-all">
|
||||
<div id="getCallSoonProc">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#getCallSoonProc"><span class="Identifier">getCallSoonProc</span></a><span class="Other">(</span><span class="Other">)</span><span class="Other">:</span> <span class="Other">(</span><span class="Keyword">proc</span> <span class="Other">(</span><span class="Identifier">cbproc</span><span class="Other">:</span> <span class="Keyword">proc</span> <span class="Other">(</span><span class="Other">)</span><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span></span>.}<span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
|
||||
<span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Get current implementation of <tt class="docutils literal"><span class="pre"><span class="Identifier">callSoon</span></span></tt>.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncfutures.nim#L92" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncfutures.nim#L92" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="mget-procs-all">
|
||||
<div id="mget,FutureVar[T]">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#mget%2CFutureVar%5BT%5D"><span class="Identifier">mget</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">future</span><span class="Other">:</span> <a href="asyncfutures.html#FutureVar"><span class="Identifier">FutureVar</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <span class="Keyword">var</span> <span class="Identifier">T</span></pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Returns a mutable value stored in <tt class="docutils literal"><span class="pre"><span class="Identifier">future</span></span></tt>.</p>
|
||||
<p>Unlike <tt class="docutils literal"><span class="pre"><span class="Identifier">read</span></span></tt>, this function will not raise an exception if the Future has not been finished.</p>
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncfutures.nim#L401" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncfutures.nim#L401" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="newFuture-procs-all">
|
||||
<div id="newFuture,string">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#newFuture%2Cstring"><span class="Identifier">newFuture</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">fromProc</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> <span class="Other">=</span> <span class="StringLit">"unspecified"</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">owned</span><span class="Other">(</span><a href="asyncfutures.html#Future"><span class="Identifier">Future</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">)</span></pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Creates a new future.</p>
|
||||
<p>Specifying <tt class="docutils literal"><span class="pre"><span class="Identifier">fromProc</span></span></tt>, which is a string specifying the name of the proc that this future belongs to, is a good habit as it helps with debugging.</p>
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncfutures.nim#L121" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncfutures.nim#L121" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="newFutureVar-procs-all">
|
||||
<div id="newFutureVar,string">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#newFutureVar%2Cstring"><span class="Identifier">newFutureVar</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">fromProc</span> <span class="Other">=</span> <span class="StringLit">"unspecified"</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">owned</span><span class="Other">(</span><a href="asyncfutures.html#FutureVar"><span class="Identifier">FutureVar</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">)</span></pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Create a new <tt class="docutils literal"><span class="pre"><span class="Identifier">FutureVar</span></span></tt>. This Future type is ideally suited for situations where you want to avoid unnecessary allocations of Futures.</p>
|
||||
<p>Specifying <tt class="docutils literal"><span class="pre"><span class="Identifier">fromProc</span></span></tt>, which is a string specifying the name of the proc that this future belongs to, is a good habit as it helps with debugging.</p>
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncfutures.nim#L129" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncfutures.nim#L129" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="or-procs-all">
|
||||
<div id="or,Future[T],Future[Y]">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#or%2CFuture%5BT%5D%2CFuture%5BY%5D"><span class="Identifier">`or`</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">,</span> <span class="Identifier">Y</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">fut1</span><span class="Other">:</span> <a href="asyncfutures.html#Future"><span class="Identifier">Future</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">fut2</span><span class="Other">:</span> <a href="asyncfutures.html#Future"><span class="Identifier">Future</span></a><span class="Other">[</span><span class="Identifier">Y</span><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <a href="asyncfutures.html#Future"><span class="Identifier">Future</span></a><span class="Other">[</span><a href="system.html#void"><span class="Identifier">void</span></a><span class="Other">]</span></pre></dt>
|
||||
<dd>
|
||||
|
||||
Returns a future which will complete once either <tt class="docutils literal"><span class="pre"><span class="Identifier">fut1</span></span></tt> or <tt class="docutils literal"><span class="pre"><span class="Identifier">fut2</span></span></tt> complete.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncfutures.nim#L452" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncfutures.nim#L452" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="read-procs-all">
|
||||
<div id="read">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#read"><span class="Identifier">read</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">future</span><span class="Other">:</span> <a href="asyncfutures.html#Future"><span class="Identifier">Future</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span> <span class="Operator">|</span> <a href="asyncfutures.html#FutureVar"><span class="Identifier">FutureVar</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">T</span></pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Retrieves the value of <tt class="docutils literal"><span class="pre"><span class="Identifier">future</span></span></tt>. Future must be finished otherwise this function will fail with a <tt class="docutils literal"><span class="pre"><span class="Identifier">ValueError</span></span></tt> exception.</p>
|
||||
<p>If the result of the future is an error then that error will be raised.</p>
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncfutures.nim#L373" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncfutures.nim#L373" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="readError-procs-all">
|
||||
<div id="readError,Future[T]">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#readError%2CFuture%5BT%5D"><span class="Identifier">readError</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">future</span><span class="Other">:</span> <a href="asyncfutures.html#Future"><span class="Identifier">Future</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <span class="Keyword">ref</span> <a href="system.html#Exception"><span class="Identifier">Exception</span></a></pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Retrieves the exception stored in <tt class="docutils literal"><span class="pre"><span class="Identifier">future</span></span></tt>.</p>
|
||||
<p>An <tt class="docutils literal"><span class="pre"><span class="Identifier">ValueError</span></span></tt> exception will be thrown if no exception exists in the specified Future.</p>
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncfutures.nim#L392" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncfutures.nim#L392" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="setCallSoonProc-procs-all">
|
||||
<div id="setCallSoonProc">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#setCallSoonProc"><span class="Identifier">setCallSoonProc</span></a><span class="Other">(</span><span class="Identifier">p</span><span class="Other">:</span> <span class="Other">(</span><span class="Keyword">proc</span> <span class="Other">(</span><span class="Identifier">cbproc</span><span class="Other">:</span> <span class="Keyword">proc</span> <span class="Other">(</span><span class="Other">)</span><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span></span>.}<span class="Other">)</span><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
|
||||
<span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Change current implementation of <tt class="docutils literal"><span class="pre"><span class="Identifier">callSoon</span></span></tt>. This is normally called when dispatcher from <tt class="docutils literal"><span class="pre"><span class="Identifier">asyncdispatcher</span></span></tt> is initialized.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncfutures.nim#L96" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncfutures.nim#L96" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="twelve-columns footer">
|
||||
<span class="nim-sprite"></span>
|
||||
<br>
|
||||
<small style="color: var(--hint);">Made with Nim. Generated: 2023-03-13 00:19:17 UTC</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script defer data-domain="nim-lang.org" src="https://plausible.io/js/plausible.js"></script>
|
||||
|
||||
<!-- Google fonts -->
|
||||
<link href='https://fonts.googleapis.com/css?family=Lato:400,600,900' rel='stylesheet' type='text/css'/>
|
||||
<link href='https://fonts.googleapis.com/css?family=Source+Code+Pro:400,500,600' rel='stylesheet' type='text/css'/>
|
||||
</body>
|
||||
</html>
|
||||
36
asyncfutures.idx
Normal file
36
asyncfutures.idx
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
nimTitle asyncfutures asyncfutures.html module std/asyncfutures 0
|
||||
nim FutureBase asyncfutures.html#FutureBase type FutureBase 26
|
||||
nim Future asyncfutures.html#Future type Future 37
|
||||
nim FutureVar asyncfutures.html#FutureVar type FutureVar 40
|
||||
nim FutureError asyncfutures.html#FutureError object FutureError 42
|
||||
nim isFutureLoggingEnabled asyncfutures.html#isFutureLoggingEnabled const isFutureLoggingEnabled 48
|
||||
nim NimAsyncContinueSuffix asyncfutures.html#NimAsyncContinueSuffix const NimAsyncContinueSuffix 51
|
||||
nim getCallSoonProc asyncfutures.html#getCallSoonProc proc getCallSoonProc(): (proc (cbproc: proc ()) {.gcsafe.}) 92
|
||||
nim setCallSoonProc asyncfutures.html#setCallSoonProc proc setCallSoonProc(p: (proc (cbproc: proc ()) {.gcsafe.})) 96
|
||||
nim callSoon asyncfutures.html#callSoon,proc) proc callSoon(cbproc: proc () {.gcsafe.}) 100
|
||||
nim newFuture asyncfutures.html#newFuture,string proc newFuture[T](fromProc: string = "unspecified"): owned(Future[T]) 121
|
||||
nim newFutureVar asyncfutures.html#newFutureVar,string proc newFutureVar[T](fromProc = "unspecified"): owned(FutureVar[T]) 129
|
||||
nim clean asyncfutures.html#clean,FutureVar[T] proc clean[T](future: FutureVar[T]) 139
|
||||
nim complete asyncfutures.html#complete,Future[T],T proc complete[T](future: Future[T]; val: T) 206
|
||||
nim complete asyncfutures.html#complete,Future[void] proc complete(future: Future[void]; val = Future[void].default) 210
|
||||
nim complete asyncfutures.html#complete,FutureVar[T] proc complete[T](future: FutureVar[T]) 213
|
||||
nim complete asyncfutures.html#complete,FutureVar[T],T proc complete[T](future: FutureVar[T]; val: T) 222
|
||||
nim fail asyncfutures.html#fail,Future[T],ref.Exception proc fail[T](future: Future[T]; error: ref Exception) 234
|
||||
nim clearCallbacks asyncfutures.html#clearCallbacks,FutureBase proc clearCallbacks(future: FutureBase) 245
|
||||
nim addCallback asyncfutures.html#addCallback,FutureBase,proc) proc addCallback(future: FutureBase; cb: proc () {.closure, gcsafe.}) 249
|
||||
nim addCallback asyncfutures.html#addCallback,Future[T],proc(Future[T]) proc addCallback[T](future: Future[T];\n cb: proc (future: Future[T]) {.closure, gcsafe.}) 259
|
||||
nim callback= asyncfutures.html#callback=,FutureBase,proc) proc callback=(future: FutureBase; cb: proc () {.closure, gcsafe.}) 269
|
||||
nim callback= asyncfutures.html#callback=,Future[T],proc(Future[T]) proc callback=[T](future: Future[T]; cb: proc (future: Future[T]) {.closure, gcsafe.}) 278
|
||||
nim `$` asyncfutures.html#$,seq[StackTraceEntry] proc `$`(stackTraceEntries: seq[StackTraceEntry]): string 314
|
||||
nim read asyncfutures.html#read proc read[T](future: Future[T] | FutureVar[T]): T 373
|
||||
nim readError asyncfutures.html#readError,Future[T] proc readError[T](future: Future[T]): ref Exception 392
|
||||
nim mget asyncfutures.html#mget,FutureVar[T] proc mget[T](future: FutureVar[T]): var T 401
|
||||
nim finished asyncfutures.html#finished proc finished(future: FutureBase | FutureVar): bool 408
|
||||
nim failed asyncfutures.html#failed,FutureBase proc failed(future: FutureBase): bool 417
|
||||
nim asyncCheck asyncfutures.html#asyncCheck,Future[T] proc asyncCheck[T](future: Future[T]) 421
|
||||
nim `and` asyncfutures.html#and,Future[T],Future[Y] proc `and`[T, Y](fut1: Future[T]; fut2: Future[Y]): Future[void] 436
|
||||
nim `or` asyncfutures.html#or,Future[T],Future[Y] proc `or`[T, Y](fut1: Future[T]; fut2: Future[Y]): Future[void] 452
|
||||
nim all asyncfutures.html#all,varargs[Future[T]] proc all[T](futs: varargs[Future[T]]): auto 464
|
||||
nimgrp addcallback asyncfutures.html#addCallback-procs-all proc 249
|
||||
nimgrp callback= asyncfutures.html#callback=-procs-all proc 269
|
||||
nimgrp complete asyncfutures.html#complete-procs-all proc 206
|
||||
416
asynchttpserver.html
Normal file
416
asynchttpserver.html
Normal file
File diff suppressed because one or more lines are too long
13
asynchttpserver.idx
Normal file
13
asynchttpserver.idx
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
nimTitle asynchttpserver asynchttpserver.html module std/asynchttpserver 0
|
||||
nim Request asynchttpserver.html#Request object Request 61
|
||||
nim AsyncHttpServer asynchttpserver.html#AsyncHttpServer type AsyncHttpServer 70
|
||||
nim getPort asynchttpserver.html#getPort,AsyncHttpServer proc getPort(self: AsyncHttpServer): Port 77
|
||||
nim newAsyncHttpServer asynchttpserver.html#newAsyncHttpServer,int proc newAsyncHttpServer(reuseAddr = true; reusePort = false; maxBody = 8388608): AsyncHttpServer 90
|
||||
nim sendHeaders asynchttpserver.html#sendHeaders,Request,HttpHeaders proc sendHeaders(req: Request; headers: HttpHeaders): Future[void] 99
|
||||
nim respond asynchttpserver.html#respond,Request,HttpCode,string,HttpHeaders proc respond(req: Request; code: HttpCode; content: string;\n headers: HttpHeaders = nil): Future[void] 105
|
||||
nim nimMaxDescriptorsFallback asynchttpserver.html#nimMaxDescriptorsFallback const nimMaxDescriptorsFallback 376
|
||||
nim listen asynchttpserver.html#listen,AsyncHttpServer,Port,string proc listen(server: AsyncHttpServer; port: Port; address = ""; domain = AF_INET) 381
|
||||
nim shouldAcceptRequest asynchttpserver.html#shouldAcceptRequest,AsyncHttpServer,int proc shouldAcceptRequest(server: AsyncHttpServer; assumedDescriptorsPerRequest = 5): bool 396
|
||||
nim acceptRequest asynchttpserver.html#acceptRequest,AsyncHttpServer,proc(Request) proc acceptRequest(server: AsyncHttpServer; callback: proc (request: Request): Future[\n void] {.closure, gcsafe.}): owned(Future[void]) 405
|
||||
nim serve asynchttpserver.html#serve,AsyncHttpServer,Port,proc(Request),string,int proc serve(server: AsyncHttpServer; port: Port;\n callback: proc (request: Request): Future[void] {.closure, gcsafe.};\n address = ""; assumedDescriptorsPerRequest = -1; domain = AF_INET): owned(\n Future[void]) 415
|
||||
nim close asynchttpserver.html#close,AsyncHttpServer proc close(server: AsyncHttpServer) 438
|
||||
334
asyncjs.html
Normal file
334
asyncjs.html
Normal file
|
|
@ -0,0 +1,334 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<!-- This file is generated by Nim. -->
|
||||
<html xmlns="https://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>std/asyncjs</title>
|
||||
|
||||
<!-- Favicon -->
|
||||
<link rel="shortcut icon" href="data:image/x-icon;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAUAAAAF////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAIAAABbAAAAlQAAAKIAAACbAAAAmwAAAKIAAACVAAAAWwAAAAL///8A////AP///wD///8A////AAAAABQAAADAAAAAYwAAAA3///8A////AP///wD///8AAAAADQAAAGMAAADAAAAAFP///wD///8A////AP///wAAAACdAAAAOv///wD///8A////AP///wD///8A////AP///wD///8AAAAAOgAAAJ3///8A////AP///wAAAAAnAAAAcP///wAAAAAoAAAASv///wD///8A////AP///wAAAABKAAAAKP///wAAAABwAAAAJ////wD///8AAAAAgQAAABwAAACIAAAAkAAAAJMAAACtAAAAFQAAABUAAACtAAAAkwAAAJAAAACIAAAAHAAAAIH///8A////AAAAAKQAAACrAAAAaP///wD///8AAAAARQAAANIAAADSAAAARf///wD///8AAAAAaAAAAKsAAACk////AAAAADMAAACcAAAAnQAAABj///8A////AP///wAAAAAYAAAAGP///wD///8A////AAAAABgAAACdAAAAnAAAADMAAAB1AAAAwwAAAP8AAADpAAAAsQAAAE4AAAAb////AP///wAAAAAbAAAATgAAALEAAADpAAAA/wAAAMMAAAB1AAAAtwAAAOkAAAD/AAAA/wAAAP8AAADvAAAA3gAAAN4AAADeAAAA3gAAAO8AAAD/AAAA/wAAAP8AAADpAAAAtwAAAGUAAAA/AAAA3wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAADfAAAAPwAAAGX///8A////AAAAAEgAAADtAAAAvwAAAL0AAADGAAAA7wAAAO8AAADGAAAAvQAAAL8AAADtAAAASP///wD///8A////AP///wD///8AAAAAO////wD///8A////AAAAAIcAAACH////AP///wD///8AAAAAO////wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A//8AAP//AAD4HwAA7/cAAN/7AAD//wAAoYUAAJ55AACf+QAAh+EAAAAAAADAAwAA4AcAAP5/AAD//wAA//8AAA=="/>
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAA3XAAAN1wFCKJt4AAAAB3RJTUUH4QQQEwksSS9ZWwAAAk1JREFUWMPtll2ITVEUx39nn/O7Y5qR8f05wtCUUr6ZIS++8pEnkZInPImneaCQ5METNdOkeFBKUhMPRIkHKfEuUZSUlGlKPN2TrgfncpvmnntnmlEyq1Z7t89/rf9a6+y99oZxGZf/XeIq61EdtgKXgdXA0xrYAvBjOIF1AI9zvjcC74BSpndrJPkBWDScTF8Aa4E3wDlgHbASaANmVqlcCnwHvgDvgVfAJ+AikAAvgfVZwLnSVZHZaOuKoQi3ZOMi4NkYkpe1p4J7A8BpYAD49hfIy/oqG0+hLomiKP2L5L+1ubn5115S+3OAn4EnwBlgMzCjyt6ZAnQCJ4A7wOs88iRJHvw50HoujuPBoCKwHWiosy8MdfZnAdcHk8dxXFJ3VQbQlCTJvRBCGdRbD4M6uc5glpY3eAihpN5S5w12diSEcCCEcKUO4ljdr15T76ur1FDDLIQQ3qv71EdDOe3Kxj3leRXyk+pxdWnFWod6Wt2bY3de3aSuUHcPBVimHs7mK9WrmeOF6lR1o9qnzskh2ar2qm1qizpfXaPeVGdlmGN5pb09qMxz1Xb1kLqgzn1RyH7JUXW52lr5e/Kqi9qpto7V1atuUzfnARrV7jEib1T76gG2qxdGmXyiekkt1GswPTtek0aBfJp6YySGBfWg2tPQ0FAYgf1stUfdmdcjarbYJEniKIq6gY/Aw+zWHAC+p2labGpqiorFYgGYCEzN7oQdQClN07O1/EfDyGgC0ALMBdYAi4FyK+4H3gLPsxfR1zRNi+NP7nH5J+QntnXe5B5mpfQAAAAASUVORK5CYII=">
|
||||
|
||||
<!-- CSS -->
|
||||
<link rel="stylesheet" type="text/css" href="nimdoc.out.css">
|
||||
|
||||
<!-- JS -->
|
||||
<script type="text/javascript" src="dochack.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="document" id="documentId">
|
||||
<div class="container">
|
||||
<h1 class="title">std/asyncjs</h1>
|
||||
<div class="row">
|
||||
<div class="three columns">
|
||||
<div class="theme-select-wrapper">
|
||||
<label for="theme-select">Theme: </label>
|
||||
<select id="theme-select" onchange="setTheme(this.value)">
|
||||
<option value="auto">🌗 Match OS</option>
|
||||
<option value="dark">🌑 Dark</option>
|
||||
<option value="light">🌕 Light</option>
|
||||
</select>
|
||||
</div>
|
||||
<div id="global-links">
|
||||
<ul class="simple-boot">
|
||||
<li><a href="manual.html">Manual</a></li>
|
||||
<li><a href="lib.html">Standard library</a></li>
|
||||
<li> <a id="indexLink" href="theindex.html">Index</a></li>
|
||||
<li><a href="compiler/theindex.html">Compiler docs</a></li>
|
||||
<li><a href="https://nim-lang.github.io/fusion/theindex.html">Fusion docs</a></li>
|
||||
<li><a href="https://nim-lang.github.io/Nim/">devel</a>, <a href="https://nim-lang.org/documentation.html">stable</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="searchInputDiv">
|
||||
Search: <input type="search" id="searchInput"
|
||||
onkeyup="search()" />
|
||||
</div>
|
||||
|
||||
<ul class="simple simple-toc" id="toc-list">
|
||||
<li><a class="reference" id="javascript-compatibility_toc" href="#javascript-compatibility">JavaScript compatibility</a></li>
|
||||
<li>
|
||||
<a class="reference reference-toplevel" href="#6" id="56">Imports</a>
|
||||
</li>
|
||||
<li>
|
||||
<details open>
|
||||
<summary><a class="reference reference-toplevel" href="#7" id="57">Types</a></summary>
|
||||
<ul class="simple simple-toc-section">
|
||||
<li><a class="reference" href="#Error" title="Error {.importjs: "Error".} = ref object of JsRoot
|
||||
message*: cstring
|
||||
name*: cstring">Error</a></li>
|
||||
<li><a class="reference" href="#Future" title="Future[T] = ref object
|
||||
future*: T">Future</a></li>
|
||||
<li><a class="reference" href="#OnReject" title="OnReject = proc (reason: Error)">OnReject</a></li>
|
||||
<li><a class="reference" href="#PromiseJs" title="PromiseJs {.importjs: "Promise".} = ref object">PromiseJs</a></li>
|
||||
|
||||
</ul>
|
||||
</details>
|
||||
</li>
|
||||
<li>
|
||||
<details open>
|
||||
<summary><a class="reference reference-toplevel" href="#12" id="62">Procs</a></summary>
|
||||
<ul class="simple simple-toc-section">
|
||||
<ul class="simple nested-toc-section">catch
|
||||
<li><a class="reference" href="#catch%2CFuture%5BT%5D%2COnReject" title="catch[T](future: Future[T]; onReject: OnReject): Future[void]">catch[T](future: Future[T]; onReject: OnReject): Future[void]</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">newPromise
|
||||
<li><a class="reference" href="#newPromise%2Cproc%28proc%29%29" title="newPromise(handler: proc (resolve: proc ())): Future[void]">newPromise(handler: proc (resolve: proc ())): Future[void]</a></li>
|
||||
<li><a class="reference" href="#newPromise%2Cproc%28proc%28T%29%29" title="newPromise[T](handler: proc (resolve: proc (response: T))): Future[T]">newPromise[T](handler: proc (resolve: proc (response: T))): Future[T]</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">then
|
||||
<li><a class="reference" href="#then%2CFuture%5BT%5D%2Cproc%2COnReject" title="then[T](future: Future[T]; onSuccess: proc; onReject: OnReject = nil): auto">then[T](future: Future[T]; onSuccess: proc; onReject: OnReject = nil): auto</a></li>
|
||||
|
||||
</ul>
|
||||
|
||||
</ul>
|
||||
</details>
|
||||
</li>
|
||||
<li>
|
||||
<details open>
|
||||
<summary><a class="reference reference-toplevel" href="#17" id="67">Macros</a></summary>
|
||||
<ul class="simple simple-toc-section">
|
||||
<ul class="simple nested-toc-section">async
|
||||
<li><a class="reference" href="#async.m%2Cuntyped" title="async(arg: untyped): untyped">async(arg: untyped): untyped</a></li>
|
||||
|
||||
</ul>
|
||||
|
||||
</ul>
|
||||
</details>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
<div class="nine columns" id="content">
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/js/asyncjs.nim#L1" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/js/asyncjs.nim#L1" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
<div id="tocRoot"></div>
|
||||
|
||||
<p class="module-desc"><p>This module implements types and macros for writing asynchronous code for the JS backend. It provides tools for interaction with JavaScript async API-s and libraries, writing async procedures in Nim and converting callback-based code to promises.</p>
|
||||
<p>A Nim procedure is asynchronous when it includes the <tt class="docutils literal"><span class="pre"><span class="Punctuation">{</span><span class="Operator">.</span><span class="Identifier">async</span><span class="Operator">.</span><span class="Punctuation">}</span></span></tt> pragma. It should always have a <tt class="docutils literal"><span class="pre"><span class="Identifier">Future</span><span class="Punctuation">[</span><span class="Identifier">T</span><span class="Punctuation">]</span></span></tt> return type or not have a return type at all. A <tt class="docutils literal"><span class="pre"><span class="Identifier">Future</span><span class="Punctuation">[</span><span class="Identifier">void</span><span class="Punctuation">]</span></span></tt> return type is assumed by default.</p>
|
||||
<p>This is roughly equivalent to the <tt class="docutils literal"><span class="pre"><span class="Identifier">async</span></span></tt> keyword in JavaScript code.</p>
|
||||
<p><pre class="listing">
|
||||
<span class="Keyword">proc</span> <span class="Identifier">loadGame</span><span class="Punctuation">(</span><span class="Identifier">name</span><span class="Punctuation">:</span> <span class="Identifier">string</span><span class="Punctuation">)</span><span class="Punctuation">:</span> <span class="Identifier">Future</span><span class="Punctuation">[</span><span class="Identifier">Game</span><span class="Punctuation">]</span> <span class="Punctuation">{</span><span class="Operator">.</span><span class="Identifier">async</span><span class="Operator">.</span><span class="Punctuation">}</span> <span class="Operator">=</span>
|
||||
<span class="Comment"># code</span></pre></p>
|
||||
<p>should be equivalent to</p>
|
||||
<p><pre class="listing">
|
||||
async function loadGame(name) {
|
||||
// code
|
||||
}</pre></p>
|
||||
<p>A call to an asynchronous procedure usually needs <tt class="docutils literal"><span class="pre"><span class="Identifier">await</span></span></tt> to wait for the completion of the <tt class="docutils literal"><span class="pre"><span class="Identifier">Future</span></span></tt>.</p>
|
||||
<p><pre class="listing">
|
||||
<span class="Keyword">var</span> <span class="Identifier">game</span> <span class="Operator">=</span> <span class="Identifier">await</span> <span class="Identifier">loadGame</span><span class="Punctuation">(</span><span class="Identifier">name</span><span class="Punctuation">)</span></pre></p>
|
||||
<p>Often, you might work with callback-based API-s. You can wrap them with asynchronous procedures using promises and <tt class="docutils literal"><span class="pre"><span class="Identifier">newPromise</span></span></tt>:</p>
|
||||
<p><pre class="listing">
|
||||
<span class="Keyword">proc</span> <span class="Identifier">loadGame</span><span class="Punctuation">(</span><span class="Identifier">name</span><span class="Punctuation">:</span> <span class="Identifier">string</span><span class="Punctuation">)</span><span class="Punctuation">:</span> <span class="Identifier">Future</span><span class="Punctuation">[</span><span class="Identifier">Game</span><span class="Punctuation">]</span> <span class="Operator">=</span>
|
||||
<span class="Keyword">var</span> <span class="Identifier">promise</span> <span class="Operator">=</span> <span class="Identifier">newPromise</span><span class="Punctuation">(</span><span class="Punctuation">)</span> <span class="Keyword">do</span> <span class="Punctuation">(</span><span class="Identifier">resolve</span><span class="Punctuation">:</span> <span class="Keyword">proc</span><span class="Punctuation">(</span><span class="Identifier">response</span><span class="Punctuation">:</span> <span class="Identifier">Game</span><span class="Punctuation">)</span><span class="Punctuation">)</span><span class="Punctuation">:</span>
|
||||
<span class="Identifier">cbBasedLoadGame</span><span class="Punctuation">(</span><span class="Identifier">name</span><span class="Punctuation">)</span> <span class="Keyword">do</span> <span class="Punctuation">(</span><span class="Identifier">game</span><span class="Punctuation">:</span> <span class="Identifier">Game</span><span class="Punctuation">)</span><span class="Punctuation">:</span>
|
||||
<span class="Identifier">resolve</span><span class="Punctuation">(</span><span class="Identifier">game</span><span class="Punctuation">)</span>
|
||||
<span class="Keyword">return</span> <span class="Identifier">promise</span></pre></p>
|
||||
<p>Forward definitions work properly, you just need to always add the <tt class="docutils literal"><span class="pre"><span class="Punctuation">{</span><span class="Operator">.</span><span class="Identifier">async</span><span class="Operator">.</span><span class="Punctuation">}</span></span></tt> pragma:</p>
|
||||
<p><pre class="listing">
|
||||
<span class="Keyword">proc</span> <span class="Identifier">loadGame</span><span class="Punctuation">(</span><span class="Identifier">name</span><span class="Punctuation">:</span> <span class="Identifier">string</span><span class="Punctuation">)</span><span class="Punctuation">:</span> <span class="Identifier">Future</span><span class="Punctuation">[</span><span class="Identifier">Game</span><span class="Punctuation">]</span> <span class="Punctuation">{</span><span class="Operator">.</span><span class="Identifier">async</span><span class="Operator">.</span><span class="Punctuation">}</span></pre></p>
|
||||
|
||||
<h1><a class="toc-backref" id="javascript-compatibility" href="#javascript-compatibility">JavaScript compatibility</a></h1><p>Nim currently generates <tt class="docutils literal"><span class="pre"><span class="Identifier">async</span><span class="Operator">/</span><span class="Identifier">await</span></span></tt> JavaScript code which is supported in modern EcmaScript and most modern versions of browsers, Node.js and Electron. If you need to use this module with older versions of JavaScript, you can use a tool that backports the resulting JavaScript code, as babel.</p>
|
||||
</p>
|
||||
<div class="section" id="6">
|
||||
<h1><a class="toc-backref" href="#6">Imports</a></h1>
|
||||
<dl class="item">
|
||||
<a class="reference external" href="jsffi.html">jsffi</a>, <a class="reference external" href="macros.html">macros</a>, <a class="reference external" href="since.html">since</a>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="section" id="7">
|
||||
<h1><a class="toc-backref" href="#7">Types</a></h1>
|
||||
<dl class="item">
|
||||
<div id="Error">
|
||||
<dt><pre><a href="asyncjs.html#Error"><span class="Identifier">Error</span></a> {.<span class="Identifier">importjs</span><span class="Other">:</span> <span class="StringLit">"Error"</span>.} <span class="Other">=</span> <span class="Keyword">ref</span> <span class="Keyword">object</span> <span class="Keyword">of</span> <a href="system.html#JsRoot"><span class="Identifier">JsRoot</span></a>
|
||||
<span class="Identifier">message</span><span class="Operator">*</span><span class="Other">:</span> <a href="system.html#cstring"><span class="Identifier">cstring</span></a>
|
||||
<span class="Identifier">name</span><span class="Operator">*</span><span class="Other">:</span> <a href="system.html#cstring"><span class="Identifier">cstring</span></a>
|
||||
</pre></dt>
|
||||
<dd>
|
||||
|
||||
<a class="reference external" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Error</a>
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/js/asyncjs.nim#L193" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/js/asyncjs.nim#L193" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
<div id="Future">
|
||||
<dt><pre><a href="asyncjs.html#Future"><span class="Identifier">Future</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span> <span class="Other">=</span> <span class="Keyword">ref</span> <span class="Keyword">object</span>
|
||||
<span class="Identifier">future</span><span class="Operator">*</span><span class="Other">:</span> <span class="Identifier">T</span>
|
||||
</pre></dt>
|
||||
<dd>
|
||||
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/js/asyncjs.nim#L75" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/js/asyncjs.nim#L75" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
<div id="OnReject">
|
||||
<dt><pre><a href="asyncjs.html#OnReject"><span class="Identifier">OnReject</span></a> <span class="Other">=</span> <span class="Keyword">proc</span> <span class="Other">(</span><span class="Identifier">reason</span><span class="Other">:</span> <a href="asyncjs.html#Error"><span class="Identifier">Error</span></a><span class="Other">)</span></pre></dt>
|
||||
<dd>
|
||||
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/js/asyncjs.nim#L198" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/js/asyncjs.nim#L198" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
<div id="PromiseJs">
|
||||
<dt><pre><a href="asyncjs.html#PromiseJs"><span class="Identifier">PromiseJs</span></a> {.<span class="Identifier">importjs</span><span class="Other">:</span> <span class="StringLit">"Promise"</span>.} <span class="Other">=</span> <span class="Keyword">ref</span> <span class="Keyword">object</span></pre></dt>
|
||||
<dd>
|
||||
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/js/asyncjs.nim#L79" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/js/asyncjs.nim#L79" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</dl>
|
||||
</div>
|
||||
<div class="section" id="12">
|
||||
<h1><a class="toc-backref" href="#12">Procs</a></h1>
|
||||
<dl class="item">
|
||||
<div id="catch-procs-all">
|
||||
<div id="catch,Future[T],OnReject">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#catch%2CFuture%5BT%5D%2COnReject"><span class="Identifier">catch</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">future</span><span class="Other">:</span> <a href="asyncjs.html#Future"><span class="Identifier">Future</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">onReject</span><span class="Other">:</span> <a href="asyncjs.html#OnReject"><span class="Identifier">OnReject</span></a><span class="Other">)</span><span class="Other">:</span> <a href="asyncjs.html#Future"><span class="Identifier">Future</span></a><span class="Other">[</span><a href="system.html#void"><span class="Identifier">void</span></a><span class="Other">]</span></pre></dt>
|
||||
<dd>
|
||||
|
||||
See <a class="reference external" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/catch">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/catch</a>
|
||||
<p><strong class="examples_text">Example: cmd: -r:off</strong></p>
|
||||
<pre class="listing"><span class="Keyword">from</span> <span class="Identifier">std</span><span class="Operator">/</span><span class="Identifier">sugar</span> <span class="Keyword">import</span> <span class="Punctuation">`</span><span class="Operator">=></span><span class="Punctuation">`</span>
|
||||
<span class="Keyword">from</span> <span class="Identifier">std</span><span class="Operator">/</span><span class="Identifier">strutils</span> <span class="Keyword">import</span> <span class="Identifier">contains</span>
|
||||
|
||||
<span class="Keyword">proc</span> <span class="Identifier">fn</span><span class="Punctuation">(</span><span class="Identifier">n</span><span class="Punctuation">:</span> <span class="Identifier">int</span><span class="Punctuation">)</span><span class="Punctuation">:</span> <span class="Identifier">Future</span><span class="Punctuation">[</span><span class="Identifier">int</span><span class="Punctuation">]</span> <span class="Punctuation">{</span><span class="Operator">.</span><span class="Identifier">async</span><span class="Operator">.</span><span class="Punctuation">}</span> <span class="Operator">=</span>
|
||||
<span class="Keyword">if</span> <span class="Identifier">n</span> <span class="Operator">>=</span> <span class="DecNumber">7</span><span class="Punctuation">:</span> <span class="Keyword">raise</span> <span class="Identifier">newException</span><span class="Punctuation">(</span><span class="Identifier">ValueError</span><span class="Punctuation">,</span> <span class="StringLit">"foobar: "</span> <span class="Operator">&</span> <span class="Operator">$</span><span class="Identifier">n</span><span class="Punctuation">)</span>
|
||||
<span class="Keyword">else</span><span class="Punctuation">:</span> <span class="Identifier">result</span> <span class="Operator">=</span> <span class="Identifier">n</span> <span class="Operator">*</span> <span class="DecNumber">2</span>
|
||||
|
||||
<span class="Keyword">proc</span> <span class="Identifier">main</span><span class="Punctuation">(</span><span class="Punctuation">)</span> <span class="Punctuation">{</span><span class="Operator">.</span><span class="Identifier">async</span><span class="Operator">.</span><span class="Punctuation">}</span> <span class="Operator">=</span>
|
||||
<span class="Keyword">var</span> <span class="Identifier">reason</span><span class="Punctuation">:</span> <span class="Identifier">Error</span>
|
||||
<span class="Identifier">await</span> <span class="Identifier">fn</span><span class="Punctuation">(</span><span class="DecNumber">6</span><span class="Punctuation">)</span><span class="Operator">.</span><span class="Identifier">catch</span><span class="Punctuation">(</span><span class="Punctuation">(</span><span class="Identifier">r</span><span class="Punctuation">:</span> <span class="Identifier">Error</span><span class="Punctuation">)</span> <span class="Operator">=></span> <span class="Punctuation">(</span><span class="Identifier">reason</span> <span class="Operator">=</span> <span class="Identifier">r</span><span class="Punctuation">)</span><span class="Punctuation">)</span> <span class="Comment"># note: `()` are needed, `=> reason = r` would not work</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">reason</span> <span class="Operator">==</span> <span class="Keyword">nil</span>
|
||||
<span class="Identifier">await</span> <span class="Identifier">fn</span><span class="Punctuation">(</span><span class="DecNumber">7</span><span class="Punctuation">)</span><span class="Operator">.</span><span class="Identifier">catch</span><span class="Punctuation">(</span><span class="Punctuation">(</span><span class="Identifier">r</span><span class="Punctuation">:</span> <span class="Identifier">Error</span><span class="Punctuation">)</span> <span class="Operator">=></span> <span class="Punctuation">(</span><span class="Identifier">reason</span> <span class="Operator">=</span> <span class="Identifier">r</span><span class="Punctuation">)</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">reason</span> <span class="Operator">!=</span> <span class="Keyword">nil</span>
|
||||
<span class="Identifier">assert</span> <span class="StringLit">"foobar: 7"</span> <span class="Keyword">in</span> <span class="Operator">$</span><span class="Identifier">reason</span><span class="Operator">.</span><span class="Identifier">message</span>
|
||||
|
||||
<span class="Keyword">discard</span> <span class="Identifier">main</span><span class="Punctuation">(</span><span class="Punctuation">)</span></pre>
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/js/asyncjs.nim#L247" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/js/asyncjs.nim#L247" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="newPromise-procs-all">
|
||||
<div id="newPromise,proc(proc))">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#newPromise%2Cproc%28proc%29%29"><span class="Identifier">newPromise</span></a><span class="Other">(</span><span class="Identifier">handler</span><span class="Other">:</span> <span class="Keyword">proc</span> <span class="Other">(</span><span class="Identifier">resolve</span><span class="Other">:</span> <span class="Keyword">proc</span> <span class="Other">(</span><span class="Other">)</span><span class="Other">)</span><span class="Other">)</span><span class="Other">:</span> <a href="asyncjs.html#Future"><span class="Identifier">Future</span></a><span class="Other">[</span><a href="system.html#void"><span class="Identifier">void</span></a><span class="Other">]</span> {.
|
||||
<span class="Identifier">importjs</span><span class="Other">:</span> <span class="StringLit">"(new Promise(#))"</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
A helper for wrapping callback-based functions into promises and async procedures.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/js/asyncjs.nim#L171" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/js/asyncjs.nim#L171" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
<div id="newPromise,proc(proc(T))">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#newPromise%2Cproc%28proc%28T%29%29"><span class="Identifier">newPromise</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">handler</span><span class="Other">:</span> <span class="Keyword">proc</span> <span class="Other">(</span><span class="Identifier">resolve</span><span class="Other">:</span> <span class="Keyword">proc</span> <span class="Other">(</span><span class="Identifier">response</span><span class="Other">:</span> <span class="Identifier">T</span><span class="Other">)</span><span class="Other">)</span><span class="Other">)</span><span class="Other">:</span> <a href="asyncjs.html#Future"><span class="Identifier">Future</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span> {.
|
||||
<span class="Identifier">importjs</span><span class="Other">:</span> <span class="StringLit">"(new Promise(#))"</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
A helper for wrapping callback-based functions into promises and async procedures.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/js/asyncjs.nim#L167" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/js/asyncjs.nim#L167" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="then-procs-all">
|
||||
<div id="then,Future[T],proc,OnReject">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#then%2CFuture%5BT%5D%2Cproc%2COnReject"><span class="Identifier">then</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">future</span><span class="Other">:</span> <a href="asyncjs.html#Future"><span class="Identifier">Future</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">onSuccess</span><span class="Other">:</span> <span class="Keyword">proc</span><span class="Other">;</span> <span class="Identifier">onReject</span><span class="Other">:</span> <a href="asyncjs.html#OnReject"><span class="Identifier">OnReject</span></a> <span class="Other">=</span> <span class="Keyword">nil</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#auto"><span class="Identifier">auto</span></a></pre></dt>
|
||||
<dd>
|
||||
|
||||
See <a class="reference external" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/then">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/then</a> Returns a <tt class="docutils literal"><span class="pre"><span class="Identifier">Future</span></span></tt> from the return type of <tt class="docutils literal"><span class="pre"><span class="Identifier">onSuccess</span><span class="Punctuation">(</span><span class="Identifier">T</span><span class="Operator">.</span><span class="Identifier">default</span><span class="Punctuation">)</span></span></tt>.
|
||||
<p><strong class="examples_text">Example: cmd: -r:off</strong></p>
|
||||
<pre class="listing"><span class="Keyword">from</span> <span class="Identifier">std</span><span class="Operator">/</span><span class="Identifier">sugar</span> <span class="Keyword">import</span> <span class="Punctuation">`</span><span class="Operator">=></span><span class="Punctuation">`</span>
|
||||
|
||||
<span class="Keyword">proc</span> <span class="Identifier">fn</span><span class="Punctuation">(</span><span class="Identifier">n</span><span class="Punctuation">:</span> <span class="Identifier">int</span><span class="Punctuation">)</span><span class="Punctuation">:</span> <span class="Identifier">Future</span><span class="Punctuation">[</span><span class="Identifier">int</span><span class="Punctuation">]</span> <span class="Punctuation">{</span><span class="Operator">.</span><span class="Identifier">async</span><span class="Operator">.</span><span class="Punctuation">}</span> <span class="Operator">=</span>
|
||||
<span class="Keyword">if</span> <span class="Identifier">n</span> <span class="Operator">>=</span> <span class="DecNumber">7</span><span class="Punctuation">:</span> <span class="Keyword">raise</span> <span class="Identifier">newException</span><span class="Punctuation">(</span><span class="Identifier">ValueError</span><span class="Punctuation">,</span> <span class="StringLit">"foobar: "</span> <span class="Operator">&</span> <span class="Operator">$</span><span class="Identifier">n</span><span class="Punctuation">)</span>
|
||||
<span class="Keyword">else</span><span class="Punctuation">:</span> <span class="Identifier">result</span> <span class="Operator">=</span> <span class="Identifier">n</span> <span class="Operator">*</span> <span class="DecNumber">2</span>
|
||||
|
||||
<span class="Keyword">proc</span> <span class="Identifier">asyncFact</span><span class="Punctuation">(</span><span class="Identifier">n</span><span class="Punctuation">:</span> <span class="Identifier">int</span><span class="Punctuation">)</span><span class="Punctuation">:</span> <span class="Identifier">Future</span><span class="Punctuation">[</span><span class="Identifier">int</span><span class="Punctuation">]</span> <span class="Punctuation">{</span><span class="Operator">.</span><span class="Identifier">async</span><span class="Operator">.</span><span class="Punctuation">}</span> <span class="Operator">=</span>
|
||||
<span class="Keyword">if</span> <span class="Identifier">n</span> <span class="Operator">></span> <span class="DecNumber">0</span><span class="Punctuation">:</span> <span class="Identifier">result</span> <span class="Operator">=</span> <span class="Identifier">n</span> <span class="Operator">*</span> <span class="Identifier">await</span> <span class="Identifier">asyncFact</span><span class="Punctuation">(</span><span class="Identifier">n</span><span class="Operator">-</span><span class="DecNumber">1</span><span class="Punctuation">)</span>
|
||||
<span class="Keyword">else</span><span class="Punctuation">:</span> <span class="Identifier">result</span> <span class="Operator">=</span> <span class="DecNumber">1</span>
|
||||
|
||||
<span class="Keyword">proc</span> <span class="Identifier">main</span><span class="Punctuation">(</span><span class="Punctuation">)</span> <span class="Punctuation">{</span><span class="Operator">.</span><span class="Identifier">async</span><span class="Operator">.</span><span class="Punctuation">}</span> <span class="Operator">=</span>
|
||||
<span class="Keyword">block</span><span class="Punctuation">:</span> <span class="Comment"># then</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">asyncFact</span><span class="Punctuation">(</span><span class="DecNumber">3</span><span class="Punctuation">)</span><span class="Operator">.</span><span class="Identifier">await</span> <span class="Operator">==</span> <span class="DecNumber">3</span><span class="Operator">*</span><span class="DecNumber">2</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">asyncFact</span><span class="Punctuation">(</span><span class="DecNumber">3</span><span class="Punctuation">)</span><span class="Operator">.</span><span class="Identifier">then</span><span class="Punctuation">(</span><span class="Identifier">asyncFact</span><span class="Punctuation">)</span><span class="Operator">.</span><span class="Identifier">await</span> <span class="Operator">==</span> <span class="DecNumber">6</span><span class="Operator">*</span><span class="DecNumber">5</span><span class="Operator">*</span><span class="DecNumber">4</span><span class="Operator">*</span><span class="DecNumber">3</span><span class="Operator">*</span><span class="DecNumber">2</span>
|
||||
<span class="Keyword">let</span> <span class="Identifier">x1</span> <span class="Operator">=</span> <span class="Identifier">await</span> <span class="Identifier">fn</span><span class="Punctuation">(</span><span class="DecNumber">3</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">x1</span> <span class="Operator">==</span> <span class="DecNumber">3</span> <span class="Operator">*</span> <span class="DecNumber">2</span>
|
||||
<span class="Keyword">let</span> <span class="Identifier">x2</span> <span class="Operator">=</span> <span class="Identifier">await</span> <span class="Identifier">fn</span><span class="Punctuation">(</span><span class="DecNumber">4</span><span class="Punctuation">)</span>
|
||||
<span class="Operator">.</span><span class="Identifier">then</span><span class="Punctuation">(</span><span class="Punctuation">(</span><span class="Identifier">a</span><span class="Punctuation">:</span> <span class="Identifier">int</span><span class="Punctuation">)</span> <span class="Operator">=></span> <span class="Identifier">a</span><span class="Operator">.</span><span class="Identifier">float</span><span class="Punctuation">)</span>
|
||||
<span class="Operator">.</span><span class="Identifier">then</span><span class="Punctuation">(</span><span class="Punctuation">(</span><span class="Identifier">a</span><span class="Punctuation">:</span> <span class="Identifier">float</span><span class="Punctuation">)</span> <span class="Operator">=></span> <span class="Operator">$</span><span class="Identifier">a</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">x2</span> <span class="Operator">==</span> <span class="StringLit">"8.0"</span>
|
||||
|
||||
<span class="Keyword">block</span><span class="Punctuation">:</span> <span class="Comment"># then with `onReject` callback</span>
|
||||
<span class="Keyword">var</span> <span class="Identifier">witness</span> <span class="Operator">=</span> <span class="DecNumber">1</span>
|
||||
<span class="Identifier">await</span> <span class="Identifier">fn</span><span class="Punctuation">(</span><span class="DecNumber">6</span><span class="Punctuation">)</span><span class="Operator">.</span><span class="Identifier">then</span><span class="Punctuation">(</span><span class="Punctuation">(</span><span class="Identifier">a</span><span class="Punctuation">:</span> <span class="Identifier">int</span><span class="Punctuation">)</span> <span class="Operator">=></span> <span class="Punctuation">(</span><span class="Identifier">witness</span> <span class="Operator">=</span> <span class="DecNumber">2</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Punctuation">(</span><span class="Identifier">r</span><span class="Punctuation">:</span> <span class="Identifier">Error</span><span class="Punctuation">)</span> <span class="Operator">=></span> <span class="Punctuation">(</span><span class="Identifier">witness</span> <span class="Operator">=</span> <span class="DecNumber">3</span><span class="Punctuation">)</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">witness</span> <span class="Operator">==</span> <span class="DecNumber">2</span>
|
||||
<span class="Identifier">await</span> <span class="Identifier">fn</span><span class="Punctuation">(</span><span class="DecNumber">7</span><span class="Punctuation">)</span><span class="Operator">.</span><span class="Identifier">then</span><span class="Punctuation">(</span><span class="Punctuation">(</span><span class="Identifier">a</span><span class="Punctuation">:</span> <span class="Identifier">int</span><span class="Punctuation">)</span> <span class="Operator">=></span> <span class="Punctuation">(</span><span class="Identifier">witness</span> <span class="Operator">=</span> <span class="DecNumber">2</span><span class="Punctuation">)</span><span class="Punctuation">,</span> <span class="Punctuation">(</span><span class="Identifier">r</span><span class="Punctuation">:</span> <span class="Identifier">Error</span><span class="Punctuation">)</span> <span class="Operator">=></span> <span class="Punctuation">(</span><span class="Identifier">witness</span> <span class="Operator">=</span> <span class="DecNumber">3</span><span class="Punctuation">)</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">witness</span> <span class="Operator">==</span> <span class="DecNumber">3</span></pre>
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/js/asyncjs.nim#L200" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/js/asyncjs.nim#L200" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</dl>
|
||||
</div>
|
||||
<div class="section" id="17">
|
||||
<h1><a class="toc-backref" href="#17">Macros</a></h1>
|
||||
<dl class="item">
|
||||
<div id="async-macros-all">
|
||||
<div id="async.m,untyped">
|
||||
<dt><pre><span class="Keyword">macro</span> <a href="#async.m%2Cuntyped"><span class="Identifier">async</span></a><span class="Other">(</span><span class="Identifier">arg</span><span class="Other">:</span> <a href="system.html#untyped"><span class="Identifier">untyped</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#untyped"><span class="Identifier">untyped</span></a></pre></dt>
|
||||
<dd>
|
||||
|
||||
Macro which converts normal procedures into javascript-compatible async procedures.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/js/asyncjs.nim#L157" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/js/asyncjs.nim#L157" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="twelve-columns footer">
|
||||
<span class="nim-sprite"></span>
|
||||
<br>
|
||||
<small style="color: var(--hint);">Made with Nim. Generated: 2023-03-13 00:19:49 UTC</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script defer data-domain="nim-lang.org" src="https://plausible.io/js/plausible.js"></script>
|
||||
|
||||
<!-- Google fonts -->
|
||||
<link href='https://fonts.googleapis.com/css?family=Lato:400,600,900' rel='stylesheet' type='text/css'/>
|
||||
<link href='https://fonts.googleapis.com/css?family=Source+Code+Pro:400,500,600' rel='stylesheet' type='text/css'/>
|
||||
</body>
|
||||
</html>
|
||||
12
asyncjs.idx
Normal file
12
asyncjs.idx
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
nimTitle asyncjs asyncjs.html module std/asyncjs 0
|
||||
nim Future asyncjs.html#Future type Future 75
|
||||
nim PromiseJs asyncjs.html#PromiseJs type PromiseJs 79
|
||||
nim async asyncjs.html#async.m,untyped macro async(arg: untyped): untyped 157
|
||||
nim newPromise asyncjs.html#newPromise,proc(proc(T)) proc newPromise[T](handler: proc (resolve: proc (response: T))): Future[T] 167
|
||||
nim newPromise asyncjs.html#newPromise,proc(proc)) proc newPromise(handler: proc (resolve: proc ())): Future[void] 171
|
||||
nim Error asyncjs.html#Error type Error 193
|
||||
nim OnReject asyncjs.html#OnReject type OnReject 198
|
||||
nim then asyncjs.html#then,Future[T],proc,OnReject proc then[T](future: Future[T]; onSuccess: proc; onReject: OnReject = nil): auto 200
|
||||
nim catch asyncjs.html#catch,Future[T],OnReject proc catch[T](future: Future[T]; onReject: OnReject): Future[void] 247
|
||||
heading JavaScript compatibility asyncjs.html#javascript-compatibility JavaScript compatibility 0
|
||||
nimgrp newpromise asyncjs.html#newPromise-procs-all proc 167
|
||||
179
asyncmacro.html
Normal file
179
asyncmacro.html
Normal file
|
|
@ -0,0 +1,179 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<!-- This file is generated by Nim. -->
|
||||
<html xmlns="https://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>std/asyncmacro</title>
|
||||
|
||||
<!-- Favicon -->
|
||||
<link rel="shortcut icon" href="data:image/x-icon;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAUAAAAF////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAIAAABbAAAAlQAAAKIAAACbAAAAmwAAAKIAAACVAAAAWwAAAAL///8A////AP///wD///8A////AAAAABQAAADAAAAAYwAAAA3///8A////AP///wD///8AAAAADQAAAGMAAADAAAAAFP///wD///8A////AP///wAAAACdAAAAOv///wD///8A////AP///wD///8A////AP///wD///8AAAAAOgAAAJ3///8A////AP///wAAAAAnAAAAcP///wAAAAAoAAAASv///wD///8A////AP///wAAAABKAAAAKP///wAAAABwAAAAJ////wD///8AAAAAgQAAABwAAACIAAAAkAAAAJMAAACtAAAAFQAAABUAAACtAAAAkwAAAJAAAACIAAAAHAAAAIH///8A////AAAAAKQAAACrAAAAaP///wD///8AAAAARQAAANIAAADSAAAARf///wD///8AAAAAaAAAAKsAAACk////AAAAADMAAACcAAAAnQAAABj///8A////AP///wAAAAAYAAAAGP///wD///8A////AAAAABgAAACdAAAAnAAAADMAAAB1AAAAwwAAAP8AAADpAAAAsQAAAE4AAAAb////AP///wAAAAAbAAAATgAAALEAAADpAAAA/wAAAMMAAAB1AAAAtwAAAOkAAAD/AAAA/wAAAP8AAADvAAAA3gAAAN4AAADeAAAA3gAAAO8AAAD/AAAA/wAAAP8AAADpAAAAtwAAAGUAAAA/AAAA3wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAADfAAAAPwAAAGX///8A////AAAAAEgAAADtAAAAvwAAAL0AAADGAAAA7wAAAO8AAADGAAAAvQAAAL8AAADtAAAASP///wD///8A////AP///wD///8AAAAAO////wD///8A////AAAAAIcAAACH////AP///wD///8AAAAAO////wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A//8AAP//AAD4HwAA7/cAAN/7AAD//wAAoYUAAJ55AACf+QAAh+EAAAAAAADAAwAA4AcAAP5/AAD//wAA//8AAA=="/>
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAA3XAAAN1wFCKJt4AAAAB3RJTUUH4QQQEwksSS9ZWwAAAk1JREFUWMPtll2ITVEUx39nn/O7Y5qR8f05wtCUUr6ZIS++8pEnkZInPImneaCQ5METNdOkeFBKUhMPRIkHKfEuUZSUlGlKPN2TrgfncpvmnntnmlEyq1Z7t89/rf9a6+y99oZxGZf/XeIq61EdtgKXgdXA0xrYAvBjOIF1AI9zvjcC74BSpndrJPkBWDScTF8Aa4E3wDlgHbASaANmVqlcCnwHvgDvgVfAJ+AikAAvgfVZwLnSVZHZaOuKoQi3ZOMi4NkYkpe1p4J7A8BpYAD49hfIy/oqG0+hLomiKP2L5L+1ubn5115S+3OAn4EnwBlgMzCjyt6ZAnQCJ4A7wOs88iRJHvw50HoujuPBoCKwHWiosy8MdfZnAdcHk8dxXFJ3VQbQlCTJvRBCGdRbD4M6uc5glpY3eAihpN5S5w12diSEcCCEcKUO4ljdr15T76ur1FDDLIQQ3qv71EdDOe3Kxj3leRXyk+pxdWnFWod6Wt2bY3de3aSuUHcPBVimHs7mK9WrmeOF6lR1o9qnzskh2ar2qm1qizpfXaPeVGdlmGN5pb09qMxz1Xb1kLqgzn1RyH7JUXW52lr5e/Kqi9qpto7V1atuUzfnARrV7jEib1T76gG2qxdGmXyiekkt1GswPTtek0aBfJp6YySGBfWg2tPQ0FAYgf1stUfdmdcjarbYJEniKIq6gY/Aw+zWHAC+p2labGpqiorFYgGYCEzN7oQdQClN07O1/EfDyGgC0ALMBdYAi4FyK+4H3gLPsxfR1zRNi+NP7nH5J+QntnXe5B5mpfQAAAAASUVORK5CYII=">
|
||||
|
||||
<!-- CSS -->
|
||||
<link rel="stylesheet" type="text/css" href="nimdoc.out.css">
|
||||
|
||||
<!-- JS -->
|
||||
<script type="text/javascript" src="dochack.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="document" id="documentId">
|
||||
<div class="container">
|
||||
<h1 class="title">std/asyncmacro</h1>
|
||||
<div class="row">
|
||||
<div class="three columns">
|
||||
<div class="theme-select-wrapper">
|
||||
<label for="theme-select">Theme: </label>
|
||||
<select id="theme-select" onchange="setTheme(this.value)">
|
||||
<option value="auto">🌗 Match OS</option>
|
||||
<option value="dark">🌑 Dark</option>
|
||||
<option value="light">🌕 Light</option>
|
||||
</select>
|
||||
</div>
|
||||
<div id="global-links">
|
||||
<ul class="simple-boot">
|
||||
<li><a href="manual.html">Manual</a></li>
|
||||
<li><a href="lib.html">Standard library</a></li>
|
||||
<li> <a id="indexLink" href="theindex.html">Index</a></li>
|
||||
<li><a href="compiler/theindex.html">Compiler docs</a></li>
|
||||
<li><a href="https://nim-lang.github.io/fusion/theindex.html">Fusion docs</a></li>
|
||||
<li><a href="https://nim-lang.github.io/Nim/">devel</a>, <a href="https://nim-lang.org/documentation.html">stable</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="searchInputDiv">
|
||||
Search: <input type="search" id="searchInput"
|
||||
onkeyup="search()" />
|
||||
</div>
|
||||
|
||||
<ul class="simple simple-toc" id="toc-list">
|
||||
<li>
|
||||
<a class="reference reference-toplevel" href="#6" id="56">Imports</a>
|
||||
</li>
|
||||
<li>
|
||||
<details open>
|
||||
<summary><a class="reference reference-toplevel" href="#17" id="67">Macros</a></summary>
|
||||
<ul class="simple simple-toc-section">
|
||||
<ul class="simple nested-toc-section">async
|
||||
<li><a class="reference" href="#async.m%2Cuntyped" title="async(prc: untyped): untyped">async(prc: untyped): untyped</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">multisync
|
||||
<li><a class="reference" href="#multisync.m%2Cuntyped" title="multisync(prc: untyped): untyped">multisync(prc: untyped): untyped</a></li>
|
||||
|
||||
</ul>
|
||||
|
||||
</ul>
|
||||
</details>
|
||||
</li>
|
||||
<li>
|
||||
<details open>
|
||||
<summary><a class="reference reference-toplevel" href="#18" id="68">Templates</a></summary>
|
||||
<ul class="simple simple-toc-section">
|
||||
<ul class="simple nested-toc-section">await
|
||||
<li><a class="reference" href="#await.t%2Ctyped" title="await(f: typed): untyped">await(f: typed): untyped</a></li>
|
||||
<li><a class="reference" href="#await.t%2CFuture%5BT%5D" title="await[T](f: Future[T]): auto">await[T](f: Future[T]): auto</a></li>
|
||||
|
||||
</ul>
|
||||
|
||||
</ul>
|
||||
</details>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
<div class="nine columns" id="content">
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncmacro.nim#L1" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncmacro.nim#L1" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
<div id="tocRoot"></div>
|
||||
|
||||
<p class="module-desc">Implements the <tt class="docutils literal"><span class="pre"><span class="Identifier">async</span></span></tt> and <tt class="docutils literal"><span class="pre"><span class="Identifier">multisync</span></span></tt> macros for <tt class="docutils literal"><span class="pre"><span class="Identifier">asyncdispatch</span></span></tt>.</p>
|
||||
<div class="section" id="6">
|
||||
<h1><a class="toc-backref" href="#6">Imports</a></h1>
|
||||
<dl class="item">
|
||||
<a class="reference external" href="macros.html">macros</a>, <a class="reference external" href="strutils.html">strutils</a>, <a class="reference external" href="asyncfutures.html">asyncfutures</a>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="section" id="17">
|
||||
<h1><a class="toc-backref" href="#17">Macros</a></h1>
|
||||
<dl class="item">
|
||||
<div id="async-macros-all">
|
||||
<div id="async.m,untyped">
|
||||
<dt><pre><span class="Keyword">macro</span> <a href="#async.m%2Cuntyped"><span class="Identifier">async</span></a><span class="Other">(</span><span class="Identifier">prc</span><span class="Other">:</span> <a href="system.html#untyped"><span class="Identifier">untyped</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#untyped"><span class="Identifier">untyped</span></a></pre></dt>
|
||||
<dd>
|
||||
|
||||
Macro which processes async procedures into the appropriate iterators and yield statements.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncmacro.nim#L278" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncmacro.nim#L278" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="multisync-macros-all">
|
||||
<div id="multisync.m,untyped">
|
||||
<dt><pre><span class="Keyword">macro</span> <a href="#multisync.m%2Cuntyped"><span class="Identifier">multisync</span></a><span class="Other">(</span><span class="Identifier">prc</span><span class="Other">:</span> <a href="system.html#untyped"><span class="Identifier">untyped</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#untyped"><span class="Identifier">untyped</span></a></pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Macro which processes async procedures into both asynchronous and synchronous procedures.</p>
|
||||
<p>The generated async procedures use the <tt class="docutils literal"><span class="pre"><span class="Identifier">async</span></span></tt> macro, whereas the generated synchronous procedures simply strip off the <tt class="docutils literal"><span class="pre"><span class="Identifier">await</span></span></tt> calls.</p>
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncmacro.nim#L337" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncmacro.nim#L337" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</dl>
|
||||
</div>
|
||||
<div class="section" id="18">
|
||||
<h1><a class="toc-backref" href="#18">Templates</a></h1>
|
||||
<dl class="item">
|
||||
<div id="await-templates-all">
|
||||
<div id="await.t,typed">
|
||||
<dt><pre><span class="Keyword">template</span> <a href="#await.t%2Ctyped"><span class="Identifier">await</span></a><span class="Other">(</span><span class="Identifier">f</span><span class="Other">:</span> <a href="system.html#typed"><span class="Identifier">typed</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#untyped"><span class="Identifier">untyped</span></a> {.<span class="Identifier">used</span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncmacro.nim#L123" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncmacro.nim#L123" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
<div id="await.t,Future[T]">
|
||||
<dt><pre><span class="Keyword">template</span> <a href="#await.t%2CFuture%5BT%5D"><span class="Identifier">await</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">f</span><span class="Other">:</span> <a href="asyncfutures.html#Future"><span class="Identifier">Future</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#auto"><span class="Identifier">auto</span></a> {.<span class="Identifier">used</span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncmacro.nim#L127" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncmacro.nim#L127" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="twelve-columns footer">
|
||||
<span class="nim-sprite"></span>
|
||||
<br>
|
||||
<small style="color: var(--hint);">Made with Nim. Generated: 2023-03-13 00:19:39 UTC</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script defer data-domain="nim-lang.org" src="https://plausible.io/js/plausible.js"></script>
|
||||
|
||||
<!-- Google fonts -->
|
||||
<link href='https://fonts.googleapis.com/css?family=Lato:400,600,900' rel='stylesheet' type='text/css'/>
|
||||
<link href='https://fonts.googleapis.com/css?family=Source+Code+Pro:400,500,600' rel='stylesheet' type='text/css'/>
|
||||
</body>
|
||||
</html>
|
||||
6
asyncmacro.idx
Normal file
6
asyncmacro.idx
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
nimTitle asyncmacro asyncmacro.html module std/asyncmacro 0
|
||||
nim await asyncmacro.html#await.t,typed template await(f: typed): untyped 123
|
||||
nim await asyncmacro.html#await.t,Future[T] template await[T](f: Future[T]): auto 127
|
||||
nim async asyncmacro.html#async.m,untyped macro async(prc: untyped): untyped 278
|
||||
nim multisync asyncmacro.html#multisync.m,untyped macro multisync(prc: untyped): untyped 337
|
||||
nimgrp await asyncmacro.html#await-templates-all template 123
|
||||
889
asyncnet.html
Normal file
889
asyncnet.html
Normal file
|
|
@ -0,0 +1,889 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<!-- This file is generated by Nim. -->
|
||||
<html xmlns="https://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>std/asyncnet</title>
|
||||
|
||||
<!-- Favicon -->
|
||||
<link rel="shortcut icon" href="data:image/x-icon;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAUAAAAF////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAIAAABbAAAAlQAAAKIAAACbAAAAmwAAAKIAAACVAAAAWwAAAAL///8A////AP///wD///8A////AAAAABQAAADAAAAAYwAAAA3///8A////AP///wD///8AAAAADQAAAGMAAADAAAAAFP///wD///8A////AP///wAAAACdAAAAOv///wD///8A////AP///wD///8A////AP///wD///8AAAAAOgAAAJ3///8A////AP///wAAAAAnAAAAcP///wAAAAAoAAAASv///wD///8A////AP///wAAAABKAAAAKP///wAAAABwAAAAJ////wD///8AAAAAgQAAABwAAACIAAAAkAAAAJMAAACtAAAAFQAAABUAAACtAAAAkwAAAJAAAACIAAAAHAAAAIH///8A////AAAAAKQAAACrAAAAaP///wD///8AAAAARQAAANIAAADSAAAARf///wD///8AAAAAaAAAAKsAAACk////AAAAADMAAACcAAAAnQAAABj///8A////AP///wAAAAAYAAAAGP///wD///8A////AAAAABgAAACdAAAAnAAAADMAAAB1AAAAwwAAAP8AAADpAAAAsQAAAE4AAAAb////AP///wAAAAAbAAAATgAAALEAAADpAAAA/wAAAMMAAAB1AAAAtwAAAOkAAAD/AAAA/wAAAP8AAADvAAAA3gAAAN4AAADeAAAA3gAAAO8AAAD/AAAA/wAAAP8AAADpAAAAtwAAAGUAAAA/AAAA3wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAADfAAAAPwAAAGX///8A////AAAAAEgAAADtAAAAvwAAAL0AAADGAAAA7wAAAO8AAADGAAAAvQAAAL8AAADtAAAASP///wD///8A////AP///wD///8AAAAAO////wD///8A////AAAAAIcAAACH////AP///wD///8AAAAAO////wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A//8AAP//AAD4HwAA7/cAAN/7AAD//wAAoYUAAJ55AACf+QAAh+EAAAAAAADAAwAA4AcAAP5/AAD//wAA//8AAA=="/>
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAA3XAAAN1wFCKJt4AAAAB3RJTUUH4QQQEwksSS9ZWwAAAk1JREFUWMPtll2ITVEUx39nn/O7Y5qR8f05wtCUUr6ZIS++8pEnkZInPImneaCQ5METNdOkeFBKUhMPRIkHKfEuUZSUlGlKPN2TrgfncpvmnntnmlEyq1Z7t89/rf9a6+y99oZxGZf/XeIq61EdtgKXgdXA0xrYAvBjOIF1AI9zvjcC74BSpndrJPkBWDScTF8Aa4E3wDlgHbASaANmVqlcCnwHvgDvgVfAJ+AikAAvgfVZwLnSVZHZaOuKoQi3ZOMi4NkYkpe1p4J7A8BpYAD49hfIy/oqG0+hLomiKP2L5L+1ubn5115S+3OAn4EnwBlgMzCjyt6ZAnQCJ4A7wOs88iRJHvw50HoujuPBoCKwHWiosy8MdfZnAdcHk8dxXFJ3VQbQlCTJvRBCGdRbD4M6uc5glpY3eAihpN5S5w12diSEcCCEcKUO4ljdr15T76ur1FDDLIQQ3qv71EdDOe3Kxj3leRXyk+pxdWnFWod6Wt2bY3de3aSuUHcPBVimHs7mK9WrmeOF6lR1o9qnzskh2ar2qm1qizpfXaPeVGdlmGN5pb09qMxz1Xb1kLqgzn1RyH7JUXW52lr5e/Kqi9qpto7V1atuUzfnARrV7jEib1T76gG2qxdGmXyiekkt1GswPTtek0aBfJp6YySGBfWg2tPQ0FAYgf1stUfdmdcjarbYJEniKIq6gY/Aw+zWHAC+p2labGpqiorFYgGYCEzN7oQdQClN07O1/EfDyGgC0ALMBdYAi4FyK+4H3gLPsxfR1zRNi+NP7nH5J+QntnXe5B5mpfQAAAAASUVORK5CYII=">
|
||||
|
||||
<!-- CSS -->
|
||||
<link rel="stylesheet" type="text/css" href="nimdoc.out.css">
|
||||
|
||||
<!-- JS -->
|
||||
<script type="text/javascript" src="dochack.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="document" id="documentId">
|
||||
<div class="container">
|
||||
<h1 class="title">std/asyncnet</h1>
|
||||
<div class="row">
|
||||
<div class="three columns">
|
||||
<div class="theme-select-wrapper">
|
||||
<label for="theme-select">Theme: </label>
|
||||
<select id="theme-select" onchange="setTheme(this.value)">
|
||||
<option value="auto">🌗 Match OS</option>
|
||||
<option value="dark">🌑 Dark</option>
|
||||
<option value="light">🌕 Light</option>
|
||||
</select>
|
||||
</div>
|
||||
<div id="global-links">
|
||||
<ul class="simple-boot">
|
||||
<li><a href="manual.html">Manual</a></li>
|
||||
<li><a href="lib.html">Standard library</a></li>
|
||||
<li> <a id="indexLink" href="theindex.html">Index</a></li>
|
||||
<li><a href="compiler/theindex.html">Compiler docs</a></li>
|
||||
<li><a href="https://nim-lang.github.io/fusion/theindex.html">Fusion docs</a></li>
|
||||
<li><a href="https://nim-lang.github.io/Nim/">devel</a>, <a href="https://nim-lang.org/documentation.html">stable</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="searchInputDiv">
|
||||
Search: <input type="search" id="searchInput"
|
||||
onkeyup="search()" />
|
||||
</div>
|
||||
|
||||
<ul class="simple simple-toc" id="toc-list">
|
||||
<li><a class="reference" id="asynchronous-io-in-nim_toc" href="#asynchronous-io-in-nim">Asynchronous IO in Nim</a></li>
|
||||
<li><a class="reference" id="ssl_toc" href="#ssl">SSL</a></li>
|
||||
<li><a class="reference" id="examples_toc" href="#examples">Examples</a></li>
|
||||
<ul class="simple"><li><a class="reference" id="examples-chat-server_toc" href="#examples-chat-server">Chat server</a></li>
|
||||
</ul><li>
|
||||
<a class="reference reference-toplevel" href="#6" id="56">Imports</a>
|
||||
</li>
|
||||
<li>
|
||||
<details open>
|
||||
<summary><a class="reference reference-toplevel" href="#7" id="57">Types</a></summary>
|
||||
<ul class="simple simple-toc-section">
|
||||
<li><a class="reference" href="#AsyncSocket" title="AsyncSocket = ref AsyncSocketDesc">AsyncSocket</a></li>
|
||||
|
||||
</ul>
|
||||
</details>
|
||||
</li>
|
||||
<li>
|
||||
<details open>
|
||||
<summary><a class="reference reference-toplevel" href="#12" id="62">Procs</a></summary>
|
||||
<ul class="simple simple-toc-section">
|
||||
<ul class="simple nested-toc-section">accept
|
||||
<li><a class="reference" href="#accept%2CAsyncSocket" title="accept(socket: AsyncSocket; flags = {SafeDisconn}): owned(Future[AsyncSocket])">accept(socket: AsyncSocket; flags = {SafeDisconn}): owned(Future[AsyncSocket])</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">acceptAddr
|
||||
<li><a class="reference" href="#acceptAddr%2CAsyncSocket" title="acceptAddr(socket: AsyncSocket; flags = {SafeDisconn};
|
||||
inheritable = defined(nimInheritHandles)): owned(
|
||||
Future[tuple[address: string, client: AsyncSocket]])">acceptAddr(socket: AsyncSocket; flags = {SafeDisconn};
|
||||
inheritable = defined(nimInheritHandles)): owned(
|
||||
Future[tuple[address: string, client: AsyncSocket]])</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">bindAddr
|
||||
<li><a class="reference" href="#bindAddr%2CAsyncSocket%2Cstring" title="bindAddr(socket: AsyncSocket; port = Port(0); address = "")">bindAddr(socket: AsyncSocket; port = Port(0); address = "")</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">bindUnix
|
||||
<li><a class="reference" href="#bindUnix%2CAsyncSocket%2Cstring" title="bindUnix(socket: AsyncSocket; path: string)">bindUnix(socket: AsyncSocket; path: string)</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">close
|
||||
<li><a class="reference" href="#close%2CAsyncSocket" title="close(socket: AsyncSocket)">close(socket: AsyncSocket)</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">connect
|
||||
<li><a class="reference" href="#connect%2CAsyncSocket%2Cstring%2CPort" title="connect(socket: AsyncSocket; address: string; port: Port): owned(
|
||||
Future[void])">connect(socket: AsyncSocket; address: string; port: Port): owned(
|
||||
Future[void])</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">connectUnix
|
||||
<li><a class="reference" href="#connectUnix%2CAsyncSocket%2Cstring" title="connectUnix(socket: AsyncSocket; path: string): owned(Future[void])">connectUnix(socket: AsyncSocket; path: string): owned(Future[void])</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">dial
|
||||
<li><a class="reference" href="#dial%2Cstring%2CPort" title="dial(address: string; port: Port; protocol = IPPROTO_TCP; buffered = true): owned(
|
||||
Future[AsyncSocket])">dial(address: string; port: Port; protocol = IPPROTO_TCP; buffered = true): owned(
|
||||
Future[AsyncSocket])</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">getFd
|
||||
<li><a class="reference" href="#getFd%2CAsyncSocket" title="getFd(socket: AsyncSocket): SocketHandle">getFd(socket: AsyncSocket): SocketHandle</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">getLocalAddr
|
||||
<li><a class="reference" href="#getLocalAddr%2CAsyncSocket" title="getLocalAddr(socket: AsyncSocket): (string, Port)">getLocalAddr(socket: AsyncSocket): (string, Port)</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">getPeerAddr
|
||||
<li><a class="reference" href="#getPeerAddr%2CAsyncSocket" title="getPeerAddr(socket: AsyncSocket): (string, Port)">getPeerAddr(socket: AsyncSocket): (string, Port)</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">getPeerCertificates
|
||||
<li><a class="reference" href="#getPeerCertificates%2CAsyncSocket" title="getPeerCertificates(socket: AsyncSocket): seq[Certificate]">getPeerCertificates(socket: AsyncSocket): seq[Certificate]</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">getSockOpt
|
||||
<li><a class="reference" href="#getSockOpt%2CAsyncSocket%2CSOBool" title="getSockOpt(socket: AsyncSocket; opt: SOBool; level = SOL_SOCKET): bool">getSockOpt(socket: AsyncSocket; opt: SOBool; level = SOL_SOCKET): bool</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">hasDataBuffered
|
||||
<li><a class="reference" href="#hasDataBuffered%2CAsyncSocket" title="hasDataBuffered(s: AsyncSocket): bool">hasDataBuffered(s: AsyncSocket): bool</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">isClosed
|
||||
<li><a class="reference" href="#isClosed%2CAsyncSocket" title="isClosed(socket: AsyncSocket): bool">isClosed(socket: AsyncSocket): bool</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">isSsl
|
||||
<li><a class="reference" href="#isSsl%2CAsyncSocket" title="isSsl(socket: AsyncSocket): bool">isSsl(socket: AsyncSocket): bool</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">listen
|
||||
<li><a class="reference" href="#listen%2CAsyncSocket" title="listen(socket: AsyncSocket; backlog = SOMAXCONN)">listen(socket: AsyncSocket; backlog = SOMAXCONN)</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">newAsyncSocket
|
||||
<li><a class="reference" href="#newAsyncSocket%2Ccint%2Ccint%2Ccint" title="newAsyncSocket(domain, sockType, protocol: cint; buffered = true;
|
||||
inheritable = defined(nimInheritHandles)): owned(AsyncSocket)">newAsyncSocket(domain, sockType, protocol: cint; buffered = true;
|
||||
inheritable = defined(nimInheritHandles)): owned(AsyncSocket)</a></li>
|
||||
<li><a class="reference" href="#newAsyncSocket%2CDomain%2CSockType%2CProtocol" title="newAsyncSocket(domain: Domain = AF_INET; sockType: SockType = SOCK_STREAM;
|
||||
protocol: Protocol = IPPROTO_TCP; buffered = true;
|
||||
inheritable = defined(nimInheritHandles)): owned(AsyncSocket)">newAsyncSocket(domain: Domain = AF_INET; sockType: SockType = SOCK_STREAM;
|
||||
protocol: Protocol = IPPROTO_TCP; buffered = true;
|
||||
inheritable = defined(nimInheritHandles)): owned(AsyncSocket)</a></li>
|
||||
<li><a class="reference" href="#newAsyncSocket%2CAsyncFD%2CDomain%2CSockType%2CProtocol" title="newAsyncSocket(fd: AsyncFD; domain: Domain = AF_INET;
|
||||
sockType: SockType = SOCK_STREAM;
|
||||
protocol: Protocol = IPPROTO_TCP; buffered = true;
|
||||
inheritable = defined(nimInheritHandles)): owned(AsyncSocket)">newAsyncSocket(fd: AsyncFD; domain: Domain = AF_INET;
|
||||
sockType: SockType = SOCK_STREAM;
|
||||
protocol: Protocol = IPPROTO_TCP; buffered = true;
|
||||
inheritable = defined(nimInheritHandles)): owned(AsyncSocket)</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">recv
|
||||
<li><a class="reference" href="#recv%2CAsyncSocket%2Cint" title="recv(socket: AsyncSocket; size: int; flags = {SafeDisconn}): owned(
|
||||
Future[string])">recv(socket: AsyncSocket; size: int; flags = {SafeDisconn}): owned(
|
||||
Future[string])</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">recvFrom
|
||||
<li><a class="reference" href="#recvFrom%2CAsyncSocket%2CFutureVar%5Bstring%5D%2Cint%2CFutureVar%5Bstring%5D%2CFutureVar%5BPort%5D" title="recvFrom(socket: AsyncSocket; data: FutureVar[string]; size: int;
|
||||
address: FutureVar[string]; port: FutureVar[Port];
|
||||
flags = {SafeDisconn}): owned(Future[int])">recvFrom(socket: AsyncSocket; data: FutureVar[string]; size: int;
|
||||
address: FutureVar[string]; port: FutureVar[Port];
|
||||
flags = {SafeDisconn}): owned(Future[int])</a></li>
|
||||
<li><a class="reference" href="#recvFrom%2CAsyncSocket%2Cint" title="recvFrom(socket: AsyncSocket; size: int; flags = {SafeDisconn}): owned(
|
||||
Future[tuple[data: string, address: string, port: Port]])">recvFrom(socket: AsyncSocket; size: int; flags = {SafeDisconn}): owned(
|
||||
Future[tuple[data: string, address: string, port: Port]])</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">recvInto
|
||||
<li><a class="reference" href="#recvInto%2CAsyncSocket%2Cpointer%2Cint" title="recvInto(socket: AsyncSocket; buf: pointer; size: int; flags = {SafeDisconn}): owned(
|
||||
Future[int])">recvInto(socket: AsyncSocket; buf: pointer; size: int; flags = {SafeDisconn}): owned(
|
||||
Future[int])</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">recvLine
|
||||
<li><a class="reference" href="#recvLine%2CAsyncSocket" title="recvLine(socket: AsyncSocket; flags = {SafeDisconn}; maxLength = MaxLineLength): owned(
|
||||
Future[string])">recvLine(socket: AsyncSocket; flags = {SafeDisconn}; maxLength = MaxLineLength): owned(
|
||||
Future[string])</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">recvLineInto
|
||||
<li><a class="reference" href="#recvLineInto%2CAsyncSocket%2CFutureVar%5Bstring%5D" title="recvLineInto(socket: AsyncSocket; resString: FutureVar[string];
|
||||
flags = {SafeDisconn}; maxLength = MaxLineLength): owned(
|
||||
Future[void])">recvLineInto(socket: AsyncSocket; resString: FutureVar[string];
|
||||
flags = {SafeDisconn}; maxLength = MaxLineLength): owned(
|
||||
Future[void])</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">send
|
||||
<li><a class="reference" href="#send%2CAsyncSocket%2Cpointer%2Cint" title="send(socket: AsyncSocket; buf: pointer; size: int; flags = {SafeDisconn}): owned(
|
||||
Future[void])">send(socket: AsyncSocket; buf: pointer; size: int; flags = {SafeDisconn}): owned(
|
||||
Future[void])</a></li>
|
||||
<li><a class="reference" href="#send%2CAsyncSocket%2Cstring" title="send(socket: AsyncSocket; data: string; flags = {SafeDisconn}): owned(
|
||||
Future[void])">send(socket: AsyncSocket; data: string; flags = {SafeDisconn}): owned(
|
||||
Future[void])</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">sendTo
|
||||
<li><a class="reference" href="#sendTo%2CAsyncSocket%2Cstring%2CPort%2Cstring" title="sendTo(socket: AsyncSocket; address: string; port: Port; data: string;
|
||||
flags = {SafeDisconn}): owned(Future[void])">sendTo(socket: AsyncSocket; address: string; port: Port; data: string;
|
||||
flags = {SafeDisconn}): owned(Future[void])</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">setSockOpt
|
||||
<li><a class="reference" href="#setSockOpt%2CAsyncSocket%2CSOBool%2Cbool" title="setSockOpt(socket: AsyncSocket; opt: SOBool; value: bool; level = SOL_SOCKET)">setSockOpt(socket: AsyncSocket; opt: SOBool; value: bool; level = SOL_SOCKET)</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">sslHandle
|
||||
<li><a class="reference" href="#sslHandle%2CAsyncSocket" title="sslHandle(self: AsyncSocket): SslPtr">sslHandle(self: AsyncSocket): SslPtr</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">wrapConnectedSocket
|
||||
<li><a class="reference" href="#wrapConnectedSocket%2CSslContext%2CAsyncSocket%2CSslHandshakeType%2Cstring" title="wrapConnectedSocket(ctx: SslContext; socket: AsyncSocket;
|
||||
handshake: SslHandshakeType; hostname: string = "")">wrapConnectedSocket(ctx: SslContext; socket: AsyncSocket;
|
||||
handshake: SslHandshakeType; hostname: string = "")</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">wrapSocket
|
||||
<li><a class="reference" href="#wrapSocket%2CSslContext%2CAsyncSocket" title="wrapSocket(ctx: SslContext; socket: AsyncSocket)">wrapSocket(ctx: SslContext; socket: AsyncSocket)</a></li>
|
||||
|
||||
</ul>
|
||||
|
||||
</ul>
|
||||
</details>
|
||||
</li>
|
||||
<li>
|
||||
<a class="reference reference-toplevel" href="#19" id="69">Exports</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
<div class="nine columns" id="content">
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncnet.nim#L1" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncnet.nim#L1" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
<div id="tocRoot"></div>
|
||||
|
||||
<p class="module-desc">This module implements a high-level asynchronous sockets API based on the asynchronous dispatcher defined in the <tt class="docutils literal"><span class="pre"><span class="Identifier">asyncdispatch</span></span></tt> module.
|
||||
<h1><a class="toc-backref" id="asynchronous-io-in-nim" href="#asynchronous-io-in-nim">Asynchronous IO in Nim</a></h1><p>Async IO in Nim consists of multiple layers (from highest to lowest):</p>
|
||||
<ul class="simple"><li><tt class="docutils literal"><span class="pre"><span class="Identifier">asyncnet</span></span></tt> module</li>
|
||||
<li>Async await</li>
|
||||
<li><tt class="docutils literal"><span class="pre"><span class="Identifier">asyncdispatch</span></span></tt> module (event loop)</li>
|
||||
<li><tt class="docutils literal"><span class="pre"><span class="Identifier">selectors</span></span></tt> module</li>
|
||||
</ul>
|
||||
<p>Each builds on top of the layers below it. The selectors module is an abstraction for the various system <tt class="docutils literal"><span class="pre"><span class="Identifier">select</span><span class="Punctuation">(</span><span class="Punctuation">)</span></span></tt> mechanisms such as epoll or kqueue. If you wish you can use it directly, and some people have done so <a class="reference external" href="http://goran.krampe.se/2014/10/25/nim-socketserver/">successfully</a>. But you must be aware that on Windows it only supports <tt class="docutils literal"><span class="pre"><span class="Identifier">select</span><span class="Punctuation">(</span><span class="Punctuation">)</span></span></tt>.</p>
|
||||
<p>The async dispatcher implements the proactor pattern and also has an implementation of IOCP. It implements the proactor pattern for other OS' via the selectors module. Futures are also implemented here, and indeed all the procedures return a future.</p>
|
||||
<p>The final layer is the async await transformation. This allows you to write asynchronous code in a synchronous style and works similar to C#'s await. The transformation works by converting any async procedures into an iterator.</p>
|
||||
<p>This is all single threaded, fully non-blocking and does give you a lot of control. In theory you should be able to work with any of these layers interchangeably (as long as you only care about non-Windows platforms).</p>
|
||||
<p>For most applications using <tt class="docutils literal"><span class="pre"><span class="Identifier">asyncnet</span></span></tt> is the way to go as it builds over all the layers, providing some extra features such as buffering.</p>
|
||||
|
||||
<h1><a class="toc-backref" id="ssl" href="#ssl">SSL</a></h1><p>SSL can be enabled by compiling with the <tt class="docutils literal"><span class="pre"><span class="Operator">-</span><span class="Identifier">d</span><span class="Punctuation">:</span><span class="Identifier">ssl</span></span></tt> flag.</p>
|
||||
<p>You must create a new SSL context with the <tt class="docutils literal"><span class="pre"><span class="Identifier">newContext</span></span></tt> function defined in the <tt class="docutils literal"><span class="pre"><span class="Identifier">net</span></span></tt> module. You may then call <tt class="docutils literal"><span class="pre"><span class="Identifier">wrapSocket</span></span></tt> on your socket using the newly created SSL context to get an SSL socket.</p>
|
||||
|
||||
<h1><a class="toc-backref" id="examples" href="#examples">Examples</a></h1>
|
||||
<h2><a class="toc-backref" id="examples-chat-server" href="#examples-chat-server">Chat server</a></h2><p>The following example demonstrates a simple chat server.</p>
|
||||
<p><pre class="listing">
|
||||
<span class="Keyword">import</span> <span class="Identifier">std</span><span class="Operator">/</span><span class="Punctuation">[</span><span class="Identifier">asyncnet</span><span class="Punctuation">,</span> <span class="Identifier">asyncdispatch</span><span class="Punctuation">]</span>
|
||||
|
||||
<span class="Keyword">var</span> <span class="Identifier">clients</span> <span class="Punctuation">{</span><span class="Operator">.</span><span class="Identifier">threadvar</span><span class="Operator">.</span><span class="Punctuation">}</span><span class="Punctuation">:</span> <span class="Identifier">seq</span><span class="Punctuation">[</span><span class="Identifier">AsyncSocket</span><span class="Punctuation">]</span>
|
||||
|
||||
<span class="Keyword">proc</span> <span class="Identifier">processClient</span><span class="Punctuation">(</span><span class="Identifier">client</span><span class="Punctuation">:</span> <span class="Identifier">AsyncSocket</span><span class="Punctuation">)</span> <span class="Punctuation">{</span><span class="Operator">.</span><span class="Identifier">async</span><span class="Operator">.</span><span class="Punctuation">}</span> <span class="Operator">=</span>
|
||||
<span class="Keyword">while</span> <span class="Identifier">true</span><span class="Punctuation">:</span>
|
||||
<span class="Keyword">let</span> <span class="Identifier">line</span> <span class="Operator">=</span> <span class="Identifier">await</span> <span class="Identifier">client</span><span class="Operator">.</span><span class="Identifier">recvLine</span><span class="Punctuation">(</span><span class="Punctuation">)</span>
|
||||
<span class="Keyword">if</span> <span class="Identifier">line</span><span class="Operator">.</span><span class="Identifier">len</span> <span class="Operator">==</span> <span class="DecNumber">0</span><span class="Punctuation">:</span> <span class="Keyword">break</span>
|
||||
<span class="Keyword">for</span> <span class="Identifier">c</span> <span class="Keyword">in</span> <span class="Identifier">clients</span><span class="Punctuation">:</span>
|
||||
<span class="Identifier">await</span> <span class="Identifier">c</span><span class="Operator">.</span><span class="Identifier">send</span><span class="Punctuation">(</span><span class="Identifier">line</span> <span class="Operator">&</span> <span class="StringLit">"</span><span class="EscapeSequence">\c</span><span class="EscapeSequence">\L</span><span class="StringLit">"</span><span class="Punctuation">)</span>
|
||||
|
||||
<span class="Keyword">proc</span> <span class="Identifier">serve</span><span class="Punctuation">(</span><span class="Punctuation">)</span> <span class="Punctuation">{</span><span class="Operator">.</span><span class="Identifier">async</span><span class="Operator">.</span><span class="Punctuation">}</span> <span class="Operator">=</span>
|
||||
<span class="Identifier">clients</span> <span class="Operator">=</span> <span class="Operator">@</span><span class="Punctuation">[</span><span class="Punctuation">]</span>
|
||||
<span class="Keyword">var</span> <span class="Identifier">server</span> <span class="Operator">=</span> <span class="Identifier">newAsyncSocket</span><span class="Punctuation">(</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">server</span><span class="Operator">.</span><span class="Identifier">setSockOpt</span><span class="Punctuation">(</span><span class="Identifier">OptReuseAddr</span><span class="Punctuation">,</span> <span class="Identifier">true</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">server</span><span class="Operator">.</span><span class="Identifier">bindAddr</span><span class="Punctuation">(</span><span class="Identifier">Port</span><span class="Punctuation">(</span><span class="DecNumber">12345</span><span class="Punctuation">)</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">server</span><span class="Operator">.</span><span class="Identifier">listen</span><span class="Punctuation">(</span><span class="Punctuation">)</span>
|
||||
|
||||
<span class="Keyword">while</span> <span class="Identifier">true</span><span class="Punctuation">:</span>
|
||||
<span class="Keyword">let</span> <span class="Identifier">client</span> <span class="Operator">=</span> <span class="Identifier">await</span> <span class="Identifier">server</span><span class="Operator">.</span><span class="Identifier">accept</span><span class="Punctuation">(</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">clients</span><span class="Operator">.</span><span class="Identifier">add</span> <span class="Identifier">client</span>
|
||||
|
||||
<span class="Identifier">asyncCheck</span> <span class="Identifier">processClient</span><span class="Punctuation">(</span><span class="Identifier">client</span><span class="Punctuation">)</span>
|
||||
|
||||
<span class="Identifier">asyncCheck</span> <span class="Identifier">serve</span><span class="Punctuation">(</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">runForever</span><span class="Punctuation">(</span><span class="Punctuation">)</span></pre></p>
|
||||
</p>
|
||||
<div class="section" id="6">
|
||||
<h1><a class="toc-backref" href="#6">Imports</a></h1>
|
||||
<dl class="item">
|
||||
<a class="reference external" href="since.html">since</a>, <a class="reference external" href="assertions.html">assertions</a>, <a class="reference external" href="syncio.html">syncio</a>, <a class="reference external" href="asyncdispatch.html">asyncdispatch</a>, <a class="reference external" href="nativesockets.html">nativesockets</a>, <a class="reference external" href="net.html">net</a>, <a class="reference external" href="os.html">os</a>, <a class="reference external" href="openssl.html">openssl</a>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="section" id="7">
|
||||
<h1><a class="toc-backref" href="#7">Types</a></h1>
|
||||
<dl class="item">
|
||||
<div id="AsyncSocket">
|
||||
<dt><pre><a href="asyncnet.html#AsyncSocket"><span class="Identifier">AsyncSocket</span></a> <span class="Other">=</span> <span class="Keyword">ref</span> <span class="Identifier">AsyncSocketDesc</span></pre></dt>
|
||||
<dd>
|
||||
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncnet.nim#L135" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncnet.nim#L135" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</dl>
|
||||
</div>
|
||||
<div class="section" id="12">
|
||||
<h1><a class="toc-backref" href="#12">Procs</a></h1>
|
||||
<dl class="item">
|
||||
<div id="accept-procs-all">
|
||||
<div id="accept,AsyncSocket">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#accept%2CAsyncSocket"><span class="Identifier">accept</span></a><span class="Other">(</span><span class="Identifier">socket</span><span class="Other">:</span> <a href="asyncnet.html#AsyncSocket"><span class="Identifier">AsyncSocket</span></a><span class="Other">;</span> <span class="Identifier">flags</span> <span class="Other">=</span> <span class="Other">{</span><span class="Identifier">SafeDisconn</span><span class="Other">}</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">owned</span><span class="Other">(</span>
|
||||
<a href="asyncfutures.html#Future"><span class="Identifier">Future</span></a><span class="Other">[</span><a href="asyncnet.html#AsyncSocket"><span class="Identifier">AsyncSocket</span></a><span class="Other">]</span><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ValueError</span><span class="Other">,</span> <span class="Identifier">OSError</span><span class="Other">,</span> <span class="Identifier">Exception</span><span class="Other">]</span><span class="Other">,</span>
|
||||
<span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">RootEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Accepts a new connection. Returns a future containing the client socket corresponding to that connection. If <tt class="docutils literal"><span class="pre"><span class="Identifier">inheritable</span></span></tt> is false (the default), the resulting client socket will not be inheritable by child processes. The future will complete when the connection is successfully accepted.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncnet.nim#L492" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncnet.nim#L492" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="acceptAddr-procs-all">
|
||||
<div id="acceptAddr,AsyncSocket">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#acceptAddr%2CAsyncSocket"><span class="Identifier">acceptAddr</span></a><span class="Other">(</span><span class="Identifier">socket</span><span class="Other">:</span> <a href="asyncnet.html#AsyncSocket"><span class="Identifier">AsyncSocket</span></a><span class="Other">;</span> <span class="Identifier">flags</span> <span class="Other">=</span> <span class="Other">{</span><span class="Identifier">SafeDisconn</span><span class="Other">}</span><span class="Other">;</span>
|
||||
<span class="Identifier">inheritable</span> <span class="Other">=</span> <span class="Identifier">defined</span><span class="Other">(</span><span class="Identifier">nimInheritHandles</span><span class="Other">)</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">owned</span><span class="Other">(</span>
|
||||
<a href="asyncfutures.html#Future"><span class="Identifier">Future</span></a><span class="Other">[</span><span class="Keyword">tuple</span><span class="Other">[</span><span class="Identifier">address</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">,</span> <span class="Identifier">client</span><span class="Other">:</span> <a href="asyncnet.html#AsyncSocket"><span class="Identifier">AsyncSocket</span></a><span class="Other">]</span><span class="Other">]</span><span class="Other">)</span> {.
|
||||
<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ValueError</span><span class="Other">,</span> <span class="Identifier">OSError</span><span class="Other">,</span> <span class="Identifier">Exception</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">RootEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Accepts a new connection. Returns a future containing the client socket corresponding to that connection and the remote address of the client.</p>
|
||||
<p>If <tt class="docutils literal"><span class="pre"><span class="Identifier">inheritable</span></span></tt> is false (the default), the resulting client socket will not be inheritable by child processes.</p>
|
||||
<p>The future will complete when the connection is successfully accepted.</p>
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncnet.nim#L468" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncnet.nim#L468" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="bindAddr-procs-all">
|
||||
<div id="bindAddr,AsyncSocket,string">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#bindAddr%2CAsyncSocket%2Cstring"><span class="Identifier">bindAddr</span></a><span class="Other">(</span><span class="Identifier">socket</span><span class="Other">:</span> <a href="asyncnet.html#AsyncSocket"><span class="Identifier">AsyncSocket</span></a><span class="Other">;</span> <span class="Identifier">port</span> <span class="Other">=</span> <a href="nativesockets.html#Port"><span class="Identifier">Port</span></a><span class="Other">(</span><span class="DecNumber">0</span><span class="Other">)</span><span class="Other">;</span> <span class="Identifier">address</span> <span class="Other">=</span> <span class="StringLit">""</span><span class="Other">)</span> {.
|
||||
<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><a href="exceptions.html#ReadIOEffect"><span class="Identifier">ReadIOEffect</span></a><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ValueError</span><span class="Other">,</span> <span class="Identifier">OSError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Binds <tt class="docutils literal"><span class="pre"><span class="Identifier">address</span></span></tt>:<tt class="docutils literal"><span class="pre"><span class="Identifier">port</span></span></tt> to the socket.</p>
|
||||
<p>If <tt class="docutils literal"><span class="pre"><span class="Identifier">address</span></span></tt> is "" then ADDR_ANY will be bound.</p>
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncnet.nim#L640" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncnet.nim#L640" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="bindUnix-procs-all">
|
||||
<div id="bindUnix,AsyncSocket,string">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#bindUnix%2CAsyncSocket%2Cstring"><span class="Identifier">bindUnix</span></a><span class="Other">(</span><span class="Identifier">socket</span><span class="Other">:</span> <a href="asyncnet.html#AsyncSocket"><span class="Identifier">AsyncSocket</span></a><span class="Other">;</span> <span class="Identifier">path</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><a href="exceptions.html#ReadIOEffect"><span class="Identifier">ReadIOEffect</span></a><span class="Other">]</span><span class="Other">,</span>
|
||||
<span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Binds Unix socket to <tt class="docutils literal"><span class="pre"><span class="Identifier">path</span></span></tt>. This only works on Unix-style systems: Mac OS X, BSD and Linux
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncnet.nim#L698" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncnet.nim#L698" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="close-procs-all">
|
||||
<div id="close,AsyncSocket">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#close%2CAsyncSocket"><span class="Identifier">close</span></a><span class="Other">(</span><span class="Identifier">socket</span><span class="Other">:</span> <a href="asyncnet.html#AsyncSocket"><span class="Identifier">AsyncSocket</span></a><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">LibraryError</span><span class="Other">,</span> <span class="Identifier">Exception</span><span class="Other">,</span> <span class="Identifier">SslError</span><span class="Other">]</span><span class="Other">,</span>
|
||||
<span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">RootEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Closes the socket.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncnet.nim#L720" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncnet.nim#L720" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="connect-procs-all">
|
||||
<div id="connect,AsyncSocket,string,Port">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#connect%2CAsyncSocket%2Cstring%2CPort"><span class="Identifier">connect</span></a><span class="Other">(</span><span class="Identifier">socket</span><span class="Other">:</span> <a href="asyncnet.html#AsyncSocket"><span class="Identifier">AsyncSocket</span></a><span class="Other">;</span> <span class="Identifier">address</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">port</span><span class="Other">:</span> <a href="nativesockets.html#Port"><span class="Identifier">Port</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#owned"><span class="Identifier">owned</span></a><span class="Other">(</span>
|
||||
<a href="asyncfutures.html#Future"><span class="Identifier">Future</span></a><span class="Other">[</span><a href="system.html#void"><span class="Identifier">void</span></a><span class="Other">]</span><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">stackTrace</span><span class="Other">:</span> <span class="DecNumber">false</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">Exception</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">RootEffect</span><span class="Other">]</span><span class="Other">,</span>
|
||||
<span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Connects <tt class="docutils literal"><span class="pre"><span class="Identifier">socket</span></span></tt> to server at <tt class="docutils literal"><span class="pre"><span class="Identifier">address</span><span class="Punctuation">:</span><span class="Identifier">port</span></span></tt>.</p>
|
||||
<p>Returns a <tt class="docutils literal"><span class="pre"><span class="Identifier">Future</span></span></tt> which will complete when the connection succeeds or an error occurs.</p>
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncnet.nim#L298" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncnet.nim#L298" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="connectUnix-procs-all">
|
||||
<div id="connectUnix,AsyncSocket,string">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#connectUnix%2CAsyncSocket%2Cstring"><span class="Identifier">connectUnix</span></a><span class="Other">(</span><span class="Identifier">socket</span><span class="Other">:</span> <a href="asyncnet.html#AsyncSocket"><span class="Identifier">AsyncSocket</span></a><span class="Other">;</span> <span class="Identifier">path</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">owned</span><span class="Other">(</span><a href="asyncfutures.html#Future"><span class="Identifier">Future</span></a><span class="Other">[</span><a href="system.html#void"><span class="Identifier">void</span></a><span class="Other">]</span><span class="Other">)</span> {.
|
||||
<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Binds Unix socket to <tt class="docutils literal"><span class="pre"><span class="Identifier">path</span></span></tt>. This only works on Unix-style systems: Mac OS X, BSD and Linux
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncnet.nim#L667" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncnet.nim#L667" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="dial-procs-all">
|
||||
<div id="dial,string,Port">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#dial%2Cstring%2CPort"><span class="Identifier">dial</span></a><span class="Other">(</span><span class="Identifier">address</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">port</span><span class="Other">:</span> <a href="nativesockets.html#Port"><span class="Identifier">Port</span></a><span class="Other">;</span> <span class="Identifier">protocol</span> <span class="Other">=</span> <span class="Identifier">IPPROTO_TCP</span><span class="Other">;</span> <span class="Identifier">buffered</span> <span class="Other">=</span> <span class="Identifier">true</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">owned</span><span class="Other">(</span>
|
||||
<a href="asyncfutures.html#Future"><span class="Identifier">Future</span></a><span class="Other">[</span><a href="asyncnet.html#AsyncSocket"><span class="Identifier">AsyncSocket</span></a><span class="Other">]</span><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">stackTrace</span><span class="Other">:</span> <span class="DecNumber">false</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">Exception</span><span class="Other">,</span> <span class="Identifier">ValueError</span><span class="Other">]</span><span class="Other">,</span>
|
||||
<span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">RootEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Establishes connection to the specified <tt class="docutils literal"><span class="pre"><span class="Identifier">address</span></span></tt>:<tt class="docutils literal"><span class="pre"><span class="Identifier">port</span></span></tt> pair via the specified protocol. The procedure iterates through possible resolutions of the <tt class="docutils literal"><span class="pre"><span class="Identifier">address</span></span></tt> until it succeeds, meaning that it seamlessly works with both IPv4 and IPv6. Returns AsyncSocket ready to send or receive data.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncnet.nim#L287" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncnet.nim#L287" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="getFd-procs-all">
|
||||
<div id="getFd,AsyncSocket">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#getFd%2CAsyncSocket"><span class="Identifier">getFd</span></a><span class="Other">(</span><span class="Identifier">socket</span><span class="Other">:</span> <a href="asyncnet.html#AsyncSocket"><span class="Identifier">AsyncSocket</span></a><span class="Other">)</span><span class="Other">:</span> <a href="winlean.html#SocketHandle"><span class="Identifier">SocketHandle</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
|
||||
<span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Returns the socket's file descriptor.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncnet.nim#L821" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncnet.nim#L821" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="getLocalAddr-procs-all">
|
||||
<div id="getLocalAddr,AsyncSocket">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#getLocalAddr%2CAsyncSocket"><span class="Identifier">getLocalAddr</span></a><span class="Other">(</span><span class="Identifier">socket</span><span class="Other">:</span> <a href="asyncnet.html#AsyncSocket"><span class="Identifier">AsyncSocket</span></a><span class="Other">)</span><span class="Other">:</span> <span class="Other">(</span><a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">,</span> <a href="nativesockets.html#Port"><span class="Identifier">Port</span></a><span class="Other">)</span> {.
|
||||
<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">OSError</span><span class="Other">,</span> <span class="Identifier">Exception</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Get the socket's local address and port number.</p>
|
||||
<p>This is high-level interface for <span id="getsockname_1">getsockname</span>.</p>
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncnet.nim#L180" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncnet.nim#L180" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="getPeerAddr-procs-all">
|
||||
<div id="getPeerAddr,AsyncSocket">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#getPeerAddr%2CAsyncSocket"><span class="Identifier">getPeerAddr</span></a><span class="Other">(</span><span class="Identifier">socket</span><span class="Other">:</span> <a href="asyncnet.html#AsyncSocket"><span class="Identifier">AsyncSocket</span></a><span class="Other">)</span><span class="Other">:</span> <span class="Other">(</span><a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">,</span> <a href="nativesockets.html#Port"><span class="Identifier">Port</span></a><span class="Other">)</span> {.
|
||||
<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">OSError</span><span class="Other">,</span> <span class="Identifier">Exception</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Get the socket's peer address and port number.</p>
|
||||
<p>This is high-level interface for <span id="getpeername_1">getpeername</span>.</p>
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncnet.nim#L187" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncnet.nim#L187" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="getPeerCertificates-procs-all">
|
||||
<div id="getPeerCertificates,AsyncSocket">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#getPeerCertificates%2CAsyncSocket"><span class="Identifier">getPeerCertificates</span></a><span class="Other">(</span><span class="Identifier">socket</span><span class="Other">:</span> <a href="asyncnet.html#AsyncSocket"><span class="Identifier">AsyncSocket</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#seq"><span class="Identifier">seq</span></a><span class="Other">[</span><a href="net.html#Certificate"><span class="Identifier">Certificate</span></a><span class="Other">]</span> {.
|
||||
<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">Exception</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Returns the certificate chain received by the peer we are connected to through the given socket. The handshake must have been completed and the certificate chain must have been verified successfully or else an empty sequence is returned. The chain is ordered from leaf certificate to root certificate.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncnet.nim#L794" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncnet.nim#L794" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="getSockOpt-procs-all">
|
||||
<div id="getSockOpt,AsyncSocket,SOBool">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#getSockOpt%2CAsyncSocket%2CSOBool"><span class="Identifier">getSockOpt</span></a><span class="Other">(</span><span class="Identifier">socket</span><span class="Other">:</span> <a href="asyncnet.html#AsyncSocket"><span class="Identifier">AsyncSocket</span></a><span class="Other">;</span> <span class="Identifier">opt</span><span class="Other">:</span> <a href="net.html#SOBool"><span class="Identifier">SOBool</span></a><span class="Other">;</span> <span class="Identifier">level</span> <span class="Other">=</span> <span class="Identifier">SOL_SOCKET</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#bool"><span class="Identifier">bool</span></a> {.
|
||||
<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><a href="exceptions.html#ReadIOEffect"><span class="Identifier">ReadIOEffect</span></a><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">OSError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Retrieves option <tt class="docutils literal"><span class="pre"><span class="Identifier">opt</span></span></tt> as a boolean value.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncnet.nim#L805" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncnet.nim#L805" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="hasDataBuffered-procs-all">
|
||||
<div id="hasDataBuffered,AsyncSocket">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#hasDataBuffered%2CAsyncSocket"><span class="Identifier">hasDataBuffered</span></a><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="asyncnet.html#AsyncSocket"><span class="Identifier">AsyncSocket</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#bool"><span class="Identifier">bool</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Determines whether an AsyncSocket has data buffered.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncnet.nim#L660" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncnet.nim#L660" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="isClosed-procs-all">
|
||||
<div id="isClosed,AsyncSocket">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#isClosed%2CAsyncSocket"><span class="Identifier">isClosed</span></a><span class="Other">(</span><span class="Identifier">socket</span><span class="Other">:</span> <a href="asyncnet.html#AsyncSocket"><span class="Identifier">AsyncSocket</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#bool"><span class="Identifier">bool</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Determines whether the socket has been closed.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncnet.nim#L825" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncnet.nim#L825" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="isSsl-procs-all">
|
||||
<div id="isSsl,AsyncSocket">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#isSsl%2CAsyncSocket"><span class="Identifier">isSsl</span></a><span class="Other">(</span><span class="Identifier">socket</span><span class="Other">:</span> <a href="asyncnet.html#AsyncSocket"><span class="Identifier">AsyncSocket</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#bool"><span class="Identifier">bool</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Determines whether <tt class="docutils literal"><span class="pre"><span class="Identifier">socket</span></span></tt> is a SSL socket.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncnet.nim#L817" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncnet.nim#L817" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="listen-procs-all">
|
||||
<div id="listen,AsyncSocket">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#listen%2CAsyncSocket"><span class="Identifier">listen</span></a><span class="Other">(</span><span class="Identifier">socket</span><span class="Other">:</span> <a href="asyncnet.html#AsyncSocket"><span class="Identifier">AsyncSocket</span></a><span class="Other">;</span> <span class="Identifier">backlog</span> <span class="Other">=</span> <span class="Identifier">SOMAXCONN</span><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><a href="exceptions.html#ReadIOEffect"><span class="Identifier">ReadIOEffect</span></a><span class="Other">]</span><span class="Other">,</span>
|
||||
<span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">OSError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Marks <tt class="docutils literal"><span class="pre"><span class="Identifier">socket</span></span></tt> as accepting connections. <tt class="docutils literal"><span class="pre"><span class="Identifier">Backlog</span></span></tt> specifies the maximum length of the queue of pending connections.</p>
|
||||
<p>Raises an OSError error upon failure.</p>
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncnet.nim#L631" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncnet.nim#L631" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="newAsyncSocket-procs-all">
|
||||
<div id="newAsyncSocket,cint,cint,cint">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#newAsyncSocket%2Ccint%2Ccint%2Ccint"><span class="Identifier">newAsyncSocket</span></a><span class="Other">(</span><span class="Identifier">domain</span><span class="Other">,</span> <span class="Identifier">sockType</span><span class="Other">,</span> <span class="Identifier">protocol</span><span class="Other">:</span> <a href="ctypes.html#cint"><span class="Identifier">cint</span></a><span class="Other">;</span> <span class="Identifier">buffered</span> <span class="Other">=</span> <span class="Identifier">true</span><span class="Other">;</span>
|
||||
<span class="Identifier">inheritable</span> <span class="Other">=</span> <span class="Identifier">defined</span><span class="Other">(</span><span class="Identifier">nimInheritHandles</span><span class="Other">)</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">owned</span><span class="Other">(</span><span class="Identifier">AsyncSocket</span><span class="Other">)</span> {.
|
||||
<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">OSError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Creates a new asynchronous socket.</p>
|
||||
<p>This procedure will also create a brand new file descriptor for this socket.</p>
|
||||
<p>If <tt class="docutils literal"><span class="pre"><span class="Identifier">inheritable</span></span></tt> is false (the default), the new file descriptor will not be inheritable by child processes.</p>
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncnet.nim#L193" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncnet.nim#L193" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
<div id="newAsyncSocket,Domain,SockType,Protocol">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#newAsyncSocket%2CDomain%2CSockType%2CProtocol"><span class="Identifier">newAsyncSocket</span></a><span class="Other">(</span><span class="Identifier">domain</span><span class="Other">:</span> <a href="nativesockets.html#Domain"><span class="Identifier">Domain</span></a> <span class="Other">=</span> <span class="Identifier">AF_INET</span><span class="Other">;</span> <span class="Identifier">sockType</span><span class="Other">:</span> <a href="nativesockets.html#SockType"><span class="Identifier">SockType</span></a> <span class="Other">=</span> <span class="Identifier">SOCK_STREAM</span><span class="Other">;</span>
|
||||
<span class="Identifier">protocol</span><span class="Other">:</span> <a href="nativesockets.html#Protocol"><span class="Identifier">Protocol</span></a> <span class="Other">=</span> <span class="Identifier">IPPROTO_TCP</span><span class="Other">;</span> <span class="Identifier">buffered</span> <span class="Other">=</span> <span class="Identifier">true</span><span class="Other">;</span>
|
||||
<span class="Identifier">inheritable</span> <span class="Other">=</span> <span class="Identifier">defined</span><span class="Other">(</span><span class="Identifier">nimInheritHandles</span><span class="Other">)</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">owned</span><span class="Other">(</span><span class="Identifier">AsyncSocket</span><span class="Other">)</span> {.
|
||||
<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">OSError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Creates a new asynchronous socket.</p>
|
||||
<p>This procedure will also create a brand new file descriptor for this socket.</p>
|
||||
<p>If <tt class="docutils literal"><span class="pre"><span class="Identifier">inheritable</span></span></tt> is false (the default), the new file descriptor will not be inheritable by child processes.</p>
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncnet.nim#L165" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncnet.nim#L165" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
<div id="newAsyncSocket,AsyncFD,Domain,SockType,Protocol">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#newAsyncSocket%2CAsyncFD%2CDomain%2CSockType%2CProtocol"><span class="Identifier">newAsyncSocket</span></a><span class="Other">(</span><span class="Identifier">fd</span><span class="Other">:</span> <a href="asyncdispatch.html#AsyncFD"><span class="Identifier">AsyncFD</span></a><span class="Other">;</span> <span class="Identifier">domain</span><span class="Other">:</span> <a href="nativesockets.html#Domain"><span class="Identifier">Domain</span></a> <span class="Other">=</span> <span class="Identifier">AF_INET</span><span class="Other">;</span>
|
||||
<span class="Identifier">sockType</span><span class="Other">:</span> <a href="nativesockets.html#SockType"><span class="Identifier">SockType</span></a> <span class="Other">=</span> <span class="Identifier">SOCK_STREAM</span><span class="Other">;</span>
|
||||
<span class="Identifier">protocol</span><span class="Other">:</span> <a href="nativesockets.html#Protocol"><span class="Identifier">Protocol</span></a> <span class="Other">=</span> <span class="Identifier">IPPROTO_TCP</span><span class="Other">;</span> <span class="Identifier">buffered</span> <span class="Other">=</span> <span class="Identifier">true</span><span class="Other">;</span>
|
||||
<span class="Identifier">inheritable</span> <span class="Other">=</span> <span class="Identifier">defined</span><span class="Other">(</span><span class="Identifier">nimInheritHandles</span><span class="Other">)</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">owned</span><span class="Other">(</span><span class="Identifier">AsyncSocket</span><span class="Other">)</span> {.
|
||||
<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">OSError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Creates a new <tt class="docutils literal"><span class="pre"><span class="Identifier">AsyncSocket</span></span></tt> based on the supplied params.</p>
|
||||
<p>The supplied <tt class="docutils literal"><span class="pre"><span class="Identifier">fd</span></span></tt>'s non-blocking state will be enabled implicitly.</p>
|
||||
<p>If <tt class="docutils literal"><span class="pre"><span class="Identifier">inheritable</span></span></tt> is false (the default), the supplied <tt class="docutils literal"><span class="pre"><span class="Identifier">fd</span></span></tt> will not be inheritable by child processes.</p>
|
||||
<p><strong>Note</strong>: This procedure will <strong>NOT</strong> register <tt class="docutils literal"><span class="pre"><span class="Identifier">fd</span></span></tt> with the global async dispatcher. You need to do this manually. If you have used <tt class="docutils literal"><span class="pre"><span class="Identifier">newAsyncNativeSocket</span></span></tt> to create <tt class="docutils literal"><span class="pre"><span class="Identifier">fd</span></span></tt> then it's already registered.</p>
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncnet.nim#L137" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncnet.nim#L137" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="recv-procs-all">
|
||||
<div id="recv,AsyncSocket,int">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#recv%2CAsyncSocket%2Cint"><span class="Identifier">recv</span></a><span class="Other">(</span><span class="Identifier">socket</span><span class="Other">:</span> <a href="asyncnet.html#AsyncSocket"><span class="Identifier">AsyncSocket</span></a><span class="Other">;</span> <span class="Identifier">size</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a><span class="Other">;</span> <span class="Identifier">flags</span> <span class="Other">=</span> <span class="Other">{</span><span class="Identifier">SafeDisconn</span><span class="Other">}</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">owned</span><span class="Other">(</span>
|
||||
<a href="asyncfutures.html#Future"><span class="Identifier">Future</span></a><span class="Other">[</span><a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">]</span><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">stackTrace</span><span class="Other">:</span> <span class="DecNumber">false</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">Exception</span><span class="Other">,</span> <span class="Identifier">ValueError</span><span class="Other">]</span><span class="Other">,</span>
|
||||
<span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">RootEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Reads <strong>up to</strong> <tt class="docutils literal"><span class="pre"><span class="Identifier">size</span></span></tt> bytes from <tt class="docutils literal"><span class="pre"><span class="Identifier">socket</span></span></tt>.</p>
|
||||
<p>For buffered sockets this function will attempt to read all the requested data. It will read this data in <tt class="docutils literal"><span class="pre"><span class="Identifier">BufferSize</span></span></tt> chunks.</p>
|
||||
<p>For unbuffered sockets this function makes no effort to read all the data requested. It will return as much data as the operating system gives it.</p>
|
||||
<p>If socket is disconnected during the recv operation then the future may complete with only a part of the requested data.</p>
|
||||
<p>If socket is disconnected and no data is available to be read then the future will complete with a value of <tt class="docutils literal"><span class="pre"><span class="StringLit">""</span></span></tt>.</p>
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncnet.nim#L388" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncnet.nim#L388" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="recvFrom-procs-all">
|
||||
<div id="recvFrom,AsyncSocket,FutureVar[string],int,FutureVar[string],FutureVar[Port]">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#recvFrom%2CAsyncSocket%2CFutureVar%5Bstring%5D%2Cint%2CFutureVar%5Bstring%5D%2CFutureVar%5BPort%5D"><span class="Identifier">recvFrom</span></a><span class="Other">(</span><span class="Identifier">socket</span><span class="Other">:</span> <a href="asyncnet.html#AsyncSocket"><span class="Identifier">AsyncSocket</span></a><span class="Other">;</span> <span class="Identifier">data</span><span class="Other">:</span> <a href="asyncfutures.html#FutureVar"><span class="Identifier">FutureVar</span></a><span class="Other">[</span><a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">size</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a><span class="Other">;</span>
|
||||
<span class="Identifier">address</span><span class="Other">:</span> <a href="asyncfutures.html#FutureVar"><span class="Identifier">FutureVar</span></a><span class="Other">[</span><a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">port</span><span class="Other">:</span> <a href="asyncfutures.html#FutureVar"><span class="Identifier">FutureVar</span></a><span class="Other">[</span><a href="nativesockets.html#Port"><span class="Identifier">Port</span></a><span class="Other">]</span><span class="Other">;</span>
|
||||
<span class="Identifier">flags</span> <span class="Other">=</span> <span class="Other">{</span><span class="Identifier">SafeDisconn</span><span class="Other">}</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">owned</span><span class="Other">(</span><a href="asyncfutures.html#Future"><span class="Identifier">Future</span></a><span class="Other">[</span><a href="system.html#int"><span class="Identifier">int</span></a><span class="Other">]</span><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">stackTrace</span><span class="Other">:</span> <span class="DecNumber">false</span><span class="Other">,</span>
|
||||
<span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ValueError</span><span class="Other">,</span> <span class="Identifier">Exception</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">RootEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Receives a datagram data from <tt class="docutils literal"><span class="pre"><span class="Identifier">socket</span></span></tt> into <tt class="docutils literal"><span class="pre"><span class="Identifier">data</span></span></tt>, which must be at least of size <tt class="docutils literal"><span class="pre"><span class="Identifier">size</span></span></tt>. The address and port of datagram's sender will be stored into <tt class="docutils literal"><span class="pre"><span class="Identifier">address</span></span></tt> and <tt class="docutils literal"><span class="pre"><span class="Identifier">port</span></span></tt>, respectively. Returned future will complete once one datagram has been received, and will return size of packet received.</p>
|
||||
<p>If an error occurs an OSError exception will be raised.</p>
|
||||
<p>This proc is normally used with connectionless sockets (UDP sockets).</p>
|
||||
<p><strong>Notes</strong></p>
|
||||
<ul class="simple"><li><tt class="docutils literal"><span class="pre"><span class="Identifier">data</span></span></tt> must be initialized to the length of <tt class="docutils literal"><span class="pre"><span class="Identifier">size</span></span></tt>.</li>
|
||||
<li><tt class="docutils literal"><span class="pre"><span class="Identifier">address</span></span></tt> must be initialized to 46 in length.</li>
|
||||
</ul>
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncnet.nim#L878" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncnet.nim#L878" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
<div id="recvFrom,AsyncSocket,int">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#recvFrom%2CAsyncSocket%2Cint"><span class="Identifier">recvFrom</span></a><span class="Other">(</span><span class="Identifier">socket</span><span class="Other">:</span> <a href="asyncnet.html#AsyncSocket"><span class="Identifier">AsyncSocket</span></a><span class="Other">;</span> <span class="Identifier">size</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a><span class="Other">;</span> <span class="Identifier">flags</span> <span class="Other">=</span> <span class="Other">{</span><span class="Identifier">SafeDisconn</span><span class="Other">}</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">owned</span><span class="Other">(</span>
|
||||
<a href="asyncfutures.html#Future"><span class="Identifier">Future</span></a><span class="Other">[</span><span class="Keyword">tuple</span><span class="Other">[</span><span class="Identifier">data</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">,</span> <span class="Identifier">address</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">,</span> <span class="Identifier">port</span><span class="Other">:</span> <a href="nativesockets.html#Port"><span class="Identifier">Port</span></a><span class="Other">]</span><span class="Other">]</span><span class="Other">)</span> {.
|
||||
<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">stackTrace</span><span class="Other">:</span> <span class="DecNumber">false</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">Exception</span><span class="Other">,</span> <span class="Identifier">ValueError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">RootEffect</span><span class="Other">]</span><span class="Other">,</span>
|
||||
<span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Receives a datagram data from <tt class="docutils literal"><span class="pre"><span class="Identifier">socket</span></span></tt>, which must be at least of size <tt class="docutils literal"><span class="pre"><span class="Identifier">size</span></span></tt>. Returned future will complete once one datagram has been received and will return tuple with: data of packet received; and address and port of datagram's sender.</p>
|
||||
<p>If an error occurs an OSError exception will be raised.</p>
|
||||
<p>This proc is normally used with connectionless sockets (UDP sockets).</p>
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncnet.nim#L932" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncnet.nim#L932" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="recvInto-procs-all">
|
||||
<div id="recvInto,AsyncSocket,pointer,int">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#recvInto%2CAsyncSocket%2Cpointer%2Cint"><span class="Identifier">recvInto</span></a><span class="Other">(</span><span class="Identifier">socket</span><span class="Other">:</span> <a href="asyncnet.html#AsyncSocket"><span class="Identifier">AsyncSocket</span></a><span class="Other">;</span> <span class="Identifier">buf</span><span class="Other">:</span> <a href="system.html#pointer"><span class="Identifier">pointer</span></a><span class="Other">;</span> <span class="Identifier">size</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a><span class="Other">;</span>
|
||||
<span class="Identifier">flags</span> <span class="Other">=</span> <span class="Other">{</span><span class="Identifier">SafeDisconn</span><span class="Other">}</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">owned</span><span class="Other">(</span><a href="asyncfutures.html#Future"><span class="Identifier">Future</span></a><span class="Other">[</span><a href="system.html#int"><span class="Identifier">int</span></a><span class="Other">]</span><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">stackTrace</span><span class="Other">:</span> <span class="DecNumber">false</span><span class="Other">,</span>
|
||||
<span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">Exception</span><span class="Other">,</span> <span class="Identifier">ValueError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">RootEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Reads <strong>up to</strong> <tt class="docutils literal"><span class="pre"><span class="Identifier">size</span></span></tt> bytes from <tt class="docutils literal"><span class="pre"><span class="Identifier">socket</span></span></tt> into <tt class="docutils literal"><span class="pre"><span class="Identifier">buf</span></span></tt>.</p>
|
||||
<p>For buffered sockets this function will attempt to read all the requested data. It will read this data in <tt class="docutils literal"><span class="pre"><span class="Identifier">BufferSize</span></span></tt> chunks.</p>
|
||||
<p>For unbuffered sockets this function makes no effort to read all the data requested. It will return as much data as the operating system gives it.</p>
|
||||
<p>If socket is disconnected during the recv operation then the future may complete with only a part of the requested data.</p>
|
||||
<p>If socket is disconnected and no data is available to be read then the future will complete with a value of <tt class="docutils literal"><span class="pre"><span class="DecNumber">0</span></span></tt>.</p>
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncnet.nim#L340" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncnet.nim#L340" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="recvLine-procs-all">
|
||||
<div id="recvLine,AsyncSocket">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#recvLine%2CAsyncSocket"><span class="Identifier">recvLine</span></a><span class="Other">(</span><span class="Identifier">socket</span><span class="Other">:</span> <a href="asyncnet.html#AsyncSocket"><span class="Identifier">AsyncSocket</span></a><span class="Other">;</span> <span class="Identifier">flags</span> <span class="Other">=</span> <span class="Other">{</span><span class="Identifier">SafeDisconn</span><span class="Other">}</span><span class="Other">;</span>
|
||||
<span class="Identifier">maxLength</span> <span class="Other">=</span> <span class="Identifier">MaxLineLength</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">owned</span><span class="Other">(</span><a href="asyncfutures.html#Future"><span class="Identifier">Future</span></a><span class="Other">[</span><a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">]</span><span class="Other">)</span> {.
|
||||
<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">stackTrace</span><span class="Other">:</span> <span class="DecNumber">false</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">Exception</span><span class="Other">,</span> <span class="Identifier">ValueError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">RootEffect</span><span class="Other">]</span><span class="Other">,</span>
|
||||
<span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Reads a line of data from <tt class="docutils literal"><span class="pre"><span class="Identifier">socket</span></span></tt>. Returned future will complete once a full line is read or an error occurs.</p>
|
||||
<p>If a full line is read <tt class="docutils literal"><span class="pre"><span class="Operator">\</span><span class="Identifier">r</span><span class="Operator">\</span><span class="Identifier">L</span></span></tt> is not added to <tt class="docutils literal"><span class="pre"><span class="Identifier">line</span></span></tt>, however if solely <tt class="docutils literal"><span class="pre"><span class="Operator">\</span><span class="Identifier">r</span><span class="Operator">\</span><span class="Identifier">L</span></span></tt> is read then <tt class="docutils literal"><span class="pre"><span class="Identifier">line</span></span></tt> will be set to it.</p>
|
||||
<p>If the socket is disconnected, <tt class="docutils literal"><span class="pre"><span class="Identifier">line</span></span></tt> will be set to <tt class="docutils literal"><span class="pre"><span class="StringLit">""</span></span></tt>.</p>
|
||||
<p>If the socket is disconnected in the middle of a line (before <tt class="docutils literal"><span class="pre"><span class="Operator">\</span><span class="Identifier">r</span><span class="Operator">\</span><span class="Identifier">L</span></span></tt> is read) then line will be set to <tt class="docutils literal"><span class="pre"><span class="StringLit">""</span></span></tt>. The partial line <strong>will be lost</strong>.</p>
|
||||
<p>The <tt class="docutils literal"><span class="pre"><span class="Identifier">maxLength</span></span></tt> parameter determines the maximum amount of characters that can be read. The result is truncated after that.</p>
|
||||
<div class="admonition admonition-warning"><span class="admonition-warning-text"><b>Warning:</b></span>
|
||||
The <tt class="docutils literal"><span class="pre"><span class="Identifier">Peek</span></span></tt> flag is not yet implemented.</div>
|
||||
<div class="admonition admonition-warning"><span class="admonition-warning-text"><b>Warning:</b></span>
|
||||
<tt class="docutils literal"><span class="pre"><span class="Identifier">recvLine</span></span></tt> on unbuffered sockets assumes that the protocol uses <tt class="docutils literal"><span class="pre"><span class="Operator">\</span><span class="Identifier">r</span><span class="Operator">\</span><span class="Identifier">L</span></span></tt> to delimit a new line.</div>
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncnet.nim#L603" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncnet.nim#L603" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="recvLineInto-procs-all">
|
||||
<div id="recvLineInto,AsyncSocket,FutureVar[string]">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#recvLineInto%2CAsyncSocket%2CFutureVar%5Bstring%5D"><span class="Identifier">recvLineInto</span></a><span class="Other">(</span><span class="Identifier">socket</span><span class="Other">:</span> <a href="asyncnet.html#AsyncSocket"><span class="Identifier">AsyncSocket</span></a><span class="Other">;</span> <span class="Identifier">resString</span><span class="Other">:</span> <a href="asyncfutures.html#FutureVar"><span class="Identifier">FutureVar</span></a><span class="Other">[</span><a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">]</span><span class="Other">;</span>
|
||||
<span class="Identifier">flags</span> <span class="Other">=</span> <span class="Other">{</span><span class="Identifier">SafeDisconn</span><span class="Other">}</span><span class="Other">;</span> <span class="Identifier">maxLength</span> <span class="Other">=</span> <span class="Identifier">MaxLineLength</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#owned"><span class="Identifier">owned</span></a><span class="Other">(</span>
|
||||
<a href="asyncfutures.html#Future"><span class="Identifier">Future</span></a><span class="Other">[</span><a href="system.html#void"><span class="Identifier">void</span></a><span class="Other">]</span><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">stackTrace</span><span class="Other">:</span> <span class="DecNumber">false</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ValueError</span><span class="Other">,</span> <span class="Identifier">Exception</span><span class="Other">]</span><span class="Other">,</span>
|
||||
<span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">RootEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Reads a line of data from <tt class="docutils literal"><span class="pre"><span class="Identifier">socket</span></span></tt> into <tt class="docutils literal"><span class="pre"><span class="Identifier">resString</span></span></tt>.</p>
|
||||
<p>If a full line is read <tt class="docutils literal"><span class="pre"><span class="Operator">\</span><span class="Identifier">r</span><span class="Operator">\</span><span class="Identifier">L</span></span></tt> is not added to <tt class="docutils literal"><span class="pre"><span class="Identifier">line</span></span></tt>, however if solely <tt class="docutils literal"><span class="pre"><span class="Operator">\</span><span class="Identifier">r</span><span class="Operator">\</span><span class="Identifier">L</span></span></tt> is read then <tt class="docutils literal"><span class="pre"><span class="Identifier">line</span></span></tt> will be set to it.</p>
|
||||
<p>If the socket is disconnected, <tt class="docutils literal"><span class="pre"><span class="Identifier">line</span></span></tt> will be set to <tt class="docutils literal"><span class="pre"><span class="StringLit">""</span></span></tt>.</p>
|
||||
<p>If the socket is disconnected in the middle of a line (before <tt class="docutils literal"><span class="pre"><span class="Operator">\</span><span class="Identifier">r</span><span class="Operator">\</span><span class="Identifier">L</span></span></tt> is read) then line will be set to <tt class="docutils literal"><span class="pre"><span class="StringLit">""</span></span></tt>. The partial line <strong>will be lost</strong>.</p>
|
||||
<p>The <tt class="docutils literal"><span class="pre"><span class="Identifier">maxLength</span></span></tt> parameter determines the maximum amount of characters that can be read. <tt class="docutils literal"><span class="pre"><span class="Identifier">resString</span></span></tt> will be truncated after that.</p>
|
||||
<div class="admonition admonition-warning"><span class="admonition-warning-text"><b>Warning:</b></span>
|
||||
The <tt class="docutils literal"><span class="pre"><span class="Identifier">Peek</span></span></tt> flag is not yet implemented.</div>
|
||||
<div class="admonition admonition-warning"><span class="admonition-warning-text"><b>Warning:</b></span>
|
||||
<tt class="docutils literal"><span class="pre"><span class="Identifier">recvLineInto</span></span></tt> on unbuffered sockets assumes that the protocol uses <tt class="docutils literal"><span class="pre"><span class="Operator">\</span><span class="Identifier">r</span><span class="Operator">\</span><span class="Identifier">L</span></span></tt> to delimit a new line.</div>
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncnet.nim#L511" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncnet.nim#L511" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="send-procs-all">
|
||||
<div id="send,AsyncSocket,pointer,int">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#send%2CAsyncSocket%2Cpointer%2Cint"><span class="Identifier">send</span></a><span class="Other">(</span><span class="Identifier">socket</span><span class="Other">:</span> <a href="asyncnet.html#AsyncSocket"><span class="Identifier">AsyncSocket</span></a><span class="Other">;</span> <span class="Identifier">buf</span><span class="Other">:</span> <a href="system.html#pointer"><span class="Identifier">pointer</span></a><span class="Other">;</span> <span class="Identifier">size</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a><span class="Other">;</span> <span class="Identifier">flags</span> <span class="Other">=</span> <span class="Other">{</span><span class="Identifier">SafeDisconn</span><span class="Other">}</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#owned"><span class="Identifier">owned</span></a><span class="Other">(</span>
|
||||
<a href="asyncfutures.html#Future"><span class="Identifier">Future</span></a><span class="Other">[</span><a href="system.html#void"><span class="Identifier">void</span></a><span class="Other">]</span><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">stackTrace</span><span class="Other">:</span> <span class="DecNumber">false</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">Exception</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">RootEffect</span><span class="Other">]</span><span class="Other">,</span>
|
||||
<span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Sends <tt class="docutils literal"><span class="pre"><span class="Identifier">size</span></span></tt> bytes from <tt class="docutils literal"><span class="pre"><span class="Identifier">buf</span></span></tt> to <tt class="docutils literal"><span class="pre"><span class="Identifier">socket</span></span></tt>. The returned future will complete once all data has been sent.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncnet.nim#L441" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncnet.nim#L441" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
<div id="send,AsyncSocket,string">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#send%2CAsyncSocket%2Cstring"><span class="Identifier">send</span></a><span class="Other">(</span><span class="Identifier">socket</span><span class="Other">:</span> <a href="asyncnet.html#AsyncSocket"><span class="Identifier">AsyncSocket</span></a><span class="Other">;</span> <span class="Identifier">data</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">flags</span> <span class="Other">=</span> <span class="Other">{</span><span class="Identifier">SafeDisconn</span><span class="Other">}</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#owned"><span class="Identifier">owned</span></a><span class="Other">(</span>
|
||||
<a href="asyncfutures.html#Future"><span class="Identifier">Future</span></a><span class="Other">[</span><a href="system.html#void"><span class="Identifier">void</span></a><span class="Other">]</span><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">stackTrace</span><span class="Other">:</span> <span class="DecNumber">false</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">Exception</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">RootEffect</span><span class="Other">]</span><span class="Other">,</span>
|
||||
<span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Sends <tt class="docutils literal"><span class="pre"><span class="Identifier">data</span></span></tt> to <tt class="docutils literal"><span class="pre"><span class="Identifier">socket</span></span></tt>. The returned future will complete once all data has been sent.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncnet.nim#L455" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncnet.nim#L455" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="sendTo-procs-all">
|
||||
<div id="sendTo,AsyncSocket,string,Port,string">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#sendTo%2CAsyncSocket%2Cstring%2CPort%2Cstring"><span class="Identifier">sendTo</span></a><span class="Other">(</span><span class="Identifier">socket</span><span class="Other">:</span> <a href="asyncnet.html#AsyncSocket"><span class="Identifier">AsyncSocket</span></a><span class="Other">;</span> <span class="Identifier">address</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">port</span><span class="Other">:</span> <a href="nativesockets.html#Port"><span class="Identifier">Port</span></a><span class="Other">;</span> <span class="Identifier">data</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span>
|
||||
<span class="Identifier">flags</span> <span class="Other">=</span> <span class="Other">{</span><span class="Identifier">SafeDisconn</span><span class="Other">}</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">owned</span><span class="Other">(</span><a href="asyncfutures.html#Future"><span class="Identifier">Future</span></a><span class="Other">[</span><a href="system.html#void"><span class="Identifier">void</span></a><span class="Other">]</span><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">stackTrace</span><span class="Other">:</span> <span class="DecNumber">false</span><span class="Other">,</span>
|
||||
<span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">Exception</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">RootEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>This proc sends <tt class="docutils literal"><span class="pre"><span class="Identifier">data</span></span></tt> to the specified <tt class="docutils literal"><span class="pre"><span class="Identifier">address</span></span></tt>, which may be an IP address or a hostname. If a hostname is specified this function will try each IP of that hostname. The returned future will complete once all data has been sent.</p>
|
||||
<p>If an error occurs an OSError exception will be raised.</p>
|
||||
<p>This proc is normally used with connectionless sockets (UDP sockets).</p>
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncnet.nim#L831" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncnet.nim#L831" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="setSockOpt-procs-all">
|
||||
<div id="setSockOpt,AsyncSocket,SOBool,bool">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#setSockOpt%2CAsyncSocket%2CSOBool%2Cbool"><span class="Identifier">setSockOpt</span></a><span class="Other">(</span><span class="Identifier">socket</span><span class="Other">:</span> <a href="asyncnet.html#AsyncSocket"><span class="Identifier">AsyncSocket</span></a><span class="Other">;</span> <span class="Identifier">opt</span><span class="Other">:</span> <a href="net.html#SOBool"><span class="Identifier">SOBool</span></a><span class="Other">;</span> <span class="Identifier">value</span><span class="Other">:</span> <a href="system.html#bool"><span class="Identifier">bool</span></a><span class="Other">;</span>
|
||||
<span class="Identifier">level</span> <span class="Other">=</span> <span class="Identifier">SOL_SOCKET</span><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><a href="exceptions.html#WriteIOEffect"><span class="Identifier">WriteIOEffect</span></a><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">OSError</span><span class="Other">]</span><span class="Other">,</span>
|
||||
<span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Sets option <tt class="docutils literal"><span class="pre"><span class="Identifier">opt</span></span></tt> to a boolean value specified by <tt class="docutils literal"><span class="pre"><span class="Identifier">value</span></span></tt>.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncnet.nim#L811" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncnet.nim#L811" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="sslHandle-procs-all">
|
||||
<div id="sslHandle,AsyncSocket">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#sslHandle%2CAsyncSocket"><span class="Identifier">sslHandle</span></a><span class="Other">(</span><span class="Identifier">self</span><span class="Other">:</span> <a href="asyncnet.html#AsyncSocket"><span class="Identifier">AsyncSocket</span></a><span class="Other">)</span><span class="Other">:</span> <a href="openssl.html#SslPtr"><span class="Identifier">SslPtr</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Retrieve the ssl pointer of <tt class="docutils literal"><span class="pre"><span class="Identifier">socket</span></span></tt>. Useful for interfacing with <tt class="docutils literal"><span class="pre"><span class="Identifier">openssl</span></span></tt>.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncnet.nim#L746" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncnet.nim#L746" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="wrapConnectedSocket-procs-all">
|
||||
<div id="wrapConnectedSocket,SslContext,AsyncSocket,SslHandshakeType,string">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#wrapConnectedSocket%2CSslContext%2CAsyncSocket%2CSslHandshakeType%2Cstring"><span class="Identifier">wrapConnectedSocket</span></a><span class="Other">(</span><span class="Identifier">ctx</span><span class="Other">:</span> <a href="net.html#SslContext"><span class="Identifier">SslContext</span></a><span class="Other">;</span> <span class="Identifier">socket</span><span class="Other">:</span> <a href="asyncnet.html#AsyncSocket"><span class="Identifier">AsyncSocket</span></a><span class="Other">;</span>
|
||||
<span class="Identifier">handshake</span><span class="Other">:</span> <a href="net.html#SslHandshakeType"><span class="Identifier">SslHandshakeType</span></a><span class="Other">;</span> <span class="Identifier">hostname</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> <span class="Other">=</span> <span class="StringLit">""</span><span class="Other">)</span> {.
|
||||
<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">SslError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Wraps a connected socket in an SSL context. This function effectively turns <tt class="docutils literal"><span class="pre"><span class="Identifier">socket</span></span></tt> into an SSL socket. <tt class="docutils literal"><span class="pre"><span class="Identifier">hostname</span></span></tt> should be specified so that the client knows which hostname the server certificate should be validated against.</p>
|
||||
<p>This should be called on a connected socket, and will perform an SSL handshake immediately.</p>
|
||||
<p><strong>Disclaimer</strong>: This code is not well tested, may be very unsafe and prone to security vulnerabilities.</p>
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncnet.nim#L769" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncnet.nim#L769" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="wrapSocket-procs-all">
|
||||
<div id="wrapSocket,SslContext,AsyncSocket">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#wrapSocket%2CSslContext%2CAsyncSocket"><span class="Identifier">wrapSocket</span></a><span class="Other">(</span><span class="Identifier">ctx</span><span class="Other">:</span> <a href="net.html#SslContext"><span class="Identifier">SslContext</span></a><span class="Other">;</span> <span class="Identifier">socket</span><span class="Other">:</span> <a href="asyncnet.html#AsyncSocket"><span class="Identifier">AsyncSocket</span></a><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">SslError</span><span class="Other">]</span><span class="Other">,</span>
|
||||
<span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Wraps a socket in an SSL context. This function effectively turns <tt class="docutils literal"><span class="pre"><span class="Identifier">socket</span></span></tt> into an SSL socket.</p>
|
||||
<p><strong>Disclaimer</strong>: This code is not well tested, may be very unsafe and prone to security vulnerabilities.</p>
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncnet.nim#L751" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncnet.nim#L751" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</dl>
|
||||
</div>
|
||||
<div class="section" id="19">
|
||||
<h1><a class="toc-backref" href="#19">Exports</a></h1>
|
||||
<dl class="item">
|
||||
<a href="net.html#SOBool"><span class="Identifier">SOBool</span></a>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="twelve-columns footer">
|
||||
<span class="nim-sprite"></span>
|
||||
<br>
|
||||
<small style="color: var(--hint);">Made with Nim. Generated: 2023-03-13 00:19:44 UTC</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script defer data-domain="nim-lang.org" src="https://plausible.io/js/plausible.js"></script>
|
||||
|
||||
<!-- Google fonts -->
|
||||
<link href='https://fonts.googleapis.com/css?family=Lato:400,600,900' rel='stylesheet' type='text/css'/>
|
||||
<link href='https://fonts.googleapis.com/css?family=Source+Code+Pro:400,500,600' rel='stylesheet' type='text/css'/>
|
||||
</body>
|
||||
</html>
|
||||
44
asyncnet.idx
Normal file
44
asyncnet.idx
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
nimTitle asyncnet asyncnet.html module std/asyncnet 0
|
||||
nim AsyncSocket asyncnet.html#AsyncSocket type AsyncSocket 135
|
||||
nim newAsyncSocket asyncnet.html#newAsyncSocket,AsyncFD,Domain,SockType,Protocol proc newAsyncSocket(fd: AsyncFD; domain: Domain = AF_INET;\n sockType: SockType = SOCK_STREAM;\n protocol: Protocol = IPPROTO_TCP; buffered = true;\n inheritable = defined(nimInheritHandles)): owned(AsyncSocket) 137
|
||||
nim newAsyncSocket asyncnet.html#newAsyncSocket,Domain,SockType,Protocol proc newAsyncSocket(domain: Domain = AF_INET; sockType: SockType = SOCK_STREAM;\n protocol: Protocol = IPPROTO_TCP; buffered = true;\n inheritable = defined(nimInheritHandles)): owned(AsyncSocket) 165
|
||||
nim getLocalAddr asyncnet.html#getLocalAddr,AsyncSocket proc getLocalAddr(socket: AsyncSocket): (string, Port) 180
|
||||
nim getPeerAddr asyncnet.html#getPeerAddr,AsyncSocket proc getPeerAddr(socket: AsyncSocket): (string, Port) 187
|
||||
nim newAsyncSocket asyncnet.html#newAsyncSocket,cint,cint,cint proc newAsyncSocket(domain, sockType, protocol: cint; buffered = true;\n inheritable = defined(nimInheritHandles)): owned(AsyncSocket) 193
|
||||
nim dial asyncnet.html#dial,string,Port proc dial(address: string; port: Port; protocol = IPPROTO_TCP; buffered = true): owned(\n Future[AsyncSocket]) 287
|
||||
nim connect asyncnet.html#connect,AsyncSocket,string,Port proc connect(socket: AsyncSocket; address: string; port: Port): owned(\n Future[void]) 298
|
||||
nim recvInto asyncnet.html#recvInto,AsyncSocket,pointer,int proc recvInto(socket: AsyncSocket; buf: pointer; size: int; flags = {SafeDisconn}): owned(\n Future[int]) 340
|
||||
nim recv asyncnet.html#recv,AsyncSocket,int proc recv(socket: AsyncSocket; size: int; flags = {SafeDisconn}): owned(\n Future[string]) 388
|
||||
nim send asyncnet.html#send,AsyncSocket,pointer,int proc send(socket: AsyncSocket; buf: pointer; size: int; flags = {SafeDisconn}): owned(\n Future[void]) 441
|
||||
nim send asyncnet.html#send,AsyncSocket,string proc send(socket: AsyncSocket; data: string; flags = {SafeDisconn}): owned(\n Future[void]) 455
|
||||
nim acceptAddr asyncnet.html#acceptAddr,AsyncSocket proc acceptAddr(socket: AsyncSocket; flags = {SafeDisconn};\n inheritable = defined(nimInheritHandles)): owned(\n Future[tuple[address: string, client: AsyncSocket]]) 468
|
||||
nim accept asyncnet.html#accept,AsyncSocket proc accept(socket: AsyncSocket; flags = {SafeDisconn}): owned(Future[AsyncSocket]) 492
|
||||
nim recvLineInto asyncnet.html#recvLineInto,AsyncSocket,FutureVar[string] proc recvLineInto(socket: AsyncSocket; resString: FutureVar[string];\n flags = {SafeDisconn}; maxLength = MaxLineLength): owned(\n Future[void]) 511
|
||||
nim recvLine asyncnet.html#recvLine,AsyncSocket proc recvLine(socket: AsyncSocket; flags = {SafeDisconn}; maxLength = MaxLineLength): owned(\n Future[string]) 603
|
||||
nim listen asyncnet.html#listen,AsyncSocket proc listen(socket: AsyncSocket; backlog = SOMAXCONN) 631
|
||||
nim bindAddr asyncnet.html#bindAddr,AsyncSocket,string proc bindAddr(socket: AsyncSocket; port = Port(0); address = "") 640
|
||||
nim hasDataBuffered asyncnet.html#hasDataBuffered,AsyncSocket proc hasDataBuffered(s: AsyncSocket): bool 660
|
||||
nim connectUnix asyncnet.html#connectUnix,AsyncSocket,string proc connectUnix(socket: AsyncSocket; path: string): owned(Future[void]) 667
|
||||
nim bindUnix asyncnet.html#bindUnix,AsyncSocket,string proc bindUnix(socket: AsyncSocket; path: string) 698
|
||||
nim close asyncnet.html#close,AsyncSocket proc close(socket: AsyncSocket) 720
|
||||
nim sslHandle asyncnet.html#sslHandle,AsyncSocket proc sslHandle(self: AsyncSocket): SslPtr 746
|
||||
nim wrapSocket asyncnet.html#wrapSocket,SslContext,AsyncSocket proc wrapSocket(ctx: SslContext; socket: AsyncSocket) 751
|
||||
nim wrapConnectedSocket asyncnet.html#wrapConnectedSocket,SslContext,AsyncSocket,SslHandshakeType,string proc wrapConnectedSocket(ctx: SslContext; socket: AsyncSocket;\n handshake: SslHandshakeType; hostname: string = "") 769
|
||||
nim getPeerCertificates asyncnet.html#getPeerCertificates,AsyncSocket proc getPeerCertificates(socket: AsyncSocket): seq[Certificate] 794
|
||||
nim getSockOpt asyncnet.html#getSockOpt,AsyncSocket,SOBool proc getSockOpt(socket: AsyncSocket; opt: SOBool; level = SOL_SOCKET): bool 805
|
||||
nim setSockOpt asyncnet.html#setSockOpt,AsyncSocket,SOBool,bool proc setSockOpt(socket: AsyncSocket; opt: SOBool; value: bool; level = SOL_SOCKET) 811
|
||||
nim isSsl asyncnet.html#isSsl,AsyncSocket proc isSsl(socket: AsyncSocket): bool 817
|
||||
nim getFd asyncnet.html#getFd,AsyncSocket proc getFd(socket: AsyncSocket): SocketHandle 821
|
||||
nim isClosed asyncnet.html#isClosed,AsyncSocket proc isClosed(socket: AsyncSocket): bool 825
|
||||
nim sendTo asyncnet.html#sendTo,AsyncSocket,string,Port,string proc sendTo(socket: AsyncSocket; address: string; port: Port; data: string;\n flags = {SafeDisconn}): owned(Future[void]) 831
|
||||
nim recvFrom asyncnet.html#recvFrom,AsyncSocket,FutureVar[string],int,FutureVar[string],FutureVar[Port] proc recvFrom(socket: AsyncSocket; data: FutureVar[string]; size: int;\n address: FutureVar[string]; port: FutureVar[Port];\n flags = {SafeDisconn}): owned(Future[int]) 878
|
||||
nim recvFrom asyncnet.html#recvFrom,AsyncSocket,int proc recvFrom(socket: AsyncSocket; size: int; flags = {SafeDisconn}): owned(\n Future[tuple[data: string, address: string, port: Port]]) 932
|
||||
heading Asynchronous IO in Nim asyncnet.html#asynchronous-io-in-nim Asynchronous IO in Nim 0
|
||||
heading SSL asyncnet.html#ssl SSL 0
|
||||
heading Examples asyncnet.html#examples Examples 0
|
||||
heading Chat server asyncnet.html#examples-chat-server Chat server 0
|
||||
idx getpeername asyncnet.html#getpeername_1 Chat server 0
|
||||
idx getsockname asyncnet.html#getsockname_1 Chat server 0
|
||||
nimgrp recvfrom asyncnet.html#recvFrom-procs-all proc 875
|
||||
nimgrp newasyncsocket asyncnet.html#newAsyncSocket-procs-all proc 137
|
||||
nimgrp send asyncnet.html#send-procs-all proc 440
|
||||
297
asyncstreams.html
Normal file
297
asyncstreams.html
Normal file
|
|
@ -0,0 +1,297 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<!-- This file is generated by Nim. -->
|
||||
<html xmlns="https://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>std/asyncstreams</title>
|
||||
|
||||
<!-- Favicon -->
|
||||
<link rel="shortcut icon" href="data:image/x-icon;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAUAAAAF////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAIAAABbAAAAlQAAAKIAAACbAAAAmwAAAKIAAACVAAAAWwAAAAL///8A////AP///wD///8A////AAAAABQAAADAAAAAYwAAAA3///8A////AP///wD///8AAAAADQAAAGMAAADAAAAAFP///wD///8A////AP///wAAAACdAAAAOv///wD///8A////AP///wD///8A////AP///wD///8AAAAAOgAAAJ3///8A////AP///wAAAAAnAAAAcP///wAAAAAoAAAASv///wD///8A////AP///wAAAABKAAAAKP///wAAAABwAAAAJ////wD///8AAAAAgQAAABwAAACIAAAAkAAAAJMAAACtAAAAFQAAABUAAACtAAAAkwAAAJAAAACIAAAAHAAAAIH///8A////AAAAAKQAAACrAAAAaP///wD///8AAAAARQAAANIAAADSAAAARf///wD///8AAAAAaAAAAKsAAACk////AAAAADMAAACcAAAAnQAAABj///8A////AP///wAAAAAYAAAAGP///wD///8A////AAAAABgAAACdAAAAnAAAADMAAAB1AAAAwwAAAP8AAADpAAAAsQAAAE4AAAAb////AP///wAAAAAbAAAATgAAALEAAADpAAAA/wAAAMMAAAB1AAAAtwAAAOkAAAD/AAAA/wAAAP8AAADvAAAA3gAAAN4AAADeAAAA3gAAAO8AAAD/AAAA/wAAAP8AAADpAAAAtwAAAGUAAAA/AAAA3wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAADfAAAAPwAAAGX///8A////AAAAAEgAAADtAAAAvwAAAL0AAADGAAAA7wAAAO8AAADGAAAAvQAAAL8AAADtAAAASP///wD///8A////AP///wD///8AAAAAO////wD///8A////AAAAAIcAAACH////AP///wD///8AAAAAO////wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A//8AAP//AAD4HwAA7/cAAN/7AAD//wAAoYUAAJ55AACf+QAAh+EAAAAAAADAAwAA4AcAAP5/AAD//wAA//8AAA=="/>
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAA3XAAAN1wFCKJt4AAAAB3RJTUUH4QQQEwksSS9ZWwAAAk1JREFUWMPtll2ITVEUx39nn/O7Y5qR8f05wtCUUr6ZIS++8pEnkZInPImneaCQ5METNdOkeFBKUhMPRIkHKfEuUZSUlGlKPN2TrgfncpvmnntnmlEyq1Z7t89/rf9a6+y99oZxGZf/XeIq61EdtgKXgdXA0xrYAvBjOIF1AI9zvjcC74BSpndrJPkBWDScTF8Aa4E3wDlgHbASaANmVqlcCnwHvgDvgVfAJ+AikAAvgfVZwLnSVZHZaOuKoQi3ZOMi4NkYkpe1p4J7A8BpYAD49hfIy/oqG0+hLomiKP2L5L+1ubn5115S+3OAn4EnwBlgMzCjyt6ZAnQCJ4A7wOs88iRJHvw50HoujuPBoCKwHWiosy8MdfZnAdcHk8dxXFJ3VQbQlCTJvRBCGdRbD4M6uc5glpY3eAihpN5S5w12diSEcCCEcKUO4ljdr15T76ur1FDDLIQQ3qv71EdDOe3Kxj3leRXyk+pxdWnFWod6Wt2bY3de3aSuUHcPBVimHs7mK9WrmeOF6lR1o9qnzskh2ar2qm1qizpfXaPeVGdlmGN5pb09qMxz1Xb1kLqgzn1RyH7JUXW52lr5e/Kqi9qpto7V1atuUzfnARrV7jEib1T76gG2qxdGmXyiekkt1GswPTtek0aBfJp6YySGBfWg2tPQ0FAYgf1stUfdmdcjarbYJEniKIq6gY/Aw+zWHAC+p2labGpqiorFYgGYCEzN7oQdQClN07O1/EfDyGgC0ALMBdYAi4FyK+4H3gLPsxfR1zRNi+NP7nH5J+QntnXe5B5mpfQAAAAASUVORK5CYII=">
|
||||
|
||||
<!-- CSS -->
|
||||
<link rel="stylesheet" type="text/css" href="nimdoc.out.css">
|
||||
|
||||
<!-- JS -->
|
||||
<script type="text/javascript" src="dochack.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="document" id="documentId">
|
||||
<div class="container">
|
||||
<h1 class="title">std/asyncstreams</h1>
|
||||
<div class="row">
|
||||
<div class="three columns">
|
||||
<div class="theme-select-wrapper">
|
||||
<label for="theme-select">Theme: </label>
|
||||
<select id="theme-select" onchange="setTheme(this.value)">
|
||||
<option value="auto">🌗 Match OS</option>
|
||||
<option value="dark">🌑 Dark</option>
|
||||
<option value="light">🌕 Light</option>
|
||||
</select>
|
||||
</div>
|
||||
<div id="global-links">
|
||||
<ul class="simple-boot">
|
||||
<li><a href="manual.html">Manual</a></li>
|
||||
<li><a href="lib.html">Standard library</a></li>
|
||||
<li> <a id="indexLink" href="theindex.html">Index</a></li>
|
||||
<li><a href="compiler/theindex.html">Compiler docs</a></li>
|
||||
<li><a href="https://nim-lang.github.io/fusion/theindex.html">Fusion docs</a></li>
|
||||
<li><a href="https://nim-lang.github.io/Nim/">devel</a>, <a href="https://nim-lang.org/documentation.html">stable</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="searchInputDiv">
|
||||
Search: <input type="search" id="searchInput"
|
||||
onkeyup="search()" />
|
||||
</div>
|
||||
|
||||
<ul class="simple simple-toc" id="toc-list">
|
||||
<li>
|
||||
<a class="reference reference-toplevel" href="#6" id="56">Imports</a>
|
||||
</li>
|
||||
<li>
|
||||
<details open>
|
||||
<summary><a class="reference reference-toplevel" href="#7" id="57">Types</a></summary>
|
||||
<ul class="simple simple-toc-section">
|
||||
<li><a class="reference" href="#FutureStream" title="FutureStream[T] = ref object
|
||||
error*: ref Exception">FutureStream</a></li>
|
||||
|
||||
</ul>
|
||||
</details>
|
||||
</li>
|
||||
<li>
|
||||
<details open>
|
||||
<summary><a class="reference reference-toplevel" href="#12" id="62">Procs</a></summary>
|
||||
<ul class="simple simple-toc-section">
|
||||
<ul class="simple nested-toc-section">callback=
|
||||
<li><a class="reference" href="#callback%3D%2CFutureStream%5BT%5D%2Cproc%28FutureStream%5BT%5D%29" title="callback=[T](future: FutureStream[T];
|
||||
cb: proc (future: FutureStream[T]) {.closure, gcsafe.})">callback=[T](future: FutureStream[T];
|
||||
cb: proc (future: FutureStream[T]) {.closure, gcsafe.})</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">complete
|
||||
<li><a class="reference" href="#complete%2CFutureStream%5BT%5D" title="complete[T](future: FutureStream[T])">complete[T](future: FutureStream[T])</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">fail
|
||||
<li><a class="reference" href="#fail%2CFutureStream%5BT%5D%2Cref.Exception" title="fail[T](future: FutureStream[T]; error: ref Exception)">fail[T](future: FutureStream[T]; error: ref Exception)</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">failed
|
||||
<li><a class="reference" href="#failed%2CFutureStream%5BT%5D" title="failed[T](future: FutureStream[T]): bool">failed[T](future: FutureStream[T]): bool</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">finished
|
||||
<li><a class="reference" href="#finished%2CFutureStream%5BT%5D" title="finished[T](future: FutureStream[T]): bool">finished[T](future: FutureStream[T]): bool</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">len
|
||||
<li><a class="reference" href="#len%2CFutureStream%5BT%5D" title="len[T](future: FutureStream[T]): int">len[T](future: FutureStream[T]): int</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">newFutureStream
|
||||
<li><a class="reference" href="#newFutureStream%2Cstring" title="newFutureStream[T](fromProc = "unspecified"): FutureStream[T]">newFutureStream[T](fromProc = "unspecified"): FutureStream[T]</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">read
|
||||
<li><a class="reference" href="#read%2CFutureStream%5BT%5D" title="read[T](future: FutureStream[T]): owned(Future[(bool, T)])">read[T](future: FutureStream[T]): owned(Future[(bool, T)])</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">write
|
||||
<li><a class="reference" href="#write%2CFutureStream%5BT%5D%2CT" title="write[T](future: FutureStream[T]; value: T): Future[void]">write[T](future: FutureStream[T]; value: T): Future[void]</a></li>
|
||||
|
||||
</ul>
|
||||
|
||||
</ul>
|
||||
</details>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
<div class="nine columns" id="content">
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncstreams.nim#L1" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncstreams.nim#L1" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
<div id="tocRoot"></div>
|
||||
|
||||
<p class="module-desc">Unstable API.</p>
|
||||
<div class="section" id="6">
|
||||
<h1><a class="toc-backref" href="#6">Imports</a></h1>
|
||||
<dl class="item">
|
||||
<a class="reference external" href="asyncfutures.html">asyncfutures</a>, <a class="reference external" href="assertions.html">assertions</a>, <a class="reference external" href="deques.html">deques</a>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="section" id="7">
|
||||
<h1><a class="toc-backref" href="#7">Types</a></h1>
|
||||
<dl class="item">
|
||||
<div id="FutureStream">
|
||||
<dt><pre><a href="asyncstreams.html#FutureStream"><span class="Identifier">FutureStream</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span> <span class="Other">=</span> <span class="Keyword">ref</span> <span class="Keyword">object</span>
|
||||
<span class="Identifier">error</span><span class="Operator">*</span><span class="Other">:</span> <span class="Keyword">ref</span> <a href="system.html#Exception"><span class="Identifier">Exception</span></a>
|
||||
</pre></dt>
|
||||
<dd>
|
||||
|
||||
Special future that acts as a queue. Its API is still experimental and so is subject to change.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncstreams.nim#L20" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncstreams.nim#L20" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</dl>
|
||||
</div>
|
||||
<div class="section" id="12">
|
||||
<h1><a class="toc-backref" href="#12">Procs</a></h1>
|
||||
<dl class="item">
|
||||
<div id="callback=-procs-all">
|
||||
<div id="callback=,FutureStream[T],proc(FutureStream[T])">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#callback%3D%2CFutureStream%5BT%5D%2Cproc%28FutureStream%5BT%5D%29"><span class="Identifier">callback=</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">future</span><span class="Other">:</span> <a href="asyncstreams.html#FutureStream"><span class="Identifier">FutureStream</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span>
|
||||
<span class="Identifier">cb</span><span class="Other">:</span> <span class="Keyword">proc</span> <span class="Other">(</span><span class="Identifier">future</span><span class="Other">:</span> <a href="asyncstreams.html#FutureStream"><span class="Identifier">FutureStream</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">)</span> {.<span class="Identifier">closure</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span></span>.}<span class="Other">)</span></pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Sets the callback proc to be called when data was placed inside the future stream.</p>
|
||||
<p>The callback is also called when the future is completed. So you should use <tt class="docutils literal"><span class="pre"><span class="Identifier">finished</span></span></tt> to check whether data is available.</p>
|
||||
<p>If the future stream already has data or is finished then <tt class="docutils literal"><span class="pre"><span class="Identifier">cb</span></span></tt> will be called immediately.</p>
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncstreams.nim#L60" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncstreams.nim#L60" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="complete-procs-all">
|
||||
<div id="complete,FutureStream[T]">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#complete%2CFutureStream%5BT%5D"><span class="Identifier">complete</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">future</span><span class="Other">:</span> <a href="asyncstreams.html#FutureStream"><span class="Identifier">FutureStream</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">)</span></pre></dt>
|
||||
<dd>
|
||||
|
||||
Completes a <tt class="docutils literal"><span class="pre"><span class="Identifier">FutureStream</span></span></tt> signalling the end of data.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncstreams.nim#L45" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncstreams.nim#L45" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="fail-procs-all">
|
||||
<div id="fail,FutureStream[T],ref.Exception">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#fail%2CFutureStream%5BT%5D%2Cref.Exception"><span class="Identifier">fail</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">future</span><span class="Other">:</span> <a href="asyncstreams.html#FutureStream"><span class="Identifier">FutureStream</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">error</span><span class="Other">:</span> <span class="Keyword">ref</span> <a href="system.html#Exception"><span class="Identifier">Exception</span></a><span class="Other">)</span></pre></dt>
|
||||
<dd>
|
||||
|
||||
Completes <tt class="docutils literal"><span class="pre"><span class="Identifier">future</span></span></tt> with <tt class="docutils literal"><span class="pre"><span class="Identifier">error</span></span></tt>.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncstreams.nim#L52" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncstreams.nim#L52" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="failed-procs-all">
|
||||
<div id="failed,FutureStream[T]">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#failed%2CFutureStream%5BT%5D"><span class="Identifier">failed</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">future</span><span class="Other">:</span> <a href="asyncstreams.html#FutureStream"><span class="Identifier">FutureStream</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#bool"><span class="Identifier">bool</span></a></pre></dt>
|
||||
<dd>
|
||||
|
||||
Determines whether <tt class="docutils literal"><span class="pre"><span class="Identifier">future</span></span></tt> completed with an error.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncstreams.nim#L81" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncstreams.nim#L81" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="finished-procs-all">
|
||||
<div id="finished,FutureStream[T]">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#finished%2CFutureStream%5BT%5D"><span class="Identifier">finished</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">future</span><span class="Other">:</span> <a href="asyncstreams.html#FutureStream"><span class="Identifier">FutureStream</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#bool"><span class="Identifier">bool</span></a></pre></dt>
|
||||
<dd>
|
||||
|
||||
Check if a <tt class="docutils literal"><span class="pre"><span class="Identifier">FutureStream</span></span></tt> is finished. <tt class="docutils literal"><span class="pre"><span class="Identifier">true</span></span></tt> value means that no more data will be placed inside the stream <em>and</em> that there is no data waiting to be retrieved.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncstreams.nim#L75" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncstreams.nim#L75" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="len-procs-all">
|
||||
<div id="len,FutureStream[T]">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#len%2CFutureStream%5BT%5D"><span class="Identifier">len</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">future</span><span class="Other">:</span> <a href="asyncstreams.html#FutureStream"><span class="Identifier">FutureStream</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a></pre></dt>
|
||||
<dd>
|
||||
|
||||
Returns the amount of data pieces inside the stream.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncstreams.nim#L145" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncstreams.nim#L145" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="newFutureStream-procs-all">
|
||||
<div id="newFutureStream,string">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#newFutureStream%2Cstring"><span class="Identifier">newFutureStream</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">fromProc</span> <span class="Other">=</span> <span class="StringLit">"unspecified"</span><span class="Other">)</span><span class="Other">:</span> <a href="asyncstreams.html#FutureStream"><span class="Identifier">FutureStream</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span></pre></dt>
|
||||
<dd>
|
||||
|
||||
Create a new <tt class="docutils literal"><span class="pre"><span class="Identifier">FutureStream</span></span></tt>. This future's callback is activated when two events occur:<ul class="simple"><li>New data is written into the future stream.</li>
|
||||
<li>The future stream is completed (this means that no more data will be written).</li>
|
||||
</ul>
|
||||
<p>Specifying <tt class="docutils literal"><span class="pre"><span class="Identifier">fromProc</span></span></tt>, which is a string specifying the name of the proc that this future belongs to, is a good habit as it helps with debugging.</p>
|
||||
<p><strong>Note:</strong> The API of FutureStream is still new and so has a higher likelihood of changing in the future.</p>
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncstreams.nim#L29" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncstreams.nim#L29" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="read-procs-all">
|
||||
<div id="read,FutureStream[T]">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#read%2CFutureStream%5BT%5D"><span class="Identifier">read</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">future</span><span class="Other">:</span> <a href="asyncstreams.html#FutureStream"><span class="Identifier">FutureStream</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">owned</span><span class="Other">(</span><a href="asyncfutures.html#Future"><span class="Identifier">Future</span></a><span class="Other">[</span><span class="Other">(</span><a href="system.html#bool"><span class="Identifier">bool</span></a><span class="Other">,</span> <span class="Identifier">T</span><span class="Other">)</span><span class="Other">]</span><span class="Other">)</span></pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Returns a future that will complete when the <tt class="docutils literal"><span class="pre"><span class="Identifier">FutureStream</span></span></tt> has data placed into it. The future will be completed with the oldest value stored inside the stream. The return value will also determine whether data was retrieved, <tt class="docutils literal"><span class="pre"><span class="Identifier">false</span></span></tt> means that the future stream was completed and no data was retrieved.</p>
|
||||
<p>This function will remove the data that was returned from the underlying <tt class="docutils literal"><span class="pre"><span class="Identifier">FutureStream</span></span></tt>.</p>
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncstreams.nim#L100" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncstreams.nim#L100" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="write-procs-all">
|
||||
<div id="write,FutureStream[T],T">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#write%2CFutureStream%5BT%5D%2CT"><span class="Identifier">write</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">future</span><span class="Other">:</span> <a href="asyncstreams.html#FutureStream"><span class="Identifier">FutureStream</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">value</span><span class="Other">:</span> <span class="Identifier">T</span><span class="Other">)</span><span class="Other">:</span> <a href="asyncfutures.html#Future"><span class="Identifier">Future</span></a><span class="Other">[</span><a href="system.html#void"><span class="Identifier">void</span></a><span class="Other">]</span></pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Writes the specified value inside the specified future stream.</p>
|
||||
<p>This will raise <tt class="docutils literal"><span class="pre"><span class="Identifier">ValueError</span></span></tt> if <tt class="docutils literal"><span class="pre"><span class="Identifier">future</span></span></tt> is finished.</p>
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/asyncstreams.nim#L85" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/asyncstreams.nim#L85" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="twelve-columns footer">
|
||||
<span class="nim-sprite"></span>
|
||||
<br>
|
||||
<small style="color: var(--hint);">Made with Nim. Generated: 2023-03-13 00:19:19 UTC</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script defer data-domain="nim-lang.org" src="https://plausible.io/js/plausible.js"></script>
|
||||
|
||||
<!-- Google fonts -->
|
||||
<link href='https://fonts.googleapis.com/css?family=Lato:400,600,900' rel='stylesheet' type='text/css'/>
|
||||
<link href='https://fonts.googleapis.com/css?family=Source+Code+Pro:400,500,600' rel='stylesheet' type='text/css'/>
|
||||
</body>
|
||||
</html>
|
||||
11
asyncstreams.idx
Normal file
11
asyncstreams.idx
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
nimTitle asyncstreams asyncstreams.html module std/asyncstreams 0
|
||||
nim FutureStream asyncstreams.html#FutureStream type FutureStream 20
|
||||
nim newFutureStream asyncstreams.html#newFutureStream,string proc newFutureStream[T](fromProc = "unspecified"): FutureStream[T] 29
|
||||
nim complete asyncstreams.html#complete,FutureStream[T] proc complete[T](future: FutureStream[T]) 45
|
||||
nim fail asyncstreams.html#fail,FutureStream[T],ref.Exception proc fail[T](future: FutureStream[T]; error: ref Exception) 52
|
||||
nim callback= asyncstreams.html#callback=,FutureStream[T],proc(FutureStream[T]) proc callback=[T](future: FutureStream[T];\n cb: proc (future: FutureStream[T]) {.closure, gcsafe.}) 60
|
||||
nim finished asyncstreams.html#finished,FutureStream[T] proc finished[T](future: FutureStream[T]): bool 75
|
||||
nim failed asyncstreams.html#failed,FutureStream[T] proc failed[T](future: FutureStream[T]): bool 81
|
||||
nim write asyncstreams.html#write,FutureStream[T],T proc write[T](future: FutureStream[T]; value: T): Future[void] 85
|
||||
nim read asyncstreams.html#read,FutureStream[T] proc read[T](future: FutureStream[T]): owned(Future[(bool, T)]) 100
|
||||
nim len asyncstreams.html#len,FutureStream[T] proc len[T](future: FutureStream[T]): int 145
|
||||
611
atomics.html
Normal file
611
atomics.html
Normal file
|
|
@ -0,0 +1,611 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<!-- This file is generated by Nim. -->
|
||||
<html xmlns="https://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>std/atomics</title>
|
||||
|
||||
<!-- Favicon -->
|
||||
<link rel="shortcut icon" href="data:image/x-icon;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAUAAAAF////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAIAAABbAAAAlQAAAKIAAACbAAAAmwAAAKIAAACVAAAAWwAAAAL///8A////AP///wD///8A////AAAAABQAAADAAAAAYwAAAA3///8A////AP///wD///8AAAAADQAAAGMAAADAAAAAFP///wD///8A////AP///wAAAACdAAAAOv///wD///8A////AP///wD///8A////AP///wD///8AAAAAOgAAAJ3///8A////AP///wAAAAAnAAAAcP///wAAAAAoAAAASv///wD///8A////AP///wAAAABKAAAAKP///wAAAABwAAAAJ////wD///8AAAAAgQAAABwAAACIAAAAkAAAAJMAAACtAAAAFQAAABUAAACtAAAAkwAAAJAAAACIAAAAHAAAAIH///8A////AAAAAKQAAACrAAAAaP///wD///8AAAAARQAAANIAAADSAAAARf///wD///8AAAAAaAAAAKsAAACk////AAAAADMAAACcAAAAnQAAABj///8A////AP///wAAAAAYAAAAGP///wD///8A////AAAAABgAAACdAAAAnAAAADMAAAB1AAAAwwAAAP8AAADpAAAAsQAAAE4AAAAb////AP///wAAAAAbAAAATgAAALEAAADpAAAA/wAAAMMAAAB1AAAAtwAAAOkAAAD/AAAA/wAAAP8AAADvAAAA3gAAAN4AAADeAAAA3gAAAO8AAAD/AAAA/wAAAP8AAADpAAAAtwAAAGUAAAA/AAAA3wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAADfAAAAPwAAAGX///8A////AAAAAEgAAADtAAAAvwAAAL0AAADGAAAA7wAAAO8AAADGAAAAvQAAAL8AAADtAAAASP///wD///8A////AP///wD///8AAAAAO////wD///8A////AAAAAIcAAACH////AP///wD///8AAAAAO////wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A//8AAP//AAD4HwAA7/cAAN/7AAD//wAAoYUAAJ55AACf+QAAh+EAAAAAAADAAwAA4AcAAP5/AAD//wAA//8AAA=="/>
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAA3XAAAN1wFCKJt4AAAAB3RJTUUH4QQQEwksSS9ZWwAAAk1JREFUWMPtll2ITVEUx39nn/O7Y5qR8f05wtCUUr6ZIS++8pEnkZInPImneaCQ5METNdOkeFBKUhMPRIkHKfEuUZSUlGlKPN2TrgfncpvmnntnmlEyq1Z7t89/rf9a6+y99oZxGZf/XeIq61EdtgKXgdXA0xrYAvBjOIF1AI9zvjcC74BSpndrJPkBWDScTF8Aa4E3wDlgHbASaANmVqlcCnwHvgDvgVfAJ+AikAAvgfVZwLnSVZHZaOuKoQi3ZOMi4NkYkpe1p4J7A8BpYAD49hfIy/oqG0+hLomiKP2L5L+1ubn5115S+3OAn4EnwBlgMzCjyt6ZAnQCJ4A7wOs88iRJHvw50HoujuPBoCKwHWiosy8MdfZnAdcHk8dxXFJ3VQbQlCTJvRBCGdRbD4M6uc5glpY3eAihpN5S5w12diSEcCCEcKUO4ljdr15T76ur1FDDLIQQ3qv71EdDOe3Kxj3leRXyk+pxdWnFWod6Wt2bY3de3aSuUHcPBVimHs7mK9WrmeOF6lR1o9qnzskh2ar2qm1qizpfXaPeVGdlmGN5pb09qMxz1Xb1kLqgzn1RyH7JUXW52lr5e/Kqi9qpto7V1atuUzfnARrV7jEib1T76gG2qxdGmXyiekkt1GswPTtek0aBfJp6YySGBfWg2tPQ0FAYgf1stUfdmdcjarbYJEniKIq6gY/Aw+zWHAC+p2labGpqiorFYgGYCEzN7oQdQClN07O1/EfDyGgC0ALMBdYAi4FyK+4H3gLPsxfR1zRNi+NP7nH5J+QntnXe5B5mpfQAAAAASUVORK5CYII=">
|
||||
|
||||
<!-- CSS -->
|
||||
<link rel="stylesheet" type="text/css" href="nimdoc.out.css">
|
||||
|
||||
<!-- JS -->
|
||||
<script type="text/javascript" src="dochack.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="document" id="documentId">
|
||||
<div class="container">
|
||||
<h1 class="title">std/atomics</h1>
|
||||
<div class="row">
|
||||
<div class="three columns">
|
||||
<div class="theme-select-wrapper">
|
||||
<label for="theme-select">Theme: </label>
|
||||
<select id="theme-select" onchange="setTheme(this.value)">
|
||||
<option value="auto">🌗 Match OS</option>
|
||||
<option value="dark">🌑 Dark</option>
|
||||
<option value="light">🌕 Light</option>
|
||||
</select>
|
||||
</div>
|
||||
<div id="global-links">
|
||||
<ul class="simple-boot">
|
||||
<li><a href="manual.html">Manual</a></li>
|
||||
<li><a href="lib.html">Standard library</a></li>
|
||||
<li> <a id="indexLink" href="theindex.html">Index</a></li>
|
||||
<li><a href="compiler/theindex.html">Compiler docs</a></li>
|
||||
<li><a href="https://nim-lang.github.io/fusion/theindex.html">Fusion docs</a></li>
|
||||
<li><a href="https://nim-lang.github.io/Nim/">devel</a>, <a href="https://nim-lang.org/documentation.html">stable</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="searchInputDiv">
|
||||
Search: <input type="search" id="searchInput"
|
||||
onkeyup="search()" />
|
||||
</div>
|
||||
|
||||
<ul class="simple simple-toc" id="toc-list">
|
||||
<li>
|
||||
<details open>
|
||||
<summary><a class="reference reference-toplevel" href="#7" id="57">Types</a></summary>
|
||||
<ul class="simple simple-toc-section">
|
||||
<li><a class="reference" href="#Atomic" title="Atomic[T] {.importcpp: "std::atomic", completeStruct.} = object">Atomic</a></li>
|
||||
<li><a class="reference" href="#AtomicFlag" title="AtomicFlag {.importcpp: "std::atomic_flag", size: 1.} = object">AtomicFlag</a></li>
|
||||
<li><a class="reference" href="#MemoryOrder" title="MemoryOrder {.importcpp: "std::memory_order".} = enum
|
||||
moRelaxed, ## No ordering constraints. Only the atomicity and ordering against
|
||||
## other atomic operations is guaranteed.
|
||||
moConsume, ## This ordering is currently discouraged as it's semantics are
|
||||
## being revised. Acquire operations should be preferred.
|
||||
moAcquire, ## When applied to a load operation, no reads or writes in the
|
||||
## current thread can be reordered before this operation.
|
||||
moRelease, ## When applied to a store operation, no reads or writes in the
|
||||
## current thread can be reorderd after this operation.
|
||||
moAcquireRelease, ## When applied to a read-modify-write operation, this behaves like
|
||||
## both an acquire and a release operation.
|
||||
moSequentiallyConsistent ## Behaves like Acquire when applied to load, like Release when
|
||||
## applied to a store and like AcquireRelease when applied to a
|
||||
## read-modify-write operation.
|
||||
## Also guarantees that all threads observe the same total ordering
|
||||
## with other moSequentiallyConsistent operations.">MemoryOrder</a></li>
|
||||
|
||||
</ul>
|
||||
</details>
|
||||
</li>
|
||||
<li>
|
||||
<details open>
|
||||
<summary><a class="reference reference-toplevel" href="#12" id="62">Procs</a></summary>
|
||||
<ul class="simple simple-toc-section">
|
||||
<ul class="simple nested-toc-section">+=
|
||||
<li><a class="reference" href="#%2B%3D%2CAtomic%5BT%3A%20SomeInteger%5D%2CT" title="`+=`[T: SomeInteger](location: var Atomic[T]; value: T)">`+=`[T: SomeInteger](location: var Atomic[T]; value: T)</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">-=
|
||||
<li><a class="reference" href="#-%3D%2CAtomic%5BT%3A%20SomeInteger%5D%2CT" title="`-=`[T: SomeInteger](location: var Atomic[T]; value: T)">`-=`[T: SomeInteger](location: var Atomic[T]; value: T)</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">atomicDec
|
||||
<li><a class="reference" href="#atomicDec%2CAtomic%5BT%3A%20SomeInteger%5D%2CT" title="atomicDec[T: SomeInteger](location: var Atomic[T]; value: T = 1)">atomicDec[T: SomeInteger](location: var Atomic[T]; value: T = 1)</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">atomicInc
|
||||
<li><a class="reference" href="#atomicInc%2CAtomic%5BT%3A%20SomeInteger%5D%2CT" title="atomicInc[T: SomeInteger](location: var Atomic[T]; value: T = 1)">atomicInc[T: SomeInteger](location: var Atomic[T]; value: T = 1)</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">clear
|
||||
<li><a class="reference" href="#clear%2CAtomicFlag%2CMemoryOrder" title="clear(location: var AtomicFlag; order: MemoryOrder = moSequentiallyConsistent)">clear(location: var AtomicFlag; order: MemoryOrder = moSequentiallyConsistent)</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">compareExchange
|
||||
<li><a class="reference" href="#compareExchange%2CAtomic%5BT%5D%2CT%2CT%2CMemoryOrder" title="compareExchange[T](location: var Atomic[T]; expected: var T; desired: T;
|
||||
order: MemoryOrder = moSequentiallyConsistent): bool">compareExchange[T](location: var Atomic[T]; expected: var T; desired: T;
|
||||
order: MemoryOrder = moSequentiallyConsistent): bool</a></li>
|
||||
<li><a class="reference" href="#compareExchange%2CAtomic%5BT%5D%2CT%2CT%2CMemoryOrder%2CMemoryOrder" title="compareExchange[T](location: var Atomic[T]; expected: var T; desired: T;
|
||||
success, failure: MemoryOrder): bool">compareExchange[T](location: var Atomic[T]; expected: var T; desired: T;
|
||||
success, failure: MemoryOrder): bool</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">compareExchangeWeak
|
||||
<li><a class="reference" href="#compareExchangeWeak%2CAtomic%5BT%5D%2CT%2CT%2CMemoryOrder" title="compareExchangeWeak[T](location: var Atomic[T]; expected: var T; desired: T;
|
||||
order: MemoryOrder = moSequentiallyConsistent): bool">compareExchangeWeak[T](location: var Atomic[T]; expected: var T; desired: T;
|
||||
order: MemoryOrder = moSequentiallyConsistent): bool</a></li>
|
||||
<li><a class="reference" href="#compareExchangeWeak%2CAtomic%5BT%5D%2CT%2CT%2CMemoryOrder%2CMemoryOrder" title="compareExchangeWeak[T](location: var Atomic[T]; expected: var T; desired: T;
|
||||
success, failure: MemoryOrder): bool">compareExchangeWeak[T](location: var Atomic[T]; expected: var T; desired: T;
|
||||
success, failure: MemoryOrder): bool</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">exchange
|
||||
<li><a class="reference" href="#exchange%2CAtomic%5BT%5D%2CT%2CMemoryOrder" title="exchange[T](location: var Atomic[T]; desired: T;
|
||||
order: MemoryOrder = moSequentiallyConsistent): T">exchange[T](location: var Atomic[T]; desired: T;
|
||||
order: MemoryOrder = moSequentiallyConsistent): T</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">fence
|
||||
<li><a class="reference" href="#fence%2CMemoryOrder" title="fence(order: MemoryOrder)">fence(order: MemoryOrder)</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">fetchAdd
|
||||
<li><a class="reference" href="#fetchAdd%2CAtomic%5BT%3A%20SomeInteger%5D%2CT%2CMemoryOrder" title="fetchAdd[T: SomeInteger](location: var Atomic[T]; value: T;
|
||||
order: MemoryOrder = moSequentiallyConsistent): T">fetchAdd[T: SomeInteger](location: var Atomic[T]; value: T;
|
||||
order: MemoryOrder = moSequentiallyConsistent): T</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">fetchAnd
|
||||
<li><a class="reference" href="#fetchAnd%2CAtomic%5BT%3A%20SomeInteger%5D%2CT%2CMemoryOrder" title="fetchAnd[T: SomeInteger](location: var Atomic[T]; value: T;
|
||||
order: MemoryOrder = moSequentiallyConsistent): T">fetchAnd[T: SomeInteger](location: var Atomic[T]; value: T;
|
||||
order: MemoryOrder = moSequentiallyConsistent): T</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">fetchOr
|
||||
<li><a class="reference" href="#fetchOr%2CAtomic%5BT%3A%20SomeInteger%5D%2CT%2CMemoryOrder" title="fetchOr[T: SomeInteger](location: var Atomic[T]; value: T;
|
||||
order: MemoryOrder = moSequentiallyConsistent): T">fetchOr[T: SomeInteger](location: var Atomic[T]; value: T;
|
||||
order: MemoryOrder = moSequentiallyConsistent): T</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">fetchSub
|
||||
<li><a class="reference" href="#fetchSub%2CAtomic%5BT%3A%20SomeInteger%5D%2CT%2CMemoryOrder" title="fetchSub[T: SomeInteger](location: var Atomic[T]; value: T;
|
||||
order: MemoryOrder = moSequentiallyConsistent): T">fetchSub[T: SomeInteger](location: var Atomic[T]; value: T;
|
||||
order: MemoryOrder = moSequentiallyConsistent): T</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">fetchXor
|
||||
<li><a class="reference" href="#fetchXor%2CAtomic%5BT%3A%20SomeInteger%5D%2CT%2CMemoryOrder" title="fetchXor[T: SomeInteger](location: var Atomic[T]; value: T;
|
||||
order: MemoryOrder = moSequentiallyConsistent): T">fetchXor[T: SomeInteger](location: var Atomic[T]; value: T;
|
||||
order: MemoryOrder = moSequentiallyConsistent): T</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">load
|
||||
<li><a class="reference" href="#load%2CAtomic%5BT%5D%2CMemoryOrder" title="load[T](location: var Atomic[T]; order: MemoryOrder = moSequentiallyConsistent): T">load[T](location: var Atomic[T]; order: MemoryOrder = moSequentiallyConsistent): T</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">signalFence
|
||||
<li><a class="reference" href="#signalFence%2CMemoryOrder" title="signalFence(order: MemoryOrder)">signalFence(order: MemoryOrder)</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">store
|
||||
<li><a class="reference" href="#store%2CAtomic%5BT%5D%2CT%2CMemoryOrder" title="store[T](location: var Atomic[T]; desired: T;
|
||||
order: MemoryOrder = moSequentiallyConsistent)">store[T](location: var Atomic[T]; desired: T;
|
||||
order: MemoryOrder = moSequentiallyConsistent)</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">testAndSet
|
||||
<li><a class="reference" href="#testAndSet%2CAtomicFlag%2CMemoryOrder" title="testAndSet(location: var AtomicFlag;
|
||||
order: MemoryOrder = moSequentiallyConsistent): bool">testAndSet(location: var AtomicFlag;
|
||||
order: MemoryOrder = moSequentiallyConsistent): bool</a></li>
|
||||
|
||||
</ul>
|
||||
|
||||
</ul>
|
||||
</details>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
<div class="nine columns" id="content">
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/concurrency/atomics.nim#L1" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/concurrency/atomics.nim#L1" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
<div id="tocRoot"></div>
|
||||
|
||||
<p class="module-desc"><p>Types and operations for atomic operations and lockless algorithms.</p>
|
||||
<p>Unstable API.</p>
|
||||
|
||||
<p><strong class="examples_text">Example:</strong></p>
|
||||
<pre class="listing"><span class="Keyword">import</span> <span class="Identifier">std</span><span class="Operator">/</span><span class="Identifier">atomics</span>
|
||||
<span class="Comment"># Atomic</span>
|
||||
<span class="Keyword">var</span> <span class="Identifier">loc</span><span class="Punctuation">:</span> <span class="Identifier">Atomic</span><span class="Punctuation">[</span><span class="Identifier">int</span><span class="Punctuation">]</span>
|
||||
<span class="Identifier">loc</span><span class="Operator">.</span><span class="Identifier">store</span><span class="Punctuation">(</span><span class="DecNumber">4</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">loc</span><span class="Operator">.</span><span class="Identifier">load</span> <span class="Operator">==</span> <span class="DecNumber">4</span>
|
||||
<span class="Identifier">loc</span><span class="Operator">.</span><span class="Identifier">store</span><span class="Punctuation">(</span><span class="DecNumber">2</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">loc</span><span class="Operator">.</span><span class="Identifier">load</span><span class="Punctuation">(</span><span class="Identifier">moRelaxed</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">2</span>
|
||||
<span class="Identifier">loc</span><span class="Operator">.</span><span class="Identifier">store</span><span class="Punctuation">(</span><span class="DecNumber">9</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">loc</span><span class="Operator">.</span><span class="Identifier">load</span><span class="Punctuation">(</span><span class="Identifier">moAcquire</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">9</span>
|
||||
<span class="Identifier">loc</span><span class="Operator">.</span><span class="Identifier">store</span><span class="Punctuation">(</span><span class="DecNumber">0</span><span class="Punctuation">,</span> <span class="Identifier">moRelease</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">loc</span><span class="Operator">.</span><span class="Identifier">load</span> <span class="Operator">==</span> <span class="DecNumber">0</span>
|
||||
|
||||
<span class="Identifier">assert</span> <span class="Identifier">loc</span><span class="Operator">.</span><span class="Identifier">exchange</span><span class="Punctuation">(</span><span class="DecNumber">7</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">0</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">loc</span><span class="Operator">.</span><span class="Identifier">load</span> <span class="Operator">==</span> <span class="DecNumber">7</span>
|
||||
|
||||
<span class="Keyword">var</span> <span class="Identifier">expected</span> <span class="Operator">=</span> <span class="DecNumber">7</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">loc</span><span class="Operator">.</span><span class="Identifier">compareExchange</span><span class="Punctuation">(</span><span class="Identifier">expected</span><span class="Punctuation">,</span> <span class="DecNumber">5</span><span class="Punctuation">,</span> <span class="Identifier">moRelaxed</span><span class="Punctuation">,</span> <span class="Identifier">moRelaxed</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">expected</span> <span class="Operator">==</span> <span class="DecNumber">7</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">loc</span><span class="Operator">.</span><span class="Identifier">load</span> <span class="Operator">==</span> <span class="DecNumber">5</span>
|
||||
|
||||
<span class="Identifier">assert</span> <span class="Keyword">not</span> <span class="Identifier">loc</span><span class="Operator">.</span><span class="Identifier">compareExchange</span><span class="Punctuation">(</span><span class="Identifier">expected</span><span class="Punctuation">,</span> <span class="DecNumber">12</span><span class="Punctuation">,</span> <span class="Identifier">moRelaxed</span><span class="Punctuation">,</span> <span class="Identifier">moRelaxed</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">expected</span> <span class="Operator">==</span> <span class="DecNumber">5</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">loc</span><span class="Operator">.</span><span class="Identifier">load</span> <span class="Operator">==</span> <span class="DecNumber">5</span>
|
||||
|
||||
<span class="Identifier">assert</span> <span class="Identifier">loc</span><span class="Operator">.</span><span class="Identifier">fetchAdd</span><span class="Punctuation">(</span><span class="DecNumber">1</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">5</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">loc</span><span class="Operator">.</span><span class="Identifier">fetchAdd</span><span class="Punctuation">(</span><span class="DecNumber">2</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">6</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">loc</span><span class="Operator">.</span><span class="Identifier">fetchSub</span><span class="Punctuation">(</span><span class="DecNumber">3</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">8</span>
|
||||
|
||||
<span class="Identifier">loc</span><span class="Operator">.</span><span class="Identifier">atomicInc</span><span class="Punctuation">(</span><span class="DecNumber">1</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">loc</span><span class="Operator">.</span><span class="Identifier">load</span> <span class="Operator">==</span> <span class="DecNumber">6</span>
|
||||
|
||||
<span class="Comment"># AtomicFlag</span>
|
||||
<span class="Keyword">var</span> <span class="Identifier">flag</span><span class="Punctuation">:</span> <span class="Identifier">AtomicFlag</span>
|
||||
|
||||
<span class="Identifier">assert</span> <span class="Keyword">not</span> <span class="Identifier">flag</span><span class="Operator">.</span><span class="Identifier">testAndSet</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">flag</span><span class="Operator">.</span><span class="Identifier">testAndSet</span>
|
||||
<span class="Identifier">flag</span><span class="Operator">.</span><span class="Identifier">clear</span><span class="Punctuation">(</span><span class="Identifier">moRelaxed</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">assert</span> <span class="Keyword">not</span> <span class="Identifier">flag</span><span class="Operator">.</span><span class="Identifier">testAndSet</span></pre></p>
|
||||
<div class="section" id="7">
|
||||
<h1><a class="toc-backref" href="#7">Types</a></h1>
|
||||
<dl class="item">
|
||||
<div id="Atomic">
|
||||
<dt><pre><a href="atomics.html#Atomic"><span class="Identifier">Atomic</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span> {.<span class="Identifier">importcpp</span><span class="Other">:</span> <span class="StringLit">"std::atomic"</span><span class="Other">,</span> <span class="Identifier">completeStruct</span>.} <span class="Other">=</span> <span class="Keyword">object</span>
|
||||
</pre></dt>
|
||||
<dd>
|
||||
|
||||
An atomic object with underlying type <tt class="docutils literal"><span class="pre"><span class="Identifier">T</span></span></tt>.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/concurrency/atomics.nim#L92" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/concurrency/atomics.nim#L92" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
<div id="AtomicFlag">
|
||||
<dt><pre><a href="atomics.html#AtomicFlag"><span class="Identifier">AtomicFlag</span></a> {.<span class="Identifier">importcpp</span><span class="Other">:</span> <span class="StringLit">"std::atomic_flag"</span><span class="Other">,</span> <span class="Identifier">size</span><span class="Other">:</span> <span class="DecNumber">1</span>.} <span class="Other">=</span> <span class="Keyword">object</span>
|
||||
</pre></dt>
|
||||
<dd>
|
||||
|
||||
An atomic boolean state.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/concurrency/atomics.nim#L96" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/concurrency/atomics.nim#L96" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
<div id="MemoryOrder">
|
||||
<dt><pre><a href="atomics.html#MemoryOrder"><span class="Identifier">MemoryOrder</span></a> {.<span class="Identifier">importcpp</span><span class="Other">:</span> <span class="StringLit">"std::memory_order"</span>.} <span class="Other">=</span> <span class="Keyword">enum</span>
|
||||
<span class="Identifier">moRelaxed</span><span class="Other">,</span> <span class="Comment">## No ordering constraints. Only the atomicity and ordering against</span>
|
||||
<span class="Comment">## other atomic operations is guaranteed.</span>
|
||||
<span class="Identifier">moConsume</span><span class="Other">,</span> <span class="Comment">## This ordering is currently discouraged as it's semantics are</span>
|
||||
<span class="Comment">## being revised. Acquire operations should be preferred.</span>
|
||||
<span class="Identifier">moAcquire</span><span class="Other">,</span> <span class="Comment">## When applied to a load operation, no reads or writes in the</span>
|
||||
<span class="Comment">## current thread can be reordered before this operation.</span>
|
||||
<span class="Identifier">moRelease</span><span class="Other">,</span> <span class="Comment">## When applied to a store operation, no reads or writes in the</span>
|
||||
<span class="Comment">## current thread can be reorderd after this operation.</span>
|
||||
<span class="Identifier">moAcquireRelease</span><span class="Other">,</span> <span class="Comment">## When applied to a read-modify-write operation, this behaves like</span>
|
||||
<span class="Comment">## both an acquire and a release operation.</span>
|
||||
<span class="Identifier">moSequentiallyConsistent</span> <span class="Comment">## Behaves like Acquire when applied to load, like Release when</span>
|
||||
<span class="Comment">## applied to a store and like AcquireRelease when applied to a</span>
|
||||
<span class="Comment">## read-modify-write operation.</span>
|
||||
<span class="Comment">## Also guarantees that all threads observe the same total ordering</span>
|
||||
<span class="Comment">## with other moSequentiallyConsistent operations.</span></pre></dt>
|
||||
<dd>
|
||||
|
||||
Specifies how non-atomic operations can be reordered around atomic operations.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/concurrency/atomics.nim#L60" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/concurrency/atomics.nim#L60" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</dl>
|
||||
</div>
|
||||
<div class="section" id="12">
|
||||
<h1><a class="toc-backref" href="#12">Procs</a></h1>
|
||||
<dl class="item">
|
||||
<div id="+=-procs-all">
|
||||
<div id="+=,Atomic[T: SomeInteger],T">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#%2B%3D%2CAtomic%5BT%3A%20SomeInteger%5D%2CT"><span class="Identifier">`+=`</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">:</span> <a href="system.html#SomeInteger"><span class="Identifier">SomeInteger</span></a><span class="Other">]</span><span class="Other">(</span><span class="Identifier">location</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="atomics.html#Atomic"><span class="Identifier">Atomic</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">value</span><span class="Other">:</span> <span class="Identifier">T</span><span class="Other">)</span> {.<span class="Identifier">inline</span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Atomically increments the atomic integer by some <tt class="docutils literal"><span class="pre"><span class="Identifier">value</span></span></tt>.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/concurrency/atomics.nim#L409" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/concurrency/atomics.nim#L409" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="-=-procs-all">
|
||||
<div id="-=,Atomic[T: SomeInteger],T">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#-%3D%2CAtomic%5BT%3A%20SomeInteger%5D%2CT"><span class="Identifier">`-=`</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">:</span> <a href="system.html#SomeInteger"><span class="Identifier">SomeInteger</span></a><span class="Other">]</span><span class="Other">(</span><span class="Identifier">location</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="atomics.html#Atomic"><span class="Identifier">Atomic</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">value</span><span class="Other">:</span> <span class="Identifier">T</span><span class="Other">)</span> {.<span class="Identifier">inline</span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Atomically decrements the atomic integer by some <tt class="docutils literal"><span class="pre"><span class="Identifier">value</span></span></tt>.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/concurrency/atomics.nim#L413" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/concurrency/atomics.nim#L413" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="atomicDec-procs-all">
|
||||
<div id="atomicDec,Atomic[T: SomeInteger],T">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#atomicDec%2CAtomic%5BT%3A%20SomeInteger%5D%2CT"><span class="Identifier">atomicDec</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">:</span> <a href="system.html#SomeInteger"><span class="Identifier">SomeInteger</span></a><span class="Other">]</span><span class="Other">(</span><span class="Identifier">location</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="atomics.html#Atomic"><span class="Identifier">Atomic</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">value</span><span class="Other">:</span> <span class="Identifier">T</span> <span class="Other">=</span> <span class="DecNumber">1</span><span class="Other">)</span> {.<span class="Identifier">inline</span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Atomically decrements the atomic integer by some <tt class="docutils literal"><span class="pre"><span class="Identifier">value</span></span></tt>.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/concurrency/atomics.nim#L405" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/concurrency/atomics.nim#L405" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="atomicInc-procs-all">
|
||||
<div id="atomicInc,Atomic[T: SomeInteger],T">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#atomicInc%2CAtomic%5BT%3A%20SomeInteger%5D%2CT"><span class="Identifier">atomicInc</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">:</span> <a href="system.html#SomeInteger"><span class="Identifier">SomeInteger</span></a><span class="Other">]</span><span class="Other">(</span><span class="Identifier">location</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="atomics.html#Atomic"><span class="Identifier">Atomic</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">value</span><span class="Other">:</span> <span class="Identifier">T</span> <span class="Other">=</span> <span class="DecNumber">1</span><span class="Other">)</span> {.<span class="Identifier">inline</span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Atomically increments the atomic integer by some <tt class="docutils literal"><span class="pre"><span class="Identifier">value</span></span></tt>.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/concurrency/atomics.nim#L401" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/concurrency/atomics.nim#L401" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="clear-procs-all">
|
||||
<div id="clear,AtomicFlag,MemoryOrder">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#clear%2CAtomicFlag%2CMemoryOrder"><span class="Identifier">clear</span></a><span class="Other">(</span><span class="Identifier">location</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="atomics.html#AtomicFlag"><span class="Identifier">AtomicFlag</span></a><span class="Other">;</span>
|
||||
<span class="Identifier">order</span><span class="Other">:</span> <a href="atomics.html#MemoryOrder"><span class="Identifier">MemoryOrder</span></a> <span class="Other">=</span> <span class="Identifier">moSequentiallyConsistent</span><span class="Other">)</span> {.
|
||||
<span class="Identifier">importcpp</span><span class="Other">:</span> <span class="StringLit">"#.clear(@)"</span><span class="Other">,</span> <span class="Identifier">header</span><span class="Other">:</span> <span class="StringLit">"<atomic>"</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
|
||||
<span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Atomically sets the value of the atomic flag to false.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/concurrency/atomics.nim#L155" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/concurrency/atomics.nim#L155" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="compareExchange-procs-all">
|
||||
<div id="compareExchange,Atomic[T],T,T,MemoryOrder">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#compareExchange%2CAtomic%5BT%5D%2CT%2CT%2CMemoryOrder"><span class="Identifier">compareExchange</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">location</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="atomics.html#Atomic"><span class="Identifier">Atomic</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">expected</span><span class="Other">:</span> <span class="Keyword">var</span> <span class="Identifier">T</span><span class="Other">;</span> <span class="Identifier">desired</span><span class="Other">:</span> <span class="Identifier">T</span><span class="Other">;</span>
|
||||
<span class="Identifier">order</span><span class="Other">:</span> <a href="atomics.html#MemoryOrder"><span class="Identifier">MemoryOrder</span></a> <span class="Other">=</span> <span class="Identifier">moSequentiallyConsistent</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#bool"><span class="Identifier">bool</span></a> {.
|
||||
<span class="Identifier">importcpp</span><span class="Other">:</span> <span class="StringLit">"#.compare_exchange_strong(@)"</span><span class="Other">,</span> <span class="Identifier">header</span><span class="Other">:</span> <span class="StringLit">"<atomic>"</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
|
||||
<span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Atomically compares the value of the atomic object with the <tt class="docutils literal"><span class="pre"><span class="Identifier">expected</span></span></tt> value and performs exchange with the <tt class="docutils literal"><span class="pre"><span class="Identifier">desired</span></span></tt> one if equal or load if not. Returns true if the exchange was successful.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/concurrency/atomics.nim#L112" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/concurrency/atomics.nim#L112" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
<div id="compareExchange,Atomic[T],T,T,MemoryOrder,MemoryOrder">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#compareExchange%2CAtomic%5BT%5D%2CT%2CT%2CMemoryOrder%2CMemoryOrder"><span class="Identifier">compareExchange</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">location</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="atomics.html#Atomic"><span class="Identifier">Atomic</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">expected</span><span class="Other">:</span> <span class="Keyword">var</span> <span class="Identifier">T</span><span class="Other">;</span> <span class="Identifier">desired</span><span class="Other">:</span> <span class="Identifier">T</span><span class="Other">;</span>
|
||||
<span class="Identifier">success</span><span class="Other">,</span> <span class="Identifier">failure</span><span class="Other">:</span> <a href="atomics.html#MemoryOrder"><span class="Identifier">MemoryOrder</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#bool"><span class="Identifier">bool</span></a> {.
|
||||
<span class="Identifier">importcpp</span><span class="Other">:</span> <span class="StringLit">"#.compare_exchange_strong(@)"</span><span class="Other">,</span> <span class="Identifier">header</span><span class="Other">:</span> <span class="StringLit">"<atomic>"</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
|
||||
<span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Same as above, but allows for different memory orders for success and failure.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/concurrency/atomics.nim#L117" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/concurrency/atomics.nim#L117" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="compareExchangeWeak-procs-all">
|
||||
<div id="compareExchangeWeak,Atomic[T],T,T,MemoryOrder">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#compareExchangeWeak%2CAtomic%5BT%5D%2CT%2CT%2CMemoryOrder"><span class="Identifier">compareExchangeWeak</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">location</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="atomics.html#Atomic"><span class="Identifier">Atomic</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">expected</span><span class="Other">:</span> <span class="Keyword">var</span> <span class="Identifier">T</span><span class="Other">;</span>
|
||||
<span class="Identifier">desired</span><span class="Other">:</span> <span class="Identifier">T</span><span class="Other">;</span>
|
||||
<span class="Identifier">order</span><span class="Other">:</span> <a href="atomics.html#MemoryOrder"><span class="Identifier">MemoryOrder</span></a> <span class="Other">=</span> <span class="Identifier">moSequentiallyConsistent</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#bool"><span class="Identifier">bool</span></a> {.
|
||||
<span class="Identifier">importcpp</span><span class="Other">:</span> <span class="StringLit">"#.compare_exchange_weak(@)"</span><span class="Other">,</span> <span class="Identifier">header</span><span class="Other">:</span> <span class="StringLit">"<atomic>"</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
|
||||
<span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Same as above, but is allowed to fail spuriously.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/concurrency/atomics.nim#L121" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/concurrency/atomics.nim#L121" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
<div id="compareExchangeWeak,Atomic[T],T,T,MemoryOrder,MemoryOrder">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#compareExchangeWeak%2CAtomic%5BT%5D%2CT%2CT%2CMemoryOrder%2CMemoryOrder"><span class="Identifier">compareExchangeWeak</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">location</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="atomics.html#Atomic"><span class="Identifier">Atomic</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">expected</span><span class="Other">:</span> <span class="Keyword">var</span> <span class="Identifier">T</span><span class="Other">;</span>
|
||||
<span class="Identifier">desired</span><span class="Other">:</span> <span class="Identifier">T</span><span class="Other">;</span> <span class="Identifier">success</span><span class="Other">,</span> <span class="Identifier">failure</span><span class="Other">:</span> <a href="atomics.html#MemoryOrder"><span class="Identifier">MemoryOrder</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#bool"><span class="Identifier">bool</span></a> {.
|
||||
<span class="Identifier">importcpp</span><span class="Other">:</span> <span class="StringLit">"#.compare_exchange_weak(@)"</span><span class="Other">,</span> <span class="Identifier">header</span><span class="Other">:</span> <span class="StringLit">"<atomic>"</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
|
||||
<span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Same as above, but allows for different memory orders for success and failure.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/concurrency/atomics.nim#L124" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/concurrency/atomics.nim#L124" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="exchange-procs-all">
|
||||
<div id="exchange,Atomic[T],T,MemoryOrder">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#exchange%2CAtomic%5BT%5D%2CT%2CMemoryOrder"><span class="Identifier">exchange</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">location</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="atomics.html#Atomic"><span class="Identifier">Atomic</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">desired</span><span class="Other">:</span> <span class="Identifier">T</span><span class="Other">;</span>
|
||||
<span class="Identifier">order</span><span class="Other">:</span> <a href="atomics.html#MemoryOrder"><span class="Identifier">MemoryOrder</span></a> <span class="Other">=</span> <span class="Identifier">moSequentiallyConsistent</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">T</span> {.
|
||||
<span class="Identifier">importcpp</span><span class="Other">:</span> <span class="StringLit">"#.exchange(@)"</span><span class="Other">,</span> <span class="Identifier">header</span><span class="Other">:</span> <span class="StringLit">"<atomic>"</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
|
||||
<span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Atomically replaces the value of the atomic object with the <tt class="docutils literal"><span class="pre"><span class="Identifier">desired</span></span></tt> value and returns the old value.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/concurrency/atomics.nim#L108" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/concurrency/atomics.nim#L108" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="fence-procs-all">
|
||||
<div id="fence,MemoryOrder">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#fence%2CMemoryOrder"><span class="Identifier">fence</span></a><span class="Other">(</span><span class="Identifier">order</span><span class="Other">:</span> <a href="atomics.html#MemoryOrder"><span class="Identifier">MemoryOrder</span></a><span class="Other">)</span> {.<span class="Identifier">importcpp</span><span class="Other">:</span> <span class="StringLit">"std::atomic_thread_fence(@)"</span><span class="Other">,</span>
|
||||
<span class="Identifier">header</span><span class="Other">:</span> <span class="StringLit">"<atomic>"</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
|
||||
<span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Ensures memory ordering without using atomic operations.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/concurrency/atomics.nim#L158" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/concurrency/atomics.nim#L158" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="fetchAdd-procs-all">
|
||||
<div id="fetchAdd,Atomic[T: SomeInteger],T,MemoryOrder">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#fetchAdd%2CAtomic%5BT%3A%20SomeInteger%5D%2CT%2CMemoryOrder"><span class="Identifier">fetchAdd</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">:</span> <a href="system.html#SomeInteger"><span class="Identifier">SomeInteger</span></a><span class="Other">]</span><span class="Other">(</span><span class="Identifier">location</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="atomics.html#Atomic"><span class="Identifier">Atomic</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">value</span><span class="Other">:</span> <span class="Identifier">T</span><span class="Other">;</span>
|
||||
<span class="Identifier">order</span><span class="Other">:</span> <a href="atomics.html#MemoryOrder"><span class="Identifier">MemoryOrder</span></a> <span class="Other">=</span> <span class="Identifier">moSequentiallyConsistent</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">T</span> {.
|
||||
<span class="Identifier">importcpp</span><span class="Other">:</span> <span class="StringLit">"#.fetch_add(@)"</span><span class="Other">,</span> <span class="Identifier">header</span><span class="Other">:</span> <span class="StringLit">"<atomic>"</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
|
||||
<span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Atomically adds a <tt class="docutils literal"><span class="pre"><span class="Identifier">value</span></span></tt> to the atomic integer and returns the original value.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/concurrency/atomics.nim#L130" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/concurrency/atomics.nim#L130" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="fetchAnd-procs-all">
|
||||
<div id="fetchAnd,Atomic[T: SomeInteger],T,MemoryOrder">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#fetchAnd%2CAtomic%5BT%3A%20SomeInteger%5D%2CT%2CMemoryOrder"><span class="Identifier">fetchAnd</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">:</span> <a href="system.html#SomeInteger"><span class="Identifier">SomeInteger</span></a><span class="Other">]</span><span class="Other">(</span><span class="Identifier">location</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="atomics.html#Atomic"><span class="Identifier">Atomic</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">value</span><span class="Other">:</span> <span class="Identifier">T</span><span class="Other">;</span>
|
||||
<span class="Identifier">order</span><span class="Other">:</span> <a href="atomics.html#MemoryOrder"><span class="Identifier">MemoryOrder</span></a> <span class="Other">=</span> <span class="Identifier">moSequentiallyConsistent</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">T</span> {.
|
||||
<span class="Identifier">importcpp</span><span class="Other">:</span> <span class="StringLit">"#.fetch_and(@)"</span><span class="Other">,</span> <span class="Identifier">header</span><span class="Other">:</span> <span class="StringLit">"<atomic>"</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
|
||||
<span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Atomically replaces the atomic integer with it's bitwise AND with the specified <tt class="docutils literal"><span class="pre"><span class="Identifier">value</span></span></tt> and returns the original value.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/concurrency/atomics.nim#L138" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/concurrency/atomics.nim#L138" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="fetchOr-procs-all">
|
||||
<div id="fetchOr,Atomic[T: SomeInteger],T,MemoryOrder">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#fetchOr%2CAtomic%5BT%3A%20SomeInteger%5D%2CT%2CMemoryOrder"><span class="Identifier">fetchOr</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">:</span> <a href="system.html#SomeInteger"><span class="Identifier">SomeInteger</span></a><span class="Other">]</span><span class="Other">(</span><span class="Identifier">location</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="atomics.html#Atomic"><span class="Identifier">Atomic</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">value</span><span class="Other">:</span> <span class="Identifier">T</span><span class="Other">;</span>
|
||||
<span class="Identifier">order</span><span class="Other">:</span> <a href="atomics.html#MemoryOrder"><span class="Identifier">MemoryOrder</span></a> <span class="Other">=</span> <span class="Identifier">moSequentiallyConsistent</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">T</span> {.
|
||||
<span class="Identifier">importcpp</span><span class="Other">:</span> <span class="StringLit">"#.fetch_or(@)"</span><span class="Other">,</span> <span class="Identifier">header</span><span class="Other">:</span> <span class="StringLit">"<atomic>"</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
|
||||
<span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Atomically replaces the atomic integer with it's bitwise OR with the specified <tt class="docutils literal"><span class="pre"><span class="Identifier">value</span></span></tt> and returns the original value.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/concurrency/atomics.nim#L142" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/concurrency/atomics.nim#L142" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="fetchSub-procs-all">
|
||||
<div id="fetchSub,Atomic[T: SomeInteger],T,MemoryOrder">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#fetchSub%2CAtomic%5BT%3A%20SomeInteger%5D%2CT%2CMemoryOrder"><span class="Identifier">fetchSub</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">:</span> <a href="system.html#SomeInteger"><span class="Identifier">SomeInteger</span></a><span class="Other">]</span><span class="Other">(</span><span class="Identifier">location</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="atomics.html#Atomic"><span class="Identifier">Atomic</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">value</span><span class="Other">:</span> <span class="Identifier">T</span><span class="Other">;</span>
|
||||
<span class="Identifier">order</span><span class="Other">:</span> <a href="atomics.html#MemoryOrder"><span class="Identifier">MemoryOrder</span></a> <span class="Other">=</span> <span class="Identifier">moSequentiallyConsistent</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">T</span> {.
|
||||
<span class="Identifier">importcpp</span><span class="Other">:</span> <span class="StringLit">"#.fetch_sub(@)"</span><span class="Other">,</span> <span class="Identifier">header</span><span class="Other">:</span> <span class="StringLit">"<atomic>"</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
|
||||
<span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Atomically subtracts a <tt class="docutils literal"><span class="pre"><span class="Identifier">value</span></span></tt> to the atomic integer and returns the original value.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/concurrency/atomics.nim#L134" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/concurrency/atomics.nim#L134" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="fetchXor-procs-all">
|
||||
<div id="fetchXor,Atomic[T: SomeInteger],T,MemoryOrder">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#fetchXor%2CAtomic%5BT%3A%20SomeInteger%5D%2CT%2CMemoryOrder"><span class="Identifier">fetchXor</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">:</span> <a href="system.html#SomeInteger"><span class="Identifier">SomeInteger</span></a><span class="Other">]</span><span class="Other">(</span><span class="Identifier">location</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="atomics.html#Atomic"><span class="Identifier">Atomic</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">value</span><span class="Other">:</span> <span class="Identifier">T</span><span class="Other">;</span>
|
||||
<span class="Identifier">order</span><span class="Other">:</span> <a href="atomics.html#MemoryOrder"><span class="Identifier">MemoryOrder</span></a> <span class="Other">=</span> <span class="Identifier">moSequentiallyConsistent</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">T</span> {.
|
||||
<span class="Identifier">importcpp</span><span class="Other">:</span> <span class="StringLit">"#.fetch_xor(@)"</span><span class="Other">,</span> <span class="Identifier">header</span><span class="Other">:</span> <span class="StringLit">"<atomic>"</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
|
||||
<span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Atomically replaces the atomic integer with it's bitwise XOR with the specified <tt class="docutils literal"><span class="pre"><span class="Identifier">value</span></span></tt> and returns the original value.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/concurrency/atomics.nim#L146" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/concurrency/atomics.nim#L146" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="load-procs-all">
|
||||
<div id="load,Atomic[T],MemoryOrder">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#load%2CAtomic%5BT%5D%2CMemoryOrder"><span class="Identifier">load</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">location</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="atomics.html#Atomic"><span class="Identifier">Atomic</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span>
|
||||
<span class="Identifier">order</span><span class="Other">:</span> <a href="atomics.html#MemoryOrder"><span class="Identifier">MemoryOrder</span></a> <span class="Other">=</span> <span class="Identifier">moSequentiallyConsistent</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">T</span> {.
|
||||
<span class="Identifier">importcpp</span><span class="Other">:</span> <span class="StringLit">"#.load(@)"</span><span class="Other">,</span> <span class="Identifier">header</span><span class="Other">:</span> <span class="StringLit">"<atomic>"</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
|
||||
<span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Atomically obtains the value of the atomic object.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/concurrency/atomics.nim#L101" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/concurrency/atomics.nim#L101" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="signalFence-procs-all">
|
||||
<div id="signalFence,MemoryOrder">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#signalFence%2CMemoryOrder"><span class="Identifier">signalFence</span></a><span class="Other">(</span><span class="Identifier">order</span><span class="Other">:</span> <a href="atomics.html#MemoryOrder"><span class="Identifier">MemoryOrder</span></a><span class="Other">)</span> {.<span class="Identifier">importcpp</span><span class="Other">:</span> <span class="StringLit">"std::atomic_signal_fence(@)"</span><span class="Other">,</span>
|
||||
<span class="Identifier">header</span><span class="Other">:</span> <span class="StringLit">"<atomic>"</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
|
||||
<span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Prevents reordering of accesses by the compiler as would fence, but inserts no CPU instructions for memory ordering.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/concurrency/atomics.nim#L161" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/concurrency/atomics.nim#L161" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="store-procs-all">
|
||||
<div id="store,Atomic[T],T,MemoryOrder">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#store%2CAtomic%5BT%5D%2CT%2CMemoryOrder"><span class="Identifier">store</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">(</span><span class="Identifier">location</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="atomics.html#Atomic"><span class="Identifier">Atomic</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">desired</span><span class="Other">:</span> <span class="Identifier">T</span><span class="Other">;</span>
|
||||
<span class="Identifier">order</span><span class="Other">:</span> <a href="atomics.html#MemoryOrder"><span class="Identifier">MemoryOrder</span></a> <span class="Other">=</span> <span class="Identifier">moSequentiallyConsistent</span><span class="Other">)</span> {.
|
||||
<span class="Identifier">importcpp</span><span class="Other">:</span> <span class="StringLit">"#.store(@)"</span><span class="Other">,</span> <span class="Identifier">header</span><span class="Other">:</span> <span class="StringLit">"<atomic>"</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
|
||||
<span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Atomically replaces the value of the atomic object with the <tt class="docutils literal"><span class="pre"><span class="Identifier">desired</span></span></tt> value.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/concurrency/atomics.nim#L104" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/concurrency/atomics.nim#L104" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="testAndSet-procs-all">
|
||||
<div id="testAndSet,AtomicFlag,MemoryOrder">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#testAndSet%2CAtomicFlag%2CMemoryOrder"><span class="Identifier">testAndSet</span></a><span class="Other">(</span><span class="Identifier">location</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="atomics.html#AtomicFlag"><span class="Identifier">AtomicFlag</span></a><span class="Other">;</span>
|
||||
<span class="Identifier">order</span><span class="Other">:</span> <a href="atomics.html#MemoryOrder"><span class="Identifier">MemoryOrder</span></a> <span class="Other">=</span> <span class="Identifier">moSequentiallyConsistent</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#bool"><span class="Identifier">bool</span></a> {.
|
||||
<span class="Identifier">importcpp</span><span class="Other">:</span> <span class="StringLit">"#.test_and_set(@)"</span><span class="Other">,</span> <span class="Identifier">header</span><span class="Other">:</span> <span class="StringLit">"<atomic>"</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
|
||||
<span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Atomically sets the atomic flag to true and returns the original value.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/concurrency/atomics.nim#L152" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/concurrency/atomics.nim#L152" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="twelve-columns footer">
|
||||
<span class="nim-sprite"></span>
|
||||
<br>
|
||||
<small style="color: var(--hint);">Made with Nim. Generated: 2023-03-13 00:19:45 UTC</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script defer data-domain="nim-lang.org" src="https://plausible.io/js/plausible.js"></script>
|
||||
|
||||
<!-- Google fonts -->
|
||||
<link href='https://fonts.googleapis.com/css?family=Lato:400,600,900' rel='stylesheet' type='text/css'/>
|
||||
<link href='https://fonts.googleapis.com/css?family=Source+Code+Pro:400,500,600' rel='stylesheet' type='text/css'/>
|
||||
</body>
|
||||
</html>
|
||||
26
atomics.idx
Normal file
26
atomics.idx
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
nimTitle atomics atomics.html module std/atomics 0
|
||||
nim MemoryOrder atomics.html#MemoryOrder enum MemoryOrder 60
|
||||
nim Atomic atomics.html#Atomic object Atomic 92
|
||||
nim AtomicFlag atomics.html#AtomicFlag object AtomicFlag 96
|
||||
nim load atomics.html#load,Atomic[T],MemoryOrder proc load[T](location: var Atomic[T]; order: MemoryOrder = moSequentiallyConsistent): T 101
|
||||
nim store atomics.html#store,Atomic[T],T,MemoryOrder proc store[T](location: var Atomic[T]; desired: T;\n order: MemoryOrder = moSequentiallyConsistent) 104
|
||||
nim exchange atomics.html#exchange,Atomic[T],T,MemoryOrder proc exchange[T](location: var Atomic[T]; desired: T;\n order: MemoryOrder = moSequentiallyConsistent): T 108
|
||||
nim compareExchange atomics.html#compareExchange,Atomic[T],T,T,MemoryOrder proc compareExchange[T](location: var Atomic[T]; expected: var T; desired: T;\n order: MemoryOrder = moSequentiallyConsistent): bool 112
|
||||
nim compareExchange atomics.html#compareExchange,Atomic[T],T,T,MemoryOrder,MemoryOrder proc compareExchange[T](location: var Atomic[T]; expected: var T; desired: T;\n success, failure: MemoryOrder): bool 117
|
||||
nim compareExchangeWeak atomics.html#compareExchangeWeak,Atomic[T],T,T,MemoryOrder proc compareExchangeWeak[T](location: var Atomic[T]; expected: var T; desired: T;\n order: MemoryOrder = moSequentiallyConsistent): bool 121
|
||||
nim compareExchangeWeak atomics.html#compareExchangeWeak,Atomic[T],T,T,MemoryOrder,MemoryOrder proc compareExchangeWeak[T](location: var Atomic[T]; expected: var T; desired: T;\n success, failure: MemoryOrder): bool 124
|
||||
nim fetchAdd atomics.html#fetchAdd,Atomic[T: SomeInteger],T,MemoryOrder proc fetchAdd[T: SomeInteger](location: var Atomic[T]; value: T;\n order: MemoryOrder = moSequentiallyConsistent): T 130
|
||||
nim fetchSub atomics.html#fetchSub,Atomic[T: SomeInteger],T,MemoryOrder proc fetchSub[T: SomeInteger](location: var Atomic[T]; value: T;\n order: MemoryOrder = moSequentiallyConsistent): T 134
|
||||
nim fetchAnd atomics.html#fetchAnd,Atomic[T: SomeInteger],T,MemoryOrder proc fetchAnd[T: SomeInteger](location: var Atomic[T]; value: T;\n order: MemoryOrder = moSequentiallyConsistent): T 138
|
||||
nim fetchOr atomics.html#fetchOr,Atomic[T: SomeInteger],T,MemoryOrder proc fetchOr[T: SomeInteger](location: var Atomic[T]; value: T;\n order: MemoryOrder = moSequentiallyConsistent): T 142
|
||||
nim fetchXor atomics.html#fetchXor,Atomic[T: SomeInteger],T,MemoryOrder proc fetchXor[T: SomeInteger](location: var Atomic[T]; value: T;\n order: MemoryOrder = moSequentiallyConsistent): T 146
|
||||
nim testAndSet atomics.html#testAndSet,AtomicFlag,MemoryOrder proc testAndSet(location: var AtomicFlag;\n order: MemoryOrder = moSequentiallyConsistent): bool 152
|
||||
nim clear atomics.html#clear,AtomicFlag,MemoryOrder proc clear(location: var AtomicFlag; order: MemoryOrder = moSequentiallyConsistent) 155
|
||||
nim fence atomics.html#fence,MemoryOrder proc fence(order: MemoryOrder) 158
|
||||
nim signalFence atomics.html#signalFence,MemoryOrder proc signalFence(order: MemoryOrder) 161
|
||||
nim atomicInc atomics.html#atomicInc,Atomic[T: SomeInteger],T proc atomicInc[T: SomeInteger](location: var Atomic[T]; value: T = 1) 401
|
||||
nim atomicDec atomics.html#atomicDec,Atomic[T: SomeInteger],T proc atomicDec[T: SomeInteger](location: var Atomic[T]; value: T = 1) 405
|
||||
nim `+=` atomics.html#+=,Atomic[T: SomeInteger],T proc `+=`[T: SomeInteger](location: var Atomic[T]; value: T) 409
|
||||
nim `-=` atomics.html#-=,Atomic[T: SomeInteger],T proc `-=`[T: SomeInteger](location: var Atomic[T]; value: T) 413
|
||||
nimgrp compareexchangeweak atomics.html#compareExchangeWeak-procs-all proc 121
|
||||
nimgrp compareexchange atomics.html#compareExchange-procs-all proc 112
|
||||
|
|
@ -1,168 +0,0 @@
|
|||
trigger:
|
||||
branches:
|
||||
include:
|
||||
- 'devel'
|
||||
- 'version-*'
|
||||
pr:
|
||||
branches:
|
||||
include:
|
||||
- '*'
|
||||
|
||||
variables:
|
||||
- name: skipci
|
||||
value: false
|
||||
|
||||
jobs:
|
||||
- job: packages
|
||||
|
||||
timeoutInMinutes: 90 # default `60` led to lots of cancelled jobs; use 0 for unlimited (may be undesirable)
|
||||
|
||||
strategy:
|
||||
matrix:
|
||||
Linux_amd64:
|
||||
vmImage: 'ubuntu-20.04'
|
||||
CPU: amd64
|
||||
# regularly breaks, refs bug #17325
|
||||
Linux_i386:
|
||||
# on 'ubuntu-16.04' (not supported anymore anyways) it errored with:
|
||||
# g++-multilib : Depends: gcc-multilib (>= 4:5.3.1-1ubuntu1) but it is not going to be installed
|
||||
vmImage: 'ubuntu-18.04'
|
||||
CPU: i386
|
||||
OSX_amd64:
|
||||
vmImage: 'macOS-11'
|
||||
CPU: amd64
|
||||
OSX_amd64_cpp:
|
||||
vmImage: 'macOS-11'
|
||||
CPU: amd64
|
||||
NIM_COMPILE_TO_CPP: true
|
||||
Windows_amd64_batch0_3:
|
||||
vmImage: 'windows-2019'
|
||||
CPU: amd64
|
||||
# see also: `NIM_TEST_PACKAGES`
|
||||
NIM_TESTAMENT_BATCH: "0_3"
|
||||
Windows_amd64_batch1_3:
|
||||
vmImage: 'windows-2019'
|
||||
CPU: amd64
|
||||
NIM_TESTAMENT_BATCH: "1_3"
|
||||
Windows_amd64_batch2_3:
|
||||
vmImage: 'windows-2019'
|
||||
CPU: amd64
|
||||
NIM_TESTAMENT_BATCH: "2_3"
|
||||
|
||||
pool:
|
||||
vmImage: $(vmImage)
|
||||
|
||||
workspace:
|
||||
clean: all
|
||||
|
||||
steps:
|
||||
- bash: git config --global core.autocrlf false
|
||||
displayName: 'Disable auto conversion to CRLF by git (Windows-only)'
|
||||
condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT'))
|
||||
|
||||
- checkout: self
|
||||
fetchDepth: 2 # see D20210329T004830
|
||||
|
||||
- bash: |
|
||||
set -e
|
||||
. ci/funs.sh
|
||||
if nimIsCiSkip; then
|
||||
echo '##vso[task.setvariable variable=skipci]true'
|
||||
fi
|
||||
displayName: 'Check whether to skip CI'
|
||||
|
||||
- task: NodeTool@0
|
||||
inputs:
|
||||
versionSpec: '16.x'
|
||||
displayName: 'Install node.js 16.x'
|
||||
condition: and(succeeded(), eq(variables['skipci'], 'false'))
|
||||
|
||||
- bash: |
|
||||
set -e
|
||||
. ci/funs.sh
|
||||
echo_run sudo apt-fast update -qq
|
||||
DEBIAN_FRONTEND='noninteractive' \
|
||||
echo_run sudo apt-fast install --no-install-recommends -yq \
|
||||
libcurl4-openssl-dev libgc-dev libsdl1.2-dev libsfml-dev valgrind libc6-dbg
|
||||
displayName: 'Install dependencies (amd64 Linux)'
|
||||
condition: and(succeeded(), eq(variables['skipci'], 'false'), eq(variables['Agent.OS'], 'Linux'), eq(variables['CPU'], 'amd64'))
|
||||
|
||||
- bash: |
|
||||
set -e
|
||||
. ci/funs.sh
|
||||
echo_run sudo dpkg --add-architecture i386
|
||||
# Downgrade llvm:
|
||||
# - llvm has to be downgraded to have 32bit version installed for sfml.
|
||||
|
||||
cat << EOF | sudo tee /etc/apt/preferences.d/pin-to-rel
|
||||
Package: libllvm6.0
|
||||
Pin: origin "azure.archive.ubuntu.com"
|
||||
Pin-Priority: 1001
|
||||
EOF
|
||||
|
||||
# echo_run sudo apt-fast update -qq
|
||||
echo_run sudo apt-fast update -qq || echo "failed, see bug #17343"
|
||||
# `:i386` (e.g. in `libffi-dev:i386`) is needed otherwise you may get:
|
||||
# `could not load: libffi.so` during dynamic loading.
|
||||
DEBIAN_FRONTEND='noninteractive' \
|
||||
echo_run sudo apt-fast install --no-install-recommends --allow-downgrades -yq \
|
||||
g++-multilib gcc-multilib libcurl4-openssl-dev:i386 libgc-dev:i386 \
|
||||
libsdl1.2-dev:i386 libsfml-dev:i386 libglib2.0-dev:i386 libffi-dev:i386
|
||||
|
||||
cat << EOF > bin/gcc
|
||||
#!/bin/bash
|
||||
|
||||
exec $(which gcc) -m32 "\$@"
|
||||
EOF
|
||||
|
||||
cat << EOF > bin/g++
|
||||
#!/bin/bash
|
||||
|
||||
exec $(which g++) -m32 "\$@"
|
||||
EOF
|
||||
|
||||
echo_run chmod 755 bin/gcc
|
||||
echo_run chmod 755 bin/g++
|
||||
|
||||
displayName: 'Install dependencies (i386 Linux)'
|
||||
condition: and(succeeded(), eq(variables['skipci'], 'false'), eq(variables['Agent.OS'], 'Linux'), eq(variables['CPU'], 'i386'))
|
||||
|
||||
- bash: brew install boehmgc make sfml
|
||||
displayName: 'Install dependencies (OSX)'
|
||||
condition: and(succeeded(), eq(variables['skipci'], 'false'), eq(variables['Agent.OS'], 'Darwin'))
|
||||
|
||||
- bash: |
|
||||
set -e
|
||||
. ci/funs.sh
|
||||
nimInternalInstallDepsWindows
|
||||
echo_run echo '##vso[task.prependpath]$(System.DefaultWorkingDirectory)/dist/mingw64/bin'
|
||||
|
||||
displayName: 'Install dependencies (Windows)'
|
||||
condition: and(succeeded(), eq(variables['skipci'], 'false'), eq(variables['Agent.OS'], 'Windows_NT'))
|
||||
|
||||
- bash: echo '##vso[task.prependpath]$(System.DefaultWorkingDirectory)/bin'
|
||||
condition: and(succeeded(), eq(variables['skipci'], 'false'))
|
||||
displayName: 'Add build binaries to PATH'
|
||||
|
||||
- bash: . ci/funs.sh && nimCiSystemInfo
|
||||
condition: and(succeeded(), eq(variables['skipci'], 'false'))
|
||||
displayName: 'System information'
|
||||
|
||||
- bash: . ci/funs.sh && nimBuildCsourcesIfNeeded CC=gcc ucpu=$(CPU)
|
||||
condition: and(succeeded(), eq(variables['skipci'], 'false'))
|
||||
displayName: 'Build csourcesAny'
|
||||
|
||||
# this could be revived if performance justifies it (needs a few updates)
|
||||
# - task: Cache@2
|
||||
# inputs:
|
||||
# key: 'csourcesAny | "$(Agent.OS)" | $(CPU) | $(csources_version)'
|
||||
# path: $(nim_csources)
|
||||
# condition: and(succeeded(), eq(variables['skipci'], 'false'))
|
||||
# displayName: 'Restore built csourcesAny'
|
||||
|
||||
- bash: . ci/funs.sh && nimInternalBuildKochAndRunCI
|
||||
# would could also show on failure: echo '##vso[task.complete result=Failed]'
|
||||
condition: and(succeeded(), eq(variables['skipci'], 'false'))
|
||||
displayName: 'koch, Run CI'
|
||||
env:
|
||||
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
|
||||
250
backends.html
Normal file
250
backends.html
Normal file
|
|
@ -0,0 +1,250 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<!-- This file is generated by Nim. -->
|
||||
<html xmlns="https://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Nim Backend Integration</title>
|
||||
|
||||
<!-- Favicon -->
|
||||
<link rel="shortcut icon" href="data:image/x-icon;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAUAAAAF////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAIAAABbAAAAlQAAAKIAAACbAAAAmwAAAKIAAACVAAAAWwAAAAL///8A////AP///wD///8A////AAAAABQAAADAAAAAYwAAAA3///8A////AP///wD///8AAAAADQAAAGMAAADAAAAAFP///wD///8A////AP///wAAAACdAAAAOv///wD///8A////AP///wD///8A////AP///wD///8AAAAAOgAAAJ3///8A////AP///wAAAAAnAAAAcP///wAAAAAoAAAASv///wD///8A////AP///wAAAABKAAAAKP///wAAAABwAAAAJ////wD///8AAAAAgQAAABwAAACIAAAAkAAAAJMAAACtAAAAFQAAABUAAACtAAAAkwAAAJAAAACIAAAAHAAAAIH///8A////AAAAAKQAAACrAAAAaP///wD///8AAAAARQAAANIAAADSAAAARf///wD///8AAAAAaAAAAKsAAACk////AAAAADMAAACcAAAAnQAAABj///8A////AP///wAAAAAYAAAAGP///wD///8A////AAAAABgAAACdAAAAnAAAADMAAAB1AAAAwwAAAP8AAADpAAAAsQAAAE4AAAAb////AP///wAAAAAbAAAATgAAALEAAADpAAAA/wAAAMMAAAB1AAAAtwAAAOkAAAD/AAAA/wAAAP8AAADvAAAA3gAAAN4AAADeAAAA3gAAAO8AAAD/AAAA/wAAAP8AAADpAAAAtwAAAGUAAAA/AAAA3wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAADfAAAAPwAAAGX///8A////AAAAAEgAAADtAAAAvwAAAL0AAADGAAAA7wAAAO8AAADGAAAAvQAAAL8AAADtAAAASP///wD///8A////AP///wD///8AAAAAO////wD///8A////AAAAAIcAAACH////AP///wD///8AAAAAO////wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A//8AAP//AAD4HwAA7/cAAN/7AAD//wAAoYUAAJ55AACf+QAAh+EAAAAAAADAAwAA4AcAAP5/AAD//wAA//8AAA=="/>
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAA3XAAAN1wFCKJt4AAAAB3RJTUUH4QQQEwksSS9ZWwAAAk1JREFUWMPtll2ITVEUx39nn/O7Y5qR8f05wtCUUr6ZIS++8pEnkZInPImneaCQ5METNdOkeFBKUhMPRIkHKfEuUZSUlGlKPN2TrgfncpvmnntnmlEyq1Z7t89/rf9a6+y99oZxGZf/XeIq61EdtgKXgdXA0xrYAvBjOIF1AI9zvjcC74BSpndrJPkBWDScTF8Aa4E3wDlgHbASaANmVqlcCnwHvgDvgVfAJ+AikAAvgfVZwLnSVZHZaOuKoQi3ZOMi4NkYkpe1p4J7A8BpYAD49hfIy/oqG0+hLomiKP2L5L+1ubn5115S+3OAn4EnwBlgMzCjyt6ZAnQCJ4A7wOs88iRJHvw50HoujuPBoCKwHWiosy8MdfZnAdcHk8dxXFJ3VQbQlCTJvRBCGdRbD4M6uc5glpY3eAihpN5S5w12diSEcCCEcKUO4ljdr15T76ur1FDDLIQQ3qv71EdDOe3Kxj3leRXyk+pxdWnFWod6Wt2bY3de3aSuUHcPBVimHs7mK9WrmeOF6lR1o9qnzskh2ar2qm1qizpfXaPeVGdlmGN5pb09qMxz1Xb1kLqgzn1RyH7JUXW52lr5e/Kqi9qpto7V1atuUzfnARrV7jEib1T76gG2qxdGmXyiekkt1GswPTtek0aBfJp6YySGBfWg2tPQ0FAYgf1stUfdmdcjarbYJEniKIq6gY/Aw+zWHAC+p2labGpqiorFYgGYCEzN7oQdQClN07O1/EfDyGgC0ALMBdYAi4FyK+4H3gLPsxfR1zRNi+NP7nH5J+QntnXe5B5mpfQAAAAASUVORK5CYII=">
|
||||
|
||||
<!-- CSS -->
|
||||
<link rel="stylesheet" type="text/css" href="nimdoc.out.css">
|
||||
|
||||
<!-- JS -->
|
||||
<script type="text/javascript" src="dochack.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="document" id="documentId">
|
||||
<div class="container">
|
||||
<h1 class="title">Nim Backend Integration</h1>
|
||||
<div class="row">
|
||||
<div class="three columns">
|
||||
<div class="theme-select-wrapper">
|
||||
<label for="theme-select">Theme: </label>
|
||||
<select id="theme-select" onchange="setTheme(this.value)">
|
||||
<option value="auto">🌗 Match OS</option>
|
||||
<option value="dark">🌑 Dark</option>
|
||||
<option value="light">🌕 Light</option>
|
||||
</select>
|
||||
</div>
|
||||
<div id="global-links">
|
||||
<ul class="simple-boot">
|
||||
<li><a href="manual.html">Manual</a></li>
|
||||
<li><a href="lib.html">Standard library</a></li>
|
||||
<li> <a id="indexLink" href="theindex.html">Index</a></li>
|
||||
<li><a href="compiler/theindex.html">Compiler docs</a></li>
|
||||
<li><a href="https://nim-lang.github.io/fusion/theindex.html">Fusion docs</a></li>
|
||||
<li><a href="https://nim-lang.github.io/Nim/">devel</a>, <a href="https://nim-lang.org/documentation.html">stable</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="searchInputDiv">
|
||||
Search: <input type="search" id="searchInput"
|
||||
onkeyup="search()" />
|
||||
</div>
|
||||
<div class="search-groupby">
|
||||
Group by:
|
||||
<select onchange="groupBy(this.value)">
|
||||
<option value="section">Section</option>
|
||||
<option value="type">Type</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<ul class="simple simple-toc" id="toc-list">
|
||||
<li><a class="reference" id="introduction_toc" href="#introduction">Introduction</a></li>
|
||||
<li><a class="reference" id="backends_toc" href="#backends">Backends</a></li>
|
||||
<ul class="simple"><li><a class="reference" id="backends-the-c-like-targets_toc" href="#backends-the-c-like-targets">The C like targets</a></li>
|
||||
<li><a class="reference" id="backends-the-javascript-target_toc" href="#backends-the-javascript-target">The JavaScript target</a></li>
|
||||
</ul><li><a class="reference" id="interfacing_toc" href="#interfacing">Interfacing</a></li>
|
||||
<ul class="simple"><li><a class="reference" id="interfacing-nim-code-calling-the-backend_toc" href="#interfacing-nim-code-calling-the-backend">Nim code calling the backend</a></li>
|
||||
<ul class="simple"><li><a class="reference" id="nim-code-calling-the-backend-c-invocation-example_toc" href="#nim-code-calling-the-backend-c-invocation-example">C invocation example</a></li>
|
||||
<li><a class="reference" id="nim-code-calling-the-backend-javascript-invocation-example_toc" href="#nim-code-calling-the-backend-javascript-invocation-example">JavaScript invocation example</a></li>
|
||||
</ul><li><a class="reference" id="interfacing-backend-code-calling-nim_toc" href="#interfacing-backend-code-calling-nim">Backend code calling Nim</a></li>
|
||||
<ul class="simple"><li><a class="reference" id="backend-code-calling-nim-nim-invocation-example-from-c_toc" href="#backend-code-calling-nim-nim-invocation-example-from-c">Nim invocation example from C</a></li>
|
||||
<li><a class="reference" id="backend-code-calling-nim-nim-invocation-example-from-javascript_toc" href="#backend-code-calling-nim-nim-invocation-example-from-javascript">Nim invocation example from JavaScript</a></li>
|
||||
</ul><li><a class="reference" id="interfacing-nimcache-naming-logic_toc" href="#interfacing-nimcache-naming-logic">Nimcache naming logic</a></li>
|
||||
</ul><li><a class="reference" id="memory-management_toc" href="#memory-management">Memory management</a></li>
|
||||
<ul class="simple"><li><a class="reference" id="memory-management-strings-and-c-strings_toc" href="#memory-management-strings-and-c-strings">Strings and C strings</a></li>
|
||||
<li><a class="reference" id="memory-management-custom-data-types_toc" href="#memory-management-custom-data-types">Custom data types</a></li>
|
||||
</ul>
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
<div class="nine columns" id="content">
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/doc/backends.md#L1" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/doc/backends.md#L1" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
<div id="tocRoot"></div>
|
||||
|
||||
<p class="module-desc"><table class="docinfo" frame="void" rules="none"><col class="docinfo-name" /><col class="docinfo-content" /><tbody valign="top"><tr><th class="docinfo-name">Author:</th><td>Puppet Master</td></tr>
|
||||
<tr><th class="docinfo-name">Version:</th><td>1.9.1</td></tr>
|
||||
</tbody></table><blockquote class="markdown-quote"><p>"Heresy grows from idleness." -- Unknown.</p></blockquote>
|
||||
|
||||
<h1><a class="toc-backref" id="introduction" href="#introduction">Introduction</a></h1><p>The <a class="reference external" href="nimc.html">Nim Compiler User Guide</a> documents the typical compiler invocation, using the <tt class="docutils literal"><span class="pre option">compile</span></tt> or <tt class="docutils literal"><span class="pre option">c</span></tt> command to transform a <tt class="docutils literal"><span class="pre">.nim</span></tt> file into one or more <tt class="docutils literal"><span class="pre">.c</span></tt> files which are then compiled with the platform's C compiler into a static binary. However, there are other commands to compile to C++, Objective-C, or JavaScript. This document tries to concentrate in a single place all the backend and interfacing options.</p>
|
||||
<p>The Nim compiler supports mainly two backend families: the C, C++ and Objective-C targets and the JavaScript target. <a class="reference external" href=" #backends-the-c-like-targets">The C like targets</a> creates source files that can be compiled into a library or a final executable. <a class="reference external" href=" #backends-the-javascript-target">The JavaScript target</a> can generate a <tt class="docutils literal"><span class="pre">.js</span></tt> file which you reference from an HTML file or create a <a class="reference external" href=" http://nodejs.org">standalone Node.js program</a>.</p>
|
||||
<p>On top of generating libraries or standalone applications, Nim offers bidirectional interfacing with the backend targets through generic and specific pragmas.</p>
|
||||
|
||||
<h1><a class="toc-backref" id="backends" href="#backends">Backends</a></h1>
|
||||
<h2><a class="toc-backref" id="backends-the-c-like-targets" href="#backends-the-c-like-targets">The C like targets</a></h2><p>The commands to compile to either C, C++ or Objective-C are:</p>
|
||||
<div class="option-list"><div class="option-list-item odd"><div class="option-list-label"><tt><span class="option">compileToC, cc</span></tt></div><div class="option-list-description">compile project with C code generator</div></div>
|
||||
<div class="option-list-item"><div class="option-list-label"><tt><span class="option">compileToCpp, cpp</span></tt></div><div class="option-list-description">compile project to C++ code</div></div>
|
||||
<div class="option-list-item odd"><div class="option-list-label"><tt><span class="option">compileToOC, objc</span></tt></div><div class="option-list-description">compile project to Objective C code</div></div>
|
||||
</div><p>The most significant difference between these commands is that if you look into the <tt class="docutils literal"><span class="pre">nimcache</span></tt> directory you will find <tt class="docutils literal"><span class="pre">.c</span></tt>, <tt class="docutils literal"><span class="pre">.cpp</span></tt> or <tt class="docutils literal"><span class="pre">.m</span></tt> files, other than that all of them will produce a native binary for your project. This allows you to take the generated code and place it directly into a project using any of these languages. Here are some typical command- line invocations:</p>
|
||||
<p><pre class="listing">
|
||||
<span class="program">nim</span> <span class="option">c</span> <span class="Identifier">hallo.nim</span>
|
||||
<span class="program">nim</span> <span class="option">cpp</span> <span class="Identifier">hallo.nim</span>
|
||||
<span class="program">nim</span> <span class="option">objc</span> <span class="Identifier">hallo.nim</span></pre></p>
|
||||
<p>The compiler commands select the target backend, but if needed you can <a class="reference external" href=" nimc.html#crossminuscompilation">specify additional switches for cross-compilation</a> to select the target CPU, operative system or compiler/linker commands.</p>
|
||||
|
||||
<h2><a class="toc-backref" id="backends-the-javascript-target" href="#backends-the-javascript-target">The JavaScript target</a></h2><p>Nim can also generate <span id="javascript_1">JavaScript</span> code through the <tt class="docutils literal"><span class="pre option">js</span></tt> command.</p>
|
||||
<p>Nim targets JavaScript 1.5 which is supported by any widely used browser. Since JavaScript does not have a portable means to include another module, Nim just generates a long <tt class="docutils literal"><span class="pre">.js</span></tt> file.</p>
|
||||
<p>Features or modules that the JavaScript platform does not support are not available. This includes:</p>
|
||||
<ul class="simple"><li>manual memory management (<tt class="docutils literal"><span class="pre"><span class="Identifier">alloc</span></span></tt>, etc.)</li>
|
||||
<li>casting and other unsafe operations (<tt class="docutils literal"><span class="pre"><span class="Keyword">cast</span></span></tt> operator, <tt class="docutils literal"><span class="pre"><span class="Identifier">zeroMem</span></span></tt>, etc.)</li>
|
||||
<li>file management</li>
|
||||
<li>OS-specific operations</li>
|
||||
<li>threading, coroutines</li>
|
||||
<li>some modules of the standard library</li>
|
||||
<li>proper 64-bit integer arithmetic</li>
|
||||
</ul>
|
||||
<p>To compensate, the standard library has modules <a class="reference external" href=" lib.html#pure-libraries-modules-for-js-backend">catered to the JS backend</a> and more support will come in the future (for instance, Node.js bindings to get OS info).</p>
|
||||
<p>To compile a Nim module into a <tt class="docutils literal"><span class="pre">.js</span></tt> file use the <tt class="docutils literal"><span class="pre option">js</span></tt> command; the default is a <tt class="docutils literal"><span class="pre">.js</span></tt> file that is supposed to be referenced in an <tt class="docutils literal"><span class="pre">.html</span></tt> file. However, you can also run the code with <span id="nodejs_1">nodejs</span> (<a class="reference external" href="http://nodejs.org">http://nodejs.org</a>):</p>
|
||||
<p><pre class="listing">
|
||||
<span class="program">nim</span> <span class="option">js</span> <span class="option">-d:nodejs</span> <span class="option">-r</span> <span class="Identifier">examples/hallo.nim</span></pre></p>
|
||||
<p>If you experience errors saying that <tt class="docutils literal"><span class="pre"><span class="Identifier">globalThis</span></span></tt> is not defined, be sure to run a recent version of Node.js (at least 12.0).</p>
|
||||
|
||||
<h1><a class="toc-backref" id="interfacing" href="#interfacing">Interfacing</a></h1><p>Nim offers bidirectional interfacing with the target backend. This means that you can call backend code from Nim and Nim code can be called by the backend code. Usually the direction of which calls which depends on your software architecture (is Nim your main program or is Nim providing a component?).</p>
|
||||
|
||||
<h2><a class="toc-backref" id="interfacing-nim-code-calling-the-backend" href="#interfacing-nim-code-calling-the-backend">Nim code calling the backend</a></h2><p>Nim code can interface with the backend through the <a class="reference external" href="manual.html#foreign-function-interface">Foreign function interface</a> mainly through the <a class="reference external" href="manual.html#foreign-function-interface-importc-pragma">importc pragma</a>. The <tt class="docutils literal"><span class="pre"><span class="Identifier">importc</span></span></tt> pragma is the <em>generic</em> way of making backend symbols available in Nim and is available in all the target backends (JavaScript too). The C++ or Objective-C backends have their respective <a class="reference external" href=" manual.html#implementation-specific-pragmas-importcpp-pragma">ImportCpp</a> and <a class="reference external" href="manual.html#implementation-specific-pragmas-importobjc-pragma">ImportObjC</a> pragmas to call methods from classes.</p>
|
||||
<p>Whenever you use any of these pragmas you need to integrate native code into your final binary. In the case of JavaScript this is no problem at all, the same HTML file which hosts the generated JavaScript will likely provide other JavaScript functions which you are importing with <tt class="docutils literal"><span class="pre"><span class="Identifier">importc</span></span></tt>.</p>
|
||||
<p>However, for the C like targets you need to link external code either statically or dynamically. The preferred way of integrating native code is to use dynamic linking because it allows you to compile Nim programs without the need for having the related development libraries installed. This is done through the <a class="reference external" href=" manual.html#foreign-function-interface-dynlib-pragma-for-import">dynlib pragma for import</a>, though more specific control can be gained using the <a class="reference external" href="dynlib.html">dynlib module</a>.</p>
|
||||
<p>The <a class="reference external" href="nimc.html#dynliboverride">dynlibOverride</a> command line switch allows to avoid dynamic linking if you need to statically link something instead. Nim wrappers designed to statically link source files can use the <a class="reference external" href="manual.html#implementation-specific-pragmas-compile-pragma">compile pragma</a> if there are few sources or providing them along the Nim code is easier than using a system library. Libraries installed on the host system can be linked in with the <a class="reference external" href="manual.html#implementation-specific-pragmas-passl-pragma">PassL pragma</a>.</p>
|
||||
<p>To wrap native code, take a look at the <a class="reference external" href=" https://github.com/nim-lang/c2nim/blob/master/doc/c2nim.rst">c2nim tool</a> which helps with the process of scanning and transforming header files into a Nim interface.</p>
|
||||
|
||||
<h3><a class="toc-backref" id="nim-code-calling-the-backend-c-invocation-example" href="#nim-code-calling-the-backend-c-invocation-example">C invocation example</a></h3><p>Create a <tt class="docutils literal"><span class="pre">logic.c</span></tt> file with the following content:</p>
|
||||
<p><pre class="listing">
|
||||
<span class="Keyword">int</span> <span class="Identifier">addTwoIntegers</span><span class="Punctuation">(</span><span class="Keyword">int</span> <span class="Identifier">a</span><span class="Punctuation">,</span> <span class="Keyword">int</span> <span class="Identifier">b</span><span class="Punctuation">)</span>
|
||||
<span class="Punctuation">{</span>
|
||||
<span class="Keyword">return</span> <span class="Identifier">a</span> <span class="Operator">+</span> <span class="Identifier">b</span><span class="Punctuation">;</span>
|
||||
<span class="Punctuation">}</span></pre></p>
|
||||
<p>Create a <tt class="docutils literal"><span class="pre">calculator.nim</span></tt> file with the following content:</p>
|
||||
<p><pre class="listing">
|
||||
<span class="Punctuation">{</span><span class="Operator">.</span><span class="Identifier">compile</span><span class="Punctuation">:</span> <span class="StringLit">"logic.c"</span><span class="Operator">.</span><span class="Punctuation">}</span>
|
||||
<span class="Keyword">proc</span> <span class="Identifier">addTwoIntegers</span><span class="Punctuation">(</span><span class="Identifier">a</span><span class="Punctuation">,</span> <span class="Identifier">b</span><span class="Punctuation">:</span> <span class="Identifier">cint</span><span class="Punctuation">)</span><span class="Punctuation">:</span> <span class="Identifier">cint</span> <span class="Punctuation">{</span><span class="Operator">.</span><span class="Identifier">importc</span><span class="Operator">.</span><span class="Punctuation">}</span>
|
||||
|
||||
<span class="Keyword">when</span> <span class="Identifier">isMainModule</span><span class="Punctuation">:</span>
|
||||
<span class="Identifier">echo</span> <span class="Identifier">addTwoIntegers</span><span class="Punctuation">(</span><span class="DecNumber">3</span><span class="Punctuation">,</span> <span class="DecNumber">7</span><span class="Punctuation">)</span></pre></p>
|
||||
<p>With these two files in place, you can run <tt class="docutils literal"><span class="pre"><span class="program">nim</span> <span class="option">c</span> <span class="option">-r</span> <span class="Identifier">calculator.nim</span></span></tt> and the Nim compiler will compile the <tt class="docutils literal"><span class="pre">logic.c</span></tt> file in addition to <tt class="docutils literal"><span class="pre">calculator.nim</span></tt> and link both into an executable, which outputs <tt class="docutils literal"><span class="pre"><span class="DecNumber">10</span></span></tt> when run. Another way to link the C file statically and get the same effect would be to remove the line with the <tt class="docutils literal"><span class="pre"><span class="Identifier">compile</span></span></tt> pragma and run the following typical Unix commands:</p>
|
||||
<p><pre class="listing">
|
||||
<span class="program">gcc</span> <span class="option">-c</span> <span class="Identifier">logic.c</span>
|
||||
<span class="program">ar</span> <span class="option">rvs</span> <span class="Identifier">mylib.a</span> <span class="Identifier">logic.o</span>
|
||||
<span class="program">nim</span> <span class="option">c</span> <span class="Identifier">--passL:mylib.a</span> <span class="option">-r</span> <span class="Identifier">calculator.nim</span></pre></p>
|
||||
<p>Just like in this example we pass the path to the <tt class="docutils literal"><span class="pre">mylib.a</span></tt> library (and we could as well pass <tt class="docutils literal"><span class="pre">logic.o</span></tt>) we could be passing switches to link any other static C library.</p>
|
||||
|
||||
<h3><a class="toc-backref" id="nim-code-calling-the-backend-javascript-invocation-example" href="#nim-code-calling-the-backend-javascript-invocation-example">JavaScript invocation example</a></h3><p>Create a <tt class="docutils literal"><span class="pre">host.html</span></tt> file with the following content:</p>
|
||||
<p><pre class="listing">
|
||||
<html><body>
|
||||
<script type="text/javascript">
|
||||
function addTwoIntegers(a, b)
|
||||
{
|
||||
return a + b;
|
||||
}
|
||||
</script>
|
||||
<script type="text/javascript" src="calculator.js"></script>
|
||||
</body></html></pre></p>
|
||||
<p>Create a <tt class="docutils literal"><span class="pre">calculator.nim</span></tt> file with the following content (or reuse the one from the previous section):</p>
|
||||
<p><pre class="listing">
|
||||
<span class="Keyword">proc</span> <span class="Identifier">addTwoIntegers</span><span class="Punctuation">(</span><span class="Identifier">a</span><span class="Punctuation">,</span> <span class="Identifier">b</span><span class="Punctuation">:</span> <span class="Identifier">int</span><span class="Punctuation">)</span><span class="Punctuation">:</span> <span class="Identifier">int</span> <span class="Punctuation">{</span><span class="Operator">.</span><span class="Identifier">importc</span><span class="Operator">.</span><span class="Punctuation">}</span>
|
||||
|
||||
<span class="Keyword">when</span> <span class="Identifier">isMainModule</span><span class="Punctuation">:</span>
|
||||
<span class="Identifier">echo</span> <span class="Identifier">addTwoIntegers</span><span class="Punctuation">(</span><span class="DecNumber">3</span><span class="Punctuation">,</span> <span class="DecNumber">7</span><span class="Punctuation">)</span></pre></p>
|
||||
<p>Compile the Nim code to JavaScript with <tt class="docutils literal"><span class="pre"><span class="program">nim</span> <span class="option">js</span> <span class="Identifier">-o:calculator.js</span> <span class="Identifier">calculator.nim</span></span></tt> and open <tt class="docutils literal"><span class="pre">host.html</span></tt> in a browser. If the browser supports javascript, you should see the value <tt class="docutils literal"><span class="pre"><span class="DecNumber">10</span></span></tt> in the browser's console. Use the <a class="reference external" href="dom.html">dom module</a> for specific DOM querying and modification procs or take a look at <a class="reference external" href="https://github.com/pragmagic/karax">karax</a> for how to develop browser-based applications.</p>
|
||||
|
||||
<h2><a class="toc-backref" id="interfacing-backend-code-calling-nim" href="#interfacing-backend-code-calling-nim">Backend code calling Nim</a></h2><p>Backend code can interface with Nim code exposed through the <a class="reference external" href="manual.html#foreign-function-interface-exportc-pragma">exportc pragma</a>. The <tt class="docutils literal"><span class="pre"><span class="Identifier">exportc</span></span></tt> pragma is the <em>generic</em> way of making Nim symbols available to the backends. By default, the Nim compiler will mangle all the Nim symbols to avoid any name collision, so the most significant thing the <tt class="docutils literal"><span class="pre"><span class="Identifier">exportc</span></span></tt> pragma does is maintain the Nim symbol name, or if specified, use an alternative symbol for the backend in case the symbol rules don't match.</p>
|
||||
<p>The JavaScript target doesn't have any further interfacing considerations since it also has garbage collection, but the C targets require you to initialize Nim's internals, which is done calling a <tt class="docutils literal"><span class="pre"><span class="Identifier">NimMain</span></span></tt> function. Also, C code requires you to specify a forward declaration for functions or the compiler will assume certain types for the return value and parameters which will likely make your program crash at runtime.</p>
|
||||
<p>The name <tt class="docutils literal"><span class="pre"><span class="Identifier">NimMain</span></span></tt> can be influenced via the <tt class="docutils literal"><span class="pre"><span class="Operator">--</span><span class="Identifier">nimMainPrefix</span><span class="Punctuation">:</span><span class="Identifier">prefix</span></span></tt> switch. Use <tt class="docutils literal"><span class="pre"><span class="Operator">--</span><span class="Identifier">nimMainPrefix</span><span class="Punctuation">:</span><span class="Identifier">MyLib</span></span></tt> and the function to call is named <tt class="docutils literal"><span class="pre"><span class="Identifier">MyLibNimMain</span></span></tt>.</p>
|
||||
|
||||
<h3><a class="toc-backref" id="backend-code-calling-nim-nim-invocation-example-from-c" href="#backend-code-calling-nim-nim-invocation-example-from-c">Nim invocation example from C</a></h3><p>Create a <tt class="docutils literal"><span class="pre">fib.nim</span></tt> file with the following content:</p>
|
||||
<p><pre class="listing">
|
||||
<span class="Keyword">proc</span> <span class="Identifier">fib</span><span class="Punctuation">(</span><span class="Identifier">a</span><span class="Punctuation">:</span> <span class="Identifier">cint</span><span class="Punctuation">)</span><span class="Punctuation">:</span> <span class="Identifier">cint</span> <span class="Punctuation">{</span><span class="Operator">.</span><span class="Identifier">exportc</span><span class="Operator">.</span><span class="Punctuation">}</span> <span class="Operator">=</span>
|
||||
<span class="Keyword">if</span> <span class="Identifier">a</span> <span class="Operator"><=</span> <span class="DecNumber">2</span><span class="Punctuation">:</span>
|
||||
<span class="Identifier">result</span> <span class="Operator">=</span> <span class="DecNumber">1</span>
|
||||
<span class="Keyword">else</span><span class="Punctuation">:</span>
|
||||
<span class="Identifier">result</span> <span class="Operator">=</span> <span class="Identifier">fib</span><span class="Punctuation">(</span><span class="Identifier">a</span> <span class="Operator">-</span> <span class="DecNumber">1</span><span class="Punctuation">)</span> <span class="Operator">+</span> <span class="Identifier">fib</span><span class="Punctuation">(</span><span class="Identifier">a</span> <span class="Operator">-</span> <span class="DecNumber">2</span><span class="Punctuation">)</span></pre></p>
|
||||
<p>Create a <tt class="docutils literal"><span class="pre">maths.c</span></tt> file with the following content:</p>
|
||||
<p><pre class="listing">
|
||||
<span class="Preprocessor">#include</span> <span class="Operator"><</span><span class="Identifier">stdio</span><span class="Punctuation">.</span><span class="Identifier">h</span><span class="Operator">></span>
|
||||
|
||||
<span class="Keyword">int</span> <span class="Identifier">fib</span><span class="Punctuation">(</span><span class="Keyword">int</span> <span class="Identifier">a</span><span class="Punctuation">)</span><span class="Punctuation">;</span>
|
||||
<span class="Keyword">void</span> <span class="Identifier">NimMain</span><span class="Punctuation">(</span><span class="Punctuation">)</span><span class="Punctuation">;</span>
|
||||
|
||||
<span class="Keyword">int</span> <span class="Identifier">main</span><span class="Punctuation">(</span><span class="Keyword">void</span><span class="Punctuation">)</span>
|
||||
<span class="Punctuation">{</span>
|
||||
<span class="Identifier">NimMain</span><span class="Punctuation">(</span><span class="Punctuation">)</span><span class="Punctuation">;</span>
|
||||
<span class="Keyword">for</span> <span class="Punctuation">(</span><span class="Keyword">int</span> <span class="Identifier">f</span> <span class="Operator">=</span> <span class="DecNumber">0</span><span class="Punctuation">;</span> <span class="Identifier">f</span> <span class="Operator"><</span> <span class="DecNumber">10</span><span class="Punctuation">;</span> <span class="Identifier">f</span><span class="Operator">++</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">printf</span><span class="Punctuation">(</span><span class="StringLit">"Fib of %d is %d</span><span class="EscapeSequence">\n</span><span class="StringLit">"</span><span class="Punctuation">,</span> <span class="Identifier">f</span><span class="Punctuation">,</span> <span class="Identifier">fib</span><span class="Punctuation">(</span><span class="Identifier">f</span><span class="Punctuation">)</span><span class="Punctuation">)</span><span class="Punctuation">;</span>
|
||||
<span class="Keyword">return</span> <span class="DecNumber">0</span><span class="Punctuation">;</span>
|
||||
<span class="Punctuation">}</span></pre></p>
|
||||
<p>Now you can run the following Unix like commands to first generate C sources from the Nim code, then link them into a static binary along your main C program:</p>
|
||||
<p><pre class="listing">
|
||||
<span class="program">nim</span> <span class="option">c</span> <span class="option">--noMain</span> <span class="option">--noLinking</span> <span class="Identifier">fib.nim</span>
|
||||
<span class="program">gcc</span> <span class="option">-o</span> <span class="option">m</span> <span class="Identifier">-I$HOME/.cache/nim/fib_d</span> <span class="Identifier">-Ipath/to/nim/lib</span> <span class="Identifier">$HOME/.cache/nim/fib_d/*.c</span> <span class="Identifier">maths.c</span></pre></p>
|
||||
<p>The first command runs the Nim compiler with three special options to avoid generating a <tt class="docutils literal"><span class="pre"><span class="Identifier">main</span><span class="Punctuation">(</span><span class="Punctuation">)</span></span></tt> function in the generated files and to avoid linking the object files into a final binary. All the generated files are placed into the <tt class="docutils literal"><span class="pre">nimcache</span></tt> directory. That's why the next command compiles the <tt class="docutils literal"><span class="pre">maths.c</span></tt> source plus all the <tt class="docutils literal"><span class="pre">.c</span></tt> files from <tt class="docutils literal"><span class="pre">nimcache</span></tt>. In addition to this path, you also have to tell the C compiler where to find Nim's <tt class="docutils literal"><span class="pre">nimbase.h</span></tt> header file.</p>
|
||||
<p>Instead of depending on the generation of the individual <tt class="docutils literal"><span class="pre">.c</span></tt> files you can also ask the Nim compiler to generate a statically linked library:</p>
|
||||
<p><pre class="listing">
|
||||
<span class="program">nim</span> <span class="option">c</span> <span class="option">--app:staticLib</span> <span class="option">--noMain</span> <span class="Identifier">fib.nim</span>
|
||||
<span class="program">gcc</span> <span class="option">-o</span> <span class="option">m</span> <span class="option">-Inimcache</span> <span class="Identifier">-Ipath/to/nim/lib</span> <span class="Identifier">maths.c</span> <span class="Identifier">libfib.nim.a</span></pre></p>
|
||||
<p>The Nim compiler will handle linking the source files generated in the <tt class="docutils literal"><span class="pre">nimcache</span></tt> directory into the <tt class="docutils literal"><span class="pre">libfib.nim.a</span></tt> static library, which you can then link into your C program. Note that these commands are generic and will vary for each system. For instance, on Linux systems you will likely need to use <tt class="docutils literal"><span class="pre option">-ldl</span></tt> too to link in required dlopen functionality.</p>
|
||||
|
||||
<h3><a class="toc-backref" id="backend-code-calling-nim-nim-invocation-example-from-javascript" href="#backend-code-calling-nim-nim-invocation-example-from-javascript">Nim invocation example from JavaScript</a></h3><p>Create a <tt class="docutils literal"><span class="pre">mhost.html</span></tt> file with the following content:</p>
|
||||
<p><pre class="listing">
|
||||
<html><body>
|
||||
<script type="text/javascript" src="fib.js"></script>
|
||||
<script type="text/javascript">
|
||||
alert("Fib for 9 is " + fib(9));
|
||||
</script>
|
||||
</body></html></pre></p>
|
||||
<p>Create a <tt class="docutils literal"><span class="pre">fib.nim</span></tt> file with the following content (or reuse the one from the previous section):</p>
|
||||
<p><pre class="listing">
|
||||
<span class="Keyword">proc</span> <span class="Identifier">fib</span><span class="Punctuation">(</span><span class="Identifier">a</span><span class="Punctuation">:</span> <span class="Identifier">cint</span><span class="Punctuation">)</span><span class="Punctuation">:</span> <span class="Identifier">cint</span> <span class="Punctuation">{</span><span class="Operator">.</span><span class="Identifier">exportc</span><span class="Operator">.</span><span class="Punctuation">}</span> <span class="Operator">=</span>
|
||||
<span class="Keyword">if</span> <span class="Identifier">a</span> <span class="Operator"><=</span> <span class="DecNumber">2</span><span class="Punctuation">:</span>
|
||||
<span class="Identifier">result</span> <span class="Operator">=</span> <span class="DecNumber">1</span>
|
||||
<span class="Keyword">else</span><span class="Punctuation">:</span>
|
||||
<span class="Identifier">result</span> <span class="Operator">=</span> <span class="Identifier">fib</span><span class="Punctuation">(</span><span class="Identifier">a</span> <span class="Operator">-</span> <span class="DecNumber">1</span><span class="Punctuation">)</span> <span class="Operator">+</span> <span class="Identifier">fib</span><span class="Punctuation">(</span><span class="Identifier">a</span> <span class="Operator">-</span> <span class="DecNumber">2</span><span class="Punctuation">)</span></pre></p>
|
||||
<p>Compile the Nim code to JavaScript with <tt class="docutils literal"><span class="pre"><span class="program">nim</span> <span class="option">js</span> <span class="Identifier">-o:fib.js</span> <span class="Identifier">fib.nim</span></span></tt> and open <tt class="docutils literal"><span class="pre">mhost.html</span></tt> in a browser. If the browser supports javascript, you should see an alert box displaying the text <tt class="docutils literal"><span class="pre">Fib for 9 is 34</span></tt>. As mentioned earlier, JavaScript doesn't require an initialization call to <tt class="docutils literal"><span class="pre"><span class="Identifier">NimMain</span></span></tt> or a similar function and you can call the exported Nim proc directly.</p>
|
||||
|
||||
<h2><a class="toc-backref" id="interfacing-nimcache-naming-logic" href="#interfacing-nimcache-naming-logic">Nimcache naming logic</a></h2><p>The <span id="nimcache_1">nimcache</span> directory is generated during compilation and will hold either temporary or final files depending on your backend target. The default name for the directory depends on the used backend and on your OS but you can use the <tt class="docutils literal"><span class="pre option">--nimcache</span></tt> <a class="reference external" href=" nimc.html#compiler-usage-commandminusline-switches">compiler switch</a> to change it.</p>
|
||||
|
||||
<h1><a class="toc-backref" id="memory-management" href="#memory-management">Memory management</a></h1><p>In the previous sections, the <tt class="docutils literal"><span class="pre"><span class="Identifier">NimMain</span><span class="Punctuation">(</span><span class="Punctuation">)</span></span></tt> function reared its head. Since JavaScript already provides automatic memory management, you can freely pass objects between the two languages without problems. In C and derivate languages you need to be careful about what you do and how you share memory. The previous examples only dealt with simple scalar values, but passing a Nim string to C, or reading back a C string in Nim already requires you to be aware of who controls what to avoid crashing.</p>
|
||||
|
||||
<h2><a class="toc-backref" id="memory-management-strings-and-c-strings" href="#memory-management-strings-and-c-strings">Strings and C strings</a></h2><p>The manual mentions that <a class="reference external" href="manual.html#types-cstring-type">Nim strings are implicitly convertible to cstrings</a> which makes interaction usually painless. Most C functions accepting a Nim string converted to a <tt class="docutils literal"><span class="pre"><span class="Identifier">cstring</span></span></tt> will likely not need to keep this string around and by the time they return the string won't be needed anymore. However, for the rare cases where a Nim string has to be preserved and made available to the C backend as a <tt class="docutils literal"><span class="pre"><span class="Identifier">cstring</span></span></tt>, you will need to manually prevent the string data from being freed with <a class="reference external" href="system.html#GC_ref,string">GC_ref</a> and <a class="reference external" href=" system.html#GC_unref,string">GC_unref</a>.</p>
|
||||
<p>A similar thing happens with C code invoking Nim code which returns a <tt class="docutils literal"><span class="pre"><span class="Identifier">cstring</span></span></tt>. Consider the following proc:</p>
|
||||
<p><pre class="listing">
|
||||
<span class="Keyword">proc</span> <span class="Identifier">gimme</span><span class="Punctuation">(</span><span class="Punctuation">)</span><span class="Punctuation">:</span> <span class="Identifier">cstring</span> <span class="Punctuation">{</span><span class="Operator">.</span><span class="Identifier">exportc</span><span class="Operator">.</span><span class="Punctuation">}</span> <span class="Operator">=</span>
|
||||
<span class="Identifier">result</span> <span class="Operator">=</span> <span class="StringLit">"Hey there C code! "</span> <span class="Operator">&</span> <span class="Operator">$</span><span class="Identifier">rand</span><span class="Punctuation">(</span><span class="DecNumber">100</span><span class="Punctuation">)</span></pre></p>
|
||||
<p>Since Nim's reference counting mechanism is not aware of the C code, once the <tt class="docutils literal"><span class="pre"><span class="Identifier">gimme</span></span></tt> proc has finished it can reclaim the memory of the <tt class="docutils literal"><span class="pre"><span class="Identifier">cstring</span></span></tt>.</p>
|
||||
|
||||
<h2><a class="toc-backref" id="memory-management-custom-data-types" href="#memory-management-custom-data-types">Custom data types</a></h2><p>Just like strings, custom data types that are to be shared between Nim and the backend will need careful consideration of who controls who. If you want to hand a Nim reference to C code, you will need to use <a class="reference external" href=" system.html#GC_ref,ref.T">GC_ref</a> to mark the reference as used, so it does not get freed. And for the C backend you will need to expose the <a class="reference external" href=" system.html#GC_unref,ref.T">GC_unref</a> proc to clean up this memory when it is not required anymore.</p>
|
||||
<p>Again, if you are wrapping a library which <em>mallocs</em> and <em>frees</em> data structures, you need to expose the appropriate <em>free</em> function to Nim so you can clean it up. And of course, once cleaned you should avoid accessing it from Nim (or C for that matter). Typically C data structures have their own <tt class="docutils literal"><span class="pre"><span class="Identifier">malloc_structure</span></span></tt> and <tt class="docutils literal"><span class="pre"><span class="Identifier">free_structure</span></span></tt> specific functions, so wrapping these for the Nim side should be enough. </p>
|
||||
</p>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="twelve-columns footer">
|
||||
<span class="nim-sprite"></span>
|
||||
<br>
|
||||
<small style="color: var(--hint);">Made with Nim. Generated: 2023-03-13 00:19:04 UTC</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script defer data-domain="nim-lang.org" src="https://plausible.io/js/plausible.js"></script>
|
||||
|
||||
<!-- Google fonts -->
|
||||
<link href='https://fonts.googleapis.com/css?family=Lato:400,600,900' rel='stylesheet' type='text/css'/>
|
||||
<link href='https://fonts.googleapis.com/css?family=Source+Code+Pro:400,500,600' rel='stylesheet' type='text/css'/>
|
||||
</body>
|
||||
</html>
|
||||
19
backends.idx
Normal file
19
backends.idx
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
markupTitle Nim Backend Integration backends.html Nim Backend Integration 0
|
||||
heading Introduction backends.html#introduction Introduction 0
|
||||
heading Backends backends.html#backends Backends 0
|
||||
heading The C like targets backends.html#backends-the-c-like-targets The C like targets 0
|
||||
heading The JavaScript target backends.html#backends-the-javascript-target The JavaScript target 0
|
||||
idx JavaScript backends.html#javascript_1 The JavaScript target 0
|
||||
idx nodejs backends.html#nodejs_1 The JavaScript target 0
|
||||
heading Interfacing backends.html#interfacing Interfacing 0
|
||||
heading Nim code calling the backend backends.html#interfacing-nim-code-calling-the-backend Nim code calling the backend 0
|
||||
heading C invocation example backends.html#nim-code-calling-the-backend-c-invocation-example C invocation example 0
|
||||
heading JavaScript invocation example backends.html#nim-code-calling-the-backend-javascript-invocation-example JavaScript invocation example 0
|
||||
heading Backend code calling Nim backends.html#interfacing-backend-code-calling-nim Backend code calling Nim 0
|
||||
heading Nim invocation example from C backends.html#backend-code-calling-nim-nim-invocation-example-from-c Nim invocation example from C 0
|
||||
heading Nim invocation example from JavaScript backends.html#backend-code-calling-nim-nim-invocation-example-from-javascript Nim invocation example from JavaScript 0
|
||||
heading Nimcache naming logic backends.html#interfacing-nimcache-naming-logic Nimcache naming logic 0
|
||||
idx nimcache backends.html#nimcache_1 Nimcache naming logic 0
|
||||
heading Memory management backends.html#memory-management Memory management 0
|
||||
heading Strings and C strings backends.html#memory-management-strings-and-c-strings Strings and C strings 0
|
||||
heading Custom data types backends.html#memory-management-custom-data-types Custom data types 0
|
||||
243
base64.html
Normal file
243
base64.html
Normal file
|
|
@ -0,0 +1,243 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<!-- This file is generated by Nim. -->
|
||||
<html xmlns="https://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>std/base64</title>
|
||||
|
||||
<!-- Favicon -->
|
||||
<link rel="shortcut icon" href="data:image/x-icon;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAUAAAAF////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAIAAABbAAAAlQAAAKIAAACbAAAAmwAAAKIAAACVAAAAWwAAAAL///8A////AP///wD///8A////AAAAABQAAADAAAAAYwAAAA3///8A////AP///wD///8AAAAADQAAAGMAAADAAAAAFP///wD///8A////AP///wAAAACdAAAAOv///wD///8A////AP///wD///8A////AP///wD///8AAAAAOgAAAJ3///8A////AP///wAAAAAnAAAAcP///wAAAAAoAAAASv///wD///8A////AP///wAAAABKAAAAKP///wAAAABwAAAAJ////wD///8AAAAAgQAAABwAAACIAAAAkAAAAJMAAACtAAAAFQAAABUAAACtAAAAkwAAAJAAAACIAAAAHAAAAIH///8A////AAAAAKQAAACrAAAAaP///wD///8AAAAARQAAANIAAADSAAAARf///wD///8AAAAAaAAAAKsAAACk////AAAAADMAAACcAAAAnQAAABj///8A////AP///wAAAAAYAAAAGP///wD///8A////AAAAABgAAACdAAAAnAAAADMAAAB1AAAAwwAAAP8AAADpAAAAsQAAAE4AAAAb////AP///wAAAAAbAAAATgAAALEAAADpAAAA/wAAAMMAAAB1AAAAtwAAAOkAAAD/AAAA/wAAAP8AAADvAAAA3gAAAN4AAADeAAAA3gAAAO8AAAD/AAAA/wAAAP8AAADpAAAAtwAAAGUAAAA/AAAA3wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAADfAAAAPwAAAGX///8A////AAAAAEgAAADtAAAAvwAAAL0AAADGAAAA7wAAAO8AAADGAAAAvQAAAL8AAADtAAAASP///wD///8A////AP///wD///8AAAAAO////wD///8A////AAAAAIcAAACH////AP///wD///8AAAAAO////wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A//8AAP//AAD4HwAA7/cAAN/7AAD//wAAoYUAAJ55AACf+QAAh+EAAAAAAADAAwAA4AcAAP5/AAD//wAA//8AAA=="/>
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAA3XAAAN1wFCKJt4AAAAB3RJTUUH4QQQEwksSS9ZWwAAAk1JREFUWMPtll2ITVEUx39nn/O7Y5qR8f05wtCUUr6ZIS++8pEnkZInPImneaCQ5METNdOkeFBKUhMPRIkHKfEuUZSUlGlKPN2TrgfncpvmnntnmlEyq1Z7t89/rf9a6+y99oZxGZf/XeIq61EdtgKXgdXA0xrYAvBjOIF1AI9zvjcC74BSpndrJPkBWDScTF8Aa4E3wDlgHbASaANmVqlcCnwHvgDvgVfAJ+AikAAvgfVZwLnSVZHZaOuKoQi3ZOMi4NkYkpe1p4J7A8BpYAD49hfIy/oqG0+hLomiKP2L5L+1ubn5115S+3OAn4EnwBlgMzCjyt6ZAnQCJ4A7wOs88iRJHvw50HoujuPBoCKwHWiosy8MdfZnAdcHk8dxXFJ3VQbQlCTJvRBCGdRbD4M6uc5glpY3eAihpN5S5w12diSEcCCEcKUO4ljdr15T76ur1FDDLIQQ3qv71EdDOe3Kxj3leRXyk+pxdWnFWod6Wt2bY3de3aSuUHcPBVimHs7mK9WrmeOF6lR1o9qnzskh2ar2qm1qizpfXaPeVGdlmGN5pb09qMxz1Xb1kLqgzn1RyH7JUXW52lr5e/Kqi9qpto7V1atuUzfnARrV7jEib1T76gG2qxdGmXyiekkt1GswPTtek0aBfJp6YySGBfWg2tPQ0FAYgf1stUfdmdcjarbYJEniKIq6gY/Aw+zWHAC+p2labGpqiorFYgGYCEzN7oQdQClN07O1/EfDyGgC0ALMBdYAi4FyK+4H3gLPsxfR1zRNi+NP7nH5J+QntnXe5B5mpfQAAAAASUVORK5CYII=">
|
||||
|
||||
<!-- CSS -->
|
||||
<link rel="stylesheet" type="text/css" href="nimdoc.out.css">
|
||||
|
||||
<!-- JS -->
|
||||
<script type="text/javascript" src="dochack.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="document" id="documentId">
|
||||
<div class="container">
|
||||
<h1 class="title">std/base64</h1>
|
||||
<div class="row">
|
||||
<div class="three columns">
|
||||
<div class="theme-select-wrapper">
|
||||
<label for="theme-select">Theme: </label>
|
||||
<select id="theme-select" onchange="setTheme(this.value)">
|
||||
<option value="auto">🌗 Match OS</option>
|
||||
<option value="dark">🌑 Dark</option>
|
||||
<option value="light">🌕 Light</option>
|
||||
</select>
|
||||
</div>
|
||||
<div id="global-links">
|
||||
<ul class="simple-boot">
|
||||
<li><a href="manual.html">Manual</a></li>
|
||||
<li><a href="lib.html">Standard library</a></li>
|
||||
<li> <a id="indexLink" href="theindex.html">Index</a></li>
|
||||
<li><a href="compiler/theindex.html">Compiler docs</a></li>
|
||||
<li><a href="https://nim-lang.github.io/fusion/theindex.html">Fusion docs</a></li>
|
||||
<li><a href="https://nim-lang.github.io/Nim/">devel</a>, <a href="https://nim-lang.org/documentation.html">stable</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="searchInputDiv">
|
||||
Search: <input type="search" id="searchInput"
|
||||
onkeyup="search()" />
|
||||
</div>
|
||||
|
||||
<ul class="simple simple-toc" id="toc-list">
|
||||
<li><a class="reference" id="basic-usage_toc" href="#basic-usage">Basic usage</a></li>
|
||||
<ul class="simple"><li><a class="reference" id="basic-usage-encoding-data_toc" href="#basic-usage-encoding-data">Encoding data</a></li>
|
||||
<li><a class="reference" id="basic-usage-decoding-data_toc" href="#basic-usage-decoding-data">Decoding data</a></li>
|
||||
<li><a class="reference" id="basic-usage-url-safe-base64_toc" href="#basic-usage-url-safe-base64">URL Safe Base64</a></li>
|
||||
</ul><li><a class="reference" id="see-also_toc" href="#see-also">See also</a></li>
|
||||
<li>
|
||||
<details open>
|
||||
<summary><a class="reference reference-toplevel" href="#12" id="62">Procs</a></summary>
|
||||
<ul class="simple simple-toc-section">
|
||||
<ul class="simple nested-toc-section">decode
|
||||
<li><a class="reference" href="#decode%2Cstring" title="decode(s: string): string">decode(s: string): string</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">encode
|
||||
<li><a class="reference" href="#encode%2CopenArray%5BT%5D" title="encode[T: byte | char](s: openArray[T]; safe = false): string">encode[T: byte | char](s: openArray[T]; safe = false): string</a></li>
|
||||
<li><a class="reference" href="#encode%2CopenArray%5BT%5D_2" title="encode[T: SomeInteger and not byte](s: openArray[T]; safe = false): string">encode[T: SomeInteger and not byte](s: openArray[T]; safe = false): string</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">encodeMime
|
||||
<li><a class="reference" href="#encodeMime%2Cstring%2Cstring" title="encodeMime(s: string; lineLen = 75.Positive; newLine = "\r\n"; safe = false): string">encodeMime(s: string; lineLen = 75.Positive; newLine = "\r\n"; safe = false): string</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">initDecodeTable
|
||||
<li><a class="reference" href="#initDecodeTable" title="initDecodeTable(): array[256, char]">initDecodeTable(): array[256, char]</a></li>
|
||||
|
||||
</ul>
|
||||
|
||||
</ul>
|
||||
</details>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
<div class="nine columns" id="content">
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/base64.nim#L1" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/base64.nim#L1" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
<div id="tocRoot"></div>
|
||||
|
||||
<p class="module-desc"><p>This module implements a base64 encoder and decoder.</p>
|
||||
<p>Unstable API.</p>
|
||||
<p>Base64 is an encoding and decoding technique used to convert binary data to an ASCII string format. Each Base64 digit represents exactly 6 bits of data. Three 8-bit bytes (i.e., a total of 24 bits) can therefore be represented by four 6-bit Base64 digits.</p>
|
||||
|
||||
<h1><a class="toc-backref" id="basic-usage" href="#basic-usage">Basic usage</a></h1>
|
||||
<h2><a class="toc-backref" id="basic-usage-encoding-data" href="#basic-usage-encoding-data">Encoding data</a></h2>
|
||||
<p><strong class="examples_text">Example:</strong></p>
|
||||
<pre class="listing"><span class="Keyword">import</span> <span class="Identifier">std</span><span class="Operator">/</span><span class="Identifier">base64</span>
|
||||
<span class="Keyword">let</span> <span class="Identifier">encoded</span> <span class="Operator">=</span> <span class="Identifier">encode</span><span class="Punctuation">(</span><span class="StringLit">"Hello World"</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">encoded</span> <span class="Operator">==</span> <span class="StringLit">"SGVsbG8gV29ybGQ="</span></pre>Apart from strings you can also encode lists of integers or characters:
|
||||
<p><strong class="examples_text">Example:</strong></p>
|
||||
<pre class="listing"><span class="Keyword">import</span> <span class="Identifier">std</span><span class="Operator">/</span><span class="Identifier">base64</span>
|
||||
<span class="Keyword">let</span> <span class="Identifier">encodedInts</span> <span class="Operator">=</span> <span class="Identifier">encode</span><span class="Punctuation">(</span><span class="Punctuation">[</span><span class="DecNumber">1'</span><span class="Identifier">u8</span><span class="Punctuation">,</span><span class="DecNumber">2</span><span class="Punctuation">,</span><span class="DecNumber">3</span><span class="Punctuation">]</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">encodedInts</span> <span class="Operator">==</span> <span class="StringLit">"AQID"</span>
|
||||
<span class="Keyword">let</span> <span class="Identifier">encodedChars</span> <span class="Operator">=</span> <span class="Identifier">encode</span><span class="Punctuation">(</span><span class="Punctuation">[</span><span class="CharLit">'h'</span><span class="Punctuation">,</span><span class="CharLit">'e'</span><span class="Punctuation">,</span><span class="CharLit">'y'</span><span class="Punctuation">]</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">encodedChars</span> <span class="Operator">==</span> <span class="StringLit">"aGV5"</span></pre>
|
||||
<h2><a class="toc-backref" id="basic-usage-decoding-data" href="#basic-usage-decoding-data">Decoding data</a></h2>
|
||||
<p><strong class="examples_text">Example:</strong></p>
|
||||
<pre class="listing"><span class="Keyword">import</span> <span class="Identifier">std</span><span class="Operator">/</span><span class="Identifier">base64</span>
|
||||
<span class="Keyword">let</span> <span class="Identifier">decoded</span> <span class="Operator">=</span> <span class="Identifier">decode</span><span class="Punctuation">(</span><span class="StringLit">"SGVsbG8gV29ybGQ="</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">decoded</span> <span class="Operator">==</span> <span class="StringLit">"Hello World"</span></pre>
|
||||
<h2><a class="toc-backref" id="basic-usage-url-safe-base64" href="#basic-usage-url-safe-base64">URL Safe Base64</a></h2>
|
||||
<p><strong class="examples_text">Example:</strong></p>
|
||||
<pre class="listing"><span class="Keyword">import</span> <span class="Identifier">std</span><span class="Operator">/</span><span class="Identifier">base64</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">encode</span><span class="Punctuation">(</span><span class="StringLit">"c</span><span class="EscapeSequence">\xf7</span><span class="StringLit">>"</span><span class="Punctuation">,</span> <span class="Identifier">safe</span> <span class="Operator">=</span> <span class="Identifier">true</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="StringLit">"Y_c-"</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">encode</span><span class="Punctuation">(</span><span class="StringLit">"c</span><span class="EscapeSequence">\xf7</span><span class="StringLit">>"</span><span class="Punctuation">,</span> <span class="Identifier">safe</span> <span class="Operator">=</span> <span class="Identifier">false</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="StringLit">"Y/c+"</span></pre>
|
||||
<h1><a class="toc-backref" id="see-also" href="#see-also">See also</a></h1><ul class="simple"><li><a class="reference external" href="hashes.html">hashes module</a> for efficient computations of hash values for diverse Nim types</li>
|
||||
<li><a class="reference external" href="md5.html">md5 module</a> for the MD5 checksum algorithm</li>
|
||||
<li><a class="reference external" href="sha1.html">sha1 module</a> for the SHA-1 checksum algorithm</li>
|
||||
</ul>
|
||||
</p>
|
||||
<div class="section" id="12">
|
||||
<h1><a class="toc-backref" href="#12">Procs</a></h1>
|
||||
<dl class="item">
|
||||
<div id="decode-procs-all">
|
||||
<div id="decode,string">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#decode%2Cstring"><span class="Identifier">decode</span></a><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ValueError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Decodes string <tt class="docutils literal"><span class="pre"><span class="Identifier">s</span></span></tt> in base64 representation back into its original form. The initial whitespace is skipped.</p>
|
||||
<p><strong>See also:</strong></p>
|
||||
<ul class="simple"><li><a class="reference external" href="#encode,openArray[T]">encode proc</a> for encoding an openarray</li>
|
||||
</ul>
|
||||
|
||||
<p><strong class="examples_text">Example:</strong></p>
|
||||
<pre class="listing"><span class="Identifier">assert</span> <span class="Identifier">decode</span><span class="Punctuation">(</span><span class="StringLit">"SGVsbG8gV29ybGQ="</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="StringLit">"Hello World"</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">decode</span><span class="Punctuation">(</span><span class="StringLit">" SGVsbG8gV29ybGQ="</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="StringLit">"Hello World"</span></pre>
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/base64.nim#L221" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/base64.nim#L221" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="encode-procs-all">
|
||||
<div id="encode,openArray[T]">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#encode%2CopenArray%5BT%5D"><span class="Identifier">encode</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">:</span> <a href="system.html#byte"><span class="Identifier">byte</span></a> <span class="Operator">|</span> <a href="system.html#char"><span class="Identifier">char</span></a><span class="Other">]</span><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="system.html#openArray"><span class="Identifier">openArray</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">safe</span> <span class="Other">=</span> <span class="Identifier">false</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a></pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Encodes <tt class="docutils literal"><span class="pre"><span class="Identifier">s</span></span></tt> into base64 representation.</p>
|
||||
<p>If <tt class="docutils literal"><span class="pre"><span class="Identifier">safe</span></span></tt> is <tt class="docutils literal"><span class="pre"><span class="Identifier">true</span></span></tt> then it will encode using the URL-Safe and Filesystem-safe standard alphabet characters, which substitutes <tt class="docutils literal"><span class="pre"><span class="Operator">-</span></span></tt> instead of <tt class="docutils literal"><span class="pre"><span class="Operator">+</span></span></tt> and <tt class="docutils literal"><span class="pre"><span class="Identifier">_</span></span></tt> instead of <tt class="docutils literal"><span class="pre"><span class="Operator">/</span></span></tt>.</p>
|
||||
<ul class="simple"><li><a class="reference external" href="https://en.wikipedia.org/wiki/Base64#URL_applications">https://en.wikipedia.org/wiki/Base64#URL_applications</a></li>
|
||||
<li><a class="reference external" href="https://tools.ietf.org/html/rfc4648#page-7">https://tools.ietf.org/html/rfc4648#page-7</a></li>
|
||||
</ul>
|
||||
<p><strong>See also:</strong></p>
|
||||
<ul class="simple"><li><a class="reference external" href="#decode,string">decode proc</a> for decoding a string</li>
|
||||
</ul>
|
||||
|
||||
<p><strong class="examples_text">Example:</strong></p>
|
||||
<pre class="listing"><span class="Identifier">assert</span> <span class="Identifier">encode</span><span class="Punctuation">(</span><span class="StringLit">"Hello World"</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="StringLit">"SGVsbG8gV29ybGQ="</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">encode</span><span class="Punctuation">(</span><span class="Punctuation">[</span><span class="CharLit">'n'</span><span class="Punctuation">,</span> <span class="CharLit">'i'</span><span class="Punctuation">,</span> <span class="CharLit">'m'</span><span class="Punctuation">]</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="StringLit">"bmlt"</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">encode</span><span class="Punctuation">(</span><span class="Operator">@</span><span class="Punctuation">[</span><span class="CharLit">'n'</span><span class="Punctuation">,</span> <span class="CharLit">'i'</span><span class="Punctuation">,</span> <span class="CharLit">'m'</span><span class="Punctuation">]</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="StringLit">"bmlt"</span>
|
||||
<span class="Identifier">assert</span> <span class="Identifier">encode</span><span class="Punctuation">(</span><span class="Punctuation">[</span><span class="DecNumber">1'</span><span class="Identifier">u8</span><span class="Punctuation">,</span> <span class="DecNumber">2</span><span class="Punctuation">,</span> <span class="DecNumber">3</span><span class="Punctuation">,</span> <span class="DecNumber">4</span><span class="Punctuation">,</span> <span class="DecNumber">5</span><span class="Punctuation">]</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="StringLit">"AQIDBAU="</span></pre>
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/base64.nim#L146" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/base64.nim#L146" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
<div id="encode,openArray[T]_2">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#encode%2CopenArray%5BT%5D_2"><span class="Identifier">encode</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">:</span> <a href="system.html#SomeInteger"><span class="Identifier">SomeInteger</span></a> <span class="Keyword">and</span> <span class="Keyword">not</span> <a href="system.html#byte"><span class="Identifier">byte</span></a><span class="Other">]</span><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="system.html#openArray"><span class="Identifier">openArray</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">;</span> <span class="Identifier">safe</span> <span class="Other">=</span> <span class="Identifier">false</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> {.
|
||||
<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">deprecated</span><span class="Other">:</span> <span class="StringLit">"use `byte` or `char` instead"</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
<div class="deprecation-message">
|
||||
<b>Deprecated:</b> use `byte` or `char` instead
|
||||
</div>
|
||||
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/base64.nim#L164" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/base64.nim#L164" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="encodeMime-procs-all">
|
||||
<div id="encodeMime,string,string">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#encodeMime%2Cstring%2Cstring"><span class="Identifier">encodeMime</span></a><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">;</span> <span class="Identifier">lineLen</span> <span class="Other">=</span> <span class="DecNumber">75</span><span class="Other">.</span><span class="Identifier">Positive</span><span class="Other">;</span> <span class="Identifier">newLine</span> <span class="Other">=</span> <span class="StringLit">"\r\n"</span><span class="Other">;</span> <span class="Identifier">safe</span> <span class="Other">=</span> <span class="Identifier">false</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> {.
|
||||
<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Encodes <tt class="docutils literal"><span class="pre"><span class="Identifier">s</span></span></tt> into base64 representation as lines. Used in email MIME format, use <tt class="docutils literal"><span class="pre"><span class="Identifier">lineLen</span></span></tt> and <tt class="docutils literal"><span class="pre"><span class="Identifier">newline</span></span></tt>.</p>
|
||||
<p>This procedure encodes a string according to MIME spec.</p>
|
||||
<p>If <tt class="docutils literal"><span class="pre"><span class="Identifier">safe</span></span></tt> is <tt class="docutils literal"><span class="pre"><span class="Identifier">true</span></span></tt> then it will encode using the URL-Safe and Filesystem-safe standard alphabet characters, which substitutes <tt class="docutils literal"><span class="pre"><span class="Operator">-</span></span></tt> instead of <tt class="docutils literal"><span class="pre"><span class="Operator">+</span></span></tt> and <tt class="docutils literal"><span class="pre"><span class="Identifier">_</span></span></tt> instead of <tt class="docutils literal"><span class="pre"><span class="Operator">/</span></span></tt>.</p>
|
||||
<ul class="simple"><li><a class="reference external" href="https://en.wikipedia.org/wiki/Base64#URL_applications">https://en.wikipedia.org/wiki/Base64#URL_applications</a></li>
|
||||
<li><a class="reference external" href="https://tools.ietf.org/html/rfc4648#page-7">https://tools.ietf.org/html/rfc4648#page-7</a></li>
|
||||
</ul>
|
||||
<p><strong>See also:</strong></p>
|
||||
<ul class="simple"><li><a class="reference external" href="#encode,openArray[T]">encode proc</a> for encoding an openArray</li>
|
||||
<li><a class="reference external" href="#decode,string">decode proc</a> for decoding a string</li>
|
||||
</ul>
|
||||
|
||||
<p><strong class="examples_text">Example:</strong></p>
|
||||
<pre class="listing"><span class="Identifier">assert</span> <span class="Identifier">encodeMime</span><span class="Punctuation">(</span><span class="StringLit">"Hello World"</span><span class="Punctuation">,</span> <span class="DecNumber">4</span><span class="Punctuation">,</span> <span class="StringLit">"</span><span class="EscapeSequence">\n</span><span class="StringLit">"</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="StringLit">"SGVs</span><span class="EscapeSequence">\n</span><span class="StringLit">bG8g</span><span class="EscapeSequence">\n</span><span class="StringLit">V29y</span><span class="EscapeSequence">\n</span><span class="StringLit">bGQ="</span></pre>
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/base64.nim#L168" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/base64.nim#L168" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="initDecodeTable-procs-all">
|
||||
<div id="initDecodeTable">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#initDecodeTable"><span class="Identifier">initDecodeTable</span></a><span class="Other">(</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#array"><span class="Identifier">array</span></a><span class="Other">[</span><span class="DecNumber">256</span><span class="Other">,</span> <a href="system.html#char"><span class="Identifier">char</span></a><span class="Other">]</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/base64.nim#L206" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/base64.nim#L206" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="twelve-columns footer">
|
||||
<span class="nim-sprite"></span>
|
||||
<br>
|
||||
<small style="color: var(--hint);">Made with Nim. Generated: 2023-03-13 00:19:33 UTC</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script defer data-domain="nim-lang.org" src="https://plausible.io/js/plausible.js"></script>
|
||||
|
||||
<!-- Google fonts -->
|
||||
<link href='https://fonts.googleapis.com/css?family=Lato:400,600,900' rel='stylesheet' type='text/css'/>
|
||||
<link href='https://fonts.googleapis.com/css?family=Source+Code+Pro:400,500,600' rel='stylesheet' type='text/css'/>
|
||||
</body>
|
||||
</html>
|
||||
12
base64.idx
Normal file
12
base64.idx
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
nimTitle base64 base64.html module std/base64 0
|
||||
nim encode base64.html#encode,openArray[T] proc encode[T: byte | char](s: openArray[T]; safe = false): string 146
|
||||
nim encode base64.html#encode,openArray[T]_2 proc encode[T: SomeInteger and not byte](s: openArray[T]; safe = false): string 164
|
||||
nim encodeMime base64.html#encodeMime,string,string proc encodeMime(s: string; lineLen = 75.Positive; newLine = "\r\n"; safe = false): string 168
|
||||
nim initDecodeTable base64.html#initDecodeTable proc initDecodeTable(): array[256, char] 206
|
||||
nim decode base64.html#decode,string proc decode(s: string): string 221
|
||||
heading Basic usage base64.html#basic-usage Basic usage 0
|
||||
heading Encoding data base64.html#basic-usage-encoding-data Encoding data 0
|
||||
heading Decoding data base64.html#basic-usage-decoding-data Decoding data 0
|
||||
heading URL Safe Base64 base64.html#basic-usage-url-safe-base64 URL Safe Base64 0
|
||||
heading See also base64.html#see-also See also 0
|
||||
nimgrp encode base64.html#encode-procs-all proc 146
|
||||
|
|
@ -1 +0,0 @@
|
|||
This file keeps several tools from deleting this subdirectory.
|
||||
25
bin/nim-gdb
25
bin/nim-gdb
|
|
@ -1,25 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Exit if anything fails
|
||||
set -e
|
||||
|
||||
which nim > /dev/null || (echo "nim not in PATH"; exit 1)
|
||||
which gdb > /dev/null || (echo "gdb not in PATH"; exit 1)
|
||||
which readlink > /dev/null || (echo "readlink not in PATH."; exit 1)
|
||||
|
||||
if [[ $(uname -s) == Darwin || $(uname -s) == *BSD ]]; then
|
||||
NIM_SYSROOT=$(dirname $(dirname $(readlink -f $(which nim))))
|
||||
else
|
||||
NIM_SYSROOT=$(dirname $(dirname $(readlink -e $(which nim))))
|
||||
fi
|
||||
|
||||
# Find out where the pretty printer Python module is
|
||||
GDB_PYTHON_MODULE_PATH="$NIM_SYSROOT/tools/debug/nim-gdb.py"
|
||||
|
||||
# Run GDB with the additional arguments that load the pretty printers
|
||||
# Set the environment variable `NIM_GDB` to overwrite the call to a
|
||||
# different/specific command (defaults to `gdb`).
|
||||
NIM_GDB="${NIM_GDB:-gdb}"
|
||||
# exec replaces the new process of bash with gdb. It is always good to
|
||||
# have fewer processes.
|
||||
exec "${NIM_GDB}" -eval-command="source $GDB_PYTHON_MODULE_PATH" "$@"
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
@echo off
|
||||
for %%i in (nim.exe) do (set NIM_BIN=%%~dp$PATH:i)
|
||||
|
||||
for %%i in ("%NIM_BIN%\..\") do (set NIM_ROOT=%%~fi)
|
||||
|
||||
set @GDB_PYTHON_MODULE_PATH=%NIM_ROOT%\tools\debug\nim-gdb.py
|
||||
set @NIM_GDB=gdb.exe
|
||||
|
||||
@echo source %@GDB_PYTHON_MODULE_PATH%> wingdbcommand.txt
|
||||
%@NIM_GDB% --command="wingdbcommand.txt" %*
|
||||
del wingdbcommand.txt /f /q
|
||||
|
||||
EXIT /B %ERRORLEVEL%
|
||||
@echo on
|
||||
974
bitops.html
Normal file
974
bitops.html
Normal file
|
|
@ -0,0 +1,974 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<!-- This file is generated by Nim. -->
|
||||
<html xmlns="https://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>std/bitops</title>
|
||||
|
||||
<!-- Favicon -->
|
||||
<link rel="shortcut icon" href="data:image/x-icon;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAUAAAAF////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAIAAABbAAAAlQAAAKIAAACbAAAAmwAAAKIAAACVAAAAWwAAAAL///8A////AP///wD///8A////AAAAABQAAADAAAAAYwAAAA3///8A////AP///wD///8AAAAADQAAAGMAAADAAAAAFP///wD///8A////AP///wAAAACdAAAAOv///wD///8A////AP///wD///8A////AP///wD///8AAAAAOgAAAJ3///8A////AP///wAAAAAnAAAAcP///wAAAAAoAAAASv///wD///8A////AP///wAAAABKAAAAKP///wAAAABwAAAAJ////wD///8AAAAAgQAAABwAAACIAAAAkAAAAJMAAACtAAAAFQAAABUAAACtAAAAkwAAAJAAAACIAAAAHAAAAIH///8A////AAAAAKQAAACrAAAAaP///wD///8AAAAARQAAANIAAADSAAAARf///wD///8AAAAAaAAAAKsAAACk////AAAAADMAAACcAAAAnQAAABj///8A////AP///wAAAAAYAAAAGP///wD///8A////AAAAABgAAACdAAAAnAAAADMAAAB1AAAAwwAAAP8AAADpAAAAsQAAAE4AAAAb////AP///wAAAAAbAAAATgAAALEAAADpAAAA/wAAAMMAAAB1AAAAtwAAAOkAAAD/AAAA/wAAAP8AAADvAAAA3gAAAN4AAADeAAAA3gAAAO8AAAD/AAAA/wAAAP8AAADpAAAAtwAAAGUAAAA/AAAA3wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAADfAAAAPwAAAGX///8A////AAAAAEgAAADtAAAAvwAAAL0AAADGAAAA7wAAAO8AAADGAAAAvQAAAL8AAADtAAAASP///wD///8A////AP///wD///8AAAAAO////wD///8A////AAAAAIcAAACH////AP///wD///8AAAAAO////wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A//8AAP//AAD4HwAA7/cAAN/7AAD//wAAoYUAAJ55AACf+QAAh+EAAAAAAADAAwAA4AcAAP5/AAD//wAA//8AAA=="/>
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAA3XAAAN1wFCKJt4AAAAB3RJTUUH4QQQEwksSS9ZWwAAAk1JREFUWMPtll2ITVEUx39nn/O7Y5qR8f05wtCUUr6ZIS++8pEnkZInPImneaCQ5METNdOkeFBKUhMPRIkHKfEuUZSUlGlKPN2TrgfncpvmnntnmlEyq1Z7t89/rf9a6+y99oZxGZf/XeIq61EdtgKXgdXA0xrYAvBjOIF1AI9zvjcC74BSpndrJPkBWDScTF8Aa4E3wDlgHbASaANmVqlcCnwHvgDvgVfAJ+AikAAvgfVZwLnSVZHZaOuKoQi3ZOMi4NkYkpe1p4J7A8BpYAD49hfIy/oqG0+hLomiKP2L5L+1ubn5115S+3OAn4EnwBlgMzCjyt6ZAnQCJ4A7wOs88iRJHvw50HoujuPBoCKwHWiosy8MdfZnAdcHk8dxXFJ3VQbQlCTJvRBCGdRbD4M6uc5glpY3eAihpN5S5w12diSEcCCEcKUO4ljdr15T76ur1FDDLIQQ3qv71EdDOe3Kxj3leRXyk+pxdWnFWod6Wt2bY3de3aSuUHcPBVimHs7mK9WrmeOF6lR1o9qnzskh2ar2qm1qizpfXaPeVGdlmGN5pb09qMxz1Xb1kLqgzn1RyH7JUXW52lr5e/Kqi9qpto7V1atuUzfnARrV7jEib1T76gG2qxdGmXyiekkt1GswPTtek0aBfJp6YySGBfWg2tPQ0FAYgf1stUfdmdcjarbYJEniKIq6gY/Aw+zWHAC+p2labGpqiorFYgGYCEzN7oQdQClN07O1/EfDyGgC0ALMBdYAi4FyK+4H3gLPsxfR1zRNi+NP7nH5J+QntnXe5B5mpfQAAAAASUVORK5CYII=">
|
||||
|
||||
<!-- CSS -->
|
||||
<link rel="stylesheet" type="text/css" href="nimdoc.out.css">
|
||||
|
||||
<!-- JS -->
|
||||
<script type="text/javascript" src="dochack.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="document" id="documentId">
|
||||
<div class="container">
|
||||
<h1 class="title">std/bitops</h1>
|
||||
<div class="row">
|
||||
<div class="three columns">
|
||||
<div class="theme-select-wrapper">
|
||||
<label for="theme-select">Theme: </label>
|
||||
<select id="theme-select" onchange="setTheme(this.value)">
|
||||
<option value="auto">🌗 Match OS</option>
|
||||
<option value="dark">🌑 Dark</option>
|
||||
<option value="light">🌕 Light</option>
|
||||
</select>
|
||||
</div>
|
||||
<div id="global-links">
|
||||
<ul class="simple-boot">
|
||||
<li><a href="manual.html">Manual</a></li>
|
||||
<li><a href="lib.html">Standard library</a></li>
|
||||
<li> <a id="indexLink" href="theindex.html">Index</a></li>
|
||||
<li><a href="compiler/theindex.html">Compiler docs</a></li>
|
||||
<li><a href="https://nim-lang.github.io/fusion/theindex.html">Fusion docs</a></li>
|
||||
<li><a href="https://nim-lang.github.io/Nim/">devel</a>, <a href="https://nim-lang.org/documentation.html">stable</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="searchInputDiv">
|
||||
Search: <input type="search" id="searchInput"
|
||||
onkeyup="search()" />
|
||||
</div>
|
||||
|
||||
<ul class="simple simple-toc" id="toc-list">
|
||||
<li>
|
||||
<a class="reference reference-toplevel" href="#6" id="56">Imports</a>
|
||||
</li>
|
||||
<li>
|
||||
<details open>
|
||||
<summary><a class="reference reference-toplevel" href="#7" id="57">Types</a></summary>
|
||||
<ul class="simple simple-toc-section">
|
||||
<li><a class="reference" href="#BitsRange" title="BitsRange[T] = range[0 .. sizeof(T) * 8 - 1]">BitsRange</a></li>
|
||||
|
||||
</ul>
|
||||
</details>
|
||||
</li>
|
||||
<li>
|
||||
<details open>
|
||||
<summary><a class="reference reference-toplevel" href="#12" id="62">Procs</a></summary>
|
||||
<ul class="simple simple-toc-section">
|
||||
<ul class="simple nested-toc-section">bitnot
|
||||
<li><a class="reference" href="#bitnot%2CT" title="bitnot[T: SomeInteger](x: T): T">bitnot[T: SomeInteger](x: T): T</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">bitslice
|
||||
<li><a class="reference" href="#bitslice%2CT%2CSlice%5Bint%5D" title="bitslice[T: SomeInteger](v: var T; slice: Slice[int])">bitslice[T: SomeInteger](v: var T; slice: Slice[int])</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">bitsliced
|
||||
<li><a class="reference" href="#bitsliced%2CT%2CSlice%5Bint%5D" title="bitsliced[T: SomeInteger](v: T; slice: Slice[int]): T">bitsliced[T: SomeInteger](v: T; slice: Slice[int]): T</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">clearBit
|
||||
<li><a class="reference" href="#clearBit%2CT%2CBitsRange%5BT%3A%20SomeInteger%5D" title="clearBit[T: SomeInteger](v: var T; bit: BitsRange[T])">clearBit[T: SomeInteger](v: var T; bit: BitsRange[T])</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">clearMask
|
||||
<li><a class="reference" href="#clearMask%2CT%2CT" title="clearMask[T: SomeInteger](v: var T; mask: T)">clearMask[T: SomeInteger](v: var T; mask: T)</a></li>
|
||||
<li><a class="reference" href="#clearMask%2CT%2CSlice%5Bint%5D" title="clearMask[T: SomeInteger](v: var T; slice: Slice[int])">clearMask[T: SomeInteger](v: var T; slice: Slice[int])</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">clearMasked
|
||||
<li><a class="reference" href="#clearMasked%2CT%2CT" title="clearMasked[T: SomeInteger](v, mask: T): T">clearMasked[T: SomeInteger](v, mask: T): T</a></li>
|
||||
<li><a class="reference" href="#clearMasked%2CT%2CSlice%5Bint%5D" title="clearMasked[T: SomeInteger](v: T; slice: Slice[int]): T">clearMasked[T: SomeInteger](v: T; slice: Slice[int]): T</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">countLeadingZeroBits
|
||||
<li><a class="reference" href="#countLeadingZeroBits%2CSomeInteger" title="countLeadingZeroBits(x: SomeInteger): int">countLeadingZeroBits(x: SomeInteger): int</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">countSetBits
|
||||
<li><a class="reference" href="#countSetBits%2CSomeInteger" title="countSetBits(x: SomeInteger): int">countSetBits(x: SomeInteger): int</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">countTrailingZeroBits
|
||||
<li><a class="reference" href="#countTrailingZeroBits%2CSomeInteger" title="countTrailingZeroBits(x: SomeInteger): int">countTrailingZeroBits(x: SomeInteger): int</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">fastLog2
|
||||
<li><a class="reference" href="#fastLog2%2CSomeInteger" title="fastLog2(x: SomeInteger): int">fastLog2(x: SomeInteger): int</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">firstSetBit
|
||||
<li><a class="reference" href="#firstSetBit%2CSomeInteger" title="firstSetBit(x: SomeInteger): int">firstSetBit(x: SomeInteger): int</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">flipBit
|
||||
<li><a class="reference" href="#flipBit%2CT%2CBitsRange%5BT%3A%20SomeInteger%5D" title="flipBit[T: SomeInteger](v: var T; bit: BitsRange[T])">flipBit[T: SomeInteger](v: var T; bit: BitsRange[T])</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">flipMask
|
||||
<li><a class="reference" href="#flipMask%2CT%2CT" title="flipMask[T: SomeInteger](v: var T; mask: T)">flipMask[T: SomeInteger](v: var T; mask: T)</a></li>
|
||||
<li><a class="reference" href="#flipMask%2CT%2CSlice%5Bint%5D" title="flipMask[T: SomeInteger](v: var T; slice: Slice[int])">flipMask[T: SomeInteger](v: var T; slice: Slice[int])</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">flipMasked
|
||||
<li><a class="reference" href="#flipMasked%2CT%2CT" title="flipMasked[T: SomeInteger](v, mask: T): T">flipMasked[T: SomeInteger](v, mask: T): T</a></li>
|
||||
<li><a class="reference" href="#flipMasked%2CT%2CSlice%5Bint%5D" title="flipMasked[T: SomeInteger](v: T; slice: Slice[int]): T">flipMasked[T: SomeInteger](v: T; slice: Slice[int]): T</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">mask
|
||||
<li><a class="reference" href="#mask%2CT%2CT" title="mask[T: SomeInteger](v: var T; mask: T)">mask[T: SomeInteger](v: var T; mask: T)</a></li>
|
||||
<li><a class="reference" href="#mask%2CT%2CSlice%5Bint%5D" title="mask[T: SomeInteger](v: var T; slice: Slice[int])">mask[T: SomeInteger](v: var T; slice: Slice[int])</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">masked
|
||||
<li><a class="reference" href="#masked%2CT%2CT" title="masked[T: SomeInteger](v, mask: T): T">masked[T: SomeInteger](v, mask: T): T</a></li>
|
||||
<li><a class="reference" href="#masked%2CT%2CSlice%5Bint%5D" title="masked[T: SomeInteger](v: T; slice: Slice[int]): T">masked[T: SomeInteger](v: T; slice: Slice[int]): T</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">parityBits
|
||||
<li><a class="reference" href="#parityBits%2CSomeInteger" title="parityBits(x: SomeInteger): int">parityBits(x: SomeInteger): int</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">popcount
|
||||
<li><a class="reference" href="#popcount%2CSomeInteger" title="popcount(x: SomeInteger): int">popcount(x: SomeInteger): int</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">reverseBits
|
||||
<li><a class="reference" href="#reverseBits%2CT" title="reverseBits[T: SomeUnsignedInt](x: T): T">reverseBits[T: SomeUnsignedInt](x: T): T</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">rotateLeftBits
|
||||
<li><a class="reference" href="#rotateLeftBits%2CT%2Crange%5B%5D" title="rotateLeftBits[T: SomeUnsignedInt](value: T; shift: range[0 .. (sizeof(T) * 8)]): T">rotateLeftBits[T: SomeUnsignedInt](value: T; shift: range[0 .. (sizeof(T) * 8)]): T</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">rotateRightBits
|
||||
<li><a class="reference" href="#rotateRightBits%2CT%2Crange%5B%5D" title="rotateRightBits[T: SomeUnsignedInt](value: T; shift: range[0 .. (sizeof(T) * 8)]): T">rotateRightBits[T: SomeUnsignedInt](value: T; shift: range[0 .. (sizeof(T) * 8)]): T</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">setBit
|
||||
<li><a class="reference" href="#setBit%2CT%2CBitsRange%5BT%3A%20SomeInteger%5D" title="setBit[T: SomeInteger](v: var T; bit: BitsRange[T])">setBit[T: SomeInteger](v: var T; bit: BitsRange[T])</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">setMask
|
||||
<li><a class="reference" href="#setMask%2CT%2CT" title="setMask[T: SomeInteger](v: var T; mask: T)">setMask[T: SomeInteger](v: var T; mask: T)</a></li>
|
||||
<li><a class="reference" href="#setMask%2CT%2CSlice%5Bint%5D" title="setMask[T: SomeInteger](v: var T; slice: Slice[int])">setMask[T: SomeInteger](v: var T; slice: Slice[int])</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">setMasked
|
||||
<li><a class="reference" href="#setMasked%2CT%2CT" title="setMasked[T: SomeInteger](v, mask: T): T">setMasked[T: SomeInteger](v, mask: T): T</a></li>
|
||||
<li><a class="reference" href="#setMasked%2CT%2CSlice%5Bint%5D" title="setMasked[T: SomeInteger](v: T; slice: Slice[int]): T">setMasked[T: SomeInteger](v: T; slice: Slice[int]): T</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">testBit
|
||||
<li><a class="reference" href="#testBit%2CT%2CBitsRange%5BT%3A%20SomeInteger%5D" title="testBit[T: SomeInteger](v: T; bit: BitsRange[T]): bool">testBit[T: SomeInteger](v: T; bit: BitsRange[T]): bool</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">toMask
|
||||
<li><a class="reference" href="#toMask%2CSlice%5Bint%5D" title="toMask[T: SomeInteger](slice: Slice[int]): T">toMask[T: SomeInteger](slice: Slice[int]): T</a></li>
|
||||
|
||||
</ul>
|
||||
|
||||
</ul>
|
||||
</details>
|
||||
</li>
|
||||
<li>
|
||||
<details open>
|
||||
<summary><a class="reference reference-toplevel" href="#17" id="67">Macros</a></summary>
|
||||
<ul class="simple simple-toc-section">
|
||||
<ul class="simple nested-toc-section">bitand
|
||||
<li><a class="reference" href="#bitand.m%2CT%2CT%2Cvarargs%5BT%5D" title="bitand[T: SomeInteger](x, y: T; z: varargs[T]): T">bitand[T: SomeInteger](x, y: T; z: varargs[T]): T</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">bitor
|
||||
<li><a class="reference" href="#bitor.m%2CT%2CT%2Cvarargs%5BT%5D" title="bitor[T: SomeInteger](x, y: T; z: varargs[T]): T">bitor[T: SomeInteger](x, y: T; z: varargs[T]): T</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">bitxor
|
||||
<li><a class="reference" href="#bitxor.m%2CT%2CT%2Cvarargs%5BT%5D" title="bitxor[T: SomeInteger](x, y: T; z: varargs[T]): T">bitxor[T: SomeInteger](x, y: T; z: varargs[T]): T</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">clearBits
|
||||
<li><a class="reference" href="#clearBits.m%2Ctyped%2Cvarargs%5Btyped%5D" title="clearBits(v: typed; bits: varargs[typed]): untyped">clearBits(v: typed; bits: varargs[typed]): untyped</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">flipBits
|
||||
<li><a class="reference" href="#flipBits.m%2Ctyped%2Cvarargs%5Btyped%5D" title="flipBits(v: typed; bits: varargs[typed]): untyped">flipBits(v: typed; bits: varargs[typed]): untyped</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">setBits
|
||||
<li><a class="reference" href="#setBits.m%2Ctyped%2Cvarargs%5Btyped%5D" title="setBits(v: typed; bits: varargs[typed]): untyped">setBits(v: typed; bits: varargs[typed]): untyped</a></li>
|
||||
|
||||
</ul>
|
||||
|
||||
</ul>
|
||||
</details>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
<div class="nine columns" id="content">
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/bitops.nim#L1" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/bitops.nim#L1" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
<div id="tocRoot"></div>
|
||||
|
||||
<p class="module-desc"><p>This module implements a series of low level methods for bit manipulation.</p>
|
||||
<p>By default, compiler intrinsics are used where possible to improve performance on supported compilers: <tt class="docutils literal"><span class="pre"><span class="Identifier">GCC</span></span></tt>, <tt class="docutils literal"><span class="pre"><span class="Identifier">LLVM_GCC</span></span></tt>, <tt class="docutils literal"><span class="pre"><span class="Identifier">CLANG</span></span></tt>, <tt class="docutils literal"><span class="pre"><span class="Identifier">VCC</span></span></tt>, <tt class="docutils literal"><span class="pre"><span class="Identifier">ICC</span></span></tt>.</p>
|
||||
<p>The module will fallback to pure nim procs in case the backend is not supported. You can also use the flag <tt class="docutils literal"><span class="pre"><span class="Identifier">noIntrinsicsBitOpts</span></span></tt> to disable compiler intrinsics.</p>
|
||||
<p>This module is also compatible with other backends: <tt class="docutils literal"><span class="pre"><span class="Identifier">JavaScript</span></span></tt>, <tt class="docutils literal"><span class="pre"><span class="Identifier">NimScript</span></span></tt> as well as the <tt class="docutils literal"><span class="pre"><span class="Identifier">compiletime</span> <span class="Identifier">VM</span></span></tt>.</p>
|
||||
<p>As a result of using optimized functions/intrinsics, some functions can return undefined results if the input is invalid. You can use the flag <tt class="docutils literal"><span class="pre"><span class="Identifier">noUndefinedBitOpts</span></span></tt> to force predictable behaviour for all input, causing a small performance hit.</p>
|
||||
<p>At this time only <tt class="docutils literal"><span class="pre"><span class="Identifier">fastLog2</span></span></tt>, <tt class="docutils literal"><span class="pre"><span class="Identifier">firstSetBit</span></span></tt>, <tt class="docutils literal"><span class="pre"><span class="Identifier">countLeadingZeroBits</span></span></tt> and <tt class="docutils literal"><span class="pre"><span class="Identifier">countTrailingZeroBits</span></span></tt> may return undefined and/or platform dependent values if given invalid input.</p>
|
||||
</p>
|
||||
<div class="section" id="6">
|
||||
<h1><a class="toc-backref" href="#6">Imports</a></h1>
|
||||
<dl class="item">
|
||||
<a class="reference external" href="macros.html">macros</a>, <a class="reference external" href="since.html">since</a>, <a class="reference external" href="bitops_utils.html">bitops_utils</a>, <a class="reference external" href="countbits_impl.html">countbits_impl</a>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="section" id="7">
|
||||
<h1><a class="toc-backref" href="#7">Types</a></h1>
|
||||
<dl class="item">
|
||||
<div id="BitsRange">
|
||||
<dt><pre><a href="bitops.html#BitsRange"><span class="Identifier">BitsRange</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span> <span class="Other">=</span> <a href="system.html#range"><span class="Identifier">range</span></a><span class="Other">[</span><span class="DecNumber">0</span> <span class="Operator">..</span> <span class="Identifier">sizeof</span><span class="Other">(</span><span class="Identifier">T</span><span class="Other">)</span> <span class="Operator">*</span> <span class="DecNumber">8</span> <span class="Operator">-</span> <span class="DecNumber">1</span><span class="Other">]</span></pre></dt>
|
||||
<dd>
|
||||
|
||||
A range with all bit positions for type <tt class="docutils literal"><span class="pre"><span class="Identifier">T</span></span></tt>.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/bitops.nim#L63" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/bitops.nim#L63" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</dl>
|
||||
</div>
|
||||
<div class="section" id="12">
|
||||
<h1><a class="toc-backref" href="#12">Procs</a></h1>
|
||||
<dl class="item">
|
||||
<div id="bitnot-procs-all">
|
||||
<div id="bitnot,T">
|
||||
<dt><pre><span class="Keyword">func</span> <a href="#bitnot%2CT"><span class="Identifier">bitnot</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">:</span> <a href="system.html#SomeInteger"><span class="Identifier">SomeInteger</span></a><span class="Other">]</span><span class="Other">(</span><span class="Identifier">x</span><span class="Other">:</span> <span class="Identifier">T</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">T</span> {.<span class="Identifier">magic</span><span class="Other">:</span> <span class="StringLit">"BitnotI"</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
|
||||
<span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Computes the <tt class="docutils literal"><span class="pre"><span class="Identifier">bitwise</span> <span class="Identifier">complement</span></span></tt> of the integer <tt class="docutils literal"><span class="pre"><span class="Identifier">x</span></span></tt>.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/bitops.nim#L32" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/bitops.nim#L32" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="bitslice-procs-all">
|
||||
<div id="bitslice,T,Slice[int]">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#bitslice%2CT%2CSlice%5Bint%5D"><span class="Identifier">bitslice</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">:</span> <a href="system.html#SomeInteger"><span class="Identifier">SomeInteger</span></a><span class="Other">]</span><span class="Other">(</span><span class="Identifier">v</span><span class="Other">:</span> <span class="Keyword">var</span> <span class="Identifier">T</span><span class="Other">;</span> <span class="Identifier">slice</span><span class="Other">:</span> <a href="system.html#Slice"><span class="Identifier">Slice</span></a><span class="Other">[</span><a href="system.html#int"><span class="Identifier">int</span></a><span class="Other">]</span><span class="Other">)</span> {.<span class="Identifier">inline</span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Mutates <tt class="docutils literal"><span class="pre"><span class="Identifier">v</span></span></tt> into an extracted (and shifted) slice of bits from <tt class="docutils literal"><span class="pre"><span class="Identifier">v</span></span></tt>.
|
||||
<p><strong class="examples_text">Example:</strong></p>
|
||||
<pre class="listing"><span class="Keyword">var</span> <span class="Identifier">x</span> <span class="Operator">=</span> <span class="BinNumber">0b101110</span>
|
||||
<span class="Identifier">x</span><span class="Operator">.</span><span class="Identifier">bitslice</span><span class="Punctuation">(</span><span class="DecNumber">2</span> <span class="Operator">..</span> <span class="DecNumber">4</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">doAssert</span> <span class="Identifier">x</span> <span class="Operator">==</span> <span class="BinNumber">0b011</span></pre>
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/bitops.nim#L78" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/bitops.nim#L78" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="bitsliced-procs-all">
|
||||
<div id="bitsliced,T,Slice[int]">
|
||||
<dt><pre><span class="Keyword">func</span> <a href="#bitsliced%2CT%2CSlice%5Bint%5D"><span class="Identifier">bitsliced</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">:</span> <a href="system.html#SomeInteger"><span class="Identifier">SomeInteger</span></a><span class="Other">]</span><span class="Other">(</span><span class="Identifier">v</span><span class="Other">:</span> <span class="Identifier">T</span><span class="Other">;</span> <span class="Identifier">slice</span><span class="Other">:</span> <a href="system.html#Slice"><span class="Identifier">Slice</span></a><span class="Other">[</span><a href="system.html#int"><span class="Identifier">int</span></a><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">T</span> {.<span class="Identifier">inline</span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Returns an extracted (and shifted) slice of bits from <tt class="docutils literal"><span class="pre"><span class="Identifier">v</span></span></tt>.
|
||||
<p><strong class="examples_text">Example:</strong></p>
|
||||
<pre class="listing"><span class="Identifier">doAssert</span> <span class="BinNumber">0b10111</span><span class="Operator">.</span><span class="Identifier">bitsliced</span><span class="Punctuation">(</span><span class="DecNumber">2</span> <span class="Operator">..</span> <span class="DecNumber">4</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="BinNumber">0b101</span>
|
||||
<span class="Identifier">doAssert</span> <span class="BinNumber">0b11100</span><span class="Operator">.</span><span class="Identifier">bitsliced</span><span class="Punctuation">(</span><span class="DecNumber">0</span> <span class="Operator">..</span> <span class="DecNumber">2</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="BinNumber">0b100</span>
|
||||
<span class="Identifier">doAssert</span> <span class="BinNumber">0b11100</span><span class="Operator">.</span><span class="Identifier">bitsliced</span><span class="Punctuation">(</span><span class="DecNumber">0</span> <span class="Operator">..<</span> <span class="DecNumber">3</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="BinNumber">0b100</span></pre>
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/bitops.nim#L66" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/bitops.nim#L66" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="clearBit-procs-all">
|
||||
<div id="clearBit,T,BitsRange[T: SomeInteger]">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#clearBit%2CT%2CBitsRange%5BT%3A%20SomeInteger%5D"><span class="Identifier">clearBit</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">:</span> <a href="system.html#SomeInteger"><span class="Identifier">SomeInteger</span></a><span class="Other">]</span><span class="Other">(</span><span class="Identifier">v</span><span class="Other">:</span> <span class="Keyword">var</span> <span class="Identifier">T</span><span class="Other">;</span> <span class="Identifier">bit</span><span class="Other">:</span> <a href="bitops.html#BitsRange"><span class="Identifier">BitsRange</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">)</span> {.<span class="Identifier">inline</span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Mutates <tt class="docutils literal"><span class="pre"><span class="Identifier">v</span></span></tt>, with the bit at position <tt class="docutils literal"><span class="pre"><span class="Identifier">bit</span></span></tt> set to 0.
|
||||
<p><strong class="examples_text">Example:</strong></p>
|
||||
<pre class="listing"><span class="Keyword">var</span> <span class="Identifier">v</span> <span class="Operator">=</span> <span class="BinNumber">0b0000_0011'</span><span class="Identifier">u8</span>
|
||||
<span class="Identifier">v</span><span class="Operator">.</span><span class="Identifier">clearBit</span><span class="Punctuation">(</span><span class="DecNumber">1'</span><span class="Identifier">u8</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">doAssert</span> <span class="Identifier">v</span> <span class="Operator">==</span> <span class="BinNumber">0b0000_0001'</span><span class="Identifier">u8</span></pre>
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/bitops.nim#L286" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/bitops.nim#L286" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="clearMask-procs-all">
|
||||
<div id="clearMask,T,T">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#clearMask%2CT%2CT"><span class="Identifier">clearMask</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">:</span> <a href="system.html#SomeInteger"><span class="Identifier">SomeInteger</span></a><span class="Other">]</span><span class="Other">(</span><span class="Identifier">v</span><span class="Other">:</span> <span class="Keyword">var</span> <span class="Identifier">T</span><span class="Other">;</span> <span class="Identifier">mask</span><span class="Other">:</span> <span class="Identifier">T</span><span class="Other">)</span> {.<span class="Identifier">inline</span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Mutates <tt class="docutils literal"><span class="pre"><span class="Identifier">v</span></span></tt>, with all the <tt class="docutils literal"><span class="pre"><span class="DecNumber">1</span></span></tt> bits from <tt class="docutils literal"><span class="pre"><span class="Identifier">mask</span></span></tt> set to 0.</p>
|
||||
<p>Effectively maps to a <a class="reference external" href="#bitand.m,T,T,varargs[T]">bitand</a> operation with an <em>inverted mask</em>.</p>
|
||||
|
||||
<p><strong class="examples_text">Example:</strong></p>
|
||||
<pre class="listing"><span class="Keyword">var</span> <span class="Identifier">v</span> <span class="Operator">=</span> <span class="BinNumber">0b0000_0011'</span><span class="Identifier">u8</span>
|
||||
<span class="Identifier">v</span><span class="Operator">.</span><span class="Identifier">clearMask</span><span class="Punctuation">(</span><span class="BinNumber">0b0000_1010'</span><span class="Identifier">u8</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">doAssert</span> <span class="Identifier">v</span> <span class="Operator">==</span> <span class="BinNumber">0b0000_0001'</span><span class="Identifier">u8</span></pre>
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/bitops.nim#L211" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/bitops.nim#L211" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
<div id="clearMask,T,Slice[int]">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#clearMask%2CT%2CSlice%5Bint%5D"><span class="Identifier">clearMask</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">:</span> <a href="system.html#SomeInteger"><span class="Identifier">SomeInteger</span></a><span class="Other">]</span><span class="Other">(</span><span class="Identifier">v</span><span class="Other">:</span> <span class="Keyword">var</span> <span class="Identifier">T</span><span class="Other">;</span> <span class="Identifier">slice</span><span class="Other">:</span> <a href="system.html#Slice"><span class="Identifier">Slice</span></a><span class="Other">[</span><a href="system.html#int"><span class="Identifier">int</span></a><span class="Other">]</span><span class="Other">)</span> {.<span class="Identifier">inline</span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Mutates <tt class="docutils literal"><span class="pre"><span class="Identifier">v</span></span></tt>, with all the <tt class="docutils literal"><span class="pre"><span class="DecNumber">1</span></span></tt> bits in the range of <tt class="docutils literal"><span class="pre"><span class="Identifier">slice</span></span></tt> set to 0.</p>
|
||||
<p>Effectively maps to a <a class="reference external" href="#bitand.m,T,T,varargs[T]">bitand</a> operation with an <em>inverted mask</em>.</p>
|
||||
|
||||
<p><strong class="examples_text">Example:</strong></p>
|
||||
<pre class="listing"><span class="Keyword">var</span> <span class="Identifier">v</span> <span class="Operator">=</span> <span class="BinNumber">0b0000_0011'</span><span class="Identifier">u8</span>
|
||||
<span class="Identifier">v</span><span class="Operator">.</span><span class="Identifier">clearMask</span><span class="Punctuation">(</span><span class="DecNumber">1</span> <span class="Operator">..</span> <span class="DecNumber">3</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">doAssert</span> <span class="Identifier">v</span> <span class="Operator">==</span> <span class="BinNumber">0b0000_0001'</span><span class="Identifier">u8</span></pre>
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/bitops.nim#L223" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/bitops.nim#L223" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="clearMasked-procs-all">
|
||||
<div id="clearMasked,T,T">
|
||||
<dt><pre><span class="Keyword">func</span> <a href="#clearMasked%2CT%2CT"><span class="Identifier">clearMasked</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">:</span> <a href="system.html#SomeInteger"><span class="Identifier">SomeInteger</span></a><span class="Other">]</span><span class="Other">(</span><span class="Identifier">v</span><span class="Other">,</span> <span class="Identifier">mask</span><span class="Other">:</span> <span class="Identifier">T</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">T</span> {.<span class="Identifier">inline</span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Returns <tt class="docutils literal"><span class="pre"><span class="Identifier">v</span></span></tt>, with all the <tt class="docutils literal"><span class="pre"><span class="DecNumber">1</span></span></tt> bits from <tt class="docutils literal"><span class="pre"><span class="Identifier">mask</span></span></tt> set to 0.</p>
|
||||
<p>Effectively maps to a <a class="reference external" href="#bitand.m,T,T,varargs[T]">bitand</a> operation with an <em>inverted mask</em>.</p>
|
||||
|
||||
<p><strong class="examples_text">Example:</strong></p>
|
||||
<pre class="listing"><span class="Keyword">let</span> <span class="Identifier">v</span> <span class="Operator">=</span> <span class="BinNumber">0b0000_0011'</span><span class="Identifier">u8</span>
|
||||
<span class="Identifier">doAssert</span> <span class="Identifier">v</span><span class="Operator">.</span><span class="Identifier">clearMasked</span><span class="Punctuation">(</span><span class="BinNumber">0b0000_1010'</span><span class="Identifier">u8</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="BinNumber">0b0000_0001'</span><span class="Identifier">u8</span></pre>
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/bitops.nim#L189" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/bitops.nim#L189" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
<div id="clearMasked,T,Slice[int]">
|
||||
<dt><pre><span class="Keyword">func</span> <a href="#clearMasked%2CT%2CSlice%5Bint%5D"><span class="Identifier">clearMasked</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">:</span> <a href="system.html#SomeInteger"><span class="Identifier">SomeInteger</span></a><span class="Other">]</span><span class="Other">(</span><span class="Identifier">v</span><span class="Other">:</span> <span class="Identifier">T</span><span class="Other">;</span> <span class="Identifier">slice</span><span class="Other">:</span> <a href="system.html#Slice"><span class="Identifier">Slice</span></a><span class="Other">[</span><a href="system.html#int"><span class="Identifier">int</span></a><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">T</span> {.<span class="Identifier">inline</span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Returns <tt class="docutils literal"><span class="pre"><span class="Identifier">v</span></span></tt>, with all the <tt class="docutils literal"><span class="pre"><span class="DecNumber">1</span></span></tt> bits in the range of <tt class="docutils literal"><span class="pre"><span class="Identifier">slice</span></span></tt> set to 0.</p>
|
||||
<p>Effectively maps to a <a class="reference external" href="#bitand.m,T,T,varargs[T]">bitand</a> operation with an <em>inverted mask</em>.</p>
|
||||
|
||||
<p><strong class="examples_text">Example:</strong></p>
|
||||
<pre class="listing"><span class="Keyword">let</span> <span class="Identifier">v</span> <span class="Operator">=</span> <span class="BinNumber">0b0000_0011'</span><span class="Identifier">u8</span>
|
||||
<span class="Identifier">doAssert</span> <span class="Identifier">v</span><span class="Operator">.</span><span class="Identifier">clearMasked</span><span class="Punctuation">(</span><span class="DecNumber">1</span> <span class="Operator">..</span> <span class="DecNumber">3</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="BinNumber">0b0000_0001'</span><span class="Identifier">u8</span></pre>
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/bitops.nim#L200" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/bitops.nim#L200" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="countLeadingZeroBits-procs-all">
|
||||
<div id="countLeadingZeroBits,SomeInteger">
|
||||
<dt><pre><span class="Keyword">func</span> <a href="#countLeadingZeroBits%2CSomeInteger"><span class="Identifier">countLeadingZeroBits</span></a><span class="Other">(</span><span class="Identifier">x</span><span class="Other">:</span> <a href="system.html#SomeInteger"><span class="Identifier">SomeInteger</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a> {.<span class="Identifier">inline</span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Returns the number of leading zero bits in an integer. If <tt class="docutils literal"><span class="pre"><span class="Identifier">x</span></span></tt> is zero, when <tt class="docutils literal"><span class="pre"><span class="Identifier">noUndefinedBitOpts</span></span></tt> is set, the result is 0, otherwise the result is undefined.</p>
|
||||
<p><strong>See also:</strong></p>
|
||||
<ul class="simple"><li><a class="reference external" href="#countTrailingZeroBits,SomeInteger">countTrailingZeroBits proc</a></li>
|
||||
</ul>
|
||||
|
||||
<p><strong class="examples_text">Example:</strong></p>
|
||||
<pre class="listing"><span class="Identifier">doAssert</span> <span class="Identifier">countLeadingZeroBits</span><span class="Punctuation">(</span><span class="BinNumber">0b0000_0001'</span><span class="Identifier">u8</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">7</span>
|
||||
<span class="Identifier">doAssert</span> <span class="Identifier">countLeadingZeroBits</span><span class="Punctuation">(</span><span class="BinNumber">0b0000_0010'</span><span class="Identifier">u8</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">6</span>
|
||||
<span class="Identifier">doAssert</span> <span class="Identifier">countLeadingZeroBits</span><span class="Punctuation">(</span><span class="BinNumber">0b0000_0100'</span><span class="Identifier">u8</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">5</span>
|
||||
<span class="Identifier">doAssert</span> <span class="Identifier">countLeadingZeroBits</span><span class="Punctuation">(</span><span class="BinNumber">0b0000_1000'</span><span class="Identifier">u8</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">4</span>
|
||||
<span class="Identifier">doAssert</span> <span class="Identifier">countLeadingZeroBits</span><span class="Punctuation">(</span><span class="BinNumber">0b0000_1111'</span><span class="Identifier">u8</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">4</span></pre>
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/bitops.nim#L598" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/bitops.nim#L598" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="countSetBits-procs-all">
|
||||
<div id="countSetBits,SomeInteger">
|
||||
<dt><pre><span class="Keyword">func</span> <a href="#countSetBits%2CSomeInteger"><span class="Identifier">countSetBits</span></a><span class="Other">(</span><span class="Identifier">x</span><span class="Other">:</span> <a href="system.html#SomeInteger"><span class="Identifier">SomeInteger</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a> {.<span class="Identifier">inline</span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Counts the set bits in an integer (also called <span id="hamming-weight_1">Hamming weight</span>).
|
||||
<p><strong class="examples_text">Example:</strong></p>
|
||||
<pre class="listing"><span class="Identifier">doAssert</span> <span class="Identifier">countSetBits</span><span class="Punctuation">(</span><span class="BinNumber">0b0000_0011'</span><span class="Identifier">u8</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">2</span>
|
||||
<span class="Identifier">doAssert</span> <span class="Identifier">countSetBits</span><span class="Punctuation">(</span><span class="BinNumber">0b1010_1010'</span><span class="Identifier">u8</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">4</span></pre>
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/bitops.nim#L482" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/bitops.nim#L482" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="countTrailingZeroBits-procs-all">
|
||||
<div id="countTrailingZeroBits,SomeInteger">
|
||||
<dt><pre><span class="Keyword">func</span> <a href="#countTrailingZeroBits%2CSomeInteger"><span class="Identifier">countTrailingZeroBits</span></a><span class="Other">(</span><span class="Identifier">x</span><span class="Other">:</span> <a href="system.html#SomeInteger"><span class="Identifier">SomeInteger</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a> {.<span class="Identifier">inline</span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Returns the number of trailing zeros in an integer. If <tt class="docutils literal"><span class="pre"><span class="Identifier">x</span></span></tt> is zero, when <tt class="docutils literal"><span class="pre"><span class="Identifier">noUndefinedBitOpts</span></span></tt> is set, the result is 0, otherwise the result is undefined.</p>
|
||||
<p><strong>See also:</strong></p>
|
||||
<ul class="simple"><li><a class="reference external" href="#countLeadingZeroBits,SomeInteger">countLeadingZeroBits proc</a></li>
|
||||
</ul>
|
||||
|
||||
<p><strong class="examples_text">Example:</strong></p>
|
||||
<pre class="listing"><span class="Identifier">doAssert</span> <span class="Identifier">countTrailingZeroBits</span><span class="Punctuation">(</span><span class="BinNumber">0b0000_0001'</span><span class="Identifier">u8</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">0</span>
|
||||
<span class="Identifier">doAssert</span> <span class="Identifier">countTrailingZeroBits</span><span class="Punctuation">(</span><span class="BinNumber">0b0000_0010'</span><span class="Identifier">u8</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">1</span>
|
||||
<span class="Identifier">doAssert</span> <span class="Identifier">countTrailingZeroBits</span><span class="Punctuation">(</span><span class="BinNumber">0b0000_0100'</span><span class="Identifier">u8</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">2</span>
|
||||
<span class="Identifier">doAssert</span> <span class="Identifier">countTrailingZeroBits</span><span class="Punctuation">(</span><span class="BinNumber">0b0000_1000'</span><span class="Identifier">u8</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">3</span>
|
||||
<span class="Identifier">doAssert</span> <span class="Identifier">countTrailingZeroBits</span><span class="Punctuation">(</span><span class="BinNumber">0b0000_1111'</span><span class="Identifier">u8</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">0</span></pre>
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/bitops.nim#L626" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/bitops.nim#L626" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="fastLog2-procs-all">
|
||||
<div id="fastLog2,SomeInteger">
|
||||
<dt><pre><span class="Keyword">func</span> <a href="#fastLog2%2CSomeInteger"><span class="Identifier">fastLog2</span></a><span class="Other">(</span><span class="Identifier">x</span><span class="Other">:</span> <a href="system.html#SomeInteger"><span class="Identifier">SomeInteger</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a> {.<span class="Identifier">inline</span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Quickly find the log base 2 of an integer. If <tt class="docutils literal"><span class="pre"><span class="Identifier">x</span></span></tt> is zero, when <tt class="docutils literal"><span class="pre"><span class="Identifier">noUndefinedBitOpts</span></span></tt> is set, the result is -1, otherwise the result is undefined.
|
||||
<p><strong class="examples_text">Example:</strong></p>
|
||||
<pre class="listing"><span class="Identifier">doAssert</span> <span class="Identifier">fastLog2</span><span class="Punctuation">(</span><span class="BinNumber">0b0000_0001'</span><span class="Identifier">u8</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">0</span>
|
||||
<span class="Identifier">doAssert</span> <span class="Identifier">fastLog2</span><span class="Punctuation">(</span><span class="BinNumber">0b0000_0010'</span><span class="Identifier">u8</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">1</span>
|
||||
<span class="Identifier">doAssert</span> <span class="Identifier">fastLog2</span><span class="Punctuation">(</span><span class="BinNumber">0b0000_0100'</span><span class="Identifier">u8</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">2</span>
|
||||
<span class="Identifier">doAssert</span> <span class="Identifier">fastLog2</span><span class="Punctuation">(</span><span class="BinNumber">0b0000_1000'</span><span class="Identifier">u8</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">3</span>
|
||||
<span class="Identifier">doAssert</span> <span class="Identifier">fastLog2</span><span class="Punctuation">(</span><span class="BinNumber">0b0000_1111'</span><span class="Identifier">u8</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">3</span></pre>
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/bitops.nim#L559" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/bitops.nim#L559" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="firstSetBit-procs-all">
|
||||
<div id="firstSetBit,SomeInteger">
|
||||
<dt><pre><span class="Keyword">func</span> <a href="#firstSetBit%2CSomeInteger"><span class="Identifier">firstSetBit</span></a><span class="Other">(</span><span class="Identifier">x</span><span class="Other">:</span> <a href="system.html#SomeInteger"><span class="Identifier">SomeInteger</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a> {.<span class="Identifier">inline</span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Returns the 1-based index of the least significant set bit of <tt class="docutils literal"><span class="pre"><span class="Identifier">x</span></span></tt>. If <tt class="docutils literal"><span class="pre"><span class="Identifier">x</span></span></tt> is zero, when <tt class="docutils literal"><span class="pre"><span class="Identifier">noUndefinedBitOpts</span></span></tt> is set, the result is 0, otherwise the result is undefined.
|
||||
<p><strong class="examples_text">Example:</strong></p>
|
||||
<pre class="listing"><span class="Identifier">doAssert</span> <span class="Identifier">firstSetBit</span><span class="Punctuation">(</span><span class="BinNumber">0b0000_0001'</span><span class="Identifier">u8</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">1</span>
|
||||
<span class="Identifier">doAssert</span> <span class="Identifier">firstSetBit</span><span class="Punctuation">(</span><span class="BinNumber">0b0000_0010'</span><span class="Identifier">u8</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">2</span>
|
||||
<span class="Identifier">doAssert</span> <span class="Identifier">firstSetBit</span><span class="Punctuation">(</span><span class="BinNumber">0b0000_0100'</span><span class="Identifier">u8</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">3</span>
|
||||
<span class="Identifier">doAssert</span> <span class="Identifier">firstSetBit</span><span class="Punctuation">(</span><span class="BinNumber">0b0000_1000'</span><span class="Identifier">u8</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">4</span>
|
||||
<span class="Identifier">doAssert</span> <span class="Identifier">firstSetBit</span><span class="Punctuation">(</span><span class="BinNumber">0b0000_1111'</span><span class="Identifier">u8</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">1</span></pre>
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/bitops.nim#L516" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/bitops.nim#L516" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="flipBit-procs-all">
|
||||
<div id="flipBit,T,BitsRange[T: SomeInteger]">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#flipBit%2CT%2CBitsRange%5BT%3A%20SomeInteger%5D"><span class="Identifier">flipBit</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">:</span> <a href="system.html#SomeInteger"><span class="Identifier">SomeInteger</span></a><span class="Other">]</span><span class="Other">(</span><span class="Identifier">v</span><span class="Other">:</span> <span class="Keyword">var</span> <span class="Identifier">T</span><span class="Other">;</span> <span class="Identifier">bit</span><span class="Other">:</span> <a href="bitops.html#BitsRange"><span class="Identifier">BitsRange</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">)</span> {.<span class="Identifier">inline</span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Mutates <tt class="docutils literal"><span class="pre"><span class="Identifier">v</span></span></tt>, with the bit at position <tt class="docutils literal"><span class="pre"><span class="Identifier">bit</span></span></tt> flipped.
|
||||
<p><strong class="examples_text">Example:</strong></p>
|
||||
<pre class="listing"><span class="Keyword">var</span> <span class="Identifier">v</span> <span class="Operator">=</span> <span class="BinNumber">0b0000_0011'</span><span class="Identifier">u8</span>
|
||||
<span class="Identifier">v</span><span class="Operator">.</span><span class="Identifier">flipBit</span><span class="Punctuation">(</span><span class="DecNumber">1'</span><span class="Identifier">u8</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">doAssert</span> <span class="Identifier">v</span> <span class="Operator">==</span> <span class="BinNumber">0b0000_0001'</span><span class="Identifier">u8</span>
|
||||
|
||||
<span class="Identifier">v</span> <span class="Operator">=</span> <span class="BinNumber">0b0000_0011'</span><span class="Identifier">u8</span>
|
||||
<span class="Identifier">v</span><span class="Operator">.</span><span class="Identifier">flipBit</span><span class="Punctuation">(</span><span class="DecNumber">2'</span><span class="Identifier">u8</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">doAssert</span> <span class="Identifier">v</span> <span class="Operator">==</span> <span class="BinNumber">0b0000_0111'</span><span class="Identifier">u8</span></pre>
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/bitops.nim#L295" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/bitops.nim#L295" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="flipMask-procs-all">
|
||||
<div id="flipMask,T,T">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#flipMask%2CT%2CT"><span class="Identifier">flipMask</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">:</span> <a href="system.html#SomeInteger"><span class="Identifier">SomeInteger</span></a><span class="Other">]</span><span class="Other">(</span><span class="Identifier">v</span><span class="Other">:</span> <span class="Keyword">var</span> <span class="Identifier">T</span><span class="Other">;</span> <span class="Identifier">mask</span><span class="Other">:</span> <span class="Identifier">T</span><span class="Other">)</span> {.<span class="Identifier">inline</span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Mutates <tt class="docutils literal"><span class="pre"><span class="Identifier">v</span></span></tt>, with all the <tt class="docutils literal"><span class="pre"><span class="DecNumber">1</span></span></tt> bits from <tt class="docutils literal"><span class="pre"><span class="Identifier">mask</span></span></tt> flipped.</p>
|
||||
<p>Effectively maps to a <a class="reference external" href="#bitxor.m,T,T,varargs[T]">bitxor</a> operation.</p>
|
||||
|
||||
<p><strong class="examples_text">Example:</strong></p>
|
||||
<pre class="listing"><span class="Keyword">var</span> <span class="Identifier">v</span> <span class="Operator">=</span> <span class="BinNumber">0b0000_0011'</span><span class="Identifier">u8</span>
|
||||
<span class="Identifier">v</span><span class="Operator">.</span><span class="Identifier">flipMask</span><span class="Punctuation">(</span><span class="BinNumber">0b0000_1010'</span><span class="Identifier">u8</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">doAssert</span> <span class="Identifier">v</span> <span class="Operator">==</span> <span class="BinNumber">0b0000_1001'</span><span class="Identifier">u8</span></pre>
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/bitops.nim#L255" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/bitops.nim#L255" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
<div id="flipMask,T,Slice[int]">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#flipMask%2CT%2CSlice%5Bint%5D"><span class="Identifier">flipMask</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">:</span> <a href="system.html#SomeInteger"><span class="Identifier">SomeInteger</span></a><span class="Other">]</span><span class="Other">(</span><span class="Identifier">v</span><span class="Other">:</span> <span class="Keyword">var</span> <span class="Identifier">T</span><span class="Other">;</span> <span class="Identifier">slice</span><span class="Other">:</span> <a href="system.html#Slice"><span class="Identifier">Slice</span></a><span class="Other">[</span><a href="system.html#int"><span class="Identifier">int</span></a><span class="Other">]</span><span class="Other">)</span> {.<span class="Identifier">inline</span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Mutates <tt class="docutils literal"><span class="pre"><span class="Identifier">v</span></span></tt>, with all the <tt class="docutils literal"><span class="pre"><span class="DecNumber">1</span></span></tt> bits in the range of <tt class="docutils literal"><span class="pre"><span class="Identifier">slice</span></span></tt> flipped.</p>
|
||||
<p>Effectively maps to a <a class="reference external" href="#bitxor.m,T,T,varargs[T]">bitxor</a> operation.</p>
|
||||
|
||||
<p><strong class="examples_text">Example:</strong></p>
|
||||
<pre class="listing"><span class="Keyword">var</span> <span class="Identifier">v</span> <span class="Operator">=</span> <span class="BinNumber">0b0000_0011'</span><span class="Identifier">u8</span>
|
||||
<span class="Identifier">v</span><span class="Operator">.</span><span class="Identifier">flipMask</span><span class="Punctuation">(</span><span class="DecNumber">1</span> <span class="Operator">..</span> <span class="DecNumber">3</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">doAssert</span> <span class="Identifier">v</span> <span class="Operator">==</span> <span class="BinNumber">0b0000_1101'</span><span class="Identifier">u8</span></pre>
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/bitops.nim#L266" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/bitops.nim#L266" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="flipMasked-procs-all">
|
||||
<div id="flipMasked,T,T">
|
||||
<dt><pre><span class="Keyword">func</span> <a href="#flipMasked%2CT%2CT"><span class="Identifier">flipMasked</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">:</span> <a href="system.html#SomeInteger"><span class="Identifier">SomeInteger</span></a><span class="Other">]</span><span class="Other">(</span><span class="Identifier">v</span><span class="Other">,</span> <span class="Identifier">mask</span><span class="Other">:</span> <span class="Identifier">T</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">T</span> {.<span class="Identifier">inline</span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Returns <tt class="docutils literal"><span class="pre"><span class="Identifier">v</span></span></tt>, with all the <tt class="docutils literal"><span class="pre"><span class="DecNumber">1</span></span></tt> bits from <tt class="docutils literal"><span class="pre"><span class="Identifier">mask</span></span></tt> flipped.</p>
|
||||
<p>Effectively maps to a <a class="reference external" href="#bitxor.m,T,T,varargs[T]">bitxor</a> operation.</p>
|
||||
|
||||
<p><strong class="examples_text">Example:</strong></p>
|
||||
<pre class="listing"><span class="Keyword">let</span> <span class="Identifier">v</span> <span class="Operator">=</span> <span class="BinNumber">0b0000_0011'</span><span class="Identifier">u8</span>
|
||||
<span class="Identifier">doAssert</span> <span class="Identifier">v</span><span class="Operator">.</span><span class="Identifier">flipMasked</span><span class="Punctuation">(</span><span class="BinNumber">0b0000_1010'</span><span class="Identifier">u8</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="BinNumber">0b0000_1001'</span><span class="Identifier">u8</span></pre>
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/bitops.nim#L235" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/bitops.nim#L235" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
<div id="flipMasked,T,Slice[int]">
|
||||
<dt><pre><span class="Keyword">func</span> <a href="#flipMasked%2CT%2CSlice%5Bint%5D"><span class="Identifier">flipMasked</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">:</span> <a href="system.html#SomeInteger"><span class="Identifier">SomeInteger</span></a><span class="Other">]</span><span class="Other">(</span><span class="Identifier">v</span><span class="Other">:</span> <span class="Identifier">T</span><span class="Other">;</span> <span class="Identifier">slice</span><span class="Other">:</span> <a href="system.html#Slice"><span class="Identifier">Slice</span></a><span class="Other">[</span><a href="system.html#int"><span class="Identifier">int</span></a><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">T</span> {.<span class="Identifier">inline</span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Returns <tt class="docutils literal"><span class="pre"><span class="Identifier">v</span></span></tt>, with all the <tt class="docutils literal"><span class="pre"><span class="DecNumber">1</span></span></tt> bits in the range of <tt class="docutils literal"><span class="pre"><span class="Identifier">slice</span></span></tt> flipped.</p>
|
||||
<p>Effectively maps to a <a class="reference external" href="#bitxor.m,T,T,varargs[T]">bitxor</a> operation.</p>
|
||||
|
||||
<p><strong class="examples_text">Example:</strong></p>
|
||||
<pre class="listing"><span class="Keyword">let</span> <span class="Identifier">v</span> <span class="Operator">=</span> <span class="BinNumber">0b0000_0011'</span><span class="Identifier">u8</span>
|
||||
<span class="Identifier">doAssert</span> <span class="Identifier">v</span><span class="Operator">.</span><span class="Identifier">flipMasked</span><span class="Punctuation">(</span><span class="DecNumber">1</span> <span class="Operator">..</span> <span class="DecNumber">3</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="BinNumber">0b0000_1101'</span><span class="Identifier">u8</span></pre>
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/bitops.nim#L245" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/bitops.nim#L245" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="mask-procs-all">
|
||||
<div id="mask,T,T">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#mask%2CT%2CT"><span class="Identifier">mask</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">:</span> <a href="system.html#SomeInteger"><span class="Identifier">SomeInteger</span></a><span class="Other">]</span><span class="Other">(</span><span class="Identifier">v</span><span class="Other">:</span> <span class="Keyword">var</span> <span class="Identifier">T</span><span class="Other">;</span> <span class="Identifier">mask</span><span class="Other">:</span> <span class="Identifier">T</span><span class="Other">)</span> {.<span class="Identifier">inline</span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Mutates <tt class="docutils literal"><span class="pre"><span class="Identifier">v</span></span></tt>, with only the <tt class="docutils literal"><span class="pre"><span class="DecNumber">1</span></span></tt> bits from <tt class="docutils literal"><span class="pre"><span class="Identifier">mask</span></span></tt> matching those of <tt class="docutils literal"><span class="pre"><span class="Identifier">v</span></span></tt> set to 1.</p>
|
||||
<p>Effectively maps to a <a class="reference external" href="#bitand.m,T,T,varargs[T]">bitand</a> operation.</p>
|
||||
|
||||
<p><strong class="examples_text">Example:</strong></p>
|
||||
<pre class="listing"><span class="Keyword">var</span> <span class="Identifier">v</span> <span class="Operator">=</span> <span class="BinNumber">0b0000_0011'</span><span class="Identifier">u8</span>
|
||||
<span class="Identifier">v</span><span class="Operator">.</span><span class="Identifier">mask</span><span class="Punctuation">(</span><span class="BinNumber">0b0000_1010'</span><span class="Identifier">u8</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">doAssert</span> <span class="Identifier">v</span> <span class="Operator">==</span> <span class="BinNumber">0b0000_0010'</span><span class="Identifier">u8</span></pre>
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/bitops.nim#L123" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/bitops.nim#L123" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
<div id="mask,T,Slice[int]">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#mask%2CT%2CSlice%5Bint%5D"><span class="Identifier">mask</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">:</span> <a href="system.html#SomeInteger"><span class="Identifier">SomeInteger</span></a><span class="Other">]</span><span class="Other">(</span><span class="Identifier">v</span><span class="Other">:</span> <span class="Keyword">var</span> <span class="Identifier">T</span><span class="Other">;</span> <span class="Identifier">slice</span><span class="Other">:</span> <a href="system.html#Slice"><span class="Identifier">Slice</span></a><span class="Other">[</span><a href="system.html#int"><span class="Identifier">int</span></a><span class="Other">]</span><span class="Other">)</span> {.<span class="Identifier">inline</span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Mutates <tt class="docutils literal"><span class="pre"><span class="Identifier">v</span></span></tt>, with only the <tt class="docutils literal"><span class="pre"><span class="DecNumber">1</span></span></tt> bits in the range of <tt class="docutils literal"><span class="pre"><span class="Identifier">slice</span></span></tt> matching those of <tt class="docutils literal"><span class="pre"><span class="Identifier">v</span></span></tt> set to 1.</p>
|
||||
<p>Effectively maps to a <a class="reference external" href="#bitand.m,T,T,varargs[T]">bitand</a> operation.</p>
|
||||
|
||||
<p><strong class="examples_text">Example:</strong></p>
|
||||
<pre class="listing"><span class="Keyword">var</span> <span class="Identifier">v</span> <span class="Operator">=</span> <span class="BinNumber">0b0000_1011'</span><span class="Identifier">u8</span>
|
||||
<span class="Identifier">v</span><span class="Operator">.</span><span class="Identifier">mask</span><span class="Punctuation">(</span><span class="DecNumber">1</span> <span class="Operator">..</span> <span class="DecNumber">3</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">doAssert</span> <span class="Identifier">v</span> <span class="Operator">==</span> <span class="BinNumber">0b0000_1010'</span><span class="Identifier">u8</span></pre>
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/bitops.nim#L135" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/bitops.nim#L135" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="masked-procs-all">
|
||||
<div id="masked,T,T">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#masked%2CT%2CT"><span class="Identifier">masked</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">:</span> <a href="system.html#SomeInteger"><span class="Identifier">SomeInteger</span></a><span class="Other">]</span><span class="Other">(</span><span class="Identifier">v</span><span class="Other">,</span> <span class="Identifier">mask</span><span class="Other">:</span> <span class="Identifier">T</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">T</span> {.<span class="Identifier">inline</span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Returns <tt class="docutils literal"><span class="pre"><span class="Identifier">v</span></span></tt>, with only the <tt class="docutils literal"><span class="pre"><span class="DecNumber">1</span></span></tt> bits from <tt class="docutils literal"><span class="pre"><span class="Identifier">mask</span></span></tt> matching those of <tt class="docutils literal"><span class="pre"><span class="Identifier">v</span></span></tt> set to 1.</p>
|
||||
<p>Effectively maps to a <a class="reference external" href="#bitand.m,T,T,varargs[T]">bitand</a> operation.</p>
|
||||
|
||||
<p><strong class="examples_text">Example:</strong></p>
|
||||
<pre class="listing"><span class="Keyword">let</span> <span class="Identifier">v</span> <span class="Operator">=</span> <span class="BinNumber">0b0000_0011'</span><span class="Identifier">u8</span>
|
||||
<span class="Identifier">doAssert</span> <span class="Identifier">v</span><span class="Operator">.</span><span class="Identifier">masked</span><span class="Punctuation">(</span><span class="BinNumber">0b0000_1010'</span><span class="Identifier">u8</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="BinNumber">0b0000_0010'</span><span class="Identifier">u8</span></pre>
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/bitops.nim#L101" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/bitops.nim#L101" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
<div id="masked,T,Slice[int]">
|
||||
<dt><pre><span class="Keyword">func</span> <a href="#masked%2CT%2CSlice%5Bint%5D"><span class="Identifier">masked</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">:</span> <a href="system.html#SomeInteger"><span class="Identifier">SomeInteger</span></a><span class="Other">]</span><span class="Other">(</span><span class="Identifier">v</span><span class="Other">:</span> <span class="Identifier">T</span><span class="Other">;</span> <span class="Identifier">slice</span><span class="Other">:</span> <a href="system.html#Slice"><span class="Identifier">Slice</span></a><span class="Other">[</span><a href="system.html#int"><span class="Identifier">int</span></a><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">T</span> {.<span class="Identifier">inline</span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Returns <tt class="docutils literal"><span class="pre"><span class="Identifier">v</span></span></tt>, with only the <tt class="docutils literal"><span class="pre"><span class="DecNumber">1</span></span></tt> bits in the range of <tt class="docutils literal"><span class="pre"><span class="Identifier">slice</span></span></tt> matching those of <tt class="docutils literal"><span class="pre"><span class="Identifier">v</span></span></tt> set to 1.</p>
|
||||
<p>Effectively maps to a <a class="reference external" href="#bitand.m,T,T,varargs[T]">bitand</a> operation.</p>
|
||||
|
||||
<p><strong class="examples_text">Example:</strong></p>
|
||||
<pre class="listing"><span class="Keyword">let</span> <span class="Identifier">v</span> <span class="Operator">=</span> <span class="BinNumber">0b0000_1011'</span><span class="Identifier">u8</span>
|
||||
<span class="Identifier">doAssert</span> <span class="Identifier">v</span><span class="Operator">.</span><span class="Identifier">masked</span><span class="Punctuation">(</span><span class="DecNumber">1</span> <span class="Operator">..</span> <span class="DecNumber">3</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="BinNumber">0b0000_1010'</span><span class="Identifier">u8</span></pre>
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/bitops.nim#L112" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/bitops.nim#L112" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="parityBits-procs-all">
|
||||
<div id="parityBits,SomeInteger">
|
||||
<dt><pre><span class="Keyword">func</span> <a href="#parityBits%2CSomeInteger"><span class="Identifier">parityBits</span></a><span class="Other">(</span><span class="Identifier">x</span><span class="Other">:</span> <a href="system.html#SomeInteger"><span class="Identifier">SomeInteger</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a> {.<span class="Identifier">inline</span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Calculate the bit parity in an integer. If the number of 1-bits is odd, the parity is 1, otherwise 0.
|
||||
<p><strong class="examples_text">Example:</strong></p>
|
||||
<pre class="listing"><span class="Identifier">doAssert</span> <span class="Identifier">parityBits</span><span class="Punctuation">(</span><span class="BinNumber">0b0000_0000'</span><span class="Identifier">u8</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">0</span>
|
||||
<span class="Identifier">doAssert</span> <span class="Identifier">parityBits</span><span class="Punctuation">(</span><span class="BinNumber">0b0101_0001'</span><span class="Identifier">u8</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">1</span>
|
||||
<span class="Identifier">doAssert</span> <span class="Identifier">parityBits</span><span class="Punctuation">(</span><span class="BinNumber">0b0110_1001'</span><span class="Identifier">u8</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">0</span>
|
||||
<span class="Identifier">doAssert</span> <span class="Identifier">parityBits</span><span class="Punctuation">(</span><span class="BinNumber">0b0111_1111'</span><span class="Identifier">u8</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="DecNumber">1</span></pre>
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/bitops.nim#L494" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/bitops.nim#L494" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="popcount-procs-all">
|
||||
<div id="popcount,SomeInteger">
|
||||
<dt><pre><span class="Keyword">func</span> <a href="#popcount%2CSomeInteger"><span class="Identifier">popcount</span></a><span class="Other">(</span><span class="Identifier">x</span><span class="Other">:</span> <a href="system.html#SomeInteger"><span class="Identifier">SomeInteger</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a> {.<span class="Identifier">inline</span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Alias for <a class="reference external" href="#countSetBits,SomeInteger">countSetBits</a> (Hamming weight).
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/bitops.nim#L490" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/bitops.nim#L490" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="reverseBits-procs-all">
|
||||
<div id="reverseBits,T">
|
||||
<dt><pre><span class="Keyword">func</span> <a href="#reverseBits%2CT"><span class="Identifier">reverseBits</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">:</span> <a href="system.html#SomeUnsignedInt"><span class="Identifier">SomeUnsignedInt</span></a><span class="Other">]</span><span class="Other">(</span><span class="Identifier">x</span><span class="Other">:</span> <span class="Identifier">T</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">T</span></pre></dt>
|
||||
<dd>
|
||||
|
||||
Return the bit reversal of x.
|
||||
<p><strong class="examples_text">Example:</strong></p>
|
||||
<pre class="listing"><span class="Identifier">doAssert</span> <span class="Identifier">reverseBits</span><span class="Punctuation">(</span><span class="BinNumber">0b10100100'</span><span class="Identifier">u8</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="BinNumber">0b00100101'</span><span class="Identifier">u8</span>
|
||||
<span class="Identifier">doAssert</span> <span class="Identifier">reverseBits</span><span class="Punctuation">(</span><span class="HexNumber">0xdd'</span><span class="Identifier">u8</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="HexNumber">0xbb'</span><span class="Identifier">u8</span>
|
||||
<span class="Identifier">doAssert</span> <span class="Identifier">reverseBits</span><span class="Punctuation">(</span><span class="HexNumber">0xddbb'</span><span class="Identifier">u16</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="HexNumber">0xddbb'</span><span class="Identifier">u16</span>
|
||||
<span class="Identifier">doAssert</span> <span class="Identifier">reverseBits</span><span class="Punctuation">(</span><span class="HexNumber">0xdeadbeef'</span><span class="Identifier">u32</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="HexNumber">0xf77db57b'</span><span class="Identifier">u32</span></pre>
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/bitops.nim#L842" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/bitops.nim#L842" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="rotateLeftBits-procs-all">
|
||||
<div id="rotateLeftBits,T,range[]">
|
||||
<dt><pre><span class="Keyword">func</span> <a href="#rotateLeftBits%2CT%2Crange%5B%5D"><span class="Identifier">rotateLeftBits</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">:</span> <a href="system.html#SomeUnsignedInt"><span class="Identifier">SomeUnsignedInt</span></a><span class="Other">]</span><span class="Other">(</span><span class="Identifier">value</span><span class="Other">:</span> <span class="Identifier">T</span><span class="Other">;</span>
|
||||
<span class="Identifier">shift</span><span class="Other">:</span> <a href="system.html#range"><span class="Identifier">range</span></a><span class="Other">[</span><span class="DecNumber">0</span> <span class="Operator">..</span> <span class="Other">(</span><span class="Identifier">sizeof</span><span class="Other">(</span><span class="Identifier">T</span><span class="Other">)</span> <span class="Operator">*</span> <span class="DecNumber">8</span><span class="Other">)</span><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">T</span> {.
|
||||
<span class="Identifier">inline</span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Left-rotate bits in a <tt class="docutils literal"><span class="pre"><span class="Identifier">value</span></span></tt>.
|
||||
<p><strong class="examples_text">Example:</strong></p>
|
||||
<pre class="listing"><span class="Identifier">doAssert</span> <span class="Identifier">rotateLeftBits</span><span class="Punctuation">(</span><span class="BinNumber">0b0110_1001'</span><span class="Identifier">u8</span><span class="Punctuation">,</span> <span class="DecNumber">4</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="BinNumber">0b1001_0110'</span><span class="Identifier">u8</span>
|
||||
<span class="Identifier">doAssert</span> <span class="Identifier">rotateLeftBits</span><span class="Punctuation">(</span><span class="BinNumber">0b00111100_11000011'</span><span class="Identifier">u16</span><span class="Punctuation">,</span> <span class="DecNumber">8</span><span class="Punctuation">)</span> <span class="Operator">==</span>
|
||||
<span class="BinNumber">0b11000011_00111100'</span><span class="Identifier">u16</span>
|
||||
<span class="Identifier">doAssert</span> <span class="Identifier">rotateLeftBits</span><span class="Punctuation">(</span><span class="BinNumber">0b0000111111110000_1111000000001111'</span><span class="Identifier">u32</span><span class="Punctuation">,</span> <span class="DecNumber">16</span><span class="Punctuation">)</span> <span class="Operator">==</span>
|
||||
<span class="BinNumber">0b1111000000001111_0000111111110000'</span><span class="Identifier">u32</span>
|
||||
<span class="Identifier">doAssert</span> <span class="Identifier">rotateLeftBits</span><span class="Punctuation">(</span><span class="BinNumber">0b00000000111111111111111100000000_11111111000000000000000011111111'</span><span class="Identifier">u64</span><span class="Punctuation">,</span> <span class="DecNumber">32</span><span class="Punctuation">)</span> <span class="Operator">==</span>
|
||||
<span class="BinNumber">0b11111111000000000000000011111111_00000000111111111111111100000000'</span><span class="Identifier">u64</span></pre>
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/bitops.nim#L779" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/bitops.nim#L779" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="rotateRightBits-procs-all">
|
||||
<div id="rotateRightBits,T,range[]">
|
||||
<dt><pre><span class="Keyword">func</span> <a href="#rotateRightBits%2CT%2Crange%5B%5D"><span class="Identifier">rotateRightBits</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">:</span> <a href="system.html#SomeUnsignedInt"><span class="Identifier">SomeUnsignedInt</span></a><span class="Other">]</span><span class="Other">(</span><span class="Identifier">value</span><span class="Other">:</span> <span class="Identifier">T</span><span class="Other">;</span>
|
||||
<span class="Identifier">shift</span><span class="Other">:</span> <a href="system.html#range"><span class="Identifier">range</span></a><span class="Other">[</span><span class="DecNumber">0</span> <span class="Operator">..</span> <span class="Other">(</span><span class="Identifier">sizeof</span><span class="Other">(</span><span class="Identifier">T</span><span class="Other">)</span> <span class="Operator">*</span> <span class="DecNumber">8</span><span class="Other">)</span><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">T</span> {.<span class="Identifier">inline</span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Right-rotate bits in a <tt class="docutils literal"><span class="pre"><span class="Identifier">value</span></span></tt>.
|
||||
<p><strong class="examples_text">Example:</strong></p>
|
||||
<pre class="listing"><span class="Identifier">doAssert</span> <span class="Identifier">rotateRightBits</span><span class="Punctuation">(</span><span class="BinNumber">0b0110_1001'</span><span class="Identifier">u8</span><span class="Punctuation">,</span> <span class="DecNumber">4</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="BinNumber">0b1001_0110'</span><span class="Identifier">u8</span>
|
||||
<span class="Identifier">doAssert</span> <span class="Identifier">rotateRightBits</span><span class="Punctuation">(</span><span class="BinNumber">0b00111100_11000011'</span><span class="Identifier">u16</span><span class="Punctuation">,</span> <span class="DecNumber">8</span><span class="Punctuation">)</span> <span class="Operator">==</span>
|
||||
<span class="BinNumber">0b11000011_00111100'</span><span class="Identifier">u16</span>
|
||||
<span class="Identifier">doAssert</span> <span class="Identifier">rotateRightBits</span><span class="Punctuation">(</span><span class="BinNumber">0b0000111111110000_1111000000001111'</span><span class="Identifier">u32</span><span class="Punctuation">,</span> <span class="DecNumber">16</span><span class="Punctuation">)</span> <span class="Operator">==</span>
|
||||
<span class="BinNumber">0b1111000000001111_0000111111110000'</span><span class="Identifier">u32</span>
|
||||
<span class="Identifier">doAssert</span> <span class="Identifier">rotateRightBits</span><span class="Punctuation">(</span><span class="BinNumber">0b00000000111111111111111100000000_11111111000000000000000011111111'</span><span class="Identifier">u64</span><span class="Punctuation">,</span> <span class="DecNumber">32</span><span class="Punctuation">)</span> <span class="Operator">==</span>
|
||||
<span class="BinNumber">0b11111111000000000000000011111111_00000000111111111111111100000000'</span><span class="Identifier">u64</span></pre>
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/bitops.nim#L807" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/bitops.nim#L807" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="setBit-procs-all">
|
||||
<div id="setBit,T,BitsRange[T: SomeInteger]">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#setBit%2CT%2CBitsRange%5BT%3A%20SomeInteger%5D"><span class="Identifier">setBit</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">:</span> <a href="system.html#SomeInteger"><span class="Identifier">SomeInteger</span></a><span class="Other">]</span><span class="Other">(</span><span class="Identifier">v</span><span class="Other">:</span> <span class="Keyword">var</span> <span class="Identifier">T</span><span class="Other">;</span> <span class="Identifier">bit</span><span class="Other">:</span> <a href="bitops.html#BitsRange"><span class="Identifier">BitsRange</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">)</span> {.<span class="Identifier">inline</span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Mutates <tt class="docutils literal"><span class="pre"><span class="Identifier">v</span></span></tt>, with the bit at position <tt class="docutils literal"><span class="pre"><span class="Identifier">bit</span></span></tt> set to 1.
|
||||
<p><strong class="examples_text">Example:</strong></p>
|
||||
<pre class="listing"><span class="Keyword">var</span> <span class="Identifier">v</span> <span class="Operator">=</span> <span class="BinNumber">0b0000_0011'</span><span class="Identifier">u8</span>
|
||||
<span class="Identifier">v</span><span class="Operator">.</span><span class="Identifier">setBit</span><span class="Punctuation">(</span><span class="DecNumber">5'</span><span class="Identifier">u8</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">doAssert</span> <span class="Identifier">v</span> <span class="Operator">==</span> <span class="BinNumber">0b0010_0011'</span><span class="Identifier">u8</span></pre>
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/bitops.nim#L277" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/bitops.nim#L277" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="setMask-procs-all">
|
||||
<div id="setMask,T,T">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#setMask%2CT%2CT"><span class="Identifier">setMask</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">:</span> <a href="system.html#SomeInteger"><span class="Identifier">SomeInteger</span></a><span class="Other">]</span><span class="Other">(</span><span class="Identifier">v</span><span class="Other">:</span> <span class="Keyword">var</span> <span class="Identifier">T</span><span class="Other">;</span> <span class="Identifier">mask</span><span class="Other">:</span> <span class="Identifier">T</span><span class="Other">)</span> {.<span class="Identifier">inline</span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Mutates <tt class="docutils literal"><span class="pre"><span class="Identifier">v</span></span></tt>, with all the <tt class="docutils literal"><span class="pre"><span class="DecNumber">1</span></span></tt> bits from <tt class="docutils literal"><span class="pre"><span class="Identifier">mask</span></span></tt> set to 1.</p>
|
||||
<p>Effectively maps to a <a class="reference external" href="#bitor.m,T,T,varargs[T]">bitor</a> operation.</p>
|
||||
|
||||
<p><strong class="examples_text">Example:</strong></p>
|
||||
<pre class="listing"><span class="Keyword">var</span> <span class="Identifier">v</span> <span class="Operator">=</span> <span class="BinNumber">0b0000_0011'</span><span class="Identifier">u8</span>
|
||||
<span class="Identifier">v</span><span class="Operator">.</span><span class="Identifier">setMask</span><span class="Punctuation">(</span><span class="BinNumber">0b0000_1010'</span><span class="Identifier">u8</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">doAssert</span> <span class="Identifier">v</span> <span class="Operator">==</span> <span class="BinNumber">0b0000_1011'</span><span class="Identifier">u8</span></pre>
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/bitops.nim#L167" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/bitops.nim#L167" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
<div id="setMask,T,Slice[int]">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#setMask%2CT%2CSlice%5Bint%5D"><span class="Identifier">setMask</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">:</span> <a href="system.html#SomeInteger"><span class="Identifier">SomeInteger</span></a><span class="Other">]</span><span class="Other">(</span><span class="Identifier">v</span><span class="Other">:</span> <span class="Keyword">var</span> <span class="Identifier">T</span><span class="Other">;</span> <span class="Identifier">slice</span><span class="Other">:</span> <a href="system.html#Slice"><span class="Identifier">Slice</span></a><span class="Other">[</span><a href="system.html#int"><span class="Identifier">int</span></a><span class="Other">]</span><span class="Other">)</span> {.<span class="Identifier">inline</span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Mutates <tt class="docutils literal"><span class="pre"><span class="Identifier">v</span></span></tt>, with all the <tt class="docutils literal"><span class="pre"><span class="DecNumber">1</span></span></tt> bits in the range of <tt class="docutils literal"><span class="pre"><span class="Identifier">slice</span></span></tt> set to 1.</p>
|
||||
<p>Effectively maps to a <a class="reference external" href="#bitor.m,T,T,varargs[T]">bitor</a> operation.</p>
|
||||
|
||||
<p><strong class="examples_text">Example:</strong></p>
|
||||
<pre class="listing"><span class="Keyword">var</span> <span class="Identifier">v</span> <span class="Operator">=</span> <span class="BinNumber">0b0000_0011'</span><span class="Identifier">u8</span>
|
||||
<span class="Identifier">v</span><span class="Operator">.</span><span class="Identifier">setMask</span><span class="Punctuation">(</span><span class="DecNumber">2</span> <span class="Operator">..</span> <span class="DecNumber">3</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">doAssert</span> <span class="Identifier">v</span> <span class="Operator">==</span> <span class="BinNumber">0b0000_1111'</span><span class="Identifier">u8</span></pre>
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/bitops.nim#L178" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/bitops.nim#L178" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="setMasked-procs-all">
|
||||
<div id="setMasked,T,T">
|
||||
<dt><pre><span class="Keyword">func</span> <a href="#setMasked%2CT%2CT"><span class="Identifier">setMasked</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">:</span> <a href="system.html#SomeInteger"><span class="Identifier">SomeInteger</span></a><span class="Other">]</span><span class="Other">(</span><span class="Identifier">v</span><span class="Other">,</span> <span class="Identifier">mask</span><span class="Other">:</span> <span class="Identifier">T</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">T</span> {.<span class="Identifier">inline</span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Returns <tt class="docutils literal"><span class="pre"><span class="Identifier">v</span></span></tt>, with all the <tt class="docutils literal"><span class="pre"><span class="DecNumber">1</span></span></tt> bits from <tt class="docutils literal"><span class="pre"><span class="Identifier">mask</span></span></tt> set to 1.</p>
|
||||
<p>Effectively maps to a <a class="reference external" href="#bitor.m,T,T,varargs[T]">bitor</a> operation.</p>
|
||||
|
||||
<p><strong class="examples_text">Example:</strong></p>
|
||||
<pre class="listing"><span class="Keyword">let</span> <span class="Identifier">v</span> <span class="Operator">=</span> <span class="BinNumber">0b0000_0011'</span><span class="Identifier">u8</span>
|
||||
<span class="Identifier">doAssert</span> <span class="Identifier">v</span><span class="Operator">.</span><span class="Identifier">setMasked</span><span class="Punctuation">(</span><span class="BinNumber">0b0000_1010'</span><span class="Identifier">u8</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="BinNumber">0b0000_1011'</span><span class="Identifier">u8</span></pre>
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/bitops.nim#L147" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/bitops.nim#L147" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
<div id="setMasked,T,Slice[int]">
|
||||
<dt><pre><span class="Keyword">func</span> <a href="#setMasked%2CT%2CSlice%5Bint%5D"><span class="Identifier">setMasked</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">:</span> <a href="system.html#SomeInteger"><span class="Identifier">SomeInteger</span></a><span class="Other">]</span><span class="Other">(</span><span class="Identifier">v</span><span class="Other">:</span> <span class="Identifier">T</span><span class="Other">;</span> <span class="Identifier">slice</span><span class="Other">:</span> <a href="system.html#Slice"><span class="Identifier">Slice</span></a><span class="Other">[</span><a href="system.html#int"><span class="Identifier">int</span></a><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">T</span> {.<span class="Identifier">inline</span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Returns <tt class="docutils literal"><span class="pre"><span class="Identifier">v</span></span></tt>, with all the <tt class="docutils literal"><span class="pre"><span class="DecNumber">1</span></span></tt> bits in the range of <tt class="docutils literal"><span class="pre"><span class="Identifier">slice</span></span></tt> set to 1.</p>
|
||||
<p>Effectively maps to a <a class="reference external" href="#bitor.m,T,T,varargs[T]">bitor</a> operation.</p>
|
||||
|
||||
<p><strong class="examples_text">Example:</strong></p>
|
||||
<pre class="listing"><span class="Keyword">let</span> <span class="Identifier">v</span> <span class="Operator">=</span> <span class="BinNumber">0b0000_0011'</span><span class="Identifier">u8</span>
|
||||
<span class="Identifier">doAssert</span> <span class="Identifier">v</span><span class="Operator">.</span><span class="Identifier">setMasked</span><span class="Punctuation">(</span><span class="DecNumber">2</span> <span class="Operator">..</span> <span class="DecNumber">3</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="BinNumber">0b0000_1111'</span><span class="Identifier">u8</span></pre>
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/bitops.nim#L157" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/bitops.nim#L157" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="testBit-procs-all">
|
||||
<div id="testBit,T,BitsRange[T: SomeInteger]">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#testBit%2CT%2CBitsRange%5BT%3A%20SomeInteger%5D"><span class="Identifier">testBit</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">:</span> <a href="system.html#SomeInteger"><span class="Identifier">SomeInteger</span></a><span class="Other">]</span><span class="Other">(</span><span class="Identifier">v</span><span class="Other">:</span> <span class="Identifier">T</span><span class="Other">;</span> <span class="Identifier">bit</span><span class="Other">:</span> <a href="bitops.html#BitsRange"><span class="Identifier">BitsRange</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#bool"><span class="Identifier">bool</span></a> {.<span class="Identifier">inline</span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Returns true if the bit in <tt class="docutils literal"><span class="pre"><span class="Identifier">v</span></span></tt> at positions <tt class="docutils literal"><span class="pre"><span class="Identifier">bit</span></span></tt> is set to 1.
|
||||
<p><strong class="examples_text">Example:</strong></p>
|
||||
<pre class="listing"><span class="Keyword">let</span> <span class="Identifier">v</span> <span class="Operator">=</span> <span class="BinNumber">0b0000_1111'</span><span class="Identifier">u8</span>
|
||||
<span class="Identifier">doAssert</span> <span class="Identifier">v</span><span class="Operator">.</span><span class="Identifier">testBit</span><span class="Punctuation">(</span><span class="DecNumber">0</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">doAssert</span> <span class="Keyword">not</span> <span class="Identifier">v</span><span class="Operator">.</span><span class="Identifier">testBit</span><span class="Punctuation">(</span><span class="DecNumber">7</span><span class="Punctuation">)</span></pre>
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/bitops.nim#L345" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/bitops.nim#L345" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="toMask-procs-all">
|
||||
<div id="toMask,Slice[int]">
|
||||
<dt><pre><span class="Keyword">func</span> <a href="#toMask%2CSlice%5Bint%5D"><span class="Identifier">toMask</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">:</span> <a href="system.html#SomeInteger"><span class="Identifier">SomeInteger</span></a><span class="Other">]</span><span class="Other">(</span><span class="Identifier">slice</span><span class="Other">:</span> <a href="system.html#Slice"><span class="Identifier">Slice</span></a><span class="Other">[</span><a href="system.html#int"><span class="Identifier">int</span></a><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">T</span> {.<span class="Identifier">inline</span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Creates a bitmask based on a slice of bits.
|
||||
<p><strong class="examples_text">Example:</strong></p>
|
||||
<pre class="listing"><span class="Identifier">doAssert</span> <span class="Identifier">toMask</span><span class="Punctuation">[</span><span class="Identifier">int32</span><span class="Punctuation">]</span><span class="Punctuation">(</span><span class="DecNumber">1</span> <span class="Operator">..</span> <span class="DecNumber">3</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="BinNumber">0b1110'i32</span>
|
||||
<span class="Identifier">doAssert</span> <span class="Identifier">toMask</span><span class="Punctuation">[</span><span class="Identifier">int32</span><span class="Punctuation">]</span><span class="Punctuation">(</span><span class="DecNumber">0</span> <span class="Operator">..</span> <span class="DecNumber">3</span><span class="Punctuation">)</span> <span class="Operator">==</span> <span class="BinNumber">0b1111'i32</span></pre>
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/bitops.nim#L90" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/bitops.nim#L90" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</dl>
|
||||
</div>
|
||||
<div class="section" id="17">
|
||||
<h1><a class="toc-backref" href="#17">Macros</a></h1>
|
||||
<dl class="item">
|
||||
<div id="bitand-macros-all">
|
||||
<div id="bitand.m,T,T,varargs[T]">
|
||||
<dt><pre><span class="Keyword">macro</span> <a href="#bitand.m%2CT%2CT%2Cvarargs%5BT%5D"><span class="Identifier">bitand</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">:</span> <a href="system.html#SomeInteger"><span class="Identifier">SomeInteger</span></a><span class="Other">]</span><span class="Other">(</span><span class="Identifier">x</span><span class="Other">,</span> <span class="Identifier">y</span><span class="Other">:</span> <span class="Identifier">T</span><span class="Other">;</span> <span class="Identifier">z</span><span class="Other">:</span> <a href="system.html#varargs"><span class="Identifier">varargs</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">T</span></pre></dt>
|
||||
<dd>
|
||||
|
||||
Computes the <tt class="docutils literal"><span class="pre"><span class="Identifier">bitwise</span> <span class="Keyword">and</span></span></tt> of all arguments collectively.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/bitops.nim#L41" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/bitops.nim#L41" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="bitor-macros-all">
|
||||
<div id="bitor.m,T,T,varargs[T]">
|
||||
<dt><pre><span class="Keyword">macro</span> <a href="#bitor.m%2CT%2CT%2Cvarargs%5BT%5D"><span class="Identifier">bitor</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">:</span> <a href="system.html#SomeInteger"><span class="Identifier">SomeInteger</span></a><span class="Other">]</span><span class="Other">(</span><span class="Identifier">x</span><span class="Other">,</span> <span class="Identifier">y</span><span class="Other">:</span> <span class="Identifier">T</span><span class="Other">;</span> <span class="Identifier">z</span><span class="Other">:</span> <a href="system.html#varargs"><span class="Identifier">varargs</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">T</span></pre></dt>
|
||||
<dd>
|
||||
|
||||
Computes the <tt class="docutils literal"><span class="pre"><span class="Identifier">bitwise</span> <span class="Keyword">or</span></span></tt> of all arguments collectively.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/bitops.nim#L48" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/bitops.nim#L48" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="bitxor-macros-all">
|
||||
<div id="bitxor.m,T,T,varargs[T]">
|
||||
<dt><pre><span class="Keyword">macro</span> <a href="#bitxor.m%2CT%2CT%2Cvarargs%5BT%5D"><span class="Identifier">bitxor</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">:</span> <a href="system.html#SomeInteger"><span class="Identifier">SomeInteger</span></a><span class="Other">]</span><span class="Other">(</span><span class="Identifier">x</span><span class="Other">,</span> <span class="Identifier">y</span><span class="Other">:</span> <span class="Identifier">T</span><span class="Other">;</span> <span class="Identifier">z</span><span class="Other">:</span> <a href="system.html#varargs"><span class="Identifier">varargs</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">T</span></pre></dt>
|
||||
<dd>
|
||||
|
||||
Computes the <tt class="docutils literal"><span class="pre"><span class="Identifier">bitwise</span> <span class="Keyword">xor</span></span></tt> of all arguments collectively.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/bitops.nim#L55" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/bitops.nim#L55" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="clearBits-macros-all">
|
||||
<div id="clearBits.m,typed,varargs[typed]">
|
||||
<dt><pre><span class="Keyword">macro</span> <a href="#clearBits.m%2Ctyped%2Cvarargs%5Btyped%5D"><span class="Identifier">clearBits</span></a><span class="Other">(</span><span class="Identifier">v</span><span class="Other">:</span> <a href="system.html#typed"><span class="Identifier">typed</span></a><span class="Other">;</span> <span class="Identifier">bits</span><span class="Other">:</span> <a href="system.html#varargs"><span class="Identifier">varargs</span></a><span class="Other">[</span><a href="system.html#typed"><span class="Identifier">typed</span></a><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#untyped"><span class="Identifier">untyped</span></a></pre></dt>
|
||||
<dd>
|
||||
|
||||
Mutates <tt class="docutils literal"><span class="pre"><span class="Identifier">v</span></span></tt>, with the bits at positions <tt class="docutils literal"><span class="pre"><span class="Identifier">bits</span></span></tt> set to 0.
|
||||
<p><strong class="examples_text">Example:</strong></p>
|
||||
<pre class="listing"><span class="Keyword">var</span> <span class="Identifier">v</span> <span class="Operator">=</span> <span class="BinNumber">0b1111_1111'</span><span class="Identifier">u8</span>
|
||||
<span class="Identifier">v</span><span class="Operator">.</span><span class="Identifier">clearBits</span><span class="Punctuation">(</span><span class="DecNumber">1</span><span class="Punctuation">,</span> <span class="DecNumber">3</span><span class="Punctuation">,</span> <span class="DecNumber">5</span><span class="Punctuation">,</span> <span class="DecNumber">7</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">doAssert</span> <span class="Identifier">v</span> <span class="Operator">==</span> <span class="BinNumber">0b0101_0101'</span><span class="Identifier">u8</span></pre>
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/bitops.nim#L320" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/bitops.nim#L320" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="flipBits-macros-all">
|
||||
<div id="flipBits.m,typed,varargs[typed]">
|
||||
<dt><pre><span class="Keyword">macro</span> <a href="#flipBits.m%2Ctyped%2Cvarargs%5Btyped%5D"><span class="Identifier">flipBits</span></a><span class="Other">(</span><span class="Identifier">v</span><span class="Other">:</span> <a href="system.html#typed"><span class="Identifier">typed</span></a><span class="Other">;</span> <span class="Identifier">bits</span><span class="Other">:</span> <a href="system.html#varargs"><span class="Identifier">varargs</span></a><span class="Other">[</span><a href="system.html#typed"><span class="Identifier">typed</span></a><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#untyped"><span class="Identifier">untyped</span></a></pre></dt>
|
||||
<dd>
|
||||
|
||||
Mutates <tt class="docutils literal"><span class="pre"><span class="Identifier">v</span></span></tt>, with the bits at positions <tt class="docutils literal"><span class="pre"><span class="Identifier">bits</span></span></tt> set to 0.
|
||||
<p><strong class="examples_text">Example:</strong></p>
|
||||
<pre class="listing"><span class="Keyword">var</span> <span class="Identifier">v</span> <span class="Operator">=</span> <span class="BinNumber">0b0000_1111'</span><span class="Identifier">u8</span>
|
||||
<span class="Identifier">v</span><span class="Operator">.</span><span class="Identifier">flipBits</span><span class="Punctuation">(</span><span class="DecNumber">1</span><span class="Punctuation">,</span> <span class="DecNumber">3</span><span class="Punctuation">,</span> <span class="DecNumber">5</span><span class="Punctuation">,</span> <span class="DecNumber">7</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">doAssert</span> <span class="Identifier">v</span> <span class="Operator">==</span> <span class="BinNumber">0b1010_0101'</span><span class="Identifier">u8</span></pre>
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/bitops.nim#L332" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/bitops.nim#L332" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="setBits-macros-all">
|
||||
<div id="setBits.m,typed,varargs[typed]">
|
||||
<dt><pre><span class="Keyword">macro</span> <a href="#setBits.m%2Ctyped%2Cvarargs%5Btyped%5D"><span class="Identifier">setBits</span></a><span class="Other">(</span><span class="Identifier">v</span><span class="Other">:</span> <a href="system.html#typed"><span class="Identifier">typed</span></a><span class="Other">;</span> <span class="Identifier">bits</span><span class="Other">:</span> <a href="system.html#varargs"><span class="Identifier">varargs</span></a><span class="Other">[</span><a href="system.html#typed"><span class="Identifier">typed</span></a><span class="Other">]</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#untyped"><span class="Identifier">untyped</span></a></pre></dt>
|
||||
<dd>
|
||||
|
||||
Mutates <tt class="docutils literal"><span class="pre"><span class="Identifier">v</span></span></tt>, with the bits at positions <tt class="docutils literal"><span class="pre"><span class="Identifier">bits</span></span></tt> set to 1.
|
||||
<p><strong class="examples_text">Example:</strong></p>
|
||||
<pre class="listing"><span class="Keyword">var</span> <span class="Identifier">v</span> <span class="Operator">=</span> <span class="BinNumber">0b0000_0011'</span><span class="Identifier">u8</span>
|
||||
<span class="Identifier">v</span><span class="Operator">.</span><span class="Identifier">setBits</span><span class="Punctuation">(</span><span class="DecNumber">3</span><span class="Punctuation">,</span> <span class="DecNumber">5</span><span class="Punctuation">,</span> <span class="DecNumber">7</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">doAssert</span> <span class="Identifier">v</span> <span class="Operator">==</span> <span class="BinNumber">0b1010_1011'</span><span class="Identifier">u8</span></pre>
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/bitops.nim#L308" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/bitops.nim#L308" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="twelve-columns footer">
|
||||
<span class="nim-sprite"></span>
|
||||
<br>
|
||||
<small style="color: var(--hint);">Made with Nim. Generated: 2023-03-13 00:19:25 UTC</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script defer data-domain="nim-lang.org" src="https://plausible.io/js/plausible.js"></script>
|
||||
|
||||
<!-- Google fonts -->
|
||||
<link href='https://fonts.googleapis.com/css?family=Lato:400,600,900' rel='stylesheet' type='text/css'/>
|
||||
<link href='https://fonts.googleapis.com/css?family=Source+Code+Pro:400,500,600' rel='stylesheet' type='text/css'/>
|
||||
</body>
|
||||
</html>
|
||||
51
bitops.idx
Normal file
51
bitops.idx
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
nimTitle bitops bitops.html module std/bitops 0
|
||||
nim bitnot bitops.html#bitnot,T proc bitnot[T: SomeInteger](x: T): T 32
|
||||
nim bitand bitops.html#bitand.m,T,T,varargs[T] macro bitand[T: SomeInteger](x, y: T; z: varargs[T]): T 41
|
||||
nim bitor bitops.html#bitor.m,T,T,varargs[T] macro bitor[T: SomeInteger](x, y: T; z: varargs[T]): T 48
|
||||
nim bitxor bitops.html#bitxor.m,T,T,varargs[T] macro bitxor[T: SomeInteger](x, y: T; z: varargs[T]): T 55
|
||||
nim BitsRange bitops.html#BitsRange type BitsRange 63
|
||||
nim bitsliced bitops.html#bitsliced,T,Slice[int] proc bitsliced[T: SomeInteger](v: T; slice: Slice[int]): T 66
|
||||
nim bitslice bitops.html#bitslice,T,Slice[int] proc bitslice[T: SomeInteger](v: var T; slice: Slice[int]) 78
|
||||
nim toMask bitops.html#toMask,Slice[int] proc toMask[T: SomeInteger](slice: Slice[int]): T 90
|
||||
nim masked bitops.html#masked,T,T proc masked[T: SomeInteger](v, mask: T): T 101
|
||||
nim masked bitops.html#masked,T,Slice[int] proc masked[T: SomeInteger](v: T; slice: Slice[int]): T 112
|
||||
nim mask bitops.html#mask,T,T proc mask[T: SomeInteger](v: var T; mask: T) 123
|
||||
nim mask bitops.html#mask,T,Slice[int] proc mask[T: SomeInteger](v: var T; slice: Slice[int]) 135
|
||||
nim setMasked bitops.html#setMasked,T,T proc setMasked[T: SomeInteger](v, mask: T): T 147
|
||||
nim setMasked bitops.html#setMasked,T,Slice[int] proc setMasked[T: SomeInteger](v: T; slice: Slice[int]): T 157
|
||||
nim setMask bitops.html#setMask,T,T proc setMask[T: SomeInteger](v: var T; mask: T) 167
|
||||
nim setMask bitops.html#setMask,T,Slice[int] proc setMask[T: SomeInteger](v: var T; slice: Slice[int]) 178
|
||||
nim clearMasked bitops.html#clearMasked,T,T proc clearMasked[T: SomeInteger](v, mask: T): T 189
|
||||
nim clearMasked bitops.html#clearMasked,T,Slice[int] proc clearMasked[T: SomeInteger](v: T; slice: Slice[int]): T 200
|
||||
nim clearMask bitops.html#clearMask,T,T proc clearMask[T: SomeInteger](v: var T; mask: T) 211
|
||||
nim clearMask bitops.html#clearMask,T,Slice[int] proc clearMask[T: SomeInteger](v: var T; slice: Slice[int]) 223
|
||||
nim flipMasked bitops.html#flipMasked,T,T proc flipMasked[T: SomeInteger](v, mask: T): T 235
|
||||
nim flipMasked bitops.html#flipMasked,T,Slice[int] proc flipMasked[T: SomeInteger](v: T; slice: Slice[int]): T 245
|
||||
nim flipMask bitops.html#flipMask,T,T proc flipMask[T: SomeInteger](v: var T; mask: T) 255
|
||||
nim flipMask bitops.html#flipMask,T,Slice[int] proc flipMask[T: SomeInteger](v: var T; slice: Slice[int]) 266
|
||||
nim setBit bitops.html#setBit,T,BitsRange[T: SomeInteger] proc setBit[T: SomeInteger](v: var T; bit: BitsRange[T]) 277
|
||||
nim clearBit bitops.html#clearBit,T,BitsRange[T: SomeInteger] proc clearBit[T: SomeInteger](v: var T; bit: BitsRange[T]) 286
|
||||
nim flipBit bitops.html#flipBit,T,BitsRange[T: SomeInteger] proc flipBit[T: SomeInteger](v: var T; bit: BitsRange[T]) 295
|
||||
nim setBits bitops.html#setBits.m,typed,varargs[typed] macro setBits(v: typed; bits: varargs[typed]): untyped 308
|
||||
nim clearBits bitops.html#clearBits.m,typed,varargs[typed] macro clearBits(v: typed; bits: varargs[typed]): untyped 320
|
||||
nim flipBits bitops.html#flipBits.m,typed,varargs[typed] macro flipBits(v: typed; bits: varargs[typed]): untyped 332
|
||||
nim testBit bitops.html#testBit,T,BitsRange[T: SomeInteger] proc testBit[T: SomeInteger](v: T; bit: BitsRange[T]): bool 345
|
||||
nim countSetBits bitops.html#countSetBits,SomeInteger proc countSetBits(x: SomeInteger): int 482
|
||||
nim popcount bitops.html#popcount,SomeInteger proc popcount(x: SomeInteger): int 490
|
||||
nim parityBits bitops.html#parityBits,SomeInteger proc parityBits(x: SomeInteger): int 494
|
||||
nim firstSetBit bitops.html#firstSetBit,SomeInteger proc firstSetBit(x: SomeInteger): int 516
|
||||
nim fastLog2 bitops.html#fastLog2,SomeInteger proc fastLog2(x: SomeInteger): int 559
|
||||
nim countLeadingZeroBits bitops.html#countLeadingZeroBits,SomeInteger proc countLeadingZeroBits(x: SomeInteger): int 598
|
||||
nim countTrailingZeroBits bitops.html#countTrailingZeroBits,SomeInteger proc countTrailingZeroBits(x: SomeInteger): int 626
|
||||
nim rotateLeftBits bitops.html#rotateLeftBits,T,range[] proc rotateLeftBits[T: SomeUnsignedInt](value: T; shift: range[0 .. (sizeof(T) * 8)]): T 779
|
||||
nim rotateRightBits bitops.html#rotateRightBits,T,range[] proc rotateRightBits[T: SomeUnsignedInt](value: T; shift: range[0 .. (sizeof(T) * 8)]): T 807
|
||||
nim reverseBits bitops.html#reverseBits,T proc reverseBits[T: SomeUnsignedInt](x: T): T 842
|
||||
idx Hamming weight bitops.html#hamming-weight_1 Module bitops 0
|
||||
nimgrp clearmask bitops.html#clearMask-procs-all proc 211
|
||||
nimgrp flipmasked bitops.html#flipMasked-procs-all proc 235
|
||||
nimgrp flipmask bitops.html#flipMask-procs-all proc 255
|
||||
nimgrp setmasked bitops.html#setMasked-procs-all proc 147
|
||||
nimgrp mask bitops.html#mask-procs-all proc 123
|
||||
nimgrp setmask bitops.html#setMask-procs-all proc 167
|
||||
nimgrp masked bitops.html#masked-procs-all proc 101
|
||||
nimgrp clearmasked bitops.html#clearMasked-procs-all proc 189
|
||||
181
bitops_utils.html
Normal file
181
bitops_utils.html
Normal file
|
|
@ -0,0 +1,181 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<!-- This file is generated by Nim. -->
|
||||
<html xmlns="https://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>std/private/bitops_utils</title>
|
||||
|
||||
<!-- Favicon -->
|
||||
<link rel="shortcut icon" href="data:image/x-icon;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAUAAAAF////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAIAAABbAAAAlQAAAKIAAACbAAAAmwAAAKIAAACVAAAAWwAAAAL///8A////AP///wD///8A////AAAAABQAAADAAAAAYwAAAA3///8A////AP///wD///8AAAAADQAAAGMAAADAAAAAFP///wD///8A////AP///wAAAACdAAAAOv///wD///8A////AP///wD///8A////AP///wD///8AAAAAOgAAAJ3///8A////AP///wAAAAAnAAAAcP///wAAAAAoAAAASv///wD///8A////AP///wAAAABKAAAAKP///wAAAABwAAAAJ////wD///8AAAAAgQAAABwAAACIAAAAkAAAAJMAAACtAAAAFQAAABUAAACtAAAAkwAAAJAAAACIAAAAHAAAAIH///8A////AAAAAKQAAACrAAAAaP///wD///8AAAAARQAAANIAAADSAAAARf///wD///8AAAAAaAAAAKsAAACk////AAAAADMAAACcAAAAnQAAABj///8A////AP///wAAAAAYAAAAGP///wD///8A////AAAAABgAAACdAAAAnAAAADMAAAB1AAAAwwAAAP8AAADpAAAAsQAAAE4AAAAb////AP///wAAAAAbAAAATgAAALEAAADpAAAA/wAAAMMAAAB1AAAAtwAAAOkAAAD/AAAA/wAAAP8AAADvAAAA3gAAAN4AAADeAAAA3gAAAO8AAAD/AAAA/wAAAP8AAADpAAAAtwAAAGUAAAA/AAAA3wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAADfAAAAPwAAAGX///8A////AAAAAEgAAADtAAAAvwAAAL0AAADGAAAA7wAAAO8AAADGAAAAvQAAAL8AAADtAAAASP///wD///8A////AP///wD///8AAAAAO////wD///8A////AAAAAIcAAACH////AP///wD///8AAAAAO////wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A//8AAP//AAD4HwAA7/cAAN/7AAD//wAAoYUAAJ55AACf+QAAh+EAAAAAAADAAwAA4AcAAP5/AAD//wAA//8AAA=="/>
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAA3XAAAN1wFCKJt4AAAAB3RJTUUH4QQQEwksSS9ZWwAAAk1JREFUWMPtll2ITVEUx39nn/O7Y5qR8f05wtCUUr6ZIS++8pEnkZInPImneaCQ5METNdOkeFBKUhMPRIkHKfEuUZSUlGlKPN2TrgfncpvmnntnmlEyq1Z7t89/rf9a6+y99oZxGZf/XeIq61EdtgKXgdXA0xrYAvBjOIF1AI9zvjcC74BSpndrJPkBWDScTF8Aa4E3wDlgHbASaANmVqlcCnwHvgDvgVfAJ+AikAAvgfVZwLnSVZHZaOuKoQi3ZOMi4NkYkpe1p4J7A8BpYAD49hfIy/oqG0+hLomiKP2L5L+1ubn5115S+3OAn4EnwBlgMzCjyt6ZAnQCJ4A7wOs88iRJHvw50HoujuPBoCKwHWiosy8MdfZnAdcHk8dxXFJ3VQbQlCTJvRBCGdRbD4M6uc5glpY3eAihpN5S5w12diSEcCCEcKUO4ljdr15T76ur1FDDLIQQ3qv71EdDOe3Kxj3leRXyk+pxdWnFWod6Wt2bY3de3aSuUHcPBVimHs7mK9WrmeOF6lR1o9qnzskh2ar2qm1qizpfXaPeVGdlmGN5pb09qMxz1Xb1kLqgzn1RyH7JUXW52lr5e/Kqi9qpto7V1atuUzfnARrV7jEib1T76gG2qxdGmXyiekkt1GswPTtek0aBfJp6YySGBfWg2tPQ0FAYgf1stUfdmdcjarbYJEniKIq6gY/Aw+zWHAC+p2labGpqiorFYgGYCEzN7oQdQClN07O1/EfDyGgC0ALMBdYAi4FyK+4H3gLPsxfR1zRNi+NP7nH5J+QntnXe5B5mpfQAAAAASUVORK5CYII=">
|
||||
|
||||
<!-- CSS -->
|
||||
<link rel="stylesheet" type="text/css" href="nimdoc.out.css">
|
||||
|
||||
<!-- JS -->
|
||||
<script type="text/javascript" src="dochack.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="document" id="documentId">
|
||||
<div class="container">
|
||||
<h1 class="title">std/private/bitops_utils</h1>
|
||||
<div class="row">
|
||||
<div class="three columns">
|
||||
<div class="theme-select-wrapper">
|
||||
<label for="theme-select">Theme: </label>
|
||||
<select id="theme-select" onchange="setTheme(this.value)">
|
||||
<option value="auto">🌗 Match OS</option>
|
||||
<option value="dark">🌑 Dark</option>
|
||||
<option value="light">🌕 Light</option>
|
||||
</select>
|
||||
</div>
|
||||
<div id="global-links">
|
||||
<ul class="simple-boot">
|
||||
<li><a href="manual.html">Manual</a></li>
|
||||
<li><a href="lib.html">Standard library</a></li>
|
||||
<li> <a id="indexLink" href="theindex.html">Index</a></li>
|
||||
<li><a href="compiler/theindex.html">Compiler docs</a></li>
|
||||
<li><a href="https://nim-lang.github.io/fusion/theindex.html">Fusion docs</a></li>
|
||||
<li><a href="https://nim-lang.github.io/Nim/">devel</a>, <a href="https://nim-lang.org/documentation.html">stable</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="searchInputDiv">
|
||||
Search: <input type="search" id="searchInput"
|
||||
onkeyup="search()" />
|
||||
</div>
|
||||
|
||||
<ul class="simple simple-toc" id="toc-list">
|
||||
<li>
|
||||
<details open>
|
||||
<summary><a class="reference reference-toplevel" href="#18" id="68">Templates</a></summary>
|
||||
<ul class="simple simple-toc-section">
|
||||
<ul class="simple nested-toc-section">castToUnsigned
|
||||
<li><a class="reference" href="#castToUnsigned.t%2Cint" title="castToUnsigned(x: int): uint">castToUnsigned(x: int): uint</a></li>
|
||||
<li><a class="reference" href="#castToUnsigned.t%2Cint8" title="castToUnsigned(x: int8): uint8">castToUnsigned(x: int8): uint8</a></li>
|
||||
<li><a class="reference" href="#castToUnsigned.t%2Cint16" title="castToUnsigned(x: int16): uint16">castToUnsigned(x: int16): uint16</a></li>
|
||||
<li><a class="reference" href="#castToUnsigned.t%2Cint32" title="castToUnsigned(x: int32): uint32">castToUnsigned(x: int32): uint32</a></li>
|
||||
<li><a class="reference" href="#castToUnsigned.t%2Cint64" title="castToUnsigned(x: int64): uint64">castToUnsigned(x: int64): uint64</a></li>
|
||||
<li><a class="reference" href="#castToUnsigned.t%2CT" title="castToUnsigned[T: SomeUnsignedInt](x: T): T">castToUnsigned[T: SomeUnsignedInt](x: T): T</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">forwardImpl
|
||||
<li><a class="reference" href="#forwardImpl.t%2C%2C" title="forwardImpl(impl, arg)">forwardImpl(impl, arg)</a></li>
|
||||
|
||||
</ul>
|
||||
|
||||
</ul>
|
||||
</details>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
<div class="nine columns" id="content">
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/std/private/bitops_utils.nim#L1" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/private/bitops_utils.nim#L1" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
<div id="tocRoot"></div>
|
||||
|
||||
<p class="module-desc"></p>
|
||||
<div class="section" id="18">
|
||||
<h1><a class="toc-backref" href="#18">Templates</a></h1>
|
||||
<dl class="item">
|
||||
<div id="castToUnsigned-templates-all">
|
||||
<div id="castToUnsigned.t,int">
|
||||
<dt><pre><span class="Keyword">template</span> <a href="#castToUnsigned.t%2Cint"><span class="Identifier">castToUnsigned</span></a><span class="Other">(</span><span class="Identifier">x</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#uint"><span class="Identifier">uint</span></a></pre></dt>
|
||||
<dd>
|
||||
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/std/private/bitops_utils.nim#L21" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/private/bitops_utils.nim#L21" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
<div id="castToUnsigned.t,int8">
|
||||
<dt><pre><span class="Keyword">template</span> <a href="#castToUnsigned.t%2Cint8"><span class="Identifier">castToUnsigned</span></a><span class="Other">(</span><span class="Identifier">x</span><span class="Other">:</span> <a href="system.html#int8"><span class="Identifier">int8</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#uint8"><span class="Identifier">uint8</span></a></pre></dt>
|
||||
<dd>
|
||||
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/std/private/bitops_utils.nim#L17" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/private/bitops_utils.nim#L17" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
<div id="castToUnsigned.t,int16">
|
||||
<dt><pre><span class="Keyword">template</span> <a href="#castToUnsigned.t%2Cint16"><span class="Identifier">castToUnsigned</span></a><span class="Other">(</span><span class="Identifier">x</span><span class="Other">:</span> <a href="system.html#int16"><span class="Identifier">int16</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#uint16"><span class="Identifier">uint16</span></a></pre></dt>
|
||||
<dd>
|
||||
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/std/private/bitops_utils.nim#L18" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/private/bitops_utils.nim#L18" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
<div id="castToUnsigned.t,int32">
|
||||
<dt><pre><span class="Keyword">template</span> <a href="#castToUnsigned.t%2Cint32"><span class="Identifier">castToUnsigned</span></a><span class="Other">(</span><span class="Identifier">x</span><span class="Other">:</span> <a href="system.html#int32"><span class="Identifier">int32</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#uint32"><span class="Identifier">uint32</span></a></pre></dt>
|
||||
<dd>
|
||||
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/std/private/bitops_utils.nim#L19" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/private/bitops_utils.nim#L19" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
<div id="castToUnsigned.t,int64">
|
||||
<dt><pre><span class="Keyword">template</span> <a href="#castToUnsigned.t%2Cint64"><span class="Identifier">castToUnsigned</span></a><span class="Other">(</span><span class="Identifier">x</span><span class="Other">:</span> <a href="system.html#int64"><span class="Identifier">int64</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#uint64"><span class="Identifier">uint64</span></a></pre></dt>
|
||||
<dd>
|
||||
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/std/private/bitops_utils.nim#L20" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/private/bitops_utils.nim#L20" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
<div id="castToUnsigned.t,T">
|
||||
<dt><pre><span class="Keyword">template</span> <a href="#castToUnsigned.t%2CT"><span class="Identifier">castToUnsigned</span></a><span class="Other">[</span><span class="Identifier">T</span><span class="Other">:</span> <a href="system.html#SomeUnsignedInt"><span class="Identifier">SomeUnsignedInt</span></a><span class="Other">]</span><span class="Other">(</span><span class="Identifier">x</span><span class="Other">:</span> <span class="Identifier">T</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">T</span></pre></dt>
|
||||
<dd>
|
||||
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/std/private/bitops_utils.nim#L22" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/private/bitops_utils.nim#L22" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="forwardImpl-templates-all">
|
||||
<div id="forwardImpl.t,,">
|
||||
<dt><pre><span class="Keyword">template</span> <a href="#forwardImpl.t%2C%2C"><span class="Identifier">forwardImpl</span></a><span class="Other">(</span><span class="Identifier">impl</span><span class="Other">,</span> <span class="Identifier">arg</span><span class="Other">)</span> {.<span class="Identifier">dirty</span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/std/private/bitops_utils.nim#L1" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/private/bitops_utils.nim#L1" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="twelve-columns footer">
|
||||
<span class="nim-sprite"></span>
|
||||
<br>
|
||||
<small style="color: var(--hint);">Made with Nim. Generated: 2023-03-13 00:20:05 UTC</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script defer data-domain="nim-lang.org" src="https://plausible.io/js/plausible.js"></script>
|
||||
|
||||
<!-- Google fonts -->
|
||||
<link href='https://fonts.googleapis.com/css?family=Lato:400,600,900' rel='stylesheet' type='text/css'/>
|
||||
<link href='https://fonts.googleapis.com/css?family=Source+Code+Pro:400,500,600' rel='stylesheet' type='text/css'/>
|
||||
</body>
|
||||
</html>
|
||||
9
bitops_utils.idx
Normal file
9
bitops_utils.idx
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
nimTitle bitops_utils bitops_utils.html module std/private/bitops_utils 0
|
||||
nim forwardImpl bitops_utils.html#forwardImpl.t,, template forwardImpl(impl, arg) 1
|
||||
nim castToUnsigned bitops_utils.html#castToUnsigned.t,int8 template castToUnsigned(x: int8): uint8 17
|
||||
nim castToUnsigned bitops_utils.html#castToUnsigned.t,int16 template castToUnsigned(x: int16): uint16 18
|
||||
nim castToUnsigned bitops_utils.html#castToUnsigned.t,int32 template castToUnsigned(x: int32): uint32 19
|
||||
nim castToUnsigned bitops_utils.html#castToUnsigned.t,int64 template castToUnsigned(x: int64): uint64 20
|
||||
nim castToUnsigned bitops_utils.html#castToUnsigned.t,int template castToUnsigned(x: int): uint 21
|
||||
nim castToUnsigned bitops_utils.html#castToUnsigned.t,T template castToUnsigned[T: SomeUnsignedInt](x: T): T 22
|
||||
nimgrp casttounsigned bitops_utils.html#castToUnsigned-templates-all template 17
|
||||
173
browsers.html
Normal file
173
browsers.html
Normal file
|
|
@ -0,0 +1,173 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<!-- This file is generated by Nim. -->
|
||||
<html xmlns="https://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>std/browsers</title>
|
||||
|
||||
<!-- Favicon -->
|
||||
<link rel="shortcut icon" href="data:image/x-icon;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAUAAAAF////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAIAAABbAAAAlQAAAKIAAACbAAAAmwAAAKIAAACVAAAAWwAAAAL///8A////AP///wD///8A////AAAAABQAAADAAAAAYwAAAA3///8A////AP///wD///8AAAAADQAAAGMAAADAAAAAFP///wD///8A////AP///wAAAACdAAAAOv///wD///8A////AP///wD///8A////AP///wD///8AAAAAOgAAAJ3///8A////AP///wAAAAAnAAAAcP///wAAAAAoAAAASv///wD///8A////AP///wAAAABKAAAAKP///wAAAABwAAAAJ////wD///8AAAAAgQAAABwAAACIAAAAkAAAAJMAAACtAAAAFQAAABUAAACtAAAAkwAAAJAAAACIAAAAHAAAAIH///8A////AAAAAKQAAACrAAAAaP///wD///8AAAAARQAAANIAAADSAAAARf///wD///8AAAAAaAAAAKsAAACk////AAAAADMAAACcAAAAnQAAABj///8A////AP///wAAAAAYAAAAGP///wD///8A////AAAAABgAAACdAAAAnAAAADMAAAB1AAAAwwAAAP8AAADpAAAAsQAAAE4AAAAb////AP///wAAAAAbAAAATgAAALEAAADpAAAA/wAAAMMAAAB1AAAAtwAAAOkAAAD/AAAA/wAAAP8AAADvAAAA3gAAAN4AAADeAAAA3gAAAO8AAAD/AAAA/wAAAP8AAADpAAAAtwAAAGUAAAA/AAAA3wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAADfAAAAPwAAAGX///8A////AAAAAEgAAADtAAAAvwAAAL0AAADGAAAA7wAAAO8AAADGAAAAvQAAAL8AAADtAAAASP///wD///8A////AP///wD///8AAAAAO////wD///8A////AAAAAIcAAACH////AP///wD///8AAAAAO////wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A//8AAP//AAD4HwAA7/cAAN/7AAD//wAAoYUAAJ55AACf+QAAh+EAAAAAAADAAwAA4AcAAP5/AAD//wAA//8AAA=="/>
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAA3XAAAN1wFCKJt4AAAAB3RJTUUH4QQQEwksSS9ZWwAAAk1JREFUWMPtll2ITVEUx39nn/O7Y5qR8f05wtCUUr6ZIS++8pEnkZInPImneaCQ5METNdOkeFBKUhMPRIkHKfEuUZSUlGlKPN2TrgfncpvmnntnmlEyq1Z7t89/rf9a6+y99oZxGZf/XeIq61EdtgKXgdXA0xrYAvBjOIF1AI9zvjcC74BSpndrJPkBWDScTF8Aa4E3wDlgHbASaANmVqlcCnwHvgDvgVfAJ+AikAAvgfVZwLnSVZHZaOuKoQi3ZOMi4NkYkpe1p4J7A8BpYAD49hfIy/oqG0+hLomiKP2L5L+1ubn5115S+3OAn4EnwBlgMzCjyt6ZAnQCJ4A7wOs88iRJHvw50HoujuPBoCKwHWiosy8MdfZnAdcHk8dxXFJ3VQbQlCTJvRBCGdRbD4M6uc5glpY3eAihpN5S5w12diSEcCCEcKUO4ljdr15T76ur1FDDLIQQ3qv71EdDOe3Kxj3leRXyk+pxdWnFWod6Wt2bY3de3aSuUHcPBVimHs7mK9WrmeOF6lR1o9qnzskh2ar2qm1qizpfXaPeVGdlmGN5pb09qMxz1Xb1kLqgzn1RyH7JUXW52lr5e/Kqi9qpto7V1atuUzfnARrV7jEib1T76gG2qxdGmXyiekkt1GswPTtek0aBfJp6YySGBfWg2tPQ0FAYgf1stUfdmdcjarbYJEniKIq6gY/Aw+zWHAC+p2labGpqiorFYgGYCEzN7oQdQClN07O1/EfDyGgC0ALMBdYAi4FyK+4H3gLPsxfR1zRNi+NP7nH5J+QntnXe5B5mpfQAAAAASUVORK5CYII=">
|
||||
|
||||
<!-- CSS -->
|
||||
<link rel="stylesheet" type="text/css" href="nimdoc.out.css">
|
||||
|
||||
<!-- JS -->
|
||||
<script type="text/javascript" src="dochack.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="document" id="documentId">
|
||||
<div class="container">
|
||||
<h1 class="title">std/browsers</h1>
|
||||
<div class="row">
|
||||
<div class="three columns">
|
||||
<div class="theme-select-wrapper">
|
||||
<label for="theme-select">Theme: </label>
|
||||
<select id="theme-select" onchange="setTheme(this.value)">
|
||||
<option value="auto">🌗 Match OS</option>
|
||||
<option value="dark">🌑 Dark</option>
|
||||
<option value="light">🌕 Light</option>
|
||||
</select>
|
||||
</div>
|
||||
<div id="global-links">
|
||||
<ul class="simple-boot">
|
||||
<li><a href="manual.html">Manual</a></li>
|
||||
<li><a href="lib.html">Standard library</a></li>
|
||||
<li> <a id="indexLink" href="theindex.html">Index</a></li>
|
||||
<li><a href="compiler/theindex.html">Compiler docs</a></li>
|
||||
<li><a href="https://nim-lang.github.io/fusion/theindex.html">Fusion docs</a></li>
|
||||
<li><a href="https://nim-lang.github.io/Nim/">devel</a>, <a href="https://nim-lang.org/documentation.html">stable</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="searchInputDiv">
|
||||
Search: <input type="search" id="searchInput"
|
||||
onkeyup="search()" />
|
||||
</div>
|
||||
|
||||
<ul class="simple simple-toc" id="toc-list">
|
||||
<li>
|
||||
<a class="reference reference-toplevel" href="#6" id="56">Imports</a>
|
||||
</li>
|
||||
<li>
|
||||
<details open>
|
||||
<summary><a class="reference reference-toplevel" href="#10" id="60">Consts</a></summary>
|
||||
<ul class="simple simple-toc-section">
|
||||
<li><a class="reference" href="#osOpenCmd" title="osOpenCmd = "xdg-open"">osOpenCmd</a></li>
|
||||
|
||||
</ul>
|
||||
</details>
|
||||
</li>
|
||||
<li>
|
||||
<details open>
|
||||
<summary><a class="reference reference-toplevel" href="#12" id="62">Procs</a></summary>
|
||||
<ul class="simple simple-toc-section">
|
||||
<ul class="simple nested-toc-section">openDefaultBrowser
|
||||
<li><a class="reference" href="#openDefaultBrowser" title="openDefaultBrowser()">openDefaultBrowser()</a></li>
|
||||
<li><a class="reference" href="#openDefaultBrowser%2Cstring" title="openDefaultBrowser(url: string)">openDefaultBrowser(url: string)</a></li>
|
||||
|
||||
</ul>
|
||||
|
||||
</ul>
|
||||
</details>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
<div class="nine columns" id="content">
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/browsers.nim#L1" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/browsers.nim#L1" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
<div id="tocRoot"></div>
|
||||
|
||||
<p class="module-desc"><p>This module implements a simple proc for opening URLs with the user's default browser.</p>
|
||||
<p>Unstable API.</p>
|
||||
</p>
|
||||
<div class="section" id="6">
|
||||
<h1><a class="toc-backref" href="#6">Imports</a></h1>
|
||||
<dl class="item">
|
||||
<a class="reference external" href="since.html">since</a>, <a class="reference external" href="strutils.html">strutils</a>, <a class="reference external" href="assertions.html">assertions</a>, <a class="reference external" href="os.html">os</a>, <a class="reference external" href="osproc.html">osproc</a>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="section" id="10">
|
||||
<h1><a class="toc-backref" href="#10">Consts</a></h1>
|
||||
<dl class="item">
|
||||
<div id="osOpenCmd">
|
||||
<dt><pre><a href="browsers.html#osOpenCmd"><span class="Identifier">osOpenCmd</span></a> <span class="Other">=</span> <span class="StringLit">"xdg-open"</span></pre></dt>
|
||||
<dd>
|
||||
|
||||
|
||||
Alias for the operating system specific <em>"open"</em> command, <tt class="docutils literal"><span class="pre"><span class="StringLit">"open"</span></span></tt> on OSX, MacOS and Windows, <tt class="docutils literal"><span class="pre"><span class="StringLit">"xdg-open"</span></span></tt> on Linux, BSD, etc.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/browsers.nim#L32" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/browsers.nim#L32" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</dl>
|
||||
</div>
|
||||
<div class="section" id="12">
|
||||
<h1><a class="toc-backref" href="#12">Procs</a></h1>
|
||||
<dl class="item">
|
||||
<div id="openDefaultBrowser-procs-all">
|
||||
<div id="openDefaultBrowser">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#openDefaultBrowser"><span class="Identifier">openDefaultBrowser</span></a><span class="Other">(</span><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ValueError</span><span class="Other">,</span> <span class="Identifier">OSError</span><span class="Other">,</span> <span class="Identifier">IOError</span><span class="Other">]</span><span class="Other">,</span>
|
||||
<span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ExecIOEffect</span><span class="Other">,</span> <span class="Identifier">ReadEnvEffect</span><span class="Other">,</span> <span class="Identifier">RootEffect</span><span class="Other">]</span><span class="Other">,</span>
|
||||
<span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Opens the user's default browser without any <tt class="docutils literal"><span class="pre"><span class="Identifier">url</span></span></tt> (blank page). This does not block. Implements IETF RFC-6694 Section 3, "about:blank" must be reserved for a blank page.</p>
|
||||
<p>Under Windows, <tt class="docutils literal"><span class="pre"><span class="Identifier">ShellExecute</span></span></tt> is used. Under Mac OS X the <tt class="docutils literal"><span class="pre"><span class="Identifier">open</span></span></tt> command is used. Under Unix, it is checked if <tt class="docutils literal"><span class="pre"><span class="Identifier">xdg</span><span class="Operator">-</span><span class="Identifier">open</span></span></tt> exists and used if it does. Otherwise the environment variable <tt class="docutils literal"><span class="pre"><span class="Identifier">BROWSER</span></span></tt> is used to determine the default browser to use.</p>
|
||||
<p>This proc doesn't raise an exception on error, beware.</p>
|
||||
<p><pre class="listing">
|
||||
<span class="Keyword">block</span><span class="Punctuation">:</span> <span class="Identifier">openDefaultBrowser</span><span class="Punctuation">(</span><span class="Punctuation">)</span></pre></p>
|
||||
<p><strong>See also:</strong></p>
|
||||
<ul class="simple"><li><a class="reference external" href="https://tools.ietf.org/html/rfc6694#section-3">https://tools.ietf.org/html/rfc6694#section-3</a></li>
|
||||
</ul>
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/browsers.nim#L78" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/browsers.nim#L78" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
<div id="openDefaultBrowser,string">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#openDefaultBrowser%2Cstring"><span class="Identifier">openDefaultBrowser</span></a><span class="Other">(</span><span class="Identifier">url</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ValueError</span><span class="Other">,</span> <span class="Identifier">OSError</span><span class="Other">,</span> <span class="Identifier">IOError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span>
|
||||
<span class="Identifier">ExecIOEffect</span><span class="Other">,</span> <span class="Identifier">ReadEnvEffect</span><span class="Other">,</span> <span class="Identifier">RootEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Opens <tt class="docutils literal"><span class="pre"><span class="Identifier">url</span></span></tt> with the user's default browser. This does not block. The URL must not be empty string, to open on a blank page see <tt class="docutils literal"><span class="pre"><span class="Identifier">openDefaultBrowser</span><span class="Punctuation">(</span><span class="Punctuation">)</span></span></tt>.</p>
|
||||
<p>Under Windows, <tt class="docutils literal"><span class="pre"><span class="Identifier">ShellExecute</span></span></tt> is used. Under Mac OS X the <tt class="docutils literal"><span class="pre"><span class="Identifier">open</span></span></tt> command is used. Under Unix, it is checked if <tt class="docutils literal"><span class="pre"><span class="Identifier">xdg</span><span class="Operator">-</span><span class="Identifier">open</span></span></tt> exists and used if it does. Otherwise the environment variable <tt class="docutils literal"><span class="pre"><span class="Identifier">BROWSER</span></span></tt> is used to determine the default browser to use.</p>
|
||||
<p>This proc doesn't raise an exception on error, beware.</p>
|
||||
<p><pre class="listing">
|
||||
<span class="Keyword">block</span><span class="Punctuation">:</span> <span class="Identifier">openDefaultBrowser</span><span class="Punctuation">(</span><span class="StringLit">"https://nim-lang.org"</span><span class="Punctuation">)</span></pre></p>
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/browsers.nim#L61" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/browsers.nim#L61" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="twelve-columns footer">
|
||||
<span class="nim-sprite"></span>
|
||||
<br>
|
||||
<small style="color: var(--hint);">Made with Nim. Generated: 2023-03-13 00:19:42 UTC</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script defer data-domain="nim-lang.org" src="https://plausible.io/js/plausible.js"></script>
|
||||
|
||||
<!-- Google fonts -->
|
||||
<link href='https://fonts.googleapis.com/css?family=Lato:400,600,900' rel='stylesheet' type='text/css'/>
|
||||
<link href='https://fonts.googleapis.com/css?family=Source+Code+Pro:400,500,600' rel='stylesheet' type='text/css'/>
|
||||
</body>
|
||||
</html>
|
||||
5
browsers.idx
Normal file
5
browsers.idx
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
nimTitle browsers browsers.html module std/browsers 0
|
||||
nim osOpenCmd browsers.html#osOpenCmd const osOpenCmd 32
|
||||
nim openDefaultBrowser browsers.html#openDefaultBrowser,string proc openDefaultBrowser(url: string) 61
|
||||
nim openDefaultBrowser browsers.html#openDefaultBrowser proc openDefaultBrowser() 78
|
||||
nimgrp opendefaultbrowser browsers.html#openDefaultBrowser-procs-all proc 61
|
||||
|
|
@ -1 +0,0 @@
|
|||
This file keeps several tools from deleting this subdirectory.
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
@echo off
|
||||
rem DO NO EDIT DIRECTLY! auto-generated by `nim r tools/ci_generate.nim`
|
||||
rem Build development version of the compiler; can be rerun safely
|
||||
rem bare bones version of ci/funs.sh adapted for windows.
|
||||
|
||||
rem Read in some common shared variables (shared with other tools),
|
||||
rem see https://stackoverflow.com/questions/3068929/how-to-read-file-contents-into-a-variable-in-a-batch-file
|
||||
for /f "delims== tokens=1,2" %%G in (config/build_config.txt) do set %%G=%%H
|
||||
SET nim_csources=bin\nim_csources_%nim_csourcesHash%.exe
|
||||
echo "building from csources: %nim_csources%"
|
||||
|
||||
if not exist %nim_csourcesDir% (
|
||||
git clone -q --depth 1 -b %nim_csourcesBranch% %nim_csourcesUrl% %nim_csourcesDir%
|
||||
)
|
||||
|
||||
if not exist %nim_csources% (
|
||||
cd %nim_csourcesDir%
|
||||
git checkout %nim_csourcesHash%
|
||||
echo "%PROCESSOR_ARCHITECTURE%"
|
||||
if "%PROCESSOR_ARCHITECTURE%"=="AMD64" (
|
||||
SET ARCH=64
|
||||
)
|
||||
CALL build.bat
|
||||
cd ..
|
||||
copy /y bin\nim.exe %nim_csources%
|
||||
)
|
||||
bin\nim.exe c --noNimblePath --skipUserCfg --skipParentCfg --hints:off koch
|
||||
koch boot -d:release --skipUserCfg --skipParentCfg --hints:off
|
||||
koch tools --skipUserCfg --skipParentCfg --hints:off
|
||||
17
build_all.sh
17
build_all.sh
|
|
@ -1,17 +0,0 @@
|
|||
#!/bin/sh
|
||||
# DO NO EDIT DIRECTLY! auto-generated by `nim r tools/ci_generate.nim`
|
||||
|
||||
# build development version of the compiler; can be rerun safely.
|
||||
# arguments can be passed, e.g.:
|
||||
# CC=gcc ucpu=amd64 uos=darwin
|
||||
|
||||
set -u # error on undefined variables
|
||||
set -e # exit on first error
|
||||
|
||||
. ci/funs.sh
|
||||
nimBuildCsourcesIfNeeded "$@"
|
||||
|
||||
echo_run bin/nim c --noNimblePath --skipUserCfg --skipParentCfg --hints:off koch
|
||||
echo_run ./koch boot -d:release --skipUserCfg --skipParentCfg --hints:off
|
||||
echo_run ./koch tools --skipUserCfg --skipParentCfg --hints:off
|
||||
|
||||
992
cgi.html
Normal file
992
cgi.html
Normal file
|
|
@ -0,0 +1,992 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<!-- This file is generated by Nim. -->
|
||||
<html xmlns="https://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>std/cgi</title>
|
||||
|
||||
<!-- Favicon -->
|
||||
<link rel="shortcut icon" href="data:image/x-icon;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAUAAAAF////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAIAAABbAAAAlQAAAKIAAACbAAAAmwAAAKIAAACVAAAAWwAAAAL///8A////AP///wD///8A////AAAAABQAAADAAAAAYwAAAA3///8A////AP///wD///8AAAAADQAAAGMAAADAAAAAFP///wD///8A////AP///wAAAACdAAAAOv///wD///8A////AP///wD///8A////AP///wD///8AAAAAOgAAAJ3///8A////AP///wAAAAAnAAAAcP///wAAAAAoAAAASv///wD///8A////AP///wAAAABKAAAAKP///wAAAABwAAAAJ////wD///8AAAAAgQAAABwAAACIAAAAkAAAAJMAAACtAAAAFQAAABUAAACtAAAAkwAAAJAAAACIAAAAHAAAAIH///8A////AAAAAKQAAACrAAAAaP///wD///8AAAAARQAAANIAAADSAAAARf///wD///8AAAAAaAAAAKsAAACk////AAAAADMAAACcAAAAnQAAABj///8A////AP///wAAAAAYAAAAGP///wD///8A////AAAAABgAAACdAAAAnAAAADMAAAB1AAAAwwAAAP8AAADpAAAAsQAAAE4AAAAb////AP///wAAAAAbAAAATgAAALEAAADpAAAA/wAAAMMAAAB1AAAAtwAAAOkAAAD/AAAA/wAAAP8AAADvAAAA3gAAAN4AAADeAAAA3gAAAO8AAAD/AAAA/wAAAP8AAADpAAAAtwAAAGUAAAA/AAAA3wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAADfAAAAPwAAAGX///8A////AAAAAEgAAADtAAAAvwAAAL0AAADGAAAA7wAAAO8AAADGAAAAvQAAAL8AAADtAAAASP///wD///8A////AP///wD///8AAAAAO////wD///8A////AAAAAIcAAACH////AP///wD///8AAAAAO////wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A//8AAP//AAD4HwAA7/cAAN/7AAD//wAAoYUAAJ55AACf+QAAh+EAAAAAAADAAwAA4AcAAP5/AAD//wAA//8AAA=="/>
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAA3XAAAN1wFCKJt4AAAAB3RJTUUH4QQQEwksSS9ZWwAAAk1JREFUWMPtll2ITVEUx39nn/O7Y5qR8f05wtCUUr6ZIS++8pEnkZInPImneaCQ5METNdOkeFBKUhMPRIkHKfEuUZSUlGlKPN2TrgfncpvmnntnmlEyq1Z7t89/rf9a6+y99oZxGZf/XeIq61EdtgKXgdXA0xrYAvBjOIF1AI9zvjcC74BSpndrJPkBWDScTF8Aa4E3wDlgHbASaANmVqlcCnwHvgDvgVfAJ+AikAAvgfVZwLnSVZHZaOuKoQi3ZOMi4NkYkpe1p4J7A8BpYAD49hfIy/oqG0+hLomiKP2L5L+1ubn5115S+3OAn4EnwBlgMzCjyt6ZAnQCJ4A7wOs88iRJHvw50HoujuPBoCKwHWiosy8MdfZnAdcHk8dxXFJ3VQbQlCTJvRBCGdRbD4M6uc5glpY3eAihpN5S5w12diSEcCCEcKUO4ljdr15T76ur1FDDLIQQ3qv71EdDOe3Kxj3leRXyk+pxdWnFWod6Wt2bY3de3aSuUHcPBVimHs7mK9WrmeOF6lR1o9qnzskh2ar2qm1qizpfXaPeVGdlmGN5pb09qMxz1Xb1kLqgzn1RyH7JUXW52lr5e/Kqi9qpto7V1atuUzfnARrV7jEib1T76gG2qxdGmXyiekkt1GswPTtek0aBfJp6YySGBfWg2tPQ0FAYgf1stUfdmdcjarbYJEniKIq6gY/Aw+zWHAC+p2labGpqiorFYgGYCEzN7oQdQClN07O1/EfDyGgC0ALMBdYAi4FyK+4H3gLPsxfR1zRNi+NP7nH5J+QntnXe5B5mpfQAAAAASUVORK5CYII=">
|
||||
|
||||
<!-- CSS -->
|
||||
<link rel="stylesheet" type="text/css" href="nimdoc.out.css">
|
||||
|
||||
<!-- JS -->
|
||||
<script type="text/javascript" src="dochack.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="document" id="documentId">
|
||||
<div class="container">
|
||||
<h1 class="title">std/cgi</h1>
|
||||
<div class="row">
|
||||
<div class="three columns">
|
||||
<div class="theme-select-wrapper">
|
||||
<label for="theme-select">Theme: </label>
|
||||
<select id="theme-select" onchange="setTheme(this.value)">
|
||||
<option value="auto">🌗 Match OS</option>
|
||||
<option value="dark">🌑 Dark</option>
|
||||
<option value="light">🌕 Light</option>
|
||||
</select>
|
||||
</div>
|
||||
<div id="global-links">
|
||||
<ul class="simple-boot">
|
||||
<li><a href="manual.html">Manual</a></li>
|
||||
<li><a href="lib.html">Standard library</a></li>
|
||||
<li> <a id="indexLink" href="theindex.html">Index</a></li>
|
||||
<li><a href="compiler/theindex.html">Compiler docs</a></li>
|
||||
<li><a href="https://nim-lang.github.io/fusion/theindex.html">Fusion docs</a></li>
|
||||
<li><a href="https://nim-lang.github.io/Nim/">devel</a>, <a href="https://nim-lang.org/documentation.html">stable</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="searchInputDiv">
|
||||
Search: <input type="search" id="searchInput"
|
||||
onkeyup="search()" />
|
||||
</div>
|
||||
|
||||
<ul class="simple simple-toc" id="toc-list">
|
||||
<li>
|
||||
<a class="reference reference-toplevel" href="#6" id="56">Imports</a>
|
||||
</li>
|
||||
<li>
|
||||
<details open>
|
||||
<summary><a class="reference reference-toplevel" href="#7" id="57">Types</a></summary>
|
||||
<ul class="simple simple-toc-section">
|
||||
<li><a class="reference" href="#CgiError" title="CgiError = object of IOError">CgiError</a></li>
|
||||
<li><a class="reference" href="#RequestMethod" title="RequestMethod = enum
|
||||
methodNone, ## no REQUEST_METHOD environment variable
|
||||
methodPost, ## query uses the POST method
|
||||
methodGet ## query uses the GET method">RequestMethod</a></li>
|
||||
|
||||
</ul>
|
||||
</details>
|
||||
</li>
|
||||
<li>
|
||||
<details open>
|
||||
<summary><a class="reference reference-toplevel" href="#12" id="62">Procs</a></summary>
|
||||
<ul class="simple simple-toc-section">
|
||||
<ul class="simple nested-toc-section">cgiError
|
||||
<li><a class="reference" href="#cgiError%2Cstring" title="cgiError(msg: string)">cgiError(msg: string)</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">existsCookie
|
||||
<li><a class="reference" href="#existsCookie%2Cstring" title="existsCookie(name: string): bool">existsCookie(name: string): bool</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">getContentLength
|
||||
<li><a class="reference" href="#getContentLength" title="getContentLength(): string">getContentLength(): string</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">getContentType
|
||||
<li><a class="reference" href="#getContentType" title="getContentType(): string">getContentType(): string</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">getCookie
|
||||
<li><a class="reference" href="#getCookie%2Cstring" title="getCookie(name: string): string">getCookie(name: string): string</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">getDocumentRoot
|
||||
<li><a class="reference" href="#getDocumentRoot" title="getDocumentRoot(): string">getDocumentRoot(): string</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">getGatewayInterface
|
||||
<li><a class="reference" href="#getGatewayInterface" title="getGatewayInterface(): string">getGatewayInterface(): string</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">getHttpAccept
|
||||
<li><a class="reference" href="#getHttpAccept" title="getHttpAccept(): string">getHttpAccept(): string</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">getHttpAcceptCharset
|
||||
<li><a class="reference" href="#getHttpAcceptCharset" title="getHttpAcceptCharset(): string">getHttpAcceptCharset(): string</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">getHttpAcceptEncoding
|
||||
<li><a class="reference" href="#getHttpAcceptEncoding" title="getHttpAcceptEncoding(): string">getHttpAcceptEncoding(): string</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">getHttpAcceptLanguage
|
||||
<li><a class="reference" href="#getHttpAcceptLanguage" title="getHttpAcceptLanguage(): string">getHttpAcceptLanguage(): string</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">getHttpConnection
|
||||
<li><a class="reference" href="#getHttpConnection" title="getHttpConnection(): string">getHttpConnection(): string</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">getHttpCookie
|
||||
<li><a class="reference" href="#getHttpCookie" title="getHttpCookie(): string">getHttpCookie(): string</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">getHttpHost
|
||||
<li><a class="reference" href="#getHttpHost" title="getHttpHost(): string">getHttpHost(): string</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">getHttpReferer
|
||||
<li><a class="reference" href="#getHttpReferer" title="getHttpReferer(): string">getHttpReferer(): string</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">getHttpUserAgent
|
||||
<li><a class="reference" href="#getHttpUserAgent" title="getHttpUserAgent(): string">getHttpUserAgent(): string</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">getPathInfo
|
||||
<li><a class="reference" href="#getPathInfo" title="getPathInfo(): string">getPathInfo(): string</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">getPathTranslated
|
||||
<li><a class="reference" href="#getPathTranslated" title="getPathTranslated(): string">getPathTranslated(): string</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">getQueryString
|
||||
<li><a class="reference" href="#getQueryString" title="getQueryString(): string">getQueryString(): string</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">getRemoteAddr
|
||||
<li><a class="reference" href="#getRemoteAddr" title="getRemoteAddr(): string">getRemoteAddr(): string</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">getRemoteHost
|
||||
<li><a class="reference" href="#getRemoteHost" title="getRemoteHost(): string">getRemoteHost(): string</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">getRemoteIdent
|
||||
<li><a class="reference" href="#getRemoteIdent" title="getRemoteIdent(): string">getRemoteIdent(): string</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">getRemotePort
|
||||
<li><a class="reference" href="#getRemotePort" title="getRemotePort(): string">getRemotePort(): string</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">getRemoteUser
|
||||
<li><a class="reference" href="#getRemoteUser" title="getRemoteUser(): string">getRemoteUser(): string</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">getRequestMethod
|
||||
<li><a class="reference" href="#getRequestMethod" title="getRequestMethod(): string">getRequestMethod(): string</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">getRequestURI
|
||||
<li><a class="reference" href="#getRequestURI" title="getRequestURI(): string">getRequestURI(): string</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">getScriptFilename
|
||||
<li><a class="reference" href="#getScriptFilename" title="getScriptFilename(): string">getScriptFilename(): string</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">getScriptName
|
||||
<li><a class="reference" href="#getScriptName" title="getScriptName(): string">getScriptName(): string</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">getServerAddr
|
||||
<li><a class="reference" href="#getServerAddr" title="getServerAddr(): string">getServerAddr(): string</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">getServerAdmin
|
||||
<li><a class="reference" href="#getServerAdmin" title="getServerAdmin(): string">getServerAdmin(): string</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">getServerName
|
||||
<li><a class="reference" href="#getServerName" title="getServerName(): string">getServerName(): string</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">getServerPort
|
||||
<li><a class="reference" href="#getServerPort" title="getServerPort(): string">getServerPort(): string</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">getServerProtocol
|
||||
<li><a class="reference" href="#getServerProtocol" title="getServerProtocol(): string">getServerProtocol(): string</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">getServerSignature
|
||||
<li><a class="reference" href="#getServerSignature" title="getServerSignature(): string">getServerSignature(): string</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">getServerSoftware
|
||||
<li><a class="reference" href="#getServerSoftware" title="getServerSoftware(): string">getServerSoftware(): string</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">readData
|
||||
<li><a class="reference" href="#readData%2Cset%5BRequestMethod%5D" title="readData(allowedMethods: set[RequestMethod] = {methodNone, methodPost, methodGet}): StringTableRef">readData(allowedMethods: set[RequestMethod] = {methodNone, methodPost, methodGet}): StringTableRef</a></li>
|
||||
<li><a class="reference" href="#readData%2Cstring" title="readData(data: string): StringTableRef">readData(data: string): StringTableRef</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">setCookie
|
||||
<li><a class="reference" href="#setCookie%2Cstring%2Cstring" title="setCookie(name, value: string)">setCookie(name, value: string)</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">setStackTraceStdout
|
||||
<li><a class="reference" href="#setStackTraceStdout" title="setStackTraceStdout()">setStackTraceStdout()</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">setTestData
|
||||
<li><a class="reference" href="#setTestData%2Cvarargs%5Bstring%5D" title="setTestData(keysvalues: varargs[string])">setTestData(keysvalues: varargs[string])</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">validateData
|
||||
<li><a class="reference" href="#validateData%2CStringTableRef%2Cvarargs%5Bstring%5D" title="validateData(data: StringTableRef; validKeys: varargs[string])">validateData(data: StringTableRef; validKeys: varargs[string])</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">writeContentType
|
||||
<li><a class="reference" href="#writeContentType" title="writeContentType()">writeContentType()</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">writeErrorMessage
|
||||
<li><a class="reference" href="#writeErrorMessage%2Cstring" title="writeErrorMessage(data: string)">writeErrorMessage(data: string)</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">xmlEncode
|
||||
<li><a class="reference" href="#xmlEncode%2Cstring" title="xmlEncode(s: string): string">xmlEncode(s: string): string</a></li>
|
||||
|
||||
</ul>
|
||||
|
||||
</ul>
|
||||
</details>
|
||||
</li>
|
||||
<li>
|
||||
<details open>
|
||||
<summary><a class="reference reference-toplevel" href="#15" id="65">Iterators</a></summary>
|
||||
<ul class="simple simple-toc-section">
|
||||
<ul class="simple nested-toc-section">decodeData
|
||||
<li><a class="reference" href="#decodeData.i%2Cset%5BRequestMethod%5D" title="decodeData(allowedMethods: set[RequestMethod] = {methodNone, methodPost,
|
||||
methodGet}): tuple[key, value: string]">decodeData(allowedMethods: set[RequestMethod] = {methodNone, methodPost,
|
||||
methodGet}): tuple[key, value: string]</a></li>
|
||||
<li><a class="reference" href="#decodeData.i%2Cstring" title="decodeData(data: string): tuple[key, value: string]">decodeData(data: string): tuple[key, value: string]</a></li>
|
||||
|
||||
</ul>
|
||||
|
||||
</ul>
|
||||
</details>
|
||||
</li>
|
||||
<li>
|
||||
<a class="reference reference-toplevel" href="#19" id="69">Exports</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
<div class="nine columns" id="content">
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/cgi.nim#L1" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/cgi.nim#L1" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
<div id="tocRoot"></div>
|
||||
|
||||
<p class="module-desc"><p>This module implements helper procs for CGI applications. Example:</p>
|
||||
<p><pre class="listing">
|
||||
<span class="Keyword">import</span> <span class="Identifier">std</span><span class="Operator">/</span><span class="Punctuation">[</span><span class="Identifier">strtabs</span><span class="Punctuation">,</span> <span class="Identifier">cgi</span><span class="Punctuation">]</span>
|
||||
|
||||
<span class="Comment"># Fill the values when debugging:</span>
|
||||
<span class="Keyword">when</span> <span class="Identifier">debug</span><span class="Punctuation">:</span>
|
||||
<span class="Identifier">setTestData</span><span class="Punctuation">(</span><span class="StringLit">"name"</span><span class="Punctuation">,</span> <span class="StringLit">"Klaus"</span><span class="Punctuation">,</span> <span class="StringLit">"password"</span><span class="Punctuation">,</span> <span class="StringLit">"123456"</span><span class="Punctuation">)</span>
|
||||
<span class="Comment"># read the data into `myData`</span>
|
||||
<span class="Keyword">var</span> <span class="Identifier">myData</span> <span class="Operator">=</span> <span class="Identifier">readData</span><span class="Punctuation">(</span><span class="Punctuation">)</span>
|
||||
<span class="Comment"># check that the data's variable names are "name" or "password"</span>
|
||||
<span class="Identifier">validateData</span><span class="Punctuation">(</span><span class="Identifier">myData</span><span class="Punctuation">,</span> <span class="StringLit">"name"</span><span class="Punctuation">,</span> <span class="StringLit">"password"</span><span class="Punctuation">)</span>
|
||||
<span class="Comment"># start generating content:</span>
|
||||
<span class="Identifier">writeContentType</span><span class="Punctuation">(</span><span class="Punctuation">)</span>
|
||||
<span class="Comment"># generate content:</span>
|
||||
<span class="Identifier">write</span><span class="Punctuation">(</span><span class="Identifier">stdout</span><span class="Punctuation">,</span> <span class="StringLit">"<!DOCTYPE HTML PUBLIC </span><span class="EscapeSequence">\"</span><span class="StringLit">-//W3C//DTD HTML 4.01//EN</span><span class="EscapeSequence">\"</span><span class="StringLit">></span><span class="EscapeSequence">\n</span><span class="StringLit">"</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">write</span><span class="Punctuation">(</span><span class="Identifier">stdout</span><span class="Punctuation">,</span> <span class="StringLit">"<html><head><title>Test</title></head><body></span><span class="EscapeSequence">\n</span><span class="StringLit">"</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">writeLine</span><span class="Punctuation">(</span><span class="Identifier">stdout</span><span class="Punctuation">,</span> <span class="StringLit">"your name: "</span> <span class="Operator">&</span> <span class="Identifier">myData</span><span class="Punctuation">[</span><span class="StringLit">"name"</span><span class="Punctuation">]</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">writeLine</span><span class="Punctuation">(</span><span class="Identifier">stdout</span><span class="Punctuation">,</span> <span class="StringLit">"your password: "</span> <span class="Operator">&</span> <span class="Identifier">myData</span><span class="Punctuation">[</span><span class="StringLit">"password"</span><span class="Punctuation">]</span><span class="Punctuation">)</span>
|
||||
<span class="Identifier">writeLine</span><span class="Punctuation">(</span><span class="Identifier">stdout</span><span class="Punctuation">,</span> <span class="StringLit">"</body></html>"</span><span class="Punctuation">)</span></pre></p>
|
||||
</p>
|
||||
<div class="section" id="6">
|
||||
<h1><a class="toc-backref" href="#6">Imports</a></h1>
|
||||
<dl class="item">
|
||||
<a class="reference external" href="strutils.html">strutils</a>, <a class="reference external" href="os.html">os</a>, <a class="reference external" href="strtabs.html">strtabs</a>, <a class="reference external" href="cookies.html">cookies</a>, <a class="reference external" href="uri.html">uri</a>, <a class="reference external" href="syncio.html">syncio</a>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="section" id="7">
|
||||
<h1><a class="toc-backref" href="#7">Types</a></h1>
|
||||
<dl class="item">
|
||||
<div id="CgiError">
|
||||
<dt><pre><a href="cgi.html#CgiError"><span class="Identifier">CgiError</span></a> <span class="Other">=</span> <span class="Keyword">object</span> <span class="Keyword">of</span> <a href="exceptions.html#IOError"><span class="Identifier">IOError</span></a></pre></dt>
|
||||
<dd>
|
||||
|
||||
Exception that is raised if a CGI error occurs.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/cgi.nim#L58" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/cgi.nim#L58" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
<div id="RequestMethod">
|
||||
<dt><pre><a href="cgi.html#RequestMethod"><span class="Identifier">RequestMethod</span></a> <span class="Other">=</span> <span class="Keyword">enum</span>
|
||||
<span class="Identifier">methodNone</span><span class="Other">,</span> <span class="Comment">## no REQUEST_METHOD environment variable</span>
|
||||
<span class="Identifier">methodPost</span><span class="Other">,</span> <span class="Comment">## query uses the POST method</span>
|
||||
<span class="Identifier">methodGet</span> <span class="Comment">## query uses the GET method</span></pre></dt>
|
||||
<dd>
|
||||
|
||||
The used request method.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/cgi.nim#L59" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/cgi.nim#L59" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</dl>
|
||||
</div>
|
||||
<div class="section" id="12">
|
||||
<h1><a class="toc-backref" href="#12">Procs</a></h1>
|
||||
<dl class="item">
|
||||
<div id="cgiError-procs-all">
|
||||
<div id="cgiError,string">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#cgiError%2Cstring"><span class="Identifier">cgiError</span></a><span class="Other">(</span><span class="Identifier">msg</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">)</span> {.<span class="Identifier">noreturn</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">CgiError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Raises a <tt class="docutils literal"><span class="pre"><span class="Identifier">CgiError</span></span></tt> exception with message <tt class="docutils literal"><span class="pre"><span class="Identifier">msg</span></span></tt>.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/cgi.nim#L64" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/cgi.nim#L64" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="existsCookie-procs-all">
|
||||
<div id="existsCookie,string">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#existsCookie%2Cstring"><span class="Identifier">existsCookie</span></a><span class="Other">(</span><span class="Identifier">name</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#bool"><span class="Identifier">bool</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ReadEnvEffect</span><span class="Other">]</span><span class="Other">,</span>
|
||||
<span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Checks if a cookie of <tt class="docutils literal"><span class="pre"><span class="Identifier">name</span></span></tt> exists.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/cgi.nim#L312" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/cgi.nim#L312" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="getContentLength-procs-all">
|
||||
<div id="getContentLength">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#getContentLength"><span class="Identifier">getContentLength</span></a><span class="Other">(</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ReadEnvEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Returns contents of the <tt class="docutils literal"><span class="pre"><span class="Identifier">CONTENT_LENGTH</span></span></tt> environment variable.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/cgi.nim#L123" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/cgi.nim#L123" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="getContentType-procs-all">
|
||||
<div id="getContentType">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#getContentType"><span class="Identifier">getContentType</span></a><span class="Other">(</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ReadEnvEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Returns contents of the <tt class="docutils literal"><span class="pre"><span class="Identifier">CONTENT_TYPE</span></span></tt> environment variable.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/cgi.nim#L127" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/cgi.nim#L127" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="getCookie-procs-all">
|
||||
<div id="getCookie,string">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#getCookie%2Cstring"><span class="Identifier">getCookie</span></a><span class="Other">(</span><span class="Identifier">name</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ReadEnvEffect</span><span class="Other">]</span><span class="Other">,</span>
|
||||
<span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Gets a cookie. If no cookie of <tt class="docutils literal"><span class="pre"><span class="Identifier">name</span></span></tt> exists, "" is returned.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/cgi.nim#L307" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/cgi.nim#L307" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="getDocumentRoot-procs-all">
|
||||
<div id="getDocumentRoot">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#getDocumentRoot"><span class="Identifier">getDocumentRoot</span></a><span class="Other">(</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ReadEnvEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Returns contents of the <tt class="docutils literal"><span class="pre"><span class="Identifier">DOCUMENT_ROOT</span></span></tt> environment variable.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/cgi.nim#L131" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/cgi.nim#L131" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="getGatewayInterface-procs-all">
|
||||
<div id="getGatewayInterface">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#getGatewayInterface"><span class="Identifier">getGatewayInterface</span></a><span class="Other">(</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ReadEnvEffect</span><span class="Other">]</span><span class="Other">,</span>
|
||||
<span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Returns contents of the <tt class="docutils literal"><span class="pre"><span class="Identifier">GATEWAY_INTERFACE</span></span></tt> environment variable.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/cgi.nim#L135" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/cgi.nim#L135" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="getHttpAccept-procs-all">
|
||||
<div id="getHttpAccept">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#getHttpAccept"><span class="Identifier">getHttpAccept</span></a><span class="Other">(</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ReadEnvEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Returns contents of the <tt class="docutils literal"><span class="pre"><span class="Identifier">HTTP_ACCEPT</span></span></tt> environment variable.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/cgi.nim#L139" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/cgi.nim#L139" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="getHttpAcceptCharset-procs-all">
|
||||
<div id="getHttpAcceptCharset">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#getHttpAcceptCharset"><span class="Identifier">getHttpAcceptCharset</span></a><span class="Other">(</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ReadEnvEffect</span><span class="Other">]</span><span class="Other">,</span>
|
||||
<span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Returns contents of the <tt class="docutils literal"><span class="pre"><span class="Identifier">HTTP_ACCEPT_CHARSET</span></span></tt> environment variable.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/cgi.nim#L143" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/cgi.nim#L143" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="getHttpAcceptEncoding-procs-all">
|
||||
<div id="getHttpAcceptEncoding">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#getHttpAcceptEncoding"><span class="Identifier">getHttpAcceptEncoding</span></a><span class="Other">(</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ReadEnvEffect</span><span class="Other">]</span><span class="Other">,</span>
|
||||
<span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Returns contents of the <tt class="docutils literal"><span class="pre"><span class="Identifier">HTTP_ACCEPT_ENCODING</span></span></tt> environment variable.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/cgi.nim#L147" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/cgi.nim#L147" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="getHttpAcceptLanguage-procs-all">
|
||||
<div id="getHttpAcceptLanguage">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#getHttpAcceptLanguage"><span class="Identifier">getHttpAcceptLanguage</span></a><span class="Other">(</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ReadEnvEffect</span><span class="Other">]</span><span class="Other">,</span>
|
||||
<span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Returns contents of the <tt class="docutils literal"><span class="pre"><span class="Identifier">HTTP_ACCEPT_LANGUAGE</span></span></tt> environment variable.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/cgi.nim#L151" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/cgi.nim#L151" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="getHttpConnection-procs-all">
|
||||
<div id="getHttpConnection">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#getHttpConnection"><span class="Identifier">getHttpConnection</span></a><span class="Other">(</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ReadEnvEffect</span><span class="Other">]</span><span class="Other">,</span>
|
||||
<span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Returns contents of the <tt class="docutils literal"><span class="pre"><span class="Identifier">HTTP_CONNECTION</span></span></tt> environment variable.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/cgi.nim#L155" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/cgi.nim#L155" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="getHttpCookie-procs-all">
|
||||
<div id="getHttpCookie">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#getHttpCookie"><span class="Identifier">getHttpCookie</span></a><span class="Other">(</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ReadEnvEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Returns contents of the <tt class="docutils literal"><span class="pre"><span class="Identifier">HTTP_COOKIE</span></span></tt> environment variable.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/cgi.nim#L159" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/cgi.nim#L159" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="getHttpHost-procs-all">
|
||||
<div id="getHttpHost">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#getHttpHost"><span class="Identifier">getHttpHost</span></a><span class="Other">(</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ReadEnvEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Returns contents of the <tt class="docutils literal"><span class="pre"><span class="Identifier">HTTP_HOST</span></span></tt> environment variable.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/cgi.nim#L163" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/cgi.nim#L163" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="getHttpReferer-procs-all">
|
||||
<div id="getHttpReferer">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#getHttpReferer"><span class="Identifier">getHttpReferer</span></a><span class="Other">(</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ReadEnvEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Returns contents of the <tt class="docutils literal"><span class="pre"><span class="Identifier">HTTP_REFERER</span></span></tt> environment variable.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/cgi.nim#L167" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/cgi.nim#L167" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="getHttpUserAgent-procs-all">
|
||||
<div id="getHttpUserAgent">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#getHttpUserAgent"><span class="Identifier">getHttpUserAgent</span></a><span class="Other">(</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ReadEnvEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Returns contents of the <tt class="docutils literal"><span class="pre"><span class="Identifier">HTTP_USER_AGENT</span></span></tt> environment variable.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/cgi.nim#L171" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/cgi.nim#L171" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="getPathInfo-procs-all">
|
||||
<div id="getPathInfo">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#getPathInfo"><span class="Identifier">getPathInfo</span></a><span class="Other">(</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ReadEnvEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Returns contents of the <tt class="docutils literal"><span class="pre"><span class="Identifier">PATH_INFO</span></span></tt> environment variable.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/cgi.nim#L175" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/cgi.nim#L175" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="getPathTranslated-procs-all">
|
||||
<div id="getPathTranslated">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#getPathTranslated"><span class="Identifier">getPathTranslated</span></a><span class="Other">(</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ReadEnvEffect</span><span class="Other">]</span><span class="Other">,</span>
|
||||
<span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Returns contents of the <tt class="docutils literal"><span class="pre"><span class="Identifier">PATH_TRANSLATED</span></span></tt> environment variable.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/cgi.nim#L179" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/cgi.nim#L179" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="getQueryString-procs-all">
|
||||
<div id="getQueryString">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#getQueryString"><span class="Identifier">getQueryString</span></a><span class="Other">(</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ReadEnvEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Returns contents of the <tt class="docutils literal"><span class="pre"><span class="Identifier">QUERY_STRING</span></span></tt> environment variable.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/cgi.nim#L183" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/cgi.nim#L183" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="getRemoteAddr-procs-all">
|
||||
<div id="getRemoteAddr">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#getRemoteAddr"><span class="Identifier">getRemoteAddr</span></a><span class="Other">(</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ReadEnvEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Returns contents of the <tt class="docutils literal"><span class="pre"><span class="Identifier">REMOTE_ADDR</span></span></tt> environment variable.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/cgi.nim#L187" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/cgi.nim#L187" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="getRemoteHost-procs-all">
|
||||
<div id="getRemoteHost">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#getRemoteHost"><span class="Identifier">getRemoteHost</span></a><span class="Other">(</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ReadEnvEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Returns contents of the <tt class="docutils literal"><span class="pre"><span class="Identifier">REMOTE_HOST</span></span></tt> environment variable.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/cgi.nim#L191" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/cgi.nim#L191" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="getRemoteIdent-procs-all">
|
||||
<div id="getRemoteIdent">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#getRemoteIdent"><span class="Identifier">getRemoteIdent</span></a><span class="Other">(</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ReadEnvEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Returns contents of the <tt class="docutils literal"><span class="pre"><span class="Identifier">REMOTE_IDENT</span></span></tt> environment variable.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/cgi.nim#L195" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/cgi.nim#L195" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="getRemotePort-procs-all">
|
||||
<div id="getRemotePort">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#getRemotePort"><span class="Identifier">getRemotePort</span></a><span class="Other">(</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ReadEnvEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Returns contents of the <tt class="docutils literal"><span class="pre"><span class="Identifier">REMOTE_PORT</span></span></tt> environment variable.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/cgi.nim#L199" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/cgi.nim#L199" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="getRemoteUser-procs-all">
|
||||
<div id="getRemoteUser">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#getRemoteUser"><span class="Identifier">getRemoteUser</span></a><span class="Other">(</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ReadEnvEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Returns contents of the <tt class="docutils literal"><span class="pre"><span class="Identifier">REMOTE_USER</span></span></tt> environment variable.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/cgi.nim#L203" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/cgi.nim#L203" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="getRequestMethod-procs-all">
|
||||
<div id="getRequestMethod">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#getRequestMethod"><span class="Identifier">getRequestMethod</span></a><span class="Other">(</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ReadEnvEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Returns contents of the <tt class="docutils literal"><span class="pre"><span class="Identifier">REQUEST_METHOD</span></span></tt> environment variable.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/cgi.nim#L207" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/cgi.nim#L207" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="getRequestURI-procs-all">
|
||||
<div id="getRequestURI">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#getRequestURI"><span class="Identifier">getRequestURI</span></a><span class="Other">(</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ReadEnvEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Returns contents of the <tt class="docutils literal"><span class="pre"><span class="Identifier">REQUEST_URI</span></span></tt> environment variable.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/cgi.nim#L211" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/cgi.nim#L211" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="getScriptFilename-procs-all">
|
||||
<div id="getScriptFilename">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#getScriptFilename"><span class="Identifier">getScriptFilename</span></a><span class="Other">(</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ReadEnvEffect</span><span class="Other">]</span><span class="Other">,</span>
|
||||
<span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Returns contents of the <tt class="docutils literal"><span class="pre"><span class="Identifier">SCRIPT_FILENAME</span></span></tt> environment variable.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/cgi.nim#L215" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/cgi.nim#L215" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="getScriptName-procs-all">
|
||||
<div id="getScriptName">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#getScriptName"><span class="Identifier">getScriptName</span></a><span class="Other">(</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ReadEnvEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Returns contents of the <tt class="docutils literal"><span class="pre"><span class="Identifier">SCRIPT_NAME</span></span></tt> environment variable.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/cgi.nim#L219" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/cgi.nim#L219" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="getServerAddr-procs-all">
|
||||
<div id="getServerAddr">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#getServerAddr"><span class="Identifier">getServerAddr</span></a><span class="Other">(</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ReadEnvEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Returns contents of the <tt class="docutils literal"><span class="pre"><span class="Identifier">SERVER_ADDR</span></span></tt> environment variable.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/cgi.nim#L223" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/cgi.nim#L223" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="getServerAdmin-procs-all">
|
||||
<div id="getServerAdmin">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#getServerAdmin"><span class="Identifier">getServerAdmin</span></a><span class="Other">(</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ReadEnvEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Returns contents of the <tt class="docutils literal"><span class="pre"><span class="Identifier">SERVER_ADMIN</span></span></tt> environment variable.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/cgi.nim#L227" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/cgi.nim#L227" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="getServerName-procs-all">
|
||||
<div id="getServerName">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#getServerName"><span class="Identifier">getServerName</span></a><span class="Other">(</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ReadEnvEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Returns contents of the <tt class="docutils literal"><span class="pre"><span class="Identifier">SERVER_NAME</span></span></tt> environment variable.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/cgi.nim#L231" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/cgi.nim#L231" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="getServerPort-procs-all">
|
||||
<div id="getServerPort">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#getServerPort"><span class="Identifier">getServerPort</span></a><span class="Other">(</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ReadEnvEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Returns contents of the <tt class="docutils literal"><span class="pre"><span class="Identifier">SERVER_PORT</span></span></tt> environment variable.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/cgi.nim#L235" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/cgi.nim#L235" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="getServerProtocol-procs-all">
|
||||
<div id="getServerProtocol">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#getServerProtocol"><span class="Identifier">getServerProtocol</span></a><span class="Other">(</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ReadEnvEffect</span><span class="Other">]</span><span class="Other">,</span>
|
||||
<span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Returns contents of the <tt class="docutils literal"><span class="pre"><span class="Identifier">SERVER_PROTOCOL</span></span></tt> environment variable.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/cgi.nim#L239" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/cgi.nim#L239" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="getServerSignature-procs-all">
|
||||
<div id="getServerSignature">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#getServerSignature"><span class="Identifier">getServerSignature</span></a><span class="Other">(</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ReadEnvEffect</span><span class="Other">]</span><span class="Other">,</span>
|
||||
<span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Returns contents of the <tt class="docutils literal"><span class="pre"><span class="Identifier">SERVER_SIGNATURE</span></span></tt> environment variable.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/cgi.nim#L243" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/cgi.nim#L243" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="getServerSoftware-procs-all">
|
||||
<div id="getServerSoftware">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#getServerSoftware"><span class="Identifier">getServerSoftware</span></a><span class="Other">(</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ReadEnvEffect</span><span class="Other">]</span><span class="Other">,</span>
|
||||
<span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Returns contents of the <tt class="docutils literal"><span class="pre"><span class="Identifier">SERVER_SOFTWARE</span></span></tt> environment variable.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/cgi.nim#L247" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/cgi.nim#L247" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="readData-procs-all">
|
||||
<div id="readData,set[RequestMethod]">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#readData%2Cset%5BRequestMethod%5D"><span class="Identifier">readData</span></a><span class="Other">(</span><span class="Identifier">allowedMethods</span><span class="Other">:</span> <a href="system.html#set"><span class="Identifier">set</span></a><span class="Other">[</span><a href="cgi.html#RequestMethod"><span class="Identifier">RequestMethod</span></a><span class="Other">]</span> <span class="Other">=</span> <span class="Other">{</span><span class="Identifier">methodNone</span><span class="Other">,</span> <span class="Identifier">methodPost</span><span class="Other">,</span>
|
||||
<span class="Identifier">methodGet</span><span class="Other">}</span><span class="Other">)</span><span class="Other">:</span> <a href="strtabs.html#StringTableRef"><span class="Identifier">StringTableRef</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">CgiError</span><span class="Other">,</span> <span class="Identifier">ValueError</span><span class="Other">,</span> <span class="Identifier">IOError</span><span class="Other">]</span><span class="Other">,</span>
|
||||
<span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ReadEnvEffect</span><span class="Other">,</span> <span class="Identifier">ReadIOEffect</span><span class="Other">]</span><span class="Other">,</span>
|
||||
<span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Reads CGI data. If the client does not use a method listed in the <tt class="docutils literal"><span class="pre"><span class="Identifier">allowedMethods</span></span></tt> set, a <tt class="docutils literal"><span class="pre"><span class="Identifier">CgiError</span></span></tt> exception is raised.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/cgi.nim#L102" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/cgi.nim#L102" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
<div id="readData,string">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#readData%2Cstring"><span class="Identifier">readData</span></a><span class="Other">(</span><span class="Identifier">data</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">)</span><span class="Other">:</span> <a href="strtabs.html#StringTableRef"><span class="Identifier">StringTableRef</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Reads CGI data from a string.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/cgi.nim#L110" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/cgi.nim#L110" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="setCookie-procs-all">
|
||||
<div id="setCookie,string,string">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#setCookie%2Cstring%2Cstring"><span class="Identifier">setCookie</span></a><span class="Other">(</span><span class="Identifier">name</span><span class="Other">,</span> <span class="Identifier">value</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">IOError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">WriteIOEffect</span><span class="Other">]</span><span class="Other">,</span>
|
||||
<span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Sets a cookie.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/cgi.nim#L300" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/cgi.nim#L300" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="setStackTraceStdout-procs-all">
|
||||
<div id="setStackTraceStdout">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#setStackTraceStdout"><span class="Identifier">setStackTraceStdout</span></a><span class="Other">(</span><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Makes Nim output stacktraces to stdout, instead of server log.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/cgi.nim#L296" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/cgi.nim#L296" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="setTestData-procs-all">
|
||||
<div id="setTestData,varargs[string]">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#setTestData%2Cvarargs%5Bstring%5D"><span class="Identifier">setTestData</span></a><span class="Other">(</span><span class="Identifier">keysvalues</span><span class="Other">:</span> <a href="system.html#varargs"><span class="Identifier">varargs</span></a><span class="Other">[</span><a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">]</span><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">OSError</span><span class="Other">]</span><span class="Other">,</span>
|
||||
<span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">WriteEnvEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Fills the appropriate environment variables to test your CGI application. This can only simulate the 'GET' request method. <tt class="docutils literal"><span class="pre"><span class="Identifier">keysvalues</span></span></tt> should provide embedded (name, value)-pairs. Example:</p>
|
||||
<p><pre class="listing">
|
||||
<span class="Identifier">setTestData</span><span class="Punctuation">(</span><span class="StringLit">"name"</span><span class="Punctuation">,</span> <span class="StringLit">"Hanz"</span><span class="Punctuation">,</span> <span class="StringLit">"password"</span><span class="Punctuation">,</span> <span class="StringLit">"12345"</span><span class="Punctuation">)</span></pre></p>
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/cgi.nim#L251" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/cgi.nim#L251" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="validateData-procs-all">
|
||||
<div id="validateData,StringTableRef,varargs[string]">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#validateData%2CStringTableRef%2Cvarargs%5Bstring%5D"><span class="Identifier">validateData</span></a><span class="Other">(</span><span class="Identifier">data</span><span class="Other">:</span> <a href="strtabs.html#StringTableRef"><span class="Identifier">StringTableRef</span></a><span class="Other">;</span> <span class="Identifier">validKeys</span><span class="Other">:</span> <a href="system.html#varargs"><span class="Identifier">varargs</span></a><span class="Other">[</span><a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">]</span><span class="Other">)</span> {.
|
||||
<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">CgiError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Validates data; raises <tt class="docutils literal"><span class="pre"><span class="Identifier">CgiError</span></span></tt> if this fails. This checks that each variable name of the CGI <tt class="docutils literal"><span class="pre"><span class="Identifier">data</span></span></tt> occurs in the <tt class="docutils literal"><span class="pre"><span class="Identifier">validKeys</span></span></tt> array.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/cgi.nim#L116" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/cgi.nim#L116" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="writeContentType-procs-all">
|
||||
<div id="writeContentType">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#writeContentType"><span class="Identifier">writeContentType</span></a><span class="Other">(</span><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">IOError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">WriteIOEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Calls this before starting to send your HTML data to <tt class="docutils literal"><span class="pre"><span class="Identifier">stdout</span></span></tt>. This implements this part of the CGI protocol:</p>
|
||||
<p><pre class="listing">
|
||||
<span class="Identifier">write</span><span class="Punctuation">(</span><span class="Identifier">stdout</span><span class="Punctuation">,</span> <span class="StringLit">"Content-type: text/html</span><span class="EscapeSequence">\n</span><span class="EscapeSequence">\n</span><span class="StringLit">"</span><span class="Punctuation">)</span></pre></p>
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/cgi.nim#L269" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/cgi.nim#L269" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="writeErrorMessage-procs-all">
|
||||
<div id="writeErrorMessage,string">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#writeErrorMessage%2Cstring"><span class="Identifier">writeErrorMessage</span></a><span class="Other">(</span><span class="Identifier">data</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">)</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">IOError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">WriteIOEffect</span><span class="Other">]</span><span class="Other">,</span>
|
||||
<span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Tries to reset browser state and writes <tt class="docutils literal"><span class="pre"><span class="Identifier">data</span></span></tt> to stdout in <plaintext> tag.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/cgi.nim#L287" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/cgi.nim#L287" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="xmlEncode-procs-all">
|
||||
<div id="xmlEncode,string">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#xmlEncode%2Cstring"><span class="Identifier">xmlEncode</span></a><span class="Other">(</span><span class="Identifier">s</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Encodes a value to be XML safe:<ul class="simple"><li><tt class="docutils literal"><span class="pre"><span class="StringLit">"</span></span></tt> is replaced by <tt class="docutils literal"><span class="pre"><span class="Operator">&</span><span class="Identifier">quot</span><span class="Punctuation">;</span></span></tt></li>
|
||||
<li><tt class="docutils literal"><span class="pre"><span class="Operator"><</span></span></tt> is replaced by <tt class="docutils literal"><span class="pre"><span class="Operator">&</span><span class="Identifier">lt</span><span class="Punctuation">;</span></span></tt></li>
|
||||
<li><tt class="docutils literal"><span class="pre"><span class="Operator">></span></span></tt> is replaced by <tt class="docutils literal"><span class="pre"><span class="Operator">&</span><span class="Identifier">gt</span><span class="Punctuation">;</span></span></tt></li>
|
||||
<li><tt class="docutils literal"><span class="pre"><span class="Operator">&</span></span></tt> is replaced by <tt class="docutils literal"><span class="pre"><span class="Operator">&</span><span class="Identifier">amp</span><span class="Punctuation">;</span></span></tt></li>
|
||||
<li>every other character is carried over.</li>
|
||||
</ul>
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/cgi.nim#L47" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/cgi.nim#L47" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</dl>
|
||||
</div>
|
||||
<div class="section" id="15">
|
||||
<h1><a class="toc-backref" href="#15">Iterators</a></h1>
|
||||
<dl class="item">
|
||||
<div id="decodeData-iterators-all">
|
||||
<div id="decodeData.i,set[RequestMethod]">
|
||||
<dt><pre><span class="Keyword">iterator</span> <a href="#decodeData.i%2Cset%5BRequestMethod%5D"><span class="Identifier">decodeData</span></a><span class="Other">(</span><span class="Identifier">allowedMethods</span><span class="Other">:</span> <a href="system.html#set"><span class="Identifier">set</span></a><span class="Other">[</span><a href="cgi.html#RequestMethod"><span class="Identifier">RequestMethod</span></a><span class="Other">]</span> <span class="Other">=</span> <span class="Other">{</span><span class="Identifier">methodNone</span><span class="Other">,</span>
|
||||
<span class="Identifier">methodPost</span><span class="Other">,</span> <span class="Identifier">methodGet</span><span class="Other">}</span><span class="Other">)</span><span class="Other">:</span> <span class="Keyword">tuple</span><span class="Other">[</span><span class="Identifier">key</span><span class="Other">,</span> <span class="Identifier">value</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">]</span> {.
|
||||
<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">CgiError</span><span class="Other">,</span> <span class="Identifier">ValueError</span><span class="Other">,</span> <span class="Identifier">IOError</span><span class="Other">]</span><span class="Other">,</span>
|
||||
<span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ReadEnvEffect</span><span class="Other">,</span> <span class="Identifier">ReadIOEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Reads and decodes CGI data and yields the (name, value) pairs the data consists of. If the client does not use a method listed in the <tt class="docutils literal"><span class="pre"><span class="Identifier">allowedMethods</span></span></tt> set, a <tt class="docutils literal"><span class="pre"><span class="Identifier">CgiError</span></span></tt> exception is raised.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/cgi.nim#L93" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/cgi.nim#L93" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
<div id="decodeData.i,string">
|
||||
<dt><pre><span class="Keyword">iterator</span> <a href="#decodeData.i%2Cstring"><span class="Identifier">decodeData</span></a><span class="Other">(</span><span class="Identifier">data</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">)</span><span class="Other">:</span> <span class="Keyword">tuple</span><span class="Other">[</span><span class="Identifier">key</span><span class="Other">,</span> <span class="Identifier">value</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">]</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
|
||||
<span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
Reads and decodes CGI data and yields the (name, value) pairs the data consists of.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/cgi.nim#L87" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/cgi.nim#L87" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</dl>
|
||||
</div>
|
||||
<div class="section" id="19">
|
||||
<h1><a class="toc-backref" href="#19">Exports</a></h1>
|
||||
<dl class="item">
|
||||
<a href="uri.html#encodeUrl,string"><span class="Identifier">encodeUrl</span></a>, <a href="uri.html#decodeUrl,string"><span class="Identifier">decodeUrl</span></a>
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="twelve-columns footer">
|
||||
<span class="nim-sprite"></span>
|
||||
<br>
|
||||
<small style="color: var(--hint);">Made with Nim. Generated: 2023-03-13 00:19:15 UTC</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script defer data-domain="nim-lang.org" src="https://plausible.io/js/plausible.js"></script>
|
||||
|
||||
<!-- Google fonts -->
|
||||
<link href='https://fonts.googleapis.com/css?family=Lato:400,600,900' rel='stylesheet' type='text/css'/>
|
||||
<link href='https://fonts.googleapis.com/css?family=Source+Code+Pro:400,500,600' rel='stylesheet' type='text/css'/>
|
||||
</body>
|
||||
</html>
|
||||
54
cgi.idx
Normal file
54
cgi.idx
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
nimTitle cgi cgi.html module std/cgi 0
|
||||
nim xmlEncode cgi.html#xmlEncode,string proc xmlEncode(s: string): string 47
|
||||
nim CgiError cgi.html#CgiError object CgiError 58
|
||||
nim methodNone cgi.html#methodNone RequestMethod.methodNone 59
|
||||
nim methodPost cgi.html#methodPost RequestMethod.methodPost 59
|
||||
nim methodGet cgi.html#methodGet RequestMethod.methodGet 59
|
||||
nim RequestMethod cgi.html#RequestMethod enum RequestMethod 59
|
||||
nim cgiError cgi.html#cgiError,string proc cgiError(msg: string) 64
|
||||
nim decodeData cgi.html#decodeData.i,string iterator decodeData(data: string): tuple[key, value: string] 87
|
||||
nim decodeData cgi.html#decodeData.i,set[RequestMethod] iterator decodeData(allowedMethods: set[RequestMethod] = {methodNone, methodPost,\n methodGet}): tuple[key, value: string] 93
|
||||
nim readData cgi.html#readData,set[RequestMethod] proc readData(allowedMethods: set[RequestMethod] = {methodNone, methodPost, methodGet}): StringTableRef 102
|
||||
nim readData cgi.html#readData,string proc readData(data: string): StringTableRef 110
|
||||
nim validateData cgi.html#validateData,StringTableRef,varargs[string] proc validateData(data: StringTableRef; validKeys: varargs[string]) 116
|
||||
nim getContentLength cgi.html#getContentLength proc getContentLength(): string 123
|
||||
nim getContentType cgi.html#getContentType proc getContentType(): string 127
|
||||
nim getDocumentRoot cgi.html#getDocumentRoot proc getDocumentRoot(): string 131
|
||||
nim getGatewayInterface cgi.html#getGatewayInterface proc getGatewayInterface(): string 135
|
||||
nim getHttpAccept cgi.html#getHttpAccept proc getHttpAccept(): string 139
|
||||
nim getHttpAcceptCharset cgi.html#getHttpAcceptCharset proc getHttpAcceptCharset(): string 143
|
||||
nim getHttpAcceptEncoding cgi.html#getHttpAcceptEncoding proc getHttpAcceptEncoding(): string 147
|
||||
nim getHttpAcceptLanguage cgi.html#getHttpAcceptLanguage proc getHttpAcceptLanguage(): string 151
|
||||
nim getHttpConnection cgi.html#getHttpConnection proc getHttpConnection(): string 155
|
||||
nim getHttpCookie cgi.html#getHttpCookie proc getHttpCookie(): string 159
|
||||
nim getHttpHost cgi.html#getHttpHost proc getHttpHost(): string 163
|
||||
nim getHttpReferer cgi.html#getHttpReferer proc getHttpReferer(): string 167
|
||||
nim getHttpUserAgent cgi.html#getHttpUserAgent proc getHttpUserAgent(): string 171
|
||||
nim getPathInfo cgi.html#getPathInfo proc getPathInfo(): string 175
|
||||
nim getPathTranslated cgi.html#getPathTranslated proc getPathTranslated(): string 179
|
||||
nim getQueryString cgi.html#getQueryString proc getQueryString(): string 183
|
||||
nim getRemoteAddr cgi.html#getRemoteAddr proc getRemoteAddr(): string 187
|
||||
nim getRemoteHost cgi.html#getRemoteHost proc getRemoteHost(): string 191
|
||||
nim getRemoteIdent cgi.html#getRemoteIdent proc getRemoteIdent(): string 195
|
||||
nim getRemotePort cgi.html#getRemotePort proc getRemotePort(): string 199
|
||||
nim getRemoteUser cgi.html#getRemoteUser proc getRemoteUser(): string 203
|
||||
nim getRequestMethod cgi.html#getRequestMethod proc getRequestMethod(): string 207
|
||||
nim getRequestURI cgi.html#getRequestURI proc getRequestURI(): string 211
|
||||
nim getScriptFilename cgi.html#getScriptFilename proc getScriptFilename(): string 215
|
||||
nim getScriptName cgi.html#getScriptName proc getScriptName(): string 219
|
||||
nim getServerAddr cgi.html#getServerAddr proc getServerAddr(): string 223
|
||||
nim getServerAdmin cgi.html#getServerAdmin proc getServerAdmin(): string 227
|
||||
nim getServerName cgi.html#getServerName proc getServerName(): string 231
|
||||
nim getServerPort cgi.html#getServerPort proc getServerPort(): string 235
|
||||
nim getServerProtocol cgi.html#getServerProtocol proc getServerProtocol(): string 239
|
||||
nim getServerSignature cgi.html#getServerSignature proc getServerSignature(): string 243
|
||||
nim getServerSoftware cgi.html#getServerSoftware proc getServerSoftware(): string 247
|
||||
nim setTestData cgi.html#setTestData,varargs[string] proc setTestData(keysvalues: varargs[string]) 251
|
||||
nim writeContentType cgi.html#writeContentType proc writeContentType() 269
|
||||
nim writeErrorMessage cgi.html#writeErrorMessage,string proc writeErrorMessage(data: string) 287
|
||||
nim setStackTraceStdout cgi.html#setStackTraceStdout proc setStackTraceStdout() 296
|
||||
nim setCookie cgi.html#setCookie,string,string proc setCookie(name, value: string) 300
|
||||
nim getCookie cgi.html#getCookie,string proc getCookie(name: string): string 307
|
||||
nim existsCookie cgi.html#existsCookie,string proc existsCookie(name: string): bool 312
|
||||
nimgrp readdata cgi.html#readData-procs-all proc 102
|
||||
nimgrp decodedata cgi.html#decodeData-iterators-all iterator 87
|
||||
143
chains.html
Normal file
143
chains.html
Normal file
|
|
@ -0,0 +1,143 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<!-- This file is generated by Nim. -->
|
||||
<html xmlns="https://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>std/chains</title>
|
||||
|
||||
<!-- Favicon -->
|
||||
<link rel="shortcut icon" href="data:image/x-icon;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAUAAAAF////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAIAAABbAAAAlQAAAKIAAACbAAAAmwAAAKIAAACVAAAAWwAAAAL///8A////AP///wD///8A////AAAAABQAAADAAAAAYwAAAA3///8A////AP///wD///8AAAAADQAAAGMAAADAAAAAFP///wD///8A////AP///wAAAACdAAAAOv///wD///8A////AP///wD///8A////AP///wD///8AAAAAOgAAAJ3///8A////AP///wAAAAAnAAAAcP///wAAAAAoAAAASv///wD///8A////AP///wAAAABKAAAAKP///wAAAABwAAAAJ////wD///8AAAAAgQAAABwAAACIAAAAkAAAAJMAAACtAAAAFQAAABUAAACtAAAAkwAAAJAAAACIAAAAHAAAAIH///8A////AAAAAKQAAACrAAAAaP///wD///8AAAAARQAAANIAAADSAAAARf///wD///8AAAAAaAAAAKsAAACk////AAAAADMAAACcAAAAnQAAABj///8A////AP///wAAAAAYAAAAGP///wD///8A////AAAAABgAAACdAAAAnAAAADMAAAB1AAAAwwAAAP8AAADpAAAAsQAAAE4AAAAb////AP///wAAAAAbAAAATgAAALEAAADpAAAA/wAAAMMAAAB1AAAAtwAAAOkAAAD/AAAA/wAAAP8AAADvAAAA3gAAAN4AAADeAAAA3gAAAO8AAAD/AAAA/wAAAP8AAADpAAAAtwAAAGUAAAA/AAAA3wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAADfAAAAPwAAAGX///8A////AAAAAEgAAADtAAAAvwAAAL0AAADGAAAA7wAAAO8AAADGAAAAvQAAAL8AAADtAAAASP///wD///8A////AP///wD///8AAAAAO////wD///8A////AAAAAIcAAACH////AP///wD///8AAAAAO////wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A//8AAP//AAD4HwAA7/cAAN/7AAD//wAAoYUAAJ55AACf+QAAh+EAAAAAAADAAwAA4AcAAP5/AAD//wAA//8AAA=="/>
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAA3XAAAN1wFCKJt4AAAAB3RJTUUH4QQQEwksSS9ZWwAAAk1JREFUWMPtll2ITVEUx39nn/O7Y5qR8f05wtCUUr6ZIS++8pEnkZInPImneaCQ5METNdOkeFBKUhMPRIkHKfEuUZSUlGlKPN2TrgfncpvmnntnmlEyq1Z7t89/rf9a6+y99oZxGZf/XeIq61EdtgKXgdXA0xrYAvBjOIF1AI9zvjcC74BSpndrJPkBWDScTF8Aa4E3wDlgHbASaANmVqlcCnwHvgDvgVfAJ+AikAAvgfVZwLnSVZHZaOuKoQi3ZOMi4NkYkpe1p4J7A8BpYAD49hfIy/oqG0+hLomiKP2L5L+1ubn5115S+3OAn4EnwBlgMzCjyt6ZAnQCJ4A7wOs88iRJHvw50HoujuPBoCKwHWiosy8MdfZnAdcHk8dxXFJ3VQbQlCTJvRBCGdRbD4M6uc5glpY3eAihpN5S5w12diSEcCCEcKUO4ljdr15T76ur1FDDLIQQ3qv71EdDOe3Kxj3leRXyk+pxdWnFWod6Wt2bY3de3aSuUHcPBVimHs7mK9WrmeOF6lR1o9qnzskh2ar2qm1qizpfXaPeVGdlmGN5pb09qMxz1Xb1kLqgzn1RyH7JUXW52lr5e/Kqi9qpto7V1atuUzfnARrV7jEib1T76gG2qxdGmXyiekkt1GswPTtek0aBfJp6YySGBfWg2tPQ0FAYgf1stUfdmdcjarbYJEniKIq6gY/Aw+zWHAC+p2labGpqiorFYgGYCEzN7oQdQClN07O1/EfDyGgC0ALMBdYAi4FyK+4H3gLPsxfR1zRNi+NP7nH5J+QntnXe5B5mpfQAAAAASUVORK5CYII=">
|
||||
|
||||
<!-- CSS -->
|
||||
<link rel="stylesheet" type="text/css" href="nimdoc.out.css">
|
||||
|
||||
<!-- JS -->
|
||||
<script type="text/javascript" src="dochack.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="document" id="documentId">
|
||||
<div class="container">
|
||||
<h1 class="title">std/chains</h1>
|
||||
<div class="row">
|
||||
<div class="three columns">
|
||||
<div class="theme-select-wrapper">
|
||||
<label for="theme-select">Theme: </label>
|
||||
<select id="theme-select" onchange="setTheme(this.value)">
|
||||
<option value="auto">🌗 Match OS</option>
|
||||
<option value="dark">🌑 Dark</option>
|
||||
<option value="light">🌕 Light</option>
|
||||
</select>
|
||||
</div>
|
||||
<div id="global-links">
|
||||
<ul class="simple-boot">
|
||||
<li><a href="manual.html">Manual</a></li>
|
||||
<li><a href="lib.html">Standard library</a></li>
|
||||
<li> <a id="indexLink" href="theindex.html">Index</a></li>
|
||||
<li><a href="compiler/theindex.html">Compiler docs</a></li>
|
||||
<li><a href="https://nim-lang.github.io/fusion/theindex.html">Fusion docs</a></li>
|
||||
<li><a href="https://nim-lang.github.io/Nim/">devel</a>, <a href="https://nim-lang.org/documentation.html">stable</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="searchInputDiv">
|
||||
Search: <input type="search" id="searchInput"
|
||||
onkeyup="search()" />
|
||||
</div>
|
||||
|
||||
<ul class="simple simple-toc" id="toc-list">
|
||||
<li>
|
||||
<details open>
|
||||
<summary><a class="reference reference-toplevel" href="#18" id="68">Templates</a></summary>
|
||||
<ul class="simple simple-toc-section">
|
||||
<ul class="simple nested-toc-section">append
|
||||
<li><a class="reference" href="#append.t%2C%2C" title="append(header, node)">append(header, node)</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">prepend
|
||||
<li><a class="reference" href="#prepend.t%2C%2C" title="prepend(header, node)">prepend(header, node)</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">unlink
|
||||
<li><a class="reference" href="#unlink.t%2C%2C" title="unlink(header, node)">unlink(header, node)</a></li>
|
||||
|
||||
</ul>
|
||||
|
||||
</ul>
|
||||
</details>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
<div class="nine columns" id="content">
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/collections/chains.nim#L1" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/collections/chains.nim#L1" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
<div id="tocRoot"></div>
|
||||
|
||||
<p class="module-desc">Template based implementation of singly and doubly linked lists. The involved types should have 'prev' or 'next' fields and the list header should have 'head' or 'tail' fields.</p>
|
||||
<div class="section" id="18">
|
||||
<h1><a class="toc-backref" href="#18">Templates</a></h1>
|
||||
<dl class="item">
|
||||
<div id="append-templates-all">
|
||||
<div id="append.t,,">
|
||||
<dt><pre><span class="Keyword">template</span> <a href="#append.t%2C%2C"><span class="Identifier">append</span></a><span class="Other">(</span><span class="Identifier">header</span><span class="Other">,</span> <span class="Identifier">node</span><span class="Other">)</span></pre></dt>
|
||||
<dd>
|
||||
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/collections/chains.nim#L25" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/collections/chains.nim#L25" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="prepend-templates-all">
|
||||
<div id="prepend.t,,">
|
||||
<dt><pre><span class="Keyword">template</span> <a href="#prepend.t%2C%2C"><span class="Identifier">prepend</span></a><span class="Other">(</span><span class="Identifier">header</span><span class="Other">,</span> <span class="Identifier">node</span><span class="Other">)</span></pre></dt>
|
||||
<dd>
|
||||
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/collections/chains.nim#L14" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/collections/chains.nim#L14" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="unlink-templates-all">
|
||||
<div id="unlink.t,,">
|
||||
<dt><pre><span class="Keyword">template</span> <a href="#unlink.t%2C%2C"><span class="Identifier">unlink</span></a><span class="Other">(</span><span class="Identifier">header</span><span class="Other">,</span> <span class="Identifier">node</span><span class="Other">)</span></pre></dt>
|
||||
<dd>
|
||||
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/pure/collections/chains.nim#L36" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/pure/collections/chains.nim#L36" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="twelve-columns footer">
|
||||
<span class="nim-sprite"></span>
|
||||
<br>
|
||||
<small style="color: var(--hint);">Made with Nim. Generated: 2023-03-13 00:19:47 UTC</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script defer data-domain="nim-lang.org" src="https://plausible.io/js/plausible.js"></script>
|
||||
|
||||
<!-- Google fonts -->
|
||||
<link href='https://fonts.googleapis.com/css?family=Lato:400,600,900' rel='stylesheet' type='text/css'/>
|
||||
<link href='https://fonts.googleapis.com/css?family=Source+Code+Pro:400,500,600' rel='stylesheet' type='text/css'/>
|
||||
</body>
|
||||
</html>
|
||||
4
chains.idx
Normal file
4
chains.idx
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
nimTitle chains chains.html module std/chains 0
|
||||
nim prepend chains.html#prepend.t,, template prepend(header, node) 14
|
||||
nim append chains.html#append.t,, template append(header, node) 25
|
||||
nim unlink chains.html#unlink.t,, template unlink(header, node) 36
|
||||
31
changelog.md
31
changelog.md
|
|
@ -1,31 +0,0 @@
|
|||
# v2.2.0 - yyyy-mm-dd
|
||||
|
||||
|
||||
## Changes affecting backward compatibility
|
||||
|
||||
|
||||
## Standard library additions and changes
|
||||
|
||||
[//]: # "Changes:"
|
||||
|
||||
|
||||
[//]: # "Additions:"
|
||||
- Added `parseutils.parseSize` - inverse to `strutils.formatSize` - to parse human readable sizes.
|
||||
|
||||
[//]: # "Deprecations:"
|
||||
|
||||
|
||||
[//]: # "Removals:"
|
||||
|
||||
|
||||
## Language changes
|
||||
|
||||
|
||||
|
||||
## Compiler changes
|
||||
|
||||
|
||||
|
||||
|
||||
## Tool changes
|
||||
|
||||
|
|
@ -1,663 +0,0 @@
|
|||
## v0.18.0 - 01/03/2018
|
||||
|
||||
### Changes affecting backwards compatibility
|
||||
|
||||
#### Breaking changes in the standard library
|
||||
|
||||
- The ``[]`` proc for strings now raises an ``IndexError`` exception when
|
||||
the specified slice is out of bounds. See issue
|
||||
[#6223](https://github.com/nim-lang/Nim/issues/6223) for more details.
|
||||
You can use ``substr(str, start, finish)`` to get the old behaviour back,
|
||||
see [this commit](https://github.com/nim-lang/nimbot/commit/98cc031a27ea89947daa7f0bb536bcf86462941f) for an example.
|
||||
|
||||
- ``strutils.split`` and ``strutils.rsplit`` with an empty string and a
|
||||
separator now returns that empty string.
|
||||
See issue [#4377](https://github.com/nim-lang/Nim/issues/4377).
|
||||
|
||||
- Arrays of char cannot be converted to ``cstring`` anymore, pointers to
|
||||
arrays of char can! This means ``$`` for arrays can finally exist
|
||||
in ``system.nim`` and do the right thing. This means ``$myArrayOfChar`` changed
|
||||
its behaviour! Compile with ``-d:nimNoArrayToString`` to see where to fix your
|
||||
code.
|
||||
|
||||
- `reExtended` is no longer default for the `re` constructor in the `re`
|
||||
module.
|
||||
|
||||
- The behavior of ``$`` has been changed for all standard library collections. The
|
||||
collection-to-string implementations now perform proper quoting and escaping of
|
||||
strings and chars.
|
||||
|
||||
- `newAsyncSocket` taking an `AsyncFD` now runs `setBlocking(false)` on the
|
||||
fd.
|
||||
|
||||
- ``mod`` and bitwise ``and`` do not produce ``range`` subtypes anymore. This
|
||||
turned out to be more harmful than helpful and the language is simpler
|
||||
without this special typing rule.
|
||||
|
||||
- ``formatFloat``/``formatBiggestFloat`` now support formatting floats with zero
|
||||
precision digits. The previous ``precision = 0`` behavior (default formatting)
|
||||
is now available via ``precision = -1``.
|
||||
|
||||
- Moved from stdlib into Nimble packages:
|
||||
- [``basic2d``](https://github.com/nim-lang/basic2d)
|
||||
_deprecated: use ``glm``, ``arraymancer``, ``neo``, or another package instead_
|
||||
- [``basic3d``](https://github.com/nim-lang/basic3d)
|
||||
_deprecated: use ``glm``, ``arraymancer``, ``neo``, or another package instead_
|
||||
- [``gentabs``](https://github.com/lcrees/gentabs)
|
||||
- [``libuv``](https://github.com/lcrees/libuv)
|
||||
- [``numeric``](https://github.com/lcrees/polynumeric)
|
||||
- [``poly``](https://github.com/lcrees/polynumeric)
|
||||
- [``pdcurses``](https://github.com/lcrees/pdcurses)
|
||||
- [``romans``](https://github.com/lcrees/romans)
|
||||
- [``libsvm``](https://github.com/nim-lang/libsvm_legacy)
|
||||
- [``joyent_http_parser``](https://github.com/nim-lang/joyent_http_parser)
|
||||
|
||||
- Proc [toCountTable](https://nim-lang.org/docs/tables.html#toCountTable,openArray[A])
|
||||
now produces a `CountTable` with values correspoding to the number of occurrences
|
||||
of the key in the input. It used to produce a table with all values set to `1`.
|
||||
|
||||
Counting occurrences in a sequence used to be:
|
||||
|
||||
```nim
|
||||
let mySeq = @[1, 2, 1, 3, 1, 4]
|
||||
var myCounter = initCountTable[int]()
|
||||
|
||||
for item in mySeq:
|
||||
myCounter.inc item
|
||||
```
|
||||
|
||||
Now, you can simply do:
|
||||
|
||||
```nim
|
||||
let
|
||||
mySeq = @[1, 2, 1, 3, 1, 4]
|
||||
myCounter = mySeq.toCountTable()
|
||||
```
|
||||
|
||||
- If you use ``--dynlibOverride:ssl`` with OpenSSL 1.0.x, you now have to
|
||||
define ``openssl10`` symbol (``-d:openssl10``). By default OpenSSL 1.1.x is
|
||||
assumed.
|
||||
|
||||
- ``newNativeSocket`` is now named ``createNativeSocket``.
|
||||
|
||||
- ``newAsyncNativeSocket`` is now named ``createAsyncNativeSocket``
|
||||
and it no longer raises an OS error but returns an ``osInvalidSocket`` when
|
||||
creation fails.
|
||||
|
||||
- The ``securehash`` module is now deprecated. Instead import ``std / sha1``.
|
||||
|
||||
- The ``readPasswordFromStdin`` proc has been moved from the ``rdstdin``
|
||||
to the ``terminal`` module, thus it does not depend on linenoise anymore.
|
||||
|
||||
#### Breaking changes in the compiler
|
||||
|
||||
- ``\n`` is now only the single line feed character like in most
|
||||
other programming languages. The new platform specific newline escape sequence is
|
||||
written as ``\p``. This change only affects the Windows platform.
|
||||
|
||||
- The overloading rules changed slightly so that constrained generics are
|
||||
preferred over unconstrained generics. (Bug #6526)
|
||||
|
||||
- We changed how array accesses "from backwards" like ``a[^1]`` or ``a[0..^1]`` are
|
||||
implemented. These are now implemented purely in ``system.nim`` without compiler
|
||||
support. There is a new "heterogeneous" slice type ``system.HSlice`` that takes 2
|
||||
generic parameters which can be ``BackwardsIndex`` indices. ``BackwardsIndex`` is
|
||||
produced by ``system.^``.
|
||||
This means if you overload ``[]`` or ``[]=`` you need to ensure they also work
|
||||
with ``system.BackwardsIndex`` (if applicable for the accessors).
|
||||
|
||||
- The parsing rules of ``if`` expressions were changed so that multiple
|
||||
statements are allowed in the branches. We found few code examples that
|
||||
now fail because of this change, but here is one:
|
||||
|
||||
```nim
|
||||
t[ti] = if exp_negative: '-' else: '+'; inc(ti)
|
||||
```
|
||||
|
||||
This now needs to be written as:
|
||||
|
||||
```nim
|
||||
t[ti] = (if exp_negative: '-' else: '+'); inc(ti)
|
||||
```
|
||||
|
||||
- The experimental overloading of the dot ``.`` operators now take
|
||||
an ``untyped``` parameter as the field name, it used to be
|
||||
a ``static[string]``. You can use ``when defined(nimNewDot)`` to make
|
||||
your code work with both old and new Nim versions.
|
||||
See [special-operators](https://nim-lang.org/docs/manual.html#special-operators)
|
||||
for more information.
|
||||
|
||||
- ``yield`` (or ``await`` which is mapped to ``yield``) never worked reliably
|
||||
in an array, seq or object constructor and is now prevented at compile-time.
|
||||
|
||||
### Library additions
|
||||
|
||||
- **Added ``sequtils.mapLiterals`` for easier construction of array and tuple literals.**
|
||||
|
||||
- Added ``system.runnableExamples`` to make examples in Nim's documentation easier
|
||||
to write and test. The examples are tested as the last step of
|
||||
``nim doc``.
|
||||
|
||||
- Implemented ``getIoHandler`` proc in the ``asyncdispatch`` module that allows
|
||||
you to retrieve the underlying IO Completion Port or ``Selector[AsyncData]``
|
||||
object in the specified dispatcher.
|
||||
|
||||
- For string formatting / interpolation a new module
|
||||
called [strformat](https://nim-lang.org/docs/strformat.html) has been added
|
||||
to the stdlib.
|
||||
|
||||
- The `ReadyKey` type in the selectors module now contains an ``errorCode``
|
||||
field to help distinguish between ``Event.Error`` events.
|
||||
|
||||
- Implemented an `accept` proc that works on a `SocketHandle` in
|
||||
``nativesockets``.
|
||||
|
||||
- Added ``algorithm.rotateLeft``.
|
||||
|
||||
- Added ``typetraits.$`` as an alias for ``typetraits.name``.
|
||||
|
||||
- Added ``system.getStackTraceEntries`` that allows you to access the stack
|
||||
trace in a structured manner without string parsing.
|
||||
|
||||
- Added ``parseutils.parseSaturatedNatural``.
|
||||
|
||||
- Added ``macros.unpackVarargs``.
|
||||
|
||||
- Added support for asynchronous programming for the JavaScript backend using
|
||||
the `asyncjs` module.
|
||||
|
||||
- Added true color support for some terminals. Example:
|
||||
```nim
|
||||
import colors, terminal
|
||||
|
||||
const Nim = "Efficient and expressive programming."
|
||||
|
||||
var
|
||||
fg = colYellow
|
||||
bg = colBlue
|
||||
int = 1.0
|
||||
|
||||
enableTrueColors()
|
||||
|
||||
for i in 1..15:
|
||||
styledEcho bgColor, bg, fgColor, fg, Nim, resetStyle
|
||||
int -= 0.01
|
||||
fg = intensity(fg, int)
|
||||
|
||||
setForegroundColor colRed
|
||||
setBackgroundColor colGreen
|
||||
styledEcho "Red on Green.", resetStyle
|
||||
```
|
||||
|
||||
### Library changes
|
||||
|
||||
- ``echo`` now works with strings that contain ``\0`` (the binary zero is not
|
||||
shown) and ``nil`` strings are equal to empty strings.
|
||||
|
||||
- JSON: Deprecated `getBVal`, `getFNum`, and `getNum` in favour of
|
||||
`getBool`, `getFloat`, `getBiggestInt`. A new `getInt` procedure was also
|
||||
added.
|
||||
|
||||
- ``rationals.toRational`` now uses an algorithm based on continued fractions.
|
||||
This means its results are more precise and it can't run into an infinite loop
|
||||
anymore.
|
||||
|
||||
- ``os.getEnv`` now takes an optional ``default`` parameter that tells ``getEnv``
|
||||
what to return if the environment variable does not exist.
|
||||
|
||||
- The ``random`` procs in ``random.nim`` have all been deprecated. Instead use
|
||||
the new ``rand`` procs. The module now exports the state of the random
|
||||
number generator as type ``Rand`` so multiple threads can easily use their
|
||||
own random number generators that do not require locking. For more information
|
||||
about this rename see issue [#6934](https://github.com/nim-lang/Nim/issues/6934)
|
||||
|
||||
- ``writeStackTrace`` is now proclaimed to have no IO effect (even though it does)
|
||||
so that it is more useful for debugging purposes.
|
||||
|
||||
- ``db_mysql`` module: ``DbConn`` is now a ``distinct`` type that doesn't expose the
|
||||
details of the underlying ``PMySQL`` type.
|
||||
|
||||
- ``parseopt2`` is now deprecated, use ``parseopt`` instead.
|
||||
|
||||
### Language additions
|
||||
|
||||
- It is now possible to forward declare object types so that mutually
|
||||
recursive types can be created across module boundaries. See
|
||||
[package level objects](https://nim-lang.org/docs/manual.html#package-level-objects)
|
||||
for more information.
|
||||
|
||||
- Added support for casting between integers of same bitsize in VM (compile time and nimscript).
|
||||
This allows to, among other things, reinterpret signed integers as unsigned.
|
||||
|
||||
- Custom pragmas are now supported using pragma ``pragma``, please see language
|
||||
manual for details.
|
||||
|
||||
- Standard library modules can now also be imported via the ``std`` pseudo-directory.
|
||||
This is useful in order to distinguish between standard library and nimble package
|
||||
imports:
|
||||
|
||||
```nim
|
||||
import std / [strutils, os, osproc]
|
||||
import someNimblePackage / [strutils, os]
|
||||
```
|
||||
|
||||
### Language changes
|
||||
|
||||
- The **unary** ``<`` is now deprecated, for ``.. <`` use ``..<`` for other usages
|
||||
use the ``pred`` proc.
|
||||
|
||||
- Bodies of ``for`` loops now get their own scope:
|
||||
|
||||
```nim
|
||||
# now compiles:
|
||||
for i in 0..4:
|
||||
let i = i + 1
|
||||
echo i
|
||||
```
|
||||
|
||||
- To make Nim even more robust the system iterators ``..`` and ``countup``
|
||||
now only accept a single generic type ``T``. This means the following code
|
||||
doesn't die with an "out of range" error anymore:
|
||||
|
||||
```nim
|
||||
var b = 5.Natural
|
||||
var a = -5
|
||||
for i in a..b:
|
||||
echo i
|
||||
```
|
||||
|
||||
- ``atomic`` and ``generic`` are no longer keywords in Nim. ``generic`` used to be
|
||||
an alias for ``concept``, ``atomic`` was not used for anything.
|
||||
|
||||
- The memory manager now uses a variant of the TLSF algorithm that has much
|
||||
better memory fragmentation behaviour. According
|
||||
to [http://www.gii.upv.es/tlsf/](http://www.gii.upv.es/tlsf/) the maximum
|
||||
fragmentation measured is lower than 25%. As a nice bonus ``alloc`` and
|
||||
``dealloc`` became O(1) operations.
|
||||
|
||||
- The compiler is now more consistent in its treatment of ambiguous symbols:
|
||||
Types that shadow procs and vice versa are marked as ambiguous (bug #6693).
|
||||
|
||||
- codegenDecl pragma now works for the JavaScript backend. It returns an empty
|
||||
string for function return type placeholders.
|
||||
|
||||
- Extra semantic checks for procs with noreturn pragma: return type is not allowed,
|
||||
statements after call to noreturn procs are no longer allowed.
|
||||
|
||||
- Noreturn proc calls and raising exceptions branches are now skipped during common type
|
||||
deduction in ``if`` and ``case`` expressions. The following code snippets now compile:
|
||||
```nim
|
||||
import strutils
|
||||
let str = "Y"
|
||||
let a = case str:
|
||||
of "Y": true
|
||||
of "N": false
|
||||
else: raise newException(ValueError, "Invalid boolean")
|
||||
let b = case str:
|
||||
of nil, "": raise newException(ValueError, "Invalid boolean")
|
||||
elif str.startsWith("Y"): true
|
||||
elif str.startsWith("N"): false
|
||||
else: false
|
||||
let c = if str == "Y": true
|
||||
elif str == "N": false
|
||||
else:
|
||||
echo "invalid bool"
|
||||
quit("this is the end")
|
||||
```
|
||||
|
||||
- Pragmas now support call syntax, for example: ``{.exportc"myname".}`` and
|
||||
``{.exportc("myname").}``
|
||||
|
||||
- The ``deprecated`` pragma now supports a user-definable warning message for procs.
|
||||
|
||||
```nim
|
||||
proc bar {.deprecated: "use foo instead".} =
|
||||
return
|
||||
|
||||
bar()
|
||||
```
|
||||
|
||||
### Tool changes
|
||||
|
||||
- The ``nim doc`` command is now an alias for ``nim doc2``, the second version of
|
||||
the documentation generator. The old version 1 can still be accessed
|
||||
via the new ``nim doc0`` command.
|
||||
|
||||
- Nim's ``rst2html`` command now supports the testing of code snippets via an RST
|
||||
extension that we called ``:test:``::
|
||||
|
||||
```rst
|
||||
.. code-block:: nim
|
||||
:test:
|
||||
# shows how the 'if' statement works
|
||||
if true: echo "yes"
|
||||
```
|
||||
|
||||
### Compiler changes
|
||||
|
||||
### Bugfixes
|
||||
|
||||
- Fixed "ReraiseError when using try/except within finally block"
|
||||
([#5871](https://github.com/nim-lang/Nim/issues/5871))
|
||||
- Fixed "Range type inference leads to counter-intuitive behvaiour"
|
||||
([#5854](https://github.com/nim-lang/Nim/issues/5854))
|
||||
- Fixed "JSON % operator can fail in extern procs with dynamic types"
|
||||
([#6385](https://github.com/nim-lang/Nim/issues/6385))
|
||||
- Fixed ""intVal is not accessible" in VM"
|
||||
([#6083](https://github.com/nim-lang/Nim/issues/6083))
|
||||
- Fixed "Add excl for OrderedSet"
|
||||
([#2467](https://github.com/nim-lang/Nim/issues/2467))
|
||||
- Fixed "newSeqOfCap actually doesn't reserve memory"
|
||||
([#6403](https://github.com/nim-lang/Nim/issues/6403))
|
||||
- Fixed "[Regression] Nim segfaults"
|
||||
([#6435](https://github.com/nim-lang/Nim/issues/6435))
|
||||
- Fixed "Seq assignment is slower than expected"
|
||||
([#6433](https://github.com/nim-lang/Nim/issues/6433))
|
||||
- Fixed "json module issues with empty dicts and lists"
|
||||
([#6438](https://github.com/nim-lang/Nim/issues/6438))
|
||||
- Fixed "mingw installed via finish.exe fails to link if Nim located in path with whitespace"
|
||||
([#6452](https://github.com/nim-lang/Nim/issues/6452))
|
||||
- Fixed "unittest.check does not perform short-circuit evaluation"
|
||||
([#5784](https://github.com/nim-lang/Nim/issues/5784))
|
||||
- Fixed "Error while concatenating an array of chars."
|
||||
([#5861](https://github.com/nim-lang/Nim/issues/5861))
|
||||
- Fixed "range initialization: [ProveInit] hint: Cannot prove that"
|
||||
([#6474](https://github.com/nim-lang/Nim/issues/6474))
|
||||
- Fixed "scanf can call procs with side-effects multiple times"
|
||||
([#6487](https://github.com/nim-lang/Nim/issues/6487))
|
||||
- Fixed "gcsafe detection problem"
|
||||
([#5620](https://github.com/nim-lang/Nim/issues/5620))
|
||||
- Fixed "C++ codegen: `mitems` generates invalid code."
|
||||
([#4910](https://github.com/nim-lang/Nim/issues/4910))
|
||||
- Fixed "strange runtime behavior on macOS"
|
||||
([#6496](https://github.com/nim-lang/Nim/issues/6496))
|
||||
- Fixed "stdtmpl: invalid indentation after a line ending in question mark"
|
||||
([#5070](https://github.com/nim-lang/Nim/issues/5070))
|
||||
- Fixed "Windows: NAN troubles on c backend"
|
||||
([#6511](https://github.com/nim-lang/Nim/issues/6511))
|
||||
- Fixed "lib/nim/system/cellsets.nim(33, 31) Error: type mismatch while attempting to compile for 16bit CPUs"
|
||||
([#3558](https://github.com/nim-lang/Nim/issues/3558))
|
||||
- Fixed "Can't compile dynlib with ``-d:useNimRtl`` and ``--threads:on``"
|
||||
([#5143](https://github.com/nim-lang/Nim/issues/5143))
|
||||
- Fixed "var s = @[0,1,2,...] can generate thousand of single assignments in C code"
|
||||
([#5007](https://github.com/nim-lang/Nim/issues/5007))
|
||||
- Fixed "`echo` discards everything after a null character"
|
||||
([#1137](https://github.com/nim-lang/Nim/issues/1137))
|
||||
- Fixed "Turn off reExtended by default"
|
||||
([#5627](https://github.com/nim-lang/Nim/issues/5627))
|
||||
- Fixed "Bad Links in docs/backends.html"
|
||||
([#5914](https://github.com/nim-lang/Nim/issues/5914))
|
||||
- Fixed "Index out of bounds error in db_postgres when executing non parameter-substituted queries containing "?""
|
||||
([#6571](https://github.com/nim-lang/Nim/issues/6571))
|
||||
- Fixed "Please add pipe2 support to posix stdlib"
|
||||
([#6553](https://github.com/nim-lang/Nim/issues/6553))
|
||||
- Fixed "Return semantics vary depending on return style"
|
||||
([#6422](https://github.com/nim-lang/Nim/issues/6422))
|
||||
- Fixed "parsecsv.open reports SIGSEGV when calling 'open' on missing file"
|
||||
([#6148](https://github.com/nim-lang/Nim/issues/6148))
|
||||
- Fixed "VCC: Nim generates non-compilable code for system.nim"
|
||||
([#6606](https://github.com/nim-lang/Nim/issues/6606))
|
||||
- Fixed "Generic subtype matches worse than a generic"
|
||||
([#6526](https://github.com/nim-lang/Nim/issues/6526))
|
||||
- Fixed "formatFloat inconsistent scientific notation"
|
||||
([#6589](https://github.com/nim-lang/Nim/issues/6589))
|
||||
- Fixed "Generated c code calls function twice"
|
||||
([#6292](https://github.com/nim-lang/Nim/issues/6292))
|
||||
- Fixed "Range type inference leads to counter-intuitive behvaiour"
|
||||
([#5854](https://github.com/nim-lang/Nim/issues/5854))
|
||||
- Fixed "New backward indexing is too limited"
|
||||
([#6631](https://github.com/nim-lang/Nim/issues/6631))
|
||||
- Fixed "Table usage in a macro (SIGSEGV: Illegal storage access.)"
|
||||
([#1860](https://github.com/nim-lang/Nim/issues/1860))
|
||||
- Fixed "Incorrect deprecation error"
|
||||
([#6634](https://github.com/nim-lang/Nim/issues/6634))
|
||||
- Fixed "Wrong indices in arrays not starting with 0"
|
||||
([#6675](https://github.com/nim-lang/Nim/issues/6675))
|
||||
- Fixed "if expressions"
|
||||
([#6609](https://github.com/nim-lang/Nim/issues/6609))
|
||||
- Fixed "BackwardsIndex: converter + `[]` + unrelated type[^1]: lib/system.nim(3536, 3) Error"
|
||||
([#6692](https://github.com/nim-lang/Nim/issues/6692))
|
||||
- Fixed "BackwardsIndex: converter + `[]` + unrelated type[^1]: lib/system.nim(3536, 3) Error"
|
||||
([#6692](https://github.com/nim-lang/Nim/issues/6692))
|
||||
- Fixed "js backend 0.17.3: array bounds check for non zero based arrays is buggy"
|
||||
([#6532](https://github.com/nim-lang/Nim/issues/6532))
|
||||
- Fixed "HttpClient's new API doesn't work through a proxy for https URLs"
|
||||
([#6685](https://github.com/nim-lang/Nim/issues/6685))
|
||||
- Fixed "isServing isn't declared and isn't compiling"
|
||||
([#6707](https://github.com/nim-lang/Nim/issues/6707))
|
||||
- Fixed "[Regression] value out of range"
|
||||
([#6710](https://github.com/nim-lang/Nim/issues/6710))
|
||||
|
||||
- Fixed "Error when using `multisync` macro"
|
||||
([#6708](https://github.com/nim-lang/Nim/issues/6708))
|
||||
|
||||
- Fixed "formatFloat inconsistent scientific notation"
|
||||
([#6589](https://github.com/nim-lang/Nim/issues/6589))
|
||||
- Fixed "Using : (constructor arguments) for passing values to functions with default arguments causes a compiler crash."
|
||||
([#6765](https://github.com/nim-lang/Nim/issues/6765))
|
||||
- Fixed "In-place object initialization leads to vcc incompatible code"
|
||||
([#6757](https://github.com/nim-lang/Nim/issues/6757))
|
||||
- Fixed "Improve parseCookies doc"
|
||||
([#5721](https://github.com/nim-lang/Nim/issues/5721))
|
||||
- Fixed "Parser regression with nested do notation inside conditional"
|
||||
([#6166](https://github.com/nim-lang/Nim/issues/6166))
|
||||
- Fixed "Request for better error message"
|
||||
([#6776](https://github.com/nim-lang/Nim/issues/6776))
|
||||
- Fixed "Testament tester does not execute test with `exitcode` only"
|
||||
([#6775](https://github.com/nim-lang/Nim/issues/6775))
|
||||
- Fixed "JS integer division off by one"
|
||||
([#6753](https://github.com/nim-lang/Nim/issues/6753))
|
||||
- Fixed "Regression: cannot prove not nil"
|
||||
([#5781](https://github.com/nim-lang/Nim/issues/5781))
|
||||
- Fixed "SIGSEGV: Illegal storage access. (Attempt to read from nil?) in generic proc"
|
||||
([#6073](https://github.com/nim-lang/Nim/issues/6073))
|
||||
- Fixed "Request for better error message"
|
||||
([#6776](https://github.com/nim-lang/Nim/issues/6776))
|
||||
- Fixed "Nim #head: sorting via reference hangs compiler"
|
||||
([#6724](https://github.com/nim-lang/Nim/issues/6724))
|
||||
- Fixed "Cannot cast pointer to char in cpp"
|
||||
([#5979](https://github.com/nim-lang/Nim/issues/5979))
|
||||
- Fixed "asynchttpserver replies with several errors on single request"
|
||||
([#6386](https://github.com/nim-lang/Nim/issues/6386))
|
||||
- Fixed "object variants superclass trigger bad codegen"
|
||||
([#5521](https://github.com/nim-lang/Nim/issues/5521))
|
||||
- Fixed "JS integer division off by one"
|
||||
([#6753](https://github.com/nim-lang/Nim/issues/6753))
|
||||
- Fixed "js backend compiler crash with tables indexed by certain types"
|
||||
([#6568](https://github.com/nim-lang/Nim/issues/6568))
|
||||
- Fixed "Jsgen bug with is"
|
||||
([#6445](https://github.com/nim-lang/Nim/issues/6445))
|
||||
- Fixed "Subrange definition with ..<"
|
||||
([#6788](https://github.com/nim-lang/Nim/issues/6788))
|
||||
- Fixed "fields not initialized: array with enum index type as object field."
|
||||
([#6682](https://github.com/nim-lang/Nim/issues/6682))
|
||||
- Fixed "Can not delete data in table when table's data type is kind of "not nil""
|
||||
([#6555](https://github.com/nim-lang/Nim/issues/6555))
|
||||
- Fixed "tables.nim: Cannot prove that 'n' is initialized"
|
||||
([#6121](https://github.com/nim-lang/Nim/issues/6121))
|
||||
- Fixed "issues with 'not nil' applied to a closure proc"
|
||||
([#6489](https://github.com/nim-lang/Nim/issues/6489))
|
||||
- Fixed "`not nil` not working in some cases"
|
||||
([#4686](https://github.com/nim-lang/Nim/issues/4686))
|
||||
- Fixed "Cannot prove '@[v]' is not nil"
|
||||
([#3993](https://github.com/nim-lang/Nim/issues/3993))
|
||||
|
||||
- Fixed "Feature: support TCP_NODELAY in net.sockets"
|
||||
([#6795](https://github.com/nim-lang/Nim/issues/6795))
|
||||
- Fixed "Code that makes the compiler throw an error message and then hangs"
|
||||
([#6820](https://github.com/nim-lang/Nim/issues/6820))
|
||||
- Fixed "Code that makes the compiler throw an error message and then hangs"
|
||||
([#6820](https://github.com/nim-lang/Nim/issues/6820))
|
||||
- Fixed "Inconsistent behavior with sequence and string slicing"
|
||||
([#6223](https://github.com/nim-lang/Nim/issues/6223))
|
||||
- Fixed "Wrong behavior of "split" (proc and iterator)"
|
||||
([#4377](https://github.com/nim-lang/Nim/issues/4377))
|
||||
- Fixed "[Documentation] Invalid module name: [foo, bar]"
|
||||
([#6831](https://github.com/nim-lang/Nim/issues/6831))
|
||||
- Fixed "The destructor is not called for temporary objects"
|
||||
([#4214](https://github.com/nim-lang/Nim/issues/4214))
|
||||
- Fixed "Destructors does not work with implicit items iterator in for loop"
|
||||
([#985](https://github.com/nim-lang/Nim/issues/985))
|
||||
- Fixed "Error in template when using the type of the parameter inside it"
|
||||
([#6756](https://github.com/nim-lang/Nim/issues/6756))
|
||||
- Fixed "should json.to() respect parent attributes?"
|
||||
([#5856](https://github.com/nim-lang/Nim/issues/5856))
|
||||
- Fixed "json 'to' macro can not marshalize into tuples"
|
||||
([#6095](https://github.com/nim-lang/Nim/issues/6095))
|
||||
- Fixed "json.to fails with seq[T]"
|
||||
([#6604](https://github.com/nim-lang/Nim/issues/6604))
|
||||
- Fixed "json.to() is not worth using compared to marshal.to[T]"
|
||||
([#5848](https://github.com/nim-lang/Nim/issues/5848))
|
||||
- Fixed "Memory not being released in time, running out of memory"
|
||||
([#6031](https://github.com/nim-lang/Nim/issues/6031))
|
||||
- Fixed "[Regression] Bad C codegen for generic code"
|
||||
([#6889](https://github.com/nim-lang/Nim/issues/6889))
|
||||
- Fixed "rollingFileLogger deletes file on every start."
|
||||
([#6264](https://github.com/nim-lang/Nim/issues/6264))
|
||||
- Fixed "Remove/deprecate securehash module."
|
||||
([#6033](https://github.com/nim-lang/Nim/issues/6033))
|
||||
- Fixed "[bug or not] object construction for seq[T] failed without space after colon"
|
||||
([#5999](https://github.com/nim-lang/Nim/issues/5999))
|
||||
- Fixed "issues with the random module"
|
||||
([#4726](https://github.com/nim-lang/Nim/issues/4726))
|
||||
- Fixed "Reassigning local var to seq of objects results in nil element in Object's seq field"
|
||||
([#668](https://github.com/nim-lang/Nim/issues/668))
|
||||
- Fixed "Compilation error with "newseq[string]""
|
||||
([#6726](https://github.com/nim-lang/Nim/issues/6726))
|
||||
- Fixed "await inside array/dict literal produces invalid code - Part 2"
|
||||
([#6626](https://github.com/nim-lang/Nim/issues/6626))
|
||||
- Fixed "terminal.eraseline() gives OverflowError on Windows"
|
||||
([#6931](https://github.com/nim-lang/Nim/issues/6931))
|
||||
- Fixed "[Regression] `sequtils.any` conflicts with `system.any`"
|
||||
([#6932](https://github.com/nim-lang/Nim/issues/6932))
|
||||
- Fixed "C++ codegen: `mitems` generates invalid code."
|
||||
([#4910](https://github.com/nim-lang/Nim/issues/4910))
|
||||
- Fixed "seq.mitems produces invalid cpp codegen"
|
||||
([#6892](https://github.com/nim-lang/Nim/issues/6892))
|
||||
- Fixed "Concepts regression"
|
||||
([#6108](https://github.com/nim-lang/Nim/issues/6108))
|
||||
- Fixed "Generic iterable concept with array crashes compiler"
|
||||
([#6277](https://github.com/nim-lang/Nim/issues/6277))
|
||||
- Fixed "C code generation "‘a’ is a pointer; did you mean to use ‘->’?""
|
||||
([#6462](https://github.com/nim-lang/Nim/issues/6462))
|
||||
- Fixed "`--NimblePath` fails if a `-` in path which is not followed by a number"
|
||||
([#6949](https://github.com/nim-lang/Nim/issues/6949))
|
||||
- Fixed ""not registered in the selector" in asyncfile.close() for something that clearly was registered"
|
||||
([#6906](https://github.com/nim-lang/Nim/issues/6906))
|
||||
- Fixed "strange frexp behavior"
|
||||
([#6353](https://github.com/nim-lang/Nim/issues/6353))
|
||||
|
||||
- Fixed "noreturn branches of case statements shouldn't contribute to type"
|
||||
([#6885](https://github.com/nim-lang/Nim/issues/6885))
|
||||
- Fixed "Type inference for 'if' statements changed"
|
||||
([#6980](https://github.com/nim-lang/Nim/issues/6980))
|
||||
- Fixed "newest asyncdispatch recursion"
|
||||
([#6100](https://github.com/nim-lang/Nim/issues/6100))
|
||||
- Fixed "Ambiguous identifier between set type and proc"
|
||||
([#6965](https://github.com/nim-lang/Nim/issues/6965))
|
||||
|
||||
- Fixed "Inconsistent behavior with sequence and string slicing"
|
||||
([#6223](https://github.com/nim-lang/Nim/issues/6223))
|
||||
|
||||
- Fixed "Unsupported OpenSSL library imported dynamically"
|
||||
([#5000](https://github.com/nim-lang/Nim/issues/5000))
|
||||
- Fixed "`nim check` segfaults"
|
||||
([#6972](https://github.com/nim-lang/Nim/issues/6972))
|
||||
- Fixed "GC deadlock"
|
||||
([#6988](https://github.com/nim-lang/Nim/issues/6988))
|
||||
- Fixed "Create a seq without memory initialization"
|
||||
([#6401](https://github.com/nim-lang/Nim/issues/6401))
|
||||
- Fixed "Fix bug for getch on Windows while using the arrow keys"
|
||||
([#6966](https://github.com/nim-lang/Nim/issues/6966))
|
||||
- Fixed "runnableExamples doesn't work in templates"
|
||||
([#7018](https://github.com/nim-lang/Nim/issues/7018))
|
||||
- Fixed "runnableExamples doesn't work with untyped statement blocks"
|
||||
([#7019](https://github.com/nim-lang/Nim/issues/7019))
|
||||
|
||||
- Fixed "Critical bug in parseBiggestFloat"
|
||||
([#7060](https://github.com/nim-lang/Nim/issues/7060))
|
||||
- Fixed "[RFC] strformat.% should be gone"
|
||||
([#7078](https://github.com/nim-lang/Nim/issues/7078))
|
||||
- Fixed "compiler crash on simple macro"
|
||||
([#7093](https://github.com/nim-lang/Nim/issues/7093))
|
||||
- Fixed "Make newlines sane again"
|
||||
([#7089](https://github.com/nim-lang/Nim/issues/7089))
|
||||
- Fixed "JS - Unicode enum string representation issue"
|
||||
([#6741](https://github.com/nim-lang/Nim/issues/6741))
|
||||
- Fixed "Strange behaviour of 0.17.3 (working ok in 0.17.2)"
|
||||
([#6989](https://github.com/nim-lang/Nim/issues/6989))
|
||||
- Fixed "Strange behaviour of 0.17.3 (working ok in 0.17.2)"
|
||||
([#6989](https://github.com/nim-lang/Nim/issues/6989))
|
||||
- Fixed "Compiler crash: try expression with infix as"
|
||||
([#7116](https://github.com/nim-lang/Nim/issues/7116))
|
||||
- Fixed "nimsuggest crash"
|
||||
([#7140](https://github.com/nim-lang/Nim/issues/7140))
|
||||
- Fixed "[RFC] Reintroduce readChar"
|
||||
([#7072](https://github.com/nim-lang/Nim/issues/7072))
|
||||
- Fixed "Copyright line needs updating"
|
||||
([#7129](https://github.com/nim-lang/Nim/issues/7129))
|
||||
- Fixed "-0.0 doesn't result in negative zero in VM"
|
||||
([#7079](https://github.com/nim-lang/Nim/issues/7079))
|
||||
- Fixed "Windows large filesize"
|
||||
([#7121](https://github.com/nim-lang/Nim/issues/7121))
|
||||
- Fixed "Securehash is not parsimonious with MD5 and other hash modules"
|
||||
([#6961](https://github.com/nim-lang/Nim/issues/6961))
|
||||
- Fixed "os.findExe() shouldn't look in current directory on posix, unless exe has a /"
|
||||
([#6939](https://github.com/nim-lang/Nim/issues/6939))
|
||||
- Fixed "`compiles(...)` with `fatal` pragma causes compiler to exit early"
|
||||
([#7080](https://github.com/nim-lang/Nim/issues/7080))
|
||||
- Fixed "NPE when compile macro that returns concrete value"
|
||||
([#5450](https://github.com/nim-lang/Nim/issues/5450))
|
||||
- Fixed "Using a variable of type `int | float` causes internal compiler error"
|
||||
([#6946](https://github.com/nim-lang/Nim/issues/6946))
|
||||
- Fixed "Unsigned integers could not be used as array indexes."
|
||||
([#7153](https://github.com/nim-lang/Nim/issues/7153))
|
||||
- Fixed "countdown with uint causes underflow"
|
||||
([#4220](https://github.com/nim-lang/Nim/issues/4220))
|
||||
- Fixed "Inconsistent method call syntax"
|
||||
([#7200](https://github.com/nim-lang/Nim/issues/7200))
|
||||
- Fixed "Impossible to create an empty const array"
|
||||
([#6853](https://github.com/nim-lang/Nim/issues/6853))
|
||||
- Fixed "Strange UINT handling"
|
||||
([#3985](https://github.com/nim-lang/Nim/issues/3985))
|
||||
- Fixed "Bad codegen when passing arg that is part of return value destination"
|
||||
([#6960](https://github.com/nim-lang/Nim/issues/6960))
|
||||
- Fixed "No info about gcsafety in error message when global var is accessed in async proc"
|
||||
([#6186](https://github.com/nim-lang/Nim/issues/6186))
|
||||
- Fixed "Resolving package vs. local import ambiguities"
|
||||
([#2819](https://github.com/nim-lang/Nim/issues/2819))
|
||||
- Fixed "Internal error with type() operator"
|
||||
([#3711](https://github.com/nim-lang/Nim/issues/3711))
|
||||
- Fixed "newAsyncSocket should raise an OS error plus other inconsistencies"
|
||||
([#4995](https://github.com/nim-lang/Nim/issues/4995))
|
||||
- Fixed "mapLiterals fails with negative values"
|
||||
([#7215](https://github.com/nim-lang/Nim/issues/7215))
|
||||
- Fixed "fmWrite doesn't truncate file with openAsync, unlike open()"
|
||||
([#5531](https://github.com/nim-lang/Nim/issues/5531))
|
||||
- Fixed "Move libsvm to an external nimble module"
|
||||
([#5786](https://github.com/nim-lang/Nim/issues/5786))
|
||||
- Fixed "Prevent acceptAddr gotcha with newSocket"
|
||||
([#7227](https://github.com/nim-lang/Nim/issues/7227))
|
||||
- Fixed "strtabs.getOrDefault is inconsistent with tables.getOrDefault"
|
||||
([#4265](https://github.com/nim-lang/Nim/issues/4265))
|
||||
|
||||
- Fixed "Code falling through into exception handler when no exception thrown."
|
||||
([#7232](https://github.com/nim-lang/Nim/issues/7232))
|
||||
- Fixed "the new generic inference rules are broken"
|
||||
([#7247](https://github.com/nim-lang/Nim/issues/7247))
|
||||
- Fixed "Odd `..<` regression"
|
||||
([#6992](https://github.com/nim-lang/Nim/issues/6992))
|
||||
- Fixed "Different proc type inferred from default parameter"
|
||||
([#4659](https://github.com/nim-lang/Nim/issues/4659))
|
||||
- Fixed "Different proc type inferred from default parameter"
|
||||
([#4659](https://github.com/nim-lang/Nim/issues/4659))
|
||||
- Fixed "Testament sometimes ignores test failures"
|
||||
([#7236](https://github.com/nim-lang/Nim/issues/7236))
|
||||
- Fixed "New Allocator Fails On >=4GB Requests"
|
||||
([#7120](https://github.com/nim-lang/Nim/issues/7120))
|
||||
- Fixed "User pragmas hide effect specifications from sempass2"
|
||||
([#7216](https://github.com/nim-lang/Nim/issues/7216))
|
||||
- Fixed "C++: SIGABRT instead of IndexError for out-of-bounds"
|
||||
([#6512](https://github.com/nim-lang/Nim/issues/6512))
|
||||
- Fixed "An uncaught exception in cpp mode doesn't show the exception name/msg"
|
||||
([#6431](https://github.com/nim-lang/Nim/issues/6431))
|
||||
|
|
@ -1,253 +0,0 @@
|
|||
## v0.19.X - XX/XX/2018
|
||||
|
||||
### Changes affecting backwards compatibility
|
||||
|
||||
- The stdlib module ``future`` has been renamed to ``sugar``.
|
||||
- ``macros.callsite`` is now deprecated. Since the introduction of ``varargs``
|
||||
parameters this became unnecessary.
|
||||
- Anonymous tuples with a single element can now be written as ``(1,)`` with a
|
||||
trailing comma. The underlying AST is ``nnkTupleConstr(newLit 1)`` for this
|
||||
example. ``nnkTupleConstr`` is a new node kind your macros need to be able
|
||||
to deal with!
|
||||
- Indexing into a ``cstring`` for the JS target is now mapped
|
||||
to ``charCodeAt``.
|
||||
- Assignments that would "slice" an object into its supertype are now prevented
|
||||
at runtime. Use ``ref object`` with inheritance rather than ``object`` with
|
||||
inheritance to prevent this issue.
|
||||
- The ``not nil`` type annotation now has to be enabled explicitly
|
||||
via ``{.experimental: "notnil".}`` as we are still not pleased with how this
|
||||
feature works with Nim's containers.
|
||||
- The parser now warns about inconsistent spacing around binary operators as
|
||||
these can easily be confused with unary operators. This warning will likely
|
||||
become an error in the future.
|
||||
- The ``'c`` and ``'C'`` suffix for octal literals is now deprecated to
|
||||
bring the language in line with the standard library (e.g. ``parseOct``).
|
||||
- The dot style for import paths (e.g ``import path.to.module`` instead of
|
||||
``import path/to/module``) has been deprecated.
|
||||
|
||||
#### Breaking changes in the standard library
|
||||
|
||||
- ``re.split`` for empty regular expressions now yields every character in
|
||||
the string which is what other programming languages chose to do.
|
||||
- The returned tuple of ``system.instantiationInfo`` now has a third field
|
||||
containing the column of the instantiation.
|
||||
|
||||
- ``cookies.setCookie`` no longer assumes UTC for the expiration date.
|
||||
- ``strutils.formatEng`` does not distinguish between ``nil`` and ``""``
|
||||
strings anymore for its ``unit`` parameter. Instead the space is controlled
|
||||
by a new parameter ``useUnitSpace``.
|
||||
|
||||
- The ``times.parse`` and ``times.format`` procs have been rewritten.
|
||||
The proc signatures are the same so it should generally not break anything.
|
||||
However, the new implementation is a bit stricter, which is a breaking change.
|
||||
For example ``parse("2017-01-01 foo", "yyyy-MM-dd")`` will now raise an error.
|
||||
|
||||
- ``proc `-`*(a, b: Time): int64`` in the ``times`` module has changed return type
|
||||
to ``times.Duration`` in order to support higher time resolutions.
|
||||
The proc is no longer deprecated.
|
||||
|
||||
- The ``times.Timezone`` is now an immutable ref-type that must be initialized
|
||||
with an explicit constructor (``newTimezone``).
|
||||
|
||||
- ``posix.Timeval.tv_sec`` has changed type to ``posix.Time``.
|
||||
|
||||
- ``math.`mod` `` for floats now behaves the same as ``mod`` for integers
|
||||
(previously it used floor division like Python). Use ``math.floorMod`` for the old behavior.
|
||||
|
||||
- For string inputs, ``unicode.isUpper`` and ``unicode.isLower`` now require a
|
||||
second mandatory parameter ``skipNonAlpha``.
|
||||
|
||||
- For string inputs, ``strutils.isUpperAscii`` and ``strutils.isLowerAscii`` now
|
||||
require a second mandatory parameter ``skipNonAlpha``.
|
||||
|
||||
- ``osLastError`` is now marked with ``sideEffect``
|
||||
- The procs ``parseHexInt`` and ``parseOctInt`` now fail on empty strings
|
||||
and strings containing only valid prefixes, e.g. "0x" for hex integers.
|
||||
|
||||
- ``terminal.setCursorPos`` and ``terminal.setCursorXPos`` now work correctly
|
||||
with 0-based coordinates on POSIX (previously, you needed to use
|
||||
1-based coordinates on POSIX for correct behaviour; the Windows behaviour
|
||||
was always correct).
|
||||
|
||||
- ``lineInfoObj`` now returns absolute path instead of project path.
|
||||
It's used by ``lineInfo``, ``check``, ``expect``, ``require``, etc.
|
||||
|
||||
- ``net.sendTo`` no longer returns an int and now raises an ``OSError``.
|
||||
- `threadpool`'s `await` and derivatives have been renamed to `blockUntil`
|
||||
to avoid confusions with `await` from the `async` macro.
|
||||
|
||||
|
||||
#### Breaking changes in the compiler
|
||||
|
||||
- The undocumented ``#? braces`` parsing mode was removed.
|
||||
- The undocumented PHP backend was removed.
|
||||
- The default location of ``nimcache`` for the native code targets was
|
||||
changed. Read [the compiler user guide](https://nim-lang.org/docs/nimc.html#generated-c-code-directory)
|
||||
for more information.
|
||||
|
||||
### Library additions
|
||||
|
||||
- ``re.split`` now also supports the ``maxsplit`` parameter for consistency
|
||||
with ``strutils.split``.
|
||||
- Added ``system.toOpenArray`` in order to support zero-copy slicing
|
||||
operations. This is currently not yet available for the JavaScript target.
|
||||
- Added ``getCurrentDir``, ``findExe``, ``cpDir`` and ``mvDir`` procs to
|
||||
``nimscript``.
|
||||
- The ``times`` module now supports up to nanosecond time resolution when available.
|
||||
- Added the type ``times.Duration`` for representing fixed durations of time.
|
||||
- Added the proc ``times.convert`` for converting between different time units,
|
||||
e.g days to seconds.
|
||||
- Added the proc ``algorithm.binarySearch[T, K]`` with the ```cmp``` parameter.
|
||||
- Added the proc ``algorithm.upperBound``.
|
||||
- Added inverse hyperbolic functions, ``math.arcsinh``, ``math.arccosh`` and ``math.arctanh`` procs.
|
||||
- Added cotangent, secant and cosecant procs ``math.cot``, ``math.sec`` and ``math.csc``; and their hyperbolic, inverse and inverse hyperbolic functions, ``math.coth``, ``math.sech``, ``math.csch``, ``math.arccot``, ``math.arcsec``, ``math.arccsc``, ``math.arccoth``, ``math.arcsech`` and ``math.arccsch`` procs.
|
||||
- Added the procs ``math.floorMod`` and ``math.floorDiv`` for floor based integer division.
|
||||
- Added the procs ``rationals.`div```, ``rationals.`mod```, ``rationals.floorDiv`` and ``rationals.floorMod`` for rationals.
|
||||
- Added the proc ``math.prod`` for product of elements in openArray.
|
||||
- Added the proc ``parseBinInt`` to parse a binary integer from a string, which returns the value.
|
||||
- ``parseOct`` and ``parseBin`` in parseutils now also support the ``maxLen`` argument similar to ``parseHexInt``.
|
||||
- Added the proc ``flush`` for memory mapped files.
|
||||
- Added the ``MemMapFileStream``.
|
||||
- Added a simple interpreting event parser template ``eventParser`` to the ``pegs`` module.
|
||||
- Added ``macros.copyLineInfo`` to copy lineInfo from other node.
|
||||
- Added ``system.ashr`` an arithmetic right shift for integers.
|
||||
|
||||
### Library changes
|
||||
|
||||
- ``macros.astGenRepr``, ``macros.lispRepr`` and ``macros.treeRepr``
|
||||
now escapes the content of string literals consistently.
|
||||
- ``macros.NimSym`` and ``macros.NimIdent`` is now deprecated in favor
|
||||
of the more general ``NimNode``.
|
||||
- ``macros.getImpl`` now includes the pragmas of types, instead of omitting them.
|
||||
- ``macros.hasCustomPragma`` and ``macros.getCustomPragmaVal`` now
|
||||
also support ``ref`` and ``ptr`` types, pragmas on types and variant
|
||||
fields.
|
||||
- ``system.SomeReal`` is now called ``SomeFloat`` for consistency and
|
||||
correctness.
|
||||
- ``algorithm.smartBinarySearch`` and ``algorithm.binarySearch`` is
|
||||
now joined in ``binarySearch``. ``smartbinarySearch`` is now
|
||||
deprecated.
|
||||
- The `terminal` module now exports additional procs for generating ANSI color
|
||||
codes as strings.
|
||||
- Added the parameter ``val`` for the ``CritBitTree[int].inc`` proc.
|
||||
- An exception raised from a ``test`` block of ``unittest`` now shows its type in
|
||||
error message.
|
||||
- The ``compiler/nimeval`` API was rewritten to simplify the "compiler as an
|
||||
API". Using the Nim compiler and its VM as a scripting engine has never been
|
||||
easier. See ``tests/compilerapi/tcompilerapi.nim`` for an example of how to
|
||||
use the Nim VM in a native Nim application.
|
||||
- Added the parameter ``val`` for the ``CritBitTree[T].incl`` proc.
|
||||
- The proc ``tgamma`` was renamed to ``gamma``. ``tgamma`` is deprecated.
|
||||
- The ``pegs`` module now exports getters for the fields of its ``Peg`` and ``NonTerminal``
|
||||
object types. ``Peg``s with child nodes now have the standard ``items`` and ``pairs``
|
||||
iterators.
|
||||
- The ``accept`` socket procedure defined in the ``net`` module can now accept
|
||||
a nil socket.
|
||||
|
||||
### Language additions
|
||||
|
||||
- Dot calls combined with explicit generic instantiations can now be written
|
||||
as ``x.y[:z]`` which is transformed into ``y[z](x)`` by the parser.
|
||||
- ``func`` is now an alias for ``proc {.noSideEffect.}``.
|
||||
- In order to make ``for`` loops and iterators more flexible to use Nim now
|
||||
supports so called "for-loop macros". See
|
||||
the [manual](manual.html#macros-for-loop-macros) for more details.
|
||||
This feature enables a Python-like generic ``enumerate`` implementation.
|
||||
|
||||
- Case statements can now be rewritten via macros. See the [manual](manual.html#macros-case-statement-macros) for more information.
|
||||
This feature enables custom pattern matchers.
|
||||
|
||||
|
||||
- the `typedesc` special type has been renamed to just `type`.
|
||||
- `static` and `type` are now also modifiers similar to `ref` and `ptr`.
|
||||
They denote the special types `static[T]` and `type[T]`.
|
||||
- Forcing compile-time evaluation with `static` now supports specifying
|
||||
the desired target type (as a concrete type or as a type class)
|
||||
- The `type` operator now supports checking that the supplied expression
|
||||
matches an expected type constraint.
|
||||
|
||||
### Language changes
|
||||
|
||||
- The `importcpp` pragma now allows importing the listed fields of generic
|
||||
C++ types. Support for numeric parameters have also been added through
|
||||
the use of `static[T]` types.
|
||||
(#6415)
|
||||
|
||||
- Native C++ exceptions can now be imported with `importcpp` pragma.
|
||||
Imported exceptions can be raised and caught just like Nim exceptions.
|
||||
More details in language manual.
|
||||
|
||||
- ``nil`` for strings/seqs is finally gone. Instead the default value for
|
||||
these is ``"" / @[]``. Use ``--nilseqs:on`` for a transition period.
|
||||
|
||||
- Accessing the binary zero terminator in Nim's native strings
|
||||
is now invalid. Internally a Nim string still has the trailing zero for
|
||||
zero-copy interoperability with ``cstring``. Compile your code with the
|
||||
new switch ``--laxStrings:on`` if you need a transition period.
|
||||
|
||||
- The command syntax now supports keyword arguments after the first comma.
|
||||
|
||||
- Thread-local variables can now be declared inside procs. This implies all
|
||||
the effects of the ``global`` pragma.
|
||||
|
||||
- Nim now supports the ``except`` clause in the export statement.
|
||||
|
||||
- Range float types, example ``range[0.0 .. Inf]``. More details in language manual.
|
||||
- The ``{.this.}`` pragma has been deprecated. It never worked within generics and
|
||||
we found the resulting code harder to read than the more explicit ``obj.field``
|
||||
syntax.
|
||||
- "Memory regions" for pointer types have been deprecated, they were hardly used
|
||||
anywhere. Note that this has **nothing** to do with the ``--gc:regions`` switch
|
||||
of managing memory.
|
||||
|
||||
- The exception hierarchy was slightly reworked, ``SystemError`` was renamed to
|
||||
``CatchableError`` and is the new base class for any exception that is guaranteed to
|
||||
be catchable. This change should have minimal impact on most existing Nim code.
|
||||
|
||||
|
||||
### Tool changes
|
||||
|
||||
- ``jsondoc2`` has been renamed ``jsondoc``, similar to how ``doc2`` was renamed
|
||||
``doc``. The old ``jsondoc`` can still be invoked with ``jsondoc0``.
|
||||
|
||||
### Compiler changes
|
||||
|
||||
- The VM's instruction count limit was raised to 3 million instructions in
|
||||
order to support more complex computations at compile-time.
|
||||
|
||||
- Support for hot code reloading has been implemented for the JavaScript
|
||||
target. To use it, compile your code with `--hotCodeReloading:on` and use a
|
||||
helper library such as LiveReload or BrowserSync.
|
||||
|
||||
- A new compiler option `--cppCompileToNamespace` puts the generated C++ code
|
||||
into the namespace "Nim" in order to avoid naming conflicts with existing
|
||||
C++ code. This is done for all Nim code - internal and exported.
|
||||
|
||||
- Added ``macros.getProjectPath`` and ``os.putEnv`` procs to Nim's virtual
|
||||
machine.
|
||||
|
||||
- The ``deadCodeElim`` option is now always turned on and the switch has no
|
||||
effect anymore, but is recognized for backwards compatibility.
|
||||
|
||||
- ``experimental`` is now a pragma / command line switch that can enable specific
|
||||
language extensions, it is not an all-or-nothing switch anymore.
|
||||
|
||||
- Nintendo Switch was added as a new platform target. See [the compiler user guide](https://nim-lang.org/docs/nimc.html)
|
||||
for more info.
|
||||
|
||||
- macros.bindSym now capable to accepts not only literal string or string constant expression.
|
||||
bindSym enhancement make it also can accepts computed string or ident node inside macros /
|
||||
compile time functions / static blocks. Only in templates / regular code it retains it's old behavior.
|
||||
This new feature can be accessed via {.experimental: "dynamicBindSym".} pragma/switch.
|
||||
|
||||
- On Posix systems the global system wide configuration is now put under ``/etc/nim/nim.cfg``,
|
||||
it used to be ``/etc/nim.cfg``. Usually it does not exist, however.
|
||||
|
||||
- On Posix systems the user configuration is now looked under ``$XDG_CONFIG_HOME/nim/nim.cfg``
|
||||
(if ``XDG_CONFIG_HOME`` is not defined, then under ``~/.config/nim/nim.cfg``). It used to be
|
||||
``$XDG_CONFIG_DIR/nim.cfg`` (and ``~/.config/nim.cfg``).
|
||||
|
||||
Similarly, on Windows, the user configuration is now looked under ``%APPDATA%/nim/nim.cfg``.
|
||||
This used to be ``%APPDATA%/nim.cfg``.
|
||||
|
||||
### Bugfixes
|
||||
|
|
@ -1,294 +0,0 @@
|
|||
## v0.20.0 - 2019-06-06
|
||||
|
||||
|
||||
### Changes affecting backwards compatibility
|
||||
|
||||
- `shr` is now sign preserving. Use `-d:nimOldShiftRight` to enable
|
||||
the old behavior globally.
|
||||
|
||||
- The ``isLower``, ``isUpper`` family of procs in strutils/unicode
|
||||
operating on **strings** have been
|
||||
deprecated since it was unclear what these do. Note that the much more
|
||||
useful procs that operate on ``char`` or ``Rune`` are not affected.
|
||||
|
||||
- `strutils.editDistance` has been deprecated,
|
||||
use `editdistance.editDistance` or `editdistance.editDistanceAscii`
|
||||
instead.
|
||||
|
||||
- The OpenMP parallel iterator \``||`\` now supports any `#pragma omp directive`
|
||||
and not just `#pragma omp parallel for`. See
|
||||
[OpenMP documentation](https://www.openmp.org/wp-content/uploads/OpenMP-4.5-1115-CPP-web.pdf).
|
||||
|
||||
The default annotation is `parallel for`, if you used OpenMP without annotation
|
||||
the change is transparent, if you used annotations you will have to prefix
|
||||
your previous annotations with `parallel for`.
|
||||
|
||||
Furthermore, an overload with positive stepping is available.
|
||||
|
||||
- The `unchecked` pragma was removed, instead use `system.UncheckedArray`.
|
||||
|
||||
- The undocumented ``#? strongSpaces`` parsing mode has been removed.
|
||||
|
||||
- The `not` operator is now always a unary operator, this means that code like
|
||||
``assert not isFalse(3)`` compiles.
|
||||
|
||||
- `getImpl` on a `var` or `let` symbol will now return the full `IdentDefs`
|
||||
tree from the symbol declaration instead of just the initializer portion.
|
||||
|
||||
- Methods are now ordinary "single" methods, only the first parameter is
|
||||
used to select the variant at runtime. For backwards compatibility
|
||||
use the new `--multimethods:on` switch.
|
||||
|
||||
- Generic methods are now deprecated; they never worked well.
|
||||
|
||||
- Compile time checks for integer and float conversions are now stricter.
|
||||
For example, `const x = uint32(-1)` now gives a compile time error instead
|
||||
of being equivalent to `const x = 0xFFFFFFFF'u32`.
|
||||
|
||||
- Using `typed` as the result type in templates/macros now means
|
||||
"expression with a type". The old meaning of `typed` is preserved
|
||||
as `void` or no result type at all.
|
||||
|
||||
- A bug allowed `macro foo(): int = 123` to compile even though a
|
||||
macro has to return a `NimNode`. This has been fixed.
|
||||
|
||||
- With the exception of `uint` and `uint64`, conversion to unsigned types
|
||||
are now range checked during runtime.
|
||||
|
||||
- Macro arguments of type `typedesc` are now passed to the macro as
|
||||
`NimNode` like every other type except `static`. Use `typed` for a
|
||||
behavior that is identical in new and old
|
||||
Nim. See the RFC [Pass typedesc as NimNode to macros](https://github.com/nim-lang/RFCs/issues/148)
|
||||
for more details.
|
||||
|
||||
|
||||
#### Breaking changes in the standard library
|
||||
|
||||
- `osproc.execProcess` now also takes a `workingDir` parameter.
|
||||
|
||||
- `std/sha1.secureHash` now accepts `openArray[char]`, not `string`. (Former
|
||||
successful matches should keep working, though former failures will not.)
|
||||
|
||||
- `options.UnpackError` is no longer a ref type and inherits from `system.Defect`
|
||||
instead of `system.ValueError`.
|
||||
|
||||
- `system.ValueError` now inherits from `system.CatchableError` instead of `system.Defect`.
|
||||
|
||||
- The procs `parseutils.parseBiggestInt`, `parseutils.parseInt`,
|
||||
`parseutils.parseBiggestUInt` and `parseutils.parseUInt` now raise a
|
||||
`ValueError` when the parsed integer is outside of the valid range.
|
||||
Previously they sometimes raised an `OverflowError` and sometimes they
|
||||
returned `0`.
|
||||
|
||||
- The procs `parseutils.parseBin`, `parseutils.parseOct` and `parseutils.parseHex`
|
||||
were not clearing their `var` parameter `number` and used to push its value to
|
||||
the left when storing the parsed string into it. Now they always set the value
|
||||
of the parameter to `0` before storing the result of the parsing, unless the
|
||||
string to parse is not valid (then the value of `number` is not changed).
|
||||
|
||||
- `streams.StreamObject` now restricts its fields to only raise `system.Defect`,
|
||||
`system.IOError` and `system.OSError`.
|
||||
This change only affects custom stream implementations.
|
||||
|
||||
- nre's `RegexMatch.{captureBounds,captures}[]` no longer return `Option` or
|
||||
`nil`/`""`, respectively. Use the newly added `n in p.captures` method to
|
||||
check if a group is captured, otherwise you'll receive an exception.
|
||||
|
||||
- nre's `RegexMatch.{captureBounds,captures}.toTable` no longer accept a
|
||||
default parameter. Instead uncaptured entries are left empty. Use
|
||||
`Table.getOrDefault()` if you need defaults.
|
||||
|
||||
- nre's `RegexMatch.captures.{items,toSeq}` now returns an `Option[string]`
|
||||
instead of a `string`. With the removal of `nil` strings, this is the only
|
||||
way to indicate a missing match. Inside your loops, instead
|
||||
of `capture == ""` or `capture == nil`, use `capture.isSome` to check if a capture is
|
||||
present, and `capture.get` to get its value.
|
||||
|
||||
- nre's `replace()` no longer throws `ValueError` when the replacement string
|
||||
has missing captures. It instead throws `KeyError` for named captures, and
|
||||
`IndexError` for unnamed captures. This is consistent with
|
||||
`RegexMatch.{captureBounds,captures}[]`.
|
||||
|
||||
- `splitFile` now correctly handles edge cases, see #10047.
|
||||
|
||||
- `isNil` is no longer false for undefined in the JavaScript backend:
|
||||
now it's true for both nil and undefined.
|
||||
Use `isNull` or `isUndefined` if you need exact equality:
|
||||
`isNil` is consistent with `===`, `isNull` and `isUndefined` with `==`.
|
||||
|
||||
- several deprecated modules were removed: `ssl`, `matchers`, `httpserver`,
|
||||
`unsigned`, `actors`, `parseurl`
|
||||
|
||||
- two poorly documented and not used modules (`subexes`, `scgi`) were moved to
|
||||
graveyard (they are available as Nimble packages)
|
||||
|
||||
- procs `string.add(int)` and `string.add(float)` which implicitly convert
|
||||
ints and floats to string have been deprecated.
|
||||
Use `string.addInt(int)` and `string.addFloat(float)` instead.
|
||||
|
||||
- ``case object`` branch transitions via ``system.reset`` are deprecated.
|
||||
Compile your code with ``-d:nimOldCaseObjects`` for a transition period.
|
||||
|
||||
- base64 module: The default parameter `newLine` for the `encode` procs
|
||||
was changed from `"\13\10"` to the empty string `""`.
|
||||
|
||||
|
||||
#### Breaking changes in the compiler
|
||||
|
||||
- The compiler now implements the "generic symbol prepass" for `when` statements
|
||||
in generics, see bug #8603. This means that code like this does not compile
|
||||
anymore:
|
||||
|
||||
```nim
|
||||
proc enumToString*(enums: openArray[enum]): string =
|
||||
# typo: 'e' instead 'enums'
|
||||
when e.low.ord >= 0 and e.high.ord < 256:
|
||||
result = newString(enums.len)
|
||||
else:
|
||||
result = newString(enums.len * 2)
|
||||
```
|
||||
|
||||
- ``discard x`` is now illegal when `x` is a function symbol.
|
||||
|
||||
- Implicit imports via ``--import: module`` in a config file are now restricted
|
||||
to the main package.
|
||||
|
||||
|
||||
### Library additions
|
||||
|
||||
- There is a new stdlib module `std/editdistance` as a replacement for the
|
||||
deprecated `strutils.editDistance`.
|
||||
|
||||
- There is a new stdlib module `std/wordwrap` as a replacement for the
|
||||
deprecated `strutils.wordwrap`.
|
||||
|
||||
- Added `split`, `splitWhitespace`, `size`, `alignLeft`, `align`,
|
||||
`strip`, `repeat` procs and iterators to `unicode.nim`.
|
||||
|
||||
- Added `or` for `NimNode` in `macros`.
|
||||
|
||||
- Added `system.typeof` for more control over how `type` expressions
|
||||
can be deduced.
|
||||
|
||||
- Added `macros.isInstantiationOf` for checking if the proc symbol
|
||||
is instantiation of generic proc symbol.
|
||||
|
||||
- Added the parameter ``isSorted`` for the ``sequtils.deduplicate`` proc.
|
||||
|
||||
- There is a new stdlib module `std/diff` to compute the famous "diff"
|
||||
of two texts by line.
|
||||
|
||||
- Added `os.relativePath`.
|
||||
|
||||
- Added `parseopt.remainingArgs`.
|
||||
|
||||
- Added `os.getCurrentCompilerExe` (implemented as `getAppFilename` at CT),
|
||||
can be used to retrieve the currently executing compiler.
|
||||
|
||||
- Added `xmltree.toXmlAttributes`.
|
||||
|
||||
- Added ``std/sums`` module for fast summation functions.
|
||||
|
||||
- Added `Rusage`, `getrusage`, `wait4` to the posix interface.
|
||||
|
||||
- Added the `posix_utils` module.
|
||||
|
||||
- Added `system.default`.
|
||||
|
||||
- Added `sequtils.items` for closure iterators, allows closure iterators
|
||||
to be used by the `mapIt`, `filterIt`, `allIt`, `anyIt`, etc.
|
||||
|
||||
|
||||
### Library changes
|
||||
|
||||
- The string output of `macros.lispRepr` proc has been tweaked
|
||||
slightly. The `dumpLisp` macro in this module now outputs an
|
||||
indented proper Lisp, devoid of commas.
|
||||
|
||||
- Added `macros.signatureHash` that returns a stable identifier
|
||||
derived from the signature of a symbol.
|
||||
|
||||
- In `strutils` empty strings now no longer matched as substrings
|
||||
anymore.
|
||||
|
||||
- The `Complex` type is now a generic object and not a tuple anymore.
|
||||
|
||||
- The `ospaths` module is now deprecated, use `os` instead. Note that
|
||||
`os` is available in a NimScript environment but unsupported
|
||||
operations produce a compile-time error.
|
||||
|
||||
- The `parseopt` module now supports a new flag `allowWhitespaceAfterColon`
|
||||
(default value: true) that can be set to `false` for better Posix
|
||||
interoperability. (Bug #9619.)
|
||||
|
||||
- `os.joinPath` and `os.normalizePath` handle edge cases like ``"a/b/../../.."``
|
||||
differently.
|
||||
|
||||
- `securehash` was moved to `lib/deprecated`.
|
||||
|
||||
- The switch ``-d:useWinAnsi`` is not supported anymore.
|
||||
|
||||
- In `times` module, procs `format` and `parse` accept a new optional
|
||||
`DateTimeLocale` argument for formatting/parsing dates in other languages.
|
||||
|
||||
|
||||
### Language additions
|
||||
|
||||
- Vm support for float32<->int32 and float64<->int64 casts was added.
|
||||
- There is a new pragma block `noSideEffect` that works like
|
||||
the `gcsafe` pragma block.
|
||||
- added `os.getCurrentProcessId`.
|
||||
- User defined pragmas are now allowed in the pragma blocks.
|
||||
- Pragma blocks are no longer eliminated from the typed AST tree to preserve
|
||||
pragmas for further analysis by macros.
|
||||
- Custom pragmas are now supported for `var` and `let` symbols.
|
||||
- Tuple unpacking is now supported for constants and for loop variables.
|
||||
- Case object branches can be initialized with a runtime discriminator if
|
||||
possible discriminator values are constrained within a case statement.
|
||||
|
||||
### Language changes
|
||||
|
||||
- The standard extension for SCF (source code filters) files was changed from
|
||||
``.tmpl`` to ``.nimf``,
|
||||
it's more recognizable and allows tools like Github to recognize it as Nim,
|
||||
see [#9647](https://github.com/nim-lang/Nim/issues/9647).
|
||||
The previous extension will continue to work.
|
||||
|
||||
- Pragma syntax is now consistent. Previous syntax where type pragmas did not
|
||||
follow the type name is now deprecated. Also pragma before generic parameter
|
||||
list is deprecated to be consistent with how pragmas are used with a proc. See
|
||||
[#8514](https://github.com/nim-lang/Nim/issues/8514) and
|
||||
[#1872](https://github.com/nim-lang/Nim/issues/1872) for further details.
|
||||
|
||||
- Hash sets and tables are initialized by default. The explicit `initHashSet`,
|
||||
`initTable`, etc. are not needed anymore.
|
||||
|
||||
|
||||
### Tool changes
|
||||
|
||||
- `jsondoc` now includes a `moduleDescription` field with the module
|
||||
description. `jsondoc0` shows comments as its own objects as shown in the
|
||||
documentation.
|
||||
- `nimpretty`: --backup now defaults to `off` instead of `on` and the flag was
|
||||
undocumented; use `git` instead of relying on backup files.
|
||||
- `koch` now defaults to build the latest *stable* Nimble version unless you
|
||||
explicitly ask for the latest master version via `--latest`.
|
||||
|
||||
|
||||
### Compiler changes
|
||||
|
||||
- The deprecated `fmod` proc is now unavailable on the VM.
|
||||
- A new `--outdir` option was added.
|
||||
- The compiled JavaScript file for the project produced by executing `nim js`
|
||||
will no longer be placed in the nimcache directory.
|
||||
- The `--hotCodeReloading` has been implemented for the native targets.
|
||||
The compiler also provides a new more flexible API for handling the
|
||||
hot code reloading events in the code.
|
||||
- The compiler now supports a ``--expandMacro:macroNameHere`` switch
|
||||
for easy introspection into what a macro expands into.
|
||||
- The `-d:release` switch now does not disable runtime checks anymore.
|
||||
For a release build that also disables runtime checks
|
||||
use `-d:release -d:danger` or simply `-d:danger`.
|
||||
|
||||
|
||||
### Bugfixes
|
||||
|
|
@ -1,55 +0,0 @@
|
|||
# v0.20.2 - 2019-07-17
|
||||
|
||||
|
||||
## Changes affecting backwards compatibility
|
||||
|
||||
- All `strutils.rfind` procs now take `start` and `last` like `strutils.find`
|
||||
with the same data slice/index meaning. This is backwards compatible for
|
||||
calls *not* changing the `rfind` `start` parameter from its default. (#11487)
|
||||
|
||||
In the unlikely case that you were using `rfind X, start=N`, or `rfind X, N`,
|
||||
then you need to change that to `rfind X, last=N` or `rfind X, 0, N`. (This
|
||||
should minimize gotchas porting code from other languages like Python or C++.)
|
||||
|
||||
- On Windows stderr/stdout/stdin are not opened as binary files anymore. Use the switch
|
||||
`-d:nimBinaryStdFiles` for a transition period.
|
||||
|
||||
### Breaking changes in the standard library
|
||||
|
||||
- Mac OS X / BSD: TSa_Family is now the ``uint8`` type, so type
|
||||
conversions like ``x.sin_family = uint16 toInt(nativesockets.AF_INET)``
|
||||
need to be changed into ``x.sin_family = TSa_Family toInt(nativesockets.AF_INET)``.
|
||||
|
||||
|
||||
### Breaking changes in the compiler
|
||||
|
||||
|
||||
## Library additions
|
||||
|
||||
- `toOpenArray` is now available for the JS target.
|
||||
|
||||
## Library changes
|
||||
|
||||
- Fix async IO operations stalling even after socket is closed. (#11232)
|
||||
|
||||
- More informative error message for `streams.openFileStream`. (#11438)
|
||||
|
||||
|
||||
## Language additions
|
||||
|
||||
|
||||
## Language changes
|
||||
|
||||
|
||||
### Tool changes
|
||||
|
||||
|
||||
### Compiler changes
|
||||
|
||||
- Better error message for IndexError for empty containers. (#11476)
|
||||
|
||||
- Fix regression in semfold for old right shift. (#11477)
|
||||
|
||||
- Fix for passing tuples as static params to macros. (#11423)
|
||||
|
||||
## Bugfixes
|
||||
|
|
@ -1,138 +0,0 @@
|
|||
# v1.0 - 2019-09-23
|
||||
|
||||
|
||||
## Changes affecting backwards compatibility
|
||||
|
||||
- The switch ``-d:nimBinaryStdFiles`` does not exist anymore. Instead
|
||||
stdin/stdout/stderr are binary files again. This change only affects
|
||||
Windows.
|
||||
|
||||
- On Windows console applications the code-page is set at program startup
|
||||
to UTF-8. Use the new switch `-d:nimDontSetUtf8CodePage` to disable this
|
||||
feature.
|
||||
|
||||
- The language definition and compiler are now stricter about ``gensym``'ed
|
||||
symbols in hygienic templates. See the section in the
|
||||
[manual](https://nim-lang.org/docs/manual.html#templates-hygiene-in-templates)
|
||||
for further details. Use the compiler switch `--oldgensym:on` for a
|
||||
transition period.
|
||||
|
||||
|
||||
### Breaking changes in the standard library
|
||||
|
||||
- We removed `unicode.Rune16` without any deprecation period as the name
|
||||
was wrong (see the [RFC](https://github.com/nim-lang/RFCs/issues/151) for details)
|
||||
and we didn't find any usages of it in the wild. If you still need it, add this
|
||||
piece of code to your project:
|
||||
```nim
|
||||
type
|
||||
Rune16* = distinct int16
|
||||
```
|
||||
|
||||
- `exportc` now uses C instead of C++ mangling with `nim cpp`, matching behavior
|
||||
of `importc`, see #10578.
|
||||
Use the new `exportcpp` to mangle as C++ when using `nim cpp`.
|
||||
|
||||
|
||||
### Breaking changes in the compiler
|
||||
|
||||
- A bug allowing `int` to be implicitly converted to range types of smaller size
|
||||
(e.g `range[0'i8..10'i8]`) has been fixed.
|
||||
|
||||
|
||||
|
||||
## Library additions
|
||||
|
||||
- `encodings.getCurrentEncoding` now distinguishes between the console's
|
||||
encoding and the OS's encoding. This distinction is only meaningful on
|
||||
Windows.
|
||||
- Added `system.getOsFileHandle` which is usually more useful
|
||||
than `system.getFileHandle`. This distinction is only meaningful on
|
||||
Windows.
|
||||
- Added a `json.parseJsonFragments` iterator that can be used to speedup
|
||||
JSON processing substantially when there are JSON fragments separated
|
||||
by whitespace.
|
||||
|
||||
|
||||
|
||||
## Library changes
|
||||
|
||||
- Added `os.delEnv` and `nimscript.delEnv`. (#11466)
|
||||
|
||||
- Enabled Oid usage in hashtables. (#11472)
|
||||
|
||||
- Added `unsafeColumnAt` procs, that return unsafe cstring from InstantRow. (#11647)
|
||||
|
||||
- Make public `Sha1Digest` and `Sha1State` types and `newSha1State`,
|
||||
`update` and `finalize` procedures from `sha1` module. (#11694)
|
||||
|
||||
- Added the `std/monotimes` module which implements monotonic timestamps.
|
||||
|
||||
- Consistent error handling of two `exec` overloads. (#10967)
|
||||
|
||||
- Officially the following modules now have an unstable API:
|
||||
- std/varints
|
||||
- core/allocators
|
||||
- core/hotcodereloading
|
||||
- asyncstreams
|
||||
- base64
|
||||
- browsers
|
||||
- collections/rtarrays
|
||||
- collections/sharedlist
|
||||
- collections/sharedtable
|
||||
- concurrency/atomics
|
||||
- concurrency/cpuload
|
||||
- concurrency/threadpool
|
||||
- coro
|
||||
- endians
|
||||
- httpcore
|
||||
- parsesql
|
||||
- pathnorm
|
||||
- reservedmem
|
||||
- typetraits
|
||||
|
||||
Every other stdlib module is API stable with respect to version 1.
|
||||
|
||||
|
||||
|
||||
## Language additions
|
||||
|
||||
- Inline iterators returning `lent T` types are now supported, similarly to
|
||||
iterators returning `var T`:
|
||||
```nim
|
||||
iterator myitems[T](x: openarray[T]): lent T
|
||||
iterator mypairs[T](x: openarray[T]): tuple[idx: int, val: lent T]
|
||||
```
|
||||
|
||||
- Added an `importjs` pragma that can now be used instead of `importcpp`
|
||||
and `importc` to import symbols from JavaScript. `importjs` for routines always
|
||||
takes a "pattern" for maximum flexibility.
|
||||
|
||||
|
||||
|
||||
## Language changes
|
||||
|
||||
- `uint64` is now finally a regular ordinal type. This means `high(uint64)` compiles
|
||||
and yields the correct value.
|
||||
|
||||
|
||||
### Tool changes
|
||||
|
||||
- The Nim compiler now does not recompile the Nim project via ``nim c -r`` if
|
||||
no dependent Nim file changed. This feature can be overridden by
|
||||
the ``--forceBuild`` command line option.
|
||||
- The Nim compiler now warns about unused module imports. You can use a
|
||||
top level ``{.used.}`` pragma in the module that you want to be importable
|
||||
without producing this warning.
|
||||
- The "testament" testing tool's name was changed
|
||||
from `tester` to `testament` and is generally available as a tool to run Nim
|
||||
tests automatically.
|
||||
|
||||
|
||||
### Compiler changes
|
||||
|
||||
- VM can now cast integer type arbitrarily. (#11459)
|
||||
|
||||
|
||||
|
||||
## Bugfixes
|
||||
|
|
@ -1,56 +0,0 @@
|
|||
# v1.0.2 - 2019-10-23
|
||||
|
||||
|
||||
## Bugfixes
|
||||
|
||||
* fixes the --verbosity:2 regression
|
||||
* Fixed "Fail to compile a file twice under Windows (v1.0 bug)." [#12242](https://github.com/nim-lang/Nim/issues/12242)
|
||||
* fix nimpretty removing space before pragma
|
||||
* JS: gensym is stricter for 'this'
|
||||
* Fixed "VM Assertion Error with newruntime" [#12294](https://github.com/nim-lang/Nim/issues/12294)
|
||||
* Fixed "Assertion error when running `nim check` on compiler/nim.nim" [#12281](https://github.com/nim-lang/Nim/issues/12281)
|
||||
* Fixed "Compiler crash with empty array and generic instantiation with int as parameter" [#12264](https://github.com/nim-lang/Nim/issues/12264)
|
||||
* Fixed "Regression in JS backend codegen "Error: request to generate code for .compileTime proc"" [#12240](https://github.com/nim-lang/Nim/issues/12240)
|
||||
* Fix how `relativePath` handle case sensitiviy
|
||||
* Fixed "SIGSEGV in compiler when using generic types and seqs" [#12336](https://github.com/nim-lang/Nim/issues/12336)
|
||||
* Fixed "[1.0.0] weird interaction between `import os` and casting integer to char on macosx trigger bad codegen" [#12291](https://github.com/nim-lang/Nim/issues/12291)
|
||||
* VM: no special casing for big endian machines
|
||||
* Fixed "`internal error: environment misses` with a simple template inside one of Jester macros" [#12323](https://github.com/nim-lang/Nim/issues/12323)
|
||||
* nimsuggest: fix tcp socket leak
|
||||
* nimsuggest: fix tcp socket leak for epc backend
|
||||
* Fixed "`writeFile` and `write(f, str)` skip null bytes on Windows" [#12315](https://github.com/nim-lang/Nim/issues/12315)
|
||||
* Fixed "Crash in intsets symmetric_difference" [#12366](https://github.com/nim-lang/Nim/issues/12366)
|
||||
* Fixed "[regression] VM crash when dealing with var param of a proc result" [#12244](https://github.com/nim-lang/Nim/issues/12244)
|
||||
* fixes a koch regression that made 'koch boot --listcmd' not work anymore
|
||||
* Fixed "[regression] inconsistent signed int `mod` operator between runtime, compiletime, and semfold" [#12332](https://github.com/nim-lang/Nim/issues/12332)
|
||||
* Fixed "Boehm disables interior pointer checking" [#12286](https://github.com/nim-lang/Nim/issues/12286)
|
||||
* Fixes semCustomPragma when nkSym
|
||||
* Fixed yield in nkCheckedFieldExpr
|
||||
* Fixed "`randomize()` from `random` not working on JS" [#12418](https://github.com/nim-lang/Nim/issues/12418)
|
||||
* Fixed "Compiler crash with invalid object variant" [#12379](https://github.com/nim-lang/Nim/issues/12379)
|
||||
* fix type's case in random.nim
|
||||
* Fixed "Update docs with a better way to signal unimplemented methods" [#10804](https://github.com/nim-lang/Nim/issues/10804)
|
||||
* Fixed "Nim language manual, push pragma is not explained well" [#10824](https://github.com/nim-lang/Nim/issues/10824)
|
||||
* Fixed "[regression] Importing more than one module with same name from different packages produce bad codegen" [#12420](https://github.com/nim-lang/Nim/issues/12420)
|
||||
* Namespace unittest enums to avoid name conflicts
|
||||
* Fixed "VM checks unsigned integers for overflow." [#12310](https://github.com/nim-lang/Nim/issues/12310)
|
||||
* Fixed "line directive is not generated for first line of function definition" [#12426](https://github.com/nim-lang/Nim/issues/12426)
|
||||
|
||||
|
||||
|
||||
## Documentation improvements
|
||||
|
||||
* threadpool: fix link in docs (#12258)
|
||||
* Fix spellings (#12277)
|
||||
* fix #12278, don't expose internal PCRE documentation
|
||||
* Fixed "Documentation of quitprocs is wrong" [#12279(https://github.com/nim-lang/Nim/issues/12279)
|
||||
* Fix typo in docs
|
||||
* Fix reference to parseSpec proc in readme
|
||||
* [doc/tut1] removed discard discussion in comments
|
||||
* Documentation improvements around the db interface
|
||||
* Easier build instructions for windows - just run `build_all.bat`.
|
||||
* fix a few dead links and a missing sentence in documentation
|
||||
* Macro docs additions
|
||||
* Updated the code example in the os module to use better grammar.
|
||||
* Mention "lambdas" and `=>` in the manual
|
||||
* Better documentation on Garbage Collector
|
||||
|
|
@ -1,535 +0,0 @@
|
|||
# v1.2.0 - 2020-04-02
|
||||
|
||||
|
||||
## Standard library additions and changes
|
||||
- Added overloaded `strformat.fmt` macro that use specified characters as
|
||||
delimiter instead of '{' and '}'.
|
||||
- Added new procs in `tables.nim`: `OrderedTable.pop`, `CountTable.del`,
|
||||
`CountTable.pop`, `Table.pop`.
|
||||
- Added `strtabs.clear` overload that reuses the existing mode.
|
||||
- Added `browsers.osOpen` const alias for the operating system specific *"open"* command.
|
||||
- Added `sugar.dup` for turning in-place algorithms like `sort` and `shuffle`
|
||||
into operations that work on a copy of the data and return the mutated copy,
|
||||
like the existing `sorted` does.
|
||||
- Added `sugar.collect` that does comprehension for seq/set/table collections.
|
||||
- Added `sugar.capture` for capturing some local loop variables when creating a
|
||||
closure. This is an enhanced version of `closureScope`.
|
||||
- Added `typetraits.tupleLen` to get number of elements of a tuple/type tuple,
|
||||
and `typetraits.get` to get the ith element of a type tuple.
|
||||
- Added `typetraits.genericParams` to return a tuple of generic params from a
|
||||
generic instantiation.
|
||||
- `options` now treats `proc` like other pointer types, meaning `nil` proc variables
|
||||
are converted to `None`.
|
||||
- Added `os.normalizePathEnd` for additional path sanitization.
|
||||
- Added `times.fromUnixFloat,toUnixFloat`, sub-second resolution versions of
|
||||
`fromUnix`,`toUnixFloat`.
|
||||
- Added `wrapnils` module for chains of field-access and indexing where the LHS
|
||||
can be nil. This simplifies code by reducing need for if-else branches around
|
||||
intermediate maybe nil values. E.g. `echo ?.n.typ.kind`.
|
||||
- Added `minIndex`, `maxIndex` and `unzip` to the `sequtils` module.
|
||||
- Added `os.isRelativeTo` to tell whether a path is relative to another.
|
||||
- Added `resetOutputFormatters` to `unittest`.
|
||||
- Added `expectIdent` to the `macros` module.
|
||||
- Added `os.isValidFilename` that returns `true` if `filename` argument is valid
|
||||
for cross-platform use.
|
||||
- Added `times.isLeapDay`.
|
||||
- `base64` adds URL-Safe Base64, implements RFC-4648 Section-7.
|
||||
- Added a new module, `std / compilesettings` for querying the compiler about
|
||||
diverse configuration settings.
|
||||
- Added `net.getPeerCertificates` and `asyncnet.getPeerCertificates` for
|
||||
retrieving the verified certificate chain of the peer we are connected to
|
||||
through an SSL-wrapped `Socket`/`AsyncSocket`.
|
||||
- Added `browsers.openDefaultBrowser` without URL, implements IETF RFC-6694 Section-3.
|
||||
- Added `jsconsole.trace`, `jsconsole.table`, `jsconsole.exception` for JavaScript target.
|
||||
- Added `distinctBase` overload for values: `assert 12.MyInt.distinctBase == 12`
|
||||
- Added new module `std/stackframes`, in particular `setFrameMsg`, which enables
|
||||
custom runtime annotation of stackframes, see #13351 for examples.
|
||||
Turn on/off via `--stackTraceMsgs:on/off`.
|
||||
- Added `sequtils.countIt`, allowing for counting items using a predicate.
|
||||
- Added a `with` macro for easy function chaining that's available everywhere,
|
||||
there is no need to concern your APIs with returning the first argument
|
||||
to enable "chaining", instead use the dedicated macro `with` that
|
||||
was designed for it. For example:
|
||||
|
||||
```nim
|
||||
import std/with
|
||||
|
||||
type
|
||||
Foo = object
|
||||
col, pos: string
|
||||
|
||||
proc setColor(f: var Foo; r, g, b: int) = f.col = $(r, g, b)
|
||||
proc setPosition(f: var Foo; x, y: float) = f.pos = $(x, y)
|
||||
|
||||
var f: Foo
|
||||
with(f, setColor(2, 3, 4), setPosition(0.0, 1.0))
|
||||
echo f
|
||||
```
|
||||
|
||||
- `macros.newLit` now works for ref object types.
|
||||
- `macro pragmas` can now be used in type sections.
|
||||
- 5 new pragmas were added to Nim in order to make the upcoming tooling more
|
||||
convenient to use. Nim compiler checks these pragmas for syntax but otherwise
|
||||
ignores them. The pragmas are `requires`, `ensures`, `assume`, `assert`, `invariant`.
|
||||
- `system.writeFile` has been overloaded to also support `openarray[byte]`.
|
||||
- `asyncdispatch.drain` now properly takes into account `selector.hasPendingOperations`
|
||||
and only returns once all pending async operations are guaranteed to have completed.
|
||||
- `sequtils.zip` now returns a sequence of anonymous tuples i.e. those tuples
|
||||
now do not have fields named "a" and "b".
|
||||
- `distinctBase` has been moved from `sugar` to `typetraits` and now it is
|
||||
implemented as compiler type trait instead of macro. `distinctBase` in sugar
|
||||
module is now deprecated.
|
||||
- `CountTable.mget` has been removed from `tables.nim`. It didn't work, and it
|
||||
was an oversight to be included in v1.0.
|
||||
- `tables.merge(CountTable, CountTable): CountTable` has been removed.
|
||||
It didn't work well together with the existing inplace version of the same proc
|
||||
(`tables.merge(var CountTable, CountTable)`).
|
||||
It was an oversight to be included in v1.0.
|
||||
- `asyncdispatch.drain` now consistently uses the passed timeout value for all
|
||||
iterations of the event loop, and not just the first iteration.
|
||||
This is more consistent with the other asyncdispatch APIs, and allows
|
||||
`asyncdispatch.drain` to be more efficient.
|
||||
- `base64.encode` and `base64.decode` were made faster by about 50%.
|
||||
- `htmlgen` adds [MathML](https://wikipedia.org/wiki/MathML) support
|
||||
(ISO 40314).
|
||||
- `macros.eqIdent` is now invariant to export markers and backtick quotes.
|
||||
- `htmlgen.html` allows `lang` in the `<html>` tag and common valid attributes.
|
||||
- `macros.basename` and `basename=` got support for `PragmaExpr`,
|
||||
so that an expression like `MyEnum {.pure.}` is handled correctly.
|
||||
- `httpclient.maxredirects` changed from `int` to `Natural`, because negative values
|
||||
serve no purpose whatsoever.
|
||||
- `httpclient.newHttpClient` and `httpclient.newAsyncHttpClient` added `headers`
|
||||
argument to set initial HTTP Headers, instead of a hardcoded empty `newHttpHeader()`.
|
||||
- `parseutils.parseUntil` has now a different behaviour if the `until` parameter is
|
||||
empty. This was required for intuitive behaviour of the strscans module
|
||||
(see bug #13605).
|
||||
- `strutils.formatFloat` with `precision = 0` has the same behavior in all
|
||||
backends, and it is compatible with Python's behavior,
|
||||
e.g. `formatFloat(3.14159, precision = 0)` is now `3`, not `3.`.
|
||||
- `times.parse` now only uses input to compute its result, and not `now`:
|
||||
`parse("2020", "YYYY", utc())` is now `2020-01-01T00:00:00Z` instead of
|
||||
`2020-03-02T00:00:00Z` if run on 03-02; it also doesn't crash anymore when
|
||||
used on 29th, 30th, 31st of each month.
|
||||
- `httpcore.==(string, HttpCode)` is now deprecated due to lack of practical
|
||||
usage. The `$` operator can be used to obtain the string form of `HttpCode`
|
||||
for comparison if desired.
|
||||
- `std/oswalkdir` was buggy, it's now deprecated and reuses `std/os` procs.
|
||||
- `os.walkDir` and `os.walkDirRec` now have new flag, `checkDir` (default: false).
|
||||
If it is set to true, it will throw if input dir is invalid instead of a noop
|
||||
(which is the default behaviour, as it was before this change),
|
||||
`os.walkDirRec` only throws if top-level dir is invalid, but ignores errors for
|
||||
subdirs, otherwise it would be impossible to resume iteration.
|
||||
- The `FD` variant of `selector.unregister` for `ioselector_epoll` and
|
||||
`ioselector_select` now properly handle the `Event.User` select event type.
|
||||
- `joinPath` path normalization when `/` is the first argument works correctly:
|
||||
`assert "/" / "/a" == "/a"`. Fixed the edge case: `assert "" / "" == ""`.
|
||||
- `xmltree` now adds indentation consistently to child nodes for any number
|
||||
of children nodes.
|
||||
- `os.splitPath()` behavior synchronized with `os.splitFile()` to return "/"
|
||||
as the dir component of `/root_sub_dir` instead of the empty string.
|
||||
- The deprecated `lc` macro has been removed from `sugar`. It is now replaced
|
||||
with the more powerful `collect` macro.
|
||||
- `os.relativePath("foo", "foo")` is now `"."`, not `""`, as `""` means invalid
|
||||
path and shouldn't be conflated with `"."`; use `-d:nimOldRelativePathBehavior`
|
||||
to restore the old behavior.
|
||||
- `os.joinPath(a, b)` now honors trailing slashes in `b` (or `a` if `b` = "").
|
||||
- `base64.encode` no longer supports `lineLen` and `newLine`.
|
||||
Use `base64.encodeMime` instead.
|
||||
|
||||
|
||||
### Breaking changes
|
||||
|
||||
- `net.newContext` now performs SSL Certificate checking on Linux and OSX.
|
||||
Define `nimDisableCertificateValidation` to disable it globally.
|
||||
|
||||
|
||||
|
||||
## Language changes
|
||||
|
||||
- An `align` pragma can now be used for variables and object fields, similar
|
||||
to the `alignas` declaration modifier in C/C++.
|
||||
- The `=sink` type bound operator is now optional. The compiler can now use a
|
||||
combination of `=destroy` and `copyMem` to move objects efficiently.
|
||||
- Unsigned integer operators have been fixed to allow promotion of the first operand.
|
||||
- Conversions to unsigned integers are unchecked at runtime, imitating earlier Nim
|
||||
versions. The documentation was improved to acknowledge this special case.
|
||||
See https://github.com/nim-lang/RFCs/issues/175 for more details.
|
||||
- There is a new syntax for lvalue references: `var b {.byaddr.} = expr` enabled by
|
||||
`import std/decls`.
|
||||
- `var a {.foo.}: MyType = expr` now lowers to `foo(a, MyType, expr)` for
|
||||
non-builtin pragmas, enabling things like lvalue references (see `decls.byaddr`).
|
||||
|
||||
|
||||
|
||||
## Compiler changes
|
||||
|
||||
- The generated JS code uses spaces, instead of mixing spaces and tabs.
|
||||
- The Nim compiler now supports the ``--asm`` command option for easier
|
||||
inspection of the produced assembler code.
|
||||
- The Nim compiler now supports a new pragma called ``.localPassc`` to
|
||||
pass specific compiler options to the C(++) backend for the C(++) file
|
||||
that was produced from the current Nim module.
|
||||
- The compiler now inferes "sink parameters". To disable this for a specific routine,
|
||||
annotate it with `.nosinks`. To disable it for a section of code, use
|
||||
`{.push sinkInference: off.}`...`{.pop.}`.
|
||||
- The compiler now supports a new switch `--panics:on` that turns runtime
|
||||
errors like `IndexError` or `OverflowError` into fatal errors that **cannot**
|
||||
be caught via Nim's `try` statement. `--panics:on` can improve the
|
||||
runtime efficiency and code size of your program significantly.
|
||||
- The compiler now warns about inheriting directly from `system.Exception` as
|
||||
this is **very bad** style. You should inherit from `ValueError`, `IOError`,
|
||||
`OSError` or from a different specific exception type that inherits from
|
||||
`CatchableError` and cannot be confused with a `Defect`.
|
||||
- The error reporting for Nim's effect system has been improved.
|
||||
- Implicit conversions for `const` behave correctly now, meaning that code like
|
||||
`const SOMECONST = 0.int; procThatTakesInt32(SOMECONST)` will be illegal now.
|
||||
Simply write `const SOMECONST = 0` instead.
|
||||
- The `{.dynlib.}` pragma is now required for exporting symbols when making
|
||||
shared objects on POSIX and macOS, which make it consistent with the behavior
|
||||
on Windows.
|
||||
- The compiler is now more strict about type conversions concerning proc
|
||||
types: Type conversions cannot be used to hide `.raise` effects or side
|
||||
effects, instead a `cast` must be used. With the flag `--useVersion:1.0` the
|
||||
old behaviour is emulated.
|
||||
- The Nim compiler now implements a faster way to detect overflows based
|
||||
on GCC's `__builtin_sadd_overflow` family of functions. (Clang also
|
||||
supports these). Some versions of GCC lack this feature and unfortunately
|
||||
we cannot detect this case reliably. So if you get compilation errors like
|
||||
"undefined reference to `__builtin_saddll_overflow`" compile your programs
|
||||
with `-d:nimEmulateOverflowChecks`.
|
||||
|
||||
|
||||
|
||||
|
||||
## Bugfixes
|
||||
|
||||
- Fixed "`nimgrep --nocolor` is ignored on posix; should be instead: `--nimgrep --color=[auto]|true|false`"
|
||||
([#7591](https://github.com/nim-lang/Nim/issues/7591))
|
||||
- Fixed "Runtime index on const array (of converted obj) causes C-compiler error"
|
||||
([#10514](https://github.com/nim-lang/Nim/issues/10514))
|
||||
- Fixed "windows x86 with vcc compile error with "asmNoStackFrame""
|
||||
([#12298](https://github.com/nim-lang/Nim/issues/12298))
|
||||
- Fixed "[TODO] regression: Error: Locks requires --threads:on option"
|
||||
([#12330](https://github.com/nim-lang/Nim/issues/12330))
|
||||
- Fixed "Add --cc option to --help or --fullhelp output"
|
||||
([#12010](https://github.com/nim-lang/Nim/issues/12010))
|
||||
- Fixed "questionable `csize` definition in `system.nim`"
|
||||
([#12187](https://github.com/nim-lang/Nim/issues/12187))
|
||||
- Fixed "os.getAppFilename() returns incorrect results on OpenBSD"
|
||||
([#12389](https://github.com/nim-lang/Nim/issues/12389))
|
||||
- Fixed "HashSet[uint64] slow insertion depending on values"
|
||||
([#11764](https://github.com/nim-lang/Nim/issues/11764))
|
||||
- Fixed "Differences between compiling 'classic call syntax' vs 'method call syntax' ."
|
||||
([#12453](https://github.com/nim-lang/Nim/issues/12453))
|
||||
- Fixed "c -d:nodejs --> SIGSEGV: Illegal storage access"
|
||||
([#12502](https://github.com/nim-lang/Nim/issues/12502))
|
||||
- Fixed "Closure iterator crashes on --newruntime due to "dangling references""
|
||||
([#12443](https://github.com/nim-lang/Nim/issues/12443))
|
||||
- Fixed "No `=destroy` for elements of closure environments other than for latest devel --gc:destructors"
|
||||
([#12577](https://github.com/nim-lang/Nim/issues/12577))
|
||||
- Fixed "strutils:formatBiggestFloat() gives different results in JS mode"
|
||||
([#8242](https://github.com/nim-lang/Nim/issues/8242))
|
||||
- Fixed "Regression (devel): the new `csize_t` definition isn't consistently used, nor tested thoroughly..."
|
||||
([#12597](https://github.com/nim-lang/Nim/issues/12597))
|
||||
- Fixed "tables.take() is defined only for `Table` and missed for other table containers"
|
||||
([#12519](https://github.com/nim-lang/Nim/issues/12519))
|
||||
- Fixed "`pthread_key_t` errors on OpenBSD"
|
||||
([#12135](https://github.com/nim-lang/Nim/issues/12135))
|
||||
- Fixed "newruntime: simple seq pop at ct results in compile error"
|
||||
([#12644](https://github.com/nim-lang/Nim/issues/12644))
|
||||
- Fixed "[Windows] finish.exe C:\Users\<USERNAME>\.nimble\bin is not in your PATH environment variable."
|
||||
([#12319](https://github.com/nim-lang/Nim/issues/12319))
|
||||
- Fixed "Error with strformat + asyncdispatch + const"
|
||||
([#12612](https://github.com/nim-lang/Nim/issues/12612))
|
||||
- Fixed "MultipartData needs $"
|
||||
([#11863](https://github.com/nim-lang/Nim/issues/11863))
|
||||
- Fixed "Nim stdlib style issues with --styleCheck:error"
|
||||
([#12687](https://github.com/nim-lang/Nim/issues/12687))
|
||||
- Fixed "new $nimbleDir path substitution yields unexpected search paths"
|
||||
([#12767](https://github.com/nim-lang/Nim/issues/12767))
|
||||
- Fixed "Regression: inlined procs now get multiple rounds of destructor injection"
|
||||
([#12766](https://github.com/nim-lang/Nim/issues/12766))
|
||||
- Fixed "newruntime: compiler generates defective code"
|
||||
([#12669](https://github.com/nim-lang/Nim/issues/12669))
|
||||
- Fixed "broken windows modules path handling because of 'os.relativePath' breaking changes"
|
||||
([#12734](https://github.com/nim-lang/Nim/issues/12734))
|
||||
- Fixed "for loop tuple syntax not rendered correctly"
|
||||
([#12740](https://github.com/nim-lang/Nim/issues/12740))
|
||||
- Fixed "Crash when trying to use `type.name[0]`"
|
||||
([#12804](https://github.com/nim-lang/Nim/issues/12804))
|
||||
- Fixed "Enums should be considered Trivial types in Atomics"
|
||||
([#12812](https://github.com/nim-lang/Nim/issues/12812))
|
||||
- Fixed "Produce static/const initializations for variables when possible"
|
||||
([#12216](https://github.com/nim-lang/Nim/issues/12216))
|
||||
- Fixed "Assigning descriminator field leads to internal assert with --gc:destructors"
|
||||
([#12821](https://github.com/nim-lang/Nim/issues/12821))
|
||||
- Fixed "nimsuggest `use` command does not return all instances of symbol"
|
||||
([#12832](https://github.com/nim-lang/Nim/issues/12832))
|
||||
- Fixed "@[] is a problem for --gc:destructors"
|
||||
([#12820](https://github.com/nim-lang/Nim/issues/12820))
|
||||
- Fixed "Codegen ICE in allPathsAsgnResult"
|
||||
([#12827](https://github.com/nim-lang/Nim/issues/12827))
|
||||
- Fixed "seq[Object with ref and destructor type] doesn't work in old runtime"
|
||||
([#12882](https://github.com/nim-lang/Nim/issues/12882))
|
||||
- Fixed "Destructor not invoked because it is instantiated too late, old runtime"
|
||||
([#12883](https://github.com/nim-lang/Nim/issues/12883))
|
||||
- Fixed "The collect macro does not handle if/case correctly"
|
||||
([#12874](https://github.com/nim-lang/Nim/issues/12874))
|
||||
- Fixed "allow typed/untyped params in magic procs (even if not in stdlib)"
|
||||
([#12911](https://github.com/nim-lang/Nim/issues/12911))
|
||||
- Fixed "ARC/newruntime memory corruption"
|
||||
([#12899](https://github.com/nim-lang/Nim/issues/12899))
|
||||
- Fixed "tasyncclosestall.nim still flaky test: Address already in use"
|
||||
([#12919](https://github.com/nim-lang/Nim/issues/12919))
|
||||
- Fixed "newruntime and computed goto: variables inside the loop are in generated code uninitialised"
|
||||
([#12785](https://github.com/nim-lang/Nim/issues/12785))
|
||||
- Fixed "osx: dsymutil needs to be called for debug builds to keep debug info"
|
||||
([#12735](https://github.com/nim-lang/Nim/issues/12735))
|
||||
- Fixed "codegen ICE with ref objects, gc:destructors"
|
||||
([#12826](https://github.com/nim-lang/Nim/issues/12826))
|
||||
- Fixed "mutable iterator cannot yield named tuples"
|
||||
([#12945](https://github.com/nim-lang/Nim/issues/12945))
|
||||
- Fixed "parsecfg stores "\r\n" line breaks just as "\n""
|
||||
([#12970](https://github.com/nim-lang/Nim/issues/12970))
|
||||
- Fixed "db_postgres.getValue issues warning when no rows found"
|
||||
([#12973](https://github.com/nim-lang/Nim/issues/12973))
|
||||
- Fixed "ARC: Unpacking tuple with seq causes segfault"
|
||||
([#12989](https://github.com/nim-lang/Nim/issues/12989))
|
||||
- Fixed "ARC/newruntime: strutils.join on seq with only empty strings causes segfault"
|
||||
([#12965](https://github.com/nim-lang/Nim/issues/12965))
|
||||
- Fixed "regression (1.0.4): `{.push exportc.}` wrongly affects generic instantiations, causing codegen errors"
|
||||
([#12985](https://github.com/nim-lang/Nim/issues/12985))
|
||||
- Fixed "cdt, crash with --gc:arc, works fine with default gc"
|
||||
([#12978](https://github.com/nim-lang/Nim/issues/12978))
|
||||
- Fixed "ARC: No indexError thrown on out-of-bound seq access, SIGSEGV instead"
|
||||
([#12961](https://github.com/nim-lang/Nim/issues/12961))
|
||||
- Fixed "ARC/async: Returning in a try-block results in wrong codegen"
|
||||
([#12956](https://github.com/nim-lang/Nim/issues/12956))
|
||||
- Fixed "asm keyword is generating wrong output C code when --cc:tcc"
|
||||
([#12988](https://github.com/nim-lang/Nim/issues/12988))
|
||||
- Fixed "Destructor not invoked"
|
||||
([#13026](https://github.com/nim-lang/Nim/issues/13026))
|
||||
- Fixed "ARC/newruntime: Adding inherited var ref object to seq with base type causes segfault"
|
||||
([#12964](https://github.com/nim-lang/Nim/issues/12964))
|
||||
- Fixed "Style check error with JS compiler target"
|
||||
([#13032](https://github.com/nim-lang/Nim/issues/13032))
|
||||
- Fixed "regression(1.0.4): undeclared identifier: 'readLines'; plus another regression and bug"
|
||||
([#13013](https://github.com/nim-lang/Nim/issues/13013))
|
||||
- Fixed "regression(1.04) `invalid pragma: since` with nim js"
|
||||
([#12996](https://github.com/nim-lang/Nim/issues/12996))
|
||||
- Fixed "Sink to MemMove optimization in injectdestructors"
|
||||
([#13002](https://github.com/nim-lang/Nim/issues/13002))
|
||||
- Fixed "--gc:arc: `catch` doesn't work with exception subclassing"
|
||||
([#13072](https://github.com/nim-lang/Nim/issues/13072))
|
||||
- Fixed "nim c --gc:arc --exceptions:{setjmp,goto} incorrectly handles raise; `nim cpp --gc:arc` is ok"
|
||||
([#13070](https://github.com/nim-lang/Nim/issues/13070))
|
||||
- Fixed "typetraits feature request - get subtype of a generic type"
|
||||
([#6454](https://github.com/nim-lang/Nim/issues/6454))
|
||||
- Fixed "CountTable inconsistencies between keys() and len() after setting value to 0"
|
||||
([#12813](https://github.com/nim-lang/Nim/issues/12813))
|
||||
- Fixed "{.align.} pragma is not applied if there is a generic field"
|
||||
([#13122](https://github.com/nim-lang/Nim/issues/13122))
|
||||
- Fixed "ARC, finalizer, allow rebinding the same function multiple times"
|
||||
([#13112](https://github.com/nim-lang/Nim/issues/13112))
|
||||
- Fixed "`nim doc` treats `export localSymbol` incorrectly"
|
||||
([#13100](https://github.com/nim-lang/Nim/issues/13100))
|
||||
- Fixed "--gc:arc SIGSEGV (double free?)"
|
||||
([#13119](https://github.com/nim-lang/Nim/issues/13119))
|
||||
- Fixed "codegen bug with arc"
|
||||
([#13105](https://github.com/nim-lang/Nim/issues/13105))
|
||||
- Fixed "symbols not defined in the grammar"
|
||||
([#10665](https://github.com/nim-lang/Nim/issues/10665))
|
||||
- Fixed "[JS] Move is not defined"
|
||||
([#9674](https://github.com/nim-lang/Nim/issues/9674))
|
||||
- Fixed "[TODO] pathutils.`/` can return invalid AbsoluteFile"
|
||||
([#13121](https://github.com/nim-lang/Nim/issues/13121))
|
||||
- Fixed "regression(1.04) `nim doc main.nim` generates broken html (no css)"
|
||||
([#12998](https://github.com/nim-lang/Nim/issues/12998))
|
||||
- Fixed "Wrong supportsCopyMem on string in type section"
|
||||
([#13095](https://github.com/nim-lang/Nim/issues/13095))
|
||||
- Fixed "Arc, finalizer, out of memory"
|
||||
([#13157](https://github.com/nim-lang/Nim/issues/13157))
|
||||
- Fixed "`--genscript` messes up nimcache and future nim invocations"
|
||||
([#13144](https://github.com/nim-lang/Nim/issues/13144))
|
||||
- Fixed "--gc:arc with --exceptions:goto for "nim c" generate invalid c code"
|
||||
([#13186](https://github.com/nim-lang/Nim/issues/13186))
|
||||
- Fixed "[regression] duplicate member `_i1` codegen bug"
|
||||
([#13195](https://github.com/nim-lang/Nim/issues/13195))
|
||||
- Fixed "RTree investigations with valgrind for --gc:arc"
|
||||
([#13110](https://github.com/nim-lang/Nim/issues/13110))
|
||||
- Fixed "relativePath("foo", ".") returns wrong path"
|
||||
([#13211](https://github.com/nim-lang/Nim/issues/13211))
|
||||
- Fixed "asyncftpclient - problem with welcome.msg"
|
||||
([#4684](https://github.com/nim-lang/Nim/issues/4684))
|
||||
- Fixed "Unclear error message, lowest priority"
|
||||
([#13256](https://github.com/nim-lang/Nim/issues/13256))
|
||||
- Fixed "Channel messages are corrupted"
|
||||
([#13219](https://github.com/nim-lang/Nim/issues/13219))
|
||||
- Fixed "Codegen bug with exportc and case objects"
|
||||
([#13281](https://github.com/nim-lang/Nim/issues/13281))
|
||||
- Fixed "[bugfix] fix #11590: c compiler warnings silently ignored, giving undefined behavior"
|
||||
([#11591](https://github.com/nim-lang/Nim/issues/11591))
|
||||
- Fixed "[CI] tnetdial flaky test"
|
||||
([#13132](https://github.com/nim-lang/Nim/issues/13132))
|
||||
- Fixed "Cross-Compiling with -d:mingw fails to locate compiler under OSX"
|
||||
([#10717](https://github.com/nim-lang/Nim/issues/10717))
|
||||
- Fixed "`nim doc --project` broken with imports below main project file or duplicate names"
|
||||
([#13150](https://github.com/nim-lang/Nim/issues/13150))
|
||||
- Fixed "regression: isNamedTuple(MyGenericTuple[int]) is false, should be true"
|
||||
([#13349](https://github.com/nim-lang/Nim/issues/13349))
|
||||
- Fixed "--gc:arc codegen bug copying objects bound to C structs with missing C struct fields"
|
||||
([#13269](https://github.com/nim-lang/Nim/issues/13269))
|
||||
- Fixed "write requires conversion to string"
|
||||
([#13182](https://github.com/nim-lang/Nim/issues/13182))
|
||||
- Fixed "Some remarks to stdlib documentation"
|
||||
([#13352](https://github.com/nim-lang/Nim/issues/13352))
|
||||
- Fixed "a `check` in unittest generated by template doesn't show actual value"
|
||||
([#6736](https://github.com/nim-lang/Nim/issues/6736))
|
||||
- Fixed "Implicit return with case expression fails with 'var' return."
|
||||
([#3339](https://github.com/nim-lang/Nim/issues/3339))
|
||||
- Fixed "Segfault with closure on arc"
|
||||
([#13314](https://github.com/nim-lang/Nim/issues/13314))
|
||||
- Fixed "[Macro] Crash on malformed case statement with multiple else"
|
||||
([#13255](https://github.com/nim-lang/Nim/issues/13255))
|
||||
- Fixed "regression: `echo 'discard' | nim c -r -` generates a file '-' ; `-` should be treated specially"
|
||||
([#13374](https://github.com/nim-lang/Nim/issues/13374))
|
||||
- Fixed "on OSX, debugging (w gdb or lldb) a nim program crashes at the 1st call to `execCmdEx`"
|
||||
([#9634](https://github.com/nim-lang/Nim/issues/9634))
|
||||
- Fixed "Internal error in getTypeDescAux"
|
||||
([#13378](https://github.com/nim-lang/Nim/issues/13378))
|
||||
- Fixed "gc:arc mode breaks tuple let"
|
||||
([#13368](https://github.com/nim-lang/Nim/issues/13368))
|
||||
- Fixed "Nim compiler hangs for certain C/C++ compiler errors"
|
||||
([#8648](https://github.com/nim-lang/Nim/issues/8648))
|
||||
- Fixed "htmlgen does not support `data-*` attributes"
|
||||
([#13444](https://github.com/nim-lang/Nim/issues/13444))
|
||||
- Fixed "[gc:arc] setLen will cause string not to be null-terminated."
|
||||
([#13457](https://github.com/nim-lang/Nim/issues/13457))
|
||||
- Fixed "joinPath("", "") is "/" ; should be """
|
||||
([#13455](https://github.com/nim-lang/Nim/issues/13455))
|
||||
- Fixed "[CI] flaky test on windows: tests/osproc/texitcode.nim"
|
||||
([#13449](https://github.com/nim-lang/Nim/issues/13449))
|
||||
- Fixed "Casting to float32 on NimVM is broken"
|
||||
([#13479](https://github.com/nim-lang/Nim/issues/13479))
|
||||
- Fixed "`--hints:off` doesn't work (doesn't override ~/.config/nim.cfg)"
|
||||
([#8312](https://github.com/nim-lang/Nim/issues/8312))
|
||||
- Fixed "joinPath("", "") is "/" ; should be """
|
||||
([#13455](https://github.com/nim-lang/Nim/issues/13455))
|
||||
- Fixed "tables.values is broken"
|
||||
([#13496](https://github.com/nim-lang/Nim/issues/13496))
|
||||
- Fixed "global user config can override project specific config"
|
||||
([#9405](https://github.com/nim-lang/Nim/issues/9405))
|
||||
- Fixed "Non deterministic macros and id consistency problem"
|
||||
([#12627](https://github.com/nim-lang/Nim/issues/12627))
|
||||
- Fixed "try expression doesn't work with return on expect branch"
|
||||
([#13490](https://github.com/nim-lang/Nim/issues/13490))
|
||||
- Fixed "CI will break every 4 years on feb 28: times doesn't handle leap years properly"
|
||||
([#13543](https://github.com/nim-lang/Nim/issues/13543))
|
||||
- Fixed "[minor] `nimgrep --word` doesn't work with operators (eg misses `1 +% 2`)"
|
||||
([#13528](https://github.com/nim-lang/Nim/issues/13528))
|
||||
- Fixed "`as` is usable as infix operator but its existence and precedence are not documented"
|
||||
([#13409](https://github.com/nim-lang/Nim/issues/13409))
|
||||
- Fixed "JSON unmarshalling drops seq's items"
|
||||
([#13531](https://github.com/nim-lang/Nim/issues/13531))
|
||||
- Fixed "os.joinPath returns wrong path when head ends '\' or '/' and tail starts '..'."
|
||||
([#13579](https://github.com/nim-lang/Nim/issues/13579))
|
||||
- Fixed "Block-local types with the same name lead to bad codegen (sighashes regression)"
|
||||
([#5170](https://github.com/nim-lang/Nim/issues/5170))
|
||||
- Fixed "tuple codegen error"
|
||||
([#12704](https://github.com/nim-lang/Nim/issues/12704))
|
||||
- Fixed "newHttpHeaders does not accept repeated headers"
|
||||
([#13573](https://github.com/nim-lang/Nim/issues/13573))
|
||||
- Fixed "regression: --incremental:on fails on simplest example"
|
||||
([#13319](https://github.com/nim-lang/Nim/issues/13319))
|
||||
- Fixed "strscan can't get value of last element in format"
|
||||
([#13605](https://github.com/nim-lang/Nim/issues/13605))
|
||||
- Fixed "hashes_examples crashes with "Bus Error" (unaligned access) on sparc64"
|
||||
([#12508](https://github.com/nim-lang/Nim/issues/12508))
|
||||
- Fixed "gc:arc bug with re-used `seq[T]`"
|
||||
([#13596](https://github.com/nim-lang/Nim/issues/13596))
|
||||
- Fixed "`raise CatchableError` is broken with --gc:arc when throwing inside a proc"
|
||||
([#13599](https://github.com/nim-lang/Nim/issues/13599))
|
||||
- Fixed "cpp --gc:arc --exceptions:goto fails to raise with discard"
|
||||
([#13436](https://github.com/nim-lang/Nim/issues/13436))
|
||||
- Fixed "terminal doesn't compile with -d:useWinAnsi"
|
||||
([#13607](https://github.com/nim-lang/Nim/issues/13607))
|
||||
- Fixed "Parsing "sink ptr T" - region needs to be an object type"
|
||||
([#12757](https://github.com/nim-lang/Nim/issues/12757))
|
||||
- Fixed "gc:arc + threads:on + closures compilation error"
|
||||
([#13519](https://github.com/nim-lang/Nim/issues/13519))
|
||||
- Fixed "[ARC] segmentation fault"
|
||||
([#13240](https://github.com/nim-lang/Nim/issues/13240))
|
||||
- Fixed "times.toDateTime buggy on 29th, 30th and 31th of each month"
|
||||
([#13558](https://github.com/nim-lang/Nim/issues/13558))
|
||||
- Fixed "Deque misbehaves on VM"
|
||||
([#13310](https://github.com/nim-lang/Nim/issues/13310))
|
||||
- Fixed "Nimscript listFiles should throw exception when path is not found"
|
||||
([#12676](https://github.com/nim-lang/Nim/issues/12676))
|
||||
- Fixed "koch boot fails if even an empty config.nims is present in ~/.config/nims/ [devel regression]"
|
||||
([#13633](https://github.com/nim-lang/Nim/issues/13633))
|
||||
- Fixed "nim doc generates lots of false positive LockLevel warnings"
|
||||
([#13218](https://github.com/nim-lang/Nim/issues/13218))
|
||||
- Fixed "Arrays are passed by copy to iterators, causing crashes, unnecessary allocations and slowdowns"
|
||||
([#12747](https://github.com/nim-lang/Nim/issues/12747))
|
||||
- Fixed "Range types always uses signed integer as a base type"
|
||||
([#13646](https://github.com/nim-lang/Nim/issues/13646))
|
||||
- Fixed "Generate c code cannot compile with recent devel version"
|
||||
([#13645](https://github.com/nim-lang/Nim/issues/13645))
|
||||
- Fixed "[regression] VM: Error: cannot convert -1 to uint64"
|
||||
([#13661](https://github.com/nim-lang/Nim/issues/13661))
|
||||
- Fixed "Spurious raiseException(Exception) detected"
|
||||
([#13654](https://github.com/nim-lang/Nim/issues/13654))
|
||||
- Fixed "gc:arc memory leak"
|
||||
([#13659](https://github.com/nim-lang/Nim/issues/13659))
|
||||
- Fixed "Error: cannot convert -1 to uint (inside tuples)"
|
||||
([#13671](https://github.com/nim-lang/Nim/issues/13671))
|
||||
- Fixed "strformat issue with --gc:arc"
|
||||
([#13622](https://github.com/nim-lang/Nim/issues/13622))
|
||||
- Fixed "astToStr doesn't work inside generics"
|
||||
([#13524](https://github.com/nim-lang/Nim/issues/13524))
|
||||
- Fixed "oswalkdir.walkDirRec wont return folders"
|
||||
([#11458](https://github.com/nim-lang/Nim/issues/11458))
|
||||
- Fixed "`echo 'echo 1' | nim c -r -` silently gives wrong results (nimBetterRun not updated for stdin)"
|
||||
([#13412](https://github.com/nim-lang/Nim/issues/13412))
|
||||
- Fixed "gc:arc destroys the global variable accidentally."
|
||||
([#13691](https://github.com/nim-lang/Nim/issues/13691))
|
||||
- Fixed "[minor] sigmatch errors should be sorted, for reproducible errors"
|
||||
([#13538](https://github.com/nim-lang/Nim/issues/13538))
|
||||
- Fixed "Exception when converting csize to clong"
|
||||
([#13698](https://github.com/nim-lang/Nim/issues/13698))
|
||||
- Fixed "ARC: variables are no copied on the thread spawn causing crashes"
|
||||
([#13708](https://github.com/nim-lang/Nim/issues/13708))
|
||||
- Fixed "Illegal distinct seq causes compiler crash"
|
||||
([#13720](https://github.com/nim-lang/Nim/issues/13720))
|
||||
- Fixed "cyclic seq definition crashes the compiler"
|
||||
([#13715](https://github.com/nim-lang/Nim/issues/13715))
|
||||
- Fixed "Iterator with openArray parameter make the argument evaluated many times"
|
||||
([#13417](https://github.com/nim-lang/Nim/issues/13417))
|
||||
- Fixed "net/asyncnet: Unable to access peer's certificate chain"
|
||||
([#13299](https://github.com/nim-lang/Nim/issues/13299))
|
||||
- Fixed "Accidentally "SIGSEGV: Illegal storage access" error after arc optimizations (#13325)"
|
||||
([#13709](https://github.com/nim-lang/Nim/issues/13709))
|
||||
- Fixed "Base64 Regression"
|
||||
([#13722](https://github.com/nim-lang/Nim/issues/13722))
|
||||
- Fixed "A regression (?) with --gc:arc and repr"
|
||||
([#13731](https://github.com/nim-lang/Nim/issues/13731))
|
||||
- Fixed "Internal compiler error when using the new variable pragmas"
|
||||
([#13737](https://github.com/nim-lang/Nim/issues/13737))
|
||||
- Fixed "bool conversion produces vcc 2019 warning at cpp compilation stage"
|
||||
([#13744](https://github.com/nim-lang/Nim/issues/13744))
|
||||
- Fixed "Compiler "does not detect" a type recursion error in the wrong code, remaining frozen"
|
||||
([#13763](https://github.com/nim-lang/Nim/issues/13763))
|
||||
- Fixed "[minor] regression: `Foo[0.0] is Foo[-0.0]` is now false"
|
||||
([#13730](https://github.com/nim-lang/Nim/issues/13730))
|
||||
- Fixed "`nim doc` - only whitespace on first line causes segfault"
|
||||
([#13631](https://github.com/nim-lang/Nim/issues/13631))
|
||||
- Fixed "hashset regression"
|
||||
([#13794](https://github.com/nim-lang/Nim/issues/13794))
|
||||
- Fixed "`os.getApplFreebsd` could return incorrect paths in the case of a long path"
|
||||
([#13806](https://github.com/nim-lang/Nim/issues/13806))
|
||||
- Fixed "Destructors are not inherited"
|
||||
([#13810](https://github.com/nim-lang/Nim/issues/13810))
|
||||
- Fixed "io.readLines AssertionError on devel"
|
||||
([#13829](https://github.com/nim-lang/Nim/issues/13829))
|
||||
- Fixed "exceptions:goto accidentally reset the variable during exception handling"
|
||||
([#13782](https://github.com/nim-lang/Nim/issues/13782))
|
||||
|
|
@ -1,874 +0,0 @@
|
|||
# v1.4.0 - 2020-10-16
|
||||
|
||||
|
||||
|
||||
## Standard library additions and changes
|
||||
|
||||
- Added some enhancements to `std/jsonutils` module.
|
||||
* Added a possibility to deserialize JSON arrays directly to `HashSet` and
|
||||
`OrderedSet` types and respectively to serialize those types to JSON arrays
|
||||
via `jsonutils.fromJson` and `jsonutils.toJson` procedures.
|
||||
* Added a possibility to deserialize JSON `null` objects to Nim option objects
|
||||
and respectively to serialize Nim option object to JSON object if `isSome`
|
||||
or to JSON null object if `isNone` via `jsonutils.fromJson` and
|
||||
`jsonutils.toJson` procedures.
|
||||
* Added a `Joptions` parameter to `jsonutils.fromJson` currently
|
||||
containing two boolean options `allowExtraKeys` and `allowMissingKeys`.
|
||||
- If `allowExtraKeys` is `true` Nim's object to which the JSON is parsed is
|
||||
not required to have a field for every JSON key.
|
||||
- If `allowMissingKeys` is `true` Nim's object to which JSON is parsed is
|
||||
allowed to have fields without corresponding JSON keys.
|
||||
- Added `bindParams`, `bindParam` to `db_sqlite` for binding parameters into a `SqlPrepared` statement.
|
||||
- Added `tryInsert`,`insert` procs to `db_*` libs which accept primary key column name.
|
||||
- Added `xmltree.newVerbatimText` support create `style`'s,`script`'s text.
|
||||
- `uri` module now implements RFC-2397.
|
||||
- Added [DOM Parser](https://developer.mozilla.org/en-US/docs/Web/API/DOMParser)
|
||||
to the `dom` module for the JavaScript target.
|
||||
- The default hash for `Ordinal` has changed to something more bit-scrambling.
|
||||
`import hashes; proc hash(x: myInt): Hash = hashIdentity(x)` recovers the old
|
||||
one in an instantiation context while `-d:nimIntHash1` recovers it globally.
|
||||
- `deques.peekFirst` and `deques.peekLast` now have `var Deque[T] -> var T` overloads.
|
||||
- File handles created from high-level abstractions in the stdlib will no longer
|
||||
be inherited by child processes. In particular, these modules are affected:
|
||||
`asyncdispatch`, `asyncnet`, `system`, `nativesockets`, `net` and `selectors`.
|
||||
|
||||
For `asyncdispatch`, `asyncnet`, `net` and `nativesockets`, an `inheritable`
|
||||
flag has been added to all `proc`s that create sockets, allowing the user to
|
||||
control whether the resulting socket is inheritable. This flag is provided to
|
||||
ease the writing of multi-process servers, where sockets inheritance is
|
||||
desired.
|
||||
|
||||
For a transition period, define `nimInheritHandles` to enable file handle
|
||||
inheritance by default. This flag does **not** affect the `selectors` module
|
||||
due to the differing semantics between operating systems.
|
||||
|
||||
`asyncdispatch.setInheritable`, `system.setInheritable` and
|
||||
`nativesockets.setInheritable` are also introduced for setting file handle or
|
||||
socket inheritance. Not all platforms have these `proc`s defined.
|
||||
|
||||
- The file descriptors created for internal bookkeeping by `ioselector_kqueue`
|
||||
and `ioselector_epoll` will no longer be leaked to child processes.
|
||||
|
||||
- `strutils.formatFloat` with `precision = 0` has been restored to the version
|
||||
1 behaviour that produces a trailing dot, e.g. `formatFloat(3.14159, precision = 0)`
|
||||
is now `3.`, not `3`.
|
||||
- Added `commonPrefixLen` to `critbits`.
|
||||
|
||||
- `relativePath(rel, abs)` and `relativePath(abs, rel)` used to silently give wrong results
|
||||
(see #13222); instead they now use `getCurrentDir` to resolve those cases,
|
||||
and this can now throw in edge cases where `getCurrentDir` throws.
|
||||
`relativePath` also now works for js with `-d:nodejs`.
|
||||
|
||||
- JavaScript and NimScript standard library changes: `streams.StringStream` is
|
||||
now supported in JavaScript, with the limitation that any buffer `pointer`s
|
||||
used must be castable to `ptr string`, any incompatible pointer type will not
|
||||
work. The `lexbase` and `streams` modules used to fail to compile on
|
||||
NimScript due to a bug, but this has been fixed.
|
||||
|
||||
The following modules now compile on both JS and NimScript: `parsecsv`,
|
||||
`parsecfg`, `parsesql`, `xmlparser`, `htmlparser` and `ropes`. Additionally
|
||||
supported for JS is `cstrutils.startsWith` and `cstrutils.endsWith`, for
|
||||
NimScript: `json`, `parsejson`, `strtabs` and `unidecode`.
|
||||
|
||||
- Added `streams.readStr` and `streams.peekStr` overloads to
|
||||
accept an existing string to modify, which avoids memory
|
||||
allocations, similar to `streams.readLine` (#13857).
|
||||
|
||||
- Added high-level `asyncnet.sendTo` and `asyncnet.recvFrom` UDP functionality.
|
||||
|
||||
- `dollars.$` now works for unsigned ints with `nim js`.
|
||||
|
||||
- Improvements to the `bitops` module, including bitslices, non-mutating versions
|
||||
of the original masking functions, `mask`/`masked`, and varargs support for
|
||||
`bitand`, `bitor`, and `bitxor`.
|
||||
|
||||
- `sugar.=>` and `sugar.->` changes: Previously `(x, y: int)` was transformed
|
||||
into `(x: auto, y: int)`, it now becomes `(x: int, y: int)` for consistency
|
||||
with regular proc definitions (although you cannot use semicolons).
|
||||
|
||||
Pragmas and using a name are now allowed on the lefthand side of `=>`. Here
|
||||
is an example of these changes:
|
||||
```nim
|
||||
import sugar
|
||||
|
||||
foo(x, y: int) {.noSideEffect.} => x + y
|
||||
|
||||
# is transformed into
|
||||
|
||||
proc foo(x: int, y: int): auto {.noSideEffect.} = x + y
|
||||
```
|
||||
|
||||
- The fields of `times.DateTime` are now private, and are accessed with getters and deprecated setters.
|
||||
|
||||
- The `times` module now handles the default value for `DateTime` more consistently.
|
||||
Most procs raise an assertion error when given
|
||||
an uninitialized `DateTime`, the exceptions are `==` and `$` (which returns `"Uninitialized DateTime"`).
|
||||
The proc `times.isInitialized` has been added which can be used to check if
|
||||
a `DateTime` has been initialized.
|
||||
|
||||
- Fix a bug where calling `close` on io streams in `osproc.startProcess` was a noop and led to
|
||||
hangs if a process had both reads from stdin and writes (e.g. to stdout).
|
||||
|
||||
- The callback that is passed to `system.onThreadDestruction` must now be `.raises: []`.
|
||||
- The callback that is assigned to `system.onUnhandledException` must now be `.gcsafe`.
|
||||
|
||||
- `osproc.execCmdEx` now takes an optional `input` for stdin, `workingDir` and `env`
|
||||
parameters.
|
||||
|
||||
- Added a `ssl_config` module containing lists of secure ciphers as recommended by
|
||||
[Mozilla OpSec](https://wiki.mozilla.org/Security/Server_Side_TLS)
|
||||
|
||||
- `net.newContext` now defaults to the list of ciphers targeting
|
||||
["Intermediate compatibility"](https://wiki.mozilla.org/Security/Server_Side_TLS#Intermediate_compatibility_.28recommended.29)
|
||||
per Mozilla's recommendation instead of `ALL`. This change should protect
|
||||
users from the use of weak and insecure ciphers while still provides
|
||||
adequate compatibility with the majority of the Internet.
|
||||
|
||||
- A new module `std/jsonutils` with hookable `jsonTo,toJson,fromJson` operations for json
|
||||
serialization/deserialization of custom types was added.
|
||||
|
||||
- A new proc `heapqueue.find[T](heap: HeapQueue[T], x: T): int` to get index of element ``x``
|
||||
was added.
|
||||
- Added `rstgen.rstToLatex` a convenience proc for `renderRstToOut` and `initRstGenerator`.
|
||||
- Added `os.normalizeExe`.
|
||||
- `macros.newLit` now preserves named vs unnamed tuples.
|
||||
- Added `random.gauss`, that uses the ratio of uniforms method of sampling from a Gaussian distribution.
|
||||
- Added `typetraits.elementType` to get the element type of an iterable.
|
||||
- `typetraits.$` changes: `$(int,)` is now `"(int,)"` instead of `"(int)"`;
|
||||
`$tuple[]` is now `"tuple[]"` instead of `"tuple"`;
|
||||
`$((int, float), int)` is now `"((int, float), int)"` instead of `"(tuple of (int, float), int)"`
|
||||
- Added `macros.extractDocCommentsAndRunnables` helper.
|
||||
|
||||
- `strformat.fmt` and `strformat.&` support `specifier =`. `fmt"{expr=}"` now
|
||||
expands to `fmt"expr={expr}"`.
|
||||
- Deprecations: instead of `os.existsDir` use `dirExists`, instead of `os.existsFile` use `fileExists`.
|
||||
|
||||
- Added the `jsre` module, [Regular Expressions for the JavaScript target.](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions).
|
||||
- Made `maxLines` argument `Positive` in `logging.newRollingFileLogger`,
|
||||
because negative values will result in a new file being created for each logged
|
||||
line which doesn't make sense.
|
||||
- Changed `log` in `logging` to use proper log level for JavaScript,
|
||||
e.g. `debug` uses `console.debug`, `info` uses `console.info`, `warn` uses `console.warn`, etc.
|
||||
- Tables, HashSets, SharedTables and deques don't require anymore that the passed
|
||||
initial size must be a power of two - this is done internally.
|
||||
Proc `rightSize` for Tables and HashSets is deprecated, as it is not needed anymore.
|
||||
`CountTable.inc` takes `val: int` again not `val: Positive`; i.e. it can "count down" again.
|
||||
- Removed deprecated symbols from `macros` module, some of which were deprecated already in `0.15`.
|
||||
- Removed `sugar.distinctBase`, deprecated since `0.19`. Use `typetraits.distinctBase`.
|
||||
- `asyncdispatch.PDispatcher.handles` is exported so that an external low-level libraries can access it.
|
||||
|
||||
- `std/with`, `sugar.dup` now support object field assignment expressions:
|
||||
```nim
|
||||
import std/with
|
||||
|
||||
type Foo = object
|
||||
x, y: int
|
||||
|
||||
var foo = Foo()
|
||||
with foo:
|
||||
x = 10
|
||||
y = 20
|
||||
|
||||
echo foo
|
||||
```
|
||||
|
||||
- Proc `math.round` is no longer deprecated. The advice to use `strformat` instead
|
||||
cannot be applied to every use case. The limitations and the (lack of) reliability
|
||||
of `round` are well documented.
|
||||
|
||||
- Added `getprotobyname` to `winlean`. Added `getProtoByname` to `nativesockets` which returns a protocol code
|
||||
from the database that matches the protocol `name`.
|
||||
|
||||
- Added missing attributes and methods to `dom.Navigator` like `deviceMemory`, `onLine`, `vibrate()`, etc.
|
||||
|
||||
- Added `strutils.indentation` and `strutils.dedent` which enable indented string literals:
|
||||
```nim
|
||||
import strutils
|
||||
echo dedent """
|
||||
This
|
||||
is
|
||||
cool!
|
||||
"""
|
||||
```
|
||||
|
||||
- Added `initUri(isIpv6: bool)` to `uri` module, now `uri` supports parsing ipv6 hostname.
|
||||
|
||||
- Added `readLines(p: Process)` to `osproc`.
|
||||
|
||||
- Added the below `toX` procs for collections. The usage is similar to procs such as
|
||||
`sets.toHashSet` and `tables.toTable`. Previously, it was necessary to create the
|
||||
respective empty collection and add items manually.
|
||||
* `critbits.toCritBitTree`, which creates a `CritBitTree` from an `openArray` of
|
||||
items or an `openArray` of pairs.
|
||||
* `deques.toDeque`, which creates a `Deque` from an `openArray`.
|
||||
* `heapqueue.toHeapQueue`, which creates a `HeapQueue` from an `openArray`.
|
||||
* `intsets.toIntSet`, which creates an `IntSet` from an `openArray`.
|
||||
|
||||
- Added `progressInterval` argument to `asyncftpclient.newAsyncFtpClient` to control the interval
|
||||
at which progress callbacks are called.
|
||||
|
||||
- Added `os.copyFileToDir`.
|
||||
|
||||
## Language changes
|
||||
|
||||
- The `=destroy` hook no longer has to reset its target, as the compiler now automatically inserts
|
||||
`wasMoved` calls where needed.
|
||||
- The `=` hook is now called `=copy` for clarity. The old name `=` is still available so there
|
||||
is no need to update your code. This change was backported to 1.2 too so you can use the
|
||||
more readable `=copy` without loss of compatibility.
|
||||
|
||||
- In the newruntime it is now allowed to assign to the discriminator field
|
||||
without restrictions as long as the case object doesn't have a custom destructor.
|
||||
The discriminator value doesn't have to be a constant either. If you have a
|
||||
custom destructor for a case object and you do want to freely assign discriminator
|
||||
fields, it is recommended to refactor the object into 2 objects like this:
|
||||
|
||||
```nim
|
||||
type
|
||||
MyObj = object
|
||||
case kind: bool
|
||||
of true: y: ptr UncheckedArray[float]
|
||||
of false: z: seq[int]
|
||||
|
||||
proc `=destroy`(x: MyObj) =
|
||||
if x.kind and x.y != nil:
|
||||
deallocShared(x.y)
|
||||
```
|
||||
Refactor into:
|
||||
```nim
|
||||
type
|
||||
MySubObj = object
|
||||
val: ptr UncheckedArray[float]
|
||||
MyObj = object
|
||||
case kind: bool
|
||||
of true: y: MySubObj
|
||||
of false: z: seq[int]
|
||||
|
||||
proc `=destroy`(x: MySubObj) =
|
||||
if x.val != nil:
|
||||
deallocShared(x.val)
|
||||
```
|
||||
- `getImpl` on enum type symbols now returns field syms instead of idents. This helps
|
||||
with writing typed macros. The old behavior for backwards compatibility can be restored
|
||||
with `--useVersion:1.0`.
|
||||
- The typed AST for proc headers will now have the arguments be syms instead of idents.
|
||||
This helps with writing typed macros. The old behaviour for backwards compatibility can
|
||||
be restored with `--useVersion:1.0`.
|
||||
- ``let`` statements can now be used without a value if declared with
|
||||
``importc``/``importcpp``/``importjs``/``importobjc``.
|
||||
- The keyword `from` is now usable as an operator.
|
||||
- Exceptions inheriting from `system.Defect` are no longer tracked with
|
||||
the `.raises: []` exception tracking mechanism. This is more consistent with the
|
||||
built-in operations. The following always used to compile (and still does):
|
||||
```nim
|
||||
proc mydiv(a, b): int {.raises: [].} =
|
||||
a div b # can raise an DivByZeroDefect
|
||||
```
|
||||
|
||||
Now also this compiles:
|
||||
```nim
|
||||
proc mydiv(a, b): int {.raises: [].} =
|
||||
if b == 0: raise newException(DivByZeroDefect, "division by zero")
|
||||
else: result = a div b
|
||||
```
|
||||
|
||||
The reason for this is that `DivByZeroDefect` inherits from `Defect` and
|
||||
with `--panics:on` `Defects` become unrecoverable errors.
|
||||
|
||||
- Added the `thiscall` calling convention as specified by Microsoft, mostly for hooking purposes.
|
||||
- Deprecated the `{.unroll.}` pragma, because it was always ignored by the compiler anyway.
|
||||
- Removed the deprecated `strutils.isNilOrWhitespace`.
|
||||
- Removed the deprecated `sharedtables.initSharedTable`.
|
||||
- Removed the deprecated `asyncdispatch.newAsyncNativeSocket`.
|
||||
- Removed the deprecated `dom.releaseEvents` and `dom.captureEvents`.
|
||||
|
||||
- Removed `sharedlist.initSharedList`, was deprecated and produces undefined behaviour.
|
||||
|
||||
- There is a new experimental feature called "strictFuncs" which makes the definition of
|
||||
`.noSideEffect` stricter. [See here](manual_experimental.html#stricts-funcs)
|
||||
for more information.
|
||||
|
||||
- "for-loop macros" (see [the manual](manual.html#macros-for-loop-macros)) are no longer
|
||||
an experimental feature. In other words, you don't have to write pragma
|
||||
`{.experimental: "forLoopMacros".}` if you want to use them.
|
||||
|
||||
- Added the ``.noalias`` pragma. It is mapped to C's ``restrict`` keyword for the increased
|
||||
performance this keyword can enable.
|
||||
|
||||
- `items` no longer compiles with enums with holes as its behavior was error prone, see #14004.
|
||||
- `system.deepcopy` has to be enabled explicitly for `--gc:arc` and `--gc:orc` via
|
||||
`--deepcopy:on`.
|
||||
|
||||
- Added the `std/effecttraits` module for introspection of the inferred effects.
|
||||
We hope this enables `async` macros that are precise about the possible exceptions that
|
||||
can be raised.
|
||||
- The pragma blocks `{.gcsafe.}: ...` and `{.noSideEffect.}: ...` can now also be
|
||||
written as `{.cast(gcsafe).}: ...` and `{.cast(noSideEffect).}: ...`. This is the new
|
||||
preferred way of writing these, emphasizing their unsafe nature.
|
||||
|
||||
|
||||
## Compiler changes
|
||||
|
||||
- Specific warnings can now be turned into errors via `--warningAsError[X]:on|off`.
|
||||
- The `define` and `undef` pragmas have been de-deprecated.
|
||||
- New command: `nim r main.nim [args...]` which compiles and runs main.nim, and implies `--usenimcache`
|
||||
so that the output is saved to $nimcache/main$exeExt, using the same logic as `nim c -r` to
|
||||
avoid recompilations when sources don't change.
|
||||
Example:
|
||||
```bash
|
||||
nim r compiler/nim.nim --help # only compiled the first time
|
||||
echo 'import os; echo getCurrentCompilerExe()' | nim r - # this works too
|
||||
nim r compiler/nim.nim --fullhelp # no recompilation
|
||||
nim r --nimcache:/tmp main # binary saved to /tmp/main
|
||||
```
|
||||
- `--hint:processing` is now supported and means `--hint:processing:on`
|
||||
(likewise with other hints and warnings), which is consistent with all other bool flags.
|
||||
(since 1.3.3).
|
||||
- `nim doc -r main` and `nim rst2html -r main` now call `openDefaultBrowser`.
|
||||
- Added the new hint `--hint:msgOrigin` will show where a compiler msg (hint|warning|error)
|
||||
was generated; this helps in particular when it's non obvious where it came from
|
||||
either because multiple locations generate the same message, or because the
|
||||
message involves runtime formatting.
|
||||
- Added the new flag `--backend:js|c|cpp|objc` (or -b:js etc), to change the backend; can be
|
||||
used with any command (e.g. nim r, doc, check etc); safe to re-assign.
|
||||
- Added the new flag `--doccmd:cmd` to pass additional flags for runnableExamples,
|
||||
e.g.: `--doccmd:-d:foo --threads`
|
||||
use `--doccmd:skip` to skip runnableExamples and rst test snippets.
|
||||
- Added the new flag `--usenimcache` to output binary files to nimcache.
|
||||
- `runnableExamples "-b:cpp -r:off": code` is now supported, allowing to override
|
||||
how an example is compiled and run, for example to change the backend.
|
||||
- `nim doc` now outputs under `$projectPath/htmldocs` when `--outdir` is unspecified
|
||||
(with or without `--project`); passing `--project` now automatically generates
|
||||
an index and enables search.
|
||||
See [docgen](docgen.html#introduction-quick-start) for details.
|
||||
- Removed the `--oldNewlines` switch.
|
||||
- Removed the `--laxStrings` switch for mutating the internal zero terminator on strings.
|
||||
- Removed the `--oldast` switch.
|
||||
- Removed the `--oldgensym` switch.
|
||||
- `$getType(untyped)` is now "untyped" instead of "expr", `$getType(typed)` is
|
||||
now "typed" instead of "stmt".
|
||||
- Sink inference is now disabled per default and has to enabled explicitly via
|
||||
`--sinkInference:on`. *Note*: For the standard library sink inference remains
|
||||
enabled. This change is most relevant for the `--gc:arc`, `--gc:orc` memory
|
||||
management modes.
|
||||
|
||||
|
||||
## Tool changes
|
||||
|
||||
- `nimsuggest` now returns both the forward declaration and the
|
||||
implementation location upon a `def` query. Previously the behavior was
|
||||
to return the forward declaration only.
|
||||
|
||||
|
||||
## Bugfixes
|
||||
|
||||
- Fixed "repr() not available for uint{,8,16,32,64} under --gc:arc"
|
||||
([#13872](https://github.com/nim-lang/Nim/issues/13872))
|
||||
- Fixed "Critical: 1 completed Future, multiple await: Only 1 await will be awakened (the last one)"
|
||||
([#13889](https://github.com/nim-lang/Nim/issues/13889))
|
||||
- Fixed "crash on openarray interator with argument in stmtListExpr"
|
||||
([#13739](https://github.com/nim-lang/Nim/issues/13739))
|
||||
- Fixed "Some compilers on Windows don't work"
|
||||
([#13910](https://github.com/nim-lang/Nim/issues/13910))
|
||||
- Fixed "httpclient hangs if it recieves an HTTP 204 (No Content)"
|
||||
([#13894](https://github.com/nim-lang/Nim/issues/13894))
|
||||
- Fixed ""distinct uint64" type corruption on 32-bit, when using {.borrow.} operators"
|
||||
([#13902](https://github.com/nim-lang/Nim/issues/13902))
|
||||
- Fixed "Regression: impossible to use typed pragmas with proc types"
|
||||
([#13909](https://github.com/nim-lang/Nim/issues/13909))
|
||||
- Fixed "openssl wrapper corrupts stack on OpenSSL 1.1.1f + Android"
|
||||
([#13903](https://github.com/nim-lang/Nim/issues/13903))
|
||||
- Fixed "C compile error with --gc:arc on version 1.2.0 "unknown type name 'TGenericSeq'"
|
||||
([#13863](https://github.com/nim-lang/Nim/issues/13863))
|
||||
- Fixed "var return type for proc doesn't work at c++ backend"
|
||||
([#13848](https://github.com/nim-lang/Nim/issues/13848))
|
||||
- Fixed "TimeFormat() should raise an error but craches at compilation time"
|
||||
([#12864](https://github.com/nim-lang/Nim/issues/12864))
|
||||
- Fixed "gc:arc cannot fully support threadpool with FlowVar"
|
||||
([#13781](https://github.com/nim-lang/Nim/issues/13781))
|
||||
- Fixed "simple 'var openarray[char]' assignment crash when the openarray source is a local string and using gc:arc"
|
||||
([#14003](https://github.com/nim-lang/Nim/issues/14003))
|
||||
- Fixed "Cant use expressions with `when` in `type` sections."
|
||||
([#14007](https://github.com/nim-lang/Nim/issues/14007))
|
||||
- Fixed "`for a in MyEnum` gives incorrect results with enum with holes"
|
||||
([#14001](https://github.com/nim-lang/Nim/issues/14001))
|
||||
- Fixed "Trivial crash"
|
||||
([#12741](https://github.com/nim-lang/Nim/issues/12741))
|
||||
- Fixed "Enum with holes cannot be used as Table index"
|
||||
([#12834](https://github.com/nim-lang/Nim/issues/12834))
|
||||
- Fixed "spawn proc that uses typedesc crashes the compiler"
|
||||
([#14014](https://github.com/nim-lang/Nim/issues/14014))
|
||||
- Fixed "Docs Search `Results` box styling is not Dark Mode Friendly"
|
||||
([#13972](https://github.com/nim-lang/Nim/issues/13972))
|
||||
- Fixed "--gc:arc -d:useSysAssert undeclared identifier `cstderr` with newSeq"
|
||||
([#14038](https://github.com/nim-lang/Nim/issues/14038))
|
||||
- Fixed "issues in the manual"
|
||||
([#12486](https://github.com/nim-lang/Nim/issues/12486))
|
||||
- Fixed "Annoying warning: inherit from a more precise exception type like ValueError, IOError or OSError [InheritFromException]"
|
||||
([#14052](https://github.com/nim-lang/Nim/issues/14052))
|
||||
- Fixed "relativePath("foo", "/") and relativePath("/", "foo") is wrong"
|
||||
([#13222](https://github.com/nim-lang/Nim/issues/13222))
|
||||
- Fixed "[regression] `parseEnum` does not work anymore for enums with holes"
|
||||
([#14030](https://github.com/nim-lang/Nim/issues/14030))
|
||||
- Fixed "Exception types in the stdlib should inherit from `CatchableError` or `Defect`, not `Exception`"
|
||||
([#10288](https://github.com/nim-lang/Nim/issues/10288))
|
||||
- Fixed "Make debugSend and debugRecv procs public in smtp.nim"
|
||||
([#12189](https://github.com/nim-lang/Nim/issues/12189))
|
||||
- Fixed "xmltree need add raw text, when add style element"
|
||||
([#14064](https://github.com/nim-lang/Nim/issues/14064))
|
||||
- Fixed "raises requirement does not propagate to derived methods"
|
||||
([#8481](https://github.com/nim-lang/Nim/issues/8481))
|
||||
- Fixed "tests/stdlib/tgetaddrinfo.nim fails on NetBSD"
|
||||
([#14091](https://github.com/nim-lang/Nim/issues/14091))
|
||||
- Fixed "tests/niminaction/Chapter8/sdl/sdl_test.nim fails on NetBSD"
|
||||
([#14088](https://github.com/nim-lang/Nim/issues/14088))
|
||||
- Fixed "Incorrect escape sequence for example in jsffi library documentation"
|
||||
([#14110](https://github.com/nim-lang/Nim/issues/14110))
|
||||
- Fixed "HCR: Can not link exported const, in external library"
|
||||
([#13915](https://github.com/nim-lang/Nim/issues/13915))
|
||||
- Fixed "Cannot import std/unidecode"
|
||||
([#14112](https://github.com/nim-lang/Nim/issues/14112))
|
||||
- Fixed "macOS: dsymutil should not be called on static libraries"
|
||||
([#14132](https://github.com/nim-lang/Nim/issues/14132))
|
||||
- Fixed "nim jsondoc -o:doc.json filename.nim fails when sequences without a type are used"
|
||||
([#14066](https://github.com/nim-lang/Nim/issues/14066))
|
||||
- Fixed "algorithm.sortedByIt template corrupts tuple input under --gc:arc"
|
||||
([#14079](https://github.com/nim-lang/Nim/issues/14079))
|
||||
- Fixed "Invalid C code with lvalue conversion"
|
||||
([#14160](https://github.com/nim-lang/Nim/issues/14160))
|
||||
- Fixed "strformat: doc example fails"
|
||||
([#14054](https://github.com/nim-lang/Nim/issues/14054))
|
||||
- Fixed "Nim doc fail to run for nim 1.2.0 (nim 1.0.4 is ok)"
|
||||
([#13986](https://github.com/nim-lang/Nim/issues/13986))
|
||||
- Fixed "Exception when converting csize to clong"
|
||||
([#13698](https://github.com/nim-lang/Nim/issues/13698))
|
||||
- Fixed "[Documentation] overloading using named arguments works but is not documented"
|
||||
([#11932](https://github.com/nim-lang/Nim/issues/11932))
|
||||
- Fixed "import os + use of existsDir/dirExists/existsFile/fileExists/findExe in config.nims causes "ambiguous call' error"
|
||||
([#14142](https://github.com/nim-lang/Nim/issues/14142))
|
||||
- Fixed "import os + use of existsDir/dirExists/existsFile/fileExists/findExe in config.nims causes "ambiguous call' error"
|
||||
([#14142](https://github.com/nim-lang/Nim/issues/14142))
|
||||
- Fixed "runnableExamples doc gen crashes compiler with `except Exception as e` syntax"
|
||||
([#14177](https://github.com/nim-lang/Nim/issues/14177))
|
||||
- Fixed "[ARC] Segfault with cyclic references (?)"
|
||||
([#14159](https://github.com/nim-lang/Nim/issues/14159))
|
||||
- Fixed "Semcheck regression when accessing a static parameter in proc"
|
||||
([#14136](https://github.com/nim-lang/Nim/issues/14136))
|
||||
- Fixed "iterator walkDir doesn't work with -d:useWinAnsi"
|
||||
([#14201](https://github.com/nim-lang/Nim/issues/14201))
|
||||
- Fixed "cas is wrong for tcc"
|
||||
([#14151](https://github.com/nim-lang/Nim/issues/14151))
|
||||
- Fixed "proc execCmdEx doesn't work with -d:useWinAnsi"
|
||||
([#14203](https://github.com/nim-lang/Nim/issues/14203))
|
||||
- Fixed "Use -d:nimEmulateOverflowChecks by default?"
|
||||
([#14209](https://github.com/nim-lang/Nim/issues/14209))
|
||||
- Fixed "Old sequences with destructor objects bug"
|
||||
([#14217](https://github.com/nim-lang/Nim/issues/14217))
|
||||
- Fixed "[ARC] ICE when changing the discriminant of a return value"
|
||||
([#14244](https://github.com/nim-lang/Nim/issues/14244))
|
||||
- Fixed "[ARC] ICE with static objects"
|
||||
([#14236](https://github.com/nim-lang/Nim/issues/14236))
|
||||
- Fixed "[ARC] "internal error: environment misses: a" in a finalizer"
|
||||
([#14243](https://github.com/nim-lang/Nim/issues/14243))
|
||||
- Fixed "[ARC] compile failure using repr with object containing `ref seq[string]`"
|
||||
([#14270](https://github.com/nim-lang/Nim/issues/14270))
|
||||
- Fixed "[ARC] implicit move on last use happening on non-last use"
|
||||
([#14269](https://github.com/nim-lang/Nim/issues/14269))
|
||||
- Fixed "[ARC] Compiler crash with a recursive non-ref object variant"
|
||||
([#14294](https://github.com/nim-lang/Nim/issues/14294))
|
||||
- Fixed "htmlparser.parseHtml behaves differently using --gc:arc or --gc:orc"
|
||||
([#13946](https://github.com/nim-lang/Nim/issues/13946))
|
||||
- Fixed "Invalid return value of openProcess is NULL rather than INVALID_HANDLE_VALUE(-1) in windows"
|
||||
([#14289](https://github.com/nim-lang/Nim/issues/14289))
|
||||
- Fixed "ARC codegen bug with inline iterators"
|
||||
([#14219](https://github.com/nim-lang/Nim/issues/14219))
|
||||
- Fixed "Building koch on OpenBSD fails unless the Nim directory is in `$PATH`"
|
||||
([#13758](https://github.com/nim-lang/Nim/issues/13758))
|
||||
- Fixed "[gc:arc] case object assignment SIGSEGV: destroy not called for primitive type "
|
||||
([#14312](https://github.com/nim-lang/Nim/issues/14312))
|
||||
- Fixed "Crash when using thread and --gc:arc "
|
||||
([#13881](https://github.com/nim-lang/Nim/issues/13881))
|
||||
- Fixed "Getting "Warning: Cannot prove that 'result' is initialized" for an importcpp'd proc with `var T` return type"
|
||||
([#14314](https://github.com/nim-lang/Nim/issues/14314))
|
||||
- Fixed "`nim cpp -r --gc:arc` segfaults on caught AssertionError"
|
||||
([#13071](https://github.com/nim-lang/Nim/issues/13071))
|
||||
- Fixed "tests/async/tasyncawait.nim is recently very flaky"
|
||||
([#14320](https://github.com/nim-lang/Nim/issues/14320))
|
||||
- Fixed "Documentation nonexistent quitprocs module"
|
||||
([#14331](https://github.com/nim-lang/Nim/issues/14331))
|
||||
- Fixed "SIGSEV encountered when creating threads in a loop w/ --gc:arc"
|
||||
([#13935](https://github.com/nim-lang/Nim/issues/13935))
|
||||
- Fixed "nim-gdb is missing from all released packages"
|
||||
([#13104](https://github.com/nim-lang/Nim/issues/13104))
|
||||
- Fixed "sysAssert error with gc:arc on 3 line program"
|
||||
([#13862](https://github.com/nim-lang/Nim/issues/13862))
|
||||
- Fixed "compiler error with inline async proc and pragma"
|
||||
([#13998](https://github.com/nim-lang/Nim/issues/13998))
|
||||
- Fixed "[ARC] Compiler crash when adding to a seq[ref Object]"
|
||||
([#14333](https://github.com/nim-lang/Nim/issues/14333))
|
||||
- Fixed "nimvm: sysFatal: unhandled exception: 'sons' is not accessible using discriminant 'kind' of type 'TNode' [FieldError]"
|
||||
([#14340](https://github.com/nim-lang/Nim/issues/14340))
|
||||
- Fixed "[Regression] karax events are not firing "
|
||||
([#14350](https://github.com/nim-lang/Nim/issues/14350))
|
||||
- Fixed "odbcsql module has some wrong integer types"
|
||||
([#9771](https://github.com/nim-lang/Nim/issues/9771))
|
||||
- Fixed "db_sqlite needs sqlPrepared"
|
||||
([#13559](https://github.com/nim-lang/Nim/issues/13559))
|
||||
- Fixed "[Regression] `createThread` is not GC-safe"
|
||||
([#14370](https://github.com/nim-lang/Nim/issues/14370))
|
||||
- Fixed "Broken example on hot code reloading"
|
||||
([#14380](https://github.com/nim-lang/Nim/issues/14380))
|
||||
- Fixed "runnableExamples block with `except` on specified error fails with `nim doc`"
|
||||
([#12746](https://github.com/nim-lang/Nim/issues/12746))
|
||||
- Fixed "compiler as a library: findNimStdLibCompileTime fails to find system.nim"
|
||||
([#12293](https://github.com/nim-lang/Nim/issues/12293))
|
||||
- Fixed "5 bugs with importcpp exceptions"
|
||||
([#14369](https://github.com/nim-lang/Nim/issues/14369))
|
||||
- Fixed "Docs shouldn't collapse pragmas inside runnableExamples/code blocks"
|
||||
([#14174](https://github.com/nim-lang/Nim/issues/14174))
|
||||
- Fixed "Bad codegen/emit for hashes.hiXorLo in some contexts."
|
||||
([#14394](https://github.com/nim-lang/Nim/issues/14394))
|
||||
- Fixed "Boehm GC does not scan thread-local storage"
|
||||
([#14364](https://github.com/nim-lang/Nim/issues/14364))
|
||||
- Fixed "RVO not exception safe"
|
||||
([#14126](https://github.com/nim-lang/Nim/issues/14126))
|
||||
- Fixed "runnableExamples that are only compiled"
|
||||
([#10731](https://github.com/nim-lang/Nim/issues/10731))
|
||||
- Fixed "`foldr` raises IndexError when called on sequence"
|
||||
([#14404](https://github.com/nim-lang/Nim/issues/14404))
|
||||
- Fixed "moveFile does not overwrite destination file"
|
||||
([#14057](https://github.com/nim-lang/Nim/issues/14057))
|
||||
- Fixed "doc2 outputs in current work dir"
|
||||
([#6583](https://github.com/nim-lang/Nim/issues/6583))
|
||||
- Fixed "[docgen] proc doc comments silently omitted after 1st runnableExamples"
|
||||
([#9227](https://github.com/nim-lang/Nim/issues/9227))
|
||||
- Fixed "`nim doc --project` shows '@@/' instead of '../' for relative paths to submodules"
|
||||
([#14448](https://github.com/nim-lang/Nim/issues/14448))
|
||||
- Fixed "re, nre have wrong `start` semantics"
|
||||
([#14284](https://github.com/nim-lang/Nim/issues/14284))
|
||||
- Fixed "runnableExamples should preserve source code doc comments, strings, and (maybe) formatting"
|
||||
([#8871](https://github.com/nim-lang/Nim/issues/8871))
|
||||
- Fixed "`nim doc ..` fails when runnableExamples uses `$` [devel] [regression]"
|
||||
([#14485](https://github.com/nim-lang/Nim/issues/14485))
|
||||
- Fixed "`items` is 20%~30% slower than iteration via an index"
|
||||
([#14421](https://github.com/nim-lang/Nim/issues/14421))
|
||||
- Fixed "ARC: unreliable setLen "
|
||||
([#14495](https://github.com/nim-lang/Nim/issues/14495))
|
||||
- Fixed "lent is unsafe: after #14447 you can modify variables with "items" loop for sequences"
|
||||
([#14498](https://github.com/nim-lang/Nim/issues/14498))
|
||||
- Fixed "`var op = fn()` wrongly gives warning `ObservableStores` with `object of RootObj` type"
|
||||
([#14514](https://github.com/nim-lang/Nim/issues/14514))
|
||||
- Fixed "Compiler assertion"
|
||||
([#14562](https://github.com/nim-lang/Nim/issues/14562))
|
||||
- Fixed "Can't get `ord` of a value of a Range type in the JS backend "
|
||||
([#14570](https://github.com/nim-lang/Nim/issues/14570))
|
||||
- Fixed "js: can't take addr of param (including implicitly via `lent`)"
|
||||
([#14576](https://github.com/nim-lang/Nim/issues/14576))
|
||||
- Fixed "{.noinit.} ignored in for loop -> bad codegen for non-movable types"
|
||||
([#14118](https://github.com/nim-lang/Nim/issues/14118))
|
||||
- Fixed "generic destructor gives: `Error: unresolved generic parameter`"
|
||||
([#14315](https://github.com/nim-lang/Nim/issues/14315))
|
||||
- Fixed "Memory leak with arc gc"
|
||||
([#14568](https://github.com/nim-lang/Nim/issues/14568))
|
||||
- Fixed "escape analysis broken with `lent`"
|
||||
([#14557](https://github.com/nim-lang/Nim/issues/14557))
|
||||
- Fixed "`wrapWords` seems to ignore linebreaks when wrapping, leaving breaks in the wrong place"
|
||||
([#14579](https://github.com/nim-lang/Nim/issues/14579))
|
||||
- Fixed "`lent` gives wrong results with -d:release"
|
||||
([#14578](https://github.com/nim-lang/Nim/issues/14578))
|
||||
- Fixed "Nested await expressions regression: `await a(await expandValue())` doesnt compile"
|
||||
([#14279](https://github.com/nim-lang/Nim/issues/14279))
|
||||
- Fixed "windows CI docs fails with strange errors"
|
||||
([#14545](https://github.com/nim-lang/Nim/issues/14545))
|
||||
- Fixed "[CI] tests/async/tioselectors.nim flaky test for freebsd + OSX CI"
|
||||
([#13166](https://github.com/nim-lang/Nim/issues/13166))
|
||||
- Fixed "seq.setLen sometimes doesn't zero memory"
|
||||
([#14655](https://github.com/nim-lang/Nim/issues/14655))
|
||||
- Fixed "`nim dump` is roughly 100x slower in 1.3 versus 1.2"
|
||||
([#14179](https://github.com/nim-lang/Nim/issues/14179))
|
||||
- Fixed "Regression: devel docgen cannot generate document for method"
|
||||
([#14691](https://github.com/nim-lang/Nim/issues/14691))
|
||||
- Fixed "recently flaky tests/async/t7758.nim"
|
||||
([#14685](https://github.com/nim-lang/Nim/issues/14685))
|
||||
- Fixed "Bind no longer working in generic procs."
|
||||
([#11811](https://github.com/nim-lang/Nim/issues/11811))
|
||||
- Fixed "The pegs module doesn't work with generics!"
|
||||
([#14718](https://github.com/nim-lang/Nim/issues/14718))
|
||||
- Fixed "Defer is not properly working for asynchronous procedures."
|
||||
([#13899](https://github.com/nim-lang/Nim/issues/13899))
|
||||
- Fixed "Add an ARC test with threads in a loop"
|
||||
([#14690](https://github.com/nim-lang/Nim/issues/14690))
|
||||
- Fixed "[goto exceptions] {.noReturn.} pragma is not detected in a case expression"
|
||||
([#14458](https://github.com/nim-lang/Nim/issues/14458))
|
||||
- Fixed "[exceptions:goto] C compiler error with dynlib pragma calling a proc"
|
||||
([#14240](https://github.com/nim-lang/Nim/issues/14240))
|
||||
- Fixed "Cannot borrow var float64 in infix assignment"
|
||||
([#14440](https://github.com/nim-lang/Nim/issues/14440))
|
||||
- Fixed "lib/pure/memfiles.nim: compilation error with --taintMode:on"
|
||||
([#14760](https://github.com/nim-lang/Nim/issues/14760))
|
||||
- Fixed "newWideCString allocates a multiple of the memory needed"
|
||||
([#14750](https://github.com/nim-lang/Nim/issues/14750))
|
||||
- Fixed "Nim source archive install: 'install.sh' fails with error: cp: cannot stat 'bin/nim-gdb': No such file or directory"
|
||||
([#14748](https://github.com/nim-lang/Nim/issues/14748))
|
||||
- Fixed "`nim cpp -r tests/exception/t9657` hangs"
|
||||
([#10343](https://github.com/nim-lang/Nim/issues/10343))
|
||||
- Fixed "Detect tool fails on FreeBSD"
|
||||
([#14715](https://github.com/nim-lang/Nim/issues/14715))
|
||||
- Fixed "compiler crash: `findUnresolvedStatic` "
|
||||
([#14802](https://github.com/nim-lang/Nim/issues/14802))
|
||||
- Fixed "seq namespace (?) regression"
|
||||
([#4796](https://github.com/nim-lang/Nim/issues/4796))
|
||||
- Fixed "Possible out of bounds string access in std/colors parseColor and isColor"
|
||||
([#14839](https://github.com/nim-lang/Nim/issues/14839))
|
||||
- Fixed "compile error on latest devel with orc and ssl"
|
||||
([#14647](https://github.com/nim-lang/Nim/issues/14647))
|
||||
- Fixed "[minor] `$` wrong for type tuple"
|
||||
([#13432](https://github.com/nim-lang/Nim/issues/13432))
|
||||
- Fixed "Documentation missing on devel asyncftpclient"
|
||||
([#14846](https://github.com/nim-lang/Nim/issues/14846))
|
||||
- Fixed "nimpretty is confused with a trailing comma in enum definition"
|
||||
([#14401](https://github.com/nim-lang/Nim/issues/14401))
|
||||
- Fixed "Output arguments get ignored when compiling with --app:staticlib"
|
||||
([#12745](https://github.com/nim-lang/Nim/issues/12745))
|
||||
- Fixed "[ARC] destructive move destroys the object too early"
|
||||
([#14396](https://github.com/nim-lang/Nim/issues/14396))
|
||||
- Fixed "highlite.getNextToken() crashes if the buffer string is "echo "\"""
|
||||
([#14830](https://github.com/nim-lang/Nim/issues/14830))
|
||||
- Fixed "Memory corruption with --gc:arc with a seq of objects with an empty body."
|
||||
([#14472](https://github.com/nim-lang/Nim/issues/14472))
|
||||
- Fixed "Stropped identifiers don't work as field names in tuple literals"
|
||||
([#14911](https://github.com/nim-lang/Nim/issues/14911))
|
||||
- Fixed "Please revert my commit"
|
||||
([#14930](https://github.com/nim-lang/Nim/issues/14930))
|
||||
- Fixed "[ARC] C compiler error with inline iterators and imports"
|
||||
([#14864](https://github.com/nim-lang/Nim/issues/14864))
|
||||
- Fixed "AsyncHttpClient segfaults with gc:orc, possibly memory corruption"
|
||||
([#14402](https://github.com/nim-lang/Nim/issues/14402))
|
||||
- Fixed "[ARC] Template with a block evaluating to a GC'd value results in a compiler crash"
|
||||
([#14899](https://github.com/nim-lang/Nim/issues/14899))
|
||||
- Fixed "[ARC] Weird issue with if expressions and templates"
|
||||
([#14900](https://github.com/nim-lang/Nim/issues/14900))
|
||||
- Fixed "xmlparser does not compile on devel"
|
||||
([#14805](https://github.com/nim-lang/Nim/issues/14805))
|
||||
- Fixed "returning lent T from a var T param gives codegen errors or SIGSEGV"
|
||||
([#14878](https://github.com/nim-lang/Nim/issues/14878))
|
||||
- Fixed "[ARC] Weird issue with if expressions and templates"
|
||||
([#14900](https://github.com/nim-lang/Nim/issues/14900))
|
||||
- Fixed "threads:on + gc:orc + unittest = C compiler errors"
|
||||
([#14865](https://github.com/nim-lang/Nim/issues/14865))
|
||||
- Fixed "mitems, mpairs doesn't work at compile time anymore"
|
||||
([#12129](https://github.com/nim-lang/Nim/issues/12129))
|
||||
- Fixed "strange result from executing code in const expression"
|
||||
([#10465](https://github.com/nim-lang/Nim/issues/10465))
|
||||
- Fixed "Same warning printed 3 times"
|
||||
([#11009](https://github.com/nim-lang/Nim/issues/11009))
|
||||
- Fixed "type alias for generic typeclass doesn't work"
|
||||
([#4668](https://github.com/nim-lang/Nim/issues/4668))
|
||||
- Fixed "exceptions:goto Bug devel codegen lvalue NIM_FALSE=NIM_FALSE"
|
||||
([#14925](https://github.com/nim-lang/Nim/issues/14925))
|
||||
- Fixed "the --useVersion:1.0 no longer works in devel"
|
||||
([#14912](https://github.com/nim-lang/Nim/issues/14912))
|
||||
- Fixed "template declaration of iterator doesn't compile"
|
||||
([#4722](https://github.com/nim-lang/Nim/issues/4722))
|
||||
- Fixed "Compiler crash on type inheritance with static generic parameter and equality check"
|
||||
([#12571](https://github.com/nim-lang/Nim/issues/12571))
|
||||
- Fixed "Nim crashes while handling a cast in async circumstances."
|
||||
([#13815](https://github.com/nim-lang/Nim/issues/13815))
|
||||
- Fixed "[ARC] Internal compiler error when calling an iterator from an inline proc "
|
||||
([#14383](https://github.com/nim-lang/Nim/issues/14383))
|
||||
- Fixed ""Cannot instantiate" error when template uses generic type"
|
||||
([#5926](https://github.com/nim-lang/Nim/issues/5926))
|
||||
- Fixed "Different raises behaviour for newTerminal between Linux and Windows"
|
||||
([#12759](https://github.com/nim-lang/Nim/issues/12759))
|
||||
- Fixed "Expand on a type (that defines a proc type) in error message "
|
||||
([#6608](https://github.com/nim-lang/Nim/issues/6608))
|
||||
- Fixed "unittest require quits program with an exit code of 0"
|
||||
([#14475](https://github.com/nim-lang/Nim/issues/14475))
|
||||
- Fixed "Range type: Generics vs concrete type, semcheck difference."
|
||||
([#8426](https://github.com/nim-lang/Nim/issues/8426))
|
||||
- Fixed "[Macro] Type mismatch when parameter name is the same as a field"
|
||||
([#13253](https://github.com/nim-lang/Nim/issues/13253))
|
||||
- Fixed "Generic instantiation failure when converting a sequence of circular generic types to strings"
|
||||
([#10396](https://github.com/nim-lang/Nim/issues/10396))
|
||||
- Fixed "initOptParser ignores argument after value option with empty value."
|
||||
([#13086](https://github.com/nim-lang/Nim/issues/13086))
|
||||
- Fixed "[ARC] proc with both explicit and implicit return results in a C compiler error"
|
||||
([#14985](https://github.com/nim-lang/Nim/issues/14985))
|
||||
- Fixed "Alias type forgets implicit generic params depending on order"
|
||||
([#14990](https://github.com/nim-lang/Nim/issues/14990))
|
||||
- Fixed "[ARC] sequtils.insert has different behaviour between ARC/refc"
|
||||
([#14994](https://github.com/nim-lang/Nim/issues/14994))
|
||||
- Fixed "The documentation for "hot code reloading" references a non-existent npm package"
|
||||
([#13621](https://github.com/nim-lang/Nim/issues/13621))
|
||||
- Fixed "existsDir deprecated but breaking `dir` undeclared"
|
||||
([#15006](https://github.com/nim-lang/Nim/issues/15006))
|
||||
- Fixed "uri.decodeUrl crashes on incorrectly formatted input"
|
||||
([#14082](https://github.com/nim-lang/Nim/issues/14082))
|
||||
- Fixed "testament incorrectly reports time for tests, leading to wrong conclusions"
|
||||
([#14822](https://github.com/nim-lang/Nim/issues/14822))
|
||||
- Fixed "Calling peekChar with Stream returned from osproc.outputStream generate runtime error"
|
||||
([#14906](https://github.com/nim-lang/Nim/issues/14906))
|
||||
- Fixed "localPassC pragma should come *after* other flags"
|
||||
([#14194](https://github.com/nim-lang/Nim/issues/14194))
|
||||
- Fixed ""Could not load" dynamic library at runtime because of hidden dependency"
|
||||
([#2408](https://github.com/nim-lang/Nim/issues/2408))
|
||||
- Fixed "--gc:arc generate invalid code for {.global.} (`«nimErr_» in NIM_UNLIKELY`)"
|
||||
([#14480](https://github.com/nim-lang/Nim/issues/14480))
|
||||
- Fixed "Using `^` from stdlib/math along with converters gives a match for types that aren't SomeNumber"
|
||||
([#15033](https://github.com/nim-lang/Nim/issues/15033))
|
||||
- Fixed "[ARC] Weird exception behaviour from doAssertRaises"
|
||||
([#15026](https://github.com/nim-lang/Nim/issues/15026))
|
||||
- Fixed "[ARC] Compiler crash declaring a finalizer proc directly in 'new'"
|
||||
([#15044](https://github.com/nim-lang/Nim/issues/15044))
|
||||
- Fixed "[ARC] C compiler error when creating a var of a const seq"
|
||||
([#15036](https://github.com/nim-lang/Nim/issues/15036))
|
||||
- Fixed "code with named arguments in proc of winim/com can not been compiled"
|
||||
([#15056](https://github.com/nim-lang/Nim/issues/15056))
|
||||
- Fixed "javascript backend produces javascript code with syntax error in object syntax"
|
||||
([#14534](https://github.com/nim-lang/Nim/issues/14534))
|
||||
- Fixed "--gc:arc should be ignored in JS mode."
|
||||
([#14684](https://github.com/nim-lang/Nim/issues/14684))
|
||||
- Fixed "arc: C compilation error with imported global code using a closure iterator"
|
||||
([#12990](https://github.com/nim-lang/Nim/issues/12990))
|
||||
- Fixed "[ARC] Crash when modifying a string with mitems iterator"
|
||||
([#15052](https://github.com/nim-lang/Nim/issues/15052))
|
||||
- Fixed "[ARC] SIGSEGV when calling a closure as a tuple field in a seq"
|
||||
([#15038](https://github.com/nim-lang/Nim/issues/15038))
|
||||
- Fixed "pass varargs[seq[T]] to iterator give empty seq "
|
||||
([#12576](https://github.com/nim-lang/Nim/issues/12576))
|
||||
- Fixed "Compiler crashes when using string as object variant selector with else branch"
|
||||
([#14189](https://github.com/nim-lang/Nim/issues/14189))
|
||||
- Fixed "JS compiler error related to implicit return and return var type"
|
||||
([#11354](https://github.com/nim-lang/Nim/issues/11354))
|
||||
- Fixed "`nkRecWhen` causes internalAssert in semConstructFields"
|
||||
([#14698](https://github.com/nim-lang/Nim/issues/14698))
|
||||
- Fixed "Memory leaks with async (closure iterators?) under ORC"
|
||||
([#15076](https://github.com/nim-lang/Nim/issues/15076))
|
||||
- Fixed "strutil.insertSep() fails on negative numbers"
|
||||
([#11352](https://github.com/nim-lang/Nim/issues/11352))
|
||||
- Fixed "Constructing a uint64 range on a 32-bit machine leads to incorrect codegen"
|
||||
([#14616](https://github.com/nim-lang/Nim/issues/14616))
|
||||
- Fixed "heapqueue pushpop() proc doesn't compile"
|
||||
([#14139](https://github.com/nim-lang/Nim/issues/14139))
|
||||
- Fixed "[ARC] SIGSEGV when trying to swap in a literal/const string"
|
||||
([#15112](https://github.com/nim-lang/Nim/issues/15112))
|
||||
- Fixed "Defer and --gc:arc"
|
||||
([#15071](https://github.com/nim-lang/Nim/issues/15071))
|
||||
- Fixed "internal error: compiler/semobjconstr.nim(324, 20) example"
|
||||
([#15111](https://github.com/nim-lang/Nim/issues/15111))
|
||||
- Fixed "[ARC] Sequence "disappears" with a table inside of a table with an object variant"
|
||||
([#15122](https://github.com/nim-lang/Nim/issues/15122))
|
||||
- Fixed "[ARC] SIGSEGV with tuple assignment caused by cursor inference"
|
||||
([#15130](https://github.com/nim-lang/Nim/issues/15130))
|
||||
- Fixed "Issue with --gc:arc at compile time"
|
||||
([#15129](https://github.com/nim-lang/Nim/issues/15129))
|
||||
- Fixed "Writing an empty string to an AsyncFile raises an IndexDefect"
|
||||
([#15148](https://github.com/nim-lang/Nim/issues/15148))
|
||||
- Fixed "Compiler is confused about call convention of function with nested closure"
|
||||
([#5688](https://github.com/nim-lang/Nim/issues/5688))
|
||||
- Fixed "Nil check on each field fails in generic function"
|
||||
([#15101](https://github.com/nim-lang/Nim/issues/15101))
|
||||
- Fixed "{.nimcall.} convention won't avoid the creation of closures"
|
||||
([#8473](https://github.com/nim-lang/Nim/issues/8473))
|
||||
- Fixed "smtp.nim(161, 40) Error: type mismatch: got <typeof(nil)> but expected 'SslContext = void'"
|
||||
([#15177](https://github.com/nim-lang/Nim/issues/15177))
|
||||
- Fixed "[strscans] scanf doesn't match a single character with $+ if it's the end of the string"
|
||||
([#15064](https://github.com/nim-lang/Nim/issues/15064))
|
||||
- Fixed "Crash and incorrect return values when using readPasswordFromStdin on Windows."
|
||||
([#15207](https://github.com/nim-lang/Nim/issues/15207))
|
||||
- Fixed "Possible capture error with fieldPairs and genericParams"
|
||||
([#15221](https://github.com/nim-lang/Nim/issues/15221))
|
||||
- Fixed "The StmtList processing of template parameters can lead to unexpected errors"
|
||||
([#5691](https://github.com/nim-lang/Nim/issues/5691))
|
||||
- Fixed "[ARC] C compiler error when passing a var openArray to a sink openArray"
|
||||
([#15035](https://github.com/nim-lang/Nim/issues/15035))
|
||||
- Fixed "Inconsistent unsigned -> signed RangeDefect usage across integer sizes"
|
||||
([#15210](https://github.com/nim-lang/Nim/issues/15210))
|
||||
- Fixed "toHex results in RangeDefect exception when used with large uint64"
|
||||
([#15257](https://github.com/nim-lang/Nim/issues/15257))
|
||||
- Fixed "Arc sink arg crash"
|
||||
([#15238](https://github.com/nim-lang/Nim/issues/15238))
|
||||
- Fixed "SQL escape in db_mysql is not enough"
|
||||
([#15219](https://github.com/nim-lang/Nim/issues/15219))
|
||||
- Fixed "Mixing 'return' with expressions is allowed in 1.2"
|
||||
([#15280](https://github.com/nim-lang/Nim/issues/15280))
|
||||
- Fixed "os.getFileInfo() causes ICE with --gc:arc on Windows"
|
||||
([#15286](https://github.com/nim-lang/Nim/issues/15286))
|
||||
- Fixed "[ARC] Sequence "disappears" with a table inside of a table with an object variant"
|
||||
([#15122](https://github.com/nim-lang/Nim/issues/15122))
|
||||
- Fixed "Documentation regression jsre module missing"
|
||||
([#15183](https://github.com/nim-lang/Nim/issues/15183))
|
||||
- Fixed "CountTable.smallest/largest() on empty table either asserts or gives bogus answer"
|
||||
([#15021](https://github.com/nim-lang/Nim/issues/15021))
|
||||
- Fixed "[Regression] Parser regression"
|
||||
([#15305](https://github.com/nim-lang/Nim/issues/15305))
|
||||
- Fixed "[ARC] SIGSEGV with tuple unpacking caused by cursor inference"
|
||||
([#15147](https://github.com/nim-lang/Nim/issues/15147))
|
||||
- Fixed "LwIP/FreeRTOS compile error - missing SIGPIPE and more "
|
||||
([#15302](https://github.com/nim-lang/Nim/issues/15302))
|
||||
- Fixed "Memory leaks with async (closure iterators?) under ORC"
|
||||
([#15076](https://github.com/nim-lang/Nim/issues/15076))
|
||||
- Fixed "Bug compiling with --gc:arg or --gc:orc"
|
||||
([#15325](https://github.com/nim-lang/Nim/issues/15325))
|
||||
- Fixed "memory corruption in tmarshall.nim"
|
||||
([#9754](https://github.com/nim-lang/Nim/issues/9754))
|
||||
- Fixed "typed macros break generic proc definitions"
|
||||
([#15326](https://github.com/nim-lang/Nim/issues/15326))
|
||||
- Fixed "nim doc2 ignores --docSeeSrcUrl parameter"
|
||||
([#6071](https://github.com/nim-lang/Nim/issues/6071))
|
||||
- Fixed "The decodeData Iterator from cgi module crash"
|
||||
([#15369](https://github.com/nim-lang/Nim/issues/15369))
|
||||
- Fixed "|| iterator generates invalid code when compiling with --debugger:native"
|
||||
([#9710](https://github.com/nim-lang/Nim/issues/9710))
|
||||
- Fixed "Wrong number of variables"
|
||||
([#15360](https://github.com/nim-lang/Nim/issues/15360))
|
||||
- Fixed "Coercions with distinct types should traverse pointer modifiers transparently."
|
||||
([#7165](https://github.com/nim-lang/Nim/issues/7165))
|
||||
- Fixed "Error with distinct generic TableRef"
|
||||
([#6060](https://github.com/nim-lang/Nim/issues/6060))
|
||||
- Fixed "Support images in nim docgen"
|
||||
([#6430](https://github.com/nim-lang/Nim/issues/6430))
|
||||
- Fixed "Regression. Double sem check for procs."
|
||||
([#15389](https://github.com/nim-lang/Nim/issues/15389))
|
||||
- Fixed "uri.nim url with literal ipv6 address is printed wrong, and cannot parsed again"
|
||||
([#15333](https://github.com/nim-lang/Nim/issues/15333))
|
||||
- Fixed "[ARC] Object variant gets corrupted with cursor inference"
|
||||
([#15361](https://github.com/nim-lang/Nim/issues/15361))
|
||||
- Fixed "`nim doc ..` compiler crash (regression 0.19.6 => 1.0)"
|
||||
([#14474](https://github.com/nim-lang/Nim/issues/14474))
|
||||
- Fixed "cannot borrow result; what it borrows from is potentially mutated"
|
||||
([#15403](https://github.com/nim-lang/Nim/issues/15403))
|
||||
- Fixed "memory corruption for seq.add(seq) with gc:arc and d:useMalloc "
|
||||
([#14983](https://github.com/nim-lang/Nim/issues/14983))
|
||||
- Fixed "DocGen HTML output appears improperly when encountering text immediately after/before inline monospace; in some cases won't compile"
|
||||
([#11537](https://github.com/nim-lang/Nim/issues/11537))
|
||||
- Fixed "Deepcopy in arc crashes"
|
||||
([#15405](https://github.com/nim-lang/Nim/issues/15405))
|
||||
- Fixed "pop pragma takes invalid input"
|
||||
([#15430](https://github.com/nim-lang/Nim/issues/15430))
|
||||
- Fixed "tests/stdlib/tgetprotobyname fails on NetBSD"
|
||||
([#15452](https://github.com/nim-lang/Nim/issues/15452))
|
||||
- Fixed "defer doesnt work with block, break and await"
|
||||
([#15243](https://github.com/nim-lang/Nim/issues/15243))
|
||||
- Fixed "tests/stdlib/tssl failing on NetBSD"
|
||||
([#15493](https://github.com/nim-lang/Nim/issues/15493))
|
||||
- Fixed "strictFuncs doesn't seem to catch simple ref mutation"
|
||||
([#15508](https://github.com/nim-lang/Nim/issues/15508))
|
||||
- Fixed "Sizeof of case object is incorrect. Showstopper"
|
||||
([#15516](https://github.com/nim-lang/Nim/issues/15516))
|
||||
- Fixed "[ARC] Internal error when trying to use a parallel for loop"
|
||||
([#15512](https://github.com/nim-lang/Nim/issues/15512))
|
||||
- Fixed "[ARC] Type-bound assign op is not being generated"
|
||||
([#15510](https://github.com/nim-lang/Nim/issues/15510))
|
||||
- Fixed "[ARC] Crash when adding openArray proc argument to a local seq"
|
||||
([#15511](https://github.com/nim-lang/Nim/issues/15511))
|
||||
- Fixed "VM: const case object gets some fields zeroed out at runtime"
|
||||
([#13081](https://github.com/nim-lang/Nim/issues/13081))
|
||||
- Fixed "regression(1.2.6 => devel): VM: const case object field access gives: 'sons' is not accessible"
|
||||
([#15532](https://github.com/nim-lang/Nim/issues/15532))
|
||||
- Fixed "Csources: huge size increase (x2.3) in 0.20"
|
||||
([#12027](https://github.com/nim-lang/Nim/issues/12027))
|
||||
- Fixed "Out of date error message for GC options"
|
||||
([#15547](https://github.com/nim-lang/Nim/issues/15547))
|
||||
- Fixed "dbQuote additional escape regression"
|
||||
([#15560](https://github.com/nim-lang/Nim/issues/15560))
|
||||
|
|
@ -1,957 +0,0 @@
|
|||
# v1.6.0 - 2021-10-14
|
||||
|
||||
|
||||
|
||||
# Major new features
|
||||
|
||||
With so many new features, pinpointing the most salient ones is a subjective exercise,
|
||||
but here are a select few:
|
||||
|
||||
|
||||
## `iterable[T]`
|
||||
|
||||
The `iterable[T]` type class was added to match called iterators,
|
||||
which solves a number of long-standing issues related to iterators.
|
||||
Example:
|
||||
|
||||
```nim
|
||||
iterator iota(n: int): int =
|
||||
for i in 0..<n: yield i
|
||||
|
||||
# previously, you'd need `untyped`, which caused other problems such as lack
|
||||
# of type inference, overloading issues, and MCS.
|
||||
template sumOld(a: untyped): untyped = # no type inference possible
|
||||
var result: typeof(block:(for ai in a: ai))
|
||||
for ai in a: result += ai
|
||||
result
|
||||
|
||||
assert sumOld(iota(3)) == 0 + 1 + 2
|
||||
|
||||
# now, you can write:
|
||||
template sum[T](a: iterable[T]): T =
|
||||
# `template sum(a: iterable): auto =` would also be possible
|
||||
var result: T
|
||||
for ai in a: result += ai
|
||||
result
|
||||
|
||||
assert sum(iota(3)) == 0 + 1 + 2 # or `iota(3).sum`
|
||||
```
|
||||
|
||||
In particular iterable arguments can now be used with the method call syntax. For example:
|
||||
```nim
|
||||
import std/[sequtils, os]
|
||||
echo walkFiles("*").toSeq # now works
|
||||
```
|
||||
See PR [#17196](https://github.com/nim-lang/Nim/pull/17196) for additional details.
|
||||
|
||||
|
||||
## Strict effects
|
||||
|
||||
The effect system was refined and there is a new `.effectsOf` annotation that does
|
||||
explicitly what was previously done implicitly. See the
|
||||
[manual](https://nim-lang.github.io/Nim/manual.html#effect-system-effectsof-annotation)
|
||||
for more details.
|
||||
To write code that is portable with older Nim versions, use this idiom:
|
||||
|
||||
```nim
|
||||
when defined(nimHasEffectsOf):
|
||||
{.experimental: "strictEffects".}
|
||||
else:
|
||||
{.pragma: effectsOf.}
|
||||
|
||||
proc mysort(s: seq; cmp: proc(a, b: T): int) {.effectsOf: cmp.}
|
||||
```
|
||||
|
||||
To enable the new effect system, compile with `--experimental:strictEffects`.
|
||||
See also [#18777](https://github.com/nim-lang/Nim/pull/18777) and RFC
|
||||
[#408](https://github.com/nim-lang/RFCs/issues/408).
|
||||
|
||||
|
||||
## Private imports and private field access
|
||||
|
||||
A new import syntax `import foo {.all.}` now allows importing all symbols
|
||||
(public or private) from `foo`.
|
||||
This can be useful for testing purposes or for more flexibility in project organization.
|
||||
|
||||
Example:
|
||||
```nim
|
||||
from system {.all.} as system2 import nil
|
||||
echo system2.ThisIsSystem # ThisIsSystem is private in `system`
|
||||
import os {.all.} # weirdTarget is private in `os`
|
||||
echo weirdTarget # or `os.weirdTarget`
|
||||
```
|
||||
|
||||
Added a new module `std/importutils`, and an API `privateAccess`, which allows access
|
||||
to private fields for an object type in the current scope.
|
||||
|
||||
Example:
|
||||
```nim
|
||||
import times
|
||||
from std/importutils import privateAccess
|
||||
block:
|
||||
let t = now()
|
||||
# echo t.monthdayZero # Error: undeclared field: 'monthdayZero' for type times.DateTime
|
||||
privateAccess(typeof(t)) # enables private access in this scope
|
||||
echo t.monthdayZero # ok
|
||||
```
|
||||
|
||||
See PR [#17706](https://github.com/nim-lang/Nim/pull/17706) for additional details.
|
||||
|
||||
|
||||
## `nim --eval:cmd`
|
||||
|
||||
Added `nim --eval:cmd` to evaluate a command directly, e.g.: `nim --eval:"echo 1"`.
|
||||
It defaults to `e` (nimscript) but can also work with other commands, e.g.:
|
||||
```bash
|
||||
find . | nim r --eval:'import strutils; for a in stdin.lines: echo a.toUpper'
|
||||
```
|
||||
|
||||
```bash
|
||||
# use as a calculator:
|
||||
nim --eval:'echo 3.1 / (1.2+7)'
|
||||
# explore a module's APIs, including private symbols:
|
||||
nim --eval:'import os {.all.}; echo weirdTarget'
|
||||
# use a custom backend:
|
||||
nim r -b:js --eval:"import std/jsbigints; echo 2'big ** 64'big"
|
||||
```
|
||||
|
||||
See PR [#15687](https://github.com/nim-lang/Nim/pull/15687) for more details.
|
||||
|
||||
|
||||
## Round-trip float to string
|
||||
|
||||
`system.addFloat` and `system.$` now can produce string representations of
|
||||
floating point numbers that are minimal in size and possess round-trip and correct
|
||||
rounding guarantees (via the
|
||||
[Dragonbox](https://raw.githubusercontent.com/jk-jeon/dragonbox/master/other_files/Dragonbox.pdf) algorithm).
|
||||
This currently has to be enabled via `-d:nimPreviewFloatRoundtrip`.
|
||||
It is expected that this behavior becomes the new default in upcoming versions,
|
||||
as with other `nimPreviewX` define flags.
|
||||
|
||||
Example:
|
||||
```nim
|
||||
from math import round
|
||||
let a = round(9.779999999999999, 2)
|
||||
assert a == 9.78
|
||||
echo a # with `-d:nimPreviewFloatRoundtrip`: 9.78, like in python3 (instead of 9.779999999999999)
|
||||
```
|
||||
|
||||
|
||||
## New `std/jsbigints` module
|
||||
|
||||
Provides arbitrary precision integers for the JS target. See PR
|
||||
[#16409](https://github.com/nim-lang/Nim/pull/16409).
|
||||
Example:
|
||||
```nim
|
||||
import std/jsbigints
|
||||
assert 2'big ** 65'big == 36893488147419103232'big
|
||||
echo 0xdeadbeef'big shl 4'big # 59774856944n
|
||||
```
|
||||
|
||||
|
||||
## New `std/sysrand` module
|
||||
Cryptographically secure pseudorandom number generator,
|
||||
allows generating random numbers from a secure source provided by the operating system.
|
||||
Example:
|
||||
```nim
|
||||
import std/sysrand
|
||||
assert urandom(1234) != urandom(1234) # unlikely to fail in practice
|
||||
```
|
||||
See PR [#16459](https://github.com/nim-lang/Nim/pull/16459).
|
||||
|
||||
|
||||
## New module: `std/tempfiles`
|
||||
|
||||
Allows creating temporary files and directories, see PR
|
||||
[#17361](https://github.com/nim-lang/Nim/pull/17361) and followups.
|
||||
```nim
|
||||
import std/tempfiles
|
||||
let tmpPath = genTempPath("prefix", "suffix.log", "/tmp/")
|
||||
# tmpPath looks like: /tmp/prefixpmW1P2KLsuffix.log
|
||||
|
||||
let dir = createTempDir("tmpprefix_", "_end")
|
||||
# created dir looks like: getTempDir() / "tmpprefix_YEl9VuVj_end"
|
||||
|
||||
let (cfile, path) = createTempFile("tmpprefix_", "_end.tmp")
|
||||
# path looks like: getTempDir() / "tmpprefix_FDCIRZA0_end.tmp"
|
||||
cfile.write "foo"
|
||||
cfile.setFilePos 0
|
||||
assert readAll(cfile) == "foo"
|
||||
close cfile
|
||||
assert readFile(path) == "foo"
|
||||
```
|
||||
|
||||
|
||||
## User-defined literals
|
||||
|
||||
Custom numeric literals (e.g. `-128'bignum`) are now supported.
|
||||
Additionally, the unary minus in `-1` is now part of the integer literal, i.e.
|
||||
it is now parsed as a single token.
|
||||
This implies that edge cases like `-128'i8` finally work correctly.
|
||||
Example:
|
||||
```nim
|
||||
func `'big`*(num: cstring): JsBigInt {.importjs: "BigInt(#)".}
|
||||
assert 0xffffffffffffffff'big == (1'big shl 64'big) - 1'big
|
||||
```
|
||||
|
||||
|
||||
## Dot-like operators
|
||||
|
||||
With `-d:nimPreviewDotLikeOps`, dot-like operators (operators starting with `.`,
|
||||
but not with `..`) now have the same precedence as `.`, so that `a.?b.c` is now
|
||||
parsed as `(a.?b).c` instead of `a.?(b.c)`.
|
||||
A warning is generated when a dot-like operator is used without `-d:nimPreviewDotLikeOps`.
|
||||
|
||||
An important use case is to enable dynamic fields without affecting the
|
||||
built-in `.` operator, e.g. for `std/jsffi`, `std/json`, `pkg/nimpy`. Example:
|
||||
```nim
|
||||
import std/json
|
||||
template `.?`(a: JsonNode, b: untyped{ident}): JsonNode =
|
||||
a[astToStr(b)]
|
||||
let j = %*{"a1": {"a2": 10}}
|
||||
assert j.?a1.?a2.getInt == 10
|
||||
```
|
||||
|
||||
|
||||
## Block arguments now support optional parameters
|
||||
|
||||
This solves a major pain point for routines accepting block parameters,
|
||||
see PR [#18631](https://github.com/nim-lang/Nim/pull/18631) for details:
|
||||
|
||||
```nim
|
||||
template fn(a = 1, b = 2, body) = discard
|
||||
fn(1, 2): # already works
|
||||
bar
|
||||
fn(a = 1): # now works
|
||||
bar
|
||||
```
|
||||
|
||||
Likewise with multiple block arguments via `do`:
|
||||
```nim
|
||||
template fn(a = 1, b = 2, body1, body2) = discard
|
||||
fn(a = 1): # now works
|
||||
bar1
|
||||
do:
|
||||
bar2
|
||||
```
|
||||
|
||||
|
||||
# Other new features
|
||||
|
||||
## New and deprecated modules
|
||||
|
||||
The following modules were added (they are discussed in the rest of the text):
|
||||
- `std/enumutils`
|
||||
- `std/genasts`
|
||||
- `std/importutils`
|
||||
- `std/jsbigints`
|
||||
- `std/jsfetch`
|
||||
- `std/jsformdata`
|
||||
- `std/jsheaders`
|
||||
- `std/packedsets`
|
||||
- `std/setutils`
|
||||
- `std/socketstreams`
|
||||
- `std/strbasics`
|
||||
- `std/sysrand`
|
||||
- `std/tasks`
|
||||
- `std/tempfiles`
|
||||
- `std/vmutils`
|
||||
|
||||
- Deprecated `std/mersenne`.
|
||||
- Removed deprecated `std/iup` module from stdlib; it has already moved to
|
||||
[nimble](https://github.com/nim-lang/iup).
|
||||
|
||||
|
||||
## New `std/jsfetch` module
|
||||
|
||||
Provides a wrapper for JS Fetch API.
|
||||
Example:
|
||||
```nim
|
||||
# requires -d:nimExperimentalAsyncjsThen
|
||||
import std/[jsfetch, asyncjs, jsconsole, jsffi, sugar]
|
||||
proc fn {.async.} =
|
||||
await fetch("https://api.github.com/users/torvalds".cstring)
|
||||
.then((response: Response) => response.json())
|
||||
.then((json: JsObject) => console.log(json))
|
||||
.catch((err: Error) => console.log("Request Failed", err))
|
||||
discard fn()
|
||||
```
|
||||
|
||||
|
||||
## New `std/tasks` module
|
||||
|
||||
Provides basic primitives for creating parallel programs.
|
||||
Example:
|
||||
```nim
|
||||
import std/tasks
|
||||
var num = 0
|
||||
proc hello(a: int) = num+=a
|
||||
|
||||
let b = toTask hello(13) # arguments must be isolated, see `std/isolation`
|
||||
b.invoke()
|
||||
assert num == 13
|
||||
b.invoke() # can be called again
|
||||
assert num == 26
|
||||
```
|
||||
|
||||
|
||||
## New module: `std/genasts`
|
||||
|
||||
Provides an API `genAst` that avoids the problems inherent with `quote do` and can
|
||||
be used as a replacement.
|
||||
Example showing how this could be used for writing a simplified version of `unittest.check`:
|
||||
```nim
|
||||
import std/[genasts, macros, strutils]
|
||||
macro check2(cond: bool): untyped =
|
||||
assert cond.kind == nnkInfix, "$# not implemented" % $cond.kind
|
||||
result = genAst(cond, s = repr(cond), lhs = cond[1], rhs = cond[2]):
|
||||
# each local symbol we access must be explicitly captured
|
||||
if not cond:
|
||||
doAssert false, "'$#'' failed: lhs: '$#', rhs: '$#'" % [s, $lhs, $rhs]
|
||||
let a = 3
|
||||
check2 a*2 == a+3
|
||||
if false: check2 a*2 < a+1 # would error with: 'a * 2 < a + 1'' failed: lhs: '6', rhs: '4'
|
||||
```
|
||||
|
||||
See PR [#17426](https://github.com/nim-lang/Nim/pull/17426) for details.
|
||||
|
||||
|
||||
## New module: `std/setutils`
|
||||
|
||||
- Added `setutils.toSet` that can take any iterable and convert it to a built-in `set`,
|
||||
if the iterable yields a built-in settable type.
|
||||
- Added `setutils.fullSet` which returns a full built-in `set` for a valid type.
|
||||
- Added `setutils.complement` which returns the complement of a built-in `set`.
|
||||
- Added `setutils.[]=`.
|
||||
|
||||
|
||||
## New module: `std/enumutils`
|
||||
|
||||
- Added `genEnumCaseStmt` macro that generates
|
||||
case statement to parse string to enum.
|
||||
- Added `items` for enums with holes.
|
||||
- Added `symbolName` to return the `enum` symbol name ignoring the human-readable name.
|
||||
- Added `symbolRank` to return the index in which an `enum` member is listed in an enum.
|
||||
|
||||
|
||||
## `system`
|
||||
|
||||
- Added `system.prepareMutation` for better support of low
|
||||
level `moveMem`, `copyMem` operations for `gc:orc`'s copy-on-write string
|
||||
implementation.
|
||||
- `system.addEscapedChar` now renders `\r` as `\r` instead of `\c`, to be compatible
|
||||
with most other languages.
|
||||
- Added `cmpMem` to `system`.
|
||||
- `doAssertRaises` now correctly handles foreign exceptions.
|
||||
- `addInt` now supports unsigned integers.
|
||||
|
||||
Compatibility notes:
|
||||
- `system.delete` had surprising behavior when the index passed to it was out of
|
||||
bounds (it would delete the last entry then). Compile with `-d:nimStrictDelete` so
|
||||
that an index error is produced instead. Be aware however that your code might depend on
|
||||
this quirky behavior so a review process is required on your part before you can
|
||||
use `-d:nimStrictDelete`. To make this review easier, use the `-d:nimAuditDelete`
|
||||
switch, which pretends that `system.delete` is deprecated so that it is easier
|
||||
to see where it was used in your code.
|
||||
`-d:nimStrictDelete` will become the default in upcoming versions.
|
||||
- `cuchar` is now deprecated as it aliased `char` where arguably it should have aliased `uint8`.
|
||||
Please use `char` or `uint8` instead.
|
||||
- `repr` now doesn't insert trailing newlines; the previous behavior was very inconsistent,
|
||||
see [#16034](https://github.com/nim-lang/Nim/pull/16034).
|
||||
Use `-d:nimLegacyReprWithNewline` for the previous behavior.
|
||||
`repr` now also renders ASTs correctly for user defined literals, setters, `do`, etc.
|
||||
- Deprecated `any`. See RFC [#281](https://github.com/nim-lang/RFCs/issues/281).
|
||||
- The unary slice `..b` was deprecated, use `0..b` instead.
|
||||
|
||||
|
||||
## `std/math`
|
||||
|
||||
- Added `almostEqual` for comparing two float values using a machine epsilon.
|
||||
- Added `clamp` which allows using a `Slice` to clamp to a value.
|
||||
- Added `ceilDiv` for integer division that rounds up.
|
||||
- Added `isNaN`.
|
||||
- Added `copySign`.
|
||||
- Added `euclDiv` and `euclMod`.
|
||||
- Added `signbit`.
|
||||
- Added `frexp` overload procs. Deprecated `c_frexp`, use `frexp` instead.
|
||||
|
||||
Compatibility notes:
|
||||
- `math.round` now rounds "away from zero" in the JS backend, which is consistent
|
||||
with other backends. See [#9125](https://github.com/nim-lang/Nim/pull/9125).
|
||||
Use `-d:nimLegacyJsRound` for the previous behavior.
|
||||
|
||||
|
||||
## Random number generators: `std/random`, `std/sysrand`, `std/oids`
|
||||
|
||||
- Added `std/sysrand` module (see details above).
|
||||
- Added `randState` template that exposes the default random number generator.
|
||||
Useful for library authors.
|
||||
- Added `initRand()` overload with no argument which uses the current time as a seed.
|
||||
- `initRand(seed)` now allows `seed == 0`.
|
||||
- Fixed overflow bugs.
|
||||
- Fix `initRand` to avoid random number sequences overlapping, refs
|
||||
[#18744](https://github.com/nim-lang/Nim/pull/18744).
|
||||
- `std/oids` now uses `std/random`.
|
||||
|
||||
Compatibility notes:
|
||||
- Deprecated `std/mersenne`.
|
||||
- `random.initRand(seed)` now produces non-skewed values for the first call to
|
||||
`rand()` after initialization with a small (< 30000) seed.
|
||||
Use `-d:nimLegacyRandomInitRand` to restore previous behavior for a transition
|
||||
time, see PR [#17467](https://github.com/nim-lang/Nim/pull/17467).
|
||||
|
||||
|
||||
## `std/json`, `std/jsonutils`
|
||||
|
||||
- With `-d:nimPreviewJsonutilsHoleyEnum`, `jsonutils` now can serialize/deserialize
|
||||
holey enums as regular enums (via `ord`) instead of as strings.
|
||||
It is expected that this behavior becomes the new default in upcoming versions.
|
||||
`toJson` now serializes `JsonNode` as is via reference (without a deep copy)
|
||||
instead of treating `JsonNode` as a regular ref object,
|
||||
this can be customized via `jsonNodeMode`.
|
||||
- `std/json` and `std/jsonutils` now serialize `NaN`, `Inf`, `-Inf` as strings,
|
||||
so that `%[NaN, -Inf]` is the string `["nan","-inf"]` instead of `[nan,-inf]`
|
||||
which was invalid JSON.
|
||||
- `std/json` can now handle integer literals and floating point literals of
|
||||
arbitrary length and precision.
|
||||
Numbers that do not fit the underlying `BiggestInt` or `BiggestFloat` fields are
|
||||
kept as string literals and one can use external BigNum libraries to handle these.
|
||||
The `parseFloat` family of functions also has now optional `rawIntegers` and
|
||||
`rawFloats` parameters that can be used to enforce that all integer or float
|
||||
literals remain in the "raw" string form so that client code can easily treat
|
||||
small and large numbers uniformly.
|
||||
- Added `BackwardsIndex` overload for `JsonNode`.
|
||||
- `json.%`,`json.to`, `jsonutils.fromJson`,`jsonutils.toJson` now work with `uint|uint64`
|
||||
instead of raising (as in 1.4) or giving wrong results (as in 1.2).
|
||||
- `std/jsonutils` now handles `cstring` (including as Table key), and `set`.
|
||||
- Added `jsonutils.jsonTo` overload with `opt = Joptions()` param.
|
||||
- `jsonutils.toJson` now supports customization via `ToJsonOptions`.
|
||||
- `std/json`, `std/jsonutils` now support round-trip serialization when
|
||||
`-d:nimPreviewFloatRoundtrip` is used.
|
||||
|
||||
|
||||
## `std/typetraits`, `std/compilesettings`
|
||||
|
||||
- `distinctBase` now is identity instead of error for non distinct types.
|
||||
- `distinctBase` now allows controlling whether to be recursive or not.
|
||||
- Added `enumLen` to return the number of elements in an enum.
|
||||
- Added `HoleyEnum` for enums with holes, `OrdinalEnum` for enums without holes.
|
||||
- Added `hasClosure`.
|
||||
- Added `pointerBase` to return `T` for `ref T | ptr T`.
|
||||
- Added `compilesettings.SingleValueSetting.libPath`.
|
||||
|
||||
|
||||
## networking: `std/net`, `std/asyncnet`, `std/htmlgen`, `std/httpclient`, `std/asyncdispatch`, `std/asynchttpserver`, `std/httpcore`
|
||||
|
||||
- Fixed buffer overflow bugs in `std/net`.
|
||||
- Exported `sslHandle` from `std/net` and `std/asyncnet`.
|
||||
- Added `hasDataBuffered` to `std/asyncnet`.
|
||||
- Various functions in `std/httpclient` now accept `url` of type `Uri`.
|
||||
Moreover, the `request` function's `httpMethod` argument of type `string` was
|
||||
deprecated in favor of `HttpMethod` `enum` type; see
|
||||
[#15919](https://github.com/nim-lang/Nim/pull/15919).
|
||||
- Added `asyncdispatch.activeDescriptors` that returns the number of currently
|
||||
active async event handles/file descriptors.
|
||||
- Added `getPort` to `std/asynchttpserver` to resolve OS-assigned `Port(0)`;
|
||||
this is usually recommended instead of hardcoding ports which can lead to
|
||||
"Address already in use" errors.
|
||||
- Fixed premature garbage collection in `std/asyncdispatch`, when a stacktrace
|
||||
override is in place.
|
||||
- Added `httpcore.is1xx` and missing HTTP codes.
|
||||
- Added `htmlgen.portal` for [making "SPA style" pages using HTML only](https://web.dev/hands-on-portals).
|
||||
|
||||
Compatibility notes:
|
||||
- On Windows, the SSL library now checks for valid certificates.
|
||||
For this purpose it uses the `cacert.pem` file, which was extracted
|
||||
from `https://curl.se/ca/cacert.pem`. Besides
|
||||
the OpenSSL DLLs (e.g. `libssl-1_1-x64.dll`, `libcrypto-1_1-x64.dll`) you
|
||||
now also need to ship `cacert.pem` with your `.exe` file.
|
||||
|
||||
|
||||
## `std/hashes`
|
||||
|
||||
- `hashes.hash` can now support `object` and `ref` (can be overloaded in user code),
|
||||
if `-d:nimPreviewHashRef` is used. It is expected that this behavior
|
||||
becomes the new default in upcoming versions.
|
||||
- `hashes.hash(proc|ptr|ref|pointer)` now calls `hash(int)` and honors `-d:nimIntHash1`.
|
||||
`hashes.hash(closure)` has also been improved.
|
||||
|
||||
|
||||
## OS: `std/os`, `std/io`, `std/socketstream`, `std/linenoise`, `std/tempfiles`
|
||||
|
||||
- `os.FileInfo` (returned by `getFileInfo`) now contains `blockSize`,
|
||||
determining preferred I/O block size for this file object.
|
||||
- Added `os.getCacheDir()` to return platform specific cache directory.
|
||||
- Improved `os.getTempDir()`, see PR [#16914](https://github.com/nim-lang/Nim/pull/16914).
|
||||
- Added `os.isAdmin` to tell whether the caller's process is a member of the
|
||||
Administrators local group (on Windows) or a root (on POSIX).
|
||||
- Added optional `options` argument to `copyFile`, `copyFileToDir`, and
|
||||
`copyFileWithPermissions`. By default, on non-Windows OSes, symlinks are
|
||||
followed (copy files symlinks point to); on Windows, `options` argument is
|
||||
ignored and symlinks are skipped.
|
||||
- On non-Windows OSes, `copyDir` and `copyDirWithPermissions` copy symlinks as
|
||||
symlinks (instead of skipping them as it was before); on Windows symlinks are
|
||||
skipped.
|
||||
- On non-Windows OSes, `moveFile` and `moveDir` move symlinks as symlinks
|
||||
(instead of skipping them sometimes as it was before).
|
||||
- Added optional `followSymlinks` argument to `setFilePermissions`.
|
||||
- Added a simpler to use `io.readChars` overload.
|
||||
- Added `socketstream` module that wraps sockets in the stream interface.
|
||||
- Added experimental `linenoise.readLineStatus` to get line and status (e.g. ctrl-D or ctrl-C).
|
||||
|
||||
|
||||
## Environment variable handling
|
||||
|
||||
- Empty environment variable values are now supported across OS's and backends.
|
||||
- Environment variable APIs now work in multithreaded scenarios, by delegating to
|
||||
direct OS calls instead of trying to keep track of the environment.
|
||||
- `putEnv`, `delEnv` now work at compile time.
|
||||
- NodeJS backend now supports osenv: `getEnv`, `putEnv`, `envPairs`, `delEnv`, `existsEnv`.
|
||||
|
||||
Compatibility notes:
|
||||
- `std/os`: `putEnv` now raises if the first argument contains a `=`.
|
||||
|
||||
|
||||
## POSIX
|
||||
|
||||
- On POSIX systems, the default signal handlers used for Nim programs (it's
|
||||
used for printing the stacktrace on fatal signals) will now re-raise the
|
||||
signal for the OS default handlers to handle.
|
||||
This lets the OS perform its default actions, which might include core
|
||||
dumping (on select signals) and notifying the parent process about the cause
|
||||
of termination.
|
||||
- On POSIX systems, we now ignore `SIGPIPE` signals, use `-d:nimLegacySigpipeHandler`
|
||||
for previous behavior.
|
||||
- Added `posix_utils.osReleaseFile` to get system identification from `os-release`
|
||||
file on Linux and the BSDs.
|
||||
([link](https://www.freedesktop.org/software/systemd/man/os-release.html))
|
||||
- Removed undefined behavior for `posix.open`.
|
||||
|
||||
|
||||
## `std/prelude`
|
||||
|
||||
- `std/strformat` is now part of `include std/prelude`.
|
||||
- Added `std/sequtils` import to `std/prelude`.
|
||||
- `std/prelude` now works with the JS target.
|
||||
- `std/prelude` can now be used via `include std/prelude`, but `include prelude` still works.
|
||||
|
||||
|
||||
## String manipulation: `std/strformat`, `std/strbasics`
|
||||
|
||||
- Added support for parenthesized expressions.
|
||||
- Added support for const strings instead of just string literals.
|
||||
- Added `std/strbasics` for high-performance string operations.
|
||||
- Added `strip`, `setSlice`, `add(a: var string, b: openArray[char])`.
|
||||
|
||||
|
||||
## `std/wrapnils`
|
||||
|
||||
- `std/wrapnils` doesn't use `experimental:dotOperators` anymore, avoiding
|
||||
issues like bug [#13063](https://github.com/nim-lang/Nim/issues/13063)
|
||||
(which affected error messages) for modules importing `std/wrapnils`.
|
||||
- Added `??.` macro which returns an `Option`.
|
||||
- `std/wrapnils` can now be used to protect against `FieldDefect` errors in
|
||||
case objects, generates optimal code (no overhead compared to manual
|
||||
if-else branches), and preserves lvalue semantics which allows modifying
|
||||
an expression.
|
||||
|
||||
|
||||
## Containers: `std/algorithm`, `std/lists`, `std/sequtils`, `std/options`, `std/packedsets`
|
||||
|
||||
- Removed the optional `longestMatch` parameter of the `critbits._WithPrefix`
|
||||
iterators (it never worked reliably).
|
||||
- Added `algorithm.merge`.
|
||||
- In `std/lists`: renamed `append` to `add` and retained `append` as an alias;
|
||||
added `prepend` and `prependMoved` analogously to `add` and `addMoved`;
|
||||
added `remove` for `SinglyLinkedList`s.
|
||||
- Added new operations for singly- and doubly linked lists: `lists.toSinglyLinkedList`
|
||||
and `lists.toDoublyLinkedList` convert from `openArray`s; `lists.copy` implements
|
||||
shallow copying; `lists.add` concatenates two lists - an O(1) variation that consumes
|
||||
its argument, `addMoved`, is also supplied.
|
||||
See PRs [#16362](https://github.com/nim-lang/Nim/pull/16362),
|
||||
[#16536](https://github.com/nim-lang/Nim/pull/16536).
|
||||
- New module: `std/packedsets`.
|
||||
Generalizes `std/intsets`, see PR [#15564](https://github.com/nim-lang/Nim/pull/15564).
|
||||
|
||||
Compatibility notes:
|
||||
- Deprecated `sequtils.delete` and added an overload taking a `Slice` that raises
|
||||
a defect if the slice is out of bounds, likewise with `strutils.delete`.
|
||||
- Deprecated `proc reversed*[T](a: openArray[T], first: Natural, last: int): seq[T]`
|
||||
in `std/algorithm`.
|
||||
- `std/options` changed `$some(3)` to `"some(3)"` instead of `"Some(3)"`
|
||||
and `$none(int)` to `"none(int)"` instead of `"None[int]"`.
|
||||
|
||||
|
||||
## `std/times`
|
||||
|
||||
- Added `ZZZ` and `ZZZZ` patterns to `times.nim` `DateTime` parsing, to match time
|
||||
zone offsets without colons, e.g. `UTC+7 -> +0700`.
|
||||
- Added `dateTime` and deprecated `initDateTime`.
|
||||
|
||||
|
||||
## `std/macros` and AST
|
||||
|
||||
- New module `std/genasts`, see description above.
|
||||
- The required name of case statement macros for the experimental
|
||||
`caseStmtMacros` feature has changed from `match` to `` `case` ``.
|
||||
- Tuple expressions are now parsed consistently as
|
||||
`nnkTupleConstr` node. Will affect macros expecting nodes to be of `nnkPar`.
|
||||
- In `std/macros`, `treeRepr,lispRepr,astGenRepr` now represent SymChoice nodes
|
||||
in a collapsed way.
|
||||
Use `-d:nimLegacyMacrosCollapseSymChoice` to get the previous behavior.
|
||||
- Made custom op in `macros.quote` work for all statements.
|
||||
|
||||
|
||||
## `std/sugar`
|
||||
|
||||
- Added `sugar.dumpToString` which improves on `sugar.dump`.
|
||||
- Added an overload for the `collect` macro that infers the container type based
|
||||
on the syntax of the last expression. Works with std seqs, tables and sets.
|
||||
|
||||
Compatibility notes:
|
||||
- Removed support for named procs in `sugar.=>`.
|
||||
|
||||
|
||||
## Parsing: `std/parsecfg`, `std/strscans`, `std/uri`
|
||||
|
||||
- Added `sections` iterator in `parsecfg`.
|
||||
- `strscans.scanf` now supports parsing single characters.
|
||||
- Added `strscans.scanTuple` which uses `strscans.scanf` internally,
|
||||
returning a tuple which can be unpacked for easier usage of `scanf`.
|
||||
- Added `decodeQuery` to `std/uri`.
|
||||
- `parseopt.initOptParser` has been made available and `parseopt` has been
|
||||
added back to `std/prelude` for all backends. Previously `initOptParser` was
|
||||
unavailable if the `std/os` module did not have `paramCount` or `paramStr`,
|
||||
but the use of these in `initOptParser` were conditionally to the runtime
|
||||
arguments passed to it, so `initOptParser` has been changed to raise
|
||||
`ValueError` when the real command line is not available. `parseopt` was
|
||||
previously excluded from `std/prelude` for JS, as it could not be imported.
|
||||
|
||||
Compatibility notes:
|
||||
- Changed the behavior of `uri.decodeQuery` when there are unencoded `=`
|
||||
characters in the decoded values. Prior versions would raise an error. This is
|
||||
no longer the case to comply with the HTML spec and other languages'
|
||||
implementations. Old behavior can be obtained with
|
||||
`-d:nimLegacyParseQueryStrict`. `cgi.decodeData` which uses the same
|
||||
underlying code is also updated the same way.
|
||||
|
||||
|
||||
## JS stdlib changes
|
||||
|
||||
- Added `std/jsbigints` module, which provides arbitrary precision integers for the JS target.
|
||||
- Added `setCurrentException` for the JS backend.
|
||||
- `writeStackTrace` is available in the JS backend now.
|
||||
- Added `then`, `catch` to `std/asyncjs` for promise pipelining, for now hidden
|
||||
behind `-d:nimExperimentalAsyncjsThen`.
|
||||
- Added `std/jsfetch` module [Fetch](https://developer.mozilla.org/docs/Web/API/Fetch_API)
|
||||
wrapper for the JS target.
|
||||
- Added `std/jsheaders` module [Headers](https://developer.mozilla.org/en-US/docs/Web/API/Headers)
|
||||
wrapper for the JS target.
|
||||
- Added `std/jsformdata` module [FormData](https://developer.mozilla.org/en-US/docs/Web/API/FormData)
|
||||
wrapper for the JS target.
|
||||
- Added `jscore.debugger` to [call any available debugging functionality, such as breakpoints](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/debugger).
|
||||
- Added `jsconsole.dir`, `jsconsole.dirxml`, `jsconsole.timeStamp`.
|
||||
- Added dollar `$` and `len` for `jsre.RegExp`.
|
||||
- Added `jsconsole.jsAssert` for the JS target.
|
||||
- Added `**` to `std/jsffi`.
|
||||
- Added `copyWithin` [for `seq` and `array` for JS targets](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/copyWithin).
|
||||
- In `std/dom`, `Interval` is now a `ref object`, same as `Timeout`.
|
||||
Definitions of `setTimeout`, `clearTimeout`, `setInterval`, `clearInterval` were updated.
|
||||
- Added `dom.scrollIntoView` proc with options.
|
||||
- Added `dom.setInterval`, `dom.clearInterval` overloads.
|
||||
- Merged `std/dom_extensions` into the `std/dom` module,
|
||||
as it was a module with a single line, see RFC [#413](https://github.com/nim-lang/RFCs/issues/413).
|
||||
- `$` now gives more correct results on the JS backend.
|
||||
|
||||
|
||||
## JS compiler changes
|
||||
|
||||
- `cstring` doesn't support the `[]=` operator anymore in the JS backend.
|
||||
- Array literals now use JS typed arrays when the corresponding JS typed array exists,
|
||||
for example `[byte(1), 2, 3]` generates `new Uint8Array([1, 2, 3])`.
|
||||
|
||||
|
||||
## VM and nimscript backend
|
||||
|
||||
- VM now supports `addr(mystring[ind])` (index + index assignment).
|
||||
- `nimscript` now handles `except Exception as e`.
|
||||
- `nil` dereference is not allowed at compile time. `cast[ptr int](nil)[]` is rejected at compile time.
|
||||
- `static[T]` now works better, refs [#17590](https://github.com/nim-lang/Nim/pull/17590),
|
||||
[#15853](https://github.com/nim-lang/Nim/pull/15853).
|
||||
- `distinct T` conversions now work in VM.
|
||||
- `items(cstring)` now works in VM.
|
||||
- Fix `addr`, `len`, `high` in VM ([#16002](https://github.com/nim-lang/Nim/pull/16002),
|
||||
[#16610](https://github.com/nim-lang/Nim/pull/16610)).
|
||||
- `std/cstrutils` now works in VM.
|
||||
|
||||
|
||||
## OS/platform-specific notes
|
||||
|
||||
- Support for Apple silicon/M1.
|
||||
- Support for 32-bit RISC-V, refs [#16231](https://github.com/nim-lang/Nim/pull/16231).
|
||||
- Support for armv8l, refs [#18901](https://github.com/nim-lang/Nim/pull/18901).
|
||||
- Support for CROSSOS, refs [#18889](https://github.com/nim-lang/Nim/pull/18889).
|
||||
- The allocator for Nintendo Switch, which was nonfunctional because
|
||||
of breaking changes in libnx, was removed, in favor of the new `-d:nimAllocPagesViaMalloc` option.
|
||||
- Allow reading parameters when compiling for Nintendo Switch.
|
||||
- `--nimcache` now correctly works in a cross-compilation setting.
|
||||
- Cross compilation targeting Windows was improved.
|
||||
- This now works from macOS/Linux: `nim r -d:mingw main`
|
||||
|
||||
|
||||
|
||||
## Performance / memory optimizations
|
||||
|
||||
- The comment field in PNode AST was moved to a side channel, reducing overall
|
||||
memory usage during compilation by a factor 1.25x
|
||||
- `std/jsonutils` deserialization is now up to 20x faster.
|
||||
- `os.copyFile` is now 2.5x faster on macOS, by using `copyfile` from `copyfile.h`;
|
||||
use `-d:nimLegacyCopyFile` for macOS < 10.5.
|
||||
- Float to string conversion is now 10x faster thanks to the Dragonbox algorithm,
|
||||
with `-d:nimPreviewFloatRoundtrip`.
|
||||
- `newSeqWith` is 3x faster.
|
||||
- CI now supports batching (making Windows CI 2.3X faster).
|
||||
- Sets now uses the optimized `countSetBits` proc, see PR
|
||||
[#17334](https://github.com/nim-lang/Nim/pull/17334).
|
||||
|
||||
|
||||
## Debugging
|
||||
|
||||
- You can now enable/disable VM tracing in user code via `vmutils.vmTrace`.
|
||||
- `koch tools` now builds `bin/nim_dbg` which allows easy access to a debug version
|
||||
of Nim without recompiling.
|
||||
- Added new module `compiler/debugutils` to help with debugging Nim compiler.
|
||||
- Renamed `-d:nimCompilerStackraceHints` to `-d:nimCompilerStacktraceHints` and
|
||||
used it in more contexts; this flag which works in tandem with `--stackTraceMsgs`
|
||||
to show user code context in compiler stacktraces.
|
||||
|
||||
|
||||
## Type system
|
||||
|
||||
- `typeof(voidStmt)` now works and returns `void`.
|
||||
- `enum` values can now be overloaded. This needs to be enabled
|
||||
via `{.experimental: "overloadableEnums".}`. We hope that this feature allows
|
||||
for the development of more fluent (less ugly) APIs.
|
||||
See RFC [#373](https://github.com/nim-lang/RFCs/issues/373) for more details.
|
||||
- A type conversion from one `enum` type to another now produces an `[EnumConv]` warning.
|
||||
You should use `ord` (or `cast`, but the compiler won't help, if you misuse it) instead.
|
||||
```nim
|
||||
type A = enum a1, a2
|
||||
type B = enum b1, b2
|
||||
echo a1.B # produces a warning
|
||||
echo a1.ord.B # produces no warning
|
||||
```
|
||||
- A dangerous implicit conversion to `cstring` now triggers a `[CStringConv]` warning.
|
||||
This warning will become an error in future versions! Use an explicit conversion
|
||||
like `cstring(x)` in order to silence the warning.
|
||||
- There is a new warning for *any* type conversion to `enum` that can be enabled via
|
||||
`.warning[AnyEnumConv]:on` or `--warning:AnyEnumConv:on`.
|
||||
- Reusing a type name in a different scope now works, refs [#17710](https://github.com/nim-lang/Nim/pull/17710).
|
||||
- Fixed implicit and explicit generics in procedures, refs [#18808](https://github.com/nim-lang/Nim/pull/18808).
|
||||
|
||||
|
||||
## New-style concepts
|
||||
|
||||
Example:
|
||||
```nim
|
||||
type
|
||||
Comparable = concept # no T, an atom
|
||||
proc cmp(a, b: Self): int
|
||||
```
|
||||
The new design does not rely on `system.compiles` and may compile faster.
|
||||
See PR [#15251](https://github.com/nim-lang/Nim/pull/15251)
|
||||
and RFC [#168](https://github.com/nim-lang/RFCs/issues/168) for details.
|
||||
|
||||
|
||||
## Lexical / syntactic
|
||||
|
||||
- Nim now supports a small subset of Unicode operators as operator symbols.
|
||||
The supported symbols are: "∙ ∘ × ★ ⊗ ⊘ ⊙ ⊛ ⊠ ⊡ ∩ ∧ ⊓ ± ⊕ ⊖ ⊞ ⊟ ∪ ∨ ⊔".
|
||||
To enable this feature, use `--experimental:unicodeOperators`. Note that due
|
||||
to parser limitations you **cannot** enable this feature via a
|
||||
pragma `{.experimental: "unicodeOperators".}` reliably, you need to enable
|
||||
it via the command line or in a configuration file.
|
||||
- `var a {.foo.} = expr` now works inside templates (except when `foo` is overloaded).
|
||||
|
||||
|
||||
## Compiler messages, error messages, hints, warnings
|
||||
|
||||
- Significant improvement to error messages involving effect mismatches,
|
||||
see PRs [#18384](https://github.com/nim-lang/Nim/pull/18384),
|
||||
[#18418](https://github.com/nim-lang/Nim/pull/18418).
|
||||
- Added `--declaredLocs` to show symbol declaration location in error messages.
|
||||
- Added `--spellSuggest` to show spelling suggestions on typos.
|
||||
- Added `--processing:dots|filenames|off` which customizes `hintProcessing`;
|
||||
`--processing:filenames` shows which include/import modules are being compiled as an import stack.
|
||||
- `FieldDefect` messages now shows discriminant value + lineinfo, in all backends (C, JS, VM)
|
||||
- Added `--hintAsError` with similar semantics as `--warningAsError`.
|
||||
- Added `--unitsep:on|off` to control whether to add ASCII unit separator `\31`
|
||||
before a newline for every generated message (potentially multiline),
|
||||
so tooling can tell when messages start and end.
|
||||
- Added `--filenames:abs|canonical|legacyRelProj` which replaces `--listFullPaths:on|off`
|
||||
- `--hint:all:on|off` is now supported to select or deselect all hints; it
|
||||
differs from `--hints:on|off` which acts as a (reversible) gate.
|
||||
Likewise with `--warning:all:on|off`.
|
||||
- The style checking of the compiler now supports a `--styleCheck:usages` switch.
|
||||
This switch enforces that every symbol is written as it was declared, not enforcing
|
||||
the official Nim style guide. To be enabled, this has to be combined either
|
||||
with `--styleCheck:error` or `--styleCheck:hint`.
|
||||
- Type mismatch errors now show more context, use `-d:nimLegacyTypeMismatch` for
|
||||
previous behavior.
|
||||
- `typedesc[Foo]` now renders as such instead of `type Foo` in compiler messages.
|
||||
- `runnableExamples` now show originating location in stacktraces on failure.
|
||||
- `SuccessX` message now shows more useful information.
|
||||
- New `DuplicateModuleImport` warning; improved `UnusedImport` and
|
||||
`XDeclaredButNotUsed` accuracy.
|
||||
|
||||
Compatibility notes:
|
||||
- `--hint:CC` now prints to stderr (like all other hints) instead of stdout.
|
||||
|
||||
|
||||
## Building and running Nim programs, configuration system
|
||||
|
||||
- JSON build instructions are now generated in `$nimcache/outFileBasename.json`
|
||||
instead of `$nimcache/projectName.json`. This allows avoiding recompiling a
|
||||
given project compiled with different options if the output file differs.
|
||||
- `--usenimcache` (implied by `nim r main`) now generates an output file that includes
|
||||
a hash of some of the compilation options, which allows caching generated binaries:
|
||||
```bash
|
||||
nim r main # recompiles
|
||||
nim r -d:foo main # recompiles
|
||||
nim r main # uses cached binary
|
||||
nim r main arg1 arg2 # likewise (runtime arguments are irrelevant)
|
||||
```
|
||||
- `nim r` now supports cross compilation from unix to windows when specifying
|
||||
`-d:mingw` by using Wine, e.g.:
|
||||
`nim r --eval:'import os; echo "a" / "b"'` prints `a\b`.
|
||||
- `nim` can compile version 1.4.0 as follows:
|
||||
`nim c --lib:lib --stylecheck:off -d:nimVersion140 compiler/nim`.
|
||||
`-d:nimVersion140` is not needed for bootstrapping, only for building 1.4.0 from devel.
|
||||
- `nim e` now accepts arbitrary file extensions for the nimscript file,
|
||||
although `.nims` is still the preferred extension in general.
|
||||
- The configuration subsystem now allows for `-d:release` and `-d:danger` to work as expected.
|
||||
The downside is that these defines now have custom logic that doesn't apply for
|
||||
other defines.
|
||||
|
||||
|
||||
## Multithreading
|
||||
|
||||
- TLS: macOS now uses native TLS (`--tlsEmulation:off`). TLS now works with
|
||||
`importcpp` non-POD types; such types must use `.cppNonPod` and
|
||||
`--tlsEmulation:off`should be used.
|
||||
- Added `unsafeIsolate` and `extract` to `std/isolation`.
|
||||
- Added `std/tasks`, see description above.
|
||||
|
||||
|
||||
## Memory management
|
||||
|
||||
- `--gc:arc` now bootstraps (PR [#17342](https://github.com/nim-lang/Nim/pull/17342)).
|
||||
- Lots of improvements to `gc:arc`, `gc:orc`, see PR
|
||||
[#15697](https://github.com/nim-lang/Nim/pull/15697),
|
||||
[#16849](https://github.com/nim-lang/Nim/pull/16849),
|
||||
[#17993](https://github.com/nim-lang/Nim/pull/17993).
|
||||
- `--gc:orc` is now 10% faster than previously for common workloads.
|
||||
If you have trouble with its changed behavior, compile with `-d:nimOldOrc`.
|
||||
- The `--gc:orc` algorithm was refined so that custom container types can participate in the
|
||||
cycle collection process. See the documentation of `=trace` for more details.
|
||||
- On embedded devices `malloc` can now be used instead of `mmap` via `-d:nimAllocPagesViaMalloc`.
|
||||
This is only supported for `--gc:orc` or `--gc:arc`.
|
||||
|
||||
Compatibility notes:
|
||||
- `--newruntime` and `--refchecks` are deprecated,
|
||||
use `--gc:arc`, `--gc:orc`, or `--gc:none` as appropriate instead.
|
||||
|
||||
|
||||
## Docgen
|
||||
|
||||
- docgen: RST files can now use single backticks instead of double backticks and
|
||||
correctly render in both `nim rst2html` (as before) as well as common tools rendering
|
||||
RST directly (e.g. GitHub).
|
||||
This is done by adding the `default-role:: code` directive inside the RST file
|
||||
(which is now handled by `nim rst2html`).
|
||||
- Source+Edit links now appear on top of every docgen'd page when
|
||||
`nim doc --git.url:url ...` is given.
|
||||
- Latex doc generation is revised: output `.tex` files should be compiled
|
||||
by `xelatex` (not by `pdflatex` as before). Now default Latex settings
|
||||
provide support for Unicode and better avoid margin overflows.
|
||||
The minimum required version is TeXLive 2018 (or an equivalent MikTeX version).
|
||||
- The RST parser now supports footnotes, citations, admonitions, and short style
|
||||
references with symbols.
|
||||
- The RST parser now supports Markdown table syntax.
|
||||
Known limitations:
|
||||
- cell alignment is not supported, i.e. alignment annotations in a delimiter
|
||||
row (`:---`, `:--:`, `---:`) are ignored
|
||||
- every table row must start with `|`, e.g. `| cell 1 | cell 2 |`.
|
||||
- Implemented `doc2tex` compiler command which converts documentation in
|
||||
`.nim` files to Latex.
|
||||
- docgen now supports syntax highlighting for inline code.
|
||||
- docgen now supports same-line doc comments:
|
||||
```nim
|
||||
func fn*(a: int): int = 42 ## Doc comment
|
||||
```
|
||||
- docgen now renders `deprecated` and other pragmas.
|
||||
- `runnableExamples` now works with templates and nested templates.
|
||||
- `runnableExamples: "-r:off"` now works for examples that should compile but not run.
|
||||
- `runnableExamples` now renders code verbatim, and produces correct code in all cases.
|
||||
- docgen now shows correct, canonical import paths in docs.
|
||||
- docgen now shows all routines in sidebar, and the proc signature is now shown in sidebar.
|
||||
|
||||
|
||||
## Effects and checks
|
||||
|
||||
- Significant improvement to error messages involving effect mismatches
|
||||
- There is a new `cast` section `{.cast(uncheckedAssign).}: body` that disables some
|
||||
compiler checks regarding `case objects`. This allows serialization libraries
|
||||
to avoid ugly, non-portable solutions. See RFC
|
||||
[#407](https://github.com/nim-lang/RFCs/issues/407) for more details.
|
||||
|
||||
Compatibility notes:
|
||||
- Fixed effect tracking for borrowed procs (see [#18882](https://github.com/nim-lang/Nim/pull/18882)).
|
||||
One consequence is that, under some circumstances, Nim could previously permit a procedure with side effects to be written with `func` - you may need to change some occurrences of `func` to `proc`.
|
||||
To illustrate, Nim versions before 1.6.0 compile the below without error
|
||||
```nim
|
||||
proc print(s: string) =
|
||||
echo s
|
||||
|
||||
type
|
||||
MyString = distinct string
|
||||
|
||||
proc print(s: MyString) {.borrow.}
|
||||
|
||||
func foo(s: MyString) =
|
||||
print(s)
|
||||
```
|
||||
but Nim 1.6.0 produces the error
|
||||
```
|
||||
Error: 'foo' can have side effects
|
||||
```
|
||||
similar to how we expect that
|
||||
```nim
|
||||
func print(s: string) =
|
||||
echo s
|
||||
```
|
||||
produces
|
||||
```
|
||||
Error: 'print' can have side effects
|
||||
```
|
||||
|
||||
|
||||
## Tools
|
||||
|
||||
- Major improvements to `nimgrep`, see PR [#15612
|
||||
](https://github.com/nim-lang/Nim/pull/15612).
|
||||
- `fusion` is now un-bundled from Nim, `./koch fusion` will
|
||||
install it via Nimble at a fixed hash.
|
||||
- `testament`: added `nimoutFull: bool` spec to compare full output of compiler
|
||||
instead of a subset; many bugfixes to testament.
|
||||
|
||||
|
||||
## Misc/cleanups
|
||||
|
||||
- Deprecated `TaintedString` and `--taintmode`.
|
||||
- Deprecated `--nilseqs` which is now a noop.
|
||||
- Added `-d:nimStrictMode` in CI in several places to ensure code doesn't have
|
||||
certain hints/warnings.
|
||||
- Removed `.travis.yml`, `appveyor.yml.disabled`, `.github/workflows/ci.yml.disabled`.
|
||||
- `[skip ci]` now works in azure and CI pipelines, see detail in PR
|
||||
[#17561](https://github.com/nim-lang/Nim/pull/17561).
|
||||
|
|
@ -1,367 +0,0 @@
|
|||
# v2.0.0 - yyyy-mm-dd
|
||||
|
||||
|
||||
## Changes affecting backward compatibility
|
||||
- `httpclient.contentLength` default to `-1` if the Content-Length header is not set in the response. It follows Apache HttpClient(Java), http(go) and .Net HttpWebResponse(C#) behavior. Previously it raised `ValueError`.
|
||||
|
||||
- `addr` is now available for all addressable locations,
|
||||
`unsafeAddr` is now deprecated and an alias for `addr`.
|
||||
|
||||
- Certain definitions from the default `system` module have been moved to
|
||||
the following new modules:
|
||||
|
||||
- `std/syncio`
|
||||
- `std/assertions`
|
||||
- `std/formatfloat`
|
||||
- `std/objectdollar`
|
||||
- `std/widestrs`
|
||||
- `std/typedthreads`
|
||||
- `std/sysatomics`
|
||||
|
||||
In the future, these definitions will be removed from the `system` module,
|
||||
and their respective modules will have to be imported to use them.
|
||||
Currently, to make these imports required, the `-d:nimPreviewSlimSystem` option
|
||||
may be used.
|
||||
|
||||
- Enabling `-d:nimPreviewSlimSystem` also removes the following deprecated
|
||||
symbols in the `system` module:
|
||||
- Aliases with `Error` suffix to exception types that have a `Defect` suffix
|
||||
(see [exceptions](https://nim-lang.github.io/Nim/exceptions.html)):
|
||||
`ArithmeticError`, `DivByZeroError`, `OverflowError`,
|
||||
`AccessViolationError`, `AssertionError`, `OutOfMemError`, `IndexError`,
|
||||
`FieldError`, `RangeError`, `StackOverflowError`, `ReraiseError`,
|
||||
`ObjectAssignmentError`, `ObjectConversionError`, `FloatingPointError`,
|
||||
`FloatOverflowError`, `FloatUnderflowError`, `FloatInexactError`,
|
||||
`DeadThreadError`, `NilAccessError`
|
||||
- `addQuitProc`, replaced by `exitprocs.addExitProc`
|
||||
- Legacy unsigned conversion operations: `ze`, `ze64`, `toU8`, `toU16`, `toU32`
|
||||
- `TaintedString`, formerly a distinct alias to `string`
|
||||
- `PInt32`, `PInt64`, `PFloat32`, `PFloat64`, aliases to
|
||||
`ptr int32`, `ptr int64`, `ptr float32`, `ptr float64`
|
||||
|
||||
- Enabling `-d:nimPreviewSlimSystem` removes the import of `channels_builtin` in
|
||||
in the `system` module.
|
||||
|
||||
- Enabling `-d:nimPreviewCstringConversion`, `ptr char`, `ptr array[N, char]` and `ptr UncheckedArray[N, char]` don't support conversion to cstring anymore.
|
||||
|
||||
- The `gc:v2` option is removed.
|
||||
|
||||
- The `mainmodule` and `m` options are removed.
|
||||
|
||||
- The `threads:on` option is now the default.
|
||||
|
||||
- Optional parameters in combination with `: body` syntax (RFC #405) are now opt-in via
|
||||
`experimental:flexibleOptionalParams`.
|
||||
|
||||
- Automatic dereferencing (experimental feature) is removed.
|
||||
|
||||
- The `Math.trunc` polyfill for targeting Internet Explorer was
|
||||
previously included in most JavaScript output files.
|
||||
Now, it is only included with `-d:nimJsMathTruncPolyfill`.
|
||||
If you are targeting Internet Explorer, you may choose to enable this option
|
||||
or define your own `Math.trunc` polyfill using the [`emit` pragma](https://nim-lang.org/docs/manual.html#implementation-specific-pragmas-emit-pragma).
|
||||
Nim uses `Math.trunc` for the division and modulo operators for integers.
|
||||
|
||||
- `shallowCopy` and `shallow` are removed for ARC/ORC. Use `move` when possible or combine assignment and
|
||||
`sink` for optimization purposes.
|
||||
|
||||
- The experimental `nimPreviewDotLikeOps` switch is going to be removed or deprecated because it didn't fullfill its promises.
|
||||
|
||||
- The `{.this.}` pragma, deprecated since 0.19, has been removed.
|
||||
- `nil` literals can no longer be directly assigned to variables or fields of `distinct` pointer types. They must be converted instead.
|
||||
```nim
|
||||
type Foo = distinct ptr int
|
||||
|
||||
# Before:
|
||||
var x: Foo = nil
|
||||
# After:
|
||||
var x: Foo = Foo(nil)
|
||||
```
|
||||
- Removed two type pragma syntaxes deprecated since 0.20, namely
|
||||
`type Foo = object {.final.}`, and `type Foo {.final.} [T] = object`.
|
||||
|
||||
- `foo a = b` now means `foo(a = b)` rather than `foo(a) = b`. This is consistent
|
||||
with the existing behavior of `foo a, b = c` meaning `foo(a, b = c)`.
|
||||
This decision was made with the assumption that the old syntax was used rarely;
|
||||
if your code used the old syntax, please be aware of this change.
|
||||
|
||||
- [Overloadable enums](https://nim-lang.github.io/Nim/manual.html#overloadable-enum-value-names) and Unicode Operators
|
||||
are no longer experimental.
|
||||
|
||||
- Removed the `nimIncrSeqV3` define.
|
||||
|
||||
- `macros.getImpl` for `const` symbols now returns the full definition node
|
||||
(as `nnkConstDef`) rather than the AST of the constant value.
|
||||
|
||||
- Lock levels are deprecated, now a noop.
|
||||
|
||||
- ORC is now the default memory management strategy. Use
|
||||
`--mm:refc` for a transition period.
|
||||
|
||||
- `strictEffects` are no longer experimental.
|
||||
Use `legacy:laxEffects` to keep backward compatibility.
|
||||
|
||||
- The `gorge`/`staticExec` calls will now return a descriptive message in the output
|
||||
if the execution fails for whatever reason. To get back legacy behaviour use `-d:nimLegacyGorgeErrors`.
|
||||
|
||||
- Pointer to `cstring` conversion now triggers a `[PtrToCstringConv]` warning.
|
||||
This warning will become an error in future versions! Use a `cast` operation
|
||||
like `cast[cstring](x)` instead.
|
||||
|
||||
- `logging` will default to flushing all log level messages. To get the legacy behaviour of only flushing Error and Fatal messages, use `-d:nimV1LogFlushBehavior`.
|
||||
|
||||
- Redefining templates with the same signature was previously
|
||||
allowed to support certain macro code. To do this explicitly, the
|
||||
`{.redefine.}` pragma has been added. Note that this is only for templates.
|
||||
Implicit redefinition of templates is now deprecated and will give an error in the future.
|
||||
|
||||
- Using an unnamed break in a block is deprecated. This warning will become an error in future versions! Use a named block with a named break instead.
|
||||
|
||||
- Several Standard libraries are moved to nimble packages, use `nimble` to install them:
|
||||
- `std/punycode` => `punycode`
|
||||
- `std/asyncftpclient` => `asyncftpclient`
|
||||
- `std/smtp` => `smtp`
|
||||
- `std/db_common` => `db_connector/db_common`
|
||||
- `std/db_sqlite` => `db_connector/db_sqlite`
|
||||
- `std/db_mysql` => `db_connector/db_mysql`
|
||||
- `std/db_postgres` => `db_connector/db_postgres`
|
||||
- `std/db_odbc` => `db_connector/db_odbc`
|
||||
|
||||
- Previously, calls like `foo(a, b): ...` or `foo(a, b) do: ...` where the final argument of
|
||||
`foo` had type `proc ()` were assumed by the compiler to mean `foo(a, b, proc () = ...)`.
|
||||
This behavior is now deprecated. Use `foo(a, b) do (): ...` or `foo(a, b, proc () = ...)` instead.
|
||||
|
||||
- If no exception or any exception deriving from Exception but not Defect or CatchableError given in except, a `warnBareExcept` warning will be triggered.
|
||||
|
||||
- The experimental strictFuncs feature now disallows a store to the heap via a `ref` or `ptr` indirection.
|
||||
|
||||
- Underscores (`_`) as routine parameters are now ignored and cannot be used in the routine body.
|
||||
The following code now does not compile:
|
||||
|
||||
```nim
|
||||
proc foo(_: int): int = _ + 1
|
||||
echo foo(1)
|
||||
```
|
||||
|
||||
Instead, the following code now compiles:
|
||||
|
||||
```nim
|
||||
proc foo(_, _: int): int = 123
|
||||
echo foo(1, 2)
|
||||
```
|
||||
- Underscores (`_`) as generic parameters are not supported and cannot be used.
|
||||
Generics that use `_` as parameters will no longer compile requires you to replace `_` with something else:
|
||||
|
||||
```nim
|
||||
proc foo[_](t: typedesc[_]): string = "BAR" # Can not compile
|
||||
proc foo[T](t: typedesc[T]): string = "BAR" # Can compile
|
||||
```
|
||||
|
||||
- - Added the `--legacy:verboseTypeMismatch` switch to get legacy type mismatch error messages.
|
||||
|
||||
## Standard library additions and changes
|
||||
|
||||
[//]: # "Changes:"
|
||||
- OpenSSL 3 is now supported.
|
||||
- `macros.parseExpr` and `macros.parseStmt` now accept an optional
|
||||
filename argument for more informative errors.
|
||||
- Module `colors` expanded with missing colors from the CSS color standard.
|
||||
`colPaleVioletRed` and `colMediumPurple` have also been changed to match the CSS color standard.
|
||||
- Fixed `lists.SinglyLinkedList` being broken after removing the last node ([#19353](https://github.com/nim-lang/Nim/pull/19353)).
|
||||
- The `md5` module now works at compile time and in JavaScript.
|
||||
- Changed `mimedb` to use an `OrderedTable` instead of `OrderedTableRef` to support `const` tables.
|
||||
- `strutils.find` now uses and defaults to `last = -1` for whole string searches,
|
||||
making limiting it to just the first char (`last = 0`) valid.
|
||||
- `random.rand` now works with `Ordinal`s.
|
||||
- Undeprecated `os.isvalidfilename`.
|
||||
- `std/oids` now uses `int64` to store time internally (before it was int32).
|
||||
- `std/uri.Uri` dollar `$` improved, precalculates the `string` result length from the `Uri`.
|
||||
- `std/uri.Uri.isIpv6` is now exported.
|
||||
- `std/logging.ConsoleLogger` and `FileLogger` now have a `flushThreshold` attribute to set what log message levels are automatically flushed. For Nim v1 use `-d:nimFlushAllLogs` to automatically flush all message levels. Flushing all logs is the default behavior for Nim v2.
|
||||
|
||||
|
||||
- `std/net.IpAddress` dollar `$` improved, uses a fixed capacity for the `string` result based from the `IpAddressFamily`.
|
||||
- `std/jsfetch.newFetchOptions` now has default values for all parameters
|
||||
- `std/jsformdata` now accepts `Blob` data type.
|
||||
|
||||
- `std/sharedlist` and `std/sharedtables` are now deprecated, see RFC [#433](https://github.com/nim-lang/RFCs/issues/433).
|
||||
|
||||
- New compile flag (`-d:nimNoGetRandom`) when building `std/sysrand` to remove dependency on linux `getrandom` syscall.
|
||||
|
||||
This compile flag only affects linux builds and is necessary if either compiling on a linux kernel version < 3.17, or if code built will be executing on kernel < 3.17.
|
||||
|
||||
On linux kernels < 3.17 (such as kernel 3.10 in RHEL7 and CentOS7), the `getrandom` syscall was not yet introduced. Without this, the `std/sysrand` module will not build properly, and if code is built on a kernel >= 3.17 without the flag, any usage of the `std/sysrand` module will fail to execute on a kernel < 3.17 (since it attempts to perform a syscall to `getrandom`, which isn't present in the current kernel). A compile flag has been added to force the `std/sysrand` module to use /dev/urandom (available since linux kernel 1.3.30), rather than the `getrandom` syscall. This allows for use of a cryptographically secure PRNG, regardless of kernel support for the `getrandom` syscall.
|
||||
|
||||
When building for RHEL7/CentOS7 for example, the entire build process for nim from a source package would then be:
|
||||
```sh
|
||||
$ yum install devtoolset-8 # Install GCC version 8 vs the standard 4.8.5 on RHEL7/CentOS7. Alternatively use -d:nimEmulateOverflowChecks. See issue #13692 for details
|
||||
$ scl enable devtoolset-8 bash # Run bash shell with default toolchain of gcc 8
|
||||
$ sh build.sh # per unix install instructions
|
||||
$ bin/nim c koch # per unix install instructions
|
||||
$ ./koch boot -d:release # per unix install instructions
|
||||
$ ./koch tools -d:nimNoGetRandom # pass the nimNoGetRandom flag to compile std/sysrand without support for getrandom syscall
|
||||
```
|
||||
|
||||
This is necessary to pass when building nim on kernel versions < 3.17 in particular to avoid an error of "SYS_getrandom undeclared" during the build process for stdlib (sysrand in particular).
|
||||
|
||||
[//]: # "Additions:"
|
||||
- Added ISO 8601 week date utilities in `times`:
|
||||
- Added `IsoWeekRange`, a range type for weeks in a week-based year.
|
||||
- Added `IsoYear`, a distinct type for a week-based year in contrast to a regular year.
|
||||
- Added a `initDateTime` overload to create a datetime from an ISO week date.
|
||||
- Added `getIsoWeekAndYear` to get an ISO week number and week-based year from a datetime.
|
||||
- Added `getIsoWeeksInYear` to return the number of weeks in a week-based year.
|
||||
- Added new modules which were part of `std/os`:
|
||||
- Added `std/oserrors` for OS error reporting. Added `std/envvars` for environment variables handling.
|
||||
- Added `std/paths`, `std/dirs`, `std/files`, `std/symlinks` and `std/appdirs`.
|
||||
- Added `std/cmdline` for reading command line parameters.
|
||||
- Added `sep` parameter in `std/uri` to specify the query separator.
|
||||
- Added bindings to [`Array.shift`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/shift)
|
||||
and [`queueMicrotask`](https://developer.mozilla.org/en-US/docs/Web/API/queueMicrotask)
|
||||
in `jscore` for JavaScript targets.
|
||||
- Added `UppercaseLetters`, `LowercaseLetters`, `PunctuationChars`, `PrintableChars` sets to `std/strutils`.
|
||||
- Added `complex.sgn` for obtaining the phase of complex numbers.
|
||||
- Added `insertAdjacentText`, `insertAdjacentElement`, `insertAdjacentHTML`,
|
||||
`after`, `before`, `closest`, `append`, `hasAttributeNS`, `removeAttributeNS`,
|
||||
`hasPointerCapture`, `releasePointerCapture`, `requestPointerLock`,
|
||||
`replaceChildren`, `replaceWith`, `scrollIntoViewIfNeeded`, `setHTML`,
|
||||
`toggleAttribute`, and `matches` to `std/dom`.
|
||||
- Added [`jsre.hasIndices`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp/hasIndices)
|
||||
- Added `capacity` for `string` and `seq` to return the current capacity, see https://github.com/nim-lang/RFCs/issues/460
|
||||
- Added `openArray[char]` overloads for `std/parseutils` allowing more code reuse.
|
||||
- Added `openArray[char]` overloads for `std/unicode` allowing more code reuse.
|
||||
- Added `safe` parameter to `base64.encodeMime`.
|
||||
|
||||
[//]: # "Deprecations:"
|
||||
- Deprecated `selfExe` for Nimscript.
|
||||
- Deprecated `std/sums`.
|
||||
- Deprecated `std/base64.encode` for collections of arbitrary integer element type.
|
||||
Now only `byte` and `char` are supported.
|
||||
|
||||
[//]: # "Removals:"
|
||||
- Removed deprecated module `parseopt2`.
|
||||
- Removed deprecated module `sharedstrings`.
|
||||
- Removed deprecated module `dom_extensions`.
|
||||
- Removed deprecated module `LockFreeHash`.
|
||||
- Removed deprecated module `events`.
|
||||
- Removed deprecated `oids.oidToString`.
|
||||
- Removed define `nimExperimentalAsyncjsThen` for `std/asyncjs.then` and `std/jsfetch`.
|
||||
- Removed deprecated `jsre.test` and `jsre.toString`.
|
||||
- Removed deprecated `math.c_frexp`.
|
||||
- Removed deprecated `` httpcore.`==` ``.
|
||||
- Removed deprecated `std/posix.CMSG_SPACE` and `std/posix.CMSG_LEN` that takes wrong argument types.
|
||||
- Removed deprecated `osproc.poDemon`, symbol with typo.
|
||||
- Removed deprecated `tables.rightSize`.
|
||||
|
||||
|
||||
- Removed deprecated `posix.CLONE_STOPPED`.
|
||||
|
||||
|
||||
## Language changes
|
||||
|
||||
- [Tag tracking](https://nim-lang.github.io/Nim/manual.html#effect-system-tag-tracking) supports the definition of forbidden tags by the `.forbids` pragma
|
||||
which can be used to disable certain effects in proc types.
|
||||
- [Case statement macros](https://nim-lang.github.io/Nim/manual.html#macros-case-statement-macros) are no longer experimental,
|
||||
meaning you no longer need to enable the experimental switch `caseStmtMacros` to use them.
|
||||
- Full command syntax and block arguments i.e. `foo a, b: c` are now allowed
|
||||
for the right-hand side of type definitions in type sections. Previously
|
||||
they would error with "invalid indentation".
|
||||
|
||||
- Compile-time define changes:
|
||||
- `defined` now accepts identifiers separated by dots, i.e. `defined(a.b.c)`.
|
||||
In the command line, this is defined as `-d:a.b.c`. Older versions can
|
||||
use accents as in ``defined(`a.b.c`)`` to access such defines.
|
||||
- [Define pragmas for constants](https://nim-lang.github.io/Nim/manual.html#implementation-specific-pragmas-compileminustime-define-pragmas)
|
||||
now support a string argument for qualified define names.
|
||||
|
||||
```nim
|
||||
# -d:package.FooBar=42
|
||||
const FooBar {.intdefine: "package.FooBar".}: int = 5
|
||||
echo FooBar # 42
|
||||
```
|
||||
|
||||
This was added to help disambiguate similar define names for different packages.
|
||||
In older versions, this could only be achieved with something like the following:
|
||||
|
||||
```nim
|
||||
const FooBar = block:
|
||||
const `package.FooBar` {.intdefine.}: int = 5
|
||||
`package.FooBar`
|
||||
```
|
||||
- A generic `define` pragma for constants has been added that interprets
|
||||
the value of the define based on the type of the constant value.
|
||||
See the [experimental manual](https://nim-lang.github.io/Nim/manual_experimental.html#generic-define-pragma)
|
||||
for a list of supported types.
|
||||
|
||||
- [Macro pragmas](https://nim-lang.github.io/Nim/manual.html#userminusdefined-pragmas-macro-pragmas) changes:
|
||||
- Templates now accept macro pragmas.
|
||||
- Macro pragmas for var/let/const sections have been redesigned in a way that works
|
||||
similarly to routine macro pragmas. The new behavior is documented in the
|
||||
[experimental manual](https://nim-lang.github.io/Nim/manual_experimental.html#extended-macro-pragmas).
|
||||
- Pragma macros on type definitions can now return `nnkTypeSection` nodes as well as `nnkTypeDef`,
|
||||
allowing multiple type definitions to be injected in place of the original type definition.
|
||||
|
||||
```nim
|
||||
import macros
|
||||
macro multiply(amount: static int, s: untyped): untyped =
|
||||
let name = $s[0].basename
|
||||
result = newNimNode(nnkTypeSection)
|
||||
for i in 1 .. amount:
|
||||
result.add(newTree(nnkTypeDef, ident(name & $i), s[1], s[2]))
|
||||
type
|
||||
Foo = object
|
||||
Bar {.multiply: 3.} = object
|
||||
x, y, z: int
|
||||
Baz = object
|
||||
# becomes
|
||||
type
|
||||
Foo = object
|
||||
Bar1 = object
|
||||
x, y, z: int
|
||||
Bar2 = object
|
||||
x, y, z: int
|
||||
Bar3 = object
|
||||
x, y, z: int
|
||||
Baz = object
|
||||
```
|
||||
|
||||
- A new form of type inference called [top-down inference](https://nim-lang.github.io/Nim/manual_experimental.html#topminusdown-type-inference)
|
||||
has been implemented for a variety of basic cases. For example, code like the following now compiles:
|
||||
|
||||
```nim
|
||||
let foo: seq[(float, byte, cstring)] = @[(1, 2, "abc")]
|
||||
```
|
||||
|
||||
- `cstring` is now accepted as a selector in `case` statements, removing the
|
||||
need to convert to `string`. On the JS backend, this is translated directly
|
||||
to a `switch` statement.
|
||||
|
||||
- Nim now supports `out` parameters and ["strict definitions"](https://nim-lang.github.io/Nim/manual_experimental.html#strict-definitions-and-nimout-parameters).
|
||||
- Nim now offers a [strict mode](https://nim-lang.github.io/Nim/manual_experimental.html#strict-case-objects) for `case objects`.
|
||||
|
||||
- IBM Z architecture and macOS m1 arm64 architecture are supported.
|
||||
|
||||
- `=wasMoved` can be overridden by users.
|
||||
|
||||
## Compiler changes
|
||||
|
||||
- The `gc` switch has been renamed to `mm` ("memory management") in order to reflect the
|
||||
reality better. (Nim moved away from all techniques based on "tracing".)
|
||||
|
||||
- Defines the `gcRefc` symbol which allows writing specific code for the refc GC.
|
||||
|
||||
- `nim` can now compile version 1.4.0 as follows: `nim c --lib:lib --stylecheck:off compiler/nim`,
|
||||
without requiring `-d:nimVersion140` which is now a noop.
|
||||
|
||||
- `--styleCheck`, `--hintAsError` and `--warningAsError` now only apply to the current package.
|
||||
|
||||
- The switch `--nimMainPrefix:prefix` has been added to add a prefix to the names of `NimMain` and
|
||||
related functions produced on the backend. This prevents conflicts with other Nim
|
||||
static libraries.
|
||||
|
||||
- When compiling for Release the flag `-fno-math-errno` is used for GCC.
|
||||
|
||||
|
||||
## Tool changes
|
||||
|
||||
- Nim now ships Nimble version 0.14 which added support for lock-files. Libraries are stored in `$nimbleDir/pkgs2` (it was `$nimbleDir/pkgs`).
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
# v1.xx.x - yyyy-mm-dd
|
||||
|
||||
This is an example file.
|
||||
The changes should go to changelog.md!
|
||||
|
||||
## Changes affecting backward compatibility
|
||||
|
||||
- `foo` now behaves differently, use `-d:nimLegacyFoo` for previous behavior.
|
||||
|
||||
## Standard library additions and changes
|
||||
|
||||
- Added `example.exampleProc`.
|
||||
|
||||
- Changed `example.foo` to take additional `bar` parameter.
|
||||
|
||||
## Language changes
|
||||
|
||||
|
||||
## Compiler changes
|
||||
|
||||
|
||||
## Tool changes
|
||||
|
||||
|
|
@ -1,61 +0,0 @@
|
|||
# Update changelog
|
||||
After each release, call:
|
||||
```
|
||||
git mv changelog.md changelogs/changelog_0_19_0.md # use correct version
|
||||
cp changelogs/changelog_X_XX_X.md changelog.md
|
||||
git add changelog.md
|
||||
```
|
||||
|
||||
## Recent changelogs are saved here (with their git history)
|
||||
|
||||
## Older changelogs are stored in https://github.com/nim-lang/website
|
||||
|
||||
## source files:
|
||||
* https://github.com/nim-lang/website/blob/master/jekyll/_posts/2009-12-21-version-086-released.md
|
||||
* https://github.com/nim-lang/website/blob/master/jekyll/_posts/2010-03-14-version-088-released.md
|
||||
* https://github.com/nim-lang/website/blob/master/jekyll/_posts/2010-10-20-version-0810-released.md
|
||||
* https://github.com/nim-lang/website/blob/master/jekyll/_posts/2011-07-10-version-0812-released.md
|
||||
* https://github.com/nim-lang/website/blob/master/jekyll/_posts/2012-02-09-version-0814-released.md
|
||||
* https://github.com/nim-lang/website/blob/master/jekyll/_posts/2012-09-23-version-090-released.md
|
||||
* https://github.com/nim-lang/website/blob/master/jekyll/_posts/2013-05-20-version-092-released.md
|
||||
* https://github.com/nim-lang/website/blob/master/jekyll/_posts/2014-04-21-version-094-released.md
|
||||
* https://github.com/nim-lang/website/blob/master/jekyll/_posts/2014-10-19-version-096-released.md
|
||||
* https://github.com/nim-lang/website/blob/master/jekyll/_posts/2014-12-29-version-0102-released.md
|
||||
* https://github.com/nim-lang/website/blob/master/jekyll/_posts/2015-04-30-version-0110-released.md
|
||||
* https://github.com/nim-lang/website/blob/master/jekyll/_posts/2015-05-04-version-0112-released.md
|
||||
* https://github.com/nim-lang/website/blob/master/jekyll/_posts/2015-10-27-version-0120-released.md
|
||||
* https://github.com/nim-lang/website/blob/master/jekyll/_posts/2016-01-18-version-0130-released.md
|
||||
* https://github.com/nim-lang/website/blob/master/jekyll/_posts/2016-06-07-version-0140-released.md
|
||||
* https://github.com/nim-lang/website/blob/master/jekyll/_posts/2016-06-09-version-0142-released.md
|
||||
* https://github.com/nim-lang/website/blob/master/jekyll/_posts/2016-09-30-version-0150-released.md
|
||||
* https://github.com/nim-lang/website/blob/master/jekyll/_posts/2016-10-23-version-0152-released.md
|
||||
* https://github.com/nim-lang/website/blob/master/jekyll/_posts/2017-01-08-version-0160-released.md
|
||||
* https://github.com/nim-lang/website/blob/master/jekyll/_posts/2017-05-17-version-0170-released.md
|
||||
* https://github.com/nim-lang/website/blob/master/jekyll/_posts/2017-09-07-version-0172-released.md
|
||||
* https://github.com/nim-lang/website/blob/master/jekyll/_posts/2018-03-01-version-0180-released.md
|
||||
* https://github.com/nim-lang/website/blob/master/jekyll/_posts/2018-09-26-version-0190-released.md
|
||||
|
||||
## urls:
|
||||
* https://nim-lang.org/blog/2009/12/21/version-086-released.html
|
||||
* https://nim-lang.org/blog/2010/03/14/version-088-released.html
|
||||
* https://nim-lang.org/blog/2010/10/20/version-0810-released.html
|
||||
* https://nim-lang.org/blog/2011/07/10/version-0812-released.html
|
||||
* https://nim-lang.org/blog/2012/02/09/version-0814-released.html
|
||||
* https://nim-lang.org/blog/2012/09/23/version-090-released.html
|
||||
* https://nim-lang.org/blog/2013/05/20/version-092-released.html
|
||||
* https://nim-lang.org/blog/2014/04/21/version-094-released.html
|
||||
* https://nim-lang.org/blog/2014/10/19/version-096-released.html
|
||||
* https://nim-lang.org/blog/2014/12/29/version-0102-released.html
|
||||
* https://nim-lang.org/blog/2015/04/30/version-0110-released.html
|
||||
* https://nim-lang.org/blog/2015/05/04/version-0112-released.html
|
||||
* https://nim-lang.org/blog/2015/10/27/version-0120-released.html
|
||||
* https://nim-lang.org/blog/2016/01/18/version-0130-released.html
|
||||
* https://nim-lang.org/blog/2016/06/07/version-0140-released.html
|
||||
* https://nim-lang.org/blog/2016/06/09/version-0142-released.html
|
||||
* https://nim-lang.org/blog/2016/09/30/version-0150-released.html
|
||||
* https://nim-lang.org/blog/2016/10/23/version-0152-released.html
|
||||
* https://nim-lang.org/blog/2017/01/08/version-0160-released.html
|
||||
* https://nim-lang.org/blog/2017/05/17/version-0170-released.html
|
||||
* https://nim-lang.org/blog/2017/09/07/version-0172-released.html
|
||||
* https://nim-lang.org/blog/2018/03/01/version-0180-released.html
|
||||
* https://nim-lang.org/blog/2018/09/26/version-0190-released.html
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
import std/[strutils, os, osproc, parseutils, strformat]
|
||||
|
||||
|
||||
proc main() =
|
||||
var msg = ""
|
||||
const cmd = "./koch boot --gc:orc -d:release"
|
||||
|
||||
let (output, exitCode) = execCmdEx(cmd)
|
||||
|
||||
doAssert exitCode == 0, output
|
||||
|
||||
let start = rfind(output, "Hint: mm")
|
||||
doAssert parseUntil(output, msg, "; proj", start) > 0, output
|
||||
|
||||
let (commitHash, _) = execCmdEx("""git log --format="%H" -n 1""")
|
||||
|
||||
let welcomeMessage = fmt"""Thanks for your hard work on this PR!
|
||||
The lines below are statistics of the Nim compiler built from {commitHash}
|
||||
|
||||
{msg}
|
||||
"""
|
||||
createDir "ci/nimcache"
|
||||
writeFile "ci/nimcache/results.txt", welcomeMessage
|
||||
|
||||
when isMainModule:
|
||||
main()
|
||||
|
|
@ -1,26 +0,0 @@
|
|||
@echo off
|
||||
rem DO NO EDIT DIRECTLY! auto-generated by `nim r tools/ci_generate.nim`
|
||||
rem Build development version of the compiler; can be rerun safely
|
||||
rem bare bones version of ci/funs.sh adapted for windows.
|
||||
|
||||
rem Read in some common shared variables (shared with other tools),
|
||||
rem see https://stackoverflow.com/questions/3068929/how-to-read-file-contents-into-a-variable-in-a-batch-file
|
||||
for /f "delims== tokens=1,2" %%G in (config/build_config.txt) do set %%G=%%H
|
||||
SET nim_csources=bin\nim_csources_%nim_csourcesHash%.exe
|
||||
echo "building from csources: %nim_csources%"
|
||||
|
||||
if not exist %nim_csourcesDir% (
|
||||
git clone -q --depth 1 -b %nim_csourcesBranch% %nim_csourcesUrl% %nim_csourcesDir%
|
||||
)
|
||||
|
||||
if not exist %nim_csources% (
|
||||
cd %nim_csourcesDir%
|
||||
git checkout %nim_csourcesHash%
|
||||
echo "%PROCESSOR_ARCHITECTURE%"
|
||||
if "%PROCESSOR_ARCHITECTURE%"=="AMD64" (
|
||||
SET ARCH=64
|
||||
)
|
||||
CALL build.bat
|
||||
cd ..
|
||||
copy /y bin\nim.exe %nim_csources%
|
||||
)
|
||||
143
ci/funs.sh
143
ci/funs.sh
|
|
@ -1,143 +0,0 @@
|
|||
# Utilities used in CI pipelines and tooling to avoid duplication.
|
||||
# Avoid top-level statements.
|
||||
# Prefer nim scripts whenever possible.
|
||||
# functions starting with `_` are considered internal, less stable.
|
||||
|
||||
echo_run () {
|
||||
# echo's a command before running it, which helps understanding logs
|
||||
echo ""
|
||||
echo "cmd: $@" # in azure we could also use this: echo '##[section]"$@"'
|
||||
"$@"
|
||||
}
|
||||
|
||||
nimGetLastCommit() {
|
||||
git log --no-merges -1 --pretty=format:"%s"
|
||||
}
|
||||
|
||||
nimIsCiSkip(){
|
||||
# D20210329T004830:here refs https://github.com/microsoft/azure-pipelines-agent/issues/2944
|
||||
# `--no-merges` is needed to avoid merge commits which occur for PR's.
|
||||
# $(Build.SourceVersionMessage) is not helpful
|
||||
# nor is `github.event.head_commit.message` for github actions.
|
||||
# Note: `[skip ci]` is now handled automatically for github actions, see https://github.blog/changelog/2021-02-08-github-actions-skip-pull-request-and-push-workflows-with-skip-ci/
|
||||
commitMsg=$(nimGetLastCommit)
|
||||
echo commitMsg: "$commitMsg"
|
||||
if [[ $commitMsg == *"[skip ci]"* ]]; then
|
||||
echo "skipci: true"
|
||||
return 0
|
||||
else
|
||||
echo "skipci: false"
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
nimInternalInstallDepsWindows(){
|
||||
echo_run mkdir dist
|
||||
echo_run curl -L https://nim-lang.org/download/mingw64.7z -o dist/mingw64.7z
|
||||
echo_run curl -L https://nim-lang.org/download/dlls.zip -o dist/dlls.zip
|
||||
echo_run 7z x dist/mingw64.7z -odist
|
||||
echo_run 7z x dist/dlls.zip -obin
|
||||
}
|
||||
|
||||
nimInternalBuildKochAndRunCI(){
|
||||
echo_run nim c koch
|
||||
if ! echo_run ./koch runCI; then
|
||||
echo_run echo "runCI failed"
|
||||
echo_run nim r tools/ci_testresults.nim
|
||||
return 1
|
||||
fi
|
||||
}
|
||||
|
||||
nimDefineVars(){
|
||||
. config/build_config.txt
|
||||
nim_csources=bin/nim_csources_$nim_csourcesHash
|
||||
}
|
||||
|
||||
_nimNumCpu(){
|
||||
# linux: $(nproc)
|
||||
# FreeBSD | macOS: $(sysctl -n hw.ncpu)
|
||||
# OpenBSD: $(sysctl -n hw.ncpuonline)
|
||||
# windows: $NUMBER_OF_PROCESSORS ?
|
||||
echo $(nproc 2>/dev/null || sysctl -n hw.logicalcpu 2>/dev/null || getconf _NPROCESSORS_ONLN 2>/dev/null || 1)
|
||||
}
|
||||
|
||||
_nimBuildCsourcesIfNeeded(){
|
||||
# if some systems cannot use make or gmake, we could add support for calling `build.sh`
|
||||
# but this is slower (not parallel jobs) and would require making build.sh
|
||||
# understand the arguments passed to the makefile (e.g. `CC=gcc ucpu=amd64 uos=darwin`),
|
||||
# instead of `--cpu amd64 --os darwin`.
|
||||
unamestr=$(uname)
|
||||
# uname values: https://en.wikipedia.org/wiki/Uname
|
||||
if [ "$unamestr" = 'FreeBSD' ]; then
|
||||
makeX=gmake
|
||||
elif [ "$unamestr" = 'OpenBSD' ]; then
|
||||
makeX=gmake
|
||||
elif [ "$unamestr" = 'NetBSD' ]; then
|
||||
makeX=gmake
|
||||
elif [ "$unamestr" = 'CROSSOS' ]; then
|
||||
makeX=gmake
|
||||
elif [ "$unamestr" = 'SunOS' ]; then
|
||||
makeX=gmake
|
||||
else
|
||||
makeX=make
|
||||
fi
|
||||
nCPU=$(_nimNumCpu)
|
||||
echo_run which $makeX
|
||||
# parallel jobs (5X faster on 16 cores: 10s instead of 50s)
|
||||
echo_run $makeX -C $nim_csourcesDir -j $((nCPU + 2)) -l $nCPU "$@"
|
||||
# keep $nim_csources in case needed to investigate bootstrap issues
|
||||
# without having to rebuild
|
||||
echo_run cp bin/nim $nim_csources
|
||||
}
|
||||
|
||||
nimCiSystemInfo(){
|
||||
nimDefineVars
|
||||
echo_run eval echo '$'nim_csources
|
||||
echo_run pwd
|
||||
echo_run date
|
||||
echo_run uname -a
|
||||
echo_run git log --no-merges -1 --pretty=oneline
|
||||
echo_run eval echo '$'PATH
|
||||
echo_run gcc -v
|
||||
echo_run node -v
|
||||
echo_run make -v
|
||||
}
|
||||
|
||||
nimCsourcesHash(){
|
||||
nimDefineVars
|
||||
echo $nim_csourcesHash
|
||||
}
|
||||
|
||||
nimBuildCsourcesIfNeeded(){
|
||||
# goal: allow cachine each tagged version independently
|
||||
# to avoid rebuilding, so that tools like `git bisect`
|
||||
# can grab a cached past version without rebuilding.
|
||||
nimDefineVars
|
||||
(
|
||||
set -e
|
||||
# avoid polluting caller scope with internal variable definitions.
|
||||
if test -f "$nim_csources"; then
|
||||
echo "$nim_csources exists."
|
||||
else
|
||||
if test -d "$nim_csourcesDir"; then
|
||||
echo "$nim_csourcesDir exists."
|
||||
else
|
||||
# Note: using git tags would allow fetching just what's needed, unlike git hashes, e.g.
|
||||
# via `git clone -q --depth 1 --branch $tag $nim_csourcesUrl`.
|
||||
echo_run git clone -q --depth 1 -b $nim_csourcesBranch \
|
||||
$nim_csourcesUrl "$nim_csourcesDir"
|
||||
# old `git` versions don't support -C option, using `cd` explicitly:
|
||||
echo_run cd "$nim_csourcesDir"
|
||||
echo_run git checkout $nim_csourcesHash
|
||||
echo_run cd "$OLDPWD"
|
||||
# if needed we could also add: `git reset --hard $nim_csourcesHash`
|
||||
fi
|
||||
_nimBuildCsourcesIfNeeded "$@"
|
||||
fi
|
||||
|
||||
echo_run rm -f bin/nim
|
||||
# fixes bug #17913, but it's unclear why it's needed, maybe specific to MacOS Big Sur 11.3 on M1 arch?
|
||||
echo_run cp $nim_csources bin/nim
|
||||
echo_run $nim_csources -v
|
||||
)
|
||||
}
|
||||
233
cmdline.html
Normal file
233
cmdline.html
Normal file
|
|
@ -0,0 +1,233 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<!-- This file is generated by Nim. -->
|
||||
<html xmlns="https://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>std/cmdline</title>
|
||||
|
||||
<!-- Favicon -->
|
||||
<link rel="shortcut icon" href="data:image/x-icon;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAUAAAAF////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAIAAABbAAAAlQAAAKIAAACbAAAAmwAAAKIAAACVAAAAWwAAAAL///8A////AP///wD///8A////AAAAABQAAADAAAAAYwAAAA3///8A////AP///wD///8AAAAADQAAAGMAAADAAAAAFP///wD///8A////AP///wAAAACdAAAAOv///wD///8A////AP///wD///8A////AP///wD///8AAAAAOgAAAJ3///8A////AP///wAAAAAnAAAAcP///wAAAAAoAAAASv///wD///8A////AP///wAAAABKAAAAKP///wAAAABwAAAAJ////wD///8AAAAAgQAAABwAAACIAAAAkAAAAJMAAACtAAAAFQAAABUAAACtAAAAkwAAAJAAAACIAAAAHAAAAIH///8A////AAAAAKQAAACrAAAAaP///wD///8AAAAARQAAANIAAADSAAAARf///wD///8AAAAAaAAAAKsAAACk////AAAAADMAAACcAAAAnQAAABj///8A////AP///wAAAAAYAAAAGP///wD///8A////AAAAABgAAACdAAAAnAAAADMAAAB1AAAAwwAAAP8AAADpAAAAsQAAAE4AAAAb////AP///wAAAAAbAAAATgAAALEAAADpAAAA/wAAAMMAAAB1AAAAtwAAAOkAAAD/AAAA/wAAAP8AAADvAAAA3gAAAN4AAADeAAAA3gAAAO8AAAD/AAAA/wAAAP8AAADpAAAAtwAAAGUAAAA/AAAA3wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAADfAAAAPwAAAGX///8A////AAAAAEgAAADtAAAAvwAAAL0AAADGAAAA7wAAAO8AAADGAAAAvQAAAL8AAADtAAAASP///wD///8A////AP///wD///8AAAAAO////wD///8A////AAAAAIcAAACH////AP///wD///8AAAAAO////wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A//8AAP//AAD4HwAA7/cAAN/7AAD//wAAoYUAAJ55AACf+QAAh+EAAAAAAADAAwAA4AcAAP5/AAD//wAA//8AAA=="/>
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAA3XAAAN1wFCKJt4AAAAB3RJTUUH4QQQEwksSS9ZWwAAAk1JREFUWMPtll2ITVEUx39nn/O7Y5qR8f05wtCUUr6ZIS++8pEnkZInPImneaCQ5METNdOkeFBKUhMPRIkHKfEuUZSUlGlKPN2TrgfncpvmnntnmlEyq1Z7t89/rf9a6+y99oZxGZf/XeIq61EdtgKXgdXA0xrYAvBjOIF1AI9zvjcC74BSpndrJPkBWDScTF8Aa4E3wDlgHbASaANmVqlcCnwHvgDvgVfAJ+AikAAvgfVZwLnSVZHZaOuKoQi3ZOMi4NkYkpe1p4J7A8BpYAD49hfIy/oqG0+hLomiKP2L5L+1ubn5115S+3OAn4EnwBlgMzCjyt6ZAnQCJ4A7wOs88iRJHvw50HoujuPBoCKwHWiosy8MdfZnAdcHk8dxXFJ3VQbQlCTJvRBCGdRbD4M6uc5glpY3eAihpN5S5w12diSEcCCEcKUO4ljdr15T76ur1FDDLIQQ3qv71EdDOe3Kxj3leRXyk+pxdWnFWod6Wt2bY3de3aSuUHcPBVimHs7mK9WrmeOF6lR1o9qnzskh2ar2qm1qizpfXaPeVGdlmGN5pb09qMxz1Xb1kLqgzn1RyH7JUXW52lr5e/Kqi9qpto7V1atuUzfnARrV7jEib1T76gG2qxdGmXyiekkt1GswPTtek0aBfJp6YySGBfWg2tPQ0FAYgf1stUfdmdcjarbYJEniKIq6gY/Aw+zWHAC+p2labGpqiorFYgGYCEzN7oQdQClN07O1/EfDyGgC0ALMBdYAi4FyK+4H3gLPsxfR1zRNi+NP7nH5J+QntnXe5B5mpfQAAAAASUVORK5CYII=">
|
||||
|
||||
<!-- CSS -->
|
||||
<link rel="stylesheet" type="text/css" href="nimdoc.out.css">
|
||||
|
||||
<!-- JS -->
|
||||
<script type="text/javascript" src="dochack.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="document" id="documentId">
|
||||
<div class="container">
|
||||
<h1 class="title">std/cmdline</h1>
|
||||
<div class="row">
|
||||
<div class="three columns">
|
||||
<div class="theme-select-wrapper">
|
||||
<label for="theme-select">Theme: </label>
|
||||
<select id="theme-select" onchange="setTheme(this.value)">
|
||||
<option value="auto">🌗 Match OS</option>
|
||||
<option value="dark">🌑 Dark</option>
|
||||
<option value="light">🌕 Light</option>
|
||||
</select>
|
||||
</div>
|
||||
<div id="global-links">
|
||||
<ul class="simple-boot">
|
||||
<li><a href="manual.html">Manual</a></li>
|
||||
<li><a href="lib.html">Standard library</a></li>
|
||||
<li> <a id="indexLink" href="theindex.html">Index</a></li>
|
||||
<li><a href="compiler/theindex.html">Compiler docs</a></li>
|
||||
<li><a href="https://nim-lang.github.io/fusion/theindex.html">Fusion docs</a></li>
|
||||
<li><a href="https://nim-lang.github.io/Nim/">devel</a>, <a href="https://nim-lang.org/documentation.html">stable</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="searchInputDiv">
|
||||
Search: <input type="search" id="searchInput"
|
||||
onkeyup="search()" />
|
||||
</div>
|
||||
|
||||
<ul class="simple simple-toc" id="toc-list">
|
||||
<li>
|
||||
<a class="reference reference-toplevel" href="#6" id="56">Imports</a>
|
||||
</li>
|
||||
<li>
|
||||
<details open>
|
||||
<summary><a class="reference reference-toplevel" href="#12" id="62">Procs</a></summary>
|
||||
<ul class="simple simple-toc-section">
|
||||
<ul class="simple nested-toc-section">commandLineParams
|
||||
<li><a class="reference" href="#commandLineParams" title="commandLineParams(): seq[string]">commandLineParams(): seq[string]</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">paramCount
|
||||
<li><a class="reference" href="#paramCount" title="paramCount(): int">paramCount(): int</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">paramStr
|
||||
<li><a class="reference" href="#paramStr%2Cint" title="paramStr(i: int): string">paramStr(i: int): string</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">parseCmdLine
|
||||
<li><a class="reference" href="#parseCmdLine%2Cstring" title="parseCmdLine(c: string): seq[string]">parseCmdLine(c: string): seq[string]</a></li>
|
||||
|
||||
</ul>
|
||||
|
||||
</ul>
|
||||
</details>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
<div class="nine columns" id="content">
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/std/cmdline.nim#L1" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/cmdline.nim#L1" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
<div id="tocRoot"></div>
|
||||
|
||||
<p class="module-desc">This module contains system facilities for reading command line parameters.<strong>See also:</strong><ul class="simple"><li><a class="reference external" href="parseopt.html">parseopt module</a> for command-line parser beyond <a class="reference internal nimdoc" title="proc parseCmdLine(c: string): seq[string]" href="#parseCmdLine,string">parseCmdLine proc</a></li>
|
||||
</ul>
|
||||
</p>
|
||||
<div class="section" id="6">
|
||||
<h1><a class="toc-backref" href="#6">Imports</a></h1>
|
||||
<dl class="item">
|
||||
<a class="reference external" href="widestrs.html">widestrs</a>, <a class="reference external" href="posix.html">posix</a>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="section" id="12">
|
||||
<h1><a class="toc-backref" href="#12">Procs</a></h1>
|
||||
<dl class="item">
|
||||
<div id="commandLineParams-procs-all">
|
||||
<div id="commandLineParams">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#commandLineParams"><span class="Identifier">commandLineParams</span></a><span class="Other">(</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#seq"><span class="Identifier">seq</span></a><span class="Other">[</span><a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">]</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ReadIOEffect</span><span class="Other">]</span><span class="Other">,</span>
|
||||
<span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Convenience proc which returns the command line parameters.</p>
|
||||
<p>This returns <strong>only</strong> the parameters. If you want to get the application executable filename, call <a class="reference internal" href="#getAppFilename">getAppFilename</a>.</p>
|
||||
<p><strong>Availability</strong>: On Posix there is no portable way to get the command line from a DLL and thus the proc isn't defined in this environment. You can test for its availability with <a class="reference external" href="system.html#declared,untyped">declared()</a>.</p>
|
||||
<p>See also:</p>
|
||||
<ul class="simple"><li><a class="reference external" href="parseopt.html">parseopt module</a></li>
|
||||
<li><a class="reference internal nimdoc" title="proc parseCmdLine(c: string): seq[string]" href="#parseCmdLine,string">parseCmdLine proc</a></li>
|
||||
<li><a class="reference internal nimdoc" title="proc paramCount(): int" href="#paramCount">paramCount proc</a></li>
|
||||
<li><a class="reference internal nimdoc" title="proc paramStr(i: int): string" href="#paramStr,int">paramStr proc</a></li>
|
||||
<li><a class="reference internal" href="#getAppFilename">getAppFilename</a></li>
|
||||
</ul>
|
||||
<p><strong>Examples:</strong></p>
|
||||
<pre class="listing"><span class="Keyword">when</span> <span class="Identifier">declared</span><span class="Punctuation">(</span><span class="Identifier">commandLineParams</span><span class="Punctuation">)</span><span class="Punctuation">:</span>
|
||||
<span class="Comment"># Use commandLineParams() here</span>
|
||||
<span class="Keyword">else</span><span class="Punctuation">:</span>
|
||||
<span class="Comment"># Do something else!</span></pre>
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/std/cmdline.nim#L279" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/cmdline.nim#L279" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="paramCount-procs-all">
|
||||
<div id="paramCount">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#paramCount"><span class="Identifier">paramCount</span></a><span class="Other">(</span><span class="Other">)</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><a href="exceptions.html#ReadIOEffect"><span class="Identifier">ReadIOEffect</span></a><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Returns the number of <span id="command-line-arguments_1">command line arguments</span> given to the application.</p>
|
||||
<p>Unlike <span id="argc_1">argc</span> in C, if your binary was called without parameters this will return zero. You can query each individual parameter with <a class="reference internal nimdoc" title="proc paramStr(i: int): string" href="#paramStr,int">paramStr proc</a> or retrieve all of them in one go with <a class="reference internal nimdoc" title="proc commandLineParams(): seq[string]" href="#commandLineParams">commandLineParams proc</a>.</p>
|
||||
<p><strong>Availability</strong>: When generating a dynamic library (see <tt class="docutils literal"><span class="pre"><span class="Operator">--</span><span class="Identifier">app</span><span class="Punctuation">:</span><span class="Identifier">lib</span></span></tt>) on Posix this proc is not defined. Test for availability using <a class="reference external" href="system.html#declared,untyped">declared()</a>.</p>
|
||||
<p>See also:</p>
|
||||
<ul class="simple"><li><a class="reference external" href="parseopt.html">parseopt module</a></li>
|
||||
<li><a class="reference internal nimdoc" title="proc parseCmdLine(c: string): seq[string]" href="#parseCmdLine,string">parseCmdLine proc</a></li>
|
||||
<li><a class="reference internal nimdoc" title="proc paramStr(i: int): string" href="#paramStr,int">paramStr proc</a></li>
|
||||
<li><a class="reference internal nimdoc" title="proc commandLineParams(): seq[string]" href="#commandLineParams">commandLineParams proc</a></li>
|
||||
</ul>
|
||||
<p><strong>Examples:</strong></p>
|
||||
<pre class="listing"><span class="Keyword">when</span> <span class="Identifier">declared</span><span class="Punctuation">(</span><span class="Identifier">paramCount</span><span class="Punctuation">)</span><span class="Punctuation">:</span>
|
||||
<span class="Comment"># Use paramCount() here</span>
|
||||
<span class="Keyword">else</span><span class="Punctuation">:</span>
|
||||
<span class="Comment"># Do something else!</span></pre>
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/std/cmdline.nim#L145" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/cmdline.nim#L145" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="paramStr-procs-all">
|
||||
<div id="paramStr,int">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#paramStr%2Cint"><span class="Identifier">paramStr</span></a><span class="Other">(</span><span class="Identifier">i</span><span class="Other">:</span> <a href="system.html#int"><span class="Identifier">int</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><a href="exceptions.html#ReadIOEffect"><span class="Identifier">ReadIOEffect</span></a><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Returns the <tt class="docutils literal"><span class="pre"><span class="Identifier">i</span></span></tt>-th <span id="command-line-argument_1">command line argument</span> given to the application.</p>
|
||||
<p><tt class="docutils literal"><span class="pre"><span class="Identifier">i</span></span></tt> should be in the range <tt class="docutils literal"><span class="pre"><span class="FloatNumber">1.</span><span class="Operator">.</span><span class="Identifier">paramCount</span><span class="Punctuation">(</span><span class="Punctuation">)</span></span></tt>, the <tt class="docutils literal"><span class="pre"><span class="Identifier">IndexDefect</span></span></tt> exception will be raised for invalid values. Instead of iterating over <a class="reference internal nimdoc" title="proc paramCount(): int" href="#paramCount">paramCount()</a> with this proc you can call the convenience <a class="reference internal nimdoc" title="proc commandLineParams(): seq[string]" href="#commandLineParams">commandLineParams()</a>.</p>
|
||||
<p>Similarly to <span id="argv_1">argv</span> in C, it is possible to call <tt class="docutils literal"><span class="pre"><span class="Identifier">paramStr</span><span class="Punctuation">(</span><span class="DecNumber">0</span><span class="Punctuation">)</span></span></tt> but this will return OS specific contents (usually the name of the invoked executable). You should avoid this and call <a class="reference internal" href="#getAppFilename">getAppFilename</a> instead.</p>
|
||||
<p><strong>Availability</strong>: When generating a dynamic library (see <tt class="docutils literal"><span class="pre"><span class="Operator">--</span><span class="Identifier">app</span><span class="Punctuation">:</span><span class="Identifier">lib</span></span></tt>) on Posix this proc is not defined. Test for availability using <a class="reference external" href="system.html#declared,untyped">declared()</a>.</p>
|
||||
<p>See also:</p>
|
||||
<ul class="simple"><li><a class="reference external" href="parseopt.html">parseopt module</a></li>
|
||||
<li><a class="reference internal nimdoc" title="proc parseCmdLine(c: string): seq[string]" href="#parseCmdLine,string">parseCmdLine proc</a></li>
|
||||
<li><a class="reference internal nimdoc" title="proc paramCount(): int" href="#paramCount">paramCount proc</a></li>
|
||||
<li><a class="reference internal nimdoc" title="proc commandLineParams(): seq[string]" href="#commandLineParams">commandLineParams proc</a></li>
|
||||
<li><a class="reference internal" href="#getAppFilename">getAppFilename</a></li>
|
||||
</ul>
|
||||
<p><strong>Examples:</strong></p>
|
||||
<pre class="listing"><span class="Keyword">when</span> <span class="Identifier">declared</span><span class="Punctuation">(</span><span class="Identifier">paramStr</span><span class="Punctuation">)</span><span class="Punctuation">:</span>
|
||||
<span class="Comment"># Use paramStr() here</span>
|
||||
<span class="Keyword">else</span><span class="Punctuation">:</span>
|
||||
<span class="Comment"># Do something else!</span></pre>
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/std/cmdline.nim#L172" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/cmdline.nim#L172" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="parseCmdLine-procs-all">
|
||||
<div id="parseCmdLine,string">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#parseCmdLine%2Cstring"><span class="Identifier">parseCmdLine</span></a><span class="Other">(</span><span class="Identifier">c</span><span class="Other">:</span> <a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">)</span><span class="Other">:</span> <a href="system.html#seq"><span class="Identifier">seq</span></a><span class="Other">[</span><a href="system.html#string"><span class="Identifier">string</span></a><span class="Other">]</span> {.<span class="Identifier">noSideEffect</span><span class="Other">,</span> <span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">gcsafe</span><span class="Other">,</span>
|
||||
<span class="Identifier">extern</span><span class="Other">:</span> <span class="StringLit">"nos$1"</span><span class="Other">,</span> <span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>Splits a <span id="command-line_1">command line</span> into several components.</p>
|
||||
<p><strong>Note</strong>: This proc is only occasionally useful, better use the <a class="reference external" href="parseopt.html">parseopt module</a>.</p>
|
||||
<p>On Windows, it uses the <a class="reference external" href="http://msdn.microsoft.com/en-us/library/17w5ykft.aspx">following parsing rules</a>:</p>
|
||||
<ul class="simple"><li>Arguments are delimited by white space, which is either a space or a tab.</li>
|
||||
<li>The caret character (^) is not recognized as an escape character or delimiter. The character is handled completely by the command-line parser in the operating system before being passed to the argv array in the program.</li>
|
||||
<li>A string surrounded by double quotation marks ("string") is interpreted as a single argument, regardless of white space contained within. A quoted string can be embedded in an argument.</li>
|
||||
<li>A double quotation mark preceded by a backslash (") is interpreted as a literal double quotation mark character (").</li>
|
||||
<li>Backslashes are interpreted literally, unless they immediately precede a double quotation mark.</li>
|
||||
<li>If an even number of backslashes is followed by a double quotation mark, one backslash is placed in the argv array for every pair of backslashes, and the double quotation mark is interpreted as a string delimiter.</li>
|
||||
<li>If an odd number of backslashes is followed by a double quotation mark, one backslash is placed in the argv array for every pair of backslashes, and the double quotation mark is "escaped" by the remaining backslash, causing a literal double quotation mark (") to be placed in argv.</li>
|
||||
</ul>
|
||||
<p>On Posix systems, it uses the following parsing rules: Components are separated by whitespace unless the whitespace occurs within <tt class="docutils literal"><span class="pre">"</span></tt> or <tt class="docutils literal"><span class="pre">'</span></tt> quotes.</p>
|
||||
<p>See also:</p>
|
||||
<ul class="simple"><li><a class="reference external" href="parseopt.html">parseopt module</a></li>
|
||||
<li><a class="reference internal nimdoc" title="proc paramCount(): int" href="#paramCount">paramCount proc</a></li>
|
||||
<li><a class="reference internal nimdoc" title="proc paramStr(i: int): string" href="#paramStr,int">paramStr proc</a></li>
|
||||
<li><a class="reference internal nimdoc" title="proc commandLineParams(): seq[string]" href="#commandLineParams">commandLineParams proc</a></li>
|
||||
</ul>
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/lib/std/cmdline.nim#L46" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/lib/std/cmdline.nim#L46" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="twelve-columns footer">
|
||||
<span class="nim-sprite"></span>
|
||||
<br>
|
||||
<small style="color: var(--hint);">Made with Nim. Generated: 2023-03-13 00:19:53 UTC</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script defer data-domain="nim-lang.org" src="https://plausible.io/js/plausible.js"></script>
|
||||
|
||||
<!-- Google fonts -->
|
||||
<link href='https://fonts.googleapis.com/css?family=Lato:400,600,900' rel='stylesheet' type='text/css'/>
|
||||
<link href='https://fonts.googleapis.com/css?family=Source+Code+Pro:400,500,600' rel='stylesheet' type='text/css'/>
|
||||
</body>
|
||||
</html>
|
||||
10
cmdline.idx
Normal file
10
cmdline.idx
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
nimTitle cmdline cmdline.html module std/cmdline 0
|
||||
nim parseCmdLine cmdline.html#parseCmdLine,string proc parseCmdLine(c: string): seq[string] 46
|
||||
nim paramCount cmdline.html#paramCount proc paramCount(): int 145
|
||||
nim paramStr cmdline.html#paramStr,int proc paramStr(i: int): string 172
|
||||
nim commandLineParams cmdline.html#commandLineParams proc commandLineParams(): seq[string] 279
|
||||
idx command line arguments cmdline.html#command-line-arguments_1 Module cmdline 0
|
||||
idx argc cmdline.html#argc_1 Module cmdline 0
|
||||
idx command line cmdline.html#command-line_1 Module cmdline 0
|
||||
idx command line argument cmdline.html#command-line-argument_1 Module cmdline 0
|
||||
idx argv cmdline.html#argv_1 Module cmdline 0
|
||||
2024
colors.html
Normal file
2024
colors.html
Normal file
File diff suppressed because it is too large
Load diff
160
colors.idx
Normal file
160
colors.idx
Normal file
|
|
@ -0,0 +1,160 @@
|
|||
nimTitle colors colors.html module std/colors 0
|
||||
nim Color colors.html#Color type Color 16
|
||||
nim `==` colors.html#==,Color,Color proc `==`(a, b: Color): bool 18
|
||||
nim `+` colors.html#+,Color,Color proc `+`(a, b: Color): Color 50
|
||||
nim `-` colors.html#-,Color,Color proc `-`(a, b: Color): Color 64
|
||||
nim extractRGB colors.html#extractRGB,Color proc extractRGB(a: Color): tuple[r, g, b: range[0 .. 255] = 0] 78
|
||||
nim intensity colors.html#intensity,Color,float proc intensity(a: Color; f: float): Color 98
|
||||
nim mix colors.html#mix.t,Color,Color,untyped template mix(a, b: Color; fn: untyped): untyped 117
|
||||
nim colAliceBlue colors.html#colAliceBlue const colAliceBlue 148
|
||||
nim colAntiqueWhite colors.html#colAntiqueWhite const colAntiqueWhite 149
|
||||
nim colAqua colors.html#colAqua const colAqua 150
|
||||
nim colAquamarine colors.html#colAquamarine const colAquamarine 151
|
||||
nim colAzure colors.html#colAzure const colAzure 152
|
||||
nim colBeige colors.html#colBeige const colBeige 153
|
||||
nim colBisque colors.html#colBisque const colBisque 154
|
||||
nim colBlack colors.html#colBlack const colBlack 155
|
||||
nim colBlanchedAlmond colors.html#colBlanchedAlmond const colBlanchedAlmond 156
|
||||
nim colBlue colors.html#colBlue const colBlue 157
|
||||
nim colBlueViolet colors.html#colBlueViolet const colBlueViolet 158
|
||||
nim colBrown colors.html#colBrown const colBrown 159
|
||||
nim colBurlyWood colors.html#colBurlyWood const colBurlyWood 160
|
||||
nim colCadetBlue colors.html#colCadetBlue const colCadetBlue 161
|
||||
nim colChartreuse colors.html#colChartreuse const colChartreuse 162
|
||||
nim colChocolate colors.html#colChocolate const colChocolate 163
|
||||
nim colCoral colors.html#colCoral const colCoral 164
|
||||
nim colCornflowerBlue colors.html#colCornflowerBlue const colCornflowerBlue 165
|
||||
nim colCornsilk colors.html#colCornsilk const colCornsilk 166
|
||||
nim colCrimson colors.html#colCrimson const colCrimson 167
|
||||
nim colCyan colors.html#colCyan const colCyan 168
|
||||
nim colDarkBlue colors.html#colDarkBlue const colDarkBlue 169
|
||||
nim colDarkCyan colors.html#colDarkCyan const colDarkCyan 170
|
||||
nim colDarkGoldenRod colors.html#colDarkGoldenRod const colDarkGoldenRod 171
|
||||
nim colDarkGray colors.html#colDarkGray const colDarkGray 172
|
||||
nim colDarkGreen colors.html#colDarkGreen const colDarkGreen 173
|
||||
nim colDarkGrey colors.html#colDarkGrey const colDarkGrey 174
|
||||
nim colDarkKhaki colors.html#colDarkKhaki const colDarkKhaki 175
|
||||
nim colDarkMagenta colors.html#colDarkMagenta const colDarkMagenta 176
|
||||
nim colDarkOliveGreen colors.html#colDarkOliveGreen const colDarkOliveGreen 177
|
||||
nim colDarkorange colors.html#colDarkorange const colDarkorange 178
|
||||
nim colDarkOrchid colors.html#colDarkOrchid const colDarkOrchid 179
|
||||
nim colDarkRed colors.html#colDarkRed const colDarkRed 180
|
||||
nim colDarkSalmon colors.html#colDarkSalmon const colDarkSalmon 181
|
||||
nim colDarkSeaGreen colors.html#colDarkSeaGreen const colDarkSeaGreen 182
|
||||
nim colDarkSlateBlue colors.html#colDarkSlateBlue const colDarkSlateBlue 183
|
||||
nim colDarkSlateGray colors.html#colDarkSlateGray const colDarkSlateGray 184
|
||||
nim colDarkSlateGrey colors.html#colDarkSlateGrey const colDarkSlateGrey 185
|
||||
nim colDarkTurquoise colors.html#colDarkTurquoise const colDarkTurquoise 186
|
||||
nim colDarkViolet colors.html#colDarkViolet const colDarkViolet 187
|
||||
nim colDeepPink colors.html#colDeepPink const colDeepPink 188
|
||||
nim colDeepSkyBlue colors.html#colDeepSkyBlue const colDeepSkyBlue 189
|
||||
nim colDimGray colors.html#colDimGray const colDimGray 190
|
||||
nim colDimGrey colors.html#colDimGrey const colDimGrey 191
|
||||
nim colDodgerBlue colors.html#colDodgerBlue const colDodgerBlue 192
|
||||
nim colFireBrick colors.html#colFireBrick const colFireBrick 193
|
||||
nim colFloralWhite colors.html#colFloralWhite const colFloralWhite 194
|
||||
nim colForestGreen colors.html#colForestGreen const colForestGreen 195
|
||||
nim colFuchsia colors.html#colFuchsia const colFuchsia 196
|
||||
nim colGainsboro colors.html#colGainsboro const colGainsboro 197
|
||||
nim colGhostWhite colors.html#colGhostWhite const colGhostWhite 198
|
||||
nim colGold colors.html#colGold const colGold 199
|
||||
nim colGoldenRod colors.html#colGoldenRod const colGoldenRod 200
|
||||
nim colGray colors.html#colGray const colGray 201
|
||||
nim colGreen colors.html#colGreen const colGreen 202
|
||||
nim colGrey colors.html#colGrey const colGrey 203
|
||||
nim colGreenYellow colors.html#colGreenYellow const colGreenYellow 204
|
||||
nim colHoneyDew colors.html#colHoneyDew const colHoneyDew 205
|
||||
nim colHotPink colors.html#colHotPink const colHotPink 206
|
||||
nim colIndianRed colors.html#colIndianRed const colIndianRed 207
|
||||
nim colIndigo colors.html#colIndigo const colIndigo 208
|
||||
nim colIvory colors.html#colIvory const colIvory 209
|
||||
nim colKhaki colors.html#colKhaki const colKhaki 210
|
||||
nim colLavender colors.html#colLavender const colLavender 211
|
||||
nim colLavenderBlush colors.html#colLavenderBlush const colLavenderBlush 212
|
||||
nim colLawnGreen colors.html#colLawnGreen const colLawnGreen 213
|
||||
nim colLemonChiffon colors.html#colLemonChiffon const colLemonChiffon 214
|
||||
nim colLightBlue colors.html#colLightBlue const colLightBlue 215
|
||||
nim colLightCoral colors.html#colLightCoral const colLightCoral 216
|
||||
nim colLightCyan colors.html#colLightCyan const colLightCyan 217
|
||||
nim colLightGoldenRodYellow colors.html#colLightGoldenRodYellow const colLightGoldenRodYellow 218
|
||||
nim colLightGray colors.html#colLightGray const colLightGray 219
|
||||
nim colLightGreen colors.html#colLightGreen const colLightGreen 220
|
||||
nim colLightGrey colors.html#colLightGrey const colLightGrey 221
|
||||
nim colLightPink colors.html#colLightPink const colLightPink 222
|
||||
nim colLightSalmon colors.html#colLightSalmon const colLightSalmon 223
|
||||
nim colLightSeaGreen colors.html#colLightSeaGreen const colLightSeaGreen 224
|
||||
nim colLightSkyBlue colors.html#colLightSkyBlue const colLightSkyBlue 225
|
||||
nim colLightSlateGray colors.html#colLightSlateGray const colLightSlateGray 226
|
||||
nim colLightSlateGrey colors.html#colLightSlateGrey const colLightSlateGrey 227
|
||||
nim colLightSteelBlue colors.html#colLightSteelBlue const colLightSteelBlue 228
|
||||
nim colLightYellow colors.html#colLightYellow const colLightYellow 229
|
||||
nim colLime colors.html#colLime const colLime 230
|
||||
nim colLimeGreen colors.html#colLimeGreen const colLimeGreen 231
|
||||
nim colLinen colors.html#colLinen const colLinen 232
|
||||
nim colMagenta colors.html#colMagenta const colMagenta 233
|
||||
nim colMaroon colors.html#colMaroon const colMaroon 234
|
||||
nim colMediumAquaMarine colors.html#colMediumAquaMarine const colMediumAquaMarine 235
|
||||
nim colMediumBlue colors.html#colMediumBlue const colMediumBlue 236
|
||||
nim colMediumOrchid colors.html#colMediumOrchid const colMediumOrchid 237
|
||||
nim colMediumPurple colors.html#colMediumPurple const colMediumPurple 238
|
||||
nim colMediumSeaGreen colors.html#colMediumSeaGreen const colMediumSeaGreen 239
|
||||
nim colMediumSlateBlue colors.html#colMediumSlateBlue const colMediumSlateBlue 240
|
||||
nim colMediumSpringGreen colors.html#colMediumSpringGreen const colMediumSpringGreen 241
|
||||
nim colMediumTurquoise colors.html#colMediumTurquoise const colMediumTurquoise 242
|
||||
nim colMediumVioletRed colors.html#colMediumVioletRed const colMediumVioletRed 243
|
||||
nim colMidnightBlue colors.html#colMidnightBlue const colMidnightBlue 244
|
||||
nim colMintCream colors.html#colMintCream const colMintCream 245
|
||||
nim colMistyRose colors.html#colMistyRose const colMistyRose 246
|
||||
nim colMoccasin colors.html#colMoccasin const colMoccasin 247
|
||||
nim colNavajoWhite colors.html#colNavajoWhite const colNavajoWhite 248
|
||||
nim colNavy colors.html#colNavy const colNavy 249
|
||||
nim colOldLace colors.html#colOldLace const colOldLace 250
|
||||
nim colOlive colors.html#colOlive const colOlive 251
|
||||
nim colOliveDrab colors.html#colOliveDrab const colOliveDrab 252
|
||||
nim colOrange colors.html#colOrange const colOrange 253
|
||||
nim colOrangeRed colors.html#colOrangeRed const colOrangeRed 254
|
||||
nim colOrchid colors.html#colOrchid const colOrchid 255
|
||||
nim colPaleGoldenRod colors.html#colPaleGoldenRod const colPaleGoldenRod 256
|
||||
nim colPaleGreen colors.html#colPaleGreen const colPaleGreen 257
|
||||
nim colPaleTurquoise colors.html#colPaleTurquoise const colPaleTurquoise 258
|
||||
nim colPaleVioletRed colors.html#colPaleVioletRed const colPaleVioletRed 259
|
||||
nim colPapayaWhip colors.html#colPapayaWhip const colPapayaWhip 260
|
||||
nim colPeachPuff colors.html#colPeachPuff const colPeachPuff 261
|
||||
nim colPeru colors.html#colPeru const colPeru 262
|
||||
nim colPink colors.html#colPink const colPink 263
|
||||
nim colPlum colors.html#colPlum const colPlum 264
|
||||
nim colPowderBlue colors.html#colPowderBlue const colPowderBlue 265
|
||||
nim colPurple colors.html#colPurple const colPurple 266
|
||||
nim colRebeccaPurple colors.html#colRebeccaPurple const colRebeccaPurple 267
|
||||
nim colRed colors.html#colRed const colRed 268
|
||||
nim colRosyBrown colors.html#colRosyBrown const colRosyBrown 269
|
||||
nim colRoyalBlue colors.html#colRoyalBlue const colRoyalBlue 270
|
||||
nim colSaddleBrown colors.html#colSaddleBrown const colSaddleBrown 271
|
||||
nim colSalmon colors.html#colSalmon const colSalmon 272
|
||||
nim colSandyBrown colors.html#colSandyBrown const colSandyBrown 273
|
||||
nim colSeaGreen colors.html#colSeaGreen const colSeaGreen 274
|
||||
nim colSeaShell colors.html#colSeaShell const colSeaShell 275
|
||||
nim colSienna colors.html#colSienna const colSienna 276
|
||||
nim colSilver colors.html#colSilver const colSilver 277
|
||||
nim colSkyBlue colors.html#colSkyBlue const colSkyBlue 278
|
||||
nim colSlateBlue colors.html#colSlateBlue const colSlateBlue 279
|
||||
nim colSlateGray colors.html#colSlateGray const colSlateGray 280
|
||||
nim colSlateGrey colors.html#colSlateGrey const colSlateGrey 281
|
||||
nim colSnow colors.html#colSnow const colSnow 282
|
||||
nim colSpringGreen colors.html#colSpringGreen const colSpringGreen 283
|
||||
nim colSteelBlue colors.html#colSteelBlue const colSteelBlue 284
|
||||
nim colTan colors.html#colTan const colTan 285
|
||||
nim colTeal colors.html#colTeal const colTeal 286
|
||||
nim colThistle colors.html#colThistle const colThistle 287
|
||||
nim colTomato colors.html#colTomato const colTomato 288
|
||||
nim colTurquoise colors.html#colTurquoise const colTurquoise 289
|
||||
nim colViolet colors.html#colViolet const colViolet 290
|
||||
nim colWheat colors.html#colWheat const colWheat 291
|
||||
nim colWhite colors.html#colWhite const colWhite 292
|
||||
nim colWhiteSmoke colors.html#colWhiteSmoke const colWhiteSmoke 293
|
||||
nim colYellow colors.html#colYellow const colYellow 294
|
||||
nim colYellowGreen colors.html#colYellowGreen const colYellowGreen 295
|
||||
nim `$` colors.html#$,Color proc `$`(c: Color): string 447
|
||||
nim parseColor colors.html#parseColor,string proc parseColor(name: string): Color 457
|
||||
nim isColor colors.html#isColor,string proc isColor(name: string): bool 479
|
||||
nim rgb colors.html#rgb,range[],range[],range[] proc rgb(r, g, b: range[0 .. 255]): Color 500
|
||||
218
compiler/aliasanalysis.html
Normal file
218
compiler/aliasanalysis.html
Normal file
|
|
@ -0,0 +1,218 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<!-- This file is generated by Nim. -->
|
||||
<html xmlns="https://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>compiler/aliasanalysis</title>
|
||||
|
||||
<!-- Favicon -->
|
||||
<link rel="shortcut icon" href="data:image/x-icon;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAUAAAAF////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAIAAABbAAAAlQAAAKIAAACbAAAAmwAAAKIAAACVAAAAWwAAAAL///8A////AP///wD///8A////AAAAABQAAADAAAAAYwAAAA3///8A////AP///wD///8AAAAADQAAAGMAAADAAAAAFP///wD///8A////AP///wAAAACdAAAAOv///wD///8A////AP///wD///8A////AP///wD///8AAAAAOgAAAJ3///8A////AP///wAAAAAnAAAAcP///wAAAAAoAAAASv///wD///8A////AP///wAAAABKAAAAKP///wAAAABwAAAAJ////wD///8AAAAAgQAAABwAAACIAAAAkAAAAJMAAACtAAAAFQAAABUAAACtAAAAkwAAAJAAAACIAAAAHAAAAIH///8A////AAAAAKQAAACrAAAAaP///wD///8AAAAARQAAANIAAADSAAAARf///wD///8AAAAAaAAAAKsAAACk////AAAAADMAAACcAAAAnQAAABj///8A////AP///wAAAAAYAAAAGP///wD///8A////AAAAABgAAACdAAAAnAAAADMAAAB1AAAAwwAAAP8AAADpAAAAsQAAAE4AAAAb////AP///wAAAAAbAAAATgAAALEAAADpAAAA/wAAAMMAAAB1AAAAtwAAAOkAAAD/AAAA/wAAAP8AAADvAAAA3gAAAN4AAADeAAAA3gAAAO8AAAD/AAAA/wAAAP8AAADpAAAAtwAAAGUAAAA/AAAA3wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAADfAAAAPwAAAGX///8A////AAAAAEgAAADtAAAAvwAAAL0AAADGAAAA7wAAAO8AAADGAAAAvQAAAL8AAADtAAAASP///wD///8A////AP///wD///8AAAAAO////wD///8A////AAAAAIcAAACH////AP///wD///8AAAAAO////wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A//8AAP//AAD4HwAA7/cAAN/7AAD//wAAoYUAAJ55AACf+QAAh+EAAAAAAADAAwAA4AcAAP5/AAD//wAA//8AAA=="/>
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAA3XAAAN1wFCKJt4AAAAB3RJTUUH4QQQEwksSS9ZWwAAAk1JREFUWMPtll2ITVEUx39nn/O7Y5qR8f05wtCUUr6ZIS++8pEnkZInPImneaCQ5METNdOkeFBKUhMPRIkHKfEuUZSUlGlKPN2TrgfncpvmnntnmlEyq1Z7t89/rf9a6+y99oZxGZf/XeIq61EdtgKXgdXA0xrYAvBjOIF1AI9zvjcC74BSpndrJPkBWDScTF8Aa4E3wDlgHbASaANmVqlcCnwHvgDvgVfAJ+AikAAvgfVZwLnSVZHZaOuKoQi3ZOMi4NkYkpe1p4J7A8BpYAD49hfIy/oqG0+hLomiKP2L5L+1ubn5115S+3OAn4EnwBlgMzCjyt6ZAnQCJ4A7wOs88iRJHvw50HoujuPBoCKwHWiosy8MdfZnAdcHk8dxXFJ3VQbQlCTJvRBCGdRbD4M6uc5glpY3eAihpN5S5w12diSEcCCEcKUO4ljdr15T76ur1FDDLIQQ3qv71EdDOe3Kxj3leRXyk+pxdWnFWod6Wt2bY3de3aSuUHcPBVimHs7mK9WrmeOF6lR1o9qnzskh2ar2qm1qizpfXaPeVGdlmGN5pb09qMxz1Xb1kLqgzn1RyH7JUXW52lr5e/Kqi9qpto7V1atuUzfnARrV7jEib1T76gG2qxdGmXyiekkt1GswPTtek0aBfJp6YySGBfWg2tPQ0FAYgf1stUfdmdcjarbYJEniKIq6gY/Aw+zWHAC+p2labGpqiorFYgGYCEzN7oQdQClN07O1/EfDyGgC0ALMBdYAi4FyK+4H3gLPsxfR1zRNi+NP7nH5J+QntnXe5B5mpfQAAAAASUVORK5CYII=">
|
||||
|
||||
<!-- CSS -->
|
||||
<link rel="stylesheet" type="text/css" href="nimdoc.out.css">
|
||||
|
||||
<!-- JS -->
|
||||
<script type="text/javascript" src="dochack.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="document" id="documentId">
|
||||
<div class="container">
|
||||
<h1 class="title">compiler/aliasanalysis</h1>
|
||||
<div class="row">
|
||||
<div class="three columns">
|
||||
<div class="theme-select-wrapper">
|
||||
<label for="theme-select">Theme: </label>
|
||||
<select id="theme-select" onchange="setTheme(this.value)">
|
||||
<option value="auto">🌗 Match OS</option>
|
||||
<option value="dark">🌑 Dark</option>
|
||||
<option value="light">🌕 Light</option>
|
||||
</select>
|
||||
</div>
|
||||
<div id="global-links">
|
||||
<ul class="simple">
|
||||
<li><a id="indexLink" href="theindex.html">Index</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="searchInputDiv">
|
||||
Search: <input type="search" id="searchInput" onkeyup="search()"/>
|
||||
</div>
|
||||
<div>
|
||||
Group by:
|
||||
<select onchange="groupBy(this.value)">
|
||||
<option value="section">Section</option>
|
||||
<option value="type">Type</option>
|
||||
</select>
|
||||
</div>
|
||||
<ul class="simple simple-toc" id="toc-list">
|
||||
<li>
|
||||
<a class="reference reference-toplevel" href="#6" id="56">Imports</a>
|
||||
</li>
|
||||
<li>
|
||||
<details open>
|
||||
<summary><a class="reference reference-toplevel" href="#7" id="57">Types</a></summary>
|
||||
<ul class="simple simple-toc-section">
|
||||
<li><a class="reference" href="#AliasKind" title="AliasKind = enum
|
||||
yes, no, maybe">AliasKind</a></li>
|
||||
|
||||
</ul>
|
||||
</details>
|
||||
</li>
|
||||
<li>
|
||||
<details open>
|
||||
<summary><a class="reference reference-toplevel" href="#10" id="60">Consts</a></summary>
|
||||
<ul class="simple simple-toc-section">
|
||||
<li><a class="reference" href="#PathKinds0" title="PathKinds0 = {nkDotExpr, nkCheckedFieldExpr, nkBracketExpr, nkDerefExpr,
|
||||
nkHiddenDeref, nkAddr, nkHiddenAddr, nkObjDownConv, nkObjUpConv}">PathKinds0</a></li>
|
||||
<li><a class="reference" href="#PathKinds1" title="PathKinds1 = {nkHiddenStdConv, nkHiddenSubConv}">PathKinds1</a></li>
|
||||
|
||||
</ul>
|
||||
</details>
|
||||
</li>
|
||||
<li>
|
||||
<details open>
|
||||
<summary><a class="reference reference-toplevel" href="#12" id="62">Procs</a></summary>
|
||||
<ul class="simple simple-toc-section">
|
||||
<ul class="simple nested-toc-section">aliases
|
||||
<li><a class="reference" href="#aliases%2CPNode%2CPNode" title="aliases(obj, field: PNode): AliasKind">aliases(obj, field: PNode): AliasKind</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">isAnalysableFieldAccess
|
||||
<li><a class="reference" href="#isAnalysableFieldAccess%2CPNode%2CPSym" title="isAnalysableFieldAccess(orig: PNode; owner: PSym): bool">isAnalysableFieldAccess(orig: PNode; owner: PSym): bool</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">skipConvDfa
|
||||
<li><a class="reference" href="#skipConvDfa%2CPNode" title="skipConvDfa(n: PNode): PNode">skipConvDfa(n: PNode): PNode</a></li>
|
||||
|
||||
</ul>
|
||||
|
||||
</ul>
|
||||
</details>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
<div class="nine columns" id="content">
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/compiler/aliasanalysis.nim#L1" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/compiler/aliasanalysis.nim#L1" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
<div id="tocRoot"></div>
|
||||
|
||||
<p class="module-desc"></p>
|
||||
<div class="section" id="6">
|
||||
<h1><a class="toc-backref" href="#6">Imports</a></h1>
|
||||
<dl class="item">
|
||||
<a class="reference external" href="ast.html">ast</a>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="section" id="7">
|
||||
<h1><a class="toc-backref" href="#7">Types</a></h1>
|
||||
<dl class="item">
|
||||
<div id="AliasKind">
|
||||
<dt><pre><a href="aliasanalysis.html#AliasKind"><span class="Identifier">AliasKind</span></a> <span class="Other">=</span> <span class="Keyword">enum</span>
|
||||
<span class="Identifier">yes</span><span class="Other">,</span> <span class="Identifier">no</span><span class="Other">,</span> <span class="Identifier">maybe</span></pre></dt>
|
||||
<dd>
|
||||
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/compiler/aliasanalysis.nim#L56" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/compiler/aliasanalysis.nim#L56" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</dl>
|
||||
</div>
|
||||
<div class="section" id="10">
|
||||
<h1><a class="toc-backref" href="#10">Consts</a></h1>
|
||||
<dl class="item">
|
||||
<div id="PathKinds0">
|
||||
<dt><pre><a href="aliasanalysis.html#PathKinds0"><span class="Identifier">PathKinds0</span></a> <span class="Other">=</span> <span class="Other">{</span><span class="DecNumber">nkDotExpr</span><span class="Other">,</span> <span class="DecNumber">nkCheckedFieldExpr</span><span class="Other">,</span> <span class="DecNumber">nkBracketExpr</span><span class="Other">,</span> <span class="DecNumber">nkDerefExpr</span><span class="Other">,</span>
|
||||
<span class="DecNumber">nkHiddenDeref</span><span class="Other">,</span> <span class="DecNumber">nkAddr</span><span class="Other">,</span> <span class="DecNumber">nkHiddenAddr</span><span class="Other">,</span> <span class="DecNumber">nkObjDownConv</span><span class="Other">,</span> <span class="DecNumber">nkObjUpConv</span><span class="Other">}</span></pre></dt>
|
||||
<dd>
|
||||
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/compiler/aliasanalysis.nim#L7" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/compiler/aliasanalysis.nim#L7" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
<div id="PathKinds1">
|
||||
<dt><pre><a href="aliasanalysis.html#PathKinds1"><span class="Identifier">PathKinds1</span></a> <span class="Other">=</span> <span class="Other">{</span><span class="DecNumber">nkHiddenStdConv</span><span class="Other">,</span> <span class="DecNumber">nkHiddenSubConv</span><span class="Other">}</span></pre></dt>
|
||||
<dd>
|
||||
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/compiler/aliasanalysis.nim#L11" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/compiler/aliasanalysis.nim#L11" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</dl>
|
||||
</div>
|
||||
<div class="section" id="12">
|
||||
<h1><a class="toc-backref" href="#12">Procs</a></h1>
|
||||
<dl class="item">
|
||||
<div id="aliases-procs-all">
|
||||
<div id="aliases,PNode,PNode">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#aliases%2CPNode%2CPNode"><span class="Identifier">aliases</span></a><span class="Other">(</span><span class="Identifier">obj</span><span class="Other">,</span> <span class="Identifier">field</span><span class="Other">:</span> <a href="ast.html#PNode"><span class="Identifier">PNode</span></a><span class="Other">)</span><span class="Other">:</span> <a href="aliasanalysis.html#AliasKind"><span class="Identifier">AliasKind</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/compiler/aliasanalysis.nim#L59" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/compiler/aliasanalysis.nim#L59" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="isAnalysableFieldAccess-procs-all">
|
||||
<div id="isAnalysableFieldAccess,PNode,PSym">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#isAnalysableFieldAccess%2CPNode%2CPSym"><span class="Identifier">isAnalysableFieldAccess</span></a><span class="Other">(</span><span class="Identifier">orig</span><span class="Other">:</span> <a href="ast.html#PNode"><span class="Identifier">PNode</span></a><span class="Other">;</span> <span class="Identifier">owner</span><span class="Other">:</span> <a href="ast.html#PSym"><span class="Identifier">PSym</span></a><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">bool</span> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span>
|
||||
<span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/compiler/aliasanalysis.nim#L23" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/compiler/aliasanalysis.nim#L23" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="skipConvDfa-procs-all">
|
||||
<div id="skipConvDfa,PNode">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#skipConvDfa%2CPNode"><span class="Identifier">skipConvDfa</span></a><span class="Other">(</span><span class="Identifier">n</span><span class="Other">:</span> <a href="ast.html#PNode"><span class="Identifier">PNode</span></a><span class="Other">)</span><span class="Other">:</span> <a href="ast.html#PNode"><span class="Identifier">PNode</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/compiler/aliasanalysis.nim#L13" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/compiler/aliasanalysis.nim#L13" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="twelve-columns footer">
|
||||
<span class="nim-sprite"></span>
|
||||
<br>
|
||||
<small style="color: var(--hint);">Made with Nim. Generated: 2023-03-13 00:20:13 UTC</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script defer data-domain="nim-lang.org" src="https://plausible.io/js/plausible.js"></script>
|
||||
|
||||
<!-- Google fonts -->
|
||||
<link href='https://fonts.googleapis.com/css?family=Lato:400,600,900' rel='stylesheet' type='text/css'/>
|
||||
<link href='https://fonts.googleapis.com/css?family=Source+Code+Pro:400,500,600' rel='stylesheet' type='text/css'/>
|
||||
</body>
|
||||
</html>
|
||||
10
compiler/aliasanalysis.idx
Normal file
10
compiler/aliasanalysis.idx
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
nimTitle aliasanalysis aliasanalysis.html module compiler/aliasanalysis 0
|
||||
nim PathKinds0 aliasanalysis.html#PathKinds0 const PathKinds0 7
|
||||
nim PathKinds1 aliasanalysis.html#PathKinds1 const PathKinds1 11
|
||||
nim skipConvDfa aliasanalysis.html#skipConvDfa,PNode proc skipConvDfa(n: PNode): PNode 13
|
||||
nim isAnalysableFieldAccess aliasanalysis.html#isAnalysableFieldAccess,PNode,PSym proc isAnalysableFieldAccess(orig: PNode; owner: PSym): bool 23
|
||||
nim yes aliasanalysis.html#yes AliasKind.yes 56
|
||||
nim no aliasanalysis.html#no AliasKind.no 56
|
||||
nim maybe aliasanalysis.html#maybe AliasKind.maybe 56
|
||||
nim AliasKind aliasanalysis.html#AliasKind enum AliasKind 56
|
||||
nim aliases aliasanalysis.html#aliases,PNode,PNode proc aliases(obj, field: PNode): AliasKind 59
|
||||
|
|
@ -1,128 +0,0 @@
|
|||
|
||||
import ast
|
||||
|
||||
import std / assertions
|
||||
|
||||
const
|
||||
PathKinds0* = {nkDotExpr, nkCheckedFieldExpr,
|
||||
nkBracketExpr, nkDerefExpr, nkHiddenDeref,
|
||||
nkAddr, nkHiddenAddr,
|
||||
nkObjDownConv, nkObjUpConv}
|
||||
PathKinds1* = {nkHiddenStdConv, nkHiddenSubConv}
|
||||
|
||||
proc skipConvDfa*(n: PNode): PNode =
|
||||
result = n
|
||||
while true:
|
||||
case result.kind
|
||||
of nkObjDownConv, nkObjUpConv:
|
||||
result = result[0]
|
||||
of PathKinds1:
|
||||
result = result[1]
|
||||
else: break
|
||||
|
||||
proc isAnalysableFieldAccess*(orig: PNode; owner: PSym): bool =
|
||||
var n = orig
|
||||
while true:
|
||||
case n.kind
|
||||
of PathKinds0 - {nkHiddenDeref, nkDerefExpr}:
|
||||
n = n[0]
|
||||
of PathKinds1:
|
||||
n = n[1]
|
||||
of nkHiddenDeref, nkDerefExpr:
|
||||
# We "own" sinkparam[].loc but not ourVar[].location as it is a nasty
|
||||
# pointer indirection.
|
||||
# bug #14159, we cannot reason about sinkParam[].location as it can
|
||||
# still be shared for tyRef.
|
||||
n = n[0]
|
||||
return n.kind == nkSym and n.sym.owner == owner and
|
||||
(n.sym.typ.skipTypes(abstractInst-{tyOwned}).kind in {tyOwned})
|
||||
else: break
|
||||
# XXX Allow closure deref operations here if we know
|
||||
# the owner controlled the closure allocation?
|
||||
result = n.kind == nkSym and n.sym.owner == owner and
|
||||
{sfGlobal, sfThread, sfCursor} * n.sym.flags == {} and
|
||||
(n.sym.kind != skParam or isSinkParam(n.sym)) # or n.sym.typ.kind == tyVar)
|
||||
# Note: There is a different move analyzer possible that checks for
|
||||
# consume(param.key); param.key = newValue for all paths. Then code like
|
||||
#
|
||||
# let splited = split(move self.root, x)
|
||||
# self.root = merge(splited.lower, splited.greater)
|
||||
#
|
||||
# could be written without the ``move self.root``. However, this would be
|
||||
# wrong! Then the write barrier for the ``self.root`` assignment would
|
||||
# free the old data and all is lost! Lesson: Don't be too smart, trust the
|
||||
# lower level C++ optimizer to specialize this code.
|
||||
|
||||
type AliasKind* = enum
|
||||
yes, no, maybe
|
||||
|
||||
proc aliases*(obj, field: PNode): AliasKind =
|
||||
# obj -> field:
|
||||
# x -> x: true
|
||||
# x -> x.f: true
|
||||
# x.f -> x: false
|
||||
# x.f -> x.f: true
|
||||
# x.f -> x.v: false
|
||||
# x -> x[]: true
|
||||
# x[] -> x: false
|
||||
# x -> x[0]: true
|
||||
# x[0] -> x: false
|
||||
# x[0] -> x[0]: true
|
||||
# x[0] -> x[1]: false
|
||||
# x -> x[i]: true
|
||||
# x[i] -> x: false
|
||||
# x[i] -> x[i]: maybe; Further analysis could make this return true when i is a runtime-constant
|
||||
# x[i] -> x[j]: maybe; also returns maybe if only one of i or j is a compiletime-constant
|
||||
template collectImportantNodes(result, n) =
|
||||
var result: seq[PNode]
|
||||
var n = n
|
||||
while true:
|
||||
case n.kind
|
||||
of PathKinds0 - {nkDotExpr, nkBracketExpr, nkDerefExpr, nkHiddenDeref}:
|
||||
n = n[0]
|
||||
of PathKinds1:
|
||||
n = n[1]
|
||||
of nkDotExpr, nkBracketExpr, nkDerefExpr, nkHiddenDeref:
|
||||
result.add n
|
||||
n = n[0]
|
||||
of nkSym:
|
||||
result.add n
|
||||
break
|
||||
else: return no
|
||||
|
||||
collectImportantNodes(objImportantNodes, obj)
|
||||
collectImportantNodes(fieldImportantNodes, field)
|
||||
|
||||
# If field is less nested than obj, then it cannot be part of/aliased by obj
|
||||
if fieldImportantNodes.len < objImportantNodes.len: return no
|
||||
|
||||
result = yes
|
||||
for i in 1..objImportantNodes.len:
|
||||
# We compare the nodes leading to the location of obj and field
|
||||
# with each other.
|
||||
# We continue until they diverge, in which case we return no, or
|
||||
# until we reach the location of obj, in which case we do not need
|
||||
# to look further, since field must be part of/aliased by obj now.
|
||||
# If we encounter an element access using an index which is a runtime value,
|
||||
# we simply return maybe instead of yes; should further nodes not diverge.
|
||||
let currFieldPath = fieldImportantNodes[^i]
|
||||
let currObjPath = objImportantNodes[^i]
|
||||
|
||||
if currFieldPath.kind != currObjPath.kind:
|
||||
return no
|
||||
|
||||
case currFieldPath.kind
|
||||
of nkSym:
|
||||
if currFieldPath.sym != currObjPath.sym: return no
|
||||
of nkDotExpr:
|
||||
if currFieldPath[1].sym != currObjPath[1].sym: return no
|
||||
of nkDerefExpr, nkHiddenDeref:
|
||||
discard
|
||||
of nkBracketExpr:
|
||||
if currFieldPath[1].kind in nkLiterals and currObjPath[1].kind in nkLiterals:
|
||||
if currFieldPath[1].intVal != currObjPath[1].intVal:
|
||||
return no
|
||||
else:
|
||||
result = maybe
|
||||
else: assert false # unreachable
|
||||
|
||||
168
compiler/aliases.html
Normal file
168
compiler/aliases.html
Normal file
|
|
@ -0,0 +1,168 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<!-- This file is generated by Nim. -->
|
||||
<html xmlns="https://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>compiler/aliases</title>
|
||||
|
||||
<!-- Favicon -->
|
||||
<link rel="shortcut icon" href="data:image/x-icon;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAUAAAAF////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAIAAABbAAAAlQAAAKIAAACbAAAAmwAAAKIAAACVAAAAWwAAAAL///8A////AP///wD///8A////AAAAABQAAADAAAAAYwAAAA3///8A////AP///wD///8AAAAADQAAAGMAAADAAAAAFP///wD///8A////AP///wAAAACdAAAAOv///wD///8A////AP///wD///8A////AP///wD///8AAAAAOgAAAJ3///8A////AP///wAAAAAnAAAAcP///wAAAAAoAAAASv///wD///8A////AP///wAAAABKAAAAKP///wAAAABwAAAAJ////wD///8AAAAAgQAAABwAAACIAAAAkAAAAJMAAACtAAAAFQAAABUAAACtAAAAkwAAAJAAAACIAAAAHAAAAIH///8A////AAAAAKQAAACrAAAAaP///wD///8AAAAARQAAANIAAADSAAAARf///wD///8AAAAAaAAAAKsAAACk////AAAAADMAAACcAAAAnQAAABj///8A////AP///wAAAAAYAAAAGP///wD///8A////AAAAABgAAACdAAAAnAAAADMAAAB1AAAAwwAAAP8AAADpAAAAsQAAAE4AAAAb////AP///wAAAAAbAAAATgAAALEAAADpAAAA/wAAAMMAAAB1AAAAtwAAAOkAAAD/AAAA/wAAAP8AAADvAAAA3gAAAN4AAADeAAAA3gAAAO8AAAD/AAAA/wAAAP8AAADpAAAAtwAAAGUAAAA/AAAA3wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAADfAAAAPwAAAGX///8A////AAAAAEgAAADtAAAAvwAAAL0AAADGAAAA7wAAAO8AAADGAAAAvQAAAL8AAADtAAAASP///wD///8A////AP///wD///8AAAAAO////wD///8A////AAAAAIcAAACH////AP///wD///8AAAAAO////wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A//8AAP//AAD4HwAA7/cAAN/7AAD//wAAoYUAAJ55AACf+QAAh+EAAAAAAADAAwAA4AcAAP5/AAD//wAA//8AAA=="/>
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAA3XAAAN1wFCKJt4AAAAB3RJTUUH4QQQEwksSS9ZWwAAAk1JREFUWMPtll2ITVEUx39nn/O7Y5qR8f05wtCUUr6ZIS++8pEnkZInPImneaCQ5METNdOkeFBKUhMPRIkHKfEuUZSUlGlKPN2TrgfncpvmnntnmlEyq1Z7t89/rf9a6+y99oZxGZf/XeIq61EdtgKXgdXA0xrYAvBjOIF1AI9zvjcC74BSpndrJPkBWDScTF8Aa4E3wDlgHbASaANmVqlcCnwHvgDvgVfAJ+AikAAvgfVZwLnSVZHZaOuKoQi3ZOMi4NkYkpe1p4J7A8BpYAD49hfIy/oqG0+hLomiKP2L5L+1ubn5115S+3OAn4EnwBlgMzCjyt6ZAnQCJ4A7wOs88iRJHvw50HoujuPBoCKwHWiosy8MdfZnAdcHk8dxXFJ3VQbQlCTJvRBCGdRbD4M6uc5glpY3eAihpN5S5w12diSEcCCEcKUO4ljdr15T76ur1FDDLIQQ3qv71EdDOe3Kxj3leRXyk+pxdWnFWod6Wt2bY3de3aSuUHcPBVimHs7mK9WrmeOF6lR1o9qnzskh2ar2qm1qizpfXaPeVGdlmGN5pb09qMxz1Xb1kLqgzn1RyH7JUXW52lr5e/Kqi9qpto7V1atuUzfnARrV7jEib1T76gG2qxdGmXyiekkt1GswPTtek0aBfJp6YySGBfWg2tPQ0FAYgf1stUfdmdcjarbYJEniKIq6gY/Aw+zWHAC+p2labGpqiorFYgGYCEzN7oQdQClN07O1/EfDyGgC0ALMBdYAi4FyK+4H3gLPsxfR1zRNi+NP7nH5J+QntnXe5B5mpfQAAAAASUVORK5CYII=">
|
||||
|
||||
<!-- CSS -->
|
||||
<link rel="stylesheet" type="text/css" href="nimdoc.out.css">
|
||||
|
||||
<!-- JS -->
|
||||
<script type="text/javascript" src="dochack.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="document" id="documentId">
|
||||
<div class="container">
|
||||
<h1 class="title">compiler/aliases</h1>
|
||||
<div class="row">
|
||||
<div class="three columns">
|
||||
<div class="theme-select-wrapper">
|
||||
<label for="theme-select">Theme: </label>
|
||||
<select id="theme-select" onchange="setTheme(this.value)">
|
||||
<option value="auto">🌗 Match OS</option>
|
||||
<option value="dark">🌑 Dark</option>
|
||||
<option value="light">🌕 Light</option>
|
||||
</select>
|
||||
</div>
|
||||
<div id="global-links">
|
||||
<ul class="simple">
|
||||
<li><a id="indexLink" href="theindex.html">Index</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="searchInputDiv">
|
||||
Search: <input type="search" id="searchInput" onkeyup="search()"/>
|
||||
</div>
|
||||
<div>
|
||||
Group by:
|
||||
<select onchange="groupBy(this.value)">
|
||||
<option value="section">Section</option>
|
||||
<option value="type">Type</option>
|
||||
</select>
|
||||
</div>
|
||||
<ul class="simple simple-toc" id="toc-list">
|
||||
<li>
|
||||
<a class="reference reference-toplevel" href="#6" id="56">Imports</a>
|
||||
</li>
|
||||
<li>
|
||||
<details open>
|
||||
<summary><a class="reference reference-toplevel" href="#7" id="57">Types</a></summary>
|
||||
<ul class="simple simple-toc-section">
|
||||
<li><a class="reference" href="#TAnalysisResult" title="TAnalysisResult = enum
|
||||
arNo, arMaybe, arYes">TAnalysisResult</a></li>
|
||||
|
||||
</ul>
|
||||
</details>
|
||||
</li>
|
||||
<li>
|
||||
<details open>
|
||||
<summary><a class="reference reference-toplevel" href="#12" id="62">Procs</a></summary>
|
||||
<ul class="simple simple-toc-section">
|
||||
<ul class="simple nested-toc-section">isPartOf
|
||||
<li><a class="reference" href="#isPartOf%2CPNode%2CPNode" title="isPartOf(a, b: PNode): TAnalysisResult">isPartOf(a, b: PNode): TAnalysisResult</a></li>
|
||||
|
||||
</ul>
|
||||
|
||||
</ul>
|
||||
</details>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
<div class="nine columns" id="content">
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/compiler/aliases.nim#L1" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/compiler/aliases.nim#L1" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
<div id="tocRoot"></div>
|
||||
|
||||
<p class="module-desc">Simple alias analysis for the HLO and the code generators.</p>
|
||||
<div class="section" id="6">
|
||||
<h1><a class="toc-backref" href="#6">Imports</a></h1>
|
||||
<dl class="item">
|
||||
<a class="reference external" href="ast.html">ast</a>, <a class="reference external" href="astalgo.html">astalgo</a>, <a class="reference external" href="types.html">types</a>, <a class="reference external" href="trees.html">trees</a>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="section" id="7">
|
||||
<h1><a class="toc-backref" href="#7">Types</a></h1>
|
||||
<dl class="item">
|
||||
<div id="TAnalysisResult">
|
||||
<dt><pre><a href="aliases.html#TAnalysisResult"><span class="Identifier">TAnalysisResult</span></a> <span class="Other">=</span> <span class="Keyword">enum</span>
|
||||
<span class="Identifier">arNo</span><span class="Other">,</span> <span class="Identifier">arMaybe</span><span class="Other">,</span> <span class="Identifier">arYes</span></pre></dt>
|
||||
<dd>
|
||||
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/compiler/aliases.nim#L19" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/compiler/aliases.nim#L19" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</dl>
|
||||
</div>
|
||||
<div class="section" id="12">
|
||||
<h1><a class="toc-backref" href="#12">Procs</a></h1>
|
||||
<dl class="item">
|
||||
<div id="isPartOf-procs-all">
|
||||
<div id="isPartOf,PNode,PNode">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#isPartOf%2CPNode%2CPNode"><span class="Identifier">isPartOf</span></a><span class="Other">(</span><span class="Identifier">a</span><span class="Other">,</span> <span class="Identifier">b</span><span class="Other">:</span> <a href="ast.html#PNode"><span class="Identifier">PNode</span></a><span class="Other">)</span><span class="Other">:</span> <a href="aliases.html#TAnalysisResult"><span class="Identifier">TAnalysisResult</span></a> {.
|
||||
<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">KeyError</span><span class="Other">,</span> <span class="Identifier">Exception</span><span class="Other">,</span> <span class="Identifier">ERecoverableError</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">RootEffect</span><span class="Other">]</span><span class="Other">,</span>
|
||||
<span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
<p>checks if location <tt class="docutils literal"><span class="pre"><span class="Identifier">a</span></span></tt> can be part of location <tt class="docutils literal"><span class="pre"><span class="Identifier">b</span></span></tt>. We treat seqs and strings as pointers because the code gen often just passes them as such.</p>
|
||||
<p>Note: <tt class="docutils literal"><span class="pre"><span class="Identifier">a</span></span></tt> can only be part of <tt class="docutils literal"><span class="pre"><span class="Identifier">b</span></span></tt>, if <tt class="docutils literal"><span class="pre"><span class="Identifier">a</span></span></tt>'s type can be part of <tt class="docutils literal"><span class="pre"><span class="Identifier">b</span></span></tt>'s type. Since however type analysis is more expensive, we perform it only if necessary.</p>
|
||||
<p>cases:</p>
|
||||
<p>YES-cases:</p>
|
||||
<p><pre class="listing">
|
||||
<span class="Identifier">x</span> <span class="Operator"><|</span> <span class="Identifier">x</span> <span class="Comment"># for general trees</span>
|
||||
<span class="Identifier">x</span><span class="Punctuation">[</span><span class="Punctuation">]</span> <span class="Operator"><|</span> <span class="Identifier">x</span>
|
||||
<span class="Identifier">x</span><span class="Punctuation">[</span><span class="Identifier">i</span><span class="Punctuation">]</span> <span class="Operator"><|</span> <span class="Identifier">x</span>
|
||||
<span class="Identifier">x</span><span class="Operator">.</span><span class="Identifier">f</span> <span class="Operator"><|</span> <span class="Identifier">x</span></pre></p>
|
||||
<p>NO-cases:</p>
|
||||
<p><pre class="listing">
|
||||
<span class="Identifier">x</span> <span class="Operator">!<|</span> <span class="Identifier">y</span> <span class="Comment"># depending on type and symbol kind</span>
|
||||
<span class="Identifier">x</span><span class="Punctuation">[</span><span class="Identifier">constA</span><span class="Punctuation">]</span> <span class="Operator">!<|</span> <span class="Identifier">x</span><span class="Punctuation">[</span><span class="Identifier">constB</span><span class="Punctuation">]</span>
|
||||
<span class="Identifier">x</span><span class="Operator">.</span><span class="Identifier">f</span> <span class="Operator">!<|</span> <span class="Identifier">x</span><span class="Operator">.</span><span class="Identifier">g</span>
|
||||
<span class="Identifier">x</span><span class="Operator">.</span><span class="Identifier">f</span> <span class="Operator">!<|</span> <span class="Identifier">y</span><span class="Operator">.</span><span class="Identifier">f</span> <span class="Identifier">iff</span> <span class="Identifier">x</span> <span class="Operator">!<=</span> <span class="Identifier">y</span></pre></p>
|
||||
<p>MAYBE-cases:</p>
|
||||
<p><pre class="listing">
|
||||
<span class="Identifier">x</span><span class="Punctuation">[</span><span class="Punctuation">]</span> <span class="Operator">?<|</span> <span class="Identifier">y</span><span class="Punctuation">[</span><span class="Punctuation">]</span> <span class="Identifier">iff</span> <span class="Identifier">compatible</span> <span class="Keyword">type</span>
|
||||
|
||||
|
||||
<span class="Identifier">x</span><span class="Punctuation">[</span><span class="Punctuation">]</span> <span class="Operator">?<|</span> <span class="Identifier">y</span> <span class="Identifier">depending</span> <span class="Identifier">on</span> <span class="Keyword">type</span></pre></p>
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/compiler/aliases.nim#L69" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/compiler/aliases.nim#L69" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="twelve-columns footer">
|
||||
<span class="nim-sprite"></span>
|
||||
<br>
|
||||
<small style="color: var(--hint);">Made with Nim. Generated: 2023-03-13 00:20:14 UTC</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script defer data-domain="nim-lang.org" src="https://plausible.io/js/plausible.js"></script>
|
||||
|
||||
<!-- Google fonts -->
|
||||
<link href='https://fonts.googleapis.com/css?family=Lato:400,600,900' rel='stylesheet' type='text/css'/>
|
||||
<link href='https://fonts.googleapis.com/css?family=Source+Code+Pro:400,500,600' rel='stylesheet' type='text/css'/>
|
||||
</body>
|
||||
</html>
|
||||
6
compiler/aliases.idx
Normal file
6
compiler/aliases.idx
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
nimTitle aliases aliases.html module compiler/aliases 0
|
||||
nim arNo aliases.html#arNo TAnalysisResult.arNo 19
|
||||
nim arMaybe aliases.html#arMaybe TAnalysisResult.arMaybe 19
|
||||
nim arYes aliases.html#arYes TAnalysisResult.arYes 19
|
||||
nim TAnalysisResult aliases.html#TAnalysisResult enum TAnalysisResult 19
|
||||
nim isPartOf aliases.html#isPartOf,PNode,PNode proc isPartOf(a, b: PNode): TAnalysisResult 69
|
||||
|
|
@ -1,207 +0,0 @@
|
|||
#
|
||||
#
|
||||
# The Nim Compiler
|
||||
# (c) Copyright 2012 Andreas Rumpf
|
||||
#
|
||||
# See the file "copying.txt", included in this
|
||||
# distribution, for details about the copyright.
|
||||
#
|
||||
|
||||
## Simple alias analysis for the HLO and the code generators.
|
||||
|
||||
import
|
||||
ast, astalgo, types, trees, intsets
|
||||
|
||||
when defined(nimPreviewSlimSystem):
|
||||
import std/assertions
|
||||
|
||||
type
|
||||
TAnalysisResult* = enum
|
||||
arNo, arMaybe, arYes
|
||||
|
||||
proc isPartOfAux(a, b: PType, marker: var IntSet): TAnalysisResult
|
||||
|
||||
proc isPartOfAux(n: PNode, b: PType, marker: var IntSet): TAnalysisResult =
|
||||
result = arNo
|
||||
case n.kind
|
||||
of nkRecList:
|
||||
for i in 0..<n.len:
|
||||
result = isPartOfAux(n[i], b, marker)
|
||||
if result == arYes: return
|
||||
of nkRecCase:
|
||||
assert(n[0].kind == nkSym)
|
||||
result = isPartOfAux(n[0], b, marker)
|
||||
if result == arYes: return
|
||||
for i in 1..<n.len:
|
||||
case n[i].kind
|
||||
of nkOfBranch, nkElse:
|
||||
result = isPartOfAux(lastSon(n[i]), b, marker)
|
||||
if result == arYes: return
|
||||
else: discard "isPartOfAux(record case branch)"
|
||||
of nkSym:
|
||||
result = isPartOfAux(n.sym.typ, b, marker)
|
||||
else: discard
|
||||
|
||||
proc isPartOfAux(a, b: PType, marker: var IntSet): TAnalysisResult =
|
||||
result = arNo
|
||||
if a == nil or b == nil: return
|
||||
if containsOrIncl(marker, a.id): return
|
||||
if compareTypes(a, b, dcEqIgnoreDistinct): return arYes
|
||||
case a.kind
|
||||
of tyObject:
|
||||
if a[0] != nil:
|
||||
result = isPartOfAux(a[0].skipTypes(skipPtrs), b, marker)
|
||||
if result == arNo: result = isPartOfAux(a.n, b, marker)
|
||||
of tyGenericInst, tyDistinct, tyAlias, tySink:
|
||||
result = isPartOfAux(lastSon(a), b, marker)
|
||||
of tyArray, tySet, tyTuple:
|
||||
for i in 0..<a.len:
|
||||
result = isPartOfAux(a[i], b, marker)
|
||||
if result == arYes: return
|
||||
else: discard
|
||||
|
||||
proc isPartOf(a, b: PType): TAnalysisResult =
|
||||
## checks iff 'a' can be part of 'b'. Iterates over VALUE types!
|
||||
var marker = initIntSet()
|
||||
# watch out: parameters reversed because I'm too lazy to change the code...
|
||||
result = isPartOfAux(b, a, marker)
|
||||
|
||||
proc isPartOf*(a, b: PNode): TAnalysisResult =
|
||||
## checks if location `a` can be part of location `b`. We treat seqs and
|
||||
## strings as pointers because the code gen often just passes them as such.
|
||||
##
|
||||
## Note: `a` can only be part of `b`, if `a`'s type can be part of `b`'s
|
||||
## type. Since however type analysis is more expensive, we perform it only
|
||||
## if necessary.
|
||||
##
|
||||
## cases:
|
||||
##
|
||||
## YES-cases:
|
||||
## ```
|
||||
## x <| x # for general trees
|
||||
## x[] <| x
|
||||
## x[i] <| x
|
||||
## x.f <| x
|
||||
## ```
|
||||
##
|
||||
## NO-cases:
|
||||
## ```
|
||||
## x !<| y # depending on type and symbol kind
|
||||
## x[constA] !<| x[constB]
|
||||
## x.f !<| x.g
|
||||
## x.f !<| y.f iff x !<= y
|
||||
## ```
|
||||
##
|
||||
## MAYBE-cases:
|
||||
##
|
||||
## ```
|
||||
## x[] ?<| y[] iff compatible type
|
||||
##
|
||||
##
|
||||
## x[] ?<| y depending on type
|
||||
## ```
|
||||
if a.kind == b.kind:
|
||||
case a.kind
|
||||
of nkSym:
|
||||
const varKinds = {skVar, skTemp, skProc, skFunc}
|
||||
# same symbol: aliasing:
|
||||
if a.sym.id == b.sym.id: result = arYes
|
||||
elif a.sym.kind in varKinds or b.sym.kind in varKinds:
|
||||
# actually, a param could alias a var but we know that cannot happen
|
||||
# here. XXX make this more generic
|
||||
result = arNo
|
||||
else:
|
||||
# use expensive type check:
|
||||
if isPartOf(a.sym.typ, b.sym.typ) != arNo:
|
||||
result = arMaybe
|
||||
of nkBracketExpr:
|
||||
result = isPartOf(a[0], b[0])
|
||||
if a.len >= 2 and b.len >= 2:
|
||||
# array accesses:
|
||||
if result == arYes and isDeepConstExpr(a[1]) and isDeepConstExpr(b[1]):
|
||||
# we know it's the same array and we have 2 constant indexes;
|
||||
# if they are
|
||||
var x = if a[1].kind == nkHiddenStdConv: a[1][1] else: a[1]
|
||||
var y = if b[1].kind == nkHiddenStdConv: b[1][1] else: b[1]
|
||||
|
||||
if sameValue(x, y): result = arYes
|
||||
else: result = arNo
|
||||
# else: maybe and no are accurate
|
||||
else:
|
||||
# pointer derefs:
|
||||
if result != arYes:
|
||||
if isPartOf(a.typ, b.typ) != arNo: result = arMaybe
|
||||
|
||||
of nkDotExpr:
|
||||
result = isPartOf(a[0], b[0])
|
||||
if result != arNo:
|
||||
# if the fields are different, it's not the same location
|
||||
if a[1].sym.id != b[1].sym.id:
|
||||
result = arNo
|
||||
|
||||
of nkHiddenDeref, nkDerefExpr:
|
||||
result = isPartOf(a[0], b[0])
|
||||
# weaken because of indirection:
|
||||
if result != arYes:
|
||||
if isPartOf(a.typ, b.typ) != arNo: result = arMaybe
|
||||
|
||||
of nkHiddenStdConv, nkHiddenSubConv, nkConv:
|
||||
result = isPartOf(a[1], b[1])
|
||||
of nkObjUpConv, nkObjDownConv, nkCheckedFieldExpr:
|
||||
result = isPartOf(a[0], b[0])
|
||||
else: discard
|
||||
# Calls return a new location, so a default of ``arNo`` is fine.
|
||||
else:
|
||||
# go down recursively; this is quite demanding:
|
||||
const
|
||||
Ix0Kinds = {nkDotExpr, nkBracketExpr, nkObjUpConv, nkObjDownConv,
|
||||
nkCheckedFieldExpr, nkHiddenAddr}
|
||||
Ix1Kinds = {nkHiddenStdConv, nkHiddenSubConv, nkConv}
|
||||
DerefKinds = {nkHiddenDeref, nkDerefExpr}
|
||||
case b.kind
|
||||
of Ix0Kinds:
|
||||
# a* !<| b.f iff a* !<| b
|
||||
result = isPartOf(a, b[0])
|
||||
|
||||
of DerefKinds:
|
||||
# a* !<| b[] iff
|
||||
if isPartOf(a.typ, b.typ) != arNo:
|
||||
result = isPartOf(a, b[0])
|
||||
if result == arNo: result = arMaybe
|
||||
|
||||
of Ix1Kinds:
|
||||
# a* !<| T(b) iff a* !<| b
|
||||
result = isPartOf(a, b[1])
|
||||
|
||||
of nkSym:
|
||||
# b is an atom, so we have to check a:
|
||||
case a.kind
|
||||
of Ix0Kinds:
|
||||
# a.f !<| b* iff a.f !<| b*
|
||||
result = isPartOf(a[0], b)
|
||||
of Ix1Kinds:
|
||||
result = isPartOf(a[1], b)
|
||||
|
||||
of DerefKinds:
|
||||
if isPartOf(a.typ, b.typ) != arNo:
|
||||
result = isPartOf(a[0], b)
|
||||
if result == arNo: result = arMaybe
|
||||
else: discard
|
||||
of nkObjConstr:
|
||||
result = arNo
|
||||
for i in 1..<b.len:
|
||||
let res = isPartOf(a, b[i][1])
|
||||
if res != arNo:
|
||||
result = res
|
||||
if res == arYes: break
|
||||
of nkCallKinds:
|
||||
result = arNo
|
||||
for i in 1..<b.len:
|
||||
let res = isPartOf(a, b[i])
|
||||
if res != arNo:
|
||||
result = res
|
||||
if res == arYes: break
|
||||
of nkBracket:
|
||||
if b.len > 0:
|
||||
result = isPartOf(a, b[0])
|
||||
else: discard
|
||||
4747
compiler/ast.html
Normal file
4747
compiler/ast.html
Normal file
File diff suppressed because one or more lines are too long
1005
compiler/ast.idx
Normal file
1005
compiler/ast.idx
Normal file
File diff suppressed because it is too large
Load diff
2141
compiler/ast.nim
2141
compiler/ast.nim
File diff suppressed because it is too large
Load diff
1211
compiler/astalgo.html
Normal file
1211
compiler/astalgo.html
Normal file
File diff suppressed because it is too large
Load diff
66
compiler/astalgo.idx
Normal file
66
compiler/astalgo.idx
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
nimTitle astalgo astalgo.html module compiler/astalgo 0
|
||||
nim hashNode astalgo.html#hashNode,RootRef proc hashNode(p: RootRef): Hash 23
|
||||
nim treeToYaml astalgo.html#treeToYaml,ConfigRef,PNode,int,int proc treeToYaml(conf: ConfigRef; n: PNode; indent: int = 0; maxRecDepth: int = -1): Rope 24
|
||||
nim typeToYaml astalgo.html#typeToYaml,ConfigRef,PType,int,int proc typeToYaml(conf: ConfigRef; n: PType; indent: int = 0; maxRecDepth: int = -1): Rope 28
|
||||
nim symToYaml astalgo.html#symToYaml,ConfigRef,PSym,int,int proc symToYaml(conf: ConfigRef; n: PSym; indent: int = 0; maxRecDepth: int = -1): Rope 29
|
||||
nim lineInfoToStr astalgo.html#lineInfoToStr,ConfigRef,TLineInfo proc lineInfoToStr(conf: ConfigRef; info: TLineInfo): Rope 30
|
||||
nim debug astalgo.html#debug,PSym,ConfigRef proc debug(n: PSym; conf: ConfigRef = nil) 35
|
||||
nim debug astalgo.html#debug,PType,ConfigRef proc debug(n: PType; conf: ConfigRef = nil) 36
|
||||
nim debug astalgo.html#debug,PNode,ConfigRef proc debug(n: PNode; conf: ConfigRef = nil) 37
|
||||
nim typekinds astalgo.html#typekinds,PType proc typekinds(t: PType) 39
|
||||
nim debug astalgo.html#debug.t template debug(x: PSym | PType | PNode) 48
|
||||
nim debug astalgo.html#debug.t,auto template debug(x: auto) 56
|
||||
nim mdbg astalgo.html#mdbg.t template mdbg(): bool 59
|
||||
nim idTableGet astalgo.html#idTableGet,TIdTable,PIdObj proc idTableGet(t: TIdTable; key: PIdObj): RootRef 83
|
||||
nim idTableGet astalgo.html#idTableGet,TIdTable,int proc idTableGet(t: TIdTable; key: int): RootRef 84
|
||||
nim idTablePut astalgo.html#idTablePut,TIdTable,PIdObj,RootRef proc idTablePut(t: var TIdTable; key: PIdObj; val: RootRef) 85
|
||||
nim idTableHasObjectAsKey astalgo.html#idTableHasObjectAsKey,TIdTable,PIdObj proc idTableHasObjectAsKey(t: TIdTable; key: PIdObj): bool 86
|
||||
nim idNodeTableGet astalgo.html#idNodeTableGet,TIdNodeTable,PIdObj proc idNodeTableGet(t: TIdNodeTable; key: PIdObj): PNode 89
|
||||
nim idNodeTablePut astalgo.html#idNodeTablePut,TIdNodeTable,PIdObj,PNode proc idNodeTablePut(t: var TIdNodeTable; key: PIdObj; val: PNode) 90
|
||||
nim lookupInRecord astalgo.html#lookupInRecord,PNode,PIdent proc lookupInRecord(n: PNode; field: PIdent): PSym 94
|
||||
nim mustRehash astalgo.html#mustRehash,int,int proc mustRehash(length, counter: int): bool 95
|
||||
nim nextTry astalgo.html#nextTry,Hash,Hash proc nextTry(h, maxHash: Hash): Hash 96
|
||||
nim InvalidKey astalgo.html#InvalidKey const InvalidKey 100
|
||||
nim TIIPair astalgo.html#TIIPair object TIIPair 103
|
||||
nim TIIPairSeq astalgo.html#TIIPairSeq type TIIPairSeq 106
|
||||
nim TIITable astalgo.html#TIITable object TIITable 107
|
||||
nim initIiTable astalgo.html#initIiTable,TIITable proc initIiTable(x: var TIITable) 112
|
||||
nim iiTableGet astalgo.html#iiTableGet,TIITable,int proc iiTableGet(t: TIITable; key: int): int 113
|
||||
nim iiTablePut astalgo.html#iiTablePut,TIITable,int,int proc iiTablePut(t: var TIITable; key, val: int) 114
|
||||
nim skipConvCastAndClosure astalgo.html#skipConvCastAndClosure,PNode proc skipConvCastAndClosure(n: PNode): PNode 118
|
||||
nim sameValue astalgo.html#sameValue,PNode,PNode proc sameValue(a, b: PNode): bool 129
|
||||
nim leValue astalgo.html#leValue,PNode,PNode proc leValue(a, b: PNode): bool 143
|
||||
nim weakLeValue astalgo.html#weakLeValue,PNode,PNode proc weakLeValue(a, b: PNode): TImplication 158
|
||||
nim getModule astalgo.html#getModule,PSym proc getModule(s: PSym): PSym 185
|
||||
nim fromSystem astalgo.html#fromSystem,PSym proc fromSystem(op: PSym): bool 190
|
||||
nim getSymFromList astalgo.html#getSymFromList,PNode,PIdent,int proc getSymFromList(list: PNode; ident: PIdent; start: int = 0): PSym 191
|
||||
nim getNamedParamFromList astalgo.html#getNamedParamFromList,PNode,PIdent proc getNamedParamFromList(list: PNode; ident: PIdent): PSym 225
|
||||
nim makeYamlString astalgo.html#makeYamlString,string proc makeYamlString(s: string): Rope 255
|
||||
nim objectSetContains astalgo.html#objectSetContains,TObjectSet,RootRef proc objectSetContains(t: TObjectSet; obj: RootRef): bool 676
|
||||
nim objectSetIncl astalgo.html#objectSetIncl,TObjectSet,RootRef proc objectSetIncl(t: var TObjectSet; obj: RootRef) 700
|
||||
nim objectSetContainsOrIncl astalgo.html#objectSetContainsOrIncl,TObjectSet,RootRef proc objectSetContainsOrIncl(t: var TObjectSet; obj: RootRef): bool 705
|
||||
nim strTableContains astalgo.html#strTableContains,TStrTable,PSym proc strTableContains(t: TStrTable; n: PSym): bool 723
|
||||
nim symTabReplace astalgo.html#symTabReplace,TStrTable,PSym,PSym proc symTabReplace(t: var TStrTable; prevSym: PSym; newSym: PSym) 752
|
||||
nim strTableAdd astalgo.html#strTableAdd,TStrTable,PSym proc strTableAdd(t: var TStrTable; n: PSym) 762
|
||||
nim strTableInclReportConflict astalgo.html#strTableInclReportConflict,TStrTable,PSym proc strTableInclReportConflict(t: var TStrTable; n: PSym; onConflictKeepOld = false): PSym 767
|
||||
nim strTableIncl astalgo.html#strTableIncl,TStrTable,PSym proc strTableIncl(t: var TStrTable; n: PSym; onConflictKeepOld = false): bool 800
|
||||
nim strTableGet astalgo.html#strTableGet,TStrTable,PIdent proc strTableGet(t: TStrTable; name: PIdent): PSym 804
|
||||
nim TIdentIter astalgo.html#TIdentIter object TIdentIter 814
|
||||
nim nextIdentIter astalgo.html#nextIdentIter,TIdentIter,TStrTable proc nextIdentIter(ti: var TIdentIter; tab: TStrTable): PSym 818
|
||||
nim initIdentIter astalgo.html#initIdentIter,TIdentIter,TStrTable,PIdent proc initIdentIter(ti: var TIdentIter; tab: TStrTable; s: PIdent): PSym 836
|
||||
nim nextIdentExcluding astalgo.html#nextIdentExcluding,TIdentIter,TStrTable,IntSet proc nextIdentExcluding(ti: var TIdentIter; tab: TStrTable; excluding: IntSet): PSym 842
|
||||
nim firstIdentExcluding astalgo.html#firstIdentExcluding,TIdentIter,TStrTable,PIdent,IntSet proc firstIdentExcluding(ti: var TIdentIter; tab: TStrTable; s: PIdent;\n excluding: IntSet): PSym 858
|
||||
nim TTabIter astalgo.html#TTabIter object TTabIter 866
|
||||
nim nextIter astalgo.html#nextIter,TTabIter,TStrTable proc nextIter(ti: var TTabIter; tab: TStrTable): PSym 869
|
||||
nim initTabIter astalgo.html#initTabIter,TTabIter,TStrTable proc initTabIter(ti: var TTabIter; tab: TStrTable): PSym 885
|
||||
nim items astalgo.html#items.i,TStrTable iterator items(tab: TStrTable): PSym 892
|
||||
nim pairs astalgo.html#pairs.i,TIdTable iterator pairs(t: TIdTable): tuple[key: int, value: RootRef] 929
|
||||
nim idTablePairs astalgo.html#idTablePairs.i,TIdTable iterator idTablePairs(t: TIdTable): tuple[key: PIdObj, val: RootRef] 963
|
||||
nim pairs astalgo.html#pairs.i,TIdNodeTable iterator pairs(t: TIdNodeTable): tuple[key: PIdObj, val: PNode] 1008
|
||||
nim isAddrNode astalgo.html#isAddrNode,PNode proc isAddrNode(n: PNode): bool 1057
|
||||
nim listSymbolNames astalgo.html#listSymbolNames,openArray[PSym] proc listSymbolNames(symbols: openArray[PSym]): string 1065
|
||||
nim isDiscriminantField astalgo.html#isDiscriminantField,PNode proc isDiscriminantField(n: PNode): bool 1071
|
||||
nimgrp debug astalgo.html#debug-procs-all proc 35
|
||||
nimgrp idtableget astalgo.html#idTableGet-procs-all proc 83
|
||||
nimgrp pairs astalgo.html#pairs-iterators-all iterator 929
|
||||
nimgrp debug astalgo.html#debug-templates-all template 48
|
||||
1074
compiler/astalgo.nim
1074
compiler/astalgo.nim
File diff suppressed because it is too large
Load diff
232
compiler/astmsgs.html
Normal file
232
compiler/astmsgs.html
Normal file
|
|
@ -0,0 +1,232 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<!-- This file is generated by Nim. -->
|
||||
<html xmlns="https://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>compiler/astmsgs</title>
|
||||
|
||||
<!-- Favicon -->
|
||||
<link rel="shortcut icon" href="data:image/x-icon;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAUAAAAF////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAIAAABbAAAAlQAAAKIAAACbAAAAmwAAAKIAAACVAAAAWwAAAAL///8A////AP///wD///8A////AAAAABQAAADAAAAAYwAAAA3///8A////AP///wD///8AAAAADQAAAGMAAADAAAAAFP///wD///8A////AP///wAAAACdAAAAOv///wD///8A////AP///wD///8A////AP///wD///8AAAAAOgAAAJ3///8A////AP///wAAAAAnAAAAcP///wAAAAAoAAAASv///wD///8A////AP///wAAAABKAAAAKP///wAAAABwAAAAJ////wD///8AAAAAgQAAABwAAACIAAAAkAAAAJMAAACtAAAAFQAAABUAAACtAAAAkwAAAJAAAACIAAAAHAAAAIH///8A////AAAAAKQAAACrAAAAaP///wD///8AAAAARQAAANIAAADSAAAARf///wD///8AAAAAaAAAAKsAAACk////AAAAADMAAACcAAAAnQAAABj///8A////AP///wAAAAAYAAAAGP///wD///8A////AAAAABgAAACdAAAAnAAAADMAAAB1AAAAwwAAAP8AAADpAAAAsQAAAE4AAAAb////AP///wAAAAAbAAAATgAAALEAAADpAAAA/wAAAMMAAAB1AAAAtwAAAOkAAAD/AAAA/wAAAP8AAADvAAAA3gAAAN4AAADeAAAA3gAAAO8AAAD/AAAA/wAAAP8AAADpAAAAtwAAAGUAAAA/AAAA3wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAADfAAAAPwAAAGX///8A////AAAAAEgAAADtAAAAvwAAAL0AAADGAAAA7wAAAO8AAADGAAAAvQAAAL8AAADtAAAASP///wD///8A////AP///wD///8AAAAAO////wD///8A////AAAAAIcAAACH////AP///wD///8AAAAAO////wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A//8AAP//AAD4HwAA7/cAAN/7AAD//wAAoYUAAJ55AACf+QAAh+EAAAAAAADAAwAA4AcAAP5/AAD//wAA//8AAA=="/>
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAA3XAAAN1wFCKJt4AAAAB3RJTUUH4QQQEwksSS9ZWwAAAk1JREFUWMPtll2ITVEUx39nn/O7Y5qR8f05wtCUUr6ZIS++8pEnkZInPImneaCQ5METNdOkeFBKUhMPRIkHKfEuUZSUlGlKPN2TrgfncpvmnntnmlEyq1Z7t89/rf9a6+y99oZxGZf/XeIq61EdtgKXgdXA0xrYAvBjOIF1AI9zvjcC74BSpndrJPkBWDScTF8Aa4E3wDlgHbASaANmVqlcCnwHvgDvgVfAJ+AikAAvgfVZwLnSVZHZaOuKoQi3ZOMi4NkYkpe1p4J7A8BpYAD49hfIy/oqG0+hLomiKP2L5L+1ubn5115S+3OAn4EnwBlgMzCjyt6ZAnQCJ4A7wOs88iRJHvw50HoujuPBoCKwHWiosy8MdfZnAdcHk8dxXFJ3VQbQlCTJvRBCGdRbD4M6uc5glpY3eAihpN5S5w12diSEcCCEcKUO4ljdr15T76ur1FDDLIQQ3qv71EdDOe3Kxj3leRXyk+pxdWnFWod6Wt2bY3de3aSuUHcPBVimHs7mK9WrmeOF6lR1o9qnzskh2ar2qm1qizpfXaPeVGdlmGN5pb09qMxz1Xb1kLqgzn1RyH7JUXW52lr5e/Kqi9qpto7V1atuUzfnARrV7jEib1T76gG2qxdGmXyiekkt1GswPTtek0aBfJp6YySGBfWg2tPQ0FAYgf1stUfdmdcjarbYJEniKIq6gY/Aw+zWHAC+p2labGpqiorFYgGYCEzN7oQdQClN07O1/EfDyGgC0ALMBdYAi4FyK+4H3gLPsxfR1zRNi+NP7nH5J+QntnXe5B5mpfQAAAAASUVORK5CYII=">
|
||||
|
||||
<!-- CSS -->
|
||||
<link rel="stylesheet" type="text/css" href="nimdoc.out.css">
|
||||
|
||||
<!-- JS -->
|
||||
<script type="text/javascript" src="dochack.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="document" id="documentId">
|
||||
<div class="container">
|
||||
<h1 class="title">compiler/astmsgs</h1>
|
||||
<div class="row">
|
||||
<div class="three columns">
|
||||
<div class="theme-select-wrapper">
|
||||
<label for="theme-select">Theme: </label>
|
||||
<select id="theme-select" onchange="setTheme(this.value)">
|
||||
<option value="auto">🌗 Match OS</option>
|
||||
<option value="dark">🌑 Dark</option>
|
||||
<option value="light">🌕 Light</option>
|
||||
</select>
|
||||
</div>
|
||||
<div id="global-links">
|
||||
<ul class="simple">
|
||||
<li><a id="indexLink" href="theindex.html">Index</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="searchInputDiv">
|
||||
Search: <input type="search" id="searchInput" onkeyup="search()"/>
|
||||
</div>
|
||||
<div>
|
||||
Group by:
|
||||
<select onchange="groupBy(this.value)">
|
||||
<option value="section">Section</option>
|
||||
<option value="type">Type</option>
|
||||
</select>
|
||||
</div>
|
||||
<ul class="simple simple-toc" id="toc-list">
|
||||
<li>
|
||||
<a class="reference reference-toplevel" href="#6" id="56">Imports</a>
|
||||
</li>
|
||||
<li>
|
||||
<details open>
|
||||
<summary><a class="reference reference-toplevel" href="#12" id="62">Procs</a></summary>
|
||||
<ul class="simple simple-toc-section">
|
||||
<ul class="simple nested-toc-section">addDeclaredLoc
|
||||
<li><a class="reference" href="#addDeclaredLoc%2Cstring%2CConfigRef%2CPSym" title="addDeclaredLoc(result: var string; conf: ConfigRef; sym: PSym)">addDeclaredLoc(result: var string; conf: ConfigRef; sym: PSym)</a></li>
|
||||
<li><a class="reference" href="#addDeclaredLoc%2Cstring%2CConfigRef%2CPType" title="addDeclaredLoc(result: var string; conf: ConfigRef; typ: PType)">addDeclaredLoc(result: var string; conf: ConfigRef; typ: PType)</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">addDeclaredLocMaybe
|
||||
<li><a class="reference" href="#addDeclaredLocMaybe%2Cstring%2CConfigRef%2CPSym" title="addDeclaredLocMaybe(result: var string; conf: ConfigRef; sym: PSym)">addDeclaredLocMaybe(result: var string; conf: ConfigRef; sym: PSym)</a></li>
|
||||
<li><a class="reference" href="#addDeclaredLocMaybe%2Cstring%2CConfigRef%2CPType" title="addDeclaredLocMaybe(result: var string; conf: ConfigRef; typ: PType)">addDeclaredLocMaybe(result: var string; conf: ConfigRef; typ: PType)</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">genFieldDefect
|
||||
<li><a class="reference" href="#genFieldDefect%2CConfigRef%2Cstring%2CPSym" title="genFieldDefect(conf: ConfigRef; field: string; disc: PSym): string">genFieldDefect(conf: ConfigRef; field: string; disc: PSym): string</a></li>
|
||||
|
||||
</ul>
|
||||
<ul class="simple nested-toc-section">typSym
|
||||
<li><a class="reference" href="#typSym%2CPType" title="typSym(t: PType): PSym">typSym(t: PType): PSym</a></li>
|
||||
|
||||
</ul>
|
||||
|
||||
</ul>
|
||||
</details>
|
||||
</li>
|
||||
<li>
|
||||
<details open>
|
||||
<summary><a class="reference reference-toplevel" href="#18" id="68">Templates</a></summary>
|
||||
<ul class="simple simple-toc-section">
|
||||
<ul class="simple nested-toc-section">quoteExpr
|
||||
<li><a class="reference" href="#quoteExpr.t%2Cstring" title="quoteExpr(a: string): untyped">quoteExpr(a: string): untyped</a></li>
|
||||
|
||||
</ul>
|
||||
|
||||
</ul>
|
||||
</details>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
<div class="nine columns" id="content">
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/compiler/astmsgs.nim#L1" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/compiler/astmsgs.nim#L1" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
<div id="tocRoot"></div>
|
||||
|
||||
<p class="module-desc"></p>
|
||||
<div class="section" id="6">
|
||||
<h1><a class="toc-backref" href="#6">Imports</a></h1>
|
||||
<dl class="item">
|
||||
<a class="reference external" href="options.html">options</a>, <a class="reference external" href="ast.html">ast</a>, <a class="reference external" href="msgs.html">msgs</a>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="section" id="12">
|
||||
<h1><a class="toc-backref" href="#12">Procs</a></h1>
|
||||
<dl class="item">
|
||||
<div id="addDeclaredLoc-procs-all">
|
||||
<div id="addDeclaredLoc,string,ConfigRef,PSym">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#addDeclaredLoc%2Cstring%2CConfigRef%2CPSym"><span class="Identifier">addDeclaredLoc</span></a><span class="Other">(</span><span class="Identifier">result</span><span class="Other">:</span> <span class="Keyword">var</span> <span class="Identifier">string</span><span class="Other">;</span> <span class="Identifier">conf</span><span class="Other">:</span> <a href="options.html#ConfigRef"><span class="Identifier">ConfigRef</span></a><span class="Other">;</span> <span class="Identifier">sym</span><span class="Other">:</span> <a href="ast.html#PSym"><span class="Identifier">PSym</span></a><span class="Other">)</span> {.
|
||||
<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ValueError</span><span class="Other">,</span> <span class="Identifier">Exception</span><span class="Other">,</span> <span class="Identifier">KeyError</span><span class="Other">]</span><span class="Other">,</span>
|
||||
<span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">RootEffect</span><span class="Other">,</span> <span class="Identifier">ReadDirEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/compiler/astmsgs.nim#L10" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/compiler/astmsgs.nim#L10" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
<div id="addDeclaredLoc,string,ConfigRef,PType">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#addDeclaredLoc%2Cstring%2CConfigRef%2CPType"><span class="Identifier">addDeclaredLoc</span></a><span class="Other">(</span><span class="Identifier">result</span><span class="Other">:</span> <span class="Keyword">var</span> <span class="Identifier">string</span><span class="Other">;</span> <span class="Identifier">conf</span><span class="Other">:</span> <a href="options.html#ConfigRef"><span class="Identifier">ConfigRef</span></a><span class="Other">;</span> <span class="Identifier">typ</span><span class="Other">:</span> <a href="ast.html#PType"><span class="Identifier">PType</span></a><span class="Other">)</span> {.
|
||||
<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ValueError</span><span class="Other">,</span> <span class="Identifier">Exception</span><span class="Other">,</span> <span class="Identifier">KeyError</span><span class="Other">]</span><span class="Other">,</span>
|
||||
<span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">RootEffect</span><span class="Other">,</span> <span class="Identifier">ReadDirEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/compiler/astmsgs.nim#L17" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/compiler/astmsgs.nim#L17" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="addDeclaredLocMaybe-procs-all">
|
||||
<div id="addDeclaredLocMaybe,string,ConfigRef,PSym">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#addDeclaredLocMaybe%2Cstring%2CConfigRef%2CPSym"><span class="Identifier">addDeclaredLocMaybe</span></a><span class="Other">(</span><span class="Identifier">result</span><span class="Other">:</span> <span class="Keyword">var</span> <span class="Identifier">string</span><span class="Other">;</span> <span class="Identifier">conf</span><span class="Other">:</span> <a href="options.html#ConfigRef"><span class="Identifier">ConfigRef</span></a><span class="Other">;</span> <span class="Identifier">sym</span><span class="Other">:</span> <a href="ast.html#PSym"><span class="Identifier">PSym</span></a><span class="Other">)</span> {.
|
||||
<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ValueError</span><span class="Other">,</span> <span class="Identifier">Exception</span><span class="Other">,</span> <span class="Identifier">KeyError</span><span class="Other">]</span><span class="Other">,</span>
|
||||
<span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">RootEffect</span><span class="Other">,</span> <span class="Identifier">ReadDirEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/compiler/astmsgs.nim#L13" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/compiler/astmsgs.nim#L13" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
<div id="addDeclaredLocMaybe,string,ConfigRef,PType">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#addDeclaredLocMaybe%2Cstring%2CConfigRef%2CPType"><span class="Identifier">addDeclaredLocMaybe</span></a><span class="Other">(</span><span class="Identifier">result</span><span class="Other">:</span> <span class="Keyword">var</span> <span class="Identifier">string</span><span class="Other">;</span> <span class="Identifier">conf</span><span class="Other">:</span> <a href="options.html#ConfigRef"><span class="Identifier">ConfigRef</span></a><span class="Other">;</span> <span class="Identifier">typ</span><span class="Other">:</span> <a href="ast.html#PType"><span class="Identifier">PType</span></a><span class="Other">)</span> {.
|
||||
<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ValueError</span><span class="Other">,</span> <span class="Identifier">Exception</span><span class="Other">,</span> <span class="Identifier">KeyError</span><span class="Other">]</span><span class="Other">,</span>
|
||||
<span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">RootEffect</span><span class="Other">,</span> <span class="Identifier">ReadDirEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/compiler/astmsgs.nim#L27" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/compiler/astmsgs.nim#L27" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="genFieldDefect-procs-all">
|
||||
<div id="genFieldDefect,ConfigRef,string,PSym">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#genFieldDefect%2CConfigRef%2Cstring%2CPSym"><span class="Identifier">genFieldDefect</span></a><span class="Other">(</span><span class="Identifier">conf</span><span class="Other">:</span> <a href="options.html#ConfigRef"><span class="Identifier">ConfigRef</span></a><span class="Other">;</span> <span class="Identifier">field</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">;</span> <span class="Identifier">disc</span><span class="Other">:</span> <a href="ast.html#PSym"><span class="Identifier">PSym</span></a><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">string</span> {.
|
||||
<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">ValueError</span><span class="Other">,</span> <span class="Identifier">Exception</span><span class="Other">,</span> <span class="Identifier">KeyError</span><span class="Other">]</span><span class="Other">,</span>
|
||||
<span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Identifier">RootEffect</span><span class="Other">,</span> <span class="Identifier">ReadDirEffect</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/compiler/astmsgs.nim#L34" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/compiler/astmsgs.nim#L34" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="typSym-procs-all">
|
||||
<div id="typSym,PType">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#typSym%2CPType"><span class="Identifier">typSym</span></a><span class="Other">(</span><span class="Identifier">t</span><span class="Other">:</span> <a href="ast.html#PType"><span class="Identifier">PType</span></a><span class="Other">)</span><span class="Other">:</span> <a href="ast.html#PSym"><span class="Identifier">PSym</span></a> {.<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/compiler/astmsgs.nim#L5" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/compiler/astmsgs.nim#L5" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</dl>
|
||||
</div>
|
||||
<div class="section" id="18">
|
||||
<h1><a class="toc-backref" href="#18">Templates</a></h1>
|
||||
<dl class="item">
|
||||
<div id="quoteExpr-templates-all">
|
||||
<div id="quoteExpr.t,string">
|
||||
<dt><pre><span class="Keyword">template</span> <a href="#quoteExpr.t%2Cstring"><span class="Identifier">quoteExpr</span></a><span class="Other">(</span><span class="Identifier">a</span><span class="Other">:</span> <span class="Identifier">string</span><span class="Other">)</span><span class="Other">:</span> <span class="Identifier">untyped</span></pre></dt>
|
||||
<dd>
|
||||
|
||||
can be used for quoting expressions in error msgs.
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/compiler/astmsgs.nim#L30" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/compiler/astmsgs.nim#L30" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="twelve-columns footer">
|
||||
<span class="nim-sprite"></span>
|
||||
<br>
|
||||
<small style="color: var(--hint);">Made with Nim. Generated: 2023-03-13 00:20:13 UTC</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script defer data-domain="nim-lang.org" src="https://plausible.io/js/plausible.js"></script>
|
||||
|
||||
<!-- Google fonts -->
|
||||
<link href='https://fonts.googleapis.com/css?family=Lato:400,600,900' rel='stylesheet' type='text/css'/>
|
||||
<link href='https://fonts.googleapis.com/css?family=Source+Code+Pro:400,500,600' rel='stylesheet' type='text/css'/>
|
||||
</body>
|
||||
</html>
|
||||
10
compiler/astmsgs.idx
Normal file
10
compiler/astmsgs.idx
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
nimTitle astmsgs astmsgs.html module compiler/astmsgs 0
|
||||
nim typSym astmsgs.html#typSym,PType proc typSym(t: PType): PSym 5
|
||||
nim addDeclaredLoc astmsgs.html#addDeclaredLoc,string,ConfigRef,PSym proc addDeclaredLoc(result: var string; conf: ConfigRef; sym: PSym) 10
|
||||
nim addDeclaredLocMaybe astmsgs.html#addDeclaredLocMaybe,string,ConfigRef,PSym proc addDeclaredLocMaybe(result: var string; conf: ConfigRef; sym: PSym) 13
|
||||
nim addDeclaredLoc astmsgs.html#addDeclaredLoc,string,ConfigRef,PType proc addDeclaredLoc(result: var string; conf: ConfigRef; typ: PType) 17
|
||||
nim addDeclaredLocMaybe astmsgs.html#addDeclaredLocMaybe,string,ConfigRef,PType proc addDeclaredLocMaybe(result: var string; conf: ConfigRef; typ: PType) 27
|
||||
nim quoteExpr astmsgs.html#quoteExpr.t,string template quoteExpr(a: string): untyped 30
|
||||
nim genFieldDefect astmsgs.html#genFieldDefect,ConfigRef,string,PSym proc genFieldDefect(conf: ConfigRef; field: string; disc: PSym): string 34
|
||||
nimgrp adddeclaredloc astmsgs.html#addDeclaredLoc-procs-all proc 10
|
||||
nimgrp adddeclaredlocmaybe astmsgs.html#addDeclaredLocMaybe-procs-all proc 13
|
||||
|
|
@ -1,39 +0,0 @@
|
|||
# this module avoids ast depending on msgs or vice versa
|
||||
import std/strutils
|
||||
import options, ast, msgs
|
||||
|
||||
proc typSym*(t: PType): PSym =
|
||||
result = t.sym
|
||||
if result == nil and t.kind == tyGenericInst: # this might need to be refined
|
||||
result = t[0].sym
|
||||
|
||||
proc addDeclaredLoc*(result: var string, conf: ConfigRef; sym: PSym) =
|
||||
result.add " [$1 declared in $2]" % [sym.kind.toHumanStr, toFileLineCol(conf, sym.info)]
|
||||
|
||||
proc addDeclaredLocMaybe*(result: var string, conf: ConfigRef; sym: PSym) =
|
||||
if optDeclaredLocs in conf.globalOptions and sym != nil:
|
||||
addDeclaredLoc(result, conf, sym)
|
||||
|
||||
proc addDeclaredLoc*(result: var string, conf: ConfigRef; typ: PType) =
|
||||
# xxx figure out how to resolve `tyGenericParam`, e.g. for
|
||||
# proc fn[T](a: T, b: T) = discard
|
||||
# fn(1.1, "a")
|
||||
let typ = typ.skipTypes(abstractInst + {tyStatic, tySequence, tyArray, tySet, tyUserTypeClassInst, tyVar, tyRef, tyPtr} - {tyRange})
|
||||
result.add " [$1" % typ.kind.toHumanStr
|
||||
if typ.sym != nil:
|
||||
result.add " declared in " & toFileLineCol(conf, typ.sym.info)
|
||||
result.add "]"
|
||||
|
||||
proc addDeclaredLocMaybe*(result: var string, conf: ConfigRef; typ: PType) =
|
||||
if optDeclaredLocs in conf.globalOptions: addDeclaredLoc(result, conf, typ)
|
||||
|
||||
template quoteExpr*(a: string): untyped =
|
||||
## can be used for quoting expressions in error msgs.
|
||||
"'" & a & "'"
|
||||
|
||||
proc genFieldDefect*(conf: ConfigRef, field: string, disc: PSym): string =
|
||||
let obj = disc.owner.name.s # `types.typeToString` might be better, eg for generics
|
||||
result = "field '$#' is not accessible for type '$#'" % [field, obj]
|
||||
if optDeclaredLocs in conf.globalOptions:
|
||||
result.add " [discriminant declared in $#]" % toFileLineCol(conf, disc.info)
|
||||
result.add " using '$# = " % disc.name.s
|
||||
154
compiler/backendpragmas.html
Normal file
154
compiler/backendpragmas.html
Normal file
|
|
@ -0,0 +1,154 @@
|
|||
<?xml version="1.0" encoding="utf-8" ?>
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<!-- This file is generated by Nim. -->
|
||||
<html xmlns="https://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>compiler/backendpragmas</title>
|
||||
|
||||
<!-- Favicon -->
|
||||
<link rel="shortcut icon" href="data:image/x-icon;base64,AAABAAEAEBAAAAEAIABoBAAAFgAAACgAAAAQAAAAIAAAAAEAIAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAUAAAAF////AP///wD///8A////AP///wD///8A////AP///wD///8A////AAAAAAIAAABbAAAAlQAAAKIAAACbAAAAmwAAAKIAAACVAAAAWwAAAAL///8A////AP///wD///8A////AAAAABQAAADAAAAAYwAAAA3///8A////AP///wD///8AAAAADQAAAGMAAADAAAAAFP///wD///8A////AP///wAAAACdAAAAOv///wD///8A////AP///wD///8A////AP///wD///8AAAAAOgAAAJ3///8A////AP///wAAAAAnAAAAcP///wAAAAAoAAAASv///wD///8A////AP///wAAAABKAAAAKP///wAAAABwAAAAJ////wD///8AAAAAgQAAABwAAACIAAAAkAAAAJMAAACtAAAAFQAAABUAAACtAAAAkwAAAJAAAACIAAAAHAAAAIH///8A////AAAAAKQAAACrAAAAaP///wD///8AAAAARQAAANIAAADSAAAARf///wD///8AAAAAaAAAAKsAAACk////AAAAADMAAACcAAAAnQAAABj///8A////AP///wAAAAAYAAAAGP///wD///8A////AAAAABgAAACdAAAAnAAAADMAAAB1AAAAwwAAAP8AAADpAAAAsQAAAE4AAAAb////AP///wAAAAAbAAAATgAAALEAAADpAAAA/wAAAMMAAAB1AAAAtwAAAOkAAAD/AAAA/wAAAP8AAADvAAAA3gAAAN4AAADeAAAA3gAAAO8AAAD/AAAA/wAAAP8AAADpAAAAtwAAAGUAAAA/AAAA3wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAAD/AAAA/wAAAP8AAADfAAAAPwAAAGX///8A////AAAAAEgAAADtAAAAvwAAAL0AAADGAAAA7wAAAO8AAADGAAAAvQAAAL8AAADtAAAASP///wD///8A////AP///wD///8AAAAAO////wD///8A////AAAAAIcAAACH////AP///wD///8AAAAAO////wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A////AP///wD///8A//8AAP//AAD4HwAA7/cAAN/7AAD//wAAoYUAAJ55AACf+QAAh+EAAAAAAADAAwAA4AcAAP5/AAD//wAA//8AAA=="/>
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAABmJLR0QA/wD/AP+gvaeTAAAACXBIWXMAAA3XAAAN1wFCKJt4AAAAB3RJTUUH4QQQEwksSS9ZWwAAAk1JREFUWMPtll2ITVEUx39nn/O7Y5qR8f05wtCUUr6ZIS++8pEnkZInPImneaCQ5METNdOkeFBKUhMPRIkHKfEuUZSUlGlKPN2TrgfncpvmnntnmlEyq1Z7t89/rf9a6+y99oZxGZf/XeIq61EdtgKXgdXA0xrYAvBjOIF1AI9zvjcC74BSpndrJPkBWDScTF8Aa4E3wDlgHbASaANmVqlcCnwHvgDvgVfAJ+AikAAvgfVZwLnSVZHZaOuKoQi3ZOMi4NkYkpe1p4J7A8BpYAD49hfIy/oqG0+hLomiKP2L5L+1ubn5115S+3OAn4EnwBlgMzCjyt6ZAnQCJ4A7wOs88iRJHvw50HoujuPBoCKwHWiosy8MdfZnAdcHk8dxXFJ3VQbQlCTJvRBCGdRbD4M6uc5glpY3eAihpN5S5w12diSEcCCEcKUO4ljdr15T76ur1FDDLIQQ3qv71EdDOe3Kxj3leRXyk+pxdWnFWod6Wt2bY3de3aSuUHcPBVimHs7mK9WrmeOF6lR1o9qnzskh2ar2qm1qizpfXaPeVGdlmGN5pb09qMxz1Xb1kLqgzn1RyH7JUXW52lr5e/Kqi9qpto7V1atuUzfnARrV7jEib1T76gG2qxdGmXyiekkt1GswPTtek0aBfJp6YySGBfWg2tPQ0FAYgf1stUfdmdcjarbYJEniKIq6gY/Aw+zWHAC+p2labGpqiorFYgGYCEzN7oQdQClN07O1/EfDyGgC0ALMBdYAi4FyK+4H3gLPsxfR1zRNi+NP7nH5J+QntnXe5B5mpfQAAAAASUVORK5CYII=">
|
||||
|
||||
<!-- CSS -->
|
||||
<link rel="stylesheet" type="text/css" href="nimdoc.out.css">
|
||||
|
||||
<!-- JS -->
|
||||
<script type="text/javascript" src="dochack.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<div class="document" id="documentId">
|
||||
<div class="container">
|
||||
<h1 class="title">compiler/backendpragmas</h1>
|
||||
<div class="row">
|
||||
<div class="three columns">
|
||||
<div class="theme-select-wrapper">
|
||||
<label for="theme-select">Theme: </label>
|
||||
<select id="theme-select" onchange="setTheme(this.value)">
|
||||
<option value="auto">🌗 Match OS</option>
|
||||
<option value="dark">🌑 Dark</option>
|
||||
<option value="light">🌕 Light</option>
|
||||
</select>
|
||||
</div>
|
||||
<div id="global-links">
|
||||
<ul class="simple">
|
||||
<li><a id="indexLink" href="theindex.html">Index</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div id="searchInputDiv">
|
||||
Search: <input type="search" id="searchInput" onkeyup="search()"/>
|
||||
</div>
|
||||
<div>
|
||||
Group by:
|
||||
<select onchange="groupBy(this.value)">
|
||||
<option value="section">Section</option>
|
||||
<option value="type">Type</option>
|
||||
</select>
|
||||
</div>
|
||||
<ul class="simple simple-toc" id="toc-list">
|
||||
<li>
|
||||
<a class="reference reference-toplevel" href="#6" id="56">Imports</a>
|
||||
</li>
|
||||
<li>
|
||||
<details open>
|
||||
<summary><a class="reference reference-toplevel" href="#12" id="62">Procs</a></summary>
|
||||
<ul class="simple simple-toc-section">
|
||||
<ul class="simple nested-toc-section">processPushBackendOption
|
||||
<li><a class="reference" href="#processPushBackendOption%2Cseq%5BTOptions%5D%2CTOptions%2CPNode%2Cint" title="processPushBackendOption(optionsStack: var seq[TOptions]; options: var TOptions;
|
||||
n: PNode; start: int)">processPushBackendOption(optionsStack: var seq[TOptions]; options: var TOptions;
|
||||
n: PNode; start: int)</a></li>
|
||||
|
||||
</ul>
|
||||
|
||||
</ul>
|
||||
</details>
|
||||
</li>
|
||||
<li>
|
||||
<details open>
|
||||
<summary><a class="reference reference-toplevel" href="#18" id="68">Templates</a></summary>
|
||||
<ul class="simple simple-toc-section">
|
||||
<ul class="simple nested-toc-section">processPopBackendOption
|
||||
<li><a class="reference" href="#processPopBackendOption.t%2Cseq%5BTOptions%5D%2CTOptions" title="processPopBackendOption(optionsStack: var seq[TOptions]; options: var TOptions)">processPopBackendOption(optionsStack: var seq[TOptions]; options: var TOptions)</a></li>
|
||||
|
||||
</ul>
|
||||
|
||||
</ul>
|
||||
</details>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
<div class="nine columns" id="content">
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/compiler/backendpragmas.nim#L1" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/compiler/backendpragmas.nim#L1" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
<div id="tocRoot"></div>
|
||||
|
||||
<p class="module-desc"></p>
|
||||
<div class="section" id="6">
|
||||
<h1><a class="toc-backref" href="#6">Imports</a></h1>
|
||||
<dl class="item">
|
||||
<a class="reference external" href="pragmas.html">pragmas</a>, <a class="reference external" href="options.html">options</a>, <a class="reference external" href="ast.html">ast</a>, <a class="reference external" href="trees.html">trees</a>
|
||||
</dl>
|
||||
</div>
|
||||
<div class="section" id="12">
|
||||
<h1><a class="toc-backref" href="#12">Procs</a></h1>
|
||||
<dl class="item">
|
||||
<div id="processPushBackendOption-procs-all">
|
||||
<div id="processPushBackendOption,seq[TOptions],TOptions,PNode,int">
|
||||
<dt><pre><span class="Keyword">proc</span> <a href="#processPushBackendOption%2Cseq%5BTOptions%5D%2CTOptions%2CPNode%2Cint"><span class="Identifier">processPushBackendOption</span></a><span class="Other">(</span><span class="Identifier">optionsStack</span><span class="Other">:</span> <span class="Keyword">var</span> <span class="Identifier">seq</span><span class="Other">[</span><a href="options.html#TOptions"><span class="Identifier">TOptions</span></a><span class="Other">]</span><span class="Other">;</span>
|
||||
<span class="Identifier">options</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="options.html#TOptions"><span class="Identifier">TOptions</span></a><span class="Other">;</span> <span class="Identifier">n</span><span class="Other">:</span> <a href="ast.html#PNode"><span class="Identifier">PNode</span></a><span class="Other">;</span> <span class="Identifier">start</span><span class="Other">:</span> <span class="Identifier">int</span><span class="Other">)</span> {.
|
||||
<span><span class="Other pragmadots">...</span></span><span class="pragmawrap"><span class="Identifier">raises</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">tags</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span><span class="Other">,</span> <span class="Identifier">forbids</span><span class="Other">:</span> <span class="Other">[</span><span class="Other">]</span></span>.}</pre></dt>
|
||||
<dd>
|
||||
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/compiler/backendpragmas.nim#L10" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/compiler/backendpragmas.nim#L10" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</dl>
|
||||
</div>
|
||||
<div class="section" id="18">
|
||||
<h1><a class="toc-backref" href="#18">Templates</a></h1>
|
||||
<dl class="item">
|
||||
<div id="processPopBackendOption-templates-all">
|
||||
<div id="processPopBackendOption.t,seq[TOptions],TOptions">
|
||||
<dt><pre><span class="Keyword">template</span> <a href="#processPopBackendOption.t%2Cseq%5BTOptions%5D%2CTOptions"><span class="Identifier">processPopBackendOption</span></a><span class="Other">(</span><span class="Identifier">optionsStack</span><span class="Other">:</span> <span class="Keyword">var</span> <span class="Identifier">seq</span><span class="Other">[</span><a href="options.html#TOptions"><span class="Identifier">TOptions</span></a><span class="Other">]</span><span class="Other">;</span>
|
||||
<span class="Identifier">options</span><span class="Other">:</span> <span class="Keyword">var</span> <a href="options.html#TOptions"><span class="Identifier">TOptions</span></a><span class="Other">)</span></pre></dt>
|
||||
<dd>
|
||||
|
||||
|
||||
<a href="https://github.com/nim-lang/Nim/tree/devel/compiler/backendpragmas.nim#L24" class="link-seesrc" target="_blank">Source</a>
|
||||
<a href="https://github.com/nim-lang/Nim/edit/devel/compiler/backendpragmas.nim#L24" class="link-seesrc" target="_blank" >Edit</a>
|
||||
|
||||
</dd>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="twelve-columns footer">
|
||||
<span class="nim-sprite"></span>
|
||||
<br>
|
||||
<small style="color: var(--hint);">Made with Nim. Generated: 2023-03-13 00:20:14 UTC</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script defer data-domain="nim-lang.org" src="https://plausible.io/js/plausible.js"></script>
|
||||
|
||||
<!-- Google fonts -->
|
||||
<link href='https://fonts.googleapis.com/css?family=Lato:400,600,900' rel='stylesheet' type='text/css'/>
|
||||
<link href='https://fonts.googleapis.com/css?family=Source+Code+Pro:400,500,600' rel='stylesheet' type='text/css'/>
|
||||
</body>
|
||||
</html>
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue