@@ -147,7 +147,7 @@ impl RustNativeGeneratedElement for SmartPtr<'_, '_> {
147
147
let rust_as_raw_mut = type_ref. rust_as_raw_name ( Constness :: Mut ) ;
148
148
149
149
let ctor = if gen_ctor ( & pointee_kind) {
150
- let extern_new = method_new ( smartptr_class. clone ( ) , type_ref, pointee_type. as_ref ( ) . clone ( ) ) . identifier ( ) ;
150
+ let extern_new = method_new ( smartptr_class. clone ( ) , type_ref. clone ( ) , pointee_type. as_ref ( ) . clone ( ) ) . identifier ( ) ;
151
151
CTOR_TPL . interpolate ( & HashMap :: from ( [
152
152
( "inner_rust_full" , inner_rust_full. as_ref ( ) ) ,
153
153
( "extern_new" , & extern_new) ,
@@ -156,13 +156,15 @@ impl RustNativeGeneratedElement for SmartPtr<'_, '_> {
156
156
"" . to_string ( )
157
157
} ;
158
158
159
+ let extern_new_null = method_new_null ( smartptr_class. clone ( ) , type_ref) . identifier ( ) ;
159
160
let extern_delete = FuncDesc :: method_delete ( smartptr_class) . identifier ( ) ;
160
161
TPL . interpolate ( & HashMap :: from ( [
161
162
( "rust_localalias" , rust_localalias. as_ref ( ) ) ,
162
163
( "rust_as_raw_const" , & rust_as_raw_const) ,
163
164
( "rust_as_raw_mut" , & rust_as_raw_mut) ,
164
165
( "rust_full" , & rust_full) ,
165
166
( "inner_rust_full" , & inner_rust_full) ,
167
+ ( "extern_new_null" , & extern_new_null) ,
166
168
( "extern_delete" , & extern_delete) ,
167
169
( "extern_get_inner_ptr" , & extern_get_inner_ptr) ,
168
170
( "extern_get_inner_ptr_mut" , & extern_get_inner_ptr_mut) ,
@@ -197,6 +199,7 @@ fn extern_functions<'tu, 'ge>(ptr: &SmartPtr<'tu, 'ge>) -> Vec<Func<'tu, 'ge>> {
197
199
smartptr_class. clone ( ) ,
198
200
pointee_type. as_ref ( ) . clone ( ) . with_inherent_constness ( Constness :: Mut ) ,
199
201
) ) ;
202
+ out. push ( method_new_null ( smartptr_class. clone ( ) , type_ref. clone ( ) ) ) ;
200
203
out. push ( FuncDesc :: method_delete ( smartptr_class. clone ( ) ) ) ;
201
204
if let Some ( cls) = pointee_kind. as_class ( ) . filter ( |cls| cls. kind ( ) . is_trait ( ) ) {
202
205
for base in all_bases ( & cls) {
@@ -297,6 +300,21 @@ fn method_new<'tu, 'ge>(
297
300
)
298
301
}
299
302
303
+ fn method_new_null < ' tu , ' ge > ( smartptr_class : Class < ' tu , ' ge > , smartptr_type_ref : TypeRef < ' tu , ' ge > ) -> Func < ' tu , ' ge > {
304
+ Func :: new_desc (
305
+ FuncDesc :: new (
306
+ FuncKind :: Constructor ( smartptr_class) ,
307
+ Constness :: Const ,
308
+ ReturnKind :: InfallibleNaked ,
309
+ "new_null" ,
310
+ "<unused>" ,
311
+ [ ] ,
312
+ smartptr_type_ref,
313
+ )
314
+ . cpp_body ( FuncCppBody :: ManualCallReturn ( "return new {{ret_type}}();" . into ( ) ) ) ,
315
+ )
316
+ }
317
+
300
318
fn method_cast_to_base < ' tu , ' ge > (
301
319
smartptr_class : Class < ' tu , ' ge > ,
302
320
base_type_ref : TypeRef < ' tu , ' ge > ,
0 commit comments