mirror of
git://projects.qi-hardware.com/eda-tools.git
synced 2024-11-26 14:04:39 +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:
parent
b781bd6fc8
commit
49a32f38e2
@ -30,45 +30,45 @@ enum text_style {
|
||||
text_normal,
|
||||
};
|
||||
|
||||
struct obj {
|
||||
enum obj_type {
|
||||
obj_poly,
|
||||
obj_rect,
|
||||
obj_circ,
|
||||
obj_arc,
|
||||
obj_text,
|
||||
obj_pin,
|
||||
struct lib_obj {
|
||||
enum lib_obj_type {
|
||||
lib_obj_poly,
|
||||
lib_obj_rect,
|
||||
lib_obj_circ,
|
||||
lib_obj_arc,
|
||||
lib_obj_text,
|
||||
lib_obj_pin,
|
||||
} type;
|
||||
unsigned unit;
|
||||
unsigned convert;
|
||||
union {
|
||||
struct poly_obj {
|
||||
struct lib_poly {
|
||||
int thick;
|
||||
char fill;
|
||||
int points;
|
||||
int *x;
|
||||
int *y;
|
||||
} poly;
|
||||
struct rect_obj {
|
||||
struct lib_rect {
|
||||
int thick;
|
||||
char fill;
|
||||
int sx, sy;
|
||||
int ex, ey;
|
||||
} rect;
|
||||
struct circ_obj {
|
||||
struct lib_circ {
|
||||
int x, y;
|
||||
int r;
|
||||
int thick;
|
||||
char fill;
|
||||
} circ;
|
||||
struct arc_obj {
|
||||
struct lib_arc {
|
||||
int x, y;
|
||||
int r;
|
||||
int start_a, end_a;
|
||||
int thick;
|
||||
char fill;
|
||||
} arc;
|
||||
struct text_obj {
|
||||
struct lib_text {
|
||||
int orient;
|
||||
int x, y;
|
||||
int dim;
|
||||
@ -77,7 +77,7 @@ struct obj {
|
||||
char hor_align;
|
||||
char vert_align;
|
||||
} text;
|
||||
struct pin_obj {
|
||||
struct lib_pin {
|
||||
char *name;
|
||||
char *number;
|
||||
int x, y;
|
||||
@ -89,7 +89,7 @@ struct obj {
|
||||
// @@@ shape
|
||||
} pin;
|
||||
} u;
|
||||
struct obj *next;
|
||||
struct lib_obj *next;
|
||||
};
|
||||
|
||||
|
||||
@ -99,10 +99,10 @@ struct obj {
|
||||
static struct comp *comps = NULL;
|
||||
static struct comp *curr_comp; /* current component */
|
||||
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 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 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 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 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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
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])
|
||||
{
|
||||
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 = {
|
||||
.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) {
|
||||
case obj_poly:
|
||||
case lib_obj_poly:
|
||||
draw_poly(&obj->u.poly, m);
|
||||
break;
|
||||
case obj_rect:
|
||||
case lib_obj_rect:
|
||||
draw_rect(&obj->u.rect, m);
|
||||
break;
|
||||
case obj_circ:
|
||||
case lib_obj_circ:
|
||||
draw_circ(&obj->u.circ, m);
|
||||
break;
|
||||
case obj_arc:
|
||||
case lib_obj_arc:
|
||||
draw_arc(&obj->u.arc, m);
|
||||
break;
|
||||
case obj_text:
|
||||
case lib_obj_text:
|
||||
draw_text(&obj->u.text, m);
|
||||
break;
|
||||
case obj_pin:
|
||||
case lib_obj_pin:
|
||||
draw_pin(comp, &obj->u.pin, m);
|
||||
break;
|
||||
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])
|
||||
{
|
||||
const struct obj *obj;
|
||||
const struct lib_obj *obj;
|
||||
|
||||
if (!unit)
|
||||
unit = 1;
|
||||
@ -484,7 +485,7 @@ static enum text_style decode_style(const char *s)
|
||||
/* ----- 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;
|
||||
|
||||
@ -542,9 +543,9 @@ static bool parse_def(const char *line)
|
||||
/* ----- 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;
|
||||
|
||||
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;
|
||||
unsigned points;
|
||||
struct obj *obj;
|
||||
struct lib_obj *obj;
|
||||
char *style;
|
||||
unsigned zero1, zero2;
|
||||
char vis;
|
||||
@ -617,7 +618,7 @@ bool lib_parse(struct lib_ctx *ctx, const char *line)
|
||||
return 1;
|
||||
}
|
||||
|
||||
obj = alloc_type(struct obj);
|
||||
obj = alloc_type(struct lib_obj);
|
||||
obj->next = NULL;
|
||||
*next_obj = obj;
|
||||
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",
|
||||
&points, &obj->unit, &obj->convert, &obj->u.poly.thick,
|
||||
&n) == 4) {
|
||||
obj->type = obj_poly;
|
||||
obj->type = lib_obj_poly;
|
||||
if (parse_poly(&obj->u.poly, line + n, points))
|
||||
return 1;
|
||||
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.ey, &obj->unit, &obj->convert,
|
||||
&obj->u.rect.thick, &obj->u.rect.fill) == 8) {
|
||||
obj->type = obj_rect;
|
||||
obj->type = lib_obj_rect;
|
||||
return 1;
|
||||
}
|
||||
if (sscanf(line, "C %d %d %d %u %u %d %c",
|
||||
&obj->u.circ.x, &obj->u.circ.y, &obj->u.circ.r,
|
||||
&obj->unit, &obj->convert, &obj->u.circ.thick,
|
||||
&obj->u.circ.fill) == 7) {
|
||||
obj->type = obj_circ;
|
||||
obj->type = lib_obj_circ;
|
||||
return 1;
|
||||
}
|
||||
if (parse_arc(obj, line)) {
|
||||
obj->type = obj_arc;
|
||||
obj->type = lib_obj_arc;
|
||||
return 1;
|
||||
}
|
||||
n = sscanf(line,
|
||||
@ -680,7 +681,7 @@ bool lib_parse(struct lib_ctx *ctx, const char *line)
|
||||
exit(1);
|
||||
}
|
||||
obj->u.text.style = decode_style(style);
|
||||
obj->type = obj_text;
|
||||
obj->type = lib_obj_text;
|
||||
return 1;
|
||||
}
|
||||
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.number_size, &obj->u.pin.name_size,
|
||||
&obj->unit, &obj->convert, &obj->u.pin.etype) == 11) {
|
||||
obj->type = obj_pin;
|
||||
obj->type = lib_obj_pin;
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
|
@ -28,7 +28,7 @@ struct lib_ctx {
|
||||
unsigned lineno;
|
||||
};
|
||||
|
||||
struct obj;
|
||||
struct lib_obj;
|
||||
|
||||
struct comp {
|
||||
const char *name;
|
||||
@ -39,7 +39,7 @@ struct comp {
|
||||
bool show_pin_num;
|
||||
unsigned name_offset;
|
||||
|
||||
struct obj *objs;
|
||||
struct lib_obj *objs;
|
||||
struct comp *next;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user