Nice work.
A few suggestions:
- You can move the file to C:\M0\Merlin\Main\Languages\Ruby\Libs.
- Use System::Environment:: System::Environment.OSVersion.Platform to
detect the OS (see e.g. Win32API.rb in Libs).
- Rather than check for the platform in every method it might be
better to define the methods differently on Windows. Something like:
module Etc
platform = System::PlatformID
case System::Environment.OSVersion.Platform
when platform.Win32S, platform.WinCE, platform.Win32Windows,
platform.Win32NT:
def self.endgrent; end
def self.endpwent; end
def self.getgrent; end
…
else
load_assembly 'Mono.Posix'
def self.endgrent
Mono::Unix::Native::Syscall.endgrent
end
def self.endpwent
Mono::Unix::Native::Syscall.endpwent
end
def self.getgrent
to_group(Mono::Unix::Native::Syscall.getgrent)
end
…
end
end
From: [email protected]
[mailto:[email protected]] On Behalf Of Ryan Riley
Sent: Saturday, April 03, 2010 3:59 PM
To: [email protected]
Subject: Re: [Ironruby-core] Anyone interested in implementing Etc module for
Mono?
I've posted an initial "complete" implementation, though I have only done basic
testing. I have a couple of TODO's remaining and some cleanup, as well as
writing actual specs. I still don't have tests running. You can find the module
here:
http://github.com/panesofglass/ironruby/blob/linux/Merlin/External.LCA_RESTRICTED/Languages/IronRuby/Etc/IronRuby.Libraries.Etc/etc.rb
Not the prettiest thing in the world, but I just wanted to get it working. I
definitely still have work to do.
Cheers,
Ryan Riley
Email: [email protected]<mailto:[email protected]>
LinkedIn: http://www.linkedin.com/in/ryanriley
Blog: http://wizardsofsmart.net/
Twitter: @panesofglass
Website: http://panesofglass.org/
On Sat, Apr 3, 2010 at 2:30 PM, Ryan Riley
<[email protected]<mailto:[email protected]>> wrote:
Sure!
Mono::Unix::Native::Passwd<http://www.go-mono.com/docs/index.aspx?link=T:Mono.Unix.Native.Passwd>
and
Mono::Unix::Native::Group<http://www.go-mono.com/docs/index.aspx?link=T:Mono.Unix.Native.Group>
that are returned from the
Mono::Unix::Native::Syscall<http://www.go-mono.com/docs/index.aspx?link=M:Mono.Posix.Syscall.getusername(System.Int32>
functions have UInt32, System.String, and System.String[]. System.String is no
biggie, and I'm finding .to_i on a System.UInt32 is still displayed as
System.UInt32, so I suppose that's not an issue, either. MRI displays Fixnum as
the type, and I was trying to get the correct types back from the functions.
That leaves MRI's Array to Mono's System.String[].
My current implementation is just a Ruby module wrapping calls to the Mono
functions and returning the appropriate types. Most of it is working, though
without being able to run tests easily, I'm testing from the command line. I
still need to add conditionals to return nil if it's run on Windows. I suppose
I also need to conditionally load the Mono.Posix.dll if it's on Windows, too.
I'm about to finish the basic implementation and post to
github<http://github.com/panesofglass/ironruby/blob/linux/Merlin/External.LCA_RESTRICTED/Languages/IronRuby/Etc/IronRuby.Libraries.Etc/etc.rb>.
(I've already got what I finished last night up there.) I also asked Shri for
a pairing session to make sure it's inline with what you're wanting.
Cheers,
Ryan Riley
Email: [email protected]<mailto:[email protected]>
LinkedIn: http://www.linkedin.com/in/ryanriley
Blog: http://wizardsofsmart.net/
Twitter: @panesofglass
Website: http://panesofglass.org/
On Sat, Apr 3, 2010 at 11:25 AM, Tomas Matousek
<[email protected]<mailto:[email protected]>> wrote:
Can you give an example of where you need the conversions?
Tomas
From:
[email protected]<mailto:[email protected]>
[mailto:[email protected]<mailto:[email protected]>]
On Behalf Of Jim Deville
Sent: Saturday, April 03, 2010 11:00 AM
To: [email protected]<mailto:[email protected]>
Subject: Re: [Ironruby-core] Anyone interested in implementing Etc module for
Mono?
No conversion for Fixnums is needed (Fixnums are ints). Arrays are harder. I
would take a look at clr_ext in merlin/main/languages/ruby/samples. Inside that
file is a to_clr_array method
JD
________________________________
From: Ryan Riley
<[email protected]<mailto:[email protected]>>
Sent: Saturday, April 03, 2010 12:13 AM
To: [email protected]<mailto:[email protected]>
<[email protected]<mailto:[email protected]>>
Subject: Re: [Ironruby-core] Anyone interested in implementing Etc module for
Mono?
Where is documentation on converting between CLR and Ruby types? I can get
RubyStrings, but what about Fixnum and Array?
Thanks,
Ryan Riley
_______________________________________________
Ironruby-core mailing list
[email protected]<mailto:[email protected]>
http://rubyforge.org/mailman/listinfo/ironruby-core
_______________________________________________
Ironruby-core mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/ironruby-core