How to bind subscript operator

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

How to bind subscript operator

he keding
hi, all

How to bind subscript operator []

For example

class Node
{
public:
    int GetValue();
...
};

class BindClass
{
public:
    int operator [] (int index)
    {
        return m_nodes[index].GetValue();
    }

    std::vector<Node> m_nodes;
};

In lua, i want code this style:

-- bindClass is BindClass instance. 
bindClass[2] = 10;

How to bind, I google but found no solution.

Thanks.

------------------------------------------------------------------------------
Benefiting from Server Virtualization: Beyond Initial Workload
Consolidation -- Increasing the use of server virtualization is a top
priority.Virtualization can reduce costs, simplify management, and improve
application availability and disaster protection. Learn more about boosting
the value of server virtualization. http://p.sf.net/sfu/vmware-sfdev2dev
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user
Reply | Threaded
Open this post in threaded view
|

Re: How to bind subscript operator

feng qiu-5
Try to overwrite __index of the class table.

On 18 April 2011 09:22, he keding <[hidden email]> wrote:
hi, all

How to bind subscript operator []

For example

class Node
{
public:
    int GetValue();
...
};

class BindClass
{
public:
    int operator [] (int index)
    {
        return m_nodes[index].GetValue();
    }

    std::vector<Node> m_nodes;
};

In lua, i want code this style:

-- bindClass is BindClass instance. 
bindClass[2] = 10;

How to bind, I google but found no solution.

Thanks.

------------------------------------------------------------------------------
Benefiting from Server Virtualization: Beyond Initial Workload
Consolidation -- Increasing the use of server virtualization is a top
priority.Virtualization can reduce costs, simplify management, and improve
application availability and disaster protection. Learn more about boosting
the value of server virtualization. http://p.sf.net/sfu/vmware-sfdev2dev
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user




--
邱烽

------------------------------------------------------------------------------
Benefiting from Server Virtualization: Beyond Initial Workload
Consolidation -- Increasing the use of server virtualization is a top
priority.Virtualization can reduce costs, simplify management, and improve
application availability and disaster protection. Learn more about boosting
the value of server virtualization. http://p.sf.net/sfu/vmware-sfdev2dev
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user
Reply | Threaded
Open this post in threaded view
|

Re: How to bind subscript operator

David Osipyan-3
In reply to this post by he keding
Looks like this is not supported yet.
http://old.nabble.com/array-access-%22A-i-%22-and-luabind-td26478178.html

On Mon, Apr 18, 2011 at 6:22 AM, he keding <[hidden email]> wrote:

> hi, all
> How to bind subscript operator []
> For example
> class Node
> {
> public:
>     int GetValue();
> ...
> };
> class BindClass
> {
> public:
>     int operator [] (int index)
>     {
>         return m_nodes[index].GetValue();
>     }
>     std::vector<Node> m_nodes;
> };
> In lua, i want code this style:
> -- bindClass is BindClass instance.
> bindClass[2] = 10;
> How to bind, I google but found no solution.
> Thanks.
> ------------------------------------------------------------------------------
> Benefiting from Server Virtualization: Beyond Initial Workload
> Consolidation -- Increasing the use of server virtualization is a top
> priority.Virtualization can reduce costs, simplify management, and improve
> application availability and disaster protection. Learn more about boosting
> the value of server virtualization. http://p.sf.net/sfu/vmware-sfdev2dev
> _______________________________________________
> luabind-user mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/luabind-user
>
>



--
Best regards
David Osipyan

------------------------------------------------------------------------------
Benefiting from Server Virtualization: Beyond Initial Workload
Consolidation -- Increasing the use of server virtualization is a top
priority.Virtualization can reduce costs, simplify management, and improve
application availability and disaster protection. Learn more about boosting
the value of server virtualization. http://p.sf.net/sfu/vmware-sfdev2dev
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user
Reply | Threaded
Open this post in threaded view
|

Re: How to bind subscript operator

he keding
Oh, that's not a good news.

The luabind source code seems complex, i don't know how to add __index, does anyone patch for this?

On Mon, Apr 18, 2011 at 2:02 PM, David Osipyan <[hidden email]> wrote:
Looks like this is not supported yet.
http://old.nabble.com/array-access-%22A-i-%22-and-luabind-td26478178.html

