preassert-postassert patch.

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@4680 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Dave Beazley 2003-04-11 18:23:03 +00:00
commit a29456369d

View file

@ -361,6 +361,21 @@ void replace_args(Parm *p, String *s) {
} }
} }
/* replace_contract_args. This function replaces argument names in contract
specifications. Used in conjunction with the %contract directive. */
static
void replace_contract_args(Parm *cp, Parm *rp, String *s) {
while (cp && rp) {
String *n = Getattr(cp,"name");
if (n) {
Replace(s,n,Getattr(rp,"lname"), DOH_REPLACE_ID);
}
cp = nextSibling(cp);
rp = nextSibling(rp);
}
}
/* ----------------------------------------------------------------------------- /* -----------------------------------------------------------------------------
* int emit_action() * int emit_action()
* *
@ -413,8 +428,7 @@ void emit_action(Node *n, Wrapper *f) {
/* Preassert -- EXPERIMENTAL */ /* Preassert -- EXPERIMENTAL */
tm = Getattr(n,"feature:preassert"); tm = Getattr(n,"feature:preassert");
if (tm) { if (tm) {
p = Getattr(n,"parms"); replace_contract_args(Getmeta(tm,"parms"), Getattr(n,"parms"),tm);
replace_args(p,tm);
Printv(f->code,tm,"\n",NIL); Printv(f->code,tm,"\n",NIL);
} }
@ -465,8 +479,7 @@ void emit_action(Node *n, Wrapper *f) {
/* Postassert - EXPERIMENTAL */ /* Postassert - EXPERIMENTAL */
tm = Getattr(n,"feature:postassert"); tm = Getattr(n,"feature:postassert");
if (tm) { if (tm) {
p = Getattr(n,"parms"); replace_contract_args(Getmeta(tm,"parms"), Getattr(n,"parms"),tm);
replace_args(p,tm);
Printv(f->code,tm,"\n",NIL); Printv(f->code,tm,"\n",NIL);
} }
} }