man C::Scan () - scan C language files for easily recognized constructs.

NAME

C::Scan - scan C language files for easily recognized constructs.

SYNOPSIS

  $c = new C::Scan 'filename' => $filename, 'filename_filter' => $filter,
                   'add_cppflags' => $addflags;
  $c->set('includeDirs' => [$Config::Config{shrpdir}]);

  my $fdec = $c->get('parsed_fdecls');

DESCRIPTION

This description is BIVERY incomplete.

This module uses CWData::Flow interface, thus one uses it in the following fashion:

  $c = new C::Scan(attr1 => $value1, attr2 => $value2);
  $c->set( attr3 => $value3 );

  $value4 = $c->get('attr4');

Attributes are depending on some other attributes. The only required attribute, i.e., the attribute which should be set, is CWfilename, which denotes which file to parse.

All other attributes are either optional, or would be calculated basing on values of required and optional attributes.

Output attributes

Value: reference to a list of included files. Value: reference to hash of macros with arguments. The values are references to an array of length 2, the first element is a reference to the list of arguments, the second one being the expansion. Newlines are not unescaped, thus

  #define C(x,y) E\
                 F
will finish with CW("C" => [ ["x", "y"], "E\nF"]). Value: reference to hash of macros without arguments. Newlines are not escaped, thus
  #define A B
will finish with CW("A" => "B"). Value: reference to list of declarations of functions. Value: reference to list of definitions of functions. Value: reference to list of parsed declarations of functions. A parsed declaration is a reference to a list of CW(rt, nm, args, ft, mod). Here CWrt is return type of a function, CWnm is the name, CWargs is the list of arguments, CWft is the full text of the declaration, and CWmod is the modifier (which is always CWundef). Each entry in the list CWargs is of the same form CW(ty, nm, args, ft, mod), here CWty is the type of an argument, CWnm is the name (a generated one if missing in the declaration), CWargs is CWundef, and CWmod is the string of array modifiers. Value: a reference to a hash which contains known CWtypedefs as keys. Values of the hash are array references of length 2, with what should be put before/after the type for a standalone typedef declaration (but without the CWtypedef substring). Parse uses naive heuristics. Value: a reference to a list which contains known expansions of CWtypedefs. Value: a reference to a list of CWtypedefed names. Heuristics are used. Value: a reference to a list of CWextern variable declarations. Value: a reference to a hash of parsed CWextern variable declarations, containing the variable names as keys. Values of the hash are array references of length 2, with what should be put before/after the name for a standalone extern variable declaration (but without the CWextern substring). Value: a reference to a hash of parsed struct declarations from typedefs. Keys are typedefed names, values are CWundef if not a struct or union, else an array reference of definitions of the elements of the structure; each definition is itself an array reference of length 3, consisting of what should be put before/after the name for a standalone variable declaration, followed by the name of the element. Anonymous structs and unions used within the definitions are given an arbitrary name including the string CWANON, and referred to using that name.