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; } decl;
Parm *tparms; Parm *tparms;
struct { struct {
String *op; String *method;
Hash *kwargs; Hash *kwargs;
} tmap; } tmap;
struct { struct {
@ -2499,10 +2499,10 @@ varargs_parms : parms { $$ = $1; }
typemap_directive : TYPEMAP LPAREN typemap_type RPAREN tm_list stringbrace { typemap_directive : TYPEMAP LPAREN typemap_type RPAREN tm_list stringbrace {
$$ = 0; $$ = 0;
if ($3.op) { if ($3.method) {
String *code = 0; String *code = 0;
$$ = new_node("typemap"); $$ = new_node("typemap");
Setattr($$,"method",$3.op); Setattr($$,"method",$3.method);
if ($3.kwargs) { if ($3.kwargs) {
ParmList *kw = $3.kwargs; ParmList *kw = $3.kwargs;
code = remove_block(kw, $6); 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 { | TYPEMAP LPAREN typemap_type RPAREN tm_list SEMI {
$$ = 0; $$ = 0;
if ($3.op) { if ($3.method) {
$$ = new_node("typemap"); $$ = new_node("typemap");
Setattr($$,"method",$3.op); Setattr($$,"method",$3.method);
appendChild($$,$5); appendChild($$,$5);
} }
} }
| TYPEMAP LPAREN typemap_type RPAREN tm_list EQUAL typemap_parm SEMI { | TYPEMAP LPAREN typemap_type RPAREN tm_list EQUAL typemap_parm SEMI {
$$ = 0; $$ = 0;
if ($3.op) { if ($3.method) {
$$ = new_node("typemapcopy"); $$ = new_node("typemapcopy");
Setattr($$,"method",$3.op); Setattr($$,"method",$3.method);
Setattr($$,"pattern", Getattr($7,"pattern")); Setattr($$,"pattern", Getattr($7,"pattern"));
appendChild($$,$5); appendChild($$,$5);
} }
@ -2546,15 +2546,15 @@ typemap_type : kwargs {
/* two argument typemap form */ /* two argument typemap form */
name = Getattr($1,"name"); name = Getattr($1,"name");
if (!name || (Strcmp(name,typemap_lang))) { if (!name || (Strcmp(name,typemap_lang))) {
$$.op = 0; $$.method = 0;
$$.kwargs = 0; $$.kwargs = 0;
} else { } else {
$$.op = Getattr(p,"name"); $$.method = Getattr(p,"name");
$$.kwargs = nextSibling(p); $$.kwargs = nextSibling(p);
} }
} else { } else {
/* one-argument typemap-form */ /* one-argument typemap-form */
$$.op = Getattr($1,"name"); $$.method = Getattr($1,"name");
$$.kwargs = p; $$.kwargs = p;
} }
} }

View file

@ -3039,7 +3039,7 @@ public:
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
* typemapLookup() * typemapLookup()
* n - for input only and must contain info for Getfile(n) and Getline(n) to work * 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 * type - typemap type to lookup
* warning - warning number to issue if no typemaps found * warning - warning number to issue if no typemaps found
* typemap_attributes - the typemap attributes are attached to this node and will * 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() * 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; Node *node = !typemap_attributes ? NewHash() : typemap_attributes;
Setattr(node, "type", type); Setattr(node, "type", type);
Setfile(node, Getfile(n)); Setfile(node, Getfile(n));
Setline(node, Getline(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) { if (!tm) {
tm = empty_string; tm = empty_string;
if (warning != WARN_NONE) 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) if (!typemap_attributes)
Delete(node); Delete(node);

View file

@ -2872,7 +2872,7 @@ public:
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
* typemapLookup() * typemapLookup()
* n - for input only and must contain info for Getfile(n) and Getline(n) to work * 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 * type - typemap type to lookup
* warning - warning number to issue if no typemaps found * warning - warning number to issue if no typemaps found
* typemap_attributes - the typemap attributes are attached to this node and will * 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() * 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; Node *node = !typemap_attributes ? NewHash() : typemap_attributes;
Setattr(node, "type", type); Setattr(node, "type", type);
Setfile(node, Getfile(n)); Setfile(node, Getfile(n));
Setline(node, Getline(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) { if (!tm) {
tm = empty_string; tm = empty_string;
if (warning != WARN_NONE) 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) if (!typemap_attributes)
Delete(node); Delete(node);

View file

@ -3818,7 +3818,7 @@ MODULA3():
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
* typemapLookup() * typemapLookup()
* n - for input only and must contain info for Getfile(n) and Getline(n) to work * 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 * type - typemap type to lookup
* warning - warning number to issue if no typemaps found * warning - warning number to issue if no typemaps found
* typemap_attributes - the typemap attributes are attached to this node and will * 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() * 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; Node *node = !typemap_attributes ? NewHash() : typemap_attributes;
Setattr(node, "type", type); Setattr(node, "type", type);
Setfile(node, Getfile(n)); Setfile(node, Getfile(n));
Setline(node, Getline(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) { if (!tm) {
tm = empty_string; tm = empty_string;
if (warning != WARN_NONE) 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) if (!typemap_attributes)
Delete(node); Delete(node);

View file

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

View file

@ -363,19 +363,19 @@ extern int ParmList_is_compactdefargs(ParmList *p);
/* --- Legacy Typemap API (somewhat simplified, ha!) --- */ /* --- Legacy Typemap API (somewhat simplified, ha!) --- */
extern void Swig_typemap_init(void); 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 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 op, ParmList *srcpattern, ParmList *pattern); 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 op, 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 int Swig_typemap_apply(ParmList *srcpat, ParmList *destpat);
extern void Swig_typemap_clear_apply(ParmList *pattern); extern void Swig_typemap_clear_apply(ParmList *pattern);
extern void Swig_typemap_debug(void); 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(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 op, Node *n, const_String_or_char_ptr lname, Wrapper *f, String *actioncode); 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 void Swig_typemap_new_scope(void);
extern Hash *Swig_typemap_pop_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 --- */ /* --- Code fragment support --- */

View file

@ -117,29 +117,29 @@ void Swig_typemap_init() {
tm_scope = 0; 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; static Hash *names = 0;
String *s; String *s;
/* Due to "interesting" object-identity semantics of DOH, /* Due to "interesting" object-identity semantics of DOH,
we have to make sure that we only intern strings without object we have to make sure that we only intern strings without object
identity into the hash table. identity into the hash table.
(typemap_attach_kwargs calls tmop_name several times with (typemap_attach_kwargs calls typemap_method_name several times with
the "same" String *op (i.e., same object identity) but differing the "same" String *tmap_method (i.e., same object identity) but differing
string values.) string values.)
Most other callers work around this by using char* rather than Most other callers work around this by using char* rather than
String *. String *.
-- mkoeppe, Jun 17, 2003 -- mkoeppe, Jun 17, 2003
*/ */
const char *op_without_object_identity = Char(op); const char *method_without_object_identity = Char(tmap_method);
if (!names) if (!names)
names = NewHash(); names = NewHash();
s = Getattr(names, op_without_object_identity); s = Getattr(names, method_without_object_identity);
if (s) if (s)
return s; return s;
s = NewStringf("tmap:%s", op); s = NewStringf("tmap:%s", tmap_method);
Setattr(names, op_without_object_identity, s); Setattr(names, method_without_object_identity, s);
Delete(s); Delete(s);
return s; return s;
} }
@ -176,18 +176,18 @@ Hash *Swig_typemap_pop_scope() {
* Add a new multi-argument 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 *tm;
Hash *tm1; Hash *tm1;
Hash *tm2; Hash *tm2;
Parm *np; Parm *np;
String *tmop; String *tm_method;
SwigType *type; SwigType *type;
String *pname; String *pname;
if (!parms) if (!parms)
return; return;
tmop = tmop_name(op); tm_method = typemap_method_name(tmap_method);
/* Register the first type in the parameter list */ /* 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; tm = tm1;
} }
/* Now see if this typemap op has been seen before */ /* Now see if this typemap method has been seen before */
tm2 = Getattr(tm, tmop); tm2 = Getattr(tm, tm_method);
if (!tm2) { if (!tm2) {
tm2 = NewHash(); tm2 = NewHash();
Setattr(tm, tmop, tm2); Setattr(tm, tm_method, tm2);
Delete(tm2); Delete(tm2);
} }
@ -247,7 +247,7 @@ void Swig_typemap_register(const_String_or_char_ptr op, ParmList *parms, const_S
np = nextSibling(parms); np = nextSibling(parms);
if (np) { if (np) {
/* Make an entirely new operator key */ /* 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 */ /* Now reregister on the remaining arguments */
Swig_typemap_register(newop, np, code, locals, kwargs); 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); Delete(newop);
} else { } else {
String *str = SwigType_str(type, pname); 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 *clocals = CopyParmList(locals);
ParmList *ckwargs = CopyParmList(kwargs); 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 * 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; Hash *tm = 0;
String *tmop; String *tm_method;
Parm *p; Parm *p;
String *pname; String *pname;
SwigType *ptype; SwigType *ptype;
int ts = tm_scope; int ts = tm_scope;
String *tmops, *newop; String *tm_methods, *newop;
if (ParmList_len(parms) != ParmList_len(srcparms)) if (ParmList_len(parms) != ParmList_len(srcparms))
return -1; return -1;
tmop = tmop_name(op); tm_method = typemap_method_name(tmap_method);
while (ts >= 0) { while (ts >= 0) {
p = srcparms; p = srcparms;
tmops = NewString(tmop); tm_methods = NewString(tm_method);
while (p) { while (p) {
ptype = Getattr(p, "type"); ptype = Getattr(p, "type");
pname = Getattr(p, "name"); pname = Getattr(p, "name");
@ -328,22 +328,22 @@ int Swig_typemap_copy(const_String_or_char_ptr op, ParmList *srcparms, ParmList
if (!tm) if (!tm)
break; break;
tm = Getattr(tm, tmops); tm = Getattr(tm, tm_methods);
if (!tm) if (!tm)
break; break;
/* Got a match. Look for next typemap */ /* Got a match. Look for next typemap */
newop = NewStringf("%s-%s+%s:", tmops, ptype, pname); newop = NewStringf("%s-%s+%s:", tm_methods, ptype, pname);
Delete(tmops); Delete(tm_methods);
tmops = newop; tm_methods = newop;
p = nextSibling(p); p = nextSibling(p);
} }
Delete(tmops); Delete(tm_methods);
if (!p && tm) { if (!p && tm) {
/* Got some kind of match */ /* 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; return 0;
} }
ts--; ts--;
@ -359,7 +359,7 @@ int Swig_typemap_copy(const_String_or_char_ptr op, ParmList *srcparms, ParmList
* Delete a multi-argument 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; SwigType *type;
String *name; String *name;
Parm *p; Parm *p;
@ -367,7 +367,7 @@ void Swig_typemap_clear(const_String_or_char_ptr op, ParmList *parms) {
Hash *tm = 0; Hash *tm = 0;
/* This might not work */ /* This might not work */
newop = NewString(op); newop = NewString(tmap_method);
p = parms; p = parms;
while (p) { while (p) {
type = Getattr(p, "type"); 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); Printf(newop, "-%s+%s:", type, name);
} }
if (tm) { if (tm) {
tm = Getattr(tm, tmop_name(newop)); tm = Getattr(tm, typemap_method_name(newop));
if (tm) { if (tm) {
Delattr(tm, "code"); Delattr(tm, "code");
Delattr(tm, "locals"); Delattr(tm, "locals");
@ -601,7 +601,7 @@ static SwigType *strip_arrays(SwigType *type) {
* that includes a 'code' attribute. * 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 *result = 0, *tm, *tm1, *tma;
Hash *backup = 0; Hash *backup = 0;
SwigType *noarrays = 0; SwigType *noarrays = 0;
@ -611,7 +611,7 @@ static Hash *typemap_search(const_String_or_char_ptr op, SwigType *type, const_S
int isarray; int isarray;
const String *cname = 0; const String *cname = 0;
SwigType *unstripped = 0; SwigType *unstripped = 0;
String *tmop = tmop_name(op); String *tm_method = typemap_method_name(tmap_method);
if ((name) && Len(name)) if ((name) && Len(name))
cname = name; cname = name;
@ -625,7 +625,7 @@ static Hash *typemap_search(const_String_or_char_ptr op, SwigType *type, const_S
if (tm && cname) { if (tm && cname) {
tm1 = Getattr(tm, cname); tm1 = Getattr(tm, cname);
if (tm1) { 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")) if (result && Getattr(result, "code"))
goto ret_result; goto ret_result;
if (result) if (result)
@ -633,7 +633,7 @@ static Hash *typemap_search(const_String_or_char_ptr op, SwigType *type, const_S
} }
} }
if (tm) { 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")) if (result && Getattr(result, "code"))
goto ret_result; goto ret_result;
if (result) if (result)
@ -650,7 +650,7 @@ static Hash *typemap_search(const_String_or_char_ptr op, SwigType *type, const_S
if (tma && cname) { if (tma && cname) {
tm1 = Getattr(tma, cname); tm1 = Getattr(tma, cname);
if (tm1) { if (tm1) {
result = Getattr(tm1, tmop); /* type-name match */ result = Getattr(tm1, tm_method); /* type-name match */
if (result && Getattr(result, "code")) if (result && Getattr(result, "code"))
goto ret_result; goto ret_result;
if (result) if (result)
@ -658,7 +658,7 @@ static Hash *typemap_search(const_String_or_char_ptr op, SwigType *type, const_S
} }
} }
if (tma) { if (tma) {
result = Getattr(tma, tmop); /* type match */ result = Getattr(tma, tm_method); /* type match */
if (result && Getattr(result, "code")) if (result && Getattr(result, "code"))
goto ret_result; goto ret_result;
if (result) if (result)
@ -702,13 +702,13 @@ static Hash *typemap_search(const_String_or_char_ptr op, SwigType *type, const_S
if (tm && cname) { if (tm && cname) {
tm1 = Getattr(tm, cname); tm1 = Getattr(tm, cname);
if (tm1) { 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) if (result)
goto ret_result; goto ret_result;
} }
} }
if (tm) { /* See if there is simply a type match */ if (tm) { /* See if there is simply a type match */
result = Getattr(tm, tmop); result = Getattr(tm, tm_method);
if (result) if (result)
goto ret_result; goto ret_result;
} }
@ -748,7 +748,7 @@ ret_result:
* Search for a multi-argument 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 *type;
SwigType *mtype = 0; SwigType *mtype = 0;
String *name; String *name;
@ -763,13 +763,13 @@ static Hash *typemap_search_multi(const_String_or_char_ptr op, ParmList *parms,
name = Getattr(parms, "name"); name = Getattr(parms, "name");
/* Try to find a match on the first type */ /* 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 (tm) {
if (mtype && SwigType_isarray(mtype)) { if (mtype && SwigType_isarray(mtype)) {
Setattr(parms, "tmap:match", mtype); Setattr(parms, "tmap:match", mtype);
} }
Delete(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); tm1 = typemap_search_multi(newop, nextSibling(parms), nmatch);
if (tm1) if (tm1)
tm = 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. * 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 * 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 * 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"). * "noblock" attribute can be retrieved with a call to Getattr(node, "tmap:in:noblock").
* *
* op - typemap method, eg "in", "out", "newfree" * tmap_method - typemap method, eg "in", "out", "newfree"
* node - the node to attach the typemap and typemap attributes to * node - the node to attach the typemap and typemap attributes to
* lname - name of variable to substitute $1, $2 etc for * lname - name of variable to substitute $1, $2 etc for
* f - wrapper code to generate into if non null * f - wrapper code to generate into if non null
* actioncode - code to generate into f before the out typemap code, unless * actioncode - code to generate into f before the out typemap code, unless
* the optimal attribute is set in the out typemap in which case * 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. * $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 *type;
SwigType *mtype = 0; SwigType *mtype = 0;
String *pname; String *pname;
@ -1204,14 +1204,14 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr op, Node *node,
String *symname; String *symname;
String *cname = 0; String *cname = 0;
String *clname = 0; String *clname = 0;
char *cop = Char(op); char *cop = Char(tmap_method);
int optimal_attribute = 0; int optimal_attribute = 0;
int optimal_substitution = 0; int optimal_substitution = 0;
int num_substitutions = 0; int num_substitutions = 0;
/* special case, we need to check for 'ref' call /* special case, we need to check for 'ref' call
and set the default code 'sdef' */ 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); 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; String *qsn = st ? Swig_symbol_string_qualify(pname, st) : 0;
if (qsn) { if (qsn) {
if (Len(qsn) && !Equal(qsn, pname)) { 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"))) { if (tm && (!Getattr(tm, "pname") || strstr(Char(Getattr(tm, "type")), "SWIGTYPE"))) {
tm = 0; tm = 0;
} }
@ -1244,7 +1244,7 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr op, Node *node,
} }
if (!tm) if (!tm)
#endif #endif
tm = typemap_search(op, type, pname, &mtype); tm = typemap_search(tmap_method, type, pname, &mtype);
if (!tm) if (!tm)
return sdef; return sdef;
@ -1270,7 +1270,7 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr op, Node *node,
Delete(mangle); Delete(mangle);
} }
sprintf(temp, "%s:%s", cop, ckwname); 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) if (Cmp(temp, "out:optimal") == 0)
optimal_attribute = (Cmp(value, "0") != 0) ? 1 : 0; optimal_attribute = (Cmp(value, "0") != 0) ? 1 : 0;
Delete(value); 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); Replace(s, "$symname", symname, DOH_REPLACE_ANY);
} }
Setattr(node, tmop_name(op), s); Setattr(node, typemap_method_name(tmap_method), s);
if (locals) { if (locals) {
sprintf(temp, "%s:locals", cop); sprintf(temp, "%s:locals", cop);
Setattr(node, tmop_name(temp), locals); Setattr(node, typemap_method_name(temp), locals);
Delete(locals); Delete(locals);
} }
if (Checkattr(tm, "type", "SWIGTYPE")) { if (Checkattr(tm, "type", "SWIGTYPE")) {
sprintf(temp, "%s:SWIGTYPE", cop); sprintf(temp, "%s:SWIGTYPE", cop);
Setattr(node, tmop_name(temp), "1"); Setattr(node, typemap_method_name(temp), "1");
} }
/* Look for warnings */ /* Look for warnings */
{ {
String *w; String *w;
sprintf(temp, "%s:warning", cop); sprintf(temp, "%s:warning", cop);
w = Getattr(node, tmop_name(temp)); w = Getattr(node, typemap_method_name(temp));
if (w) { if (w) {
Swig_warning(0, Getfile(node), Getline(node), "%s\n", 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; String *fragment;
sprintf(temp, "%s:fragment", cop); sprintf(temp, "%s:fragment", cop);
fragment = Getattr(node, tmop_name(temp)); fragment = Getattr(node, typemap_method_name(temp));
if (fragment) { if (fragment) {
String *fname = Copy(fragment); String *fname = Copy(fragment);
Setfile(fname, Getfile(node)); Setfile(fname, Getfile(node));
@ -1402,14 +1402,14 @@ static String *Swig_typemap_lookup_impl(const_String_or_char_ptr op, Node *node,
return s; 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(actioncode);
assert(Cmp(op, "out") == 0); assert(Cmp(tmap_method, "out") == 0);
return Swig_typemap_lookup_impl(op, node, lname, f, actioncode); 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) { 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(op, node, lname, f, 0); 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. * 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(); String *temp = NewStringEmpty();
Parm *kw = Getattr(tm, "kwargs"); Parm *kw = Getattr(tm, "kwargs");
while (kw) { while (kw) {
@ -1437,36 +1437,36 @@ static void typemap_attach_kwargs(Hash *tm, const_String_or_char_ptr op, Parm *p
value = v; value = v;
} }
Clear(temp); Clear(temp);
Printf(temp, "%s:%s", op, Getattr(kw, "name")); Printf(temp, "%s:%s", tmap_method, Getattr(kw, "name"));
Setattr(p, tmop_name(temp), value); Setattr(p, typemap_method_name(temp), value);
Delete(value); Delete(value);
kw = nextSibling(kw); kw = nextSibling(kw);
} }
Clear(temp); Clear(temp);
Printf(temp, "%s:match_type", op); Printf(temp, "%s:match_type", tmap_method);
Setattr(p, tmop_name(temp), Getattr(tm, "type")); Setattr(p, typemap_method_name(temp), Getattr(tm, "type"));
Delete(temp); Delete(temp);
} }
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
* typemap_warn() * 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. * attribute, print that warning message.
* ----------------------------------------------------------------------------- */ * ----------------------------------------------------------------------------- */
static void typemap_warn(const_String_or_char_ptr op, Parm *p) { static void typemap_warn(const_String_or_char_ptr tmap_method, Parm *p) {
String *temp = NewStringf("%s:warning", op); String *temp = NewStringf("%s:warning", tmap_method);
String *w = Getattr(p, tmop_name(temp)); String *w = Getattr(p, typemap_method_name(temp));
Delete(temp); Delete(temp);
if (w) { if (w) {
Swig_warning(0, Getfile(p), Getline(p), "%s\n", 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) { static void typemap_emit_code_fragments(const_String_or_char_ptr tmap_method, Parm *p) {
String *temp = NewStringf("%s:fragment", op); String *temp = NewStringf("%s:fragment", tmap_method);
String *f = Getattr(p, tmop_name(temp)); String *f = Getattr(p, typemap_method_name(temp));
if (f) { if (f) {
String *fname = Copy(f); String *fname = Copy(f);
Setfile(fname, Getfile(p)); 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. * attributes to the parameter for each type in the parameter list.
* *
* This function basically provides the typemap code and typemap attribute values as * 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") * 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"). * and the "numinputs" attribute can be retrieved with a call to Getattr(parm, "tmap:in:numinputs").
* *
* op - typemap method, eg "in", "out", "newfree" * tmap_method - typemap method, eg "in", "out", "newfree"
* parms - parameter list to attach each typemap and all typemap attributes * parms - parameter list to attach each typemap and all typemap attributes
* f - wrapper code to generate into if non null * 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; Parm *p, *firstp;
Hash *tm; Hash *tm;
int nmatch = 0; int nmatch = 0;
@ -1514,21 +1514,21 @@ void Swig_typemap_attach_parms(const_String_or_char_ptr op, ParmList *parms, Wra
ParmList *locals; ParmList *locals;
int argnum = 0; int argnum = 0;
char temp[256]; char temp[256];
char *cop = Char(op); char *cop = Char(tmap_method);
String *kwmatch = 0; String *kwmatch = 0;
p = parms; p = parms;
#ifdef SWIG_DEBUG #ifdef SWIG_DEBUG
Printf(stdout, "Swig_typemap_attach_parms: %s\n", op); Printf(stdout, "Swig_typemap_attach_parms: %s\n", tmap_method);
#endif #endif
while (p) { while (p) {
argnum++; argnum++;
nmatch = 0; nmatch = 0;
#ifdef SWIG_DEBUG #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 #endif
tm = typemap_search_multi(op, p, &nmatch); tm = typemap_search_multi(tmap_method, p, &nmatch);
#ifdef SWIG_DEBUG #ifdef SWIG_DEBUG
if (tm) if (tm)
Printf(stdout, "found: %s\n", 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")) { if (Checkattr(tm, "type", "SWIGTYPE")) {
sprintf(temp, "%s:SWIGTYPE", cop); sprintf(temp, "%s:SWIGTYPE", cop);
Setattr(p, tmop_name(temp), "1"); Setattr(p, typemap_method_name(temp), "1");
} }
p = nextSibling(p); 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 */ /* Attach attributes to object */
#ifdef SWIG_DEBUG #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 #endif
Setattr(firstp, tmop_name(op), s); /* Code object */ Setattr(firstp, typemap_method_name(tmap_method), s); /* Code object */
if (locals) { if (locals) {
sprintf(temp, "%s:locals", cop); sprintf(temp, "%s:locals", cop);
Setattr(firstp, tmop_name(temp), locals); Setattr(firstp, typemap_method_name(temp), locals);
Delete(locals); Delete(locals);
} }
/* Attach a link to the next parameter. Needed for multimaps */ /* Attach a link to the next parameter. Needed for multimaps */
sprintf(temp, "%s:next", cop); sprintf(temp, "%s:next", cop);
Setattr(firstp, tmop_name(temp), p); Setattr(firstp, typemap_method_name(temp), p);
/* Attach kwargs */ /* Attach kwargs */
typemap_attach_kwargs(tm, op, firstp); typemap_attach_kwargs(tm, tmap_method, firstp);
/* Print warnings, if any */ /* Print warnings, if any */
typemap_warn(op, firstp); typemap_warn(tmap_method, firstp);
/* Look for code fragments */ /* Look for code fragments */
typemap_emit_code_fragments(op, firstp); typemap_emit_code_fragments(tmap_method, firstp);
/* increase argnum to consider numinputs */ /* increase argnum to consider numinputs */
argnum += nmatch - 1; argnum += nmatch - 1;
Delete(s); Delete(s);
#ifdef SWIG_DEBUG #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 #endif
} }
@ -1790,7 +1790,7 @@ static void replace_embedded_typemap(String *s, String *lname, Wrapper *f) {
if (!syntax_error) { if (!syntax_error) {
List *l; List *l;
String *op; String *tmap_method;
Hash *vars; Hash *vars;
syntax_error = 1; syntax_error = 1;
@ -1799,7 +1799,7 @@ static void replace_embedded_typemap(String *s, String *lname, Wrapper *f) {
if (Len(l) >= 2) { if (Len(l) >= 2) {
ParmList *to_match_parms; ParmList *to_match_parms;
op = Getitem(l, 0); tmap_method = Getitem(l, 0);
/* the second parameter might contain multiple sub-parameters for multi-argument /* the second parameter might contain multiple sub-parameters for multi-argument
* typemap matching, so split these parameters apart */ * typemap matching, so split these parameters apart */
@ -1843,11 +1843,11 @@ static void replace_embedded_typemap(String *s, String *lname, Wrapper *f) {
#endif #endif
if (!already_substituting) { if (!already_substituting) {
already_substituting = 1; 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; already_substituting = 0;
/* Look for the typemap code */ /* Look for the typemap code */
attr = NewStringf("tmap:%s", op); attr = NewStringf("tmap:%s", tmap_method);
tm = Getattr(to_match_parms, attr); tm = Getattr(to_match_parms, attr);
if (tm) { if (tm) {
Printf(attr, "%s", ":next"); 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); Replace(tm, ki.key, ki.item, DOH_REPLACE_ANY);
} }
/* offer the target language module the chance to make special variable substitutions */ /* 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 */ /* finish up - do the substitution */
Replace(s, dollar_typemap, tm, DOH_REPLACE_ANY); Replace(s, dollar_typemap, tm, DOH_REPLACE_ANY);
Delete(tm); Delete(tm);