00:21 xiaomiao joined 00:40 kjs_ joined 02:47 ilbot3 joined 03:34 colomon joined 03:52 colomon joined 06:02 vendethiel joined 07:32 vendethiel joined 08:25 vendethiel joined 08:53 rurban joined 09:06 camelia joined 09:13 vendethiel joined 10:21 vendethiel joined 10:24 mj41 joined 10:28 FROGGS joined 11:03 camelia joined
FROGGS $ perl6-m -e 'class Foo is repr<CStruct> { has buf8 $.bar }' 11:28
===SORRY!===
CStruct representation only handles int, num, CArray, CPointer and CStruct but got a Uninstantiable
:o(
12:12 FROGGS_ joined 12:20 zakharyas joined 12:32 kjs_ joined 12:58 Ven joined
FROGGS_ jnthn: how do I pun the buf8 role into a class in repr/CStruct.c? 13:13
this is also needed to return a VMArray like a buf8 13:16
I need this basically: m: say Buf[uint8].^make_pun; 13:25
m: say Buf[uint8].^make_pun;
camelia rakudo-moar 9fc66c: OUTPUT«(Buf[uint8])␤»
FROGGS_ I guess I can/should do that in NativeCall... 13:34
at least for the returns trait
$ perl6-m -e 'use NativeCall; sub malloc(int32) returns buf8 is native { * }; say malloc(1)' 13:47
Buf[uint8]:0x<>
okay, trouble here is of course that we don't know its .elems... 13:48
looks like we cannot allow blobs in CStruct attribute or as return types of native subs :/ 13:56
unless we'd know the elems in beforehand 14:04
14:28 zakharyas joined 15:24 hoelzro_ joined, timotimo joined, muraiki joined 15:35 brrt joined 16:12 kjs_ joined 16:18 brrt joined
FROGGS_ hmmm, would be nice to be able to inline structures... 16:26
timotimo yes please 16:27
FROGGS_ that an unions seem equally hard 16:38
timotimo i thought unions would be trivial 16:39
i looked at the code that places the slots in a CStruct and it looked like you could just "not increment" the starting position 16:41
FROGGS_ how do you do that at Perl 6 level?
like, having num32 and int32 share the same memory 16:42
timotimo since you always just access those via getattr and bindattr, i don't think that's too difficult 16:43
FROGGS_ m: class Foo { has num32|int32 $.bar }
camelia rakudo-moar 9fc66c: OUTPUT«===SORRY!===␤Type 'num32' is not declared␤at /tmp/SqukKpL9ND:1␤------> class Foo { has num32⏏|int32 $.bar }␤Malformed has␤at /tmp/SqukKpL9ND:1␤------> class Foo { has num32⏏|int32 $.bar }␤␤»
timotimo and if they want to be rw, you'll end up using jnthn's new native attr code
ah, that's what you're asking
FROGGS_ :o)
timotimo well, you'd have to build a class that's repr CUnion or something 16:44
or is repr CStruct is union OSLT
FROGGS_ ahh, and inline that one...
timotimo well, i'd expect putting a CUnion repr'd class into a struct would inline by default, but i can see why you might want to have a pointer to such a union sometimes 16:45
FROGGS_ inline by default will happen anyway I think
timotimo so you'd have to "is pointer" if you want a pointer instead? 16:46
FROGGS_ given that 'int32 $bar is rw' as a parameter declaration will mean 'int *bar' in near future
is rw
timotimo ... oh?
FROGGS_ aye
timotimo i didn't know that
FROGGS_ and it kinda makes sense to call it 'is rw' for attributes 16:47
timotimo oh? 16:48
FROGGS_ because you can shove update the pointer to another structure, whereas you cannot do that if the structure was inlined
s/shove//
timotimo i'd like to have CStruct classes with "is rw" attributes just so that i can modify them without writing my own accesors
FROGGS_ true
I know what you mean: 16:52
method Set(Num $x, Num $y) {
nqp::bindattr_n(nqp::decont(self), Box2D::Vec2, '$!x', nqp::unbox_n($x));
nqp::bindattr_n(nqp::decont(self), Box2D::Vec2, '$!y', nqp::unbox_n($y));
}
-.-
timotimo hrhr
and with the native refs that jnthn made it'll be much more efficient than having to bindattr all the time
fwiw, i don't like the "is rw" for "is actually a pointer" very much 16:58
TimToady if we're trying to be C-like, we really want it as part of the type, not tacked on as a trait 17:03
Ptr[MyType] or so 17:04
timotimo hm, we have a CPointer REPR 17:07
a role for this would indeed be nice. 17:11
17:46 camelia joined 17:51 kjs_ joined, brrt joined
FROGGS_ timotimo: that was my first thought too 18:05
Pointer[int32]
maybe we should TIMTOWTDI the whole thing 18:06
dalek arVM/cpp: 953c022 | coke++ | macports/Portfile:
Add a macports Portfile
19:07
arVM/cpp: c462d90 | coke++ | / (2 files):
delint Portfile, move to correct location
arVM/cpp: cad876f | FROGGS++ | src/6model/reprs/CStruct.h:
make clear what strict_size is about
arVM/cpp: dc0bd10 | FROGGS++ | / (8 files):
implement nativecallsizeof of
arVM/cpp: c314d3d | FROGGS++ | src/core/nativecall.c:
return number of bytes from MVM_nativecall_sizeof

