Merge branch 'master' into director-unwrap-result
This commit is contained in:
commit
deb7cbf741
1099 changed files with 14845 additions and 34359 deletions
|
|
@ -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 */
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ static int debug = 0;
|
|||
* Swig_fragment_register()
|
||||
*
|
||||
* Add a fragment. Use the original Node*, so, if something needs to be
|
||||
* changed, lang.cxx doesn't nedd to be touched again.
|
||||
* changed, lang.cxx doesn't need to be touched again.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void Swig_fragment_register(Node *fragment) {
|
||||
|
|
|
|||
|
|
@ -1157,47 +1157,15 @@ int Swig_scopename_check(const String *s) {
|
|||
/* -----------------------------------------------------------------------------
|
||||
* Swig_string_command()
|
||||
*
|
||||
* Executes a external command via popen with the string as a command
|
||||
* line parameter. For example:
|
||||
*
|
||||
* Printf(stderr,"%(command:sed 's/[a-z]/\U\\1/' <<<)s","hello") -> Hello
|
||||
* Feature removed in SWIG 4.1.0.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
#if defined(_MSC_VER)
|
||||
# define popen _popen
|
||||
# define pclose _pclose
|
||||
# if !defined(HAVE_POPEN)
|
||||
# define HAVE_POPEN 1
|
||||
# endif
|
||||
#else
|
||||
# if !defined(_WIN32)
|
||||
/* These Posix functions are not ISO C and so are not always defined in stdio.h */
|
||||
extern FILE *popen(const char *command, const char *type);
|
||||
extern int pclose(FILE *stream);
|
||||
# endif
|
||||
#endif
|
||||
|
||||
String *Swig_string_command(String *s) {
|
||||
String *res = NewStringEmpty();
|
||||
#if defined(HAVE_POPEN)
|
||||
if (Len(s)) {
|
||||
char *command = Char(s);
|
||||
FILE *fp = popen(command, "r");
|
||||
if (fp) {
|
||||
char buffer[1025];
|
||||
while (fscanf(fp, "%1024s", buffer) != EOF) {
|
||||
Append(res, buffer);
|
||||
}
|
||||
pclose(fp);
|
||||
} else {
|
||||
Swig_error("SWIG", Getline(s), "Command encoder fails attempting '%s'.\n", s);
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return res;
|
||||
Swig_error("SWIG", Getline(s), "Command encoder no longer supported - use regex encoder instead.\n");
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_string_strip()
|
||||
*
|
||||
|
|
@ -1312,7 +1280,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 +1344,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 +1366,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 +1418,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 +1451,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
|
||||
|
|
|
|||
|
|
@ -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 ) {
|
||||
|
|
@ -1132,6 +1138,7 @@ static int name_regexmatch_value(Node *n, String *pattern, String *s) {
|
|||
Swig_error("SWIG", Getline(n),
|
||||
"PCRE regex matching is not available in this SWIG build.\n");
|
||||
SWIG_exit(EXIT_FAILURE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* HAVE_PCRE/!HAVE_PCRE */
|
||||
|
|
@ -1510,20 +1517,30 @@ String *Swig_name_make(Node *n, String *prefix, const_String_or_char_ptr cname,
|
|||
result = apply_rename(n, rename, fullname, prefix, name);
|
||||
if ((msg) && (Len(msg))) {
|
||||
if (!Getmeta(nname, "already_warned")) {
|
||||
String* suffix = 0;
|
||||
if (Strcmp(result, "$ignore") == 0) {
|
||||
suffix = NewStringf(": ignoring '%s'\n", name);
|
||||
} else if (Strcmp(result, name) != 0) {
|
||||
suffix = NewStringf(", renaming to '%s'\n", result);
|
||||
} else {
|
||||
/* No rename was performed */
|
||||
suffix = NewString("\n");
|
||||
}
|
||||
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);
|
||||
Swig_warning(0, Getfile(n), Getline(n), "%s\n", msg);
|
||||
Swig_warning(0, Getfile(n), Getline(n), "%s%s", msg, suffix);
|
||||
SWIG_WARN_NODE_END(n);
|
||||
}
|
||||
} else {
|
||||
Swig_warning(0, Getfile(name), Getline(name), "%s\n", msg);
|
||||
Swig_warning(0, Getfile(name), Getline(name), "%s%s", msg, suffix);
|
||||
}
|
||||
Setmeta(nname, "already_warned", "1");
|
||||
Delete(suffix);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -134,7 +134,7 @@ SwigType *NewSwigType(int t) {
|
|||
return NewString("double");
|
||||
break;
|
||||
case T_COMPLEX:
|
||||
return NewString("complex");
|
||||
return NewString("_Complex");
|
||||
break;
|
||||
case T_CHAR:
|
||||
return NewString("char");
|
||||
|
|
@ -1291,11 +1291,29 @@ void SwigType_typename_replace(SwigType *t, String *pat, String *rep) {
|
|||
Replace(e, pat, rep, DOH_REPLACE_ANY);
|
||||
} else if (SwigType_istemplate(e)) {
|
||||
/* Replaces a type of the form 'pat<args>' with 'rep' */
|
||||
if (Equal(e, pat)) {
|
||||
String *repbase = SwigType_templateprefix(rep);
|
||||
Replace(e, pat, repbase, DOH_REPLACE_ID | DOH_REPLACE_FIRST);
|
||||
Delete(repbase);
|
||||
{
|
||||
/* To match "e=TemplateTemplateT<(float)>"
|
||||
* with "pat=TemplateTemplateT"
|
||||
* we need to compare only the first part of the string e.
|
||||
*/
|
||||
int len = Len(pat);
|
||||
|
||||
/* Len(e) > len, not >= (because we expect at least a
|
||||
* character '<' following the template typename)
|
||||
*/
|
||||
if (Len(e) > len) {
|
||||
String *firstPartOfType = NewStringWithSize(e, len);
|
||||
const char* e_as_char = Char(e);
|
||||
|
||||
if (Equal(firstPartOfType, pat) && e_as_char[len] == '<') {
|
||||
String *repbase = SwigType_templateprefix(rep);
|
||||
Replace(e, pat, repbase, DOH_REPLACE_ID | DOH_REPLACE_FIRST);
|
||||
Delete(repbase);
|
||||
}
|
||||
Delete(firstPartOfType);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
String *tsuffix;
|
||||
List *tparms = SwigType_parmlist(e);
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
#include "swig.h"
|
||||
#include "swigwarn.h"
|
||||
#include "cparse.h"
|
||||
#include <ctype.h>
|
||||
|
||||
/* #define SWIG_DEBUG*/
|
||||
|
|
@ -641,10 +641,11 @@ void Swig_symbol_cadd(const_String_or_char_ptr name, Node *n) {
|
|||
|
||||
{
|
||||
Node *td = n;
|
||||
while (td && Checkattr(td, "nodeType", "cdecl") && Checkattr(td, "storage", "typedef")) {
|
||||
while (td && ((Equal(nodeType(td), "cdecl") && Checkattr(td, "storage", "typedef")) || (Equal(nodeType(td), "using") && !Getattr(n, "namespace")))) {
|
||||
SwigType *type;
|
||||
Node *td1;
|
||||
type = Copy(Getattr(td, "type"));
|
||||
int using_not_typedef = Equal(nodeType(td), "using");
|
||||
type = Copy(Getattr(td, using_not_typedef ? "uname" : "type"));
|
||||
SwigType_push(type, Getattr(td, "decl"));
|
||||
td1 = Swig_symbol_clookup(type, 0);
|
||||
|
||||
|
|
@ -665,9 +666,13 @@ void Swig_symbol_cadd(const_String_or_char_ptr name, Node *n) {
|
|||
ie, when Foo -> FooBar -> Foo, jump one scope up when possible.
|
||||
|
||||
*/
|
||||
if (td1 && Checkattr(td1, "storage", "typedef")) {
|
||||
String *st = Getattr(td1, "type");
|
||||
if (td1) {
|
||||
String *st = 0;
|
||||
String *sn = Getattr(td, "name");
|
||||
if (Equal(nodeType(td1), "cdecl") && Checkattr(td1, "storage", "typedef"))
|
||||
st = Getattr(td1, "type");
|
||||
else if (Equal(nodeType(td1), "using") && !Getattr(td1, "namespace"))
|
||||
st = Getattr(td1, "uname");
|
||||
if (st && sn && Equal(st, sn)) {
|
||||
Symtab *sc = Getattr(current_symtab, "parentNode");
|
||||
if (sc)
|
||||
|
|
@ -1177,7 +1182,9 @@ Node *Swig_symbol_clookup(const_String_or_char_ptr name, Symtab *n) {
|
|||
Symtab *un = Getattr(s, "sym:symtab");
|
||||
Node *ss = (!Equal(name, uname) || (un != n)) ? Swig_symbol_clookup(uname, un) : 0; /* avoid infinity loop */
|
||||
if (!ss) {
|
||||
SWIG_WARN_NODE_BEGIN(s);
|
||||
Swig_warning(WARN_PARSE_USING_UNDEF, Getfile(s), Getline(s), "Nothing known about '%s'.\n", SwigType_namestr(Getattr(s, "uname")));
|
||||
SWIG_WARN_NODE_END(s);
|
||||
}
|
||||
s = ss;
|
||||
}
|
||||
|
|
@ -1249,7 +1256,9 @@ Node *Swig_symbol_clookup_check(const_String_or_char_ptr name, Symtab *n, int (*
|
|||
Node *ss;
|
||||
ss = Swig_symbol_clookup(Getattr(s, "uname"), Getattr(s, "sym:symtab"));
|
||||
if (!ss && !checkfunc) {
|
||||
SWIG_WARN_NODE_BEGIN(s);
|
||||
Swig_warning(WARN_PARSE_USING_UNDEF, Getfile(s), Getline(s), "Nothing known about '%s'.\n", SwigType_namestr(Getattr(s, "uname")));
|
||||
SWIG_WARN_NODE_END(s);
|
||||
}
|
||||
s = ss;
|
||||
}
|
||||
|
|
@ -1300,7 +1309,9 @@ Node *Swig_symbol_clookup_local(const_String_or_char_ptr name, Symtab *n) {
|
|||
while (s && Checkattr(s, "nodeType", "using")) {
|
||||
Node *ss = Swig_symbol_clookup_local(Getattr(s, "uname"), Getattr(s, "sym:symtab"));
|
||||
if (!ss) {
|
||||
SWIG_WARN_NODE_BEGIN(s);
|
||||
Swig_warning(WARN_PARSE_USING_UNDEF, Getfile(s), Getline(s), "Nothing known about '%s'.\n", SwigType_namestr(Getattr(s, "uname")));
|
||||
SWIG_WARN_NODE_END(s);
|
||||
}
|
||||
s = ss;
|
||||
}
|
||||
|
|
@ -1348,7 +1359,9 @@ Node *Swig_symbol_clookup_local_check(const_String_or_char_ptr name, Symtab *n,
|
|||
while (s && Checkattr(s, "nodeType", "using")) {
|
||||
Node *ss = Swig_symbol_clookup_local_check(Getattr(s, "uname"), Getattr(s, "sym:symtab"), checkfunc);
|
||||
if (!ss && !checkfunc) {
|
||||
SWIG_WARN_NODE_BEGIN(s);
|
||||
Swig_warning(WARN_PARSE_USING_UNDEF, Getfile(s), Getline(s), "Nothing known about '%s'.\n", SwigType_namestr(Getattr(s, "uname")));
|
||||
SWIG_WARN_NODE_END(s);
|
||||
}
|
||||
s = ss;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -225,7 +225,7 @@ void removeNode(Node *n) {
|
|||
/* Delete attributes */
|
||||
Delattr(n,"parentNode");
|
||||
Delattr(n,"nextSibling");
|
||||
Delattr(n,"prevSibling");
|
||||
Delattr(n,"previousSibling");
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -1256,6 +1256,59 @@ static String *typemap_warn(const_String_or_char_ptr tmap_method, Parm *p) {
|
|||
return w ? Copy(w) : 0;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* typemap_merge_fragment_kwargs()
|
||||
*
|
||||
* If multiple 'fragment' attributes are provided to a typemap, combine them by
|
||||
* concatenating with commas.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static void typemap_merge_fragment_kwargs(Parm *kw) {
|
||||
Parm *reattach_kw = NULL;
|
||||
Parm *prev_kw = NULL;
|
||||
Parm *next_kw = NULL;
|
||||
String *fragment = NULL;
|
||||
while (kw) {
|
||||
next_kw = nextSibling(kw);
|
||||
if (Strcmp(Getattr(kw, "name"), "fragment") == 0) {
|
||||
String *thisfragment = Getattr(kw, "value");
|
||||
String *kwtype = Getattr(kw, "type");
|
||||
if (!fragment) {
|
||||
/* First fragment found; it should remain in the list */
|
||||
fragment = thisfragment;
|
||||
prev_kw = kw;
|
||||
} else {
|
||||
/* Concatenate to previously found fragment */
|
||||
Printv(fragment, ",", thisfragment, NULL);
|
||||
reattach_kw = prev_kw;
|
||||
}
|
||||
if (kwtype) {
|
||||
String *mangle = Swig_string_mangle(kwtype);
|
||||
Append(fragment, mangle);
|
||||
Delete(mangle);
|
||||
/* Remove 'type' from kwargs so it's not duplicated later */
|
||||
Setattr(kw, "type", NULL);
|
||||
}
|
||||
} else {
|
||||
/* Not a fragment */
|
||||
if (reattach_kw) {
|
||||
/* Update linked list to remove duplicate fragment */
|
||||
DohIncref(kw);
|
||||
set_nextSibling(reattach_kw, kw);
|
||||
set_previousSibling(kw, reattach_kw);
|
||||
Delete(reattach_kw);
|
||||
reattach_kw = NULL;
|
||||
}
|
||||
prev_kw = kw;
|
||||
}
|
||||
kw = next_kw;
|
||||
}
|
||||
if (reattach_kw) {
|
||||
/* Update linked list to remove duplicate fragment */
|
||||
set_nextSibling(reattach_kw, kw);
|
||||
}
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_typemap_lookup()
|
||||
*
|
||||
|
|
@ -1463,6 +1516,7 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr tmap_method, No
|
|||
|
||||
/* Attach kwargs - ie the typemap attributes */
|
||||
kw = Getattr(tm, "kwargs");
|
||||
typemap_merge_fragment_kwargs(kw);
|
||||
while (kw) {
|
||||
String *value = Copy(Getattr(kw, "value"));
|
||||
String *kwtype = Getattr(kw, "type");
|
||||
|
|
@ -1577,6 +1631,7 @@ String *Swig_typemap_lookup(const_String_or_char_ptr tmap_method, Node *node, co
|
|||
static void typemap_attach_kwargs(Hash *tm, const_String_or_char_ptr tmap_method, Parm *firstp, int nmatch) {
|
||||
String *temp = NewStringEmpty();
|
||||
Parm *kw = Getattr(tm, "kwargs");
|
||||
typemap_merge_fragment_kwargs(kw);
|
||||
while (kw) {
|
||||
String *value = Copy(Getattr(kw, "value"));
|
||||
String *type = Getattr(kw, "type");
|
||||
|
|
|
|||
|
|
@ -488,6 +488,7 @@ SwigType *SwigType_del_reference(SwigType *t) {
|
|||
char *c = Char(t);
|
||||
int check = strncmp(c, "r.", 2);
|
||||
assert(check == 0);
|
||||
(void)check;
|
||||
Delslice(t, 0, 2);
|
||||
return t;
|
||||
}
|
||||
|
|
@ -523,6 +524,7 @@ SwigType *SwigType_del_rvalue_reference(SwigType *t) {
|
|||
char *c = Char(t);
|
||||
int check = strncmp(c, "z.", 2);
|
||||
assert(check == 0);
|
||||
(void)check;
|
||||
Delslice(t, 0, 2);
|
||||
return t;
|
||||
}
|
||||
|
|
@ -613,6 +615,7 @@ SwigType *SwigType_del_qualifier(SwigType *t) {
|
|||
char *c = Char(t);
|
||||
int check = strncmp(c, "q(", 2);
|
||||
assert(check == 0);
|
||||
(void)check;
|
||||
Delslice(t, 0, element_size(c));
|
||||
return t;
|
||||
}
|
||||
|
|
@ -681,6 +684,7 @@ SwigType *SwigType_del_memberpointer(SwigType *t) {
|
|||
char *c = Char(t);
|
||||
int check = strncmp(c, "m(", 2);
|
||||
assert(check == 0);
|
||||
(void)check;
|
||||
Delslice(t, 0, element_size(c));
|
||||
return t;
|
||||
}
|
||||
|
|
@ -725,6 +729,7 @@ SwigType *SwigType_del_array(SwigType *t) {
|
|||
char *c = Char(t);
|
||||
int check = strncmp(c, "a(", 2);
|
||||
assert(check == 0);
|
||||
(void)check;
|
||||
Delslice(t, 0, element_size(c));
|
||||
return t;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1453,11 +1453,11 @@ int SwigType_type(const SwigType *t) {
|
|||
return T_DOUBLE;
|
||||
if (strcmp(c, "long double") == 0)
|
||||
return T_LONGDOUBLE;
|
||||
if (!cparse_cplusplus && (strcmp(c, "float complex") == 0))
|
||||
if (!cparse_cplusplus && (strcmp(c, "float _Complex") == 0))
|
||||
return T_FLTCPLX;
|
||||
if (!cparse_cplusplus && (strcmp(c, "double complex") == 0))
|
||||
if (!cparse_cplusplus && (strcmp(c, "double _Complex") == 0))
|
||||
return T_DBLCPLX;
|
||||
if (!cparse_cplusplus && (strcmp(c, "complex") == 0))
|
||||
if (!cparse_cplusplus && (strcmp(c, "_Complex") == 0))
|
||||
return T_COMPLEX;
|
||||
if (strcmp(c, "void") == 0)
|
||||
return T_VOID;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue