Class::HPLOO::InlineC is a Perl module that adds a pseudo syntax over C to work easier with SV*, AV*, HV* and RV*.
Who have worked with XS and perlapi knows that to access values from AV* and HV*, and work with references is not very friendly. To work arounf that I have added a pseudo syntax over the C syntax, that helps to work easily with SV*, AV*, HV* and RV*.
USAGE
use Class::HPLOO ;
class Point {
sub Point ($x , $y) {
$this->{x} = $x ;
$this->{y} = $y ;
}
sub move_x( $mv_x ) {
$this->{x} += $mv_x ;
}
sub[C] void move_y( SV* self , int mv_y ) {
int y = self->{y}->int + mv_y ;
self->{y} = int2sv(y) ;
}
sub[C] SV* get_xy_ref( SV* self ) {
AV* ret = newAV() ;
ret->[0] = self->{x} ;
ret->[1] = self->{y} ;
return {ret} ;
}
}
my $p = Point->new(10,20) ;
$p->move_x(100) ;
$p->move_y(100) ;
my $xy = $p->get_xy_ref() ; ## returns an ARRAY reference.
print "XY> @$xyn" ; ## XY> 110 120
As you can see, is very easy to access and set an integer value from $Point->{y} (at self). Also is simple to create an ARRAY and return a reference to it.
Requirements:
· Perl
Product's homepage
Requirements:
· Perl