summaryrefslogtreecommitdiffstats
path: root/source4/build/pidl/ejs_header.pm
blob: af6b4d426da181b449325929162d526206988488 (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
###################################################
# create C header files for an EJS mapping functions
# Copyright tridge@samba.org 2005
# released under the GNU GPL

package EjsHeader;

use strict;
use pidl::typelist;

my($res);

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

#####################################################################
# prototype a typedef
sub HeaderTypedefProto($)
{
	my $d = shift;
	my $name = $d->{NAME};
	
	return unless util::has_property($d, "public");
	
	my $type_decl = typelist::mapType($name);

	pidl "NTSTATUS ejs_push_$d->{NAME}(struct ejs_rpc *, struct MprVar *, const char *, const $type_decl *);\n";
	pidl "NTSTATUS ejs_pull_$d->{NAME}(struct ejs_rpc *, struct MprVar *, const char *, $type_decl *);\n";
}

#####################################################################
# parse the interface definitions
sub HeaderInterface($)
{
	my($interface) = shift;

	my $count = 0;

	pidl "#ifndef _HEADER_EJS_$interface->{NAME}\n";
	pidl "#define _HEADER_EJS_$interface->{NAME}\n\n";

	if (defined $interface->{PROPERTIES}->{depends}) {
		my @d = split / /, $interface->{PROPERTIES}->{depends};
		foreach my $i (@d) {
			pidl "#include \"librpc/gen_ndr/ndr_$i\_ejs\.h\"\n";
		}
	}

	pidl "\n";

	foreach my $d (@{$interface->{TYPEDEFS}}) {
		HeaderTypedefProto($d);
	}

	pidl "\n";
	pidl "#endif /* _HEADER_EJS_$interface->{NAME} */\n";
}

#####################################################################
# parse a parsed IDL into a C header
sub Parse($)
{
    my($idl) = shift;

    $res = "";
    pidl "/* header auto-generated by pidl */\n\n";
    foreach my $x (@{$idl}) {
	    ($x->{TYPE} eq "INTERFACE") && HeaderInterface($x);
    }
    return $res;
}

1;