Next Previous Contents

4.10 Off-line attribute specification

As an alternate mechanism to specifying the IDL attributes that are associated with a type / method, HaskellDirect has got Attribute Specification Files (ASF).

Instead of specifying the attribute list in the input itself, you give the hierarchic name of the IDL name you want to configure along with the attributes you want to associate. For instance, if you feed the compiler the IDL declaration:

char* getenv(char*);

there's no telling what kind of pointer values are being passed or returned here. So, if you additionally supply the ASF information:

getenv : [string,nofree]
getenv.arg1 : [in,string]

it will be processed as if you'd written

[string,nofree]char* getenv([in,string]char*);

causing the HaskellDirect to give the getenv() stub the following (friendly) signature:

getenv :: String -> IO String

An ASF file is specified on the command line using the --asf=file option. The syntax is simply a sequence of line-separated name, attribute pairs, i.e.,

asf : {- empty -}   { [] }
    | asf att_pair  { $2 : $1 }

att_pair : ATTRIB_NAME ':' attributes { ($1,False,$3) }
         | ATTRIB_NAME '=' attributes { ($1,True,$3) }

An attribute pair can either augment the list of attributes associated with an IDL name, or replace it. ":" does the former, while "=" replaces. Unless you have good reasons not to, stick with ":".

Notice: parameters to a method/procedure can either be referenced by name or position, i.e.,

f.arg1 : [in]
f.sz   : [in]

both refer to the first argument of int f(int sz);.


Next Previous Contents