Changeset 360 for trunk/zoo-project/zoo-kernel/service_internal_python.c
- Timestamp:
- Jun 7, 2012, 10:54:31 PM (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/zoo-project/zoo-kernel/service_internal_python.c
r348 r360 2 2 * Author : Gérald FENOY 3 3 * 4 * Copyright (c) 2009-201 1GeoLabs SARL4 * Copyright (c) 2009-2012 GeoLabs SARL 5 5 * 6 6 * Permission is hereby granted, free of charge, to any person obtaining a copy … … 208 208 PyObject* res=PyDict_New( ); 209 209 map* tmp=t; 210 int hasSize=0; 211 map* isArray=getMap(tmp,"isArray"); 210 212 map* size=getMap(tmp,"size"); 213 map* tmap=getMapType(tmp); 211 214 while(tmp!=NULL){ 212 215 PyObject* name=PyString_FromString(tmp->name); 213 if(strcasecmp(tmp->name,"value")==0){ 214 if(size!=NULL){ 216 if(strcasecmp(tmp->name,"value")==0) { 217 if(isArray!=NULL){ 218 map* len=getMap(tmp,"length"); 219 int cnt=atoi(len->value); 220 PyObject* value=PyList_New(cnt); 221 PyObject* mvalue=PyList_New(cnt); 222 PyObject* svalue=PyList_New(cnt); 223 224 for(int i=0;i<cnt;i++){ 225 226 map* vMap=getMapArray(tmp,"value",i); 227 map* sMap=getMapArray(tmp,"size",i); 228 229 if(vMap!=NULL){ 230 231 PyObject* lvalue; 232 PyObject* lsvalue; 233 if(sMap==NULL){ 234 lvalue=PyString_FromString(vMap->value); 235 lsvalue=Py_None; 236 } 237 else{ 238 lvalue=PyString_FromStringAndSize(vMap->value,atoi(sMap->value)); 239 lsvalue=PyString_FromString(sMap->value); 240 hasSize=1; 241 } 242 243 if(PyList_SetItem(value,i,lvalue)<0){ 244 fprintf(stderr,"Unable to set key value pair..."); 245 return NULL; 246 } 247 if(PyList_SetItem(svalue,i,lsvalue)<0){ 248 fprintf(stderr,"Unable to set key value pair..."); 249 return NULL; 250 } 251 } 252 253 map* mMap=getMapArray(tmp,tmap->name,i); 254 PyObject* lmvalue; 255 if(mMap!=NULL){ 256 lmvalue=PyString_FromString(mMap->value); 257 }else 258 lmvalue=Py_None; 259 260 if(PyList_SetItem(mvalue,i,lmvalue)<0){ 261 fprintf(stderr,"Unable to set key value pair..."); 262 return NULL; 263 } 264 265 } 266 267 if(PyDict_SetItem(res,name,value)<0){ 268 fprintf(stderr,"Unable to set key value pair..."); 269 return NULL; 270 } 271 if(PyDict_SetItem(res,PyString_FromString(tmap->name),mvalue)<0){ 272 fprintf(stderr,"Unable to set key value pair..."); 273 return NULL; 274 } 275 if(hasSize>0) 276 if(PyDict_SetItem(res,PyString_FromString("size"),svalue)<0){ 277 fprintf(stderr,"Unable to set key value pair..."); 278 return NULL; 279 } 280 } 281 else if(size!=NULL){ 215 282 PyObject* value=PyString_FromStringAndSize(tmp->value,atoi(size->value)); 216 283 if(PyDict_SetItem(res,name,value)<0){ … … 228 295 } 229 296 else{ 230 PyObject* value=PyString_FromString(tmp->value); 231 if(PyDict_SetItem(res,name,value)<0){ 232 fprintf(stderr,"Unable to set key value pair..."); 233 return NULL; 297 if(PyDict_GetItem(res,name)==NULL){ 298 PyObject* value=PyString_FromString(tmp->value); 299 if(PyDict_SetItem(res,name,value)<0){ 300 fprintf(stderr,"Unable to set key value pair..."); 301 return NULL; 302 } 234 303 } 235 304 }
Note: See TracChangeset
for help on using the changeset viewer.