[Fribidi-discuss] (Justified?) compilation warning (fwd)

Behdad Esfahbod behdad at bamdad.org
Tue Oct 22 19:13:02 EST 2002


On Sat, 28 Sep 2002, Shachar Shemesh wrote:

> Shachar Shemesh wrote:
> 
> > The actual attached code will come in a little while, in a seperate mail.
> >                Shachar
> 
> Ok, here's the explanation of what's going on here.
> 
> fribidi_utf.h - project's header file.
> This is where both the specific encodings functions and types are 
> declared, and a default is selected. The default is selected based on 
> the value of a macro called "FRIBIDI_CHAR_BYTES". If that is not 
> defined, it is set to 4 (and thus, backwards compatibility is fully 
> maintained).

I don't like the idea too much.  IMHO the FriBidiChar type should 
remain 4 bytes.  We should have different encoding types.

> fribidi_utf.c - The library's source
> In here, the function fribidi_log2vis is defined for one encoding only. 
> You will notice the lack of #ifdef in this file (actually, I cheated a 
> little to print the string's width, by placing a #define that didn't 
> really belong there in the header files. This would not happen in a 
> library that actually does something, however, and the only #ifdef we 
> are expected to see in the real implementation is when actual alogrithm 
> differ between the different widths, probably due to optimizations).
> 
> main.c - A source to an extrenal program that uses fribid.
> This program nicely shows how both the default encoding can be used (and 
> selected based on the default required), as well as non-default 
> encodings used when applicable.
> 
> Makefile - don't you know what that is?
> There are two special tricks performed in this makefile.
> The first is for compiling fribidi_utf.c three times, selecting a 
> different default each time. The three .o files are then merged into a 
> single library.
> The second should not be in fribidi's Makefile, and will probably not be 
> necessary for the using program's Makefile either. It is therefor ok 
> that it is a little patchy. It allows compiling the test program in 
> three flavours. Please notice, however, that all three flavours are 
> linked against the same library.

Nice trick, it's a bit unreadible at first, but I like it.  But I 
really don't know how to merge it with fribidi's current 
codebase.

> In order to build the three test programs, run "make main8", "make 
> main16" and "make main32". You will get three programs with apropriate 
> names.
> 
> Notice that no conversions were used throughout the sources, static 
> typing is kept whether you use the default or override it. A program 
> that needs the default most of the time but occasionally needs a 
> different encoding will still get a warning if the wrong function is 
> called by mistake. The entire thing compiles without a single warning.
> 
>                 Shachar

In the meanwhile, I have thought more about the idea of writing 
fribidi's engine independent of char size, I have started the 
conversion, but it really needs work...

BTW, I'm also reading "Thinking in Patterns, in Java", by Bruce 
Eckel.  I hope I can finally find a reasonable solution for the 
fribidi api design..

So, in the mean time, you start with your hacks for the 
interface, and I will hack the engine, we will merge in a few 
weeks.  No problem that I will reinvent the API myself after a 
month or two...

-- 
Behdad Esfahbod		1 Aban 1381, 2002 Oct 23 
http://behdad.org/	[Finger for Geek Code]

#define is_persian_leap(y) ((((y)-474)%2820+2820)%2820*31%128<31)







More information about the FriBidi mailing list