shroud icon indicating copy to clipboard operation
shroud copied to clipboard

Wrapping a const function that returns a pointer

Open kennyweiss opened this issue 4 years ago • 1 comments

In the references example, there is the following case:

  - decl: double* getArray() +dimension(getSize())

I ran into a problem wrapping the function if it is const, e.g.

  - decl: double* getArray() const +dimension(getSize())

The errors were of the form:

<src>.cpp: error: a value of type "const ArrayWrapper *" cannot be used to initialize an entity of type "ArrayWrapper *"
      ArrayWrapper *obj = static_cast<const ArrayWrapper *>(self->addr);

Could you please add the const versions of these functions, with shroud wrappers?

kennyweiss avatar May 09 '20 02:05 kennyweiss

I added the test on the arraywrapper4 branch. However, I was getting a different error from the Fortran wrapper:

Argument 'dshc_rv' of pure function 'c_arraywrapper_get_array_const_bufferify' at (1) must be INTENT(IN) or VALUE

Try out the branch in your library. I'll add a few more cases like making the result const:

- decl: const double* getArray() +dimension(getSize())

ltaylor16 avatar May 09 '20 21:05 ltaylor16