new explicitcall feature
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@9188 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
37005baff5
commit
32abf157f7
4 changed files with 46 additions and 10 deletions
|
|
@ -159,7 +159,14 @@
|
||||||
#define %clearnovaluewrapper %feature("novaluewrapper","")
|
#define %clearnovaluewrapper %feature("novaluewrapper","")
|
||||||
|
|
||||||
/* Contract support - Experimental and undocumented */
|
/* Contract support - Experimental and undocumented */
|
||||||
#define %contract %feature("contract")
|
#define %contract %feature("contract")
|
||||||
|
#define %nocontract %feature("contract","0")
|
||||||
|
#define %clearcontract %feature("contract","")
|
||||||
|
|
||||||
|
/* explicitcall directives */
|
||||||
|
#define %explicitcall %feature("explicitcall")
|
||||||
|
#define %noexplicitcall %feature("explicitcall","0")
|
||||||
|
#define %clearexplicitcall %feature("explicitcall","")
|
||||||
|
|
||||||
/* Macro for setting a dynamic cast function */
|
/* Macro for setting a dynamic cast function */
|
||||||
%define DYNAMIC_CAST(mangle,func)
|
%define DYNAMIC_CAST(mangle,func)
|
||||||
|
|
|
||||||
|
|
@ -973,7 +973,30 @@ Language::functionHandler(Node *n) {
|
||||||
} else if (isfriend) {
|
} else if (isfriend) {
|
||||||
globalfunctionHandler(n);
|
globalfunctionHandler(n);
|
||||||
} else {
|
} else {
|
||||||
|
Node* explicit_n = 0;
|
||||||
|
if (GetFlag(n, "feature:explicitcall")) {
|
||||||
|
// Add in an explicit wrapper call to virtual methods
|
||||||
|
if (Cmp(storage, "virtual") == 0 && (cplus_mode == PUBLIC))
|
||||||
|
explicit_n = Copy(n);
|
||||||
|
}
|
||||||
|
|
||||||
memberfunctionHandler(n);
|
memberfunctionHandler(n);
|
||||||
|
|
||||||
|
if (explicit_n) {
|
||||||
|
String *new_symname = Copy(Getattr(n,"sym:name"));
|
||||||
|
String *suffix = Getattr(n,"feature:explicitcall:suffix");
|
||||||
|
if (!suffix)
|
||||||
|
suffix = Getattr(parentNode(n),"sym:name");
|
||||||
|
Printv(new_symname, suffix, NIL);
|
||||||
|
Setattr(explicit_n,"sym:name", new_symname);
|
||||||
|
Delattr(explicit_n,"storage");
|
||||||
|
Delattr(explicit_n,"override");
|
||||||
|
Delattr(explicit_n,"hides");
|
||||||
|
SetFlag(explicit_n,"explicitcall");
|
||||||
|
memberfunctionHandler(explicit_n);
|
||||||
|
Delattr(explicit_n,"explicitcall");
|
||||||
|
Delete(explicit_n);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return SWIG_OK;
|
return SWIG_OK;
|
||||||
|
|
|
||||||
|
|
@ -381,8 +381,8 @@ Swig_cfunction_call(String_or_char *name, ParmList *parms) {
|
||||||
* set to "(*this)->" or some similar sequence.
|
* set to "(*this)->" or some similar sequence.
|
||||||
* ----------------------------------------------------------------------------- */
|
* ----------------------------------------------------------------------------- */
|
||||||
|
|
||||||
String *
|
static String *
|
||||||
Swig_cmethod_call(String_or_char *name, ParmList *parms, String_or_char *self) {
|
Swig_cmethod_call(String_or_char *name, ParmList *parms, String_or_char *self, String *explicit_qualifier) {
|
||||||
String *func, *nname;
|
String *func, *nname;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
Parm *p = parms;
|
Parm *p = parms;
|
||||||
|
|
@ -426,11 +426,13 @@ Swig_cmethod_call(String_or_char *name, ParmList *parms, String_or_char *self) {
|
||||||
- gcc-3.4 forbids the use of 'template'.
|
- gcc-3.4 forbids the use of 'template'.
|
||||||
the rest seems not caring very much,
|
the rest seems not caring very much,
|
||||||
*/
|
*/
|
||||||
if (SwigType_istemplate(name)) {
|
if (SwigType_istemplate(name))
|
||||||
Printf(func,"SWIGTEMPLATEDISAMBIGUATOR %s(", nname);
|
Printf(func,"SWIGTEMPLATEDISAMBIGUATOR ");
|
||||||
} else {
|
|
||||||
Printf(func,"%s(", nname);
|
if (explicit_qualifier)
|
||||||
}
|
Printv(func, explicit_qualifier, "::", NIL);
|
||||||
|
|
||||||
|
Printf(func,"%s(", nname);
|
||||||
|
|
||||||
i++;
|
i++;
|
||||||
p = nextSibling(p);
|
p = nextSibling(p);
|
||||||
|
|
@ -843,11 +845,16 @@ Swig_MethodToFunction(Node *n, String *classname, int flags) {
|
||||||
|
|
||||||
/* Generate action code for the access */
|
/* Generate action code for the access */
|
||||||
if (!(flags & CWRAP_EXTEND)) {
|
if (!(flags & CWRAP_EXTEND)) {
|
||||||
String *call = Swig_cmethod_call(name,p,self);
|
/* Call the explicit method rather than allow for a polymorphic call */
|
||||||
|
String *explicit_qualifier = GetFlag(n,"explicitcall") ?
|
||||||
|
SwigType_namestr(Getattr(Getattr(parentNode(n),"typescope"),k_qname)) : 0;
|
||||||
|
|
||||||
|
String *call = Swig_cmethod_call(name,p,self,explicit_qualifier);
|
||||||
String *cres = Swig_cresult(Getattr(n,k_type),k_result, call);
|
String *cres = Swig_cresult(Getattr(n,k_type),k_result, call);
|
||||||
Setattr(n,k_wrapaction, cres);
|
Setattr(n,k_wrapaction, cres);
|
||||||
Delete(call);
|
Delete(call);
|
||||||
Delete(cres);
|
Delete(cres);
|
||||||
|
Delete(explicit_qualifier);
|
||||||
} else {
|
} else {
|
||||||
/* Methods with default arguments are wrapped with additional methods for each default argument,
|
/* Methods with default arguments are wrapped with additional methods for each default argument,
|
||||||
* however, only one extra %extend method is generated. */
|
* however, only one extra %extend method is generated. */
|
||||||
|
|
|
||||||
|
|
@ -479,7 +479,6 @@ extern int Swig_cargs(Wrapper *w, ParmList *l);
|
||||||
extern String *Swig_cresult(SwigType *t, const String_or_char *name, const String_or_char *decl);
|
extern String *Swig_cresult(SwigType *t, const String_or_char *name, const String_or_char *decl);
|
||||||
|
|
||||||
extern String *Swig_cfunction_call(String_or_char *name, ParmList *parms);
|
extern String *Swig_cfunction_call(String_or_char *name, ParmList *parms);
|
||||||
extern String *Swig_cmethod_call(String_or_char *name, ParmList *parms, String_or_char *self);
|
|
||||||
extern String *Swig_cconstructor_call(String_or_char *name);
|
extern String *Swig_cconstructor_call(String_or_char *name);
|
||||||
extern String *Swig_cppconstructor_call(String_or_char *name, ParmList *parms);
|
extern String *Swig_cppconstructor_call(String_or_char *name, ParmList *parms);
|
||||||
extern String *Swig_unref_call(Node *n);
|
extern String *Swig_unref_call(Node *n);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue