1
0
mirror of git://projects.qi-hardware.com/eda-tools.git synced 2024-11-30 02:03:45 +02:00

sch2fig/lib.c (struct lib_obj), lib.h: prefix externally visible names with lib_

Where "externally" = "in the compilation unit".
This will soon become global.
This commit is contained in:
Werner Almesberger 2016-07-31 14:26:46 -03:00
parent b781bd6fc8
commit 49a32f38e2
2 changed files with 46 additions and 45 deletions

View File

@ -30,45 +30,45 @@ enum text_style {
text_normal, text_normal,
}; };
struct obj { struct lib_obj {
enum obj_type { enum lib_obj_type {
obj_poly, lib_obj_poly,
obj_rect, lib_obj_rect,
obj_circ, lib_obj_circ,
obj_arc, lib_obj_arc,
obj_text, lib_obj_text,
obj_pin, lib_obj_pin,
} type; } type;
unsigned unit; unsigned unit;
unsigned convert; unsigned convert;
union { union {
struct poly_obj { struct lib_poly {
int thick; int thick;
char fill; char fill;
int points; int points;
int *x; int *x;
int *y; int *y;
} poly; } poly;
struct rect_obj { struct lib_rect {
int thick; int thick;
char fill; char fill;
int sx, sy; int sx, sy;
int ex, ey; int ex, ey;
} rect; } rect;
struct circ_obj { struct lib_circ {
int x, y; int x, y;
int r; int r;
int thick; int thick;
char fill; char fill;
} circ; } circ;
struct arc_obj { struct lib_arc {
int x, y; int x, y;
int r; int r;
int start_a, end_a; int start_a, end_a;
int thick; int thick;
char fill; char fill;
} arc; } arc;
struct text_obj { struct lib_text {
int orient; int orient;
int x, y; int x, y;
int dim; int dim;
@ -77,7 +77,7 @@ struct obj {
char hor_align; char hor_align;
char vert_align; char vert_align;
} text; } text;
struct pin_obj { struct lib_pin {
char *name; char *name;
char *number; char *number;
int x, y; int x, y;
@ -89,7 +89,7 @@ struct obj {
// @@@ shape // @@@ shape
} pin; } pin;
} u; } u;
struct obj *next; struct lib_obj *next;
}; };
@ -99,10 +99,10 @@ struct obj {
static struct comp *comps = NULL; static struct comp *comps = NULL;
static struct comp *curr_comp; /* current component */ static struct comp *curr_comp; /* current component */
static struct comp **next_comp = &comps; static struct comp **next_comp = &comps;
static struct obj **next_obj; static struct lib_obj **next_obj;
static void draw_poly(const struct poly_obj *poly, const int m[6]) static void draw_poly(const struct lib_poly *poly, const int m[6])
{ {
int n = poly->points; int n = poly->points;
int x[n]; int x[n];
@ -133,7 +133,7 @@ static void draw_poly(const struct poly_obj *poly, const int m[6])
} }
static void draw_rect(const struct rect_obj *rect, const int m[6]) static void draw_rect(const struct lib_rect *rect, const int m[6])
{ {
int sx = mx(rect->sx, rect->sy, m); int sx = mx(rect->sx, rect->sy, m);
int sy = my(rect->sx, rect->sy, m); int sy = my(rect->sx, rect->sy, m);
@ -159,7 +159,7 @@ static void draw_rect(const struct rect_obj *rect, const int m[6])
} }
static void draw_circ(const struct circ_obj *circ, const int m[6]) static void draw_circ(const struct lib_circ *circ, const int m[6])
{ {
int x = mx(circ->x, circ->y, m); int x = mx(circ->x, circ->y, m);
int y = my(circ->x, circ->y, m); int y = my(circ->x, circ->y, m);
@ -184,7 +184,7 @@ static void draw_circ(const struct circ_obj *circ, const int m[6])
} }
static void draw_arc(const struct arc_obj *arc, const int m[6]) static void draw_arc(const struct lib_arc *arc, const int m[6])
{ {
int a = matrix_to_angle(m); int a = matrix_to_angle(m);
int x = mx(arc->x, arc->y, m); int x = mx(arc->x, arc->y, m);
@ -212,7 +212,7 @@ static void draw_arc(const struct arc_obj *arc, const int m[6])
} }
static void draw_pin_name(const struct comp *comp, const struct pin_obj *pin, static void draw_pin_name(const struct comp *comp, const struct lib_pin *pin,
const int m[6], int dx, int dy, int rot, enum text_align hor) const int m[6], int dx, int dy, int rot, enum text_align hor)
{ {
int ox, oy, sx, sy; int ox, oy, sx, sy;
@ -263,7 +263,7 @@ static void draw_pin_name(const struct comp *comp, const struct pin_obj *pin,
} }
static void draw_pin_num(const struct comp *comp, const struct pin_obj *pin, static void draw_pin_num(const struct comp *comp, const struct lib_pin *pin,
const int m[6], int dx, int dy, int rot, enum text_align hor) const int m[6], int dx, int dy, int rot, enum text_align hor)
{ {
int ox, oy, sx, sy; int ox, oy, sx, sy;
@ -322,7 +322,7 @@ static void draw_pin_num(const struct comp *comp, const struct pin_obj *pin,
} }
static void draw_pin(const struct comp *comp, const struct pin_obj *pin, static void draw_pin(const struct comp *comp, const struct lib_pin *pin,
const int m[6]) const int m[6])
{ {
int x[2], y[2]; int x[2], y[2];
@ -368,7 +368,7 @@ static void draw_pin(const struct comp *comp, const struct pin_obj *pin,
} }
static void draw_text(const struct text_obj *text, const int m[6]) static void draw_text(const struct lib_text *text, const int m[6])
{ {
struct text txt = { struct text txt = {
.s = text->s, .s = text->s,
@ -411,25 +411,26 @@ static void draw_text(const struct text_obj *text, const int m[6])
} }
static void draw(const struct comp *comp, const struct obj *obj, const int m[6]) static void draw(const struct comp *comp, const struct lib_obj *obj,
const int m[6])
{ {
switch (obj->type) { switch (obj->type) {
case obj_poly: case lib_obj_poly:
draw_poly(&obj->u.poly, m); draw_poly(&obj->u.poly, m);
break; break;
case obj_rect: case lib_obj_rect:
draw_rect(&obj->u.rect, m); draw_rect(&obj->u.rect, m);
break; break;
case obj_circ: case lib_obj_circ:
draw_circ(&obj->u.circ, m); draw_circ(&obj->u.circ, m);
break; break;
case obj_arc: case lib_obj_arc:
draw_arc(&obj->u.arc, m); draw_arc(&obj->u.arc, m);
break; break;
case obj_text: case lib_obj_text:
draw_text(&obj->u.text, m); draw_text(&obj->u.text, m);
break; break;
case obj_pin: case lib_obj_pin:
draw_pin(comp, &obj->u.pin, m); draw_pin(comp, &obj->u.pin, m);
break; break;
default: default:
@ -458,7 +459,7 @@ bool lib_field_visible(const struct comp *comp, int n)
void lib_exec(const struct comp *comp, unsigned unit, const int m[4]) void lib_exec(const struct comp *comp, unsigned unit, const int m[4])
{ {
const struct obj *obj; const struct lib_obj *obj;
if (!unit) if (!unit)
unit = 1; unit = 1;
@ -484,7 +485,7 @@ static enum text_style decode_style(const char *s)
/* ----- Polygons ---------------------------------------------------------- */ /* ----- Polygons ---------------------------------------------------------- */
static bool parse_poly(struct poly_obj *poly, const char *line, int points) static bool parse_poly(struct lib_poly *poly, const char *line, int points)
{ {
int i, n; int i, n;
@ -542,9 +543,9 @@ static bool parse_def(const char *line)
/* ----- Arcs -------------------------------------------------------------- */ /* ----- Arcs -------------------------------------------------------------- */
static bool parse_arc(struct obj *obj, const char *line) static bool parse_arc(struct lib_obj *obj, const char *line)
{ {
struct arc_obj *arc = &obj->u.arc; struct lib_arc *arc = &obj->u.arc;
int a1, a2; int a1, a2;
if (sscanf(line, "A %d %d %d %d %d %u %u %u %c", if (sscanf(line, "A %d %d %d %d %d %u %u %u %c",
@ -583,7 +584,7 @@ bool lib_parse(struct lib_ctx *ctx, const char *line)
{ {
int n = 0; int n = 0;
unsigned points; unsigned points;
struct obj *obj; struct lib_obj *obj;
char *style; char *style;
unsigned zero1, zero2; unsigned zero1, zero2;
char vis; char vis;
@ -617,7 +618,7 @@ bool lib_parse(struct lib_ctx *ctx, const char *line)
return 1; return 1;
} }
obj = alloc_type(struct obj); obj = alloc_type(struct lib_obj);
obj->next = NULL; obj->next = NULL;
*next_obj = obj; *next_obj = obj;
next_obj = &obj->next; next_obj = &obj->next;
@ -625,7 +626,7 @@ bool lib_parse(struct lib_ctx *ctx, const char *line)
if (sscanf(line, "P %u %u %u %u %n", if (sscanf(line, "P %u %u %u %u %n",
&points, &obj->unit, &obj->convert, &obj->u.poly.thick, &points, &obj->unit, &obj->convert, &obj->u.poly.thick,
&n) == 4) { &n) == 4) {
obj->type = obj_poly; obj->type = lib_obj_poly;
if (parse_poly(&obj->u.poly, line + n, points)) if (parse_poly(&obj->u.poly, line + n, points))
return 1; return 1;
break; break;
@ -634,18 +635,18 @@ bool lib_parse(struct lib_ctx *ctx, const char *line)
&obj->u.rect.sx, &obj->u.rect.sy, &obj->u.rect.ex, &obj->u.rect.sx, &obj->u.rect.sy, &obj->u.rect.ex,
&obj->u.rect.ey, &obj->unit, &obj->convert, &obj->u.rect.ey, &obj->unit, &obj->convert,
&obj->u.rect.thick, &obj->u.rect.fill) == 8) { &obj->u.rect.thick, &obj->u.rect.fill) == 8) {
obj->type = obj_rect; obj->type = lib_obj_rect;
return 1; return 1;
} }
if (sscanf(line, "C %d %d %d %u %u %d %c", if (sscanf(line, "C %d %d %d %u %u %d %c",
&obj->u.circ.x, &obj->u.circ.y, &obj->u.circ.r, &obj->u.circ.x, &obj->u.circ.y, &obj->u.circ.r,
&obj->unit, &obj->convert, &obj->u.circ.thick, &obj->unit, &obj->convert, &obj->u.circ.thick,
&obj->u.circ.fill) == 7) { &obj->u.circ.fill) == 7) {
obj->type = obj_circ; obj->type = lib_obj_circ;
return 1; return 1;
} }
if (parse_arc(obj, line)) { if (parse_arc(obj, line)) {
obj->type = obj_arc; obj->type = lib_obj_arc;
return 1; return 1;
} }
n = sscanf(line, n = sscanf(line,
@ -680,7 +681,7 @@ bool lib_parse(struct lib_ctx *ctx, const char *line)
exit(1); exit(1);
} }
obj->u.text.style = decode_style(style); obj->u.text.style = decode_style(style);
obj->type = obj_text; obj->type = lib_obj_text;
return 1; return 1;
} }
if (sscanf(line, "X %ms %ms %d %d %d %c %d %d %u %u %c", if (sscanf(line, "X %ms %ms %d %d %d %c %d %d %u %u %c",
@ -689,7 +690,7 @@ bool lib_parse(struct lib_ctx *ctx, const char *line)
&obj->u.pin.orient, &obj->u.pin.orient,
&obj->u.pin.number_size, &obj->u.pin.name_size, &obj->u.pin.number_size, &obj->u.pin.name_size,
&obj->unit, &obj->convert, &obj->u.pin.etype) == 11) { &obj->unit, &obj->convert, &obj->u.pin.etype) == 11) {
obj->type = obj_pin; obj->type = lib_obj_pin;
return 1; return 1;
} }
break; break;

View File

@ -28,7 +28,7 @@ struct lib_ctx {
unsigned lineno; unsigned lineno;
}; };
struct obj; struct lib_obj;
struct comp { struct comp {
const char *name; const char *name;
@ -39,7 +39,7 @@ struct comp {
bool show_pin_num; bool show_pin_num;
unsigned name_offset; unsigned name_offset;
struct obj *objs; struct lib_obj *objs;
struct comp *next; struct comp *next;
}; };