diff --git a/duchess-reflect/src/codegen.rs b/duchess-reflect/src/codegen.rs index 41a7e82..72a5f70 100644 --- a/duchess-reflect/src/codegen.rs +++ b/duchess-reflect/src/codegen.rs @@ -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], @@ -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,)*], @@ -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], @@ -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], @@ -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 @@ -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], @@ -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 { diff --git a/duchess-reflect/src/signature.rs b/duchess-reflect/src/signature.rs index 4478f90..db571bf 100644 --- a/duchess-reflect/src/signature.rs +++ b/duchess-reflect/src/signature.rs @@ -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 { match &ty.to_non_repeating() { NonRepeatingType::Ref(_) => Ok(quote!( - duchess::plumbing::JvmRefOp + duchess::semver_unstable::JvmRefOp )), NonRepeatingType::Scalar(_) => Ok(quote!( - duchess::plumbing::JvmScalarOp + duchess::semver_unstable::JvmScalarOp )), } } @@ -223,13 +223,13 @@ impl Signature { /// prefer [`Self::java_ty_tt`][]. pub fn java_ty_rs(&mut self, ty: &Type) -> syn::Result { 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 { 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. @@ -272,7 +272,7 @@ impl Signature { pub fn class_ref_ty_rs(&mut self, ty: &ClassRef) -> syn::Result { 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 { diff --git a/macro-rules/src/java_types/argument_impl_trait.rs b/macro-rules/src/java_types/argument_impl_trait.rs index 3ffad48..b1de542 100644 --- a/macro-rules/src/java_types/argument_impl_trait.rs +++ b/macro-rules/src/java_types/argument_impl_trait.rs @@ -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)? }; } diff --git a/macro-rules/src/java_types/field_output_trait.rs b/macro-rules/src/java_types/field_output_trait.rs index 2a7f6b4..0b35cc1 100644 --- a/macro-rules/src/java_types/field_output_trait.rs +++ b/macro-rules/src/java_types/field_output_trait.rs @@ -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) > }; } diff --git a/macro-rules/src/java_types/output_trait.rs b/macro-rules/src/java_types/output_trait.rs index aafde3c..12150dc 100644 --- a/macro-rules/src/java_types/output_trait.rs +++ b/macro-rules/src/java_types/output_trait.rs @@ -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)? }; } diff --git a/macro-rules/src/java_types/output_type.rs b/macro-rules/src/java_types/output_type.rs index 542f613..6310e63 100644 --- a/macro-rules/src/java_types/output_type.rs +++ b/macro-rules/src/java_types/output_type.rs @@ -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> + Option> }; } diff --git a/macro-rules/src/java_types/rust_ty.rs b/macro-rules/src/java_types/rust_ty.rs index 143effc..e154d86 100644 --- a/macro-rules/src/java_types/rust_ty.rs +++ b/macro-rules/src/java_types/rust_ty.rs @@ -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 + java::Array }; ((generic $name:ident)) => { $name diff --git a/macro-rules/src/java_types/view_of_obj.rs b/macro-rules/src/java_types/view_of_obj.rs index 8705726..3003b6a 100644 --- a/macro-rules/src/java_types/view_of_obj.rs +++ b/macro-rules/src/java_types/view_of_obj.rs @@ -9,6 +9,6 @@ #[macro_export] macro_rules! view_of_obj { ($r:tt) => { - ::OfObj + ::OfObj }; } diff --git a/macro-rules/src/java_types/view_of_op.rs b/macro-rules/src/java_types/view_of_op.rs index 4a51114..c5b021a 100644 --- a/macro-rules/src/java_types/view_of_op.rs +++ b/macro-rules/src/java_types/view_of_op.rs @@ -9,6 +9,6 @@ #[macro_export] macro_rules! view_of_op { ($r:tt) => { - ::OfOp + ::OfOp }; } diff --git a/macro-rules/src/mro.rs b/macro-rules/src/mro.rs index 88e1466..72d2792 100644 --- a/macro-rules/src/mro.rs +++ b/macro-rules/src/mro.rs @@ -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. /// @@ -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,)*]), > }; } diff --git a/macro-rules/src/setup_class.rs b/macro-rules/src/setup_class.rs index 31aead5..334cab3 100644 --- a/macro-rules/src/setup_class.rs +++ b/macro-rules/src/setup_class.rs @@ -28,8 +28,8 @@ macro_rules! setup_class { #[allow(nonstandard_style)] const _: () = { use duchess::{java, Java, Jvm, Local, LocalResult}; - use duchess::plumbing::once_cell::sync::OnceCell; - use duchess::plumbing::mro; + use duchess::semver_unstable::once_cell::sync::OnceCell; + use duchess::semver_unstable::mro; // Implement the `JavaObject` trait for `$S`. // This impl is unsafe because we are asserting that @@ -46,7 +46,7 @@ macro_rules! setup_class { fn class<'jvm>(jvm: &mut Jvm<'jvm>) -> LocalResult<'jvm, Local<'jvm, java::lang::Class>> { static CLASS: OnceCell> = OnceCell::new(); let global = CLASS.get_or_try_init::<_, duchess::Error>>(|| { - let class = duchess::plumbing::find_class(jvm, $jni_class_name)?; + let class = duchess::semver_unstable::find_class(jvm, $jni_class_name)?; Ok(jvm.global(&class)) })?; Ok(jvm.local(global)) @@ -100,16 +100,16 @@ macro_rules! setup_class { where $($G: duchess::JavaObject,)* { - type Target = ::OfObj; + type Target = ::OfObj; fn deref(&self) -> &Self::Target { - duchess::plumbing::FromRef::from_ref(self) + duchess::semver_unstable::FromRef::from_ref(self) } } // Reflexive upcast impl - unsafe impl<$($G,)*> duchess::plumbing::Upcast<$S<$($G,)*>> for $S<$($G,)*> + unsafe impl<$($G,)*> duchess::semver_unstable::Upcast<$S<$($G,)*>> for $S<$($G,)*> where $($G: duchess::JavaObject,)* {} @@ -119,7 +119,7 @@ macro_rules! setup_class { // // [mro]: https://duchess-rs.github.io/duchess/methods.html - duchess::plumbing::setup_class! { + duchess::semver_unstable::setup_class! { @upcast_impls($S, [$($mro_ty,)*], [$($G,)*]) } @@ -152,11 +152,11 @@ macro_rules! setup_class { // // [mro]: https://duchess-rs.github.io/duchess/methods.html - duchess::plumbing::setup_class! { + duchess::semver_unstable::setup_class! { @op_obj_definitions($S, $op_name, [$($G,)*]) } - duchess::plumbing::setup_class! { + duchess::semver_unstable::setup_class! { @op_obj_definitions($S, $obj_name, [$($G,)*]) } @@ -165,8 +165,8 @@ macro_rules! setup_class { impl<$($G,)* J, N> $op_name<$($G,)* J, N> where $($G: duchess::JavaObject,)* - J: duchess::plumbing::JvmRefOp<$S<$($G,)*>>, - N: duchess::plumbing::FromRef, + J: duchess::semver_unstable::JvmRefOp<$S<$($G,)*>>, + N: duchess::semver_unstable::FromRef, { $($op_struct_methods)* } @@ -174,7 +174,7 @@ macro_rules! setup_class { impl<$($G,)* J, N> $obj_name<$($G,)* J, N> where $($G: duchess::JavaObject,)* - for<'jvm> &'jvm J: duchess::plumbing::JvmRefOp<$S<$($G,)*>>, + for<'jvm> &'jvm J: duchess::semver_unstable::JvmRefOp<$S<$($G,)*>>, { $($obj_struct_methods)* } @@ -191,7 +191,7 @@ macro_rules! setup_class { // // [mro]: https://duchess-rs.github.io/duchess/methods.html - impl<$($G,)*> duchess::plumbing::JavaView for $S<$($G,)*> + impl<$($G,)*> duchess::semver_unstable::JavaView for $S<$($G,)*> { type OfOp = $op_name< $($G,)* J, @@ -203,7 +203,7 @@ macro_rules! setup_class { N, > where - N: duchess::plumbing::FromRef; + N: duchess::semver_unstable::FromRef; type OfObj = $obj_name< $($G,)* J, @@ -215,7 +215,7 @@ macro_rules! setup_class { N, > where - N: duchess::plumbing::FromRef; + N: duchess::semver_unstable::FromRef; } }; }; @@ -223,15 +223,15 @@ macro_rules! setup_class { // Generate the struct definition and necessary impls for the op or obj struct. (@op_obj_definitions($S:ident, $opobj_name:ident, [$($G:ident,)*])) => { - duchess::plumbing::setup_class! { + duchess::semver_unstable::setup_class! { @op_obj_struct($S, $opobj_name, [$($G,)*]) } - duchess::plumbing::setup_class! { + duchess::semver_unstable::setup_class! { @op_obj_FromRef_impl($opobj_name, [$($G,)*]) } - duchess::plumbing::setup_class! { + duchess::semver_unstable::setup_class! { @op_obj_Deref_impl($opobj_name, [$($G,)*]) } }; @@ -259,12 +259,12 @@ macro_rules! setup_class { (@op_obj_Deref_impl($opobj_name:ident,[$($G:ident,)*])) => { impl<$($G,)* J, N> ::core::ops::Deref for $opobj_name<$($G,)* J, N> where - N: duchess::plumbing::FromRef, + N: duchess::semver_unstable::FromRef, { type Target = N; fn deref(&self) -> &N { - duchess::plumbing::FromRef::from_ref(&self.this) + duchess::semver_unstable::FromRef::from_ref(&self.this) } } }; @@ -275,7 +275,7 @@ macro_rules! setup_class { // on the op/obj struct definitions. (@op_obj_FromRef_impl($opobj_name:ident, [$($G:ident,)*])) => { - impl<$($G,)* J, N> duchess::plumbing::FromRef for $opobj_name<$($G,)* J, N> { + impl<$($G,)* J, N> duchess::semver_unstable::FromRef for $opobj_name<$($G,)* J, N> { fn from_ref(j: &J) -> &Self { // This is safe because of the `#[repr(transparent)]` // on the struct declaration. @@ -295,12 +295,12 @@ macro_rules! setup_class { (@upcast_impls($S:ident, [], [$($G:ident,)*])) => {}; (@upcast_impls($S:ident, [$mro_head_ty:ty, $($mro_tail_ty:ty,)*], [$($G:ident,)*])) => { - unsafe impl<$($G,)*> duchess::plumbing::Upcast<$mro_head_ty> for $S<$($G,)*> + unsafe impl<$($G,)*> duchess::semver_unstable::Upcast<$mro_head_ty> for $S<$($G,)*> where $($G: duchess::JavaObject,)* {} - duchess::plumbing::setup_class! { + duchess::semver_unstable::setup_class! { @upcast_impls($S, [$($mro_tail_ty,)*], [$($G,)*]) } }; diff --git a/macro-rules/src/setup_constructor.rs b/macro-rules/src/setup_constructor.rs index 20696be..a833ea7 100644 --- a/macro-rules/src/setup_constructor.rs +++ b/macro-rules/src/setup_constructor.rs @@ -10,7 +10,7 @@ macro_rules! setup_constructor { jni_descriptor: [$jni_descriptor:expr], ) => { pub fn new( - $($I : duchess::plumbing::argument_impl_trait!($I_ty),)* + $($I : duchess::semver_unstable::argument_impl_trait!($I_ty),)* ) -> impl duchess::prelude::JavaConstructor<$S<$($G,)*>> { struct Impl< $($G,)* @@ -44,10 +44,10 @@ macro_rules! setup_constructor { self, jvm: &mut duchess::Jvm<'jvm>, ) -> duchess::LocalResult<'jvm, Self::Output<'jvm>> { - use duchess::plumbing::once_cell::sync::OnceCell; + use duchess::semver_unstable::once_cell::sync::OnceCell; $( - duchess::plumbing::prepare_input!(let $I = (self.$I: $I_ty) in jvm); + duchess::semver_unstable::prepare_input!(let $I = (self.$I: $I_ty) in jvm); )* let class = <$S<$($G,)*> as duchess::JavaObject>::class(jvm)?; @@ -55,19 +55,19 @@ macro_rules! setup_constructor { // Cache the method id for the constructor -- note that we only have one cache // no matter how many generic monomorphizations there are. This makes sense // given Java's erased-based generics system. - static CONSTRUCTOR: OnceCell = OnceCell::new(); + static CONSTRUCTOR: OnceCell = OnceCell::new(); let constructor = CONSTRUCTOR.get_or_try_init(|| { - duchess::plumbing::find_constructor(jvm, &class, $jni_descriptor) + duchess::semver_unstable::find_constructor(jvm, &class, $jni_descriptor) })?; let env = jvm.env(); let obj: ::core::option::Option>> = unsafe { env.invoke(|env| env.NewObjectA, |env, f| f( env, - duchess::plumbing::JavaObjectExt::as_raw(&*class).as_ptr(), + duchess::semver_unstable::JavaObjectExt::as_raw(&*class).as_ptr(), constructor.as_ptr(), [ - $(duchess::plumbing::IntoJniValue::into_jni_value($I),)* + $(duchess::semver_unstable::IntoJniValue::into_jni_value($I),)* ].as_ptr(), )) }?; @@ -88,10 +88,10 @@ macro_rules! setup_constructor { $($G: duchess::JavaObject,)* $($I: $I_op,)* { - type Target = <$S<$($G,)*> as duchess::plumbing::JavaView>::OfOp; + type Target = <$S<$($G,)*> as duchess::semver_unstable::JavaView>::OfOp; fn deref(&self) -> &Self::Target { - >::from_ref(self) + >::from_ref(self) } } diff --git a/macro-rules/src/setup_inherent_object_method.rs b/macro-rules/src/setup_inherent_object_method.rs index 6587646..4865df0 100644 --- a/macro-rules/src/setup_inherent_object_method.rs +++ b/macro-rules/src/setup_inherent_object_method.rs @@ -20,8 +20,8 @@ macro_rules! setup_inherent_object_method { ) => { pub fn $M<$($MG,)*>( this: impl duchess::prelude::IntoJava<$S<$($G,)*>>, - $($I: duchess::plumbing::argument_impl_trait!($I_ty),)* - ) -> duchess::plumbing::output_trait!($O_ty) + $($I: duchess::semver_unstable::argument_impl_trait!($I_ty),)* + ) -> duchess::semver_unstable::output_trait!($O_ty) where $($SIG)* { @@ -39,7 +39,7 @@ macro_rules! setup_inherent_object_method { impl<$($G,)* $($MG,)* this, $($I,)*> ::core::clone::Clone for $M<$($G,)* $($MG,)* this, $($I,)*> where - this: duchess::plumbing::JvmRefOp<$S<$($G,)*>>, + this: duchess::semver_unstable::JvmRefOp<$S<$($G,)*>>, $($I: $I_op,)* $($G: duchess::JavaObject,)* $($SIG)* @@ -56,45 +56,45 @@ macro_rules! setup_inherent_object_method { impl<$($G,)* $($MG,)* this, $($I,)*> duchess::prelude::JvmOp for $M<$($G,)* $($MG,)* this, $($I,)*> where - this: duchess::plumbing::JvmRefOp<$S<$($G,)*>>, + this: duchess::semver_unstable::JvmRefOp<$S<$($G,)*>>, $($I: $I_op,)* $($G: duchess::JavaObject,)* $($SIG)* { - type Output<'jvm> = duchess::plumbing::output_type!('jvm, $O_ty); + type Output<'jvm> = duchess::semver_unstable::output_type!('jvm, $O_ty); fn do_jni<'jvm>( self, jvm: &mut duchess::Jvm<'jvm>, ) -> duchess::LocalResult<'jvm, Self::Output<'jvm>> { - use duchess::plumbing::once_cell::sync::OnceCell; + use duchess::semver_unstable::once_cell::sync::OnceCell; let this = self.this.into_as_jref(jvm)?; let this: &$S<$($G,)*> = duchess::prelude::AsJRef::as_jref(&this)?; - let this = duchess::plumbing::JavaObjectExt::as_raw(this); + let this = duchess::semver_unstable::JavaObjectExt::as_raw(this); $( - duchess::plumbing::prepare_input!(let $I = (self.$I: $I_ty) in jvm); + duchess::semver_unstable::prepare_input!(let $I = (self.$I: $I_ty) in jvm); )* // Cache the method id for this method -- note that we only have one cache // no matter how many generic monomorphizations there are. This makes sense // given Java's erased-based generics system. - static METHOD: OnceCell = OnceCell::new(); + static METHOD: OnceCell = OnceCell::new(); let method = METHOD.get_or_try_init(|| { let class = <$S<$($G,)*> as duchess::JavaObject>::class(jvm)?; - duchess::plumbing::find_method(jvm, &class, $jni_method, $jni_descriptor, false) + duchess::semver_unstable::find_method(jvm, &class, $jni_method, $jni_descriptor, false) })?; unsafe { jvm.env().invoke( - duchess::plumbing::jni_call_fn!($O_ty), + duchess::semver_unstable::jni_call_fn!($O_ty), |env, f| f( env, this.as_ptr(), method.as_ptr(), [ - $(duchess::plumbing::IntoJniValue::into_jni_value($I),)* + $(duchess::semver_unstable::IntoJniValue::into_jni_value($I),)* ].as_ptr(), ), ) @@ -102,7 +102,7 @@ macro_rules! setup_inherent_object_method { } } - duchess::plumbing::macro_if! { + duchess::semver_unstable::macro_if! { if is_ref_ty($O_ty) { impl<$($G,)* $($MG,)* this, $($I,)*> ::core::ops::Deref for $M<$($G,)* $($MG,)* this, $($I,)*> @@ -110,10 +110,10 @@ macro_rules! setup_inherent_object_method { $($G: duchess::JavaObject,)* $($SIG)* { - type Target = duchess::plumbing::view_of_op!($O_ty); + type Target = duchess::semver_unstable::view_of_op!($O_ty); fn deref(&self) -> &Self::Target { - >::from_ref(self) + >::from_ref(self) } } } diff --git a/macro-rules/src/setup_obj_method.rs b/macro-rules/src/setup_obj_method.rs index d959c85..d53e72d 100644 --- a/macro-rules/src/setup_obj_method.rs +++ b/macro-rules/src/setup_obj_method.rs @@ -12,8 +12,8 @@ macro_rules! setup_obj_method { ) => { pub fn $M<'a, $($MG,)*>( &'a self, - $($I: duchess::plumbing::argument_impl_trait!($I_ty + 'a),)* - ) -> duchess::plumbing::output_trait!($O_ty + 'a) + $($I: duchess::semver_unstable::argument_impl_trait!($I_ty + 'a),)* + ) -> duchess::semver_unstable::output_trait!($O_ty + 'a) where $($SIG)* { diff --git a/macro-rules/src/setup_op_method.rs b/macro-rules/src/setup_op_method.rs index 648bd17..7ed3b43 100644 --- a/macro-rules/src/setup_op_method.rs +++ b/macro-rules/src/setup_op_method.rs @@ -12,8 +12,8 @@ macro_rules! setup_op_method { ) => { pub fn $M<$($MG,)*>( &self, - $($I: duchess::plumbing::argument_impl_trait!($I_ty),)* - ) -> duchess::plumbing::output_trait!($O_ty) + $($I: duchess::semver_unstable::argument_impl_trait!($I_ty),)* + ) -> duchess::semver_unstable::output_trait!($O_ty) where $($SIG)* { diff --git a/macro-rules/src/setup_static_field_getter.rs b/macro-rules/src/setup_static_field_getter.rs index 86e359f..a5443be 100644 --- a/macro-rules/src/setup_static_field_getter.rs +++ b/macro-rules/src/setup_static_field_getter.rs @@ -9,7 +9,7 @@ macro_rules! setup_static_field_getter { jni_field: [$jni_field:expr], jni_descriptor: [$jni_descriptor:expr], ) => { - pub fn $F() -> duchess::plumbing::field_output_trait!($F_ty) + pub fn $F() -> duchess::semver_unstable::field_output_trait!($F_ty) where $($SIG)* { @@ -28,30 +28,30 @@ macro_rules! setup_static_field_getter { $($G: duchess::JavaObject,)* $($SIG)* { - type Output<'jvm> = duchess::plumbing::output_type!('jvm, $F_ty); + type Output<'jvm> = duchess::semver_unstable::output_type!('jvm, $F_ty); fn do_jni<'jvm>( self, jvm: &mut duchess::Jvm<'jvm>, ) -> duchess::LocalResult<'jvm, Self::Output<'jvm>> { - use duchess::plumbing::once_cell::sync::OnceCell; + use duchess::semver_unstable::once_cell::sync::OnceCell; // Cache the field id for this field -- note that we only have one cache // no matter how many generic monomorphizations there are. This makes sense // given Java's erased-based generics system. - static FIELD: OnceCell = OnceCell::new(); + static FIELD: OnceCell = OnceCell::new(); let field = FIELD.get_or_try_init(|| { let class = <$S<$($G,)*> as duchess::JavaObject>::class(jvm)?; - duchess::plumbing::find_field(jvm, &class, $jni_field, $jni_descriptor, true) + duchess::semver_unstable::find_field(jvm, &class, $jni_field, $jni_descriptor, true) })?; let class = <$S<$($G,)*> as duchess::JavaObject>::class(jvm)?; unsafe { jvm.env().invoke( - duchess::plumbing::jni_static_field_get_fn!($F_ty), + duchess::semver_unstable::jni_static_field_get_fn!($F_ty), |env, f| f( env, - duchess::plumbing::JavaObjectExt::as_raw(&*class).as_ptr(), + duchess::semver_unstable::JavaObjectExt::as_raw(&*class).as_ptr(), field.as_ptr(), ), ) diff --git a/macro-rules/src/setup_static_method.rs b/macro-rules/src/setup_static_method.rs index 19d3aaa..13d96a4 100644 --- a/macro-rules/src/setup_static_method.rs +++ b/macro-rules/src/setup_static_method.rs @@ -14,8 +14,8 @@ macro_rules! setup_static_method { jni_descriptor: [$jni_descriptor:expr], ) => { pub fn $M<$($MG,)*>( - $($I: duchess::plumbing::argument_impl_trait!($I_ty),)* - ) -> duchess::plumbing::output_trait!($O_ty) + $($I: duchess::semver_unstable::argument_impl_trait!($I_ty),)* + ) -> duchess::semver_unstable::output_trait!($O_ty) where $($SIG)* { @@ -51,37 +51,37 @@ macro_rules! setup_static_method { $($G: duchess::JavaObject,)* $($SIG)* { - type Output<'jvm> = duchess::plumbing::output_type!('jvm, $O_ty); + type Output<'jvm> = duchess::semver_unstable::output_type!('jvm, $O_ty); fn do_jni<'jvm>( self, jvm: &mut duchess::Jvm<'jvm>, ) -> duchess::LocalResult<'jvm, Self::Output<'jvm>> { - use duchess::plumbing::once_cell::sync::OnceCell; + use duchess::semver_unstable::once_cell::sync::OnceCell; $( - duchess::plumbing::prepare_input!(let $I = (self.$I: $I_ty) in jvm); + duchess::semver_unstable::prepare_input!(let $I = (self.$I: $I_ty) in jvm); )* // Cache the method id for this method -- note that we only have one cache // no matter how many generic monomorphizations there are. This makes sense // given Java's erased-based generics system. - static METHOD: OnceCell = OnceCell::new(); + static METHOD: OnceCell = OnceCell::new(); let method = METHOD.get_or_try_init(|| { let class = <$S<$($G,)*> as duchess::JavaObject>::class(jvm)?; - duchess::plumbing::find_method(jvm, &class, $jni_method, $jni_descriptor, true) + duchess::semver_unstable::find_method(jvm, &class, $jni_method, $jni_descriptor, true) })?; let class = <$S<$($G,)*> as duchess::JavaObject>::class(jvm)?; unsafe { jvm.env().invoke( - duchess::plumbing::jni_static_call_fn!($O_ty), + duchess::semver_unstable::jni_static_call_fn!($O_ty), |env, f| f( env, - duchess::plumbing::JavaObjectExt::as_raw(&*class).as_ptr(), + duchess::semver_unstable::JavaObjectExt::as_raw(&*class).as_ptr(), method.as_ptr(), [ - $(duchess::plumbing::IntoJniValue::into_jni_value($I),)* + $(duchess::semver_unstable::IntoJniValue::into_jni_value($I),)* ].as_ptr(), ), ) @@ -89,7 +89,7 @@ macro_rules! setup_static_method { } } - duchess::plumbing::macro_if! { + duchess::semver_unstable::macro_if! { if is_ref_ty($O_ty) { impl<$($G,)* $($MG,)* $($I,)*> ::core::ops::Deref for $M<$($G,)* $($MG,)* $($I,)*> @@ -97,10 +97,10 @@ macro_rules! setup_static_method { $($G: duchess::JavaObject,)* $($SIG)* { - type Target = duchess::plumbing::view_of_op!($O_ty); + type Target = duchess::semver_unstable::view_of_op!($O_ty); fn deref(&self) -> &Self::Target { - >::from_ref(self) + >::from_ref(self) } } } diff --git a/macro/src/derive.rs b/macro/src/derive.rs index 877d4f9..1a84965 100644 --- a/macro/src/derive.rs +++ b/macro/src/derive.rs @@ -215,7 +215,7 @@ impl Driver<'_> { } } - impl #impl_generics duchess::plumbing::ToJavaImpl<#root_class_name> for #self_ty #ty_generics #where_clause { + impl #impl_generics duchess::semver_unstable::ToJavaImpl<#root_class_name> for #self_ty #ty_generics #where_clause { fn to_java_impl<'jvm>(rust: &Self, jvm: &mut duchess::Jvm<'jvm>) -> duchess::LocalResult<'jvm, ::core::option::Option>> { Ok(Some(duchess::JvmOp::do_jni(rust, jvm)?)) } diff --git a/macro/src/java_function.rs b/macro/src/java_function.rs index 5a7e5ae..1bd40e6 100644 --- a/macro/src/java_function.rs +++ b/macro/src/java_function.rs @@ -117,10 +117,10 @@ pub fn java_function(selector: MethodSelector, input: syn::ItemFn) -> syn::Resul } } - impl duchess::plumbing::JavaFn for #input_fn_name { - fn java_fn() -> duchess::plumbing::JavaFunction { + impl duchess::semver_unstable::JavaFn for #input_fn_name { + fn java_fn() -> duchess::semver_unstable::JavaFunction { unsafe { - duchess::plumbing::JavaFunction::new( + duchess::semver_unstable::JavaFunction::new( #method_name_literal, #signature_literal, std::ptr::NonNull::new_unchecked(#java_fn_name as *mut ()), @@ -228,11 +228,11 @@ impl Driver<'_> { let env_arg = Argument { name: syn::Ident::new("jni_env", span), - ty: quote_spanned!(span => duchess::plumbing::EnvPtr<'_>), + ty: quote_spanned!(span => duchess::semver_unstable::EnvPtr<'_>), }; let this_ty = if self.method_info.flags.is_static { - quote_spanned!(span => duchess::plumbing::jni_sys::jclass) + quote_spanned!(span => duchess::semver_unstable::jni_sys::jclass) } else { let rust_this_ty = self.convert_ty(&self.class_info.this_ref().into())?; quote_spanned!(span => &#rust_this_ty) @@ -406,14 +406,14 @@ impl Driver<'_> { let output_rust_ty = ty.to_tokens(span); Ok(( output_rust_ty.clone(), - quote_spanned!(span => duchess::plumbing::native_function_returning_scalar::<#output_rust_ty, _>(#env_name, || #return_expr)), + quote_spanned!(span => duchess::semver_unstable::native_function_returning_scalar::<#output_rust_ty, _>(#env_name, || #return_expr)), )) } class_info::Type::Ref(_) | class_info::Type::Repeat(_) => { let output_java_ty = self.convert_ty(ty)?; Ok(( - quote_spanned!(span => duchess::plumbing::jni_sys::jobject), - quote_spanned!(span => duchess::plumbing::native_function_returning_object::<#output_java_ty, _>(#env_name, || #return_expr)), + quote_spanned!(span => duchess::semver_unstable::jni_sys::jobject), + quote_spanned!(span => duchess::semver_unstable::native_function_returning_object::<#output_java_ty, _>(#env_name, || #return_expr)), )) } }, diff --git a/src/array.rs b/src/array.rs index e4fd329..133ed33 100644 --- a/src/array.rs +++ b/src/array.rs @@ -4,7 +4,7 @@ use crate::{ cast::Upcast, java::{self, lang::Class}, jvm::JavaView, - plumbing::{FromRef, JavaObjectExt}, + semver_unstable::{FromRef, JavaObjectExt}, to_java::ToJavaImpl, AsJRef, Error, IntoRust, JDeref, JavaObject, JavaType, Jvm, JvmOp, Local, Nullable, ScalarMethod, TryJDeref, diff --git a/src/jvm.rs b/src/jvm.rs index 1f2f230..099c61d 100644 --- a/src/jvm.rs +++ b/src/jvm.rs @@ -5,8 +5,8 @@ use crate::{ java::lang::{Class, Throwable}, link::{IntoJavaFns, JavaFunction}, not_null::NotNull, - plumbing::{FromRef, ToJavaImpl, ToJavaScalar}, raw::{self, EnvPtr, JvmPtr, ObjectPtr}, + semver_unstable::{FromRef, ToJavaImpl, ToJavaScalar}, thread, try_catch::TryCatch, AsJRef, Error, IntoRust, Java, Local, Result, ToJava, TryJDeref, diff --git a/src/lib.rs b/src/lib.rs index 12ef383..0f17a27 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -53,7 +53,8 @@ pub mod prelude { /// Internal module containing non-semver protected /// names used by generated code. -pub mod plumbing { +#[doc(hidden)] +pub mod semver_unstable { pub use crate::cast::Upcast; pub use crate::find::{find_class, find_constructor, find_field, find_method}; pub use crate::from_ref::FromRef; diff --git a/src/raw.rs b/src/raw.rs index 7570b3d..6be938c 100644 --- a/src/raw.rs +++ b/src/raw.rs @@ -13,7 +13,7 @@ use std::{ use jni_sys::jvalue; -use crate::{jvm::JavaObjectExt, plumbing::ToJavaScalar, Error, JavaObject, Jvm, Local}; +use crate::{jvm::JavaObjectExt, semver_unstable::ToJavaScalar, Error, JavaObject, Jvm, Local}; // Set the JNI API version // JNI 1.8 is the default not in android diff --git a/src/ref_.rs b/src/ref_.rs index 4a693f9..4f8ad7c 100644 --- a/src/ref_.rs +++ b/src/ref_.rs @@ -2,7 +2,7 @@ use std::{marker::PhantomData, ops::Deref, ptr::NonNull}; use crate::jvm::JavaObjectExt; use crate::thread; -use crate::{cast::Upcast, plumbing::ObjectPtr, raw::EnvPtr, JavaObject}; +use crate::{cast::Upcast, raw::EnvPtr, semver_unstable::ObjectPtr, JavaObject}; /// An owned local reference to a non-null Java object of type `T`. The reference will be freed when /// dropped. Cannot be shared across threads or [`Jvm::with`] invocations.