Skip to content

Commit

Permalink
- all element types except sref and aref now have the datatype (dtype)
Browse files Browse the repository at this point in the history
  property, which seems to be common practice (thanks to Eng Wen Ong
  for pointing it out).
  • Loading branch information
ulfgri committed Jun 1, 2019
1 parent b2076d9 commit 5c6fcda
Show file tree
Hide file tree
Showing 12 changed files with 137 additions and 102 deletions.
25 changes: 10 additions & 15 deletions Basic/@gds_element/gds_element.m
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -30,28 +30,24 @@
% 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:
% ============================
%
% Boundary element:
% -----------------
% 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
Expand All @@ -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:
% -------------
Expand All @@ -76,18 +72,17 @@
% -------------
% 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.
% horj : horizontal justification. 0 = left, 1
% = 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):
% ----------------
Expand Down
18 changes: 6 additions & 12 deletions Basic/@gds_element/private/el_hash.h
Original file line number Diff line number Diff line change
@@ -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' */

Expand Down Expand Up @@ -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 <bug-gnu-gperf@gnu.org>."
#error "gperf generated tables don't work with this execution character set. Please report a bug to <bug-gperf@gnu.org>."
#endif

#line 1 "el_hash.gperf"
Expand Down Expand Up @@ -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[] =
{
Expand Down Expand Up @@ -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[] =
{
Expand All @@ -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;

Expand Down
55 changes: 49 additions & 6 deletions Basic/@gds_element/private/get_element_data.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
}


Expand All @@ -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();
Expand All @@ -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();
Expand Down
6 changes: 3 additions & 3 deletions Basic/@gds_element/private/get_prop_hash.gperf
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
24 changes: 9 additions & 15 deletions Basic/@gds_element/private/get_prop_hash.h
Original file line number Diff line number Diff line change
@@ -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' */

Expand Down Expand Up @@ -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 <bug-gnu-gperf@gnu.org>."
#error "gperf generated tables don't work with this execution character set. Please report a bug to <bug-gperf@gnu.org>."
#endif

#line 1 "get_prop_hash.gperf"
Expand Down Expand Up @@ -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[] =
{
Expand Down Expand Up @@ -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[] =
{
Expand All @@ -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"
Expand All @@ -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},
Expand All @@ -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;

Expand Down
18 changes: 6 additions & 12 deletions Basic/@gds_element/private/has_hash.h
Original file line number Diff line number Diff line change
@@ -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' */

Expand Down Expand Up @@ -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 <bug-gnu-gperf@gnu.org>."
#error "gperf generated tables don't work with this execution character set. Please report a bug to <bug-gperf@gnu.org>."
#endif

#line 1 "has_hash.gperf"
Expand Down Expand Up @@ -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[] =
{
Expand Down Expand Up @@ -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[] =
{
Expand Down Expand Up @@ -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;

Expand Down
Loading

0 comments on commit 5c6fcda

Please sign in to comment.