@@ -60,6 +60,18 @@ pub enum NonstandardOutgoing {
60
60
kind : VectorKind ,
61
61
} ,
62
62
63
+ /// A Rust String (or &str) which might be cached, or might be `None`.
64
+ ///
65
+ /// If `offset` is 0 then it is cached, and the cached JsValue's index is in `length`.
66
+ ///
67
+ /// If `offset` and `length` are both 0, then it is `None`.
68
+ CachedString {
69
+ offset : u32 ,
70
+ length : u32 ,
71
+ owned : bool ,
72
+ optional : bool ,
73
+ } ,
74
+
63
75
/// A `&[u64]` or `&[i64]` is being passed to JS, and the 64-bit sizes here
64
76
/// aren't supported by WebIDL bindings yet.
65
77
View64 {
@@ -240,6 +252,8 @@ impl OutgoingBuilder<'_> {
240
252
Descriptor :: Ref ( d) => self . process_ref ( false , d) ?,
241
253
Descriptor :: RefMut ( d) => self . process_ref ( true , d) ?,
242
254
255
+ Descriptor :: CachedString => self . cached_string ( false , true ) ,
256
+
243
257
Descriptor :: Vector ( _) | Descriptor :: String => {
244
258
let kind = arg. vector_kind ( ) . ok_or_else ( || {
245
259
format_err ! (
@@ -281,6 +295,7 @@ impl OutgoingBuilder<'_> {
281
295
self . bindings
282
296
. push ( NonstandardOutgoing :: BorrowedAnyref { idx } ) ;
283
297
}
298
+ Descriptor :: CachedString => self . cached_string ( false , false ) ,
284
299
Descriptor :: Slice ( _) | Descriptor :: String => {
285
300
use wasm_webidl_bindings:: ast:: WebidlScalarType :: * ;
286
301
@@ -422,6 +437,9 @@ impl OutgoingBuilder<'_> {
422
437
}
423
438
Descriptor :: Ref ( d) => self . process_option_ref ( false , d) ?,
424
439
Descriptor :: RefMut ( d) => self . process_option_ref ( true , d) ?,
440
+
441
+ Descriptor :: CachedString => self . cached_string ( true , true ) ,
442
+
425
443
Descriptor :: String | Descriptor :: Vector ( _) => {
426
444
let kind = arg. vector_kind ( ) . ok_or_else ( || {
427
445
format_err ! (
@@ -455,6 +473,7 @@ impl OutgoingBuilder<'_> {
455
473
self . bindings
456
474
. push ( NonstandardOutgoing :: BorrowedAnyref { idx } ) ;
457
475
}
476
+ Descriptor :: CachedString => self . cached_string ( true , false ) ,
458
477
Descriptor :: String | Descriptor :: Slice ( _) => {
459
478
let kind = arg. vector_kind ( ) . ok_or_else ( || {
460
479
format_err ! (
@@ -505,6 +524,18 @@ impl OutgoingBuilder<'_> {
505
524
. push ( NonstandardOutgoing :: Standard ( binding. into ( ) ) ) ;
506
525
}
507
526
527
+ fn cached_string ( & mut self , optional : bool , owned : bool ) {
528
+ let offset = self . push_wasm ( ValType :: I32 ) ;
529
+ let length = self . push_wasm ( ValType :: I32 ) ;
530
+ self . webidl . push ( ast:: WebidlScalarType :: DomString ) ;
531
+ self . bindings . push ( NonstandardOutgoing :: CachedString {
532
+ offset,
533
+ length,
534
+ owned,
535
+ optional,
536
+ } )
537
+ }
538
+
508
539
fn option_native ( & mut self , signed : bool , ty : ValType ) {
509
540
let present = self . push_wasm ( ValType :: I32 ) ;
510
541
let val = self . push_wasm ( ty) ;
0 commit comments