Feature #9513

Hide Rational internal

Added by Akira Tanaka about 1 year ago. Updated 11 months ago.

[ruby-core:60665]
Status:Closed
Priority:Normal
Assignee:Yukihiro Matsumoto

Description

I'd like to hide C-level Ratinal internal.
I made a patch to do it.
This is similar to [Feature #6083] for struct RBignum.

If the internal is hidden, we can change it without compatibility problem.
For example, we can use GMP.

The patch moves struct RRational and related macros to internal.h.
It also provides two accessors, rb_rational_num and rb_rational_den and
changes ext/bigdecimal/bigdecimal.c and ext/date/date_core.c to
use these accessors.

How do you think, tadf?

hide-rational-internal.patch Magnifier (5.98 KB) Akira Tanaka, 02/12/2014 11:51 AM

Associated revisions

Revision 45976
Added by Akira Tanaka 11 months ago

  • include/ruby/ruby.h: Hide Rational internal.
    (RRational): Moved to internal.h
    (RRATIONAL): Ditto.
    (RRATIONAL_SET_NUM): Moved to rational.c.
    (RRATIONAL_SET_DEN): Ditto.

  • rational.c (rb_rational_num): New function.
    (rb_rational_den): Ditto.

  • include/ruby/intern.h (rb_rational_num): Declared.
    (rb_rational_den): Ditto.

  • ext/bigdecimal/bigdecimal.c: Follow the above change.

  • ext/date/date_core.c: Ditto.

[Feature #9513]

Revision 45976
Added by Akira Tanaka 11 months ago

  • include/ruby/ruby.h: Hide Rational internal.
    (RRational): Moved to internal.h
    (RRATIONAL): Ditto.
    (RRATIONAL_SET_NUM): Moved to rational.c.
    (RRATIONAL_SET_DEN): Ditto.

  • rational.c (rb_rational_num): New function.
    (rb_rational_den): Ditto.

  • include/ruby/intern.h (rb_rational_num): Declared.
    (rb_rational_den): Ditto.

  • ext/bigdecimal/bigdecimal.c: Follow the above change.

  • ext/date/date_core.c: Ditto.

[Feature #9513]

History

#1 Updated by Eric Wong about 1 year ago

akr@fsij.org wrote:

This is similar to [Feature #6083] for struct RBignum.

I support hiding more internals. Thank you.
I hope for 100% opaque data structures for the C-API one day,
maybe in 3-5 years?

#2 Updated by tadayoshi funaba 11 months ago

  • Status changed from Open to Assigned
  • Assignee changed from tadayoshi funaba to Yukihiro Matsumoto

i'm ok.

#3 Updated by Yukihiro Matsumoto 11 months ago

Accepted.

#4 Updated by Akira Tanaka 11 months ago

  • Status changed from Assigned to Closed
  • % Done changed from 0 to 100

Applied in changeset r45976.


  • include/ruby/ruby.h: Hide Rational internal.
    (RRational): Moved to internal.h
    (RRATIONAL): Ditto.
    (RRATIONAL_SET_NUM): Moved to rational.c.
    (RRATIONAL_SET_DEN): Ditto.

  • rational.c (rb_rational_num): New function.
    (rb_rational_den): Ditto.

  • include/ruby/intern.h (rb_rational_num): Declared.
    (rb_rational_den): Ditto.

  • ext/bigdecimal/bigdecimal.c: Follow the above change.

  • ext/date/date_core.c: Ditto.

[Feature #9513]

Also available in: Atom PDF