better SwigPyObject -> long/hex/oct, no warnings now
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7025 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
5394efadec
commit
3c385cb49c
1 changed files with 19 additions and 11 deletions
|
|
@ -101,27 +101,35 @@ PySwigObject_str(PySwigObject *v)
|
||||||
SWIGRUNTIME PyObject *
|
SWIGRUNTIME PyObject *
|
||||||
PySwigObject_long(PySwigObject *v)
|
PySwigObject_long(PySwigObject *v)
|
||||||
{
|
{
|
||||||
return PyLong_FromUnsignedLong((unsigned long) v->ptr);
|
return PyLong_FromVoidPtr(v->ptr);
|
||||||
|
}
|
||||||
|
|
||||||
|
SWIGRUNTIME PyObject *
|
||||||
|
PySwigObject_format(PySwigObject *v, const char* fmt)
|
||||||
|
{
|
||||||
|
PyObject *res = NULL;
|
||||||
|
PyObject *args = PyTuple_New(1);
|
||||||
|
if (args && (PyTuple_SetItem(args, 0, PySwigObject_long(v)) == 0)) {
|
||||||
|
PyObject *ofmt = PyString_FromString(fmt);
|
||||||
|
if (ofmt) {
|
||||||
|
res = PyString_Format(ofmt,args);
|
||||||
|
Py_DECREF(ofmt);
|
||||||
|
}
|
||||||
|
Py_DECREF(args);
|
||||||
|
}
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
SWIGRUNTIME PyObject *
|
SWIGRUNTIME PyObject *
|
||||||
PySwigObject_oct(PySwigObject *v)
|
PySwigObject_oct(PySwigObject *v)
|
||||||
{
|
{
|
||||||
char buf[100];
|
return PySwigObject_format(v,"%o");
|
||||||
unsigned long x = (unsigned long)v->ptr;
|
|
||||||
if (x == 0)
|
|
||||||
strncpy(buf, "0",sizeof(buf));
|
|
||||||
else
|
|
||||||
PyOS_snprintf(buf, sizeof(buf), "0%lo", x);
|
|
||||||
return PyString_FromString(buf);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SWIGRUNTIME PyObject *
|
SWIGRUNTIME PyObject *
|
||||||
PySwigObject_hex(PySwigObject *v)
|
PySwigObject_hex(PySwigObject *v)
|
||||||
{
|
{
|
||||||
char buf[100];
|
return PySwigObject_format(v,"%x");
|
||||||
PyOS_snprintf(buf, sizeof(buf), "%p", v->ptr);
|
|
||||||
return PyString_FromString(buf);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
SWIGRUNTIME int
|
SWIGRUNTIME int
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue