Author: ArcRiley
Date: 2009-01-03 17:39:36 -0500 (Sat, 03 Jan 2009)
New Revision: 1414

Modified:
   trunk/concordance/src/Core.c
Log:
Added comments for tuple parsing and opensocket


Modified: trunk/concordance/src/Core.c
===================================================================
--- trunk/concordance/src/Core.c        2009-01-03 22:18:55 UTC (rev 1413)
+++ trunk/concordance/src/Core.c        2009-01-03 22:39:36 UTC (rev 1414)
@@ -80,17 +80,46 @@
     self->c2s.port = 5222;
     self->s2s.port = 5269;
 
-    /* parse arguments and keywords */
+    /* parse arguments and keywords
+
+       From http://docs.python.org/3.0/c-api/arg.html :
+         |  Indicates that the remaining arguments in the Python argument list 
+            are optional. The C variables corresponding to optional arguments 
+            should be initialized to their default value — when an optional 
+            argument is not specified, PyArg_ParseTuple does not touch the 
+            contents of the corresponding C variable(s).
+         () The object must be a Python sequence whose length is the number of 
+            format units in items. The C arguments must correspond to the 
+            individual format units in items. Format units for sequences may 
+            be nested.
+         s  Convert a Python string or Unicode object to a C pointer to a 
+            character string. You must not provide storage for the string 
+            itself; a pointer to an existing string is stored into the 
+            character pointer variable whose address you pass. The C string is 
+            NUL-terminated. The Python string must not contain embedded NUL 
+            bytes; if it does, a TypeError exception is raised. Unicode 
+            objects are converted to C strings using the default encoding. If 
+            this conversion fails, a UnicodeError is raised.
+         H  Convert a Python integer to a C unsigned short int, without 
+            overflow checking.
+         :  The list of format units ends here; the string after the colon is 
+            used as the function name in error messages (the “associated 
+            value” of the exception that PyArg_ParseTuple raises).
+    */
     if (!PyArg_ParseTupleAndKeywords(args, kwds, "|(sH)(sH):Core", kwlist, 
                                      &self->c2s.addr, &self->c2s.port, 
                                      &self->s2s.addr, &self->s2s.port))
       return -1;
     
-    /* open client-to-server listening socket (self->c2s->sock) */
+    /* open the listening sockets (self->c2s->sock and self->s2s->sock)
+
+       Note that these default to -1 and remain -1 on failure, the dealloc
+       function uses this (if != -1) to close open all sockets.
+
+       opensocket (see below) will set the Python error message on failure.
+    */
     if (!opensocket(self->c2s))
       return -1;
-
-    /* open server-to-server listening socket (self->s2s->sock) */
     if (!opensocket(self->s2s))
       return -1;
 

_______________________________________________
PySoy-SVN mailing list
PySoy-SVN@pysoy.org
http://www.pysoy.org/mailman/listinfo/pysoy-svn

Reply via email to