Skip to content
Snippets Groups Projects
Commit 4b983632 authored by Christophe Geuzaine's avatar Christophe Geuzaine
Browse files

allow "values() = strings()" syntax in enumerations

parent dd0db4ed
No related branches found
No related tags found
No related merge requests found
This diff is collapsed.
......@@ -239,7 +239,7 @@ extern int gmsh_yydebug;
union YYSTYPE
{
#line 109 "Gmsh.y" /* yacc.c:1909 */
#line 110 "Gmsh.y" /* yacc.c:1909 */
char *c;
int i;
......
......@@ -98,6 +98,7 @@ void addPeriodicEdge(int, int, const std::vector<double>&);
void addPeriodicFace(int, int, const std::map<int,int>&);
void addPeriodicFace(int, int, const std::vector<double>&);
void computeAffineTransformation(SPoint3&, SPoint3&, double, SPoint3&, std::vector<double>&);
char *strsave(char *ptr);
struct doubleXstring{
double d;
......@@ -1472,6 +1473,30 @@ Enumeration :
doubleXstring v = {$3, $5};
List_Add($$, &v);
}
| FExpr_Multi tAFFECT String__Index '(' ')'
{
$$ = List_Create(20,20,sizeof(doubleXstring));
int n = List_Nbr($1);
if(!gmsh_yystringsymbols.count($3)){
yymsg(0, "Unknown string variable '%s'", $3);
}
else{
std::vector<std::string> &s(gmsh_yystringsymbols[$3]);
int m = s.size();
if(n == m){
for(int i = 0; i < n; i++){
double d;
List_Read($1, i, &d);
doubleXstring v = {d, strsave((char*)s[i].c_str())};
List_Add($$, &v);
}
}
else{
yymsg(0, "Size mismatch in enumeration: %d != %d", n, m);
}
}
List_Delete($1);
}
;
FloatParameterOptions :
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment