Date:2010-04-27 03:02:24 (9 years 3 months ago)
Author:werner
Commit:82a12023cdc81c3a4768ac8339b28f3a561272de
Message:I thought there was a bug in frame ordering, but it turns out that it works fine. Anyway, here's a new debug construct (%frame) and a bunch of new regression tests.

- fpd.y, fpd.l, README: added new directive %frame to link frames also to other
frames than the current one (like in the GUI)
- gui_tool.h, gui_tool.c: export is_parent_of
- test/frame_ref: regression tests to ensure that frame order remains valid,
even if we reference late from early frames



git-svn-id: http://svn.openmoko.org/trunk/eda/fped@5945 99fdad57-331a-0410-800a-d7fa5415bdb3
Files: README (2 diffs)
fpd.l (1 diff)
fpd.y (6 diffs)
gui_tool.c (1 diff)
gui_tool.h (1 diff)
test/frame_ref (1 diff)

Change Details

README
590590
591591%del <identifier>
592592%move <identifier> [<number>] <identifier>
593%frame <identifier> <qualified-base>
593594%print <expression>
594595%dump
595596%exit
...... 
6106111 - second point end of arc high point
6116122 - - start of arc -
612613
614%frame creates a frame reference. Unlike "frame", the destination frame
615can be different from the current frame. E.g., "%frame foo bar.a" would
616add a reference to frame "foo" in frame "bar", rooted at vector "a". The
617parent frame's origin can be references as "@".
618
613619%dump writes the footprint definition in the fped language to standard
614620output. %exit immediately exits fped, without invoking the GUI.
615621
fpd.l
127127                  return TOK_DBG_DEL; }
128128<INITIAL>"%move" { BEGIN(NOKEYWORD);
129129                  return TOK_DBG_MOVE; }
130<INITIAL>"%frame" { BEGIN(NOKEYWORD);
131                  return TOK_DBG_FRAME; }
130132<INITIAL>"%print" { BEGIN(NOKEYWORD);
131133                  return TOK_DBG_PRINT; }
132134<INITIAL>"%dump" { BEGIN(NOKEYWORD);
fpd.y
234234}
235235
236236
237/*
238 * @@@ This is very similar to what we do in rule "obj". Consider merging.
239 */
240
241static int dbg_link_frame(const char *frame_name,
242    struct frame *base_frame, struct vec *base_vec)
243{
244    struct frame *frame;
245    struct obj *obj;
246
247    frame = find_frame(frame_name);
248    if (!frame) {
249        yyerrorf("unknown frame \"%s\"", frame_name);
250        return 0;
251    }
252    /* this can only fail in %frame */
253    if (is_parent_of(frame, base_frame)) {
254        yyerrorf("frame \"%s\" is a parent of \"%s\"",
255            frame->name, base_frame->name);
256        return 0;
257    }
258    obj = new_obj(ot_frame);
259    obj->base = base_vec;
260    obj->frame = base_frame;
261    obj->u.frame.ref = frame;
262    connect_obj(base_frame, obj);
263    if (!frame->active_ref)
264        frame->active_ref = obj;
265    return 1;
266}
267
268
237269static int dbg_print(const struct expr *expr)
238270{
239271    const char *s;
...... 
283315        int inverted;
284316        int max;
285317    } mo;
318    struct {
319        struct frame *frame;
320        struct vec *vec;
321    } qvec;
286322};
287323
288324
...... 
291327%token TOK_PAD TOK_RPAD TOK_HOLE TOK_RECT TOK_LINE TOK_CIRC TOK_ARC
292328%token TOK_MEAS TOK_MEASX TOK_MEASY TOK_UNIT
293329%token TOK_NEXT TOK_NEXT_INVERTED TOK_MAX TOK_MAX_INVERTED
294%token TOK_DBG_DEL TOK_DBG_MOVE TOK_DBG_PRINT TOK_DBG_DUMP
295%token TOK_DBG_EXIT TOK_DBG_TSORT
330%token TOK_DBG_DEL TOK_DBG_MOVE TOK_DBG_FRAME TOK_DBG_PRINT
331%token TOK_DBG_DUMP TOK_DBG_EXIT TOK_DBG_TSORT
296332
297333%token <num> NUMBER
298334%token <str> STRING
...... 
306342%type <obj> object obj meas
307343%type <expr> expr opt_expr add_expr mult_expr unary_expr primary_expr
308344%type <num> opt_num
345%type <frame> frame_qualifier
309346%type <str> opt_string
310347%type <pt> pad_type
311348%type <mt> meas_type
312349%type <mo> meas_op
350%type <qvec> qualified_base
313351
314352%%
315353
...... 
468506            if (!dbg_move($2, $3.n, $4))
469507                YYABORT;
470508        }
509    | TOK_DBG_FRAME ID qualified_base
510        {
511            if (!dbg_link_frame($2, $3.frame, $3.vec))
512                YYABORT;
513        }
471514    | TOK_DBG_PRINT expr
472515        {
473516            if (!dbg_print($2))
...... 
672715        }
673716    ;
674717
718qualified_base:
719    base
720        {
721            $$.frame = curr_frame;
722            $$.vec = $1;
723        }
724    | frame_qualifier '@'
725        {
726            $$.frame = $1;
727            $$.vec = NULL;
728        }
729    | frame_qualifier ID
730        {
731            $$.frame = $1;
732            $$.vec = find_vec($1, $2);
733            if (!$$.vec) {
734                yyerrorf("unknown vector \"%s.%s\"",
735                    $1->name, $2);
736                YYABORT;
737            }
738        }
739    ;
740
741frame_qualifier:
742    ID '.'
743        {
744            $$ = find_frame($1);
745            if (!$$) {
746                yyerrorf("unknown frame \"%s\"", $1);
747                YYABORT;
748            }
749        }
750    ;
751
675752object:
676753    obj
677754        {
gui_tool.c
603603/* ----- frame helper ------------------------------------------------------ */
604604
605605
606static int is_parent_of(const struct frame *p, const struct frame *c)
606int is_parent_of(const struct frame *p, const struct frame *c)
607607{
608608    const struct obj *obj;
609609
gui_tool.h
6262
6363struct obj *new_obj_unconnected(enum obj_type type, struct inst *base);
6464void connect_obj(struct frame *frame, struct obj *obj);
65int is_parent_of(const struct frame *p, const struct frame *c);
66
6567struct pix_buf *draw_move_line_common(struct inst *inst,
6668    struct coord end, struct coord pos, int i);
6769struct pix_buf *drag_new_line(struct inst *from, struct coord to);
test/frame_ref
1#!/bin/sh
2. ./Common
3
4###############################################################################
5
6fped_dump "frame reference: with \"frame\" (origin)" <<EOF
7frame f {}
8frame f @
9EOF
10expect <<EOF
11/* MACHINE-GENERATED ! */
12
13frame f {
14}
15
16package "_"
17unit mm
18frame f @
19EOF
20
21#------------------------------------------------------------------------------
22
23fped_dump "frame reference: with \"%frame\" (current frame origin)" <<EOF
24frame f {}
25%frame f @
26EOF
27expect <<EOF
28/* MACHINE-GENERATED ! */
29
30frame f {
31}
32
33package "_"
34unit mm
35frame f @
36EOF
37
38#------------------------------------------------------------------------------
39
40fped_dump "frame reference: with \"%frame\" (current frame vector)" <<EOF
41frame f {}
42v: vec @(0mm, 0mm)
43%frame f v
44EOF
45expect <<EOF
46/* MACHINE-GENERATED ! */
47
48frame f {
49}
50
51package "_"
52unit mm
53v: vec @(0mm, 0mm)
54frame f .
55EOF
56
57#------------------------------------------------------------------------------
58
59fped_dump "frame reference: with \"%frame\" (other frame origin)" <<EOF
60frame f {}
61frame g {}
62%frame f g.@
63EOF
64expect <<EOF
65/* MACHINE-GENERATED ! */
66
67frame f {
68}
69
70frame g {
71    frame f @
72}
73
74package "_"
75unit mm
76EOF
77
78#------------------------------------------------------------------------------
79
80fped_dump "frame reference: with \"%frame\" (other frame base)" <<EOF
81frame f {}
82frame g {
83    v: vec @(0mm, 0mm)
84}
85%frame f g.v
86EOF
87expect <<EOF
88/* MACHINE-GENERATED ! */
89
90frame f {
91}
92
93frame g {
94    v: vec @(0mm, 0mm)
95    frame f .
96}
97
98package "_"
99unit mm
100EOF
101
102#------------------------------------------------------------------------------
103
104fped_fail "frame reference: with \"%frame\" (cycle)" <<EOF
105frame f {
106}
107
108frame g {
109    frame f @
110}
111
112%frame g f.@
113EOF
114expect <<EOF
1158: frame "g" is a parent of "f" near "@"
116EOF
117
118#------------------------------------------------------------------------------
119
120fped_dump "frame reference: with \"%frame\" (out-of-order)" <<EOF
121frame f {
122}
123
124frame g {
125}
126
127%frame g f.@
128EOF
129expect <<EOF
130/* MACHINE-GENERATED ! */
131
132frame g {
133}
134
135frame f {
136    frame g @
137}
138
139package "_"
140unit mm
141EOF
142
143###############################################################################

Archive Download the corresponding diff file

Branches:
master



interactive