allow to nativesizeof(CPPStruct)
19:33 brrt joined 19:41 kjs_ joined 19:53 hoelzro joined 19:55 dalek joined
brrt please review this commit, i'll push it to master if you're ok with it :-) github.com/bdw/MoarVM/commit/a70d7...26bd4dee52 20:24
fwiw, the label: { block } syntax is pretty nice in C 20:26
FROGGS_ that's working code: github.com/FROGGS/p6-Box2D/blob/ma...locator.pm 20:45
brrt FROGGS_++
FROGGS_ tested here: github.com/FROGGS/p6-Box2D/blob/ma...llocator.t 20:46
I like the Pointer role :o)
brrt nice
i'm going to push since spectest was clean (enough) 20:47
dalek arVM: 8352aeb | brrt++ | src/io/fileops.c:
Rewrite MVM_file_copy

The old version could not handle file sizes larger than 2GB
  (on linux, at least). This version uses a loop to correct
for the fact that sendfile doesn't necessarily send all bytes you request.
FROGGS_ brrt: I would not spot an error anyway :o)
brrt i tried to make it a bit cleaner than the 3-level-deep nested ifs 20:48
FROGGS_ it is still hairy
like C in general
brrt i like C, i don't think it's that hairy 20:50
but then again, i like exactness in my code, and c lets you be as exact (or conversely as sloppy) as you like 20:51
FROGGS_ yeah, true
brrt afk 21:02
21:02 brrt left
FROGGS TimToady / timotimo / jnthn: we can now have typed pointers (e.g. Pointer[MyStruct], they have a deref method) as params, attrs and return types 22:38
timotimo and pointer arithmetic, too, yeah?
FROGGS TimToady / timotimo / jnthn: it is implemented in the cpp branch, but is not cpp specific
timotimo: gah!
:P
timotimo: you are welcome to jump in :o) 22:39
(dunno if that idiom works in English at all)
m: use NativeCall; sub malloc(int32) returns OpaquePointer is native { * }; say my $p = malloc(32); say OpaquePointer.new( $p + 8 ) 22:41
camelia rakudo-moar d850a9: OUTPUT«OpaquePointer<0x5e1f790>␤OpaquePointer<0x5e1f798>␤»
FROGGS timotimo: ^^
not convenient but works
and since we have nativesizeof and you can cast a certain pointer to a struct you can basically unpack a memory area into structs 22:42
gnight 22:51
timotimo i like that 23:03