Ë
    £ehö  ã                   ó  — d Z ddlmZmZ ddlmZmZ ddl	Z	ddl
Z
dZdZ G d„ de«      Zd	„ Zdd
„Zdd„Zd„ Z e
j&                  d«      Z e
j&                  d«      Z e
j&                  d«      ZddddœZi Zdd„Zd„ Zedk(  r e«        yy)a  sstruct.py -- SuperStruct

Higher level layer on top of the struct module, enabling to
bind names to struct elements. The interface is similar to
struct, except the objects passed and returned are not tuples
(or argument lists), but dictionaries or instances.

Just like struct, we use fmt strings to describe a data
structure, except we use one line per element. Lines are
separated by newlines or semi-colons. Each line contains
either one of the special struct characters ('@', '=', '<',
'>' or '!') or a 'name:formatchar' combo (eg. 'myFloat:f').
Repetitions, like the struct module offers them are not useful
in this context, except for fixed length strings  (eg. 'myInt:5h'
is not allowed but 'myString:5s' is). The 'x' fmt character
(pad byte) is treated as 'special', since it is by definition
anonymous. Extra whitespace is allowed everywhere.

The sstruct module offers one feature that the "normal" struct
module doesn't: support for fixed point numbers. These are spelled
as "n.mF", where n is the number of bits before the point, and m
the number of bits after the point. Fixed point numbers get
converted to floats.

pack(fmt, object):
	'object' is either a dictionary or an instance (or actually
	anything that has a __dict__ attribute). If it is a dictionary,
	its keys are used for names. If it is an instance, it's
	attributes are used to grab struct elements from. Returns
	a string containing the data.

unpack(fmt, data, object=None)
	If 'object' is omitted (or None), a new dictionary will be
	returned. If 'object' is a dictionary, it will be used to add
	struct elements to. If it is an instance (or in fact anything
	that has a __dict__ attribute), an attribute will be added for
	each struct element. In the latter two cases, 'object' itself
	is returned.

unpack2(fmt, data, object=None)
	Convenience function. Same as unpack, except data may be longer
	than needed. The returned value is a tuple: (object, leftoverdata).

calcsize(fmt)
	like struct.calcsize(), but uses our own fmt strings:
	it returns the size of the data in bytes.
é    )ÚfixedToFloatÚfloatToFixed)ÚtobytesÚtostrNz1.2z4Copyright 1998, Just van Rossum <just@letterror.com>c                   ó   — e Zd Zy)ÚErrorN©Ú__name__Ú
__module__Ú__qualname__© ó    úT/var/www/skyplay_api_hub/venv/lib/python3.12/site-packages/fontTools/misc/sstruct.pyr   r   :   s   „ Ør   r   c           
      ó$  — t        | d¬«      \  }}}g }t        |t        «      s|j                  }|}|j	                  d«      r|dd  }t        |j                  «       «      D ]d  \  }}||   }	||v rt        |	||   «      }	nt        |	t        «      rt        |	«      }	|j                  |	«       	 t        j                  ||   |	«       Œf t        j                  |ft        |«      z   Ž }|S # t        $ r}
