On Wed, Oct 16, 2002 at 03:55:02PM +0100, Mark Fowler wrote:
> What's the general thoughts in adding even more DWIM to C constructors?
> Extra bloat or needed syntatic sugar?
Not sure if it's either. I want the functionality, but I'm not convinced
that I like the DWIM, as it involves breaking the one to one correspondence
between C parameters and perl parameters.
> As a random thought I was having the other day, it'd be nice if the
> following automagically worked:
>
> void functionname(char* foo, STRLEN foo_length)
> {
> ....
>
> Which can be called from perl like so:
>
> functionname("this is my string, do you like it?")
>
> And both foo and foo_length get filled in. What do we think? Conditions
> for the DWIM to kick in are:
>
> a) A char* (or similar) followed by a STRLEN.
>
> b) The STRLEN variable name is the same as the char* but has _length
> attached on the end.
>
> Does this kind of thing make sense, or am I just muddying the waters here?
How about Inline defining a C struct that is
{
char *buffer;
STRLEN length;
}
and a typemap, and if you specify one of those (I think not a pointer to a
struct, but the struct itself) as a single parameter to the function, then
it gets the two initialised from the perl scalar.
The other thing I'd like (more often than this, actually) is a way to say
char *, but if the scalar is undef, give me NULL rather than "" and a perl
warning about an uninitialized value.
Nicholas Clark
--
Even better than the real thing: http://nms-cgi.sourceforge.net/