Squirrel

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

Does Squirrel support reference return value?

Last post 01-15-2010, 8:12 PM by liangpengcheng. 0 replies.
Sort Posts: Previous Next
  •  01-15-2010, 8:12 PM 3616

    Does Squirrel support reference return value?

    I wrote a c++ class like

     

    class Vector3

    {

       //...

       inline Vector3 & setX( float x )

    {

       val[0] = x;

       return *this;

    }

     

        // Set the y element of a 3-D vector
        //
        inline Vector3 & setY( float y )

    {

       val[1] = y;

       return *this;

    }

     


        // Set the z element of a 3-D vector
        //
        inline Vector3 & setZ( float z )

    {

       val[2] = z;

       return *this;

    }

    }

    I use sqplus bind the script

    DECLARE_INSTANCE_TYPE(Vector3)

    SQClassDef<Vector3> v3def(_T("Vector3"));

    v3def.overloadFunc<Vector3& (Vector3::*)(float)>(&Vector3::setX,_T("setX"));
    v3def.overloadFunc<Vector3& (Vector3::*)(float)>(&Vector3::setY,_T("setY"));
    v3def.overloadFunc<Vector3& (Vector3::*)(float)>(&Vector3::setZ,_T("setZ"));

    The script wrote like

    local vec = Vector3();
    vec.setX(1.0).setY(2.0).setZ(3.0);

    But the z and y of vec is zero.x is 1.0

    Help me please.

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