Created
January 2, 2016 10:43
-
-
Save bpetering/02f5062933ba6db2933f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
#include <stdlib.h> | |
struct foo { | |
int x; | |
}; | |
void foo_init(struct foo **f) { | |
*f = malloc(sizeof(struct foo)); | |
printf("malloc'd, pointer = %p\n", (void *) *f); | |
} | |
void foo_shutdown(struct foo *f) { | |
printf("freeing, pointer = %p\n", (void *) f); | |
free(f); | |
} | |
void foo_test() { printf("foo\n"); } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use NativeCall; | |
class foo is repr('CPointer') { } | |
sub foo_init(Pointer[foo] $x is rw) | |
is native('test') | |
{ * } | |
sub foo_shutdown(foo) | |
is native('test') | |
{ * } | |
sub foo_test() | |
is native('test') | |
{ * } | |
# foo_test(); # works | |
my Pointer[foo] $p; | |
foo_init($p); | |
say $p.deref; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment