1
0
mirror of git://projects.qi-hardware.com/eda-tools.git synced 2024-11-23 02:22:49 +02:00

eeshow/sch.h, sch-parse.c: add pointer to sub-sheet to obj.u.sheet

This commit is contained in:
Werner Almesberger 2016-08-03 11:53:03 -03:00
parent 48327e149b
commit 95bc0f06fd
2 changed files with 18 additions and 5 deletions

View File

@ -262,7 +262,7 @@ static bool parse_hsheet_field(struct sch_ctx *ctx, const char *line)
/* ----- Schematics parser ------------------------------------------------- */
static void submit_obj(struct sch_ctx *ctx, enum sch_obj_type type)
static struct sch_obj *submit_obj(struct sch_ctx *ctx, enum sch_obj_type type)
{
struct sch_obj *obj;
@ -273,6 +273,8 @@ static void submit_obj(struct sch_ctx *ctx, enum sch_obj_type type)
*ctx->curr_sheet->next_obj = obj;
ctx->curr_sheet->next_obj = &obj->next;
return obj;
}
@ -305,17 +307,21 @@ static void end_sheet(struct sch_ctx *ctx)
static bool parse_line(const struct file *file, void *user, const char *line);
static void recurse_sheet(struct sch_ctx *ctx, const struct file *related)
static const struct sheet *recurse_sheet(struct sch_ctx *ctx,
const struct file *related)
{
const char *name = ctx->obj.u.sheet.file;
const struct sheet *sheet;
struct file file;
new_sheet(ctx);
sheet = new_sheet(ctx);
ctx->state = sch_descr;
file_open(&file, name, related);
file_read(&file, parse_line, ctx);
file_close(&file);
end_sheet(ctx);
return sheet;
}
@ -339,6 +345,7 @@ static bool parse_line(const struct file *file, void *user, const char *line)
obj->u.sheet.file = NULL;
obj->u.sheet.rotated = 0;
obj->u.sheet.fields = NULL;
obj->u.sheet.sheet = NULL;
return 1;
}
@ -470,8 +477,11 @@ static bool parse_line(const struct file *file, void *user, const char *line)
break;
case sch_sheet:
if (sscanf(line, "$EndSheet%n", &n) == 0 && n) {
submit_obj(ctx, sch_obj_sheet);
struct sch_obj *sheet_obj;
sheet_obj = submit_obj(ctx, sch_obj_sheet);
if (ctx->recurse)
sheet_obj->u.sheet.sheet =
recurse_sheet(ctx, file);
ctx->state = sch_basic;
return 1;

View File

@ -31,6 +31,8 @@ enum sch_state {
sch_wire, /* wire */
};
struct sheet;
struct sch_obj {
enum sch_obj_type {
sch_obj_wire,
@ -72,6 +74,7 @@ struct sch_obj {
const char *file;
unsigned file_dim;
bool rotated;
const struct sheet *sheet; /* pointer to sub-sheet */
struct sheet_field {
char *s;