<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
<TITLE> {The S-lang C Library Reference}: SLclass_register_class</TITLE>
<LINK HREF="cref-42.html" REL=next>
<LINK HREF="cref-40.html" REL=previous>
<LINK HREF="cref.html#toc41" REL=contents>
</HEAD>
<BODY>
<A HREF="cref-42.html">Next</A>
<A HREF="cref-40.html">Previous</A>
<A HREF="cref.html#toc41">Contents</A>
<HR>
<H2><A NAME="SLclass_register_class"></A> <A NAME="s41">41. <B>SLclass_register_class</B></A></H2>

<P>
<DL>
<DT><B> Synopsis </B><DD><P>Register a new data type with the interpreter
<DT><B> Usage </B><DD><P><CODE>int SLclass_register_class (cl, type, sizeof_type, class_type)</CODE>
<BLOCKQUOTE><CODE>
<PRE>
    SLang_Class_Type *cl
    unsigned char type
    unsigned int sizeof_type
    unsigned char class_type
</PRE>
</CODE></BLOCKQUOTE>
<DT><B> Description </B><DD><P>The <CODE>SLclass_register_class</CODE> function is used to register a new
class or data type with the interpreter.  If successful, the
function returns <CODE>0</CODE>, or upon failure, it returns <CODE>-1</CODE>.
<P>The first parameter, <CODE>cl</CODE>, must have been previously obtained
via the <CODE>SLclass_allocate_class</CODE> function.
<P>The second parameter, <CODE>type</CODE> specifies the data type of the new
class.  It must be an unsigned character with value greater that
<CODE>127</CODE>.  The values in the range <CODE>0-127</CODE> are reserved for
internal use by the library.
<P>The size that the data type represents in bytes is specified by the
third parameter, <CODE>sizeof_type</CODE>.   This value should not be
confused with the sizeof the structure that represents the data
type, unless the data type is of class <CODE>SLANG_CLASS_TYPE_VECTOR</CODE>
or <CODE>SLANG_CLASS_TYPE_SCALAR</CODE>.  For pointer objects, the value
of this parameter is just <CODE>sizeof(void *)</CODE>.
<P>The final parameter specifies the class type of the data type.  It must
be one of the values:
<BLOCKQUOTE><CODE>
<PRE>
     SLANG_CLASS_TYPE_SCALAR
     SLANG_CLASS_TYPE_VECTOR
     SLANG_CLASS_TYPE_PTR
     SLANG_CLASS_TYPE_MMT
</PRE>
</CODE></BLOCKQUOTE>

The <CODE>SLANG_CLASS_TYPE_SCALAR</CODE> indicates that the new data type
is a scalar.  Examples of scalars in <CODE>SLANG_INT_TYPE</CODE> and
<CODE>SLANG_DOUBLE_TYPE</CODE>.
<P>Setting <CODE>class_type</CODE> to SLANG_CLASS_TYPE_VECTOR implies that the
new data type is a vector, or a 1-d array of scalar types.  An
example of a data type of this class is the
<CODE>SLANG_COMPLEX_TYPE</CODE>, which represents complex numbers.
<P><CODE>SLANG_CLASS_TYPE_PTR</CODE> specifies the data type is of a pointer
type.  Examples of data types of this class include
<CODE>SLANG_STRING_TYPE</CODE> and <CODE>SLANG_ARRAY_TYPE</CODE>.  Such types must
provide for their own memory management.
<P>Data types of class <CODE>SLANG_CLASS_TYPE_MMT</CODE> are pointer types
except that the memory management, i.e., creation and destruction of
the type, is handled by the interpreter.  Such a type is called a
<EM>memory managed type</EM>.  An example of this data type is the
<CODE>SLANG_FILEPTR_TYPE</CODE>.
<DT><B> Notes </B><DD><P>See the <EM>S-Lang Library C Programmer's Guide</EM> for more information.
<DT><B> See Also </B><DD><P><CODE>SLclass_allocate_class</CODE>
</DL>
<P>
<P>
<P>
<HR>
<A HREF="cref-42.html">Next</A>
<A HREF="cref-40.html">Previous</A>
<A HREF="cref.html#toc41">Contents</A>
</BODY>
</HTML>
