+
    ĜiM                       ^ RI Ht ^ RIt^ RIt^ RIHtHtHt ^ RIH	t	H
t
 ^ RIHt ^ RIHtHtHtHtHt ^ RIHt ^ RIHtHt ^ R	IHtHtHtHtHtHtHtH t H!t!H"t" ^ R
I#H$t$ ]'       d   ^ RI%t%^ RI&H't'H(t(H)t)H*t*H+t+ ^ RI#H,t, R R lt-]! R].4      t/^ t0]	! RR7       ! R R4      4       t1]R R l4       t2 ! R R]4      t3R R lt4]	! RR7       ! R R4      4       t5R# )    )annotationsN)asynccontextmanagercontextmanagersuppress)	dataclassfield)
format_exc)TYPE_CHECKINGAnyNewTypeProtocolcast)init_mini_racer)JSEvalExceptionJSPromiseError)
CancelableJSFunctionJSArray
JSFunctionJSMappedObjectJSObject	JSPromiseJSUndefinedJSUndefinedTypePyJsFunctionTypePythonJSConvertedTypesValueHandle)AsyncGeneratorCallable	Coroutine	GeneratorIterator)RawValueHandleTypec                   V ^8  d   QhRR/#    returnint )formats   "_/Users/mibo/.openclaw/workspace/.venv-ak/lib/python3.14/site-packages/py_mini_racer/_context.py__annotate__r,   !   s     ' 's '    c                 L    \        RR7      p \        V P                  4       4      # )z=For tests only: how many context handles are still allocated?T)ignore_duplicate_init)r   r(   mr_context_count)dlls    r+   context_countr2   !   s"     
5Cs##%&&r-   ContextTypeT)frozenc                  <    ] tR t^,t$ RtR]R&   R]R&   R R ltRtR	# )
_TaskSetzpThis is a very very simplistic standin for Python 3.11+ TaskGroups (whereas we
are still targeting Python 3.10).asyncio.AbstractEventLoop_event_loopz)set[asyncio.Task[PythonJSConvertedTypes]]_ongoing_tasksc                    V ^8  d   QhRRRR/# )r&   corozCoroutine[Any, Any, None]r'   Noner)   )r*   s   "r+   r,   _TaskSet.__annotate__4   s     < <8 <T <r-   c                	    V P                   P                  V4      pV P                  P                  V4       VP	                  V P                  P
                  4       R # N)r8   create_taskr9   addadd_done_callbackdiscard)selfr;   tasks   && r+   
start_task_TaskSet.start_task4   sF    ++D1%t22::;r-   r)   N)__name__
__module____qualname____firstlineno____doc____annotations__rF   __static_attributes__r)   r-   r+   r6   r6   ,   s    ) +*==< <r-   r6   c                    V ^8  d   QhRRRR/# )r&   
event_loopr7   r'   zAsyncGenerator[_TaskSet, None]r)   )r*   s   "r+   r,   r,   ;   s      )#r-   c           
      "   \        4       p \        W4      5x  \        V4       FG  p\        \        P
                  4      ;_uu_ 4        VP                  4        VG R j  xL
  R R R 4       KI  	  R #  L  + '       g   i     K`  ; i  \        T4       F\  p\        \        P
                  4      ;_uu_ 4        TP                  4        TG R j  xL 
  R R R 4       KJ    + '       g   i     K[  ; i	  i ; i5ir?   )setr6   listr   asyncioCancelledErrorcancel)rP   ongoing_tasksts   &  r+   _make_task_setrY   :   s      @CuMz11m$A'0011
 21 %  211 m$A'0011
 2111 %si   C:B
 /C:A6!A4
