'Generate Cython code to match objects to buffer specializations.
First try to get a numpy dtype object and match it against the individual
specializations. If that fails, try naively to coerce the object
to each specialization, which obtains the buffer each time and tries
to match the format string.'

def _buffer_checks(self, buffer_types, pythran_types, pyx_code, decl_code, env):

    pyx_code.put_chunk(u'\n                                                                if    ndarray    is    not    None:\n                                                                                if    isinstance(arg,    ndarray):\n                                                                                                dtype    =    arg.dtype\n                                                                                                arg_is_pythran_compatible    =    True\n                                                                                elif    __pyx_memoryview_check(arg):\n                                                                                                arg_base    =    arg.base\n                                                                                                if    isinstance(arg_base,    ndarray):\n                                                                                                                dtype    =    arg_base.dtype\n                                                                                                else:\n                                                                                                                dtype    =    None\n                                                                                else:\n                                                                                                dtype    =    None\n\n                                                                                itemsize    =    -1\n                                                                                if    dtype    is    not    None:\n                                                                                                itemsize    =    dtype.itemsize\n                                                                                                kind    =    ord(dtype.kind)\n                                                                                                #    We    only    support    the    endianess    of    the    current    compiler\n                                                                                                byteorder    =    dtype.byteorder\n                                                                                                if    byteorder    ==    "<"    and    not    __Pyx_Is_Little_Endian():\n                                                                                                                arg_is_pythran_compatible    =    False\n                                                                                                if    byteorder    ==    ">"    and    __Pyx_Is_Little_Endian():\n                                                                                                                arg_is_pythran_compatible    =    False\n                                                                                                dtype_signed    =    kind    ==    \'i\'\n                                                                                                if    arg_is_pythran_compatible:\n                                                                                                                cur_stride    =    itemsize\n                                                                                                                for    dim,stride    in    zip(reversed(arg.shape),reversed(arg.strides)):\n                                                                                                                                if    stride    !=    cur_stride:\n                                                                                                                                                arg_is_pythran_compatible    =    False\n                                                                                                                                                break\n                                                                                                                                cur_stride    *=    dim\n                                                                                                                else:\n                                                                                                                                arg_is_pythran_compatible    =    not    (arg.flags.f_contiguous    and    arg.ndim    >    1)\n                                                ')
    pyx_code.indent(2)
    pyx_code.named_insertion_point('numpy_dtype_checks')
    self._buffer_check_numpy_dtype(pyx_code, buffer_types, pythran_types)
    pyx_code.dedent(2)
    for specialized_type in buffer_types:
        self._buffer_parse_format_string_check(pyx_code, decl_code, specialized_type, env)
