Merge pull request #60 from philburk/usefromjuce
[debian/pforth] / csrc / pforth.h
1 /* @(#) pforth.h 98/01/26 1.2 */
2 #ifndef _pforth_h
3 #define _pforth_h
4
5 /***************************************************************
6 ** Include file for pForth, a portable Forth based on 'C'
7 **
8 ** This file is included in any application that uses pForth as a tool.
9 **
10 ** Author: Phil Burk
11 ** Copyright 1994 3DO, Phil Burk, Larry Polansky, David Rosenboom
12 **
13 ** The pForth software code is dedicated to the public domain,
14 ** and any third party may reproduce, distribute and modify
15 ** the pForth software code or any derivative works thereof
16 ** without any compensation or license.  The pForth software
17 ** code is provided on an "as is" basis without any warranty
18 ** of any kind, including, without limitation, the implied
19 ** warranties of merchantability and fitness for a particular
20 ** purpose and their equivalents under the laws of any jurisdiction.
21 **
22 **
23 ***************************************************************/
24
25 /* Define stubs for data types so we can pass pointers but not touch inside. */
26 typedef void *PForthTask;
27 typedef void *PForthDictionary;
28
29 #include <stdint.h>
30 /* Integer types for Forth cells, signed and unsigned: */
31 typedef intptr_t cell_t;
32 typedef uintptr_t ucell_t;
33
34 typedef ucell_t ExecToken;              /* Execution Token */
35 typedef cell_t ThrowCode;
36
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40
41 /* Main entry point to pForth. */
42 ThrowCode pfDoForth( const char *DicName, const char *SourceName, cell_t IfInit );
43
44 /* Turn off messages. */
45 void  pfSetQuiet( cell_t IfQuiet );
46
47 /* Query message status. */
48 cell_t  pfQueryQuiet( void );
49
50 /* Send a message using low level I/O of pForth */
51 void  pfMessage( const char *CString );
52
53 /* Create a task used to maintain context of execution. */
54 PForthTask pfCreateTask( cell_t UserStackDepth, cell_t ReturnStackDepth );
55
56 /* Establish this task as the current task. */
57 void  pfSetCurrentTask( PForthTask task );
58
59 /* Delete task created by pfCreateTask */
60 void  pfDeleteTask( PForthTask task );
61
62 /* Build a dictionary with all the basic kernel words. */
63 PForthDictionary pfBuildDictionary( cell_t HeaderSize, cell_t CodeSize );
64
65 /* Create an empty dictionary. */
66 PForthDictionary pfCreateDictionary( cell_t HeaderSize, cell_t CodeSize );
67
68 /* Load dictionary from a file. */
69 PForthDictionary pfLoadDictionary( const char *FileName, ExecToken *EntryPointPtr );
70
71 /* Load dictionary from static array in "pfdicdat.h". */
72 PForthDictionary pfLoadStaticDictionary( void );
73
74 /* Delete dictionary data. */
75 void  pfDeleteDictionary( PForthDictionary dict );
76
77 /* Execute the pForth interpreter. Yes, QUIT is an odd name but it has historical meaning. */
78 ThrowCode pfQuit( void );
79
80 /* Execute a single execution token in the current task and return 0 or an error code. */
81 ThrowCode pfCatch( ExecToken XT );
82
83 /* Include the given pForth source code file. */
84 ThrowCode pfIncludeFile( const char *FileName );
85
86 /* Execute a Forth word by name. */
87 ThrowCode  pfExecIfDefined( const char *CString );
88
89 #ifdef __cplusplus
90 }
91 #endif
92
93 #endif  /* _pforth_h */