logo       

cvs: pear /PECL/python python.c: msg#00658

php.cvs.pear

Subject: cvs: pear /PECL/python python.c

jon Sun Sep 29 15:37:06 2002 EDT

Modified files:
/pear/PECL/python python.c
Log:
A little reorganization / renaming to make things a little clearer.


Index: pear/PECL/python/python.c
diff -u pear/PECL/python/python.c:1.5 pear/PECL/python/python.c:1.6
--- pear/PECL/python/python.c:1.5 Thu Sep 19 20:39:00 2002
+++ pear/PECL/python/python.c Sun Sep 29 15:37:06 2002
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/

-/* $Id: python.c,v 1.5 2002/09/20 00:39:00 jon Exp $ */
+/* $Id: python.c,v 1.6 2002/09/29 19:37:06 jon Exp $ */

/*
* TODO:
@@ -476,63 +476,23 @@
* call PHP functions made available by the "php" module constructed above.
*/

-/* {{{ globals
-*/
-ZEND_BEGIN_MODULE_GLOBALS(python)
- PyObject *interpreters;
- char *paths;
-ZEND_END_MODULE_GLOBALS(python)
-
-ZEND_DECLARE_MODULE_GLOBALS(python)
-/* }}} */
-
-/* {{{ init_globals
- */
-static void
-init_globals(zend_python_globals *python_globals TSRMLS_DC)
-{
- memset(python_globals, 0, sizeof(zend_python_globals));
-}
-/* }}} */
-
-/* {{{ python_error
- */
-static void
-python_error(int error_type)
-{
- PyObject *ptype, *pvalue, *ptraceback;
- PyObject *type, *value;
-
- /* Fetch the last error and store the type and value as strings. */
- PyErr_Fetch(&ptype, &pvalue, &ptraceback);
- type = PyObject_Str(ptype);
- value = PyObject_Str(pvalue);
-
- Py_XDECREF(ptype);
- Py_XDECREF(pvalue);
- Py_XDECREF(ptraceback);
+/* Utility Functions */

- /* Output the error to the user using php_error. */
- php_error(error_type, "Python: [%s] '%s'", PyString_AsString(type),
- PyString_AsString(value));
-}
-/* }}} */
-
-/* {{{ python_prependpath
+/* {{{ _prepend_syspath
*/
static void
-python_prependpath(const char *dir)
+_prepend_syspath(const char *dir)
{
if (dir) {
PyObject *sys;
PyObject *path;
PyObject *dirstr;

- /* Prepend dir to sys.path if it's not already there. */
sys = PyImport_ImportModule("sys");
path = PyObject_GetAttrString(sys, "path");
dirstr = PyString_FromString(dir);

+ /* Prepend dir to sys.path if it's not already there. */
if (PySequence_Index(path, dirstr) == -1) {
PyObject *list;
PyErr_Clear();
@@ -558,12 +518,56 @@

path = strtok((char *)paths, delim);
while (path != NULL) {
- python_prependpath(path);
+ _prepend_syspath(path);
path = strtok(NULL, delim);
}
}
/* }}} */

+/* {{{ python_error
+ */
+static void
+python_error(int error_type)
+{
+ PyObject *ptype, *pvalue, *ptraceback;
+ PyObject *type, *value;
+
+ /* Fetch the last error and store the type and value as strings. */
+ PyErr_Fetch(&ptype, &pvalue, &ptraceback);
+ type = PyObject_Str(ptype);
+ value = PyObject_Str(pvalue);
+
+ Py_XDECREF(ptype);
+ Py_XDECREF(pvalue);
+ Py_XDECREF(ptraceback);
+
+ /* Output the error to the user using php_error. */
+ php_error(error_type, "Python: [%s] '%s'", PyString_AsString(type),
+ PyString_AsString(value));
+}
+/* }}} */
+
+/* PHP Extension Stuff */
+
+/* {{{ globals
+*/
+ZEND_BEGIN_MODULE_GLOBALS(python)
+ PyObject *interpreters;
+ char *paths;
+ZEND_END_MODULE_GLOBALS(python)
+
+ZEND_DECLARE_MODULE_GLOBALS(python)
+/* }}} */
+
+/* {{{ init_globals
+ */
+static void
+init_globals(zend_python_globals *python_globals TSRMLS_DC)
+{
+ memset(python_globals, 0, sizeof(zend_python_globals));
+}
+/* }}} */
+
/* {{{ python_call_function_handler
Function call handler */
void
@@ -923,6 +927,8 @@
php_info_print_table_end();
}
/* }}} */
+
+/* PHP Python Functions */

/* {{{ proto void py_eval(string code)
Evaluate the given string of code by passing it to the interpreter */



--
PEAR CVS Mailing List (http://pear.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise