PyObject *name,
const char *format, ...);
-extern PyObject* _PyObject_CallMethodIdObjArgs(
- PyObject *obj,
- _Py_Identifier *name,
- ...);
-
-static inline PyObject *
-_PyObject_VectorcallMethodId(
- _Py_Identifier *name, PyObject *const *args,
- size_t nargsf, PyObject *kwnames)
-{
- PyObject *oname = _PyUnicode_FromId(name); /* borrowed */
- if (!oname) {
- return _Py_NULL;
- }
- return PyObject_VectorcallMethod(oname, args, nargsf, kwnames);
-}
-
-static inline PyObject *
-_PyObject_CallMethodIdNoArgs(PyObject *self, _Py_Identifier *name)
-{
- size_t nargsf = 1 | PY_VECTORCALL_ARGUMENTS_OFFSET;
- return _PyObject_VectorcallMethodId(name, &self, nargsf, _Py_NULL);
-}
-
-static inline PyObject *
-_PyObject_CallMethodIdOneArg(PyObject *self, _Py_Identifier *name, PyObject *arg)
-{
- PyObject *args[2] = {self, arg};
- size_t nargsf = 2 | PY_VECTORCALL_ARGUMENTS_OFFSET;
- assert(arg != NULL);
- return _PyObject_VectorcallMethodId(name, args, nargsf, _Py_NULL);
-}
-
/* === Vectorcall protocol (PEP 590) ============================= */
// Export for 'array' shared extension
PyAPI_FUNC(PyObject*) _PyEval_GetBuiltin(PyObject *);
-extern PyObject* _PyEval_GetBuiltinId(_Py_Identifier *);
-
extern void _PyEval_SetSwitchInterval(unsigned long microseconds);
extern unsigned long _PyEval_GetSwitchInterval(void);
extern int _PyDict_Contains_KnownHash(PyObject *, PyObject *, Py_hash_t);
-// "Id" variants
-extern PyObject* _PyDict_GetItemIdWithError(PyObject *dp,
- _Py_Identifier *key);
-extern int _PyDict_ContainsId(PyObject *, _Py_Identifier *);
-extern int _PyDict_SetItemId(PyObject *dp, _Py_Identifier *key, PyObject *item);
-extern int _PyDict_DelItemId(PyObject *mp, _Py_Identifier *key);
-
extern int _PyDict_Next(
PyObject *mp, Py_ssize_t *pos, PyObject **key, PyObject **value, Py_hash_t *hash);
Py_ssize_t seqlen
);
-/* Test whether a unicode is equal to ASCII identifier. Return 1 if true,
- 0 otherwise. The right argument must be ASCII identifier.
- Any error occurs inside will be cleared before return. */
-extern int _PyUnicode_EqualToASCIIId(
- PyObject *left, /* Left string */
- _Py_Identifier *right /* Right identifier */
- );
-
// Test whether a unicode is equal to ASCII string. Return 1 if true,
// 0 otherwise. The right argument must be ASCII-encoded string.
// Any error occurs inside will be cleared before return.
}
-PyObject *
-_PyObject_CallMethodIdObjArgs(PyObject *obj, _Py_Identifier *name, ...)
-{
- PyThreadState *tstate = _PyThreadState_GET();
- if (obj == NULL || name == NULL) {
- return null_error(tstate);
- }
-
- PyObject *oname = _PyUnicode_FromId(name); /* borrowed */
- if (!oname) {
- return NULL;
- }
- _PyCStackRef method;
- _PyThreadState_PushCStackRef(tstate, &method);
- int is_method = _PyObject_GetMethodStackRef(tstate, obj, oname, &method.ref);
- if (PyStackRef_IsNull(method.ref)) {
- _PyThreadState_PopCStackRef(tstate, &method);
- return NULL;
- }
- PyObject *callable = PyStackRef_AsPyObjectBorrow(method.ref);
-
- obj = is_method ? obj : NULL;
-
- va_list vargs;
- va_start(vargs, name);
- PyObject *result = object_vacall(tstate, obj, callable, vargs);
- va_end(vargs);
-
- _PyThreadState_PopCStackRef(tstate, &method);
- return result;
-}
-
-
PyObject *
PyObject_CallFunctionObjArgs(PyObject *callable, ...)
{
return _PyDict_GetItem_KnownHash(dp, kv, hash); // borrowed reference
}
-PyObject *
-_PyDict_GetItemIdWithError(PyObject *dp, _Py_Identifier *key)
-{
- PyObject *kv;
- kv = _PyUnicode_FromId(key); /* borrowed */
- if (kv == NULL)
- return NULL;
- Py_hash_t hash = unicode_get_hash(kv);
- assert (hash != -1); /* interned strings have their hash value initialised */
- return _PyDict_GetItem_KnownHash(dp, kv, hash); // borrowed reference
-}
-
PyObject *
_PyDict_GetItemStringWithError(PyObject *v, const char *key)
{
return 0;
}
-int
-_PyDict_ContainsId(PyObject *op, _Py_Identifier *key)
-{
- PyObject *kv = _PyUnicode_FromId(key); /* borrowed */
- if (kv == NULL) {
- return -1;
- }
- return PyDict_Contains(op, kv);
-}
-
/* Hack to implement "key in dict" */
static PySequenceMethods dict_as_sequence = {
0, /* sq_length */
return res;
}
-int
-_PyDict_SetItemId(PyObject *v, _Py_Identifier *key, PyObject *item)
-{
- PyObject *kv;
- kv = _PyUnicode_FromId(key); /* borrowed */
- if (kv == NULL)
- return -1;
- return PyDict_SetItem(v, kv, item);
-}
-
int
PyDict_SetItemString(PyObject *v, const char *key, PyObject *item)
{
return err;
}
-int
-_PyDict_DelItemId(PyObject *v, _Py_Identifier *key)
-{
- PyObject *kv = _PyUnicode_FromId(key); /* borrowed */
- if (kv == NULL)
- return -1;
- return PyDict_DelItem(v, kv);
-}
-
int
PyDict_DelItemString(PyObject *v, const char *key)
{
PyDict_DelItemString PyMapping_DelItemString
PyDict_GetItem -
PyDict_GetItemWithError PyObject_GetItem
-_PyDict_GetItemIdWithError -
PyDict_GetItemString PyMapping_GetItemString
PyDict_Items PyMapping_Items
PyDict_Keys PyMapping_Keys
memcmp(PyUnicode_1BYTE_DATA(unicode), str, len) == 0;
}
-int
-_PyUnicode_EqualToASCIIId(PyObject *left, _Py_Identifier *right)
-{
- PyObject *right_uni;
-
- assert(_PyUnicode_CHECK(left));
- assert(right->string);
-#ifndef NDEBUG
- for (const char *p = right->string; *p; p++) {
- assert((unsigned char)*p < 128);
- }
-#endif
-
- if (!PyUnicode_IS_ASCII(left))
- return 0;
-
- right_uni = _PyUnicode_FromId(right); /* borrowed */
- if (right_uni == NULL) {
- /* memory error or bad data */
- PyErr_Clear();
- return _PyUnicode_EqualToASCIIString(left, right->string);
- }
-
- if (left == right_uni)
- return 1;
-
- assert(PyUnicode_CHECK_INTERNED(right_uni));
- if (PyUnicode_CHECK_INTERNED(left)) {
- return 0;
- }
-
- Py_hash_t right_hash = PyUnicode_HASH(right_uni);
- assert(right_hash != -1);
- Py_hash_t hash = PyUnicode_HASH(left);
- if (hash != -1 && hash != right_hash) {
- return 0;
- }
-
- return unicode_eq(left, right_uni);
-}
-
PyObject *
PyUnicode_RichCompare(PyObject *left, PyObject *right, int op)
{
return attr;
}
-PyObject *
-_PyEval_GetBuiltinId(_Py_Identifier *name)
-{
- return _PyEval_GetBuiltin(_PyUnicode_FromId(name));
-}
-
PyObject *
PyEval_GetLocals(void)
{