# HG changeset patch # User Rik # Date 1355346931 28800 # Node ID e61405133a7649c83ba5886199f73cf1c5f01b62 # Parent eade542fedaa55a8ce53ac509a3f65bca7339294 Add new isjava function. * libinterp/octave-value/ov-base.h: Add new virtual function is_java (). Returns false. libinterp/octave-value/ov-java.h: Overload virtual function is_java to return true for objects in class octave_java. libinterp/octave-value/ov.h: Add is_java function that calls objects is_java function. * libinterp/octave-value/ov-java.cc: Add new DEFUN (isjava) which uses is_java. Placed outside HAVE_JAVA ifdef so that it is always available. diff -r eade542fedaa -r e61405133a76 libinterp/octave-value/ov-base.h --- a/libinterp/octave-value/ov-base.h Wed Dec 12 08:35:29 2012 -0800 +++ b/libinterp/octave-value/ov-base.h Wed Dec 12 13:15:31 2012 -0800 @@ -365,6 +365,8 @@ virtual bool is_object (void) const { return false; } + virtual bool is_java (void) const { return false; } + virtual bool is_cs_list (void) const { return false; } virtual bool is_magic_colon (void) const { return false; } diff -r eade542fedaa -r e61405133a76 libinterp/octave-value/ov-java.cc --- a/libinterp/octave-value/ov-java.cc Wed Dec 12 08:35:29 2012 -0800 +++ b/libinterp/octave-value/ov-java.cc Wed Dec 12 13:15:31 2012 -0800 @@ -2209,3 +2209,22 @@ #endif +// Outside of #ifdef HAVE_JAVA because it is desirable to be able to +// merely test for the presence of a Java object without having Java installed. +DEFUN (isjava, args, , + "-*- texinfo -*-\n\ +@deftypefn {Built-in Function} {} isjava (@var{x})\n\ +Return true if @var{x} is a Java object.\n\ +@seealso{class, typeinfo, isa}\n\ +@end deftypefn") +{ + octave_value retval; + + if (args.length () != 1) + print_usage (); + else + retval = args(0).is_java (); + + return retval; +} + diff -r eade542fedaa -r e61405133a76 libinterp/octave-value/ov-java.h --- a/libinterp/octave-value/ov-java.h Wed Dec 12 08:35:29 2012 -0800 +++ b/libinterp/octave-value/ov-java.h Wed Dec 12 13:15:31 2012 -0800 @@ -149,6 +149,8 @@ bool is_map (void) const { return true; } + bool is_java (void) const { return true; } + string_vector map_keys (void) const; dim_vector dims (void) const; diff -r eade542fedaa -r e61405133a76 libinterp/octave-value/ov.h --- a/libinterp/octave-value/ov.h Wed Dec 12 08:35:29 2012 -0800 +++ b/libinterp/octave-value/ov.h Wed Dec 12 13:15:31 2012 -0800 @@ -563,6 +563,9 @@ bool is_object (void) const { return rep->is_object (); } + bool is_java (void) const + { return rep->is_java (); } + bool is_cs_list (void) const { return rep->is_cs_list (); }