- Timestamp:
- Feb 26, 2009 9:54:03 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified caPython/branches/newPointers/ca_internal_functions.c ¶
r28 r39 94 94 func = PyTuple_GetItem(pyTup, 0); 95 95 if (PyCallable_Check(func)) { 96 chidptr = SWIG_NewPointerObj( ( void *) &(connect_args.chid),96 chidptr = SWIG_NewPointerObj( (chid *) &(connect_args.chid), 97 97 SWIGTYPE_p_chid, 0); 98 98 retVals = Py_BuildValue("(Oi)", chidptr, connect_args.op); … … 135 135 136 136 /* Create a swigged pointer to the channel identifier */ 137 chidptr = SWIG_NewPointerObj((ch ar*) &(event_args.chid),137 chidptr = SWIG_NewPointerObj((chid *) &(event_args.chid), 138 138 SWIGTYPE_p_chid, 0); 139 139 /* Build a dictionary of CA values to return to the callback routine */ 140 retVals = Py_BuildValue("{s: s, s:i, s:i, s:i}",140 retVals = Py_BuildValue("{s:O, s:i, s:i, s:i}", 141 141 GET_CHID, chidptr, 142 142 GET_TYPE, event_args.type, … … 255 255 switch (dbrType) { 256 256 case DBR_STRING: 257 d = Py_BuildValue(" {s:s}", PV_VALUE, (char *)pBuf->strval);257 d = Py_BuildValue("s", (char *)pBuf->strval); 258 258 break; 259 259 case DBR_CHAR: 260 d = Py_BuildValue(" {s:b}", PV_VALUE,(int)pBuf->charval);260 d = Py_BuildValue("b", (int)pBuf->charval); 261 261 break; 262 262 /* case DBR_SHORT: = DBR_INT */ 263 263 case DBR_INT: 264 d = Py_BuildValue(" {s:h}", PV_VALUE,(int)pBuf->intval);264 d = Py_BuildValue("h", (int)pBuf->intval); 265 265 break; 266 266 case DBR_ENUM: 267 d = Py_BuildValue(" {s:h}", PV_VALUE, (int)pBuf->enmval);267 d = Py_BuildValue("h", (int)pBuf->enmval); 268 268 break; 269 269 case DBR_LONG: 270 d = Py_BuildValue(" {s:i}", PV_VALUE,(int)pBuf->longval);270 d = Py_BuildValue("i", (int)pBuf->longval); 271 271 break; 272 272 case DBR_FLOAT: 273 d = Py_BuildValue(" {s:d}", PV_VALUE, (double)pBuf->fltval);273 d = Py_BuildValue("d", (double)pBuf->fltval); 274 274 break; 275 275 case DBR_DOUBLE: 276 d = Py_BuildValue(" {s:d}", PV_VALUE, (double)pBuf->doubleval);276 d = Py_BuildValue("d", (double)pBuf->doubleval); 277 277 break; 278 278 default: … … 281 281 } /* end if */ 282 282 else { 283 t = Py Tuple_New(count);283 t = PyList_New(count); 284 284 for(i = 0; i < count; ++i) { 285 285 switch (dbrType) { … … 305 305 break; 306 306 } /* end switch */ 307 Py Tuple_SetItem(t, i, pyVal);307 PyList_SetItem(t, i, pyVal); 308 308 } /* end for */ 309 d = Py_BuildValue("{s:O}", PV_VALUE, t); 310 Py_XDECREF(t); /* dictionary now references the tuple */ 309 /*d = Py_BuildValue("{s:O}", PV_VALUE, t);*/ 310 d = t; 311 /* Py_XDECREF(t); */ /* dictionary now references the tuple */ 311 312 } /* end else */ 312 313 return d; … … 429 430 430 431 } /* end switch(requestType) */ 431 t = Py Tuple_New(count);432 t = PyList_New(count); 432 433 for(i = 0; i < count; ++i) { 433 434 switch (dbrType) { … … 453 454 break; 454 455 } /* end switch */ 455 Py Tuple_SetItem(t, i, pyVal);456 PyList_SetItem(t, i, pyVal); 456 457 } /* end for */ 457 458 PyDict_SetItemString(d, PV_VALUE, t); … … 595 596 printf("unpackTimeGet: Unknown DBR type\n"); 596 597 } /* end switch(requestType) */ 597 t = Py Tuple_New(count);598 t = PyList_New(count); 598 599 for(i = 0; i < count; ++i) { 599 600 switch (dbrType) { … … 618 619 break; 619 620 } /* end switch */ 620 Py Tuple_SetItem(t, i, pyVal);621 PyList_SetItem(t, i, pyVal); 621 622 } /* end for */ 622 623 PyDict_SetItemString(d, PV_VALUE, t); … … 817 818 printf("unpackGraphicGet: Unknown DBR type\n"); 818 819 } /* end switch(requestType) */ 819 t = Py Tuple_New(count);820 t = PyList_New(count); 820 821 for(i = 0; i < count; ++i) { 821 822 switch (dbrType) { … … 840 841 break; 841 842 } /* end switch */ 842 Py Tuple_SetItem(t, i, pyVal);843 PyList_SetItem(t, i, pyVal); 843 844 } /* end for */ 844 845 PyDict_SetItemString(d, PV_VALUE, t); … … 1057 1058 printf("unpackControlGet: Unknown DBR type\n"); 1058 1059 } /* end switch(requestType) */ 1059 t = Py Tuple_New(count);1060 t = PyList_New(count); 1060 1061 for(i = 0; i < count; ++i) { 1061 1062 switch (dbrType) { … … 1080 1081 break; 1081 1082 } /* end switch */ 1082 Py Tuple_SetItem(t, i, pyVal);1083 PyList_SetItem(t, i, pyVal); 1083 1084 } /* end for */ 1084 1085 PyDict_SetItemString(d, PV_VALUE, t); … … 1103 1104 void getCallback(struct event_handler_args event_args) 1104 1105 { 1105 PyObject *func, *args, *pyTup, *d=NULL, * result, *v;1106 PyObject *func, *args, *pyTup, *d=NULL, *s=NULL, *result, *v; 1106 1107 PyObject *chidptr; 1107 1108 /*char _ptemp[STR_LEN];*/ … … 1112 1113 1113 1114 if(dbr_type_is_plain(event_args.type)) { 1114 d = unpackPlainGet(pBuf, event_args.type, event_args.count); 1115 s = unpackPlainGet(pBuf, event_args.type, event_args.count); 1116 d = Py_BuildValue( "{s:O}", PV_VALUE, s); 1115 1117 } 1116 1118 else if(dbr_type_is_STS(event_args.type)) { … … 1130 1132 } 1131 1133 1132 chidptr = SWIG_NewPointerObj((ch ar*) &(event_args.chid),1134 chidptr = SWIG_NewPointerObj((chid *) &(event_args.chid), 1133 1135 SWIGTYPE_p_chid, 0); 1134 v = Py_BuildValue(" s", chidptr);1136 v = Py_BuildValue("O", chidptr); 1135 1137 PyDict_SetItemString(d, GET_CHID, v); 1136 1138 Py_XDECREF(v); … … 1174 1176 void eventCallback(struct event_handler_args event_args) 1175 1177 { 1176 PyObject *func, *args, *pyTup, *d=NULL, * result, *v;1178 PyObject *func, *args, *pyTup, *d=NULL, *s=NULL, *result, *v; 1177 1179 PyObject *chidptr; 1178 1180 /*char _ptemp[STR_LEN];*/ … … 1182 1184 pBuf = (union db_access_val *)event_args.dbr; 1183 1185 if(dbr_type_is_plain(event_args.type)) { 1184 d = unpackPlainGet(pBuf, event_args.type, event_args.count); 1186 s = unpackPlainGet(pBuf, event_args.type, event_args.count); 1187 d = Py_BuildValue( "{s:O}", PV_VALUE, s); 1185 1188 } 1186 1189 else if(dbr_type_is_STS(event_args.type)) { … … 1201 1204 1202 1205 /* Create a swigged pointer to the channel identifier */ 1203 chidptr = SWIG_NewPointerObj((ch ar*) &(event_args.chid),1206 chidptr = SWIG_NewPointerObj((chid *) &(event_args.chid), 1204 1207 SWIGTYPE_p_chid, 0); 1205 1208 1206 v = Py_BuildValue(" s", chidptr);1209 v = Py_BuildValue("O", chidptr); 1207 1210 PyDict_SetItemString(d, GET_CHID, v); 1208 1211 Py_XDECREF(v);
Note: See TracChangeset
for help on using the changeset viewer.