ammer icon indicating copy to clipboard operation
ammer copied to clipboard

Invalid FFI type for return

Open darmie opened this issue 4 years ago • 6 comments

I tried to build my project with haxe 4.2.3 I got this error

ammer/FFITools.hx:115: characters 9-59 : invalid FFI type for return

Verbose

Calling macro ammer.Pointer.initType (?:1)
Exiting macro ammer.Pointer.initType
Calling macro ammer.Ammer.buildType (/Volumes/Vibranium/Users/damilare/haxe/haxe_libraries/ammer/0.0.1/github/9fe359b15fcdec1685c2bbe879f5e9c56c0ebcdc/src/ammer/FFITools.hx:111)
Calling macro ammer.Pointer.initType (?:1)
Exiting macro ammer.Pointer.initType
Calling macro ammer.Ammer.buildType (/Volumes/Vibranium/Users/damilare/haxe/haxe_libraries/ammer/0.0.1/github/9fe359b15fcdec1685c2bbe879f5e9c56c0ebcdc/src/ammer/FFITools.hx:111)
Exiting macro ammer.Ammer.buildType
Parsed /Volumes/Vibranium/Users/damilare/haxe/haxe_libraries/ammer/0.0.1/github/9fe359b15fcdec1685c2bbe879f5e9c56c0ebcdc/src/ammer/conv/ArrayWrapper.hx
/Volumes/Vibranium/Users/damilare/haxe/haxe_libraries/ammer/0.0.1/github/9fe359b15fcdec1685c2bbe879f5e9c56c0ebcdc/src/ammer/FFITools.hx:115: characters 9-59 : invalid FFI type for return

darmie avatar Aug 31 '21 17:08 darmie

Any idea what type is causing the error? You would get more information with -D ammer.debug=all.

Also, is this something that used to work with a previous version of Haxe?

Aurel300 avatar Aug 31 '21 19:08 Aurel300

The first time I used the library was when it was first announced and i think the tests worked.

I'll use the debug filter and give you feedback

darmie avatar Aug 31 '21 19:08 darmie

After adding the debug flag, I got these outputs

