Permalink
Browse files

Support opaque pointers in NativeCall.

  • Loading branch information...
1 parent d22dd75 commit 4561a4f4c843512b03262410bcf0ee30d81237eb @jnthn jnthn committed Nov 28, 2011
Showing with 5 additions and 0 deletions.
  1. +5 −0 lib/NativeCall.pm6
View
@@ -61,6 +61,8 @@ sub type_code_for(Mu ::T) {
if %type_map.exists(T.^name);
return 'cstruct'
if T.REPR eq 'CStruct';
+ return 'cpointer'
+ if T.REPR eq 'CPointer';
die "Unknown type {T.^name} used in native call.\n" ~
"If you want to pass a struct, be sure to use the CStruct representation.\n" ~
"If you want to pass an array, be sure to use the CArray type.";
@@ -102,6 +104,9 @@ my role NativeCallEncoded[$name] {
method native_call_encoded() { $name };
}
+# Expose an OpaquePointer class for working with raw pointers.
+my class OpaquePointer is export is repr('CPointer') { }
+
# Specifies that the routine is actually a native call, and gives
# the name of the library to load it from.
multi trait_mod:<is>(Routine $r, $libname, :$native!) is export {

0 comments on commit 4561a4f

Please sign in to comment.