Repository navigation
Open
Labels
bugThis has been identified as a bugThis has been identified as a bugconfirmeddiscussiontopic:gdextensionThis relates to the new Godot 4 extension implementationThis relates to the new Godot 4 extension implementation
Milestone
Description
godot-cpp: ad11bbb5845a454551d490812631922c33b7601c
godot: godotengine/godot#52192
Some missing API functions and discrepancies found during attempt to port TextServerAdvanced to the GDExtension (as part of godotengine/godot#52192):
String:missingptr,ptrwmethods.missing+,+=operators.
StringNamedo not expose<and>operators, and unusable as map key.Packed*Arrray:missingptr,ptrwmethods.[]operator API difference with the engine ([]vs.write[]).
Dictionary:missing[]operator.seems to have no methods to write value at all.
Char*String:no public constructors.
RID:nois_validmethod.noIncluded in Port a bunch of Godot container templates to GDExtension. #701.RID_*_Ownerimplementation, can be copy-pasted locally from the engine with minimal changes, but probably should be part of godot-cpp.
MutexandSemaphore:lockandunlockmethods aren'tconst.noIncluded in Port a bunch of Godot container templates to GDExtension. #701.MutexLockclass and_THREAD_SAFE_macros defined (can be added locally, but probably should be part of godot-cpp).
memnew,memdeletearen't working with non-Godot classes.nomemalloc,memfreemacros defined (can be added locally):#define memalloc(m_size) Memory::alloc_static(m_size) #define memrealloc(m_mem, m_size) Memory::realloc_static(m_mem, m_size) #define memfree(m_mem) Memory::free_static(m_mem)Enum type return values can't be bound on the engine side.Enum type argument types can't be bound, unless conversion macros is added manually-MAKE_PTRARGCONV(TextServer::Direction, int64_t);.Missing math defines,MAX,MIN,CLAMPetc.No conversion for custom native pointer types, can be fixed locally by addingGDVIRTUAL_NATIVE_PTR(Glyph *);macro.No templates forIncluded in Port a bunch of Godot container templates to GDExtension. #701.Vector,Map,List,HashMap,Set, not a critical issue, but would be convenient to have for better module <-> GDExtension portability.
Reacted by Sarah
Metadata
Metadata
Assignees
Labels
bugThis has been identified as a bugThis has been identified as a bugconfirmeddiscussiontopic:gdextensionThis relates to the new Godot 4 extension implementationThis relates to the new Godot 4 extension implementation
Activity
akien-mga commentedon Sep 29, 2021
Most of the discrepancy in core classes comes from the fact that GDExtension uses the API registered in
ClassDB, i.e. the proxy classes defined incore/core_bind.cpp. Some of the differences are probably oversights (core class refactored, but not thecore_bind.cppversion), and others might be for technical reasons. For exampleThreadandcore_bind::Threadhave a somewhat different API (e.g.Thread::is_started()vscore_bind::Thread::is_active()).I ran into most of the above too when attempting to port the
opensimplexmodule to an extension (just for testing purposes). Some others I ran into:RSalias forRenderingServeris not defined (might be worth considering whether we should still use it at all upstream).RenderingServer::free()is exposed asRenderingServer::free_rid(). That's a good candidate for renaming upstream to usefree_ridconsistently IMO (alsoPhysicsServer*andTextServer)SNAMEis not available to create and reference static stringnames.callable_mpis not available either. It could likely be copied fromcore/object/callable_method_pointer.hand adapted to work in godot-cpp.vformatnot availableDEFVALnot defined. It's a no-op upstream but used for readability: Remove DEFVAL godot#46903. Either that PR should be reassessed (removeDEFVAL), or it should be added here for consistency.Imageconstructors missing.OBJ_SAVE_TYPEandGDREGISTER_CLASSmissing.I also had issues with a class extending
Texture2D. It's an abstract virtual class upstream, and my derived class is still seen as abstract in Godot so it can't be instantiated. That's probably the same cause as godotengine/godot#35484 for GDScript/C# custom nodes.Also related, using the
overridekeyword in that class extendingTexture2Ddidn't work, as apparently godot-cpp couldn't see that I'm indeed overriding virtual methods from the base class. That might be an expected limitation though.Zylann commentedon Sep 29, 2021
For these ones I believe they should stop being used. In C++ max/min/clamp already exist as inline templates in
Math::and in STL so I see no reason to use macros for that stuff.Such shortcuts shouldn't need to exist IMO, at least not globally. It's a 2-letter macro whose sole purpose is shortening something that isn't that long and not used often (depends of the area of course), and being explicit would be much better. If the singleton is repeated a lot then it can be placed in a local reference.
Xrayez commentedon Sep 29, 2021
I use those all the time in https://github.com/goostengine/goost, even templates like
LocalVector.See godotengine/godot#42830.
Razoric480 commentedon Dec 5, 2021
The ClassDB object allows for registering but doesn't give access to any of its methods as defined in the version GDscript has access to: https://docs.godotengine.org/en/latest/classes/class_classdb.html
2shady4u commentedon Jan 29, 2022
Another method of String that went missing in GDExtension:
alloc_c_string()EDIT: Also, I can't seem to find an equivalent to the
String::num_int64()-method in the new GDExtension API.bruvzg commentedon Feb 21, 2022
There's no such method in the Godot ether, what's it supposed to do?
This is fixed.
Updated the first comment, most of the stuff in the original issue is already fixed, or (in case of templates) will be added by #701
2shady4u commentedon Feb 21, 2022
It's supposed to be an easy way of converting a Godot String to a char*.
This can be worked around by first going to CharString and then getting a char* from that.
bruvzg commentedon Feb 21, 2022
With the new GDextension API you can do something like this instead (and
CharStringis essentially a wrapper which will do it for you and auto-free thechar *array):2shady4u commentedon Feb 26, 2022
I'm getting warnings during compilation:

Is there any reason why the []-operator doesn't take a int64_t (like all other Array methods)?

All other methods of Array either return or accept int64_t as their output/input. For example the
insert()-method which also deals with accessing an array's position is as follows:In Godot's source code this method takes an int instead.
If no reason at all, would it be possible to change this inconsistency?
(Either by making all methods take int or by making all methods take int64_t)
Zylann commentedon Feb 26, 2022
In Godot's source code, that method also takes an
int, and in practice if you need more thanINT_MAXthen you'd need a bit more than 64 Gb of RAM to hold such an array in memory (Variant is around 32 bytes).One reason I know
int64_tis used in many places is becauseVariantstores integers as such. Otherwise, I don't know.For consistency however it would be valid to use
int64_there instead, orsize_t. I dont think it's usingintfor any other reason than "it's the same in core".codecat commentedon Mar 5, 2022
This issue mentions
String::operator+=but is stroked out, does that mean it won't be implemented, or is that just an oversight for now? I think+=is kind of an important operator on strings, and it does exist on Godot itself.Zylann commentedon Mar 5, 2022
Dont the strokes mean "done"?
codecat commentedon Mar 5, 2022
It it means "done", then it is wrongly crossed out:
bruvzg commentedon Mar 5, 2022
It means "done", but it's done it the godotengine/godot#58233, which is not merged.
2shady4u commentedon Jun 5, 2022
I'm using the latest master commit (eaaf941) and using += to add two godot Strings together isn't accepted yet... :/ (Event though godotengine/godot#58233) has now been merged and been included in the latest Godot 4.0 Alpha 9.
DmitriySalnikov commentedon Jul 1, 2022
Do I understand correctly that
Callablein GDExtension cannot be used normally at the moment?For example, in
Godot v4.0.alpha11.official [afdae67cc]Thread.startnow does not acceptuser_data, butCallable.bindis not implemented.Callable.binddoesn't even get a pointer to the engine function.Zylann commentedon Sep 11, 2022
@DmitriySalnikov None of Callable's vararg methods are implemented #802
Daylily-Zeleen commentedon Dec 4, 2022
Implement by #936.
mihe commentedon Dec 8, 2022
I'm not sure if this should be considered a bug or an API discrepancy, but
CharString,Char16StringandChar32Stringall behave differently from core with regards tolength()and (lack of)size().In core,
size()returns the size with the null-terminator included andlength()returns the size without the null-terminator included.In godot-cpp, there is no
size()andlength()returns the size with the null-terminator included.However,
String::length()behaves as expected in godot-cpp, giving you the size without the null-terminator, which makes this discrepancy a bit jarring.EDIT: I ended up making a PR for it: #961
DmitriySalnikov commentedon May 31, 2023
Resource::get_ridis not exposed as virtual method.For me, this makes it a bit difficult to create my own
Texture2Dand forces me to override thedraw_*methods.Actually, this issue has already been discussed here #877, but for some reason it was archived.