comparison src/if_py_both.h @ 3648:2d107086903a v7.3.584

updated for version 7.3.584 Problem: PyCObject is not always defined. Solution: Use PyObject instead.
author Bram Moolenaar <bram@vim.org>
date Sat, 30 Jun 2012 13:34:34 +0200
parents f02b6ad168ae
children e13f2f3568e1
comparison
equal deleted inserted replaced
3647:d4d12df80e4f 3648:2d107086903a
2430 2430
2431 static int 2431 static int
2432 convert_dl(PyObject *obj, typval_T *tv, 2432 convert_dl(PyObject *obj, typval_T *tv,
2433 pytotvfunc py_to_tv, PyObject *lookupDict) 2433 pytotvfunc py_to_tv, PyObject *lookupDict)
2434 { 2434 {
2435 # ifdef PY_USE_CAPSULE
2436 PyObject *capsule; 2435 PyObject *capsule;
2437 # else
2438 PyCObject *cobject;
2439 # endif
2440 char hexBuf[sizeof(void *) * 2 + 3]; 2436 char hexBuf[sizeof(void *) * 2 + 3];
2441 2437
2442 sprintf(hexBuf, "%p", obj); 2438 sprintf(hexBuf, "%p", obj);
2443 2439
2444 # ifdef PY_USE_CAPSULE 2440 # ifdef PY_USE_CAPSULE
2445 capsule = PyDict_GetItemString(lookupDict, hexBuf); 2441 capsule = PyDict_GetItemString(lookupDict, hexBuf);
2442 # else
2443 capsule = (PyObject *)PyDict_GetItemString(lookupDict, hexBuf);
2444 # endif
2446 if (capsule == NULL) 2445 if (capsule == NULL)
2447 # else
2448 cobject = (PyCObject *)PyDict_GetItemString(lookupDict, hexBuf);
2449 if (cobject == NULL)
2450 # endif
2451 { 2446 {
2452 # ifdef PY_USE_CAPSULE 2447 # ifdef PY_USE_CAPSULE
2453 capsule = PyCapsule_New(tv, NULL, NULL); 2448 capsule = PyCapsule_New(tv, NULL, NULL);
2449 # else
2450 capsule = PyCObject_FromVoidPtr(tv, NULL);
2451 # endif
2454 PyDict_SetItemString(lookupDict, hexBuf, capsule); 2452 PyDict_SetItemString(lookupDict, hexBuf, capsule);
2455 Py_DECREF(capsule); 2453 Py_DECREF(capsule);
2456 # else
2457 cobject = PyCObject_FromVoidPtr(tv, NULL);
2458 PyDict_SetItemString(lookupDict, hexBuf, cobject);
2459 Py_DECREF(cobject);
2460 # endif
2461 if (py_to_tv(obj, tv, lookupDict) == -1) 2454 if (py_to_tv(obj, tv, lookupDict) == -1)
2462 { 2455 {
2463 tv->v_type = VAR_UNKNOWN; 2456 tv->v_type = VAR_UNKNOWN;
2464 return -1; 2457 return -1;
2465 } 2458 }
2476 typval_T *v; 2469 typval_T *v;
2477 2470
2478 # ifdef PY_USE_CAPSULE 2471 # ifdef PY_USE_CAPSULE
2479 v = PyCapsule_GetPointer(capsule, NULL); 2472 v = PyCapsule_GetPointer(capsule, NULL);
2480 # else 2473 # else
2481 v = PyCObject_AsVoidPtr(cobject); 2474 v = PyCObject_AsVoidPtr(capsule);
2482 # endif 2475 # endif
2483 copy_tv(v, tv); 2476 copy_tv(v, tv);
2484 } 2477 }
2485 return 0; 2478 return 0;
2486 } 2479 }