summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Andreas Benkard <matthias@benkard.de>2008-06-22 19:16:25 +0200
committerMatthias Andreas Benkard <matthias@benkard.de>2008-06-22 19:16:25 +0200
commit29b9ca1a3a9d1f6291af51ab2f6150039b2d5619 (patch)
treeb5ac2d792a8c5ec420f1b7a12d2f5f858c655e27
parent10e9a6f9e07aee31eb739187fbc7e065ac369bf4 (diff)
Add a -descriptionForLisp method to all number classes.
-rw-r--r--MLKDoubleFloat.h1
-rw-r--r--MLKInteger.h1
-rw-r--r--MLKInteger.m11
-rw-r--r--MLKRatio.h1
-rw-r--r--MLKRatio.m11
-rw-r--r--MLKSingleFloat.h1
-rw-r--r--MLKSingleFloat.m5
7 files changed, 31 insertions, 0 deletions
diff --git a/MLKDoubleFloat.h b/MLKDoubleFloat.h
index d7dbcd5..ce27ebd 100644
--- a/MLKDoubleFloat.h
+++ b/MLKDoubleFloat.h
@@ -50,4 +50,5 @@
-(MLKFloat *) divideBy:(MLKFloat *)arg;
-(NSString *) description;
+-(NSString *) descriptionForLisp;
@end
diff --git a/MLKInteger.h b/MLKInteger.h
index c651bab..f3c8d4f 100644
--- a/MLKInteger.h
+++ b/MLKInteger.h
@@ -51,6 +51,7 @@
-(NSString *) description;
-(NSString *) descriptionWithBase:(int)base;
+-(NSString *) descriptionForLisp;
-(void) dealloc;
@end
diff --git a/MLKInteger.m b/MLKInteger.m
index c7ecc48..03e56b3 100644
--- a/MLKInteger.m
+++ b/MLKInteger.m
@@ -16,7 +16,9 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#import "MLKDynamicContext.h"
#import "MLKInteger.h"
+#import "MLKPackage.h"
#import "runtime-compatibility.h"
#import "util.h"
@@ -101,6 +103,15 @@ DEFINE_MPZ_TWOARG_OPERATION (divideBy:, mpz_div)
return str;
}
+-(NSString *) descriptionForLisp
+{
+ MLKInteger *base = [[MLKDynamicContext currentContext]
+ valueForBinding:[[MLKPackage
+ findPackage:@"COMMON-LISP"]
+ intern:@"*PRINT-BASE*"]];
+ return [self descriptionWithBase:[base intValue]];
+}
+
-(void) dealloc
{
mpz_clear (value);
diff --git a/MLKRatio.h b/MLKRatio.h
index 6104955..b81e91a 100644
--- a/MLKRatio.h
+++ b/MLKRatio.h
@@ -49,6 +49,7 @@
-(NSString *) description;
-(NSString *) descriptionWithBase:(int)base;
+-(NSString *) descriptionForLisp;
-(void) dealloc;
@end
diff --git a/MLKRatio.m b/MLKRatio.m
index 4c434c9..d11ff49 100644
--- a/MLKRatio.m
+++ b/MLKRatio.m
@@ -16,6 +16,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+#import "MLKDynamicContext.h"
+#import "MLKPackage.h"
#import "MLKRatio.h"
#import "runtime-compatibility.h"
#import "util.h"
@@ -104,6 +106,15 @@ DEFINE_MPQ_TWOARG_OPERATION (divideBy:, mpq_div)
return str;
}
+-(NSString *) descriptionForLisp
+{
+ MLKInteger *base = [[MLKDynamicContext currentContext]
+ valueForBinding:[[MLKPackage
+ findPackage:@"COMMON-LISP"]
+ intern:@"*PRINT-BASE*"]];
+ return [self descriptionWithBase:[base intValue]];
+}
+
-(void) dealloc
{
mpq_clear (value);
diff --git a/MLKSingleFloat.h b/MLKSingleFloat.h
index 138c188..0dbec17 100644
--- a/MLKSingleFloat.h
+++ b/MLKSingleFloat.h
@@ -47,4 +47,5 @@
-(MLKFloat *) divideBy:(MLKFloat *)arg;
-(NSString *) description;
+-(NSString *) descriptionForLisp;
@end
diff --git a/MLKSingleFloat.m b/MLKSingleFloat.m
index 20d92ed..c10ccce 100644
--- a/MLKSingleFloat.m
+++ b/MLKSingleFloat.m
@@ -144,4 +144,9 @@
return [NSString stringWithFormat:@"%@s0",str];
}
+
+-(NSString *) descriptionForLisp
+{
+ return [self description];
+}
@end