Skip to content

Commit b4c82d2

Browse files
Change How tao_idl Passes Files to Preprocessor
This is a backport of the same commit in DOCGroup#1357, but with copy preprocessor input method being the default. Fixes an issue that came up in OpenDDS/OpenDDS#2161. To make behavior of `#include ".."` consistent with C and C++, change how `tao_idl` calls the C preprocessor by default in most cases from making a copy of the IDL file to using the IDL file directly.
1 parent 0fdb3b7 commit b4c82d2

File tree

13 files changed

+342
-109
lines changed

13 files changed

+342
-109
lines changed

TAO/NEWS

+5
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,11 @@ USER VISIBLE CHANGES BETWEEN TAO-2.5.12 and TAO-2.5.13
66
. Version of IDL specification being used is available as the
77
`__TAO_IDL_IDL_VERSION` preprocessor macro.
88

9+
. Added `--preprocessor-input` option to `tao_idl` to make behavior of
10+
`#include ".."` consistent with C and C++. This is not enabled by default
11+
like it is in TAO 3, though. For details, see the `--preprocessor-input`
12+
argument in `docs/compiler.html`.
13+
914
USER VISIBLE CHANGES BETWEEN TAO-2.5.11 and TAO-2.5.12
1015
======================================================
1116

TAO/TAO_IDL/driver/drv_args.cpp

+56-7
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ trademarks or registered trademarks of Sun Microsystems, Inc.
8484
extern long DRV_nfiles;
8585
extern char *DRV_files[];
8686

87-
void process_long_option(long ac, char **av, long &i);
87+
void process_long_option (long ac, char **av, long &i);
8888

8989
// Push a file into the list of files to be processed
9090
void
@@ -156,6 +156,10 @@ DRV_usage (void)
156156
ACE_TEXT (" --unknown-annotations ARG Set reaction to unknown annotations.\n")
157157
ACE_TEXT (" ARG must be `warn-once` (default), `warn-all`,\n")
158158
ACE_TEXT (" `error`, or `ignore`.\n")
159+
ACE_TEXT (" --preprocessor-input KIND Set C preprocessor file input method. KIND must \n")
160+
ACE_TEXT (" be `guess`, `direct-with-e`, `direct-without-e`,\n")
161+
ACE_TEXT (" `direct-gcc`, or `copy` (default).\n")
162+
ACE_TEXT (" See docs/compiler.html for more info.\n")
159163
));
160164

161165
be_util::usage ();
@@ -485,7 +489,7 @@ DRV_parse_args (long ac, char **av)
485489
}
486490
else
487491
{
488-
process_long_option(ac, av, i);
492+
process_long_option (ac, av, i);
489493
}
490494
break;
491495

@@ -556,7 +560,7 @@ DRV_parse_args (long ac, char **av)
556560
}
557561

558562
void
559-
print_idl_versions()
563+
print_idl_versions ()
560564
{
561565
ACE_DEBUG ((LM_INFO,
562566
ACE_TEXT ("These are the valid IDL versions this compiler will accept:\n")
@@ -570,7 +574,7 @@ print_idl_versions()
570574
}
571575

572576
void
573-
process_long_option(long ac, char **av, long &i)
577+
process_long_option (long ac, char **av, long &i)
574578
{
575579
const char *long_option = av[i] + 2;
576580
bool no_more_args = i + 1 >= ac;
@@ -680,21 +684,66 @@ process_long_option(long ac, char **av, long &i)
680684
{
681685
invalid_argument = true;
682686
ACE_ERROR ((LM_ERROR,
683-
ACE_TEXT ("\"%C\" is not a valid argument.\n"),
687+
ACE_TEXT ("\"%C\" is not a valid argument to --unknown-annotations.\n"),
684688
av[i]
685689
));
686690
}
687691
}
688692
if (invalid_argument)
689693
{
690694
ACE_ERROR ((LM_ERROR,
691-
ACE_TEXT ("Use either \"warn-once\", \"warn-all\", ")
692-
ACE_TEXT ("\"error\" or \"ignore\".\n"),
695+
ACE_TEXT ("Use \"warn-once\", \"warn-all\", \"error\" or \"ignore\".\n"),
693696
av[i]
694697
));
695698
idl_global->parse_args_exit (1);
696699
}
697700
}
701+
else if (!ACE_OS::strcmp (long_option, "preprocessor-input"))
702+
{
703+
bool invalid_argument = no_more_args;
704+
if (no_more_args)
705+
{
706+
ACE_ERROR ((LM_ERROR,
707+
ACE_TEXT ("--preprocessor-input is missing its required argument.")));
708+
}
709+
else
710+
{
711+
i++;
712+
if (!ACE_OS::strcmp (av[i], "guess"))
713+
{
714+
idl_global->preprocessor_input_ = IDL_GlobalData::PreprocessorInputGuess;
715+
}
716+
else if (!ACE_OS::strcmp (av[i], "direct-with-e"))
717+
{
718+
idl_global->preprocessor_input_ = IDL_GlobalData::PreprocessorInputDirectWithE;
719+
}
720+
else if (!ACE_OS::strcmp (av[i], "direct-without-e"))
721+
{
722+
idl_global->preprocessor_input_ = IDL_GlobalData::PreprocessorInputDirectWithoutE;
723+
}
724+
else if (!ACE_OS::strcmp (av[i], "direct-gcc"))
725+
{
726+
idl_global->preprocessor_input_ = IDL_GlobalData::PreprocessorInputDirectGcc;
727+
}
728+
else if (!ACE_OS::strcmp (av[i], "copy"))
729+
{
730+
idl_global->preprocessor_input_ = IDL_GlobalData::PreprocessorInputCopy;
731+
}
732+
else
733+
{
734+
invalid_argument = true;
735+
ACE_ERROR ((LM_ERROR,
736+
ACE_TEXT ("\"%C\" is not a valid argument to --preprocessor-input.\n"), av[i]));
737+
}
738+
}
739+
if (invalid_argument)
740+
{
741+
ACE_ERROR ((LM_ERROR, ACE_TEXT ("Use \"guess\", \"direct-with-e\", ")
742+
ACE_TEXT ("\"direct-without-e\", \"direct-gcc\", or \"copy\".\n"),
743+
av[i]));
744+
idl_global->parse_args_exit (1);
745+
}
746+
}
698747
else
699748
{
700749
be_global->parse_args (i, av);

0 commit comments

Comments
 (0)