RAII Helpers
RAII helpers for managing lifetime of AngelScript objects.
asIScriptEngine*
-
inline script_engine asbind20::make_script_engine(asDWORD version = ANGELSCRIPT_VERSION)
Create an AngelScript engine.
-
class script_engine
Script engine manager.
Public Types
-
using handle_type = asIScriptEngine*
Public Functions
-
inline script_engine() noexcept
-
script_engine(const script_engine&) = delete
-
inline script_engine(script_engine&&) noexcept
-
inline explicit script_engine(handle_type engine) noexcept
-
script_engine &operator=(const script_engine&) = delete
-
inline script_engine &operator=(script_engine &&other) noexcept
-
inline ~script_engine()
-
inline handle_type get() const noexcept
-
inline operator handle_type() const noexcept
-
inline handle_type operator->() const noexcept
-
inline handle_type release() noexcept
-
inline void reset(handle_type engine = nullptr) noexcept
-
using handle_type = asIScriptEngine*
asIScriptContext*
-
inline auto asbind20::current_context() -> asIScriptContext*
Get current script context from a function called by script.
- Returns:
A pointer to the currently executing context, or null if no context is executing
-
class request_context
RAII helper for requesting script context from the engine.
Public Types
-
using handle_type = asIScriptContext*
Public Functions
-
request_context() = delete
-
request_context(const request_context&) = delete
-
request_context &operator=(const request_context&) = delete
-
inline explicit request_context(asIScriptEngine *engine)
-
inline ~request_context()
-
inline handle_type get() const noexcept
-
inline auto get_engine() const noexcept -> asIScriptEngine*
-
inline operator handle_type() const noexcept
-
inline handle_type operator->() const noexcept
-
using handle_type = asIScriptContext*
-
class reuse_active_context
RAII helper for reusing active script context.
It will fallback to request context from the engine.
Public Types
-
using handle_type = asIScriptContext*
Public Functions
-
reuse_active_context() = delete
-
reuse_active_context(const reuse_active_context&) = delete
-
reuse_active_context &operator=(const reuse_active_context&) = delete
-
inline explicit reuse_active_context(asIScriptEngine *engine, bool propagate_error = true)
-
inline ~reuse_active_context()
-
inline handle_type get() const noexcept
-
inline auto get_engine() const noexcept -> asIScriptEngine*
-
inline operator handle_type() const noexcept
-
inline handle_type operator->() const noexcept
-
inline bool is_nested() const noexcept
Returns true if current context is reused.
-
inline bool will_propagate_error() const noexcept
-
using handle_type = asIScriptContext*
asIScriptObject*
-
class script_object
Smart pointer for script object.
Public Types
-
using handle_type = asIScriptObject*
Public Functions
-
script_object() noexcept = default
-
inline script_object(script_object &&other) noexcept
-
script_object(const script_object&) = delete
-
inline explicit script_object(handle_type obj)
-
inline ~script_object()
-
inline handle_type get() const noexcept
-
inline explicit operator handle_type() const noexcept
-
inline explicit operator bool() const noexcept
-
inline handle_type operator->() const noexcept
-
inline handle_type release() noexcept
Release without decreasing reference count.
Warning
USE WITH CAUTION!
- Returns:
Previously stored object
-
inline void reset(std::nullptr_t = nullptr) noexcept
Reset object the null pointer.
-
inline void reset(handle_type obj)
Reset object.
- Parameters:
obj – New object to store
-
using handle_type = asIScriptObject*
IO Helpers
The IO support is in a standalone header <asbind20/io/stream.hpp>,
which means you need to include it explicitly if you want to load/save byte code of AngelScript.
- group Byte code manipulation
Functions
-
inline int save_byte_code(std::ostream &os, asIScriptModule *m, bool strip_debug_info = false)
Save byte code to
std::ostream- Parameters:
os – Output stream
m – Script module to save
strip_debug_info – Strip debug information
- Returns:
Result of
asIScriptModule::SaveByteCode
-
template<typename OutputIteratorValueType = std::byte>
int save_byte_code(std::output_iterator<OutputIteratorValueType> auto out, asIScriptModule *m, bool strip_debug_info = false) Save byte code to an output iterator.
- Template Parameters:
OutputIteratorValueType – Value type of output iterator. It can be any integral type whose size equals to
std::byte.- Parameters:
out – Output iterator
m – Script module
strip_debug_info – Strip debug information
- Returns:
Result of
asIScriptModule::SaveByteCode
-
inline io::load_byte_code_result load_byte_code(std::istream &is, asIScriptModule *m)
Load byte code from
std::istream- Parameters:
is – Input stream
m – Script module
- Returns:
Loading result
-
inline io::load_byte_code_result load_byte_code(const void *mem, std::size_t size, asIScriptModule *m)
Load byte code from memory buffer.
- Parameters:
mem – Memory buffer
size – Buffer size
m – Script module
- Returns:
Loading result
-
inline int save_byte_code(std::ostream &os, asIScriptModule *m, bool strip_debug_info = false)
Miscellaneous Utilities
-
inline std::string asbind20::to_string(asEContextState state)
Convert context state enum to string.
- Parameters:
state – Context state
- Returns:
String representation of the state. If the state value is invalid, the result will be
"asEContextState({state})", e.g."asEContextState(-1)".
-
inline std::string asbind20::to_string(asERetCodes ret)
Convert return code to string.
- Parameters:
ret – Return code
- Returns:
String representation of the return code. If the value is invalid, the result will be
"asERetCodes({ret})", e.g."asERetCodes(1)".
-
template<detail::concat_accepted... Args>
constexpr std::string asbind20::string_concat(Args&&... args) Concatenate strings.
- Parameters:
args – String-like inputs
- Returns:
std::string Result
-
template<typename Fn, typename ...Args>
decltype(auto) asbind20::with_cstr(Fn &&fn, Args&&... args) This function will convert
stringandstring_viewin parameters to null-terminatedconst char*for APIs receiving C-style string.This function will make a copy of string view if it is not null-terminated.
-
template<std::size_t Size>
class fixed_string -
Public Functions
-
constexpr fixed_string(const fixed_string&) noexcept = default
-
constexpr bool operator==(const fixed_string&) const noexcept = default
-
template<std::size_t N>
inline constexpr bool operator==(const fixed_string<N>&) const noexcept
-
inline constexpr const value_type *data() const noexcept
-
inline constexpr const value_type *c_str() const noexcept
-
inline constexpr operator const char*() const noexcept
-
inline constexpr std::string_view view() const noexcept
-
inline constexpr operator std::string_view() const noexcept
Public Members
-
constexpr fixed_string(const fixed_string&) noexcept = default
-
template<typename T1, typename T2>
class compressed_pair Compressed pair for saving storage space.
This class will use the empty base optimization (EBO) to reduce the size of compressed pair.
- Template Parameters:
T1 – First member type
T2 – Second member type
Public Types
Public Functions
-
compressed_pair() = default
-
compressed_pair(const compressed_pair&) = default
-
compressed_pair(compressed_pair&&) noexcept(std::is_nothrow_move_constructible_v<T1> && std::is_nothrow_move_constructible_v<T2>) = default
-
template<typename Tuple1, typename Tuple2>
inline compressed_pair(std::piecewise_construct_t, Tuple1 &&tuple1, Tuple2 &&tuple2)
-
inline compressed_pair(T1 &&t1, T2 &&t2) noexcept(std::is_nothrow_move_constructible_v<T1> && std::is_nothrow_move_constructible_v<T2>)
-
inline void swap(compressed_pair &other) noexcept(std::is_nothrow_swappable_v<T1> && std::is_nothrow_swappable_v<T2>)
Friends
-
template<std::size_t Idx>
inline friend element_type<Idx> &get(compressed_pair &cp) noexcept
-
template<std::size_t Idx>
inline friend const element_type<Idx> &get(const compressed_pair &cp) noexcept
-
template<std::size_t Idx>
inline friend element_type<Idx> &&get(compressed_pair &&cp) noexcept
-
template<std::size_t Idx>
inline friend const element_type<Idx> &&get(const compressed_pair &&cp) noexcept
Debugging
-
inline const char *asbind20::debugging::get_function_section_name(const asIScriptFunction *func)
Get script section name of function.
This helper can handle the different interfaces for getting the section name across AngelScript versions.
- Parameters:
func – Script function. It cannot be nullptr.
-
struct gc_statistics
GC statistics.
Public Types
-
using value_type = asUINT
Public Functions
-
bool operator==(const gc_statistics&) const noexcept = default
Public Members
-
value_type current_size
-
value_type total_destroyed
-
value_type total_detected
-
value_type new_objects
-
value_type total_new_destroyed
-
using value_type = asUINT
-
inline gc_statistics asbind20::debugging::get_gc_statistics(asIScriptEngine *engine)
Get the GC statistics.
- Parameters:
engine – Script engine. It cannot be nullptr.