Loading ...
Sorry, an error occurred while loading the content.
 

advice on writing a wrapper to a C library

Expand Messages
  • Paul Archer
    I need to use libusb from Perl, but there s no (usable) wrapper for it--so I thought that I would (with the help of the Houston PM group) write one. I ve got a
    Message 1 of 2 , Jan 23, 2006
      I need to use libusb from Perl, but there's no (usable) wrapper for it--so I
      thought that I would (with the help of the Houston PM group) write one.

      I've got a couple of questions:

      Are there any documents that lay out any sort of standard for wrappers to C
      libraries?

      If not, is using an OO style, and dropping the first part of the C function
      name (a good way|the best way) to go about it? Eg:
      my $usb = Device::USB::LibUSB->init;
      $usb->control_msg(bunch, o, params);

      where the C functions are usb_init and usb_control_msg, respectively?

      And should the Perl wrapper check the params for validity? For example, if
      the C function takes an unsigned char, should Perl check to make sure that
      it's passing something in the range of 0-255, or should it assume that the
      Perl programmer knows what they're doing, and give them the rope to hang
      them selves?

      Paul


      ----------------------------------------------------------------
      Q: What do Winnie-the-Pooh and John the Baptist have in common?
      A: Their middle name.
      ----------------------------------------------------------------
    Your message has been successfully submitted and would be delivered to recipients shortly.