Skip to content

Commit

Permalink
remove duplicate header stuff in C module
Browse files Browse the repository at this point in the history
  • Loading branch information
ctb committed Jun 15, 2016
1 parent 6fd301a commit 9f60602
Showing 1 changed file with 7 additions and 54 deletions.
61 changes: 7 additions & 54 deletions sourmash_lib/_minhash.cc
Original file line number Diff line number Diff line change
@@ -1,69 +1,22 @@
//
// Python 2/3 compatibility: PyInt and PyLong
//

// Must be first.
#include <Python.h>

#if (PY_MAJOR_VERSION >= 3)
#define PyInt_Check(arg) PyLong_Check(arg)
#define PyInt_AsLong(arg) PyLong_AsLong(arg)
#define PyInt_FromLong(arg) PyLong_FromLong(arg)
#endif

//
// Python 2/3 compatibility: PyBytes and PyString
// https://docs.python.org/2/howto/cporting.html#str-unicode-unification
//

#include "bytesobject.h"

//
// Python 2/3 compatibility: Module initialization
// http://python3porting.com/cextensions.html#module-initialization
//

#if PY_MAJOR_VERSION >= 3
#define MOD_ERROR_VAL NULL
#define MOD_SUCCESS_VAL(val) val
#define MOD_INIT(name) PyMODINIT_FUNC PyInit_##name(void)
#define MOD_DEF(ob, name, doc, methods) \
static struct PyModuleDef moduledef = { \
PyModuleDef_HEAD_INIT, name, doc, -1, methods, }; \
ob = PyModule_Create(&moduledef);
#else
#define MOD_ERROR_VAL
#define MOD_SUCCESS_VAL(val)
#define MOD_INIT(name) void init##name(void)
#define MOD_DEF(ob, name, doc, methods) \
ob = Py_InitModule3(name, methods, doc);
#endif

//
// Function necessary for Python loading:
//

extern "C" {
MOD_INIT(_minhash);
}


#include <string>
#include <set>
#include <map>
#include <exception>
#include <iostream>

#include "../third-party/smhasher/MurmurHash3.h"

typedef unsigned long long HashIntoType;
typedef std::set<HashIntoType> CMinHashType;
uint64_t _hash_murmur(const std::string& kmer);

#include "_minhash.hh"
#include "../third-party/smhasher/MurmurHash3.h"

////

#include "_minhash.hh"
extern "C" {
MOD_INIT(_minhash);
}

////

static int _MinHash_len(PyObject *);
static PyObject * _MinHash_concat_inplace(PyObject *, PyObject *);
Expand Down

0 comments on commit 9f60602

Please sign in to comment.