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
Allow to use java.util.zip
in Windows
#2361
Allow to use java.util.zip
in Windows
#2361
Conversation
object zlibExt { | ||
import zlib._ | ||
|
||
sealed trait z_stream |
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.
The definition of z_stream
here having the same name as type z_stream[UINT, ULONG]
below is extremely confusing. It's basically impossible to tell which is which. Please use different names.
Furthermore, it seems that this z_stream
is only used as a phantom type in an intersection Ptr[Byte with z_stream]
. This is not guaranteed to keep working in Scala 3, since intersection types are commutative there. Do you really need a phantom type, here? If yes, use an uninstantiated abstract type member instead of a sealed trait
.
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.
The same issues exist with gz_header
.
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.
I've removed the sealed trait z_stream
the only reason for the usage of phantom was to increase type safety, however it's not really helping us with anything.
Now we define
type z_streamp = Ptr[z_stream[_, _]]
...
private[scalanative] type z_stream[UINT, ULONG] = CStruct14[...]
object z_stream {
def size: CSize = ???
}
Is such naming fine or should I rename generic z_stream[_,_]
to something else, eg. z_stream_impl[_,_]
By default zlib on Unix uses different primitive types for its internal structs leading to undefined behaviour at runtime.
This PR adds conditional resolution of expected struct layout. Additionally, implicit ops were added to zlib structs allowing for usage of accessor methods instead of field indexes.