diff --git a/Project.toml b/Project.toml index dae76a1..cfa87f5 100644 --- a/Project.toml +++ b/Project.toml @@ -4,13 +4,11 @@ authors = ["SteffenPL and contributors"] version = "0.1.0" [deps] -CEnum = "fa961155-64e5-5f13-b03f-caf6b980ea82" PortMidi_jll = "6b227df9-c220-5195-838c-e1464939a66f" [compat] PortMidi_jll = "2.0.4" julia = "1.6" -CEnum = "0.5" [extras] Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40" diff --git a/gen/generator.toml b/gen/generator.toml index dc0cf97..28479cf 100644 --- a/gen/generator.toml +++ b/gen/generator.toml @@ -4,12 +4,10 @@ output_file_path = "../src/PortMidi.jl" module_name = "PortMidi" jll_pkg_name = "PortMidi_jll" -# use_julia_native_enum_type = true +use_julia_native_enum_type = true -# prologue_file_path = "prologue.jl" -# epilogue_file_path = "epilogue.jl" +prologue_file_path = "prologue.jl" +epilogue_file_path = "epilogue.jl" -# export_symbol_prefixes = ["Pm"] -# output_ignorelist = ["TRUE", "FALSE"] - -ignore_pure_definition = false \ No newline at end of file +export_symbol_prefixes = ["Pm"] +output_ignorelist = ["TRUE", "FALSE"] \ No newline at end of file diff --git a/src/PortMidi.jl b/src/PortMidi.jl index 40f3ec5..e7fd36d 100644 --- a/src/PortMidi.jl +++ b/src/PortMidi.jl @@ -3,7 +3,8 @@ module PortMidi using PortMidi_jll export PortMidi_jll -using CEnum +to_c_type(::Type{<:AbstractString}) = Cstring # or Ptr{Cchar} +to_c_type(t::Type{<:Union{AbstractArray,Ref}}) = Ptr{eltype(t)} const PmQueue = Cvoid @@ -21,9 +22,9 @@ end const PortMidiStream = Cvoid -@cenum PmError::Int32 begin +@enum PmError::Int32 begin pmNoError = 0 - pmNoData = 0 + # pmNoData = 0 pmGotData = 1 pmHostError = -10000 pmInvalidDeviceId = -9999 @@ -163,7 +164,7 @@ function Pm_WriteSysEx(stream, when, msg) ccall((:Pm_WriteSysEx, libportmidi), PmError, (Ptr{PortMidiStream}, PmTimestamp, Ptr{Cuchar}), stream, when, msg) end -@cenum PtError::Int32 begin +@enum PtError::Int32 begin ptNoError = 0 ptHostError = -10000 ptAlreadyStarted = -9999 @@ -196,10 +197,6 @@ function Pt_Sleep(duration) ccall((:Pt_Sleep, libportmidi), Cvoid, (int32_t,), duration) end -const FALSE = 0 - -const TRUE = 1 - const PM_DEFAULT_SYSEX_BUFFER_SIZE = 1024 const PmStream = PortMidiStream @@ -252,4 +249,19 @@ const PM_FILT_TUNE = 1 << 0x06 const PM_FILT_SYSTEMCOMMON = ((PM_FILT_MTC | PM_FILT_SONG_POSITION) | PM_FILT_SONG_SELECT) | PM_FILT_TUNE +Pm_Message(status, data1, data2) = ((((data2) << 16) & 0xFF0000) | (((data1) << 8) & 0xFF00) | ((status) & 0xFF)) +Pm_MessageStatus(msg) = ((msg) & 0xFF) +Pm_MessageData1(msg) = (((msg) >> 8) & 0xFF) +Pm_MessageData2(msg) = (((msg) >> 16) & 0xFF) + +export Pm_Message, Pm_MessageStatus, Pm_MessageData1, Pm_MessageData2 + +# exports +const PREFIXES = ["Pm"] +for name in names(@__MODULE__; all=true), prefix in PREFIXES + if startswith(string(name), prefix) + @eval export $name + end +end + end # module