-
-
Notifications
You must be signed in to change notification settings - Fork 82
Closed
Labels
exp: intermediateAchievable by experienced contributors, or with some guidanceAchievable by experienced contributors, or with some guidancepri: intermediateAn issue resulting in non-critical functionality loss and no significant effect on usabilityAn issue resulting in non-critical functionality loss and no significant effect on usabilitytype: refactorRefactor existing codeRefactor existing code
Milestone
Description
Currently, StructInfo is appended to a TypeInfo struct - for types that are structs. We can obtain the StructInfo as follows:
/// Retrieves the type's struct information, if available.
pub fn as_struct(&self) -> Option<&StructInfo> {
if self.group.is_struct() {
let ptr = (self as *const TypeInfo).cast::<u8>();
let ptr = ptr.wrapping_add(mem::size_of::<TypeInfo>());
let offset = ptr.align_offset(mem::align_of::<StructInfo>());
let ptr = ptr.wrapping_add(offset);
Some(unsafe { &*ptr.cast::<StructInfo>() })
} else {
None
}
}As this is unsafe, we want to add proper ABI support for StructInfo inside the TypeInfo, by adding:
#[derive(AsValue)]
#[repr(u8)]
pub enum TypeInfoData {
Primitive,
Struct(StructInfo),
}to the TypeInfo:
#[derive(AsValue)]
pub struct TypeInfo {
...
pub data: TypeInfoData,
}Depends on #275
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
exp: intermediateAchievable by experienced contributors, or with some guidanceAchievable by experienced contributors, or with some guidancepri: intermediateAn issue resulting in non-critical functionality loss and no significant effect on usabilityAn issue resulting in non-critical functionality loss and no significant effect on usabilitytype: refactorRefactor existing codeRefactor existing code