Rudi Schlatte <[EMAIL PROTECTED]> writes: > > - Provide wrapper objects for each foreign resource that is visible > in Lisp, so that it can be inspected, have methods defined etc. > - For non-memory foreign resources, or when the Lisp object is tiny > and the foreign memory consumption huge, provide explicit close and > with-foo functionality
Add exception handling; we need this all over the place. For the first point, there are several SDL structures that I have specifically pushed down into the lower CFFI layer so as NOT to be visible. SDL_Event, SDL_Rectangle and SDL_Color are allocated/deallocated automatically using the CFFI translation functions. On the Lisp side, these are represented as Vectors. In the random-rects examples, new SDL_Rectangle structures are allocated/ deallocated several hundred times per second (depending on the CPU and GPU capabilities of the host machine). I would add to the second point to state that WITH-FOO functionality should be added when hundreds of a particualar foreign resource may allocated/deallocated every second. In lispbuilder-sdl-gfx and lispbuilder-sdl-ttf, we need wrapper objects to handle the memory management for the font data. In lispbuilder-sdl the following SDL structures need to be managed (hopefully this is a somewhat complete list): SDL_Surface, SDL_RWops, SDL_Cursor and SDL_Overlay need wrapper objects. We have several with-surface macros to manage SDL_Surface structures, but these can be short-circuited so as to not deallocate the SDL_Surface upon exit. SDL_RWops structure can become very large and are not handled well at all, apart from the few functions in lispbuilder-sdl-image. SDL_PixelFormat and SDL_Palette probably need wrapper objects. SDL_VideoInfo may need a wrapper object, but seems to be handled quite well by GET-VIDEO-INFO. (Although I see that the SDL_VideoInfo structure is not deallocated by this function. Need to fix this.) SDL_Event I don't think needs a wrapper object. It is completely hidden by the sdl:with-events macro. SDL_SysWMinfo could probably use a wrapper object. It is handled somewhat by the function GET-NATIVE-WINDOW. This leaves the following structures that are not handled by the lispbuilder- sdl wrappers at all (I'm guessing some kind of wrapper objects are required here): - SDL_AudioSpec and SDL_AudioCVT: No work has been done on the lispbuilder- sdl audio side, so I would not be surprised if SDL audio crashed. - Same with SDL_CD and SDL_CDTrack. - Luke _______________________________________________ application-builder mailing list [email protected] http://www.lispniks.com/mailman/listinfo/application-builder
