1Convert::Binary::C::CacUhseedr(3C)ontributed Perl DocumeCnotnavteirotn::Binary::C::Cached(3)
2
3
4
6 Convert::Binary::C::Cached - Caching for Convert::Binary::C
7
9 use Convert::Binary::C::Cached;
10 use Data::Dumper;
11
12 #------------------------
13 # Create a cached object
14 #------------------------
15 $c = Convert::Binary::C::Cached->new(
16 Cache => '/tmp/cache.c',
17 Include => [
18 '/usr/lib/gcc/i686-pc-linux-gnu/4.1.2/include',
19 '/usr/include',
20 ],
21 );
22
23 #----------------------------------------------------
24 # Parse 'time.h' and dump the definition of timespec
25 #----------------------------------------------------
26 $c->parse_file('time.h');
27
28 print Dumper($c->struct('timespec'));
29
31 Convert::Binary::C::Cached simply adds caching capability to
32 Convert::Binary::C. You can use it in just the same way that you would
33 use Convert::Binary::C. The interface is exactly the same.
34
35 To use the caching capability, you must pass the "Cache" option to the
36 constructor. If you don't pass it, you will receive an ordinary
37 Convert::Binary::C object. The argument to the "Cache" option is the
38 file that is used for caching this object.
39
40 The caching algorithm automatically detects when the cache file cannot
41 be used and the original code has to be parsed. In that case, the
42 cache file is updated. An update of the cache file can be triggered by
43 one or more of the following factors:
44
45 · The cache file doesn't exist, which is obvious.
46
47 · The cache file is corrupt, i.e. cannot be parsed.
48
49 · The object's configuration has changed.
50
51 · The embedded code for a "parse" method call has changed.
52
53 · At least one of the files that the object depends on does not exist
54 or has a different size or a different modification or change
55 timestamp.
56
58 You cannot call "parse" or "parse_file" more that once when using a
59 Convert::Binary::C::Cached object. This isn't a big problem, as you
60 usually don't call them multiple times.
61
62 If a dependency file changes, but the change affects neither the size
63 nor the timestamps of that file, the caching algorithm cannot detect
64 that an update is required.
65
67 Copyright (c) 2002-2009 Marcus Holland-Moritz. All rights reserved.
68 This program is free software; you can redistribute it and/or modify it
69 under the same terms as Perl itself.
70
72 See Convert::Binary::C.
73
74
75
76perl v5.12.0 2009-04-18 Convert::Binary::C::Cached(3)