[ammer:stage] started type ammer.externs.AmmerArray_1.AmmerArray_1 (/Volumes/Vibranium/Users/damilare/haxe/haxe_libraries/ammer/0.0.1/github/9fe359b15fcdec1685c2bbe879f5e9c56c0ebcdc/src/ammer/Ammer.hx:876)
[ammer:stage] finalising type ammer.externs.AmmerArray_1.AmmerArray_1 (/Volumes/Vibranium/Users/damilare/haxe/haxe_libraries/ammer/0.0.1/github/9fe359b15fcdec1685c2bbe879f5e9c56c0ebcdc/src/ammer/Ammer.hx:593)
[ammer:stage] started type ammer.externs.AmmerArray_0.AmmerArray_0 (/Volumes/Vibranium/Users/damilare/haxe/haxe_libraries/ammer/0.0.1/github/9fe359b15fcdec1685c2bbe879f5e9c56c0ebcdc/src/ammer/Ammer.hx:876)
[ammer:stage] finalising type ammer.externs.AmmerArray_0.AmmerArray_0 (/Volumes/Vibranium/Users/damilare/haxe/haxe_libraries/ammer/0.0.1/github/9fe359b15fcdec1685c2bbe879f5e9c56c0ebcdc/src/ammer/Ammer.hx:593)
[ammer:stage] finished type ammer.externs.AmmerArray_0.AmmerArray_0 (/Volumes/Vibranium/Users/damilare/haxe/haxe_libraries/ammer/0.0.1/github/9fe359b15fcdec1685c2bbe879f5e9c56c0ebcdc/src/ammer/Ammer.hx:866)
[ammer:gen-type] private var ammerNative : cpp.Pointer<ammer.externs.AmmerExternType_4> (/Volumes/Vibranium/Users/damilare/haxe/haxe_libraries/ammer/0.0.1/github/9fe359b15fcdec1685c2bbe879f5e9c56c0ebcdc/src/ammer/Ammer.hx:902)
[ammer:gen-type] private function new(native:cpp.Pointer<ammer.externs.AmmerExternType_4>) {
        this.ammerNative = native;
} (/Volumes/Vibranium/Users/damilare/haxe/haxe_libraries/ammer/0.0.1/github/9fe359b15fcdec1685c2bbe879f5e9c56c0ebcdc/src/ammer/Ammer.hx:902)
[ammer:gen-type] public static function nullPointer() {
        return new ammer.externs.AmmerArray_0(null);
} (/Volumes/Vibranium/Users/damilare/haxe/haxe_libraries/ammer/0.0.1/github/9fe359b15fcdec1685c2bbe879f5e9c56c0ebcdc/src/ammer/Ammer.hx:902)
[ammer:gen-type] public static function alloc(_arg0:Int):ammer.externs.AmmerArray_0 return @:privateAccess stella.native.StellaNative._ammer_externs_AmmerArray_0_AmmerArray_0_alloc(_arg0) (/Volumes/Vibranium/Users/damilare/haxe/haxe_libraries/ammer/0.0.1/github/9fe359b15fcdec1685c2bbe879f5e9c56c0ebcdc/src/ammer/Ammer.hx:902)
[ammer:gen-type] public function get(_arg1:Int):Float return @:privateAccess stella.native.StellaNative._ammer_externs_AmmerArray_0_AmmerArray_0_get(this, _arg1) (/Volumes/Vibranium/Users/damilare/haxe/haxe_libraries/ammer/0.0.1/github/9fe359b15fcdec1685c2bbe879f5e9c56c0ebcdc/src/ammer/Ammer.hx:902)
[ammer:gen-type] public function set(_arg1:Int, _arg2:Float):Void return @:privateAccess stella.native.StellaNative._ammer_externs_AmmerArray_0_AmmerArray_0_set(this, _arg1, _arg2) (/Volumes/Vibranium/Users/damilare/haxe/haxe_libraries/ammer/0.0.1/github/9fe359b15fcdec1685c2bbe879f5e9c56c0ebcdc/src/ammer/Ammer.hx:902)
/Volumes/Vibranium/Users/damilare/haxe/haxe_libraries/ammer/0.0.1/github/9fe359b15fcdec1685c2bbe879f5e9c56c0ebcdc/src/ammer/FFITools.hx:115: characters 9-59 : invalid FFI type for return

It seems to be refering to this class

class StellaNative extends Library<"stella"> {
    public static function create_stella_demuxer_ptr():ammer.ffi.Alloc<DemuxerNative>;
    public static function create_stella_demuxer_cb_ptr():ammer.ffi.Alloc<DemuxerCBNative>;

    public static function create_stella_decoder_ptr():ammer.ffi.Alloc<DecoderNative>;
    public static function create_stella_decoder_cb_ptr():ammer.ffi.Alloc<DecoderCBNative>;
}

darmie avatar Aug 31 '21 19:08 darmie

@Aurel300 what do you think I might be doing wrong?

darmie avatar Aug 31 '21 20:08 darmie

I think I have fixed it... I removed the static functions and used their .alloc respectively... the code built

darmie avatar Aug 31 '21 21:08 darmie

It seems it was a false fix... I am getting this now

