Allow ClassDB to create a Object without postinitialization for GDExtension.

This commit is contained in:
Daylily-Zeleen
2024-04-22 22:34:44 +08:00
parent 8dfb8efaa9
commit 3d575801ce
40 changed files with 345 additions and 140 deletions

View File

@ -49,8 +49,8 @@
#define PEM_END_CRT "-----END CERTIFICATE-----\n"
#define PEM_MIN_SIZE 54
CryptoKey *CryptoKeyMbedTLS::create() {
return memnew(CryptoKeyMbedTLS);
CryptoKey *CryptoKeyMbedTLS::create(bool p_notify_postinitialize) {
return static_cast<CryptoKey *>(ClassDB::creator<CryptoKeyMbedTLS>(p_notify_postinitialize));
}
Error CryptoKeyMbedTLS::load(const String &p_path, bool p_public_only) {
@ -153,8 +153,8 @@ int CryptoKeyMbedTLS::_parse_key(const uint8_t *p_buf, int p_size) {
#endif
}
X509Certificate *X509CertificateMbedTLS::create() {
return memnew(X509CertificateMbedTLS);
X509Certificate *X509CertificateMbedTLS::create(bool p_notify_postinitialize) {
return static_cast<X509Certificate *>(ClassDB::creator<X509CertificateMbedTLS>(p_notify_postinitialize));
}
Error X509CertificateMbedTLS::load(const String &p_path) {
@ -250,8 +250,8 @@ bool HMACContextMbedTLS::is_md_type_allowed(mbedtls_md_type_t p_md_type) {
}
}
HMACContext *HMACContextMbedTLS::create() {
return memnew(HMACContextMbedTLS);
HMACContext *HMACContextMbedTLS::create(bool p_notify_postinitialize) {
return static_cast<HMACContext *>(ClassDB::creator<HMACContextMbedTLS>(p_notify_postinitialize));
}
Error HMACContextMbedTLS::start(HashingContext::HashType p_hash_type, const PackedByteArray &p_key) {
@ -309,8 +309,8 @@ HMACContextMbedTLS::~HMACContextMbedTLS() {
}
}
Crypto *CryptoMbedTLS::create() {
return memnew(CryptoMbedTLS);
Crypto *CryptoMbedTLS::create(bool p_notify_postinitialize) {
return static_cast<Crypto *>(ClassDB::creator<CryptoMbedTLS>(p_notify_postinitialize));
}
void CryptoMbedTLS::initialize_crypto() {

View File

@ -49,7 +49,7 @@ private:
int _parse_key(const uint8_t *p_buf, int p_size);
public:
static CryptoKey *create();
static CryptoKey *create(bool p_notify_postinitialize = true);
static void make_default() { CryptoKey::_create = create; }
static void finalize() { CryptoKey::_create = nullptr; }
@ -80,7 +80,7 @@ private:
int locks;
public:
static X509Certificate *create();
static X509Certificate *create(bool p_notify_postinitialize = true);
static void make_default() { X509Certificate::_create = create; }
static void finalize() { X509Certificate::_create = nullptr; }
@ -112,7 +112,7 @@ private:
void *ctx = nullptr;
public:
static HMACContext *create();
static HMACContext *create(bool p_notify_postinitialize = true);
static void make_default() { HMACContext::_create = create; }
static void finalize() { HMACContext::_create = nullptr; }
@ -133,7 +133,7 @@ private:
static X509CertificateMbedTLS *default_certs;
public:
static Crypto *create();
static Crypto *create(bool p_notify_postinitialize = true);
static void initialize_crypto();
static void finalize_crypto();
static X509CertificateMbedTLS *get_default_certificates();

View File

@ -54,8 +54,8 @@ Ref<PacketPeerDTLS> DTLSServerMbedTLS::take_connection(Ref<PacketPeerUDP> p_udp_
return out;
}
DTLSServer *DTLSServerMbedTLS::_create_func() {
return memnew(DTLSServerMbedTLS);
DTLSServer *DTLSServerMbedTLS::_create_func(bool p_notify_postinitialize) {
return static_cast<DTLSServer *>(ClassDB::creator<DTLSServerMbedTLS>(p_notify_postinitialize));
}
void DTLSServerMbedTLS::initialize() {

View File

@ -37,7 +37,7 @@
class DTLSServerMbedTLS : public DTLSServer {
private:
static DTLSServer *_create_func();
static DTLSServer *_create_func(bool p_notify_postinitialize);
Ref<TLSOptions> tls_options;
Ref<CookieContextMbedTLS> cookies;

View File

@ -270,8 +270,8 @@ PacketPeerMbedDTLS::Status PacketPeerMbedDTLS::get_status() const {
return status;
}
PacketPeerDTLS *PacketPeerMbedDTLS::_create_func() {
return memnew(PacketPeerMbedDTLS);
PacketPeerDTLS *PacketPeerMbedDTLS::_create_func(bool p_notify_postinitialize) {
return static_cast<PacketPeerDTLS *>(ClassDB::creator<PacketPeerMbedDTLS>(p_notify_postinitialize));
}
void PacketPeerMbedDTLS::initialize_dtls() {

View File

@ -50,7 +50,7 @@ private:
Ref<PacketPeerUDP> base;
static PacketPeerDTLS *_create_func();
static PacketPeerDTLS *_create_func(bool p_notify_postinitialize);
static int bio_recv(void *ctx, unsigned char *buf, size_t len);
static int bio_send(void *ctx, const unsigned char *buf, size_t len);

View File

@ -295,8 +295,8 @@ Ref<StreamPeer> StreamPeerMbedTLS::get_stream() const {
return base;
}
StreamPeerTLS *StreamPeerMbedTLS::_create_func() {
return memnew(StreamPeerMbedTLS);
StreamPeerTLS *StreamPeerMbedTLS::_create_func(bool p_notify_postinitialize) {
return static_cast<StreamPeerTLS *>(ClassDB::creator<StreamPeerMbedTLS>(p_notify_postinitialize));
}
void StreamPeerMbedTLS::initialize_tls() {

View File

@ -42,7 +42,7 @@ private:
Ref<StreamPeer> base;
static StreamPeerTLS *_create_func();
static StreamPeerTLS *_create_func(bool p_notify_postinitialize);
static int bio_recv(void *ctx, unsigned char *buf, size_t len);
static int bio_send(void *ctx, const unsigned char *buf, size_t len);