mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 10:22:45 -04:00
python 2.4 stuff
This commit is contained in:
parent
8277b718b9
commit
b3fa4b906c
@ -687,7 +687,13 @@ void DCPacker::
|
||||
pack_object(PyObject *object) {
|
||||
nassertv(_mode == M_pack || _mode == M_repack);
|
||||
|
||||
#ifdef USE_PYTHON_2_2_OR_EARLIER
|
||||
if (PyInt_Check(object)) {
|
||||
#else
|
||||
if (PyLong_Check(object)) {
|
||||
pack_int(PyLong_AsUnsignedLong(object));
|
||||
} else if (PyInt_Check(object)) {
|
||||
#endif
|
||||
pack_int(PyInt_AS_LONG(object));
|
||||
} else if (PyFloat_Check(object)) {
|
||||
pack_double(PyFloat_AS_DOUBLE(object));
|
||||
|
@ -398,13 +398,17 @@ bool CConnectionRepository::
|
||||
handle_update_field() {
|
||||
#ifdef HAVE_PYTHON
|
||||
PStatTimer timer(_update_pcollector);
|
||||
int do_id = _di.get_uint32();
|
||||
unsigned int do_id = _di.get_uint32();
|
||||
if (_python_repository != (PyObject *)NULL) {
|
||||
PyObject *doId2do =
|
||||
PyObject_GetAttrString(_python_repository, "doId2do");
|
||||
nassertr(doId2do != NULL, false);
|
||||
|
||||
#ifdef USE_PYTHON_2_2_OR_EARLIER
|
||||
PyObject *doId = PyInt_FromLong(do_id);
|
||||
#else
|
||||
PyObject *doId = PyLong_FromUnsignedLong(do_id);
|
||||
#endif
|
||||
PyObject *distobj = PyDict_GetItem(doId2do, doId);
|
||||
Py_DECREF(doId);
|
||||
Py_DECREF(doId2do);
|
||||
@ -482,7 +486,11 @@ describe_message(ostream &out, const string &prefix,
|
||||
PyObject_GetAttrString(_python_repository, "doId2do");
|
||||
nassertv(doId2do != NULL);
|
||||
|
||||
#ifdef USE_PYTHON_2_2_OR_EARLIER
|
||||
PyObject *doId = PyInt_FromLong(do_id);
|
||||
#else
|
||||
PyObject *doId = PyLong_FromUnsignedLong(do_id);
|
||||
#endif
|
||||
PyObject *distobj = PyDict_GetItem(doId2do, doId);
|
||||
Py_DECREF(doId);
|
||||
Py_DECREF(doId2do);
|
||||
|
@ -232,13 +232,13 @@ write_class_wrapper(ostream &out, InterfaceMaker::Object *object) {
|
||||
<< " PyObject *name = PyString_FromString(\""
|
||||
<< python_name << "\");\n"
|
||||
<< " wrapper = PyClass_New(bases, dict, name);\n"
|
||||
<< " for (i = 0; i < methods_size; i++) {\n"
|
||||
<< " for (i = 0; i < methods_size; ++i) {\n"
|
||||
<< " PyObject *function, *method;\n"
|
||||
<< " function = PyCFunction_New(&methods[i], (PyObject *)NULL);\n"
|
||||
<< " method = PyMethod_New(function, (PyObject *)NULL, wrapper);\n"
|
||||
<< " PyDict_SetItemString(dict, methods[i].ml_name, method);\n"
|
||||
<< " }\n"
|
||||
<< " for (i = 0; i < class_methods_size; i++) {\n"
|
||||
<< " for (i = 0; i < class_methods_size; ++i) {\n"
|
||||
<< " PyObject *function;\n"
|
||||
<< " function = PyCFunction_New(&class_methods[i], (PyObject *)NULL);\n"
|
||||
<< " PyDict_SetItemString(dict, class_methods[i].ml_name, function);\n"
|
||||
@ -394,6 +394,13 @@ write_function_instance(ostream &out, int indent_level,
|
||||
extra_cleanup += " Py_XDECREF(" + param_name + "_long);";
|
||||
expected_params += "long";
|
||||
|
||||
#ifndef USE_PYTHON_2_2_OR_EARLIER
|
||||
} else if (TypeManager::is_unsigned_integer(type)) {
|
||||
out << "unsigned int " << param_name;
|
||||
format_specifiers += "I"; // This requires Python 2.3 or better
|
||||
parameter_list += ", &" + param_name;
|
||||
#endif
|
||||
|
||||
} else if (TypeManager::is_integer(type)) {
|
||||
out << "int " << param_name;
|
||||
format_specifiers += "i";
|
||||
@ -564,6 +571,12 @@ pack_return_value(ostream &out, int indent_level,
|
||||
indent(out, indent_level)
|
||||
<< "return PyLong_FromLongLong(" << return_expr << ");\n";
|
||||
|
||||
#ifndef USE_PYTHON_2_2_OR_EARLIER
|
||||
} else if (TypeManager::is_unsigned_integer(type)) {
|
||||
indent(out, indent_level)
|
||||
<< "return PyLong_FromUnsignedLong(" << return_expr << ");\n";
|
||||
#endif
|
||||
|
||||
} else if (TypeManager::is_integer(type)) {
|
||||
indent(out, indent_level)
|
||||
<< "return PyInt_FromLong(" << return_expr << ");\n";
|
||||
|
@ -251,7 +251,7 @@ void InterfaceMakerPythonSimple::write_function_instance(ostream &out, Interface
|
||||
// the parameter expression list for call_function().
|
||||
|
||||
int pn;
|
||||
for (pn = 0; pn < (int)remap->_parameters.size(); pn++) {
|
||||
for (pn = 0; pn < (int)remap->_parameters.size(); ++pn) {
|
||||
indent(out, 2);
|
||||
CPPType *orig_type = remap->_parameters[pn]._remap->get_orig_type();
|
||||
CPPType *type = remap->_parameters[pn]._remap->get_new_type();
|
||||
@ -303,6 +303,13 @@ void InterfaceMakerPythonSimple::write_function_instance(ostream &out, Interface
|
||||
pexpr_string = "PyLong_AsLongLong(" + param_name + "_long)";
|
||||
extra_cleanup += " Py_XDECREF(" + param_name + "_long);";
|
||||
|
||||
#ifndef USE_PYTHON_2_2_OR_EARLIER
|
||||
} else if (TypeManager::is_unsigned_integer(type)) {
|
||||
out << "unsigned int " << param_name;
|
||||
format_specifiers += "I"; // This requires Python 2.3 or better
|
||||
parameter_list += ", &" + param_name;
|
||||
#endif
|
||||
|
||||
} else if (TypeManager::is_integer(type)) {
|
||||
out << "int " << param_name;
|
||||
format_specifiers += "i";
|
||||
@ -456,6 +463,12 @@ pack_return_value(ostream &out, int indent_level,
|
||||
indent(out, indent_level)
|
||||
<< "return PyLong_FromLongLong(" << return_expr << ");\n";
|
||||
|
||||
#ifndef USE_PYTHON_2_2_OR_EARLIER
|
||||
} else if (TypeManager::is_unsigned_integer(type)) {
|
||||
indent(out, indent_level)
|
||||
<< "return PyLong_FromUnsignedLong(" << return_expr << ");\n";
|
||||
#endif
|
||||
|
||||
} else if (TypeManager::is_integer(type)) {
|
||||
indent(out, indent_level)
|
||||
<< "return PyInt_FromLong(" << return_expr << ");\n";
|
||||
|
Loading…
x
Reference in New Issue
Block a user