Changeset 188de86 in git for Tst/Short/pyobject.tst


Ignore:
Timestamp:
Aug 2, 2012, 4:09:13 PM (11 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'c987db42cd2ec943b97ac5746c99892ceddf909c')
Children:
4f9652847609cefd5ff3b91d14f34611592ab699
Parents:
0419aba8292e7109329604d8ad03b70f8ef6542344a1c2199e33375a631289eaab7a81954c8383e2
Message:
Merge pull request #158 from alexanderdreyer/spielwiese

Transfering newstruct and pyobject fixes to Spielwiese
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Tst/Short/pyobject.tst

    r0419ab r188de86  
    138138attrib(new_pyobj, "new_attr");     // -> error message
    139139
     140// python list from empty Singular list (bug fixed?)
     141pyobject ll_empty = list();
     142ll_empty;
     143
     144// converting to and from intvec
     145intvec v0;
     146v0;
     147pyobject obj0 = v0;
     148obj0;
     149
     150intvec v=(1,2,3);
     151pyobject obj = v;
     152obj;
     153intvec(obj);
     154
     155intvec(python_eval("[1,2,9999999999]")); // -> error
     156intvec(python_eval("[1,2,list()]"));     // -> error
     157
     158ring r=0,x,lp;
     159def rl = ringlist(r);
     160
     161python_eval("tuple")(list(rl[1..3]));
     162
     163// interaction with newstruct'ed type
     164newstruct("wrapping","pyobject p");
     165wrapping wrapped;
     166
     167pyobject seventeen = 17;
     168wrapped.p = seventeen;
     169wrapped;
     170
     171proc unwrap(wrapping arg) { return (arg.p); }
     172system("install", "wrapping", "pyobject", unwrap, 1);
     173
     174pyobject released = wrapped;
     175released;
     176
     177proc wrap(pyobject arg) { wrapping res; res.p = arg; return (res); }
     178system("install", "pyobject", "wrapping", wrap, 1);
     179
     180pyobject nineteen = 19;
     181wrapped = nineteen;
     182wrapped;
     183
     184
     185// interaction with built-ins
     186proc to_poly(pyobject arg) { return (poly(23)); }
     187system("install", "pyobject", "poly", to_poly, 1);
     188
     189pyobject for_poly="4poly";
     190poly(for_poly);
     191
     192proc from_poly(poly arg) { pyobject res = string(arg); return (res); }
     193system("install", "pyobject", "=", from_poly, 1);
     194
     195poly p = x+1;
     196for_poly = p;
     197for_poly;
     198
     199
     200// interaction with both built-ins and newstructs
     201newstruct("another","pyobject p");
     202another other;
     203other.p = seventeen;
     204other;
     205
     206released = other;  // -> error
     207released;
     208
     209proc from_types(def arg) {
     210  if (typeof(arg) == "poly") { return (from_poly(arg)); }
     211  if (typeof(arg) == "another") { return (arg.p); }
     212}
     213system("install", "pyobject", "=", from_types, 1);
     214
     215released = other;
     216released;
     217released = p;
     218released;
     219
     220proc from_ideal(ideal arg) { pyobject res = "(missing)"; return (res); }
     221system("install", "pyobject", "=", from_ideal, 1);
     222pyobject ported = ringlist(r);
     223ported;
     224
    140225tst_status(1);
    141226$
Note: See TracChangeset for help on using the changeset viewer.