sdk-builder: canonicalize and ident-ize package name
- fix `,` not being an illegal char in idents
This commit is contained in:
parent
8c47749c98
commit
c34886f954
|
@ -143,7 +143,7 @@ pub mod rust {
|
||||||
|
|
||||||
use anyhow::Context;
|
use anyhow::Context;
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use proc_macro2::TokenStream;
|
use proc_macro2::{Ident, TokenStream};
|
||||||
use quote::{format_ident, quote};
|
use quote::{format_ident, quote};
|
||||||
use unreal_sdk::sdk::repr::{
|
use unreal_sdk::sdk::repr::{
|
||||||
Class, ClassField, ClassMethod, Enum, ObjectRef, PrimitiveType, ProcessedPackage, Sdk,
|
Class, ClassField, ClassMethod, Enum, ObjectRef, PrimitiveType, ProcessedPackage, Sdk,
|
||||||
|
@ -175,9 +175,9 @@ pub mod rust {
|
||||||
"i64", "i128", "usize", "isize",
|
"i64", "i128", "usize", "isize",
|
||||||
];
|
];
|
||||||
|
|
||||||
const CHARS: [char; 19] = [
|
const CHARS: [char; 20] = [
|
||||||
' ', '?', '+', '-', ':', '/', '^', '(', ')', '[', ']', '<', '>', '&', '.', '#', '\'', '"',
|
' ', '?', '+', '-', ':', '/', '^', '(', ')', '[', ']', '<', '>', '&', '.', '#', '\'', '"',
|
||||||
'%',
|
'%', ',',
|
||||||
];
|
];
|
||||||
|
|
||||||
pub struct Builder {
|
pub struct Builder {
|
||||||
|
@ -257,7 +257,7 @@ pub mod rust {
|
||||||
.packages
|
.packages
|
||||||
.values()
|
.values()
|
||||||
.map(|pkg| {
|
.map(|pkg| {
|
||||||
let name = pkg.name.clone();
|
let name = canonicalize_name(&pkg.name).to_string();
|
||||||
let tokens = self.generate_package(pkg, args.feature_gate)?;
|
let tokens = self.generate_package(pkg, args.feature_gate)?;
|
||||||
|
|
||||||
anyhow::Ok((name, tokens))
|
anyhow::Ok((name, tokens))
|
||||||
|
@ -280,6 +280,7 @@ pub mod rust {
|
||||||
let mut mod_rs = TokenStream::new();
|
let mut mod_rs = TokenStream::new();
|
||||||
|
|
||||||
for (name, tokens) in packages {
|
for (name, tokens) in packages {
|
||||||
|
let name = format_ident!("{name}");
|
||||||
if args.single_file {
|
if args.single_file {
|
||||||
mod_rs.extend(quote! {
|
mod_rs.extend(quote! {
|
||||||
pub mod #name {
|
pub mod #name {
|
||||||
|
|
Loading…
Reference in a new issue