[ammer:stage] started type stella.backend.av.Demuxer.DemuxerNative (/Volumes/Vibranium/Users/damilare/haxe/haxe_libraries/ammer/0.0.1/github/9fe359b15fcdec1685c2bbe879f5e9c56c0ebcdc/src/ammer/Ammer.hx:876)
[ammer:stage] started StellaNative (library stella) (/Volumes/Vibranium/Users/damilare/haxe/haxe_libraries/ammer/0.0.1/github/9fe359b15fcdec1685c2bbe879f5e9c56c0ebcdc/src/ammer/Ammer.hx:484)
[ammer:gen-library] [] (/Volumes/Vibranium/Users/damilare/haxe/haxe_libraries/ammer/0.0.1/github/9fe359b15fcdec1685c2bbe879f5e9c56c0ebcdc/src/ammer/Ammer.hx:294)
[ammer:gen-library] {} (/Volumes/Vibranium/Users/damilare/haxe/haxe_libraries/ammer/0.0.1/github/9fe359b15fcdec1685c2bbe879f5e9c56c0ebcdc/src/ammer/Ammer.hx:295)
[ammer:gen-library] package ammer.externs;
@:headerCode("#include \"../ammer/ammer_stella.cpp.c\"") @:cppFileCode("#define AMMER_CODE_0\n#include \"../ammer/ammer_stella.cpp.c\"\n#undef AMMER_CODE_0") @:buildXml("<files id=\"haxe\">\n  <compilerflag value=\"-I/Volumes/Vibranium/Workspace/Zenturi/experiments/Stella/native/build/native/root/include\"/>\n</files>\n<target id=\"haxe\">\n  <libpath name=\"/Volumes/Vibranium/Workspace/Zenturi/experiments/Stella/native/build/native/libstella\"/>\n  <lib name=\"-lstella\" unless=\"windows\" />\n  <lib name=\"stella\" if=\"windows\" />\n</target>\n") class AmmerExtern_stella_0 {

} (/Volumes/Vibranium/Users/damilare/haxe/haxe_libraries/ammer/0.0.1/github/9fe359b15fcdec1685c2bbe879f5e9c56c0ebcdc/src/ammer/Ammer.hx:418)
[ammer:stage] finished StellaNative (library stella) (/Volumes/Vibranium/Users/damilare/haxe/haxe_libraries/ammer/0.0.1/github/9fe359b15fcdec1685c2bbe879f5e9c56c0ebcdc/src/ammer/Ammer.hx:518)
[ammer:stage] finalising type stella.backend.av.Demuxer.DemuxerNative (/Volumes/Vibranium/Users/damilare/haxe/haxe_libraries/ammer/0.0.1/github/9fe359b15fcdec1685c2bbe879f5e9c56c0ebcdc/src/ammer/Ammer.hx:593)
[ammer:stage] started type stella.backend.av.Demuxer.DemuxerCBNative (/Volumes/Vibranium/Users/damilare/haxe/haxe_libraries/ammer/0.0.1/github/9fe359b15fcdec1685c2bbe879f5e9c56c0ebcdc/src/ammer/Ammer.hx:876)
[ammer:stage] finalising type stella.backend.av.Demuxer.DemuxerCBNative (/Volumes/Vibranium/Users/damilare/haxe/haxe_libraries/ammer/0.0.1/github/9fe359b15fcdec1685c2bbe879f5e9c56c0ebcdc/src/ammer/Ammer.hx:593)
[ammer:stage] started type stella.backend.av.Decoder.DecoderNative (/Volumes/Vibranium/Users/damilare/haxe/haxe_libraries/ammer/0.0.1/github/9fe359b15fcdec1685c2bbe879f5e9c56c0ebcdc/src/ammer/Ammer.hx:876)
[ammer:stage] finalising type stella.backend.av.Decoder.DecoderNative (/Volumes/Vibranium/Users/damilare/haxe/haxe_libraries/ammer/0.0.1/github/9fe359b15fcdec1685c2bbe879f5e9c56c0ebcdc/src/ammer/Ammer.hx:593)
[ammer:stage] started type stella.backend.av.Decoder.DecoderCBNative (/Volumes/Vibranium/Users/damilare/haxe/haxe_libraries/ammer/0.0.1/github/9fe359b15fcdec1685c2bbe879f5e9c56c0ebcdc/src/ammer/Ammer.hx:876)
[ammer:stage] finalising type stella.backend.av.Decoder.DecoderCBNative (/Volumes/Vibranium/Users/damilare/haxe/haxe_libraries/ammer/0.0.1/github/9fe359b15fcdec1685c2bbe879f5e9c56c0ebcdc/src/ammer/Ammer.hx:593)
/Volumes/Vibranium/Users/damilare/haxe/haxe_libraries/ammer/0.0.1/github/9fe359b15fcdec1685c2bbe879f5e9c56c0ebcdc/src/ammer/FFITools.hx:237: characters 25-34 : Uncaught exception field access on null
/Volumes/Vibranium/Users/damilare/haxe/haxe_libraries/ammer/0.0.1/github/9fe359b15fcdec1685c2bbe879f5e9c56c0ebcdc/src/ammer/FFITools.hx:349: characters 12-67 : Called from here
/Volumes/Vibranium/Users/damilare/haxe/haxe_libraries/ammer/0.0.1/github/9fe359b15fcdec1685c2bbe879f5e9c56c0ebcdc/src/ammer/FFITools.hx:390: lines 390-395 : Called from here
/Volumes/Vibranium/Users/damilare/haxe/haxe_libraries/ammer/0.0.1/github/9fe359b15fcdec1685c2bbe879f5e9c56c0ebcdc/src/ammer/FFITools.hx:482: characters 12-65 : Called from here
/Volumes/Vibranium/Users/damilare/haxe/haxe_libraries/ammer/0.0.1/github/9fe359b15fcdec1685c2bbe879f5e9c56c0ebcdc/src/ammer/Ammer.hx:91: characters 15-62 : Called from here
/Volumes/Vibranium/Users/damilare/haxe/haxe_libraries/ammer/0.0.1/github/9fe359b15fcdec1685c2bbe879f5e9c56c0ebcdc/src/ammer/Ammer.hx:733: characters 11-38 : Called from here
/Volumes/Vibranium/Users/damilare/haxe/haxe_libraries/ammer/0.0.1/github/9fe359b15fcdec1685c2bbe879f5e9c56c0ebcdc/src/ammer/Ammer.hx:892: characters 15-58 : Called from here
src/stella/backend/av/Decoder.hx:14: character 1 : Called from here
/Volumes/Vibranium/Users/damilare/haxe/versions/4.2.1/std/haxe/macro/Context.hx:441: characters 10-34 : Called from here
/Volumes/Vibranium/Users/damilare/haxe/haxe_libraries/ammer/0.0.1/github/9fe359b15fcdec1685c2bbe879f5e9c56c0ebcdc/src/ammer/FFITools.hx:169: characters 11-70 : Called from here
/Volumes/Vibranium/Users/damilare/haxe/haxe_libraries/ammer/0.0.1/github/9fe359b15fcdec1685c2bbe879f5e9c56c0ebcdc/src/ammer/FFITools.hx:175: characters 5-26 : Called from here
/Volumes/Vibranium/Users/damilare/haxe/haxe_libraries/ammer/0.0.1/github/9fe359b15fcdec1685c2bbe879f5e9c56c0ebcdc/src/ammer/FFITools.hx:349: characters 12-67 : Called from here
/Volumes/Vibranium/Users/damilare/haxe/haxe_libraries/ammer/0.0.1/github/9fe359b15fcdec1685c2bbe879f5e9c56c0ebcdc/src/ammer/Ammer.hx:207: lines 207-211 : Called from here
/Volumes/Vibranium/Users/damilare/haxe/haxe_libraries/ammer/0.0.1/github/9fe359b15fcdec1685c2bbe879f5e9c56c0ebcdc/src/ammer/Ammer.hx:717: characters 21-71 : Called from here
/Volumes/Vibranium/Users/damilare/haxe/haxe_libraries/ammer/0.0.1/github/9fe359b15fcdec1685c2bbe879f5e9c56c0ebcdc/src/ammer/Ammer.hx:892: characters 15-58 : Called from here
src/stella/backend/av/Decoder.hx:38: character 1 : Called from here
/Volumes/Vibranium/Users/damilare/haxe/versions/4.2.1/std/haxe/macro/Context.hx:441: characters 10-34 : Called from here
/Volumes/Vibranium/Users/damilare/haxe/haxe_libraries/ammer/0.0.1/github/9fe359b15fcdec1685c2bbe879f5e9c56c0ebcdc/src/ammer/FFITools.hx:169: characters 11-70 : Called from here
/Volumes/Vibranium/Users/damilare/haxe/haxe_libraries/ammer/0.0.1/github/9fe359b15fcdec1685c2bbe879f5e9c56c0ebcdc/src/ammer/FFITools.hx:175: characters 5-26 : Called from here
/Volumes/Vibranium/Users/damilare/haxe/haxe_libraries/ammer/0.0.1/github/9fe359b15fcdec1685c2bbe879f5e9c56c0ebcdc/src/ammer/FFITools.hx:349: characters 12-67 : Called from here
/Volumes/Vibranium/Users/damilare/haxe/haxe_libraries/ammer/0.0.1/github/9fe359b15fcdec1685c2bbe879f5e9c56c0ebcdc/src/ammer/FFITools.hx:390: lines 390-395 : Called from here
/Volumes/Vibranium/Users/damilare/haxe/haxe_libraries/ammer/0.0.1/github/9fe359b15fcdec1685c2bbe879f5e9c56c0ebcdc/src/ammer/FFITools.hx:482: characters 12-65 : Called from here
/Volumes/Vibranium/Users/damilare/haxe/haxe_libraries/ammer/0.0.1/github/9fe359b15fcdec1685c2bbe879f5e9c56c0ebcdc/src/ammer/Ammer.hx:91: characters 15-62 : Called from here
/Volumes/Vibranium/Users/damilare/haxe/haxe_libraries/ammer/0.0.1/github/9fe359b15fcdec1685c2bbe879f5e9c56c0ebcdc/src/ammer/Ammer.hx:733: characters 11-38 : Called from here
/Volumes/Vibranium/Users/damilare/haxe/haxe_libraries/ammer/0.0.1/github/9fe359b15fcdec1685c2bbe879f5e9c56c0ebcdc/src/ammer/Ammer.hx:892: characters 15-58 : Called from here
src/stella/backend/av/Demuxer.hx:35: character 1 : Called from here
/Volumes/Vibranium/Users/damilare/haxe/versions/4.2.1/std/haxe/macro/Context.hx:441: characters 10-34 : Called from here
/Volumes/Vibranium/Users/damilare/haxe/haxe_libraries/ammer/0.0.1/github/9fe359b15fcdec1685c2bbe879f5e9c56c0ebcdc/src/ammer/FFITools.hx:169: characters 11-70 : Called from here
/Volumes/Vibranium/Users/damilare/haxe/haxe_libraries/ammer/0.0.1/github/9fe359b15fcdec1685c2bbe879f5e9c56c0ebcdc/src/ammer/FFITools.hx:175: characters 5-26 : Called from here
/Volumes/Vibranium/Users/damilare/haxe/haxe_libraries/ammer/0.0.1/github/9fe359b15fcdec1685c2bbe879f5e9c56c0ebcdc/src/ammer/FFITools.hx:349: characters 12-67 : Called from here
/Volumes/Vibranium/Users/damilare/haxe/haxe_libraries/ammer/0.0.1/github/9fe359b15fcdec1685c2bbe879f5e9c56c0ebcdc/src/ammer/Ammer.hx:207: lines 207-211 : Called from here
/Volumes/Vibranium/Users/damilare/haxe/haxe_libraries/ammer/0.0.1/github/9fe359b15fcdec1685c2bbe879f5e9c56c0ebcdc/src/ammer/Ammer.hx:717: characters 21-71 : Called from here
/Volumes/Vibranium/Users/damilare/haxe/haxe_libraries/ammer/0.0.1/github/9fe359b15fcdec1685c2bbe879f5e9c56c0ebcdc/src/ammer/Ammer.hx:892: characters 15-58 : Called from here
src/stella/backend/av/Demuxer.hx:49: character 1 : Called from here

