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. r5918 - trunk/eda/fped (wer...@docs.openmoko.org)
2. r5919 - trunk/eda/fped (wer...@docs.openmoko.org)
3. r5920 - trunk/gta02-core/bom/research (wer...@docs.openmoko.org)
4. r5921 - trunk/eda/fped (wer...@docs.openmoko.org)
5. r5922 - trunk/eda/fped (wer...@docs.openmoko.org)
--- Begin Message ---
Author: werner
Date: 2010-04-19 14:23:04 +0200 (Mon, 19 Apr 2010)
New Revision: 5918
Modified:
trunk/eda/fped/gui_frame.c
Log:
When unselecting a value selected for editing in a table with a single row, the
unselected value was set to the background color for an inactive row. Now it's
set to the color of an active row.
- gui_frame.c (unselect_value): to detect a table, consider not only the number
of rows but also the number of columns
- gui_frame.c (unselect_value, edit_value_list): use COLOR_EXPR_* for
expressions, not COLOR_VAR_* (this has no visual effect for now, since the
colors in questions have the same value)
Modified: trunk/eda/fped/gui_frame.c
===================================================================
--- trunk/eda/fped/gui_frame.c 2010-04-18 22:01:19 UTC (rev 5917)
+++ trunk/eda/fped/gui_frame.c 2010-04-19 12:23:04 UTC (rev 5918)
@@ -679,11 +679,11 @@
* AND it's an assignment (not a table).
*
* We need the last condition because the expressions of assignments
- * are drawn with COLOR_VAR_PASSIVE. (See build_assignment.)
+ * are drawn with COLOR_EXPR_PASSIVE. (See build_assignment.)
*/
label_in_box_bg(value->widget,
value->row && value->row->table->active_row == value->row &&
- value->row->table->rows->next ?
+ (value->row->table->rows->next || value->row->table->vars->next) ?
COLOR_CHOICE_SELECTED : COLOR_EXPR_PASSIVE);
}
@@ -703,7 +703,7 @@
void *user)
{
inst_select_outside(value, unselect_value);
- label_in_box_bg(value->widget, COLOR_VAR_EDITING);
+ label_in_box_bg(value->widget, COLOR_EXPR_EDITING);
show_value(value->expr, frame);
edit_nothing();
edit_expr_list(value->expr, set_values, user, "Value(s)");
--- End Message ---
--- Begin Message ---
Author: werner
Date: 2010-04-19 16:39:57 +0200 (Mon, 19 Apr 2010)
New Revision: 5919
Modified:
trunk/eda/fped/README
trunk/eda/fped/dump.c
trunk/eda/fped/expr.c
trunk/eda/fped/fpd.l
trunk/eda/fped/fpd.y
trunk/eda/fped/inst.c
trunk/eda/fped/inst.h
trunk/eda/fped/obj.c
trunk/eda/fped/obj.h
Log:
Added debugging directives to the fped language. They're describe at the end
of README.
- fpd.l, fpd.y, README: added debugging directives %del, %move, %print, %dump,
and %exit
- obj.h, fpd.y (find_obj, find_label, new_obj): objects can now be labeled
- obj.c (obj_anchors), inst.c (inst_anchors): gathering the list of anchors is
now a per-object function, not an instance "method". inst_anchors implements
the vector vs. object switch.
- inst.h, inst.c: removed all *_op_anchors functions
- expr.c (str_unit): in the past, we returned a malloc'ed string, but these
times are long gone. Thus, don't stralloc("").
Modified: trunk/eda/fped/README
===================================================================
--- trunk/eda/fped/README 2010-04-19 12:23:04 UTC (rev 5918)
+++ trunk/eda/fped/README 2010-04-19 14:39:57 UTC (rev 5919)
@@ -555,3 +555,34 @@
measx "width = " a >> b 0mm
would print "width = 1mm"
+
+
+Experimental: debugging directives
+----------------------------------
+
+For debugging and regression tests, fped supports the following commands
+that mimick the effect of GUI operations:
+
+%del <identifier>
+%move <identifier> [<number>] <identifier>
+%print <expression>
+%dump
+%exit
+
+%del and %move take as their first argument the name of the vector or
+object to manipulate. For this purpose, also objects can be labeled.
+
+Object labels behave like vector labels and share the same name space.
+They are not shown anywhere in the GUI.
+
+%move sets an anchor point to the vector named as its last argument.
+The anchor point is identified by index as follows:
+
+anchor index vec/frame line/rect/pad arc measurement
+-------------- --------- ------------- ------------ -----------
+0 (or omitted) base first point center low point
+1 - second point end of arc high point
+2 - - start of arc -
+
+%dump writes the footprint definition in the fped language to standard
+output. %exit immediately exits fped, without invoking the GUI.
Modified: trunk/eda/fped/dump.c
===================================================================
--- trunk/eda/fped/dump.c 2010-04-19 12:23:04 UTC (rev 5918)
+++ trunk/eda/fped/dump.c 2010-04-19 14:39:57 UTC (rev 5919)
@@ -1,8 +1,8 @@
/*
* dump.c - Dump objects in the native FPD format
*
- * Written 2009 by Werner Almesberger
- * Copyright 2009 by Werner Almesberger
+ * Written 2009, 2010 by Werner Almesberger
+ * Copyright 2009, 2010 by Werner Almesberger
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -484,8 +484,11 @@
order = order_frame(frame);
for (item = order; item->vec || item->obj; item++) {
if (item->obj) {
+ fprintf(file, "%s", indent);
+ if (item->obj->name)
+ fprintf(file, "%s: ", item->obj->name);
s = print_obj(item->obj, item->vec);
- fprintf(file, "%s%s\n", indent, s);
+ fprintf(file, "%s\n", s);
} else {
s1 = print_label(item->vec);
s = print_vec(item->vec);
Modified: trunk/eda/fped/expr.c
===================================================================
--- trunk/eda/fped/expr.c 2010-04-19 12:23:04 UTC (rev 5918)
+++ trunk/eda/fped/expr.c 2010-04-19 14:39:57 UTC (rev 5919)
@@ -55,7 +55,7 @@
char buf[20]; /* @@@ plenty */
if (n.exponent == 0)
- return stralloc("");
+ return "";
switch (n.type) {
case nt_mm:
unit = "mm";
Modified: trunk/eda/fped/fpd.l
===================================================================
--- trunk/eda/fped/fpd.l 2010-04-19 12:23:04 UTC (rev 5918)
+++ trunk/eda/fped/fpd.l 2010-04-19 14:39:57 UTC (rev 5919)
@@ -121,6 +121,17 @@
<INITIAL>"unit" { BEGIN(NOKEYWORD);
return TOK_UNIT; }
+<INITIAL>"%del" { BEGIN(NOKEYWORD);
+ return TOK_DBG_DEL; }
+<INITIAL>"%move" { BEGIN(NOKEYWORD);
+ return TOK_DBG_MOVE; }
+<INITIAL>"%print" { BEGIN(NOKEYWORD);
+ return TOK_DBG_PRINT; }
+<INITIAL>"%dump" { BEGIN(NOKEYWORD);
+ return TOK_DBG_DUMP; }
+<INITIAL>"%exit" { BEGIN(NOKEYWORD);
+ return TOK_DBG_EXIT; }
+
<INITIAL>[a-zA-Z_][a-zA-Z_0-9]*: { *strchr(yytext, ':') = 0;
yylval.id = unique(yytext);
return LABEL; }
Modified: trunk/eda/fped/fpd.y
===================================================================
--- trunk/eda/fped/fpd.y 2010-04-19 12:23:04 UTC (rev 5918)
+++ trunk/eda/fped/fpd.y 2010-04-19 14:39:57 UTC (rev 5919)
@@ -21,6 +21,7 @@
#include "obj.h"
#include "meas.h"
#include "gui_status.h"
+#include "dump.h"
#include "fpd.h"
@@ -68,6 +69,27 @@
}
+static struct obj *find_obj(const struct frame *frame, const char *name)
+{
+ struct obj *obj;
+
+ for (obj = frame->objs; obj; obj = obj->next)
+ if (obj->name == name)
+ return obj;
+ return NULL;
+}
+
+
+static int find_label(const struct frame *frame, const char *name)
+{
+ if (find_vec(frame, name))
+ return 1;
+ if (find_obj(frame, name))
+ return 1;
+ return 0;
+}
+
+
static struct var *find_var(const struct frame *frame, const char *name)
{
const struct table *table;
@@ -145,6 +167,7 @@
obj = alloc_type(struct obj);
obj->type = type;
+ obj->name = NULL;
obj->frame = curr_frame;
obj->next = NULL;
obj->lineno = lineno;
@@ -152,6 +175,80 @@
}
+static int dbg_delete(const char *name)
+{
+ struct vec *vec;
+ struct obj *obj;
+
+ vec = find_vec(curr_frame, name);
+ if (vec) {
+ delete_vec(vec);
+ return 1;
+ }
+ obj = find_obj(curr_frame, name);
+ if (obj) {
+ delete_obj(obj);
+ return 1;
+ }
+ yyerrorf("unknown item \"%s\"", name);
+ return 0;
+}
+
+
+static int dbg_move(const char *name, int anchor, const char *dest)
+{
+ struct vec *to, *vec;
+ struct obj *obj;
+ struct vec **anchors[3];
+ int n_anchors;
+
+ to = find_vec(curr_frame, dest);
+ if (!to) {
+ yyerrorf("unknown vector \"%s\"", dest);
+ return 0;
+ }
+ vec = find_vec(curr_frame, name);
+ if (vec) {
+ if (anchor) {
+ yyerrorf("invalid anchor (%d > 0)", anchor);
+ return 0;
+ }
+ vec->base = to;
+ return 1;
+ }
+ obj = find_obj(curr_frame, name);
+ if (!obj) {
+ yyerrorf("unknown item \"%s\"", name);
+ return 0;
+ }
+ n_anchors = obj_anchors(obj, anchors);
+ if (anchor >= n_anchors) {
+ yyerrorf("invalid anchor (%d > %d)", anchor, n_anchors-1);
+ return 0;
+ }
+ *anchors[anchor] = to;
+ return 1;
+}
+
+
+static int dbg_print(const struct expr *expr)
+{
+ const char *s;
+ struct num num;
+
+ s = eval_str(expr, curr_frame);
+ if (s) {
+ printf("%s\n", s);
+ return 1;
+ }
+ num = eval_num(expr, curr_frame);
+ if (is_undef(num))
+ return 0;
+ printf("%lg%s\n", num.n, str_unit(num));
+ return 1;
+}
+
+
%}
@@ -181,6 +278,8 @@
%token TOK_PAD TOK_RPAD 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
%token <num> NUMBER
%token <str> STRING
@@ -191,8 +290,9 @@
%type <row> rows
%type <value> row value opt_value_list
%type <vec> vec base qbase
-%type <obj> obj meas
+%type <obj> object obj meas
%type <expr> expr opt_expr add_expr mult_expr unary_expr primary_expr
+%type <num> opt_num
%type <str> opt_string
%type <pt> pad_type
%type <mt> meas_type
@@ -323,17 +423,47 @@
| vec
| LABEL vec
{
- if (find_vec(curr_frame, $1)) {
- yyerrorf("duplicate vector \"%s\"", $1);
+ if (find_label(curr_frame, $1)) {
+ yyerrorf("duplicate label \"%s\"", $1);
YYABORT;
}
$2->name = $1;
}
- | obj
+ | object
+ | LABEL object
{
- *next_obj = $1;
- next_obj = &$1->next;
+ if (find_label(curr_frame, $1)) {
+ yyerrorf("duplicate label \"%s\"", $1);
+ YYABORT;
+ }
+ $2->name = $1;
}
+ | TOK_DBG_DEL ID
+ {
+ if (!dbg_delete($2))
+ YYABORT;
+ }
+ | TOK_DBG_MOVE ID opt_num ID
+ {
+ if (!dbg_move($2, $3.n, $4))
+ YYABORT;
+ }
+ | TOK_DBG_PRINT expr
+ {
+ if (!dbg_print($2))
+ YYABORT;
+ }
+ | TOK_DBG_DUMP
+ {
+ if (!dump(stdout)) {
+ perror("stdout");
+ exit(1);
+ }
+ }
+ | TOK_DBG_EXIT
+ {
+ exit(0);
+ }
;
table:
@@ -478,6 +608,15 @@
}
;
+object:
+ obj
+ {
+ $$ = $1;
+ *next_obj = $1;
+ next_obj = &$1->next;
+ }
+ ;
+
obj:
TOK_PAD STRING base base pad_type
{
@@ -650,6 +789,16 @@
}
;
+opt_num:
+ {
+ $$.n = 0;
+ }
+ | NUMBER
+ {
+ $$ = $1;
+ }
+ ;
+
opt_string:
{
$$ = NULL;
Modified: trunk/eda/fped/inst.c
===================================================================
--- trunk/eda/fped/inst.c 2010-04-19 12:23:04 UTC (rev 5918)
+++ trunk/eda/fped/inst.c 2010-04-19 14:39:57 UTC (rev 5919)
@@ -421,7 +421,11 @@
int inst_anchors(struct inst *inst, struct vec ***anchors)
{
- return inst->ops->anchors ? inst->ops->anchors(inst, anchors) : 0;
+ if (inst->vec) {
+ anchors[0] = &inst->vec->base;
+ return 1;
+ }
+ return obj_anchors(inst->obj, anchors);
}
@@ -658,13 +662,6 @@
}
-static int vec_op_anchors(struct inst *inst, struct vec ***anchors)
-{
- anchors[0] = &inst->vec->base;
- return 1;
-}
-
-
/*
* When instantiating and when dumping, we assume that bases appear in the
* frame->vecs list before vectors using them. A move may change this order.
@@ -729,7 +726,6 @@
.distance = gui_dist_vec,
.select = vec_op_select,
.find_point = find_point_vec,
- .anchors = vec_op_anchors,
.draw_move = draw_move_vec,
.do_move_to = do_move_to_vec,
};
@@ -765,21 +761,10 @@
}
-static int line_op_anchors(struct inst *inst, struct vec ***anchors)
-{
- struct obj *obj = inst->obj;
-
- anchors[0] = &obj->base;
- anchors[1] = &obj->u.rect.other;
- return 2;
-}
-
-
static struct inst_ops line_ops = {
.draw = gui_draw_line,
.distance = gui_dist_line,
.select = line_op_select,
- .anchors = line_op_anchors,
.draw_move = draw_move_line,
};
@@ -820,7 +805,6 @@
.draw = gui_draw_rect,
.distance = gui_dist_rect,
.select = rect_op_select,
- .anchors = line_op_anchors,
.draw_move = draw_move_rect,
};
@@ -874,21 +858,10 @@
}
-static int pad_op_anchors(struct inst *inst, struct vec ***anchors)
-{
- struct obj *obj = inst->obj;
-
- anchors[0] = &obj->base;
- anchors[1] = &obj->u.pad.other;
- return 2;
-}
-
-
static struct inst_ops pad_ops = {
.draw = gui_draw_pad,
.distance = gui_dist_pad,
.select = pad_op_select,
- .anchors = pad_op_anchors,
.draw_move = draw_move_pad,
};
@@ -906,7 +879,6 @@
.draw = gui_draw_rpad,
.distance = gui_dist_pad, /* @@@ */
.select = rpad_op_select,
- .anchors = pad_op_anchors,
.draw_move = draw_move_rpad,
};
@@ -951,26 +923,10 @@
}
-static int arc_op_anchors(struct inst *inst, struct vec ***anchors)
-{
- struct obj *obj = inst->obj;
-
- /*
- * Put end point first so that this is what we grab if dragging a
- * circle (thereby turning it into an arc).
- */
- anchors[0] = &obj->base;
- anchors[1] = &obj->u.arc.end;
- anchors[2] = &obj->u.arc.start;
- return 3;
-}
-
-
static struct inst_ops arc_ops = {
.draw = gui_draw_arc,
.distance = gui_dist_arc,
.select = arc_op_select,
- .anchors = arc_op_anchors,
.draw_move = draw_move_arc,
.do_move_to = do_move_to_arc,
};
@@ -1022,21 +978,10 @@
}
-static int meas_op_anchors(struct inst *inst, struct vec ***anchors)
-{
- struct obj *obj = inst->obj;
-
- anchors[0] = &obj->base;
- anchors[1] = &obj->u.meas.high;
- return 2;
-}
-
-
static struct inst_ops meas_ops = {
.draw = gui_draw_meas,
.distance = gui_dist_meas,
.select = meas_op_select,
- .anchors = meas_op_anchors,
.begin_drag_move= begin_drag_move_meas,
.find_point = find_point_meas_move,
.draw_move = draw_move_meas,
@@ -1146,19 +1091,11 @@
}
-static int frame_op_anchors(struct inst *inst, struct vec ***anchors)
-{
- anchors[0] = &inst->obj->base;
- return 1;
-}
-
-
static struct inst_ops frame_ops = {
.draw = gui_draw_frame,
.hover = gui_hover_frame,
.distance = gui_dist_frame,
.select = frame_op_select,
- .anchors = frame_op_anchors,
.draw_move = draw_move_frame,
};
Modified: trunk/eda/fped/inst.h
===================================================================
--- trunk/eda/fped/inst.h 2010-04-19 12:23:04 UTC (rev 5918)
+++ trunk/eda/fped/inst.h 2010-04-19 14:39:57 UTC (rev 5919)
@@ -61,7 +61,6 @@
unit_type (*distance)(struct inst *self, struct coord pos,
unit_type scale);
void (*select)(struct inst *self);
- int (*anchors)(struct inst *self, struct vec ***anchors);
void (*begin_drag_move)(struct inst *from, int i);
struct inst *(*find_point)(struct inst *self, struct coord pos);
struct pix_buf *(*draw_move)(struct inst *inst,
Modified: trunk/eda/fped/obj.c
===================================================================
--- trunk/eda/fped/obj.c 2010-04-19 12:23:04 UTC (rev 5918)
+++ trunk/eda/fped/obj.c 2010-04-19 14:39:57 UTC (rev 5919)
@@ -96,6 +96,39 @@
}
+/* ----- Get the list of anchors of an object ------------------------------ */
+
+
+int obj_anchors(struct obj *obj, struct vec ***anchors)
+{
+ anchors[0] = &obj->base;
+ switch (obj->type) {
+ case ot_frame:
+ return 1;
+ case ot_rect:
+ case ot_line:
+ anchors[1] = &obj->u.rect.other;
+ return 2;
+ case ot_pad:
+ anchors[1] = &obj->u.pad.other;
+ return 2;
+ case ot_meas:
+ anchors[1] = &obj->u.meas.high;
+ return 2;
+ case ot_arc:
+ /*
+ * Put end point first so that this is what we grab if dragging
+ * a circle (thereby turning it into an arc).
+ */
+ anchors[1] = &obj->u.arc.end;
+ anchors[2] = &obj->u.arc.start;
+ return 3;
+ default:
+ abort();
+ }
+}
+
+
/* ----- Instantiation ----------------------------------------------------- */
Modified: trunk/eda/fped/obj.h
===================================================================
--- trunk/eda/fped/obj.h 2010-04-19 12:23:04 UTC (rev 5918)
+++ trunk/eda/fped/obj.h 2010-04-19 14:39:57 UTC (rev 5919)
@@ -205,6 +205,7 @@
struct obj {
enum obj_type type;
+ const char *name; /* NULL if anonymous */
union {
struct frame_ref frame;
struct rect rect;
@@ -251,6 +252,8 @@
void search_inst(const struct inst *inst);
+int obj_anchors(struct obj *obj, struct vec ***anchors);
+
int instantiate(void);
void obj_cleanup(void);
--- End Message ---
--- Begin Message ---
Author: werner
Date: 2010-04-19 23:14:32 +0200 (Mon, 19 Apr 2010)
New Revision: 5920
Modified:
trunk/gta02-core/bom/research/u1501
Log:
URL of Samsung's 2442 page changed. (Fixed by Igor Almeida.)
Modified: trunk/gta02-core/bom/research/u1501
===================================================================
--- trunk/gta02-core/bom/research/u1501 2010-04-19 14:39:57 UTC (rev 5919)
+++ trunk/gta02-core/bom/research/u1501 2010-04-19 21:14:32 UTC (rev 5920)
@@ -1,6 +1,6 @@
U1501: Samsung SC32442B54
-http://www.samsung.com/global/business/semiconductor/productInfo.do?fmly_id=229&partnum=SC32442&xFmly_id=229
+http://www.samsung.com/global/business/semiconductor/productInfo.do?fmly_id=836&partnum=SC32442
Part has not been found yet. Many brokers list it, but without complete
information.
--- End Message ---
--- Begin Message ---
Author: werner
Date: 2010-04-20 00:57:51 +0200 (Tue, 20 Apr 2010)
New Revision: 5921
Modified:
trunk/eda/fped/fpd.y
Log:
%dump didn't dump the root frame because this frame was only appended to the
list of frames at the end of parsing. We now tentatively append it each time
a %dump is requested.
- fpd.y: append the root frame before calling "dump"
Modified: trunk/eda/fped/fpd.y
===================================================================
--- trunk/eda/fped/fpd.y 2010-04-19 21:14:32 UTC (rev 5920)
+++ trunk/eda/fped/fpd.y 2010-04-19 22:57:51 UTC (rev 5921)
@@ -249,6 +249,16 @@
}
+static void append_root_frame(void)
+{
+ root_frame->prev = last_frame;
+ if (last_frame)
+ last_frame->next = root_frame;
+ else
+ frames = root_frame;
+}
+
+
%}
@@ -311,11 +321,7 @@
}
fpd
{
- root_frame->prev = last_frame;
- if (last_frame)
- last_frame->next = root_frame;
- else
- frames = root_frame;
+ append_root_frame();
}
| START_EXPR expr
{
@@ -455,6 +461,13 @@
}
| TOK_DBG_DUMP
{
+ /*
+ * It's okay to do append the root frame multiple
+ * times. If more frames are added afterwards, they
+ * just replace the root frame until it gets appended a
+ * final time when parsing ends.
+ */
+ append_root_frame();
if (!dump(stdout)) {
perror("stdout");
exit(1);
--- End Message ---
--- Begin Message ---
Author: werner
Date: 2010-04-20 03:11:45 +0200 (Tue, 20 Apr 2010)
New Revision: 5922
Added:
trunk/eda/fped/fped.h
Modified:
trunk/eda/fped/dump.c
trunk/eda/fped/dump.h
trunk/eda/fped/file.c
trunk/eda/fped/fped.c
trunk/eda/fped/gui.c
trunk/eda/fped/gui.h
Log:
Added a "Save as" dialog and made fped disable "Save" if working on a manually
created file. This is a precaution against accidently saving to a manual work,
which would change the structure and remove all comments.
- fped.h, fped.c, file.c: moved declaration of save_file_name into shared
header
- dump.h, dump.c (MACHINE_GENERATED): moved header marking machine-generated
files into shared macro
- gui.c (save_as_fpd): added "Save as" dialog
- fped.h, fped.c (load_file), gui.c: disable "Save" if editing a file that
doesn't have the machine-generated header
Modified: trunk/eda/fped/dump.c
===================================================================
--- trunk/eda/fped/dump.c 2010-04-19 22:57:51 UTC (rev 5921)
+++ trunk/eda/fped/dump.c 2010-04-20 01:11:45 UTC (rev 5922)
@@ -536,7 +536,7 @@
{
struct frame *frame;
- fprintf(file, "/* MACHINE-GENERATED ! */\n\n");
+ fprintf(file, "%s\n", MACHINE_GENERATED);
for (frame = frames; frame; frame = frame->next)
frame->dumped = 0;
for (frame = frames; frame; frame = frame->next) {
Modified: trunk/eda/fped/dump.h
===================================================================
--- trunk/eda/fped/dump.h 2010-04-19 22:57:51 UTC (rev 5921)
+++ trunk/eda/fped/dump.h 2010-04-20 01:11:45 UTC (rev 5922)
@@ -1,8 +1,8 @@
/*
* dump.h - Dump objects in the native FPD format
*
- * Written 2009 by Werner Almesberger
- * Copyright 2009 by Werner Almesberger
+ * Written 2009, 2010 by Werner Almesberger
+ * Copyright 2009, 2010 by Werner Almesberger
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -19,6 +19,9 @@
#include "obj.h"
+#define MACHINE_GENERATED "/* MACHINE-GENERATED ! */\n"
+
+
/*
* vec obj
* --------------------------------------------------------------
Modified: trunk/eda/fped/file.c
===================================================================
--- trunk/eda/fped/file.c 2010-04-19 22:57:51 UTC (rev 5921)
+++ trunk/eda/fped/file.c 2010-04-20 01:11:45 UTC (rev 5922)
@@ -20,14 +20,11 @@
#include "dump.h"
#include "kicad.h"
#include "postscript.h"
-
#include "util.h"
#include "file.h"
+#include "fped.h"
-extern char *save_file_name;
-
-
/* ----- general helper functions ------------------------------------------ */
Modified: trunk/eda/fped/fped.c
===================================================================
--- trunk/eda/fped/fped.c 2010-04-19 22:57:51 UTC (rev 5921)
+++ trunk/eda/fped/fped.c 2010-04-20 01:11:45 UTC (rev 5922)
@@ -14,6 +14,7 @@
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
+#include <errno.h>
#include "cpp.h"
#include "util.h"
@@ -21,20 +22,37 @@
#include "obj.h"
#include "inst.h"
#include "file.h"
+#include "dump.h"
#include "gui.h"
#include "delete.h"
#include "fpd.h"
+#include "fped.h"
char *save_file_name = NULL;
+int no_save = 0;
static void load_file(const char *name)
{
- if (file_exists(name) == 1) {
+ FILE *file;
+ char line[sizeof(MACHINE_GENERATED)];
+
+ file = fopen(name, "r");
+ if (file) {
+ if (!fgets(line, sizeof(line), file)) {
+ perror(name);
+ exit(1);
+ }
+ no_save = strcmp(line, MACHINE_GENERATED);
+ fclose(file);
reporter = report_parse_error;
run_cpp_on_file(name);
} else {
+ if (errno != ENOENT) {
+ perror(name);
+ exit(1);
+ }
scan_empty();
}
(void) yyparse();
Added: trunk/eda/fped/fped.h
===================================================================
--- trunk/eda/fped/fped.h (rev 0)
+++ trunk/eda/fped/fped.h 2010-04-20 01:11:45 UTC (rev 5922)
@@ -0,0 +1,20 @@
+/*
+ * fped.h - Things fped.c exports
+ *
+ * Written 2010 by Werner Almesberger
+ * Copyright 2010 by Werner Almesberger
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+
+#ifndef FPED_H
+#define FPED_H
+
+extern char *save_file_name;
+extern int no_save;
+
+#endif /* !FPED_H */
Modified: trunk/eda/fped/gui.c
===================================================================
--- trunk/eda/fped/gui.c 2010-04-19 22:57:51 UTC (rev 5921)
+++ trunk/eda/fped/gui.c 2010-04-20 01:11:45 UTC (rev 5922)
@@ -23,6 +23,7 @@
#include "gui_tool.h"
#include "gui_frame.h"
#include "gui.h"
+#include "fped.h"
#include "icons/stuff.xpm"
#include "icons/stuff_off.xpm"
@@ -50,6 +51,33 @@
static void do_build_frames(void);
+/* ----- save callbacks ---------------------------------------------------- */
+
+
+static void save_as_fpd(void)
+{
+ GtkWidget *dialog;
+
+ dialog = gtk_file_chooser_dialog_new("Save File",
+ NULL, GTK_FILE_CHOOSER_ACTION_SAVE,
+ GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
+ GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, NULL);
+ gtk_file_chooser_set_do_overwrite_confirmation(
+ GTK_FILE_CHOOSER(dialog), TRUE);
+ if (save_file_name)
+ gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dialog),
+ save_file_name);
+ if (gtk_dialog_run(GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT) {
+ save_file_name =
+ gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(dialog));
+ save_fpd();
+ /* @@@ we may leak save_file_name */
+ no_save = 0;
+ }
+ gtk_widget_destroy(dialog);
+}
+
+
/* ----- view callbacks ---------------------------------------------------- */
@@ -68,6 +96,7 @@
static GtkItemFactoryEntry menu_entries[] = {
{ "/File", NULL, NULL, 0, "<Branch>" },
{ "/File/Save", NULL, save_fpd, 0, "<Item>" },
+ { "/File/Save as", NULL, save_as_fpd, 0, "<Item>" },
{ "/File/sep1", NULL, NULL, 0,
"<Separator>" },
{ "/File/Write KiCad", NULL, write_kicad, 0, "<Item>" },
{ "/File/Write Postscript",
@@ -95,6 +124,9 @@
bar = gtk_item_factory_get_widget(factory, "<FpedMenu>");
gtk_box_pack_start(GTK_BOX(hbox), bar, TRUE, TRUE, 0);
+
+ gtk_widget_set_sensitive(
+ gtk_item_factory_get_item(factory, "/File/Save"), !no_save);
}
Modified: trunk/eda/fped/gui.h
===================================================================
--- trunk/eda/fped/gui.h 2010-04-19 22:57:51 UTC (rev 5921)
+++ trunk/eda/fped/gui.h 2010-04-20 01:11:45 UTC (rev 5922)
@@ -1,8 +1,8 @@
/*
* gui.h - Editor GUI core
*
- * Written 2009 by Werner Almesberger
- * Copyright 2009 by Werner Almesberger
+ * Written 2009, 2010 by Werner Almesberger
+ * Copyright 2009, 2010 by Werner Almesberger
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -23,7 +23,9 @@
extern int show_meas;
extern int show_bright;
+extern int no_save;
+
/* update everything after a model change */
void change_world(void);
--- End Message ---
_______________________________________________
commitlog mailing list
commitlog@lists.openmoko.org
http://lists.openmoko.org/mailman/listinfo/commitlog