[Fwd: Re: Wrapping variable length agument lists]

2004-08-25 Thread Sisyphus
Nicholas Clark wrote: > > I think that it's possible to partly work round this by prototyping your > function (at the perl level), but in turn I don't think that Inline can do > this; you'd need XS. > > But even that doesn't really solve the problem at perl level, as > @a = (%d\n%#o\n", $x, $y);

Re: Wrapping variable length agument lists

2004-08-23 Thread Nicholas Clark
On Thu, Aug 19, 2004 at 01:42:14PM +1000, Sisyphus wrote: > void wrap_printf(AV * arguments) { > /* Code to transfer the referred arguments to C's printf() function */ > } > > I don't know, off the top of my head, exactly what *that* "Code" looks > like either - though I'm confident I can work i

Re: Wrapping variable length agument lists

2004-08-23 Thread Ken Williams
On Aug 21, 2004, at 10:42 PM, Sisyphus wrote: I've struck something similar. I was trying the following (which I thought *should* work, but which prints out a couple of wrong values, then segfaults): [...] It looks to me like this is an Inline bug/nonfeature, not a generic C issue. Look at the

Re: Wrapping variable length agument lists

2004-08-21 Thread Sisyphus
Eric Wilhelm wrote: # The following was supposedly scribed by # Eric Wilhelm # on Saturday 21 August 2004 07:38 pm: Is there a "vgmp_printf" function? Sounds like you'll need one. Okay, there is gmp_vprintf(), but it isn't going to do you any good. Looking at the minprintf() example in K&R's "Th

Re: Wrapping variable length agument lists

2004-08-21 Thread Sisyphus
Eric Wilhelm wrote: http://www.faqs.org/faqs/C-faq/faq/index.html " 15.12: How can I write a function which takes a variable number of arguments and passes them to some other function (which takes a variable number of arguments)? Bah I consulted that very same FAQ a coupla day

Re: Wrapping variable length agument lists

2004-08-21 Thread Sisyphus
Eric Wilhelm wrote: Okay, but if they are all the same type of objects, you are basically only trying to wrap something like printf("%s %s %s %s", s1, s2, s3, s4) and we can forget about trying to detect integers vs floats and strings. Correct. Except, you have just said that you don't have to d

Re: Wrapping variable length agument lists

2004-08-21 Thread Eric Wilhelm
# The following was supposedly scribed by # Eric Wilhelm # on Saturday 21 August 2004 07:38 pm: >Is there a "vgmp_printf" function?  Sounds like you'll need one. Okay, there is gmp_vprintf(), but it isn't going to do you any good. Looking at the minprintf() example in K&R's "The C Programming La

Re: Wrapping variable length agument lists

2004-08-21 Thread Eric Wilhelm
# The following was supposedly scribed by # Eric Wilhelm # on Saturday 21 August 2004 07:28 pm: >>Hmmm I've been starting to fear that there's going to be much more >>to this than I originally thought. The last part of that sentence does >>little to allay that fear :-) >So, you need a functi

Re: Wrapping variable length agument lists

2004-08-21 Thread Sisyphus
Eric Wilhelm wrote: > # The following was supposedly scribed by > # Sisyphus > # on Saturday 21 August 2004 12:53 am: > > >>> void c_printf(char *format, AV * arguments) { >>>... >> >> >> It's the code that goes in here that I'm struggling with. There's no >> problem with passing the first arg

Re: Wrapping variable length agument lists

2004-08-21 Thread Eric Wilhelm
# The following was supposedly scribed by # Sisyphus # on Saturday 21 August 2004 06:44 pm: >In reality, I would like to wrap the GMP library's gmp_printf function. >That function is analogous to C's printf function - it takes a 'char * >format' as its first argument, followed by however many GMP

Re: Wrapping variable length agument lists

2004-08-21 Thread Eric Wilhelm
# The following was supposedly scribed by # Sisyphus # on Saturday 21 August 2004 12:53 am: >>   void c_printf(char *format, AV * arguments) { >>     ... > >It's the code that goes in here that I'm struggling with. There's no >problem with passing the first argument to C's printf function, but how

Re: Wrapping variable length agument lists

2004-08-20 Thread Sisyphus
[EMAIL PROTECTED] wrote: An alternative in c: You can also make a new va_list out of the old one. It's basically an array of void pointers. So you va_start, va_arg and repopulate the second array with appropriate void casted pointers. You can then vprintf on this hacked va_list. I wasn't fami

Re: Wrapping variable length agument lists

2004-08-20 Thread Sisyphus
Williams, Kenneth (Ken) (TLR Corp) wrote: Hey Rob, One approach would be to use a wrapper wrapper: use Inline C => <<'EOC'; void c_printf(char *format, AV * arguments) { ... It's the code that goes in here that I'm struggling with. There's no problem with passing the first argument to C's pr

RE: Wrapping variable length agument lists

2004-08-19 Thread Williams, Kenneth (Ken) (TLR Corp)
printf("%#o\n", $y); -Ken > -Original Message- > From: Sisyphus [mailto:[EMAIL PROTECTED] > Sent: Wednesday, August 18, 2004 10:42 PM > To: inline > Subject: Wrapping variable length agument lists > > > Hi, > > Suppose I wanted to write a wrapper

Wrapping variable length agument lists

2004-08-18 Thread Sisyphus
Hi, Suppose I wanted to write a wrapper for the C printf() function - something like: use warnings; use Inline C => <<'EOC'; void wrap_printf(SV * a, SV * b) { if(SvUOK(b)) printf(SvPV_nolen(a), SvUV(b)); if(SvIOK(b)) printf(SvPV_nolen(a), SvIV(b)); if(SvNOK(b)) printf(SvPV_nolen(a