Further progress towards Godot 4.0 support

- Primary example scenes (menu, terminal, and asciicast) working but
  still a lot of warning/error messages and some regressions.
- Editor integrated terminal works, but still a lot of warning/error
  messages and some regressions.
- Added support for "blink" display attribute.
- Removed GDScript terminal code. Terminal node is now purely a
  GDExtension. So is LibuvUtils.
- GUT tests not working yet.
- Still a lot of things to fix.
- So far, only built for and manually tested on Linux x86_64.
This commit is contained in:
Leroy Hopson 2023-01-08 22:41:48 +13:00
parent aad8e39dae
commit ad7f97e493
No known key found for this signature in database
GPG key ID: D2747312A6DB51AA
30 changed files with 1385 additions and 1459 deletions

View file

@ -1,36 +0,0 @@
# Copyright (c) 2021, Leroy Hopson (MIT License)
@tool
extends Object
# Wrapper around libuv utility functions.
# GDNative does not currently support registering static functions so we fake it.
# Only the static functions of this class should be called.
static func get_os_environ() -> Dictionary:
# While Godot has OS.get_environment(), I could see a way to get all environent
# variables, other than by OS.execute() which would require to much platform
# specific code. Easier to use libuv's utility function.
return LibuvUtils.get_os_environ()
static func get_cwd() -> String:
# Use uv_cwd() rather than Directory.get_current_dir() because the latter
# defaults to res:// even if starting godot from a different directory.
return LibuvUtils.new().get_cwd()
static func get_windows_build_number() -> int:
assert(OS.get_name() == "Windows") #,"This function is only supported checked Windows.")
var release: String = LibuvUtils.new().get_os_release()
assert(false) #,"Not implemented.")
return 0
static func kill(pid: int, signum: int):
if pid > 1:
return LibuvUtils.new().kill(pid, signum)
static func new():
assert(false) #,"Abstract sealed (i.e. static) class should not be instantiated.")

View file

@ -64,7 +64,10 @@ var _exit_cb: Callable
# Writes data to the socket.
# data: The data to write.
func write(data) -> void:
assert(data is PackedByteArray or data is String, "Invalid type for argument 'data'. Should be of type PackedByteArray or String")
var correct_type: bool = data is PackedByteArray or data is String
var err_message := "Invalid type for argument 'data'. Should be of type PackedByteArray or String"
assert(correct_type, err_message)
if _pipe:
_pipe.write(data if data is PackedByteArray else data.to_utf8_buffer())
@ -88,7 +91,7 @@ func _parse_env(env: Dictionary = {}) -> PackedStringArray:
for key in keys:
var value = env[key]
var valid = key is String and value is String
assert(valid) #,"Env key/value pairs must be of type String/String.")
assert(valid) #,"Env key/value pairs must be of type String/String.")
if not valid:
push_warning("Skipping invalid env key/value pair.")
@ -129,9 +132,23 @@ func fork(
_exit_cb = Callable(self, "on_exit")
# Actual fork.
var result = PTYUnix.new().fork(
# VERY IMPORTANT: The second argument must be 0, otherwise will get an ENOTSOCK error after connecting our pipe to the fd.
file, 0, args, parsed_env, cwd, cols, rows, uid, gid, utf8, _exit_cb
var result = (
PTYUnix
. new()
. fork(
# VERY IMPORTANT: The second argument must be 0, otherwise will get an ENOTSOCK error after connecting our pipe to the fd.
file,
0,
args,
parsed_env,
cwd,
cols,
rows,
uid,
gid,
utf8,
_exit_cb
)
)
if result[0] != OK:
@ -146,10 +163,10 @@ func fork(
_pid = result[1].pid
_pipe = Pipe.new()
_pipe.open(_fd, true) # FIXME: _pipe.open(_fd) should be sufficient but requires two args.
_pipe.open(_fd, false)
# Must connect to signal AFTER opening, otherwise we will get error ENOTSOCK.
_pipe.connect("data_received",Callable(self,"_on_pipe_data_received"))
_pipe.connect("data_received", Callable(self, "_on_pipe_data_received"))
return OK
@ -159,7 +176,7 @@ func open(cols: int = DEFAULT_COLS, rows: int = DEFAULT_ROWS) -> Array:
func _exit_tree():
_exit_cb = null
_exit_cb = Callable()
if _pid > 1:
LibuvUtils.kill(_pid, IPCSignal.SIGHUP)
if _pipe:

View file

@ -1,2 +0,0 @@
@tool
extends SubViewport

View file

@ -1,23 +0,0 @@
[gd_scene load_steps=2 format=3 uid="uid://c62updkby54f3"]
[sub_resource type="GDScript" id="GDScript_d8lvm"]
script/source = "@tool
extends SubViewport
"
[node name="SubViewport" type="SubViewport"]
transparent_bg = true
handle_input_locally = false
gui_snap_controls_to_pixels = false
size = Vector2i(2, 2)
render_target_clear_mode = 1
script = SubResource("GDScript_d8lvm")
[node name="Terminal" type="Terminal" parent="."]
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
offset_right = -2.0
offset_bottom = -2.0
grow_horizontal = 2
grow_vertical = 2