HxGodot / hxgodot

A Haxe GDExtension for Godot 4
MIT License
232 stars 11 forks source link

Building want other types, latest Haxe nightly #49

Closed PXshadow closed 1 year ago

PXshadow commented 1 year ago
haxe build.hxml -debug -D HXCPP_M64
src/example/HxExample.hx:73: characters 23-36 : cpp.Int64 should be Int
src/example/HxExample.hx:81: characters 23-33 : cpp.Int64 should be Int
src/example/HxExample.hx:82: characters 19-31 : godot.variant.Variant should be Int
src/example/HxExample.hx:82: characters 19-31 : ... For function argument 'v'
/usr/local/lib/haxe/lib/hxgodot/git/src/godot/macros/ArgumentMacros.hx:49: characters 33-49 : godot.variant.Variant should be Int
/usr/local/lib/haxe/lib/hxgodot/git/src/godot/macros/ArgumentMacros.hx:49: characters 33-49 : ... For function argument '_a'
/usr/local/lib/haxe/lib/hxgodot/git/src/godot/macros/ArgumentMacros.hx:49: characters 33-49 : godot.variant.Variant should be Int
/usr/local/lib/haxe/lib/hxgodot/git/src/godot/macros/ArgumentMacros.hx:49: characters 33-49 : ... For function argument '_v'
bindings/godot/Viewport.hx:241: lines 241-252 : In method set_screen_space_aa required by property screen_space_aa
bindings/godot/Viewport.hx:241: lines 241-252 : ... error: cpp.Int64 should be cpp.Int32
bindings/godot/Viewport.hx:241: lines 241-252 : ... have: (cpp.Int32) -> ...
bindings/godot/Viewport.hx:241: lines 241-252 : ... want: (cpp.Int64) -> ...
scons: *** [bin/libHxGodot-debug.a] Error 1
scons: building terminated because of errors.
Screen Shot 2023-02-08 at 05 16 23

os: mac os 64x intel Haxe version: 4.3.0-rc.1+660947b Godot version: Godot_v4.0-beta14

Seems to be related to hxcpp changes in basic types.

snwhd commented 1 year ago

I ran into this issue as well.

One of the errors I have is in the generated bindings/godot/Node.hx where the process_mode property is defined as type cpp.Int64, but set_process_mode is defined as function set_process_mode(mode:cpp.Int32):cpp.Int64. The argument type should be defined as cpp.Int64.

This is due to the way hxgodot is handling enum values. In extension_api.json the Node.process_mode property is defined as type int (which is translated to cpp.Int64 in TypeMacros.hx) but the method Node.set_process_mode has it's argument defined as type enum::Node.ProcessMode and enums are translated to cpp.Int32 in ClassGenMacros._generateClasses.

Changing the translated enum type to cpp.Int64 resolves these errors. I suspect I'm misunderstanding something though, because if this is the issue shouldn't the errors throw for everyone using hxgodot?

That still leaves the "godot.variant.Variant should be Int" errors which I have not looked into yet. I'm still fairly new to Haxe and this is my first time working with macros, but I'll look into that one later. Hopefully this is helpful

dazKind commented 1 year ago

Oh that actually makes sense. I will do a bugfix pass tonight. Interestingly with a non-nightly / stable version we dont see these errors

dazKind commented 1 year ago

I isolated the error here: https://gist.github.com/dazKind/8a916288a9b4bdcf8b64ae6d2eee1265

Turns out that the culprit is https://github.com/HaxeFoundation/haxe/pull/10133 which has not been released on stable before, hence why everything silently works on 4.2.5. Im not sure yet what a feasible solution could be since it totally breaks with normal for-loops and int64

dazKind commented 1 year ago

This is solved with the official support for Haxe 4.3.1