|
From: William S F. <ws...@fu...> - 2006-12-01 23:53:32
|
Steve M. Robbins wrote:
> On Fri, Dec 01, 2006 at 12:37:05PM -0600, Steve M. Robbins wrote:
>
>> For the opaque "C pointer holder" types like SWIGTYPE_p_char, I'd like
>> to have a nice Java toString() method.
>
> Okay, no comments so far. It turns out to be straightforward, I
> think. Here's my attempt:
>
>
> --- java.swg.orig 2006-12-01 17:02:12.180019100 -0600
> +++ java.swg 2006-12-01 17:05:27.704321000 -0600
> @@ -1081,6 +1081,10 @@
> swigCPtr = 0;
> }
>
> + public String toString() {
> + return "$javaclassname<0x" + Long.toHexString( swigCPtr ) + ">";
> + }
> +
> protected static long getCPtr($javaclassname obj) {
> return (obj == null) ? 0 : obj.swigCPtr;
> }
>
You can of course provide your own modified javabody typemap, don't have
to edit the one in java.swg. Also you put the toString method in the
javacode typemap and get the same result.
William
|