Parrot 4.8.0 "Spix's Macaw" | parrot.org/ | Log: irclog.perlgeek.de/parrot | #parrotsketch meeting Tuesday 19:30 UTC
Set by moderator on 11 October 2012.
00:08 benabik joined 00:38 dbcooper joined 02:39 bluescreen joined 04:44 bluescreen joined 06:46 Administrator joined 06:59 zby_home joined 07:18 Mike-PerlRecruiter_ joined 09:02 mobile joined 09:41 fperrad joined
dalek kudo/nom: edb767a | moritz++ | src/core/Str.pm:
allow substr($str, $first, Inf)
10:23
10:57 whiteknight joined
whiteknight good morning, #parrot 12:00
moritz good morning, whiteknight 12:01
in C, how do I call a method on PMC of which I know that it returns a string? 12:02
I guess I frist need to use VTABLE_find_method to get the method object
and then? Parrot_pcc_invoke_sub_from_c_args? or Parrot_ext_call? 12:03
12:08 PacoAir joined 12:13 not_gerd joined
not_gerd whiteknight: I opened an issue ( github.com/parrot/parrot/issues/860 ) with some more information 12:14
12:16 ligne joined 13:04 Psyche^ joined
moritz nqp: say(nqp::chars(pir::trans_encoding__SSI('ø', pir::find_encoding__Is('binary'))); 13:26
p6eval nqp: OUTPUT«Confused at line 2, near "say(nqp::c"␤current instr.: 'panic' pc 20014 (src/stage2/gen/NQPHLL.pir:7316) (src/stage2/gen/NQPHLL.pm:324)␤»
moritz nqp: say(nqp::chars(pir::trans_encoding__SSI('ø', pir::find_encoding__Is('binary'))));
p6eval nqp: OUTPUT«1␤»
moritz why does that print 1 instead of 2? 13:27
I thought 'ø' would be an UTF-8 string, and changing it binary would produce two bytes 13:28
nqp: say(nqp::chars(pir::trans_encoding__SSI('€', pir::find_encoding__Is('binary')))); 13:29
p6eval nqp: OUTPUT«Lossy conversion to single byte encoding␤current instr.: '' pc 46 ((file unknown):42) (/tmp/4yergZqlju:1)␤»
moritz that one is even more confusing to me
are binary strings documented anywhere? 13:33
not_gerd moritz: my guess would be this is due to the fact that your first example is in latin-1 13:34
moritz not_gerd: might be, yes 13:35
anyway, I don't understand how converting anything to binary can be a lossy conversion 13:37
probably because there's a mismatch between what parrot considers a binary string, and what I do 13:38
which is why I'm asking for documentation
not_gerd moritz: there's always the source 13:48
binary uses the fixed8 encoder, ie just accepts any unicode char with value <= 0xFF
moritz so binary is a synonym for Latin-1? 13:49
can I somehow convert an UTF-8 string to a binary string with the same bytes? 13:50
not_gerd moritz: it's not equivalent to latin-1 as it fails for many string operations
to get at the bytes, you'll probably poke into the backing buffer 13:51
no idea if there's an API for that
*need to poke
moritz: creating a ByteBuffer PMC from the string appears to do what you want 13:58
moritz not_gerd: well, currently i want to avoid ByteBuffer, because nqp and rakudo can't serialize them 13:59
not_gerd moritz: I can tell you how to do it using the C API, but that's probably not very helpful 14:03
moritz not_gerd: well, i could write a custom opcode once I know how it's done in C :-) 14:04
not_gerd moritz: you can pass the string's strstart and bufused to Parrot_api_string_import_binary(), or use Parrot_str_new_init() directly 14:06
the former is a thin wrapper for the latter
oh - the proper way is probably to string->bytebuffer->string 14:07
moritz that's still an option, yes 14:08
14:11 arnsholt joined
moritz tries it 14:14
not_gerd bye, #parrot 14:45
14:45 not_gerd left
rurban_home moritz: binary strings are a bit crippled in parrot. I enhanced them in some branch, but forgot in which. They behaved like ByteBuffer's then 14:47
I had exactly the same problem you are facing. 14:48
dalek kudo/nom: 837d0f8 | moritz++ | src/core/ (4 files):
switch Buf from ByteBuffer to binary string storage

the serializer knows how serialize strings, but not ByteBuffer; should fix #114500
15:19
p: 86b5b43 | moritz++ | / (2 files):
fix command line parsing (RT #114720)
16:03
kudo/nom: 0d2140b | moritz++ | tools/build/NQP_REVISION:
bump NQP revision to get command line parser improvements
16:04
whiteknight how are binary strings crippled in parrot? 16:24
16:24 whiteknight joined
whiteknight moritz: Sorry, I didn't see your earlier question about invoking a method from C 16:29
Moritz: from NQP-land code, if you already have the method object, best is probably Parrot_ext_call() 16:30
STRING reg = STRINGNULL;
Parrot_ext_call(interp, method, "Pi->S", obj, &reg);
Pi is the invocant, S is the returned string 16:31
moritz whiteknight: ok, thanks
16:32 benabik joined 17:08 brrt joined
brrt ping whiteknight 17:31
17:39 contingencyplan joined
pmichaud I just added another note to #860 -- it looks to me like the encoding and/or record_separator attributes of the Handle PMC may be prematurely recycled by GC 18:43
at least, I can't find where they're being marked. (I've never completely been able to follow how marking works when PObj_custom_mark_SET() isn't called.) 18:44
that looks like a bug of sorts to me -- the previous version of handle.pmc apparently didn't have any STRING attributes. 18:45
(previous version == version in 4.6.0) 18:46
afk for a while.
18:51 tuxit joined 19:20 Mike-PerlRecruiter_ joined
dalek kudo/nom: dfbfbb9 | moritz++ | src/core/terms.pm:
Add another dir to @*INC

In the long run I want panda and R* to install the modules there, instead of ~./perl6/lib, which is shared among different Rakudo versions. Currently this means that if you have precompiled modules in ~/.perl6/lib, R* fails to compile modules.
You can find this new dir with perl6 -e 'say $*CUSTOM-LIB' Better names are very welcome :-)
19:46
kudo/nom: 8a07b84 | moritz++ | src/core/terms.pm:
refine $*CUSTOM-LIB

panda wants a prefix below which it creates bin/ lib/ and panda/ dirs. So now @*INC containts "$*CUSTOM-LIB/lib" by default
20:20
21:04 tuxit joined 21:58 contingencyplan joined 23:28 benabik joined