Giter Site home page Giter Site logo

Comments (1)

rhx avatar rhx commented on August 19, 2024

Yes, it would be nice to integrate the post-processing steps directly into gir2swift. From my experience, there a number of different reasons for why post-processing is needed. They all vary a bit in terms of what is required. Some examples I can think of:

  1. inadequate code generation in gir2swift. These often fix syntax errors or insert keywords/attributes that Swift requires (such as @escaping, adding/removing override, etc.).
  • ideally these should be fixed by making gir2swift smarter, so they are not needed anymore
  • however, this can be a lot of work for only a few edge cases
  1. errors in the relevant .gir files.
  • these are often version specific (so should be tagable)
  • ideally, they should be upstreamed to ensure they eventually get fixed (so would be nice to tag them with an upstream PR number)
  1. errors in the relevant header files.
  • sometimes what is defined varies between different platforms or versions
  • examples include #define that is visible to Swift in some cases and invisible in other cases
  1. syntactic sugar
  • there are cases where gir2swift generates correct code, but small changes can make the generated code more Swift-friendly

So what's a good way forward? Maybe initially, it would be good if the existing functionality was integrated directly into gir2swift. Probably the sed scripts are low-hanging fruit as a first step, as they provide simple search and replace based on regular expressions. Rather than a generic gir2swift-manifest.jsonfile, I would suggest using a module-specific file (similar to the.preambleand other files we already have), e.g.GObjectmight have aGObject-2.0.quirks` file.

Also, since these files need to be created by humans, I would not use json as a format. We probably want an expression system for versions and platforms (to avoid complex shell scripts such as the GLib one that needs to handle differently versioned .sed and .awk files), so something simple like the sed format would not be enough. Maybe something like yaml/StrictYAML might strike the right balance. Also, we will eventually needs something that can replace the state-based awk scripts (ideally with some domain knowledge that awk doesn't have, but gir2swift does: e.g. "the XYZ pointer type in the convenience initialisers implemented by functions containing new_abc_label that are part of the ABC struct).

from gir2swift.

Related Issues (13)

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.