Author: ArcRiley
Date: 2009-01-18 20:45:45 -0500 (Sun, 18 Jan 2009)
New Revision: 1498

Added:
   trunk/concordance/include/
   trunk/concordance/include/concordance.h
   trunk/concordance/include/concordance.services.h
   trunk/concordance/include/concordance.sockets.h
   trunk/concordance/src/sockets/__init__.c
Removed:
   trunk/concordance/src/globals.h
   trunk/concordance/src/services/__init__.h
   trunk/concordance/src/sockets/Client.h
   trunk/concordance/src/sockets/Socket.h
   trunk/concordance/src/sockets/__init__.c
   trunk/concordance/src/sockets/__init__.h
Modified:
   trunk/concordance/setup.py
   trunk/concordance/src/_core/__init__.h
   trunk/concordance/src/_core/utils.h
   trunk/concordance/src/sockets/Client.c
   trunk/concordance/src/sockets/Socket.c
Log:
moving headers to include/



Property changes on: trunk/concordance/include
___________________________________________________________________
Added: svn:mergeinfo
   + 

Copied: trunk/concordance/include/concordance.h (from rev 1495, 
trunk/concordance/src/globals.h)
===================================================================
--- trunk/concordance/include/concordance.h                             (rev 0)
+++ trunk/concordance/include/concordance.h     2009-01-19 01:45:45 UTC (rev 
1498)
@@ -0,0 +1,47 @@
+/*
+# Concordance XMPP Service Framework
+#
+# Copyright (C) 2009 Copyleft Games Group
+#
+#  This program is free software; you can redistribute it and/or modify
+#  it under the terms of the GNU Affero General Public License as published
+#  by the Free Software Foundation, either version 3 of the License, or
+#  (at your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU Affero General Public License for more details.
+#
+#  You should have received a copy of the GNU Affero General Public License
+#  along with this program; if not, see http://www.gnu.org/licenses
+#
+# $Id$
+*/
+
+#ifndef CONCORDANCE_H
+#define CONCORDANCE_H
+
+#include "Python.h"
+#include "glib.h"
+#include "gsasl.h"
+#include "expat.h"
+
+#ifdef MS_WINDOWS
+  #include <ws2tcpip.h>
+  #include <Winsock2.h>
+  WSADATA        wsaData;
+  gboolean       wsaInit;
+#else
+  #include <sys/socket.h>
+  #include <netdb.h>
+#endif
+
+
+typedef struct {
+  GMainContext*    context;              /* Concordance's Glib context */
+  GMainLoop*       mainloop;             /* Concordance's Glib mainloop */
+  GThread*         threadid;             /* thread ID for mainloop thread */
+} concordGlobals;
+
+#endif


Property changes on: trunk/concordance/include/concordance.h
___________________________________________________________________
Added: svn:keywords
   + Id
Added: svn:mergeinfo
   + 

Copied: trunk/concordance/include/concordance.services.h (from rev 1494, 
trunk/concordance/src/services/__init__.h)
===================================================================
--- trunk/concordance/include/concordance.services.h                            
(rev 0)
+++ trunk/concordance/include/concordance.services.h    2009-01-19 01:45:45 UTC 
(rev 1498)
@@ -0,0 +1,27 @@
+/*
+# Concordance XMPP Service Framework
+#
+# Copyright (C) 2009 Copyleft Games Group
+#
+#  This program is free software; you can redistribute it and/or modify
+#  it under the terms of the GNU Affero General Public License as published
+#  by the Free Software Foundation, either version 3 of the License, or
+#  (at your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU Affero General Public License for more details.
+#
+#  You should have received a copy of the GNU Affero General Public License
+#  along with this program; if not, see http://www.gnu.org/licenses
+#
+# $Id$
+*/
+
+#ifndef CONCORDANCE_SERVICES_H
+#define CONCORDANCE_SERVICES_H
+
+#include "concordance.h"
+
+#endif

