Merge pull request #1478 from dhalbert/struct-compat

Improve struct compatibility with CPython
This commit is contained in:
Scott Shawcroft 2019-01-21 00:31:45 -08:00 committed by GitHub
commit b369fa9013
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
14 changed files with 511 additions and 372 deletions

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-01-20 17:33-0800\n"
"POT-Creation-Date: 2019-01-20 22:46-0500\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -1363,9 +1363,9 @@ msgstr ""
msgid "schedule stack full"
msgstr ""
#: py/modstruct.c:145 py/modstruct.c:153 py/modstruct.c:234 py/modstruct.c:244
#: shared-bindings/struct/__init__.c:103 shared-bindings/struct/__init__.c:145
#: shared-module/struct/__init__.c:91 shared-module/struct/__init__.c:175
#: py/modstruct.c:148 py/modstruct.c:156 py/modstruct.c:244 py/modstruct.c:254
#: shared-bindings/struct/__init__.c:102 shared-bindings/struct/__init__.c:161
#: shared-module/struct/__init__.c:183
msgid "buffer too small"
msgstr ""
@ -2649,10 +2649,20 @@ msgstr ""
msgid "'S' and 'O' are not supported format types"
msgstr ""
#: shared-module/struct/__init__.c:83
#: shared-module/struct/__init__.c:128
#, fuzzy, c-format
msgid "unpack requires a buffer of %d bytes"
msgstr "Gagal untuk megalokasikan buffer RX dari %d byte"
#: shared-module/struct/__init__.c:136
msgid "too many arguments provided with the given format"
msgstr ""
#: shared-module/struct/__init__.c:179
#, fuzzy
msgid "buffer size must match format"
msgstr "buffers harus mempunyai panjang yang sama"
#: shared-module/usb_hid/Device.c:45
#, c-format
msgid "Buffer incorrect size. Should be %d bytes."
@ -2739,17 +2749,8 @@ msgid ""
"exit safe mode.\n"
msgstr ""
#~ msgid ""
#~ "Please file an issue here with the contents of your CIRCUITPY drive:\n"
#~ msgstr ""
#~ "Silahkan taruh masalah disini dengan isi dari CIRCUITPY drive: anda \n"
#~ msgid "Invalid UUID parameter"
#~ msgstr "Parameter UUID tidak valid"
#~ msgid "Looks like our core CircuitPython code crashed hard. Whoops!\n"
#~ msgstr ""
#~ "Sepertinya inti kode CircuitPython kita crash dengan sangat keras. Ups!\n"
#~ msgid "Invalid UUID string length"
#~ msgstr "Panjang string UUID tidak valid"
#~ msgid ""
#~ "enough power for the whole circuit and press reset (after ejecting "
@ -2758,5 +2759,14 @@ msgstr ""
#~ "tegangan cukup untuk semua sirkuit dan tekan reset (setelah mencabut "
#~ "CIRCUITPY).\n"
#~ msgid "Invalid UUID string length"
#~ msgstr "Panjang string UUID tidak valid"
#~ msgid "Looks like our core CircuitPython code crashed hard. Whoops!\n"
#~ msgstr ""
#~ "Sepertinya inti kode CircuitPython kita crash dengan sangat keras. Ups!\n"
#~ msgid "Invalid UUID parameter"
#~ msgstr "Parameter UUID tidak valid"
#~ msgid ""
#~ "Please file an issue here with the contents of your CIRCUITPY drive:\n"
#~ msgstr ""
#~ "Silahkan taruh masalah disini dengan isi dari CIRCUITPY drive: anda \n"

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-01-20 17:33-0800\n"
"POT-Creation-Date: 2019-01-20 22:46-0500\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@ -1330,9 +1330,9 @@ msgstr ""
msgid "schedule stack full"
msgstr ""
#: py/modstruct.c:145 py/modstruct.c:153 py/modstruct.c:234 py/modstruct.c:244
#: shared-bindings/struct/__init__.c:103 shared-bindings/struct/__init__.c:145
#: shared-module/struct/__init__.c:91 shared-module/struct/__init__.c:175
#: py/modstruct.c:148 py/modstruct.c:156 py/modstruct.c:244 py/modstruct.c:254
#: shared-bindings/struct/__init__.c:102 shared-bindings/struct/__init__.c:161
#: shared-module/struct/__init__.c:183
msgid "buffer too small"
msgstr ""
@ -2612,10 +2612,19 @@ msgstr ""
msgid "'S' and 'O' are not supported format types"
msgstr ""
#: shared-module/struct/__init__.c:83
#: shared-module/struct/__init__.c:128
#, c-format
msgid "unpack requires a buffer of %d bytes"
msgstr ""
#: shared-module/struct/__init__.c:136
msgid "too many arguments provided with the given format"
msgstr ""
#: shared-module/struct/__init__.c:179
msgid "buffer size must match format"
msgstr ""
#: shared-module/usb_hid/Device.c:45
#, c-format
msgid "Buffer incorrect size. Should be %d bytes."

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-01-20 17:33-0800\n"
"POT-Creation-Date: 2019-01-20 22:46-0500\n"
"PO-Revision-Date: 2018-07-27 11:55-0700\n"
"Last-Translator: Sebastian Plamauer\n"
"Language-Team: \n"
@ -1359,9 +1359,9 @@ msgstr ""
msgid "schedule stack full"
msgstr ""
#: py/modstruct.c:145 py/modstruct.c:153 py/modstruct.c:234 py/modstruct.c:244
#: shared-bindings/struct/__init__.c:103 shared-bindings/struct/__init__.c:145
#: shared-module/struct/__init__.c:91 shared-module/struct/__init__.c:175
#: py/modstruct.c:148 py/modstruct.c:156 py/modstruct.c:244 py/modstruct.c:254
#: shared-bindings/struct/__init__.c:102 shared-bindings/struct/__init__.c:161
#: shared-module/struct/__init__.c:183
msgid "buffer too small"
msgstr ""
@ -2651,10 +2651,20 @@ msgstr "Kann '/' nicht remounten when USB aktiv ist"
msgid "'S' and 'O' are not supported format types"
msgstr ""
#: shared-module/struct/__init__.c:83
#: shared-module/struct/__init__.c:128
#, fuzzy, c-format
msgid "unpack requires a buffer of %d bytes"
msgstr "Konnte keine RX Buffer mit %d allozieren"
#: shared-module/struct/__init__.c:136
msgid "too many arguments provided with the given format"
msgstr ""
#: shared-module/struct/__init__.c:179
#, fuzzy
msgid "buffer size must match format"
msgstr "Buffer müssen gleich lang sein"
#: shared-module/usb_hid/Device.c:45
#, c-format
msgid "Buffer incorrect size. Should be %d bytes."
@ -2739,22 +2749,29 @@ msgid ""
"exit safe mode.\n"
msgstr ""
#~ msgid "Invalid UUID string length"
#~ msgstr "Ungültige UUID-Stringlänge"
#~ msgid "Can not add Characteristic."
#~ msgstr "Kann das Merkmal nicht hinzufügen."
#~ msgid "Can encode UUID into the advertisement packet."
#~ msgstr "Kann UUID in das advertisement packet kodieren."
#~ msgid "Can not add Service."
#~ msgstr "Kann den Dienst nicht hinzufügen."
#~ msgid ""
#~ "Please file an issue here with the contents of your CIRCUITPY drive:\n"
#~ msgstr ""
#~ "Bitte erstelle ein issue hier mit dem Inhalt deines CIRCUITPY-speichers:\n"
#~ msgid "Looks like our core CircuitPython code crashed hard. Whoops!\n"
#~ msgstr "CircuitPython ist abgestürzt. Ups!\n"
#~ msgid "Invalid UUID parameter"
#~ msgstr "Ungültiger UUID-Parameter"
#~ msgid "Can not apply advertisement data. status: 0x%02x"
#~ msgstr "Kann advertisement data nicht anwenden. Status: 0x%02x"
#~ msgid "Invalid Service type"
#~ msgstr "Ungültiger Diensttyp"
#~ msgid "Cannot apply GAP parameters."
#~ msgstr "Kann GAP Parameter nicht anwenden."
#~ msgid "Can not encode UUID, to check length."
#~ msgstr "Kann UUID nicht kodieren, um die Länge zu überprüfen."
#~ msgid "Can not query for the device address."
#~ msgstr "Kann nicht nach der Geräteadresse suchen."
#~ msgid "Can not apply device name in the stack."
#~ msgstr "Der Gerätename kann nicht im Stack verwendet werden."
#~ msgid ""
#~ "enough power for the whole circuit and press reset (after ejecting "
@ -2763,26 +2780,19 @@ msgstr ""
#~ "genug Strom für den ganzen Schaltkreis liefert und drücke reset (nach dem "
#~ "sicheren Auswerfen von CIRCUITPY.)\n"
#~ msgid "Can not apply device name in the stack."
#~ msgstr "Der Gerätename kann nicht im Stack verwendet werden."
#~ msgid "Invalid Service type"
#~ msgstr "Ungültiger Diensttyp"
#~ msgid "Can not query for the device address."
#~ msgstr "Kann nicht nach der Geräteadresse suchen."
#~ msgid "Invalid UUID parameter"
#~ msgstr "Ungültiger UUID-Parameter"
#~ msgid "Can not encode UUID, to check length."
#~ msgstr "Kann UUID nicht kodieren, um die Länge zu überprüfen."
#~ msgid ""
#~ "Please file an issue here with the contents of your CIRCUITPY drive:\n"
#~ msgstr ""
#~ "Bitte erstelle ein issue hier mit dem Inhalt deines CIRCUITPY-speichers:\n"
#~ msgid "Cannot apply GAP parameters."
#~ msgstr "Kann GAP Parameter nicht anwenden."
#~ msgid "Can encode UUID into the advertisement packet."
#~ msgstr "Kann UUID in das advertisement packet kodieren."
#~ msgid "Can not apply advertisement data. status: 0x%02x"
#~ msgstr "Kann advertisement data nicht anwenden. Status: 0x%02x"
#~ msgid "Looks like our core CircuitPython code crashed hard. Whoops!\n"
#~ msgstr "CircuitPython ist abgestürzt. Ups!\n"
#~ msgid "Can not add Service."
#~ msgstr "Kann den Dienst nicht hinzufügen."
#~ msgid "Can not add Characteristic."
#~ msgstr "Kann das Merkmal nicht hinzufügen."
#~ msgid "Invalid UUID string length"
#~ msgstr "Ungültige UUID-Stringlänge"

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-01-20 17:33-0800\n"
"POT-Creation-Date: 2019-01-20 22:46-0500\n"
"PO-Revision-Date: 2018-07-27 11:55-0700\n"
"Last-Translator: \n"
"Language-Team: \n"
@ -1330,9 +1330,9 @@ msgstr ""
msgid "schedule stack full"
msgstr ""
#: py/modstruct.c:145 py/modstruct.c:153 py/modstruct.c:234 py/modstruct.c:244
#: shared-bindings/struct/__init__.c:103 shared-bindings/struct/__init__.c:145
#: shared-module/struct/__init__.c:91 shared-module/struct/__init__.c:175
#: py/modstruct.c:148 py/modstruct.c:156 py/modstruct.c:244 py/modstruct.c:254
#: shared-bindings/struct/__init__.c:102 shared-bindings/struct/__init__.c:161
#: shared-module/struct/__init__.c:183
msgid "buffer too small"
msgstr ""
@ -2612,10 +2612,19 @@ msgstr ""
msgid "'S' and 'O' are not supported format types"
msgstr ""
#: shared-module/struct/__init__.c:83
#: shared-module/struct/__init__.c:128
#, c-format
msgid "unpack requires a buffer of %d bytes"
msgstr ""
#: shared-module/struct/__init__.c:136
msgid "too many arguments provided with the given format"
msgstr ""
#: shared-module/struct/__init__.c:179
msgid "buffer size must match format"
msgstr ""
#: shared-module/usb_hid/Device.c:45
#, c-format
msgid "Buffer incorrect size. Should be %d bytes."

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-01-20 17:33-0800\n"
"POT-Creation-Date: 2019-01-20 22:46-0500\n"
"PO-Revision-Date: 2018-08-24 22:56-0500\n"
"Last-Translator: \n"
"Language-Team: \n"
@ -1366,9 +1366,9 @@ msgstr "división por cero"
msgid "schedule stack full"
msgstr ""
#: py/modstruct.c:145 py/modstruct.c:153 py/modstruct.c:234 py/modstruct.c:244
#: shared-bindings/struct/__init__.c:103 shared-bindings/struct/__init__.c:145
#: shared-module/struct/__init__.c:91 shared-module/struct/__init__.c:175
#: py/modstruct.c:148 py/modstruct.c:156 py/modstruct.c:244 py/modstruct.c:254
#: shared-bindings/struct/__init__.c:102 shared-bindings/struct/__init__.c:161
#: shared-module/struct/__init__.c:183
msgid "buffer too small"
msgstr "buffer demasiado pequeño"
@ -2673,10 +2673,20 @@ msgstr "No se puede volver a montar '/' cuando el USB esta activo."
msgid "'S' and 'O' are not supported format types"
msgstr "'S' y 'O' no son compatibles con los tipos de formato"
#: shared-module/struct/__init__.c:83
#: shared-module/struct/__init__.c:128
#, fuzzy, c-format
msgid "unpack requires a buffer of %d bytes"
msgstr "Falló la asignación del buffer RX de %d bytes"
#: shared-module/struct/__init__.c:136
msgid "too many arguments provided with the given format"
msgstr "demasiados argumentos provistos con el formato dado"
#: shared-module/struct/__init__.c:179
#, fuzzy
msgid "buffer size must match format"
msgstr "los buffers deben de tener la misma longitud"
#: shared-module/usb_hid/Device.c:45
#, c-format
msgid "Buffer incorrect size. Should be %d bytes."
@ -2771,31 +2781,32 @@ msgstr ""
"El botón reset fue presionado mientras arrancaba CircuitPython. Presiona "
"otra vez para salir del modo seguro.\n"
#~ msgid "Invalid UUID string length"
#~ msgstr "Longitud de string UUID inválida"
#~ msgid "Baud rate too high for this SPI peripheral"
#~ msgstr "Baud rate demasiado alto para este periférico SPI"
#~ msgid "Invalid UUID parameter"
#~ msgstr "Parámetro UUID inválido"
#~ msgid "Invalid Service type"
#~ msgstr "Tipo de Servicio inválido"
#~ msgid "Can not query for the device address."
#~ msgstr "No se puede consultar la dirección del dispositivo."
#~ msgid "Can not apply advertisement data. status: 0x%02x"
#~ msgstr "No se puede aplicar los datos de anuncio. status: 0x%02x"
#~ msgid "Looks like our core CircuitPython code crashed hard. Whoops!\n"
#~ msgstr ""
#~ "Parece que nuestro código CircuitPython dejó de funcionar. Whoops!\n"
#~ msgid "Can encode UUID into the advertisement packet."
#~ msgstr "Se puede codificar el UUID en el paquete de anuncio."
#~ msgid "Cannot set PPCP parameters."
#~ msgstr "No se pueden establecer los parámetros PPCP."
#~ msgid "Can not encode UUID, to check length."
#~ msgstr "No se puede codificar el UUID, para revisar la longitud."
#~ msgid ""
#~ "enough power for the whole circuit and press reset (after ejecting "
#~ "CIRCUITPY).\n"
#~ msgstr ""
#~ "suficiente poder para todo el circuito y presiona reset (después de "
#~ "expulsar CIRCUITPY).\n"
#~ msgid "Cannot apply GAP parameters."
#~ msgstr "No se pueden aplicar los parámetros GAP."
#~ msgid "Can not apply device name in the stack."
#~ msgstr "No se puede aplicar el nombre del dispositivo en el stack."
#~ msgid "Can not add Service."
#~ msgstr "No se puede agregar el Servicio."
#~ msgid "Wrong number of bytes provided"
#~ msgstr "Numero erroneo de bytes dados"
#~ msgid "Wrong address length"
#~ msgstr "Longitud de address erronea"
#, fuzzy
#~ msgid ""
@ -2804,29 +2815,28 @@ msgstr ""
#~ "Por favor registra un issue en la siguiente URL con el contenidos de tu "
#~ "unidad de almacenamiento CIRCUITPY:\n"
#~ msgid "Wrong address length"
#~ msgstr "Longitud de address erronea"
#~ msgid "Can not apply device name in the stack."
#~ msgstr "No se puede aplicar el nombre del dispositivo en el stack."
#~ msgid "Wrong number of bytes provided"
#~ msgstr "Numero erroneo de bytes dados"
#~ msgid ""
#~ "enough power for the whole circuit and press reset (after ejecting "
#~ "CIRCUITPY).\n"
#~ msgstr ""
#~ "suficiente poder para todo el circuito y presiona reset (después de "
#~ "expulsar CIRCUITPY).\n"
#~ msgid "Can not add Service."
#~ msgstr "No se puede agregar el Servicio."
#~ msgid "Cannot set PPCP parameters."
#~ msgstr "No se pueden establecer los parámetros PPCP."
#~ msgid "Cannot apply GAP parameters."
#~ msgstr "No se pueden aplicar los parámetros GAP."
#~ msgid "Looks like our core CircuitPython code crashed hard. Whoops!\n"
#~ msgstr ""
#~ "Parece que nuestro código CircuitPython dejó de funcionar. Whoops!\n"
#~ msgid "Can not encode UUID, to check length."
#~ msgstr "No se puede codificar el UUID, para revisar la longitud."
#~ msgid "Can not query for the device address."
#~ msgstr "No se puede consultar la dirección del dispositivo."
#~ msgid "Can encode UUID into the advertisement packet."
#~ msgstr "Se puede codificar el UUID en el paquete de anuncio."
#~ msgid "Invalid UUID parameter"
#~ msgstr "Parámetro UUID inválido"
#~ msgid "Can not apply advertisement data. status: 0x%02x"
#~ msgstr "No se puede aplicar los datos de anuncio. status: 0x%02x"
#~ msgid "Invalid Service type"
#~ msgstr "Tipo de Servicio inválido"
#~ msgid "Baud rate too high for this SPI peripheral"
#~ msgstr "Baud rate demasiado alto para este periférico SPI"
#~ msgid "Invalid UUID string length"
#~ msgstr "Longitud de string UUID inválida"

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-01-20 17:33-0800\n"
"POT-Creation-Date: 2019-01-20 22:46-0500\n"
"PO-Revision-Date: 2018-12-20 22:15-0800\n"
"Last-Translator: Timothy <me@timothygarcia.ca>\n"
"Language-Team: fil\n"
@ -1367,9 +1367,9 @@ msgstr "dibisyon ng zero"
msgid "schedule stack full"
msgstr "puno na ang schedule stack"
#: py/modstruct.c:145 py/modstruct.c:153 py/modstruct.c:234 py/modstruct.c:244
#: shared-bindings/struct/__init__.c:103 shared-bindings/struct/__init__.c:145
#: shared-module/struct/__init__.c:91 shared-module/struct/__init__.c:175
#: py/modstruct.c:148 py/modstruct.c:156 py/modstruct.c:244 py/modstruct.c:254
#: shared-bindings/struct/__init__.c:102 shared-bindings/struct/__init__.c:161
#: shared-module/struct/__init__.c:183
msgid "buffer too small"
msgstr "masyadong maliit ang buffer"
@ -2679,10 +2679,20 @@ msgstr "Hindi ma-remount '/' kapag aktibo ang USB."
msgid "'S' and 'O' are not supported format types"
msgstr "Ang 'S' at 'O' ay hindi suportadong uri ng format"
#: shared-module/struct/__init__.c:83
#: shared-module/struct/__init__.c:128
#, fuzzy, c-format
msgid "unpack requires a buffer of %d bytes"
msgstr "Nabigong ilaan ang RX buffer ng %d bytes"
#: shared-module/struct/__init__.c:136
msgid "too many arguments provided with the given format"
msgstr "masyadong maraming mga argumento na ibinigay sa ibinigay na format"
#: shared-module/struct/__init__.c:179
#, fuzzy
msgid "buffer size must match format"
msgstr "aarehas na haba dapat ang buffer slices"
#: shared-module/usb_hid/Device.c:45
#, c-format
msgid "Buffer incorrect size. Should be %d bytes."
@ -2777,21 +2787,42 @@ msgstr ""
"Ang reset button ay pinindot habang nag boot ang CircuitPython. Pindutin "
"ulit para lumabas sa safe mode.\n"
#~ msgid "Invalid UUID string length"
#~ msgstr "Mali ang UUID string length"
#, fuzzy
#~ msgid "palette must be displayio.Palette"
#~ msgstr "ang palette ay dapat 32 bytes ang haba"
#~ msgid "Invalid UUID parameter"
#~ msgstr "Mali ang UUID parameter"
#~ msgid "Invalid Service type"
#~ msgstr "Mali ang tipo ng serbisyo"
#~ msgid "Can not query for the device address."
#~ msgstr "Hindi maaaring mag-query para sa address ng device."
#~ msgid "Can not apply advertisement data. status: 0x%02x"
#~ msgstr "Hindi ma i-apply ang advertisement data. status: 0x%02x"
#~ msgid "Looks like our core CircuitPython code crashed hard. Whoops!\n"
#~ msgid "Can encode UUID into the advertisement packet."
#~ msgstr "Maaring i-encode ang UUID sa advertisement packet."
#~ msgid "Can not encode UUID, to check length."
#~ msgstr "Hindi ma-encode UUID, para suriin ang haba."
#~ msgid "Cannot apply GAP parameters."
#~ msgstr "Hindi ma-apply ang GAP parameters."
#~ msgid "Can not add Service."
#~ msgstr "Hindi maidaragdag ang serbisyo."
#~ msgid "Wrong number of bytes provided"
#~ msgstr "Mali ang bilang ng bytes"
#~ msgid "Wrong address length"
#~ msgstr "Mali ang address length"
#~ msgid ""
#~ "Please file an issue here with the contents of your CIRCUITPY drive:\n"
#~ msgstr ""
#~ "Mukhang ang core CircuitPython code ay nag-crash ng malakas. Aray!\n"
#~ "Mag-file ng isang isyu dito gamit ang mga nilalaman ng iyong CIRCUITPY "
#~ "drive:\n"
#~ msgid "Cannot set PPCP parameters."
#~ msgstr "Hindi ma-set ang PPCP parameters."
#~ msgid "Can not apply device name in the stack."
#~ msgstr "Hindi maaaring ma-aplay ang device name sa stack."
#~ msgid ""
#~ "enough power for the whole circuit and press reset (after ejecting "
@ -2800,39 +2831,18 @@ msgstr ""
#~ "ay nagbibigay ng sapat na power para sa buong circuit at i-press ang "
#~ "reset (pagkatapos i-eject ang CIRCUITPY).\n"
#~ msgid "Can not apply device name in the stack."
#~ msgstr "Hindi maaaring ma-aplay ang device name sa stack."
#~ msgid "Cannot set PPCP parameters."
#~ msgstr "Hindi ma-set ang PPCP parameters."
#~ msgid ""
#~ "Please file an issue here with the contents of your CIRCUITPY drive:\n"
#~ msgid "Looks like our core CircuitPython code crashed hard. Whoops!\n"
#~ msgstr ""
#~ "Mag-file ng isang isyu dito gamit ang mga nilalaman ng iyong CIRCUITPY "
#~ "drive:\n"
#~ "Mukhang ang core CircuitPython code ay nag-crash ng malakas. Aray!\n"
#~ msgid "Wrong address length"
#~ msgstr "Mali ang address length"
#~ msgid "Can not query for the device address."
#~ msgstr "Hindi maaaring mag-query para sa address ng device."
#~ msgid "Wrong number of bytes provided"
#~ msgstr "Mali ang bilang ng bytes"
#~ msgid "Invalid UUID parameter"
#~ msgstr "Mali ang UUID parameter"
#~ msgid "Can not add Service."
#~ msgstr "Hindi maidaragdag ang serbisyo."
#~ msgid "Cannot apply GAP parameters."
#~ msgstr "Hindi ma-apply ang GAP parameters."
#~ msgid "Can not encode UUID, to check length."
#~ msgstr "Hindi ma-encode UUID, para suriin ang haba."
#~ msgid "Can encode UUID into the advertisement packet."
#~ msgstr "Maaring i-encode ang UUID sa advertisement packet."
#~ msgid "Can not apply advertisement data. status: 0x%02x"
#~ msgstr "Hindi ma i-apply ang advertisement data. status: 0x%02x"
#~ msgid "Invalid Service type"
#~ msgstr "Mali ang tipo ng serbisyo"
#, fuzzy
#~ msgid "palette must be displayio.Palette"
#~ msgstr "ang palette ay dapat 32 bytes ang haba"
#~ msgid "Invalid UUID string length"
#~ msgstr "Mali ang UUID string length"

View File

@ -7,7 +7,7 @@ msgid ""
msgstr ""
"Project-Id-Version: 0.1\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-01-20 17:33-0800\n"
"POT-Creation-Date: 2019-01-20 22:46-0500\n"
"PO-Revision-Date: 2018-12-23 20:05+0100\n"
"Last-Translator: Pierrick Couturier <arofarn@arofarn.info>\n"
"Language-Team: fr\n"
@ -1366,9 +1366,9 @@ msgstr "division par zéro"
msgid "schedule stack full"
msgstr "pile de plannification pleine"
#: py/modstruct.c:145 py/modstruct.c:153 py/modstruct.c:234 py/modstruct.c:244
#: shared-bindings/struct/__init__.c:103 shared-bindings/struct/__init__.c:145
#: shared-module/struct/__init__.c:91 shared-module/struct/__init__.c:175
#: py/modstruct.c:148 py/modstruct.c:156 py/modstruct.c:244 py/modstruct.c:254
#: shared-bindings/struct/__init__.c:102 shared-bindings/struct/__init__.c:161
#: shared-module/struct/__init__.c:183
msgid "buffer too small"
msgstr "tampon trop petit"
@ -2703,10 +2703,20 @@ msgstr "'/' ne peut être remonté quand l'USB est actif."
msgid "'S' and 'O' are not supported format types"
msgstr "'S' et 'O' ne sont pas des types de format supportés"
#: shared-module/struct/__init__.c:83
#: shared-module/struct/__init__.c:128
#, fuzzy, c-format
msgid "unpack requires a buffer of %d bytes"
msgstr "Echec de l'allocation de %d octets du tampon RX"
#: shared-module/struct/__init__.c:136
msgid "too many arguments provided with the given format"
msgstr "trop d'arguments fournis avec ce format"
#: shared-module/struct/__init__.c:179
#, fuzzy
msgid "buffer size must match format"
msgstr "les slices de tampon doivent être de longueurs égales"
#: shared-module/usb_hid/Device.c:45
#, c-format
msgid "Buffer incorrect size. Should be %d bytes."
@ -2806,47 +2816,17 @@ msgstr ""
"Le bouton 'reset' a été appuyé pendant le démarrage de CircuitPython. "
"Appuyer denouveau pour quitter de le mode sans-échec.\n"
#~ msgid "Invalid UUID string length"
#~ msgstr "Longeur de chaîne UUID invalide"
#~ msgid "Cannot set PPCP parameters."
#~ msgstr "Impossible d'appliquer les paramètres PPCP"
#~ msgid "Invalid UUID parameter"
#~ msgstr "Paramètre UUID invalide"
#~ msgid "Can not add Characteristic."
#~ msgstr "Impossible d'ajouter la Characteristic."
#, fuzzy
#~ msgid "palette must be displayio.Palette"
#~ msgstr "la palette doit être une displayio.Palette"
#~ msgid "Can not query for the device address."
#~ msgstr "Impossible d'obtenir l'adresse du périphérique"
#, fuzzy
#~ msgid "value_size must be power of two"
#~ msgstr "value_size doit être une puissance de 2"
#~ msgid "Cannot apply GAP parameters."
#~ msgstr "Impossible d'appliquer les paramètres GAP"
#~ msgid "Invalid Service type"
#~ msgstr "Type de service invalide"
#~ msgid ""
#~ "Please file an issue here with the contents of your CIRCUITPY drive:\n"
#~ msgstr ""
#~ "SVP, remontez le problème là avec le contenu du lecteur CIRCUITPY:\n"
#~ msgid "Can not encode UUID, to check length."
#~ msgstr "Impossible d'encoder l'UUID pour vérifier la longueur."
#~ msgid "Wrong address length"
#~ msgstr "Mauvaise longueur d'adresse"
#, fuzzy
#~ msgid "Wrong number of bytes provided"
#~ msgstr "mauvais nombre d'octets fourni'"
#~ msgid "Can not apply device name in the stack."
#~ msgstr "Impossible d'appliquer le nom de périphérique dans la pile"
#~ msgid "Looks like our core CircuitPython code crashed hard. Whoops!\n"
#~ msgstr ""
#~ "Il semblerait que votre code CircuitPython a durement planté. Oups!\n"
#~ msgid "Can not add Service."
#~ msgstr "Impossible d'ajouter le Service"
#~ msgid ""
#~ "enough power for the whole circuit and press reset (after ejecting "
@ -2855,14 +2835,44 @@ msgstr ""
#~ "assez de puissance pour l'ensemble du circuit et appuyez sur "
#~ "'reset' (après avoir éjecter CIRCUITPY).\n"
#~ msgid "Can not add Service."
#~ msgstr "Impossible d'ajouter le Service"
#~ msgid "Looks like our core CircuitPython code crashed hard. Whoops!\n"
#~ msgstr ""
#~ "Il semblerait que votre code CircuitPython a durement planté. Oups!\n"
#~ msgid "Can not query for the device address."
#~ msgstr "Impossible d'obtenir l'adresse du périphérique"
#~ msgid "Can not apply device name in the stack."
#~ msgstr "Impossible d'appliquer le nom de périphérique dans la pile"
#~ msgid "Can not add Characteristic."
#~ msgstr "Impossible d'ajouter la Characteristic."
#, fuzzy
#~ msgid "Wrong number of bytes provided"
#~ msgstr "mauvais nombre d'octets fourni'"
#~ msgid "Cannot set PPCP parameters."
#~ msgstr "Impossible d'appliquer les paramètres PPCP"
#~ msgid "Wrong address length"
#~ msgstr "Mauvaise longueur d'adresse"
#~ msgid "Can not encode UUID, to check length."
#~ msgstr "Impossible d'encoder l'UUID pour vérifier la longueur."
#~ msgid ""
#~ "Please file an issue here with the contents of your CIRCUITPY drive:\n"
#~ msgstr ""
#~ "SVP, remontez le problème là avec le contenu du lecteur CIRCUITPY:\n"
#~ msgid "Invalid Service type"
#~ msgstr "Type de service invalide"
#~ msgid "Cannot apply GAP parameters."
#~ msgstr "Impossible d'appliquer les paramètres GAP"
#, fuzzy
#~ msgid "value_size must be power of two"
#~ msgstr "value_size doit être une puissance de 2"
#, fuzzy
#~ msgid "palette must be displayio.Palette"
#~ msgstr "la palette doit être une displayio.Palette"
#~ msgid "Invalid UUID parameter"
#~ msgstr "Paramètre UUID invalide"
#~ msgid "Invalid UUID string length"
#~ msgstr "Longeur de chaîne UUID invalide"

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-01-20 17:33-0800\n"
"POT-Creation-Date: 2019-01-20 22:46-0500\n"
"PO-Revision-Date: 2018-10-02 16:27+0200\n"
"Last-Translator: Enrico Paganin <enrico.paganin@mail.com>\n"
"Language-Team: \n"
@ -1366,9 +1366,9 @@ msgstr "divisione per zero"
msgid "schedule stack full"
msgstr ""
#: py/modstruct.c:145 py/modstruct.c:153 py/modstruct.c:234 py/modstruct.c:244
#: shared-bindings/struct/__init__.c:103 shared-bindings/struct/__init__.c:145
#: shared-module/struct/__init__.c:91 shared-module/struct/__init__.c:175
#: py/modstruct.c:148 py/modstruct.c:156 py/modstruct.c:244 py/modstruct.c:254
#: shared-bindings/struct/__init__.c:102 shared-bindings/struct/__init__.c:161
#: shared-module/struct/__init__.c:183
msgid "buffer too small"
msgstr "buffer troppo piccolo"
@ -2685,10 +2685,20 @@ msgstr "Non è possibile rimontare '/' mentre l'USB è attiva."
msgid "'S' and 'O' are not supported format types"
msgstr "'S' e 'O' non sono formati supportati"
#: shared-module/struct/__init__.c:83
#: shared-module/struct/__init__.c:128
#, fuzzy, c-format
msgid "unpack requires a buffer of %d bytes"
msgstr "Fallita allocazione del buffer RX di %d byte"
#: shared-module/struct/__init__.c:136
msgid "too many arguments provided with the given format"
msgstr "troppi argomenti forniti con il formato specificato"
#: shared-module/struct/__init__.c:179
#, fuzzy
msgid "buffer size must match format"
msgstr "slice del buffer devono essere della stessa lunghezza"
#: shared-module/usb_hid/Device.c:45
#, c-format
msgid "Buffer incorrect size. Should be %d bytes."
@ -2775,53 +2785,8 @@ msgid ""
"exit safe mode.\n"
msgstr ""
#~ msgid "Invalid UUID string length"
#~ msgstr "Lunghezza della stringa UUID non valida"
#~ msgid "Invalid UUID parameter"
#~ msgstr "Parametro UUID non valido"
#~ msgid "Invalid Service type"
#~ msgstr "Tipo di servizio non valido"
#, fuzzy
#~ msgid "Wrong number of bytes provided"
#~ msgstr "numero di argomenti errato"
#~ msgid "Cannot set PPCP parameters."
#~ msgstr "Impossibile impostare i parametri PPCP."
#~ msgid "Can not add Characteristic."
#~ msgstr "Non è possibile aggiungere Characteristic."
#~ msgid "Can not encode UUID, to check length."
#~ msgstr "Non è possibile codificare l'UUID, lunghezza da controllare."
#~ msgid ""
#~ "Please file an issue here with the contents of your CIRCUITPY drive:\n"
#~ msgstr ""
#~ "Ti preghiamo di compilare una issue con il contenuto del tuo drie "
#~ "CIRCUITPY:\n"
#~ msgid "Can encode UUID into the advertisement packet."
#~ msgstr "È possibile codificare l'UUID nel pacchetto di advertisement."
#~ msgid "Can not apply device name in the stack."
#~ msgstr "Non è possibile inserire il nome del dipositivo nella lista."
#~ msgid "Can not add Service."
#~ msgstr "Non è possibile aggiungere Service."
#~ msgid "Can not apply advertisement data. status: 0x%02x"
#~ msgstr "Impossible inserire dati advertisement. status: 0x%02x"
#~ msgid "Can not query for the device address."
#~ msgstr "Non è possibile trovare l'indirizzo del dispositivo."
#~ msgid "Looks like our core CircuitPython code crashed hard. Whoops!\n"
#~ msgstr ""
#~ "Sembra che il codice del core di CircuitPython sia crashato malamente. "
#~ "Whoops!\n"
#~ msgid "Cannot apply GAP parameters."
#~ msgstr "Impossibile applicare i parametri GAP."
#~ msgid ""
#~ "enough power for the whole circuit and press reset (after ejecting "
@ -2830,5 +2795,50 @@ msgstr ""
#~ "abbastanza potenza per l'intero circuito e premere reset (dopo aver "
#~ "espulso CIRCUITPY).\n"
#~ msgid "Cannot apply GAP parameters."
#~ msgstr "Impossibile applicare i parametri GAP."
#~ msgid "Looks like our core CircuitPython code crashed hard. Whoops!\n"
#~ msgstr ""
#~ "Sembra che il codice del core di CircuitPython sia crashato malamente. "
#~ "Whoops!\n"
#~ msgid "Can not query for the device address."
#~ msgstr "Non è possibile trovare l'indirizzo del dispositivo."
#~ msgid "Can not apply advertisement data. status: 0x%02x"
#~ msgstr "Impossible inserire dati advertisement. status: 0x%02x"
#~ msgid "Can not add Service."
#~ msgstr "Non è possibile aggiungere Service."
#~ msgid "Can not apply device name in the stack."
#~ msgstr "Non è possibile inserire il nome del dipositivo nella lista."
#~ msgid "Can encode UUID into the advertisement packet."
#~ msgstr "È possibile codificare l'UUID nel pacchetto di advertisement."
#~ msgid ""
#~ "Please file an issue here with the contents of your CIRCUITPY drive:\n"
#~ msgstr ""
#~ "Ti preghiamo di compilare una issue con il contenuto del tuo drie "
#~ "CIRCUITPY:\n"
#~ msgid "Can not encode UUID, to check length."
#~ msgstr "Non è possibile codificare l'UUID, lunghezza da controllare."
#~ msgid "Can not add Characteristic."
#~ msgstr "Non è possibile aggiungere Characteristic."
#~ msgid "Cannot set PPCP parameters."
#~ msgstr "Impossibile impostare i parametri PPCP."
#, fuzzy
#~ msgid "Wrong number of bytes provided"
#~ msgstr "numero di argomenti errato"
#~ msgid "Invalid Service type"
#~ msgstr "Tipo di servizio non valido"
#~ msgid "Invalid UUID parameter"
#~ msgstr "Parametro UUID non valido"
#~ msgid "Invalid UUID string length"
#~ msgstr "Lunghezza della stringa UUID non valida"

