FriBidiEnv (was: Re: [Fribidi-discuss] Starting to work on EPOC 6 port of FriBidi)

Omer Zak omerz at actcom.co.il
Sat Jan 19 07:04:03 EST 2002


Hello Behdad,
Okay.

1. I suggest that any function, which needs the FriBidiEnv, first validate
   it by a macro call:

   FriBidiResult fribidi_do_something(FriBidiEnv *env, s, s_len,...)
   {
     VALIDATE_FRIBIDIENV(env);
     do_other_stuff("TM");
     return((FriBidiResult) "Great FriBidiResult (TM)");
   }

   The VALIDATE_FRIBIDIENV(env) macro will be defined by a configuration
   option and it can be one of the following (other variations are welcome):

   1. #define VALIDATE_FRIBIDIENV(env) \
           if (env == NULL) env = &fribidi_global_env
   2. #define VALIDATE_FRIBIDIENV(env)  if (env == NULL) Panic()
               /* (for environments, which disallow global variables). */
   3. #define VALIDATE_FRIBIDIENV(env)
               /* Null definition, for environments, which guarantee valid
               ** environments, and need the efficiency.
               */

2. About API names - for now, I assume that not too many projects are
   bound to the interface used by version 0.10.0, so let's use the same
   flag for the interface with implicit strlen()'s and for NULL
   FriBidiEnvs.

3. From what I saw in FriBidi code, it needs to malloc and free memory
   chunks of various sizes.  How can this be managed?

                                             --- Omer
WARNING TO SPAMMERS:  see at http://www.zak.co.il/spamwarning.html


On Tue, 15 Jan 2002, Behdad Esfahbod wrote:

> Ok, I will work on this when I have enough time.
> 
> And about the interface, to support interface version 2, we will have 
> these (ignore the symbol names, just the idea, we should discuss 
> about the new api names too):
> 
> in fribidi_compat.h:
> 
> extern FriBidiEnv fribidi_global_env;
> 
> #define fribidi_log2vis(a, b, c, d)	\
> 	new_fribidi_log2vis(&fribidi_global_env, a, b, c, d)
> #define fribidi_set_mirroring(m)	\
> 	fribidi_set_flag(&fribidi_global_env, FRIBIDI_FLAG_MIRRORING)
> ...
> 
> and in fribidi_compat.c:
> 
> FriBidiEnv fribidi_global_env = { default values};
> 
> --------------
> 
> This way all the old api work, when one do not need the compatibility
> (or needs no global var...), removes compat stuff through a configure
> time option.
> 
> Yours,
> behdad
> 
> On Sun, 6 Jan 2002, Omer Zak wrote:
> [snip] 
> > Okay, let's define the following structure:
> > 
> > struct FriBidiEnv {
> >   FriBidiList* iUsedListItems;  // Pointer to linked list of used list
> >                                 // items.
> >   FriBidiList* iFreeListItems;  // Pointer to linked list of free list
> >                                 // items.  Allocation requests are
> >                                 // satisfied first from this list, then
> >                                 // from regular malloc().
> >   // The FriBidiList structure will either have an extra pointer for
> >   // memory management support, or else we'll use existing pointers
> >   // for this purpose.
> >   // TO BE CHECKED:  if we allocate and free only one data structure
> >   //                 or more than one different data structures.
> >   //                 This affects handling the above lists.
> >   FriBidiFlags iFlags;
> >   // The flags will define:
> >   // - Debug mode
> >   // - Mirroring
> >   // - L3 rule on/off
> >   // - remove BiDi marks on/off
> >   // - Arabic joining on/off
> >   // - Ligaturing on/off
> >   // They will be set and cleared by inlined access procedures.
> > };
> > 
> > In addition, let's replace all malloc() and free() calls by
> > fribidi_malloc() and fribidi_free() calls.  For now, they'll be #define'd
> > to be the same as malloc() and free().  But next version we'll add the
> > environment parameter.





More information about the FriBidi mailing list