Skip to content

Commit

Permalink
rename s/plumbing/semver_unstable, hide in docs (#186)
Browse files Browse the repository at this point in the history
Co-authored-by: Niko Matsakis <[email protected]>
  • Loading branch information
nikomatsakis and Niko Matsakis authored Oct 1, 2024
1 parent 0a81378 commit 0b2975a
Show file tree
Hide file tree
Showing 24 changed files with 138 additions and 133 deletions.
58 changes: 31 additions & 27 deletions duchess-reflect/src/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ impl ClassInfo {
let mro_tys = self.mro(upcasts)?;

let output = quote! {
duchess::plumbing::setup_class! {
duchess::semver_unstable::setup_class! {
struct_name: [#struct_name],
java_class_generics: [#(#java_class_generics,)*],
jni_class_name: [#jni_class_name],
Expand Down Expand Up @@ -206,7 +206,7 @@ impl ClassInfo {
let descriptor = Literal::string(&constructor.descriptor(&self.generics_scope()));

Ok(quote! {
duchess::plumbing::setup_constructor! {
duchess::semver_unstable::setup_constructor! {
struct_name: [#struct_name],
java_class_generics: [#(#java_class_generics,)*],
input_names: [#(#input_names,)*],
Expand Down Expand Up @@ -247,7 +247,7 @@ impl ClassInfo {
// to account for captures.
let sig_where_clauses = &sig.where_clauses;

Ok(quote!(duchess::plumbing::setup_op_method! {
Ok(quote!(duchess::semver_unstable::setup_op_method! {
struct_name: [#struct_name],
java_class_generics: [#(#java_class_generics,)*],
rust_method_name: [#rust_method_name],
Expand Down Expand Up @@ -283,7 +283,7 @@ impl ClassInfo {
// to account for captures.
let sig_where_clauses = &sig.where_clauses;

Ok(quote!(duchess::plumbing::setup_obj_method! {
Ok(quote!(duchess::semver_unstable::setup_obj_method! {
struct_name: [#struct_name],
java_class_generics: [#(#java_class_generics,)*],
rust_method_name: [#rust_method_name],
Expand Down Expand Up @@ -322,19 +322,21 @@ impl ClassInfo {
// to account for captures.
let sig_where_clauses = &sig.where_clauses;

Ok(quote!(duchess::plumbing::setup_inherent_object_method! {
struct_name: [#struct_name],
java_class_generics: [#(#java_class_generics,)*],
rust_method_name: [#rust_method_name],
rust_method_generics: [#(#rust_method_generics,)*],
input_names: [#(#input_names,)*],
input_ty_tts: [#(#input_ty_tts,)*],
input_ty_ops: [#(#input_ty_ops,)*],
output_ty_tt: [#output_ty_tt],
sig_where_clauses: [#(#sig_where_clauses,)*],
jni_method: [#jni_method],
jni_descriptor: [#jni_descriptor],
}))
Ok(quote!(
duchess::semver_unstable::setup_inherent_object_method! {
struct_name: [#struct_name],
java_class_generics: [#(#java_class_generics,)*],
rust_method_name: [#rust_method_name],
rust_method_generics: [#(#rust_method_generics,)*],
input_names: [#(#input_names,)*],
input_ty_tts: [#(#input_ty_tts,)*],
input_ty_ops: [#(#input_ty_ops,)*],
output_ty_tt: [#output_ty_tt],
sig_where_clauses: [#(#sig_where_clauses,)*],
jni_method: [#jni_method],
jni_descriptor: [#jni_descriptor],
}
))
}

/// Generates a static method declaration that should be part of the inherent methods
Expand Down Expand Up @@ -368,7 +370,7 @@ impl ClassInfo {

let sig_where_clauses = &sig.where_clauses;

Ok(quote!(duchess::plumbing::setup_static_method! {
Ok(quote!(duchess::semver_unstable::setup_static_method! {
struct_name: [#struct_name],
java_class_generics: [#(#java_class_generics,)*],
rust_method_name: [#rust_method_name],
Expand Down Expand Up @@ -406,15 +408,17 @@ impl ClassInfo {

let sig_where_clauses = &sig.where_clauses;

Ok(quote!(duchess::plumbing::setup_static_field_getter! {
struct_name: [#struct_name],
java_class_generics: [#(#java_class_generics,)*],
rust_field_name: [#rust_field_name],
field_ty: [#field_ty],
sig_where_clauses: [#(#sig_where_clauses,)*],
jni_field: [#jni_field],
jni_descriptor: [#jni_descriptor],
}))
Ok(quote!(
duchess::semver_unstable::setup_static_field_getter! {
struct_name: [#struct_name],
java_class_generics: [#(#java_class_generics,)*],
rust_field_name: [#rust_field_name],
field_ty: [#field_ty],
sig_where_clauses: [#(#sig_where_clauses,)*],
jni_field: [#jni_field],
jni_descriptor: [#jni_descriptor],
}
))
}

fn struct_name(&self) -> Ident {
Expand Down
12 changes: 6 additions & 6 deletions duchess-reflect/src/signature.rs
Original file line number Diff line number Diff line change
Expand Up @@ -177,16 +177,16 @@ impl Signature {
/// Returns a path to a suitable JVM trait alias
/// (`duchess::JvmRefOp` or `duchess::JavaScalarOp`)
/// to the type. This really *ought* to be done in
/// macro-rules code (e.g., `$I: duchess::plumbing::jvm_op!($_ty)`)
/// macro-rules code (e.g., `$I: duchess::semver_unstable::jvm_op!($_ty)`)
/// but we can't easily do that because macro invocations
/// aren't allowed in that position.
pub fn jvm_op_trait(&mut self, ty: &Type, ty_tt: &TokenStream) -> syn::Result<TokenStream> {
match &ty.to_non_repeating() {
NonRepeatingType::Ref(_) => Ok(quote!(
duchess::plumbing::JvmRefOp<duchess::plumbing::rust_ty!(#ty_tt)>
duchess::semver_unstable::JvmRefOp<duchess::semver_unstable::rust_ty!(#ty_tt)>
)),
NonRepeatingType::Scalar(_) => Ok(quote!(
duchess::plumbing::JvmScalarOp<duchess::plumbing::rust_ty!(#ty_tt)>
duchess::semver_unstable::JvmScalarOp<duchess::semver_unstable::rust_ty!(#ty_tt)>
)),
}
}
Expand Down Expand Up @@ -223,13 +223,13 @@ impl Signature {
/// prefer [`Self::java_ty_tt`][].
pub fn java_ty_rs(&mut self, ty: &Type) -> syn::Result<TokenStream> {
let tt = self.java_ty_tt(ty)?;
Ok(quote!(duchess::plumbing::rust_ty!(#tt)))
Ok(quote!(duchess::semver_unstable::rust_ty!(#tt)))
}

/// Return tokens to create the Rust type for a RefType.
fn java_ref_ty_rs(&mut self, ty: &RefType) -> syn::Result<TokenStream> {
let tt = self.java_ref_ty_tt(ty)?;
Ok(quote!(duchess::plumbing::rust_ty!(#tt)))
Ok(quote!(duchess::semver_unstable::rust_ty!(#tt)))
}

/// Return the token-tree for a RefType.
Expand Down Expand Up @@ -272,7 +272,7 @@ impl Signature {

pub fn class_ref_ty_rs(&mut self, ty: &ClassRef) -> syn::Result<TokenStream> {
let tt = self.class_ref_ty_tt(ty)?;
Ok(quote!(duchess::plumbing::rust_ty!(#tt)))
Ok(quote!(duchess::semver_unstable::rust_ty!(#tt)))
}

fn class_ref_ty_tt(&mut self, ty: &ClassRef) -> syn::Result<TokenStream> {
Expand Down
4 changes: 2 additions & 2 deletions macro-rules/src/java_types/argument_impl_trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
#[macro_export]
macro_rules! argument_impl_trait {
($scalar:ident $(+ $lt:lifetime)?) => {
impl duchess::IntoScalar< duchess::plumbing::rust_ty!($scalar) > $(+ $lt)?
impl duchess::IntoScalar< duchess::semver_unstable::rust_ty!($scalar) > $(+ $lt)?
};

($r:tt $(+ $lt:lifetime)?) => {
impl duchess::IntoJava< duchess::plumbing::rust_ty!($r) > $(+ $lt)?
impl duchess::IntoJava< duchess::semver_unstable::rust_ty!($r) > $(+ $lt)?
};
}
4 changes: 2 additions & 2 deletions macro-rules/src/java_types/field_output_trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
#[macro_export]
macro_rules! field_output_trait {
($scalar:ident) => {
impl duchess::ScalarField< duchess::plumbing::rust_ty!($scalar) >
impl duchess::ScalarField< duchess::semver_unstable::rust_ty!($scalar) >
};

($r:tt) => {
impl duchess::JavaField< duchess::plumbing::rust_ty!($r) >
impl duchess::JavaField< duchess::semver_unstable::rust_ty!($r) >
};
}
4 changes: 2 additions & 2 deletions macro-rules/src/java_types/output_trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ macro_rules! output_trait {
};

($scalar:ident $(+ $lt:lifetime)?) => {
impl duchess::ScalarMethod< duchess::plumbing::rust_ty!($scalar) > $(+ $lt)?
impl duchess::ScalarMethod< duchess::semver_unstable::rust_ty!($scalar) > $(+ $lt)?
};

($r:tt $(+ $lt:lifetime)?) => {
impl duchess::JavaMethod< duchess::plumbing::rust_ty!($r) > $(+ $lt)?
impl duchess::JavaMethod< duchess::semver_unstable::rust_ty!($r) > $(+ $lt)?
};
}
4 changes: 2 additions & 2 deletions macro-rules/src/java_types/output_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ macro_rules! output_type {
};

($lt:lifetime, $scalar:ident) => {
duchess::plumbing::rust_ty!($scalar)
duchess::semver_unstable::rust_ty!($scalar)
};

($lt:lifetime, $r:tt) => {
Option<duchess::Local<$lt, duchess::plumbing::rust_ty!($r)>>
Option<duchess::Local<$lt, duchess::semver_unstable::rust_ty!($r)>>
};
}
4 changes: 2 additions & 2 deletions macro-rules/src/java_types/rust_ty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,10 @@ macro_rules! rust_ty {
$($path)*
};
((class[$($path:tt)*] $($args:tt)*)) => {
($($path)* < $(duchess::plumbing::rust_ty!($args),)* >)
($($path)* < $(duchess::semver_unstable::rust_ty!($args),)* >)
};
((array $elem:tt)) => {
java::Array<duchess::plumbing::rust_ty!($elem)>
java::Array<duchess::semver_unstable::rust_ty!($elem)>
};
((generic $name:ident)) => {
$name
Expand Down
2 changes: 1 addition & 1 deletion macro-rules/src/java_types/view_of_obj.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
#[macro_export]
macro_rules! view_of_obj {
($r:tt) => {
<duchess::plumbing::rust_ty!($r) as duchess::plumbing::JavaView>::OfObj<Self>
<duchess::semver_unstable::rust_ty!($r) as duchess::semver_unstable::JavaView>::OfObj<Self>
};
}
2 changes: 1 addition & 1 deletion macro-rules/src/java_types/view_of_op.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
#[macro_export]
macro_rules! view_of_op {
($r:tt) => {
<duchess::plumbing::rust_ty!($r) as duchess::plumbing::JavaView>::OfOp<Self>
<duchess::semver_unstable::rust_ty!($r) as duchess::semver_unstable::JavaView>::OfOp<Self>
};
}
6 changes: 3 additions & 3 deletions macro-rules/src/mro.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/// Generates a reference to the op or obj struct for a given type.
/// This type is named by using the associated types on the `duchess::plumbing::JavaView` trait.
/// This type is named by using the associated types on the `duchess::semver_unstable::JavaView` trait.
/// It expands to a recursive type that encodes the [method resolution order][mro] from the
/// original source type.
///
Expand All @@ -14,13 +14,13 @@ macro_rules! mro {
($J:ident,$assoc_name:ident,[$mro_ty_head:ty, $($mro_ty_tail:ty,)*]) => {
// The head type is the type we are viewing our original object as
// (some superclass/interface of the original type).
<$mro_ty_head as duchess::plumbing::JavaView>::$assoc_name<
<$mro_ty_head as duchess::semver_unstable::JavaView>::$assoc_name<
// J here represents the type we are coming *from*
$J,

// N here represents the next type in the MRO sequence,
// which is generated recursively
duchess::plumbing::mro!($J, $assoc_name, [$($mro_ty_tail,)*]),
duchess::semver_unstable::mro!($J, $assoc_name, [$($mro_ty_tail,)*]),
>
};
}
Loading

0 comments on commit 0b2975a

Please sign in to comment.