View File

@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2019-01-20 17:33-0800\n"
"POT-Creation-Date: 2019-01-20 22:46-0500\n"
"PO-Revision-Date: 2018-10-02 21:14-0000\n"
"Last-Translator: \n"
"Language-Team: \n"
@ -1348,9 +1348,9 @@ msgstr "divisão por zero"
msgid "schedule stack full"
msgstr ""
#: py/modstruct.c:145 py/modstruct.c:153 py/modstruct.c:234 py/modstruct.c:244
#: shared-bindings/struct/__init__.c:103 shared-bindings/struct/__init__.c:145
#: shared-module/struct/__init__.c:91 shared-module/struct/__init__.c:175
#: py/modstruct.c:148 py/modstruct.c:156 py/modstruct.c:244 py/modstruct.c:254
#: shared-bindings/struct/__init__.c:102 shared-bindings/struct/__init__.c:161
#: shared-module/struct/__init__.c:183
msgid "buffer too small"
msgstr ""
@ -2642,10 +2642,20 @@ msgstr "Não é possível remontar '/' enquanto o USB estiver ativo."
msgid "'S' and 'O' are not supported format types"
msgstr "'S' e 'O' não são tipos de formato suportados"
#: shared-module/struct/__init__.c:83
#: shared-module/struct/__init__.c:128
#, fuzzy, c-format
msgid "unpack requires a buffer of %d bytes"
msgstr "Falha ao alocar buffer RX de %d bytes"
#: shared-module/struct/__init__.c:136
msgid "too many arguments provided with the given format"
msgstr "Muitos argumentos fornecidos com o formato dado"
#: shared-module/struct/__init__.c:179
#, fuzzy
msgid "buffer size must match format"
msgstr "buffers devem ser o mesmo tamanho"
#: shared-module/usb_hid/Device.c:45
#, c-format
msgid "Buffer incorrect size. Should be %d bytes."
@ -2726,32 +2736,32 @@ msgid ""
"exit safe mode.\n"
msgstr ""
#~ msgid "Can not query for the device address."
#~ msgstr "Não é possível consultar o endereço do dispositivo."
#~ msgid "Invalid Service type"
#~ msgstr "Tipo de serviço inválido"
#~ msgid "Can not apply device name in the stack."
#~ msgstr "Não é possível aplicar o nome do dispositivo na pilha."
#~ msgid "Baud rate too high for this SPI peripheral"
#~ msgstr "Taxa de transmissão muito alta para esse periférico SPI"
#~ msgid "Can not add Characteristic."
#~ msgstr "Não é possível adicionar Característica."
#~ msgid "Cannot apply GAP parameters."
#~ msgstr "Não é possível aplicar parâmetros GAP."
#~ msgid "Invalid UUID parameter"
#~ msgstr "Parâmetro UUID inválido"
#~ msgid "Can not apply advertisement data. status: 0x%02x"
#~ msgstr "Não é possível aplicar dados de anúncio. status: 0x%02x"
#~ msgid "Cannot set PPCP parameters."
#~ msgstr "Não é possível definir parâmetros PPCP."
#~ msgid "Can encode UUID into the advertisement packet."
#~ msgstr "Pode codificar o UUID no pacote de anúncios."
#~ msgid "Cannot set PPCP parameters."
#~ msgstr "Não é possível definir parâmetros PPCP."
#~ msgid "Can not apply advertisement data. status: 0x%02x"
#~ msgstr "Não é possível aplicar dados de anúncio. status: 0x%02x"
#~ msgid "Invalid UUID parameter"
#~ msgstr "Parâmetro UUID inválido"
#~ msgid "Cannot apply GAP parameters."
#~ msgstr "Não é possível aplicar parâmetros GAP."
#~ msgid "Can not add Characteristic."
#~ msgstr "Não é possível adicionar Característica."
#~ msgid "Baud rate too high for this SPI peripheral"
#~ msgstr "Taxa de transmissão muito alta para esse periférico SPI"
#~ msgid "Can not apply device name in the stack."
#~ msgstr "Não é possível aplicar o nome do dispositivo na pilha."
#~ msgid "Invalid Service type"
#~ msgstr "Tipo de serviço inválido"
#~ msgid "Can not query for the device address."
#~ msgstr "Não é possível consultar o endereço do dispositivo."

