Skip to content

Commit

Permalink
We need bidi_types all over the place (in joining, in shaping, ...), so
Browse files Browse the repository at this point in the history
make them mandatory.  As a consequence, many of our functions don't need str
anymore:  they just need this bidi_types.
  • Loading branch information
behdad committed Jun 21, 2004
1 parent b1a9af5 commit 597b12b
Show file tree
Hide file tree
Showing 10 changed files with 104 additions and 108 deletions.
8 changes: 3 additions & 5 deletions lib/bidi-types.h
@@ -1,10 +1,10 @@
/* FriBidi
* bidi-types.h - define internal bidi types
*
* $Id: bidi-types.h,v 1.5 2004-06-14 17:00:33 behdad Exp $
* $Id: bidi-types.h,v 1.6 2004-06-21 18:49:23 behdad Exp $
* $Author: behdad $
* $Date: 2004-06-14 17:00:33 $
* $Revision: 1.5 $
* $Date: 2004-06-21 18:49:23 $
* $Revision: 1.6 $
* $Source: /home/behdad/src/fdo/fribidi/togit/git/../fribidi/fribidi2/lib/bidi-types.h,v $
*
* Author:
Expand Down Expand Up @@ -53,8 +53,6 @@ fribidi_char_from_bidi_type (

#endif /* DEBUG */

#define BIDI_TYPE(i) (bidi_types ? bidi_types[(i)] : fribidi_get_bidi_type(str[(i)]))

#include <fribidi-enddecls.h>

#endif /* !_BIDI_TYPES_H */
Expand Down
11 changes: 8 additions & 3 deletions lib/common.h
@@ -1,10 +1,10 @@
/* FriBidi
* common.h - common include for library sources
*
* $Id: common.h,v 1.14 2004-06-15 11:52:02 behdad Exp $
* $Id: common.h,v 1.15 2004-06-21 18:49:23 behdad Exp $
* $Author: behdad $
* $Date: 2004-06-15 11:52:02 $
* $Revision: 1.14 $
* $Date: 2004-06-21 18:49:23 $
* $Revision: 1.15 $
* $Source: /home/behdad/src/fdo/fribidi/togit/git/../fribidi/fribidi2/lib/common.h,v $
*
* Author:
Expand Down Expand Up @@ -166,6 +166,11 @@
# define _GNU_SOURCE
#endif /* !_GNU_SOURCE */

/* We respect our own rules. */
#define FRIBIDI_STRICT 1
#undef FRIBIDI_COMPAT


#include "debug.h"

#endif /* !_COMMON_H */
Expand Down
14 changes: 9 additions & 5 deletions lib/fribidi-bidi-types.h
@@ -1,10 +1,10 @@
/* FriBidi
* fribidi-bidi-types.h - character bidi types
*
* $Id: fribidi-bidi-types.h,v 1.12 2004-06-18 19:21:33 behdad Exp $
* $Id: fribidi-bidi-types.h,v 1.13 2004-06-21 18:49:23 behdad Exp $
* $Author: behdad $
* $Date: 2004-06-18 19:21:33 $
* $Revision: 1.12 $
* $Date: 2004-06-21 18:49:23 $
* $Revision: 1.13 $
* $Source: /home/behdad/src/fdo/fribidi/togit/git/../fribidi/fribidi2/lib/fribidi-bidi-types.h,v $
*
* Author:
Expand Down Expand Up @@ -224,16 +224,20 @@ typedef fribidi_uint32 FriBidiParType;

#endif

/* For lazy people... */
/* Please don't use these two type names, use FRIBIDI_PAR_* form instead. */
#define FRIBIDI_TYPE_WLTR FRIBIDI_PAR_WLTR
#define FRIBIDI_TYPE_WL FRIBIDI_PAR_WLTR
#define FRIBIDI_TYPE_WRTL FRIBIDI_PAR_WRTL

/* These are here just for lazy people. */
#if !FRIBIDI_STRICT
#define FRIBIDI_TYPE_WL FRIBIDI_PAR_WLTR
#define FRIBIDI_TYPE_WR FRIBIDI_PAR_WRTL
#define FRIBIDI_TYPE_L FRIBIDI_PAR_LTR
#define FRIBIDI_TYPE_R FRIBIDI_PAR_RTL
#define FRIBIDI_TYPE_N FRIBIDI_PAR_ON
#define FRIBIDI_TYPE_B FRIBIDI_TYPE_BS
#define FRIBIDI_TYPE_S FRIBIDI_TYPE_SS
#endif /* !FRIBIDI_STRICT */


