-
-
Notifications
You must be signed in to change notification settings - Fork 9
Anything
Anything
represents the type of a value that can be anything at runtime.
Type | Size | Possible Values | Memory Management Model | File |
---|---|---|---|---|
Anything |
32 bytes | Everything | Ownership | 2.7/Anything.adept |
struct Anything (struct Any, ownership Ownership, defer_func func(ptr) void)
where Any
is defined as
struct Any (type *AnyType, placeholder ulong)
Name | Type | Description |
---|---|---|
type |
*AnyType |
Pointer to type information |
placeholder |
ulong |
64-bits used either for value of primitive or for pointer to non-primitive |
ownership |
Ownership |
Whether responsible for cleanup |
defer_func |
func(ptr) void |
__defer__ function of held value. Can be null . |
-
func __defer__(this *Anything) void
Calls
this.defer_func
if it isn'tnull
. Used to deconstruct objects that require it. -
func __assign__(this *Anything, other POD Anything) void
Transfers ownership of values with
this.ownership == Ownership::GIVEN
, otherwise assigns self to be a weak reference to the data ofother
. -
func __pass__(anything POD Anything) Anything
Transfers ownership of values with
this.ownership == Ownership::GIVEN
to beOwnership::OWN
, otherwise if the passed value doesn't havethis.ownership == Ownership::OWN
, then a value will be returned with a weak reference to data of the passed value.
Anything
values are automatically freed when they run out of scope and have ownership.
-
func Anything(primitive $T~__primitive__) Anything
Constructs an
Anything
containing a primitive value -
func Anything(pointer *$T) Anything
Constructs an
Anything
containing a pointer to a value -
func Anything(thing POD $T) Anything
Constructs an
Anything
containing a new zero-initialized value of type$T
and then assignsthing
to the new contained value -
func AnythingFromAny(any Any) Anything
Constructs an
Anything
from anAny
by weakly referencing the data referenced in theAny
-
func Anything(data ptr, type *AnyType, ownership Ownership, __defer__ func(ptr) void) Anything
Constructs an
Anything
from individual fields
-
func set(this *Anything, object *$T, ownership Ownership) void
Sets an
Anything
to an object. If the suppliedownership
isOwnership::OWN
orOwnership::GIVEN
, then theAnything
will gain ownership of the heap-allocated memory pointed to byobject
and responsibility for__defer__
. Otherwise, theAnything
will weakly reference the data pointed to byobject
. -
func set(this *Anything, data ptr, type *AnyType, ownership Ownership, defer_func func(ptr) void) void
Sets an
Anything
to an object. If the suppliedownership
isOwnership::OWN
orOwnership::GIVEN
, then theAnything
will gain ownership of the heap-allocated memory pointed to byobject
and responsibility for__defer__
. Otherwise, theAnything
will weakly reference the data pointed to byobject
. The__defer__
method must be manually specified asdefer_func
and may be null. -
func commit(this *Anything) Anything
Changes the ownership of an
Anything
to beOwnership::REFERENCE
. If theAnything
previously had ownership, then anAnything
value will be returned withOwnership::GIVEN
, otherwise the originalAnything
will be returned. This method is used for transferring ownership of internal data ofAnything
values to otherAnything
values. -
func donate(this *Anything) Anything
If the
Anything
has ownership, then the subject's ownership will be changed toOwnership::DONOR
and anAnything
value will be returned withOwnership::GIVEN
, otherwise the originalAnything
will be returned. This method is used for transferring ownership of internal data ofAnything
values to otherAnything
values. If ownership was transferred, then the subject value will be completely invalidated and will be unable to be used afterwards.
- This file requires runtime type information