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

📄 upascalconsts.pas

📁 DelphiDoc is a program for automatic generation of documentation on a Delphi-Project. At the momen
💻 PAS
📖 第 1 页 / 共 2 页
字号:
{  JADD - Just Another DelphiDoc: Documentation from Delphi Source Code

Copyright (C) 2003-2008   Gerold Veith

This file is part of JADD - Just Another DelphiDoc.

DelphiDoc is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License version 3 as
published by the Free Software Foundation.

DelphiDoc is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.
}


unit UPascalConsts;

{This unit contains several constants and simple types.~[br]
 It also contains the function ~[link IsWordIn] to find a word in an
 alphabetically sorted list of words. It is often used to test if a word is a
 reserved word.
}

interface

      //identifiers start with one of these characters;
      //the '&' is not really a character of an identifier, but raher it is
      //used as a prefix for keywords to handle them as normal identifiers in
      //Delphi 8+, in FreePascal it is used like "$" only for octal numbers
const StartIdentifierChars = ['&', '_', 'A'..'Z', 'a'..'z', #128..#255];
      //any following character in an identifier is one of these characters
      IdentifierChars = ['0'..'9'] + (StartIdentifierChars - ['&']);


      //the four different kinds of parameters
type  TParameterKind = (
        pkNormal,        //a "normal by value"-parameter
        pkReference,     //a "by reference"-parameter
        pkConstant,      //a "constant" parameter (maybe by reference)
        pkOut);          //an "out" (by reference-) parameter

      //reserved words to define the kind of a parameter
const ParameterFormalAttributNames: array[TParameterKind] of String =
                                                   ('', 'var', 'const', 'out');


      //the four different kinds of functions
type  TFunctionKind = (
        fkProcedure,     //a function that returns nothing
        fkFunction,      //a normal function
        //a function that returns a new object of that class, if it is called
        fkConstructor,   //as a class function, else the object itself
        fkDestructor);   //a function that frees the object and returns nothing

      //a set of the different kinds of functions
      TFunctionKinds = set of TFunctionKind;

      //reserved words to define the kind of function
const FuncNames: array[TFunctionKind] of String =
                        ('procedure', 'function', 'constructor', 'destructor');




      //the possible scopes of identifiers;
      //the new strict variants of private and protected of DotNet are
      //currently mapped to the normal variants
type  TScope = (
        sUnknown,         //error
        sInterface,       //declared in interface section
        sImplementation,  //declared in implementation section and main-program
        sPrivate, sProtected, sPublic, sPublished, sAutomated, //classes...
        sLocal);          //declarations in functions

      //a set of scopes (f.i. for a filter)
      TScopes = set of TScope;

      //the possible scopes of members of classes
      TMemberScope = sPrivate..sAutomated;

      //scopes that are treated as public scopes
      //(to generate public/interface documentation)
const PublicScopes = [sInterface, sPublic, sPublished, sAutomated];





      //the different types of source files possible in Delphi
type  TSourceFileType = (
        //the project file with "program" or nothing of the others
        sftProgram,     //at the beginning (this means, this is the default)
        sftUnit,        //a unit, starting with "unit"
        sftLibrary,     //a project file for a library, starting with "library"
        sftPackage);    //a project file for a package, starting with "package"


      //names of the types of the files
const FileTypeNames: array[TSourceFileType] of String =
                        ('Program', 'Unit', 'Library', 'Package');

      //reserved word for the type of the file (alphabetically)
      //use ~[link FileStartWordTypes] to get to the type; default: program
      FileStartWords: array[Ord(Low(TSourceFileType))..
                            Ord(High(TSourceFileType))] of String =
                      ('library', 'package', 'program', 'unit');
      //can be used to get from the index in ~[link FileStartWords] to the type
      FileStartWordTypes: array[TSourceFileType] of TSourceFileType =
                                 (sftLibrary, sftPackage, sftProgram, sftUnit);




      //the different kinds of record-like types (structures) in Delphi
type  TRecordKind = (
        rkRecord,         //a simple record type
        rkObject,         //a class defined with the reserved word object
        rkClass,          //a class defined with the reserved word class
        rkInterface,      //an interface
        rkDispInterface); //a dispatch interface

     //all kinds of record-like types
     TRecordKinds = set of TRecordKind;



      //all kinds of record-like types that can inherit from a parent class
const RecordKindCanInherit = [rkObject, rkClass, rkInterface];

      //all kinds of record-like types that can be abstract
      RecordKindCanBeAbstract = [rkObject, rkClass];

      //all kinds of record-like types for which all methods are abstract
      RecordKindMethodsAreAbstract = [rkInterface, rkDispInterface];

      //names of the kinds of record-likes types
      RecordKindNames: array[TRecordKind] of String =
                    ('record', 'object', 'class', 'interface', 'dispinterface');

      //the name of the parent if none given
      RecordKindDefaultParent: array[Boolean] of String =
                    ('TObject', 'IUnknown');

      //the name of the parent if none given for interfaces in D6+ or D7+
      RecordKindDefaultInterfaceParent = 'IInterface';





      


      //alphabetical list of names of the kinds of record-like types
const RecordTypWords: array[Ord(Low(TRecordKind))..
                            Ord(High(TRecordKind))] of String =
                   ('class', 'dispinterface', 'interface', 'object', 'record');

      //maps the indices in ~[link RecordTypWords] to TRecordKind
      RecordTypWordKinds: array[Ord(Low(TRecordKind))..
                                Ord(High(TRecordKind))] of TRecordKind =
                   (rkClass, rkDispInterface, rkInterface, rkObject, rkRecord);



      //portability issues of an identifier/unit
type  TIdentPortability = (
                           //the identifier is deprecated and shouldn't be used
                           ipDeprecated,
                           //the identifier is library/implementation specific
                           ipLibrary,
                           //the identifier is platform specific
                           ipPlatform);

      //all portability issues of an identifier/unit
      TIdentPortabilities = set of TIdentPortability;




      //all words that indicate a portability issue
const IdentPortability: array[TIdentPortability] of String =
                                         ('deprecated', 'library', 'platform');



      //all words that act as attributes for functions
      FuncAttributes: array[0..25] of String =
              ('abstract', 'assembler',   'cdecl',    'deprecated', 'dispid',
               'dynamic',  'export',      'external', 'far',        'forward',
               'inline',   'library',     'local',    'message',    'near',
               'of',       'overload',    'override', 'pascal',     'platform',
               'register', 'reintroduce', 'safecall', 'stdcall',    'varargs',
               'virtual');


      DeprecatedAttribute = 3;      //deprecated        ~see FuncAttributes
      LibraryAttribute = 11;        //library           ~see FuncAttributes
      PlatformAttribute = 19;       //platform          ~see FuncAttributes


      OverloadedAttribute = 16;     //overload          ~see FuncAttributes
      VirtualAttributes = [5, 25];  //dynamic, virtual  ~see FuncAttributes
      AbstractAttribute = 0;        //abstract          ~see FuncAttributes
      OverrideAttribute = 17;       //override          ~see FuncAttributes
      OfObjectAttribute = 15;       //of [object]       ~see FuncAttributes
      ExternalAttribute = 7;        //external          ~see FuncAttributes
      MessageAttribute = 13;        //message           ~see FuncAttributes

      //after this attributes follows an expression
      //dispid, external, message  ~see FuncAttributes
      ExtendedAttributes = [4, ExternalAttribute, MessageAttribute];

      ForwardAttribute = 9;         //forward           ~see FuncAttributes


      //dispid IntConst;

      //external;       (like forward but not implemented in .pas, only linked)

      //external StringConst; external StringConst name StringConst;
      //                      external StringConst index IntConst;

      //message IntConst;


      //these attributes mean that there is no body (at least here):
      //external, forward
      //~see FuncAttributes
      NoBodyAttributes = [ExternalAttribute, ForwardAttribute];




      //possible attributes of a function
type  TFunctionAttribute = (
        faClassMethod,       //is a class method

⌨️ 快捷键说明

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