Exemple #1
0
    def __finalizetype__(cls):
        SmallVectorsBase.__finalizetype__(cls)

        # Make all x, y, z, etc property accessors. Mutable objects have
        # read/write accessors, while immutable types have only the read
        # accessor.
        def getter(i):
            return lambda self: self[i]

        def setter(i):
            return lambda self, value: self.__setitem__(i, value)

        for i in range(cls.size or 0):
            prop = property(getter(i))
            if issubclass(cls, Mutable):
                prop = prop.setter(setter(i))

            attr = 'x%i' % i
            if not hasattr(cls, attr):
                setattr(cls, attr, prop)
            if i < 4:
                attr = ('x', 'y', 'z', 'w')[i]
                if not hasattr(cls, attr):
                    setattr(cls, attr, prop)
Exemple #2
0
    def __finalizetype__(cls):
        SmallVectorsBase.__finalizetype__(cls)

        # Make all x, y, z, etc property accessors. Mutable objects have
        # read/write accessors, while immutable types have only the read
        # accessor.
        def getter(i):
            return lambda self: self[i]

        def setter(i):
            return lambda self, value: self.__setitem__(i, value)

        for i in range(cls.size or 0):
            prop = property(getter(i))
            if issubclass(cls, Mutable):
                prop = prop.setter(setter(i))

            attr = 'x%i' % i
            if not hasattr(cls, attr):
                setattr(cls, attr, prop)
            if i < 4:
                attr = ('x', 'y', 'z', 'w')[i]
                if not hasattr(cls, attr):
                    setattr(cls, attr, prop)
Exemple #3
0
 def __preparenamespace__(cls, params):
     ns = SmallVectorsBase.__preparenamespace__(params)
     if isinstance(params[0], int) and params[0] > 4:
         ns.update(__slots__='flat')
     return ns
Exemple #4
0
 def __preparenamespace__(cls, params):
     ns = SmallVectorsBase.__preparenamespace__(params)
     if isinstance(params[0], int) and params[0] > 4:
         ns.update(__slots__='flat')
     return ns