Send commitlog mailing list submissions to
        commitlog@lists.openmoko.org

To subscribe or unsubscribe via the World Wide Web, visit
        http://lists.openmoko.org/mailman/listinfo/commitlog
or, via email, send a message with subject or body 'help' to
        commitlog-requ...@lists.openmoko.org

You can reach the person managing the list at
        commitlog-ow...@lists.openmoko.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of commitlog digest..."
Today's Topics:

   1. r5945 - in trunk/eda/fped: . test (wer...@docs.openmoko.org)
--- Begin Message ---
Author: werner
Date: 2010-04-27 03:02:24 +0200 (Tue, 27 Apr 2010)
New Revision: 5945

Added:
   trunk/eda/fped/test/frame_ref
Modified:
   trunk/eda/fped/README
   trunk/eda/fped/fpd.l
   trunk/eda/fped/fpd.y
   trunk/eda/fped/gui_tool.c
   trunk/eda/fped/gui_tool.h
Log:
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



Modified: trunk/eda/fped/README
===================================================================
--- trunk/eda/fped/README       2010-04-26 23:11:22 UTC (rev 5944)
+++ trunk/eda/fped/README       2010-04-27 01:02:24 UTC (rev 5945)
@@ -590,6 +590,7 @@
 
 %del <identifier>
 %move <identifier> [<number>] <identifier>
+%frame <identifier> <qualified-base>
 %print <expression>
 %dump
 %exit
@@ -610,6 +611,11 @@
 1              -               second point    end of arc      high point
 2              -               -               start of arc    -
 
+%frame creates a frame reference. Unlike "frame", the destination frame
+can be different from the current frame. E.g., "%frame foo bar.a" would
+add a reference to frame "foo" in frame "bar", rooted at vector "a". The
+parent frame's origin can be references as "@".
+
 %dump writes the footprint definition in the fped language to standard
 output. %exit immediately exits fped, without invoking the GUI.
 

Modified: trunk/eda/fped/fpd.l
===================================================================
--- trunk/eda/fped/fpd.l        2010-04-26 23:11:22 UTC (rev 5944)
+++ trunk/eda/fped/fpd.l        2010-04-27 01:02:24 UTC (rev 5945)
@@ -127,6 +127,8 @@
                                  return TOK_DBG_DEL; }
 <INITIAL>"%move"               { BEGIN(NOKEYWORD);
                                  return TOK_DBG_MOVE; }
+<INITIAL>"%frame"              { BEGIN(NOKEYWORD);
+                                 return TOK_DBG_FRAME; }
 <INITIAL>"%print"              { BEGIN(NOKEYWORD);
                                  return TOK_DBG_PRINT; }
 <INITIAL>"%dump"               { BEGIN(NOKEYWORD);

Modified: trunk/eda/fped/fpd.y
===================================================================
--- trunk/eda/fped/fpd.y        2010-04-26 23:11:22 UTC (rev 5944)
+++ trunk/eda/fped/fpd.y        2010-04-27 01:02:24 UTC (rev 5945)
@@ -234,6 +234,38 @@
 }
 
 
+/*
+ * @@@ This is very similar to what we do in rule "obj". Consider merging.
+ */
+
+static int dbg_link_frame(const char *frame_name,
+    struct frame *base_frame, struct vec *base_vec)
+{
+       struct frame *frame;
+       struct obj *obj;
+
+       frame = find_frame(frame_name);
+       if (!frame) {
+               yyerrorf("unknown frame \"%s\"", frame_name);
+               return 0;
+       }
+       /* this can only fail in %frame */
+       if (is_parent_of(frame, base_frame)) {
+               yyerrorf("frame \"%s\" is a parent of \"%s\"",
+                   frame->name, base_frame->name);
+               return 0;
+       }
+       obj = new_obj(ot_frame);
+       obj->base = base_vec;
+       obj->frame = base_frame;
+       obj->u.frame.ref = frame;
+       connect_obj(base_frame, obj);
+       if (!frame->active_ref)
+               frame->active_ref = obj;
+       return 1;
+}
+
+
 static int dbg_print(const struct expr *expr)
 {
        const char *s;
@@ -283,6 +315,10 @@
                int inverted;
                int max;
        } mo;
