00:02 colomon joined 02:40 colomon joined 02:47 ilbot3 joined 03:24 camelia joined 05:45 vendethiel joined 06:47 japhb joined 07:17 japhb joined 09:58 rurban__ joined 10:33 tgt joined
dalek arVM/native-ref: 86bf121 | jnthn++ | src/6model/reprs/P6opaque.c:
Liberalize mixin prefix test in P6opaque.

Up to the point we hit the first attribute-contributing class, we can skip the checking. This makes the Perl 6 MOP re-parenting not break the ability to mix in to meta-objects.
11:26
12:03 mj41 joined 13:04 colomon joined 13:21 rurban__ joined 13:55 colomon joined 15:22 zakharyas joined
FROGGS perl6-m -MNativeCall -e 'sub PolygonShape_Set_ZN14b2PolygonShape3SetEPK6b2Vec2i(OpaquePointer, int32) is native("libBox2D") { * }; _ZN14b2PolygonShape3SetEPK6b2Vec2i(OpaquePointer, 0)' 16:11
moar: /build/buildd/box2d-2.3.0+ds/Box2D/Box2D/Collision/Shapes/b2PolygonShape.cpp:122: void b2PolygonShape::Set(const b2Vec2*, int32): Assertion `3 <= count && count <= 8' failed.
I find that quite encouraging
ohh, I pasted the subname wrong, it is called like in the actual call 16:12
I guess I have to use the thiscall calling convention here? 16:17
hmm no, seems not 16:20
"All mangled symbols begin with _Z (note that an underscore followed by a capital is a reserved identifier in C, so conflict with user identifiers is avoided); for nested names (including both namespaces and classes), this is followed by N, then a series of <length, id> pairs (the length being the length of the next identifier), and finally E." 17:08
that seems to agree with this example: _ZN14b2PolygonShape3SetEPK6b2Vec2i 17:09
sort of
17:10 mj41 joined
FROGGS _ZN 14b2PolygonShape 3Set E PK 6b2Vec2 i 17:10
m: sub foo::bar() { 42 }; say foo::bar 17:14
camelia rakudo-moar d9f58f: OUTPUT«Could not find symbol '&bar'␤ in method <anon> at src/gen/m-CORE.setting:14609␤ in any find_method_fallback at src/gen/m-Metamodel.nqp:2810␤ in any find_method at src/gen/m-Metamodel.nqp:992␤ in block <unit> at /tmp/sKXHLm8vbH:1␤␤»
FROGGS a very minimal case generates the symbol correctly: gist.github.com/FROGGS/7c8180851f3b89821631 17:39
17:42 FROGGS[mobile] joined
timotimo is that the gcc specific mangling or something? 18:28
18:40 FROGGS[mobile] joined
FROGGS timotimo: en.wikipedia.org/wiki/Name_mangling..._functions 18:47
must be g++ on an ubuntu machine I think
dalek arVM/native-ref: 71fd576 | jnthn++ | src/ (3 files):
Implement iscont_[ins].
18:48
18:51 rurban__ joined
FROGGS I guess in b2PolygonShape::Set(b2Vec2 const*, int), which is `thiscall`, I need to pass the "THIS" as the first arg? 19:46
jnthn has really no idea, sorry :( 19:48
Also, wtf: "Spesh inline: unhandled arg instruction"
FROGGS O.o 19:49
jnthn Seems it might be a constant named arg that triggers it. 19:56
Ah, no 20:09
FROGGS 0000000000000000 T _ZN7b2WorldC1ERK6b2Vec2 20:11
0000000000000110 T _ZN7b2WorldD1Ev
the first is a constructor, the latter a destructor btw
("C" vs "D")
jnthn eek 20:14
Such mangle...
FROGGS I enjoy it :o)
dalek arVM/native-ref: 679d06f | jnthn++ | src/spesh/inline.c:
Add missing inline arg count check.

We only collect information on up to a certain number of args. Without this, we try to resolve arg instructions beyond the end of the buffer, which innevitably works out rather badly.
20:17
arVM/native-ref: b23351a | jnthn++ | src/spesh/inline.c:
Improve error by including unhandled op.
arVM/native-ref: da8fbed | jnthn++ | src/spesh/inline.c:
Handle argconst_ instructions in inline.

Fix order of args passed to lexical ref function.
arVM/native-ref: d5ef005 | jnthn++ | src/6model/reprs/NativeRef.c:
Implement by-index native lexical ref support.
21:19 Peter_R joined
FROGGS ahh: 21:20
my $gravity = OpaquePointer<140737326674832>
Program received signal SIGSEGV, Segmentation fault.
b2World::b2World (this=0x4d36840, gravity=...) at /build/buildd/box2d-2.3.0+ds/Box2D/Box2D/Dynamics/b2World.cpp:55
even for a constructor I have to pass THIS
jnthn ah :) 21:22
FROGGS [Inferior 1 (process 5976) exited normally] \o/
THIS as in malloc'd to the right size (... I don't know how to calculate) 21:23
jnthn Sounds like good progress :)
FROGGS I mean, look at class World, I dunno how vtable and all these things are layed out in mem: box2d.googlecode.com/svn/tags/v2.3..../b2World.h 21:24
jnthn FROGGS: Can't help but wonder if the easier way would be to write a small wrapper that exposes a C-friendly API... 21:29
Though, that would need compiling. 21:30
FROGGS jnthn: that'd mean that every user of a C++ would have to do that
which... is not trivial
jnthn Well, if they're using C++ they're already used to pain, at least... :P
FROGGS :P
I see how far I get, if it proves to be too hard, I'll take another route 21:31
but atm, it is a nice project
jnthn is curious what other languages have a C++ FFI approach that doesn't need some kind of C wrapper 21:34
FROGGS jnthn: python 21:36
and Java probably
you'd probably know about C# 21:37
jnthn FROGGS: search.cpan.org/~plicease/FFI-Platy...ang/CPP.pm may be of interest, fwiw
FROGGS jnthn: very nice! 21:39
"You need to alloate the memory needed for the object before you call the constructor[...]" aye :o) 21:40
ohh damn, it, I can call a method on my b2World instance! 21:46
timotimo <3 21:47
FROGGS this could be end up very sweet... like have native methods in a CStruct... 21:49
so I am doing this: 21:52
# alloc $world
new_World($world, b2Vec2.new(x => 42e0, y => 42e0));
World_Dump($world);
and I get in my shell:
b2Vec2 g(4.200000000000000e+01f, 4.200000000000000e+01f);
m_world->SetGravity(g);
b2Body** bodies = (b2Body**)b2Alloc(0 * sizeof(b2Body*));
[...]
the vector I pass to the world's constructor is the gravity 21:53
to allocate the world I just fill a buf8 with a hundred elements :o)
for C++ I guess we'd want to have 'is native' and 'is symbol' on class definitions too, as well as on methods 21:55
22:00 FROGGS[mobile] joined
jnthn Not going to make it all the way to "is rw" on native params today, but got many (most, I hope) of the groundwork in place by now :) 22:04
22:04 FROGGS_ joined
TimToady \o/ anyway :) 22:05
timotimo i'm liking it, too
TimToady likes to see the C++ progress too
it was really strange to hear that XS doesn't support C++, since the original XS was written specifically to call into C++ code 22:06
jnthn went through 3 different designs for integrating the native ref stuff with QAST::Var before finding one he liked. :)
TimToady and part of why P5 supported OO was to ease the mismatch with C++
timotimo jnthn: i'd rather have you try multiple different things than pull through the first thing you try even if it's not 100% to you rliking
FROGGS_ ohh, we already allow 'is native' on methods and we probably already pass self/this along 22:10
jnthn FROGGS_: I...uh...wow, that's a happy accident! o.O 22:11
timotimo methods are routines ... dunno if it know sabout the invocant? 22:12
jnthn (You're right, I think, it just wasn't actually a design consideration. :))
Well, not a concious one
I wonder if we could have a is repr('CPPClass') or so
FROGGS_ we probably need to 22:13
timotimo can the given mangling convention of a library be figured out somehow? perhaps just listing the available symbols in a library or so?
TimToady that was part of why we invented repr poly in the first place...
FROGGS_ star-m: use NativeCall; class Foo is repr<CStruct> { method malloc(int32) is native is symbol<malloc> { * } }; Foo.new.malloc(32) 22:15
camelia star-m 2015.01: OUTPUT«Unknown type Mu used in native call.␤If you want to pass a struct, be sure to use the CStruct representation.␤If you want to pass an array, be sure to use the CArray type.␤ in sub type_code_for at /home/camelia/rakudo-star-2015.01/install/languages/perl…»
FROGGS_ I could have bet that it failed differently :/
like, showing that we pass self along
jnthn is off for the night 22:20
o/
timotimo good night jnthn!
FROGGS_ gnight jnthn 22:21
japhb FROGGS_++ # Working on C++ support. 22:30
Really, I can't even tell you how much that would improve things for me at $day-job, where lots of the deep infrastructure is written in C++, and SWIG is all over the place. 22:32
FROGGS_ ohh, that sounds motivating :o) 22:33
m: class Foo { method bar { } }; Foo.^find_method('bar').signature.params».type.say
camelia rakudo-moar d9f58f: OUTPUT«(Foo) (Mu)␤»
FROGGS_ what's that Mu? the implicit *%?
m: class Foo { method bar { } }; Foo.^find_method('bar').signature.params».name.say # :o) 22:34
camelia rakudo-moar d9f58f: OUTPUT«Nil %_␤»
FROGGS_ introspection ftw
japhb *chuckle* Well, that's one way to find out. :-)
japhb <3 deep Perl 6 introspection 22:35
FROGGS_ aye
:o)
timotimo areed 22:44