Ensure -c++out is not used with -c++
Error checking for this combination implemented as well as correcting Octave Also refactor, replacing CPlusPlusOut variable with cparse_cplusplusout for an implementation which more closely resembles cparse_cplusplus which is also required in both .c and .cxx files.
This commit is contained in:
parent
3b4d331310
commit
2121e1217e
8 changed files with 30 additions and 14 deletions
|
|
@ -29,10 +29,6 @@
|
|||
|
||||
static Language *lang = 0; // Language method
|
||||
int CPlusPlus = 0;
|
||||
extern "C"
|
||||
{
|
||||
int CPlusPlusOut = 0; // Generate C++ compatible code when wrapping C code
|
||||
}
|
||||
int Extend = 0; // Extend flag
|
||||
int ForceExtern = 0; // Force extern mode
|
||||
int GenerateDefault = 1; // Generate default constructors
|
||||
|
|
@ -488,7 +484,8 @@ void SWIG_getoptions(int argc, char *argv[]) {
|
|||
Swig_cparse_cplusplus(1);
|
||||
Swig_mark_arg(i);
|
||||
} else if (strcmp(argv[i], "-c++out") == 0) {
|
||||
CPlusPlusOut = 1;
|
||||
// Undocumented
|
||||
Swig_cparse_cplusplusout(1);
|
||||
Swig_mark_arg(i);
|
||||
} else if (strcmp(argv[i], "-fcompact") == 0) {
|
||||
Wrapper_compact_print_mode_set(1);
|
||||
|
|
@ -955,6 +952,11 @@ int SWIG_main(int argc, char *argv[], Language *l) {
|
|||
// Don't check for an input file if -external-runtime is passed
|
||||
Swig_check_options(external_runtime ? 0 : 1);
|
||||
|
||||
if (CPlusPlus && cparse_cplusplusout) {
|
||||
Printf(stderr, "The -c++out option is for C input but C++ input has been requested via -c++\n");
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
install_opts(argc, argv);
|
||||
|
||||
// Add language dependent directory to the search path
|
||||
|
|
|
|||
|
|
@ -400,7 +400,7 @@ void Swig_nested_name_unnamed_c_structs(Node *n) {
|
|||
c = next;
|
||||
continue;
|
||||
}
|
||||
} else if (CPlusPlusOut) {
|
||||
} else if (cparse_cplusplusout) {
|
||||
if (Getattr(c, "nested:outer")) {
|
||||
Node *ins = create_insert(c, true);
|
||||
insertNodeAfter(c, ins);
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
#include "swigmod.h"
|
||||
#include "cparse.h"
|
||||
|
||||
static String *global_name = 0;
|
||||
static String *op_prefix = 0;
|
||||
|
|
@ -86,7 +87,6 @@ public:
|
|||
director_multiple_inheritance = 1;
|
||||
director_language = 1;
|
||||
docs = NewHash();
|
||||
CPlusPlusOut = 1;
|
||||
}
|
||||
|
||||
virtual void main(int argc, char *argv[]) {
|
||||
|
|
@ -133,6 +133,10 @@ public:
|
|||
SWIG_config_file("octave.swg");
|
||||
SWIG_typemap_lang("octave");
|
||||
allow_overloading();
|
||||
|
||||
// Octave API is C++, so output must be C++ compatibile even when wrapping C code
|
||||
if (!cparse_cplusplus)
|
||||
Swig_cparse_cplusplusout(1);
|
||||
}
|
||||
|
||||
virtual int top(Node *n) {
|
||||
|
|
|
|||
|
|
@ -32,7 +32,6 @@ extern String *input_file;
|
|||
extern int line_number;
|
||||
extern int start_line;
|
||||
extern int CPlusPlus; // C++ mode
|
||||
extern "C" int CPlusPlusOut; // generate C++ declarations for C code (currently used for Octave)
|
||||
extern int Extend; // Extend mode
|
||||
extern int Verbose;
|
||||
extern int IsVirtual;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue