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