nimraylib_now icon indicating copy to clipboard operation
nimraylib_now copied to clipboard

Generate bindings from JSON

Open greenfork opened this issue 4 years ago • 5 comments

Raylib provides a parser which conveniently generates specification of all the types and functions for its sources. This should be a better option than current struggle with multi-step processing of C and Nim files.

Current PoC: https://gist.github.com/planetis-m/04d4fb2a3784329d2c6d2e20ed52c2fc

greenfork avatar Dec 27 '21 08:12 greenfork

Just to mention, an alternative might be to modify c2nim postprocessor.nim to either output JSON or directly apply transformations to PNodes. This might be better considering raylib_parser is having trouble processing other files than raylib.h

planetis-m avatar Dec 29 '21 11:12 planetis-m

@planetis-m what is our current state of JSON vs c2nim implementation, what are your thoughts? JSON still has some problems as c2nim at least with pointers/arrays. So it's not that obvious what's going to be better at the end if we assume that c2nim will evolve. According to Nim survey tooling looks like a decent priority.

Did you have a chance to look at c2nim API for ways to better integrate the conversion script? We can certainly reuse ideas from JSON script I think, looks like they intersect quite a bit.

greenfork avatar Jan 19 '22 05:01 greenfork

Did you have a chance to look at c2nim API for ways to better integrate the conversion script? We can certainly reuse ideas from JSON script I think, looks like they intersect quite a bit.

Araq made the branch araq-gobject that has an example of using c2nim as a library with a custom callback. I am stuck at trying to update c2nim to the latest compiler, there are a couple of regressions and I have limited time. But I believe it's the way forward.

planetis-m avatar Jan 20 '22 15:01 planetis-m

I see! Okay, than I will do my part at restructuring the pipeline and I will take a closer look at how to integrate all the great stuff in the JSON PR and whether we would like to completely switch to it. I have very mixed feelings about choosing between c2nim and JSON version :) It is probable that for research purposes we might want to maintain both versions until there's a clear leader.

greenfork avatar Jan 20 '22 15:01 greenfork

In that case, a better alternative to raylib-parser is opir from futhark. We ca use its output instead.

planetis-m avatar Jan 20 '22 17:01 planetis-m