[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Load api - context?
Load api - context?
Thu, 7 Mar 2013 14:31:29 +0000
I was looking at the load api. It's quite clever and minimal whilst
allowing you to do almost anything you might ever need to do. I have
two thoughts about future proofing it. You might see them as
extraneous but they come from something else I'm looking at.
1) In another plugin mechanism that I was working on I wanted to give
my C plugins the ability to create memory which the C++ host could
safely delete without knowing that it came from a plugin. It removed
the need to reallocate and copy just to make it "compatible".
I needed to offer memory allocation and deallocation to the api. I
think that gmake should do this too so that differing memory
allocation schemes can't ever become a problem - e.g. if gmake starts
to use garbage collection, reference counting or anything like that
then there will be a natural and efficient way to let plugins work
2) There are reasons why this suggestion would suit me but for GNU
make at the moment it's not entirely relevant so you may consider it a
Functions have the following interface:
char *(*func)(const char *nm, int argc, char **argv)
I think it would be farsighted to add a void* context parameter to the
function call that must be passed onwards as the first parameter to
every call back into the api:
char *(*func)(void *context, const char *nm, int argc, char **argv)
void gmk_eval (void *context, const char *buffer, const gmk_floc *floc);
char *gmk_expand (void *context, const char *str);
void gmk_add_function (const char *name,
char *(*func)(void *context, const char *nm,
int argc, char **argv),
int min_args, int max_args, int expand_args);
Essentially if I create an "ifeq" function then it will receive a
"context" which it must pass on to "gmk_expand" when it calls that
part of the API.
This makes it a lot easier to implement lots of different features
within make without having to change plugins.
You could help some brave and decent people to have access to
uncensored news by making a donation at:
|[Prev in Thread]
||[Next in Thread]|
- Load api - context?,
Tim Murphy <=