forked from reaper-oss/sws
-
Notifications
You must be signed in to change notification settings - Fork 0
/
reascript_helper.pl
95 lines (78 loc) · 1.83 KB
/
reascript_helper.pl
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
84
85
86
87
88
89
90
91
92
93
94
95
# Original script by Cockos (http://landoleet.org/dev/sws/), also see http://code.google.com/p/sws-extension/issues/detail?id=432
# JFB mods: tailored for the SWS/S&M extension, i.e. process ./ReaScript.cpp rather than ../plugin.cpp
#!/usr/bin/perl
sub ReadAPIFuncs
{
@funclist=();
%rtype={};
%ptypes={};
open INFILE, "ReaScript.cpp" or die "Can't read ReaScript.cpp";
while (<INFILE>)
{
if (/\s*\{\s*APIFUNC/)
{
$fname="";
if (/APIFUNC\((.+?)\),\s*(.*)/)
{
$fname=$1;
$_=$2;
}
elsif (/APIFUNC_NAMED\((.+?)\,(.+?)\),\s*(.*)/)
{
$fname=$1;
$_=$3;
}
$fname or die "Can't parse function name";
push @funclist, $fname;
(/\"(.+?)\"\,\s*(.*)/) or die "Can't parse return type";
$rtype{$fname}=$1;
$_=$2;
(/\"(.*?)\"\,\s*(.*)/) or die "Can't parse parameter types";
$ptypes{$fname}=$1;
$_=$2;
# not using these
#(/\"(.*?)\"/) or die "Can't parse parameter names";
#$pnames{$fname}=$1;
}
}
close INFILE;
@funclist=sort {lc $a cmp lc $b} @funclist;
return (\@funclist, \%rtype, \%ptypes);
}
sub IsInt
{
my %types=map { $_ => 1 } ( "int", "unsigned int", "UINT", "DWORD", "size_t", "LICE_pixel" );
my ($t)=@_;
return exists $types{$t};
}
sub IsPlainData
{
my %types=map { $_ => 1 } ( "bool", "char", "float", "double" );
my ($t)=@_;
return IsInt($t) || exists $types{$t};
}
sub IsPlainDataPtr
{
my ($t)=@_;
$t =~ s/\*// or return 0;
return IsPlainData($t);
}
sub IsString
{
my ($t)= @_;
return ($t eq "char*" || $t eq "const char*");
}
sub IsOpaquePtr
{
my ($t)=@_;
$t eq "HWND" and return 1;
$t =~ s/\*// or return 0;
return (!IsPlainData($t) && $t ne "const char");
}
sub UnderlyingType
{
my ($t)=@_;
chop $t;
return $t;
}
1;