summaryrefslogtreecommitdiff
path: root/modules/oop
diff options
context:
space:
mode:
Diffstat (limited to 'modules/oop')
-rw-r--r--modules/oop/pf-objects.scm31
1 files changed, 28 insertions, 3 deletions
diff --git a/modules/oop/pf-objects.scm b/modules/oop/pf-objects.scm
index f5b6466..fd11182 100644
--- a/modules/oop/pf-objects.scm
+++ b/modules/oop/pf-objects.scm
@@ -171,6 +171,7 @@ explicitly tell it to not update etc.
(hash-ref h key -fail))))
(define-method (find-in-class x key fail) fail)
+(define-method (find-in-class-raw klass key fail) fail)
(define-method (find-in-class-raw (klass <pf>) key fail)
(let ((r (vhash-assoc key (slot-ref klass 'h))))
@@ -519,6 +520,30 @@ explicitly tell it to not update etc.
(apply it class x)
(the-create-object class x))))))
+(define int-cls #f)
+(define int? #f)
+(define tuple-cls #f)
+(define tuple? #f)
+(define string-cls #f)
+(define str? #f)
+(define bytes-cls #f)
+(define bytes? #f)
+(define list-cls #f)
+(define list? #f)
+(define float-cls #f)
+(define float? #f)
+
+(define (check-obj obj)
+ (cond
+ ((int? obj) int-cls)
+ ((tuple? obj) tuple-cls)
+ ((float? obj) float-cls)
+ ((str? obj) string-cls)
+ ((list? obj) list-cls)
+ ((bytes? obj) bytes-cls)
+ (else
+ object)))
+
(define type-call
(lambda (class . l)
(if (pytype? class)
@@ -528,11 +553,11 @@ explicitly tell it to not update etc.
(lambda ()
(aif it (find-in-class-raw obj '__class__ #f)
it
- type))
+ (check-obj obj)))
(lambda x
(warn x)
- type)))
-
+ (check-obj obj))))
+
((meta name bases dict . keys)
(type- meta name bases dict keys)))
class l)