diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..0a04128 --- /dev/null +++ b/LICENSE @@ -0,0 +1,165 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. diff --git a/composition.scm b/composition.scm index 6919b2e..5fe4b11 100644 --- a/composition.scm +++ b/composition.scm @@ -1,6 +1,6 @@ ((packager . "retropikzel") (name . "r7rs-pffi") - (version . "v0-4-2") + (version . "v0-4-3") (type . "library") (description . "Portable Foreign Function Interface for R7RS schemes") (license . "LGPL") diff --git a/curl.dll b/curl.dll new file mode 100755 index 0000000..094e776 Binary files /dev/null and b/curl.dll differ diff --git a/retropikzel/r7rs-pffi/version/kawa.scm b/retropikzel/r7rs-pffi/version/kawa.scm index cfd4ef0..af9b3cd 100644 --- a/retropikzel/r7rs-pffi/version/kawa.scm +++ b/retropikzel/r7rs-pffi/version/kawa.scm @@ -130,3 +130,7 @@ (define pffi-pointer-deref (lambda (pointer) (invoke pointer 'get (static-field java.lang.foreign.ValueLayout 'ADDRESS) 0))) + +(define pffi-define-callback + (lambda (scheme-name return-type argument-types procedure) + (error "pffi-define-callback not yet implemented for Kawa"))) diff --git a/retropikzel/r7rs-pffi/version/main.rkt b/retropikzel/r7rs-pffi/version/main.rkt index 99d8971..4a9282a 100644 --- a/retropikzel/r7rs-pffi/version/main.rkt +++ b/retropikzel/r7rs-pffi/version/main.rkt @@ -1,234 +1,3 @@ #lang r7rs -(define-library - (retropikzel r7rs-pffi version main) - (cond-expand - (sagittarius - (import (scheme base) - (scheme write) - (scheme file) - (scheme process-context) - (retropikzel r7rs-pffi version sagittarius))) - (guile - (import (scheme base) - (scheme write) - (scheme file) - (scheme process-context) - (retropikzel r7rs-pffi version guile))) - (racket - (import (scheme base) - (scheme write) - (scheme file) - (scheme process-context) - (only (racket base) system-type) - (retropikzel r7rs-pffi version racket))) - (stklos - (import (scheme base) - (scheme write) - (scheme file) - (scheme process-context) - (stklos) - (retropikzel r7rs-pffi version stklos))) - (kawa - (import (scheme base) - (scheme write) - (scheme file) - (scheme process-context))) - (cyclone - (import (scheme base) - (scheme write) - (scheme file) - (scheme process-context) - (retropikzel r7rs-pffi version cyclone))) - (gambit - (import (scheme base) - (scheme write) - (scheme file) - (scheme process-context) - (retropikzel r7rs-pffi version gambit))) - (chicken - (import (scheme base) - (scheme write) - (scheme file) - (scheme process-context) - (retropikzel r7rs-pffi version chicken))) - (chibi - (import (scheme base) - (scheme write) - (scheme file) - (scheme process-context) - (retropikzel r7rs-pffi version chibi))) - (mit-scheme - (import (scheme base) - (scheme write) - (scheme file) - (scheme process-context) - (retropikzel r7rs-pffi version mit-scheme)))) - (export pffi-shared-object-auto-load - pffi-shared-object-load - pffi-define - pffi-define-callback - pffi-size-of - pffi-pointer-allocate - pffi-pointer-null - pffi-string->pointer - pffi-pointer->string - pffi-pointer-free - pffi-pointer? - pffi-pointer-null? - pffi-pointer-set! - pffi-pointer-get - pffi-pointer-deref) - (begin - - - #|doc Testing multiline comment |# - - - - (define library-version "v0-3-0") - (define slash (cond-expand (windows (string #\\)) (else "/"))) - - (define platform-file-extension - (cond-expand - (racket (if (equal? (system-type 'os) 'windows) ".dll" ".so")) - (windows ".dll") - (else ".so"))) - - (define platform-lib-prefix - (cond-expand - (racket (if (equal? (system-type 'os) 'windows) "" "lib")) - (windows "") - (else "lib"))) - - (define pffi-types - '(int8 - uint8 - int16 - uint16 - int32 - uint32 - int64 - uint64 - char - unsigned-char - short - unsigned-short - int - unsigned-int - long - unsigned-long - float - double - string - pointer - void)) - - (define string-split - (lambda (str mark) - (let* ((str-l (string->list str)) - (res (list)) - (last-index 0) - (index 0) - (splitter (lambda (c) - (cond ((char=? c mark) - (begin - (set! res (append res (list (string-copy str last-index index)))) - (set! last-index (+ index 1)))) - ((equal? (length str-l) (+ index 1)) - (set! res (append res (list (string-copy str last-index (+ index 1))))))) - (set! index (+ index 1))))) - (for-each splitter str-l) - res))) - - (define auto-load-paths - (append - (cond-expand - (windows - (append - (if (get-environment-variable "SYSTEM") - (list (get-environment-variable "SYSTEM")) - (list)) - (if (get-environment-variable "WINDIR") - (list (get-environment-variable "WINDIR")) - (list)) - (if (get-environment-variable "WINEDLLDIR0") - (list (get-environment-variable "WINEDLLDIR0")) - (list)) - (if (get-environment-variable "SystemRoot") - (list (string-append - (get-environment-variable "SystemRoot") - slash - "system32")) - (list)) - (list ".") - (if (get-environment-variable "PATH") - (string-split (get-environment-variable "PATH") #\;) - (list)))) - (else - (append - ; Guix - (list (if (get-environment-variable "GUIX_ENVIRONMENT") - (string-append (get-environment-variable "GUIX_ENVIRONMENT") "/lib") - "") - "/run/current-system/profile/lib") - ; Debian - (if (get-environment-variable "LD_LIBRARY_PATH") - (list (string-split (get-environment-variable "LD_LIBRARY_PATH") #\:)) - (list)) - (list - ;;; x86-64 - ; Debian - "/lib/x86_64-linux-gnu" - "/usr/lib/x86_64-linux-gnu" - "/usr/local/lib" - ; Fedora/Alpine - "/usr/lib" - "/usr/lib64" - ;;; aarch64 - ; Debian - "/lib/aarch64-linux-gnu" - "/usr/lib/aarch64-linux-gnu" - "/usr/local/lib" - ; Fedora/Alpine - "/usr/lib" - "/usr/lib64" - )))))) - - (define auto-load-versions (list "")) - - (define-syntax pffi-shared-object-auto-load - (syntax-rules () - ((pffi-shared-object-auto-load headers additional-paths object-name additional-versions) - (cond-expand - (cyclone (pffi-shared-object-load headers)) - (chicken (pffi-shared-object-load headers)) - (gambit (pffi-shared-object-load headers)) - (else - (let* ((paths (append auto-load-paths additional-paths)) - (versions (append auto-load-versions additional-versions)) - (shared-object #f)) - (for-each - (lambda (path) - (for-each - (lambda (version) - (let ((library-path (string-append path - slash - platform-lib-prefix - object-name - platform-file-extension - version))) - (if (file-exists? library-path) - (set! shared-object library-path)))) - versions)) - paths) - (if (not shared-object) - (error "Could not load shared object" - (list (cons 'object object-name) - (cons 'paths paths) - (cons 'platform-file-extension platform-file-extension) - (cons 'versions versions))) - (pffi-shared-object-load headers shared-object)))))))) - - (cond-expand - (kawa (include "kawa.scm")) - (else #t)))) +(import (scheme base)) +(include "main.scm") diff --git a/retropikzel/r7rs-pffi/version/main.scm b/retropikzel/r7rs-pffi/version/main.scm index d0a5241..83f444a 100644 --- a/retropikzel/r7rs-pffi/version/main.scm +++ b/retropikzel/r7rs-pffi/version/main.scm @@ -19,6 +19,7 @@ (scheme file) (scheme process-context) (only (racket base) system-type) + (ffi winapi) (retropikzel r7rs-pffi version racket))) (stklos (import (scheme base) @@ -76,13 +77,18 @@ pffi-pointer-null? pffi-pointer-set! pffi-pointer-get - pffi-pointer-deref) + pffi-pointer-deref + pffi-os-name) (begin #|doc Testing multiline comment |# - + (define pffi-os-name + (cond-expand + (windows "windows") + (racket (if (equal? (system-type 'os) 'windows) "windows" "unix")) + (else "unix"))) (define library-version "v0-3-0") (define slash (cond-expand (windows (string #\\)) (else "/"))) @@ -140,58 +146,58 @@ res))) (define auto-load-paths - (append - (cond-expand - (windows - (append - (if (get-environment-variable "SYSTEM") - (list (get-environment-variable "SYSTEM")) - (list)) - (if (get-environment-variable "WINDIR") - (list (get-environment-variable "WINDIR")) - (list)) - (if (get-environment-variable "WINEDLLDIR0") - (list (get-environment-variable "WINEDLLDIR0")) - (list)) - (if (get-environment-variable "SystemRoot") - (list (string-append - (get-environment-variable "SystemRoot") - slash - "system32")) - (list)) - (list ".") - (if (get-environment-variable "PATH") - (string-split (get-environment-variable "PATH") #\;) - (list)))) - (else - (append - ; Guix - (list (if (get-environment-variable "GUIX_ENVIRONMENT") - (string-append (get-environment-variable "GUIX_ENVIRONMENT") "/lib") - "") - "/run/current-system/profile/lib") - ; Debian - (if (get-environment-variable "LD_LIBRARY_PATH") - (list (string-split (get-environment-variable "LD_LIBRARY_PATH") #\:)) - (list)) - (list - ;;; x86-64 - ; Debian - "/lib/x86_64-linux-gnu" - "/usr/lib/x86_64-linux-gnu" - "/usr/local/lib" - ; Fedora/Alpine - "/usr/lib" - "/usr/lib64" - ;;; aarch64 - ; Debian - "/lib/aarch64-linux-gnu" - "/usr/lib/aarch64-linux-gnu" - "/usr/local/lib" - ; Fedora/Alpine - "/usr/lib" - "/usr/lib64" - )))))) + (if (string=? pffi-os-name "windows") + (append + (if (get-environment-variable "SYSTEM") + (list (get-environment-variable "SYSTEM")) + (list)) + (if (get-environment-variable "WINDIR") + (list (get-environment-variable "WINDIR")) + (list)) + (if (get-environment-variable "WINEDLLDIR0") + (list (get-environment-variable "WINEDLLDIR0")) + (list)) + (if (get-environment-variable "SystemRoot") + (list (string-append + (get-environment-variable "SystemRoot") + slash + "system32")) + (list)) + (list ".") + (if (get-environment-variable "PATH") + (string-split (get-environment-variable "PATH") #\;) + (list)) + (if (get-environment-variable "PWD") + (list (get-environment-variable "PWD")) + (list))) + (append + ; Guix + (list (if (get-environment-variable "GUIX_ENVIRONMENT") + (string-append (get-environment-variable "GUIX_ENVIRONMENT") slash "lib") + "") + "/run/current-system/profile/lib") + ; Debian + (if (get-environment-variable "LD_LIBRARY_PATH") + (list (string-split (get-environment-variable "LD_LIBRARY_PATH") #\:)) + (list)) + (list + ;;; x86-64 + ; Debian + "/lib/x86_64-linux-gnu" + "/usr/lib/x86_64-linux-gnu" + "/usr/local/lib" + ; Fedora/Alpine + "/usr/lib" + "/usr/lib64" + ;;; aarch64 + ; Debian + "/lib/aarch64-linux-gnu" + "/usr/lib/aarch64-linux-gnu" + "/usr/local/lib" + ; Fedora/Alpine + "/usr/lib" + "/usr/lib64" + )))) (define auto-load-versions (list "")) diff --git a/retropikzel/r7rs-pffi/version/racket.rkt b/retropikzel/r7rs-pffi/version/racket.rkt new file mode 100644 index 0000000..8600763 --- /dev/null +++ b/retropikzel/r7rs-pffi/version/racket.rkt @@ -0,0 +1,3 @@ +#lang r7rs +(import (scheme base)) +(include "racket.scm") diff --git a/test-racket-wine b/test-racket-wine new file mode 100755 index 0000000..5775876 --- /dev/null +++ b/test-racket-wine @@ -0,0 +1,6 @@ +#!/usr/bin/env bash +source scripts/init-test.sh + +SCHEME="racket.exe -I r7rs --make -S . --script" + +source scripts/test-runs-dynamic.sh diff --git a/test-racket-wine.sh b/test-racket-wine.sh index 5775876..f711987 100644 --- a/test-racket-wine.sh +++ b/test-racket-wine.sh @@ -1,6 +1,7 @@ #!/usr/bin/env bash source scripts/init-test.sh -SCHEME="racket.exe -I r7rs --make -S . --script" +export WINEPATH=$(winepath ${HOME}/.wine/drive_c/Program\ Files/Racket) +SCHEME="wine64 racket.exe -I r7rs --make -S . --script" source scripts/test-runs-dynamic.sh diff --git a/test-sagittarius-wine.sh b/test-sagittarius-wine.sh index d45dce4..b239ff4 100644 --- a/test-sagittarius-wine.sh +++ b/test-sagittarius-wine.sh @@ -1,6 +1,7 @@ #!/usr/bin/env bash source scripts/init-test.sh -SCHEME="wine sash.exe -c -r7 -L ." +export WINEPATH=$(winepath ${HOME}/.wine/drive_c/Program\ Files/Sagittarius) +SCHEME="wine64 sash.exe -c -r7 -L ." source scripts/test-runs-dynamic.sh diff --git a/test/700_libc.scm b/test/600_libc.scm similarity index 59% rename from test/700_libc.scm rename to test/600_libc.scm index e3881b6..c905878 100644 --- a/test/700_libc.scm +++ b/test/600_libc.scm @@ -4,10 +4,10 @@ (scheme eval) (retropikzel r7rs-pffi version main)) -(define libc (pffi-shared-object-auto-load (list "curl/curl.h") - (list) - "c" - (list ".6"))) +(define libc + (if (string=? pffi-os-name "windows") + (pffi-shared-object-auto-load (list "stdio.h") (list) "ucrtbase" (list "")) + (pffi-shared-object-auto-load (list "stdio.h") (list) "c" (list "" ".6")))) (pffi-define puts libc 'puts 'int (list 'pointer)) diff --git a/test/600_pffi-define.scm b/test/700_pffi-define.scm similarity index 100% rename from test/600_pffi-define.scm rename to test/700_pffi-define.scm