Welcome to mirror list, hosted at ThFree Co, Russian Federation.

mkwrapper.pl « scripts - github.com/mumble-voip/mumble.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: fb7cac6bb578622d192672273509ddbccfcdbf0e (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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
#! /usr/bin/perl
#
# Copyright 2005-2019 The Mumble Developers. All rights reserved.
# Use of this source code is governed by a BSD-style license
# that can be found in the LICENSE file at the root of the
# Mumble source tree or at <https://www.mumble.info/LICENSE>.

use warnings;
use strict;

my $class;
my %return;
open(my $MI, "MurmurIce.cpp");
my @mi = <$MI>;
close($MI);

my $ice;
open(my $ICE, "Murmur.ice");
my @ice=<$ICE>;
close($ICE);
$ice = join("", @ice);

$ice =~ s/\/\*.+?\*\///gms;
$ice =~ s/^\t+//gm;
$ice =~ s/\n+/\n/gs;
$ice =~ s/^\n+//s;

$ice =~ s/"/\\"/g;
$ice =~ s/\n/\\n/g;

open(my $I, ">MurmurIceWrapper.cpp");
open(my $B, ">BasicImpl.cpp");

for my $fh ($I, $B) {
	print $fh qq'
// Auto-generated by scripts/mkwrapper.pl . Do not edit manually.

';
}

open(my $MH, "murmur_ice/Murmur.h") or die "Could not open murmur_ice/Murmur.h";

sub func($$\@\@\@) {
  my ($class, $func, $wrapargs, $callargs, $implargs) = @_;
  

  print $I qq'
void ::Murmur::${class}I::${func}_async('. join(", ", @{$wrapargs}).qq') {
	// qWarning() << "${func}" << meta->mp.qsIceSecretRead.isNull() << meta->mp.qsIceSecretRead.isEmpty();
#ifndef ACCESS_${class}_${func}_ALL
#ifdef ACCESS_${class}_${func}_READ
	if (! meta->mp.qsIceSecretRead.isNull()) {
		bool ok = ! meta->mp.qsIceSecretRead.isEmpty();
#else
	if (! meta->mp.qsIceSecretRead.isNull() || ! meta->mp.qsIceSecretWrite.isNull()) {
		bool ok = ! meta->mp.qsIceSecretWrite.isEmpty();
#endif
		::Ice::Context::const_iterator i = current.ctx.find("secret");
		ok = ok && (i != current.ctx.end());
		if (ok) {
			const QString &secret = u8((*i).second);
#ifdef ACCESS_${class}_${func}_READ
			ok = ((secret == meta->mp.qsIceSecretRead) || (secret == meta->mp.qsIceSecretWrite));
#else
			ok = (secret == meta->mp.qsIceSecretWrite);
#endif
		}
		if (! ok) {
			cb->ice_exception(InvalidSecretException());
			return;
		}
	}
#endif
	ExecEvent *ie = new ExecEvent(boost::bind(&impl_${class}_$func, ' . join(", ", @${callargs}).qq'));
	QCoreApplication::instance()->postEvent(mi, ie);
}
';

  if( ! grep(/impl_${class}_$func/,@mi)) {
    print $B "static void impl_${class}_$func(".join(", ", @${implargs}). ") {}\n";
  }
}


while(<$MH>) {
  chomp();
  if (/^class AMD_(.+) : virtual public ::Ice(?:::AMDCallback|Util::Shared)/) {
    $class = "AMD_".$1;
  }
  if (/virtual void ice_response\((.*)\) = 0;/) {
    $return{$class}=$1;
  }
  if (/virtual void (.+)_async\(const (.+?)&,(.*) const ::Ice::Current&/) {
    my $func=$1;
    my $obj=$2;
    my $args=$3;
    
    next if ($func eq "getSlice");

    my $class="Meta";
    $class = "Server" if ($obj =~ /AMD_Server/);

    my @wrapargs;
    my @callargs;
    my @implargs;
    my $pc=0;
    push @wrapargs, "const $obj &cb";
    push @callargs, "cb";
    push @implargs, "const $obj cb";
    if ($class eq "Server") {
      push @callargs, "QString::fromStdString(current.id.name).toInt()";
      push @implargs, "int server_id";
    } else {
      push @callargs, "current.adapter";
      push @implargs, "const Ice::ObjectAdapterPtr adapter";
    }
    foreach my $p (split(/,/,$args)) {
      $pc++;
      push @wrapargs, "$p p$pc";
      push @callargs, "p$pc";
      push @implargs, "$p p$pc";
    }
#    if ($class eq "Server") {
      push @wrapargs, "const ::Ice::Current &current";
#    } else {
#      push @wrapargs, "const ::Ice::Current &";
#    }

    func($class,$func,@wrapargs,@callargs,@implargs);
  }
}
                                                                             
print $I qq'
void ::Murmur::MetaI::getSlice_async(const ::Murmur::AMD_Meta_getSlicePtr& cb, const Ice::Current&) {
	cb->ice_response(std::string("$ice"));
}
';

close($MH);
close($I);
close($B);