# Path: skema/omxil12.py
# OMX_STRING = String # OMX_Types.h: 124
# 
# Path: skema/omxil12.py
# OMX_VERSIONTYPE = union_OMX_VERSIONTYPE # OMX_Types.h: 236
# 
# Path: skema/omxil12.py
# OMX_UUIDTYPE = c_ubyte * 128 # OMX_Types.h: 126
# 
# Path: skema/omxil12.py
# class struct_anon_1(Structure):
#     pass
# 
# Path: skema/omxil12.py
# def OMX_GetComponentVersion(hComponent, pComponentName, pComponentVersion, pSpecVersion, pComponentUUID):
#     return ((cast(hComponent, POINTER(OMX_COMPONENTTYPE)).contents.GetComponentVersion) (hComponent, pComponentName, pComponentVersion, pSpecVersion, pComponentUUID))
# 
# Path: skema/omxil12.py
# def get_string_from_il_enum(enum, hint):
#     from skema import omxil12
#     for name, val in omxil12.__dict__.iteritems():
#         if enum == val:
#             if name.startswith(hint):
#                 return name
#     raise AttributeError
# 
# Path: skema/omxil12.py
# OMX_MAX_STRINGNAME_SIZE = 128
# 
# Path: skema/utils.py
# def log_api(line):
#     log_line ()
#     logging.info("")
#     log_line ()
#     logging.info("")
#     l = "[" + line  +"]"
#     logging.info(l)
#     lansi = "[skema] " + bcolors.BOLD + l + bcolors.ENDC
#     printit (lansi)
# 
# Path: skema/utils.py
# def log_line(line="", tabs=0):
#     if (line == ""):
#         lansi = "[skema] "
#         l = ""
#     else:
#         l = ('\t' * tabs) + "[" + line + "]"
#         lansi = "[skema] " + bcolors.WARNING + l + bcolors.ENDC
#     logging.info(l)
#     printit (lansi)
# 
# Path: skema/utils.py
# def log_param(param, val, tabs=0):
#     l = ('\t' * tabs) + "[" + param + " -> '" + val + "']"
#     lansi = "[skema] " + bcolors.WARNING + l + bcolors.ENDC
#     logging.info(l)
#     printit (lansi)
# 
# Path: skema/utils.py
# def log_result(tag, err):
#     log_line ()
#     if (err == "OMX_ErrorNone"):
#         l = "[" + tag + " -> '" + err + "']"
#         lansi = "[skema] " + bcolors.OKGREEN + l + bcolors.ENDC
#         logging.info(l)
#     else:
#         l = "[" + tag + " -> '" + err + "']"
#         lansi = "[skema] " + bcolors.FAIL + l + bcolors.ENDC
#         logging.error(l)
# 
#     printit (lansi)


import skema.tag
from skema.omxil12 import OMX_STRING
from skema.omxil12 import OMX_VERSIONTYPE
from skema.omxil12 import OMX_UUIDTYPE
from skema.omxil12 import struct_anon_1
from skema.omxil12 import OMX_GetComponentVersion
from skema.omxil12 import get_string_from_il_enum
from skema.omxil12 import OMX_MAX_STRINGNAME_SIZE
from skema.utils import log_api
from skema.utils import log_line
from skema.utils import log_param
from skema.utils import log_result
from ctypes import byref
from ctypes import create_string_buffer
from ctypes import c_ubyte
from ctypes import c_char
from ctypes import c_char_p
from ctypes import POINTER
from ctypes import cast
    """

    """
    def run(self, element, context):
        alias  = element.get('alias')
        name   = context.cnames[alias]
        log_api ("%s '%s'" % (element.tag, name))
        handle = context.handles[alias]
        cname = (c_ubyte * OMX_MAX_STRINGNAME_SIZE)()
        cversion = OMX_VERSIONTYPE()
        specversion = OMX_VERSIONTYPE()
        cuuid = OMX_UUIDTYPE()
        if (handle != None):
            omxerror = OMX_GetComponentVersion(handle, cast(cname, POINTER(c_char)),
                                               byref(cversion),
                                               byref(specversion),
                                               byref(cuuid))
            interror = int(omxerror & 0xffffffff)

            err = get_string_from_il_enum(interror, "OMX_Error")

            log_line ()
            msg = "Component Name : " + cast(cname, c_char_p).value
            log_line (msg, 1)

            log_line ()
            log_line ("Component Version", 1)
            for name, _ in struct_anon_1._fields_:
                log_param (name, str(getattr(cversion.s, name)), 2)


