⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ubaseidents.pas

📁 DelphiDoc is a program for automatic generation of documentation on a Delphi-Project. At the momen
💻 PAS
📖 第 1 页 / 共 5 页
字号:
  end;












   { * * *  ***  * * *  ***   TIdentifierFileList   ***  * * *  ***  * * *  }


  //The saved items in the ~[link TIdentifierFileList].
  TIdentFileItem = record
    Ident: TIdentifier;          //the identifier
    TheFile: TPascalFile;        //the file, if it is not an identifier
  end;

  PIdentFileItem = ^TIdentFileItem;   //pointer to an entry


  {A type for compare-functions for the sorting method
   ~[link TIdentifierFileList.CustomSort]. There are several functions of this
   type defined in this unit.
  ~param E1, E2 the items to compare
  ~result the result of the comparison (like in CompareText) }
  TIdentFileItemCompareFunction = function(const E1,
                                                 E2: TIdentFileItem): Integer;



  {Serves as a list of identifiers and files. Besides the methods to insert,
   remove, test, count etc. them, the list can also be sorted by several
   different keys. The identifiers of the list are seen to be just listed in
   this list, this means by default all identifiers are not freed, when they
   are removed from the list or it is freed. }
  TIdentifierFileList = class
  private
    //the list of identifiers or files
    FList: TList;
  protected
  public
    //Creates the list.
    constructor Create;
    //Frees the list.
    destructor Destroy; override;

    //Adds the identifier.
    procedure AddIdent(Ident: TIdentifier);
    //Adds the file.
    procedure AddFile(TheFile: TPascalFile);
    //Adds the identifier or file.
    procedure AddIdentOrFile(Ident: TIdentifier; TheFile: TPascalFile);

    //Gets the identifier or the file.
    function GetIdentIndex(Index: Integer;
                           var TheFile: TPascalFile): TIdentifier;

    //Tests whether the identifier is in the list.
    function IsIn(Ident: TIdentifier): Boolean;
    //Tests whether the file is in the list.
    function IsFileIn(TheFile: TPascalFile): Boolean;

    //Returns the number of identifiers and files in the list.
    function Count: Integer;
    //Tests whether the list is empty.
    function IsEmpty: Boolean;




    //Sorts the list with/by the given compare function (fast!).
    procedure CustomSort(Compare: TIdentFileItemCompareFunction);

    //Sorts the list of identifiers and files alphabetically.
    procedure SortAllAlphabetically;
    //Sorts the list by the file alphabetically.
    procedure SortFileAlphabetically;

    //Removes the identifier from the list.
    procedure RemoveIdent(Ident: TIdentifier);
    //Removes all identifiers.
    procedure RemoveAll;
  end;




































   { * * *  ***  * * *  ***   TDefines   ***  * * *  ***  * * *  }


  {Defines the compiler options needed while parsing the pascal code,
   especially to handle conditional compiling commands/comments. }
  TDefines = class
  private
    //the compiler switches, set or not
    FOptions: TCompilerOptions;
    //the defined symbols
    FDefines: TStringList;
    //the unit-aliases (a list of: Alias=Unit)
    FUnitAliases: TStringList;
    //search path for files
    FSearchPath: TStringList;
    //list of additional constants for conditional compiling
    FConditionalCompilingConstants: TIdentifierList;
    //list of required packages as read from the .cfg/.conf file; transient
    FRequiredPackages: TStringList;

    //Sets the value of an option.
    procedure SetOption(c: Char; Value: Boolean);
  public
    //Creates the object for the options.
    constructor Create;
    //Frees the object for the options.
    destructor Destroy; override;


    //Copies the compiler options from one variable to another.
    procedure CopyOptions(UseDefines: TDefines);


    //Sets the compiler options based on the values of a variable of options to
    //set this options.
    procedure SetOptionsWithoutCFGFile(DefineOptions: TDefineOptions);
    //Parses the config-file of a project to get the compiler options etc..
    procedure SetOptionsWithCFGFile(DefineOptions: TDefineOptions;
                                    const CFGFileName: String);


    //Saves the compiler options to the stream.
    procedure SaveToStream(Stream: TIdentStream);
    //Loads the compiler options from the stream.
    procedure LoadFromStream(Stream: TIdentStream;
                             Version: TIdentClassVersion);


    //Checks if the unit name is an lias and returns the true name of the unit.
    function DealiasUnit(UnitName: String): String;


    property Options: TCompilerOptions read FOptions write FOptions;
    //can be used to set only one field in ~[link Options]
    property Option[c: Char]: Boolean write SetOption;
    property Defines: TStringList read FDefines;
    property UnitAliases: TStringList read FUnitAliases;
    property SearchPath: TStringList read FSearchPath;
    property ConditionalCompilingConstants: TIdentifierList
                                           read FConditionalCompilingConstants;
    property RequiredPackages: TStringList read FRequiredPackages;
  end;





   { * * *  ***  * * *  ***   TDefineOptions   ***  * * *  ***  * * *  }


  {Defines for a compiler switch, if it should be set or unset after it has
   been read from the config-file. }
  TPostOption = (
    poUnset,      //unset the compiler switch
    poSet,        //set the compiler switch
    poNothing);   //don't change the compiler switch

  {Defines for all compiler switches, if it should be set or unset after it has
   been read from the config-file. }
  TPostOptions = array['A'..'Z'] of TPostOption;



  {Defines the values needed to parse the compiler options from a .conf file
   needed to parse pascal code, especially to handle conditional compiling
   commands/comments. }
  TDefineOptions = class
  private
    //the options to set by default if the options are not defined by a
    //config-file
    FPreOptions: TCompilerOptions;
    //the pre-defined compiler symbols
    FPreDefines: TStringList;
    //pre-defined search paths for files (absolute short unique paths!)
    FPreSearchPath: TStringList;
    //if the config-file should be parsed;
    //the post-options and -defines will will be added even
    //when the config-file will not be parsed
    FAutoParse: Boolean;
    //if and how the switches should be changed after the parsing of the
    //config-file
    FPostOptions: TPostOptions;
    //compiler symbols to define after parsing the config-file
    FPostDefines: TStringList;
    //compiler symbols to undefine after parsing the config-file
    FPostUnDefines: TStringList;
    //additional search paths for files (absolute short unique paths!)
    FPostSearchPath: TStringList;
    //search pathes to ignore for files (absolute short unique paths!)
    FPostNoSearchPath: TStringList;
    //list of additional constants for conditional compiling
    FConditionalCompilingConstants: TIdentifierList;
    //list of unit aliases
    FPostUnitAliases: TStringList;


    //Returns all unit aliases as a string.
    function GetPostUnitAliasesAsString: String;
    //Sets the unit aliases from a string.
    procedure SetPostUnitAliasesAsString(Value: String);

  public
    //Creates the object for the options.
    constructor Create;
    //Frees the object for the options.
    destructor Destroy; override;


    //Resets all values to default.
    procedure ResetToDefault;

    //Copies the defined compiler options from one variable to another.
    procedure CopyOptions(UseDefines: TDefineOptions);




    property PreOptions: TCompilerOptions read FPreOptions write FPreOptions;
    property PreDefines: TStringList read FPreDefines;
    property PreSearchPath: TStringList read FPreSearchPath;
    property AutoParse: Boolean read FAutoParse write FAutoParse;
    property PostOptions: TPostOptions read FPostOptions write FPostOptions;
    property PostDefines: TStringList read FPostDefines;
    property PostUnDefines: TStringList read FPostUnDefines;
    property PostSearchPath: TStringList read FPostSearchPath;
    property PostNoSearchPath: TStringList read FPostNoSearchPath;
    property ConditionalCompilingConstants: TIdentifierList
                                           read FConditionalCompilingConstants;
    property PostUnitAliases: TStringList read FPostUnitAliases;
    property PostUnitAliasesAsString: String read GetPostUnitAliasesAsString
                                             write SetPostUnitAliasesAsString;
  end;





























   { * * *  ***  * * *  ***   TTextFormat   ***  * * *  ***  * * *  }



  TType = class;                    //base class of all type identifiers
  TProperty = class;                //the class of properties



  {Serves as a set of call-back functions to format text when getting the
   descriptions of identifiers.
  ~see Self a test of self links }
  TTextFormat = class
  public
    //Will be called for all reserved words.
    function ReservedWord(const Word: String): String; virtual;

    //Will be called for all texts of identifiers.
    function IdentifierText(const Text: String): String; virtual;

    //Will be called for all names of identifier-type identifiers.
    function TypeIdentifierText(Ident: TIdentifier): String; virtual;
    //Will be called for a text of a type identifier.
    function TypeText(const TypeStr: String;
                      SourceIdent: TIdentifier): String; virtual;
    //Will be called for all expressions.
    function ExprText(const ExprStr: String;
                      SourceIdent: TIdentifier): String; virtual;

    //Will be called for read- and write-attributes of properties.
    function PropertyReadWrite(const ReadWrite: String; Prop: TProperty;
                               SourceIdent: TIdentifier): String; virtual;
    //Will be called for implements-attribute of properties.
    function PropertyImplements(Prop: TProperty;
                                SourceIdent: TIdentifier): String; virtual;
    //Will be called for a reference on a method of an implemented interface.
    function InterfaceMethod(const Name: String; MethodOf: TRecordType;
                             SourceIdent: TIdentifier): String; virtual;
    //Will be called for a reference on a method.
    function MethodName(const Name: String; MethodOf: TRecordType;
                        SourceIdent: TIdentifier): String; virtual;
  end;






   { * * *  ***  * * *  ***   TDeclarationAssembler   ***  * * *  ***  * * *  }

  {Abstract base class whose sub-classes can be used to assemble the
   declaration of an identifier by calling the method ~[link GetDeclaration].
   It will call the method ~[link TIdentifier.GetDeclaration GetDeclaration]
   of the specified object of class ~[link TIdentifier]. }
  TDeclarationAssembler = class
  private
    //the identifier to return the declaration of
    FSourceIdent: TIdentifier;
  protected

    //Sets the identifier to assemble the declaration of.
    procedure SetSourceIdentifier(Identifier: TIdentifier);
  public
    //Assembles the declaration of the identifier.
    procedure GetDeclaration(Identifier: TIdentifier); virtual;

    //Will be called for all reserved words.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -