Commit d5e2753e authored by Niels Möller's avatar Niels Möller
Browse files

* make_class: New type special-struct.

Rev: src/make_class:1.9
parent d9fe6388
...@@ -66,6 +66,7 @@ ...@@ -66,6 +66,7 @@
;; (bignum) mpz_t name ;; (bignum) mpz_t name
;; (simple c-type) c-type ;; (simple c-type) c-type
;; (special c-type mark-fn free-fn) ;; (special c-type mark-fn free-fn)
;; (special-struct c-type mark-fn free-fn)
;; ;;
;; (struct tag) ;; (struct tag)
;; ;;
...@@ -91,7 +92,7 @@ ...@@ -91,7 +92,7 @@
(type->category `(simple ,type)) (type->category `(simple ,type))
(let ((tag (car type))) (let ((tag (car type)))
(case tag (case tag
((string object simple special space bignum struct) tag) ((string object simple special special-struct space bignum struct) tag)
((array var-array pointer) (type->category (cadr type))) ((array var-array pointer) (type->category (cadr type)))
(else (error "make_class: type->category: Invalid type" type)))))) (else (error "make_class: type->category: Invalid type" type))))))
...@@ -104,7 +105,7 @@ ...@@ -104,7 +105,7 @@
((object) (list "struct " (cadr type) " *" expr)) ((object) (list "struct " (cadr type) " *" expr))
((struct) (list "struct " (cadr type) " " expr)) ((struct) (list "struct " (cadr type) " " expr))
((bignum) (list "mpz_t " expr)) ((bignum) (list "mpz_t " expr))
((simple special) (list (cadr type) " " expr)) ((simple special special-struct) (list (cadr type) " " expr))
((pointer space) (type->declaration (cadr type) ((pointer space) (type->declaration (cadr type)
(list "(*(" expr "))"))) (list "(*(" expr "))")))
((array) (type->declaration (cadr type) ((array) (type->declaration (cadr type)
...@@ -141,7 +142,9 @@ ...@@ -141,7 +142,9 @@
((special) (let ((mark-fn (caddr type))) ((special) (let ((mark-fn (caddr type)))
(and mark-fn (list mark-fn "(" expr ", mark);\n")))) (and mark-fn (list mark-fn "(" expr ", mark);\n"))))
((special-struct) (let ((mark-fn (caddr type)))
(and mark-fn (list mark-fn "(&(" expr "), mark);\n"))))
;; FIXME: Doesn't handle nested arrays ;; FIXME: Doesn't handle nested arrays
((array) ((array)
(let ((mark-k (type->mark (cadr type) (list "(" expr ")[k]")))) (let ((mark-k (type->mark (cadr type) (list "(" expr ")[k]"))))
...@@ -173,7 +176,10 @@ ...@@ -173,7 +176,10 @@
((bignum) (free/f "mpz_clear")) ((bignum) (free/f "mpz_clear"))
((space) (free/f "lsh_space_free")) ((space) (free/f "lsh_space_free"))
((special) (free/f (cadddr type))) ((special) (free/f (cadddr type)))
((special-struct) (let ((free-fn (cadddr type)))
(and free-fn
(list free-fn "(&(" expr "));\n"))))
((array) ((array)
(let ((free-k (type->free (cadr type) (list "(" expr ")[k]")))) (let ((free-k (type->free (cadr type) (list "(" expr ")[k]"))))
(and free-k (and free-k
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment