2
0

euclid.rs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. struct UnknownUnit;
  2. struct LayoutUnit;
  3. #[repr(C)]
  4. struct TypedLength<T, Unit>(T, PhantomData<Unit>);
  5. #[repr(C)]
  6. struct TypedSideOffsets2D<T, U> {
  7. top: T,
  8. right: T,
  9. bottom: T,
  10. left: T,
  11. _phantom: PhantomData<U>,
  12. }
  13. #[repr(C)]
  14. struct TypedSize2D<T, U> {
  15. width: T,
  16. height: T,
  17. _phantom: PhantomData<U>,
  18. }
  19. #[repr(C)]
  20. struct TypedPoint2D<T, U> {
  21. x: T,
  22. y: T,
  23. _phantom: PhantomData<U>,
  24. }
  25. #[repr(C)]
  26. struct TypedRect<T, U> {
  27. origin: TypedPoint2D<T, U>,
  28. size: TypedSize2D<T, U>,
  29. _phantom: PhantomData<U>,
  30. }
  31. #[repr(C)]
  32. struct TypedTransform2D<T, Src, Dst> {
  33. m11: T, m12: T,
  34. m21: T, m22: T,
  35. m31: T, m32: T,
  36. _phantom: PhantomData<U>,
  37. }
  38. type Length<T> = TypedLength<T, UnknownUnit>;
  39. type SideOffsets2D<T> = TypedSideOffsets2D<T, UnknownUnit>;
  40. type Size2D<T> = TypedSize2D<T, UnknownUnit>;
  41. type Point2D<T> = TypedPoint2D<T, UnknownUnit>;
  42. type Rect<T> = TypedRect<T, UnknownUnit>;
  43. type LayoutLength = TypedLength<f32, LayoutUnit>;
  44. type LayoutSideOffsets2D = TypedSideOffsets2D<f32, LayoutUnit>;
  45. type LayoutSize2D = TypedSize2D<f32, LayoutUnit>;
  46. type LayoutPoint2D = TypedPoint2D<f32, LayoutUnit>;
  47. type LayoutRect = TypedRect<f32, LayoutUnit>;
  48. #[no_mangle]
  49. pub extern "C" fn root(
  50. length_a: TypedLength<f32, UnknownUnit>,
  51. length_b: TypedLength<f32, LayoutUnit>,
  52. length_c: Length<f32>,
  53. length_d: LayoutLength,
  54. side_offsets_a: TypedSideOffsets2D<f32, UnknownUnit>,
  55. side_offsets_b: TypedSideOffsets2D<f32, LayoutUnit>,
  56. side_offsets_c: SideOffsets2D<f32>,
  57. side_offsets_d: LayoutSideOffsets2D,
  58. size_a: TypedSize2D<f32, UnknownUnit>,
  59. size_b: TypedSize2D<f32, LayoutUnit>,
  60. size_c: Size2D<f32>,
  61. size_d: LayoutSize2D,
  62. point_a: TypedPoint2D<f32, UnknownUnit>,
  63. point_b: TypedPoint2D<f32, LayoutUnit>,
  64. point_c: Point2D<f32>,
  65. point_d: LayoutPoint2D,
  66. rect_a: TypedRect<f32, UnknownUnit>,
  67. rect_b: TypedRect<f32, LayoutUnit>,
  68. rect_c: Rect<f32>,
  69. rect_d: LayoutRect,
  70. transform_a: TypedTransform2D<f32, UnknownUnit, LayoutUnit>,
  71. transform_b: TypedTransform2D<f32, LayoutUnit, UnknownUnit>
  72. ) { }