implemented traits for all v2 types
This commit is contained in:
parent
03c1c61d42
commit
e68aa9ec55
|
@ -79,6 +79,27 @@ macro_rules! define_utypes {
|
|||
impl const traits::UObjectTrait for $ty {}
|
||||
)+
|
||||
};
|
||||
|
||||
($($ty:ident where $($trt:ty),+ => $name:literal),+) => {
|
||||
$(
|
||||
#[repr(transparent)]
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub struct $ty(NonNull<UnsafeCell<()>>);
|
||||
|
||||
impl $ty {
|
||||
pub const fn static_class_name() -> &'static str {
|
||||
concat!("Class CoreUObject.", $name)
|
||||
}
|
||||
}
|
||||
|
||||
impl_asuobject!($ty);
|
||||
|
||||
impl const traits::UObjectTrait for $ty {}
|
||||
$(
|
||||
impl const $trt for $ty {}
|
||||
)+
|
||||
)+
|
||||
};
|
||||
}
|
||||
|
||||
macro_rules! impl_const_trait_for {
|
||||
|
@ -116,56 +137,47 @@ macro_rules! impl_asuobject {
|
|||
}
|
||||
|
||||
define_utypes!(
|
||||
UObject => "Object",
|
||||
UField => "Field",
|
||||
UEnum => "Enum",
|
||||
UStruct => "Struct",
|
||||
UScriptStruct => "ScriptStruct",
|
||||
UClass => "Class",
|
||||
UProperty => "Property",
|
||||
UFunction => "Function",
|
||||
UNumericProperty => "NumericProperty",
|
||||
UByteProperty => "ByteProperty",
|
||||
UUInt16Property => "UInt16Property",
|
||||
UUInt32Property => "UInt32Property",
|
||||
UUInt64Property => "UInt64Property",
|
||||
UInt8Property => "Int8Property",
|
||||
UInt16Property => "Int16Property",
|
||||
UIntProperty => "IntProperty", // i32
|
||||
UInt64Property => "Int64Property",
|
||||
UFloatProperty => "FloatProperty",
|
||||
UDoubleProperty => "DoubleProperty",
|
||||
UBoolProperty => "BoolProperty",
|
||||
UObjectPropertyBase => "ObjectPropertyBase",
|
||||
UObjectProperty => "ObjectProperty",
|
||||
UClassProperty => "ClassProperty",
|
||||
UInterfaceProperty => "InterfaceProperty",
|
||||
UWeakObjectProperty => "WeakObjectProperty",
|
||||
ULazyObjectProperty => "LazyObjectProperty",
|
||||
UAssetObjectProperty => "AssetObjectProperty",
|
||||
UAssetClassProperty => "AssetClassProperty",
|
||||
USoftObjectProperty => "SoftObjectProperty",
|
||||
UNameProperty => "NameProperty",
|
||||
UStructProperty => "StructProperty",
|
||||
UStrProperty => "StrProperty",
|
||||
UTextProperty => "TextProperty",
|
||||
UArrayProperty => "ArrayProperty",
|
||||
UMapProperty => "MapProperty",
|
||||
UDelegateProperty => "DelegateProperty",
|
||||
UMulticastDelegateProperty => "MulticastDelegateProperty",
|
||||
UEnumProperty => "EnumProperty"
|
||||
UObject => "Object"
|
||||
);
|
||||
define_utypes!(
|
||||
UField where UFieldTrait => "Field",
|
||||
UEnum where UFieldTrait, UEnumTrait => "Enum",
|
||||
UStruct where UFieldTrait, UStructTrait => "Struct",
|
||||
UScriptStruct where UFieldTrait, UStructTrait, UScriptStructTrait => "ScriptStruct",
|
||||
UClass where UFieldTrait, UStructTrait, UClassTrait => "Class",
|
||||
UProperty where UFieldTrait, UStructTrait, UPropertyTrait => "Property",
|
||||
UFunction where UFieldTrait, UStructTrait, UFunctionTrait => "Function",
|
||||
UNumericProperty where UFieldTrait, UStructTrait, UPropertyTrait, UNumericPropertyTrait => "NumericProperty",
|
||||
UByteProperty where UFieldTrait, UStructTrait, UPropertyTrait,UNumericPropertyTrait, UBytePropertyTrait => "ByteProperty",
|
||||
UUInt16Property where UFieldTrait, UStructTrait, UPropertyTrait,UNumericPropertyTrait, UUInt16PropertyTrait => "UInt16Property",
|
||||
UUInt32Property where UFieldTrait, UStructTrait, UPropertyTrait,UNumericPropertyTrait, UUInt32PropertyTrait => "UInt32Property",
|
||||
UUInt64Property where UFieldTrait, UStructTrait, UPropertyTrait,UNumericPropertyTrait, UUInt64PropertyTrait => "UInt64Property",
|
||||
UInt8Property where UFieldTrait, UStructTrait, UPropertyTrait,UNumericPropertyTrait, UInt8PropertyTrait => "Int8Property",
|
||||
UInt16Property where UFieldTrait, UStructTrait, UPropertyTrait,UNumericPropertyTrait, UInt16PropertyTrait => "Int16Property",
|
||||
UIntProperty where UFieldTrait, UStructTrait, UPropertyTrait,UNumericPropertyTrait, UIntPropertyTrait => "IntProperty", // i32
|
||||
UInt64Property where UFieldTrait, UStructTrait, UPropertyTrait,UNumericPropertyTrait, UInt64PropertyTrait => "Int64Property",
|
||||
UFloatProperty where UFieldTrait, UStructTrait, UPropertyTrait,UNumericPropertyTrait, UFloatPropertyTrait => "FloatProperty",
|
||||
UDoubleProperty where UFieldTrait, UStructTrait, UPropertyTrait,UNumericPropertyTrait, UDoublePropertyTrait => "DoubleProperty",
|
||||
UBoolProperty where UFieldTrait, UStructTrait, UPropertyTrait,UBoolPropertyTrait => "BoolProperty",
|
||||
UObjectPropertyBase where UFieldTrait, UStructTrait, UPropertyTrait,UObjectPropertyBaseTrait => "ObjectPropertyBase",
|
||||
UObjectProperty where UFieldTrait, UStructTrait, UPropertyTrait, UObjectPropertyBaseTrait,UObjectPropertyTrait => "ObjectProperty",
|
||||
UClassProperty where UFieldTrait, UStructTrait, UPropertyTrait, UObjectPropertyBaseTrait, UObjectPropertyTrait,UClassPropertyTrait => "ClassProperty",
|
||||
UInterfaceProperty where UFieldTrait, UStructTrait, UPropertyTrait,UInterfacePropertyTrait => "InterfaceProperty",
|
||||
UWeakObjectProperty where UFieldTrait, UStructTrait, UPropertyTrait,UObjectPropertyBaseTrait, UObjectPropertyTrait,UWeakObjectPropertyTrait => "WeakObjectProperty",
|
||||
ULazyObjectProperty where UFieldTrait, UStructTrait, UPropertyTrait,UObjectPropertyBaseTrait, UObjectPropertyTrait,ULazyObjectPropertyTrait => "LazyObjectProperty",
|
||||
UAssetObjectProperty where UFieldTrait, UStructTrait, UPropertyTrait,UObjectPropertyBaseTrait, UObjectPropertyTrait,UAssetObjectPropertyTrait => "AssetObjectProperty",
|
||||
UAssetClassProperty where UFieldTrait, UStructTrait, UPropertyTrait,UObjectPropertyBaseTrait, UObjectPropertyTrait, UAssetObjectPropertyTrait,UAssetClassPropertyTrait => "AssetClassProperty",
|
||||
USoftObjectProperty where UFieldTrait, UStructTrait, UPropertyTrait,USoftObjectPropertyTrait => "SoftObjectProperty",
|
||||
UNameProperty where UFieldTrait, UStructTrait, UPropertyTrait,UNamePropertyTrait => "NameProperty",
|
||||
UStructProperty where UFieldTrait, UStructTrait, UPropertyTrait,UStructPropertyTrait => "StructProperty",
|
||||
UStrProperty where UFieldTrait, UStructTrait, UPropertyTrait,UStrPropertyTrait => "StrProperty",
|
||||
UTextProperty where UFieldTrait, UStructTrait, UPropertyTrait,UTextPropertyTrait => "TextProperty",
|
||||
UArrayProperty where UFieldTrait, UStructTrait, UPropertyTrait,UArrayPropertyTrait => "ArrayProperty",
|
||||
UMapProperty where UFieldTrait, UStructTrait, UPropertyTrait,UMapPropertyTrait => "MapProperty",
|
||||
UDelegateProperty where UFieldTrait, UStructTrait, UPropertyTrait,UDelegatePropertyTrait => "DelegateProperty",
|
||||
UMulticastDelegateProperty where UFieldTrait, UStructTrait, UPropertyTrait,UMulticastDelegatePropertyTrait => "MulticastDelegateProperty",
|
||||
UEnumProperty where UFieldTrait, UStructTrait, UPropertyTrait,UEnumPropertyTrait => "EnumProperty"
|
||||
);
|
||||
// impl_const_trait_for!(
|
||||
// traits::UFieldTrait: UField,
|
||||
// UEnum,
|
||||
// UStruct,
|
||||
// UClass,
|
||||
// UProperty
|
||||
// );
|
||||
|
||||
// impl_const_trait_for!(traits::UStructTrait: UStruct, UClass);
|
||||
// impl_const_trait_for!(traits::UEnumTrait: UEnum);
|
||||
// impl_const_trait_for!(traits::UPropertyTrait: UProperty);
|
||||
|
||||
impl UObject {
|
||||
#![allow(dead_code)]
|
||||
|
@ -197,6 +209,7 @@ impl UEnum {
|
|||
}
|
||||
}
|
||||
|
||||
use traits::*;
|
||||
mod traits {
|
||||
use std::ptr::NonNull;
|
||||
|
||||
|
@ -251,10 +264,8 @@ mod traits {
|
|||
}
|
||||
}
|
||||
|
||||
impl<T> const UFieldTrait for T where T: ~const UEnumTrait {}
|
||||
|
||||
#[const_trait]
|
||||
pub trait UStructTrait: ~const UFieldTrait {
|
||||
pub trait UStructTrait: ~const AsUObject {
|
||||
fn super_field(&self) -> &Option<super::UStruct> {
|
||||
unsafe { &*self.as_uobject().raw_ptr().offset(48).cast() }
|
||||
}
|
||||
|
@ -270,13 +281,13 @@ mod traits {
|
|||
}
|
||||
|
||||
#[const_trait]
|
||||
pub trait UScriptStructTrait: ~const UStructTrait {}
|
||||
pub trait UScriptStructTrait: ~const AsUObject {}
|
||||
|
||||
#[const_trait]
|
||||
pub trait UClassTrait: ~const UStructTrait {}
|
||||
pub trait UClassTrait: ~const AsUObject {}
|
||||
|
||||
#[const_trait]
|
||||
pub trait UFunctionTrait: ~const UStructTrait {
|
||||
pub trait UFunctionTrait: ~const AsUObject {
|
||||
fn function_flags(&self) -> &u32 {
|
||||
unsafe { &*self.as_uobject().raw_ptr().offset(144).cast() }
|
||||
}
|
||||
|
@ -307,7 +318,7 @@ mod traits {
|
|||
}
|
||||
|
||||
#[const_trait]
|
||||
pub trait UPropertyTrait: ~const UFieldTrait {
|
||||
pub trait UPropertyTrait: ~const AsUObject {
|
||||
fn array_dim(&self) -> &i32 {
|
||||
unsafe { &*self.as_uobject().raw_ptr().offset(48).cast() }
|
||||
}
|
||||
|
@ -341,14 +352,53 @@ mod traits {
|
|||
}
|
||||
|
||||
#[const_trait]
|
||||
pub trait UBytePropertyTrait: ~const UPropertyTrait {
|
||||
pub trait UNamePropertyTrait: ~const AsUObject {}
|
||||
|
||||
#[const_trait]
|
||||
pub trait UStrPropertyTrait: ~const AsUObject {}
|
||||
|
||||
#[const_trait]
|
||||
pub trait UTextPropertyTrait: ~const AsUObject {}
|
||||
|
||||
#[const_trait]
|
||||
pub trait UNumericPropertyTrait: ~const AsUObject {}
|
||||
|
||||
#[const_trait]
|
||||
pub trait UUInt16PropertyTrait: ~const AsUObject {}
|
||||
|
||||
#[const_trait]
|
||||
pub trait UUInt32PropertyTrait: ~const AsUObject {}
|
||||
|
||||
#[const_trait]
|
||||
pub trait UUInt64PropertyTrait: ~const AsUObject {}
|
||||
|
||||
#[const_trait]
|
||||
pub trait UInt16PropertyTrait: ~const AsUObject {}
|
||||
|
||||
#[const_trait]
|
||||
pub trait UInt8PropertyTrait: ~const AsUObject {}
|
||||
|
||||
#[const_trait]
|
||||
pub trait UInt64PropertyTrait: ~const AsUObject {}
|
||||
|
||||
#[const_trait]
|
||||
pub trait UIntPropertyTrait: ~const AsUObject {}
|
||||
|
||||
#[const_trait]
|
||||
pub trait UFloatPropertyTrait: ~const AsUObject {}
|
||||
|
||||
#[const_trait]
|
||||
pub trait UDoublePropertyTrait: ~const AsUObject {}
|
||||
|
||||
#[const_trait]
|
||||
pub trait UBytePropertyTrait: ~const AsUObject {
|
||||
fn uenum(&self) -> &Option<super::UEnum> {
|
||||
unsafe { &*self.as_uobject().raw_ptr().offset(112).cast() }
|
||||
}
|
||||
}
|
||||
|
||||
#[const_trait]
|
||||
pub trait UBoolPropertyTrait: ~const UPropertyTrait {
|
||||
pub trait UBoolPropertyTrait: ~const AsUObject {
|
||||
fn field_size(&self) -> &u8 {
|
||||
unsafe { &*self.as_uobject().raw_ptr().offset(112).cast() }
|
||||
}
|
||||
|
@ -364,35 +414,50 @@ mod traits {
|
|||
}
|
||||
|
||||
#[const_trait]
|
||||
pub trait UObjectPropertyBaseTrait: ~const UPropertyTrait {
|
||||
pub trait UObjectPropertyBaseTrait: ~const AsUObject {
|
||||
fn property_class(&self) -> &Option<super::UClass> {
|
||||
unsafe { &*self.as_uobject().raw_ptr().offset(112).cast() }
|
||||
}
|
||||
}
|
||||
|
||||
#[const_trait]
|
||||
pub trait UInterfacePropertyTrait: ~const UPropertyTrait {
|
||||
pub trait UObjectPropertyTrait: ~const AsUObject {}
|
||||
|
||||
#[const_trait]
|
||||
pub trait UWeakObjectPropertyTrait: ~const AsUObject {}
|
||||
|
||||
#[const_trait]
|
||||
pub trait ULazyObjectPropertyTrait: ~const AsUObject {}
|
||||
|
||||
#[const_trait]
|
||||
pub trait UAssetObjectPropertyTrait: ~const AsUObject {}
|
||||
|
||||
#[const_trait]
|
||||
pub trait USoftObjectPropertyTrait: ~const AsUObject {}
|
||||
|
||||
#[const_trait]
|
||||
pub trait UInterfacePropertyTrait: ~const AsUObject {
|
||||
fn interface_class(&self) -> &Option<super::UClass> {
|
||||
unsafe { &*self.as_uobject().raw_ptr().offset(112).cast() }
|
||||
}
|
||||
}
|
||||
|
||||
#[const_trait]
|
||||
pub trait UStructPropertyTrait: ~const UPropertyTrait {
|
||||
pub trait UStructPropertyTrait: ~const AsUObject {
|
||||
fn ustruct(&self) -> &Option<super::UStruct> {
|
||||
unsafe { &*self.as_uobject().raw_ptr().offset(112).cast() }
|
||||
}
|
||||
}
|
||||
|
||||
#[const_trait]
|
||||
pub trait UArrayPropertyTrait: ~const UPropertyTrait {
|
||||
pub trait UArrayPropertyTrait: ~const AsUObject {
|
||||
fn inner(&self) -> &Option<super::UClass> {
|
||||
unsafe { &*self.as_uobject().raw_ptr().offset(112).cast() }
|
||||
}
|
||||
}
|
||||
|
||||
#[const_trait]
|
||||
pub trait UMapPropertyTrait: ~const UPropertyTrait {
|
||||
pub trait UMapPropertyTrait: ~const AsUObject {
|
||||
fn key_prop(&self) -> &Option<super::UProperty> {
|
||||
unsafe { &*self.as_uobject().raw_ptr().offset(112).cast() }
|
||||
}
|
||||
|
@ -402,28 +467,35 @@ mod traits {
|
|||
}
|
||||
|
||||
#[const_trait]
|
||||
pub trait UClassPropertyTrait: ~const UObjectPropertyBaseTrait {
|
||||
pub trait UClassPropertyTrait: ~const AsUObject {
|
||||
fn meta_class(&self) -> &Option<super::UClass> {
|
||||
unsafe { &*self.as_uobject().raw_ptr().offset(120).cast() }
|
||||
}
|
||||
}
|
||||
|
||||
#[const_trait]
|
||||
pub trait UAssetClassPropertyTrait: ~const UObjectPropertyBaseTrait {
|
||||
pub trait UAssetClassPropertyTrait: ~const AsUObject {
|
||||
fn meta_class(&self) -> &Option<super::UClass> {
|
||||
unsafe { &*self.as_uobject().raw_ptr().offset(120).cast() }
|
||||
}
|
||||
}
|
||||
|
||||
#[const_trait]
|
||||
pub trait UDelegatePropertyTrait: ~const UPropertyTrait {
|
||||
pub trait UDelegatePropertyTrait: ~const AsUObject {
|
||||
fn signature_function(&self) -> &Option<super::UFunction> {
|
||||
unsafe { &*self.as_uobject().raw_ptr().offset(112).cast() }
|
||||
}
|
||||
}
|
||||
|
||||
#[const_trait]
|
||||
pub trait UEnumPropertyTrait: ~const UPropertyTrait {
|
||||
pub trait UMulticastDelegatePropertyTrait: ~const AsUObject {
|
||||
fn signature_function(&self) -> &Option<super::UFunction> {
|
||||
unsafe { &*self.as_uobject().raw_ptr().offset(112).cast() }
|
||||
}
|
||||
}
|
||||
|
||||
#[const_trait]
|
||||
pub trait UEnumPropertyTrait: ~const AsUObject {
|
||||
fn underlying_type(&self) -> &Option<super::UProperty> {
|
||||
unsafe { &*self.as_uobject().raw_ptr().offset(112).cast() }
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue