[perl5] Use sv_setpvn() to set a scalar from a pointer and length
- patch from SF#174460 by "matsubaray". git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9937 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
c836c81acb
commit
e2d7f303b8
6 changed files with 28 additions and 13 deletions
8
Examples/test-suite/li_cdata_carrays.i
Normal file
8
Examples/test-suite/li_cdata_carrays.i
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
%module li_cdata_carrays
|
||||
|
||||
%include <carrays.i>
|
||||
%array_class(int, intArray);
|
||||
|
||||
%include <cdata.i>
|
||||
|
||||
%cdata(int);
|
||||
|
|
@ -16,11 +16,12 @@ CPP_TEST_CASES += \
|
|||
primitive_types \
|
||||
li_cdata \
|
||||
li_cstring \
|
||||
li_cdata_carrays \
|
||||
|
||||
C_TEST_CASES += \
|
||||
li_cdata \
|
||||
li_cstring \
|
||||
|
||||
li_cdata_carrays \
|
||||
|
||||
include $(srcdir)/../common.mk
|
||||
|
||||
|
|
|
|||
11
Examples/test-suite/perl5/li_cdata_carrays_runme.pl
Normal file
11
Examples/test-suite/perl5/li_cdata_carrays_runme.pl
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
use li_cdata_carrays;
|
||||
|
||||
$a = li_cdata_carrays::intArray->new(5);
|
||||
for (0..4) {
|
||||
$a->setitem($_, $_**2);
|
||||
}
|
||||
$x = pack q{I5}, map $_**2, (0..4);
|
||||
$y = li_cdata_carrays::cdata_int($a->cast, 5);
|
||||
if ( $x ne $y ) {
|
||||
die "$x vs $y";
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue