Class TCasScriptMatrix3d

Unit

Declaration

type TCasScriptMatrix3d = class(specialize TCasScriptMatrix<TCasScriptVec3d,TMatrix3Double,TVector3Double>)

Description

This item has no description.

Source: castlescript/castlescriptvectors.pas (line 174).

Hierarchy

Show Additional Members:

Overview

Methods

Protected function CoreExecute: TCasScriptValue; virtual; abstract;
Public function Execute: TCasScriptValue;
Public function TryExecuteMath: TCasScriptValue;
Public function AsFloat(const ADefaultValue: Float = 0): Float;
Public function AsInt(const ADefaultValue: Int64 = 0): Int64;
Public function AsString(const ADefaultValue: String = ''): string;
Public function AsBool(const ADefaultValue: boolean = false): boolean;
Public procedure FreeByParentExpression;
Protected function CoreExecute: TCasScriptValue; override;
Public constructor Create(const AWriteable: boolean); virtual;
Public procedure AssignValue(Source: TCasScriptValue); virtual; abstract;
Public procedure AssignValue(Source: TCasScriptValue); override;

Properties

Public property Environment: TCasScriptEnvironment read FEnvironment write FEnvironment;
Public property Writeable: boolean read FWriteable write FWriteable;
Public property OwnedByParentExpression: boolean read FOwnedByParentExpression write FOwnedByParentExpression default true;
Public property Name: string read FName write FName;
Public property ValueAssigned: boolean read FValueAssigned write FValueAssigned default false;
Public property Value: TMatrixXxx read FValue write SetValue;

Description

Methods

Protected function CoreExecute: TCasScriptValue; virtual; abstract;

More internal version of Execute.

This doesn't necessarily check floating-point exceptions. Execute actually calls CoreExecute and then ClearExceptions.

Also this doesn't try to convert EIntError and EMathError to ECasScriptAnyMathError. This is done by Execute.

When one CastleScript CoreExecute calls another function, it can use CoreExecute instead of Execute. This way only one ClearExceptions will be needed for whole expression execution, instead of doing ClearExceptions after each function handler.

Source: castlescript/castlescript.pas (line 114).

Public function Execute: TCasScriptValue;

Execute and calculate this expression.

Returned value is owned by this object. Which should be comfortable for you usually, as you do not have to worry about freeing it. Also, it allows us to make various optimizations to avoid creating/destroying lots of temporary TCasScriptExpression instances during calculation of complex expression.

The disadvantage of this is that returned object value is valid only until you executed this same expression again, or until you freed this expression. If you need to remember the execute result for longer, you have to copy it somewhere. For example you can do

{ This will always work, thanks to virtual TCasScriptValue.Create
  and AssignValue methods. }
Copy := TCasScriptValue(ReturnedValue.ClassType).Create;
Copy.AssignValue(ReturnedValue);

Exceptions raised
ECasScriptError

Execute is guaranteed to raise an ECasScriptError exception if some calculation fails because of invalid arguments.

This means that when you run CastleScript expression provided by the user, you only have to catch ECasScriptError to be safe from errors produced by user. No need to catch something more general like Exception class.

Also it's guaranteed that no hanging floating-point errors are left. Normally, there is no guarantee that floating-point errors are raised immediately, they may be raised at the next fp operation (this is needed for fp operations to proceed in parallel, and be much faster). For executing CastleScript, Execute calls Math.ClearExceptions(true) to make sure that all floating point errors are caught. This ensures that we can safely execute even invalid expressions (like 'ln(-3)') and get reliable exceptions.

Floating-point errors of course also result in ECasScriptError descendants. More specifically, EIntError and EMathError result in ECasScriptAnyMathError.

Source: castlescript/castlescript.pas (line 161).

Public function TryExecuteMath: TCasScriptValue;

Try to execute expression, or return Nil if a mathematical error occurred within expression. "Math error within expression" means that a ECasScriptAnyMathError exception occurred while calculating expression.

This is useful to secure you against math arguments errors ('ln(-3)', 'sqrt(-3)') but still raises normal exception on other ECasScriptError errors (like invalid argument type for function).

Source: castlescript/castlescript.pas (line 170).

