[m-dev.] for review: add MC++ implementation of library and runtime
Tyson Dowd
trd at cs.mu.OZ.AU
Wed Dec 20 16:44:09 AEDT 2000
On 10-Dec-2000, Fergus Henderson <fjh at cs.mu.OZ.AU> wrote:
> On 04-Dec-2000, Tyson Dowd <trd at cs.mu.OZ.AU> wrote:
> > +% io__do_open(File, Mode, ResultCode, Stream, IO0, IO1).
> > +% Attempts to open a file in the specified mode.
> > +% ResultCode is 0 for success, -1 for failure.
> > +:- pragma foreign_code("MC++",
> > + io__do_open(FileName::in, Mode::in, ResultCode::out,
> > + Stream::out, IO0::di, IO::uo),
> > + [will_not_call_mercury, thread_safe],
> > +"
> > + MR_MercuryFile mf = mercury_open(FileName, Mode);
> > + MR_c_pointer_to_word(Stream, mf);
> > + update_io(IO0, IO);
> > +").
>
> That needs to set ResultCode.
This is another cvs diff bug --
ResultCode = (mf ? 0 : -1);
was there all along (I promise).
>
> > +:- pragma foreign_code("MC++",
> > + io__get_exit_status(ExitStatus::out, IO0::di, IO::uo),
> > + will_not_call_mercury, "
> > + ExitStatus = System::Environment::get_ExitCode();
> > + MR_Runtime::SORRY(""foreign code for this function"");
> > + update_io(IO0, IO);
> > +").
>
> Is the call to SORRY() there needed?
> If so, best to put it at the start, rather than in the middle.
No, it shouldn't be there.
>
> > +:- pragma foreign_code("C",
> > + library__version(Version::out), will_not_call_mercury,
> > +"
> > MR_ConstString version_string =
> > MR_VERSION "", configured for "" MR_FULLARCH;
> > /*
> ...
> > +:- pragma foreign_code("MC++",
> > + library__version(Version::out), will_not_call_mercury,
> > +"
> > + Version = String::Concat(MR_VERSION,
> > + "", configured for "", MR_FULLARCH);
> > ").
>
> Doesn't ANSI C string literal concatenation work in MC++?
Fixed.
Although strictly speaking I'm going to have to change this to
use S"stringbody" style string literals (this makes it a System::String
instead of a char *). But that didn't work straight away.
>
> library/math.m:
> > +:- pragma foreign_decl("MC++", "
> >
> > + // This is not defined in the .NET Frameworks.
> > +
> > + #define ML_FLOAT_LN2 0.69314718055994530941
> > +").
>
> I don't understand the comment here.
> Why is the code here different for MC++ than it is for C?
> The code for C defines ML_FLOAT_E and ML_FLOAT_PI too.
e and pi are defined in the .NET Math class, but ln2 isn't.
I used e and pi from the .NET Math class.
I thought this would be a better choice, since it would be nice if our
pi corresponded exactly with pi in other languages.
> > + static int MR_SECTAG_NONE = 0;
> > + static int MR_SECTAG_LOCAL = 1;
> > + static int MR_SECTAG_REMOTE = 2;
>
> Please put comments at the definitions of the corresponding
> enums in the runtime directory saying that they are duplicated here.
Ok, done.
> If you prefer I'm happy to commit all these fixes for the MC++ versions
> of all-solutions stuff as a separate change.
It's fine, I've done them now.
--
Tyson Dowd #
# Surreal humour isn't everyone's cup of fur.
trd at cs.mu.oz.au #
http://www.cs.mu.oz.au/~trd #
--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to: mercury-developers at cs.mu.oz.au
Administrative Queries: owner-mercury-developers at cs.mu.oz.au
Subscriptions: mercury-developers-request at cs.mu.oz.au
--------------------------------------------------------------------------
More information about the developers
mailing list