Commit 36ab859c authored by Kirill Smelkov's avatar Kirill Smelkov

io: New package that mirrors Go's io (stub)

Only io.EOF and io.ErrUnexpectedEOF for now.
Moved here from wcfs from wendelin.core.
parent 03f88c0b
......@@ -14,6 +14,8 @@ include golang/errors_test.cpp
include golang/fmt.h
include golang/fmt.cpp
include golang/fmt_test.cpp
include golang/io.h
include golang/io.cpp
include golang/strings.h
include golang/strings.cpp
include golang/strings_test.cpp
......
......@@ -6,6 +6,7 @@
/_fmt_test.cpp
/_golang.cpp
/_golang_test.cpp
/_io.cpp
/_strings_test.cpp
/_sync.cpp
/_sync_test.cpp
......
# cython: language_level=2
# Copyright (C) 2019-2020 Nexedi SA and Contributors.
# Kirill Smelkov <kirr@nexedi.com>
#
# This program is free software: you can Use, Study, Modify and Redistribute
# it under the terms of the GNU General Public License version 3, or (at your
# option) any later version, as published by the Free Software Foundation.
#
# You can also Link and Combine this program with other software covered by
# the terms of any of the Free Software licenses or any of the Open Source
# Initiative approved licenses and Convey the resulting work. Corresponding
# source of such a combination shall include the source code for all other
# software used.
#
# This program is distributed WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# See COPYING file for full licensing terms.
# See https://www.nexedi.com/licensing for rationale and options.
"""Package io mirrors Go package io."""
from golang cimport error
cdef extern from "golang/io.h" namespace "golang::io" nogil:
error EOF "golang::io::EOF_"
error ErrUnexpectedEOF
# -*- coding: utf-8 -*-
# cython: language_level=2
# Copyright (C) 2020 Nexedi SA and Contributors.
# Kirill Smelkov <kirr@nexedi.com>
#
# This program is free software: you can Use, Study, Modify and Redistribute
# it under the terms of the GNU General Public License version 3, or (at your
# option) any later version, as published by the Free Software Foundation.
#
# You can also Link and Combine this program with other software covered by
# the terms of any of the Free Software licenses or any of the Open Source
# Initiative approved licenses and Convey the resulting work. Corresponding
# source of such a combination shall include the source code for all other
# software used.
#
# This program is distributed WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# See COPYING file for full licensing terms.
# See https://www.nexedi.com/licensing for rationale and options.
"""_io.pyx implements io.pyx - see _io.pxd for package overview."""
from __future__ import print_function, absolute_import
from golang cimport pyerror
pyEOF = pyerror.from_error(EOF)
pyErrUnexpectedEOF = pyerror.from_error(ErrUnexpectedEOF)
// Copyright (C) 2019-2020 Nexedi SA and Contributors.
// Kirill Smelkov <kirr@nexedi.com>
//
// This program is free software: you can Use, Study, Modify and Redistribute
// it under the terms of the GNU General Public License version 3, or (at your
// option) any later version, as published by the Free Software Foundation.
//
// You can also Link and Combine this program with other software covered by
// the terms of any of the Free Software licenses or any of the Open Source
// Initiative approved licenses and Convey the resulting work. Corresponding
// source of such a combination shall include the source code for all other
// software used.
//
// This program is distributed WITHOUT ANY WARRANTY; without even the implied
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
//
// See COPYING file for full licensing terms.
// See https://www.nexedi.com/licensing for rationale and options.
// Package io mirrors Go package io.
// See io.h for package overview.
#include "golang/errors.h"
#include "golang/io.h"
// golang::io::
namespace golang {
namespace io {
const global<error> EOF_ = errors::New("EOF");
const global<error> ErrUnexpectedEOF = errors::New("unexpected EOF");
}} // golang::io::
#ifndef _NXD_LIBGOLANG_IO_H
#define _NXD_LIBGOLANG_IO_H
// Copyright (C) 2019-2020 Nexedi SA and Contributors.
// Kirill Smelkov <kirr@nexedi.com>
//
// This program is free software: you can Use, Study, Modify and Redistribute
// it under the terms of the GNU General Public License version 3, or (at your
// option) any later version, as published by the Free Software Foundation.
//
// You can also Link and Combine this program with other software covered by
// the terms of any of the Free Software licenses or any of the Open Source
// Initiative approved licenses and Convey the resulting work. Corresponding
// source of such a combination shall include the source code for all other
// software used.
//
// This program is distributed WITHOUT ANY WARRANTY; without even the implied
// warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
//
// See COPYING file for full licensing terms.
// See https://www.nexedi.com/licensing for rationale and options.
// Package io mirrors Go package io.
#include <golang/libgolang.h>
// golang::io::
namespace golang {
namespace io {
// EOF_ is the error that indicates that e.g. read reached end of file or stream.
//
// Note: the name is EOF_, not EOF, to avoid conflict with EOF define by stdio.h.
extern LIBGOLANG_API const global<error> EOF_;
// ErrUnexpectedEOF is the error that indicates that EOF was reached, but was not expected.
extern LIBGOLANG_API const global<error> ErrUnexpectedEOF;
}} // golang::io::
#endif // _NXD_LIBGOLANG_IO_H
# cython: language_level=2
# Copyright (C) 2019-2020 Nexedi SA and Contributors.
# Kirill Smelkov <kirr@nexedi.com>
#
# This program is free software: you can Use, Study, Modify and Redistribute
# it under the terms of the GNU General Public License version 3, or (at your
# option) any later version, as published by the Free Software Foundation.
#
# You can also Link and Combine this program with other software covered by
# the terms of any of the Free Software licenses or any of the Open Source
# Initiative approved licenses and Convey the resulting work. Corresponding
# source of such a combination shall include the source code for all other
# software used.
#
# This program is distributed WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# See COPYING file for full licensing terms.
# See https://www.nexedi.com/licensing for rationale and options.
"""Package io mirrors Go package io.
See io.pxd for package documentation.
"""
# redirect cimport: golang.io -> golang._io (see __init__.pxd for rationale)
from golang._io cimport *
# -*- coding: utf-8 -*-
# Copyright (C) 2020 Nexedi SA and Contributors.
# Kirill Smelkov <kirr@nexedi.com>
#
# This program is free software: you can Use, Study, Modify and Redistribute
# it under the terms of the GNU General Public License version 3, or (at your
# option) any later version, as published by the Free Software Foundation.
#
# You can also Link and Combine this program with other software covered by
# the terms of any of the Free Software licenses or any of the Open Source
# Initiative approved licenses and Convey the resulting work. Corresponding
# source of such a combination shall include the source code for all other
# software used.
#
# This program is distributed WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# See COPYING file for full licensing terms.
# See https://www.nexedi.com/licensing for rationale and options.
"""Package io mirrors Go package io."""
from __future__ import print_function, absolute_import
from golang._io import \
pyEOF as EOF, \
pyErrUnexpectedEOF as ErrUnexpectedEOF
# -*- coding: utf-8 -*-
# Copyright (C) 2020 Nexedi SA and Contributors.
# Kirill Smelkov <kirr@nexedi.com>
#
# This program is free software: you can Use, Study, Modify and Redistribute
# it under the terms of the GNU General Public License version 3, or (at your
# option) any later version, as published by the Free Software Foundation.
#
# You can also Link and Combine this program with other software covered by
# the terms of any of the Free Software licenses or any of the Open Source
# Initiative approved licenses and Convey the resulting work. Corresponding
# source of such a combination shall include the source code for all other
# software used.
#
# This program is distributed WITHOUT ANY WARRANTY; without even the implied
# warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
#
# See COPYING file for full licensing terms.
# See https://www.nexedi.com/licensing for rationale and options.
from __future__ import print_function, absolute_import
from golang import io
def test_errors():
assert str(io.EOF) == "EOF"
assert str(io.ErrUnexpectedEOF) == "unexpected EOF"
assert (io.EOF == io.ErrUnexpectedEOF) == False
assert (io.EOF != io.ErrUnexpectedEOF) == True
......@@ -176,6 +176,7 @@ def _with_build_defaults(kw): # -> (pygo, kw')
dependv.append('%s/golang/cxx.h' % pygo)
dependv.append('%s/golang/errors.h' % pygo)
dependv.append('%s/golang/fmt.h' % pygo)
dependv.append('%s/golang/io.h' % pygo)
dependv.append('%s/golang/strings.h' % pygo)
dependv.append('%s/golang/sync.h' % pygo)
dependv.append('%s/golang/time.h' % pygo)
......@@ -209,6 +210,8 @@ def Extension(name, sources, **kw):
dependv.append('%s/golang/_errors.pxd' % pygo)
dependv.append('%s/golang/fmt.pxd' % pygo)
dependv.append('%s/golang/_fmt.pxd' % pygo)
dependv.append('%s/golang/io.pxd' % pygo)
dependv.append('%s/golang/_io.pxd' % pygo)
dependv.append('%s/golang/strings.pxd' % pygo)
dependv.append('%s/golang/sync.pxd' % pygo)
dependv.append('%s/golang/_sync.pxd' % pygo)
......
......@@ -197,6 +197,7 @@ setup(
'golang/context.cpp',
'golang/errors.cpp',
'golang/fmt.cpp',
'golang/io.cpp',
'golang/strings.cpp',
'golang/sync.cpp',
'golang/time.cpp'],
......@@ -206,6 +207,7 @@ setup(
'golang/cxx.h',
'golang/errors.h',
'golang/fmt.h',
'golang/io.h',
'golang/strings.h',
'golang/sync.h',
'golang/time.h'],
......@@ -267,6 +269,9 @@ setup(
['golang/_fmt_test.pyx',
'golang/fmt_test.cpp']),
Ext('golang._io',
['golang/_io.pyx']),
Ext('golang._strings_test',
['golang/_strings_test.pyx',
'golang/strings_test.cpp']),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment