调试器声明方法消息是未定义的,因为它嵌套在C中,如果是,我该如何更改
class LiveMIDI
module C
extend DL::Importer
dlload '/System/Library/Frameworks/CoreMIDI.framework/Versions/Current/CoreMIDI'
extern "int MIDIClientCreate(void *, void *, void *,void *)"
extern "int MIDIClientDispose(void *)"
extern "int MIDIGetNumberOfDestinations()"
extern "void * MIDIGetDestination(int)"
extern "int MIDIOutputPortCreate(void *, void *, void *)"
extern "void * MIDIPacketListInit(void *)"
extern "void * MIDIPacketListAdd(void *, int, void *, int, int, int, void *)"
extern "int MIDISend(void *, void *,void *)"
module CF
extend DL::Importer
dlload '/System/Library/Frameworks/CoreFoundation.framework/Versions/Current/CoreFoundation'
def _message(*args)
format = "C" * args.size
bytes = args.pack(format).to_ptr
packet_list = DL.malloc(256)
packet_ptr = C.mIDIPacketListInit(packet_list)
packet_ptr = C.mIDIPacketListAdd(packet_list, 256, packet_ptr, 0, 0, args.size, bytes)
C.mIDISend(@outport, @destination, packet_list)
extern "void * CFStringCreateWithCString (void *, char *, int)"
def open
client_name = CF.cFStringCreateWithString(nil, "RubyMIDI", 0)
@client = DL::PtrData.new(nil)
C.mIDIClientCreate(client_name, nil, nil, @client.ref)
port_name = CF.cFStringCreateWithString(nil, "Output", 0)
@output = DL::PttD6ata.new(nil)
C.mIDIOutputPortCreate(@client, port_name, @outport.ref)
num = C.mIDIGetNumberOfDestinations()
raise NoMIDIDestinations if num < 1
@destination = C.mIDIGetDestination(0)
end
def close
C.mIDIClientDispose(@client)
end
end
end
end
end