godotengine / godot-cpp

C++ bindings for the Godot script API
MIT License
1.71k stars 573 forks source link

Crypto class has no _new() method #1268

Closed ashtonmeuser closed 1 year ago

ashtonmeuser commented 1 year ago

Godot version

4.1.2-stable

godot-cpp version

godot-4.1.2-stable

System information

MacOS 13.4, Windows 10

Issue description

The generated Crypto class has no way of declaring a new reference. In the Godot 3.x branch of the C++ bindings, there exists a static _new() method. No such method exists in the 4.x branch. That means that users must manually use unreference() or errors indicating orphaned objects is thrown.

Steps to reproduce

Build Godot C++ bindings. View resultant _godot-cpp/gen/include/godotcpp/classes/crypto.hpp file. Note that there is no static _new() method (or similar equivalent).

Minimal reproduction project

N/A

dsnopek commented 1 year ago

I'm not really familiar with how this worked in GDNative - can you share how you expect to use the _new() method?

Is there a reason you can't do something like:

Ref<Crypto> crypto;
crypto.instantiate();
Ref<CryptoKey> key = crypto->generate_rsa(4096);

I don't know what you're trying to do with the Crypt class :-)

ashtonmeuser commented 1 year ago

Thanks! That works. I was looking for a single-line replacement for Godot 3.x's Crypto::_new()->generate_random_bytes(n) but this can be (hackily) achieved with [n]()->PackedByteArray{Ref<Crypto> c;c.instantiate();return c->generate_random_bytes(n);}(). Closing this issue.