Skip to content

Commit

Permalink
update not finished
Browse files Browse the repository at this point in the history
  • Loading branch information
AstroAir committed Feb 3, 2024
1 parent cd7da02 commit 170934a
Show file tree
Hide file tree
Showing 56 changed files with 4,157 additions and 1,826 deletions.
2 changes: 1 addition & 1 deletion libs
Submodule libs updated 88 files
+1 −0 CMakeLists.txt
+1 −1 backward/backward.hpp
+42 −35 emhash/hash_table8.hpp
+60 −0 pcoketpy/CMakeLists.txt
+3 −0 pcoketpy/include/pocketpy.h
+9 −0 pcoketpy/include/pocketpy/base64.h
+185 −0 pcoketpy/include/pocketpy/bindings.h
+4 −0 pcoketpy/include/pocketpy/ceval.h
+131 −0 pcoketpy/include/pocketpy/cffi.h
+209 −0 pcoketpy/include/pocketpy/codeobject.h
+13 −0 pcoketpy/include/pocketpy/collections.h
+249 −0 pcoketpy/include/pocketpy/common.h
+142 −0 pcoketpy/include/pocketpy/compiler.h
+96 −0 pcoketpy/include/pocketpy/config.h
+9 −0 pcoketpy/include/pocketpy/csv.h
+73 −0 pcoketpy/include/pocketpy/dict.h
+9 −0 pcoketpy/include/pocketpy/easing.h
+80 −0 pcoketpy/include/pocketpy/error.h
+34 −0 pcoketpy/include/pocketpy/export.h
+332 −0 pcoketpy/include/pocketpy/expr.h
+130 −0 pcoketpy/include/pocketpy/frame.h
+71 −0 pcoketpy/include/pocketpy/gc.h
+32 −0 pcoketpy/include/pocketpy/io.h
+64 −0 pcoketpy/include/pocketpy/iter.h
+142 −0 pcoketpy/include/pocketpy/lexer.h
+203 −0 pcoketpy/include/pocketpy/linalg.h
+25 −0 pcoketpy/include/pocketpy/memory.h
+14 −0 pcoketpy/include/pocketpy/modules.h
+337 −0 pcoketpy/include/pocketpy/namedict.h
+411 −0 pcoketpy/include/pocketpy/obj.h
+142 −0 pcoketpy/include/pocketpy/opcodes.h
+17 −0 pcoketpy/include/pocketpy/pocketpy.h
+109 −0 pcoketpy/include/pocketpy/pocketpy_c.h
+9 −0 pcoketpy/include/pocketpy/random.h
+18 −0 pcoketpy/include/pocketpy/repl.h
+228 −0 pcoketpy/include/pocketpy/str.h
+54 −0 pcoketpy/include/pocketpy/tuplelist.h
+167 −0 pcoketpy/include/pocketpy/vector.h
+643 −0 pcoketpy/include/pocketpy/vm.h
+3 −0 pcoketpy/include/pocketpy_c.h
+117 −0 pcoketpy/include/typings/c.pyi
+2 −0 pcoketpy/include/typings/cjson.pyi
+31 −0 pcoketpy/include/typings/easing.pyi
+145 −0 pcoketpy/include/typings/linalg.pyi
+0 −15,328 pcoketpy/pocketpy.h
+40 −0 pcoketpy/prebuild.py
+325 −0 pcoketpy/python/_long.py
+95 −0 pcoketpy/python/_set.py
+72 −0 pcoketpy/python/bisect.py
+299 −0 pcoketpy/python/builtins.py
+172 −0 pcoketpy/python/cmath.py
+69 −0 pcoketpy/python/collections.py
+171 −0 pcoketpy/python/colorsys.py
+59 −0 pcoketpy/python/dataclasses.py
+148 −0 pcoketpy/python/datetime.py
+19 −0 pcoketpy/python/functools.py
+86 −0 pcoketpy/python/heapq.py
+182 −0 pcoketpy/python/pickle.py
+21 −0 pcoketpy/python/this.py
+36 −0 pcoketpy/python/typing.py
+188 −0 pcoketpy/src/base64.cpp
+873 −0 pcoketpy/src/ceval.cpp
+274 −0 pcoketpy/src/cffi.cpp
+24 −0 pcoketpy/src/codeobject.cpp
+564 −0 pcoketpy/src/collections.cpp
+1,217 −0 pcoketpy/src/compiler.cpp
+93 −0 pcoketpy/src/csv.cpp
+182 −0 pcoketpy/src/dict.cpp
+251 −0 pcoketpy/src/easing.cpp
+72 −0 pcoketpy/src/error.cpp
+695 −0 pcoketpy/src/expr.cpp
+67 −0 pcoketpy/src/frame.cpp
+68 −0 pcoketpy/src/gc.cpp
+199 −0 pcoketpy/src/io.cpp
+90 −0 pcoketpy/src/iter.cpp
+557 −0 pcoketpy/src/lexer.cpp
+627 −0 pcoketpy/src/linalg.cpp
+258 −0 pcoketpy/src/memory.cpp
+249 −0 pcoketpy/src/modules.cpp
+4 −0 pcoketpy/src/namedict.cpp
+61 −0 pcoketpy/src/obj.cpp
+1,498 −0 pcoketpy/src/pocketpy.cpp
+589 −0 pcoketpy/src/pocketpy_c.cpp
+72 −0 pcoketpy/src/random.cpp
+42 −0 pcoketpy/src/repl.cpp
+548 −0 pcoketpy/src/str.cpp
+61 −0 pcoketpy/src/tuplelist.cpp
+1,348 −0 pcoketpy/src/vm.cpp
263 changes: 0 additions & 263 deletions src/atom/experiment/icon.cpp

This file was deleted.

87 changes: 87 additions & 0 deletions src/atom/experiment/invoke.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
/*
* invoke.hpp
*
* Copyright (C) 2023-2024 Max Qian <lightapt.com>
*/

/*************************************************
Date: 2023-3-29
Description: An implementation of invoke function. Support C++11 and C++17.
**************************************************/

#ifndef ATOM_EXPERIMENTAL_INVOKE_HPP
#define ATOM_EXPERIMENTAL_INVOKE_HPP

#include <functional>
#include <tuple>
#include <utility>

#if __cplusplus >= 201703L

#include <type_traits>

template <typename F, typename... Args>
using is_invocable_with_args = std::is_invocable<F, Args...>;

template <class F, class... Args>
auto delay_invoke(F &&f, Args &&...args)
{
// 静态断言,确保 F 是一个可调用类型,并且可以接受 Args... 作为参数
static_assert(is_invocable_with_args<F, Args...>::value, "F must be callable with Args...");

return [f = std::forward<F>(f), args = std::make_tuple(std::forward<Args>(args)...)]() mutable
{
return std::apply(f, args);
};
}
#else
template <std::size_t... I>
struct index_sequence
{
};

template <std::size_t N, std::size_t... I>
struct make_index_sequence_impl : make_index_sequence_impl<N - 1, N - 1, I...>
{
};

template <std::size_t... I>
struct make_index_sequence_impl<0, I...>
{
using type = index_sequence<I...>;
};

template <std::size_t N>
using make_index_sequence = typename make_index_sequence_impl<N>::type;

template <typename T, class F, class... Args>
struct DelayInvoke
{
F f;
std::tuple<Args...> args;

DelayInvoke(F &&f, Args &&...args) : f(std::forward<F>(f)), args(std::make_tuple(std::forward<Args>(args)...)) {}

template <std::size_t... I>
T invoke(index_sequence<I...>)
{
return (f)(std::get<I>(args)...);
}

T operator()()
{
return invoke(make_index_sequence<sizeof...(Args)>());
}
};

template <typename T, class F, class... Args>
T delay_invoke(F &&f, Args &&...args)
{
return DelayInvoke<T, F, Args...>(std::forward<F>(f), std::forward<Args>(args)...)();
}
#endif

#endif
Loading

0 comments on commit 170934a

Please sign in to comment.