Skip to content

Commit d1e8dbd

Browse files
committed
update types
1 parent 8401253 commit d1e8dbd

File tree

5 files changed

+215
-171
lines changed

5 files changed

+215
-171
lines changed

std/assembly/builtins.ts

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -2600,126 +2600,126 @@ export namespace string {
26002600

26012601
// @ts-ignore: decorator
26022602
@builtin
2603-
export declare function const_(str: string): stringref;
2603+
export declare function const_(str: string): ref_string;
26042604

26052605
// @ts-ignore: decorator
26062606
@unsafe @builtin
2607-
export declare function new_utf8(ptr: usize, bytes: i32): stringref;
2607+
export declare function new_utf8(ptr: usize, bytes: i32): ref_string;
26082608

26092609
// @ts-ignore: decorator
26102610
@builtin
2611-
export declare function new_utf8_array(array: arrayref, start: i32, end: i32): stringref;
2611+
export declare function new_utf8_array(array: arrayref, start: i32, end: i32): ref_string;
26122612

26132613
// @ts-ignore: decorator
26142614
@unsafe @builtin
2615-
export declare function new_lossy_utf8(ptr: usize, bytes: i32): stringref;
2615+
export declare function new_lossy_utf8(ptr: usize, bytes: i32): ref_string;
26162616

26172617
// @ts-ignore: decorator
26182618
@builtin
2619-
export declare function new_lossy_utf8_array(array: arrayref, start: i32, end: i32): stringref;
2619+
export declare function new_lossy_utf8_array(array: ref_array, start: i32, end: i32): ref_string;
26202620

26212621
// @ts-ignore: decorator
26222622
@unsafe @builtin
2623-
export declare function new_wtf8(ptr: usize, bytes: i32): stringref;
2623+
export declare function new_wtf8(ptr: usize, bytes: i32): ref_string;
26242624

26252625
// @ts-ignore: decorator
26262626
@builtin
2627-
export declare function new_wtf8_array(arr: arrayref, start: i32, end: i32): stringref;
2627+
export declare function new_wtf8_array(arr: ref_array, start: i32, end: i32): ref_string;
26282628

26292629
// @ts-ignore: decorator
26302630
@unsafe @builtin
2631-
export declare function new_wtf16(ptr: usize, units: i32): stringref;
2631+
export declare function new_wtf16(ptr: usize, units: i32): ref_string;
26322632

26332633
// @ts-ignore: decorator
26342634
@builtin
2635-
export declare function new_wtf16_array(arr: arrayref, start: i32, end: i32): stringref;
2635+
export declare function new_wtf16_array(arr: ref_array, start: i32, end: i32): ref_string;
26362636

26372637
// @ts-ignore: decorator
26382638
@builtin
2639-
export declare function from_code_point(codepoint: i32): stringref;
2639+
export declare function from_code_point(codepoint: i32): ref_string;
26402640

26412641
// @ts-ignore: decorator
26422642
@builtin
2643-
export declare function hash(str: stringref): i32;
2643+
export declare function hash(str: ref_string): i32;
26442644

26452645
// @ts-ignore: decorator
26462646
@builtin
2647-
export declare function measure_utf8(str: stringref): i32;
2647+
export declare function measure_utf8(str: ref_string): i32;
26482648

26492649
// @ts-ignore: decorator
26502650
@builtin
2651-
export declare function measure_wtf8(str: stringref): i32;
2651+
export declare function measure_wtf8(str: ref_string): i32;
26522652

26532653
// @ts-ignore: decorator
26542654
@builtin
2655-
export declare function measure_wtf16(str: stringref): i32;
2655+
export declare function measure_wtf16(str: ref_string): i32;
26562656

26572657
// @ts-ignore: decorator
26582658
@builtin
2659-
export declare function is_usv_sequence(str: stringref): i32;
2659+
export declare function is_usv_sequence(str: ref_string): i32;
26602660

26612661
// @ts-ignore: decorator
26622662
@unsafe @builtin
2663-
export declare function encode_utf8(str: stringref, ptr: usize): i32;
2663+
export declare function encode_utf8(str: ref_string, ptr: usize): i32;
26642664

26652665
// @ts-ignore: decorator
26662666
@builtin
2667-
export declare function encode_utf8_array(str: stringref, arr: arrayref, start: i32): i32;
2667+
export declare function encode_utf8_array(str: ref_string, arr: arrayref, start: i32): i32;
26682668

26692669
// TODO: encode_lossy_utf8
26702670

26712671
// TODO: encode_lossy_utf8_array
26722672

26732673
// @ts-ignore: decorator
26742674
@unsafe @builtin
2675-
export declare function encode_wtf8(str: stringref, ptr: usize): i32;
2675+
export declare function encode_wtf8(str: ref_string, ptr: usize): i32;
26762676

26772677
// @ts-ignore: decorator
26782678
@builtin
2679-
export declare function encode_wtf8_array(str: stringref, arr: arrayref, start: i32): i32;
2679+
export declare function encode_wtf8_array(str: ref_string, arr: ref_array, start: i32): i32;
26802680

26812681
// @ts-ignore: decorator
26822682
@unsafe @builtin
2683-
export declare function encode_wtf16(str: stringref, ptr: usize): i32;
2683+
export declare function encode_wtf16(str: ref_string, ptr: usize): i32;
26842684

26852685
// @ts-ignore: decorator
26862686
@builtin
2687-
export declare function encode_wtf16_array(str: stringref, arr: arrayref, start: i32): i32;
2687+
export declare function encode_wtf16_array(str: ref_string, arr: ref_array, start: i32): i32;
26882688

26892689
// @ts-ignore: decorator
26902690
@builtin
2691-
export declare function concat(left: stringref, right: stringref): stringref;
2691+
export declare function concat(left: ref_string, right: ref_string): ref_string;
26922692

26932693
// @ts-ignore: decorator
26942694
@builtin
2695-
export declare function eq(left: stringref, right: stringref): bool;
2695+
export declare function eq(left: ref_string | null, right: ref_string | null): bool;
26962696

26972697
// @ts-ignore: decorator
26982698
@builtin
2699-
export declare function compare(left: stringref, right: stringref): i32;
2699+
export declare function compare(left: ref_string, right: ref_string): i32;
27002700

27012701
// @ts-ignore: decorator
27022702
@builtin
2703-
export declare function as_wtf8(str: stringref): stringview_wtf8;
2703+
export declare function as_wtf8(str: ref_string): ref_stringview_wtf8;
27042704

27052705
// @ts-ignore: decorator
27062706
@builtin
2707-
export declare function as_wtf16(str: stringref): stringview_wtf16;
2707+
export declare function as_wtf16(str: ref_string): ref_stringview_wtf16;
27082708

27092709
// @ts-ignore: decorator
27102710
@builtin
2711-
export declare function as_iter(str: stringref): stringview_iter;
2711+
export declare function as_iter(str: ref_string): ref_stringview_iter;
27122712
}
27132713

