mirror of
git://projects.qi-hardware.com/eda-tools.git
synced 2024-11-26 22:57:30 +02:00
eeshow/sch.h, sch-parse.c: add pointer to sub-sheet to obj.u.sheet
This commit is contained in:
parent
48327e149b
commit
95bc0f06fd
@ -262,7 +262,7 @@ static bool parse_hsheet_field(struct sch_ctx *ctx, const char *line)
|
|||||||
/* ----- Schematics parser ------------------------------------------------- */
|
/* ----- 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;
|
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;
|
||||||
ctx->curr_sheet->next_obj = &obj->next;
|
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 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 char *name = ctx->obj.u.sheet.file;
|
||||||
|
const struct sheet *sheet;
|
||||||
struct file file;
|
struct file file;
|
||||||
|
|
||||||
new_sheet(ctx);
|
sheet = new_sheet(ctx);
|
||||||
ctx->state = sch_descr;
|
ctx->state = sch_descr;
|
||||||
file_open(&file, name, related);
|
file_open(&file, name, related);
|
||||||
file_read(&file, parse_line, ctx);
|
file_read(&file, parse_line, ctx);
|
||||||
file_close(&file);
|
file_close(&file);
|
||||||
end_sheet(ctx);
|
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.file = NULL;
|
||||||
obj->u.sheet.rotated = 0;
|
obj->u.sheet.rotated = 0;
|
||||||
obj->u.sheet.fields = NULL;
|
obj->u.sheet.fields = NULL;
|
||||||
|
obj->u.sheet.sheet = NULL;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -470,8 +477,11 @@ static bool parse_line(const struct file *file, void *user, const char *line)
|
|||||||
break;
|
break;
|
||||||
case sch_sheet:
|
case sch_sheet:
|
||||||
if (sscanf(line, "$EndSheet%n", &n) == 0 && n) {
|
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)
|
if (ctx->recurse)
|
||||||
|
sheet_obj->u.sheet.sheet =
|
||||||
recurse_sheet(ctx, file);
|
recurse_sheet(ctx, file);
|
||||||
ctx->state = sch_basic;
|
ctx->state = sch_basic;
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -31,6 +31,8 @@ enum sch_state {
|
|||||||
sch_wire, /* wire */
|
sch_wire, /* wire */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct sheet;
|
||||||
|
|
||||||
struct sch_obj {
|
struct sch_obj {
|
||||||
enum sch_obj_type {
|
enum sch_obj_type {
|
||||||
sch_obj_wire,
|
sch_obj_wire,
|
||||||
@ -72,6 +74,7 @@ struct sch_obj {
|
|||||||
const char *file;
|
const char *file;
|
||||||
unsigned file_dim;
|
unsigned file_dim;
|
||||||
bool rotated;
|
bool rotated;
|
||||||
|
const struct sheet *sheet; /* pointer to sub-sheet */
|
||||||
|
|
||||||
struct sheet_field {
|
struct sheet_field {
|
||||||
char *s;
|
char *s;
|
||||||
|
Loading…
Reference in New Issue
Block a user