On Mon, Apr 18, 2011 at 6:22 AM, he keding <[hidden email]> wrote:
> hi, all
> How to bind subscript operator []
> For example
> class Node
> {
> public:
>     int GetValue();
> ...
> };
> class BindClass
> {
> public:
>     int operator [] (int index)
>     {
>         return m_nodes[index].GetValue();
>     }
>     std::vector<Node> m_nodes;
> };
> In lua, i want code this style:
> -- bindClass is BindClass instance.
> bindClass[2] = 10;
> How to bind, I google but found no solution.
> Thanks.
> ------------------------------------------------------------------------------
> Benefiting from Server Virtualization: Beyond Initial Workload
> Consolidation -- Increasing the use of server virtualization is a top
> priority.Virtualization can reduce costs, simplify management, and improve
> application availability and disaster protection. Learn more about boosting
> the value of server virtualization. http://p.sf.net/sfu/vmware-sfdev2dev
> _______________________________________________
> luabind-user mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/luabind-user
>
>



--
Best regards
David Osipyan

------------------------------------------------------------------------------
Benefiting from Server Virtualization: Beyond Initial Workload
Consolidation -- Increasing the use of server virtualization is a top
priority.Virtualization can reduce costs, simplify management, and improve
application availability and disaster protection. Learn more about boosting
the value of server virtualization. http://p.sf.net/sfu/vmware-sfdev2dev
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user


------------------------------------------------------------------------------
Benefiting from Server Virtualization: Beyond Initial Workload
Consolidation -- Increasing the use of server virtualization is a top
priority.Virtualization can reduce costs, simplify management, and improve
application availability and disaster protection. Learn more about boosting
the value of server virtualization. http://p.sf.net/sfu/vmware-sfdev2dev
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user
Reply | Threaded
Open this post in threaded view
|

Re: How to bind subscript operator

David Osipyan-3
Possible workaround is adding at (long index) whih calls operator[]
and bind at() to lua.

On Mon, Apr 18, 2011 at 6:13 PM, he keding <[hidden email]> wrote:

> Oh, that's not a good news.
> The luabind source code seems complex, i don't know how to add __index, does
> anyone patch for this?
>
> On Mon, Apr 18, 2011 at 2:02 PM, David Osipyan <[hidden email]> wrote:
>>
>> Looks like this is not supported yet.
>> http://old.nabble.com/array-access-%22A-i-%22-and-luabind-td26478178.html
>>
>> On Mon, Apr 18, 2011 at 6:22 AM, he keding <[hidden email]> wrote:
>> > hi, all
>> > How to bind subscript operator []
>> > For example
>> > class Node
>> > {
>> > public:
>> >     int GetValue();
>> > ...
>> > };
>> > class BindClass
>> > {
>> > public:
>> >     int operator [] (int index)
>> >     {
>> >         return m_nodes[index].GetValue();
>> >     }
>> >     std::vector<Node> m_nodes;
>> > };
>> > In lua, i want code this style:
>> > -- bindClass is BindClass instance.
>> > bindClass[2] = 10;
>> > How to bind, I google but found no solution.
>> > Thanks.
>> >
>> > ------------------------------------------------------------------------------
>> > Benefiting from Server Virtualization: Beyond Initial Workload
>> > Consolidation -- Increasing the use of server virtualization is a top
>> > priority.Virtualization can reduce costs, simplify management, and
>> > improve
>> > application availability and disaster protection. Learn more about
>> > boosting
>> > the value of server virtualization. http://p.sf.net/sfu/vmware-sfdev2dev
>> > _______________________________________________
>> > luabind-user mailing list
>> > [hidden email]
>> > https://lists.sourceforge.net/lists/listinfo/luabind-user
>> >
>> >
>>
>>
>>
>> --
>> Best regards
>> David Osipyan
>>
>>
>> ------------------------------------------------------------------------------
>> Benefiting from Server Virtualization: Beyond Initial Workload
>> Consolidation -- Increasing the use of server virtualization is a top
>> priority.Virtualization can reduce costs, simplify management, and improve
>> application availability and disaster protection. Learn more about
>> boosting
>> the value of server virtualization. http://p.sf.net/sfu/vmware-sfdev2dev
>> _______________________________________________
>> luabind-user mailing list
>> [hidden email]
>> https://lists.sourceforge.net/lists/listinfo/luabind-user
>
>
> ------------------------------------------------------------------------------
> Benefiting from Server Virtualization: Beyond Initial Workload
> Consolidation -- Increasing the use of server virtualization is a top
> priority.Virtualization can reduce costs, simplify management, and improve
> application availability and disaster protection. Learn more about boosting
> the value of server virtualization. http://p.sf.net/sfu/vmware-sfdev2dev
> _______________________________________________
> luabind-user mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/luabind-user
>
>



--
Best regards
David Osipyan

------------------------------------------------------------------------------
Benefiting from Server Virtualization: Beyond Initial Workload
Consolidation -- Increasing the use of server virtualization is a top
priority.Virtualization can reduce costs, simplify management, and improve
application availability and disaster protection. Learn more about boosting
the value of server virtualization. http://p.sf.net/sfu/vmware-sfdev2dev
_______________________________________________
luabind-user mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/luabind-user