Squirrel

The programming language
Welcome to Squirrel Sign in | Join | Help
in Search

[SQPlus] binding templated class

Last post 06-22-2009, 2:41 PM by DoMeN. 4 replies.
Sort Posts: Previous Next
  •  06-20-2009, 2:30 PM 3319

    [SQPlus] binding templated class

    Hy, is there a way to bind a ( specialized ) templated class with SQPlus?

    for e.g. such a class:

    template< typename T >
    class foo
    {
    };

    bind_with_sqplus( foo< unsigned int > );


    If it's not possible with sqplus, is it possible with any other binder?

    regards,
    Domen
  •  06-21-2009, 1:32 AM 3320 in reply to 3319

    Re: [SQPlus] binding templated class

    I want to use DECLARE_INSTANCE_TYPE( foo< unsigned int > ); so that I could use it as a variable in squirrel.
  •  06-21-2009, 1:03 PM 3321 in reply to 3320

    Re: [SQPlus] binding templated class

    See testSqPlus2.cpp for an example...

    You need to do something like this:

    template<typename T>
    struct Point {
      Point() {}
      Point(T X, T Y) : X(X), Y(Y) {}
      T X, Y;
    };

    typedef Point<float> Pointf;

    DECLARE_INSTANCE_TYPE(Pointf)



  •  06-22-2009, 2:16 PM 3323 in reply to 3321

    Re: [SQPlus] binding templated class

    Thx for the hint. I tested the sample and there were no problems with compiling them.

    But in my case I still get this error:

    EXTERNAL/SQUIRREL2_1_1_sqplus_snapshot_20080713/SHARED/include_sqplus/sqplus.h|689|error: no match for ‘operator=’ in ‘* newClass = classToCopy’|
    note: candidates are: LD_Array<T>& LD_Array<T>::operator=(LD_Array<T>&) [with T = unsigned int]|

    I guess that it has a problem with my overloaded operator=

    How should I write operator= to use the class with SQPlus?

  •  06-22-2009, 2:41 PM 3324 in reply to 3323

    Re: [SQPlus] binding templated class

    OK I've finally managed to compile it... the only thing that had to be changed was to put const in front of LD_Array<T>&... Embarrassed [:$]

    Thx for the help
View as RSS news feed in XML
Powered by Community Server, by Telligent Systems