Re: SQL parser ready to hook up to Dia



Le mar, aoû 14, 2001, à 07:33:58 -0700, Andrew S . Halper a écrit:

About that...  I've gotten as far as being ready to set the "name" property of
the UML class (may not have the terminology correct here...still learning the
StdProp interface), but now I'm kind of stuck and could use some help.

The code leading up to it is:

      /* these should be probably changed to more useful defaults
       eventually */
      startpoint.x = 0.0;
      startpoint.y = 0.0;
      umlclass_obj = otype->ops->create(&startpoint, otype->default_user_data,
                                      &h1, &h2);
      layer_add_object(layer, umlclass_obj);

      props = prop_list_from_descs(sql_prop_descs, pdtpp_true);
      g_assert(props->len == 11);

which should look familiar, because I just nicked it from dxf-import.c and
renamed some variables.  In the next line, I think I need to set up the "name"
property of UML class I created in umlclass_obj.  In the DXF import plug-in, you
have:

    ((PointProperty *)(g_ptr_array_index(props,0)))->point_data.x = start.x;

In fact, that's the first snippet I wrote. I now prefer to write slightly
differently:

        PointProperty *ptprop; /* one for each of the types I'll need */
        /* ... */

        ptprop = g_ptr_array_index(props,0);
        ptrop->point_data = start; /* you can move a small struct in a
                                        single statement */

and then let gcc simplify the code down to the first form. Neither form
really satisfies me.

and I assume I need to do something similar, but with different casts and
structure references.  Where should I look to relate the 4th element of
sql_prop_descs:

  { "name", PROP_TYPE_STRING, PROP_FLAG_VISIBLE, N_("Name"), NULL, NULL },

(In those property descriptors, where you never use the properties to do
anything else than obj->ops->set_props(obj,props), no clipboard, no
load/save, no dialogs, you can abridge to just the first two fields).

to the type of structure pointer cast I need to do?

"Almost" trivial:
        grep PROP_TYPE_WHATEVER lib/prop_*.c | grep register
and then you look for the type used in the whateverprop_ops methods.
 (WhateverProperty *) defined in lib/prop_*.h would be a safe bet, in this 
case.

Hmmm.... A few comments in lib/properties.h wouldn't hurt, would they ?
On my TODO.

Also, of course I was wondering if there was some luxurious plug-in writer's
documentation I could add this to once I figure it out?  If not, I can attempt
to cook one up while I'm doing this.

ahem :-)

        -- Cyrille

-- 
Grumpf.





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]