Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

Creating a new module with an XS submodule

by kikuchiyo (Pilgrim)
on Feb 14, 2013 at 23:09 UTC ( #1018810=perlquestion: print w/replies, xml ) Need Help??
kikuchiyo has asked for the wisdom of the Perl Monks concerning the following question:

I want to create a module that will provide a Perl interface to a specific file format. (The format itself is still under development at this point, that's why I don't write details here.)

I want to re-use the project's reference parser, written in C, to do the parsing for me, however, I want to keep the XS part in a sub-module. Specifically, if the main module, providing the user interface, will be called MyFormat::Simple, then I'd want to put the XS module that interfaces with the C parser in MyFormat::Simple::Parser::XS.

Three notes here:
  • MyFormat is obviously just a placeholder.
  • I've chosen not to use the top namespace MyFormat directly, anticipating that if the format proves to be successful, other people will want to use it for their modules.
  • In addition to the XS-based parser, a pure-perl MyFormat::Simple::Parser::PP may be developed later, and the main module could fall back to it if the XS module is not available for some reason.

Now my question is, how to set about to create all this? More specifically, which module creation framework to use, and how exactly?

Should I run h2xs twice, separately, for the two modules, once with -X for the main module that doesn't need XS, and once with -x for the XS module?

Or should I use some other supposedly better and more modern tool, like Dist::Zilla for the non-XS module?

Or should I create just one module skeleton, and work inside it on the submodule as well?

I appreciate any help.

  • Comment on Creating a new module with an XS submodule

Replies are listed 'Best First'.
Re: Creating a new module with an XS submodule
by Anonymous Monk on Feb 15, 2013 at 17:25 UTC

      I know about Inline::C, I've used it in the past, but I don't see how it could help me here. I was under the impression that it is primarily for embedding C code in perl scripts quickly and easily, whereas I want to create a proper module that I eventually want to release on CPAN.

      My question was more about module organization, anyway.

      none, they don't really help

      Would you care to elaborate on that?

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://1018810]
Approved by ww
Front-paged by BrowserUk
[Discipulus]: testicles..
[LanX]: well as long as they are your *own* testicles...
[Discipulus]: oh and only with your left hand!
LanX is relieved!
marto wonders what the hell people are talking about

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (6)
As of 2018-04-26 10:14 GMT
Find Nodes?
    Voting Booth?