Re: metaprogramming question

2010-04-19 Thread fawcett
On 10-04-19 01:31 AM, BCS wrote: Hello Justin Spahr-Summers, On Mon, 19 Apr 2010 00:12:28 + (UTC), Graham Fawcett wrote: Hi folks, I'd like to wrap a family of C functions that look like this: gboolean fooXXX(arg1, ..., argN, GError** err) Their signatures and arities vary, but they a

Re: metaprogramming question

2010-04-18 Thread Philippe Sigaud
On Mon, Apr 19, 2010 at 07:43, Justin Spahr-Summers < justin.spahrsumm...@gmail.com> wrote: > > Yes, sorry. That's what I was trying to do originally, but I couldn't > quite spit it out. Indeed, templating the actual arguments is a horrible > idea. > Sorry to comment on it, then. I'm discovering

Re: metaprogramming question

2010-04-18 Thread Philippe Sigaud
On Mon, Apr 19, 2010 at 07:31, BCS wrote: > Or you can mangel that a bit: > > template check(alias func) { > bool check(EL ...)() { > > GError* err; > bool ok = func(EL, &err); > if (!ok) >throw new Exception((*err).message); > return ok; > } > } > > that should allow yo

Re: metaprogramming question

2010-04-18 Thread Justin Spahr-Summers
On Mon, 19 Apr 2010 07:28:09 +0200, Philippe Sigaud wrote: > > On Mon, Apr 19, 2010 at 05:21, Justin Spahr-Summers < > justin.spahrsumm...@gmail.com> wrote: > > > You can use some expression tuple magic to accomplish something like > > that: > > > > bool check(alias func, EL ...)() { > >GEr

Re: metaprogramming question

2010-04-18 Thread BCS
Hello Justin Spahr-Summers, On Mon, 19 Apr 2010 00:12:28 + (UTC), Graham Fawcett wrote: Hi folks, I'd like to wrap a family of C functions that look like this: gboolean fooXXX(arg1, ..., argN, GError** err) Their signatures and arities vary, but they all have a GError** as their last a

Re: metaprogramming question

2010-04-18 Thread BCS
Hello Philippe, Of course, it'd be nice to check the EL at CT to see if they correspond to func parameters types. The call inside check will coever that for you as long as you don't mind getting the error in an odd place. -- ... <

Re: metaprogramming question

2010-04-18 Thread Philippe Sigaud
On Mon, Apr 19, 2010 at 05:21, Justin Spahr-Summers < justin.spahrsumm...@gmail.com> wrote: > You can use some expression tuple magic to accomplish something like > that: > > bool check(alias func, EL ...)() { >GError* err; >bool ok = func(EL, &err); > if (!ok) >throw new Excep

Re: metaprogramming question

2010-04-18 Thread Daniel Keep
http://while-nan.blogspot.com/2007/06/wrapping-functions-for-fun-and-profit.html It shouldn't be too difficult to inject an extra parameter; just add it to the end of the call to the wrapped function after args.

Re: metaprogramming question

2010-04-18 Thread Justin Spahr-Summers
On Mon, 19 Apr 2010 00:12:28 + (UTC), Graham Fawcett wrote: > > Hi folks, > > I'd like to wrap a family of C functions that look like this: > > gboolean fooXXX(arg1, ..., argN, GError** err) > > Their signatures and arities vary, but they all have a GError** as > their last argument

metaprogramming question

2010-04-18 Thread Graham Fawcett
Hi folks, I'd like to wrap a family of C functions that look like this: gboolean fooXXX(arg1, ..., argN, GError** err) Their signatures and arities vary, but they all have a GError** as their last argument. If a function returns false, then 'err' will be set to a relevant Error struct. I