Skip to content

Commit

Permalink
Merge pull request #2142 from jstuder-gh/carray_indexing_candidates
Browse files Browse the repository at this point in the history
Add Callable, Whatever, and zen indexing candidates for CArray
  • Loading branch information
zoffixznet committed Jul 28, 2018
2 parents 0ec4f5f + 2a803a3 commit b7379a8
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
15 changes: 15 additions & 0 deletions lib/NativeCall.pm6
Expand Up @@ -588,6 +588,21 @@ multi sub postcircumfix:<[ ]>(CArray:D \array, $pos) is export(:DEFAULT, :types)
multi sub postcircumfix:<[ ]>(CArray:D \array, *@pos) is export(:DEFAULT, :types) {
@pos.map: { array.AT-POS($_) };
}
multi sub postcircumfix:<[ ]>(CArray:D \array, Callable:D $block) is export(:DEFAULT, :types) {
nqp::stmts(
(my $*INDEX = 'Effective index'),
array[$block.pos(array)]
)
}
multi sub postcircumfix:<[ ]>(CArray:D \array) is export(:DEFAULT, :types) {
array.ZEN-POS
}
multi sub postcircumfix:<[ ]>(CArray:D \array, Whatever:D) is export(:DEFAULT, :types) {
array[^array.elems]
}
multi sub postcircumfix:<[ ]>(CArray:D \array, HyperWhatever:D) is export(:DEFAULT, :types) {
X::NYI.new(feature => 'HyperWhatever in CArray index').throw;
}

multi trait_mod:<is>(Routine $r, :$symbol!) is export(:DEFAULT, :traits) {
$r does NativeCallSymbol[$symbol];
Expand Down
2 changes: 2 additions & 0 deletions lib/NativeCall/Types.pm6
Expand Up @@ -218,6 +218,8 @@ our class CArray is repr('CArray') is array_type(Pointer) {
$what;
}

method Str { self.join(' ') }

method elems { nqp::elems(self) }

method list {
Expand Down

0 comments on commit b7379a8

Please sign in to comment.