OpenCores
URL https://opencores.org/ocsvn/w11/w11/trunk

Subversion Repositories w11

[/] [w11/] [tags/] [w11a_V0.7/] [tools/] [src/] [librtcltools/] [Rtcl.cpp] - Diff between revs 10 and 19

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 10 Rev 19
Line 1... Line 1...
// $Id: Rtcl.cpp 369 2011-03-13 22:39:26Z mueller $
// $Id: Rtcl.cpp 488 2013-02-16 18:49:47Z mueller $
//
//
// Copyright 2011- by Walter F.J. Mueller <W.F.J.Mueller@gsi.de>
// Copyright 2011-2013 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
// Software Foundation, either version 2, or at your option any later version.
// Software Foundation, either version 2, or at your option any later version.
//
//
Line 11... Line 11...
// or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
// or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
// for complete details.
// for complete details.
// 
// 
// Revision History: 
// Revision History: 
// Date         Rev Version  Comment
// Date         Rev Version  Comment
 
// 2013-01-06   473   1.0.4  add NewListIntObj(const uint(8|16)_t, ...)
// 2011-03-13   369   1.0.2  add NewListIntObj(vector<uint8_t>)
// 2011-03-13   369   1.0.2  add NewListIntObj(vector<uint8_t>)
// 2011-03-05   366   1.0.1  add AppendResultNewLines()
// 2011-03-05   366   1.0.1  add AppendResultNewLines()
// 2011-02-26   364   1.0    Initial version
// 2011-02-26   364   1.0    Initial version
// 2011-02-13   361   0.1    First draft
// 2011-02-13   361   0.1    First draft
// ---------------------------------------------------------------------------
// ---------------------------------------------------------------------------
 
 
/*!
/*!
  \file
  \file
  \version $Id: Rtcl.cpp 369 2011-03-13 22:39:26Z mueller $
  \version $Id: Rtcl.cpp 488 2013-02-16 18:49:47Z mueller $
  \brief   Implemenation of Rtcl.
  \brief   Implemenation of Rtcl.
*/
*/
 
 
#include "Rtcl.hpp"
#include "Rtcl.hpp"
 
 
using namespace std;
using namespace std;
using namespace Retro;
 
 
 
/*!
/*!
  \class Retro::Rtcl
  \class Retro::Rtcl
  \brief FIXME_docs
  \brief FIXME_docs
*/
*/
 
 
 
// all method definitions in namespace Retro
 
