[v1.0.8] - 2026-03-02
This release introduces a modernization of pointer handling, turning pins into first-class objects with native indexing support. In other words, you can now use $ptr->[$n] to access the nth element.
Support for passing 128bit integers around is now complete. Additionally, functions expecting an enumeration now accept the string name of a constant; state('PLASMA') is the same as state(PLASMA) where state expects values defined like this: typedef States => Enum['SOLID', 'LIQUID', 'GAS', 'PLASMA'].
Added
- Added support for native Perl array indexing on pointers and arrays. You can now use
$ptr->[$i]to read or write memory at an offset without manual casting. - New
Affix::Pointerobjects for structs and unions now allow direct field access like$ptr->{field}without explicit casting toLiveStruct. - Recursive Liveness: Unified access and
LiveStructnow work recursively. Accessing a nested struct member returns a live view or pointer tied to the original memory block. - All pointers returned by
malloc,calloc,cast, etc., are now blessed into theAffix::Pointerclass, which provides several new methods:address(): Returns the virtual memory address.type(): Returns the Lsignature of the pointer. element_type(): Returns the signature of the pointed-to elements.count(): Returns the element count for Arrays, or byte size for Void pointers.size(): Returns the total allocated size for managed pointers.cast($type): Reinterprets the pointer.attach_destructor($destructor, [$lib]): Attaches a custom C cleanup routine to the pointer.
- Added
attach_destructor( $pin, $destructor, [$lib] )to allow attaching custom C cleanup routines to managed pointers. - Improved
VarArgssupport to automatically promote Perl strings tochar*. - Experimental Zero-Copy 'Live' Aggregates:
LiveStruct: A new helper to return zero-copy, live views of C structs. Modifications to the returned blessed hash reflect immediately in C memory.LiveArray: A new helper to return liveAffix::Pointerobjects instead of deeply copied array references.- Implemented the
TIEHASHinterface forAffix::Liveso perl can treat them as standard Perl hashes (keys %$live,each %$live, etc.).
- Fully implemented marshalling for
Int128andUInt128(sint128/uint128) primitive types. - Added
Affix::Wrap->generate( $lib, $pkg, $file )for static binding generation. This emits standalone Perl modules that depend only onAffix, eliminating the need forClangor header files at runtime. - Recursive macro resolution support in
Affix::Wrapfor bitwise OR expressions like(FLAG_A | FLAG_B). - Support for passing string names of enum constants directly to functions.
- Added
params()method toAffix::Type::Callbackto allow inspecting and modifying callback parameters. - Added string-to-integer conversion when passing Perl strings to C functions expecting enums.
Fixed
- Optimized
Pointerreturns in the XSUB dispatcher for performance by inlining the marshalling path and caching the stash. - Fixed several issues in
CLONEwhere metadata, managed memory, and enum registries were not correctly duplicated across perl's ithreads. - Improved
_get_pin_from_svandis_pinto safely handle both references to pins and direct magical scalars like those found in Unions. - Fixed potential double-frees and leaks in
Affix_Lib_DESTROYandAffix_free_pinby improving reference counting and ownership tracking. - Symbols found via
find_symbolnow correctly track the parentAffix::Libobject to prevent the library from being unloaded while symbols are still in use. - Corrected a memory corruption bug in
Affix_mallocandAffix_strdupcaused by uninitialized internalAffix_Pinstructures. - Fixed
dualvarbehavior for enums returned from C, ensuring they correctly function as both strings and integers in Perl. - Fixed the
cleanaction inAffix::Builderwhich was failing due to an undefinedrmtreecall. - Fixed an issue where blessing a return value could prematurely trigger 'set' magic on the underlying SV.
- Fixed
typedefparsing: Named types now return properAffix::Type::Referenceobjects instead of strings, ensuring they are correctly resolved when nested in other aggregates. - Fixed
castto correctly return blessedAffix::Liveobjects when the+hint is used for live struct views. - Hardened pointer indexing: Added strict type checks to
$ptr->[$i]to ensure indexing is only performed onArraytypes orVoid*(byte-indexed).
Full Changelog: https://github.com/sanko/Affix.pm/compare/v1.0.7...v1.0.8