5 Miscellaneous Support
(regexp-replaces objname substs) → string? |
A function that is convenient for many interfaces where the foreign library has some naming convention that you want to use in your interface as well. The objname argument can be any value that will be used to name the foreign object; it is first converted into a string, and then modified according to the given substs list in sequence, where each element in this list is a list of a regular expression and a substitution string. Usually, regexp-replace* is used to perform the substitution, except for cases where the regular expression begins with a ^ or ends with a $, in which case regexp-replace is used.
For example, the following makes it convenient to define Scheme bindings such as foo-bar for foreign names like MyLib_foo_bar:
(define-syntax defmyobj |
(syntax-rules (:) |
(define name |
(regexp-replaces 'name '((#rx"-" "_") |
(#rx"^" "MyLib_"))) |
(list->cblock lst type) → any |
lst : list> |
type : ctype? |
Allocates a memory block of an appropriate size, and initializes it using values from lst and the given type. The lst must hold values that can all be converted to C values according to the given type.
(vector->cblock vector type) → any |
vector : any/c |
type : type? |
Like list->cblock, but for Scheme vectors.
5.1 Unsafe Miscellaneous Operations
(cblock->list cblock type length) → list? |
cblock : any/c |
type : ctype? |
length : nonnegative-exact-integer? |
Converts C cblock, which is a vector of types, to a Scheme list. The arguments are the same as in the list->cblock. The length must be specified because there is no way to know where the block ends.
(cblock->vector cblock type length) → vector? |
cblock : any/c |
type : ctype? |
length : nonnegative-exact-integer? |
Like cblock->vector, but for Scheme vectors.