Demuxer.hx

package stella.backend.av;

import stella.native.StellaNative;
// import stella.native.AppState;
import haxe.Constraints.Function;
import ammer.*;
import ammer.ffi.*;
import haxe.io.Bytes;
import haxe.Int64;

@:ammer.nativePrefix("stella_demuxer_")
@:ammer.struct
class DemuxerCBNative extends Pointer<"stella_demuxer_cb", StellaNative> {
    public function set_init_audio_cb(_:This, func:Closure<(channels:Int, rate:Int, _:ClosureDataUse)->Void, "forever">, _:ClosureData<"func">):Void;
    public function set_init_video_cb(_:This, func:Closure<(frameWidth:Int, frameHeight:Int,chromaWidth:Int, chromaHeight:Int, fps:Float, picWidth:Int, picHeight:Int, picX:Int, picY:Int, displayWidth:Int, displayHeight:Int, _:ClosureDataUse)->Void, "forever">, _:ClosureData<"func">):Void;
    public function set_loaded_metadata_cb(_:This, func:Closure<(videoCodec:String, audioCodec:String, _:ClosureDataUse)->Void, "forever">, _:ClosureData<"func">):Void;
    public function set_video_packet_cb(_:This, func:Closure<(buffer:Bytes, len:SizeOf<"buffer">, frameTimestamp:Float, keyframeTimestamp:Float, isKeyframe:Int, _:ClosureDataUse)->Void, "forever">, _:ClosureData<"func">):Void;
    public function set_audio_packet_cb(_:This, func:Closure<(buffer:Bytes, len:SizeOf<"buffer">, audioTimestamp:Float, discardPadding:Float, _:ClosureDataUse)->Void, "forever">, _:ClosureData<"func">):Void;
    public function set_frame_ready_cb(_:This, func:Closure<(_:ClosureDataUse)->Int, "forever">, _:ClosureData<"func">):Void;
    public function set_audio_ready_cb(_:This, func:Closure<(_:ClosureDataUse)->Int, "forever">, _:ClosureData<"func">):Void;
    public function set_seek_cb(_:This, func:Closure<(offset:Int64, _:ClosureDataUse)->Void, "forever">):Void;
}


