scala-native-bindgen icon indicating copy to clipboard operation
scala-native-bindgen copied to clipboard

Consider shortening the output

Open ekrich opened this issue 7 years ago • 6 comments

Currently in hand generated code there are tricks to make the code shorter and cleaner such as use of imports. A good example is the following: https://github.com/scala-native/scala-native/blob/master/nativelib/src/main/scala/scala/scalanative/posix/dirent.scala

The keys points are the imports that eliminate the native. and Nat. prefixes. Also, in hand generated code the struct is just named dirent.

ekrich avatar Jul 02 '18 22:07 ekrich

Related with https://github.com/kornilova-l/scala-native-bindgen/issues/32

The generated code is longer and more explicit by design to avoid having to keep track of whether declarations in the generated code shadows a declaration being imported.

jonas avatar Jul 03 '18 05:07 jonas

It seems that you have already covered this issue. I hoped the native.XXX could be shortened to XXX. Also, there is an issue in Scala Native related. https://github.com/scala-native/scala-native/issues/1197

ekrich avatar Jul 03 '18 14:07 ekrich

I think that it is a good idea. Shorter code may be a default option since names in native and Nat are not common in C, but there also might be an option to generate code with all prefixes. It will just take some time to make sure that bindgen always generates valid code.

kornilova203 avatar Jul 03 '18 14:07 kornilova203

Okay, let's keep it open, but I think we should give it pretty low priority for now since there are a lot of more important things to address.

jonas avatar Jul 03 '18 23:07 jonas

I found another thing that might help. When functions are generated they are given parameter names as anonymous0, anonymous1, ... anonymousn. This could probably be p0, p1, ... pn for params.

ekrich avatar Aug 07 '18 23:08 ekrich

I agree, I also do not like anonymous...

kornilova203 avatar Aug 08 '18 04:08 kornilova203