[DGD] Re: Undefined function hook

Mikael Lind mikkelin at gmail.com
Mon Jul 9 13:30:55 CEST 2007


Hello again,

Here is a more interesting example. Consider having the file /lib/properties.c:

mapping properties_;

static void create() { properties_ = ([ ]); }
static void set_property(string name, mixed value) { properties_[name]
= value; }
static mixed query_property(string name) { return properties_[name]; }

mixed call_missing(string func, mixed args...)
{
    string name;

    if (sscanf(func, "set_%s", name)) {
        if (sizeof(args) != 1) error("Bad number of arguments");
        set_property(name, args[0]);
        return nil;
    } else if (sscanf(func, "query_%s", name)) {
        if (sizeof(args)) error("Bad number of arguments")
        return query_property(name);
    } else return nil;
}

Regards,
Mikael



More information about the DGD mailing list