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/05/27 16:21:20 UTC

[1/3] lucy-clownfish git commit: Move To_I64, To_F64, and To_Bool from Obj to Num

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 <we...@aevum.de>
Authored: Fri May 22 17:34:45 2015 +0200
Committer: Nick Wellnhofer <we...@aevum.de>
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";


[2/3] lucy-clownfish git commit: Convert calls to Obj_To_[FI]64

Posted by nw...@apache.org.
Convert calls to Obj_To_[FI]64


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

Branch: refs/heads/master
Commit: be77123b21ee3b9987274e822cb611bf82107a3a
Parents: 2000cf9
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Fri May 22 17:17:39 2015 +0200
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Wed May 27 16:01:11 2015 +0200

----------------------------------------------------------------------
 runtime/core/Clownfish/Num.c | 2 +-
 runtime/perl/xs/XSBind.c     | 9 +++++----
 2 files changed, 6 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/be77123b/runtime/core/Clownfish/Num.c
----------------------------------------------------------------------
diff --git a/runtime/core/Clownfish/Num.c b/runtime/core/Clownfish/Num.c
index 862156c..1016aa3 100644
--- a/runtime/core/Clownfish/Num.c
+++ b/runtime/core/Clownfish/Num.c
@@ -83,7 +83,7 @@ IntNum_Compare_To_IMP(IntNum *self, Obj *other) {
         return -Obj_Compare_To(other, (Obj*)self);
     }
     int64_t self_value  = IntNum_To_I64(self);
-    int64_t other_value = Obj_To_I64(other);
+    int64_t other_value = IntNum_To_I64((IntNum*)other);
     if (self_value < other_value)      { return -1; }
     else if (self_value > other_value) { return 1;  }
     return 0;

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/be77123b/runtime/perl/xs/XSBind.c
----------------------------------------------------------------------
diff --git a/runtime/perl/xs/XSBind.c b/runtime/perl/xs/XSBind.c
index 7640e5c..eca8145 100644
--- a/runtime/perl/xs/XSBind.c
+++ b/runtime/perl/xs/XSBind.c
@@ -25,6 +25,7 @@
 #include "Clownfish/CharBuf.h"
 #include "Clownfish/HashIterator.h"
 #include "Clownfish/Method.h"
+#include "Clownfish/Num.h"
 #include "Clownfish/TestHarness/TestUtils.h"
 #include "Clownfish/Util/Atomic.h"
 #include "Clownfish/Util/StringHelper.h"
@@ -160,7 +161,7 @@ XSBind_cfish_to_perl(pTHX_ cfish_Obj *obj) {
         return S_cfish_hash_to_perl_hash(aTHX_ (cfish_Hash*)obj);
     }
     else if (CFISH_Obj_Is_A(obj, CFISH_FLOATNUM)) {
-        return newSVnv(CFISH_Obj_To_F64(obj));
+        return newSVnv(CFISH_FloatNum_To_F64((cfish_FloatNum*)obj));
     }
     else if (obj == (cfish_Obj*)CFISH_TRUE) {
         return newSViv(1);
@@ -169,15 +170,15 @@ XSBind_cfish_to_perl(pTHX_ cfish_Obj *obj) {
         return newSViv(0);
     }
     else if (sizeof(IV) == 8 && CFISH_Obj_Is_A(obj, CFISH_INTNUM)) {
-        int64_t num = CFISH_Obj_To_I64(obj);
+        int64_t num = CFISH_IntNum_To_I64((cfish_IntNum*)obj);
         return newSViv((IV)num);
     }
     else if (sizeof(IV) == 4 && CFISH_Obj_Is_A(obj, CFISH_INTEGER32)) {
-        int32_t num = (int32_t)CFISH_Obj_To_I64(obj);
+        int32_t num = (int32_t)CFISH_Int32_To_I64((cfish_Integer32*)obj);
         return newSViv((IV)num);
     }
     else if (sizeof(IV) == 4 && CFISH_Obj_Is_A(obj, CFISH_INTEGER64)) {
-        int64_t num = CFISH_Obj_To_I64(obj);
+        int64_t num = CFISH_Int64_To_I64((cfish_Integer64*)obj);
         return newSVnv((double)num); // lossy
     }
     else {


[3/3] lucy-clownfish git commit: Remove abstract method Obj_Mimic

Posted by nw...@apache.org.
Remove abstract method Obj_Mimic


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

Branch: refs/heads/master
Commit: 9a5dd08d7546badd9d86d0e9f7b63c2541fe9516
Parents: 90e8a54
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Fri May 22 17:55:09 2015 +0200
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Wed May 27 16:01:12 2015 +0200

----------------------------------------------------------------------
 runtime/core/Clownfish/Obj.cfh        | 6 ------
 runtime/core/Clownfish/Test/TestObj.c | 8 +-------
 2 files changed, 1 insertion(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/9a5dd08d/runtime/core/Clownfish/Obj.cfh
----------------------------------------------------------------------
diff --git a/runtime/core/Clownfish/Obj.cfh b/runtime/core/Clownfish/Obj.cfh
index 64e9f00..d4d20ad 100644
--- a/runtime/core/Clownfish/Obj.cfh
+++ b/runtime/core/Clownfish/Obj.cfh
@@ -82,11 +82,5 @@ public abstract class Clownfish::Obj {
      */
     public incremented String*
     To_String(Obj *self);
-
-    /** Update the internal state of the object to mimic that of
-     * `other`.
-     */
-    public abstract void
-    Mimic(Obj *self, Obj *other);
 }
 

http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/9a5dd08d/runtime/core/Clownfish/Test/TestObj.c
----------------------------------------------------------------------
diff --git a/runtime/core/Clownfish/Test/TestObj.c b/runtime/core/Clownfish/Test/TestObj.c
index 0a08c44..d763988 100644
--- a/runtime/core/Clownfish/Test/TestObj.c
+++ b/runtime/core/Clownfish/Test/TestObj.c
@@ -116,11 +116,6 @@ S_attempt_Compare_To(void *context) {
 }
 
 static void
-S_attempt_Mimic(void *context) {
-    Obj_Mimic((Obj*)context, (Obj*)context);
-}
-
-static void
 S_verify_abstract_error(TestBatchRunner *runner, Err_Attempt_t routine,
                         void *context, const char *name) {
     char message[100];
@@ -141,13 +136,12 @@ 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_Mimic,      obj, "Mimic");
     DECREF(obj);
 }
 
 void
 TestObj_Run_IMP(TestObj *self, TestBatchRunner *runner) {
-    TestBatchRunner_Plan(runner, (TestBatch*)self, 14);
+    TestBatchRunner_Plan(runner, (TestBatch*)self, 13);
     test_refcounts(runner);
     test_To_String(runner);
     test_Equals(runner);