Changeset 396 for cpp/frams/param


Ignore:
Timestamp:
06/23/15 00:52:00 (9 years ago)
Author:
Maciej Komosinski
Message:
  • makeParamTab can now turn PARAM_READONLY into PARAM_USERREADONLY
  • fixed paramtab/paramobject creation for objects containing 'p' members
Location:
cpp/frams/param
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • cpp/frams/param/paramobj.cpp

    r348 r396  
    2323
    2424ParamEntry* ParamObject::makeParamTab(ParamInterface *pi, bool stripgroups, bool stripproc,
    25         int firstprop, int maxprops, bool dupentries, int flagsexclude, bool addnew, const char* rename)
     25                                      int firstprop, int maxprops, bool dupentries, int flagsexclude, bool addnew, const char* rename, bool readonly_into_userreadonly)
    2626{
    2727        ParamEntry *tab, *t;
     
    6969        for (i = firstprop; i < pi->getPropCount(); i++)
    7070        {
    71                 if ((!stripproc) || (strchr("dfsox", *pi->type(i))))
     71                const char* type=pi->type(i);
     72                if ((!stripproc) || (strchr("dfsox", type[0])))
    7273                {
    7374                        if ((!flagsexclude) || (!(pi->flags(i)&flagsexclude)))
    7475                        {
    75                                 t->offset = offset;
    76                                 if (*pi->type(i) != 'x') t->offset += (((char*)&ex.data[0]) - ((char*)&ex));
     76                                if (type[0]=='p')
     77                                        t->offset=0;
     78                                else
     79                                        {
     80                                        t->offset = offset;
     81                                        if (type[0] != 'x') t->offset += (((char*)&ex.data[0]) - ((char*)&ex));
     82                                        offset += sizeof(ExtValue);
     83                                        }
    7784                                t->group = (short)(stripgroups ? 0 : pi->group(i));
    7885                                t->flags = (short)pi->flags(i);
     86                                if (readonly_into_userreadonly && (t->flags & PARAM_READONLY))
     87                                        t->flags=(t->flags & ~PARAM_READONLY) | PARAM_USERREADONLY;
    7988                                t->fun1 = 0;
    8089                                t->fun2 = 0;
    8190                                t->id = maybedup(dupentries, pi->id(i));
    8291                                t->name = maybedup(dupentries, pi->name(i));
    83                                 t->type = maybedup(dupentries, pi->type(i));
     92                                t->type = maybedup(dupentries, type);
    8493                                t->help = maybedup(dupentries, pi->help(i));
    85                                 t++; n++; offset += sizeof(ExtValue);
     94                                t++; n++;
    8695                                if (n > count) break;
    8796                        }
     
    165174ParamObject* ParamObject::makeObject(ParamEntry *tab)
    166175{
    167         if (!tab) return 0;
    168         int n = tab->flags;
    169         if (!n) return 0;
    170         ParamObject *obj = new(n)ParamObject(n, tab); // new(n): allocate n fields ; ParamObject(n,...): tell the object it has n fields
     176        if (!tab) return NULL;
     177        int n=tab->flags, used_fields=0;
     178        for (ParamEntry *t=tab+tab->group; n > 0; n--, t++)
     179                if (strchr("dfsox",t->type[0]))
     180                        used_fields++;
     181
     182        if (used_fields==0) return NULL;
     183        ParamObject *obj = new(used_fields)ParamObject(used_fields, tab); // new(n): allocate n fields ; ParamObject(n,...): tell the object it has n fields
    171184        ExtValue *v = &obj->fields[0];
    172         tab += tab->group;
    173         for (; n > 0; n--, tab++)
    174                 switch (*tab->type)
     185        n=tab->flags;
     186        for (ParamEntry *t=tab+tab->group; n > 0; n--, t++)
     187                switch (*t->type)
    175188        {
    176189                case 'd': v->setInt(0); v++; break;
  • cpp/frams/param/paramobj.h

    r333 r396  
    5353                ParamObject::freeObject(obj2);
    5454                */
    55         static ParamEntry* makeParamTab(ParamInterface *pi, bool stripgroups = 0, bool stripproc = 0, int firstprop = 0, int maxprops = 9999, bool dupentries = false, int flagsexclude = 0, bool addnew = false, const char* rename = NULL);
     55        static ParamEntry* makeParamTab(ParamInterface *pi, bool stripgroups = 0, bool stripproc = 0, int firstprop = 0, int maxprops = 9999, bool dupentries = false, int flagsexclude = 0, bool addnew = false, const char* rename = NULL,bool readonly_into_userreadonly=false);
    5656
    5757        /** deallocate paramtab obtained from makeParamTab() */
Note: See TracChangeset for help on using the changeset viewer.