First, congrats, your code passed the "Murphy, first stage" test : it
worked here (with -march=k6) (I didn't have the time to shake it with
ElectricFence, though).
On Sat, 5 Feb 2000, James Henstridge wrote:
> I have converted the flowchart/box object over to using the properties
> as a test case. It has reduced the code size by a fair ammount (there is
> still a bit of dead code I haven't trimmed out yet, but it looks like it
> cuts off around 100 lines of code). The automatically generated
> properties dialog works pretty well, and even undo with it works
> correctly. It doesn't seem to crash either, which is good :)
Are these masses of tests (in box_[sg]et_props()) really necessary ?
What about having struct type (ObjectType *) and field offset fields in
PropDescription, and then let a pair of object_auto[sg]et_props()
functions handle that automatically ? [there will probably be a need for
macros around G_STRUCT_MEMBER to handle the access to the object's
fields].
I've got a 4) to append to your list of things to do :
4) provide functions which use the PropDescription to automate the
grunt work of _save() and _load() functions (basically, _load() becomes
_create() + modification of the field values according to whatever was
saved, then only update_values() the object). Bumm ! 100 less lines of
code per object (30-40 with lazyprops.h).
Are _[sg]et_state() still useful/mandatory with your code ? If yes, then :
5) provide functions to automatically build state objects
according to the PropDescription. If an object is complicated enough to
require a manual implementation, then the programmer still has the choice
to manually implement _[sg]et_state(). Otherwise, it becomes :
void foo_set_state(Foo *foo, FooState *state) {
prop_auto_get_state(state,foo_props,foo);
}
and basta ! 30 less lines of code per object.
Finally (while I'm at this),
6) There might be a use for a NotebookPageDesc object :
struct NotebookPageDesc {
{ _N("page 1"), 0 },
{ _N("page 2"), 0 },
{ _N("page 3"), 0 },
{ NULL } };
Then a field in PropDescription to tell the dialog building code in which
page to put each field (NULL page meaning _N("General"), and if only NULL
pages, then no notebook).
Just my .02 EUR, of course.
-- Cyrille
------------------------------------------------------------------------------
Grumpf.