From miles at lubin.us Sun Jun 20 10:02:10 2004 From: miles at lubin.us (Miles Lubin) Date: Fri Jun 25 09:36:20 2004 Subject: [Python.NET] Compiling under mono Message-ID: <20040620100210.797915fd.miles@lubin.us> I know this isnt supposed to work yet, but no harm in trying, When I make under mono, I get: ilasm /nologo /dll /quiet /output=CLR.dll \ ./src/runtime/CLRModule.il; syntax error, got token `K_INT32', expecting INT64 K_AT K_FROMUNMANAGED K_CALLMOSTDERIVED Error at: line (45) column (19) ***** FAILURE ***** make: *** [CLR.dll] Error 1 I don't know il at all, so I dont understand the error, but if you could help me make it compile, it would be great. Thanks, Miles From hchwang at dsic.co.kr Mon Jun 21 02:19:29 2004 From: hchwang at dsic.co.kr (=?ks_c_5601-1987?B?yLLH9sO1?=) Date: Fri Jun 25 09:36:22 2004 Subject: [Python.NET] Comment about Python for .Net Message-ID: Skipped content of type multipart/alternative-------------- next part -------------- // CallConvUtil.cs - A utility to rewrite IL and insert calling // convention metadata. This is needed to ensure that Python // type callbacks are called using cdecl rather than stdcall. // // Author: Brian Lloyd // // (c) 2002 Brian Lloyd using System; using System.IO; using System.Collections; using System.Text; public class CallConvUtil { static string ccAttr = ".custom instance void Python.Runtime.CallConvCdeclAttribute"; static string modOpt = "\n modopt([mscorlib]System.Runtime.CompilerServices.CallConvCdecl)"; StreamReader reader; StreamWriter writer; public static int Main(string[] args) { CallConvUtil munger = new CallConvUtil(); return munger.Run(); } public int Run() { string inputFile = @"C:\Documents and Settings\???\My Documents\xx\PythonNet\"+"Python.Runtime.il"; string outputFile = @"C:\Documents and Settings\???\My Documents\xx\PythonNet\"+"Python.Runtime.il2"; string buff; string line; if (!File.Exists(inputFile)) { Console.WriteLine("{0} does not exist!", inputFile); return -1; } // reader = File.OpenText(inputFile); // writer = File.CreateText(outputFile); reader = new StreamReader(inputFile, Encoding.Default); writer = new StreamWriter(outputFile, false, Encoding.Default); while ((line = reader.ReadLine())!= null) { buff = line.Trim(); if (buff.StartsWith(".class ")) { ReadClass(line, false); } else { writer.WriteLine(line); } } reader.Close(); writer.Close(); string k = "sdaf"; return 0; } public void ReadClass(string line, bool nested) { ArrayList lines = new ArrayList(); bool hasAttr = false; string data; string buff; if (!nested) { lines.Add(line); } while ((data = reader.ReadLine()) != null) { buff = data.Trim(); if (buff.StartsWith(".class ")) { WriteBuffer(lines); writer.WriteLine(data); ReadClass(data, true); lines = new ArrayList(); } else if (buff.StartsWith(ccAttr)) { hasAttr = true; lines.Add(data); } else if ( (!hasAttr) && buff.StartsWith(".method ")) { WriteBuffer(lines); ReadMethod(data); lines = new ArrayList(); } else if (buff.StartsWith("} // end of class")) { WriteBuffer(lines); writer.WriteLine(data); return; } else if (hasAttr && buff.StartsWith("Invoke(")) { WriteBuffer(lines); writer.WriteLine(modOpt); writer.WriteLine(data); lines = new ArrayList(); } else { lines.Add(data); } } } public void ReadMethod(string line) { ArrayList lines = new ArrayList(); string mline = line; string data; string buff; while ((data = reader.ReadLine()) != null) { buff = data.Trim(); if (buff.StartsWith(ccAttr)) { 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); } } public void WriteBuffer(ArrayList data) { IEnumerator iter = data.GetEnumerator(); while (iter.MoveNext()) { writer.WriteLine((String)iter.Current); } } } From brian at zope.com Fri Jun 25 11:27:54 2004 From: brian at zope.com (Brian Lloyd) Date: Fri Jun 25 11:28:30 2004 Subject: [Python.NET] Compiling under mono In-Reply-To: <20040620100210.797915fd.miles@lubin.us> Message-ID: > I know this isnt supposed to work yet, but no harm in trying, > > When I make under mono, I get: > > ilasm /nologo /dll /quiet /output=CLR.dll \ > ./src/runtime/CLRModule.il; > syntax error, got token `K_INT32', expecting INT64 K_AT > K_FROMUNMANAGED K_CALLMOSTDERIVED > > > > I don't know il at all, so I dont understand the error, but if > you could help me make it compile, it would be great. Hi Miles - I don't think it _can_ assemble correctly yet with the mono ilasm. The reason is that I have to do a terrible hack that involves compiling with the csharp compiler, then disassembling to IL to add some necessary marshalling modifiers that can't be indicated in csharp, and finally reassembling the result. Last time I looked, the mono assembler couldn't deal with modopt(...) or modreq(...) in IL, which is what causes the error. So it probably won't compile under native mono tools until support for that is added to ilasm. Brian Lloyd brian@zope.com V.P. Engineering 540.361.1716 Zope Corporation http://www.zope.com