
Adobe Acrobat SDK
Working with Host Function Tables
Developing Plug-ins and Applications
Creating HFT method definitions 167
Defining function prototypes
After you define an enumeration and an HFT object, you can define a function pointer for each method by
using the following syntax:
typdef ACCBPROTO1 return_type (ACCBPROTO2
*function_nameSELPROTO)(parameters);
The following table describes this syntax.
For example, to define a function pointer to the
BeepNTimes
method, specify the following syntax:
typedef ACCBPROTO1 void (ACCBPROTO2 *BeepNTimesSELPROTO)(ASInt32 numtimes);
ACCBPROTO1
and
ACCBPROTO2
are macros whose definitions are platform-specific (for example, in Mac
OS,
ACCBPROTO1
is defined as
pascal
).
BeepNTimesSELPROTO
specifies a pointer to the
BeepNTimes
method. Without using these macros, you would have to use the following syntax:
typedef void (*func)(ASInt32 numtimes);
Defining an HFT method name
You must specify a name for each method that is used to invoke the HFT method from other plug-ins. You
can define an HFT method name by using the following syntax:
#define method_name (*((method_nameSELPROTO)(HFTname [method_nameSEL])))
The following table describes this syntax.
For example, to define a method name for the
BeepNTimesImplementation
method, specify the
following:
#define BeepNTimes (*((BeepNTimesSELPROTO)(gMyHFT[BeepNTimesSEL])))
This macro defines the symbol
BeepNTimes
, which is the HFT method name.
gMyHFT[BeepNTimesSEL]
is the function pointer obtained by indexing the HFT and
BeepNTimesSELPROTO
casts the pointer to the right type. The end result is that the method can be
invoked by specifying the HFT method name:
BeepNTimes(3);
HFT method names and the implementation method names must be different to avoid conflict between
the
#define
statement and the corresponding method name.
return_type
The return type of the HFT method.
function_name
The name of the HFT method.
parameters
The HFT method’s parameters with their types.
method_name
The name of the HFT method that is used to invoke the method from external
plug-ins.
HFTname
The name of the HFT object.