Skip to content

Generate C wrappers for functions that pass structs by value #40

Open
@kornilova203

Description

@kornilova203

Scala code will not compile if there are structs that are passed by value.
Example:

struct MyStruct {
    int a;
};

struct OtherStruct {
    struct MyStruct s;
};

This Scala code will not compile:

@native.link("Lib")
@native.extern
object Lib {
  type struct_MyStruct = native.CStruct1[native.CInt]
  type struct_OtherStruct = native.CStruct1[struct_MyStruct]
}

import Lib._

object LibMembersHelpers {
  implicit class struct_OtherStruct_ops(val p: native.Ptr[struct_OtherStruct]) extends AnyVal {
    def s: struct_MyStruct = !p._1 // error
    def s_=(value: struct_MyStruct):Unit = !p._1 = value // error
  }
}

One possible solution - remove declarations that use structs by value.
Another - generate C code that converts struct to a pointer

Metadata

Metadata

Assignees

No one assigned

    Labels

    bindgenBinding generatorbugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions