[A3]Delphi / C++Builder XE2
Deep DiveDavid Intersimone “David I”
Vice President of Developer Relations and Chief Evangelist
Embarcadero Technologies
davidi@embarcadero.com

• Delphi 64‐bit
64 bit• VCL Styles• RTL• LiveBindings• RAD Cloud• DataSnap

Delphi 64
64‐bitbit

Delphi 32 and 64
64‐bitbit Type Sizes

Signed types
ShortInt
S llI tSmallIntLongInt
Integer
Int64

Delphi/32
1 byte2bbytest
4 bytes
4 bytes
8 bytes

Delphi/64
Unsigned types
Byte
WordLongWord
CardinalUInt64

Delphi/32
1 byte2 bytes4 bytes
4 bytes
8 bytes

Delphi/64Delphi 32 and 64
64‐bitbit Type Sizes

Signed types
NativeInt

Delphi/32
4 bytes

Delphi/64
8 bytes

Unsigned types
NativeUInt

Delphi/32
4 bytes

Delphi/64
8 bytes

Delphi 32 and 64‐bit Pointer Types
Pointer types
PointerStringClass instanceClass reference
Interface
AnsiString
WideString
UnicodeString
Procedure pointerDynamic array
PAnsiChar
PWideChardeC aPChar

Delphi/32 Delphi/64

4 bytes

8 bytes

Delphi 64
64‐bitbit on Windows• Same Windows API– CreateWindowEx, PeekMessage, etc..

• Same Delphil hi RTL– SysUtils, Classes, Generics.Collections, etc…

• Same VCL– Forms, Graphics, Controls, Menus, etc..

What Can Do in your Code?
• Find all Integer<‐>Pointer casts, including
Integer<‐>instance casts.
– Check for Pointer size assumptions• Ensure external dependencies are also 64bit– Image/bitmap libraries– Hardware interfaces libraries– ActiveX controls• Consider rewriting Assembler in pure‐Pascal– Better futurefportabilitybili (think( hi k ARMACPUs…)
C U )– Rely more on algorithmic performance ratherthan raw assembly performance.

• MMakek sure you knowkwhath t bit‐size
bit i (32 vs 64)
you’re shifting with SHL/SHR.

Demonstration

VCL Styles

Themes in Delphi/C++Builder XE and earlier• OOnlyy 1 "theme"t e e supported
suppo ted ((nativeat e Windows)
do s)• 3rd party products required to change look of VCLappspp• Current “skinning" products for Windows
common controls– Requiring hooking WndProc's– Intercepting control messages• Separate controls needed for "custom" controls– TCustomControl / TGraphicControl descendants

VCL Styles• Multiple styles provided/supported• Custom style file creation• CustomCstylel classesl• Pluggable style engine• Works with TWinControl and TGraphicControl
descendants

VCL Styles
••

•

•

TThemeServices replaced by TCustomStyleServices– Extends TThemeServices with more parts, states and methods
TStyleEngine– Processes control messages– Calls StyleServices to render parts
TStyleManager– Provides services such as• LoadFromFile• LoadFromResource• RegisterStyle• RegisterStyleClass ‐ Associates file extension with Style class• SetStyle• Stylel selectionl• Style engine selection
Providing custom styles– Create style file (using provided style building tool)– Implement TCustomStyleServices descendant and render parts directlyWhat cancan’tt be styled?
• TMainMenu/TPopupMenu (main menu bar isstyled, but not the pop‐up parts)• Ribbon controls• OS dialogs

Project Options | AppearanceTypical Usage• Uses Vcl.Styles,
Vcl Styles Vcl.Themes;
Vcl Themes;• TStyleManager.SetStyle(‘Ruby Red Graphite’);RTLDemonstration

RTL

What’ss new in the RTL?
What•••64‐bit for Windows!!!
M OSX ‐ NoMacOSX
N COM,COM No
N ActiveX.
A i X :))– Windows specifics has been mapped to MacOSX equivalents whereverpossible
TOSVersion– Architecture (32/64‐bit), Platform (Win/Mac), Major, minor OS version, Service Pack info••••••

