LEOValue (Public)
IntroductionLEOValues are how variables and stack entries are implemented in the LEO runtime. They can have various types, and most types can be transparently converted into each other. A LEOValue is essentially a base class (with subclasses) implemented in straight C. Each LEOValue has an "isa" that points to the method table. This way, you can e.g. run the InitCopy method on any LEOValue without having to know which "subclass" you are dealing with. GroupsLEOValue methodsGroup members:
ConstructorsGroup members:
LEOValue storage measuringGroup members:Functions
LEOCanGetAsInteger#define LEOCanGetAsInteger(v,c) ParametersDiscussionReturns TRUE if the value can be converted to an integral number, FALSE otherwise. LEOCanGetAsNumber#define LEOCanGetAsNumber(v,c) ParametersDiscussionReturns TRUE if the value can be converted to a number, FALSE otherwise. LEOCleanUpValue#define LEOCleanUpValue(v,k,c) do { if( ((LEOValuePtr)(v)) && ((LEOValuePtr)(v))->base.isa ) ((LEOValuePtr)(v))->base.isa->CleanUp(((LEOValuePtr)(v)),(k),(c)); } while(0) Parameters
DiscussionDispose of any additional storage the value has allocated to hold its data. If there are references to this value, this will cause the references to fail with an error when next they try to access this value. LEODetermineChunkRangeOfSubstringParameters
DiscussionParses the given substring of a value for the given chunk, and then returns the absolute range of that chunk. See Also
LEOFollowReferencesAndReturnValueOfType#define LEOFollowReferencesAndReturnValueOfType(v,t,c) ParametersReturn ValueA LEOValuePtr pointing to the value matching the given type, or NULL if no value of that type is in the chain of references. DiscussionFollow all references in the given value, until a value of a specific type is found. LEOGetBooleanValueSize#define LEOGetBooleanValueSize() DiscussionReturns the size (in bytes) of storage you need to provide to LEOInitCopy for a new boolean value. LEOGetIntegerValueSize#define LEOGetIntegerValueSize() DiscussionReturns the size (in bytes) of storage you need to provide to LEOInitCopy for a new integer value. LEOGetKeyCount#define LEOGetKeyCount(v,c) ParametersReturn ValueA LEOValuePtr pointing to the actual value in the array. DiscussionReturns the number of key-value-pairs in this value. LEOGetNativeObjectValueSize#define LEOGetNativeObjectValueSize() DiscussionReturns the size (in bytes) of storage you need to provide to LEOInitCopy for a new native object value. LEOGetNumberValueSize#define LEOGetNumberValueSize() DiscussionReturns the size (in bytes) of storage you need to provide to LEOInitCopy for a new number value. LEOGetPointValueSize#define LEOGetPointValueSize() DiscussionReturns the size (in bytes) of storage you need to provide to LEOInitCopy for a new point value. LEOGetRangeValueSize#define LEOGetRangeValueSize() DiscussionReturns the size (in bytes) of storage you need to provide to LEOInitCopy for a new range value. LEOGetRectValueSize#define LEOGetRectValueSize() DiscussionReturns the size (in bytes) of storage you need to provide to LEOInitCopy for a new rectangle value. LEOGetReferenceValueSize#define LEOGetReferenceValueSize() DiscussionReturns the size (in bytes) of storage you need to provide to LEOInitCopy for a new reference value. LEOGetStringConstantValueSize#define LEOGetStringConstantValueSize() DiscussionReturns the size (in bytes) of storage you need to provide to LEOInitCopy for a new constant string value. LEOGetStringValueSize#define LEOGetStringValueSize() DiscussionReturns the size (in bytes) of storage you need to provide to LEOInitCopy for a new dynamically allocated string value. LEOGetValueAsBoolean#define LEOGetValueAsBoolean(v,c) ParametersDiscussionReturns the given value as a bool, converting it, if necessary. If conversion isn't possible, it will fail with an error message and stop execution in the current LEOContext. LEOGetValueAsInteger#define LEOGetValueAsInteger(v,ou,c) ParametersDiscussionReturns the given value as a LEOInteger, converting it, if necessary. If conversion isn't possible, it will fail with an error message and stop execution in the current LEOContext. LEOGetValueAsNumber#define LEOGetValueAsNumber(v,ou,c) ParametersDiscussionReturns the given value as a LEONumber, converting it, if necessary. If conversion isn't possible, it will fail with an error message and stop execution in the current LEOContext. LEOGetValueAsPoint#define LEOGetValueAsPoint(v,l,t,c) Parameters
DiscussionReturns the given value as a point, converting it, if necessary. If conversion isn't possible, it will fail with an error message and stop execution in the current LEOContext. LEOGetValueAsRangeParameters
DiscussionReturns the given value as a range, converting it, if necessary. If conversion isn't possible, it will fail with an error message and stop execution in the current LEOContext. LEOGetValueAsRangeOfStringParameters
DiscussionProvides a range of the string representation of the given value as a char*, converting it, if necessary. If conversion isn't possible, it will fail with an error message and stop execution in the current LEOContext. LEOGetValueAsRectParameters
DiscussionReturns the given value as a rectangle, converting it, if necessary. If conversion isn't possible, it will fail with an error message and stop execution in the current LEOContext. LEOGetValueAsString#define LEOGetValueAsString(v,s,l,c) ParametersReturn ValueEither s, or a pointer to an internal buffer, if the value has one that contains the entire requested value. DiscussionProvides the given value as a char*, converting it, if necessary. If conversion isn't possible, it will fail with an error message and stop execution in the current LEOContext. LEOGetValueForKeyParameters
Return ValueA LEOValuePtr pointing to the actual value in the array. If this is equal to t, you need to call LEOCleanUpValue on it. DiscussionFetches the value with the given key from the array in the specified value. Returns NULL if there is no value under that key yet. LEOGetValueForKeyOfRangeParameters
DiscussionFetches the value with the given key from the array in the specified value. Returns NULL if there is no value under that key yet. LEOGetValueIsUnset#define LEOGetValueIsUnset(v,c) ParametersDiscussionFind out if this value is or references the "unset" value (which to all other calls just shows up as an empty constant string). LEOGetValueSize#define LEOGetValueSize(v) ParametersDiscussionReturns the size (in bytes) of storage you need to provide to LEOInitCopy for this object. LEOGetVariantValueSize#define LEOGetVariantValueSize() DiscussionReturns the size (in bytes) of storage you need to provide to LEOInitCopy for a new variant value. Since variants can be converted between all types, this method applies to all kinds of variants. LEOInitArrayVariantValuevoid LEOInitArrayVariantValue( LEOValuePtr self, struct LEOArrayEntry *array, LEOKeepReferencesFlag keepReferences, struct LEOContext *inContext ); // Takes over ownership of the array. DiscussionInitialize the given storage so it's a valid array variant value containing the given array items. A variant is a value whose type changes depending on what type of data you put in it. So while this value is initially an array, if you call LEOSetValueAsString() on it, it will turn itself into a string variant value, or if you call LEOSetValueAsNumber() a number variant value. As such, assignments to variants can never fail due to a type mismatch, but retrieving a variant as a certain type still can. See Also LEOInitBooleanValuevoid LEOInitBooleanValue( LEOValuePtr inStorage, bool inBoolean, LEOKeepReferencesFlag keepReferences, struct LEOContext *inContext ); DiscussionInitialize the given storage so it's a valid boolean value containing the given boolean. See Also LEOInitBooleanVariantValuevoid LEOInitBooleanVariantValue( LEOValuePtr self, bool inBoolean, LEOKeepReferencesFlag keepReferences, struct LEOContext *inContext ); DiscussionInitialize the given storage so it's a valid boolean variant value containing the given boolean. A variant is a value whose type changes depending on what type of data you put in it. So while this value is initially a boolean, if you call LEOSetValueAsString() on it, it will turn itself into a string variant value, or if you call LEOSetValueAsNumber() a number variant value. As such, assignments to variants can never fail due to a type mismatch, but retrieving a variant as a certain type still can. See Also LEOInitCopy#define LEOInitCopy(v,d,k,c) Parameters
DiscussionInitializes the given storage to be an exact copy of the given value. If the value is a reference, you will get a second reference to the original value, not a copy of the original value, and not a reference to the reference. See Also
LEOInitIntegerValuevoid LEOInitIntegerValue( LEOValuePtr inStorage, LEOInteger inNumber, LEOUnit inUnit, LEOKeepReferencesFlag keepReferences, struct LEOContext *inContext ); DiscussionInitialize the given storage so it's a valid number value containing the given number. See Also
LEOInitIntegerVariantValuevoid LEOInitIntegerVariantValue( LEOValuePtr self, LEOInteger inNumber, LEOUnit inUnit, LEOKeepReferencesFlag keepReferences, struct LEOContext *inContext ); DiscussionInitialize the given storage so it's a valid number variant value containing the given number. A variant is a value whose type changes depending on what type of data you put in it. So while this value is initially a number, if you call LEOSetValueAsString() on it, it will turn itself into a string variant value, or if you call LEOSetValueAsBoolean() a boolean variant value. As such, assignments to variants can never fail due to a type mismatch, but retrieving a variant as a certain type still can. See Also LEOInitNativeObjectValuevoid LEOInitNativeObjectValue( LEOValuePtr inStorage, void *inNativeObject, LEOKeepReferencesFlag keepReferences, struct LEOContext *inContext ); DiscussionInitialize the given storage so it's a valid native object value containing the given pointer. Native objects are essentially just opaque 'things' that the scripter hands to native functions. A wrapper to a pointer that you can't answer and can't put into a field or property. You can store it in variants (like local variables or globals), though. See Also LEOInitNativeObjectVariantValuevoid LEOInitNativeObjectVariantValue( LEOValuePtr self, void *inNativeObject, LEOKeepReferencesFlag keepReferences, struct LEOContext *inContext ); DiscussionInitialize the given storage so it's a valid native object variant value containing the given pointer. A variant is a value whose type changes depending on what type of data you put in it. So while this value is initially a boolean, if you call LEOSetValueAsString() on it, it will turn itself into a string variant value, or if you call LEOSetValueAsNumber() a number variant value. As such, assignments to variants can never fail due to a type mismatch, but retrieving a variant as a certain type still can. See Also LEOInitNumberValuevoid LEOInitNumberValue( LEOValuePtr inStorage, LEONumber inNumber, LEOUnit inUnit, LEOKeepReferencesFlag keepReferences, struct LEOContext *inContext ); DiscussionInitialize the given storage so it's a valid number value containing the given number. See Also
LEOInitNumberVariantValuevoid LEOInitNumberVariantValue( LEOValuePtr self, LEONumber inNumber, LEOUnit inUnit, LEOKeepReferencesFlag keepReferences, struct LEOContext *inContext ); DiscussionInitialize the given storage so it's a valid number variant value containing the given number. A variant is a value whose type changes depending on what type of data you put in it. So while this value is initially a number, if you call LEOSetValueAsString() on it, it will turn itself into a string variant value, or if you call LEOSetValueAsBoolean() a boolean variant value. As such, assignments to variants can never fail due to a type mismatch, but retrieving a variant as a certain type still can. See Also LEOInitPointValuevoid LEOInitPointValue( LEOValuePtr inStorage, LEOInteger l, LEOInteger t, LEOKeepReferencesFlag keepReferences, struct LEOContext *inContext ); DiscussionInitialize the given storage so it's a valid point value containing the given four coordinates. See Also LEOInitPointVariantValuevoid LEOInitPointVariantValue( LEOValuePtr inStorage, LEOInteger l, LEOInteger t, LEOKeepReferencesFlag keepReferences, struct LEOContext *inContext ); DiscussionInitialize the given storage so it's a valid point value containing the given four coordinates. A variant is a value whose type changes depending on what type of data you put in it. So while this value is initially a rect, if you call LEOSetValueAsString() on it, it will turn itself into a string variant value, or if you call LEOSetValueAsNumber() a number variant value. As such, assignments to variants can never fail due to a type mismatch, but retrieving a variant as a certain type still can. See Also LEOInitRangeValuevoid LEOInitRangeValue( LEOValuePtr inStorage, LEOInteger s, LEOInteger e, LEOChunkType t, LEOKeepReferencesFlag keepReferences, struct LEOContext *inContext ); DiscussionInitialize the given storage so it's a valid range value containing the given range in the given unit. See Also LEOInitRangeVariantValuevoid LEOInitRangeVariantValue( LEOValuePtr inStorage, LEOInteger s, LEOInteger e, LEOChunkType t, LEOKeepReferencesFlag keepReferences, struct LEOContext *inContext ); DiscussionInitialize the given storage so it's a valid range value containing the given range in the given unit. A variant is a value whose type changes depending on what type of data you put in it. So while this value is initially a range, if you call LEOSetValueAsString() on it, it will turn itself into a string variant value, or if you call LEOSetValueAsNumber() a number variant value. As such, assignments to variants can never fail due to a type mismatch, but retrieving a variant as a certain type still can. See Also LEOInitRectValuevoid LEOInitRectValue( LEOValuePtr inStorage, LEOInteger l, LEOInteger t, LEOInteger r, LEOInteger b, LEOKeepReferencesFlag keepReferences, struct LEOContext *inContext ); DiscussionInitialize the given storage so it's a valid rectangle value containing the given four coordinates. See Also LEOInitRectVariantValuevoid LEOInitRectVariantValue( LEOValuePtr inStorage, LEOInteger l, LEOInteger t, LEOInteger r, LEOInteger b, LEOKeepReferencesFlag keepReferences, struct LEOContext *inContext ); DiscussionInitialize the given storage so it's a valid rectangle value containing the given four coordinates. A variant is a value whose type changes depending on what type of data you put in it. So while this value is initially a rect, if you call LEOSetValueAsString() on it, it will turn itself into a string variant value, or if you call LEOSetValueAsNumber() a number variant value. As such, assignments to variants can never fail due to a type mismatch, but retrieving a variant as a certain type still can. See Also LEOInitReferenceValuevoid LEOInitReferenceValue( LEOValuePtr self, LEOValuePtr dest, LEOKeepReferencesFlag keepReferences, LEOChunkType inType, size_t startOffs, size_t endOffs, struct LEOContext *inContext ); DiscussionInitialize the given storage so it's a valid reference value that points to the given original value. If the original value is destructed while a reference still points to it, method calls to such a reference will fail with an error message and abort execution of the current LEOContext. However, the destructor of the value is safe to call, as is InitCopy. Pass kLEOChunkTypeINVALID if you want to reference the whole value and not only a chunk of it. See Also LEOInitReferenceValueWithIDsvoid LEOInitReferenceValueWithIDs( LEOValuePtr self, LEOObjectID referencedObjectID, LEOObjectSeed referencedObjectSeed, LEOKeepReferencesFlag keepReferences, struct LEOContext *inContext ); DiscussionInitialize the given storage so it's a valid reference value that points to an original value referenced by object ID and seed. If the original value is destructed while a reference still points to it, method calls to such a reference will fail with an error message and abort execution of the current LEOContext. However, the destructor of the value is safe to call, as is InitCopy. Pass kLEOChunkTypeINVALID if you want to reference the whole value and not only a chunk of it. See Also LEOInitStringConstantValuevoid LEOInitStringConstantValue( LEOValuePtr inStorage, const char *inString, LEOKeepReferencesFlag keepReferences, struct LEOContext *inContext ); DiscussionInitialize the given storage so it's a valid string constant value directly referencing the given string. The caller is responsible for ensuring that the string is not disposed of while the value still needs it. See Also LEOInitStringValuevoid LEOInitStringValue( LEOValuePtr inStorage, const char *inString, size_t inLen, LEOKeepReferencesFlag keepReferences, struct LEOContext *inContext ); DiscussionInitialize the given storage so it's a valid string value containing a copy of the given string. See Also LEOInitStringVariantValuevoid LEOInitStringVariantValue( LEOValuePtr self, const char *inString, LEOKeepReferencesFlag keepReferences, struct LEOContext *inContext ); DiscussionInitialize the given storage so it's a valid string variant value containing the given C-string. A variant is a value whose type changes depending on what type of data you put in it. So while this value is initially a string, if you call LEOSetValueAsNumber() on it, it will turn itself into a number variant value, or if you call LEOSetValueAsBoolean() a boolean variant value. As such, assignments to variants can never fail due to a type mismatch, but retrieving a variant as a certain type still can. See Also LEOInitUnsetValuevoid LEOInitUnsetValue( LEOValuePtr inStorage, LEOKeepReferencesFlag keepReferences, struct LEOContext *inContext ); DiscussionInitialize the given storage so it's a valid "unset" value. An unset value looks just like an empty string (a constant string, in fact), but can be distinguished using the LEOGetValueIsUnset() call. It is used e.g. for initializing the empty result of a handler so you can distinguish whether someone actually returned something or not. See Also LEOPutValueIntoValue#define LEOPutValueIntoValue(v,d,c) Parameters
DiscussionCopy the contents of a value to another value, preserving the native type, if possible. LEOSetValueAsArray#define LEOSetValueAsArray(v,a,c) ParametersDiscussionReplace the value of a variant or array with the given array value. LEOSetValueAsBoolean#define LEOSetValueAsBoolean(v,n,c) ParametersDiscussionAssigns the given boolean to the value, converting it, if necessary. If conversion isn't possible, it will fail with an error message and stop execution in the current LEOContext. LEOSetValueAsCString#define LEOSetValueAsCString(v,s,c) LEOSetValueAsString(v,s,strlen(s),c) DiscussionLike LEOSetValueAsString, but takes a zero-terminated C string instead of buffer and length byte. See Also
LEOSetValueAsInteger#define LEOSetValueAsInteger(v,n,u,c) ParametersDiscussionAssigns the given number to the value, converting it, if necessary. If conversion isn't possible, it will fail with an error message and stop execution in the current LEOContext. LEOSetValueAsNativeObject#define LEOSetValueAsNativeObject(v,o,c) ParametersDiscussionReplace the value of a variant or native object with the given native object value. LEOSetValueAsNumber#define LEOSetValueAsNumber(v,n,u,c) ParametersDiscussionAssigns the given number to the value, converting it, if necessary. If conversion isn't possible, it will fail with an error message and stop execution in the current LEOContext. LEOSetValueAsPoint#define LEOSetValueAsPoint(v,l,t,c) ParametersDiscussionReplace the value of another value with the given point. LEOSetValueAsRangeParametersDiscussionReplace the value of another value with the given rectangle. LEOSetValueAsRectParameters
DiscussionReplace the value of another value with the given rectangle. LEOSetValueAsString#define LEOSetValueAsString(v,s,l,c) ParametersDiscussionAssigns the given string to the value, converting it, if necessary. If conversion isn't possible, it will fail with an error message and stop execution in the current LEOContext. See Also
LEOSetValueForKey#define LEOSetValueForKey(v,ak,s,c) ParametersDiscussionStores a value under the given key in the array in the specified value. LEOSetValueForKeyOfRangeParametersDiscussionStores a value under the given key in the array in the specified value. LEOSetValuePredeterminedRangeAsStringParameters
DiscussionAssigns the given string to the specified range of the given value, converting it, if necessary. If conversion isn't possible, it will fail with an error message and stop execution in the current LEOContext. See Also
LEOSetValueRangeAsStringParameters
DiscussionAssigns the given string to the specified range of the given value, converting it, if necessary. If conversion isn't possible, it will fail with an error message and stop execution in the current LEOContext. TypedefsLEOIntegertypedef long long LEOInteger; DiscussionThe type of integers in the language. This is guaranteed to be signed, but large enough to hold a pointer. LEONumbertypedef float LEONumber; DiscussionThe type of fractional numbers in the language. LEOObjectIDtypedef unsigned long LEOObjectID; DiscussionObject IDs are indexes used internally by reference values to look up the referenced value in a way that's safe even after the original has been disposed of. LEOObjectSeedtypedef unsigned long LEOObjectSeed; DiscussionAn Object Seed is a value used internally to allow reference values to detect whether the slot in which their value used to be has already been reused. LEOUnittypedef uint8_t LEOUnit; DiscussionA unit attached to a numerical value. LEOUnitGrouptypedef uint8_t LEOUnitGroup; DiscussionA group of units. We can convert between numbers of the same group, but not between members of different groups. LEOValuePtrtypedef union LEOValue * LEOValuePtr; DiscussionA LEOValuePtr is a generic pointer to a LEOValue or one of its subclasses. LEOValueTypePtrtypedef struct LEOValueType * LEOValueTypePtr; DiscussionA LEOValueTypePtr is a pointer to a method look-up table for an object used internally. Structs and Unions
LEOValueunion LEOValue { struct LEOValueBase base; struct LEOValueNumber number; struct LEOValueInteger integer; struct LEOValueString string; struct LEOValueBoolean boolean; struct LEOValueReference reference; struct LEOValueArray array; struct LEOValueObject object; struct LEOValueRect rect; struct LEOValuePoint point; struct LEOValueRange range; }; DiscussionWe build the stack out of entries of this union, so we can just add 1 to the stack pointer to add another value to the stack, and so we don't have to check the size of each item before initializing. It's probably a good idea to keep all the value structs small, so the stack doesn't grow too large. LEOValueArraystruct LEOValueArray { struct LEOValueBase base; struct LEOArrayEntry *array; }; FieldsDiscussionArrays in our language are associative arrays, so they're not necessarily continuously numbered, but rather contain items associated with a string. LEOValueBasestruct LEOValueBase { LEOValueTypePtr isa; LEOObjectID refObjectID; }; FieldsDiscussionIVar layout common to all LEOValueBase subclasses: Each type of subclass should begin with this struct: That way it can be typecasted to the more generic type and methods can be called on it. LEOValueBooleanstruct LEOValueBoolean { struct LEOValueBase base; bool boolean; }; FieldsDiscussionThis is a boolean. In our language, booleans and integers are distinct types, but the (case-insensitive) strings "true" and "false" are valid booleans as well. LEOValueIntegerstruct LEOValueInteger { struct LEOValueBase base; LEOInteger integer; LEOUnit unit; }; FieldsDiscussionA number that doesn't have fractional parts: LEOValueNumberstruct LEOValueNumber { struct LEOValueBase base; LEONumber number; LEOUnit unit; }; FieldsDiscussionA number, which may have a fractional part: LEOValueObjectstruct LEOValueObject { struct LEOValueBase base; void *object; }; DiscussionA generic wrapper around foreign objects. The host may provide its own LEOValueType for an individual instance, so don't make any assumptions. This is mainly here so foreign objects can pass through LEO scripts and be stored on the stack unharmed. LEOValuePointstruct LEOValuePoint { struct LEOValueBase base; LEOInteger horizontal; LEOInteger vertical; }; FieldsDiscussionThis is a point. In our language, points are dictionaries that contain the keys left, top, right and bottom. In HyperCard compatibility mode, they are a comma-separated list of numbers, in the order l,t,r,b. LEOValueRangestruct LEOValueRange { struct LEOValueBase base; LEOInteger start; LEOInteger end; LEOChunkType type; }; FieldsDiscussionThis is a range. In our language, ranges are conceptually chunk expressions stored in a variable as a string. That is, they start with a type (character, line etc.) then the start offset (1-based), then the word "to", then the end offset (1-based). If a range's start and end are equal, the "to" portion may be omitted. Note that values of *type* range are distinct from reference values that reference a chunk of another value's string representation. LEOValueRectstruct LEOValueRect { struct LEOValueBase base; LEOInteger left; LEOInteger top; LEOInteger right; LEOInteger bottom; }; Fields
DiscussionThis is a rectangle. In our language, rectangles are dictionaries that contain the keys left, top, right and bottom. In HyperCard compatibility mode, they are a comma-separated list of numbers, in the order l,t,r,b. LEOValueReferencestruct LEOValueReference { struct LEOValueBase base; LEOObjectID objectID; LEOObjectSeed objectSeed; LEOChunkType chunkType; size_t chunkStart; size_t chunkEnd; }; Fields
DiscussionEssentially our castrated version of a pointer, without pointer arithmetics or other type-unsafeties you wouldn't like to have in our language. A reference can detect whether the value it points to is still valid (or has been disposed) and can gracefully exit in that case, instead of crashing the application. LEOValueStringstruct LEOValueString { struct LEOValueBase base; char *string; size_t stringLen; }; FieldsDiscussionThis is used both for strings we dynamically allocated, and for ones referencing C string constants built into the program: It can happen that such a string value gets turned from constant into an dynamic one or back. LEOValueTypestruct LEOValueType { const char *displayTypeName; size_t size; LEONumber (*GetAsNumber)( LEOValuePtr self, LEOUnit *outUnit, struct LEOContext* inContext ); LEOInteger (*GetAsInteger)( LEOValuePtr self, LEOUnit *outUnit, struct LEOContext* inContext ); const char *(*GetAsString)( LEOValuePtr self, char* outBuf, size_t bufSize, struct LEOContext* inContext ); // Either returns buf, or an internal pointer holding the entire string. bool (*GetAsBoolean)( LEOValuePtr self, struct LEOContext* inContext ); void (*GetAsRangeOfString)( LEOValuePtr self, LEOChunkType inType, size_t inRangeStart, size_t inRangeEnd, char* outBuf, size_t bufSize, struct LEOContext* inContext ); void (*SetAsNumber)( LEOValuePtr self, LEONumber inNumber, LEOUnit inUnit, struct LEOContext* inContext ); void (*SetAsInteger)( LEOValuePtr self, LEOInteger inNumber, LEOUnit inUnit, struct LEOContext* inContext ); void (*SetAsString)( LEOValuePtr self, const char* inBuf, size_t bufLen, struct LEOContext* inContext ); void (*SetAsBoolean)( LEOValuePtr self, bool inBoolean, struct LEOContext* inContext ); void (*SetRangeAsString)( LEOValuePtr self, LEOChunkType inType, size_t inRangeStart, size_t inRangeEnd, const char* inBuf, struct LEOContext* inContext ); void (*SetPredeterminedRangeAsString)( LEOValuePtr self, size_t inRangeStart, size_t inRangeEnd, const char* inBuf, struct LEOContext* inContext ); void (*InitCopy)( LEOValuePtr self, LEOValuePtr dest, LEOKeepReferencesFlag keepReferences, struct LEOContext* inContext ); void (*InitSimpleCopy)( LEOValuePtr self, LEOValuePtr dest, LEOKeepReferencesFlag keepReferences, struct LEOContext* inContext ); void (*PutValueIntoValue)( LEOValuePtr self, LEOValuePtr dest, struct LEOContext* inContext ); LEOValuePtr (*FollowReferencesAndReturnValueOfType)( LEOValuePtr self, LEOValueTypePtr inType, struct LEOContext* inContext ); // Returns NULL if no direct reference. void (*DetermineChunkRangeOfSubstring)( LEOValuePtr self, size_t *ioBytesStart, size_t *ioBytesEnd, size_t *ioBytesDelStart, size_t *ioBytesDelEnd, LEOChunkType inType, size_t inRangeStart, size_t inRangeEnd, struct LEOContext* inContext ); void (*CleanUp)( LEOValuePtr self, LEOKeepReferencesFlag keepReferences, struct LEOContext* inContext ); bool (*CanGetAsNumber)( LEOValuePtr self, struct LEOContext* inContext ); LEOValuePtr (*GetValueForKey)( LEOValuePtr self, const char* keyName, union LEOValue* tempStorage, LEOKeepReferencesFlag keepReferences, struct LEOContext* inContext ); void (*SetValueForKey)( LEOValuePtr self, const char* keyName, LEOValuePtr inValue, struct LEOContext* inContext ); void (*SetValueAsArray)( LEOValuePtr self, struct LEOArrayEntry* inArray, struct LEOContext* inContext ); size_t (*GetKeyCount)( LEOValuePtr self, struct LEOContext* inContext ); void (*GetValueForKeyOfRange)( LEOValuePtr self, const char* keyName, size_t startOffset, size_t endOffset, LEOValuePtr outValue, struct LEOContext* inContext ); void (*SetValueForKeyOfRange)( LEOValuePtr self, const char* keyName, LEOValuePtr inValue, size_t startOffset, size_t endOffset, struct LEOContext* inContext ); void (*SetValueAsNativeObject)( LEOValuePtr self, void* inNativeObject, struct LEOContext* inContext ); void (*SetValueAsRect)( LEOValuePtr self, LEOInteger l, LEOInteger t, LEOInteger r, LEOInteger b, struct LEOContext* inContext ); void (*GetValueAsRect)( LEOValuePtr self, LEOInteger *l, LEOInteger *t, LEOInteger *r, LEOInteger *b, struct LEOContext* inContext ); void (*SetValueAsPoint)( LEOValuePtr self, LEOInteger l, LEOInteger t, struct LEOContext* inContext ); void (*GetValueAsPoint)( LEOValuePtr self, LEOInteger *l, LEOInteger *t, struct LEOContext* inContext ); bool (*GetValueIsUnset)( LEOValuePtr self, struct LEOContext* inContext ); void (*SetValueAsRange)( LEOValuePtr self, LEOInteger s, LEOInteger e, LEOChunkType t, struct LEOContext* inContext ); void (*GetValueAsRange)( LEOValuePtr self, LEOInteger *s, LEOInteger *e, LEOChunkType *t, struct LEOContext* inContext ); bool (*CanGetAsInteger)( LEOValuePtr self, struct LEOContext* inContext ); }; FieldsCallbacks
DiscussionLayout of the virtual function tables for all the LEOValue subclasses: Also doubles as the 'class name'. Enumerated TypeseLEOKeepReferencesFlagConstants
DiscussionFlag that decides whether to clear references to this object or keep them. This is used e.g. by variants when re-creating a value as a different type to make sure that any references to it remain valid, or for returning a result. OTOH, you generally want to invalidate references when e.g. creating a stack slot to make sure that references from previous iterations notice that while the address is identical, the old value is gone. Macro DefinitionskLEOObjectIDINVALID#define kLEOObjectIDINVALID 0 DiscussionIf an object ID is invalid, it is set to this value. |