示例#1
0
protected mixed execute_anything(mixed fun, varargs mixed args)
{
  if ( closurep(fun) && objectp(query_closure_object(fun)) )
    return apply(fun, args);

  if (stringp(fun))
    return call_other(this_object(), fun, args...);

  if ( pointerp(fun))
  {
    if (sizeof(fun) != 2)
      raise_error(sprintf("execute_anything(): <fun> argument must "
                         "have 2 elements if array.\n"));
    object ob;
    if ( stringp(fun[0]) )
      ob=find_object(fun[0]);
    else
      ob=fun[0];

    if ( !objectp(ob) || !stringp(fun[1]) )
      return 0;

    return call_other(ob, fun[1], args...);
  }
  return 0;
}
示例#2
0
/*
    Description:
      Prove knowledge of some secret.
    Parameters:
         ( mixed secret, closure cl, mixed extra )
      or ( mixed secret, object ob,  string func, mixed extra )

      secret - something you want to prove knowledge of
      cl     - a closure
      ob     - an object in which to call func
      func   - a function to call in ob
      extra  - an extra parameter to pass

      Depending on which form is used, one of these will be done:
            ob->func( hash, extra )
        or  funcall( hash, extra )
      where hash is the hash value of the secret: hash( secret )

    Returns:
      The return value of the call/eval.
    Notes:
      None.
*/
varargs mixed
prove( mixed val, mixed ob_or_cl, mixed func_or_extra, mixed extra )
{
  if( closurep( ob_or_cl ) )
    return funcall( (closure) ob_or_cl, hash( val ), func_or_extra );
  if( !objectp( ob_or_cl ) || !stringp( func_or_extra ))
    return 0;
  return call_other( (object) ob_or_cl, (string) func_or_extra, 
                     hash( val ), extra );
}
示例#3
0
/* check an item instance variable */
static LVAL check_item_ivar P2C(int, which, LVAL, value)
{
  int good=0;
  
  switch (which) {
  case 'T': good = (stringp(value) && strlen(getstring(value)) != 0); break;
  case 'K': good = (charp(value) || value == NIL); break;
  case 'M': good = (charp(value) || value == NIL || value == s_true); break;
  case 'S': good = (symbolp(value) || listp(value)); break;
  case 'A': good = (value == NIL || symbolp(value) || closurep(value) || subrp(value) || (bcclosurep(value))); break;
  case 'E': good = TRUE; value = (value != NIL) ? s_true : NIL; break;
  default:  xlfail("unknown item instance variable");
  }
  if (! good) xlerror("bad instance variable value", value);
  return(value);
}
示例#4
0
/* macroexpand - expand a macro call */
int macroexpand(LVAL fun, LVAL args, LVAL *pval)
{
    LVAL *argv;
    int argc;
    
    /* make sure it's really a macro call */
    if (!closurep(fun) || gettype(fun) != s_macro)
        return (FALSE);
        
    /* call the expansion function */
    argc = pushargs(fun,args);
    argv = xlfp + 3;
    *pval = evfun(fun,argc,argv);
    xlsp = xlfp;
    xlfp = xlfp - (int)getfixnum(*xlfp);
    return (TRUE);
}