"A6&C:4A66B	C:
0C7:C CC 
C7 C1+C77C:c                  .    ] tR t^ItR R ltR R ltRtR# )ObjectFactoryc               $    V ^8  d   QhRRRRRR/# )r&   ctxContext
val_handler   r'   r   r)   )r*   s   "r+   r,   ObjectFactory.__annotate__J   s$     % %%(3%	%r-   c                	    R # r?   r)   )rD   r]   r_   s   &&&r+   value_handle_to_python$ObjectFactory.value_handle_to_pythonJ   s    !$r-   c               $    V ^8  d   QhRRRRRR/# )r&   r]   r^   objr   r'   r   r)   )r*   s   "r+   r,   r`   N   s$      !7	r-   c                	    R # r?   r)   )rD   r]   re   s   &&&r+   python_to_value_handle$ObjectFactory.python_to_value_handleN   s    r-   r)   N)rH   rI   rJ   rK   rb   rg   rN   r)   r-   r+   r[   r[   I   s    % r-   r[   c                   V ^8  d   QhRR/# )r&   r'   z asyncio.AbstractEventLoop | Noner)   )r*   s   "r+   r,   r,   S   s      "B r-   c                 R     \         P                  ! 4       #   \         d     R # i ; ir?   )rT   get_running_loopRuntimeErrorr)   r-   r+   get_running_loop_or_nonerm   S   s(    '')) s    &&c                     ] tR t^Zt$ RtR]R&   R]R&   R]R&   R]R	&   R
]R&   ]! ]R7      tR]R&   ]! ]	P                  R7      tR]R&   R R ltR R ltR R ltR R lt]R R l4       tR R ltR R ltR R  ltR! R" ltR# R$ ltR% R& ltR' R( ltR) R* ltR+ R, ltR- R. ltR/ R0 ltR1 R2 ltR3]/R4 R5 lltR3]/R6 R7 llt R8 R9 lt!R: R; lt"R< R= lt#R> R? lt$R@ RA lt%RB RC lt&RD RE lt'RF RG lt(]RH RI l4       t)]*RJ RK l4       t+RL RM lt,RN RO lt-RP RQ lt.RR RS lt/RT RU lt0RV RW lt1RX RY lt2RZ R[ lt3R\ R] lt4R^t5R_# )`r^   zHWrapper for all operations involving the DLL and C++ MiniRacer::Context.zctypes.CDLL_dllr3   _ctxr7   rP   r[   _object_factoryzIterator[int]_next_async_callback_id)default_factoryz(dict[int, Callable[[ValueHandle], None]]$_active_cancelable_mr_task_callbackszqueue.Queue[ValueHandle]%_non_cancelable_mr_task_results_queuec                   V ^8  d   QhRR/# r&   r'   strr)   )r*   s   "r+   r,   Context.__annotate__j   s     > >C >r-   c                	f    \        V P                  P                  4       P                  R 4      4      # zutf-8)rx   ro   mr_v8_versiondecoderD   s   &r+   
v8_versionContext.v8_versionj   s%    499**,33G<==r-   c                   V ^8  d   QhRR/# r&   r'   boolr)   )r*   s   "r+   r,   ry   m   s     8 8T 8r-   c                H    \        V P                  P                  4       4      # )zIChecks for enablement of the V8 Sandbox. See https://v8.dev/blog/sandbox.)r   ro   mr_v8_is_using_sandboxr~   s   &r+   v8_is_using_sandboxContext.v8_is_using_sandboxm   s     DII44677r-   c               $    V ^8  d   QhRRRRRR/# )r&   callback_idr(   raw_val_handler#   r'   r<   r)   )r*   s   "r+   r,   ry   r   s$      0B	r-   c                	    V P                  V4      pV\        8X  d   V P                  P                  V4       R # V P                  P                  V P                  W4       R # r?   )_wrap_raw_handle_UNCANCELABLE_TASK_CALLBACK_IDru   putrP   call_soon_threadsafe&_handle_callback_from_v8_on_event_loop)rD   r   r   r_   s   &&& r+   handle_callback_from_v8Context.handle_callback_from_v8r   sN     **>:
8866:::FOO00;;[r-   c               $    V ^8  d   QhRRRRRR/# )r&   r   r(   r_   r   r'   r<   r)   )r*   s   "r+   r,   ry      s$     	 		,7			r-   c                	b     V P                   V,          pT! T4       R #   \         d     R # i ; ir?   )rt   KeyError)rD   r   r_   callbacks   &&& r+   r   .Context._handle_callback_from_v8_on_event_loop   s5    	@@MH
 		  		s    ..c                    V ^8  d   QhRRRR/# )r&   funcCallable[[ValueHandle], None]r'   zGenerator[int, None, None]r)   )r*   s   "r+   r,   ry      s      
G 
G1
G	#
Gr-   c              #  	   "   \        V P                  4      pWP                  V&    Vx  V P                  P                  V4       R #   T P                  P                  T4       i ; i5ir?   )nextrr   rt   poprD   r   r   s   && r+   %_register_cancelable_mr_task_callback-Context._register_cancelable_mr_task_callback   sY      4778AE11+>	G5599+FD5599+Fs   $A(A A(A%%A(c                    V ^8  d   QhRRRR/# r&   coderx   r'   r   r)   )r*   s   "r+   r,   ry      s     V V# V2H Vr-   c                	   "   V P                  V4      pV P                  V P                  P                  VP                  4      G R j  xL
 #  L5ir?   )_python_to_value_handle_run_cancelable_mr_taskro   mr_evalrawrD   r   code_handles   && r+   eval_cancelableContext.eval_cancelable   s<     224811$))2C2C[__UUUUs   AAAAc                    V ^8  d   QhRRRR/# r   r)   )r*   s   "r+   r,   ry      s     R R R!7 Rr-   c                	    V P                  V4      pV P                  V P                  P                  VP                  4      # r?   )r   _run_uncancelable_mr_taskro   r   r   r   s   && r+   evalContext.eval   s3    2248--dii.?.?QQr-   c                    V ^8  d   QhRRRR/# )r&   promiser   r'   r   r)   )r*   s   "r+   r,   ry      s     -  - 9 - 9O - r-   c                	  a a	"   S P                  V4      pS P                  R 4      p\        RS P                  S P                  S P                  P                  S P                  VP                  VP                  4      4      4      4      pS P                  P                  4       o	R V	V 3R llpR V	V 3R llpS P                  V4      ;_uu_ 4       pS P                  V4      ;_uu_ 4       pV! WxVR7       S	G Rj  xL
 uuRRR4       uuRRR4       #  L  + '       g   i     M; i RRR4       R#   + '       g   i     R# ; i5i)thenr   c                    V ^8  d   QhRRRR/# r&   r_   r   r'   r<   r)   )r*   s   "r+   r,   +Context.await_promise.<locals>.__annotate__   s     	 	K 	D 	r-   c                   < SP                  4       '       d   R # SP                  \        RSP                  V 4      4      ^ ,          4       R # )Nr   )	cancelled
set_resultr   _value_handle_to_python)r_   futurerD   s   &r+   on_resolved*Context.await_promise.<locals>.on_resolved   s=    !!Y < <Z HI!Lr-   c                    V ^8  d   QhRRRR/# r   r)   )r*   s   "r+   r,   r      s     	6 	6K 	6D 	6r-   c                @  < SP                  4       '       d   R # \        RSP                  V 4      4      ^ ,          p\        V\        4      '       g   \        V4      pM&RV9   d   \        RVR,          4      pM\        V4      pSP                  \        V4      4       R # )Nr   stackrx   )r   r   r   
isinstancer   rx   set_exceptionr   )r_   valuemsgr   rD   s   &  r+   on_rejected*Context.await_promise.<locals>.on_rejected   s{    !!D$@$@$LMaPEe^44%jE!5%.1%j  !45r-   )thisN)r   r   r   r   ro   mr_get_object_itemrp   r   rP   create_future_register_js_notification)
rD   r   promise_handlethen_name_handle	then_funcr   r   on_resolved_js_funcon_rejected_js_funcr   s
   f&       @r+   await_promiseContext.await_promise   s    55g>77?((%%II00		>#5#57G7K7K	
	 :>9V9V9X	 		6 	6 **;77;N**;77;N)WM<	 87 87
  	 877 8777sN   CED4+D	;D<D	?
D4	ED	D&!D4*
E4E	?	Ec                    V ^8  d   QhRRRR/# )r&   re   r   r'   r(   r)   )r*   s   "r+   r,   ry      s     

 

X 

# 

r-   c                	    V P                  V4      p\        R V P                  V P                  V P                  P                  V P                  VP                  4      4      4      4      # )r(   )r   r   r   r   ro   mr_get_identity_hashrp   r   )rD   re   
obj_handles   && r+   get_identity_hashContext.get_identity_hash   sZ    11#6
((%%II22499jnnM
 	
r-   c                    V ^8  d   QhRRRR/# )r&   re   r   r'   z"tuple[PythonJSConvertedTypes, ...]r)   )r*   s   "r+   r,   ry      s      	+r-   c                	   V P                  V4      pV P                  V P                  V P                  P	                  V P
                  VP                  4      4      4      p\        V\        4      '       g   \        h\        V4      # r?   )r   r   r   ro   mr_get_own_property_namesrp   r   r   r   	TypeErrortuple)rD   re   r   namess   &&  r+   get_own_property_namesContext.get_own_property_names   sl     11#6
,,!!		33DIIz~~N

 %))OU|r-   c               $    V ^8  d   QhRRRRRR/# )r&   re   r   keyr   r'   r)   )r*   s   "r+   r,   ry      s$     

 



"8

	

r-   c           	     	    V P                  V4      pV P                  V4      pV P                  V P                  V P                  P	                  V P
                  VP                  VP                  4      4      4      # r?   )r   r   r   ro   r   rp   r   rD   re   r   r   
key_handles   &&&  r+   get_object_itemContext.get_object_item   sg     11#6
11#6
++!!		,,TYY

W
 	
r-   c               (    V ^8  d   QhRRRRRRRR/# )r&   re   r   r   r   valr'   r<   r)   )r*   s   "r+   r,   ry      s,     
 

"8
?U
	
r-   c           
     	4   V P                  V4      pV P                  V4      pV P                  V4      pV P                  V P                  V P                  P	                  V P
                  VP                  VP                  VP                  4      4      4       R # r?   )r   r   r   ro   mr_set_object_itemrp   r   )rD   re   r   r   r   r   r_   s   &&&&   r+   set_object_itemContext.set_object_item   s}     11#6
11#6
11#6
 	$$!!		,,IIz~~z~~z~~	
r-   c               $    V ^8  d   QhRRRRRR/# )r&   re   r   r   r   r'   r<   r)   )r*   s   "r+   r,   ry     s"     	
 	
8 	
2H 	
T 	
r-   c           	     	    V P                  V4      pV P                  V4      pV P                  V P                  V P                  P	                  V P
                  VP                  VP                  4      4      4       R # r?   )r   r   r   ro   mr_del_object_itemrp   r   r   s   &&&  r+   del_object_itemContext.del_object_item  sb    11#6
11#6
 	$$!!		,,TYY

W	
r-   c               $    V ^8  d   QhRRRRRR/# )r&   arrr   indexr(   r'   r<   r)   )r*   s   "r+   r,   ry     s!     
 
' 
# 
$ 
r-   c                	    V P                  V4      pV P                  V P                  V P                  P	                  V P
                  VP                  V^R4      4      4       R# )   Nr   r   r   ro   mr_splice_arrayrp   r   )rD   r   r   
arr_handles   &&& r+   del_from_arrayContext.del_from_array  sR    11#6
 	$$!!		))$))Z^^UAtT	