Copied: trunk/concordance/include/concordance.sockets.h (from rev 1495, 
trunk/concordance/src/sockets/__init__.c)
===================================================================
--- trunk/concordance/include/concordance.sockets.h                             
(rev 0)
+++ trunk/concordance/include/concordance.sockets.h     2009-01-19 01:45:45 UTC 
(rev 1498)
@@ -0,0 +1,56 @@
+/*
+# Concordance XMPP Service Framework
+#
+# Copyright (C) 2009 Copyleft Games Group
+#
+#  This program is free software; you can redistribute it and/or modify
+#  it under the terms of the GNU Affero General Public License as published
+#  by the Free Software Foundation, either version 3 of the License, or
+#  (at your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU Affero General Public License for more details.
+#
+#  You should have received a copy of the GNU Affero General Public License
+#  along with this program; if not, see http://www.gnu.org/licenses
+#
+# $Id$
+*/
+
+#ifndef CONCORDANCE_SOCKETS_H
+#define CONCORDANCE_SOCKETS_H
+
+#include "concordance.h"
+
+
+/* concordance.sockets.Socket definition */
+PyTypeObject socketsSocket_Type;
+
+typedef struct {
+  PyObject_HEAD
+  PyObject*             module;        /* reference to our own module */
+  GMainContext*         context;       /* Concordance's Glib context */
+  const gchar*          addr;
+  gushort               port;
+  int                   sock;
+  GIOChannel*           chan;
+} socketsSocket_Object;
+
+
+/* concordance.sockets.Socket definition */
+PyTypeObject socketsClient_Type;
+
+typedef struct {
+  PyObject_HEAD
+  PyObject*             module;        /* reference to our own module */
+  GMainContext*         context;       /* Concordance's Glib context */
+  const gchar*          addr;
+  gushort               port;
+  int                   sock;
+  GIOChannel*           chan;
+} socketsClient_Object;
+
+
+#endif

Modified: trunk/concordance/setup.py
===================================================================
--- trunk/concordance/setup.py  2009-01-18 22:52:02 UTC (rev 1497)
+++ trunk/concordance/setup.py  2009-01-19 01:45:45 UTC (rev 1498)
@@ -34,7 +34,8 @@
 if sys.version_info[0] != 3 :
   raise RuntimeError('Python 3.0 is required for this package.')
 
