Replace scala native imports with explicit references
jonas opened this issue · comments
Right now the generated code has these three imports:
import scala.scalanative._
import scala.scalanative.native._
import scala.scalanative.native.Nat._
This may lead to issues if a binding uses the name native
or one of the natural number symbols like _1
. In order to avoid such conflicts we need to be more explicit in the generated code, like prefixing everything with scalanative.native.CInt
.
Alternatively we need to document limitations of what names are not allowed.
We can use native.Nat._1
instead of _1
👍
I do not want to add scalanative
prefix everywhere because it will make a file less readable.
Lets try to list all the cases that we need to avoid and see whether we can solve them without using scalanative
prefix:
- lib object cannot be named
native
.
Here we can use annotation@name("native")
and rename the object. - functions cannot be named
native
.
Again we can use the annotation
Anything else? Type named native
seems to work fine.
Also I found one problem related to naming
If a struct field has name _1
.._22
then there will be helper method with similar name, but the helper method will be shadowed by the method from Ptr.scala
which is confusing.
It seems to be really special case and I am not sure that it is worth spending time
Seems like import scala.scalanative.native._
is never used
EDIT:
It is used for enums, for example: .toUInt