Quantcast

Wrapping a templated function pointer

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Wrapping a templated function pointer

Guillaume Bittoun

Hello,

I am currently using SWIG 3.0.8, trying to wrap an object that has templated function pointer in argument of a function as

class Object
{

public:

    template<typename T>
    int exec (std::list<std::shared_ptr<T>>&, unsigned int (T::*)() const) const;

}

On this specific function SWIG returns:

Object.h:68: Error: Syntax error in input(3).

I am now wondering if that kind of function syntax, ie. taking a templated function pointer as argument, is supported by SWIG. I can barely find some examples of this on the internet and I apologise if I missed this in the doc but is there any known issue about my problem ? Is there a workaround ? I can remove this function from the wrapping, but a `%ignore Object::exec` directive doesn’t avoid the previous SWIG error.

Any clue is welcome :-)

Regards,

Guillaume


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Swig-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/swig-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Wrapping a templated function pointer

Jake

You can ignore it by wrapping the header declaration in:

#ifndef SWIG
...
#endif

This will prevent SWIG from seeing it during parsing. The ignore directive needs a successful parse so it can't be used when SWIG doesn't support part of the language.

-Jake Cobb


On Fri, Feb 17, 2017, 06:11 Guillaume Bittoun <[hidden email]> wrote:

Hello,

I am currently using SWIG 3.0.8, trying to wrap an object that has templated function pointer in argument of a function as

class Object
{

public:

    template<typename T>
    int exec (std::list<std::shared_ptr<T>>&, unsigned int (T::*)() const) const;

}

On this specific function SWIG returns:

Object.h:68: Error: Syntax error in input(3).

I am now wondering if that kind of function syntax, ie. taking a templated function pointer as argument, is supported by SWIG. I can barely find some examples of this on the internet and I apologise if I missed this in the doc but is there any known issue about my problem ? Is there a workaround ? I can remove this function from the wrapping, but a `%ignore Object::exec` directive doesn’t avoid the previous SWIG error.

Any clue is welcome :-)

Regards,

Guillaume

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot_______________________________________________
Swig-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/swig-user

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Swig-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/swig-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Wrapping a templated function pointer

Guillaume Bittoun

Thanks, it indeed solved my problem;

I couldn’t find a list of known problems on C++ parsing in the documentation but maybe I just looked bad, if there is any, I’d be pleased to read it :-)

Regards,

Guillaume


Le 17/02/2017 à 13:39, Jake a écrit :

You can ignore it by wrapping the header declaration in:

#ifndef SWIG
...
#endif

This will prevent SWIG from seeing it during parsing. The ignore directive needs a successful parse so it can't be used when SWIG doesn't support part of the language.

-Jake Cobb


On Fri, Feb 17, 2017, 06:11 Guillaume Bittoun <[hidden email]> wrote:

Hello,

I am currently using SWIG 3.0.8, trying to wrap an object that has templated function pointer in argument of a function as

class Object
{

public:

    template<typename T>
    int exec (std::list<std::shared_ptr<T>>&, unsigned int (T::*)() const) const;

}

On this specific function SWIG returns:

Object.h:68: Error: Syntax error in input(3).

I am now wondering if that kind of function syntax, ie. taking a templated function pointer as argument, is supported by SWIG. I can barely find some examples of this on the internet and I apologise if I missed this in the doc but is there any known issue about my problem ? Is there a workaround ? I can remove this function from the wrapping, but a `%ignore Object::exec` directive doesn’t avoid the previous SWIG error.

Any clue is welcome :-)

Regards,

Guillaume

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot_______________________________________________
Swig-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/swig-user


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Swig-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/swig-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Wrapping a templated function pointer

William S Fulton
Guillaume, Parsing errors are often fixed when reported, so there aren't many known parsing problems. Known problems are most likely to be found as open Github issues. I've committed a change to fix the parsing syntax error you mention below. In this case the problem was the const declaration of the member function pointer parameter and is independent of the exec function being a template.

William

On 19 February 2017 at 10:32, Guillaume Bittoun <[hidden email]> wrote:

Thanks, it indeed solved my problem;

