(cls, name_or_ptr, bases=None, attrs=None, *, protocols=())
return self
The constructor accepts either the name of an Objective-C class to look up
        (as :class:`str` or :class:`bytes`), or a pointer to an existing class object
        (in any form accepted by :class:`ObjCInstance`).

        If given a pointer, it must refer to an Objective-C class; pointers to other objects are not accepted.
        (Use :class:`ObjCInstance` to wrap a pointer that might also refer to other kinds of objects.)
        If the pointer refers to a metaclass, an instance of :class:`ObjCMetaClass` is returned instead.
        Creating an :class:`ObjCClass` from a ``Nil`` pointer returns ``None``.

        :class:`ObjCClass` can also be called like :class:`type`, with three arguments
        (name, bases list, namespace mapping). This form is called implicitly by Python's ``class`` syntax,
        and is used to create a new Objective-C class from Python (see :ref:`custom-classes-and-protocols`).
        The bases list must contain exactly one :class:`ObjCClass` to be extended by the new class.
        An optional ``protocols`` keyword argument is also accepted,
        which must be a sequence of :class:`ObjCProtocol`\\s for the new class to adopt.
The constructor accepts either the name of an Objective-C class to look up
        (as :class:`str` or :class:`bytes`), or a pointer to an existing class object
        (in any form accepted by :class:`ObjCInstance`).
The constructor accepts either the name of an Objective - C class to look up ( as : class : str or : class : bytes ) or a pointer to an existing class object ( in any form accepted by : class : ObjCInstance ) .
def __new__(cls, name_or_ptr, bases=None, attrs=None, *, protocols=()):
        """The constructor accepts either the name of an Objective-C class to look up
        (as :class:`str` or :class:`bytes`), or a pointer to an existing class object
        (in any form accepted by :class:`ObjCInstance`).

        If given a pointer, it must refer to an Objective-C class; pointers to other objects are not accepted.
        (Use :class:`ObjCInstance` to wrap a pointer that might also refer to other kinds of objects.)
        If the pointer refers to a metaclass, an instance of :class:`ObjCMetaClass` is returned instead.
        Creating an :class:`ObjCClass` from a ``Nil`` pointer returns ``None``.

        :class:`ObjCClass` can also be called like :class:`type`, with three arguments
        (name, bases list, namespace mapping). This form is called implicitly by Python's ``class`` syntax,
        and is used to create a new Objective-C class from Python (see :ref:`custom-classes-and-protocols`).
        The bases list must contain exactly one :class:`ObjCClass` to be extended by the new class.
        An optional ``protocols`` keyword argument is also accepted,
        which must be a sequence of :class:`ObjCProtocol`\\s for the new class to adopt.
        """

        if (bases is None) ^ (attrs is None):
            raise TypeError('ObjCClass arguments 2 and 3 must be given together')

        if bases is None and attrs is None:
            # A single argument provided. If it's a string, treat it as
            # a class name. Anything else treat as a class pointer.

            if protocols:
                raise ValueError('protocols kwarg is not allowed for the single-argument form of ObjCClass')

            attrs = {}

            if isinstance(name_or_ptr, (bytes, str)):
                ptr, name = cls._new_from_name(name_or_ptr)
            else:
                ptr, name = cls._new_from_ptr(name_or_ptr)
                if not issubclass(cls, ObjCMetaClass) and libobjc.class_isMetaClass(ptr):
                    return ObjCMetaClass(ptr)
        else:
            ptr, name, attrs = cls._new_from_class_statement(name_or_ptr, bases, attrs, protocols=protocols)

        objc_class_name = name.decode('utf-8')

        new_attrs = {
            'name': objc_class_name,
            'methods_ptr_count': c_uint(0),
            'methods_ptr': None,
            # Mapping of name -> method pointer
            'instance_method_ptrs': {},
            # Mapping of name -> instance method
            'instance_methods': {},
            # Mapping of name -> (accessor method, mutator method)
            'instance_properties': {},
            # Explicitly declared properties
            'forced_properties': set(),
            # Mapping of first keyword -> ObjCPartialMethod instances
            'partial_methods': {},
        }

        # On Python 3.6 and later, the class namespace may contain a __classcell__ attribute that must be passed on
        # to type.__new__. See https://docs.python.org/3/reference/datamodel.html#creating-the-class-object
        if '__classcell__' in attrs:
            new_attrs['__classcell__'] = attrs['__classcell__']

        # Create the class object. If there is already a cached instance for ptr,
        # it is returned and the additional arguments are ignored.
        # Logically this can only happen when creating an ObjCClass from an existing
        # name or pointer, not when creating a new class.
        # If there is no cached instance for ptr, a new one is created and cached.
        self = super().__new__(cls, ptr, objc_class_name, (ObjCInstance,), new_attrs)

        return self
def __new__ ( cls , name_or_ptr , bases = None , attrs = None , * , protocols = ( ) ) : if ( bases is None ) ^ ( attrs is None ) : raise TypeError ( 'ObjCClass arguments 2 and 3 must be given together' ) if bases is None and attrs is None : # A single argument provided. If it's a string, treat it as # a class name. Anything else treat as a class pointer. if protocols : raise ValueError ( 'protocols kwarg is not allowed for the single-argument form of ObjCClass' ) attrs = { } if isinstance ( name_or_ptr , ( bytes , str ) ) : ptr , name = cls . _new_from_name ( name_or_ptr ) else : ptr , name = cls . _new_from_ptr ( name_or_ptr ) if not issubclass ( cls , ObjCMetaClass ) and libobjc . class_isMetaClass ( ptr ) : return ObjCMetaClass ( ptr ) else : ptr , name , attrs = cls . _new_from_class_statement ( name_or_ptr , bases , attrs , protocols = protocols ) objc_class_name = name . decode ( 'utf-8' ) new_attrs = { 'name' : objc_class_name , 'methods_ptr_count' : c_uint ( 0 ) , 'methods_ptr' : None , # Mapping of name -> method pointer 'instance_method_ptrs' : { } , # Mapping of name -> instance method 'instance_methods' : { } , # Mapping of name -> (accessor method, mutator method) 'instance_properties' : { } , # Explicitly declared properties 'forced_properties' : set ( ) , # Mapping of first keyword -> ObjCPartialMethod instances 'partial_methods' : { } , } # On Python 3.6 and later, the class namespace may contain a __classcell__ attribute that must be passed on # to type.__new__. See https://docs.python.org/3/reference/datamodel.html#creating-the-class-object if '__classcell__' in attrs : new_attrs [ '__classcell__' ] = attrs [ '__classcell__' ] # Create the class object. If there is already a cached instance for ptr, # it is returned and the additional arguments are ignored. # Logically this can only happen when creating an ObjCClass from an existing # name or pointer, not when creating a new class. # If there is no cached instance for ptr, a new one is created and cached. self = super ( ) . __new__ ( cls , ptr , objc_class_name , ( ObjCInstance , ) , new_attrs ) return self