NativeStructAlloc<C extends Struct, D extends StructD<C, D> > class
A slot-based allocator for native structs of type C, accepting Dart-side
StructD wrappers of type D.
Bridges between the ergonomic Dart StructD layer and raw Pointer<C>
memory, supporting both single-value and array slots.
- Inheritance
-
- Object
- RaylibTempAllocatorBase<
RaylibTemp, Pointer< C> , Pointer<C> > - NativeAlloc<
C> - NativeStructAlloc
- Mixed-in types
-
- RaylibTempStructAllocatorBase<
RaylibTemp, D, C, Pointer< C> , Pointer<C> >
- RaylibTempStructAllocatorBase<
Constructors
-
NativeStructAlloc(RaylibTemp temp, String name, {required int byteSize, required Pointer<
C> allocatorFunc([int count]), required String printerFunc(Pointer<C> ptr), required C refFunc(Pointer<C> ptr), required Pointer<C> setRefFunc(Pointer<C> ptr, C value), required void setCFunc(Pointer<C> ptr, int i, C value), required C indexerFunc(Pointer<C> ptr, int i), required void indexSetterFunc(Pointer<C> ptr, int i, C value), required D pointerToStruct(Pointer<C> ptr), required void updateFunc(Pointer<C> ptr, D source)})
Properties
-
allocatorFunc
→ Pointer<
C> Function([int count]) -
Allocates
countelements and returns the raw source pointer.finalinherited - byteSize → int
-
Size in bytes of a single element this allocator manages.
finalinherited
-
freeFunc
→ void Function(Pointer<
C> ptr) -
Frees the memory at
ptr.finalinherited - hashCode → int
-
The hash code for this object.
no setterinherited
-
indexerFunc
→ C Function(Pointer<
C> ptr, int i) -
Returns the
Cstruct at indexiof the array atptr.final -
indexSetterFunc
→ void Function(Pointer<
C> ptr, int i, C value) -
Overwrites the
i-th element of the array atptrwithvalue.final -
isPointerNull
→ bool Function(Pointer<
C> ptr) -
Returns
trueifptris null or zero.finalinherited - name → String
-
Debug name for this allocator, used in logging and diagnostics.
finalinherited
-
nullptrFactory
→ Pointer<
C> Function() -
Returns a null/zero pointer of type
P.finalinherited -
pointerFactory
→ Pointer<
C> Function(Pointer<C> ptr) -
Wraps a source pointer
ptrinto the platform pointer typeP.finalinherited -
pointerToSource
→ Pointer<
C> Function(Pointer<C> ptr) -
Unwraps a platform pointer
ptrback to its source typeS.finalinherited -
pointerToStruct
→ D Function(Pointer<
C> ptr) -
Converts a
Pto its Dart-sideXwrapper, referencing the memory at that pointer.final -
printerFunc
→ String Function(Pointer<
C> ptr) -
Returns a human-readable string representation of
ptr.finalinherited -
refFunc
→ C Function(Pointer<
C> ptr) -
Returns the
Vstruct value referenced byptr.final - runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
setCFunc
→ void Function(Pointer<
C> ptr, int i, C value) -
Copies the raw C struct
valueinto thei-th element of the array atptr.final -
setRefFunc
→ Pointer<
C> Function(Pointer<C> ptr, C value) -
Assigns
valueto the struct referenced byptr.final -
slots
→ Map<
String, (Pointer< C> , int)> -
Active allocation slots, keyed by slot name.
Each entry holds the pointer and its element count.
finalinherited
- temp → RaylibTemp
-
finalinherited
-
updateFunc
→ void Function(Pointer<
C> ptr, D source) -
Copies the fields of
sourceinto the native memory atptr.final -
writeIntoFunc
↔ void Function(Pointer<
C> ptr, D value) -
Writes the Dart value
valueinto the struct atptr.latefinaloverride-getter -
writeIntoIndexedFunc
↔ void Function(Pointer<
C> ptr, int i, D value) -
Writes the Dart value
valueinto thei-th element of the array atptr.latefinaloverride-getter
Methods
-
Array(
List< D> array, {String? key}) → Pointer<C> -
Writes
arrayinto a tracked slot of sufficient capacity.inherited -
At(
String key, [int count = 1]) → Pointer< C> -
Returns the
Pstored inkey, allocating (or reallocating) if necessary.inherited -
AtUnique(
String key, [int count = 1]) → Pointer< C> -
Allocates (or reuses) a slot identified by a unique
keysuffix.inherited -
Copy(
Pointer< C> src, int length, {String? key}) → Pointer<C> -
Copies
lengthstructs fromsrcinto a tracked slot using setCFunc.inherited -
dispose(
) → void -
Frees all currently tracked slots and clears the slot table.
inherited
-
Extract1(
void fn(Pointer< C> ptr)) → D -
Allocates slot
'1'as an uninitialized sret destination, passes its raw pointer tofn, then returns the structfnwrote into it.inherited -
Extract2(
void fn(Pointer< C> ptr)) → D -
Allocates slot
'2'as an uninitialized sret destination, passes its raw pointer tofn, then returns the structfnwrote into it.inherited -
Extract3(
void fn(Pointer< C> ptr)) → D -
Allocates slot
'3'as an uninitialized sret destination, passes its raw pointer tofn, then returns the structfnwrote into it.inherited -
Extract4(
void fn(Pointer< C> ptr)) → D -
Allocates slot
'4'as an uninitialized sret destination, passes its raw pointer tofn, then returns the structfnwrote into it.inherited -
Extract5(
void fn(Pointer< C> ptr)) → D -
Allocates slot
'5'as an uninitialized sret destination, passes its raw pointer tofn, then returns the structfnwrote into it.inherited -
Extract6(
void fn(Pointer< C> ptr)) → D -
Allocates slot
'6'as an uninitialized sret destination, passes its raw pointer tofn, then returns the structfnwrote into it.inherited -
Extract7(
void fn(Pointer< C> ptr)) → D -
Allocates slot
'7'as an uninitialized sret destination, passes its raw pointer tofn, then returns the structfnwrote into it.inherited -
Extract8(
void fn(Pointer< C> ptr)) → D -
Allocates slot
'8'as an uninitialized sret destination, passes its raw pointer tofn, then returns the structfnwrote into it.inherited -
Fill(
int count, D init(int), {String? key}) → Pointer< C> -
Fills a tracked slot of
countstructs, producing each element viainit(i)and writing it through writeIntoIndexedFunc.inherited -
FillInto(
int count, void init(int, C), {String? key}) → Pointer< C> -
Fills a tracked slot of
countstructs by callinginit(i, struct)which writes directly into the native struct fields.inherited -
FillWith(
int count, C init(Pointer< C> , int), {String? key}) → Pointer<C> -
Fills a tracked slot of
countstructs by setting each element to theCreturned byinit(ptr, i).inherited -
Free(
String key) → void -
Frees the native memory owned by slot
keyand removes it from the table.inherited -
getBaseKey(
D value, [String? inner]) → String -
Builds a RaylibTempBase slot key from
value'sstructName,tag, and an optionalinnersuffix.inherited -
getBaseKeyWithId(
D value, [String? inner]) → String -
Like getBaseKey but prefixed with
value'sinternalId, used for pointer-owning structs to prevent cross-instance key collisions.inherited -
Has(
String key) → bool -
Returns
trueif a slot with the givenkeyexists.inherited -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
PointerTo(
D value, [String? key]) → Pointer< C> -
Allocates or syncs
valueto a tracked slot atkey.inherited -
Raw(
[int count = 1]) → Pointer< C> -
Allocates
countraw elements and returns the wrapped pointer.inherited -
RawArray(
List< D> array) → Pointer<C> -
Allocates an unslotted array.
inherited
-
RawArrayPopulated(
List< D> array) → Pointer<C> -
Allocates an unslotted array and populates it from
array.inherited -
RawFillInto(
int count, void init(int, C)) → Pointer< C> -
Allocates an unslotted array of
countstructs, populating each viainit(i, struct)which writes directly into the native memory.inherited -
RawFillWith(
int count, C init(Pointer< C> , int)) → Pointer<C> -
Allocates an unslotted array of
countstructs, setting each element to theCreturned byinit(ptr, i).inherited -
Ref1(
[D? o]) → Pointer< C> -
Allocates
ointo slot'1', or reuses the existing slot'1'allocation ifoisnull.inherited -
Ref1OrNull(
[D? o]) → Pointer< C> -
Allocates
ointo slot'1', or returnsnullptrifoisnull.inherited -
Ref2(
[D? o]) → Pointer< C> -
Allocates
ointo slot'2', or reuses the existing slot'2'allocation ifoisnull.inherited -
Ref2OrNull(
[D? o]) → Pointer< C> -
Allocates
ointo slot'2', or returnsnullptrifoisnull.inherited -
Ref3(
[D? o]) → Pointer< C> -
Allocates
ointo slot'3', or reuses the existing slot'3'allocation ifoisnull.inherited -
Ref3OrNull(
[D? o]) → Pointer< C> -
Allocates
ointo slot'3', or returnsnullptrifoisnull.inherited -
Ref4(
[D? o]) → Pointer< C> -
Allocates
ointo slot'4', or reuses the existing slot'4'allocation ifoisnull.inherited -
Ref4OrNull(
[D? o]) → Pointer< C> -
Allocates
ointo slot'4', or returnsnullptrifoisnull.inherited -
Ref5(
[D? o]) → Pointer< C> -
Allocates
ointo slot'5', or reuses the existing slot'5'allocation ifoisnull.inherited -
Ref5OrNull(
[D? o]) → Pointer< C> -
Allocates
ointo slot'5', or returnsnullptrifoisnull.inherited -
Ref6(
[D? o]) → Pointer< C> -
Allocates
ointo slot'6', or reuses the existing slot'6'allocation ifoisnull.inherited -
Ref6OrNull(
[D? o]) → Pointer< C> -
Allocates
ointo slot'6', or returnsnullptrifoisnull.inherited -
Ref7(
[D? o]) → Pointer< C> -
Allocates
ointo slot'7', or reuses the existing slot'7'allocation ifoisnull.inherited -
Ref7OrNull(
[D? o]) → Pointer< C> -
Allocates
ointo slot'7', or returnsnullptrifoisnull.inherited -
Ref8(
[D? o]) → Pointer< C> -
Allocates
ointo slot'8', or reuses the existing slot'8'allocation ifoisnull.inherited -
Ref8OrNull(
[D? o]) → Pointer< C> -
Allocates
ointo slot'8', or returnsnullptrifoisnull.inherited -
RefCapture(
String key, dynamic fn(Pointer< C> ptr)) → D -
Copies the native struct
ointo a uniquely-keyed tracked slot and returns its Dart-sideXwrapper via pointerToStruct.inherited -
RefUpdate1<
R> (D? o, R fn(Pointer< C> p)) → R -
Allocates
ointo slot'1', callsfnwith the pointer, then syncs native memory back intoovia updateFunc.inherited -
RefUpdate2<
R> (D? o, R fn(Pointer< C> p)) → R -
Allocates
ointo slot'2', callsfnwith the pointer, then syncs native memory back intoovia updateFunc.inherited -
RefUpdate3<
R> (D? o, R fn(Pointer< C> p)) → R -
Allocates
ointo slot'3', callsfnwith the pointer, then syncs native memory back intoovia updateFunc.inherited -
RefUpdate4<
R> (D? o, R fn(Pointer< C> p)) → R -
Allocates
ointo slot'4', callsfnwith the pointer, then syncs native memory back intoovia updateFunc.inherited -
RefUpdate5<
R> (D? o, R fn(Pointer< C> p)) → R -
Allocates
ointo slot'5', callsfnwith the pointer, then syncs native memory back intoovia updateFunc.inherited -
RefUpdate6<
R> (D? o, R fn(Pointer< C> p)) → R -
Allocates
ointo slot'6', callsfnwith the pointer, then syncs native memory back intoovia updateFunc.inherited -
RefUpdate7<
R> (D? o, R fn(Pointer< C> p)) → R -
Allocates
ointo slot'7', callsfnwith the pointer, then syncs native memory back intoovia updateFunc.inherited -
RefUpdate8<
R> (D? o, R fn(Pointer< C> p)) → R -
Allocates
ointo slot'8', callsfnwith the pointer, then syncs native memory back intoovia updateFunc.inherited -
signature(
) → String -
Returns a string that identifies the concrete type of this allocator,
including its type parameters.
inherited
-
Size(
[int count = 1]) → int -
Returns the total byte size for
countelements.inherited -
Slot(
String key) → Pointer< C> ? -
Returns the pointer stored under
key, ornullif the slot does not exist. Does not allocate.inherited -
slotKey(
[String? key]) → String -
Returns the canonical slot key for
key, falling back to'struct'whenkeyisnull.inherited -
toString(
) → String -
A string representation of this object.
inherited
-
uniqueSlotKey(
String key) → String -
Returns a slot key guaranteed to be unique within this temp context,
by prefixing
keywith the next available ID.inherited -
Unslot(
String key) → void -
Removes the slot entry for
keyfrom the table without freeing the underlying memory.inherited -
Value(
[D? value, String? key]) → Pointer< C> -
Returns the pointer for slot
key, optionally writingvalueinto it.inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited