Re: [Ironruby-core] IronRuby DynamicObject.TryGetMember returning null

2011-09-09 Thread Benjamin Joldersma
Heads up, looks like this applies to the Expando object as well, here's 
an even simpler gist:

https://gist.github.com/1205646

-- 
Posted via http://www.ruby-forum.com/.
___
Ironruby-core mailing list
Ironruby-core@rubyforge.org
http://rubyforge.org/mailman/listinfo/ironruby-core


Re: [Ironruby-core] IronRuby DynamicObject.TryGetMember returning null

2011-09-09 Thread Jimmy Schementi
Try implementing TryInvokeMember.

In IronRuby d.foo actually gets and invokes foo, so it will use 
DynamicObject's TryInvokeMember. This is different from IronPython and C# where 
method calls are two operations: TryGetMember (d.Foo) and TryInvoke (d.Foo()). 
The rough IronRuby equivalent to this is d.method(:foo).call().

~js

On Sep 9, 2011, at 2:45 AM, Benjamin Joldersma wrote:

 I am working with IronRuby and a DynamicObject derived class to create a
 proxy layer for a game scripting engine that allows me to intercept gets
 and sets and do things like mark objects for saving, potentially
 security checks, etc.
 
 But I'm finding that if my TryGetMember returns true, but sets the out
 result param to null, then IronRuby seems to hang indefinitely.
 
 I've created a pretty concise repro case here:
 
 https://gist.github.com/1205629
 
 can anyone shed some insight into this problem?  So far, I'm loving
 IronRuby.
 
 best,
 
 --ben joldersma
 
 -- 
 Posted via http://www.ruby-forum.com/.
 ___
 Ironruby-core mailing list
 Ironruby-core@rubyforge.org
 http://rubyforge.org/mailman/listinfo/ironruby-core

___
Ironruby-core mailing list
Ironruby-core@rubyforge.org
http://rubyforge.org/mailman/listinfo/ironruby-core


Re: [Ironruby-core] IronRuby DynamicObject.TryGetMember returning null

2011-09-09 Thread Benjamin Joldersma
Okay, very interesting stuff.  I had seen you and others suggest that in 
other places, but I thought I was insulated from it, because I *was* 
implementing TryInvokeMember!  After further examination, I seem to have 
stumbled to a solution.

In my actual code, I was trying to return a function delegate in the 
TryGetMember, when the member in question is a method.  I think that 
this, coupled with the TryInvokeMember implementation was causing some 
badness.  So I removed the delegate creation code in TryGetMember, and 
just handle properties, and then in TryInvokeMember, I handle both 
methods and properties (this seems to work!)

Thanks a million for your help!

Next problem: I'm hesitant to bring it up again, maybe I should be able 
to figure this out on my own, but it's stumped me for quite a spell now. 
I'm getting a System.InvalidOperationException that says No coercion 
operator is defined between types 'System.String' and 
'IronRuby.Builtins.MutableString' when I try and call a method on one 
of my dynamic objects with a literal Ruby string.

I've created another gist that reproduces the problem here:

https://gist.github.com/1207726

If I write 'test'.to_clr_string, this works, but that seems like kind of 
a pain to have to do in my scripts...

Any ideas about this?  The difficult part about it is that it doesn't 
even seem the runtime even gets to the point where any of my overrides 
are executed - no breakpoints are hit in MonoDevelop, no console output, 
so I don't think I can fix it from that vantage point...  Any help is 
much appreciated.

best,

--ben

-- 
Posted via http://www.ruby-forum.com/.
___
Ironruby-core mailing list
Ironruby-core@rubyforge.org
http://rubyforge.org/mailman/listinfo/ironruby-core