r5971 - trunk/eda/fped
werner at docs.openmoko.org
werner at docs.openmoko.org
Mon May 31 07:53:57 CEST 2010
Author: werner
Date: 2010-05-31 07:53:56 +0200 (Mon, 31 May 2010)
New Revision: 5971
Modified:
trunk/eda/fped/TODO
trunk/eda/fped/coord.c
trunk/eda/fped/gui_frame_drag.c
trunk/eda/fped/gui_meas.c
trunk/eda/fped/gui_util.c
trunk/eda/fped/util.h
Log:
A bit of cleanup.
- gui_frame_drag.c (FOR_UNORDERED, drag_var_motion, drag_value_motion,
drag_frame_motion): moved hard to read loop into helper macro
- capitalized SWAP, to make it clear it's a macro and can multiply side-effects
- TODO: updated discussion of open issues
Modified: trunk/eda/fped/TODO
===================================================================
--- trunk/eda/fped/TODO 2010-05-30 20:30:24 UTC (rev 5970)
+++ trunk/eda/fped/TODO 2010-05-31 05:53:56 UTC (rev 5971)
@@ -53,12 +53,14 @@
A1: no: would cause confusion in GUI (vectors could become orphaned)
A2: yes. but we don't change the linkage.
- Q: how do we handle stacks of objects ?
- A: we don't but we make it easy to avoid them, by giving a good zoom,
- flexible selection, and by disallowing stacks of identical objects in the
- first place.
+ A1: we don't but we make it easy to avoid them, by giving a good zoom,
+ flexible selection, and by disallowing stacks of identical objects in the
+ first place.
+ A2: the current mechanism of selecting the next eligible object when clicking
+ on the same position repeatedly lets one cycle through stacks.
- Q: add frame arguments ? (e.g., .frame pad(pin_num_offset) ...)
- we can already approximate this by introducing an intermediate table that
- sets up the arguments (provided that we don't consider vectors as well)
+ A: we can already approximate this by introducing an intermediate table that
+ sets up the arguments (provided that we don't consider vectors as well)
- Q: should we make it a requirement to generate objects only once ?
A: yes.
Modified: trunk/eda/fped/coord.c
===================================================================
--- trunk/eda/fped/coord.c 2010-05-30 20:30:24 UTC (rev 5970)
+++ trunk/eda/fped/coord.c 2010-05-31 05:53:56 UTC (rev 5971)
@@ -157,9 +157,9 @@
void sort_coord(struct coord *min, struct coord *max)
{
if (min->x > max->x)
- swap(min->x, max->x);
+ SWAP(min->x, max->x);
if (min->y > max->y)
- swap(min->y, max->y);
+ SWAP(min->y, max->y);
}
Modified: trunk/eda/fped/gui_frame_drag.c
===================================================================
--- trunk/eda/fped/gui_frame_drag.c 2010-05-30 20:30:24 UTC (rev 5970)
+++ trunk/eda/fped/gui_frame_drag.c 2010-05-31 05:53:56 UTC (rev 5971)
@@ -93,7 +93,11 @@
NTH_walk = &(*NTH_walk)->next; \
NTH_walk; })
+#define FOR_UNORDERED(var, a, b) \
+ for (var = (a) < (b) ? (a) : (b); var != ((a) < (b) ? (b) : (a)); \
+ var++)
+
/* ----- generic helper functions. maybe move to gui_util later ------------ */
@@ -203,8 +207,8 @@
swap_table_cells(box_of_label((*var_a)->widget),
box_of_label((*var_b)->widget));
- swap(*var_a, *var_b);
- swap((*var_a)->next, (*var_b)->next);
+ SWAP(*var_a, *var_b);
+ SWAP((*var_a)->next, (*var_b)->next);
}
@@ -218,12 +222,11 @@
swap_table_cells(box_of_label((*value_a)->widget),
box_of_label((*value_b)->widget));
- swap(*value_a, *value_b);
- swap((*value_a)->next, (*value_b)->next);
+ SWAP(*value_a, *value_b);
+ SWAP((*value_a)->next, (*value_b)->next);
}
-
static void swap_cols(struct table *table, int a, int b)
{
struct row *row;
@@ -246,8 +249,8 @@
value_a = value_a->next;
value_b = value_b->next;
}
- swap(*a, *b);
- swap((*a)->next, (*b)->next);
+ SWAP(*a, *b);
+ SWAP((*a)->next, (*b)->next);
}
@@ -262,8 +265,8 @@
swap_table_rows(table, 2*a+1, 2*b+1);
swap_table_rows(table, 2*a+2, 2*b+2);
- swap(*frame_a, *frame_b);
- swap((*frame_a)->next, (*frame_b)->next);
+ SWAP(*frame_a, *frame_b);
+ SWAP((*frame_a)->next, (*frame_b)->next);
}
@@ -341,8 +344,7 @@
return FALSE;
from_n = NDX(from->table->vars, from);
to_n = NDX(to->table->vars, to);
- for (i = from_n < to_n ? from_n : to_n;
- i != (from_n < to_n ? to_n : from_n); i++)
+ FOR_UNORDERED(i, from_n, to_n)
swap_cols(from->table, i, i+1);
return FALSE;
}
@@ -386,8 +388,7 @@
from_n = NDX(from->row->values, from);
to_n = NDX(to->row->values, to);
- for (i = from_n < to_n ? from_n : to_n;
- i != (from_n < to_n ? to_n : from_n); i++)
+ FOR_UNORDERED(i, from_n, to_n)
swap_cols(table, i, i+1);
/* rows */
@@ -490,8 +491,7 @@
assert(to != frames);
from_n = NDX(frames, from);
to_n = NDX(frames, to);
- for (i = from_n < to_n ? from_n : to_n;
- i != (from_n < to_n ? to_n : from_n); i++)
+ FOR_UNORDERED(i, from_n, to_n)
swap_frames(gtk_widget_get_ancestor(widget, GTK_TYPE_TABLE),
i, i+1);
return FALSE;
Modified: trunk/eda/fped/gui_meas.c
===================================================================
--- trunk/eda/fped/gui_meas.c 2010-05-30 20:30:24 UTC (rev 5970)
+++ trunk/eda/fped/gui_meas.c 2010-05-31 05:53:56 UTC (rev 5971)
@@ -378,7 +378,7 @@
a = inst->base;
b = inst->u.meas.end;
if (inst->obj->u.meas.inverted)
- swap(a, b);
+ SWAP(a, b);
switch (i) {
case 0:
mode = meas->type < 3 ? next_to_min : max_to_min;
Modified: trunk/eda/fped/gui_util.c
===================================================================
--- trunk/eda/fped/gui_util.c 2010-05-30 20:30:24 UTC (rev 5970)
+++ trunk/eda/fped/gui_util.c 2010-05-31 05:53:56 UTC (rev 5971)
@@ -68,9 +68,9 @@
int w, h;
if (xa > xb)
- swap(xa, xb);
+ SWAP(xa, xb);
if (ya > yb)
- swap(ya, yb);
+ SWAP(ya, yb);
buf = alloc_type(struct pix_buf);
buf->da = da;
buf->x = xa-border;
Modified: trunk/eda/fped/util.h
===================================================================
--- trunk/eda/fped/util.h 2010-05-30 20:30:24 UTC (rev 5970)
+++ trunk/eda/fped/util.h 2010-05-31 05:53:56 UTC (rev 5971)
@@ -51,10 +51,10 @@
strnalloc_tmp[n] = 0; \
strnalloc_tmp; })
-#define swap(a, b) \
- ({ typeof(a) swap_tmp = (a); \
+#define SWAP(a, b) \
+ ({ typeof(a) SWAP_tmp = (a); \
(a) = (b); \
- (b) = swap_tmp; })
+ (b) = SWAP_tmp; })
char *stralloc_vprintf(const char *fmt, va_list ap);
More information about the commitlog
mailing list