27142714
export namespace stringview_wtf8 {
27152715

27162716
// @ts-ignore: decorator
27172717
@builtin
2718-
export declare function advance(view: stringview_wtf8, pos: i32, bytes: i32): i32;
2718+
export declare function advance(view: ref_stringview_wtf8, pos: i32, bytes: i32): i32;
27192719

27202720
// @ts-ignore: decorator
27212721
@builtin
2722-
export declare function slice(view: stringview_wtf8, start: i32, end: i32): stringref;
2722+
export declare function slice(view: ref_stringview_wtf8, start: i32, end: i32): ref_string;
27232723

27242724
// TODO: encode_utf8
27252725

@@ -2732,15 +2732,15 @@ export namespace stringview_wtf16 {
27322732

27332733
// @ts-ignore: decorator
27342734
@builtin
2735-
export declare function length(view: stringview_wtf16): i32;
2735+
export declare function length(view: ref_stringview_wtf16): i32;
27362736

27372737
// @ts-ignore: decorator
27382738
@builtin
2739-
export declare function slice(view: stringview_wtf16, start: i32, end: i32): stringref;
2739+
export declare function slice(view: ref_stringview_wtf16, start: i32, end: i32): ref_string;
27402740

27412741
// @ts-ignore: decorator
27422742
@builtin
2743-
export declare function get_codeunit(view: stringview_wtf16, pos: i32): i32;
2743+
export declare function get_codeunit(view: ref_stringview_wtf16, pos: i32): i32;
27442744

27452745
// TODO: encode
27462746
}
@@ -2749,19 +2749,19 @@ export namespace stringview_iter {
27492749

27502750
// @ts-ignore: decorator
27512751
@builtin
2752-
export declare function next(view: stringview_iter): i32;
2752+
export declare function next(view: ref_stringview_iter): i32;
27532753

27542754
// @ts-ignore: decorator
27552755
@builtin
2756-
export declare function advance(view: stringview_iter, count: i32): i32;
2756+
export declare function advance(view: ref_stringview_iter, count: i32): i32;
27572757

27582758
// @ts-ignore: decorator
27592759
@builtin
2760-
export declare function rewind(view: stringview_iter, count: i32): i32;
2760+
export declare function rewind(view: ref_stringview_iter, count: i32): i32;
27612761

27622762
// @ts-ignore: decorator
27632763
@builtin
2764-
export declare function slice(view: stringview_iter, count: i32): stringref;
2764+
export declare function slice(view: ref_stringview_iter, count: i32): ref_string;
27652765
}
27662766

27672767
/* eslint-disable @typescript-eslint/no-unused-vars */

std/assembly/index.d.ts

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1670,92 +1670,92 @@ declare abstract class i31 {
16701670

16711671
declare namespace string {
16721672
/** Constructs a string reference from a string literal. Temporary! */
1673-
export function const_(str: string): stringref;
1673+
export function const_(str: string): ref_string;
16741674
/** Creates a new string from memory using a strict UTF-8 decoder, decoding `bytes` bytes starting at `ptr`. */
1675-
export function new_utf8(ptr: usize, bytes: i32): stringref;
1675+
export function new_utf8(ptr: usize, bytes: i32): ref_string;
16761676
/** Creates a new string from `array` using a strict UTF-8 decoder, decoding from `start` inclusive to `end` exclusive. */
1677-
export function new_utf8_array(array: arrayref, start: i32, end: i32): stringref;
1677+
export function new_utf8_array(array: ref_array, start: i32, end: i32): ref_string;
16781678
/** Creates a new string from memory using a lossy UTF-8 decoder, decoding `bytes` bytes starting at `ptr`. */
1679-
export function new_lossy_utf8(ptr: usize, bytes: i32): stringref;
1679+
export function new_lossy_utf8(ptr: usize, bytes: i32): ref_string;
16801680
/** Creates a new string from `array` using a lossy UTF-8 decoder, decoding from `start` inclusive to `end` exclusive. */
1681-
export function new_lossy_utf8_array(array: arrayref, start: i32, end: i32): stringref;
1681+
export function new_lossy_utf8_array(array: ref_array, start: i32, end: i32): ref_string;
16821682
/** Creates a new string from memory using a strict WTF-8 decoder, decodiing `bytes` bytes starting at `ptr`. */
1683-
export function new_wtf8(ptr: usize, bytes: i32): stringref;
1683+
export function new_wtf8(ptr: usize, bytes: i32): ref_string;
16841684
/** Creates a new string from `array` using a strict WTF-8 decoder, decoding from `start` inclusive to `end` exclusive. */
1685-
export function new_wtf8_array(array: arrayref, start: i32, end: i32): stringref;
1685+
export function new_wtf8_array(array: ref_array, start: i32, end: i32): ref_string;
16861686
/** Creates a new string from memory assuming WTF-16 encoding, reading `codeunits` code units starting at `ptr`. `ptr` must be two-byte aligned. */
1687-
export function new_wtf16(ptr: usize, codeunits: i32): stringref;
1687+
export function new_wtf16(ptr: usize, codeunits: i32): ref_string;
16881688
/** Creates a new string from `array` assuming WTF-16 encoding, reading from `start` inclusive to `end` exclusive. */
1689-
export function new_wtf16_array(array: arrayref, start: i32, end: i32): stringref;
1689+
export function new_wtf16_array(array: ref_array, start: i32, end: i32): ref_string;
16901690
/** Creates a new string from the given `codepoint`. */
1691-
export function from_code_point(codepoint: i32): stringref;
1691+
export function from_code_point(codepoint: i32): ref_string;
16921692
/** Obtains an implementation-defined 32-bit hash value of `str`. */
1693-
export function hash(str: stringref): i32;
1693+
export function hash(str: ref_string): i32;
16941694
/** Measures the number of bytes required to encode `str` to UTF-8. Returns `-1` if the string contains an isolated surrogate. */
1695-
export function measure_utf8(str: stringref): i32;
1695+
export function measure_utf8(str: ref_string): i32;
16961696
/** Measures the number of bytes required to encode `str` to WTF-8. */
1697-
export function measure_wtf8(str: stringref): i32;
1697+
export function measure_wtf8(str: ref_string): i32;
16981698
/** Measures the number of 16-bit code units required to encode `str` to WTF-16. */
1699-
export function measure_wtf16(str: stringref): i32;
1699+
export function measure_wtf16(str: ref_string): i32;
17001700
/** Tests whether `str` is a sequence of Unicode scalar values, i.e. does not contain isolated surrogates. */
1701-
export function is_usv_sequence(str: stringref): bool;
1701+
export function is_usv_sequence(str: ref_string): bool;
17021702
/** Encodes `str` to memory at `ptr` using a strict UTF-8 encoder. */
1703-
export function encode_utf8(str: stringref, ptr: usize): i32;
1703+
export function encode_utf8(str: ref_string, ptr: usize): i32;
17041704
/** Encodes `str` to `arr` at `start` using a strict UTF-8 encoder. */
1705-
export function encode_utf8_array(str: stringref, arr: arrayref, start: i32): i32;
1705+
export function encode_utf8_array(str: ref_string, arr: ref_array, start: i32): i32;
17061706
// TODO: encode_lossy_utf8
17071707
// TODO: encode_lossy_utf8_array
17081708
/** Encodes `str` to memory at `ptr` using a WTF-8 encoder. */
1709-
export function encode_wtf8(str: stringref, ptr: usize): i32;
1709+
export function encode_wtf8(str: ref_string, ptr: usize): i32;
17101710
/** Encodes `str` to `arr` at `start` using a WTF-8 encoder. */
1711-
export function encode_wtf8_array(str: stringref, arr: arrayref, start: i32): i32;
1711+
export function encode_wtf8_array(str: ref_string, arr: ref_array, start: i32): i32;
17121712
/** Encodes `str` to memory at `ptr` using a WTF-16 encoder. */
1713-
export function encode_wtf16(str: stringref, ptr: usize): i32;
1713+
export function encode_wtf16(str: ref_string, ptr: usize): i32;
17141714
/** Encodes `str` to `arr` at `start` using a WTF-16 encoder. */
1715-
export function encode_wtf16_array(str: stringref, arr: arrayref, start: i32): i32;
1715+
export function encode_wtf16_array(str: ref_string, arr: arrayref, start: i32): i32;
17161716
/** Concatenates `left` and `right` in this order. Traps if either operand is `null`. */
1717-
export function concat(left: stringref, right: stringref): stringref;
1717+
export function concat(left: ref_string, right: ref_string): ref_string;
17181718
/** Tests whether `left` and `right` are equal, including if both are `null`. */
1719-
export function eq(left: stringref, right: stringref): bool;
1719+
export function eq(left: ref_string | null, right: ref_string | null): bool;
17201720
/** Compares the contents of `left` and `right`, returning `-1` if `left < right`, `0` if `left == right` or `1` if `left > right`. Traps if either operand is `null`. */
1721-
export function compare(left: stringref, right: stringref): i32;
1721+
export function compare(left: ref_string, right: ref_string): i32;
17221722
/** Obtains a WTF-8 view on `str`. */
1723-
export function as_wtf8(str: stringref): stringview_wtf8;
1723+
export function as_wtf8(str: ref_string): ref_stringview_wtf8;
17241724
/** Obtains a WTF-16 view on `str`. */
1725-
export function as_wtf16(str: stringref): stringview_wtf16;
1725+
export function as_wtf16(str: ref_string): ref_stringview_wtf16;
17261726
/** Obtains an iterator view on `str`. */
1727-
export function as_iter(str: stringref): stringview_iter;
1727+
export function as_iter(str: ref_string): ref_stringview_iter;
17281728
}
17291729

17301730
declare namespace stringview_wtf8 {
17311731
/** Obtains the highest code point offset in `view` that is not greater than `pos + bytes`. If `pos` does not match the start of a code point, it is advanced to the next code point. */
1732-
export function advance(view: stringview_wtf8, pos: i32, bytes: i32): i32;
1732+
export function advance(view: ref_stringview_wtf8, pos: i32, bytes: i32): i32;
17331733
/** Returns a substring of `view` from `start` inclusive to `end` exclusive. If `start` or `end` do not match the start of a code point, these are advanced to the next code point. */
1734-
export function slice(view: stringview_wtf8, start: i32, end: i32): stringref;
1734+
export function slice(view: ref_stringview_wtf8, start: i32, end: i32): ref_string;
17351735
// TODO: encode_utf8
17361736
// TODO: encode_lossy_utf8
17371737
// TODO: encode_wtf8
17381738
}
17391739

17401740
declare namespace stringview_wtf16 {
17411741
/** Obtains the number of 16-bit code units in `view`. */
1742-
export function length(view: stringview_wtf16): i32;
1742+
export function length(view: ref_stringview_wtf16): i32;
17431743
/** Returns a substring of `view` from `start` inclusive to `end` exclusive. */
1744-
export function slice(view: stringview_wtf16, start: i32, end: i32): stringref;
1744+
export function slice(view: ref_stringview_wtf16, start: i32, end: i32): ref_string;
17451745
/** Obtains the 16-bit code unit at `pos` in `view`. Traps if `pos` is greater than or equal to the view's WTF-16 length. */
1746-
export function get_codeunit(view: stringview_wtf16, pos: i32): i32;
1746+
export function get_codeunit(view: ref_stringview_wtf16, pos: i32): i32;
17471747
// TODO: encode
17481748
}
17491749

17501750
declare namespace stringview_iter {
17511751
/** Obtains the code point at the iterator's current position, advancing the iterator by one code point. Returns `-1` if already at the end. */
1752-
export function next(view: stringview_iter): i32;
1752+
export function next(view: ref_stringview_iter): i32;
17531753
/** Advances the iterator by up to `count` code points, returning the number of code points consumed. */
1754-
export function advance(view: stringview_iter, count: i32): i32;
1754+
export function advance(view: ref_stringview_iter, count: i32): i32;
17551755
/** Rewinds the iterator by up to `count` code points, returning the number of coode points consumed. */
1756-
export function rewind(view: stringview_iter, count: i32): i32;
1756+
export function rewind(view: ref_stringview_iter, count: i32): i32;
17571757
/** Returns a substring of `view`, starting at the current position for up to `count` code points. */
1758-
export function slice(view: stringview_iter, count: i32): stringref;
1758+
export function slice(view: ref_stringview_iter, count: i32): ref_string;
17591759
}
17601760

17611761
/** Macro type evaluating to the underlying native WebAssembly type. */

0 commit comments

Comments
 (0)