Changeset 769a27 in git


Ignore:
Timestamp:
Apr 24, 2015, 11:04:41 AM (8 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'spielwiese', '8e0ad00ce244dfd0756200662572aef8402f13d5')
Children:
20f29bb8cb76fe2c06f278317d3df2c5d344e796
Parents:
dabe36d14b912971b3ee9a07d9d75e0ad989dc13
Message:
fix: user defined assign of newstruct objects
Location:
Singular
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • Singular/dyn_modules/pyobject/pyobject.cc

    rdabe36d r769a27  
    358358
    359359    sleftv tmp;
    360     BOOLEAN newstruct_equal(int, leftv, leftv); // declaring overloaded '='
    361     if (!newstruct_equal(PythonInterpreter::id(), &tmp, value))
     360    BOOLEAN newstruct_Assign_user(int, leftv, leftv); // declaring overloaded '='
     361    if (!newstruct_Assign_user(PythonInterpreter::id(), &tmp, value))
    362362      return PythonCastStatic<>(&tmp);
    363363
  • Singular/newstruct.cc

    rdabe36d r769a27  
    166166
    167167// Used by newstruct_Assign for overloaded '='
    168 BOOLEAN newstruct_equal(int op, leftv l, leftv r)
     168BOOLEAN newstruct_Assign_user(int op, leftv l, leftv r)
    169169{
    170170  blackbox *ll=getBlackboxStuff(op);
     
    222222}
    223223
     224static BOOLEAN newstruct_Assign_same(leftv l, leftv r)
     225{
     226  assume(l->Typ() == r->Typ());
     227  if (l->Data()!=NULL)
     228  {
     229    lists n1=(lists)l->Data();
     230    lClean_newstruct(n1);
     231  }
     232  lists n2=(lists)r->Data();
     233  n2=lCopy_newstruct(n2);
     234  r->CleanUp();
     235  if (l->rtyp==IDHDL)
     236  {
     237    IDDATA((idhdl)l->data)=(char *)n2;
     238  }
     239  else
     240  {
     241    l->data=(void *)n2;
     242  }
     243  return FALSE;
     244}
     245
    224246BOOLEAN newstruct_Assign(leftv l, leftv r)
    225247{
     248  assume(l->Typ() > MAX_TOK);
     249  if (l->Typ()==r->Typ())
     250  {
     251    return newstruct_Assign_same(l,r);
     252  }
     253  // is there an overloading '=' ?
     254  sleftv tmp;
     255  if(!newstruct_Assign_user(l->Typ(), &tmp, r)) return newstruct_Assign(l, &tmp);
     256  // not, try to find an equal type or parent newstruct
    226257  if (r->Typ()>MAX_TOK)
    227258  {
     
    257288        if (! newstruct_Op1(l->Typ(), &tmp, r))  return newstruct_Assign(l, &tmp);
    258289      }
    259     }
    260     if (l->Typ()==r->Typ())
    261     {
    262       if (l->Data()!=NULL)
    263       {
    264         lists n1=(lists)l->Data();
    265         lClean_newstruct(n1);
    266       }
    267       lists n2=(lists)r->Data();
    268       n2=lCopy_newstruct(n2);
    269       r->CleanUp();
    270       if (l->rtyp==IDHDL)
    271       {
    272         IDDATA((idhdl)l->data)=(char *)n2;
    273       }
    274       else
    275       {
    276         l->data=(void *)n2;
    277       }
    278       return FALSE;
    279     }
    280   }
    281   else
    282   {
    283     assume(l->Typ() > MAX_TOK);
    284     sleftv tmp;
    285     if(!newstruct_equal(l->Typ(), &tmp, r)) return newstruct_Assign(l, &tmp);
     290      if (l->Typ()==r->Typ())
     291        return newstruct_Assign_same(l,r);
     292    }
    286293  }
    287294  Werror("assign %s(%d) = %s(%d)",
Note: See TracChangeset for help on using the changeset viewer.