1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-22 13:34:15 +03:00

r24815: Support cpp_quote().

(This used to be commit 30c1de30bb)
This commit is contained in:
Jelmer Vernooij 2007-08-31 00:03:54 +00:00 committed by Gerald (Jerry) Carter
parent 82037a75ea
commit 7acc0e77a6
7 changed files with 1439 additions and 1366 deletions

View File

@ -21,6 +21,7 @@ idl:
| idl import { push(@{$_[1]}, $_[2]); $_[1] }
| idl include { push(@{$_[1]}, $_[2]); $_[1] }
| idl importlib { push(@{$_[1]}, $_[2]); $_[1] }
| idl cpp_quote { push(@{$_[1]}, $_[2]); $_[1] }
;
import: 'import' commalist ';' {{
@ -77,6 +78,15 @@ interface: property_list 'interface' identifier '{' definitions '}' optional_sem
}}
;
cpp_quote: 'cpp_quote' '(' text ')'
{{
"TYPE" => "CPP_QUOTE",
"FILE" => $_[0]->YYData->{FILE},
"LINE" => $_[0]->YYData->{LINE},
"DATA" => $_[3]
}}
;
definitions:
definition { [ $_[1] ] }
| definitions definition { push(@{$_[1]}, $_[2]); $_[1] }
@ -466,7 +476,7 @@ again:
if (s/^([\w_]+)//) {
$parser->YYData->{LAST_TOKEN} = $1;
if ($1 =~
/^(coclass|interface|const|typedef|declare|union
/^(coclass|interface|const|typedef|declare|union|cpp_quote
|struct|enum|bitmap|void|unsigned|signed|import|include
|importlib)$/x) {
return $1;

File diff suppressed because it is too large Load Diff

View File

@ -715,6 +715,7 @@ sub Parse($)
my @ndr = ();
foreach (@{$idl}) {
($_->{TYPE} eq "CPP_QUOTE") && push(@ndr, $_);
($_->{TYPE} eq "INTERFACE") && push(@ndr, ParseInterface($_));
($_->{TYPE} eq "IMPORT") && push(@ndr, $_);
}

View File

@ -371,6 +371,13 @@ sub HeaderInterface($)
pidl "#endif /* _HEADER_$interface->{NAME} */\n";
}
sub HeaderQuote($)
{
my($quote) = shift;
pidl $quote->{DATA};
}
#####################################################################
# parse a parsed IDL into a C header
sub Parse($)
@ -388,6 +395,7 @@ sub Parse($)
pidl "\n";
foreach (@{$ndr}) {
($_->{TYPE} eq "CPP_QUOTE") && HeaderQuote($_);
($_->{TYPE} eq "INTERFACE") && HeaderInterface($_);
($_->{TYPE} eq "IMPORT") && HeaderImport(@{$_->{PATHS}});
($_->{TYPE} eq "INCLUDE") && HeaderInclude(@{$_->{PATHS}});

View File

@ -273,7 +273,7 @@ Datagram support (ncadg_*)
in, out, ref, length_is, switch_is, size_is, uuid, case, default, string,
unique, ptr, pointer_default, v1_enum, object, helpstring, range, local,
call_as, endpoint, switch_type, progid, coclass, iid_is, represent_as,
transmit_as, import, include.
transmit_as, import, include, cpp_quote.
=head2 PIDL Specific properties
@ -347,7 +347,7 @@ to the host format. Commonly used values are UCS2, DOS and UTF8.
=head2 Unsupported MIDL properties or statements
aggregatable, appobject, async_uuid, bindable, control, cpp_quote,
aggregatable, appobject, async_uuid, bindable, control,
defaultbind, defaultcollelem, defaultvalue, defaultvtable, dispinterface,
displaybind, dual, entry, first_is, helpcontext, helpfile, helpstringcontext,
helpstringdll, hidden, idl_module, idl_quote, id, immediatebind, importlib,

View File

@ -4,7 +4,7 @@
use strict;
use warnings;
use Test::More tests => 15;
use Test::More tests => 16;
use FindBin qw($RealBin);
use lib "$RealBin";
use Util;
@ -53,3 +53,6 @@ like(parse_idl("interface p { struct x; };"),
like(parse_idl("interface p { typedef struct x { int p; } x; };"),
qr/struct x.*{.*int32_t p;.*};/sm, "double struct declaration");
like(parse_idl("cpp_quote(\"some-foo\")"),
qr/some-foo/sm, "cpp quote");

View File

@ -4,7 +4,7 @@
# Published under the GNU General Public License
use strict;
use Test::More tests => 64 * 2 + 2;
use Test::More tests => 65 * 2 + 3;
use FindBin qw($RealBin);
use lib "$RealBin";
use Util qw(test_errors);
@ -109,6 +109,7 @@ testok "import-multiple", "import \"foo.idl\", \"bar.idl\";";
testok "include-multiple", "include \"foo.idl\", \"bar.idl\";";
testok "empty-struct", "interface test { struct foo { }; }";
testok "typedef-double", "interface test { typedef struct foo { } foo; }";
testok "cpp-quote", "cpp_quote(\"bla\")";
my $x = Parse::Pidl::IDL::parse_string("interface foo { struct x {}; }", "<foo>");
@ -122,3 +123,10 @@ is_deeply($x,
[ { 'FILE' => '<foo>', 'NAME' => 'foo', 'DATA' => [
{ 'NAME' => 'x', 'TYPE' => 'STRUCT' } ],
'TYPE' => 'INTERFACE', 'LINE' => 0 } ]);
$x = Parse::Pidl::IDL::parse_string("cpp_quote(\"foobar\")", "<quote>");
is_deeply($x,
[ { 'FILE' => '<quote>', 'DATA' => '"foobar"',
'TYPE' => 'CPP_QUOTE', 'LINE' => 0 } ]);