@amirrajan I heard a rumor that Rubymotion is going to be opensourced this year? I thought I should check with somebody legit so I know whether to squash the rumor or not.
@amirrajan That's awesome, so am I :) We should totally hang out.
@ioquatix Heck yea! Consider it done 🙂
@amirrajan I've been thinking of making Vulkan bindings for Ruby, including MoltenVK for MacOS. Is that totally crazy!?
@ioquatix no it isn't. Do it. And that's relevant to what I'll be talking about at Kaigi actually 🙂
@amirrajan I've already got a working C++ API, now just need to use SWIG or something similar to expose all the bindings and display/input stuff.
@ioquatix create a straight C api if you can. I can do some very cool things with that header file if you can pull it off.
@amirrajan It's easy enough to make a C header for a C++ API. It could even be generated automatically... I worked on C bindings for libclang which lets you parse the C++ AST and do stuff like generate documentation, refactoring etc.
@ioquatix Yep. I figured the C api is straight forward to create. With that created you can use one of RubyMotion's technologies called BridgeSupport that will automagically create the Ruby bindings.
It works with Java and Objective C too.
Still working on a turn key C++/Swift solution.
@amirrajan That sounds pretty awesome - what are the problems with supporting C++ right now? What are the benefits over using ffi?
@ioquatix take a look at this: https://github.com/amirrajan/RubyMotionBridgeSupport/tree/rubymotion-5.16/test
With regards to C++, the issue is mapping C++ features to Ruby features. It's not exactly 1-to-1 (especially with all the crazy stuff that has ben added to C++17+).
@ioquatix re "What are the benefits over using ffi?"
It still uses FFI, but the FFI is automatically created for you. All you need to do is give it a header file.
@amirrajan Haha, yeah I totally get how that stuff is super tricky. Especially if you were trying to map lambdas, template meta programming, etc. If you use pseudo-object C (e.g. struct pointer as first argument) does that get converted into an object in Ruby?
@ioquatix Structs *mostly* work (simd is always a pain in the ass). Variadic functions work too. But macros/macro expansion doesn't... yet
@ioquatix come to the RubyMotion Slack channel and DM me so we can plan the next steps for world domination.
@amirrajan Here is an example extracting all declarations and their related comment: https://github.com/ioquatix/ffi-clang/blob/master/examples/docs.rb
A Mastodon instance for Rubyists & friends