r-   c               (    V ^8  d   QhRRRRRRRR/# )	r&   r   r   r   r(   new_valr   r'   r<   r)   )r*   s   "r+   r,   ry   !  s,     
 

#&
1G
	
r-   c                	    V P                  V4      pV P                  V4      pV P                  V P                  V P                  P	                  V P
                  VP                  V^ VP                  4      4      4       R# )r   Nr   )rD   r   r   r   r   new_val_handles   &&&&  r+   array_insertContext.array_insert!  sm     11#6
55g> 	$$!!		))IIz~~ua9K9K	
r-   c               $    V ^8  d   QhRRRRRR/# )r&   r   r   r   r   r'   r<   r)   )r*   s   "r+   r,   ry   0  s"     	
 	
g 	
0F 	
4 	
r-   c           	     	    V P                  V4      pV P                  V4      pV P                  V P                  V P                  P	                  V P
                  VP                  VP                  4      4      4       R # r?   )r   r   r   ro   mr_array_pushrp   r   )rD   r   r   r   r  s   &&&  r+   
array_pushContext.array_push0  sd    11#6
55g> 	$$!!		''		:>>>CUCUV	
r-   c                   V ^8  d   QhRR/# r   r)   )r*   s   "r+   r,   ry   ;  s     = =T =r-   c                	.    \        4       V P                  J # r?   )rm   rP   r~   s   &r+   +are_we_running_on_the_mini_racer_event_loop3Context.are_we_running_on_the_mini_racer_event_loop;  s    ')T__<<r-   r   c               (    V ^8  d   QhRRRRRRRR/# )r&   r   z!CancelableJSFunction | JSFunctionargsr   r   JSObject | JSUndefinedTyper'   r)   )r*   s   "r+   r,   ry   >  s2     
 
