summaryrefslogtreecommitdiff
path: root/source4/build/pidl/esp.pm
blob: 8625544fda824b98937a09e62b5c77cd3047b4a5 (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
###################################################
# ESP function wrapper generator
# Copyright jelmer@samba.org 2005
# released under the GNU GPL

package EspClient;

use strict;
use pidl::typelist;

my($res);

sub pidl ($)
{
	$res .= shift;
}

sub ESPFunction($)
{
	my $d = shift;

	pidl "static int esp_$d->{NAME}(struct EspRequest *ep, int argc, struct MprVar **argv)\n";
	pidl "{\n";

	# FIXME

	pidl "\treturn 0;\n";
	pidl "}\n\n";
}

#####################################################################
# parse the interface definitions
sub ESPInterface($)
{
	my($interface) = shift;
	my @fns = ();

	foreach my $d (@{$interface->{FUNCTIONS}}) {
		next if not defined($d->{OPNUM});
		
		ESPFunction($d);

		push (@fns, $d->{NAME});
	}
	
	return @fns;
}

#####################################################################
# parse a parsed IDL into a C header
sub Parse($$)
{
    my($ndr) = shift;
	my $hdr = shift;
	my @fns = ();

	$res = "";
	pidl "#include \"$hdr\"\n\n";
    pidl "/* ESP wrapper functions auto-generated by pidl */\n\n";
    foreach my $x (@{$ndr}) {
	    if ($x->{TYPE} eq "INTERFACE") {
		    push (@fns, ESPInterface($x));
	    }
    }

	pidl "void setup_ejs_functions(void)\n";
	pidl "{\n";
	foreach (@fns) {
		pidl "\tespDefineCFunction(NULL, \"$_\", esp_$_, NULL);\n";
	}
	pidl "}\n";
	
    return $res;
}

1;