From 29b9ca1a3a9d1f6291af51ab2f6150039b2d5619 Mon Sep 17 00:00:00 2001 From: Matthias Andreas Benkard Date: Sun, 22 Jun 2008 19:16:25 +0200 Subject: Add a -descriptionForLisp method to all number classes. --- MLKDoubleFloat.h | 1 + MLKInteger.h | 1 + MLKInteger.m | 11 +++++++++++ MLKRatio.h | 1 + MLKRatio.m | 11 +++++++++++ MLKSingleFloat.h | 1 + MLKSingleFloat.m | 5 +++++ 7 files changed, 31 insertions(+) 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 . */ +#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 . */ +#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 -- cgit v1.2.3