r12463: Rename 'Samba' namespace to 'Samba4'
[samba.git] / source4 / pidl / lib / Parse / Pidl / Samba4 / SWIG.pm
1 ###################################################
2 # Samba4 parser generator for swig wrappers
3 # Copyright tpot@samba.org 2004,2005
4 # released under the GNU GPL
5
6 package Parse::Pidl::Samba4::SWIG;
7
8 use vars qw($VERSION);
9 $VERSION = '0.01';
10
11 use strict;
12
13 sub pidl($)
14 {
15         print OUT shift;
16 }
17
18 #####################################################################
19 # rewrite autogenerated header file
20 sub RewriteHeader($$$)
21 {
22     my($idl) = shift;
23     my($input) = shift;
24     my($output) = shift;
25
26     open(IN, "<$input") || die "can't open $input for reading";
27     open(OUT, ">$output") || die "can't open $output for writing";    
28
29     pidl "%{\n";
30     pidl "#define data_in in\n";
31     pidl "#define data_out out\n";
32     pidl "%}\n\n";
33    
34     while(<IN>) {
35
36         # Rename dom_sid2 to dom_sid as we don't care about the difference
37         # for the swig wrappers.
38
39         s/dom_sid2/dom_sid/g;
40
41         # Copy structure and union definitions
42
43         if (/^(struct|union) .*? {$/ .. /^\};$/) {
44             s/\} (in|out);/\} data_$1;/; # "in" is a Python keyword
45             pidl $_;
46             next;
47         }
48
49         # Copy dcerpc functions
50
51         pidl $_ if /^NTSTATUS dcerpc_.*?\(struct dcerpc_pipe/;
52
53         # Copy interface definitions
54
55         pidl $_ 
56             if /^\#define DCERPC_.*?_UUID/ or /^\#define DCERPC_.*?_VERSION/;
57     }
58
59     close(OUT);   
60 }
61
62 #####################################################################
63 # rewrite autogenerated header file
64 sub RewriteC($$$)
65 {
66     my($idl) = shift;
67     my($input) = shift;
68     my($output) = shift;
69
70     open(IN, "<$input") || die "can't open $input for reading";
71     open(OUT, ">>$output") || die "can't open $output for writing";    
72    
73     while(<IN>) {
74     }
75
76     close(OUT);   
77 }
78
79 1;