chickadee » scheme2c-compatibility

This page is maintained in the package's github repository.

scheme2c-compatibility

This implements miscellaneous functions and macros that make Chicken more compatible with Scheme->C. Some of this comes from from Jeff Siskind's QobiScheme. Much of this functionality is redundant with that offered by other Chicken eggs but is offered with a Scheme->C-compatible API and naming scheme.

Lists

eleventh xprocedure
twelfth xprocedure

Strings

lines stringprocedure

Combine a list of lines into a string separated by newlines.

unlines lprocedure

Split a string into a list of lines.

words stringprocedure

Split a string into words.

unwords lprocedure

Combine a list of words into a string separated by spaces.

number-of-fields stringprocedure
field-ref string nprocedure
fields stringprocedure

System

usleep microsecondsprocedure
directory-list dprocedure

File IO

read-object-from-file pathnameprocedure
write-object-to-file object pathnameprocedure

Read/write a single scheme object to/from a file. This is not the same as chicken's read-file.

read-text-file pathnameprocedure
write-text-file lines pathnameprocedure

Read/write a text file.

fclose handleprocedure
fopen filename modeprocedure
fmemopen buffer size modeprocedure
popenprocedure
pcloseprocedure

Paths

strip-directory pathnameprocedure
has-extension? pathnameprocedure
extension pathnameprocedure
strip-extension pathnameprocedure
default-extension pathname extensionprocedure
replace-extension pathname extensionprocedure
has-directory? pathnameprocedure
get-directory pathnameprocedure

X11

c-docolordither pic24 w h rdisp gdisp bdisp idisp maplenprocedure
ylookupstring event #!rest optprocedure
xallocnamedcolor3 dpy cmap colornameprocedure
xquerypointer2 dpy wprocedure
getenvprocedure

Temporary files

*tmp*parameter
tmp pathnameprocedure
with-temporary-file prefix fprocedure

Call f with a unique filename that will be removed once f returns. The extension of prefix is honored, but not its base filename.

Bitwise operations

bit-not nprocedure
bit-and nprocedure
bit-or nprocedure
bit-lsh n offsetprocedure
bit-rsh n offsetprocedure

FFI compatibility

Sizeof
c-sizeof-shortprocedure
c-sizeof-intprocedure
c-sizeof-longprocedure
c-sizeof-floatprocedure
c-sizeof-doubleprocedure
c-sizeof-tscpprocedure
c-sizeof-s2cuintprocedure
c-sizeof-pointerprocedure
Memory accesss
c-byte-ref ptr offprocedure
c-byte-set! ptr off valprocedure
c-double-ref ptr offprocedure
c-double-set! ptr off valprocedure
c-float-ref ptr offprocedure
c-float-set! ptr off valprocedure
c-int-ref ptr offprocedure
c-int-set! ptr off valprocedure
c-longint-ref ptr offprocedure
c-longint-set! ptr off valprocedure
c-longunsigned-ref ptr offprocedure
c-longunsigned-set! ptr off valprocedure
c-s2cuint-ref ptr offprocedure
c-s2cuint-set! ptr off valprocedure
c-shortint-ref ptr offprocedure
c-shortint-set! ptr off valprocedure
c-shortunsigned-ref ptr offprocedure
c-shortunsigned-set! ptr off valprocedure
c-unsigned-ref ptr offprocedure
c-unsigned-set! ptr off valprocedure
pointer-pointer-ref ptr-to-ptrprocedure
pointer-pointer-set! ptr-to-ptr valprocedure
c-string->string bufprocedure
c-null-separated-strings->strings c-stringsprocedure

Access buffers containg various standard types. s2cuint is the same size as a pointer.

Arrays
c-array->list array get-element element-size nr-elementsprocedure
c-array->vector array get-element element-size nr-elementsprocedure
c-exact-array->list array element-size nr-elements signed?procedure
c-exact-array->vector array element-size nr-elements signed?procedure
c-inexact-array->list array element-size nr-elements signed?procedure
c-inexact-array->vector array element-size nr-elements signed?procedure
list->c-array array l set-element element-sizeprocedure
list->c-exact-array array l element-size signed?procedure
list->c-inexact-array array l element-size signed?procedure
vector->c-array array v set-element element-sizeprocedure
vector->c-exact-array array v element-size signed?procedure
vector->c-inexact-array array v element-size signed?procedure

Various functions to convert to and from C arrays.

c-sized-int-ptr-ref size signed?procedure
c-sized-int-ptr-set! size signed?procedure
c-sized-inexact-ptr-ref size signed?procedure
c-sized-inexact-ptr-set! size signed?procedure

Return functions which access arrays with elements of given sizes.

Scroped
with-alloc x fprocedure
with-buffer-stream f buffer size modeprocedure
with-c-string str fprocedure
with-file-stream f filename modeprocedure
with-array elements element-size fprocedure
with-c-pointers f vprocedure
with-vector->c-array f set-element element-size vprocedure

Perform many of the operations above automatically cleaning up once the procedure returns.

misc
exact-round xprocedure
exact-ceiling xprocedure
exact-floor xprocedure

Round/floor/ceiling and inexact->exact.

c-valuesyntax
c-sizeofsyntax
c-functionsyntax
mallocprocedure
memcpyprocedure
bzeroprocedure
unsigned-list->unsigneda lprocedure

misc

fuck-upprocedure
panic format-string #!rest &restprocedure
xor a bprocedure
*panic?*parameter
*program*parameter
read-from-string stringprocedure

(read) from a string.

flush-bufferprocedure

flush-output

TODO

with-temporary-file is wrong! It ignores the prefix and more importantly its extension and will lead to breakage.

License

  Copyright 1993-1995 University of Toronto. All rights reserved.
  Copyright 1996 Technion. All rights reserved.
  Copyright 1996 and 1997 University of Vermont. All rights reserved.
  Copyright 1997-2001 NEC Research Institute, Inc. All rights reserved.
  Copyright 2002-2012 Purdue University. All rights reserved.
  Contact Andrei Barbu, andrei@0xab.com.
  This program is free software: you can redistribute it and/or modify
  it under the terms of the GNU Lesser General Public License as published by
  the Free Software Foundation, either version 3 of the License, or
  (at your option) any later version.
  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU Lesser General Public License for more details.
  You should have received a copy of the GNU Lesser General Public License
  along with this program.  If not, see http://www.gnu.org/licenses.

Contents »