FPC Cleanroom

From Lazarus wiki
Revision as of 12:41, 9 March 2008 by Vincent (talk | contribs) (→‎TDataset.DataEvent: specification from Joost.)
Jump to navigationJump to search

In 2007 it was found that some functions could need a new implementation because they were too similar to the implementation from Delphi. FPC 2.2.2 will be the first release after the cleanroom implementation of those routines.

The core FPC developers already know the old implementation, so impartial contributiors not familiar with the old code or the Delphi code need to be found. The functions alse need to be tested and specifications for them written.

Volunteers to implement the functions

  • Vincent
  • Almindor

Volunteers to write specs and test apps

Downloading the cleanroom branch

One can download it using subversion with:

svn co http://svn.freepascal.org/svn/fpc/branches/cleanroom cleanroom

Or use viewcvs to view it:

[1]

Affected functions

The affected functions are marked with "tainted" on the branch.

TDataset.CalculateFields

location

cleanroom/packages/fpc-db/src/base/dataset.inc

declaration

Procedure TDataset.CalculateFields(Buffer: PChar);

Specifications

TDataset.DataEvent

location

cleanroom/packages/fpc-db/src/base/dataset.inc

declaration

Procedure TDataset.DataEvent(Event: TDataEvent; Info: Ptrint);

Specifications

Handles an event

When the event is equal to deFieldChange then the provided 'Info' parameter is a TField. If it's fieldkind is fkData or fkInternalCalc then SetModified is called to set Modified to 'true'.

If the event is deFieldChange and the state of the dataset is not dssetkey then there are first two checks: if FInternalCalcFields and info's FieldKind is equal to fkData, then RefreshInternalCalcfields is called with ActiveBuffer as parameter. Second check is that if the first check is not true but the info's fieldkind is equal to fkData, FAutoCalcFields is true and FCalcFieldsSize is not equal to 0, then CalculateFields is called for the ActiveBuffer. After those two checks, Info.Change is always called.

If the event is equal to deDatasetChange or deDatasetScroll and TDataset.State is not dsInsert then UpdateCursorPos is called.

Thereafter, if ControlsDisabled is false, the event is distributed to all datasources linked to this dataset by calling the datasource's ProcessEvent with 'Event' and 'Info' as parameters.

TDataset.EnableControls

location

cleanroom/packages/fpc-db/src/base/dataset.inc

declaration

Procedure TDataset.EnableControls;

Specifications

Reactivates the displaying of data on screen after a call to DisableControls.

EnableControls should decrement the disabled count on the dataset, up to a minimum of zero. If it's zero, it will tell the controls using the dataset they can show their values on screen.

TDataLink.CalcFirstRecord

location

cleanroom/packages/fpc-db/src/base/datasource.inc

declaration

Function TDataLink.CalcFirstRecord(Index : Integer) : Integer;

Specifications

TField.CalcLookupValue

location

cleanroom/packages/fpc-db/src/base/fields.inc

declaration

procedure TField.CalcLookupValue;

Specifications

TField.RefreshLookupList

location

cleanroom/packages/fpc-db/src/base/fields.inc

declaration

procedure TField.RefreshLookupList;

Specifications

RefreshLookupList should be called to reload the lookup cache. This is used, for example, when setting the LookupCache property at run-time, or after changing the properties LookupResultField, LookupKeyFields and LookupDataSet.

Related to

  • TField.LookupCache
  • TField.LookupDataSet
  • TField.LookupKeyFields
  • TField.LookupList
  • TField.LookupResultField