Add deprecated module and deprecate alloca_array
This commit is contained in:
parent
f8c1c78df1
commit
b9752e1e98
3 changed files with 32 additions and 5 deletions
|
|
@ -34,7 +34,7 @@ def _extract_ptrs(objs):
|
|||
class LLVMException(Exception):
|
||||
pass
|
||||
|
||||
def test(verbosity=1):
|
||||
def test(verbosity=3):
|
||||
"""test(verbosity=1) -> TextTestResult
|
||||
|
||||
Run self-test, and return the number of failures + errors
|
||||
|
|
|
|||
10
llvm/core.py
10
llvm/core.py
|
|
@ -41,7 +41,7 @@ import contextlib, weakref
|
|||
|
||||
import llvm
|
||||
from llvm._intrinsic_ids import *
|
||||
|
||||
from llvm.deprecated import deprecated
|
||||
from llvmpy import api
|
||||
|
||||
#===----------------------------------------------------------------------===
|
||||
|
|
@ -2301,11 +2301,13 @@ class Builder(llvm.Wrapper):
|
|||
inst = self._ptr.Insert(malloc, name)
|
||||
return _make_value(inst)
|
||||
|
||||
def alloca(self, ty, name=""):
|
||||
return _make_value(self._ptr.CreateAlloca(ty._ptr, None, name))
|
||||
def alloca(self, ty, size=None, name=""):
|
||||
sizeptr = size._ptr if size else None
|
||||
return _make_value(self._ptr.CreateAlloca(ty._ptr, sizeptr, name))
|
||||
|
||||
@deprecated
|
||||
def alloca_array(self, ty, size, name=""):
|
||||
return _make_value(self._ptr.CreateAlloca(ty._ptr, size._ptr, name))
|
||||
return self.alloca(ty, size, name=name)
|
||||
|
||||
def free(self, ptr):
|
||||
free = api.llvm.CallInst.CreateFree(ptr._ptr, self.basic_block._ptr)
|
||||
|
|
|
|||
25
llvm/deprecated.py
Normal file
25
llvm/deprecated.py
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
"""
|
||||
Shameless borrowed from Smart_deprecation_warnings
|
||||
https://wiki.python.org/moin/PythonDecoratorLibrary
|
||||
"""
|
||||
|
||||
import warnings
|
||||
import functools
|
||||
|
||||
|
||||
def deprecated(func):
|
||||
"""This is a decorator which can be used to mark functions
|
||||
as deprecated. It will result in a warning being emitted
|
||||
when the function is used."""
|
||||
|
||||
@functools.wraps(func)
|
||||
def new_func(*args, **kwargs):
|
||||
warnings.warn_explicit(
|
||||
"Call to deprecated function {}.".format(func.__name__),
|
||||
category=DeprecationWarning,
|
||||
filename=func.func_code.co_filename,
|
||||
lineno=func.func_code.co_firstlineno + 1
|
||||
)
|
||||
return func(*args, **kwargs)
|
||||
|
||||
return new_func
|
||||
Loading…
Add table
Add a link
Reference in a new issue