2021-07-02 19:27:34 +02:00
|
|
|
#ifndef GODOT_XTERM_UV_UTILS_H
|
|
|
|
#define GODOT_XTERM_UV_UTILS_H
|
|
|
|
|
2022-12-29 10:52:13 +01:00
|
|
|
#include <godot_cpp/classes/ref_counted.hpp>
|
2021-07-02 19:27:34 +02:00
|
|
|
#include <uv.h>
|
|
|
|
|
|
|
|
#define UV_ERR_PRINT(uv_err) \
|
|
|
|
ERR_PRINT(String(uv_err_name(uv_err)) + String(": ") + \
|
|
|
|
String(uv_strerror(uv_err)));
|
|
|
|
|
|
|
|
#define RETURN_UV_ERR(uv_err) \
|
2021-07-22 07:17:23 +02:00
|
|
|
if (uv_err < 0) { \
|
|
|
|
UV_ERR_PRINT(uv_err); \
|
|
|
|
} \
|
2021-07-02 19:27:34 +02:00
|
|
|
return LibuvUtils::translate_uv_errno(uv_err);
|
|
|
|
|
|
|
|
#define RETURN_IF_UV_ERR(uv_err) \
|
|
|
|
if (uv_err < 0) { \
|
|
|
|
RETURN_UV_ERR(uv_err); \
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace godot {
|
|
|
|
|
2022-12-29 10:52:13 +01:00
|
|
|
class LibuvUtils : public RefCounted {
|
|
|
|
GDCLASS(LibuvUtils, RefCounted)
|
2021-07-02 19:27:34 +02:00
|
|
|
|
|
|
|
public:
|
|
|
|
LibuvUtils();
|
|
|
|
~LibuvUtils();
|
|
|
|
|
2022-12-29 10:52:13 +01:00
|
|
|
static Dictionary get_os_environ();
|
|
|
|
static String get_os_release();
|
|
|
|
static String get_cwd();
|
2021-07-02 19:27:34 +02:00
|
|
|
|
2022-12-29 10:52:13 +01:00
|
|
|
static Error kill(int pid, int signum);
|
2021-07-22 07:17:23 +02:00
|
|
|
|
2021-07-02 19:27:34 +02:00
|
|
|
public:
|
2022-12-29 10:52:13 +01:00
|
|
|
static Error translate_uv_errno(int uv_err);
|
|
|
|
|
|
|
|
protected:
|
|
|
|
static void _bind_methods();
|
2021-07-02 19:27:34 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace godot
|
|
|
|
|
2022-12-29 10:52:13 +01:00
|
|
|
#endif // GODOT_XTERM_UV_UTILS_H
|