ReportTcl fmt and rm casts

This commit is contained in:
James Cherry 2020-04-12 19:19:22 -07:00
parent 85e0254629
commit b104aa7138
1 changed files with 209 additions and 192 deletions

View File

@ -16,18 +16,18 @@
#include "ReportTcl.hh"
#include <stdlib.h>
#include <stdio.h>
#include <stdlib.h>
namespace sta {
using ::Tcl_Channel;
using ::Tcl_GetChannelType;
using ::Tcl_ChannelType;
using ::ClientData;
using ::Tcl_GetChannelInstanceData;
using ::Tcl_DriverOutputProc;
using ::Tcl_Channel;
using ::Tcl_ChannelOutputProc;
using ::Tcl_ChannelType;
using ::Tcl_DriverOutputProc;
using ::Tcl_GetChannelInstanceData;
using ::Tcl_GetChannelType;
extern "C" {
@ -38,29 +38,42 @@ extern "C" {
#endif
static int
encapOutputProc(ClientData instanceData, CONST84 char *buf, int toWrite,
encapOutputProc(ClientData instanceData,
CONST84 char *buf,
int toWrite,
int *errorCodePtr);
static int
encapErrorOutputProc(ClientData instanceData, CONST84 char *buf, int toWrite,
encapErrorOutputProc(ClientData instanceData,
CONST84 char *buf,
int toWrite,
int *errorCodePtr);
static int
encapCloseProc(ClientData instanceData, Tcl_Interp *interp);
static int
encapSetOptionProc(ClientData instanceData, Tcl_Interp *interp,
CONST84 char *optionName, CONST84 char *value);
encapSetOptionProc(ClientData instanceData,
Tcl_Interp *interp,
CONST84 char *optionName,
CONST84 char *value);
static int
encapGetOptionProc(ClientData instanceData, Tcl_Interp *interp,
CONST84 char *optionName, Tcl_DString *dsPtr);
encapGetOptionProc(ClientData instanceData,
Tcl_Interp *interp,
CONST84 char *optionName,
Tcl_DString *dsPtr);
static int
encapInputProc(ClientData instanceData, char *buf, int bufSize,
encapInputProc(ClientData instanceData,
char *buf,
int bufSize,
int *errorCodePtr);
static int
encapSeekProc(ClientData instanceData, long offset, int seekMode,
encapSeekProc(ClientData instanceData,
long offset,
int seekMode,
int *errorCodePtr);
static void
encapWatchProc(ClientData instanceData, int mask);
static int
encapGetHandleProc(ClientData instanceData, int direction,
encapGetHandleProc(ClientData instanceData,
int direction,
ClientData *handlePtr);
static int
encapBlockModeProc(ClientData instanceData, int mode);
@ -264,12 +277,8 @@ Tcl_ChannelType tcl_encap_type_stderr = {
////////////////////////////////////////////////////////////////
ReportTcl::ReportTcl() :
Report(),
interp_(nullptr),
tcl_stdout_(nullptr),
tcl_stderr_(nullptr),
tcl_encap_stdout_(nullptr),
tcl_encap_stderr_(nullptr)
Report(), interp_(nullptr), tcl_stdout_(nullptr), tcl_stderr_(nullptr),
tcl_encap_stdout_(nullptr), tcl_encap_stderr_(nullptr)
{
}
@ -290,10 +299,16 @@ ReportTcl::setTclInterp(Tcl_Interp *interp)
interp_ = interp;
tcl_stdout_ = Tcl_GetStdChannel(TCL_STDOUT);
tcl_stderr_ = Tcl_GetStdChannel(TCL_STDERR);
tcl_encap_stdout_ = Tcl_StackChannel(interp, &tcl_encap_type_stdout, this,
TCL_WRITABLE, tcl_stdout_);
tcl_encap_stderr_ = Tcl_StackChannel(interp, &tcl_encap_type_stderr, this,
TCL_WRITABLE, tcl_stderr_);
tcl_encap_stdout_ = Tcl_StackChannel(interp,
&tcl_encap_type_stdout,
this,
TCL_WRITABLE,
tcl_stdout_);
tcl_encap_stderr_ = Tcl_StackChannel(interp,
&tcl_encap_type_stderr,
this,
TCL_WRITABLE,
tcl_stderr_);
}
size_t
@ -315,8 +330,9 @@ ReportTcl::printTcl(Tcl_Channel channel, const char *buffer, size_t length)
Tcl_DriverOutputProc *output_proc = Tcl_ChannelOutputProc(ch_type);
int error_code;
ClientData clientData = Tcl_GetChannelInstanceData(channel);
return output_proc(clientData, const_cast<char*>(buffer),
static_cast<int>(length),
return output_proc(clientData,
const_cast<char *>(buffer),
length,
&error_code);
}
@ -389,19 +405,20 @@ ReportTcl::redirectStringEnd()
////////////////////////////////////////////////////////////////
static int
encapOutputProc(ClientData instanceData, CONST84 char *buf, int toWrite,
int *)
encapOutputProc(ClientData instanceData, CONST84 char *buf, int toWrite, int *)
{
ReportTcl *report = reinterpret_cast<ReportTcl *>(instanceData);
return static_cast<int>(report->printString(buf, toWrite));
return report->printString(buf, toWrite);
}
static int
encapErrorOutputProc(ClientData instanceData, CONST84 char *buf, int toWrite,
encapErrorOutputProc(ClientData instanceData,
CONST84 char *buf,
int toWrite,
int *)
{
ReportTcl *report = reinterpret_cast<ReportTcl *>(instanceData);
return static_cast<int>(report->printString(buf, toWrite));
return report->printString(buf, toWrite);
}
static int
@ -455,4 +472,4 @@ encapBlockModeProc(ClientData, int)
return 0;
}
} // namespace
} // namespace sta