[Python.NET] Updates to callconvutil.cs for .NET 2.0

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[Python.NET] Updates to callconvutil.cs for .NET 2.0

Michael Eddington
Anyone else out there started to mess with Python.NET on the 2.0
platform?  One of the first hurtles was the output from ildasm does
not always place the method name on the next line, causing
callconvutil to place the modopt in the wrong place.  I've added a
regex in to check for and split the method line if the function name
is found.

Currently getting lots of access violation exceptions.

mike

Replace ReadMethod with the following:

    public void ReadMethod(string line)
    {
        Regex findMethod = new
Regex(@"^(\s*.method\s.*\s)([^\s()]+\([^()]*(?:,|\)\s.*))$");

        ArrayList lines = new ArrayList();
        string mline = line;

        string data;
        string buff;

        while ((data = reader.ReadLine()) != null)
        {
            buff = data.Trim();
            if (buff.StartsWith(ccAttr))
            {
                // BUG: mline may have method name in it already which breaks
                //      things.  This is mostly seen in .NET 2.0.
                // Example:  .method public hidebysig static int32
tp_descr_set(native int ds,
                if (findMethod.IsMatch(mline))
                {
                    // method name is on same line as .method.  Need to insert
                    // modOpt prior to method name.
                    Match match = findMethod.Match(mline);

                    writer.WriteLine(match.Groups[1].Value + " ");
                    writer.WriteLine(modOpt + " ");
                    writer.WriteLine(match.Groups[2].Value);
                }
                else
                {
                    writer.WriteLine(mline);
                    writer.WriteLine(modOpt);
                }

                WriteBuffer(lines);
                writer.WriteLine(data);
                return;
            }
            else if (buff.StartsWith("} // end of method"))
            {
                writer.WriteLine(mline);
                WriteBuffer(lines);
                writer.WriteLine(data);
                return;
            }
            lines.Add(data);
        }
    }
_________________________________________________
Python.NET mailing list - [hidden email]
http://mail.python.org/mailman/listinfo/pythondotnet
Reply | Threaded
Open this post in threaded view
|

Re: [Python.NET] Updates to callconvutil.cs for .NET 2.0

Brian Lloyd-2
Thanks for the patch! I've been slammed lately and haven't
had time to wrap up 1.0 and make the 2.x branch ;(

Any details you can post on the access violations would be
helpful too (to me, anyway).


Brian Lloyd        [hidden email]
V.P. Engineering   540.361.1716              
Zope Corporation   http://www.zope.com 


> -----Original Message-----
> From: pythondotnet-bounces+brian=[hidden email]
> [mailto:pythondotnet-bounces+brian=[hidden email]]On Behalf Of
> Michael Eddington
> Sent: Thursday, September 15, 2005 7:22 PM
> To: [hidden email]
> Subject: [Python.NET] Updates to callconvutil.cs for .NET 2.0
>
>
> Anyone else out there started to mess with Python.NET on the 2.0
> platform?  One of the first hurtles was the output from ildasm does
> not always place the method name on the next line, causing
> callconvutil to place the modopt in the wrong place.  I've added a
> regex in to check for and split the method line if the function name
> is found.
>
> Currently getting lots of access violation exceptions.
>
> mike
>
> Replace ReadMethod with the following:
>
>     public void ReadMethod(string line)
>     {
>         Regex findMethod = new
> Regex(@"^(\s*.method\s.*\s)([^\s()]+\([^()]*(?:,|\)\s.*))$");
>
>         ArrayList lines = new ArrayList();
>         string mline = line;
>
>         string data;
>         string buff;
>
>         while ((data = reader.ReadLine()) != null)
>         {
>             buff = data.Trim();
>             if (buff.StartsWith(ccAttr))
>             {
>                 // BUG: mline may have method name in it already
> which breaks
>                 //      things.  This is mostly seen in .NET 2.0.
>                 // Example:  .method public hidebysig static int32
> tp_descr_set(native int ds,
>                 if (findMethod.IsMatch(mline))
>                 {
>                     // method name is on same line as .method.  
> Need to insert
>                     // modOpt prior to method name.
>                     Match match = findMethod.Match(mline);
>
>                     writer.WriteLine(match.Groups[1].Value + " ");
>                     writer.WriteLine(modOpt + " ");
>                     writer.WriteLine(match.Groups[2].Value);
>                 }
>                 else
>                 {
>                     writer.WriteLine(mline);
>                     writer.WriteLine(modOpt);
>                 }
>
>                 WriteBuffer(lines);
>                 writer.WriteLine(data);
>                 return;
>             }
>             else if (buff.StartsWith("} // end of method"))
>             {
>                 writer.WriteLine(mline);
>                 WriteBuffer(lines);
>                 writer.WriteLine(data);
>                 return;
>             }
>             lines.Add(data);
>         }
>     }
> _________________________________________________
> Python.NET mailing list - [hidden email]
> http://mail.python.org/mailman/listinfo/pythondotnet
>
_________________________________________________
Python.NET mailing list - [hidden email]
http://mail.python.org/mailman/listinfo/pythondotnet