Like any self-respecting compiler ;-), the IDL compiler supports a fair number of options for tweaking the output generated:
--include-header=<file>
When compiling HaskellDirect-generated code, a C compiler is normally involved. For the C stubs generated for Hugs, that's definitely the case, and a C compiler is also involved when using GHC (native code generators aren't quite there.)
In the case of Hugs C stubs (see
Section
Compiling Hugs stubs
for more details), prototypes and type definitions specific
to the API will need to be in scope for the C compiler to operate.
For GHC compiled code, you may also need to do this (i.e., you're not
using GHC's -femit-extern-decls option) to have the C
compiler use the right calling convention.
To have a header file be included in either scenario, use
--include-header="foo.h" or the HaskellDirect-supported
IDL extension stub_include:
stub_include <foo.h>;
stub_include "bar.h";
--include-c-header=<file>
Closely related to the previous option, but
--include-c-header=<file> only include
file in any generated C stubs (including
generated header files.)
-fcompress-enums
IDL enum declarations lets you provide a mapping between
symbolic name and an int tag values. Mapping these into
Haskell requires the generation of a Haskell enumeration data type
along with an Enum instance for the type.
By default, HaskellDirect will spot whether it can make use of Haskell's
deriving declaration to have the Haskell system automatically
generate the Enum instance, i.e., if the enum's tag sequence
is of the form [0,1,2. ...].
By supplying the option -fcompress-enums, HaskellDirect will
try to spot other common progressions and generate
GHC-specific Enum instances which maps to and from
tag values and their Haskell equivalent data constructor tags without
wasting lots of code space.
-fone-mod-per-iface
This option causes the generated stubs to be split up into one module per interface encountered in the input.
-fno-export-list
For each Haskell module generated, don't generate an export list. The effect of this option is to export everything.
-fexport-with-tysig
If generated, augment the export list with the types of the functions being exported. Sometimes a useful way to document what's on offer from a Haskell module.
-fexport-abstractly
The default is to export the types in the generated Haskell module,
non-abstractly, i.e., the data constructors can be seen (and used)
outside of the module boundaries. To turn this default behaviour
off, use -fexport-abstractly.
There's currently no way of specifying on a per IDL type basis whether its Haskell type should be exported or not - just all or nothing.
-fno-module-header
Leave out the Haskell module header entirely. You may want to
do this if you supply your own using an hs_quote()
declaration.
-fno-import-lists
Generate Haskell import declarations, but don't include list of exactly what is being imported. The default behaviour is to include the import lists.
In case you're processing large IDL specifications, one way to cut
down the compilation time is to use -fno-import-lists, since
it saves having to make a separate pass over the Haskell code (about
to be) generated.
-fno-imports
Don't generate any import declarations at all -- let the user supply them separately.
-fno-qualified-names
The default is for the generated Haskell source to refer to the
imported types and values by their qualified names, so as to
eliminate any potential name clashes. The -fno-qualified-names
option disables this behaviour.
-fno-share-ffi-decls
By default, HaskellDirect tries to re-use foreign import
declarations within a module. If two methods/functions map down to
a foreign import declaration with the same type (and calling
convention), only one declaration will be generated.
In some cases, this significantly reduces the number of FFI decls
that need to be generated, but should you want to turn off this
`smart', use -fno-share-ffi-decls.
-fout-pointers-are-not-refs
OSF DCE IDL (and Microsoft's implementation of it) has the restriction
that [out] parameters have to be references (at the
toplevel). -fout-pointers-are-not-refs relaxes this
(sensible) restriction, and is useful if you want to return a result
but not unmarshall it into Haskell. Having [out]
parameters return references is still possible with this option turned on,
but you now have to be explicit about it.
-fuse-ints-everywhere
Don't try to make use of the sized integer types that the Hugs/GHC
interfaces Int and Word provide. Instead, just stick
with good old Int throughout.
-fint-is-int
By default the mapping for the IDL type int is Int32 (on
32-bit platforms). Use -fint-is-int to have it map to Int
instead.
-fint-prelude-coercions
Up until recently, both GHC and Hugs exported the functions
toInt and fromInt via the Prelude. GHC has with 4.04
stopped doing so, providing these two now via the Int
interface instead. HaskellDirect-generated code will by default
assume that Int is where these guys live. (the Sept99 release
of Hugs98 exports them through Int as well as through the
Prelude.)
Should your Haskell system insist that you pick toInt and
fromInt from the Prelude instead, use -fint-prelude-coercions
to achieve the desired effect.
-fint-as-word
Oops, use of the previous option will still run the risk of generating
uses of Word, a ghc specific type representing unsigned
Ints. To coerce these guys into Int as well, use
-fint-as-word.
Notice that the marshalling library that HaskellDirect supplies makes
use of the numeric types provided by the Int and
Word interfaces, so your quest to create 'Ints-everywhere'
world view may not be complete with the addition of
-fint-as-word and -fuse-ints-everywhere to your
command line...(I guess what I'm trying to say is that these two
options haven't been put to extensive use!)
-fignore-helpstrings
The default is for the help strings that are supplied with the
helpstring() attribute to be included in the generated
Haskell source next to the method the help comment applies to.
Should that annoy you, use -fignore-helpstrings to
turn it off.
-fignore-hidden-methods
Don't generated any code for methods that have the attribute
hidden pinned onto them.
Note: As an IDL extension, HaskellDirect supports the ignore
attribute. It has the same effect as the use of hidden
coupled with the use of -fignore-hidden-methods.
-fignore-restricted-methods
Don't generated any code for methods that have the attribute
restricted pinned onto them.
-fno-qualified-instance-methods
If qualified names are to be used in the generated source, turn off the use of qualified names for method in instance declarations. This is required if you're targetting Hugs, but not if you're working with GHC (where it's required that you don't use this option ;-) With respect to the Haskell 98 standard, GHC is the one behaving correctly.
-fignore-source-interfaces
Some interfaces are marked as being ``source'' interfaces, i.e., in the case we're generating client COM stubs, interfaces that the client is supposed to implement (e.g., out-going event interfaces.)
If the client context is either not interested in these interfaces or
simply doesn't support them, use -fignore-source-interfaces
to avoid emitting any code for these.
Notice that HaskellDirect doesn't support the generation of code that
lets you implement COM components in Hugs, so uses of --hugs
implies -fignore-source-interfaces.
-flonglong-as-integer
Hugs doesn't support fully support the Int64 type, so if the
functions/methods you interface to makes use of long long,
use -flonglong-as-integer to have long longs map
to Integer on the Haskell side.
-fno-dependent-args
Experimental option for turning off the special handling of dependent fields/parameters that HaskellDirect performs.
-fclassic-name-mangling
By default, IDL names are converted into Haskell type or variable
names by changing the casing on the initial letter. For example,
iDL_NAME goes to IDL_NAME, if the name represents a
Haskell type/class/module name, but stays as iDL_NAME if
not. An alternative mapping is provided by the
-fclassic-name-mangling option, which will transform
iDL_NAME into either idlName or IdlName,
depending. That is, a sequence of all-upper case letters terminated by
an underscore (or end of name) is converted into a capitalised word,
and the underscore is removed. Some people like that better.
--unsafe-calls
The GHC/Hugs FFI makes the distinction between safe and unsafe
calls to the outside world. By default, HaskellDirect generates
call-outs of the safe kind, but by using --unsafe-calls,
it'll do the opposite.
-fpattern-as-lambda
The Haskell function definitions generated by the IDL compiler will by default bind function arguments using pattern variables, e.g.,
methFoo x y = ...
The -fpattern-as-lambda option transfers the argument binders
to the right hand side,
methFoo = \ x \ y -> ...
which is compatible with some people's programming style.
-funwrap-singleton-structs
Tell the compiler to treat IDL struct types with only a single
field as being equal to the type of that field.
-fremove-empty-structs
If the input contains empty struct declarations, e.g.,
"typedef struct foo bar", simply ignore these.