diff --git a/Common/LuaBindings.cpp b/Common/LuaBindings.cpp index 1467dd4c9520d3b754dfc82b9d14e4843bfdb880..8668c7d903ce468002e99db63b2da7be9d8bc7fe 100644 --- a/Common/LuaBindings.cpp +++ b/Common/LuaBindings.cpp @@ -123,11 +123,11 @@ static void reportErrors(lua_State *L, int status) } } -const char *colorRed = "\033[1;31m"; -const char *colorGreen = "\033[1;32m"; -const char *colorBlue = "\033[1;34m"; -const char *colorDefault = "\033[0m"; -const char *colorBold = "\033[1m"; +static const char *colorRed = "\033[1;31m"; +static const char *colorGreen = "\033[1;32m"; +static const char *colorBlue = "\033[1;34m"; +static const char *colorDefault = "\033[0m"; +static const char *colorBold = "\033[1m"; static void printMethod(std::string name, luaMethodBinding *mb, bool isConstructor=false) { diff --git a/Common/LuaBindings.h b/Common/LuaBindings.h index 14b74d885d87c00e0e5946aca432b5076be4cdae..8b004722e6ebc18a12b90338bec222876ef3524d 100644 --- a/Common/LuaBindings.h +++ b/Common/LuaBindings.h @@ -1227,13 +1227,12 @@ class classBinding { lua_setmetatable(L, methods); // setmetatable(methods, mt) lua_pop(L, 2); // drop metatable and method table } - template<typename parentType> - void setParentClass() - { + void setParentClassName(const std::string parentClassName) { if(_parent) Msg::Error("Multiple inheritance not implemented in lua bindings " "for class %s", _className.c_str()); - std::string parentClassName = className<parentType>::get(); + if(_b->classes.find(parentClassName) == _b->classes.end()) + Msg::Error("Unknown class %s", parentClassName.c_str()); _parent = _b->classes[parentClassName]; _parent->children.insert(this); lua_getglobal(_b->L, _className.c_str()); @@ -1244,6 +1243,11 @@ class classBinding { // mt.__index = global[_parentClassName] // this is the inheritance bit lua_pop(_b->L, 2); } + template<typename parentType> + void setParentClass() + { + setParentClassName(className<parentType>::get()); + } void setDescription(std::string description){ _description = description; } inline const std::string getDescription() const { return _description; } inline classBinding *getParent() const { return _parent; } diff --git a/Solver/linearSystem.cpp b/Solver/linearSystem.cpp index 84193cd788e023e160c51d5d02d75012b06dd1cf..f823902db4734496fa11961746cd017994f04df7 100644 --- a/Solver/linearSystem.cpp +++ b/Solver/linearSystem.cpp @@ -8,7 +8,7 @@ template<> void linearSystem<double>::registerBindings(binding *b){ - classBinding *cb = b->addClass<linearSystem<double> >("linearSystem"); + classBinding *cb = b->addClass<linearSystem<double> >("linearSystemDouble"); cb->setDescription("An abstraction of a linear system Ax = b."); methodBinding *cm; cm = cb->addMethod("systemSolve", &linearSystem<double>::systemSolve); @@ -34,6 +34,11 @@ void linearSystem<double>::registerBindings(binding *b){ cm->setDescription ("A new Lapack based <double> solver"); cm->setArgNames(NULL); cb->setParentClass<linearSystem<double> >(); + // block + cb = b->addClass<linearSystem<fullMatrix<double> > >("linearSystemFullMatrixDouble"); + cb->setDescription("An abstraction of a linear system Ax = b."); + cm = cb->addMethod("systemSolve", &linearSystem<fullMatrix<double> >::systemSolve); + cm->setDescription("compute x = A^{-1}b"); #ifdef HAVE_PETSC linearSystemPETScRegisterBindings (b); #endif diff --git a/Solver/linearSystemPETSc.cpp b/Solver/linearSystemPETSc.cpp index 658caffa31a756a6885a0ca4ca55913f05d0e894..82805bf9a0e14b8f3920c6891cc8fe66a5d6301c 100644 --- a/Solver/linearSystemPETSc.cpp +++ b/Solver/linearSystemPETSc.cpp @@ -107,21 +107,13 @@ void linearSystemPETScRegisterBindings(binding *b) cm->setDescription ("A new PETSc<PetscScalar> solver"); cb->setParentClass<linearSystem<PetscScalar> >(); cm->setArgNames(NULL); - cm = cb->addMethod("systemSolve", &linearSystem<fullMatrix<PetscScalar> >::systemSolve); - cm->setDescription("compute x = A^{-1}b"); - - cb = b->addClass<linearSystem<fullMatrix<double> > >("linearSystemBlock"); - cb->setDescription("A linear system solver with blocks"); - cb = b->addClass<linearSystemPETSc<fullMatrix<PetscScalar> > >("linearSystemPETScBlock"); cb->setDescription("A linear system solver, based on PETSc"); cm = cb->setConstructor<linearSystemPETSc<fullMatrix<PetscScalar> >, int>(); cm->setDescription ("A new PETScBlock<PetscScalar> solver (we probably should get rid of the blockSize argument)"); cb->setParentClass<linearSystem<fullMatrix<PetscScalar> > >(); cm->setArgNames("blockSize", NULL); - cm = cb->addMethod("systemSolve", &linearSystem<fullMatrix<PetscScalar> >::systemSolve); - cm->setDescription("compute x = A^{-1}b"); - #endif // FIXME +#endif // FIXME }