[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: "load" on Windows
From: |
Eli Zaretskii |
Subject: |
Re: "load" on Windows |
Date: |
Sat, 05 Oct 2013 16:34:11 +0300 |
> From: "Gisle Vanem" <address@hidden>
> Date: Sat, 5 Oct 2013 14:33:26 +0200
>
> "Eli Zaretskii" <address@hidden> wrote:
>
> > Well, the tests in the test suite that test this feature did work for
> > me at some point, so you may wish first to verify they do for you, and
> > then compare your extension with the ones used by the test suite, to
> > see what's different.
>
> Well this is just silly. I've added tracing code a lot of places (enabled
> by option --trace) . I do see my mk_test_gmk_setup() gets called, but not
> the new function added by gmk_add_function().
>
> gmk_add_function() calls define_new_function(), but therein I see a:
> ent->fptr.alloc_func_ptr = func;
>
> What about setting:
> ent->fptr.func_ptr = func;
>
> too?
They are one and the same, since they are members of a union:
struct function_table_entry
{
union {
char *(*func_ptr) (char *output, char **argv, const char *fname);
char *(*alloc_func_ptr) (const char *fname, int argc, char **argv);
} fptr;
> How else is the new function supposed to be called? I don't understand
> this contorted logic.
I don't understand the question, sorry. The logic looks quite simple
to me: In expand_builtin_function we have:
if (!entry_p->alloc_fn)
return entry_p->fptr.func_ptr (o, argv, entry_p->name);
/* This function allocates memory and returns it to us.
Write it to the variable buffer, then free it. */
p = entry_p->fptr.alloc_func_ptr (entry_p->name, argc, argv);
if (p)
{
o = variable_buffer_output (o, p, strlen (p));
free (p);
}
For loaded functions, define_new_function has this:
ent->alloc_fn = 1;
ent->fptr.alloc_func_ptr = func;
So expand_builtin_function should see that alloc_fn is non-zero, and
invoke your function via the alloc_func_ptr pointer.
> For reference, here is my complete mk_test.c:
Thanks. Your problem is here:
> EXPORT int mk_test_gmk_setup (const gmk_floc *flocp)
> {
> gmk_add_function ("hello_world", hello_world, 0, 255, 0);
^^^^^^^^^^^
Make functions cannot have the '_' character in their names, so it
seems. Here's why:
/* Look up a function by name. */
static const struct function_table_entry *
lookup_function (const char *s)
{
const char *e = s;
while (*e && ( (*e >= 'a' && *e <= 'z') || *e == '-')) <<<<<<<<<<<<
e++;
So if you name your function hello-world instead, it will work.
Paul, if this limitation is deliberate, I suggest to document it where
we explain the arguments of gmk_add_function.
Btw, Gisle, I don't understand why you needed to use the EXPORT
thingy, the DLL is compiled just fine without it, and only exports
non-static variables and functions anyway. Doing away with it makes
the code portable to platforms other than Windows.
- "load" on Windows, Gisle Vanem, 2013/10/03
- Re: "load" on Windows, Eli Zaretskii, 2013/10/03
- Re: "load" on Windows, Gisle Vanem, 2013/10/03
- Re: "load" on Windows, Eli Zaretskii, 2013/10/04
- Re: "load" on Windows, Eli Zaretskii, 2013/10/04
- Re: "load" on Windows, Gisle Vanem, 2013/10/05
- Re: "load" on Windows,
Eli Zaretskii <=
- Re: "load" on Windows, Eli Zaretskii, 2013/10/05
- Re: "load" on Windows, David Boyce, 2013/10/05
- Re: "load" on Windows, Eli Zaretskii, 2013/10/05
- Re: "load" on Windows, Paul Smith, 2013/10/05
- Re: "load" on Windows, Gisle Vanem, 2013/10/05