Skip to content
This repository has been archived by the owner on Mar 6, 2020. It is now read-only.

Commit

Permalink
string constants are no longer valid; http://lists.w3.org/Archives/Pu…
Browse files Browse the repository at this point in the history
  • Loading branch information
dontcallmedom committed Dec 14, 2011
1 parent ed8b171 commit c078e26
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 24 deletions.
3 changes: 1 addition & 2 deletions doc/widlproc.html
Expand Up @@ -655,7 +655,7 @@ <h4>Const</h4>
syntax. syntax.
The <em>Type</em> specifies the constant's type, the The <em>Type</em> specifies the constant's type, the
<em>name</em> attribute specifies the constant's name, and the <em>name</em> attribute specifies the constant's name, and the
<em>value</em> attribute specifies its value for non-string values, and <em>stringvalue</em> for string values. <em>value</em> attribute specifies its value.
The <em>descriptive></em> element The <em>descriptive></em> element
provides the <em>Const</em>'s documentation if any. provides the <em>Const</em>'s documentation if any.
The <em>id</em> attribute specifies the absolute scoped name of the const. The <em>id</em> attribute specifies the absolute scoped name of the const.
Expand All @@ -665,7 +665,6 @@ <h4>Const</h4>
&lt;!ELEMENT Const (webidl, descriptive?, ExtendedAttributeList?, Type) > &lt;!ELEMENT Const (webidl, descriptive?, ExtendedAttributeList?, Type) >
&lt;!ATTLIST Const name CDATA #REQUIRED &lt;!ATTLIST Const name CDATA #REQUIRED
value CDATA #IMPLIED value CDATA #IMPLIED
stringvalue CDATA #IMPLIED
id CDATA #REQUIRED > id CDATA #REQUIRED >
</pre> </pre>


Expand Down
32 changes: 28 additions & 4 deletions src/parse.c
Expand Up @@ -676,7 +676,7 @@ parseattributeoroperation(struct tok *tok, struct node *eal)
} }


/*********************************************************************** /***********************************************************************
* parseconstexpr : parse ConstExpr * parseconstexpr : parse ConstValue
* *
* Enter: tok = next token * Enter: tok = next token
* node * node
Expand All @@ -692,7 +692,6 @@ parseconstexpr (struct tok *tok, struct node *node) {
case TOK_false: case TOK_false:
case TOK_INTEGER: case TOK_INTEGER:
case TOK_FLOAT: case TOK_FLOAT:
case TOK_STRING:
case TOK_null: case TOK_null:
break; break;
default: default:
Expand All @@ -711,6 +710,32 @@ parseconstexpr (struct tok *tok, struct node *node) {
return node; return node;
} }


/***********************************************************************
* parsedefaultvalue : parse DefaultValue
*
* Enter: tok = next token
* node
*
* Return: node updated with value
* tok updated
*/
static struct node *
parsedefaultvalue (struct tok *tok, struct node *node) {
char *s;
if (tok->type == TOK_STRING) {
s = memalloc(tok->len + 1);
memcpy(s, tok->start, tok->len);
s[tok->len] = 0;
addnode(node, newattr("stringvalue", s));
lexnocomment();
return node;
} else {
return parseconstexpr(tok, node);
}
}



/*********************************************************************** /***********************************************************************
* parsedictionarymember : parse DictionaryMember * parsedictionarymember : parse DictionaryMember
* *
Expand All @@ -732,7 +757,7 @@ parsedictionarymember(struct tok *tok, struct node *eal)
// Optional value // Optional value
if (tok->type == '=') { if (tok->type == '=') {
tok = lexnocomment(); tok = lexnocomment();
node = parseconstexpr(tok, node); node = parsedefaultvalue(tok, node);
} }
return node; return node;
} }
Expand All @@ -759,7 +784,6 @@ parseconst(struct tok *tok, struct node *eal)
case TOK_octet: case TOK_octet:
case TOK_float: case TOK_float:
case TOK_double: case TOK_double:
case TOK_DOMString:
case TOK_unsigned: case TOK_unsigned:
case TOK_short: case TOK_short:
case TOK_long: case TOK_long:
Expand Down
1 change: 1 addition & 0 deletions test/invalid/error/stringconstants.idl
@@ -0,0 +1 @@
invalid/idl/stringconstants.idl: 2: at 'DOMString': expected acceptable constant type
3 changes: 3 additions & 0 deletions test/invalid/idl/stringconstants.idl
@@ -0,0 +1,3 @@
interface Util {
const DOMString hello = "world";
};
3 changes: 0 additions & 3 deletions test/valid/idl/constants.widl
Expand Up @@ -4,9 +4,6 @@ interface Util {
const octet LF = 10; const octet LF = 10;
const unsigned long BIT_MASK = 0x0000fc00; const unsigned long BIT_MASK = 0x0000fc00;
const float AVOGADRO = 6.022e23; const float AVOGADRO = 6.022e23;
const DOMString hello = "world";
const DOMString? nullString = "null";
const DOMString? nullable = null;
}; };


exception Error { exception Error {
Expand Down
15 changes: 0 additions & 15 deletions test/valid/xml/constants.widlprocxml
Expand Up @@ -7,9 +7,6 @@
const octet LF = 10; const octet LF = 10;
const unsigned long BIT_MASK = 0x0000fc00; const unsigned long BIT_MASK = 0x0000fc00;
const float AVOGADRO = 6.022e23; const float AVOGADRO = 6.022e23;
const DOMString hello = &quot;world&quot;;
const DOMString? nullString = &quot;null&quot;;
const DOMString? nullable = null;
};</webidl> };</webidl>
<Const name="DEBUG" value="false" id="::Util::DEBUG"> <Const name="DEBUG" value="false" id="::Util::DEBUG">
<webidl> const boolean DEBUG = false;</webidl> <webidl> const boolean DEBUG = false;</webidl>
Expand All @@ -27,18 +24,6 @@
<webidl> const float AVOGADRO = 6.022e23;</webidl> <webidl> const float AVOGADRO = 6.022e23;</webidl>
<Type type="float"/> <Type type="float"/>
</Const> </Const>
<Const name="hello" stringvalue="world" id="::Util::hello">
<webidl> const DOMString hello = &quot;world&quot;;</webidl>
<Type type="DOMString"/>
</Const>
<Const name="nullString" stringvalue="null" id="::Util::nullString">
<webidl> const DOMString? nullString = &quot;null&quot;;</webidl>
<Type type="DOMString" nullable="nullable"/>
</Const>
<Const name="nullable" value="null" id="::Util::nullable">
<webidl> const DOMString? nullable = null;</webidl>
<Type type="DOMString" nullable="nullable"/>
</Const>
</Interface> </Interface>
<Exception name="Error" id="::Error"> <Exception name="Error" id="::Error">
<webidl>exception Error { <webidl>exception Error {
Expand Down

0 comments on commit c078e26

Please sign in to comment.