Delphi5-Borland Object Language Guide
Index 1-1
Contents
Chapter 1
Introduction 1-1
What's in this manual?.............. 1-1
Delphi and Object Pascal........... 1-1
Typographical conventions.......... 1-2
Other sources of information........... 1-2
Software registration and technical support . . 1-2
Part I ,w
Basic language description
Chapter 2
Overview 2-1
Program organization..........*. . Г . . 2-1
Pascal source files............... 2-1
Other files used to build applications .... 2-2
Compiler-generated files........... 2-3
Example programs................. 2-3
A simple console application......... 2-3
A more complicated example......... 2-4
A Windows application............ 2-5
Chapter 3
Programs and units 3-1
Program structure and syntax.....\ . . . . 3-1
The program heading............. 3-2
The program uses clause........... 3-2
The block.................... 3-2
Unit structure and syntax............. 3-3
The unit heading................ 3-3
The interface section.............. 3-4
The implementation section.......... 3-4
The initialization section............ 3-4
The finalization section............ 3-5
Unit references and the uses clause....... 3-5
The syntax of a uses clause.......... 3-5
Multiple and indirect unit references .... 3-6
Circular unit references............ 3-7
Chapter 4 r*»^
Syntactic elements 4-1
Fundamental syntactic elements......... 4-1
Special symbols............,..... 4-2
Identifiers.................... 4-2
Qualified identifiers............ 4-2
Reserved words.................4-3
Directives.....................4-3
Numerals..................... 4-4
Labels..................: . . . . 4-4
Character strings................4-4
lomments and compiler directives........4-5
expressions.....................4-5
Operators.....................4-6
Arithmetic operators............4-6
; Boolean operators..............4-7
Logical (bitwise) operators.........4-8
; String operators...............4-9
Pointer operators............... 4-9
Set operators................4-10
Relational operators............4-10
Class operators...............4-11
The @ operator...............4-11
Operator precedence rules........4-12
Function calls.................4-13
Set constructors................4-13
Indexes.....................4-13
Typecasts....................4-14
Value typecasts...............4-14
Variable typecasts.............4-14
)eclarations and statements...........4-16
Declarations..................4-16
Statements...................4-16
Simple statements...............4-16
Assignment statements..........4-17
Procedure and function calls.......4-17
Goto statements..............4-18
Structured statements.............4-19
Compound statements..........4-19
With statements..............4-20
If statements................4-21
Case statements..............4-23
Control loops................4-24
Repeat statements.............4-24
While statements..............4-25
For statements...............4-25
locks and scope.................4-27
Blocks......................4-27
Scope......................4-27
Naming conflicts..............4-28
Chapter 5
Data types, variables, and constants 5-1
About types.....................5-1
Simple types....................5-2
Ordinal types..................5-2
Integer types.................5-3
., Character types...............5-4
Boolean types................5-5
Enumerated types.............5-6
Subrange types...............5-7
Real types....................5-8
String types.....................5-9
Short strings...................5-11
Long strings...................5-11
WideString...................5-12
' About extended character sets......5-12
Working with null-terminated strings . . . .5-12 Using pointers, arrays, and string
constants..................5-13
Mixing Pascal strings and
null-terminated strings..........5-14
Structured types..................5-15
Sets........................5-16
Arrays......................5-16
Static arrays.................5-17
f..j Dynamic arrays...............5-17
.. Array types and assignments.......5-20
Records.....................5-20
Variant parts in records..........5-21
File types....................5-23
Pointers and pointer types............5-24
Overview of pointers.............5-24
Pointer types..................5-26
Character pointers.............5-26
Other standard pointer types.......5-26
Procedural types..................5-27
Procedural types in statements and
expressions..................5-28
Variant types....................5-29
Variant type conversions...........5-30
Variants in expressions............5-32
Variant arrays..................5-32
OleVariant.................-. . .5-33
Type compatibility and identity.........5-33
Type identity..................5-33 '
Type compatibility...............5-34
Assignment-compatibility...........5-34
Declaring types..................5-J
Variables......................5-}
Declaring variables..............5-J
Absolute addresses............5-3
Dynamic variables.............5-J
Thread-local variables...........5-3
Declared constants................5-3
True constants.................5-3
Constant expressions...........5-3
Resource strings..............54
Typed constants................5-1
Array constants..............И
Record constants..............5-4
Procedural constants...........5-1'
Pointer constants..............Si
Chapter 6
Procedures and functions 6-1
Declaring procedures and functions.......6-1
Procedure declarations.............Й
Function declarations..............Ы
Calling conventions...............M
Forward and interface declarations......И
External declarations..............M
Linking to .OBJ files.............U
Importing functions from DLLs......И
Overloading procedures and functions. . . ,M
Local declarations................H
Nested routines...............M
Parameters......................M
Parameter semantics.............Mi
Value and variable parameters......6-11
Constant parameters...........6-11
Out parameters...............Hi
Untyped parameters............И
String "parameters...............6-1)
Array parameters...............6-E
Open array parameters..........6-1)
Variant open array parameters......Hi
Default parameters..............Hi
Default parameters and overloaded
routines..................6-1?
Default parameters in forward and
interface declarations..........6-17
Hailing procedures and functions........6-17
Open array constructors...........6-1!
Chapter 7 "•'
Classes and objects 7-1
Class types.....................7-1
Inheritance and scope.............7-2
TObject and TClass.............7-3
Compatibility of class types........7-3
Object types.................7-3
Visibility of class members..........7-4
Private, protected, and public
members..................7-5
Published members.............7-5
Automated members............7-5
Forward declarations and mutually
dependent classes...............7-6
Fields.................'.......7-7
Methods.......................7-8
Method implementations...........7-8
Inherited...................7-8
Self......................7-9
Method binding................7-9
Static methods................7-9
Virtual and dynamic methods.......7-10
Abstract methods.........¦ . . . . 7-11
Overloading methods.............7-12
Constructors..................7-12
Destructors...................7-14
Message handlers...............7-15
Implementing message handlers.....7-15
Message dispatching............7-15
Properties......................7-16
Property access.................7-16
Array properties................7-18
Index specifiers.................7-19
Storage specifiers................7-20
Property overrides and redeclarations.... 7-20
Class references..................7-22
Class-reference types..............7-22
Constructors and class references.....7-22
Class operators.................7-23
The is operator...............7-23
The as operator...............7-24
Class methods.................7-24
Exceptions.....................7-25
Declaring exception types...........7-25
Raising and handling exceptions.......7-25
Try...except statements...........7-26
Re-raising exceptions...........7-28
Nested exceptions.............7-29
Try...finally statements..........7-30
Standard exception classes and routines . . 7-30
Chapter 8
Standard routines and I/O 8-1
File input and output................8-1
Text files.....................8-3
Untyped files...................8-4
Text-file device drivers...............8-4
Device functions.................8-5
The Open function..............8-5
The InOut function..............8-5
The Flush function..............8-6
The Close function..............8-6
Handling null-terminated strings.........8-6
Wide-character strings.............8-7
Other standard routines..............8-7
PartII ..,,.„,,*,*; ¦¦.-.»,
Special topics
Chapter 9
Dynamic-link libraries and packages 9-1
Calling DLLs....................9-1
Static loading.................9-1
Dynamic loading...............9-2
Writing DLLs....................9-3
The exports clause................9-4
Library initialization code...........9-4
Global variables in a DLL...........9-5
DLLs and System variables..........9-5
Exceptions and runtime errors in DLLs. . . .9-6
The shared-memory manager.........9-6
Packages.......................9-7
Package declarations and source files.....9-7
Naming packages..............9-8
The requires clause.............9-8
The contains clause.............9-8
Compiling packages..............9-9
Generated files................9-9
Package-specific compiler directives . . . 9-9 Package-specific command-line compiler switches............9-10
Chapter 10 ; .^= •?
Object interfaces 10-1
Interface types...................10-1
IUnknown and inheritance..........10-2
Interface identification.............10-2
Calling conventions..............10-3
Interface properties...............10-3
Forward declarations.............10-3
Implementing interfaces.............10-4
Method resolution clauses...........10-5
Changing inherited implementations .... 10-5 Implementing interfaces by delegation . . .10-6 Delegating to an interface-type
property..................10-6
Delegating to a class-type property.... 10-7
Interface references................10-8
Interface assignment-compatibility......10-9
Interface typecasts...............10-9
Interface querying.............10-9
Automation objects...............10-10
Dispatch interface types...........10-10
Dispatch interface methods.......10-11
Dispatch interface properties......10-11
Accessing Automation objects.......10-11
Automation object method-call
syntax...................10-12
Dual interfaces................10-12
Chapter 11
Memory management 11-1
Delphi's memory manager............11-1
Variables.....................11-2
Internal data formats...............11-2
Integer types..................11-2
Character types.................11-3
Boolean types..................11-3
Enumerated types...............11-3
Real types....................11-3
The Real48 type...............11-4
The Single type...............11-4
The Double type..............11-4
The Extended type.............11-5
The Comp type...............11-5
The Currency type.............11-5
Pointer types..................11-5
Short string types................11-5
Long string types................11-5
Wide string types................11-6
Set types....................11
Static array types...............t
Dynamic array types.............11
Record types..................1;
File types....................11 4.
Procedural types.................11 4.
Class types...................11 4
Class reference types.............11! 4
Variant types..................11-. 4
4
Chapter 12 4
Program control 12 4
Parameters and function results.........11 ^
Parameter passing...............1!
Register saving conventions.......!!¦
Function results................11 •
Method calls..................11
Constructors and destructors.......11-
Exit procedures..................1}
Chapter 13
Inline assembler code 131
The asm statement................1J-1
Register use..................К
Assembler statement syntax...........1Я
Labels......................Ш
Instruction opcodes..............13:
¦-• <: RET instruction sizing...........13-
Automatic jump sizing..........Ш
Assembler directives.............13i
Operands................, . . . 13i
Expressions....................131
Differences between Object Pascal and
assembler expressions............13-1
Expression elements.............13f
Constants . . Л ..............134
Registers.................13-i
Symbols..................13-10
Expression classes..............13-11
Expression types...............13-11
Expression operators............13-14
Assembler procedures and functions.....13-16
Appendix A
Object Pascal grammar A-l
Index 1-1
Tables
4.1 Reserved words...............4-3
4.2 Directives...................4-3
4.3 Binary arithmetic operators........4-6
4.4 Unary arithmetic operators.........4-6
4.5 Boolean operators..............4-7
4.6 Logical (bitwise) operators.........4-8
4.7 String operators...............4-9
4.8 Character-pointer operators........4-9
4.9 Set operators.................4-10
4.10 Relational operators.............4-10
4.11 Precedence of operators...........4-12
5.1 Generic integer types for 32-bit implementations of Object Pascal.....5-3
5.2 Fundamental integer types.........5-3
5.3 Fundamental real types'...........5-8
5.4 Generic real types..............5-9
5.5 String types..................5-9
5.6 Selected pointer types declared in
System and SysUtils.............5-26
5.7 Variant type conversion rules.......5-31
5.8 Types for integer constants.........5-39
6.1 Calling conventions.............6-5
8.1 Input and output procedures and functions....................8-1
8.2 Null-terminated string functions......8-6
8.3 Other standard routines...........8-7
9.1 Compiled package files...........9-9
9.2 Package-specific compiler directives .... 9-9
9.3 Package-specific command-line
compiler switches..............9-10
11.1 Long string dynamic memory layout . . 11-5
11.2 Wide string dynamic memory layout . . 11-6
11.3 Dynamic array memory layout......11-7
11.4 Type alignment masks...........11-7
11.5 Virtual method table layout........11-10
13.1 Built-in assembler reserved words .... 13-7
13.2 String examples and their values.....13-9
13.3 CPU registers...............13-10
13.4 Symbols recognized by the built-in assembler..................13-11
13.5 Predefined type symbols.........13-14
13.6 Precedence of built-in assembler expression operators...........13-14
13.7 Definitions of built-in assembler expression operators...........13-15


Hosted by uCoz