Outdated egg!
This is an egg for CHICKEN 4, the unsupported old release. You're almost certainly looking for the CHICKEN 5 version of this egg, if it exists.
If it does not exist, there may be equivalent functionality provided by another egg; have a look at the egg index. Otherwise, please consider porting this egg to the current version of CHICKEN.
inline
Description
Allows compiled C inside interpreter scripts.
Author
Requirements
Documentation
This extension library provides a simple macro for using C code in the Chicken interpreter (csi). The program text is embedded into a thin Scheme wrapper and compiled on the fly into a dynamically loadable library. A local directory caches the compiled code and subsequent definitions of the same source text will load the already compiled library from the cache.
Callbacks back into Scheme are not supported.
- (inline STRING [OPTIONS])syntax
Expands into a call of inline-compile and compiles the code given in STRING. If encountered in compiled code, then this form will directly expand into a (bind* ...) form, effectively embedding the inline code in the compiled file (so no run-time compilation is needed). The optional string argument OPTIONS may contain additional compilation parameters (these are ignored, when inline is used in compiled code).
(inline "int foo(int n) { return(n * 2); }") ==> (inline-compile "int foo(int n) { return(n * 2); }") ; when interpreted ==> (bind* ; when compiled "int foo(int n) { return(n * 2); }")
- inline-compile STRING #!optional OPTIONSprocedure
Compiles the C source code in STRING dynamically. If a compiled library with the same source text is currently loaded (and has been cached), then nothing is done. If it is not loaded, the inline cache is consulted, whether a compiled file for the same text is stored, and, if it is, it's loaded and the procedure is returned. If no such file exists, the compiler (``csc'') is invoked to create a compiled library (with any extra options passed in OPTIONS), which is stored in the cache. The code will be compiled as if wrapped in #>! ... <#. Note that you will have to shield #include forms, if you don't want them to be processed by the FFI parser:
(inline #<<EOF #ifndef CHICKEN #include "gd.h" #include <stdio.h> #endif void genimages(int w, int h) { gdImagePtr im; FILE *pngout, *jpegout; int black; int white; im = gdImageCreate(w, h); black = gdImageColorAllocate(im, 0, 0, 0); white = gdImageColorAllocate(im, 255, 255, 255); gdImageLine(im, 0, 0, w - 1, h - 1, white); pngout = fopen("test.png", "wb"); jpegout = fopen("test.jpg", "wb"); gdImagePng(im, pngout); gdImageJpeg(im, jpegout, -1); fclose(pngout); fclose(jpegout); gdImageDestroy(im); } EOF "-L -lgd -L -lpng -L -lz -L -ljpeg -L -lfreetype" ) (genimages 64 64)
- inline-cacheparameter
Holds the name of the directory which is used as a cache for compiled code and defaults to ./.cache.
Changelog
- 1.9 use simple-sha1 instead of md5 to reduce number of dependencies
- 1.7 md5-digest use replaced [Kon Lovett]
- 1.6 ported to CHICKEN 4 [felix]
- 1.5 Fixed dependencies on new easyffi egg
- 1.4 Fixed dependency on utils unit [Thanks to Benedikt Rosenau]
- 1.3 inline-support wasn't installed properly [Thanks to Peter Wang]
- 1.2 Adapted to new setup scheme
- 1.1 Now uses easyffi stuff, which is much simpler and more powerful. Does the right thing when compiled.
- 1.0 Initial release
License
Copyright (c) 2003-2007, Felix L. Winkelmann All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.