From: <bc...@wo...> - 2001-11-01 14:56:45
|
[brian zimmer] >If you have a PyObject and want to get the underlying Java instance, use: > > po.__tojava__(<the Java class you want>) > >For instance, say arg is a PyInteger instance, the following would get the >long value: > > long ticks = ((Number) arg.__tojava__(Number.class)).longValue(); Just the smallest little nit about style: If arg isn't a number, the line above will throw an ugly classcast exception. Normally it is better to do: Object tmp = arg.__tojava__(Number.class): if (tmp != Py.NoConversion) { long ticks = ((Number) tmp).longValue(); } >Most subclasses (maybe all) ... All subclasses that we want to use as arguments to java methods must implement __tojava__(). regards, finn |