<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
<TITLE> {The S-lang C Library Reference}: SLclass_set_push_function</TITLE>
<LINK HREF="cref-45.html" REL=next>
<LINK HREF="cref-43.html" REL=previous>
<LINK HREF="cref.html#toc44" REL=contents>
</HEAD>
<BODY>
<A HREF="cref-45.html">Next</A>
<A HREF="cref-43.html">Previous</A>
<A HREF="cref.html#toc44">Contents</A>
<HR>
<H2><A NAME="SLclass_set_push_function"></A> <A NAME="s44">44. <B>SLclass_set_push_function</B></A></H2>

<P>
<DL>
<DT><B> Synopsis </B><DD><P>Set the push callback for a new data type
<DT><B> Usage </B><DD><P><CODE>int SLclass_set_push_function (cl, push_fun)</CODE>
<BLOCKQUOTE><CODE>
<PRE>
    SLang_Class_Type *cl
    int (*push_fun) (unsigned char, VOID_STAR);
</PRE>
</CODE></BLOCKQUOTE>
<DT><B> Description </B><DD><P><CODE>SLclass_set_push_function</CODE> is used to set the push callback
for a new data type specified by <CODE>cl</CODE>, which must have been
previously obtained via <CODE>SLclass_allocate_class</CODE>.
<P>The parameter <CODE>push_fun</CODE> is a pointer to the push callback.  It
is required to take two arguments: an unsigned character
representing the data type, and the address of the object to be
pushed.  It must return zero upon success, or <CODE>-1</CODE> upon failure.
<P><CODE>SLclass_set_push_function</CODE> returns zero upon success, or <CODE>-1</CODE>
upon failure.
<DT><B> Example </B><DD><P>The push callback for <CODE>SLANG_COMPLEX_TYPE</CODE> looks like:
<BLOCKQUOTE><CODE>
<PRE>
      static int complex_push (unsigned char type, VOID_STAR ptr)
      {
         double *z = *(double **) ptr;
         return SLang_push_complex (z[0], z[1]);
      }
</PRE>
</CODE></BLOCKQUOTE>
<DT><B> See Also </B><DD><P><CODE>SLclass_allocate_class, SLclass_register_class</CODE>
</DL>
<P>
<P>
<P>
<HR>
<A HREF="cref-45.html">Next</A>
<A HREF="cref-43.html">Previous</A>
<A HREF="cref.html#toc44">Contents</A>
</BODY>
</HTML>