t        d|	›d||   ›d|›�«      |
‚d }
~
ww xY w)NT)Úkeep_pad_byteú>é   zValue z does not fit in format z for )Ú	getformatÚ
isinstanceÚdictÚ__dict__Ú
startswithÚ	enumerateÚkeysÚfl2fiÚstrr   ÚappendÚstructÚpackÚ	ExceptionÚ
ValueErrorÚtuple)ÚfmtÚobjÚformatstringÚnamesÚfixesÚelementsÚstring_indexÚixÚnameÚvalueÚeÚdatas               r   r   r   >   s  € Ü!*¨3¸dÔ!CÑ€L�%˜Ø€HÜ�cœ4Ô Ø�l‰lˆØ€LØ×Ñ˜sÔ#Ø# A BÐ'ˆÜ˜eŸj™j›lÓ+ò ‰ˆˆDØ�D‘	ˆØ�5‰=ä˜%  t¡Ó-‰EÜ˜œsÔ#Ü˜E“NˆEØ�‰˜Ôð	Ü�K‰K˜˜d™ UÕ+ðô �;‰;˜˜¬%°«/Ñ9Ð:€DØ€Køô ò 	ÝÚ?DÀeÈDÃkÑSWÐXóàðûð	ús   Â-C)Ã)	DÃ2D
Ä
Dc                 ó¨  — |€i }t        |«      }t        | «      \  }}}t        |t        «      r|}n|j                  }t        j                  ||«      }t        t        |«      «      D ]X  }t        |j                  «       «      |   }	||   }
|	|v rt        |
||	   «      }
nt        |
t        «      r	 t        |
«      }
|
||	<   ŒZ |S # t        $ r Y Œw xY w©N)r   r   r   r   r   r   ÚunpackÚrangeÚlenÚlistr   Úfi2flÚbytesr   ÚUnicodeDecodeError)r#   r.   r$   r%   r&   r'   Údr(   Úir+   r,   s              r   r1   r1   Y   sØ   € Ø
€{ØˆÜ�4‹=€DÜ!*¨3£Ñ€L�%˜Ü�#”tÔØ‰à�L‰LˆÜ�}‰}˜\¨4Ó0€HÜ”3�u“:Óò ˆÜ�E—J‘J“LÓ! !Ñ$ˆØ˜‘ˆØ�5‰=ä˜%  t¡Ó-‰EÜ˜œuÔ%ðÜ˜e›�ð ˆˆ$Šðð €Jøô &ò Ùðús   Â1CÃ	CÃCc                 óB   — t        | «      }t        | |d | |«      ||d  fS r0   )Úcalcsizer1   )r#   r.   r$   Úlengths       r   Úunpack2r=   r   s+   € Ü�c‹]€FÜ�#�t˜G˜V�} cÓ*¨D°°¨MÐ9Ð9r   c                 óJ   — t        | «      \  }}}t        j                  |«      S r0   )r   r   r;   )r#   r%   r&   r'   s       r   r;   r;   w   s!   € Ü!*¨3£Ñ€L�%˜Ü�?‰?˜<Ó(Ð(r   z`\s*([A-Za-z_][A-Za-z_0-9]*)\s*:\s*([xcbB?hHiIlLqQfd]|[0-9]+[ps]|([0-9]+)\.([0-9]+)(F))\s*(#.*)?$z\s*([x@=<>!])\s*(#.*)?$z
\s*(#.*)?$ÚbÚhÚl©é   é   é    c                 ó  — t        | d¬«      } 	 t        |    \  }}}|||fS # t        $ �r_ t        j                  d| «      }d}i }i }|D �]-  }t
        j                  |«      rŒt        j                  |«      }|r#|j                  d«      }|dk7  râ|ràt        d«      ‚t        j                  |«      }|st        d|z  «      ‚|j                  d«      }	|j                  d	«      }|s|dk7  r|||	<   |j                  d
«      rqt        |j                  d
«      «      }
t        |j                  d«      «      }|
|z   }|dvrt        d«      ‚t        |   }|||	<   |j                  d«      dk(  sJ ‚|||	<   ||z  }�Œ0 |||ft        | <   Y �Œmw xY w)NÚascii)Úencodingz[
;]Ú r   Úxz a special fmt char must be firstzsyntax error in fmt: '%s'é   é   é   rB   z)fixed point must be 8, 16 or 32 bits longé   ÚF)r   Ú_formatcacheÚKeyErrorÚreÚsplitÚ_emptyREÚmatchÚ_extraREÚgroupr   Ú
_elementREÚintÚ_fixedpointmappings)r#   r   r%   r&   r'   ÚlinesÚlineÚmÚ
formatcharr+   ÚbeforeÚafterÚbitss                r   r   r   “   s¢  € Ü
�˜gÔ
&€Cð#7Ü%1°#Ñ%6Ñ"ˆ�e˜UðF ˜ Ð%Ð%øôE ó !7Ü—‘˜ #Ó&ˆØˆØˆØˆØó 	'ˆDÜ�~‰~˜dÔ#ØÜ—‘˜tÓ$ˆAÙØŸW™W Q›Z�
Ø Ò$©ÜÐ BÓCÐCä×$Ñ$ TÓ*�ÙÜÐ ;¸dÑ BÓCÐCØ—w‘w˜q“z�ØŸW™W Q›Z�
Ù  J°#Ò$5Ø",�E˜$‘KØ—7‘7˜1”:ä  §¡¨£›_�FÜ §¡¨£
›O�EØ! E™>�DØ ;Ñ.Ü#Ð$OÓPÐPÜ!4°TÑ!:�JØ",�E˜$‘KØŸ7™7 1›:¨Ò,Ð,Ð,Ø"'�E˜$‘KØ˜JÑ&ŠLð7	'ð8 )¨%°Ð6Œ�SÔðC!7ús   �! ¡E%F
Æ	F
c                  ó˜  — d} t        dt        | «      «        G d„ dt        «      } |«       }d|_        d|_        d|_        d|_        d	|_        d
|_        d
|_	        d|_
        d|_        t        | |«      }t        dt        |«      «       t        t        | |«      «        |«       }t        | ||«       t        t        |«      «       y )Na  
		# comments are allowed
		>  # big endian (see documentation for struct)
		# empty lines are allowed:

		ashort: h
		along: l
		abyte: b	# a byte
		achar: c
		astr: 5s
		afloat: f; adouble: d	# multiple "statements" are allowed
		afixed: 16.16F
		abool: ?
		apad: x
	zsize:c                   ó   — e Zd Zy)ú_test.<locals>.fooNr	   r   r   r   Úfoord   Ï   s   „ Ør   re   iÿ  iÿÿÿé   ÚaÚ12345g      à?g      ø?Tzdata:)Úprintr;   ÚobjectÚashortÚalongÚabyteÚacharÚastrÚafloatÚadoubleÚafixedÚaboolr   Úreprr1   Úvars)r#   re   r9   r.   Úi2s        r   Ú_testrw   ¼   s³   € ð€Cô  
ˆ'”8˜C“=Ô!ôŒfô ñ 	‹€Aà€A„HØ€A„GØ€A„GØ€A„GØ€A„FØ€A„HØ€A„IØ€A„HØ€A„Gä��Q‹<€DÜ	ˆ'”4˜“:ÔÜ	Œ&��dÓ
ÔÙ	‹€BÜ
ˆ3��bÔÜ	Œ$ˆr‹(…Or   Ú__main__r0   )F)Ú__doc__ÚfontTools.misc.fixedToolsr   r5   r   r   ÚfontTools.misc.textToolsr   r   r   rR   Ú__version__Ú__copyright__r    r   r   r1   r=   r;   ÚcompilerX   rV   rT   rZ   rP   r   rw   r
   r   r   r   ú<module>r      s²   ðñ.÷` Sß 3Û Û 	à€ØF€ô	ˆIô 	òó6ó2:ò
)ð ˆR�Z‰Zðó	€
ð ˆ2�:‰:Ð0Ó1€ð ˆ2�:‰:�mÓ$€à 3¨CÑ0Ð à€ó&&òR'ðT ˆzÒÙ	…Gð r   