From: ellson Date: Sun, 28 Sep 2008 17:07:30 +0000 (+0000) Subject: another good stopping point X-Git-Tag: LAST_LIBGRAPH~32^2~3285 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b2cdd89033bd5eefe519d2ddb4680369e0a78e1d;p=graphviz another good stopping point --- diff --git a/lib/inkpot/inkpot.h b/lib/inkpot/inkpot.h index b64f20c96..f30e62030 100644 --- a/lib/inkpot/inkpot.h +++ b/lib/inkpot/inkpot.h @@ -27,7 +27,8 @@ typedef enum { INKPOT_COLOR_UNKNOWN, INKPOT_COLOR_NONAME, INKPOT_COLOR_NOPALETTE, - INKPOT_SCHEME_UNKNOWN + INKPOT_SCHEME_UNKNOWN, + INKPOT_NOSUCH_INDEX } inkpot_status_t; typedef struct inkpot_s inkpot_t; diff --git a/lib/inkpot/inkpot_define.h b/lib/inkpot/inkpot_define.h index a8de6a725..fcaff6899 100644 --- a/lib/inkpot/inkpot_define.h +++ b/lib/inkpot/inkpot_define.h @@ -15,36 +15,35 @@ **********************************************************/ typedef unsigned int IDX_STRINGS; +#define SZT_STRINGS 79 +#define SZL_STRINGS 6 + typedef unsigned short MSK_SCHEMES_NAME; typedef unsigned char IDX_SCHEMES_NAME; -typedef unsigned char IDX_SCHEMES_INDEX; -typedef unsigned int IDX_NAMES; -typedef unsigned char IDX_NAME_ALTS; - -typedef unsigned int IDX_MRU_CACHE; -#define SZT_MRU_CACHE 4 +#define SZT_SCHEMES_NAME 3 +typedef unsigned char IDX_SCHEMES_INDEX; #define SZT_SCHEMES_INDEX 2 -#define SZL_STRINGS 6 - -#define SZT_STRINGS 79 -#define SZT_SCHEMES_NAME 3 +typedef unsigned int IDX_NAMES; #define SZT_NAMES 11 -#define SZT_NAME_ALTS 2 +typedef unsigned char IDX_NAME_ALTS; +#define SZT_NAME_ALTS 2 -/* for values */ +typedef unsigned int IDX_MRU_CACHE; +#define SZT_MRU_CACHE 4 -typedef unsigned int IDX_VALUES; typedef unsigned int IDX_IXVALUES; +#define SZT_IXVALUES 7 +typedef unsigned int IDX_TONAMES; +#define SZT_TONAMES 7 + typedef unsigned long VALUE; #define SZB_RED 16 #define MSK_RED 65535 #define MAX_RED 65535 +typedef unsigned int IDX_VALUES; #define SZT_VALUES 7 #define SZT_NONAME_VALUES 4 -#define SZT_IXVALUES 7 - - diff --git a/lib/inkpot/inkpot_name_table.h b/lib/inkpot/inkpot_name_table.h index 319a04151..0d6a151da 100644 --- a/lib/inkpot/inkpot_name_table.h +++ b/lib/inkpot/inkpot_name_table.h @@ -61,3 +61,20 @@ inkpot_name_t TAB_NAMES[SZT_NAMES] = { /* Must be LC_ALL=C sort'ed by name with IDX_NAMES TAB_NAME_ALTS[SZT_NAME_ALTS] = { 0, 10, }; + +IDX_TONAMES TAB_TONAMES[SZT_TONAMES] = { + 0, /* black */ + 1, /* bleu, blue */ + 3, /* green, vert */ + 5, /* red, rouge */ + 7, /* yellow (svg) */ + 8, /* yellow (x11), jaune */ + 10, /* white */ +}; + +IDX_VALUES TAB_IXVALUES[SZT_IXVALUES] = { + 7, 8, 9, 10, 1, /* xxx */ + 0, 6, /* yyy */ +}; + + diff --git a/lib/inkpot/inkpot_scheme.c b/lib/inkpot/inkpot_scheme.c index 47024bf82..67fe99339 100644 --- a/lib/inkpot/inkpot_scheme.c +++ b/lib/inkpot/inkpot_scheme.c @@ -42,11 +42,12 @@ inkpot_t *inkpot_init ( void ) inkpot = malloc(sizeof(inkpot_t)); if (inkpot) { - inkpot->values = inkpot_values_init (); - if (! inkpot->values) { - free(inkpot); - return NULL; - } + inkpot->values.no_palette_value = 0; + inkpot->values.no_palette_vtype = (BIT_VTYPE_size_16 | BIT_VTYPE_code_VALUE | BIT_VTYPE_alpha_yes); + + inkpot->value.index = 0; + inkpot->value.value = 0; + inkpot->value.vtype = (BIT_VTYPE_size_16 | BIT_VTYPE_code_VALUE | BIT_VTYPE_alpha_yes); inkpot->canon = NULL; inkpot->canon_alloc = 0; @@ -69,7 +70,6 @@ inkpot_t *inkpot_init ( void ) void inkpot_destroy ( inkpot_t *inkpot ) { - inkpot_values_destroy ( inkpot->values ); free(inkpot->canon); free(inkpot); } @@ -399,7 +399,7 @@ inkpot_status_t inkpot_set_rgba ( inkpot_t *inkpot, double rgba[4] ) } value.vtype = BIT_VTYPE_size_16 | BIT_VTYPE_code_VALUE | BIT_VTYPE_alpha_yes; - rc = inkpot_value_set ( inkpot->values, &value ); + rc = inkpot_value_set ( &inkpot->values, &value ); if (rc == INKPOT_SUCCESS) inkpot->value = value; return (inkpot->status = rc); @@ -465,7 +465,7 @@ inkpot_status_t inkpot_set ( inkpot_t *inkpot, const char *color ) value.value = (((((((VALUE)r) << SZB_RED) | (VALUE)g) << SZB_RED) | (VALUE)b) << SZB_RED) | (VALUE)a; value.vtype = BIT_VTYPE_size_16 | BIT_VTYPE_code_VALUE | BIT_VTYPE_alpha_yes; - rc = inkpot_value_set ( inkpot->values, &value ); + rc = inkpot_value_set ( &inkpot->values, &value ); if (rc == INKPOT_SUCCESS) inkpot->value = value; inkpot->status = rc; @@ -544,7 +544,7 @@ inkpot_status_t inkpot_get ( inkpot_t *inkpot, const char **color ) if (inkpot->out_scheme_bit) { value_idx = inkpot->value.index; if (value_idx < SZT_VALUES) { - for (t = TAB_VALUES[value_idx].toname_idx; t < SZT_NAMES; t++) { + for (t = TAB_TONAMES[value_idx]; t < SZT_NAMES; t++) { out_name = &TAB_NAMES[TAB_NAMES[t].toname_idx]; if (out_name->value_idx != value_idx) break; @@ -586,7 +586,7 @@ inkpot_status_t inkpot_get_rgba_i ( inkpot_t *inkpot, unsigned short rgba[4] ) int i; value = inkpot->value; - rc = inkpot->status = inkpot_value_get( inkpot->values, &value ); + rc = inkpot->status = inkpot_value_get( &inkpot->values, &value ); if (rc == INKPOT_SUCCESS) { for (i = 3; i >= 0; i--) { rgba[i] = (value.value & MSK_RED); @@ -603,7 +603,7 @@ inkpot_status_t inkpot_get_rgba ( inkpot_t *inkpot, double rgba[4] ) int i; value = inkpot->value; - rc = inkpot->status = inkpot_value_get( inkpot->values, &value ); + rc = inkpot->status = inkpot_value_get( &inkpot->values, &value ); if (rc == INKPOT_SUCCESS) { for (i = 3; i >= 0; i--) { rgba[i] = (value.value & MSK_RED) / (double)MAX_RED; @@ -766,6 +766,7 @@ inkpot_status_t inkpot_debug_schemes( inkpot_t *inkpot ) return ((inkpot->status = INKPOT_SUCCESS)); } +#if 0 static inkpot_status_t inkpot_debug_scheme_names( inkpot_t *inkpot, int scheme_bits ) { IDX_SCHEMES_NAME i; @@ -797,7 +798,9 @@ static void inkpot_debug_rgba( inkpot_t *inkpot, VALUE value ) sprintf(buf, "#%04x%04x%04x%04x", rgba[0], rgba[1], rgba[2], rgba[3]); errputs(inkpot, buf); } +#endif +#if 0 static inkpot_status_t inkpot_debug_names_schemes( inkpot_t *inkpot, MSK_SCHEMES_NAME scheme_bits, IDX_SCHEMES_INDEX active, IDX_SCHEMES_NAME *scheme_index ) { inkpot_name_t *name; @@ -860,6 +863,7 @@ inkpot_status_t inkpot_debug_out_names( inkpot_t *inkpot ) errputs(inkpot, "names (out):\n"); return inkpot_debug_names_schemes(inkpot, inkpot->out_scheme_bit, 1, inkpot->out_scheme_list); } +#endif #if 0 /* Print all values that are members of the currently listed @@ -868,6 +872,7 @@ inkpot_status_t inkpot_debug_out_names( inkpot_t *inkpot ) * be a member of. */ inkpot_status_t inkpot_debug_values( inkpot_t *inkpot ) { + inkpot_status_t rc; inkpot_value_t *value; inkpot_name_t *name; IDX_VALUES i; @@ -876,8 +881,10 @@ inkpot_status_t inkpot_debug_values( inkpot_t *inkpot ) int found; errputs(inkpot, "values:\n"); - for (i = 0; i < SZT_VALUES; i++) { - value = &TAB_VALUES[i]; + for (rc = inkpot_value_get_first(inkpot, &value); + rc == INKPOT_SUCCESS + rc = inkpot_value_get_next(inkpot, &value)) { + found = 0; for (t = value->toname_idx; t < SZT_NAMES; t++) { name = &TAB_NAMES[TAB_NAMES[t].toname_idx]; @@ -921,6 +928,8 @@ inkpot_status_t inkpot_debug_error ( inkpot_t *inkpot ) m = "\nINKPOT_COLOR_PALETTE\n"; break; case INKPOT_SCHEME_UNKNOWN: m = "\nINKPOT_SCHEME_UNKNOWN\n"; break; + case INKPOT_NOSUCH_INDEX: + m = "\nINKPOT_NOSUCH_INDEX\n"; break; } inkpot->disc.err_writer(inkpot->err_closure, m, strlen(m)); diff --git a/lib/inkpot/inkpot_struct.h b/lib/inkpot/inkpot_struct.h index 1a01071fa..1776994fa 100644 --- a/lib/inkpot/inkpot_struct.h +++ b/lib/inkpot/inkpot_struct.h @@ -95,7 +95,7 @@ struct inkpot_s { /* The Ink Pot */ char *canon; /* malloc'ed, reused storage for canonicalizing color request strings */ int canon_alloc; - inkpot_values_t *values;/* The values store */ + inkpot_values_t values; /* The values store */ inkpot_value_t value; /* The current value of the inkpot */ inkpot_cache_element_t diff --git a/lib/inkpot/inkpot_value.c b/lib/inkpot/inkpot_value.c index 75a0deab7..e62ee4725 100644 --- a/lib/inkpot/inkpot_value.c +++ b/lib/inkpot/inkpot_value.c @@ -23,29 +23,6 @@ #include "inkpot_value.h" #include "inkpot_value_table.h" -struct inkpot_values_s { - VALUE - no_palette_value; - BIT_VTYPE - no_palette_vtype; -}; - -inkpot_values_t* inkpot_values_init ( void ) -{ - inkpot_values_t *values; - - values = (inkpot_values_t*)malloc(sizeof(inkpot_values_t)); - if (values) { - - } - return values; -} - -void inkpot_values_destroy ( inkpot_values_t *values ) -{ - free(values); -} - inkpot_status_t inkpot_value_set ( inkpot_values_t *values, inkpot_value_t *value ) { values->no_palette_value = value->value; @@ -61,11 +38,11 @@ inkpot_status_t inkpot_value_get ( inkpot_values_t *values, inkpot_value_t *valu index = value->index; if (index < SZT_VALUES) { - value->value = TAB_VALUES[index].value; + value->value = TAB_VALUES[index]; value->vtype = BIT_VTYPE_size_16 | BIT_VTYPE_code_VALUE | BIT_VTYPE_alpha_yes; } else if (index - SZT_VALUES < SZT_NONAME_VALUES) { - value->value = TAB_NONAME_VALUES[index - SZT_VALUES].value; + value->value = TAB_NONAME_VALUES[index - SZT_VALUES]; value->vtype = BIT_VTYPE_size_16 | BIT_VTYPE_code_VALUE | BIT_VTYPE_alpha_yes; } else if (index == SZT_VALUES + SZT_NONAME_VALUES) { @@ -73,7 +50,19 @@ inkpot_status_t inkpot_value_get ( inkpot_values_t *values, inkpot_value_t *valu value->vtype = values->no_palette_vtype; } else - assert(0); + return INKPOT_NOSUCH_INDEX; return INKPOT_SUCCESS; } + +inkpot_status_t inkpot_value_get_first ( inkpot_values_t *values, inkpot_value_t *value ) +{ + value->index = 0; + return inkpot_value_get ( values, value ); +} + +inkpot_status_t inkpot_value_get_next ( inkpot_values_t *values, inkpot_value_t *value ) +{ + value->index++; + return inkpot_value_get ( values, value ); +} diff --git a/lib/inkpot/inkpot_value.h b/lib/inkpot/inkpot_value.h index 472d51c87..395017c81 100644 --- a/lib/inkpot/inkpot_value.h +++ b/lib/inkpot/inkpot_value.h @@ -21,55 +21,11 @@ extern "C" { #endif -#if 1 -/* FIXME - this stuff needs to go */ - -typedef struct inkpot_oldvalue_s { /* Numeric color values used by the set - * of inkpot_name_t and indexes from - * indexed color schemes ( total presumed - * to be less than all possible color values). - * inkpot_value_t instances are unique and - * are numerically sorted by rgb value - * in TAB_VALUES[] */ - - VALUE value; - - IDX_NAMES /* FIXME - searate this in to a separate table */ - toname_idx; /* An index into TAB_NAMES to the toname - * which indexes the first inkpot_name_t - * in TAB_NAMES that maps to this color, - * followed in TAB_NAMES by the toname indexes - * of other inkpot_name_t that also map to - * this inkpot_value_t, until a toname index - * in TAB_NAMES indexes a inkpot_name_t - * that doesn't map to this inkpot_value_t, - * or until the end of TAB_NAMES is reached. - * (Phew!) */ -} inkpot_oldvalue_t; - -typedef struct inkpot_noname_value_s { /* Numeric color values used by the remainder - * of indexes from indexed color schemes - * inkpot_noname_value_t instances are unique and - * are numerically sorted by rgba value - * in TAB_NONAME_VALUES[] */ - VALUE value; - -} inkpot_noname_value_t; - -extern inkpot_oldvalue_t TAB_VALUES[]; -extern inkpot_noname_value_t TAB_NONAME_VALUES[]; -#endif -extern IDX_VALUES TAB_IXVALUES[]; - -/* proper api starts here */ - -typedef struct inkpot_values_s inkpot_values_t; - typedef int BIT_VTYPE; #define MSK_VTYPE_size 0x01 -#define BIT_VTYPE_size_8 0x00 -#define BIT_VTYPE_size_16 0x01 +#define BIT_VTYPE_size_16 0x00 +#define BIT_VTYPE_size_8 0x01 #define MSK_VTYPE_code 0x0e #define BIT_VTYPE_code_VALUE 0x00 @@ -78,18 +34,20 @@ typedef int BIT_VTYPE; #define BIT_VTYPE_code_cmyk 0x06 #define MSK_VTYPE_alpha 0x10 -#define BIT_VTYPE_alpha_no 0x00 -#define BIT_VTYPE_alpha_yes 0x10 +#define BIT_VTYPE_alpha_yes 0x00 +#define BIT_VTYPE_alpha_no 0x10 + +typedef struct inkpot_values_s { + VALUE no_palette_value; + BIT_VTYPE no_palette_vtype; +} inkpot_values_t; typedef struct inkpot_value_s { - IDX_VALUES index; /* write by set, read by get, write by first/next */ - BIT_VTYPE vtype; /* read by set, write by get, read by first/next */ - VALUE value; /* read by set, write by get, write by first/next */ + IDX_VALUES index; /* write by set, read by get, write by first, read/write by next */ + BIT_VTYPE vtype; /* read by set, write by get, read by first, read by next */ + VALUE value; /* read by set, write by get, write by first, write by next */ } inkpot_value_t; -extern inkpot_values_t* inkpot_values_init (); -extern void inkpot_values_destroy ( inkpot_values_t *values ); - extern inkpot_status_t inkpot_value_set ( inkpot_values_t *values, inkpot_value_t *value ); extern inkpot_status_t inkpot_value_get ( inkpot_values_t *values, inkpot_value_t *value ); diff --git a/lib/inkpot/inkpot_value_table.h b/lib/inkpot/inkpot_value_table.h index cfd9e16b2..083225457 100644 --- a/lib/inkpot/inkpot_value_table.h +++ b/lib/inkpot/inkpot_value_table.h @@ -14,24 +14,19 @@ * AT&T Research, Florham Park NJ * **********************************************************/ -inkpot_oldvalue_t TAB_VALUES[SZT_VALUES] = { /* Must be sort'ed */ - { 0x000000000000ffff, 0 }, /* black */ - { 0x00000000ffffffff, 1 }, /* bleu, blue */ - { 0x0000ffff0000ffff, 3 }, /* green, vert */ - { 0xffff00000000ffff, 5 }, /* red, rouge */ - { 0xffffcf000000ffff, 7 }, /* yellow (svg) */ - { 0xffffffff0000ffff, 8 }, /* yellow (x11), jaune */ - { 0xffffffffffffffff, 10}, /* white */ +VALUE TAB_VALUES[SZT_VALUES] = { + 0x000000000000ffff, /* black */ + 0x00000000ffffffff, /* bleu, blue */ + 0x0000ffff0000ffff, /* green, vert */ + 0xffff00000000ffff, /* red, rouge */ + 0xffffcf000000ffff, /* yellow (svg) */ + 0xffffffff0000ffff, /* yellow (x11), jaune */ + 0xffffffffffffffff, /* white */ }; -inkpot_noname_value_t TAB_NONAME_VALUES[SZT_NONAME_VALUES] = { /* Must be sort'ed */ - { 0x000000008000ffff, }, - { 0x00000000a400ffff, }, - { 0x00000000c800ffff, }, - { 0x00000000ea00ffff, }, +VALUE TAB_NONAME_VALUES[SZT_NONAME_VALUES] = { + 0x000000008000ffff, + 0x00000000a400ffff, + 0x00000000c800ffff, + 0x00000000ea00ffff, }; - -IDX_VALUES TAB_IXVALUES[SZT_IXVALUES] = { - 7, 8, 9, 10, 1, /* xxx */ - 0, 6, /* yyy */ -};