| 1 |
|
| #define PERL_NO_GET_CONTEXT |
| 2 |
|
| #include "EXTERN.h" |
| 3 |
|
| #include "perl.h" |
| 4 |
|
| #include "XSUB.h" |
| 5 |
|
| #include "ppport.h" |
| 6 |
|
| |
| 7 |
|
| /* C functions */ |
| 8 |
|
| int |
| 9 |
1 |
| use_scoped_variable(int size) |
| 10 |
|
| { |
| 11 |
1 |
▶ | if (size < 1) { |
Branch: 1 branch
| Branch | True | False | Total |
| if (size < 1) { |
0 |
1 |
1 |
|
| 12 |
0 |
| size = -size; |
| 13 |
|
| } |
| 14 |
|
| |
| 15 |
1 |
| int x = 0; |
| 16 |
11 |
▶ | for(int i=0; i< size; ++i) { |
Branch: 1 branch
| Branch | True | False | Total |
| for(int i=0; i< size; ++i) { |
10 |
1 |
11 |
|
| 17 |
10 |
| x += i; |
| 18 |
|
| } |
| 19 |
|
| |
| 20 |
1 |
| return x; |
| 21 |
|
| } |
| 22 |
|
| |
| 23 |
|
| MODULE = Devel::CCompat::C99::ScopedVariables PACKAGE = Devel::CCompat::C99::ScopedVariables |
| 24 |
|
| PROTOTYPES: DISABLE |
| 25 |
|
| |
| 26 |
|
| # XS code |
| 27 |
|
| |
| 28 |
|
| int |
| 29 |
|
| create_scoped_variable(int size) |
| 30 |
|
| CODE: |
| 31 |
1 |
▶ | if(size <= 0) { |
Branch: 1 branch
| Branch | True | False | Total |
| if(size <= 0) { |
0 |
1 |
1 |
|
| 32 |
0 |
| croak("size must be positive\n"); |
| 33 |
|
| } |
| 34 |
1 |
| RETVAL = use_scoped_variable(size); |
| 35 |
|
| OUTPUT: RETVAL |
| 36 |
|
| |