Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@cython.cfunc
@cython.nogil(False)
@cython.locals(x=cython.int)
@cython.returns(cython.int)
def cdef_nogil_false(x):
return x + 1
@cython.cfunc
@cython.returns(cython.long)
@cython.exceptval(-1)
def cdef_except(x):
if x == 0:
raise ValueError
return x+1
@cython.cfunc
@cython.inline
def cdef_inline(x) -> cython.double:
return x + 1
@cython.cfunc
def f(self, a):
return a*10
@cython.cfunc
@cython.locals(
css=cython.unicode,
c=cython.Py_UCS4,
start_pos=cython.Py_ssize_t,
pos=cython.Py_ssize_t,
length=cython.Py_ssize_t,
chunks=cython.list,
)
def _consume_url(css, pos):
"""Return (unescaped_url, new_pos)
The given pos is assumed to be just after the '(' of 'url('.
"""
length = len(css)
# http://dev.w3.org/csswg/css-syntax/#consume-a-url-token
@cython.cfunc
@cython.locals(
css=cython.unicode,
c=cython.Py_UCS4,
pos=cython.Py_ssize_t,
codepoint=cython.int,
)
def _consume_escape(css, pos):
r"""Return (unescaped_char, new_pos).
Assumes a valid escape: pos is just after '\' and not followed by '\n'.
"""
# http://dev.w3.org/csswg/css-syntax/#consume-an-escaped-character
hex_match = _HEX_ESCAPE_RE.match(css, pos)
if hex_match:
codepoint = int(hex_match.group(1), 16)
@cython.cfunc
def _index_access(index_code, indices):
indexing = ",".join([index_code(idx) for idx in indices])
return ('[%s]' if len(indices) == 1 else '(%s)') % indexing
@cython.cfunc
@cython.locals(
css=cython.unicode,
c=cython.Py_UCS4,
start_pos=cython.Py_ssize_t,
pos=cython.Py_ssize_t,
length=cython.Py_ssize_t,
max_pos=cython.Py_ssize_t,
)
def _consume_unicode_range(css, pos):
"""Return (range, new_pos)
The given pos is assume to be just after the '+' of 'U+' or 'u+'.
"""
# http://dev.w3.org/csswg/css-syntax/#consume-a-unicode-range-token
length = len(css)
@cython.cfunc
@cython.locals(
css=cython.unicode,
c=cython.Py_UCS4,
start_pos=cython.Py_ssize_t,
pos=cython.Py_ssize_t,
length=cython.Py_ssize_t,
chunks=cython.list,
)
def _consume_ident(css, pos):
"""Return (unescaped_value, new_pos).
Assumes pos starts at a valid identifier. See :func:`_is_ident_start`.
"""
# http://dev.w3.org/csswg/css-syntax/#consume-a-name
chunks = []
@cython.cfunc
def type_remove_ref(ty):
return "typename std::remove_reference<%s>::type" % ty