def remove(self, item): SHMOBJ.protect(self) np = py2shmobj.shmlist_first(self.addr) while np: (p,datatype,datalen) = py2shmobj.shmlnode_get(np) obj = typed_ptr(p,datatype) if obj == item: py2shmobj.shmlist_remove(self.addr, np) return None np = py2shmobj.shmlist_next(self.addr,np)
def delitem(self, idx, shallow=False): SHMOBJ.protect(self) np = py2shmobj.shmlist_getnode(self.addr, idx) if not np: raise IndexError if not shallow: (p,datatype,datalen) = py2shmobj.shmlnode_get(np) if p: obj = typed_ptr(p,datatype) if isinstance(obj, SHMLST): obj.delete(shallow=shallow) else: obj.delete() py2shmobj.shmlist_remove(self.addr,np) py2shmobj.shmobj_del(np)
def delete(self, shallow=False): SHMOBJ.protect(self) np = py2shmobj.shmlist_first(self.addr) while np: if not shallow: (p,datatype,datalen) = py2shmobj.shmlnode_get(np) if p: val = typed_ptr(p,datatype) if type(val) in [SHMLST, SHMDCT]: val.delete(shallow=shallow) elif isinstance(val, SHMOBJ): val.delete() next = py2shmobj.shmlist_next(self.addr,np) py2shmobj.shmlist_remove(self.addr, np) py2shmobj.shmobj_del(np) np = next SHMOBJ.delete(self)