use crate::{
objects::JObject,
sys::{jobject, jobjectArray},
};
use super::AsJArrayRaw;
#[repr(transparent)]
#[derive(Debug)]
pub struct JObjectArray<'local>(JObject<'local>);
impl<'local> AsRef<JObjectArray<'local>> for JObjectArray<'local> {
fn as_ref(&self) -> &JObjectArray<'local> {
self
}
}
impl<'local> AsRef<JObject<'local>> for JObjectArray<'local> {
fn as_ref(&self) -> &JObject<'local> {
self
}
}
impl<'local> ::std::ops::Deref for JObjectArray<'local> {
type Target = JObject<'local>;
fn deref(&self) -> &Self::Target {
&self.0
}
}
impl<'local> From<JObjectArray<'local>> for JObject<'local> {
fn from(other: JObjectArray) -> JObject {
other.0
}
}
impl<'local> From<JObject<'local>> for JObjectArray<'local> {
fn from(other: JObject) -> Self {
unsafe { Self::from_raw(other.into_raw()) }
}
}
impl<'local, 'obj_ref> From<&'obj_ref JObject<'local>> for &'obj_ref JObjectArray<'local> {
fn from(other: &'obj_ref JObject<'local>) -> Self {
unsafe { &*(other as *const JObject<'local> as *const JObjectArray<'local>) }
}
}
impl<'local> std::default::Default for JObjectArray<'local> {
fn default() -> Self {
Self(JObject::null())
}
}
unsafe impl<'local> AsJArrayRaw<'local> for JObjectArray<'local> {}
impl<'local> JObjectArray<'local> {
pub unsafe fn from_raw(raw: jobjectArray) -> Self {
Self(JObject::from_raw(raw as jobject))
}
pub fn into_raw(self) -> jobjectArray {
self.0.into_raw() as jobjectArray
}
}