, stdCallConv
, cCallConv
+ , defaultCallConv
, callConvAttribute
, decorateExtName
) where
cCallConv :: CallConv
cCallConv = 1
+
+defaultCallConv :: CallConv
+defaultCallConv = cCallConv
\end{code}
Generate the gcc attribute corresponding to the given
| C_CALL { $$ = CALLCONV_CCALL; }
| PASCAL { $$ = CALLCONV_PASCAL; }
| FASTCALL { $$ = CALLCONV_FASTCALL; }
-/* If you leave out the specification of a calling convention, you'll get C's. */
- | /*empty*/ { $$ = CALLCONV_CCALL; }
+/* If you leave out the specification of a calling convention, you'll (probably) get C's. */
+ | /*empty*/ { $$ = CALLCONV_NONE; }
;
ext_name: STRING { $$ = mkjust(lsing($1)); }
*/
/* FFI predefines */
+#define CALLCONV_NONE (-1)
#define CALLCONV_STDCALL 0
#define CALLCONV_CCALL 1
#define CALLCONV_PASCAL 2
[mod,nm] -> returnUgn (ExtName nm (Just mod))
rdCallConv :: Int -> UgnM CallConv
-rdCallConv x = returnUgn x
+rdCallConv x =
+ -- this tracks the #defines in parser/utils.h
+ case x of
+ (-1) -> -- no calling convention specified, use default.
+ returnUgn defaultCallConv
+ _ -> returnUgn x
rdForKind :: Int -> Bool -> UgnM ForKind
rdForKind 0 isUnsafe = -- foreign import