summaryrefslogtreecommitdiff
path: root/Lisp
diff options
context:
space:
mode:
authorMatthias Benkard <code@mail.matthias.benkard.de>2007-09-14 21:32:59 +0200
committerMatthias Benkard <code@mail.matthias.benkard.de>2007-09-14 21:32:59 +0200
commit213250b363705b9be3acdd90f604169c0e23b355 (patch)
tree1d0d2f50b40ea50b57d15eacc6662a0537251d14 /Lisp
parent25cc1a489ff21bedae0a9ebfc9b462113ccc56c7 (diff)
Use PRIMITIVE-INVOKE in memory management and clean the codebase up a bit.
darcs-hash:a0d7f10b0b4e7fe43271fcce37523424f43480da
Diffstat (limited to 'Lisp')
-rw-r--r--Lisp/data-types.lisp33
-rw-r--r--Lisp/init.lisp3
-rw-r--r--Lisp/memory-management.lisp8
-rw-r--r--Lisp/utilities.lisp34
4 files changed, 41 insertions, 37 deletions
diff --git a/Lisp/data-types.lisp b/Lisp/data-types.lisp
index 35acb2f..6f66e8c 100644
--- a/Lisp/data-types.lisp
+++ b/Lisp/data-types.lisp
@@ -169,39 +169,6 @@ an __exception__, you can simply send it the `self' message.
(foreign-free obj-data))
-(defmethod print-object ((object id) stream)
- (print-unreadable-object (object stream)
- (format stream "~A `~A' {~X}"
- (objcl-class-name (primitive-invoke object "class" :id))
- (primitive-invoke (primitive-invoke object "description" :id)
- "UTF8String" :string)
- (primitive-invoke object "hash" :unsigned-int))))
-
-
-(defmethod print-object ((class objc-class) stream)
- (print-unreadable-object (class stream)
- (format stream "~S ~A {~X}"
- 'objc-class
- (objcl-class-name class)
- (primitive-invoke class "hash" :unsigned-int))))
-
-
-(defmethod print-object ((selector selector) stream)
- (print-unreadable-object (selector stream)
- (format stream "~S `~A'"
- 'selector
- (selector-name selector))))
-
-
-(defmethod print-object ((exception exception) stream)
- (print-unreadable-object (exception stream)
- (format stream "~S ~A {~X}"
- 'exception
- (primitive-invoke (primitive-invoke exception "name" :id)
- "UTF8String" :string)
- (primitive-invoke exception "hash" :unsigned-int))))
-
-
;;;; (@* "Convenience types")
(deftype c-pointer ()
'(satisfies pointerp))
diff --git a/Lisp/init.lisp b/Lisp/init.lisp
new file mode 100644
index 0000000..84ae511
--- /dev/null
+++ b/Lisp/init.lisp
@@ -0,0 +1,3 @@
+(in-package #:mulk.objective-cl)
+
+(initialise-runtime)
diff --git a/Lisp/memory-management.lisp b/Lisp/memory-management.lisp
index 1a3055b..4dec98e 100644
--- a/Lisp/memory-management.lisp
+++ b/Lisp/memory-management.lisp
@@ -18,8 +18,8 @@
`(lambda ()
(defmethod make-instance ((class (eql ',type)) &rest initargs &key)
(let* ((hash-table ,(ecase type
- ((id) '*id-objects*)
- ((objc-class) '*class-objects*)
+ ((id) '*id-objects*)
+ ((objc-class) '*class-objects*)
((exception) '*exception-objects*)))
(hash-key (pointer-address (getf initargs :pointer)))
(obj (weak-gethash hash-key hash-table nil)))
@@ -30,7 +30,7 @@
:incomplete)
(let ((new-obj (call-next-method)))
(unless *skip-retaining*
- (invoke-by-name new-obj "retain"))
+ (primitive-invoke new-obj "retain" :id))
(unless *skip-finalization*
;; We only put the new object into the hash
;; table if it is a regular wrapper object
@@ -56,7 +56,7 @@
(*skip-retaining* t))
(make-instance saved-type
:pointer saved-pointer))))
- (invoke-by-name temp "release"))))
+ (primitive-invoke temp "release" :id))))
(trivial-garbage:finalize new-obj #'finalizer))))
new-obj))
(t obj))))
diff --git a/Lisp/utilities.lisp b/Lisp/utilities.lisp
index 29efb60..be6f8b4 100644
--- a/Lisp/utilities.lisp
+++ b/Lisp/utilities.lisp
@@ -90,3 +90,37 @@
(defmethod objc-equal ((x string) (y selector))
(equal x (selector-name y)))
+
+
+;;; (@* "Object Representation")
+(defmethod print-object ((object id) stream)
+ (print-unreadable-object (object stream)
+ (format stream "~A `~A' {~X}"
+ (objcl-class-name (primitive-invoke object "class" :id))
+ (primitive-invoke (primitive-invoke object "description" :id)
+ "UTF8String" :string)
+ (primitive-invoke object "hash" :unsigned-int))))
+
+
+(defmethod print-object ((class objc-class) stream)
+ (print-unreadable-object (class stream)
+ (format stream "~S ~A {~X}"
+ 'objc-class
+ (objcl-class-name class)
+ (primitive-invoke class "hash" :unsigned-int))))
+
+
+(defmethod print-object ((selector selector) stream)
+ (print-unreadable-object (selector stream)
+ (format stream "~S `~A'"
+ 'selector
+ (selector-name selector))))
+
+
+(defmethod print-object ((exception exception) stream)
+ (print-unreadable-object (exception stream)
+ (format stream "~S ~A {~X}"
+ 'exception
+ (primitive-invoke (primitive-invoke exception "name" :id)
+ "UTF8String" :string)
+ (primitive-invoke exception "hash" :unsigned-int))))