tags:

views:

363

answers:

1

I currently have the following lua code:

    g = engine.CGeometry()

    vertexes = {}

    vertexes[1] = 0
    vertexes[2] = 0
    vertexes[3] = 0

    vertexes[4] = 0
    vertexes[5] = -1
    vertexes[6] = 0

    vertexes[7] = -1
    vertexes[8] = 0
    vertexes[9] = 0

    print "adding vertexes"
    g:SetVertexes(vertexes)

where g:SetVertexes() isimplemented in C++ as:

void CGeometry::SetVertexes(double* vertexes){
    this->vertexes = vertexes;
}

resulting in this error:

adding vertexes
PANIC: unprotected error in call to Lua API (Error in SetVertexes (arg 2), expected 'double *' got 'table')
Press any key to continue . . .

Any ideas?

+1  A: 

Try writing:

void CGeometry::SetVertexes(double vertexes[]);

in the interface defintion. Judging from the documentation, SWIG makes a difference between pointers and arrays.

David Hanak
at one point I changed double* vertexes to double vertexes[] and got the same error
Tom J Nowell