Skip to content

Instantly share code, notes, and snippets.

@arnsholt
Created August 29, 2013 15:52
Show Gist options
  • Select an option

  • Save arnsholt/6379906 to your computer and use it in GitHub Desktop.

Select an option

Save arnsholt/6379906 to your computer and use it in GitHub Desktop.
From cdeabc2ba7f357b886184c2a73b8beb48e1720c9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Arne=20Skj=C3=A6rholt?= <arnsholt@gmail.com>
Date: Thu, 29 Aug 2013 17:51:29 +0200
Subject: [PATCH] Temporary commit for jnthn.
---
lib/NativeCall.pm6 | 7 +++++--
t/02-simple-args.t | 14 +++++++-------
2 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/lib/NativeCall.pm6 b/lib/NativeCall.pm6
index 7cf6906..6b7eba1 100644
--- a/lib/NativeCall.pm6
+++ b/lib/NativeCall.pm6
@@ -261,13 +261,16 @@ class CStr is repr('CStr') {
}
role ExplicitlyManagedString {
- has CStr $.cstr is rw;
+ has CStr $!cstr;
+
+ method set-cstr($str) { $!cstr = $str; }
}
multi explicitly-manage(Str $x is rw, :$encoding = 'utf8') is export(:DEFAULT,
:utils) {
$x does ExplicitlyManagedString;
- $x.cstr = pir::repr_box_str__PsP(nqp::unbox_s($x), CStr[$encoding]);
+ #$x.cstr = pir::repr_box_str__PsP(nqp::unbox_s($x), CStr[$encoding]);
+ $x.set-cstr(pir::repr_box_str__PsP(nqp::unbox_s($x), CStr[$encoding]));
}
multi refresh($obj) is export(:DEFAULT, :utils) {
diff --git a/t/02-simple-args.t b/t/02-simple-args.t
index f619679..d30151e 100644
--- a/t/02-simple-args.t
+++ b/t/02-simple-args.t
@@ -25,13 +25,13 @@ sub TakeAString(Str) is native('./02-simple-args') { * }
TakeAString('ok 9 - passed a string');
# Explicitly managing strings
-say 'ok 10 - SKIP issue 28: Cannot create rw-accessors for natively typed attribute';
-# sub SetString(Str) is native('./02-simple-args') { * }
-# sub PrintString() is native('./02-simple-args') { * }
-# my $str = 'ok 10 - delayed string print';
-# explicitly-manage($str);
-# SetString($str);
-# PrintString();
+#say 'ok 10 - SKIP issue 28: Cannot create rw-accessors for natively typed attribute';
+sub SetString(Str) is native('./02-simple-args') { * }
+sub PrintString() is native('./02-simple-args') { * }
+my $str = 'ok 10 - delayed string print';
+explicitly-manage($str);
+SetString($str);
+PrintString();
# Make sure wrapped subs work
sub wrapped(int) is native('./02-simple-args') { * }
--
1.7.9.5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment