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

Version 3 #40

Closed
ghost opened this issue Mar 16, 2016 · 7 comments
Closed

Version 3 #40

ghost opened this issue Mar 16, 2016 · 7 comments

Comments

@ghost
Copy link

ghost commented Mar 16, 2016

Edit (20 October 2016): I'm working on a generator using clang. There will be a major restructure. The x11 crate will have function bindings moved into a separate crate called x11-static while x11 will only contain only types and constants (similar to the winapi crate). Both x11-static and x11-dl will depend on x11 for these items so there will no longer be duplicates. x11-generator will be a build dependency to generate the function bindings and will be available for custom bindings as well.

x11 and x11-generator will be built using x11-parser, which scans the C headers to generate bindings. The code generated by x11-parser will be commited to the repository, so the C headers won't have to be present when building the Rust bindings.

I am considering changing x11-dl to use lazy initialization. This will prevent the loader functions from failing if there are missing functions in order to avoid versioned structs. Instead, calling a missing function will cause a panic.

Note: Version 3 probably won't be stable until untagged unions are a stable feature in Rust.

@ghost ghost mentioned this issue Mar 16, 2016
@ghost
Copy link
Author

ghost commented Mar 16, 2016

@tomaka

@tomaka
Copy link

tomaka commented Mar 17, 2016

For plan A you should keep in mind that some systems don't have X11, so that should be detectable.

@ghost
Copy link
Author

ghost commented Mar 17, 2016

There would be functions to check the availability of libraries and functions, so you can avoid calling missing functions and causing a panic. Probably something like:

pub enum Lib {
    Xlib,
    Glx,
    ...
}

pub fn check_lib (lib: Lib) -> bool { ... }
pub fn check_fn (lib: Lib, fname: &str) -> bool { ... }
pub fn check_fns (lib: Lib, fnames: &[&str]) -> bool { ... }

One of the current problems is that Ubuntu LTS 14.04 has an older version of Xrandr which is missing 5 of the functions defined in x11::xrandr::Xrandr, so we added a separate struct (x11::xrandr::Xrandr_2_2_0) which omits these functions. Both plans described above will have better ways to avoid this problem.

@bennofs
Copy link
Contributor

bennofs commented Jul 13, 2016

I'm wondering if perhaps x11-dl could also be made just a feature of the main x11 crate? It mostly uses the same code anyway, and this way the code sharing could be better IMO. Of course this would be a breaking change, that's why I'm adding this comment to the version 3 thread.

@ghost
Copy link
Author

ghost commented Jul 19, 2016

My current plan is to define all types in x11 and pub use them into x11-dl when version 3.0 comes around. I think this may even be possible before 3.0 without breaking anything.

@eazar001
Copy link

eazar001 commented Aug 7, 2016

A suggestion for version 3:
Include some more bindings for xfixes extension if possible.

@ghost
Copy link
Author

ghost commented Aug 7, 2016

Like winapi-rs bindings are currently being added by hand, which is why things are missing. If xfixes bindings are needed, I'll see if I have some time to add them. Unfortunately, version 3 may have to wait for untagged unions, or else a version 4 would follow shortly after.

@ghost ghost closed this as completed Oct 28, 2017
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants