Skip to content
Snippets Groups Projects
Commit ea0ac7e7 authored by Jonathan Lambrechts's avatar Jonathan Lambrechts
Browse files

lua bindings of gmsh options

parent aa2f6201
No related branches found
No related tags found
No related merge requests found
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include "dgRungeKutta.h" #include "dgRungeKutta.h"
#include "dgSystemOfEquations.h" #include "dgSystemOfEquations.h"
#include "dgLimiter.h" #include "dgLimiter.h"
#include "bindings.h"
extern "C" { extern "C" {
#include "lua.h" #include "lua.h"
...@@ -33,6 +34,61 @@ extern "C" { ...@@ -33,6 +34,61 @@ extern "C" {
#include "history.h" #include "history.h"
#endif #endif
//trivial class to bind options
class gmshOptions {
public:
gmshOptions(){};
void colorSet(std::string category, int index, std::string name, int value) {
GmshSetOption(category,name,(unsigned int)(value), index);
}
int colorGet(std::string category, int index, std::string name) {
unsigned int value;
GmshGetOption(category, name, value, index);
return value;
}
double numberGet(std::string category, int index, std::string name) {
double value;
GmshGetOption(category, name, value, index);
return value;
}
void numberSet(std::string category, int index, std::string name, double value) {
GmshSetOption(category, name, value, index);
}
std::string stringGet(std::string category, int index, std::string name) {
std::string value;
GmshGetOption(category, name, value, index);
return value;
}
void stringSet(std::string category, int index, std::string name, double value) {
GmshSetOption(category, name, value, index);
}
static void registerBindings(binding *b) {
classBinding *cb = b->addClass<gmshOptions>("gmshOptions");
cb->setDescription("access the gmsh option database");
methodBinding *mb;
mb = cb->addMethod("colorSet", &gmshOptions::colorSet);
mb->setDescription("set the value of a color (unsigned int) option. This is equivalent to category[index].name = value");
mb->setArgNames("category","index","name","value",NULL);
mb = cb->addMethod("colorGet", &gmshOptions::colorGet);
mb->setDescription("return the value of a color (unsigned int) option. This is equivalent to category[index].name");
mb->setArgNames("category","index","name",NULL);
mb = cb->addMethod("numberSet", &gmshOptions::numberSet);
mb->setDescription("set the value of a number option. This is equivalent to category[index].name = value");
mb->setArgNames("category","index","name","value",NULL);
mb = cb->addMethod("numberGet", &gmshOptions::numberGet);
mb->setDescription("return the value of a number option. This is equivalent to category[index].name");
mb->setArgNames("category","index","name",NULL);
mb = cb->addMethod("srtingSet", &gmshOptions::stringSet);
mb->setDescription("set the value of a string option. This is equivalent to category[index].name = \"value\"");
mb->setArgNames("category","index","name","value",NULL);
mb = cb->addMethod("srtingGet", &gmshOptions::stringGet);
mb->setDescription("return the value of a string option. This is equivalent to category[index].name");
mb->setArgNames("category","index","name",NULL);
mb = cb->setConstructor<gmshOptions>();
mb->setDescription("an instance of gmshOptions is needed to access the database");
}
};
static void reportErrors(lua_State *L, int status) static void reportErrors(lua_State *L, int status)
{ {
if ( status!=0 ) { if ( status!=0 ) {
...@@ -288,6 +344,7 @@ binding::binding(){ ...@@ -288,6 +344,7 @@ binding::binding(){
DocRecord::registerBindings(this); DocRecord::registerBindings(this);
GEntity::registerBindings(this); GEntity::registerBindings(this);
GFace::registerBindings(this); GFace::registerBindings(this);
gmshOptions::registerBindings(this);
} }
binding *binding::_instance=NULL; binding *binding::_instance=NULL;
#endif #endif
...@@ -119,6 +119,21 @@ class luaStack<int>{ ...@@ -119,6 +119,21 @@ class luaStack<int>{
} }
}; };
template<>
class luaStack<unsigned int>{
public:
static int get(lua_State *L, unsigned int ia){
unsigned int a= (unsigned int)luaL_checkint(L,ia);
return a;
}
static void push(lua_State *L, unsigned int i){
lua_pushinteger(L,i);
}
static std::string getName(){
return "unsigned int";
}
};
template<class type> template<class type>
class luaStack<std::vector<type > >{ class luaStack<std::vector<type > >{
public: public:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment