-
Notifications
You must be signed in to change notification settings - Fork 60
Move the non-IO parts of ceylon.io into a cross-platform module #449
Comments
How about |
Btw, there are plans to allow shared native declarations that aren't cross-platform (see ceylon/ceylon-spec#1459) , although personally I'd only use it if the amount of non-crossplatform code would be small in comparison to the rest. Otherwise splitting it off into a separate module might not be a bad idea. |
@tombentley yes @quintesse Good, I see that making I will wait a few more days for further comment, then start working on the PR if there are no objections. |
Started working on this here. Not quite ready for a PR yet, one of the tests fails on JavaScript, not sure why. |
This may be a bug in the
This doesn't look like something a ByteBuffer bug would case (and all its own tests pass). I see most of the Charset implementations do some bit manipulation. I know from Svalinn that this doesn't work reliably cross-backend, so that might be the source of the problem. |
Similar problem with
Expected is Python's encoding, generated with: ", ".join("#"+hex(x)[2:] for x in "z水𐀀𝄞".encode("utf-8")) The bit manipulations I see in both seem fairly safe; they don't appear to rely on a fixed |
Well it has to be a bit issue. You should be able to track it down using a small test (that one char that causes issues) and |
I added print statements into CharacterBuffer.get and on encode's codepoint value. They're different between JVM and JS, so it's different before it gets to the bit manipulation. Will look deeper at CharacterBuffer... Printing the String literal and printing CharacterBuffer.array after JVM:
JS:
If I swap out for (i->c in string.indexed) {
array.set(i, c);
} Then JS returns (the same as JVM):
With that change in place, all So, it looks like we've discovered a bug in whatever the native JS implementation is for |
Pull request filed (#457) with the workaround in place. |
The data representation (Buffers) and text/data conversion (Charsets, Base64) features of
ceylon.io
could be adapted without much effort (most of the work is adding a pure Ceylon ByteBuffer) to use on the JS backend.However, one of the limitations of the
native
annotation in a cross-platform module is that allshared
things must implement both backends. As the actual Input/Output parts (FileDescriptors, etc.) ofceylon.io
can't be made to work in browsers (though maybe they could work on node.js?), I propose splitting the module.The new cross-platform module might be called
ceylon.binary
(that being the common theme), but maybe there is a better name. I don't think many modifications would be required to the remainingceylon.io
code to allow it to import/useceylon.binary
. One thing I did spot was some things relying onunderlyingBuffer
instead ofimplementation
from theByteBuffer
interface, but that's a quick fix.I'm willing to work on this myself, if people agree it should be done.
The text was updated successfully, but these errors were encountered: