Compare commits
16 Commits
3eb891173f
...
d918439258
Author | SHA1 | Date |
---|---|---|
|
d918439258 | |
|
1c19d627aa | |
|
646c71c277 | |
|
48afa82f29 | |
|
39ca745d0d | |
|
a7becb43e6 | |
|
41517eacb1 | |
|
17137b2e2e | |
|
cad5be53b1 | |
|
54136ee835 | |
|
0f78fc45bd | |
|
11b2700b23 | |
|
20c4e843b0 | |
|
f3143c7a9c | |
|
943d1c8cdf | |
|
7e4a811b2c |
|
@ -104,7 +104,7 @@ jobs:
|
||||||
continue-on-error: true
|
continue-on-error: true
|
||||||
|
|
||||||
- name: Set up Python (for SCons)
|
- name: Set up Python (for SCons)
|
||||||
uses: actions/setup-python@v4
|
uses: actions/setup-python@v5
|
||||||
with:
|
with:
|
||||||
python-version: '3.x'
|
python-version: '3.x'
|
||||||
|
|
||||||
|
|
|
@ -47,11 +47,6 @@ option(GODOT_CPP_WARNING_AS_ERROR "Treat warnings as errors" OFF)
|
||||||
# Add path to modules
|
# Add path to modules
|
||||||
list( APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/" )
|
list( APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/" )
|
||||||
|
|
||||||
# Check if we are building ourself or being included
|
|
||||||
if(${PROJECT_NAME} STREQUAL ${CMAKE_PROJECT_NAME})
|
|
||||||
set(GODOT_CPP_BUILDING_SELF ON)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
# Set some helper variables for readability
|
# Set some helper variables for readability
|
||||||
set( compiler_is_clang "$<OR:$<CXX_COMPILER_ID:AppleClang>,$<CXX_COMPILER_ID:Clang>>" )
|
set( compiler_is_clang "$<OR:$<CXX_COMPILER_ID:AppleClang>,$<CXX_COMPILER_ID:Clang>>" )
|
||||||
set( compiler_is_gnu "$<CXX_COMPILER_ID:GNU>" )
|
set( compiler_is_gnu "$<CXX_COMPILER_ID:GNU>" )
|
||||||
|
@ -158,12 +153,6 @@ add_library(godot::cpp ALIAS ${PROJECT_NAME})
|
||||||
|
|
||||||
include(GodotCompilerWarnings)
|
include(GodotCompilerWarnings)
|
||||||
|
|
||||||
# Treat warnings as errors if we are building ourself
|
|
||||||
if(GODOT_CPP_BUILDING_SELF)
|
|
||||||
unset( GODOT_CPP_WARNING_AS_ERROR CACHE )
|
|
||||||
set_warning_as_error()
|
|
||||||
endif()
|
|
||||||
|
|
||||||
target_compile_features(${PROJECT_NAME}
|
target_compile_features(${PROJECT_NAME}
|
||||||
PRIVATE
|
PRIVATE
|
||||||
cxx_std_17
|
cxx_std_17
|
||||||
|
|
|
@ -7,8 +7,9 @@
|
||||||
> from Godot's `master` branch.
|
> from Godot's `master` branch.
|
||||||
>
|
>
|
||||||
> For users of stable branches, switch to the branch matching your target Godot version:
|
> For users of stable branches, switch to the branch matching your target Godot version:
|
||||||
> - [`4.0`](https://github.com/godotengine/godot-cpp/tree/4.0)
|
> - [`4.2`](https://github.com/godotengine/godot-cpp/tree/4.2)
|
||||||
> - [`4.1`](https://github.com/godotengine/godot-cpp/tree/4.1)
|
> - [`4.1`](https://github.com/godotengine/godot-cpp/tree/4.1)
|
||||||
|
> - [`4.0`](https://github.com/godotengine/godot-cpp/tree/4.0)
|
||||||
>
|
>
|
||||||
> Or check out the Git tag matching your Godot version (e.g. `godot-4.1.1-stable`).
|
> Or check out the Git tag matching your Godot version (e.g. `godot-4.1.1-stable`).
|
||||||
>
|
>
|
||||||
|
|
|
@ -1329,7 +1329,11 @@ def generate_engine_class_header(class_api, used_classes, fully_used_classes, us
|
||||||
|
|
||||||
if "enums" in class_api:
|
if "enums" in class_api:
|
||||||
for enum_api in class_api["enums"]:
|
for enum_api in class_api["enums"]:
|
||||||
result.append(f'\tenum {enum_api["name"]} {{')
|
if enum_api["is_bitfield"]:
|
||||||
|
result.append(f'\tenum {enum_api["name"]} : uint64_t {{')
|
||||||
|
else:
|
||||||
|
result.append(f'\tenum {enum_api["name"]} {{')
|
||||||
|
|
||||||
for value in enum_api["values"]:
|
for value in enum_api["values"]:
|
||||||
result.append(f'\t\t{value["name"]} = {value["value"]},')
|
result.append(f'\t\t{value["name"]} = {value["value"]},')
|
||||||
result.append("\t};")
|
result.append("\t};")
|
||||||
|
@ -1686,11 +1690,18 @@ def generate_global_constants(api, output_dir):
|
||||||
header.append(f"#ifndef {header_guard}")
|
header.append(f"#ifndef {header_guard}")
|
||||||
header.append(f"#define {header_guard}")
|
header.append(f"#define {header_guard}")
|
||||||
header.append("")
|
header.append("")
|
||||||
|
header.append("#include <cstdint>")
|
||||||
|
header.append("")
|
||||||
header.append("namespace godot {")
|
header.append("namespace godot {")
|
||||||
header.append("")
|
header.append("")
|
||||||
|
|
||||||
for constant in api["global_constants"]:
|
for constant in api["global_constants"]:
|
||||||
header.append(f'\tconst int {escape_identifier(constant["name"])} = {constant["value"]};')
|
if constant["value"] == -9223372036854775808:
|
||||||
|
# INT64_MIN is an special case here. In C++ it has to be specified like this to avoid warnings
|
||||||
|
# because 9223372036854775808 can't fit inside a `long long`, so it'll be turned into a `uint64_t`.
|
||||||
|
header.append(f'\tconst int64_t {escape_identifier(constant["name"])} = -9223372036854775807 - 1;')
|
||||||
|
else:
|
||||||
|
header.append(f'\tconst int64_t {escape_identifier(constant["name"])} = {constant["value"]};')
|
||||||
|
|
||||||
header.append("")
|
header.append("")
|
||||||
|
|
||||||
|
@ -1698,7 +1709,11 @@ def generate_global_constants(api, output_dir):
|
||||||
if enum_def["name"].startswith("Variant."):
|
if enum_def["name"].startswith("Variant."):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
header.append(f'\tenum {enum_def["name"]} {{')
|
if enum_def["is_bitfield"]:
|
||||||
|
header.append(f'\tenum {enum_def["name"]} : uint64_t {{')
|
||||||
|
else:
|
||||||
|
header.append(f'\tenum {enum_def["name"]} {{')
|
||||||
|
|
||||||
for value in enum_def["values"]:
|
for value in enum_def["values"]:
|
||||||
header.append(f'\t\t{value["name"]} = {value["value"]},')
|
header.append(f'\t\t{value["name"]} = {value["value"]},')
|
||||||
header.append("\t};")
|
header.append("\t};")
|
||||||
|
@ -2405,6 +2420,8 @@ def escape_identifier(id):
|
||||||
}
|
}
|
||||||
if id in cpp_keywords_map:
|
if id in cpp_keywords_map:
|
||||||
return cpp_keywords_map[id]
|
return cpp_keywords_map[id]
|
||||||
|
if re.match(r"U?INT\d*_(MIN|MAX)", id):
|
||||||
|
return "_" + id
|
||||||
return id
|
return id
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,9 +3,9 @@
|
||||||
"version_major": 4,
|
"version_major": 4,
|
||||||
"version_minor": 2,
|
"version_minor": 2,
|
||||||
"version_patch": 0,
|
"version_patch": 0,
|
||||||
"version_status": "rc2",
|
"version_status": "stable",
|
||||||
"version_build": "official",
|
"version_build": "official",
|
||||||
"version_full_name": "Godot Engine v4.2.rc2.official"
|
"version_full_name": "Godot Engine v4.2.stable.official"
|
||||||
},
|
},
|
||||||
"builtin_class_sizes": [
|
"builtin_class_sizes": [
|
||||||
{
|
{
|
||||||
|
|
|
@ -356,6 +356,12 @@ String vformat(const String &p_text, const VarArgs... p_args) {
|
||||||
|
|
||||||
#include <godot_cpp/variant/builtin_vararg_methods.hpp>
|
#include <godot_cpp/variant/builtin_vararg_methods.hpp>
|
||||||
|
|
||||||
|
#ifdef REAL_T_IS_DOUBLE
|
||||||
|
using PackedRealArray = PackedFloat64Array;
|
||||||
|
#else
|
||||||
|
using PackedRealArray = PackedFloat32Array;
|
||||||
|
#endif // REAL_T_IS_DOUBLE
|
||||||
|
|
||||||
} // namespace godot
|
} // namespace godot
|
||||||
|
|
||||||
#endif // GODOT_VARIANT_HPP
|
#endif // GODOT_VARIANT_HPP
|
||||||
|
|
|
@ -50,6 +50,12 @@ void Wrapped::_postinitialize() {
|
||||||
godot::internal::gdextension_interface_object_set_instance(_owner, reinterpret_cast<GDExtensionConstStringNamePtr>(extension_class), this);
|
godot::internal::gdextension_interface_object_set_instance(_owner, reinterpret_cast<GDExtensionConstStringNamePtr>(extension_class), this);
|
||||||
}
|
}
|
||||||
godot::internal::gdextension_interface_object_set_instance_binding(_owner, godot::internal::token, this, _get_bindings_callbacks());
|
godot::internal::gdextension_interface_object_set_instance_binding(_owner, godot::internal::token, this, _get_bindings_callbacks());
|
||||||
|
if (extension_class) {
|
||||||
|
Object *obj = dynamic_cast<Object *>(this);
|
||||||
|
if (obj) {
|
||||||
|
obj->notification(Object::NOTIFICATION_POSTINITIALIZE);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Wrapped::Wrapped(const StringName p_godot_class) {
|
Wrapped::Wrapped(const StringName p_godot_class) {
|
||||||
|
|
|
@ -271,7 +271,12 @@ GDExtensionBool GDExtensionBinding::init(GDExtensionInterfaceGetProcAddress p_ge
|
||||||
} else if (internal::godot_version.minor != GODOT_VERSION_MINOR) {
|
} else if (internal::godot_version.minor != GODOT_VERSION_MINOR) {
|
||||||
compatible = internal::godot_version.minor > GODOT_VERSION_MINOR;
|
compatible = internal::godot_version.minor > GODOT_VERSION_MINOR;
|
||||||
} else {
|
} else {
|
||||||
|
#if GODOT_VERSION_PATCH > 0
|
||||||
compatible = internal::godot_version.patch >= GODOT_VERSION_PATCH;
|
compatible = internal::godot_version.patch >= GODOT_VERSION_PATCH;
|
||||||
|
#else
|
||||||
|
// Prevent -Wtype-limits warning due to unsigned comparison.
|
||||||
|
compatible = true;
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
if (!compatible) {
|
if (!compatible) {
|
||||||
// We need to use snprintf() here because vformat() uses Variant, and we haven't loaded
|
// We need to use snprintf() here because vformat() uses Variant, and we haven't loaded
|
||||||
|
|
|
@ -59,31 +59,9 @@ if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
|
||||||
|
|
||||||
else()
|
else()
|
||||||
|
|
||||||
#elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
|
|
||||||
# using Clang
|
|
||||||
#elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
|
|
||||||
# using GCC and maybe MinGW?
|
|
||||||
|
|
||||||
set(GODOT_LINKER_FLAGS "-static-libgcc -static-libstdc++ -Wl,-R,'$$ORIGIN'")
|
set(GODOT_LINKER_FLAGS "-static-libgcc -static-libstdc++ -Wl,-R,'$$ORIGIN'")
|
||||||
|
|
||||||
# Hmm.. maybe to strikt?
|
|
||||||
set(GODOT_COMPILE_FLAGS "-fPIC -g -Wwrite-strings")
|
set(GODOT_COMPILE_FLAGS "-fPIC -g -Wwrite-strings")
|
||||||
set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} -Wchar-subscripts -Wcomment -Wdisabled-optimization")
|
|
||||||
set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} -Wformat -Wformat=2 -Wformat-security -Wformat-y2k")
|
|
||||||
set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} -Wimport -Winit-self -Winline -Winvalid-pch -Werror")
|
|
||||||
set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} -Wmissing-braces -Wmissing-format-attribute")
|
|
||||||
set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} -Wmissing-include-dirs -Wmissing-noreturn -Wpacked -Wpointer-arith")
|
|
||||||
set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} -Wredundant-decls -Wreturn-type -Wsequence-point")
|
|
||||||
set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} -Wswitch -Wswitch-enum -Wtrigraphs")
|
|
||||||
set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} -Wuninitialized -Wunknown-pragmas -Wunreachable-code -Wunused-label")
|
|
||||||
set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} -Wunused-value -Wvariadic-macros -Wvolatile-register-var -Wno-error=attributes")
|
|
||||||
|
|
||||||
# -Wshadow -Wextra -Wall -Weffc++ -Wfloat-equal -Wstack-protector -Wunused-parameter -Wsign-compare -Wunused-variable -Wcast-align
|
|
||||||
# -Wunused-function -Wstrict-aliasing -Wstrict-aliasing=2 -Wmissing-field-initializers
|
|
||||||
|
|
||||||
if(NOT CMAKE_SYSTEM_NAME STREQUAL "Android")
|
|
||||||
set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} -Wno-ignored-attributes")
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(CMAKE_BUILD_TYPE MATCHES Debug)
|
if(CMAKE_BUILD_TYPE MATCHES Debug)
|
||||||
set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} -fno-omit-frame-pointer -O0")
|
set(GODOT_COMPILE_FLAGS "${GODOT_COMPILE_FLAGS} -fno-omit-frame-pointer -O0")
|
||||||
|
|
|
@ -236,6 +236,11 @@ func _ready():
|
||||||
get_viewport().push_input(event)
|
get_viewport().push_input(event)
|
||||||
assert_equal(custom_signal_emitted, ["_input: H", 72])
|
assert_equal(custom_signal_emitted, ["_input: H", 72])
|
||||||
|
|
||||||
|
# Check NOTIFICATION_POST_INITIALIZED, both when created from GDScript and godot-cpp.
|
||||||
|
var new_example_ref = ExampleRef.new()
|
||||||
|
assert_equal(new_example_ref.was_post_initialized(), true)
|
||||||
|
assert_equal(example.test_post_initialize(), true)
|
||||||
|
|
||||||
exit_with_status()
|
exit_with_status()
|
||||||
|
|
||||||
func _on_Example_custom_signal(signal_name, value):
|
func _on_Example_custom_signal(signal_name, value):
|
||||||
|
|
|
@ -63,10 +63,18 @@ int ExampleRef::get_id() const {
|
||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ExampleRef::_notification(int p_what) {
|
||||||
|
if (p_what == NOTIFICATION_POSTINITIALIZE) {
|
||||||
|
post_initialized = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void ExampleRef::_bind_methods() {
|
void ExampleRef::_bind_methods() {
|
||||||
ClassDB::bind_method(D_METHOD("set_id", "id"), &ExampleRef::set_id);
|
ClassDB::bind_method(D_METHOD("set_id", "id"), &ExampleRef::set_id);
|
||||||
ClassDB::bind_method(D_METHOD("get_id"), &ExampleRef::get_id);
|
ClassDB::bind_method(D_METHOD("get_id"), &ExampleRef::get_id);
|
||||||
|
|
||||||
|
ClassDB::bind_method(D_METHOD("was_post_initialized"), &ExampleRef::was_post_initialized);
|
||||||
|
|
||||||
ADD_PROPERTY(PropertyInfo(Variant::INT, "id"), "set_id", "get_id");
|
ADD_PROPERTY(PropertyInfo(Variant::INT, "id"), "set_id", "get_id");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -220,6 +228,7 @@ void Example::_bind_methods() {
|
||||||
|
|
||||||
ClassDB::bind_method(D_METHOD("def_args", "a", "b"), &Example::def_args, DEFVAL(100), DEFVAL(200));
|
ClassDB::bind_method(D_METHOD("def_args", "a", "b"), &Example::def_args, DEFVAL(100), DEFVAL(200));
|
||||||
ClassDB::bind_method(D_METHOD("callable_bind"), &Example::callable_bind);
|
ClassDB::bind_method(D_METHOD("callable_bind"), &Example::callable_bind);
|
||||||
|
ClassDB::bind_method(D_METHOD("test_post_initialize"), &Example::test_post_initialize);
|
||||||
|
|
||||||
ClassDB::bind_static_method("Example", D_METHOD("test_static", "a", "b"), &Example::test_static);
|
ClassDB::bind_static_method("Example", D_METHOD("test_static", "a", "b"), &Example::test_static);
|
||||||
ClassDB::bind_static_method("Example", D_METHOD("test_static2"), &Example::test_static2);
|
ClassDB::bind_static_method("Example", D_METHOD("test_static2"), &Example::test_static2);
|
||||||
|
@ -597,6 +606,12 @@ Vector4 Example::get_v4() const {
|
||||||
return Vector4(1.2, 3.4, 5.6, 7.8);
|
return Vector4(1.2, 3.4, 5.6, 7.8);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool Example::test_post_initialize() const {
|
||||||
|
Ref<ExampleRef> new_example_ref;
|
||||||
|
new_example_ref.instantiate();
|
||||||
|
return new_example_ref->was_post_initialized();
|
||||||
|
}
|
||||||
|
|
||||||
// Virtual function override.
|
// Virtual function override.
|
||||||
bool Example::_has_point(const Vector2 &point) const {
|
bool Example::_has_point(const Vector2 &point) const {
|
||||||
Label *label = get_node<Label>("Label");
|
Label *label = get_node<Label>("Label");
|
||||||
|
|
|
@ -35,16 +35,21 @@ private:
|
||||||
static int last_id;
|
static int last_id;
|
||||||
|
|
||||||
int id;
|
int id;
|
||||||
|
bool post_initialized = false;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
static void _bind_methods();
|
static void _bind_methods();
|
||||||
|
|
||||||
|
void _notification(int p_what);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
ExampleRef();
|
ExampleRef();
|
||||||
~ExampleRef();
|
~ExampleRef();
|
||||||
|
|
||||||
void set_id(int p_id);
|
void set_id(int p_id);
|
||||||
int get_id() const;
|
int get_id() const;
|
||||||
|
|
||||||
|
bool was_post_initialized() const { return post_initialized; }
|
||||||
};
|
};
|
||||||
|
|
||||||
class ExampleMin : public Control {
|
class ExampleMin : public Control {
|
||||||
|
@ -167,6 +172,8 @@ public:
|
||||||
Vector2 get_custom_position() const;
|
Vector2 get_custom_position() const;
|
||||||
Vector4 get_v4() const;
|
Vector4 get_v4() const;
|
||||||
|
|
||||||
|
bool test_post_initialize() const;
|
||||||
|
|
||||||
// Static method.
|
// Static method.
|
||||||
static int test_static(int p_a, int p_b);
|
static int test_static(int p_a, int p_b);
|
||||||
static void test_static2();
|
static void test_static2();
|
||||||
|
|
Loading…
Reference in New Issue