Peter Seibel wrote:
> I see. The other issue--and the reason I happened to ask about it 
> today--is it'd be a bit easier to grok the code base if I could tell 
> which bits were completely machine generated versus hand written versus 
> machine generated and hand hacked. If you happen to get bored sometime 
> and wanted to make up a list of which are which, I'd be happy to put 
> comments in the files to help out the next guy to come along.

The general rule of thumb for the lispbuilder-sdl* libraries is that
everything in the /cffi/ directory was first generated by SWIG and then
lispified by hand. I don't believe that there is single file in any of
the cffi/ directories that is still SWIG-raw. Helpful? ;)

cffi/ : The raw, SWIG-generated, and then manually modified CFFI
bindings. At the most helper CFFI translation functions may be defined
to convert Lisp strings to C strings and back, but that's about it (see
cffi-translate.lisp). Otherwise all functions in cffi/ accept and return
foreign objects only.

base/ : A thin wrapper over the functions in cffi/ . The functions in
base/ will take keyword arguments where appropriate, accept NIL instead
of CFFI:NULL-POINTER etc. Otherwise functions accept and return foreign
objects. There may be some checking of types (IS-VALID-PTR SURFACE) but
this layer is meant to be lean. Someone who implements a graphics engine
might use this layer instead of sdl/ if speed is a concern. The
WITH-EVENTS macro is defined in base/ . There are no fancy drawing
primitives in this layer.

sdl/ : The Lisp wrapper over cffi/ and base/. Foreign objects are passed
around neatly wrapped in CLOS objects, using TRIVIAL-GARBAGE for
automatic garbage collection (minimize foreign objects being left on the
heap). There are no functions in sdl/ that accept or return foreign
objects (with the exception of the few functions that create the CLOS
wrapper objects - crosses fingers) Functions in sdl/ call down into
base/ or cffi/ as appropriate. All lispbuilder-sdl symbols available in
SDL: are exported from sdl/ , with symbols imported into sdl/ from cffi/
and base/ as appropriate (e.g. WITH-EVENTS). All drawing primitives are
defined in this layer; circles, rectangles, lines, triangles,
with-bezier etc. Functions in sdl/ implement a lot of type checking.

One example of the difference between base/ and sdl/ is that the
WITH-RECTANGLE macro in base/ will create and destroy a foreign
SDL_Rect. While the WITH-RECTANGLE macro in sdl/ will create and destroy
a CLOS RECTANGLE object.

The only package that has a base/ thus far is lispbuilder-sdl. The other
 packages, like sdl-image, sdl-ttf, sdl-mixer and sdl-gfx are supposed
to sit on top of lispbuilder-sdl. So functions in sdl-image, for example
will create and return SURFACE objects.

I hope this gives you a 10,000 foot view of how the packages are organized.

- Luke
_______________________________________________
application-builder mailing list
[email protected]
http://www.lispniks.com/mailman/listinfo/application-builder

Reply via email to