Skip to content

Commit

Permalink
Merge pull request #25 from SeisSol/fix-luastate-init
Browse files Browse the repository at this point in the history
Fix initialization of Lua state
  • Loading branch information
krenzland committed Feb 9, 2022
2 parents 39c2508 + f4083de commit 0d1d4e8
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 5 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ project(easi)
cmake_minimum_required(VERSION 3.13)
set(EASI_VERSION_MAJOR 1)
set(EASI_VERSION_MINOR 1)
set(EASI_VERSION_PATCH 0)
set(EASI_VERSION_PATCH 1)

include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
Expand Down
2 changes: 1 addition & 1 deletion examples/4_lua.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ components:
mu: 0.0
lambda: 1.96e10
- !LuaMap
returns: ["rho", "mu", "lambda"]
returns: [rho, mu, lambda]
function: |
function f (x)
io.write(x[1], " ", x[2], " ", x[3], "\n") -- optional debug output
Expand Down
4 changes: 2 additions & 2 deletions include/easi/component/LuaMap.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ class LuaMap : public Map {

~LuaMap() override;
protected:
virtual Matrix<double> map(Matrix<double>& x) override;
Matrix<double> map(Matrix<double>& x) override;

private:
double executeLuaFunction(Matrix<double> x, unsigned coordIdx, unsigned funcIdx);
std::string function;
std::vector<std::string> idxToNameMap;
lua_State* luaState;
lua_State* luaState{nullptr};

};

Expand Down
1 change: 0 additions & 1 deletion src/component/LuaMap.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ double LuaMap::executeLuaFunction(Matrix<double> x,
unsigned coordIdx,
unsigned funcIdx) {
if (!luaState) {
std::cout << "Init lua state" << std::endl;
luaState = luaL_newstate();
luaL_openlibs(luaState);
const auto status = luaL_dostring(luaState, function.data());
Expand Down

0 comments on commit 0d1d4e8

Please sign in to comment.