Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
gmsh
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Larry Price
gmsh
Commits
ea0ac7e7
Commit
ea0ac7e7
authored
15 years ago
by
Jonathan Lambrechts
Browse files
Options
Downloads
Patches
Plain Diff
lua bindings of gmsh options
parent
aa2f6201
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Common/LuaBindings.cpp
+57
-0
57 additions, 0 deletions
Common/LuaBindings.cpp
Common/LuaBindings.h
+15
-0
15 additions, 0 deletions
Common/LuaBindings.h
with
72 additions
and
0 deletions
Common/LuaBindings.cpp
+
57
−
0
View file @
ea0ac7e7
...
@@ -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
This diff is collapsed.
Click to expand it.
Common/LuaBindings.h
+
15
−
0
View file @
ea0ac7e7
...
@@ -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:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment