Skip to content

Commit

Permalink
Rename 2 OpenXR classes for readability
Browse files Browse the repository at this point in the history
  • Loading branch information
Bromeon committed Oct 20, 2023
1 parent 3234344 commit e8017d5
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
5 changes: 5 additions & 0 deletions godot-codegen/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ fn test_pascal_conversion() {
("JSONRPC", "JsonRpc"),
("NetworkedMultiplayerENet", "NetworkedMultiplayerENet"),
("ObjectID", "ObjectId"),
("OpenXRAPIExtension", "OpenXrApiExtension"),
("ObjectID", "ObjectId"),
("OpenXRIPBinding", "OpenXrIpBinding"),
("PackedFloat32Array", "PackedFloat32Array"),
("PCKPacker", "PckPacker"),
("PHashTranslation", "PHashTranslation"),
Expand Down Expand Up @@ -77,6 +80,8 @@ fn test_snake_conversion() {
("JSONRPC", "json_rpc"),
("NetworkedMultiplayerENet", "networked_multiplayer_e_net"),
("ObjectID", "object_id"),
("OpenXRAPIExtension", "open_xr_api_extension"),
("OpenXRIPBinding", "open_xr_ip_binding"),
("PackedFloat32Array", "packed_float32_array"),
("PCKPacker", "pck_packer"),
("PHashTranslation", "p_hash_translation"),
Expand Down
11 changes: 7 additions & 4 deletions godot-codegen/src/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use crate::{Context, GodotTy, ModName, RustTy, TyName};
use proc_macro2::{Ident, Literal, TokenStream};
use quote::{format_ident, quote, ToTokens};

use heck::ToPascalCase;
use std::fmt;

#[derive(Clone, Debug, PartialEq, Eq)]
Expand Down Expand Up @@ -431,9 +432,10 @@ pub fn to_snake_case(class_name: &str) -> String {
use heck::ToSnakeCase;

// Special cases
#[allow(clippy::single_match)]
match class_name {
"JSONRPC" => return "json_rpc".to_string(),
"OpenXRAPIExtension" => return "open_xr_api_extension".to_string(),
"OpenXRIPBinding" => return "open_xr_ip_binding".to_string(),
_ => {}
}

Expand All @@ -448,10 +450,11 @@ pub fn to_snake_case(class_name: &str) -> String {
pub fn to_pascal_case(class_name: &str) -> String {
use heck::ToPascalCase;

// Special cases
#[allow(clippy::single_match)]
// Special cases: reuse snake_case impl to ensure at least consistency between those 2.
match class_name {
"JSONRPC" => return "JsonRpc".to_string(),
"JSONRPC" | "OpenXRAPIExtension" | "OpenXRIPBinding" => {
return to_snake_case(class_name).to_pascal_case()
}
_ => {}
}

Expand Down

0 comments on commit e8017d5

Please sign in to comment.