Porting utility that can map to native APIs?

Has anyone ever considered writing a porting utility that can map x qt etc to the native api and prodyce a tree of diffs that could speed up and simplify ports ?

This way the tool could make the application native and patches could be upstreamed.

It seems like 95% of the effort exists in writing the library to start with. Afaik the biggest hurdle for ports to a different api is the large amount boiler plate code that makes it tedious.

It would also dramatically improve the odds of the haiku api being used.

The last time someone succeeded with a similar effort was the collection of awk scripts for converting SunView programs to Open Look, and that was with OL intrinstics specifically designed to resemble SunView to make porting trivial. Modern toolkits are much more complicated than SunView, so I don’t think an automatic porting tool would be realistic.

If you can write a comparability Library, you can translate the calls

That’s writing code, not a “porting utility that generates diffs”.

You are performing the same task, you are taking a api cal and converting it to another api.

I also didn’t say it would be easy, i stated that it would make sense to develop a tool

Even if it only translates 50% of the calls, it can still be very useful.

Even 50% of the calls would be very difficult to get right. Simple example: how do you distinguish between a Window used as a widget (where the corresponding Haiku concept is BView), and a Window used as a top level window (like a BWindow)?

The parent of the Window is only available at runtime, and that’s the only difference that distinguishes them (toplevel windows are attached to the root window, while “widget” windows are attached to something else.)

How does anyone ever do anything I wonder.

Probably Machine learning like gpt3 could be used.

The first problem you will hit is that each window runs in a separate thread, which most other toolkits don’t expect.

The BWindow/BView problem is not so hard to solve: in my IUP port I represent them both as BHandler, and dynamic_cast them as needed.

1 Like

I think that a AI type application could parse and translate much of the work

That would be an awesome AI project! The complicated thing is getting the training data, which would require a lot of examples of many applications in various other APIs then in the Haiku API. Preferably function to function (function A in QT, function A in some Windows junk, function A in GTK, etc and then function A with Haiku’s API). But given that, should be do-able with an convolutional neural network.

It’s probably worth experimenting