Skip to content

Commit 66c4153

Browse files
committed
Break LibXML::DocumentFragment parse() method into multis
Make it consistant with LibXML::Parser
1 parent f08ce46 commit 66c4153

File tree

2 files changed

+22
-8
lines changed

2 files changed

+22
-8
lines changed

docs/DocumentFragment.md

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,9 @@ Creates a new empty document fragment to which nodes can be added; typically by
6161

6262
```raku
6363
method parse(
64-
Str(Any) :$string!,
64+
Str:D(Any):D :$string!,
6565
Bool :balanced($)! where { ... },
66-
NativeCall::Types::Pointer :$user-data,
67-
|c
66+
NativeCall::Types::Pointer :$user-data
6867
) returns LibXML::DocumentFragment
6968
```
7069

lib/LibXML/DocumentFragment.rakumod

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,16 +113,31 @@ method new(LibXML::Node :doc($_), xmlDocFrag :$native, *%c) {
113113
=end pod
114114

115115
#| parses a balanced XML chunk
116-
method parse(
117-
Str() :$string!,
116+
proto method parse(
117+
Str:D() :$string!,
118+
Bool :balanced($)! where .so,
119+
Pointer :$user-data,
120+
--> LibXML::DocumentFragment) {
121+
{*}
122+
}
123+
124+
multi method parse(
125+
::?CLASS:U:
126+
Str:D() :$string,
127+
Bool :balanced($)! where .so,
128+
Pointer :$user-data,
129+
|c) is hidden-from-backtrace {
130+
self.new(|c).parse: :$string, :balanced, :$user-data, |c;
131+
}
132+
133+
multi method parse(
134+
::?CLASS:D $doc-frag:
135+
Str:D() :$string!,
118136
Bool :balanced($)! where .so,
119137
Pointer :$user-data,
120138
|c
121139
--> LibXML::DocumentFragment) is hidden-from-backtrace {
122140

123-
my $doc-frag = self;
124-
$_ .= new(|c) without $doc-frag;
125-
126141
my ParserContext $ctx = $doc-frag.create: ParserContext, :$string, :$doc-frag, :$user-data, |c;
127142

128143
$ctx.do: {

0 commit comments

Comments
 (0)