Skip to content
Browse files

Microsoft.Scripting.SymbolId and Microsoft.Scripting.SymbolTable do n…

…ot exist anymore in newer versions of the DLR.
  • Loading branch information...
1 parent f180774 commit 1677894cfe5017e9f72344cb3c98c4a41a2a238b @nrk committed Jul 17, 2010
Showing with 43 additions and 36 deletions.
  1. +22 −15 src/Hpricot.cs
  2. +21 −21 src/HpricotScanner.cs
View
37 src/Hpricot.cs
@@ -229,15 +229,18 @@ public Comment(RubyContext context)
[RubyClass("DocType", Inherits = typeof(BaseElement))]
public class DocumentType : BaseElement {
- private static readonly SymbolId _systemId = SymbolTable.StringToId("system_id");
- private static readonly SymbolId _publicId = SymbolTable.StringToId("public_id");
+ private RubySymbol _systemId;
+ private RubySymbol _publicId;
public DocumentType(ScannerState state)
: this(state.Context) {
}
public DocumentType(RubyContext context)
: base(context, new AttributeData()) {
+
+ _systemId = context.CreateAsciiSymbol("system_id");
+ _publicId = context.CreateAsciiSymbol("public_id");
}
[RubyConstructor]
@@ -284,7 +287,7 @@ public DocumentType(RubyContext context)
}
Object value;
- (data.Attr as Hash).TryGetValue(_publicId, out value);
+ (data.Attr as Hash).TryGetValue(self._publicId, out value);
return value;
}
@@ -294,7 +297,7 @@ public DocumentType(RubyContext context)
if (data.AttrIsNull) {
data.Attr = new Hash(context);
}
- (data.Attr as Hash)[_publicId] = publicId;
+ (data.Attr as Hash)[self._publicId] = publicId;
}
[RubyMethod("system_id")]
@@ -305,7 +308,7 @@ public DocumentType(RubyContext context)
}
Object value;
- (data.Attr as Hash).TryGetValue(_systemId, out value);
+ (data.Attr as Hash).TryGetValue(self._systemId, out value);
return value;
}
@@ -315,7 +318,7 @@ public DocumentType(RubyContext context)
if (data.AttrIsNull) {
data.Attr = new Hash(context);
}
- (data.Attr as Hash)[_systemId] = systemId;
+ (data.Attr as Hash)[self._systemId] = systemId;
}
}
@@ -489,16 +492,20 @@ public Text(RubyContext context)
[RubyClass("XMLDecl", Inherits = typeof(BaseElement))]
public class XmlDeclaration : BaseElement {
- private static readonly SymbolId _encoding = SymbolTable.StringToId("encoding");
- private static readonly SymbolId _standalone = SymbolTable.StringToId("standalone");
- private static readonly SymbolId _version = SymbolTable.StringToId("version");
+ private RubySymbol _encoding;
+ private RubySymbol _standalone;
+ private RubySymbol _version;
public XmlDeclaration(ScannerState state)
: this(state.Context) {
}
public XmlDeclaration(RubyContext context)
: base(context, new AttributeData()) {
+
+ _encoding = context.CreateAsciiSymbol("encoding");
+ _standalone = context.CreateAsciiSymbol("standalone");
+ _version = context.CreateAsciiSymbol("version");
}
[RubyConstructor]
@@ -537,7 +544,7 @@ public XmlDeclaration(RubyContext context)
}
Object value;
- (data.Attr as Hash).TryGetValue(_encoding, out value);
+ (data.Attr as Hash).TryGetValue(self._encoding, out value);
return value;
}
@@ -547,7 +554,7 @@ public XmlDeclaration(RubyContext context)
if (data.AttrIsNull) {
data.Attr = new Hash(context);
}
- (data.Attr as Hash)[_encoding] = encoding;
+ (data.Attr as Hash)[self._encoding] = encoding;
}
[RubyMethod("standalone")]
@@ -558,7 +565,7 @@ public XmlDeclaration(RubyContext context)
}
Object value;
- (data.Attr as Hash).TryGetValue(_standalone, out value);
+ (data.Attr as Hash).TryGetValue(self._standalone, out value);
return value;
}
@@ -568,7 +575,7 @@ public XmlDeclaration(RubyContext context)
if (data.AttrIsNull) {
data.Attr = new Hash(context);
}
- (data.Attr as Hash)[_standalone] = standalone;
+ (data.Attr as Hash)[self._standalone] = standalone;
}
[RubyMethod("version")]
@@ -579,7 +586,7 @@ public XmlDeclaration(RubyContext context)
}
Object value;
- (data.Attr as Hash).TryGetValue(_version, out value);
+ (data.Attr as Hash).TryGetValue(self._version, out value);
return value;
}
@@ -589,7 +596,7 @@ public XmlDeclaration(RubyContext context)
if (data.AttrIsNull) {
data.Attr = new Hash(context);
}
- (data.Attr as Hash)[_version] = version;
+ (data.Attr as Hash)[self._version] = version;
}
}
View
42 src/HpricotScanner.cs
@@ -33,20 +33,20 @@ public class HpricotScanner {
#region fields - hpricot symbols
- private static Object sym_xmldecl;
- private static Object sym_doctype;
- private static Object sym_procins;
- private static Object sym_stag;
- private static Object sym_etag;
- private static Object sym_emptytag;
- private static Object sym_comment;
- private static Object sym_cdata;
- private static Object sym_text;
- private static Object sym_EMPTY;
- private static Object sym_CDATA;
-
- private static Object symAllow;
- private static Object symDeny;
+ private static RubySymbol sym_xmldecl;
+ private static RubySymbol sym_doctype;
+ private static RubySymbol sym_procins;
+ private static RubySymbol sym_stag;
+ private static RubySymbol sym_etag;
+ private static RubySymbol sym_emptytag;
+ private static RubySymbol sym_comment;
+ private static RubySymbol sym_cdata;
+ private static RubySymbol sym_text;
+ private static RubySymbol sym_EMPTY;
+ private static RubySymbol sym_CDATA;
+
+ private static RubySymbol symAllow;
+ private static RubySymbol symDeny;
private static RubySymbol _optXml;
private static RubySymbol _optFixupTags;
@@ -1286,8 +1286,8 @@ public class HpricotScanner {
if (state.Strict) {
// TODO: need to check if attr is really an Hash instance
Debug.Assert(attr is Hash, "attr is not an instance of Hash");
- (attr as Hash).Add(SymbolTable.StringToId("system_id"), MutableString.CreateAscii("http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"));
- (attr as Hash).Add(SymbolTable.StringToId("public_id"), MutableString.CreateAscii("-//W3C//DTD XHTML 1.0 Strict//EN"));
+ (attr as Hash).Add(state.Context.CreateAsciiSymbol("system_id"), MutableString.CreateAscii("http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"));
+ (attr as Hash).Add(state.Context.CreateAsciiSymbol("public_id"), MutableString.CreateAscii("-//W3C//DTD XHTML 1.0 Strict//EN"));
}
rb_hpricot_add(state.Focus, H_ELE(new Hpricot.DocumentType(state), state, sym, tag, attr, ec, raw, rawlen));
}
@@ -1664,15 +1664,15 @@ public class HpricotScanner {
break;
case 7: { SET(akey, p); }
break;
- case 8: { SET(aval, p); ATTR(SymbolTable.StringToId("version"), aval); }
+ case 8: { SET(aval, p); ATTR(_state.Context.CreateAsciiSymbol("version"), aval); }
break;
- case 9: { SET(aval, p); ATTR(SymbolTable.StringToId("encoding"), aval); }
+ case 9: { SET(aval, p); ATTR(_state.Context.CreateAsciiSymbol("encoding"), aval); }
break;
- case 10: { SET(aval, p); ATTR(SymbolTable.StringToId("standalone"), aval); }
+ case 10: { SET(aval, p); ATTR(_state.Context.CreateAsciiSymbol("standalone"), aval); }
break;
- case 11: { SET(aval, p); ATTR(SymbolTable.StringToId("public_id"), aval); }
+ case 11: { SET(aval, p); ATTR(_state.Context.CreateAsciiSymbol("public_id"), aval); }
break;
- case 12: { SET(aval, p); ATTR(SymbolTable.StringToId("system_id"), aval); }
+ case 12: { SET(aval, p); ATTR(_state.Context.CreateAsciiSymbol("system_id"), aval); }
break;
case 13: {
akey[0] = null;

0 comments on commit 1677894

Please sign in to comment.
Something went wrong with that request. Please try again.