⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rtl.h

📁 C-smile OOL is a scripting language with C++-like grammar. It has compiler, VM running bytecodes and
💻 H
📖 第 1 页 / 共 2 页
字号:
    STREAM ( PACKAGE* package );

    static VALUE put       ( int argc, VALUE *argv );
    static VALUE printf    ( int argc, VALUE *argv );
    static VALUE get       ( int argc, VALUE *argv );
    static VALUE read      ( int argc, VALUE *argv );
    static VALUE write     ( int argc, VALUE *argv );
    static VALUE size      ( int argc, VALUE *argv );
    static VALUE position  ( int argc, VALUE *argv );
    static VALUE close     ( int argc, VALUE *argv );
    static VALUE get_match ( int argc, VALUE *argv );
    static VALUE src       ( int argc, VALUE *argv );
    static VALUE eof       ( int argc, VALUE *argv );

    static void fill_params ( array<string>& params, int argc, VALUE *argv );

  };

  class NODE: public CLASS
  {
  public:
    class INSTANCE : public THING
    {
    public:
      string path;

      INSTANCE  ()
      {
      }

      INSTANCE ( const char *p ) : path ( p )
      {
      }

      ~INSTANCE  ()
      {
      }

      CLASS *
        get_class ()
      {
        return klass;
      }

      virtual size_t
        allocated_size ()
      {
        return sizeof ( INSTANCE );
      }

      static CLASS * klass;
    };

    NODE ( PACKAGE* package ) : CLASS ( "node", 0, package )
    {
      add_function ( "toString",    tostring    );
      add_function ( "node",        ctor        );
      add_function ( "remove",      remove      );
      add_function ( "make_folder", make_folder );
      add_function ( "rename",      rename      );
      add_property ( "path",        path        );

      add_function ( "stream",      stream      );
      add_function ( "nodes",       nodes       );

      add_property ( "size",        size        );

      add_property ( "ctime",       ctime       );
      add_property ( "mtime",       mtime       );
      add_property ( "atime",       atime       );

      add_property ( "drive",       drive       );
      add_property ( "dir",         dir         );
      add_property ( "name",        name        );
      add_property ( "extension",   extension   );
      add_property ( "name_extension", name_extension );
      add_property ( "exist",       exist       );

      add_property ( "is_file",     is_file     );
      add_property ( "is_folder",   is_folder   );

      add_property ( "can_read",    can_read    );
      add_property ( "can_write",   can_write   );
      add_property ( "can_exec",    can_exec    );
      add_property ( "is_pipe",     is_pipe     );
      add_property ( "is_link",     is_link     );

#ifdef _WIN32
      add_static_data ( "path_separator", VALUE ( "\\" ) );
#else
      add_static_data ( "path_separator", VALUE ( "/" ) );
#endif

      //enum access_mode
      add_static_data ( "a_read",      VALUE ( int ( sal::file::fa_read ) ) );
      add_static_data ( "a_write",     VALUE ( int ( sal::file::fa_write ) ) );
      add_static_data ( "a_readwrite", VALUE ( int ( sal::file::fa_readwrite ) ) );

      //enum open_mode
      add_static_data ( "o_truncate",  VALUE ( int ( sal::file::fo_truncate ) ) );
      add_static_data ( "o_create",    VALUE ( int ( sal::file::fo_create ) ) );
      add_static_data ( "o_random",    VALUE ( int ( sal::file::fo_random ) ) );
      add_static_data ( "o_exclusive", VALUE ( int ( sal::file::fo_exclusive ) ) );
      add_static_data ( "o_shared",    VALUE ( int ( sal::file::fo_shared ) ) );

      INSTANCE::klass = this;
    }
    static VALUE ctor         ( int argc, VALUE *argv );
    static VALUE size         ( int argc, VALUE *argv );
    static VALUE stream       ( int argc, VALUE *argv );
    static VALUE nodes        ( int argc, VALUE *argv );
    static VALUE ctime        ( int argc, VALUE *argv );
    static VALUE mtime        ( int argc, VALUE *argv );
    static VALUE atime        ( int argc, VALUE *argv );
    static VALUE drive        ( int argc, VALUE *argv );
    static VALUE dir          ( int argc, VALUE *argv );
    static VALUE name         ( int argc, VALUE *argv );
    static VALUE name_extension ( int argc, VALUE *argv );
    static VALUE extension    ( int argc, VALUE *argv );
    static VALUE exist        ( int argc, VALUE *argv );
    static VALUE remove       ( int argc, VALUE *argv );
    static VALUE path         ( int argc, VALUE *argv );
    static VALUE is_file      ( int argc, VALUE *argv );
    static VALUE is_folder    ( int argc, VALUE *argv );
    static VALUE tostring     ( int argc, VALUE *argv );
    static VALUE make_folder  ( int argc, VALUE *argv );
    static VALUE rename       ( int argc, VALUE *argv );
    static VALUE do_mode_prop ( int argc, VALUE *argv, int mask );
    static VALUE can_read     ( int argc, VALUE *argv );
    static VALUE can_write    ( int argc, VALUE *argv );
    static VALUE can_exec     ( int argc, VALUE *argv );
    static VALUE is_pipe      ( int argc, VALUE *argv );
    static VALUE is_link      ( int argc, VALUE *argv );

    static void error_ne      ( INSTANCE *me );
    static void error_nf      ( INSTANCE *me );
    static void error_nd      ( INSTANCE *me );
    static void error_access  ( INSTANCE *me );

  };


  class SOCKET: public CLASS
  {
  public:
    class INSTANCE : public THING
    {
    public:
      sal::socket_t *              socket;
      sal::socket_t::socket_domain domain;
      bool                         server;     // listening socket
      unsigned int                 streams;

      INSTANCE () : socket ( 0 ), streams ( 0 ), server ( false ),
                    domain ( sal::socket_t::sock_any_domain )
      {
      }

      ~INSTANCE  ()
      {
      }

      CLASS *
        get_class ()
      {
        return klass;
      }

      virtual size_t
        allocated_size ()
      {
        return sizeof ( INSTANCE );
      }

      static CLASS * klass;
    };

    SOCKET ( PACKAGE* package );

    static VALUE socket       ( int argc, VALUE *argv );
    static VALUE accept       ( int argc, VALUE *argv );
    static VALUE connect      ( int argc, VALUE *argv );
    static VALUE close        ( int argc, VALUE *argv );
    static VALUE stream       ( int argc, VALUE *argv );
    static VALUE remote_addr  ( int argc, VALUE *argv );
    static VALUE remote_port  ( int argc, VALUE *argv );
    static VALUE addr         ( int argc, VALUE *argv );
    static VALUE port         ( int argc, VALUE *argv );
    static VALUE name_by_addr ( int argc, VALUE *argv );
    static VALUE addr_by_name ( int argc, VALUE *argv );
    static VALUE hostname     ( int argc, VALUE *argv );
    static VALUE shutdown     ( int argc, VALUE *argv );

  };


  class BLOB: public CLASS
  {
  public:
    class INSTANCE : public THING
    {
    public:
      BUFFER data;

      INSTANCE  ()
      {
      }

      ~INSTANCE  ()
      {
      }

      CLASS *
        get_class ()
      {
        return klass;
      }

      virtual size_t
        allocated_size ()
      {
        return sizeof ( INSTANCE );
      }

      static CLASS * klass;
    };

    BLOB ( PACKAGE* package ) : CLASS ( "blob", 0, package  )
    {
      add_function ( "blob",   ctor   );
      add_property ( "length", length );
      add_function ( "[]",     item   );
      INSTANCE::klass = this;
    }

    static VALUE ctor      ( int argc, VALUE *argv );
    static VALUE length    ( int argc, VALUE *argv );
    static VALUE item      ( int argc, VALUE *argv );
    static VALUE item_type ( int argc, VALUE *argv );

  };

  class REGEXP: public CLASS
  {
  public:
    class  INSTANCE : public THING
    {
      friend class REGEXP;

      string expression;
      bool   compiled;
      regexp re;

    public:

      INSTANCE  () : compiled ( false )
      {
      }

      ~INSTANCE  ()
      {
      }

      CLASS *
        get_class ()
      {
        return klass;
      }

      virtual size_t
        allocated_size ()
      {
        return sizeof ( INSTANCE );
      }
      static CLASS * klass;
    };

    REGEXP ( PACKAGE* package ) : CLASS ( "regexp", 0, package )
    {
      add_function ( "toString", tostring );
      add_function ( "regexp",   ctor     );
      add_function ( "match",    match    );
      add_function ( "test",     test     );
      add_function ( "compile",  compile  );
      add_function ( "[]",       item     );
      add_property ( "length",   length   );
      add_function ( "split",    split    );

      INSTANCE::klass = this;
    }

    static VALUE ctor     ( int argc, VALUE *argv );
    static VALUE tostring ( int argc, VALUE *argv );
    static VALUE match    ( int argc, VALUE *argv );
    static VALUE test     ( int argc, VALUE *argv );
    static VALUE compile  ( int argc, VALUE *argv );
    static VALUE item     ( int argc, VALUE *argv );
    static VALUE length   ( int argc, VALUE *argv );
    static VALUE split    ( int argc, VALUE *argv );

  };

};

#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -