This commit is contained in:
Michael Davidsaver
2013-03-24 22:10:53 -04:00
parent f58ba8dccb
commit 0f4b62e45d
8 changed files with 150 additions and 10 deletions

View File

@ -20,7 +20,7 @@ static int pyField_Init(pyField *self, PyObject *args, PyObject *kws)
{
const char *pvname;
if(PyArg_ParseTuple(args, "s", &pvname))
if(!PyArg_ParseTuple(args, "s", &pvname))
return -1;
if(dbNameToAddr(pvname, &self->addr)) {
@ -157,7 +157,7 @@ static PyMethodDef pyField_methods[] = {
"Return Names (\"record\",\"field\")"},
{"fieldinfo", (PyCFunction)pyField_fldinfo, METH_NOARGS,
"Field type info\nReturn (type, size, #elements"},
{"getval", (PyCFunction)pyField_getval, METH_VARARGS,
{"getval", (PyCFunction)pyField_getval, METH_NOARGS,
"Returns scalar version of field value"},
{"putval", (PyCFunction)pyField_putval, METH_VARARGS,
"Sets field value from a scalar"},
@ -168,13 +168,13 @@ static PyMethodDef pyField_methods[] = {
static PyTypeObject pyField_type = {
PyObject_HEAD_INIT(NULL)
0,
"_dbapi.Field",
"_dbapi._Field",
sizeof(pyField),
};
int pyField_prepare(void)
{
pyField_type.tp_flags = Py_TPFLAGS_DEFAULT;
pyField_type.tp_flags = Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE;
pyField_type.tp_methods = pyField_methods;
pyField_type.tp_init = (initproc)pyField_Init;
@ -188,5 +188,5 @@ void pyField_setup(PyObject *module)
{
PyObject *typeobj=(PyObject*)&pyField_type;
Py_INCREF(typeobj);
PyModule_AddObject(module, "Field", (PyObject*)&pyField_type);
PyModule_AddObject(module, "_Field", (PyObject*)&pyField_type);
}

View File

@ -20,7 +20,6 @@ typedef struct {
static int pyRecord_Init(pyRecord *self, PyObject *args, PyObject *kws)
{
const char *recname;
if(!PyArg_ParseTuple(args, "s", &recname))
return -1;
@ -136,14 +135,14 @@ static PyMethodDef pyRecord_methods[] = {
static PyTypeObject pyRecord_type = {
PyObject_HEAD_INIT(NULL)
0,
"_dbapi.Record",
"_dbapi._Record",
sizeof(pyRecord),
};
int pyRecord_prepare(void)
{
pyRecord_type.tp_flags = Py_TPFLAGS_DEFAULT;
pyRecord_type.tp_flags = Py_TPFLAGS_DEFAULT|Py_TPFLAGS_BASETYPE;
pyRecord_type.tp_methods = pyRecord_methods;
pyRecord_type.tp_init = (initproc)pyRecord_Init;
@ -157,5 +156,5 @@ void pyRecord_setup(PyObject *module)
{
PyObject *typeobj=(PyObject*)&pyRecord_type;
Py_INCREF(typeobj);
PyModule_AddObject(module, "Field", (PyObject*)&pyRecord_type);
PyModule_AddObject(module, "_Record", (PyObject*)&pyRecord_type);
}