Date:2010-04-28 00:36:46 (9 years 1 month ago)
Author:werner
Commit:ac535d6e03c221d389a798af55f096f92c9bf3ff
Message:Deleting things often left measurements behind. Fixed these bugs, enhanced %del to also delete frames and items in other frames than the current one, and added the corresponding regression tests.

- fpd.y, README: %del can now also delete frames
- test/del_frame: regression test for frame deletion
- fpd.y: moved all debug items into debug_item, so that they can be invoked
after defining measurements
- README: clarified that object labels aren't entirely hidden in the GUI
- delete.c (delete_references): also delete measurements referencing the frame
(test/del_frame)
- fpd.y (dbg_link_frame): described why we need base_frame in addition to
base_vec
- fpd.y, README: %del can now also reach into frames other than the current one
- delete.c (do_delete_vec): also delete references in the root frame, i.e.,
measurements (tests/del_vec)



git-svn-id: http://svn.openmoko.org/trunk/eda/fped@5947 99fdad57-331a-0410-800a-d7fa5415bdb3
Files: README (2 diffs)
delete.c (2 diffs)
fpd.y (4 diffs)
test/del_frame (1 diff)
test/del_vec (1 diff)

Change Details

README
588588For debugging and regression tests, fped supports the following commands,
589589most of which mimick the effect of GUI operations:
590590
591%del <identifier>
591%del <qualified-identifier>
592592%move <identifier> [<number>] <identifier>
593593%frame <identifier> <qualified-base>
594594%print <expression>
...... 
596596%exit
597597%tsort { -<id> | +<id> | <id-before> <id-after> [<number>] ... }
598598
599%del and %move take as their first argument the name of the vector or
600object to manipulate. For this purpose, also objects can be labeled.
599%del removes the specified item. This can be a vector, an object, or
600a frame. If the vector or object is in a different frame than the
601current, its name is qualified with the frame name, e.g., "foo.obj".
601602
602Object labels behave like vector labels and share the same name space.
603They are not shown anywhere in the GUI.
603For this purpose, also objects can be labeled. Object labels behave like
604vector labels and share the same name space. They are not normally
605accessible in the GUI. (You can see them in the code view.)
604606
605%move sets an anchor point to the vector named as its last argument.
606The anchor point is identified by index as follows:
607%move take as its first argument the name of the vector or object to
608manipulate. %move sets an anchor point to the vector named as its last
609argument. The anchor point is identified by index as follows:
607610
608611anchor index vec/frame line/rect/pad arc measurement
609612-------------- --------- ------------- ------------ -----------
delete.c
177177
178178    delete_vecs_by_ref(vec->frame->vecs, vec);
179179    delete_objs_by_ref(&vec->frame->objs, vec);
180    delete_objs_by_ref(&root_frame->objs, vec); /* catch measurements */
180181}
181182
182183
...... 
522523
523524    for (frame = frames; frame; frame = frame->next)
524525        for (obj = frame->objs; obj; obj = obj->next)
525            if (obj->type == ot_frame)
526            switch (obj->type) {
527            case ot_frame:
526528                if (obj->u.frame.ref == ref)
527529                    do_delete_obj(obj);
530                break;
531            case ot_meas:
532                if (obj->base->frame == ref ||
533                    obj->u.meas.high->frame == ref)
534                    do_delete_obj(obj);
535                break;
536            default:
537                break;
538            }
528539    for (obj = ref->objs; obj; obj = obj->next)
529540        if (obj->type == ot_frame)
530541            if (obj->u.frame.ref->active_ref == obj)
fpd.y
178178}
179179
180180
181static int dbg_delete(const char *name)
181static int dbg_delete(const char *frame_name, const char *name)
182182{
183183    struct vec *vec;
184184    struct obj *obj;
185    struct frame *frame;
185186
186    vec = find_vec(curr_frame, name);
187    if (!frame_name)
188        frame = curr_frame;
189    else {
190        frame = find_frame(frame_name);
191        if (!frame) {
192            yyerrorf("unknown frame \"%s\"", frame_name);
193            return 0;
194        }
195    }
196    vec = find_vec(frame, name);
187197    if (vec) {
188198        delete_vec(vec);
189199        return 1;
190200    }
191    obj = find_obj(curr_frame, name);
201    obj = find_obj(frame, name);
192202    if (obj) {
193203        delete_obj(obj);
194204        return 1;
195205    }
196    yyerrorf("unknown item \"%s\"", name);
206    if (!frame_name) {
207        frame = find_frame(name);
208        if (frame) {
209            if (curr_frame == frame) {
210                yyerrorf("a frame can't delete itself");
211                return 0;
212            }
213            if (last_frame == frame)
214                last_frame = frame->prev;
215            delete_frame(frame);
216            return 1;
217        }
218    }
219    if (frame_name)
220        yyerrorf("unknown item \"%s.%s\"", frame_name, name);
221    else
222        yyerrorf("unknown item \"%s\"", name);
197223    return 0;
198224}
199225
...... 
238264 * @@@ This is very similar to what we do in rule "obj". Consider merging.
239265 */
240266
267/*
268 * We need to pass base_frame and base_vec, not just the vector (with the
269 * frame implied) since we can also reference the frame's origin, whose
270 * "vector" is NULL.
271 */
272
241273static int dbg_link_frame(const char *frame_name,
242274    struct frame *base_frame, struct vec *base_vec)
243275{
244276    struct frame *frame;
245277    struct obj *obj;
246278
279    assert(!base_vec || base_vec->frame == base_frame);
247280    frame = find_frame(frame_name);
248281    if (!frame) {
249282        yyerrorf("unknown frame \"%s\"", frame_name);
...... 
496529            }
497530            $2->name = $1;
498531        }
499    | TOK_DBG_DEL ID
532    | debug_item
533    ;
534
535debug_item:
536    TOK_DBG_DEL ID
500537        {
501            if (!dbg_delete($2))
538            append_root_frame();
539            if (!dbg_delete(NULL, $2))
540                YYABORT;
541        }
542    | TOK_DBG_DEL ID '.' ID
543        {
544            append_root_frame();
545            if (!dbg_delete($2, $4))
502546                YYABORT;
503547        }
504548    | TOK_DBG_MOVE ID opt_num ID
...... 
516560            if (!dbg_print($2))
517561                YYABORT;
518562        }
519    | debug_item
520    ;
521
522debug_item:
523    TOK_DBG_DUMP
563    | TOK_DBG_DUMP
524564        {
525565            /*
526566             * It's okay to do append the root frame multiple
test/del_frame
1#!/bin/sh
2. ./Common
3
4###############################################################################
5
6fped_fail "delete frame: can't self-destruct" <<EOF
7frame f {
8    %del f
9}
10EOF
11expect <<EOF
123: a frame can't delete itself near "}"
13EOF
14
15#------------------------------------------------------------------------------
16
17fped_dump "delete frame: content disappears" <<EOF
18frame f {
19    vec @(0mm, 0mm)
20}
21
22%del f
23EOF
24expect <<EOF
25/* MACHINE-GENERATED ! */
26
27package "_"
28unit mm
29EOF
30
31#------------------------------------------------------------------------------
32
33fped_dump "delete frame: references disappear" <<EOF
34frame f {
35    vec @(0mm, 0mm)
36}
37
38frame f @
39
40%del f
41EOF
42expect <<EOF
43/* MACHINE-GENERATED ! */
44
45package "_"
46unit mm
47EOF
48
49#------------------------------------------------------------------------------
50
51fped_dump "delete frame: measurements disappear" <<EOF
52frame f {
53    v: vec @(0mm, 0mm)
54}
55
56meas f.v -> f.v
57
58%del f
59EOF
60expect <<EOF
61/* MACHINE-GENERATED ! */
62
63package "_"
64unit mm
65EOF
66
67###############################################################################
test/del_vec
1#!/bin/sh
2. ./Common
3
4###############################################################################
5
6fped_dump "delete vector: it disappears" <<EOF
7v: vec @(0mm, 0mm)
8%del v
9EOF
10expect <<EOF
11/* MACHINE-GENERATED ! */
12
13package "_"
14unit mm
15EOF
16
17#------------------------------------------------------------------------------
18
19fped_dump "delete vector: references disappear" <<EOF
20v: vec @(0mm, 0mm)
21line v v
22%del v
23EOF
24expect <<EOF
25/* MACHINE-GENERATED ! */
26
27package "_"
28unit mm
29EOF
30
31#------------------------------------------------------------------------------
32
33fped_dump "delete vector: measurements disappear (same frame)" <<EOF
34v: vec @(0mm, 0mm)
35meas v -> v
36%del v
37EOF
38expect <<EOF
39/* MACHINE-GENERATED ! */
40
41package "_"
42unit mm
43EOF
44
45#------------------------------------------------------------------------------
46
47fped_dump "delete vector: measurements disappear (other frame)" <<EOF
48frame f {
49    v: vec @(0mm, 0mm)
50}
51meas f.v -> f.v
52%del f.v
53EOF
54expect <<EOF
55/* MACHINE-GENERATED ! */
56
57frame f {
58}
59
60package "_"
61unit mm
62EOF
63
64###############################################################################

Archive Download the corresponding diff file

Branches:
master



interactive