12/17/12
John,
I have an octave_value that is the input to a DEFUN function. I have
verified that the object is in fact of class "octave_java". Is there an
easy way to interpret the octave_value as being of class octave_java and
calling a method from the octave_java class?
Or is the real, but longer way, to declare a new function in ov-base.h that
performs the interpretation. And then in the DEFUN function I need to
declare a new instance of the octave_java class.
octave_java oct_jobj = args(0).octave_java_value ();
oct_jobj.method_name ();
The java.cc code used to do something like (see TO_JAVA macro):
dynamic_cast<octave_java*> ((obj).internal_rep ())
Not very clean, but it was only used internally anyway. This also returns a pointer, not a plain object. Having a method octave_value::octave_java_value() returning a plain octave_java is technically possible: the octave_java class handles copy, by referencing the underlying Java object.
Michael.