File: rabinkarp_gen.py

package info (click to toggle)
fastchunking 0.0.3-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 300 kB
  • sloc: cpp: 490; python: 384; makefile: 197
file content (30 lines) | stat: -rw-r--r-- 1,326 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import pybindgen


def generate(file_):
    mod = pybindgen.Module('_rabinkarprh')
    mod.add_include('"rabinkarp.h"')
    mod.add_container('std::list<unsigned int>', 'unsigned int', 'list')
    mod.add_container('std::list<double>', 'double', 'list')

    cls = mod.add_class('RabinKarpHash')
    cls.add_constructor([pybindgen.param('int', 'my_window_size'),
                         pybindgen.param('int', 'seed')])
    cls.add_method('set_threshold',
                   None,
                   [pybindgen.param('double', 'my_threshold')])
    cls.add_method('next_chunk_boundaries',
                   pybindgen.retval('std::list<unsigned int>'),
                   [pybindgen.param('std::string*', 'str'),
                    pybindgen.param('unsigned int', 'prepend_bytes')])

    cls = mod.add_class('RabinKarpMultiThresholdHash')
    cls.add_constructor([pybindgen.param('int', 'my_window_size'),
                         pybindgen.param('int', 'seed'),
                         pybindgen.param('std::list<double>', 'my_thresholds')])
    cls.add_method('next_chunk_boundaries_with_thresholds',
                   pybindgen.retval('std::list<unsigned int>'),
                   [pybindgen.param('std::string*', 'str'),
                    pybindgen.param('unsigned int', 'prepend_bytes')])

    mod.generate(file_)