Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^3: Ignoring subs in Test::Pod::Coverage?

by marioroy (Prior)
on Jul 01, 2017 at 22:52 UTC ( [id://1194014]=note: print w/replies, xml ) Need Help??


in reply to Re^2: Ignoring subs in Test::Pod::Coverage?
in thread Ignoring subs in Test::Pod::Coverage?

Hi stevieb. Another way is prefixing the functions considered private with an underscore.

_ads1115Setup _analogRead _analogWrite _bmp180Pressure

Replies are listed 'Best First'.
Re^4: Ignoring subs in Test::Pod::Coverage?
by stevieb (Canon) on Jul 01, 2017 at 23:11 UTC

    Thanks marioroy, I've considered that, but that would require some structural changes to the XS (however, I'm not overly against doing so).

    Currently, I have my XSUBs loaded as they are direct from the C libraries themselves, when I don't need to wrap them again locally:

    void digitalWriteByte(value) int value void digitalWriteByte2(value) int value # SPI int wiringPiSPISetup(channel, speed) int channel int speed

    Other ones have full-blown C wrappers as stated, then the XSUB calls the actual function:

    Wrapper:

    void spiDataRW(int channel, SV* byte_ref, int len){ /* * Custom wrapper for wiringPiSPIDataRW() as we * need to translate an aref into an unsigned char *, * and then send back an array containing the bytes * read from the device */ if (channel != 0 && channel != 1){ croak("channel param must be 0 or 1\n"); } if (! SvROK(byte_ref) || SvTYPE(SvRV(byte_ref)) != SVt_PVAV){ croak("data param must be an array reference\n"); } AV* bytes = (AV*)SvRV(byte_ref); int num_bytes = av_len(bytes) + 1; if (len != num_bytes){ croak("len param doesn't match element count in data\n"); } unsigned char buf[num_bytes]; int i; for (i=0; i<len; i++){ SV** elem = av_fetch(bytes, i, 0); int elem_int = (int)SvNV(*elem); if (elem_int < 0 || elem_int > 255){ printf("byte %d in data param out of range: (%d)\n", i, el +em_int); exit(1); } buf[i] = (unsigned char)SvNV(*elem); } if (wiringPiSPIDataRW(channel, buf, len) < 0){ croak("failed to write to the SPI bus\n"); } inline_stack_vars; inline_stack_reset; int x; for (x=0; x<len; x++){ inline_stack_push(sv_2mortal(newSViv(buf[x]))); } inline_stack_done; }

    The wrapper in XS then calls the C function I'm wrapping with the manipulated arguments:

    void spiDataRW (channel, byte_ref, len) int channel SV * byte_ref int len PREINIT: I32* temp; PPCODE: temp = PL_markstack_ptr++; spiDataRW(channel, byte_ref, len); if (PL_markstack_ptr != temp) { PL_markstack_ptr = temp; XSRETURN_EMPTY; } return;

    I've been 'learning' for a full year at this stuff amongst other things, but I'm no where near proficient. I have learned about using the PREFIX directive in my XS code, and that'll likely help.

    What I think is that preceeding everything with the Perl private notation may not work here very easily as there is a lot going on. I will play though. I've got everything exceptionally stable, all tests pass against everything, so I'm relatively content.

    I'm going to leave well enough alone for the time being, and poke my CI test software for a bit, to fix some issues there. This task can wait; I just thought another question wouldn't hurt here ;)

    Cheers,

    -stevieb

    ps. In the example given where I do trickery turning a perl aref into a char pointer, I know thanks to the Monks how to do that stuff with pack etc, I just haven't changed it yet. This XS trickery can be avoided, but I like to learn ;)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1194014]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2024-04-18 03:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found