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:37 UTC
[03/12] lucy-clownfish git commit: Move To_{Bool|String}
implementations to {Float|Int}64
Move To_{Bool|String} implementations to {Float|Int}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/5dc80204
Tree: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/tree/5dc80204
Diff: http://git-wip-us.apache.org/repos/asf/lucy-clownfish/diff/5dc80204
Branch: refs/heads/master
Commit: 5dc802044c944d49d81bcaf3c7cc368794630270
Parents: 8d379ef
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Thu Jul 9 15:33:28 2015 +0200
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Thu Jul 9 16:34:00 2015 +0200
----------------------------------------------------------------------
runtime/core/Clownfish/Num.c | 35 ++++++++++++++++++++---------------
runtime/core/Clownfish/Num.cfh | 30 ++++++++++++++++++------------
2 files changed, 38 insertions(+), 27 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/5dc80204/runtime/core/Clownfish/Num.c
----------------------------------------------------------------------
diff --git a/runtime/core/Clownfish/Num.c b/runtime/core/Clownfish/Num.c
index f310fd9..8f2e82c 100644
--- a/runtime/core/Clownfish/Num.c
+++ b/runtime/core/Clownfish/Num.c
@@ -64,11 +64,6 @@ Num_init(Num *self) {
return self;
}
-bool
-Num_To_Bool_IMP(Num *self) {
- return !!Num_To_I64(self);
-}
-
/***************************************************************************/
FloatNum*
@@ -77,11 +72,6 @@ FloatNum_init(FloatNum *self) {
return (FloatNum*)Num_init((Num*)self);
}
-String*
-FloatNum_To_String_IMP(FloatNum *self) {
- return Str_newf("%f64", FloatNum_To_F64(self));
-}
-
/***************************************************************************/
IntNum*
@@ -90,11 +80,6 @@ IntNum_init(IntNum *self) {
return (IntNum*)Num_init((Num*)self);
}
-String*
-IntNum_To_String_IMP(IntNum *self) {
- return Str_newf("%i64", IntNum_To_I64(self));
-}
-
/***************************************************************************/
Float64*
@@ -163,6 +148,16 @@ Float64_To_I64_IMP(Float64 *self) {
return (int64_t)self->value;
}
+bool
+Float64_To_Bool_IMP(Float64 *self) {
+ return self->value != 0.0;
+}
+
+String*
+Float64_To_String_IMP(Float64 *self) {
+ return Str_newf("%f64", self->value);
+}
+
Float64*
Float64_Clone_IMP(Float64 *self) {
return Float64_new(self->value);
@@ -239,6 +234,16 @@ Int64_To_I64_IMP(Integer64 *self) {
return self->value;
}
+bool
+Int64_To_Bool_IMP(Integer64 *self) {
+ return self->value != 0;
+}
+
+String*
+Int64_To_String_IMP(Integer64 *self) {
+ return Str_newf("%i64", self->value);
+}
+
Integer64*
Int64_Clone_IMP(Integer64 *self) {
return Int64_new(self->value);
http://git-wip-us.apache.org/repos/asf/lucy-clownfish/blob/5dc80204/runtime/core/Clownfish/Num.cfh
----------------------------------------------------------------------
diff --git a/runtime/core/Clownfish/Num.cfh b/runtime/core/Clownfish/Num.cfh
index 053c94d..ed314fe 100644
--- a/runtime/core/Clownfish/Num.cfh
+++ b/runtime/core/Clownfish/Num.cfh
@@ -32,12 +32,6 @@ abstract class Clownfish::Num inherits Clownfish::Obj {
*/
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.
@@ -46,9 +40,6 @@ abstract class Clownfish::FloatNum inherits Clownfish::Num {
inert FloatNum*
init(FloatNum *self);
-
- public incremented String*
- To_String(FloatNum *self);
}
@@ -58,9 +49,6 @@ abstract class Clownfish::IntNum inherits Clownfish::Num {
inert IntNum*
init(IntNum *self);
-
- public incremented String*
- To_String(IntNum *self);
}
/** Double precision floating point number.
@@ -93,6 +81,15 @@ final class Clownfish::Float64 inherits Clownfish::FloatNum {
public double
To_F64(Float64 *self);
+ /** Evaluate the number in a boolean context. Returns true if it is
+ * non-zero.
+ */
+ public bool
+ To_Bool(Float64 *self);
+
+ public incremented String*
+ To_String(Float64 *self);
+
public bool
Equals(Float64 *self, Obj *other);
@@ -138,6 +135,15 @@ final class Clownfish::Integer64 nickname Int64
public double
To_F64(Integer64 *self);
+ /** Evaluate the number in a boolean context. Returns true if it is
+ * non-zero.
+ */
+ public bool
+ To_Bool(Integer64 *self);
+
+ public incremented String*
+ To_String(Integer64 *self);
+
public bool
Equals(Integer64 *self, Obj *other);