oi UdZddlmZddlZddlZddlZddlZddlZejdZ ejdZ ejdZ ejdZ ejdZ ejd Ze e egZejd Zejd Zejd Ziad ed<iZded< ejddZn#e$rz ejddZnU#e$rMdgZ edejdejdn #e$rYnwxYwYnwxYwYnwxYwdZdZifdZe dkr edSdS)a Vendored from https://github.com/python/cpython/blob/3.8/Tools/scripts/h2py.py Changes since vendored version: - Minimal changes to satisfy our checkers. - Rename `p_hex` to `p_signed_hex` and improve to include lowercase l - Fixed `pytify` to remove leftover L after numbers and actually compute negative hexadecimal constants - Added `p_int_cast` and `p_literal_constant` --- Read #define's and translate to Python code. Handle #include statements. Handle #define macros with one argument. Anything that isn't recognized or doesn't translate into valid Python is ignored. Without filename arguments, acts as a filter. If one or more filenames are given, output is written to corresponding filenames in the local directory, translated to all uppercase, with the extension replaced by ".py". By passing one or more options of the form "-i regular_expression" you can specify additional strings to be ignored. This is useful e.g. to ignore casts to u_long: simply specify "-i '(u_long)'". ) annotationsNz/^[\t ]*#[\t ]*define[\t ]+([a-zA-Z0-9_]+)[\t ]+zK^[\t ]*#[\t ]*define[\t ]+([a-zA-Z0-9_]+)\(([_a-zA-Z][_a-zA-Z0-9]*)\)[\t ]+z&^[\t ]*#[\t ]*include[\t ]+<([^>\n]+)>z/\*([^*]+|\*+[^/])*(\*+/)?z//.*z6\((DWORD|HRESULT|SCODE|LONG|HWND|HANDLE|int|HBITMAP)\)z'(\\.[^\\]*|[^\\])'z0x([0-9a-fA-F]+)[lL]?z#((0x[0-9a-fA-F]+?)|([0-9]+?))[uUlL]zdict[str, None]filedictzdict[str, str] importableinclude;INCLUDEz /usr/include MULTIARCHc tjtjddd\}}|D]7\}}|dkr,tt j|8|sdg}|D]}|dkrDtjdttj tjMt|5}tj |}|d}|dkr |d|}|}|dz}t|d 5} | d |ziat$D]c} |dt'| | krFdt"|t'| dzd<|t(|t'| dzd<ndt|| dddn #1swxYwYdddn #1swxYwYdS) Nzi:z-i-z# Generated by h2py from stdin .rz.pywz# Generated by h2py from %s )getoptsysargvignoresappendrecompilestdoutwriteprocessstdinopenospathbasenamerfindupperr searchdirslenr) optsargsoafilenamefpoutfileimodnameoutfpdirs BC:\PYTHON\Scheduler\python\Lib\site-packages\win32/scripts/h2py.pymainr.Msfsx|T22JD$**1 99 NN2:a== ) ) ) u'' s?? J  ? @ @ @ CIsz * * * *h '2'**844MM#&&q55%bqbkG!--//!E/'3'''5KK ?( JKKK!H)""#Jc#hhJ/366AEHXc#hhlnn%=>CJJxC1 '?@!E7B&&&''''''''''''''' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ' ''s8A.G/6BG G/G G/G G//G3 6G3 c tD]}|d|}td|}d} t||}|sn|\}}t jt|t|ddj }|dkr+|d|dzt|zdz||dz}|dz}td|}|S) N z ord('\1')rr ()z\1) rsubp_char p_signed_hexsearchspanctypesc_int32intslicevaluestrp_literal_constant)bodypstartmsevals r-pytifyrGls   uuS$ ::lD ) )D E   e , ,  vvxx1nSeQVVAYY&7!8"==>>D 778c>CHH,s2T!""X=DA  ! !% . .D Kcd} |}|sdS|dz}t|}|r|dddkr/|}|sn|dz}||z}|dddk/|d}||d}t |}d} |d|d} t| ||| n)#tj d| zYnxYwt|}|r|dd\} } ||d}t |}d | d | d |d} t| ||| n)#tj d| zYnxYwt|}|r|j } | d\}}|||}|tvr$|d t|zn|tvrdt|<d}t D])} t#|d z|z}n#t$$rY&wxYw|rD|5|d|zt'|||dddn #1swxYwYn"tj d|z)Nrr z\ z =  z Skipping: %szdef r2z ): return zfrom %s import * /z # Included from %s z!Warning - could not find file %s )readlinep_definematchgroupendrGstripexecrrstderrp_macro p_includeregsrrr rIOErrorr)r'r+envlinenolinerPnextlinenamer@okstmtmacroargrXr%br&inclfpr,s r-rrs F:V{{}}  E!t$$  "rss)v%%;;==!h rss)v%% ;;q>>D &D$<rsse@#""""" 2:H I I "*V   BJ@ A A BJ4 5 5  6"" RZQ R R mZ 0 * + +rz233 RZ FGG  I&,,S11JJZ *0055 $%     anbj>U!V!V W W W W    D  '''>,<V<V<V<V~ zDFFFFFsZ C##E") D  E" E:E EEEEEE"EE"!E"