Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

implement typed pointer increment and array dereference salortiz++ #1186

Merged
merged 1 commit into from Oct 10, 2017

Conversation

dwarring
Copy link
Contributor

@dwarring dwarring commented Oct 7, 2017

The following now works.

use NativeCall;
my CArray[uint16] $a .= new: 10, 20 ... 100;
my $p = nativecast(Pointer[uint16], $a);

# pointer increment
++$p;
say $p.deref; # 20
# array dereferencing
say $p[2];  ; # 40

Addresses RT #128000. Based on NativeHelpers::Pointer implementation salortiz++

This enables:

        use NativeCall;
        my CArray[uint16] $a .= new: 10, 20 ... 100;
        my $p = nativecast(Pointer[uint16], $a);

        ++$p;
        say $p.deref; # 20
        say $p[2];  ; # 40

    Addresses RT #128000. Based on NativeHelpers::Pointer implementation salortiz++
@dwarring
Copy link
Contributor Author

I'm currently working on a port of Perl 5's Font::FreeType to Perl 6 (https://github.com/p6-pdf/Font-FreeType-p6).

I'm finding it handy to think in terms of pointers and pointer dereferencing.

@zoffixznet zoffixznet merged commit e19b340 into rakudo:nom Oct 10, 2017
@zoffixznet
Copy link
Contributor

👍 Thanks! Would it be possible for you to document this feature, so users know about it?

@dwarring
Copy link
Contributor Author

thanks! will do.

@dwarring dwarring deleted the pointer++ branch October 10, 2017 22:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants