Ok, I keep running into this over and over. Whenever Silverlight passes a string to javascript, it comes out as some unreadable object. You have to call to_clr_string to get it working. This is ok... You can monkey patch some of the javascript library code to fix it, but with HtmlPage.window.invoke, for example, it''s not easy to do because it sends a variable number of arguments. Is this being fixed? Or is this something we''re going to have to deal with for a while? Thanks ~sean -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20080815/6eb880cb/attachment.html>
This isn''t a Silverlight issue but an IronRuby one. A Ruby string simply isn''t the same as a CLR string - the Ruby string is mutable while the CLR string is not. We need to come up with a cohesive plan for dealing with the difference before we can "fix" anything. From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Sean Clark Hess Sent: Friday, August 15, 2008 9:25 AM To: ironruby-core at rubyforge.org Subject: [Ironruby-core] Stupid to_clr_string Ok, I keep running into this over and over. Whenever Silverlight passes a string to javascript, it comes out as some unreadable object. You have to call to_clr_string to get it working. This is ok... You can monkey patch some of the javascript library code to fix it, but with HtmlPage.window.invoke, for example, it''s not easy to do because it sends a variable number of arguments. Is this being fixed? Or is this something we''re going to have to deal with for a while? Thanks ~sean -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://rubyforge.org/pipermail/ironruby-core/attachments/20080815/7b2f884e/attachment.html>
Ah, makes sense. I''m totally unfamiliar with the way IronRuby is implemented. Is it possible to switch it to a clr string any time it calls any framework code? (like the invoke function I''m using). ~sean On Fri, Aug 15, 2008 at 10:33 AM, Curt Hagenlocher <curth at microsoft.com>wrote:> This isn''t a Silverlight issue but an IronRuby one. A Ruby string simply > isn''t the same as a CLR string ? the Ruby string is mutable while the CLR > string is not. > > > > We need to come up with a cohesive plan for dealing with the difference > before we can "fix" anything. > > > > *From:* ironruby-core-bounces at rubyforge.org [mailto: > ironruby-core-bounces at rubyforge.org] *On Behalf Of *Sean Clark Hess > *Sent:* Friday, August 15, 2008 9:25 AM > *To:* ironruby-core at rubyforge.org > *Subject:* [Ironruby-core] Stupid to_clr_string > > > > Ok, I keep running into this over and over. Whenever Silverlight passes a > string to javascript, it comes out as some unreadable object. You have to > call to_clr_string to get it working. > > > > This is ok... You can monkey patch some of the javascript library code to > fix it, but with HtmlPage.window.invoke, for example, it''s not easy to do > because it sends a variable number of arguments. > > > > Is this being fixed? Or is this something we''re going to have to deal with > for a while? > > > > Thanks > > ~sean > > _______________________________________________ > 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/20080815/42aeb56f/attachment.html>
The binder could automatically create a conversion - in effect, calling to_clr_string for you automatically. But it might be a little strange for the binder to do that automatically in one direction and not the other - which is why I said that there needs to be a plan before we make any changes. From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Sean Clark Hess Sent: Friday, August 15, 2008 9:39 AM To: ironruby-core at rubyforge.org Subject: Re: [Ironruby-core] Stupid to_clr_string Ah, makes sense. I''m totally unfamiliar with the way IronRuby is implemented. Is it possible to switch it to a clr string any time it calls any framework code? (like the invoke function I''m using). ~sean On Fri, Aug 15, 2008 at 10:33 AM, Curt Hagenlocher <curth at microsoft.com<mailto:curth at microsoft.com>> wrote: This isn''t a Silverlight issue but an IronRuby one. A Ruby string simply isn''t the same as a CLR string - the Ruby string is mutable while the CLR string is not. We need to come up with a cohesive plan for dealing with the difference before we can "fix" anything. 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 Sean Clark Hess Sent: Friday, August 15, 2008 9:25 AM To: ironruby-core at rubyforge.org<mailto:ironruby-core at rubyforge.org> Subject: [Ironruby-core] Stupid to_clr_string Ok, I keep running into this over and over. Whenever Silverlight passes a string to javascript, it comes out as some unreadable object. You have to call to_clr_string to get it working. This is ok... You can monkey patch some of the javascript library code to fix it, but with HtmlPage.window.invoke, for example, it''s not easy to do because it sends a variable number of arguments. Is this being fixed? Or is this something we''re going to have to deal with for a while? Thanks ~sean _______________________________________________ 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/20080815/3dd32f4f/attachment-0001.html>
...oh, if the CLR interface we''re calling is typed to System.Object instead of System.String, then we probably can''t do any kind of automatic conversion. From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Sean Clark Hess Sent: Friday, August 15, 2008 9:39 AM To: ironruby-core at rubyforge.org Subject: Re: [Ironruby-core] Stupid to_clr_string Ah, makes sense. I''m totally unfamiliar with the way IronRuby is implemented. Is it possible to switch it to a clr string any time it calls any framework code? (like the invoke function I''m using). ~sean On Fri, Aug 15, 2008 at 10:33 AM, Curt Hagenlocher <curth at microsoft.com<mailto:curth at microsoft.com>> wrote: This isn''t a Silverlight issue but an IronRuby one. A Ruby string simply isn''t the same as a CLR string - the Ruby string is mutable while the CLR string is not. We need to come up with a cohesive plan for dealing with the difference before we can "fix" anything. 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 Sean Clark Hess Sent: Friday, August 15, 2008 9:25 AM To: ironruby-core at rubyforge.org<mailto:ironruby-core at rubyforge.org> Subject: [Ironruby-core] Stupid to_clr_string Ok, I keep running into this over and over. Whenever Silverlight passes a string to javascript, it comes out as some unreadable object. You have to call to_clr_string to get it working. This is ok... You can monkey patch some of the javascript library code to fix it, but with HtmlPage.window.invoke, for example, it''s not easy to do because it sends a variable number of arguments. Is this being fixed? Or is this something we''re going to have to deal with for a while? Thanks ~sean _______________________________________________ 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/20080815/9951d060/attachment.html>
Makes sense. On Fri, Aug 15, 2008 at 10:44 AM, Curt Hagenlocher <curth at microsoft.com>wrote:> The binder could automatically create a conversion ? in effect, calling > to_clr_string for you automatically. But it might be a little strange for > the binder to do that automatically in one direction and not the other ? > which is why I said that there needs to be a plan before we make any > changes. > > > > *From:* ironruby-core-bounces at rubyforge.org [mailto: > ironruby-core-bounces at rubyforge.org] *On Behalf Of *Sean Clark Hess > *Sent:* Friday, August 15, 2008 9:39 AM > *To:* ironruby-core at rubyforge.org > *Subject:* Re: [Ironruby-core] Stupid to_clr_string > > > > Ah, makes sense. I''m totally unfamiliar with the way IronRuby is > implemented. Is it possible to switch it to a clr string any time it calls > any framework code? (like the invoke function I''m using). > > > > ~sean > > On Fri, Aug 15, 2008 at 10:33 AM, Curt Hagenlocher <curth at microsoft.com> > wrote: > > This isn''t a Silverlight issue but an IronRuby one. A Ruby string simply > isn''t the same as a CLR string ? the Ruby string is mutable while the CLR > string is not. > > > > We need to come up with a cohesive plan for dealing with the difference > before we can "fix" anything. > > > > *From:* ironruby-core-bounces at rubyforge.org [mailto: > ironruby-core-bounces at rubyforge.org] *On Behalf Of *Sean Clark Hess > *Sent:* Friday, August 15, 2008 9:25 AM > *To:* ironruby-core at rubyforge.org > *Subject:* [Ironruby-core] Stupid to_clr_string > > > > Ok, I keep running into this over and over. Whenever Silverlight passes a > string to javascript, it comes out as some unreadable object. You have to > call to_clr_string to get it working. > > > > This is ok... You can monkey patch some of the javascript library code to > fix it, but with HtmlPage.window.invoke, for example, it''s not easy to do > because it sends a variable number of arguments. > > > > Is this being fixed? Or is this something we''re going to have to deal with > for a while? > > > > Thanks > > ~sean > > > _______________________________________________ > Ironruby-core mailing list > Ironruby-core at rubyforge.org > http://rubyforge.org/mailman/listinfo/ironruby-core > > > > _______________________________________________ > 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/20080815/03d5d49a/attachment.html>
You can monkey-patch the Silverlight classes you''re using to do the to_clr_string for you. For example HtmlDocument#GetElementById requires you pass it a ClrString, which can be annoying from IronRuby. So, you can make it take a Ruby string or symbol like this: module System::Windows::Browser class HtmlDocument alias_method orig_get_element_by_id, get_element_by_id def get_element_by_id(id) orig_get_element_by_id(id.to_s.to_clr_string) end end end # usage include System::Windows:Browser element = HtmlPage.document.get_element_by_id(:foo) From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Sean Clark Hess Sent: Friday, August 15, 2008 9:48 AM To: ironruby-core at rubyforge.org Subject: Re: [Ironruby-core] Stupid to_clr_string Makes sense. On Fri, Aug 15, 2008 at 10:44 AM, Curt Hagenlocher <curth at microsoft.com<mailto:curth at microsoft.com>> wrote: The binder could automatically create a conversion - in effect, calling to_clr_string for you automatically. But it might be a little strange for the binder to do that automatically in one direction and not the other - which is why I said that there needs to be a plan before we make any changes. 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 Sean Clark Hess Sent: Friday, August 15, 2008 9:39 AM To: ironruby-core at rubyforge.org<mailto:ironruby-core at rubyforge.org> Subject: Re: [Ironruby-core] Stupid to_clr_string Ah, makes sense. I''m totally unfamiliar with the way IronRuby is implemented. Is it possible to switch it to a clr string any time it calls any framework code? (like the invoke function I''m using). ~sean On Fri, Aug 15, 2008 at 10:33 AM, Curt Hagenlocher <curth at microsoft.com<mailto:curth at microsoft.com>> wrote: This isn''t a Silverlight issue but an IronRuby one. A Ruby string simply isn''t the same as a CLR string - the Ruby string is mutable while the CLR string is not. We need to come up with a cohesive plan for dealing with the difference before we can "fix" anything. 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 Sean Clark Hess Sent: Friday, August 15, 2008 9:25 AM To: ironruby-core at rubyforge.org<mailto:ironruby-core at rubyforge.org> Subject: [Ironruby-core] Stupid to_clr_string Ok, I keep running into this over and over. Whenever Silverlight passes a string to javascript, it comes out as some unreadable object. You have to call to_clr_string to get it working. This is ok... You can monkey patch some of the javascript library code to fix it, but with HtmlPage.window.invoke, for example, it''s not easy to do because it sends a variable number of arguments. Is this being fixed? Or is this something we''re going to have to deal with for a while? Thanks ~sean _______________________________________________ Ironruby-core mailing list Ironruby-core at rubyforge.org<mailto:Ironruby-core at rubyforge.org> http://rubyforge.org/mailman/listinfo/ironruby-core _______________________________________________ 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/20080815/df5d5308/attachment.html>