@@ -294,49 +294,66 @@ a default argument may include a plus symbol:
294294 api
295295^^^
296296
297- Controls the API used by the C wrapper. The values are *capi *,
298- *buf *, *capsule *, *capptr *, *cdesc * and *cfi *.
299- Normally, this attribute is determined by Shroud
300- internally. Scalar native types such as ``int `` and ``double `` will
301- use *capi * since the argument can be passed directly to C using the
302- *interoperability with C * feature of Fortran.
303-
304- Otherwise a 'bufferify' wrapper will also be created. Pointers to native and
305- ``char `` use additional metadata extracted by the Fortran wrapper via
306- intrinsics ``LEN `` and ``SIZE ``. In addition, *intent(in) * strings
307- will be copied and null-terminated. This uses *api(buf) *.
308-
309- *cdesc * will pass down a pointer to a struct which contains metadata
310- for the argument instead of passing additional fields. The advantage
311- is the struct can also be used to return metadata from the C wrapper
312- to the Fortran wrapper.
313- The metadata includes shape information from a *dimension * attribute
314- and is used on *intent(OUT) * arguments and function results to set
315- Fortran ``POINTER `` shapes.
316- The struct is named by the format fields
317- *C_array_type * and *F_array_type *.
318-
319- The option *F_CFI *, will use the *Further interoperability with C *
320- features and pass ``CFI_cdesc_t `` arguments to the C where where the
321- metadata is extracted. This uses *api(cfi) *.
322-
323- The *capsule * and *capptr * APIs are used by the capsule created by
324- shadow types created for C++ classes. In both cases the result is
325- passed from Fortran to C as an extra argument for function which
326- return a class. With *capptr *, the C wrapper will return a pointer to
327- the capsule argument while *capsule * will not return a value for
328- the function. This is controlled by the *C_shadow_result * option.
329-
330- There is currently one useful case where the user would want to set
331- this attribute. To avoid creating a wrapper which copies and null
332- terminates a ``char * `` argument the user can set *api(capi) *. The
333- address of the formal parameter will be passed to the user's library.
334- This is useful when null termination does not make sense. For example,
335- when the argument is a large buffer to be written to a file. The C
336- library must have some other way of determining the length of the
337- argument such as another argument with the explicit length.
297+ Controls the API used by the C wrapper.
298+ Normally, this attribute is determined by Shroud internally based on the
299+ argument type and attributes.
300+ But in some cases it's helpful if the user defines it.
301+
302+ buf
303+
304+ Pass a pointer to a string along with meta data about the length
305+ or size.
306+ Pointers to native and
307+ ``char `` use additional metadata extracted by the Fortran wrapper via
308+ intrinsics ``LEN `` and ``SIZE ``. In addition, *intent(in) * strings
309+ will be copied and null-terminated.
310+
311+ capi
312+
313+ There is currently one useful case where the user would want to set
314+ this attribute. To avoid creating a wrapper which copies and null
315+ terminates a ``char * `` argument the user can set *api(capi) *. The
316+ address of the formal parameter will be passed to the user's library.
317+ This is useful when null termination does not make sense. For example,
318+ when the argument is a large buffer to be written to a file. The C
319+ library must have some other way of determining the length of the
320+ argument such as another argument with the explicit length.
338321
339322.. tested by strings.yaml CpassCharPtrCAPI
323+
324+ capptr
325+ capsule
326+
327+ The *capsule * and *capptr * APIs are used by the capsule created by
328+ shadow types created for C++ classes. In both cases the result is
329+ passed from Fortran to C as an extra argument for function which
330+ return a class. With *capptr *, the C wrapper will return a pointer to
331+ the capsule argument while *capsule * will not return a value for
332+ the function. This is controlled by the **C_shadow_result ** option.
333+
334+ cdesc
335+
336+ Uses a struct to pass the metadata between Fortran and C.
337+ This struct contains additional metadata beyond
338+ the length and size used by *api(buf) *.
339+ It is also used to return metadata from the C wrapper to the Fortran wrapper.
340+ The metadata includes shape information from a *dimension * attribute
341+ and is used on *intent(OUT) * arguments and function results to set the
342+ shape of Fortran ``POINTER `` variables.
343+ The struct is named by the format fields *C_array_type * and *F_array_type *.
344+ It is similar to the ``CFI_cdesc_t `` struct provied by Fortran 2018.
345+
346+ cfi
347+
348+ Use *Further interoperability with C * features and pass
349+ ``CFI_cdesc_t `` arguments to the C wrapper which will extract the
350+ metadata. Using option *F_CFI * will make this the default
351+ behavior.
352+
353+ this
354+
355+ Used when the *return_this * field is *True *.
356+ The C++ function returns a pointer to the **this ** variable.
340357
341358.. In the future a user settable api might be useful to do custom
342359 actions in the wrappers.
@@ -510,6 +527,18 @@ scalar
510527
511528.. function pointers meta[deref] for both the +external and +funptr.
512529
530+ destructor_name
531+ ^^^^^^^^^^^^^^^
532+
533+ Specifies a name in the **destructors ** section which lists code to be used to
534+ release memory. Used with function results.
535+ It is used in the *C_memory_dtor_function * and will have the
536+ variable ``void *ptr `` available as the pointer to the memory
537+ to be released.
538+ See :ref: `MemoryManagementAnchor ` for details.
539+
540+ .. and *intent(out)* arguments.
541+
513542 dimension
514543^^^^^^^^^
515544
@@ -589,18 +618,6 @@ as the dummy argument for the function pointer.
589618See also the *funptr * attribute.
590619See :ref: `DeclAnchor_Function_Pointers `.
591620
592- free_pattern
593- ^^^^^^^^^^^^
594-
595- A name in the **patterns ** section which lists code to be used to
596- release memory. Used with function results.
597- It is used in the *C_memory_dtor_function * and will have the
598- variable ``void *ptr `` available as the pointer to the memory
599- to be released.
600- See :ref: `MemoryManagementAnchor ` for details.
601-
602- .. and *intent(out)* arguments.
603-
604621funcarg
605622^^^^^^^
606623
0 commit comments