PyDict_SetItemString(dict, "__builtin__", builtin);
PyDict_SetItemString(dict, "__builtins__", builtin);
+ PyEval_SaveThread();
return (jlong)modDef;
}
}
##VariableImpl( \
JNIEnv *env, jobject thisObj, jlong contextID, jstring variableName, \
jtype value) { \
- PyObject *module = getModule(contextID); \
+ PyObject *module; \
\
PyEval_RestoreThread(main_ts); \
+ module = getModule(contextID); \
setPythonVariable(module, getPythonString(env, variableName), \
j2py(env, value)); \
PyEval_SaveThread(); \
Java_org_simantics_pythonlink_PythonContext_setPythonNDArrayVariableImpl(
JNIEnv *env, jobject thisObj, jlong contextID, jstring variableName,
jobject value) {
- PyObject *module = getModule(contextID);
-
if (!hasNumpy) {
throwPythonException(env, "Importing numpy failed");
return;
PyEval_RestoreThread(main_ts);
{
+ PyObject *module = getModule(contextID);
PyObject *pythonName = getPythonString(env, variableName);
PyObject *val = getPythonNDArray(env, value);
Java_org_simantics_pythonlink_PythonContext_setPythonVariantVariableImpl(
JNIEnv *env, jobject thisObj, jlong contextID, jstring variableName,
jobject value, jobject binding) {
- PyObject *module = getModule(contextID);
+ PyObject *module;
PyEval_RestoreThread(main_ts);
+ module = getModule(contextID);
setPythonVariable(module, getPythonString(env, variableName),
getPythonObject(env, value, binding));
PyEval_SaveThread();
JNIEXPORT jint JNICALL
Java_org_simantics_pythonlink_PythonContext_executePythonStatementImpl(
JNIEnv *env, jobject thisObj, jlong contextID, jstring statement) {
- PyObject *module = getModule(contextID);
-
const char *utfchars = (*env)->GetStringUTFChars(env, statement, NULL);
PyEval_RestoreThread(main_ts);
PyErr_Clear();
{
+ PyObject *module = getModule(contextID);
+
jclass sclReportingWriterClass = (*env)->FindClass(env, SCL_REPORTING_WRITER_CLASS);
jmethodID constructor = (*env)->GetMethodID(env, sclReportingWriterClass, "<init>", "()V");
jmethodID flushMethod = (*env)->GetMethodID(env, sclReportingWriterClass, "flush", "()V");