summaryrefslogtreecommitdiff
path: root/source4/pidl/lib/Parse/Pidl/Samba4/SWIG.pm
blob: b6c268edebc23d3b09abc5dbadaceed50457291f (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
###################################################
# Samba4 parser generator for swig wrappers
# Copyright tpot@samba.org 2004,2005
# released under the GNU GPL

package Parse::Pidl::Samba4::SWIG;

use vars qw($VERSION);
$VERSION = '0.01';

use strict;

sub pidl($)
{
	print OUT shift;
}

#####################################################################
# rewrite autogenerated header file
sub RewriteHeader($$$)
{
    my($idl) = shift;
    my($input) = shift;
    my($output) = shift;

    open(IN, "<$input") || die "can't open $input for reading";
    open(OUT, ">$output") || die "can't open $output for writing";    

    pidl "%{\n";
    pidl "#define data_in in\n";
    pidl "#define data_out out\n";
    pidl "%}\n\n";
   
    while(<IN>) {

	# Rename dom_sid2 to dom_sid as we don't care about the difference
	# for the swig wrappers.

	s/dom_sid2/dom_sid/g;

	# Copy structure and union definitions

	if (/^(struct|union) .*? {$/ .. /^\};$/) {
	    s/\} (in|out);/\} data_$1;/; # "in" is a Python keyword
	    pidl $_;
	    next;
	}

	# Copy dcerpc functions

	pidl $_ if /^NTSTATUS dcerpc_.*?\(struct dcerpc_pipe/;

	# Copy interface definitions

        pidl $_ 
	    if /^\#define DCERPC_.*?_UUID/ or /^\#define DCERPC_.*?_VERSION/;
    }

    close(OUT);   
}

#####################################################################
# rewrite autogenerated header file
sub RewriteC($$$)
{
    my($idl) = shift;
    my($input) = shift;
    my($output) = shift;

    open(IN, "<$input") || die "can't open $input for reading";
    open(OUT, ">>$output") || die "can't open $output for writing";    
   
    while(<IN>) {
    }

    close(OUT);   
}

1;