You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by nw...@apache.org on 2015/07/11 14:52:36 UTC

[02/12] lucy-clownfish git commit: Flatten Num class hierarchy

Flatten Num class hierarchy

Float64 and Integer64 inherit directly from Obj now.


Project: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/commit/d845e959
Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/d845e959
Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/d845e959

Branch: refs/heads/master
Commit: d845e95925fb927491c2ef24493122fa77b4540b
Parents: 5dc8020
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Thu Jul 9 15:39:16 2015 +0200
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Thu Jul 9 16:34:00 2015 +0200

----------------------------------------------------------------------
 runtime/core/Clownfish/Num.c   | 31 ++--------------------------
 runtime/core/Clownfish/Num.cfh | 40 ++-----------------------------------
 2 files changed, 4 insertions(+), 67 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/d845e959/runtime/core/Clownfish/Num.c
----------------------------------------------------------------------
diff --git a/runtime/core/Clownfish/Num.c b/runtime/core/Clownfish/Num.c
index 8f2e82c..3dad95d 100644
--- a/runtime/core/Clownfish/Num.c
+++ b/runtime/core/Clownfish/Num.c
@@ -14,9 +14,6 @@
  * limitations under the License.
  */
 
-#define C_CFISH_NUM
-#define C_CFISH_INTNUM
-#define C_CFISH_FLOATNUM
 #define C_CFISH_INTEGER64
 #define C_CFISH_FLOAT64
 #define CFISH_USE_SHORT_NAMES
@@ -58,30 +55,6 @@ S_compare_i64_f64(int64_t i64, double f64);
 static bool
 S_equals_i64_f64(int64_t i64, double f64);
 
-Num*
-Num_init(Num *self) {
-    ABSTRACT_CLASS_CHECK(self, NUM);
-    return self;
-}
-
-/***************************************************************************/
-
-FloatNum*
-FloatNum_init(FloatNum *self) {
-    ABSTRACT_CLASS_CHECK(self, FLOATNUM);
-    return (FloatNum*)Num_init((Num*)self);
-}
-
-/***************************************************************************/
-
-IntNum*
-IntNum_init(IntNum *self) {
-    ABSTRACT_CLASS_CHECK(self, INTNUM);
-    return (IntNum*)Num_init((Num*)self);
-}
-
-/***************************************************************************/
-
 Float64*
 Float64_new(double value) {
     Float64 *self = (Float64*)Class_Make_Obj(FLOAT64);
@@ -91,7 +64,7 @@ Float64_new(double value) {
 Float64*
 Float64_init(Float64 *self, double value) {
     self->value = value;
-    return (Float64*)FloatNum_init((FloatNum*)self);
+    return self;
 }
 
 bool
@@ -180,7 +153,7 @@ Int64_new(int64_t value) {
 Integer64*
 Int64_init(Integer64 *self, int64_t value) {
     self->value = value;
-    return (Integer64*)IntNum_init((IntNum*)self);
+    return self;
 }
 
 bool

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/d845e959/runtime/core/Clownfish/Num.cfh
----------------------------------------------------------------------
diff --git a/runtime/core/Clownfish/Num.cfh b/runtime/core/Clownfish/Num.cfh
index ed314fe..0b4b368 100644
--- a/runtime/core/Clownfish/Num.cfh
+++ b/runtime/core/Clownfish/Num.cfh
@@ -16,44 +16,9 @@
 
 parcel Clownfish;
 
-/** Abstract base class for numbers.
- */
-abstract class Clownfish::Num inherits Clownfish::Obj {
-
-    inert Num*
-    init(Num *self);
-
-    /** Convert the number to a 64-bit integer.
-     */
-    public abstract int64_t
-    To_I64(Num *self);
-
-    /** Convert the number to a double precision floating point number.
-     */
-    public abstract double
-    To_F64(Num *self);
-}
-
-/** Abstract base class for floating point numbers.
- */
-abstract class Clownfish::FloatNum inherits Clownfish::Num {
-
-    inert FloatNum*
-    init(FloatNum *self);
-}
-
-
-/** Abstract base class for Integers.
- */
-abstract class Clownfish::IntNum inherits Clownfish::Num {
-
-    inert IntNum*
-    init(IntNum *self);
-}
-
 /** Double precision floating point number.
  */
-final class Clownfish::Float64 inherits Clownfish::FloatNum {
+final class Clownfish::Float64 {
 
     double value;
 
@@ -106,8 +71,7 @@ final class Clownfish::Float64 inherits Clownfish::FloatNum {
 /**
  * 64-bit signed integer.
  */
-final class Clownfish::Integer64 nickname Int64
-    inherits Clownfish::IntNum {
+final class Clownfish::Integer64 nickname Int64 {
 
     int64_t value;