Skip to content

Commit

Permalink
Merge pull request #60 from Faless/bump/alpha16
Browse files Browse the repository at this point in the history
Update to Godot alpha16
  • Loading branch information
Faless authored Sep 11, 2022
2 parents 2ad1bf1 + d8cbd14 commit 822e053
Show file tree
Hide file tree
Showing 15 changed files with 67 additions and 86 deletions.
14 changes: 2 additions & 12 deletions .github/workflows/build_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,11 @@ jobs:
matrix:
include:
# Android
- platform: android
arch: 'x86_32'
gdnative_flags: 'android_arch=x86'
sconsflags: ''
os: 'ubuntu-20.04'
- platform: android
arch: 'x86_64'
gdnative_flags: 'android_arch=x86_64'
sconsflags: ''
os: 'ubuntu-20.04'
- platform: android
arch: 'arm32'
gdnative_flags: 'android_arch=armv7'
sconsflags: ''
os: 'ubuntu-20.04'
- platform: android
arch: 'arm64'
gdnative_flags: 'android_arch=arm64v8'
Expand Down Expand Up @@ -84,12 +74,12 @@ jobs:
os: 'ubuntu-20.04'

# macOS
- platform: osx
- platform: macos
arch: 'x86_64'
gdnative_flags: 'macos_arch=x86_64 bits=64'
sconsflags: ''
os: 'macos-11'
- platform: osx
- platform: macos
gdnative_flags: 'macos_arch=arm64 bits=64'
arch: 'arm64'
sconsflags: ''
Expand Down
7 changes: 7 additions & 0 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ opts.Add(EnumVariable("godot_version", "The Godot target version", "4", ["3", "4
opts.Update(env)

if env["godot_version"] == "3":
if "platform" in ARGUMENTS and ARGUMENTS["platform"] == "macos":
ARGUMENTS["platform"] = "osx" # compatibility with old osx name

env = SConscript("godot-cpp-3.x/SConstruct")

# Patch base env
Expand All @@ -41,6 +44,10 @@ if env["godot_version"] == "3":
if env["platform"] == "windows" and env["use_mingw"]:
env.Append(LINKFLAGS=["-static-libgcc"])

if env["platform"] == "osx":
env["platform"] = "macos" # compatibility with old osx name
ARGUMENTS["platform"] = "macos"

# Normalize suffix
if env["platform"] in ["windows", "linux"]:
env["arch"] = "x86_32" if env["bits"] == "32" else "x86_64"
Expand Down
4 changes: 2 additions & 2 deletions builders.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ def ssl_action(target, source, env):
ssl_env.PrependENVPath("PATH", os.path.dirname(env["CC"]))
ssl_env["ENV"]["ANDROID_NDK_ROOT"] = os.environ.get("ANDROID_NDK_ROOT", "")

elif env["platform"] == "osx":
elif env["platform"] == "macos":
if env["arch"] == "x86_64":
args.extend(["darwin64-x86_64"])
elif env["arch"] == "arm64":
Expand Down Expand Up @@ -191,7 +191,7 @@ def rtc_action(target, source, env):
"-DCMAKE_C_FLAGS=-m64",
"-DCMAKE_CXX_FLAGS=-m64"
])
elif env["platform"] == "osx":
elif env["platform"] == "macos":
if env["macos_deployment_target"] != "default":
args.extend(["-DCMAKE_OSX_DEPLOYMENT_TARGET=%s" % env["macos_deployment_target"]])
if env["arch"] == "x86_64":
Expand Down
2 changes: 1 addition & 1 deletion deps/openssl
Submodule openssl updated 278 files
2 changes: 1 addition & 1 deletion godot-cpp
Submodule godot-cpp updated 61 files
+7 −7 .github/workflows/ci.yml
+13 −15 CMakeLists.txt
+4 −11 Makefile
+10 −6 README.md
+21 −3 SConstruct
+74 −12 binding_generator.py
+116,339 −113,055 godot-headers/extension_api.json
+19 −9 godot-headers/godot/gdnative_interface.h
+2 −2 include/godot_cpp/classes/ref.hpp
+267 −63 include/godot_cpp/classes/wrapped.hpp
+21 −0 include/godot_cpp/core/binder_common.hpp
+12 −7 include/godot_cpp/core/class_db.hpp
+1 −0 include/godot_cpp/core/defs.hpp
+3 −0 include/godot_cpp/core/engine_ptrcall.hpp
+210 −195 include/godot_cpp/core/error_macros.hpp
+15 −0 include/godot_cpp/core/math.hpp
+6 −6 include/godot_cpp/core/memory.hpp
+3 −3 include/godot_cpp/core/method_bind.hpp
+5 −2 include/godot_cpp/core/method_ptrcall.hpp
+6 −38 include/godot_cpp/core/object.hpp
+86 −0 include/godot_cpp/core/property_info.hpp
+50 −0 include/godot_cpp/core/type_info.hpp
+16 −0 include/godot_cpp/templates/hashfuncs.hpp
+4 −4 include/godot_cpp/variant/basis.hpp
+175 −0 include/godot_cpp/variant/projection.hpp
+9 −0 include/godot_cpp/variant/variant.hpp
+111 −59 include/godot_cpp/variant/vector2.hpp
+51 −24 include/godot_cpp/variant/vector2i.hpp
+160 −89 include/godot_cpp/variant/vector3.hpp
+77 −48 include/godot_cpp/variant/vector3i.hpp
+297 −0 include/godot_cpp/variant/vector4.hpp
+345 −0 include/godot_cpp/variant/vector4i.hpp
+1 −1 misc/hooks/pre-commit
+1 −1 misc/scripts/clang_format.sh
+2 −2 src/core/class_db.cpp
+39 −0 src/variant/char_string.cpp
+934 −0 src/variant/projection.cpp
+34 −1 src/variant/variant.cpp
+21 −30 src/variant/vector2.cpp
+16 −3 src/variant/vector2i.cpp
+54 −42 src/variant/vector3.cpp
+15 −9 src/variant/vector3i.cpp
+106 −0 src/variant/vector4.cpp
+95 −0 src/variant/vector4i.cpp
+1 −1 test/CMakeLists.txt
+34 −0 test/README.md
+1 −1 test/SConstruct
+12 −12 test/demo/example.gdextension
+11 −0 test/demo/main.gd
+2 −0 test/demo/main.tscn
+1 −1 test/demo/project.godot
+54 −29 test/src/example.cpp
+27 −32 test/src/example.h
+5 −31 test/src/register_types.cpp
+6 −30 test/src/register_types.h
+2 −6 tools/android.py
+9 −9 tools/ios.py
+3 −3 tools/ios_osxcross.py
+4 −4 tools/macos.py
+0 −0 tools/macos_osxcross.py
+5 −0 tools/windows.py
2 changes: 0 additions & 2 deletions misc/webrtc.gdextension
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ osx.arm64 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.osx.{TARGET}.arm64.dylib
windows.x86_64 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.windows.{TARGET}.x86_64.dll"
windows.x86_32 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.windows.{TARGET}.x86_32.dll"
android.arm64 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.android.{TARGET}.arm64.so"
android.arm32 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.android.{TARGET}.arm32.so"
android.x86_64 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.android.{TARGET}.x86_64.so"
android.x86_32 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.android.{TARGET}.x86_32.so"
ios.arm64 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.ios.{TARGET}.arm64.dylib"
ios.x86_64 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.ios.{TARGET}.x86_64.simulator.dylib"
2 changes: 0 additions & 2 deletions misc/webrtc.tres
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@ entry/X11.64 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.linux.{TARGET}.x86_64
entry/X11.32 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.linux.{TARGET}.x86_32.so"
entry/Server.64 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.linux.{TARGET}.x86_64.so"
entry/Server.32 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.linux.{TARGET}.x86_32.so"
entry/Android.armeabi-v7a = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.android.{TARGET}.arm32.so"
entry/Android.arm64-v8a = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.android.{TARGET}.arm64.so"
entry/Android.x64 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.android.{TARGET}.x86_64.so"
entry/Android.x86 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.android.{TARGET}.x86_32.so"
entry/iOS.armv7 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.ios.{TARGET}.armv32.dylib"
entry/iOS.arm64 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.ios.{TARGET}.arm64.dylib"
entry/iOS.x86_64 = "res://{GDNATIVE_PATH}/lib/libwebrtc_native.ios.{TARGET}.x86_64.simulator.dylib"
Expand Down
24 changes: 12 additions & 12 deletions src/WebRTCLibDataChannel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@
#ifdef GDNATIVE_WEBRTC
#include "GDNativeLibrary.hpp"
#include "NativeScript.hpp"
#define ERR_UNAVAILABLE GODOT_ERR_UNAVAILABLE
#define FAILED GODOT_FAILED
#define ERR_INVALID_PARAMETER GODOT_ERR_INVALID_PARAMETER
#define OK GODOT_OK
#define ERR_UNAVAILABLE Error::ERR_UNAVAILABLE
#define FAILED Error::FAILED
#define ERR_INVALID_PARAMETER Error::ERR_INVALID_PARAMETER
#define OK Error::OK
#endif

#include <stdio.h>
Expand Down Expand Up @@ -108,20 +108,20 @@ void WebRTCLibDataChannel::queue_packet(const uint8_t *data, uint32_t size, bool
mutex->unlock();
}

void WebRTCLibDataChannel::_set_write_mode(int64_t p_mode) {
void WebRTCLibDataChannel::_set_write_mode(WriteMode p_mode) {
ERR_FAIL_COND(p_mode != WRITE_MODE_TEXT && p_mode != WRITE_MODE_BINARY);
write_mode = (WriteMode)p_mode;
write_mode = p_mode;
}

int64_t WebRTCLibDataChannel::_get_write_mode() const {
WebRTCDataChannel::WriteMode WebRTCLibDataChannel::_get_write_mode() const {
return write_mode;
}

bool WebRTCLibDataChannel::_was_string_packet() const {
return current_packet.second;
}

int64_t WebRTCLibDataChannel::_get_ready_state() const {
WebRTCDataChannel::ChannelState WebRTCLibDataChannel::_get_ready_state() const {
ERR_FAIL_COND_V(!channel, STATE_CLOSED);
return channel_state;
}
Expand Down Expand Up @@ -166,7 +166,7 @@ int64_t WebRTCLibDataChannel::_get_buffered_amount() const {
return channel->bufferedAmount();
}

int64_t WebRTCLibDataChannel::_poll() {
Error WebRTCLibDataChannel::_poll() {
return OK;
}

Expand All @@ -177,7 +177,7 @@ void WebRTCLibDataChannel::_close() try {
} catch (...) {
}

int64_t WebRTCLibDataChannel::_get_packet(const uint8_t **r_buffer, int32_t *r_len) {
Error WebRTCLibDataChannel::_get_packet(const uint8_t **r_buffer, int32_t *r_len) {
ERR_FAIL_COND_V(packet_queue.empty(), ERR_UNAVAILABLE);

mutex->lock();
Expand All @@ -191,10 +191,10 @@ int64_t WebRTCLibDataChannel::_get_packet(const uint8_t **r_buffer, int32_t *r_l

mutex->unlock();

return 0;
return OK;
}

int64_t WebRTCLibDataChannel::_put_packet(const uint8_t *p_buffer, int64_t p_len) try {
Error WebRTCLibDataChannel::_put_packet(const uint8_t *p_buffer, int64_t p_len) try {
ERR_FAIL_COND_V(!channel, FAILED);
ERR_FAIL_COND_V(channel->isClosed(), FAILED);
if (write_mode == WRITE_MODE_TEXT) {
Expand Down
13 changes: 7 additions & 6 deletions src/WebRTCLibDataChannel.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#define GDCLASS(arg1, arg2) GODOT_CLASS(arg1, arg2)
#endif
#else
#include <godot_cpp/classes/global_constants_binds.hpp>
#include <godot_cpp/classes/web_rtc_data_channel_extension.hpp>
#endif

Expand Down Expand Up @@ -75,20 +76,20 @@ class WebRTCLibDataChannel : public godot::WebRTCDataChannelExtension {
static WebRTCLibDataChannel *new_data_channel(std::shared_ptr<rtc::DataChannel> p_channel, bool p_negotiated);

/* PacketPeer */
virtual int64_t _get_packet(const uint8_t **r_buffer, int32_t *r_len) override;
virtual int64_t _put_packet(const uint8_t *p_buffer, int64_t p_len) override;
virtual godot::Error _get_packet(const uint8_t **r_buffer, int32_t *r_len) override;
virtual godot::Error _put_packet(const uint8_t *p_buffer, int64_t p_len) override;
virtual int64_t _get_available_packet_count() const override;
virtual int64_t _get_max_packet_size() const override;

/* WebRTCDataChannel */
int64_t _poll() override;
godot::Error _poll() override;
void _close() override;

void _set_write_mode(int64_t p_mode) override;
int64_t _get_write_mode() const override;
void _set_write_mode(WriteMode p_mode) override;
WriteMode _get_write_mode() const override;
bool _was_string_packet() const override;

int64_t _get_ready_state() const override;
ChannelState _get_ready_state() const override;
godot::String _get_label() const override;
bool _is_ordered() const override;
int64_t _get_id() const override;
Expand Down
38 changes: 12 additions & 26 deletions src/WebRTCLibPeerConnection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,24 +35,10 @@ using namespace godot;
using namespace godot_webrtc;

#ifdef GDNATIVE_WEBRTC
struct CastableError {
godot::Error err_enum;
int64_t err_int;

operator int64_t() { return err_int; }
operator godot::Error() { return err_enum; }
CastableError(godot::Error p_enum, int64_t p_int) {
err_enum = p_enum;
err_int = p_int;
}
};
#define MKERR(m_err) CastableError(godot::Error::m_err, GODOT_##m_err)
#define OK MKERR(OK)
#define FAILED MKERR(FAILED)
#define ERR_UNCONFIGURED MKERR(ERR_UNCONFIGURED)
#define ERR_UNAVAILABLE MKERR(ERR_UNAVAILABLE)
#define ERR_INVALID_PARAMETER MKERR(ERR_INVALID_PARAMETER)
#define ERR_BUG MKERR(ERR_BUG)
#define OK Error::OK
#define FAILED Error::FAILED
#define ERR_UNCONFIGURED Error::ERR_UNCONFIGURED
#define ERR_INVALID_PARAMETER Error::ERR_INVALID_PARAMETER
#endif

void WebRTCLibPeerConnection::initialize_signaling() {
Expand Down Expand Up @@ -124,7 +110,7 @@ Error WebRTCLibPeerConnection::_parse_channel_config(rtc::DataChannelInit &r_con
return OK;
}

int64_t WebRTCLibPeerConnection::_get_connection_state() const {
WebRTCPeerConnection::ConnectionState WebRTCLibPeerConnection::_get_connection_state() const {
ERR_FAIL_COND_V(peer_connection == nullptr, STATE_CLOSED);

rtc::PeerConnection::State state = peer_connection->state();
Expand All @@ -144,7 +130,7 @@ int64_t WebRTCLibPeerConnection::_get_connection_state() const {
}
}

int64_t WebRTCLibPeerConnection::_initialize(const Dictionary &p_config) {
Error WebRTCLibPeerConnection::_initialize(const Dictionary &p_config) {
rtc::Configuration config = {};
if (p_config.has("iceServers") && p_config["iceServers"].get_type() == Variant::ARRAY) {
Array servers = p_config["iceServers"];
Expand All @@ -155,7 +141,7 @@ int64_t WebRTCLibPeerConnection::_initialize(const Dictionary &p_config) {
ERR_FAIL_COND_V(err != OK, FAILED);
}
}
return (int64_t)_create_pc(config);
return _create_pc(config);
}

Object *WebRTCLibPeerConnection::_create_data_channel(const String &p_channel, const Dictionary &p_channel_config) try {
Expand All @@ -178,7 +164,7 @@ Object *WebRTCLibPeerConnection::_create_data_channel(const String &p_channel, c
ERR_FAIL_V(nullptr);
}

int64_t WebRTCLibPeerConnection::_create_offer() try {
Error WebRTCLibPeerConnection::_create_offer() try {
ERR_FAIL_COND_V(!peer_connection, ERR_UNCONFIGURED);
ERR_FAIL_COND_V(_get_connection_state() != STATE_NEW, FAILED);
peer_connection->setLocalDescription(rtc::Description::Type::Offer);
Expand All @@ -188,7 +174,7 @@ int64_t WebRTCLibPeerConnection::_create_offer() try {
ERR_FAIL_V(FAILED);
}

int64_t WebRTCLibPeerConnection::_set_remote_description(const String &p_type, const String &p_sdp) try {
Error WebRTCLibPeerConnection::_set_remote_description(const String &p_type, const String &p_sdp) try {
ERR_FAIL_COND_V(!peer_connection, ERR_UNCONFIGURED);
std::string sdp(p_sdp.utf8().get_data());
std::string type(p_type.utf8().get_data());
Expand All @@ -204,15 +190,15 @@ int64_t WebRTCLibPeerConnection::_set_remote_description(const String &p_type, c
ERR_FAIL_V(FAILED);
}

int64_t WebRTCLibPeerConnection::_set_local_description(const String &p_type, const String &p_sdp) {
Error WebRTCLibPeerConnection::_set_local_description(const String &p_type, const String &p_sdp) {
ERR_FAIL_COND_V(!peer_connection, ERR_UNCONFIGURED);
// XXX Library quirk. It doesn't seem possible to create offers/answers without setting the local description.
// Ignore this call for now to avoid crash (it's already set automatically!).
//peer_connection->setLocalDescription(p_type == String("offer") ? rtc::Description::Type::Offer : rtc::Description::Type::Answer);
return OK;
}

int64_t WebRTCLibPeerConnection::_add_ice_candidate(const String &sdpMidName, int64_t sdpMlineIndexName, const String &sdpName) try {
Error WebRTCLibPeerConnection::_add_ice_candidate(const String &sdpMidName, int64_t sdpMlineIndexName, const String &sdpName) try {
ERR_FAIL_COND_V(!peer_connection, ERR_UNCONFIGURED);
rtc::Candidate candidate(sdpName.utf8().get_data(), sdpMidName.utf8().get_data());
peer_connection->addRemoteCandidate(candidate);
Expand All @@ -222,7 +208,7 @@ int64_t WebRTCLibPeerConnection::_add_ice_candidate(const String &sdpMidName, in
ERR_FAIL_V(FAILED);
}

int64_t WebRTCLibPeerConnection::_poll() {
Error WebRTCLibPeerConnection::_poll() {
ERR_FAIL_COND_V(!peer_connection, ERR_UNCONFIGURED);

while (!signal_queue.empty()) {
Expand Down
15 changes: 8 additions & 7 deletions src/WebRTCLibPeerConnection.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#define GDCLASS(arg1, arg2) GODOT_CLASS(arg1, arg2)
#endif
#else
#include <godot_cpp/classes/global_constants_binds.hpp>
#include <godot_cpp/classes/web_rtc_peer_connection_extension.hpp>
#endif

Expand Down Expand Up @@ -71,15 +72,15 @@ class WebRTCLibPeerConnection : public godot::WebRTCPeerConnectionExtension {

void _init();

int64_t _get_connection_state() const override;
ConnectionState _get_connection_state() const override;

int64_t _initialize(const godot::Dictionary &p_config) override;
godot::Error _initialize(const godot::Dictionary &p_config) override;
godot::Object *_create_data_channel(const godot::String &p_channel, const godot::Dictionary &p_channel_config) override;
int64_t _create_offer() override;
int64_t _set_remote_description(const godot::String &type, const godot::String &sdp) override;
int64_t _set_local_description(const godot::String &type, const godot::String &sdp) override;
int64_t _add_ice_candidate(const godot::String &sdpMidName, int64_t sdpMlineIndexName, const godot::String &sdpName) override;
int64_t _poll() override;
godot::Error _create_offer() override;
godot::Error _set_remote_description(const godot::String &type, const godot::String &sdp) override;
godot::Error _set_local_description(const godot::String &type, const godot::String &sdp) override;
godot::Error _add_ice_candidate(const godot::String &sdpMidName, int64_t sdpMlineIndexName, const godot::String &sdpName) override;
godot::Error _poll() override;
void _close() override;

WebRTCLibPeerConnection();
Expand Down
2 changes: 1 addition & 1 deletion src/net/WebRTCDataChannelNative.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ godot_int get_max_packet_size_wdc(const void *user) {
}

void set_write_mode_wdc(void *user, godot_int write_mode) {
((WebRTCDataChannelNative *)user)->_set_write_mode(write_mode);
((WebRTCDataChannelNative *)user)->_set_write_mode((godot::WebRTCDataChannel::WriteMode)write_mode);
}

godot_int get_write_mode_wdc(const void *user) {
Expand Down
12 changes: 6 additions & 6 deletions src/net/WebRTCDataChannelNative.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,11 +112,11 @@ class WebRTCDataChannelNative : public godot::WebRTCDataChannelGDNative {
void _init();
void register_interface(const godot_net_webrtc_data_channel *interface);

virtual void _set_write_mode(int64_t mode) = 0;
virtual int64_t _get_write_mode() const = 0;
virtual void _set_write_mode(WriteMode mode) = 0;
virtual WriteMode _get_write_mode() const = 0;
virtual bool _was_string_packet() const = 0;

virtual int64_t _get_ready_state() const = 0;
virtual ChannelState _get_ready_state() const = 0;
virtual godot::String _get_label() const = 0;
virtual bool _is_ordered() const = 0;
virtual int64_t _get_id() const = 0;
Expand All @@ -126,12 +126,12 @@ class WebRTCDataChannelNative : public godot::WebRTCDataChannelGDNative {
virtual bool _is_negotiated() const = 0;
virtual int64_t _get_buffered_amount() const = 0;

virtual int64_t _poll() = 0;
virtual godot::Error _poll() = 0;
virtual void _close() = 0;

/* PacketPeer */
virtual int64_t _get_packet(const uint8_t **r_buffer, int32_t *r_len) = 0;
virtual int64_t _put_packet(const uint8_t *p_buffer, int64_t p_len) = 0;
virtual godot::Error _get_packet(const uint8_t **r_buffer, int32_t *r_len) = 0;
virtual godot::Error _put_packet(const uint8_t *p_buffer, int64_t p_len) = 0;
virtual int64_t _get_available_packet_count() const = 0;
virtual int64_t _get_max_packet_size() const = 0;

Expand Down
Loading

0 comments on commit 822e053

Please sign in to comment.