Skip to content

Commit 773e42e

Browse files
committed
Rename #[class(hidden)] -> #[class(internal)]
1 parent e3c6335 commit 773e42e

File tree

5 files changed

+34
-21
lines changed

5 files changed

+34
-21
lines changed

godot-core/src/deprecated.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,11 @@ pub const fn init_default() {}
4343

4444
#[deprecated = "\nThe attribute key #[class(editor_plugin)] is now implied by #[class(base = EditorPlugin)]. It is ignored.\n\
4545
More information on https://github.com/godot-rust/gdext/pull/884."]
46-
pub const fn editor_plugin() {}
46+
pub const fn class_editor_plugin() {}
47+
48+
#[deprecated = "\nThe attribute key #[class(hidden)] has been renamed to #[class(internal)], following Godot terminology.\n\
49+
More information on https://github.com/godot-rust/gdext/pull/884."]
50+
pub const fn class_hidden() {}
4751

4852
// ----------------------------------------------------------------------------------------------------------------------------------------------
4953
// Godot-side deprecations

godot-core/src/registry/class.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ fn fill_class_info(item: PluginItem, c: &mut ClassRegistrationInfo) {
229229
default_get_virtual_fn,
230230
is_tool,
231231
is_editor_plugin,
232-
is_hidden,
232+
is_internal,
233233
is_instantiable,
234234
#[cfg(all(since_api = "4.3", feature = "docs"))]
235235
docs: _,
@@ -257,7 +257,7 @@ fn fill_class_info(item: PluginItem, c: &mut ClassRegistrationInfo) {
257257
.expect("duplicate: create_instance_func (def)");
258258

259259
#[cfg(before_api = "4.2")]
260-
let _ = is_hidden; // mark used
260+
let _ = is_internal; // mark used
261261
#[cfg(since_api = "4.2")]
262262
{
263263
fill_into(
@@ -266,7 +266,7 @@ fn fill_class_info(item: PluginItem, c: &mut ClassRegistrationInfo) {
266266
)
267267
.expect("duplicate: recreate_instance_func (def)");
268268

269-
c.godot_params.is_exposed = sys::conv::bool_to_sys(!is_hidden);
269+
c.godot_params.is_exposed = sys::conv::bool_to_sys(!is_internal);
270270
}
271271

272272
#[cfg(before_api = "4.2")]

godot-core/src/registry/plugin.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,11 @@ pub enum PluginItem {
8989
/// Whether `#[class(tool)]` was used.
9090
is_tool: bool,
9191

92-
/// Whether `#[class(editor_plugin)]` was used.
92+
/// Whether the base class is an `EditorPlugin`.
9393
is_editor_plugin: bool,
9494

95-
/// Whether `#[class(hidden)]` was used.
96-
is_hidden: bool,
95+
/// Whether `#[class(internal)]` was used.
96+
is_internal: bool,
9797

9898
/// Whether the class has a default constructor.
9999
is_instantiable: bool,

godot-macros/src/class/derive_godot_class.rs

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ pub fn derive_godot_class(item: venial::Item) -> ParseResult<TokenStream> {
2626
let is_editor_plugin = struct_cfg.is_editor_plugin();
2727

2828
let mut deprecations = std::mem::take(&mut struct_cfg.deprecations);
29-
deprecations.extend(fields.deprecations.drain(..));
29+
deprecations.append(&mut fields.deprecations);
3030

3131
let class_name = &class.name;
3232
let class_name_str: String = struct_cfg
@@ -37,7 +37,7 @@ pub fn derive_godot_class(item: venial::Item) -> ParseResult<TokenStream> {
3737
let class_name_cstr = util::c_str(&class_name_str);
3838
let class_name_obj = util::class_name_obj(class_name);
3939

40-
let is_hidden = struct_cfg.is_hidden;
40+
let is_internal = struct_cfg.is_internal;
4141
let base_ty = &struct_cfg.base_ty;
4242
#[cfg(all(feature = "docs", since_api = "4.3"))]
4343
let docs = crate::docs::make_definition_docs(
@@ -155,7 +155,7 @@ pub fn derive_godot_class(item: venial::Item) -> ParseResult<TokenStream> {
155155
default_get_virtual_fn: #default_get_virtual_fn,
156156
is_tool: #is_tool,
157157
is_editor_plugin: #is_editor_plugin,
158-
is_hidden: #is_hidden,
158+
is_internal: #is_internal,
159159
is_instantiable: #is_instantiable,
160160
#docs
161161
},
@@ -203,7 +203,7 @@ struct ClassAttributes {
203203
base_ty: Ident,
204204
init_strategy: InitStrategy,
205205
is_tool: bool,
206-
is_hidden: bool,
206+
is_internal: bool,
207207
rename: Option<Ident>,
208208
deprecations: Vec<TokenStream>,
209209
}
@@ -318,7 +318,7 @@ fn parse_struct_attributes(class: &venial::Struct) -> ParseResult<ClassAttribute
318318
let mut base_ty = ident("RefCounted");
319319
let mut init_strategy = InitStrategy::UserDefined;
320320
let mut is_tool = false;
321-
let mut is_hidden = false;
321+
let mut is_internal = false;
322322
let mut rename: Option<Ident> = None;
323323
let mut deprecations = vec![];
324324

@@ -341,22 +341,31 @@ fn parse_struct_attributes(class: &venial::Struct) -> ParseResult<ClassAttribute
341341
is_tool = true;
342342
}
343343

344-
// #[class(editor_plugin)]
344+
// Deprecated #[class(editor_plugin)]
345345
if let Some(_attr_key) = parser.handle_alone_with_span("editor_plugin")? {
346346
deprecations.push(quote! {
347-
::godot::__deprecated::emit_deprecated_warning!(editor_plugin);
347+
::godot::__deprecated::emit_deprecated_warning!(class_editor_plugin);
348348
});
349349
}
350350

351351
// #[class(rename = NewName)]
352352
rename = parser.handle_ident("rename")?;
353353

354-
// #[class(hidden)]
355-
// TODO consider naming this "internal"; godot-cpp uses that terminology:
356-
// https://github.com/godotengine/godot-cpp/blob/master/include/godot_cpp/core/class_db.hpp#L327
354+
// #[class(internal)]
355+
// Named "internal" following Godot terminology: https://github.com/godotengine/godot-cpp/blob/master/include/godot_cpp/core/class_db.hpp#L327
356+
if let Some(span) = parser.handle_alone_with_span("internal")? {
357+
require_api_version!("4.2", span, "#[class(internal)]")?;
358+
is_internal = true;
359+
}
360+
361+
// Deprecated #[class(hidden)]
357362
if let Some(span) = parser.handle_alone_with_span("hidden")? {
358363
require_api_version!("4.2", span, "#[class(hidden)]")?;
359-
is_hidden = true;
364+
is_internal = true;
365+
366+
deprecations.push(quote! {
367+
::godot::__deprecated::emit_deprecated_warning!(class_hidden);
368+
});
360369
}
361370

362371
parser.finish()?;
@@ -368,7 +377,7 @@ fn parse_struct_attributes(class: &venial::Struct) -> ParseResult<ClassAttribute
368377
base_ty,
369378
init_strategy,
370379
is_tool,
371-
is_hidden,
380+
is_internal,
372381
rename,
373382
deprecations,
374383
})

godot-macros/src/lib.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -400,12 +400,12 @@ use crate::util::ident;
400400
///
401401
/// ## Class hiding
402402
///
403-
/// If you want to register a class with Godot, but not have it show up in the editor then you can use `#[class(hidden)]`.
403+
/// If you want to register a class with Godot, but not have it show up in the editor then you can use `#[class(internal)]`.
404404
///
405405
/// ```
406406
/// # use godot::prelude::*;
407407
/// #[derive(GodotClass)]
408-
/// #[class(base=Node, init, hidden)]
408+
/// #[class(base=Node, init, internal)]
409409
/// pub struct Foo {}
410410
/// ```
411411
///

0 commit comments

Comments
 (0)