|
From: Andre R. <and...@us...> - 2004-11-24 18:52:45
|
Update of /cvsroot/frontierkernel/Frontier/Common/source In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20353 Modified Files: Tag: sidewinder-branch langpython.c Log Message: Reorganized platform ifdefs at top of file slightly to make clear what works and what doesn't work yet. Added a few more types from the Python C API. In runstringverb, lock the pythonCode handle before dereferencing and passing the resulting pointer in to the Python interpreter. Index: langpython.c =================================================================== RCS file: /cvsroot/frontierkernel/Frontier/Common/source/langpython.c,v retrieving revision 1.2.4.13 retrieving revision 1.2.4.14 diff -C2 -d -r1.2.4.13 -r1.2.4.14 *** langpython.c 24 Nov 2004 07:16:26 -0000 1.2.4.13 --- langpython.c 24 Nov 2004 18:52:20 -0000 1.2.4.14 *************** *** 27,36 **** #include "standard.h" - #ifdef MACVERSION - #include <iac.h> - #endif - #include "error.h" - //#include "file.h" #include "memory.h" #include "ops.h" --- 27,31 ---- *************** *** 38,47 **** #include "strings.h" #include "lang.h" - //#include "langipc.h" #include "langinternal.h" #include "langexternal.h" - //#include "langsystem7.h" - //#include "langhtml.h" - //#include "langwinipc.h" //#include "process.h" //#include "tableinternal.h" --- 33,38 ---- *************** *** 54,63 **** #include "kernelverbs.h" #include "kernelverbdefs.h" - //#include "shell.rsrc.h" //#include "timedate.h" - //#include "winsocknetevents.h" - //#ifdef flcomponent - //#include "osacomponent.h" - //#endif #ifdef MACVERSION --- 45,49 ---- *************** *** 65,85 **** #endif #ifdef FRONTIER_PYTHON #include "langpython.h" ! #if defined(MACVERSION) && defined(TARGET_RT_MAC_MACHO) #include <Python/Python.h> ! #else ! #ifdef WIN95VERSION /*otherwise debug build of Frontier requires debug build of python dll*/ ! #undef _DEBUG ! #endif ! #include <Python.h> - #endif #include <time.h> --- 51,90 ---- #endif + #ifdef FRONTIER_PYTHON + #include "langpython.h" ! ! #if defined(WIN95VERSION) ! ! #undef _DEBUG /*otherwise debug build of Frontier requires debug build of python dll*/ ! #include <Python.h> ! ! #elif defined(MACVERSION) ! ! #if TARGET_API_MAC_CARBON ! ! #if TARGET_RT_MAC_MACHO #include <Python/Python.h> ! #elif TARGET_RT_MAC_CFM ! #error "Python integration is not yet supported in the OS X CFM build" ! #endif /*TARGET_RT_MAC_CFM*/ ! ! #endif /*TARGET_API_MAC_CARBON*/ ! ! #if TARGET_API_MAC_CLASSIC ! ! #error "Python integration is not yet supported in the PPC build" ! ! #endif /*TARGET_API_MAC_CLASSIC*/ ! ! #endif /*MACVERSION*/ #include <time.h> *************** *** 203,206 **** --- 208,213 ---- PyTypeObject * ptr_PyTuple_Type; /*tupleobject.h*/ + + PyTypeObject * ptr_PyUnicode_Type; /*unicodeobject.h*/ } py; *************** *** 286,289 **** --- 293,297 ---- #define PySlice_Type (*py.ptr_PySlice_Type) + #define PyString_Type (*py.ptr_PyString_Type) #define PyString_AsString (*py.ptr_PyString_AsString) *************** *** 291,294 **** --- 299,304 ---- #define PyTuple_Type (*py.ptr_PyTuple_Type) + + #define PyUnicode_Type (*py.ptr_PyUnicode_Type) #if defined(WIN95VERSION) *************** *** 349,352 **** --- 359,364 ---- fl = fl && importsymbol (hm, "PyDict_SetItemString", (void**) &py.ptr_PyDict_SetItemString); + fl = fl && importsymbol (hm, "PyFile_Type", (void**) &py.ptr_PyFile_Type); + fl = fl && importsymbol (hm, "PyFloat_Type", (void**) &py.ptr_PyFloat_Type); fl = fl && importsymbol (hm, "PyFloat_AsDouble", (void**) &py.ptr_PyFloat_AsDouble); *************** *** 354,357 **** --- 366,371 ---- fl = fl && importsymbol (hm, "PyInt_Type", (void**) &py.ptr_PyInt_Type); fl = fl && importsymbol (hm, "PyInt_AsLong", (void**) &py.ptr_PyInt_AsLong); + + fl = fl && importsymbol (hm, "PySeqIter_Type", (void**) &py.ptr_PySeqIter_Type); fl = fl && importsymbol (hm, "PyList_Append", (void**) &py.ptr_PyList_Append); *************** *** 363,366 **** --- 377,381 ---- fl = fl && importsymbol (hm, "PyLong_Type", (void**) &py.ptr_PyLong_Type); + fl = fl && importsymbol (hm, "PyMethod_Type", (void**) &py.ptr_PyMethod_Type); fl = fl && importsymbol (hm, "Py_FindMethod", (void**) &py.ptr_Py_FindMethod); *************** *** 371,374 **** --- 386,390 ---- fl = fl && importsymbol (hm, "_Py_NoneStruct", (void**) &py.ptr__Py_NoneStruct); + fl = fl && importsymbol (hm, "PyType_Type", (void**) &py.ptr_PyType_Type); fl = fl && importsymbol (hm, "PyObject_GetAttrString", (void**) &py.ptr_PyObject_GetAttrString); fl = fl && importsymbol (hm, "PyObject_Str", (void**) &py.ptr_PyObject_Str); *************** *** 402,409 **** --- 418,430 ---- fl = fl && importsymbol (hm, "PyRun_String", (void**) &py.ptr_PyRun_String); + fl = fl && importsymbol (hm, "PySlice_Type", (void**) &py.ptr_PySlice_Type); + fl = fl && importsymbol (hm, "PyString_Type", (void**) &py.ptr_PyString_Type); fl = fl && importsymbol (hm, "PyString_AsString", (void**) &py.ptr_PyString_AsString); fl = fl && importsymbol (hm, "PyString_FromString", (void**) &py.ptr_PyString_FromString); + fl = fl && importsymbol (hm, "PyTuple_Type", (void**) &py.ptr_PyTuple_Type); + + fl = fl && importsymbol (hm, "PyUnicode_Type", (void**) &py.ptr_PyUnicode_Type); if (fl) { *************** *** 1496,1500 **** --- 1517,1523 ---- // run the python code // + lockhandle (pythonCode); result = PyRun_String(*pythonCode, Py_file_input, globals, locals); + unlockhandle (pythonCode); if (result) Py_DECREF(result); err = PyErr_Occurred(); |