Public function AsFloat(const ADefaultValue: Float = 0): Float;

Execute expression, return the result as a simple float value. It assumes that the expression is written to always return float. To easily create such expression, use ParseFloatExpression.

Source: castlescript/castlescript.pas (line 175).

Public function AsInt(const ADefaultValue: Int64 = 0): Int64;

Execute expression, return the result as a simple integer value. It assumes that the expression is written to always return integer. To easily create such expression, use ParseIntExpression.

Source: castlescript/castlescript.pas (line 180).

Public function AsString(const ADefaultValue: String = ''): string;

Execute expression, return the result as a simple string value. It assumes that the expression is written to always return string. To easily create such expression, use ParseStringExpression.

Source: castlescript/castlescript.pas (line 185).

Public function AsBool(const ADefaultValue: boolean = false): boolean;

Execute expression, return the result as a simple boolean value. It assumes that the expression is written to always return boolean. To easily create such expression, use ParseBoolExpression.

Source: castlescript/castlescript.pas (line 190).

Public procedure FreeByParentExpression;

Call Free, but only if this is not TCasScriptValue with OwnedByParentExpression = false. (This cannot be implemented cleanly, as virtual procedure, since it must work when Self is Nil, and then virtual method table is not available of course.)

Source: castlescript/castlescript.pas (line 196).

Protected function CoreExecute: TCasScriptValue; override;

This item has no description. Showing description inherited from TCasScriptExpression.CoreExecute.

More internal version of Execute.

This doesn't necessarily check floating-point exceptions. Execute actually calls CoreExecute and then ClearExceptions.

Also this doesn't try to convert EIntError and EMathError to ECasScriptAnyMathError. This is done by Execute.

When one CastleScript CoreExecute calls another function, it can use CoreExecute instead of Execute. This way only one ClearExceptions will be needed for whole expression execution, instead of doing ClearExceptions after each function handler.

Source: castlescript/castlescript.pas (line 218).

Public constructor Create(const AWriteable: boolean); virtual;

This item has no description.

Source: castlescript/castlescript.pas (line 224).

Public procedure AssignValue(Source: TCasScriptValue); virtual; abstract;

Assign value from Source to Self.

Exceptions raised
ECasScriptAssignError
if assignment is not possible because types don't match.

Source: castlescript/castlescript.pas (line 244).

Public procedure AssignValue(Source: TCasScriptValue); override;

This item has no description. Showing description inherited from TCasScriptValue.AssignValue.

Assign value from Source to Self.

Source: castlescript/castlescriptvectors.pas (line 159).

Properties

Public property Environment: TCasScriptEnvironment read FEnvironment write FEnvironment;

Environment (outside information) for this expression. May be Nil. This object is not owned by TCasScriptExpression, will not be freed by TCasScriptExpression and such.

Source: castlescript/castlescript.pas (line 201).

Public property Writeable: boolean read FWriteable write FWriteable;

Is this value writeable. If not, this will not be allowed to change by CastleScript assignment and such functions. Note that Writeable = False will not prevent you from changing value internally, by AssignValue or changin Value property directly (that would be too uncomfortable).

Source: castlescript/castlescript.pas (line 231).

Public property OwnedByParentExpression: boolean read FOwnedByParentExpression write FOwnedByParentExpression default true;

This item has no description.

Source: castlescript/castlescript.pas (line 233).

Public property Name: string read FName write FName;

Name of this value, or '' if not named. Named value can be recognized in expressions by CastleScriptParser.

Source: castlescript/castlescript.pas (line 239).

Public property ValueAssigned: boolean read FValueAssigned write FValueAssigned default false;

Set to True on each assign to Value. You can reset it at any time to False.

This allows the caller to know which variables were assigned during script execution, which is useful if changes to CastleScript variables should be propagated to some other things after the script finished execution. This is essential for behavior in VRML/X3D Script node.

Descendants note: you have to set this to True in SetValue.

Source: castlescript/castlescript.pas (line 256).

Public property Value: TMatrixXxx read FValue write SetValue;

This item has no description.

Source: castlescript/castlescriptvectors.pas (line 157).


Generated by PasDoc 0.17.0.snapshot.