From 89e6910f04bb7dcb4d1b3879b8e98295bc20271d Mon Sep 17 00:00:00 2001 From: ko1 Date: Mon, 13 May 2013 15:55:09 +0000 Subject: * include/ruby/ruby.h: constify RRational::(num,den) and RComplex::(real,imag). Add macro to set these values: * RRATIONAL_SET_NUM() * RRATIONAL_SET_DEN() * RCOMPLEX_SET_REAL() * RCOMPLEX_SET_IMAG() This change is a part of RGENGC branch [ruby-trunk - Feature #8339]. TODO: API design. RRATIONAL_SET(rat,num,den) is enough? TODO: Setting constify variable with cast has same issue of r40691. * complex.c, rational.c: use above macros. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@40698 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- include/ruby/ruby.h | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'include/ruby') diff --git a/include/ruby/ruby.h b/include/ruby/ruby.h index ed91594bf1..3e6909d3e0 100644 --- a/include/ruby/ruby.h +++ b/include/ruby/ruby.h @@ -931,16 +931,22 @@ struct RFile { struct RRational { struct RBasic basic; - VALUE num; - VALUE den; + const VALUE num; + const VALUE den; }; +#define RRATIONAL_SET_NUM(rat, n) (*((VALUE *)(&((struct RRational *)(rat))->num)) = (n)) +#define RRATIONAL_SET_DEN(rat, d) (*((VALUE *)(&((struct RRational *)(rat))->den)) = (d)) + struct RComplex { struct RBasic basic; - VALUE real; - VALUE imag; + const VALUE real; + const VALUE imag; }; +#define RCOMPLEX_SET_REAL(cmp, r) (*((VALUE *)(&((struct RComplex *)(cmp))->real)) = (r)) +#define RCOMPLEX_SET_IMAG(cmp, i) (*((VALUE *)(&((struct RComplex *)(cmp))->imag)) = (i)) + struct RData { struct RBasic basic; void (*dmark)(void*); -- cgit v1.2.3