diff options
author | Atsushi Eno <atsushieno@gmail.com> | 2007-06-28 20:44:07 +0400 |
---|---|---|
committer | Atsushi Eno <atsushieno@gmail.com> | 2007-06-28 20:44:07 +0400 |
commit | 19308b4ef020057c83ef959fa52bcedc73cef707 (patch) | |
tree | 648f106f4be2f4b4aaff54c3cbfbf5065ebb0eb1 /mcs/class/System.XML/Mono.Xml.Xsl | |
parent | c224f1ad45189bb3315e7678055d63495a8b5171 (diff) |
2007-06-28 Atsushi Enomoto <atsushi@ximian.com>
Yes, it is Hack Week, I had to start delayed though.
* System.Xml.dll.sources : added XsltDebuggerWrapper.cs, as initial
attempt to support external debugger.
* XslText.cs XslMessage.cs XslVariable.cs XslNotSupportedOperation.cs
XslNumber.cs XslElement.cs XslIf.cs XslCopyOf.cs XslFallback.cs
XslValueOf.cs XslComment.cs XslAttribute.cs XslApplyImports.cs
XslApplyTemplates.cs XslLiteralElement.cs XslCompiledElement.cs
XslTemplateContent.cs XslForEach.cs XslCallTemplate.cs
XslCopy.cs XslProcessingInstruction.cs XslChoose.cs :
minimum required injection for debugger.
initial attempt to hook debuggers.
* XsltDebuggerWrapper.cs : new.
* XslTransformProcessor.cs Compiler.cs : use above.
* XslCompiledTransform.cs XslTransform.cs : initial attempt to
support external debugger.
svn path=/trunk/mcs/; revision=80984
Diffstat (limited to 'mcs/class/System.XML/Mono.Xml.Xsl')
4 files changed, 91 insertions, 2 deletions
diff --git a/mcs/class/System.XML/Mono.Xml.Xsl/ChangeLog b/mcs/class/System.XML/Mono.Xml.Xsl/ChangeLog index d0bba12cc8c..c8bd0fa92e9 100644 --- a/mcs/class/System.XML/Mono.Xml.Xsl/ChangeLog +++ b/mcs/class/System.XML/Mono.Xml.Xsl/ChangeLog @@ -1,3 +1,9 @@ +2007-06-28 Atsushi Enomoto <atsushi@ximian.com> + + initial attempt to hook debuggers. + * XsltDebuggerWrapper.cs : new. + * XslTransformProcessor.cs Compiler.cs : use above. + 2007-01-09 Atsushi Enomoto <atsushi@ximian.com> * XslKey.cs : keep keytables per instance document and do not share diff --git a/mcs/class/System.XML/Mono.Xml.Xsl/Compiler.cs b/mcs/class/System.XML/Mono.Xml.Xsl/Compiler.cs index aeadf6f85a3..abc1becd311 100644 --- a/mcs/class/System.XML/Mono.Xml.Xsl/Compiler.cs +++ b/mcs/class/System.XML/Mono.Xml.Xsl/Compiler.cs @@ -124,6 +124,17 @@ namespace Mono.Xml.Xsl Hashtable outputs = new Hashtable (); bool keyCompilationMode; string stylesheetVersion; + XsltDebuggerWrapper debugger; + + public Compiler (object debugger) + { + if (debugger != null) + this.debugger = new XsltDebuggerWrapper (debugger); + } + + public XsltDebuggerWrapper Debugger { + get { return debugger; } + } public CompiledStylesheet Compile (XPathNavigator nav, XmlResolver res, Evidence evidence) { diff --git a/mcs/class/System.XML/Mono.Xml.Xsl/XslTransformProcessor.cs b/mcs/class/System.XML/Mono.Xml.Xsl/XslTransformProcessor.cs index 4dd77c91607..ea03b671105 100644 --- a/mcs/class/System.XML/Mono.Xml.Xsl/XslTransformProcessor.cs +++ b/mcs/class/System.XML/Mono.Xml.Xsl/XslTransformProcessor.cs @@ -44,6 +44,8 @@ using QName = System.Xml.XmlQualifiedName; namespace Mono.Xml.Xsl { internal class XslTransformProcessor { + XsltDebuggerWrapper debugger; + CompiledStylesheet compiledStyle; XslStylesheet style; @@ -61,11 +63,13 @@ namespace Mono.Xml.Xsl { // Store the values of global params internal Hashtable globalVariableTable = new Hashtable (); - public XslTransformProcessor (CompiledStylesheet style) + public XslTransformProcessor (CompiledStylesheet style, object debugger) { this.XPathContext = new XsltCompiledContext (this); this.compiledStyle = style; this.style = style.Style; + if (debugger != null) + this.debugger = new XsltDebuggerWrapper (debugger); } public void Process (XPathNavigator root, Outputter outputtter, XsltArgumentList args, XmlResolver resolver) @@ -108,7 +112,11 @@ namespace Mono.Xml.Xsl { this.ApplyTemplates (root.Select (exp, this.XPathContext), QName.Empty, null); this.PopOutput (); } - + + public XsltDebuggerWrapper Debugger { + get { return debugger; } + } + public CompiledStylesheet CompiledStyle { get { return compiledStyle; }} public XsltArgumentList Arguments {get{return args;}} diff --git a/mcs/class/System.XML/Mono.Xml.Xsl/XsltDebuggerWrapper.cs b/mcs/class/System.XML/Mono.Xml.Xsl/XsltDebuggerWrapper.cs new file mode 100644 index 00000000000..f15e77a0f11 --- /dev/null +++ b/mcs/class/System.XML/Mono.Xml.Xsl/XsltDebuggerWrapper.cs @@ -0,0 +1,64 @@ +// +// XsltDebuggerWrapper.cs +// +// Author: +// Atsushi Enomoto <atsushi@ximian.com> +// +// Copyright (C) 2007 Novell, Inc. +// + +// +// Permission is hereby granted, free of charge, to any person obtaining +// a copy of this software and associated documentation files (the +// "Software"), to deal in the Software without restriction, including +// without limitation the rights to use, copy, modify, merge, publish, +// distribute, sublicense, and/or sell copies of the Software, and to +// permit persons to whom the Software is furnished to do so, subject to +// the following conditions: +// +// The above copyright notice and this permission notice shall be +// included in all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE +// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION +// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +// + +using System; +using System.Reflection; +using System.Xml; +using System.Xml.XPath; + +namespace Mono.Xml.Xsl +{ + internal class XsltDebuggerWrapper + { + readonly MethodInfo on_compile, on_execute; + readonly object impl; + + public XsltDebuggerWrapper (object impl) + { + this.impl = impl; + on_compile = impl.GetType ().GetMethod ("OnCompile", BindingFlags.NonPublic | BindingFlags.Instance); + if (on_compile == null) + throw new InvalidOperationException ("INTERNAL ERROR: the debugger does not look like what System.Xml.dll expects. OnCompile method was not found"); + on_execute = impl.GetType ().GetMethod ("OnExecute", BindingFlags.NonPublic | BindingFlags.Instance); + if (on_execute == null) + throw new InvalidOperationException ("INTERNAL ERROR: the debugger does not look like what System.Xml.dll expects. OnExecute method was not found"); + } + + public void DebugCompile (XPathNavigator style) + { + on_compile.Invoke (impl, new object [] {style.Clone ()}); + } + + public void DebugExecute (XslTransformProcessor p, XPathNavigator style) + { + on_execute.Invoke (impl, new object [] {p.CurrentNodeset.Clone (), style.Clone (), p.XPathContext}); + } + } +} |