aBothe / Mono-D

D Add-In for MonoDevelop
http://wiki.dlang.org/Mono-D
Other
113 stars 26 forks source link

OSX and FreeBSD versions not recognized #526

Closed etcimon closed 10 years ago

etcimon commented 10 years ago

Both platforms are unrecognized by Mono-D and do not parse the codes under version(OSX) or version(FreeBSD)

aBothe commented 10 years ago

They are parsed but grayed out.

etcimon commented 10 years ago

Why gray them out?

aBothe commented 10 years ago

To let people see that these code regions aren't active yet.

etcimon commented 10 years ago

Let's say I'm developing under Mac OS X, shouldn't version(OSX) be active?

aBothe commented 10 years ago

sure, I'm trying to fix it

etcimon commented 10 years ago

Oh, great I thought you were saying it shouldn't be =)

aBothe commented 10 years ago

https://github.com/aBothe/D_Parser/blob/master/DParser2/Misc/VersionIdEvaluation.cs#L38 Although I'd expect it to work on OSX. Could you try to put in a breakpoint at that position?

etcimon commented 10 years ago

Hmm, would that be with gdb? I've never really tried debugging C# on a Mac

aBothe commented 10 years ago

nope, directly inside XS

etcimon commented 10 years ago

Um, so I clone the repo and compile it in XS?

http://stackoverflow.com/questions/10138040/how-to-detect-properly-windows-linux-mac-operating-systems

Oh look, apparently Mac returns Unix on a call to Environment.OSVersion.Platform

etcimon commented 10 years ago

Here's something

    //From Managed.Windows.Forms/XplatUI
    [DllImport ("libc")]
    static extern int uname (IntPtr buf);

    static bool IsRunningOnMac ()
    {
        IntPtr buf = IntPtr.Zero;
        try {
            buf = Marshal.AllocHGlobal (8192);
            // This is a hacktastic way of getting sysname from uname ()
            if (uname (buf) == 0) {
                string os = Marshal.PtrToStringAnsi (buf);
                if (os == "Darwin")
                    return true;
            }
        } catch {
        } finally {
            if (buf != IntPtr.Zero)
                Marshal.FreeHGlobal (buf);
        }
        return false;
    }

    static bool IsRunningOnFreeBSD ()
    {
        IntPtr buf = IntPtr.Zero;
        try {
            buf = Marshal.AllocHGlobal (8192);
            // This is a hacktastic way of getting sysname from uname ()
            if (uname (buf) == 0) {
                string os = Marshal.PtrToStringAnsi (buf);
                if (os == "FreeBSD")
                    return true;
            }
        } catch {
        } finally {
            if (buf != IntPtr.Zero)
                Marshal.FreeHGlobal (buf);
        }
        return false;
    }
etcimon commented 10 years ago

You might want to use uname() to find FreeBSD as well

aBothe commented 10 years ago

Not yet. I'll wait until someone actually uses MD under FreeBSD. Or did you? :P

etcimon commented 10 years ago

Heh, I was using it but it's the worst UI I've ever seen, I'll develop kqueue under mac instead

aBothe commented 10 years ago

:-D