new explicitcall feature
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9188 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
b2a344a30b
commit
0fd23e92ba
4 changed files with 46 additions and 10 deletions
|
|
@ -159,7 +159,14 @@
|
|||
#define %clearnovaluewrapper %feature("novaluewrapper","")
|
||||
|
||||
/* 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 */
|
||||
%define DYNAMIC_CAST(mangle,func)
|
||||
|
|
|
|||
|
|
@ -973,7 +973,30 @@ Language::functionHandler(Node *n) {
|
|||
} else if (isfriend) {
|
||||
globalfunctionHandler(n);
|
||||
} 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);
|
||||
|
||||
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;
|
||||
|
|
|
|||
|
|
@ -381,8 +381,8 @@ Swig_cfunction_call(String_or_char *name, ParmList *parms) {
|
|||
* set to "(*this)->" or some similar sequence.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
String *
|
||||
Swig_cmethod_call(String_or_char *name, ParmList *parms, String_or_char *self) {
|
||||
static String *
|
||||
Swig_cmethod_call(String_or_char *name, ParmList *parms, String_or_char *self, String *explicit_qualifier) {
|
||||
String *func, *nname;
|
||||
int i = 0;
|
||||
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'.
|
||||
the rest seems not caring very much,
|
||||
*/
|
||||
if (SwigType_istemplate(name)) {
|
||||
Printf(func,"SWIGTEMPLATEDISAMBIGUATOR %s(", nname);
|
||||
} else {
|
||||
Printf(func,"%s(", nname);
|
||||
}
|
||||
if (SwigType_istemplate(name))
|
||||
Printf(func,"SWIGTEMPLATEDISAMBIGUATOR ");
|
||||
|
||||
if (explicit_qualifier)
|
||||
Printv(func, explicit_qualifier, "::", NIL);
|
||||
|
||||
Printf(func,"%s(", nname);
|
||||
|
||||
i++;
|
||||
p = nextSibling(p);
|
||||
|
|
@ -843,11 +845,16 @@ Swig_MethodToFunction(Node *n, String *classname, int flags) {
|
|||
|
||||
/* Generate action code for the access */
|
||||
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);
|
||||
Setattr(n,k_wrapaction, cres);
|
||||
Delete(call);
|
||||
Delete(cres);
|
||||
Delete(explicit_qualifier);
|
||||
} else {
|
||||
/* Methods with default arguments are wrapped with additional methods for each default argument,
|
||||
* 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_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_cppconstructor_call(String_or_char *name, ParmList *parms);
|
||||
extern String *Swig_unref_call(Node *n);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue