Skip to content

Instantly share code, notes, and snippets.

@FROGGS
Created February 9, 2015 14:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save FROGGS/239a936c29bf0873c38f to your computer and use it in GitHub Desktop.
Save FROGGS/239a936c29bf0873c38f to your computer and use it in GitHub Desktop.
use NativeCall;
class b2Vec2 is repr<CStruct> {
has num32 $.x;
has num32 $.y;
}
class b2World is repr<CPPStruct> {
has OpaquePointer $.data;
method new(b2Vec2) is symbol<b2World::new> is native("libBox2D") { * }
method Dump() is symbol<b2World::Dump> is native("libBox2D") { * }
}
my $vec = b2Vec2.new(x => 42e0, y => 42e0);
my $w = b2World.new($vec);
$w.Dump; # that will print:
# b2Vec2 g(4.200000000000000e+01f, 4.200000000000000e+01f);
# m_world->SetGravity(g);
# b2Body** bodies = (b2Body**)b2Alloc(0 * sizeof(b2Body*));
# b2Joint** joints = (b2Joint**)b2Alloc(0 * sizeof(b2Joint*));
# b2Free(joints);
# b2Free(bodies);
# joints = NULL;
# bodies = NULL;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment