本文整理汇总了C++中PyDict_SetItemString函数的典型用法代码示例。如果您正苦于以下问题:C++ PyDict_SetItemString函数的具体用法?C++ PyDict_SetItemString怎么用?C++ PyDict_SetItemString使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PyDict_SetItemString函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: readTable
//.........这里部分代码省略.........
if(debugMode)
fprintf(debugFile, "HSpiceRead: failed to create array.\n");
for(j = 0; j < i + 1; j++) Py_XDECREF(tmpArray[j]);
goto readTableFailed;
}
}
for(i = 0; i < numOfVectors; i++) // Prepare fast access structures.
{
faPtr[i].data = ((PyArrayObject *)(tmpArray[i]))->data;
faPtr[i].pos = ((PyArrayObject *)(tmpArray[i]))->data;
faPtr[i].stride =
((PyArrayObject *)(tmpArray[i]))->strides[((PyArrayObject *)(tmpArray[i]))->nd -
1];
faPtr[i].length = PyArray_Size(tmpArray[i]);
}
if(postVersion == 2001)
{
for(i = 0; i < num; i++) // Save raw data.
{
struct FastArray *faPos = faPtr;
for(j = 0; j < numOfVectors; j++)
{
if(type == complex_var && j > 0 && j < numOfVariables)
{
((npy_cdouble *)(faPos->pos))->real = *((double *)rawDataPos);
rawDataPos = rawDataPos + 2;
((npy_cdouble *)(faPos->pos))->imag = *((double *)rawDataPos);
} else *((npy_double *)(faPos->pos)) = *((double *)rawDataPos);
rawDataPos = rawDataPos + 2;
faPos->pos = faPos->pos + faPos->stride;
faPos = faPos + 1;
}
}
}
else
{
for(i = 0; i < num; i++) // Save raw data.
{
struct FastArray *faPos = faPtr;
for(j = 0; j < numOfVectors; j++)
{
if(type == complex_var && j > 0 && j < numOfVariables)
{
((npy_cdouble *)(faPos->pos))->real = *rawDataPos;
rawDataPos = rawDataPos + 1;
((npy_cdouble *)(faPos->pos))->imag = *rawDataPos;
} else *((npy_double *)(faPos->pos)) = *rawDataPos;
rawDataPos = rawDataPos + 1;
faPos->pos = faPos->pos + faPos->stride;
faPos = faPos + 1;
}
}
}
PyMem_Free(rawData);
rawData = NULL;
// Insert vectors into dictionary.
num = PyDict_SetItemString(data, scale, tmpArray[0]);
i = -1;
if(num == 0) for(i = 0; i < numOfVectors - 1; i++)
{
num = PyDict_SetItemString(data, name[i], tmpArray[i + 1]);
if(num != 0) break;
}
for(j = 0; j < numOfVectors; j++) Py_XDECREF(tmpArray[j]);
if(num)
{
if(debugMode) {
if(i == -1) fprintf(debugFile,
"HSpiceRead: failed to insert vector %s into dictionary.\n",
scale);
else fprintf(debugFile,
"HSpiceRead: failed to insert vector %s into dictionary.\n",
name[i]);
}
goto readTableFailed;
}
// Insert table into the list of data dictionaries.
num = PyList_Append(dataList, data);
if(num)
{
if(debugMode) fprintf(debugFile,
"HSpiceRead: failed to append table to the list of data dictionaries.\n");
goto readTableFailed;
}
Py_XDECREF(data);
data = NULL;
return 0;
readTableFailed:
PyMem_Free(rawData);
Py_XDECREF(data);
return 1;
}
开发者ID:xanderhsia,项目名称:pyopus,代码行数:101,代码来源:hspice_read.c
示例2: RtAudio_getDeviceInfo
static PyObject *
RtAudio_getDeviceInfo(PyRtAudio *self, PyObject *args)
{
int device;
RtAudioDeviceInfo info;
PyObject *name = NULL;
PyObject *probed = NULL;
PyObject *outputChannels = NULL;
PyObject *inputChannels = NULL;
PyObject *duplexChannels = NULL;
PyObject *isDefault = NULL;
PyObject *sampleRates = NULL;
PyObject *nativeFormats = NULL;
PyObject *deviceInfo = NULL;
if(!PyArg_ParseTuple(args, "i", &device))
return NULL;
try
{
info = self->rtaudio->getDeviceInfo(device);
}
catch(RtError &error)
{
PyErr_Format(RtAudioError, error.getMessageString());
return NULL;
}
name = PyString_FromString(info.name.c_str());
if(name == NULL) return NULL;
if(info.probed)
{
probed = Py_True;
Py_INCREF(Py_True);
}
else
{
probed = Py_False;
Py_INCREF(Py_False);
}
outputChannels = PyInt_FromLong(info.outputChannels);
if(outputChannels == NULL) goto fail;
inputChannels = PyInt_FromLong(info.inputChannels);
if(inputChannels == NULL) goto fail;
duplexChannels = PyInt_FromLong(info.duplexChannels);
if(duplexChannels == NULL) goto fail;
if(info.isDefault)
{
isDefault = Py_True;
Py_INCREF(Py_True);
}
else
{
isDefault = Py_False;
Py_INCREF(Py_False);
}
sampleRates = PyTuple_New(info.sampleRates.size());
if(sampleRates == NULL)
goto fail;
for(uint i=0; i < info.sampleRates.size(); i++)
{
PyObject *rate = PyInt_FromLong(info.sampleRates[i]);
if(rate == NULL)
goto fail;
if(PyTuple_SetItem(sampleRates, i, rate))
{
Py_DECREF(rate);
goto fail;
}
}
nativeFormats = PyLong_FromUnsignedLong(info.nativeFormats);
if(nativeFormats == NULL)
return NULL;
deviceInfo = PyDict_New();
if(deviceInfo == NULL)
goto fail;
if(PyDict_SetItemString(deviceInfo, "name", name))
goto fail;
if(PyDict_SetItemString(deviceInfo, "probed", probed))
goto fail;
if(PyDict_SetItemString(deviceInfo, "outputChannels", outputChannels))
goto fail;
if(PyDict_SetItemString(deviceInfo, "inputChannels", inputChannels))
goto fail;
if(PyDict_SetItemString(deviceInfo, "deviceChannels", duplexChannels))
goto fail;
if(PyDict_SetItemString(deviceInfo, "isDefault", isDefault))
goto fail;
//.........这里部分代码省略.........
开发者ID:RikVerschueren,项目名称:AccordionMega,代码行数:101,代码来源:rtaudiomodule.cpp
示例3: inittest_array_from_pyobj_ext
PyObject *PyInit_test_array_from_pyobj_ext(void) {
#else
#define RETVAL
PyMODINIT_FUNC inittest_array_from_pyobj_ext(void) {
#endif
PyObject *m,*d, *s;
#if PY_VERSION_HEX >= 0x03000000
m = wrap_module = PyModule_Create(&moduledef);
#else
m = wrap_module = Py_InitModule("test_array_from_pyobj_ext", f2py_module_methods);
#endif
Py_TYPE(&PyFortran_Type) = &PyType_Type;
import_array();
if (PyErr_Occurred())
Py_FatalError("can't initialize module wrap (failed to import numpy)");
d = PyModule_GetDict(m);
s = PyString_FromString("This module 'wrap' is auto-generated with f2py (version:2_1330).\nFunctions:\n"
" arr = call(type_num,dims,intent,obj)\n"
".");
PyDict_SetItemString(d, "__doc__", s);
wrap_error = PyErr_NewException ("wrap.error", NULL, NULL);
Py_DECREF(s);
PyDict_SetItemString(d, "F2PY_INTENT_IN", PyInt_FromLong(F2PY_INTENT_IN));
PyDict_SetItemString(d, "F2PY_INTENT_INOUT", PyInt_FromLong(F2PY_INTENT_INOUT));
PyDict_SetItemString(d, "F2PY_INTENT_OUT", PyInt_FromLong(F2PY_INTENT_OUT));
PyDict_SetItemString(d, "F2PY_INTENT_HIDE", PyInt_FromLong(F2PY_INTENT_HIDE));
PyDict_SetItemString(d, "F2PY_INTENT_CACHE", PyInt_FromLong(F2PY_INTENT_CACHE));
PyDict_SetItemString(d, "F2PY_INTENT_COPY", PyInt_FromLong(F2PY_INTENT_COPY));
PyDict_SetItemString(d, "F2PY_INTENT_C", PyInt_FromLong(F2PY_INTENT_C));
PyDict_SetItemString(d, "F2PY_OPTIONAL", PyInt_FromLong(F2PY_OPTIONAL));
PyDict_SetItemString(d, "F2PY_INTENT_INPLACE", PyInt_FromLong(F2PY_INTENT_INPLACE));
PyDict_SetItemString(d, "PyArray_BOOL", PyInt_FromLong(PyArray_BOOL));
PyDict_SetItemString(d, "PyArray_BYTE", PyInt_FromLong(PyArray_BYTE));
PyDict_SetItemString(d, "PyArray_UBYTE", PyInt_FromLong(PyArray_UBYTE));
PyDict_SetItemString(d, "PyArray_SHORT", PyInt_FromLong(PyArray_SHORT));
PyDict_SetItemString(d, "PyArray_USHORT", PyInt_FromLong(PyArray_USHORT));
PyDict_SetItemString(d, "PyArray_INT", PyInt_FromLong(PyArray_INT));
PyDict_SetItemString(d, "PyArray_UINT", PyInt_FromLong(PyArray_UINT));
PyDict_SetItemString(d, "PyArray_INTP", PyInt_FromLong(PyArray_INTP));
PyDict_SetItemString(d, "PyArray_UINTP", PyInt_FromLong(PyArray_UINTP));
PyDict_SetItemString(d, "PyArray_LONG", PyInt_FromLong(PyArray_LONG));
PyDict_SetItemString(d, "PyArray_ULONG", PyInt_FromLong(PyArray_ULONG));
PyDict_SetItemString(d, "PyArray_LONGLONG", PyInt_FromLong(PyArray_LONGLONG));
PyDict_SetItemString(d, "PyArray_ULONGLONG", PyInt_FromLong(PyArray_ULONGLONG));
PyDict_SetItemString(d, "PyArray_FLOAT", PyInt_FromLong(PyArray_FLOAT));
PyDict_SetItemString(d, "PyArray_DOUBLE", PyInt_FromLong(PyArray_DOUBLE));
PyDict_SetItemString(d, "PyArray_LONGDOUBLE", PyInt_FromLong(PyArray_LONGDOUBLE));
PyDict_SetItemString(d, "PyArray_CFLOAT", PyInt_FromLong(PyArray_CFLOAT));
PyDict_SetItemString(d, "PyArray_CDOUBLE", PyInt_FromLong(PyArray_CDOUBLE));
PyDict_SetItemString(d, "PyArray_CLONGDOUBLE", PyInt_FromLong(PyArray_CLONGDOUBLE));
PyDict_SetItemString(d, "PyArray_OBJECT", PyInt_FromLong(PyArray_OBJECT));
PyDict_SetItemString(d, "PyArray_STRING", PyInt_FromLong(PyArray_STRING));
PyDict_SetItemString(d, "PyArray_UNICODE", PyInt_FromLong(PyArray_UNICODE));
PyDict_SetItemString(d, "PyArray_VOID", PyInt_FromLong(PyArray_VOID));
PyDict_SetItemString(d, "PyArray_NTYPES", PyInt_FromLong(PyArray_NTYPES));
PyDict_SetItemString(d, "PyArray_NOTYPE", PyInt_FromLong(PyArray_NOTYPE));
PyDict_SetItemString(d, "PyArray_UDERDEF", PyInt_FromLong(PyArray_USERDEF));
PyDict_SetItemString(d, "CONTIGUOUS", PyInt_FromLong(NPY_CONTIGUOUS));
PyDict_SetItemString(d, "FORTRAN", PyInt_FromLong(NPY_FORTRAN));
PyDict_SetItemString(d, "OWNDATA", PyInt_FromLong(NPY_OWNDATA));
PyDict_SetItemString(d, "FORCECAST", PyInt_FromLong(NPY_FORCECAST));
PyDict_SetItemString(d, "ENSURECOPY", PyInt_FromLong(NPY_ENSURECOPY));
PyDict_SetItemString(d, "ENSUREARRAY", PyInt_FromLong(NPY_ENSUREARRAY));
PyDict_SetItemString(d, "ALIGNED", PyInt_FromLong(NPY_ALIGNED));
PyDict_SetItemString(d, "WRITEABLE", PyInt_FromLong(NPY_WRITEABLE));
PyDict_SetItemString(d, "UPDATEIFCOPY", PyInt_FromLong(NPY_UPDATEIFCOPY));
PyDict_SetItemString(d, "BEHAVED", PyInt_FromLong(NPY_BEHAVED));
PyDict_SetItemString(d, "BEHAVED_NS", PyInt_FromLong(NPY_BEHAVED_NS));
PyDict_SetItemString(d, "CARRAY", PyInt_FromLong(NPY_CARRAY));
PyDict_SetItemString(d, "FARRAY", PyInt_FromLong(NPY_FARRAY));
PyDict_SetItemString(d, "CARRAY_RO", PyInt_FromLong(NPY_CARRAY_RO));
PyDict_SetItemString(d, "FARRAY_RO", PyInt_FromLong(NPY_FARRAY_RO));
PyDict_SetItemString(d, "DEFAULT", PyInt_FromLong(NPY_DEFAULT));
PyDict_SetItemString(d, "UPDATE_ALL", PyInt_FromLong(NPY_UPDATE_ALL));
if (PyErr_Occurred())
Py_FatalError("can't initialize module wrap");
#ifdef F2PY_REPORT_ATEXIT
on_exit(f2py_report_on_exit,(void*)"array_from_pyobj.wrap.call");
#endif
return RETVAL;
}
开发者ID:8cH9azbsFifZ,项目名称:wspr,代码行数:86,代码来源:wrapmodule.c
示例4: python_orbstat
static PyObject *
python_orbstat( PyObject *self, PyObject *args ) {
char *usage = "Usage: _orbstat(orb)\n";
int orbfd;
Orbstat *os = 0;
char *ip;
struct in_addr addr;
int rc;
PyObject *obj;
if( ! PyArg_ParseTuple( args, "i", &orbfd ) ) {
if( ! PyErr_Occurred() ) {
PyErr_SetString( PyExc_RuntimeError, usage );
}
return NULL;
}
rc = orbstat( orbfd, &os );
if( rc < 0 ) {
PyErr_SetString( PyExc_RuntimeError, "error querying orb status" );
return NULL;
}
memcpy( &addr.s_addr, &os->address, 4 );
ip = inet_ntoa( addr );
obj = PyDict_New();
PyDict_SetItemString( obj, "when", Py_BuildValue( "f", os->when ) );
PyDict_SetItemString( obj, "started", Py_BuildValue( "f", os->started ) );
PyDict_SetItemString( obj, "orb_start", Py_BuildValue( "f", os->orb_start ) );
PyDict_SetItemString( obj, "connections", Py_BuildValue( "i", os->connections ) );
PyDict_SetItemString( obj, "messages", Py_BuildValue( "i", os->messages ) );
PyDict_SetItemString( obj, "maxdata", PyInt_FromLong( (long) os->maxdata ) );
PyDict_SetItemString( obj, "errors", Py_BuildValue( "i", os->errors ) );
PyDict_SetItemString( obj, "rejected", Py_BuildValue( "i", os->rejected ) );
PyDict_SetItemString( obj, "closes", Py_BuildValue( "i", os->closes ) );
PyDict_SetItemString( obj, "opens", Py_BuildValue( "i", os->opens ) );
PyDict_SetItemString( obj, "port", Py_BuildValue( "i", os->port ) );
PyDict_SetItemString( obj, "address", Py_BuildValue( "s", ip ) );
PyDict_SetItemString( obj, "pid", Py_BuildValue( "i", os->pid ) );
PyDict_SetItemString( obj, "nsources", Py_BuildValue( "i", os->nsources ) );
PyDict_SetItemString( obj, "nclients", Py_BuildValue( "i", os->nclients ) );
PyDict_SetItemString( obj, "maxsrc", Py_BuildValue( "i", os->maxsrc ) );
PyDict_SetItemString( obj, "maxpkts", Py_BuildValue( "i", os->maxpkts ) );
PyDict_SetItemString( obj, "version", Py_BuildValue( "s", os->version ) );
PyDict_SetItemString( obj, "who", Py_BuildValue( "s", os->who ) );
PyDict_SetItemString( obj, "host", Py_BuildValue( "s", os->host ) );
return obj;
}
开发者ID:vonseg,项目名称:antelope_contrib,代码行数:57,代码来源:_orb.c
示例5: PyImport_AddModule
bool mitk::PythonService::CopyToPythonAsSimpleItkImage(mitk::Image *image, const std::string &stdvarName)
{
QString varName = QString::fromStdString( stdvarName );
QString command;
unsigned int* imgDim = image->GetDimensions();
int npy_nd = 1;
npy_intp* npy_dims = new npy_intp[1];
npy_dims[0] = imgDim[0] * imgDim[1] * imgDim[2];
// access python module
PyObject *pyMod = PyImport_AddModule((char*)"__main__");
// global dictionarry
PyObject *pyDict = PyModule_GetDict(pyMod);
const mitk::Vector3D spacing = image->GetGeometry()->GetSpacing();
const mitk::Point3D origin = image->GetGeometry()->GetOrigin();
mitk::PixelType pixelType = image->GetPixelType();
itk::ImageIOBase::IOPixelType ioPixelType = image->GetPixelType().GetPixelType();
PyObject* npyArray = NULL;
mitk::ImageReadAccessor racc(image);
void* array = (void*) racc.GetData();
// default pixeltype: unsigned short
NPY_TYPES npy_type = NPY_USHORT;
std::string sitk_type = "sitkUInt8";
if( ioPixelType == itk::ImageIOBase::SCALAR )
{
if( pixelType.GetComponentType() == itk::ImageIOBase::DOUBLE ) {
npy_type = NPY_DOUBLE;
sitk_type = "sitkFloat64";
} else if( pixelType.GetComponentType() == itk::ImageIOBase::FLOAT ) {
npy_type = NPY_FLOAT;
sitk_type = "sitkFloat32";
} else if( pixelType.GetComponentType() == itk::ImageIOBase::SHORT) {
npy_type = NPY_SHORT;
sitk_type = "sitkInt16";
} else if( pixelType.GetComponentType() == itk::ImageIOBase::CHAR ) {
npy_type = NPY_BYTE;
sitk_type = "sitkInt8";
} else if( pixelType.GetComponentType() == itk::ImageIOBase::INT ) {
npy_type = NPY_INT;
sitk_type = "sitkInt32";
} else if( pixelType.GetComponentType() == itk::ImageIOBase::LONG ) {
npy_type = NPY_LONG;
sitk_type = "sitkInt64";
} else if( pixelType.GetComponentType() == itk::ImageIOBase::UCHAR ) {
npy_type = NPY_UBYTE;
sitk_type = "sitkUInt8";
} else if( pixelType.GetComponentType() == itk::ImageIOBase::UINT ) {
npy_type = NPY_UINT;
sitk_type = "sitkUInt32";
} else if( pixelType.GetComponentType() == itk::ImageIOBase::ULONG ) {
npy_type = NPY_LONG;
sitk_type = "sitkUInt64";
} else if( pixelType.GetComponentType() == itk::ImageIOBase::USHORT ) {
npy_type = NPY_USHORT;
sitk_type = "sitkUInt16";
}
} else {
MITK_WARN << "not a scalar pixeltype";
return false;
}
// creating numpy array
import_array1 (true);
npyArray = PyArray_SimpleNewFromData(npy_nd,npy_dims,npy_type,array);
// add temp array it to the python dictionary to access it in python code
const int status = PyDict_SetItemString( pyDict,QString("%1_numpy_array")
.arg(varName).toStdString().c_str(),
npyArray );
// sanity check
if ( status != 0 )
return false;
command.append( QString("%1 = sitk.Image(%2,%3,%4,sitk.%5)\n").arg(varName)
.arg(QString::number(imgDim[0]))
.arg(QString::number(imgDim[1]))
.arg(QString::number(imgDim[2]))
.arg(QString(sitk_type.c_str())) );
command.append( QString("%1.SetSpacing([%2,%3,%4])\n").arg(varName)
.arg(QString::number(spacing[0]))
.arg(QString::number(spacing[1]))
.arg(QString::number(spacing[2])) );
command.append( QString("%1.SetOrigin([%2,%3,%4])\n").arg(varName)
.arg(QString::number(origin[0]))
.arg(QString::number(origin[1]))
.arg(QString::number(origin[2])) );
// directly access the cpp api from the lib
command.append( QString("_SimpleITK._SetImageFromArray(%1_numpy_array,%1)\n").arg(varName) );
command.append( QString("del %1_numpy_array").arg(varName) );
MITK_DEBUG("PythonService") << "Issuing python command " << command.toStdString();
this->Execute( command.toStdString(), IPythonService::MULTI_LINE_COMMAND );
return true;
}
开发者ID:DiagnosisMultisystems,项目名称:MITK,代码行数:96,代码来源:mitkPythonService.cpp
示例6: PyInit_mathutils
PyMODINIT_FUNC PyInit_mathutils(void)
{
PyObject *mod;
PyObject *submodule;
PyObject *sys_modules = PyThreadState_GET()->interp->modules;
if (PyType_Ready(&vector_Type) < 0)
return NULL;
if (PyType_Ready(&matrix_Type) < 0)
return NULL;
if (PyType_Ready(&matrix_access_Type) < 0)
return NULL;
if (PyType_Ready(&euler_Type) < 0)
return NULL;
if (PyType_Ready(&quaternion_Type) < 0)
return NULL;
if (PyType_Ready(&color_Type) < 0)
return NULL;
mod = PyModule_Create(&M_Mathutils_module_def);
/* each type has its own new() function */
PyModule_AddObject(mod, vector_Type.tp_name, (PyObject *)&vector_Type);
PyModule_AddObject(mod, matrix_Type.tp_name, (PyObject *)&matrix_Type);
PyModule_AddObject(mod, euler_Type.tp_name, (PyObject *)&euler_Type);
PyModule_AddObject(mod, quaternion_Type.tp_name, (PyObject *)&quaternion_Type);
PyModule_AddObject(mod, color_Type.tp_name, (PyObject *)&color_Type);
/* submodule */
PyModule_AddObject(mod, "geometry", (submodule = PyInit_mathutils_geometry()));
/* XXX, python doesnt do imports with this usefully yet
* 'from mathutils.geometry import PolyFill'
* ...fails without this. */
PyDict_SetItemString(sys_modules, PyModule_GetName(submodule), submodule);
Py_INCREF(submodule);
PyModule_AddObject(mod, "interpolate", (submodule = PyInit_mathutils_interpolate()));
/* XXX, python doesnt do imports with this usefully yet
* 'from mathutils.geometry import PolyFill'
* ...fails without this. */
PyDict_SetItemString(sys_modules, PyModule_GetName(submodule), submodule);
Py_INCREF(submodule);
#ifndef MATH_STANDALONE
/* Noise submodule */
PyModule_AddObject(mod, "noise", (submodule = PyInit_mathutils_noise()));
PyDict_SetItemString(sys_modules, PyModule_GetName(submodule), submodule);
Py_INCREF(submodule);
/* BVHTree submodule */
PyModule_AddObject(mod, "bvhtree", (submodule = PyInit_mathutils_bvhtree()));
PyDict_SetItemString(sys_modules, PyModule_GetName(submodule), submodule);
Py_INCREF(submodule);
/* KDTree submodule */
PyModule_AddObject(mod, "kdtree", (submodule = PyInit_mathutils_kdtree()));
PyDict_SetItemString(sys_modules, PyModule_GetName(submodule), submodule);
Py_INCREF(submodule);
#endif
mathutils_matrix_row_cb_index = Mathutils_RegisterCallback(&mathutils_matrix_row_cb);
mathutils_matrix_col_cb_index = Mathutils_RegisterCallback(&mathutils_matrix_col_cb);
mathutils_matrix_translation_cb_index = Mathutils_RegisterCallback(&mathutils_matrix_translation_cb);
return mod;
}
开发者ID:JasonWilkins,项目名称:blender-viewport_fx,代码行数:66,代码来源:mathutils.c
示例7: gen_do_trig
//
// generalized function for setting up a dictionary and running a trigger. The
// common types of variables can be supplied in the function. Additional ones
// can be added in the optional list, which must be deleted after use
void gen_do_trig(TRIGGER_DATA *trig,
void *me, int me_type, CHAR_DATA *ch, OBJ_DATA *obj,
ROOM_DATA *room, EXIT_DATA *exit, const char *command,
const char *arg, LIST *optional) {
// make our basic dictionary, and fill it up with these new variables
PyObject *dict = restricted_script_dict();
LIST *varnames = newList();
// now, import all of our variables
if(command) {
PyObject *pycmd = PyString_FromString(command);
PyDict_SetItemString(dict, "cmd", pycmd);
listPut(varnames, strdup("cmd"));
Py_DECREF(pycmd);
}
if(arg) {
PyObject *pyarg = PyString_FromString(arg);
PyDict_SetItemString(dict, "arg", pyarg);
listPut(varnames, strdup("arg"));
Py_DECREF(pyarg);
}
if(ch) {
PyObject *pych = charGetPyForm(ch);
PyDict_SetItemString(dict, "ch", pych);
listPut(varnames, strdup("ch"));
Py_DECREF(pych);
}
if(room) {
PyObject *pyroom = roomGetPyForm(room);
PyDict_SetItemString(dict, "room", pyroom);
listPut(varnames, strdup("room"));
Py_DECREF(pyroom);
}
if(obj) {
PyObject *pyobj = objGetPyForm(obj);
PyDict_SetItemString(dict, "obj", pyobj);
listPut(varnames, strdup("obj"));
Py_DECREF(pyobj);
}
if(exit) {
PyObject *pyexit = newPyExit(exit);
PyDict_SetItemString(dict, "ex", pyexit);
listPut(varnames, strdup("ex"));
Py_DECREF(pyexit);
}
// add the thing the tirgger is attached to
if(me) {
PyObject *pyme = NULL;
switch(me_type) {
case TRIGVAR_CHAR: pyme = charGetPyForm(me); break;
case TRIGVAR_OBJ: pyme = objGetPyForm(me); break;
case TRIGVAR_ROOM: pyme = roomGetPyForm(me); break;
}
PyDict_SetItemString(dict, "me", pyme);
listPut(varnames, strdup("me"));
Py_DECREF(pyme);
}
// now, add any optional variables
if(optional) {
LIST_ITERATOR *opt_i = newListIterator(optional);
OPT_VAR *opt = NULL;
PyObject *pyopt = NULL;
ITERATE_LIST(opt, opt_i) {
pyopt = NULL;
switch(opt->type) {
case TRIGVAR_CHAR: pyopt = charGetPyForm(opt->data); break;
case TRIGVAR_OBJ: pyopt = objGetPyForm(opt->data); break;
case TRIGVAR_ROOM: pyopt = roomGetPyForm(opt->data); break;
}
PyDict_SetItemString(dict, opt->name, pyopt);
listPut(varnames, strdup(opt->name));
Py_XDECREF(pyopt);
} deleteListIterator(opt_i);
}
开发者ID:avidal,项目名称:nakedmud,代码行数:79,代码来源:trighooks.c
示例8: GPU_shader_export
static PyObject *GPU_export_shader(PyObject *UNUSED(self), PyObject *args, PyObject *kwds)
{
PyObject *pyscene;
PyObject *pymat;
PyObject *result;
PyObject *dict;
PyObject *val;
PyObject *seq;
int i;
Scene *scene;
PointerRNA tptr;
Material *material;
GPUShaderExport *shader;
GPUInputUniform *uniform;
GPUInputAttribute *attribute;
static const char *kwlist[] = {"scene", "material", NULL};
if (!PyArg_ParseTupleAndKeywords(args, kwds, "OO:export_shader", (char **)(kwlist), &pyscene, &pymat))
return NULL;
scene = (Scene *)PyC_RNA_AsPointer(pyscene, "Scene");
if (scene == NULL) {
return NULL;
}
material = (Material *)PyC_RNA_AsPointer(pymat, "Material");
if (material == NULL) {
return NULL;
}
/* we can call our internal function at last: */
shader = GPU_shader_export(scene, material);
if (!shader) {
PyErr_SetString(PyExc_RuntimeError, "cannot export shader");
return NULL;
}
/* build a dictionary */
result = PyDict_New();
if (shader->fragment) {
PY_DICT_ADD_STRING(result, shader, fragment);
}
if (shader->vertex) {
PY_DICT_ADD_STRING(result, shader, vertex);
}
seq = PyList_New(BLI_listbase_count(&shader->uniforms));
for (i = 0, uniform = shader->uniforms.first; uniform; uniform = uniform->next, i++) {
dict = PyDict_New();
PY_DICT_ADD_STRING(dict, uniform, varname);
PY_DICT_ADD_LONG(dict, uniform, datatype);
PY_DICT_ADD_LONG(dict, uniform, type);
if (uniform->lamp) {
PY_DICT_ADD_ID(dict, uniform, lamp);
}
if (uniform->image) {
PY_DICT_ADD_ID(dict, uniform, image);
}
if (uniform->type == GPU_DYNAMIC_SAMPLER_2DBUFFER ||
uniform->type == GPU_DYNAMIC_SAMPLER_2DIMAGE ||
uniform->type == GPU_DYNAMIC_SAMPLER_2DSHADOW)
{
PY_DICT_ADD_LONG(dict, uniform, texnumber);
}
if (uniform->texpixels) {
val = PyByteArray_FromStringAndSize((const char *)uniform->texpixels, uniform->texsize * 4);
PyDict_SetItemString(dict, "texpixels", val);
Py_DECREF(val);
PY_DICT_ADD_LONG(dict, uniform, texsize);
}
PyList_SET_ITEM(seq, i, dict);
}
PyDict_SetItemString(result, "uniforms", seq);
Py_DECREF(seq);
seq = PyList_New(BLI_listbase_count(&shader->attributes));
for (i = 0, attribute = shader->attributes.first; attribute; attribute = attribute->next, i++) {
dict = PyDict_New();
PY_DICT_ADD_STRING(dict, attribute, varname);
PY_DICT_ADD_LONG(dict, attribute, datatype);
PY_DICT_ADD_LONG(dict, attribute, type);
PY_DICT_ADD_LONG(dict, attribute, number);
if (attribute->name) {
if (attribute->name[0] != 0) {
PY_DICT_ADD_STRING(dict, attribute, name);
}
else {
val = PyLong_FromLong(0);
PyDict_SetItemString(dict, "name", val);
Py_DECREF(val);
}
}
PyList_SET_ITEM(seq, i, dict);
}
PyDict_SetItemString(result, "attributes", seq);
Py_DECREF(seq);
GPU_free_shader_export(shader);
return result;
//.........这里部分代码省略.........
开发者ID:akonneker,项目名称:blensor,代码行数:101,代码来源:gpu.c
示例9: PyRRD_info
static PyObject *
PyRRD_info(PyObject UNUSED(*self), PyObject *args)
{
PyObject *r, *t, *ds;
rrd_t rrd;
FILE *in_file;
char *filename;
unsigned long i, j;
if (! PyArg_ParseTuple(args, "s:info", &filename))
return NULL;
if (rrd_open(filename, &in_file, &rrd, RRD_READONLY) == -1) {
PyErr_SetString(ErrorObject, rrd_get_error());
rrd_clear_error();
return NULL;
}
fclose(in_file);
#define DICTSET_STR(dict, name, value) \
t = PyString_FromString(value); \
PyDict_SetItemString(dict, name, t); \
Py_DECREF(t);
#define DICTSET_CNT(dict, name, value) \
t = PyInt_FromLong((long)value); \
PyDict_SetItemString(dict, name, t); \
Py_DECREF(t);
#define DICTSET_VAL(dict, name, value) \
t = isnan(value) ? (Py_INCREF(Py_None), Py_None) : \
PyFloat_FromDouble((double)value); \
PyDict_SetItemString(dict, name, t); \
Py_DECREF(t);
r = PyDict_New();
DICTSET_STR(r, "filename", filename);
DICTSET_STR(r, "rrd_version", rrd.stat_head->version);
DICTSET_CNT(r, "step", rrd.stat_head->pdp_step);
DICTSET_CNT(r, "last_update", rrd.live_head->last_up);
ds = PyDict_New();
PyDict_SetItemString(r, "ds", ds);
Py_DECREF(ds);
for (i = 0; i < rrd.stat_head->ds_cnt; i++) {
PyObject *d;
d = PyDict_New();
PyDict_SetItemString(ds, rrd.ds_def[i].ds_nam, d);
Py_DECREF(d);
DICTSET_STR(d, "ds_name", rrd.ds_def[i].ds_nam);
DICTSET_STR(d, "type", rrd.ds_def[i].dst);
DICTSET_CNT(d, "minimal_heartbeat", rrd.ds_def[i].par[DS_mrhb_cnt].u_cnt);
DICTSET_VAL(d, "min", rrd.ds_def[i].par[DS_min_val].u_val);
DICTSET_VAL(d, "max", rrd.ds_def[i].par[DS_max_val].u_val);
DICTSET_STR(d, "last_ds", rrd.pdp_prep[i].last_ds);
DICTSET_VAL(d, "value", rrd.pdp_prep[i].scratch[PDP_val].u_val);
DICTSET_CNT(d, "unknown_sec", rrd.pdp_prep[i].scratch[PDP_unkn_sec_cnt].u_cnt);
}
ds = PyList_New(rrd.stat_head->rra_cnt);
PyDict_SetItemString(r, "rra", ds);
Py_DECREF(ds);
for (i = 0; i < rrd.stat_head->rra_cnt; i++) {
PyObject *d, *cdp;
d = PyDict_New();
PyList_SET_ITEM(ds, i, d);
DICTSET_STR(d, "cf", rrd.rra_def[i].cf_nam);
DICTSET_CNT(d, "rows", rrd.rra_def[i].row_cnt);
DICTSET_CNT(d, "pdp_per_row", rrd.rra_def[i].pdp_cnt);
DICTSET_VAL(d, "xff", rrd.rra_def[i].par[RRA_cdp_xff_val].u_val);
cdp = PyList_New(rrd.stat_head->ds_cnt);
PyDict_SetItemString(d, "cdp_prep", cdp);
Py_DECREF(cdp);
for (j = 0; j < rrd.stat_head->ds_cnt; j++) {
PyObject *cdd;
cdd = PyDict_New();
PyList_SET_ITEM(cdp, j, cdd);
DICTSET_VAL(cdd, "value",
rrd.cdp_prep[i*rrd.stat_head->ds_cnt+j].scratch[CDP_val].u_val);
DICTSET_CNT(cdd, "unknown_datapoints",
rrd.cdp_prep[i*rrd.stat_head->ds_cnt+j].scratch[CDP_unkn_pdp_cnt].u_cnt);
}
}
rrd_free(&rrd);
return r;
}
开发者ID:OPSF,项目名称:uClinux,代码行数:99,代码来源:rrdtoolmodule.c
示例10: initModule
/* Shared python2/3 module initialization: */
static int initModule(PyObject *m)
{
PyObject * d;
/*
* treat error to register rpm cleanup hook as fatal, tracebacks
* can and will leave stale locks around if we can't clean up
*/
if (Py_AtExit(rpm_exithook) == -1)
return 0;
/* failure to initialize rpm (crypto and all) is rather fatal too... */
if (rpmReadConfigFiles(NULL, NULL) == -1)
return 0;
d = PyModule_GetDict(m);
pyrpmError = PyErr_NewException("_rpm.error", NULL, NULL);
if (pyrpmError != NULL)
PyDict_SetItemString(d, "error", pyrpmError);
Py_INCREF(&hdr_Type);
PyModule_AddObject(m, "hdr", (PyObject *) &hdr_Type);
Py_INCREF(&rpmds_Type);
PyModule_AddObject(m, "ds", (PyObject *) &rpmds_Type);
Py_INCREF(&rpmfd_Type);
PyModule_AddObject(m, "fd", (PyObject *) &rpmfd_Type);
Py_INCREF(&rpmfi_Type);
PyModule_AddObject(m, "fi", (PyObject *) &rpmfi_Type);
Py_INCREF(&rpmKeyring_Type);
PyModule_AddObject(m, "keyring", (PyObject *) &rpmKeyring_Type);
Py_INCREF(&rpmmi_Type);
PyModule_AddObject(m, "mi", (PyObject *) &rpmmi_Type);
Py_INCREF(&rpmii_Type);
PyModule_AddObject(m, "ii", (PyObject *) &rpmii_Type);
Py_INCREF(&rpmProblem_Type);
PyModule_AddObject(m, "prob", (PyObject *) &rpmProblem_Type);
Py_INCREF(&rpmPubkey_Type);
PyModule_AddObject(m, "pubkey", (PyObject *) &rpmPubkey_Type);
#if 0
Py_INCREF(&rpmtd_Type);
PyModule_AddObject(m, "td", (PyObject *) &rpmtd_Type);
#endif
Py_INCREF(&rpmte_Type);
PyModule_AddObject(m, "te", (PyObject *) &rpmte_Type);
Py_INCREF(&rpmts_Type);
PyModule_AddObject(m, "ts", (PyObject *) &rpmts_Type);
addRpmTags(m);
PyModule_AddStringConstant(m, "__version__", RPMVERSION);
#define REGISTER_ENUM(val) PyModule_AddIntConstant(m, #val, val)
REGISTER_ENUM(RPMTAG_NOT_FOUND);
REGISTER_ENUM(RPMRC_OK);
REGISTER_ENUM(RPMRC_NOTFOUND);
REGISTER_ENUM(RPMRC_FAIL);
REGISTER_ENUM(RPMRC_NOTTRUSTED);
REGISTER_ENUM(RPMRC_NOKEY);
REGISTER_ENUM(RPMFILE_STATE_NORMAL);
REGISTER_ENUM(RPMFILE_STATE_REPLACED);
REGISTER_ENUM(RPMFILE_STATE_NOTINSTALLED);
REGISTER_ENUM(RPMFILE_STATE_NETSHARED);
REGISTER_ENUM(RPMFILE_STATE_WRONGCOLOR);
REGISTER_ENUM(RPMFILE_CONFIG);
REGISTER_ENUM(RPMFILE_DOC);
REGISTER_ENUM(RPMFILE_MISSINGOK);
REGISTER_ENUM(RPMFILE_NOREPLACE);
REGISTER_ENUM(RPMFILE_GHOST);
REGISTER_ENUM(RPMFILE_LICENSE);
REGISTER_ENUM(RPMFILE_README);
REGISTER_ENUM(RPMFILE_PUBKEY);
REGISTER_ENUM(RPMDEP_SENSE_REQUIRES);
REGISTER_ENUM(RPMDEP_SENSE_CONFLICTS);
REGISTER_ENUM(RPMSENSE_ANY);
REGISTER_ENUM(RPMSENSE_LESS);
REGISTER_ENUM(RPMSENSE_GREATER);
REGISTER_ENUM(RPMSENSE_EQUAL);
REGISTER_ENUM(RPMSENSE_POSTTRANS);
REGISTER_ENUM(RPMSENSE_PREREQ);
REGISTER_ENUM(RPMSENSE_PRETRANS);
REGISTER_ENUM(RPMSENSE_INTERP);
//.........这里部分代码省略.........
开发者ID:boklm,项目名称:rpm,代码行数:101,代码来源:rpmmodule.c
示例11: __import__compiled
static PyObject*
__import__compiled(FILE *f, char *name, char *path, char *as, PyObject *local, PyObject *global)
{
char *module_name = as ? as : name;
PyCodeObject *co;
PyObject *m;
if(name == NULL)
return NULL;
//比较文件的魔数
if(PyMarshal_ReadLongFromFile(f) != PYC_MAGIC)
{
PyErr_Format(PyExc_ImportError, "Bad magic number of %s", name);
return NULL;
}
//读掉时间信息
(void*)PyMarshal_ReadLongFromFile(f);
//创建PyCodeObject
co = (PyCodeObject*)PyMarshal_ReadLastObjectFromFile(f);
if(co == NULL)
{
PyErr_Format(PyExc_ImportError, "Cannot create code object from module %s", name);
return NULL;
}
if(!PyCode_Check(co))
{
PyErr_Format(PyExc_ImportError, "Non-code object in module %s", name);
Py_DECREF(co);
return NULL;
}
/*创建模块*/
m = create_module(name, (PyObject*)co);
if(m == NULL)
{
Ps_Log("create_module failed\n", Ps_LOG_WARING);
return NULL;
}
Py_DECREF(co);
/*将模块导入命名空间*/
if(local && PyDict_Check(local))
{
Py_INCREF(m);
#ifdef IMPORT_DEBUG
Ps_LogFormat("The module name is %s\n", Ps_LOG_NORMAL, module_name);
Ps_LogObject(local, Ps_LOG_WARING);
Ps_LogObject(m, Ps_LOG_WARING);
int ret =
#endif
PyDict_SetItemString(local, module_name, m);
#ifdef IMPORT_DEBUG
if(ret == 0)
Ps_LogFormat("ret is %d, Import module %s successfully\n", Ps_LOG_NORMAL, ret, module_name);
else
Ps_LogFormat("ret is %d, Import module %s failed\n", Ps_LOG_NORMAL, ret, module_name);
#endif
}
else
{
PyObject *info = PyString_FromFormat("Import module %s failed", name);
if(!info)
{
PyErr_SetString(PyExc_ImportError, "Import module failed");
}
else
PyErr_SetObject(PyExc_ImportError, info);
return NULL;
}
return m;
}
开发者ID:yuriyao,项目名称:PS,代码行数:72,代码来源:import_module.c
示例12: init_sk1objs
init_sk1objs(void)
{
PyObject * d, *m, *r;
SKCurveType.ob_type = &PyType_Type;
SKCacheType.ob_type = &PyType_Type;
SKColorType.ob_type = &PyType_Type;
SKFontMetricType.ob_type = &PyType_Type;
SKPointType.ob_type = &PyType_Type;
SKRectType.ob_type = &PyType_Type;
SKTrafoType.ob_type = &PyType_Type;
m = Py_InitModule("_sk1objs", curve_functions);
d = PyModule_GetDict(m);
/* Rect specific initialization */
/* The InfinityRect is initialized with FLT_MAX instead of HUGE_VAL
now (Sketch 0.5.4), because of problems with HUGE_VAL on Alpha
Linux. */
r = SKRect_FromDouble(-FLT_MAX, -FLT_MAX, FLT_MAX, FLT_MAX);
if (r)
{
PyDict_SetItemString(d, "InfinityRect", r);
SKRect_InfinityRect = (SKRectObject*)r;
}
r = SKRect_FromDouble(0.0, 0.0, 0.0, 0.0);
if (r)
{
PyDict_SetItemString(d, "EmptyRect", r);
SKRect_EmptyRect = (SKRectObject*)r;
}
/* Trafo specific initialization */
SKTrafo_ExcSingular = PyErr_NewException("_sk1objs.SingularMatrix",
PyExc_ArithmeticError, NULL);
if (SKTrafo_ExcSingular)
{
PyDict_SetItemString(d, "SingularMatrix", SKTrafo_ExcSingular);
}
/* Sketch type objects */
PyDict_SetItemString(d, "RectType", (PyObject*)&SKRectType);
PyDict_SetItemString(d, "PointType", (PyObject*)&SKPointType);
PyDict_SetItemString(d, "TrafoType", (PyObject*)&SKTrafoType);
PyDict_SetItemString(d, "CurveType", (PyObject*)&SKCurveType);
/* Curve specific initialization */
#define ADD_INT(name) add_int(d, name, #name)
#define ADD_INT2(i, name) add_int(d, i, name)
ADD_INT(ContAngle);
ADD_INT(ContSmooth);
ADD_INT(ContSymmetrical);
ADD_INT2(CurveBezier, "Bezier");
ADD_INT2(CurveLine, "Line");
ADD_INT(SelNone);
ADD_INT(SelNodes);
ADD_INT(SelSegmentFirst);
ADD_INT(SelSegmentLast);
_SKCurve_InitCurveObject();
}
开发者ID:Scrik,项目名称:sk1-wx,代码行数:64,代码来源:_sketchmodule.c
示例13: LDAPerror
/* Convert an LDAP error into an informative python exception */
PyObject*
LDAPerror( LDAP *l, char *msg )
{
if (l == NULL) {
PyErr_SetFromErrno( LDAPexception_class );
return NULL;
}
else {
int errnum, opt_errnum;
PyObject *errobj;
PyObject *info;
PyObject *str;
char *matched, *error;
opt_errnum = ldap_get_option(l, LDAP_OPT_ERROR_NUMBER, &errnum);
if (opt_errnum != LDAP_OPT_SUCCESS)
errnum = opt_errnum;
if (errnum == LDAP_NO_MEMORY)
return PyErr_NoMemory();
if (errnum >= LDAP_ERROR_MIN && errnum <= LDAP_ERROR_MAX)
errobj = errobjects[errnum+LDAP_ERROR_OFFSET];
else
errobj = LDAPexception_class;
info = PyDict_New();
if (info == NULL)
return NULL;
str = PyString_FromString(ldap_err2string(errnum));
if (str)
PyDict_SetItemString( info, "desc", str );
Py_XDECREF(str);
if (ldap_get_option(l, LDAP_OPT_MATCHED_DN, &matched) >= 0
&& matched != NULL) {
if (*matched != '\0') {
str = PyString_FromString(matched);
if (str)
PyDict_SetItemString( info, "matched", str );
Py_XDECREF(str);
}
ldap_memfree(matched);
}
if (errnum == LDAP_REFERRAL) {
str = PyString_FromString(msg);
if (str)
PyDict_SetItemString( info, "info", str );
Py_XDECREF(str);
} else if (ldap_get_option(l, LDAP_OPT_ERROR_STRING, &error) >= 0
&& error != NULL) {
if (error != '\0') {
str = PyString_FromString(error);
if (str)
PyDict_SetItemString( info, "info", str );
Py_XDECREF(str);
}
ldap_memfree(error);
}
PyErr_SetObject( errobj, info );
Py_DECREF(info);
return NULL;
}
}
开发者ID:Awingu,项目名称:python-ldap,代码行数:68,代码来源:errors.c
示例14: LDAPinit_errors
void
LDAPinit_errors( PyObject*d ) {
/* create the base exception class */
LDAPexception_class = PyErr_NewException("ldap.LDAPError",
NULL,
NULL);
PyDict_SetItemString( d, "LDAPError", LDAPexception_class );
/* XXX - backward compatibility with pre-1.8 */
PyDict_SetItemString( d, "error", LDAPexception_class );
/* create each LDAP error object */
# define seterrobj2(n,o) \
PyDict_SetItemString( d, #n, (errobjects[LDAP_##n+LDAP_ERROR_OFFSET] = o) )
# define seterrobj(n) { \
PyObject *e = PyErr_NewException("ldap." #n, \
LDAPexception_class, NULL); \
seterrobj2(n, e); \
Py_INCREF(e); \
}
seterrobj(ADMINLIMIT_EXCEEDED);
seterrobj(AFFECTS_MULTIPLE_DSAS);
seterrobj(ALIAS_DEREF_PROBLEM);
seterrobj(ALIAS_PROBLEM);
seterrobj(ALREADY_EXISTS);
seterrobj(AUTH_METHOD_NOT_SUPPORTED);
seterrobj(AUTH_UNKNOWN);
seterrobj(BUSY);
seterrobj(CLIENT_LOOP);
seterrobj(COMPARE_FALSE);
seterrobj(COMPARE_TRUE);
seterrobj(CONFIDENTIALITY_REQUIRED);
seterrobj(CONNECT_ERROR);
seterrobj(CONSTRAINT_VIOLATION);
seterrobj(CONTROL_NOT_FOUND);
seterrobj(DECODING_ERROR);
seterrobj(ENCODING_ERROR);
seterrobj(FILTER_ERROR);
seterrobj(INAPPROPRIATE_AUTH);
seterrobj(INAPPROPRIATE_MATCHING);
seterrobj(INSUFFICIENT_ACCESS);
seterrobj(INVALID_CREDENTIALS);
seterrobj(INVALID_DN_SYNTAX);
seterrobj(INVALID_SYNTAX);
seterrobj(IS_LEAF);
seterrobj(LOCAL_ERROR);
seterrobj(LOOP_DETECT);
seterrobj(MORE_RESULTS_TO_RETURN);
seterrobj(NAMING_VIOLATION);
seterrobj(NO_MEMORY);
seterrobj(NO_OBJECT_CLASS_MODS);
seterrobj(NO_OBJECT_CLASS_MODS);
seterrobj(NO_RESULTS_RETURNED);
seterrobj(NO_SUCH_ATTRIBUTE);
seterrobj(NO_SUCH_OBJECT);
seterrobj(NOT_ALLOWED_ON_NONLEAF);
seterrobj(NOT_ALLOWED_ON_RDN);
seterrobj(NOT_SUPPORTED);
seterrobj(OBJECT_CLASS_VIOLATION);
seterrobj(OPERATIONS_ERROR);
seterrobj(OTHER);
seterrobj(PARAM_ERROR);
seterrobj(PARTIAL_RESULTS);
seterrobj(PROTOCOL_ERROR);
seterrobj(REFERRAL);
seterrobj(REFERRAL_LIMIT_EXCEEDED);
seterrobj(RESULTS_TOO_LARGE);
seterrobj(SASL_BIND_IN_PROGRESS);
seterrobj(SERVER_DOWN);
seterrobj(SIZELIMIT_EXCEEDED);
seterrobj(STRONG_AUTH_NOT_SUPPORTED);
seterrobj(STRONG_AUTH_REQUIRED);
seterrobj(SUCCESS);
seterrobj(TIMELIMIT_EXCEEDED);
seterrobj(TIMEOUT);
seterrobj(TYPE_OR_VALUE_EXISTS);
seterrobj(UNAVAILABLE);
seterrobj(UNAVAILABLE_CRITICAL_EXTENSION);
seterrobj(UNDEFINED_TYPE);
seterrobj(UNWILLING_TO_PERFORM);
seterrobj(USER_CANCELLED);
seterrobj(VLV_ERROR);
seterrobj(X_PROXY_AUTHZ_FAILURE);
#ifdef LDAP_API_FEATURE_CANCEL
seterrobj(CANCELLED);
seterrobj(NO_SUCH_OPERATION);
seterrobj(TOO_LATE);
seterrobj(CANNOT_CANCEL);
#endif
#ifdef LDAP_ASSERTION_FAILED
seterrobj(ASSERTION_FAILED);
#endif
//.........这里部分代码省略.........
开发者ID:Awingu,项目名称:python-ldap,代码行数:101,代码来源:errors.c
示例15: csl_execute
int
csl_execute(char *code, size_t size, const char *func_name, struct pack *pak, char **resptr, int *reslen)
{
PyObject *pCode, *pModule, *pDict, *pFunc, *pValue, *pStr;
PyObject *pArgs, *pkArgs;
PyMethodDef *meth;
node *n;
int arg_count;
PyObject *argNames;
pModule = PyImport_AddModule("__builtin__");
pDict = PyModule_GetDict(pModule);
for (meth = methods; meth->ml_name; meth++) {
pCode = PyCFunction_New(meth, NULL);
PyDict_SetItemString(pDict, meth->ml_name, pCode);
}
if (size == 0) {
n = PyParser_SimpleParseString(code, Py_file_inp
|
请发表评论