instead of using PyCObject or plain strings.
The new PySwigObject is even safer than PyCObject, and
more friendly than plain strings:
now you can do
print a.this
<Swig Object at _00691608_p_A>
print str(a.this)
_00691608_p_A
print long(a.this)
135686400
print "%s 0x%x" % (a.this, a.this)
_00691608_p_A 0x8166900
the last one is very useful when debugging the C/C++ side, since
is the pointer value you will usually get from the debugger.
Also, if you have some old code that uses the string representation
"_00691608_p_A", you can use it now again by calling str(ptr), or
maybe nothing special by just calling PyString_AsString(..).
This change is mainly for nostalgic swig users that miss the
string representation, but also allows to say again
if a.this == b.this:
return "a is b"
and well, since the change were really simple, maybe in the future
we will be able to do
next = a.this + 1
or add native python iteration over native C/C++ arrays, ie, no
need to create/copy new tuples when returning and array or vector.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@6759 626c5289-ae23-0410-ae9c-e8d60b6d4f22
20 lines
222 B
OpenEdge ABL
20 lines
222 B
OpenEdge ABL
%module swigobject
|
|
|
|
|
|
|
|
%inline
|
|
{
|
|
struct A {
|
|
char name[4];
|
|
};
|
|
|
|
const char* pointer_str(A *a){
|
|
static char result[1024];
|
|
sprintf(result,"%x",a);
|
|
return result;
|
|
}
|
|
|
|
A *a_ptr(A *a){
|
|
return a;
|
|
}
|
|
}
|