Files
typthon/Include/boolobject.h
copilot-swe-agent[bot] 42e2356c88 Fix incorrect replacements in Py_ to Ty_ renaming
Fixed several macros and constants that should not have been renamed:
- _Py_CAST, _Py_NULL, _Py_RVALUE (internal utility macros)
- Py_UNUSED (unused parameter macro)
- Py_EQ, Py_NE, Py_LT, Py_LE, Py_GT, Py_GE (comparison constants)
- Py_RETURN_* macros (NONE, TRUE, FALSE, NOTIMPLEMENTED, RICHCOMPARE)
- Py_READONLY, Py_ULL, Py_CONTEXT_SWITCHED
- TyGC_Head in generated clinic files

Build is still in progress with some remaining issues to resolve.

Co-authored-by: johndoe6345789 <224850594+johndoe6345789@users.noreply.github.com>
2025-12-29 17:44:05 +00:00

55 lines
1.6 KiB
C

/* Boolean object interface */
#ifndef Ty_BOOLOBJECT_H
#define Ty_BOOLOBJECT_H
#ifdef __cplusplus
extern "C" {
#endif
// TyBool_Type is declared by object.h
#define TyBool_Check(x) Ty_IS_TYPE((x), &TyBool_Type)
/* Ty_False and Ty_True are the only two bools in existence. */
/* Don't use these directly */
PyAPI_DATA(PyLongObject) _Ty_FalseStruct;
PyAPI_DATA(PyLongObject) _Ty_TrueStruct;
/* Use these macros */
#if defined(Ty_LIMITED_API) && Ty_LIMITED_API+0 >= 0x030D0000
# define Ty_False Ty_GetConstantBorrowed(Ty_CONSTANT_FALSE)
# define Ty_True Ty_GetConstantBorrowed(Ty_CONSTANT_TRUE)
#else
# define Ty_False _TyObject_CAST(&_Ty_FalseStruct)
# define Ty_True _TyObject_CAST(&_Ty_TrueStruct)
#endif
// Test if an object is the True singleton, the same as "x is True" in Python.
PyAPI_FUNC(int) Ty_IsTrue(TyObject *x);
#define Ty_IsTrue(x) Ty_Is((x), Ty_True)
// Test if an object is the False singleton, the same as "x is False" in Python.
PyAPI_FUNC(int) Ty_IsFalse(TyObject *x);
#define Ty_IsFalse(x) Ty_Is((x), Ty_False)
/* Macros for returning Ty_True or Ty_False, respectively.
* Only treat Ty_True and Ty_False as immortal in the limited C API 3.12
* and newer. */
#if defined(Ty_LIMITED_API) && Ty_LIMITED_API+0 < 0x030c0000
# define Py_RETURN_TRUE return Ty_NewRef(Ty_True)
# define Py_RETURN_FALSE return Ty_NewRef(Ty_False)
#else
# define Py_RETURN_TRUE return Ty_True
# define Py_RETURN_FALSE return Ty_False
#endif
/* Function to return a bool from a C long */
PyAPI_FUNC(TyObject *) TyBool_FromLong(long);
#ifdef __cplusplus
}
#endif
#endif /* !Ty_BOOLOBJECT_H */