[m-rev.] diff: fix standard library compilation in C# grade
Julien Fischer
jfischer at opturion.com
Tue Mar 8 22:43:22 AEDT 2022
Fix standard library compilation in C# grade.
library/io.environment.m:
Fully qualify a call to a foreign_exported Mercury predicate in order to
avoid an error if its containing foreign_proc is inlined across module
boundaries.
library/io.file.m:
Fully qualify some foreign_exported enum constants for the same reason.
Add missing using directives.
Add a missing definition needed by Mono.
library/io.m:
Delete trailing whitespace.
Delete code moved to io.file.m.
Julien.
diff --git a/library/io.environment.m b/library/io.environment.m
index d111eb2..2c22a7f 100644
--- a/library/io.environment.m
+++ b/library/io.environment.m
@@ -189,7 +189,8 @@ get_environment_var_map(EnvVarMap, !IO) :-
foreach (System.Collections.DictionaryEntry entry in env) {
string name = (string) entry.Key;
string value = (string) entry.Value;
- EnvVarAL = ML_record_env_var_and_value(name, value, EnvVarAL);
+ EnvVarAL = mercury.io__environment.ML_record_env_var_and_value(name,
+ value, EnvVarAL);
}
").
diff --git a/library/io.file.m b/library/io.file.m
index dce172d..f0470c9 100644
--- a/library/io.file.m
+++ b/library/io.file.m
@@ -1040,18 +1040,18 @@ file_type(FollowSymLinks, FileName, Result, !IO) :-
if ((attrs & System.IO.FileAttributes.Directory) ==
System.IO.FileAttributes.Directory)
{
- FileType = io.ML_FILE_TYPE_DIRECTORY;
+ FileType = mercury.io__file.ML_FILE_TYPE_DIRECTORY;
}
else if ((attrs & System.IO.FileAttributes.Device) ==
System.IO.FileAttributes.Device)
{
// XXX It may be a block device, but .NET doesn't
// distinguish between character and block devices.
- FileType = io.ML_FILE_TYPE_CHARACTER_DEVICE;
+ FileType = mercury.io__file.ML_FILE_TYPE_CHARACTER_DEVICE;
}
else
{
- FileType = io.ML_FILE_TYPE_REGULAR_FILE;
+ FileType = mercury.io__file.ML_FILE_TYPE_REGULAR_FILE;
}
Error = null;
} catch (System.Exception e) {
@@ -1503,6 +1503,23 @@ make_temp_directory(Dir, Prefix, Suffix, Result, !IO) :-
long ML_io_tempnam_counter = 0;
").
+:- pragma foreign_decl("C#", "
+using System;
+using System.IO;
+using System.Runtime.InteropServices;
+using System.Security.AccessControl;
+using System.Security.Principal;
+").
+
+:- pragma foreign_code("C#", "
+#if __MonoCS__
+ // int chmod(const char *path, mode_t mode);
+ [DllImport(""libc"", SetLastError=true, EntryPoint=""mkdir"",
+ CallingConvention=CallingConvention.Cdecl)]
+ static extern int ML_sys_mkdir (string path, uint mode);
+#endif
+").
+
:- pragma foreign_decl("Java", local, "
import java.io.File;
import java.io.IOException;
diff --git a/library/io.m b/library/io.m
index 793ffa4..1a7ad2e 100644
--- a/library/io.m
+++ b/library/io.m
@@ -1528,21 +1528,21 @@
% NOTE_TO_IMPLEMENTORS are removed. However, while the forwarding predicates
% NOTE_TO_IMPLEMENTORS are here, the types that some of them depend on
% NOTE_TO_IMPLEMENTORS should be here as well.
-% NOTE_TO_IMPLEMENTORS
+% NOTE_TO_IMPLEMENTORS
% NOTE_TO_IMPLEMENTORS Keeping the definitions of these types here suits both
% NOTE_TO_IMPLEMENTORS old code and new code.
-% NOTE_TO_IMPLEMENTORS
+% NOTE_TO_IMPLEMENTORS
% NOTE_TO_IMPLEMENTORS - Old code can call all the forwarding predicates,
% NOTE_TO_IMPLEMENTORS and pass them values of these types, while importing
% NOTE_TO_IMPLEMENTORS only io.m.
-% NOTE_TO_IMPLEMENTORS
+% NOTE_TO_IMPLEMENTORS
% NOTE_TO_IMPLEMENTORS - New code using io.file.m must also import io.m anyway,
% NOTE_TO_IMPLEMENTORS not just because io.m is io.file.m's parent
% NOTE_TO_IMPLEMENTORS (a requirement that we may eliminate in the future),
% NOTE_TO_IMPLEMENTORS but because all the operations in io.file.m take
% NOTE_TO_IMPLEMENTORS a pair of I/O state arguments, and the I/O state type
% NOTE_TO_IMPLEMENTORS is defined here.
-% NOTE_TO_IMPLEMENTORS
+% NOTE_TO_IMPLEMENTORS
% NOTE_TO_IMPLEMENTORS On the other hand, if we moved the definitions of
% NOTE_TO_IMPLEMENTORS these types to io.file.m, new code would still work,
% NOTE_TO_IMPLEMENTORS but old code would break immediately, in a way that
@@ -3520,12 +3520,6 @@ using System.Security.Principal;
static readonly System.Text.Encoding text_encoding =
new System.Text.UTF8Encoding(false);
-#if __MonoCS__
- // int chmod(const char *path, mode_t mode);
- [DllImport(""libc"", SetLastError=true, EntryPoint=""mkdir"",
- CallingConvention=CallingConvention.Cdecl)]
- static extern int ML_sys_mkdir (string path, uint mode);
-#endif
").
:- pragma foreign_code("C#", "
More information about the reviews
mailing list