hajimehoshi / go-steamworks

A Steamworks SDK binding for Go
Apache License 2.0
101 stars 18 forks source link

Steam_api_flat.h #9

Closed dan-myles closed 7 months ago

dan-myles commented 7 months ago

Hey!

Love your game engine, I think its a great project. However I did notice that a lot of bindings are missing in this library. I started to implementing some bindings myself so that I could file a PR but I noticed that steam now includes a steam_api_flat.h header file.

There are tools like c-for-go that could possibly generate unsafe bindings for all of the steam api in one go. Have you looked at the flat file at all? Have u thought about maybe programmatically generating unsafe Go bindings and then wrapping them further?

Let me know what you think. I tried to give it a go and generate some bindings but my C/C++ is not too great. Let me know what you think.

hajimehoshi commented 7 months ago

Yeah I actually create bindings based on steam_api_flat.h. Unfortunately the header file doen't include the information about public APIs (e.g. SteamAPI_InitSafe should be called for the public API Init). Also, how do we automatically generate the bindings from a C header file?

dan-myles commented 7 months ago

Yeah I actually create bindings based on steam_api_flat.h. Unfortunately the header file doen't include the information about public APIs (e.g. SteamAPI_InitSafe should be called for the public API Init). Also, how do we automatically generate the bindings from a C header file?

Coming from a Rust background I was used to using something like bindgen for that side of things. I loved that experience and thought it was a good way to do things.

Thankfully is similar tooling which you can find here. Tested it out with some simple libraries and it seemed to be working really great, and it is actively developed! Would take a lot of the work out of manually writing bindings, not to mention its produced some great libraries that you may use even now. Unfortunately the binding generator expects a C ABI because its using cgo... thankfully steam provides a C ABI wrapper now! So maybe someone with more intimate knowledge of C++ could generate some raw bindings.

hajimehoshi commented 7 months ago

As we plan to use PureGo in the future, such a tool is not an option unfortunately.

dan-myles commented 7 months ago

Wow looks really interesting! Thanks for the in-depth responses, looks like a neat tool.