Line 1... |
Line 1... |
// $Id: RtclBvi.cpp 434 2011-12-02 19:17:38Z mueller $
|
// $Id: RtclBvi.cpp 488 2013-02-16 18:49:47Z mueller $
|
//
|
//
|
// Copyright 2011- by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
|
// Copyright 2011- by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
|
//
|
//
|
// This program is free software; you may redistribute and/or modify it under
|
// This program is free software; you may redistribute and/or modify it under
|
// the terms of the GNU General Public License as published by the Free
|
// the terms of the GNU General Public License as published by the Free
|
Line 18... |
Line 18... |
// 2011-02-13 361 0.1 First draft
|
// 2011-02-13 361 0.1 First draft
|
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
|
|
/*!
|
/*!
|
\file
|
\file
|
\version $Id: RtclBvi.cpp 434 2011-12-02 19:17:38Z mueller $
|
\version $Id: RtclBvi.cpp 488 2013-02-16 18:49:47Z mueller $
|
\brief Implemenation of RtclBvi.
|
\brief Implemenation of RtclBvi.
|
*/
|
*/
|
|
|
#include <ctype.h>
|
#include <ctype.h>
|
#include <stdlib.h>
|
#include <stdlib.h>
|
Line 32... |
Line 32... |
|
|
#include "RtclBvi.hpp"
|
#include "RtclBvi.hpp"
|
#include "librtcltools/RtclOPtr.hpp"
|
#include "librtcltools/RtclOPtr.hpp"
|
|
|
using namespace std;
|
using namespace std;
|
using namespace Retro;
|
|
|
|
/*!
|
/*!
|
\class Retro::RtclBvi
|
\class Retro::RtclBvi
|
\brief FIXME_text
|
\brief FIXME_docs
|
*/
|
*/
|
|
|
|
// all method definitions in namespace Retro
|
|
namespace Retro {
|
|
|
static const int kOK = TCL_OK;
|
static const int kOK = TCL_OK;
|
static const int kERR = TCL_ERROR;
|
static const int kERR = TCL_ERROR;
|
|
|
//------------------------------------------+-----------------------------------
|
//------------------------------------------+-----------------------------------
|
//! FIXME_text
|
//! FIXME_docs
|
|
|
void RtclBvi::CreateCmds(Tcl_Interp* interp)
|
void RtclBvi::CreateCmds(Tcl_Interp* interp)
|
{
|
{
|
Tcl_CreateObjCommand(interp, "bvi", DoCmd, (ClientData) kStr2Int, NULL);
|
Tcl_CreateObjCommand(interp, "bvi", DoCmd, (ClientData) kStr2Int, NULL);
|
Tcl_CreateObjCommand(interp, "pbvi", DoCmd, (ClientData) kInt2Str, NULL);
|
Tcl_CreateObjCommand(interp, "pbvi", DoCmd, (ClientData) kInt2Str, NULL);
|
return;
|
return;
|
}
|
}
|
|
|
//------------------------------------------+-----------------------------------
|
//------------------------------------------+-----------------------------------
|
//! FIXME_text
|
//! FIXME_docs
|
|
|
int RtclBvi::DoCmd(ClientData cdata, Tcl_Interp* interp, int objc,
|
int RtclBvi::DoCmd(ClientData cdata, Tcl_Interp* interp, int objc,
|
Tcl_Obj* const objv[])
|
Tcl_Obj* const objv[])
|
{
|
{
|
bool list = false;
|
bool list = false;
|
Line 93... |
Line 95... |
|
|
return kOK;
|
return kOK;
|
}
|
}
|
|
|
//------------------------------------------+-----------------------------------
|
//------------------------------------------+-----------------------------------
|
//! FIXME_text
|
//! FIXME_docs
|
|
|
Tcl_Obj* RtclBvi::DoConv(Tcl_Interp* interp, ConvMode mode, Tcl_Obj* val,
|
Tcl_Obj* RtclBvi::DoConv(Tcl_Interp* interp, ConvMode mode, Tcl_Obj* val,
|
char form, int nbit)
|
char form, int nbit)
|
{
|
{
|
if (mode == kStr2Int) {
|
if (mode == kStr2Int) {
|
Line 115... |
Line 117... |
}
|
}
|
|
|
// check for c"ddd" format
|
// check for c"ddd" format
|
if (lval>3 && pval[1]=='"' && pval[lval-1]=='"') {
|
if (lval>3 && pval[1]=='"' && pval[lval-1]=='"') {
|
if (strchr("bBoOdDxX", pval[0]) == 0) {
|
if (strchr("bBoOdDxX", pval[0]) == 0) {
|
Tcl_AppendResult(interp, "-E: bad prefix in c\"dddd\" format string",
|
Tcl_AppendResult(interp, "-E: bad prefix in c'dddd' format string",
|
NULL);
|
NULL);
|
return 0;
|
return 0;
|
}
|
}
|
form = pval[0];
|
form = pval[0];
|
pval += 2;
|
pval += 2;
|
Line 199... |
Line 201... |
}
|
}
|
return 0;
|
return 0;
|
}
|
}
|
|
|
//------------------------------------------+-----------------------------------
|
//------------------------------------------+-----------------------------------
|
//! FIXME_text
|
//! FIXME_docs
|
|
|
bool RtclBvi::CheckFormat(Tcl_Interp* interp, int objc, Tcl_Obj* const objv[],
|
bool RtclBvi::CheckFormat(Tcl_Interp* interp, int objc, Tcl_Obj* const objv[],
|
bool& list, char& form, int& nbit)
|
bool& list, char& form, int& nbit)
|
{
|
{
|
list = false;
|
list = false;
|
Line 234... |
Line 236... |
|
|
default:
|
default:
|
if (*opt>='0' && *opt<='9') {
|
if (*opt>='0' && *opt<='9') {
|
nbit = 10*nbit + ((*opt) - '0');
|
nbit = 10*nbit + ((*opt) - '0');
|
if (nbit > 32) {
|
if (nbit > 32) {
|
Tcl_AppendResult(interp, "-E: invalid bvi format \"", opt, "\"",
|
Tcl_AppendResult(interp, "-E: invalid bvi format '", opt, "'",
|
" bit count > 32", NULL);
|
" bit count > 32", NULL);
|
return false;
|
return false;
|
}
|
}
|
} else {
|
} else {
|
Tcl_AppendResult(interp, "-E: invalid bvi format \"", opt, "\"",
|
Tcl_AppendResult(interp, "-E: invalid bvi format '", opt, "'",
|
" allowed: [bBoOxXl][0-9]*", NULL);
|
" allowed: [bBoOxXl][0-9]*", NULL);
|
return false;
|
return false;
|
}
|
}
|
break;
|
break;
|
}
|
}
|
Line 253... |
Line 255... |
if (nbit==0) nbit=8;
|
if (nbit==0) nbit=8;
|
|
|
return true;
|
return true;
|
}
|
}
|
|
|
//------------------------------------------+-----------------------------------
|
} // end namespace Retro
|
#if (defined(Retro_NoInline) || defined(Retro_RtclBvi_NoInline))
|
|
#define inline
|
|
//#include "RtclBvi.ipp"
|
|
#undef inline
|
|
#endif
|
|
|
|
No newline at end of file
|
No newline at end of file
|