[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]

Re: Newer xsubpp



On Sun, Jan 23, 2000 at 05:31:44PM -0800, Larry Wall wrote:
> Hmm, the difficulty of creating out parameters was somewhat intentional.
> While you might want the capability in a "thin" interface if the
> underlying C interface happens to use out parameters, we'd generally
> like to encourage people to use a more Perlistic approach of returning
> multiple values.

Yes, this is exactly what my patch does.  Maybe take Tim's comment on
happiness of people who know the converted C API better than Perl, and
rename out to outlist, inout to in_outlist?

> : Another area of possible improvement is simplification of treatement
> : of C API which takes length of strings.
> 
> Yes, that would be good.
> 
> I just wish the average C api was as well specified (and as inspectable)
> as the average Java api.  With Java one can write all the glue code
> automatically.  (In fact, that's precisely what JPL does.)

With dynamic strings it is easy.  But with C?  I found a function with
the following API recently (in a possible future xsubpp syntax):

  NOOUTPUT int_as_0_is_success_or_positive_errno_then_return_empty
  f(in int length(s), inout char s[], out int length(s));

Currently the xsubpp I have would not be able to handle this
declaration, but when it does, it would be used as

  ($out) = f($in) or die "f($in) reports error: $!";

Here NOOUTPUT is a shortcut for an empty OUTPUT list (so the retval is
ignored), the type int_as_0_is_success_or_positive_errno_then_return_empty
can be treated in a typemap, the rest (all the complications of in-length,
out-length and inout-ness of s) should be treated by xsubpp.

Well, maybe one would want to allow something like

  out int length(s)=MAXPATHLEN

in the above declaration to request a preallocation of buffer of this size...

Ilya


References to:
Ilya Zakharevich <ilya@math.ohio-state.edu>
Larry Wall <larry@wall.org>

[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]