On Thu, 2 Nov 2000, Lee Brown wrote:
> To anybody:
>
> One problem I had with extensions is that it didn't have
> a way of loading the extension dynamically. In other words,
> I have this:
>
> fnt_font_t fntInitFTFont(FT_Face ftface)
> {
> /* some code using freetype */
> }
>
> fnt_font_t fntInitXFont(XFont xfont)
> {
> /* some code using X */
> }
>
> Which makes the whole library depend on Freetype and X
Right. You should be using multiple targets for this.
> I want :
>
> struct {
> fnt_font_t (*init_ft_font)(FT_Face ftface);
> fnt_font_t (*init_x_font)(XFont xfont);
> } fnt_api;
>
> #define fntInitFTFont(ftface) fnt_api->init_ft_font(ftface)
> #define fntInitXFont(xfont) fnt_api->init_x_font(xfont)
No you don't. You want to use opaque, platform-independent
handles and types at the API level and deal with gluing that to X fonts or
FreeType fonts or console fonts or whatever.
> This way the user can still use the extension even if he doesn't have
> both X and Freetype. With the other extensions this isn't a problem because
> they only have one library they depend on ( either libart or libxmi )
That's because both(? I only know about LibXMI) haven't yet had
any targets other than the stubs target (uses only LibGGI functions)
written for them yet. They won't stay that way forever, and then we will
have to encapsulate the target-specific API functions and data types
inside of the target code.
> so if
> the user doesn't have that library then they simply don't use the extension.
No. Extensions have targets too, just like LibGGI itself. Look
at the 'misc' target in degas/lib/libggi/extensions to see an example of
how to write an extension target which works with the equivalent LibGGI
targets.
> But
> if an extension brings one api to multiple libraries then the user is stuck with
> all or nothing.
Unless you use targets.
> Does this make sense? I am (now) convinced that the extension concept is a
> good one maybe it can be taken further so that not only are the functions
> attached to the visual are loaded dynamically, but the other functions as well.
Yes, that is what targets are for.
Jon
---
'Cloning and the reprogramming of DNA is the first serious step in
becoming one with God.'
- Scientist G. Richard Seed