View File

@ -49,7 +49,7 @@ size_t mp_binary_get_size(char struct_type, char val_type, mp_uint_t *palign) {
switch (struct_type) {
case '<': case '>':
switch (val_type) {
case 'b': case 'B':
case 'b': case 'B': case 'x':
size = 1; break;
case 'h': case 'H':
size = 2; break;
@ -79,7 +79,7 @@ size_t mp_binary_get_size(char struct_type, char val_type, mp_uint_t *palign) {
// particular (or any) ABI.
switch (val_type) {
case BYTEARRAY_TYPECODE:
case 'b': case 'B':
case 'b': case 'B': case 'x':
align = size = 1; break;
case 'h': case 'H':
align = alignof(short);
@ -126,6 +126,7 @@ mp_obj_t mp_binary_get_val_array(char typecode, void *p, mp_uint_t index) {
break;
case BYTEARRAY_TYPECODE:
case 'B':
case 'x': // value will be discarded
val = ((unsigned char*)p)[index];
break;
case 'h':
@ -364,6 +365,8 @@ void mp_binary_set_val_array_from_int(char typecode, void *p, mp_uint_t index, m
case 'B':
((unsigned char*)p)[index] = val;
break;
case 'x':
((unsigned char*)p)[index] = 0;
case 'h':
((short*)p)[index] = val;
break;

View File

@ -97,7 +97,10 @@ STATIC size_t calc_size_items(const char *fmt, size_t *total_sz) {
total_cnt += 1;
size += cnt;
} else {
// Pad bytes are skipped and don't get included in the item count.
if (*fmt != 'x') {
total_cnt += cnt;
}
mp_uint_t align;
size_t sz = mp_binary_get_size(fmt_type, *fmt, &align);
while (cnt--) {
@ -166,9 +169,12 @@ STATIC mp_obj_t struct_unpack_from(size_t n_args, const mp_obj_t *args) {
} else {
while (cnt--) {
item = mp_binary_get_val(fmt_type, *fmt, &p);
// Pad bytes ('x') are just skipped.
if (*fmt != 'x') {
res->items[i++] = item;
}
}
}
fmt++;
}
return MP_OBJ_FROM_PTR(res);
@ -204,7 +210,11 @@ STATIC void struct_pack_into_internal(mp_obj_t fmt_in, byte *p, size_t n_args, c
} else {
// If we run out of args then we just finish; CPython would raise struct.error
while (cnt-- && i < n_args) {
mp_binary_set_val(fmt_type, *fmt, args[i++], &p);
mp_binary_set_val(fmt_type, *fmt, args[i], &p);
// Pad bytes don't have a corresponding argument.
if (*fmt != 'x') {
i++;
}
}
}
fmt++;

View File

@ -51,7 +51,7 @@
//|
//| Supported size/byte order prefixes: *@*, *<*, *>*, *!*.
//|
//| Supported format codes: *b*, *B*, *h*, *H*, *i*, *I*, *l*, *L*, *q*, *Q*,
//| Supported format codes: *b*, *B*, *x*, *h*, *H*, *i*, *I*, *l*, *L*, *q*, *Q*,
//| *s*, *P*, *f*, *d* (the latter 2 depending on the floating-point support).
//|
@ -74,7 +74,6 @@ MP_DEFINE_CONST_FUN_OBJ_1(struct_calcsize_obj, struct_calcsize);
//|
STATIC mp_obj_t struct_pack(size_t n_args, const mp_obj_t *args) {
// TODO: "The arguments must match the values required by the format exactly."
mp_int_t size = MP_OBJ_SMALL_INT_VALUE(struct_calcsize(args[0]));
vstr_t vstr;
vstr_init_len(&vstr, size);
@ -115,29 +114,46 @@ MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(struct_pack_into_obj, 3, MP_OBJ_FUN_ARGS_MAX
//| .. function:: unpack(fmt, data)
//|
//| Unpack from the data according to the format string fmt. The return value
//| is a tuple of the unpacked values.
//| is a tuple of the unpacked values. The buffer size must match the size
//| required by the format.
//|
//| .. function:: unpack_from(fmt, data, offset)
//|
//| Unpack from the data starting at offset according to the format string fmt.
//| offset may be negative to count from the end of buffer. The return value is
//| a tuple of the unpacked values.
//|
STATIC mp_obj_t struct_unpack_from(size_t n_args, const mp_obj_t *args) {
// unpack requires that the buffer be exactly the right size.
// unpack_from requires that the buffer be "big enough".
// Since we implement unpack and unpack_from using the same function
// we relax the "exact" requirement, and only implement "big enough".
STATIC mp_obj_t struct_unpack(size_t n_args, const mp_obj_t *args) {
mp_buffer_info_t bufinfo;
mp_get_buffer_raise(args[1], &bufinfo, MP_BUFFER_READ);
byte *p = bufinfo.buf;
byte *end_p = &p[bufinfo.len];
if (n_args > 2) {
mp_int_t offset = mp_obj_get_int(args[2]);
// offset arg provided
// true means check the size must be exactly right.
return MP_OBJ_FROM_PTR(shared_modules_struct_unpack_from(args[0] , p, end_p, true));
}
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(struct_unpack_obj, 2, 3, struct_unpack);
//| .. function:: unpack_from(fmt, data, offset=0)
//|
//| Unpack from the data starting at offset according to the format string fmt.
//| offset may be negative to count from the end of buffer. The return value is
//| a tuple of the unpacked values. The buffer size must be at least as big
//| as the size required by the form.
//|
STATIC mp_obj_t struct_unpack_from(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
enum { ARG_format, ARG_buffer, ARG_offset };
static const mp_arg_t allowed_args[] = {
{ MP_QSTR_format, MP_ARG_REQUIRED | MP_ARG_OBJ },
{ MP_QSTR_buffer, MP_ARG_REQUIRED | MP_ARG_OBJ },
{ MP_QSTR_offset, MP_ARG_INT, {.u_int = 0} },
};
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
mp_buffer_info_t bufinfo;
mp_get_buffer_raise(args[ARG_buffer].u_obj, &bufinfo, MP_BUFFER_READ);
byte *p = bufinfo.buf;
byte *end_p = &p[bufinfo.len];
mp_int_t offset = args[ARG_offset].u_int;
if (offset < 0) {
// negative offsets are relative to the end of the buffer
offset = bufinfo.len + offset;
@ -146,18 +162,19 @@ STATIC mp_obj_t struct_unpack_from(size_t n_args, const mp_obj_t *args) {
}
}
p += offset;
}
return MP_OBJ_FROM_PTR(shared_modules_struct_unpack_from(args[0] , p, end_p));
// false means the size doesn't have to be exact. struct.unpack_from() only requires
// that be buffer be big enough.
return MP_OBJ_FROM_PTR(shared_modules_struct_unpack_from(args[ARG_format].u_obj, p, end_p, false));
}
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(struct_unpack_from_obj, 2, 3, struct_unpack_from);
MP_DEFINE_CONST_FUN_OBJ_KW(struct_unpack_from_obj, 0, struct_unpack_from);
STATIC const mp_rom_map_elem_t mp_module_struct_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_struct) },
{ MP_ROM_QSTR(MP_QSTR_calcsize), MP_ROM_PTR(&struct_calcsize_obj) },
{ MP_ROM_QSTR(MP_QSTR_pack), MP_ROM_PTR(&struct_pack_obj) },
{ MP_ROM_QSTR(MP_QSTR_pack_into), MP_ROM_PTR(&struct_pack_into_obj) },
{ MP_ROM_QSTR(MP_QSTR_unpack), MP_ROM_PTR(&struct_unpack_from_obj) },
{ MP_ROM_QSTR(MP_QSTR_unpack), MP_ROM_PTR(&struct_unpack_obj) },
{ MP_ROM_QSTR(MP_QSTR_unpack_from), MP_ROM_PTR(&struct_unpack_from_obj) },
};

View File

@ -29,6 +29,6 @@
void shared_modules_struct_pack_into(mp_obj_t fmt_in, byte *p, byte* end_p, size_t n_args, const mp_obj_t *args);
mp_uint_t shared_modules_struct_calcsize(mp_obj_t fmt_in);
mp_obj_tuple_t * shared_modules_struct_unpack_from(mp_obj_t fmt_in, byte *p, byte *end_p);
mp_obj_tuple_t * shared_modules_struct_unpack_from(mp_obj_t fmt_in, byte *p, byte *end_p, bool exact_size);
#endif // MICROPY_INCLUDED_SHARED_BINDINGS_RANDOM___INIT___H

View File

@ -71,45 +71,6 @@ mp_uint_t get_fmt_num(const char **p) {
return val;
}
void shared_modules_struct_pack_into(mp_obj_t fmt_in, byte *p, byte* end_p, size_t n_args, const mp_obj_t *args) {
const char *fmt = mp_obj_str_get_str(fmt_in);
char fmt_type = get_fmt_type(&fmt);
size_t i;
for (i = 0; i < n_args;) {
mp_uint_t sz = 1;
if (*fmt == '\0') {
// more arguments given than used by format string; CPython raises struct.error here
mp_raise_RuntimeError(translate("too many arguments provided with the given format"));
}
struct_validate_format(*fmt);
if (unichar_isdigit(*fmt)) {
sz = get_fmt_num(&fmt);
}
if (p + sz > end_p) {
mp_raise_RuntimeError(translate("buffer too small"));
}
if (*fmt == 's') {
mp_buffer_info_t bufinfo;
mp_get_buffer_raise(args[i++], &bufinfo, MP_BUFFER_READ);
mp_uint_t to_copy = sz;
if (bufinfo.len < to_copy) {
to_copy = bufinfo.len;
}
memcpy(p, bufinfo.buf, to_copy);
memset(p + to_copy, 0, sz - to_copy);
p += sz;
} else {
while (sz--) {
mp_binary_set_val(fmt_type, *fmt, args[i++], &p);
}
}
fmt++;
}
}
mp_uint_t calcsize_items(const char *fmt) {
mp_uint_t cnt = 0;
while (*fmt) {
@ -120,7 +81,10 @@ mp_uint_t calcsize_items(const char *fmt) {
num = 1;
}
}
// Pad bytes are skipped and don't get included in the item count.
if (*fmt != 'x') {
cnt += num;
}
fmt++;
}
return cnt;
@ -155,14 +119,71 @@ mp_uint_t shared_modules_struct_calcsize(mp_obj_t fmt_in) {
return size;
}
void shared_modules_struct_pack_into(mp_obj_t fmt_in, byte *p, byte* end_p, size_t n_args, const mp_obj_t *args) {
const char *fmt = mp_obj_str_get_str(fmt_in);
char fmt_type = get_fmt_type(&fmt);
const mp_uint_t total_sz = shared_modules_struct_calcsize(fmt_in);
mp_obj_tuple_t * shared_modules_struct_unpack_from(mp_obj_t fmt_in, byte *p, byte *end_p) {
if (p + total_sz != end_p) {
mp_raise_msg_varg(&mp_type_RuntimeError, translate("unpack requires a buffer of %d bytes"), total_sz);
}
size_t i;
for (i = 0; i < n_args;) {
mp_uint_t sz = 1;
if (*fmt == '\0') {
// more arguments given than used by format string; CPython raises struct.error here
mp_raise_RuntimeError(translate("too many arguments provided with the given format"));
}
struct_validate_format(*fmt);
if (unichar_isdigit(*fmt)) {
sz = get_fmt_num(&fmt);
}
if (*fmt == 's') {
mp_buffer_info_t bufinfo;
mp_get_buffer_raise(args[i++], &bufinfo, MP_BUFFER_READ);
mp_uint_t to_copy = sz;
if (bufinfo.len < to_copy) {
to_copy = bufinfo.len;
}
memcpy(p, bufinfo.buf, to_copy);
memset(p + to_copy, 0, sz - to_copy);
p += sz;
} else {
while (sz--) {
mp_binary_set_val(fmt_type, *fmt, args[i], &p);
// Pad bytes don't have a corresponding argument.
if (*fmt != 'x') {
i++;
}
}
}
fmt++;
}
}
mp_obj_tuple_t * shared_modules_struct_unpack_from(mp_obj_t fmt_in, byte *p, byte *end_p, bool exact_size) {
const char *fmt = mp_obj_str_get_str(fmt_in);
char fmt_type = get_fmt_type(&fmt);
mp_uint_t num_items = calcsize_items(fmt);
const mp_uint_t num_items = calcsize_items(fmt);
const mp_uint_t total_sz = shared_modules_struct_calcsize(fmt_in);
mp_obj_tuple_t *res = MP_OBJ_TO_PTR(mp_obj_new_tuple(num_items, NULL));
// If exact_size, make sure the buffer is exactly the right size.
// Otherwise just make sure it's big enough.
if (exact_size) {
if (p + total_sz != end_p) {
mp_raise_RuntimeError(translate("buffer size must match format"));
}
} else {
if (p + total_sz > end_p) {
mp_raise_RuntimeError(translate("buffer too small"));
}
}
for (uint i = 0; i < num_items;) {
mp_uint_t sz = 1;
@ -171,9 +192,6 @@ mp_obj_tuple_t * shared_modules_struct_unpack_from(mp_obj_t fmt_in, byte *p, byt
if (unichar_isdigit(*fmt)) {
sz = get_fmt_num(&fmt);
}
if (p + sz > end_p) {
mp_raise_RuntimeError(translate("buffer too small"));
}
mp_obj_t item;
if (*fmt == 's') {
item = mp_obj_new_bytes(p, sz);
@ -182,9 +200,12 @@ mp_obj_tuple_t * shared_modules_struct_unpack_from(mp_obj_t fmt_in, byte *p, byt
} else {
while (sz--) {
item = mp_binary_get_val(fmt_type, *fmt, &p);
// Pad bytes are not stored.
if (*fmt != 'x') {
res->items[i++] = item;
}
}
}
fmt++;
}
return res;