JL_DLLEXPORT void jl_yield(void) { static jl_function_t *yieldfunc = NULL; if (yieldfunc == NULL) yieldfunc = (jl_function_t*)jl_get_global(jl_base_module, jl_symbol("yield")); if (yieldfunc != NULL) jl_call0(yieldfunc); }
jl_array_t *jl_get_loaded_modules(void) { static jl_value_t *loaded_modules_array = NULL; if (loaded_modules_array == NULL && jl_base_module != NULL) loaded_modules_array = jl_get_global(jl_base_module, jl_symbol("loaded_modules_array")); if (loaded_modules_array != NULL) return (jl_array_t*)jl_call0((jl_function_t*)loaded_modules_array); return NULL; }
SqwJl::SqwJl(const char* pcFile) : m_pmtx(std::make_shared<std::mutex>()) { std::string strFile = pcFile; std::string strDir = tl::get_dir(strFile); const bool bSetScriptCWD = 1; // init interpreter static bool bInited = 0; if(!bInited) { jl_init(0); std::string strJl = jl_ver_string(); tl::log_debug("Initialised Julia interpreter version ", strJl, "."); bInited = 1; } // include module jl_function_t *pInc = jl_get_function(jl_base_module, "include"); jl_value_t *pMod = jl_cstr_to_string(pcFile); jl_call1(pInc, pMod); // working dir if(bSetScriptCWD) { jl_function_t *pCwd = jl_get_function(jl_base_module, "cd"); jl_value_t *pDir = jl_cstr_to_string(strDir.c_str()); jl_call1(pCwd, pDir); } // import takin functions m_pInit = jl_get_function(jl_main_module, "TakinInit"); m_pSqw = jl_get_function(jl_main_module, "TakinSqw"); if(!m_pSqw) { m_bOk = 0; tl::log_err("Julia script has no TakinSqw function."); return; } else { m_bOk = 1; } if(m_pInit) jl_call0((jl_function_t*)m_pInit); else tl::log_warn("Julia script has no TakinInit function."); }
void td_jl_invoke0(td_val_t *out, char *fname) { jl_function_t *f = jl_get_function(jl_base_module, fname); jl_value_t *v = jl_call0(f); to_td_val(out, v); }