-
Notifications
You must be signed in to change notification settings - Fork 0
Phase 37 datatypes plan
Part of the Amiga port design log.
Status: planned, low priority. Not yet started — this page is the scope sketch, to be expanded into a step plan when the phase is picked up.
Wrap datatypes.library (V39+) for universal file recognition.
datatypes.library is AmigaOS's plug-in registry of file-format
handlers (.datatype modules in SYS:Classes/DataTypes/); any
running system knows about every datatype that's been installed
on it.
from amiga import datatypes
# "What is this file?" — works for everything the system has a
# datatype for: PNG/JPEG/GIF/IFF ILBM, 8SVX/AIFF/WAV, ASCII/IFF FTXT,
# anim, etc.
info = datatypes.recognize("Work:Photos/holiday.jpg")
# {'group': 'picture', 'type': 'jpeg', 'name': 'JPEG (JFIF)'}
# Slightly more: full DTA_* attribute dump.
attrs = datatypes.info("Work:Photos/holiday.jpg")
# {'BaseName': 'JPEG', 'GroupID': 'pict', 'Width': 1280, 'Height': 720, ...}-
amiga.datatypes.recognize(path)→ dict withgroup,type,name. UsesObtainDataTypeA(DTST_FILE, lock, NULL)thenGetDTAttrs(DTA_BaseName, DTA_GroupID, DTA_Name), releases viaReleaseDataType. -
amiga.datatypes.info(path)→ dict. Same asrecognizebut also queries common attrs (DTA_NominalHoriz/_NominalVertfor pictures,DTA_Duration/_SampleLengthfor sound, etc.) so callers can do quick metadata reads withoutNewDTObject. -
amiga.datatypes.groups()→ list of installed group IDs (one of"sound"/"picture"/"text"/"anim"/"system"/"document"). Iterates thedtl_*chain inDataTypesList.
-
NewDTObjectA/DoDTMethodA(DTM_DRAW)rendering — requires aRastPortand a targetBitMap, plus colour-map handling for CLUT formats. That's a much larger surface (graphics.library BitMap wrappers + intuition Screen/Window plumbing) and the payoff for a MicroPython workload is narrow. - Save-as-other-format (
DTM_WRITE) — same render-pipeline problem in reverse. - Audio playback (
DTM_TRIGGERon sound datatypes) — needs AHI on modern hosts. - BOOPSI object exposure —
NewDTObjectreturns anObject *that callers normally drive viaSetDTAttrs/GetDTAttrs/DoDTMethod. Surfacing that as a Python type is a whole separate phase (one BOOPSI superclass per Python class).
-
datatypes.libraryv39+. Lazy open. The library is V39+ (OS 3.0) baseline — earlier Kickstarts simply skip the import (we already require V37 for things likelib_call, so V39 is a small bump but worth a cleanOSError(MP_ENOSYS)if missing).
ports/amiga/moddatatypes.c — C module
ports/amiga/modules/amiga.py — adds `import _datatypes as datatypes`
tests/ports/amiga/test_datatypes_smoke.py — vamos arg-shape smoke
Variants: all three. ~2 KB text per variant.
recognize / info is genuinely useful but rarely on the critical
path for a MicroPython script — file-type sniffing is more often
done by reading the first few bytes (b"\x89PNG", b"\xff\xd8").
The big win is universal sniffing across formats the system has
been taught about (third-party PNG / JPEG / WebP .datatypes), and
that lives or dies by which datatypes are installed on the target
host. Land Phase 35 / 36 first; pick up Phase 37 if a real caller
shows up.