Class TFunctionClass

DescriptionHierarchyFieldsMethodsProperties

Unit

Declaration

type TFunctionClass = class(TObject)

Description

TFunctionClass defines a function that can be called by TRbwParser.

Hierarchy

Overview

Fields

Private FSynonyms: TStrings;
Private FunctionRecord: TFunctionRecord;
Private FPrototype: string;

Methods

Private function GetAllowConversionToConstant: boolean;
Private function GetBFunctionAddr: TrbwBooleanFunction;
Private function GetHidden: boolean;
Private function GetIFunctionAddr: TrbwIntegerFunction;
Private function GetInputDataCount: integer;
Private function GetInputDataTypes(const Index: integer): TRbwDataType;
Private function GetName: string;
Private function GetOptionalArguments: integer; inline;
Private function GetResultType: TRbwDataType;
Private function GetRFunctionAddr: TrbwRealFunction;
Private function GetSFunctionAddr: TrbwStringFunction;
Private procedure SetAllowConversionToConstant(const Value: boolean); inline;
Private procedure SetBFunctionAddr(const Value: TrbwBooleanFunction);
Private procedure SetHidden(const Value: boolean); inline;
Private procedure SetIFunctionAddr(const Value: TrbwIntegerFunction);
Private procedure SetInputDataCount(const Value: integer);
Private procedure SetInputDataTypes(const Index: integer; const Value: TRbwDataType);
Private procedure SetName(const Value: string);
Private procedure SetOptionalArguments(const Value: integer); inline;
Private procedure SetRFunctionAddr(const Value: TrbwRealFunction);
Private procedure SetSFunctionAddr(const Value: TrbwStringFunction);
Private procedure SetSynonyms(const Value: TStrings);
Private function GetOptionalType: TRbwDataType;
Private procedure SetOptionalType(const Value: TRbwDataType);
Public constructor Create;
Public destructor Destroy; override;

Properties

Public property AllowConversionToConstant: boolean read GetAllowConversionToConstant write SetAllowConversionToConstant;
Public property BFunctionAddr: TRbwBooleanFunction read GetBFunctionAddr write SetBFunctionAddr;
Public property IFunctionAddr: TRbwIntegerFunction read GetIFunctionAddr write SetIFunctionAddr;
Public property InputDataCount: integer read GetInputDataCount write SetInputDataCount;
Public property InputDataTypes[constIndex:integer]: TRbwDataType read GetInputDataTypes write SetInputDataTypes;
Public property OptionalType: TRbwDataType read GetOptionalType write SetOptionalType;
Public property Name: string read GetName write SetName;
Public property Prototype: string read FPrototype write FPrototype;
Public property OptionalArguments: integer read GetOptionalArguments write SetOptionalArguments;
Public property ResultType: TRbwDataType read GetResultType;
Public property RFunctionAddr: TRbwRealFunction read GetRFunctionAddr write SetRFunctionAddr;
Public property SFunctionAddr: TRbwStringFunction read GetSFunctionAddr write SetSFunctionAddr;
Public property Hidden: boolean read GetHidden write SetHidden;
Public property Synonyms: TStrings read FSynonyms write SetSynonyms;

Description

Fields

Private FSynonyms: TStrings;

FSynonyms: TStrings; See Synonyms.

Private FunctionRecord: TFunctionRecord;

FunctionRecord: TFunctionRecord; FunctionRecord stores the data represented by many of the public properties.

Private FPrototype: string;

FPrototype: string; See Prototype.

Methods

Private function GetAllowConversionToConstant: boolean;

See AllowConversionToConstant.

Private function GetBFunctionAddr: TrbwBooleanFunction;

Gets value of BFunctionAddr property

Private function GetHidden: boolean;

See Hidden.

Private function GetIFunctionAddr: TrbwIntegerFunction;

Gets value of IFunctionAddr property

Private function GetInputDataCount: integer;

See InputDataCount.

Private function GetInputDataTypes(const Index: integer): TRbwDataType;

See InputDataTypes.

Private function GetName: string;

See Name.

Private function GetOptionalArguments: integer; inline;

See OptionalArguments.

Private function GetResultType: TRbwDataType;

See ResultType.

Private function GetRFunctionAddr: TrbwRealFunction;

Gets value of RFunctionAddr property

Private function GetSFunctionAddr: TrbwStringFunction;

Gets value of SFunctionAddr property

Private procedure SetAllowConversionToConstant(const Value: boolean); inline;

See AllowConversionToConstant.

Private procedure SetBFunctionAddr(const Value: TrbwBooleanFunction);

Sets value of BFunctionAddr property

Private procedure SetHidden(const Value: boolean); inline;

See Hidden.

Private procedure SetIFunctionAddr(const Value: TrbwIntegerFunction);

