RubyInline

fmms 13年前
     <p>RubyInline允许你在ruby代码中直接编写c/c++代码,还会有性能问题吗?</p>    <p>安装方法:sudo gem install RubyInline</p>    <p>示例代码:</p>    <pre class="brush:ruby; toolbar: true; auto-links: false;">class MyTest    def factorial(n)     f = 1     n.downto(2) { |x| f *= x }     f   end    inline do |builder|     builder.c "     long factorial_c(int max) {       int i=max, result=1;       while (i >= 2) { result *= i--; }       return result;     }"   end end</pre>    <p><strong>项目主页:</strong><a href="http://www.open-open.com/lib/view/home/1326986378265" target="_blank">http://www.open-open.com/lib/view/home/1326986378265</a></p>    <p></p>