From 7f18ebd29bf523b512c314f769dfe7a49e908712 Mon Sep 17 00:00:00 2001 From: makai410 Date: Wed, 18 Sep 2024 10:56:13 +0000 Subject: [PATCH] Update --- gen/src/write.rs | 30 +++++++++++++++--------------- macro/src/expand.rs | 6 +++--- syntax/instantiate.rs | 12 ++++++------ 3 files changed, 24 insertions(+), 24 deletions(-) diff --git a/gen/src/write.rs b/gen/src/write.rs index 2110b2dcc..23e038781 100644 --- a/gen/src/write.rs +++ b/gen/src/write.rs @@ -3,7 +3,7 @@ use crate::gen::nested::NamespaceEntries; use crate::gen::out::OutFile; use crate::gen::{builtin, include, Opt}; use crate::syntax::atom::Atom::{self, *}; -use crate::syntax::instantiate::{CxxVectorPayloadImplKey, ImplKey, NamedImplKey, PtrConstness}; +use crate::syntax::instantiate::{CxxVectorPayloadImplKey, ImplKey, NamedImplKey, PtrMutability}; use crate::syntax::map::UnorderedMap as Map; use crate::syntax::set::UnorderedSet; use crate::syntax::symbol::{self, Symbol}; @@ -1352,7 +1352,7 @@ fn write_space_after_type(out: &mut OutFile, ty: &Type) { enum UniquePtr<'a> { Ident(&'a Ident), CxxVector(&'a Ident), - CxxVectorPtr(&'a Ident, PtrConstness), + CxxVectorPtr(PtrMutability, &'a Ident), } trait ToTypename { @@ -1372,10 +1372,10 @@ impl<'a> ToTypename for UniquePtr<'a> { UniquePtr::CxxVector(element) => { format!("::std::vector<{}>", element.to_typename(types)) } - UniquePtr::CxxVectorPtr(element, constness) => { - let const_prefix = match constness { - PtrConstness::Const => "const ", - PtrConstness::Mut => "", + UniquePtr::CxxVectorPtr(mutability, element) => { + let const_prefix = match mutability { + PtrMutability::Const => "const ", + PtrMutability::Mut => "", }; format!( "::std::vector<{}{}*>", @@ -1404,10 +1404,10 @@ impl<'a> ToMangled for UniquePtr<'a> { UniquePtr::CxxVector(element) => { symbol::join(&[&"std", &"vector", &element.to_mangled(types)]) } - UniquePtr::CxxVectorPtr(element, constness) => { - let prefix = match constness { - PtrConstness::Const => "ptrc", - PtrConstness::Mut => "ptrm", + UniquePtr::CxxVectorPtr(mutability, element) => { + let prefix = match mutability { + PtrMutability::Const => "ptrc", + PtrMutability::Mut => "ptrm", }; symbol::join(&[&"std", &"vector", &prefix, &element.to_mangled(types)]) } @@ -1917,12 +1917,12 @@ fn write_weak_ptr(out: &mut OutFile, key: NamedImplKey) { fn write_cxx_vector(out: &mut OutFile, payload: CxxVectorPayloadImplKey) { let (key, ptr_prefix, unique_ptr_payload) = match payload { CxxVectorPayloadImplKey::Named(id) => (id, "", UniquePtr::CxxVector(id.rust)), - CxxVectorPayloadImplKey::Ptr(id, constness) => { - let prefix = match constness { - PtrConstness::Const => "ptrc$", - PtrConstness::Mut => "ptrm$", + CxxVectorPayloadImplKey::Ptr(id, mutability) => { + let prefix = match mutability { + PtrMutability::Const => "ptrc$", + PtrMutability::Mut => "ptrm$", }; - (id, prefix, UniquePtr::CxxVectorPtr(id.rust, constness)) + (id, prefix, UniquePtr::CxxVectorPtr(mutability, id.rust)) } }; let element = key.rust; diff --git a/macro/src/expand.rs b/macro/src/expand.rs index 39171ae57..e050c5e1d 100644 --- a/macro/src/expand.rs +++ b/macro/src/expand.rs @@ -2,7 +2,7 @@ use crate::syntax::atom::Atom::*; use crate::syntax::attrs::{self, OtherAttrs}; use crate::syntax::cfg::CfgExpr; use crate::syntax::file::Module; -use crate::syntax::instantiate::{CxxVectorPayloadImplKey, ImplKey, NamedImplKey, PtrConstness}; +use crate::syntax::instantiate::{CxxVectorPayloadImplKey, ImplKey, NamedImplKey, PtrMutability}; use crate::syntax::qualified::QualifiedName; use crate::syntax::report::Errors; use crate::syntax::symbol::Symbol; @@ -1676,8 +1676,8 @@ fn expand_cxx_vector( ) -> TokenStream { let (ptr_prefix, key, ty_prefix) = match payload { CxxVectorPayloadImplKey::Named(id) => ("", id, quote! {}), - CxxVectorPayloadImplKey::Ptr(id, PtrConstness::Const) => ("ptrc$", id, quote! { *const }), - CxxVectorPayloadImplKey::Ptr(id, PtrConstness::Mut) => ("ptrm$", id, quote! { *mut }), + CxxVectorPayloadImplKey::Ptr(id, PtrMutability::Const) => ("ptrc$", id, quote! { *const }), + CxxVectorPayloadImplKey::Ptr(id, PtrMutability::Mut) => ("ptrm$", id, quote! { *mut }), }; let elem = key.rust; diff --git a/syntax/instantiate.rs b/syntax/instantiate.rs index a41a39a14..2d2333e48 100644 --- a/syntax/instantiate.rs +++ b/syntax/instantiate.rs @@ -14,7 +14,7 @@ pub(crate) enum ImplKey<'a> { } #[derive(Copy, Clone, PartialEq, Eq, Hash)] -pub enum PtrConstness { +pub enum PtrMutability { Const, Mut, } @@ -22,7 +22,7 @@ pub enum PtrConstness { #[derive(Copy, Clone, PartialEq, Eq, Hash)] pub(crate) enum CxxVectorPayloadImplKey<'a> { Named(NamedImplKey<'a>), - Ptr(NamedImplKey<'a>, PtrConstness), + Ptr(NamedImplKey<'a>, PtrMutability), } #[derive(Copy, Clone)] @@ -68,14 +68,14 @@ impl Type { } if let Type::Ptr(ptr) = &ty.inner { if let Type::Ident(ident) = &ptr.inner { - let constness = if ptr.constness.is_some() { - PtrConstness::Const + let mutability = if ptr.constness.is_some() { + PtrMutability::Const } else { - PtrConstness::Mut + PtrMutability::Mut }; return Some(ImplKey::CxxVector(CxxVectorPayloadImplKey::Ptr( NamedImplKey::new(ty, ident), - constness, + mutability, ))); } }