[IronPython] IronPython to JavaScript

Jimmy Schementi Jimmy.Schementi at microsoft.com
Mon Mar 9 10:21:37 CET 2009


The AddReference issue sounds bad ... I have to figure out exactly what's happening there. And the onload thing is also really messed up; I'll ask around to find out what it actually does.
________________________________________
From: users-bounces at lists.ironpython.com [users-bounces at lists.ironpython.com] On Behalf Of Michael Foord [fuzzyman at voidspace.org.uk]
Sent: Sunday, March 08, 2009 4:39 PM
To: Discussion of IronPython
Subject: Re: [IronPython] IronPython to JavaScript

Jimmy Schementi wrote:
> Kristian wrote:
>
>> Just curios... Has anyone had time to look at my sample yet?
>>
>
> Yes, and sorry for the horrifically late reply ...
>
> http://jimmy.schementi.com/silverlight/scriptable
>
> source is here:
> http://jimmy.schementi.com/silverlight/scriptable.zip
>
> There was a few small changes I made to Michael's code:
>
> 1. The Python code used to load the C# assembly will fail, since there's no namespace defined as Scriptable. It should be change to:
>
> clr.AddReferenceToFile("Scriptable.dll")
> import ScriptableForString
>

In the actual source for download the namespace was defined. It was
omitted for brevity in the article. I'm adding it to avoid confusion in
the future.

> ... and "Scriptable.dll" doesn't need to be added to the AppManifest.xaml, just needs to be present in the XAP. I use clr.AddReferenceToFile because clr.AddReference or clr.AddReferenceByName can fail depending on whether or not Microsoft.Scripting.Silverlight.dll is signed (which can differ if you get the bits from codeplex or build them yourself from github), because you didn't give the fully-qualified assembly name.
>

Interesting. AddReference can fail if you put the dll in the xap file -
that sounds like a big scary gotcha.
> 2. The SomeClass class needs to take new_string as a parameter, instead of "string"
>

The _method returns new_string to indicate that it returns a new string
(and probably not the one you pass in). This is what the ellipsis in the
code body is for - to indicate the missing implementation.
> 3. There are both "some_class" and "someClass" variables, but there are intended to mean the same thing. So I changed them all to "someClass".
>
> 4. Calling event.OnEvent(args) in top-level Python code can run before JavaScript has a chance to hook the event, so either an error will happen, or nothing. It's strange because it executes onload of the Silverlight control, but sounds like that happens before the start script has a chance to finish. In my demo I trigger the event from a link.
>

So onload isn't reliable  - great.
> 5. http://jimmy.schementi.com/silverlight/scriptable/csharp/scriptable.cs MSDN documentation said that events need to be marked with ScriptableMemberAttribute, rather than ScriptableMember. I don't think I makes a difference ...
>

This applies to *all* of the references. I don't think ScriptableType
and ScriptableMember exist any more - thanks.

In the process of making these updates.

Michael
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>


--
http://www.ironpythoninaction.com/
http://www.voidspace.org.uk/blog


_______________________________________________
Users mailing list
Users at lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com




More information about the Ironpython-users mailing list