28 #if defined (HAVE_CONFIG_H) 32 #if defined (HAVE_WINDOWS_H) 46 #include "builtin-defun-decls.h" 62 #if defined (HAVE_JAVA) 66 #if defined (HAVE_JAVA) 68 #define TO_JOBJECT(obj) reinterpret_cast<jobject> (obj) 69 #define TO_JCLASS(obj) reinterpret_cast<jclass> (obj) 71 #define TO_JNIENV(env) reinterpret_cast<JNIEnv *> (env) 144 box (JNIEnv *jni_env,
void *jobj,
void *jcls_arg =
nullptr);
147 box_more (JNIEnv *jni_env,
void *jobj_arg,
void *jcls_arg =
nullptr);
159 JNIEXPORT jboolean JNICALL
163 JNIEXPORT
void JNICALL
166 JNIEXPORT
void JNICALL
169 JNIEXPORT
void JNICALL
172 JNIEXPORT jboolean JNICALL
179 static JavaVM *
jvm =
nullptr;
216 vm_args.version = JNI_VERSION_1_6;
219 vm_args.ignoreUnrecognized =
false;
240 std::ifstream js (
filename.c_str ());
242 if (! js.bad () && ! js.fail ())
246 while (! js.eof () && ! js.fail ())
248 std::getline (js,
line);
250 if (
line.find (
'-') == 0)
253 std::cerr <<
"invalid JVM option, skipping: " <<
line 263 if (
vm_args.options !=
nullptr)
266 delete []
vm_args.options[
i].optionString;
289 std::cout << opt << std::endl;
330 if (java_dir.empty ())
334 if (java_dir.empty ())
361 std::ifstream
fs (filepath.c_str ());
370 if (
line.length () > 0 &&
line[0] !=
'#' &&
line[0] !=
'%')
376 int last =
line.find_last_not_of (
" \t\f\v\r\n");
417 std::string jar_file = java_dir + sep +
"octave.jar";
437 std::vector<std::string> cp_list = {
"javaclasspath.txt",
452 retval.append (classpath);
466 retval.append (classpath);
474 cp_file = java_dir + sep +
filename;
480 retval.append (classpath);
486 error (
"octave.jar does not exist: %s", jar_file.c_str ());
489 error (
"initial java dir is empty");
494 #if defined (OCTAVE_USE_WINDOWS_API) 497 get_regkey_value (HKEY h_rootkey,
const std::string subkey,
535 const char *static_locale = setlocale (LC_ALL,
nullptr);
539 std::string jvm_lib_path =
"linked in or loaded libraries";
543 (lib.
search (
"JNI_CreateJavaVM"));
545 (lib.
search (
"JNI_GetCreatedJavaVMs"));
547 if (! create_vm || ! get_vm)
549 #if defined (OCTAVE_USE_WINDOWS_API) 555 key = R
"(software\javasoft\jre)"; 560 if (jversion.empty ())
562 value =
"CurrentVersion";
563 retval = get_regkey_value (HKEY_LOCAL_MACHINE, key,
value, regval);
565 if (
retval != ERROR_SUCCESS)
568 key = R
"(software\javasoft\java runtime environment)"; 569 retval = get_regkey_value (HKEY_LOCAL_MACHINE, key, value, 573 if (
retval != ERROR_SUCCESS)
574 error (
"unable to find Java Runtime Environment: %s::%s",
575 key.c_str (),
value.c_str ());
578 "initialize_jvm: registry value \"%s\" at \"%s\" must be a string",
579 value.c_str (), key.c_str ());
582 key = key +
'\\' + jversion;
583 value =
"RuntimeLib";
584 retval = get_regkey_value (HKEY_LOCAL_MACHINE, key,
value, regval);
585 if (
retval != ERROR_SUCCESS)
588 key = R
"(software\javasoft\java runtime environment\)" + jversion; 589 retval = get_regkey_value (HKEY_LOCAL_MACHINE, key, value, regval); 592 if (
retval != ERROR_SUCCESS)
593 error (
"unable to find Java Runtime Environment: %s::%s",
594 key.c_str (),
value.c_str ());
597 "initialize_jvm: registry value \"%s\" at \"%s\" must be a string",
598 value.c_str (), key.c_str ());
600 if (jvm_lib_path.empty ())
601 error (
"unable to find Java Runtime Environment: %s::%s",
602 key.c_str (),
value.c_str ());
605 # if defined (__APPLE__) 606 jvm_lib_path = JAVA_LDPATH +
std::string (
"/libjvm.dylib");
608 jvm_lib_path = JAVA_LDPATH +
std::string (
"/libjvm.so");
614 error (
"unable to load Java Runtime Environment from %s",
615 jvm_lib_path.c_str ());
618 (lib.
search (
"JNI_CreateJavaVM"));
620 (lib.
search (
"JNI_GetCreatedJavaVMs"));
623 error (
"unable to find JNI_CreateJavaVM in %s", jvm_lib_path.c_str ());
626 error (
"unable to find JNI_GetCreatedJavaVMs in %s",
627 jvm_lib_path.c_str ());
633 if (get_vm (&
jvm, 1, &nVMs) == 0 && nVMs > 0)
637 switch (
jvm->GetEnv (reinterpret_cast<void **> (¤t_env),
642 JavaVMAttachArgs vm_args;
643 vm_args.version = JNI_VERSION_1_6;
644 vm_args.name =
const_cast<char *
> (
"octave");
645 vm_args.group =
nullptr;
646 if (
jvm->AttachCurrentThread (reinterpret_cast<void **> (¤t_env),
648 error (
"JVM internal error, unable to attach octave to existing JVM");
652 error (
"JVM internal error, the required JNI version is not supported");
670 vm_args.
add (
"-Djava.system.class.loader=org.octave.OctClassLoader");
671 vm_args.
add (
"-Xrs");
678 if (create_vm (&
jvm, ¤t_env, vm_args.
to_args ()) != JNI_OK)
679 error (
"unable to start Java VM in %s", jvm_lib_path.c_str ());
684 setlocale (LC_ALL, locale.c_str ());
702 jvm->DetachCurrentThread ();
704 jvm->DestroyJavaVM ();
725 const char *cstr = jni_env->GetStringUTFChars (
s,
nullptr);
727 jni_env->ReleaseStringUTFChars (
s, cstr);
740 jclass_ref cls (jni_env, jni_env->FindClass (
"java/lang/String"));
743 if (jni_env->IsInstanceOf (obj, cls))
745 reinterpret_cast<jstring> (obj));
758 static inline JNIEnv *
761 JNIEnv *env =
nullptr;
764 jvm->GetEnv (reinterpret_cast<void **> (&env), JNI_VERSION_1_6);
774 #if defined (HAVE_JAVA) 780 jclass_ref cls (current_env, current_env->FindClass (
"java/lang/String"));
799 #if defined (HAVE_JAVA) 804 std::replace (cls_cpp.begin (), cls_cpp.end (),
'.',
'/');
808 jclass_ref cls (current_env, current_env->FindClass (cls_cpp.c_str ()));
809 if (current_env->ExceptionCheck ())
810 current_env->ExceptionClear ();
818 octave_unused_parameter (cls_name);
828 #if defined (HAVE_JAVA) 840 jni_env->ExceptionDescribe ();
842 jni_env->ExceptionClear ();
844 jclass_ref jcls (jni_env, jni_env->GetObjectClass (ex));
845 jmethodID mID = jni_env->GetMethodID (jcls,
"toString",
846 "()Ljava/lang/String;");
848 reinterpret_cast<jstring> (jni_env->CallObjectMethod (ex,
852 error (
"[java] %s", msg.c_str ());
864 static jclass uiClass =
nullptr;
866 jclass jcls = jni_env->FindClass (
name);
870 jni_env->ExceptionClear ();
874 if (class_loader.empty ())
877 jni_env->FindClass (
"java/lang/System"));
878 jmethodID mID = jni_env->GetStaticMethodID
881 "(Ljava/lang/String;)Ljava/lang/String;");
883 jni_env->NewStringUTF (
"octave.class.loader"));
884 js =
reinterpret_cast<jstring
> (jni_env->CallStaticObjectMethod
885 (syscls, mID, jstring (js)));
887 std::replace (class_loader.begin (), class_loader.end (),
892 jni_env->FindClass (class_loader.c_str ()));
896 jni_env->ExceptionClear ();
899 std::replace (class_loader.begin (), class_loader.end (),
902 jni_env->FindClass (
"org/openide/util/Lookup"));
903 jmethodID mID = jni_env->GetStaticMethodID
904 (jcls2,
"getDefault",
"()Lorg/openide/util/Lookup;");
906 jni_env->CallStaticObjectMethod (jcls2, mID));
907 mID = jni_env->GetMethodID (jcls2,
"lookup",
908 "(Ljava/lang/Class;)Ljava/lang/Object;");
910 jni_env->FindClass (
"java/lang/ClassLoader"));
912 jni_env->CallObjectMethod
913 (lObj, mID, jclass (cLoaderCls)));
914 mID = jni_env->GetMethodID (cLoaderCls,
"loadClass",
915 "(Ljava/lang/String;)Ljava/lang/Class;");
917 jni_env->NewStringUTF (class_loader.c_str ()));
918 uicls =
reinterpret_cast<jclass
> 919 (jni_env->CallObjectMethod (cLoader, mID, jstring (js)));
923 uiClass =
reinterpret_cast<jclass
> 924 (jni_env->NewGlobalRef (jclass (uicls)));
929 jmethodID mID = jni_env->GetStaticMethodID
930 (uiClass,
"findClass",
"(Ljava/lang/String;)Ljava/lang/Class;");
932 jcls =
reinterpret_cast<jclass
> 933 (jni_env->CallStaticObjectMethod (uiClass, mID, jstring (js)));
944 jclass_ref jcls (jni_env, jni_env->GetObjectClass (obj));
945 jclass_ref ccls (jni_env, jni_env->GetObjectClass (jcls));
946 jmethodID isArray_ID = jni_env->GetMethodID (ccls,
"isArray",
"()Z");
947 jmethodID getComponentType_ID = jni_env->GetMethodID (ccls,
949 "()Ljava/lang/Class;");
955 while (jcls && jni_env->CallBooleanMethod (jcls, isArray_ID))
957 int len = (jobj ? jni_env->GetArrayLength (jobj) : 0);
961 jcls =
reinterpret_cast<jclass
> 962 (jni_env->CallObjectMethod (jcls, getComponentType_ID));
964 ?
reinterpret_cast<jobjectArray
> (jni_env->GetObjectArrayElement (jobj,
978 jclass_ref ocls (jni_env, jni_env->FindClass (
"[I"));
979 jobjectArray
retval = jni_env->NewObjectArray (idx.
length (), ocls,
nullptr);
989 jint *buf = jni_env->GetIntArrayElements (i_array,
nullptr);
997 jni_env->ReleaseIntArrayElements (i_array, buf, 0);
998 jni_env->SetObjectArrayElement (
retval,
i, i_array);
1005 e.set_pos_if_unset (idx.
length (),
i + 1);
1022 "org/octave/ClassHelper"));
1023 jmethodID mID = jni_env
1024 ->GetStaticMethodID (helperClass,
"arraySubsref",
1025 "(Ljava/lang/Object;[[I)Ljava/lang/Object;");
1026 resObj = jni_env->CallStaticObjectMethod
1027 (helperClass, mID, jobj, jobject (java_idx));
1040 set_array_elements (JNIEnv *jni_env, jobject jobj,
1050 if (
unbox (jni_env, rhs, rhsObj, rhsCls))
1054 "org/octave/ClassHelper"));
1055 jmethodID mID = jni_env->GetStaticMethodID (helperClass,
"arraySubsasgn",
1056 "(Ljava/lang/Object;[[ILjava/lang/Object;)" "Ljava/lang/Object;");
1057 resObj = jni_env->CallStaticObjectMethod
1058 (helperClass, mID, jobj, jobject (java_idx), jobject (rhsObj));
1072 get_invoke_list (JNIEnv *jni_env,
void *jobj_arg)
1076 std::list<std::string> name_list;
1080 jclass_ref cls (jni_env, jni_env->GetObjectClass (jobj));
1081 jclass_ref ccls (jni_env, jni_env->GetObjectClass (cls));
1082 jmethodID getMethods_ID = jni_env->GetMethodID
1083 (ccls,
"getMethods",
"()[Ljava/lang/reflect/Method;");
1084 jmethodID getFields_ID = jni_env->GetMethodID
1085 (ccls,
"getFields",
"()[Ljava/lang/reflect/Field;");
1087 reinterpret_cast<jobjectArray>
1088 (jni_env->CallObjectMethod (cls, getMethods_ID)));
1090 reinterpret_cast<jobjectArray>
1091 (jni_env->CallObjectMethod (cls, getFields_ID)));
1092 int mLen = jni_env->GetArrayLength (mList);
1093 int fLen = jni_env->GetArrayLength (fList);
1095 jni_env->FindClass (
"java/lang/reflect/Method"));
1097 jni_env->FindClass (
"java/lang/reflect/Field"));
1098 jmethodID m_getName_ID = jni_env->GetMethodID (mCls,
"getName",
1099 "()Ljava/lang/String;");
1100 jmethodID f_getName_ID = jni_env->GetMethodID (fCls,
"getName",
1101 "()Ljava/lang/String;");
1103 for (
int i = 0;
i < mLen;
i++)
1105 jobject_ref meth (jni_env, jni_env->GetObjectArrayElement (mList,
i));
1106 jstring_ref methName (jni_env, reinterpret_cast<jstring>
1107 (jni_env->CallObjectMethod (meth,
1112 for (
int i = 0;
i < fLen;
i++)
1115 jni_env->GetObjectArrayElement (fList,
i));
1117 reinterpret_cast<jstring>
1118 (jni_env->CallObjectMethod
1119 (field, f_getName_ID)));
1128 return v.sort (
true);
1132 convert_to_string (JNIEnv *jni_env, jobject java_object,
bool force,
char type)
1136 if (jni_env && java_object)
1138 jclass_ref cls (jni_env, jni_env->FindClass (
"java/lang/String"));
1140 if (jni_env->IsInstanceOf (java_object, cls))
1144 cls = jni_env->FindClass (
"[Ljava/lang/String;");
1146 if (jni_env->IsInstanceOf (java_object, cls))
1148 jobjectArray
array =
reinterpret_cast<jobjectArray
> (java_object);
1149 int len = jni_env->GetArrayLength (
array);
1152 for (
int i = 0;
i < len;
i++)
1155 reinterpret_cast<jstring>
1156 (jni_env->GetObjectArrayElement (
array,
i)));
1168 cls = jni_env->FindClass (
"java/lang/Object");
1169 jmethodID mID = jni_env->GetMethodID (cls,
"toString",
1170 "()Ljava/lang/String;");
1172 reinterpret_cast<jstring>
1173 (jni_env->CallObjectMethod (java_object,
1183 error (
"unable to convert Java object to string");
1191 #define TO_JAVA(obj) dynamic_cast<octave_java *> ((obj).internal_rep ()) 1204 is_auto_convertible_number (JNIEnv *jni_env, jobject jobj)
1207 cls = jni_env->FindClass (
"java/lang/Double");
1208 if (jni_env->IsInstanceOf (jobj, cls))
1210 cls = jni_env->FindClass (
"java/lang/Float");
1211 if (jni_env->IsInstanceOf (jobj, cls))
1213 cls = jni_env->FindClass (
"java/lang/Byte");
1214 if (jni_env->IsInstanceOf (jobj, cls))
1216 cls = jni_env->FindClass (
"java/lang/Short");
1217 if (jni_env->IsInstanceOf (jobj, cls))
1219 cls = jni_env->FindClass (
"java/lang/Integer");
1220 if (jni_env->IsInstanceOf (jobj, cls))
1222 cls = jni_env->FindClass (
"java/lang/Long");
1223 if (jni_env->IsInstanceOf (jobj, cls))
1250 box (JNIEnv *jni_env,
void *jobj_arg,
void *jcls_arg)
1267 cls = jni_env->FindClass (
"java/lang/Number");
1268 if (jni_env->IsInstanceOf (jobj, cls)
1269 && is_auto_convertible_number (jni_env, jobj))
1271 jmethodID m = jni_env->GetMethodID (cls,
"doubleValue",
"()D");
1272 retval = jni_env->CallDoubleMethod (jobj, m);
1276 cls = jni_env->FindClass (
"java/lang/Boolean");
1277 if (jni_env->IsInstanceOf (jobj, cls))
1279 jmethodID m = jni_env->GetMethodID (cls,
"booleanValue",
"()Z");
1280 retval = (jni_env->CallBooleanMethod (jobj, m) ? true :
false);
1284 cls = jni_env->FindClass (
"java/lang/String");
1285 if (jni_env->IsInstanceOf (jobj, cls))
1291 cls = jni_env->FindClass (
"java/lang/Character");
1292 if (jni_env->IsInstanceOf (jobj, cls))
1294 jmethodID m = jni_env->GetMethodID (cls,
"charValue",
"()C");
1295 retval = jni_env->CallCharMethod (jobj, m);
1300 #define BOX_PRIMITIVE_ARRAY(JAVA_TYPE, JAVA_ID, JAVA_TYPE_CAP, OCTAVE_ID) \ 1301 cls = jni_env->FindClass (JAVA_ID); \ 1302 if (jni_env->IsInstanceOf (jobj, cls)) \ 1304 const JAVA_TYPE ## Array jarr = reinterpret_cast<JAVA_TYPE ## Array> (jobj); \ 1305 const jsize len = jni_env->GetArrayLength (jarr); \ 1306 OCTAVE_ID ## NDArray d (dim_vector (len, 1)); \ 1307 JAVA_TYPE *buffer = reinterpret_cast<JAVA_TYPE *> (d.fortran_vec ()); \ 1308 jni_env->Get ## JAVA_TYPE_CAP ## ArrayRegion (jarr, 0, len, buffer); \ 1322 #undef BOX_PRIMITIVE_ARRAY 1328 if (jni_env->IsInstanceOf (jobj, cls))
1330 jmethodID mID = jni_env->GetMethodID (cls,
"getDims",
"()[I");
1332 reinterpret_cast<jintArray>
1333 (jni_env->CallObjectMethod (jobj, mID)));
1334 jint *iv_data = jni_env->GetIntArrayElements (jintArray (iv),
1337 dims.resize (jni_env->GetArrayLength (jintArray (iv)));
1339 for (
int i = 0;
i <
dims.ndims ();
i++)
1342 jni_env->ReleaseIntArrayElements (jintArray (iv), iv_data, 0);
1343 mID = jni_env->GetMethodID (cls,
"getClassName",
1344 "()Ljava/lang/String;");
1346 reinterpret_cast<jstring>
1347 (jni_env->CallObjectMethod (jobj, mID)));
1354 mID = jni_env->GetMethodID (cls,
"toDouble",
"()[D");
1356 reinterpret_cast<jdoubleArray>
1357 (jni_env->CallObjectMethod (jobj,
1359 jni_env->GetDoubleArrayRegion (
dv, 0, m.
numel (),
1364 else if (
s ==
"byte")
1369 mID = jni_env->GetMethodID (cls,
"toByte",
"()[B");
1371 reinterpret_cast<jbyteArray>
1372 (jni_env->CallObjectMethod (jobj,
1374 jni_env->GetByteArrayRegion (
dv, 0, m.
numel (),
1375 reinterpret_cast<jbyte *
> 1376 (m.fortran_vec ()));
1383 mID = jni_env->GetMethodID (cls,
"toByte",
"()[B");
1385 reinterpret_cast<jbyteArray>
1386 (jni_env->CallObjectMethod (jobj,
1388 jni_env->GetByteArrayRegion (
dv, 0, m.
numel (),
1389 reinterpret_cast<jbyte *
> 1390 (m.fortran_vec ()));
1395 else if (
s ==
"integer")
1400 mID = jni_env->GetMethodID (cls,
"toInt",
"()[I");
1402 reinterpret_cast<jintArray>
1403 (jni_env->CallObjectMethod (jobj,
1405 jni_env->GetIntArrayRegion (
dv, 0, m.
numel (),
1406 reinterpret_cast<jint *
> 1407 (m.fortran_vec ()));
1414 mID = jni_env->GetMethodID (cls,
"toInt",
"()[I");
1416 reinterpret_cast<jintArray>
1417 (jni_env->CallObjectMethod (jobj,
1419 jni_env->GetIntArrayRegion (
dv, 0, m.
numel (),
1420 reinterpret_cast<jint *
> 1421 (m.fortran_vec ()));
1430 if (jni_env->IsInstanceOf (jobj, cls))
1432 jmethodID mID = jni_env->GetMethodID (cls,
"getID",
"()I");
1433 int ID = jni_env->CallIntMethod (jobj, mID);
1434 std::map<int,octave_value>::iterator it =
octave_ref_map.find (ID);
1450 box_more (JNIEnv *jni_env,
void *jobj_arg,
void *jcls_arg)
1465 cls = jni_env->FindClass (
"[D");
1467 if (jni_env->IsInstanceOf (jobj, cls))
1469 jdoubleArray jarr =
reinterpret_cast<jdoubleArray
> (jobj);
1470 int len = jni_env->GetArrayLength (jarr);
1475 jni_env->GetDoubleArrayRegion (jarr, 0, len,
1486 cls = jni_env->FindClass (
"[[D");
1488 if (jni_env->IsInstanceOf (jobj, cls))
1490 jobjectArray jarr =
reinterpret_cast<jobjectArray
> (jobj);
1491 int rows = jni_env->GetArrayLength (jarr);
1498 for (
int r = 0; r < rows; r++)
1501 reinterpret_cast<jdoubleArray>
1502 (jni_env->GetObjectArrayElement
1507 cols = jni_env->GetArrayLength (
row);
1510 jni_env->GetDoubleArrayRegion
1522 cls = jni_env->FindClass (
"[Ljava/lang/String;");
1524 if (jni_env->IsInstanceOf (jobj, cls))
1526 jobjectArray jarr =
reinterpret_cast<jobjectArray
> (jobj);
1527 int len = jni_env->GetArrayLength (jarr);
1530 for (
int i = 0;
i < len;
i++)
1533 reinterpret_cast<jstring>
1534 (jni_env->GetObjectArrayElement (jarr,
i)));
1562 jcls = jni_env->GetObjectClass (jobj);
1564 else if (
val.is_string ())
1568 jobj = jni_env->NewStringUTF (
s.c_str ());
1569 jcls = jni_env->GetObjectClass (jobj);
1571 else if (
val.iscellstr ())
1576 jclass_ref scls (jni_env, jni_env->FindClass (
"java/lang/String"));
1577 jobjectArray
array = jni_env->NewObjectArray (n, scls,
nullptr);
1582 (str_arr(
i).c_str ()));
1583 jni_env->SetObjectArrayElement (
array,
i, jstr);
1587 jcls = jni_env->GetObjectClass (jobj);
1589 else if (
val.numel () > 1 &&
val.dims ().isvector ())
1594 #define UNBOX_PRIMITIVE_ARRAY(METHOD_T, OCTAVE_T, JAVA_T, JAVA_T_CAP) \ 1597 const OCTAVE_T ## NDArray v = val.METHOD_T ## array_value (); \ 1598 JAVA_T ## Array jarr = jni_env->New ## JAVA_T_CAP ## Array (v.numel ()); \ 1599 const JAVA_T *jv = reinterpret_cast<const JAVA_T *> (v.data ()); \ 1600 jni_env->Set ## JAVA_T_CAP ## ArrayRegion (jarr, 0, v.numel (), jv); \ 1601 jobj = reinterpret_cast<jobject> (jarr); \ 1602 jcls = jni_env->GetObjectClass (jobj); \ 1609 if (
val.is_double_type ())
1611 else if (
val.islogical ())
1613 else if (
val.isfloat ())
1615 else if (
val.is_int8_type ())
1617 else if (
val.is_uint8_type ())
1619 else if (
val.is_int16_type ())
1621 else if (
val.is_uint16_type ())
1623 else if (
val.is_int32_type ())
1625 else if (
val.is_uint32_type ())
1627 else if (
val.is_int64_type ())
1629 else if (
val.is_uint64_type ())
1632 #undef UNBOX_PRIMITIVE_ARRAY 1634 else if (
val.is_real_scalar () ||
val.is_bool_scalar ())
1639 #define UNBOX_PRIMITIVE_SCALAR(OCTAVE_T, METHOD_T, JAVA_T, JAVA_CON) \ 1642 const OCTAVE_T ov = val.METHOD_T ## _value (); \ 1643 jclass_ref dcls (jni_env, jni_env->FindClass (JAVA_T)); \ 1644 const jfieldID fid = jni_env->GetStaticFieldID (dcls, "TYPE", "Ljava/lang/Class;"); \ 1645 const jmethodID mid = jni_env->GetMethodID (dcls, "<init>", JAVA_CON); \ 1646 jcls = reinterpret_cast<jclass> (jni_env->GetStaticObjectField (dcls, fid)); \ 1647 jobj = jni_env->NewObject (dcls, mid, ov); \ 1651 if (
val.is_double_type ())
1653 else if (
val.islogical ())
1655 else if (
val.isfloat ())
1657 else if (
val.is_int8_type ())
1659 else if (
val.is_uint8_type ())
1661 else if (
val.is_int16_type ())
1663 else if (
val.is_uint16_type ())
1665 else if (
val.is_int32_type ())
1667 else if (
val.is_uint32_type ())
1669 else if (
val.is_int64_type ())
1671 else if (
val.is_uint64_type ())
1674 #undef UNBOX_PRIMITIVE_SCALAR 1676 else if (
val.isempty ())
1683 && ((
val.is_real_matrix ()
1684 && (
val.rows () == 1 ||
val.columns () == 1))
1685 ||
val.is_range ()))
1688 jdoubleArray
dv = jni_env->NewDoubleArray (m.
numel ());
1691 jcls = jni_env->GetObjectClass (jobj);
1694 && (
val.is_matrix_type () ||
val.is_range ())
1698 "org/octave/Matrix"));
1701 jint *iv_data = jni_env->GetIntArrayElements (jintArray (iv),
nullptr);
1703 for (
int i = 0;
i <
dims.ndims ();
i++)
1706 jni_env->ReleaseIntArrayElements (jintArray (iv), iv_data, 0);
1708 if (
val.is_double_type ())
1712 jni_env->SetDoubleArrayRegion (jdoubleArray (
dv), 0, m.
numel (),
1714 jmethodID mID = jni_env->GetMethodID (mcls,
"<init>",
"([D[I)V");
1715 jobj = jni_env->NewObject (jclass (mcls), mID, jdoubleArray (
dv),
1717 jcls = jni_env->GetObjectClass (jobj);
1719 else if (
val.is_int8_type ())
1723 jni_env->SetByteArrayRegion (jbyteArray (bv), 0, m.
numel (),
1724 reinterpret_cast<jbyte *
> 1726 jmethodID mID = jni_env->GetMethodID (mcls,
"<init>",
"([B[I)V");
1727 jobj = jni_env->NewObject
1728 (jclass (mcls), mID, jbyteArray (bv), jintArray (iv));
1729 jcls = jni_env->GetObjectClass (jobj);
1731 else if (
val.is_uint8_type ())
1735 jni_env->SetByteArrayRegion (jbyteArray (bv), 0, m.
numel (),
1736 reinterpret_cast<jbyte *
> 1738 jmethodID mID = jni_env->GetMethodID (mcls,
"<init>",
"([B[I)V");
1739 jobj = jni_env->NewObject
1740 (jclass (mcls), mID, jbyteArray (bv), jintArray (iv));
1741 jcls = jni_env->GetObjectClass (jobj);
1743 else if (
val.is_int32_type ())
1747 jni_env->SetIntArrayRegion (jintArray (v), 0, m.
numel (),
1748 reinterpret_cast<jint *
> 1750 jmethodID mID = jni_env->GetMethodID (mcls,
"<init>",
"([I[I)V");
1751 jobj = jni_env->NewObject
1752 (jclass (mcls), mID, jintArray (v), jintArray (iv));
1753 jcls = jni_env->GetObjectClass (jobj);
1758 error (
"cannot convert matrix of type '%s'",
1759 val.class_name ().c_str ());
1765 jmethodID mID = jni_env->GetMethodID (rcls,
"<init>",
"(I)V");
1768 jobj = jni_env->NewObject (rcls, mID, ID);
1782 jclass_ref ocls (jni_env, jni_env->FindClass (
"java/lang/Object"));
1783 jclass_ref ccls (jni_env, jni_env->FindClass (
"java/lang/Class"));
1786 jobjs = jni_env->NewObjectArray (args.
length (), ocls,
nullptr);
1789 jclss = jni_env->NewObjectArray (args.
length (), ccls,
nullptr);
1791 for (
int i = 0;
i < args.
length ();
i++)
1800 jni_env->SetObjectArrayElement (jobjs,
i, jobj);
1801 jni_env->SetObjectArrayElement (jclss,
i, jcls);
1815 get_current_thread_ID (JNIEnv *jni_env)
1820 jclass_ref cls (jni_env, jni_env->FindClass (
"java/lang/Thread"));
1821 jmethodID mID = jni_env->GetStaticMethodID (cls,
"currentThread",
1822 "()Ljava/lang/Thread;");
1823 jobject_ref jthread (jni_env, jni_env->CallStaticObjectMethod (cls, mID));
1828 jclass_ref jth_cls (jni_env, jni_env->GetObjectClass (jthread));
1829 mID = jni_env->GetMethodID (jth_cls,
"getId",
"()J");
1830 long result = jni_env->CallLongMethod (jthread, mID);
1843 java_event_hook (
void)
1851 "org/octave/Octave"));
1852 jmethodID mID = current_env->GetStaticMethodID
1853 (cls,
"checkPendingAction",
"()V");
1854 current_env->CallStaticVoidMethod (cls, mID);
1870 initialize_java (
void)
1886 error (msg.c_str ());
1893 JNIEXPORT jboolean JNICALL
1895 jobjectArray argin, jobjectArray argout)
1899 int nargout = env->GetArrayLength (argout);
1900 int nargin = env->GetArrayLength (argin);
1905 varargin(
i) =
box (env, env->GetObjectArrayElement (argin,
i),
nullptr);
1911 return unbox (env, varargout, out_objs, out_clss);
1914 JNIEXPORT
void JNICALL
1920 JNIEXPORT
void JNICALL
1924 std::map<int,octave_value>::iterator it =
octave_ref_map.find (ID);
1929 int len = env->GetArrayLength (args);
1932 for (
int i = 0;
i < len;
i++)
1934 jobject_ref jobj (env, env->GetObjectArrayElement (args,
i));
1935 oct_args(
i) =
box (env, jobj,
nullptr);
1938 BEGIN_INTERRUPT_WITH_EXCEPTIONS;
1940 if (
val.is_function_handle ())
1945 else if (
val.iscell () &&
val.length () > 0
1946 && (
val.rows () == 1 ||
val.columns () == 1)
1947 &&
val.cell_value()(0).is_function_handle ())
1952 for (
int i=1;
i<
c.numel ();
i++)
1953 oct_args(len+
i-1) =
c(
i);
1958 error (
"trying to invoke non-invocable object");
1960 END_INTERRUPT_WITH_EXCEPTIONS;
1964 JNIEXPORT
void JNICALL
1972 JNIEXPORT jboolean JNICALL
1985 #if ! defined (HAVE_JAVA) 1995 #if defined (HAVE_JAVA) 2001 octave_unused_parameter (jobj);
2002 octave_unused_parameter (jcls);
2016 #if defined (HAVE_JAVA) 2023 octave_unused_parameter (ti);
2031 #if defined (HAVE_JAVA) 2052 const std::list<octave_value_list>& idx,
int nargout)
2054 #if defined (HAVE_JAVA) 2064 if (
type.length () > 1 &&
type[1] ==
'(')
2069 ovl(0) = (idx.front ())(0);
2070 std::list<octave_value_list>::const_iterator it = idx.begin ();
2080 ovl(1) = (idx.front ())(0);
2092 error (
"subsref: Java object cannot be indexed with %c",
type[0]);
2096 if (idx.size () > 1 &&
type.length () > 1)
2103 octave_unused_parameter (
type);
2104 octave_unused_parameter (idx);
2105 octave_unused_parameter (
nargout);
2117 const std::list<octave_value_list>& idx,
2120 #if defined (HAVE_JAVA) 2129 if (
type.length () == 1)
2135 ovl(1) = (idx.front ())(0);
2137 F__java_set__ (
ovl);
2142 else if (
type.length () > 2 &&
type[1] ==
'(')
2144 std::list<octave_value_list> new_idx;
2145 std::list<octave_value_list>::const_iterator it = idx.begin ();
2146 new_idx.push_back (*it++);
2147 new_idx.push_back (*it++);
2150 std::list<octave_value_list> next_idx (idx);
2151 next_idx.erase (next_idx.begin ());
2152 next_idx.erase (next_idx.begin ());
2153 u(0).subsasgn (
type.substr (2), next_idx, rhs);
2158 else if (
type[1] ==
'.')
2162 std::list<octave_value_list> next_idx (idx);
2163 next_idx.erase (next_idx.begin ());
2164 u(0).subsasgn (
type.substr (1), next_idx, rhs);
2170 error (
"invalid indexing/assignment on Java object");
2185 error (
"Java object cannot be indexed with %c",
type[0]);
2193 octave_unused_parameter (
type);
2194 octave_unused_parameter (idx);
2195 octave_unused_parameter (rhs);
2208 #if defined (HAVE_JAVA) 2213 return get_invoke_list (current_env,
to_java ());
2230 #if defined (HAVE_JAVA) 2241 octave_unused_parameter (force);
2242 octave_unused_parameter (
type);
2262 os <<
"<Java object: " << java_classname << '>
'; 2265 // FIXME: Need routines to actually save/load java objects through Serialize. 2269 octave_java::save_ascii (std::ostream& /* os */) 2271 warning ("save: unable to save java objects, skipping"); 2277 octave_java::load_ascii (std::istream& /* is */) 2279 // Silently skip over java object that was not saved 2284 octave_java::save_binary (std::ostream& /* os */, bool& /* save_as_floats */) 2286 warning ("save: unable to save java objects, skipping"); 2292 octave_java::load_binary (std::istream& /* is */, bool /* swap*/, 2293 octave::mach_info::float_format /* fmt */) 2295 // Silently skip over java object that was not saved 2300 octave_java::save_hdf5 (octave_hdf5_id /* loc_id */, const char * /* name */, 2301 bool /* save_as_floats */) 2303 warning ("save: unable to save java objects, skipping"); 2309 octave_java::load_hdf5 (octave_hdf5_id /* loc_id */, const char * /* name */) 2311 // Silently skip object that was not saved 2316 octave_java::do_javaMethod (void *jni_env_arg, const std::string& name, 2317 const octave_value_list& args) 2319 #if defined (HAVE_JAVA) 2321 octave_value retval; 2323 JNIEnv *jni_env = TO_JNIENV (jni_env_arg); 2327 jobjectArray_ref arg_objs (jni_env), arg_types (jni_env); 2328 if (unbox (jni_env, args, arg_objs, arg_types)) 2330 jclass_ref helperClass (jni_env, find_octave_class (jni_env, "org/octave/ClassHelper")); 2331 jmethodID mID = jni_env->GetStaticMethodID (helperClass, "invokeMethod", 2332 "(Ljava/lang/Object;Ljava/lang/String;[Ljava/lang/Object;[Ljava/lang/Class;)Ljava/lang/Object;"); 2333 jstring_ref methName (jni_env, jni_env->NewStringUTF (name.c_str ())); 2334 jobjectArray_ref resObj (jni_env, reinterpret_cast<jobjectArray> (jni_env->CallStaticObjectMethod (helperClass, mID, 2335 to_java (), jstring (methName), jobjectArray (arg_objs), jobjectArray (arg_types)))); 2337 retval = box (jni_env, resObj); 2339 retval = check_exception (jni_env); 2342 octave_set_default_fpucw (); 2349 octave_unused_parameter (jni_env_arg); 2350 octave_unused_parameter (name); 2351 octave_unused_parameter (args); 2365 #if defined (HAVE_JAVA) 2371 octave_unused_parameter (
name);
2372 octave_unused_parameter (args);
2388 #if defined (HAVE_JAVA) 2392 JNIEnv *jni_env =
TO_JNIENV (jni_env_arg);
2397 if (
unbox (jni_env, args, arg_objs, arg_types))
2401 "org/octave/ClassHelper"));
2402 jmethodID mID = jni_env->GetStaticMethodID (helperClass,
2403 "invokeStaticMethod",
2404 "(Ljava/lang/String;Ljava/lang/String;[Ljava/lang/Object;[Ljava/lang/Class;)Ljava/lang/Object;");
2406 jni_env->NewStringUTF (
name.c_str ()));
2408 jni_env->NewStringUTF (
class_name.c_str ()));
2410 jni_env->CallStaticObjectMethod (helperClass,
2414 jobjectArray (arg_objs),
2415 jobjectArray (arg_types)));
2429 octave_unused_parameter (jni_env_arg);
2431 octave_unused_parameter (
name);
2432 octave_unused_parameter (args);
2447 #if defined (HAVE_JAVA) 2454 octave_unused_parameter (
name);
2455 octave_unused_parameter (args);
2469 #if defined (HAVE_JAVA) 2473 JNIEnv *jni_env =
TO_JNIENV (jni_env_arg);
2479 if (
unbox (jni_env, args, arg_objs, arg_types))
2483 "org/octave/ClassHelper"));
2484 jmethodID mID = jni_env->GetStaticMethodID (helperClass,
2485 "invokeConstructor",
2486 "(Ljava/lang/String;[Ljava/lang/Object;[Ljava/lang/Class;)Ljava/lang/Object;");
2488 jni_env->NewStringUTF (
name.c_str ()));
2490 jni_env->CallStaticObjectMethod (helperClass,
2493 jobjectArray (arg_objs),
2494 jobjectArray (arg_types)));
2509 octave_unused_parameter (jni_env_arg);
2510 octave_unused_parameter (
name);
2511 octave_unused_parameter (args);
2525 #if defined (HAVE_JAVA) 2531 octave_unused_parameter (
name);
2532 octave_unused_parameter (args);
2545 #if defined (HAVE_JAVA) 2549 JNIEnv *jni_env =
TO_JNIENV (jni_env_arg);
2555 "org/octave/ClassHelper"));
2556 jmethodID mID = jni_env->GetStaticMethodID (helperClass,
"getField",
2557 "(Ljava/lang/Object;Ljava/lang/String;)Ljava/lang/Object;");
2560 jni_env->CallStaticObjectMethod (helperClass,
2577 octave_unused_parameter (jni_env_arg);
2578 octave_unused_parameter (
name);
2591 #if defined (HAVE_JAVA) 2597 octave_unused_parameter (
name);
2611 #if defined (HAVE_JAVA) 2615 JNIEnv *jni_env =
TO_JNIENV (jni_env_arg);
2621 "org/octave/ClassHelper"));
2622 jmethodID mID = jni_env->GetStaticMethodID (helperClass,
2624 "(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/Object;");
2628 jni_env->CallStaticObjectMethod (helperClass, mID,
2643 octave_unused_parameter (jni_env_arg);
2645 octave_unused_parameter (
name);
2659 #if defined (HAVE_JAVA) 2666 octave_unused_parameter (
name);
2680 #if defined (HAVE_JAVA) 2684 JNIEnv *jni_env =
TO_JNIENV (jni_env_arg);
2691 if (
unbox (jni_env,
val, jobj, jcls))
2695 "org/octave/ClassHelper"));
2696 jmethodID mID = jni_env->GetStaticMethodID (helperClass,
"setField",
2697 "(Ljava/lang/Object;Ljava/lang/String;Ljava/lang/Object;)V");
2699 jni_env->CallStaticObjectMethod (helperClass, mID,
to_java (),
2700 jstring (fName), jobject (jobj));
2711 octave_unused_parameter (jni_env_arg);
2712 octave_unused_parameter (
name);
2713 octave_unused_parameter (
val);
2726 #if defined (HAVE_JAVA) 2732 octave_unused_parameter (
name);
2733 octave_unused_parameter (
val);
2747 #if defined (HAVE_JAVA) 2751 JNIEnv *jni_env =
TO_JNIENV (jni_env_arg);
2758 if (
unbox (jni_env,
val, jobj, jcls))
2762 "org/octave/ClassHelper"));
2763 jmethodID mID = jni_env->GetStaticMethodID (helperClass,
2765 "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/Object;)V");
2767 jni_env->NewStringUTF (
class_name.c_str ()));
2769 jni_env->CallStaticObjectMethod (helperClass, mID, jstring (cName),
2770 jstring (fName), jobject (jobj));
2781 octave_unused_parameter (jni_env_arg);
2783 octave_unused_parameter (
name);
2784 octave_unused_parameter (
val);
2799 #if defined (HAVE_JAVA) 2806 octave_unused_parameter (
name);
2807 octave_unused_parameter (
val);
2820 #if defined (HAVE_JAVA) 2833 java_class = current_env->NewGlobalRef (jcls);
2838 java_class = current_env->NewGlobalRef (jclass (ocls));
2845 jmethodID mID = current_env->GetMethodID (clsCls,
2847 "()Ljava/lang/String;");
2856 octave_unused_parameter (jobj_arg);
2857 octave_unused_parameter (jcls_arg);
2870 #if defined (HAVE_JAVA) 2899 DEFUN (__java_init__, , ,
2907 #if defined (HAVE_JAVA) 2924 DEFUN (__java_exit__, , ,
2933 #if defined (HAVE_JAVA) 2946 DEFUN (javaObject, args, ,
2966 #if defined (HAVE_JAVA) 2971 std::string classname = args(0).xstring_value (
"javaObject: CLASSNAME must be a string");
2985 octave_unused_parameter (args);
3001 DEFUN (javaMethod, args, ,
3027 #if defined (HAVE_JAVA) 3032 std::string methodname = args(0).xstring_value (
"javaMethod: METHODNAME must be a string");
3044 if (args(1).isjava ())
3049 else if (args(1).is_string ())
3055 error (
"javaMethod: OBJ must be a Java object or a string");
3061 octave_unused_parameter (args);
3080 DEFUN (__java_get__, args, ,
3102 #if defined (HAVE_JAVA) 3107 std::string name = args(1).string_value (
"__java_get__: NAME must be a string");
3115 if (args(0).isjava ())
3120 else if (args(0).is_string ())
3126 error (
"__java_get__: OBJ must be a Java object or a string");
3132 octave_unused_parameter (args);
3139 DEFUN (__java_set__, args, ,
3162 #if defined (HAVE_JAVA) 3167 std::string name = args(1).xstring_value (
"__java_set__: NAME must be a string");
3175 if (args(0).isjava ())
3180 else if (args(0).is_string ())
3186 error (
"__java_set__: OBJ must be a Java object or a string");
3192 octave_unused_parameter (args);
3199 DEFUN (__java2mat__, args, ,
3205 #if defined (HAVE_JAVA) 3216 if (args(0).isjava ())
3228 octave_unused_parameter (args);
3251 #if defined (HAVE_JAVA) 3257 octave_unused_parameter (args);
3258 octave_unused_parameter (
nargout);
3282 #if defined (HAVE_JAVA) 3288 octave_unused_parameter (args);
3289 octave_unused_parameter (
nargout);
3311 #if defined (HAVE_JAVA) 3317 octave_unused_parameter (args);
3318 octave_unused_parameter (
nargout);
3329 DEFUN (isjava, args, ,
3339 return ovl (args(0).isjava ());
void * to_java(void) const
OCTINTERP_API octave_value_list feval(const std::string &name, const octave_value_list &args=octave_value_list(), int nargout=0)
java_local_ref(JNIEnv *_env, T obj)
string_vector map_keys(void) const
static std::string get_current_directory(void)
JNIEXPORT void JNICALL Java_org_octave_Octave_doEvalString(JNIEnv *, jclass, jstring)
static octave_value get_array_elements(JNIEnv *jni_env, jobject jobj, const octave_value_list &idx)
is already an absolute the name is checked against the file system instead of Octave s loadpath In this if otherwise an empty string is returned If the first argument is a cell array of search each directory of the loadpath for element of the cell array and return the first that matches If the second optional argument return a cell array containing the list of all files that have the same name in the path If no files are found
F77_RET_T const F77_INT F77_CMPLX const F77_INT F77_CMPLX * B
void octave_set_default_fpucw(void)
void resize(octave_idx_type nr, octave_idx_type nc, double rfv=0)
#define UNBOX_PRIMITIVE_SCALAR(OCTAVE_T, METHOD_T, JAVA_T, JAVA_CON)
java_local_ref< jclass > jclass_ref
OCTINTERP_API void print_usage(void)
java_local_ref< jstring > jstring_ref
static dim_vector compute_array_dimensions(JNIEnv *jni_env, jobject obj)
identity matrix If supplied two scalar respectively For allows like xample val
void print_raw(std::ostream &os, bool pr_as_read_syntax=false) const
static std::string path_sep_str(void)
void newline(std::ostream &os) const
std::string xstring_value(const char *fmt,...) const
octave_value_list & append(const octave_value &val)
std::string tilde_expand(const std::string &name)
java_local_ref< jbyteArray > jbyteArray_ref
void resize(int n, int fill_value=0)
const T * fortran_vec(void) const
octave_value do_java_set(void *jni_env, const std::string &name, const octave_value &val)
#define DEFUN(name, args_name, nargout_name, doc)
Macro to define a builtin function.
void error(const char *fmt,...)
#define SET_INTERNAL_VARIABLE(NM)
JNIEXPORT jboolean JNICALL Java_org_octave_Octave_call(JNIEnv *, jclass, jstring, jobjectArray, jobjectArray)
static std::string initial_java_dir(void)
The java initialization directory is given by the environment variable OCTAVE_JAVA_DIR if defined; ot...
octave_value subsasgn(const std::string &type, const std::list< octave_value_list > &idx, const octave_value &rhs)
static std::string jstring_to_string(JNIEnv *jni_env, jstring s)
Converts a Java string object to std::string.
void init(void *jobj, void *jcls)
F77_RET_T const F77_INT const F77_INT const F77_INT F77_DBLE const F77_INT F77_DBLE const F77_INT F77_DBLE const F77_INT F77_DBLE * Z
OCTAVE_EXPORT octave_value_list return the number of command line arguments passed to Octave If called with the optional argument the function t
#define BOX_PRIMITIVE_ARRAY(JAVA_TYPE, JAVA_ID, JAVA_TYPE_CAP, OCTAVE_ID)
static octave_value do_javaObject(void *jni_env, const std::string &name, const octave_value_list &args)
nd example oindent opens the file binary numeric values will be read assuming they are stored in IEEE format with the least significant bit and then converted to the native representation Opening a file that is already open simply opens it again and returns a separate file id It is not an error to open a file several though writing to the same file through several different file ids may produce unexpected results The possible values of text mode reading and writing automatically converts linefeeds to the appropriate line end character for the you may append a you must also open the file in binary mode The parameter conversions are currently only supported for and permissions will be set to and then everything is written in a single operation This is very efficient and improves performance c
std::list< std::string > close(void)
static std::string initial_class_path(void)
Return the initial classpath.
static jobject make_java_index(JNIEnv *jni_env, const octave_value_list &idx)
static bool jvm_attached
Whether the current thread is attached to the jvm given by jvm.
static void initialize_jvm(void)
Initialize the java virtual machine (jvm) and field jvm if necessary.
std::string fcn_file_dir(void)
void read_java_opts(const std::string &filename)
std::string dir_sep_str(void)
static std::string getenv(const std::string &name)
JNIEXPORT jboolean JNICALL Java_org_octave_Octave_needThreadedInvokation(JNIEnv *, jclass)
static std::map< int, octave_value > listener_map
then the function must return scalars which will be concatenated into the return array(s). If code
Matrix transpose(void) const
nd deftypefn *std::string name
bool Vjava_matrix_autoconversion
OCTAVE_EXPORT octave_value_list return the number of command line arguments passed to Octave If called with the optional argument the function xample nargout(@histc)
static octave_value box(JNIEnv *jni_env, void *jobj, void *jcls_arg=nullptr)
static std::string get_home_directory(void)
OCTINTERP_API octave_value_list eval_string(const std::string &, bool silent, int &parse_status, int nargout)
static JNIEnv * thread_jni_env(void)
}
std::string class_name(void) const
octave_value do_java_get(void *jni_env, const std::string &name)
bool is_java_string(void) const
static long octave_thread_ID
The thread id of the currently executing thread or -1 if this is unknown.
jint(JNICALL * JNI_CreateJavaVM_t)(JavaVM **pvm, JNIEnv **penv, void *args)
static octave_value box_more(JNIEnv *jni_env, void *jobj_arg, void *jcls_arg=nullptr)
static bool unbox(JNIEnv *jni_env, const octave_value &val, jobject_ref &jobj, jclass_ref &jcls)
octave_value do_javaMethod(void *jni_env, const std::string &name, const octave_value_list &args)
octave_idx_type length(octave_idx_type n=0) const
dim_vector dims(void) const
#define panic_impossible()
JNIEXPORT void JNICALL Java_org_octave_OctaveReference_doFinalize(JNIEnv *, jclass, jint)
static octave_value check_exception(JNIEnv *jni_env)
static void register_type(void)
static int octave_java_refcount
static jclass find_octave_class(JNIEnv *jni_env, const char *name)
static std::string read_classpath_txt(const std::string &filepath)
Return the classpath in the given file filepath as a string.
java_local_ref(JNIEnv *_env)
the exceeded dimensions are set to if fewer subscripts than dimensions are the exceeding dimensions are merged into the final requested dimension For consider the following dims
java_local_ref< jobjectArray > jobjectArray_ref
octave_value convert_to_str_internal(bool pad, bool force, char type) const
octave_value convert_to_str(bool pad=false, bool force=false, char type='\'') const
java_local_ref< jdoubleArray > jdoubleArray_ref
With real return the complex result
bool Vjava_unsigned_autoconversion
friend class octave_value
static const std::string t_name
return octave_value(v1.char_array_value() . concat(v2.char_array_value(), ra_idx),((a1.is_sq_string()||a2.is_sq_string()) ? '\'' :'"'))
std::list< std::string > java_opts
int register_type(const std::string &, const std::string &, const octave_value &, bool abort_on_duplicate=false)
bool is_instance_of(const std::string &) const
JavaVMInitArgs * to_args()
static char * strsave(const char *s)
bool is_undefined(void) const
void print(std::ostream &os, bool pr_as_read_syntax=false)
OCTAVE_EXPORT octave_value_list isa nd deftypefn *return ovl(args(0).isinteger())
octave_idx_type numel(int n=0) const
Number of elements that a matrix with this dimensions would have.
std::string java_classname
#define UNBOX_PRIMITIVE_ARRAY(METHOD_T, OCTAVE_T, JAVA_T, JAVA_T_CAP)
JNIEXPORT void JNICALL Java_org_octave_Octave_doInvoke(JNIEnv *, jclass, jint, jobjectArray)
java_local_ref< jobject > jobject_ref
octave_idx_type length(void) const
defaults to zero A value of zero computes the digamma a value of
java_local_ref< jintArray > jintArray_ref
octave::sys::file_stat fs(filename)
octave::refcount< octave_idx_type > count
octave_value_list subsref(const std::string &type, const std::list< octave_value_list > &idx, int nargout)
static void add_event_hook(event_hook_fcn f)
static std::map< int, octave_value > octave_ref_map
octave_idx_type ndims(void) const
Number of dimensions.
static void terminate_jvm(void)
Terminate the current jvm, if there is any.
void add(const std::string &opt)
octave_idx_type numel(void) const
Number of elements in the array.
write the output to stdout if nargout is
Vector representing the dimensions (size) of an Array.
void err_disabled_feature(const std::string &fcn, const std::string &feature, const std::string &pkg)
static JavaVM * jvm
The pointer to a java virtual machine either created in the current thread or attached this thread to...
If this string is the system will ring the terminal sometimes it is useful to be able to print the original representation of the string
nd group nd example For each display the value
jint(JNICALL * JNI_GetCreatedJavaVMs_t)(JavaVM **pvm, jsize bufLen, jsize *nVMs)
void * search(const std::string &nm, name_mangler mangler=nullptr) const
static octave::dynamic_library jvm_lib
Need to keep hold of the shared library handle until exit.
java_local_ref< jthrowable > jthrowable_ref
octave_value next_subsref(const std::string &type, const std::list< octave_value_list > &idx, size_t skip=1)
where the brackets indicate optional arguments and and character or cell array For character arrays the conversion is repeated for every row
void F(const TSRC *v, TRES *r, octave_idx_type m, octave_idx_type n)