summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDennis Kasprzyk <onestone@beryl-project.org>2007-03-26 21:34:07 +0200
committerDennis Kasprzyk <onestone@beryl-project.org>2007-03-26 21:34:07 +0200
commit55aa311ed39484f80738ef8d69ca0fe2f88667d6 (patch)
tree5265dd69ef1a646e299f32883bf2a69b2a3cb8d8
parent304c6d960b56c10887cdc146f98a20190e765aab (diff)
downloadberyl-bcop-55aa311ed39484f80738ef8d69ca0fe2f88667d6.tar.gz
beryl-bcop-55aa311ed39484f80738ef8d69ca0fe2f88667d6.tar.bz2
added match option type
-rw-r--r--src/bcop.h7
-rw-r--r--src/code_generator.c21
-rw-r--r--src/xml_parser.c20
3 files changed, 47 insertions, 1 deletions
diff --git a/src/bcop.h b/src/bcop.h
index 4112069..ed28968 100644
--- a/src/bcop.h
+++ b/src/bcop.h
@@ -57,6 +57,7 @@ typedef enum {
OptionTypeSelection,
OptionTypeColor,
OptionTypeAction,
+ OptionTypeMatch,
OptionTypeError
} OptionType;
@@ -123,6 +124,11 @@ typedef struct _StringOptionInfo
char *def;
} StringOptionInfo;
+typedef struct _MatchOptionInfo
+{
+ char *def;
+} MatchOptionInfo;
+
typedef struct _StringListOptionInfo
{
OptionValuesList* begin;
@@ -161,6 +167,7 @@ typedef union _OptionInfo
BindingOptionInfo asBind;
StringListOptionInfo asSList;
ColorOptionInfo asColor;
+ StringOptionInfo asMatch;
} OptionInfo;
struct _Option {
diff --git a/src/code_generator.c b/src/code_generator.c
index 79b7f45..09912f6 100644
--- a/src/code_generator.c
+++ b/src/code_generator.c
@@ -302,6 +302,20 @@ void addBoolOption(Option *o)
addGetFunction(o,"Bool","",".value.b","");
}
+void addMatchOption(Option *o)
+{
+ StringElement *out = (o->screen)?&initScreenOpt:&initDisplayOpt;
+ char name[1024];
+
+ sprintf(name,"%s_%s",data.uName,o->uName);
+ addString(&defines,"#define %s_DEFAULT \"%s\"\n\n",name,o->data.asString.def);
+
+ addString(out,"\tmatchInit (&o->value.match);\n");
+ addString(out,"\tmatchAddFromString (&o->value.match, %s_DEFAULT);\n",name);
+
+ addGetFunction(o,"CompMatch *","",".value.match","&");
+}
+
void addStringOption(Option *o)
{
StringElement *out = (o->screen)?&initScreenOpt:&initDisplayOpt;
@@ -316,7 +330,6 @@ void addStringOption(Option *o)
addGetFunction(o,"char *","",".value.s","");
}
-
void addStringListOption(Option *o)
{
StringElement *out = (o->screen)?&initScreenOpt:&initDisplayOpt;
@@ -838,6 +851,12 @@ void addOption(Option *o)
addString(out,"\to->type = CompOptionTypeAction;\n");
addActionOption(o);
break;
+ case OptionTypeMatch:
+ addString(outs,"\t\tif (compSetMatchOption (o, value))\n"
+ "\t\t{\n");
+ addString(out,"\to->type = CompOptionTypeMatch;\n");
+ addMatchOption(o);
+ break;
default:
break;
}
diff --git a/src/xml_parser.c b/src/xml_parser.c
index f427b18..e30d32c 100644
--- a/src/xml_parser.c
+++ b/src/xml_parser.c
@@ -84,6 +84,8 @@ static OptionType get_Option_type(xmlChar * type)
return OptionTypeColor;
if (!xmlStrcmp(type, (const xmlChar *) "action"))
return OptionTypeAction;
+ if (!xmlStrcmp(type, (const xmlChar *) "match"))
+ return OptionTypeMatch;
return OptionTypeError;
}
@@ -168,6 +170,21 @@ parseStringOption(xmlDoc *doc, xmlNode *node, Option *set)
}
static void
+parseMatchOption(xmlDoc *doc, xmlNode *node, Option *set)
+{
+ xmlNode *cur = node;
+ while (cur != NULL)
+ {
+ if (!xmlStrcmp(cur->name, (const xmlChar *) "default")) {
+ xmlChar *key = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1);
+ set->data.asMatch.def = strdup((char *)key);
+ xmlFree(key);
+ }
+ cur = cur->next;
+ }
+}
+
+static void
parseColorOption(xmlDoc *doc, xmlNode *node, Option *set)
{
xmlNode *cur = node;
@@ -632,6 +649,9 @@ parseOption(xmlDoc *doc, ParserState* pState, xmlNode *node)
case OptionTypeAction:
parseActionOption(doc, node->xmlChildrenNode, ns);
break;
+ case OptionTypeMatch:
+ parseMatchOption(doc, node->xmlChildrenNode, ns);
+ break;
default:
break;
}