Format: application/x-python-code
⬇ Download File (3.1 KB)
   1  o
   2  
   3  �h��@sVdZddlZddlZddlmZej�ej�d��Z	ej
   4  Zee	j_
   5  ee	j_
   6  ee	j_
   7  e	jZdd�Zdd�Zd	d
   8  �Zej�ej�d��ZejZeje_
   9  ejZee_
  10  ejZee_
  11  ejZde_
  12  ege_ejZee_
  13  eejejejejeege_ejZde_
  14  eeege_e�ed�Zd
  15  d�Z dd�Z!e�Z"ddd�Z#e�$dee�Z%e%e#�Z&dd�Z'ddd�Z(dS)zGEventloop hook for OS X
  16  
  17  Calls NSApp / CoreFoundation APIs via ctypes.
  18  �N)�Event�objccCst|t�s
  19  |�d�}|S)zensure utf8 bytes�utf8)�
  20  isinstance�bytes�encode)�s�r	�Pc:\Users\shubh\Videos\agent\nova\Lib\site-packages\ipykernel/_eventloop_macos.py�_utf8s
  21  
  22  rcC�t�t|��S)z)create a selector name (for ObjC methods))r�sel_registerNamer)�namer	r	r
  23  �n�rcCr)zget an ObjC Class by name)r�
  24  objc_getClassr)�	classnamer	r	r
  25  �C$rr�CoreFoundation�kCFRunLoopCommonModescCsttgtj_ttd�td��S)z0Return the global NSApplication instance (NSApp)Z
  26  NSApplicationZsharedApplication��void_pr�objc_msgSend�argtypes�msgrrr	r	r	r
  27  �_NSAppPsrcCsltttttttttttgtj_ttd�td�ddddddddd�}ttttgtj_t|td�t|�d�dS)zWake the ApplicationZNSEventz]otherEventWithType:location:modifierFlags:timestamp:windowNumber:context:subtype:data1:data2:�rNzpostEvent:atStart:Tr)�NSApp�eventr	r	r
  28  �_wakeVs:�
  29  ��rcCs`t��t�}ttgtj_t|td��r)tttgtj_t|td�|�t	|�dSt
  30  t��dS)z.Callback to fire when there's input to be readZ	isRunningzstop:N)�
  31  _triggered�setrrrrrrrr�
  32  CFRunLoopStop�CFRunLoopGetCurrent)�timer�looprr	r	r
  33  �stop|sr&cCs,tdt�|dddtd�}tt�|t�dS)z1Register callback to stop eventloop after a delayNr)�CFRunLoopTimerCreate�CFAbsoluteTimeGetCurrent�_c_stop_callback�CFRunLoopAddTimer�CFRunLoopGetMainr)�delayr$r	r	r
  34  �_stop_after�s�	�r-�cCsHt��t�}t|�ttgtj_t|t	d��t�
  35  �s"t��dSdS)z<run the Cocoa eventloop for the specified duration (seconds)�runN)
  36  r �clearrr-rrrrrr�is_setrZCFRunLoopRun)�durationrr	r	r
  37  �mainloop�s�r3)NN)r.))�__doc__�ctypesZctypes.util�	threadingr�cdll�LoadLibrary�utilZfind_libraryr�c_void_prr�restyper
  38  rrrrrrr(�c_doubler#r+r"rr'�c_intr*�in_dllrrrr r&�	CFUNCTYPEZ_c_callback_func_typer)r-r3r	r	r	r
  39  �<module>s^
  40  ��
  41  #
  42