-JNIEXPORT jstring JNICALL Java_org_simantics_pythonlink_PythonContext_getPythonStringVariableImpl(JNIEnv *env, jobject thisObj, jlong contextID, jstring variableName) {
- PyObject *module = (PyObject*)contextID;
-
- PyObject *pythonName = getPythonString(env, variableName);
-
- PyObject *value = PyDict_GetItem(PyModule_GetDict(module), pythonName);
- if (value == NULL) {
- throwPythonException(env, "Python variable not found");
- return 0;
- }
-
- if (!PyUnicode_Check(value)) {
- throwPythonException(env, "Python variable not a string");
- return 0;
- }
-
- {
- jstring result = pythonStringAsJavaString(env, value);
- return result;
- }
-}
-
-JNIEXPORT jobjectArray JNICALL Java_org_simantics_pythonlink_PythonContext_getPythonStringArrayVariableImpl(JNIEnv *env, jobject thisObj, jlong contextID, jstring variableName) {
- PyObject *module = (PyObject*)contextID;
-
- PyObject *pythonName = getPythonString(env, variableName);
-
- PyObject *value = PyDict_GetItem(PyModule_GetDict(module), pythonName);
- if (value == NULL) {
- throwPythonException(env, "Python variable not found");
- return 0;
- }
-
- if (!PySequence_Check(value)) {
- throwPythonException(env, "Python variable not a sequence");
- return 0;
- }
-
- {
- jobjectArray result = pythonSequenceAsStringArray(env, value);
- return result;
- }
-}
-
-JNIEXPORT jboolean JNICALL Java_org_simantics_pythonlink_PythonContext_getPythonBooleanVariableImpl(JNIEnv *env, jobject thisObj, jlong contextID, jstring variableName) {
- PyObject *module = (PyObject*)contextID;
-
- PyObject *pythonName = getPythonString(env, variableName);
-
- PyObject *value = PyDict_GetItem(PyModule_GetDict(module), pythonName);
- if (value == NULL) {
- throwPythonException(env, "Python variable not found");
- return 0;
- }
-
- if (!PyBool_Check(value)) {
- throwPythonException(env, "Python variable not a boolean");
- return 0;
- }
-
- return value == Py_True;
-}
-
-JNIEXPORT jbooleanArray JNICALL Java_org_simantics_pythonlink_PythonContext_getPythonBooleanArrayVariableImpl(JNIEnv *env, jobject thisObj, jlong contextID, jstring variableName) {
- PyObject *module = (PyObject*)contextID;
-
- PyObject *pythonName = getPythonString(env, variableName);
-
- PyObject *value = PyDict_GetItem(PyModule_GetDict(module), pythonName);
- if (value == NULL) {
- throwPythonException(env, "Python variable not found");
- return 0;
- }
-
- if (!PySequence_Check(value)) {
- throwPythonException(env, "Python variable not a sequence");
- return 0;
- }
-
- {
- jbooleanArray result = pythonSequenceAsBooleanArray(env, value);
- return result;
- }
-}
-
-JNIEXPORT jlong JNICALL Java_org_simantics_pythonlink_PythonContext_getPythonLongVariableImpl(JNIEnv *env, jobject thisObj, jlong contextID, jstring variableName) {
- PyObject *module = (PyObject*)contextID;
-
- PyObject *pythonName = getPythonString(env, variableName);
-
- PyObject *value = PyDict_GetItem(PyModule_GetDict(module), pythonName);
- if (value == NULL) {
- throwPythonException(env, "Python variable not found");
- return 0;
- }
-
- if (!PyLong_Check(value)) {
- throwPythonException(env, "Python variable not an integer");
- return 0;
- }
-
- {
- jlong result = PyLong_AsLongLong(value);
- return result;
- }
-}
-
-JNIEXPORT jintArray JNICALL Java_org_simantics_pythonlink_PythonContext_getPythonIntegerArrayVariableImpl(JNIEnv *env, jobject thisObj, jlong contextID, jstring variableName) {
- PyObject *module = (PyObject*)contextID;
-
- PyObject *pythonName = getPythonString(env, variableName);
-
- PyObject *value = PyDict_GetItem(PyModule_GetDict(module), pythonName);
- if (value == NULL) {
- throwPythonException(env, "Python variable not found");
- return NULL;
- }
-
- if (!PySequence_Check(value)) {
- throwPythonException(env, "Python variable not a sequence");
- return NULL;
- }
-
- {
- jintArray result = pythonSequenceAsIntegerArray(env, value);
- return result;
- }
-}
-
-JNIEXPORT jlongArray JNICALL Java_org_simantics_pythonlink_PythonContext_getPythonLongArrayVariableImpl(JNIEnv *env, jobject thisObj, jlong contextID, jstring variableName) {
- PyObject *module = (PyObject*)contextID;
-
- PyObject *pythonName = getPythonString(env, variableName);
-
- PyObject *value = PyDict_GetItem(PyModule_GetDict(module), pythonName);
- if (value == NULL) {
- throwPythonException(env, "Python variable not found");
- return NULL;
- }
-
- if (!PySequence_Check(value)) {
- throwPythonException(env, "Python variable not a sequence");
- return NULL;
- }