Exemple #1
0
 def set(instance, strings):
     bufs = []
     for string in strings:
         if string is None:
             buf = iface.NULL
         else:
             buf = iface.new('char[]', string.encode())
         bufs.append(buf)
     self._check_size(instance, bufs)
     cdata_obj = iface.new('char*[]', bufs)
     self.set_backing_object(instance, self.wrapped_attrname,
                             cdata_obj, (cdata_obj, bufs))
Exemple #2
0
 def set(instance, strings):
     bufs = []
     for string in strings:
         if string is None:
             buf = iface.NULL
         else:
             buf = iface.new('char[]', string.encode())
         bufs.append(buf)
     self._check_size(instance, bufs)
     cdata_obj = iface.new('char*[]', bufs)
     self.set_backing_object(instance, self.wrapped_attrname, cdata_obj,
                             (cdata_obj, bufs))
Exemple #3
0
 def set(instance, bools):
     bools = [bool(b) for b in bools]
     self._check_size(instance, bools)
     cdata = iface.new('unsigned char[]', bools)
     self.set_backing_object(instance,
                             self.wrapped_attrname,
                             backing_value=cdata)
Exemple #4
0
 def set(instance, ints):
     ints = [int(i) for i in ints]
     self._check_size(instance, ints)
     cdata_obj = iface.new('int[]', ints)
     self.set_backing_object(instance,
                             self.wrapped_attrname,
                             backing_value=cdata_obj)
Exemple #5
0
 def set(instance, objects):
     cdata_objs = [obj.cdata if obj is not None else iface.NULL
                   for obj in objects]
     size = getattr(instance, self.sizeattr)
     if len(cdata_objs) != size:
         errmsg = 'List has size %i, should be %i' % (len(cdata_objs),
                                                      size)
         raise AttributeSizeError(errmsg)
     t = self.klass._struct + '*[]'
     cdata_objsp = iface.new(t, cdata_objs)
     self.set_backing_object(instance, self.wrapped_attrname,
                             cdata_objsp, (cdata_objsp, cdata_objs))
Exemple #6
0
 def set(instance, objects):
     cdata_objs = [
         obj.cdata if obj is not None else iface.NULL for obj in objects
     ]
     size = getattr(instance, self.sizeattr)
     if len(cdata_objs) != size:
         errmsg = 'List has size %i, should be %i' % (len(cdata_objs),
                                                      size)
         raise AttributeSizeError(errmsg)
     t = self.klass._struct + '*[]'
     cdata_objsp = iface.new(t, cdata_objs)
     self.set_backing_object(instance, self.wrapped_attrname,
                             cdata_objsp, (cdata_objsp, cdata_objs))
Exemple #7
0
 def __setitem__(self, idx, string):
     self._check_idx(idx)
     if string is None:
         buf = iface.NULL
     else:
         buf = iface.new('char[]', string.encode())
     cdata, bufs = getattr(self.instance, self.listattr.wrapped_attrname)
     cdata[idx] = buf
     bufs[idx] = buf
     backing_object = getattr(
         getattr(self.instance, self.instance._backing_object),
         self.listattr.backing)
     backing_object[idx] = buf
Exemple #8
0
 def __setitem__(self, idx, string):
     self._check_idx(idx)
     if string is None:
         buf = iface.NULL
     else:
         buf = iface.new('char[]', string.encode())
     cdata, bufs = getattr(self.instance, self.listattr.wrapped_attrname)
     cdata[idx] = buf
     bufs[idx] = buf
     backing_object = getattr(getattr(self.instance,
                                      self.instance._backing_object),
                              self.listattr.backing)
     backing_object[idx] = buf
Exemple #9
0
 def set(instance, string):
     if string is None:
         cdata = iface.NULL
     else:
         cdata = iface.new('char[]', string.encode())  # TODO py2/py3k
     self.set_backing_object(instance, self.wrapped_attrname, cdata)
Exemple #10
0
 def set(instance, buf):
     if buf is None:
         cdata = iface.NULL
     else:
         cdata = iface.new('unsigned char[]', bytes(buf))
     self.set_backing_object(instance, self.wrapped_attrname, cdata)
Exemple #11
0
 def set(instance, bools):
     bools = [bool(b) for b in bools]
     self._check_size(instance, bools)
     cdata = iface.new('unsigned char[]', bools)
     self.set_backing_object(instance, self.wrapped_attrname,
                             backing_value=cdata)
Exemple #12
0
 def set(instance, ints):
     ints = [int(i) for i in ints]
     self._check_size(instance, ints)
     cdata_obj = iface.new('int[]', ints)
     self.set_backing_object(instance, self.wrapped_attrname,
                             backing_value=cdata_obj)
Exemple #13
0
 def set(instance, string):
     if string is None:
         cdata = iface.NULL
     else:
         cdata = iface.new('char[]', string.encode())  # TODO py2/py3k
     self.set_backing_object(instance, self.wrapped_attrname, cdata)
Exemple #14
0
 def set(instance, buf):
     if buf is None:
         cdata = iface.NULL
     else:
         cdata = iface.new('unsigned char[]', bytes(buf))
     self.set_backing_object(instance, self.wrapped_attrname, cdata)