godot-cpp: [GDExtension] Missing methods, classes and API discrepancies.
godot-cpp: ad11bbb5845a454551d490812631922c33b7601c
godot: https://github.com/godotengine/godot/pull/52192
Some missing API functions and discrepancies found during attempt to port TextServerAdvanced
to the GDExtension
(as part of https://github.com/godotengine/godot/pull/52192):
- ~
String
:~- ~missing
ptr
,ptrw
methods.~ - ~missing
+
,+=
operators.~
- ~missing
- ~
StringName
do not expose<
and>
operators, and unusable as map key.~ Packed*Arrray
:- ~missing
ptr
,ptrw
methods.~ []
operator API difference with the engine ([]
vs.write[]
).
- ~missing
- ~
Dictionary
:~- ~missing
[]
operator.~ - ~seems to have no methods to write value at all.~
- ~missing
- ~
Char*String
:~- ~no public constructors.~
RID
:- ~no
is_valid
method.~ - ~no
RID_*_Owner
implementation, can be copy-pasted locally from the engine with minimal changes, but probably should be part of godot-cpp.~ Included in #701.
- ~no
Mutex
andSemaphore
:lock
andunlock
methods aren’tconst
.- ~no
MutexLock
class and_THREAD_SAFE_
macros defined (can be added locally, but probably should be part of godot-cpp).~ Included in #701.
- ~
memnew
,memdelete
aren’t working with non-Godot classes.~ - ~no
memalloc
,memfree
macros 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
,CLAMP
etc.~ - ~No conversion for custom native pointer types, can be fixed locally by adding
GDVIRTUAL_NATIVE_PTR(Glyph *);
macro.~ - ~No templates for
Vector
,Map
,List
,HashMap
,Set
, not a critical issue, but would be convenient to have for better module <-> GDExtension portability.~ Included in #701.
About this issue
- Original URL
- State: open
- Created 3 years ago
- Reactions: 1
- Comments: 20 (14 by maintainers)
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
In Godot’s source code, that method also takes an
int
, and in practice if you need more thanINT_MAX
then 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_t
is used in many places is becauseVariant
stores integers as such. Otherwise, I don’t know.For consistency however it would be valid to use
int64_t
here instead, orsize_t
. I dont think it’s usingint
for any other reason than “it’s the same in core”.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.
It means “done”, but it’s done it the https://github.com/godotengine/godot/pull/58233, which is not merged.
Dont the strokes mean “done”?
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
I use those all the time in https://github.com/goostengine/goost, even templates like
LocalVector
.See godotengine/godot#42830.