+       struct {
+               struct frame *frame;
+               struct vec *vec;
+       } qvec;
 };
 
 
@@ -291,8 +327,8 @@
 %token         TOK_PAD TOK_RPAD TOK_HOLE TOK_RECT TOK_LINE TOK_CIRC TOK_ARC
 %token         TOK_MEAS TOK_MEASX TOK_MEASY TOK_UNIT
 %token         TOK_NEXT TOK_NEXT_INVERTED TOK_MAX TOK_MAX_INVERTED
-%token         TOK_DBG_DEL TOK_DBG_MOVE TOK_DBG_PRINT TOK_DBG_DUMP
-%token         TOK_DBG_EXIT TOK_DBG_TSORT
+%token         TOK_DBG_DEL TOK_DBG_MOVE TOK_DBG_FRAME TOK_DBG_PRINT
+%token         TOK_DBG_DUMP TOK_DBG_EXIT TOK_DBG_TSORT
 
 %token <num>   NUMBER
 %token <str>   STRING
@@ -306,10 +342,12 @@
 %type  <obj>   object obj meas
 %type  <expr>  expr opt_expr add_expr mult_expr unary_expr primary_expr
 %type  <num>   opt_num
+%type  <frame> frame_qualifier
 %type  <str>   opt_string
 %type  <pt>    pad_type
 %type  <mt>    meas_type
 %type  <mo>    meas_op
+%type  <qvec>  qualified_base
 
 %%
 
@@ -468,6 +506,11 @@
                        if (!dbg_move($2, $3.n, $4))
                                YYABORT;
                }
+       | TOK_DBG_FRAME ID qualified_base
+               {
+                       if (!dbg_link_frame($2, $3.frame, $3.vec))
+                               YYABORT;
+               }
        | TOK_DBG_PRINT expr
                {
                        if (!dbg_print($2))
@@ -672,6 +715,40 @@
                }
        ;
 
