Orion Edwards
2010-Jan-18 02:44 UTC
[Ironruby-core] Accessing classes defined in IronRuby.dll from within IronRuby (IronRuby 1.0RC1)
I''d like to use the IronRuby name mangling methods from within a script I''m writing, but it seems as though I can''t access things that are defined in IronRuby.dll? Reflector tells me that TryMangleName is a public static method on IronRuby.Runtime.RubyUtils, which is defined in IronRuby.dll. I''m trying to access it like this:> load_assembly ''IronRuby''=> true> System::AppDomain.current_domain.get_assemblies.each{|x| puts x}; nil...(snip) ... System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 IronRuby, Version=0.9.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 Microsoft.Scripting, Version=0.9.6.20, Culture=neutral, PublicKeyToken=31bf3856ad364e35 ...(snip) ... => nil> IronRuby::Runtime::RubyUtils.try_mangle_name("Foo")NameError: uninitialized constant IronRuby::Runtime> IronRuby::RuntimeNameError: uninitialized constant IronRuby::Runtime Is IronRuby treating it''s own dll''s specially? If so, is there any way I can get at the name mangling function? Thanks, Orion. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20100118/ff1238ba/attachment.html>
Jimmy Schementi
2010-Jan-18 02:56 UTC
[Ironruby-core] Accessing classes defined in IronRuby.dll from within IronRuby (IronRuby 1.0RC1)
load_assembly ''IronRuby'' will do the trick. Doing require ''ironruby'' will actually load the ironruby.rb in the ironruby library dir, but that file just warns that its not required to load that file, and doesn''t load any assemblies. We should probably just get rid of that file, or make it actually load the assembly. ~Jimmy On Jan 17, 2010, at 6:45 PM, "Orion Edwards" <orion.edwards at gmail.com<mailto:orion.edwards at gmail.com>> wrote: I''d like to use the IronRuby name mangling methods from within a script I''m writing, but it seems as though I can''t access things that are defined in IronRuby.dll? Reflector tells me that TryMangleName is a public static method on IronRuby.Runtime.RubyUtils, which is defined in IronRuby.dll. I''m trying to access it like this:> load_assembly ''IronRuby''=> true> System::AppDomain.current_domain.get_assemblies.each{|x| puts x}; nil...(snip) ... System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 IronRuby, Version=0.9.3.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35 Microsoft.Scripting, Version=0.9.6.20, Culture=neutral, PublicKeyToken=31bf3856ad364e35 ...(snip) ... => nil> IronRuby::Runtime::RubyUtils.try_mangle_name("Foo")NameError: uninitialized constant IronRuby::Runtime> IronRuby::RuntimeNameError: uninitialized constant IronRuby::Runtime Is IronRuby treating it''s own dll''s specially? If so, is there any way I can get at the name mangling function? Thanks, Orion. _______________________________________________ Ironruby-core mailing list Ironruby-core at rubyforge.org<mailto:Ironruby-core at rubyforge.org> http://rubyforge.org/mailman/listinfo/ironruby-core -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20100118/5da81c89/attachment.html>
Orion Edwards
2010-Jan-18 04:29 UTC
[Ironruby-core] Accessing classes defined in IronRuby.dll from within IronRuby (IronRuby 1.0RC1)
I am doing load_assembly ''IronRuby'', and it didn''t work (the example is copy/pasted pretty much verbatim). Not sure if that means your version of IR is different to mine, or what? Cheers, On Mon, Jan 18, 2010 at 3:56 PM, Jimmy Schementi < Jimmy.Schementi at microsoft.com> wrote:> load_assembly ''IronRuby'' will do the trick. >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20100118/edf99963/attachment.html>
Tomas Matousek
2010-Jan-18 06:23 UTC
[Ironruby-core] Accessing classes defined in IronRuby.dll from within IronRuby (IronRuby 1.0RC1)
IronRuby is a module already defined in standard library. It gives you access to a bunch of useful APIs, including name mangling:>>> IronRuby.singleton_methods=> ["configuration", "globals", "load", "loaded_assemblies", "loaded_scripts", "require", ''create_runtime'', ''create_engine'', ''create_ruby_setup'', ''get_engine'', ''require_file'', ''get_execution_context'']>>> IronRuby.constants=> ["Clr", "Print"]>>> IronRuby::Clr.constants=> ["BigInteger", "FlagEnumeration", "Float", "Integer", "MultiDimensionalArray", "String", "Name", "Scope"]>>> IronRuby::Clr::Name.singleton_methods(false)=> ["clr_to_ruby", "mangle", "ruby_to_clr", "unmangle"]>>> include IronRuby::Clr >>> Name.mangle("FooBar")=> "foo_bar">>> Name.unmangle("my_foo")=> "MyFoo" Re loading IronRuby.dll - the problem is that IronRuby is also a namespace in IronRuby.dll so there is a name conflict we don''t probably handle the best we could. Loading IronRuby.dll shouldn''t be a common scenario though. The best place for IronRuby specific functionality is in the IronRuby module. If you''re missing some let us know. Tomas From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Orion Edwards Sent: Sunday, January 17, 2010 8:29 PM To: ironruby-core at rubyforge.org Subject: Re: [Ironruby-core] Accessing classes defined in IronRuby.dll from within IronRuby (IronRuby 1.0RC1) I am doing load_assembly ''IronRuby'', and it didn''t work (the example is copy/pasted pretty much verbatim). Not sure if that means your version of IR is different to mine, or what? Cheers, On Mon, Jan 18, 2010 at 3:56 PM, Jimmy Schementi <Jimmy.Schementi at microsoft.com<mailto:Jimmy.Schementi at microsoft.com>> wrote: load_assembly ''IronRuby'' will do the trick. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20100118/1aa5b24b/attachment-0001.html>
Tomas Matousek
2010-Jan-18 06:35 UTC
[Ironruby-core] Accessing classes defined in IronRuby.dll from within IronRuby (IronRuby 1.0RC1)
BTW, if you really needed to get to IronRuby.dll''s types you can use this workaround:>>> Utils = System::Type.get_type(''IronRuby.Runtime.RubyUtils, IronRuby'').to_class=> IronRuby::Runtime::RubyUtils>>> Utils.try_unmangle_name("foo_bar")=> ''FooBar'' Tomas From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Tomas Matousek Sent: Sunday, January 17, 2010 10:24 PM To: ironruby-core at rubyforge.org Subject: Re: [Ironruby-core] Accessing classes defined in IronRuby.dll from within IronRuby (IronRuby 1.0RC1) IronRuby is a module already defined in standard library. It gives you access to a bunch of useful APIs, including name mangling:>>> IronRuby.singleton_methods=> ["configuration", "globals", "load", "loaded_assemblies", "loaded_scripts", "require", ''create_runtime'', ''create_engine'', ''create_ruby_setup'', ''get_engine'', ''require_file'', ''get_execution_context'']>>> IronRuby.constants=> ["Clr", "Print"]>>> IronRuby::Clr.constants=> ["BigInteger", "FlagEnumeration", "Float", "Integer", "MultiDimensionalArray", "String", "Name", "Scope"]>>> IronRuby::Clr::Name.singleton_methods(false)=> ["clr_to_ruby", "mangle", "ruby_to_clr", "unmangle"]>>> include IronRuby::Clr >>> Name.mangle("FooBar")=> "foo_bar">>> Name.unmangle("my_foo")=> "MyFoo" Re loading IronRuby.dll - the problem is that IronRuby is also a namespace in IronRuby.dll so there is a name conflict we don''t probably handle the best we could. Loading IronRuby.dll shouldn''t be a common scenario though. The best place for IronRuby specific functionality is in the IronRuby module. If you''re missing some let us know. Tomas From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Orion Edwards Sent: Sunday, January 17, 2010 8:29 PM To: ironruby-core at rubyforge.org Subject: Re: [Ironruby-core] Accessing classes defined in IronRuby.dll from within IronRuby (IronRuby 1.0RC1) I am doing load_assembly ''IronRuby'', and it didn''t work (the example is copy/pasted pretty much verbatim). Not sure if that means your version of IR is different to mine, or what? Cheers, On Mon, Jan 18, 2010 at 3:56 PM, Jimmy Schementi <Jimmy.Schementi at microsoft.com<mailto:Jimmy.Schementi at microsoft.com>> wrote: load_assembly ''IronRuby'' will do the trick. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20100118/66a3af3a/attachment.html>
Orion Edwards
2010-Jan-18 20:40 UTC
[Ironruby-core] Accessing classes defined in IronRuby.dll from within IronRuby (IronRuby 1.0RC1)
Thanks for that Tomas. I ended up copy/pasting the String#camelize and #underscore methods from rails as they were only a couple of lines long. This is probably less error prone than importing types from the IronRuby dll in the long run anyway :-) Cheers. On Mon, Jan 18, 2010 at 7:35 PM, Tomas Matousek < Tomas.Matousek at microsoft.com> wrote:> BTW, if you really needed to get to IronRuby.dll?s types you can use this > workaround: > > > > >>> Utils = System::Type.get_type(''IronRuby.Runtime.RubyUtils, > IronRuby'').to_class > > => IronRuby::Runtime::RubyUtils > > >>> Utils.try_unmangle_name("foo_bar") > > => ''FooBar'' > > > > Tomas > > > > *From:* ironruby-core-bounces at rubyforge.org [mailto: > ironruby-core-bounces at rubyforge.org] *On Behalf Of *Tomas Matousek > *Sent:* Sunday, January 17, 2010 10:24 PM > > *To:* ironruby-core at rubyforge.org > *Subject:* Re: [Ironruby-core] Accessing classes defined in IronRuby.dll > from within IronRuby (IronRuby 1.0RC1) > > > > IronRuby is a module already defined in standard library. It gives you > access to a bunch of useful APIs, including name mangling: > > > > >>> IronRuby.singleton_methods > > => ["configuration", "globals", "load", "loaded_assemblies", > "loaded_scripts", "require", ''create_runtime'', ''create_engine'', > ''create_ruby_setup'', ''get_engine'', ''require_file'', ''get_execution_context''] > > >>> IronRuby.constants > > => ["Clr", "Print"] > > >>> IronRuby::Clr.constants > > => ["BigInteger", "FlagEnumeration", "Float", "Integer", > "MultiDimensionalArray", "String", "Name", "Scope"] > > >>> IronRuby::Clr::Name.singleton_methods(false) > > => ["clr_to_ruby", "mangle", "ruby_to_clr", "unmangle"] > > >>> include IronRuby::Clr > > >>> Name.mangle("FooBar") > > => "foo_bar" > > >>> Name.unmangle("my_foo") > > => "MyFoo" > > > > Re loading IronRuby.dll ? the problem is that IronRuby is also a namespace > in IronRuby.dll so there is a name conflict we don?t probably handle the > best we could. Loading IronRuby.dll shouldn?t be a common scenario though. > The best place for IronRuby specific functionality is in the IronRuby > module. If you?re missing some let us know. > > > > Tomas > > > > *From:* ironruby-core-bounces at rubyforge.org [mailto: > ironruby-core-bounces at rubyforge.org] *On Behalf Of *Orion Edwards > *Sent:* Sunday, January 17, 2010 8:29 PM > *To:* ironruby-core at rubyforge.org > *Subject:* Re: [Ironruby-core] Accessing classes defined in IronRuby.dll > from within IronRuby (IronRuby 1.0RC1) > > > > I am doing load_assembly ''IronRuby'', and it didn''t work (the example is > copy/pasted pretty much verbatim). Not sure if that means your version of IR > is different to mine, or what? > > > > Cheers, > > On Mon, Jan 18, 2010 at 3:56 PM, Jimmy Schementi < > Jimmy.Schementi at microsoft.com> wrote: > > load_assembly ''IronRuby'' will do the trick. > > _______________________________________________ > Ironruby-core mailing list > Ironruby-core at rubyforge.org > http://rubyforge.org/mailman/listinfo/ironruby-core > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20100119/d2008f67/attachment.html>
Tomas Matousek
2010-Jan-18 21:09 UTC
[Ironruby-core] Accessing classes defined in IronRuby.dll from within IronRuby (IronRuby 1.0RC1)
They won''t probably work exactly the same way as IronRuby mangling though. So if you need this for CLR interop you should use IronRuby::Clr::Name class. Tomas From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Orion Edwards Sent: Monday, January 18, 2010 12:41 PM To: ironruby-core at rubyforge.org Subject: Re: [Ironruby-core] Accessing classes defined in IronRuby.dll from within IronRuby (IronRuby 1.0RC1) Thanks for that Tomas. I ended up copy/pasting the String#camelize and #underscore methods from rails as they were only a couple of lines long. This is probably less error prone than importing types from the IronRuby dll in the long run anyway :-) Cheers. On Mon, Jan 18, 2010 at 7:35 PM, Tomas Matousek <Tomas.Matousek at microsoft.com<mailto:Tomas.Matousek at microsoft.com>> wrote: BTW, if you really needed to get to IronRuby.dll''s types you can use this workaround:>>> Utils = System::Type.get_type(''IronRuby.Runtime.RubyUtils, IronRuby'').to_class=> IronRuby::Runtime::RubyUtils>>> Utils.try_unmangle_name("foo_bar")=> ''FooBar'' Tomas From: ironruby-core-bounces at rubyforge.org<mailto:ironruby-core-bounces at rubyforge.org> [mailto:ironruby-core-bounces at rubyforge.org<mailto:ironruby-core-bounces at rubyforge.org>] On Behalf Of Tomas Matousek Sent: Sunday, January 17, 2010 10:24 PM To: ironruby-core at rubyforge.org<mailto:ironruby-core at rubyforge.org> Subject: Re: [Ironruby-core] Accessing classes defined in IronRuby.dll from within IronRuby (IronRuby 1.0RC1) IronRuby is a module already defined in standard library. It gives you access to a bunch of useful APIs, including name mangling:>>> IronRuby.singleton_methods=> ["configuration", "globals", "load", "loaded_assemblies", "loaded_scripts", "require", ''create_runtime'', ''create_engine'', ''create_ruby_setup'', ''get_engine'', ''require_file'', ''get_execution_context'']>>> IronRuby.constants=> ["Clr", "Print"]>>> IronRuby::Clr.constants=> ["BigInteger", "FlagEnumeration", "Float", "Integer", "MultiDimensionalArray", "String", "Name", "Scope"]>>> IronRuby::Clr::Name.singleton_methods(false)=> ["clr_to_ruby", "mangle", "ruby_to_clr", "unmangle"]>>> include IronRuby::Clr >>> Name.mangle("FooBar")=> "foo_bar">>> Name.unmangle("my_foo")=> "MyFoo" Re loading IronRuby.dll - the problem is that IronRuby is also a namespace in IronRuby.dll so there is a name conflict we don''t probably handle the best we could. Loading IronRuby.dll shouldn''t be a common scenario though. The best place for IronRuby specific functionality is in the IronRuby module. If you''re missing some let us know. Tomas From: ironruby-core-bounces at rubyforge.org<mailto:ironruby-core-bounces at rubyforge.org> [mailto:ironruby-core-bounces at rubyforge.org<mailto:ironruby-core-bounces at rubyforge.org>] On Behalf Of Orion Edwards Sent: Sunday, January 17, 2010 8:29 PM To: ironruby-core at rubyforge.org<mailto:ironruby-core at rubyforge.org> Subject: Re: [Ironruby-core] Accessing classes defined in IronRuby.dll from within IronRuby (IronRuby 1.0RC1) I am doing load_assembly ''IronRuby'', and it didn''t work (the example is copy/pasted pretty much verbatim). Not sure if that means your version of IR is different to mine, or what? Cheers, On Mon, Jan 18, 2010 at 3:56 PM, Jimmy Schementi <Jimmy.Schementi at microsoft.com<mailto:Jimmy.Schementi at microsoft.com>> wrote: load_assembly ''IronRuby'' will do the trick. _______________________________________________ Ironruby-core mailing list Ironruby-core at rubyforge.org<mailto:Ironruby-core at rubyforge.org> http://rubyforge.org/mailman/listinfo/ironruby-core -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20100118/a1f9d9ca/attachment-0001.html>