Fix 1832613 - template function pointer typedefs
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@10195 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
afc303a8ec
commit
da509bd641
4 changed files with 80 additions and 18 deletions
|
|
@ -1,6 +1,9 @@
|
|||
Version 1.3.34 (in progress)
|
||||
============================
|
||||
|
||||
12/16/2007: wsfulton
|
||||
Fix #1832613 - Templates and some typedefs involving pointers or function pointers
|
||||
|
||||
12/12/2007: wsfulton
|
||||
[Java] Fix #1632625 - Compilation errors on Visual C++ 6 when using directors.
|
||||
|
||||
|
|
|
|||
|
|
@ -307,6 +307,7 @@ CPP_TEST_CASES += \
|
|||
template_typedef_cplx3 \
|
||||
template_typedef_cplx4 \
|
||||
template_typedef_cplx5 \
|
||||
template_typedef_funcptr \
|
||||
template_typedef_ns \
|
||||
template_typedef_ptr \
|
||||
template_typedef_rec \
|
||||
|
|
|
|||
48
Examples/test-suite/template_typedef_funcptr.i
Normal file
48
Examples/test-suite/template_typedef_funcptr.i
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
%module template_typedef_funcptr
|
||||
|
||||
//Bug #1832613
|
||||
|
||||
%include <std_string.i>
|
||||
|
||||
%inline %{
|
||||
|
||||
#include <string>
|
||||
|
||||
template<typename T> class Ptr {};
|
||||
|
||||
class MCContract {};
|
||||
typedef Ptr<MCContract> MCContractPtr;
|
||||
%}
|
||||
|
||||
%template() Ptr<MCContract>;
|
||||
|
||||
%inline %{
|
||||
template <class Contract, typename ContractID, typename CallbackType>
|
||||
class ContractFactory
|
||||
{
|
||||
public:
|
||||
static ContractFactory<Contract,ContractID,CallbackType> &getInstance() {
|
||||
static ContractFactory<Contract, ContractID, CallbackType> instance;
|
||||
return instance;
|
||||
}
|
||||
};
|
||||
/**
|
||||
* CreateXXContractCallback is a pointer to a function taking no arguments and
|
||||
* returning a pointer to an XXContract.
|
||||
*/
|
||||
typedef MCContractPtr (*CreateMCContractCallback)();
|
||||
%}
|
||||
|
||||
|
||||
//Get around it by changing this:
|
||||
%template(MCContractFactory) ContractFactory<MCContract, std::string, CreateMCContractCallback>;
|
||||
|
||||
//to a form which expands the typedef:
|
||||
//%template(MCContractFactory) ContractFactory<MCContract, std::string, Ptr<MCContract>(*)()>;
|
||||
|
||||
%inline %{
|
||||
typedef MCContractPtr* ContractPtrPtr;
|
||||
%}
|
||||
// Plain pointers were also causing problems...
|
||||
%template(MCContractFactory2) ContractFactory<MCContract, std::string, ContractPtrPtr>;
|
||||
|
||||
|
|
@ -974,10 +974,6 @@ static Node *symbol_lookup_qualified(String_or_char *name, Symtab *symtab, Strin
|
|||
* to get the real node.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static
|
||||
SwigType *Swig_symbol_template_reduce(SwigType *qt, Symtab *ntab);
|
||||
|
||||
|
||||
Node *Swig_symbol_clookup(String_or_char *name, Symtab *n) {
|
||||
Hash *hsym = 0;
|
||||
Node *s = 0;
|
||||
|
|
@ -1336,11 +1332,7 @@ Node *Swig_symbol_isoverloaded(Node *n) {
|
|||
* Create a fully qualified type name
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static int no_constructor(Node *n) {
|
||||
return !Checkattr(n, "nodeType", "constructor");
|
||||
}
|
||||
|
||||
/* This cache produce problems with OSS, don't active it */
|
||||
/* This cache produces problems with OSS, don't active it */
|
||||
/* #define SWIG_TEMPLATE_QUALIFY_CACHE */
|
||||
static SwigType *Swig_symbol_template_qualify(const SwigType *e, Symtab *st) {
|
||||
String *tprefix, *tsuffix;
|
||||
|
|
@ -1407,6 +1399,10 @@ static SwigType *Swig_symbol_template_qualify(const SwigType *e, Symtab *st) {
|
|||
}
|
||||
|
||||
|
||||
static int no_constructor(Node *n) {
|
||||
return !Checkattr(n, "nodeType", "constructor");
|
||||
}
|
||||
|
||||
SwigType *Swig_symbol_type_qualify(const SwigType *t, Symtab *st) {
|
||||
List *elements;
|
||||
String *result = NewStringEmpty();
|
||||
|
|
@ -1483,15 +1479,22 @@ SwigType *Swig_symbol_type_qualify(const SwigType *t, Symtab *st) {
|
|||
}
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_symbol_typedef_reduce()
|
||||
*
|
||||
* Chase a typedef through symbol tables looking for a match.
|
||||
* Swig_symbol_template_reduce()
|
||||
* Resolves template parameter types
|
||||
* For example:
|
||||
* typedef int Int;
|
||||
* typedef Int Integer;
|
||||
* with input:
|
||||
* Foo<(Int,Integer)>
|
||||
* returns:
|
||||
* Foo<(int,int)>
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static
|
||||
SwigType *Swig_symbol_template_reduce(SwigType *qt, Symtab *ntab) {
|
||||
Parm *p;
|
||||
List *parms = SwigType_parmlist(qt);
|
||||
String *templateargs = SwigType_templateargs(qt);
|
||||
List *parms = SwigType_parmlist(templateargs);
|
||||
Iterator pi = First(parms);
|
||||
String *tprefix = SwigType_templateprefix(qt);
|
||||
String *tsuffix = SwigType_templatesuffix(qt);
|
||||
|
|
@ -1528,10 +1531,17 @@ SwigType *Swig_symbol_template_reduce(SwigType *qt, Symtab *ntab) {
|
|||
Delete(parms);
|
||||
Delete(tprefix);
|
||||
Delete(tsuffix);
|
||||
Delete(templateargs);
|
||||
return qprefix;
|
||||
}
|
||||
|
||||
|
||||
/* -----------------------------------------------------------------------------
|
||||
* Swig_symbol_typedef_reduce()
|
||||
*
|
||||
* Chase a typedef through symbol tables looking for a match.
|
||||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
SwigType *Swig_symbol_typedef_reduce(SwigType *ty, Symtab *tab) {
|
||||
SwigType *prefix, *base;
|
||||
Node *n;
|
||||
|
|
@ -1547,14 +1557,14 @@ SwigType *Swig_symbol_typedef_reduce(SwigType *ty, Symtab *tab) {
|
|||
Append(prefix, qt);
|
||||
Delete(qt);
|
||||
#ifdef SWIG_DEBUG
|
||||
Printf(stderr, "symbol_reduce %s %s\n", ty, prefix);
|
||||
Printf(stderr, "symbol_reduce (a) %s %s\n", ty, prefix);
|
||||
#endif
|
||||
Delete(base);
|
||||
return prefix;
|
||||
} else {
|
||||
Delete(prefix);
|
||||
#ifdef SWIG_DEBUG
|
||||
Printf(stderr, "symbol_reduce %s %s\n", ty, ty);
|
||||
Printf(stderr, "symbol_reduce (b) %s %s\n", ty, ty);
|
||||
#endif
|
||||
return Copy(ty);
|
||||
}
|
||||
|
|
@ -1568,7 +1578,7 @@ SwigType *Swig_symbol_typedef_reduce(SwigType *ty, Symtab *tab) {
|
|||
Delete(base);
|
||||
Delete(prefix);
|
||||
#ifdef SWIG_DEBUG
|
||||
Printf(stderr, "symbol_reduce %s %s\n", ty, ty);
|
||||
Printf(stderr, "symbol_reduce (c) %s %s\n", ty, ty);
|
||||
#endif
|
||||
return Copy(ty);
|
||||
}
|
||||
|
|
@ -1612,7 +1622,7 @@ SwigType *Swig_symbol_typedef_reduce(SwigType *ty, Symtab *tab) {
|
|||
Delete(nt);
|
||||
Delete(rt);
|
||||
#ifdef SWIG_DEBUG
|
||||
Printf(stderr, "symbol_reduce %s %s\n", qt, ty);
|
||||
Printf(stderr, "symbol_reduce (d) %s %s\n", qt, ty);
|
||||
#endif
|
||||
return qt;
|
||||
}
|
||||
|
|
@ -1620,7 +1630,7 @@ SwigType *Swig_symbol_typedef_reduce(SwigType *ty, Symtab *tab) {
|
|||
Delete(base);
|
||||
Delete(prefix);
|
||||
#ifdef SWIG_DEBUG
|
||||
Printf(stderr, "symbol_reduce %s %s\n", ty, ty);
|
||||
Printf(stderr, "symbol_reduce (e) %s %s\n", ty, ty);
|
||||
#endif
|
||||
return Copy(ty);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue