[IronPython] ReflectedPackage issue
Anthony Tarlano
mailinglist.account at gmail.com
Sat Jul 2 01:19:34 CEST 2005
Great job! this is why open source succeeds... Let's hope that the
ironPython team accepts your efforts.
Anthony
On 7/1/05, Jonathan Jacobs <korpse-ironpython at kaydash.za.net> wrote:
>
> Hi,
>
> I'd like to start off by saying that I'm not sure whether this is the
> preferred place to post patches. If not, you may want to start writing
> your
> reply now.
>
> Recently IronPython sparked my interest in using DirectX from Python,
> however I've run into a couple of issues. One of which I've been able to
> fix...as far as I can tell anyway.
>
> Here is a demonstration of the problem:
>
> IronPython 0.7.6 on .NET 2.0.50215.44
> Copyright (c) Microsoft Corporation. All rights reserved.
> >>> import sys
> >>> sys.LoadAssemblyByName('System')
> >>> sys.LoadAssemblyByName('Microsoft.DirectX')
> >>> import System, Microsoft.DirectX
> >>> Microsoft.DirectX.Matrix
> <type 'Microsoft.DirectX.UnsafeNativeMethods+Matrix'>
> >>> Microsoft.DirectX.UnsafeNativeMethods.Matrix
> <type 'Microsoft.DirectX.UnsafeNativeMethods+Matrix'>
>
> Hrm...that's not right. This matters because Microsoft.DirectX.Matrix
> provides more functionality than
> Microsoft.DirectX.UnsafeNativeMethods.Matrix; this problem actually crops
> up
> with a number of other objects in the Microsoft.DirectX namespace, namely
> Vector3, Quaternion, etc.
>
> So, I went investigating...
>
> >>> A = System.Reflection.Assembly.LoadWithPartialName('Microsoft.DirectX
> ')
> >>> M1, M2 = [t for t in A.GetExportedTypes() if
> >>> t.FullName.endswith('Matrix')]
> >>> M1
> Microsoft.DirectX.Matrix
> >>> M2
> Microsoft.DirectX.UnsafeNativeMethods+Matrix
> >>> M1.Name <http://M1.Name>
> 'Matrix'
> >>> M2.Name <http://M2.Name>
> 'Matrix'
> >>> M1.FullName
> 'Microsoft.DirectX.Matrix'
> >>> M2.FullName
> 'Microsoft.DirectX.UnsafeNativeMethods+Matrix'
>
> Logically enough, Microsoft.DirectX.Matrix and
> Microsoft.DirectX.UnsafeNativeMethods.Matrix both report their name as
> "Matrix"
> but not their full name.
>
> Following the codepath lead me to IronPython.Objects.ReflectedPackage,
> where
> I found the problem: GetCoreTypeName. It returns, for all intents and
> purposes, the type's Name property, which the calling functions then use
> as
> a key to map the type to.
>
> Of course, this causes a problem when two objects have the same name,
> which
> would explain the craziness, after calming down, I was seeing. I've
> attached
> a patch that appears to fix the problem.
>
> For interest's sake, after applying my patch:
>
> IronPython 0.7.6 on .NET 2.0.50215.44
> Copyright (c) Microsoft Corporation. All rights reserved.
> >>> import sys
> >>> sys.LoadAssemblyByName('System')
> >>> sys.LoadAssemblyByName('Microsoft.DirectX')
> >>> import System, Microsoft.DirectX
> >>> Microsoft.DirectX.Matrix
> <type 'Microsoft.DirectX.Matrix'>
> >>> Microsoft.DirectX.UnsafeNativeMethods.Matrix
> <type 'Microsoft.DirectX.UnsafeNativeMethods+Matrix'>
>
> I'm not sure if I've fixed this The Right Way, but I've attached my patch
> anyway.
> --
> Jonathan
>
>
> _______________________________________________
> users-ironpython.com <http://users-ironpython.com> mailing list
> users-ironpython.com at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20050702/c1723f99/attachment.html>
More information about the Ironpython-users
mailing list