- •Contents
- •1.1 Fundamental Types
- •1.2 T Classes
- •1.3 C Classes
- •1.4 R Classes
- •1.5 M Classes
- •1.6 Static Classes
- •1.7 Buyer Beware
- •1.8 Summary
- •2 Leaves: Symbian OS Exceptions
- •2.1 Leaving Functions
- •2.3 Constructors and Destructors
- •2.4 Working with Leaving Functions
- •2.5 Trapping a Leave Using TRAP and TRAPD
- •2.6 LeaveScan
- •2.7 Summary
- •3 The Cleanup Stack
- •3.1 Using the Cleanup Stack
- •3.2 How Does the Cleanup Stack Work?
- •3.4 Using TCleanupItem for Customized Cleanup
- •3.5 Portability
- •3.6 An Incidental Note on the Use of Casts
- •3.7 Summary
- •5 Descriptors: Symbian OS Strings
- •5.3 Pointer Descriptors
- •5.4 Stack-Based Buffer Descriptors
- •5.5 Heap-Based Buffer Descriptors
- •5.6 Literal Descriptors
- •5.7 Summary
- •6 Good Descriptor Style
- •6.1 Descriptors as Parameters and Return Types
- •6.2 Common Descriptor Methods
- •6.3 The Use of HBufC Heap Descriptors
- •6.4 Externalizing and Internalizing Descriptors
- •6.5 The Overuse of TFileName
- •6.6 Useful Classes for Descriptor Manipulation
- •6.7 Summary
- •7 Dynamic Arrays and Buffers
- •7.1 CArrayX Classes
- •7.3 Why Use RArray Instead of CArrayX?
- •7.4 Dynamic Descriptor Arrays
- •7.5 Fixed-Length Arrays
- •7.6 Dynamic Buffers
- •7.7 Summary
- •8.1 Multitasking Basics
- •8.2 Event-Driven Multitasking
- •8.3 Working with Active Objects
- •8.4 Example Code
- •8.5 Threads Without an Active Scheduler
- •8.6 Application Code and Active Objects
- •8.7 Summary
- •9 Active Objects under the Hood
- •9.1 Active Object Basics
- •9.2 Responsibilities of an Active Object
- •9.3 Responsibilities of an Asynchronous Service Provider
- •9.4 Responsibilities of the Active Scheduler
- •9.5 Starting the Active Scheduler
- •9.6 Nesting the Active Scheduler
- •9.7 Extending the Active Scheduler
- •9.8 Cancellation
- •9.9 Request Completion
- •9.10 State Machines
- •9.11 Long-Running Tasks
- •9.14 Common Mistakes
- •9.15 Summary
- •10 Symbian OS Threads and Processes
- •10.2 Thread Priorities
- •10.3 Stopping a Running Thread
- •10.5 Exception Handling
- •10.6 Processes
- •10.7 Summary
- •11.2 How Do the Client and Server Fit Together?
- •11.3 How Do the Client and Server Communicate?
- •11.5 How Do Synchronous and Asynchronous Requests Differ?
- •11.6 How Is a Server Started?
- •11.7 How Many Connections Can a Client Have?
- •11.8 What Happens When a Client Disconnects?
- •11.9 What Happens If a Client Dies?
- •11.10 What Happens If a Server Dies?
- •11.15 How Many Outstanding Requests Can a Client Make to a Server?
- •11.16 Can Server Functionality Be Extended?
- •11.17 Example Code
- •11.18 Summary
- •12.2 Client Boilerplate Code
- •12.3 Starting the Server and Connecting to It from the Client
- •12.4 Server Startup Code
- •12.5 Server Classes
- •12.6 Server Shutdown
- •12.7 Accessing the Server
- •12.8 Summary
- •13 Binary Types
- •13.1 Symbian OS EXEs
- •13.2 Symbian OS DLLs
- •13.3 Writable Static Data
- •13.4 Thread-Local Storage
- •13.5 The DLL Loader
- •13.6 UIDs
- •13.8 Summary
- •14 ECOM
- •14.1 ECOM Architecture
- •14.2 Features of an ECOM Interface
- •14.3 Factory Methods
- •14.4 Implementing an ECOM Interface
- •14.5 Resource Files
- •14.6 Example Client Code
- •14.7 Summary
- •15 Panics
- •15.2 Good Panic Style
- •15.3 Symbian OS Panic Categories
- •15.4 Panicking Another Thread
- •15.5 Faults, Leaves and Panics
- •15.6 Summary
- •16 Bug Detection Using Assertions
- •16.3 Summary
- •17 Debug Macros and Test Classes
- •17.1 Heap-Checking Macros
- •17.2 Object Invariance Macros
- •17.3 Console Tests Using RTest
- •17.4 Summary
- •18 Compatibility
- •18.1 Forward and Backward Compatibility
- •18.2 Source Compatibility
- •18.3 Binary Compatibility
- •18.4 Preventing Compatibility Breaks
- •18.5 What Can I Change Without Breaking Binary Compatibility?
- •18.6 Best Practice: Planning for Future Changes
- •18.7 Compatibility and the Symbian OS Class Types
- •18.8 Summary
- •19 Thin Templates
- •20.1 Class Layout
- •20.3 Parameters and Return Values
- •20.4 Member Data and Functional Abstraction
- •20.5 Choosing Class, Method and Parameter Names
- •20.7 Summary
- •21 Good Code Style
- •21.1 Reduce the Size of Program Code
- •21.2 Use Heap Memory Carefully
- •21.3 Use Stack Memory Carefully
- •21.5 Optimize Late
- •21.6 Summary
- •Glossary
- •Bibliography and Online Resources
- •Index
Glossary
Term |
Definition |
Chapter |
active object |
Responsible for issuing requests to |
8, 9 |
|
asynchronous service providers and |
|
|
handling those requests on completion. |
|
|
Derives from CActive. |
|
active scheduler |
Responsible for scheduling events to the |
8, 9 |
|
active objects in an event-handling program. |
|
asynchronous |
A system, component or class, which |
8, 9 |
service provider |
provides a service asynchronously, typically |
|
|
to an active object. Asynchronous requests |
|
|
are indicated by function calls with a |
|
|
TRequestStatus reference parameter. |
|
backward |
Updating a component in such a way that |
18 |
compatibility |
client code which used the original version |
|
|
can continue to work with the updated |
|
|
version. See also forward compatibility. |
|
binary |
Modifying a library in such a way that code |
18 |
compatibility |
which linked against the previous version |
|
|
can continue to run with the new version |
|
|
without needing recompilation. |
|
C function |
In the context of Symbian OS, this refers to a |
3 |
|
function with a trailing C in its name, e.g. |
|
NewLC(). If successful, this type of function leaves one or more objects on the cleanup stack when it returns.
340 |
GLOSSARY |
|
Term |
Definition |
Chapter |
chunk |
A unit of memory allocation, where a linear |
13 |
|
region of RAM is mapped into contiguous |
|
|
logical addresses. |
|
clanger |
The Clangers are a race of highly-civilized, |
throughout |
|
small, bright pink, long-nosed, |
|
|
mouse-shaped persons who stand upright |
|
|
on big flappy feet (see www.clangers.co.uk |
|
|
for more information). |
|
cleanup stack |
Takes responsibility for cleaning up the |
3 |
|
objects pushed onto it if a leave |
|
|
occurs. |
|
client interface |
A member function in a client-side session |
11, 12 |
function |
(or subsession) class that sends a specific |
|
|
message request to a server, identified by an |
|
|
opcode. |
|
context switch |
A switch in execution between one thread |
10, 11, 12 |
|
or process and another. This involves saving |
|
|
the context of the currently executing thread |
|
|
or process (i.e. its address space mappings) |
|
|
and restoring the context of the newly |
|
|
executing thread or process. |
|
descriptor |
A string, so-called because it is |
4, 5 |
|
self-describing. All descriptor classes derive |
|
|
from TDesC, which describes an area of |
|
|
memory used as either a string or binary |
|
|
data. |
|
descriptorize |
To marshal a flat data object, typically a |
6, 11, 12 |
|
struct or T class, into a descriptor for |
|
|
inter-thread data transfer. |
|
DLL (dynamic |
Dynamic link libraries contain functions |
13 |
link library) |
that are linked and stored separately from |
|
|
the programs that use them. |
|
DLL export table |
An area in the DLL which lists the DLL |
13 |
|
addresses of exported items. On Symbian |
|
|
OS, these items are indexed by |
|
|
ordinal. |
|
E32 |
Collective term for the base components of |
|
|
Symbian OS. |
|
ECOM |
A generic framework in Symbian OS from |
14 |
|
v7.0 for use with plug-in modules. |
|
|
GLOSSARY |
341 |
Term |
Definition |
Chapter |
emulator |
An implementation of Symbian OS hosted |
13 |
|
on a PC running Microsoft Windows. |
|
|
Compare with target hardware. |
|
entry point |
A function called when a DLL is loaded or |
13 |
|
attached by a thread or process. In Symbian |
|
|
OS, the function E32Dll() is usually |
|
|
coded as the entry point. |
|
EPOC, EPOC32 |
Earlier names for Symbian OS. Rumors that |
|
|
this stood for ‘Electronic Piece of Cheese’ |
|
|
are unconfirmed. |
|
exec call |
A call to the kernel via a software interrupt |
10 |
|
(see this useful paper by John Pagonis for |
|
|
more details www.symbian.com/developer/ |
|
|
techlib/papers/userland/userland.pdf) |
|
F32 |
Collective term for the components making |
|
|
up the Symbian OS file server. |
|
FEP (Front-End |
Allows the input of characters by a user, for |
13 |
Processor) |
example, by handwriting recognition or |
|
|
voice, and converts the input transparently |
|
|
into text. |
|
file server |
The server thread that mediates all file |
11 |
|
system operations. All application programs |
|
|
that use files are clients of this thread. |
|
flat buffer |
A dynamic buffer using flat storage, i.e. a |
7 |
|
single segment of memory (see also |
|
|
segmented buffer). |
|
forward |
Updating a component in such a way that |
18 |
compatibility |
code which works with the new version also |
|
|
works with the original version. See also |
|
|
backward compatibility. |
|
framework |
A component that allows its functionality to |
13, 14 |
|
be extended by plug-in modules, sometimes |
|
|
known as framework extensions. The |
|
|
framework loads the extensions as required |
|
|
at runtime. |
|
framework |
Provides plug-in functionality to a |
14 |
extension |
framework, typically by implementing |
|
|
interfaces defined by that framework. On |
|
|
Symbian OS, a framework extension is |
|
|
implemented as a polymorphic DLL. |
|
342 |
GLOSSARY |
Term
freeze
import library (.lib)
IPC (Inter-Process Communication)
just-in-time (JIT)
kernel
L function
leave
mixin
module definition file (.def)
null thread
Definition |
Chapter |
The process of fixing the association |
13 |
between name and ordinal, for functions |
|
exported from a DLL. It is a colloquial |
|
reference to a .def file (see module |
|
definition file). |
|
A static library that an application program |
13 |
uses at link time to resolve references to |
|
symbols defined in a corresponding DLL. |
|
Information from this library concerning the |
|
location of export functions in the DLL is |
|
included in the application’s executable |
|
file. |
|
Used by clients to communicate with |
11, 12 |
out-of-process servers on Symbian OS. |
|
Just-in-time debugging is used to attach a |
15 |
debugger to a process at the point at which |
|
it is about to terminate. |
|
The core of the operating system. It manages |
10 |
memory, loads processes and libraries and |
|
schedules threads for execution. |
|
A function with a trailing L in its name, e.g. |
2 |
NewL(), which indicates that it may leave. |
|
Symbian OS exception handling. A function |
2 |
leaves when User::Leave()is called. It |
|
causes a return to the current trap harness. |
|
An interface class for ”mixing in” with |
1 |
primary base classes, and the only form of |
|
multiple inheritance encouraged on |
|
Symbian OS. |
|
A file that specifies an ordinal value for each |
13, 18 |
named function or data item to be exported |
|
from a DLL. It is used to insert ordinal |
|
information into the DLL export table, |
|
allowing exports to be accessed by ordinal |
|
from clients of the DLL. |
|
The lowest-priority thread in the system, |
10 |
belonging to the kernel. It only runs when |
|
there is no higher priority thread to run and |
|
usually puts the phone into power-saving |
|
mode. |
|
|
GLOSSARY |
343 |
Term |
Definition |
Chapter |
OOM |
An error caused when the available RAM |
throughout |
(out-of-memory) |
has been exhausted, preventing further heap |
|
|
allocation. |
|
panic |
A run-time exception on Symbian OS that |
15, 16 |
|
terminates the current thread. Panics tend to |
|
|
be caused when assertion statements |
|
|
fail. |
|
plug-in |
A polymorphic interface DLL used to extend |
13, 14 |
|
a framework application. |
|
polymorphic |
A DLL that provides plug-in functionality to |
13, 14 |
DLL |
another program by implementing a defined |
|
|
interface. These are typically known as |
|
|
plug-ins and are loaded dynamically by |
|
|
another program (usually a framework) |
|
|
using RLibrary::Load(). Compare with |
|
|
shared library. |
|
process |
The unit of memory protection on Symbian |
10 |
|
OS. One user process may not access |
|
|
another’s memory. A process may contain |
|
|
one or more threads. |
|
recognizer |
A plug-in that examines data from a file and |
13 |
|
returns its data (MIME) type, if recognized. |
|
request |
A semaphore associated with a thread, |
8, 9 |
semaphore |
which is used to indicate the completion of |
|
|
an asynchronous request. |
|
request status |
An object that indicates the completion |
8, 9 |
|
status of a request, represented by |
|
|
TRequestStatus. |
|
ROM |
Read-Only Memory. This is permanent |
13 |
|
memory that can be read but not (easily) |
|
|
written to. It holds code and data that must |
|
|
persist when the phone is switched off. On |
|
|
Symbian OS, it is usually identified as the Z: |
|
|
drive. |
|
SDK |
Software Development Kit. |
|
segmented |
A dynamic buffer using segmented storage, |
7 |
buffer |
which consists of a doubly-linked list of |
|
|
segments. Segments are added when the |
|
|
buffer needs to expand and removed when |
|
|
it is compressed. See also flat buffer. |
|
344 |
GLOSSARY |
|
Term |
Definition |
Chapter |
server call |
A call to the kernel in which the kernel |
11, 12 |
|
server thread runs on behalf of the user |
|
|
program. See this useful paper by John |
|
|
Pagonis for more information |
|
|
www.symbian.com/developer/techlib/ |
|
|
papers/userland/userland.pdf |
|
session |
The channel of communication between a |
11, 12 |
|
client and a server. |
|
shared library |
A library that is loaded by the DLL loader |
13 |
|
when an executable that links to it is |
|
|
loaded. Compare with polymorphic |
|
|
DLL. |
|
static library |
Other executable code may link to this |
13 |
|
library to resolve references to exported |
|
|
functions. Builds with a .lib |
|
|
extension. |
|
target hardware |
A phone handset running Symbian OS |
10, 13 |
|
(compare with emulator) |
|
thin template |
An idiom used to minimize code bloat from |
19 |
|
the use of standard C++ templates. |
|
thread-local |
A machine word of memory that may be |
13 |
storage (TLS) |
used to anchor information in the context of |
|
|
a DLL or a thread. Used instead of writable |
|
|
static data, which is not supported for |
|
|
Symbian OS DLLs. |
|
TRAP, TRAPD |
Trap harness macros within which |
2 |
|
leaving code may be executed and any |
|
|
leaves ”caught”. Can be likened to a |
|
|
combination of try and catch in standard |
|
|
C++. |
|
two-phase |
An idiom used on Symbian OS to ensure |
4 |
construction |
that an object can be initialized safely using |
|
|
leaving code. |
|
UID (unique |
A unique 32-bit number used in a |
13 |
identifier) |
compound identifier to identify an object, |
|
|
file type, etc. When users refer to ”UID” |
|
|
they often mean UID3, the identifier for a |
|
|
particular program. |
|
UID type |
A set of three UIDs that, in combination, |
13 |
|
identify a Symbian OS object. |
|
|
GLOSSARY |
345 |
Term |
Definition |
Chapter |
UID1 |
The first UID in a compound identifier (UID |
13 |
|
type). It identifies the general type of a |
|
|
Symbian OS object and can be thought of as |
|
|
a system-level identifier; for example |
|
|
executables, DLLs and file stores are all |
|
|
distinguished by UID1. |
|
UID2 |
The second UID in a compound identifier |
13 |
|
(UID type). It is used to distinguish within a |
|
|
type (e.g. between types of DLL) and can be |
|
|
thought of as an interface identifier. For |
|
|
example, static interface and polymorphic |
|
|
interface DLLs are distinguished by UID2. |
|
UID3 |
The third UID in a compound identifier |
13 |
|
(UID type). It identifies a particular subtype |
|
|
and can be thought of as a project identifier |
|
|
(for example, UID3 may be shared by all |
|
|
objects belonging to a given program, |
|
|
including library DLLs, framework DLLs, |
|
|
and all documents). |
|
Unicode |
A 16-bit character set that is used to assign |
5, 6 |
|
unique character codes for a wide range of |
|
|
languages. |
|