home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
QBasic & Borland Pascal & C
/
Delphi5.iso
/
C
/
Samples
/
CSAPE32.ARJ
/
SOURCE
/
CSSRC
/
UFUNCOBJ.C
< prev
Wrap
C/C++ Source or Header
|
1990-08-24
|
3KB
|
129 lines
/*
ufuncobj.c
% ufunc_Class(), ufunc_Open()
User function objects
C-scape 3.2
Copyright (c) 1988, by Oakland Group, Inc.
ALL RIGHTS RESERVED.
Revision History:
-----------------
11/20/88 jmd add ID to objects
12/11/88 jmd removed GETPOS and GETSIZE message handling
added idata to _od
04/23/89 jdc added full support
11/06/89 jmd removed DoRaw Macro
11/21/89 ted Renamed ufunc xd and od bob kernels from cd to bd.
12/08/89 jmd added OGLOBAL
3/28/90 jmd ansi-fied
8/24/90 jdc added classhandle macros
*/
#include "sed.h"
#include "ufuncobj.h"
#include "ufuncod.h"
/* The ufunc bob class */
OGLOBAL objreq_fptr ufuncreq_loadfptr = objreq_Null;
OGLOBAL objreq_fptr ufuncreq_savefptr = objreq_Null;
int ufunc_Class(VOID *objdata, int msg, VOID *indata, VOID *outdata)
/*
Dispatch function for ufunc.
*/
{
ufunc_od *ufuncd;
ufuncopen_struct *ufuncopen;
obj_type ufunc;
ufuncd = (ufunc_od *) objdata;
if (msg != OBJM_GETDATASIZE) {
ufunc = ufuncod_GetSelf(ufuncd);
}
switch (msg) {
case OBJM_LOAD:
return((*ufuncreq_loadfptr)(objdata, msg, indata, outdata));
case OBJM_SAVE:
return((*ufuncreq_savefptr)(objdata, msg, indata, outdata));
case OBJM_GETDATASIZE:
((ogds_struct *) outdata)->odsize = sizeof(ufunc_od);
((ogds_struct *) outdata)->xdsize = sizeof(ufunc_xd);
((ogds_struct *) outdata)->id = ID_UFUNC;
break;
case OBJM_OPEN:
bob_SetDepend(ufunc, FALSE); /* ufuncs MUST be independent */
bob_SetParent(ufunc, NULL);
obj_SetClassHandle(ufunc, -1);
break;
case OBJM_INIT:
/* Initialize the ufuncbob_od (passed a ufuncopen_struct *) */
ufuncd->ufunc = ((ufuncopen_struct *) indata)->ufunc;
ufuncd->idata = ((ufuncopen_struct *) indata)->idata;
break;
case OBJM_WHO:
/* Identify ourselves */
return (*((int *) indata) == ID_UFUNC || *((int *) indata) == ID_BOB);
case WINM_GOREQ:
/* indata is a VOID *, outdata is an int * return code */
if (ufuncd->ufunc == FNULL) {
/* if our ufunc is FNULL, simply return idata */
*((int *) outdata) = ufuncd->idata;
}
else {
/* call the user func */
*((int *) outdata) = (*(ufuncd->ufunc))(indata, ufuncd->idata);
}
break;
case UFUNCBM_GETUFUNC:
/* outdata is a (ufuncopen_struct *) */
ufuncopen = (ufuncopen_struct *) outdata;
ufuncopen->ufunc = ufuncd->ufunc;
ufuncopen->idata = ufuncd->idata;
break;
default:
return(bob_Class(&(ufuncd->bd), msg, indata, outdata));
}
return(TRUE);
}
/* Auxillary Functions */
obj_type ufunc_Open(ufunc_fptr ufunc, int idata)
/*
Create an object from a ufunc.
*/
{
ufuncopen_struct ufuncopen;
bob_type bob;
if ((bob = obj_Open(ufunc_Class, NULL)) != NULL) {
ufuncopen.ufunc = ufunc;
ufuncopen.idata = idata;
bob_Do(bob, OBJM_INIT, &ufuncopen, NULL);
ufuncbob_SetFuncHandle(bob, -1); /* initialize */
}
return(bob);
}