typemap method name: use consistent terminology in code

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@11473 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2009-07-30 06:06:49 +00:00
commit 7f0e632ddd
7 changed files with 127 additions and 127 deletions

View file

@ -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;
}
}

View file

@ -3039,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
@ -3047,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);

View file

@ -2872,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
@ -2880,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);

View file

@ -3818,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
@ -3826,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);

View file

@ -2196,8 +2196,8 @@ public:
return NewStringEmpty();
}
String *PhpTypeFromTypemap(char *op, Node *n, const_String_or_char_ptr lname) {
String *tms = Swig_typemap_lookup(op, n, lname, 0);
String *PhpTypeFromTypemap(char *tmap_method, Node *n, const_String_or_char_ptr lname) {
String *tms = Swig_typemap_lookup(tmap_method, n, lname, 0);
if (!tms)
return 0;
else

View file

@ -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 --- */

View file

@ -117,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;
}
@ -176,18 +176,18 @@ Hash *Swig_typemap_pop_scope() {
* 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 */
@ -212,11 +212,11 @@ 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);
}
@ -247,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);
@ -255,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);
@ -304,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");
@ -328,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--;
@ -359,7 +359,7 @@ int Swig_typemap_copy(const_String_or_char_ptr op, ParmList *srcparms, ParmList
* 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;
@ -367,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");
@ -380,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");
@ -601,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;
@ -611,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;
@ -625,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)
@ -633,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)
@ -650,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)
@ -658,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)
@ -702,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;
}
@ -748,7 +748,7 @@ ret_result:
* 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;
@ -763,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;
@ -1178,20 +1178,20 @@ static void typemap_locals(DOHString * s, ParmList *l, Wrapper *f, int argnum) {
*
* 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 op="in", the typemap code can be retrieved
* 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").
*
* op - 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
* 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;
@ -1204,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);
}
@ -1234,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;
}
@ -1244,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;
@ -1270,7 +1270,7 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr op, Node *node,
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);
@ -1353,23 +1353,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);
}
@ -1379,7 +1379,7 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr op, Node *node,
{
String *fragment;
sprintf(temp, "%s:fragment", cop);
fragment = Getattr(node, tmop_name(temp));
fragment = Getattr(node, typemap_method_name(temp));
if (fragment) {
String *fname = Copy(fragment);
Setfile(fname, Getfile(node));
@ -1402,14 +1402,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);
}
/* -----------------------------------------------------------------------------
@ -1423,7 +1423,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) {
@ -1437,36 +1437,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));
@ -1496,16 +1496,16 @@ static String *typemap_get_option(Hash *tm, const_String_or_char_ptr name) {
* 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 op="in", the typemap
* 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").
*
* op - 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
* 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 op, ParmList *parms, Wrapper *f) {
void Swig_typemap_attach_parms(const_String_or_char_ptr tmap_method, ParmList *parms, Wrapper *f) {
Parm *p, *firstp;
Hash *tm;
int nmatch = 0;
@ -1514,21 +1514,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);
@ -1634,7 +1634,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);
}
@ -1651,34 +1651,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
}
@ -1790,7 +1790,7 @@ static void replace_embedded_typemap(String *s, String *lname, Wrapper *f) {
if (!syntax_error) {
List *l;
String *op;
String *tmap_method;
Hash *vars;
syntax_error = 1;
@ -1799,7 +1799,7 @@ static void replace_embedded_typemap(String *s, String *lname, Wrapper *f) {
if (Len(l) >= 2) {
ParmList *to_match_parms;
op = Getitem(l, 0);
tmap_method = Getitem(l, 0);
/* the second parameter might contain multiple sub-parameters for multi-argument
* typemap matching, so split these parameters apart */
@ -1843,11 +1843,11 @@ static void replace_embedded_typemap(String *s, String *lname, Wrapper *f) {
#endif
if (!already_substituting) {
already_substituting = 1;
Swig_typemap_attach_parms(op, to_match_parms, f);
Swig_typemap_attach_parms(tmap_method, to_match_parms, f);
already_substituting = 0;
/* Look for the typemap code */
attr = NewStringf("tmap:%s", op);
attr = NewStringf("tmap:%s", tmap_method);
tm = Getattr(to_match_parms, attr);
if (tm) {
Printf(attr, "%s", ":next");
@ -1859,7 +1859,7 @@ static void replace_embedded_typemap(String *s, String *lname, Wrapper *f) {
Replace(tm, ki.key, ki.item, DOH_REPLACE_ANY);
}
/* offer the target language module the chance to make special variable substitutions */
Language_replace_special_variables(op, tm, to_match_parms);
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);