Feature #9888
closedHide Complex internal
Description
From 428bce1d9b43210ca07c89e7c594925dda3b7934 Mon Sep 17 00:00:00 2001
From: "Urabe, Shyouhei" <shyouhei@ruby-lang.org>
Date: Sat, 31 May 2014 21:48:10 +0900
Subject: [PATCH] Hide Complex internal
So I agree with Eric and tried to hide RSymbol, but turned out that was already done by him :p
Here you are the other (seemingly) okay struct to hide.
Signed-off-by: Urabe, Shyouhei <shyouhei@ruby-lang.org>
---
 ChangeLog           |  6 ++++++
 include/ruby/ruby.h | 10 ----------
 internal.h          | 10 ++++++++++
 3 files changed, 16 insertions(+), 10 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 7f8d338..0f83112 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Sat May 31 21:47:40 2014  URABE Shyouhei  <shyouhei@ruby-lang.org>
+
+	* include/ruby/ruby.h (struct RComplex) : no longer.
+
+	* internal.h (struct RComplex) : moved here.
+
 Sat May 31 16:32:50 2014  SHIBATA Hiroshi  <shibata.hiroshi@gmail.com>
 
 	* lib/ipaddr.rb: extracted inline tests into test dir.
diff --git a/include/ruby/ruby.h b/include/ruby/ruby.h
index 7c7cb67..c412e9e 100644
--- a/include/ruby/ruby.h
+++ b/include/ruby/ruby.h
@@ -943,15 +943,6 @@ struct RFile {
     struct rb_io_t *fptr;
 };
 
-struct RComplex {
-    struct RBasic basic;
-    const VALUE real;
-    const VALUE imag;
-};
-
-#define RCOMPLEX_SET_REAL(cmp, r) RB_OBJ_WRITE((cmp), &((struct RComplex *)(cmp))->real,(r))
-#define RCOMPLEX_SET_IMAG(cmp, i) RB_OBJ_WRITE((cmp), &((struct RComplex *)(cmp))->imag,(i))
-
 struct RData {
     struct RBasic basic;
     void (*dmark)(void*);
@@ -1086,7 +1077,6 @@ struct RStruct {
 #define RTYPEDDATA(obj)   (R_CAST(RTypedData)(obj))
 #define RSTRUCT(obj) (R_CAST(RStruct)(obj))
 #define RFILE(obj)   (R_CAST(RFile)(obj))
-#define RCOMPLEX(obj) (R_CAST(RComplex)(obj))
 
 #define FL_SINGLETON FL_USER0
 #define FL_WB_PROTECTED (((VALUE)1)<<5)
diff --git a/internal.h b/internal.h
index 2c1c6a3..19ccdaa 100644
--- a/internal.h
+++ b/internal.h
@@ -420,6 +420,16 @@ struct RSymbol {
 
 #define RSYMBOL(obj) (R_CAST(RSymbol)(obj))
 
+struct RComplex {
+    struct RBasic basic;
+    const VALUE real;
+    const VALUE imag;
+};
+
+#define RCOMPLEX(obj) (R_CAST(RComplex)(obj))
+#define RCOMPLEX_SET_REAL(cmp, r) RB_OBJ_WRITE((cmp), &((struct RComplex *)(cmp))->real,(r))
+#define RCOMPLEX_SET_IMAG(cmp, i) RB_OBJ_WRITE((cmp), &((struct RComplex *)(cmp))->imag,(i))
+
 /* class.c */
 void rb_class_subclass_add(VALUE super, VALUE klass);
 void rb_class_remove_from_super_subclasses(VALUE);
-- 
1.9.1
        
           Updated by nobu (Nobuyoshi Nakada) over 11 years ago
          Updated by nobu (Nobuyoshi Nakada) over 11 years ago
          
          
        
        
      
      Why keep RCOMPLEX_SET_REAL and RCOMPLEX_SET_IMAG public?
They don't seem to be used anywhere else.
At least, they have to have rb_ prefix.
        
           Updated by shyouhei (Shyouhei Urabe) over 11 years ago
          Updated by shyouhei (Shyouhei Urabe) over 11 years ago
          
          
        
        
      
      Nobuyoshi Nakada wrote:
Why keep
RCOMPLEX_SET_REALandRCOMPLEX_SET_IMAGpublic?
They don't seem to be used anywhere else.
At least, they have to haverb_prefix.
If deleting now-public APIs are OK, I'd be happy to do so.  Having rb_ prefix
makes absolutely zero sense because they are for backward API compatibility.
        
           Updated by nobu (Nobuyoshi Nakada) over 11 years ago
          Updated by nobu (Nobuyoshi Nakada) over 11 years ago
          
          
        
        
      
      The prefix is to avoid potential name-clashes with other libraries.
        
           Updated by shyouhei (Shyouhei Urabe) over 11 years ago
          Updated by shyouhei (Shyouhei Urabe) over 11 years ago
          
          
        
        
      
      - Description updated (diff)
OK, lets just abandon them. Patch updated.
        
           Updated by shyouhei (Shyouhei Urabe) over 11 years ago
          Updated by shyouhei (Shyouhei Urabe) over 11 years ago
          
          
        
        
      
      - Description updated (diff)
        
           Updated by matz (Yukihiro Matsumoto) over 11 years ago
          Updated by matz (Yukihiro Matsumoto) over 11 years ago
          
          
        
        
      
      Approved.
Matz.
        
           Updated by shyouhei (Shyouhei Urabe) over 11 years ago
          Updated by shyouhei (Shyouhei Urabe) over 11 years ago
          
          
        
        
      
      - Status changed from Open to Closed
- % Done changed from 0 to 100
Applied in changeset r46506.
- 
include/ruby/ruby.h (struct RComplex): no longer. [Feature #9888] - 
include/ruby/ruby.h (RCOMPLEX): ditto. 
- 
include/ruby/ruby.h (RCOMPLEX_SET_REAL): deprecated. Will be deleted later. 
- 
include/ruby/ruby.h (RCOMPLEX_SET_IMAG): ditto. 
- 
internal.h (struct RFloat): moved here. 
- 
internal.h (RCOMPLEX): ditto. 
- 
complex.c (rb_complex_set_real): do not use this. 
- 
complex.c (rb_complex_set_imag): ditto. 
 
-