Replace Language::directorsEnabled() with Swig_directors_enabled()

For use outside of the target languages for forthcoming commits
which move adding default constructors/destructors from Language
to Allocate.
This commit is contained in:
William S Fulton 2023-07-10 21:43:26 +01:00
parent b7332ce8ca
commit 84542f6b59
12 changed files with 83 additions and 83 deletions

View File

@ -166,7 +166,7 @@ public:
/* for now, multiple inheritance in directors is disabled, this
should be easy to implement though */
director_multiple_inheritance = 0;
director_language = 1;
directorLanguage();
}
/* -----------------------------------------------------------------------------
@ -325,7 +325,7 @@ public:
Exit(EXIT_FAILURE);
}
if (directorsEnabled()) {
if (Swig_directors_enabled()) {
if (!outfile_h) {
Printf(stderr, "Unable to determine outfile_h\n");
Exit(EXIT_FAILURE);
@ -401,7 +401,7 @@ public:
Swig_obligatory_macros(f_runtime, "CSHARP");
if (directorsEnabled()) {
if (Swig_directors_enabled()) {
Printf(f_runtime, "#define SWIG_DIRECTORS\n");
/* Emit initial director header and director code: */
@ -444,7 +444,7 @@ public:
/* Emit code */
Language::top(n);
if (directorsEnabled()) {
if (Swig_directors_enabled()) {
// Insert director runtime into the f_runtime file (make it occur before %header section)
Swig_insert_file("director_common.swg", f_runtime);
Swig_insert_file("director.swg", f_runtime);
@ -608,7 +608,7 @@ public:
Dump(f_runtime, f_begin);
Dump(f_header, f_begin);
if (directorsEnabled()) {
if (Swig_directors_enabled()) {
Dump(f_directors, f_begin);
Dump(f_directors_h, f_runtime_h);

View File

@ -276,7 +276,7 @@ public:
// For now, multiple inheritance with directors is not possible. It should be
// easy to implement though.
director_multiple_inheritance = 0;
director_language = 1;
directorLanguage();
// Not used:
Delete(none_comparison);
@ -383,7 +383,7 @@ public:
Exit(EXIT_FAILURE);
}
if (directorsEnabled()) {
if (Swig_directors_enabled()) {
if (!outfile_h) {
Printf(stderr, "Unable to determine outfile_h\n");
Exit(EXIT_FAILURE);
@ -470,7 +470,7 @@ public:
Swig_obligatory_macros(f_runtime, "D");
if (directorsEnabled()) {
if (Swig_directors_enabled()) {
Printf(f_runtime, "#define SWIG_DIRECTORS\n");
/* Emit initial director header and director code: */
@ -501,7 +501,7 @@ public:
// Emit all the wrapper code.
Language::top(n);
if (directorsEnabled()) {
if (Swig_directors_enabled()) {
// Insert director runtime into the f_runtime file (before %header section).
Swig_insert_file("director_common.swg", f_runtime);
Swig_insert_file("director.swg", f_runtime);
@ -683,7 +683,7 @@ public:
Dump(f_runtime, f_begin);
Dump(f_header, f_begin);
if (directorsEnabled()) {
if (Swig_directors_enabled()) {
Dump(f_directors, f_begin);
Dump(f_directors_h, f_runtime_h);

View File

@ -237,7 +237,7 @@ public:
go_imports(NULL),
unique_id(NULL) {
director_multiple_inheritance = 1;
director_language = 1;
directorLanguage();
director_prot_ctor_code = NewString("_swig_gopanic(\"accessing abstract class or protected constructor\");");
}
@ -464,7 +464,7 @@ private:
Exit(EXIT_FAILURE);
}
if (directorsEnabled()) {
if (Swig_directors_enabled()) {
if (!c_filename_h) {
Printf(stderr, "Unable to determine outfile_h\n");
Exit(EXIT_FAILURE);
@ -527,7 +527,7 @@ private:
Printf(f_c_runtime, "#define SWIGGO_PREFIX %s\n", go_prefix);
}
if (directorsEnabled()) {
if (Swig_directors_enabled()) {
Printf(f_c_runtime, "#define SWIG_DIRECTORS\n");
Swig_banner(f_c_directors_h);
@ -573,7 +573,7 @@ private:
Language::top(n);
if (directorsEnabled()) {
if (Swig_directors_enabled()) {
// Insert director runtime into the f_runtime file (make it occur before %header section)
Swig_insert_file("director_common.swg", f_c_runtime);
Swig_insert_file("director.swg", f_c_runtime);
@ -616,7 +616,7 @@ private:
Dump(f_c_header, f_c_runtime);
if (directorsEnabled()) {
if (Swig_directors_enabled()) {
Printf(f_c_directors_h, "#endif\n");
Delete(f_c_directors_h);
f_c_directors_h = NULL;
@ -672,7 +672,7 @@ private:
Dump(f_go_header, f_go_begin);
Dump(f_go_runtime, f_go_begin);
Dump(f_go_wrappers, f_go_begin);
if (directorsEnabled()) {
if (Swig_directors_enabled()) {
Dump(f_go_directors, f_go_begin);
}
Delete(f_c_runtime);

View File

@ -167,7 +167,7 @@ public:
/* for now, multiple inheritance in directors is disabled, this
should be easy to implement though */
director_multiple_inheritance = 0;
director_language = 1;
directorLanguage();
}
~JAVA() {
@ -367,7 +367,7 @@ public:
Exit(EXIT_FAILURE);
}
if (directorsEnabled()) {
if (Swig_directors_enabled()) {
if (!outfile_h) {
Printf(stderr, "Unable to determine outfile_h\n");
Exit(EXIT_FAILURE);
@ -445,7 +445,7 @@ public:
Swig_obligatory_macros(f_runtime, "JAVA");
if (directorsEnabled()) {
if (Swig_directors_enabled()) {
Printf(f_runtime, "#define SWIG_DIRECTORS\n");
/* Emit initial director header and director code: */
@ -497,7 +497,7 @@ public:
/* Emit code */
Language::top(n);
if (directorsEnabled()) {
if (Swig_directors_enabled()) {
// Insert director runtime into the f_runtime file (make it occur before %header section)
Swig_insert_file("director_common.swg", f_runtime);
Swig_insert_file("director.swg", f_runtime);
@ -739,7 +739,7 @@ public:
/* Close all of the files */
Dump(f_header, f_runtime);
if (directorsEnabled()) {
if (Swig_directors_enabled()) {
Dump(f_directors, f_runtime);
Dump(f_directors_h, f_runtime_h);

View File

@ -16,13 +16,18 @@
#include <ctype.h>
/* default mode settings */
static int directors_allowed = 0;
static int director_language = 0;
static int director_mode = 0;
static int director_protected_mode = 1;
static int all_protected_mode = 0;
static int naturalvar_mode = 0;
Language *Language::this_ = 0;
/* Set director_protected_mode */
int Swig_directors_enabled() {
return director_language && CPlusPlus && (directors_allowed || director_mode);
}
void Wrapper_director_mode_set(int flag) {
director_mode = flag;
}
@ -361,8 +366,7 @@ director_prot_ctor_code(0),
symtabs(NewHash()),
overloading(0),
multiinput(0),
cplus_runtime(0),
directors(0) {
cplus_runtime(0) {
symbolAddScope(""); // create top level/global symbol table scope
argc_template_string = NewString("argc");
argv_template_string = NewString("argv[%d]");
@ -376,7 +380,6 @@ directors(0) {
*/
director_prot_ctor_code = 0;
director_multiple_inheritance = 1;
director_language = 0;
assert(!this_);
this_ = this;
@ -915,7 +918,7 @@ int Language::cDeclaration(Node *n) {
if (!isfriend) {
/* Check what the director needs. If the method is pure virtual, it is always needed.
* Also wrap non-virtual protected members if asked for (allprotected mode). */
if (!(directorsEnabled() && ((is_member_director(CurrentClass, n) && need_nonpublic_member(n)) || isNonVirtualProtectedAccess(n)))) {
if (!(Swig_directors_enabled() && ((is_member_director(CurrentClass, n) && need_nonpublic_member(n)) || isNonVirtualProtectedAccess(n)))) {
return SWIG_NOWRAP;
}
// Prevent wrapping protected overloaded director methods more than once -
@ -1116,7 +1119,7 @@ int Language::functionHandler(Node *n) {
// This is a member function, set a flag so the documentation type is correct
SetFlag(n, "memberfunction");
Node *explicit_n = 0;
if (directorsEnabled() && is_member_director(CurrentClass, n) && !extraDirectorProtectedCPPMethodsRequired()) {
if (Swig_directors_enabled() && is_member_director(CurrentClass, n) && !extraDirectorProtectedCPPMethodsRequired()) {
bool virtual_but_not_pure_virtual = (!(Cmp(storage, "virtual")) && (Cmp(Getattr(n, "value"), "0") != 0));
if (virtual_but_not_pure_virtual) {
// Add additional wrapper which makes an explicit call to the virtual method (ie not a virtual call)
@ -1293,7 +1296,7 @@ int Language::memberfunctionHandler(Node *n) {
}
int DirectorExtraCall = 0;
if (directorsEnabled() && is_member_director(CurrentClass, n) && !SmartPointer)
if (Swig_directors_enabled() && is_member_director(CurrentClass, n) && !SmartPointer)
if (extraDirectorProtectedCPPMethodsRequired())
DirectorExtraCall = CWRAP_DIRECTOR_TWO_CALLS;
@ -2535,7 +2538,7 @@ int Language::classDeclaration(Node *n) {
/* Call classHandler() here */
if (!ImportMode) {
if (directorsEnabled()) {
if (Swig_directors_enabled()) {
int ndir = GetFlag(n, "feature:director");
int nndir = GetFlag(n, "feature:nodirector");
/* 'nodirector' has precedence over 'director' */
@ -3546,20 +3549,20 @@ int Language::cplus_runtime_mode() {
return cplus_runtime;
}
/* -----------------------------------------------------------------------------
* Language::directorLanguage()
* ----------------------------------------------------------------------------- */
void Language::directorLanguage(int val) {
director_language = val;
}
/* -----------------------------------------------------------------------------
* Language::allow_directors()
* ----------------------------------------------------------------------------- */
void Language::allow_directors(int val) {
directors = val;
}
/* -----------------------------------------------------------------------------
* Language::directorsEnabled()
* ----------------------------------------------------------------------------- */
int Language::directorsEnabled() const {
return director_language && CPlusPlus && (directors || director_mode);
directors_allowed = val;
}
/* -----------------------------------------------------------------------------
@ -3583,7 +3586,7 @@ void Language::allow_allprotected(int val) {
* ----------------------------------------------------------------------------- */
int Language::dirprot_mode() const {
return directorsEnabled() ? director_protected_mode : 0;
return Swig_directors_enabled() ? director_protected_mode : 0;
}
/* -----------------------------------------------------------------------------
@ -3619,7 +3622,7 @@ int Language::need_nonpublic_ctor(Node *n) {
members, and use %ignore for the method you don't want to add in
the director class.
*/
if (directorsEnabled()) {
if (Swig_directors_enabled()) {
if (is_protected(n)) {
if (dirprot_mode()) {
/* when using dirprot mode, the protected constructors are
@ -3652,7 +3655,7 @@ int Language::need_nonpublic_ctor(Node *n) {
* Language::need_nonpublic_member()
* ----------------------------------------------------------------------------- */
int Language::need_nonpublic_member(Node *n) {
if (directorsEnabled() && DirectorClassName) {
if (Swig_directors_enabled() && DirectorClassName) {
if (is_protected(n)) {
if (dirprot_mode()) {
/* when using dirprot mode, the protected members are always needed. */
@ -3849,7 +3852,7 @@ int Language::abstractClassTest(Node *n) {
#endif
if (!labs)
return 0; /*strange, but need to be fixed */
if (abstracts && !directorsEnabled())
if (abstracts && !Swig_directors_enabled())
return 1;
if (!GetFlag(n, "feature:director"))
return 1;

View File

@ -69,7 +69,7 @@ public:
"if ( $comparison ) { /* subclassed */\n",
" $director_new \n", "} else {\n", " caml_failwith(\"accessing abstract class or protected constructor\"); \n", "}\n", NIL);
director_multiple_inheritance = 1;
director_language = 1;
directorLanguage();
}
String *Swig_class_name(Node *n) {
@ -291,7 +291,7 @@ public:
Printf(f_int_to_enum, "let int_to_enum x y =\n" " match (x : c_enum_type) with\n" " `unknown -> C_enum (`Int y)\n");
if (directorsEnabled()) {
if (Swig_directors_enabled()) {
Printf(f_runtime, "#define SWIG_DIRECTORS\n");
}
@ -340,7 +340,7 @@ public:
Printf(f_enumtypes_type, "]\n");
Printf(f_enumtypes_value, "]\n\n" "type c_obj = c_enum_value c_obj_t\n");
if (directorsEnabled()) {
if (Swig_directors_enabled()) {
// Insert director runtime into the f_runtime file (make it occur before %header section)
Swig_insert_file("director_common.swg", f_runtime);
Swig_insert_file("director.swg", f_runtime);

View File

@ -85,7 +85,7 @@ public:
enable_cplus_runtime_mode();
allow_overloading();
director_multiple_inheritance = 1;
director_language = 1;
directorLanguage();
docs = NewHash();
}
@ -199,7 +199,7 @@ public:
Printf(f_runtime, "#define SWIG_global_name \"%s\"\n", global_name);
Printf(f_runtime, "#define SWIG_op_prefix \"%s\"\n", op_prefix);
if (directorsEnabled()) {
if (Swig_directors_enabled()) {
Printf(f_runtime, "#define SWIG_DIRECTORS\n");
Swig_banner(f_directors_h);
if (dirprot_mode()) {
@ -224,7 +224,7 @@ public:
if (Len(docs))
emit_doc_texinfo();
if (directorsEnabled()) {
if (Swig_directors_enabled()) {
Swig_insert_file("director_common.swg", f_runtime);
Swig_insert_file("director.swg", f_runtime);
}
@ -237,7 +237,7 @@ public:
Dump(f_runtime, f_begin);
Dump(f_header, f_begin);
Dump(f_doc, f_begin);
if (directorsEnabled()) {
if (Swig_directors_enabled()) {
Dump(f_directors_h, f_begin);
Dump(f_directors, f_begin);
}

View File

@ -123,7 +123,7 @@ public:
Printv(argc_template_string, "items", NIL);
Clear(argv_template_string);
Printv(argv_template_string, "ST(%d)", NIL);
director_language = 1;
directorLanguage();
}
/* Test to see if a type corresponds to something wrapped with a shadow class */
@ -285,7 +285,7 @@ public:
f_directors_h = NewString("");
f_directors = NewString("");
if (directorsEnabled()) {
if (Swig_directors_enabled()) {
f_runtime_h = NewFile(outfile_h, "w", SWIG_output_files());
if (!f_runtime_h) {
FileErrorDisplay(outfile_h);
@ -321,7 +321,7 @@ public:
Swig_obligatory_macros(f_runtime, "PERL");
if (directorsEnabled()) {
if (Swig_directors_enabled()) {
Printf(f_runtime, "#define SWIG_DIRECTORS\n");
}
Printf(f_runtime, "#define SWIG_CASTRANK_MODE\n");
@ -341,7 +341,7 @@ public:
fprintf(stdout, "top: using namespace_module: %s\n", Char(namespace_module));
}
if (directorsEnabled()) {
if (Swig_directors_enabled()) {
Swig_banner(f_directors_h);
Printf(f_directors_h, "\n");
Printf(f_directors_h, "#ifndef SWIG_%s_WRAP_H_\n", underscore_module);
@ -454,7 +454,7 @@ public:
/* emit wrappers */
Language::top(n);
if (directorsEnabled()) {
if (Swig_directors_enabled()) {
// Insert director runtime into the f_runtime file (make it occur before %header section)
Swig_insert_file("director_common.swg", f_runtime);
Swig_insert_file("director.swg", f_runtime);
@ -612,7 +612,7 @@ public:
Dump(f_runtime, f_begin);
Dump(f_header, f_begin);
if (directorsEnabled()) {
if (Swig_directors_enabled()) {
Dump(f_directors_h, f_runtime_h);
Printf(f_runtime_h, "\n");
Printf(f_runtime_h, "#endif\n");

View File

@ -512,7 +512,7 @@ static PHPTypes *phptypes = NULL;
class PHP : public Language {
public:
PHP() {
director_language = 1;
directorLanguage();
}
/* ------------------------------------------------------------
@ -595,7 +595,7 @@ public:
f_directors_h = NewStringEmpty();
f_directors = NewStringEmpty();
if (directorsEnabled()) {
if (Swig_directors_enabled()) {
f_runtime_h = NewFile(outfile_h, "w", SWIG_output_files());
if (!f_runtime_h) {
FileErrorDisplay(outfile_h);
@ -619,7 +619,7 @@ public:
Swig_obligatory_macros(f_runtime, "PHP");
if (directorsEnabled()) {
if (Swig_directors_enabled()) {
Printf(f_runtime, "#define SWIG_DIRECTORS\n");
}
@ -656,7 +656,7 @@ public:
if (!prefix)
prefix = NewStringEmpty();
if (directorsEnabled()) {
if (Swig_directors_enabled()) {
Swig_banner(f_directors_h);
Printf(f_directors_h, "\n");
Printf(f_directors_h, "#ifndef SWIG_%s_WRAP_H_\n", cap_module);
@ -686,7 +686,7 @@ public:
Printf(s_header, "}\n");
Printf(s_header, "#endif\n\n");
if (directorsEnabled()) {
if (Swig_directors_enabled()) {
// Insert director runtime
Swig_insert_file("director_common.swg", s_header);
Swig_insert_file("director.swg", s_header);
@ -883,7 +883,7 @@ public:
* function really needs totally redoing.
*/
if (directorsEnabled()) {
if (Swig_directors_enabled()) {
Dump(f_directors_h, f_runtime_h);
Printf(f_runtime_h, "\n");
Printf(f_runtime_h, "#endif\n");
@ -896,7 +896,7 @@ public:
Dump(f_runtime, f_begin);
Printv(f_begin, s_header, NIL);
if (directorsEnabled()) {
if (Swig_directors_enabled()) {
Dump(f_directors, f_begin);
}
Printv(f_begin, s_vdecl, s_wrappers, NIL);

View File

@ -220,7 +220,7 @@ public:
" $director_new \n",
"} else {\n", " SWIG_SetErrorMsg(PyExc_RuntimeError,\"accessing abstract class or protected constructor\"); \n", " SWIG_fail;\n", "}\n", NIL);
director_multiple_inheritance = 1;
director_language = 1;
directorLanguage();
}
~PYTHON() {
@ -560,7 +560,7 @@ public:
f_builtins = NewString("");
}
if (directorsEnabled()) {
if (Swig_directors_enabled()) {
if (!no_header_file) {
f_runtime_h = NewFile(outfile_h, "w", SWIG_output_files());
if (!f_runtime_h) {
@ -589,7 +589,7 @@ public:
Swig_obligatory_macros(f_runtime, "PYTHON");
if (directorsEnabled()) {
if (Swig_directors_enabled()) {
Printf(f_runtime, "#define SWIG_DIRECTORS\n");
}
@ -638,7 +638,7 @@ public:
module = Copy(Getattr(n, "name"));
mainmodule = Getattr(n, "name");
if (directorsEnabled()) {
if (Swig_directors_enabled()) {
Swig_banner(f_directors_h);
Printf(f_directors_h, "\n");
Printf(f_directors_h, "#ifndef SWIG_%s_WRAP_H_\n", module);
@ -769,7 +769,7 @@ public:
Printv(f_shadow, "\n", NIL);
if (directorsEnabled())
if (Swig_directors_enabled())
Printv(f_shadow, "import weakref\n\n", NIL);
}
}
@ -805,7 +805,7 @@ public:
/* emit code */
Language::top(n);
if (directorsEnabled()) {
if (Swig_directors_enabled()) {
// Insert director runtime into the f_runtime file (make it occur before %header section)
Swig_insert_file("director_common.swg", f_runtime);
Swig_insert_file("director.swg", f_runtime);
@ -886,7 +886,7 @@ public:
Dump(f_runtime, f_begin);
Dump(f_header, f_begin);
if (directorsEnabled()) {
if (Swig_directors_enabled()) {
Dump(f_directors_h, f_runtime_h);
Printf(f_runtime_h, "\n");
Printf(f_runtime_h, "#endif\n");

View File

@ -825,7 +825,7 @@ public:
" $director_new \n",
"} else {\n", " rb_raise(rb_eRuntimeError,\"accessing abstract class or protected constructor\"); \n", " return Qnil;\n", "}\n", NIL);
director_multiple_inheritance = 0;
director_language = 1;
directorLanguage();
}
/* ---------------------------------------------------------------------
@ -1055,7 +1055,7 @@ public:
f_directors_helpers = NewString("");
f_initbeforefunc = NewString("");
if (directorsEnabled()) {
if (Swig_directors_enabled()) {
if (!outfile_h) {
Printf(stderr, "Unable to determine outfile_h\n");
Exit(EXIT_FAILURE);
@ -1089,7 +1089,7 @@ public:
Swig_obligatory_macros(f_runtime, "RUBY");
if (directorsEnabled()) {
if (Swig_directors_enabled()) {
Printf(f_runtime, "#define SWIG_DIRECTORS\n");
}
@ -1104,7 +1104,7 @@ public:
/* Set module name */
set_module(Char(Getattr(n, "name")));
if (directorsEnabled()) {
if (Swig_directors_enabled()) {
/* Build a version of the module name for use in a C macro name. */
String *module_macro = Copy(module);
Replaceall(module_macro, "::", "__");
@ -1165,7 +1165,7 @@ public:
Language::top(n);
if (directorsEnabled()) {
if (Swig_directors_enabled()) {
// Insert director runtime into the f_runtime file (make it occur before %header section)
Swig_insert_file("director_common.swg", f_runtime);
Swig_insert_file("director.swg", f_runtime);
@ -1179,7 +1179,7 @@ public:
Dump(f_runtime, f_begin);
Dump(f_header, f_begin);
if (directorsEnabled()) {
if (Swig_directors_enabled()) {
Dump(f_directors_helpers, f_begin);
Dump(f_directors, f_begin);
Dump(f_directors_h, f_runtime_h);
@ -1817,7 +1817,7 @@ public:
Node *pn = Swig_methodclass(n);
String *symname = Getattr(pn, "sym:name");
String *action = Getattr(n, "wrap:action");
if (directorsEnabled()) {
if (Swig_directors_enabled()) {
String *classname = NewStringf("const char *classname SWIGUNUSED = \"%s::%s\"", module, symname);
Wrapper_add_local(f, "classname", classname);
}

View File

@ -228,12 +228,12 @@ public:
/* Returns the cplus_runtime mode */
int cplus_runtime_mode();
/* Flag for language to support directors */
void directorLanguage(int val = 1);
/* Allow director related code generation */
void allow_directors(int val = 1);
/* Return true if directors are enabled */
int directorsEnabled() const;
/* Allow director protected members related code generation */
void allow_dirprot(int val = 1);
@ -339,9 +339,6 @@ protected:
/* Director allows multiple inheritance */
int director_multiple_inheritance;
/* Director language module */
int director_language;
/* Used to translate Doxygen comments to target documentation format */
class DoxygenTranslator *doxygenTranslator;
@ -352,7 +349,6 @@ private:
int overloading;
int multiinput;
int cplus_runtime;
int directors;
static Language *this_;
};
@ -396,6 +392,7 @@ String *Swig_overload_dispatch_cast(Node *n, const_String_or_char_ptr fmt, int *
List *Swig_overload_rank(Node *n, bool script_lang_wrapping);
SwigType *cplus_value_type(SwigType *t);
int Swig_directors_enabled();
/* directors.cxx start */
String *Swig_csuperclass_call(String *base, String *method, ParmList *l);
String *Swig_class_declaration(Node *n, String *name);