Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Conflicts: src/bdelta.cpp src/bdelta_python.cpp src/libbdelta.cpp
- Loading branch information
Showing
6 changed files
with
311 additions
and
276 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,20 @@ | ||
from distutils.core import setup, Extension | ||
from Cython.Distutils import build_ext | ||
|
||
ext_modules = [Extension( | ||
"bdelta", | ||
["src/bdelta.pyx", "src/libbdelta.cpp"], | ||
define_macros=[('TOKEN_SIZE', '2')], | ||
)] | ||
|
||
setup( | ||
name = 'BDelta', | ||
version='0.3.0', | ||
description='Python Bindings for BDelta', | ||
author='John Whitney', | ||
author_email='jjw@deltup.org', | ||
url='http://deltup.org', | ||
cmdclass = {'build_ext': build_ext}, | ||
ext_modules = ext_modules | ||
) | ||
|
||
setup(name='bdelta_python', | ||
version='0.2.3', | ||
description='Python Bindings for BDelta', | ||
author='John Whitney', | ||
author_email='jjw@deltup.org', | ||
url='http://deltup.org', | ||
ext_modules=[Extension('bdelta_python', ['src/bdelta_python.cpp'])], | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
cdef extern from "bdelta.h": | ||
ctypedef struct BDelta_Instance: | ||
pass | ||
|
||
ctypedef void *(*bdelta_readCallback)(void *handle, void *buf, unsigned place, unsigned num) | ||
BDelta_Instance *bdelta_init_alg(unsigned data1_size, unsigned data2_size, | ||
bdelta_readCallback cb, void *handle1, void *handle2, | ||
unsigned tokenSize) | ||
void bdelta_done_alg(BDelta_Instance *b) | ||
|
||
void bdelta_pass(BDelta_Instance *b, unsigned blockSize, unsigned minMatchSize, unsigned maxHoleSize, unsigned flags) | ||
|
||
void bdelta_swap_inputs(BDelta_Instance *b) | ||
void bdelta_clean_matches(BDelta_Instance *b, unsigned flags) | ||
|
||
unsigned bdelta_numMatches(BDelta_Instance *b) | ||
|
||
void bdelta_getMatch(BDelta_Instance *b, unsigned matchNum, | ||
unsigned *p1, unsigned *p2, unsigned *num) | ||
|
||
int bdelta_getError(BDelta_Instance *b) | ||
void bdelta_showMatches(BDelta_Instance *b) | ||
|
||
cdef enum PassFlags: | ||
BDELTA_GLOBAL, | ||
BDELTA_SIDES_ORDERED | ||
cdef enum CleanFlags: | ||
BDELTA_REMOVE_OVERLAP | ||
|
||
cdef void *readCallback(void *handle, void *buf, unsigned place, unsigned num): | ||
cdef char *str = <bytes>handle | ||
return str + ((place + 1) * 2); | ||
|
||
cdef class BDelta: | ||
cdef BDelta_Instance *_b | ||
cdef bytes str1, str2 | ||
|
||
def __cinit__(self, str1, str2): | ||
self.str1 = str1.encode('UTF-16') | ||
self.str2 = str2.encode('UTF-16') | ||
self._b = bdelta_init_alg(len(str1), len(str2), readCallback, <void*>self.str1, <void*>self.str2, 2) | ||
|
||
def __dealloc__(self): | ||
self.str1 = None | ||
self.str2 = None | ||
bdelta_done_alg(self._b) | ||
|
||
def b_pass(self, blockSize, minMatchSize, maxHoleSize, globalScope = False, sidesOrdered = False): | ||
bdelta_pass(self._b, blockSize, minMatchSize, maxHoleSize, | ||
(BDELTA_GLOBAL if globalScope else 0) | (BDELTA_SIDES_ORDERED if sidesOrdered else 0)) | ||
|
||
def matches(self): | ||
cdef unsigned p1, p2, num | ||
for i in xrange(bdelta_numMatches(self._b)): | ||
bdelta_getMatch(self._b, i, &p1, &p2, &num) | ||
yield (int(p1), int(p2), int(num)) |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.