/
 &
 )	

 
 
r-   c               	z  "   \        R V P                  R4      4      pV F  pVP                  V4       K  	  V P                  V4      pV P                  V4      pV P                  V4      pV P	                  V P
                  P                  VP                  VP                  VP                  4      G Rj  xL
 #  L5i)r   []N)r   r   appendr   r   ro   mr_call_functionr   	rD   r   r   r  argvargfunc_handlethis_handleargv_handles	   &&$*     r+   call_function_cancelable Context.call_function_cancelable>  s      Ityy/CKK  22482248224811II&&OOOOOO	
 
 	
 
s   B2B;4B95B;c               (    V ^8  d   QhRRRRRRRR/# )r&   r   r   r  r   r   r  r'   r)   )r*   s   "r+   r,   ry   S  s2     
 

 &
 )	

 
 
r-   c               	^   \        R V P                  R4      4      pV F  pVP                  V4       K  	  V P                  V4      pV P                  V4      pV P                  V4      pV P	                  V P
                  P                  VP                  VP                  VP                  4      # )r   r  )r   r   r  r   r   ro   r  r   r  s	   &&$*     r+   call_functionContext.call_functionS  s     Ityy/CKK  224822482248--II&&OOOOOO	
 	
r-   c                    V ^8  d   QhRRRR/# r&   limitr(   r'   r<   r)   )r*   s   "r+   r,   ry   h       = =3 =4 =r-   c                	R    V P                   P                  V P                  V4       R # r?   )ro   mr_set_hard_memory_limitrp   rD   r"  s   &&r+   set_hard_memory_limitContext.set_hard_memory_limith      		**499e<r-   c                    V ^8  d   QhRRRR/# r!  r)   )r*   s   "r+   r,   ry   k  r#  r-   c                	R    V P                   P                  V P                  V4       R # r?   )ro   mr_set_soft_memory_limitrp   r&  s   &&r+   set_soft_memory_limitContext.set_soft_memory_limitk  r)  r-   c                   V ^8  d   QhRR/# r   r)   )r*   s   "r+   r,   ry   n       G Gt Gr-   c                	^    \        V P                  P                  V P                  4      4      # r?   )r   ro   mr_hard_memory_limit_reachedrp   r~   s   &r+   was_hard_memory_limit_reached%Context.was_hard_memory_limit_reachedn       DII::499EFFr-   c                   V ^8  d   QhRR/# r   r)   )r*   s   "r+   r,   ry   q  r0  r-   c                	^    \        V P                  P                  V P                  4      4      # r?   )r   ro   mr_soft_memory_limit_reachedrp   r~   s   &r+   was_soft_memory_limit_reached%Context.was_soft_memory_limit_reachedq  r5  r-   c                   V ^8  d   QhRR/# )r&   r'   r<   r)   )r*   s   "r+   r,   ry   t  s     8 8 8r-   c                	P    V P                   P                  V P                  4       R # r?   )ro   mr_low_memory_notificationrp   r~   s   &r+   low_memory_notificationContext.low_memory_notificationt  s    		,,TYY7r-   c                   V ^8  d   QhRR/# rw   r)   )r*   s   "r+   r,   ry   w  s     
 
