/trunk/Examples/test-suite/template_typedef_funcptr.i
Swig | 53 lines | 35 code | 14 blank | 4 comment | 0 complexity | a109cfb724992b20be104f0e7e53be8e MD5 | raw file
1%module template_typedef_funcptr 2 3//Bug #1832613 4 5#if !defined(SWIGR) 6// R Swig fails on this test. Because it tries to return a nil SEXP in 7// an error 8 9%include <std_string.i> 10 11%inline %{ 12 13#include <string> 14 15template<typename T> class Ptr {}; 16 17class MCContract {}; 18typedef Ptr<MCContract> MCContractPtr; 19%} 20 21%template() Ptr<MCContract>; 22 23%inline %{ 24template <class Contract, typename ContractID, typename CallbackType> 25class ContractFactory 26{ 27 public: 28 static ContractFactory<Contract,ContractID,CallbackType> &getInstance() { 29 static ContractFactory<Contract, ContractID, CallbackType> instance; 30 return instance; 31 } 32}; 33/** 34 * CreateXXContractCallback is a pointer to a function taking no arguments and 35 * returning a pointer to an XXContract. 36 */ 37typedef MCContractPtr (*CreateMCContractCallback)(); 38%} 39 40 41//Get around it by changing this: 42%template(MCContractFactory) ContractFactory<MCContract, std::string, CreateMCContractCallback>; 43 44//to a form which expands the typedef: 45//%template(MCContractFactory) ContractFactory<MCContract, std::string, Ptr<MCContract>(*)()>; 46 47%inline %{ 48typedef MCContractPtr* ContractPtrPtr; 49%} 50// Plain pointers were also causing problems... 51%template(MCContractFactory2) ContractFactory<MCContract, std::string, ContractPtrPtr>; 52 53#endif