Sets value of IFunctionAddr property

Private procedure SetInputDataCount(const Value: integer);

See InputDataCount.

Private procedure SetInputDataTypes(const Index: integer; const Value: TRbwDataType);

See InputDataTypes.

Private procedure SetName(const Value: string);

See Name.

Private procedure SetOptionalArguments(const Value: integer); inline;

See OptionalArguments.

Private procedure SetRFunctionAddr(const Value: TrbwRealFunction);

Sets value of RFunctionAddr property

Private procedure SetSFunctionAddr(const Value: TrbwStringFunction);

Sets value of SFunctionAddr property

Private procedure SetSynonyms(const Value: TStrings);

See Synonyms.

Private function GetOptionalType: TRbwDataType;
 
Private procedure SetOptionalType(const Value: TRbwDataType);
 
Public constructor Create;

Create calls the inherited Create and sets AllowConversionToConstant to true.

Users should generally not call Create directly but instead create a TFunctionClass by calling TFunctionStringList.Add.

Public destructor Destroy; override;

Destroy destroys the TFunctionClass. Do not call Destroy directly. Call Free instead.

Properties

Public property AllowConversionToConstant: boolean read GetAllowConversionToConstant write SetAllowConversionToConstant;

AllowConversionToConstant defines whether the result of a function may be considered a constant value if all of the values passed to the function in the values array are constants.

Normally AllowConversionToConstant should be set to True but if the function makes reference to global variables that may change between one evaluation of the expression and the next, AllowConversionToConstant should be set to False.

Pi is an example of a function for which AllowConversionToConstant should be true.

AllowConversionToConstant is used when optimizing compiled expressions.

Public property BFunctionAddr: TRbwBooleanFunction read GetBFunctionAddr write SetBFunctionAddr;

BFunctionAddr is the address of a TRbwBooleanFunction assigned to the TFunctionClass. If ResultType is of the wrong type, reading BFunctionAddr will raise an exception. Writing BFunctionAddr sets ResultType.

Public property IFunctionAddr: TRbwIntegerFunction read GetIFunctionAddr write SetIFunctionAddr;

IFunctionAddr is the address of a TRbwIntegerFunction assigned to the TFunctionClass. If ResultType is of the wrong type, reading IFunctionAddr will raise an exception. Writing IFunctionAddr sets ResultType.

Public property InputDataCount: integer read GetInputDataCount write SetInputDataCount;

InputDataCount normally defines the maximum number of arguments that can be passed into the function. However, if OptionalArguments is less than 0, an unlimited number of arguments can be passed to the function and the types of all those arguments must match the type of the last member of InputDataTypes. In that case, the minimum number of required arguments is InputDataCount minus 1.

Public property InputDataTypes[constIndex:integer]: TRbwDataType read GetInputDataTypes write SetInputDataTypes;

InputDataTypes is used to define the data types passed into or returned by a function. Data are passed into a function as pointers to variables of the correct type. Results of the functions are values of the correct type rather than pointers.

Public property OptionalType: TRbwDataType read GetOptionalType write SetOptionalType;
 
Public property Name: string read GetName write SetName;

Name defines the name of the function. The Name of each function and variable in a TRbwParser must be unique. seealso(Synonyms)

Public property Prototype: string read FPrototype write FPrototype;

Prototype gives suggestions as to how the names and arguments for a function could be shown on a GUI interface. The "|" character is used in the prototype to classify functions. Portions of the prototype that appear before a "|" character is the classification to which the rest of the prototype belongs. Thus, the portions before the "|" could be used to populate a tree control.

Public property OptionalArguments: integer read GetOptionalArguments write SetOptionalArguments;

If OptionalArguments is greater than 0, up to that number of nil pointers may be passed to the function when it is evaluated. All the nil pointers must follow all the non-nil pointers.

If OptionalArguments is less than 0, an unlimited number of arguments may be passed to the function. The data type of these pointers will correspond to the data type defined in the last member of InputDataTypes.

Public property ResultType: TRbwDataType read GetResultType;

ResultType is used to define the data type passed returned by a function. The results of the functions are values of the correct type rather than pointers.

Example:

