merge revisions 11872:11876 from trunk to gsoc2009-sploving branch - license changes
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2009-sploving@11906 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
613d1a1a8d
commit
f2b542d8f4
433 changed files with 1382 additions and 12571 deletions
|
|
@ -1,28 +0,0 @@
|
|||
TOP = ../..
|
||||
SWIG = $(TOP)/../preinst-swig
|
||||
INTERFACE = example.i
|
||||
SRCS =
|
||||
CXXSRCS =
|
||||
TARGET = zlib
|
||||
INCLUDE =
|
||||
SWIGOPT = -I/usr/include
|
||||
CFLAGS =
|
||||
VARIANT =
|
||||
LIBS = -lz
|
||||
VARIANT = _direct
|
||||
|
||||
all:: $(TARGET)
|
||||
|
||||
$(TARGET): $(INTERFACE) $(SRCS)
|
||||
$(MAKE) -f $(TOP)/Makefile \
|
||||
SRCS='$(SRCS)' CXXSRCS='$(CXXSRCS)' \
|
||||
INCLUDE='$(INCLUDE)' SWIGOPT='$(SWIGOPT)' LIBS='$(LIBS)' TARGET='$(TARGET)' \
|
||||
SWIG='$(SWIG)' INTERFACE='$(INTERFACE)' CHICKENOPTS='$(CHICKENOPTS)' chicken$(VARIANT)
|
||||
|
||||
clean::
|
||||
$(MAKE) -f $(TOP)/Makefile chicken_clean
|
||||
rm -f example.scm
|
||||
rm -f $(TARGET)
|
||||
|
||||
check::
|
||||
csi test-zlib.scm
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -1,76 +0,0 @@
|
|||
/* File : example.i */
|
||||
%module example
|
||||
%{
|
||||
/* Put headers and other declarations here */
|
||||
#include "zlib.h"
|
||||
%}
|
||||
|
||||
%include typemaps.i
|
||||
|
||||
%rename(VERSION) ZLIB_VERSION;
|
||||
%rename(z_error) zError;
|
||||
%apply char * { Bytef * };
|
||||
|
||||
/* Allow the sourceLen to be automatically filled in from the length
|
||||
of the 'source' string */
|
||||
%typemap(in) (const Bytef *source, uLong sourceLen)
|
||||
%{ if (!C_swig_is_string ($input)) {
|
||||
swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "Argument $input is not a string");
|
||||
}
|
||||
$2 = (uLong) C_header_size ($input);
|
||||
$1 = C_c_string ($input);
|
||||
%}
|
||||
|
||||
/* Allocate space the size of which is determined by the Scheme
|
||||
integer argument, and make a temporary integer so we can set
|
||||
destLen. */
|
||||
%typemap(in) (Bytef *dest, uLongf *destLen) (uLong len)
|
||||
%{ if (!C_swig_is_fixnum ($input)) {
|
||||
swig_barf (SWIG_BARF1_BAD_ARGUMENT_TYPE, "Argument $input is not a integer");
|
||||
}
|
||||
len = (uLong) C_unfix ($input);
|
||||
$2 = &len;
|
||||
$1 = (char *) malloc (*$2);
|
||||
%}
|
||||
|
||||
/* Return the mutated string as a new object. */
|
||||
%typemap(argout) (Bytef *dest, uLongf *destLen)
|
||||
(C_word *scmstr)
|
||||
%{ scmstr = C_alloc (C_SIZEOF_STRING (*$2));
|
||||
SWIG_APPEND_VALUE(C_string (&scmstr, *$2, $1));
|
||||
free ($1);
|
||||
%}
|
||||
|
||||
%include "zconf.h"
|
||||
%include "zlib.h"
|
||||
|
||||
/* Ignore destLen as an input argument, and make a temporary integer so
|
||||
we can set destLen. */
|
||||
%typemap(numinputs=0) uLongf *destLen (uLong len)
|
||||
"$1 = &len;";
|
||||
|
||||
/* Return a sized string as a new object. */
|
||||
%typemap(argout)
|
||||
(void *outstr, uLongf *destLen) (C_word *scmstr)
|
||||
%{ scmstr = C_alloc (C_SIZEOF_STRING (*$2));
|
||||
SWIG_APPEND_VALUE(C_string (&scmstr, *$2, $1));
|
||||
%}
|
||||
|
||||
%inline %{
|
||||
/* %inline blocks are seen by SWIG and are inserted into the header
|
||||
portion of example_wrap.c, so that they are also seen by the C
|
||||
compiler. */
|
||||
int deflate_init(z_streamp strm, int level) {
|
||||
return deflateInit(strm,level); /* call macro */
|
||||
}
|
||||
int inflate_init(z_streamp strm) {
|
||||
return inflateInit(strm); /* call macro */
|
||||
}
|
||||
void* z_stream_save_next_out(z_streamp strm) {
|
||||
return (void*) strm->next_out;
|
||||
}
|
||||
void z_stream_get_next_chunk(z_streamp strm, void *outstr, uLongf *destLen) {
|
||||
*destLen = strm->next_out - (Bytef*)outstr;
|
||||
}
|
||||
%}
|
||||
|
||||
|
|
@ -1,41 +0,0 @@
|
|||
(load-library 'example "./zlib.so")
|
||||
|
||||
;; Init zstream
|
||||
(define s (new-z-stream))
|
||||
(z-stream-zalloc-set s #f)
|
||||
(z-stream-zfree-set s #f)
|
||||
(z-stream-opaque-set s #f)
|
||||
(deflate-init s (Z-DEFAULT-COMPRESSION))
|
||||
|
||||
;; Deflate something small so we don't need to loop/stream data
|
||||
(define in "some pony et jumping et jack et flash et had a jack pony")
|
||||
(define out (make-string 1000))
|
||||
(printf "to be compressed: ~A~%to be compressed bytes: ~A~%~%" in (string-length in))
|
||||
(z-stream-next-in-set s in)
|
||||
(z-stream-avail-in-set s (string-length in))
|
||||
(z-stream-next-out-set s out)
|
||||
(z-stream-avail-out-set s (string-length out))
|
||||
(let*
|
||||
((saved-out (z-stream-save-next-out s))
|
||||
(ret (deflate s (Z-FINISH))))
|
||||
(cond
|
||||
((= ret (Z-STREAM-END))
|
||||
(printf "deflated properly!~%compressed bytes: ~A~%compressed stream: ~A~%"
|
||||
(z-stream-total-out-get s) (z-stream-get-next-chunk s saved-out)))
|
||||
((= ret (Z-OK))
|
||||
(display "only partial deflation ... not enough output space\n"))
|
||||
(else
|
||||
(printf "deflate error(~D): ~A ~%" ret (z-stream-msg-get s)))))
|
||||
|
||||
;; Use simple compress routine, and set max output size to 100
|
||||
(newline)
|
||||
(call-with-values (lambda () (compress 100 in))
|
||||
(lambda (ret compressed)
|
||||
(cond
|
||||
((= ret (Z-OK))
|
||||
(printf "compressed properly!~%compressed bytes: ~A~%compressed stream: ~A~%"
|
||||
(string-length compressed) compressed))
|
||||
(else
|
||||
(printf "compress error(~D): ~A ~%" ret (z-error ret))))))
|
||||
|
||||
(exit 0)
|
||||
Loading…
Add table
Add a link
Reference in a new issue