namespace Retro {
 
 
//------------------------------------------+-----------------------------------
//------------------------------------------+-----------------------------------
//! FIXME_docs
//! FIXME_docs
 
 
Tcl_Obj* Rtcl::NewLinesObj(const std::string& str)
Tcl_Obj* Rtcl::NewLinesObj(const std::string& str)
{
{
Line 47... Line 50...
}
}
 
 
//------------------------------------------+-----------------------------------
//------------------------------------------+-----------------------------------
//! FIXME_docs
//! FIXME_docs
 
 
Tcl_Obj* Rtcl::NewListIntObj(const std::vector<uint8_t>& vec)
Tcl_Obj* Rtcl::NewListIntObj(const uint8_t* data, size_t size)
{
{
  if (vec.size() == 0) return Tcl_NewListObj(0, NULL);
  if (size == 0) return Tcl_NewListObj(0, NULL);
 
 
  vector<Tcl_Obj*> vobj;
  vector<Tcl_Obj*> vobj;
  vobj.reserve(vec.size());
  vobj.reserve(size);
 
 
  for (size_t i=0; i<vec.size(); i++) {
  for (size_t i=0; i<size; i++) {
    vobj.push_back(Tcl_NewIntObj((int)vec[i]));
    vobj.push_back(Tcl_NewIntObj((int)data[i]));
  }
  }
  return Tcl_NewListObj(vobj.size(), vobj.data());
  return Tcl_NewListObj(vobj.size(), vobj.data());
}
}
 
 
//------------------------------------------+-----------------------------------
//------------------------------------------+-----------------------------------
//! FIXME_docs
//! FIXME_docs
 
 
Tcl_Obj* Rtcl::NewListIntObj(const std::vector<uint16_t>& vec)
Tcl_Obj* Rtcl::NewListIntObj(const uint16_t* data, size_t size)
{
{
  if (vec.size() == 0) return Tcl_NewListObj(0, NULL);
  if (size == 0) return Tcl_NewListObj(0, NULL);
 
 
  vector<Tcl_Obj*> vobj;
  vector<Tcl_Obj*> vobj;
  vobj.reserve(vec.size());
  vobj.reserve(size);
 
 
  for (size_t i=0; i<vec.size(); i++) {
  for (size_t i=0; i<size; i++) {
    vobj.push_back(Tcl_NewIntObj((int)vec[i]));
    vobj.push_back(Tcl_NewIntObj((int)data[i]));
  }
  }
  return Tcl_NewListObj(vobj.size(), vobj.data());
  return Tcl_NewListObj(vobj.size(), vobj.data());
}
}
 
 
//------------------------------------------+-----------------------------------
//------------------------------------------+-----------------------------------
//! FIXME_docs
//! FIXME_docs
 
 
 
Tcl_Obj* Rtcl::NewListIntObj(const std::vector<uint8_t>& vec)
 
{
 
  return NewListIntObj(vec.data(), vec.size());
 
}
 
 
 
//------------------------------------------+-----------------------------------
 
//! FIXME_docs
 
 
 
Tcl_Obj* Rtcl::NewListIntObj(const std::vector<uint16_t>& vec)
 
{
 
  return NewListIntObj(vec.data(), vec.size());
 
}
 
 
 
//------------------------------------------+-----------------------------------
 
//! FIXME_docs
 
 
bool Rtcl::SetVar(Tcl_Interp* interp, const std::string& varname, Tcl_Obj* pobj)
bool Rtcl::SetVar(Tcl_Interp* interp, const std::string& varname, Tcl_Obj* pobj)
{
{
  Tcl_Obj* pret = 0;
  Tcl_Obj* pret = 0;
 
 
  size_t pos_pbeg = varname.find_first_of('(');
  size_t pos_pbeg = varname.find_first_of('(');
  size_t pos_pend = varname.find_first_of(')');
  size_t pos_pend = varname.find_first_of(')');
  if (pos_pbeg != string::npos || pos_pend != string::npos) {
  if (pos_pbeg != string::npos || pos_pend != string::npos) {
    if (pos_pbeg == string::npos || pos_pbeg == 0 ||
    if (pos_pbeg == string::npos || pos_pbeg == 0 ||
        pos_pend == string::npos || pos_pend != varname.length()-1 ||
        pos_pend == string::npos || pos_pend != varname.length()-1 ||
        pos_pend-pos_pbeg <= 1) {
        pos_pend-pos_pbeg <= 1) {
      Tcl_AppendResult(interp, "illformed array name \"", varname.c_str(),
      Tcl_AppendResult(interp, "illformed array name '", varname.c_str(),
                       "\"", NULL);
                       "'", NULL);
      return false;
      return false;
    }
    }
    string arrname(varname.substr(0,pos_pbeg));
    string arrname(varname.substr(0,pos_pbeg));
    string elename(varname.substr(pos_pbeg+1, pos_pend-pos_pbeg-1));
    string elename(varname.substr(pos_pbeg+1, pos_pend-pos_pbeg-1));
 
 
Line 142... Line 161...
{
{
  Tcl_SetObjResult(interp, NewLinesObj(str));
  Tcl_SetObjResult(interp, NewLinesObj(str));
  return;
  return;
}
}
 
 
//------------------------------------------+-----------------------------------
} // end namespace Retro
#if (defined(Retro_NoInline) || defined(Retro_Rtcl_NoInline))
 
#define inline
 
#include "Rtcl.ipp"
 
#undef  inline
 
#endif
 
 
 
 No newline at end of file
 No newline at end of file

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.