C 
r-   c           
     	    \        R V P                  V P                  V P                  P	                  V P
                  4      4      4      4      # )rx   )r   r   r   ro   mr_heap_statsrp   r~   s   &r+   
heap_statsContext.heap_statsw  sA    ((%%dii&=&=dii&HI
 	
r-   c                   V ^8  d   QhRR/# rw   r)   )r*   s   "r+   r,   ry     s     
 
s 
r-   c           
         \        RV P                  V P                  V P                  P	                  V P
                  4      4      4      4      # )z)Return a snapshot of the V8 isolate heap.rx   )r   r   r   ro   mr_heap_snapshotrp   r~   s   &r+   heap_snapshotContext.heap_snapshot  sC     ((%%dii&@&@&KL
 	
r-   c                   V ^8  d   QhRR/# r%   r)   )r*   s   "r+   r,   ry     s     8 8S 8r-   c                ^    \        V P                  P                  V P                  4      4      # )z;For tests only: how many value handles are still allocated?)r(   ro   mr_value_countrp   r~   s   &r+   value_countContext.value_count  s"     499++DII677r-   c                    V ^8  d   QhRRRR/# )r&   r   r   r'   z!Generator[JSFunction, None, None]r)   )r*   s   "r+   r,   ry     s      1	*r-   c              #    "   V P                  V4      ;_uu_ 4       p\        RV P                  V P                  V P                  P                  V P                  V4      4      4      4      x  RRR4       R#   + '       g   i     R# ; i5i)zCreate a "notification": an async, one-way callback function, from JavaScript
to Python.

"One-way" here means the function returns nothing. "async" means that on the JS
side, the function returns before it has been processed on the Python side.r   N)r   r   r   r   ro   mr_make_js_callbackrp   r   s   && r+   r   !Context._register_js_notification  sl      77==,,))		55diiM  >===s   BAA7-
B7B		Bc                    V ^8  d   QhRRRR/# )r&   r   r   r'   z AsyncGenerator[JSFunction, None]r)   )r*   s   "r+   r,   ry     s     1 1$1	)1r-   c           
    	  a aaa"   R  VV 3R llo\        S P                  4      ;_uu_4       GRj  xL
 oS P                  VV3R l4      ;_uu_ 4       p\        RS P	                  R4      4      p\        RV! V4      4      5x  RRR4       RRR4      GRj  xL
  R#  Lm  + '       g   i     L$; i L  + GRj  xL 
 '       g   i     R# ; i5i)c                    V ^8  d   QhRRRR/# r   r)   )r*   s   "r+   r,   =Context.wrap_py_function_as_js_function.<locals>.__annotate__  s     	 	k 	d 	r-   c                J  <"   SP                  V 4      p\        R V4      w  r#p S! \        R V4      !  G Rj  xL
 p\        RV4      ! V4       R#  L  \         dC    \        RSP                  R4      4      p\        RT4      ! T! R\	        4        24      4        R# i ; i5i)r   Nr   zs => new Error(s)zError running Python function:
)r   r   	Exceptionr   r	   )	r_   params	argumentsresolverejectresult	err_makerr   rD   s	   &      r+   await_into_js_promise_resolversPContext.wrap_py_function_as_js_function.<locals>.await_into_js_promise_resolvers  s     11*=F)-i)@&I	#T)Y%?@@\7+F3 A  !tyy9L/MN	\6* @OP	s9   !B#A AA B#A A	B B#B  B#Nc                2   < SP                  S! V 4      4      # r?   )rF   )r_   r_  task_sets   &r+   <lambda>9Context.wrap_py_function_as_js_function.<locals>.<lambda>  s    8#6#63J?$r-   r   z
fn => {
    return (...arguments) => {
        let p = Promise.withResolvers();

        fn(arguments, p.resolve, p.reject);

        return p.promise;
    }
}
)rY   rP   r   r   r   )rD   r   js_to_py_notification$wrap_outbound_calls_with_js_promisesr_  rb  s   ff  @@r+   wrap_py_function_as_js_function'Context.wrap_py_function_as_js_function  s     	 	 "$//222h//  ' 8< II
84"  89NO 9 322  3222sb   ,CB CB71B"	B7CB5C"B2-B75C7C	=C >
C		C		Cc                    V ^8  d   QhRRRR/# )r&   r   r#   r'   r   r)   )r*   s   "r+   r,   ry     s     9 9$6 9; 9r-   c                	(   a a \        VV 3R  lS4      # )c                 &   < SP                  S 4      # r?   )_free)r   rD   s   r+   rc  *Context._wrap_raw_handle.<locals>.<lambda>  s    4::c?r-   r   rD   r   s   ffr+   r   Context._wrap_raw_handle  s    2C88r-   c               $    V ^8  d   QhRRRRRR/# )r&   r   r(   typr'   r   r)   )r*   s   "r+   r,   ry     s&     V VS Vs V{ Vr-   c                	l    V P                  V P                  P                  V P                  W4      4      # r?   )r   ro   mr_alloc_int_valrp   rD   r   rq  s   &&&r+   create_intish_valContext.create_intish_val  s(    $$TYY%?%?		3%TUUr-   c               $    V ^8  d   QhRRRRRR/# )r&   r   floatrq  r(   r'   r   r)   )r*   s   "r+   r,   ry     s&     Y Yu Y3 Y; Yr-   c                	l    V P                  V P                  P                  V P                  W4      4      # r?   )r   ro   mr_alloc_double_valrp   rt  s   &&&r+   create_doublish_valContext.create_doublish_val  s(    $$TYY%B%B499c%WXXr-   c               $    V ^8  d   QhRRRRRR/# )r&   r   rx   rq  r(   r'   r   r)   )r*   s   "r+   r,   ry     s!     
 