Because OptionalArguments is less than 0, the CaseB, CaseI, CaseR, and CaseS functions can take an unlimited number of arguments.

      function _CaseBoolean(Values : array of pointer) : boolean;
      begin
        result := PBoolean(Values[PInteger(Values[0])ˆ])ˆ;
      end;

      function _CaseInteger(Values : array of pointer) : integer;
      begin
        result := PInteger(Values[PInteger(Values[0])ˆ])ˆ;
      end;

      function _CaseDouble(Values : array of pointer) : double;
      begin
        result := PDouble(Values[PInteger(Values[0])ˆ])ˆ;
      end;

      function _CaseString(Values : array of pointer) : String;
      begin
        result := PString(Values[PInteger(Values[0])ˆ])ˆ;
      end;

      var
        CaseBooleanFunction : TFunctionRecord;
        CaseIntegerFunction : TFunctionRecord;
        CaseDoubleFunction : TFunctionRecord;
        CaseStringFunction : TFunctionRecord;

      constructor TFunctionStringList.Create;
      begin
        inherited;
        CaseSensitive := False;
        Duplicates := dupError;
        Sorted := True;

        // ... others lines omitted in example.

        CaseBooleanFunction.ResultType := rdtBoolean;
        CaseBooleanFunction.Name := 'CaseB';
        SetLength(CaseBooleanFunction.InputDataTypes, 4);

        CaseBooleanFunction.InputDataTypes[0] := rdtInteger;
        CaseBooleanFunction.InputDataTypes[1] := rdtBoolean;
        CaseBooleanFunction.InputDataTypes[2] := rdtBoolean;
        CaseBooleanFunction.InputDataTypes[3] := rdtBoolean;
        CaseBooleanFunction.CanConvertToConstant := True;
        CaseBooleanFunction.OptionalArguments := -1;
        CaseBooleanFunction.BFunctionAddr := _CaseBoolean;
        Add(CaseBooleanFunction);

        CaseIntegerFunction.ResultType := rdtInteger;
        CaseIntegerFunction.Name := 'CaseI';
        SetLength(CaseIntegerFunction.InputDataTypes, 4);

        CaseIntegerFunction.InputDataTypes[0] := rdtInteger;
        CaseIntegerFunction.InputDataTypes[1] := rdtInteger;
        CaseIntegerFunction.InputDataTypes[2] := rdtInteger;
        CaseIntegerFunction.InputDataTypes[3] := rdtInteger;
        CaseIntegerFunction.OptionalArguments := -1;
        CaseIntegerFunction.CanConvertToConstant := True;
        CaseIntegerFunction.IFunctionAddr := _CaseInteger;
        Add(CaseIntegerFunction);

        CaseDoubleFunction.ResultType := rdtDouble;
        CaseDoubleFunction.Name := 'CaseR';
        SetLength(CaseDoubleFunction.InputDataTypes, 4);
        CaseDoubleFunction.InputDataTypes[0] := rdtInteger;
        CaseDoubleFunction.InputDataTypes[1] := rdtDouble;
        CaseDoubleFunction.InputDataTypes[2] := rdtDouble;
        CaseDoubleFunction.InputDataTypes[3] := rdtDouble;
        CaseDoubleFunction.OptionalArguments := -1;

        CaseDoubleFunction.CanConvertToConstant := True;
        CaseDoubleFunction.RFunctionAddr := _CaseDouble;
        Add(CaseDoubleFunction);

        CaseStringFunction.ResultType := rdtString;
        CaseStringFunction.Name := 'CaseS';
        SetLength(CaseStringFunction.InputDataTypes, 4);
        CaseStringFunction.InputDataTypes[0] := rdtInteger;
        CaseStringFunction.InputDataTypes[1] := rdtString;
        CaseStringFunction.InputDataTypes[2] := rdtString;
        CaseStringFunction.InputDataTypes[3] := rdtString;
        CaseStringFunction.OptionalArguments := -1;
        CaseStringFunction.CanConvertToConstant := True;
        CaseStringFunction.SFunctionAddr := _CaseString;
        Add(CaseStringFunction);
        // ... others lines omitted in example.
      end;

      

Public property RFunctionAddr: TRbwRealFunction read GetRFunctionAddr write SetRFunctionAddr;

RFunctionAddr is the address of a TRbwRealFunction assigned to the TFunctionClass. If ResultType is of the wrong type, reading RFunctionAddr will raise an exception. Writing RFunctionAddr sets ResultType.

Public property SFunctionAddr: TRbwStringFunction read GetSFunctionAddr write SetSFunctionAddr;

SFunctionAddr is the address of a TRbwStringFunction assigned to the TFunctionClass. If ResultType is of the wrong type, reading SFunctionAddr will raise an exception. Writing SFunctionAddr sets ResultType.

Public property Hidden: boolean read GetHidden write SetHidden;

Hidden has no effect. It is intended to be used to indicate whether or not the function specified by the TFunctionClass should be visible to the user.

Public property Synonyms: TStrings read FSynonyms write SetSynonyms;

Synonyms holds a list of alternative acceptable spellings for a function. No alternate name should be the same as the name of any other function or one of its alternate names. .

See also
Name
Name defines the name of the function.

Generated by PasDoc 0.12.1 on 2013-05-13 15:41:59