fp.c

MudOSa4DGD/mudlib/dgd/lib/sys/efun/fp.c · 621 B

From the archive MudOSa4DGD-30.06.98.tar.gz

Download the archive   « Back to the archive contents

/*
 * fp.c
 *
 * define functions for functionpointers
 *
 * (C) Frank Schmidt, Jesus@NorseMUD
 *
 */


/* test if <var> is a function */
static int functionp(mixed var) {
  if (arrayp(var) && ::sizeof(var) == 2 && stringp(_FUNC(var))) {
    switch (typeof(_OB(var))) {
    case T_OBJECT:
    case T_STRING:
      return 1;
    }
  }
  return 0;
}


/* call a functionpointer with some arguments */
static varargs mixed call_fp(mixed fp, mixed args...) {
  if (functionp(fp))
    return __call_other(_OB(fp), _FUNC(fp), args...);
  error("Illegal argument 1 to function call_fp(), needs functionpointer.");
  return 0;
}

Site Stats

Snippets: 1791
Codebases: 571