octave-maintainers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Easy way to interpret octave_value as XXX?


From: Michael Goffioul
Subject: Re: Easy way to interpret octave_value as XXX?
Date: Mon, 17 Dec 2012 18:24:05 -0500

On Mon, Dec 17, 2012 at 5:43 PM, Rik <address@hidden> wrote:
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.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]