How can I make SWIG for Lua create a binary operators with a scalar as left argument and custom class on the right? -


the swig documentation shows how overload operators. example have of complex class , show how overload operator+. have example talking mixing double , complex. example given, though defines complex operator+(double, const complex &), works complex+double. take following example:

a = complex(2,3); b = a+3; print(b); b = 3+a; print(b); 

the output follows:

<complex userdata: 7ffe30c47438> not execute script file test.lua: error in complex::__add__ (arg 1), expected 'complex *' got 'number' 

the first line of output result of first call print(b). call 3+a fails.

how can make swig generate code work when left hand side scalar , complex on right hand side?


Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -