;iddlZddlmZddlmZmZmZddlmZmZddl m Z m Z m Z ddl mZdgZd ZGd de Zd e d e fd Zd e de fdZdZejdkrdefdZdefdZdSdefdZdefdZdS)N)Path) GeneratorTupleOptional)ffi load_hostfxr)Runtime RuntimeInfo StrOrPath) check_resultDotnetCoreRuntimeFc eZdZUeed<ddddedeedeedefdZed efd Z ed e fd Z ed e fd Z d ed efdZ d eded dfdZd eeeefddffdZdZdededefdZddZdZdS)r_versionN)runtime_config entry_dll dotnet_rootrrparamsc d|_trtdt||_t |j|_d|_|!t|j|j||_n2|!t|j|j||_ntd| D] \}}|||< d|_ dS)Nz Runtime can not be reinitializedz3Either runtime_config or entry_dll must be providedz ) _handle _IS_SHUTDOWN RuntimeErrorr _dotnet_rootr _dll _load_func_get_handle_for_runtime_config#_get_handle_for_dotnet_command_line ValueErroritemsr)selfrrrrkeyvalues FC:\PYTHON\MyICR_Workspace\venv\Lib\site-packages\clr_loader/hostfxr.py__init__zDotnetCoreRuntime.__init__s  CABB B -- !233   %9 4,nDLL "> 4,iDLLRSS S ,,..  JCDII+ returnc|jSN)rr s r#rzDotnetCoreRuntime.dotnet_root3s   r%c|jduSr()rr)s r#is_initializedz DotnetCoreRuntime.is_initialized7sd**r%ctSr()rr)s r# is_shutdownzDotnetCoreRuntime.is_shutdown;sr%r!c|jrtdtjd}|j|jt||}|dkrt|t|dS)NRuntime is shut downzchar_t**r) r-rrnewr"hostfxr_get_runtime_property_valuerencodeKeyErrordecode)r r!bufress r# __getitem__zDotnetCoreRuntime.__getitem__?sx   7566 6gj!!i:: L&++s   !883-- c!f~~r%r"c|jrtd|j|jt |t |}t |dS)NzAlready initialized)r+rr"hostfxr_set_runtime_property_valuerr2r )r r!r"r6s r# __setitem__zDotnetCoreRuntime.__setitem__Ks^   6455 5i:: L&++ve}}   Sr%c#K|jrtdd}tjd}||d<tjd|}tjd|}|j|j|||}t|t|dD].}t||t||fV/dS)Nr/dzsize_t*rz char_t*[]) r-rrr0rhostfxr_get_runtime_propertiesrr ranger4)r max_sizesize_ptrkeys_ptr values_ptrr6is r#__iter__zDotnetCoreRuntime.__iter__Ts   7566 679%% 7;11W[(33 i66 L(Hj   Sx{## ? ?A(1+&&z!}(=(=> > > > > ? ?r%c\|jt|j|j|_|jSr()r_get_load_funcrrr)s r#rFz DotnetCoreRuntime._get_load_funcfs' ? ",TY EEDOr% assembly_pathtypenamefunctionct|}|j}|d|}tjd}|t t |t |t |tjtj|}t|tj d|dS)Nz, void**component_entry_point_fnr) rstemrr0rFr2strNULLr cast)r rGrHrI assembly_name delegate_ptrr6s r# _get_callablezDotnetCoreRuntime._get_callablels ]++ %* 11-11wx(( #d!!## 3}%% & & 8   8   H H     Sx2LODDDr%cv|jr/|jr*|j|jd|_dSdSdSr()rr hostfxr_closer)s r#shutdownzDotnetCoreRuntime.shutdownsL < DI I # #DL 1 1 1DLLL    r%c |td|j|jdu|jdutst |niS)NCoreCLR)kindversion initializedrV properties)r rrrdictr)s r#infozDotnetCoreRuntime.infosGM D0\T))5=tDzzz2     r%)r&N)__name__ __module__ __qualname__rN__annotations__rrr$propertyrboolr+r-r7r:rrrDrFr rSrVr^r%r#rrsMMM *.$( + + + +! + D> +  + + + +D!T!!!X!++++X+TX s s    s34?)E#s(OT4$?@????$ E9EEsEEEE*         r%rrc tjd}tjd|_tj|_tjdt tt|}||_ tjd}| t tt|||}t||dS)Nhostfxr_initialize_parameters*hostfxr_initialize_parameterschar_t[]hostfxr_handle*r) rr0sizeofsizerO host_pathr2rNrr%hostfxr_initialize_for_runtime_configr )dllrrr dotnet_root_p handle_ptrr6s r#rrsW5 6 6F*<==FKxFGJs4 3D3D/E/E(F(FGGM&F*++J 3 3s4''(())6:  C a=r%rc 4tjd}tjd|_tj|_tjdt tt|}||_ tjd}tjd}tjdt tt|}||d<| d|||}t||dS)Nrgrhrirjz char_t*[1]rr) rr0rkrlrOrmr2rNrr*hostfxr_initialize_for_dotnet_command_liner ) rorrrrprqargs_ptrarg_ptrr6s r#rrsW5 6 6F*<==FKxFGJs4 3D3D/E/E(F(FGGM&F*++Jw|$$Hgj&T)__)=)=">">??GHQK 8 8 8VZ  C a=r%ctjd}|||j|}t |tjd|dS)NrK)load_assembly_and_get_function_pointer_fnr)rr0hostfxr_get_runtime_delegate*hdt_load_assembly_and_get_function_pointerr rP)rohandlerRr6s r#rFrFsW78$$L * *>   C 8?a Q QQr%win32stringc|Sr(rer|s r#r2r2s r%r&c*tj|Sr()rr|char_ptrs r#r4r4sz(###r%c,|dSNutf8)r2r~s r#r2r2s}}V$$$r%cPtj|dSr)rr|r4rs r#r4r4s z(##**6222r%)syspathlibrtypingrrrrr typesr r r utilr __all__rrrrrFplatformrNr2r4rer%r#rs ----------""""""""2222222222           D1:(,5.RRR<7s$C$$$$$$ %s%%%%3C333333r%