@@ -88,17 +88,15 @@ fn make_native_structure(
8888
8989 let imports = util:: make_imports ( ) ;
9090 let ( fields, methods) = make_native_structure_fields_and_methods ( structure, ctx) ;
91- let doc = format ! ( "[`ToGodot`] and [`FromGodot`] are implemented for `*mut {class_name}` and `*const {class_name}`." ) ;
9291
9392 // mod re_export needed, because class should not appear inside the file module, and we can't re-export private struct as pub
9493 let tokens = quote ! {
9594 #imports
9695 use std:: ffi:: c_void; // for opaque object pointer fields
97- use crate :: meta:: { GodotConvert , FromGodot , ToGodot } ;
96+ use crate :: meta:: { GodotConvert , EngineFromGodot , EngineToGodot } ;
9897
9998 /// Native structure; can be passed via pointer in APIs that are not exposed to GDScript.
10099 ///
101- #[ doc = #doc]
102100 #[ derive( Clone , PartialEq , Debug ) ]
103101 #[ repr( C ) ]
104102 pub struct #class_name {
@@ -113,36 +111,53 @@ fn make_native_structure(
113111 type Via = i64 ;
114112 }
115113
116- impl ToGodot for * mut #class_name {
114+ // Native structure pointers implement internal-only conversion traits for use in engine APIs.
115+ impl EngineToGodot for * mut #class_name {
117116 type Pass = crate :: meta:: ByValue ;
118117
119- fn to_godot ( & self ) -> Self :: Via {
118+ fn engine_to_godot ( & self ) -> crate :: meta :: ToArg < ' _ , Self :: Via , Self :: Pass > {
120119 * self as i64
121120 }
121+
122+ fn engine_to_variant( & self ) -> crate :: builtin:: Variant {
123+ crate :: builtin:: Variant :: from( * self as i64 )
124+ }
122125 }
123126
124- impl FromGodot for * mut #class_name {
125- fn try_from_godot ( via: Self :: Via ) -> Result <Self , crate :: meta:: error:: ConvertError > {
127+ impl EngineFromGodot for * mut #class_name {
128+ fn engine_try_from_godot ( via: Self :: Via ) -> Result <Self , crate :: meta:: error:: ConvertError > {
126129 Ok ( via as Self )
127130 }
131+
132+ fn engine_try_from_variant( variant: & crate :: builtin:: Variant ) -> Result <Self , crate :: meta:: error:: ConvertError > {
133+ variant. try_to:: <i64 >( ) . map( |i| i as Self )
134+ }
128135 }
129136
130137 impl GodotConvert for * const #class_name {
131138 type Via = i64 ;
132139 }
133140
134- impl ToGodot for * const #class_name {
141+ impl EngineToGodot for * const #class_name {
135142 type Pass = crate :: meta:: ByValue ;
136143
137- fn to_godot ( & self ) -> Self :: Via {
144+ fn engine_to_godot ( & self ) -> crate :: meta :: ToArg < ' _ , Self :: Via , Self :: Pass > {
138145 * self as i64
139146 }
147+
148+ fn engine_to_variant( & self ) -> crate :: builtin:: Variant {
149+ crate :: builtin:: Variant :: from( * self as i64 )
150+ }
140151 }
141152
142- impl FromGodot for * const #class_name {
143- fn try_from_godot ( via: Self :: Via ) -> Result <Self , crate :: meta:: error:: ConvertError > {
153+ impl EngineFromGodot for * const #class_name {
154+ fn engine_try_from_godot ( via: Self :: Via ) -> Result <Self , crate :: meta:: error:: ConvertError > {
144155 Ok ( via as Self )
145156 }
157+
158+ fn engine_try_from_variant( variant: & crate :: builtin:: Variant ) -> Result <Self , crate :: meta:: error:: ConvertError > {
159+ variant. try_to:: <i64 >( ) . map( |i| i as Self )
160+ }
146161 }
147162 } ;
148163 // note: TypePtr -> ObjectPtr conversion OK?
0 commit comments