<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:Wingdings;
        panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
        {font-family:Wingdings;
        panose-1:5 0 0 0 0 0 0 0 0 0;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri","sans-serif";}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">It’s not that
</span>WINFUNCTYPE is always changing in CPython – it’s that each time you run it’ll have a different ID. In IronPython we allocate object IDs sequentially starting at 43. So if the only thing you call id() on (which printing the repr does implicitly) then
the 1<sup>st</sup> object will always have an id of 43. If you did “id(100)” first and then looked at ctypes.WINFUNCTYPE then you’d see it’d be 0x2C.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Can you include the line of code where the call is happening and an setup to get into the call? It does look like there’s a 3<sup>rd</sup> argument that’s optional because:<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">from ctypes import *<o:p></o:p></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">WINFUNCTYPE(c_int, c_int, c_int)(100, 'foo', '100')<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D">Starts reporting a different error message on CPython than IronPython. My guess is we need to implement this but there don’t seem to be any tests for it so
if we can see at least 1 call site that’d be helpful </span><span style="font-size:11.0pt;font-family:Wingdings;color:#1F497D">J</span><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"> can you open a bug on CodePlex for this
as well?<o:p></o:p></span></p>
<p class="MsoNormal"><span style="font-size:11.0pt;font-family:"Calibri","sans-serif";color:#1F497D"><o:p> </o:p></span></p>
<div style="border:none;border-left:solid blue 1.5pt;padding:0in 0in 0in 4.0pt">
<div>
<div style="border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif"">From:</span></b><span style="font-size:10.0pt;font-family:"Tahoma","sans-serif""> users-bounces@lists.ironpython.com [mailto:users-bounces@lists.ironpython.com]
<b>On Behalf Of </b>Clemens Nylandsted Klokmose<br>
<b>Sent:</b> Sunday, September 12, 2010 7:48 AM<br>
<b>To:</b> users@lists.ironpython.com<br>
<b>Subject:</b> [IronPython] PyBonjour through Ctypes<o:p></o:p></span></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Hi,<o:p></o:p></p>
<div>
<p class="MsoNormal">I am experimenting with getting a Python library running in IronPython that relies on PyBonjour (<a href="http://code.google.com/p/pybonjour/">http://code.google.com/p/pybonjour/</a>).<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">PyBonjour is a pure python library interfacing with the systems bonjour installation. I am completely unexperienced with CTypes, so what I am proposing now might seem naïve.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">At the top of the pybonjour.py is code looking like this:<o:p></o:p></p>
</div>
<div>
<div>
<p class="MsoNormal">if sys.platform == 'win32':<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> # Need to use the stdcall variants<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> _libdnssd = ctypes.windll.dnssd<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"> _CFunc = ctypes.WINFUNCTYPE<o:p></o:p></p>
</div>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">IronPython's sys.platform evaluates to 'cli', so I have tried to change the check to if sys.platform == 'win32' or sys.platform == 'cli':<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">This seems to work, but everytime a C function is called now, Python complains that theres an argument too much.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">E.g. TypeError: CFunctionType() takes at most 2 arguments (3 given). My suggestion is that ctypes.WINFUNCTYPE in IronPython might be a wrong value? (In IronPython it seems to always be 0x000000000000002B, whereas in CPython the value varies)<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Does anyone have an idea of how to go about this?<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">It should be noted that I have pybonjour running with the standard CPython on Windows.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Thanks,<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal">Clemens<o:p></o:p></p>
</div>
</div>
</div>
</body>
</html>