Questions tagged [xs]

XS is a language extension for Perl that can wrap a C library to make it a Perl library.

The documentation is available at http://perldoc.perl.org/perlxs.html.

The characters "xs" are also a commonly-used name for the XML Schema namespace. Questions about XML Schema should use .

130 questions
3
votes
2 answers

How to use PERL XS to call a C++ function that takes in a STL Vector

I have been using PerlXS to write a perl wrapper around a C++ Object. Usually my fcn takes in a string/int etc and I can just make them with no problem. I just write code like this in the .xs file MyClass::func_a(std::string a, int b); This time; I…
shergill
  • 3,738
  • 10
  • 41
  • 50
3
votes
0 answers

Perl XS :Shared library link

I am fairly new to perl and I am trying to use XS to call a particular C function from my perl script.I am trying to call the C function from an test script from now.I am getting the following error on running "make test" - PERL_DL_NONLAZY=1…
3
votes
1 answer

Should be there newSVuv instead newSVnv in perlxstut?

I'm just going through perlxstut and I found there newSVnv in EXAMPLE 5 and EXAMPLE 6 but I think that newSVuv should be more appropriate. Curiously newSVnv works too. What's going on?
Hynek -Pichi- Vychodil
  • 26,174
  • 5
  • 52
  • 73
3
votes
2 answers

Procedural and object oriented interface in Perl/XS

I am currently writing my first XS-module (just a wrapper around the C math-library) with ok-ish success. The biggest issue is the documentation that is quite hard to understand and/or is incomplete. I have successfully written a constructor in XS…
user2875983
  • 303
  • 2
  • 6
3
votes
1 answer

Is it possible to use/create/modify SV/HV/AV outside of the main thread?

I am trying to create SV with newSVpvn() in the new thread created with pthread_create(). At this point my program crashes. C function where crash occures looks like this void *_inet_aton(void *v_arg) { SV* rv = &PL_sv_undef; struct…
Oleg G
  • 925
  • 4
  • 12
3
votes
2 answers

Using struct with Perl XS

I am new to Perl XS and I am trying to convert a C function to Perl subroutine. I have the following C function void parse(struct parser *result, const char *string, size_t len); where the parse function accepts a pointer to struct parser, a string…
smith
  • 3,232
  • 26
  • 55
3
votes
2 answers

How to interface c++ and perl using XS?

This is a school thing. Here's the problem: We're working on a Bomberman clone, and we have to implement a scripting interface, allowing the user to make his own "artificial intelligence". We chose to use Perl. Right now, I build the perl module…
Arkeopix
  • 77
  • 1
  • 7
3
votes
1 answer

Access system constants using ExtUtils::Constants

I'm trying to export C constants from a system header using ExtUtils::Constant. As per the doc, I have in Makefile.PL: ExtUtils::Constant::WriteConstants ( NAME => 'Foo::Bar', NAMES => [ qw(EPOLLIN EPOLLOUT) ] ); Then in Bar.xs: #include…
CodeClown42
  • 11,194
  • 1
  • 32
  • 67
3
votes
1 answer

Why does sv_setref_pv() store its void * argument in the IV slot?

When looking at the Perl API, I was wondering why sv_setref_iv() stores its IV argument in the IV slot, sv_setref_nv() stores its NV argument in the NV slot, but sv_setref_pv() stores its void * argument in the IV slot, instead of the PV slot? I…
Edward
  • 486
  • 4
  • 14
3
votes
1 answer

How can I use an Ada module in a Perl program using XS?

I started learning Ada recently and knowing that Ada and C object files can be linked together to build a multilingual program or library, is it possible to call Ada code from Perl using XS?
Cahu
  • 249
  • 2
  • 9
3
votes
1 answer

leak while blessing an empty reference inside the XS code

I am trying to do a XS equivalent of this: package RefTestPP; use strict; use warnings; sub new { my ($class, $self) = (@_, {}); return bless $self, $class; } 1; This kind of constructor is supposed to "autovivify" it's base when called…
creaktive
  • 5,193
  • 2
  • 18
  • 32
3
votes
1 answer

In XS, how do I get a variables address from its name?

In XS, how do I turn a string that holds a variable name into its address, I want to do something like the following perl code: our $var = 1; print ${$main::{var}};
Chas. Owens
  • 64,182
  • 22
  • 135
  • 226
2
votes
3 answers

How can I use a C linked list from Perl XS?

I writing programing with Perl and XS. I need to display and do some operations that use a linked list from C. How can I accomplish that?
joe
  • 34,529
  • 29
  • 100
  • 137
2
votes
1 answer

How to tell MakeMaker to build XS files in a subdirectory?

I've got a largish project to which I've just added some XS code, and I'd like to keep the top-level directory as clean as possible. I want to put the XS file and typemap et al. into a subdirectory, but if I do, MakeMaker can't find them. So right…
Hercynium
  • 929
  • 9
  • 18
2
votes
2 answers

How do I compile an XS module from CPAN manually?

I just downloaded an XS module from CPAN, but want to compile it by hand, not using cpan. Running perl Makefile.PL and make creates .c, .o, .xs and .bs files, but I don't see any .pm to put in my path. What am I missing? I don't want to make install…
Andreas
  • 7,470
  • 10
  • 51
  • 73
1 2 3
8 9