@@ -95,6 +95,26 @@ pub struct WasmtimeStoreData {
9595
9696 /// Limits for the store.
9797 pub store_limits : StoreLimits ,
98+
99+ #[ cfg( feature = "component-model" ) ]
100+ pub ( crate ) resource_table : wasmtime:: component:: ResourceTable ,
101+
102+ #[ cfg( all( feature = "component-model" , feature = "wasi" ) ) ]
103+ pub ( crate ) wasip2 : Option < wasmtime_wasi:: p2:: WasiCtx > ,
104+ }
105+
106+ #[ cfg( all( feature = "component-model" , feature = "wasi" ) ) ]
107+ impl wasmtime_wasi:: p2:: IoView for WasmtimeStoreData {
108+ fn table ( & mut self ) -> & mut wasmtime_wasi:: ResourceTable {
109+ & mut self . resource_table
110+ }
111+ }
112+
113+ #[ cfg( all( feature = "component-model" , feature = "wasi" ) ) ]
114+ impl wasmtime_wasi:: p2:: WasiView for WasmtimeStoreData {
115+ fn ctx ( & mut self ) -> & mut wasmtime_wasi:: p2:: WasiCtx {
116+ self . wasip2 . as_mut ( ) . unwrap ( )
117+ }
98118}
99119
100120#[ unsafe( no_mangle) ]
@@ -113,6 +133,10 @@ pub extern "C" fn wasmtime_store_new(
113133 hostcall_val_storage : Vec :: new ( ) ,
114134 wasm_val_storage : Vec :: new ( ) ,
115135 store_limits : StoreLimits :: default ( ) ,
136+ #[ cfg( feature = "component-model" ) ]
137+ resource_table : wasmtime:: component:: ResourceTable :: default ( ) ,
138+ #[ cfg( all( feature = "component-model" , feature = "wasi" ) ) ]
139+ wasip2 : None ,
116140 } ,
117141 ) ,
118142 } )
@@ -217,6 +241,15 @@ pub extern "C" fn wasmtime_context_set_wasi(
217241 } )
218242}
219243
244+ #[ cfg( all( feature = "component-model" , feature = "wasi" ) ) ]
245+ #[ unsafe( no_mangle) ]
246+ pub unsafe extern "C" fn wasmtime_context_set_wasip2 (
247+ mut context : WasmtimeStoreContextMut < ' _ > ,
248+ mut config : Box < crate :: wasmtime_wasip2_config_t > ,
249+ ) {
250+ context. data_mut ( ) . wasip2 = Some ( config. builder . build ( ) ) ;
251+ }
252+
220253#[ unsafe( no_mangle) ]
221254pub extern "C" fn wasmtime_context_gc ( mut context : WasmtimeStoreContextMut < ' _ > ) {
222255 context. gc ( None ) ;
0 commit comments