[prev in list] [next in list] [prev in thread] [next in thread] 

List:       ruby-talk
Subject:    Re: Ruby 2.7: rb_define_method and C++
From:       Hanlyu Sarang <hanlyusarang () gmail ! com>
Date:       2019-12-29 3:15:50
Message-ID: 8548a895-427b-d569-0bf1-bbfdabc5f63b () gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


I noticed that rice stopped working when I upgraded to 2.7.0. I never 
had that problem before, and I always build from the sources, using 
./configure --enable-shared. It would be nice to get rice working again.

On 12/28/19 6:59 PM, Jason Roelofs 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:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
> <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>


[Attachment #5 (text/html)]

<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html;
      charset=windows-1252">
  </head>
  <body>
    <p>I noticed that rice stopped working when I upgraded to 2.7.0. I
      never had that problem before, and I always build from the
      sources, using ./configure --enable-shared. It would be nice to
      get rice working again.<br>
    </p>
    <div class="moz-cite-prefix">On 12/28/19 6:59 PM, Jason Roelofs
      wrote:<br>
    </div>
    <blockquote type="cite"
      cite="mid:C187C167-03DE-49A9-A40E-9D2B2ECF0FAF@gmail.com">
      <meta http-equiv="Content-Type" content="text/html;
        charset=windows-1252">
      Hey,
      <div class=""><br class="">
      </div>
      <div class="">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.</div>
      <div class=""><br class="">
      </div>
      <div class="">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].</div>
      <div class=""><br class="">
      </div>
      <div class="">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)?</div>
      <div class=""><br class="">
      </div>
      <div class="">Thanks</div>
      <div class=""><br class="">
      </div>
      <div class="">Jason</div>
      <div class=""><br class="">
      </div>
      <div class="">[0] <a href="https://github.com/jasonroelofs/rice"
          class="" moz-do-not-send="true">https://github.com/jasonroelofs/rice</a></div>
  <div class="">[1] <a
href="https://github.com/ruby/ruby/commit/9c0d5e51cb3726455560c34ad595ab82f651da48#diff-3b256c5581538dcd834697c766a2b1aaR2770"
  class="" moz-do-not-send="true">https://github.com/ruby/ruby/commit/9c0d5e51cb3726455560c34ad595ab82f651da48#diff-3b256c5581538dcd834697c766a2b1aaR2770</a></div>
  <div class="">[2] <a
          href="https://github.com/jasonroelofs/rice/issues/119"
          class="" moz-do-not-send="true">https://github.com/jasonroelofs/rice/issues/119</a></div>
  <div class="">[3] <a
href="https://github.com/jasonroelofs/rice/blob/master/rice/detail/method_data.cpp#L78"
                
          class="" moz-do-not-send="true">https://github.com/jasonroelofs/rice/blob/master/rice/detail/method_data.cpp#L78</a></div>
  <br>
      <fieldset class="mimeAttachmentHeader"></fieldset>
      <pre class="moz-quote-pre" wrap="">
Unsubscribe: <a class="moz-txt-link-rfc2396E" \
href="mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe">&lt;mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe&gt;</a>
 <a class="moz-txt-link-rfc2396E" \
href="http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk">&lt;http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk&gt;</a>
 </pre>
    </blockquote>
  </body>
</html>



Unsubscribe: <mailto:ruby-talk-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-talk>


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic