@@ -2249,20 +2249,20 @@ package ExtUtils::ParseXS; # XXX tmp
2249
2249
# block which can follow an xsub signature or CASE keyword.
2250
2250
2251
2251
sub INPUT_handler {
2252
- my ExtUtils::ParseXS $self = shift ;
2253
- my $line = shift ;
2252
+ my ExtUtils::ParseXS $self = shift ;
2253
+ my $line = shift ;
2254
2254
2255
- # In this loop: process each line until the next keyword or end of
2256
- # paragraph.
2255
+ # In this loop: process each line until the next keyword or end of
2256
+ # paragraph.
2257
2257
2258
- for (; $line !~ / ^$ExtUtils::ParseXS::BLOCK_regexp /o ; $line = shift (@{ $self -> {line } })) {
2259
- # treat NOT_IMPLEMENTED_YET as another block separator, in addition to
2260
- # $BLOCK_regexp.
2261
- last if $line =~ / ^\s *NOT_IMPLEMENTED_YET/ ;
2258
+ for (; $line !~ / ^$ExtUtils::ParseXS::BLOCK_regexp /o ; $line = shift (@{ $self -> {line } })) {
2259
+ # treat NOT_IMPLEMENTED_YET as another block separator, in addition to
2260
+ # $BLOCK_regexp.
2261
+ last if $line =~ / ^\s *NOT_IMPLEMENTED_YET/ ;
2262
2262
2263
- $self -> INPUT_handler_line($line );
2264
- } # foreach line in INPUT block
2265
- $_ = $line ;
2263
+ $self -> INPUT_handler_line($line );
2264
+ } # foreach line in INPUT block
2265
+ $_ = $line ;
2266
2266
}
2267
2267
2268
2268
@@ -2273,8 +2273,8 @@ package ExtUtils::ParseXS; # XXX tmp
2273
2273
# process a single line from an INPUT section
2274
2274
2275
2275
sub INPUT_handler_line {
2276
- my ExtUtils::ParseXS $self = shift ;
2277
- my $line = shift ;
2276
+ my ExtUtils::ParseXS $self = shift ;
2277
+ my $line = shift ;
2278
2278
2279
2279
return unless $line =~ / \S / ; # skip blank lines
2280
2280
@@ -2310,77 +2310,77 @@ sub INPUT_handler_line {
2310
2310
# int a XYZ;
2311
2311
2312
2312
my ($var_type , $var_addr , $var_name ) =
2313
- $line =~ / ^
2314
- ( .*? [^&\s ] ) # type
2315
- \s *
2316
- (\& ?) # addr
2317
- \s * \b
2318
- (\w + | length\(\w +\) ) # name or length(name)
2319
- $
2320
- /xs
2321
- or $self -> blurt(" Error: invalid parameter declaration '$orig_line '" ), return ;
2313
+ $line =~ / ^
2314
+ ( .*? [^&\s ] ) # type
2315
+ \s *
2316
+ (\& ?) # addr
2317
+ \s * \b
2318
+ (\w + | length\(\w +\) ) # name or length(name)
2319
+ $
2320
+ /xs
2321
+ or $self -> blurt(" Error: invalid parameter declaration '$orig_line '" ), return ;
2322
2322
2323
2323
# length(s) is only allowed in the XSUB's signature.
2324
2324
if ($var_name =~ / ^length\( (\w +)\) $ / ) {
2325
- $self -> blurt(" Error: length() not permitted in INPUT section" );
2326
- return ;
2325
+ $self -> blurt(" Error: length() not permitted in INPUT section" );
2326
+ return ;
2327
2327
}
2328
2328
2329
2329
my ($var_num , $is_alien );
2330
2330
2331
2331
my ExtUtils::ParseXS::Node::Param $param
2332
- = $self -> {xsub_sig }{names }{$var_name };
2332
+ = $self -> {xsub_sig }{names }{$var_name };
2333
2333
2334
2334
2335
2335
if (defined $param ) {
2336
- # The var appeared in the signature too.
2337
-
2338
- # Check for duplicate definitions of a particular parameter name.
2339
- # This can be either because it has appeared in multiple INPUT
2340
- # lines, or because the type was already defined in the signature,
2341
- # and thus shouldn't be defined again. The exception to this are
2342
- # synthetic params like THIS, which are assigned a provisional type
2343
- # which can be overridden.
2344
- if ( $param -> {in_input }
2345
- or (!$param -> {is_synthetic } and defined $param -> {type })
2346
- ) {
2347
- $self -> blurt(
2348
- " Error: duplicate definition of parameter '$var_name ' ignored" );
2349
- return ;
2350
- }
2351
-
2352
- if ($var_name eq ' RETVAL' and $param -> {is_synthetic }) {
2353
- # Convert a synthetic RETVAL into a real parameter
2354
- delete $param -> {is_synthetic };
2355
- delete $param -> {no_init };
2356
- if (! defined $param -> {arg_num }) {
2357
- # if has arg_num, RETVAL has appeared in signature but with no
2358
- # type, and has already been moved to the correct position;
2359
- # otherwise, it's an alien var that didn't appear in the
2360
- # signature; move to the correct position.
2361
- @{$self -> {xsub_sig }{params }} =
2362
- grep $_ != $param , @{$self -> {xsub_sig }{params }};
2363
- push @{$self -> {xsub_sig }{params }}, $param ;
2364
- $is_alien = 1;
2365
- $param -> {is_alien } = 1;
2336
+ # The var appeared in the signature too.
2337
+
2338
+ # Check for duplicate definitions of a particular parameter name.
2339
+ # This can be either because it has appeared in multiple INPUT
2340
+ # lines, or because the type was already defined in the signature,
2341
+ # and thus shouldn't be defined again. The exception to this are
2342
+ # synthetic params like THIS, which are assigned a provisional type
2343
+ # which can be overridden.
2344
+ if ( $param -> {in_input }
2345
+ or (!$param -> {is_synthetic } and defined $param -> {type })
2346
+ ) {
2347
+ $self -> blurt(
2348
+ " Error: duplicate definition of parameter '$var_name ' ignored" );
2349
+ return ;
2350
+ }
2351
+
2352
+ if ($var_name eq ' RETVAL' and $param -> {is_synthetic }) {
2353
+ # Convert a synthetic RETVAL into a real parameter
2354
+ delete $param -> {is_synthetic };
2355
+ delete $param -> {no_init };
2356
+ if (! defined $param -> {arg_num }) {
2357
+ # if has arg_num, RETVAL has appeared in signature but with no
2358
+ # type, and has already been moved to the correct position;
2359
+ # otherwise, it's an alien var that didn't appear in the
2360
+ # signature; move to the correct position.
2361
+ @{$self -> {xsub_sig }{params }} =
2362
+ grep $_ != $param , @{$self -> {xsub_sig }{params }};
2363
+ push @{$self -> {xsub_sig }{params }}, $param ;
2364
+ $is_alien = 1;
2365
+ $param -> {is_alien } = 1;
2366
+ }
2366
2367
}
2367
- }
2368
2368
2369
- $param -> {in_input } = 1;
2370
- $var_num = $param -> {arg_num };
2369
+ $param -> {in_input } = 1;
2370
+ $var_num = $param -> {arg_num };
2371
2371
}
2372
2372
else {
2373
- # The var is in an INPUT line, but not in signature. Treat it as a
2374
- # general var declaration (which really should have been in a
2375
- # PREINIT section). Legal but nasty: flag is as 'alien'
2376
- $is_alien = 1;
2377
- $param = ExtUtils::ParseXS::Node::Param-> new({
2378
- var => $var_name ,
2379
- is_alien => 1,
2380
- });
2381
-
2382
- push @{$self -> {xsub_sig }{params }}, $param ;
2383
- $self -> {xsub_sig }{names }{$var_name } = $param ;
2373
+ # The var is in an INPUT line, but not in signature. Treat it as a
2374
+ # general var declaration (which really should have been in a
2375
+ # PREINIT section). Legal but nasty: flag is as 'alien'
2376
+ $is_alien = 1;
2377
+ $param = ExtUtils::ParseXS::Node::Param-> new({
2378
+ var => $var_name ,
2379
+ is_alien => 1,
2380
+ });
2381
+
2382
+ push @{$self -> {xsub_sig }{params }}, $param ;
2383
+ $self -> {xsub_sig }{names }{$var_name } = $param ;
2384
2384
}
2385
2385
2386
2386
# Parse the initialisation part of the INPUT line (if any)
@@ -2389,54 +2389,54 @@ sub INPUT_handler_line {
2389
2389
my $no_init = $param -> {no_init }; # may have had OUT in signature
2390
2390
2391
2391
if (!$no_init && defined $init_op ) {
2392
- # Emit the init code based on overridden $var_init, which was
2393
- # preceded by /[=;+]/ which has been extracted into $init_op
2394
-
2395
- if ( $init_op =~ / ^[=;]$ /
2396
- and $var_init =~ / ^NO_INIT\s *;?\s *$ /
2397
- ) {
2398
- # NO_INIT: skip initialisation
2399
- $no_init = 1;
2400
- }
2401
- elsif ($init_op eq ' =' ) {
2402
- # Overridden typemap, such as '= ($type)SvUV($arg)'
2403
- $var_init =~ s / ;\s *$// ;
2404
- $init = $var_init ,
2405
- }
2406
- else {
2407
- # "; extra code" or "+ extra code" :
2408
- # append the extra code (after passing through eval) after all the
2409
- # INPUT and PREINIT blocks have been processed, indirectly using
2410
- # the $self->{xsub_deferred_code_lines} mechanism.
2411
- # In addition, for '+', also generate the normal initialisation
2412
- # code from the standard typemap - assuming that it's a real
2413
- # parameter that appears in the signature as well as the INPUT
2414
- # line.
2415
- $no_init = !($init_op eq ' +' && !$is_alien );
2416
- # But in either case, add the deferred code
2417
- $defer = $var_init ;
2418
- }
2392
+ # Emit the init code based on overridden $var_init, which was
2393
+ # preceded by /[=;+]/ which has been extracted into $init_op
2394
+
2395
+ if ( $init_op =~ / ^[=;]$ /
2396
+ and $var_init =~ / ^NO_INIT\s *;?\s *$ /
2397
+ ) {
2398
+ # NO_INIT: skip initialisation
2399
+ $no_init = 1;
2400
+ }
2401
+ elsif ($init_op eq ' =' ) {
2402
+ # Overridden typemap, such as '= ($type)SvUV($arg)'
2403
+ $var_init =~ s / ;\s *$// ;
2404
+ $init = $var_init ,
2405
+ }
2406
+ else {
2407
+ # "; extra code" or "+ extra code" :
2408
+ # append the extra code (after passing through eval) after all the
2409
+ # INPUT and PREINIT blocks have been processed, indirectly using
2410
+ # the $self->{xsub_deferred_code_lines} mechanism.
2411
+ # In addition, for '+', also generate the normal initialisation
2412
+ # code from the standard typemap - assuming that it's a real
2413
+ # parameter that appears in the signature as well as the INPUT
2414
+ # line.
2415
+ $no_init = !($init_op eq ' +' && !$is_alien );
2416
+ # But in either case, add the deferred code
2417
+ $defer = $var_init ;
2418
+ }
2419
2419
}
2420
2420
else {
2421
- # no initialiser: emit var and init code based on typemap entry,
2422
- # unless: it's alien (so no stack arg to bind to it)
2423
- $no_init = 1 if $is_alien ;
2421
+ # no initialiser: emit var and init code based on typemap entry,
2422
+ # unless: it's alien (so no stack arg to bind to it)
2423
+ $no_init = 1 if $is_alien ;
2424
2424
}
2425
2425
2426
2426
%$param = (
2427
- %$param ,
2428
- type => $var_type ,
2429
- arg_num => $var_num ,
2430
- var => $var_name ,
2431
- defer => $defer ,
2432
- init => $init ,
2433
- init_op => $init_op ,
2434
- no_init => $no_init ,
2435
- is_addr => !!$var_addr ,
2427
+ %$param ,
2428
+ type => $var_type ,
2429
+ arg_num => $var_num ,
2430
+ var => $var_name ,
2431
+ defer => $defer ,
2432
+ init => $init ,
2433
+ init_op => $init_op ,
2434
+ no_init => $no_init ,
2435
+ is_addr => !!$var_addr ,
2436
2436
);
2437
2437
2438
2438
$param -> check($self )
2439
- or return ;
2439
+ or return ;
2440
2440
2441
2441
# Emit "type var" declaration and possibly various forms of
2442
2442
# initialiser code.
@@ -2449,6 +2449,7 @@ sub INPUT_handler_line {
2449
2449
$param -> as_code($self );
2450
2450
}
2451
2451
2452
+
2452
2453
# ======================================================================
2453
2454
2454
2455
0 commit comments