Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/topic/robin/remove-std-function'
Browse files Browse the repository at this point in the history
* origin/topic/robin/remove-std-function:
  Address review feedback.
  Remove unused include headers.
  Remove all usage of `std::function` from toolchain.
  Remove usage of `std::function` from parser and sink runtime representations.
  Remove use of `std::function` from `spicy::rt::Configuration`.
  Remove unused functional header.
  Remove use of `std::function` from runtime vector class.
  Remove support for deferred expressions.
  • Loading branch information
rsmmr committed May 10, 2024
2 parents 92f7654 + 359e2ae commit e2b5c11
Show file tree
Hide file tree
Showing 67 changed files with 208 additions and 461 deletions.
23 changes: 23 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
@@ -1,3 +1,26 @@
1.11.0-dev.151 | 2024-05-10 16:35:50 +0200

* Remove unused include headers. (Robin Sommer, Corelight)

* Remove all usage of `std::function` from toolchain. (Robin Sommer, Corelight)

* Remove usage of `std::function` from parser and sink runtime representations. (Robin Sommer, Corelight)

We switch to raw function pointers, which is easy enough.

* Remove use of `std::function` from `spicy::rt::Configuration`. (Robin Sommer, Corelight)

Callbacks are now classic function pointers.

* Remove unused functional header. (Robin Sommer, Corelight)

* Remove use of `std::function` from runtime vector class. (Robin Sommer, Corelight)

* Remove support for deferred expressions. (Robin Sommer, Corelight)

These weren't used anymore anywhere so we can remove the corresponding
code from toolchain and runtime.

1.11.0-dev.142 | 2024-05-06 15:14:40 +0200

* GH-1664: Fix `&convert` typing issue with bit ranges. (Robin Sommer, Corelight)
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.11.0-dev.142
1.11.0-dev.151
1 change: 0 additions & 1 deletion hilti/runtime/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,6 @@ add_executable(
src/tests/bytes.cc
src/tests/context.cc
src/tests/debug-logger.cc
src/tests/deferred-expression.cc
src/tests/enum.cc
src/tests/exception.cc
src/tests/fiber.cc
Expand Down
1 change: 0 additions & 1 deletion hilti/runtime/include/configuration.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#pragma once

#include <cstddef>
#include <iostream>
#include <memory>
#include <optional>
#include <string>
Expand Down
2 changes: 0 additions & 2 deletions hilti/runtime/include/context.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
#pragma once

#include <cassert>
#include <iostream>
#include <memory>
#include <optional>
#include <utility>
#include <vector>

Expand Down
1 change: 0 additions & 1 deletion hilti/runtime/include/debug-logger.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include <fstream>
#include <map>
#include <memory>
#include <optional>
#include <string_view>

#include <hilti/rt/filesystem.h>
Expand Down
60 changes: 0 additions & 60 deletions hilti/runtime/include/deferred-expression.h

This file was deleted.

2 changes: 0 additions & 2 deletions hilti/runtime/include/exception.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,12 @@

#pragma once

#include <iostream>
#include <optional>
#include <ostream>
#include <stdexcept>
#include <string>
#include <string_view>
#include <utility>
#include <vector>

#include <hilti/rt/backtrace.h>
#include <hilti/rt/extension-points.h>
Expand Down
2 changes: 0 additions & 2 deletions hilti/runtime/include/fiber.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
#pragma once

#include <csetjmp>
#include <functional>
#include <iostream>
#include <memory>
#include <optional>
#include <string>
Expand Down
1 change: 0 additions & 1 deletion hilti/runtime/include/global-state.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
#include <sys/resource.h>

#include <memory>
#include <optional>
#include <string>
#include <unordered_map>
#include <vector>
Expand Down
1 change: 0 additions & 1 deletion hilti/runtime/include/hilti.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

#pragma once

#include <iostream>
#include <type_traits>

#include <hilti/rt/configuration.h>
Expand Down
1 change: 0 additions & 1 deletion hilti/runtime/include/intrusive-ptr.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#pragma once

#include <cstdint>
#include <iostream>
#include <type_traits>
#include <utility>

Expand Down
1 change: 0 additions & 1 deletion hilti/runtime/include/libhilti.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include <hilti/rt/autogen/version.h>
#include <hilti/rt/configuration.h>
#include <hilti/rt/context.h>
#include <hilti/rt/deferred-expression.h>
#include <hilti/rt/exception.h>
#include <hilti/rt/extension-points.h>
#include <hilti/rt/fiber-check-stack.h>
Expand Down
2 changes: 0 additions & 2 deletions hilti/runtime/include/types/enum.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@

#include <algorithm>
#include <limits>
#include <string>
#include <type_traits>
#include <variant>

#include <hilti/rt/exception.h>
#include <hilti/rt/logging.h>
Expand Down
5 changes: 0 additions & 5 deletions hilti/runtime/include/types/function.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,6 @@

namespace hilti::rt::detail::adl {

template<typename R, typename... Args>
inline std::string to_string(std::function<R(Args...)>, adl::tag /*unused*/) {
return "<function>";
}

template<typename R, typename... Args>
inline std::string to_string(R (*)(Args...), adl::tag /*unused*/) {
return "<function>";
Expand Down
2 changes: 0 additions & 2 deletions hilti/runtime/include/types/interval.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
#include <arpa/inet.h>

#include <limits>
#include <memory>
#include <string>
#include <variant>

#include <hilti/rt/extension-points.h>
#include <hilti/rt/fmt.h>
Expand Down
1 change: 0 additions & 1 deletion hilti/runtime/include/types/map.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#pragma once

#include <algorithm>
#include <functional>
#include <initializer_list>
#include <map>
#include <memory>
Expand Down
1 change: 0 additions & 1 deletion hilti/runtime/include/types/network.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include <arpa/inet.h>

#include <string>
#include <variant>

#include <hilti/rt/exception.h>
#include <hilti/rt/extension-points.h>
Expand Down
1 change: 0 additions & 1 deletion hilti/runtime/include/types/null.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#include <optional>
#include <ostream>
#include <string>
#include <variant>

#include <hilti/rt/extension-points.h>

Expand Down
1 change: 0 additions & 1 deletion hilti/runtime/include/types/port.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
#include <arpa/inet.h>

#include <string>
#include <variant>

#include <hilti/rt/extension-points.h>
#include <hilti/rt/types/address.h>
Expand Down
17 changes: 17 additions & 0 deletions hilti/runtime/include/types/reference.h
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,23 @@ class StrongReferenceGeneric {
}
}

/**
* Returns a value reference that is linked to the referred value. If the
* strong reference is null or expired, the returned reference will be
* null.
*/
template<typename T>
ValueReference<T> derefAsValue() const {
if ( _ptr.empty() )
return {};

try {
return hilti::rt::any_cast<StrongReference<T>>(_ptr).derefAsValue();
} catch ( const hilti::rt::bad_any_cast& ) {
throw IllegalReference("invalid target type");
}
}

/** Releases the bound reference. */
void reset() { _ptr.clear(); }

Expand Down
1 change: 0 additions & 1 deletion hilti/runtime/include/types/regexp.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
#pragma once

#include <memory>
#include <optional>
#include <string>
#include <tuple>
#include <utility>
Expand Down
3 changes: 0 additions & 3 deletions hilti/runtime/include/types/stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,13 @@
#include <algorithm>
#include <array>
#include <cassert>
#include <cinttypes>
#include <cstddef>
#include <cstring>
#include <limits>
#include <memory>
#include <optional>
#include <string>
#include <tuple>
#include <utility>
#include <variant>
#include <vector>

#include <hilti/rt/any.h>
Expand Down
1 change: 0 additions & 1 deletion hilti/runtime/include/types/time.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

#include <limits>
#include <string>
#include <variant>

#include <hilti/rt/extension-points.h>
#include <hilti/rt/types/interval.h>
Expand Down
12 changes: 7 additions & 5 deletions hilti/runtime/include/types/vector.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
#include <cinttypes>
#include <cstddef>
#include <cstdint>
#include <functional>
#include <initializer_list>
#include <iterator>
#include <memory>
Expand Down Expand Up @@ -546,17 +545,20 @@ inline bool operator!=(const Empty& /*unused*/, const Vector<T, Allocator>& v) {
return ! v.empty();
}

template<typename Allocator, typename I, typename O, typename C>
Vector<O, Allocator> make(const C& input, std::function<O(I)> func) {
template<typename Allocator, typename C, typename Func>
auto make(const C& input, Func&& func) {
using O = typename std::result_of_t<Func(typename C::value_type)>;
Vector<O, Allocator> output;
output.reserve(input.size());
for ( auto&& i : input )
output.emplace_back(func(i));

return output;
}

template<typename Allocator, typename I, typename O, typename C>
Vector<O, Allocator> make(const C& input, std::function<O(I)> func, std::function<bool(I)> pred) {
template<typename Allocator, typename C, typename Func, typename Pred>
auto make(const C& input, Func&& func, Pred&& pred) {
using O = typename std::result_of_t<Func(typename C::value_type)>;
Vector<O, Allocator> output;
for ( auto&& i : input )
if ( pred(i) )
Expand Down
2 changes: 0 additions & 2 deletions hilti/runtime/include/util.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@

#include <algorithm>
#include <list>
#include <memory>
#include <numeric>
#include <optional>
#include <set>
#include <string>
Expand Down

0 comments on commit e2b5c11

Please sign in to comment.