:param cm: a ClassManager object
            :type cm: :class:`ClassManager` object
            :param size: the total size of the buffer
            :type size: int
            :param insn: a raw buffer where are the instructions
            :type insn: string
            :param idx: a start address in the buffer
            :type idx: int

            :rtype: a generator of :class:`Instruction` objects

def get_instructions(self, cm, size, insn, idx):
        """
            :param cm: a ClassManager object
            :type cm: :class:`ClassManager` object
            :param size: the total size of the buffer
            :type size: int
            :param insn: a raw buffer where are the instructions
            :type insn: string
            :param idx: a start address in the buffer
            :type idx: int

            :rtype: a generator of :class:`Instruction` objects
        """
        self.odex = cm.get_odex_format()

        max_idx = size * calcsize('=H')
        if max_idx > len(insn):
            max_idx = len(insn)

        # Get instructions
        while idx < max_idx:
            obj = None
            classic_instruction = True

            op_value = insn[idx]

            #print "%x %x" % (op_value, idx)

            #payload instructions or extented/optimized instructions
            if (op_value == 0x00 or op_value == 0xff) and ((idx + 2) < max_idx):
                op_value = unpack('=H', insn[idx:idx + 2])[0]

                # payload instructions ?
                if op_value in DALVIK_OPCODES_PAYLOAD:
                    try:
                        obj = get_instruction_payload(op_value, insn[idx:])
                        classic_instruction = False
                    except struct.error:
                        warning("error while decoding instruction ...")

                elif op_value in DALVIK_OPCODES_EXTENDED_WIDTH:
                    try:
                        obj = get_extented_instruction(cm, op_value, insn[idx:])
                        classic_instruction = False
                    except struct.error as why:
                        warning("error while decoding instruction ..." +
                                why.__str__())

                # optimized instructions ?
                elif self.odex and (op_value in DALVIK_OPCODES_OPTIMIZED):
                    obj = get_optimized_instruction(cm, op_value, insn[idx:])
                    classic_instruction = False

            # classical instructions
            if classic_instruction:
                op_value = insn[idx]
                obj = get_instruction(cm, op_value, insn[idx:], self.odex)

            # emit instruction
            yield obj
            idx = idx + obj.get_length()