1
0
forked from alex-eg/sex

fix pub function prototypes

This commit is contained in:
2025-06-14 17:10:09 +03:00
parent 923900a6ae
commit 650bff6d0e
2 changed files with 22 additions and 5 deletions

View File

@@ -13,7 +13,8 @@
(struct foo (struct foo
((float a) ((float a)
(int b) (int b)
((const char *) c))) ((const char *) c)
((fn bool ((bool val))) not)))
,(list-T '(int)) ,(list-T '(int))
,(make-list-T '(int) #f) ,(make-list-T '(int) #f)
@@ -38,3 +39,8 @@
,(list-for-each '((printf "%d " v) l v)) ,(list-for-each '((printf "%d " v) l v))
(printf "\n") (printf "\n")
0) 0)
(pub fn segs-renderer* create-renderer ())
(pub fn void clear-command-buffer ((segs-renderer *r)))
(pub fn void add-render-command ((segs-renderer *r) ((fn void ()) command)))
(pub fn void commit-command-buffer ((segs-renderer *r)))

View File

@@ -80,10 +80,21 @@
form)) form))
acc))))) acc)))))
(define (normalize-fn-form form)
;; (fn ret-type name arglist body) -> normal function
;; (fn ret-type name arglist) -> prototype
(if (>= (length form) 5)
form
(cons 'prototype (cdr form))))
(define (walk-function form static acc) (define (walk-function form static acc)
(if static (if static
(append (walk-generic (list 'static form) (list)) acc) (append (walk-generic (list 'static (normalize-fn-form form))
(append (walk-generic (cdr form) (list)) acc))) (list))
acc)
(append (walk-generic (normalize-fn-form (cdr form))
(list))
acc)))
(define (walk-struct form acc) (define (walk-struct form acc)
(let ((name (unkebabify (cadr form)))) (let ((name (unkebabify (cadr form))))
@@ -94,11 +105,11 @@
(case (cadr form) (case (cadr form)
((fn) ((fn)
(append (append
(walk-generic (list 'extern (cons 'prototype (cddr form))) (list)) (list (cons 'extern (walk-function form #f (list))))
acc)) acc))
((var) ((var)
(append (append
(walk-generic (list 'extern (cdr form)) (list)) (list (cons 'extern (walk-generic (cdr form) (list))))
acc)) acc))
(else (error "Extern what?")))) (else (error "Extern what?"))))