# Path: mididings/units/call.py
# class _CallBase(_Unit):
#     def __init__(self, function, async, cont):
#         def do_call(ev):
#             # add additional properties that don't exist on the C++ side
#             ev.__class__ = _event.MidiEvent
# 
#             # call the function
#             ret = function(ev)
# 
#             if ret is None or async:
#                 return None
#             elif isinstance(ret, _types.GeneratorType):
#                 # function is a generator, build list
#                 ret = list(ret)
#             elif not _misc.issequence(ret):
#                 ret = [ret]
# 
#             for ev in ret:
#                 ev._finalize()
#             return ret
# 
#         _Unit.__init__(self, _mididings.Call(do_call, async, cont))


from mididings.units.call import _CallBase
        from mididings import engine
import mididings.overload as _overload
import mididings.unitrepr as _unitrepr
import mididings.constants as _constants
import mididings.misc as _misc
import sys as _sys
import collections as _collections
#
# Copyright (C) 2008-2014  Dominic Sacré  <dominic.sacre@gmx.de>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#





class _Print(_CallBase):
    max_name_length = -1
    max_portname_length = -1
    portnames_used = False

    def __init__(self, name, portnames):
        if portnames is not None:
            _Print.portnames_used = True

        # find maximum name length
        if name:
            _Print.max_name_length = max(_Print.max_name_length, len(name))

        # using a separare object to do the actual printing avoids keeping
        # references back to this unit, thus preventing a cycle
        printer = _Printer(name, portnames)


# Path: mididings/units/call.py
# class _CallBase(_Unit):
#     def __init__(self, function, async, cont):
#         def do_call(ev):
#             # add additional properties that don't exist on the C++ side
#             ev.__class__ = _event.MidiEvent
# 
#             # call the function
#             ret = function(ev)
# 
#             if ret is None or async:
#                 return None
#             elif isinstance(ret, _types.GeneratorType):
#                 # function is a generator, build list
#                 ret = list(ret)
#             elif not _misc.issequence(ret):
#                 ret = [ret]
# 
#             for ev in ret:
#                 ev._finalize()
#             return ret
# 
#         _Unit.__init__(self, _mididings.Call(do_call, async, cont))


# Path: mididings/units/printing.py
from mididings.units.call import _CallBase
        from mididings import engine
import mididings.overload as _overload
import mididings.unitrepr as _unitrepr
import mididings.constants as _constants
import mididings.misc as _misc
import sys as _sys
import collections as _collections

#
# Copyright (C) 2008-2014  Dominic Sacré  <dominic.sacre@gmx.de>
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#





class _Print(_CallBase):
    max_name_length = -1
    max_portname_length = -1
    portnames_used = False

    def __init__(self, name, portnames):
        if portnames is not None:
            _Print.portnames_used = True

        # find maximum name length
        if name:
            _Print.max_name_length = max(_Print.max_name_length, len(name))

        # using a separare object to do the actual printing avoids keeping
        # references back to this unit, thus preventing a cycle
        printer = _Printer(name, portnames)


        _CallBase.__init__(self, printer, True, True)