File: //usr/lib/python3.9/site-packages/usb/__pycache__/_objfinalizer.cpython-39.opt-1.pyc
a
j��Y� � @ s^ d dl Z dgZG dd� de�Ze jdkrJd dlZdd� ZG dd� de�ZnG d d� de�ZdS )
� N�AutoFinalizedObjectc s@ e Zd ZdZdd� Z� fdd�Zdd� Zdd � Zd
d� Z� Z S )�_AutoFinalizedObjectBasez[
Base class for objects that get automatically
finalized on delete or at exit.
c C s dS )z�Actually finalizes the object (frees allocated resources etc.).
Returns: None
Derived classes should implement this.
N� ��selfr r �5/usr/lib/python3.9/site-packages/usb/_objfinalizer.py�_finalize_object* s z)_AutoFinalizedObjectBase._finalize_objectc s t t| ��| �}d|_|S )z�Creates a new object instance and adds the private finalizer
attributes to it.
Returns: new object instance
Arguments:
* *args, **kwargs -- ignored
F)�superr �__new__�_finalize_called��cls�args�kwargs�instance�� __class__r r r
3 s z _AutoFinalizedObjectBase.__new__c C s | j sd| _ | �� dS )z\Helper method that finalizes the object if not already done.
Returns: None
TN)r r r r r r �_do_finalize_object@ s z,_AutoFinalizedObjectBase._do_finalize_objectc C s t d��dS )zIFinalizes the object if not already done.
Returns: None
z6finalize() must be implemented by AutoFinalizedObject.N)�NotImplementedErrorr r r r �finalizeI s �z!_AutoFinalizedObjectBase.finalizec C s | � � d S )N)r r r r r �__del__S s z _AutoFinalizedObjectBase.__del__)
�__name__�
__module__�__qualname__�__doc__r r
r r r �
__classcell__r r r r r $ s
r i c C s | � }|dur|� � dS )a) Helper function for weakref.finalize() that dereferences a weakref
to an object and calls its _do_finalize_object() method if the object
is still alive. Does nothing otherwise.
Returns: None (implicit)
Arguments:
* obj_ref -- weakref to an object
N�r )Zobj_ref�objr r r �_do_finalize_object_ref[ s
r c s$ e Zd Z� fdd�Zdd� Z� ZS )r c s8 t t| �j| g|�R i |��}t�|tt�|��|_|S )a& Creates a new object instance and adds the private finalizer
attributes to it.
Returns: new object instance
Arguments:
* *args, **kwargs -- passed to the parent instance creator
(which ignores them)
)r r r
�weakrefr r �ref�
_finalizerr r r r r
m s
����zAutoFinalizedObject.__new__c C s | � � dS �z)Finalizes the object if not already done.N)r! r r r r r � s �AutoFinalizedObject.finalize)r r r r
r r r r r r r k s !c @ s e Zd Zdd� ZdS )r c C s | � � dS r"