Diff
Not logged in

Differences From Artifact [e2eb85ead2]:

To Artifact [472a2118c2]:


45
46
47
48
49
50
51
52
53


54
55
56

57
58
59
60
61
62
63
45
46
47
48
49
50
51


52
53
54
55

56
57
58
59
60
61
62
63







-
-
+
+


-
+







/*
** This structure defines the output state associated with a
** Th_Vtab. It is intended that a given Vtab be able to swap out
** output back-ends during its lifetime, e.g. to form a stack of
** buffers.
*/
struct Th_Vtab_OutputMethods {
  Th_Output_f write;   /* output handler */
    void (*dispose)( void * pState ); /* Called when the framework is done with
  Th_Output_f xWrite;   /* output handler */
    void (*xDispose)( void * pState ); /* Called when the framework is done with
                                         this output handler,passed this object's
                                         pState pointer.. */
  void * pState;   /* final argument for write() and dispose()*/
  void * pState;   /* final argument for xWrite() and xDispose()*/
  char enabled;    /* if 0, Th_Output() does nothing. */
};
typedef struct Th_Vtab_OutputMethods Th_Vtab_OutputMethods;

/*
** Shared Th_Vtab_OutputMethods instance used for copy-initialization. This
** implementation uses Th_Output_f_FILE as its write() impl and
95
96
97
98
99
100
101
102

103
104
105
106
107
108
109
95
96
97
98
99
100
101

102
103
104
105
106
107
108
109







-
+







** Opaque handle for interpeter.
*/
typedef struct Th_Interp Th_Interp;


/* 
** Creates a new interpreter instance using the given v-table. pVtab
** must outlive the returned object, and pVtab->out.dispose() will be
** must outlive the returned object, and pVtab->out.xDispose() will be
** called when the interpreter is cleaned up. The optional "ob" API
** swaps out Vtab::out instances, so pVtab->out might not be active
** for the entire lifetime of the interpreter.
**
** Potential TODO: we "should probably" add a dispose() method to the
** Th_Vtab interface.
*/
369
370
371
372
373
374
375
376

377
378

379
380
381
382
383
384
385
369
370
371
372
373
374
375

376
377

378
379
380
381
382
383
384
385







-
+

-
+







** A Th_Output_f() implementation which sends its output to either
** pState (which must be NULL or a (FILE*)) or stdout (if pState is
** NULL).
*/
int Th_Output_f_FILE( char const * zData, int len, void * pState );

/*
** A Th_Vtab_OutputMethods::dispose() impl for FILE handles. If pState is not
** A Th_Vtab_OutputMethods::xDispose() impl for FILE handles. If pState is not
** one of the standard streams (stdin, stdout, stderr) then it is
** fclose()d.
** fclose()d by this call.
*/
void Th_Output_dispose_FILE( void * pState );

/*
** A helper type for holding lists of function registration information.
** For use with Th_RegisterCommands().
*/
442
443
444
445
446
447
448
449






450
451
452
453
454
455
456
442
443
444
445
446
447
448

449
450
451
452
453
454
455
456
457
458
459
460
461







-
+
+
+
+
+
+







** have a NULL zName field (that is the end-of-list marker).
** Returns TH_OK on success, "something else" on error.
*/
int Th_RegisterCommands( Th_Interp * interp, Th_Command_Reg const * pList );

#ifdef TH_ENABLE_OB
/*
** Output buffer stack manager for TH. Used/managed by the Th_ob_xxx() functions.
** Output buffer stack manager for TH. Used/managed by the Th_ob_xxx()
** functions. This class manages Th_Interp::pVtab->out for a specific
** interpreter, swapping it in and out in order to redirect output
** generated via Th_Output() to internal buffers. The buffers can be
** pushed and popped from the stack, allowing clients to selectively
** capture output for a given block of TH1 code.
*/
struct Th_Ob_Manager {
  Blob ** aBuf;        /* Stack of Blobs */
  int nBuf;            /* Number of blobs */
  int cursor;          /* Current level (-1=not active) */
  Th_Interp * interp;  /* The associated interpreter */
  Th_Vtab_OutputMethods * aOutput