+qualified_base:
+       base
+               {
+                       $$.frame = curr_frame;
+                       $$.vec = $1;
+               }
+       | frame_qualifier '@'
+               {
+                       $$.frame = $1;
+                       $$.vec = NULL;
+               }
+       | frame_qualifier ID
+               {
+                       $$.frame = $1;
+                       $$.vec = find_vec($1, $2);
+                       if (!$$.vec) {
+                               yyerrorf("unknown vector \"%s.%s\"",
+                                   $1->name, $2);
+                               YYABORT;
+                       }
+               }
+       ;
+
+frame_qualifier:
+       ID '.'
+               {
+                       $$ = find_frame($1);
+                       if (!$$) {
+                               yyerrorf("unknown frame \"%s\"", $1);
+                               YYABORT;
+                       }
+               }
+       ;
+
 object:
        obj
                {

Modified: trunk/eda/fped/gui_tool.c
===================================================================
--- trunk/eda/fped/gui_tool.c   2010-04-26 23:11:22 UTC (rev 5944)
+++ trunk/eda/fped/gui_tool.c   2010-04-27 01:02:24 UTC (rev 5945)
@@ -603,7 +603,7 @@
 /* ----- frame helper ------------------------------------------------------ */
 
 
-static int is_parent_of(const struct frame *p, const struct frame *c)
+int is_parent_of(const struct frame *p, const struct frame *c)
 {
        const struct obj *obj;
 

Modified: trunk/eda/fped/gui_tool.h
===================================================================
--- trunk/eda/fped/gui_tool.h   2010-04-26 23:11:22 UTC (rev 5944)
+++ trunk/eda/fped/gui_tool.h   2010-04-27 01:02:24 UTC (rev 5945)
@@ -62,6 +62,8 @@
 
 struct obj *new_obj_unconnected(enum obj_type type, struct inst *base);
 void connect_obj(struct frame *frame, struct obj *obj);
+int is_parent_of(const struct frame *p, const struct frame *c);
+
 struct pix_buf *draw_move_line_common(struct inst *inst,
     struct coord end, struct coord pos, int i);
 struct pix_buf *drag_new_line(struct inst *from, struct coord to);

Added: trunk/eda/fped/test/frame_ref
===================================================================
--- trunk/eda/fped/test/frame_ref                               (rev 0)
+++ trunk/eda/fped/test/frame_ref       2010-04-27 01:02:24 UTC (rev 5945)
@@ -0,0 +1,143 @@
+#!/bin/sh
+. ./Common
+
+###############################################################################
+
+fped_dump "frame reference: with \"frame\" (origin)" <<EOF
+frame f {}
+frame f @
+EOF
+expect <<EOF
+/* MACHINE-GENERATED ! */
+
+frame f {
+}
+
+package "_"
+unit mm
+frame f @
+EOF
+
+#------------------------------------------------------------------------------
+
+fped_dump "frame reference: with \"%frame\" (current frame origin)" <<EOF
+frame f {}
+%frame f @
+EOF
+expect <<EOF
+/* MACHINE-GENERATED ! */
+
+frame f {
+}
+
+package "_"
+unit mm
+frame f @
+EOF
+
+#------------------------------------------------------------------------------
+
+fped_dump "frame reference: with \"%frame\" (current frame vector)" <<EOF
+frame f {}
+v: vec @(0mm, 0mm)
+%frame f v
+EOF
+expect <<EOF
+/* MACHINE-GENERATED ! */
+
+frame f {
+}
+
+package "_"
+unit mm
+v: vec @(0mm, 0mm)
+frame f .
+EOF
+
+#------------------------------------------------------------------------------
+
+fped_dump "frame reference: with \"%frame\" (other frame origin)" <<EOF
+frame f {}
+frame g {}
+%frame f g.@
+EOF
+expect <<EOF
+/* MACHINE-GENERATED ! */
+
+frame f {
+}
+
+frame g {
+       frame f @
+}
+
+package "_"
+unit mm
+EOF
+
+#------------------------------------------------------------------------------
+
+fped_dump "frame reference: with \"%frame\" (other frame base)" <<EOF
+frame f {}
+frame g {
+    v: vec @(0mm, 0mm)
+}
+%frame f g.v
+EOF
+expect <<EOF
+/* MACHINE-GENERATED ! */
+
+frame f {
+}
+
+frame g {
+       v: vec @(0mm, 0mm)
+       frame f .
+}
+
+package "_"
+unit mm
+EOF
+
+#------------------------------------------------------------------------------
+
+fped_fail "frame reference: with \"%frame\" (cycle)" <<EOF
+frame f {
+}
+
+frame g {
+    frame f @
+}
+
+%frame g f.@
+EOF
+expect <<EOF
+8: frame "g" is a parent of "f" near "@"
+EOF
+
+#------------------------------------------------------------------------------
+
+fped_dump "frame reference: with \"%frame\" (out-of-order)" <<EOF
+frame f {
+}
+
+frame g {
+}
+
+%frame g f.@
+EOF
+expect <<EOF
+/* MACHINE-GENERATED ! */
+
+frame g {
+}
+
+frame f {
+       frame g @
+}
+
+package "_"
+unit mm
+EOF
+
+###############################################################################


Property changes on: trunk/eda/fped/test/frame_ref
___________________________________________________________________
Name: svn:executable
   + *




--- End Message ---
_______________________________________________
commitlog mailing list
commitlog@lists.openmoko.org
http://lists.openmoko.org/mailman/listinfo/commitlog

Reply via email to