From c509179c8d9b5e8db40c1cc08b0655fb125bfd3f Mon Sep 17 00:00:00 2001 From: "mdevan.foobar" Date: Fri, 21 Nov 2008 06:07:14 +0000 Subject: [PATCH] Improved compatibility with Python 2.4, ready for 0.4 release. git-svn-id: http://llvm-py.googlecode.com/svn/trunk@48 8d1e9007-1d4e-0410-b67e-1979fd6579aa --- CHANGELOG | 2 +- README | 4 ++-- llvm/_core.c | 5 +++++ llvm/core.py | 10 ++++++++-- setup.py | 4 +++- www/src/download.txt | 3 ++- www/src/index.txt | 3 +++ 7 files changed, 24 insertions(+), 7 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 3fd8c03..0f201cf 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,5 @@ -0.4, in progress: +0.4, 21-Nov-2008: * Code cleanup, added license headers. * Added llvm.core.load_library_permanently() (Issue #12). diff --git a/README b/README index ac15ff7..6ef4275 100644 --- a/README +++ b/README @@ -25,8 +25,8 @@ Quickstart: 2. Unpack llvm-py, build and install: - $ tar jxvf llvm-py-0.3.tar.bz2 - $ cd llvm-py-0.3 + $ tar jxvf llvm-py-0.4.tar.bz2 + $ cd llvm-py-0.4 # Locate llvm-config, usually under /Release/bin $ sudo python setup.py install --llvm-config=/path/to/llvm-config diff --git a/llvm/_core.c b/llvm/_core.c index ea1ee70..1a03824 100644 --- a/llvm/_core.c +++ b/llvm/_core.c @@ -40,6 +40,11 @@ /* libc includes */ #include /* for malloc(), free() */ +/* Compatibility with Python 2.4: Py_ssize_t is not available. */ +#ifndef PY_SSIZE_T_MAX +typedef int Py_ssize_t; +#endif + /*===----------------------------------------------------------------------===*/ /* Modules */ diff --git a/llvm/core.py b/llvm/core.py index 7780ee7..de8f5e9 100644 --- a/llvm/core.py +++ b/llvm/core.py @@ -747,6 +747,12 @@ def check_is_callable(obj): return raise TypeError, "argument is neither a function nor a function pointer" +def _to_int(v): + if v: + return 1 + else: + return 0 + #===----------------------------------------------------------------------=== # Module @@ -1009,7 +1015,7 @@ class Type(object): `param_tys'. Set `var_arg' to True (default is False) for a variadic function.""" check_is_type(return_ty) - var_arg = 1 if var_arg else 0 # convert to int + var_arg = _to_int(var_arg) # ensure int params = unpack_types(param_tys) return _make_type(_core.LLVMFunctionType(return_ty.ptr, params, var_arg), TYPE_FUNCTION) @@ -1636,7 +1642,7 @@ class GlobalVariable(GlobalValue): return _core.LLVMIsGlobalConstant(self.ptr) def _set_is_global_constant(self, value): - value = 1 if value else 0 + value = _to_int(value) _core.LLVMSetGlobalConstant(self.ptr, value) global_constant = property(_get_is_global_constant, _set_is_global_constant) diff --git a/setup.py b/setup.py index 79baa76..92c308e 100644 --- a/setup.py +++ b/setup.py @@ -3,6 +3,8 @@ import sys, os from distutils.core import setup, Extension +LLVM_PY_VERSION = '0.4' + def _run(cmd): return os.popen(cmd).read().rstrip() @@ -72,7 +74,7 @@ def call_setup(llvm_config): setup( name='llvm-py', - version='0.4', + version=LLVM_PY_VERSION, description='Python Bindings for LLVM', author='Mahadevan R', author_email='mdevan.foobar@gmail.com', diff --git a/www/src/download.txt b/www/src/download.txt index e4ea610..3e621b9 100644 --- a/www/src/download.txt +++ b/www/src/download.txt @@ -1,7 +1,7 @@ Download ======== -The latest release is 0.3, released 8-Sep-2008 (link:#changelog[Changelog] +The latest release is 0.4, released 21-Nov-2008 (link:#changelog[Changelog] below). Download it here: @@ -10,6 +10,7 @@ Download it here: ````~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Release,Date,Package,Mirror ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +0.4,21-Nov-2008,http://llvm-py.googlecode.com/files/llvm-py-0.4.tar.bz2[llvm-py-0.4.tar.bz2],link:llvm-py-0.4.tar.bz2[llvm-py-0.4.tar.bz2] 0.3,8-Sep-2008,http://llvm-py.googlecode.com/files/llvm-py-0.3.tar.bz2[llvm-py-0.3.tar.bz2],link:llvm-py-0.3.tar.bz2[llvm-py-0.3.tar.bz2] 0.2.1,18-Jun-2008,http://llvm-py.googlecode.com/files/llvm-py-0.2.1.tar.bz2[llvm-py-0.2.1.tar.bz2],link:llvm-py-0.2.1.tar.bz2[llvm-py-0.2.1.tar.bz2] 0.2,15-Jun-2008,http://llvm-py.googlecode.com/files/llvm-py-0.2.tar.bz2[llvm-py-0.2.tar.bz2],link:llvm-py-0.2.tar.bz2[llvm-py-0.2.tar.bz2] diff --git a/www/src/index.txt b/www/src/index.txt index 384a571..e392f79 100644 --- a/www/src/index.txt +++ b/www/src/index.txt @@ -24,6 +24,9 @@ _LLVM 2.4_: Read link:userguide.html#llvm24[this] if you're using LLVM News ---- +21-Nov-2008:: + 0.4 released. Bug fixes, few additional APIs, code cleanup. + 8-Sep-2008:: 0.3 released. Passes, intrinsics, bitcode, assembly!