Git Product home page Git Product logo

Comments (6)

 avatar commented on August 29, 2024

@robertknight

from x11-rs.

robertknight avatar robertknight commented on August 29, 2024

So to recap:

  • One module per shared library, with corresponding functions => x11::{xlib,xi,xfixes,xinerama}...
  • Constants and types in modules based on the header files they come from. Perhaps x11types::xlib::{...} . Or perhaps there should just be one module with all the relevant structs/constants, since the structs already have prefixes that namespace them - eg. 'x11types::{XIDeviceInfo, Success, Display ...}'
  • One crate for statically linked X11, one for dynamically linked and one for constants/types shared between the two?

from x11-rs.

 avatar commented on August 29, 2024

I guess the structure would depend on whether the bindings are generated at compile time or ahead of time. But glob re-exports into the root module would make the layout less important. If things are generated at compile time, I wouldn't see any benefit to splitting them up by header or library.

My first thought was to have types, constants and static functions all in the x11 module and dylib functions in the x11-dl module. But if libraries are feature gated in x11-dl to vastly improve compile time, then it may be worth it to merge them all into the same crate. This would require a macro similar to x11_link for each individual library, which isn't such a bad thing.

from x11-rs.

robertknight avatar robertknight commented on August 29, 2024

For generating constant definitions, someone else had a much better idea - generate C++ code which leverages the compiler's type inference to determine the type of macros: http://vojtech.kral.hk/en/rust-importing-c-constants-proof-of-concept/

from x11-rs.

 avatar commented on August 29, 2024

One of the problems I was thinking of when generating bindings from the C headers is determining the types of the thousands of macros. I've been thinking recently that they can all be c_int unless they have an L suffix, in which case they can be c_long. It may be a little less ergonomic in many cases where the constant is meant for a type other than int, but it still seems like a cleaner solution than writing constants by hand like we have been doing.

from x11-rs.

 avatar commented on August 29, 2024

Closing in favor of #40.

from x11-rs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.