update swig on windows
This commit is contained in:
18
winx64/bin/swigwin-4.0.0/Examples/guile/port/Makefile
Normal file
18
winx64/bin/swigwin-4.0.0/Examples/guile/port/Makefile
Normal file
@@ -0,0 +1,18 @@
|
||||
TOP = ../..
|
||||
SWIGEXE = $(TOP)/../swig
|
||||
SWIG_LIB_DIR = $(TOP)/../$(TOP_BUILDDIR_TO_TOP_SRCDIR)Lib
|
||||
SRCS = example.c
|
||||
TARGET = my-guile
|
||||
INTERFACE = example.i
|
||||
|
||||
check: build
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' guile_augmented_run
|
||||
|
||||
build:
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' SRCS='$(SRCS)' \
|
||||
SWIG_LIB_DIR='$(SWIG_LIB_DIR)' SWIGEXE='$(SWIGEXE)' \
|
||||
TARGET='$(TARGET)' INTERFACE='$(INTERFACE)' guile_augmented
|
||||
|
||||
clean:
|
||||
$(MAKE) -f $(TOP)/Makefile SRCDIR='$(SRCDIR)' TARGET='$(TARGET)' guile_clean
|
||||
rm -f test.out
|
||||
2
winx64/bin/swigwin-4.0.0/Examples/guile/port/README
Normal file
2
winx64/bin/swigwin-4.0.0/Examples/guile/port/README
Normal file
@@ -0,0 +1,2 @@
|
||||
This example illustrates the translation from Scheme file ports to
|
||||
temporary FILE streams. Read the source and run ./my-guile -s runme.scm
|
||||
18
winx64/bin/swigwin-4.0.0/Examples/guile/port/example.c
Normal file
18
winx64/bin/swigwin-4.0.0/Examples/guile/port/example.c
Normal file
@@ -0,0 +1,18 @@
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
|
||||
void print_int(FILE *f, int i)
|
||||
{
|
||||
if (fprintf(f, "%d\n", i)<0)
|
||||
perror("print_int");
|
||||
}
|
||||
|
||||
int read_int(FILE *f)
|
||||
{
|
||||
int i;
|
||||
if (fscanf(f, "%d", &i)!=1) {
|
||||
fprintf(stderr, "read_int: error reading from file\n");
|
||||
perror("read_int");
|
||||
}
|
||||
return i;
|
||||
}
|
||||
15
winx64/bin/swigwin-4.0.0/Examples/guile/port/example.i
Normal file
15
winx64/bin/swigwin-4.0.0/Examples/guile/port/example.i
Normal file
@@ -0,0 +1,15 @@
|
||||
%module port
|
||||
|
||||
%include guilemain.i
|
||||
|
||||
/* Include the required FILE * typemaps */
|
||||
%include ports.i
|
||||
|
||||
%{
|
||||
#include <stdio.h>
|
||||
%}
|
||||
|
||||
%inline %{
|
||||
void print_int(FILE *f, int i);
|
||||
int read_int(FILE *f);
|
||||
%}
|
||||
35
winx64/bin/swigwin-4.0.0/Examples/guile/port/runme.scm
Normal file
35
winx64/bin/swigwin-4.0.0/Examples/guile/port/runme.scm
Normal file
@@ -0,0 +1,35 @@
|
||||
;; Call with standard output
|
||||
(print-int (current-output-port) 314159)
|
||||
|
||||
;; Redirection to a file. Note that the port is automatically flushed
|
||||
;; (via force-output) before calling the C function, and that the C
|
||||
;; function gets a temporary "FILE" stream, which is closed after the
|
||||
;; call. So you can simply mix Scheme and C output.
|
||||
(with-output-to-file "test.out"
|
||||
(lambda ()
|
||||
(display 4711)
|
||||
(newline)
|
||||
(print-int (current-output-port) 314159)
|
||||
(display 815)
|
||||
(newline)))
|
||||
|
||||
;; Redirection to a string or soft port won't work --
|
||||
;; we can only handle file ports.
|
||||
(catch #t
|
||||
(lambda ()
|
||||
(with-output-to-string
|
||||
(lambda ()
|
||||
(print-int (current-output-port) 314159))))
|
||||
(lambda args
|
||||
(display "Below shows that attempting to write to a string or soft port will result in a wrong-type-error...")
|
||||
(newline)
|
||||
(write args) (newline)))
|
||||
|
||||
;; Read from a file port. Note that it is a bad idea to mix Scheme and
|
||||
;; C input because of buffering, hence the call to seek to rewind the file.
|
||||
(with-input-from-file "test.out"
|
||||
(lambda ()
|
||||
(seek (current-input-port) 0 SEEK_SET)
|
||||
(display (read-int (current-input-port)))
|
||||
(newline)))
|
||||
|
||||
Reference in New Issue
Block a user