|
Navigation: Programming Cookbook > External Interfacing > External Field Types > Scalar Fields |
![]() ![]()
|
Scalar fields are essentially the familiar base types of C and C++. We have chosen to use the Windows™ names for these types because they are independent of machine word size. So, for example, there are BOOLFields to represent boolean values, and WORDFields to represent unsigned 16-bit integers. These types are straightforward to use, and there are very many example in the system (e.g. LOGBRUSH). The complete set of ScalarFields defined at the time of writing is listed in the following table:
ExternalField Class |
C type(s) |
Description |
BOOLField |
BOOL |
32-bit integer interpreted as TRUE if non-zero |
BYTEField |
BYTE |
Unsigned 8-bit integer |
DOUBLEField |
double |
64-bit double precision IEEE Float |
DWORDField |
DWORD, UINT |
32-bit unsigned integer |
HANDLEField |
HANDLE, HWND, etc |
32-bit opaque handle types, e.g. |
LPVOIDField |
void* |
Generic pointer/address field (see Address Fields) |
FLOATField |
float |
32-bit single precision IEEE Float |
QWORDField |
unsigned __int64 |
Unsigned 64-bit integer |
SBYTEField |
SBYTE |
Signed 8-bit integer |
SDWORDField |
SDWORD, int |
32-bit signed integer |
SQWORDField |
__int64 |
64-bit signed integer |
SWORDField |
SWORD |
16-bit signed integer |
WORDField |
WORD |
16-bit unsigned integer |
Address Fields
The most quirky scalar field type is LPVOIDField, which is used when one wants to access the pointers stored in structures as pointers, rather than the object pointed at by the pointer! Typically one does not want to worry about the indirection, and so one should employ pointer fields that automatically de-reference the pointer so that one can work with objects instead of addresses.
An example can be found in the EDITSTREAM structure used with the Rich Edit control, which stores down a function pointer (into which we store an ExternalCallback):
defineFields
"Define the fields of the Win32 EDITSTREAM structure.
EDITSTREAM compileDefinition
typedef struct _editstream {
DWORD dwCookie;
DWORD dwError;
EDITSTREAMCALLBACK pfnCallback;
} EDITSTREAM;"
self
defineField: #dwCookie type: DWORDField writeOnly;
defineField: #dwError type: DWORDField filler;
defineField: #pfnCallback type: LPVOIDField writeOnly