Repository: lucy-clownfish
Updated Branches:
  refs/heads/master 2000cf969 -> 9a5dd08d7


Move To_I64, To_F64, and To_Bool from Obj to Num


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

Branch: refs/heads/master
Commit: 90e8a54201438e3491e86d576c8b6a76752b2b9d
Parents: be77123
Author: Nick Wellnhofer <[email protected]>
Authored: Fri May 22 17:34:45 2015 +0200
Committer: Nick Wellnhofer <[email protected]>
Committed: Wed May 27 16:01:11 2015 +0200

----------------------------------------------------------------------
 runtime/core/Clownfish/Num.c                     |  5 +++++
 runtime/core/Clownfish/Num.cfh                   | 16 ++++++++++++++++
 runtime/core/Clownfish/Obj.c                     |  5 -----
 runtime/core/Clownfish/Obj.cfh                   | 16 ----------------
 runtime/core/Clownfish/Test/TestObj.c            | 14 +-------------
 runtime/perl/buildlib/Clownfish/Build/Binding.pm |  2 --
 runtime/perl/t/binding/019-obj.t                 |  4 ++--
 7 files changed, 24 insertions(+), 38 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/90e8a542/runtime/core/Clownfish/Num.c
----------------------------------------------------------------------
diff --git a/runtime/core/Clownfish/Num.c b/runtime/core/Clownfish/Num.c
index 1016aa3..aeb9429 100644
--- a/runtime/core/Clownfish/Num.c
+++ b/runtime/core/Clownfish/Num.c
@@ -47,6 +47,11 @@ Num_Equals_IMP(Num *self, Obj *other) {
     return true;
 }
 
+bool
+Num_To_Bool_IMP(Num *self) {
+    return !!Num_To_I64(self);
+}
+
 /***************************************************************************/
 
 FloatNum*

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/90e8a542/runtime/core/Clownfish/Num.cfh
----------------------------------------------------------------------
diff --git a/runtime/core/Clownfish/Num.cfh b/runtime/core/Clownfish/Num.cfh
index 8cf03fc..b43d958 100644
--- a/runtime/core/Clownfish/Num.cfh
+++ b/runtime/core/Clownfish/Num.cfh
@@ -25,6 +25,22 @@ abstract class Clownfish::Num inherits Clownfish::Obj {
 
     public bool
     Equals(Num *self, Obj *other);
+
+    /** 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);
+
+    /** Evaluate the number in a boolean context.  By default, invokes
+     * [](cfish:.To_I64) and returns true if it is non-zero.
+     */
+    public bool
+    To_Bool(Num *self);
 }
 
 /** Abstract base class for floating point numbers.

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/90e8a542/runtime/core/Clownfish/Obj.c
----------------------------------------------------------------------
diff --git a/runtime/core/Clownfish/Obj.c b/runtime/core/Clownfish/Obj.c
index 3e2d040..6e99077 100644
--- a/runtime/core/Clownfish/Obj.c
+++ b/runtime/core/Clownfish/Obj.c
@@ -77,11 +77,6 @@ Obj_To_String_IMP(Obj *self) {
 #endif
 }
 
-bool
-Obj_To_Bool_IMP(Obj *self) {
-    return !!Obj_To_I64(self);
-}
-
 Class*
 Obj_Get_Class_IMP(Obj *self) {
     return self->klass;

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/90e8a542/runtime/core/Clownfish/Obj.cfh
----------------------------------------------------------------------
diff --git a/runtime/core/Clownfish/Obj.cfh b/runtime/core/Clownfish/Obj.cfh
index 9e74467..64e9f00 100644
--- a/runtime/core/Clownfish/Obj.cfh
+++ b/runtime/core/Clownfish/Obj.cfh
@@ -83,22 +83,6 @@ public abstract class Clownfish::Obj {
     public incremented String*
     To_String(Obj *self);
 
-    /** Convert the object to a 64-bit integer.
-     */
-    public abstract int64_t
-    To_I64(Obj *self);
-
-    /** Convert the object to a double precision floating point number.
-     */
-    public abstract double
-    To_F64(Obj *self);
-
-    /** Evaluate the object in a boolean context.  By default, invokes
-     * [](cfish:.To_I64) and returns true if it is non-zero.
-     */
-    public bool
-    To_Bool(Obj *self);
-
     /** Update the internal state of the object to mimic that of
      * `other`.
      */

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/90e8a542/runtime/core/Clownfish/Test/TestObj.c
----------------------------------------------------------------------
diff --git a/runtime/core/Clownfish/Test/TestObj.c 
b/runtime/core/Clownfish/Test/TestObj.c
index 4924288..0a08c44 100644
--- a/runtime/core/Clownfish/Test/TestObj.c
+++ b/runtime/core/Clownfish/Test/TestObj.c
@@ -116,16 +116,6 @@ S_attempt_Compare_To(void *context) {
 }
 
 static void
-S_attempt_To_I64(void *context) {
-    Obj_To_I64((Obj*)context);
-}
-
-static void
-S_attempt_To_F64(void *context) {
-    Obj_To_F64((Obj*)context);
-}
-
-static void
 S_attempt_Mimic(void *context) {
     Obj_Mimic((Obj*)context, (Obj*)context);
 }
@@ -151,15 +141,13 @@ test_abstract_routines(TestBatchRunner *runner) {
     Obj *obj = S_new_testobj();
     S_verify_abstract_error(runner, S_attempt_Clone,      obj, "Clone");
     S_verify_abstract_error(runner, S_attempt_Compare_To, obj, "Compare_To");
-    S_verify_abstract_error(runner, S_attempt_To_I64,     obj, "To_I64");
-    S_verify_abstract_error(runner, S_attempt_To_F64,     obj, "To_F64");
     S_verify_abstract_error(runner, S_attempt_Mimic,      obj, "Mimic");
     DECREF(obj);
 }
 
 void
 TestObj_Run_IMP(TestObj *self, TestBatchRunner *runner) {
-    TestBatchRunner_Plan(runner, (TestBatch*)self, 16);
+    TestBatchRunner_Plan(runner, (TestBatch*)self, 14);
     test_refcounts(runner);
     test_To_String(runner);
     test_Equals(runner);

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/90e8a542/runtime/perl/buildlib/Clownfish/Build/Binding.pm
----------------------------------------------------------------------
diff --git a/runtime/perl/buildlib/Clownfish/Build/Binding.pm 
b/runtime/perl/buildlib/Clownfish/Build/Binding.pm
index fa2f668..07ad5bd 100644
--- a/runtime/perl/buildlib/Clownfish/Build/Binding.pm
+++ b/runtime/perl/buildlib/Clownfish/Build/Binding.pm
@@ -390,8 +390,6 @@ END_XS_CODE
 sub bind_obj {
     my @exposed = qw(
         To_String
-        To_I64
-        To_F64
         Equals
     );
     my @hand_rolled = qw(

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/90e8a542/runtime/perl/t/binding/019-obj.t
----------------------------------------------------------------------
diff --git a/runtime/perl/t/binding/019-obj.t b/runtime/perl/t/binding/019-obj.t
index f2c0e10..5ac44e8 100644
--- a/runtime/perl/t/binding/019-obj.t
+++ b/runtime/perl/t/binding/019-obj.t
@@ -94,8 +94,8 @@ ok( !$object->is_a("thing"),             "custom is_a wrong" 
);
 eval { my $another_obj = TestObj->new( kill_me_now => 1 ) };
 like( $@, qr/kill_me_now/, "reject bad param" );
 
-eval { $object->to_i64 };
-like( $@, qr/Abstract method 'To_I64' not defined by TestObj/,
+eval { $object->clone };
+like( $@, qr/Abstract method 'Clone' not defined by TestObj/,
       "calling an abstract method throws" );
 
 my $stringified_perl_obj = "$object";

Reply via email to