Implement enum and conversion compatibility
This commit is contained in:
@@ -40,6 +40,8 @@ TARGETS = {
|
||||
NATIVE_TYPES = {
|
||||
"T:LibreMetaverse.Color4": "crate::color4::Color4",
|
||||
"T:LibreMetaverse.CRC32": "crate::crc32::CRC32",
|
||||
"T:LibreMetaverse.EnumInfoAttribute": "crate::enum_compat::EnumInfoAttribute",
|
||||
"T:LibreMetaverse.EnumInfoExtensions": "crate::enum_compat::EnumInfoExtensions",
|
||||
"T:LibreMetaverse.Matrix4": "crate::geometry::Matrix4",
|
||||
"T:LibreMetaverse.Quaternion": "crate::geometry::Quaternion",
|
||||
"T:LibreMetaverse.Ray": "crate::vectors::Ray",
|
||||
@@ -48,6 +50,7 @@ NATIVE_TYPES = {
|
||||
"T:LibreMetaverse.Vector3": "crate::vectors::Vector3",
|
||||
"T:LibreMetaverse.Vector3d": "crate::vectors::Vector3d",
|
||||
"T:LibreMetaverse.Vector4": "crate::vectors::Vector4",
|
||||
"T:LibreMetaverse.Utils": "crate::utils::Utils",
|
||||
}
|
||||
|
||||
NATIVE_MEMBER_BODIES = {
|
||||
@@ -453,6 +456,11 @@ def render_compile_fixture(
|
||||
row = member_rows[member["doc_id"]]
|
||||
method_names = generic_names(member)
|
||||
parameters = [*owner_names, *generic_declarations(member, mapper, owner_names)]
|
||||
if member["doc_id"] == "M:LibreMetaverse.Utils.EnumTryParse``1(System.String,``0@)":
|
||||
parameters = [
|
||||
*owner_names,
|
||||
"T: libremetaverse_types::EnumValueMetadata",
|
||||
]
|
||||
if trait:
|
||||
parameters.append(f"__Probe: {owner_type}")
|
||||
declaration = generic_suffix(parameters)
|
||||
@@ -838,7 +846,10 @@ def coverage_report(catalog: dict, coverage: dict[str, tuple[int, int, bool]]) -
|
||||
if complete and (types, members) != (got_types, got_members):
|
||||
raise ValueError(f"incomplete generated slice for {name}")
|
||||
native_type_ids = {
|
||||
item["doc_id"] for item in assembly["types"] if item["doc_id"] in NATIVE_TYPES
|
||||
item["doc_id"]
|
||||
for item in assembly["types"]
|
||||
if item["doc_id"] in NATIVE_TYPES
|
||||
or (name == "LibreMetaverse.Types" and item["kind"] == "enum")
|
||||
}
|
||||
native_member_ids = {
|
||||
member["doc_id"]
|
||||
|
||||
@@ -189,6 +189,30 @@ MEMBER_TYPE_OVERRIDES = {
|
||||
),
|
||||
}
|
||||
MEMBER_SIGNATURE_OVERRIDES = {
|
||||
"M:LibreMetaverse.Utils.DoubleToBytes(System.Double,System.Byte[],System.Int32)": (
|
||||
"pub fn double_to_bytes_with_double_bytes_int32(value: f64, dest: &mut [u8], pos: i32) -> Result<(), crate::Error>",
|
||||
"owned,mutable_borrow,owned",
|
||||
),
|
||||
"M:LibreMetaverse.Utils.EnumTryParse``1(System.String,``0@)": (
|
||||
"pub fn enum_try_parse<T: crate::EnumValueMetadata>(str_type: String, result: &mut Option<T>) -> Result<bool, crate::Error>",
|
||||
"owned,mutable_borrow",
|
||||
),
|
||||
"M:LibreMetaverse.Utils.FloatToBytes(System.Single,System.Byte[],System.Int32)": (
|
||||
"pub fn float_to_bytes_with_single_bytes_int32(value: f32, dest: &mut [u8], pos: i32) -> Result<(), crate::Error>",
|
||||
"owned,mutable_borrow,owned",
|
||||
),
|
||||
"M:LibreMetaverse.Utils.Int16ToBytes(System.Int16,System.Byte[],System.Int32)": (
|
||||
"pub fn int16_to_bytes_with_int16_bytes_int32(value: i16, dest: &mut [u8], pos: i32) -> Result<(), crate::Error>",
|
||||
"owned,mutable_borrow,owned",
|
||||
),
|
||||
"M:LibreMetaverse.Utils.Int64ToBytes(System.Int64,System.Byte[],System.Int32)": (
|
||||
"pub fn int64_to_bytes_with_int64_bytes_int32(value: i64, dest: &mut [u8], pos: i32) -> Result<(), crate::Error>",
|
||||
"owned,mutable_borrow,owned",
|
||||
),
|
||||
"M:LibreMetaverse.Utils.IntToBytes(System.Int32,System.Byte[],System.Int32)": (
|
||||
"pub fn int_to_bytes_with_int32_bytes_int32(value: i32, dest: &mut [u8], pos: i32) -> Result<(), crate::Error>",
|
||||
"owned,mutable_borrow,owned",
|
||||
),
|
||||
"M:LibreMetaverse.Utils.ReadSingleLittleEndian(System.Byte[],System.Int32)": (
|
||||
"pub fn read_single_little_endian(src: &[u8], pos: i32) -> Result<f32, crate::Error>",
|
||||
"shared_borrow,owned",
|
||||
@@ -205,6 +229,30 @@ MEMBER_SIGNATURE_OVERRIDES = {
|
||||
"pub fn write_double_little_endian(dest: &mut [u8], pos: i32, value: f64) -> Result<(), crate::Error>",
|
||||
"mutable_borrow,owned,owned",
|
||||
),
|
||||
"M:LibreMetaverse.Utils.UInt16ToBytes(System.UInt16,System.Byte[],System.Int32)": (
|
||||
"pub fn u_int16_to_bytes_with_u_int16_bytes_int32(value: u16, dest: &mut [u8], pos: i32) -> Result<(), crate::Error>",
|
||||
"owned,mutable_borrow,owned",
|
||||
),
|
||||
"M:LibreMetaverse.Utils.UInt16ToBytesBig(System.UInt16,System.Byte[],System.Int32)": (
|
||||
"pub fn u_int16_to_bytes_big(value: u16, dest: &mut [u8], pos: i32) -> Result<(), crate::Error>",
|
||||
"owned,mutable_borrow,owned",
|
||||
),
|
||||
"M:LibreMetaverse.Utils.UInt64ToBytes(System.UInt64,System.Byte[],System.Int32)": (
|
||||
"pub fn u_int64_to_bytes_with_u_int64_bytes_int32(value: u64, dest: &mut [u8], pos: i32) -> Result<(), crate::Error>",
|
||||
"owned,mutable_borrow,owned",
|
||||
),
|
||||
"M:LibreMetaverse.Utils.UInt64ToBytesBig(System.UInt64,System.Byte[],System.Int32)": (
|
||||
"pub fn u_int64_to_bytes_big_with_u_int64_bytes_int32(value: u64, dest: &mut [u8], pos: i32) -> Result<(), crate::Error>",
|
||||
"owned,mutable_borrow,owned",
|
||||
),
|
||||
"M:LibreMetaverse.Utils.UIntToBytes(System.UInt32,System.Byte[],System.Int32)": (
|
||||
"pub fn u_int_to_bytes_with_u_int32_bytes_int32(value: u32, dest: &mut [u8], pos: i32) -> Result<(), crate::Error>",
|
||||
"owned,mutable_borrow,owned",
|
||||
),
|
||||
"M:LibreMetaverse.Utils.UIntToBytesBig(System.UInt32,System.Byte[],System.Int32)": (
|
||||
"pub fn u_int_to_bytes_big(value: u32, dest: &mut [u8], pos: i32) -> Result<(), crate::Error>",
|
||||
"owned,mutable_borrow,owned",
|
||||
),
|
||||
"M:LibreMetaverse.UUID.ToBytes(System.Byte[],System.Int32)": (
|
||||
"pub fn to_bytes(&self, dest: &mut [u8], pos: i32) -> Result<(), crate::Error>",
|
||||
"shared_self,mutable_borrow,owned",
|
||||
|
||||
Reference in New Issue
Block a user