[MLton-commit] r6827
Matthew Fluet
fluet at mlton.org
Mon Sep 1 06:19:42 PDT 2008
Be less cryptic about symbol pasting.
----------------------------------------------------------------------
U mlton/trunk/mlton/atoms/ffi.fun
----------------------------------------------------------------------
Modified: mlton/trunk/mlton/atoms/ffi.fun
===================================================================
--- mlton/trunk/mlton/atoms/ffi.fun 2008-09-01 13:19:38 UTC (rev 6826)
+++ mlton/trunk/mlton/atoms/ffi.fun 2008-09-01 13:19:41 UTC (rev 6827)
@@ -55,15 +55,23 @@
List.foreach
(!symbols, fn {name, ty, symbolScope} =>
let
- val symbolScope =
- case symbolScope of
+ val (headerSymbolScope, symbolScope) =
+ case symbolScope of
SymbolScope.External =>
Error.bug "Ffi.declareExports.symbols: External"
- | SymbolScope.Private => "INTERNAL "
- | SymbolScope.Public => "EXPORTED "
- val decl = symbolScope ^ CType.toString ty ^ " " ^ name;
+ | SymbolScope.Private => ("MLLIB_INTERNAL", "INTERNAL")
+ | SymbolScope.Public => ("MLLIB_EXPORTED", "EXPORTED")
+ val headerDecl =
+ concat ["extern", " ",
+ headerSymbolScope, " ",
+ CType.toString ty, " ",
+ name]
+ val decl =
+ concat [symbolScope, " ",
+ CType.toString ty, " ",
+ name]
in
- List.push (headers, "extern MLLIB_" ^ decl);
+ List.push (headers, headerDecl);
print (decl ^ ";\n")
end);
List.foreach
@@ -80,13 +88,14 @@
concat ["\tlocalOpArgsRes[", Int.toString (i + 1), "] = ",
"(Pointer)(&", x, ");\n"])
end)
- val header =
- concat [case symbolScope of
- SymbolScope.External =>
- Error.bug "Ffi.declareExports.exports: External"
- | SymbolScope.Private => "INTERNAL "
- | SymbolScope.Public => "EXPORTED ",
- case res of
+ val (headerSymbolScope, symbolScope) =
+ case symbolScope of
+ SymbolScope.External =>
+ Error.bug "Ffi.declareExports.exports: External"
+ | SymbolScope.Private => ("MLLIB_INTERNAL","INTERNAL")
+ | SymbolScope.Public => ("MLLIB_EXPORTED","EXPORTED")
+ val prototype =
+ concat [case res of
NONE => "void"
| SOME t => CType.toString t,
if convention <> Convention.Cdecl
@@ -101,8 +110,8 @@
1 + (Vector.length args)
+ (case res of NONE => 0 | SOME _ => 1)
in
- List.push (headers, "MLLIB_" ^ header)
- ; print (concat [header, " {\n"])
+ List.push (headers, concat [headerSymbolScope, " ", prototype])
+ ; print (concat [symbolScope, " ", prototype, " {\n"])
; print (concat ["\tPointer localOpArgsRes[", Int.toString n,"];\n"])
; print (concat ["\tMLton_FFI_opArgsResPtr = (Pointer)(localOpArgsRes);\n"])
; print (concat ["\tInt32 localOp = ", Int.toString id, ";\n",
More information about the MLton-commit
mailing list