@:ammer.nativePrefix("stella_demuxer_")
@:ammer.struct
class DemuxerNative extends Pointer<"stella_demuxer_t", StellaNative> {
    @:ammer.native("mediaType") public var mediaType:String;
    @:ammer.native("callbacks") public var callbacks:ammer.ffi.Nested<DemuxerCBNative>;
    @:ammer.native("hasVideo") public var hasVideo:Bool;
    @:ammer.native("videoTrack") public var videoTrack:UInt;
    @:ammer.native("videoCodec") public var videoCodec:Int;
    @:ammer.native("videoCodecName") public var videoCodecName:String;
    @:ammer.native("videoStream") public var videoStream:Int64;

    @:ammer.native("hasAudio") public var hasAudio:Bool;
    @:ammer.native("audioTrack") public var audioTrack:UInt;
    @:ammer.native("audioCodec") public var audioCodec:Int;
    @:ammer.native("audioCodecName") public var audioCodecName:String;
    @:ammer.native("audioStream") public var audioStream:Int64;

    @:ammer.native("seekTime") public var seekTime:Int64;
    @:ammer.native("seekTrack") public var seekTrack:UInt;
    @:ammer.native("startPosition") public var startPosition:Int64;
    @:ammer.native("lastKeyframeKimestamp") public var lastKeyframeKimestamp:Float;
    // @:ammer.native("appState") public var appState:AppState;

    public function init(_:This, type:String, callbacks:DemuxerCBNative):Void;
    public function receive_buffer(_:This, buffer:Bytes, bufSize:ammer.ffi.SizeOf<"buffer">):Void;
    public function process(_:This):Int;
    public function destroy(_:This):Void;
    public function flush(_:This):Void;
    public function media_length(_:This):Int64;
    public function media_duration(_:This):Float;
    public function seekable(_:This):Int;
    public function keypoint_offset(_:This, time_ms:Float):Int64;
    public function seek_to_keypoint(_:This, time_ms:Float):Int;
}


darmie avatar Aug 31 '21 23:08 darmie