Merge branch 'swig:master' into imfunc

This commit is contained in:
LindleyF 2022-02-02 16:15:17 -08:00 • committed by GitHub
commit e25911b846
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
308 changed files with 5008 additions and 4773 deletions

View file

@ -351,6 +351,9 @@ static int yylook(void) {
}
break;
case SWIG_TOKEN_ELLIPSIS:
return ELLIPSIS;
/* Look for multi-character sequences */
case SWIG_TOKEN_RSTRING:

View file

@ -1587,6 +1587,9 @@ static String *add_qualifier_to_declarator(SwigType *type, SwigType *qualifier)
Node *node;
};
// Define special token END for end of input.
%token END 0
%token <id> ID
%token <str> HBLOCK
%token <id> POUND
@ -1596,7 +1599,7 @@ static String *add_qualifier_to_declarator(SwigType *type, SwigType *qualifier)
%token <dtype> NUM_INT NUM_FLOAT NUM_UNSIGNED NUM_LONG NUM_ULONG NUM_LONGLONG NUM_ULONGLONG NUM_BOOL
%token <intvalue> TYPEDEF
%token <type> TYPE_INT TYPE_UNSIGNED TYPE_SHORT TYPE_LONG TYPE_FLOAT TYPE_DOUBLE TYPE_CHAR TYPE_WCHAR TYPE_VOID TYPE_SIGNED TYPE_BOOL TYPE_COMPLEX TYPE_TYPEDEF TYPE_RAW TYPE_NON_ISO_INT8 TYPE_NON_ISO_INT16 TYPE_NON_ISO_INT32 TYPE_NON_ISO_INT64
%token LPAREN RPAREN COMMA SEMI EXTERN INIT LBRACE RBRACE PERIOD
%token LPAREN RPAREN COMMA SEMI EXTERN INIT LBRACE RBRACE PERIOD ELLIPSIS
%token CONST_QUAL VOLATILE REGISTER STRUCT UNION EQUAL SIZEOF MODULE LBRACKET RBRACKET
%token BEGINFILE ENDOFFILE
%token ILLEGAL CONSTANT
@ -1671,11 +1674,11 @@ static String *add_qualifier_to_declarator(SwigType *type, SwigType *qualifier)
%type <p> templateparameter ;
%type <id> templcpptype cpptype classkey classkeyopt access_specifier;
%type <node> base_specifier;
%type <str> ellipsis variadic;
%type <str> variadic;
%type <type> type rawtype type_right anon_bitfield_type decltype ;
%type <bases> base_list inherit raw_inherit;
%type <dtype> definetype def_args etype default_delete deleted_definition explicit_default;
%type <dtype> expr exprnum exprcompound valexpr exprmem;
%type <dtype> expr exprnum exprsimple exprcompound valexpr exprmem;
%type <id> ename ;
%type <id> less_valparms_greater;
%type <str> type_qualifier;
@ -2010,6 +2013,10 @@ constant_directive : CONSTANT identifier EQUAL definetype SEMI {
Swig_warning(WARN_PARSE_BAD_VALUE,cparse_file,cparse_line,"Bad constant value (ignored).\n");
$$ = 0;
}
| CONSTANT error END {
Swig_error(cparse_file,cparse_line,"Missing ';' after %%constant.\n");
SWIG_exit(EXIT_FAILURE);
}
;
/* ------------------------------------------------------------
@ -3376,6 +3383,10 @@ cpp_alternate_rettype : primitive_type { $$ = $1; }
*/
| TYPE_RAW { $$ = $1; }
| idcolon { $$ = $1; }
| idcolon AND {
$$ = $1;
SwigType_add_reference($$);
}
| decltype { $$ = $1; }
;
@ -4355,18 +4366,30 @@ cpp_template_decl : TEMPLATE LESSTHAN template_parms GREATERTHAN {
parsing_template_declaration = 0;
}
/* Explicit template instantiation */
/* Class template explicit instantiation definition */
| TEMPLATE cpptype idcolon {
Swig_warning(WARN_PARSE_EXPLICIT_TEMPLATE, cparse_file, cparse_line, "Explicit template instantiation ignored.\n");
$$ = 0;
}
/* Explicit template instantiation without the translation unit */
/* Function template explicit instantiation definition */
| TEMPLATE cpp_alternate_rettype idcolon LPAREN parms RPAREN {
Swig_warning(WARN_PARSE_EXPLICIT_TEMPLATE, cparse_file, cparse_line, "Explicit template instantiation ignored.\n");
$$ = 0;
}
/* Class template explicit instantiation declaration (extern template) */
| EXTERN TEMPLATE cpptype idcolon {
Swig_warning(WARN_PARSE_EXPLICIT_TEMPLATE, cparse_file, cparse_line, "Explicit template instantiation ignored.\n");
Swig_warning(WARN_PARSE_EXTERN_TEMPLATE, cparse_file, cparse_line, "Extern template ignored.\n");
$$ = 0;
}
;
/* Function template explicit instantiation declaration (extern template) */
| EXTERN TEMPLATE cpp_alternate_rettype idcolon LPAREN parms RPAREN {
Swig_warning(WARN_PARSE_EXTERN_TEMPLATE, cparse_file, cparse_line, "Extern template ignored.\n");
$$ = 0;
}
;
cpp_template_possible: c_decl {
$$ = $1;
@ -4449,11 +4472,12 @@ templateparameterstail : COMMA templateparameter templateparameterstail {
/* Namespace support */
cpp_using_decl : USING idcolon SEMI {
String *uname = Swig_symbol_type_qualify($2,0);
String *uname = Swig_symbol_type_qualify($2,0);
String *name = Swig_scopename_last($2);
$$ = new_node("using");
$$ = new_node("using");
Setattr($$,"uname",uname);
Setattr($$,"name", name);
Swig_symbol_add_using(name, uname, $$);
Delete(uname);
Delete(name);
add_symbols($$);
@ -5143,7 +5167,7 @@ parm_no_dox : rawtype parameter_declarator {
Setattr($$,"value",$7.val);
}
}
| PERIOD PERIOD PERIOD {
| ELLIPSIS {
SwigType *t = NewString("v(...)");
$$ = NewParmWithoutFileLineInfo(t, 0);
previousNode = currentNode;
@ -5488,16 +5512,16 @@ declarator : pointer notso_direct_declarator {
/* Variadic versions eg. MyClasses&... myIds */
| pointer PERIOD PERIOD PERIOD notso_direct_declarator {
$$ = $5;
| pointer ELLIPSIS notso_direct_declarator {
$$ = $3;
if ($$.type) {
SwigType_push($1,$$.type);
Delete($$.type);
}
$$.type = $1;
}
| pointer AND PERIOD PERIOD PERIOD notso_direct_declarator {
$$ = $6;
| pointer AND ELLIPSIS notso_direct_declarator {
$$ = $4;
SwigType_add_reference($1);
if ($$.type) {
SwigType_push($1,$$.type);
@ -5505,8 +5529,8 @@ declarator : pointer notso_direct_declarator {
}
$$.type = $1;
}
| pointer LAND PERIOD PERIOD PERIOD notso_direct_declarator {
$$ = $6;
| pointer LAND ELLIPSIS notso_direct_declarator {
$$ = $4;
SwigType_add_rvalue_reference($1);
if ($$.type) {
SwigType_push($1,$$.type);
@ -5514,34 +5538,34 @@ declarator : pointer notso_direct_declarator {
}
$$.type = $1;
}
| PERIOD PERIOD PERIOD direct_declarator {
$$ = $4;
| ELLIPSIS direct_declarator {
$$ = $2;
if (!$$.type) $$.type = NewStringEmpty();
}
| AND PERIOD PERIOD PERIOD notso_direct_declarator {
$$ = $5;
| AND ELLIPSIS notso_direct_declarator {
$$ = $3;
$$.type = NewStringEmpty();
SwigType_add_reference($$.type);
if ($5.type) {
SwigType_push($$.type,$5.type);
Delete($5.type);
if ($3.type) {
SwigType_push($$.type,$3.type);
Delete($3.type);
}
}
| LAND PERIOD PERIOD PERIOD notso_direct_declarator {
| LAND ELLIPSIS notso_direct_declarator {
/* Introduced in C++11, move operator && */
/* Adds one S/R conflict */
$$ = $5;
$$ = $3;
$$.type = NewStringEmpty();
SwigType_add_rvalue_reference($$.type);
if ($5.type) {
SwigType_push($$.type,$5.type);
Delete($5.type);
if ($3.type) {
SwigType_push($$.type,$3.type);
Delete($3.type);
}
}
| idcolon DSTAR PERIOD PERIOD PERIOD notso_direct_declarator {
| idcolon DSTAR ELLIPSIS notso_direct_declarator {
SwigType *t = NewStringEmpty();
$$ = $6;
$$ = $4;
SwigType_add_memberpointer(t,$1);
if ($$.type) {
SwigType_push(t,$$.type);
@ -5549,9 +5573,9 @@ declarator : pointer notso_direct_declarator {
}
$$.type = t;
}
| pointer idcolon DSTAR PERIOD PERIOD PERIOD notso_direct_declarator {
| pointer idcolon DSTAR ELLIPSIS notso_direct_declarator {
SwigType *t = NewStringEmpty();
$$ = $7;
$$ = $5;
SwigType_add_memberpointer(t,$2);
SwigType_push($1,t);
if ($$.type) {
@ -5561,8 +5585,8 @@ declarator : pointer notso_direct_declarator {
$$.type = $1;
Delete(t);
}
| pointer idcolon DSTAR AND PERIOD PERIOD PERIOD notso_direct_declarator {
$$ = $8;
| pointer idcolon DSTAR AND ELLIPSIS notso_direct_declarator {
$$ = $6;
SwigType_add_memberpointer($1,$2);
SwigType_add_reference($1);
if ($$.type) {
@ -5571,8 +5595,8 @@ declarator : pointer notso_direct_declarator {
}
$$.type = $1;
}
| pointer idcolon DSTAR LAND PERIOD PERIOD PERIOD notso_direct_declarator {
$$ = $8;
| pointer idcolon DSTAR LAND ELLIPSIS notso_direct_declarator {
$$ = $6;
SwigType_add_memberpointer($1,$2);
SwigType_add_rvalue_reference($1);
if ($$.type) {
@ -5581,9 +5605,9 @@ declarator : pointer notso_direct_declarator {
}
$$.type = $1;
}
| idcolon DSTAR AND PERIOD PERIOD PERIOD notso_direct_declarator {
| idcolon DSTAR AND ELLIPSIS notso_direct_declarator {
SwigType *t = NewStringEmpty();
$$ = $7;
$$ = $5;
SwigType_add_memberpointer(t,$1);
SwigType_add_reference(t);
if ($$.type) {
@ -5592,9 +5616,9 @@ declarator : pointer notso_direct_declarator {
}
$$.type = t;
}
| idcolon DSTAR LAND PERIOD PERIOD PERIOD notso_direct_declarator {
| idcolon DSTAR LAND ELLIPSIS notso_direct_declarator {
SwigType *t = NewStringEmpty();
$$ = $7;
$$ = $5;
SwigType_add_memberpointer(t,$1);
SwigType_add_rvalue_reference(t);
if ($$.type) {
@ -6509,19 +6533,18 @@ exprmem : ID ARROW ID {
$$ = $1;
Printf($$.val, "->%s", $3);
}
/* This generates a shift-reduce
| ID PERIOD ID {
$$.val = NewStringf("%s.%s", $1, $3);
$$.type = 0;
}
*/
| exprmem PERIOD ID {
$$ = $1;
Printf($$.val, ".%s", $3);
}
;
valexpr : exprnum {
/* Non-compound expression */
exprsimple : exprnum {
$$ = $1;
}
| exprmem {
@ -6536,12 +6559,30 @@ valexpr : exprnum {
$$.val = NewStringf("sizeof(%s)",SwigType_str($3,0));
$$.type = T_ULONG;
}
| SIZEOF PERIOD PERIOD PERIOD LPAREN type parameter_declarator RPAREN {
SwigType_push($6,$7.type);
$$.val = NewStringf("sizeof...(%s)",SwigType_str($6,0));
| SIZEOF ELLIPSIS LPAREN type parameter_declarator RPAREN {
SwigType_push($4,$5.type);
$$.val = NewStringf("sizeof...(%s)",SwigType_str($4,0));
$$.type = T_ULONG;
}
| exprcompound { $$ = $1; }
/* We don't support all valid expressions here currently - e.g.
* sizeof(<unaryop> x) doesn't work - but those are unlikely to
* be seen in real code.
*
* Note: sizeof(x) is not handled here, but instead by the rule
* for sizeof(<type>) because it matches that syntactically.
*/
| SIZEOF LPAREN exprsimple RPAREN {
$$.val = NewStringf("sizeof(%s)", $3.val);
$$.type = T_ULONG;
}
/* `sizeof expr` without parentheses is valid for an expression,
* but not for a type. This doesn't support `sizeof x` in
* addition to the case not supported above.
*/
| SIZEOF exprsimple {
$$.val = NewStringf("sizeof(%s)", $2.val);
$$.type = T_ULONG;
}
| wstring {
$$.val = $1;
$$.rawval = NewStringf("L\"%s\"", $$.val);
@ -6576,6 +6617,11 @@ valexpr : exprnum {
$$.final = 0;
}
;
valexpr : exprsimple { $$ = $1; }
| exprcompound { $$ = $1; }
/* grouping */
| LPAREN expr RPAREN %prec CAST {
$$.val = NewStringf("(%s)",$2.val);
@ -6654,7 +6700,7 @@ valexpr : exprnum {
$$ = $2;
$$.val = NewStringf("*%s",$2.val);
}
;
;
exprnum : NUM_INT { $$ = $1; }
| NUM_FLOAT { $$ = $1; }
@ -6722,16 +6768,24 @@ exprcompound : expr PLUS expr {
$$.val = NewStringf("%s!=%s",COMPOUND_EXPR_VAL($1),COMPOUND_EXPR_VAL($3));
$$.type = cparse_cplusplus ? T_BOOL : T_INT;
}
/* Sadly this causes 2 reduce-reduce conflicts with templates. FIXME resolve these.
| expr GREATERTHAN expr {
$$.val = NewStringf("%s > %s", COMPOUND_EXPR_VAL($1), COMPOUND_EXPR_VAL($3));
/* Trying to parse `>` in the general case results in conflicts
* in the parser, but all user-reported cases are actually inside
* parentheses and we can handle that case.
*/
| LPAREN expr GREATERTHAN expr RPAREN {
$$.val = NewStringf("%s > %s", COMPOUND_EXPR_VAL($2), COMPOUND_EXPR_VAL($4));
$$.type = cparse_cplusplus ? T_BOOL : T_INT;
}
| expr LESSTHAN expr {
$$.val = NewStringf("%s < %s", COMPOUND_EXPR_VAL($1), COMPOUND_EXPR_VAL($3));
/* Similarly for `<` except trying to handle exprcompound on the
* left side gives a shift/reduce conflict, so also restrict
* handling to non-compound subexpressions there. Again this
* covers all user-reported cases.
*/
| LPAREN exprsimple LESSTHAN expr RPAREN {
$$.val = NewStringf("%s < %s", COMPOUND_EXPR_VAL($2), COMPOUND_EXPR_VAL($4));
$$.type = cparse_cplusplus ? T_BOOL : T_INT;
}
*/
| expr GREATERTHANOREQUALTO expr {
$$.val = NewStringf("%s >= %s", COMPOUND_EXPR_VAL($1), COMPOUND_EXPR_VAL($3));
$$.type = cparse_cplusplus ? T_BOOL : T_INT;
@ -6778,14 +6832,9 @@ exprcompound : expr PLUS expr {
}
;
ellipsis : PERIOD PERIOD PERIOD {
variadic : ELLIPSIS {
$$ = NewString("...");
}
;
variadic : ellipsis {
$$ = $1;
}
| empty {
$$ = 0;
}
@ -6875,11 +6924,11 @@ templcpptype : CLASS {
$$ = (char *)"typename";
if (!inherit_list) last_cpptype = $$;
}
| CLASS PERIOD PERIOD PERIOD {
| CLASS ELLIPSIS {
$$ = (char *)"class...";
if (!inherit_list) last_cpptype = $$;
}
| TYPENAME PERIOD PERIOD PERIOD {
| TYPENAME ELLIPSIS {
$$ = (char *)"typename...";
if (!inherit_list) last_cpptype = $$;
}
@ -7085,8 +7134,8 @@ ctor_initializer : COLON mem_initializer_list
mem_initializer_list : mem_initializer
| mem_initializer_list COMMA mem_initializer
| mem_initializer PERIOD PERIOD PERIOD
| mem_initializer_list COMMA mem_initializer PERIOD PERIOD PERIOD
| mem_initializer ELLIPSIS
| mem_initializer_list COMMA mem_initializer ELLIPSIS
;
mem_initializer : idcolon LPAREN {

View file

@ -364,7 +364,7 @@ extern void DohMemoryDebug(void);
#define Push(s,x) DohInsertitem(s,DOH_BEGIN,x)
#define Len DohLen
#define Data DohData
#define Char (char *) Data
#define Char(X) ((char *) Data(X))
#define Cmp DohCmp
#define Equal DohEqual
#define Setline DohSetline

View file

@ -1241,6 +1241,9 @@ void DoxygenParser::processHtmlTags(size_t &pos, const std::string &line) {
// prepend '<' to distinguish HTML tags from doxygen commands
if (!cmd.empty() && addDoxyCommand(m_tokenList, '<' + cmd)) {
// it is a valid HTML command
if (pos == string::npos) {
pos = line.size();
}
if (line[pos] != '>') {
// it should be HTML tag with args,
// for example <A ...>, <IMG ...>, ...
@ -1266,7 +1269,7 @@ void DoxygenParser::processHtmlTags(size_t &pos, const std::string &line) {
}
}
if (pos != string::npos) {
if (pos < line.size()) {
pos++; // skip '>'
}
} else {

View file

@ -53,13 +53,13 @@ public:
virtual ~DoxygenTranslator();
/*
* Return the documentation for a given node formated for the correct
* Return the documentation for a given node formatted for the correct
* documentation system.
*/
String *getDocumentation(Node *node, const_String_or_char_ptr indentationString);
/*
* Returns truem is the specified node has comment attached.
* Returns true if the specified node has comment attached.
*/
bool hasDocumentation(Node *node);

View file

@ -195,7 +195,7 @@ private:
typedef std::map<std::string, std::pair<tagHandler, std::string> >TagHandlersMap;
static TagHandlersMap tagHandlers;
// this contains the sections tittles, like 'Arguments:' or 'Notes:', that are printed only once
// this contains the sections titles, like 'Arguments:' or 'Notes:', that are printed only once
static std::map<std::string, std::string> sectionTitles;
// Helper functions for fillStaticTables(): make a new tag handler object.

View file

@ -93,6 +93,7 @@
#define WARN_PARSE_NESTED_TEMPLATE 324
#define WARN_PARSE_NAMED_NESTED_CLASS 325
#define WARN_PARSE_EXTEND_NAME 326
#define WARN_PARSE_EXTERN_TEMPLATE 327
#define WARN_CPP11_LAMBDA 340
#define WARN_CPP11_ALIAS_DECLARATION 341 /* redundant now */

File diff suppressed because it is too large Load diff

View file

@ -196,7 +196,7 @@ public:
String *name = Getattr(n, "name") ? Getattr(n, "name") : NewString("<unnamed>");
Swig_warning(WARN_JAVA_NSPACE_WITHOUT_PACKAGE, Getfile(n), Getline(n),
"The nspace feature is used on '%s' without -package. "
"The generated code may not compile as Java does not support types declared in a named package accessing types declared in an unnamed package.\n", name);
"The generated code may not compile as Java does not support types declared in a named package accessing types declared in an unnamed package.\n", SwigType_namestr(name));
}
}

View file

@ -994,7 +994,7 @@ int JSEmitter::emitDtor(Node *n) {
{
SWIG_PRV_DATA* t = (SWIG_PRV_DATA*)JSObjectGetPrivate(thisObject);
if(t && t->swigCMemOwn) free ((${type}*)t->swigCObject);
if(t) free(t);
free(t);
}
%}
@ -1007,7 +1007,7 @@ int JSEmitter::emitDtor(Node *n) {
${type}* arg1 = (${type}*)t->swigCObject;
${destructor_action}
}
if(t) free(t);
free(t);
Based on what I saw in the Lua and Ruby modules, I use Getattr(n, "wrap:action")
to decide if the user has a preferred destructor action.
@ -1255,7 +1255,7 @@ int JSEmitter::emitFunctionDispatcher(Node *n, bool /*is_member */ ) {
// Note: this dispatcher function gets called after the last overloaded function has been created.
// At this time, n.wrap:name contains the name of the last wrapper function.
// To get a valid function name for the dispatcher function we take the last wrapper name and
// substract the extension "sym:overname",
// subtract the extension "sym:overname",
String *wrap_name = NewString(Getattr(n, "wrap:name"));
String *overname = Getattr(n, "sym:overname");

View file

@ -1320,16 +1320,21 @@ int Language::staticmemberfunctionHandler(Node *n) {
Delete(mrename);
mrename = mangled;
if (Getattr(n, "sym:overloaded") && code) {
Append(cname, Getattr(defaultargs ? defaultargs : n, "sym:overname"));
}
if (code) {
// See Swig_MethodToFunction() for the explanation of this code.
if (Getattr(n, "sym:overloaded")) {
Append(cname, Getattr(defaultargs ? defaultargs : n, "sym:overname"));
} else {
Append(cname, "__SWIG");
}
if (!defaultargs && code) {
/* Hmmm. An added static member. We have to create a little wrapper for this */
String *mangled_cname = Swig_name_mangle(cname);
Swig_add_extension_code(n, mangled_cname, parms, type, code, CPlusPlus, 0);
Setattr(n, "extendname", mangled_cname);
Delete(mangled_cname);
if (!defaultargs) {
/* Hmmm. An added static member. We have to create a little wrapper for this */
String *mangled_cname = Swig_name_mangle(cname);
Swig_add_extension_code(n, mangled_cname, parms, type, code, CPlusPlus, 0);
Setattr(n, "extendname", mangled_cname);
Delete(mangled_cname);
}
}
}

View file

@ -137,7 +137,7 @@ static const char *usage4 = (const char *) "\
-oh <headfile> - Set name of C++ output header file for directors to <headfile>\n\
-outcurrentdir - Set default output dir to current dir instead of input file's path\n\
-outdir <dir> - Set language specific files output directory to <dir>\n\
-pcreversion - Display PCRE version information\n\
-pcreversion - Display PCRE2 version information\n\
-small - Compile in virtual elimination and compact mode\n\
-swiglib - Report location of SWIG library and exit\n\
-templatereduce - Reduce all the typedefs in templates\n\

View file

@ -21,6 +21,7 @@
String *argv_template_string;
String *argc_template_string;
namespace {
struct Overloaded {
Node *n; /* Node */
int argc; /* Argument count */
@ -28,6 +29,7 @@ struct Overloaded {
int error; /* Ambiguity error */
bool implicitconv_function; /* For ordering implicitconv functions*/
};
}
static int fast_dispatch_mode = 0;
static int cast_dispatch_mode = 0;

View file

@ -445,13 +445,7 @@ public:
Printv(magic,
"#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n",
"#ifdef PERL_OBJECT\n",
"#define MAGIC_CLASS _wrap_", underscore_module, "_var::\n",
"class _wrap_", underscore_module, "_var : public CPerlObj {\n",
"public:\n",
"#else\n",
"#define MAGIC_CLASS\n",
"#endif\n",
"SWIGCLASS_STATIC int swig_magic_readonly(pTHX_ SV *SWIGUNUSEDPARM(sv), MAGIC *SWIGUNUSEDPARM(mg)) {\n",
tab4, "MAGIC_PPERL\n", tab4, "croak(\"Value is read-only.\");\n", tab4, "return 0;\n", "}\n", NIL);
@ -470,7 +464,6 @@ public:
/* Dump out variable wrappers */
Printv(magic, "\n\n#ifdef PERL_OBJECT\n", "};\n", "#endif\n", NIL);
Printv(magic, "\n#ifdef __cplusplus\n}\n#endif\n", NIL);
Printf(f_header, "%s\n", magic);

File diff suppressed because it is too large Load diff

View file

@ -73,8 +73,10 @@ static int py3 = 0;
/* C++ Support + Shadow Classes */
static int have_constructor;
static int have_repr;
static int have_constructor = 0;
static int have_repr = 0;
static bool have_builtin_static_member_method_callback = false;
static bool have_fast_proxy_static_member_method_callback = false;
static String *real_classname;
/* Thread Support */
@ -93,6 +95,7 @@ static int nortti = 0;
static int relativeimport = 0;
/* flags for the make_autodoc function */
namespace {
enum autodoc_t {
AUTODOC_CLASS,
AUTODOC_CTOR,
@ -103,7 +106,7 @@ enum autodoc_t {
AUTODOC_CONST,
AUTODOC_VAR
};
}
static const char *usage1 = "\
Python Options (available with -python)\n\
@ -444,6 +447,11 @@ public:
}
}
if (builtin && !shadow) {
Printf(stderr, "Incompatible options -builtin and -noproxy specified.\n");
SWIG_exit(EXIT_FAILURE);
}
if (doxygen)
doxygenTranslator = new PyDocConverter(doxygen_translator_flags);
@ -814,6 +822,10 @@ public:
Append(const_code, "{0, 0, 0, 0.0, 0, 0}};\n");
Printf(f_wrappers, "%s\n", const_code);
if (have_fast_proxy_static_member_method_callback)
Printf(f_init, " SWIG_Python_FixMethods(SwigMethods_proxydocs, swig_const_table, swig_types, swig_type_initial);\n\n");
initialize_threads(f_init);
Printf(f_init, "#if PY_VERSION_HEX >= 0x03000000\n");
@ -2477,6 +2489,7 @@ public:
Printf(methods, "\"swig_ptr: %s\"", Getattr(n, "feature:callback:name"));
if (fastproxy) {
Printf(methods_proxydocs, "\"swig_ptr: %s\"", Getattr(n, "feature:callback:name"));
have_fast_proxy_static_member_method_callback = true;
}
} else {
Append(methods, "NULL");
@ -2797,7 +2810,7 @@ public:
/* Generate code for argument marshalling */
if (funpack) {
if (num_arguments > 0 && !overname) {
if (num_arguments > (builtin_self && !constructor ? 1 : 0) && !overname) {
sprintf(source, "PyObject *swig_obj[%d]", num_arguments);
Wrapper_add_localv(f, "swig_obj", source, NIL);
}
@ -3423,7 +3436,6 @@ public:
Printf(f_init, "#endif\n");
Printf(f_init, "\t }\n");
Printf(f_init, "\t PyDict_SetItemString(md, \"%s\", globals);\n", global_name);
Printf(f_init, "\t Py_DECREF(globals);\n");
if (builtin)
Printf(f_init, "\t SwigPyBuiltin_AddPublicSymbol(public_interface, \"%s\");\n", global_name);
have_globals = 1;
@ -3935,6 +3947,10 @@ public:
int funpack = fastunpack;
static String *tp_new = NewString("PyType_GenericNew");
if (have_builtin_static_member_method_callback) {
Printf(f_init, " SWIG_Python_FixMethods(SwigPyBuiltin_%s_methods, swig_const_table, swig_types, swig_type_initial);\n", mname);
}
Printv(f_init, " SwigPyBuiltin_SetMetaType(builtin_pytype, metatype);\n", NIL);
// We can’t statically initialize a structure member with a function defined in another C module
@ -4365,6 +4381,7 @@ public:
/* Create new strings for building up a wrapper function */
have_constructor = 0;
have_repr = 0;
have_builtin_static_member_method_callback = false;
class_name = Getattr(n, "sym:name");
real_classname = Getattr(n, "name");
@ -4727,6 +4744,7 @@ public:
Swig_restore(n);
}
int kw = (check_kwargs(n) && !Getattr(n, "sym:overloaded")) ? 1 : 0;
if (builtin && in_class) {
if ((GetFlagAttr(n, "feature:extend") || checkAttribute(n, "access", "public"))
&& !Getattr(class_members, symname)) {
@ -4741,7 +4759,7 @@ public:
else if (funpack && argcount == 1)
Append(pyflags, "METH_O");
else
Append(pyflags, "METH_VARARGS");
Append(pyflags, kw ? "METH_VARARGS|METH_KEYWORDS" : "METH_VARARGS");
// Cast via void(*)(void) to suppress GCC -Wcast-function-type warning.
// Python should always call the function correctly, but the Python C
// API requires us to store it in function pointer of a different type.
@ -4749,6 +4767,11 @@ public:
String *ds = cdocstring(n, AUTODOC_STATICFUNC);
Printf(builtin_methods, " { \"%s\", (PyCFunction)(void(*)(void))%s, %s, \"%s\" },\n", symname, wname, pyflags, ds);
Delete(ds);
} else if (Getattr(n, "feature:callback")) {
String *ds = NewStringf("swig_ptr: %s", Getattr(n, "feature:callback:name"));
Printf(builtin_methods, " { \"%s\", (PyCFunction)(void(*)(void))%s, %s, \"%s\" },\n", symname, wname, pyflags, ds);
Delete(ds);
have_builtin_static_member_method_callback = true;
} else {
Printf(builtin_methods, " { \"%s\", (PyCFunction)(void(*)(void))%s, %s, \"\" },\n", symname, wname, pyflags);
}
@ -4767,7 +4790,6 @@ public:
String *staticfunc_name = NewString(fastproxy ? "_swig_new_static_method" : "staticmethod");
bool fast = (fastproxy && !have_addtofunc(n)) || Getattr(n, "feature:callback");
if (!fast || olddefs) {
int kw = (check_kwargs(n) && !Getattr(n, "sym:overloaded")) ? 1 : 0;
String *parms = make_pyParmList(n, false, false, kw);
String *callParms = make_pyParmList(n, false, true, kw);
Printv(f_shadow, "\n", tab4, "@staticmethod", NIL);

View file

@ -1301,13 +1301,14 @@ void R::addAccessor(String *memberName, Wrapper *wrapper, String *name,
#define MAX_OVERLOAD 256
namespace {
struct Overloaded {
Node *n; /* Node */
int argc; /* Argument count */
ParmList *parms; /* Parameters used for overload check */
int error; /* Ambiguity error */
};
}
List * R::Swig_overload_rank(Node *n,
bool script_lang_wrapping) {
@ -2568,7 +2569,7 @@ int R::generateCopyRoutines(Node *n) {
Printf(sfile, "# Start definition of copy methods for %s\n", rclassName);
Printf(sfile, "setMethod('copyToR', '_p_%s', CopyToR%s);\n", rclassName,
Printf(sfile, "setMethod('copyToR', '_p%s', CopyToR%s);\n", mangledName,
mangledName);
Printf(sfile, "setMethod('copyToC', '%s', CopyToC%s);\n\n", rclassName,
mangledName);

View file

@ -106,9 +106,10 @@ public:
char *strip(const_String_or_char_ptr s) {
Clear(temp);
Append(temp, s);
if (Strncmp(s, prefix, Len(prefix)) == 0) {
Replaceall(temp, prefix, "");
Append(temp, Char(s) + Len(prefix));
} else {
Append(temp, s);
}
return Char(temp);
}
@ -116,6 +117,7 @@ public:
/* flags for the make_autodoc function */
namespace {
enum autodoc_t {
AUTODOC_CLASS,
AUTODOC_CTOR,
@ -127,6 +129,7 @@ enum autodoc_t {
AUTODOC_SETTER,
AUTODOC_NONE
};
}
static const char *usage = "\
Ruby Options (available with -ruby)\n\

View file

@ -228,9 +228,10 @@ public:
// Module initialization function
String *gatewayInitFunctionName = NewStringf("%s_Init", gatewayName);
String *wrapperInitFunctionName = NewStringf("SWIG_%s_Init", gatewayName);
/* Add initialization function to builder table */
addFunctionToScilab(gatewayInitFunctionName, gatewayInitFunctionName);
addFunctionToScilab(gatewayInitFunctionName, wrapperInitFunctionName);
// Add helper functions to builder table
addHelperFunctions();

View file

@ -632,7 +632,7 @@ String *Swig_cppconstructor_director_call(const_String_or_char_ptr name, ParmLis
* If you define SWIG_FAST_REC_SEARCH, the method will set the found
* 'attr' in the target class 'n'. If not, the method will set the
* 'noattr' one. This prevents of having to navigate the entire
* hierarchy tree everytime, so, it is an O(1) method... or something
* hierarchy tree every time, so, it is an O(1) method... or something
* like that. However, it populates all the parsed classes with the
* 'attr' and/or 'noattr' attributes.
*
@ -1076,9 +1076,18 @@ int Swig_MethodToFunction(Node *n, const_String_or_char_ptr nspace, String *clas
/* Check if the method is overloaded. If so, and it has code attached, we append an extra suffix
to avoid a name-clash in the generated wrappers. This allows overloaded methods to be defined
in C. */
if (Getattr(n, "sym:overloaded") && code) {
Append(mangled, Getattr(defaultargs ? defaultargs : n, "sym:overname"));
in C.
But when not using the suffix used for overloaded functions, we still need to ensure that the
wrapper name doesn't conflict with any wrapper functions, so make it sufficiently unique by
appending a suffix similar to the one used for overloaded functions to it.
*/
if (code) {
if (Getattr(n, "sym:overloaded")) {
Append(mangled, Getattr(defaultargs ? defaultargs : n, "sym:overname"));
} else {
Append(mangled, "__SWIG");
}
}
/* See if there is any code that we need to emit */

View file

@ -1312,7 +1312,8 @@ void Swig_offset_string(String *s, int number) {
#ifdef HAVE_PCRE
#include <pcre.h>
#define PCRE2_CODE_UNIT_WIDTH 8
#include <pcre2.h>
static int split_regex_pattern_subst(String *s, String **pattern, String **subst, const char **input)
{
@ -1375,7 +1376,7 @@ static void copy_with_maybe_case_conversion(String *dst, const char *src, int le
}
}
String *replace_captures(int num_captures, const char *input, String *subst, int captures[], String *pattern, String *s)
String *replace_captures(int num_captures, const char *input, String *subst, size_t captures[], String *pattern, String *s)
{
int convertCase = 0, convertNextOnly = 0;
String *result = NewStringEmpty();
@ -1397,7 +1398,7 @@ String *replace_captures(int num_captures, const char *input, String *subst, int
} else if (isdigit((unsigned char)*p)) {
int group = *p++ - '0';
if (group < num_captures) {
int l = captures[group*2], r = captures[group*2 + 1];
int l = (int)captures[group*2], r = (int)captures[group*2 + 1];
if (l != -1) {
copy_with_maybe_case_conversion(result, input + l, r - l, &convertCase, convertNextOnly);
}
@ -1449,26 +1450,31 @@ String *Swig_string_regex(String *s) {
const int pcre_options = 0;
String *res = 0;
pcre *compiled_pat = 0;
const char *pcre_error, *input;
int pcre_errorpos;
pcre2_code *compiled_pat = 0;
const char *input;
PCRE2_UCHAR pcre_error[256];
int pcre_errornum;
size_t pcre_errorpos;
String *pattern = 0, *subst = 0;
int captures[30];
size_t *captures = 0;
pcre2_match_data *match_data = 0;
if (split_regex_pattern_subst(s, &pattern, &subst, &input)) {
int rc;
compiled_pat = pcre_compile(
Char(pattern), pcre_options, &pcre_error, &pcre_errorpos, NULL);
compiled_pat = pcre2_compile(
(PCRE2_SPTR8)Char(pattern), PCRE2_ZERO_TERMINATED, pcre_options, &pcre_errornum, &pcre_errorpos, NULL);
if (!compiled_pat) {
pcre2_get_error_message (pcre_errornum, pcre_error, sizeof pcre_error);
Swig_error("SWIG", Getline(s), "PCRE compilation failed: '%s' in '%s':%i.\n",
pcre_error, Char(pattern), pcre_errorpos);
SWIG_exit(EXIT_FAILURE);
}
rc = pcre_exec(compiled_pat, NULL, input, (int)strlen(input), 0, 0, captures, 30);
match_data = pcre2_match_data_create_from_pattern (compiled_pat, NULL);
rc = pcre2_match(compiled_pat, (PCRE2_SPTR8)input, PCRE2_ZERO_TERMINATED, 0, 0, match_data, NULL);
captures = pcre2_get_ovector_pointer (match_data);
if (rc >= 0) {
res = replace_captures(rc, input, subst, captures, pattern, s);
} else if (rc != PCRE_ERROR_NOMATCH) {
} else if (rc != PCRE2_ERROR_NOMATCH) {
Swig_error("SWIG", Getline(s), "PCRE execution failed: error %d while matching \"%s\" using \"%s\".\n",
rc, Char(pattern), input);
SWIG_exit(EXIT_FAILURE);
@ -1477,12 +1483,19 @@ String *Swig_string_regex(String *s) {
DohDelete(pattern);
DohDelete(subst);
pcre_free(compiled_pat);
pcre2_code_free(compiled_pat);
pcre2_match_data_free(match_data);
return res ? res : NewStringEmpty();
}
String *Swig_pcre_version(void) {
return NewStringf("PCRE Version: %s", pcre_version());
int len = pcre2_config(PCRE2_CONFIG_VERSION, NULL);
char *buf = malloc(len);
String *result;
pcre2_config(PCRE2_CONFIG_VERSION, buf);
result = NewStringf("PCRE2 Version: %s", buf);
free(buf);
return result;
}
#else

View file

@ -1092,26 +1092,32 @@ static DOH *get_lattr(Node *n, List *lattr) {
}
#ifdef HAVE_PCRE
#include <pcre.h>
#define PCRE2_CODE_UNIT_WIDTH 8
#include <pcre2.h>
static int name_regexmatch_value(Node *n, String *pattern, String *s) {
pcre *compiled_pat;
const char *err;
int errpos;
pcre2_code *compiled_pat;
PCRE2_UCHAR err[256];
int errornum;
size_t errpos;
int rc;
compiled_pat = pcre_compile(Char(pattern), 0, &err, &errpos, NULL);
compiled_pat = pcre2_compile((PCRE2_SPTR8)Char(pattern), PCRE2_ZERO_TERMINATED, 0, &errornum, &errpos, NULL);
if (!compiled_pat) {
pcre2_get_error_message (errornum, err, sizeof err);
Swig_error("SWIG", Getline(n),
"Invalid regex \"%s\": compilation failed at %d: %s\n",
Char(pattern), errpos, err);
SWIG_exit(EXIT_FAILURE);
}
rc = pcre_exec(compiled_pat, NULL, Char(s), Len(s), 0, 0, NULL, 0);
pcre_free(compiled_pat);
pcre2_match_data *match_data = 0;
match_data = pcre2_match_data_create_from_pattern (compiled_pat, NULL);
rc = pcre2_match(compiled_pat, (PCRE2_SPTR8)Char(s), PCRE2_ZERO_TERMINATED, 0, 0, match_data, 0);
pcre2_code_free(compiled_pat);
pcre2_match_data_free(match_data);
if (rc == PCRE_ERROR_NOMATCH)
if (rc == PCRE2_ERROR_NOMATCH)
return 0;
if (rc < 0 ) {
@ -1514,7 +1520,7 @@ String *Swig_name_make(Node *n, String *prefix, const_String_or_char_ptr cname,
if (n) {
/* Parameter renaming is not fully implemented. Mainly because there is no C/C++ syntax to
* for %rename to fully qualify a function's parameter name from outside the function. Hence it
* is not possible to implemented targetted warning suppression on one parameter in one function. */
* is not possible to implemented targeted warning suppression on one parameter in one function. */
int suppress_parameter_rename_warning = Equal(nodeType(n), "parm");
if (!suppress_parameter_rename_warning) {
SWIG_WARN_NODE_BEGIN(n);

View file

@ -636,7 +636,7 @@ static int look(Scanner *s) {
}
else if (c == '.')
state = 100; /* Maybe a number, maybe just a period */
state = 100; /* Maybe a number, maybe ellipsis, just a period */
else if (isdigit(c))
state = 8; /* A numerical value */
else
@ -1330,19 +1330,34 @@ static int look(Scanner *s) {
}
break;
/* A period or maybe a floating point number */
/* A period or an ellipsis or maybe a floating point number */
case 100:
if ((c = nextchar(s)) == 0)
return (0);
if (isdigit(c))
state = 81;
else if (c == '.')
state = 101;
else {
retract(s, 1);
return SWIG_TOKEN_PERIOD;
}
break;
/* An ellipsis */
case 101:
if ((c = nextchar(s)) == 0)
return (0);
if (c == '.') {
return SWIG_TOKEN_ELLIPSIS;
} else {
retract(s, 2);
return SWIG_TOKEN_PERIOD;
}
break;
case 200: /* PLUS, PLUSPLUS, PLUSEQUAL */
if ((c = nextchar(s)) == 0)
return SWIG_TOKEN_PLUS;

View file

@ -221,6 +221,7 @@ extern "C" {
extern void Swig_symbol_print_tables_summary(void);
extern void Swig_symbol_print_symbols(void);
extern void Swig_symbol_print_csymbols(void);
extern void Swig_symbol_add_using(String *name, String *uname, Node *n);
extern void Swig_symbol_init(void);
extern void Swig_symbol_setscopename(const_String_or_char_ptr name);
extern String *Swig_symbol_getscopename(void);

View file

@ -70,6 +70,7 @@ extern void Scanner_locator(Scanner *, String *loc);
#define SWIG_TOKEN_BOOL 32 /* true or false */
#define SWIG_TOKEN_WSTRING 33 /* L"str" */
#define SWIG_TOKEN_WCHAR 34 /* L'c' */
#define SWIG_TOKEN_ELLIPSIS 35 /* ... */
#define SWIG_TOKEN_ILLEGAL 99
#define SWIG_TOKEN_ERROR -1

View file

@ -382,6 +382,29 @@ String *Swig_symbol_qualified_language_scopename(Symtab *n) {
return result;
}
/* -----------------------------------------------------------------------------
* Swig_symbol_add_using()
*
* Adds a node to the C symbol table for a using declaration.
* Used for using-declarations within classes/structs.
* ----------------------------------------------------------------------------- */
void Swig_symbol_add_using(String *name, String *uname, Node *n) {
Hash *h;
h = Swig_symbol_clookup(uname, 0);
if (h && (checkAttribute(h, "kind", "class") || checkAttribute(h, "kind", "struct"))) {
String *qcurrent = Swig_symbol_qualifiedscopename(0);
if (qcurrent) {
Append(qcurrent, "::");
Append(qcurrent, name);
} else {
qcurrent = NewString(name);
}
Setattr(symtabs, qcurrent, n);
Delete(qcurrent);
}
}
/* -----------------------------------------------------------------------------
* Swig_symbol_newscope()
*
@ -1074,7 +1097,19 @@ static Node *symbol_lookup_qualified(const_String_or_char_ptr name, Symtab *symt
Delete(qalloc);
return st;
}
n = symbol_lookup(name, st, checkfunc);
if (checkAttribute(st, "nodeType", "using")) {
String *uname = Getattr(st, "uname");
if (uname) {
st = Getattr(symtabs, uname);
if (st) {
n = symbol_lookup(name, st, checkfunc);
} else {
fprintf(stderr, "Error: Found corrupt 'using' node\n");
}
}
} else if (Getattr(st, "csymtab")) {
n = symbol_lookup(name, st, checkfunc);
}
}
if (qalloc)
Delete(qalloc);

View file

@ -225,7 +225,7 @@ void removeNode(Node *n) {
/* Delete attributes */
Delattr(n,"parentNode");
Delattr(n,"nextSibling");
Delattr(n,"prevSibling");
Delattr(n,"previousSibling");
}
/* -----------------------------------------------------------------------------