summaryrefslogtreecommitdiffstats
path: root/src/perl/get-signals.pl
blob: f7675f1b51a188d29be760c1812ff09891acddd4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/usr/bin/perl

print "/*\n";
print " * Autogenerated by get-signals.pl from ../../doc/signals.txt,\n";
print " * do not edit.\n";
print " */\n\n";
print "static PERL_SIGNAL_ARGS_REC perl_signal_args[] =\n{\n";

while (<>) {
	chomp;

	next if (!/^ "([^"]*)"(<.*>)?(?:,\s*(.*))?/);
	next if (/\.\.\./);
	next if (/\(/);

	$signal = $1;
	$_ = $3;

	s/GList \* of ([^,]*)s/glistptr_\1/g;
	s/GSList of ([^,]*)s/gslist_\1/g;

	s/GString \*[^,]*/gstring/g;

	s/char \*[^,]*/string/g;
	s/ulong \*[^,]*/ulongptr/g;
	s/int \*[^,]*/intptr/g;
	s/int [^,]*/int/g;


	my %map = (
		# core
		CHATNET_REC   => 'iobject',
		SERVER_REC    => 'iobject',
		RECONNECT_REC => 'iobject',
		CHANNEL_REC   => 'iobject',
		QUERY_REC     => 'iobject',
		COMMAND_REC   => 'Irssi::Command',
		NICK_REC      => 'iobject',
		LOG_REC	      => 'Irssi::Log',
		RAWLOG_REC    => 'Irssi::Rawlog',
		IGNORE_REC    => 'Irssi::Ignore',
		MODULE_REC    => 'Irssi::Module',
		TLS_REC       => 'iobject',

		# irc
		BAN_REC		    => 'Irssi::Irc::Ban',
		NETSPLIT_REC	    => 'Irssi::Irc::Netsplit',
		NETSPLIT_SERVER_REC => 'Irssi::Irc::Netsplitserver',

		# irc modules
		DCC_REC	       => 'siobject',
		AUTOIGNORE_REC => 'Irssi::Irc::Autoignore',
		NOTIFYLIST_REC => 'Irssi::Irc::Notifylist',
		CLIENT_REC     => 'Irssi::Irc::Client',

		# fe-common
		THEME_REC	   => 'Irssi::UI::Theme',
		KEYINFO_REC	   => 'Irssi::UI::Keyinfo',
		PROCESS_REC	   => 'Irssi::UI::Process',
		TEXT_DEST_REC	   => 'Irssi::UI::TextDest',
		LINE_INFO_META_REC => 'Irssi::UI::LineInfoMeta',
		WINDOW_REC	   => 'Irssi::UI::Window',
		WI_ITEM_REC	   => 'iobject',

		# fe-text
		TEXTBUFFER_VIEW_REC => 'Irssi::TextUI::TextBufferView',
		LINE_REC	    => 'Irssi::TextUI::Line',

		# perl
		PERL_SCRIPT_REC => 'Irssi::Script',
	);
	my $k = join '|', sort { length $b <=> length $a } keys %map;
	s/($k)[^,]*/$map{$1}/g;

	s/([\w\*:]+)(,|$)/"\1"\2/g;
	if ($_ eq "") {
		print "	   { \"$signal\", { NULL } },\n";
	} else {
		print "	   { \"$signal\", { $_, NULL } },\n";
	}
}

print "\n    { NULL }\n};\n";