mapping.pxd 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. cdef extern from "Python.h":
  2. ############################################################################
  3. # 6.4 Mapping Protocol
  4. ############################################################################
  5. bint PyMapping_Check(object o)
  6. # Return 1 if the object provides mapping protocol, and 0
  7. # otherwise. This function always succeeds.
  8. Py_ssize_t PyMapping_Length(object o) except -1
  9. # Returns the number of keys in object o on success, and -1 on
  10. # failure. For objects that do not provide mapping protocol, this
  11. # is equivalent to the Python expression "len(o)".
  12. int PyMapping_DelItemString(object o, char *key) except -1
  13. # Remove the mapping for object key from the object o. Return -1
  14. # on failure. This is equivalent to the Python statement "del
  15. # o[key]".
  16. int PyMapping_DelItem(object o, object key) except -1
  17. # Remove the mapping for object key from the object o. Return -1
  18. # on failure. This is equivalent to the Python statement "del
  19. # o[key]".
  20. bint PyMapping_HasKeyString(object o, char *key)
  21. # On success, return 1 if the mapping object has the key key and 0
  22. # otherwise. This is equivalent to the Python expression
  23. # "o.has_key(key)". This function always succeeds.
  24. bint PyMapping_HasKey(object o, object key)
  25. # Return 1 if the mapping object has the key key and 0
  26. # otherwise. This is equivalent to the Python expression
  27. # "o.has_key(key)". This function always succeeds.
  28. object PyMapping_Keys(object o)
  29. # Return value: New reference.
  30. # On success, return a list of the keys in object o. On failure,
  31. # return NULL. This is equivalent to the Python expression
  32. # "o.keys()".
  33. object PyMapping_Values(object o)
  34. # Return value: New reference.
  35. # On success, return a list of the values in object o. On failure,
  36. # return NULL. This is equivalent to the Python expression
  37. # "o.values()".
  38. object PyMapping_Items(object o)
  39. # Return value: New reference.
  40. # On success, return a list of the items in object o, where each
  41. # item is a tuple containing a key-value pair. On failure, return
  42. # NULL. This is equivalent to the Python expression "o.items()".
  43. object PyMapping_GetItemString(object o, char *key)
  44. # Return value: New reference.
  45. # Return element of o corresponding to the object key or NULL on
  46. # failure. This is the equivalent of the Python expression
  47. # "o[key]".
  48. int PyMapping_SetItemString(object o, char *key, object v) except -1
  49. # Map the object key to the value v in object o. Returns -1 on
  50. # failure. This is the equivalent of the Python statement "o[key]
  51. # = v".