Author: ArcRiley Date: 2009-02-26 18:28:11 -0500 (Thu, 26 Feb 2009) New Revision: 1531
Added: trunk/concordance/include/concordance._core.h Modified: trunk/concordance/include/concordance.h trunk/concordance/setup.py trunk/concordance/src/_core/__init__.c trunk/concordance/src/_core/step.c Log: some more work on callbacks - this doesn't compile Added: trunk/concordance/include/concordance._core.h =================================================================== --- trunk/concordance/include/concordance._core.h (rev 0) +++ trunk/concordance/include/concordance._core.h 2009-02-26 23:28:11 UTC (rev 1531) @@ -0,0 +1,30 @@ +/* +# 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__CORE_H +#define CONCORDANCE__CORE_H + +#include "concordance.h" + +PyObject* concordStep(); +extern concordGlobals* globals; + +#endif Modified: trunk/concordance/include/concordance.h =================================================================== --- trunk/concordance/include/concordance.h 2009-02-26 22:56:11 UTC (rev 1530) +++ trunk/concordance/include/concordance.h 2009-02-26 23:28:11 UTC (rev 1531) @@ -51,6 +51,18 @@ } concordGlobals; typedef struct { + PyObject* self; + gchar* method; + GString* message; +} concordCore_QueueMsg; + + +typedef struct { + GSource base; + PyObject* self; +} concordCore_QueueSource; + +typedef struct { guint major; guint minor; } concordVersion; Modified: trunk/concordance/setup.py =================================================================== --- trunk/concordance/setup.py 2009-02-26 22:56:11 UTC (rev 1530) +++ trunk/concordance/setup.py 2009-02-26 23:28:11 UTC (rev 1531) @@ -90,6 +90,7 @@ Extension( name = '_core', sources = ['src/_core/__init__.c', + 'src/_core/step.c', 'src/utils.c', ], include_dirs = include_dirs, Modified: trunk/concordance/src/_core/__init__.c =================================================================== --- trunk/concordance/src/_core/__init__.c 2009-02-26 22:56:11 UTC (rev 1530) +++ trunk/concordance/src/_core/__init__.c 2009-02-26 23:28:11 UTC (rev 1531) @@ -19,7 +19,7 @@ # $Id$ */ -#include "concordance.h" +#include "concordance._core.h" static gpointer _core_loop(gpointer n) { @@ -38,7 +38,7 @@ static PyMethodDef concord_Methods[] = { - { "step", concordStep, NULL, NULL }, + { "step", concordStep, 0, NULL }, { NULL, NULL } }; @@ -60,7 +60,6 @@ PyInit__core(void) { /*\ cdef : \*/ PyObject* module; - concordGlobals* globals; /* Initialize Glib threading support @@ -131,3 +130,5 @@ /* return the module object to Python */ return module; } + +concordGlobals* globals; Modified: trunk/concordance/src/_core/step.c =================================================================== --- trunk/concordance/src/_core/step.c 2009-02-26 22:56:11 UTC (rev 1530) +++ trunk/concordance/src/_core/step.c 2009-02-26 23:28:11 UTC (rev 1531) @@ -19,12 +19,25 @@ # $Id: Core.c 1485 2009-01-17 03:19:45Z ArcRiley $ */ -#include "concordance.h" +#include "concordance._core.h" -static PyObject* +static void +concordCore_queueFreeMsg(concordCore_QueueMsg* msg) { + /* free message struct and it's members + + gchar* g_string_free (GString *string, + gboolean free_segment); + void g_free (gpointer mem); + */ + g_free(msg->method); + g_string_free(msg->message, TRUE); + g_free(msg); +} + + +PyObject* concordStep() { /*\ cdef : \*/ - concordCore_Object* self = (concordCore_Object*) s; PyObject* output; concordCore_QueueMsg* popped; GTimeVal popEnd; @@ -44,7 +57,7 @@ GTimeVal *end_time); */ Py_BEGIN_ALLOW_THREADS - popped = g_async_queue_timed_pop(self->queueRecv, &popEnd); + popped = g_async_queue_timed_pop(globals->queueRecv, &popEnd); Py_END_ALLOW_THREADS /* return if the pop call timed out */ @@ -69,21 +82,21 @@ Convert a C string and its length to a Python unicode object. If the C string pointer is NULL, the length is ignored and None is returned. */ - output = PyEval_CallMethod(s, "clientHandle", "OU#", - popped->session->self, - popped->message->str, popped->message->len); + output = PyEval_CallMethod(popped->self, popped->method, "OU#", + popped->self, + popped->message->str, popped->message->len); if (!output) { /* free message struct and exit here if callback raised an error */ concordCore_queueFreeMsg(popped); - break; + return; } /* if output is None, decref it, free message struct, and continue */ if (output == Py_None) { Py_DECREF(output); concordCore_queueFreeMsg(popped); - continue; + return; } /* ensure output is PyUnicode_Type (since it's not None) _______________________________________________ PySoy-SVN mailing list PySoy-SVN@pysoy.org http://www.pysoy.org/mailman/listinfo/pysoy-svn