Changeset 1764


Ignore:
Timestamp:
May 18, 2005, 3:46:43 AM (16 years ago)
Author:
orlov
Message:
  • Use new methods for working with symbols.
Location:
to-imperative/trunk/library/Dir
Files:
1 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • to-imperative/trunk/library/Dir/close_dir.cc

    r1508 r1764  
     1// $Id$
     2
    13#include <rf_core.hh>
    24#include "lib_error.hh"
     5#include "dir_symbol.hh"
    36
    47namespace refal
     
    1316  if (_dir.get_len() == 1) {
    1417    Term* p = _dir.get_first();
    15     rftype::Dir* d = p->cast_to<rftype::Dir>(type_dir);
    16     if (d) {
     18    if (p->is_instance_of<rftype::Dir>()) {
    1719      try
    1820      {
    19         d->close();
     21        p->get_obj_ptr<rftype::Dir>()->close();
    2022      }
    2123      catch (pxx::SysError const& err)
  • to-imperative/trunk/library/Dir/dir_symbol.hh

    r1762 r1764  
    77#define __dir_symbol_hh__
    88
    9 #include "rf_symbol.hh"
     9#include "rf_symbol.ih"
    1010#include "dir.ih"
    1111
     
    1313{
    1414
    15 //RF_NEW_SYMBOL(Dir, object_term);
    16 //typedef RF_SYMBOL(Dir) DirSymbol;
     15RF_NEW_SYMBOL(Dir, object_term);
    1716
    18 typedef Symbol<Dir> DirSymbol;
    19 
    20 template<>
    21 const term_class_t SymbolType<Dir>::type = object_term;
     17inline pxx::WString RF_SYMBOL(Dir)::to_string (RF_SYMBOL(Dir) const* _dir)
     18{
     19  const size_t max_len = hex_ptr_len + 10;
     20  wchar_t* str = static_cast<wchar_t*>(alloca(max_len * sizeof(wchar_t)));
     21  Dir* ptr = _dir->get_obj_ptr();
     22  int len = swprintf(str, max_len, L"<Dir|%p>", ptr);
     23  if (-1 == len) {
     24    FATAL("<Dir|%p> is more then %u wide characters", ptr, max_len);
     25  }
     26  return pxx::WString(str, len);
     27}
    2228
    2329
  • to-imperative/trunk/library/Dir/open_dir.cc

    r1734 r1764  
     1// $Id$
     2
    13#include <rf_core.hh>
    24#include "lib_error.hh"
     5#include "dir_symbol.hh"
    36
    47namespace refal
     
    2225  try
    2326  {
    24     _dir = Expr::create<rftype::Dir>(name);
     27    _dir = Expr::create_sym<rftype::Dir>(name);
    2528  }
    2629  catch (pxx::SysError const& err)
  • to-imperative/trunk/library/Dir/read_dir.cc

    r1591 r1764  
     1// $Id$
     2
    13#include <rf_core.hh>
    24#include "lib_error.hh"
    3 
    4 using namespace rfrt;
     5#include "dir_symbol.hh"
    56
    67namespace refal
    78{
     9
     10using namespace rfrt;
    811
    912namespace Dir
     
    1417  {
    1518    Term* p = _dir.get_first();
    16     rftype::Dir* d = p->cast_to<rftype::Dir>(type_dir);
    17     if (d)
     19    RF_SYMBOL(rftype::Dir)* d_x = p->cast_to<RF_SYMBOL(rftype::Dir)>();
     20    if (d_x)
    1821    {
     22      rftype::Dir* d = d_x->get_obj_ptr();
    1923      try
    2024      {
     
    2933      catch (pxx::SysError const& err)
    3034      {
    31         throw_rf_error(L"Close-Dir", err.get_code());
     35        throw_rf_error(L"Read-Dir", err.get_code());
    3236      }
    3337    }
Note: See TracChangeset for help on using the changeset viewer.