Re: Ruby 2.7: rb_define_method and C++
Ryan Davis <[email protected]> Thu, 2 Jan 2020 01:46:16 -0800
| Newsgroups | gmane.comp.lang.ruby.general |
|---|---|
| Message-ID | <[email protected]> |
Please file an issue on bugs.ruby-lang.org or contact nobu directly... You won't get traction here. > On Dec 28, 2019, at 16:59, Jason Roelofs <[email protected]> wrote: > > Hey, > > I'm the maintainer of the Rice gem[0] which provides a higher level way for exposing C++ APIs into Ruby, and I've got a problem getting Rice to work with Ruby 2.7 and wondering if I can get some help or pointers. > > The short of it is, rb_define_method, when compiled under C++, is now redefined as a templated struct that takes the arity parameter as the template argument to pick the right overload at compile time[1]. This has led to a straight up compilation error in Rice under Ruby 2.7 [2] because as a C++ wrapper library, Rice builds up a wrapper object around each defined method to properly wrap and convert parameters and return values to and from Ruby, as well as providing a path from a templated C++ function or method to a plain C-usable function. That wrapper object is then provided to rb_define_method to properly expose the requested function/method to Ruby [3]. > > From what I can see, rb_define_method is now completely redefined to be this templated macro and I have found no way to directly call the underlying, original function. Does anyone here know why this change was made, if there were thoughts about keeping this function exposed for dynamic use, or if it still is, how I can call it (I've read through the source a few times, tried a few different defines, nothing seems to work)? > > Thanks > > Jason > > [0] https://github.com/jasonroelofs/rice > [1] https://github.com/ruby/ruby/commit/9c0d5e51cb3726455560c34ad595ab82f651da48#diff-3b256c5581538dcd834697c766a2b1aaR2770 > [2] https://github.com/jasonroelofs/rice/issues/119 > [3] https://github.com/jasonroelofs/rice/blob/master/rice/detail/method_data.cpp#L78 > > Unsubscribe: <mailto:[email protected]?subject=unsubscribe> > <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk> Unsubscribe: <mailto:[email protected]?subject=unsubscribe> <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>