* This file is part of SWIG, which is licensed as a whole under version 3
* (or any later version) of the GNU General Public License. Some additional
* terms also apply to certain portions of SWIG. The full details of the SWIG
* license and copyrights can be found in the LICENSE and COPYRIGHT files
* included with the SWIG source code as distributed by the SWIG developers
* and at https://www.swig.org/legal.html.
*
* swigmod.h
*
* Main header file for SWIG modules.
* ----------------------------------------------------------------------------- */
#ifndef SWIG_SWIGMOD_H
#define SWIG_SWIGMOD_H
#include "swig.h"
#include "preprocessor.h"
#include "swigwarn.h"
#define NOT_VIRTUAL 0
#define PLAIN_VIRTUAL 1
#define PURE_VIRTUAL 2
extern String *input_file;
extern int line_number;
extern int start_line;
extern int CPlusPlus;
extern int Extend;
extern int Verbose;
extern int IsVirtual;
extern int ImportMode;
extern int NoExcept;
extern int Abstract;
extern int SmartPointer;
extern String *argv_template_string;
extern String *argc_template_string;
#define tab0 ""
#define tab2 " "
#define tab4 " "
#define tab8 " "
class Dispatcher {
public:
Dispatcher ():cplus_mode(PUBLIC) {
}
virtual ~ Dispatcher () {
}
virtual int emit_one(Node *n);
virtual int emit_children(Node *n);
virtual int defaultHandler(Node *n);
virtual int top(Node *n) = 0;
virtual int applyDirective(Node *n);
virtual int clearDirective(Node *n);
virtual int constantDirective(Node *n);
virtual int extendDirective(Node *n);
virtual int fragmentDirective(Node *n);
virtual int importDirective(Node *n);
virtual int includeDirective(Node *n);
virtual int insertDirective(Node *n);
virtual int moduleDirective(Node *n);
virtual int nativeDirective(Node *n);
virtual int pragmaDirective(Node *n);
virtual int typemapDirective(Node *n);
virtual int typemapitemDirective(Node *n);
virtual int typemapcopyDirective(Node *n);
virtual int typesDirective(Node *n);
virtual int cDeclaration(Node *n);
virtual int externDeclaration(Node *n);
virtual int enumDeclaration(Node *n);
virtual int enumvalueDeclaration(Node *n);
virtual int enumforwardDeclaration(Node *n);
virtual int classDeclaration(Node *n);
virtual int classforwardDeclaration(Node *n);
virtual int constructorDeclaration(Node *n);
virtual int destructorDeclaration(Node *n);
virtual int accessDeclaration(Node *n);
virtual int usingDeclaration(Node *n);
virtual int namespaceDeclaration(Node *n);
virtual int templateDeclaration(Node *n);
virtual int lambdaDeclaration(Node *n);
enum AccessMode { PUBLIC, PRIVATE, PROTECTED };
protected:
AccessMode cplus_mode;
AccessMode accessModeFromString(String *access);
int abstractClassTest(Node *n);
};
* class language:
*
* This class defines the functions that need to be supported by the
* scripting language being used. The translator calls these virtual
* functions to output different types of code for different languages.
* ------------------------------------------------------------------------- */
class Language:public Dispatcher {
public:
Language();
virtual ~Language();
virtual int emit_one(Node *n);
String *directorClassName(Node *n);
virtual void main(int argc, char *argv[]);
virtual int top(Node *n);
virtual int applyDirective(Node *n);
virtual int clearDirective(Node *n);
virtual int constantDirective(Node *n);
virtual int extendDirective(Node *n);
virtual int fragmentDirective(Node *n);
virtual int importDirective(Node *n);
virtual int includeDirective(Node *n);
virtual int insertDirective(Node *n);
virtual int moduleDirective(Node *n);
virtual int nativeDirective(Node *n);
virtual int pragmaDirective(Node *n);
virtual int typemapDirective(Node *n);
virtual int typemapcopyDirective(Node *n);
virtual int typesDirective(Node *n);
virtual int cDeclaration(Node *n);
virtual int externDeclaration(Node *n);
virtual int enumDeclaration(Node *n);
virtual int enumvalueDeclaration(Node *n);
virtual int enumforwardDeclaration(Node *n);
virtual int classDeclaration(Node *n);
virtual int classforwardDeclaration(Node *n);
virtual int constructorDeclaration(Node *n);
virtual int destructorDeclaration(Node *n);
virtual int accessDeclaration(Node *n);
virtual int namespaceDeclaration(Node *n);
virtual int usingDeclaration(Node *n);
virtual int functionHandler(Node *n);
virtual int globalfunctionHandler(Node *n);
virtual int memberfunctionHandler(Node *n);
virtual int staticmemberfunctionHandler(Node *n);
virtual int callbackfunctionHandler(Node *n);
virtual int variableHandler(Node *n);
virtual int globalvariableHandler(Node *n);
virtual int membervariableHandler(Node *n);
virtual int staticmembervariableHandler(Node *n);
virtual int memberconstantHandler(Node *n);
virtual int constructorHandler(Node *n);
virtual int copyconstructorHandler(Node *n);
virtual int destructorHandler(Node *n);
virtual int classHandler(Node *n);
virtual int typedefHandler(Node *n);
virtual int constantWrapper(Node *n);
virtual int variableWrapper(Node *n);
virtual int functionWrapper(Node *n);
virtual int nativeWrapper(Node *n);
virtual int classDirector(Node *n);
virtual int classDirectorInit(Node *n);
virtual int classDirectorEnd(Node *n);
virtual int unrollVirtualMethods(Node *n, Node *parent, List *vm, int &virtual_destructor, int protectedbase = 0);
virtual int classDirectorConstructor(Node *n);
virtual int classDirectorDefaultConstructor(Node *n);
virtual int classDirectorMethod(Node *n, Node *parent, String *super);
virtual int classDirectorConstructors(Node *n);
virtual int classDirectorDestructor(Node *n);
virtual int classDirectorMethods(Node *n);
virtual int classDirectorDisown(Node *n);
virtual int validIdentifier(String *s);
virtual int addSymbol(const String *s, const Node *n, const_String_or_char_ptr scope = "");
virtual int addInterfaceSymbol(const String *interface_name, Node *n, const_String_or_char_ptr scope = "");
virtual void dumpSymbols();
virtual Node *symbolLookup(const String *s, const_String_or_char_ptr scope = "");
virtual Hash* symbolAddScope(const_String_or_char_ptr scope);
virtual Hash* symbolScopeLookup(const_String_or_char_ptr scope);
virtual Hash* symbolScopePseudoSymbolLookup(const_String_or_char_ptr scope);
static Node *classLookup(const SwigType *s);
static Node *enumLookup(SwigType *s);
virtual int is_immutable(Node *n);
virtual String *runtimeCode();
virtual String *defaultExternalRuntimeFilename();
virtual void replaceSpecialVariables(String *method, String *tm, Parm *parm);
void enable_cplus_runtime_mode();
int cplus_runtime_mode();
void directorLanguage(int val = 1);
void allow_directors(int val = 1);
void allow_dirprot(int val = 1);
void allow_allprotected(int val = 0);
int dirprot_mode() const;
int need_nonpublic_ctor(Node *n);
int need_nonpublic_member(Node *n);
void setSubclassInstanceCheck(String *s);
void setOverloadResolutionTemplates(String *argc, String *argv);
static Language* instance();
protected:
void allow_multiple_input(int val = 1);
void allow_overloading(int val = 1);
int is_wrapping_class() const;
Node *getCurrentClass() const;
int getCPlusMode() const;
String *getNSpace() const;
String *getClassName() const;
Hash *getClassHash() const;
String *getClassPrefix() const;
String *getEnumClassPrefix() const;
String *getClassType() const;
int is_smart_pointer() const;
virtual String *makeParameterName(Node *n, Parm *p, int arg_num, bool setter = false) const;
virtual bool extraDirectorProtectedCPPMethodsRequired() const;
public:
enum NestedClassSupport {
NCS_None,
NCS_Full,
NCS_Unknown
};
If NCS_Unknown is returned, then the nested classes will be ignored unless
%feature "flatnested" is applied to them, in which case they will appear in global space.
If the target language does not support the notion of class
nesting, the language module should return NCS_None from this function, and
the nested classes will be moved to the global scope (like implicit global %feature "flatnested").
*/
virtual NestedClassSupport nestedClassesSupport() const;
virtual bool kwargsSupport() const;
protected:
This does not include protected virtual methods as they are turned on with the dirprot option. */
bool isNonVirtualProtectedAccess(Node *n) const;
int use_naturalvar_mode(Node *n) const;
String *none_comparison;
String *director_ctor_code;
default. Each language that needs it, has to define it. */
String *director_prot_ctor_code;
int director_multiple_inheritance;
class DoxygenTranslator *doxygenTranslator;
private:
void unrollOneVirtualMethod(String *classname, Node *n, Node *parent, List *vm, int &virtual_destructor, int protectedbase);
Hash *symtabs;
int overloading;
int multiinput;
int cplus_runtime;
static Language *this_;
};
extern "C" {
typedef Language *(*ModuleFactory) (void);
}
enum Status {Disabled, Deprecated, Experimental, Supported};
struct TargetLanguageModule {
const char *name;
ModuleFactory fac;
const char *help;
Status status;
};
int SWIG_main(int argc, char *argv[], const TargetLanguageModule *tlm);
void emit_parameter_variables(ParmList *l, Wrapper *f);
void emit_return_variable(Node *n, SwigType *rt, Wrapper *f);
void SWIG_config_file(const_String_or_char_ptr );
const String *SWIG_output_directory();
void SWIG_config_cppext(const char *ext);
void Swig_print_xml(Node *obj, String *filename);
List *SWIG_output_files();
void SWIG_library_directory(const char *);
int emit_num_arguments(ParmList *);
int emit_num_required(ParmList *);
int emit_isvarargs(ParmList *p);
bool emit_isvarargs_function(Node *n);
void emit_attach_parmmaps(ParmList *, Wrapper *f);
void emit_mark_varargs(ParmList *l);
String *emit_action(Node *n);
int emit_action_code(Node *n, String *wrappercode, String *action);
void Swig_overload_check(Node *n);
String *Swig_overload_dispatch(Node *n, const_String_or_char_ptr fmt, int *, const_String_or_char_ptr fmt_fastdispatch = 0);
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();
String *Swig_csuperclass_call(String *base, String *method, ParmList *l);
String *Swig_class_declaration(Node *n, String *name);
String *Swig_class_name(Node *n);
String *Swig_method_call(const_String_or_char_ptr name, ParmList *parms);
String *Swig_method_decl(SwigType *return_base_type, SwigType *decl, const_String_or_char_ptr id, List *args, int default_args);
String *Swig_director_declaration(Node *n);
void Swig_director_emit_dynamic_cast(Node *n, Wrapper *f);
void Swig_director_parms_fixup(ParmList *parms);
bool Swig_director_can_unwrap(Node *n);
int is_public(Node *n);
int is_private(Node *n);
int is_protected(Node *n);
int is_member_director(Node *parentnode, Node *member);
int is_member_director(Node *member);
int is_non_virtual_protected_access(Node *n);
void Wrapper_virtual_elimination_mode_set(int);
void Wrapper_fast_dispatch_mode_set(int);
void Wrapper_cast_dispatch_mode_set(int);
void Wrapper_naturalvar_mode_set(int);
void clean_overloaded(Node *n);
extern "C" {
const char *Swig_to_string(DOH *object, int count = -1);
const char *Swig_to_string_with_location(DOH *object, int count = -1);
void Swig_print(DOH *object, int count = -1);
void Swig_print_with_location(DOH *object, int count = -1);
}
void Swig_default_allocators(Node *n);
void Swig_process_types(Node *n);
void Swig_contracts(Node *n);
void Swig_contract_mode_set(int flag);
int Swig_contract_mode_get();
void Swig_nested_process_classes(Node *n);
void Swig_nested_name_unnamed_c_structs(Node *n);
void Swig_interface_feature_enable();
void Swig_interface_propagate_methods(Node *n);
template <class T> class save_value {
T _value;
T& _value_ptr;
save_value(const save_value&);
save_value& operator=(const save_value&);
public:
save_value(T& value) : _value(value), _value_ptr(value) {}
save_value(T& value, T new_val) : _value(value), _value_ptr(value) { value = new_val; }
~save_value() { _value_ptr = _value; }
};
#endif