5 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK);
12 use options qw($options);
13 use output qw($output);
17 ########################################################################
22 my $class = ref($proto) || $proto;
24 bless ($self, $class);
26 my $file = \${$self->{FILE}};
27 my $found_comment = \${$self->{FOUND_COMMENT}};
28 my $found_declaration = \${$self->{FOUND_DECLARATION}};
29 my $create_function = \${$self->{CREATE_FUNCTION}};
30 my $found_function = \${$self->{FOUND_FUNCTION}};
31 my $found_function_call = \${$self->{FOUND_FUNCTION_CALL}};
32 my $found_line = \${$self->{FOUND_LINE}};
33 my $found_preprocessor = \${$self->{FOUND_PREPROCESSOR}};
34 my $found_statement = \${$self->{FOUND_STATEMENT}};
35 my $found_variable = \${$self->{FOUND_VARIABLE}};
39 $$found_comment = sub { return 1; };
40 $$found_declaration = sub { return 1; };
41 $$create_function = sub { return new c_function; };
42 $$found_function = sub { return 1; };
43 $$found_function_call = sub { return 1; };
44 $$found_line = sub { return 1; };
45 $$found_preprocessor = sub { return 1; };
46 $$found_statement = sub { return 1; };
47 $$found_variable = sub { return 1; };
52 ########################################################################
53 # set_found_comment_callback
55 sub set_found_comment_callback {
58 my $found_comment = \${$self->{FOUND_COMMENT}};
60 $$found_comment = shift;
63 ########################################################################
64 # set_found_declaration_callback
66 sub set_found_declaration_callback {
69 my $found_declaration = \${$self->{FOUND_DECLARATION}};
71 $$found_declaration = shift;
74 ########################################################################
75 # set_found_function_callback
77 sub set_found_function_callback {
80 my $found_function = \${$self->{FOUND_FUNCTION}};
82 $$found_function = shift;
85 ########################################################################
86 # set_found_function_call_callback
88 sub set_found_function_call_callback {
91 my $found_function_call = \${$self->{FOUND_FUNCTION_CALL}};
93 $$found_function_call = shift;
96 ########################################################################
97 # set_found_line_callback
99 sub set_found_line_callback {
102 my $found_line = \${$self->{FOUND_LINE}};
104 $$found_line = shift;
107 ########################################################################
108 # set_found_preprocessor_callback
110 sub set_found_preprocessor_callback {
113 my $found_preprocessor = \${$self->{FOUND_PREPROCESSOR}};
115 $$found_preprocessor = shift;
118 ########################################################################
119 # set_found_statement_callback
121 sub set_found_statement_callback {
124 my $found_statement = \${$self->{FOUND_STATEMENT}};
126 $$found_statement = shift;
129 ########################################################################
130 # set_found_variable_callback
132 sub set_found_variable_callback {
135 my $found_variable = \${$self->{FOUND_VARIABLE}};
137 $$found_variable = shift;
140 ########################################################################
147 my $refcurrent = shift;
149 my $refcolumn = shift;
151 my $refmatch = shift;
153 local $_ = $$refcurrent;
154 my $line = $$refline;
155 my $column = $$refcolumn;
158 if(s/^(?:$pattern)//s) {
159 $self->_update_c_position($&, \$line, \$column);
165 $self->_parse_c_until_one_of("\\S", \$_, \$line, \$column);
169 $$refcolumn = $column;
176 ########################################################################
179 # FIXME: Use caller (See man perlfunc)
184 my $file = \${$self->{FILE}};
192 $message = "parse error" if !$message;
196 my @lines = split(/\n/, $_);
198 $current .= $lines[0] . "\n" if $lines[0];
199 $current .= $lines[1] . "\n" if $lines[1];
202 if($output->prefix) {
203 $output->write("\n");
208 $output->write("$$file:$line." . ($column + 1) . ": $context: $message: \\\n$current");
210 $output->write("$$file:$line." . ($column + 1) . ": $context: $message\n");
216 ########################################################################
219 sub _parse_c_warning {
226 $output->write("$line." . ($column + 1) . ": $message\n");
229 ########################################################################
230 # _parse_c_until_one_of
232 sub _parse_c_until_one_of {
235 my $characters = shift;
236 my $refcurrent = shift;
238 my $refcolumn = shift;
241 local $_ = $$refcurrent;
242 my $line = $$refline;
243 my $column = $$refcolumn;
245 if(!defined($match)) {
247 $match = \$blackhole;
251 while(/^[^$characters]/s) {
254 if(s/^[^$characters\n\t\'\"]*//s) {
260 while(/^./ && !s/^\'//) {
276 $$match .= $submatch;
277 $column += length($submatch);
280 while(/^./ && !s/^\"//) {
296 $$match .= $submatch;
297 $column += length($submatch);
301 $$match .= $submatch;
307 $$match .= $submatch;
308 $column = $column + 8 - $column % 8;
310 $$match .= $submatch;
311 $column += length($submatch);
317 $$refcolumn = $column;
321 ########################################################################
324 sub _update_c_position {
329 my $refcolumn = shift;
331 my $line = $$refline;
332 my $column = $$refcolumn;
335 if(s/^[^\n\t\'\"]*//s) {
336 $column += length($&);
341 while(/^./ && !s/^\'//) {
343 $column += length($1);
347 $column += length($1);
350 $column += length($1);
358 while(/^./ && !s/^\"//) {
360 $column += length($1);
364 $column += length($1);
367 $column += length($1);
377 $column = $column + 8 - $column % 8;
382 $$refcolumn = $column;
385 ########################################################################
391 my $refcurrent = shift;
393 my $refcolumn = shift;
395 my $refstatements = shift;
396 my $refstatements_line = shift;
397 my $refstatements_column = shift;
399 local $_ = $$refcurrent;
400 my $line = $$refline;
401 my $column = $$refcolumn;
403 $self->_parse_c_until_one_of("\\S", \$_, \$line, \$column);
413 $self->_parse_c_until_one_of("\\S", \$_, \$line, \$column);
415 my $statements_line = $line;
416 my $statements_column = $column;
421 $self->_parse_c_until_one_of("\\{\\}", \$_, \$line, \$column, \$match);
425 $statements .= $match;
441 $$refcolumn = $column;
442 $$refstatements = $statements;
443 $$refstatements_line = $statements_line;
444 $$refstatements_column = $statements_column;
449 ########################################################################
450 # parse_c_declaration
452 sub parse_c_declaration {
455 my $found_declaration = \${$self->{FOUND_DECLARATION}};
456 my $found_function = \${$self->{FOUND_FUNCTION}};
458 my $refcurrent = shift;
460 my $refcolumn = shift;
462 local $_ = $$refcurrent;
463 my $line = $$refline;
464 my $column = $$refcolumn;
466 $self->_parse_c_until_one_of("\\S", \$_, \$line, \$column);
468 my $begin_line = $line;
469 my $begin_column = $column + 1;
471 my $end_line = $begin_line;
472 my $end_column = $begin_column;
473 $self->_update_c_position($_, \$end_line, \$end_column);
475 if(!&$$found_declaration($begin_line, $begin_column, $end_line, $end_column, $_)) {
480 my $function = shift;
483 my $calling_convention = shift;
484 my $return_type = shift;
486 my @arguments = shift;
487 my @argument_lines = shift;
488 my @argument_columns = shift;
495 } elsif(s/^(?:DEFAULT|DECLARE)_DEBUG_CHANNEL\s*\(\s*(\w+)\s*\)\s*//s) { # FIXME: Wine specific kludge
496 $self->_update_c_position($&, \$line, \$column);
497 } elsif(s/^__ASM_GLOBAL_FUNC\(\s*(\w+)\s*,\s*//s) { # FIXME: Wine specific kludge
498 $self->_update_c_position($&, \$line, \$column);
499 $self->_parse_c_until_one_of("\)", \$_, \$line, \$column);
503 } elsif(s/^(?:jump|strong)_alias//s) { # FIXME: GNU C library specific kludge
504 } elsif(s/^extern\s*\"C\"\s*{//s) {
505 $self->_update_c_position($&, \$line, \$column);
506 } elsif(s/^(?:__asm__|asm)\s*\(//) {
507 $self->_update_c_position($&, \$line, \$column);
508 } elsif($self->parse_c_typedef(\$_, \$line, \$column)) {
510 } elsif($self->parse_c_variable(\$_, \$line, \$column, \$linkage, \$type, \$name)) {
512 } elsif($self->parse_c_function(\$_, \$line, \$column, \$function)) {
513 if(&$$found_function($function))
515 my $statements = $function->statements;
516 my $statements_line = $function->statements_line;
517 my $statements_column = $function->statements_column;
519 if(defined($statements)) {
520 if(!$self->parse_c_statements(\$statements, \$statements_line, \$statements_column)) {
526 $self->_parse_c_error($_, $line, $column, "declaration");
531 $$refcolumn = $column;
536 ########################################################################
537 # parse_c_declarations
539 sub parse_c_declarations {
542 my $refcurrent = shift;
544 my $refcolumn = shift;
549 ########################################################################
552 sub parse_c_expression {
555 my $refcurrent = shift;
557 my $refcolumn = shift;
559 my $found_function_call = \${$self->{FOUND_FUNCTION_CALL}};
561 local $_ = $$refcurrent;
562 my $line = $$refline;
563 my $column = $$refcolumn;
565 $self->_parse_c_until_one_of("\\S", \$_, \$line, \$column);
568 if(s/^(.*?)(\w+\s*\()/$2/s) {
569 $self->_update_c_position($1, \$line, \$column);
571 my $begin_line = $line;
572 my $begin_column = $column + 1;
577 my @argument_columns;
578 if(!$self->parse_c_function_call(\$_, \$line, \$column, \$name, \@arguments, \@argument_lines, \@argument_columns)) {
582 if(&$$found_function_call($begin_line, $begin_column, $line, $column, $name, \@arguments))
584 while(defined(my $argument = shift @arguments) &&
585 defined(my $argument_line = shift @argument_lines) &&
586 defined(my $argument_column = shift @argument_columns))
588 $self->parse_c_expression(\$argument, \$argument_line, \$argument_column);
596 $self->_update_c_position($_, \$line, \$column);
600 $$refcolumn = $column;
605 ########################################################################
611 my $found_comment = \${$self->{FOUND_COMMENT}};
612 my $found_line = \${$self->{FOUND_LINE}};
614 my $refcurrent = shift;
616 my $refcolumn = shift;
618 local $_ = $$refcurrent;
619 my $line = $$refline;
620 my $column = $$refcolumn;
622 my $declaration = "";
623 my $declaration_line = $line;
624 my $declaration_column = $column;
626 my $previous_line = 0;
627 my $previous_column = -1;
634 while($plevel > 0 || $blevel > 0) {
636 $self->_parse_c_until_one_of("#/\\(\\)\\[\\]\\{\\};", \$_, \$line, \$column, \$match);
638 if($line != $previous_line) {
639 &$$found_line($line);
640 } elsif($column == $previous_column) {
641 $self->_parse_c_error($_, $line, $column, "file", "no progress");
643 # &$$found_line("$line.$column");
645 $previous_line = $line;
646 $previous_column = $column;
648 # $output->write("file: $plevel $blevel: '$match'\n");
650 if(!$declaration && $match =~ s/^\s+//s) {
651 $self->_update_c_position($&, \$declaration_line, \$declaration_column);
654 $declaration .= $match;
659 while(s/^.*?\n//) { $blank_lines++; }
662 $declaration_line = $line;
663 $declaration_column = $column;
665 $declaration .= "\n" x $blank_lines;
673 my $preprocessor_line = $line;
674 my $preprocessor_column = $column;
676 my $preprocessor = $&;
677 while(s/^(.*?)\\\s*\n//) {
679 $preprocessor .= "$1\n";
681 if(s/^(.*?)(\/\*.*?\*\/)(.*?)\n//) {
684 $preprocessor .= "$1$3";
688 } elsif(s/^(.*?)(\/[\*\/].*?)?\n//) {
697 if($if0 && $preprocessor =~ /^\#\s*endif/) {
705 } elsif($preprocessor =~ /^\#\s*if/) {
706 if($preprocessor =~ /^\#\s*if\s*0/) {
713 if(!$self->parse_c_preprocessor(\$preprocessor, \$preprocessor_line, \$preprocessor_column)) {
718 if(s/^\/\*.*?\*\///s) {
719 &$$found_comment($line, $column + 1, $&);
725 $column += length($_);
727 } elsif(s/^\/\/(.*?)\n//) {
728 &$$found_comment($line, $column + 1, $&);
737 $line += $blank_lines;
738 if($blank_lines > 0) {
743 $declaration_line = $line;
744 $declaration_column = $column;
745 } elsif($blank_lines > 0) {
746 $declaration .= "\n" x $blank_lines;
768 if($plevel == 1 && $declaration =~ /^__ASM_GLOBAL_FUNC/) {
769 if(!$self->parse_c_declaration(\$declaration, \$declaration_line, \$declaration_column)) {
772 $self->_parse_c_until_one_of("\\S", \$_, \$line, \$column);
774 $declaration_line = $line;
775 $declaration_column = $column;
783 if($declaration =~ /^typedef/s ||
784 $declaration =~ /^(?:const\s+|extern\s+|static\s+)*(?:struct|union)(?:\s+\w+)?\s*\{/s)
787 } elsif($plevel == 1 && $blevel == 1) {
788 if(!$self->parse_c_declaration(\$declaration, \$declaration_line, \$declaration_column)) {
791 $self->_parse_c_until_one_of("\\S", \$_, \$line, \$column);
793 $declaration_line = $line;
794 $declaration_column = $column;
795 } elsif($column == 1) {
796 $self->_parse_c_error("", $line, $column, "file", "inner } ends on column 1");
801 $declaration !~ /^typedef/ &&
802 $declaration !~ /^(?:const\s+|extern\s+|static\s+)(?:struct|union)(?:\s+\w+)?\s*\{/s &&
803 $declaration =~ /^(?:\w+\s*)*(?:(?:\*\s*)+|\s+)(\w+)\s*\(\s*(?:(?:\w+\s*,\s*)*\w+\s*)?\)(.*?);/s &&
804 $1 ne "ICOM_VTABLE" && $2) # K&R
806 $self->_parse_c_warning($line, $column, "function $1: warning: function has K&R format");
807 } elsif($plevel == 1 && $blevel == 1) {
808 $declaration =~ s/\s*;$//;
809 if($declaration && !$self->parse_c_declaration(\$declaration, \$declaration_line, \$declaration_column)) {
812 $self->_parse_c_until_one_of("\\S", \$_, \$line, \$column);
814 $declaration_line = $line;
815 $declaration_column = $column;
817 } elsif(/^\s*$/ && $declaration =~ /^\s*$/ && $match =~ /^\s*$/) {
821 $self->_parse_c_error($_, $line, $column, "file", "'$declaration' '$match'");
827 $$refcolumn = $column;
832 ########################################################################
835 sub parse_c_function {
838 my $file = \${$self->{FILE}};
839 my $create_function = \${$self->{CREATE_FUNCTION}};
841 my $refcurrent = shift;
843 my $refcolumn = shift;
845 my $reffunction = shift;
847 local $_ = $$refcurrent;
848 my $line = $$refline;
849 my $column = $$refcolumn;
852 my $calling_convention = "";
857 my @argument_columns;
860 my $statements_column;
862 $self->_parse_c_until_one_of("\\S", \$_, \$line, \$column);
864 my $begin_line = $line;
865 my $begin_column = $column + 1;
868 while($self->_parse_c('const|inline|extern|static|volatile|' .
869 'signed(?=\\s+char|s+int|\s+long(?:\s+long)?|\s+short)|' .
870 'unsigned(?=\s+char|\s+int|\s+long(?:\s+long)?|\s+short)',
871 \$_, \$line, \$column, \$match))
873 if($match =~ /^extern|static$/) {
883 } elsif($self->_parse_c('DECL_GLOBAL_CONSTRUCTOR', \$_, \$line, \$column, \$name)) { # FIXME: Wine specific kludge
885 } elsif($self->_parse_c('WINE_EXCEPTION_FILTER\(\w+\)', \$_, \$line, \$column, \$name)) { # FIXME: Wine specific kludge
888 if(!$self->parse_c_type(\$_, \$line, \$column, \$return_type)) {
892 $self->_parse_c("__cdecl|__stdcall|inline|CDECL|VFWAPIV|VFWAPI|WINAPIV|WINAPI|CALLBACK|WINE_UNUSED|PASCAL",
893 \$_, \$line, \$column, \$calling_convention);
895 if(!$self->_parse_c('\w+', \$_, \$line, \$column, \$name)) {
899 if(!$self->parse_c_tuple(\$_, \$line, \$column, \@arguments, \@argument_lines, \@argument_columns)) {
905 # FIXME: Implement proper handling of K&R C functions
906 $self->_parse_c_until_one_of("{", \$_, \$line, \$column, $kar);
909 $output->write("K&R: $kar\n");
912 if($_ && !$self->parse_c_block(\$_, \$line, \$column, \$statements, \$statements_line, \$statements_column)) {
916 my $end_line = $line;
917 my $end_column = $column;
921 $$refcolumn = $column;
923 my $function = &$$create_function;
925 $function->file($$file);
926 $function->begin_line($begin_line);
927 $function->begin_column($begin_column);
928 $function->end_line($end_line);
929 $function->end_column($end_column);
930 $function->linkage($linkage);
931 $function->return_type($return_type);
932 $function->calling_convention($calling_convention);
933 $function->name($name);
934 # if(defined($argument_types)) {
935 # $function->argument_types([@$argument_types]);
937 # if(defined($argument_names)) {
938 # $function->argument_names([@$argument_names]);
940 $function->statements_line($statements_line);
941 $function->statements_column($statements_column);
942 $function->statements($statements);
944 $$reffunction = $function;
949 ########################################################################
950 # parse_c_function_call
952 sub parse_c_function_call {
955 my $refcurrent = shift;
957 my $refcolumn = shift;
960 my $refarguments = shift;
961 my $refargument_lines = shift;
962 my $refargument_columns = shift;
964 local $_ = $$refcurrent;
965 my $line = $$refline;
966 my $column = $$refcolumn;
971 my @argument_columns;
973 if(s/^(\w+)(\s*)(?=\()//s) {
974 $self->_update_c_position($&, \$line, \$column);
978 if(!$self->parse_c_tuple(\$_, \$line, \$column, \@arguments, \@argument_lines, \@argument_columns)) {
987 $$refcolumn = $column;
990 @$refarguments = @arguments;
991 @$refargument_lines = @argument_lines;
992 @$refargument_columns = @argument_columns;
997 ########################################################################
998 # parse_c_preprocessor
1000 sub parse_c_preprocessor {
1003 my $found_preprocessor = \${$self->{FOUND_PREPROCESSOR}};
1005 my $refcurrent = shift;
1006 my $refline = shift;
1007 my $refcolumn = shift;
1009 local $_ = $$refcurrent;
1010 my $line = $$refline;
1011 my $column = $$refcolumn;
1013 $self->_parse_c_until_one_of("\\S", \$_, \$line, \$column);
1015 my $begin_line = $line;
1016 my $begin_column = $column + 1;
1018 if(!&$$found_preprocessor($begin_line, $begin_column, "$_")) {
1024 } elsif(/^\#\s*define\s*(.*?)$/s) {
1025 $self->_update_c_position($_, \$line, \$column);
1026 } elsif(/^\#\s*else/s) {
1027 $self->_update_c_position($_, \$line, \$column);
1028 } elsif(/^\#\s*endif/s) {
1029 $self->_update_c_position($_, \$line, \$column);
1030 } elsif(/^\#\s*(?:if|ifdef|ifndef)?\s*(.*?)$/s) {
1031 $self->_update_c_position($_, \$line, \$column);
1032 } elsif(/^\#\s*include\s+(.*?)$/s) {
1033 $self->_update_c_position($_, \$line, \$column);
1034 } elsif(/^\#\s*undef\s+(.*?)$/s) {
1035 $self->_update_c_position($_, \$line, \$column);
1037 $self->_parse_c_error($_, $line, $column, "preprocessor");
1042 $$refcolumn = $column;
1047 ########################################################################
1050 sub parse_c_statement {
1053 my $refcurrent = shift;
1054 my $refline = shift;
1055 my $refcolumn = shift;
1057 my $found_function_call = \${$self->{FOUND_FUNCTION_CALL}};
1059 local $_ = $$refcurrent;
1060 my $line = $$refline;
1061 my $column = $$refcolumn;
1063 $self->_parse_c_until_one_of("\\S", \$_, \$line, \$column);
1065 $self->_parse_c('(?:case\s+)?(\w+)\s*:\s*', \$_, \$line, \$column);
1067 # $output->write("$line.$column: statement: '$_'\n");
1073 my $statements_line;
1074 my $statements_column;
1075 if(!$self->parse_c_block(\$_, \$line, \$column, \$statements, \$statements_line, \$statements_column)) {
1078 if(!$self->parse_c_statements(\$statements, \$statements_line, \$statements_column)) {
1081 } elsif(s/^(for|if|switch|while)\s*(?=\()//) {
1082 $self->_update_c_position($&, \$line, \$column);
1088 my @argument_columns;
1089 if(!$self->parse_c_tuple(\$_, \$line, \$column, \@arguments, \@argument_lines, \@argument_columns)) {
1093 $self->_parse_c_until_one_of("\\S", \$_, \$line, \$column);
1094 if(!$self->parse_c_statement(\$_, \$line, \$column)) {
1097 $self->_parse_c_until_one_of("\\S", \$_, \$line, \$column);
1099 while(defined(my $argument = shift @arguments) &&
1100 defined(my $argument_line = shift @argument_lines) &&
1101 defined(my $argument_column = shift @argument_columns))
1103 $self->parse_c_expression(\$argument, \$argument_line, \$argument_column);
1105 } elsif(s/^else//) {
1106 $self->_update_c_position($&, \$line, \$column);
1107 if(!$self->parse_c_statement(\$_, \$line, \$column)) {
1110 } elsif(s/^return//) {
1111 $self->_update_c_position($&, \$line, \$column);
1112 $self->_parse_c_until_one_of("\\S", \$_, \$line, \$column);
1113 if(!$self->parse_c_expression(\$_, \$line, \$column)) {
1116 } elsif($self->parse_c_expression(\$_, \$line, \$column)) {
1119 # $self->_parse_c_error($_, $line, $column, "statement");
1122 $self->_update_c_position($_, \$line, \$column);
1126 $$refcolumn = $column;
1131 ########################################################################
1132 # parse_c_statements
1134 sub parse_c_statements {
1137 my $refcurrent = shift;
1138 my $refline = shift;
1139 my $refcolumn = shift;
1141 my $found_function_call = \${$self->{FOUND_FUNCTION_CALL}};
1143 local $_ = $$refcurrent;
1144 my $line = $$refline;
1145 my $column = $$refcolumn;
1147 $self->_parse_c_until_one_of("\\S", \$_, \$line, \$column);
1149 # $output->write("$line.$column: statements: '$_'\n");
1152 my $statement_line = $line;
1153 my $statement_column = $column;
1155 my $previous_line = -1;
1156 my $previous_column = -1;
1160 while($plevel > 0 || $blevel > 0) {
1162 $self->_parse_c_until_one_of("\\(\\)\\[\\]\\{\\};", \$_, \$line, \$column, \$match);
1164 if($previous_line == $line && $previous_column == $column) {
1165 $self->_parse_c_error($_, $line, $column, "statements", "no progress");
1167 $previous_line = $line;
1168 $previous_column = $column;
1170 # $output->write("'$match' '$_'\n");
1172 $statement .= $match;
1177 } elsif(s/^[\)\]]//) {
1180 $self->_parse_c_error($_, $line, $column, "statements");
1190 if(!$self->parse_c_statement(\$statement, \$statement_line, \$statement_column)) {
1193 $self->_parse_c_until_one_of("\\S", \$_, \$line, \$column);
1195 $statement_line = $line;
1196 $statement_column = $column;
1199 if($plevel == 1 && $blevel == 1) {
1200 if(!$self->parse_c_statement(\$statement, \$statement_line, \$statement_column)) {
1204 $self->_parse_c_until_one_of("\\S", \$_, \$line, \$column);
1206 $statement_line = $line;
1207 $statement_column = $column;
1211 } elsif(/^\s*$/ && $statement =~ /^\s*$/ && $match =~ /^\s*$/) {
1215 $self->_parse_c_error($_, $line, $column, "statements");
1219 $self->_update_c_position($_, \$line, \$column);
1223 $$refcolumn = $column;
1228 ########################################################################
1234 my $refcurrent = shift;
1235 my $refline = shift;
1236 my $refcolumn = shift;
1238 # FIXME: Should not write directly
1240 my $item_lines = shift;
1241 my $item_columns = shift;
1243 local $_ = $$refcurrent;
1245 my $line = $$refline;
1246 my $column = $$refcolumn;
1256 my $item_line = $line;
1257 my $item_column = $column + 1;
1260 while($plevel > 0) {
1262 $self->_parse_c_until_one_of("\\(,\\)", \$_, \$line, \$column, \$match);
1270 push @$item_lines, $item_line;
1271 push @$item_columns, $item_column;
1272 push @$items, $item;
1282 push @$item_lines, $item_line;
1283 push @$item_columns, $item_column;
1284 push @$items, $item;
1285 $self->_parse_c_until_one_of("\\S", \$_, \$line, \$column);
1287 $item_column = $column + 1;
1299 $$refcolumn = $column;
1304 ########################################################################
1310 my $refcurrent = shift;
1311 my $refline = shift;
1312 my $refcolumn = shift;
1314 my $reftype = shift;
1316 local $_ = $$refcurrent;
1317 my $line = $$refline;
1318 my $column = $$refcolumn;
1322 $self->_parse_c("const", \$_, \$line, \$column);
1326 } elsif($self->_parse_c('ICOM_VTABLE\(.*?\)', \$_, \$line, \$column, \$type)) {
1328 } elsif($self->_parse_c('(?:enum\s+|struct\s+|union\s+)?\w+\s*(\*\s*)*', \$_, \$line, \$column, \$type)) {
1337 $$refcolumn = $column;
1344 ########################################################################
1347 sub parse_c_typedef {
1350 my $refcurrent = shift;
1351 my $refline = shift;
1352 my $refcolumn = shift;
1354 my $reftype = shift;
1356 local $_ = $$refcurrent;
1357 my $line = $$refline;
1358 my $column = $$refcolumn;
1362 if($self->_parse_c("typedef", \$_, \$line, \$column)) {
1364 } elsif($self->_parse_c('enum(?:\s+\w+)?\s*\{', \$_, \$line, \$column)) {
1372 $$refcolumn = $column;
1379 ########################################################################
1382 sub parse_c_variable {
1385 my $found_variable = \${$self->{FOUND_VARIABLE}};
1387 my $refcurrent = shift;
1388 my $refline = shift;
1389 my $refcolumn = shift;
1391 my $reflinkage = shift;
1392 my $reftype = shift;
1393 my $refname = shift;
1395 local $_ = $$refcurrent;
1396 my $line = $$refline;
1397 my $column = $$refcolumn;
1399 $self->_parse_c_until_one_of("\\S", \$_, \$line, \$column);
1401 my $begin_line = $line;
1402 my $begin_column = $column + 1;
1409 while($self->_parse_c('const|inline|extern|static|volatile|' .
1410 'signed(?=\\s+char|s+int|\s+long(?:\s+long)?|\s+short)|' .
1411 'unsigned(?=\s+char|\s+int|\s+long(?:\s+long)?|\s+short)',
1412 \$_, \$line, \$column, \$match))
1414 if($match =~ /^extern|static$/) {
1425 } elsif($self->_parse_c('SEQ_DEFINEBUF', \$_, \$line, \$column, \$match)) { # Linux specific
1428 } elsif($self->_parse_c('DEFINE_GUID', \$_, \$line, \$column, \$match)) { # Windows specific
1431 } elsif($self->_parse_c('DEFINE_REGS_ENTRYPOINT_\w+|DPQ_DECL_\w+|HANDLER_DEF|IX86_ONLY', # Wine specific
1432 \$_, \$line, \$column, \$match))
1436 } elsif($self->_parse_c('(?:struct\s+)?ICOM_VTABLE\s*\(\w+\)', \$_, \$line, \$column, \$match)) {
1439 } elsif(s/^(?:enum\s+|struct\s+|union\s+)(\w+)?\s*\{.*?\}\s*//s) {
1440 $self->_update_c_position($&, \$line, \$column);
1443 $type = "struct $1 { }";
1445 $type = "struct { }";
1454 } elsif(s/^((?:enum\s+|struct\s+|union\s+)?\w+)\s*(?:\*\s*)*//s) {
1461 # $output->write("$type: '$_'\n");
1465 } elsif(s/^WINAPI\s*//) {
1466 $self->_update_c_position($&, \$line, \$column);
1471 } elsif(s/^(\((?:__cdecl)?\s*\*?\s*(?:__cdecl)?\w+\s*(?:\[[^\]]*\]\s*)*\))\s*\(//) {
1472 $self->_update_c_position($&, \$line, \$column);
1477 $self->_parse_c_until_one_of("\\)", \$_, \$line, \$column);
1478 if(s/^\)//) { $column++; }
1479 $self->_parse_c_until_one_of("\\S", \$_, \$line, \$column);
1481 if(!s/^(?:=\s*|,\s*|$)//) {
1484 } elsif(s/^(?:\*\s*)*(?:const\s+)?(\w+)\s*(?:\[[^\]]*\]\s*)*\s*(?:=\s*|,\s*|$)//) {
1485 $self->_update_c_position($&, \$line, \$column);
1495 # $output->write("$type: $name: '$_'\n");
1499 } elsif($self->_parse_c('(?:struct\s+)?ICOM_VTABLE\s*\(.*?\)', \$_, \$line, \$column, \$match)) {
1502 } elsif(s/^((?:enum\s+|struct\s+|union\s+)?\w+)\s*
1503 (?:\*\s*)*(\w+|\s*\*?\s*\w+\s*\))\s*(?:\[[^\]]*\]|\([^\)]*\))?
1504 (?:,\s*(?:\*\s*)*(\w+)\s*(?:\[[^\]]*\])?)*
1507 $self->_update_c_position($&, \$line, \$column);
1513 $type =~ s/^struct/struct /;
1514 } elsif(/^(?:enum|struct|union)(?:\s+(\w+))?\s*\{.*?\}\s*((?:\*\s*)*)(\w+)\s*(?:=|$)/s) {
1515 $self->_update_c_position($&, \$line, \$column);
1518 $type = "struct $1 { }";
1520 $type = "struct { }";
1539 $$refcolumn = $column;
1541 $$reflinkage = $linkage;
1545 if(&$$found_variable($begin_line, $begin_column, $linkage, $type, $name))