[ab] lispbuilder-sdl API changes
Luke J Crook
luke at balooga.com
Wed Dec 13 14:20:01 CST 2006
This is a quick update on how I am currently butchering the
lispbuilder-sdl API's. We have discussed most of these changes on this
list but I am finally getting around to implementing what we discussed.
Here is the summary:
1) Automatic CFFI finalization when foreign objects go out of scope.
2) Making the lispbuilder-sdl API's more lispy (contentious issue)
3) Having three layers of abstraction.
I'll start with (3): I have already implemented the lower two of the
three abstraction layers.
- The lowest tier contains the 'raw' CFFI bindings and
re-implementation of C macros in Lisp. These are contained in the
'lispbuilder-sdl-cffi' package.
- The second tier, 'lispbuilder-sdl-base' contains most of the macros
and functions that have traditionally resided in the 'lispbuilder-sdl'
package in the 0.8 release. For example, WITH-SURFACE, WITH-RECTANGLE,
WITH-EVENTS, BLIT-SURFACE, READ/WRITE-PIXEL etc. The main changes in the
API's at this level (i.e lispbuilder-sdl -> lispbuilder-sdl-base) are
that the new API's accept foreign pointers instead of VECTORs for
rectangles and colors. In addition this layer no longer makes use of the
default global variables, *default-surface*, *default-color* etc. These
must be passed as parameters to the functions. Surprisingly the new API
is very similar to the old API in that the existing examples require
very minor changes to get working. I made these modifications because
the current API was quite inefficient. Vectors were being converted to
and from foreign types and on each call to the CFFI bindings. I noticed
this when I was trying to speed up pixel access for Anthony (blame
Anthony for this change ;) )
- The third tier that I am now working on is CLOS based. It has to be
because of (1) above. More on this later.
For (2): I have manually gone though all the SWIG generated CFFI
bindings in 'lispbuilder-sdl-cffi' and performed a lispification on
almost everything. This means that SDL_BlitSurface is now
sdl-blit-surface. Why, I hear you scream? Well, Emacs automatically
expands (s-b-c to sdl-blit-surface with the C->TAB combination. It's
cool and it really speeds up coding. I haven't gone completely overboard
and wrapped constants in '+', e.g. +blah+ as this I don't like.
For (1): This layer will be entirely CLOS based. This will be the
'lispbuilder-sdl' layer. The CFFI finalization methods require that
foreign objects be wrapped in a class in order to fire the necessary
clean up routines when the Lisp object is garbage collected. The
advantage is that coding using this layer should now be a lot easier as
a lot less messy WITH-* macros are required.
Let me know what you all think.
- Luke
More information about the application-builder
mailing list