merge from trunk
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2009-sploving@11489 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
commit
21671f7534
86 changed files with 3689 additions and 502 deletions
|
|
@ -1465,7 +1465,7 @@ static void tag_nodes(Node *n, const_String_or_char_ptr attrname, DOH *value) {
|
|||
} decl;
|
||||
Parm *tparms;
|
||||
struct {
|
||||
String *op;
|
||||
String *method;
|
||||
Hash *kwargs;
|
||||
} tmap;
|
||||
struct {
|
||||
|
|
@ -2499,10 +2499,10 @@ varargs_parms : parms { $$ = $1; }
|
|||
|
||||
typemap_directive : TYPEMAP LPAREN typemap_type RPAREN tm_list stringbrace {
|
||||
$$ = 0;
|
||||
if ($3.op) {
|
||||
if ($3.method) {
|
||||
String *code = 0;
|
||||
$$ = new_node("typemap");
|
||||
Setattr($$,"method",$3.op);
|
||||
Setattr($$,"method",$3.method);
|
||||
if ($3.kwargs) {
|
||||
ParmList *kw = $3.kwargs;
|
||||
code = remove_block(kw, $6);
|
||||
|
|
@ -2516,17 +2516,17 @@ typemap_directive : TYPEMAP LPAREN typemap_type RPAREN tm_list stringbrace {
|
|||
}
|
||||
| TYPEMAP LPAREN typemap_type RPAREN tm_list SEMI {
|
||||
$$ = 0;
|
||||
if ($3.op) {
|
||||
if ($3.method) {
|
||||
$$ = new_node("typemap");
|
||||
Setattr($$,"method",$3.op);
|
||||
Setattr($$,"method",$3.method);
|
||||
appendChild($$,$5);
|
||||
}
|
||||
}
|
||||
| TYPEMAP LPAREN typemap_type RPAREN tm_list EQUAL typemap_parm SEMI {
|
||||
$$ = 0;
|
||||
if ($3.op) {
|
||||
if ($3.method) {
|
||||
$$ = new_node("typemapcopy");
|
||||
Setattr($$,"method",$3.op);
|
||||
Setattr($$,"method",$3.method);
|
||||
Setattr($$,"pattern", Getattr($7,"pattern"));
|
||||
appendChild($$,$5);
|
||||
}
|
||||
|
|
@ -2546,15 +2546,15 @@ typemap_type : kwargs {
|
|||
/* two argument typemap form */
|
||||
name = Getattr($1,"name");
|
||||
if (!name || (Strcmp(name,typemap_lang))) {
|
||||
$$.op = 0;
|
||||
$$.method = 0;
|
||||
$$.kwargs = 0;
|
||||
} else {
|
||||
$$.op = Getattr(p,"name");
|
||||
$$.method = Getattr(p,"name");
|
||||
$$.kwargs = nextSibling(p);
|
||||
}
|
||||
} else {
|
||||
/* one-argument typemap-form */
|
||||
$$.op = Getattr($1,"name");
|
||||
$$.method = Getattr($1,"name");
|
||||
$$.kwargs = p;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -250,6 +250,7 @@
|
|||
|
||||
#define WARN_PHP_MULTIPLE_INHERITANCE 870
|
||||
#define WARN_PHP_UNKNOWN_PRAGMA 871
|
||||
#define WARN_PHP_PUBLIC_BASE 872
|
||||
|
||||
/* please leave 870-889 free for PHP */
|
||||
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@ BUILD_SOURCE_DIR=$(top_builddir)/Source
|
|||
|
||||
SWIG_CXX_DEFS = @SWILL@
|
||||
|
||||
AM_CFLAGS = -I$(BUILD_SOURCE_DIR)/Include \
|
||||
AM_CPPFLAGS = -I$(BUILD_SOURCE_DIR)/Include \
|
||||
-I$(BUILD_SOURCE_DIR)/CParse \
|
||||
-I$(SOURCE_DIR)/Include \
|
||||
-I$(SOURCE_DIR)/DOH \
|
||||
|
|
@ -17,8 +17,7 @@ AM_CFLAGS = -I$(BUILD_SOURCE_DIR)/Include \
|
|||
-I$(SOURCE_DIR)/Swig \
|
||||
-I$(SOURCE_DIR)/Modules
|
||||
|
||||
AM_CXXFLAGS = $(AM_CFLAGS) \
|
||||
$(SWIG_CXX_DEFS)
|
||||
AM_CXXFLAGS = $(SWIG_CXX_DEFS)
|
||||
|
||||
AM_YFLAGS = -d
|
||||
|
||||
|
|
|
|||
|
|
@ -1803,13 +1803,13 @@ static List *Swig_overload_rank(Node *n, bool script_lang_wrapping) {
|
|||
String *t2 = Getattr(p2, "tmap:typecheck:precedence");
|
||||
if ((!t1) && (!nodes[i].error)) {
|
||||
Swig_warning(WARN_TYPEMAP_TYPECHECK, Getfile(nodes[i].n), Getline(nodes[i].n),
|
||||
"Overloaded %s(%s) not supported (no type checking rule for '%s').\n",
|
||||
Getattr(nodes[i].n, "name"), ParmList_str_defaultargs(Getattr(nodes[i].n, "parms")), SwigType_str(Getattr(p1, "type"), 0));
|
||||
"Overloaded method %s not supported (no type checking rule for '%s').\n",
|
||||
Swig_name_decl(nodes[i].n), SwigType_str(Getattr(p1, "type"), 0));
|
||||
nodes[i].error = 1;
|
||||
} else if ((!t2) && (!nodes[j].error)) {
|
||||
Swig_warning(WARN_TYPEMAP_TYPECHECK, Getfile(nodes[j].n), Getline(nodes[j].n),
|
||||
"Overloaded %s(%s) not supported (no type checking rule for '%s').\n",
|
||||
Getattr(nodes[j].n, "name"), ParmList_str_defaultargs(Getattr(nodes[j].n, "parms")), SwigType_str(Getattr(p2, "type"), 0));
|
||||
"Overloaded method %s not supported (no type checking rule for '%s').\n",
|
||||
Swig_name_decl(nodes[j].n), SwigType_str(Getattr(p2, "type"), 0));
|
||||
nodes[j].error = 1;
|
||||
}
|
||||
if (t1 && t2) {
|
||||
|
|
@ -1937,19 +1937,15 @@ static List *Swig_overload_rank(Node *n, bool script_lang_wrapping) {
|
|||
if (!nodes[j].error) {
|
||||
if (script_lang_wrapping) {
|
||||
Swig_warning(WARN_LANG_OVERLOAD_SHADOW, Getfile(nodes[j].n), Getline(nodes[j].n),
|
||||
"Overloaded %s(%s)%s is shadowed by %s(%s)%s at %s:%d.\n",
|
||||
Getattr(nodes[j].n, "name"), ParmList_errorstr(nodes[j].parms),
|
||||
SwigType_isconst(Getattr(nodes[j].n, "decl")) ? " const" : "",
|
||||
Getattr(nodes[i].n, "name"), ParmList_errorstr(nodes[i].parms),
|
||||
SwigType_isconst(Getattr(nodes[i].n, "decl")) ? " const" : "", Getfile(nodes[i].n), Getline(nodes[i].n));
|
||||
"Overloaded method %s is shadowed by %s at %s:%d.\n",
|
||||
Swig_name_decl(nodes[j].n), Swig_name_decl(nodes[i].n),
|
||||
Getfile(nodes[i].n), Getline(nodes[i].n));
|
||||
} else {
|
||||
if (!Getattr(nodes[j].n, "overload:ignore"))
|
||||
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n),
|
||||
"Overloaded method %s(%s)%s ignored. Method %s(%s)%s at %s:%d used.\n",
|
||||
Getattr(nodes[j].n, "name"), ParmList_errorstr(nodes[j].parms),
|
||||
SwigType_isconst(Getattr(nodes[j].n, "decl")) ? " const" : "",
|
||||
Getattr(nodes[i].n, "name"), ParmList_errorstr(nodes[i].parms),
|
||||
SwigType_isconst(Getattr(nodes[i].n, "decl")) ? " const" : "", Getfile(nodes[i].n), Getline(nodes[i].n));
|
||||
"Overloaded method %s ignored. Method %s at %s:%d used.\n",
|
||||
Swig_name_decl(nodes[j].n), Swig_name_decl(nodes[i].n),
|
||||
Getfile(nodes[i].n), Getline(nodes[i].n));
|
||||
}
|
||||
nodes[j].error = 1;
|
||||
}
|
||||
|
|
@ -2010,7 +2006,7 @@ Node *parent_node_skipping_extends(Node *n) {
|
|||
* emit_num_lin_arguments()
|
||||
*
|
||||
* Calculate the total number of arguments. This function is safe for use
|
||||
* with multi-valued typemaps which may change the number of arguments in
|
||||
* with multi-argument typemaps which may change the number of arguments in
|
||||
* strange ways.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
|
|
|
|||
|
|
@ -2766,6 +2766,16 @@ public:
|
|||
Delete(func_name);
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
* replaceSpecialVariables()
|
||||
*--------------------------------------------------------------------*/
|
||||
|
||||
virtual void replaceSpecialVariables(String *method, String *tm, Parm *parm) {
|
||||
(void)method;
|
||||
SwigType *type = Getattr(parm, "type");
|
||||
substituteClassname(type, tm);
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
* decodeEnumFeature()
|
||||
* Decode the possible enum features, which are one of:
|
||||
|
|
@ -2859,15 +2869,15 @@ public:
|
|||
/* -----------------------------------------------------------------------------
|
||||
* substituteClassname()
|
||||
*
|
||||
* Substitute $csclassname with the proxy class name for classes/structs/unions that SWIG knows about.
|
||||
* Also substitutes enums with enum name.
|
||||
* Substitute the special variable $csclassname with the proxy class name for classes/structs/unions
|
||||
* that SWIG knows about. Also substitutes enums with enum name.
|
||||
* Otherwise use the $descriptor name for the C# class name. Note that the $&csclassname substitution
|
||||
* is the same as a $&descriptor substitution, ie one pointer added to descriptor name.
|
||||
* Inputs:
|
||||
* pt - parameter type
|
||||
* tm - cstype typemap
|
||||
* tm - typemap contents that might contain the special variable to be replaced
|
||||
* Outputs:
|
||||
* tm - cstype typemap with $csclassname substitution
|
||||
* tm - typemap contents complete with the special variable substitution
|
||||
* Return:
|
||||
* substitution_performed - flag indicating if a substitution was performed
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
|
@ -3029,7 +3039,7 @@ public:
|
|||
/* -----------------------------------------------------------------------------
|
||||
* typemapLookup()
|
||||
* n - for input only and must contain info for Getfile(n) and Getline(n) to work
|
||||
* op - typemap method name
|
||||
* tmap_method - typemap method name
|
||||
* type - typemap type to lookup
|
||||
* warning - warning number to issue if no typemaps found
|
||||
* typemap_attributes - the typemap attributes are attached to this node and will
|
||||
|
|
@ -3037,16 +3047,16 @@ public:
|
|||
* return is never NULL, unlike Swig_typemap_lookup()
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
const String *typemapLookup(Node *n, const_String_or_char_ptr op, SwigType *type, int warning, Node *typemap_attributes = 0) {
|
||||
const String *typemapLookup(Node *n, const_String_or_char_ptr tmap_method, SwigType *type, int warning, Node *typemap_attributes = 0) {
|
||||
Node *node = !typemap_attributes ? NewHash() : typemap_attributes;
|
||||
Setattr(node, "type", type);
|
||||
Setfile(node, Getfile(n));
|
||||
Setline(node, Getline(n));
|
||||
const String *tm = Swig_typemap_lookup(op, node, "", 0);
|
||||
const String *tm = Swig_typemap_lookup(tmap_method, node, "", 0);
|
||||
if (!tm) {
|
||||
tm = empty_string;
|
||||
if (warning != WARN_NONE)
|
||||
Swig_warning(warning, Getfile(n), Getline(n), "No %s typemap defined for %s\n", op, SwigType_str(type, 0));
|
||||
Swig_warning(warning, Getfile(n), Getline(n), "No %s typemap defined for %s\n", tmap_method, SwigType_str(type, 0));
|
||||
}
|
||||
if (!typemap_attributes)
|
||||
Delete(node);
|
||||
|
|
|
|||
|
|
@ -200,7 +200,7 @@ void emit_attach_parmmaps(ParmList *l, Wrapper *f) {
|
|||
* emit_num_arguments()
|
||||
*
|
||||
* Calculate the total number of arguments. This function is safe for use
|
||||
* with multi-valued typemaps which may change the number of arguments in
|
||||
* with multi-argument typemaps which may change the number of arguments in
|
||||
* strange ways.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
|
|
@ -232,7 +232,7 @@ int emit_num_arguments(ParmList *parms) {
|
|||
* emit_num_required()
|
||||
*
|
||||
* Computes the number of required arguments. This function is safe for
|
||||
* use with multi-valued typemaps and knows how to skip over everything
|
||||
* use with multi-argument typemaps and knows how to skip over everything
|
||||
* properly. Note that parameters with default values are counted unless
|
||||
* the compact default args option is on.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
|
|
|||
|
|
@ -2603,6 +2603,16 @@ public:
|
|||
Delete(func_name);
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
* replaceSpecialVariables()
|
||||
*--------------------------------------------------------------------*/
|
||||
|
||||
virtual void replaceSpecialVariables(String *method, String *tm, Parm *parm) {
|
||||
(void)method;
|
||||
SwigType *type = Getattr(parm, "type");
|
||||
substituteClassname(type, tm);
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
* decodeEnumFeature()
|
||||
* Decode the possible enum features, which are one of:
|
||||
|
|
@ -2700,16 +2710,16 @@ public:
|
|||
/* -----------------------------------------------------------------------------
|
||||
* substituteClassname()
|
||||
*
|
||||
* Substitute $javaclassname with the proxy class name for classes/structs/unions that SWIG knows about.
|
||||
* Also substitutes enums with enum name.
|
||||
* Substitute the special variable $javaclassname with the proxy class name for classes/structs/unions
|
||||
* that SWIG knows about. Also substitutes enums with enum name.
|
||||
* Otherwise use the $descriptor name for the Java class name. Note that the $&javaclassname substitution
|
||||
* is the same as a $&descriptor substitution, ie one pointer added to descriptor name.
|
||||
* Inputs:
|
||||
* pt - parameter type
|
||||
* tm - jstype typemap
|
||||
* tm - typemap contents that might contain the special variable to be replaced
|
||||
* jnidescriptor - if set, inner class names are separated with '$' otherwise a '.'
|
||||
* Outputs:
|
||||
* tm - jstype typemap with $javaclassname substitution
|
||||
* tm - typemap contents complete with the special variable substitution
|
||||
* Return:
|
||||
* substitution_performed - flag indicating if a substitution was performed
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
|
@ -2862,7 +2872,7 @@ public:
|
|||
/* -----------------------------------------------------------------------------
|
||||
* typemapLookup()
|
||||
* n - for input only and must contain info for Getfile(n) and Getline(n) to work
|
||||
* op - typemap method name
|
||||
* tmap_method - typemap method name
|
||||
* type - typemap type to lookup
|
||||
* warning - warning number to issue if no typemaps found
|
||||
* typemap_attributes - the typemap attributes are attached to this node and will
|
||||
|
|
@ -2870,16 +2880,16 @@ public:
|
|||
* return is never NULL, unlike Swig_typemap_lookup()
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
const String *typemapLookup(Node *n, const_String_or_char_ptr op, SwigType *type, int warning, Node *typemap_attributes = 0) {
|
||||
const String *typemapLookup(Node *n, const_String_or_char_ptr tmap_method, SwigType *type, int warning, Node *typemap_attributes = 0) {
|
||||
Node *node = !typemap_attributes ? NewHash() : typemap_attributes;
|
||||
Setattr(node, "type", type);
|
||||
Setfile(node, Getfile(n));
|
||||
Setline(node, Getline(n));
|
||||
const String *tm = Swig_typemap_lookup(op, node, "", 0);
|
||||
const String *tm = Swig_typemap_lookup(tmap_method, node, "", 0);
|
||||
if (!tm) {
|
||||
tm = empty_string;
|
||||
if (warning != WARN_NONE)
|
||||
Swig_warning(warning, Getfile(n), Getline(n), "No %s typemap defined for %s\n", op, SwigType_str(type, 0));
|
||||
Swig_warning(warning, Getfile(n), Getline(n), "No %s typemap defined for %s\n", tmap_method, SwigType_str(type, 0));
|
||||
}
|
||||
if (!typemap_attributes)
|
||||
Delete(node);
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ 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 */
|
||||
void Wrapper_director_mode_set(int flag) {
|
||||
|
|
@ -46,6 +47,9 @@ extern "C" {
|
|||
int Swig_all_protected_mode() {
|
||||
return all_protected_mode;
|
||||
}
|
||||
void Language_replace_special_variables(String *method, String *tm, Parm *parm) {
|
||||
Language::instance()->replaceSpecialVariables(method, tm, parm);
|
||||
}
|
||||
}
|
||||
|
||||
/* Some status variables used during parsing */
|
||||
|
|
@ -323,6 +327,8 @@ directors(0) {
|
|||
director_prot_ctor_code = 0;
|
||||
director_multiple_inheritance = 1;
|
||||
director_language = 0;
|
||||
assert(!this_);
|
||||
this_ = this;
|
||||
}
|
||||
|
||||
Language::~Language() {
|
||||
|
|
@ -331,6 +337,7 @@ Language::~Language() {
|
|||
Delete(enumtypes);
|
||||
Delete(director_ctor_code);
|
||||
Delete(none_comparison);
|
||||
this_ = 0;
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
|
|
@ -874,30 +881,8 @@ int Language::cDeclaration(Node *n) {
|
|||
if (over)
|
||||
over = first_nontemplate(over);
|
||||
if (over && (over != n)) {
|
||||
SwigType *tc = Copy(decl);
|
||||
SwigType *td = SwigType_pop_function(tc);
|
||||
String *oname;
|
||||
String *cname;
|
||||
if (CurrentClass) {
|
||||
oname = NewStringf("%s::%s", ClassName, name);
|
||||
cname = NewStringf("%s::%s", ClassName, Getattr(over, "name"));
|
||||
} else {
|
||||
oname = NewString(name);
|
||||
cname = NewString(Getattr(over, "name"));
|
||||
}
|
||||
|
||||
SwigType *tc2 = Copy(Getattr(over, "decl"));
|
||||
SwigType *td2 = SwigType_pop_function(tc2);
|
||||
|
||||
Swig_warning(WARN_LANG_OVERLOAD_DECL, input_file, line_number, "Overloaded declaration ignored. %s\n", SwigType_str(td, SwigType_namestr(oname)));
|
||||
Swig_warning(WARN_LANG_OVERLOAD_DECL, Getfile(over), Getline(over), "Previous declaration is %s\n", SwigType_str(td2, SwigType_namestr(cname)));
|
||||
|
||||
Delete(tc2);
|
||||
Delete(td2);
|
||||
Delete(tc);
|
||||
Delete(td);
|
||||
Delete(oname);
|
||||
Delete(cname);
|
||||
Swig_warning(WARN_LANG_OVERLOAD_DECL, input_file, line_number, "Overloaded declaration ignored. %s\n", Swig_name_decl(n));
|
||||
Swig_warning(WARN_LANG_OVERLOAD_DECL, Getfile(over), Getline(over), "Previous declaration is %s\n", Swig_name_decl(over));
|
||||
return SWIG_NOWRAP;
|
||||
}
|
||||
}
|
||||
|
|
@ -978,7 +963,7 @@ int Language::cDeclaration(Node *n) {
|
|||
if (Strncmp(symname, "__dummy_", 8) == 0) {
|
||||
SetFlag(n, "feature:ignore");
|
||||
Swig_warning(WARN_LANG_TEMPLATE_METHOD_IGNORE, input_file, line_number,
|
||||
"%%template() contains no name. Template method ignored: %s\n", SwigType_str(decl, SwigType_namestr(Getattr(n,"name"))));
|
||||
"%%template() contains no name. Template method ignored: %s\n", Swig_name_decl(n));
|
||||
}
|
||||
}
|
||||
if (!GetFlag(n, "feature:ignore"))
|
||||
|
|
@ -3423,6 +3408,24 @@ String *Language::defaultExternalRuntimeFilename() {
|
|||
return 0;
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Language::replaceSpecialVariables()
|
||||
* Language modules should implement this if special variables are to be handled
|
||||
* correctly in the $typemap(...) special variable macro.
|
||||
* method - typemap method name
|
||||
* tm - string containing typemap contents
|
||||
* parm - a parameter describing the typemap type to be handled
|
||||
* ----------------------------------------------------------------------------- */
|
||||
void Language::replaceSpecialVariables(String *method, String *tm, Parm *parm) {
|
||||
(void)method;
|
||||
(void)tm;
|
||||
(void)parm;
|
||||
}
|
||||
|
||||
Language *Language::instance() {
|
||||
return this_;
|
||||
}
|
||||
|
||||
Hash *Language::getClassHash() const {
|
||||
return classhash;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3581,17 +3581,28 @@ MODULA3():
|
|||
Delete(throws_hash);
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
* replaceSpecialVariables()
|
||||
*--------------------------------------------------------------------*/
|
||||
|
||||
virtual void replaceSpecialVariables(String *method, String *tm, Parm *parm) {
|
||||
(void)method;
|
||||
SwigType *type = Getattr(parm, "type");
|
||||
substituteClassname(type, tm);
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* substituteClassname()
|
||||
*
|
||||
* Substitute $m3classname with the proxy class name for classes/structs/unions that SWIG knows about.
|
||||
* Substitute the special variable $m3classname with the proxy class name for classes/structs/unions
|
||||
* that SWIG knows about.
|
||||
* Otherwise use the $descriptor name for the Modula 3 class name. Note that the $&m3classname substitution
|
||||
* is the same as a $&descriptor substitution, ie one pointer added to descriptor name.
|
||||
* Inputs:
|
||||
* pt - parameter type
|
||||
* tm - m3wraptype typemap
|
||||
* tm - typemap contents that might contain the special variable to be replaced
|
||||
* Outputs:
|
||||
* tm - m3wraptype typemap with $m3classname substitution
|
||||
* tm - typemap contents complete with the special variable substitution
|
||||
* Return:
|
||||
* substitution_performed - flag indicating if a substitution was performed
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
|
@ -3807,7 +3818,7 @@ MODULA3():
|
|||
/* -----------------------------------------------------------------------------
|
||||
* typemapLookup()
|
||||
* n - for input only and must contain info for Getfile(n) and Getline(n) to work
|
||||
* op - typemap method name
|
||||
* tmap_method - typemap method name
|
||||
* type - typemap type to lookup
|
||||
* warning - warning number to issue if no typemaps found
|
||||
* typemap_attributes - the typemap attributes are attached to this node and will
|
||||
|
|
@ -3815,16 +3826,16 @@ MODULA3():
|
|||
* return is never NULL, unlike Swig_typemap_lookup()
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
const String *typemapLookup(Node *n, const_String_or_char_ptr op, SwigType *type, int warning, Node *typemap_attributes = 0) {
|
||||
const String *typemapLookup(Node *n, const_String_or_char_ptr tmap_method, SwigType *type, int warning, Node *typemap_attributes = 0) {
|
||||
Node *node = !typemap_attributes ? NewHash() : typemap_attributes;
|
||||
Setattr(node, "type", type);
|
||||
Setfile(node, Getfile(n));
|
||||
Setline(node, Getline(n));
|
||||
const String *tm = Swig_typemap_lookup(op, node, "", 0);
|
||||
const String *tm = Swig_typemap_lookup(tmap_method, node, "", 0);
|
||||
if (!tm) {
|
||||
tm = empty_string;
|
||||
if (warning != WARN_NONE)
|
||||
Swig_warning(warning, Getfile(n), Getline(n), "No %s typemap defined for %s\n", op, SwigType_str(type, 0));
|
||||
Swig_warning(warning, Getfile(n), Getline(n), "No %s typemap defined for %s\n", tmap_method, SwigType_str(type, 0));
|
||||
}
|
||||
if (!typemap_attributes)
|
||||
Delete(node);
|
||||
|
|
|
|||
|
|
@ -718,6 +718,10 @@ String *Swig_overload_dispatch(Node *n, const_String_or_char_ptr fmt, int *maxar
|
|||
Parm *pi = Getattr(ni, "wrap:parms");
|
||||
int num_required = emit_num_required(pi);
|
||||
int num_arguments = emit_num_arguments(pi);
|
||||
if (GetFlag(n, "wrap:this")) {
|
||||
num_required++;
|
||||
num_arguments++;
|
||||
}
|
||||
if (num_arguments > *maxargs)
|
||||
*maxargs = num_arguments;
|
||||
int varargs = emit_isvarargs(pi);
|
||||
|
|
@ -751,7 +755,7 @@ String *Swig_overload_dispatch(Node *n, const_String_or_char_ptr fmt, int *maxar
|
|||
Printf(f, "}\n");
|
||||
Delete(lfmt);
|
||||
}
|
||||
if (print_typecheck(f, j, pj)) {
|
||||
if (print_typecheck(f, (GetFlag(n, "wrap:this") ? j + 1 : j), pj)) {
|
||||
Printf(f, "if (_v) {\n");
|
||||
num_braces++;
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -728,7 +728,7 @@ public:
|
|||
Printf(f_shadow, tab8 tab8 "_mod = imp.load_module('%s', fp, pathname, description)\n", module);
|
||||
Printv(f_shadow, tab4 tab8, "finally:\n", NULL);
|
||||
Printv(f_shadow, tab8 tab8, "fp.close()\n", NULL);
|
||||
Printv(f_shadow, tab8 tab8, "return _mod\n", NULL);
|
||||
Printv(f_shadow, tab4 tab8, "return _mod\n", NULL);
|
||||
Printf(f_shadow, tab4 "%s = swig_import_helper()\n", module);
|
||||
Printv(f_shadow, tab4, "del swig_import_helper\n", NULL);
|
||||
Printv(f_shadow, "else:\n", NULL);
|
||||
|
|
|
|||
|
|
@ -1418,15 +1418,13 @@ static List * Swig_overload_rank(Node *n,
|
|||
String *t2 = Getattr(p2,"tmap:typecheck:precedence");
|
||||
if ((!t1) && (!nodes[i].error)) {
|
||||
Swig_warning(WARN_TYPEMAP_TYPECHECK, Getfile(nodes[i].n), Getline(nodes[i].n),
|
||||
"Overloaded %s(%s) not supported (no type checking rule for '%s').\n",
|
||||
Getattr(nodes[i].n,"name"),ParmList_str_defaultargs(Getattr(nodes[i].n,"parms")),
|
||||
SwigType_str(Getattr(p1,"type"),0));
|
||||
"Overloaded method %s not supported (no type checking rule for '%s').\n",
|
||||
Swig_name_decl(nodes[i].n), SwigType_str(Getattr(p1, "type"), 0));
|
||||
nodes[i].error = 1;
|
||||
} else if ((!t2) && (!nodes[j].error)) {
|
||||
Swig_warning(WARN_TYPEMAP_TYPECHECK, Getfile(nodes[j].n), Getline(nodes[j].n),
|
||||
"Overloaded %s(%s) not supported (no type checking rule for '%s').\n",
|
||||
Getattr(nodes[j].n,"name"),ParmList_str_defaultargs(Getattr(nodes[j].n,"parms")),
|
||||
SwigType_str(Getattr(p2,"type"),0));
|
||||
"xx Overloaded method %s not supported (no type checking rule for '%s').\n",
|
||||
Swig_name_decl(nodes[j].n), SwigType_str(Getattr(p2, "type"), 0));
|
||||
nodes[j].error = 1;
|
||||
}
|
||||
if (t1 && t2) {
|
||||
|
|
@ -1556,21 +1554,15 @@ static List * Swig_overload_rank(Node *n,
|
|||
if (!nodes[j].error) {
|
||||
if (script_lang_wrapping) {
|
||||
Swig_warning(WARN_LANG_OVERLOAD_SHADOW, Getfile(nodes[j].n), Getline(nodes[j].n),
|
||||
"Overloaded %s(%s)%s is shadowed by %s(%s)%s at %s:%d.\n",
|
||||
Getattr(nodes[j].n,"name"), ParmList_errorstr(nodes[j].parms),
|
||||
SwigType_isconst(Getattr(nodes[j].n,"decl")) ? " const" : "",
|
||||
Getattr(nodes[i].n,"name"), ParmList_errorstr(nodes[i].parms),
|
||||
SwigType_isconst(Getattr(nodes[i].n,"decl")) ? " const" : "",
|
||||
Getfile(nodes[i].n),Getline(nodes[i].n));
|
||||
"Overloaded method %s is shadowed by %s at %s:%d.\n",
|
||||
Swig_name_decl(nodes[j].n), Swig_name_decl(nodes[i].n),
|
||||
Getfile(nodes[i].n), Getline(nodes[i].n));
|
||||
} else {
|
||||
if (!Getattr(nodes[j].n, "overload:ignore"))
|
||||
Swig_warning(WARN_LANG_OVERLOAD_IGNORED, Getfile(nodes[j].n), Getline(nodes[j].n),
|
||||
"Overloaded method %s(%s)%s ignored. Method %s(%s)%s at %s:%d used.\n",
|
||||
Getattr(nodes[j].n,"name"), ParmList_errorstr(nodes[j].parms),
|
||||
SwigType_isconst(Getattr(nodes[j].n,"decl")) ? " const" : "",
|
||||
Getattr(nodes[i].n,"name"), ParmList_errorstr(nodes[i].parms),
|
||||
SwigType_isconst(Getattr(nodes[i].n,"decl")) ? " const" : "",
|
||||
Getfile(nodes[i].n),Getline(nodes[i].n));
|
||||
"Overloaded method %s ignored. Method %s at %s:%d used.\n",
|
||||
Swig_name_decl(nodes[j].n), Swig_name_decl(nodes[i].n),
|
||||
Getfile(nodes[i].n), Getline(nodes[i].n));
|
||||
}
|
||||
nodes[j].error = 1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -216,6 +216,7 @@ public:
|
|||
virtual int is_assignable(Node *n); /* Is variable assignable? */
|
||||
virtual String *runtimeCode(); /* returns the language specific runtime code */
|
||||
virtual String *defaultExternalRuntimeFilename(); /* the default filename for the external runtime */
|
||||
virtual void replaceSpecialVariables(String *method, String *tm, Parm *parm); /* Language specific special variable substitutions for $typemap() */
|
||||
|
||||
/* Runtime is C++ based, so extern "C" header section */
|
||||
void enable_cplus_runtime_mode();
|
||||
|
|
@ -250,6 +251,9 @@ public:
|
|||
/* Set overload variable templates argc and argv */
|
||||
void setOverloadResolutionTemplates(String *argc, String *argv);
|
||||
|
||||
/* Language instance is a singleton - get instance */
|
||||
static Language* instance();
|
||||
|
||||
protected:
|
||||
/* Allow multiple-input typemaps */
|
||||
void allow_multiple_input(int val = 1);
|
||||
|
|
@ -307,6 +311,7 @@ private:
|
|||
int multiinput;
|
||||
int cplus_runtime;
|
||||
int directors;
|
||||
static Language *this_;
|
||||
};
|
||||
|
||||
int SWIG_main(int, char **, Language *);
|
||||
|
|
@ -347,7 +352,9 @@ void Swig_director_emit_dynamic_cast(Node *n, Wrapper *f);
|
|||
extern "C" {
|
||||
void SWIG_typemap_lang(const char *);
|
||||
typedef Language *(*ModuleFactory) (void);
|
||||
} void Swig_register_module(const char *name, ModuleFactory fac);
|
||||
}
|
||||
|
||||
void Swig_register_module(const char *name, ModuleFactory fac);
|
||||
ModuleFactory Swig_find_module(const char *name);
|
||||
|
||||
/* Utilities */
|
||||
|
|
|
|||
|
|
@ -1611,7 +1611,7 @@ String *Swig_name_decl(Node *n) {
|
|||
qname = NewString("");
|
||||
if (qualifier && Len(qualifier) > 0)
|
||||
Printf(qname, "%s::", qualifier);
|
||||
Printf(qname, "%s", name);
|
||||
Printf(qname, "%s", SwigType_str(name, 0));
|
||||
|
||||
decl = NewStringf("%s(%s)%s", qname, ParmList_errorstr(Getattr(n, "parms")), SwigType_isconst(Getattr(n, "decl")) ? " const" : "");
|
||||
|
||||
|
|
|
|||
|
|
@ -85,6 +85,7 @@ void Scanner_clear(Scanner * s) {
|
|||
Clear(s->text);
|
||||
Clear(s->scanobjs);
|
||||
Delete(s->error);
|
||||
s->str = 0;
|
||||
s->error = 0;
|
||||
s->line = 1;
|
||||
s->nexttoken = -1;
|
||||
|
|
|
|||
|
|
@ -363,19 +363,19 @@ extern int ParmList_is_compactdefargs(ParmList *p);
|
|||
/* --- Legacy Typemap API (somewhat simplified, ha!) --- */
|
||||
|
||||
extern void Swig_typemap_init(void);
|
||||
extern void Swig_typemap_register(const_String_or_char_ptr op, ParmList *pattern, const_String_or_char_ptr code, ParmList *locals, ParmList *kwargs);
|
||||
extern int Swig_typemap_copy(const_String_or_char_ptr op, ParmList *srcpattern, ParmList *pattern);
|
||||
extern void Swig_typemap_clear(const_String_or_char_ptr op, ParmList *pattern);
|
||||
extern void Swig_typemap_register(const_String_or_char_ptr tmap_method, ParmList *pattern, const_String_or_char_ptr code, ParmList *locals, ParmList *kwargs);
|
||||
extern int Swig_typemap_copy(const_String_or_char_ptr tmap_method, ParmList *srcpattern, ParmList *pattern);
|
||||
extern void Swig_typemap_clear(const_String_or_char_ptr tmap_method, ParmList *pattern);
|
||||
extern int Swig_typemap_apply(ParmList *srcpat, ParmList *destpat);
|
||||
extern void Swig_typemap_clear_apply(ParmList *pattern);
|
||||
extern void Swig_typemap_debug(void);
|
||||
|
||||
extern String *Swig_typemap_lookup(const_String_or_char_ptr op, Node *n, const_String_or_char_ptr lname, Wrapper *f);
|
||||
extern String *Swig_typemap_lookup_out(const_String_or_char_ptr op, Node *n, const_String_or_char_ptr lname, Wrapper *f, String *actioncode);
|
||||
extern String *Swig_typemap_lookup(const_String_or_char_ptr tmap_method, Node *n, const_String_or_char_ptr lname, Wrapper *f);
|
||||
extern String *Swig_typemap_lookup_out(const_String_or_char_ptr tmap_method, Node *n, const_String_or_char_ptr lname, Wrapper *f, String *actioncode);
|
||||
extern void Swig_typemap_new_scope(void);
|
||||
extern Hash *Swig_typemap_pop_scope(void);
|
||||
|
||||
extern void Swig_typemap_attach_parms(const_String_or_char_ptr op, ParmList *parms, Wrapper *f);
|
||||
extern void Swig_typemap_attach_parms(const_String_or_char_ptr tmap_method, ParmList *parms, Wrapper *f);
|
||||
|
||||
/* --- Code fragment support --- */
|
||||
|
||||
|
|
@ -390,6 +390,7 @@ extern int ParmList_is_compactdefargs(ParmList *p);
|
|||
extern void Wrapper_director_mode_set(int);
|
||||
extern void Wrapper_director_protected_mode_set(int);
|
||||
extern void Wrapper_all_protected_mode_set(int);
|
||||
extern void Language_replace_special_variables(String *method, String *tm, Parm *parm);
|
||||
|
||||
|
||||
/* -- template init -- */
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@ char cvsroot_typemap_c[] = "$Id$";
|
|||
#define SWIG_DEBUG
|
||||
#endif
|
||||
|
||||
static void replace_embedded_typemap(String *s);
|
||||
static void replace_embedded_typemap(String *s, ParmList *parm_sublist, Wrapper *f);
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Typemaps are stored in a collection of nested hash tables. Something like
|
||||
|
|
@ -31,14 +31,24 @@ static void replace_embedded_typemap(String *s);
|
|||
* different typemap methods. These are referenced by names such as
|
||||
* "tmap:in", "tmap:out", "tmap:argout", and so forth.
|
||||
*
|
||||
* The object corresponding to a specific method has the following
|
||||
* attributes:
|
||||
* The object corresponding to a specific typemap method has the following attributes:
|
||||
*
|
||||
* "type" - Typemap type
|
||||
* "pname" - Parameter name
|
||||
* "code" - Typemap code
|
||||
* "typemap" - Descriptive text describing the actual map
|
||||
* "locals" - Local variables (if any)
|
||||
* "kwargs" - Typemap attributes
|
||||
*
|
||||
* Example for a typemap method named "in":
|
||||
* %typemap(in, warning="987:my warning", noblock=1) int &my_int (int tmp) "$1 = $input;"
|
||||
*
|
||||
* "type" - r.int
|
||||
* "pname" - my_int
|
||||
* "code" - $1 = $input;
|
||||
* "typemap" - typemap(in) int &my_int
|
||||
* "locals" - int tmp
|
||||
* "kwargs" - warning="987:my typemap warning", foo=123
|
||||
*
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
|
|
@ -107,29 +117,29 @@ void Swig_typemap_init() {
|
|||
tm_scope = 0;
|
||||
}
|
||||
|
||||
static String *tmop_name(const_String_or_char_ptr op) {
|
||||
static String *typemap_method_name(const_String_or_char_ptr tmap_method) {
|
||||
static Hash *names = 0;
|
||||
String *s;
|
||||
/* Due to "interesting" object-identity semantics of DOH,
|
||||
we have to make sure that we only intern strings without object
|
||||
identity into the hash table.
|
||||
|
||||
(typemap_attach_kwargs calls tmop_name several times with
|
||||
the "same" String *op (i.e., same object identity) but differing
|
||||
(typemap_attach_kwargs calls typemap_method_name several times with
|
||||
the "same" String *tmap_method (i.e., same object identity) but differing
|
||||
string values.)
|
||||
|
||||
Most other callers work around this by using char* rather than
|
||||
String *.
|
||||
-- mkoeppe, Jun 17, 2003
|
||||
*/
|
||||
const char *op_without_object_identity = Char(op);
|
||||
const char *method_without_object_identity = Char(tmap_method);
|
||||
if (!names)
|
||||
names = NewHash();
|
||||
s = Getattr(names, op_without_object_identity);
|
||||
s = Getattr(names, method_without_object_identity);
|
||||
if (s)
|
||||
return s;
|
||||
s = NewStringf("tmap:%s", op);
|
||||
Setattr(names, op_without_object_identity, s);
|
||||
s = NewStringf("tmap:%s", tmap_method);
|
||||
Setattr(names, method_without_object_identity, s);
|
||||
Delete(s);
|
||||
return s;
|
||||
}
|
||||
|
|
@ -163,21 +173,21 @@ Hash *Swig_typemap_pop_scope() {
|
|||
/* -----------------------------------------------------------------------------
|
||||
* Swig_typemap_register()
|
||||
*
|
||||
* Add a new multi-valued typemap
|
||||
* Add a new multi-argument typemap
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void Swig_typemap_register(const_String_or_char_ptr op, ParmList *parms, const_String_or_char_ptr code, ParmList *locals, ParmList *kwargs) {
|
||||
void Swig_typemap_register(const_String_or_char_ptr tmap_method, ParmList *parms, const_String_or_char_ptr code, ParmList *locals, ParmList *kwargs) {
|
||||
Hash *tm;
|
||||
Hash *tm1;
|
||||
Hash *tm2;
|
||||
Parm *np;
|
||||
String *tmop;
|
||||
String *tm_method;
|
||||
SwigType *type;
|
||||
String *pname;
|
||||
|
||||
if (!parms)
|
||||
return;
|
||||
tmop = tmop_name(op);
|
||||
tm_method = typemap_method_name(tmap_method);
|
||||
|
||||
/* Register the first type in the parameter list */
|
||||
|
||||
|
|
@ -202,15 +212,15 @@ void Swig_typemap_register(const_String_or_char_ptr op, ParmList *parms, const_S
|
|||
tm = tm1;
|
||||
}
|
||||
|
||||
/* Now see if this typemap op has been seen before */
|
||||
tm2 = Getattr(tm, tmop);
|
||||
/* Now see if this typemap method has been seen before */
|
||||
tm2 = Getattr(tm, tm_method);
|
||||
if (!tm2) {
|
||||
tm2 = NewHash();
|
||||
Setattr(tm, tmop, tm2);
|
||||
Setattr(tm, tm_method, tm2);
|
||||
Delete(tm2);
|
||||
}
|
||||
|
||||
/* For a multi-valued typemap, the typemap code and information
|
||||
/* For a multi-argument typemap, the typemap code and information
|
||||
is really only stored in the last argument. However, to
|
||||
make this work, we perform a really neat trick using
|
||||
the typemap operator name.
|
||||
|
|
@ -237,7 +247,7 @@ void Swig_typemap_register(const_String_or_char_ptr op, ParmList *parms, const_S
|
|||
np = nextSibling(parms);
|
||||
if (np) {
|
||||
/* Make an entirely new operator key */
|
||||
String *newop = NewStringf("%s-%s+%s:", op, type, pname);
|
||||
String *newop = NewStringf("%s-%s+%s:", tmap_method, type, pname);
|
||||
/* Now reregister on the remaining arguments */
|
||||
Swig_typemap_register(newop, np, code, locals, kwargs);
|
||||
|
||||
|
|
@ -245,7 +255,7 @@ void Swig_typemap_register(const_String_or_char_ptr op, ParmList *parms, const_S
|
|||
Delete(newop);
|
||||
} else {
|
||||
String *str = SwigType_str(type, pname);
|
||||
String *typemap = NewStringf("typemap(%s) %s", op, str);
|
||||
String *typemap = NewStringf("typemap(%s) %s", tmap_method, str);
|
||||
ParmList *clocals = CopyParmList(locals);
|
||||
ParmList *ckwargs = CopyParmList(kwargs);
|
||||
|
||||
|
|
@ -294,21 +304,21 @@ static Hash *typemap_get(SwigType *type, const_String_or_char_ptr name, int scop
|
|||
* Copy a typemap
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
int Swig_typemap_copy(const_String_or_char_ptr op, ParmList *srcparms, ParmList *parms) {
|
||||
int Swig_typemap_copy(const_String_or_char_ptr tmap_method, ParmList *srcparms, ParmList *parms) {
|
||||
Hash *tm = 0;
|
||||
String *tmop;
|
||||
String *tm_method;
|
||||
Parm *p;
|
||||
String *pname;
|
||||
SwigType *ptype;
|
||||
int ts = tm_scope;
|
||||
String *tmops, *newop;
|
||||
String *tm_methods, *newop;
|
||||
if (ParmList_len(parms) != ParmList_len(srcparms))
|
||||
return -1;
|
||||
|
||||
tmop = tmop_name(op);
|
||||
tm_method = typemap_method_name(tmap_method);
|
||||
while (ts >= 0) {
|
||||
p = srcparms;
|
||||
tmops = NewString(tmop);
|
||||
tm_methods = NewString(tm_method);
|
||||
while (p) {
|
||||
ptype = Getattr(p, "type");
|
||||
pname = Getattr(p, "name");
|
||||
|
|
@ -318,22 +328,22 @@ int Swig_typemap_copy(const_String_or_char_ptr op, ParmList *srcparms, ParmList
|
|||
if (!tm)
|
||||
break;
|
||||
|
||||
tm = Getattr(tm, tmops);
|
||||
tm = Getattr(tm, tm_methods);
|
||||
if (!tm)
|
||||
break;
|
||||
|
||||
/* Got a match. Look for next typemap */
|
||||
newop = NewStringf("%s-%s+%s:", tmops, ptype, pname);
|
||||
Delete(tmops);
|
||||
tmops = newop;
|
||||
newop = NewStringf("%s-%s+%s:", tm_methods, ptype, pname);
|
||||
Delete(tm_methods);
|
||||
tm_methods = newop;
|
||||
p = nextSibling(p);
|
||||
}
|
||||
Delete(tmops);
|
||||
Delete(tm_methods);
|
||||
|
||||
if (!p && tm) {
|
||||
|
||||
/* Got some kind of match */
|
||||
Swig_typemap_register(op, parms, Getattr(tm, "code"), Getattr(tm, "locals"), Getattr(tm, "kwargs"));
|
||||
Swig_typemap_register(tmap_method, parms, Getattr(tm, "code"), Getattr(tm, "locals"), Getattr(tm, "kwargs"));
|
||||
return 0;
|
||||
}
|
||||
ts--;
|
||||
|
|
@ -346,10 +356,10 @@ int Swig_typemap_copy(const_String_or_char_ptr op, ParmList *srcparms, ParmList
|
|||
/* -----------------------------------------------------------------------------
|
||||
* Swig_typemap_clear()
|
||||
*
|
||||
* Delete a multi-valued typemap
|
||||
* Delete a multi-argument typemap
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void Swig_typemap_clear(const_String_or_char_ptr op, ParmList *parms) {
|
||||
void Swig_typemap_clear(const_String_or_char_ptr tmap_method, ParmList *parms) {
|
||||
SwigType *type;
|
||||
String *name;
|
||||
Parm *p;
|
||||
|
|
@ -357,7 +367,7 @@ void Swig_typemap_clear(const_String_or_char_ptr op, ParmList *parms) {
|
|||
Hash *tm = 0;
|
||||
|
||||
/* This might not work */
|
||||
newop = NewString(op);
|
||||
newop = NewString(tmap_method);
|
||||
p = parms;
|
||||
while (p) {
|
||||
type = Getattr(p, "type");
|
||||
|
|
@ -370,7 +380,7 @@ void Swig_typemap_clear(const_String_or_char_ptr op, ParmList *parms) {
|
|||
Printf(newop, "-%s+%s:", type, name);
|
||||
}
|
||||
if (tm) {
|
||||
tm = Getattr(tm, tmop_name(newop));
|
||||
tm = Getattr(tm, typemap_method_name(newop));
|
||||
if (tm) {
|
||||
Delattr(tm, "code");
|
||||
Delattr(tm, "locals");
|
||||
|
|
@ -591,7 +601,7 @@ static SwigType *strip_arrays(SwigType *type) {
|
|||
* that includes a 'code' attribute.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static Hash *typemap_search(const_String_or_char_ptr op, SwigType *type, const_String_or_char_ptr name, SwigType **matchtype) {
|
||||
static Hash *typemap_search(const_String_or_char_ptr tmap_method, SwigType *type, const_String_or_char_ptr name, SwigType **matchtype) {
|
||||
Hash *result = 0, *tm, *tm1, *tma;
|
||||
Hash *backup = 0;
|
||||
SwigType *noarrays = 0;
|
||||
|
|
@ -601,7 +611,7 @@ static Hash *typemap_search(const_String_or_char_ptr op, SwigType *type, const_S
|
|||
int isarray;
|
||||
const String *cname = 0;
|
||||
SwigType *unstripped = 0;
|
||||
String *tmop = tmop_name(op);
|
||||
String *tm_method = typemap_method_name(tmap_method);
|
||||
|
||||
if ((name) && Len(name))
|
||||
cname = name;
|
||||
|
|
@ -615,7 +625,7 @@ static Hash *typemap_search(const_String_or_char_ptr op, SwigType *type, const_S
|
|||
if (tm && cname) {
|
||||
tm1 = Getattr(tm, cname);
|
||||
if (tm1) {
|
||||
result = Getattr(tm1, tmop); /* See if there is a type-name match */
|
||||
result = Getattr(tm1, tm_method); /* See if there is a type-name match */
|
||||
if (result && Getattr(result, "code"))
|
||||
goto ret_result;
|
||||
if (result)
|
||||
|
|
@ -623,7 +633,7 @@ static Hash *typemap_search(const_String_or_char_ptr op, SwigType *type, const_S
|
|||
}
|
||||
}
|
||||
if (tm) {
|
||||
result = Getattr(tm, tmop); /* See if there is simply a type match */
|
||||
result = Getattr(tm, tm_method); /* See if there is simply a type match */
|
||||
if (result && Getattr(result, "code"))
|
||||
goto ret_result;
|
||||
if (result)
|
||||
|
|
@ -640,7 +650,7 @@ static Hash *typemap_search(const_String_or_char_ptr op, SwigType *type, const_S
|
|||
if (tma && cname) {
|
||||
tm1 = Getattr(tma, cname);
|
||||
if (tm1) {
|
||||
result = Getattr(tm1, tmop); /* type-name match */
|
||||
result = Getattr(tm1, tm_method); /* type-name match */
|
||||
if (result && Getattr(result, "code"))
|
||||
goto ret_result;
|
||||
if (result)
|
||||
|
|
@ -648,7 +658,7 @@ static Hash *typemap_search(const_String_or_char_ptr op, SwigType *type, const_S
|
|||
}
|
||||
}
|
||||
if (tma) {
|
||||
result = Getattr(tma, tmop); /* type match */
|
||||
result = Getattr(tma, tm_method); /* type match */
|
||||
if (result && Getattr(result, "code"))
|
||||
goto ret_result;
|
||||
if (result)
|
||||
|
|
@ -692,13 +702,13 @@ static Hash *typemap_search(const_String_or_char_ptr op, SwigType *type, const_S
|
|||
if (tm && cname) {
|
||||
tm1 = Getattr(tm, cname);
|
||||
if (tm1) {
|
||||
result = Getattr(tm1, tmop); /* See if there is a type-name match */
|
||||
result = Getattr(tm1, tm_method); /* See if there is a type-name match */
|
||||
if (result)
|
||||
goto ret_result;
|
||||
}
|
||||
}
|
||||
if (tm) { /* See if there is simply a type match */
|
||||
result = Getattr(tm, tmop);
|
||||
result = Getattr(tm, tm_method);
|
||||
if (result)
|
||||
goto ret_result;
|
||||
}
|
||||
|
|
@ -735,10 +745,10 @@ ret_result:
|
|||
/* -----------------------------------------------------------------------------
|
||||
* typemap_search_multi()
|
||||
*
|
||||
* Search for a multi-valued typemap.
|
||||
* Search for a multi-argument typemap.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static Hash *typemap_search_multi(const_String_or_char_ptr op, ParmList *parms, int *nmatch) {
|
||||
static Hash *typemap_search_multi(const_String_or_char_ptr tmap_method, ParmList *parms, int *nmatch) {
|
||||
SwigType *type;
|
||||
SwigType *mtype = 0;
|
||||
String *name;
|
||||
|
|
@ -753,13 +763,13 @@ static Hash *typemap_search_multi(const_String_or_char_ptr op, ParmList *parms,
|
|||
name = Getattr(parms, "name");
|
||||
|
||||
/* Try to find a match on the first type */
|
||||
tm = typemap_search(op, type, name, &mtype);
|
||||
tm = typemap_search(tmap_method, type, name, &mtype);
|
||||
if (tm) {
|
||||
if (mtype && SwigType_isarray(mtype)) {
|
||||
Setattr(parms, "tmap:match", mtype);
|
||||
}
|
||||
Delete(mtype);
|
||||
newop = NewStringf("%s-%s+%s:", op, type, name);
|
||||
newop = NewStringf("%s-%s+%s:", tmap_method, type, name);
|
||||
tm1 = typemap_search_multi(newop, nextSibling(parms), nmatch);
|
||||
if (tm1)
|
||||
tm = tm1;
|
||||
|
|
@ -806,7 +816,7 @@ static int typemap_replace_vars(String *s, ParmList *locals, SwigType *type, Swi
|
|||
SwigType *ftype;
|
||||
int bare_substitution_count = 0;
|
||||
|
||||
Replaceall(s, "$typemap", "$TYPEMAP");
|
||||
Replaceall(s, "$typemap", "$TYPEMAP"); /* workaround for $type substitution below */
|
||||
|
||||
ftype = SwigType_typedef_resolve_all(type);
|
||||
|
||||
|
|
@ -1162,16 +1172,26 @@ static void typemap_locals(DOHString * s, ParmList *l, Wrapper *f, int argnum) {
|
|||
*
|
||||
* Attach one or more typemaps to a node and optionally generate the typemap contents
|
||||
* into the wrapper.
|
||||
* op - typemap name, eg "out", "newfree"
|
||||
* node - the node to attach the typemaps to
|
||||
* lname - name of variable to substitute $1, $2 etc for
|
||||
* f - wrapper code to generate into if non null
|
||||
* actioncode - code to generate into f before the out typemap code, unless
|
||||
*
|
||||
* Looks for a typemap matching the given type and name and attaches the typemap code
|
||||
* and any typemap attributes to the provided node.
|
||||
*
|
||||
* The node should contain the "type" and "name" attributes for the typemap match on.
|
||||
* input. The typemap code and typemap attribute values are attached onto the node
|
||||
* prefixed with "tmap:". For example with tmap_method="in", the typemap code can be retrieved
|
||||
* with a call to Getattr(node, "tmap:in") (this is also the string returned) and the
|
||||
* "noblock" attribute can be retrieved with a call to Getattr(node, "tmap:in:noblock").
|
||||
*
|
||||
* tmap_method - typemap method, eg "in", "out", "newfree"
|
||||
* node - the node to attach the typemap and typemap attributes to
|
||||
* lname - name of variable to substitute $1, $2 etc for
|
||||
* f - wrapper code to generate into if non null
|
||||
* actioncode - code to generate into f before the out typemap code, unless
|
||||
* the optimal attribute is set in the out typemap in which case
|
||||
* $1 in the out typemap will be replaced by the code in actioncode.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static String *Swig_typemap_lookup_impl(const_String_or_char_ptr op, Node *node, const_String_or_char_ptr lname, Wrapper *f, String *actioncode) {
|
||||
static String *Swig_typemap_lookup_impl(const_String_or_char_ptr tmap_method, Node *node, const_String_or_char_ptr lname, Wrapper *f, String *actioncode) {
|
||||
SwigType *type;
|
||||
SwigType *mtype = 0;
|
||||
String *pname;
|
||||
|
|
@ -1184,14 +1204,14 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr op, Node *node,
|
|||
String *symname;
|
||||
String *cname = 0;
|
||||
String *clname = 0;
|
||||
char *cop = Char(op);
|
||||
char *cop = Char(tmap_method);
|
||||
int optimal_attribute = 0;
|
||||
int optimal_substitution = 0;
|
||||
int num_substitutions = 0;
|
||||
|
||||
/* special case, we need to check for 'ref' call
|
||||
and set the default code 'sdef' */
|
||||
if (node && Cmp(op, "newfree") == 0) {
|
||||
if (node && Cmp(tmap_method, "newfree") == 0) {
|
||||
sdef = Swig_ref_call(node, lname);
|
||||
}
|
||||
|
||||
|
|
@ -1214,7 +1234,7 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr op, Node *node,
|
|||
String *qsn = st ? Swig_symbol_string_qualify(pname, st) : 0;
|
||||
if (qsn) {
|
||||
if (Len(qsn) && !Equal(qsn, pname)) {
|
||||
tm = typemap_search(op, type, qsn, &mtype);
|
||||
tm = typemap_search(tmap_method, type, qsn, &mtype);
|
||||
if (tm && (!Getattr(tm, "pname") || strstr(Char(Getattr(tm, "type")), "SWIGTYPE"))) {
|
||||
tm = 0;
|
||||
}
|
||||
|
|
@ -1224,7 +1244,7 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr op, Node *node,
|
|||
}
|
||||
if (!tm)
|
||||
#endif
|
||||
tm = typemap_search(op, type, pname, &mtype);
|
||||
tm = typemap_search(tmap_method, type, pname, &mtype);
|
||||
if (!tm)
|
||||
return sdef;
|
||||
|
||||
|
|
@ -1242,15 +1262,15 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr op, Node *node,
|
|||
kw = Getattr(tm, "kwargs");
|
||||
while (kw) {
|
||||
String *value = Copy(Getattr(kw, "value"));
|
||||
String *type = Getattr(kw, "type");
|
||||
String *kwtype = Getattr(kw, "type");
|
||||
char *ckwname = Char(Getattr(kw, "name"));
|
||||
if (type) {
|
||||
String *mangle = Swig_string_mangle(type);
|
||||
if (kwtype) {
|
||||
String *mangle = Swig_string_mangle(kwtype);
|
||||
Append(value, mangle);
|
||||
Delete(mangle);
|
||||
}
|
||||
sprintf(temp, "%s:%s", cop, ckwname);
|
||||
Setattr(node, tmop_name(temp), value);
|
||||
Setattr(node, typemap_method_name(temp), value);
|
||||
if (Cmp(temp, "out:optimal") == 0)
|
||||
optimal_attribute = (Cmp(value, "0") != 0) ? 1 : 0;
|
||||
Delete(value);
|
||||
|
|
@ -1324,7 +1344,13 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr op, Node *node,
|
|||
if (locals && f) {
|
||||
typemap_locals(s, locals, f, -1);
|
||||
}
|
||||
replace_embedded_typemap(s);
|
||||
|
||||
{
|
||||
ParmList *parm_sublist = NewParm(type, pname);
|
||||
Setattr(parm_sublist, "lname", lname);
|
||||
replace_embedded_typemap(s, parm_sublist, f);
|
||||
Delete(parm_sublist);
|
||||
}
|
||||
|
||||
Replace(s, "$name", pname, DOH_REPLACE_ANY);
|
||||
|
||||
|
|
@ -1333,23 +1359,23 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr op, Node *node,
|
|||
Replace(s, "$symname", symname, DOH_REPLACE_ANY);
|
||||
}
|
||||
|
||||
Setattr(node, tmop_name(op), s);
|
||||
Setattr(node, typemap_method_name(tmap_method), s);
|
||||
if (locals) {
|
||||
sprintf(temp, "%s:locals", cop);
|
||||
Setattr(node, tmop_name(temp), locals);
|
||||
Setattr(node, typemap_method_name(temp), locals);
|
||||
Delete(locals);
|
||||
}
|
||||
|
||||
if (Checkattr(tm, "type", "SWIGTYPE")) {
|
||||
sprintf(temp, "%s:SWIGTYPE", cop);
|
||||
Setattr(node, tmop_name(temp), "1");
|
||||
Setattr(node, typemap_method_name(temp), "1");
|
||||
}
|
||||
|
||||
/* Look for warnings */
|
||||
{
|
||||
String *w;
|
||||
sprintf(temp, "%s:warning", cop);
|
||||
w = Getattr(node, tmop_name(temp));
|
||||
w = Getattr(node, typemap_method_name(temp));
|
||||
if (w) {
|
||||
Swig_warning(0, Getfile(node), Getline(node), "%s\n", w);
|
||||
}
|
||||
|
|
@ -1357,11 +1383,11 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr op, Node *node,
|
|||
|
||||
/* Look for code fragments */
|
||||
{
|
||||
String *f;
|
||||
String *fragment;
|
||||
sprintf(temp, "%s:fragment", cop);
|
||||
f = Getattr(node, tmop_name(temp));
|
||||
if (f) {
|
||||
String *fname = Copy(f);
|
||||
fragment = Getattr(node, typemap_method_name(temp));
|
||||
if (fragment) {
|
||||
String *fname = Copy(fragment);
|
||||
Setfile(fname, Getfile(node));
|
||||
Setline(fname, Getline(node));
|
||||
Swig_fragment_emit(fname);
|
||||
|
|
@ -1382,14 +1408,14 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr op, Node *node,
|
|||
return s;
|
||||
}
|
||||
|
||||
String *Swig_typemap_lookup_out(const_String_or_char_ptr op, Node *node, const_String_or_char_ptr lname, Wrapper *f, String *actioncode) {
|
||||
String *Swig_typemap_lookup_out(const_String_or_char_ptr tmap_method, Node *node, const_String_or_char_ptr lname, Wrapper *f, String *actioncode) {
|
||||
assert(actioncode);
|
||||
assert(Cmp(op, "out") == 0);
|
||||
return Swig_typemap_lookup_impl(op, node, lname, f, actioncode);
|
||||
assert(Cmp(tmap_method, "out") == 0);
|
||||
return Swig_typemap_lookup_impl(tmap_method, node, lname, f, actioncode);
|
||||
}
|
||||
|
||||
String *Swig_typemap_lookup(const_String_or_char_ptr op, Node *node, const_String_or_char_ptr lname, Wrapper *f) {
|
||||
return Swig_typemap_lookup_impl(op, node, lname, f, 0);
|
||||
String *Swig_typemap_lookup(const_String_or_char_ptr tmap_method, Node *node, const_String_or_char_ptr lname, Wrapper *f) {
|
||||
return Swig_typemap_lookup_impl(tmap_method, node, lname, f, 0);
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
|
|
@ -1403,7 +1429,7 @@ String *Swig_typemap_lookup(const_String_or_char_ptr op, Node *node, const_Strin
|
|||
* A new attribute called "tmap:in:foo" with value "xyz" is attached to p.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static void typemap_attach_kwargs(Hash *tm, const_String_or_char_ptr op, Parm *p) {
|
||||
static void typemap_attach_kwargs(Hash *tm, const_String_or_char_ptr tmap_method, Parm *p) {
|
||||
String *temp = NewStringEmpty();
|
||||
Parm *kw = Getattr(tm, "kwargs");
|
||||
while (kw) {
|
||||
|
|
@ -1417,36 +1443,36 @@ static void typemap_attach_kwargs(Hash *tm, const_String_or_char_ptr op, Parm *p
|
|||
value = v;
|
||||
}
|
||||
Clear(temp);
|
||||
Printf(temp, "%s:%s", op, Getattr(kw, "name"));
|
||||
Setattr(p, tmop_name(temp), value);
|
||||
Printf(temp, "%s:%s", tmap_method, Getattr(kw, "name"));
|
||||
Setattr(p, typemap_method_name(temp), value);
|
||||
Delete(value);
|
||||
kw = nextSibling(kw);
|
||||
}
|
||||
Clear(temp);
|
||||
Printf(temp, "%s:match_type", op);
|
||||
Setattr(p, tmop_name(temp), Getattr(tm, "type"));
|
||||
Printf(temp, "%s:match_type", tmap_method);
|
||||
Setattr(p, typemap_method_name(temp), Getattr(tm, "type"));
|
||||
Delete(temp);
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* typemap_warn()
|
||||
*
|
||||
* If any warning message is attached to this parameter's "tmap:op:warning"
|
||||
* If any warning message is attached to this parameter's "tmap:<method>:warning"
|
||||
* attribute, print that warning message.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static void typemap_warn(const_String_or_char_ptr op, Parm *p) {
|
||||
String *temp = NewStringf("%s:warning", op);
|
||||
String *w = Getattr(p, tmop_name(temp));
|
||||
static void typemap_warn(const_String_or_char_ptr tmap_method, Parm *p) {
|
||||
String *temp = NewStringf("%s:warning", tmap_method);
|
||||
String *w = Getattr(p, typemap_method_name(temp));
|
||||
Delete(temp);
|
||||
if (w) {
|
||||
Swig_warning(0, Getfile(p), Getline(p), "%s\n", w);
|
||||
}
|
||||
}
|
||||
|
||||
static void typemap_emit_code_fragments(const_String_or_char_ptr op, Parm *p) {
|
||||
String *temp = NewStringf("%s:fragment", op);
|
||||
String *f = Getattr(p, tmop_name(temp));
|
||||
static void typemap_emit_code_fragments(const_String_or_char_ptr tmap_method, Parm *p) {
|
||||
String *temp = NewStringf("%s:fragment", tmap_method);
|
||||
String *f = Getattr(p, typemap_method_name(temp));
|
||||
if (f) {
|
||||
String *fname = Copy(f);
|
||||
Setfile(fname, Getfile(p));
|
||||
|
|
@ -1457,13 +1483,6 @@ static void typemap_emit_code_fragments(const_String_or_char_ptr op, Parm *p) {
|
|||
Delete(temp);
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_typemap_attach_parms()
|
||||
*
|
||||
* Given a parameter list, this function attaches all of the typemaps for a
|
||||
* given typemap type
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static String *typemap_get_option(Hash *tm, const_String_or_char_ptr name) {
|
||||
Parm *kw = Getattr(tm, "kwargs");
|
||||
while (kw) {
|
||||
|
|
@ -1476,7 +1495,23 @@ static String *typemap_get_option(Hash *tm, const_String_or_char_ptr name) {
|
|||
return 0;
|
||||
}
|
||||
|
||||
void Swig_typemap_attach_parms(const_String_or_char_ptr op, ParmList *parms, Wrapper *f) {
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_typemap_attach_parms()
|
||||
*
|
||||
* Given a parameter list, this function attaches all of the typemaps and typemap
|
||||
* attributes to the parameter for each type in the parameter list.
|
||||
*
|
||||
* This function basically provides the typemap code and typemap attribute values as
|
||||
* attributes on each parameter prefixed with "tmap:". For example with tmap_method="in", the typemap
|
||||
* code can be retrieved for the first parameter with a call to Getattr(parm, "tmap:in")
|
||||
* and the "numinputs" attribute can be retrieved with a call to Getattr(parm, "tmap:in:numinputs").
|
||||
*
|
||||
* tmap_method - typemap method, eg "in", "out", "newfree"
|
||||
* parms - parameter list to attach each typemap and all typemap attributes
|
||||
* f - wrapper code to generate into if non null
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
void Swig_typemap_attach_parms(const_String_or_char_ptr tmap_method, ParmList *parms, Wrapper *f) {
|
||||
Parm *p, *firstp;
|
||||
Hash *tm;
|
||||
int nmatch = 0;
|
||||
|
|
@ -1485,21 +1520,21 @@ void Swig_typemap_attach_parms(const_String_or_char_ptr op, ParmList *parms, Wra
|
|||
ParmList *locals;
|
||||
int argnum = 0;
|
||||
char temp[256];
|
||||
char *cop = Char(op);
|
||||
char *cop = Char(tmap_method);
|
||||
String *kwmatch = 0;
|
||||
p = parms;
|
||||
|
||||
#ifdef SWIG_DEBUG
|
||||
Printf(stdout, "Swig_typemap_attach_parms: %s\n", op);
|
||||
Printf(stdout, "Swig_typemap_attach_parms: %s\n", tmap_method);
|
||||
#endif
|
||||
|
||||
while (p) {
|
||||
argnum++;
|
||||
nmatch = 0;
|
||||
#ifdef SWIG_DEBUG
|
||||
Printf(stdout, "parms: %s %s %s\n", op, Getattr(p, "name"), Getattr(p, "type"));
|
||||
Printf(stdout, "parms: %s %s %s\n", tmap_method, Getattr(p, "name"), Getattr(p, "type"));
|
||||
#endif
|
||||
tm = typemap_search_multi(op, p, &nmatch);
|
||||
tm = typemap_search_multi(tmap_method, p, &nmatch);
|
||||
#ifdef SWIG_DEBUG
|
||||
if (tm)
|
||||
Printf(stdout, "found: %s\n", tm);
|
||||
|
|
@ -1605,7 +1640,7 @@ void Swig_typemap_attach_parms(const_String_or_char_ptr op, ParmList *parms, Wra
|
|||
|
||||
if (Checkattr(tm, "type", "SWIGTYPE")) {
|
||||
sprintf(temp, "%s:SWIGTYPE", cop);
|
||||
Setattr(p, tmop_name(temp), "1");
|
||||
Setattr(p, typemap_method_name(temp), "1");
|
||||
}
|
||||
p = nextSibling(p);
|
||||
}
|
||||
|
|
@ -1614,7 +1649,7 @@ void Swig_typemap_attach_parms(const_String_or_char_ptr op, ParmList *parms, Wra
|
|||
typemap_locals(s, locals, f, argnum);
|
||||
}
|
||||
|
||||
replace_embedded_typemap(s);
|
||||
replace_embedded_typemap(s, firstp, f);
|
||||
|
||||
/* Replace the argument number */
|
||||
sprintf(temp, "%d", argnum);
|
||||
|
|
@ -1622,34 +1657,34 @@ void Swig_typemap_attach_parms(const_String_or_char_ptr op, ParmList *parms, Wra
|
|||
|
||||
/* Attach attributes to object */
|
||||
#ifdef SWIG_DEBUG
|
||||
Printf(stdout, "attach: %s %s %s\n", Getattr(firstp, "name"), tmop_name(op), s);
|
||||
Printf(stdout, "attach: %s %s %s\n", Getattr(firstp, "name"), typemap_method_name(tmap_method), s);
|
||||
#endif
|
||||
Setattr(firstp, tmop_name(op), s); /* Code object */
|
||||
Setattr(firstp, typemap_method_name(tmap_method), s); /* Code object */
|
||||
|
||||
if (locals) {
|
||||
sprintf(temp, "%s:locals", cop);
|
||||
Setattr(firstp, tmop_name(temp), locals);
|
||||
Setattr(firstp, typemap_method_name(temp), locals);
|
||||
Delete(locals);
|
||||
}
|
||||
|
||||
/* Attach a link to the next parameter. Needed for multimaps */
|
||||
sprintf(temp, "%s:next", cop);
|
||||
Setattr(firstp, tmop_name(temp), p);
|
||||
Setattr(firstp, typemap_method_name(temp), p);
|
||||
|
||||
/* Attach kwargs */
|
||||
typemap_attach_kwargs(tm, op, firstp);
|
||||
typemap_attach_kwargs(tm, tmap_method, firstp);
|
||||
|
||||
/* Print warnings, if any */
|
||||
typemap_warn(op, firstp);
|
||||
typemap_warn(tmap_method, firstp);
|
||||
|
||||
/* Look for code fragments */
|
||||
typemap_emit_code_fragments(op, firstp);
|
||||
typemap_emit_code_fragments(tmap_method, firstp);
|
||||
|
||||
/* increase argnum to consider numinputs */
|
||||
argnum += nmatch - 1;
|
||||
Delete(s);
|
||||
#ifdef SWIG_DEBUG
|
||||
Printf(stdout, "res: %s %s %s\n", Getattr(firstp, "name"), tmop_name(op), Getattr(firstp, tmop_name(op)));
|
||||
Printf(stdout, "res: %s %s %s\n", Getattr(firstp, "name"), typemap_method_name(tmap_method), Getattr(firstp, typemap_method_name(tmap_method)));
|
||||
#endif
|
||||
|
||||
}
|
||||
|
|
@ -1659,23 +1694,8 @@ void Swig_typemap_attach_parms(const_String_or_char_ptr op, ParmList *parms, Wra
|
|||
|
||||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* split_embedded()
|
||||
*
|
||||
* This function replaces the special variable $typemap(....) with typemap
|
||||
* code. The general form of $typemap is as follows:
|
||||
*
|
||||
* $TYPEMAP(method, $var1=value, $var2=value, $var3=value,...)
|
||||
*
|
||||
* For example:
|
||||
*
|
||||
* $TYPEMAP(in, $1=int x, $input=y, ...)
|
||||
*
|
||||
* Note: this was added as an experiment and could be removed
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
/* Splits the arguments of an embedded typemap */
|
||||
static List *split_embedded(String *s) {
|
||||
static List *split_embedded_typemap(String *s) {
|
||||
List *args = 0;
|
||||
char *c, *start;
|
||||
int level = 0;
|
||||
|
|
@ -1683,6 +1703,7 @@ static List *split_embedded(String *s) {
|
|||
args = NewList();
|
||||
|
||||
c = strchr(Char(s), '(');
|
||||
assert(c);
|
||||
c++;
|
||||
|
||||
start = c;
|
||||
|
|
@ -1723,41 +1744,36 @@ static List *split_embedded(String *s) {
|
|||
return args;
|
||||
}
|
||||
|
||||
static void split_var(String *s, String **name, String **value) {
|
||||
char *eq;
|
||||
char *c;
|
||||
/* -----------------------------------------------------------------------------
|
||||
* replace_embedded_typemap()
|
||||
*
|
||||
* This function replaces the special variable macro $typemap(...) with typemap
|
||||
* code. The general form of $typemap is as follows:
|
||||
*
|
||||
* $typemap(method, typelist, var1=value, var2=value, ...)
|
||||
*
|
||||
* where varx parameters are optional and undocumented; they were used in an earlier version of $typemap.
|
||||
* A search is made using the typemap matching rules of form:
|
||||
*
|
||||
* %typemap(method) typelist {...}
|
||||
*
|
||||
* and if found will substitute in the typemap contents, making appropriate variable replacements.
|
||||
*
|
||||
* For example:
|
||||
* $typemap(in, int) # simple usage matching %typemap(in) int { ... }
|
||||
* $typemap(in, int b) # simple usage matching %typemap(in) int b { ... } or above %typemap
|
||||
* $typemap(in, (Foo<int, bool> a, int b)) # multi-argument typemap matching %typemap(in) (Foo<int, bool> a, int b) {...}
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
eq = strchr(Char(s), '=');
|
||||
if (!eq) {
|
||||
*name = 0;
|
||||
*value = 0;
|
||||
return;
|
||||
}
|
||||
c = Char(s);
|
||||
*name = NewStringWithSize(c, eq - c);
|
||||
|
||||
/* Look for $n variables */
|
||||
if (isdigit((int) *(c))) {
|
||||
/* Parse the value as a type */
|
||||
String *v;
|
||||
Parm *p;
|
||||
v = NewString(eq + 1);
|
||||
p = Swig_cparse_parm(v);
|
||||
Delete(v);
|
||||
*value = p;
|
||||
} else {
|
||||
*value = NewString(eq + 1);
|
||||
}
|
||||
}
|
||||
|
||||
static void replace_embedded_typemap(String *s) {
|
||||
static void replace_embedded_typemap(String *s, ParmList *parm_sublist, Wrapper *f) {
|
||||
char *start = 0;
|
||||
while ((start = strstr(Char(s), "$TYPEMAP("))) {
|
||||
while ((start = strstr(Char(s), "$TYPEMAP("))) { /* note $typemap capitalisation to $TYPEMAP hack */
|
||||
|
||||
/* Gather the argument */
|
||||
/* Gather the parameters */
|
||||
char *end = 0, *c;
|
||||
int level = 0;
|
||||
String *tmp;
|
||||
String *dollar_typemap;
|
||||
int syntax_error = 1;
|
||||
c = start;
|
||||
while (*c) {
|
||||
if (*c == '(')
|
||||
|
|
@ -1772,103 +1788,127 @@ static void replace_embedded_typemap(String *s) {
|
|||
c++;
|
||||
}
|
||||
if (end) {
|
||||
tmp = NewStringWithSize(start, (end - start));
|
||||
dollar_typemap = NewStringWithSize(start, (end - start));
|
||||
syntax_error = 0;
|
||||
} else {
|
||||
tmp = 0;
|
||||
dollar_typemap = NewStringWithSize(start, (c - start));
|
||||
}
|
||||
|
||||
/* Got a substitution. Split it apart into pieces */
|
||||
if (tmp) {
|
||||
if (!syntax_error) {
|
||||
List *l;
|
||||
String *tmap_method;
|
||||
Hash *vars;
|
||||
String *method;
|
||||
int i, ilen;
|
||||
syntax_error = 1;
|
||||
|
||||
l = split_embedded(tmp);
|
||||
vars = NewHash();
|
||||
ilen = Len(l);
|
||||
for (i = 1; i < ilen; i++) {
|
||||
String *n, *v;
|
||||
split_var(Getitem(l, i), &n, &v);
|
||||
if (n && v) {
|
||||
Insert(n, 0, "$");
|
||||
Setattr(vars, n, v);
|
||||
}
|
||||
Delete(n);
|
||||
Delete(v);
|
||||
}
|
||||
/* Split apart each parameter in $typemap(...) */
|
||||
l = split_embedded_typemap(dollar_typemap);
|
||||
|
||||
method = Getitem(l, 0);
|
||||
/* Generate the parameter list for matching typemaps */
|
||||
if (Len(l) >= 2) {
|
||||
ParmList *to_match_parms;
|
||||
tmap_method = Getitem(l, 0);
|
||||
|
||||
{
|
||||
Parm *p = 0;
|
||||
Parm *first = 0;
|
||||
char temp[32];
|
||||
int n = 1;
|
||||
while (1) {
|
||||
Hash *v;
|
||||
sprintf(temp, "$%d", n);
|
||||
v = Getattr(vars, temp);
|
||||
if (v) {
|
||||
if (p) {
|
||||
set_nextSibling(p, v);
|
||||
set_previousSibling(v, p);
|
||||
/* the second parameter might contain multiple sub-parameters for multi-argument
|
||||
* typemap matching, so split these parameters apart */
|
||||
to_match_parms = Swig_cparse_parms(Getitem(l, 1));
|
||||
if (to_match_parms) {
|
||||
Parm *p = to_match_parms;
|
||||
Parm *sub_p = parm_sublist;
|
||||
String *empty_string = NewStringEmpty();
|
||||
String *lname = empty_string;
|
||||
while (p) {
|
||||
if (sub_p) {
|
||||
lname = Getattr(sub_p, "lname");
|
||||
sub_p = nextSibling(sub_p);
|
||||
}
|
||||
p = v;
|
||||
Setattr(p, "lname", Getattr(p, "name"));
|
||||
if (Getattr(p, "value")) {
|
||||
Setattr(p, "name", Getattr(p, "value"));
|
||||
}
|
||||
if (!first)
|
||||
first = p;
|
||||
DohIncref(p);
|
||||
Delattr(vars, temp);
|
||||
} else {
|
||||
break;
|
||||
Setattr(p, "lname", lname);
|
||||
p = nextSibling(p);
|
||||
}
|
||||
n++;
|
||||
Delete(empty_string);
|
||||
}
|
||||
|
||||
/* process optional extra parameters - the variable replacements (undocumented) */
|
||||
vars = NewHash();
|
||||
{
|
||||
int i, ilen;
|
||||
ilen = Len(l);
|
||||
for (i = 2; i < ilen; i++) {
|
||||
String *parm = Getitem(l, i);
|
||||
char *eq = strchr(Char(parm), '=');
|
||||
char *c = Char(parm);
|
||||
if (eq && (eq - c > 0)) {
|
||||
String *name = NewStringWithSize(c, eq - c);
|
||||
String *value = NewString(eq + 1);
|
||||
Insert(name, 0, "$");
|
||||
Setattr(vars, name, value);
|
||||
} else {
|
||||
to_match_parms = 0; /* error - variable replacement parameters must be of form varname=value */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Perform a typemap search */
|
||||
if (first) {
|
||||
if (to_match_parms) {
|
||||
static int already_substituting = 0;
|
||||
String *tm;
|
||||
String *attr;
|
||||
int match = 0;
|
||||
#ifdef SWIG_DEBUG
|
||||
Printf(stdout, "Swig_typemap_attach_parms: embedded\n");
|
||||
#endif
|
||||
Swig_typemap_attach_parms(method, first, 0);
|
||||
{
|
||||
String *tm;
|
||||
int match = 0;
|
||||
char attr[64];
|
||||
sprintf(attr, "tmap:%s", Char(method));
|
||||
if (!already_substituting) {
|
||||
already_substituting = 1;
|
||||
Swig_typemap_attach_parms(tmap_method, to_match_parms, f);
|
||||
already_substituting = 0;
|
||||
|
||||
/* Look for the typemap code */
|
||||
tm = Getattr(first, attr);
|
||||
attr = NewStringf("tmap:%s", tmap_method);
|
||||
tm = Getattr(to_match_parms, attr);
|
||||
if (tm) {
|
||||
sprintf(attr, "tmap:%s:next", Char(method));
|
||||
if (!Getattr(first, attr)) {
|
||||
/* Should be no more matches. Hack??? */
|
||||
/* Replace all of the remaining variables */
|
||||
Printf(attr, "%s", ":next");
|
||||
/* fail if multi-argument lookup requested in $typemap(...) and the lookup failed */
|
||||
if (!Getattr(to_match_parms, attr)) {
|
||||
/* Replace parameter variables */
|
||||
Iterator ki;
|
||||
for (ki = First(vars); ki.key; ki = Next(ki)) {
|
||||
Replace(tm, ki.key, ki.item, DOH_REPLACE_ANY);
|
||||
}
|
||||
/* Do the replacement */
|
||||
Replace(s, tmp, tm, DOH_REPLACE_ANY);
|
||||
/* offer the target language module the chance to make special variable substitutions */
|
||||
Language_replace_special_variables(tmap_method, tm, to_match_parms);
|
||||
/* finish up - do the substitution */
|
||||
Replace(s, dollar_typemap, tm, DOH_REPLACE_ANY);
|
||||
Delete(tm);
|
||||
match = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (!match) {
|
||||
Swig_error(Getfile(s), Getline(s), "No typemap found for %s\n", tmp);
|
||||
String *dtypemap = NewString(dollar_typemap);
|
||||
Replaceall(dtypemap, "$TYPEMAP", "$typemap");
|
||||
Swig_error(Getfile(s), Getline(s), "No typemap found for %s\n", dtypemap);
|
||||
Delete(dtypemap);
|
||||
}
|
||||
Delete(attr);
|
||||
} else {
|
||||
/* simple recursive call check, but prevents using an embedded typemap that contains another embedded typemap */
|
||||
String *dtypemap = NewString(dollar_typemap);
|
||||
Replaceall(dtypemap, "$TYPEMAP", "$typemap");
|
||||
Swig_error(Getfile(s), Getline(s), "Recursive $typemap calls not supported - %s\n", dtypemap);
|
||||
Delete(dtypemap);
|
||||
}
|
||||
syntax_error = 0;
|
||||
}
|
||||
Delete(vars);
|
||||
}
|
||||
Replace(s, tmp, "<embedded typemap>", DOH_REPLACE_ANY);
|
||||
Delete(vars);
|
||||
Delete(tmp);
|
||||
Delete(l);
|
||||
}
|
||||
if (syntax_error) {
|
||||
String *dtypemap = NewString(dollar_typemap);
|
||||
Replaceall(dtypemap, "$TYPEMAP", "$typemap");
|
||||
Swig_error(Getfile(s), Getline(s), "Syntax error in: %s\n", dtypemap);
|
||||
Delete(dtypemap);
|
||||
}
|
||||
Replace(s, dollar_typemap, "<error in embedded typemap>", DOH_REPLACE_ANY);
|
||||
Delete(dollar_typemap);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue