[Ironruby-core] .Net<->IR Object Mapping

Jim Deville jdeville at microsoft.com
Tue Jun 9 12:18:23 EDT 2009


That should work:

[302] > rbr
IronRuby 0.5.0.0 on .NET 2.0.50727.4918
Copyright (c) Microsoft Corporation. All rights reserved.

>>> require 'fixtures.generated'
=> true
>>> c = ClassWithMethods.new
=> ClassWithMethods
>>> c.private_method
:0: undefined method `private_method' for ClassWithMethods:ClassWithMethods (NoMethodError)

>>> c.private_methods
=> ["initialize", "`", "abort", "Array", "at_exit", "autoload", "autoload?", "binding", "block_given?", "caller", "catch", "eval", "exec", "exit", "exit!", "fail", "Float", "format", "getc", "gets", "global_variables", "initialize_copy", "Integer", "iterator?", "lambda", "load", "load_assembly", "local_variables", "loop", "method_missing", "open", "p", "print", "printf", "proc", "putc", "puts", "raise", "rand", "remove_instance_variable", "require", "select", "set_trace_func", "singleton_method_added", "singleton_method_removed", "singleton_method_undefined", "sleep", "sprintf", "String", "system", "throw", "trap", "warn"]
>>> c.method(:private_method)
:0:in `method': undefined method `private_method' for class `ClassWithMethods' (NameError)
        from :0

>>> exit
C:\vsl\Merlin\Main\Languages\Ruby\Tests\Interop\net
[303] > rbr "-X:PrivateBinding"
IronRuby 0.5.0.0 on .NET 2.0.50727.4918
Copyright (c) Microsoft Corporation. All rights reserved.

>>> require 'fixtures.generated'
=> true
>>> c = ClassWithMethods.new
=> ClassWithMethods
>>> c.private_method
=> 'private'
>>> c.private_methods
=> ["initialize", "`", "abort", "Array", "at_exit", "autoload", "autoload?", "binding", "block_given?", "caller", "catch", "eval", "exec", "exit", "exit!", "fail", "Float", "format", "getc", "gets", "global_variables", "initialize_copy", "Integer", "iterator?", "lambda", "load", "load_assembly", "local_variables", "loop", "method_missing", "open", "p", "print", "printf", "proc", "putc", "puts", "raise", "rand", "remove_instance_variable", "require", "select", "set_trace_func", "singleton_method_added", "singleton_method_removed", "singleton_method_undefined", "sleep", "sprintf", "String", "system", "throw", "trap", "warn"]
>>> c.method(:private_method)
=> #<Method: ClassWithMethods#private_method>
>>> c.method(:private_method).call
=> 'private'
>>> c.method(:private_method)[]
=> 'private'
>>> exit
C:\vsl\Merlin\Main\Languages\Ruby\Tests\Interop\net
[304] >


If you want to try with this class, it is defined in the fixtures.generated.dll assembly in Merlin\Main\Languages\Ruby\Tests\Interop\net

Thanks,
JD

...there is no try


> -----Original Message-----
> From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-
> bounces at rubyforge.org] On Behalf Of Shay Friedman
> Sent: Tuesday, June 09, 2009 8:39 AM
> To: ironruby-core at rubyforge.org
> Subject: Re: [Ironruby-core] .Net<->IR Object Mapping
>
> I assumed a reflection like behavior... For example, doing something
> like:
> klass.method(:MyPrivateClrMethod).call
>
> Can you write a simple example of what you've described?
>
> Thanks,
> Shay.
>
> ----------------------------
> http://www.ironshay.com
> Follow me: http://twitter.com/ironshay
> --
> Posted via http://www.ruby-forum.com/.
> _______________________________________________
> Ironruby-core mailing list
> Ironruby-core at rubyforge.org
> http://rubyforge.org/mailman/listinfo/ironruby-core



More information about the Ironruby-core mailing list