I couldn’t find a list of known problems on C++ parsing in the documentation but maybe I just looked bad, if there is any, I’d be pleased to read it :-)

Regards,

Guillaume


Le 17/02/2017 à 13:39, Jake a écrit :

You can ignore it by wrapping the header declaration in:

#ifndef SWIG
...
#endif

This will prevent SWIG from seeing it during parsing. The ignore directive needs a successful parse so it can't be used when SWIG doesn't support part of the language.

-Jake Cobb


On Fri, Feb 17, 2017, 06:11 Guillaume Bittoun <[hidden email]> wrote:

Hello,

I am currently using SWIG 3.0.8, trying to wrap an object that has templated function pointer in argument of a function as

class Object
{

public:

    template<typename T>
    int exec (std::list<std::shared_ptr<T>>&, unsigned int (T::*)() const) const;

}

On this specific function SWIG returns:

Object.h:68: Error: Syntax error in input(3).

I am now wondering if that kind of function syntax, ie. taking a templated function pointer as argument, is supported by SWIG. I can barely find some examples of this on the internet and I apologise if I missed this in the doc but is there any known issue about my problem ? Is there a workaround ? I can remove this function from the wrapping, but a `%ignore Object::exec` directive doesn’t avoid the previous SWIG error.

Any clue is welcome :-)

Regards,

Guillaume

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot_______________________________________________
Swig-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/swig-user


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Swig-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/swig-user



------------------------------------------------------------------------------
Announcing the Oxford Dictionaries API! The API offers world-renowned
dictionary content that is easy and intuitive to access. Sign up for an
account today to start using our lexical data to power your apps and
projects. Get started today and enter our developer competition.
http://sdm.link/oxford
_______________________________________________
Swig-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/swig-user
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Wrapping a templated function pointer

Guillaume Bittoun

Thank you so much !

Accept my sincere apologies for not reporting this as a bug on github.

Best regards,

Guillaume

Le 11/03/2017 à 00:58, William S Fulton a écrit :
Guillaume, Parsing errors are often fixed when reported, so there aren't many known parsing problems. Known problems are most likely to be found as open Github issues. I've committed a change to fix the parsing syntax error you mention below. In this case the problem was the const declaration of the member function pointer parameter and is independent of the exec function being a template.

William

On 19 February 2017 at 10:32, Guillaume Bittoun <[hidden email]> wrote:

Thanks, it indeed solved my problem;

I couldn’t find a list of known problems on C++ parsing in the documentation but maybe I just looked bad, if there is any, I’d be pleased to read it :-)

Regards,

Guillaume


Le 17/02/2017 à 13:39, Jake a écrit :

You can ignore it by wrapping the header declaration in:

#ifndef SWIG
...
#endif

This will prevent SWIG from seeing it during parsing. The ignore directive needs a successful parse so it can't be used when SWIG doesn't support part of the language.

-Jake Cobb


On Fri, Feb 17, 2017, 06:11 Guillaume Bittoun <[hidden email]> wrote:

Hello,

I am currently using SWIG 3.0.8, trying to wrap an object that has templated function pointer in argument of a function as

class Object
{

public:

    template<typename T>
    int exec (std::list<std::shared_ptr<T>>&, unsigned int (T::*)() const) const;

}

On this specific function SWIG returns:

Object.h:68: Error: Syntax error in input(3).

I am now wondering if that kind of function syntax, ie. taking a templated function pointer as argument, is supported by SWIG. I can barely find some examples of this on the internet and I apologise if I missed this in the doc but is there any known issue about my problem ? Is there a workaround ? I can remove this function from the wrapping, but a `%ignore Object::exec` directive doesn’t avoid the previous SWIG error.

Any clue is welcome :-)

Regards,

Guillaume

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot_______________________________________________
Swig-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/swig-user


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
Swig-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/swig-user




------------------------------------------------------------------------------
Announcing the Oxford Dictionaries API! The API offers world-renowned
dictionary content that is easy and intuitive to access. Sign up for an
account today to start using our lexical data to power your apps and
projects. Get started today and enter our developer competition.
http://sdm.link/oxford
_______________________________________________
Swig-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/swig-user
Loading...