-
-
Notifications
You must be signed in to change notification settings - Fork 687
feat: Add memory.dataUTF8() built-in function
#2974
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
base: main
Are you sure you want to change the base?
Changes from all commits
231750d
7f1f5a8
90eab32
5d54b3c
abfef6d
568e9ca
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -62,6 +62,7 @@ under the licensing terms detailed in LICENSE: | |
| * Kam Chehresa <[email protected]> | ||
| * Mopsgamer <[email protected]> | ||
| * EDM115 <[email protected]> | ||
| * Geraint Luff <[email protected]> | ||
| * Weixie Cui <[email protected]> | ||
|
|
||
| Portions of this software are derived from third-party works licensed under | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1798,6 +1798,8 @@ declare namespace memory { | |
| export function data(size: i32, align?: i32): usize; | ||
| /** Gets a pointer to a pre-initialized static chunk of memory. Alignment defaults to the size of `T`. Arguments must be compile-time constants. */ | ||
| export function data<T>(values: T[], align?: i32): usize; | ||
| /** Gets a pointer to a pre-initialized static chunk of memory containing null-terminated UTF8. Value must be a compile-time constant. */ | ||
| export function dataUTF8(value: string): usize; | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this API could be improved and instead enum TextEncoding { UTF8, UTF16 }
declare namespace memory {
...
export function text(value: string, encoding?: TextEncoding, nullTerminated?: bool): usize;
}
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Seems reasonable to me - shall I take a swing at it?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I still think about the best API. Not sure about nullTerminated. It makes sense asually only for ASCII/UTF8. enum TextEncoding {
UTF8, // default ?
UTF8CString, // null terminzated
UTF16
}
declare namespace memory {
...
export function text(value: string, encoding?: TextEncoding): usize;
} |
||
|
|
||
| export namespace atomic { | ||
| /** Performs a wait operation on a 32-bit integer value in memory suspending this agent if the condition is met. */ | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This
FIXMEis copied from thememory.data<T>implementation just above. Tbh I don't understand it, but if it's a problem there, then it's a problem here.