sanko / Affix.pm

A Foreign Function Interface eXtension for Perl
https://metacpan.org/dist/Affix
Artistic License 2.0
1 stars 0 forks source link

Sugar to wrap C++ classes #32

Open sanko opened 1 year ago

sanko commented 1 year ago

With Itanium mangling somewhat functional, defining and calling this methods should be handled internally.

sanko commented 1 year ago
typedef 'MyClass' => Class[
    [ speed => 'set_speed' ] => Method [ [Int] => Void ],
    speed                    => Method [ []    => Int ],
    private                  => [ fuel => Float ],
    speed                    => Int,
    driver                   => Str
];

Something like this? Usage would be something like...

my $car = MyClass->new( speed => 0, driver => 'Mike' );
$car->set_speed(100);
print $car->speed;

Edit: In the above examples, MyClass::speed() would be _ZN7MyClass5speedEv and MyClass::set_speed($) would be _ZN7MyClass5speedEi in Itanium.

sanko commented 1 year ago

As of this comment, C++ class support includes:

I haven't wrapped a full C++ yet to test how unwieldy that is.