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
Fix #1796: Nativelib toCString() & fromCString() now return nulls. #1945
Fix #1796: Nativelib toCString() & fromCString() now return nulls. #1945
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR. There are several asInstanceOf
s that are not necessary, I believe.
nativelib/src/main/scala/scala/scalanative/unsafe/package.scala
Outdated
Show resolved
Hide resolved
nativelib/src/main/scala/scala/scalanative/unsafe/package.scala
Outdated
Show resolved
Hide resolved
unit-tests/src/test/scala/scala/scalanative/unsafe/CStringSuite.scala
Outdated
Show resolved
Hide resolved
unit-tests/src/test/scala/scala/scalanative/unsafe/CStringSuite.scala
Outdated
Show resolved
Hide resolved
@david-bouyssie, @jokade Does this PR provide what you were describing & needing to ease your work? |
``` In the sweat of thy face shalt thou eat bread, till thou return unto the ground; for out of it wast thou taken: for null thou art, and unto null shalt thou return." ``` [^1] * This PR was motivated by Issue scala-native#1796. There is extensive discussion of design alternatives in that Issue. This PR implements the final decision; toCString() & fromCString are to return null when given a null. * Two test cases for exercising null handling were added to were added to CStringSuite.scala. To isolate the changes of this PR, I left CStringSuite.scala as the old-style Scala Native test Suite it was before I touched it this time. If/when the core changes of this PR are found acceptable, I can sweep through and convert that file to JUnit, under the guidance of: You touch it, you own it. Documentation: * The standard changelog entry is requested. * I added a one sentence paragraph to `docs/user/interop.rst` to make the newly defined behavior accessible to users of Scala Native. `interop.rst` had a number (7 or 8) warnings before I touched it. I left it with the same warnings. That is, I did not introduce any warning, but, to keep this PR reviewable on-sight, I did not fix any. I think I have a PR in the queue which fixes some of those warnings and others; yielding, at that time, a clean build. Testing: Safety - + Built and tested ("test-all") in debug mode using sbt 1.3.13 on X86_64 only . All tests pass. Efficacy - + The two newly cases in CStringSuite.scala to exercise the changes of this both passed. Documentation - + I did a successful manual html build of the `doc` directory. [^1]: Modified from [original](https://www.phrases.org.uk/meanings/ashes-to-ashes.html) Travis CI restarts: 1) All but one runs completed green. The one which failed did so with a Coursier fetch error, apparently unrelated to this PR. Restarting.
957151c
to
1a11b7a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM now.
370c749
to
bb7e5fa
Compare
Travis CI restart #2. Failed Travis job (scalafmt, but not in scalafmt) unrelated to the PR, just after "store build cache". Travis CI restart scala-native#3. Two failed jobs unrelated to this PR. One was a failed CLA check. Second was a failed Coursier fetch.
bb7e5fa
to
6a8b3b7
Compare
* PR scala-native#1945 added two cases to unsafe.CStringSuite.scala. To aid review of scala-native#1945, I did not convert CStringSuite from the classical Scala Native test format to JUnit. Rather, I left an IOU in the commit message for scala-native#1945. This PR pays off that IOU. * There should be no functional changes. A trial testOnly of CSuiteTest.scala reveals no changes beyond changed test names and JUnit style output. * It looks as though the CStringSuite tests had been written at different times, with slightly different assert styles. I am supposing that the later authors did not want to alter existing, working tests, again to minimize and isolate changes. I changed some of the asserts to use a consistent "expected, result" format. This is the convention documented by JUnit and some/most of the existing tests. Future readers will expect that a JUnit test follow the JUnit convention. Documentation: * As a number of tests are changing to JUnit the Release Notes will need a blanket statement saying "Many tests changed to JUnit.". This test would be covered by that statement. Testing: Safety - + Built and tested ("test-all") in debug mode using sbt 1.3.13 on X86_64 only . All tests pass. Efficacy - + JUnit style output is evident upon execution.
* PR scala-native#1945 added two cases to unsafe.CStringSuite.scala. To aid review of scala-native#1945, I did not convert CStringSuite from the classical Scala Native test format to JUnit. Rather, I left an IOU in the commit message for scala-native#1945. This PR pays off that IOU. * There should be no functional changes. A trial testOnly of CSuiteTest.scala reveals no changes beyond changed test names and JUnit style output. * It looks as though the CStringSuite tests had been written at different times, with slightly different assert styles. I am supposing that the later authors did not want to alter existing, working tests, again to minimize and isolate changes. I changed some of the asserts to use a consistent "expected, result" format. This is the convention documented by JUnit and some/most of the existing tests. Future readers will expect that a JUnit test follow the JUnit convention. Documentation: * As a number of tests are changing to JUnit the Release Notes will need a blanket statement saying "Many tests changed to JUnit.". This test would be covered by that statement. Testing: Safety - + Built and tested ("test-all") in debug mode using sbt 1.3.13 on X86_64 only . All tests pass. Efficacy - + JUnit style output is evident upon execution. Travis CI restarts: 1) Failures unrelated the changes of this PR: One CLA failure, two Coursier. Looks like Travis's network is having a bad hair day. All the other cases are successful/green.
…now return nulls. (scala-native#1945)" This reverts commit 978eb96.
…now return nulls. (scala-native#1945)" This reverts commit 978eb96.
This PR was motivated by Issue fromCString(null) returns java.lang.RuntimeException not NullPointerException #1796. There is extensive discussion
of design alternatives in that Issue. This PR implements the
final decision; toCString() & fromCString are to
return null when given a null.
Two test cases for exercising null handling were added to
were added to CStringSuite.scala.
To isolate the changes of this PR, I left CStringSuite.scala
as the old-style Scala Native test Suite it was before I touched
it this time. If/when the core changes of this PR are found
acceptable, I can sweep through and convert that file to JUnit,
under the guidance of: You touch it, you own it.
Documentation:
The standard changelog entry is requested.
I added a one sentence paragraph to
docs/user/interop.rst
to make the newly defined behavior accessible to users of Scala Native.
interop.rst
had a number (7 or 8) warnings before I touched it.I left it with the same warnings. That is, I did not introduce
any warning, but, to keep this PR reviewable on-sight, I did
not fix any. I think I have a PR in the queue which fixes some
of those warnings and others; yielding, at that time, a clean build.
Testing:
Safety -
X86_64 only . All tests pass.
Efficacy -
of this both passed.
Documentation -
doc
directory.[1]: Adapted from original