S 
s 
{ 
r-   c           	     	    VP                  R 4      pV P                  V P                  P                  V P                  V\        V4      V4      4      # r{   )encoder   ro   mr_alloc_string_valrp   len)rD   r   rq  bs   &&& r+   create_string_valContext.create_string_val  sC    JJw$$II))$))QAD
 	
r-   c                    V ^8  d   QhRRRR/# )r&   r   r#   r'   r<   r)   )r*   s   "r+   r,   ry     s     0 0+ 0 0r-   c                	R    V P                   P                  V P                  V4       R # r?   )ro   mr_free_valuerp   rn  s   &&r+   rl  Context._free  s    				3/r-   c               $    V ^8  d   QhRRRRRR/# r&   
dll_methodr   r  r'   r   r)   )r*   s   "r+   r,   ry     s(     %= %=%= %= 
 	%=r-   c                  a a"   \         P                  ! 4       oR VV 3R llpS P                  V4      ;_uu_ 4       pV! S P                  .VOVN5!  p SG Rj  xL
 S P                  P                  S P                  V4       uuRRR4       #  L4  S P                  P                  S P                  T4       i ; i  + '       g   i     R# ; i5i)a  Manages cancelable tasks within the MiniRacer DLL.

Several MiniRacer functions (JS evaluation and 2 heap stats calls) are
cancelable and asynchronous. They take a function callback and callback data
parameter, and they return a task handle.

In this method, we create a future for each callback to get the right data to
the right caller, and we manage the lifecycle of the task and task handle.
c                    V ^8  d   QhRRRR/# r   r)   )r*   s   "r+   r,   5Context._run_cancelable_mr_task.<locals>.__annotate__  s     
	% 
	% 
	% 
	%r-   c                   < SP                  4       '       d   R #  SP                  V 4      pSP	                  T4       R #   \         d   pSP                  T4        R p?R # R p?ii ; ir?   )r   r   r   r   r   )r_   r   er   rD   s   &  r+   r   1Context._run_cancelable_mr_task.<locals>.callback  s]    !!44Z@
 e$	 # $$Q's   ? A&
A!!A&N)rT   Futurer   rp   ro   mr_cancel_task)rD   r  r  r   r   task_idr   s   f&*   @r+   r   Context._run_cancelable_mr_task  s      :A9I
	% 
	% 77AA[ ?T?;?G=#| 		((G< BA $ 		((G< BAAsF   9CB<BBB&B<CB(B99B<<C		Cc               $    V ^8  d   QhRRRRRR/# r  r)   )r*   s   "r+   r,   ry     s(     8 88 8 
 	8r-   c                    V P                  4       '       g   Q hV! V P                  .VO\        N5!  pV P                  P	                  4       pV P                  V4      # )zvLike _run_cancelable_mr_task, but eschewing cancellation semantics and
instead just waiting on a result synchronously.)r  rp   r   ru   getr   )rD   r  r  _task_idr_   s   &&*  r+   r   !Context._run_uncancelable_mr_task  sW     ??AAAAdiiO$O0NO??CCE
++J77r-   c                    V ^8  d   QhRRRR/# )r&   r_   r   r'   r   r)   )r*   s   "r+   r,   ry      s      M M%M	Mr-   c                	8    V P                   P                  W4      # r?   )rq   rb   )rD   r_   s   &&r+   r   Context._value_handle_to_python   s     ##::4LLr-   c                    V ^8  d   QhRRRR/# )r&   re   r   r'   r   r)   )r*   s   "r+   r,   ry   %  s     F F+A Fk Fr-   c                	8    V P                   P                  W4      # r?   )rq   rg   )rD   re   s   &&r+   r   Context._python_to_value_handle%  s    ##::4EEr-   r)   N)6rH   rI   rJ   rK   rL   rM   r   dictrt   queueQueueru   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r  r  r  r   r  r  r'  r-  r3  r9  r>  rC  rH  rM  r   r   rg  r   ru  r{  r  rl  r   r   r   r   rN   r)   r-   r+   r^   r^   Z   si   R

))""**d# )*R  GLG)+C >8
&	 
G 
GV
R
- ^




 	


	
=
 ,7	
*
 ,7	
*==GG8

8
  & 1 1f9VY
0%=N8"M
F Fr-   r^   )6
__future__r   rT   r  
contextlibr   r   r   dataclassesr   r   	tracebackr	   typingr
   r   r   r   r   py_mini_racer._dllr   py_mini_racer._excr   r   py_mini_racer._typesr   r   r   r   r   r   r   r   r   r   py_mini_racer._value_handler   ctypescollections.abcr   r   r    r!   r"   r#   r2   objectr3   r   r6   rY   r[   rm   r^   r)   r-   r+   <module>r     s    "   D D (   > > . >   4XX>' mV,!"  $
< 
< 
<  H  $KF KF KFr-   