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