Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow accessing pointers to fields in struct aliases #268

Open
keynmol opened this issue Jan 23, 2024 · 0 comments
Open

Allow accessing pointers to fields in struct aliases #268

keynmol opened this issue Jan 23, 2024 · 0 comments

Comments

@keynmol
Copy link
Contributor

keynmol commented Jan 23, 2024

Consider:

  opaque type RenderTexture = CStruct3[CUnsignedInt, Texture, Texture]
  object RenderTexture:
    given _tag: Tag[RenderTexture] = Tag.materializeCStruct3Tag[CUnsignedInt, Texture, Texture]
    def apply()(using Zone): Ptr[RenderTexture] = scala.scalanative.unsafe.alloc[RenderTexture](1)
    def apply(id : CUnsignedInt, texture : Texture, depth : Texture)(using Zone): Ptr[RenderTexture] = 
      val ____ptr = apply()
      (!____ptr).id = id
      (!____ptr).texture = texture
      (!____ptr).depth = depth
      ____ptr
    extension (struct: RenderTexture)
      def id : CUnsignedInt = struct._1
      def id_=(value: CUnsignedInt): Unit = !struct.at1 = value
      def texture : Texture = struct._2
      def texture_=(value: Texture): Unit = !struct.at2 = value
      def depth : Texture = struct._3
      def depth_=(value: Texture): Unit = !struct.at3 = value

There is no safe way to get Ptr[Texture] from RenderTexture

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant