live scalar field views - #76
Merged
Merged
Conversation
Scalar allocatable and pointer fields of a derived type, numeric or character, now read as live read-only rank-zero views or None and are assigned through an allocating or target copy, the way the matching module variables are. They previously failed to build. Pointer holders now report fields they cannot reach as a policy diagnostic instead of failing during planning, and the generated .pyi constructor no longer lists these fields. The README's Fortran limitations drop assumed-rank type(*) buffers and the now-supported fields, and end every item with a full stop. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Scalar fields of a Fortran derived type now read as live rank-zero NumPy views of the object's storage, the way module variables do: numeric and logical fields as T[()] views and fixed-length character fields as fixed-width bytes views, spelled T[()] and String[n][()] in generated contracts. An edited contract that keeps a plain T or String[n] field still reads a copied value. Direct objects, module-object members, and objects held through allocatable or pointer descriptors all lend the same storage. Scalar allocatable and pointer module variables and fields now lend writable views, matching allocatable and pointer array views: a view is valid until native code reallocates, deallocates, or reassociates it, and assigning the attribute still reaches the current storage. The bridge's field dispatchers become table dispatch over named builders, and one address-capture reader in the planner serves both backends. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
Fortran character(kind=selected_char_kind('ISO_10646')) declarations are
wrapped through the new UString contract type, which takes every form
String does and maps fixed-width storage to NumPy U<n> instead of S<n>.
Kinds that select ASCII or DEFAULT are ordinary Strings; a compiler without
ISO_10646 is reported as not providing the character set.
String and UString share one path. The type name carries the character
width, one helper answers whether a type is a string and how wide its
characters are, and every stage reads that width: the bridge declares the
matching character kind and sizes byte buffers, the binding selects the
UTF-8 or UCS-4 codec, NumPy dtype, and itemsize, and the runtime helpers
take the width. For the default kind every stage emits the code it did
before. A UCS-4 str input is converted into the call buffer mutable strings
already use, because a str holds no UCS-4 storage to lend.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…mber
Kind numbers are processor-dependent, so character(kind=4) no longer means
UCS-4; only selected_char_kind('ISO_10646'), directly or through a parameter,
selects UString. A known selector keeps its spelling instead of being
replaced by its probed number, which now only reports a compiler lacking the
set. Function results resolve their character selector against module
parameters the way arguments already did.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… sets
A numeric character kind such as kind=4 names whichever character set the
target compiler numbers that way. Semantic requirement collection now asks
the probe for selected_char_kind('DEFAULT'), 'ASCII', and 'ISO_10646', and
the converter builds one compiler-specific map from kind number to String or
UString. A number the compiler assigns to none of them is refused with a
message saying so. Selector spellings are still classified by the set they
name, without a probe.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…, and planner The allocatable- and pointer-holder field lowerings in the bridge and the binding differed only in holder type, capsule, and symbol names, so each backend now lowers holder fields once. Private field methods share one owner-argument parser, stored-field getters share one view builder, string validation is one function for both character widths, and field entrypoints share one operation and character-buffer constructor. Generated sources are byte-identical for every fixture in the test corpus. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ings Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.