Sync the TypedDictionary class
Copied over TypedDictionary class from Godot, re-commented out the IPAddress macro lines and changed the VARIANT_TYPE and METADATA variables to use their respective GDExtension enum types.
Tested on one of my projects and it seems to work fine.
Thanks!
The code changes match what's in Godot's version, but the test project fails to compile for me locally. The CI didn't fail, because it looks like the jobs that build the test project didn't run? I'm not sure what that's about.
Anyway, the these are the errors I'm getting:
Compilation errors
In file included from /home/dsnopek/Sync/Projects/default/godot-cpp/include/godot_cpp/core/method_bind.hpp:33,
from /home/dsnopek/Sync/Projects/default/godot-cpp/include/godot_cpp/core/class_db.hpp:37,
from /home/dsnopek/Sync/Projects/default/godot-cpp/gen/include/godot_cpp/classes/ref_counted.hpp:38,
from /home/dsnopek/Sync/Projects/default/godot-cpp/include/godot_cpp/classes/ref.hpp:36,
from /home/dsnopek/Sync/Projects/default/godot-cpp/gen/include/godot_cpp/classes/node.hpp:36,
from /home/dsnopek/Sync/Projects/default/godot-cpp/gen/include/godot_cpp/classes/canvas_item.hpp:36,
from /home/dsnopek/Sync/Projects/default/godot-cpp/gen/include/godot_cpp/classes/control.hpp:35,
from src/example.h:16,
from src/example.cpp:6:
/home/dsnopek/Sync/Projects/default/godot-cpp/include/godot_cpp/core/binder_common.hpp: In instantiation of 'void godot::call_get_argument_type_helper(int, int&, GDExtensionVariantType&) [with Q = const godot::TypedDictionary<godot::String, long int>&]':
/home/dsnopek/Sync/Projects/default/godot-cpp/include/godot_cpp/core/binder_common.hpp:494:53: required from 'GDExtensionVariantType godot::call_get_argument_type(int) [with P = {const godot::TypedDictionary<godot::String, long int>&}]'
/home/dsnopek/Sync/Projects/default/godot-cpp/include/godot_cpp/core/method_bind.hpp:446:39: required from 'GDExtensionVariantType godot::MethodBindTR<R, P>::gen_argument_type(int) const [with R = int; P = {const godot::TypedDictionary<godot::String, long int>&}]'
/home/dsnopek/Sync/Projects/default/godot-cpp/include/godot_cpp/core/method_bind.hpp:444:33: required from here
/home/dsnopek/Sync/Projects/default/godot-cpp/include/godot_cpp/core/binder_common.hpp:483:63: error: incomplete type 'godot::GetTypeInfo<const godot::TypedDictionary<godot::String, long int>&, void>' used in nested name specifier
483 | type = GDExtensionVariantType(GetTypeInfo<Q>::VARIANT_TYPE);
| ^~~~~~~~~~~~
/home/dsnopek/Sync/Projects/default/godot-cpp/include/godot_cpp/core/binder_common.hpp: In instantiation of 'void godot::call_get_argument_type_info_helper(int, int&, godot::PropertyInfo&) [with Q = const godot::TypedDictionary<godot::String, long int>&]':
/home/dsnopek/Sync/Projects/default/godot-cpp/include/godot_cpp/core/binder_common.hpp:513:58: required from 'void godot::call_get_argument_type_info(int, godot::PropertyInfo&) [with P = {const godot::TypedDictionary<godot::String, long int>&}]'
/home/dsnopek/Sync/Projects/default/godot-cpp/include/godot_cpp/core/method_bind.hpp:455:37: required from 'godot::PropertyInfo godot::MethodBindTR<R, P>::gen_argument_type_info(int) const [with R = int; P = {const godot::TypedDictionary<godot::String, long int>&}]'
/home/dsnopek/Sync/Projects/default/godot-cpp/include/godot_cpp/core/method_bind.hpp:452:23: required from here
/home/dsnopek/Sync/Projects/default/godot-cpp/include/godot_cpp/core/binder_common.hpp:503:54: error: incomplete type 'godot::GetTypeInfo<const godot::TypedDictionary<godot::String, long int>&, void>' used in nested name specifier
503 | info = GetTypeInfo<Q>::get_class_info();
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~
/home/dsnopek/Sync/Projects/default/godot-cpp/include/godot_cpp/core/binder_common.hpp: In instantiation of 'void godot::call_get_argument_metadata_helper(int, int&, GDExtensionClassMethodArgumentMetadata&) [with Q = const godot::TypedDictionary<godot::String, long int>&]':
/home/dsnopek/Sync/Projects/default/godot-cpp/include/godot_cpp/core/binder_common.hpp:533:57: required from 'GDExtensionClassMethodArgumentMetadata godot::call_get_argument_metadata(int) [with P = {const godot::TypedDictionary<godot::String, long int>&}]'
/home/dsnopek/Sync/Projects/default/godot-cpp/include/godot_cpp/core/method_bind.hpp:468:43: required from 'GDExtensionClassMethodArgumentMetadata godot::MethodBindTR<R, P>::get_argument_metadata(int) const [with R = int; P = {const godot::TypedDictionary<godot::String, long int>&}]'
/home/dsnopek/Sync/Projects/default/godot-cpp/include/godot_cpp/core/method_bind.hpp:466:49: required from here
/home/dsnopek/Sync/Projects/default/godot-cpp/include/godot_cpp/core/binder_common.hpp:521:38: error: incomplete type 'godot::GetTypeInfo<const godot::TypedDictionary<godot::String, long int>&, void>' used in nested name specifier
521 | md = GetTypeInfo<Q>::METADATA;
| ^~~~~~~~
/home/dsnopek/Sync/Projects/default/godot-cpp/include/godot_cpp/core/binder_common.hpp: In instantiation of 'void godot::call_with_ptr_args_ret_helper(T*, R (T::*)(P ...), const void* const*, void*, godot::IndexSequence<Is ...>) [with T = godot::_gde_UnexistingClass; R = int; P = {const godot::TypedDictionary<godot::String, long int>&}; long unsigned int ...Is = {0}; GDExtensionConstTypePtr = const void*]':
/home/dsnopek/Sync/Projects/default/godot-cpp/include/godot_cpp/core/binder_common.hpp:224:43: required from 'void godot::call_with_ptr_args(T*, R (T::*)(P ...), const void* const*, void*) [with T = godot::_gde_UnexistingClass; R = int; P = {const godot::TypedDictionary<godot::String, long int>&}; GDExtensionConstTypePtr = const void*]'
/home/dsnopek/Sync/Projects/default/godot-cpp/include/godot_cpp/core/method_bind.hpp:487:36: required from 'void godot::MethodBindTR<R, P>::ptrcall(GDExtensionClassInstancePtr, const void* const*, GDExtensionTypePtr) const [with R = int; P = {const godot::TypedDictionary<godot::String, long int>&}; GDExtensionClassInstancePtr = void*; GDExtensionConstTypePtr = const void*; GDExtensionTypePtr = void*]'
/home/dsnopek/Sync/Projects/default/godot-cpp/include/godot_cpp/core/method_bind.hpp:483:15: required from here
/home/dsnopek/Sync/Projects/default/godot-cpp/include/godot_cpp/core/binder_common.hpp:204:73: error: 'convert' is not a member of 'godot::PtrToArg<const godot::TypedDictionary<godot::String, long int>&>'
204 | PtrToArg<R>::encode((p_instance->*p_method)(PtrToArg<P>::convert(p_args[Is])...), r_ret);
| ~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
scons: *** [src/example.os] Error 1
scons: building terminated because of errors.
It seems to come from this function on the Example class:
int test_tdictionary_arg(const TypedDictionary<String, int64_t> &p_dictionary);
The problem appears to be that it's using a const reference. If I change this to:
int test_tdictionary_arg(TypedDictionary<String, int64_t> p_dictionary);
Then it compiles just fine!
I think the Godot version depends on this code in type_info.h:
template <typename T>
struct GetTypeInfo<T, std::enable_if_t<!std::is_same_v<T, GetSimpleTypeT<T>>>> : GetTypeInfo<GetSimpleTypeT<T>> {};
So, I think we need to sync type_info.h before we can sync typed_dictionary.h
The CI didn't fail, because it looks like the jobs that build the test project didn't run? I'm not sure what that's about.
thats probably my fault from when i merged in the selective compile depending on what source changes. I'll double check and submit a PR shortly, unless someone else gets to it first.
Edit: Checked and yes its my fault, the filter only picksu up .h and not .hpp
with:
files_yaml: sources:
- '.github/workflows/*.yml'
- '**/*.py'
- '**/*.cpp'
- '**/*.h'
- 'test/build_profile.json'
- 'gdextension/extension_api.json'
scons:
- '**/SConstruct'
- '**/SCsub'
- '**/*.py'
cmake:
- '**/CMakeLists.txt'
- '**/*.cmake'