/* @(#) pf_cglue.c 98/02/11 1.4 */
/***************************************************************
** 'C' Glue support for Forth based on 'C'
** Copyright 1994 3DO, Phil Burk, Larry Polansky, David Rosenboom
** The pForth software code is dedicated to the public domain,
** and any third party may reproduce, distribute and modify
** the pForth software code or any derivative works thereof
** without any compensation or license. The pForth software
** code is provided on an "as is" basis without any warranty
** of any kind, including, without limitation, the implied
** warranties of merchantability and fitness for a particular
** purpose and their equivalents under the laws of any jurisdiction.
***************************************************************/
extern CFunc0 CustomFunctionTable
[];
/***************************************************************/
cell_t
CallUserFunction( cell_t Index
, int32_t ReturnMode
, int32_t NumParams
)
cell_t P1
, P2
, P3
, P4
, P5
;
DBUG(("CallUserFunction: Index = %d, ReturnMode = %d, NumParams = %d\n",
Index
, ReturnMode
, NumParams
));
CF
= CustomFunctionTable
[Index
];
Result
= ((CFunc0
) CF
) ( );
Result
= ((CFunc1
) CF
) ( P1
);
Result
= ((CFunc2
) CF
) ( P1
, P2
);
Result
= ((CFunc3
) CF
) ( P1
, P2
, P3
);
Result
= ((CFunc4
) CF
) ( P1
, P2
, P3
, P4
);
Result
= ((CFunc5
) CF
) ( P1
, P2
, P3
, P4
, P5
);
pfReportError("CallUserFunction", PF_ERR_NUM_PARAMS
);
/* Push result on Forth stack if requested. */
if(ReturnMode
== C_RETURNS_VALUE
) PUSH_DATA_STACK( Result
);
#if (!defined(PF_NO_INIT)) && (!defined(PF_NO_SHELL))
/***************************************************************/
Err
CreateGlueToC( const char *CName
, ucell_t Index
, cell_t ReturnMode
, int32_t NumParams
)
CStringToForth( FName
, CName
, sizeof(FName
) );
Packed
= (Index
& 0xFFFF) | 0 | (NumParams
<< 24) |
DBUG(("Packed = 0x%8x\n", Packed
));
ffCreateSecondaryHeader( FName
);