GNU Octave
4.2.1
A high-level interpreted language, primarily intended for numerical computations, mostly compatible with Matlab
|
#include "defun.h"
#include "error.h"
#include "errwarn.h"
#include "fpucw-wrappers.h"
#include <algorithm>
#include <map>
#include <iostream>
#include <fstream>
#include <string>
#include <clocale>
#include "Cell.h"
#include "cmd-edit.h"
#include "defaults.h"
#include "file-ops.h"
#include "file-stat.h"
#include "load-path.h"
#include "oct-env.h"
#include "oct-shlib.h"
#include "ov-java.h"
#include "parse.h"
#include "variables.h"
#include <jni.h>
Go to the source code of this file.
Classes | |
class | java_local_ref< T > |
class | octave::JVMArgs |
Namespaces | |
octave | |
Octave interface to the compression and uncompression libraries. | |
Macros | |
#define | BOX_PRIMITIVE_ARRAY(JAVA_TYPE, JAVA_ID, JAVA_TYPE_CAP, OCTAVE_ID) |
#define | TO_JAVA(obj) dynamic_cast<octave_java*> ((obj).internal_rep ()) |
#define | TO_JCLASS(obj) reinterpret_cast<jclass> (obj) |
#define | TO_JNIENV(env) reinterpret_cast<JNIEnv *> (env) |
#define | TO_JOBJECT(obj) reinterpret_cast<jobject> (obj) |
#define | UNBOX_PRIMITIVE_ARRAY(METHOD_T, OCTAVE_T, JAVA_T, JAVA_T_CAP) |
#define | UNBOX_PRIMITIVE_SCALAR(OCTAVE_T, METHOD_T, JAVA_T, JAVA_CON) |
Typedefs | |
typedef JNIEnv void * | args |
typedef jsize | bufLen |
typedef java_local_ref < jbyteArray > | jbyteArray_ref |
typedef java_local_ref< jclass > | jclass_ref |
typedef java_local_ref < jdoubleArray > | jdoubleArray_ref |
typedef java_local_ref< jintArray > | jintArray_ref |
typedef java_local_ref< jobject > | jobject_ref |
typedef java_local_ref < jobjectArray > | jobjectArray_ref |
typedef java_local_ref< jstring > | jstring_ref |
typedef java_local_ref < jthrowable > | jthrowable_ref |
typedef jsize jsize * | nVMs |
typedef JNIEnv ** | penv |
Functions | |
static octave_value | box (JNIEnv *jni_env, void *jobj_arg, void *jcls_arg) |
Convert the Java object pointed to by jobj_arg with class jcls_arg to an Octave value. More... | |
static octave_value | box_more (JNIEnv *jni_env, void *jobj_arg, void *jcls_arg=0) |
static octave_value | check_exception (JNIEnv *jni_env) |
static dim_vector | compute_array_dimensions (JNIEnv *jni_env, jobject obj) |
static octave_value | convert_to_string (JNIEnv *jni_env, jobject java_object, bool force, char type) |
OCTAVE_EXPORT octave_value_list | F__java_exit__ (const octave_value_list &, int) |
OCTAVE_EXPORT octave_value_list | F__java_init__ (const octave_value_list &, int) |
static jclass | find_octave_class (JNIEnv *jni_env, const char *name) |
OCTAVE_EXPORT octave_value_list | FjavaObject (const octave_value_list &args, int) by calling the class const ructor with the arguments ar |
static octave_value | get_array_elements (JNIEnv *jni_env, jobject jobj, const octave_value_list &idx) |
static long | get_current_thread_ID (JNIEnv *jni_env) |
static string_vector | get_invoke_list (JNIEnv *jni_env, void *jobj_arg) |
static std::string | initial_class_path (void) |
static std::string | initial_java_dir (void) |
static void | initialize_java (void) |
static void | initialize_jvm (void) |
static bool | is_auto_convertible_number (JNIEnv *jni_env, jobject jobj) |
Return whether jobj shall be automatically converted to an Octave numeric value. More... | |
static int | java_event_hook (void) |
JNIEXPORT jboolean JNICALL | Java_org_octave_Octave_call (JNIEnv *, jclass, jstring, jobjectArray, jobjectArray) |
JNIEXPORT void JNICALL | Java_org_octave_Octave_doEvalString (JNIEnv *, jclass, jstring) |
JNIEXPORT void JNICALL | Java_org_octave_Octave_doInvoke (JNIEnv *, jclass, jint, jobjectArray) |
JNIEXPORT jboolean JNICALL | Java_org_octave_Octave_needThreadedInvokation (JNIEnv *, jclass) |
JNIEXPORT void JNICALL | Java_org_octave_OctaveReference_doFinalize (JNIEnv *, jclass, jint) |
typedef | jint (JNICALL *JNI_CreateJavaVM_t)(JavaVM **pvm |
static std::string | jstring_to_string (JNIEnv *jni_env, jstring s) |
static std::string | jstring_to_string (JNIEnv *jni_env, jobject obj) |
static jobject | make_java_index (JNIEnv *jni_env, const octave_value_list &idx) |
static std::string | read_classpath_txt (const std::string &filepath) |
static octave_value | set_array_elements (JNIEnv *jni_env, jobject jobj, const octave_value_list &idx, const octave_value &rhs) |
static void | terminate_jvm (void) |
static JNIEnv * | thread_jni_env (void) |
static bool | unbox (JNIEnv *jni_env, const octave_value &val, jobject_ref &jobj, jclass_ref &jcls) |
static bool | unbox (JNIEnv *jni_env, const octave_value_list &args, jobjectArray_ref &jobjs, jobjectArray_ref &jclss) |
Variables | |
static JavaVM * | jvm = 0 |
static bool | jvm_attached = false |
static octave::dynamic_library | jvm_lib |
static std::map< int, octave_value > | listener_map |
ots The first example below creates an uninitialized | object |
static int | octave_java_refcount = 0 |
static std::map< int, octave_value > | octave_ref_map |
static long | octave_thread_ID = -1 |
bool | Vdebug_java = false |
bool | Vjava_matrix_autoconversion = false |
bool | Vjava_unsigned_autoconversion = true |
#define BOX_PRIMITIVE_ARRAY | ( | JAVA_TYPE, | |
JAVA_ID, | |||
JAVA_TYPE_CAP, | |||
OCTAVE_ID | |||
) |
Referenced by box().
#define TO_JAVA | ( | obj | ) | dynamic_cast<octave_java*> ((obj).internal_rep ()) |
Definition at line 1136 of file ov-java.cc.
Referenced by unbox().
#define TO_JCLASS | ( | obj | ) | reinterpret_cast<jclass> (obj) |
Definition at line 63 of file ov-java.cc.
Referenced by box(), box_more(), octave_java::init(), and octave_java::release().
#define TO_JNIENV | ( | env | ) | reinterpret_cast<JNIEnv *> (env) |
Definition at line 65 of file ov-java.cc.
Referenced by octave_java::do_java_get(), octave_java::do_java_set(), octave_java::do_javaMethod(), and octave_java::do_javaObject().
#define TO_JOBJECT | ( | obj | ) | reinterpret_cast<jobject> (obj) |
Definition at line 62 of file ov-java.cc.
Referenced by box(), box_more(), octave_java::convert_to_str_internal(), octave_java::dims(), get_invoke_list(), octave_java::init(), octave_java::is_instance_of(), octave_java::is_java_string(), octave_java::release(), octave_java::subsasgn(), octave_java::subsref(), and unbox().
#define UNBOX_PRIMITIVE_ARRAY | ( | METHOD_T, | |
OCTAVE_T, | |||
JAVA_T, | |||
JAVA_T_CAP | |||
) |
Referenced by unbox().
#define UNBOX_PRIMITIVE_SCALAR | ( | OCTAVE_T, | |
METHOD_T, | |||
JAVA_T, | |||
JAVA_CON | |||
) |
Referenced by unbox().
OCTAVE_EXPORT octave_value_list int64 nd deftypefn *return args |
Definition at line 67 of file ov-java.cc.
typedef jsize bufLen |
Definition at line 70 of file ov-java.cc.
typedef java_local_ref<jbyteArray> jbyteArray_ref |
Definition at line 127 of file ov-java.cc.
typedef java_local_ref<jclass> jclass_ref |
Definition at line 123 of file ov-java.cc.
typedef java_local_ref<jdoubleArray> jdoubleArray_ref |
Definition at line 128 of file ov-java.cc.
typedef java_local_ref<jintArray> jintArray_ref |
Definition at line 126 of file ov-java.cc.
typedef java_local_ref<jobject> jobject_ref |
Definition at line 122 of file ov-java.cc.
typedef java_local_ref<jobjectArray> jobjectArray_ref |
Definition at line 125 of file ov-java.cc.
typedef java_local_ref<jstring> jstring_ref |
Definition at line 124 of file ov-java.cc.
typedef java_local_ref<jthrowable> jthrowable_ref |
Definition at line 129 of file ov-java.cc.
typedef jsize jsize* nVMs |
Definition at line 70 of file ov-java.cc.
typedef JNIEnv** penv |
Definition at line 67 of file ov-java.cc.
|
static |
Convert the Java object pointed to by jobj_arg
with class jcls_arg
to an Octave value.
jni_env | JNI environment pointer |
jobj_arg | pointer to a Java object |
jcls_arg | optional pointer to the Java class of jobj_arg |
double
if jobj_arg
is of type Byte
, Short
, Integer
, Long
, Float
or Double
jobj_arg
is of type Boolean
jobj_arg
is of type Character
or String
jobj_arg
is a Java array of primitive types jobj_arg
is of type org.octave.Matrix
and Vjava_matrix_autoconversion is enabled jobj_arg
is of type org.octave.OctaveReference
octave_java
object wrapping the Java object otherwise Definition at line 1192 of file ov-java.cc.
References BOX_PRIMITIVE_ARRAY, octave_value::convert_to_str(), dims, dv, find_octave_class(), Array< T >::fortran_vec(), int16, int32, int64, is_auto_convertible_number(), octave_value::is_undefined(), jint(), jstring_to_string(), m, dim_vector::ndims(), Array< T >::numel(), octave_value(), dim_vector::resize(), retval, s, string, TO_JCLASS, and TO_JOBJECT.
Referenced by box_more(), octave_java::do_java_get(), octave_java::do_javaMethod(), get_array_elements(), axes::properties::get_property(), Java_org_octave_Octave_call(), Java_org_octave_Octave_doInvoke(), set_array_elements(), axes::properties::set_defaults(), shortcut_manager::shortcut_dialog(), octave::ft_text_renderer::text_to_pixels(), QtHandles::PopupMenuControl::update(), and uicontrol::properties::update_text_extent().
|
static |
Definition at line 1386 of file ov-java.cc.
References box(), Array< T >::fortran_vec(), Array< T >::is_empty(), octave_value::is_java(), octave_value::is_undefined(), jstring_to_string(), m, octave_set_default_fpucw(), octave_value(), Matrix::resize(), retval, row, TO_JCLASS, TO_JOBJECT, and Matrix::transpose().
|
static |
Definition at line 779 of file ov-java.cc.
References error(), jstring_to_string(), retval, and string.
Referenced by convert_to_string(), octave_java::do_java_get(), octave_java::do_java_set(), octave_java::do_javaMethod(), octave_java::do_javaObject(), get_array_elements(), make_java_index(), and set_array_elements().
|
static |
Definition at line 888 of file ov-java.cc.
References java_local_ref< T >::detach(), dv, dim_vector::ndims(), octave_set_default_fpucw(), and dim_vector::resize().
Referenced by octave_java::dims().
|
static |
Definition at line 1078 of file ov-java.cc.
References array(), c, check_exception(), error(), jstring_to_string(), octave_set_default_fpucw(), octave_value(), retval, and type.
Referenced by octave_java::convert_to_str_internal().
OCTAVE_EXPORT octave_value_list F__java_exit__ | ( | const octave_value_list & | , |
int | |||
) |
Definition at line 2804 of file ov-java.cc.
References err_disabled_feature(), ovl(), and terminate_jvm().
Referenced by install_ov_java_fcns().
OCTAVE_EXPORT octave_value_list F__java_init__ | ( | const octave_value_list & | , |
int | |||
) |
Definition at line 2776 of file ov-java.cc.
References err_disabled_feature(), initialize_java(), and retval.
Referenced by install_ov_java_fcns().
|
static |
Definition at line 808 of file ov-java.cc.
References jstring_to_string(), replace(), and string.
Referenced by box(), octave_java::do_java_get(), octave_java::do_java_set(), octave_java::do_javaMethod(), octave_java::do_javaObject(), get_array_elements(), java_event_hook(), set_array_elements(), and unbox().
OCTAVE_EXPORT octave_value_list FjavaObject | ( | const octave_value_list & | args, |
int | |||
) | const |
Definition at line 2837 of file ov-java.cc.
|
static |
Definition at line 960 of file ov-java.cc.
References box(), check_exception(), find_octave_class(), make_java_index(), octave_set_default_fpucw(), and retval.
Referenced by octave_java::subsref().
|
static |
Definition at line 1743 of file ov-java.cc.
References result.
Referenced by initialize_java(), and Java_org_octave_Octave_needThreadedInvokation().
|
static |
Definition at line 1019 of file ov-java.cc.
References jstring_to_string(), octave_set_default_fpucw(), string_vector::sort(), and TO_JOBJECT.
Referenced by octave_java::map_keys().
|
static |
Definition at line 402 of file ov-java.cc.
References octave::sys::file_ops::dir_sep_str(), error(), filename, octave::sys::env::get_current_directory(), octave::sys::env::get_home_directory(), initial_java_dir(), read_classpath_txt(), retval, string, and octave::sys::file_ops::tilde_expand().
Referenced by initialize_jvm().
|
static |
Definition at line 339 of file ov-java.cc.
References octave::sys::file_ops::dir_sep_str(), octave::sys::env::getenv(), string, and Vfcn_file_dir.
Referenced by initial_class_path(), and initialize_jvm().
|
static |
Definition at line 1785 of file ov-java.cc.
References octave::command_editor::add_event_hook(), error(), get_current_thread_ID(), initialize_jvm(), java_event_hook(), jvm, octave_set_default_fpucw(), octave_thread_ID, string, and thread_jni_env().
Referenced by F__java_init__().
|
static |
Definition at line 491 of file ov-java.cc.
References octave::JVMArgs::add(), octave::sys::file_ops::dir_sep_str(), error(), octave::sys::env::getenv(), initial_class_path(), initial_java_dir(), jvm, octave::JVMArgs::read_java_opts(), octave::dynamic_library::search(), string, octave::JVMArgs::to_args(), and value().
Referenced by initialize_java().
|
static |
Return whether jobj
shall be automatically converted to an Octave numeric value.
If jobj
is an instance of any of the numeric wrapper classes Byte
, Integer
, Long
, Short
, Float
, or Double
, then it will be converted using the java.lang.Number.doubleValue()
method.
jobj | Java object being returned to Octave |
true
if jobj
shall be converted into a numeric value automatically, false
otherwise Definition at line 1149 of file ov-java.cc.
Referenced by box().
|
static |
Definition at line 1766 of file ov-java.cc.
References find_octave_class(), octave_set_default_fpucw(), and thread_jni_env().
Referenced by initialize_java().
JNIEXPORT jboolean JNICALL Java_org_octave_Octave_call | ( | JNIEnv * | env, |
jclass | , | ||
jstring | funcName, | ||
jobjectArray | argin, | ||
jobjectArray | argout | ||
) |
Definition at line 1810 of file ov-java.cc.
References box(), feval(), fname, jstring_to_string(), nargin, nargout(), string, and unbox().
JNIEXPORT void JNICALL Java_org_octave_Octave_doEvalString | ( | JNIEnv * | env, |
jclass | , | ||
jstring | cmd | ||
) |
Definition at line 1881 of file ov-java.cc.
References eval_string(), jstring_to_string(), s, and string.
JNIEXPORT void JNICALL Java_org_octave_Octave_doInvoke | ( | JNIEnv * | env, |
jclass | , | ||
jint | ID, | ||
jobjectArray | args | ||
) |
Definition at line 1837 of file ov-java.cc.
References box(), c, octave_value::cell_value(), octave_value::columns(), error(), fcn, feval(), octave_value::function_value(), octave_value::is_cell(), octave_value::is_function_handle(), octave_value::length(), Array< T >::numel(), octave_value::rows(), and val.
JNIEXPORT jboolean JNICALL Java_org_octave_Octave_needThreadedInvokation | ( | JNIEnv * | env, |
jclass | |||
) |
Definition at line 1889 of file ov-java.cc.
References get_current_thread_ID(), and octave_thread_ID.
JNIEXPORT void JNICALL Java_org_octave_OctaveReference_doFinalize | ( | JNIEnv * | , |
jclass | , | ||
jint | ID | ||
) |
Definition at line 1831 of file ov-java.cc.
typedef jint | ( | JNICALL * | JNI_CreateJavaVM_t | ) |
Referenced by box(), make_java_index(), and unbox().
|
static |
Definition at line 673 of file ov-java.cc.
References retval, and string.
Referenced by box(), box_more(), check_exception(), convert_to_string(), find_octave_class(), get_invoke_list(), octave_java::init(), Java_org_octave_Octave_call(), Java_org_octave_Octave_doEvalString(), and jstring_to_string().
|
static |
Definition at line 688 of file ov-java.cc.
References jstring_to_string(), retval, and string.
|
static |
Definition at line 923 of file ov-java.cc.
References check_exception(), e, jint(), k, octave_value_list::length(), idx_vector::length(), retval, and octave::index_exception::set_pos_if_unset().
Referenced by get_array_elements(), and set_array_elements().
|
static |
Definition at line 366 of file ov-java.cc.
References octave::sys::base_file_stat::fail, fs, octave::directory_path::path_sep_str(), string, and octave::sys::file_ops::tilde_expand().
Referenced by initial_class_path().
|
static |
Definition at line 987 of file ov-java.cc.
References box(), check_exception(), find_octave_class(), make_java_index(), octave_set_default_fpucw(), retval, and unbox().
Referenced by octave_java::subsasgn().
|
static |
Definition at line 653 of file ov-java.cc.
References octave::dynamic_library::close(), jvm, and octave_set_default_fpucw().
Referenced by F__java_exit__().
|
inlinestatic |
Definition at line 707 of file ov-java.cc.
References jvm.
Referenced by octave_java::convert_to_str_internal(), octave_java::dims(), octave_java::do_java_get(), octave_java::do_java_set(), octave_java::do_javaMethod(), octave_java::do_javaObject(), octave_java::init(), initialize_java(), octave_java::is_instance_of(), octave_java::is_java_string(), java_event_hook(), octave_java::map_keys(), octave_java::release(), octave_java::subsasgn(), and octave_java::subsref().
|
static |
Definition at line 1487 of file ov-java.cc.
References array(), octave_value::array_value(), octave_value::cellstr_value(), octave_value::class_name(), octave_value::columns(), java_local_ref< T >::detach(), dims, octave_value::dims(), dv, error(), find_octave_class(), Array< T >::fortran_vec(), found, int16, int32, octave_value::int32_array_value(), int64, octave_value::int8_array_value(), octave_value::is_bool_scalar(), octave_value::is_bool_type(), octave_value::is_cellstr(), octave_value::is_double_type(), octave_value::is_empty(), octave_value::is_float_type(), octave_value::is_int16_type(), octave_value::is_int32_type(), octave_value::is_int64_type(), octave_value::is_int8_type(), octave_value::is_java(), octave_value::is_matrix_type(), octave_value::is_range(), octave_value::is_real_matrix(), octave_value::is_real_scalar(), octave_value::is_real_type(), octave_value::is_string(), octave_value::is_uint16_type(), octave_value::is_uint32_type(), octave_value::is_uint64_type(), octave_value::is_uint8_type(), dim_vector::is_vector(), jint(), m, octave_value::matrix_value(), dim_vector::ndims(), Array< T >::numel(), octave_value::numel(), octave_value::rows(), s, string, octave_value::string_value(), octave_java::to_java(), TO_JAVA, TO_JOBJECT, uint16, uint32, octave_value::uint8_array_value(), UNBOX_PRIMITIVE_ARRAY, UNBOX_PRIMITIVE_SCALAR, and val.
Referenced by octave_java::do_java_set(), octave_java::do_javaMethod(), octave_java::do_javaObject(), Java_org_octave_Octave_call(), set_array_elements(), and unbox().
|
static |
Definition at line 1712 of file ov-java.cc.
References found, octave_value_list::length(), and unbox().
|
static |
Definition at line 170 of file ov-java.cc.
Referenced by initialize_java(), initialize_jvm(), terminate_jvm(), and thread_jni_env().
Definition at line 171 of file ov-java.cc.
|
static |
Definition at line 174 of file ov-java.cc.
|
static |
Definition at line 176 of file ov-java.cc.
Definition at line 2837 of file ov-java.cc.
Referenced by octave_classdef::get_object(), octave_classdef::get_object_ref(), and jit_convert::resolve().
|
static |
Definition at line 178 of file ov-java.cc.
|
static |
Definition at line 177 of file ov-java.cc.
|
static |
Definition at line 179 of file ov-java.cc.
Referenced by initialize_java(), and Java_org_octave_Octave_needThreadedInvokation().
Definition at line 183 of file ov-java.cc.
Referenced by octave::JVMArgs::read_java_opts().
Definition at line 181 of file ov-java.cc.
bool Vjava_unsigned_autoconversion = true |
Definition at line 182 of file ov-java.cc.