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

Replace scala native imports with explicit references #32

Closed
jonas opened this issue Jun 4, 2018 · 2 comments
Closed

Replace scala native imports with explicit references #32

jonas opened this issue Jun 4, 2018 · 2 comments
Labels
bindgen Binding generator bug Something isn't working
Milestone

Comments

@jonas
Copy link
Member

jonas commented Jun 4, 2018

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.

@jonas jonas added the bug Something isn't working label Jun 5, 2018
@kornilova203
Copy link
Member

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

@kornilova203
Copy link
Member

kornilova203 commented Jun 10, 2018

Seems like import scala.scalanative.native._ is never used
EDIT:
It is used for enums, for example: .toUInt

@jonas jonas added the bindgen Binding generator label Jun 25, 2018
@jonas jonas added this to the 0.1 milestone Jul 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bindgen Binding generator bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants