From b933c9976fc4a4da73d10dbad5193ebabdec2695 Mon Sep 17 00:00:00 2001 From: Werner Almesberger Date: Sat, 30 Jul 2016 21:33:36 -0300 Subject: [PATCH] sch2fig/fig.h (enum fig_shape): move to dwg.h and rename --- sch2fig/dwg.c | 22 +++++++++++----------- sch2fig/dwg.h | 15 ++++++++++++--- sch2fig/fig.h | 9 --------- sch2fig/sch.c | 28 ++++++++++++++-------------- sch2fig/sch.h | 5 +++-- 5 files changed, 40 insertions(+), 39 deletions(-) diff --git a/sch2fig/dwg.c b/sch2fig/dwg.c index 4ce2f79..ecef942 100644 --- a/sch2fig/dwg.c +++ b/sch2fig/dwg.c @@ -53,7 +53,7 @@ static enum box_type flip_box(enum box_type box) void dwg_label(int x, int y, const char *s, int dir, int dim, - enum fig_shape shape) + enum dwg_shape shape) { struct text txt = { .s = s, @@ -98,7 +98,7 @@ void dwg_label(int x, int y, const char *s, int dir, int dim, void dwg_glabel(int x, int y, const char *s, int dir, int dim, - enum fig_shape shape) + enum dwg_shape shape) { struct text txt = { .s = s, @@ -118,16 +118,16 @@ void dwg_glabel(int x, int y, const char *s, int dir, int dim, bool anchor_right = 1; switch (shape) { - case fig_unspec: + case dwg_unspec: box = box_simple; break; - case fig_in: + case dwg_in: box = box_right; break; - case fig_out: + case dwg_out: box = box_left; break; - case fig_bidir: + case dwg_bidir: box = box_both; break; default: @@ -291,7 +291,7 @@ static int make_box(enum box_type box, int h, int *vx, int *vy) void dwg_hlabel(int x, int y, const char *s, int dir, int dim, - enum fig_shape shape) + enum dwg_shape shape) { struct text txt = { .s = s, @@ -307,16 +307,16 @@ void dwg_hlabel(int x, int y, const char *s, int dir, int dim, int n, i; switch (shape) { - case fig_unspec: + case dwg_unspec: n = make_box(box_simple, dim, vx, vy); break; - case fig_in: + case dwg_in: n = make_box(box_left, dim, vx, vy); break; - case fig_out: + case dwg_out: n = make_box(box_right, dim, vx, vy); break; - case fig_bidir: + case dwg_bidir: n = make_box(box_both, dim, vx, vy); break; default: diff --git a/sch2fig/dwg.h b/sch2fig/dwg.h index 35c1464..7a1abf8 100644 --- a/sch2fig/dwg.h +++ b/sch2fig/dwg.h @@ -17,12 +17,21 @@ #include "fig.h" +enum dwg_shape { + dwg_unspec, // UnSpc + dwg_in, // Input + dwg_out, // Output + dwg_tri, // 3State + dwg_bidir, // Bidirectional +}; + + void dwg_label(int x, int y, const char *s, int dir, int dim, - enum fig_shape shape); + enum dwg_shape shape); void dwg_hlabel(int x, int y, const char *s, int dir, int dim, - enum fig_shape shape); + enum dwg_shape shape); void dwg_glabel(int x, int y, const char *s, int dir, int dim, - enum fig_shape shape); + enum dwg_shape shape); void dwg_junction(int x, int y); void dwg_noconn(int x, int y); diff --git a/sch2fig/fig.h b/sch2fig/fig.h index 2669323..5d3608e 100644 --- a/sch2fig/fig.h +++ b/sch2fig/fig.h @@ -17,15 +17,6 @@ #include "text.h" -enum fig_shape { - fig_unspec, // UnSpc - fig_in, // Input - fig_out, // Output - fig_tri, // 3State - fig_bidir, // Bidirectional -}; - - /* schematics */ void fig_line(int sx, int sy, int ex, int ey); diff --git a/sch2fig/sch.c b/sch2fig/sch.c index 7972c6d..e0ece45 100644 --- a/sch2fig/sch.c +++ b/sch2fig/sch.c @@ -31,26 +31,26 @@ /* ----- (Global) Labels --------------------------------------------------- */ -static enum fig_shape do_decode_shape(const char *s) +static enum dwg_shape do_decode_shape(const char *s) { if (!strcmp(s, "UnSpc")) - return fig_unspec; + return dwg_unspec; if (!strcmp(s, "Input")) - return fig_in; + return dwg_in; if (!strcmp(s, "Output")) - return fig_out; + return dwg_out; if (!strcmp(s, "3State")) - return fig_tri; + return dwg_tri; if (!strcmp(s, "BiDi")) - return fig_bidir; + return dwg_bidir; fprintf(stderr, "unknown shape: \"%s\"\n", s); exit(1); } -static enum fig_shape decode_shape(const char *s) +static enum dwg_shape decode_shape(const char *s) { - enum fig_shape res; + enum dwg_shape res; res = do_decode_shape(s); free((void *) s); @@ -62,7 +62,7 @@ static enum fig_shape decode_shape(const char *s) static void draw_text(int x, int y, const char *s, int dir, int dim, - enum fig_shape shape) + enum dwg_shape shape) { struct text txt = { .s = s, @@ -259,19 +259,19 @@ static void dump_fields(struct sch_field *fields, int m[6]) /* ----- Sheet field ------------------------------------------------------- */ -static enum fig_shape decode_form(char form) +static enum dwg_shape decode_form(char form) { switch (form) { case 'O': - return fig_in; + return dwg_in; case 'I': - return fig_out; + return dwg_out; case 'B': /* fall through */ case 'T': - return fig_bidir; + return dwg_bidir; case 'U': - return fig_unspec; + return dwg_unspec; default: fprintf(stderr, "unknown form: \"%c\"\n", form); exit(1); diff --git a/sch2fig/sch.h b/sch2fig/sch.h index 1eca4a8..f0f5604 100644 --- a/sch2fig/sch.h +++ b/sch2fig/sch.h @@ -16,6 +16,7 @@ #include +#include "dwg.h" #include "text.h" #include "lib.h" @@ -40,10 +41,10 @@ struct sch_ctx { /* text */ void (*text)(int x, int y, const char *s, int dir, int dim, - enum fig_shape shape); + enum dwg_shape shape); int dir; /* orientation */ int dim; /* dimension */ - enum fig_shape shape; + enum dwg_shape shape; /* component */