relicense to 0BSD
[pforth] / csrc / pforth.h
CommitLineData
8e9db35f
PB
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**
1f99f95d
S
13** Permission to use, copy, modify, and/or distribute this
14** software for any purpose with or without fee is hereby granted.
15**
16** THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
17** WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
18** WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
19** THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR
20** CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING
21** FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
22** CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
23** OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
8e9db35f
PB
24**
25**
26***************************************************************/
27
28/* Define stubs for data types so we can pass pointers but not touch inside. */
29typedef void *PForthTask;
30typedef void *PForthDictionary;
31
32#include <stdint.h>
33/* Integer types for Forth cells, signed and unsigned: */
34typedef intptr_t cell_t;
35typedef uintptr_t ucell_t;
36
37typedef ucell_t ExecToken; /* Execution Token */
38typedef cell_t ThrowCode;
39
40#ifdef __cplusplus
41extern "C" {
42#endif
43
44/* Main entry point to pForth. */
529bb4e2 45ThrowCode pfDoForth( const char *DicName, const char *SourceName, cell_t IfInit );
8e9db35f
PB
46
47/* Turn off messages. */
48void pfSetQuiet( cell_t IfQuiet );
49
50/* Query message status. */
51cell_t pfQueryQuiet( void );
52
53/* Send a message using low level I/O of pForth */
54void pfMessage( const char *CString );
55
56/* Create a task used to maintain context of execution. */
57PForthTask pfCreateTask( cell_t UserStackDepth, cell_t ReturnStackDepth );
58
59/* Establish this task as the current task. */
60void pfSetCurrentTask( PForthTask task );
61
62/* Delete task created by pfCreateTask */
63void pfDeleteTask( PForthTask task );
64
65/* Build a dictionary with all the basic kernel words. */
66PForthDictionary pfBuildDictionary( cell_t HeaderSize, cell_t CodeSize );
67
68/* Create an empty dictionary. */
69PForthDictionary pfCreateDictionary( cell_t HeaderSize, cell_t CodeSize );
70
71/* Load dictionary from a file. */
72PForthDictionary pfLoadDictionary( const char *FileName, ExecToken *EntryPointPtr );
73
74/* Load dictionary from static array in "pfdicdat.h". */
75PForthDictionary pfLoadStaticDictionary( void );
76
77/* Delete dictionary data. */
78void pfDeleteDictionary( PForthDictionary dict );
79
80/* Execute the pForth interpreter. Yes, QUIT is an odd name but it has historical meaning. */
81ThrowCode pfQuit( void );
82
83/* Execute a single execution token in the current task and return 0 or an error code. */
529bb4e2 84ThrowCode pfCatch( ExecToken XT );
8e9db35f
PB
85
86/* Include the given pForth source code file. */
87ThrowCode pfIncludeFile( const char *FileName );
88
89/* Execute a Forth word by name. */
90ThrowCode pfExecIfDefined( const char *CString );
91
92#ifdef __cplusplus
93}
94#endif
95
96#endif /* _pforth_h */