jim license cleanup
[openocd.git] / src / helper / jim.h
1 /* Jim - A small embeddable Tcl interpreter
2 *
3 * Copyright 2005 Salvatore Sanfilippo <antirez@invece.org>
4 * Copyright 2005 Clemens Hintze <c.hintze@gmx.net>
5 * Copyright 2005 patthoyts - Pat Thoyts <patthoyts@users.sf.net>
6 * Copyright 2008 oharboe - √ėyvind Harboe - soyvind.harboe@zylin.com
7 * Copyright 2008 Andrew Lunn <andrew@lunn.ch>
8 * Copyright 2008 Duane Ellis <openocd@duaneellis.com>
9 * Copyright 2008 Uwe Klein <uklein@klein-messgeraete.de>
10 *
11 * The FreeBSD license
12 *
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following conditions
15 * are met:
16 *
17 * 1. Redistributions of source code must retain the above copyright
18 * notice, this list of conditions and the following disclaimer.
19 * 2. Redistributions in binary form must reproduce the above
20 * copyright notice, this list of conditions and the following
21 * disclaimer in the documentation and/or other materials
22 * provided with the distribution.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE JIM TCL PROJECT ``AS IS'' AND ANY
25 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
26 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
27 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
28 * JIM TCL PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
29 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
30 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
33 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
35 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36 *
37 * The views and conclusions contained in the software and documentation
38 * are those of the authors and should not be interpreted as representing
39 * official policies, either expressed or implied, of the Jim Tcl Project.
40 **/
41
42 #ifndef __JIM__H
43 #define __JIM__H
44
45 #ifdef __cplusplus
46 extern "C" {
47 #endif
48
49 #include <time.h>
50 #include <limits.h>
51 #include <stdio.h> /* for the FILE typedef definition */
52 #include <stdlib.h> /* In order to export the Jim_Free() macro */
53
54 /* -----------------------------------------------------------------------------
55 * Some /very/ old compiler maybe do not know how to
56 * handle 'const'. They even do not know, how to ignore
57 * it. For those compiler it may be better to compile with
58 * define JIM_NO_CONST activated
59 * ---------------------------------------------------------------------------*/
60
61 #ifdef JIM_NO_CONST
62 # define const
63 #endif
64
65 /* -----------------------------------------------------------------------------
66 * System configuration
67 * For most modern systems, you can leave the default.
68 * For embedded systems some change may be required.
69 * ---------------------------------------------------------------------------*/
70
71 #define HAVE_LONG_LONG
72
73 /* -----------------------------------------------------------------------------
74 * Compiler specific fixes.
75 * ---------------------------------------------------------------------------*/
76
77 /* MSC has _stricmp instead of strcasecmp */
78 #ifdef _MSC_VER
79 # define strcasecmp _stricmp
80 #endif /* _MSC_VER */
81
82 /* Long Long type and related issues */
83 #ifdef HAVE_LONG_LONG
84 # ifdef _MSC_VER /* MSC compiler */
85 # define jim_wide _int64
86 # ifndef LLONG_MAX
87 # define LLONG_MAX 9223372036854775807I64
88 # endif
89 # ifndef LLONG_MIN
90 # define LLONG_MIN (-LLONG_MAX - 1I64)
91 # endif
92 # define JIM_WIDE_MIN LLONG_MIN
93 # define JIM_WIDE_MAX LLONG_MAX
94 # else /* Other compilers (mainly GCC) */
95 # define jim_wide long long
96 # ifndef LLONG_MAX
97 # define LLONG_MAX 9223372036854775807LL
98 # endif
99 # ifndef LLONG_MIN
100 # define LLONG_MIN (-LLONG_MAX - 1LL)
101 # endif
102 # define JIM_WIDE_MIN LLONG_MIN
103 # define JIM_WIDE_MAX LLONG_MAX
104 # endif
105 #else
106 # define jim_wide long
107 # define JIM_WIDE_MIN LONG_MIN
108 # define JIM_WIDE_MAX LONG_MAX
109 #endif
110
111 /* -----------------------------------------------------------------------------
112 * LIBC specific fixes
113 * ---------------------------------------------------------------------------*/
114
115 #ifdef HAVE_LONG_LONG
116 # if defined(_MSC_VER) || defined(__MSVCRT__)
117 # define JIM_WIDE_MODIFIER "I64d"
118 # else
119 # define JIM_WIDE_MODIFIER "lld"
120 # endif
121 #else
122 # define JIM_WIDE_MODIFIER "ld"
123 #endif
124
125 /* -----------------------------------------------------------------------------
126 * Exported defines
127 * ---------------------------------------------------------------------------*/
128
129 /* Jim version numbering: every version of jim is marked with a
130 * successive integer number. This is version 0. The first
131 * stable version will be 1, then 2, 3, and so on. */
132 #define JIM_VERSION 51
133
134 #define JIM_OK 0
135 #define JIM_ERR 1
136 #define JIM_RETURN 2
137 #define JIM_BREAK 3
138 #define JIM_CONTINUE 4
139 #define JIM_EVAL 5
140 #define JIM_EXIT 6
141 #define JIM_MAX_NESTING_DEPTH 10000 /* default max nesting depth */
142
143 /* Some function get an integer argument with flags to change
144 * the behaviour. */
145 #define JIM_NONE 0 /* no flags set */
146 #define JIM_ERRMSG 1 /* set an error message in the interpreter. */
147
148 /* Flags for Jim_SubstObj() */
149 #define JIM_SUBST_NOVAR 1 /* don't perform variables substitutions */
150 #define JIM_SUBST_NOCMD 2 /* don't perform command substitutions */
151 #define JIM_SUBST_NOESC 4 /* don't perform escapes substitutions */
152
153 /* Unused arguments generate annoying warnings... */
154 #define JIM_NOTUSED(V) ((void) V)
155
156 /* Flags used by API calls getting a 'nocase' argument. */
157 #define JIM_CASESENS 0 /* case sensitive */
158 #define JIM_NOCASE 1 /* no case */
159
160 /* Filesystem related */
161 #define JIM_PATH_LEN 1024
162
163 /* Newline, some embedded system may need -DJIM_CRLF */
164 #ifdef JIM_CRLF
165 #define JIM_NL "\r\n"
166 #else
167 #define JIM_NL "\n"
168 #endif
169
170 #if defined(__WIN32__) || defined(_WIN32)
171 #define DLLEXPORT __declspec(dllexport)
172 #define DLLIMPORT __declspec(dllimport)
173 #else
174 #define DLLEXPORT
175 #define DLLIMPORT
176 #endif
177
178 /* -----------------------------------------------------------------------------
179 * Stack
180 * ---------------------------------------------------------------------------*/
181
182 typedef struct Jim_Stack {
183 int len;
184 int maxlen;
185 void **vector;
186 } Jim_Stack;
187
188 /* -----------------------------------------------------------------------------
189 * Hash table
190 * ---------------------------------------------------------------------------*/
191
192 typedef struct Jim_HashEntry {
193 const void *key;
194 void *val;
195 struct Jim_HashEntry *next;
196 } Jim_HashEntry;
197
198 typedef struct Jim_HashTableType {
199 unsigned int (*hashFunction)(const void *key);
200 const void *(*keyDup)(void *privdata, const void *key);
201 void *(*valDup)(void *privdata, const void *obj);
202 int (*keyCompare)(void *privdata, const void *key1, const void *key2);
203 void (*keyDestructor)(void *privdata, const void *key);
204 void (*valDestructor)(void *privdata, void *obj);
205 } Jim_HashTableType;
206
207 typedef struct Jim_HashTable {
208 Jim_HashEntry **table;
209 Jim_HashTableType *type;
210 unsigned int size;
211 unsigned int sizemask;
212 unsigned int used;
213 unsigned int collisions;
214 void *privdata;
215 } Jim_HashTable;
216
217 typedef struct Jim_HashTableIterator {
218 Jim_HashTable *ht;
219 int index;
220 Jim_HashEntry *entry, *nextEntry;
221 } Jim_HashTableIterator;
222
223 /* This is the initial size of every hash table */
224 #define JIM_HT_INITIAL_SIZE 16
225
226 /* ------------------------------- Macros ------------------------------------*/
227 #define Jim_FreeEntryVal(ht, entry) \
228 if ((ht)->type->valDestructor) \
229 (ht)->type->valDestructor((ht)->privdata, (entry)->val)
230
231 #define Jim_SetHashVal(ht, entry, _val_) do { \
232 if ((ht)->type->valDup) \
233 entry->val = (ht)->type->valDup((ht)->privdata, _val_); \
234 else \
235 entry->val = (_val_); \
236 } while(0)
237
238 #define Jim_FreeEntryKey(ht, entry) \
239 if ((ht)->type->keyDestructor) \
240 (ht)->type->keyDestructor((ht)->privdata, (entry)->key)
241
242 #define Jim_SetHashKey(ht, entry, _key_) do { \
243 if ((ht)->type->keyDup) \
244 entry->key = (ht)->type->keyDup((ht)->privdata, _key_); \
245 else \
246 entry->key = (_key_); \
247 } while(0)
248
249 #define Jim_CompareHashKeys(ht, key1, key2) \
250 (((ht)->type->keyCompare) ? \
251 (ht)->type->keyCompare((ht)->privdata, key1, key2) : \
252 (key1) == (key2))
253
254 #define Jim_HashKey(ht, key) (ht)->type->hashFunction(key)
255
256 #define Jim_GetHashEntryKey(he) ((he)->key)
257 #define Jim_GetHashEntryVal(he) ((he)->val)
258 #define Jim_GetHashTableCollisions(ht) ((ht)->collisions)
259 #define Jim_GetHashTableSize(ht) ((ht)->size)
260 #define Jim_GetHashTableUsed(ht) ((ht)->used)
261
262 /* -----------------------------------------------------------------------------
263 * Jim_Obj structure
264 * ---------------------------------------------------------------------------*/
265
266 /* -----------------------------------------------------------------------------
267 * Jim object. This is mostly the same as Tcl_Obj itself,
268 * with the addition of the 'prev' and 'next' pointers.
269 * In Jim all the objects are stored into a linked list for GC purposes,
270 * so that it's possible to access every object living in a given interpreter
271 * sequentially. When an object is freed, it's moved into a different
272 * linked list, used as object pool.
273 *
274 * The refcount of a freed object is always -1.
275 * ---------------------------------------------------------------------------*/
276 typedef struct Jim_Obj {
277 int refCount; /* reference count */
278 char *bytes; /* string representation buffer. NULL = no string repr. */
279 int length; /* number of bytes in 'bytes', not including the numterm. */
280 struct Jim_ObjType *typePtr; /* object type. */
281 /* Internal representation union */
282 union {
283 /* integer number type */
284 jim_wide wideValue;
285 /* hashed object type value */
286 int hashValue;
287 /* index type */
288 int indexValue;
289 /* return code type */
290 int returnCode;
291 /* double number type */
292 double doubleValue;
293 /* Generic pointer */
294 void *ptr;
295 /* Generic two pointers value */
296 struct {
297 void *ptr1;
298 void *ptr2;
299 } twoPtrValue;
300 /* Variable object */
301 struct {
302 unsigned jim_wide callFrameId;
303 struct Jim_Var *varPtr;
304 } varValue;
305 /* Command object */
306 struct {
307 unsigned jim_wide procEpoch;
308 struct Jim_Cmd *cmdPtr;
309 } cmdValue;
310 /* List object */
311 struct {
312 struct Jim_Obj **ele; /* Elements vector */
313 int len; /* Length */
314 int maxLen; /* Allocated 'ele' length */
315 } listValue;
316 /* String type */
317 struct {
318 int maxLength;
319 } strValue;
320 /* Reference type */
321 struct {
322 jim_wide id;
323 struct Jim_Reference *refPtr;
324 } refValue;
325 /* Source type */
326 struct {
327 const char *fileName;
328 int lineNumber;
329 } sourceValue;
330 /* Dict substitution type */
331 struct {
332 struct Jim_Obj *varNameObjPtr;
333 struct Jim_Obj *indexObjPtr;
334 } dictSubstValue;
335 /* tagged binary type */
336 struct {
337 unsigned char *data;
338 size_t len;
339 } binaryValue;
340 } internalRep;
341 /* This are 8 or 16 bytes more for every object
342 * but this is required for efficient garbage collection
343 * of Jim references. */
344 struct Jim_Obj *prevObjPtr; /* pointer to the prev object. */
345 struct Jim_Obj *nextObjPtr; /* pointer to the next object. */
346 } Jim_Obj;
347
348 /* Jim_Obj related macros */
349 #define Jim_IncrRefCount(objPtr) \
350 ++(objPtr)->refCount
351 #define Jim_DecrRefCount(interp, objPtr) \
352 if (--(objPtr)->refCount <= 0) Jim_FreeObj(interp, objPtr)
353 #define Jim_IsShared(objPtr) \
354 ((objPtr)->refCount > 1)
355
356 /* This macro is used when we allocate a new object using
357 * Jim_New...Obj(), but for some error we need to destroy it.
358 * Instead to use Jim_IncrRefCount() + Jim_DecrRefCount() we
359 * can just call Jim_FreeNewObj. To call Jim_Free directly
360 * seems too raw, the object handling may change and we want
361 * that Jim_FreeNewObj() can be called only against objects
362 * that are belived to have refcount == 0. */
363 #define Jim_FreeNewObj Jim_FreeObj
364
365 /* Free the internal representation of the object. */
366 #define Jim_FreeIntRep(i,o) \
367 if ((o)->typePtr && (o)->typePtr->freeIntRepProc) \
368 (o)->typePtr->freeIntRepProc(i, o)
369
370 /* Get the internal representation pointer */
371 #define Jim_GetIntRepPtr(o) (o)->internalRep.ptr
372
373 /* Set the internal representation pointer */
374 #define Jim_SetIntRepPtr(o, p) \
375 (o)->internalRep.ptr = (p)
376
377 /* The object type structure.
378 * There are four methods.
379 *
380 * - FreeIntRep is used to free the internal representation of the object.
381 * Can be NULL if there is nothing to free.
382 * - DupIntRep is used to duplicate the internal representation of the object.
383 * If NULL, when an object is duplicated, the internalRep union is
384 * directly copied from an object to another.
385 * Note that it's up to the caller to free the old internal repr of the
386 * object before to call the Dup method.
387 * - UpdateString is used to create the string from the internal repr.
388 * - setFromAny is used to convert the current object into one of this type.
389 */
390
391 struct Jim_Interp;
392
393 typedef void (Jim_FreeInternalRepProc)(struct Jim_Interp *interp,
394 struct Jim_Obj *objPtr);
395 typedef void (Jim_DupInternalRepProc)(struct Jim_Interp *interp,
396 struct Jim_Obj *srcPtr, Jim_Obj *dupPtr);
397 typedef void (Jim_UpdateStringProc)(struct Jim_Obj *objPtr);
398
399 typedef struct Jim_ObjType {
400 const char *name; /* The name of the type. */
401 Jim_FreeInternalRepProc *freeIntRepProc;
402 Jim_DupInternalRepProc *dupIntRepProc;
403 Jim_UpdateStringProc *updateStringProc;
404 int flags;
405 } Jim_ObjType;
406
407 /* Jim_ObjType flags */
408 #define JIM_TYPE_NONE 0 /* No flags */
409 #define JIM_TYPE_REFERENCES 1 /* The object may contain referneces. */
410
411 /* Starting from 1 << 20 flags are reserved for private uses of
412 * different calls. This way the same 'flags' argument may be used
413 * to pass both global flags and private flags. */
414 #define JIM_PRIV_FLAG_SHIFT 20
415
416 /* -----------------------------------------------------------------------------
417 * Call frame, vars, commands structures
418 * ---------------------------------------------------------------------------*/
419
420 /* Call frame */
421 typedef struct Jim_CallFrame {
422 unsigned jim_wide id; /* Call Frame ID. Used for caching. */
423 struct Jim_HashTable vars; /* Where local vars are stored */
424 struct Jim_HashTable *staticVars; /* pointer to procedure static vars */
425 struct Jim_CallFrame *parentCallFrame;
426 Jim_Obj *const *argv; /* object vector of the current procedure call. */
427 int argc; /* number of args of the current procedure call. */
428 Jim_Obj *procArgsObjPtr; /* arglist object of the running procedure */
429 Jim_Obj *procBodyObjPtr; /* body object of the running procedure */
430 struct Jim_CallFrame *nextFramePtr;
431 } Jim_CallFrame;
432
433 /* The var structure. It just holds the pointer of the referenced
434 * object. If linkFramePtr is not NULL the variable is a link
435 * to a variable of name store on objPtr living on the given callframe
436 * (this happens when the [global] or [upvar] command is used).
437 * The interp in order to always know how to free the Jim_Obj associated
438 * with a given variable because In Jim objects memory managment is
439 * bound to interpreters. */
440 typedef struct Jim_Var {
441 Jim_Obj *objPtr;
442 struct Jim_CallFrame *linkFramePtr;
443 } Jim_Var;
444
445 /* The cmd structure. */
446 typedef int (*Jim_CmdProc)(struct Jim_Interp *interp, int argc,
447 Jim_Obj *const *argv);
448 typedef void (*Jim_DelCmdProc)(struct Jim_Interp *interp, void *privData);
449
450 /* A command is implemented in C if funcPtr is != NULL, otherwise
451 * it's a Tcl procedure with the arglist and body represented by the
452 * two objects referenced by arglistObjPtr and bodyoObjPtr. */
453 typedef struct Jim_Cmd {
454 Jim_CmdProc cmdProc; /* Not-NULL for a C command. */
455 void *privData; /* Only used for C commands. */
456 Jim_DelCmdProc delProc; /* Called when the command is deleted if != NULL */
457 Jim_Obj *argListObjPtr;
458 Jim_Obj *bodyObjPtr;
459 Jim_HashTable *staticVars; /* Static vars hash table. NULL if no statics. */
460 int arityMin; /* Min number of arguments. */
461 int arityMax; /* Max number of arguments. */
462 } Jim_Cmd;
463
464 /* Pseudo Random Number Generator State structure */
465 typedef struct Jim_PrngState {
466 unsigned char sbox[256];
467 unsigned int i, j;
468 } Jim_PrngState;
469
470 /* -----------------------------------------------------------------------------
471 * Jim interpreter structure.
472 * Fields similar to the real Tcl interpreter structure have the same names.
473 * ---------------------------------------------------------------------------*/
474 typedef struct Jim_Interp {
475 Jim_Obj *result; /* object returned by the last command called. */
476 int errorLine; /* Error line where an error occurred. */
477 const char *errorFileName; /* Error file where an error occurred. */
478 int numLevels; /* Number of current nested calls. */
479 int maxNestingDepth; /* Used for infinite loop detection. */
480 int returnCode; /* Completion code to return on JIM_RETURN. */
481 int exitCode; /* Code to return to the OS on JIM_EXIT. */
482 Jim_CallFrame *framePtr; /* Pointer to the current call frame */
483 Jim_CallFrame *topFramePtr; /* toplevel/global frame pointer. */
484 struct Jim_HashTable commands; /* Commands hash table */
485 unsigned jim_wide procEpoch; /* Incremented every time the result
486 of procedures names lookup caching
487 may no longer be valid. */
488 unsigned jim_wide callFrameEpoch; /* Incremented every time a new
489 callframe is created. This id is used for the
490 'ID' field contained in the Jim_CallFrame
491 structure. */
492 Jim_Obj *liveList; /* Linked list of all the live objects. */
493 Jim_Obj *freeList; /* Linked list of all the unused objects. */
494 const char *scriptFileName; /* File name of the script currently in execution. */
495 Jim_Obj *emptyObj; /* Shared empty string object. */
496 unsigned jim_wide referenceNextId; /* Next id for reference. */
497 struct Jim_HashTable references; /* References hash table. */
498 jim_wide lastCollectId; /* reference max Id of the last GC
499 execution. It's set to -1 while the collection
500 is running as sentinel to avoid to recursive
501 calls via the [collect] command inside
502 finalizers. */
503 time_t lastCollectTime; /* unix time of the last GC execution */
504 struct Jim_HashTable sharedStrings; /* Shared Strings hash table */
505 Jim_Obj *stackTrace; /* Stack trace object. */
506 Jim_Obj *unknown; /* Unknown command cache */
507 int errorFlag; /* Set if an error occurred during execution. */
508 int evalRetcodeLevel; /* Level where the last return with code JIM_EVAL
509 happened. */
510 void *cmdPrivData; /* Used to pass the private data pointer to
511 a command. It is set to what the user specified
512 via Jim_CreateCommand(). */
513
514 struct Jim_HashTable stub; /* Stub hash table to export API */
515 /* Jim_GetApi() function pointer, used to bootstrap the STUB table */
516 int (*getApiFuncPtr)(struct Jim_Interp *, const char *, void *);
517 struct Jim_CallFrame *freeFramesList; /* list of CallFrame structures. */
518 struct Jim_HashTable assocData; /* per-interp storage for use by packages */
519 Jim_PrngState *prngState; /* per interpreter Random Number Gen. state. */
520 struct Jim_HashTable packages; /* Provided packages hash table */
521 void *cookie_stdin; /* input file pointer, 'stdin' by default */
522 void *cookie_stdout; /* output file pointer, 'stdout' by default */
523 void *cookie_stderr; /* errors file pointer, 'stderr' by default */
524 size_t (*cb_fwrite )( const void *ptr, size_t size, size_t n, void *cookie );
525 size_t (*cb_fread )( void *ptr, size_t size, size_t n, void *cookie );
526 int (*cb_vfprintf)( void *cookie, const char *fmt, va_list ap );
527 int (*cb_fflush )( void *cookie );
528 char *(*cb_fgets )( char *s, int size, void *cookie );
529 } Jim_Interp;
530
531 /* Currently provided as macro that performs the increment.
532 * At some point may be a real function doing more work.
533 * The proc epoch is used in order to know when a command lookup
534 * cached can no longer considered valid. */
535 #define Jim_InterpIncrProcEpoch(i) (i)->procEpoch++
536 #define Jim_SetResultString(i,s,l) Jim_SetResult(i, Jim_NewStringObj(i,s,l))
537 #define Jim_SetEmptyResult(i) Jim_SetResult(i, (i)->emptyObj)
538 #define Jim_GetResult(i) ((i)->result)
539 #define Jim_CmdPrivData(i) ((i)->cmdPrivData)
540
541 /* Note that 'o' is expanded only one time inside this macro,
542 * so it's safe to use side effects. */
543 #define Jim_SetResult(i,o) do { \
544 Jim_Obj *_resultObjPtr_ = (o); \
545 Jim_IncrRefCount(_resultObjPtr_); \
546 Jim_DecrRefCount(i,(i)->result); \
547 (i)->result = _resultObjPtr_; \
548 } while(0)
549
550 /* Reference structure. The interpreter pointer is held within privdata member in HashTable */
551 #define JIM_REFERENCE_TAGLEN 7 /* The tag is fixed-length, because the reference
552 string representation must be fixed length. */
553 typedef struct Jim_Reference {
554 Jim_Obj *objPtr;
555 Jim_Obj *finalizerCmdNamePtr;
556 char tag[JIM_REFERENCE_TAGLEN+1];
557 } Jim_Reference;
558
559 /* -----------------------------------------------------------------------------
560 * Exported API prototypes.
561 * ---------------------------------------------------------------------------*/
562
563 /* Macros that are common for extensions and core. */
564 #define Jim_NewEmptyStringObj(i) Jim_NewStringObj(i, "", 0)
565
566 /* The core includes real prototypes, extensions instead
567 * include a global function pointer for every function exported.
568 * Once the extension calls Jim_InitExtension(), the global
569 * functon pointers are set to the value of the STUB table
570 * contained in the Jim_Interp structure.
571 *
572 * This makes Jim able to load extensions even if it is statically
573 * linked itself, and to load extensions compiled with different
574 * versions of Jim (as long as the API is still compatible.) */
575
576 /* Macros are common for core and extensions */
577 #define Jim_FreeHashTableIterator(iter) Jim_Free(iter)
578
579 #ifndef __JIM_CORE__
580 # if defined JIM_EXTENSION || defined JIM_EMBEDDED
581 # define JIM_API(x) (*x)
582 # define JIM_STATIC
583 # else
584 # define JIM_API(x) (*x)
585 # define JIM_STATIC extern
586 # endif
587 #else
588 # define JIM_API(x) x
589 # if defined(BUILD_Jim)
590 # define JIM_STATIC DLLEXPORT
591 # else
592 # define JIM_STATIC static
593 # endif
594 #endif /* __JIM_CORE__ */
595
596 /* Memory allocation */
597 JIM_STATIC void * JIM_API(Jim_Alloc) (int size);
598 JIM_STATIC void JIM_API(Jim_Free) (void *ptr);
599 JIM_STATIC char * JIM_API(Jim_StrDup) (const char *s);
600
601 /* evaluation */
602 JIM_STATIC int JIM_API(Jim_Eval)(Jim_Interp *interp, const char *script);
603 JIM_STATIC int JIM_API(Jim_EvalGlobal)(Jim_Interp *interp, const char *script);
604 JIM_STATIC int JIM_API(Jim_EvalFile)(Jim_Interp *interp, const char *filename);
605 JIM_STATIC int JIM_API(Jim_EvalObj) (Jim_Interp *interp, Jim_Obj *scriptObjPtr);
606 JIM_STATIC int JIM_API(Jim_EvalObjBackground) (Jim_Interp *interp,
607 Jim_Obj *scriptObjPtr);
608 JIM_STATIC int JIM_API(Jim_EvalObjVector) (Jim_Interp *interp, int objc,
609 Jim_Obj *const *objv);
610 JIM_STATIC int JIM_API(Jim_SubstObj) (Jim_Interp *interp, Jim_Obj *substObjPtr,
611 Jim_Obj **resObjPtrPtr, int flags);
612
613 /* stack */
614 JIM_STATIC void JIM_API(Jim_InitStack)(Jim_Stack *stack);
615 JIM_STATIC void JIM_API(Jim_FreeStack)(Jim_Stack *stack);
616 JIM_STATIC int JIM_API(Jim_StackLen)(Jim_Stack *stack);
617 JIM_STATIC void JIM_API(Jim_StackPush)(Jim_Stack *stack, void *element);
618 JIM_STATIC void * JIM_API(Jim_StackPop)(Jim_Stack *stack);
619 JIM_STATIC void * JIM_API(Jim_StackPeek)(Jim_Stack *stack);
620 JIM_STATIC void JIM_API(Jim_FreeStackElements)(Jim_Stack *stack, void (*freeFunc)(void *ptr));
621
622 /* hash table */
623 JIM_STATIC int JIM_API(Jim_InitHashTable) (Jim_HashTable *ht,
624 Jim_HashTableType *type, void *privdata);
625 JIM_STATIC int JIM_API(Jim_ExpandHashTable) (Jim_HashTable *ht,
626 unsigned int size);
627 JIM_STATIC int JIM_API(Jim_AddHashEntry) (Jim_HashTable *ht, const void *key,
628 void *val);
629 JIM_STATIC int JIM_API(Jim_ReplaceHashEntry) (Jim_HashTable *ht,
630 const void *key, void *val);
631 JIM_STATIC int JIM_API(Jim_DeleteHashEntry) (Jim_HashTable *ht,
632 const void *key);
633 JIM_STATIC int JIM_API(Jim_FreeHashTable) (Jim_HashTable *ht);
634 JIM_STATIC Jim_HashEntry * JIM_API(Jim_FindHashEntry) (Jim_HashTable *ht,
635 const void *key);
636 JIM_STATIC int JIM_API(Jim_ResizeHashTable) (Jim_HashTable *ht);
637 JIM_STATIC Jim_HashTableIterator *JIM_API(Jim_GetHashTableIterator)
638 (Jim_HashTable *ht);
639 JIM_STATIC Jim_HashEntry * JIM_API(Jim_NextHashEntry)
640 (Jim_HashTableIterator *iter);
641
642 /* objects */
643 JIM_STATIC Jim_Obj * JIM_API(Jim_NewObj) (Jim_Interp *interp);
644 JIM_STATIC void JIM_API(Jim_FreeObj) (Jim_Interp *interp, Jim_Obj *objPtr);
645 JIM_STATIC void JIM_API(Jim_InvalidateStringRep) (Jim_Obj *objPtr);
646 JIM_STATIC void JIM_API(Jim_InitStringRep) (Jim_Obj *objPtr, const char *bytes,
647 int length);
648 JIM_STATIC Jim_Obj * JIM_API(Jim_DuplicateObj) (Jim_Interp *interp,
649 Jim_Obj *objPtr);
650 JIM_STATIC const char * JIM_API(Jim_GetString)(Jim_Obj *objPtr,
651 int *lenPtr);
652 JIM_STATIC int JIM_API(Jim_Length)(Jim_Obj *objPtr);
653
654 /* string object */
655 JIM_STATIC Jim_Obj * JIM_API(Jim_NewStringObj) (Jim_Interp *interp,
656 const char *s, int len);
657 JIM_STATIC Jim_Obj * JIM_API(Jim_NewStringObjNoAlloc) (Jim_Interp *interp,
658 char *s, int len);
659 JIM_STATIC void JIM_API(Jim_AppendString) (Jim_Interp *interp, Jim_Obj *objPtr,
660 const char *str, int len);
661 JIM_STATIC void JIM_API(Jim_AppendObj) (Jim_Interp *interp, Jim_Obj *objPtr,
662 Jim_Obj *appendObjPtr);
663 JIM_STATIC void JIM_API(Jim_AppendStrings) (Jim_Interp *interp,
664 Jim_Obj *objPtr, ...);
665 JIM_STATIC int JIM_API(Jim_StringEqObj) (Jim_Obj *aObjPtr,
666 Jim_Obj *bObjPtr, int nocase);
667 JIM_STATIC int JIM_API(Jim_StringMatchObj) (Jim_Obj *patternObjPtr,
668 Jim_Obj *objPtr, int nocase);
669 JIM_STATIC Jim_Obj * JIM_API(Jim_StringRangeObj) (Jim_Interp *interp,
670 Jim_Obj *strObjPtr, Jim_Obj *firstObjPtr,
671 Jim_Obj *lastObjPtr);
672 JIM_STATIC Jim_Obj * JIM_API(Jim_FormatString) (Jim_Interp *interp,
673 Jim_Obj *fmtObjPtr, int objc, Jim_Obj *const *objv);
674 JIM_STATIC Jim_Obj * JIM_API(Jim_ScanString) (Jim_Interp *interp, Jim_Obj *strObjPtr,
675 Jim_Obj *fmtObjPtr, int flags);
676 JIM_STATIC int JIM_API(Jim_CompareStringImmediate) (Jim_Interp *interp,
677 Jim_Obj *objPtr, const char *str);
678
679 /* reference object */
680 JIM_STATIC Jim_Obj * JIM_API(Jim_NewReference) (Jim_Interp *interp,
681 Jim_Obj *objPtr, Jim_Obj *tagPtr, Jim_Obj *cmdNamePtr);
682 JIM_STATIC Jim_Reference * JIM_API(Jim_GetReference) (Jim_Interp *interp,
683 Jim_Obj *objPtr);
684 JIM_STATIC int JIM_API(Jim_SetFinalizer) (Jim_Interp *interp, Jim_Obj *objPtr, Jim_Obj *cmdNamePtr);
685 JIM_STATIC int JIM_API(Jim_GetFinalizer) (Jim_Interp *interp, Jim_Obj *objPtr, Jim_Obj **cmdNamePtrPtr);
686
687 /* interpreter */
688 JIM_STATIC Jim_Interp * JIM_API(Jim_CreateInterp) (void);
689 JIM_STATIC void JIM_API(Jim_FreeInterp) (Jim_Interp *i);
690 JIM_STATIC int JIM_API(Jim_GetExitCode) (Jim_Interp *interp);
691 JIM_STATIC void * JIM_API(Jim_SetStdin) (Jim_Interp *interp, void *fp);
692 JIM_STATIC void * JIM_API(Jim_SetStdout) (Jim_Interp *interp, void *fp);
693 JIM_STATIC void * JIM_API(Jim_SetStderr) (Jim_Interp *interp, void *fp);
694
695 /* commands */
696 JIM_STATIC void JIM_API(Jim_RegisterCoreCommands) (Jim_Interp *interp);
697 JIM_STATIC int JIM_API(Jim_CreateCommand) (Jim_Interp *interp,
698 const char *cmdName, Jim_CmdProc cmdProc, void *privData,
699 Jim_DelCmdProc delProc);
700 JIM_STATIC int JIM_API(Jim_CreateProcedure) (Jim_Interp *interp,
701 const char *cmdName, Jim_Obj *argListObjPtr, Jim_Obj *staticsListObjPtr,
702 Jim_Obj *bodyObjPtr, int arityMin, int arityMax);
703 JIM_STATIC int JIM_API(Jim_DeleteCommand) (Jim_Interp *interp,
704 const char *cmdName);
705 JIM_STATIC int JIM_API(Jim_RenameCommand) (Jim_Interp *interp,
706 const char *oldName, const char *newName);
707 JIM_STATIC Jim_Cmd * JIM_API(Jim_GetCommand) (Jim_Interp *interp,
708 Jim_Obj *objPtr, int flags);
709 JIM_STATIC int JIM_API(Jim_SetVariable) (Jim_Interp *interp,
710 Jim_Obj *nameObjPtr, Jim_Obj *valObjPtr);
711 JIM_STATIC int JIM_API(Jim_SetVariableStr) (Jim_Interp *interp,
712 const char *name, Jim_Obj *objPtr);
713 JIM_STATIC int JIM_API(Jim_SetGlobalVariableStr) (Jim_Interp *interp,
714 const char *name, Jim_Obj *objPtr);
715 JIM_STATIC int JIM_API(Jim_SetVariableStrWithStr) (Jim_Interp *interp,
716 const char *name, const char *val);
717 JIM_STATIC int JIM_API(Jim_SetVariableLink) (Jim_Interp *interp,
718 Jim_Obj *nameObjPtr, Jim_Obj *targetNameObjPtr,
719 Jim_CallFrame *targetCallFrame);
720 JIM_STATIC Jim_Obj * JIM_API(Jim_GetVariable) (Jim_Interp *interp,
721 Jim_Obj *nameObjPtr, int flags);
722 JIM_STATIC Jim_Obj * JIM_API(Jim_GetGlobalVariable) (Jim_Interp *interp,
723 Jim_Obj *nameObjPtr, int flags);
724 JIM_STATIC Jim_Obj * JIM_API(Jim_GetVariableStr) (Jim_Interp *interp,
725 const char *name, int flags);
726 JIM_STATIC Jim_Obj * JIM_API(Jim_GetGlobalVariableStr) (Jim_Interp *interp,
727 const char *name, int flags);
728 JIM_STATIC int JIM_API(Jim_UnsetVariable) (Jim_Interp *interp,
729 Jim_Obj *nameObjPtr, int flags);
730
731 /* call frame */
732 JIM_STATIC int JIM_API(Jim_GetCallFrameByLevel) (Jim_Interp *interp,
733 Jim_Obj *levelObjPtr, Jim_CallFrame **framePtrPtr,
734 int *newLevelPtr);
735
736 /* garbage collection */
737 JIM_STATIC int JIM_API(Jim_Collect) (Jim_Interp *interp);
738 JIM_STATIC void JIM_API(Jim_CollectIfNeeded) (Jim_Interp *interp);
739
740 /* index object */
741 JIM_STATIC int JIM_API(Jim_GetIndex) (Jim_Interp *interp, Jim_Obj *objPtr,
742 int *indexPtr);
743
744 /* list object */
745 JIM_STATIC Jim_Obj * JIM_API(Jim_NewListObj) (Jim_Interp *interp,
746 Jim_Obj *const *elements, int len);
747 JIM_STATIC void JIM_API(Jim_ListInsertElements) (Jim_Interp *interp,
748 Jim_Obj *listPtr, int index, int objc, Jim_Obj *const *objVec);
749 JIM_STATIC void JIM_API(Jim_ListAppendElement) (Jim_Interp *interp,
750 Jim_Obj *listPtr, Jim_Obj *objPtr);
751 JIM_STATIC void JIM_API(Jim_ListAppendList) (Jim_Interp *interp,
752 Jim_Obj *listPtr, Jim_Obj *appendListPtr);
753 JIM_STATIC void JIM_API(Jim_ListLength) (Jim_Interp *interp, Jim_Obj *listPtr,
754 int *intPtr);
755 JIM_STATIC int JIM_API(Jim_ListIndex) (Jim_Interp *interp, Jim_Obj *listPrt,
756 int index, Jim_Obj **objPtrPtr, int seterr);
757 JIM_STATIC int JIM_API(Jim_SetListIndex) (Jim_Interp *interp,
758 Jim_Obj *varNamePtr, Jim_Obj *const *indexv, int indexc,
759 Jim_Obj *newObjPtr);
760 JIM_STATIC Jim_Obj * JIM_API(Jim_ConcatObj) (Jim_Interp *interp, int objc,
761 Jim_Obj *const *objv);
762
763 /* dict object */
764 JIM_STATIC Jim_Obj * JIM_API(Jim_NewDictObj) (Jim_Interp *interp,
765 Jim_Obj *const *elements, int len);
766 JIM_STATIC int JIM_API(Jim_DictKey) (Jim_Interp *interp, Jim_Obj *dictPtr,
767 Jim_Obj *keyPtr, Jim_Obj **objPtrPtr, int flags);
768 JIM_STATIC int JIM_API(Jim_DictKeysVector) (Jim_Interp *interp,
769 Jim_Obj *dictPtr, Jim_Obj *const *keyv, int keyc,
770 Jim_Obj **objPtrPtr, int flags);
771 JIM_STATIC int JIM_API(Jim_SetDictKeysVector) (Jim_Interp *interp,
772 Jim_Obj *varNamePtr, Jim_Obj *const *keyv, int keyc,
773 Jim_Obj *newObjPtr);
774
775 /* return code object */
776 JIM_STATIC int JIM_API(Jim_GetReturnCode) (Jim_Interp *interp, Jim_Obj *objPtr,
777 int *intPtr);
778
779 /* expression object */
780 JIM_STATIC int JIM_API(Jim_EvalExpression) (Jim_Interp *interp,
781 Jim_Obj *exprObjPtr, Jim_Obj **exprResultPtrPtr);
782 JIM_STATIC int JIM_API(Jim_GetBoolFromExpr) (Jim_Interp *interp,
783 Jim_Obj *exprObjPtr, int *boolPtr);
784
785 /* integer object */
786 JIM_STATIC int JIM_API(Jim_GetWide) (Jim_Interp *interp, Jim_Obj *objPtr,
787 jim_wide *widePtr);
788 JIM_STATIC int JIM_API(Jim_GetLong) (Jim_Interp *interp, Jim_Obj *objPtr,
789 long *longPtr);
790 JIM_STATIC void JIM_API(Jim_SetWide) (Jim_Interp *interp, Jim_Obj *objPtr,
791 jim_wide wideValue);
792 JIM_STATIC Jim_Obj * JIM_API(Jim_NewIntObj) (Jim_Interp *interp,
793 jim_wide wideValue);
794
795 /* double object */
796 JIM_STATIC int JIM_API(Jim_GetDouble)(Jim_Interp *interp, Jim_Obj *objPtr,
797 double *doublePtr);
798 JIM_STATIC void JIM_API(Jim_SetDouble)(Jim_Interp *interp, Jim_Obj *objPtr,
799 double doubleValue);
800 JIM_STATIC Jim_Obj * JIM_API(Jim_NewDoubleObj)(Jim_Interp *interp, double doubleValue);
801
802 /* shared strings */
803 JIM_STATIC const char * JIM_API(Jim_GetSharedString) (Jim_Interp *interp,
804 const char *str);
805 JIM_STATIC void JIM_API(Jim_ReleaseSharedString) (Jim_Interp *interp,
806 const char *str);
807
808 /* commands utilities */
809 JIM_STATIC void JIM_API(Jim_WrongNumArgs) (Jim_Interp *interp, int argc,
810 Jim_Obj *const *argv, const char *msg);
811 JIM_STATIC int JIM_API(Jim_GetEnum) (Jim_Interp *interp, Jim_Obj *objPtr,
812 const char **tablePtr, int *indexPtr, const char *name, int flags);
813 JIM_STATIC int JIM_API(Jim_ScriptIsComplete) (const char *s, int len,
814 char *stateCharPtr);
815
816 /* package utilities */
817 typedef void (Jim_InterpDeleteProc)(Jim_Interp *interp, void *data);
818 JIM_STATIC void * JIM_API(Jim_GetAssocData)(Jim_Interp *interp, const char *key);
819 JIM_STATIC int JIM_API(Jim_SetAssocData)(Jim_Interp *interp, const char *key,
820 Jim_InterpDeleteProc *delProc, void *data);
821 JIM_STATIC int JIM_API(Jim_DeleteAssocData)(Jim_Interp *interp, const char *key);
822
823 /* API import/export functions */
824 JIM_STATIC int JIM_API(Jim_GetApi) (Jim_Interp *interp, const char *funcname,
825 void *targetPtrPtr);
826 JIM_STATIC int JIM_API(Jim_RegisterApi) (Jim_Interp *interp,
827 const char *funcname, void *funcptr);
828
829 /* Packages C API */
830 JIM_STATIC int JIM_API(Jim_PackageProvide) (Jim_Interp *interp,
831 const char *name, const char *ver, int flags);
832 JIM_STATIC const char * JIM_API(Jim_PackageRequire) (Jim_Interp *interp,
833 const char *name, const char *ver, int flags);
834
835 /* error messages */
836 JIM_STATIC void JIM_API(Jim_PrintErrorMessage) (Jim_Interp *interp);
837
838 /* interactive mode */
839 JIM_STATIC int JIM_API(Jim_InteractivePrompt) (Jim_Interp *interp);
840
841 /* Misc */
842 JIM_STATIC void JIM_API(Jim_Panic) (Jim_Interp *interp, const char *fmt, ...);
843
844 /* Jim's STDIO */
845 JIM_STATIC int JIM_API( Jim_fprintf )( Jim_Interp *interp, void *cookie, const char *fmt, ... );
846 JIM_STATIC int JIM_API( Jim_vfprintf )( Jim_Interp *interp, void *cookie, const char *fmt, va_list ap );
847 JIM_STATIC size_t JIM_API( Jim_fwrite )( Jim_Interp *interp, const void *ptr, size_t size, size_t nmeb, void *cookie );
848 JIM_STATIC size_t JIM_API( Jim_fread )( Jim_Interp *interp, void *ptr, size_t size, size_t nmeb, void *cookie );
849 JIM_STATIC int JIM_API( Jim_fflush )( Jim_Interp *interp, void *cookie );
850 JIM_STATIC char * JIM_API( Jim_fgets )( Jim_Interp *interp, char *s, int size, void *cookie );
851
852
853 #undef JIM_STATIC
854 #undef JIM_API
855
856 #ifndef __JIM_CORE__
857
858 #define JIM_GET_API(name) \
859 Jim_GetApi(interp, "Jim_" #name, ((void *)&Jim_ ## name))
860
861 #if defined JIM_EXTENSION || defined JIM_EMBEDDED
862 /* This must be included "inline" inside the extension */
863 static void Jim_InitExtension(Jim_Interp *interp)
864 {
865 Jim_GetApi = interp->getApiFuncPtr;
866
867 JIM_GET_API(Alloc);
868 JIM_GET_API(Free);
869 JIM_GET_API(Eval);
870 JIM_GET_API(EvalGlobal);
871 JIM_GET_API(EvalFile);
872 JIM_GET_API(EvalObj);
873 JIM_GET_API(EvalObjBackground);
874 JIM_GET_API(EvalObjVector);
875 JIM_GET_API(InitHashTable);
876 JIM_GET_API(ExpandHashTable);
877 JIM_GET_API(AddHashEntry);
878 JIM_GET_API(ReplaceHashEntry);
879 JIM_GET_API(DeleteHashEntry);
880 JIM_GET_API(FreeHashTable);
881 JIM_GET_API(FindHashEntry);
882 JIM_GET_API(ResizeHashTable);
883 JIM_GET_API(GetHashTableIterator);
884 JIM_GET_API(NextHashEntry);
885 JIM_GET_API(NewObj);
886 JIM_GET_API(FreeObj);
887 JIM_GET_API(InvalidateStringRep);
888 JIM_GET_API(InitStringRep);
889 JIM_GET_API(DuplicateObj);
890 JIM_GET_API(GetString);
891 JIM_GET_API(Length);
892 JIM_GET_API(InvalidateStringRep);
893 JIM_GET_API(NewStringObj);
894 JIM_GET_API(NewStringObjNoAlloc);
895 JIM_GET_API(AppendString);
896 JIM_GET_API(AppendObj);
897 JIM_GET_API(AppendStrings);
898 JIM_GET_API(StringEqObj);
899 JIM_GET_API(StringMatchObj);
900 JIM_GET_API(StringRangeObj);
901 JIM_GET_API(FormatString);
902 JIM_GET_API(ScanString);
903 JIM_GET_API(CompareStringImmediate);
904 JIM_GET_API(NewReference);
905 JIM_GET_API(GetReference);
906 JIM_GET_API(SetFinalizer);
907 JIM_GET_API(GetFinalizer);
908 JIM_GET_API(CreateInterp);
909 JIM_GET_API(FreeInterp);
910 JIM_GET_API(GetExitCode);
911 JIM_GET_API(SetStdin);
912 JIM_GET_API(SetStdout);
913 JIM_GET_API(SetStderr);
914 JIM_GET_API(CreateCommand);
915 JIM_GET_API(CreateProcedure);
916 JIM_GET_API(DeleteCommand);
917 JIM_GET_API(RenameCommand);
918 JIM_GET_API(GetCommand);
919 JIM_GET_API(SetVariable);
920 JIM_GET_API(SetVariableStr);
921 JIM_GET_API(SetGlobalVariableStr);
922 JIM_GET_API(SetVariableStrWithStr);
923 JIM_GET_API(SetVariableLink);
924 JIM_GET_API(GetVariable);
925 JIM_GET_API(GetCallFrameByLevel);
926 JIM_GET_API(Collect);
927 JIM_GET_API(CollectIfNeeded);
928 JIM_GET_API(GetIndex);
929 JIM_GET_API(NewListObj);
930 JIM_GET_API(ListInsertElements);
931 JIM_GET_API(ListAppendElement);
932 JIM_GET_API(ListAppendList);
933 JIM_GET_API(ListLength);
934 JIM_GET_API(ListIndex);
935 JIM_GET_API(SetListIndex);
936 JIM_GET_API(ConcatObj);
937 JIM_GET_API(NewDictObj);
938 JIM_GET_API(DictKey);
939 JIM_GET_API(DictKeysVector);
940 JIM_GET_API(GetIndex);
941 JIM_GET_API(GetReturnCode);
942 JIM_GET_API(EvalExpression);
943 JIM_GET_API(GetBoolFromExpr);
944 JIM_GET_API(GetWide);
945 JIM_GET_API(GetLong);
946 JIM_GET_API(SetWide);
947 JIM_GET_API(NewIntObj);
948 JIM_GET_API(GetDouble);
949 JIM_GET_API(SetDouble);
950 JIM_GET_API(NewDoubleObj);
951 JIM_GET_API(WrongNumArgs);
952 JIM_GET_API(SetDictKeysVector);
953 JIM_GET_API(SubstObj);
954 JIM_GET_API(RegisterApi);
955 JIM_GET_API(PrintErrorMessage);
956 JIM_GET_API(InteractivePrompt);
957 JIM_GET_API(RegisterCoreCommands);
958 JIM_GET_API(GetSharedString);
959 JIM_GET_API(ReleaseSharedString);
960 JIM_GET_API(Panic);
961 JIM_GET_API(StrDup);
962 JIM_GET_API(UnsetVariable);
963 JIM_GET_API(GetVariableStr);
964 JIM_GET_API(GetGlobalVariable);
965 JIM_GET_API(GetGlobalVariableStr);
966 JIM_GET_API(GetAssocData);
967 JIM_GET_API(SetAssocData);
968 JIM_GET_API(DeleteAssocData);
969 JIM_GET_API(GetEnum);
970 JIM_GET_API(ScriptIsComplete);
971 JIM_GET_API(PackageProvide);
972 JIM_GET_API(PackageRequire);
973 JIM_GET_API(InitStack);
974 JIM_GET_API(FreeStack);
975 JIM_GET_API(StackLen);
976 JIM_GET_API(StackPush);
977 JIM_GET_API(StackPop);
978 JIM_GET_API(StackPeek);
979 JIM_GET_API(FreeStackElements);
980 JIM_GET_API(fprintf );
981 JIM_GET_API(vfprintf );
982 JIM_GET_API(fwrite );
983 JIM_GET_API(fread );
984 JIM_GET_API(fflush );
985 JIM_GET_API(fgets );
986
987 }
988 #endif /* defined JIM_EXTENSION || defined JIM_EMBEDDED */
989
990 #undef JIM_GET_API
991
992 #ifdef JIM_EMBEDDED
993 Jim_Interp *ExportedJimCreateInterp(void);
994 static void Jim_InitEmbedded(void) {
995 Jim_Interp *i = ExportedJimCreateInterp();
996 Jim_InitExtension(i);
997 Jim_FreeInterp(i);
998 }
999 #endif /* JIM_EMBEDDED */
1000 #endif /* __JIM_CORE__ */
1001
1002 #ifdef __cplusplus
1003 }
1004 #endif
1005
1006 #endif /* __JIM__H */