Squirrel

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

arith op + on between instance and instance error

Last post 06-02-2008, 12:13 AM by imtrobin. 8 replies.
Sort Posts: Previous Next
  •  05-26-2008, 5:50 AM 2538

    arith op + on between instance and instance error

    Hi

    I'm trying to expose operator + like this thread but am receiving an "arith op + on between instance and instance" error. Any advice?

    http://squirrel-lang.org/forums/thread/872.aspx

    SQClassDef <Ogre::Vector3> ("Vector3")

    .overloadFunc <Ogre::Vector3(Ogre::Vector3::*)(const Ogre::Vector3&) const>(&Ogre::Vector3::operator+, "_add");

    The script

    local v = Vector3 (1.0, 2.0, 5.0);
     
     // make copy
    local vcopy = Vector3 (v);
    local result = v + vcopy; // fails

     

  •  05-26-2008, 7:24 AM 2540 in reply to 2538

    Re: arith op + on between instance and instance error

    Hi,

    .overloadFunc doesn't work with operator, so
    try .overloadOperator instead.

    Regards
    --
    K. Kawachi
  •  05-28-2008, 4:27 AM 2544 in reply to 2540

    Re: arith op + on between instance and instance error

    Hmm, I'm getting a

    4Push(): could not create INSTANCE copy (check registration name)

    error

  •  05-28-2008, 5:40 AM 2545 in reply to 2544

    Re: arith op + on between instance and instance error

    Oops :(

    Please post the whole binding code for Ogre::Vector3
    including SQClassDef and DECLARE_INSTANCE_TYPE_NAME.

    Regards,
    --
    K. Kawachi

  •  05-28-2008, 7:48 PM 2547 in reply to 2545

    Re: arith op + on between instance and instance error

    // ogre Vector3 has overloaded operators for +, I only paste the relevant parts

    namespace Ogre
    {
    class _OgreExport Vector3
    {
    public:
       Real x, y, z;
    public:
       inline Vector3(){}
       inline Vector3( const Real fX, const Real fY, const Real fZ )
          :
    x( fX ), y( fY ), z( fZ )
       {}

       inline Vector3 operator + ( const Vector3& rkVector ) const
       {
          return Vector3(x + rkVector.x,y + rkVector.y,z + rkVector.z);
       }
    };

    DECLARE_INSTANCE_TYPE_NAME (Ogre::Vector3, Vector3);

    // binding

    SQClassDef <Ogre::Vector3> ("Vector3")

    .overloadConstructor <Ogre::Vector3(*)(void)>()
    .overloadConstructor <Ogre::Vector3(*)(float, float, float)>()
    .
    overloadConstructor <Ogre::Vector3(*)(const Ogre::Vector3&)>()

    .var (&Ogre::Vector3::x, "x")
    .
    var (&Ogre::Vector3::y, "y")
    .
    var (&Ogre::Vector3::z, "z")

    .overloadOperator <Ogre::Vector3(Ogre::Vector3::*)(const Ogre::Vector3&) const>(&Ogre::Vector3::operator+, "_add");

    // script that fails

     local result = Vector3 ();
     result = v + vcopy;  // both v and vcopy are Vector3

  •  05-29-2008, 7:57 AM 2548 in reply to 2547

    Re: arith op + on between instance and instance error

    Hi,

    Your code works fine on my PC.  I'd like to know your compiler and sqplus version.
    I've tested it with
    • gcc-3.4.4 (cygwin)
    • SQUIRREL2_1_1_sqplus_snapshot_20071014
    • SQPLUS_OVERLOAD_OPT and SQPLUS_CONST_OPT  defined in sqplus.h
    Regards
    --
    K. Kawachi

  •  05-30-2008, 10:48 AM 2550 in reply to 2548

    Re: arith op + on between instance and instance error

    VC8 SP1, sqplus  r154 from SV

    I have both defined

    These are my defines

    #define NO_SQUNICODE

    #define SQPLUS_AUTOCONVERT_OTHER_CHAR

    #define SQPLUS_SUPPORT_SQ_STD_STRING

    #define SQPLUS_CONST_OPT

    #define SQ_SUPPORT_INSTANCE_TYPE_INFO

    #define SQPLUS_OVERLOAD_OPT

    #define SQ_USE_CLASS_INHERITANCE

    #define CPP_STYLE_INHERITANCE

    #define _CRT_SECURE_NO_DEPRECATE

    #define _CRT_NONSTDC_NO_DEPRECATE

    #define _CRT_NON_CONFORMING_SWPRINTFS

    //#define SQPLUS_SUPPORT_NULL_INSTANCES

    #define SQPLUS_DISABLE_COPY_INSTANCES

    #include <sqplus.h>

  •  05-31-2008, 9:50 PM 2553 in reply to 2550

    Re: arith op + on between instance and instance error

    > #define SQPLUS_DISABLE_COPY_INSTANCES

    undefine this!

    --

    K.Kawachi

  •  06-02-2008, 12:13 AM 2554 in reply to 2553

    Re: arith op + on between instance and instance error

    Sooka..working now! Domo! Thanks!

     

View as RSS news feed in XML
Powered by Community Server, by Telligent Systems