[Fribidi-discuss] Implementing away (stop me if you can, HAHAHAHAHA)

Shachar Shemesh fribidi-discuss at sun.consumer.org.il
Mon Oct 21 10:27:06 EST 2002


There's an old saying in the open source world:
"If noone else will do it, do it yourself".

I am now officially working on adding my Makefile tricks into the layers 
upon layers of auto* generations used by fribidi. If anyone wishes to 
help me out (this is the only project I know of that uses four different 
auto* tools - are they all REALLY necessary? Why isn't autoconf enough 
for us, just like everybody else?), I would much apretiate it. If not, 
RTFM is your friend.

            Shachar


Shachar Shemesh wrote:

> Hey everyone, and Behdad (without trying to claim that Behdad is not 
> part of everyone, of course).
>
> I was wondering whether you had time to look at my proposed way, and 
> whether there were any comments. I would like to get this ball 
> rolling, at least to the point where there is some sort of UTF-16 
> support in a released package (so I can get the patches into Wine).
>
> If noone has any objections, I can try and work on fribidi patches 
> that will incorporate this approach.
>
>                Shachar
>
>
> 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).
>>
>> 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.
>>
>> 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
>>
>> ------------------------------------------------------------------------
>>
>> #include <stdio.h>
>> #include <stdlib.h>
>>
>> #include "fribidi_utf.h"
>>
>>
>> int fribidi_log2vis(fribidi_chartype *str, int nextpar)
>> {
>>     return printf(NUM_BYTES_STR" %d\n", nextpar );
>> }
>>
>>  
>>
>> ------------------------------------------------------------------------
>>
>> #ifndef FRIBIDI_CHAR_BYTES
>> #define FRIBIDI_CHAR_BYTES 4 /* Or whatever we think should be the 
>> default encoding */
>> #endif
>>
>> typedef char fribidi_chartype1;
>> typedef short fribidi_chartype2;
>> typedef long fribidi_chartype4;
>>
>> int fribidi_log2vis4( fribidi_chartype4 *str, int nextpar );
>> int fribidi_log2vis2( fribidi_chartype2 *str, int nextpar );
>> int fribidi_log2vis1( fribidi_chartype1 *str, int nextpar );
>>
>> #if FRIBIDI_CHAR_BYTES==4
>>
>> typedef fribidi_chartype4 fribidi_chartype;
>> #define fribidi_log2vis fribidi_log2vis4
>> #define NUM_BYTES_STR "4"
>>
>> #elif FRIBIDI_CHAR_BYTES==2
>>
>> typedef fribidi_chartype2 fribidi_chartype;
>> #define fribidi_log2vis fribidi_log2vis2
>> #define NUM_BYTES_STR "2"
>>
>> #else
>>
>> typedef fribidi_chartype1 fribidi_chartype;
>> #define fribidi_log2vis fribidi_log2vis1
>> #define NUM_BYTES_STR "1"
>>
>> #endif
>>
>>  
>>
>> ------------------------------------------------------------------------
>>
>> #include "fribidi_utf.h"
>>
>> int main()
>> {
>>     fribidi_chartype str0[]={'H','e','l','l','o','\0'};
>>     fribidi_chartype1 str1[]={'H','e','l','l','o','\0'};
>>     fribidi_chartype2 str2[]={'H','e','l','l','o','\0'};
>>     fribidi_chartype4 str4[]={'H','e','l','l','o','\0'};
>>     
>>     fribidi_log2vis(str0, 0);
>>     fribidi_log2vis1(str1, 1);
>>     fribidi_log2vis2(str2, 2);
>>     fribidi_log2vis4(str4, 4);
>>
>>     return 0;
>> }
>>  
>>
>
>
>
> -------------------------------------------------------
> This sf.net email is sponsored by:ThinkGeek
> Welcome to geek heaven.
> http://thinkgeek.com/sf
> _______________________________________________
> Fribidi-discuss mailing list
> Fribidi-discuss at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/fribidi-discuss






More information about the FriBidi mailing list