Example #1
0
static void
ase_metric_prnt(Lisp_Object obj, Lisp_Object pcf, int unused)
{
	EMOD_ASE_DEBUG_METR("m:0x%08x@0x%08x (rc:%d)\n",
			    (unsigned int)(XASE_METRIC(obj)),
			    (unsigned int)obj, 1);
	write_c_string("#<", pcf);
	print_internal(XDYNACAT_TYPE(obj), pcf, unused);
	{
		if (NILP(XASE_METRIC_LDIST(obj))) {
			write_hex_ptr(XASE_METRIC_DIST(obj),pcf);
		} else {
			Lisp_Object ldist = XASE_METRIC_LDIST(obj);
			if (SYMBOLP(ldist)) {
				Lisp_String *name =
					symbol_name(XSYMBOL(ldist));
				write_fmt_string(pcf, " #'%s", string_data(name));
			} else if (SUBRP(ldist)) {
				const char *name = subr_name(XSUBR(ldist));
				write_fmt_string(pcf, " #'%s", name);
			} else {
				write_c_string(" #'(lambda ...)", pcf);
			}
		}
	}
	write_c_string(">", pcf);
	return;
}
Example #2
0
static void
store_function_docstring (Lisp_Object obj, ptrdiff_t offset)
{
  /* Don't use indirect_function here, or defaliases will apply their
     docstrings to the base functions (Bug#2603).  */
  Lisp_Object fun = SYMBOLP (obj) ? XSYMBOL (obj)->function : obj;

  /* The type determines where the docstring is stored.  */

  /* Lisp_Subrs have a slot for it.  */
  if (SUBRP (fun))
    {
      intptr_t negative_offset = - offset;
      XSUBR (fun)->doc = (char *) negative_offset;
    }

  /* If it's a lisp form, stick it in the form.  */
  else if (CONSP (fun))
    {
      Lisp_Object tem;

      tem = XCAR (fun);
      if (EQ (tem, Qlambda) || EQ (tem, Qautoload)
	  || (EQ (tem, Qclosure) && (fun = XCDR (fun), 1)))
	{
	  tem = Fcdr (Fcdr (fun));
	  if (CONSP (tem) && INTEGERP (XCAR (tem)))
	    /* FIXME: This modifies typically pure hash-cons'd data, so its
	       correctness is quite delicate.  */
	    XSETCAR (tem, make_number (offset));
	}
      else if (EQ (tem, Qmacro))
	store_function_docstring (XCDR (fun), offset);
    }

  /* Bytecode objects sometimes have slots for it.  */
  else if (COMPILEDP (fun))
    {
      /* This bytecode object must have a slot for the
	 docstring, since we've found a docstring for it.  */
      if ((ASIZE (fun) & PSEUDOVECTOR_SIZE_MASK) > COMPILED_DOC_STRING)
	ASET (fun, COMPILED_DOC_STRING, make_number (offset));
      else
	{
	  AUTO_STRING (format, "No docstring slot for %s");
	  CALLN (Fmessage, format,
		 (SYMBOLP (obj)
		  ? SYMBOL_NAME (obj)
		  : build_string ("<anonymous>")));
	}
    }
}
Example #3
0
File: doc.c Project: rradonic/emacs
static void
store_function_docstring (Lisp_Object obj, EMACS_INT offset)
/* Use EMACS_INT because we get offset from pointer subtraction.  */
{
    /* Don't use indirect_function here, or defaliases will apply their
       docstrings to the base functions (Bug#2603).  */
    Lisp_Object fun = SYMBOLP (obj) ? XSYMBOL (obj)->function : obj;

    /* The type determines where the docstring is stored.  */

    /* Lisp_Subrs have a slot for it.  */
    if (SUBRP (fun))
    {
        intptr_t negative_offset = - offset;
        XSUBR (fun)->doc = (char *) negative_offset;
    }

    /* If it's a lisp form, stick it in the form.  */
    else if (CONSP (fun))
    {
        Lisp_Object tem;

        tem = XCAR (fun);
        if (EQ (tem, Qlambda) || EQ (tem, Qautoload)
                || (EQ (tem, Qclosure) && (fun = XCDR (fun), 1)))
        {
            tem = Fcdr (Fcdr (fun));
            if (CONSP (tem) && INTEGERP (XCAR (tem)))
                XSETCAR (tem, make_number (offset));
        }
        else if (EQ (tem, Qmacro))
            store_function_docstring (XCDR (fun), offset);
    }

    /* Bytecode objects sometimes have slots for it.  */
    else if (COMPILEDP (fun))
    {
        /* This bytecode object must have a slot for the
        docstring, since we've found a docstring for it.  */
        if ((ASIZE (fun) & PSEUDOVECTOR_SIZE_MASK) > COMPILED_DOC_STRING)
            ASET (fun, COMPILED_DOC_STRING, make_number (offset));
    }
}