File Coverage

blib/lib/C/Blocks.pm
Criterion Covered Total %
statement 22 40 55.0
branch n/a
condition n/a
subroutine 8 15 53.3
pod n/a
total 30 55 54.5


line stmt bran cond sub pod time code
1             ########################################################################
2             package C::Blocks;
3             ########################################################################
4              
5 28     28   517026 use strict;
  28         57  
  28         1008  
6 28     28   129 use warnings;
  28         40  
  28         1075  
7 28     28   132 use warnings::register qw(import compiler linker);
  28         53  
  28         9660  
8              
9 28     28   16025 use Alien::TinyCCx;
  28         405119  
  28         1288  
10 28     28   223 use XSLoader;
  28         69  
  28         4824  
11              
12             # Use David Golden's version numbering suggestions. Note that we have to call
13             # the XSLoader before evaling the version string because XS modules check the
14             # version *string*, not the version *number*, at boot time.
15             our $VERSION = "0.41";
16             XSLoader::load('C::Blocks', $VERSION);
17             $VERSION = eval $VERSION;
18              
19             our (@__code_cache_array, @__symtab_cache_array, @__dll_list_array);
20             our $default_compiler_options = "-Wall -D_C_BLOCKS_OS_$^O ";
21             our $compiler_options = $default_compiler_options;
22             our @libraries_to_link;
23             our ($_add_msg_functions, $_msg);
24              
25             sub import {
26 0     0     my $class = shift;
27 0           my $caller = caller;
28 28     28   151 no strict 'refs';
  28         43  
  28         6572  
29 0     0     *{$caller.'::cblock'} = sub () {};
  0            
30 0     0     *{$caller.'::csub'} = sub () {};
  0            
31 0     0     *{$caller.'::cshare'} = sub () {};
  0            
32 0     0     *{$caller.'::clex'} = sub () {};
  0            
33 0           _import();
34             }
35              
36             # Provided so I can call warnings::warnif from Blocks.xs. Why can't I
37             # just call warnings::warnif from that code directly???? XXX
38             sub warnif {
39 0     0     my ($category, $message) = @_;
40 0           warnings::warnif($category, $message);
41             }
42              
43             # The XS code for the keyword parser makes sure that if a module invokes cshare,
44             # it is also a descendent of C::Blocks::libloader. The only reason it does that
45             # is to make sure that this function has a good chance of getting invoked when
46             # somebody tries to use the module. This function adds its module's symtab list
47             # (a series of pointers) to the calling lexical scope's hints hash. These
48             # symtabs are consulted during compilation of cblock declarations in the calling
49             # lexical scope.
50             sub C::Blocks::libloader::import {
51             # Get the name of the module that is being imported.
52 0     0     my ($module) = @_;
53            
54             # Get the use'd module's symbol table list
55 0           my $symtab_list = do {
56 28     28   160 no strict 'refs';
  28         45  
  28         3346  
57 0           ${"${module}::__cblocks_extended_symtab_list"}
  0            
58             };
59            
60             # add the symtab list to the calling context's hints hash
61 0           $^H{"C::Blocks/extended_symtab_tables"} .= $symtab_list;
62             }
63              
64             END {
65 26     26   3685 _cleanup();
66             }
67              
68             1;
69              
70             __END__