/*
Expand Down
55 changes: 24 additions & 31 deletions lib/fribidi-bidi.c
@@ -1,10 +1,10 @@
/* FriBidi
* fribidi-bidi.c - bidirectional algorithm
*
* $Id: fribidi-bidi.c,v 1.16 2004-06-21 16:15:27 behdad Exp $
* $Id: fribidi-bidi.c,v 1.17 2004-06-21 18:49:23 behdad Exp $
* $Author: behdad $
* $Date: 2004-06-21 16:15:27 $
* $Revision: 1.16 $
* $Date: 2004-06-21 18:49:23 $
* $Revision: 1.17 $
* $Source: /home/behdad/src/fdo/fribidi/togit/git/../fribidi/fribidi2/lib/fribidi-bidi.c,v $
*
* Authors:
Expand Down Expand Up @@ -198,18 +198,17 @@ print_resolved_types (
static void
print_bidi_string (
/* input */
const FriBidiChar *str,
const FriBidiStrIndex len,
const FriBidiCharType *bidi_types
const FriBidiCharType *bidi_types,
const FriBidiStrIndex len
)
{
register FriBidiStrIndex i;

fribidi_assert (str || bidi_types);
fribidi_assert (bidi_types);

MSG (" Org. types : ");
for (i = 0; i < len; i++)
MSG2 ("%c", fribidi_char_from_bidi_type (BIDI_TYPE (i)));
MSG2 ("%c", fribidi_char_from_bidi_type (bidi_types[i]));
MSG ("\n");
}
#endif /* DEBUG */
Expand Down Expand Up @@ -308,18 +307,17 @@ print_bidi_string (
FRIBIDI_ENTRY FriBidiParType
fribidi_get_par_direction (
/* input */
const FriBidiChar *str,
const FriBidiStrIndex len,
const FriBidiCharType *bidi_types
const FriBidiCharType *bidi_types,
const FriBidiStrIndex len
)
{
register FriBidiStrIndex i;

fribidi_assert (str || bidi_types);
fribidi_assert (bidi_types);

for (i = 0; i < len; i++)
if (FRIBIDI_IS_LETTER (BIDI_TYPE (i)))
return FRIBIDI_IS_RTL (BIDI_TYPE (i)) ? FRIBIDI_PAR_RTL :
if (FRIBIDI_IS_LETTER (bidi_types[i]))
return FRIBIDI_IS_RTL (bidi_types[i]) ? FRIBIDI_PAR_RTL :
FRIBIDI_PAR_LTR;

return FRIBIDI_PAR_ON;
Expand All @@ -328,9 +326,8 @@ fribidi_get_par_direction (
FRIBIDI_ENTRY FriBidiLevel
fribidi_get_par_embedding_levels (
/* input */
const FriBidiChar *str,
const FriBidiStrIndex len,
const FriBidiCharType *bidi_types,
const FriBidiStrIndex len,
/* input and output */
FriBidiParType *pbase_dir,
/* output */
Expand All @@ -349,16 +346,16 @@ fribidi_get_par_embedding_levels (
goto out;
}

DBG ("entering fribidi_get_par_embedding_levels");
DBG ("in fribidi_get_par_embedding_levels");

fribidi_assert (str || bidi_types);
fribidi_assert (bidi_types);
fribidi_assert (pbase_dir);
fribidi_assert (embedding_levels);

/* Determinate character types */
{
/* Get run-length encoded character types */
main_run_list = run_list_encode_bidi_types (str, len, bidi_types);
main_run_list = run_list_encode_bidi_types (bidi_types, len);
if UNLIKELY
(!main_run_list) goto out;
}
Expand Down Expand Up @@ -512,7 +509,7 @@ fribidi_get_par_embedding_levels (
(fribidi_debug_status ())
{
print_types_re (main_run_list);
print_bidi_string (str, len, bidi_types);
print_bidi_string (bidi_types, len);
print_resolved_levels (main_run_list);
print_resolved_types (main_run_list);
}
Expand Down Expand Up @@ -716,7 +713,7 @@ fribidi_get_par_embedding_levels (
if UNLIKELY
(fribidi_debug_status ())
{
print_bidi_string (str, len, bidi_types);
print_bidi_string (bidi_types, len);
print_resolved_levels (main_run_list);
print_resolved_types (main_run_list);
}
Expand Down Expand Up @@ -772,7 +769,7 @@ fribidi_get_par_embedding_levels (
{
/* close up the open link at the end */
if (j >= 0)
char_type = BIDI_TYPE (j);
char_type = bidi_types[j];
else
char_type = FRIBIDI_TYPE_ON;
if (!state && FRIBIDI_IS_SEPARATOR (char_type))
Expand Down Expand Up @@ -877,11 +874,10 @@ index_array_reverse (

FRIBIDI_ENTRY FriBidiLevel
fribidi_reorder_line (
const FriBidiChar *str,
/* input */
const FriBidiCharType *bidi_types,
const FriBidiStrIndex len,
const FriBidiStrIndex off,
const FriBidiCharType *bidi_types,
const FriBidiParType base_dir,
/* input and output */
FriBidiLevel *embedding_levels,
Expand Down Expand Up @@ -915,20 +911,17 @@ fribidi_reorder_line (

DBG ("in fribidi_reorder_line");

fribidi_assert (str || visual_str || bidi_types);
fribidi_assert (bidi_types);
fribidi_assert (embedding_levels);

if (!str)
str = visual_str;

DBG ("reset the embedding levels, 4. whitespace at the end of line");
{
register FriBidiStrIndex i;

/* L1. Reset the embedding levels of some chars:
4. any sequence of white space characters at the end of the line. */
for (i = off + len - 1; i >= off &&
FRIBIDI_IS_EXPLICIT_OR_BN_OR_WS (BIDI_TYPE (i)); i--)
FRIBIDI_IS_EXPLICIT_OR_BN_OR_WS (bidi_types[i]); i--)
embedding_levels[i] = FRIBIDI_DIR_TO_LEVEL (base_dir);
}

Expand Down Expand Up @@ -962,13 +955,13 @@ fribidi_reorder_line (
/* L3. Reorder NSMs. */
for (i = off + len - 1; i >= off; i--)
if (FRIBIDI_LEVEL_IS_RTL (embedding_levels[i])
&& BIDI_TYPE (i) == FRIBIDI_TYPE_NSM)
&& bidi_types[i] == FRIBIDI_TYPE_NSM)
{
register FriBidiStrIndex seq_end = i;
level = embedding_levels[i];

for (i--; i >= off &&
FRIBIDI_IS_EXPLICIT_OR_BN_OR_NSM (BIDI_TYPE (i))
FRIBIDI_IS_EXPLICIT_OR_BN_OR_NSM (bidi_types[i])
&& embedding_levels[i] == level; i--)
;

Expand Down
43 changes: 7 additions & 36 deletions lib/fribidi-bidi.h
@@ -1,10 +1,10 @@
/* FriBidi
* fribidi-bidi.h - bidirectional algorithm
*
* $Id: fribidi-bidi.h,v 1.12 2004-06-21 16:15:27 behdad Exp $
* $Id: fribidi-bidi.h,v 1.13 2004-06-21 18:49:23 behdad Exp $
* $Author: behdad $
* $Date: 2004-06-21 16:15:27 $
* $Revision: 1.12 $
* $Date: 2004-06-21 18:49:23 $
* $Revision: 1.13 $
* $Source: /home/behdad/src/fdo/fribidi/togit/git/../fribidi/fribidi2/lib/fribidi-bidi.h,v $
*
* Authors:
Expand Down Expand Up @@ -49,12 +49,6 @@
* as defined by rule P2 of the Unicode Bidirectional Algorithm available at
* http://www.unicode.org/reports/tr9/#P2.
*
* You can provide either the string, or the bidi types; or both.
* If bidi_types are provided, they are used as the bidi types of characters
* in the string, otherwise the types are computed from the characters in str.
* Providing bidi types if available at your side, saves you a few cycles.
* Bidi types can be obtained by calling fribidi_get_bidi_types().
*
* You typically do not need this function as
* fribidi_get_par_embedding_levels() knows how to compute base direction
* itself, but you may need this to implement a more sophisticated paragraph
Expand All @@ -69,9 +63,8 @@
* only LTR, RTL, or ON.
*/
FRIBIDI_ENTRY FriBidiParType fribidi_get_par_direction (
const FriBidiChar *str, /* input paragraph string */
const FriBidiStrIndex len, /* input string length */
const FriBidiCharType *bidi_types /* input bidi types */
const FriBidiCharType *bidi_types, /* input bidi types */
const FriBidiStrIndex len /* input string length */
);

#define fribidi_get_par_embedding_levels FRIBIDI_NAMESPACE(get_par_embedding_levels)
Expand All @@ -84,12 +77,6 @@ FRIBIDI_ENTRY FriBidiParType fribidi_get_par_direction (
* implemented in fribidi_remove_bidi_marks(). Part 4 of L1 is implemented
* in fribidi_reorder_line().
*
* You can provide either the string, or the bidi types; or both.
* If bidi_types are provided, they are used as the bidi types of characters
* in the string, otherwise the types are computed from the characters in str.
* Providing bidi types if available at your side, saves you a few cycles.
* Bidi types can be obtained by calling fribidi_get_bidi_types().
*
* There are a few macros defined in fribidi-bidi-types.h to work with this
* embedding levels.
*
Expand All @@ -98,9 +85,8 @@ FRIBIDI_ENTRY FriBidiParType fribidi_get_par_direction (
*/
FRIBIDI_ENTRY FriBidiLevel
fribidi_get_par_embedding_levels (
const FriBidiChar *str, /* input paragraph string */
const FriBidiStrIndex len, /* input string length of the paragraph */
const FriBidiCharType *bidi_types, /* input bidi types */
const FriBidiStrIndex len, /* input string length of the paragraph */
FriBidiParType *pbase_dir, /* requested and resolved paragraph
* base direction */
FriBidiLevel *embedding_levels /* output list of embedding levels */
Expand All @@ -116,20 +102,6 @@ fribidi_get_par_embedding_levels (
*
* As a side effect it also sets position maps if not NULL.
*
* You can provide either the string str, or the bidi types; or both. If
* bidi_types are provided, they are used as the bidi types of characters in
* the string, otherwise the types are computed from the characters in str.
* If neither str nor bidi types are provided, visual_str is used instead.
* Feel free to pass the same string as both str and visual_str, but if you
* done extensive complicated shaping in visual_str, you better provide
* logical string as str. There is no known differences yet between providing
* logical or visual string as str.
*
* If you have obtained the embedding levels using custom bidi types, you
* should provide the same types to this function for valid resutls.
* Providing bidi types if available at your side, saves you a few cycles, and
* you don't need to provide str anymore.
*
* You should provide the resolved paragraph direction and embedding levels as
* set by fribidi_get_par_embedding_levels(). Also note that the embedding
* levels may change a bit. To be exact, the embedding level of any sequence
Expand All @@ -146,11 +118,10 @@ fribidi_get_par_embedding_levels (
* occured (memory allocation failure most probably).
*/
FRIBIDI_ENTRY FriBidiLevel fribidi_reorder_line (
const FriBidiChar *str, /* input string */
const FriBidiCharType *bidi_types, /* input bidi types */
const FriBidiStrIndex len, /* input length of the line */
const FriBidiStrIndex off, /* input offset of the beginning of the line
in the paragraph */
const FriBidiCharType *bidi_types, /* input bidi types */
const FriBidiParType base_dir, /* resolved paragraph base direction */
FriBidiLevel *embedding_levels, /* list of embedding levels,
as returned by
Expand Down
17 changes: 13 additions & 4 deletions lib/fribidi-joining.c
@@ -1,10 +1,10 @@
/* FriBidi
* fribidi-joining.h - Arabic joining algorithm
*
* $Id: fribidi-joining.c,v 1.2 2004-06-15 11:52:02 behdad Exp $
* $Id: fribidi-joining.c,v 1.3 2004-06-21 18:49:23 behdad Exp $
* $Author: behdad $
* $Date: 2004-06-15 11:52:02 $
* $Revision: 1.2 $
* $Date: 2004-06-21 18:49:23 $
* $Revision: 1.3 $
* $Source: /home/behdad/src/fdo/fribidi/togit/git/../fribidi/fribidi2/lib/fribidi-joining.c,v $
*
* Authors:
Expand Down Expand Up @@ -70,6 +70,15 @@ print_joining_types (
#endif /* DEBUG */


#if FRIBIDI_JOIN_WITHIN_RUN_LEVEL
/* Join within same level run (to be proposed for inclusion in Unicode 4.1) */
# define FRIBIDI_JOINING_RUN(l) (l)
#else /* !FRIBIDI_JOIN_WITHIN_RUN_LEVEL */
/* Join within same directional run (current rule in Unicode 4.0.1) */
# define FRIBIDI_JOINING_RUN(l) FRIBIDI_LEVEL_IS_RTL(l)
#endif /* !FRIBIDI_JOIN_WITHIN_RUN_LEVEL */


FRIBIDI_ENTRY void
fribidi_join_arabic (
/* input */
Expand All @@ -82,7 +91,7 @@ fribidi_join_arabic (
if UNLIKELY
(len == 0) return;

DBG ("entering fribidi_join_arabic");
DBG ("in fribidi_join_arabic");

fribidi_assert (embedding_levels);
fribidi_assert (ar_props);
Expand Down

0 comments on commit 597b12b

Please sign in to comment.