Ticket #541: const-fix.patch

File const-fix.patch, 2.0 KB (added by sjamaan, 13 years ago)

syntax stripping for "const" specifier and possibly others

  • support.scm

    diff --git a/support.scm b/support.scm
    index d2fde7a..77e3fa9 100644
    a b  
    11191119;;; Convert result value, if a string:
    11201120
    11211121(define (finish-foreign-result type body)
    1122   (case type
     1122  (case (##sys#strip-syntax type)
    11231123    [(c-string unsigned-c-string) `(##sys#peek-c-string ,body '0)]
    11241124    [(nonnull-c-string) `(##sys#peek-nonnull-c-string ,body '0)]
    11251125    [(c-string* unsigned-c-string*) `(##sys#peek-and-free-c-string ,body '0)]
     
    11291129    [(c-string-list*) `(##sys#peek-and-free-c-string-list ,body '#f)]
    11301130    [else
    11311131     (if (list? type)
    1132          (if (and (eq? (car type) 'const)
     1132         (if (and (eq? (##sys#strip-syntax (car type)) 'const)
    11331133                  (= 2 (length type))
    1134                   (memq (cadr type) '(c-string c-string* unsigned-c-string
    1135                                                unsigned-c-string* nonnull-c-string
    1136                                                nonnull-c-string*
    1137                                                nonnull-unsigned-string*)))
     1134                  (memq (##sys#strip-syntax (cadr type))
     1135                        '(c-string c-string* unsigned-c-string
     1136                                   unsigned-c-string* nonnull-c-string
     1137                                   nonnull-c-string*
     1138                                   nonnull-unsigned-string*)))
    11381139             (finish-foreign-result (cadr type) body)
    11391140             (if (= 3 (length type))
    11401141                 (case (car type)
  • tests/compiler-tests.scm

    diff --git a/tests/compiler-tests.scm b/tests/compiler-tests.scm
    index 43e308e..f4feb01 100644
    a b  
    125125    (fp)))
    126126
    127127
     128;; "const" qualifier should have no visible effect in Scheme
     129(define-syntax generate-external
     130  (syntax-rules ()
     131    ((_) (define-external
     132           (print_foo ((const c-string) foo))
     133           void
     134           (assert (string? foo))
     135           (print foo)))))
     136(generate-external)
     137((foreign-safe-lambda* void ()
     138   "print_foo(\"bar\");"))
     139
     140
    128141;;; compiler-syntax for map/for-each must be careful when the
    129142;   operator may have side-effects (currently only lambda exprs and symbols
    130143;   are allowed)