mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-30 16:58:40 -04:00
Allow a long (provided it is not overflowing) where an int is accepted
This commit is contained in:
parent
2514ca29d8
commit
828e52578d
@ -4774,10 +4774,9 @@ write_function_instance(ostream &out, FunctionRemap *remap,
|
|||||||
|
|
||||||
} else if (TypeManager::is_unsigned_short(type)) {
|
} else if (TypeManager::is_unsigned_short(type)) {
|
||||||
if (args_type == AT_single_arg) {
|
if (args_type == AT_single_arg) {
|
||||||
// This is defined to PyLong_Check for Python 3 by py_panda.h.
|
type_check = "PyLongOrInt_Check(arg)";
|
||||||
type_check = "PyInt_Check(arg)";
|
|
||||||
extra_convert
|
extra_convert
|
||||||
<< "long " << param_name << " = PyInt_AS_LONG(arg);\n";
|
<< "long " << param_name << " = PyLongOrInt_AS_LONG(arg);\n";
|
||||||
|
|
||||||
pexpr_string = "(" + type->get_local_name(&parser) + ")" + param_name;
|
pexpr_string = "(" + type->get_local_name(&parser) + ")" + param_name;
|
||||||
} else {
|
} else {
|
||||||
@ -4804,12 +4803,11 @@ write_function_instance(ostream &out, FunctionRemap *remap,
|
|||||||
|
|
||||||
} else if (TypeManager::is_short(type)) {
|
} else if (TypeManager::is_short(type)) {
|
||||||
if (args_type == AT_single_arg) {
|
if (args_type == AT_single_arg) {
|
||||||
// This is defined to PyLong_Check for Python 3 by py_panda.h.
|
type_check = "PyLongOrInt_Check(arg)";
|
||||||
type_check = "PyInt_Check(arg)";
|
|
||||||
|
|
||||||
// Perform overflow checking in debug builds.
|
// Perform overflow checking in debug builds.
|
||||||
extra_convert
|
extra_convert
|
||||||
<< "long arg_val = PyInt_AS_LONG(arg);\n"
|
<< "long arg_val = PyLongOrInt_AS_LONG(arg);\n"
|
||||||
<< "#ifndef NDEBUG\n"
|
<< "#ifndef NDEBUG\n"
|
||||||
<< "if (arg_val < SHRT_MIN || arg_val > SHRT_MAX) {\n";
|
<< "if (arg_val < SHRT_MIN || arg_val > SHRT_MAX) {\n";
|
||||||
|
|
||||||
@ -4867,14 +4865,13 @@ write_function_instance(ostream &out, FunctionRemap *remap,
|
|||||||
|
|
||||||
} else if (TypeManager::is_integer(type)) {
|
} else if (TypeManager::is_integer(type)) {
|
||||||
if (args_type == AT_single_arg) {
|
if (args_type == AT_single_arg) {
|
||||||
// This is defined to PyLong_Check for Python 3 by py_panda.h.
|
type_check = "PyLongOrInt_Check(arg)";
|
||||||
type_check = "PyInt_Check(arg)";
|
|
||||||
|
|
||||||
// Perform overflow checking in debug builds. Note that Python 2
|
// Perform overflow checking in debug builds. Note that Python 2
|
||||||
// stores longs internally, for ints, so we don't do it on Windows,
|
// stores longs internally, for ints, so we don't do it on Windows,
|
||||||
// where longs are the same size as ints.
|
// where longs are the same size as ints.
|
||||||
extra_convert
|
extra_convert
|
||||||
<< "long arg_val = PyInt_AS_LONG(arg);\n"
|
<< "long arg_val = PyLongOrInt_AS_LONG(arg);\n"
|
||||||
<< "#if (SIZEOF_LONG > SIZEOF_INT) && !defined(NDEBUG)\n"
|
<< "#if (SIZEOF_LONG > SIZEOF_INT) && !defined(NDEBUG)\n"
|
||||||
<< "if (arg_val < INT_MIN || arg_val > INT_MAX) {\n";
|
<< "if (arg_val < INT_MIN || arg_val > INT_MAX) {\n";
|
||||||
|
|
||||||
|
@ -114,6 +114,7 @@ inline PyObject* doPy_RETURN_FALSE()
|
|||||||
#define PyLongOrInt_FromSize_t PyLong_FromSize_t
|
#define PyLongOrInt_FromSize_t PyLong_FromSize_t
|
||||||
#define PyLongOrInt_FromLong PyLong_FromLong
|
#define PyLongOrInt_FromLong PyLong_FromLong
|
||||||
#define PyLongOrInt_FromUnsignedLong PyLong_FromUnsignedLong
|
#define PyLongOrInt_FromUnsignedLong PyLong_FromUnsignedLong
|
||||||
|
#define PyLongOrInt_AS_LONG PyLong_AS_LONG
|
||||||
#define PyInt_Check PyLong_Check
|
#define PyInt_Check PyLong_Check
|
||||||
#define PyInt_AsLong PyLong_AsLong
|
#define PyInt_AsLong PyLong_AsLong
|
||||||
#define PyInt_AS_LONG PyLong_AS_LONG
|
#define PyInt_AS_LONG PyLong_AS_LONG
|
||||||
@ -122,6 +123,7 @@ inline PyObject* doPy_RETURN_FALSE()
|
|||||||
// PyInt_FromSize_t automatically picks the right type.
|
// PyInt_FromSize_t automatically picks the right type.
|
||||||
#define PyLongOrInt_FromSize_t PyInt_FromSize_t
|
#define PyLongOrInt_FromSize_t PyInt_FromSize_t
|
||||||
#define PyLongOrInt_FromLong PyInt_FromLong
|
#define PyLongOrInt_FromLong PyInt_FromLong
|
||||||
|
#define PyLongOrInt_AS_LONG PyInt_AsLong
|
||||||
|
|
||||||
// For more portably defining hash functions.
|
// For more portably defining hash functions.
|
||||||
typedef long Py_hash_t;
|
typedef long Py_hash_t;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user