functions.c

MudOSa4DGD/mudlib/dgd/lib/sys/efun/functions.c · 1.5 KB

From the archive MudOSa4DGD-30.06.98.tar.gz

Download the archive   « Back to the archive contents

/*
 * functions.c
 *
 * Div. function functions d:-D
 *
 * (C) Frank Schmidt, Jesus@NorseMUD
 *
 */


#ifdef MUDOS_FUNCTION_EXISTS

/* find filename of a given function in an object */
static varargs string function_exists(string func, object ob) {
  return ::function_object(func, ob ? ob : this_object());
}

#endif


/* Get the previous function for the current function-n
   using the call_trace() kfun in DGD */
static varargs string previous_function(int n) {
  int size;
  mixed *trace, *elem;
  trace = ::call_trace();
  size = ::sizeof(trace);
  if (size >= 3+n) {
    elem = trace[size-3-n];
    return elem[TRACE_FUNCTION];
  }
  return 0;
}


/* determine if current function-n was called locally */
static varargs int called_locally(int n) {
  int size;
  mixed *trace, *elem;
  trace = ::call_trace();
  size = ::sizeof(trace);
  if (size >= 2+n) {
    elem = trace[size-2-n];
    return !elem[TRACE_EXTERNAL];
  }
  return 0;
}


/* determine the objectfile that called us last-n (can be current file) */
static varargs string calling_file(int n) {
  int size;
  mixed *trace, *elem;
  trace = ::call_trace();
  size = ::sizeof(trace);
  if (size >= 3+n) {
    elem = trace[size-3-n];
    return elem[TRACE_OBJNAME];
  }
  return 0;
}


/* determine the object that called us last-n (can be this_object()) */
static varargs object calling_object(int n) {
  int size;
  mixed *trace, *elem;
  trace = ::call_trace();
  size = ::sizeof(trace);
  if (size >= 3+n) {
    elem = trace[size-3-n];
    return find_object(elem[TRACE_OBJNAME]);
  }
  return 0;
}

Site Stats

Snippets: 1791
Codebases: 571