# Path: skema/omxil12.py
# OMX_STRING = String # OMX_Types.h: 124
# 
# Path: skema/omxil12.py
# OMX_VERSIONTYPE = union_OMX_VERSIONTYPE # OMX_Types.h: 236
# 
# Path: skema/omxil12.py
# OMX_UUIDTYPE = c_ubyte * 128 # OMX_Types.h: 126
# 
# Path: skema/omxil12.py
# class struct_anon_1(Structure):
#     pass
# 
# Path: skema/omxil12.py
# def OMX_GetComponentVersion(hComponent, pComponentName, pComponentVersion, pSpecVersion, pComponentUUID):
#     return ((cast(hComponent, POINTER(OMX_COMPONENTTYPE)).contents.GetComponentVersion) (hComponent, pComponentName, pComponentVersion, pSpecVersion, pComponentUUID))
# 
# Path: skema/omxil12.py
# def get_string_from_il_enum(enum, hint):
#     from skema import omxil12
#     for name, val in omxil12.__dict__.iteritems():
#         if enum == val:
#             if name.startswith(hint):
#                 return name
#     raise AttributeError
# 
# Path: skema/omxil12.py
# OMX_MAX_STRINGNAME_SIZE = 128
# 
# Path: skema/utils.py
# def log_api(line):
#     log_line ()
#     logging.info("")
#     log_line ()
#     logging.info("")
#     l = "[" + line  +"]"
#     logging.info(l)
#     lansi = "[skema] " + bcolors.BOLD + l + bcolors.ENDC
#     printit (lansi)
# 
# Path: skema/utils.py
# def log_line(line="", tabs=0):
#     if (line == ""):
#         lansi = "[skema] "
#         l = ""
#     else:
#         l = ('\t' * tabs) + "[" + line + "]"
#         lansi = "[skema] " + bcolors.WARNING + l + bcolors.ENDC
#     logging.info(l)
#     printit (lansi)
# 
# Path: skema/utils.py
# def log_param(param, val, tabs=0):
#     l = ('\t' * tabs) + "[" + param + " -> '" + val + "']"
#     lansi = "[skema] " + bcolors.WARNING + l + bcolors.ENDC
#     logging.info(l)
#     printit (lansi)
# 
# Path: skema/utils.py
# def log_result(tag, err):
#     log_line ()
#     if (err == "OMX_ErrorNone"):
#         l = "[" + tag + " -> '" + err + "']"
#         lansi = "[skema] " + bcolors.OKGREEN + l + bcolors.ENDC
#         logging.info(l)
#     else:
#         l = "[" + tag + " -> '" + err + "']"
#         lansi = "[skema] " + bcolors.FAIL + l + bcolors.ENDC
#         logging.error(l)
# 
#     printit (lansi)


# Path: skema/tags/OMX_GetComponentVersion.py
import skema.tag
from skema.omxil12 import OMX_STRING
from skema.omxil12 import OMX_VERSIONTYPE
from skema.omxil12 import OMX_UUIDTYPE
from skema.omxil12 import struct_anon_1
from skema.omxil12 import OMX_GetComponentVersion
from skema.omxil12 import get_string_from_il_enum
from skema.omxil12 import OMX_MAX_STRINGNAME_SIZE
from skema.utils import log_api
from skema.utils import log_line
from skema.utils import log_param
from skema.utils import log_result
from ctypes import byref
from ctypes import create_string_buffer
from ctypes import c_ubyte
from ctypes import c_char
from ctypes import c_char_p
from ctypes import POINTER
from ctypes import cast

    """

    """
    def run(self, element, context):
        alias  = element.get('alias')
        name   = context.cnames[alias]
        log_api ("%s '%s'" % (element.tag, name))
        handle = context.handles[alias]
        cname = (c_ubyte * OMX_MAX_STRINGNAME_SIZE)()
        cversion = OMX_VERSIONTYPE()
        specversion = OMX_VERSIONTYPE()
        cuuid = OMX_UUIDTYPE()
        if (handle != None):
            omxerror = OMX_GetComponentVersion(handle, cast(cname, POINTER(c_char)),
                                               byref(cversion),
                                               byref(specversion),
                                               byref(cuuid))
            interror = int(omxerror & 0xffffffff)

            err = get_string_from_il_enum(interror, "OMX_Error")

            log_line ()
            msg = "Component Name : " + cast(cname, c_char_p).value
            log_line (msg, 1)

            log_line ()
            log_line ("Component Version", 1)
            for name, _ in struct_anon_1._fields_:
                log_param (name, str(getattr(cversion.s, name)), 2)


            log_line ()