1
1
mirror of https://github.com/OpenVoiceOS/OpenVoiceOS synced 2025-06-05 22:19:21 +02:00

Add pre-installed python packages within rootfs overlay

TODO: This is just a quick fix and need to be changed to
buildroot packages in the upcoming days/weeks/months.
This commit is contained in:
j1nx
2022-12-08 21:02:30 +01:00
parent ce2443f753
commit 37d97e1551
36609 changed files with 7287696 additions and 0 deletions

View File

@ -0,0 +1,18 @@
#ifndef PYTHONIC_DISPATCH_CLEAR_HPP
#define PYTHONIC_DISPATCH_CLEAR_HPP
#include "pythonic/include/__dispatch__/clear.hpp"
#include "pythonic/utils/functor.hpp"
PYTHONIC_NS_BEGIN
namespace __dispatch__
{
template <class Any>
auto clear(Any &&any) -> decltype(any.clear());
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,21 @@
#ifndef PYTHONIC_DISPATCH_CONJUGATE_HPP
#define PYTHONIC_DISPATCH_CONJUGATE_HPP
#include "pythonic/include/__dispatch__/conjugate.hpp"
#include "pythonic/numpy/conjugate.hpp"
#include "pythonic/utils/functor.hpp"
PYTHONIC_NS_BEGIN
namespace __dispatch__
{
template <class Any>
auto conjugate(Any const &any) -> decltype(numpy::functor::conjugate{}(any))
{
return numpy::functor::conjugate{}(any);
}
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,20 @@
#ifndef PYTHONIC_DISPATCH_COPY_HPP
#define PYTHONIC_DISPATCH_COPY_HPP
#include "pythonic/include/__dispatch__/copy.hpp"
#include "pythonic/utils/functor.hpp"
PYTHONIC_NS_BEGIN
namespace __dispatch__
{
template <class Any>
auto copy(Any const &any) -> decltype(any.copy())
{
return any.copy();
}
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,22 @@
#ifndef PYTHONIC_DISPATCH_COUNT_HPP
#define PYTHONIC_DISPATCH_COUNT_HPP
#include "pythonic/include/__dispatch__/count.hpp"
#include "pythonic/utils/functor.hpp"
PYTHONIC_NS_BEGIN
namespace __dispatch__
{
template <class Any, class Value>
auto count(Any &&any, Value &&value)
-> decltype(any.count(std::forward<Value>(value)))
{
return any.count(std::forward<Value>(value));
}
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,7 @@
#ifndef PYTHONIC_DISPATCH_INDEX_HPP
#define PYTHONIC_DISPATCH_INDEX_HPP
#include "pythonic/include/__dispatch__/index.hpp"
#include "pythonic/operator_/indexOf.hpp"
#endif

View File

@ -0,0 +1,21 @@
#ifndef PYTHONIC_DISPATCH_POP_HPP
#define PYTHONIC_DISPATCH_POP_HPP
#include "pythonic/include/__dispatch__/pop.hpp"
#include "pythonic/utils/functor.hpp"
PYTHONIC_NS_BEGIN
namespace __dispatch__
{
template <class Any, class... Arg0>
auto pop(Any &&any, Arg0 &&... arg0)
-> decltype(any.pop(std::forward<Arg0>(arg0)...))
{
return any.pop(std::forward<Arg0>(arg0)...);
}
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,20 @@
#ifndef PYTHONIC_DISPATCH_REMOVE_HPP
#define PYTHONIC_DISPATCH_REMOVE_HPP
#include "pythonic/include/__dispatch__/remove.hpp"
#include "pythonic/utils/functor.hpp"
PYTHONIC_NS_BEGIN
namespace __dispatch__
{
template <class Any, class Arg0>
auto remove(Any &any, Arg0 const &arg0) -> decltype(any.remove(arg0))
{
return any.remove(arg0);
}
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,38 @@
#ifndef PYTHONIC_DISPATCH_SORT_HPP
#define PYTHONIC_DISPATCH_SORT_HPP
#include "pythonic/include/__dispatch__/sort.hpp"
#include "pythonic/builtins/list/sort.hpp"
#include "pythonic/numpy/sort.hpp"
PYTHONIC_NS_BEGIN
namespace __dispatch__
{
template <class T, class... Args>
auto sort(types::list<T> &l, Args &&... args)
-> decltype(pythonic::builtins::list::sort(l,
std::forward<Args>(args)...))
{
return pythonic::builtins::list::sort(l, std::forward<Args>(args)...);
}
template <class T, class... Args>
auto sort(types::list<T> &&l, Args &&... args)
-> decltype(pythonic::builtins::list::sort(std::move(l),
std::forward<Args>(args)...))
{
return pythonic::builtins::list::sort(std::move(l),
std::forward<Args>(args)...);
}
template <class Any, class... Args>
types::none_type sort(Any &&any, Args &&... args)
{
return pythonic::numpy::ndarray::sort(std::forward<Any>(any),
std::forward<Args>(args)...);
}
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,22 @@
#ifndef PYTHONIC_DISPATCH_UPDATE_HPP
#define PYTHONIC_DISPATCH_UPDATE_HPP
#include "pythonic/include/__dispatch__/update.hpp"
#include "pythonic/utils/functor.hpp"
PYTHONIC_NS_BEGIN
namespace __dispatch__
{
template <class Any, class... Arg0>
auto update(Any &&any, Arg0 &&... arg0)
-> decltype(any.update(std::forward<Arg0>(arg0)...))
{
return any.update(std::forward<Arg0>(arg0)...);
}
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,35 @@
#ifndef PYTHONIC_BISECT_BISECT_HPP
#define PYTHONIC_BISECT_BISECT_HPP
#include "pythonic/include/bisect/bisect.hpp"
#include "pythonic/builtins/ValueError.hpp"
#include "pythonic/utils/functor.hpp"
#include <iterator>
PYTHONIC_NS_BEGIN
namespace bisect
{
template <class X, class A>
long bisect(X const &x, A const &a, long lo,
details::bisect_fun<X, A> const &fun)
{
if (lo < 0)
throw types::ValueError("lo must be non-negative");
return std::distance(x.begin(), fun(x.begin() + lo, x.end(), a));
}
template <class X, class A>
long bisect(X const &x, A const &a, long lo, long hi,
details::bisect_fun<X, A> const &fun)
{
if (lo < 0)
throw types::ValueError("lo must be non-negative");
return std::distance(x.begin(), fun(x.begin() + lo, x.begin() + hi, a));
}
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,30 @@
#ifndef PYTHONIC_BISECT_BISECTLEFT_HPP
#define PYTHONIC_BISECT_BISECTLEFT_HPP
#include "pythonic/include/bisect/bisect_left.hpp"
#include "pythonic/bisect/bisect.hpp"
#include "pythonic/utils/functor.hpp"
#include <algorithm>
PYTHONIC_NS_BEGIN
namespace bisect
{
template <class X, class A>
long bisect_left(X const &x, A const &a, long lo)
{
return bisect(x, a, lo, std::lower_bound<typename X::const_iterator, A>);
}
template <class X, class A>
long bisect_left(X const &x, A const &a, long lo, long hi)
{
return bisect(x, a, lo, hi,
std::lower_bound<typename X::const_iterator, A>);
}
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,28 @@
#ifndef PYTHONIC_BISECT_BISECTRIGHT_HPP
#define PYTHONIC_BISECT_BISECTRIGHT_HPP
#include "pythonic/include/bisect/bisect_right.hpp"
#include "pythonic/bisect/bisect.hpp"
#include "pythonic/utils/functor.hpp"
PYTHONIC_NS_BEGIN
namespace bisect
{
template <class X, class A>
long bisect_right(X const &x, A const &a, long lo)
{
return bisect(x, a, lo);
}
template <class X, class A>
long bisect_right(X const &x, A const &a, long lo, long hi)
{
return bisect(x, a, lo, hi);
}
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,17 @@
#ifndef PYTHONIC_BUILTIN_ARITHMETICERROR_HPP
#define PYTHONIC_BUILTIN_ARITHMETICERROR_HPP
#include "pythonic/include/builtins/ArithmeticError.hpp"
#include "pythonic/types/exceptions.hpp"
PYTHONIC_NS_BEGIN
namespace builtins
{
PYTHONIC_EXCEPTION_IMPL(ArithmeticError)
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,17 @@
#ifndef PYTHONIC_BUILTIN_ASSERTIONERROR_HPP
#define PYTHONIC_BUILTIN_ASSERTIONERROR_HPP
#include "pythonic/include/builtins/AssertionError.hpp"
#include "pythonic/types/exceptions.hpp"
PYTHONIC_NS_BEGIN
namespace builtins
{
PYTHONIC_EXCEPTION_IMPL(AssertionError)
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,17 @@
#ifndef PYTHONIC_BUILTIN_ATTRIBUTEERROR_HPP
#define PYTHONIC_BUILTIN_ATTRIBUTEERROR_HPP
#include "pythonic/include/builtins/AttributeError.hpp"
#include "pythonic/types/exceptions.hpp"
PYTHONIC_NS_BEGIN
namespace builtins
{
PYTHONIC_EXCEPTION_IMPL(AttributeError)
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,17 @@
#ifndef PYTHONIC_BUILTIN_BASEEXCEPTION_HPP
#define PYTHONIC_BUILTIN_BASEEXCEPTION_HPP
#include "pythonic/include/builtins/BaseException.hpp"
#include "pythonic/types/exceptions.hpp"
PYTHONIC_NS_BEGIN
namespace builtins
{
PYTHONIC_EXCEPTION_IMPL(BaseException)
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,17 @@
#ifndef PYTHONIC_BUILTIN_BUFFERERROR_HPP
#define PYTHONIC_BUILTIN_BUFFERERROR_HPP
#include "pythonic/include/builtins/BufferError.hpp"
#include "pythonic/types/exceptions.hpp"
PYTHONIC_NS_BEGIN
namespace builtins
{
PYTHONIC_EXCEPTION_IMPL(BufferError)
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,17 @@
#ifndef PYTHONIC_BUILTIN_BYTESWARNING_HPP
#define PYTHONIC_BUILTIN_BYTESWARNING_HPP
#include "pythonic/include/builtins/BytesWarning.hpp"
#include "pythonic/types/exceptions.hpp"
PYTHONIC_NS_BEGIN
namespace builtins
{
PYTHONIC_EXCEPTION_IMPL(BytesWarning)
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,17 @@
#ifndef PYTHONIC_BUILTIN_DEPRECATIONWARNING_HPP
#define PYTHONIC_BUILTIN_DEPRECATIONWARNING_HPP
#include "pythonic/include/builtins/DeprecationWarning.hpp"
#include "pythonic/types/exceptions.hpp"
PYTHONIC_NS_BEGIN
namespace builtins
{
PYTHONIC_EXCEPTION_IMPL(DeprecationWarning)
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,17 @@
#ifndef PYTHONIC_BUILTIN_EOFERROR_HPP
#define PYTHONIC_BUILTIN_EOFERROR_HPP
#include "pythonic/include/builtins/EOFError.hpp"
#include "pythonic/types/exceptions.hpp"
PYTHONIC_NS_BEGIN
namespace builtins
{
PYTHONIC_EXCEPTION_IMPL(EOFError)
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,17 @@
#ifndef PYTHONIC_BUILTIN_ENVIRONMENTERROR_HPP
#define PYTHONIC_BUILTIN_ENVIRONMENTERROR_HPP
#include "pythonic/include/builtins/EnvironmentError.hpp"
#include "pythonic/types/exceptions.hpp"
PYTHONIC_NS_BEGIN
namespace builtins
{
PYTHONIC_EXCEPTION_IMPL(EnvironmentError)
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,17 @@
#ifndef PYTHONIC_BUILTIN_EXCEPTION_HPP
#define PYTHONIC_BUILTIN_EXCEPTION_HPP
#include "pythonic/include/builtins/Exception.hpp"
#include "pythonic/types/exceptions.hpp"
PYTHONIC_NS_BEGIN
namespace builtins
{
PYTHONIC_EXCEPTION_IMPL(Exception)
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,6 @@
#ifndef PYTHONIC_BUILTIN_FALSE_HPP
#define PYTHONIC_BUILTIN_FALSE_HPP
#include "pythonic/include/builtins/False.hpp"
#endif

View File

@ -0,0 +1,17 @@
#ifndef PYTHONIC_BUILTIN_FILENOTFOUNDERROR_HPP
#define PYTHONIC_BUILTIN_FILENOTFOUNDERROR_HPP
#include "pythonic/include/builtins/FileNotFoundError.hpp"
#include "pythonic/types/exceptions.hpp"
PYTHONIC_NS_BEGIN
namespace builtins
{
PYTHONIC_EXCEPTION_IMPL(FileNotFoundError)
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,17 @@
#ifndef PYTHONIC_BUILTIN_FLOATINGPOINTERROR_HPP
#define PYTHONIC_BUILTIN_FLOATINGPOINTERROR_HPP
#include "pythonic/include/builtins/FloatingPointError.hpp"
#include "pythonic/types/exceptions.hpp"
PYTHONIC_NS_BEGIN
namespace builtins
{
PYTHONIC_EXCEPTION_IMPL(FloatingPointError)
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,17 @@
#ifndef PYTHONIC_BUILTIN_FUTUREWARNING_HPP
#define PYTHONIC_BUILTIN_FUTUREWARNING_HPP
#include "pythonic/include/builtins/FutureWarning.hpp"
#include "pythonic/types/exceptions.hpp"
PYTHONIC_NS_BEGIN
namespace builtins
{
PYTHONIC_EXCEPTION_IMPL(FutureWarning)
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,17 @@
#ifndef PYTHONIC_BUILTIN_GENERATOREXIT_HPP
#define PYTHONIC_BUILTIN_GENERATOREXIT_HPP
#include "pythonic/include/builtins/GeneratorExit.hpp"
#include "pythonic/types/exceptions.hpp"
PYTHONIC_NS_BEGIN
namespace builtins
{
PYTHONIC_EXCEPTION_IMPL(GeneratorExit)
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,17 @@
#ifndef PYTHONIC_BUILTIN_IOERROR_HPP
#define PYTHONIC_BUILTIN_IOERROR_HPP
#include "pythonic/include/builtins/IOError.hpp"
#include "pythonic/types/exceptions.hpp"
PYTHONIC_NS_BEGIN
namespace builtins
{
PYTHONIC_EXCEPTION_IMPL(IOError)
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,17 @@
#ifndef PYTHONIC_BUILTIN_IMPORTERROR_HPP
#define PYTHONIC_BUILTIN_IMPORTERROR_HPP
#include "pythonic/include/builtins/ImportError.hpp"
#include "pythonic/types/exceptions.hpp"
PYTHONIC_NS_BEGIN
namespace builtins
{
PYTHONIC_EXCEPTION_IMPL(ImportError)
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,17 @@
#ifndef PYTHONIC_BUILTIN_IMPORTWARNING_HPP
#define PYTHONIC_BUILTIN_IMPORTWARNING_HPP
#include "pythonic/include/builtins/ImportWarning.hpp"
#include "pythonic/types/exceptions.hpp"
PYTHONIC_NS_BEGIN
namespace builtins
{
PYTHONIC_EXCEPTION_IMPL(ImportWarning)
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,17 @@
#ifndef PYTHONIC_BUILTIN_INDENTATIONERROR_HPP
#define PYTHONIC_BUILTIN_INDENTATIONERROR_HPP
#include "pythonic/include/builtins/IndentationError.hpp"
#include "pythonic/types/exceptions.hpp"
PYTHONIC_NS_BEGIN
namespace builtins
{
PYTHONIC_EXCEPTION_IMPL(IndentationError)
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,17 @@
#ifndef PYTHONIC_BUILTIN_INDEXERROR_HPP
#define PYTHONIC_BUILTIN_INDEXERROR_HPP
#include "pythonic/include/builtins/IndexError.hpp"
#include "pythonic/types/exceptions.hpp"
PYTHONIC_NS_BEGIN
namespace builtins
{
PYTHONIC_EXCEPTION_IMPL(IndexError)
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,17 @@
#ifndef PYTHONIC_BUILTIN_KEYERROR_HPP
#define PYTHONIC_BUILTIN_KEYERROR_HPP
#include "pythonic/include/builtins/KeyError.hpp"
#include "pythonic/types/exceptions.hpp"
PYTHONIC_NS_BEGIN
namespace builtins
{
PYTHONIC_EXCEPTION_IMPL(KeyError)
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,17 @@
#ifndef PYTHONIC_BUILTIN_KEYBOARDINTERRUPT_HPP
#define PYTHONIC_BUILTIN_KEYBOARDINTERRUPT_HPP
#include "pythonic/include/builtins/KeyboardInterrupt.hpp"
#include "pythonic/types/exceptions.hpp"
PYTHONIC_NS_BEGIN
namespace builtins
{
PYTHONIC_EXCEPTION_IMPL(KeyboardInterrupt)
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,17 @@
#ifndef PYTHONIC_BUILTIN_LOOKUPERROR_HPP
#define PYTHONIC_BUILTIN_LOOKUPERROR_HPP
#include "pythonic/include/builtins/LookupError.hpp"
#include "pythonic/types/exceptions.hpp"
PYTHONIC_NS_BEGIN
namespace builtins
{
PYTHONIC_EXCEPTION_IMPL(LookupError)
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,17 @@
#ifndef PYTHONIC_BUILTIN_MEMORYERROR_HPP
#define PYTHONIC_BUILTIN_MEMORYERROR_HPP
#include "pythonic/include/builtins/MemoryError.hpp"
#include "pythonic/types/exceptions.hpp"
PYTHONIC_NS_BEGIN
namespace builtins
{
PYTHONIC_EXCEPTION_IMPL(MemoryError)
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,17 @@
#ifndef PYTHONIC_BUILTIN_NAMEERROR_HPP
#define PYTHONIC_BUILTIN_NAMEERROR_HPP
#include "pythonic/include/builtins/NameError.hpp"
#include "pythonic/types/exceptions.hpp"
PYTHONIC_NS_BEGIN
namespace builtins
{
PYTHONIC_EXCEPTION_IMPL(NameError)
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,6 @@
#ifndef PYTHONIC_BUILTIN_NONE_HPP
#define PYTHONIC_BUILTIN_NONE_HPP
#include "pythonic/include/builtins/None.hpp"
#endif

View File

@ -0,0 +1,17 @@
#ifndef PYTHONIC_BUILTIN_NOTIMPLEMENTEDERROR_HPP
#define PYTHONIC_BUILTIN_NOTIMPLEMENTEDERROR_HPP
#include "pythonic/include/builtins/NotImplementedError.hpp"
#include "pythonic/types/exceptions.hpp"
PYTHONIC_NS_BEGIN
namespace builtins
{
PYTHONIC_EXCEPTION_IMPL(NotImplementedError)
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,17 @@
#ifndef PYTHONIC_BUILTIN_OSERROR_HPP
#define PYTHONIC_BUILTIN_OSERROR_HPP
#include "pythonic/include/builtins/OSError.hpp"
#include "pythonic/types/exceptions.hpp"
PYTHONIC_NS_BEGIN
namespace builtins
{
PYTHONIC_EXCEPTION_IMPL(OSError)
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,17 @@
#ifndef PYTHONIC_BUILTIN_OVERFLOWERROR_HPP
#define PYTHONIC_BUILTIN_OVERFLOWERROR_HPP
#include "pythonic/include/builtins/OverflowError.hpp"
#include "pythonic/types/exceptions.hpp"
PYTHONIC_NS_BEGIN
namespace builtins
{
PYTHONIC_EXCEPTION_IMPL(OverflowError)
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,17 @@
#ifndef PYTHONIC_BUILTIN_PENDINGDEPRECATIONWARNING_HPP
#define PYTHONIC_BUILTIN_PENDINGDEPRECATIONWARNING_HPP
#include "pythonic/include/builtins/PendingDeprecationWarning.hpp"
#include "pythonic/types/exceptions.hpp"
PYTHONIC_NS_BEGIN
namespace builtins
{
PYTHONIC_EXCEPTION_IMPL(PendingDeprecationWarning)
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,17 @@
#ifndef PYTHONIC_BUILTIN_REFERENCEERROR_HPP
#define PYTHONIC_BUILTIN_REFERENCEERROR_HPP
#include "pythonic/include/builtins/ReferenceError.hpp"
#include "pythonic/types/exceptions.hpp"
PYTHONIC_NS_BEGIN
namespace builtins
{
PYTHONIC_EXCEPTION_IMPL(ReferenceError)
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,17 @@
#ifndef PYTHONIC_BUILTIN_RUNTIMEERROR_HPP
#define PYTHONIC_BUILTIN_RUNTIMEERROR_HPP
#include "pythonic/include/builtins/RuntimeError.hpp"
#include "pythonic/types/exceptions.hpp"
PYTHONIC_NS_BEGIN
namespace builtins
{
PYTHONIC_EXCEPTION_IMPL(RuntimeError)
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,17 @@
#ifndef PYTHONIC_BUILTIN_RUNTIMEWARNING_HPP
#define PYTHONIC_BUILTIN_RUNTIMEWARNING_HPP
#include "pythonic/include/builtins/RuntimeWarning.hpp"
#include "pythonic/types/exceptions.hpp"
PYTHONIC_NS_BEGIN
namespace builtins
{
PYTHONIC_EXCEPTION_IMPL(RuntimeWarning)
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,17 @@
#ifndef PYTHONIC_BUILTIN_STOPITERATION_HPP
#define PYTHONIC_BUILTIN_STOPITERATION_HPP
#include "pythonic/include/builtins/StopIteration.hpp"
#include "pythonic/types/exceptions.hpp"
PYTHONIC_NS_BEGIN
namespace builtins
{
PYTHONIC_EXCEPTION_IMPL(StopIteration)
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,17 @@
#ifndef PYTHONIC_BUILTIN_SYNTAXERROR_HPP
#define PYTHONIC_BUILTIN_SYNTAXERROR_HPP
#include "pythonic/include/builtins/SyntaxError.hpp"
#include "pythonic/types/exceptions.hpp"
PYTHONIC_NS_BEGIN
namespace builtins
{
PYTHONIC_EXCEPTION_IMPL(SyntaxError)
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,17 @@
#ifndef PYTHONIC_BUILTIN_SYNTAXWARNING_HPP
#define PYTHONIC_BUILTIN_SYNTAXWARNING_HPP
#include "pythonic/include/builtins/SyntaxWarning.hpp"
#include "pythonic/types/exceptions.hpp"
PYTHONIC_NS_BEGIN
namespace builtins
{
PYTHONIC_EXCEPTION_IMPL(SyntaxWarning)
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,17 @@
#ifndef PYTHONIC_BUILTIN_SYSTEMERROR_HPP
#define PYTHONIC_BUILTIN_SYSTEMERROR_HPP
#include "pythonic/include/builtins/SystemError.hpp"
#include "pythonic/types/exceptions.hpp"
PYTHONIC_NS_BEGIN
namespace builtins
{
PYTHONIC_EXCEPTION_IMPL(SystemError)
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,17 @@
#ifndef PYTHONIC_BUILTIN_SYSTEMEXIT_HPP
#define PYTHONIC_BUILTIN_SYSTEMEXIT_HPP
#include "pythonic/include/builtins/SystemExit.hpp"
#include "pythonic/types/exceptions.hpp"
PYTHONIC_NS_BEGIN
namespace builtins
{
PYTHONIC_EXCEPTION_IMPL(SystemExit)
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,17 @@
#ifndef PYTHONIC_BUILTIN_TABERROR_HPP
#define PYTHONIC_BUILTIN_TABERROR_HPP
#include "pythonic/include/builtins/TabError.hpp"
#include "pythonic/types/exceptions.hpp"
PYTHONIC_NS_BEGIN
namespace builtins
{
PYTHONIC_EXCEPTION_IMPL(TabError)
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,6 @@
#ifndef PYTHONIC_BUILTIN_TRUE_HPP
#define PYTHONIC_BUILTIN_TRUE_HPP
#include "pythonic/include/builtins/True.hpp"
#endif

View File

@ -0,0 +1,17 @@
#ifndef PYTHONIC_BUILTIN_TYPEERROR_HPP
#define PYTHONIC_BUILTIN_TYPEERROR_HPP
#include "pythonic/include/builtins/TypeError.hpp"
#include "pythonic/types/exceptions.hpp"
PYTHONIC_NS_BEGIN
namespace builtins
{
PYTHONIC_EXCEPTION_IMPL(TypeError)
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,17 @@
#ifndef PYTHONIC_BUILTIN_UNBOUNDLOCALERROR_HPP
#define PYTHONIC_BUILTIN_UNBOUNDLOCALERROR_HPP
#include "pythonic/include/builtins/UnboundLocalError.hpp"
#include "pythonic/types/exceptions.hpp"
PYTHONIC_NS_BEGIN
namespace builtins
{
PYTHONIC_EXCEPTION_IMPL(UnboundLocalError)
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,17 @@
#ifndef PYTHONIC_BUILTIN_UNICODEERROR_HPP
#define PYTHONIC_BUILTIN_UNICODEERROR_HPP
#include "pythonic/include/builtins/UnicodeError.hpp"
#include "pythonic/types/exceptions.hpp"
PYTHONIC_NS_BEGIN
namespace builtins
{
PYTHONIC_EXCEPTION_IMPL(UnicodeError)
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,17 @@
#ifndef PYTHONIC_BUILTIN_UNICODEWARNING_HPP
#define PYTHONIC_BUILTIN_UNICODEWARNING_HPP
#include "pythonic/include/builtins/UnicodeWarning.hpp"
#include "pythonic/types/exceptions.hpp"
PYTHONIC_NS_BEGIN
namespace builtins
{
PYTHONIC_EXCEPTION_IMPL(UnicodeWarning)
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,17 @@
#ifndef PYTHONIC_BUILTIN_USERWARNING_HPP
#define PYTHONIC_BUILTIN_USERWARNING_HPP
#include "pythonic/include/builtins/UserWarning.hpp"
#include "pythonic/types/exceptions.hpp"
PYTHONIC_NS_BEGIN
namespace builtins
{
PYTHONIC_EXCEPTION_IMPL(UserWarning)
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,17 @@
#ifndef PYTHONIC_BUILTIN_VALUEERROR_HPP
#define PYTHONIC_BUILTIN_VALUEERROR_HPP
#include "pythonic/include/builtins/ValueError.hpp"
#include "pythonic/types/exceptions.hpp"
PYTHONIC_NS_BEGIN
namespace builtins
{
PYTHONIC_EXCEPTION_IMPL(ValueError)
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,17 @@
#ifndef PYTHONIC_BUILTIN_WARNING_HPP
#define PYTHONIC_BUILTIN_WARNING_HPP
#include "pythonic/include/builtins/Warning.hpp"
#include "pythonic/types/exceptions.hpp"
PYTHONIC_NS_BEGIN
namespace builtins
{
PYTHONIC_EXCEPTION_IMPL(Warning)
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,17 @@
#ifndef PYTHONIC_BUILTIN_ZERODIVISIONERROR_HPP
#define PYTHONIC_BUILTIN_ZERODIVISIONERROR_HPP
#include "pythonic/include/builtins/ZeroDivisionError.hpp"
#include "pythonic/types/exceptions.hpp"
PYTHONIC_NS_BEGIN
namespace builtins
{
PYTHONIC_EXCEPTION_IMPL(ZeroDivisionError)
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,7 @@
#ifndef PYTHONIC_BUILTIN_ABS_HPP
#define PYTHONIC_BUILTIN_ABS_HPP
#include "pythonic/include/builtins/abs.hpp"
#include "pythonic/numpy/abs.hpp"
#endif

View File

@ -0,0 +1,24 @@
#ifndef PYTHONIC_BUILTIN_ALL_HPP
#define PYTHONIC_BUILTIN_ALL_HPP
#include "pythonic/utils/functor.hpp"
#include "pythonic/include/builtins/all.hpp"
PYTHONIC_NS_BEGIN
namespace builtins
{
template <class Iterable>
bool all(Iterable &&s)
{
auto iend = s.end();
for (auto iter = s.begin(); iter != iend; ++iter)
if (!*iter)
return false;
return true;
}
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,24 @@
#ifndef PYTHONIC_BUILTIN_ANY_HPP
#define PYTHONIC_BUILTIN_ANY_HPP
#include "pythonic/include/builtins/any.hpp"
#include "pythonic/utils/functor.hpp"
PYTHONIC_NS_BEGIN
namespace builtins
{
template <class Iterable>
bool any(Iterable &&s)
{
auto iend = s.end();
for (auto iter = s.begin(); iter != iend; ++iter)
if (*iter)
return true;
return false;
}
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,28 @@
#ifndef PYTHONIC_BUILTIN_ASSERT_HPP
#define PYTHONIC_BUILTIN_ASSERT_HPP
#include "pythonic/include/builtins/assert.hpp"
#include "pythonic/builtins/AssertionError.hpp"
#include "pythonic/types/str.hpp"
PYTHONIC_NS_BEGIN
void pythran_assert(bool cond)
{
#ifndef NDEBUG
if (!cond)
throw types::AssertionError();
#endif
}
void pythran_assert(bool cond, types::str const &what)
{
#ifndef NDEBUG
if (!cond)
throw types::AssertionError(what);
#endif
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,64 @@
#ifndef PYTHONIC_BUILTIN_BIN_HPP
#define PYTHONIC_BUILTIN_BIN_HPP
#include "pythonic/include/builtins/bin.hpp"
#include "pythonic/types/str.hpp"
#include "pythonic/utils/functor.hpp"
#include <algorithm>
#include <cmath>
#include <limits>
PYTHONIC_NS_BEGIN
namespace builtins
{
template <class T>
typename std::enable_if<std::is_scalar<T>::value, types::str>::type
bin(T const &v)
{
using UT = typename std::make_unsigned<T>::type;
if (v < T{0})
if (v == std::numeric_limits<T>::min()) {
// In this special case, calling -v would overflow so
// a special case is needed.
types::str res;
auto &backend = res.chars();
backend.resize(8 * sizeof(T) + 3);
auto it = backend.begin();
*it++ = '-';
*it++ = '0';
*it++ = 'b';
*it++ = '1';
std::fill(it, backend.end(), '0');
return res;
} else
return "-" + bin(-v);
else if (v == T{0})
return "0b0";
else {
// Due to rounding errors, we cannot use std::log2(v)
// to accuratly find length.
size_t len = (8 * sizeof(UT)) - 1;
UT i{UT{1} << len};
while (!(i & v)) {
i >>= 1;
len--;
}
types::str res;
res.reserve(2 + len);
auto &backend = res.chars();
backend.append("0b");
for (; i; i >>= 1)
if (v & i)
backend.append("1");
else
backend.append("0");
return res;
}
}
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,42 @@
#ifndef PYTHONIC_BUILTIN_BOOL_HPP
#define PYTHONIC_BUILTIN_BOOL_HPP
#include "pythonic/include/builtins/bool_.hpp"
#include "pythonic/utils/functor.hpp"
#include "pythonic/types/tuple.hpp"
PYTHONIC_NS_BEGIN
namespace builtins
{
namespace functor
{
template <class T>
bool bool_::operator()(T const &val) const
{
return static_cast<bool>(val);
}
template <class... Ts>
bool bool_::operator()(std::tuple<Ts...> const &val) const
{
return sizeof...(Ts);
}
template <class T, size_t N>
bool bool_::operator()(types::array<T, N> const &val) const
{
return N;
}
bool bool_::operator()() const
{
return false;
}
}
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,21 @@
#ifndef PYTHONIC_BUILTIN_CHR_HPP
#define PYTHONIC_BUILTIN_CHR_HPP
#include "pythonic/include/builtins/chr.hpp"
#include "pythonic/types/str.hpp"
#include "pythonic/utils/functor.hpp"
PYTHONIC_NS_BEGIN
namespace builtins
{
template <class T>
types::str chr(T const &v)
{
return types::str((char)v);
}
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,24 @@
#ifndef PYTHONIC_BUILTIN_COMPLEX_HPP
#define PYTHONIC_BUILTIN_COMPLEX_HPP
#include "pythonic/include/builtins/complex.hpp"
#include "pythonic/types/complex.hpp"
#include "pythonic/utils/functor.hpp"
PYTHONIC_NS_BEGIN
namespace builtins
{
namespace functor
{
complex::type complex::operator()(double v0, double v1) const
{
return {v0, v1};
}
}
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,7 @@
#ifndef PYTHONIC_BUILTIN_COMPLEX_CONJUGATE_HPP
#define PYTHONIC_BUILTIN_COMPLEX_CONJUGATE_HPP
#include "pythonic/include/builtins/complex/conjugate.hpp"
#include "pythonic/numpy/conjugate.hpp"
#endif

View File

@ -0,0 +1,47 @@
#ifndef PYTHONIC_BUILTIN_DICT_HPP
#define PYTHONIC_BUILTIN_DICT_HPP
#include "pythonic/include/builtins/dict.hpp"
#include "pythonic/types/dict.hpp"
#include "pythonic/utils/functor.hpp"
#include <tuple>
#include <utility>
PYTHONIC_NS_BEGIN
namespace builtins
{
namespace anonymous
{
types::empty_dict dict()
{
return types::empty_dict();
}
template <class K, class V>
types::dict<K, V> dict(types::dict<K, V> const &other)
{
return other.copy();
}
template <class Iterable>
auto dict(Iterable &&iterable) -> types::dict<
typename std::decay<decltype(std::get<0>(*iterable.begin()))>::type,
typename std::decay<decltype(std::get<1>(*iterable.begin()))>::type>
{
types::dict<
typename std::decay<decltype(std::get<0>(*iterable.begin()))>::type,
typename std::decay<decltype(std::get<1>(*iterable.begin()))>::type>
out = types::empty_dict();
for (auto const &i : iterable)
out[std::get<0>(i)] = std::get<1>(i);
return out;
}
}
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,7 @@
#ifndef PYTHONIC_BUILTIN_DICT_CLEAR_HPP
#define PYTHONIC_BUILTIN_DICT_CLEAR_HPP
#include "pythonic/include/builtins/dict/clear.hpp"
#include "pythonic/__dispatch__/clear.hpp"
#endif

View File

@ -0,0 +1,7 @@
#ifndef PYTHONIC_BUILTIN_DICT_COPY_HPP
#define PYTHONIC_BUILTIN_DICT_COPY_HPP
#include "pythonic/include/builtins/dict/copy.hpp"
#include "pythonic/__dispatch__/copy.hpp"
#endif

View File

@ -0,0 +1,34 @@
#ifndef PYTHONIC_BUILTIN_DICT_FROMKEYS_HPP
#define PYTHONIC_BUILTIN_DICT_FROMKEYS_HPP
#include "pythonic/include/builtins/dict/fromkeys.hpp"
#include "pythonic/types/dict.hpp"
#include "pythonic/utils/functor.hpp"
#include <type_traits>
PYTHONIC_NS_BEGIN
namespace builtins
{
namespace dict
{
template <class Iterable, class V>
types::dict<typename std::remove_reference<Iterable>::type::value_type, V>
fromkeys(Iterable &&iter, V const &v)
{
types::dict<typename std::remove_reference<Iterable>::type::value_type,
V> D =
types::empty_dict(); // Allocate default capacity to dict
for (auto const &i : iter)
D[i] = v;
return D;
}
}
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,39 @@
#ifndef PYTHONIC_BUILTIN_DICT_GET_HPP
#define PYTHONIC_BUILTIN_DICT_GET_HPP
#include "pythonic/include/builtins/dict/get.hpp"
#include "pythonic/types/dict.hpp"
#include "pythonic/types/NoneType.hpp"
#include "pythonic/utils/functor.hpp"
PYTHONIC_NS_BEGIN
namespace builtins
{
namespace dict
{
template <class K, class V, class W, class X>
typename __combined<V, X>::type get(types::dict<K, V> const &d, W const &k,
X const &default_)
{
return d.get(k, default_);
}
template <class K, class V, class W>
types::none<V> get(types::dict<K, V> const &d, W const &k)
{
return d.get(k);
}
template <class W, class X>
X get(types::empty_dict const &, W const &, X const &default_)
{
return default_;
}
}
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,29 @@
#ifndef PYTHONIC_BUILTIN_DICT_ITEMS_HPP
#define PYTHONIC_BUILTIN_DICT_ITEMS_HPP
#include "pythonic/include/builtins/dict/items.hpp"
#include "pythonic/include/utils/functor.hpp"
#include "pythonic/include/types/dict.hpp"
#include "pythonic/include/types/list.hpp"
#include <tuple>
PYTHONIC_NS_BEGIN
namespace builtins
{
namespace dict
{
template <class D>
auto items(D &&d) -> decltype(std::forward<D>(d).items())
{
return std::forward<D>(d).items();
}
}
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,30 @@
#ifndef PYTHONIC_BUILTIN_DICT_KEYS_HPP
#define PYTHONIC_BUILTIN_DICT_KEYS_HPP
#include "pythonic/include/builtins/dict/keys.hpp"
#include "pythonic/types/dict.hpp"
#include "pythonic/types/list.hpp"
#include "pythonic/utils/functor.hpp"
PYTHONIC_NS_BEGIN
namespace builtins
{
namespace dict
{
// We need a copy here for lvalue like :
// for i in {"a": "b", "c": "d"}.keys():
// pass
template <class D>
auto keys(D &&d) -> decltype(std::forward<D>(d).keys())
{
return std::forward<D>(d).keys();
}
}
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,7 @@
#ifndef PYTHONIC_BUILTIN_DICT_POP_HPP
#define PYTHONIC_BUILTIN_DICT_POP_HPP
#include "pythonic/include/builtins/dict/pop.hpp"
#include "pythonic/__dispatch__/pop.hpp"
#endif

View File

@ -0,0 +1,28 @@
#ifndef PYTHONIC_BUILTIN_DICT_POPITEM_HPP
#define PYTHONIC_BUILTIN_DICT_POPITEM_HPP
#include "pythonic/include/builtins/dict/popitem.hpp"
#include "pythonic/types/dict.hpp"
#include "pythonic/utils/functor.hpp"
#include <tuple>
PYTHONIC_NS_BEGIN
namespace builtins
{
namespace dict
{
template <class D>
auto popitem(D &&d) -> decltype(std::forward<D>(d).popitem())
{
return std::forward<D>(d).popitem();
}
}
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,44 @@
#ifndef PYTHONIC_BUILTIN_DICT_SETDEFAULT_HPP
#define PYTHONIC_BUILTIN_DICT_SETDEFAULT_HPP
#include "pythonic/include/builtins/dict/setdefault.hpp"
#include "pythonic/types/dict.hpp"
#include "pythonic/utils/functor.hpp"
PYTHONIC_NS_BEGIN
namespace builtins
{
namespace dict
{
template <class K, class V, class W, class X>
V &setdefault(types::dict<K, V> &d, W const &k, X const &default_)
{
return d.setdefault(k, default_);
}
template <class K, class V, class W>
types::none<V> setdefault(types::dict<K, V> &d, W const &k)
{
return d.get(k);
}
template <class K, class V, class W, class X>
V setdefault(types::dict<K, V> &&d, W const &k, X const &default_)
{
return d.setdefault(k, default_);
}
template <class K, class V, class W>
types::none<V> setdefault(types::dict<K, V> &&d, W const &k)
{
return d.get(k);
}
}
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,7 @@
#ifndef PYTHONIC_BUILTIN_DICT_UPDATE_HPP
#define PYTHONIC_BUILTIN_DICT_UPDATE_HPP
#include "pythonic/include/builtins/dict/update.hpp"
#include "pythonic/__dispatch__/update.hpp"
#endif

View File

@ -0,0 +1,26 @@
#ifndef PYTHONIC_BUILTIN_DICT_VALUES_HPP
#define PYTHONIC_BUILTIN_DICT_VALUES_HPP
#include "pythonic/include/builtins/dict/values.hpp"
#include "pythonic/types/dict.hpp"
#include "pythonic/utils/functor.hpp"
PYTHONIC_NS_BEGIN
namespace builtins
{
namespace dict
{
template <class D>
auto values(D &&d) -> decltype(std::forward<D>(d).values())
{
return std::forward<D>(d).values();
}
}
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,23 @@
#ifndef PYTHONIC_BUILTIN_DIVMOD_HPP
#define PYTHONIC_BUILTIN_DIVMOD_HPP
#include "pythonic/include/builtins/divmod.hpp"
#include "pythonic/types/tuple.hpp"
#include "pythonic/utils/functor.hpp"
PYTHONIC_NS_BEGIN
namespace builtins
{
template <class T0, class T1>
auto divmod(T0 const &t0, T1 const &t1) // other types are left over
-> decltype(types::make_tuple(t0 / t1, t0 % t1))
{
return types::make_tuple(t0 / t1, t0 % t1);
}
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,117 @@
#ifndef PYTHONIC_BUILTIN_ENUMERATE_HPP
#define PYTHONIC_BUILTIN_ENUMERATE_HPP
#include "pythonic/include/builtins/enumerate.hpp"
#include "pythonic/utils/functor.hpp"
#include <tuple>
PYTHONIC_NS_BEGIN
namespace builtins
{
namespace details
{
/// enumerate_iterator implementation
template <class Iterator>
enumerate_iterator<Iterator>::enumerate_iterator()
{
}
template <class Iterator>
enumerate_iterator<Iterator>::enumerate_iterator(Iterator const &iter,
long first)
: value(first), iter(iter)
{
}
template <class Iterator>
enumerate_iterator<Iterator> &enumerate_iterator<Iterator>::
operator+=(long n)
{
value += n, iter += n;
return *this;
}
// Comparison operators can't use value as end() doesn't have a valid
// value content
// du to the lake of size information for generator
// TODO : We could handle case with && without size if there is a
// performances benefits
template <class Iterator>
bool enumerate_iterator<Iterator>::
operator!=(enumerate_iterator<Iterator> const &other) const
{
return !(*this == other);
}
template <class Iterator>
bool enumerate_iterator<Iterator>::
operator<(enumerate_iterator const &other) const
{
return iter < other.iter;
}
template <class Iterator>
bool enumerate_iterator<Iterator>::
operator==(enumerate_iterator<Iterator> const &other) const
{
return iter == other.iter;
}
template <class Iterator>
long enumerate_iterator<Iterator>::
operator-(enumerate_iterator<Iterator> const &other) const
{
return iter - other.iter;
}
/// details::enumerate implementation
template <class Iterable>
enumerate<Iterable>::enumerate()
{
}
template <class Iterable>
enumerate<Iterable>::enumerate(Iterable seq, long first)
: Iterable(seq), iterator(Iterable::begin(), first),
end_iter(Iterable::end(), -1)
{
}
template <class Iterable>
typename enumerate<Iterable>::iterator &enumerate<Iterable>::begin()
{
return *this;
}
template <class Iterable>
typename enumerate<Iterable>::iterator const &
enumerate<Iterable>::begin() const
{
return *this;
}
template <class Iterable>
typename enumerate<Iterable>::iterator enumerate<Iterable>::end() const
{
return end_iter;
}
}
/// enumerate implementation
template <class Iterable>
details::enumerate<typename std::remove_cv<
typename std::remove_reference<Iterable>::type>::type>
enumerate(Iterable &&seq, long first)
{
return {std::forward<Iterable>(seq), first};
}
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,25 @@
#ifndef PYTHONIC_BUILTIN_FILE_HPP
#define PYTHONIC_BUILTIN_FILE_HPP
#include "pythonic/include/builtins/file.hpp"
#include "pythonic/types/file.hpp"
#include "pythonic/types/str.hpp"
#include "pythonic/utils/functor.hpp"
PYTHONIC_NS_BEGIN
namespace builtins
{
namespace anonymous
{
types::file file(types::str const &filename, types::str const &strmode)
{
return {filename, strmode};
}
}
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,29 @@
#ifndef PYTHONIC_BUILTIN_FILE_CLOSE_HPP
#define PYTHONIC_BUILTIN_FILE_CLOSE_HPP
#include "pythonic/include/builtins/file/close.hpp"
#include "pythonic/types/file.hpp"
#include "pythonic/utils/functor.hpp"
PYTHONIC_NS_BEGIN
namespace builtins
{
namespace file
{
void close(types::file &f)
{
f.close();
}
void close(types::file &&f)
{
f.close();
}
}
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,24 @@
#ifndef PYTHONIC_BUILTIN_FILE_FILENO_HPP
#define PYTHONIC_BUILTIN_FILE_FILENO_HPP
#include "pythonic/include/builtins/file/fileno.hpp"
#include "pythonic/types/file.hpp"
#include "pythonic/utils/functor.hpp"
PYTHONIC_NS_BEGIN
namespace builtins
{
namespace file
{
long fileno(types::file const &f)
{
return f.fileno();
}
}
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,29 @@
#ifndef PYTHONIC_BUILTIN_FILE_FLUSH_HPP
#define PYTHONIC_BUILTIN_FILE_FLUSH_HPP
#include "pythonic/include/builtins/file/flush.hpp"
#include "pythonic/types/file.hpp"
#include "pythonic/utils/functor.hpp"
PYTHONIC_NS_BEGIN
namespace builtins
{
namespace file
{
void flush(types::file &f)
{
f.flush();
}
void flush(types::file &&f)
{
f.flush();
}
}
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,24 @@
#ifndef PYTHONIC_BUILTIN_FILE_ISATTY_HPP
#define PYTHONIC_BUILTIN_FILE_ISATTY_HPP
#include "pythonic/include/builtins/file/isatty.hpp"
#include "pythonic/types/file.hpp"
#include "pythonic/utils/functor.hpp"
PYTHONIC_NS_BEGIN
namespace builtins
{
namespace file
{
bool isatty(types::file const &f)
{
return f.isatty();
}
}
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,7 @@
#ifndef PYTHONIC_BUILTIN_FILE_NEXT_HPP
#define PYTHONIC_BUILTIN_FILE_NEXT_HPP
#include "pythonic/include/builtins/file/next.hpp"
#include "pythonic/__dispatch__/next.hpp"
#endif

View File

@ -0,0 +1,29 @@
#ifndef PYTHONIC_BUILTIN_FILE_READ_HPP
#define PYTHONIC_BUILTIN_FILE_READ_HPP
#include "pythonic/include/builtins/file/read.hpp"
#include "pythonic/types/file.hpp"
#include "pythonic/types/str.hpp"
#include "pythonic/utils/functor.hpp"
PYTHONIC_NS_BEGIN
namespace builtins
{
namespace file
{
types::str read(types::file &f, long size)
{
return f.read(size);
}
types::str read(types::file &&f, long size)
{
return f.read(size);
}
}
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,30 @@
#ifndef PYTHONIC_BUILTIN_FILE_READLINE_HPP
#define PYTHONIC_BUILTIN_FILE_READLINE_HPP
#include "pythonic/include/builtins/file/readline.hpp"
#include "pythonic/types/file.hpp"
#include "pythonic/types/str.hpp"
#include "pythonic/utils/functor.hpp"
PYTHONIC_NS_BEGIN
namespace builtins
{
namespace file
{
types::str readline(types::file &f, long size)
{
return size < 0 ? f.readline() : f.readline(size);
}
types::str readline(types::file &&f, long size)
{
return size < 0 ? f.readline() : f.readline(size);
}
}
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,33 @@
#ifndef PYTHONIC_BUILTIN_FILE_READLINES_HPP
#define PYTHONIC_BUILTIN_FILE_READLINES_HPP
#include "pythonic/include/builtins/file/readlines.hpp"
#include "pythonic/types/file.hpp"
#include "pythonic/types/list.hpp"
#include "pythonic/types/str.hpp"
#include "pythonic/utils/functor.hpp"
PYTHONIC_NS_BEGIN
namespace builtins
{
namespace file
{
template <class F>
types::list<types::str> readlines(F &&f)
{
return f.readlines();
}
template <class F>
types::list<types::str> readlines(F &&f, long sizehint)
{
return f.readlines(sizehint);
}
}
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,39 @@
#ifndef PYTHONIC_BUILTIN_FILE_SEEK_HPP
#define PYTHONIC_BUILTIN_FILE_SEEK_HPP
#include "pythonic/include/builtins/file/seek.hpp"
#include "pythonic/types/file.hpp"
#include "pythonic/utils/functor.hpp"
PYTHONIC_NS_BEGIN
namespace builtins
{
namespace file
{
void seek(types::file &f, long offset)
{
f.seek(offset);
}
void seek(types::file &&f, long offset)
{
// Nothing have to be done as it is a lvalue
}
void seek(types::file &f, long offset, long whence)
{
f.seek(offset, whence);
}
void seek(types::file &&f, long offset, long whence)
{
// Nothing have to be done as it is a lvalue
}
}
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,24 @@
#ifndef PYTHONIC_BUILTIN_FILE_TELL_HPP
#define PYTHONIC_BUILTIN_FILE_TELL_HPP
#include "pythonic/include/builtins/file/tell.hpp"
#include "pythonic/types/file.hpp"
#include "pythonic/utils/functor.hpp"
PYTHONIC_NS_BEGIN
namespace builtins
{
namespace file
{
long tell(types::file const &f)
{
return f.tell();
}
}
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,39 @@
#ifndef PYTHONIC_BUILTIN_FILE_TRUNCATE_HPP
#define PYTHONIC_BUILTIN_FILE_TRUNCATE_HPP
#include "pythonic/include/builtins/file/truncate.hpp"
#include "pythonic/types/file.hpp"
#include "pythonic/utils/functor.hpp"
PYTHONIC_NS_BEGIN
namespace builtins
{
namespace file
{
void truncate(types::file &f)
{
f.truncate();
}
void truncate(types::file &&f)
{
f.truncate();
}
void truncate(types::file &f, long size)
{
f.truncate(size);
}
void truncate(types::file &&f, long size)
{
f.truncate(size);
}
}
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,30 @@
#ifndef PYTHONIC_BUILTIN_FILE_WRITE_HPP
#define PYTHONIC_BUILTIN_FILE_WRITE_HPP
#include "pythonic/include/builtins/file/write.hpp"
#include "pythonic/types/file.hpp"
#include "pythonic/types/str.hpp"
#include "pythonic/utils/functor.hpp"
PYTHONIC_NS_BEGIN
namespace builtins
{
namespace file
{
long write(types::file &f, types::str const &str)
{
return f.write(str);
}
long write(types::file &&f, types::str const &str)
{
return f.write(str);
}
}
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,25 @@
#ifndef PYTHONIC_BUILTIN_FILE_WRITELINES_HPP
#define PYTHONIC_BUILTIN_FILE_WRITELINES_HPP
#include "pythonic/include/builtins/file/writelines.hpp"
#include "pythonic/types/file.hpp"
#include "pythonic/utils/functor.hpp"
PYTHONIC_NS_BEGIN
namespace builtins
{
namespace file
{
template <class F, class T>
void writelines(F &&f, T const &sequence)
{
f.writelines(sequence);
}
}
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,129 @@
#ifndef PYTHONIC_BUILTIN_FILTER_HPP
#define PYTHONIC_BUILTIN_FILTER_HPP
#include "pythonic/include/builtins/filter.hpp"
#include "pythonic/utils/iterator.hpp"
#include "pythonic/itertools/common.hpp"
#include "pythonic/utils/functor.hpp"
PYTHONIC_NS_BEGIN
namespace builtins
{
namespace details
{
template <typename Operator, typename List0>
bool filter_iterator<Operator, List0>::test_filter(std::false_type)
{
return op(*iter);
}
template <typename Operator, typename List0>
bool filter_iterator<Operator, List0>::test_filter(std::true_type)
{
return *iter;
}
template <typename Operator, typename List0>
filter_iterator<Operator, List0>::filter_iterator(Operator _op, List0 &_seq)
: op(_op), iter(_seq.begin()), iter_end(_seq.end())
{
if (!test_filter(std::is_same<types::none_type, Operator>()))
next_value();
}
template <typename Operator, typename List0>
filter_iterator<Operator, List0>::filter_iterator(itertools::npos,
Operator _op, List0 &_seq)
: op(_op), iter(_seq.end()), iter_end(_seq.end())
{
}
template <typename Operator, typename List0>
typename List0::value_type filter_iterator<Operator, List0>::
operator*() const
{
return *iter;
}
template <typename Operator, typename List0>
filter_iterator<Operator, List0> &filter_iterator<Operator, List0>::
operator++()
{
next_value();
return *this;
}
template <typename Operator, typename List0>
void filter_iterator<Operator, List0>::next_value()
{
while (++iter != iter_end) {
if (test_filter(std::is_same<types::none_type, Operator>()))
return;
}
}
template <typename Operator, typename List0>
bool filter_iterator<Operator, List0>::
operator==(filter_iterator const &other) const
{
return !(iter != other.iter);
}
template <typename Operator, typename List0>
bool filter_iterator<Operator, List0>::
operator!=(filter_iterator const &other) const
{
return iter != other.iter;
}
template <typename Operator, typename List0>
bool filter_iterator<Operator, List0>::
operator<(filter_iterator const &other) const
{
return iter != other.iter;
}
template <typename Operator, typename List0>
filter<Operator, List0>::filter(Operator _op, List0 const &_seq)
: utils::iterator_reminder<false, List0>(_seq),
iterator(_op, this->values),
end_iter(itertools::npos(), _op, this->values)
{
}
template <typename Operator, typename List0>
typename filter<Operator, List0>::iterator &filter<Operator, List0>::begin()
{
return *this;
}
template <typename Operator, typename List0>
typename filter<Operator, List0>::iterator const &
filter<Operator, List0>::begin() const
{
return *this;
}
template <typename Operator, typename List0>
typename filter<Operator, List0>::iterator const &
filter<Operator, List0>::end() const
{
return end_iter;
}
}
template <typename Operator, typename List0>
details::filter<typename std::remove_cv<
typename std::remove_reference<Operator>::type>::type,
typename std::remove_cv<
typename std::remove_reference<List0>::type>::type>
filter(Operator &&_op, List0 &&_seq)
{
return {std::forward<Operator>(_op), std::forward<List0>(_seq)};
}
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,29 @@
#ifndef PYTHONIC_BUILTIN_FLOAT_HPP
#define PYTHONIC_BUILTIN_FLOAT_HPP
#include "pythonic/include/builtins/float_.hpp"
#include "pythonic/utils/functor.hpp"
PYTHONIC_NS_BEGIN
namespace builtins
{
namespace functor
{
template <class T>
float_::type float_::operator()(T &&t) const
{
return static_cast<float_::type>(t);
}
float_::type float_::operator()() const
{
return 0.;
}
}
}
PYTHONIC_NS_END
#endif

View File

@ -0,0 +1,26 @@
#ifndef PYTHONIC_BUILTIN_FLOAT_ISINTEGER_HPP
#define PYTHONIC_BUILTIN_FLOAT_ISINTEGER_HPP
#include "pythonic/include/builtins/float_/is_integer.hpp"
#include "pythonic/utils/functor.hpp"
#include <cmath>
PYTHONIC_NS_BEGIN
namespace builtins
{
namespace float_
{
bool is_integer(double d)
{
return std::trunc(d) == d;
}
}
}
PYTHONIC_NS_END
#endif

Some files were not shown because too many files have changed in this diff Show More