[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Using WCTs as `out' parameters
From: |
Ludovic Courtès |
Subject: |
Using WCTs as `out' parameters |
Date: |
Wed, 23 Mar 2005 15:37:19 +0100 |
User-agent: |
Gnus/5.1007 (Gnus v5.10.7) Emacs/21.3 (gnu/linux) |
Hi,
I'm wondering: why can't one use a WCT as an out parameter? This is
forbidden in `c-types.scm' by the `check-typespec-options' method for
`<gw-wct>' objects.
Consider the following scenario. On the C side we have:
/* Allocate and initialize a new chbouib based on SEED. Return
ERR_INVALID_ARG if SEED is out of range and ENOMEM if allocation
failed. */
errcode_t allocate_and_initialize_a_chbouib (int seed,
chbouib_t **the_new_chbouib);
which one would want to specify like this:
(wrap-as-wct! ws
#:name '<chbouib>
#:c-type-name "chbouib_t *"
#:c-const-type-name "const chbouib_t *"
#:destroy-value-function-name "destroy_and_dealloc_a_chbouib")
(wrap-function! ws
#:name 'make-chbouib
#:c-name "allocate_and_initialize_a_chbouib"
#:returns '<errcode>
#:arguments '((int seed)
((<chbouib> out) the-new-chbouib)))
I looked at how GnuCash deals with this [1] and it seems that all the
`*-create' functions have a WCT as their return type and never use an
`out' WCT. This means that the caller can only know whether these
function fail, not why.
Thanks,
Ludovic.
[1]
https://cvs.gnucash.org/cgi-bin/cvsweb.cgi/gnucash/src/business/business-core/gw-business-core-spec.scm?rev=1.33
- Using WCTs as `out' parameters,
Ludovic Courtès <=