-include_dirs = ['/usr/include/glib-2.0',
+include_dirs = ['include',
+                '/usr/include/glib-2.0',
                 '/usr/lib/glib-2.0/include',
 ]
 

Modified: trunk/concordance/src/_core/__init__.h
===================================================================
--- trunk/concordance/src/_core/__init__.h      2009-01-18 22:52:02 UTC (rev 
1497)
+++ trunk/concordance/src/_core/__init__.h      2009-01-19 01:45:45 UTC (rev 
1498)
@@ -23,6 +23,5 @@
 #define _CORE_INIT_H
 
 #include "utils.h"
-#include "../globals.h"
 
 #endif

Modified: trunk/concordance/src/_core/utils.h
===================================================================
--- trunk/concordance/src/_core/utils.h 2009-01-18 22:52:02 UTC (rev 1497)
+++ trunk/concordance/src/_core/utils.h 2009-01-19 01:45:45 UTC (rev 1498)
@@ -22,7 +22,7 @@
 #ifndef CONCORD_UTILS_H
 #define CONCORD_UTILS_H
 
-#include "../globals.h"
+#include "concordance.h"
 
 GIOChannel*   concordAddSocket         (gint fd, GIOCondition condition,
                                         GSourceFunc callback, gpointer data,

Deleted: trunk/concordance/src/globals.h
===================================================================
--- trunk/concordance/src/globals.h     2009-01-18 22:52:02 UTC (rev 1497)
+++ trunk/concordance/src/globals.h     2009-01-19 01:45:45 UTC (rev 1498)
@@ -1,47 +0,0 @@
-/*
-# Concordance XMPP Service Framework
-#
-# Copyright (C) 2009 Copyleft Games Group
-#
-#  This program is free software; you can redistribute it and/or modify
-#  it under the terms of the GNU Affero General Public License as published
-#  by the Free Software Foundation, either version 3 of the License, or
-#  (at your option) any later version.
-#
-#  This program is distributed in the hope that it will be useful,
-#  but WITHOUT ANY WARRANTY; without even the implied warranty of
-#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#  GNU Affero General Public License for more details.
-#
-#  You should have received a copy of the GNU Affero General Public License
-#  along with this program; if not, see http://www.gnu.org/licenses
-#
-# $Id$
-*/
-
-#ifndef GLOBALS_H
-#define GLOBALS_H
-
-#include "Python.h"
-#include "glib.h"
-#include "gsasl.h"
-#include "expat.h"
-
-#ifdef MS_WINDOWS
-  #include <ws2tcpip.h>
-  #include <Winsock2.h>
-  WSADATA        wsaData;
-  gboolean       wsaInit;
-#else
-  #include <sys/socket.h>
-  #include <netdb.h>
-#endif
-
-
-typedef struct {
-  GMainContext*    context;              /* Concordance's Glib context */
-  GMainLoop*       mainloop;             /* Concordance's Glib mainloop */
-  GThread*         threadid;             /* thread ID for mainloop thread */
-} concordGlobals;
-
-#endif

Deleted: trunk/concordance/src/services/__init__.h
===================================================================
--- trunk/concordance/src/services/__init__.h   2009-01-18 22:52:02 UTC (rev 
1497)
+++ trunk/concordance/src/services/__init__.h   2009-01-19 01:45:45 UTC (rev 
1498)
@@ -1,27 +0,0 @@
-/*
-# Concordance XMPP Service Framework
-#
-# Copyright (C) 2009 Copyleft Games Group
-#
-#  This program is free software; you can redistribute it and/or modify
-#  it under the terms of the GNU Affero General Public License as published
-#  by the Free Software Foundation, either version 3 of the License, or
-#  (at your option) any later version.
-#
-#  This program is distributed in the hope that it will be useful,
-#  but WITHOUT ANY WARRANTY; without even the implied warranty of
-#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#  GNU Affero General Public License for more details.
-#
-#  You should have received a copy of the GNU Affero General Public License
-#  along with this program; if not, see http://www.gnu.org/licenses
-#
-# $Id$
-*/
-
-#ifndef SERVICES_INIT_H
-#define SERVICES_INIT_H
-
-#include "../_core/__init__.h"
-
-#endif

Modified: trunk/concordance/src/sockets/Client.c
===================================================================
--- trunk/concordance/src/sockets/Client.c      2009-01-18 22:52:02 UTC (rev 
1497)
+++ trunk/concordance/src/sockets/Client.c      2009-01-19 01:45:45 UTC (rev 
1498)
@@ -19,43 +19,137 @@
 # $Id$
 */
 
-#include "Socket.h"
+#include "concordance.sockets.h"
 
                                                                           /*\
 cdef class Socket :                                                       \*/
-  static char socketsSocket_Doc[] = "Test";
+  static char socketsClient_Doc[] = "Test";
 
+
   static PyObject*
-  socketsSocket_new(PyTypeObject* type, PyObject* args, PyObject* kwds) { /*\
+  socketsClient_new(PyTypeObject* type, PyObject* args, PyObject* kwds) { /*\
     cdef :                                                                \*/
-      socketsSocket_Object* self;
+      socketsClient_Object* self;
 
     /* allocate self */
-    self = (socketsSocket_Object*) type->tp_alloc(type, 0);
+    self = (socketsClient_Object*) type->tp_alloc(type, 0);
 
     /* start with closed socket */
     self->sock = -1;
 
-    /* grab context from _core */
-    self->cntx = NULL;
+    /* Get a reference to our local module
+    
+       This is to keep our module alive as long as this instance.
+       
+       PyObject*        PyImport_ImportModule    (const char *name);
+    */
+    self->module = PyImport_ImportModule("concordance.sockets");
+    
+    /* Get context from global state
 
+       I'm sorry for this.  Here's the natural language for this block:
+         1) get the state of sockets module - a PyObject** to concordance._core
+         2) dereference the PyObject** to PyObject*
+         3) get the state of _core - a concordGlobals**
+         4) dereference concordGlobals** to concordGlobals*
+         5) copy the GMainContext* context from the struct to self->context
+
+       void*            PyModule_GetState        (PyObject*);
+    */
+    self->context = (*(concordGlobals**) PyModule_GetState(
+                     *(PyObject**) PyModule_GetState(self->module)))->context;
+
     return (PyObject*) self;
   }
 
+
   static int
-  socketsSocket_init(PyObject* s, PyObject* args, PyObject* kwds) {       /*\
+  socketsClient_init(PyObject* s, PyObject* args, PyObject* kwds) {       /*\
     cdef :                                                                \*/
-      socketsSocket_Object*      self = (socketsSocket_Object*) s;
+      socketsClient_Object*      self = (socketsClient_Object*) s;
     
     return 0;
   }
 
 
   static void
-  socketsSocket_dealloc(socketsSocket_Object* self) {
+  socketsClient_dealloc(socketsClient_Object* self) {
+    /* close the socket if open */
     if (self->sock > -1)
       close(self->sock);
+
+    /* decref our module handle, which may in-turn decref _core */
+    if (self->module)
+      Py_DECREF(self->module);
+
     PyObject_Del(self);
   }
 
 
+  static PyObject*
+  socketsClient_getattro(socketsClient_Object* self, PyObject* key) {
+    return PyObject_GenericGetAttr((PyObject*) self, key);
+  }
+
+
+  static int
+  socketsClient_setattro(socketsClient_Object* self, PyObject* key,
+                         PyObject* value) {
+    return PyObject_GenericSetAttr((PyObject*) self, key, value);
+  }
+  
+  
+  /*
+  #
+  ###########################################################################
+  #
+  # global structs
+  #                                                                        */
+
+  static PyMethodDef socketsClient_Methods[] = {
+    { NULL, NULL },                              /* sentinel */
+  };
+
+
+  PyTypeObject socketsClient_Type = {
+    PyVarObject_HEAD_INIT(NULL, 0)
+    "concordance.sockets.Socket",                /*tp_name*/
+    sizeof(socketsClient_Object),                /*tp_basicsize*/
+    0,                                           /*tp_itemsize*/
+    (destructor) socketsClient_dealloc,          /*tp_dealloc*/
+    0,                                           /*tp_print*/
+    (getattrfunc) 0,                             /*tp_getattr*/
+    (setattrfunc) 0,                             /*tp_setattr*/
+    0,                                           /*tp_compare*/
+    0,                                           /*tp_repr*/
+    0,                                           /*tp_as_number*/
+    0,                                           /*tp_as_sequence*/
+    0,                                           /*tp_as_mapping*/
+    0,                                           /*tp_hash*/
+    0,                                           /*tp_call*/
+    0,                                           /*tp_str*/
+    (getattrofunc) socketsClient_getattro,       /*tp_getattro*/
+    (setattrofunc) socketsClient_setattro,       /*tp_setattro*/
+    0,                                           /*tp_as_buffer*/
+    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,    /*tp_flags*/
+    socketsClient_Doc,                           /*tp_doc*/
+    0,                                           /*tp_traverse*/
+    0,                                           /*tp_clear*/
+    0,                                           /*tp_richcompare*/
+    0,                                           /*tp_weaklistoffset*/
+    0,                                           /*tp_iter*/
+    0,                                           /*tp_iternext*/
+    socketsClient_Methods,                       /*tp_methods*/
+    0,                                           /*tp_members*/
+    0,                                           /*tp_getset*/
+    0,                                           /*tp_base*/
+    0,                                           /*tp_dict*/
+    0,                                           /*tp_descr_get*/
+    0,                                           /*tp_descr_set*/
+    0,                                           /*tp_dictoffset*/
+    socketsClient_init,                          /*tp_init*/
+    0,                                           /*tp_alloc*/
+    socketsClient_new,                           /*tp_new*/
+    0,                                           /*tp_free*/
+    0,                                           /*tp_is_gc*/
+  };

Deleted: trunk/concordance/src/sockets/Client.h
===================================================================
--- trunk/concordance/src/sockets/Client.h      2009-01-18 22:52:02 UTC (rev 
1497)
+++ trunk/concordance/src/sockets/Client.h      2009-01-19 01:45:45 UTC (rev 
1498)
@@ -1,27 +0,0 @@
-/*
-# Concordance XMPP Service Framework
-#
-# Copyright (C) 2009 Copyleft Games Group
-#
-#  This program is free software; you can redistribute it and/or modify
-#  it under the terms of the GNU Affero General Public License as published
-#  by the Free Software Foundation, either version 3 of the License, or
-#  (at your option) any later version.
-#
-#  This program is distributed in the hope that it will be useful,
-#  but WITHOUT ANY WARRANTY; without even the implied warranty of
-#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#  GNU Affero General Public License for more details.
-#
-#  You should have received a copy of the GNU Affero General Public License
-#  along with this program; if not, see http://www.gnu.org/licenses
-#
-# $Id$
-*/
-
-#ifndef SOCKETS_SOCKET_H
-#define SOCKETS_SOCKET_H
-
-#include "__init__.h"
-
-#endif

Modified: trunk/concordance/src/sockets/Socket.c
===================================================================
--- trunk/concordance/src/sockets/Socket.c      2009-01-18 22:52:02 UTC (rev 
1497)
+++ trunk/concordance/src/sockets/Socket.c      2009-01-19 01:45:45 UTC (rev 
1498)
@@ -19,7 +19,7 @@
 # $Id$
 */
 
-#include "Socket.h"
+#include "concordance.sockets.h"
 
                                                                           /*\
 cdef class Socket :                                                       \*/

Deleted: trunk/concordance/src/sockets/Socket.h
===================================================================
--- trunk/concordance/src/sockets/Socket.h      2009-01-18 22:52:02 UTC (rev 
1497)
+++ trunk/concordance/src/sockets/Socket.h      2009-01-19 01:45:45 UTC (rev 
1498)
@@ -1,27 +0,0 @@
-/*
-# Concordance XMPP Service Framework
-#
-# Copyright (C) 2009 Copyleft Games Group
-#
-#  This program is free software; you can redistribute it and/or modify
-#  it under the terms of the GNU Affero General Public License as published
-#  by the Free Software Foundation, either version 3 of the License, or
-#  (at your option) any later version.
-#
-#  This program is distributed in the hope that it will be useful,
-#  but WITHOUT ANY WARRANTY; without even the implied warranty of
-#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#  GNU Affero General Public License for more details.
-#
-#  You should have received a copy of the GNU Affero General Public License
-#  along with this program; if not, see http://www.gnu.org/licenses
-#
-# $Id$
-*/
-
-#ifndef SOCKETS_SOCKET_H
-#define SOCKETS_SOCKET_H
-
-#include "__init__.h"
-
-#endif

Deleted: trunk/concordance/src/sockets/__init__.c
===================================================================
--- trunk/concordance/src/sockets/__init__.c    2009-01-18 22:52:02 UTC (rev 
1497)
+++ trunk/concordance/src/sockets/__init__.c    2009-01-19 01:45:45 UTC (rev 
1498)
@@ -1,105 +0,0 @@
-/*
-# Concordance XMPP Service Framework
-#
-# Copyright (C) 2009 Copyleft Games Group
-#
-#  This program is free software; you can redistribute it and/or modify
-#  it under the terms of the GNU Affero General Public License as published
-#  by the Free Software Foundation, either version 3 of the License, or
-#  (at your option) any later version.
-#
-#  This program is distributed in the hope that it will be useful,
-#  but WITHOUT ANY WARRANTY; without even the implied warranty of
-#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#  GNU Affero General Public License for more details.
-#
-#  You should have received a copy of the GNU Affero General Public License
-#  along with this program; if not, see http://www.gnu.org/licenses
-#
-# $Id$
-*/
-
-#include "__init__.h"
-
-
-static PyMethodDef sockets_Methods[] = {
-  { NULL, NULL }
-};
-
-static struct PyModuleDef sockets_Module = {
-  PyModuleDef_HEAD_INIT,
-  "sockets",                           /*m_name*/
-  "Test Help",                         /*m_doc*/
-  sizeof(gpointer),                    /*m_size*/
-  sockets_Methods,                     /*m_methods*/
-  NULL,                                /*m_reload*/
-  NULL,                                /*m_traverse*/
-  NULL,                                /*m_clear*/
-  NULL                                 /*m_free*/
-};
-
-PyMODINIT_FUNC
-PyInit_sockets(void) {                                                    /*\
-  cdef :                                                                  \*/
-    gpointer            _core;
-    PyObject*           module;
-
-  /* Initialize Glib threading support
-
-     gboolean  g_thread_supported  ();
-       This function returns TRUE if the thread system is initialized, and 
-       FALSE if it is not. 
-
-     void      g_thread_init       (GThreadFunctions *vtable);
-       If you use GLib from more than one thread, you must initialize the 
-       thread system by calling g_thread_init(). Most of the time you will 
-       only have to call g_thread_init (NULL).
-  */
-  if (!g_thread_supported()) g_thread_init(NULL);
-
-  /* Initialize all types prior to module creation
-
-     int PyType_Ready(PyTypeObject*)
-       Finalize a type object. This should be called on all type objects to 
-       finish their initialization. This function is responsible for adding 
-       inherited slots from a type’s base class.
-       Return 0 on success, or return -1 and sets an exception on error.
-  */
-  if (PyType_Ready(&socketsSocket_Type) < 0)
-    return NULL;
-  if (PyType_Ready(&socketsClient_Type) < 0)
-    return NULL;
-
-  /* Get a handle to _core or fail
-
-     PyObject*          PyImport_ImportModule    (const char *name);
-  */
-  if (!(_core = (gpointer) PyImport_ImportModule("concordance._core")))
-    return NULL;
-
-  /* Create concordance module object
-
-     PyObject* PyModule_Create(struct PyModuleDef*)
-  */
-  module = PyModule_Create(&sockets_Module);
-
-  /* Record _core in module state so we can decref during garbage collection
-
-     void*              PyModule_GetState        (PyObject*);
-  */
-  *(gpointer*) PyModule_GetState(module) = _core;
-
-  /* incref each extension type */
-  Py_INCREF(&socketsSocket_Type);
-  Py_INCREF(&socketsClient_Type);
-
-  /* Add classes to the concordance module object
-
-     int PyModule_AddObject(PyObject*, const char*, PyObject*);
-  */
-  PyModule_AddObject(module, "Socket", (PyObject*) &socketsSocket_Type);
-  PyModule_AddObject(module, "Client", (PyObject*) &socketsClient_Type);
-
-  /* return the module object to Python */
-  return module;
-}

Added: trunk/concordance/src/sockets/__init__.c
===================================================================
--- trunk/concordance/src/sockets/__init__.c                            (rev 0)
+++ trunk/concordance/src/sockets/__init__.c    2009-01-19 01:45:45 UTC (rev 
1498)
@@ -0,0 +1,105 @@
+/*
+# Concordance XMPP Service Framework
+#
+# Copyright (C) 2009 Copyleft Games Group
+#
+#  This program is free software; you can redistribute it and/or modify
+#  it under the terms of the GNU Affero General Public License as published
+#  by the Free Software Foundation, either version 3 of the License, or
+#  (at your option) any later version.
+#
+#  This program is distributed in the hope that it will be useful,
+#  but WITHOUT ANY WARRANTY; without even the implied warranty of
+#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+#  GNU Affero General Public License for more details.
+#
+#  You should have received a copy of the GNU Affero General Public License
+#  along with this program; if not, see http://www.gnu.org/licenses
+#
+# $Id$
+*/
+
+#include "concordance.sockets.h"
+
+
+static PyMethodDef sockets_Methods[] = {
+  { NULL, NULL }
+};
+
+static struct PyModuleDef sockets_Module = {
+  PyModuleDef_HEAD_INIT,
+  "sockets",                           /*m_name*/
+  "Test Help",                         /*m_doc*/
+  sizeof(gpointer),                    /*m_size*/
+  sockets_Methods,                     /*m_methods*/
+  NULL,                                /*m_reload*/
+  NULL,                                /*m_traverse*/
+  NULL,                                /*m_clear*/
+  NULL                                 /*m_free*/
+};
+
+PyMODINIT_FUNC
+PyInit_sockets(void) {                                                    /*\
+  cdef :                                                                  \*/
+    gpointer            _core;
+    PyObject*           module;
+
+  /* Initialize Glib threading support
+
+     gboolean  g_thread_supported  ();
+       This function returns TRUE if the thread system is initialized, and 
+       FALSE if it is not. 
+
+     void      g_thread_init       (GThreadFunctions *vtable);
+       If you use GLib from more than one thread, you must initialize the 
+       thread system by calling g_thread_init(). Most of the time you will 
+       only have to call g_thread_init (NULL).
+  */
+  if (!g_thread_supported()) g_thread_init(NULL);
+
+  /* Initialize all types prior to module creation
+
+     int PyType_Ready(PyTypeObject*)
+       Finalize a type object. This should be called on all type objects to 
+       finish their initialization. This function is responsible for adding 
+       inherited slots from a type’s base class.
+       Return 0 on success, or return -1 and sets an exception on error.
+  */
+  if (PyType_Ready(&socketsSocket_Type) < 0)
+    return NULL;
+  if (PyType_Ready(&socketsClient_Type) < 0)
+    return NULL;
+
+  /* Get a handle to _core or fail
+
+     PyObject*          PyImport_ImportModule    (const char *name);
+  */
+  if (!(_core = (gpointer) PyImport_ImportModule("concordance._core")))
+    return NULL;
+
+  /* Create concordance module object
+
+     PyObject* PyModule_Create(struct PyModuleDef*)
+  */
+  module = PyModule_Create(&sockets_Module);
+
+  /* Record _core in module state so we can decref during garbage collection
+
+     void*              PyModule_GetState        (PyObject*);
+  */
+  *(gpointer*) PyModule_GetState(module) = _core;
+
+  /* incref each extension type */
+  Py_INCREF(&socketsSocket_Type);
+  Py_INCREF(&socketsClient_Type);
+
+  /* Add classes to the concordance module object
+
+     int PyModule_AddObject(PyObject*, const char*, PyObject*);
+  */
+  PyModule_AddObject(module, "Socket", (PyObject*) &socketsSocket_Type);
+  PyModule_AddObject(module, "Client", (PyObject*) &socketsClient_Type);
+
+  /* return the module object to Python */
+  return module;
+}

Deleted: trunk/concordance/src/sockets/__init__.h
===================================================================
--- trunk/concordance/src/sockets/__init__.h    2009-01-18 22:52:02 UTC (rev 
1497)
+++ trunk/concordance/src/sockets/__init__.h    2009-01-19 01:45:45 UTC (rev 
1498)
@@ -1,56 +0,0 @@
-/*
-# Concordance XMPP Service Framework
-#
-# Copyright (C) 2009 Copyleft Games Group
-#
-#  This program is free software; you can redistribute it and/or modify
-#  it under the terms of the GNU Affero General Public License as published
-#  by the Free Software Foundation, either version 3 of the License, or
-#  (at your option) any later version.
-#
-#  This program is distributed in the hope that it will be useful,
-#  but WITHOUT ANY WARRANTY; without even the implied warranty of
-#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-#  GNU Affero General Public License for more details.
-#
-#  You should have received a copy of the GNU Affero General Public License
-#  along with this program; if not, see http://www.gnu.org/licenses
-#
-# $Id$
-*/
-
-#ifndef SOCKETS_INIT_H
-#define SOCKETS_INIT_H
-
-#include "../_core/__init__.h"
-
-
-/* concordance.sockets.Socket definition */
-PyTypeObject socketsSocket_Type;
-
-typedef struct {
-  PyObject_HEAD
-  PyObject*             module;        /* reference to our own module */
-  GMainContext*         context;       /* Concordance's Glib context */
-  const gchar*          addr;
-  gushort               port;
-  int                   sock;
-  GIOChannel*           chan;
-} socketsSocket_Object;
-
-
-/* concordance.sockets.Socket definition */
-PyTypeObject socketsClient_Type;
-
-typedef struct {
-  PyObject_HEAD
-  PyObject*             module;        /* reference to our own module */
-  GMainContext*         context;       /* Concordance's Glib context */
-  const gchar*          addr;
-  gushort               port;
-  int                   sock;
-  GIOChannel*           chan;
-} socketsClient_Object;
-
-
-#endif

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

Reply via email to