From 5c6fcdaab68dbb1ff24891d589d22f5de277cf9b Mon Sep 17 00:00:00 2001 From: Ulf GRIESMANN Date: Sat, 1 Jun 2019 08:40:16 -0400 Subject: [PATCH] - all element types except sref and aref now have the datatype (dtype) property, which seems to be common practice (thanks to Eng Wen Ong for pointing it out). --- Basic/@gds_element/gds_element.m | 25 ++++----- Basic/@gds_element/private/el_hash.h | 18 ++---- Basic/@gds_element/private/get_element_data.c | 55 +++++++++++++++++-- .../@gds_element/private/get_prop_hash.gperf | 6 +- Basic/@gds_element/private/get_prop_hash.h | 24 +++----- Basic/@gds_element/private/has_hash.h | 18 ++---- Basic/@gds_element/private/notint_hash.h | 18 ++---- Basic/@gds_element/private/set_element_data.c | 6 +- Basic/@gds_element/private/set_prop_hash.h | 18 ++---- Basic/gdsio/gds_read_element.c | 26 ++++++--- Basic/gdsio/gds_write_element.c | 18 +++++- Basic/gdsio/gdstypes.h | 7 ++- 12 files changed, 137 insertions(+), 102 deletions(-) diff --git a/Basic/@gds_element/gds_element.m b/Basic/@gds_element/gds_element.m index 3397b5a..1cc6b02 100644 --- a/Basic/@gds_element/gds_element.m +++ b/Basic/@gds_element/gds_element.m @@ -7,7 +7,7 @@ % % gelm : element object created by the constructor % etype : a string with one of the GDSII elements: boundary, -% path, box, aref, sref, text, node. +% path, box, text, node, sref, aref. % varargin : EITHER a list of property, value pairs % OR a structure with ALL element properties - no % error checking ! This provides a fast way to create @@ -30,9 +30,11 @@ % The total number of bytes for all properties in the structure % array must not exceed 128, or 512 in the case of sref and aref % elements. -% layer : GDS layer for the element EXCEPT SREF and AREF, which -% have no layer property (default is 1). -% +% layer : GDS layer for the element (default is 1). +% dtype : data type number 0 .. 255. Default is 0. +% layer and dtype for a complete layer specification. +% NOTE: sref and aref elements have no layer and dtype properties. +% % Element specific properties: % ============================ % @@ -40,18 +42,12 @@ % ----------------- % xy : a cell array of N x 2 matrices containing one or % more closed polygons with up to 8191 vertices. -% dtype : data type number 0 .. 255. Default is 0. -% Forms a layer specification together with -% the layer. % nume : number of polygons in the boundary element % % Path element: % ------------- % xy : a cell array of N x 2 matrices describing one or % more paths with up to 8191 vertex coordinates. -% dtype : data type number 0 .. 255. Default is 0. -% Forms a layer specification together with -% the layer. % ptype : path type 0,1, 2, or 4. Default is 0. % width : width of the path in user units % Negative numbers imply absolute widths @@ -65,7 +61,7 @@ % ------------ % xy : 5 x N matrix of closed rectangular % polygon. -% btype : a box type 0 .. 255 +% btype : a box type 0 .. 255. Default is 0. % % Node element: % ------------- @@ -76,8 +72,7 @@ % ------------- % text : a text string % xy : text location in user units -% ttype : text type, a number 0 .. 63. Default -% is 0. +% ttype : text type, a number 0 .. 63. Default is 0. % font : text font 0 .. 3. Default is 0 % verj : vertical justification; 0 = top, 1 = % middle, 2 = bottom. Default is 0. @@ -85,9 +80,9 @@ % = middle, 2 = right. Default is 0. % ptype : path type. Default is 1. % width : width of line for drawing text in -% user units (obsolete) +% user units (obsolete). % strans: an strans record which describes text -% transformations. Omitted by default. +% transformations. Omitted by default. % % Sref element(s): % ---------------- diff --git a/Basic/@gds_element/private/el_hash.h b/Basic/@gds_element/private/el_hash.h index f7c6f5c..9fa3b81 100644 --- a/Basic/@gds_element/private/el_hash.h +++ b/Basic/@gds_element/private/el_hash.h @@ -1,4 +1,4 @@ -/* ANSI-C code produced by gperf version 3.0.4 */ +/* ANSI-C code produced by gperf version 3.1 */ /* Command-line: gperf el_hash.gperf */ /* Computed positions: -k'1' */ @@ -26,7 +26,7 @@ && ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \ && ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126)) /* The character set is not based on ISO-646. */ -#error "gperf generated tables don't work with this execution character set. Please report a bug to ." +#error "gperf generated tables don't work with this execution character set. Please report a bug to ." #endif #line 1 "el_hash.gperf" @@ -60,7 +60,7 @@ inline #endif #endif static unsigned int -hash (register const char *str, register unsigned int len) +hash (register const char *str, register size_t len) { static unsigned char asso_values[] = { @@ -94,14 +94,8 @@ hash (register const char *str, register unsigned int len) return len + asso_values[(unsigned char)str[0]]; } -#ifdef __GNUC__ -__inline -#if defined __GNUC_STDC_INLINE__ || defined __GNUC_GNU_INLINE__ -__attribute__ ((__gnu_inline__)) -#endif -#endif struct keyword * -in_word_set (register const char *str, register unsigned int len) +in_word_set (register const char *str, register size_t len) { static struct keyword wordlist[] = { @@ -126,9 +120,9 @@ in_word_set (register const char *str, register unsigned int len) if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH) { - register int key = hash (str, len); + register unsigned int key = hash (str, len); - if (key <= MAX_HASH_VALUE && key >= 0) + if (key <= MAX_HASH_VALUE) { register const char *s = wordlist[key].name; diff --git a/Basic/@gds_element/private/get_element_data.c b/Basic/@gds_element/private/get_element_data.c index ee8c6e4..7d7c009 100644 --- a/Basic/@gds_element/private/get_element_data.c +++ b/Basic/@gds_element/private/get_element_data.c @@ -33,6 +33,9 @@ static mxArray* get_plex(element_t *pe); static mxArray* get_layer(element_t *pe); static mxArray* get_dtype(element_t *pe); static mxArray* get_ptype(element_t *pe); +static mxArray* get_ttype(element_t *pe); +static mxArray* get_ntype(element_t *pe); +static mxArray* get_btype(element_t *pe); static mxArray* get_width(element_t *pe); static mxArray* get_ext(element_t *pe); static mxArray* get_font(element_t *pe); @@ -143,11 +146,9 @@ static mxArray* get_dtype(element_t *pe) { if (pe->kind == GDS_SREF || pe->kind == GDS_AREF) - return empty_matrix(); - else - return mxCreateDoubleScalar((double)pe->dtype); + mexErrMsgTxt("get_element_data : sref and aref have no dtype property."); - return NULL; /* make compiler happy */ + return mxCreateDoubleScalar((double)pe->dtype); } @@ -156,7 +157,10 @@ get_dtype(element_t *pe) static mxArray* get_ptype(element_t *pe) { - if (pe->has & HAS_PTYPE) + if (pe->kind != GDS_PATH && pe->kind != GDS_TEXT) + mexErrMsgTxt("get_element_data : element has no ptype property."); + + if (pe->has & HAS_PTYPE) /* path type is optional */ return mxCreateDoubleScalar((double)pe->ptype); else return empty_matrix(); @@ -166,10 +170,49 @@ get_ptype(element_t *pe) /*-----------------------------------------------------------------*/ +static mxArray* +get_ttype(element_t *pe) +{ + if (pe->kind != GDS_TEXT) + mexErrMsgTxt("get_element_data : element has no ttype property."); + + return mxCreateDoubleScalar((double)pe->ttype); +} + + +/*-----------------------------------------------------------------*/ + + +static mxArray* +get_ntype(element_t *pe) +{ + if (pe->kind != GDS_NODE) + mexErrMsgTxt("get_element_data : element has no ntype property."); + + return mxCreateDoubleScalar((double)pe->ntype); +} + + +/*-----------------------------------------------------------------*/ + + +static mxArray* +get_btype(element_t *pe) +{ + if (pe->kind != GDS_BOX) + mexErrMsgTxt("get_element_data : element has no btype property."); + + return mxCreateDoubleScalar((double)pe->btype); +} + + +/*-----------------------------------------------------------------*/ + + static mxArray* get_width(element_t *pe) { - if (pe->has & HAS_WIDTH) + if (pe->has & HAS_WIDTH) /* width property is optional */ return mxCreateDoubleScalar((double)pe->width); else return empty_matrix(); diff --git a/Basic/@gds_element/private/get_prop_hash.gperf b/Basic/@gds_element/private/get_prop_hash.gperf index d843789..4a6bb4b 100644 --- a/Basic/@gds_element/private/get_prop_hash.gperf +++ b/Basic/@gds_element/private/get_prop_hash.gperf @@ -22,9 +22,9 @@ plex, &get_plex layer, &get_layer dtype, &get_dtype ptype, &get_ptype -ttype, &get_dtype -btype, &get_dtype -ntype, &get_dtype +ttype, &get_ttype +btype, &get_btype +ntype, &get_ntype width, &get_width ext, &get_ext font, &get_font diff --git a/Basic/@gds_element/private/get_prop_hash.h b/Basic/@gds_element/private/get_prop_hash.h index 768c4ff..2bdeea9 100644 --- a/Basic/@gds_element/private/get_prop_hash.h +++ b/Basic/@gds_element/private/get_prop_hash.h @@ -1,4 +1,4 @@ -/* ANSI-C code produced by gperf version 3.0.4 */ +/* ANSI-C code produced by gperf version 3.1 */ /* Command-line: gperf get_prop_hash.gperf */ /* Computed positions: -k'1' */ @@ -26,7 +26,7 @@ && ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \ && ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126)) /* The character set is not based on ISO-646. */ -#error "gperf generated tables don't work with this execution character set. Please report a bug to ." +#error "gperf generated tables don't work with this execution character set. Please report a bug to ." #endif #line 1 "get_prop_hash.gperf" @@ -60,7 +60,7 @@ inline #endif #endif static unsigned int -hash (register const char *str, register unsigned int len) +hash (register const char *str, register size_t len) { static unsigned char asso_values[] = { @@ -94,14 +94,8 @@ hash (register const char *str, register unsigned int len) return len + asso_values[(unsigned char)str[0]]; } -#ifdef __GNUC__ -__inline -#if defined __GNUC_STDC_INLINE__ || defined __GNUC_GNU_INLINE__ -__attribute__ ((__gnu_inline__)) -#endif -#endif struct keyword * -in_word_set (register const char *str, register unsigned int len) +in_word_set (register const char *str, register size_t len) { static struct keyword wordlist[] = { @@ -117,7 +111,7 @@ in_word_set (register const char *str, register unsigned int len) #line 20 "get_prop_hash.gperf" {"elflags", &get_elflags}, #line 26 "get_prop_hash.gperf" - {"btype", &get_dtype}, + {"btype", &get_btype}, #line 21 "get_prop_hash.gperf" {"plex", &get_plex}, #line 24 "get_prop_hash.gperf" @@ -131,12 +125,12 @@ in_word_set (register const char *str, register unsigned int len) #line 30 "get_prop_hash.gperf" {"font", &get_font}, #line 25 "get_prop_hash.gperf" - {"ttype", &get_dtype}, + {"ttype", &get_ttype}, {""}, {""}, {""}, #line 35 "get_prop_hash.gperf" {"adim", &get_adim}, #line 27 "get_prop_hash.gperf" - {"ntype", &get_dtype}, + {"ntype", &get_ntype}, {""}, {""}, {""}, {""}, #line 22 "get_prop_hash.gperf" {"layer", &get_layer}, @@ -147,9 +141,9 @@ in_word_set (register const char *str, register unsigned int len) if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH) { - register int key = hash (str, len); + register unsigned int key = hash (str, len); - if (key <= MAX_HASH_VALUE && key >= 0) + if (key <= MAX_HASH_VALUE) { register const char *s = wordlist[key].name; diff --git a/Basic/@gds_element/private/has_hash.h b/Basic/@gds_element/private/has_hash.h index 2d101cd..e41c3bc 100644 --- a/Basic/@gds_element/private/has_hash.h +++ b/Basic/@gds_element/private/has_hash.h @@ -1,4 +1,4 @@ -/* ANSI-C code produced by gperf version 3.0.4 */ +/* ANSI-C code produced by gperf version 3.1 */ /* Command-line: gperf has_hash.gperf */ /* Computed positions: -k'1' */ @@ -26,7 +26,7 @@ && ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \ && ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126)) /* The character set is not based on ISO-646. */ -#error "gperf generated tables don't work with this execution character set. Please report a bug to ." +#error "gperf generated tables don't work with this execution character set. Please report a bug to ." #endif #line 1 "has_hash.gperf" @@ -63,7 +63,7 @@ inline #endif #endif static unsigned int -hash (register const char *str, register unsigned int len) +hash (register const char *str, register size_t len) { static unsigned char asso_values[] = { @@ -97,14 +97,8 @@ hash (register const char *str, register unsigned int len) return len + asso_values[(unsigned char)str[0]]; } -#ifdef __GNUC__ -__inline -#if defined __GNUC_STDC_INLINE__ || defined __GNUC_GNU_INLINE__ -__attribute__ ((__gnu_inline__)) -#endif -#endif struct keyword * -in_word_set (register const char *str, register unsigned int len) +in_word_set (register const char *str, register size_t len) { static struct keyword wordlist[] = { @@ -134,9 +128,9 @@ in_word_set (register const char *str, register unsigned int len) if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH) { - register int key = hash (str, len); + register unsigned int key = hash (str, len); - if (key <= MAX_HASH_VALUE && key >= 0) + if (key <= MAX_HASH_VALUE) { register const char *s = wordlist[key].name; diff --git a/Basic/@gds_element/private/notint_hash.h b/Basic/@gds_element/private/notint_hash.h index 88bb018..553daac 100644 --- a/Basic/@gds_element/private/notint_hash.h +++ b/Basic/@gds_element/private/notint_hash.h @@ -1,4 +1,4 @@ -/* ANSI-C code produced by gperf version 3.0.4 */ +/* ANSI-C code produced by gperf version 3.1 */ /* Command-line: gperf notint_hash.gperf */ /* Computed positions: -k'1' */ @@ -26,7 +26,7 @@ && ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \ && ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126)) /* The character set is not based on ISO-646. */ -#error "gperf generated tables don't work with this execution character set. Please report a bug to ." +#error "gperf generated tables don't work with this execution character set. Please report a bug to ." #endif #line 1 "notint_hash.gperf" @@ -56,7 +56,7 @@ inline #endif #endif static unsigned int -hash (register const char *str, register unsigned int len) +hash (register const char *str, register size_t len) { static unsigned char asso_values[] = { @@ -90,14 +90,8 @@ hash (register const char *str, register unsigned int len) return len + asso_values[(unsigned char)str[0]]; } -#ifdef __GNUC__ -__inline -#if defined __GNUC_STDC_INLINE__ || defined __GNUC_GNU_INLINE__ -__attribute__ ((__gnu_inline__)) -#endif -#endif const char * -in_word_set (register const char *str, register unsigned int len) +in_word_set (register const char *str, register size_t len) { static const char * wordlist[] = { @@ -110,9 +104,9 @@ in_word_set (register const char *str, register unsigned int len) if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH) { - register int key = hash (str, len); + register unsigned int key = hash (str, len); - if (key <= MAX_HASH_VALUE && key >= 0) + if (key <= MAX_HASH_VALUE) { register const char *s = wordlist[key]; diff --git a/Basic/@gds_element/private/set_element_data.c b/Basic/@gds_element/private/set_element_data.c index f977968..3a69133 100644 --- a/Basic/@gds_element/private/set_element_data.c +++ b/Basic/@gds_element/private/set_element_data.c @@ -200,7 +200,7 @@ set_ttype(element_t *pe, mxArray *val) if ( pe->kind != GDS_TEXT ) mexErrMsgTxt("set_element_data : element has no ttype property."); pd = (double *)mxGetData(val); - pe->dtype = (uint16_t)pd[0]; + pe->ttype = (uint16_t)pd[0]; } @@ -214,7 +214,7 @@ set_ntype(element_t *pe, mxArray *val) if ( pe->kind != GDS_NODE ) mexErrMsgTxt("set_element_data : element has no ntype property."); pd = (double *)mxGetData(val); - pe->dtype = (uint16_t)pd[0]; + pe->ntype = (uint16_t)pd[0]; } @@ -228,7 +228,7 @@ set_btype(element_t *pe, mxArray *val) if ( pe->kind != GDS_BOX ) mexErrMsgTxt("set_element_data : element has no btype property."); pd = (double *)mxGetData(val); - pe->dtype = (uint16_t)pd[0]; + pe->btype = (uint16_t)pd[0]; } diff --git a/Basic/@gds_element/private/set_prop_hash.h b/Basic/@gds_element/private/set_prop_hash.h index 14797c2..f8c68a8 100644 --- a/Basic/@gds_element/private/set_prop_hash.h +++ b/Basic/@gds_element/private/set_prop_hash.h @@ -1,4 +1,4 @@ -/* ANSI-C code produced by gperf version 3.0.4 */ +/* ANSI-C code produced by gperf version 3.1 */ /* Command-line: gperf set_prop_hash.gperf */ /* Computed positions: -k'1' */ @@ -26,7 +26,7 @@ && ('w' == 119) && ('x' == 120) && ('y' == 121) && ('z' == 122) \ && ('{' == 123) && ('|' == 124) && ('}' == 125) && ('~' == 126)) /* The character set is not based on ISO-646. */ -#error "gperf generated tables don't work with this execution character set. Please report a bug to ." +#error "gperf generated tables don't work with this execution character set. Please report a bug to ." #endif #line 1 "set_prop_hash.gperf" @@ -60,7 +60,7 @@ inline #endif #endif static unsigned int -hash (register const char *str, register unsigned int len) +hash (register const char *str, register size_t len) { static unsigned char asso_values[] = { @@ -94,14 +94,8 @@ hash (register const char *str, register unsigned int len) return len + asso_values[(unsigned char)str[0]]; } -#ifdef __GNUC__ -__inline -#if defined __GNUC_STDC_INLINE__ || defined __GNUC_GNU_INLINE__ -__attribute__ ((__gnu_inline__)) -#endif -#endif struct keyword * -in_word_set (register const char *str, register unsigned int len) +in_word_set (register const char *str, register size_t len) { static struct keyword wordlist[] = { @@ -147,9 +141,9 @@ in_word_set (register const char *str, register unsigned int len) if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH) { - register int key = hash (str, len); + register unsigned int key = hash (str, len); - if (key <= MAX_HASH_VALUE && key >= 0) + if (key <= MAX_HASH_VALUE) { register const char *s = wordlist[key].name; diff --git a/Basic/gdsio/gds_read_element.c b/Basic/gdsio/gds_read_element.c index 7211af6..e3061c3 100644 --- a/Basic/gdsio/gds_read_element.c +++ b/Basic/gdsio/gds_read_element.c @@ -328,6 +328,10 @@ read_path(FILE *fob, mxArray **data, double dbu_to_uu) path.layer = read_layer(fob); break; + case DATATYPE: + path.dtype = read_type(fob); + break; + case PATHTYPE: path.ptype = read_type(fob); path.has |= HAS_PTYPE; @@ -348,10 +352,6 @@ read_path(FILE *fob, mxArray **data, double dbu_to_uu) path.has |= HAS_ENDEXTN; break; - case DATATYPE: - path.dtype = read_type(fob); - break; - case ELFLAGS: path.elflags = read_elflags(fob); path.has |= HAS_ELFLAGS; @@ -776,7 +776,7 @@ read_text(FILE *fob, mxArray **data, double dbu_to_uu) break; case TEXTTYPE: - text.dtype = read_type(fob); + text.ttype = read_type(fob); break; case XY: @@ -787,6 +787,10 @@ read_text(FILE *fob, mxArray **data, double dbu_to_uu) text.layer = read_layer(fob); break; + case DATATYPE: + text.dtype = read_type(fob); + break; + case PATHTYPE: text.ptype = read_type(fob); text.has |= HAS_PTYPE; @@ -935,10 +939,14 @@ read_node(FILE *fob, mxArray **data, double dbu_to_uu) node.layer = read_layer(fob); break; - case NODETYPE: + case DATATYPE: node.dtype = read_type(fob); break; + case NODETYPE: + node.ntype = read_type(fob); + break; + case ELFLAGS: node.elflags = read_elflags(fob); node.has |= HAS_ELFLAGS; @@ -1053,10 +1061,14 @@ read_box(FILE *fob, mxArray **data, double dbu_to_uu) box.layer = read_layer(fob); break; - case BOXTYPE: + case DATATYPE: box.dtype = read_type(fob); break; + case BOXTYPE: + box.btype = read_type(fob); + break; + case ELFLAGS: box.elflags = read_elflags(fob); box.has |= HAS_ELFLAGS; diff --git a/Basic/gdsio/gds_write_element.c b/Basic/gdsio/gds_write_element.c index 0158393..88f7fe4 100644 --- a/Basic/gdsio/gds_write_element.c +++ b/Basic/gdsio/gds_write_element.c @@ -791,9 +791,13 @@ write_text(FILE *fob, mxArray *data, double uu_to_dbu) write_record_hdr(fob, LAYER, sizeof(uint16_t)); write_word(fob, text.layer); + /* DATATYPE */ + write_record_hdr(fob, DATATYPE, sizeof(uint16_t)); + write_word(fob, text.dtype); + /* TEXTTYPE */ write_record_hdr(fob, TEXTTYPE, sizeof(uint16_t)); - write_word(fob, text.dtype); + write_word(fob, text.ttype); /* PRESENTATION */ if ( text.has & HAS_PRESTN ) { @@ -894,9 +898,13 @@ write_node(FILE *fob, mxArray *data, double uu_to_dbu) write_record_hdr(fob, LAYER, sizeof(uint16_t)); write_word(fob, node.layer); + /* DATATYPE */ + write_record_hdr(fob, DATATYPE, sizeof(uint16_t)); + write_word(fob, node.dtype); + /* NODETYPE */ write_record_hdr(fob, NODETYPE, sizeof(uint16_t)); - write_word(fob, node.dtype); + write_word(fob, node.ntype); /* XY */ if ( get_field_ptr(data, "xy", &field) ) { @@ -956,9 +964,13 @@ write_box(FILE *fob, mxArray *data, double uu_to_dbu) write_record_hdr(fob, LAYER, sizeof(uint16_t)); write_word(fob, box.layer); + /* DATATYPE */ + write_record_hdr(fob, DATATYPE, sizeof(uint16_t)); + write_word(fob, box.dtype); + /* BOXTYPE */ write_record_hdr(fob, BOXTYPE, sizeof(uint16_t)); - write_word(fob, box.dtype); + write_word(fob, box.btype); /* XY */ if ( get_field_ptr(data, "xy", &field) ) { diff --git a/Basic/gdsio/gdstypes.h b/Basic/gdsio/gdstypes.h index 97f59ee..9bd6b4a 100644 --- a/Basic/gdsio/gdstypes.h +++ b/Basic/gdsio/gdstypes.h @@ -124,9 +124,12 @@ typedef struct { unsigned int has; /* element property flags */ uint16_t elflags; uint16_t layer; - uint16_t dtype; /* [data|text|node|box] type */ + uint16_t dtype; /* data type */ uint16_t ptype; /* path type */ - uint16_t present; /* presentation */ + uint16_t ttype; /* text type */ + uint16_t ntype; /* node type */ + uint16_t btype; /* box type */ + uint16_t present; /* text presentation */ uint16_t nrow; uint16_t ncol; int32_t plex;