TFormatSettings– replaces global format setting variables (that don't exist on MacOSX)
TZipFile ‐ cross platform Zip support
SymLinks in IOUtils and SysUtils file handling routines– class function TFile.CreateSymLink(const Link, Target: string): Boolean;
TLoginCredentialServiceg– Extensible framework agnostic login credential services with support forcallbacks (success, failure, etc)
TPoint, TRect, TSize ‐ new methods and properties
TPointF TRectF,TPointF,TRectF TSizeF ‐ floating point versions

LiveBindings

What is LiveBindings?

““Provides
id a way ffor ddevelopers
lto create aread/write link between components/objects
and their data in the the application.”

LiveBindings Overview• Supported by FireMonkey and VCL• Based on relational expressions, called binding
expressions– Can be unidirectional or bidirectional• Can be used programmatically or visually• Is all about control objects and source object

LiveBinding Engine• Allow developers to create live binding in run‐time between
components/objects at design‐time.
• The LiveBinding visual components use the engine:– TBindScope for bindings to components– TBindScopeDB for bindings to databases– TBindingsList for holding of binding lists• A number of conversion services in the box and allows to create
new conversion service• Automatic updates– Expressions are automatically re‐evaluated when a variable (e.g.;property) referenced by an expression has changed value.
– Requires external notification

LiveBinding Engine• Allow developers to create live binding in run‐time between
components/objects at design‐time.
• The LiveBinding visual components use the engine:– TBindScope for bindings to components– TBindScopeDB for bindings to databases– TBindingsList for holding of binding lists• A number of conversion services in the box and allows to create
new conversion service• Automatic updates– Expressions are automatically re‐evaluated when a variable (e.g.;property) referenced by an expression has changed value.
– Requires external notification

LiveBinding components• TBindScopeDB – magic binding– Bind data from DataSet to components– “Link to DB Field” wizard create the expressions to bind the data from DataSetto components• TBindScope – non‐dataset binding– Bind data between components/objects– Support single object or collection of objects• TBindingsList– Hold the binding lists– Manage the list of methods and output converters used by the expression

LiveBinding Scenario
SOURCE
TFieldCONTROL
TLabelSource Expression
DisplayName

Control Expression
TextLiveBindingEngine

Binding Expression EditorCode Sample – Binding an objectvar
BindingExpression2 : TBindingExpression;
begin
BindingExpression2 := TBindings.CreateManagedBinding(TBindings CreateManagedBinding({ inputs }[TBindings.CreateAssociationScope([Associate(MyObject1,i ( Obj''o1'),')
Associate(MyObject2, 'o2’) ])], 'o1.StringValue + o2.StringValue',{output}[TBindings.CreateAssociationScope([Associate(MyResultObject, 'res’) ])], 'res.StringValue’,nil);Demonstration

RAD CloudCloud API service support

Storage

Azure Blobs Service

Amazon S3

Table

Azure Table Service

SimpleDBpQueueAzure Queue Service

Amazon SQSName conventions• Amazon and Microsoft use different names forthe same things

Container=Bucket

Blobs=ObjectPage=Multipart

ACL=ACL (Access Control List)

Microsoft Azure• Blob Storage– Unstructured storage– Defined Container– For storingg largeg pieces
pof data such as: Images,
g Video,Documents, etc.

• Azure Tables– Scalable structured storage
g– NOSQL type tables– Entities stored in a table– Different set of pproperties
pmade upp of different typesyp• Queues– Persistent asynchronous messaging– Each message is up to 8kb long

Amazon WS• Simple Storage Service (S3)– Blob Storage– Unstructured storage– Defined Container– ForF storingt i large
lpieces
ioff datad t suchh as: Images,I
Vid DVideo,
Documents,t
etc.

• SimpleDB ‐ Tables– Scalable structured storage– NOSQL type tables– Entities stored in a table– Different set of p
properties
pmade upp of different types
yp• Simple Queue Service (SQS)– Persistent asynchronous messaging– Each message is up to 64kb longDeploy to the Cloud• Deployment Manager support:– Amazon EC2– Microsoft Azure• Requires
Ri PlPlatformtfAssistant
A it tWhat'ss New in DataSnap
What

What’ss new in DataSnap
What• Enhancements– Server– REST Interfaces– Callback– Authentication
A th ti ti ManagerM• New DataSnap Monitoring and Control

Server• Proxy info support for DataSnap HTTP
connections in TSQLConnection andTDSRESTConnection• New TDBXChannelInfo.DBXClientInfo(TDBXClientInfo record) provides:– IP Address– ProtocolPl– Application Name (when possible) – only for HTTP

HTTPS Support• For Stand
Stand‐alone
alone DataSnap servers• For Stand‐alone WebBroker servers• DataSnapSWizards
i d updated
d d withi h HTTPSSsupport

Session Manager• Session support for TCP/IP protocol• Support for store and retrieve TObject inSessions• Sessions created and destroyed with theTCP/IP protocoll now notifies
ifi theh
AddSessionEvent and RemoveSessionEvent• Support for multiple Callback Tunnels onDataSnap REST Interface

Callbacks• Heavyweight callbacks now support
broadcasting to specific callbacks• GetAllChannelNames added to the DSServer
to get the name of all callback channels

Callback client side events• Notifications whenever the manager’s
manager s tunnel
is opened or closed, or when callbacks areadded to it or removed from it.
it Available for:– DBX Client Events– REST Client Events– JavaScript REST Client Events

DataSnap Monitoring and Control“DataSnap servers in XE2 are able to easily
monitor connections,connections and close any TCP
connection they wish.”What you can do• Take control over the client connections• Monitor client requests• Limiti i theh numberb off requests per connectioni• Improve Security• More…

How it works?
• TDSTCPServerTransport components has twonew events:– onConnect– onDisconnect• Connections
Ctiare linkedli k d withith a SSessioni ID

Detecting Graceless Disconnects• By default
default, the OnDisconnect event will not be
notified if the client abruptly loses his internetconnection• This behavior depends on OS configuration• Use
U TDSTCPChannel
TDSTCPChl methods
h d to controll thishibehavior for each connection:– EnableKeepAlive– DisableKeepAliveKeepAlive Enablement• Available through TDSTCPServerTransportcomponent• Three new published properties– KeepAliveEnablement ‐ (Set: Default, Enabled,Disabled)– KeepAliveTime ‐ Integer Milliseconds value– KeepAliveInterval
KAli I tl ‐ Integer
I t
Milli
Milliseconds
d valuelClosing Client Connections• Connection can be closed any time
• Channel provide the connection instance//Get the associated Channel for the given connection, and if successful close it
if FConnections.TryGetValue(Connection, Channel) thenChannel.Close;Demo• Tracking all the TCP/IP connections and theircorresponding sessions• How to manually close a TCP/IP connection
from the server• How
H to ddetect whenh a clientlih
has llost internet
iconnectivity while connected.

Q&A

Thank You 