@@ -119,6 +119,73 @@ unsafe extern "C" fn ffi_deinitialize_layer<E: ExtensionLibrary>(
119
119
} ) ;
120
120
}
121
121
122
+ #[ cfg( since_api = "4.3" ) ]
123
+ unsafe fn register ( ) {
124
+ use crate :: registry:: plugin:: PluginItem ;
125
+ use std:: collections:: { hash_map:: Entry , HashMap } ;
126
+ #[ derive( Default ) ]
127
+ struct DocPieces {
128
+ /// base, description, members
129
+ definition : [ & ' static str ; 3 ] ,
130
+ /// methods, signals, constants
131
+ inherent : [ & ' static str ; 3 ] ,
132
+ imethods : & ' static str ,
133
+ }
134
+
135
+ let mut map = HashMap :: < & ' static str , DocPieces > :: new ( ) ;
136
+ crate :: private:: iterate_plugins ( |x| match x. item {
137
+ PluginItem :: InherentImpl { docs, .. } => match map. entry ( x. class_name . as_str ( ) ) {
138
+ Entry :: Occupied ( x) => x. into_mut ( ) . inherent = docs,
139
+ Entry :: Vacant ( x) => drop ( x. insert ( DocPieces {
140
+ inherent : docs,
141
+ ..Default :: default ( )
142
+ } ) ) ,
143
+ } ,
144
+ PluginItem :: ITraitImpl { docs, .. } => match map. entry ( x. class_name . as_str ( ) ) {
145
+ Entry :: Occupied ( x) => x. into_mut ( ) . imethods = docs,
146
+ Entry :: Vacant ( x) => drop ( x. insert ( DocPieces {
147
+ imethods : docs,
148
+ ..Default :: default ( )
149
+ } ) ) ,
150
+ } ,
151
+ PluginItem :: Struct { docs, .. } => match map. entry ( x. class_name . as_str ( ) ) {
152
+ Entry :: Occupied ( x) => x. into_mut ( ) . definition = docs,
153
+ Entry :: Vacant ( x) => drop ( x. insert ( DocPieces {
154
+ definition : docs,
155
+ ..Default :: default ( )
156
+ } ) ) ,
157
+ } ,
158
+ } ) ;
159
+ for (
160
+ class,
161
+ DocPieces {
162
+ definition : [ base, desc, members] ,
163
+ inherent : [ methods, signals, constants] ,
164
+ imethods,
165
+ } ,
166
+ ) in map
167
+ {
168
+ let brief = desc. lines ( ) . next ( ) . unwrap_or_default ( ) ;
169
+ let xml = format ! (
170
+ r#"
171
+ <?xml version="1.0" encoding="UTF-8"?>
172
+ <class name="{class}" inherits="{base}" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
173
+ <brief_description>{brief}</brief_description>
174
+ <description>{desc}</description>
175
+ <methods>{methods}{imethods}</methods>
176
+ <constants>{constants}</constants>
177
+ <signals>{signals}</signals>
178
+ <members>{members}</members>
179
+ </class>"#
180
+ ) ;
181
+ // SAFETY: the godot binding is initialized
182
+ crate :: sys:: interface_fn!( editor_help_load_xml_from_utf8_chars_and_len) (
183
+ xml. as_ptr ( ) . cast ( ) ,
184
+ xml. len ( ) as _ ,
185
+ ) ;
186
+ }
187
+ }
188
+
122
189
/// Tasks needed to be done by gdext internally upon loading an initialization level. Called before user code.
123
190
fn gdext_on_level_init ( level : InitLevel ) {
124
191
// SAFETY: we are in the main thread, during initialization, no other logic is happening.
@@ -136,6 +203,8 @@ fn gdext_on_level_init(level: InitLevel) {
136
203
ensure_godot_features_compatible ( ) ;
137
204
}
138
205
InitLevel :: Editor => {
206
+ #[ cfg( since_api = "4.3" ) ]
207
+ register ( ) ;
139
208
sys:: load_class_method_table ( sys:: ClassApiLevel :: Editor ) ;
140
209
}
141
210
}
0 commit comments