scala-native / scala-native-bindgen

Scala Native Binding Generator

Home Page:https://scala-native.github.io/scala-native-bindgen/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Incorrect translation of fixed size array to CArray

david-bouyssie opened this issue · comments

For this given struct (see https://github.com/libexpat/libexpat/blob/master/expat/lib/expat.h#L507):

typedef struct {
  int map[256];
  void *data;
  int(XMLCALL *convert)(void *data, const char *s);
  void(XMLCALL *release)(void *data);
} XML_Encoding;

The produced definition is:

type struct_XML_Encoding = CStruct4[CArray[CInt, Nat.Digit[Nat._2, Nat.Digit[Nat._5, Nat._6]]], Ptr[Byte], CFunctionPtr2[Ptr[Byte], CString, CInt], CFunctionPtr1[Ptr[Byte], Unit]]

There are two minor problems here:

  • Nat.Digit is missing a number suffix
  • CFunctionPtrX should be CFuncPtrX

However the major problem is Nat.Digit[Nat._2, Nat.Digit[Nat._5, Nat._6]] which should simplified I guess toNat.Digit3[Nat._2, Nat._5, Nat._6]

@david-bouyssie This has changed from 0.3.9 to 0.4.0 as you know. This has been changed in the following PR. #195

I still haven't worked through all the issues. I have been running the following to test:

sbt:scala-native-bindgen> verify

Ok, sorry I should have checked that before.
I thought it was a distinct issue.
Glad you already fixed that one.

It is not fixed yet so I would leave this open.