Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add get/opt cbytes #1122

Merged
merged 1 commit into from May 7, 2023
Merged

Add get/opt cbytes #1122

merged 1 commit into from May 7, 2023

Conversation

CosmicToast
Copy link
Contributor

Like getcstring, but operates on a byteview.
When writing bindings (i.e what capi.c is primarily used for), it's common to want to accept a buffer or a string rather than just a string.
For this, a byteview is perfect (and why not accept keywords while you're at it?).
However, there's no built-in function for getting a cstring out of a byteview, this adds one.
This also reformulates getcstring to be an edge-case of getcbytes (simply adding an explicit check for stringness).

Like getcstring, but operates on a byteview.
When writing bindings (i.e what capi.c is primarily used for), it's
common to want to accept a buffer *or* a string rather than just
a string.
For this, a byteview is perfect (and why not accept keywords while
you're at it?).
However, there's no built-in function for getting a cstring out of
a byteview, this adds one.
This also reformulates getcstring to be an edge-case of getcbytes
(simply adding an explicit check for stringness).
@bakpakin bakpakin merged commit c93ddce into janet-lang:master May 7, 2023
6 checks passed
@CosmicToast CosmicToast deleted the getcbytes branch May 7, 2023 15:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants