mirror of
git://projects.qi-hardware.com/fped.git
synced 2024-11-28 17:26:14 +02:00
9e7e804d1a
- deallocate all our data structures on exit (to help find memory leaks, bad pointers, and general logic errors) - fixed memory leak when allocating pad names in instantiation - added "magic" environment variable FPED_NO_GUI to run fped without initializing Gtk+ - added valgrind wrapper "leakcheck" - delete.c: destroy() now requires a deletion to exist - vacate_op: free string expressions - destroy_obj: free measurement labels - delete_references: use do_delete_obj so the we don't bump the group number - delete_frame: delete references after deleting the frame itself, so they end up on the stack above the frame and get destroyed first - do_delete_vec: like above, even though it doesn't matter here git-svn-id: http://svn.openmoko.org/trunk/eda/fped@5506 99fdad57-331a-0410-800a-d7fa5415bdb3
197 lines
3.2 KiB
C
197 lines
3.2 KiB
C
/*
|
|
* obj.h - Object definition model
|
|
*
|
|
* Written 2009 by Werner Almesberger
|
|
* Copyright 2009 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 OBJ_H
|
|
#define OBJ_H
|
|
|
|
#include <assert.h>
|
|
#include <gtk/gtk.h>
|
|
|
|
#include "expr.h"
|
|
#include "coord.h"
|
|
#include "meas.h"
|
|
|
|
|
|
struct var {
|
|
const char *name;
|
|
struct var *next;
|
|
|
|
/* back reference */
|
|
struct frame *frame;
|
|
struct table *table; /* NULL if loop */
|
|
|
|
/* for the GUI */
|
|
GtkWidget *widget;
|
|
|
|
/* for evaluation */
|
|
int visited;
|
|
};
|
|
|
|
struct value {
|
|
struct expr *expr;
|
|
struct value *next;
|
|
|
|
/* back reference */
|
|
struct row *row;
|
|
|
|
/* for the GUI */
|
|
GtkWidget *widget;
|
|
};
|
|
|
|
struct row {
|
|
struct value *values;
|
|
struct row *next;
|
|
|
|
/* back reference */
|
|
struct table *table;
|
|
};
|
|
|
|
struct table {
|
|
struct var *vars;
|
|
struct row *rows;
|
|
struct table *next;
|
|
|
|
/* used during generation and when editing */
|
|
struct row *curr_row;
|
|
|
|
/* GUI use */
|
|
struct row *active_row;
|
|
};
|
|
|
|
struct loop {
|
|
struct var var;
|
|
struct value from;
|
|
struct value to;
|
|
struct loop *next;
|
|
|
|
/* used during generation */
|
|
double curr_value;
|
|
|
|
/* GUI use */
|
|
int active; /* n-th iteration is active, 0 based */
|
|
int iterations; /* iterations when it was active */
|
|
|
|
/* for evaluation */
|
|
int initialized;
|
|
};
|
|
|
|
struct sample;
|
|
|
|
struct vec {
|
|
const char *name; /* NULL if anonymous */
|
|
struct expr *x;
|
|
struct expr *y;
|
|
struct vec *base; /* NULL if frame */
|
|
struct vec *next;
|
|
|
|
/* used during generation */
|
|
struct coord pos;
|
|
|
|
/* used when editing */
|
|
struct frame *frame;
|
|
|
|
/* index into table of samples */
|
|
int n;
|
|
|
|
/* for the GUI */
|
|
GtkWidget *list_widget; /* NULL if items aren't shown */
|
|
};
|
|
|
|
struct frame {
|
|
const char *name; /* NULL if top-level */
|
|
struct table *tables;
|
|
struct loop *loops;
|
|
struct vec *vecs;
|
|
struct obj *objs;
|
|
struct frame *next;
|
|
struct frame *prev; /* for the list of frames in the GUI */
|
|
|
|
/* used during generation */
|
|
const struct frame *curr_parent;
|
|
|
|
/* generating and editing */
|
|
struct obj *active_ref;
|
|
|
|
/* for dumping */
|
|
int dumped;
|
|
|
|
/* for the GUI */
|
|
GtkWidget *label;
|
|
};
|
|
|
|
enum obj_type {
|
|
ot_frame,
|
|
ot_rect,
|
|
ot_pad,
|
|
ot_line,
|
|
ot_arc,
|
|
ot_meas,
|
|
};
|
|
|
|
struct frame_ref {
|
|
struct frame *ref;
|
|
int lineno;
|
|
};
|
|
|
|
struct rect {
|
|
struct vec *other; /* NULL if frame origin */
|
|
struct expr *width;
|
|
};
|
|
|
|
struct pad {
|
|
char *name;
|
|
struct vec *other; /* NULL if frame origin */
|
|
int rounded;
|
|
};
|
|
|
|
struct arc {
|
|
struct vec *start; /* NULL if frame origin */
|
|
struct vec *end; /* NULL if this is a circle */
|
|
struct expr *width;
|
|
};
|
|
|
|
struct obj {
|
|
enum obj_type type;
|
|
union {
|
|
struct frame_ref frame;
|
|
struct rect rect;
|
|
struct rect line;
|
|
struct pad pad;
|
|
struct arc arc;
|
|
struct meas meas;
|
|
} u;
|
|
struct frame *frame;
|
|
struct vec *base;
|
|
struct obj *next;
|
|
int lineno;
|
|
|
|
/* for dumping */
|
|
int dumped;
|
|
|
|
/* for the GUI */
|
|
GtkWidget *list_widget; /* NULL if items are not shown */
|
|
};
|
|
|
|
|
|
extern char *pkg_name;
|
|
extern struct frame *frames;
|
|
extern struct frame *root_frame;
|
|
extern struct frame *active_frame;
|
|
extern void *instantiation_error;
|
|
|
|
|
|
int instantiate(void);
|
|
void obj_cleanup(void);
|
|
|
|
#endif /* !OBJ_H */
|