@@ -30,13 +30,7 @@ pub trait AbiArgument {
3030 fn to_bytes (
3131 & self ,
3232 buffer : & mut Vec < u8 > ,
33- find_dict_overrides : impl Copy
34- + Fn (
35- & ConcreteTypeId ,
36- ) -> (
37- Option < extern "C" fn ( * mut c_void , * mut c_void ) > ,
38- Option < extern "C" fn ( * mut c_void ) > ,
39- ) ,
33+ find_dict_drop_override : impl Copy + Fn ( & ConcreteTypeId ) -> Option < extern "C" fn ( * mut c_void ) > ,
4034 ) -> Result < ( ) > ;
4135}
4236
@@ -74,18 +68,16 @@ impl AbiArgument for ValueWithInfoWrapper<'_> {
7468 fn to_bytes (
7569 & self ,
7670 buffer : & mut Vec < u8 > ,
77- find_dict_overrides : impl Copy
78- + Fn (
79- & ConcreteTypeId ,
80- ) -> (
81- Option < extern "C" fn ( * mut c_void , * mut c_void ) > ,
82- Option < extern "C" fn ( * mut c_void ) > ,
83- ) ,
71+ find_dict_drop_override : impl Copy + Fn ( & ConcreteTypeId ) -> Option < extern "C" fn ( * mut c_void ) > ,
8472 ) -> Result < ( ) > {
8573 match ( self . value , self . info ) {
8674 ( value, CoreTypeConcrete :: Box ( info) ) => {
87- let ptr =
88- value. to_ptr ( self . arena , self . registry , self . type_id , find_dict_overrides) ?;
75+ let ptr = value. to_ptr (
76+ self . arena ,
77+ self . registry ,
78+ self . type_id ,
79+ find_dict_drop_override,
80+ ) ?;
8981
9082 let layout = self . registry . get_type ( & info. ty ) ?. layout ( self . registry ) ?;
9183 let heap_ptr = unsafe {
@@ -94,17 +86,17 @@ impl AbiArgument for ValueWithInfoWrapper<'_> {
9486 heap_ptr
9587 } ;
9688
97- heap_ptr. to_bytes ( buffer, find_dict_overrides ) ?;
89+ heap_ptr. to_bytes ( buffer, find_dict_drop_override ) ?;
9890 }
9991 ( value, CoreTypeConcrete :: Nullable ( info) ) => {
10092 if matches ! ( value, Value :: Null ) {
101- null :: < ( ) > ( ) . to_bytes ( buffer, find_dict_overrides ) ?;
93+ null :: < ( ) > ( ) . to_bytes ( buffer, find_dict_drop_override ) ?;
10294 } else {
10395 let ptr = value. to_ptr (
10496 self . arena ,
10597 self . registry ,
10698 self . type_id ,
107- find_dict_overrides ,
99+ find_dict_drop_override ,
108100 ) ?;
109101
110102 let layout = self . registry . get_type ( & info. ty ) ?. layout ( self . registry ) ?;
@@ -114,12 +106,12 @@ impl AbiArgument for ValueWithInfoWrapper<'_> {
114106 heap_ptr
115107 } ;
116108
117- heap_ptr. to_bytes ( buffer, find_dict_overrides ) ?;
109+ heap_ptr. to_bytes ( buffer, find_dict_drop_override ) ?;
118110 }
119111 }
120112 ( value, CoreTypeConcrete :: NonZero ( info) | CoreTypeConcrete :: Snapshot ( info) ) => self
121113 . map ( value, & info. ty ) ?
122- . to_bytes ( buffer, find_dict_overrides ) ?,
114+ . to_bytes ( buffer, find_dict_drop_override ) ?,
123115
124116 ( Value :: Array ( _) , CoreTypeConcrete :: Array ( _) ) => {
125117 // TODO: Assert that `info.ty` matches all the values' types.
@@ -128,50 +120,50 @@ impl AbiArgument for ValueWithInfoWrapper<'_> {
128120 self . arena ,
129121 self . registry ,
130122 self . type_id ,
131- find_dict_overrides ,
123+ find_dict_drop_override ,
132124 ) ?;
133125 let abi = unsafe { abi_ptr. cast :: < ArrayAbi < ( ) > > ( ) . as_ref ( ) } ;
134126
135- abi. ptr . to_bytes ( buffer, find_dict_overrides ) ?;
136- abi. since . to_bytes ( buffer, find_dict_overrides ) ?;
137- abi. until . to_bytes ( buffer, find_dict_overrides ) ?;
138- abi. capacity . to_bytes ( buffer, find_dict_overrides ) ?;
127+ abi. ptr . to_bytes ( buffer, find_dict_drop_override ) ?;
128+ abi. since . to_bytes ( buffer, find_dict_drop_override ) ?;
129+ abi. until . to_bytes ( buffer, find_dict_drop_override ) ?;
130+ abi. capacity . to_bytes ( buffer, find_dict_drop_override ) ?;
139131 }
140132 ( Value :: BoundedInt { .. } , CoreTypeConcrete :: BoundedInt ( _) ) => {
141133 native_panic ! ( "todo: implement AbiArgument for Value::BoundedInt case" )
142134 }
143135 ( Value :: Bytes31 ( value) , CoreTypeConcrete :: Bytes31 ( _) ) => {
144- value. to_bytes ( buffer, find_dict_overrides ) ?
136+ value. to_bytes ( buffer, find_dict_drop_override ) ?
145137 }
146138 ( Value :: EcPoint ( x, y) , CoreTypeConcrete :: EcPoint ( _) ) => {
147- x. to_bytes ( buffer, find_dict_overrides ) ?;
148- y. to_bytes ( buffer, find_dict_overrides ) ?;
139+ x. to_bytes ( buffer, find_dict_drop_override ) ?;
140+ y. to_bytes ( buffer, find_dict_drop_override ) ?;
149141 }
150142 ( Value :: EcState ( x, y, x0, y0) , CoreTypeConcrete :: EcState ( _) ) => {
151- x. to_bytes ( buffer, find_dict_overrides ) ?;
152- y. to_bytes ( buffer, find_dict_overrides ) ?;
153- x0. to_bytes ( buffer, find_dict_overrides ) ?;
154- y0. to_bytes ( buffer, find_dict_overrides ) ?;
143+ x. to_bytes ( buffer, find_dict_drop_override ) ?;
144+ y. to_bytes ( buffer, find_dict_drop_override ) ?;
145+ x0. to_bytes ( buffer, find_dict_drop_override ) ?;
146+ y0. to_bytes ( buffer, find_dict_drop_override ) ?;
155147 }
156148 ( Value :: Enum { tag, value, .. } , CoreTypeConcrete :: Enum ( info) ) => {
157149 if self . info . is_memory_allocated ( self . registry ) ? {
158150 let abi_ptr = self . value . to_ptr (
159151 self . arena ,
160152 self . registry ,
161153 self . type_id ,
162- find_dict_overrides ,
154+ find_dict_drop_override ,
163155 ) ?;
164156
165157 let abi_ptr = unsafe { * abi_ptr. cast :: < NonNull < ( ) > > ( ) . as_ref ( ) } ;
166- abi_ptr. as_ptr ( ) . to_bytes ( buffer, find_dict_overrides ) ?;
158+ abi_ptr. as_ptr ( ) . to_bytes ( buffer, find_dict_drop_override ) ?;
167159 } else {
168160 match ( info. variants . len ( ) . next_power_of_two ( ) . trailing_zeros ( ) + 7 ) / 8 {
169161 0 => { }
170- _ => ( * tag as u64 ) . to_bytes ( buffer, find_dict_overrides ) ?,
162+ _ => ( * tag as u64 ) . to_bytes ( buffer, find_dict_drop_override ) ?,
171163 }
172164
173165 self . map ( value, & info. variants [ * tag] ) ?
174- . to_bytes ( buffer, find_dict_overrides ) ?;
166+ . to_bytes ( buffer, find_dict_drop_override ) ?;
175167 }
176168 }
177169 (
@@ -183,14 +175,19 @@ impl AbiArgument for ValueWithInfoWrapper<'_> {
183175 | StarkNetTypeConcrete :: StorageAddress ( _)
184176 | StarkNetTypeConcrete :: StorageBaseAddress ( _) ,
185177 ) ,
186- ) => value. to_bytes ( buffer, find_dict_overrides ) ?,
178+ ) => value. to_bytes ( buffer, find_dict_drop_override ) ?,
187179 ( Value :: Felt252Dict { .. } , CoreTypeConcrete :: Felt252Dict ( _) ) => {
188180 // TODO: Assert that `info.ty` matches all the values' types.
189181
190182 self . value
191- . to_ptr ( self . arena , self . registry , self . type_id , find_dict_overrides) ?
183+ . to_ptr (
184+ self . arena ,
185+ self . registry ,
186+ self . type_id ,
187+ find_dict_drop_override,
188+ ) ?
192189 . as_ptr ( )
193- . to_bytes ( buffer, find_dict_overrides ) ?
190+ . to_bytes ( buffer, find_dict_drop_override ) ?
194191 }
195192 (
196193 Value :: Secp256K1Point ( Secp256k1Point { x, y, is_infinity } ) ,
@@ -204,46 +201,46 @@ impl AbiArgument for ValueWithInfoWrapper<'_> {
204201 Secp256PointTypeConcrete :: R1 ( _) ,
205202 ) ) ,
206203 ) => {
207- x. to_bytes ( buffer, find_dict_overrides ) ?;
208- y. to_bytes ( buffer, find_dict_overrides ) ?;
209- is_infinity. to_bytes ( buffer, find_dict_overrides ) ?;
204+ x. to_bytes ( buffer, find_dict_drop_override ) ?;
205+ y. to_bytes ( buffer, find_dict_drop_override ) ?;
206+ is_infinity. to_bytes ( buffer, find_dict_drop_override ) ?;
210207 }
211208 ( Value :: Sint128 ( value) , CoreTypeConcrete :: Sint128 ( _) ) => {
212- value. to_bytes ( buffer, find_dict_overrides ) ?
209+ value. to_bytes ( buffer, find_dict_drop_override ) ?
213210 }
214211 ( Value :: Sint16 ( value) , CoreTypeConcrete :: Sint16 ( _) ) => {
215- value. to_bytes ( buffer, find_dict_overrides ) ?
212+ value. to_bytes ( buffer, find_dict_drop_override ) ?
216213 }
217214 ( Value :: Sint32 ( value) , CoreTypeConcrete :: Sint32 ( _) ) => {
218- value. to_bytes ( buffer, find_dict_overrides ) ?
215+ value. to_bytes ( buffer, find_dict_drop_override ) ?
219216 }
220217 ( Value :: Sint64 ( value) , CoreTypeConcrete :: Sint64 ( _) ) => {
221- value. to_bytes ( buffer, find_dict_overrides ) ?
218+ value. to_bytes ( buffer, find_dict_drop_override ) ?
222219 }
223220 ( Value :: Sint8 ( value) , CoreTypeConcrete :: Sint8 ( _) ) => {
224- value. to_bytes ( buffer, find_dict_overrides ) ?
221+ value. to_bytes ( buffer, find_dict_drop_override ) ?
225222 }
226223 ( Value :: Struct { fields, .. } , CoreTypeConcrete :: Struct ( info) ) => {
227224 fields
228225 . iter ( )
229226 . zip ( & info. members )
230227 . map ( |( value, type_id) | self . map ( value, type_id) )
231- . try_for_each ( |wrapper| wrapper?. to_bytes ( buffer, find_dict_overrides ) ) ?;
228+ . try_for_each ( |wrapper| wrapper?. to_bytes ( buffer, find_dict_drop_override ) ) ?;
232229 }
233230 ( Value :: Uint128 ( value) , CoreTypeConcrete :: Uint128 ( _) ) => {
234- value. to_bytes ( buffer, find_dict_overrides ) ?
231+ value. to_bytes ( buffer, find_dict_drop_override ) ?
235232 }
236233 ( Value :: Uint16 ( value) , CoreTypeConcrete :: Uint16 ( _) ) => {
237- value. to_bytes ( buffer, find_dict_overrides ) ?
234+ value. to_bytes ( buffer, find_dict_drop_override ) ?
238235 }
239236 ( Value :: Uint32 ( value) , CoreTypeConcrete :: Uint32 ( _) ) => {
240- value. to_bytes ( buffer, find_dict_overrides ) ?
237+ value. to_bytes ( buffer, find_dict_drop_override ) ?
241238 }
242239 ( Value :: Uint64 ( value) , CoreTypeConcrete :: Uint64 ( _) ) => {
243- value. to_bytes ( buffer, find_dict_overrides ) ?
240+ value. to_bytes ( buffer, find_dict_drop_override ) ?
244241 }
245242 ( Value :: Uint8 ( value) , CoreTypeConcrete :: Uint8 ( _) ) => {
246- value. to_bytes ( buffer, find_dict_overrides ) ?
243+ value. to_bytes ( buffer, find_dict_drop_override ) ?
247244 }
248245 _ => native_panic ! (
249246 "todo: abi argument unimplemented for ({:?}, {:?})" ,
0 commit comments