mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 02:15:43 -04:00
implicitly coerce strings to InternalName pointers if needed
This commit is contained in:
parent
74d98b801a
commit
9d6ebb4c34
@ -73,6 +73,15 @@ attempt_coercion(PyObject *self, Dtool_PyTypedObject *classdef,
|
|||||||
// Attempt coercion: try to create a temporary instance of the
|
// Attempt coercion: try to create a temporary instance of the
|
||||||
// required class using the supplied parameter.
|
// required class using the supplied parameter.
|
||||||
PyObject *obj = PyObject_Call((PyObject *)classdef, self, NULL);
|
PyObject *obj = PyObject_Call((PyObject *)classdef, self, NULL);
|
||||||
|
if (obj == NULL) {
|
||||||
|
// That didn't work; try to call a static "make" method instead.
|
||||||
|
PyObject *make = PyObject_GetAttrString((PyObject *)classdef, "make");
|
||||||
|
if (make != NULL) {
|
||||||
|
PyErr_Clear();
|
||||||
|
obj = PyObject_Call(make, self, NULL);
|
||||||
|
Py_DECREF(make);
|
||||||
|
}
|
||||||
|
}
|
||||||
if (obj != NULL) {
|
if (obj != NULL) {
|
||||||
// Well, whaddaya know? The supplied parameter(s) suited
|
// Well, whaddaya know? The supplied parameter(s) suited
|
||||||
// the object's constructor. Now we have a temporary object
|
// the object's constructor. Now we have a temporary object
|
||||||
|
Loading…
x
Reference in New Issue
Block a user